@gaunt-sloth/agent 2.0.0-alpha.1 → 2.0.0-alpha.11
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/LICENSE +7 -0
- package/README.md +9 -0
- package/dist/builtInToolsConfig.d.ts +5 -0
- package/dist/builtInToolsConfig.js +16 -2
- package/dist/builtInToolsConfig.js.map +1 -1
- package/dist/core/GthDeepAgent.d.ts +72 -13
- package/dist/core/GthDeepAgent.js +308 -122
- package/dist/core/GthDeepAgent.js.map +1 -1
- package/dist/core/debugCapture.d.ts +8 -49
- package/dist/core/debugCapture.js +1 -1
- package/dist/core/debugCapture.js.map +1 -1
- package/dist/core/deepAgentPermissions.d.ts +72 -12
- package/dist/core/deepAgentPermissions.js +191 -29
- package/dist/core/deepAgentPermissions.js.map +1 -1
- package/dist/core/gthAcpServer.js +11 -0
- package/dist/core/gthAcpServer.js.map +1 -1
- package/dist/core/gthDeepAgentFactory.d.ts +3 -0
- package/dist/core/gthDeepAgentFactory.js +9 -1
- package/dist/core/gthDeepAgentFactory.js.map +1 -1
- package/dist/core/resolveAgentFactory.d.ts +14 -0
- package/dist/core/resolveAgentFactory.js +18 -0
- package/dist/core/resolveAgentFactory.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/OAuthClientProviderImpl.js +2 -2
- package/dist/mcp/OAuthClientProviderImpl.js.map +1 -1
- package/dist/middleware/registry.d.ts +1 -1
- package/dist/middleware/registry.js +1 -1
- package/dist/middleware/types.d.ts +1 -1
- package/dist/middleware/types.js +1 -1
- package/dist/modules/acpModule.d.ts +5 -2
- package/dist/modules/acpModule.js +13 -2
- package/dist/modules/acpModule.js.map +1 -1
- package/dist/modules/apiAgUiModule.js +48 -16
- package/dist/modules/apiAgUiModule.js.map +1 -1
- package/dist/modules/interactiveSessionModule.js +140 -7
- package/dist/modules/interactiveSessionModule.js.map +1 -1
- package/dist/resolvers.js +70 -7
- package/dist/resolvers.js.map +1 -1
- package/dist/tools/GthDevToolkit.d.ts +45 -1
- package/dist/tools/GthDevToolkit.js +204 -17
- package/dist/tools/GthDevToolkit.js.map +1 -1
- package/dist/tools/gthChecklistTool.d.ts +30 -0
- package/dist/tools/gthChecklistTool.js +81 -0
- package/dist/tools/gthChecklistTool.js.map +1 -0
- package/dist/tools/shell/allowlist.d.ts +11 -0
- package/dist/tools/shell/allowlist.js +12 -0
- package/dist/tools/shell/allowlist.js.map +1 -0
- package/dist/tools/shell/arity.d.ts +11 -0
- package/dist/tools/shell/arity.js +12 -0
- package/dist/tools/shell/arity.js.map +1 -0
- package/dist/tools/shell/env.d.ts +22 -0
- package/dist/tools/shell/env.js +110 -0
- package/dist/tools/shell/env.js.map +1 -0
- package/dist/tools/shell/hardline.d.ts +15 -0
- package/dist/tools/shell/hardline.js +88 -0
- package/dist/tools/shell/hardline.js.map +1 -0
- package/dist/tools/shell/normalize.d.ts +10 -0
- package/dist/tools/shell/normalize.js +11 -0
- package/dist/tools/shell/normalize.js.map +1 -0
- package/dist/tools/shell/outputBuffer.d.ts +53 -0
- package/dist/tools/shell/outputBuffer.js +157 -0
- package/dist/tools/shell/outputBuffer.js.map +1 -0
- package/dist/tools/shell/workDir.d.ts +11 -0
- package/dist/tools/shell/workDir.js +45 -0
- package/dist/tools/shell/workDir.js.map +1 -0
- package/dist/utils/mcpAuthError.d.ts +36 -0
- package/dist/utils/mcpAuthError.js +89 -0
- package/dist/utils/mcpAuthError.js.map +1 -0
- package/dist/utils/mcpUtils.js +16 -0
- package/dist/utils/mcpUtils.js.map +1 -1
- package/package.json +14 -10
package/dist/resolvers.js
CHANGED
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
* agent middleware registry.
|
|
10
10
|
*/
|
|
11
11
|
import { debugLog } from '@gaunt-sloth/core/utils/debugUtils.js';
|
|
12
|
-
import { displayInfo } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
12
|
+
import { displayInfo, displayWarning } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
13
13
|
import { createA2AAgentTool } from '#src/tools/A2AAgentTool.js';
|
|
14
14
|
import { prepareMcpTools } from '#src/utils/mcpUtils.js';
|
|
15
|
+
import { formatMcpConnectFailureMessage } from '#src/utils/mcpAuthError.js';
|
|
15
16
|
import { createAuthProviderAndAuthenticate } from '#src/mcp/OAuthClientProviderImpl.js';
|
|
16
17
|
import { MultiServerMCPClient } from '@langchain/mcp-adapters';
|
|
18
|
+
import { MCP_TOOL_NAME_PREFIX } from '@gaunt-sloth/core/constants.js';
|
|
17
19
|
/**
|
|
18
20
|
* Create a full set of resolvers for the GthLangChainAgent.
|
|
19
21
|
*
|
|
@@ -22,8 +24,14 @@ import { MultiServerMCPClient } from '@langchain/mcp-adapters';
|
|
|
22
24
|
*/
|
|
23
25
|
export function createResolvers() {
|
|
24
26
|
let mcpClientInstance = null;
|
|
27
|
+
// EXT-32: per-server MCP discovery `instructions` captured during the most recent resolveTools.
|
|
28
|
+
// Kept on the resolver so the composed system prompt (via getMcpServerInstructions) AND a future
|
|
29
|
+
// MCP debug tab ([[TUI-C20]]) can read the SAME captured text without re-querying the servers.
|
|
30
|
+
let mcpServerInstructions = [];
|
|
25
31
|
const resolveTools = async (config, command) => {
|
|
26
32
|
const tools = [];
|
|
33
|
+
// Fresh capture per resolution; a stale value must never leak across re-inits.
|
|
34
|
+
mcpServerInstructions = [];
|
|
27
35
|
// 1. Get built-in tools (filesystem, devTools, customTools, etc.)
|
|
28
36
|
try {
|
|
29
37
|
const { getDefaultTools } = await import('#src/builtInToolsConfig.js');
|
|
@@ -50,6 +58,37 @@ export function createResolvers() {
|
|
|
50
58
|
}
|
|
51
59
|
catch (error) {
|
|
52
60
|
debugLog(`MCP tools error: ${error}`);
|
|
61
|
+
// EXT-31: both connection-level failures (incl. expired/invalid auth) AND per-tool schema-load
|
|
62
|
+
// errors under throwOnLoadError are caught inside the adapter's _initializeConnection and
|
|
63
|
+
// routed to the function-form onConnectionError callback in getMcpClient (surface + skip, no
|
|
64
|
+
// re-throw), so they do NOT reach here. This backstop therefore only catches a wholesale
|
|
65
|
+
// getTools() throw (belt-and-braces) — surface it neutrally so MCP tool loading can never fail
|
|
66
|
+
// silently, while the session degrades gracefully (built-in and A2A tools below still load).
|
|
67
|
+
displayWarning(`MCP integration tools could not be fully loaded; continuing without them. ` +
|
|
68
|
+
`Underlying error: ${error}`);
|
|
69
|
+
}
|
|
70
|
+
// 2b. EXT-32: capture each connected MCP server's discovery `instructions` string (from its MCP
|
|
71
|
+
// `initialize` handshake, exposed by the SDK Client via getInstructions()). This is ISOLATED
|
|
72
|
+
// from the getTools() block above so a getClient/getInstructions failure can never discard
|
|
73
|
+
// successfully-loaded MCP tools nor log a misleading "MCP tools error". Per-server try/catch so
|
|
74
|
+
// one unreachable/instruction-less server does not abort the rest. Absent/empty/whitespace-only
|
|
75
|
+
// instructions contribute nothing (trimmed, then omitted). The captured value is injected —
|
|
76
|
+
// fenced + per-server-labelled — into the composed system prompt on BOTH backends.
|
|
77
|
+
if (mcpClientInstance) {
|
|
78
|
+
const serverNames = Object.keys(config.mcpServers || {});
|
|
79
|
+
for (const serverName of serverNames) {
|
|
80
|
+
try {
|
|
81
|
+
const client = await mcpClientInstance.getClient(serverName);
|
|
82
|
+
const instructions = client?.getInstructions()?.trim();
|
|
83
|
+
if (instructions) {
|
|
84
|
+
mcpServerInstructions.push({ server: serverName, instructions });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
debugLog(`MCP instructions capture error for '${serverName}': ${error}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
debugLog(`MCP servers with instructions: ${mcpServerInstructions.length}`);
|
|
53
92
|
}
|
|
54
93
|
// 3. Get A2A tools
|
|
55
94
|
const a2aTools = getA2ATools(config);
|
|
@@ -85,11 +124,16 @@ export function createResolvers() {
|
|
|
85
124
|
const cleanupMiddleware = async () => {
|
|
86
125
|
// No cleanup needed for middleware currently
|
|
87
126
|
};
|
|
127
|
+
// EXT-32: expose the captured per-server MCP instructions for the shared prompt composition (and,
|
|
128
|
+
// later, the [[TUI-C20]] MCP debug tab). Returns a defensive copy so callers can't mutate the
|
|
129
|
+
// captured state. Empty until resolveTools has run (or when no server supplied instructions).
|
|
130
|
+
const getMcpServerInstructions = () => [...mcpServerInstructions];
|
|
88
131
|
return {
|
|
89
132
|
resolveTools,
|
|
90
133
|
cleanupTools,
|
|
91
134
|
resolveMiddleware,
|
|
92
135
|
cleanupMiddleware,
|
|
136
|
+
getMcpServerInstructions,
|
|
93
137
|
};
|
|
94
138
|
}
|
|
95
139
|
// --- Private helpers ---
|
|
@@ -103,11 +147,19 @@ async function getMcpClient(config) {
|
|
|
103
147
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
148
|
if (server.url && server && server.authProvider === 'OAuth') {
|
|
105
149
|
displayInfo(`Starting OAuth for ${server.url}`);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
150
|
+
try {
|
|
151
|
+
const authProvider = await createAuthProviderAndAuthenticate(server);
|
|
152
|
+
mcpServers[serverName] = {
|
|
153
|
+
...server,
|
|
154
|
+
authProvider,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
// EXT-31: an OAuth handshake/refresh failure happens BEFORE the MCP client exists, so it
|
|
159
|
+
// can't reach the connect-time onConnectionError callback below. Surface it here (named +
|
|
160
|
+
// actionable) and skip only THIS server so the others still load — never a silent drop.
|
|
161
|
+
displayWarning(formatMcpConnectFailureMessage(serverName, error, { oauth: true }));
|
|
162
|
+
}
|
|
111
163
|
}
|
|
112
164
|
else {
|
|
113
165
|
mcpServers[serverName] = server;
|
|
@@ -118,8 +170,19 @@ async function getMcpClient(config) {
|
|
|
118
170
|
return new MultiServerMCPClient({
|
|
119
171
|
throwOnLoadError: true,
|
|
120
172
|
prefixToolNameWithServerName: true,
|
|
121
|
-
|
|
173
|
+
// TUI-C20: single-sourced so the MCP debug tab can regroup tools back by server prefix.
|
|
174
|
+
additionalToolNamePrefix: MCP_TOOL_NAME_PREFIX,
|
|
122
175
|
mcpServers: mcpServers,
|
|
176
|
+
// EXT-31: per-server surfacing. The function form of onConnectionError lets a failed server be
|
|
177
|
+
// classified + surfaced and then SKIPPED (added to the client's failedServers set) rather than
|
|
178
|
+
// aborting getTools() — so one integration's expired auth no longer swallows every other
|
|
179
|
+
// server's tools. Auth failures (401/403/expired token/refused handshake) get a named re-auth
|
|
180
|
+
// message; other failures are surfaced plainly as non-auth. Degradation stays graceful.
|
|
181
|
+
onConnectionError: ({ serverName, error }) => {
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
+
const oauth = rawMcpServers[serverName]?.authProvider === 'OAuth';
|
|
184
|
+
displayWarning(formatMcpConnectFailureMessage(serverName, error, { oauth }));
|
|
185
|
+
},
|
|
123
186
|
});
|
|
124
187
|
}
|
|
125
188
|
else {
|
package/dist/resolvers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../src/resolvers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../src/resolvers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,oBAAoB,E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F,wBAAwB,EAAE,oBAAoB;YAC9C,UAAU,EAAE,UAAU;YACtB,+FAA+F;YAC/F,+FAA+F;YAC/F,yFAAyF;YACzF,8FAA8F;YAC9F,wFAAwF;YACxF,iBAAiB,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAA2C,EAAE,EAAE;gBACpF,8DAA8D;gBAC9D,MAAM,KAAK,GAAI,aAAa,CAAC,UAAU,CAAC,EAAE,YAAoB,KAAK,OAAO,CAAC;gBAC3E,cAAc,CAAC,8BAA8B,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YAC/E,CAAC;SACF,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,2BAA2B,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,MAAiB;IACpC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAGxC,CAAC;IACF,MAAM,KAAK,GAA8B,EAAE,CAAC;IAE5C,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/D,QAAQ,CAAC,0BAA0B,OAAO,EAAE,CAAC,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -3,10 +3,38 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { BaseToolkit, StructuredToolInterface } from '@langchain/core/tools';
|
|
5
5
|
import { GthDevToolsConfig } from '@gaunt-sloth/core/config.js';
|
|
6
|
+
import type { GthCommand } from '@gaunt-sloth/core/core/types.js';
|
|
7
|
+
export { ShellCommandFailedError } from '@gaunt-sloth/core/core/shell/ShellCommandFailedError.js';
|
|
8
|
+
/**
|
|
9
|
+
* Kill the child AND its descendants on timeout.
|
|
10
|
+
*
|
|
11
|
+
* POSIX: the child is spawned `detached`, so it leads its own process group;
|
|
12
|
+
* signalling the NEGATIVE pid (`-pid`) delivers to the whole group — otherwise a
|
|
13
|
+
* shell's children (e.g. a spawned server) would be orphaned and keep running.
|
|
14
|
+
*
|
|
15
|
+
* Windows (EXT-15): there are no POSIX process groups — `process.kill(-pid)`
|
|
16
|
+
* throws `EINVAL`, and `child.kill()` only terminates the `cmd.exe` wrapper while
|
|
17
|
+
* grandchildren keep the piped stdio handles open, so `'close'` never fires and
|
|
18
|
+
* the tool Promise hangs forever (silently cancelling Windows CI). Use `taskkill
|
|
19
|
+
* /T` to kill the whole tree by pid; `/F` (force) mirrors POSIX SIGKILL, while a
|
|
20
|
+
* graceful taskkill mirrors SIGTERM. Swallows the races where it has already exited.
|
|
21
|
+
*
|
|
22
|
+
* Exported for unit testing the platform branch without a Windows host.
|
|
23
|
+
*/
|
|
24
|
+
export declare function killProcessGroup(child: {
|
|
25
|
+
pid?: number;
|
|
26
|
+
kill: (signal?: NodeJS.Signals) => boolean;
|
|
27
|
+
}, signal: NodeJS.Signals): void;
|
|
6
28
|
export default class GthDevToolkit extends BaseToolkit {
|
|
7
29
|
tools: StructuredToolInterface[];
|
|
8
30
|
private commands;
|
|
9
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The active command, threaded through so the EXT-12 absent-config default for the shell
|
|
33
|
+
* tool (ON in `code`, OFF elsewhere) is resolved consistently with the deep agent's
|
|
34
|
+
* interrupt wiring. Omitted → historical OFF-by-default behaviour.
|
|
35
|
+
*/
|
|
36
|
+
private readonly command;
|
|
37
|
+
constructor(commands?: GthDevToolsConfig, command?: GthCommand | undefined);
|
|
10
38
|
/**
|
|
11
39
|
* Get tools filtered by operation type
|
|
12
40
|
*/
|
|
@@ -19,6 +47,22 @@ export default class GthDevToolkit extends BaseToolkit {
|
|
|
19
47
|
* Build the command for running a single test file
|
|
20
48
|
*/
|
|
21
49
|
private buildSingleTestCommand;
|
|
50
|
+
/**
|
|
51
|
+
* Execute a shell command with the EXT-9 Tier-1 hardening applied:
|
|
52
|
+
* 1. stdin closed + timeout + process-group kill (no hang on interactive
|
|
53
|
+
* commands; runaway commands are killed group-wide on timeout),
|
|
54
|
+
* 2. output capped with a head/tail window + temp-file spillover,
|
|
55
|
+
* 3. provider/LLM credentials scrubbed from the child env,
|
|
56
|
+
* 4. an unbypassable hardline blocklist (refuses catastrophic commands BEFORE
|
|
57
|
+
* spawn — fires even when confirmation is bypassed by yolo).
|
|
58
|
+
*
|
|
59
|
+
* Resolves with a model-facing string on a CLEAN exit (`code === 0`). EXT-20: a non-zero exit
|
|
60
|
+
* and a timeout-kill instead REJECT with a {@link ShellCommandFailedError} that carries the FULL
|
|
61
|
+
* model-facing body — the deep-agent {@link GthDeepShellExitSoftening} middleware converts that
|
|
62
|
+
* throw into an error `ToolMessage` (status:'error' → ✗) while preserving the output, so the
|
|
63
|
+
* model still sees the killed-after-N / exit-code message and can continue. Spawn-level failures
|
|
64
|
+
* (`child.on('error')`) still reject with a plain `Error`.
|
|
65
|
+
*/
|
|
22
66
|
private executeCommand;
|
|
23
67
|
private createTools;
|
|
24
68
|
}
|
|
@@ -3,10 +3,85 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { BaseToolkit, tool } from '@langchain/core/tools';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { spawn } from 'child_process';
|
|
6
|
+
import { spawn, spawnSync } from 'child_process';
|
|
7
7
|
import path from 'node:path';
|
|
8
|
-
import { displayInfo, displayError } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
8
|
+
import { displayInfo, displayError, displayWarning } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
9
|
+
import { getShellMaxOutputBytes, getShellTimeoutMs, isShellToolEnabled, } from '@gaunt-sloth/core/config.js';
|
|
9
10
|
import { stdout } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
11
|
+
import { ShellCommandFailedError } from '@gaunt-sloth/core/core/shell/ShellCommandFailedError.js';
|
|
12
|
+
import { checkHardline } from '#src/tools/shell/hardline.js';
|
|
13
|
+
import { buildScrubbedEnv } from '#src/tools/shell/env.js';
|
|
14
|
+
import { OutputBuffer } from '#src/tools/shell/outputBuffer.js';
|
|
15
|
+
import { getShellWorkDir } from '#src/tools/shell/workDir.js';
|
|
16
|
+
// EXT-21: `ShellCommandFailedError` moved to core so BOTH agents can recognise a shell failure
|
|
17
|
+
// without breaking the agent→core dependency direction (the lean `GthLangChainAgent` lives in core
|
|
18
|
+
// and cannot import from agent). Re-exported here so the historical import site
|
|
19
|
+
// (`#src/tools/GthDevToolkit.js`) — GthDeepAgent + the existing GthDevToolkit specs — keeps working
|
|
20
|
+
// and every throw below is one and the same core type both agents' softeners catch.
|
|
21
|
+
export { ShellCommandFailedError } from '@gaunt-sloth/core/core/shell/ShellCommandFailedError.js';
|
|
22
|
+
// Grace period (ms) between SIGTERM and the escalation to SIGKILL when a command
|
|
23
|
+
// exceeds its timeout. Mirrors opencode's `forceKillAfter` (3s).
|
|
24
|
+
const KILL_GRACE_MS = 3_000;
|
|
25
|
+
/**
|
|
26
|
+
* Kill the child AND its descendants on timeout.
|
|
27
|
+
*
|
|
28
|
+
* POSIX: the child is spawned `detached`, so it leads its own process group;
|
|
29
|
+
* signalling the NEGATIVE pid (`-pid`) delivers to the whole group — otherwise a
|
|
30
|
+
* shell's children (e.g. a spawned server) would be orphaned and keep running.
|
|
31
|
+
*
|
|
32
|
+
* Windows (EXT-15): there are no POSIX process groups — `process.kill(-pid)`
|
|
33
|
+
* throws `EINVAL`, and `child.kill()` only terminates the `cmd.exe` wrapper while
|
|
34
|
+
* grandchildren keep the piped stdio handles open, so `'close'` never fires and
|
|
35
|
+
* the tool Promise hangs forever (silently cancelling Windows CI). Use `taskkill
|
|
36
|
+
* /T` to kill the whole tree by pid; `/F` (force) mirrors POSIX SIGKILL, while a
|
|
37
|
+
* graceful taskkill mirrors SIGTERM. Swallows the races where it has already exited.
|
|
38
|
+
*
|
|
39
|
+
* Exported for unit testing the platform branch without a Windows host.
|
|
40
|
+
*/
|
|
41
|
+
export function killProcessGroup(child, signal) {
|
|
42
|
+
if (typeof child.pid !== 'number')
|
|
43
|
+
return;
|
|
44
|
+
if (process.platform === 'win32') {
|
|
45
|
+
// No process groups on Windows; taskkill /T walks the whole tree by pid.
|
|
46
|
+
const args = ['/PID', String(child.pid), '/T'];
|
|
47
|
+
if (signal === 'SIGKILL')
|
|
48
|
+
args.push('/F');
|
|
49
|
+
// IMPORTANT: spawnSync does NOT throw when it fails to spawn (e.g. ENOENT if taskkill is
|
|
50
|
+
// missing from PATH) — unlike execSync, it returns an object with an `error` property. So a
|
|
51
|
+
// try/catch would never reach the fallback. Inspect `res.error` explicitly and fall back to
|
|
52
|
+
// the direct child kill (best effort). A non-zero exit (process already gone) is NOT a spawn
|
|
53
|
+
// failure, so it correctly does not trigger the fallback. (`res?.` tolerates test mocks.)
|
|
54
|
+
const res = spawnSync('taskkill', args, { stdio: 'ignore', windowsHide: true });
|
|
55
|
+
if (res?.error) {
|
|
56
|
+
try {
|
|
57
|
+
child.kill(signal);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Already exited — nothing to do.
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
// Negative pid → signal the entire process group.
|
|
67
|
+
process.kill(-child.pid, signal);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
const code = e?.code;
|
|
72
|
+
// ESRCH: already gone. EPERM: group-kill not permitted — fall through to the
|
|
73
|
+
// direct child kill below. Anything else: also fall back rather than throw.
|
|
74
|
+
if (code === 'ESRCH')
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// Fallback: kill just the child (best effort).
|
|
78
|
+
try {
|
|
79
|
+
child.kill(signal);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Already exited — nothing to do.
|
|
83
|
+
}
|
|
84
|
+
}
|
|
10
85
|
// Helper function to create a tool with dev type
|
|
11
86
|
function createGthTool(fn, config, gthDevType) {
|
|
12
87
|
const toolInstance = tool(fn, config);
|
|
@@ -21,13 +96,23 @@ const RunBuildArgsSchema = z.object({});
|
|
|
21
96
|
const RunSingleTestArgsSchema = z.object({
|
|
22
97
|
testPath: z.string().describe('Relative path to the test file to run'),
|
|
23
98
|
});
|
|
99
|
+
const RunShellCommandArgsSchema = z.object({
|
|
100
|
+
command: z.string().describe('The shell command to run'),
|
|
101
|
+
});
|
|
24
102
|
const TEST_PATH_PLACEHOLDER = '${testPath}';
|
|
25
103
|
export default class GthDevToolkit extends BaseToolkit {
|
|
26
104
|
tools;
|
|
27
105
|
commands;
|
|
28
|
-
|
|
106
|
+
/**
|
|
107
|
+
* The active command, threaded through so the EXT-12 absent-config default for the shell
|
|
108
|
+
* tool (ON in `code`, OFF elsewhere) is resolved consistently with the deep agent's
|
|
109
|
+
* interrupt wiring. Omitted → historical OFF-by-default behaviour.
|
|
110
|
+
*/
|
|
111
|
+
command;
|
|
112
|
+
constructor(commands = {}, command) {
|
|
29
113
|
super();
|
|
30
114
|
this.commands = commands;
|
|
115
|
+
this.command = command;
|
|
31
116
|
this.tools = this.createTools();
|
|
32
117
|
}
|
|
33
118
|
/**
|
|
@@ -93,45 +178,131 @@ export default class GthDevToolkit extends BaseToolkit {
|
|
|
93
178
|
throw new Error('No test command configured');
|
|
94
179
|
}
|
|
95
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Execute a shell command with the EXT-9 Tier-1 hardening applied:
|
|
183
|
+
* 1. stdin closed + timeout + process-group kill (no hang on interactive
|
|
184
|
+
* commands; runaway commands are killed group-wide on timeout),
|
|
185
|
+
* 2. output capped with a head/tail window + temp-file spillover,
|
|
186
|
+
* 3. provider/LLM credentials scrubbed from the child env,
|
|
187
|
+
* 4. an unbypassable hardline blocklist (refuses catastrophic commands BEFORE
|
|
188
|
+
* spawn — fires even when confirmation is bypassed by yolo).
|
|
189
|
+
*
|
|
190
|
+
* Resolves with a model-facing string on a CLEAN exit (`code === 0`). EXT-20: a non-zero exit
|
|
191
|
+
* and a timeout-kill instead REJECT with a {@link ShellCommandFailedError} that carries the FULL
|
|
192
|
+
* model-facing body — the deep-agent {@link GthDeepShellExitSoftening} middleware converts that
|
|
193
|
+
* throw into an error `ToolMessage` (status:'error' → ✗) while preserving the output, so the
|
|
194
|
+
* model still sees the killed-after-N / exit-code message and can continue. Spawn-level failures
|
|
195
|
+
* (`child.on('error')`) still reject with a plain `Error`.
|
|
196
|
+
*/
|
|
96
197
|
async executeCommand(command, toolName) {
|
|
97
198
|
displayInfo(`\n🔧 Executing ${toolName}: ${command}`);
|
|
199
|
+
// (4) Hardline blocklist — checked here so it fires regardless of yolo,
|
|
200
|
+
// allow-lists, or any confirmation path. Refuse WITHOUT executing.
|
|
201
|
+
const hardline = checkHardline(command);
|
|
202
|
+
if (hardline) {
|
|
203
|
+
const refusal = `Refusing to execute '${command}': blocked by hardline safety policy ` +
|
|
204
|
+
`(${hardline.description}). This is a catastrophic, non-recoverable command ` +
|
|
205
|
+
`and is blocked even when command confirmation is disabled.`;
|
|
206
|
+
displayWarning(`\n⛔ ${refusal}`);
|
|
207
|
+
return refusal;
|
|
208
|
+
}
|
|
209
|
+
const timeoutMs = getShellTimeoutMs(this.commands);
|
|
210
|
+
const maxOutputBytes = getShellMaxOutputBytes(this.commands);
|
|
98
211
|
return new Promise((resolve, reject) => {
|
|
99
212
|
const child = spawn(command, {
|
|
100
213
|
shell: true,
|
|
214
|
+
// EXT-22 (S4) / EXT-23: spawn in the SAME directory the deepagents FilesystemBackend is
|
|
215
|
+
// rooted at, so the shell tool and the fs tools (ls/read_file/write_file/edit_file/glob/grep)
|
|
216
|
+
// operate on one path namespace instead of diverging. `getShellWorkDir()` returns
|
|
217
|
+
// `getCurrentWorkDir()` on the local code/chat runner + AG-UI (where init() roots the backend
|
|
218
|
+
// at `rootDir: getCurrentWorkDir()`), and the ACP session override on the ACP transport (where
|
|
219
|
+
// `gthAcpServer` re-roots the per-session backend to `session/new.cwd` and updates the
|
|
220
|
+
// override to match — see tools/shell/workDir.ts). Evaluated at call time.
|
|
221
|
+
cwd: getShellWorkDir(),
|
|
222
|
+
// (1) Never let the child block on stdin (e.g. git commit opening $EDITOR).
|
|
223
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
224
|
+
// (1) POSIX: own process group so we can kill the whole tree on timeout
|
|
225
|
+
// (see killProcessGroup). No-op/harmful on Windows, which uses taskkill /T.
|
|
226
|
+
detached: process.platform !== 'win32',
|
|
227
|
+
// (3) Child env with provider/LLM credentials removed.
|
|
228
|
+
env: buildScrubbedEnv(),
|
|
101
229
|
});
|
|
102
|
-
|
|
103
|
-
|
|
230
|
+
// (2) Bounded capture for the returned message; live streaming is uncapped.
|
|
231
|
+
const buffer = new OutputBuffer(maxOutputBytes);
|
|
232
|
+
let timedOut = false;
|
|
233
|
+
let settled = false;
|
|
234
|
+
let killTimer;
|
|
235
|
+
const timeoutTimer = setTimeout(() => {
|
|
236
|
+
timedOut = true;
|
|
237
|
+
killProcessGroup(child, 'SIGTERM');
|
|
238
|
+
// Escalate to SIGKILL after a short grace if it didn't die.
|
|
239
|
+
killTimer = setTimeout(() => killProcessGroup(child, 'SIGKILL'), KILL_GRACE_MS);
|
|
240
|
+
// killTimer must not keep the event loop alive on its own.
|
|
241
|
+
killTimer.unref?.();
|
|
242
|
+
}, timeoutMs);
|
|
243
|
+
timeoutTimer.unref?.();
|
|
244
|
+
const clearTimers = () => {
|
|
245
|
+
clearTimeout(timeoutTimer);
|
|
246
|
+
if (killTimer)
|
|
247
|
+
clearTimeout(killTimer);
|
|
248
|
+
};
|
|
104
249
|
if (child.stdout) {
|
|
105
250
|
child.stdout.on('data', (data) => {
|
|
106
251
|
const chunk = data.toString();
|
|
107
252
|
stdout.write(chunk);
|
|
108
|
-
|
|
253
|
+
buffer.append(chunk);
|
|
109
254
|
});
|
|
110
255
|
}
|
|
111
256
|
if (child.stderr) {
|
|
112
257
|
child.stderr.on('data', (data) => {
|
|
113
258
|
const chunk = data.toString();
|
|
114
259
|
stdout.write(chunk);
|
|
115
|
-
|
|
260
|
+
buffer.append(chunk);
|
|
116
261
|
});
|
|
117
262
|
}
|
|
118
263
|
child.on('close', (code) => {
|
|
264
|
+
if (settled)
|
|
265
|
+
return;
|
|
266
|
+
settled = true;
|
|
267
|
+
clearTimers();
|
|
268
|
+
const captured = buffer.finalize();
|
|
269
|
+
const body = `Executing '${command}'...\n\n` +
|
|
270
|
+
`<COMMAND_OUTPUT>\n` +
|
|
271
|
+
captured.text +
|
|
272
|
+
`</COMMAND_OUTPUT>\n`;
|
|
273
|
+
if (timedOut) {
|
|
274
|
+
// EXT-20: a timeout-kill is a failure — reject so the deep-agent middleware flips the
|
|
275
|
+
// tool result to status:'error' (✗). The FULL body is preserved on the error so the
|
|
276
|
+
// model's observation is unchanged except for the status.
|
|
277
|
+
reject(new ShellCommandFailedError({
|
|
278
|
+
output: body +
|
|
279
|
+
`\n\nCommand '${command}' was killed after exceeding the ${Math.round(timeoutMs / 1000)}s timeout. ` +
|
|
280
|
+
`If it legitimately needs longer, increase the shell timeout in config.`,
|
|
281
|
+
exitCode: null,
|
|
282
|
+
command,
|
|
283
|
+
toolName,
|
|
284
|
+
}));
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
119
287
|
if (code === 0) {
|
|
120
|
-
resolve(
|
|
121
|
-
`<COMMAND_OUTPUT>\n` +
|
|
122
|
-
output +
|
|
123
|
-
`</COMMAND_OUTPUT>\n` +
|
|
124
|
-
`\n\nCommand '${command}' completed successfully`);
|
|
288
|
+
resolve(body + `\n\nCommand '${command}' completed successfully`);
|
|
125
289
|
}
|
|
126
290
|
else {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
291
|
+
// EXT-20: a non-zero exit is a failure — reject (was resolve) so the softening
|
|
292
|
+
// middleware surfaces the ✗ (isError) signal while preserving the full output body.
|
|
293
|
+
reject(new ShellCommandFailedError({
|
|
294
|
+
output: body + `\n\nCommand '${command}' exited with code ${code}`,
|
|
295
|
+
exitCode: code,
|
|
296
|
+
command,
|
|
297
|
+
toolName,
|
|
298
|
+
}));
|
|
132
299
|
}
|
|
133
300
|
});
|
|
134
301
|
child.on('error', (error) => {
|
|
302
|
+
if (settled)
|
|
303
|
+
return;
|
|
304
|
+
settled = true;
|
|
305
|
+
clearTimers();
|
|
135
306
|
const errorMsg = `Failed to execute command '${command}': ${error.message}`;
|
|
136
307
|
displayError(errorMsg);
|
|
137
308
|
reject(new Error(errorMsg));
|
|
@@ -183,6 +354,22 @@ export default class GthDevToolkit extends BaseToolkit {
|
|
|
183
354
|
schema: RunBuildArgsSchema,
|
|
184
355
|
}, 'execute'));
|
|
185
356
|
}
|
|
357
|
+
// Opt-in general-purpose shell tool. Unlike the fixed run_* commands, the model supplies
|
|
358
|
+
// the command, so the guardrail is the per-command confirmation dialog wired by the deep
|
|
359
|
+
// agent (createDeepAgent `interruptOn`), not a parameter sanitizer — a real shell command
|
|
360
|
+
// legitimately contains pipes / `$` / `;`, so validateParameterValue must NOT be applied.
|
|
361
|
+
if (isShellToolEnabled(this.commands, this.command)) {
|
|
362
|
+
tools.push(createGthTool(async (args) => {
|
|
363
|
+
return await this.executeCommand(args.command, 'run_shell_command');
|
|
364
|
+
}, {
|
|
365
|
+
name: 'run_shell_command',
|
|
366
|
+
description: 'Run an arbitrary shell command in the project working directory and return its ' +
|
|
367
|
+
'combined stdout/stderr and exit status. Use for any task the fixed run_* tools do ' +
|
|
368
|
+
'not cover (e.g. git, package managers, file inspection). Each call is subject to ' +
|
|
369
|
+
'human approval before it runs unless approval has been disabled.',
|
|
370
|
+
schema: RunShellCommandArgsSchema,
|
|
371
|
+
}, 'execute'));
|
|
372
|
+
}
|
|
186
373
|
return tools;
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,CACX,KAAK,EAAE,IAA+C,EAAmB,EAAE;gBACzE,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;YACtE,CAAC,EACD;gBACE,IAAI,EAAE,mBAAmB;gBACzB,WAAW,EACT,iFAAiF;oBACjF,oFAAoF;oBACpF,mFAAmF;oBACnF,kEAAkE;gBACpE,MAAM,EAAE,yBAAyB;aAClC,EACD,SAAS,CACV,CACF,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GthConfig } from '@gaunt-sloth/core/config.js';
|
|
3
|
+
export declare const CHECKLIST_TOOL_NAME = "gth_checklist";
|
|
4
|
+
export type ChecklistStatus = 'pending' | 'in_progress' | 'completed';
|
|
5
|
+
export interface ChecklistItem {
|
|
6
|
+
content: string;
|
|
7
|
+
status: ChecklistStatus;
|
|
8
|
+
}
|
|
9
|
+
/** Render a checklist as a markdown observation the model (and a plain terminal) can read back. */
|
|
10
|
+
export declare function formatChecklist(items: ChecklistItem[]): string;
|
|
11
|
+
export declare function get(_config: GthConfig): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
12
|
+
items: z.ZodArray<z.ZodObject<{
|
|
13
|
+
content: z.ZodString;
|
|
14
|
+
status: z.ZodEnum<{
|
|
15
|
+
completed: "completed";
|
|
16
|
+
pending: "pending";
|
|
17
|
+
in_progress: "in_progress";
|
|
18
|
+
}>;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
}, z.core.$strip>, {
|
|
21
|
+
items: {
|
|
22
|
+
content: string;
|
|
23
|
+
status: "completed" | "pending" | "in_progress";
|
|
24
|
+
}[];
|
|
25
|
+
}, {
|
|
26
|
+
items: {
|
|
27
|
+
content: string;
|
|
28
|
+
status: "completed" | "pending" | "in_progress";
|
|
29
|
+
}[];
|
|
30
|
+
}, string, unknown, "gth_checklist">;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module gthChecklistTool
|
|
3
|
+
* The `gth_checklist` planning tool — the lean agent's first-party equivalent of the deepagents
|
|
4
|
+
* `write_todos` capability. Gives the model a durable, structured task list for multi-step work so
|
|
5
|
+
* it can plan, track progress, and stay oriented across a long run.
|
|
6
|
+
*
|
|
7
|
+
* Design (mirrors Claude Code's `TodoWrite` / opencode's todo tools): the model sends the WHOLE
|
|
8
|
+
* list every call and it REPLACES the previous one (no incremental add/remove verbs to keep in
|
|
9
|
+
* sync). State is a closure private to each `get()` result, i.e. one list per agent init / session,
|
|
10
|
+
* so concurrent sessions (e.g. the AG-UI server) never share a checklist. The tool returns a
|
|
11
|
+
* rendered markdown checklist as its observation; the TUI additionally folds it into a live
|
|
12
|
+
* checkbox panel (see {@link file://../../../app/src/tui/viewModel.ts} `CHECKLIST_TOOL_NAME`).
|
|
13
|
+
*
|
|
14
|
+
* The name is deliberately NOT `write_todos` (nor `task`/`read_file`/`write_file`/`edit_file`/`ls`):
|
|
15
|
+
* on the experimental deep backend `createDeepAgent` throws on a name collision with its built-ins,
|
|
16
|
+
* and both backends share the same resolved toolset.
|
|
17
|
+
*/
|
|
18
|
+
import { tool } from '@langchain/core/tools';
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
export const CHECKLIST_TOOL_NAME = 'gth_checklist';
|
|
21
|
+
const itemSchema = z.object({
|
|
22
|
+
content: z
|
|
23
|
+
.string()
|
|
24
|
+
.min(1)
|
|
25
|
+
.describe('Short, imperative description of the task, e.g. "Add tests"'),
|
|
26
|
+
status: z
|
|
27
|
+
.enum(['pending', 'in_progress', 'completed'])
|
|
28
|
+
.describe('pending = not started, in_progress = being worked on now, completed = finished'),
|
|
29
|
+
});
|
|
30
|
+
const schema = z.object({
|
|
31
|
+
items: z
|
|
32
|
+
.array(itemSchema)
|
|
33
|
+
.describe('The FULL checklist. This replaces any previous checklist entirely.'),
|
|
34
|
+
});
|
|
35
|
+
const description = [
|
|
36
|
+
'Record and update a checklist (todo list) for the current task. Use it to plan multi-step',
|
|
37
|
+
'work and to show the user your progress. Send the ENTIRE list every time — it replaces the',
|
|
38
|
+
'previous checklist, so include already-completed items too.',
|
|
39
|
+
'',
|
|
40
|
+
'When to use: any task with 3+ distinct steps, or when the user gives several requirements.',
|
|
41
|
+
'Skip it for a single trivial step.',
|
|
42
|
+
'',
|
|
43
|
+
'Rules:',
|
|
44
|
+
'- Keep at most ONE item "in_progress" at a time.',
|
|
45
|
+
'- Mark an item "completed" as soon as it is done — do not batch completions.',
|
|
46
|
+
'- Keep item text short and outcome-focused.',
|
|
47
|
+
].join('\n');
|
|
48
|
+
const STATUS_GLYPH = {
|
|
49
|
+
completed: '[x]',
|
|
50
|
+
in_progress: '[~]',
|
|
51
|
+
pending: '[ ]',
|
|
52
|
+
};
|
|
53
|
+
/** Render a checklist as a markdown observation the model (and a plain terminal) can read back. */
|
|
54
|
+
export function formatChecklist(items) {
|
|
55
|
+
if (items.length === 0) {
|
|
56
|
+
return 'Checklist cleared (no items).';
|
|
57
|
+
}
|
|
58
|
+
const completed = items.filter((i) => i.status === 'completed').length;
|
|
59
|
+
const header = `Checklist (${completed}/${items.length} completed):`;
|
|
60
|
+
const lines = items.map((i) => `${STATUS_GLYPH[i.status]} ${i.content}`);
|
|
61
|
+
return [header, ...lines].join('\n');
|
|
62
|
+
}
|
|
63
|
+
export function get(_config) {
|
|
64
|
+
// Session-scoped state: one list per tool instance (== per agent init). Whole-list-replace
|
|
65
|
+
// semantics mean each call overwrites this; it is kept so the tool can render the current
|
|
66
|
+
// state back as its observation.
|
|
67
|
+
let items = [];
|
|
68
|
+
const impl = async ({ items: next }) => {
|
|
69
|
+
const inProgress = next.filter((i) => i.status === 'in_progress').length;
|
|
70
|
+
if (inProgress > 1) {
|
|
71
|
+
// Do NOT mutate state on a malformed update — return guidance so the model can retry.
|
|
72
|
+
return (`Rejected: ${inProgress} items are "in_progress" but only one may be in progress at a ` +
|
|
73
|
+
'time. Set all but the current task to "pending" or "completed" and call gth_checklist ' +
|
|
74
|
+
'again.');
|
|
75
|
+
}
|
|
76
|
+
items = next;
|
|
77
|
+
return formatChecklist(items);
|
|
78
|
+
};
|
|
79
|
+
return tool(impl, { name: CHECKLIST_TOOL_NAME, description, schema });
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=gthChecklistTool.js.map
|