@crewhaus/tool-task 0.2.4 → 0.3.1

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SubAgentDefinition } from "@crewhaus/agent-context-isolation";
1
+ import type { SubAgentDefinition, SubAgentFailure } from "@crewhaus/agent-context-isolation";
2
2
  import { CrewhausError } from "@crewhaus/errors";
3
3
  import type { RegisteredTool } from "@crewhaus/tool-catalog";
4
4
  import { z } from "zod";
@@ -6,6 +6,20 @@ export declare class SubAgentResolutionError extends CrewhausError {
6
6
  readonly name = "SubAgentResolutionError";
7
7
  constructor(message: string, cause?: unknown);
8
8
  }
9
+ /**
10
+ * v0.3.0 §7.1 — a NON-fatal classified child failure, rethrown by the Task
11
+ * tool so `tool-executor` surfaces it as an `is_error: true` tool result
12
+ * whose content is the structured `{isError, failureClass, report}` JSON —
13
+ * the parent model sees an honest, classified failure instead of a bare
14
+ * `[sub-agent error]` string. Fatal classes (billing/auth) never reach
15
+ * here: the spawner rethrows `RunFailedError`, which tool-executor lets
16
+ * propagate so the whole run halts with the child's report.
17
+ */
18
+ export declare class SubAgentFailedError extends CrewhausError {
19
+ readonly name = "SubAgentFailedError";
20
+ readonly failure: SubAgentFailure;
21
+ constructor(failure: SubAgentFailure);
22
+ }
9
23
  export declare const BUILTIN_GENERAL_PURPOSE: SubAgentDefinition;
10
24
  declare const taskInputSchema: z.ZodObject<{
11
25
  description: z.ZodString;
package/dist/index.js CHANGED
@@ -48,6 +48,23 @@ export class SubAgentResolutionError extends CrewhausError {
48
48
  super("config", message, cause);
49
49
  }
50
50
  }
51
+ /**
52
+ * v0.3.0 §7.1 — a NON-fatal classified child failure, rethrown by the Task
53
+ * tool so `tool-executor` surfaces it as an `is_error: true` tool result
54
+ * whose content is the structured `{isError, failureClass, report}` JSON —
55
+ * the parent model sees an honest, classified failure instead of a bare
56
+ * `[sub-agent error]` string. Fatal classes (billing/auth) never reach
57
+ * here: the spawner rethrows `RunFailedError`, which tool-executor lets
58
+ * propagate so the whole run halts with the child's report.
59
+ */
60
+ export class SubAgentFailedError extends CrewhausError {
61
+ name = "SubAgentFailedError";
62
+ failure;
63
+ constructor(failure) {
64
+ super("tool", JSON.stringify({ isError: true, failureClass: failure.failureClass, report: failure.report }));
65
+ this.failure = failure;
66
+ }
67
+ }
51
68
  export const BUILTIN_GENERAL_PURPOSE = {
52
69
  name: "general-purpose",
53
70
  description: "General-purpose sub-agent. Pass it a task and it will use the parent's tools (filtered by inherited permissions) to complete it and return a single summary.",
@@ -253,7 +270,20 @@ export function createTaskTool(opts = {}) {
253
270
  model: bridge.model,
254
271
  maxTokens: bridge.maxTokens,
255
272
  ...(bridge.sessionRootDir !== undefined ? { sessionRootDir: bridge.sessionRootDir } : {}),
273
+ // v0.3.0 §7.1 — the four child seams, projected by runtime-core onto
274
+ // the bridge (recall-only memory, skills list, failure taxonomy,
275
+ // read-only continuity) and handed to the spawner verbatim.
276
+ ...(bridge.memory !== undefined ? { memory: bridge.memory } : {}),
277
+ ...(bridge.skills !== undefined ? { skills: bridge.skills } : {}),
278
+ ...(bridge.failureTaxonomy !== undefined
279
+ ? { failureTaxonomy: bridge.failureTaxonomy }
280
+ : {}),
281
+ ...(bridge.continuity !== undefined ? { continuity: bridge.continuity } : {}),
256
282
  };
283
+ // A fatal child failure (billing/auth) makes `spawnSubAgent` throw
284
+ // `RunFailedError`; it propagates through here and through
285
+ // tool-executor's carve-out so the whole run halts with the child's
286
+ // report (§7.1: "a billing failure anywhere ends the run").
257
287
  const result = await spawnSubAgent(parentHandle, {
258
288
  def,
259
289
  prompt: input.prompt,
@@ -262,6 +292,12 @@ export function createTaskTool(opts = {}) {
262
292
  childTools,
263
293
  ...(bridge.sessionRootDir !== undefined ? { sessionRootDir: bridge.sessionRootDir } : {}),
264
294
  });
295
+ if (result.failure !== undefined) {
296
+ // Non-fatal classified failure → an is_error tool result carrying
297
+ // the structured {isError, failureClass, report} content. The run
298
+ // continues; the parent model decides what to do next.
299
+ throw new SubAgentFailedError(result.failure);
300
+ }
265
301
  return result.finalMessage;
266
302
  },
267
303
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewhaus/tool-task",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Task(description, prompt, subagent_type?) tool — spawns a sub-agent and returns its final message (Section 13)",
6
6
  "main": "dist/index.js",
@@ -15,18 +15,18 @@
15
15
  "test": "bun test src"
16
16
  },
17
17
  "dependencies": {
18
- "@crewhaus/agent-context-isolation": "0.2.4",
19
- "@crewhaus/errors": "0.2.4",
20
- "@crewhaus/sub-agent-permission-inheritance": "0.2.4",
21
- "@crewhaus/tool-builder": "0.2.4",
22
- "@crewhaus/tool-catalog": "0.2.4",
18
+ "@crewhaus/agent-context-isolation": "0.3.1",
19
+ "@crewhaus/errors": "0.3.1",
20
+ "@crewhaus/sub-agent-permission-inheritance": "0.3.1",
21
+ "@crewhaus/tool-builder": "0.3.1",
22
+ "@crewhaus/tool-catalog": "0.3.1",
23
23
  "yaml": "^2.6.0",
24
24
  "zod": "^3.23.8"
25
25
  },
26
26
  "devDependencies": {
27
- "@crewhaus/event-log": "0.2.4",
28
- "@crewhaus/permission-engine": "0.2.4",
29
- "@crewhaus/run-context": "0.2.4"
27
+ "@crewhaus/event-log": "0.3.1",
28
+ "@crewhaus/permission-engine": "0.3.1",
29
+ "@crewhaus/run-context": "0.3.1"
30
30
  },
31
31
  "license": "Apache-2.0",
32
32
  "author": {