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

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 (289) hide show
  1. package/README.md +71 -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/configDiscovery.d.ts +79 -0
  6. package/dist/config/configDiscovery.js +80 -0
  7. package/dist/config/configDiscovery.js.map +1 -0
  8. package/dist/config/defaults.d.ts +21 -21
  9. package/dist/config/defaults.js +11 -9
  10. package/dist/config/defaults.js.map +1 -1
  11. package/dist/config/filesystem-tools.d.ts +41 -0
  12. package/dist/config/filesystem-tools.js +56 -0
  13. package/dist/config/filesystem-tools.js.map +1 -0
  14. package/dist/config/jsonc.d.ts +12 -0
  15. package/dist/config/jsonc.js +41 -0
  16. package/dist/config/jsonc.js.map +1 -0
  17. package/dist/config/loader.d.ts +165 -6
  18. package/dist/config/loader.js +963 -109
  19. package/dist/config/loader.js.map +1 -1
  20. package/dist/config/mouse.d.ts +50 -0
  21. package/dist/config/mouse.js +44 -0
  22. package/dist/config/mouse.js.map +1 -0
  23. package/dist/config/profiles.d.ts +68 -0
  24. package/dist/config/profiles.js +93 -0
  25. package/dist/config/profiles.js.map +1 -0
  26. package/dist/config/providerKeys.d.ts +69 -0
  27. package/dist/config/providerKeys.js +69 -0
  28. package/dist/config/providerKeys.js.map +1 -0
  29. package/dist/config/schema.d.ts +2695 -130
  30. package/dist/config/schema.js +1385 -68
  31. package/dist/config/schema.js.map +1 -1
  32. package/dist/config/shell-policy.d.ts +899 -111
  33. package/dist/config/shell-policy.js +800 -70
  34. package/dist/config/shell-policy.js.map +1 -1
  35. package/dist/config/tool-descriptions.d.ts +211 -0
  36. package/dist/config/tool-descriptions.js +272 -0
  37. package/dist/config/tool-descriptions.js.map +1 -0
  38. package/dist/config/types.d.ts +372 -34
  39. package/dist/config/types.js +1 -0
  40. package/dist/config/types.js.map +1 -1
  41. package/dist/config.d.ts +35 -1
  42. package/dist/config.js +16 -1
  43. package/dist/config.js.map +1 -1
  44. package/dist/constants.d.ts +45 -0
  45. package/dist/constants.js +45 -0
  46. package/dist/constants.js.map +1 -1
  47. package/dist/core/GthAbstractAgent.d.ts +190 -11
  48. package/dist/core/GthAbstractAgent.js +551 -35
  49. package/dist/core/GthAbstractAgent.js.map +1 -1
  50. package/dist/core/GthAgentRunner.d.ts +565 -57
  51. package/dist/core/GthAgentRunner.js +1546 -140
  52. package/dist/core/GthAgentRunner.js.map +1 -1
  53. package/dist/core/GthLangChainAgent.d.ts +117 -2
  54. package/dist/core/GthLangChainAgent.js +644 -18
  55. package/dist/core/GthLangChainAgent.js.map +1 -1
  56. package/dist/core/approvals/annotations.d.ts +122 -0
  57. package/dist/core/approvals/annotations.js +137 -0
  58. package/dist/core/approvals/annotations.js.map +1 -0
  59. package/dist/core/approvals/grants.d.ts +216 -0
  60. package/dist/core/approvals/grants.js +469 -0
  61. package/dist/core/approvals/grants.js.map +1 -0
  62. package/dist/core/approvals/matcher.d.ts +202 -0
  63. package/dist/core/approvals/matcher.js +267 -0
  64. package/dist/core/approvals/matcher.js.map +1 -0
  65. package/dist/core/approvals/mcpSubjects.d.ts +40 -0
  66. package/dist/core/approvals/mcpSubjects.js +99 -0
  67. package/dist/core/approvals/mcpSubjects.js.map +1 -0
  68. package/dist/core/approvals/promptHeader.d.ts +28 -0
  69. package/dist/core/approvals/promptHeader.js +62 -0
  70. package/dist/core/approvals/promptHeader.js.map +1 -0
  71. package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
  72. package/dist/core/approvals/toolAnnotationSources.js +277 -0
  73. package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
  74. package/dist/core/approvals/toolHost.d.ts +46 -0
  75. package/dist/core/approvals/toolHost.js +108 -0
  76. package/dist/core/approvals/toolHost.js.map +1 -0
  77. package/dist/core/debugCapture.d.ts +74 -0
  78. package/dist/core/debugCapture.js +100 -0
  79. package/dist/core/debugCapture.js.map +1 -0
  80. package/dist/core/gthLeanAgentFactory.d.ts +9 -0
  81. package/dist/core/gthLeanAgentFactory.js +10 -0
  82. package/dist/core/gthLeanAgentFactory.js.map +1 -0
  83. package/dist/core/launchBanner.d.ts +127 -0
  84. package/dist/core/launchBanner.js +414 -0
  85. package/dist/core/launchBanner.js.map +1 -0
  86. package/dist/core/modelLabel.d.ts +19 -0
  87. package/dist/core/modelLabel.js +26 -0
  88. package/dist/core/modelLabel.js.map +1 -0
  89. package/dist/core/plainToolIndication.d.ts +15 -0
  90. package/dist/core/plainToolIndication.js +174 -0
  91. package/dist/core/plainToolIndication.js.map +1 -0
  92. package/dist/core/reasoningBlocks.d.ts +65 -0
  93. package/dist/core/reasoningBlocks.js +103 -0
  94. package/dist/core/reasoningBlocks.js.map +1 -0
  95. package/dist/core/refusal.d.ts +53 -0
  96. package/dist/core/refusal.js +133 -0
  97. package/dist/core/refusal.js.map +1 -0
  98. package/dist/core/runHeader.d.ts +38 -0
  99. package/dist/core/runHeader.js +42 -0
  100. package/dist/core/runHeader.js.map +1 -0
  101. package/dist/core/runStats.d.ts +52 -0
  102. package/dist/core/runStats.js +118 -0
  103. package/dist/core/runStats.js.map +1 -0
  104. package/dist/core/shell/ShellCommandFailedError.d.ts +53 -0
  105. package/dist/core/shell/ShellCommandFailedError.js +67 -0
  106. package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
  107. package/dist/core/shell/abstention.d.ts +88 -0
  108. package/dist/core/shell/abstention.js +184 -0
  109. package/dist/core/shell/abstention.js.map +1 -0
  110. package/dist/core/shell/approvalCapture.d.ts +271 -0
  111. package/dist/core/shell/approvalCapture.js +108 -0
  112. package/dist/core/shell/approvalCapture.js.map +1 -0
  113. package/dist/core/shell/approvalStop.d.ts +123 -0
  114. package/dist/core/shell/approvalStop.js +269 -0
  115. package/dist/core/shell/approvalStop.js.map +1 -0
  116. package/dist/core/shell/arity.d.ts +6 -0
  117. package/dist/core/shell/arity.js +20 -6
  118. package/dist/core/shell/arity.js.map +1 -1
  119. package/dist/core/shell/denylist.d.ts +11 -0
  120. package/dist/core/shell/denylist.js +37 -0
  121. package/dist/core/shell/denylist.js.map +1 -0
  122. package/dist/core/shell/escalationSeverity.d.ts +141 -0
  123. package/dist/core/shell/escalationSeverity.js +89 -0
  124. package/dist/core/shell/escalationSeverity.js.map +1 -0
  125. package/dist/core/shell/framing.d.ts +190 -0
  126. package/dist/core/shell/framing.js +633 -0
  127. package/dist/core/shell/framing.js.map +1 -0
  128. package/dist/core/shell/hardline.d.ts +103 -0
  129. package/dist/core/shell/hardline.js +780 -0
  130. package/dist/core/shell/hardline.js.map +1 -0
  131. package/dist/core/shell/negotiation.d.ts +328 -0
  132. package/dist/core/shell/negotiation.js +488 -0
  133. package/dist/core/shell/negotiation.js.map +1 -0
  134. package/dist/core/shell/normalize.d.ts +44 -4
  135. package/dist/core/shell/normalize.js +61 -7
  136. package/dist/core/shell/normalize.js.map +1 -1
  137. package/dist/core/shell/openWorld.d.ts +263 -0
  138. package/dist/core/shell/openWorld.js +1188 -0
  139. package/dist/core/shell/openWorld.js.map +1 -0
  140. package/dist/core/shell/rater.d.ts +873 -0
  141. package/dist/core/shell/rater.js +1454 -0
  142. package/dist/core/shell/rater.js.map +1 -0
  143. package/dist/core/shell/raterModel.d.ts +41 -0
  144. package/dist/core/shell/raterModel.js +51 -0
  145. package/dist/core/shell/raterModel.js.map +1 -0
  146. package/dist/core/shell/raterVocabulary.d.ts +121 -0
  147. package/dist/core/shell/raterVocabulary.js +116 -0
  148. package/dist/core/shell/raterVocabulary.js.map +1 -0
  149. package/dist/core/shell/rejection.d.ts +69 -0
  150. package/dist/core/shell/rejection.js +38 -0
  151. package/dist/core/shell/rejection.js.map +1 -0
  152. package/dist/core/toolCallRepair/grammar.d.ts +41 -0
  153. package/dist/core/toolCallRepair/grammar.js +116 -0
  154. package/dist/core/toolCallRepair/grammar.js.map +1 -0
  155. package/dist/core/toolCallRepair/index.d.ts +2 -0
  156. package/dist/core/toolCallRepair/index.js +7 -0
  157. package/dist/core/toolCallRepair/index.js.map +1 -0
  158. package/dist/core/toolCallRepair/payload.d.ts +36 -0
  159. package/dist/core/toolCallRepair/payload.js +341 -0
  160. package/dist/core/toolCallRepair/payload.js.map +1 -0
  161. package/dist/core/toolCallRepair/promote.d.ts +45 -0
  162. package/dist/core/toolCallRepair/promote.js +90 -0
  163. package/dist/core/toolCallRepair/promote.js.map +1 -0
  164. package/dist/core/toolDisplay.d.ts +123 -0
  165. package/dist/core/toolDisplay.js +451 -0
  166. package/dist/core/toolDisplay.js.map +1 -0
  167. package/dist/core/toolOutputChannel.d.ts +95 -0
  168. package/dist/core/toolOutputChannel.js +165 -0
  169. package/dist/core/toolOutputChannel.js.map +1 -0
  170. package/dist/core/types.d.ts +378 -16
  171. package/dist/core/types.js.map +1 -1
  172. package/dist/history/historyFormat.d.ts +28 -0
  173. package/dist/history/historyFormat.js +127 -0
  174. package/dist/history/historyFormat.js.map +1 -0
  175. package/dist/history/historyStore.d.ts +198 -0
  176. package/dist/history/historyStore.js +482 -0
  177. package/dist/history/historyStore.js.map +1 -0
  178. package/dist/history/recordSession.d.ts +37 -0
  179. package/dist/history/recordSession.js +56 -0
  180. package/dist/history/recordSession.js.map +1 -0
  181. package/dist/index.d.ts +4 -0
  182. package/dist/index.js +4 -0
  183. package/dist/index.js.map +1 -1
  184. package/dist/providers/anthropic.d.ts +1 -1
  185. package/dist/providers/anthropic.js +17 -10
  186. package/dist/providers/anthropic.js.map +1 -1
  187. package/dist/providers/configurationPassthrough.d.ts +107 -0
  188. package/dist/providers/configurationPassthrough.js +148 -0
  189. package/dist/providers/configurationPassthrough.js.map +1 -0
  190. package/dist/providers/deepseek.d.ts +1 -1
  191. package/dist/providers/deepseek.js +5 -10
  192. package/dist/providers/deepseek.js.map +1 -1
  193. package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
  194. package/dist/providers/geminiSchemaSanitizer.js +347 -0
  195. package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
  196. package/dist/providers/geminiThinking.d.ts +60 -0
  197. package/dist/providers/geminiThinking.js +92 -0
  198. package/dist/providers/geminiThinking.js.map +1 -0
  199. package/dist/providers/google-genai.d.ts +1 -1
  200. package/dist/providers/google-genai.js +23 -11
  201. package/dist/providers/google-genai.js.map +1 -1
  202. package/dist/providers/groq.d.ts +1 -1
  203. package/dist/providers/groq.js +17 -10
  204. package/dist/providers/groq.js.map +1 -1
  205. package/dist/providers/huggingface.d.ts +25 -0
  206. package/dist/providers/huggingface.js +69 -0
  207. package/dist/providers/huggingface.js.map +1 -0
  208. package/dist/providers/modelCatalog.d.ts +109 -0
  209. package/dist/providers/modelCatalog.js +245 -0
  210. package/dist/providers/modelCatalog.js.map +1 -0
  211. package/dist/providers/modelDiscovery.d.ts +153 -6
  212. package/dist/providers/modelDiscovery.js +295 -41
  213. package/dist/providers/modelDiscovery.js.map +1 -1
  214. package/dist/providers/ollama.d.ts +19 -5
  215. package/dist/providers/ollama.js +72 -52
  216. package/dist/providers/ollama.js.map +1 -1
  217. package/dist/providers/openai.d.ts +1 -1
  218. package/dist/providers/openai.js +39 -10
  219. package/dist/providers/openai.js.map +1 -1
  220. package/dist/providers/openrouter.d.ts +27 -5
  221. package/dist/providers/openrouter.js +88 -36
  222. package/dist/providers/openrouter.js.map +1 -1
  223. package/dist/providers/vertexai.d.ts +1 -1
  224. package/dist/providers/vertexai.js +24 -11
  225. package/dist/providers/vertexai.js.map +1 -1
  226. package/dist/providers/xai.d.ts +1 -1
  227. package/dist/providers/xai.js +25 -10
  228. package/dist/providers/xai.js.map +1 -1
  229. package/dist/runtime/askStructured.d.ts +105 -0
  230. package/dist/runtime/askStructured.js +120 -0
  231. package/dist/runtime/askStructured.js.map +1 -0
  232. package/dist/runtime/conversation.d.ts +64 -0
  233. package/dist/runtime/conversation.js +171 -0
  234. package/dist/runtime/conversation.js.map +1 -0
  235. package/dist/runtime/singleShot.d.ts +39 -5
  236. package/dist/runtime/singleShot.js +115 -36
  237. package/dist/runtime/singleShot.js.map +1 -1
  238. package/dist/runtime/structuredOutput.d.ts +104 -0
  239. package/dist/runtime/structuredOutput.js +393 -0
  240. package/dist/runtime/structuredOutput.js.map +1 -0
  241. package/dist/utils/ProgressIndicator.d.ts +21 -0
  242. package/dist/utils/ProgressIndicator.js +30 -3
  243. package/dist/utils/ProgressIndicator.js.map +1 -1
  244. package/dist/utils/aiignoreUtils.js.map +1 -1
  245. package/dist/utils/binaryOutputUtils.js.map +1 -1
  246. package/dist/utils/consoleUtils.d.ts +95 -0
  247. package/dist/utils/consoleUtils.js +112 -2
  248. package/dist/utils/consoleUtils.js.map +1 -1
  249. package/dist/utils/crashHandler.d.ts +87 -0
  250. package/dist/utils/crashHandler.js +128 -0
  251. package/dist/utils/crashHandler.js.map +1 -0
  252. package/dist/utils/debugDump.d.ts +134 -0
  253. package/dist/utils/debugDump.js +381 -0
  254. package/dist/utils/debugDump.js.map +1 -0
  255. package/dist/utils/debugUtils.d.ts +13 -4
  256. package/dist/utils/debugUtils.js +36 -13
  257. package/dist/utils/debugUtils.js.map +1 -1
  258. package/dist/utils/displayWidth.d.ts +53 -0
  259. package/dist/utils/displayWidth.js +195 -0
  260. package/dist/utils/displayWidth.js.map +1 -0
  261. package/dist/utils/fileUtils.d.ts +20 -1
  262. package/dist/utils/fileUtils.js +35 -2
  263. package/dist/utils/fileUtils.js.map +1 -1
  264. package/dist/utils/llmUtils.d.ts +39 -8
  265. package/dist/utils/llmUtils.js +76 -8
  266. package/dist/utils/llmUtils.js.map +1 -1
  267. package/dist/utils/redactSecrets.d.ts +63 -0
  268. package/dist/utils/redactSecrets.js +286 -0
  269. package/dist/utils/redactSecrets.js.map +1 -0
  270. package/dist/utils/systemPromptNotes.d.ts +222 -0
  271. package/dist/utils/systemPromptNotes.js +338 -0
  272. package/dist/utils/systemPromptNotes.js.map +1 -0
  273. package/dist/utils/systemUtils.d.ts +18 -1
  274. package/dist/utils/systemUtils.js +38 -3
  275. package/dist/utils/systemUtils.js.map +1 -1
  276. package/dist/utils/toolMatching.d.ts +30 -0
  277. package/dist/utils/toolMatching.js +44 -0
  278. package/dist/utils/toolMatching.js.map +1 -0
  279. package/dist/utils/untrustedText.d.ts +86 -0
  280. package/dist/utils/untrustedText.js +101 -0
  281. package/dist/utils/untrustedText.js.map +1 -0
  282. package/package.json +21 -6
  283. package/schema/gsloth-config.schema.json +1979 -353
  284. package/dist/core/shell/allowlist.d.ts +0 -75
  285. package/dist/core/shell/allowlist.js +0 -187
  286. package/dist/core/shell/allowlist.js.map +0 -1
  287. package/dist/core/shell/judge.d.ts +0 -161
  288. package/dist/core/shell/judge.js +0 -261
  289. package/dist/core/shell/judge.js.map +0 -1
