@gaunt-sloth/core 2.0.0-alpha.3 → 2.0.0-alpha.30

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 (271) hide show
  1. package/README.md +52 -20
  2. package/dist/config/colour.d.ts +38 -0
  3. package/dist/config/colour.js +36 -0
  4. package/dist/config/colour.js.map +1 -0
  5. package/dist/config/defaults.d.ts +84 -0
  6. package/dist/config/defaults.js +99 -0
  7. package/dist/config/defaults.js.map +1 -0
  8. package/dist/config/filesystem-tools.d.ts +41 -0
  9. package/dist/config/filesystem-tools.js +56 -0
  10. package/dist/config/filesystem-tools.js.map +1 -0
  11. package/dist/config/jsonc.d.ts +12 -0
  12. package/dist/config/jsonc.js +41 -0
  13. package/dist/config/jsonc.js.map +1 -0
  14. package/dist/config/loader.d.ts +246 -0
  15. package/dist/config/loader.js +1321 -0
  16. package/dist/config/loader.js.map +1 -0
  17. package/dist/config/mouse.d.ts +50 -0
  18. package/dist/config/mouse.js +44 -0
  19. package/dist/config/mouse.js.map +1 -0
  20. package/dist/config/profiles.d.ts +68 -0
  21. package/dist/config/profiles.js +93 -0
  22. package/dist/config/profiles.js.map +1 -0
  23. package/dist/config/providerKeys.d.ts +69 -0
  24. package/dist/config/providerKeys.js +69 -0
  25. package/dist/config/providerKeys.js.map +1 -0
  26. package/dist/config/schema.d.ts +2999 -0
  27. package/dist/config/schema.js +1519 -0
  28. package/dist/config/schema.js.map +1 -0
  29. package/dist/config/shell-policy.d.ts +896 -0
  30. package/dist/config/shell-policy.js +750 -0
  31. package/dist/config/shell-policy.js.map +1 -0
  32. package/dist/config/tool-descriptions.d.ts +211 -0
  33. package/dist/config/tool-descriptions.js +272 -0
  34. package/dist/config/tool-descriptions.js.map +1 -0
  35. package/dist/config/types.d.ts +760 -0
  36. package/dist/config/types.js +13 -0
  37. package/dist/config/types.js.map +1 -0
  38. package/dist/config.d.ts +34 -827
  39. package/dist/config.js +25 -657
  40. package/dist/config.js.map +1 -1
  41. package/dist/constants.d.ts +46 -0
  42. package/dist/constants.js +46 -0
  43. package/dist/constants.js.map +1 -1
  44. package/dist/core/GthAbstractAgent.d.ts +135 -2
  45. package/dist/core/GthAbstractAgent.js +496 -30
  46. package/dist/core/GthAbstractAgent.js.map +1 -1
  47. package/dist/core/GthAgentRunner.d.ts +568 -54
  48. package/dist/core/GthAgentRunner.js +1537 -136
  49. package/dist/core/GthAgentRunner.js.map +1 -1
  50. package/dist/core/GthLangChainAgent.d.ts +115 -0
  51. package/dist/core/GthLangChainAgent.js +644 -17
  52. package/dist/core/GthLangChainAgent.js.map +1 -1
  53. package/dist/core/approvals/annotations.d.ts +122 -0
  54. package/dist/core/approvals/annotations.js +137 -0
  55. package/dist/core/approvals/annotations.js.map +1 -0
  56. package/dist/core/approvals/grants.d.ts +216 -0
  57. package/dist/core/approvals/grants.js +469 -0
  58. package/dist/core/approvals/grants.js.map +1 -0
  59. package/dist/core/approvals/matcher.d.ts +202 -0
  60. package/dist/core/approvals/matcher.js +267 -0
  61. package/dist/core/approvals/matcher.js.map +1 -0
  62. package/dist/core/approvals/mcpSubjects.d.ts +40 -0
  63. package/dist/core/approvals/mcpSubjects.js +99 -0
  64. package/dist/core/approvals/mcpSubjects.js.map +1 -0
  65. package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
  66. package/dist/core/approvals/toolAnnotationSources.js +277 -0
  67. package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
  68. package/dist/core/approvals/toolHost.d.ts +46 -0
  69. package/dist/core/approvals/toolHost.js +108 -0
  70. package/dist/core/approvals/toolHost.js.map +1 -0
  71. package/dist/core/debugCapture.d.ts +75 -0
  72. package/dist/core/debugCapture.js +101 -0
  73. package/dist/core/debugCapture.js.map +1 -0
  74. package/dist/core/gthLeanAgentFactory.d.ts +9 -0
  75. package/dist/core/gthLeanAgentFactory.js +10 -0
  76. package/dist/core/gthLeanAgentFactory.js.map +1 -0
  77. package/dist/core/launchBanner.d.ts +120 -0
  78. package/dist/core/launchBanner.js +418 -0
  79. package/dist/core/launchBanner.js.map +1 -0
  80. package/dist/core/plainToolIndication.d.ts +15 -0
  81. package/dist/core/plainToolIndication.js +174 -0
  82. package/dist/core/plainToolIndication.js.map +1 -0
  83. package/dist/core/reasoningBlocks.d.ts +60 -0
  84. package/dist/core/reasoningBlocks.js +98 -0
  85. package/dist/core/reasoningBlocks.js.map +1 -0
  86. package/dist/core/refusal.d.ts +53 -0
  87. package/dist/core/refusal.js +133 -0
  88. package/dist/core/refusal.js.map +1 -0
  89. package/dist/core/runStats.d.ts +52 -0
  90. package/dist/core/runStats.js +118 -0
  91. package/dist/core/runStats.js.map +1 -0
  92. package/dist/core/shell/ShellCommandFailedError.d.ts +54 -0
  93. package/dist/core/shell/ShellCommandFailedError.js +68 -0
  94. package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
  95. package/dist/core/shell/abstention.d.ts +88 -0
  96. package/dist/core/shell/abstention.js +184 -0
  97. package/dist/core/shell/abstention.js.map +1 -0
  98. package/dist/core/shell/approvalCapture.d.ts +271 -0
  99. package/dist/core/shell/approvalCapture.js +108 -0
  100. package/dist/core/shell/approvalCapture.js.map +1 -0
  101. package/dist/core/shell/approvalStop.d.ts +84 -0
  102. package/dist/core/shell/approvalStop.js +119 -0
  103. package/dist/core/shell/approvalStop.js.map +1 -0
  104. package/dist/core/shell/arity.d.ts +6 -0
  105. package/dist/core/shell/arity.js +20 -6
  106. package/dist/core/shell/arity.js.map +1 -1
  107. package/dist/core/shell/denylist.d.ts +11 -0
  108. package/dist/core/shell/denylist.js +37 -0
  109. package/dist/core/shell/denylist.js.map +1 -0
  110. package/dist/core/shell/escalationSeverity.d.ts +141 -0
  111. package/dist/core/shell/escalationSeverity.js +89 -0
  112. package/dist/core/shell/escalationSeverity.js.map +1 -0
  113. package/dist/core/shell/framing.d.ts +190 -0
  114. package/dist/core/shell/framing.js +633 -0
  115. package/dist/core/shell/framing.js.map +1 -0
  116. package/dist/core/shell/hardline.d.ts +81 -0
  117. package/dist/core/shell/hardline.js +607 -0
  118. package/dist/core/shell/hardline.js.map +1 -0
  119. package/dist/core/shell/negotiation.d.ts +249 -0
  120. package/dist/core/shell/negotiation.js +355 -0
  121. package/dist/core/shell/negotiation.js.map +1 -0
  122. package/dist/core/shell/normalize.d.ts +44 -4
  123. package/dist/core/shell/normalize.js +61 -7
  124. package/dist/core/shell/normalize.js.map +1 -1
  125. package/dist/core/shell/openWorld.d.ts +263 -0
  126. package/dist/core/shell/openWorld.js +1188 -0
  127. package/dist/core/shell/openWorld.js.map +1 -0
  128. package/dist/core/shell/rater.d.ts +935 -0
  129. package/dist/core/shell/rater.js +1473 -0
  130. package/dist/core/shell/rater.js.map +1 -0
  131. package/dist/core/shell/raterModel.d.ts +41 -0
  132. package/dist/core/shell/raterModel.js +51 -0
  133. package/dist/core/shell/raterModel.js.map +1 -0
  134. package/dist/core/shell/rejection.d.ts +69 -0
  135. package/dist/core/shell/rejection.js +38 -0
  136. package/dist/core/shell/rejection.js.map +1 -0
  137. package/dist/core/toolCallRepair/grammar.d.ts +41 -0
  138. package/dist/core/toolCallRepair/grammar.js +116 -0
  139. package/dist/core/toolCallRepair/grammar.js.map +1 -0
  140. package/dist/core/toolCallRepair/index.d.ts +2 -0
  141. package/dist/core/toolCallRepair/index.js +7 -0
  142. package/dist/core/toolCallRepair/index.js.map +1 -0
  143. package/dist/core/toolCallRepair/payload.d.ts +36 -0
  144. package/dist/core/toolCallRepair/payload.js +341 -0
  145. package/dist/core/toolCallRepair/payload.js.map +1 -0
  146. package/dist/core/toolCallRepair/promote.d.ts +45 -0
  147. package/dist/core/toolCallRepair/promote.js +90 -0
  148. package/dist/core/toolCallRepair/promote.js.map +1 -0
  149. package/dist/core/toolDisplay.d.ts +123 -0
  150. package/dist/core/toolDisplay.js +451 -0
  151. package/dist/core/toolDisplay.js.map +1 -0
  152. package/dist/core/toolOutputChannel.d.ts +95 -0
  153. package/dist/core/toolOutputChannel.js +165 -0
  154. package/dist/core/toolOutputChannel.js.map +1 -0
  155. package/dist/core/types.d.ts +294 -12
  156. package/dist/core/types.js.map +1 -1
  157. package/dist/history/historyFormat.d.ts +28 -0
  158. package/dist/history/historyFormat.js +127 -0
  159. package/dist/history/historyFormat.js.map +1 -0
  160. package/dist/history/historyStore.d.ts +198 -0
  161. package/dist/history/historyStore.js +482 -0
  162. package/dist/history/historyStore.js.map +1 -0
  163. package/dist/history/recordSession.d.ts +37 -0
  164. package/dist/history/recordSession.js +56 -0
  165. package/dist/history/recordSession.js.map +1 -0
  166. package/dist/index.d.ts +4 -0
  167. package/dist/index.js +4 -0
  168. package/dist/index.js.map +1 -1
  169. package/dist/providers/anthropic.d.ts +1 -1
  170. package/dist/providers/anthropic.js +5 -10
  171. package/dist/providers/anthropic.js.map +1 -1
  172. package/dist/providers/deepseek.d.ts +1 -1
  173. package/dist/providers/deepseek.js +5 -10
  174. package/dist/providers/deepseek.js.map +1 -1
  175. package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
  176. package/dist/providers/geminiSchemaSanitizer.js +347 -0
  177. package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
  178. package/dist/providers/geminiThinking.d.ts +52 -0
  179. package/dist/providers/geminiThinking.js +72 -0
  180. package/dist/providers/geminiThinking.js.map +1 -0
  181. package/dist/providers/google-genai.d.ts +1 -1
  182. package/dist/providers/google-genai.js +12 -11
  183. package/dist/providers/google-genai.js.map +1 -1
  184. package/dist/providers/groq.d.ts +1 -1
  185. package/dist/providers/groq.js +5 -10
  186. package/dist/providers/groq.js.map +1 -1
  187. package/dist/providers/huggingface.d.ts +25 -0
  188. package/dist/providers/huggingface.js +69 -0
  189. package/dist/providers/huggingface.js.map +1 -0
  190. package/dist/providers/modelCatalog.d.ts +109 -0
  191. package/dist/providers/modelCatalog.js +245 -0
  192. package/dist/providers/modelCatalog.js.map +1 -0
  193. package/dist/providers/modelDiscovery.d.ts +153 -6
  194. package/dist/providers/modelDiscovery.js +295 -41
  195. package/dist/providers/modelDiscovery.js.map +1 -1
  196. package/dist/providers/ollama.d.ts +19 -5
  197. package/dist/providers/ollama.js +60 -52
  198. package/dist/providers/ollama.js.map +1 -1
  199. package/dist/providers/openai.d.ts +1 -1
  200. package/dist/providers/openai.js +39 -10
  201. package/dist/providers/openai.js.map +1 -1
  202. package/dist/providers/openrouter.d.ts +4 -5
  203. package/dist/providers/openrouter.js +20 -35
  204. package/dist/providers/openrouter.js.map +1 -1
  205. package/dist/providers/vertexai.d.ts +1 -1
  206. package/dist/providers/vertexai.js +12 -11
  207. package/dist/providers/vertexai.js.map +1 -1
  208. package/dist/providers/xai.d.ts +1 -1
  209. package/dist/providers/xai.js +5 -10
  210. package/dist/providers/xai.js.map +1 -1
  211. package/dist/runtime/askStructured.d.ts +105 -0
  212. package/dist/runtime/askStructured.js +120 -0
  213. package/dist/runtime/askStructured.js.map +1 -0
  214. package/dist/runtime/conversation.d.ts +60 -0
  215. package/dist/runtime/conversation.js +151 -0
  216. package/dist/runtime/conversation.js.map +1 -0
  217. package/dist/runtime/singleShot.d.ts +25 -5
  218. package/dist/runtime/singleShot.js +95 -36
  219. package/dist/runtime/singleShot.js.map +1 -1
  220. package/dist/runtime/structuredOutput.d.ts +104 -0
  221. package/dist/runtime/structuredOutput.js +393 -0
  222. package/dist/runtime/structuredOutput.js.map +1 -0
  223. package/dist/utils/ProgressIndicator.d.ts +21 -0
  224. package/dist/utils/ProgressIndicator.js +30 -3
  225. package/dist/utils/ProgressIndicator.js.map +1 -1
  226. package/dist/utils/aiignoreUtils.js.map +1 -1
  227. package/dist/utils/binaryOutputUtils.js.map +1 -1
  228. package/dist/utils/consoleUtils.d.ts +52 -0
  229. package/dist/utils/consoleUtils.js +72 -2
  230. package/dist/utils/consoleUtils.js.map +1 -1
  231. package/dist/utils/crashHandler.d.ts +87 -0
  232. package/dist/utils/crashHandler.js +128 -0
  233. package/dist/utils/crashHandler.js.map +1 -0
  234. package/dist/utils/debugDump.d.ts +134 -0
  235. package/dist/utils/debugDump.js +381 -0
  236. package/dist/utils/debugDump.js.map +1 -0
  237. package/dist/utils/debugUtils.d.ts +13 -4
  238. package/dist/utils/debugUtils.js +36 -13
  239. package/dist/utils/debugUtils.js.map +1 -1
  240. package/dist/utils/displayWidth.d.ts +53 -0
  241. package/dist/utils/displayWidth.js +195 -0
  242. package/dist/utils/displayWidth.js.map +1 -0
  243. package/dist/utils/fileUtils.d.ts +24 -2
  244. package/dist/utils/fileUtils.js +54 -12
  245. package/dist/utils/fileUtils.js.map +1 -1
  246. package/dist/utils/llmUtils.d.ts +39 -8
  247. package/dist/utils/llmUtils.js +76 -8
  248. package/dist/utils/llmUtils.js.map +1 -1
  249. package/dist/utils/redactSecrets.d.ts +63 -0
  250. package/dist/utils/redactSecrets.js +286 -0
  251. package/dist/utils/redactSecrets.js.map +1 -0
  252. package/dist/utils/systemPromptNotes.d.ts +225 -0
  253. package/dist/utils/systemPromptNotes.js +340 -0
  254. package/dist/utils/systemPromptNotes.js.map +1 -0
  255. package/dist/utils/systemUtils.d.ts +49 -1
  256. package/dist/utils/systemUtils.js +67 -3
  257. package/dist/utils/systemUtils.js.map +1 -1
  258. package/dist/utils/toolMatching.d.ts +30 -0
  259. package/dist/utils/toolMatching.js +44 -0
  260. package/dist/utils/toolMatching.js.map +1 -0
  261. package/dist/utils/untrustedText.d.ts +66 -0
  262. package/dist/utils/untrustedText.js +80 -0
  263. package/dist/utils/untrustedText.js.map +1 -0
  264. package/package.json +22 -6
  265. package/schema/gsloth-config.schema.json +3134 -0
  266. package/dist/core/shell/allowlist.d.ts +0 -75
  267. package/dist/core/shell/allowlist.js +0 -187
  268. package/dist/core/shell/allowlist.js.map +0 -1
  269. package/dist/core/shell/judge.d.ts +0 -161
  270. package/dist/core/shell/judge.js +0 -261
  271. package/dist/core/shell/judge.js.map +0 -1
