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.renamed.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 aliasString or symbolMeaning
LocalJsonlTranscriptSourcetranscriptSource:"local-jsonl"Sessions default to local JSONL transcript storage.
CurrentSessionJsonlName`${v$()}.jsonl`Current-session JSONL file naming.
SessionDiscoveryasync function jHHResume/latest-session discovery.
TranscriptRestoreasync function OG8Transcript restore into the live envelope.
TranscriptRecorderrecordTranscriptDurable transcript append/export surface.
FileHistorySnapshotRecorderrecordFileHistorySnapshotFile-history snapshot storage.
ContextCollapseSnapshotRecorderrecordContextCollapseSnapshotContext-collapse snapshot storage.
SdkSessionStoreAdaptersessionStoreSDK/external storage adapter hook.
SessionStateFramesession_state_changedRuntime/session state stream frame.
TranscriptMirrorFrametranscript_mirrorTranscript mirror stream frame.
BridgeStateFramebridge_stateRemote bridge state stream frame.
ControlRequestFramecontrol_requestHost/SDK control request frame.
ControlResponseFramecontrol_responseHost/bridge control response event type.
PermissionResponseFramepermission_responsePermission response/control frame.
BridgeToolCallFieldstarget_device_id, permission_mode, allowed_domainsBrowser/MCP bridge tool-call frame fields.
PermissionResponseFieldsrequest_id, allowedPermission response payload fields.
RemoteControlRequestRequirementsendControlRequest not yet wiredRemote transport wrapper requires a concrete sendControlRequest implementation.
WebSocketAuthFdCLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTORRemote/session ingress token source for bridge auth.
SessionAccessTokenCLAUDE_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.