(chunk: Uint8Array)
| 138 | async start(controller) { |
| 139 | let closed = false; |
| 140 | const safeEnqueue = (chunk: Uint8Array) => { |
| 141 | if (closed) return; |
| 142 | try { |
| 143 | controller.enqueue(chunk); |
| 144 | } catch { |
| 145 | // controller 已关闭——忽略 |
| 146 | closed = true; |
| 147 | } |
| 148 | }; |
| 149 | // 整段逻辑跑在 workspaceContext 作用域内:root_index 预热 + runAgent 深处的所有 |
| 150 | // executeTool 都会读到 workspace,并在调 web 时带上 kb_workspace cookie。 |
| 151 | await workspaceContext.run(workspace, async () => { |