Message Parts

All message parts extend BasePart which provides a stable id: string. The ChatMessagePart union is the discriminated union of every part type below, keyed on the type field.

Part Types

Type StringInterfaceKey FieldsDescription
textTextParttextFinal assembled plain text.
text-deltaTextDeltaPartdeltaStreaming text fragment. Accumulated into a TextPart on completion.
markdownMarkdownPartmarkdownMarkdown-formatted content.
citationCitationParttitle, url, snippet?Source citation with a link.
suggestion-chipsSuggestionChipPartchips[], payloadVersion?Tappable suggestion chips. Each chip has label and optional value.
product-carouselProductCarouselPartproducts[], payloadVersion?Horizontal product carousel.
order-summaryOrderSummaryPartorderId, items[], subtotal, total, payloadVersion?Order summary with line items and totals.
customCustomPayloadPartpayloadType, data, payloadVersion?Arbitrary payload for app-specific rendering.
tool-callToolCallParttoolCallId, toolName, input, status, output?, error?Agent-initiated tool invocation and its lifecycle.
tool-resultToolResultParttoolCallId, toolName, output, error?Result returned from a tool execution.
fileFilePartattachmentId?, fileName, mimeType, sizeBytes, url?, uploadStatus?, uploadProgress?, lifecycleStatus?, preview?, scanStatus?Attached file with upload lifecycle metadata. File bytes are never stored in the part.
agent-transferAgentTransferPartstatus, targetAgent?, reason?, queuePosition?, estimatedWaitTime?Live-agent handoff status.
diagnosticDiagnosticPartcategory, message, details?, timestampInternal diagnostic event surfaced as a part.
end-sessionEndSessionPartreason, message?Session termination marker.
errorErrorPartcode, message, userMessage?, developerHint?, docsUrl?, retryable?Structured error surfaced inline in the message stream.
audio-inputAudioInputPartmimeType, status, durationMs?, sampleRate?, channels?, url?, retained?User-captured audio. status flows `capturing → completed
audio-outputAudioOutputPartmimeType, status, durationMs?, sampleRate?, url?, retained?, playedUpToMs?Model-generated audio. status flows `streaming → completed
transcriptTranscriptPartrole, text, interim, confidence?, language?, audioRefId?STT output. Interim transcripts are replaced in place when finalized.
audio-cueAudioCuePartcue, responseId?, metadata?Side-channel voice signal (end-of-turn, barge-in, speech-started, silence-threshold-hit, session-ready, session-ended).
visionVisionPartkind, mimeType, url?, data?, width?, height?, altText?, caption?, sizeBytes?First-class image input or output. `kind: 'input'
memory-approvalMemoryApprovalPartoperation, entryId?, payload, statusLong-term memory write awaiting user approval (save/update/delete).
memory-recall-resultMemoryRecallResultPartquery?, entries[]Result of a memory.recall tool call.
sentiment-signalSentimentSignalPartcategory, score, confidence, polarity, source, latencyMs, attributedMessageId?Sentiment classification, default sr-only renderer.
intent-signalIntentSignalPartintent, score, confidence, source, latencyMs, attributedMessageId?Inferred intent classification, default sr-only renderer.
computer-use-surfaceComputerUseSurfacePartsessionId, state, streamUrl?, actionLog[], error?Sandboxed browser action stream. Default renderer is <ComputerUseSurface>.
a2ui-surfaceA2UISurfacePartsurfaceId, state, components, dataModel?Agent-to-UI generative surface.

ToolCallPart Status Values

StatusMeaning
requestedServer requested the tool call.
awaiting_approvalWaiting for user/host approval.
pending_supervisorWaiting for a supervisor approval workflow.
async_pendingAccepted for asynchronous server-side completion.
approvedApproved, ready to execute.
deniedUser or policy denied the call.
executingHandler is running.
completedExecution succeeded.
failedExecution threw an error.
timed_outExecution exceeded timeoutMs.
duplicateServer replay protection detected a repeated idempotency key.

Server actions may also attach idempotencyKey, duplicateDisposition, and approvalPolicy to ToolCallPart so the UI can explain replay and approval state without inspecting raw tool input.

FilePart Upload Status Values

uploadStatus is the coarse, backwards-compatible status. New attachment UIs should prefer lifecycleStatus when present.

StatusMeaning
pendingFile selected, upload not started.
uploadingUpload in progress (uploadProgress updates).
completedUpload succeeded, url is populated.
failedUpload failed.

FilePart Lifecycle Values

LifecycleMeaning
selectedThe user selected a file and the SDK created an attachment id.
validatingMIME type, size, count, and customer policy checks are running.
rejectedValidation failed before upload.
queuedValidation passed and upload is queued.
uploadingBytes are being sent to the mock adapter, proxy route, or custom adapter.
uploadedUpload completed; scan or ready-to-send processing may still follow.
scan_pendingA proxy scan hook is pending. The reference proxy uses a metadata-only fake hook by default.
scan_failedThe scan hook rejected the attachment.
ready_to_sendThe SDK staged a typed file part for the next user turn.
sentThe file part was included in a user message.
failedUpload failed after validation. Retry may be available.
removedThe attachment was removed and will not be sent.

preview contains safe metadata only: { kind, fileName, mimeType, sizeBytes }. It does not contain file contents, text snippets, HTML, base64, or object URLs. Host apps can render their own local previews, but debug bundles and message parts should stay metadata-only.

EndSessionPart Reason Values

ReasonMeaning
completedNatural conversation end.
timeoutSession timed out.
errorSession ended due to an error.
user_endedUser explicitly ended the session.
agent_endedAgent ended the session.
handoff_completedHandoff to a live agent completed.

AudioInputPart Status Values

StatusMeaning
capturingMic is open and recording.
completedCapture finished, audio sent to provider.
cancelledCapture cancelled (push-to-talk released without speaking, etc.).
failedCapture failed (device error, permission revoked mid-session).

AudioOutputPart Status Values

StatusMeaning
streamingProvider is emitting audio frames.
completedPlayback finished naturally.
interruptedBarge-in interrupted playback; playedUpToMs records the offset.

AudioCuePart Cue Values

CueMeaning
session-readyVoiceSession is open and listening.
session-endedVoiceSession is closing.
speech-startedProvider VAD detected user speech (drives barge-in).
silence-threshold-hitVAD detected end of user speech.
end-of-turnTurn boundary (either explicit pushToTalk('release') or provider-detected).
barge-inEmitted by the SDK after the arbiter has interrupted an in-flight assistant turn.

VisionPart Kind Values

KindMeaning
inputUser-uploaded image attached to a user turn.
outputModel-generated image returned in an assistant turn.

Type Guards

Every part type has a corresponding type guard exported from gecx-chat:

import { isTextPart, isToolCallPart, isSuggestionChipsPart } from 'gecx-chat';

for (const part of message.parts) {
  if (isTextPart(part)) { /* part is TextPart */ }
  if (isToolCallPart(part)) { /* part is ToolCallPart */ }
}

Base set: isTextPart, isTextDeltaPart, isMarkdownPart, isCitationPart, isSuggestionChipsPart, isProductCarouselPart, isOrderSummaryPart, isCustomPayloadPart, isToolCallPart, isToolResultPart, isFilePart, isAgentTransferPart, isDiagnosticPart, isEndSessionPart, isErrorPart, isA2UISurfacePart.

Voice and multimodal: isAudioInputPart, isAudioOutputPart, isTranscriptPart, isAudioCuePart, isVisionPart.

Memory: isMemoryApprovalPart, isMemoryRecallResultPart.

Signals: isSentimentSignalPart, isIntentSignalPart, and a combined isSignalPart that matches either.

Computer-use: isComputerUseSurfacePart.

Builders

Factory functions for constructing parts without hand-rolling the shape:

import { textPart, chipsPart, toolCallPart } from 'gecx-chat';

const text = textPart('Hello');
const chips = chipsPart([{ label: 'Yes' }, { label: 'No' }]);

Available builders: textPart, markdownPart, citationPart, chipsPart, toolCallPart, toolResultPart, productCarouselPart, orderSummaryPart, errorPart, diagnosticPart, agentTransferPart, endSessionPart, filePart, customPart, plus voice builders (audioInputPart, audioOutputPart, transcriptPart, audioCuePart, visionPart), signal builders (sentimentSignalPart, intentSignalPart), and memoryApprovalPart / memoryRecallResultPart.

ChatMessage

The envelope that wraps an array of parts:

FieldTypeDescription
idstringUnique message identifier.
role'user' | 'agent'Message author.
status'pending' | 'streaming' | 'completed' | 'error'Current message lifecycle state.
createdAtstringISO 8601 timestamp.
sessionIdstringOwning session identifier.
turnIndexnumberZero-based turn index in the conversation.
responseIdstring?Transport response identifier (agent messages).
partsChatMessagePart[]Ordered array of message parts.
metadataRecord<string, unknown>?Arbitrary metadata.
rawResponse{ events: TransportEvent[] }?Raw transport events (when preserveRawResponses is enabled).
Source: docs/reference/message-parts.md