({
content,
isMeta,
isVisibleInTranscriptOnly,
isVirtual,
isCompactSummary,
summarizeMetadata,
toolUseResult,
mcpMeta,
uuid,
timestamp,
imagePasteIds,
sourceToolAssistantUUID,
permissionMode,
origin,
}: {
content: string | ContentBlockParam[]
isMeta?: true
isVisibleInTranscriptOnly?: true
isVirtual?: true
isCompactSummary?: true
toolUseResult?: unknown // Matches tool's `Output` type
/** MCP protocol metadata to pass through to SDK consumers (never sent to model) */
mcpMeta?: {
_meta?: Record<string, unknown>
structuredContent?: Record<string, unknown>
}
uuid?: UUID | string
timestamp?: string
imagePasteIds?: number[]
// For tool_result messages: the UUID of the assistant message containing the matching tool_use
sourceToolAssistantUUID?: UUID
// Permission mode when message was sent (for rewind restoration)
permissionMode?: PermissionMode
summarizeMetadata?: {
messagesSummarized: number
userContext?: string
direction?: PartialCompactDirection
}
// Provenance of this message. undefined = human (keyboard).
origin?: MessageOrigin
})
| 458 | } |
| 459 | |
| 460 | export function createUserMessage({ |
| 461 | content, |
| 462 | isMeta, |
| 463 | isVisibleInTranscriptOnly, |
| 464 | isVirtual, |
| 465 | isCompactSummary, |
| 466 | summarizeMetadata, |
| 467 | toolUseResult, |
| 468 | mcpMeta, |
| 469 | uuid, |
| 470 | timestamp, |
| 471 | imagePasteIds, |
| 472 | sourceToolAssistantUUID, |
| 473 | permissionMode, |
| 474 | origin, |
| 475 | }: { |
| 476 | content: string | ContentBlockParam[] |
| 477 | isMeta?: true |
| 478 | isVisibleInTranscriptOnly?: true |
| 479 | isVirtual?: true |
| 480 | isCompactSummary?: true |
| 481 | toolUseResult?: unknown // Matches tool's `Output` type |
| 482 | /** MCP protocol metadata to pass through to SDK consumers (never sent to model) */ |
| 483 | mcpMeta?: { |
| 484 | _meta?: Record<string, unknown> |
| 485 | structuredContent?: Record<string, unknown> |
| 486 | } |
| 487 | uuid?: UUID | string |
| 488 | timestamp?: string |
| 489 | imagePasteIds?: number[] |
| 490 | // For tool_result messages: the UUID of the assistant message containing the matching tool_use |
| 491 | sourceToolAssistantUUID?: UUID |
| 492 | // Permission mode when message was sent (for rewind restoration) |
| 493 | permissionMode?: PermissionMode |
| 494 | summarizeMetadata?: { |
| 495 | messagesSummarized: number |
| 496 | userContext?: string |
| 497 | direction?: PartialCompactDirection |
| 498 | } |
| 499 | // Provenance of this message. undefined = human (keyboard). |
| 500 | origin?: MessageOrigin |
| 501 | }): UserMessage { |
| 502 | const m: UserMessage = { |
| 503 | type: 'user', |
| 504 | message: { |
| 505 | role: 'user', |
| 506 | content: content || NO_CONTENT_MESSAGE, // Make sure we don't send empty messages |
| 507 | }, |
| 508 | isMeta, |
| 509 | isVisibleInTranscriptOnly, |
| 510 | isVirtual, |
| 511 | isCompactSummary, |
| 512 | summarizeMetadata, |
| 513 | uuid: (uuid as UUID | undefined) || randomUUID(), |
| 514 | timestamp: timestamp ?? new Date().toISOString(), |
| 515 | toolUseResult, |
| 516 | mcpMeta, |
| 517 | imagePasteIds, |
no outgoing calls
no test coverage detected