33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- import type { FilePart , TextPart } from '@a2a-js/sdk' ;
6+ import type { FilePart , Message , TextPart } from '@a2a-js/sdk' ;
77import { v4 as uuid } from 'uuid' ;
88
99import type { UIFilePart , UIMessagePart } from '#modules/messages/types.ts' ;
@@ -18,25 +18,25 @@ import {
1818 getFileUri ,
1919} from './utils' ;
2020
21- export function processTextPart ( part : TextPart , messageId : string ) : UIMessagePart [ ] {
22- const parts : UIMessagePart [ ] = [ ] ;
23- const { metadata, text } = part ;
24- const trajectory = extractTrajectory ( metadata ) ;
25- const citation = extractCitation ( metadata ) ;
21+ export function processMessageMetadata ( message : Message ) : UIMessagePart [ ] {
22+ const trajectory = extractTrajectory ( message . metadata ) ;
23+ const citation = extractCitation ( message . metadata ) ;
2624
2725 if ( trajectory ) {
28- parts . push ( createTrajectoryPart ( trajectory ) ) ;
26+ return [ createTrajectoryPart ( trajectory ) ] ;
2927 } else if ( citation ) {
30- const sourcePart = createSourcePart ( citation , messageId ) ;
28+ const sourcePart = createSourcePart ( citation , message . messageId ) ;
3129
3230 if ( sourcePart ) {
33- parts . push ( sourcePart ) ;
31+ return [ sourcePart ] ;
3432 }
3533 }
3634
37- parts . push ( createTextPart ( text ) ) ;
35+ return [ ] ;
36+ }
3837
39- return parts ;
38+ export function processTextPart ( { text } : TextPart ) : UIMessagePart [ ] {
39+ return [ createTextPart ( text ) ] ;
4040}
4141
4242export function processFilePart ( part : FilePart ) : UIMessagePart [ ] {
0 commit comments