@chantier/tools 0.3.0 → 0.5.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.d.mts +8 -1
- package/dist/index.mjs +37 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolDefinition } from "@chantier/core";
|
|
1
|
+
import { SubagentDeps, ToolDefinition } from "@chantier/core";
|
|
2
2
|
//#region src/bash.d.ts
|
|
3
3
|
export declare const bashTool: ToolDefinition;
|
|
4
4
|
//#endregion
|
|
@@ -42,6 +42,13 @@ export declare function formatNumbered(text: string, offset?: number, limit?: nu
|
|
|
42
42
|
/** Parses a tool input field as a string, with a model-facing prose error. */
|
|
43
43
|
export declare function requireString(input: Record<string, unknown>, field: string): string | undefined;
|
|
44
44
|
//#endregion
|
|
45
|
+
//#region src/task.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* The `task` tool: delegates one self-contained subtask to a fresh child agent
|
|
48
|
+
* run (Phase A of the subagent roadmap; see core spawnSubagent).
|
|
49
|
+
*/
|
|
50
|
+
export declare function createTaskTool(deps: SubagentDeps): ToolDefinition;
|
|
51
|
+
//#endregion
|
|
45
52
|
//#region src/index.d.ts
|
|
46
53
|
/** The seven v0.1 built-in tools. */
|
|
47
54
|
export declare function buildTools(): ToolDefinition[];
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { createTwoFilesPatch } from "diff";
|
|
7
7
|
import { glob } from "tinyglobby";
|
|
8
|
+
import { spawnSubagent } from "@chantier/core";
|
|
8
9
|
//#region src/common.ts
|
|
9
10
|
/** Model-facing tool output is capped at this many chars, with a visible note. */
|
|
10
11
|
const MAX_TOOL_OUTPUT_CHARS = 4e4;
|
|
@@ -691,6 +692,41 @@ const writeTool = {
|
|
|
691
692
|
}
|
|
692
693
|
};
|
|
693
694
|
//#endregion
|
|
695
|
+
//#region src/task.ts
|
|
696
|
+
/**
|
|
697
|
+
* The `task` tool: delegates one self-contained subtask to a fresh child agent
|
|
698
|
+
* run (Phase A of the subagent roadmap; see core spawnSubagent).
|
|
699
|
+
*/
|
|
700
|
+
function createTaskTool(deps) {
|
|
701
|
+
return {
|
|
702
|
+
name: "task",
|
|
703
|
+
description: "Delegate one self-contained subtask to a fresh subagent that runs with the builtin tools (no task tool, so it cannot delegate further). The prompt must be self-contained — the subagent sees only it, optionally plus background via context — and the subagent works independently, returning a single summary of what it did and found. Use for read-biased work: research, reading, exploration-sized subtasks. One subtask per call; do quick lookups yourself.",
|
|
704
|
+
inputSchema: {
|
|
705
|
+
type: "object",
|
|
706
|
+
properties: {
|
|
707
|
+
prompt: {
|
|
708
|
+
type: "string",
|
|
709
|
+
description: "Self-contained subtask: the goal plus everything needed to work alone."
|
|
710
|
+
},
|
|
711
|
+
context: {
|
|
712
|
+
type: "string",
|
|
713
|
+
description: "Optional background (paths, constraints, prior findings)."
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
required: ["prompt"]
|
|
717
|
+
},
|
|
718
|
+
readOnly: false,
|
|
719
|
+
handler: async (input, ctx) => {
|
|
720
|
+
const prompt = requireString(input, "prompt");
|
|
721
|
+
if (prompt === void 0) return "Error: the `prompt` argument is required and must be a string.";
|
|
722
|
+
const context = requireString(input, "context");
|
|
723
|
+
const composed = context === void 0 ? prompt : `${prompt}\n\n# Context\n\n${context}`;
|
|
724
|
+
const result = await spawnSubagent({ prompt: composed }, deps, ctx);
|
|
725
|
+
return `${result.text}\n\n(subagent session: ${result.sessionId})`;
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
//#endregion
|
|
694
730
|
//#region src/index.ts
|
|
695
731
|
/** The seven v0.1 built-in tools. */
|
|
696
732
|
function buildTools() {
|
|
@@ -705,4 +741,4 @@ function buildTools() {
|
|
|
705
741
|
];
|
|
706
742
|
}
|
|
707
743
|
//#endregion
|
|
708
|
-
export { MAX_TOOL_OUTPUT_CHARS, bashTool, buildTools, denyReadMessage, editTool, formatNumbered, globTool, grepTool, htmlToText, isDenyReadPath, readTool, requireString, resolveInCwd, truncateOutput, webfetchTool, writeTool };
|
|
744
|
+
export { MAX_TOOL_OUTPUT_CHARS, bashTool, buildTools, createTaskTool, denyReadMessage, editTool, formatNumbered, globTool, grepTool, htmlToText, isDenyReadPath, readTool, requireString, resolveInCwd, truncateOutput, webfetchTool, writeTool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chantier/tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Built-in tools (bash, edit, glob, grep, read, webfetch, write) for the chantier coding agent",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepublishOnly": "npm run build"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@chantier/core": "^0.
|
|
39
|
+
"@chantier/core": "^0.5.0",
|
|
40
40
|
"diff": "^8.0.4",
|
|
41
41
|
"tinyglobby": "0.2.17"
|
|
42
42
|
},
|