Northlight

Streaming and activity

A node's live event stream and the activity feed built on top of it.

Exports of @north-light/sdk, read from the TypeScript compiler at build time. Types re-exported from @north-light/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) => number

DescribeTool

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 | null

describeToolDefault

variable declared in resources/activity.ts

Plain labels for the tools every node can use.

(tool: string, summary: string) => string | null

followActivity

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: AppClient, runId: string, options: { after: number; signal?: AbortSignal; }) => Response

NodeEventsOptions

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("@north-light/api").NodeEventErrorDTO | import("@north-light/api").NodeOutputTextDeltaDTO | import("@north-light/api").NodeOutputTextDoneDTO | import("@north-light/api").NodeReportPushedDTO | import("@north-light/api").NodeSettledDTO | import("@north-light/api").NodeStatusChangedDTO | import("@north-light/api").NodeToolCallCompletedDTO | import("@north-light/api").NodeToolCallStartedDTO | import("@north-light/api").NodeTurnCompletedDTO | import("@north-light/api").NodeTurnStartedDTO

NodeStreamEventListener

type declared in resources/node-stream.ts

A listener for one event type, receiving only that type's event.

(event: Extract<NodeStreamEvent, { type: T; }>) => void

NodeStreamEventType

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>) => void

RunReply

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.

Iteration ends normally in exactly two cases, told apart by idle: the run settled (idle is false) or the runtime sent event: idle and closed (idle is true: the run is quiet, nothing is lost, and cursor is where to reopen with runs.events(runId, {after: cursor}) when there is something to read). After the idle frame the stream does not reconnect on its own. A transport or protocol failure throws instead, as before.

Prop

Type

RunStreamEnd

interface declared in resources/run-stream.ts

How a RunStream ended without an error: the run settled, or the runtime closed an idle stream (no running turn and no new event for its quiet window) and cursor is where to reopen it.

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

On this page