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