Streaming and activity
A node's live event stream and the activity feed built on top of it.
Exports of @crouter/sdk, read from the TypeScript compiler at build time. Types re-exported from @crouter/api are documented with that package.
ActivityStep
interface declared in resources/activity.ts
One tool call rendered as an activity step.
Prop
Type
cursorFromRequest
function declared in resources/forward.ts
Native EventSource sends Last-Event-ID on reconnect; it takes precedence over the URL cursor.
(request: Request) => numberDescribeTool
type declared in resources/activity.ts
Turn a streamed tool call into a label, or return null to omit it.
(tool: string, summary: string) => string | nulldescribeToolDefault
variable declared in resources/activity.ts
Plain labels for the tools every node can use.
(tool: string, summary: string) => string | nullfollowActivity
function declared in resources/activity.ts
Yield an immutable activity snapshot after every streamed tool-call change.
(stream: AsyncIterable<NodeStreamEvent>, options?: { describe?: DescribeTool; }) => AsyncGenerator<ActivityStep[]>forwardRunEvents
function declared in resources/forward.ts
(crouter: Crouter, runId: string, options: { after: number; signal?: AbortSignal; }) => ResponseNodeEventsOptions
interface declared in types.ts
Options for an existing node's event stream. Streams have no wall-clock timeout.
Prop
Type
NodeStream
class declared in resources/node-stream.ts
A parsed node event stream. Aborting it disconnects this observer, not the node.
Prop
Type
NodeStreamEvent
type declared in resources/node-stream.ts
One event from a node's stream.
import("@crouter/api").NodeEventErrorDTO | import("@crouter/api").NodeOutputTextDeltaDTO | import("@crouter/api").NodeOutputTextDoneDTO | import("@crouter/api").NodeReportPushedDTO | import("@crouter/api").NodeSettledDTO | import("@crouter/api").NodeStatusChangedDTO | import("@crouter/api").NodeToolCallCompletedDTO | import("@crouter/api").NodeToolCallStartedDTO | import("@crouter/api").NodeTurnCompletedDTO | import("@crouter/api").NodeTurnStartedDTONodeStreamEventListener
type declared in resources/node-stream.ts
A listener for one event type, receiving only that type's event.
(event: Extract<NodeStreamEvent, { type: T; }>) => voidNodeStreamEventType
type declared in resources/node-stream.ts
The type discriminant of a stream event, and the name on and off take.
"error" | "node.output_text.delta" | "node.output_text.done" | "node.report.pushed" | "node.settled" | "node.status.changed" | "node.tool_call.completed" | "node.tool_call.started" | "node.turn.completed" | "node.turn.started"RunEventListener
type declared in resources/run-stream.ts
(event: RunEventOf<T>) => voidRunReply
class declared in resources/run-reply.ts
The reply to one message: the root's turn that delivers it. Consume it once:
iterate it, or call collect() (text plus how it ended, with an optional
onDelta while it streams) or text(). It ends after turn.completed (or run.settled) and
closes its event stream; aborting the signal rejects with APIUserAbortError.
Prop
Type
RunReplyCollectOptions
interface declared in resources/run-reply.ts
RunReply.collect options.
Prop
Type
RunReplyEnding
type declared in resources/run-reply.ts
How a reply ended (RunReply.collect):
- completed: the turn finished cleanly; text may still be empty when the model wrote nothing.
- error: the turn's last assistant message failed; error says why.
- waiting_on_user: the turn ended on a question to the person; the run waits for an answer.
- settled: the run settled before the turn completed; outcome says how.
"completed" | "error" | "settled" | "waiting_on_user"RunReplyEvent
type declared in resources/run-reply.ts
One event of the reply to a message (runs.reply).
{ type: 'text.delta'; delta: string; sequence_number: number; } | { type: 'message.done'; text: string; stop_reason: AssistantStopReasonDTO; sequence_number: number; } | { type: 'turn.completed'; run_status: Exclude<RunStatusDTO, 'settled'>; stop_reason: string; error?: TurnErrorDTO; message_ids: string[]; sequence_number: number; } | { type: 'run.settled'; outcome: RunOutcomeDTO; sequence_number: number; }RunReplyResult
interface declared in resources/run-reply.ts
The whole reply, from RunReply.collect.
Prop
Type
RunStream
class declared in resources/run-stream.ts
A resumable run event stream. Closing it does not stop the run.
Prop
Type
SentRunMessage
interface declared in resources/run-reply.ts
What runs.message returns: the message a reply answers.
Prop
Type
UnknownRunEvent
type declared in resources/run-stream.ts
An event under a type this SDK version does not declare (a newer daemon's), or read by field name.
Prop
Type