@@ -0,0 +1,246 @@
1
+ import { type RawConfigValidationResult } from '#src/config/schema.js';
2
+ import type { CommandLineConfigOverrides, ConsoleLevelInput, GthConfig, RawGthConfig } from '#src/config/types.js';
3
+ /**
4
+ * Find THE project config by walking up from cwd toward a stop boundary, returning the FIRST
5
+ * match (first-match-win: nearest dir, then format precedence within that dir — NOT a merged
6
+ * stack). Detection ({@link hasProjectConfig}/{@link hasAnyConfig}) and loading ({@link initConfig})
7
+ * both go through this, so they can never disagree.
8
+ *
9
+ * Stop boundary — the dir is SEARCHED, then ascent stops at: a dir containing `.git` (the git
10
+ * root), the user's home dir, or the filesystem root — whichever comes first. So a config IN the
11
+ * git root (or home) is found; a config ABOVE it is not.
12
+ *
13
+ * A `customConfigPath` override wins outright (no walking).
14
+ *
15
+ * NOTE (identity profile): with an `identityProfile` set, each dir's per-format resolver
16
+ * ({@link resolveConfigPath}) tries the profile path `.gsloth/.gsloth-settings/<profile>/<file>`
17
+ * but FALLS BACK to the plain `<dir>/<file>` when the profile file is absent. So a match here does
18
+ * NOT prove the named profile itself has a config — it may be a plain (non-profile) config. Use
19
+ * {@link resolveIdentityProfileConfigPath} when you need to know a profile specifically resolved.
20
+ *
21
+ * @returns the matched `{ dir, path }`, or `undefined` when no project config exists within the
22
+ * boundary.
23
+ */
24
+ export declare function findProjectConfigPath(commandLineConfigOverrides: CommandLineConfigOverrides): {
25
+ dir: string;
26
+ path: string;
27
+ } | undefined;
28
+ /**
29
+ * STRICT existence check for an EXPLICITLY-named identity profile: does
30
+ * `.gsloth/.gsloth-settings/<identityProfile>/<config>` resolve to a real config file anywhere in
31
+ * the same up-tree search {@link findProjectConfigPath} walks? Returns the resolved profile config
32
+ * path (nearest dir, then format precedence) when the profile has its OWN config, `undefined`
33
+ * otherwise.
34
+ *
35
+ * Unlike {@link findProjectConfigPath}, it matches ONLY the profile-specific path — it NEVER falls
36
+ * through to a plain `<dir>/<config>` and NEVER falls back to the global config. That strictness is
37
+ * the whole point: it lets a caller distinguish "this named profile really exists" from "a bare
38
+ * config happens to be present / a global config exists," a distinction the loader's fall-through
39
+ * deliberately blurs.
40
+ *
41
+ * PURE PREDICATE — never throws, never calls `exit` (contrast the loader's interactive-CLI
42
+ * `exit(1)` safety net in {@link initConfig}). So batch/eval code (e.g. `gth eval --judge <profile>`
43
+ * and BATCH-12's identity matrix) can pre-check an explicitly-requested profile and raise its OWN
44
+ * catchable error / graceful exit code instead of dying on an uncatchable `process.exit`. A
45
+ * blank/whitespace-only name counts as "no profile" → `undefined`.
46
+ *
47
+ * @param identityProfile The explicitly-requested identity profile name.
48
+ * @returns The resolved profile config path, or `undefined` when the profile has no config.
49
+ */
50
+ export declare function resolveIdentityProfileConfigPath(identityProfile: string): string | undefined;
51
+ /**
52
+ * Loads the global gsloth config (if present) from the global `~/.gsloth` folder.
53
+ *
54
+ * Precedence support: the returned raw config is intended to act as the BASE that the
55
+ * project config (and CLI overrides) merge on top of, so any value here is the lowest
56
+ * user-controlled layer (still above {@link DEFAULT_CONFIG}).
57
+ *
58
+ * Lookup order within the global folder, first match wins:
59
+ * `.gsloth.config.json` -> `.gsloth.config.jsonc` -> `.gsloth.config.js` -> `.gsloth.config.mjs`
60
+ *
61
+ * Absence of every variant is a no-op: returns `undefined` so behaviour is unchanged.
62
+ *
63
+ * NOTE: secrets (API keys) may live in this file; this function must never log its
64
+ * contents. Only non-sensitive diagnostics (the resolved path / parse failure) are emitted.
65
+ *
66
+ * @returns The raw global config object, or `undefined` when no global config exists.
67
+ */
68
+ export declare function loadGlobalRawConfig(): Promise<Partial<RawGthConfig> | undefined>;
69
+ /**
70
+ * GS2-41 — resolve a named profile's `extends` inheritance into a single composed raw config,
71
+ * riding the SAME GS2-1 deep-merge the config LAYERS use (NO second merge engine). When the given
72
+ * profile config declares `extends: "<base>"`, the base profile's config resolves FIRST
73
+ * (recursively — a base may itself extend another, so base-of-base resolves first), then this
74
+ * profile's own fields merge on top with last-wins semantics: the child overrides the base, nested
75
+ * objects merge, arrays REPLACE except the additive-array fields (`allowDirs`, `aiignore.patterns`
76
+ * and the three `approvals` rule lists, see {@link isAdditiveArrayField}) which accumulate
77
+ * base+child. The `extends` key itself is consumed and never leaks into the composed output.
78
+ *
79
+ * A config WITHOUT `extends` is returned UNCHANGED — every non-inheriting config (the vast
80
+ * majority) is untouched and behaves exactly as before.
81
+ *
82
+ * Composition is CONFINED to the profile-dir layer: it produces the single raw config that then
83
+ * acts as the project-file layer the global config underlays and CLI flags overlay, preserving
84
+ * GS2-33's outer precedence `CLI flags > profile (base+child composed) > global > defaults`. It is
85
+ * therefore invoked in {@link initConfig} on the loaded project/profile config BEFORE
86
+ * {@link applyGlobalConfigBase}.
87
+ *
88
+ * The base profile is discovered with {@link resolveIdentityProfileConfigPath} (the SAME strict
89
+ * up-tree profile walk `--profile` uses), so `extends` names a profile exactly as a user selects
90
+ * one; a name with no config dir is a hard, clearly-named error.
91
+ *
92
+ * CYCLE GUARD: the chain of profile NAMES is tracked (seeded with the selected profile's own name);
93
+ * because `extends` is single-valued the chain is linear, so a repeated name — `A extends B extends
94
+ * A`, or a self-extend — is an unambiguous cycle and fails fast with a clear error NAMING the cycle,
95
+ * never infinite-looping / stack-overflowing. A hard {@link MAX_EXTENDS_CHAIN_DEPTH} cap backstops
96
+ * it regardless of how the base path was derived.
97
+ *
98
+ * @param rawConfig the just-loaded, schema-validated raw config that MAY declare `extends`.
99
+ * @param profileLabel the selected profile's own name (for cycle detection + messages); undefined
100
+ * for a plain (non-profile) project config.
101
+ */
102
+ export declare function resolveConfigExtends(rawConfig: Record<string, unknown>, profileLabel: string | undefined): Promise<Record<string, unknown>>;
103
+ /**
104
+ * ORDERING INVARIANT (GS2-11): detection ({@link hasProjectConfig}/{@link hasAnyConfig}) MUST run
105
+ * before {@link initConfig} in a given process. Both resolve cwd-level candidates via
106
+ * `getGslothConfigReadPath`, which reads `getProjectDir()`; {@link initConfig} clears `projectDir`
107
+ * at the start of its run, so detection stays cwd-correct as long as it precedes initConfig (it
108
+ * does: startSession calls hasAnyConfig before any initConfig, and the ACP/agent path calls
109
+ * initConfig directly without detection). Calling detection AFTER an initConfig with a changed cwd
110
+ * in a long-lived process would read a stale projectDir (currently unreachable). If that call
111
+ * order is ever introduced, decouple discovery's cwd-branch from `getProjectDir()`.
112
+ */
113
+ /**
114
+ * Returns true when a project-level config file (json/jsonc/js/mjs) exists for the given
115
+ * overrides. Honours `customConfigPath` and the active identity profile so the check
116
+ * matches exactly what {@link initConfig} would attempt to load.
117
+ *
118
+ * This is the project half of CFG-10's "is any config present?" detection; the global
119
+ * half is {@link loadGlobalRawConfig} (used by {@link hasAnyConfig}).
120
+ */
121
+ export declare function hasProjectConfig(commandLineConfigOverrides: CommandLineConfigOverrides): boolean;
122
+ /**
123
+ * CFG-10 — true when ANY usable configuration is present, either a project config file
124
+ * (json/jsonc/js/mjs) or a standalone global config (`~/.gsloth/.gsloth.config.*`). When this
125
+ * returns false the caller should run the first-run dialog instead of erroring.
126
+ *
127
+ * Reuses CFG-8's project + global detection so the two paths can never disagree.
128
+ */
129
+ export declare function hasAnyConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<boolean>;
130
+ /**
131
+ * CFG-37 — the layered value of the top-level `tui` config key, read BEFORE a session picks its
132
+ * surface. `chat`/`code` choose between the Ink TUI and the readline session in the app's
133
+ * `startSession` dispatcher, and each surface then loads its own config via {@link initConfig} — so
134
+ * at the moment of the choice there is no resolved {@link GthConfig} to consult, and this is the
135
+ * seam that supplies the one key the choice needs.
136
+ *
137
+ * Layering matches a run: the discovered PROJECT layer wins over the GLOBAL one, and a layer that
138
+ * does not set `tui` defers to the next rather than overriding it with `undefined`. A scalar needs
139
+ * no deep merge, so this reads the two layers and picks — it does not fork the merge engine.
140
+ *
141
+ * QUIET and fail-soft for the layers it reads ITSELF: it does not validate them and does not
142
+ * `exit` on a malformed one, because the caller runs moments before {@link initConfig}, which
143
+ * validates every layer and reports the very same problem — warning twice about one file is worse
144
+ * than not warning here. A failed read resolves to `undefined`, i.e. "nobody set it", and the
145
+ * surface auto-detects exactly as it does for a run with no config.
146
+ *
147
+ * ONE EXCEPTION, and it is deliberate: a `tui` may be INHERITED through a GS2-41 profile `extends`
148
+ * chain, so this walks that chain via the SHARED {@link resolveConfigExtends} rather than forking
149
+ * it — and that traversal owns its own reporting. It validates each base layer (so a base's own
150
+ * unknown-key warning can appear here as well as from `initConfig`) and hard-`exit`s on a cycle, a
151
+ * missing base or a malformed base. What the user sees is unchanged — `initConfig` exits on the
152
+ * same chain with the same message a moment later — but it now happens EARLIER, at surface
153
+ * selection rather than at config load. Forking the walk to silence it would mean a second
154
+ * inheritance engine; ignoring `extends` would mean silently dropping an inherited `tui`.
155
+ *
156
+ * Ordering: this is DETECTION, so per the GS2-11 invariant above it must run before any
157
+ * {@link initConfig} in the process — as it does, alongside {@link hasAnyConfig} in `startSession`.
158
+ */
159
+ export declare function loadConfiguredTui(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<boolean | undefined>;
160
+ /**
161
+ * Initialize configuration by loading from available config files
162
+ * @returns The loaded GthConfig
163
+ */
164
+ export declare function initConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
165
+ /**
166
+ * Process JSON LLM config by creating the appropriate LLM instance
167
+ * @param jsonConfig - The parsed JSON config
168
+ * @param commandLineConfigOverrides - command line config overrides
169
+ * @returns Promise<GthConfig>
170
+ */
171
+ export declare function tryJsonConfig(jsonConfig: RawGthConfig, commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
172
+ /**
173
+ * Resolve a fully-merged {@link GthConfig} from a partial config + CLI overrides WITHOUT
174
+ * any global side effects. It deep-merges defaults, applies CLI overrides, resolves the numeric
175
+ * `consoleLevel` (warning + defaulting to INFO on an invalid value), and computes
176
+ * `canInterruptInferenceWithEsc` and `useColour`. The process-global setters (`setUseColour` /
177
+ * `setConsoleLevel`) are applied separately by {@link mergeConfig}, so this function can be
178
+ * reasoned about and reused without touching global state.
179
+ *
180
+ * It WRITES nothing globally, but it does READ the environment: `canInterruptInferenceWithEsc`
181
+ * consults stdin's TTY status, and (CFG-30) `useColour` consults `FORCE_COLOR`, `NO_COLOR` and
182
+ * stdout's TTY status. So it is deterministic for a given environment rather than a pure function
183
+ * of its arguments — a test that pins a resolved config should declare the terminal and the colour
184
+ * environment it expects in its setup. The ladder itself is a pure helper
185
+ * ({@link resolveUseColour}) so it can be tested rung by rung without process globals.
186
+ */
187
+ export declare function resolveConfig(partialConfig: Omit<Partial<GthConfig>, 'consoleLevel'> & {
188
+ consoleLevel?: ConsoleLevelInput;
189
+ }, commandLineConfigOverrides: CommandLineConfigOverrides): GthConfig;
190
+ /**
191
+ * One config LAYER's validation outcome inside a {@link ConfigValidationReport}: the pure
192
+ * read-side result ({@link validateRawGthConfig}) plus the source label so a consumer can name
193
+ * WHICH file carried a warning/error (the project path, or `"<name> (global)"`).
194
+ */
195
+ export interface ConfigLayerValidationReport extends RawConfigValidationResult {
196
+ /** The resolved config path (project layer) or `"<name> (global)"` (global layer). */
197
+ sourceLabel: string;
198
+ }
199
+ /**
200
+ * The outcome of `gth config validate`: whether any config was found, and the per-layer verdict
201
+ * for EVERY layer a run would validate. Pure/read-side — it neither builds an LLM nor mutates
202
+ * process globals, so it can report a verdict without the run-path's side effects. The command
203
+ * layer turns this into console output + an exit code.
204
+ *
205
+ * GS2-29 — `validateConfig` mirrors the layer set `initConfig` validates: the discovered PROJECT
206
+ * layer (if any) AND the GLOBAL layer (if any). A run validates both and exits(1) if EITHER
207
+ * carries a problem, so a removed shape in the global config (with a clean project config) shows
208
+ * up here exactly as the run would reject it. Both layers are kept in {@link layers} (in run
209
+ * order) so the offending file is always identifiable.
210
+ */
211
+ export interface ConfigValidationReport {
212
+ /** False when neither a project nor a global config exists within the discovery boundary. */
213
+ found: boolean;
214
+ /** True only when a config was found AND every present layer validates OK. */
215
+ ok: boolean;
216
+ /**
217
+ * Each config layer a run would load + validate, in run order: the discovered PROJECT layer
218
+ * (if any) first, then the GLOBAL layer (if any). Empty when `found` is false.
219
+ */
220
+ layers: ConfigLayerValidationReport[];
221
+ }
222
+ /**
223
+ * Locate and validate the effective raw config against the schema WITHOUT building the LLM
224
+ * or merging defaults (the read-side of GS2-1). Honours `--config`, up-tree discovery, and the
225
+ * identity profile via {@link findProjectConfigPath}.
226
+ *
227
+ * GS2-29 — validates the SAME layer set a real run does: the discovered PROJECT layer (if any)
228
+ * AND the GLOBAL layer (if any), mirroring `initConfig`'s `validateRawConfigLayer(project)` +
229
+ * `applyGlobalConfigBase` → `loadGlobalRawConfig(global)`. Each present layer is validated
230
+ * independently ({@link validateRawGthConfig}) and its outcome recorded in {@link
231
+ * ConfigValidationReport.layers}, so a removed shape in EITHER file is reported (labelled with
232
+ * its source) rather than under-reported.
233
+ *
234
+ * A PROJECT-layer JSONC/module parse failure is thrown to the caller (surfaced as a clear
235
+ * "invalid config" error + non-zero exit). A GLOBAL-layer parse failure is treated as an absent
236
+ * global (no layer added) but is surfaced with a `displayWarning` — exactly as a run does (it
237
+ * warns the user while ignoring the broken global's value) — see {@link
238
+ * loadGlobalRawConfigUnvalidated}.
239
+ *
240
+ * GS2-73 — for the PROJECT layer it also walks the GS2-41 profile `extends` chain (via the SAME
241
+ * {@link composeExtends}/{@link resolveExtendsChain} the run path uses), so a cycle or a missing
242
+ * base — which fail a real run — is reported here as a not-ok layer instead of passing OK and only
243
+ * failing at run time. The GLOBAL layer is NOT walked, mirroring the run (`resolveConfigExtends`
244
+ * runs on the project/profile layer only).
245
+ */
246
+ export declare function validateConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<ConfigValidationReport>;