@@ -24,6 +24,7 @@
24
24
  * `{ providerId, model }` maps directly onto a `RawGthConfig.llm`.
25
25
  */
26
26
  import { type ConfigType } from '#src/config.js';
27
+ import type { MissingProviderKeyDetails } from '#src/config/providerKeys.js';
27
28
  /**
28
29
  * Provider identifiers understood by model discovery. These match the provider
29
30
  * factory module names (`#src/providers/<id>.js`) and {@link LLMConfig.type},
@@ -49,10 +50,14 @@ export interface ModelInfo {
49
50
  * Covers openai, openrouter, groq, deepseek, xai and ollama (local).
50
51
  * - `anthropic` — Anthropic's native `GET /v1/models`
51
52
  * (`{ data: [{ type, id, display_name }] }`) with `x-api-key` auth.
52
- * - `none` no cheap live endpoint; stay on the curated list
53
- * (google-genai, vertexai).
53
+ * - `google` Google AI Studio's native ListModels
54
+ * (`GET /v1beta/models` → `{ models: [{ name, supportedGenerationMethods }] }`)
55
+ * with `x-goog-api-key` auth. Chat capability is decided by a data-driven
56
+ * `supportedGenerationMethods` check rather than a name regex (google-genai).
57
+ * - `none` — no cheap live endpoint; stay on the curated list (vertexai,
58
+ * which authenticates via gcloud ADC rather than an API key).
54
59
  */
