(opts: {
text: string
data?: unknown
files?: A2AFileInput[]
taskId?: string
contextId?: string
})
| 247 | |
| 248 | /** Construct a user `Message` with a text part plus optional data and file parts. */ |
| 249 | export function buildUserMessage(opts: { |
| 250 | text: string |
| 251 | data?: unknown |
| 252 | files?: A2AFileInput[] |
| 253 | taskId?: string |
| 254 | contextId?: string |
| 255 | }): Message { |
| 256 | const parts: Part[] = [textPart(opts.text)] |
| 257 | if (opts.data !== undefined) parts.push(dataPart(opts.data)) |
| 258 | for (const file of opts.files ?? []) parts.push(filePart(file)) |
| 259 | return { |
| 260 | messageId: generateId(), |
| 261 | contextId: opts.contextId ?? '', |
| 262 | taskId: opts.taskId ?? '', |
| 263 | role: Role.ROLE_USER, |
| 264 | parts, |
| 265 | metadata: undefined, |
| 266 | extensions: [], |
| 267 | referenceTaskIds: [], |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | function partsText(parts: Part[]): string { |
| 272 | return parts |
no test coverage detected