Skip to content

Data models and frame schemas

This page centralizes observable session data models, transcript record families, bridge/control frames, and protocol-shaped message families. It is intentionally schema-oriented; narrative flows remain in the session and protocol pages.

Scope and caveats

  • These are reconstructed shapes from source-visible strings and existing implementation docs, not official public JSON Schemas.
  • cli.js is minified; exact object validation and optional fields can be mode- or feature-gate-dependent.
  • External consumers should validate liberally and prefer live SDK/runtime schemas when available.

Source anchors

Semantic aliasSourceApproximate locationString or symbolMeaning
LocalJsonlTranscriptSourcecli.jsline ~11, byte 0xd67ctranscriptSource:"local-jsonl"Sessions default to local JSONL transcript storage.
CurrentSessionJsonlNamecli.jsline ~486, byte 0x30ac6c`${v$()}.jsonl`Current-session JSONL file naming.
SessionDiscoverycli.jsline ~2773, byte 0x79bffeasync function jHHResume/latest-session discovery.
TranscriptRestorecli.jsline ~9514, byte 0xc8b15aasync function OG8Transcript restore into the live envelope.
TranscriptRecordercli.jsline ~8884, byte 0xb8b07arecordTranscriptDurable transcript append/export surface.
FileHistorySnapshotRecordercli.jsline ~8884, byte 0xb8b108recordFileHistorySnapshotFile-history snapshot storage.
ContextCollapseSnapshotRecordercli.jsline ~8884, byte 0xb8b12arecordContextCollapseSnapshotContext-collapse snapshot storage.
SdkSessionStoreAdaptercli.jsline ~7249, byte 0xb3aaa5sessionStoreSDK/external storage adapter hook.
SessionStateFramecli.jsline ~2004, byte 0x518f8csession_state_changedRuntime/session state stream frame.
TranscriptMirrorFramecli.jsline ~2004, byte 0x517c48transcript_mirrorTranscript mirror stream frame.
BridgeStateFramecli.jsline ~19356, byte 0xdaf5aabridge_stateRemote bridge state stream frame.
ControlRequestFramecli.jsline ~2004, byte 0x519ca7control_requestHost/SDK control request frame.
ControlResponseFramecli.jsline ~2621, byte 0x64e931control_responseHost/bridge control response event type.
PermissionResponseFramecli.jsline ~64, byte 0x39a71permission_responsePermission response/control frame.
BridgeToolCallFieldscli.jsline ~64, byte 0x3630etarget_device_id, permission_mode, allowed_domainsBrowser/MCP bridge tool-call frame fields.
PermissionResponseFieldscli.jsline ~64, byte 0x39a86request_id, allowedPermission response payload fields.
RemoteControlRequestRequirementcli.jsline ~791, byte 0x43cee0sendControlRequest not yet wiredRemote transport wrapper requires a concrete sendControlRequest implementation.
WebSocketAuthFdcli.jsline ~2624, byte 0x6516a5CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTORRemote/session ingress token source for bridge auth.
SessionAccessTokencli.jsline ~2624, byte 0x6519e7CLAUDE_CODE_SESSION_ACCESS_TOKENSession access token source for remote/bridge auth.

Session model

LayerObservable fields or recordsResponsibility
Session identitySession UUID, JSONL filename, optional alias/name.Stable address for local, resumed, forked, and remote-projected state.
Durable transcriptUser/assistant messages, tool use/results, hook/event records, context-collapse records.Append and replay history for restore/continue/fork.
Live envelopeModel state, cwd, permission mode, visible tools, hooks, agents/tasks, bridge state.Process-time runtime state rebuilt from flags/settings/transcript.
Metadata/indexTitle/summary, cwd, git branch/tag, timestamps, alias records.Session picker, latest-session discovery, and restore metadata.
File/checkpoint stateFile-history snapshots, leaf checkpoints, context-collapse snapshots.Rewind and checkpoint restore.
External mirrorsessionStore, transcript_mirror frames.Optional SDK/external mirroring fed by local persistence.

Transcript record families