55
- export type DiscoveryKind = 'openai' | 'anthropic' | 'none';
60
+ export type DiscoveryKind = 'openai' | 'anthropic' | 'google' | 'none';
56
61
  /**
57
62
  * Per-provider live-discovery adapter. Bundled on the {@link ProviderDescriptor}
58
63
  * so {@link discoverModels} can be fully data-driven.
@@ -112,6 +117,13 @@ export declare const DEFAULT_OLLAMA_HOST = "http://127.0.0.1:11434";
112
117
  * Provider registry. The curated `preferredModels` are the models we have
113
118
  * tested with Gaunt Sloth's agent loop; defaults mirror the `init` templates in
114
119
  * each `#src/providers/<id>.js` factory.
120
+ *
121
+ * CFG-22 (2026-07-24): the CLOUD curated lists were trimmed to 1-2 current-gen ids/provider
122
+ * (head-first = the runtime default via getCuratedFallbackModel). Every surviving cloud id was live
123
+ * tool-call-validated with a `gth eval` identity matrix (a marker-read that proves a real tool
124
+ * call), with two exceptions: vertexai (no ADC here → mirrors the google-genai head) and ollama
125
+ * (local ids, out of the cloud-trim scope — kept as-is, validated against the local daemon if
126
+ * present). A dead id was caught and dropped: groq's qwen 404'd (`model_not_found`).
115
127
  */
