@gaunt-sloth/core 2.0.0-alpha.2 → 2.0.0-alpha.21
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/.gsloth.code.md +10 -0
- package/README.md +6 -6
- package/dist/config/defaults.d.ts +85 -0
- package/dist/config/defaults.js +103 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/jsonc.d.ts +12 -0
- package/dist/config/jsonc.js +41 -0
- package/dist/config/jsonc.js.map +1 -0
- package/dist/config/loader.d.ts +169 -0
- package/dist/config/loader.js +872 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +673 -0
- package/dist/config/schema.js +524 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/shell-policy.d.ts +331 -0
- package/dist/config/shell-policy.js +238 -0
- package/dist/config/shell-policy.js.map +1 -0
- package/dist/config/types.d.ts +596 -0
- package/dist/config/types.js +13 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config.d.ts +18 -647
- package/dist/config.js +15 -516
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +42 -0
- package/dist/constants.js +42 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +85 -2
- package/dist/core/GthAbstractAgent.js +398 -28
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +158 -1
- package/dist/core/GthAgentRunner.js +367 -4
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.js +193 -16
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/debugCapture.d.ts +59 -0
- package/dist/core/debugCapture.js +101 -0
- package/dist/core/debugCapture.js.map +1 -0
- package/dist/core/gthLeanAgentFactory.d.ts +9 -0
- package/dist/core/gthLeanAgentFactory.js +10 -0
- package/dist/core/gthLeanAgentFactory.js.map +1 -0
- package/dist/core/plainToolIndication.d.ts +15 -0
- package/dist/core/plainToolIndication.js +148 -0
- package/dist/core/plainToolIndication.js.map +1 -0
- package/dist/core/runStats.d.ts +41 -0
- package/dist/core/runStats.js +73 -0
- package/dist/core/runStats.js.map +1 -0
- package/dist/core/shell/ShellCommandFailedError.d.ts +54 -0
- package/dist/core/shell/ShellCommandFailedError.js +68 -0
- package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
- package/dist/core/shell/allowlist.d.ts +75 -0
- package/dist/core/shell/allowlist.js +187 -0
- package/dist/core/shell/allowlist.js.map +1 -0
- package/dist/core/shell/arity.d.ts +75 -0
- package/dist/core/shell/arity.js +313 -0
- package/dist/core/shell/arity.js.map +1 -0
- package/dist/core/shell/judge.d.ts +161 -0
- package/dist/core/shell/judge.js +261 -0
- package/dist/core/shell/judge.js.map +1 -0
- package/dist/core/shell/normalize.d.ts +27 -0
- package/dist/core/shell/normalize.js +53 -0
- package/dist/core/shell/normalize.js.map +1 -0
- package/dist/core/toolDisplay.d.ts +101 -0
- package/dist/core/toolDisplay.js +374 -0
- package/dist/core/toolDisplay.js.map +1 -0
- package/dist/core/toolOutputChannel.d.ts +68 -0
- package/dist/core/toolOutputChannel.js +112 -0
- package/dist/core/toolOutputChannel.js.map +1 -0
- package/dist/core/types.d.ts +173 -0
- package/dist/core/types.js.map +1 -1
- package/dist/history/historyFormat.d.ts +28 -0
- package/dist/history/historyFormat.js +127 -0
- package/dist/history/historyFormat.js.map +1 -0
- package/dist/history/historyStore.d.ts +198 -0
- package/dist/history/historyStore.js +482 -0
- package/dist/history/historyStore.js.map +1 -0
- package/dist/history/recordSession.d.ts +37 -0
- package/dist/history/recordSession.js +56 -0
- package/dist/history/recordSession.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +5 -10
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +5 -10
- package/dist/providers/deepseek.js.map +1 -1
- package/dist/providers/geminiSchemaSanitizer.d.ts +52 -0
- package/dist/providers/geminiSchemaSanitizer.js +201 -0
- package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
- package/dist/providers/google-genai.d.ts +1 -1
- package/dist/providers/google-genai.js +9 -11
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +5 -10
- package/dist/providers/groq.js.map +1 -1
- package/dist/providers/huggingface.d.ts +25 -0
- package/dist/providers/huggingface.js +69 -0
- package/dist/providers/huggingface.js.map +1 -0
- package/dist/providers/modelCatalog.d.ts +109 -0
- package/dist/providers/modelCatalog.js +245 -0
- package/dist/providers/modelCatalog.js.map +1 -0
- package/dist/providers/modelDiscovery.d.ts +111 -3
- package/dist/providers/modelDiscovery.js +183 -27
- package/dist/providers/modelDiscovery.js.map +1 -1
- package/dist/providers/ollama.d.ts +19 -5
- package/dist/providers/ollama.js +60 -52
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.js +5 -10
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +12 -12
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/vertexai.d.ts +1 -1
- package/dist/providers/vertexai.js +9 -11
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +5 -10
- package/dist/providers/xai.js.map +1 -1
- package/dist/runtime/askStructured.d.ts +62 -0
- package/dist/runtime/askStructured.js +76 -0
- package/dist/runtime/askStructured.js.map +1 -0
- package/dist/runtime/conversation.d.ts +59 -0
- package/dist/runtime/conversation.js +137 -0
- package/dist/runtime/conversation.js.map +1 -0
- package/dist/runtime/singleShot.d.ts +24 -5
- package/dist/runtime/singleShot.js +56 -9
- package/dist/runtime/singleShot.js.map +1 -1
- package/dist/utils/aiignoreUtils.js.map +1 -1
- package/dist/utils/binaryOutputUtils.js.map +1 -1
- package/dist/utils/consoleUtils.d.ts +22 -0
- package/dist/utils/consoleUtils.js +45 -0
- package/dist/utils/consoleUtils.js.map +1 -1
- package/dist/utils/debugDump.d.ts +57 -0
- package/dist/utils/debugDump.js +236 -0
- package/dist/utils/debugDump.js.map +1 -0
- package/dist/utils/debugUtils.d.ts +13 -4
- package/dist/utils/debugUtils.js +36 -13
- package/dist/utils/debugUtils.js.map +1 -1
- package/dist/utils/fileUtils.d.ts +24 -2
- package/dist/utils/fileUtils.js +54 -12
- package/dist/utils/fileUtils.js.map +1 -1
- package/dist/utils/llmUtils.js.map +1 -1
- package/dist/utils/redactSecrets.d.ts +63 -0
- package/dist/utils/redactSecrets.js +238 -0
- package/dist/utils/redactSecrets.js.map +1 -0
- package/dist/utils/systemPromptNotes.d.ts +181 -0
- package/dist/utils/systemPromptNotes.js +298 -0
- package/dist/utils/systemPromptNotes.js.map +1 -0
- package/dist/utils/systemUtils.d.ts +32 -1
- package/dist/utils/systemUtils.js +50 -3
- package/dist/utils/systemUtils.js.map +1 -1
- package/dist/utils/toolMatching.d.ts +30 -0
- package/dist/utils/toolMatching.js +44 -0
- package/dist/utils/toolMatching.js.map +1 -0
- package/package.json +17 -8
- package/schema/gsloth-config.schema.json +2111 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Shell / dev-tools policy: the {@link GthDevToolsConfig} type plus all the resolvers
|
|
4
|
+
* that interpret it (shell enablement, timeouts, output budget, allow-list, the EXT-10
|
|
5
|
+
* LLM-as-judge gate, and per-command dev-tools selection).
|
|
6
|
+
*
|
|
7
|
+
* CFG-18 — the dev/shell tools are now configured through the unified {@link GthConfig.builtInTools}
|
|
8
|
+
* registry (`string[] | Record<string, boolean | BuiltInToolConfig>`), NOT the removed per-command
|
|
9
|
+
* `commands.<mode>.devTools` key. {@link GthDevToolsConfig} is therefore no longer an on-disk shape:
|
|
10
|
+
* it is the internal, resolved view that {@link getEffectiveDevToolsConfig} builds from the effective
|
|
11
|
+
* `builtInTools` registry, and that {@link GthDevToolkit} + the shell accessors below consume. This
|
|
12
|
+
* keeps the toolkit/accessor surface stable while the single config surface is `builtInTools`.
|
|
13
|
+
*/
|
|
14
|
+
import type { GthCommand } from '#src/core/types.js';
|
|
15
|
+
import type { GthConfig, LLMConfig } from '#src/config/types.js';
|
|
16
|
+
/**
|
|
17
|
+
* CFG-18 — the per-tool config object carried as a value in the {@link GthConfig.builtInTools}
|
|
18
|
+
* registry (the object form's values, alongside a bare boolean that enables/force-disables a tool).
|
|
19
|
+
* Heterogeneous by tool, modelled as one permissive object (all fields optional) rather than a
|
|
20
|
+
* discriminated union so the registry can carry every tool's shape:
|
|
21
|
+
* - the fixed dev-command tools (`run_tests`/`run_lint`/`run_build`/`run_single_test`) read
|
|
22
|
+
* {@link command} — the shell command to run; its presence enables the tool;
|
|
23
|
+
* - `run_shell_command` reads the EXT-9/10/12 knobs ({@link enabled}/{@link timeout}/
|
|
24
|
+
* {@link maxOutputBytes}/{@link allowlist}/{@link persistAllowlist}/{@link judge}/{@link yolo} —
|
|
25
|
+
* `yolo` is the folded former `shellYolo`);
|
|
26
|
+
* - `gth_grep` reads {@link fileSet} (GS2-51) — which corpus to search;
|
|
27
|
+
* - a plain built-in tool (`gth_checklist`, `gth_web_fetch`, …) reads {@link enabled} (or is
|
|
28
|
+
* toggled with a bare boolean in the registry).
|
|
29
|
+
*/
|
|
30
|
+
export interface BuiltInToolConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Enable / force-disable this tool. For `run_shell_command` the resolution is `enabled ?? default`
|
|
33
|
+
* (EXT-12: default ON in `code` mode, OFF elsewhere), so an object entry WITHOUT `enabled` still
|
|
34
|
+
* defaults ON in `code`; `enabled: false` is the hard escape hatch that disables it even in `code`.
|
|
35
|
+
* For a plain built-in tool, `enabled: false` removes it from the loaded set.
|
|
36
|
+
*/
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
/** The shell command for a fixed dev-command tool (`run_tests`/`run_lint`/`run_build`/`run_single_test`). */
|
|
39
|
+
command?: string;
|
|
40
|
+
/** `run_shell_command`: per-command wall-clock timeout (ms). See {@link SHELL_DEFAULT_TIMEOUT_MS}. */
|
|
41
|
+
timeout?: number;
|
|
42
|
+
/** `run_shell_command`: captured-output byte budget. See {@link SHELL_DEFAULT_MAX_OUTPUT_BYTES}. */
|
|
43
|
+
maxOutputBytes?: number;
|
|
44
|
+
/** `run_shell_command`: EXT-9 Tier-2 scoped allow-list master switch (default `true`). */
|
|
45
|
+
allowlist?: boolean;
|
|
46
|
+
/** `run_shell_command`: persist `always`-scoped approvals to the project file (default `true`). */
|
|
47
|
+
persistAllowlist?: boolean;
|
|
48
|
+
/** `run_shell_command`: EXT-10 LLM-as-judge safety gate (default OFF). */
|
|
49
|
+
judge?: boolean | {
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
autoApproveLow?: boolean;
|
|
52
|
+
blockHigh?: boolean;
|
|
53
|
+
model?: LLMConfig;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* `run_shell_command`: opt out of the per-command approval prompt — the explicit "yolo" bypass
|
|
57
|
+
* (folded former top-level `shellYolo`). Dangerous by design; off by default. Example:
|
|
58
|
+
* `{ "run_shell_command": { "yolo": true } }`.
|
|
59
|
+
*/
|
|
60
|
+
yolo?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* `gth_grep` (GS2-51): which corpus the content-search tool scans, applied consistently to BOTH
|
|
63
|
+
* execution engines (native ripgrep and the in-process JS fallback):
|
|
64
|
+
* - `gitignore` (DEFAULT) — respect `.gitignore`/`.ignore` and skip hidden dot-files. This is the
|
|
65
|
+
* best code-search UX and is already ripgrep's own default, so rg-present machines see NO
|
|
66
|
+
* behaviour change; only the corpus *selection* becomes explicit.
|
|
67
|
+
* - `all` — scan everything except the noise dirs (`node_modules`/`dist`/`.git`/`.idea`); for rg
|
|
68
|
+
* this passes `--no-ignore --hidden`.
|
|
69
|
+
*
|
|
70
|
+
* Example: `{ "builtInTools": { "gth_grep": { "fileSet": "all" } } }`.
|
|
71
|
+
*
|
|
72
|
+
* NOTE: under `gitignore` the JS fallback is a best-effort approximation (skip noise dirs + hidden
|
|
73
|
+
* dot-files); it does NOT parse arbitrary `.gitignore` rules the way rg does. See the residual
|
|
74
|
+
* rg-vs-JS divergence note in `gthGrepTool.ts`.
|
|
75
|
+
*/
|
|
76
|
+
fileSet?: 'gitignore' | 'all';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* CFG-18 — the widened `builtInTools` setting. Either the legacy `string[]` (each named tool
|
|
80
|
+
* enabled) or a registry keyed by tool name whose values **enable** (`true`), **force-disable**
|
|
81
|
+
* (`false`), or **configure** ({@link BuiltInToolConfig}) each tool. This single key replaces the
|
|
82
|
+
* former split of `builtInTools: string[]` (which tools are on) + per-command `devTools` (how each
|
|
83
|
+
* dev/shell tool is configured).
|
|
84
|
+
*
|
|
85
|
+
* Example — keep the checklist, add web fetch, and configure the shell:
|
|
86
|
+
* ```json
|
|
87
|
+
* { "builtInTools": {
|
|
88
|
+
* "gth_checklist": true,
|
|
89
|
+
* "gth_web_fetch": true,
|
|
90
|
+
* "run_shell_command": { "timeout": 300000, "judge": { "enabled": true } }
|
|
91
|
+
* } }
|
|
92
|
+
* ```
|
|
93
|
+
* Turn the (code-mode default-on) shell OFF: `{ "builtInTools": { "run_shell_command": false } }`.
|
|
94
|
+
*/
|
|
95
|
+
export type BuiltInToolsSetting = string[] | Record<string, boolean | BuiltInToolConfig>;
|
|
96
|
+
/**
|
|
97
|
+
* The fixed dev-command tools: each maps a `command` string (from its {@link BuiltInToolConfig})
|
|
98
|
+
* to a run_* tool emitted by {@link GthDevToolkit}.
|
|
99
|
+
*/
|
|
100
|
+
export declare const DEV_COMMAND_TOOL_NAMES: readonly ['run_tests', 'run_lint', 'run_build', 'run_single_test'];
|
|
101
|
+
/** The opt-in general-purpose shell tool name. */
|
|
102
|
+
export declare const SHELL_TOOL_NAME = "run_shell_command";
|
|
103
|
+
/**
|
|
104
|
+
* All dev/shell tool names carried in the {@link GthConfig.builtInTools} registry. These are emitted
|
|
105
|
+
* by {@link GthDevToolkit} via the dev-tools bucket, NOT loaded as plain built-in tools — so
|
|
106
|
+
* `getBuiltInTools` skips them (a `run_shell_command` entry in `builtInTools` is legitimate, not an
|
|
107
|
+
* "unknown built-in tool").
|
|
108
|
+
*/
|
|
109
|
+
export declare const DEV_TOOL_NAMES: readonly string[];
|
|
110
|
+
/**
|
|
111
|
+
* Normalize the widened {@link BuiltInToolsSetting} to a plain lookup keyed by tool name. The array
|
|
112
|
+
* form maps each name to `true`; the object form passes through unchanged; absent → `{}`.
|
|
113
|
+
*/
|
|
114
|
+
export declare function normalizeBuiltInTools(builtInTools: BuiltInToolsSetting | undefined): Record<string, boolean | BuiltInToolConfig>;
|
|
115
|
+
/**
|
|
116
|
+
* Whether a plain built-in tool's registry entry is enabled: a bare `true`, or an object entry that
|
|
117
|
+
* is not `{ enabled: false }` (configuring a tool enables it). A bare `false` force-disables it.
|
|
118
|
+
* Dev/shell tools ({@link DEV_TOOL_NAMES}) are NOT resolved through this — they go through
|
|
119
|
+
* {@link getEffectiveDevToolsConfig} / {@link isShellToolEnabled}.
|
|
120
|
+
*/
|
|
121
|
+
export declare function isBuiltInToolEntryEnabled(value: boolean | BuiltInToolConfig | undefined): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Config for {@link GthDevToolkit} — the INTERNAL, resolved dev/shell view (CFG-18: no longer an
|
|
124
|
+
* on-disk shape; built from the {@link GthConfig.builtInTools} registry by
|
|
125
|
+
* {@link getEffectiveDevToolsConfig}). Tools are not applied when the config is empty. Only active
|
|
126
|
+
* in `code`/`exec` mode (and `ask --write`).
|
|
127
|
+
*/
|
|
128
|
+
export interface GthDevToolsConfig {
|
|
129
|
+
/**
|
|
130
|
+
* Optional shell command to run tests.
|
|
131
|
+
* Not applied when config is not provided.
|
|
132
|
+
*/
|
|
133
|
+
run_tests?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Optional shell command to run static analysis (lint).
|
|
136
|
+
* Not applied when config is not provided.
|
|
137
|
+
*/
|
|
138
|
+
run_lint?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Optional shell command to run the build.
|
|
141
|
+
* Not applied when config is not provided.
|
|
142
|
+
*/
|
|
143
|
+
run_build?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Optional shell command to run a single test file.
|
|
146
|
+
* Supports command interpolation with the `${testPath}` placeholder.
|
|
147
|
+
* Example: "npm test -- ${testPath}" or "jest ${testPath}"
|
|
148
|
+
* Example: "npm test" - the test will simply be appended
|
|
149
|
+
* Not applied when config is not provided.
|
|
150
|
+
*/
|
|
151
|
+
run_single_test?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Opt-in general-purpose shell tool (`run_shell_command`). Unlike the fixed
|
|
154
|
+
* `run_*` commands above, this lets the agent run ARBITRARY shell commands it
|
|
155
|
+
* composes itself — the agentic-coding escape hatch the deep agent otherwise
|
|
156
|
+
* lacks (it can read/write files but not run commands).
|
|
157
|
+
*
|
|
158
|
+
* EXT-12 — default: ON in `code` mode, OFF elsewhere. When this is ABSENT/undefined,
|
|
159
|
+
* `code` mode emits the tool (still GATED behind the per-command approval prompt — the
|
|
160
|
+
* absent-config default NEVER implies yolo); `exec` / `ask --write` keep it OFF. An
|
|
161
|
+
* EXPLICIT value always wins: `shell: false` (or `{ enabled: false }`) is a hard escape
|
|
162
|
+
* hatch that fully disables it even in `code`. Accepts a bare boolean or an
|
|
163
|
+
* `{ enabled }` object for symmetry with future per-tool options.
|
|
164
|
+
*
|
|
165
|
+
* Because the model chooses the command, every invocation is gated behind a
|
|
166
|
+
* per-command human confirmation dialog (LangChain `humanInTheLoopMiddleware`,
|
|
167
|
+
* wired via deepagents' `interruptOn`) UNLESS {@link shellYolo} bypasses it.
|
|
168
|
+
* The confirmation — not string-filtering — is the guardrail, so the command
|
|
169
|
+
* is passed through verbatim (pipes / `$` / `;` are all legitimate).
|
|
170
|
+
*
|
|
171
|
+
* The object form also tunes the EXT-9 Tier-1 hardening applied to every run
|
|
172
|
+
* (these have safe defaults so bare `shell: true` is already hardened):
|
|
173
|
+
* - `timeout`: per-command wall-clock limit in MILLISECONDS before the child
|
|
174
|
+
* (and its process group) is killed. Default {@link SHELL_DEFAULT_TIMEOUT_MS}.
|
|
175
|
+
* - `maxOutputBytes`: byte budget for the captured output returned to the model
|
|
176
|
+
* (head + tail window; the middle is dropped and the full output spilled to a
|
|
177
|
+
* temp file). Default {@link SHELL_DEFAULT_MAX_OUTPUT_BYTES}. Live terminal
|
|
178
|
+
* streaming is never capped.
|
|
179
|
+
*
|
|
180
|
+
* A hardcoded hardline blocklist of catastrophic commands (rm -rf /, mkfs, dd
|
|
181
|
+
* to a block device, fork bomb, shutdown/reboot, …) is refused even under
|
|
182
|
+
* {@link shellYolo}; that floor is not configurable.
|
|
183
|
+
*
|
|
184
|
+
* On-disk (CFG-18) these live on the `run_shell_command` entry of `builtInTools`, e.g.
|
|
185
|
+
* `{ "builtInTools": { "run_shell_command": true } }` or
|
|
186
|
+
* `{ "builtInTools": { "run_shell_command": { "timeout": 300000, "maxOutputBytes": 200000 } } }`.
|
|
187
|
+
*
|
|
188
|
+
* The object form additionally accepts EXT-9 Tier-2 allow-list knobs:
|
|
189
|
+
* - `allowlist`: master switch for the scoped approval allow-list (session +
|
|
190
|
+
* persisted `always`). Default `true` — once a command is approved at `session`/
|
|
191
|
+
* `always` scope, flag-variants of the same classified operation auto-approve
|
|
192
|
+
* without re-prompting. Set `false` to require fresh approval for every command.
|
|
193
|
+
* - `persistAllowlist`: whether `always`-scoped approvals are written to the project
|
|
194
|
+
* allow-list file (`.gsloth/.gsloth-settings/shell-allowlist.json`). Default `true`.
|
|
195
|
+
* When `false`, an `always` decision behaves like `session` (in-memory only).
|
|
196
|
+
*
|
|
197
|
+
* The object form also accepts the EXT-10 LLM-as-judge safety gate (default OFF):
|
|
198
|
+
* - `judge`: an opt-in, tiered auto-approve pre-filter that vets each `run_shell_command`
|
|
199
|
+
* with a lightweight judge model BEFORE the human prompt. It auto-approves clearly-safe
|
|
200
|
+
* commands (fatigue reducer), escalates the rest to the existing human prompt, and may
|
|
201
|
+
* reject clearly-catastrophic ones. Default OFF because it costs one LLM call per command.
|
|
202
|
+
* Accepts a bare boolean (`judge: true` → defaults: auto-approve low, escalate medium/high,
|
|
203
|
+
* judge model = `config.llm`) or an object:
|
|
204
|
+
* - `enabled`: turn the gate on.
|
|
205
|
+
* - `autoApproveLow`: auto-approve `low`-risk, statically-resolvable commands. Default true.
|
|
206
|
+
* - `blockHigh`: reject clearly-catastrophic (`high` + destructive) verdicts WITHOUT
|
|
207
|
+
* prompting. Default false (conservative; EXT-9's hardline floor already refuses truly
|
|
208
|
+
* catastrophic commands at exec time).
|
|
209
|
+
* - `model`: an optional separate (e.g. cheaper) judge model config. Defaults to `config.llm`.
|
|
210
|
+
* Hardening (always on when the judge runs): the command is normalized + XML-tagged as
|
|
211
|
+
* UNTRUSTED input in the judge prompt; a judge throw/timeout/parse-failure fails CLOSED
|
|
212
|
+
* (escalate, never auto-approve); commands whose target can't be statically resolved
|
|
213
|
+
* (shell composition / substitution / redirection) and interpreter+script invocations that
|
|
214
|
+
* leak ALL_CAPS env vars are NEVER auto-approved.
|
|
215
|
+
*/
|
|
216
|
+
shell?: boolean | {
|
|
217
|
+
enabled?: boolean;
|
|
218
|
+
timeout?: number;
|
|
219
|
+
maxOutputBytes?: number;
|
|
220
|
+
allowlist?: boolean;
|
|
221
|
+
persistAllowlist?: boolean;
|
|
222
|
+
judge?: boolean | {
|
|
223
|
+
enabled?: boolean;
|
|
224
|
+
autoApproveLow?: boolean;
|
|
225
|
+
blockHigh?: boolean;
|
|
226
|
+
model?: LLMConfig;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Opt-out of the per-command confirmation dialog for {@link shell}
|
|
231
|
+
* (`run_shell_command`) — the explicit "yolo" bypass. When `true` AND `shell`
|
|
232
|
+
* is enabled, the shell tool runs without any approval interrupt: the model's
|
|
233
|
+
* commands execute immediately. Dangerous by design; off by default.
|
|
234
|
+
*
|
|
235
|
+
* On-disk (CFG-18) this is the `yolo` knob of the `run_shell_command` entry, e.g.
|
|
236
|
+
* `{ "builtInTools": { "run_shell_command": { "yolo": true } } }`.
|
|
237
|
+
*/
|
|
238
|
+
shellYolo?: boolean;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Default per-command shell timeout (ms) when {@link GthDevToolsConfig.shell}
|
|
242
|
+
* does not specify one. ~120s suits typical build/test/git steps without
|
|
243
|
+
* hanging the agent forever on a stuck command.
|
|
244
|
+
*/
|
|
245
|
+
export declare const SHELL_DEFAULT_TIMEOUT_MS = 120000;
|
|
246
|
+
/**
|
|
247
|
+
* Default byte budget for shell output captured into the ToolMessage returned to
|
|
248
|
+
* the model (head + tail window). ~100KB keeps a noisy log from blowing the
|
|
249
|
+
* context window; the full output is spilled to a temp file when this is exceeded.
|
|
250
|
+
*/
|
|
251
|
+
export declare const SHELL_DEFAULT_MAX_OUTPUT_BYTES = 100000;
|
|
252
|
+
/**
|
|
253
|
+
* Normalize the {@link GthDevToolsConfig.shell} opt-in (bare boolean or
|
|
254
|
+
* `{ enabled }`) to a plain boolean. Centralized so the toolkit (tool emission)
|
|
255
|
+
* and the deep agent (interrupt wiring) agree on what "shell enabled" means.
|
|
256
|
+
*
|
|
257
|
+
* EXT-12 / CFG-18 — default-resolution is `enabled ?? default`. An EXPLICIT `enabled` always wins
|
|
258
|
+
* (a bare boolean, or the object form's `enabled`), so `shell: false` / `{ enabled: false }` remains
|
|
259
|
+
* a hard escape hatch that fully disables the tool. When `enabled` is ABSENT — whether `shell` is
|
|
260
|
+
* undefined OR an object that omits `enabled` (e.g. `{ timeout: 300000 }`, i.e. a
|
|
261
|
+
* `{ "run_shell_command": { "timeout": 300000 } }` registry entry) — the per-mode default applies:
|
|
262
|
+
* ON in `code` mode (still gated — the per-command approval interrupt is wired separately and is NOT
|
|
263
|
+
* bypassed by this), OFF everywhere else (`exec`, `ask --write`, …). This is the CFG-18 change from
|
|
264
|
+
* the old `enabled === true` object semantics: configuring the shell no longer silently turns it off.
|
|
265
|
+
* The default is `code`-mode only because `code` is the interactive agentic-coding surface where a
|
|
266
|
+
* TTY can answer the approval prompt; the absent-config default never implies yolo.
|
|
267
|
+
*
|
|
268
|
+
* @param command The active command, so the absent-config default can be scoped to `code`.
|
|
269
|
+
* Omit (or pass a non-`code` command) to keep the historical OFF-by-default behaviour.
|
|
270
|
+
*/
|
|
271
|
+
export declare function isShellToolEnabled(devTools: GthDevToolsConfig | undefined, command?: GthCommand | undefined): boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Resolve the per-command shell timeout (ms) from config, falling back to
|
|
274
|
+
* {@link SHELL_DEFAULT_TIMEOUT_MS}. Only the object form can override it; a bare
|
|
275
|
+
* `shell: true` uses the default. Non-positive / non-finite values are ignored.
|
|
276
|
+
*/
|
|
277
|
+
export declare function getShellTimeoutMs(devTools: GthDevToolsConfig | undefined): number;
|
|
278
|
+
/**
|
|
279
|
+
* Resolve the captured-output byte budget from config, falling back to
|
|
280
|
+
* {@link SHELL_DEFAULT_MAX_OUTPUT_BYTES}. Only the object form can override it.
|
|
281
|
+
* Non-positive / non-finite values are ignored.
|
|
282
|
+
*/
|
|
283
|
+
export declare function getShellMaxOutputBytes(devTools: GthDevToolsConfig | undefined): number;
|
|
284
|
+
/**
|
|
285
|
+
* Whether the EXT-9 Tier-2 scoped allow-list is active. Default `true`; only the object
|
|
286
|
+
* form's `allowlist: false` disables it (a bare `shell: true` keeps it on). When off, the
|
|
287
|
+
* runner prompts for every `run_shell_command` regardless of prior approvals.
|
|
288
|
+
*/
|
|
289
|
+
export declare function isShellAllowlistEnabled(devTools: GthDevToolsConfig | undefined): boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Whether `always`-scoped approvals are persisted to the project allow-list file. Default
|
|
292
|
+
* `true`; only the object form's `persistAllowlist: false` disables persistence (an
|
|
293
|
+
* `always` decision then behaves as `session`).
|
|
294
|
+
*/
|
|
295
|
+
export declare function isShellAllowlistPersisted(devTools: GthDevToolsConfig | undefined): boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Resolved settings for the EXT-10 LLM-as-judge safety gate.
|
|
298
|
+
*/
|
|
299
|
+
export interface ShellJudgeSettings {
|
|
300
|
+
/** Whether the judge gate runs at all. */
|
|
301
|
+
enabled: boolean;
|
|
302
|
+
/** Auto-approve `low`-risk, statically-resolvable commands (the fatigue reducer). */
|
|
303
|
+
autoApproveLow: boolean;
|
|
304
|
+
/** Reject clearly-catastrophic (`high` + destructive) verdicts without prompting. */
|
|
305
|
+
blockHigh: boolean;
|
|
306
|
+
/** Optional separate judge model config; when absent the runner uses `config.llm`. */
|
|
307
|
+
model?: LLMConfig;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Whether the EXT-10 LLM-as-judge safety gate is enabled for the given dev-tools config.
|
|
311
|
+
* Default OFF (only the object form's `judge` truthy enables it), mirroring
|
|
312
|
+
* {@link isShellToolEnabled}. A bare `shell: true` keeps the judge OFF — it costs an LLM call
|
|
313
|
+
* per command and must be opted into explicitly.
|
|
314
|
+
*/
|
|
315
|
+
export declare function isShellJudgeEnabled(devTools: GthDevToolsConfig | undefined): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Resolve the EXT-10 judge gate settings from a dev-tools config, applying safe defaults
|
|
318
|
+
* (auto-approve low, do NOT block high). `enabled` reflects {@link isShellJudgeEnabled}.
|
|
319
|
+
*/
|
|
320
|
+
export declare function getShellJudgeSettings(devTools: GthDevToolsConfig | undefined): ShellJudgeSettings;
|
|
321
|
+
/**
|
|
322
|
+
* Resolve the {@link GthDevToolsConfig} that applies to the active command from the unified
|
|
323
|
+
* {@link GthConfig.builtInTools} registry (CFG-18 — replaces the removed per-command `devTools`).
|
|
324
|
+
* Mirrors the per-command selection used by `builtInToolsConfig.getDefaultTools`: `exec` →
|
|
325
|
+
* `commands.exec`, `ask --write` → `commands.ask`, `code` → `commands.code`; `undefined` elsewhere
|
|
326
|
+
* (the dev/shell tools are inert there). The effective registry for the scope is the per-command
|
|
327
|
+
* `builtInTools` if set, else the root `builtInTools` — matching `getEffectiveConfig`'s replace
|
|
328
|
+
* merge. Shared in core so the runner's allow-list/judge gates stay in lockstep with where the
|
|
329
|
+
* shell tool is actually emitted.
|
|
330
|
+
*/
|
|
331
|
+
export declare function getEffectiveDevToolsConfig(config: Pick<GthConfig, 'commands' | 'builtInTools' | 'askWriteMode'> | undefined, command: GthCommand | undefined): GthDevToolsConfig | undefined;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fixed dev-command tools: each maps a `command` string (from its {@link BuiltInToolConfig})
|
|
3
|
+
* to a run_* tool emitted by {@link GthDevToolkit}.
|
|
4
|
+
*/
|
|
5
|
+
export const DEV_COMMAND_TOOL_NAMES = [
|
|
6
|
+
'run_tests',
|
|
7
|
+
'run_lint',
|
|
8
|
+
'run_build',
|
|
9
|
+
'run_single_test',
|
|
10
|
+
];
|
|
11
|
+
/** The opt-in general-purpose shell tool name. */
|
|
12
|
+
export const SHELL_TOOL_NAME = 'run_shell_command';
|
|
13
|
+
/**
|
|
14
|
+
* All dev/shell tool names carried in the {@link GthConfig.builtInTools} registry. These are emitted
|
|
15
|
+
* by {@link GthDevToolkit} via the dev-tools bucket, NOT loaded as plain built-in tools — so
|
|
16
|
+
* `getBuiltInTools` skips them (a `run_shell_command` entry in `builtInTools` is legitimate, not an
|
|
17
|
+
* "unknown built-in tool").
|
|
18
|
+
*/
|
|
19
|
+
export const DEV_TOOL_NAMES = [...DEV_COMMAND_TOOL_NAMES, SHELL_TOOL_NAME];
|
|
20
|
+
/**
|
|
21
|
+
* Normalize the widened {@link BuiltInToolsSetting} to a plain lookup keyed by tool name. The array
|
|
22
|
+
* form maps each name to `true`; the object form passes through unchanged; absent → `{}`.
|
|
23
|
+
*/
|
|
24
|
+
export function normalizeBuiltInTools(builtInTools) {
|
|
25
|
+
if (!builtInTools)
|
|
26
|
+
return {};
|
|
27
|
+
if (Array.isArray(builtInTools)) {
|
|
28
|
+
const out = {};
|
|
29
|
+
for (const name of builtInTools)
|
|
30
|
+
out[name] = true;
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
return builtInTools;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Whether a plain built-in tool's registry entry is enabled: a bare `true`, or an object entry that
|
|
37
|
+
* is not `{ enabled: false }` (configuring a tool enables it). A bare `false` force-disables it.
|
|
38
|
+
* Dev/shell tools ({@link DEV_TOOL_NAMES}) are NOT resolved through this — they go through
|
|
39
|
+
* {@link getEffectiveDevToolsConfig} / {@link isShellToolEnabled}.
|
|
40
|
+
*/
|
|
41
|
+
export function isBuiltInToolEntryEnabled(value) {
|
|
42
|
+
if (value === undefined)
|
|
43
|
+
return false;
|
|
44
|
+
if (typeof value === 'boolean')
|
|
45
|
+
return value;
|
|
46
|
+
return value.enabled !== false;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Default per-command shell timeout (ms) when {@link GthDevToolsConfig.shell}
|
|
50
|
+
* does not specify one. ~120s suits typical build/test/git steps without
|
|
51
|
+
* hanging the agent forever on a stuck command.
|
|
52
|
+
*/
|
|
53
|
+
export const SHELL_DEFAULT_TIMEOUT_MS = 120_000;
|
|
54
|
+
/**
|
|
55
|
+
* Default byte budget for shell output captured into the ToolMessage returned to
|
|
56
|
+
* the model (head + tail window). ~100KB keeps a noisy log from blowing the
|
|
57
|
+
* context window; the full output is spilled to a temp file when this is exceeded.
|
|
58
|
+
*/
|
|
59
|
+
export const SHELL_DEFAULT_MAX_OUTPUT_BYTES = 100_000;
|
|
60
|
+
/**
|
|
61
|
+
* Normalize the {@link GthDevToolsConfig.shell} opt-in (bare boolean or
|
|
62
|
+
* `{ enabled }`) to a plain boolean. Centralized so the toolkit (tool emission)
|
|
63
|
+
* and the deep agent (interrupt wiring) agree on what "shell enabled" means.
|
|
64
|
+
*
|
|
65
|
+
* EXT-12 / CFG-18 — default-resolution is `enabled ?? default`. An EXPLICIT `enabled` always wins
|
|
66
|
+
* (a bare boolean, or the object form's `enabled`), so `shell: false` / `{ enabled: false }` remains
|
|
67
|
+
* a hard escape hatch that fully disables the tool. When `enabled` is ABSENT — whether `shell` is
|
|
68
|
+
* undefined OR an object that omits `enabled` (e.g. `{ timeout: 300000 }`, i.e. a
|
|
69
|
+
* `{ "run_shell_command": { "timeout": 300000 } }` registry entry) — the per-mode default applies:
|
|
70
|
+
* ON in `code` mode (still gated — the per-command approval interrupt is wired separately and is NOT
|
|
71
|
+
* bypassed by this), OFF everywhere else (`exec`, `ask --write`, …). This is the CFG-18 change from
|
|
72
|
+
* the old `enabled === true` object semantics: configuring the shell no longer silently turns it off.
|
|
73
|
+
* The default is `code`-mode only because `code` is the interactive agentic-coding surface where a
|
|
74
|
+
* TTY can answer the approval prompt; the absent-config default never implies yolo.
|
|
75
|
+
*
|
|
76
|
+
* @param command The active command, so the absent-config default can be scoped to `code`.
|
|
77
|
+
* Omit (or pass a non-`code` command) to keep the historical OFF-by-default behaviour.
|
|
78
|
+
*/
|
|
79
|
+
export function isShellToolEnabled(devTools, command) {
|
|
80
|
+
const shell = devTools?.shell;
|
|
81
|
+
if (typeof shell === 'boolean')
|
|
82
|
+
return shell;
|
|
83
|
+
// Object form: `enabled ?? default` — an object without `enabled` still defaults ON in `code`.
|
|
84
|
+
if (shell && typeof shell === 'object')
|
|
85
|
+
return shell.enabled ?? command === 'code';
|
|
86
|
+
// Absent/undefined shell: ON by default for `code` mode (gated), OFF elsewhere.
|
|
87
|
+
return command === 'code';
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolve the per-command shell timeout (ms) from config, falling back to
|
|
91
|
+
* {@link SHELL_DEFAULT_TIMEOUT_MS}. Only the object form can override it; a bare
|
|
92
|
+
* `shell: true` uses the default. Non-positive / non-finite values are ignored.
|
|
93
|
+
*/
|
|
94
|
+
export function getShellTimeoutMs(devTools) {
|
|
95
|
+
const shell = devTools?.shell;
|
|
96
|
+
if (shell && typeof shell === 'object' && typeof shell.timeout === 'number') {
|
|
97
|
+
if (Number.isFinite(shell.timeout) && shell.timeout > 0)
|
|
98
|
+
return shell.timeout;
|
|
99
|
+
}
|
|
100
|
+
return SHELL_DEFAULT_TIMEOUT_MS;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Resolve the captured-output byte budget from config, falling back to
|
|
104
|
+
* {@link SHELL_DEFAULT_MAX_OUTPUT_BYTES}. Only the object form can override it.
|
|
105
|
+
* Non-positive / non-finite values are ignored.
|
|
106
|
+
*/
|
|
107
|
+
export function getShellMaxOutputBytes(devTools) {
|
|
108
|
+
const shell = devTools?.shell;
|
|
109
|
+
if (shell && typeof shell === 'object' && typeof shell.maxOutputBytes === 'number') {
|
|
110
|
+
if (Number.isFinite(shell.maxOutputBytes) && shell.maxOutputBytes > 0) {
|
|
111
|
+
return shell.maxOutputBytes;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return SHELL_DEFAULT_MAX_OUTPUT_BYTES;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Whether the EXT-9 Tier-2 scoped allow-list is active. Default `true`; only the object
|
|
118
|
+
* form's `allowlist: false` disables it (a bare `shell: true` keeps it on). When off, the
|
|
119
|
+
* runner prompts for every `run_shell_command` regardless of prior approvals.
|
|
120
|
+
*/
|
|
121
|
+
export function isShellAllowlistEnabled(devTools) {
|
|
122
|
+
const shell = devTools?.shell;
|
|
123
|
+
if (shell && typeof shell === 'object' && shell.allowlist === false)
|
|
124
|
+
return false;
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Whether `always`-scoped approvals are persisted to the project allow-list file. Default
|
|
129
|
+
* `true`; only the object form's `persistAllowlist: false` disables persistence (an
|
|
130
|
+
* `always` decision then behaves as `session`).
|
|
131
|
+
*/
|
|
132
|
+
export function isShellAllowlistPersisted(devTools) {
|
|
133
|
+
const shell = devTools?.shell;
|
|
134
|
+
if (shell && typeof shell === 'object' && shell.persistAllowlist === false)
|
|
135
|
+
return false;
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Whether the EXT-10 LLM-as-judge safety gate is enabled for the given dev-tools config.
|
|
140
|
+
* Default OFF (only the object form's `judge` truthy enables it), mirroring
|
|
141
|
+
* {@link isShellToolEnabled}. A bare `shell: true` keeps the judge OFF — it costs an LLM call
|
|
142
|
+
* per command and must be opted into explicitly.
|
|
143
|
+
*/
|
|
144
|
+
export function isShellJudgeEnabled(devTools) {
|
|
145
|
+
const shell = devTools?.shell;
|
|
146
|
+
if (!shell || typeof shell !== 'object')
|
|
147
|
+
return false;
|
|
148
|
+
const judge = shell.judge;
|
|
149
|
+
if (typeof judge === 'boolean')
|
|
150
|
+
return judge;
|
|
151
|
+
if (judge && typeof judge === 'object')
|
|
152
|
+
return judge.enabled === true;
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Resolve the EXT-10 judge gate settings from a dev-tools config, applying safe defaults
|
|
157
|
+
* (auto-approve low, do NOT block high). `enabled` reflects {@link isShellJudgeEnabled}.
|
|
158
|
+
*/
|
|
159
|
+
export function getShellJudgeSettings(devTools) {
|
|
160
|
+
const enabled = isShellJudgeEnabled(devTools);
|
|
161
|
+
const shell = devTools?.shell;
|
|
162
|
+
const judge = shell && typeof shell === 'object' && shell.judge && typeof shell.judge === 'object'
|
|
163
|
+
? shell.judge
|
|
164
|
+
: undefined;
|
|
165
|
+
return {
|
|
166
|
+
enabled,
|
|
167
|
+
autoApproveLow: judge?.autoApproveLow ?? true,
|
|
168
|
+
blockHigh: judge?.blockHigh ?? false,
|
|
169
|
+
model: judge?.model,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Build the internal, resolved {@link GthDevToolsConfig} from a normalized `builtInTools` registry:
|
|
174
|
+
* the fixed dev-command tools read their `command` string, and `run_shell_command` maps to the
|
|
175
|
+
* `shell` (+ `shellYolo`) view the accessors below consume. Returns `undefined` when the registry
|
|
176
|
+
* carries no dev/shell entry at all, so callers treat it exactly like an unset `devTools` (the
|
|
177
|
+
* `code`-mode shell default still applies downstream via {@link isShellToolEnabled}).
|
|
178
|
+
*/
|
|
179
|
+
function devToolsConfigFromRegistry(registry) {
|
|
180
|
+
const resolved = {};
|
|
181
|
+
let hasAny = false;
|
|
182
|
+
for (const name of DEV_COMMAND_TOOL_NAMES) {
|
|
183
|
+
const entry = registry[name];
|
|
184
|
+
const cmd = entry && typeof entry === 'object' ? entry.command : undefined;
|
|
185
|
+
if (typeof cmd === 'string' && cmd.length > 0) {
|
|
186
|
+
resolved[name] = cmd;
|
|
187
|
+
hasAny = true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (Object.prototype.hasOwnProperty.call(registry, SHELL_TOOL_NAME)) {
|
|
191
|
+
const entry = registry[SHELL_TOOL_NAME];
|
|
192
|
+
if (typeof entry === 'boolean') {
|
|
193
|
+
resolved.shell = entry;
|
|
194
|
+
}
|
|
195
|
+
else if (entry && typeof entry === 'object') {
|
|
196
|
+
resolved.shell = {
|
|
197
|
+
enabled: entry.enabled,
|
|
198
|
+
timeout: entry.timeout,
|
|
199
|
+
maxOutputBytes: entry.maxOutputBytes,
|
|
200
|
+
allowlist: entry.allowlist,
|
|
201
|
+
persistAllowlist: entry.persistAllowlist,
|
|
202
|
+
judge: entry.judge,
|
|
203
|
+
};
|
|
204
|
+
if (entry.yolo !== undefined)
|
|
205
|
+
resolved.shellYolo = entry.yolo;
|
|
206
|
+
}
|
|
207
|
+
hasAny = true;
|
|
208
|
+
}
|
|
209
|
+
return hasAny ? resolved : undefined;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Resolve the {@link GthDevToolsConfig} that applies to the active command from the unified
|
|
213
|
+
* {@link GthConfig.builtInTools} registry (CFG-18 — replaces the removed per-command `devTools`).
|
|
214
|
+
* Mirrors the per-command selection used by `builtInToolsConfig.getDefaultTools`: `exec` →
|
|
215
|
+
* `commands.exec`, `ask --write` → `commands.ask`, `code` → `commands.code`; `undefined` elsewhere
|
|
216
|
+
* (the dev/shell tools are inert there). The effective registry for the scope is the per-command
|
|
217
|
+
* `builtInTools` if set, else the root `builtInTools` — matching `getEffectiveConfig`'s replace
|
|
218
|
+
* merge. Shared in core so the runner's allow-list/judge gates stay in lockstep with where the
|
|
219
|
+
* shell tool is actually emitted.
|
|
220
|
+
*/
|
|
221
|
+
export function getEffectiveDevToolsConfig(config, command) {
|
|
222
|
+
if (!config)
|
|
223
|
+
return undefined;
|
|
224
|
+
const askWrite = command === 'ask' && config.askWriteMode === true;
|
|
225
|
+
const cmdConfig = command === 'exec'
|
|
226
|
+
? config.commands?.exec
|
|
227
|
+
: askWrite
|
|
228
|
+
? config.commands?.ask
|
|
229
|
+
: command === 'code'
|
|
230
|
+
? config.commands?.code
|
|
231
|
+
: undefined;
|
|
232
|
+
// Only the do-the-job commands (code/exec/ask --write) carry dev/shell tools.
|
|
233
|
+
if (command !== 'exec' && command !== 'code' && !askWrite)
|
|
234
|
+
return undefined;
|
|
235
|
+
const effective = cmdConfig?.builtInTools ?? config.builtInTools;
|
|
236
|
+
return devToolsConfigFromRegistry(normalizeBuiltInTools(effective));
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=shell-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-policy.js","sourceRoot":"","sources":["../../src/config/shell-policy.ts"],"names":[],"mappings":"AAoGA;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW;IACX,UAAU;IACV,WAAW;IACX,iBAAiB;CACT,CAAC;AAEX,kDAAkD;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAEnD;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