Record familyTypical contentsOwner
Message recordsRole, content blocks, model/tool-use IDs, timestamps.Session transcript and context restore.
Tool recordsTool name, tool input/result, errors, permission/denial metadata.Tool execution and permission pages.
Hook/event recordsHook name, event input/output, decision or observation metadata.Hook runtime and audit trail.
File-history recordsPaths, snapshots, checkpoint IDs, restore metadata.Rewind/checkpoint mechanics.
Context-collapse recordsSummary/replacement metadata, token-savings metadata, commit records.Context compaction.
Sidechain/subagent recordsParent session ID, task/subagent transcript linkage.Agent/task runtime.
Queue/control recordsPending task/control operations and bridge messages.SDK/remote/task control plane.

Stream and control frame families

Frame or subtypeDirectionObservable role
session_state_changedruntime → SDK/hostSession state changed.
transcript_mirrorruntime → SDK/external storeLocal JSONL line mirrored outward.
bridge_stateruntime → remote hostRemote bridge status changed.
control_requestruntime → hostRuntime asks a host to approve or perform control-plane work.
control_responsehost → runtimeHost resolves a prior control request.
permission_responsehost → runtimeHost returns a tool permission decision.
permission_deniedruntime → host/SDK/model resultTool call was denied without an ask-style approval path.
task_started, task_updated, task_progress, task_notificationruntime → host/modelTask or subagent lifecycle/progress output.
prompt_suggestionruntime → SDK/hostPredicted next prompt when enabled.
rate_limit_eventprovider/runtime → SDK/hostRate-limit/quota state surfaced to consumers.
relevant_memoriesmemory subsystem → model/contextMemory recall surfaced for a turn.
elicitation_completeMCP/runtime → SDK/hostMCP URL-mode elicitation completed.

Permission/control shape

ShapeKey fields visible in docsNotes
Tool permission requesttool name, tool input, tool-use ID, optional agent/task context.Used before tool execution for ask-style decisions.
Tool permission denialtool name, tool-use ID, reason type, reason/message, optional agent ID.Can become permission_denied frame and model-visible denial result.
PreToolUse resultdecision (allow, ask, deny, defer), updatedInput, additionalContext, reason.Participates in authorization and input mutation.
Host control responserequest ID plus decision/response payload.Resolves a control_request.

Remote and bridge frame shape notes

The source-visible frame schemas are not a complete public protocol specification, but several payload shapes are now anchored enough to document safely.

Frame or objectDirectionSource-visible fieldsInterpretation
Bridge tool callruntime → bridge/servertype:"tool_call", tool_use_id, client_type, tool, args, optional target_device_id, permission_mode, allowed_domains, handle_permission_prompts, session_scopeRemote/browser-backed tools are sent as typed JSON frames with the original tool name and arguments plus policy/session hints.
Permission responsebridge/server → runtimetype:"permission_response", request_id, allowed, optional target_device_idThe host resolves an ask-style permission prompt for a specific request.
Remote bridge stateruntime → SDK/hosttype:"system", subtype:"bridge_state", state, detail, uuid, session_idRemote Control initialization and state changes are emitted as system stream frames.
Remote transport wrapperin-process runtime objectkind, isRemoteMode, viewerOnly, sessionId, sendMessage, cancelRequest, disconnect, sendControlRequestThe local runtime wraps remote transports behind a common control interface; viewer-only transports cannot send control requests.
Control response eventhost/bridge → runtimepayload.type or event_type equals control_responseControl responses are routed as bridge events and pass device-attestation checks before being accepted.

Remote Control frame detail remains feature-gate and transport dependent. Consumers should treat these shapes as observed bundle anchors, not as a frozen external API, and should keep accepting unknown optional fields.

Remote/session storage areas

Storage areaEvidenceWhat is stored
Project/session transcriptsprojects, `${sessionId}.jsonl`, recordTranscriptAppend-only JSONL transcript and session records.
Session metadata/indexlistSessions, getSessionInfo, alias/metadata restore helpersPicker/latest-session metadata.
File history/checkpointsrecordFileHistorySnapshot, checkpoint/rewind surfacesSnapshots used for rewind and restore.
Context-collapse datarecordContextCollapseSnapshot, collapse commit/replacement recordsCompaction metadata and summary replacement records.
Sidechain/subagent transcriptssidechain/subagent transcript loadersSubagent/task history separate from the main transcript view.
Remote metadataremote-agent and bridge-session metadata helpersRemote/bridge/agent metadata linked to a local session.
Queuesqueue operation records and task message handlingPending task/control messages.
Debug/ops logsdebug log env vars and latest symlinkOperational logs outside the transcript.

Created and maintained by Yingting Huang.