116
128
  export declare const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[];
117
129
  /**
@@ -140,6 +152,30 @@ export interface DetectedProvider {
140
152
  * @returns the matching env var name, or undefined when none is set.
141
153
  */
142
154
  export declare function findApiKeyEnvVar(descriptor: ProviderDescriptor): string | undefined;
155
+ /**
156
+ * Decide whether an LLM spec has **no resolvable API key at all** for its provider, and if so
157
+ * report which provider and which variable names would have supplied one.
158
+ *
159
+ * This is the classifier the config loader uses to tell a missing secret apart from a provider
160
+ * that broke for some other reason, and it answers that question from the ENVIRONMENT rather than
161
+ * from the text of whatever error a provider SDK happened to throw. Message-sniffing would be
162
+ * wrong on both sides: SDK wording is not ours to depend on, and several providers word the same
163
+ * failure differently (some name the variable, some do not).
164
+ *
165
+ * Returns `undefined` — meaning "not a missing-key failure" — when any of these hold:
166
+ * - the provider is unknown here, or authenticates outside an env-var key (vertexai via ADC,
167
+ * ollama locally), so there is no key to be missing;
168
+ * - the config carries an inline `llm.apiKey`;
169
+ * - the config names an `llm.apiKeyEnvironmentVariable` that IS set;
170
+ * - any variable the provider accepts is set.
171
+ *
172
+ * The last two matter for correctness, not tidiness: classifying a provider outage as a missing
173
+ * key when a key was in fact present would defeat the whole distinction.
174
+ */
175
+ export declare function findMissingProviderKey(providerType: string | undefined, llmConfig: {
176
+ apiKey?: unknown;
177
+ apiKeyEnvironmentVariable?: unknown;
178
+ } | undefined): MissingProviderKeyDetails | undefined;
143
179
  /**
144
180
  * Build the {@link ModelInfo} list for a provider given the descriptor and an
145
181
  * optional set of model ids known to actually exist (e.g. from a live
@@ -148,9 +184,83 @@ export declare function findApiKeyEnvVar(descriptor: ProviderDescriptor): string
148
184
  * - When `discoveredModels` is omitted, the curated `preferredModels` are
149
185
  * returned, all flagged ⭐ preferred.
150
186
  * - When provided, every discovered model is listed; those that also appear in
151
- * the curated `preferredModels` are flagged ⭐ preferred.
187
+ * the curated `preferredModels` are flagged ⭐ preferred. The list is ordered
188
+ * **preferred first** (in curated order, so the recommended default sits on top
189
+ * and is pre-selected), then every other discovered model **alphabetically** —
190
+ * so a large catalog (e.g. OpenRouter's 200+ models) is navigable instead of
191
+ * arriving in the endpoint's arbitrary order.
152
192
  */
