Transcript streaming¶
octomate_protocol.stream ¶
The transcript stream's wire protocol — what a client-side tail exchanges with the server's stream endpoint when a native session's transcript lives on another machine.
The payload is raw transcript lines plus the byte offsets they occupy in the client's own file. Turn assembly stays server-side. Codex clients additionally recognize explicit visualization references to attach bounded HTML snapshots; raw transcript lines and their offsets are unchanged. The same frames carry a Claude session file or a Codex rollout; the mounting endpoint selects its assembler.
The server is the only cursor authority. A connect opens with hello/welcome: the
client claims a session, the server answers where each of its files resumes (recomputed
from the committed runs), and the client holds no durable state — a crash anywhere
costs a re-stream, never a loss. Lines then flow contiguously per file; finalize
(server → client, relaying SessionEnd from the hook pipe) and eof (client → server,
"drained, commit the trailing turns") close a session out.
StreamClientMessage
module-attribute
¶
StreamClientMessage = Annotated[
StreamHello
| StreamOpenSubagent
| StreamLine
| StreamSnapshotStart
| StreamEof,
Field(discriminator="type"),
]
StreamServerMessage
module-attribute
¶
StreamServerMessage = Annotated[
StreamWelcome
| StreamSubagentOpened
| StreamFinalize
| StreamSnapshotStored,
Field(discriminator="type"),
]
client_message_adapter
module-attribute
¶
server_message_adapter
module-attribute
¶
StreamHello
pydantic-model
¶
Bases: BaseModel
The client's opening claim: which session it tails, where the transcript lives
on the client's machine (a label in the client's namespace — the server never
opens it), and the directory the session runs in, which files the session's thread
under its project exactly as the http hooks' cwd does.
Fields:
-
type(Literal['hello']) -
protocol(int) -
session_id(str) -
transcript_path(str) -
cwd(str) -
client_version(str) -
catchup_end(NonNegativeInt)
Source code in protocol/octomate_protocol/stream.py
catchup_end
pydantic-field
¶
Transcript byte length at connection time; earlier lines restore history.
StreamLine
pydantic-model
¶
Bases: BaseModel
One complete transcript line and the byte range it occupies in its file.
start/end are the client file's own offsets, end past the newline the line
was framed on — the same range the assembled run's start_offset/end_offset
records. Lines arrive contiguously per file, blank ones included (skipping one
would read as a gap); the server closes on a gap and the reconnect re-asks where
to resume.
Fields:
-
type(Literal['line']) -
conversation_id(UUID7) -
start(int) -
end(int) -
line(str) -
visualizations(list[HtmlSnapshot])
Validators:
Source code in protocol/octomate_protocol/stream.py
StreamEof
pydantic-model
¶
Bases: BaseModel
The client drained its files to EOF and is done — answering a finalize, or on
its own idle give-up. The server commits the trailing turns on this; a connection
that drops without it leaves them uncommitted for the next connect to re-stream.
Fields:
-
type(Literal['eof'])
Source code in protocol/octomate_protocol/stream.py
StreamSnapshotCursor
pydantic-model
¶
Bases: BaseModel
The durable transcript prefix the client must verify before appending.
Fields:
Source code in protocol/octomate_protocol/stream.py
TranscriptOffsets
pydantic-model
¶
Bases: BaseModel
Resume positions keyed by Octomate conversation UUID.
Fields:
Source code in protocol/octomate_protocol/stream.py
StreamWelcome
pydantic-model
¶
Bases: TranscriptOffsets
The session's conversation UUID and the resume positions for its files.
Fields:
-
offsets(dict[UUID7, NonNegativeInt]) -
subagents(dict[UUID7, str]) -
type(Literal['welcome']) -
conversation_id(UUID7) -
transcript(StreamSnapshotCursor | None)
Source code in protocol/octomate_protocol/stream.py
StreamOpenSubagent
pydantic-model
¶
Bases: BaseModel
Resolve a newly discovered child before sending its transcript.
Fields:
-
type(Literal['open_subagent']) -
name(str) -
first_line(str | None) -
catchup_end(NonNegativeInt) -
tool_call_id(str | None) -
description(str | None)
Source code in protocol/octomate_protocol/stream.py
first_line
pydantic-field
¶
Codex rollout metadata for parent verification.
catchup_end
pydantic-field
¶
Child transcript byte length at registration time.
tool_call_id
pydantic-field
¶
The parent's call a Claude child answers, from the meta file beside its transcript. An interrupted call's result names no child.
description
pydantic-field
¶
What the parent called a Claude child's task, from the same file.
StreamSubagentOpened
pydantic-model
¶
Bases: BaseModel
Registration result. A Codex rollout belonging to another session is skipped.
Fields:
-
type(Literal['subagent_opened']) -
conversation_id(UUID7 | None) -
offset(NonNegativeInt)
Source code in protocol/octomate_protocol/stream.py
StreamSnapshotStart
pydantic-model
¶
Bases: BaseModel
Client announces the next transcript range before sending its bytes.
Fields:
-
type(Literal['snapshot_start']) -
conversation_id(UUID7) -
transfer_id(UUID) -
start(int) -
end(int)
Source code in protocol/octomate_protocol/stream.py
StreamSnapshotStored
pydantic-model
¶
Bases: BaseModel
Server acknowledgment after the uploaded snapshot is durably stored.
Fields:
-
type(Literal['snapshot_stored']) -
transfer_id(UUID)
Source code in protocol/octomate_protocol/stream.py
StreamFinalize
pydantic-model
¶
Bases: BaseModel
Server → client: the session ended (SessionEnd arrived on the hook pipe) —
drain the remaining bytes, answer with eof, and exit.
A snapshot starts with snapshot_start, followed by binary messages totaling
end - start bytes. The client waits for snapshot_stored before sending eof.
Each batch's transcript lines precede its binary messages; they never interleave.
Batches may upload throughout a turn, before finalization.
Fields:
-
type(Literal['finalize'])
Source code in protocol/octomate_protocol/stream.py
octomate_protocol.visualizations ¶
Explicit Codex HTML references shared by driven capture and native clients.
Files must be regular UTF-8 HTML beneath the session workspace, without symlinks, and at most 1 MB. Native clients send snapshots alongside the original rollout line; the server never opens a path supplied by a remote client.
VISUALIZATION_REFERENCE
module-attribute
¶
rollout_object_adapter
module-attribute
¶
HtmlReference
pydantic-model
¶
Bases: BaseModel
An explicit file reference with an optional layout hint retained on capture.
Fields:
Source code in protocol/octomate_protocol/visualizations.py
mode
pydantic-field
¶
Native layout hint requesting a wider inline visualization.
read ¶
Read a bounded snapshot through directory descriptors without following links.
Source code in protocol/octomate_protocol/visualizations.py
HtmlSnapshot
pydantic-model
¶
Bases: BaseModel
An explicit visualization and the UTF-8 HTML read on its owning machine.
Fields:
-
reference(HtmlReference) -
html(str)
Validators:
Source code in protocol/octomate_protocol/visualizations.py
bounded_html
pydantic-validator
¶
Source code in protocol/octomate_protocol/visualizations.py
codex_html_references ¶
Read explicit references from assistant response items only.
Unmodeled lines remain the server tailer's concern. A recognized visualization must validate before its client opens any file. Prompts and tool output never authorize file capture.