Skip to content
SumOfficeSumOfficeSumOffice

SumDoc transport and message format

Exchanging JSON strings and over WebSocket, the request and response format, refusal texts, timeouts, and exchange contract versions.

Terminal window
# $CLI is the path to the processor inside the installed application,
# it's given on the “Installation and verification” page
"$CLI" serve
{
"schema": "fastdoc.session-serve.v1",
"stage_id": "D7",
"session_kind": "jsonl-stdio-document-session-prototype",
"supported_commands": [
"apply-composition",
"apply-text-transaction",
"commit-snapshot",
"commit-structural-snapshot",
"compatibility-inspect",
"compose",
"model",
"mutate",
"open",
"paginate",
"ping",
"print",
"print-delta",
"print-summary",
"print-window",
"redo",
"report",
"review",
"save",
"save-checkpoint",
"set-selection",
"shutdown",
"simple-field-inventory",
"squash-history",
"status",
"style",
"track-revisions-state",
"undo"
],
"ready": true
}
Terminal window
"$CLI" serve --ws 0 [--token <token>]
{"schema":"fastdoc.session-ws-bootstrap.v1","transport":"websocket","host":"127.0.0.1","port":49152,"token":"<64 hex>","ready":true}

The connection accepts only UTF-8 text frames, listens only on a local address, and checks the token passed in the connection address. Right after connecting, the same readiness line arrives as with standard-input/output exchange.

About --token. If you don’t set one, the processor generates a new token on every launch: 256 bits from the system randomness source — the same 64 hex characters in the readiness line — and it lives exactly as long as the process runs. If you set your own, rotating it on every launch becomes your responsibility, and a fixed value in the startup script cancels that rotation.

interface Request { id?: unknown; cmd: SessionCommandName; /* command fields flattened */ }
interface Response<T=unknown> { id:unknown; ok:boolean; cmd?:string; elapsed_ms?:number; result?:T; error?:string; }
Situation What comes back
The request isn’t an object, or is missing the cmd field ok: false, with the error field — each request line must be a JSON object with a string cmd field
No command with that name exists ok: false, with errorunknown session command: <name>
The command requires an open document ok: false, with errorno document is open in this session
An internal processing error ok: false and a message marked panicked. The session stays alive and the connection doesn’t drop — you can send the next command

The first line of the session isn’t a formality: you use it to verify what you’re talking to. It has five fields.

Field What’s in it
schema fastdoc.session-serve.v1 — the version of the conversation itself. Check this one at startup: if it doesn’t match, the processor is older or newer than your code.
session_kind How you connected (three values, below).
supported_commands The full list of commands this particular processor will accept. More reliable than the reference: it speaks for itself.
stage_id An internal build-stage marker. Not needed for embedding; don’t branch on it.
ready true when the session is ready to accept commands.

There are three kinds of session, and they show which way the conversation was opened:

session_kind value When you see it
jsonl-stdio-document-session-prototype Exchanging strings over standard input/output — serve with no flags.
json-websocket-document-session The same contract over WebSocket — serve --ws.
json-websocket-embedded-surface-session An embedded-surface session — surface.
Contract Version
Machine-readable description of the session protocol fastdoc.session-protocol-descriptor.v1
JSONL session readiness fastdoc.session-serve.v1
Address and token for WebSocket fastdoc.session-ws-bootstrap.v1
Starting the surface: address, token, version fastdoc.surface-host-bootstrap.v1
Mounting the surface on your page fastdoc.surface-mount.v1
Surface event to your application fastdoc.surface-host-event.v1
Interaction context — proposed a4.interaction-context.v1, not yet finalized

Documentation assistant

Answers are assembled from the documentation and may be inaccurate — check the sources.