153
193
  export declare function buildModelList(descriptor: ProviderDescriptor, discoveredModels?: string[]): ModelInfo[];
194
+ /**
195
+ * The single fallback source of truth for a provider's default model id (CFG-14).
196
+ *
197
+ * Returns the top curated ⭐ `preferredModels` entry for the provider — the one
198
+ * id that provider factories fall back to when a config carries no `model`, and
199
+ * the id first-run writes when live discovery is impossible. Centralising it here
200
+ * means the fallback lives in exactly ONE place (the curated registry above)
201
+ * instead of being duplicated as a literal in every `providers/<id>.ts`.
202
+ *
203
+ * Every registered provider is required to carry at least one curated model, so
204
+ * this always resolves for a known id; it throws for an unknown provider or a
205
+ * provider whose `preferredModels` is empty (a developer error — the invariant
206
+ * that the fallback source is complete would otherwise fail silently).
207
+ *
208
+ * @returns the curated default model id (always defined for a known provider).
209
+ */
210
+ export declare function getCuratedFallbackModel(providerId: ProviderId): string;
211
+ /**
212
+ * Build the minimal `.gsloth.config.json` body an `init` template writes for a
213
+ * provider (CFG-14). When `model` is omitted, the `model` key is left OUT of the
214
+ * config entirely, so the provider factory resolves it at run time from
215
+ * {@link getCuratedFallbackModel} — the single curated source that tracks the
216
+ * installed version, rather than a literal frozen into the user's file that 404s
217
+ * once the model is retired.
218
+ *
219
+ * A `$schema` pointer ({@link CONFIG_SCHEMA_POINTER}) is written first so editors offer
220
+ * autocomplete/validation against the shipped JSON Schema (GS2-1). `$schema` is a known,
221
+ * runtime-ignored config field (see the zod schema), so it never affects loading.
222
+ */
223
+ export declare function buildInitConfigContent(providerId: ProviderId, model?: string): string;
224
+ /**
225
+ * CFG-21 — the timeout for the *interactive* first-run model fetch. The dialog is
226
+ * blocking on a human who just picked a provider, so it can afford to wait a lot
227
+ * longer than the background probes for a large cloud catalog (OpenRouter ~300
228
+ * models) to arrive over a cold connection, rather than losing the 2s race and
229
+ * silently dropping to a 3-item curated stub. Threaded per-call so ONLY the dialog
230
+ * uses it — `detectProviders` / `resolveInitModel` stay on the short
231
+ * {@link DISCOVERY_TIMEOUT_MS} probe (a long global would hang the *provider* step
232
+ * whenever the local Ollama daemon is down).
233
+ */
234
+ export declare const INTERACTIVE_MODEL_FETCH_TIMEOUT_MS = 12000;
235
+ /**
236
+ * Provenance of a returned model list (CFG-21). Distinguishes the three outcomes so
237
+ * an interactive caller can tell an honest "couldn't reach the provider" degrade
238
+ * apart from a by-design curated list:
239
+ *
240
+ * - `live` — a successful, non-empty live `/v1/models` query.
241
+ * - `fallback` — a live query WAS attempted (key present / ollama probed) but
242
+ * failed: network error/timeout, non-2xx, or an empty/malformed payload. THIS is
243
+ * the "couldn't reach" case the first-run dialog surfaces.
244
+ * - `curated` — no live query was attempted, by design: a `kind:'none'` provider
245
+ * (vertexai) or a cloud provider with no API key present. The
246
+ * curated catalog is the expected result here, NOT a degrade, so the dialog must
247
+ * NOT show a "couldn't reach" notice for it.
248
+ */
249
+ export type ModelDiscoveryStatus = 'live' | 'fallback' | 'curated';
250
+ /** Per-call discovery options (CFG-21). */
251
+ export interface ModelDiscoveryOptions {
252
+ /**
253
+ * Live-fetch timeout in ms. Defaults to the short {@link DISCOVERY_TIMEOUT_MS} so
254
+ * every existing caller is unchanged; the interactive first-run dialog passes the
255
+ * generous {@link INTERACTIVE_MODEL_FETCH_TIMEOUT_MS}.
256
+ */
257
+ timeoutMs?: number;
258
+ }
259
+ /** A model list plus its {@link ModelDiscoveryStatus} provenance (CFG-21). */
260
+ export interface ModelDiscoveryResult {
261
+ models: ModelInfo[];
262
+ status: ModelDiscoveryStatus;
263
+ }
154
264
  /**
155
265
  * Discover the models for a single provider.
156
266
  *
@@ -158,6 +268,9 @@ export declare function buildModelList(descriptor: ProviderDescriptor, discovere
158
268
  * - `kind: 'openai' | 'anthropic'` → fetches the models endpoint with a short
159
269
  * timeout, parses `data[].id`, applies the chat-only `filter`, and overlays
160
270
  * the ⭐ preferred flags via `buildModelList(descriptor, liveIds)`.
271
+ * - `kind: 'google'` → fetches the native ListModels endpoint, parses
272
+ * `models[].name` keeping only `generateContent`-capable entries and stripping
273
+ * the `models/` prefix, then overlays the ⭐ preferred flags likewise.
161
274
  *
162
275
  * Best-effort: any error / non-2xx / malformed / empty payload falls back to
163
276
  * the curated list. This function NEVER throws — a bad key must degrade to the
@@ -167,15 +280,49 @@ export declare function buildModelList(descriptor: ProviderDescriptor, discovere
167
280
  * the curated catalog is returned directly. Ollama (no key, local daemon) is
168
281
  * always probed.
169
282
  */
