MCPcopy Index your code
hub / github.com/simstudioai/sim / buildUserMessage

Function buildUserMessage

apps/sim/lib/a2a/client.ts:249–269  ·  view source on GitHub ↗
(opts: {
  text: string
  data?: unknown
  files?: A2AFileInput[]
  taskId?: string
  contextId?: string
})

Source from the content-addressed store, hash-verified

247
248/** Construct a user `Message` with a text part plus optional data and file parts. */
249export 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
271function partsText(parts: Part[]): string {
272 return parts

Callers 2

client.test.tsFile · 0.90
route.tsFile · 0.90

Calls 5

generateIdFunction · 0.90
dataPartFunction · 0.85
filePartFunction · 0.85
textPartFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected