@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
package/dist/config.js CHANGED
@@ -7,521 +7,20 @@
7
7
  * Refer to {@link DEFAULT_CONFIG} for default configuration.
8
8
  *
9
9
  * Some config params can be overriden from command line, see {@link CommandLineConfigOverrides}
10
- */
11
- import { PROJECT_GUIDELINES, PROJECT_REVIEW_INSTRUCTIONS, USER_PROJECT_CONFIG_JS, USER_PROJECT_CONFIG_JSON, USER_PROJECT_CONFIG_MJS, } from '#src/constants.js';
12
- import { StatusLevel } from '#src/core/types.js';
13
- import { displayDebug, displayError, displayInfo, displayWarning, setConsoleLevel, } from '#src/utils/consoleUtils.js';
14
- import { getGslothConfigReadPath, importExternalFile } from '#src/utils/fileUtils.js';
15
- import { getGlobalGslothConfigReadPath } from '#src/utils/globalConfigUtils.js';
16
- import { error, exit, isTTY, setUseColour } from '#src/utils/systemUtils.js';
17
- import { existsSync, readFileSync } from 'node:fs';
18
- export const availableDefaultConfigs = [
19
- 'vertexai',
20
- 'anthropic',
21
- 'groq',
22
- 'deepseek',
23
- 'openai',
24
- 'google-genai',
25
- 'xai',
26
- 'openrouter',
27
- 'ollama',
28
- ];
29
- /**
30
- * Default config
31
- */
32
- export const DEFAULT_CONFIG = {
33
- contentSource: 'file',
34
- requirementSource: 'file',
35
- contentProvider: 'file',
36
- requirementsProvider: 'file',
37
- /**
38
- * Path to project-specific guidelines.
39
- * The default is `.gsloth.guidelines.md`; this config may be used to point Gaunt Sloth to a different file,
40
- * for example, to AGENTS.md
41
- */
42
- projectGuidelines: PROJECT_GUIDELINES,
43
- /**
44
- * Whether to include the current date in the project review instructions or not.
45
- */
46
- includeCurrentDateAfterGuidelines: false,
47
- projectReviewInstructions: PROJECT_REVIEW_INSTRUCTIONS,
48
- filesystem: 'none',
49
- debugLog: false,
50
- consoleLevel: StatusLevel.INFO, // Default to INFO level, not debug
51
- /**
52
- * Default provider for both requirements and content is GitHub.
53
- * It needs GitHub CLI (gh).
54
- *
55
- * `github` content provider uses `gh pr diff NN` internally. {@link src/providers/ghPrDiffProvider.ts!}
56
- *
57
- *
58
- * `github` requirements provider `gh issue view NN` internally
59
- */
60
- commands: {
61
- pr: {
62
- contentSource: 'github',
63
- requirementSource: 'github',
64
- contentProvider: 'github',
65
- requirementsProvider: 'github',
66
- rating: {
67
- enabled: true,
68
- passThreshold: 6,
69
- minRating: 0,
70
- maxRating: 10,
71
- errorOnReviewFail: true,
72
- },
73
- },
74
- review: {
75
- rating: {
76
- enabled: true,
77
- passThreshold: 6,
78
- minRating: 0,
79
- maxRating: 10,
80
- errorOnReviewFail: true,
81
- },
82
- },
83
- ask: {
84
- filesystem: 'read',
85
- },
86
- chat: {
87
- filesystem: 'read',
88
- },
89
- code: {
90
- filesystem: 'all',
91
- },
92
- exec: {
93
- filesystem: 'all',
94
- },
95
- api: {
96
- filesystem: 'read',
97
- port: 3000,
98
- cors: {
99
- allowOrigin: 'http://localhost:3000',
100
- allowMethods: 'POST, GET, OPTIONS',
101
- allowHeaders: 'Content-Type, Accept',
102
- },
103
- },
104
- },
105
- streamOutput: true,
106
- writeOutputToFile: true,
107
- writeBinaryOutputsToFile: true,
108
- useColour: true,
109
- streamSessionInferenceLog: true,
110
- canInterruptInferenceWithEsc: true,
111
- aiignore: {
112
- enabled: true,
113
- patterns: undefined,
114
- },
115
- };
116
- /**
117
- * Needed DEFAULT_CONFIG to be plain const to be picked up by typedoc,
118
- * this cast here is just for typecheck.
119
- */
120
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
121
- DEFAULT_CONFIG;
122
- /**
123
- * Loads the global gsloth config (if present) from the global `~/.gsloth` folder.
124
- *
125
- * Precedence support: the returned raw config is intended to act as the BASE that the
126
- * project config (and CLI overrides) merge on top of, so any value here is the lowest
127
- * user-controlled layer (still above {@link DEFAULT_CONFIG}).
128
- *
129
- * Lookup order within the global folder, first match wins:
130
- * `.gsloth.config.json` -> `.gsloth.config.js` -> `.gsloth.config.mjs`
131
- *
132
- * Absence of every variant is a no-op: returns `undefined` so behaviour is unchanged.
133
- *
134
- * NOTE: secrets (API keys) may live in this file; this function must never log its
135
- * contents. Only non-sensitive diagnostics (the resolved path / parse failure) are emitted.
136
- *
137
- * @returns The raw global config object, or `undefined` when no global config exists.
138
- */
139
- export async function loadGlobalRawConfig() {
140
- // JSON first (the must-have format).
141
- const jsonPath = getGlobalGslothConfigReadPath(USER_PROJECT_CONFIG_JSON);
142
- if (existsSync(jsonPath)) {
143
- try {
144
- return JSON.parse(readFileSync(jsonPath, 'utf8'));
145
- }
146
- catch (e) {
147
- displayDebug(e instanceof Error ? e : String(e));
148
- displayWarning(`Failed to read global config from ${jsonPath}, ignoring it.`);
149
- return undefined;
150
- }
151
- }
152
- // Then JS / MJS variants (dynamic import of a `configure()` module).
153
- for (const filename of [USER_PROJECT_CONFIG_JS, USER_PROJECT_CONFIG_MJS]) {
154
- const modulePath = getGlobalGslothConfigReadPath(filename);
155
- if (existsSync(modulePath)) {
156
- try {
157
- const imported = await importExternalFile(modulePath);
158
- const configured = await imported.configure();
159
- return configured;
160
- }
161
- catch (e) {
162
- displayDebug(e instanceof Error ? e : String(e));
163
- displayWarning(`Failed to read global config from ${modulePath}, ignoring it.`);
164
- return undefined;
165
- }
166
- }
167
- }
168
- return undefined;
169
- }
170
- /**
171
- * Deep-merges a loaded global raw config UNDER the given project raw config, so the
172
- * project config wins on conflicting keys. When no global config exists this is a no-op
173
- * and the original project config is returned unchanged.
174
- */
175
- async function applyGlobalConfigBase(projectRawConfig) {
176
- const globalRawConfig = await loadGlobalRawConfig();
177
- if (!globalRawConfig) {
178
- return projectRawConfig;
179
- }
180
- return deepMerge(globalRawConfig, projectRawConfig);
181
- }
182
- /**
183
- * Returns true when a project-level config file (json/js/mjs) exists for the given
184
- * overrides. Honours `customConfigPath` and the active identity profile so the check
185
- * matches exactly what {@link initConfig} would attempt to load.
186
10
  *
187
- * This is the project half of CFG-10's "is any config present?" detection; the global
188
- * half is {@link loadGlobalRawConfig} (used by {@link hasAnyConfig}).
189
- */
190
- export function hasProjectConfig(commandLineConfigOverrides) {
191
- if (commandLineConfigOverrides.customConfigPath) {
192
- return existsSync(commandLineConfigOverrides.customConfigPath);
193
- }
194
- return [USER_PROJECT_CONFIG_JSON, USER_PROJECT_CONFIG_JS, USER_PROJECT_CONFIG_MJS].some((filename) => existsSync(getGslothConfigReadPath(filename, commandLineConfigOverrides.identityProfile)));
195
- }
196
- /**
197
- * CFG-10 — true when ANY usable configuration is present, either a project config file
198
- * (json/js/mjs) or a standalone global config (`~/.gsloth/.gsloth.config.*`). When this
199
- * returns false the caller should run the first-run dialog instead of erroring.
200
- *
201
- * Reuses CFG-8's project + global detection so the two paths can never disagree.
202
- */
203
- export async function hasAnyConfig(commandLineConfigOverrides) {
204
- if (hasProjectConfig(commandLineConfigOverrides)) {
205
- return true;
206
- }
207
- return (await loadGlobalRawConfig()) !== undefined;
208
- }
209
- /**
210
- * Initialize configuration by loading from available config files
211
- * @returns The loaded GthConfig
212
- */
213
- export async function initConfig(commandLineConfigOverrides) {
214
- if (commandLineConfigOverrides.customConfigPath &&
215
- !existsSync(commandLineConfigOverrides.customConfigPath)) {
216
- throw new Error(`Provided manual config "${commandLineConfigOverrides.customConfigPath}" does not exist`);
217
- }
218
- const jsonConfigPath = commandLineConfigOverrides.customConfigPath ??
219
- getGslothConfigReadPath(USER_PROJECT_CONFIG_JSON, commandLineConfigOverrides.identityProfile);
220
- // CFG-8 — when no project config file of any format exists, fall back to a standalone
221
- // global config (loaded alone) before erroring. Project config still takes precedence:
222
- // this branch only runs when there is no project file to apply the global config under.
223
- if (!hasProjectConfig(commandLineConfigOverrides)) {
224
- const globalRawConfig = await loadGlobalRawConfig();
225
- if (globalRawConfig) {
226
- if (globalRawConfig.llm &&
227
- typeof globalRawConfig.llm === 'object' &&
228
- 'type' in globalRawConfig.llm) {
229
- // Route the global config through the same path the project JSON uses.
230
- return await tryJsonConfig(globalRawConfig, commandLineConfigOverrides);
231
- }
232
- displayError('Global configuration found but it is not in valid format. Should at least define llm.type');
233
- exit(1);
234
- // Unreachable past exit(1) in production; keeps TS happy and prevents test exit.
235
- throw new Error('Unexpected error occurred.');
236
- }
237
- }
238
- // Try loading the JSON config file first
239
- if (jsonConfigPath.endsWith('.json') && existsSync(jsonConfigPath)) {
240
- try {
241
- // TODO makes sense to employ ZOD to validate config
242
- const projectJsonConfig = JSON.parse(readFileSync(jsonConfigPath, 'utf8'));
243
- // Apply global config as the base layer (project config wins on conflicts).
244
- const jsonConfig = (await applyGlobalConfigBase(projectJsonConfig));
245
- // If the config has an LLM with a type, create the appropriate LLM instance
246
- if (jsonConfig.llm && typeof jsonConfig.llm === 'object' && 'type' in jsonConfig.llm) {
247
- return await tryJsonConfig(jsonConfig, commandLineConfigOverrides);
248
- }
249
- else {
250
- error(`${jsonConfigPath} is not in valid format. Should at least define llm.type`);
251
- exit(1);
252
- // noinspection ExceptionCaughtLocallyJS
253
- // This throw is unreachable due to exit(1) above, but satisfies TS type analysis and prevents tests from exiting
254
- // noinspection ExceptionCaughtLocallyJS
255
- throw new Error('Unexpected error occurred.');
256
- }
257
- }
258
- catch (e) {
259
- displayDebug(e instanceof Error ? e : String(e));
260
- displayError(`Failed to read config from ${USER_PROJECT_CONFIG_JSON}, will try other formats.`);
261
- // Continue to try other formats
262
- return await tryJsConfig(commandLineConfigOverrides);
263
- }
264
- }
265
- else {
266
- // JSON config not found, try JS
267
- return tryJsConfig(commandLineConfigOverrides);
268
- }
269
- }
270
- // Helper function to try loading JS config
271
- async function tryJsConfig(commandLineConfigOverrides) {
272
- const jsConfigPath = commandLineConfigOverrides.customConfigPath ??
273
- getGslothConfigReadPath(USER_PROJECT_CONFIG_JS, commandLineConfigOverrides.identityProfile);
274
- if (jsConfigPath.endsWith('.js') && existsSync(jsConfigPath)) {
275
- try {
276
- const i = await importExternalFile(jsConfigPath);
277
- const customConfig = await i.configure();
278
- const mergedWithGlobal = await applyGlobalConfigBase(customConfig);
279
- return await mergeConfig(mergedWithGlobal, commandLineConfigOverrides);
280
- }
281
- catch (e) {
282
- displayDebug(e instanceof Error ? e : String(e));
283
- displayError(`Failed to read config from ${USER_PROJECT_CONFIG_JS}, will try other formats.`);
284
- // Continue to try other formats
285
- return await tryMjsConfig(commandLineConfigOverrides);
286
- }
287
- }
288
- else {
289
- // JS config not found, try MJS
290
- return await tryMjsConfig(commandLineConfigOverrides);
291
- }
292
- }
293
- // Helper function to try loading MJS config
294
- async function tryMjsConfig(commandLineConfigOverrides) {
295
- const mjsConfigPath = commandLineConfigOverrides.customConfigPath ??
296
- getGslothConfigReadPath(USER_PROJECT_CONFIG_MJS, commandLineConfigOverrides.identityProfile);
297
- if (mjsConfigPath.endsWith('.mjs') && existsSync(mjsConfigPath)) {
298
- try {
299
- const i = await importExternalFile(mjsConfigPath);
300
- const customConfig = await i.configure();
301
- const mergedWithGlobal = await applyGlobalConfigBase(customConfig);
302
- return await mergeConfig(mergedWithGlobal, commandLineConfigOverrides);
303
- }
304
- catch (e) {
305
- displayDebug(e instanceof Error ? e : String(e));
306
- displayError(`Failed to read config from ${USER_PROJECT_CONFIG_MJS}.`);
307
- displayError(`No valid configuration found. Please create a valid configuration file.`);
308
- exit(1);
309
- }
310
- }
311
- else {
312
- // No config files found
313
- displayError('No configuration file found. Please create one of: ' +
314
- `${USER_PROJECT_CONFIG_JSON}, ${USER_PROJECT_CONFIG_JS}, or ${USER_PROJECT_CONFIG_MJS} ` +
315
- 'in your project directory.');
316
- exit(1);
317
- }
318
- // This throw is unreachable due to exit(1) above, but satisfies TS type analysis and prevents tests from exiting
319
- throw new Error('Unexpected error occurred.');
320
- }
321
- /**
322
- * Process JSON LLM config by creating the appropriate LLM instance
323
- * @param jsonConfig - The parsed JSON config
324
- * @param commandLineConfigOverrides - command line config overrides
325
- * @returns Promise<GthConfig>
326
- */
327
- export async function tryJsonConfig(jsonConfig, commandLineConfigOverrides) {
328
- try {
329
- if (jsonConfig.llm && typeof jsonConfig.llm === 'object') {
330
- // Get the type of LLM (e.g. 'vertexai', 'anthropic') - this should exist
331
- const llmType = jsonConfig.llm.type;
332
- if (!llmType) {
333
- displayError('LLM type not specified in config.');
334
- exit(1);
335
- }
336
- // Get the configuration for the specific LLM type
337
- const llmConfig = jsonConfig.llm;
338
- if (commandLineConfigOverrides.verbose) {
339
- // Necessary to avoid https://github.com/langchain-ai/langchainjs/issues/8705
340
- llmConfig.verbose = commandLineConfigOverrides.verbose;
341
- }
342
- // Import the appropriate config module
343
- const configModule = await import(`#src/providers/${llmType}.js`);
344
- if (configModule.processJsonConfig) {
345
- const llm = (await configModule.processJsonConfig(llmConfig));
346
- const mergedConfig = mergeRawConfig(jsonConfig, llm, commandLineConfigOverrides);
347
- if (configModule.postProcessJsonConfig) {
348
- return await configModule.postProcessJsonConfig(mergedConfig);
349
- }
350
- else {
351
- return await mergedConfig;
352
- }
353
- }
354
- else {
355
- displayWarning(`Config module for ${llmType} does not have processJsonConfig function.`);
356
- exit(1);
357
- }
358
- }
359
- else {
360
- displayError('No LLM configuration found in config.');
361
- exit(1);
362
- }
363
- }
364
- catch (e) {
365
- if (e instanceof Error && e.message.includes('Cannot find module')) {
366
- displayError(`LLM type '${jsonConfig.llm.type}' not supported.`);
367
- }
368
- else {
369
- displayError(`Error processing LLM config: ${e instanceof Error ? e.message : String(e)}`);
370
- }
371
- exit(1);
372
- }
373
- // This throw is unreachable due to exit(1) above, but satisfies TS type analysis and prevents tests from exiting
374
- throw new Error('Unexpected error occurred.');
375
- }
376
- /**
377
- * Deep merge two objects, with source overriding target properties
378
- * @param target - The target object with default values
379
- * @param source - The source object with user overrides
380
- * @param maxDepth - Maximum recursion depth to prevent stack overflow (default: 4)
381
- */
382
- function deepMerge(target, source, maxDepth = 4) {
383
- if (!source)
384
- return target;
385
- if (!target)
386
- return source;
387
- const result = { ...target };
388
- // Return result without merging if depth is exceeded
389
- if (maxDepth === 0)
390
- return result;
391
- for (const key in source) {
392
- const sourceValue = source[key];
393
- const targetValue = target[key];
394
- if (sourceValue &&
395
- typeof sourceValue === 'object' &&
396
- !Array.isArray(sourceValue) &&
397
- targetValue &&
398
- typeof targetValue === 'object' &&
399
- !Array.isArray(targetValue)) {
400
- // Recursively merge nested objects
401
- result[key] = deepMerge(targetValue, sourceValue, maxDepth - 1);
402
- }
403
- else if (sourceValue !== undefined) {
404
- // Override with source value if it exists
405
- result[key] = sourceValue;
406
- }
407
- }
408
- return result;
409
- }
410
- /**
411
- * Merge config with default config
412
- */
413
- async function mergeConfig(partialConfig, commandLineConfigOverrides) {
414
- const config = partialConfig;
415
- // Migrate deprecated property names
416
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
417
- const raw = config;
418
- if (raw.contentProvider && !raw.contentSource) {
419
- displayWarning('Config property "contentProvider" is deprecated. Use "contentSource" instead.');
420
- config.contentSource = raw.contentProvider;
421
- }
422
- if (raw.requirementsProvider && !raw.requirementSource) {
423
- displayWarning('Config property "requirementsProvider" is deprecated. Use "requirementSource" instead.');
424
- config.requirementSource = raw.requirementsProvider;
425
- }
426
- // Keep both old and new in sync
427
- if (config.contentSource)
428
- config.contentProvider = config.contentSource;
429
- if (config.requirementSource)
430
- config.requirementsProvider = config.requirementSource;
431
- // Migrate command-level deprecated properties
432
- if (config.commands) {
433
- for (const cmdName of ['pr', 'review']) {
434
- const cmd = config.commands[cmdName];
435
- if (cmd) {
436
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
437
- const cmdRaw = cmd;
438
- if (cmdRaw.contentProvider && !cmdRaw.contentSource) {
439
- cmd.contentSource = cmdRaw.contentProvider;
440
- }
441
- if (cmdRaw.requirementsProvider && !cmdRaw.requirementSource) {
442
- cmd.requirementSource = cmdRaw.requirementsProvider;
443
- }
444
- if (cmd.contentSource)
445
- cmd.contentProvider = cmd.contentSource;
446
- if (cmd.requirementSource)
447
- cmd.requirementsProvider = cmd.requirementSource;
448
- }
449
- }
450
- }
451
- // Deep merge command configs while preserving defaults
452
- // Type complexity from DEFAULT_CONFIG.commands 'as const' requires any cast for deep merge result
453
- const mergedCommands = {
454
- pr: deepMerge(DEFAULT_CONFIG.commands.pr, config?.commands?.pr), // eslint-disable-line @typescript-eslint/no-explicit-any
455
- review: deepMerge(DEFAULT_CONFIG.commands.review, config?.commands?.review), // eslint-disable-line @typescript-eslint/no-explicit-any
456
- code: deepMerge(DEFAULT_CONFIG.commands.code, config?.commands?.code), // eslint-disable-line @typescript-eslint/no-explicit-any
457
- exec: deepMerge(DEFAULT_CONFIG.commands.exec, config?.commands?.exec), // eslint-disable-line @typescript-eslint/no-explicit-any
458
- ask: deepMerge(DEFAULT_CONFIG.commands.ask, config?.commands?.ask), // eslint-disable-line @typescript-eslint/no-explicit-any
459
- chat: deepMerge(DEFAULT_CONFIG.commands.chat, config?.commands?.chat), // eslint-disable-line @typescript-eslint/no-explicit-any
460
- api: deepMerge(DEFAULT_CONFIG.commands.api, config?.commands?.api), // eslint-disable-line @typescript-eslint/no-explicit-any
461
- };
462
- const mergedConfig = {
463
- ...DEFAULT_CONFIG,
464
- ...config,
465
- commands: mergedCommands,
466
- };
467
- if (commandLineConfigOverrides.identityProfile !== undefined) {
468
- displayInfo(`Activating profile: ${commandLineConfigOverrides.identityProfile}`);
469
- mergedConfig.identityProfile = commandLineConfigOverrides.identityProfile.trim();
470
- }
471
- if (commandLineConfigOverrides.verbose !== undefined) {
472
- mergedConfig.llm.verbose = commandLineConfigOverrides.verbose;
473
- }
474
- if (commandLineConfigOverrides.writeOutputToFile !== undefined) {
475
- mergedConfig.writeOutputToFile = commandLineConfigOverrides.writeOutputToFile;
476
- }
477
- // Set the useColour value in systemUtils
478
- setUseColour(mergedConfig.useColour);
479
- // Set console logging level
480
- if (mergedConfig.consoleLevel !== undefined) {
481
- const resolvedConsoleLevel = resolveConsoleLevel(mergedConfig.consoleLevel);
482
- if (resolvedConsoleLevel !== undefined) {
483
- mergedConfig.consoleLevel = resolvedConsoleLevel;
484
- setConsoleLevel(resolvedConsoleLevel);
485
- }
486
- else {
487
- displayWarning(`Invalid consoleLevel "${String(mergedConfig.consoleLevel)}", using default ${StatusLevel.INFO}.`);
488
- mergedConfig.consoleLevel = StatusLevel.INFO;
489
- setConsoleLevel(StatusLevel.INFO);
490
- }
491
- }
492
- mergedConfig.canInterruptInferenceWithEsc = mergedConfig.canInterruptInferenceWithEsc && isTTY();
493
- return mergedConfig;
494
- }
495
- const CONSOLE_LEVELS_BY_NAME = {
496
- debug: StatusLevel.DEBUG,
497
- info: StatusLevel.INFO,
498
- display: StatusLevel.DISPLAY,
499
- success: StatusLevel.SUCCESS,
500
- warning: StatusLevel.WARNING,
501
- error: StatusLevel.ERROR,
502
- stream: StatusLevel.STREAM,
503
- };
504
- function resolveConsoleLevel(level) {
505
- if (typeof level === 'number') {
506
- return StatusLevel[level] !== undefined ? level : undefined;
507
- }
508
- if (typeof level === 'string') {
509
- const normalized = level.trim().toLowerCase();
510
- if (normalized in CONSOLE_LEVELS_BY_NAME) {
511
- return CONSOLE_LEVELS_BY_NAME[normalized];
512
- }
513
- const enumValue = StatusLevel[level];
514
- if (typeof enumValue === 'number') {
515
- return enumValue;
516
- }
517
- }
518
- return undefined;
519
- }
520
- /**
521
- * Merge raw with default config
522
- */
523
- async function mergeRawConfig(config, llm, commandLineConfigOverrides) {
524
- const modelDisplayName = config.llm?.model;
525
- return await mergeConfig({ ...config, llm, modelDisplayName }, commandLineConfigOverrides);
526
- }
11
+ * This module is the **public barrel** for the configuration system. The implementation
12
+ * is split into focused modules under `config/`:
13
+ * - `config/types.ts` — the configuration type surface.
14
+ * - `config/shell-policy.ts` — {@link GthDevToolsConfig} + the shell/dev-tools resolvers.
15
+ * - `config/defaults.ts` {@link DEFAULT_CONFIG}.
16
+ * - `config/loader.ts` — discovery + the layered load/merge pipeline.
17
+ * - `config/schema.ts` — the Zod schema (single source of truth) + JSON-Schema generator.
18
+ *
19
+ * Every name that was previously exported from `config.ts` is re-exported here, so the
20
+ * public import path `@gaunt-sloth/core/config.js` (and `#src/config.js`) is unchanged.
21
+ */
22
+ export * from '#src/config/types.js';
23
+ export * from '#src/config/shell-policy.js';
24
+ export * from '#src/config/defaults.js';
25
+ export * from '#src/config/loader.js';
527
26
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,cAAc,EACd,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG7E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAgfnD,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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C;QAC9C,IAAI,UAAU,IAAI,sBAAsB,EAAE,CAAC;YACzC,OAAO,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,SAAS,GAAG,WAAW,CAAC,KAAiC,CAAC,CAAC;QACjE,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAClC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,cAAc,CAC3B,MAAoB,EACpB,GAAkB,EAClB,0BAAsD;IAEtD,MAAM,gBAAgB,GAAuB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC;IAC/D,OAAO,MAAM,WAAW,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,EAAE,0BAA0B,CAAC,CAAC;AAC7F,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
@@ -4,6 +4,7 @@ export declare const GSLOTH_AUTH = ".gsloth-auth";
4
4
  export declare const USER_PROJECT_CONFIG_JS = ".gsloth.config.js";
