(params: UserMessageParams)
| 313 | } |
| 314 | |
| 315 | export function buildPersistedUserMessage(params: UserMessageParams): PersistedMessage { |
| 316 | const message: PersistedMessage = { |
| 317 | id: params.id, |
| 318 | role: 'user', |
| 319 | content: params.content, |
| 320 | timestamp: new Date().toISOString(), |
| 321 | } |
| 322 | |
| 323 | if (params.fileAttachments && params.fileAttachments.length > 0) { |
| 324 | message.fileAttachments = params.fileAttachments |
| 325 | } |
| 326 | |
| 327 | if (params.contexts && params.contexts.length > 0) { |
| 328 | message.contexts = params.contexts.map((c) => ({ |
| 329 | kind: c.kind, |
| 330 | label: c.label, |
| 331 | ...(c.workflowId ? { workflowId: c.workflowId } : {}), |
| 332 | ...(c.knowledgeId ? { knowledgeId: c.knowledgeId } : {}), |
| 333 | ...(c.tableId ? { tableId: c.tableId } : {}), |
| 334 | ...(c.fileId ? { fileId: c.fileId } : {}), |
| 335 | ...(c.folderId ? { folderId: c.folderId } : {}), |
| 336 | ...(c.chatId ? { chatId: c.chatId } : {}), |
| 337 | })) |
| 338 | } |
| 339 | |
| 340 | return message |
| 341 | } |
| 342 | |
| 343 | // --------------------------------------------------------------------------- |
| 344 | // Read: raw JSONB → PersistedMessage |
no outgoing calls
no test coverage detected