Resume a pending protocol interrupt by sending a response payload back to the interrupted namespace.
When options.interruptId is omitted, walks getThread()?.interrupts
from newest to oldest and resumes the first not yet resolved by a prior
respond() call. That may be a root or subgraph interrupt and is
not necessarily interrupt (interrupts[0], root-only).
Safe when exactly one interrupt is pending; otherwise pass an explicit
options.interruptId (and options.namespace for subgraph
interrupts).
The server validates namespace against the pending interrupt. Root
interrupts use namespace: [] (default when omitted). For subgraph
interrupts, copy namespace from getThread()?.interrupts.
respond(response: unknown, options: StreamRespondOptions<ConfigurableType>): Promise<void>| Name | Type | Description |
|---|---|---|
response* | unknown | |
options | StreamRespondOptions<ConfigurableType> |
// Single pending interrupt
await stream.respond({ approved: true });// Multiple root interrupts
{#each stream.interrupts as intr (intr.id)}
<button onclick={() => stream.respond(decide(intr.value), { interruptId: intr.id! })}>
Resolve
</button>
{/each}// Subgraph interrupt ā namespace from `getThread()`
const thread = stream.getThread();
for (const entry of thread?.interrupts ?? []) {
await stream.respond(buildResponse(entry.payload), {
interruptId: entry.interruptId,
namespace: entry.namespace,
});
}