5
5
  export declare const USER_PROJECT_CONFIG_JSON = ".gsloth.config.json";
6
6
  export declare const USER_PROJECT_CONFIG_MJS = ".gsloth.config.mjs";
7
+ export declare const USER_PROJECT_CONFIG_TS = ".gsloth.config.ts";
7
8
  export declare const GSLOTH_BACKSTORY = ".gsloth.backstory.md";
8
9
  export declare const PROJECT_GUIDELINES = ".gsloth.guidelines.md";
9
10
  export declare const PROJECT_REVIEW_INSTRUCTIONS = ".gsloth.review.md";
@@ -12,3 +13,8 @@ export declare const GSLOTH_CHAT_PROMPT = ".gsloth.chat.md";
12
13
  export declare const GSLOTH_CODE_PROMPT = ".gsloth.code.md";
13
14
  export declare const GSLOTH_EXEC_PROMPT = ".gsloth.exec.md";
14
15
  export declare const AIIGNORE_FILE = ".aiignore";
16
+ /**
17
+ * EXT-9 Tier-2: project-scoped persisted shell allow-list (`always` approvals).
18
+ * Lives under `.gsloth/.gsloth-settings/` like other project settings.
19
+ */
20
+ export declare const SHELL_ALLOWLIST_FILE = "shell-allowlist.json";
package/dist/constants.js CHANGED
@@ -4,6 +4,7 @@ export const GSLOTH_AUTH = '.gsloth-auth';
4
4
  export const USER_PROJECT_CONFIG_JS = '.gsloth.config.js';
