@crewhaus/streaming-tool-executor 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuntimeError } from "@crewhaus/errors";
|
|
1
|
+
import { RuntimeError, isRunFailedError } from "@crewhaus/errors";
|
|
2
2
|
import { executeTool } from "@crewhaus/tool-executor";
|
|
3
3
|
// Mirror of runtime-core's DEFAULT_MAX_CONCURRENT_TOOLS — bound the
|
|
4
4
|
// in-flight set so a wide sub-agent fan-out can't open unbounded model
|
|
@@ -50,6 +50,12 @@ export async function executeStreaming(stream, opts) {
|
|
|
50
50
|
const openOrder = [];
|
|
51
51
|
let stopReason = "end_turn";
|
|
52
52
|
let usage = { input: 0, output: 0 };
|
|
53
|
+
// v0.3.0 §7.1 — a RunFailedError escaping a tool dispatch is a terminal
|
|
54
|
+
// RUN verdict (a sub-agent's billing/auth failure escalated by the
|
|
55
|
+
// spawner). It must not dissolve into an is_error tool result: capture
|
|
56
|
+
// the first one, short-circuit the queue, and rethrow after the drain so
|
|
57
|
+
// in-flight siblings still settle.
|
|
58
|
+
let fatalError;
|
|
53
59
|
if (opts.abortSignal) {
|
|
54
60
|
if (opts.abortSignal.aborted) {
|
|
55
61
|
siblingAbort.abort("external_abort");
|
|
@@ -141,6 +147,17 @@ export async function executeStreaming(stream, opts) {
|
|
|
141
147
|
})
|
|
142
148
|
.catch((err) => {
|
|
143
149
|
entry.status = "done";
|
|
150
|
+
if (fatalError === undefined && isRunFailedError(err)) {
|
|
151
|
+
fatalError = err;
|
|
152
|
+
if (!siblingAbort.signal.aborted) {
|
|
153
|
+
siblingAbort.abort("fatal_error");
|
|
154
|
+
fire({
|
|
155
|
+
kind: "sibling-aborted",
|
|
156
|
+
reason: "fatal_error",
|
|
157
|
+
failedToolName: entry.block.name,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
144
161
|
const msg = err instanceof Error ? err.message : String(err);
|
|
145
162
|
results.set(entry.block.id, {
|
|
146
163
|
type: "tool_result",
|
|
@@ -305,6 +322,11 @@ export async function executeStreaming(stream, opts) {
|
|
|
305
322
|
await Promise.race(inFlight);
|
|
306
323
|
processQueue();
|
|
307
324
|
}
|
|
325
|
+
// v0.3.0 §7.1 — every sibling has settled; surface the terminal verdict
|
|
326
|
+
// now. The caller (runtime-core's streaming path) routes it to recovery,
|
|
327
|
+
// which halts the run with the report verbatim.
|
|
328
|
+
if (fatalError !== undefined)
|
|
329
|
+
throw fatalError;
|
|
308
330
|
// Build the final content array in open-order so tool_use blocks
|
|
309
331
|
// surface in the same order they came down the wire (matching the
|
|
310
332
|
// Anthropic-shaped final message historically returned).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/streaming-tool-executor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dispatch tool execution mid-stream so tools start before message_stop",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@anthropic-ai/sdk": "^0.96.0",
|
|
19
|
-
"@crewhaus/adapter-anthropic": "0.
|
|
20
|
-
"@crewhaus/errors": "0.
|
|
21
|
-
"@crewhaus/tool-builder": "0.
|
|
22
|
-
"@crewhaus/tool-catalog": "0.
|
|
23
|
-
"@crewhaus/tool-executor": "0.
|
|
24
|
-
"@crewhaus/turn-state-machine": "0.
|
|
19
|
+
"@crewhaus/adapter-anthropic": "0.3.0",
|
|
20
|
+
"@crewhaus/errors": "0.3.0",
|
|
21
|
+
"@crewhaus/tool-builder": "0.3.0",
|
|
22
|
+
"@crewhaus/tool-catalog": "0.3.0",
|
|
23
|
+
"@crewhaus/tool-executor": "0.3.0",
|
|
24
|
+
"@crewhaus/turn-state-machine": "0.3.0",
|
|
25
25
|
"zod": "^3.23.8"
|
|
26
26
|
},
|
|
27
27
|
"license": "Apache-2.0",
|