Skip to main content
handleSse(req): Promise<Response>
Serve the agent’s streams as one SSE response (see the class doc for the URL contract and the event format). The connection is negotiated through the socket server’s own bootstrap: authorize resolves the token from the query string (or an Authorization header), onAttach may veto, and the subscribed streams replay their backlog past the Last-Event-ID cursors before live pushes begin. A rejected connection answers with the error frame as JSON (401 for a rejected credential) instead of a stream. When the response is torn down — the EventSource closed, the request aborted, the network dropped — the subscription is released immediately: the connection leaves the watcher set and broadcasts stop targeting it. Parameters Returns Promise<Response> A text/event-stream response, or an error response.