@gaunt-sloth/core 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (53) hide show
  1. package/.gsloth.code.md +10 -0
  2. package/README.md +3 -4
  3. package/dist/config/defaults.d.ts +84 -0
  4. package/dist/config/defaults.js +97 -0
  5. package/dist/config/defaults.js.map +1 -0
  6. package/dist/config/loader.d.ts +88 -0
  7. package/dist/config/loader.js +604 -0
  8. package/dist/config/loader.js.map +1 -0
  9. package/dist/config/schema.d.ts +471 -0
  10. package/dist/config/schema.js +301 -0
  11. package/dist/config/schema.js.map +1 -0
  12. package/dist/config/shell-policy.d.ts +212 -0
  13. package/dist/config/shell-policy.js +142 -0
  14. package/dist/config/shell-policy.js.map +1 -0
  15. package/dist/config/types.d.ts +453 -0
  16. package/dist/config/types.js +12 -0
  17. package/dist/config/types.js.map +1 -0
  18. package/dist/config.d.ts +18 -647
  19. package/dist/config.js +15 -516
  20. package/dist/config.js.map +1 -1
  21. package/dist/constants.d.ts +6 -0
  22. package/dist/constants.js +6 -0
  23. package/dist/constants.js.map +1 -1
  24. package/dist/core/GthAbstractAgent.d.ts +24 -1
  25. package/dist/core/GthAbstractAgent.js +86 -4
  26. package/dist/core/GthAbstractAgent.js.map +1 -1
  27. package/dist/core/GthAgentRunner.d.ts +127 -1
  28. package/dist/core/GthAgentRunner.js +298 -4
  29. package/dist/core/GthAgentRunner.js.map +1 -1
  30. package/dist/core/shell/allowlist.d.ts +75 -0
  31. package/dist/core/shell/allowlist.js +187 -0
  32. package/dist/core/shell/allowlist.js.map +1 -0
  33. package/dist/core/shell/arity.d.ts +75 -0
  34. package/dist/core/shell/arity.js +313 -0
  35. package/dist/core/shell/arity.js.map +1 -0
  36. package/dist/core/shell/judge.d.ts +161 -0
  37. package/dist/core/shell/judge.js +261 -0
  38. package/dist/core/shell/judge.js.map +1 -0
  39. package/dist/core/shell/normalize.d.ts +27 -0
  40. package/dist/core/shell/normalize.js +53 -0
  41. package/dist/core/shell/normalize.js.map +1 -0
  42. package/dist/core/types.d.ts +75 -0
  43. package/dist/core/types.js.map +1 -1
  44. package/dist/providers/openrouter.js +2 -2
  45. package/dist/providers/openrouter.js.map +1 -1
  46. package/dist/utils/fileUtils.d.ts +4 -1
  47. package/dist/utils/fileUtils.js +19 -10
  48. package/dist/utils/fileUtils.js.map +1 -1
  49. package/dist/utils/systemUtils.d.ts +31 -0
  50. package/dist/utils/systemUtils.js +38 -0
  51. package/dist/utils/systemUtils.js.map +1 -1
  52. package/package.json +12 -8
  53. package/schema/gsloth-config.schema.json +1548 -0
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Default per-command shell timeout (ms) when {@link GthDevToolsConfig.shell}
3
+ * does not specify one. ~120s suits typical build/test/git steps without
4
+ * hanging the agent forever on a stuck command.
5
+ */
6
+ export const SHELL_DEFAULT_TIMEOUT_MS = 120_000;
7
+ /**
8
+ * Default byte budget for shell output captured into the ToolMessage returned to
9
+ * the model (head + tail window). ~100KB keeps a noisy log from blowing the
10
+ * context window; the full output is spilled to a temp file when this is exceeded.
11
+ */
12
+ export const SHELL_DEFAULT_MAX_OUTPUT_BYTES = 100_000;
13
+ /**
14
+ * Normalize the {@link GthDevToolsConfig.shell} opt-in (bare boolean or
15
+ * `{ enabled }`) to a plain boolean. Centralized so the toolkit (tool emission)
16
+ * and the deep agent (interrupt wiring) agree on what "shell enabled" means.
17
+ *
18
+ * EXT-12 — default-resolution: an EXPLICIT value always wins (a bare boolean, or the
19
+ * object form's `enabled`), so `shell: false` / `{ enabled: false }` remains a hard
20
+ * escape hatch that fully disables the tool. Only when `shell` is ABSENT/undefined does
21
+ * the per-mode default apply: in `code` mode the shell tool is ON by default (still
22
+ * gated — the per-command approval interrupt is wired separately and is NOT bypassed by
23
+ * this), and OFF everywhere else (`exec`, `ask --write`, …) to preserve prior behaviour.
24
+ * The default is `code`-mode only because `code` is the interactive agentic-coding surface
25
+ * where a TTY can answer the approval prompt; the absent-config default never implies yolo.
26
+ *
27
+ * @param command The active command, so the absent-config default can be scoped to `code`.
28
+ * Omit (or pass a non-`code` command) to keep the historical OFF-by-default behaviour.
29
+ */
30
+ export function isShellToolEnabled(devTools, command) {
31
+ const shell = devTools?.shell;
32
+ if (typeof shell === 'boolean')
33
+ return shell;
34
+ if (shell && typeof shell === 'object')
35
+ return shell.enabled === true;
36
+ // Absent/undefined shell: ON by default for `code` mode (gated), OFF elsewhere.
37
+ return command === 'code';
38
+ }
39
+ /**
40
+ * Resolve the per-command shell timeout (ms) from config, falling back to
41
+ * {@link SHELL_DEFAULT_TIMEOUT_MS}. Only the object form can override it; a bare
42
+ * `shell: true` uses the default. Non-positive / non-finite values are ignored.
43
+ */
44
+ export function getShellTimeoutMs(devTools) {
45
+ const shell = devTools?.shell;
46
+ if (shell && typeof shell === 'object' && typeof shell.timeout === 'number') {
47
+ if (Number.isFinite(shell.timeout) && shell.timeout > 0)
48
+ return shell.timeout;
49
+ }
50
+ return SHELL_DEFAULT_TIMEOUT_MS;
51
+ }
52
+ /**
53
+ * Resolve the captured-output byte budget from config, falling back to
54
+ * {@link SHELL_DEFAULT_MAX_OUTPUT_BYTES}. Only the object form can override it.
55
+ * Non-positive / non-finite values are ignored.
56
+ */
57
+ export function getShellMaxOutputBytes(devTools) {
58
+ const shell = devTools?.shell;
59
+ if (shell && typeof shell === 'object' && typeof shell.maxOutputBytes === 'number') {
60
+ if (Number.isFinite(shell.maxOutputBytes) && shell.maxOutputBytes > 0) {
61
+ return shell.maxOutputBytes;
62
+ }
63
+ }
64
+ return SHELL_DEFAULT_MAX_OUTPUT_BYTES;
65
+ }
66
+ /**
67
+ * Whether the EXT-9 Tier-2 scoped allow-list is active. Default `true`; only the object
68
+ * form's `allowlist: false` disables it (a bare `shell: true` keeps it on). When off, the
69
+ * runner prompts for every `run_shell_command` regardless of prior approvals.
70
+ */
71
+ export function isShellAllowlistEnabled(devTools) {
72
+ const shell = devTools?.shell;
73
+ if (shell && typeof shell === 'object' && shell.allowlist === false)
74
+ return false;
75
+ return true;
76
+ }
77
+ /**
78
+ * Whether `always`-scoped approvals are persisted to the project allow-list file. Default
79
+ * `true`; only the object form's `persistAllowlist: false` disables persistence (an
80
+ * `always` decision then behaves as `session`).
81
+ */
82
+ export function isShellAllowlistPersisted(devTools) {
83
+ const shell = devTools?.shell;
84
+ if (shell && typeof shell === 'object' && shell.persistAllowlist === false)
85
+ return false;
86
+ return true;
87
+ }
88
+ /**
89
+ * Whether the EXT-10 LLM-as-judge safety gate is enabled for the given dev-tools config.
90
+ * Default OFF (only the object form's `judge` truthy enables it), mirroring
91
+ * {@link isShellToolEnabled}. A bare `shell: true` keeps the judge OFF — it costs an LLM call
92
+ * per command and must be opted into explicitly.
93
+ */
94
+ export function isShellJudgeEnabled(devTools) {
95
+ const shell = devTools?.shell;
96
+ if (!shell || typeof shell !== 'object')
97
+ return false;
98
+ const judge = shell.judge;
99
+ if (typeof judge === 'boolean')
100
+ return judge;
101
+ if (judge && typeof judge === 'object')
102
+ return judge.enabled === true;
103
+ return false;
104
+ }
105
+ /**
106
+ * Resolve the EXT-10 judge gate settings from a dev-tools config, applying safe defaults
107
+ * (auto-approve low, do NOT block high). `enabled` reflects {@link isShellJudgeEnabled}.
108
+ */
109
+ export function getShellJudgeSettings(devTools) {
110
+ const enabled = isShellJudgeEnabled(devTools);
111
+ const shell = devTools?.shell;
112
+ const judge = shell && typeof shell === 'object' && shell.judge && typeof shell.judge === 'object'
113
+ ? shell.judge
114
+ : undefined;
115
+ return {
116
+ enabled,
117
+ autoApproveLow: judge?.autoApproveLow ?? true,
118
+ blockHigh: judge?.blockHigh ?? false,
119
+ model: judge?.model,
120
+ };
121
+ }
122
+ /**
123
+ * Resolve the {@link GthDevToolsConfig} that applies to the active command, mirroring the
124
+ * per-command selection in `builtInToolsConfig.getDefaultTools` (which is what actually emits
125
+ * the dev tools) and `GthDeepAgent.getEffectiveDevToolsConfig`: `exec` → `commands.exec`,
126
+ * `ask --write` → `commands.ask`, `code` → `commands.code`; `undefined` elsewhere (the
127
+ * toolkit is inert there). Shared in core so the runner's allow-list gate stays in lockstep
128
+ * with where the shell tool is actually emitted.
129
+ */
130
+ export function getEffectiveDevToolsConfig(config, command) {
131
+ if (!config)
132
+ return undefined;
133
+ const askWrite = command === 'ask' && config.askWriteMode === true;
134
+ if (command === 'exec')
135
+ return config.commands?.exec?.devTools;
136
+ if (askWrite)
137
+ return config.commands?.ask?.devTools;
138
+ if (command === 'code')
139
+ return config.commands?.code?.devTools;
140
+ return undefined;
141
+ }
142
+ //# sourceMappingURL=shell-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-policy.js","sourceRoot":"","sources":["../../src/config/shell-policy.ts"],"names":[],"mappings":"AAkIA;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,OAAO,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAuC,EACvC,OAAgC;IAEhC,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,CAAC;IAC9B,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;IACtE,gFAAgF;IAChF,OAAO,OAAO,KAAK,MAAM,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAuC;IACvE,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,CAAC;IAC9B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5E,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,O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AI,EAAE,QAAQ,CAAC;IAC/D,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,453 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Gaunt Sloth configuration types. Extracted verbatim from the former `config.ts`
4
+ * god-file; the public type surface is unchanged. The shell/dev-tools policy types
5
+ * live in `./shell-policy.ts`; defaults in `./defaults.ts`; the loader in `./loader.ts`.
6
+ */
7
+ import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
8
+ import type { BaseToolkit, StructuredToolInterface } from '@langchain/core/tools';
9
+ import type { StatusLevel } from '#src/core/types.js';
10
+ import type { GthDevToolsConfig } from '#src/config/shell-policy.js';
11
+ /**
12
+ * Shared per-command tooling configuration (the knobs every actionable command carries).
13
+ * Reused across the per-command types in {@link GthConfig.commands} and by
14
+ * {@link PrCommandConfig}. Type-level dedupe only — no runtime/behaviour change.
15
+ *
16
+ * NOTE: `commands.api` intentionally does NOT use this shape (it only has
17
+ * `filesystem`/`builtInTools` plus `port`/`cors`), so it stays bespoke below.
18
+ */
19
+ export interface CommandToolingConfig {
20
+ filesystem?: string[] | 'all' | 'read' | 'none';
21
+ builtInTools?: string[];
22
+ customTools?: CustomToolsConfig | false;
23
+ /** See {@link GthConfig.allowedTools}. */
24
+ allowedTools?: string[];
25
+ binaryFormats?: false | BinaryFormatConfig[];
26
+ }
27
+ /**
28
+ * This is a processed Gaunt Sloth config ready to be passed down into components.
29
+ *
30
+ * Default values can be found in {@link DEFAULT_CONFIG}
31
+ */
32
+ export interface GthConfig {
33
+ llm: BaseChatModel;
34
+ /**
35
+ * Binary format support configuration.
36
+ * Disabled by default unless explicitly configured.
37
+ */
38
+ binaryFormats?: false | BinaryFormatConfig[];
39
+ /**
40
+ * Content source type. Source used to fetch content (usually diff) for `review` or `pr` command.
41
+ *
42
+ * {@link DEFAULT_CONFIG#contentSource}
43
+ */
44
+ contentSource: string;
45
+ /**
46
+ * Requirement source type. Source used to fetch requirements for `review` or `pr` command.
47
+ */
48
+ requirementSource: string;
49
+ /**
50
+ * Path to project-specific guidelines.
51
+ * The default is `.gsloth.guidelines.md`; this config may be used to point Gaunt Sloth to a different file,
52
+ * for example, to AGENTS.md
53
+ */
54
+ projectGuidelines: string;
55
+ /**
56
+ * Separate identity profile.
57
+ * May include separate identity, guidelines and command protocol,
58
+ * making gsloth behave as an agent different from default profile behaviour.
59
+ * for example, `devops` profile to detect changes such as properties and environment variables.
60
+ * Custom config can still win over this one.
61
+ * This setting requires .gsloth/.gsloth-settings directory to exist.
62
+ */
63
+ identityProfile?: string;
64
+ /**
65
+ * Whether to include the current date in the project review instructions or not.
66
+ */
67
+ includeCurrentDateAfterGuidelines: boolean;
68
+ /**
69
+ * Organisation name, locale and timezone.
70
+ * Only used with {@link includeCurrentDateAfterGuidelines}.
71
+ * timeZone and locale should be in format supported by Intl.DateTimeFormat
72
+ */
73
+ organization?: {
74
+ name?: string;
75
+ locale?: string;
76
+ timezone?: string;
77
+ };
78
+ projectReviewInstructions: string;
79
+ /**
80
+ * If true, only use user-provided system prompts. Do not fall back to the
81
+ * bundled `.gsloth.*.md` prompt files shipped with the installation.
82
+ * This applies to all `.gsloth.*.md` files (backstory, system, chat, code, guidelines, review).
83
+ */
84
+ noDefaultPrompts?: boolean;
85
+ filesystem: string[] | 'all' | 'read' | 'none';
86
+ builtInTools?: string[];
87
+ tools?: StructuredToolInterface[] | BaseToolkit[] | ServerTool[];
88
+ /**
89
+ * Restrict the agent to this allow-list of tool names, applied after every tool source
90
+ * (filesystem, built-in, custom, MCP, A2A, and `tools`) is resolved. This is the only knob
91
+ * that can gate MCP and A2A tools, which have no per-source override of their own.
92
+ *
93
+ * - omitted/undefined: no filtering, all resolved tools remain available.
94
+ * - non-empty array: keep only tools whose name is in the list.
95
+ * - empty array `[]`: disable every tool. MCP servers are not even contacted (no OAuth),
96
+ * which is useful for agents that only need to reason over the prompt (e.g. the review
97
+ * agent).
98
+ *
99
+ * Can be overridden per command via `commands.<command>.allowedTools`.
100
+ */
101
+ allowedTools?: string[];
102
+ /**
103
+ * Middleware configuration for LangChain v1.
104
+ * Middleware provides hooks to intercept and control agent execution at critical points.
105
+ *
106
+ * Middleware can be:
107
+ * - Predefined middleware (string or config object) - works in both JSON and JS configs
108
+ * - Custom middleware objects - only available in JS configs
109
+ *
110
+ * Example (JSON config):
111
+ * ```json
112
+ * {
113
+ * "middleware": [
114
+ * "summarization",
115
+ * { "name": "anthropic-prompt-caching", "ttl": "5m" }
116
+ * ]
117
+ * }
118
+ * ```
119
+ *
120
+ * Example (JS config):
121
+ * ```js
122
+ * {
123
+ * middleware: [
124
+ * "summarization",
125
+ * { beforeModel: (state) => { /* custom logic *\/ return state; } }
126
+ * ]
127
+ * }
128
+ * ```
129
+ *
130
+ * Available predefined middleware:
131
+ * - `anthropic-prompt-caching`: Reduces API costs by caching prompts (Anthropic only)
132
+ * - `summarization`: Condenses conversation history when approaching token limits
133
+ */
134
+ middleware?: unknown[];
135
+ /**
136
+ * Stream output. Some models do not support streaming. Set value to `false` for them.
137
+ *
138
+ * {@link DEFAULT_CONFIG#streamOutput}
139
+ */
140
+ streamOutput: boolean;
141
+ /**
142
+ * Should the output be written to md file.
143
+ * (e.g. gth_2025-07-26_22-59-06_REVIEW.md).
144
+ * Can be set to false with `-wn` or `-w0`
145
+ * Can be set to a specific filename or path by passing a string:
146
+ * - Bare filenames (e.g. `"review.md"`) are placed in `.gsloth/` when it exists, otherwise project root
147
+ * - Paths with separators (e.g. `"./review.md"` or `"reviews/last.md"`) are always relative to project root
148
+ * Please note the string does not accept absolute path, but allows to exit project with `..` if necessary.
149
+ */
150
+ writeOutputToFile: boolean | string;
151
+ /**
152
+ * Whether binary model outputs should be written to files instead of printed inline.
153
+ * When enabled, supported binary content blocks are materialized as `gth_*.<ext>` files.
154
+ */
155
+ writeBinaryOutputsToFile: boolean;
156
+ /**
157
+ * Use colour in output
158
+ */
159
+ useColour: boolean;
160
+ /**
161
+ * Stream session log instead of writing it when inference streaming is complete.
162
+ * (only works when {@link streamOutput} is true)
163
+ */
164
+ streamSessionInferenceLog: boolean;
165
+ /**
166
+ * Allow inference to be interrupted with esc. Only has an effect in TTY mode.
167
+ */
168
+ canInterruptInferenceWithEsc: boolean;
169
+ /**
170
+ * Log messages and events to gaunt-sloth.log,
171
+ * use llm.verbose or `gth --verbose` as more intrusive option, setting verbose to LangChain / LangGraph
172
+ */
173
+ debugLog?: boolean;
174
+ /**
175
+ * LangGraph recursion limit for an agent run — the maximum number of
176
+ * super-steps (model ↔ tool round-trips) before the graph throws. Defaults to
177
+ * 1000, which suits long coding chains; embodied / tight-loop consumers can
178
+ * lower it so a stuck run fails fast and visibly instead of grinding.
179
+ */
180
+ recursionLimit?: number;
181
+ /**
182
+ * Console logging level. Only messages at or above this level will be displayed.
183
+ * Valid values: 'debug', 'info', 'display', 'success', 'warning', 'error', 'stream'
184
+ * Default: 'info' (not debug)
185
+ */
186
+ consoleLevel?: StatusLevel;
187
+ customTools?: CustomToolsConfig;
188
+ requirementSourceConfig?: Record<string, unknown>;
189
+ contentSourceConfig?: Record<string, unknown>;
190
+ /**
191
+ * MCP (Model Context Protocol) server connections.
192
+ * Allows connecting to external MCP servers including those requiring OAuth.
193
+ * @see {@link https://modelcontextprotocol.io/}
194
+ */
195
+ mcpServers?: Record<string, unknown>;
196
+ /**
197
+ * A2A (Agent-to-Agent) protocol agents configuration.
198
+ * Enables delegation of tasks to external AI agents.
199
+ * Each agent becomes available as a tool named `a2a_agent_<agentId>`.
200
+ * @experimental This feature is experimental and may change.
201
+ * @see {@link https://a2a-protocol.org/}
202
+ */
203
+ a2aAgents?: Record<string, unknown>;
204
+ builtInToolsConfig?: BuiltInToolsConfig;
205
+ aiignore?: {
206
+ enabled?: boolean;
207
+ patterns?: string[];
208
+ };
209
+ commands?: {
210
+ pr?: PrCommandConfig;
211
+ review?: CommandToolingConfig & {
212
+ contentSource?: string;
213
+ requirementSource?: string;
214
+ rating?: RatingConfig;
215
+ };
216
+ ask?: CommandToolingConfig & {
217
+ /**
218
+ * Dev tools (run commands etc.) for `ask --write` runs. Normally inherited from
219
+ * `commands.exec` / `commands.code` by the `--write` flag rather than set directly.
220
+ */
221
+ devTools?: GthDevToolsConfig;
222
+ };
223
+ chat?: CommandToolingConfig;
224
+ code?: CommandToolingConfig & {
225
+ devTools?: GthDevToolsConfig;
226
+ };
227
+ /**
228
+ * `gth exec` — prompt-as-script runtime. Like `code`, an exec run may need to actually
229
+ * do the job (read/write files, run commands), so it carries the same tool/filesystem knobs.
230
+ */
231
+ exec?: CommandToolingConfig & {
232
+ devTools?: GthDevToolsConfig;
233
+ };
234
+ api?: {
235
+ filesystem?: string[] | 'all' | 'read' | 'none';
236
+ builtInTools?: string[];
237
+ port?: number;
238
+ cors?: {
239
+ allowOrigin?: string;
240
+ allowMethods?: string;
241
+ allowHeaders?: string;
242
+ };
243
+ };
244
+ };
245
+ modelDisplayName?: string;
246
+ /**
247
+ * Transient (runtime-only) extra filesystem roots the agent is allowed to read/write for
248
+ * THIS run, in addition to the cwd sandbox. Populated by `gth exec --allow-dir <path>`
249
+ * (repeatable); never persisted to a config file. When set, the deep agent's
250
+ * {@link FilesystemBackend} drops `virtualMode` (so absolute paths and `..` resolve on the
251
+ * real filesystem) and access is constrained to cwd + these dirs via permission allow-rules.
252
+ * Removing the cwd-only sandbox is a guardrail removal, so callers announce it loudly.
253
+ */
254
+ allowDirs?: string[];
255
+ /**
256
+ * Transient (runtime-only) flag set by `gth ask --write`: opt `ask` into the same
257
+ * "do-the-job" filesystem + dev tools that `exec`/`code` get, so a question can act
258
+ * (read/write files, run commands) rather than only chat. Never persisted to a config file.
259
+ */
260
+ askWriteMode?: boolean;
261
+ }
262
+ /**
263
+ * `gth pr` command configuration.
264
+ *
265
+ * Declared as a named interface (rather than inline in {@link GthConfig}) so that downstream
266
+ * packages can extend it with their own command features via TypeScript module augmentation
267
+ * (`declare module '@gaunt-sloth/core/config.js'`), keeping those features' types out of core.
268
+ * For example, the assistant package merges its PR discovery config (`discovery`) into this
269
+ * interface.
270
+ */
271
+ export interface PrCommandConfig extends CommandToolingConfig {
272
+ contentSource?: string;
273
+ requirementSource?: string;
274
+ logWorkForReviewInSeconds?: number;
275
+ rating?: RatingConfig;
276
+ }
277
+ /**
278
+ * Server tools such as Anthropic Web Search.
279
+ * These tools are meant to be magic objects like
280
+ * `{"type": "web_search_20250305", "name": "web_search", "max_uses": 10}`,
281
+ * AI Provider does the rest of the magic on their side.
282
+ */
283
+ export interface ServerTool extends Record<string, unknown> {
284
+ type: string;
285
+ name?: string;
286
+ }
287
+ /**
288
+ * Raw, unprocessed Gaunt Sloth config.
289
+ */
290
+ export type ConsoleLevelInput = StatusLevel | keyof typeof StatusLevel | Lowercase<keyof typeof StatusLevel>;
291
+ export interface RawGthConfig extends Omit<GthConfig, 'llm' | 'consoleLevel'> {
292
+ llm: LLMConfig;
293
+ consoleLevel?: ConsoleLevelInput;
294
+ }
295
+ export type BinaryFormatType = 'image' | 'file' | 'audio' | 'video' | 'binary';
296
+ export interface BinaryFormatConfig {
297
+ /**
298
+ * The type/category of binary format.
299
+ */
300
+ type: BinaryFormatType;
301
+ /**
302
+ * List of allowed extensions for this type (without leading dot).
303
+ */
304
+ extensions: string[];
305
+ /**
306
+ * Maximum file size in bytes. Defaults to 10MB when omitted.
307
+ */
308
+ maxSize?: number;
309
+ /**
310
+ * Optional MIME type overrides for extensions not in the default mapping.
311
+ */
312
+ mimeTypes?: Record<string, string>;
313
+ }
314
+ export type CustomToolsConfig = Record<string, CustomCommandConfig>;
315
+ export type BuiltInToolsConfig = Record<string, unknown>;
316
+ /**
317
+ * Configuration for review rating feature.
318
+ * Allows configuring automated review scoring with pass/fail thresholds.
319
+ */
320
+ export interface RatingConfig {
321
+ /**
322
+ * Enable or disable review rating.
323
+ * @default true
324
+ */
325
+ enabled?: boolean;
326
+ /**
327
+ * Minimum score (0-10) required to pass the review.
328
+ * @default 6
329
+ */
330
+ passThreshold?: number;
331
+ /**
332
+ * Highest allowed value on the rating scale.
333
+ * @default 10
334
+ */
335
+ maxRating?: number;
336
+ /**
337
+ * Lowest allowed value on the rating scale.
338
+ * @default 0
339
+ */
340
+ minRating?: number;
341
+ /**
342
+ * Exit with error code 1 when review fails (below threshold).
343
+ * When false, exits normally (code 0) regardless of rating.
344
+ * @default true
345
+ */
346
+ errorOnReviewFail?: boolean;
347
+ }
348
+ /**
349
+ * Validation checks that can be skipped for custom command parameters.
350
+ * Use with the `allow` property to bypass specific security checks.
351
+ *
352
+ * - `absolute-paths`: Allow absolute paths (e.g. `/dev/ttyUSB0`)
353
+ * - `directory-traversal`: Allow `..` in paths
354
+ * - `shell-injection`: Allow shell metacharacters (`|`, `&`, `;`, etc.)
355
+ * - `null-bytes`: Allow null bytes in values
356
+ */
357
+ export type ValidationCheck = 'absolute-paths' | 'directory-traversal' | 'shell-injection' | 'null-bytes';
358
+ /**
359
+ * Configuration for a custom command parameter.
360
+ * Parameters allow the model to provide dynamic values to commands.
361
+ */
362
+ export interface CustomCommandParameter {
363
+ /**
364
+ * Description of the parameter shown to the model.
365
+ */
366
+ description: string;
367
+ /**
368
+ * Optional list of validation checks to skip for this parameter's value.
369
+ * Use when this parameter legitimately requires values that would normally be blocked.
370
+ * For example, `["absolute-paths"]` allows values like `/dev/ttyUSB0` for this parameter.
371
+ *
372
+ * Available checks: `absolute-paths`, `directory-traversal`, `shell-injection`, `null-bytes`
373
+ */
374
+ allow?: ValidationCheck[];
375
+ }
376
+ /**
377
+ * Configuration for a custom command.
378
+ * Custom commands can be executed with or without parameters.
379
+ */
380
+ export interface CustomCommandConfig {
381
+ /**
382
+ * The shell command to execute.
383
+ * Can include placeholders like ${paramName} that will be replaced with parameter values.
384
+ * If no placeholder is present and parameters are provided, they are appended to the command.
385
+ */
386
+ command: string;
387
+ /**
388
+ * Description of what this command does, shown to the model.
389
+ */
390
+ description: string;
391
+ /**
392
+ * Optional parameters that the model can provide when calling this command.
393
+ * Each parameter has a name (the key) and a description.
394
+ * Parameters are validated for security (no shell injection, directory traversal, etc.).
395
+ */
396
+ parameters?: Record<string, CustomCommandParameter>;
397
+ /**
398
+ * Optional timeout in seconds.
399
+ * When set, the command will be killed if it exceeds this duration.
400
+ * When omitted, no timeout is applied.
401
+ */
402
+ timeout?: number;
403
+ }
404
+ export interface LLMConfig extends Record<string, unknown> {
405
+ type: string;
406
+ model: string;
407
+ configuration: Record<string, unknown>;
408
+ apiKeyEnvironmentVariable?: string;
409
+ }
410
+ export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq", "deepseek", "openai", "google-genai", "xai", "openrouter", "ollama"];
411
+ export type ConfigType = (typeof availableDefaultConfigs)[number];
412
+ export interface CommandLineConfigOverrides {
413
+ /**
414
+ * Custom config path
415
+ */
416
+ customConfigPath?: string;
417
+ /**
418
+ * Set LangChain/LangGraph to verbose mode,
419
+ * causing LangChain/LangGraph to log many details to the console.
420
+ * debugLog from config.ts may be a less intrusive option.
421
+ */
422
+ verbose?: boolean;
423
+ /**
424
+ * Should the output be written to md file.
425
+ * (e.g. gth_2025-07-26_22-59-06_REVIEW.md).
426
+ * Can be set to false with `-wn` or `-w0`
427
+ * Can be set to a specific filename or path by passing a string:
428
+ * - Bare filenames (e.g. `"review.md"`) are placed in `.gsloth/` when it exists, otherwise project root
429
+ * - Paths with separators (e.g. `"./review.md"` or `"reviews/last.md"`) are always relative to project root
430
+ * Please note the string does not accept absolute path, but allows to exit project with `..` if necessary.
431
+ */
432
+ writeOutputToFile?: boolean | string;
433
+ /**
434
+ * Separate identity profile.
435
+ * May include separate identity, guidelines and command protocol,
436
+ * making gsloth behave as an agent different from default profile behaviour.
437
+ * for example, `devops` profile to detect changes such as properties and environment variables.
438
+ * Custom config can still win over this one.
439
+ * This setting requires .gsloth/.gsloth-settings directory to exist.
440
+ * Important to note that the profile directory substitutes the entire config directory,
441
+ * in the case if some prompt files are missing - a file from the installation directory will be used.
442
+ */
443
+ identityProfile?: string;
444
+ /**
445
+ * Interactive TUI activation override for chat/code sessions.
446
+ * - `true` (`--tui`): force the Ink TUI on where the terminal supports it (also overrides
447
+ * the CI auto-off heuristic).
448
+ * - `false` (`--no-tui`): force the plain readline session.
449
+ * - `undefined` (default): auto-detect from the terminal.
450
+ * The decision itself lives in `gaunt-sloth`'s `shouldUseTui`; this only carries the flag.
451
+ */
452
+ tui?: boolean;
453
+ }
@@ -0,0 +1,12 @@
1
+ export const availableDefaultConfigs = [
2
+ 'vertexai',
3
+ 'anthropic',
4
+ 'groq',
5
+ 'deepseek',
6
+ 'openai',
7
+ 'google-genai',
8
+ 'xai',
9
+ 'openrouter',
10
+ 'ollama',
11
+ ];
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AA+aA,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,UAAU;IACV,WAAW;IACX,MAAM;IACN,UAAU;IACV,QAAQ;IACR,cAAc;IACd,KAAK;IACL,YAAY;IACZ,QAAQ;CACA,CAAC"}