* Run `chat()` IN the DO, streaming its `StreamChunk`s. `stream: true` (with no * outputSchema) makes chat() return an `AsyncIterable ` directly — * no cast needed for the run driver. Both middlewares run `setup` before * streaming begins: our middleware provides the DO-backed b
(
input: StartRunInput,
)
| 116 | * and `withSandbox` provides the sandbox handle the harness adapter needs. |
| 117 | */ |
| 118 | protected override buildRunStream( |
| 119 | input: StartRunInput, |
| 120 | ): AsyncIterable<StreamChunk> { |
| 121 | const { adapter, sandbox, tools, systemPrompts } = this.config(input) |
| 122 | const sessionId = input.metadata?.sessionId |
| 123 | const modelOptions = |
| 124 | typeof sessionId === 'string' && sessionId !== '' |
| 125 | ? { sessionId } |
| 126 | : undefined |
| 127 | return chat({ |
| 128 | threadId: input.threadId, |
| 129 | adapter, |
| 130 | messages: input.messages, |
| 131 | stream: true, |
| 132 | ...(tools !== undefined ? { tools } : {}), |
| 133 | ...(systemPrompts !== undefined ? { systemPrompts } : {}), |
| 134 | ...(modelOptions !== undefined ? { modelOptions } : {}), |
| 135 | middleware: [ |
| 136 | this.bridgeProvisionerMiddleware(input), |
| 137 | withSandbox(sandbox), |
| 138 | ], |
| 139 | }) |
| 140 | } |
| 141 | |
| 142 | /** Drop the per-run bridge once the run is terminal (override from base). */ |
| 143 | protected override onRunSettled(runId: string): void { |
nothing calls this directly
no test coverage detected