Anchorage API reference
    Preparing search index...

    The three reads this router makes, as a type of their own.

    Narrower than BackgroundTaskManager on purpose. The manager also carries enqueue, registerStaticExecutor, registerTaskContext, resume, and restart — each of which puts a task body on the deployment without passing the execution fence — so a route handler holding one is a single property access away from the thing the fence exists to stop. Typing the option as the reads instead lets BackgroundTaskHost hand over its own fence-preserving forwarding surface, while a plain manager still satisfies it structurally for a host that has no fence to preserve.

    interface BackgroundTaskReads {
        getTask: (taskId: string) => Promise<BackgroundTask | null>;
        listTasks: (filter?: TaskFilter) => Promise<TaskListResult>;
        stream: (options?: {}) => ReadableStream<Record<string, unknown>>;
    }
    Index

    Properties

    getTask: (taskId: string) => Promise<BackgroundTask | null>
    listTasks: (filter?: TaskFilter) => Promise<TaskListResult>
    stream: (options?: {}) => ReadableStream<Record<string, unknown>>

    Type Declaration

      • (options?: {}): ReadableStream<Record<string, unknown>>
      • Returns a ReadableStream of all background task lifecycle events, filtered by optional criteria. Intended to be piped directly to an SSE response.

        On connection, emits the current state of all non-terminal tasks as a snapshot, then subscribes to live pubsub events for subsequent updates.

        Events include:

        • task.running (status: 'running') — task picked up by a worker
        • task.completed (status: 'completed') — task finished successfully
        • task.failed (status: 'failed' or 'timed_out') — task errored or timed out
        • task.cancelled (status: 'cancelled') — task was cancelled
        • task.suspended (status: 'suspended') — task paused via suspend() from inside its tool executor; resume with manager.resume(taskId, data)
        • task.resumed (status: 'running') — suspended task resumed

        The stream stays open until the caller's AbortSignal fires (client disconnect).

        Parameters

        • Optionaloptions: {}

        Returns ReadableStream<Record<string, unknown>>