Skip to content

parseStreamLine

View as Markdown
function parseStreamLine(raw):
| {
msg: | {
machineId: string;
minAgentVersion: string;
protocol: number;
t: "welcome";
}
| {
minAgentVersion: string;
t: "upgrade_required";
}
| {
args: unknown;
id: string;
op: | "createSession"
| "startRun"
| "cancelRun"
| "decide"
| "updateSettings"
| "addAttachment"
| "snapshot"
| "listSessions"
| "readEvents";
t: "command";
}
| {
sequence: number;
sessionId: string;
t: "ack";
}
| {
id: string;
ok: true;
result: {
content: (
| {
text: string;
type: "text";
}
| {
json: unknown;
type: "json";
})[];
isError?: boolean;
};
t: "tool_result";
}
| {
error: {
code: | "runtime_unavailable"
| "auth_required"
| "unsupported_capability"
| "invalid_workspace"
| "session_busy"
| "session_read_only"
| "not_found"
| "unauthorized"
| "forbidden_origin"
| "invalid_request"
| "approval_expired"
| "approval_already_resolved"
| "event_replay_unavailable"
| "runtime_disconnected"
| "policy_denied"
| "store_locked"
| "attachment_too_large"
| "attachment_type_unsupported"
| "machine_offline"
| "machine_not_found"
| "upgrade_required"
| "tool_failed"
| "device_code_expired"
| "rate_limited"
| "internal_error";
details?: Record<string, unknown>;
hint?: string;
message: string;
requestId?: string;
retryable: boolean;
};
id: string;
ok: false;
t: "tool_result";
}
| {
id: string;
maxBytes: number;
path: string;
sessionId: string;
t: "file_pull";
}
| {
id: string;
mime: string;
name: string;
sessionId: string;
size: number;
t: "attachment_begin";
}
| {
data: string;
id: string;
seq: number;
t: "attachment_chunk";
}
| {
id: string;
t: "attachment_end";
}
| {
id: string;
t: "attachment_abort";
}
| {
at: number;
t: "ping";
};
seq: number;
}
| {
at?: number;
ctl: "closed" | "ping" | "rotate" | "replaced" | "revoked";
};

Defined in: transport.ts:82

Parse one NDJSON line of the downstream stream. Throws ProtocolFrameError (code: 'invalid_request').

Parameter Type
raw string

| { msg: | { machineId: string; minAgentVersion: string; protocol: number; t: "welcome"; } | { minAgentVersion: string; t: "upgrade_required"; } | { args: unknown; id: string; op: | "createSession" | "startRun" | "cancelRun" | "decide" | "updateSettings" | "addAttachment" | "snapshot" | "listSessions" | "readEvents"; t: "command"; } | { sequence: number; sessionId: string; t: "ack"; } | { id: string; ok: true; result: { content: ( | { text: string; type: "text"; } | { json: unknown; type: "json"; })[]; isError?: boolean; }; t: "tool_result"; } | { error: { code: | "runtime_unavailable" | "auth_required" | "unsupported_capability" | "invalid_workspace" | "session_busy" | "session_read_only" | "not_found" | "unauthorized" | "forbidden_origin" | "invalid_request" | "approval_expired" | "approval_already_resolved" | "event_replay_unavailable" | "runtime_disconnected" | "policy_denied" | "store_locked" | "attachment_too_large" | "attachment_type_unsupported" | "machine_offline" | "machine_not_found" | "upgrade_required" | "tool_failed" | "device_code_expired" | "rate_limited" | "internal_error"; details?: Record<string, unknown>; hint?: string; message: string; requestId?: string; retryable: boolean; }; id: string; ok: false; t: "tool_result"; } | { id: string; maxBytes: number; path: string; sessionId: string; t: "file_pull"; } | { id: string; mime: string; name: string; sessionId: string; size: number; t: "attachment_begin"; } | { data: string; id: string; seq: number; t: "attachment_chunk"; } | { id: string; t: "attachment_end"; } | { id: string; t: "attachment_abort"; } | { at: number; t: "ping"; }; seq: number; } | { at?: number; ctl: "closed" | "ping" | "rotate" | "replaced" | "revoked"; }