170
- export declare function discoverModels(providerId: ProviderId): Promise<ModelInfo[]>;
283
+ export declare function discoverModels(providerId: ProviderId, options?: ModelDiscoveryOptions): Promise<ModelInfo[]>;
171
284
  /**
172
285
  * List the models for a single provider.
173
286
  *
174
287
  * Live-discovers from the provider's models endpoint where possible (with a
175
288
  * curated fallback); returns the curated set for `kind: 'none'` providers. Does
176
289
  * not require the provider to be "available".
290
+ *
291
+ * `options.timeoutMs` (CFG-21) overrides the default short live-fetch timeout; the
292
+ * bare `listModels(providerId)` call is unchanged.
293
+ */
294
+ export declare function listModels(providerId: ProviderId, options?: ModelDiscoveryOptions): Promise<ModelInfo[]>;
295
+ /**
296
+ * CFG-21 — like {@link discoverModels} but also returns the model list's
297
+ * {@link ModelDiscoveryStatus} provenance, so an interactive caller (the first-run
298
+ * dialog) can tell an honest "couldn't reach the provider" degrade (`fallback`)
299
+ * apart from a by-design curated list (`curated`) and a real live catalog (`live`).
300
+ * Kept as a separate export so `listModels` / `discoverModels` keep their existing
301
+ * `(providerId) => ModelInfo[]` signatures other callers rely on.
302
+ *
303
+ * Never throws for a discovery failure (that degrades to `fallback`); it only
304
+ * throws for an unknown provider id, mirroring {@link discoverModels}.
305
+ */
306
+ export declare function discoverModelsWithProvenance(providerId: ProviderId, options?: ModelDiscoveryOptions): Promise<ModelDiscoveryResult>;
307
+ /**
308
+ * Resolve the model id that `init` should bake into a generated config for a
309
+ * provider (CFG-14) — the safeguard against writing a speculative id that 404s
310
+ * once the model is retired.
311
+ *
312
+ * - **Live discovery possible** (a key / running daemon and a responding
313
+ * `/v1/models` endpoint): returns a *verified-present* id — the highest-ranked
314
+ * curated ⭐ id that is actually in the live list (matched tolerant of an
315
+ * `:latest` suffix), or, when no curated id is live, the first live id.
316
+ * - **Live discovery impossible** (`kind: 'none'`, no key, offline, empty
317
+ * catalog): returns `undefined`. This is the ONLY speculative path, and it
318
+ * deliberately declines to invent a literal: the caller OMITS `model` so the
319
+ * provider factory falls back to {@link getCuratedFallbackModel} at run time
320
+ * (a single curated source that upgrades with the installed version).
321
+ *
322
+ * Never throws — a bad key or network error degrades to `undefined`, mirroring
323
+ * {@link discoverModels}.
177
324
  */
178
- export declare function listModels(providerId: ProviderId): Promise<ModelInfo[]>;
325
+ export declare function resolveInitModel(providerId: ProviderId): Promise<string | undefined>;
179
326
  /**
180
327
  * Detect every known provider on this machine and list its models.
181
328
  *