@gaunt-sloth/agent 2.0.0-alpha.2 → 2.0.0-alpha.3

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.
Files changed (42) hide show
  1. package/README.md +9 -0
  2. package/dist/builtInToolsConfig.js +11 -2
  3. package/dist/builtInToolsConfig.js.map +1 -1
  4. package/dist/core/GthDeepAgent.d.ts +32 -0
  5. package/dist/core/GthDeepAgent.js +113 -9
  6. package/dist/core/GthDeepAgent.js.map +1 -1
  7. package/dist/core/deepAgentPermissions.d.ts +29 -11
  8. package/dist/core/deepAgentPermissions.js +67 -26
  9. package/dist/core/deepAgentPermissions.js.map +1 -1
  10. package/dist/mcp/OAuthClientProviderImpl.js +2 -2
  11. package/dist/mcp/OAuthClientProviderImpl.js.map +1 -1
  12. package/dist/middleware/registry.d.ts +1 -1
  13. package/dist/middleware/registry.js +1 -1
  14. package/dist/middleware/types.d.ts +1 -1
  15. package/dist/middleware/types.js +1 -1
  16. package/dist/modules/acpModule.d.ts +5 -2
  17. package/dist/modules/acpModule.js +5 -2
  18. package/dist/modules/acpModule.js.map +1 -1
  19. package/dist/modules/interactiveSessionModule.js +56 -2
  20. package/dist/modules/interactiveSessionModule.js.map +1 -1
  21. package/dist/tools/GthDevToolkit.d.ts +40 -1
  22. package/dist/tools/GthDevToolkit.js +169 -17
  23. package/dist/tools/GthDevToolkit.js.map +1 -1
  24. package/dist/tools/shell/allowlist.d.ts +11 -0
  25. package/dist/tools/shell/allowlist.js +12 -0
  26. package/dist/tools/shell/allowlist.js.map +1 -0
  27. package/dist/tools/shell/arity.d.ts +11 -0
  28. package/dist/tools/shell/arity.js +12 -0
  29. package/dist/tools/shell/arity.js.map +1 -0
  30. package/dist/tools/shell/env.d.ts +22 -0
  31. package/dist/tools/shell/env.js +110 -0
  32. package/dist/tools/shell/env.js.map +1 -0
  33. package/dist/tools/shell/hardline.d.ts +15 -0
  34. package/dist/tools/shell/hardline.js +88 -0
  35. package/dist/tools/shell/hardline.js.map +1 -0
  36. package/dist/tools/shell/normalize.d.ts +10 -0
  37. package/dist/tools/shell/normalize.js +11 -0
  38. package/dist/tools/shell/normalize.js.map +1 -0
  39. package/dist/tools/shell/outputBuffer.d.ts +53 -0
  40. package/dist/tools/shell/outputBuffer.js +157 -0
  41. package/dist/tools/shell/outputBuffer.js.map +1 -0
  42. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @packageDocumentation
3
- * Middleware registry for Gaunt Sloth Assistant.
3
+ * Middleware registry for Gaunt Sloth.
4
4
  *
5
5
  * This module provides factory functions for creating predefined middleware instances
6
6
  * and a resolver to convert middleware configurations into middleware objects.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @packageDocumentation
3
- * Middleware registry for Gaunt Sloth Assistant.
3
+ * Middleware registry for Gaunt Sloth.
4
4
  *
5
5
  * This module provides factory functions for creating predefined middleware instances
6
6
  * and a resolver to convert middleware configurations into middleware objects.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @packageDocumentation
3
- * Type definitions for middleware configuration in Gaunt Sloth Assistant.
3
+ * Type definitions for middleware configuration in Gaunt Sloth.
4
4
  *
5
5
  * Middleware provides hooks to intercept and control agent execution at critical points.
6
6
  * This module defines the configuration interfaces for both predefined and custom middleware.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @packageDocumentation
3
- * Type definitions for middleware configuration in Gaunt Sloth Assistant.
3
+ * Type definitions for middleware configuration in Gaunt Sloth.
4
4
  *
5
5
  * Middleware provides hooks to intercept and control agent execution at critical points.
6
6
  * This module defines the configuration interfaces for both predefined and custom middleware.
