Connector API
Streaming
Once a run reaches running status, subscribe to its SSE stream for live output. The Vercel proxy path works for every session and is what you should build against. A second, direct path exists only for older sessions still served by the classic runtime; /events-token tells you whether a given session has it.
Stream from a browser
To show a run live in a browser without giving it your credential, mint a stream descriptor on your server — POST /v1/sessions/:sessionId/stream-descriptor, or the session_stream_descriptorMCP tool — and hand it to the browser. Its tokenreads that one session’s stream from the Toscana Gateway at events_base_url, addressed by stream_session_id; it can do nothing else, and it expires (mint another). The browser reads the Gateway directly, so no function timeout sits in between. The reads it makes are the ones in Toscana protocol; toscana-client’s browser chat does them for you.
curl -X POST https://connector.socialistic.ai/v1/sessions/$SESSION/stream-descriptor \
-H "Authorization: Bearer $KEY"
# → { "runtime": "toscana", "token": "eyJ…", "events_base_url": "https://…",
# "stream_session_id": "…" }POST/v1/sessions/:sessionId/stream-descriptorsession:run
Mint a browser stream descriptor for one of your sessions: a token the Toscana Gateway accepts for reading THIS session's stream only (no runs, no other session, nothing else on this API), its base URL, and the Toscana session id the stream is addressed by. Hand it to a browser — the API credential itself never leaves your server — and the browser streams the session directly from the Gateway, with no function timeout in between (it is the same descriptor toscana-client's server handlers give a browser). The token expires; mint a new one when it does. Toscana sessions only: a read-only session (it ran on the retired classic runtime) answers 409 SESSION_READ_ONLY.
Request
No request body.
Response
| Field | Type | Description |
|---|---|---|
runtime | "toscana" | |
token | string | |
events_base_url | string | |
stream_session_id | string |
Get an events token
Call once per session. If the server returns a non-null token + events_base_url, use the direct path. The token is valid for 24 hours.
curl https://connector.socialistic.ai/v1/sessions/$SESSION/events-token \
-H "Authorization: Bearer $KEY"
# → 200 (direct SSE available)
{ "token": "eyJz…", "events_base_url": "https://goose.socialistic.ai" }
# → 200 (direct SSE unavailable — use Vercel proxy)
{ "token": null, "events_base_url": null }GET/v1/sessions/:sessionId/events-tokensession:run
Legacy sidecar sessions only: mint a short-lived HMAC token for direct SSE to the retired sidecar. Every other session (all current ones) returns null fields; use the proxy events endpoint.
Request
No request body.
Response
| Field | Type | Description |
|---|---|---|
token | string | null | HMAC-signed token for sidecar SSE auth (null when direct SSE is unavailable) |
events_base_url | string (uri) | null | Base URL of the sidecar SSE endpoint (null when direct SSE is unavailable) |
Vercel proxy (default)
GET /v1/sessions/$SESSION/runs/$RUN_ID/events
Authorization: Bearer $KEYWorks for every session that can still take runs, and is the only path available when /events-token returns null. Subject to the Vercel function timeout (300 s). If the run exceeds this, the connection drops and you must reconnect.
A read-onlysession — one that ran on the retired classic runtime — also answers null, but it has nothing to stream and never will: POST /runs on it returns 409 SESSION_READ_ONLY. Treat that as terminal, read its history with GET /v1/sessions/:sessionId (which reports read_only: true, and history_complete: false when the conversation could not be recovered), and create a new session to continue.
Verify a session from your own service
An MCP server attached to a skill learns which session, skill, creator and consumer is calling it — and can verify it — as Session identity describes.
Direct SSE (legacy sessions only)
GET $EVENTS_BASE_URL/run-events\
?goose_session_id=$GOOSE_SESSION_ID\
&run_id=$RUN_ID\
&token=$TOKENOnly for older sessions, whose /events-token returns a real token and base URL. No Authorizationheader needed — the HMAC token carries the auth, and the connection is persistent (no serverless timeout). Sessions created today do not have this path: use the proxy above. $GOOSE_SESSION_ID comes from GET /v1/sessions/:sessionId, which returns it as goose_session_id (null on sessions that never ran on the classic runtime).
GET/v1/sessions/:sessionId/runs/:runId/eventssession:run
Stream a run's output as server-sent events. The default path, serving every session that can still take runs; a read-only session answers 409 SESSION_READ_ONLY (terminal — do not reconnect). Subscribe after the run status becomes running. Reconnect past a drop with ?after=<lastEventId>.
Request
No request body.
Response
No response body.
Reconnecting mid-run
If the SSE connection drops before a terminal event, reconnect with after set to the last id:you received. Exponential backoff (500 ms → 1 s → 2 s, 3 attempts) is a good default.
# Vercel proxy path
GET /v1/sessions/$SESSION/runs/$RUN_ID/events?after=LAST_EVENT_ID
# Direct path (legacy sessions only)
GET $EVENTS_BASE_URL/run-events\
?goose_session_id=$GOOSE_SESSION_ID\
&run_id=$RUN_ID\
&token=$TOKEN\
&after=LAST_EVENT_IDIf the run already ended (or the agent host restarted), the server replays the stored transcript then closes. Accumulate message.deltaclient-side for the real output, and treat the stream closing right after a reconnect as “run no longer active” rather than looping.
Event frames
Each SSE frame is data: {…} JSON. Every frame carries event (type), run_id, and timestamp (ms epoch).
Streaming events
message.delta
{ event, run_id, timestamp, delta: string }
Incremental output text from the model.
tool.started
{ event, run_id, timestamp, tool: string, command_label?: string }
Agent invoked a tool. `tool` is the tool name. For the shell tool,
`command_label` is the first word of the command (e.g. "cat").
tool.completed
{ event, run_id, timestamp, tool: string, duration: number, error: boolean, command_label?: string }
Tool finished. `duration` is milliseconds; `error` is true if the tool failed.
artifact.delivered
{ event, run_id, timestamp, artifact_id: string, url: string, file_name: string, content_type: string }
A file the agent published, emitted at the moment it was delivered.
`url` is the stored file's public URL; `artifact_id` is an opaque,
unique id of the delivery. The agent is not asked to repeat the link in
its reply — render this event, or ask for links in your query.
Optional: runs that publish nothing never emit it.
reasoning.available
{ event, run_id, timestamp, text: string }
Extended-thinking / reasoning trace from the model.
steer
{ event, run_id, timestamp, steer_id: string, text: string,
state: "accepted" | "picked_up" | "discarded" }
Text added to the run (POST …/steer). One steer_id per input, its state
moving on: accepted, then picked_up once the agent took it in, or
discarded when the run finished first.
user.input
{ event, run_id, timestamp, text: string, parts?: Array<
{ type: "text", content: string } | { type: "file", name: string, url: string } > }
User message. Only emitted on history replay (reconnect), not live
streams. `parts` is present when the replayed turn had uploads.Terminal events
run.completed
{ event, run_id, timestamp, output: string, usage }
Run succeeded. Build the response text by accumulating `message.delta`:
`output` is always "" on current sessions (only legacy sessions fill it).
usage: {
input_tokens: number input tokens for this run
output_tokens: number output tokens for this run
total_tokens: number total tokens for this run
upstream_cost_usd?: number upstream cost in USD (legacy sessions only)
upstream_generation_id?: string upstream generation ID (legacy sessions only)
upstream_provider?: string upstream provider name (legacy sessions only)
}
run.failed
{ event, run_id, timestamp, error: string, error_code?: string, error_stage?: string }
Run errored. `error` is a debug-level message; display `error_code` to users.Keepalive
During tool execution the agent can go quiet, and the proxy forwards only data:frames — no keepalive comments reach you, so a silent stream is not by itself a dropped one. Pick your own idle threshold generously (longer than a slow tool call), and if it passes, reconnect with after or poll the run status rather than giving up.
A run is complete when you receive either run.completed or run.failed. After a terminal event, close the connection — no further events will arrive for that run_id.