The Open Framework for Building Agents
feat(eve): client - follow subagent streams through the parent session (#3730)
Andrew Barbafaacecf38175
diff --git a/.changeset/client-subagent-streams.md b/.changeset/client-subagent-streams.mdnew file mode 100644index 000000000..1c6470dcd--- /dev/null+++ b/.changeset/client-subagent-streams.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Follow a delegated child's activity from a client with `session.streamSubagent(called, options?)`. Pass a `subagent.called` event from that session. The client reads its `childStreamPath` with the session's host and credentials, so a remote child streams through the parent deployment's proxy route, and the child's cursor stays separate from the parent's. Eval sessions expose the same method with the eval client's credentials.diff --git a/docs/concepts/sessions-runs-and-streaming.md b/docs/concepts/sessions-runs-and-streaming.mdindex 3990f6441..e984a745d 100644--- a/docs/concepts/sessions-runs-and-streaming.md+++ b/docs/concepts/sessions-runs-and-streaming.md@@ -79,7 +79,7 @@ The stream is newline-delimited JSON (NDJSON), one event per line:| `action.result` | A tool call returned. || `input.requested` | The run paused for human input ([HITL](/docs/human-in-the-loop) approval or a `ctx.ask()` question); carries `requests`. || `input.resolved` | The server accepted terminal human-input outcomes; carries `resolutions` with responses when provided. |-| `subagent.called` | A subagent was delegated; carries `childSessionId` to attach to. |+| `subagent.called` | A subagent was delegated; carries `childSessionId` and the `childStreamPath` that `session.streamSubagent()` follows. || `subagent.completed` | The parent recorded a successful subagent invocation result; carries the actual output. || `reasoning.appended` | A reasoning text delta. || `reasoning.completed` | The finalized reasoning block. |@@ -119,7 +119,7 @@ Note: consider the privacy, confidentiality, and user-experience implications foWhen a task explicitly requires conditional delivery and there is nothing new to report, the agent can finish with exactly `<eve-empty-delivery/>`. eve emits `message.completed` with `message: null` for that intentional silence. The marker must be the entire response, apart from surrounding whitespace; the HTML-escaped form `<eve-empty-delivery/>` is also accepted. A response that quotes the marker in prose or code is delivered normally.-A delegated subagent publishes progress on its own child-session stream. The parent emits `subagent.called` with a `childSessionId`, which a client uses to attach. Both blocking and background calls emit `subagent.completed` with the actual output after the parent records a successful outcome. A background working receipt is an `action.result` tool output; it does not emit completion. Older streams can contain receipt-bearing completion events marked by `data.backgroundTask`; those are admission only. Completion does not mean that the reusable child session has ended. Background task terminal outcomes also arrive as task-triggered `message.received` notifications with `data.kind: "execution.background_task"`. The default frontend reducer retains these events in `events` but does not project their runtime-authored text as participant messages.+A delegated subagent publishes progress on its own child-session stream. The parent emits `subagent.called` with a `childSessionId` and a `childStreamPath`, which a client follows with `session.streamSubagent()`. Both blocking and background calls emit `subagent.completed` with the actual output after the parent records a successful outcome. A background working receipt is an `action.result` tool output; it does not emit completion. Older streams can contain receipt-bearing completion events marked by `data.backgroundTask`; those are admission only. Completion does not mean that the reusable child session has ended. Background task terminal outcomes also arrive as task-triggered `message.received` notifications with `data.kind: "execution.background_task"`. The default frontend reducer retains these events in `events` but does not project their runtime-authored text as participant messages.`step.failed` and `turn.failed` carry `{ code, message, details? }` for the failed fragment or turn, and `session.failed` is the terminal session-level variant. `turn.cancelled` is not a failure: the cancelled turn ends without any failure event, `session.waiting` follows, and the session accepts the next message normally. Whatever the turn streamed before cancellation stays on the stream. Durable history keeps the accepted user input and previously settled work, but discards incomplete assistant output and unfinished tool state. When a turn requested an output schema, the finalized payload lands on `result.completed` as `data.result` before the turn boundary. `authorization.required` carries the sign-in challenge (`data.authorization` may include `url`, `userCode`, `expiresAt`, `instructions`), and `authorization.completed` carries `data.outcome` (`"authorized" | "declined" | "failed" | "timed-out"`).diff --git a/docs/evals/cases.mdx b/docs/evals/cases.mdxindex eae7abb3f..50056f1e9 100644--- a/docs/evals/cases.mdx+++ b/docs/evals/cases.mdx@@ -111,6 +111,7 @@ Every `t.session()` or `t.send()` creates a new independent conversation. Contin- `session.start(message, options?)` starts a text turn and returns as soon as the server accepts it. The live turn exposes `.session`, `.sessionId`, `.waitForEvent(...)`, `.cancel()`, and `.result()`.- `session.cancel()` requests cooperative cancellation of that session's active turn. Both `accepted` and `no_active_turn` are successful outcomes.- `session.sendFile(text, path, mediaType?)` attaches a local file as a data URL.+- `session.streamSubagent(called, options?)` follows a delegated child's stream through the parent with the eval client's credentials. Pass a `subagent.called` event from that session. It also reaches children on another deployment, which `t.target.watchTurn(...)` cannot address.- `session.requireInputRequest(filter?)` records a gate, requires exactly one pending request, and returns it. Filters match tool name, action input, prompt, display, and option ids.- `session.respond(responses, options?)` answers specific pending input requests and sends them as the next turn. `session.startRespond(...)` returns a live turn for the same operation.- `session.respondAll(optionId)` answers every pending input request with the same option and sends the responses as the next turn.diff --git a/docs/guides/client/streaming.mdx b/docs/guides/client/streaming.mdxindex 95d2cbf25..807a4ecc8 100644--- a/docs/guides/client/streaming.mdx+++ b/docs/guides/client/streaming.mdx@@ -241,6 +241,32 @@ Unlike `stream()`, `snapshot()` does not advance the originating`ClientSession`. Its returned cursor contains the fixed session ID and the exactstream index after the captured prefix.+## Follow a subagent++A delegated subagent reports its progress on its own child session. The parent stream announces each dispatch with a `subagent.called` event. Pass that event to `streamSubagent()` on the parent's session handle to follow the child:++```ts+import { isCurrentTurnBoundaryEvent } from "eve/client";++const session = client.sessions.attach(parentSessionId);+const { events } = await session.snapshot();+const called = events.find((event) => event.type === "subagent.called");++if (called?.type === "subagent.called") {+ for await (const event of session.streamSubagent(called)) {+ console.log(called.data.name, event.type);+ if (isCurrentTurnBoundaryEvent(event)) break;+ }+}+```++`streamSubagent()` reads the event's `childStreamPath` with the parent session's host and credentials, so the same client works for local and [remote](../remote-agents) children:++- A local child's path is its own session stream route on the same deployment. The channel's usual session authorization applies.+- A remote child's path is a proxy route on the parent deployment. The parent checks that the child belongs to this session, then relays the remote child's stream with the remote agent's authored `auth` and `headers`. The client never needs the remote URL or its credentials.++The child has its own cursor, starting at `0`, and reading it never advances the parent's `streamIndex`. Pass `startIndex` to resume, `follow: false` for a bounded read, and `signal` to detach. A child parks after answering and can be continued later, so stop at a turn boundary with `isCurrentTurnBoundaryEvent` when you only need the current turn. Passing a `subagent.called` event from a different session throws.+## Abort a requestPass an `AbortSignal` to cancel the POST or stream. Aborting is local transport cancellation: turns are resumable across disconnects, so detaching never stops server-side work. Use `session.cancel()` to stop the active turn, or `session.cancel({ tasks: true })` to also stop background tasks owned by the session. Cancellation is asynchronous; watch the stream for `turn.cancelled` followed by `session.waiting`, and inspect task state in a later turn to confirm task cancellation.diff --git a/docs/guides/frontend/overview.mdx b/docs/guides/frontend/overview.mdxindex f433fa5ae..024e1d23c 100644--- a/docs/guides/frontend/overview.mdx+++ b/docs/guides/frontend/overview.mdx@@ -172,7 +172,7 @@ supplied `session` remains externally owned and is never replaced by prewarming`data.messages` are eve-owned `EveMessage[]`. Common text, reasoning, file, and dynamic-tool parts follow the [AI SDK `UIMessage`](https://ai-sdk.dev/docs/reference/ai-sdk-core/ui-message) rendering convention, but the types are not interchangeable. eve also exposes authorization and HITL metadata, and a file part's URL can be absent. Adapt those parts before passing messages to an API typed as `UIMessage[]`.-When the root agent delegates, its stream emits `subagent.called` with the child's `childSessionId`, then `subagent.completed` when the parent records a successful result, for both blocking and background invocations. A background working receipt appears in `action.result`, without a completion event. The child session can remain available for reuse. Task notifications wake the parent with completion, failure, or cancellation. Detailed child progress lives on the child session's stream instead of being flattened into the root `data.messages`. Use the lower-level [TypeScript client](../client/overview#sessions) to attach to that ID when your UI needs live subagent activity. See [What the parent sees](../../subagents#what-the-parent-sees) for the complete contract.+When the root agent delegates, its stream emits `subagent.called` with the child's `childSessionId`, then `subagent.completed` when the parent records a successful result, for both blocking and background invocations. A background working receipt appears in `action.result`, without a completion event. The child session can remain available for reuse. Task notifications wake the parent with completion, failure, or cancellation. Detailed child progress lives on the child session's stream instead of being flattened into the root `data.messages`. When your UI needs live subagent activity, attach a [client session](../client/overview#sessions) to the parent and pass the `subagent.called` event from `events` to [`streamSubagent()`](../client/streaming#follow-a-subagent). It follows local and remote children through the parent, so the browser never calls a remote deployment directly. See [What the parent sees](../../subagents#what-the-parent-sees) for the complete contract.## Sending and streamingdiff --git a/docs/guides/remote-agents.md b/docs/guides/remote-agents.mdindex 6277b0aa5..a30c41118 100644--- a/docs/guides/remote-agents.md+++ b/docs/guides/remote-agents.md@@ -192,6 +192,8 @@ A remote subagent runs as a durable background task in its own deployment:The parent stream carries the same `subagent.called`, `action.result`, and `subagent.completed` events as local delegation. For a remote call, `subagent.called.data.remote.url` records the target.+Clients follow a remote child through the parent. [`session.streamSubagent()`](./client/streaming#follow-a-subagent) reads `subagent.called.data.childStreamPath`, a route on the parent deployment. The parent verifies that the child belongs to that session, resolves the remote agent's `auth` and `headers`, and relays the child's stream. A browser never calls the remote deployment or holds its credentials; it only needs access to the parent session.+An admitted task survives cancellation of the turn that started it; background work that has not yet been admitted is rejected with the cancelled step. Use `task_cancel` to stop an admitted task. eve resolves the remote's `headers` and `auth` again for every cancellation attempt, so rotating credentials work the same way as they do for session creation. Cancellation always uses the standard eve cancel path on `url`, even when `path` customizes only the create-session endpoint. The remote child reports `turn.cancelled` → `session.waiting` on its own stream; an older or unreachable remote is logged but cannot turn the parent's cancellation into a failure.You can also steer a running remote background child by calling its subagent tool with the same `agentId` and an updated `message`. eve cancels the old task and requests cancellation of the remote turn before continuing the same remote session under a new task ID. The remote must support the standard eve cancellation and session-message routes. See [Agent messaging](../subagents#agent-messaging) for the shared steering contract.diff --git a/docs/subagents/index.mdx b/docs/subagents/index.mdxindex de897fa30..2b0a6ad79 100644--- a/docs/subagents/index.mdx+++ b/docs/subagents/index.mdx@@ -259,7 +259,7 @@ By default, a subagent named `researcher` collides with an authored tool named `Do not rely on subagent delegation by itself as an approval boundary. Put sensitive tools behind `approval`, connection approval, route/session authorization, or other controls wherever those tools can be called.-Each delegated subagent spins up its own child session and stream. The parent stream carries the control-plane events `subagent.called` and `subagent.completed`, plus interactive `input.requested`, `authorization.required`, and `authorization.completed` events proxied from descendants so the root channel can prompt the user. To follow the child's other progress, read `subagent.called.data.childSessionId` and subscribe at `GET /eve/v1/session/:childSessionId/stream`.+Each delegated subagent spins up its own child session and stream. The parent stream carries the control-plane events `subagent.called` and `subagent.completed`, plus interactive `input.requested`, `authorization.required`, and `authorization.completed` events proxied from descendants so the root channel can prompt the user. To follow the child's other progress, pass the `subagent.called` event to [`session.streamSubagent()`](./guides/client/streaming#follow-a-subagent) on a client session attached to the parent. It reads `subagent.called.data.childStreamPath`: the child's own session stream for a local child, or a parent-origin proxy for a remote child, which the parent authenticates to the remote deployment.Both blocking and background invocations emit `subagent.called` after dispatch and `subagent.completed` after the parent records successful completion. Completion carries the actual output and identifies the same invocation by `callId`; the child session can remain available for reuse. A background working receipt is returned as an `action.result` tool output and does not emit completion. Background completion events do not wait for the cohort report. Failure and cancellation are not successful completion; task notifications retain those outcomes.diff --git a/e2e/fixtures/agent-subagents/evals/remote-subagent-stream.eval.ts b/e2e/fixtures/agent-subagents/evals/remote-subagent-stream.eval.tsnew file mode 100644index 000000000..ddf5da7ca--- /dev/null+++ b/e2e/fixtures/agent-subagents/evals/remote-subagent-stream.eval.ts@@ -0,0 +1,62 @@+import {+ isCurrentTurnBoundaryEvent,+ type MessageStreamEvent,+ type SubagentCalledStreamEvent,+} from "eve/client";+import { defineEval, type EveEvalContext, type EveEvalTurn } from "eve/evals";+import { satisfies } from "eve/evals/expect";++import { WORKSPACE_FORWARDING_MARKER, WORKSPACE_LOOKUP_MESSAGE } from "../constants";++const CREATE_CHILD_MESSAGE = [+ WORKSPACE_FORWARDING_MARKER,+ "Use remote-loopback with this message:",+ JSON.stringify(WORKSPACE_LOOKUP_MESSAGE),+].join(" ");++/** A client follows a remote child's activity through the parent session's proxy route. */+export default defineEval({+ tags: ["subagent-stream"],+ description:+ "A client reads a remote child's tool activity through the parent session instead of addressing the child deployment.",+ async test(t) {+ const turn = await t.send(CREATE_CHILD_MESSAGE);+ turn.expectOk();+ const called = await requireRemoteCall(t, turn);++ const childEvents: MessageStreamEvent[] = [];+ for await (const event of turn.session.streamSubagent(called)) {+ childEvents.push(event);+ if (isCurrentTurnBoundaryEvent(event)) break;+ }++ await t.require(+ childEvents,+ satisfies(+ (events: readonly MessageStreamEvent[]) =>+ events.some(+ (event) =>+ event.type === "action.result" &&+ event.data.status === "completed" &&+ event.data.result.kind === "tool-result" &&+ event.data.result.toolName === "read-workspace-label",+ ),+ "the proxied child stream carries the child's completed workspace lookup",+ ),+ );+ t.succeeded();+ },+});++/** The parent may finish its turn before recording the dispatch; wait for it on the stream if so. */+async function requireRemoteCall(+ t: EveEvalContext,+ turn: EveEvalTurn,+): Promise<SubagentCalledStreamEvent> {+ for (const event of turn.events) {+ if (event.type === "subagent.called" && event.data.name === "remote-loopback") return event;+ }+ return await t.target+ .watchTurn(turn.sessionId, { startIndex: turn.session.state.streamIndex })+ .waitForEvent("subagent.called", { data: { name: "remote-loopback" } });+}diff --git a/packages/eve/src/cli/dev/tui/runner.test.ts b/packages/eve/src/cli/dev/tui/runner.test.tsindex a05ccae61..47c539d5a 100644--- a/packages/eve/src/cli/dev/tui/runner.test.ts+++ b/packages/eve/src/cli/dev/tui/runner.test.ts@@ -255,7 +255,7 @@ describe("registryHandoffAddress", () => {}));const client = stubClient();const fetchChild = vi- .spyOn(client, "fetch")+ .fn<typeof fetch>().mockResolvedValueOnce(messageStreamResponseOf([stampTestEvent(@@ -358,6 +358,7 @@ describe("registryHandoffAddress", () => {stampTestEvent({ type: "session.completed" } as UnstampedMessageStreamEvent, 5),]);});+ vi.stubGlobal("fetch", fetchChild);const renderer = fakeRenderer({readPrompt: vi.fn()@@ -395,6 +396,7 @@ describe("registryHandoffAddress", () => {childStreamPath: "/eve/v1/session/child-session/stream",name: "self-modification__agent",sequence: 0,+ sessionId: "parent-session",turnId: "parent-turn",},},@@ -412,11 +414,9 @@ describe("registryHandoffAddress", () => {promptCommandHandler: { handle },}).run();- expect(fetchChild).toHaveBeenNthCalledWith(- 2,- "/eve/v1/session/child-session/stream?startIndex=3",- expect.objectContaining({ signal: expect.any(AbortSignal) }),- );+ const resumed = new URL(String(fetchChild.mock.calls[1]![0]));+ expect(resumed.pathname).toBe("/eve/v1/session/child-session/stream");+ expect(resumed.searchParams.get("startIndex")).toBe("3");expect(handle).toHaveBeenCalledWith({ type: "extension", name: "add", argument: "channel/slack" },expect.objectContaining({ title: "Add to your agent" }),@@ -3534,29 +3534,32 @@ describe("EveTUIRunner renderer teardown", () => {it("finishes the section on the child's own turn boundary, before subagent.completed", async () => {const client = stubClient();- vi.spyOn(client, "fetch").mockResolvedValue(- messageStreamResponseOf([- stampTestEvent(- {- type: "message.completed",- data: {- finishReason: "stop",- message: "final answer",- sequence: 0,- stepIndex: 0,- turnId: "turn-child",- },- } as UnstampedMessageStreamEvent,- 0,- ),- stampTestEvent(- {- type: "session.waiting",- data: { continuationToken: "session-id", wait: "next-user-message" },- } as UnstampedMessageStreamEvent,- 1,- ),- ]),+ vi.stubGlobal(+ "fetch",+ vi.fn<typeof fetch>().mockResolvedValue(+ messageStreamResponseOf([+ stampTestEvent(+ {+ type: "message.completed",+ data: {+ finishReason: "stop",+ message: "final answer",+ sequence: 0,+ stepIndex: 0,+ turnId: "turn-child",+ },+ } as UnstampedMessageStreamEvent,+ 0,+ ),+ stampTestEvent(+ {+ type: "session.waiting",+ data: { continuationToken: "session-id", wait: "next-user-message" },+ } as UnstampedMessageStreamEvent,+ 1,+ ),+ ]),+ ),);const completeSubagent = vi.fn();@@ -3740,8 +3743,8 @@ describe("EveTUIRunner renderer teardown", () => {it("aborts child-session streams when Ctrl-C exits the runner", async () => {const client = stubClient();let childSignal: AbortSignal | undefined;- vi.spyOn(client, "fetch").mockImplementation(async (_path, init) => {- const signal = init?.signal as AbortSignal | undefined;+ const fetchChild = vi.fn<typeof fetch>(async (_input, init) => {+ const signal = init?.signal ?? undefined;if (signal === undefined) {throw new Error("Expected the child stream to receive an abort signal.");}@@ -3749,7 +3752,11 @@ describe("EveTUIRunner renderer teardown", () => {return new Response(new ReadableStream<Uint8Array>({start(controller) {- signal.addEventListener("abort", () => controller.close(), { once: true });+ signal.addEventListener(+ "abort",+ () => controller.error(new DOMException("Aborted", "AbortError")),+ { once: true },+ );},}),{@@ -3757,6 +3764,7 @@ describe("EveTUIRunner renderer teardown", () => {},);});+ vi.stubGlobal("fetch", fetchChild);const runner = new EveTUIRunner({client,@@ -4785,18 +4793,25 @@ describe("EveTUIRunner cancelled-turn subagent settling", () => {// A child stream that never ends on its own — it only stops when the// pump aborts it (the scoped cancellation path under test).const client = stubClient();- vi.spyOn(client, "fetch").mockImplementation(- async (_path, init) =>- new Response(- new ReadableStream<Uint8Array>({- start(controller) {- init?.signal?.addEventListener("abort", () => controller.close(), { once: true });+ vi.stubGlobal(+ "fetch",+ vi.fn<typeof fetch>(+ async (_input, init) =>+ new Response(+ new ReadableStream<Uint8Array>({+ start(controller) {+ init?.signal?.addEventListener(+ "abort",+ () => controller.error(new DOMException("Aborted", "AbortError")),+ { once: true },+ );+ },+ }),+ {+ headers: { [EVE_STREAM_VERSION_HEADER]: EVE_MESSAGE_STREAM_VERSION },},- }),- {- headers: { [EVE_STREAM_VERSION_HEADER]: EVE_MESSAGE_STREAM_VERSION },- },- ),+ ),+ ),);const session = sessionYielding([@@ -4808,6 +4823,7 @@ describe("EveTUIRunner cancelled-turn subagent settling", () => {childStreamPath: "/eve/v1/session/child-a/stream",name: "researcher",sequence: 0,+ sessionId: "parent-session",turnId: "turn-a",},},@@ -4819,6 +4835,7 @@ describe("EveTUIRunner cancelled-turn subagent settling", () => {childStreamPath: "/eve/v1/session/child-1/stream",name: "researcher",sequence: 1,+ sessionId: "parent-session",turnId: "turn-1",},},diff --git a/packages/eve/src/cli/dev/tui/subagent-pump.test.ts b/packages/eve/src/cli/dev/tui/subagent-pump.test.tsindex c2823d9da..2b0e59875 100644--- a/packages/eve/src/cli/dev/tui/subagent-pump.test.ts+++ b/packages/eve/src/cli/dev/tui/subagent-pump.test.ts@@ -13,6 +13,7 @@ import { SubagentPump, type SubagentView } from "./subagent-pump.js";afterEach(() => {vi.useRealTimers();+ vi.restoreAllMocks();});function fakeView(): SubagentView {@@ -27,6 +28,46 @@ function fakeView(): SubagentView {};}+interface ChildRequest {+ readonly url: URL;+ readonly path: string;+ readonly startIndex: number;+ readonly signal: AbortSignal | undefined;+}++/** Serves every child stream request the client opens through `fetch`. */+function serveChildStreams(respond: (request: ChildRequest) => Response | Promise<Response>) {+ const requests: ChildRequest[] = [];+ vi.spyOn(globalThis, "fetch").mockImplementation(async (input, init) => {+ const url = new URL(String(input));+ const request: ChildRequest = {+ path: url.pathname,+ signal: init?.signal ?? undefined,+ startIndex: Number(url.searchParams.get("startIndex") ?? 0),+ url,+ };+ requests.push(request);+ return await respond(request);+ });+ return requests;+}++/** A durable child log that honors the requested cursor, like the stream route. */+function durableChild(events: readonly MessageStreamEvent[]) {+ return (request: ChildRequest) => responseOf(events.slice(request.startIndex));+}++function createPump(options: { host?: string; onToolCompleted?: () => Promise<void> } = {}) {+ const view = fakeView();+ const pump = new SubagentPump({+ client: new Client({ host: options.host ?? "http://localhost:3000" }),+ view,+ formatActionResultError: () => "failed",+ onToolCompleted: options.onToolCompleted,+ });+ return { pump, view };+}+/*** A hand-pumped child response: events pushed after scoped cancellation aborts* the pump must never reach the view.@@ -76,6 +117,7 @@ function subagentCalled(callId: string, turnId = "turn-1"): SubagentCalledStreamchildStreamPath: `/eve/v1/children/${callId}/stream`,name: "researcher",sequence: 1,+ sessionId: "parent",turnId,},} as SubagentCalledStreamEvent;@@ -132,8 +174,8 @@ function failedBoundaryEvent(index: number): MessageStreamEvent {);}-async function settleAsyncWork(): Promise<void> {- for (let i = 0; i < 8; i += 1) await Promise.resolve();+function completedEvent(index: number): MessageStreamEvent {+ return stampTestEvent({ type: "session.completed" } as UnstampedMessageStreamEvent, index);}describe("SubagentPump.settleCancelledTurn", () => {@@ -146,21 +188,19 @@ describe("SubagentPump.settleCancelledTurn", () => {["/eve/v1/children/background-b/stream", backgroundB],["/eve/v1/children/foreground-b/stream", foregroundB],]);- const client = new Client({ host: "http://localhost:3000" });- vi.spyOn(client, "fetch").mockImplementation(async (path, init) => {+ const requests = serveChildStreams(({ path, signal }) => {const child = streams.get(path);if (child === undefined) throw new Error(`Unexpected child path: ${path}`);- return child.response(init?.signal ?? undefined);+ return child.response(signal);});- const view = fakeView();- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });+ const { pump, view } = createPump();pump.begin(subagentCalled("background-a", "turn-a"));pump.background("background-a");pump.begin(subagentCalled("background-b", "turn-b"));pump.background("background-b");pump.begin(subagentCalled("foreground-b", "turn-b"));- await settleAsyncWork();+ await vi.waitFor(() => expect(requests).toHaveLength(3));pump.settleCancelledTurn("turn-b");@@ -177,18 +217,16 @@ describe("SubagentPump.settleCancelledTurn", () => {it("closes live sections and stops stale child output after cancellation", async () => {const child = pushableChildStream();- const client = new Client({ host: "http://localhost:3000" });- vi.spyOn(client, "fetch").mockImplementation(async (_path, init) =>- child.response(init?.signal ?? undefined),- );- const view = fakeView();- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });+ const requests = serveChildStreams(({ signal }) => child.response(signal));+ const { pump, view } = createPump();pump.begin(subagentCalled("call-1"));+ await vi.waitFor(() => expect(requests).toHaveLength(1));child.push(reasoningEvent("**Searching for current events**", 0));- await settleAsyncWork();- expect(view.upsertStep).toHaveBeenCalledWith(- expect.objectContaining({ callId: "call-1", finalized: false }),+ await vi.waitFor(() =>+ expect(view.upsertStep).toHaveBeenCalledWith(+ expect.objectContaining({ callId: "call-1", finalized: false }),+ ),);// The parent turn is cancelled: sections settle and the stream stops.@@ -201,7 +239,7 @@ describe("SubagentPump.settleCancelledTurn", () => {// A child still flushing output after the cancel paints nothing.const updatesAfterSettle = vi.mocked(view.upsertStep).mock.calls.length;child.push(reasoningEvent("stale output", 1));- await settleAsyncWork();+ await new Promise((resolve) => setTimeout(resolve, 10));expect(vi.mocked(view.upsertStep).mock.calls.length).toBe(updatesAfterSettle);// The parent's late `subagent.completed` fallback settles as a no-op.@@ -224,12 +262,8 @@ describe("SubagentPump background receipts", () => {it("keeps the section open until the child stream reaches its own boundary", async () => {const child = pushableChildStream();- const client = new Client({ host: "http://localhost:3000" });- vi.spyOn(client, "fetch").mockImplementation(async (_path, init) =>- child.response(init?.signal ?? undefined),- );- const view = fakeView();- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });+ const requests = serveChildStreams(({ signal }) => child.response(signal));+ const { pump, view } = createPump();pump.begin(subagentCalled("call-1"));pump.background("call-1");@@ -237,41 +271,34 @@ describe("SubagentPump background receipts", () => {expect(view.background).toHaveBeenCalledWith({ callId: "call-1" });expect(view.complete).not.toHaveBeenCalled();+ await vi.waitFor(() => expect(requests).toHaveLength(1));child.push(reasoningEvent("still working", 0));child.push(boundaryEvent(1));- await settleAsyncWork();+ await vi.waitFor(() =>+ expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "call-1" }),+ );expect(view.upsertStep).toHaveBeenCalledWith(expect.objectContaining({ callId: "call-1", reasoning: "still working" }),);- expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "call-1" });});it("treats a child failure boundary as authoritative completion", async () => {- const child = pushableChildStream();- const client = new Client({ host: "http://localhost:3000" });- vi.spyOn(client, "fetch").mockImplementation(async (_path, init) =>- child.response(init?.signal ?? undefined),- );- const view = fakeView();- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });+ serveChildStreams(durableChild([failedBoundaryEvent(0)]));+ const { pump, view } = createPump();pump.begin(subagentCalled("call-1"));pump.background("call-1");- child.push(failedBoundaryEvent(0));- await settleAsyncWork();- expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "call-1" });+ await vi.waitFor(() =>+ expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "call-1" }),+ );});it("reopens after parent completion and upgrades at the child boundary", async () => {const child = pushableChildStream();- const client = new Client({ host: "http://localhost:3000" });- vi.spyOn(client, "fetch").mockImplementation(async (_path, init) =>- child.response(init?.signal ?? undefined),- );- const view = fakeView();- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });+ const requests = serveChildStreams(({ signal }) => child.response(signal));+ const { pump, view } = createPump();pump.begin(subagentCalled("call-1"));pump.settle("call-1");@@ -279,119 +306,109 @@ describe("SubagentPump background receipts", () => {pump.begin(subagentCalled("call-1"));expect(view.begin).toHaveBeenCalledOnce();+ await vi.waitFor(() => expect(requests).toHaveLength(1));child.push(reasoningEvent("delayed output", 0));child.push(boundaryEvent(1));- await settleAsyncWork();+ await vi.waitFor(() =>+ expect(view.complete).toHaveBeenLastCalledWith({ authoritative: true, callId: "call-1" }),+ );expect(view.begin).toHaveBeenCalledTimes(2);expect(view.upsertStep).toHaveBeenCalledWith(expect.objectContaining({ callId: "call-1", reasoning: "delayed output" }),);- expect(view.complete).toHaveBeenLastCalledWith({ authoritative: true, callId: "call-1" });});});describe("SubagentPump child stream transport", () => {- it.each([- boundaryEvent(0),- stampTestEvent({ type: "session.completed" } as UnstampedMessageStreamEvent, 0),- failedBoundaryEvent(0),- ])("aborts a cloned open child stream at $type", async (boundary) => {- const client = new Client({ host: "http://localhost:3000" });- const view = fakeView();- const tracingError = vi.fn();- let signal: AbortSignal | undefined;- let closeStream = () => {};- let tracingDone: Promise<unknown> | undefined;- const fetch = vi.spyOn(client, "fetch").mockImplementation(async (_path, init) => {- signal = init?.signal ?? undefined;- const response = new Response(- new ReadableStream<Uint8Array>({- start(controller) {- closeStream = () => controller.error(new DOMException("Aborted", "AbortError"));- signal?.addEventListener("abort", closeStream, { once: true });- controller.enqueue(new TextEncoder().encode(`${JSON.stringify(boundary)}\n`));- },- }),- { headers: { [EVE_STREAM_VERSION_HEADER]: EVE_MESSAGE_STREAM_VERSION } },- );- tracingDone = response.clone().text().catch(tracingError);- return response;- });- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });-- try {- pump.begin(subagentCalled("call-1"));- await vi.waitFor(() =>- expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "call-1" }),- );- await vi.waitFor(() => expect(signal?.aborted).toBe(true));- await tracingDone;-- expect(tracingError).toHaveBeenCalledWith(expect.objectContaining({ name: "AbortError" }));- expect(fetch).toHaveBeenCalledOnce();- } finally {- closeStream();- pump.abortAll();- await tracingDone;- }- });+ it.each([boundaryEvent(0), completedEvent(0), failedBoundaryEvent(0)])(+ "aborts a cloned open child stream at $type",+ async (boundary) => {+ const tracingError = vi.fn();+ let signal: AbortSignal | undefined;+ let closeStream = () => {};+ let tracingDone: Promise<unknown> | undefined;+ const requests = serveChildStreams((request) => {+ signal = request.signal;+ const response = new Response(+ new ReadableStream<Uint8Array>({+ start(controller) {+ closeStream = () => controller.error(new DOMException("Aborted", "AbortError"));+ signal?.addEventListener("abort", closeStream, { once: true });+ controller.enqueue(new TextEncoder().encode(`${JSON.stringify(boundary)}\n`));+ },+ }),+ { headers: { [EVE_STREAM_VERSION_HEADER]: EVE_MESSAGE_STREAM_VERSION } },+ );+ tracingDone = response.clone().text().catch(tracingError);+ return response;+ });+ const { pump, view } = createPump();++ try {+ pump.begin(subagentCalled("call-1"));+ await vi.waitFor(() =>+ expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "call-1" }),+ );+ await vi.waitFor(() => expect(signal?.aborted).toBe(true));+ await tracingDone;++ expect(tracingError).toHaveBeenCalledWith(expect.objectContaining({ name: "AbortError" }));+ expect(requests).toHaveLength(1);+ } finally {+ closeStream();+ pump.abortAll();+ await tracingDone;+ }+ },+ );it("resumes from the prior cursor when a conversation subagent is called again", async () => {- const client = new Client({ host: "http://localhost:3000" });- const fetch = vi- .spyOn(client, "fetch")- .mockResolvedValueOnce(responseOf([boundaryEvent(0)]))- .mockResolvedValueOnce(- responseOf([- stampTestEvent(- {- type: "actions.requested",- data: {- actions: [- {- callId: "registry-add",- input: { address: "channel/slack" },- kind: "tool-call",- toolName: "registry_add",- },- ],- sequence: 1,- stepIndex: 0,- turnId: "child-turn-2",- },- } as UnstampedMessageStreamEvent,- 1,- ),- stampTestEvent(- {- type: "action.result",- data: {- result: {+ const requests = serveChildStreams(+ durableChild([+ boundaryEvent(0),+ stampTestEvent(+ {+ type: "actions.requested",+ data: {+ actions: [+ {callId: "registry-add",- kind: "tool-result",- output: { status: "needs-terminal", address: "channel/slack" },+ input: { address: "channel/slack" },+ kind: "tool-call",toolName: "registry_add",},- sequence: 2,- status: "completed",- stepIndex: 0,- turnId: "child-turn-2",+ ],+ sequence: 1,+ stepIndex: 0,+ turnId: "child-turn-2",+ },+ } as UnstampedMessageStreamEvent,+ 1,+ ),+ stampTestEvent(+ {+ type: "action.result",+ data: {+ result: {+ callId: "registry-add",+ kind: "tool-result",+ output: { status: "needs-terminal", address: "channel/slack" },+ toolName: "registry_add",},- } as UnstampedMessageStreamEvent,- 2,- ),- stampTestEvent({ type: "session.completed" } as UnstampedMessageStreamEvent, 3),- ]),- );+ sequence: 2,+ status: "completed",+ stepIndex: 0,+ turnId: "child-turn-2",+ },+ } as UnstampedMessageStreamEvent,+ 2,+ ),+ completedEvent(3),+ ]),+ );const onToolCompleted = vi.fn(async () => {});- const view = fakeView();- const pump = new SubagentPump({- client,- view,- formatActionResultError: () => "failed",- onToolCompleted,- });+ const { pump, view } = createPump({ onToolCompleted });const first = subagentCalled("call-1");first.data.childSessionId = "conversation-child";first.data.name = "self-modification__agent";@@ -406,11 +423,7 @@ describe("SubagentPump child stream transport", () => {pump.begin(second);await vi.waitFor(() => expect(onToolCompleted).toHaveBeenCalledOnce());- expect(fetch).toHaveBeenNthCalledWith(- 2,- "/eve/v1/children/call-2/stream?startIndex=1",- expect.objectContaining({ signal: expect.any(AbortSignal) }),- );+ expect(requests[1]).toMatchObject({ path: "/eve/v1/children/call-2/stream", startIndex: 1 });expect(onToolCompleted).toHaveBeenCalledWith("self-modification__agent", "registry_add", {status: "needs-terminal",address: "channel/slack",@@ -419,51 +432,37 @@ describe("SubagentPump child stream transport", () => {it("does not let a repeated call consume the previous call's trailing boundary", async () => {const firstStream = pushableChildStream();- const client = new Client({ host: "http://localhost:3000" });- const fetch = vi- .spyOn(client, "fetch")- .mockImplementationOnce(async (_path, init) =>- firstStream.response(init?.signal ?? undefined),- )- .mockResolvedValueOnce(- responseOf([- reasoningEvent("second turn", 1),- stampTestEvent({ type: "session.completed" } as UnstampedMessageStreamEvent, 2),- ]),- );- const view = fakeView();- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });+ const requests = serveChildStreams((request) =>+ request.startIndex === 0+ ? firstStream.response(request.signal)+ : responseOf([reasoningEvent("second turn", 1), completedEvent(2)]),+ );+ const { pump, view } = createPump();const first = subagentCalled("call-1");first.data.childSessionId = "conversation-child";const second = subagentCalled("call-2", "turn-2");second.data.childSessionId = "conversation-child";pump.begin(first);- await settleAsyncWork();+ await vi.waitFor(() => expect(requests).toHaveLength(1));pump.settle("call-1");pump.begin(second);- await settleAsyncWork();+ await new Promise((resolve) => setTimeout(resolve, 10));- expect(fetch).toHaveBeenCalledOnce();+ expect(requests).toHaveLength(1);firstStream.push(boundaryEvent(0));- await vi.waitFor(() => expect(fetch).toHaveBeenCalledTimes(2));await vi.waitFor(() =>expect(view.upsertStep).toHaveBeenCalledWith(expect.objectContaining({ callId: "call-2", reasoning: "second turn" }),),);- expect(fetch).toHaveBeenNthCalledWith(- 2,- "/eve/v1/children/call-2/stream?startIndex=1",- expect.objectContaining({ signal: expect.any(AbortSignal) }),- );+ expect(requests[1]).toMatchObject({ path: "/eve/v1/children/call-2/stream", startIndex: 1 });});it("leaves connection authorization events to the parent runner", async () => {- const client = new Client({ host: "http://localhost:3000" });- vi.spyOn(client, "fetch").mockResolvedValue(- responseOf([+ serveChildStreams(+ durableChild([stampTestEvent({type: "authorization.required",@@ -493,8 +492,7 @@ describe("SubagentPump child stream transport", () => {boundaryEvent(2),]),);- const view = fakeView();- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });+ const { pump, view } = createPump();pump.begin(subagentCalled("call-1"));await vi.waitFor(() =>@@ -505,68 +503,88 @@ describe("SubagentPump child stream transport", () => {expect(view.upsertTool).not.toHaveBeenCalled();});- it("reopens an exhausted source at its cursor without replaying output", async () => {+ it("reopens an exhausted source at its cursor", async () => {vi.useFakeTimers();- const first = reasoningEvent("looked up ", 0);- const second = reasoningEvent("the forecast", 1);- const client = new Client({ host: "http://localhost:3000" });- const fetch = vi- .spyOn(client, "fetch")- .mockResolvedValueOnce(responseOf([first]))- .mockResolvedValueOnce(responseOf([first, second, boundaryEvent(2)]));- const view = fakeView();- const pump = new SubagentPump({ client, view, formatActionResultError: () => "failed" });+ const log = [+ reasoningEvent("looked up ", 0),+ reasoningEvent("the forecast", 1),+ boundaryEvent(2),+ ];+ const requests = serveChildStreams((request) =>+ // The first connection ends after one event, before the child finishes.+ responseOf(request.startIndex === 0 ? log.slice(0, 1) : log.slice(request.startIndex)),+ );+ const { pump, view } = createPump();pump.begin(subagentCalled("call-1"));- await settleAsyncWork();- await vi.advanceTimersByTimeAsync(100);- await settleAsyncWork();-- expect(fetch).toHaveBeenNthCalledWith(- 1,- "/eve/v1/children/call-1/stream",- expect.objectContaining({ signal: expect.any(AbortSignal) }),- );- expect(fetch).toHaveBeenNthCalledWith(- 2,- "/eve/v1/children/call-1/stream?startIndex=1",- expect.objectContaining({ signal: expect.any(AbortSignal) }),+ await vi.waitFor(() =>+ expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "call-1" }),);++ expect(requests.map(({ path, startIndex }) => ({ path, startIndex }))).toEqual([+ { path: "/eve/v1/children/call-1/stream", startIndex: 0 },+ { path: "/eve/v1/children/call-1/stream", startIndex: 1 },+ ]);expect(view.upsertStep).toHaveBeenLastCalledWith(expect.objectContaining({ reasoning: "looked up the forecast" }),);+ });++ it("keeps following a silent child past the default idle budget", async () => {+ vi.useFakeTimers();+ const requests = serveChildStreams((request) =>+ responseOf(requests.length > 8 ? [boundaryEvent(request.startIndex)] : []),+ );+ const { pump, view } = createPump();++ pump.begin(subagentCalled("call-1"));+ await vi.advanceTimersByTimeAsync(60_000);++ expect(requests).toHaveLength(9);expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "call-1" });});+ it("stops following when the child stream is refused", async () => {+ const requests = serveChildStreams(() => new Response("forbidden", { status: 403 }));+ const { pump, view } = createPump();++ pump.begin(subagentCalled("call-1"));+ await vi.waitFor(() => expect(requests).toHaveLength(1));+ await new Promise((resolve) => setTimeout(resolve, 10));++ expect(requests).toHaveLength(1);+ expect(view.complete).not.toHaveBeenCalled();+ pump.settle("call-1");+ expect(view.complete).toHaveBeenCalledWith({ authoritative: false, callId: "call-1" });+ });+it("uses the parent-authored child path and never the remote URL", async () => {- const client = new Client({ host: "https://parent.example" });- const fetch = vi.spyOn(client, "fetch").mockResolvedValue(responseOf([boundaryEvent(0)]));- const pump = new SubagentPump({ client, view: fakeView(), formatActionResultError: () => "" });+ const requests = serveChildStreams(durableChild([boundaryEvent(0)]));+ const { pump, view } = createPump({ host: "https://parent.example" });const called = subagentCalled("remote-call");called.data.childStreamPath = "/eve/v1/session/parent/subagents/remote-call/child/stream";called.data.remote = { url: "https://remote.example/private" };pump.begin(called);- await settleAsyncWork();-- expect(fetch).toHaveBeenCalledWith(- called.data.childStreamPath,- expect.objectContaining({ signal: expect.any(AbortSignal) }),+ await vi.waitFor(() =>+ expect(view.complete).toHaveBeenCalledWith({ authoritative: true, callId: "remote-call" }),);- expect(fetch.mock.calls.flatMap((call) => call).join(" ")).not.toContain("remote.example");++ expect(requests[0]!.url.origin).toBe("https://parent.example");+ expect(requests[0]!.path).toBe(called.data.childStreamPath);+ expect(requests.map(({ url }) => url.href).join(" ")).not.toContain("remote.example");});it("does not reopen after abortAll", async () => {vi.useFakeTimers();- const client = new Client({ host: "http://localhost:3000" });- const fetch = vi.spyOn(client, "fetch").mockResolvedValue(responseOf([]));- const pump = new SubagentPump({ client, view: fakeView(), formatActionResultError: () => "" });+ const requests = serveChildStreams(() => responseOf([]));+ const { pump } = createPump();pump.begin(subagentCalled("call-1"));- await settleAsyncWork();+ await vi.waitFor(() => expect(requests).toHaveLength(1));pump.abortAll();await vi.advanceTimersByTimeAsync(10_000);- expect(fetch).toHaveBeenCalledOnce();+ expect(requests).toHaveLength(1);});});diff --git a/packages/eve/src/cli/dev/tui/subagent-pump.ts b/packages/eve/src/cli/dev/tui/subagent-pump.tsindex e1ddc6e84..a2bd47ace 100644--- a/packages/eve/src/cli/dev/tui/subagent-pump.ts+++ b/packages/eve/src/cli/dev/tui/subagent-pump.ts@@ -6,18 +6,23 @@* {@link SubagentView} seam.*/-import type { Client } from "#client/index.js";-import { readNdjsonStream } from "#client/ndjson.js";-import { readMessageStreamVersion } from "#client/stream-version.js";-import { createEventDeduper, type EventDeduper } from "#protocol/event-dedupe.js";+import type { Client, StreamReconnectPolicy } from "#client/index.js";import {isCurrentTurnBoundaryEvent,type ActionResultStreamEvent,type MessageStreamEvent,type SubagentCalledStreamEvent,} from "#protocol/message.js";-const childStreamReconnectBaseDelayMs = 100;-const childStreamReconnectMaxDelayMs = 2_000;++/**+ * Pumps end on the child boundary or abort, never on a retry budget: a child+ * parked for HITL can stay silent indefinitely, and the dev server can restart+ * underneath an open follower.+ */+const childStreamReconnectPolicy = {+ streamIdleReconnectPolicy: { maxAttempts: Infinity },+ streamOpenReconnectPolicy: { maxAttempts: Infinity },+} as const satisfies StreamReconnectPolicy;/*** The renderer's subagent surface. One cohesive capability: a renderer that@@ -73,10 +78,8 @@ export type SubagentRun = {background: boolean;/** Parent completion is provisional; only a child boundary is authoritative. */status: "open" | "provisional" | "authoritative";- /** Parent-authored route on the parent origin, valid for local and remote children. */- childStreamPath: string;- /** Absolute durable cursor retained across exhausted transport sources. */- childStreamIndex: number;+ /** Dispatch event whose parent-origin child stream this run follows. */+ called: SubagentCalledStreamEvent;/*** One entry per logical "child message" — independent of the child's* `stepIndex` field, which the harness can reuse across multiple@@ -94,11 +97,6 @@ export type SubagentRun = {/** Monotonic counter for new section keys. */nextSectionKey: number;tools: Map<string, SubagentToolState>;- /**- * Child events already folded into this run. A restarted pump replays the- * child stream from `streamIndex: 0` while this run's state survives.- */- seenChildEvents: EventDeduper;};export type SubagentStepUpdate = {@@ -172,13 +170,11 @@ export class SubagentPump {parentTurnId: called.data.turnId,background: false,status: "open",- childStreamPath: called.data.childStreamPath,- childStreamIndex: this.#childStreamIndices.get(called.data.childSessionId) ?? 0,+ called,steps: new Map(),currentSectionKey: null,nextSectionKey: 0,tools: new Map(),- seenChildEvents: createEventDeduper(),});} else {existing.name = called.data.name;@@ -258,7 +254,6 @@ export class SubagentPump {if (run === undefined || run.status === "authoritative") return;const activeCallId = this.#activeChildCalls.get(run.childSessionId);if (activeCallId === undefined) {- run.childStreamIndex = this.#childStreamIndices.get(run.childSessionId) ?? 0;this.#activeChildCalls.set(run.childSessionId, callId);this.#startPump(callId);return;@@ -280,50 +275,32 @@ export class SubagentPump {this.#pumps.set(callId, controller);void (async () => {- let reconnectDelayMs = childStreamReconnectBaseDelayMs;+ const { childSessionId } = run;+ let cursor = this.#childStreamIndices.get(childSessionId) ?? 0;try {- while (!controller.signal.aborted && run.status !== "authoritative") {- let deliveredEvent = false;- try {- const response = await client.fetch(- streamPathAt(run.childStreamPath, run.childStreamIndex),- {- cache: "no-store",- signal: controller.signal,- },- );- if (!response.ok || response.body === null) {- await response.body?.cancel().catch(() => {});- throw new Error(`Child stream returned ${response.status}.`);- }-- for await (const event of readNdjsonStream(response.body, {- streamVersion: readMessageStreamVersion(response.headers),- })) {- if (controller.signal.aborted) return;- deliveredEvent = true;- run.childStreamIndex += 1;- this.#childStreamIndices.set(run.childSessionId, run.childStreamIndex);- const childEventWork = this.#applyChildEvent(callId, event);- if (childEventWork !== undefined) await childEventWork;- if (isCurrentTurnBoundaryEvent(event)) {- // A proxied child approval parks at an intermediate- // `session.waiting`. Keep following from this cursor so the- // approved tool result can still update the nested view.- if (event.type === "session.waiting" && hasPendingChildApproval(run)) continue;- this.#finalizeRun(callId, true);- return;- }- }- } catch {- if (controller.signal.aborted) return;- }-- reconnectDelayMs = deliveredEvent- ? childStreamReconnectBaseDelayMs- : Math.min(reconnectDelayMs * 2, childStreamReconnectMaxDelayMs);- await abortableDelay(reconnectDelayMs, controller.signal);+ const events = client.sessions+ .attach(run.called.data.sessionId)+ .streamSubagent(run.called, {+ signal: controller.signal,+ startIndex: cursor,+ streamReconnectPolicy: childStreamReconnectPolicy,+ });+ for await (const event of events) {+ if (controller.signal.aborted) return;+ this.#childStreamIndices.set(childSessionId, (cursor += 1));+ const childEventWork = this.#applyChildEvent(callId, event);+ if (childEventWork !== undefined) await childEventWork;+ if (!isCurrentTurnBoundaryEvent(event)) continue;+ // A proxied child approval parks at an intermediate+ // `session.waiting`. Keep following so the approved tool result+ // can still update the nested view.+ if (event.type === "session.waiting" && hasPendingChildApproval(run)) continue;+ this.#finalizeRun(callId, true);+ return;}+ } catch {+ // Only a non-retryable failure ends the follower early; the parent's+ // `subagent.completed` still settles the section.} finally {controller.abort();if (this.#pumps.get(callId) === controller) this.#pumps.delete(callId);@@ -435,7 +412,6 @@ export class SubagentPump {if (nextRun === undefined || nextRun.status === "authoritative") continue;if (remaining.length === 0) this.#queuedChildCalls.delete(childSessionId);else this.#queuedChildCalls.set(childSessionId, remaining);- nextRun.childStreamIndex = this.#childStreamIndices.get(childSessionId) ?? 0;this.#activeChildCalls.set(childSessionId, nextCallId);this.#startPump(nextCallId);return;@@ -460,7 +436,6 @@ export class SubagentPump {#applyChildEvent(callId: string, event: MessageStreamEvent): Promise<void> | undefined {const run = this.#runs.get(callId);if (!run) return;- if (!run.seenChildEvents.admit(event)) return;// Parent completion is provisional. Any delayed child event reopens the// mutable cohort until the child stream supplies its own boundary.if (run.status === "provisional") {@@ -609,27 +584,6 @@ function hasPendingChildApproval(run: SubagentRun): boolean {return [...run.tools.values()].some((tool) => tool.status === "approval-requested");}-function streamPathAt(path: string, startIndex: number): string {- if (startIndex === 0) return path;- return `${path}${path.includes("?") ? "&" : "?"}startIndex=${startIndex}`;-}--async function abortableDelay(ms: number, signal: AbortSignal): Promise<void> {- if (signal.aborted) return;- await new Promise<void>((resolve) => {- const onAbort = () => {- clearTimeout(timer);- resolve();- };- const timer = setTimeout(() => {- signal.removeEventListener("abort", onAbort);- resolve();- }, ms);- timer.unref?.();- signal.addEventListener("abort", onAbort, { once: true });- });-}-function openCurrentSubagentSection(run: SubagentRun): {key: number;step: SubagentChildStep;diff --git a/packages/eve/src/client/open-stream.test.ts b/packages/eve/src/client/open-stream.test.tsindex 5ec5b5e54..2fe903f55 100644--- a/packages/eve/src/client/open-stream.test.ts+++ b/packages/eve/src/client/open-stream.test.ts@@ -35,7 +35,7 @@ describe("openStreamBody", () => {const connection = await openStreamBody({host: "https://agent.example",resolveHeaders: () => Promise.resolve(new Headers()),- sessionId: "session_1",+ path: "/eve/v1/session/session_1/stream",startIndex: 0,});connection.close();@@ -64,7 +64,7 @@ describe("openStreamBody", () => {const connection = await openStreamBody({host: "https://agent.example",resolveHeaders: () => Promise.resolve(new Headers()),- sessionId: "session_1",+ path: "/eve/v1/session/session_1/stream",startIndex: 0,});connection.close();@@ -91,7 +91,7 @@ describe("followStreamIterable", () => {resolveReconnectPolicy: () => ({streamIdleReconnectPolicy: { maxAttempts: 1, baseDelayMs: 0 },}),- sessionId: "session_1",+ path: "/eve/v1/session/session_1/stream",startIndex: 0,})) {expect.unreachable(`Unexpected event: ${event.type}`);@@ -124,7 +124,7 @@ describe("followStreamIterable", () => {for await (const event of followStreamIterable({host: "https://agent.example",resolveHeaders: () => Promise.resolve(new Headers()),- sessionId: "session_1",+ path: "/eve/v1/session/session_1/stream",...options,})) {expect.unreachable(`Unexpected event: ${event.type}`);@@ -179,7 +179,7 @@ describe("followStreamIterable", () => {for await (const event of followStreamIterable({host: "https://agent.example",resolveHeaders: () => Promise.resolve(new Headers()),- sessionId: "session_1",+ path: "/eve/v1/session/session_1/stream",startIndex: 1,follow,})) {@@ -213,7 +213,7 @@ describe("followStreamIterable", () => {for await (const _event of followStreamIterable({host: "https://agent.example",resolveHeaders: () => Promise.resolve(new Headers()),- sessionId: "session_1",+ path: "/eve/v1/session/session_1/stream",signal: abort.signal,startIndex: 0,})) {diff --git a/packages/eve/src/client/open-stream.ts b/packages/eve/src/client/open-stream.tsindex 9deaa48ab..3818a7aae 100644--- a/packages/eve/src/client/open-stream.ts+++ b/packages/eve/src/client/open-stream.ts@@ -5,7 +5,6 @@ import {EVE_STREAM_TAIL_INDEX_HEADER,} from "#protocol/message.js";import type { MessageStreamVersion } from "#protocol/message-version.js";-import { createEveSessionStreamRoutePath } from "#protocol/routes.js";import { ClientError } from "#client/client-error.js";import { isStreamDisconnectError, readNdjsonStream } from "#client/ndjson.js";import { readMessageStreamVersion } from "#client/stream-version.js";@@ -97,7 +96,8 @@ interface FollowStreamInput {readonly streamReadIdleTimeoutMs?: number;readonly resolveHeaders: () => Promise<Headers>;readonly redirect?: ClientRedirectPolicy;- readonly sessionId: string;+ /** eve stream route path, such as a session stream or a parent-origin subagent stream. */+ readonly path: string;readonly signal?: AbortSignal;readonly startIndex: number;/** Follow the live stream after the durable tail (default). `false` bounds the read at the tail. */@@ -110,7 +110,7 @@ interface OpenStreamInput extends FollowStreamInput {}/**- * Follows a session's durable event stream from an absolute cursor,+ * Follows one durable event stream route from an absolute cursor,* transparently reconnecting whenever the transport ends.** Transport endings reconnect from the advanced cursor. Progress resets the@@ -289,7 +289,7 @@ export async function openStreamBody(input.signal?.throwIfAborted();const url = createClientUrl(input.host,- createEveSessionStreamRoutePath(input.sessionId),+ input.path,Object.keys(searchParams).length > 0 ? searchParams : undefined,);diff --git a/packages/eve/src/client/session.test.ts b/packages/eve/src/client/session.test.tsindex 74518b7c9..f915ed34b 100644--- a/packages/eve/src/client/session.test.ts+++ b/packages/eve/src/client/session.test.ts@@ -3,7 +3,12 @@ import { afterEach, describe, expect, it, vi } from "vitest";import { ClientError } from "#client/client-error.js";import { ClientSession } from "#client/session.js";import type { ClientSessionState } from "#client/types.js";-import { EVE_MESSAGE_STREAM_VERSION, EVE_STREAM_VERSION_HEADER } from "#protocol/message.js";+import {+ EVE_MESSAGE_STREAM_VERSION,+ EVE_STREAM_VERSION_HEADER,+ createSubagentCalledEvent,+ type SubagentCalledStreamEvent,+} from "#protocol/message.js";afterEach(() => {vi.restoreAllMocks();@@ -1330,3 +1335,120 @@ describe("ClientSession", () => {expect(streamStartIndices).toEqual([null, "2"]);});});++describe("ClientSession.streamSubagent", () => {+ function calledEvent(+ input: { readonly remote?: boolean; readonly sessionId?: string } = {},+ ): SubagentCalledStreamEvent {+ return createSubagentCalledEvent({+ callId: "call_1",+ childSessionId: "child_1",+ name: "research",+ remote:+ input.remote === false+ ? undefined+ : { resolverId: "subagents/research", url: "https://remote.test" },+ sequence: 1,+ sessionId: input.sessionId ?? "session_1",+ toolName: "research",+ turnId: "turn_1",+ workflowId: "workflow_1",+ });+ }++ const childEvents = [+ { type: "turn.started", data: { turnId: "child_turn_1" } },+ { type: "turn.completed", data: { turnId: "child_turn_1" } },+ ];++ it("follows a remote child through the parent proxy with this session's credentials", async () => {+ const requests: { readonly url: URL; readonly authorization: string | null }[] = [];+ vi.spyOn(globalThis, "fetch").mockImplementation(async (request, init) => {+ requests.push({+ authorization: new Headers(init?.headers).get("authorization"),+ url: new URL(String(request)),+ });+ return createBoundedStreamResponse(childEvents);+ });+ const parentState = { sessionId: "session_1", streamIndex: 4 };+ const session = createSession(parentState, {+ resolveHeaders: async () => new Headers({ authorization: "Bearer parent" }),+ });++ const types: string[] = [];+ for await (const event of session.streamSubagent(calledEvent(), { follow: false })) {+ types.push(event.type);+ }++ expect(types).toEqual(["turn.started", "turn.completed"]);+ expect(requests).toHaveLength(1);+ expect(requests[0]!.url.origin).toBe("https://eve.test");+ expect(requests[0]!.url.pathname).toBe(+ "/eve/v1/session/session_1/subagents/call_1/child_1/stream",+ );+ expect(requests[0]!.url.searchParams.get("startIndex")).toBeNull();+ expect(requests[0]!.authorization).toBe("Bearer parent");+ expect(session.state).toBe(parentState);+ });++ it("resumes a child from its own cursor without touching the parent cursor", async () => {+ const urls: URL[] = [];+ vi.spyOn(globalThis, "fetch").mockImplementation(async (request) => {+ urls.push(new URL(String(request)));+ return createStreamResponse(childEvents.slice(1));+ });+ const parentState = { sessionId: "session_1", streamIndex: 9 };+ const session = createSession(parentState);++ const types: string[] = [];+ for await (const event of session.streamSubagent(calledEvent(), {+ startIndex: 1,+ streamReconnectPolicy: { reconnect: false },+ })) {+ types.push(event.type);+ }++ expect(types).toEqual(["turn.completed"]);+ expect(urls[0]!.searchParams.get("startIndex")).toBe("1");+ expect(session.state).toBe(parentState);+ });++ it("follows a local child through its own session stream route", async () => {+ const urls: URL[] = [];+ vi.spyOn(globalThis, "fetch").mockImplementation(async (request) => {+ urls.push(new URL(String(request)));+ return createBoundedStreamResponse(childEvents);+ });+ const session = createSession();++ for await (const _event of session.streamSubagent(calledEvent({ remote: false }), {+ follow: false,+ })) {+ // Drain the bounded child stream.+ }++ expect(urls[0]!.pathname).toBe("/eve/v1/session/child_1/stream");+ });++ it("rejects a subagent event from a different parent session", () => {+ const fetchMock = vi.spyOn(globalThis, "fetch");+ const session = createSession();++ expect(() => session.streamSubagent(calledEvent({ sessionId: "session_2" }))).toThrow(+ "streamSubagent() requires a subagent.called event from session session_1, but it came from session session_2.",+ );+ expect(fetchMock).not.toHaveBeenCalled();+ });++ it("rejects a subagent event recorded before childStreamPath existed", () => {+ const fetchMock = vi.spyOn(globalThis, "fetch");+ const session = createSession();+ const { childStreamPath: _, ...legacyData } = calledEvent().data;+ const legacy = { ...calledEvent(), data: legacyData } as SubagentCalledStreamEvent;++ expect(() => session.streamSubagent(legacy)).toThrow(+ "streamSubagent() requires a subagent.called event with childStreamPath, but call call_1 has none. The event was recorded by an older eve version.",+ );+ expect(fetchMock).not.toHaveBeenCalled();+ });+});diff --git a/packages/eve/src/client/session.ts b/packages/eve/src/client/session.tsindex 9ad5d784a..2634dd9b3 100644--- a/packages/eve/src/client/session.ts+++ b/packages/eve/src/client/session.ts@@ -1,7 +1,11 @@import { updatePendingAuthorizations } from "#client/session-utils.js";-import type { MessageStreamEvent } from "#protocol/message.js";+import type { MessageStreamEvent, SubagentCalledStreamEvent } from "#protocol/message.js";import { EVE_SESSION_ID_HEADER, isCurrentTurnBoundaryEvent } from "#protocol/message.js";-import { EVE_SESSION_ROUTE_PATH, createEveSessionRoutePath } from "#protocol/routes.js";+import {+ EVE_SESSION_ROUTE_PATH,+ createEveSessionRoutePath,+ createEveSessionStreamRoutePath,+} from "#protocol/routes.js";import { ClientError } from "#client/client-error.js";import { MessageResponse } from "#client/message-response.js";import { followStreamIterable, sleep } from "#client/open-stream.js";@@ -206,6 +210,53 @@ export class ClientSession {return this.#streamAndAdvance(options);}+ /**+ * Follows one delegated child's durable event stream through this parent session.+ *+ * Pass a `subagent.called` event from this session. The client reads its+ * `childStreamPath` with this session's host and credentials: a local child's+ * own stream route, or the parent-origin proxy for a remote child, which the+ * parent deployment authenticates to the remote agent. Reading the child never+ * advances this session's cursor. The child cursor starts at `0`; pass+ * `startIndex` to resume. Stop at a child turn boundary with+ * `isCurrentTurnBoundaryEvent`.+ *+ * @throws {Error} When `called` belongs to a different session or has no+ * `childStreamPath` because an older eve version recorded it.+ */+ streamSubagent(+ called: SubagentCalledStreamEvent,+ options?: StreamOptions,+ ): AsyncIterable<MessageStreamEvent> {+ if (called.data.sessionId !== this.#state.sessionId) {+ throw new Error(+ `streamSubagent() requires a subagent.called event from session ${this.#state.sessionId}, but it came from session ${called.data.sessionId}.`,+ );+ }+ // Events persisted before childStreamPath existed replay without it.+ if (typeof called.data.childStreamPath !== "string") {+ throw new Error(+ `streamSubagent() requires a subagent.called event with childStreamPath, but call ${called.data.callId} has none. The event was recorded by an older eve version.`,+ );+ }+ const startIndex = options?.startIndex ?? 0;+ if (options?.follow === false && startIndex < 0) {+ throw new Error(+ "streamSubagent({ follow: false }) requires a nonnegative startIndex; a tail-relative cursor cannot be bounded.",+ );+ }+ return followStreamIterable({+ follow: options?.follow,+ host: this.#context.host,+ path: called.data.childStreamPath,+ redirect: this.#context.redirect,+ resolveHeaders: () => this.#context.resolveHeaders(),+ signal: options?.signal,+ startIndex,+ streamReconnectPolicy: options?.streamReconnectPolicy,+ });+ }+[followSession](options: FollowSessionOptions): AsyncIterable<MessageStreamEvent> {return this.#streamAndAdvance({ ...options, keepAlive: true });}@@ -323,8 +374,8 @@ export class ClientSession {host: this.#context.host,keepAlive: input.keepAlive,resolveHeaders: () => this.#context.resolveHeaders(input.resolveHeaders?.() ?? input.headers),+ path: createEveSessionStreamRoutePath(this.#state.sessionId),redirect: this.#context.redirect,- sessionId: this.#state.sessionId,signal: input.signal,startIndex: input.startIndex,streamReconnectPolicy: input.streamReconnectPolicy,diff --git a/packages/eve/src/client/stream-follow.integration.test.ts b/packages/eve/src/client/stream-follow.integration.test.tsindex 1519089d8..804b8647a 100644--- a/packages/eve/src/client/stream-follow.integration.test.ts+++ b/packages/eve/src/client/stream-follow.integration.test.ts@@ -37,7 +37,7 @@ function follow(host: string, options?: { follow?: boolean }) {follow: options?.follow,host,resolveHeaders: () => Promise.resolve(new Headers()),- sessionId: "s",+ path: "/eve/v1/session/s/stream",startIndex: 0,});}@@ -120,7 +120,7 @@ describe("stream following over real sockets", () => {for await (const event of followStreamIterable({host,resolveHeaders: () => Promise.resolve(new Headers()),- sessionId: "s",+ path: "/eve/v1/session/s/stream",startIndex: 0,streamReadIdleTimeoutMs: 50,})) {diff --git a/packages/eve/src/client/subagent-stream.integration.test.ts b/packages/eve/src/client/subagent-stream.integration.test.tsnew file mode 100644index 000000000..1a3a22101--- /dev/null+++ b/packages/eve/src/client/subagent-stream.integration.test.ts@@ -0,0 +1,189 @@+import { afterEach, describe, expect, it, vi } from "vitest";++import type { RouteHandlerArgs } from "#channel/routes.js";+import type { Session } from "#channel/session.js";+import { Client } from "#client/client.js";+import { attachRemoteAgentStreamHeadersResolver } from "#internal/nitro/routes/channel-route-context.js";+import { mockChannelContext } from "#internal/testing/mocks/mock-channel-operations.js";+import { stampTestEvent } from "#internal/testing/events.js";+import {+ EVE_MESSAGE_STREAM_VERSION,+ EVE_STREAM_CONTROL_VERSION,+ EVE_STREAM_CONTROL_VERSION_QUERY,+ EVE_STREAM_TAIL_INDEX_HEADER,+ EVE_STREAM_VERSION_HEADER,+ createSubagentCalledEvent,+ type MessageStreamEvent,+ type SubagentCalledStreamEvent,+} from "#protocol/message.js";+import { EVE_SUBAGENT_STREAM_ROUTE_PATTERN } from "#protocol/routes.js";+import { none } from "#public/channels/auth.js";+import { eveChannel } from "#public/channels/eve.js";++const PARENT_ORIGIN = "https://parent.test";+const REMOTE_URL = "https://remote.test/base";++afterEach(() => {+ vi.unstubAllGlobals();+});++describe("ClientSession.streamSubagent through the parent proxy", () => {+ it("reads a remote child's events through the parent channel with authored remote credentials", async () => {+ const called = createCalled();+ const childEvents = [+ { type: "turn.started", data: { turnId: "child-turn" } },+ {+ type: "message.completed",+ data: { message: "Found three matches.", turnId: "child-turn" },+ },+ { type: "turn.completed", data: { turnId: "child-turn" } },+ ];+ const remoteRequests: { readonly url: string; readonly headers: Headers }[] = [];+ const parentRoute = createParentRoute(stampTestEvent(called, 0));++ vi.stubGlobal("fetch", async (input: string | URL | Request, init?: RequestInit) => {+ const url = new URL(input instanceof Request ? input.url : String(input));+ if (url.origin === PARENT_ORIGIN) {+ return await parentRoute(new Request(url, init));+ }+ remoteRequests.push({ headers: new Headers(init?.headers), url: url.toString() });+ return ndjsonResponse(childEvents);+ });++ const session = new Client({ host: PARENT_ORIGIN }).sessions.attach("parent-1");+ const received: MessageStreamEvent[] = [];+ for await (const event of session.streamSubagent(called, { follow: false })) {+ received.push(event);+ }++ expect(received.map((event) => event.type)).toEqual([+ "turn.started",+ "message.completed",+ "turn.completed",+ ]);+ expect(remoteRequests).toHaveLength(1);+ const remoteUrl = new URL(remoteRequests[0]!.url);+ expect(`${remoteUrl.origin}${remoteUrl.pathname}`).toBe(+ `${REMOTE_URL}/eve/v1/session/child-1/stream`,+ );+ expect(remoteUrl.searchParams.get("includeTailIndex")).toBe("1");+ expect(remoteUrl.searchParams.get(EVE_STREAM_CONTROL_VERSION_QUERY)).toBe(+ EVE_STREAM_CONTROL_VERSION,+ );+ expect(remoteUrl.searchParams.has("startIndex")).toBe(false);+ expect(remoteRequests[0]!.headers.get("authorization")).toBe("Bearer authored-remote");+ expect(session.state).toEqual({ sessionId: "parent-1", streamIndex: 0 });+ });++ it("surfaces the parent's refusal when the child is not bound to that parent", async () => {+ const called = createCalled();+ const parentRoute = createParentRoute(stampTestEvent(createCalled({ callId: "other" }), 0));+ const remoteFetch = vi.fn();++ vi.stubGlobal("fetch", async (input: string | URL | Request, init?: RequestInit) => {+ const url = new URL(input instanceof Request ? input.url : String(input));+ if (url.origin === PARENT_ORIGIN) {+ return await parentRoute(new Request(url, init));+ }+ return remoteFetch();+ });++ const session = new Client({ host: PARENT_ORIGIN }).sessions.attach("parent-1");+ const read = async () => {+ for await (const _event of session.streamSubagent(called, {+ streamReconnectPolicy: { reconnect: false },+ })) {+ // The proxy refuses before any child event exists.+ }+ };++ await expect(read()).rejects.toMatchObject({ status: 404 });+ expect(remoteFetch).not.toHaveBeenCalled();+ });+});++function createCalled(overrides: { readonly callId?: string } = {}): SubagentCalledStreamEvent {+ return createSubagentCalledEvent({+ callId: overrides.callId ?? "call-1",+ childSessionId: "child-1",+ name: "research",+ remote: { resolverId: "subagents/research", url: REMOTE_URL },+ sequence: 1,+ sessionId: "parent-1",+ toolName: "research",+ turnId: "turn-1",+ workflowId: "workflow-1",+ });+}++/** The parent deployment's real eve channel route over one recorded parent event. */+function createParentRoute(+ parentEvent: MessageStreamEvent,+): (request: Request) => Promise<Response> {+ const channel = eveChannel({ auth: none() });+ const route = channel.routes.find(+ (candidate) =>+ candidate.method === "GET" && candidate.path === EVE_SUBAGENT_STREAM_ROUTE_PATTERN,+ ) as { handler: (request: Request, args: RouteHandlerArgs) => Promise<Response> } | undefined;+ if (route === undefined) throw new Error("No remote subagent stream route found.");++ const parent: Session = {+ id: "parent-1",+ send: vi.fn(),+ respond: vi.fn(),+ async cancel() {+ return { status: "no_active_turn" };+ },+ async compact() {+ return { sessionId: "parent-1", status: "accepted" };+ },+ async clear() {+ return { sessionId: "parent-1", status: "accepted" };+ },+ async reset() {+ return { previousSessionId: "parent-1", status: "reset" };+ },+ async getEventStream() {+ return new ReadableStream<MessageStreamEvent>({+ start(controller) {+ controller.enqueue(parentEvent);+ controller.close();+ },+ });+ },+ async getStreamTailIndex() {+ return 0;+ },+ };++ return async (request) => {+ const segments = new URL(request.url).pathname.split("/");+ const args = attachRemoteAgentStreamHeadersResolver(+ {+ ...mockChannelContext(vi.fn()),+ attachSession: vi.fn().mockReturnValue(parent),+ params: {+ callId: decodeURIComponent(segments[6]!),+ childSessionId: decodeURIComponent(segments[7]!),+ parentSessionId: decodeURIComponent(segments[4]!),+ },+ requestIp: "127.0.0.1",+ to: vi.fn() as never,+ waitUntil: () => undefined,+ },+ async () => ({ authorization: "Bearer authored-remote" }),+ );+ return await route.handler(request, args);+ };+}++function ndjsonResponse(events: readonly object[]): Response {+ const body = events.map((event) => `${JSON.stringify(event)}\n`).join("");+ return new Response(body, {+ headers: {+ "content-type": "application/x-ndjson; charset=utf-8",+ [EVE_STREAM_TAIL_INDEX_HEADER]: String(events.length - 1),+ [EVE_STREAM_VERSION_HEADER]: EVE_MESSAGE_STREAM_VERSION,+ },+ });+}diff --git a/packages/eve/src/evals/session.ts b/packages/eve/src/evals/session.tsindex 0ddbdcdef..4c420d171 100644--- a/packages/eve/src/evals/session.ts+++ b/packages/eve/src/evals/session.ts@@ -9,10 +9,12 @@ import type {SendTurnInput,SendTurnOptions,SendTurnPayload,+ StreamOptions,} from "#client/types.js";import type {MessageStreamEvent,RuntimeTraceContext,+ SubagentCalledStreamEvent,TurnFailureStreamEvent,} from "#protocol/message.js";import { isCurrentTurnBoundaryEvent, isTurnFailureEvent } from "#protocol/message.js";@@ -144,6 +146,16 @@ export class EvalSessionDriver implements EveEvalSession {return await this.#session.cancel();}+ streamSubagent(+ called: SubagentCalledStreamEvent,+ options: StreamOptions = {},+ ): AsyncIterable<MessageStreamEvent> {+ return this.#session.streamSubagent(called, {+ ...options,+ signal: options.signal ?? this.#signal,+ });+ }+/** @internal */async cleanup(signal: AbortSignal): Promise<void> {await this.#session.reset({ reason: "Eval timed out", signal });diff --git a/packages/eve/src/evals/types.ts b/packages/eve/src/evals/types.tsindex 7513b53d6..d0ee57379 100644--- a/packages/eve/src/evals/types.ts+++ b/packages/eve/src/evals/types.ts@@ -5,6 +5,7 @@ import type {RuntimeIdentity,RuntimeTraceContext,MessageStreamEvent,+ SubagentCalledStreamEvent,} from "#protocol/message.js";import type {CancelSessionResult,@@ -12,6 +13,7 @@ import type {CreateSessionOptions,SendTurnInput,SendTurnOptions,+ StreamOptions,} from "#client/types.js";import type { InputRequest, InputResponse } from "#shared/input.js";import type { JsonObject, JsonValue } from "#shared/json.js";@@ -325,6 +327,15 @@ export interface EveEvalSessionDriver {start(message: string, options?: SendTurnOptions): Promise<EveEvalLiveTurn>;/** Send one text turn with a local file attached as a data URL. */sendFile(text: string, filePath: string, mediaType?: string): Promise<EveEvalTurn>;+ /**+ * Follow one delegated child's stream through this parent session, with the+ * eval client's credentials. Local children use their own stream route; remote+ * children use the parent-origin proxy.+ */+ streamSubagent(+ called: SubagentCalledStreamEvent,+ options?: StreamOptions,+ ): AsyncIterable<MessageStreamEvent>;}/** One accepted session, exposed by `t.session()`, turns, and target attachment helpers. */