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 workertask.completed (status: 'completed') — task finished successfullytask.failed (status: 'failed' or 'timed_out') — task errored or timed outtask.cancelled (status: 'cancelled') — task was cancelledtask.suspended (status: 'suspended') — task paused via suspend() from
inside its tool executor; resume with manager.resume(taskId, data)task.resumed (status: 'running') — suspended task resumedThe stream stays open until the caller's AbortSignal fires (client disconnect).
Optionaloptions: {}
The three reads this router makes, as a type of their own.
Narrower than
BackgroundTaskManageron purpose. The manager also carriesenqueue,registerStaticExecutor,registerTaskContext,resume, andrestart— 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 letsBackgroundTaskHosthand over its own fence-preserving forwarding surface, while a plain manager still satisfies it structurally for a host that has no fence to preserve.