5
5
  export const USER_PROJECT_CONFIG_JSON = '.gsloth.config.json';
6
6
  export const USER_PROJECT_CONFIG_MJS = '.gsloth.config.mjs';
7
+ export const USER_PROJECT_CONFIG_TS = '.gsloth.config.ts';
7
8
  export const GSLOTH_BACKSTORY = '.gsloth.backstory.md';
8
9
  export const PROJECT_GUIDELINES = '.gsloth.guidelines.md';
9
10
  export const PROJECT_REVIEW_INSTRUCTIONS = '.gsloth.review.md';
@@ -12,4 +13,9 @@ export const GSLOTH_CHAT_PROMPT = '.gsloth.chat.md';
12
13
  export const GSLOTH_CODE_PROMPT = '.gsloth.code.md';
13
14
  export const GSLOTH_EXEC_PROMPT = '.gsloth.exec.md';
14
15
  export const AIIGNORE_FILE = '.aiignore';
16
+ /**
17
+ * EXT-9 Tier-2: project-scoped persisted shell allow-list (`always` approvals).
18
+ * Lives under `.gsloth/.gsloth-settings/` like other project settings.
19
+ */
20
+ export const SHELL_ALLOWLIST_FILE = 'shell-allowlist.json';
15
21
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAC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D,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AACpD,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AACzC;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { GthConfig, ServerTool } from '#src/config.js';
2
- import { AgentResolvers, AgentStreamEvent, GthAgentInterface, GthCommand, GthCompiledGraph, Message, StatusUpdateCallback } from '#src/core/types.js';
2
+ import { AgentResolvers, AgentStreamEvent, GthAgentInterface, GthCommand, GthCompiledGraph, Message, PendingToolInterrupt, StatusUpdateCallback } from '#src/core/types.js';
3
3
  import { BaseMessage } from '@langchain/core/messages';
