chainlesschain 0.45.70 → 0.45.75
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/package.json +1 -1
- package/src/assets/web-panel/.build-hash +1 -1
- package/src/assets/web-panel/assets/Analytics-B4OM8S8X.css +1 -0
- package/src/assets/web-panel/assets/Analytics-sBrYoc3A.js +3 -0
- package/src/assets/web-panel/assets/AppLayout-2RCrdXxl.js +1 -0
- package/src/assets/web-panel/assets/AppLayout-D9pBLPC3.css +1 -0
- package/src/assets/web-panel/assets/Backup-D68fenbD.js +1 -0
- package/src/assets/web-panel/assets/Backup-fZqtfC1m.css +1 -0
- package/src/assets/web-panel/assets/{Chat-DXtvKoM0.js → Chat-B2nB8o_F.js} +1 -1
- package/src/assets/web-panel/assets/{Cron-BJ4ODHOy.js → Cron-CNs03iHJ.js} +2 -2
- package/src/assets/web-panel/assets/{Dashboard-BZd4wDPQ.js → Dashboard-DanoHPSI.js} +2 -2
- package/src/assets/web-panel/assets/Git-CCMVr3Y8.js +2 -0
- package/src/assets/web-panel/assets/Git-DGcuBXST.css +1 -0
- package/src/assets/web-panel/assets/{Logs-CSeKZEG_.js → Logs-BY6A0UNG.js} +2 -2
- package/src/assets/web-panel/assets/{McpTools-BYQAK11r.js → McpTools-CrBVYlg6.js} +2 -2
- package/src/assets/web-panel/assets/{Memory-gkUAPyuZ.js → Memory-CWx3SpUt.js} +2 -2
- package/src/assets/web-panel/assets/{Notes-bjNrQgAo.js → Notes-1LcGD49x.js} +2 -2
- package/src/assets/web-panel/assets/Organization-DdOOM4ic.css +1 -0
- package/src/assets/web-panel/assets/Organization-Dx2DhbkM.js +4 -0
- package/src/assets/web-panel/assets/P2P-B16fjqfJ.js +2 -0
- package/src/assets/web-panel/assets/P2P-OEzOeMZX.css +1 -0
- package/src/assets/web-panel/assets/Permissions-BQbC9FzG.js +4 -0
- package/src/assets/web-panel/assets/Permissions-C9WlkGl-.css +1 -0
- package/src/assets/web-panel/assets/Projects-CjhZbNYm.js +2 -0
- package/src/assets/web-panel/assets/Projects-DxKelI5h.css +1 -0
- package/src/assets/web-panel/assets/Providers-BEakqcO5.css +1 -0
- package/src/assets/web-panel/assets/Providers-ivOAQtHM.js +2 -0
- package/src/assets/web-panel/assets/RssFeed-BlFC20eg.css +1 -0
- package/src/assets/web-panel/assets/RssFeed-BrsErdrU.js +3 -0
- package/src/assets/web-panel/assets/Security-DnEvJU5h.js +4 -0
- package/src/assets/web-panel/assets/Security-Dwxw7rfP.css +1 -0
- package/src/assets/web-panel/assets/{Services-CS0oMdxh.js → Services-7jQywNbl.js} +2 -2
- package/src/assets/web-panel/assets/Skills-CLlblJcG.js +1 -0
- package/src/assets/web-panel/assets/{Tasks-qULws8pc.js → Tasks-CmJBC1cf.js} +1 -1
- package/src/assets/web-panel/assets/Templates-DOY_oZnm.css +1 -0
- package/src/assets/web-panel/assets/Templates-RXT8-DNk.js +1 -0
- package/src/assets/web-panel/assets/Wallet-3iYASEx_.js +4 -0
- package/src/assets/web-panel/assets/Wallet-DnIumafl.css +1 -0
- package/src/assets/web-panel/assets/WebAuthn-CNPl2VQR.css +1 -0
- package/src/assets/web-panel/assets/WebAuthn-s3Hzd9db.js +5 -0
- package/src/assets/web-panel/assets/{antd-CJSBocer.js → antd-gZyc63Qr.js} +114 -114
- package/src/assets/web-panel/assets/chat-DWBA4-cl.js +1 -0
- package/src/assets/web-panel/assets/index-CyGtHm63.js +2 -0
- package/src/assets/web-panel/assets/{markdown-Bo5cVN4u.js → markdown-Bv7nG63L.js} +1 -1
- package/src/assets/web-panel/assets/ws-CU7Gvoom.js +1 -0
- package/src/assets/web-panel/index.html +2 -2
- package/src/commands/doctor.js +33 -151
- package/src/commands/mcp.js +1 -1
- package/src/commands/plugin.js +1 -1
- package/src/commands/session.js +106 -7
- package/src/commands/status.js +39 -69
- package/src/gateways/ws/session-protocol.js +1 -1
- package/src/gateways/ws/ws-agent-handler.js +484 -0
- package/src/gateways/ws/ws-server.js +758 -4
- package/src/gateways/ws/ws-session-gateway.js +1432 -1
- package/src/harness/mcp-client.js +417 -0
- package/src/harness/mock-llm-provider.js +167 -0
- package/src/harness/plugin-manager.js +434 -0
- package/src/lib/agent-core.js +25 -1902
- package/src/lib/hashline.js +208 -0
- package/src/lib/jsonl-session-store.js +11 -0
- package/src/lib/mcp-client.js +14 -412
- package/src/lib/plugin-manager.js +29 -428
- package/src/lib/prompt-compressor.js +11 -0
- package/src/lib/session-hooks.js +61 -0
- package/src/lib/skill-loader.js +4 -0
- package/src/lib/skill-mcp.js +190 -0
- package/src/lib/workflow-state-reader.js +94 -0
- package/src/lib/ws-agent-handler.js +8 -472
- package/src/lib/ws-server.js +12 -756
- package/src/lib/ws-session-manager.js +8 -1417
- package/src/repl/agent-repl.js +27 -3
- package/src/runtime/agent-core.js +1760 -0
- package/src/runtime/agent-runtime.js +3 -1
- package/src/runtime/coding-agent-contract-shared.cjs +496 -0
- package/src/runtime/coding-agent-contract.js +49 -229
- package/src/runtime/coding-agent-policy.cjs +54 -5
- package/src/runtime/diagnostics.js +317 -0
- package/src/runtime/index.js +3 -0
- package/src/tools/index.js +3 -0
- package/src/tools/legacy-agent-tools.js +5 -0
- package/src/assets/web-panel/assets/AppLayout-B_tkw3Pn.js +0 -1
- package/src/assets/web-panel/assets/AppLayout-CFP4dGIJ.css +0 -1
- package/src/assets/web-panel/assets/Providers-Brm-S_hS.css +0 -1
- package/src/assets/web-panel/assets/Providers-Dbf57Tbv.js +0 -1
- package/src/assets/web-panel/assets/Skills-B2fgruv8.js +0 -1
- package/src/assets/web-panel/assets/chat-DnH09sSR.js +0 -1
- package/src/assets/web-panel/assets/index-IK-oro0g.js +0 -2
- package/src/assets/web-panel/assets/ws-DjelKkD6.js +0 -1
|
@@ -15,7 +15,7 @@ import { startChatRepl } from "../gateways/repl/chat-repl.js";
|
|
|
15
15
|
import { ChainlessChainWSServer } from "../gateways/ws/ws-server.js";
|
|
16
16
|
import { WSSessionManager } from "../gateways/ws/ws-session-gateway.js";
|
|
17
17
|
import { createWebUIServer } from "../gateways/ui/web-ui-server.js";
|
|
18
|
-
import { MCPClient, MCPServerConfig } from "../
|
|
18
|
+
import { MCPClient, MCPServerConfig } from "../harness/mcp-client.js";
|
|
19
19
|
import sharedManagedToolPolicy from "./coding-agent-managed-tool-policy.cjs";
|
|
20
20
|
import { findProjectRoot, loadProjectConfig } from "../lib/project-detector.js";
|
|
21
21
|
import { loadConfig } from "../lib/config-manager.js";
|
|
@@ -228,6 +228,7 @@ export class AgentRuntime {
|
|
|
228
228
|
);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
const appConfig = this.deps.loadConfig();
|
|
231
232
|
const mcpClient = await this._initializeCodingAgentMcpClient(rawDb, {
|
|
232
233
|
logger: runtimeLogger,
|
|
233
234
|
});
|
|
@@ -235,6 +236,7 @@ export class AgentRuntime {
|
|
|
235
236
|
const sessionManager = this.deps.createSessionManager({
|
|
236
237
|
db,
|
|
237
238
|
defaultProjectRoot: project,
|
|
239
|
+
config: appConfig,
|
|
238
240
|
mcpClient,
|
|
239
241
|
allowedMcpServerNames: DEFAULT_ALLOWED_MCP_SERVER_NAMES,
|
|
240
242
|
mcpServerRegistry: this.deps.mcpServerRegistry,
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const sharedCodingAgentPolicy = require("./coding-agent-policy.cjs");
|
|
4
|
+
|
|
5
|
+
const { TOOL_POLICY_METADATA } = sharedCodingAgentPolicy;
|
|
6
|
+
|
|
7
|
+
function cloneValue(value) {
|
|
8
|
+
return JSON.parse(JSON.stringify(value));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function createFunctionToolContract(tool) {
|
|
12
|
+
return Object.freeze({
|
|
13
|
+
type: "function",
|
|
14
|
+
function: {
|
|
15
|
+
name: tool.name,
|
|
16
|
+
description: tool.description || "",
|
|
17
|
+
parameters: cloneValue(
|
|
18
|
+
tool.inputSchema || { type: "object", properties: {} },
|
|
19
|
+
),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const CODING_AGENT_TOOL_CONTRACTS = Object.freeze([
|
|
25
|
+
{
|
|
26
|
+
name: "read_file",
|
|
27
|
+
title: "Read File",
|
|
28
|
+
kind: "filesystem",
|
|
29
|
+
tier: "mvp",
|
|
30
|
+
description: "Read a file's content",
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
path: { type: "string", description: "File path to read" },
|
|
35
|
+
},
|
|
36
|
+
required: ["path"],
|
|
37
|
+
},
|
|
38
|
+
...TOOL_POLICY_METADATA.read_file,
|
|
39
|
+
permissions: {
|
|
40
|
+
level: "readonly",
|
|
41
|
+
scopes: ["filesystem:read"],
|
|
42
|
+
},
|
|
43
|
+
telemetry: {
|
|
44
|
+
category: "filesystem",
|
|
45
|
+
tags: ["tool:read_file", "contract:coding-agent", "tier:mvp"],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "write_file",
|
|
50
|
+
title: "Write File",
|
|
51
|
+
kind: "filesystem",
|
|
52
|
+
tier: "mvp",
|
|
53
|
+
description: "Write content to a file (create or overwrite)",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
path: { type: "string", description: "File path" },
|
|
58
|
+
content: { type: "string", description: "File content" },
|
|
59
|
+
},
|
|
60
|
+
required: ["path", "content"],
|
|
61
|
+
},
|
|
62
|
+
...TOOL_POLICY_METADATA.write_file,
|
|
63
|
+
permissions: {
|
|
64
|
+
level: "elevated",
|
|
65
|
+
scopes: ["filesystem:write"],
|
|
66
|
+
},
|
|
67
|
+
telemetry: {
|
|
68
|
+
category: "filesystem",
|
|
69
|
+
tags: ["tool:write_file", "contract:coding-agent", "tier:mvp"],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "edit_file",
|
|
74
|
+
title: "Edit File",
|
|
75
|
+
kind: "filesystem",
|
|
76
|
+
tier: "mvp",
|
|
77
|
+
description: "Replace a specific string in a file with new content",
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: "object",
|
|
80
|
+
properties: {
|
|
81
|
+
path: { type: "string", description: "File path" },
|
|
82
|
+
old_string: {
|
|
83
|
+
type: "string",
|
|
84
|
+
description: "Exact string to find and replace",
|
|
85
|
+
},
|
|
86
|
+
new_string: {
|
|
87
|
+
type: "string",
|
|
88
|
+
description: "Replacement string",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
required: ["path", "old_string", "new_string"],
|
|
92
|
+
},
|
|
93
|
+
...TOOL_POLICY_METADATA.edit_file,
|
|
94
|
+
permissions: {
|
|
95
|
+
level: "elevated",
|
|
96
|
+
scopes: ["filesystem:write"],
|
|
97
|
+
},
|
|
98
|
+
telemetry: {
|
|
99
|
+
category: "filesystem",
|
|
100
|
+
tags: ["tool:edit_file", "contract:coding-agent", "tier:mvp"],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "edit_file_hashed",
|
|
105
|
+
title: "Edit File (Hash-Anchored)",
|
|
106
|
+
kind: "filesystem",
|
|
107
|
+
tier: "mvp",
|
|
108
|
+
description:
|
|
109
|
+
"Replace a single line in a file, anchored by its content hash. Use this instead of edit_file for robust edits: each line of read_file output (with hashed:true) is tagged with a 6-char hash like 'a3Kp9Z| const x = ...'. Pass the hash as anchor_hash, the current line as expected_line, and the replacement as new_line. Rejects edits if the line drifted (hash mismatch) — retry by re-reading the file with hashed:true.",
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
path: { type: "string", description: "File path" },
|
|
114
|
+
anchor_hash: {
|
|
115
|
+
type: "string",
|
|
116
|
+
description:
|
|
117
|
+
"6-char base64url hash of the line to replace (from read_file with hashed:true)",
|
|
118
|
+
},
|
|
119
|
+
expected_line: {
|
|
120
|
+
type: "string",
|
|
121
|
+
description:
|
|
122
|
+
"Current content of the line — used as a second-layer check against hash collisions. Compared after .trim().",
|
|
123
|
+
},
|
|
124
|
+
new_line: {
|
|
125
|
+
type: "string",
|
|
126
|
+
description:
|
|
127
|
+
"Replacement line content (without the hash tag prefix). Preserve the original indentation.",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
required: ["path", "anchor_hash", "expected_line", "new_line"],
|
|
131
|
+
},
|
|
132
|
+
...TOOL_POLICY_METADATA.edit_file_hashed,
|
|
133
|
+
permissions: {
|
|
134
|
+
level: "elevated",
|
|
135
|
+
scopes: ["filesystem:write"],
|
|
136
|
+
},
|
|
137
|
+
telemetry: {
|
|
138
|
+
category: "filesystem",
|
|
139
|
+
tags: ["tool:edit_file_hashed", "contract:coding-agent", "tier:mvp"],
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "run_shell",
|
|
144
|
+
title: "Run Shell",
|
|
145
|
+
kind: "shell",
|
|
146
|
+
tier: "mvp",
|
|
147
|
+
description:
|
|
148
|
+
"Execute a shell command and return the output. Use for running tests, linting, builds, and other non-git workspace commands.",
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: "object",
|
|
151
|
+
properties: {
|
|
152
|
+
command: { type: "string", description: "Shell command to execute" },
|
|
153
|
+
cwd: {
|
|
154
|
+
type: "string",
|
|
155
|
+
description: "Working directory (optional)",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
required: ["command"],
|
|
159
|
+
},
|
|
160
|
+
...TOOL_POLICY_METADATA.run_shell,
|
|
161
|
+
runtimeDescriptor: "shell",
|
|
162
|
+
permissions: {
|
|
163
|
+
level: "elevated",
|
|
164
|
+
scopes: ["process:spawn", "filesystem:workspace"],
|
|
165
|
+
},
|
|
166
|
+
telemetry: {
|
|
167
|
+
category: "shell",
|
|
168
|
+
tags: ["tool:run_shell", "contract:coding-agent", "tier:mvp"],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "git",
|
|
173
|
+
title: "Git",
|
|
174
|
+
kind: "git",
|
|
175
|
+
tier: "mvp",
|
|
176
|
+
description:
|
|
177
|
+
"Run a git command inside the workspace. Use this instead of run_shell for git status, diff, log, commit, branch, and related repository operations.",
|
|
178
|
+
inputSchema: {
|
|
179
|
+
type: "object",
|
|
180
|
+
properties: {
|
|
181
|
+
command: {
|
|
182
|
+
type: "string",
|
|
183
|
+
description:
|
|
184
|
+
'Git subcommand to execute, for example "status", "diff --stat", or "log --oneline -5"',
|
|
185
|
+
},
|
|
186
|
+
cwd: {
|
|
187
|
+
type: "string",
|
|
188
|
+
description: "Working directory (optional)",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
required: ["command"],
|
|
192
|
+
},
|
|
193
|
+
...TOOL_POLICY_METADATA.git,
|
|
194
|
+
runtimeDescriptor: "git",
|
|
195
|
+
permissions: {
|
|
196
|
+
level: "elevated",
|
|
197
|
+
scopes: ["process:spawn", "filesystem:workspace", "vcs:git"],
|
|
198
|
+
},
|
|
199
|
+
telemetry: {
|
|
200
|
+
category: "git",
|
|
201
|
+
tags: ["tool:git", "contract:coding-agent", "tier:mvp"],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "search_files",
|
|
206
|
+
title: "Search Files",
|
|
207
|
+
kind: "filesystem",
|
|
208
|
+
tier: "mvp",
|
|
209
|
+
description: "Search for files by name pattern or content",
|
|
210
|
+
inputSchema: {
|
|
211
|
+
type: "object",
|
|
212
|
+
properties: {
|
|
213
|
+
pattern: {
|
|
214
|
+
type: "string",
|
|
215
|
+
description: "Glob pattern or search string",
|
|
216
|
+
},
|
|
217
|
+
directory: {
|
|
218
|
+
type: "string",
|
|
219
|
+
description: "Directory to search in (default: cwd)",
|
|
220
|
+
},
|
|
221
|
+
content_search: {
|
|
222
|
+
type: "boolean",
|
|
223
|
+
description: "If true, search file contents instead of names",
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
required: ["pattern"],
|
|
227
|
+
},
|
|
228
|
+
...TOOL_POLICY_METADATA.search_files,
|
|
229
|
+
permissions: {
|
|
230
|
+
level: "readonly",
|
|
231
|
+
scopes: ["filesystem:read", "search:content"],
|
|
232
|
+
},
|
|
233
|
+
telemetry: {
|
|
234
|
+
category: "filesystem",
|
|
235
|
+
tags: ["tool:search_files", "contract:coding-agent", "tier:mvp"],
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "list_dir",
|
|
240
|
+
title: "List Directory",
|
|
241
|
+
kind: "filesystem",
|
|
242
|
+
tier: "mvp",
|
|
243
|
+
description: "List contents of a directory",
|
|
244
|
+
inputSchema: {
|
|
245
|
+
type: "object",
|
|
246
|
+
properties: {
|
|
247
|
+
path: {
|
|
248
|
+
type: "string",
|
|
249
|
+
description: "Directory path (default: cwd)",
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
...TOOL_POLICY_METADATA.list_dir,
|
|
254
|
+
permissions: {
|
|
255
|
+
level: "readonly",
|
|
256
|
+
scopes: ["filesystem:read"],
|
|
257
|
+
},
|
|
258
|
+
telemetry: {
|
|
259
|
+
category: "filesystem",
|
|
260
|
+
tags: ["tool:list_dir", "contract:coding-agent", "tier:mvp"],
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: "run_skill",
|
|
265
|
+
title: "Run Skill",
|
|
266
|
+
kind: "skill",
|
|
267
|
+
tier: "extension",
|
|
268
|
+
description:
|
|
269
|
+
"Run a built-in ChainlessChain skill. Available skills include: code-review, summarize, translate, refactor, unit-test, debug, explain-code, browser-automation, data-analysis, git-history-analyzer, and 130+ more. Use list_skills first to discover available skills.",
|
|
270
|
+
inputSchema: {
|
|
271
|
+
type: "object",
|
|
272
|
+
properties: {
|
|
273
|
+
skill_name: {
|
|
274
|
+
type: "string",
|
|
275
|
+
description:
|
|
276
|
+
"Name of the skill to run (e.g. code-review, summarize, translate)",
|
|
277
|
+
},
|
|
278
|
+
input: {
|
|
279
|
+
type: "string",
|
|
280
|
+
description: "Input text or parameters for the skill",
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
required: ["skill_name", "input"],
|
|
284
|
+
},
|
|
285
|
+
...TOOL_POLICY_METADATA.run_skill,
|
|
286
|
+
permissions: {
|
|
287
|
+
level: "standard",
|
|
288
|
+
scopes: ["skill:invoke"],
|
|
289
|
+
},
|
|
290
|
+
telemetry: {
|
|
291
|
+
category: "skill",
|
|
292
|
+
tags: ["tool:run_skill", "contract:coding-agent", "tier:extension"],
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: "list_skills",
|
|
297
|
+
title: "List Skills",
|
|
298
|
+
kind: "skill",
|
|
299
|
+
tier: "extension",
|
|
300
|
+
description:
|
|
301
|
+
"List available built-in skills, optionally filtered by category or keyword",
|
|
302
|
+
inputSchema: {
|
|
303
|
+
type: "object",
|
|
304
|
+
properties: {
|
|
305
|
+
category: {
|
|
306
|
+
type: "string",
|
|
307
|
+
description: "Filter by category (e.g. development, automation, data)",
|
|
308
|
+
},
|
|
309
|
+
query: {
|
|
310
|
+
type: "string",
|
|
311
|
+
description: "Search keyword to filter skills",
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
...TOOL_POLICY_METADATA.list_skills,
|
|
316
|
+
permissions: {
|
|
317
|
+
level: "readonly",
|
|
318
|
+
scopes: ["skill:read"],
|
|
319
|
+
},
|
|
320
|
+
telemetry: {
|
|
321
|
+
category: "skill",
|
|
322
|
+
tags: ["tool:list_skills", "contract:coding-agent", "tier:extension"],
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: "run_code",
|
|
327
|
+
title: "Run Code",
|
|
328
|
+
kind: "code",
|
|
329
|
+
tier: "extension",
|
|
330
|
+
description:
|
|
331
|
+
"Write and execute code in Python, Node.js, or Bash. Use this when the user needs data processing, calculations, file batch operations, API calls, or any task best solved with a script. Scripts are saved for reference. Missing Python packages are auto-installed.",
|
|
332
|
+
inputSchema: {
|
|
333
|
+
type: "object",
|
|
334
|
+
properties: {
|
|
335
|
+
language: {
|
|
336
|
+
type: "string",
|
|
337
|
+
enum: ["python", "node", "bash"],
|
|
338
|
+
description: "Programming language",
|
|
339
|
+
},
|
|
340
|
+
code: { type: "string", description: "Code to execute" },
|
|
341
|
+
timeout: {
|
|
342
|
+
type: "number",
|
|
343
|
+
description: "Execution timeout in seconds (default: 60, max: 300)",
|
|
344
|
+
},
|
|
345
|
+
persist: {
|
|
346
|
+
type: "boolean",
|
|
347
|
+
description:
|
|
348
|
+
"If true (default), save script in .chainlesschain/agent-scripts/. If false, use temp file and clean up.",
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
required: ["language", "code"],
|
|
352
|
+
},
|
|
353
|
+
...TOOL_POLICY_METADATA.run_code,
|
|
354
|
+
permissions: {
|
|
355
|
+
level: "elevated",
|
|
356
|
+
scopes: ["process:spawn", "filesystem:workspace", "runtime:script"],
|
|
357
|
+
},
|
|
358
|
+
telemetry: {
|
|
359
|
+
category: "code",
|
|
360
|
+
tags: ["tool:run_code", "contract:coding-agent", "tier:extension"],
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "spawn_sub_agent",
|
|
365
|
+
title: "Spawn Sub Agent",
|
|
366
|
+
kind: "agent",
|
|
367
|
+
tier: "extension",
|
|
368
|
+
description:
|
|
369
|
+
"Spawn an isolated sub-agent to handle a subtask. The sub-agent has its own context and message history, and only returns a summary result. Use this for tasks that benefit from focused, independent execution (e.g. code review, summarization, translation).",
|
|
370
|
+
inputSchema: {
|
|
371
|
+
type: "object",
|
|
372
|
+
properties: {
|
|
373
|
+
role: {
|
|
374
|
+
type: "string",
|
|
375
|
+
description:
|
|
376
|
+
"Sub-agent role (e.g. code-review, summarizer, translator, debugger)",
|
|
377
|
+
},
|
|
378
|
+
task: {
|
|
379
|
+
type: "string",
|
|
380
|
+
description: "Task description for the sub-agent",
|
|
381
|
+
},
|
|
382
|
+
context: {
|
|
383
|
+
type: "string",
|
|
384
|
+
description:
|
|
385
|
+
"Optional condensed context from the parent agent to pass to the sub-agent",
|
|
386
|
+
},
|
|
387
|
+
tools: {
|
|
388
|
+
type: "array",
|
|
389
|
+
items: { type: "string" },
|
|
390
|
+
description:
|
|
391
|
+
'Optional tool whitelist for the sub-agent (e.g. ["read_file", "search_files"]). If omitted, all tools are available.',
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
required: ["role", "task"],
|
|
395
|
+
},
|
|
396
|
+
...TOOL_POLICY_METADATA.spawn_sub_agent,
|
|
397
|
+
permissions: {
|
|
398
|
+
level: "elevated",
|
|
399
|
+
scopes: ["agent:spawn"],
|
|
400
|
+
},
|
|
401
|
+
telemetry: {
|
|
402
|
+
category: "agent",
|
|
403
|
+
tags: ["tool:spawn_sub_agent", "contract:coding-agent", "tier:extension"],
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
]);
|
|
407
|
+
|
|
408
|
+
const CODING_AGENT_MVP_TOOL_NAMES = Object.freeze(
|
|
409
|
+
CODING_AGENT_TOOL_CONTRACTS.filter((tool) => tool.tier === "mvp").map(
|
|
410
|
+
(tool) => tool.name,
|
|
411
|
+
),
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
const CODING_AGENT_EXTENSION_TOOL_NAMES = Object.freeze(
|
|
415
|
+
CODING_AGENT_TOOL_CONTRACTS.filter((tool) => tool.tier === "extension").map(
|
|
416
|
+
(tool) => tool.name,
|
|
417
|
+
),
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
const TOOL_CONTRACT_MAP = new Map(
|
|
421
|
+
CODING_AGENT_TOOL_CONTRACTS.map((tool) => [tool.name, tool]),
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
function getCodingAgentToolContract(name) {
|
|
425
|
+
const tool = TOOL_CONTRACT_MAP.get(name);
|
|
426
|
+
return tool ? cloneValue(tool) : null;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function getCodingAgentToolContracts(options = {}) {
|
|
430
|
+
const { tier = null } = options;
|
|
431
|
+
return CODING_AGENT_TOOL_CONTRACTS.filter((tool) => {
|
|
432
|
+
if (tier && tool.tier !== tier) {
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
return true;
|
|
436
|
+
}).map(cloneValue);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function listCodingAgentToolNames(options = {}) {
|
|
440
|
+
return getCodingAgentToolContracts(options).map((tool) => tool.name);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function isCodingAgentMvpTool(name) {
|
|
444
|
+
return CODING_AGENT_MVP_TOOL_NAMES.includes(name);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function getCodingAgentToolPolicy(name) {
|
|
448
|
+
const tool = TOOL_CONTRACT_MAP.get(name);
|
|
449
|
+
if (!tool) {
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return {
|
|
454
|
+
tier: tool.tier,
|
|
455
|
+
riskLevel: tool.riskLevel,
|
|
456
|
+
availableInPlanMode: tool.availableInPlanMode,
|
|
457
|
+
planModeBehavior: tool.planModeBehavior || "standard",
|
|
458
|
+
requiresPlanApproval: tool.requiresPlanApproval,
|
|
459
|
+
approvalFlow: tool.approvalFlow,
|
|
460
|
+
permissions: cloneValue(tool.permissions),
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function getCodingAgentFunctionToolDefinition(name) {
|
|
465
|
+
const tool = TOOL_CONTRACT_MAP.get(name);
|
|
466
|
+
return tool ? createFunctionToolContract(tool) : null;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function getCodingAgentFunctionToolDefinitions(options = {}) {
|
|
470
|
+
const { tier = null, names = null } = options;
|
|
471
|
+
const allowedNames =
|
|
472
|
+
Array.isArray(names) && names.length > 0 ? new Set(names) : null;
|
|
473
|
+
|
|
474
|
+
return CODING_AGENT_TOOL_CONTRACTS.filter((tool) => {
|
|
475
|
+
if (tier && tool.tier !== tier) {
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
if (allowedNames && !allowedNames.has(tool.name)) {
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
return true;
|
|
482
|
+
}).map(createFunctionToolContract);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
module.exports = {
|
|
486
|
+
CODING_AGENT_TOOL_CONTRACTS,
|
|
487
|
+
CODING_AGENT_MVP_TOOL_NAMES,
|
|
488
|
+
CODING_AGENT_EXTENSION_TOOL_NAMES,
|
|
489
|
+
getCodingAgentFunctionToolDefinition,
|
|
490
|
+
getCodingAgentFunctionToolDefinitions,
|
|
491
|
+
getCodingAgentToolContract,
|
|
492
|
+
getCodingAgentToolContracts,
|
|
493
|
+
getCodingAgentToolPolicy,
|
|
494
|
+
isCodingAgentMvpTool,
|
|
495
|
+
listCodingAgentToolNames,
|
|
496
|
+
};
|