@@ -31,7 +31,10 @@ export interface StartAcpServerOptions {
31
31
  *
32
32
  * NOTE: deepagents-acp 0.1.12 does NOT forward `permissions` to `createDeepAgent` — on the ACP
33
33
  * path fs gating is delegated to the host's interactive permission prompts, not gsloth's
34
- * `.aiignore`→permissions mapping. `permissions` is still passed here for forward-compatibility
35
- * (if a later deepagents-acp forwards it, gsloth's mapping applies with no change here).
34
+ * `.aiignore`→permissions mapping. `permissions` is still passed here for forward-compatibility.
35
+ * EXT-13 caveat: the ACP backend keeps `virtualMode` ON (`/` = workspace, see gthAcpServer), while
36
+ * EXT-13 re-anchored gsloth's default permissions at the REAL absolute cwd for the local runner. So
37
+ * if a future deepagents-acp DOES forward these rules they would not match the virtual `/`-rooted
38
+ * paths the ACP backend hands them — revisit the mapping (or the ACP backend's mode) at that point.
36
39
  */
37
40
  export declare function startAcpServer(config: GthConfig, options?: StartAcpServerOptions): Promise<void>;
@@ -33,8 +33,11 @@ const acpStatusUpdate = (_level, message) => {
33
33
  *
34
34
  * NOTE: deepagents-acp 0.1.12 does NOT forward `permissions` to `createDeepAgent` — on the ACP
35
35
  * path fs gating is delegated to the host's interactive permission prompts, not gsloth's
36
- * `.aiignore`→permissions mapping. `permissions` is still passed here for forward-compatibility
37
- * (if a later deepagents-acp forwards it, gsloth's mapping applies with no change here).
36
+ * `.aiignore`→permissions mapping. `permissions` is still passed here for forward-compatibility.
37
+ * EXT-13 caveat: the ACP backend keeps `virtualMode` ON (`/` = workspace, see gthAcpServer), while
38
+ * EXT-13 re-anchored gsloth's default permissions at the REAL absolute cwd for the local runner. So
39
+ * if a future deepagents-acp DOES forward these rules they would not match the virtual `/`-rooted
40
+ * paths the ACP backend hands them — revisit the mapping (or the ACP backend's mode) at that point.
38
41
  */
39
42
  export async function startAcpServer(config, options = {}) {
40
43
  const command = options.command ?? 'code';
@@ -1 +1 @@
1
- {"version":3,"file":"acpModule.js","sourceRoot":"","sources":["../../src/modules/acpModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2B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,MAAM,CAAC,KAAK;YACnB,YAAY;YACZ,8DAA8D;YAC9D,UAAU,EAAE,MAAM,CAAC,UAAiB;YACpC,sFAAsF;YACtF,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC;QACD,aAAa;KACd,CAAC,CAAC;AACL,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { initConfig } from '@gaunt-sloth/core/config.js';
2
- import { defaultStatusCallback, display, displayInfo, flushSessionLog, formatInputPrompt, initSessionLogging, stopSessionLogging, } from '@gaunt-sloth/core/utils/consoleUtils.js';
2
+ import { defaultStatusCallback, display, displayInfo, displayWarning, flushSessionLog, formatInputPrompt, initSessionLogging, stopSessionLogging, } from '@gaunt-sloth/core/utils/consoleUtils.js';
3
3
  import { GthAgentRunner } from '@gaunt-sloth/core/core/GthAgentRunner.js';
4
4
  import { appendToFile, getCommandOutputFilePath } from '@gaunt-sloth/core/utils/fileUtils.js';
5
5
  import { createInterface, error, exit, setRawMode, stdin as input, stdout as output, } from '@gaunt-sloth/core/utils/systemUtils.js';
@@ -20,6 +20,46 @@ export async function createInteractiveSession(sessionConfig, commandLineConfigO
20
20
  await runner.init(sessionConfig.mode, config, checkpointSaver);
21
21
  const rl = createInterface({ input, output });
22
22
  let shouldExit = false;
23
+ // Tool-approval (human-in-the-loop) prompt for gated tools — currently the opt-in
24
+ // `run_shell_command`. When a run suspends on such a tool call, the runner calls this with
25
+ // the pending command. EXT-9 Tier-2: instead of a bare y/N, offer a scoped choice so the
26
+ // human can stop re-prompting for an operation they trust:
27
+ // [o]nce — approve this single invocation only (persists nothing),
28
+ // [s]ession — auto-approve this command's classified prefix for the rest of the session,
29
+ // [a]lways — additionally persist it to the project allow-list,
30
+ // anything else → reject (fail-closed).
31
+ // The runner consults the allow-list BEFORE calling this, so trusted commands never reach
32
+ // this prompt at all. (The Ink TUI surfaces the same scoped prompt via an approval bridge —
33
+ // see tuiSessionModule's createApprovalBridge + the <ApprovalPrompt> component.)
34
+ runner.setToolApprovalCallback(async (pending) => {
35
+ const commandText = typeof pending.args.command === 'string'
36
+ ? pending.args.command
37
+ : JSON.stringify(pending.args);
38
+ displayWarning(`\nThe agent wants to run a shell command via ${pending.name}:`);
39
+ display(`\n ${commandText}\n`);
40
+ // EXT-10: if the LLM-as-judge gate escalated (rather than auto-approving) this command, show
41
+ // its flag + reason before the human decides.
42
+ if (pending.safetyVerdict) {
43
+ displayWarning(`⚠ safety judge (${pending.safetyVerdict.risk}): ${pending.safetyVerdict.reason}`);
44
+ }
45
+ setRawMode(false); // ensure typed input is echoed for this confirm
46
+ const answer = (await rl.question(formatInputPrompt('Approve? [o]nce / [s]ession / [a]lways / [N]o: ')))
47
+ .trim()
48
+ .toLowerCase();
49
+ if (answer === 'o' || answer === 'once') {
50
+ return { type: 'approve', scope: 'once' };
51
+ }
52
+ if (answer === 's' || answer === 'session') {
53
+ displayInfo('Approved for this session — future variants will not re-prompt.');
54
+ return { type: 'approve', scope: 'session' };
55
+ }
56
+ if (answer === 'a' || answer === 'always') {
57
+ displayInfo('Approved and remembered — saved to the project allow-list.');
58
+ return { type: 'approve', scope: 'always' };
59
+ }
60
+ displayInfo('Command rejected.');
61
+ return { type: 'reject', message: 'User rejected the shell command.' };
62
+ });
23
63
  if (logFileName) {
24
64
  displayInfo(`${sessionConfig.mode} session will be logged to ${logFileName}\n`);
25
65
  }
@@ -43,7 +83,7 @@ export async function createInteractiveSession(sessionConfig, commandLineConfigO
43
83
  if (!userInput.trim()) {
44
84
  continue; // Skip inference if no input
45
85
  }
46
- const lowerInput = userInput.toLowerCase();
86
+ const lowerInput = userInput.toLowerCase().trim();
47
87
  if (lowerInput === 'exit' || lowerInput === '/exit') {
48
88
  display('Exiting...');
49
89
  shouldExit = true;
@@ -52,6 +92,20 @@ export async function createInteractiveSession(sessionConfig, commandLineConfigO
52
92
  rl.close();
53
93
  break;
54
94
  }
95
+ // EXT-12 — `/yolo` toggles session-wide shell auto-approval at the approval-decision
96
+ // layer (the runner flag), distinct from the static `shellYolo` config. Session-scoped,
97
+ // reversible, never persisted; the hardline floor still blocks catastrophic commands.
98
+ if (lowerInput === '/yolo') {
99
+ const enabled = runner.toggleSessionYolo();
100
+ if (enabled) {
101
+ displayWarning('yolo ON — shell commands auto-approved this session (no per-command prompt). ' +
102
+ 'The hardline safety floor still blocks catastrophic commands. Run /yolo again to require approvals.');
103
+ }
104
+ else {
105
+ displayInfo('yolo OFF — approvals required before each shell command.');
106
+ }
107
+ continue; // do not send the command to the model
108
+ }
55
109
  let shouldRetry = false;
56
110
  do {
57
111
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"interactiveSessionModule.js","sourceRoot":"","sources":["../../src/modules/interactiveSessionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACL,eAAe,EACf,KAAK,EACL,IAAI,EACJ,UAAU,EACV,KAAK,IAAI,KAAK,EACd,MAAM,IAAI,MAAM,GACjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAoB,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAUvE,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,aAA4B,EAC5B,0BAAsD,EACtD,OAAgB;IAEhB,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,MAAM,UAAU,CAAC,0BAA0B,CAAC,CAAC,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I,CAAC,UAAU,EAAE,CAAC;oBAChB,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACpC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,UAAU;YAAE,MAAM,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,EAAE,CAAC;YACT,CAAC,EAAE,GAAG,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,kBAAkB,EAAE,CAAC;QACrB,KAAK,CAAC,YAAY,aAAa,CAAC,IAAI,aAAa,GAAG,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,CAAC,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"interactiveSessionModule.js","sourceRoot":"","sources":["../../src/modules/interactiveSessionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,WAAW,EACX,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACL,eAAe,E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,UAAU,EAAE,CAAC;oBAChB,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACpC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,UAAU;YAAE,MAAM,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,EAAE,CAAC;YACT,CAAC,EAAE,GAAG,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,kBAAkB,EAAE,CAAC;QACrB,KAAK,CAAC,YAAY,aAAa,CAAC,IAAI,aAAa,GAAG,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,CAAC,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
@@ -3,10 +3,37 @@
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
+ /**
8
+ * Kill the child AND its descendants on timeout.
9
+ *
10
+ * POSIX: the child is spawned `detached`, so it leads its own process group;
11
+ * signalling the NEGATIVE pid (`-pid`) delivers to the whole group — otherwise a
12
+ * shell's children (e.g. a spawned server) would be orphaned and keep running.
13
+ *
14
+ * Windows (EXT-15): there are no POSIX process groups — `process.kill(-pid)`
15
+ * throws `EINVAL`, and `child.kill()` only terminates the `cmd.exe` wrapper while
16
+ * grandchildren keep the piped stdio handles open, so `'close'` never fires and
17
+ * the tool Promise hangs forever (silently cancelling Windows CI). Use `taskkill
18
+ * /T` to kill the whole tree by pid; `/F` (force) mirrors POSIX SIGKILL, while a
19
+ * graceful taskkill mirrors SIGTERM. Swallows the races where it has already exited.
20
+ *
21
+ * Exported for unit testing the platform branch without a Windows host.
22
+ */
23
+ export declare function killProcessGroup(child: {
24
+ pid?: number;
25
+ kill: (signal?: NodeJS.Signals) => boolean;
26
+ }, signal: NodeJS.Signals): void;
6
27
  export default class GthDevToolkit extends BaseToolkit {
7
28
  tools: StructuredToolInterface[];
8
29
  private commands;
9
- constructor(commands?: GthDevToolsConfig);
30
+ /**
31
+ * The active command, threaded through so the EXT-12 absent-config default for the shell
32
+ * tool (ON in `code`, OFF elsewhere) is resolved consistently with the deep agent's
33
+ * interrupt wiring. Omitted → historical OFF-by-default behaviour.
34
+ */
35
+ private readonly command;
36
+ constructor(commands?: GthDevToolsConfig, command?: GthCommand | undefined);
10
37
  /**
11
38
  * Get tools filtered by operation type
12
39
  */
@@ -19,6 +46,18 @@ export default class GthDevToolkit extends BaseToolkit {
19
46
  * Build the command for running a single test file
20
47
  */
21
48
  private buildSingleTestCommand;
49
+ /**
50
+ * Execute a shell command with the EXT-9 Tier-1 hardening applied:
51
+ * 1. stdin closed + timeout + process-group kill (no hang on interactive
52
+ * commands; runaway commands are killed group-wide on timeout),
53
+ * 2. output capped with a head/tail window + temp-file spillover,
54
+ * 3. provider/LLM credentials scrubbed from the child env,
55
+ * 4. an unbypassable hardline blocklist (refuses catastrophic commands BEFORE
56
+ * spawn — fires even when confirmation is bypassed by yolo).
57
+ *
58
+ * Resolves with a model-facing string. Timeouts resolve (not reject) so the
59
+ * model sees the killed-after-N message and can continue.
60
+ */
22
61
  private executeCommand;
23
62
  private createTools;
24
63
  }
@@ -3,10 +3,77 @@
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 { checkHardline } from '#src/tools/shell/hardline.js';
12
+ import { buildScrubbedEnv } from '#src/tools/shell/env.js';
13
+ import { OutputBuffer } from '#src/tools/shell/outputBuffer.js';
14
+ // Grace period (ms) between SIGTERM and the escalation to SIGKILL when a command
15
+ // exceeds its timeout. Mirrors opencode's `forceKillAfter` (3s).
16
+ const KILL_GRACE_MS = 3_000;
17
+ /**
18
+ * Kill the child AND its descendants on timeout.
19
+ *
20
+ * POSIX: the child is spawned `detached`, so it leads its own process group;
21
+ * signalling the NEGATIVE pid (`-pid`) delivers to the whole group — otherwise a
22
+ * shell's children (e.g. a spawned server) would be orphaned and keep running.
23
+ *
24
+ * Windows (EXT-15): there are no POSIX process groups — `process.kill(-pid)`
25
+ * throws `EINVAL`, and `child.kill()` only terminates the `cmd.exe` wrapper while
26
+ * grandchildren keep the piped stdio handles open, so `'close'` never fires and
27
+ * the tool Promise hangs forever (silently cancelling Windows CI). Use `taskkill
28
+ * /T` to kill the whole tree by pid; `/F` (force) mirrors POSIX SIGKILL, while a
29
+ * graceful taskkill mirrors SIGTERM. Swallows the races where it has already exited.
30
+ *
31
+ * Exported for unit testing the platform branch without a Windows host.
32
+ */
33
+ export function killProcessGroup(child, signal) {
34
+ if (typeof child.pid !== 'number')
35
+ return;
36
+ if (process.platform === 'win32') {
37
+ // No process groups on Windows; taskkill /T walks the whole tree by pid.
38
+ const args = ['/PID', String(child.pid), '/T'];
39
+ if (signal === 'SIGKILL')
40
+ args.push('/F');
41
+ // IMPORTANT: spawnSync does NOT throw when it fails to spawn (e.g. ENOENT if taskkill is
42
+ // missing from PATH) — unlike execSync, it returns an object with an `error` property. So a
43
+ // try/catch would never reach the fallback. Inspect `res.error` explicitly and fall back to
44
+ // the direct child kill (best effort). A non-zero exit (process already gone) is NOT a spawn
45
+ // failure, so it correctly does not trigger the fallback. (`res?.` tolerates test mocks.)
46
+ const res = spawnSync('taskkill', args, { stdio: 'ignore', windowsHide: true });
47
+ if (res?.error) {
48
+ try {
49
+ child.kill(signal);
50
+ }
51
+ catch {
52
+ // Already exited — nothing to do.
53
+ }
54
+ }
55
+ return;
56
+ }
57
+ try {
58
+ // Negative pid → signal the entire process group.
59
+ process.kill(-child.pid, signal);
60
+ return;
61
+ }
62
+ catch (e) {
63
+ const code = e?.code;
64
+ // ESRCH: already gone. EPERM: group-kill not permitted — fall through to the
65
+ // direct child kill below. Anything else: also fall back rather than throw.
66
+ if (code === 'ESRCH')
67
+ return;
68
+ }
69
+ // Fallback: kill just the child (best effort).
70
+ try {
71
+ child.kill(signal);
72
+ }
73
+ catch {
74
+ // Already exited — nothing to do.
75
+ }
76
+ }
10
77
  // Helper function to create a tool with dev type
11
78
  function createGthTool(fn, config, gthDevType) {
12
79
  const toolInstance = tool(fn, config);
@@ -21,13 +88,23 @@ const RunBuildArgsSchema = z.object({});
21
88
  const RunSingleTestArgsSchema = z.object({
22
89
  testPath: z.string().describe('Relative path to the test file to run'),
23
90
  });
91
+ const RunShellCommandArgsSchema = z.object({
92
+ command: z.string().describe('The shell command to run'),
93
+ });
24
94
  const TEST_PATH_PLACEHOLDER = '${testPath}';
25
95
  export default class GthDevToolkit extends BaseToolkit {
26
96
  tools;
27
97
  commands;
28
- constructor(commands = {}) {
98
+ /**
99
+ * The active command, threaded through so the EXT-12 absent-config default for the shell
100
+ * tool (ON in `code`, OFF elsewhere) is resolved consistently with the deep agent's
101
+ * interrupt wiring. Omitted → historical OFF-by-default behaviour.
102
+ */
103
+ command;
104
+ constructor(commands = {}, command) {
29
105
  super();
30
106
  this.commands = commands;
107
+ this.command = command;
31
108
  this.tools = this.createTools();
32
109
  }
33
110
  /**
@@ -93,45 +170,104 @@ export default class GthDevToolkit extends BaseToolkit {
93
170
  throw new Error('No test command configured');
94
171
  }
95
172
  }
173
+ /**
174
+ * Execute a shell command with the EXT-9 Tier-1 hardening applied:
175
+ * 1. stdin closed + timeout + process-group kill (no hang on interactive
176
+ * commands; runaway commands are killed group-wide on timeout),
177
+ * 2. output capped with a head/tail window + temp-file spillover,
178
+ * 3. provider/LLM credentials scrubbed from the child env,
179
+ * 4. an unbypassable hardline blocklist (refuses catastrophic commands BEFORE
180
+ * spawn — fires even when confirmation is bypassed by yolo).
181
+ *
182
+ * Resolves with a model-facing string. Timeouts resolve (not reject) so the
183
+ * model sees the killed-after-N message and can continue.
184
+ */
96
185
  async executeCommand(command, toolName) {
97
186
  displayInfo(`\n🔧 Executing ${toolName}: ${command}`);
187
+ // (4) Hardline blocklist — checked here so it fires regardless of yolo,
188
+ // allow-lists, or any confirmation path. Refuse WITHOUT executing.
189
+ const hardline = checkHardline(command);
190
+ if (hardline) {
191
+ const refusal = `Refusing to execute '${command}': blocked by hardline safety policy ` +
192
+ `(${hardline.description}). This is a catastrophic, non-recoverable command ` +
193
+ `and is blocked even when command confirmation is disabled.`;
194
+ displayWarning(`\n⛔ ${refusal}`);
195
+ return refusal;
196
+ }
197
+ const timeoutMs = getShellTimeoutMs(this.commands);
198
+ const maxOutputBytes = getShellMaxOutputBytes(this.commands);
98
199
  return new Promise((resolve, reject) => {
99
200
  const child = spawn(command, {
100
201
  shell: true,
202
+ // (1) Never let the child block on stdin (e.g. git commit opening $EDITOR).
203
+ stdio: ['ignore', 'pipe', 'pipe'],
204
+ // (1) POSIX: own process group so we can kill the whole tree on timeout
205
+ // (see killProcessGroup). No-op/harmful on Windows, which uses taskkill /T.
206
+ detached: process.platform !== 'win32',
207
+ // (3) Child env with provider/LLM credentials removed.
208
+ env: buildScrubbedEnv(),
101
209
  });
102
- let output = '';
103
- // Capture output if available (when stdio is not 'inherit')
210
+ // (2) Bounded capture for the returned message; live streaming is uncapped.
211
+ const buffer = new OutputBuffer(maxOutputBytes);
212
+ let timedOut = false;
213
+ let settled = false;
214
+ let killTimer;
215
+ const timeoutTimer = setTimeout(() => {
216
+ timedOut = true;
217
+ killProcessGroup(child, 'SIGTERM');
218
+ // Escalate to SIGKILL after a short grace if it didn't die.
219
+ killTimer = setTimeout(() => killProcessGroup(child, 'SIGKILL'), KILL_GRACE_MS);
220
+ // killTimer must not keep the event loop alive on its own.
221
+ killTimer.unref?.();
222
+ }, timeoutMs);
223
+ timeoutTimer.unref?.();
224
+ const clearTimers = () => {
225
+ clearTimeout(timeoutTimer);
226
+ if (killTimer)
227
+ clearTimeout(killTimer);
228
+ };
104
229
  if (child.stdout) {
105
230
  child.stdout.on('data', (data) => {
106
231
  const chunk = data.toString();
107
232
  stdout.write(chunk);
108
- output += chunk;
233
+ buffer.append(chunk);
109
234
  });
110
235
  }
111
236
  if (child.stderr) {
112
237
  child.stderr.on('data', (data) => {
113
238
  const chunk = data.toString();
114
239
  stdout.write(chunk);
115
- output += chunk;
240
+ buffer.append(chunk);
116
241
  });
117
242
  }
118
243
  child.on('close', (code) => {
244
+ if (settled)
245
+ return;
246
+ settled = true;
247
+ clearTimers();
248
+ const captured = buffer.finalize();
249
+ const body = `Executing '${command}'...\n\n` +
250
+ `<COMMAND_OUTPUT>\n` +
251
+ captured.text +
252
+ `</COMMAND_OUTPUT>\n`;
253
+ if (timedOut) {
254
+ resolve(body +
255
+ `\n\nCommand '${command}' was killed after exceeding the ${Math.round(timeoutMs / 1000)}s timeout. ` +
256
+ `If it legitimately needs longer, increase the shell timeout in config.`);
257
+ return;
258
+ }
119
259
  if (code === 0) {
120
- resolve(`Executing '${command}'...\n\n` +
121
- `<COMMAND_OUTPUT>\n` +
122
- output +
123
- `</COMMAND_OUTPUT>\n` +
124
- `\n\nCommand '${command}' completed successfully`);
260
+ resolve(body + `\n\nCommand '${command}' completed successfully`);
125
261
  }
126
262
  else {
127
- resolve(`Executing '${command}'...\n\n` +
128
- `<COMMAND_OUTPUT>\n` +
129
- output +
130
- `</COMMAND_OUTPUT>\n` +
131
- `\n\nCommand '${command}' exited with code ${code}`);
263
+ resolve(body + `\n\nCommand '${command}' exited with code ${code}`);
132
264
  }
133
265
  });
134
266
  child.on('error', (error) => {
267
+ if (settled)
268
+ return;
269
+ settled = true;
270
+ clearTimers();
135
271
  const errorMsg = `Failed to execute command '${command}': ${error.message}`;
136
272
  displayError(errorMsg);
137
273
  reject(new Error(errorMsg));
@@ -183,6 +319,22 @@ export default class GthDevToolkit extends BaseToolkit {
183
319
  schema: RunBuildArgsSchema,
184
320
  }, 'execute'));
185
321
  }
322
+ // Opt-in general-purpose shell tool. Unlike the fixed run_* commands, the model supplies
323
+ // the command, so the guardrail is the per-command confirmation dialog wired by the deep
324
+ // agent (createDeepAgent `interruptOn`), not a parameter sanitizer — a real shell command
325
+ // legitimately contains pipes / `$` / `;`, so validateParameterValue must NOT be applied.
326
+ if (isShellToolEnabled(this.commands, this.command)) {
327
+ tools.push(createGthTool(async (args) => {
328
+ return await this.executeCommand(args.command, 'run_shell_command');
329
+ }, {
330
+ name: 'run_shell_command',
331
+ description: 'Run an arbitrary shell command in the project working directory and return its ' +
332
+ 'combined stdout/stderr and exit status. Use for any task the fixed run_* tools do ' +
333
+ 'not cover (e.g. git, package managers, file inspection). Each call is subject to ' +
334
+ 'human approval before it runs unless approval has been disabled.',
335
+ schema: RunShellCommandArgsSchema,
336
+ }, 'execute'));
337
+ }
186
338
  return tools;
187
339
  }
188
340
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GthDevToolkit.js","sourceRoot":"","sources":["../../src/tools/GthDevToolkit.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAA2B,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE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CAAC,SAAU,IAAI;gBAC9D,MAAM,EAAE,kBAAkB;aAC3B,EACD,SAAS,CACV,CACF,CAAC;QACJ,CAAC;QAED,yFAAyF;QACzF,yFAAyF;QACzF,0FAA0F;QAC1F,0FAA0F;QAC1F,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,KAAK,CAAC,IAAI,CACR,aAAa,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,11 @@
1
+ /**
2
+ * @module tools/shell/allowlist
3
+ *
4
+ * Re-export of the EXT-9 Tier-2 allow-list engine. The implementation lives in
5
+ * `@gaunt-sloth/core` (`core/shell/allowlist`) because the core {@link GthAgentRunner}
6
+ * owns the per-instance session store and the loaded persisted store and consults
7
+ * `matchesApproval` before prompting (core cannot import from `@gaunt-sloth/agent`).
8
+ *
9
+ * See the core module for the exact safe-bin / anti-widening matching rule.
10
+ */
11
+ export { matchesApproval, hasWideningFlag, AllowlistStore, PersistedAllowlist, type ApprovalScope, type ApprovalStores, } from '@gaunt-sloth/core/core/shell/allowlist.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module tools/shell/allowlist
3
+ *
4
+ * Re-export of the EXT-9 Tier-2 allow-list engine. The implementation lives in
5
+ * `@gaunt-sloth/core` (`core/shell/allowlist`) because the core {@link GthAgentRunner}
6
+ * owns the per-instance session store and the loaded persisted store and consults
7
+ * `matchesApproval` before prompting (core cannot import from `@gaunt-sloth/agent`).
8
+ *
9
+ * See the core module for the exact safe-bin / anti-widening matching rule.
10
+ */
11
+ export { matchesApproval, hasWideningFlag, AllowlistStore, PersistedAllowlist, } from '@gaunt-sloth/core/core/shell/allowlist.js';
12
+ //# sourceMappingURL=allowlist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../../../src/tools/shell/allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,EACd,kBAAkB,GAGnB,MAAM,2CAA2C,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module tools/shell/arity
3
+ *
4
+ * Re-export of the EXT-9 Tier-2 command classifier. The implementation lives in
5
+ * `@gaunt-sloth/core` (`core/shell/arity`) because the core {@link GthAgentRunner}
6
+ * must consult it BEFORE prompting (and core cannot import from `@gaunt-sloth/agent`).
7
+ * This stable agent-side path is kept for tests and any agent-layer consumers.
8
+ *
9
+ * See the core module for the arity table scope and the anti-injection fail-closed rule.
10
+ */
11
+ export { classifyCommand, tokenize, meaningfulPrefixTokens, type CommandClassification, } from '@gaunt-sloth/core/core/shell/arity.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module tools/shell/arity
3
+ *
4
+ * Re-export of the EXT-9 Tier-2 command classifier. The implementation lives in
5
+ * `@gaunt-sloth/core` (`core/shell/arity`) because the core {@link GthAgentRunner}
6
+ * must consult it BEFORE prompting (and core cannot import from `@gaunt-sloth/agent`).
7
+ * This stable agent-side path is kept for tests and any agent-layer consumers.
8
+ *
9
+ * See the core module for the arity table scope and the anti-injection fail-closed rule.
10
+ */
11
+ export { classifyCommand, tokenize, meaningfulPrefixTokens, } from '@gaunt-sloth/core/core/shell/arity.js';
12
+ //# sourceMappingURL=arity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arity.js","sourceRoot":"","sources":["../../../src/tools/shell/arity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,eAAe,EACf,QAAQ,EACR,sBAAsB,GAEvB,MAAM,uCAAuC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Explicit blocklist of LLM-provider and cloud credentials. Covers the providers
3
+ * gaunt-sloth (and its consumers) can be configured against, plus the standard
4
+ * cloud secret-bearing vars. Matched case-insensitively.
5
+ */
6
+ export declare const CREDENTIAL_BLOCKLIST: ReadonlyArray<string>;
7
+ /**
8
+ * Allow-list of credential-shaped names that must survive the wildcard sweep
9
+ * because gaunt-sloth legitimately depends on them. Matched case-insensitively.
10
+ */
11
+ export declare const CREDENTIAL_ALLOWLIST: ReadonlyArray<string>;
12
+ /**
13
+ * True when an env var name should be scrubbed from the child environment.
14
+ * Exported for testing.
15
+ */
16
+ export declare function shouldScrubEnvVar(name: string): boolean;
17
+ /**
18
+ * Build the child environment for a spawned shell command: a copy of the parent
19
+ * env with LLM/cloud credentials removed. Defaults to the live `process.env`
20
+ * (via systemUtils); a source can be injected for testing.
21
+ */
22
+ export declare function buildScrubbedEnv(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;