4
4
  import { RunnableConfig } from '@langchain/core/runnables';
5
5
  import { BaseToolkit, StructuredToolInterface } from '@langchain/core/tools';
@@ -42,6 +42,19 @@ export declare abstract class GthAbstractAgent implements GthAgentInterface {
42
42
  * When stream is not appropriate use {@link invoke}.
43
43
  */
44
44
  stream(messages: Message[], runConfig: RunnableConfig): Promise<IterableReadableStream<string>>;
45
+ /**
46
+ * Resume a graph suspended on a human-in-the-loop `interrupt()` and stream the continuation
47
+ * as text. Identical plumbing to {@link stream} (Esc-to-interrupt, binary handling), except
48
+ * the graph input is a `Command({ resume })` instead of fresh `messages` — so the suspended
49
+ * tool-approval interrupt is answered and the run continues on the same thread.
50
+ */
51
+ streamResume(resumeValue: unknown, runConfig: RunnableConfig): Promise<IterableReadableStream<string>>;
52
+ /**
53
+ * Shared body for {@link stream} / {@link streamResume}: drive the compiled graph from
54
+ * `input` (fresh `{ messages }` or a resume `Command`) and surface AI text deltas as a
55
+ * string stream, with Esc-to-interrupt and binary-output materialization.
56
+ */
57
+ private streamFromInput;
45
58
  /**
46
59
  * Stream agent events as typed AgentStreamEvent objects.
47
60
  * Yields text deltas, tool call lifecycle events, and tool results.
@@ -61,6 +74,16 @@ export declare abstract class GthAbstractAgent implements GthAgentInterface {
61
74
  * the client sends in `forwardedProps.command.resume`.
62
75
  */
63
76
  streamWithEventsResume(resumeValue: unknown, runConfig: RunnableConfig, queuedMessages?: BaseMessage[], signal?: AbortSignal): AsyncGenerator<AgentStreamEvent>;
77
+ /**
78
+ * Inspect the checkpointed state for the thread and return the tool calls currently pending
79
+ * human approval (empty array when the run finished normally). A LangGraph
80
+ * `humanInTheLoopMiddleware` interrupt parks one `HITLRequest` per suspended super-step in
81
+ * `state.tasks[].interrupts[].value.actionRequests` (each `{ name, args }`); this flattens
82
+ * those into {@link PendingToolInterrupt}s. Defensive throughout — a graph without
83
+ * `getState`, or any unexpected shape, yields `[]` rather than throwing, so a missing HITL
84
+ * setup degrades to "no approval needed" instead of breaking the run.
85
+ */
86
+ getPendingToolInterrupts(runConfig: RunnableConfig): Promise<PendingToolInterrupt[]>;
64
87
  protected processEventStream(stream: IterableReadableStream<[BaseMessage, Record<string, unknown>]>): AsyncGenerator<AgentStreamEvent>;
65
88
  cleanup(): Promise<void>;
66
89
  getEffectiveConfig(config: GthConfig, command: GthCommand | undefined): GthConfig;