pi-namespace-patch 1.2.0-namespace.2 → 1.4.0-namespace.1

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 (233) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +5 -5
  3. package/dist/bundle/chunks/anthropic-messages-5FHV3XZG.js +6 -0
  4. package/dist/bundle/chunks/azure-openai-responses-KLTRI2FU.js +2 -0
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +12 -9
  6. package/dist/bundle/chunks/{chunk-TRDNDS6A.js → chunk-3V45WARH.js} +6 -3
  7. package/dist/bundle/chunks/chunk-4GGCU36O.js +11 -0
  8. package/dist/bundle/chunks/{chunk-S3GGRYIO.js → chunk-5AGIVGSV.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-F5ZABL6Z.js → chunk-7CBJINYJ.js} +2 -2
  10. package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-7DDKXS2Q.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-CQ3XTLTY.js → chunk-A45IWOC6.js} +4 -4
  12. package/dist/bundle/chunks/{chunk-WJUNYZC5.js → chunk-BSS6T6KQ.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-H3QXYIF7.js → chunk-CF5GWZHW.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-DOST5PQW.js → chunk-EGE5YVUM.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-C2AEIDJZ.js → chunk-FB6L7ZMV.js} +1 -1
  16. package/dist/bundle/chunks/chunk-H76KZMOI.js +2 -0
  17. package/dist/bundle/chunks/{chunk-GDR5JFDJ.js → chunk-INGZIYBC.js} +2 -2
  18. package/dist/bundle/chunks/{chunk-D7PHKNBM.js → chunk-IUWY2KTF.js} +11 -11
  19. package/dist/bundle/chunks/{chunk-4L3WN2XY.js → chunk-JXWJOIH4.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-6CYCI3EJ.js → chunk-LVVZS2NO.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-5GTPJSRI.js → chunk-N43LRJ4N.js} +1 -1
  22. package/dist/bundle/chunks/chunk-NFLURVK3.js +2 -0
  23. package/dist/bundle/chunks/chunk-QSDU2SDK.js +16 -0
  24. package/dist/bundle/chunks/chunk-RISAW7OQ.js +9 -0
  25. package/dist/bundle/chunks/{chunk-AKJ3ZOR3.js → chunk-RWO6Q3KK.js} +1 -1
  26. package/dist/bundle/chunks/{chunk-6MWTY2OB.js → chunk-T726RZZU.js} +10 -9
  27. package/dist/bundle/chunks/{chunk-ZBURYEWF.js → chunk-TMTOQ7H7.js} +1 -1
  28. package/dist/bundle/chunks/chunk-TRERZKRC.js +2 -0
  29. package/dist/bundle/chunks/{chunk-22CYIUS4.js → chunk-UKVNB6C4.js} +1 -1
  30. package/dist/bundle/chunks/chunk-Z6I32PHA.js +2 -0
  31. package/dist/bundle/chunks/{chunk-H7S5Z6OB.js → chunk-ZEIZZEGK.js} +42 -40
  32. package/dist/bundle/chunks/{cli-SWM4FQ6V.js → cli-MIMUTM5L.js} +1 -1
  33. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-7J6REGDV.js +2 -0
  34. package/dist/bundle/chunks/{easter-egg-3d-OX6RUCIS.js → easter-egg-3d-RMLF7AC4.js} +1 -1
  35. package/dist/bundle/chunks/{execute-3CFUPDLS.js → execute-MT7QEDSI.js} +9 -3
  36. package/dist/bundle/chunks/github-copilot.js +1 -1
  37. package/dist/bundle/chunks/google-generative-ai-VPNFZDHO.js +2 -0
  38. package/dist/bundle/chunks/google-vertex-ZFM23MQ4.js +2 -0
  39. package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  40. package/dist/bundle/chunks/{jiti-loader-C3NU2SDH.js → jiti-loader-GL4HJFAD.js} +1 -1
  41. package/dist/bundle/chunks/{jiti-static-loader-E6ANQD5T.js → jiti-static-loader-2RCDI6B4.js} +1 -1
  42. package/dist/bundle/chunks/{lib-TEDK3E5I.js → lib-4AVRLBHM.js} +1 -1
  43. package/dist/bundle/chunks/{llama-cpp-classify-FYN623RH.js → llama-cpp-classify-U4EH6TAM.js} +2 -2
  44. package/dist/bundle/chunks/mistral-conversations-WCAJTBXO.js +5 -0
  45. package/dist/bundle/chunks/{multipart-parser-SQ6GDJL7.js → multipart-parser-FMGQ7342.js} +1 -1
  46. package/dist/bundle/chunks/{node-TWVVAGPO.js → node-AUOGOBCN.js} +1 -1
  47. package/dist/bundle/chunks/{node-N5BSDOA5.js → node-KCMANYC2.js} +1 -1
  48. package/dist/bundle/chunks/openai-codex-responses-JQR3IK2C.js +10 -0
  49. package/dist/bundle/chunks/openai-completions-27RKPL37.js +7 -0
  50. package/dist/bundle/chunks/{openai-decisions-WVPMQ4JD.js → openai-decisions-MJYPUCLX.js} +1 -1
  51. package/dist/bundle/chunks/openai-responses-I2TBW7OL.js +4 -0
  52. package/dist/bundle/chunks/openrouter-images-WBAVKHHY.js +2 -0
  53. package/dist/bundle/chunks/pi-messages-S7RKCD5K.js +8 -0
  54. package/dist/bundle/chunks/{runtime-366HE7CW.js → runtime-GJOZRI5I.js} +1 -1
  55. package/dist/bundle/chunks/{src-UK77SYZE.js → src-QKGKDFSU.js} +1 -1
  56. package/dist/bundle/chunks/typesafe-system-one-4C7ULOVP.js +2 -0
  57. package/dist/bundle/chunks/virtual-modules-6XWNE4NR.js +2 -0
  58. package/dist/bundle/cli-runtime.js +1 -1
  59. package/dist/bundle/index.js +1 -1
  60. package/dist/bundle/rpc-entry.js +1 -1
  61. package/dist/cli/credential-print.d.ts.map +1 -1
  62. package/dist/cli/credential-print.js +4 -4
  63. package/dist/cli/credential-print.js.map +1 -1
  64. package/dist/core/agent-session.d.ts +9 -3
  65. package/dist/core/agent-session.d.ts.map +1 -1
  66. package/dist/core/agent-session.js +45 -15
  67. package/dist/core/agent-session.js.map +1 -1
  68. package/dist/core/client-identity.d.ts +8 -0
  69. package/dist/core/client-identity.d.ts.map +1 -0
  70. package/dist/core/client-identity.js +15 -0
  71. package/dist/core/client-identity.js.map +1 -0
  72. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  73. package/dist/core/compaction/branch-summarization.js +1 -2
  74. package/dist/core/compaction/branch-summarization.js.map +1 -1
  75. package/dist/core/compaction/compaction.d.ts +2 -2
  76. package/dist/core/compaction/compaction.d.ts.map +1 -1
  77. package/dist/core/compaction/compaction.js +20 -15
  78. package/dist/core/compaction/compaction.js.map +1 -1
  79. package/dist/core/export-html/index.d.ts.map +1 -1
  80. package/dist/core/export-html/index.js +2 -0
  81. package/dist/core/export-html/index.js.map +1 -1
  82. package/dist/core/export-html/template.html +1 -0
  83. package/dist/core/export-html/template.js +23 -17
  84. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  85. package/dist/core/export-html/vendor/marked.min.js +30 -29
  86. package/dist/core/extensions/loader.d.ts.map +1 -1
  87. package/dist/core/extensions/loader.js +3 -0
  88. package/dist/core/extensions/loader.js.map +1 -1
  89. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  90. package/dist/core/extensions/virtual-modules.js +3 -0
  91. package/dist/core/extensions/virtual-modules.js.map +1 -1
  92. package/dist/core/model-config.d.ts +939 -8
  93. package/dist/core/model-config.d.ts.map +1 -1
  94. package/dist/core/model-config.js +48 -24
  95. package/dist/core/model-config.js.map +1 -1
  96. package/dist/core/model-resolver.d.ts +56 -43
  97. package/dist/core/model-resolver.d.ts.map +1 -1
  98. package/dist/core/model-resolver.js +253 -358
  99. package/dist/core/model-resolver.js.map +1 -1
  100. package/dist/core/model-runtime.d.ts.map +1 -1
  101. package/dist/core/model-runtime.js +6 -3
  102. package/dist/core/model-runtime.js.map +1 -1
  103. package/dist/core/prompt-templates.d.ts.map +1 -1
  104. package/dist/core/prompt-templates.js +7 -2
  105. package/dist/core/prompt-templates.js.map +1 -1
  106. package/dist/core/provider-composer.d.ts +2 -1
  107. package/dist/core/provider-composer.d.ts.map +1 -1
  108. package/dist/core/provider-composer.js +7 -3
  109. package/dist/core/provider-composer.js.map +1 -1
  110. package/dist/core/sdk.d.ts.map +1 -1
  111. package/dist/core/sdk.js +8 -9
  112. package/dist/core/sdk.js.map +1 -1
  113. package/dist/core/settings-defaults.d.ts +1 -0
  114. package/dist/core/settings-defaults.d.ts.map +1 -1
  115. package/dist/core/settings-defaults.js +1 -0
  116. package/dist/core/settings-defaults.js.map +1 -1
  117. package/dist/core/settings-manager.d.ts +4 -2
  118. package/dist/core/settings-manager.d.ts.map +1 -1
  119. package/dist/core/settings-manager.js +11 -0
  120. package/dist/core/settings-manager.js.map +1 -1
  121. package/dist/core/settings-schema.d.ts +2 -0
  122. package/dist/core/settings-schema.d.ts.map +1 -1
  123. package/dist/core/settings-schema.js +4 -0
  124. package/dist/core/settings-schema.js.map +1 -1
  125. package/dist/core/slash-commands.js +1 -1
  126. package/dist/core/slash-commands.js.map +1 -1
  127. package/dist/core/tools/grep.d.ts.map +1 -1
  128. package/dist/core/tools/grep.js +3 -1
  129. package/dist/core/tools/grep.js.map +1 -1
  130. package/dist/core/tools/render-utils.d.ts +2 -0
  131. package/dist/core/tools/render-utils.d.ts.map +1 -1
  132. package/dist/core/tools/render-utils.js +21 -0
  133. package/dist/core/tools/render-utils.js.map +1 -1
  134. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  135. package/dist/core/tools/renderers/read.js +7 -11
  136. package/dist/core/tools/renderers/read.js.map +1 -1
  137. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  138. package/dist/extensions/codemode/execute.js +101 -14
  139. package/dist/extensions/codemode/execute.js.map +1 -1
  140. package/dist/extensions/mcp/config.d.ts.map +1 -1
  141. package/dist/extensions/mcp/config.js +3 -2
  142. package/dist/extensions/mcp/config.js.map +1 -1
  143. package/dist/index.d.ts +1 -0
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +1 -0
  146. package/dist/index.js.map +1 -1
  147. package/dist/main.d.ts.map +1 -1
  148. package/dist/main.js +1 -0
  149. package/dist/main.js.map +1 -1
  150. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  151. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  152. package/dist/modes/interactive/components/settings-selector.js +10 -0
  153. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  154. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  155. package/dist/modes/interactive/components/tree-selector.js +2 -9
  156. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  157. package/dist/modes/interactive/interactive-mode.d.ts +11 -15
  158. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  159. package/dist/modes/interactive/interactive-mode.js +76 -111
  160. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  161. package/dist/modes/interactive/session-share.d.ts.map +1 -1
  162. package/dist/modes/interactive/session-share.js +9 -2
  163. package/dist/modes/interactive/session-share.js.map +1 -1
  164. package/dist/package-manager-cli.d.ts.map +1 -1
  165. package/dist/package-manager-cli.js +2 -1
  166. package/dist/package-manager-cli.js.map +1 -1
  167. package/dist/utils/clipboard-command.d.ts.map +1 -1
  168. package/dist/utils/clipboard-command.js +3 -0
  169. package/dist/utils/clipboard-command.js.map +1 -1
  170. package/dist/utils/pi-user-agent.d.ts +1 -0
  171. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  172. package/dist/utils/pi-user-agent.js +3 -2
  173. package/dist/utils/pi-user-agent.js.map +1 -1
  174. package/dist/utils/shell.d.ts.map +1 -1
  175. package/dist/utils/shell.js +45 -13
  176. package/dist/utils/shell.js.map +1 -1
  177. package/dist/utils/tools-manager.d.ts.map +1 -1
  178. package/dist/utils/tools-manager.js +4 -3
  179. package/dist/utils/tools-manager.js.map +1 -1
  180. package/docs/cli.md +3 -3
  181. package/docs/codemode.md +3 -1
  182. package/docs/compaction.md +3 -3
  183. package/docs/custom-provider.md +53 -1
  184. package/docs/docs.json +8 -0
  185. package/docs/environment-variables.md +1 -0
  186. package/docs/extensions.md +133 -10
  187. package/docs/llama-cpp.md +1 -1
  188. package/docs/models-configuration.md +196 -0
  189. package/docs/models.md +21 -5
  190. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  191. package/docs/sessions.md +1 -1
  192. package/docs/settings.md +2 -1
  193. package/docs/tui.md +70 -0
  194. package/docs/usage.md +1 -1
  195. package/docs/windows.md +16 -2
  196. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  197. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  198. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  199. package/examples/extensions/gondolin/package-lock.json +2 -2
  200. package/examples/extensions/gondolin/package.json +1 -1
  201. package/examples/extensions/minimal-mode.ts +4 -5
  202. package/examples/extensions/sandbox/package-lock.json +2 -2
  203. package/examples/extensions/sandbox/package.json +1 -1
  204. package/examples/extensions/subagent/index.ts +4 -6
  205. package/examples/extensions/with-deps/package-lock.json +2 -2
  206. package/examples/extensions/with-deps/package.json +1 -1
  207. package/package.json +7 -6
  208. package/schemas/models.schema.json +88 -34
  209. package/schemas/settings.schema.json +18 -0
  210. package/dist/bundle/chunks/anthropic-messages-Q7SXESRX.js +0 -6
  211. package/dist/bundle/chunks/azure-openai-responses-LM52U7CK.js +0 -2
  212. package/dist/bundle/chunks/chunk-3ZATHNCK.js +0 -9
  213. package/dist/bundle/chunks/chunk-HACVPRBJ.js +0 -11
  214. package/dist/bundle/chunks/chunk-ITZNWD4K.js +0 -2
  215. package/dist/bundle/chunks/chunk-TN4NLWHF.js +0 -11
  216. package/dist/bundle/chunks/chunk-WBQBCFWG.js +0 -2
  217. package/dist/bundle/chunks/chunk-XIX7LUWI.js +0 -2
  218. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-UTBL2KOF.js +0 -2
  219. package/dist/bundle/chunks/google-generative-ai-DXKP72HC.js +0 -2
  220. package/dist/bundle/chunks/google-vertex-W6SIDOVV.js +0 -2
  221. package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +0 -13
  222. package/dist/bundle/chunks/mistral-conversations-GBMHTSYF.js +0 -5
  223. package/dist/bundle/chunks/openai-codex-responses-RN6B5UPP.js +0 -10
  224. package/dist/bundle/chunks/openai-completions-QW2B4SML.js +0 -7
  225. package/dist/bundle/chunks/openai-responses-KDJUSIU7.js +0 -3
  226. package/dist/bundle/chunks/openrouter-images-DUPG5DZO.js +0 -2
  227. package/dist/bundle/chunks/pi-messages-YHKPQIHC.js +0 -8
  228. package/dist/bundle/chunks/typesafe-system-one-ZSK3RN4B.js +0 -2
  229. package/dist/bundle/chunks/virtual-modules-KHZAOPVZ.js +0 -2
  230. package/dist/core/provider-attribution.d.ts +0 -4
  231. package/dist/core/provider-attribution.d.ts.map +0 -1
  232. package/dist/core/provider-attribution.js +0 -72
  233. package/dist/core/provider-attribution.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAWxD,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAoB5C,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBzB,CAAC;AAEH,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcvB,CAAC;AAEH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;CACb,CAAC;AAIF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACnE,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACzE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAqBrE,yCAAyC;AACzC,qBAAa,WAAW;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0C;IACpE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAE3C,OAAO,eAGN;IAED,OAAa,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAsC1E;IAED,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE9D;IAED,cAAc,IAAI,SAAS,MAAM,EAAE,CAElC;IAED,QAAQ,IAAI,MAAM,GAAG,SAAS,CAE7B;CACD"}
@@ -16,50 +16,68 @@ const SamplingParamsByThinkingLevelSchema = Type.Object({
16
16
  high: Type.Optional(SamplingParamsSchema),
17
17
  xhigh: Type.Optional(SamplingParamsSchema),
18
18
  max: Type.Optional(SamplingParamsSchema),
19
+ }, { description: "samplingParams per thinking level, merged over samplingParams." });
20
+ const SamplingParamsFieldSchema = Type.Record(Type.String(), Type.Unknown(), {
21
+ description: "Fields merged into every request body. Applies only to OpenAI-compatible APIs.",
19
22
  });
20
- const PositiveTokenCountSchema = Type.Number({ exclusiveMinimum: 0 });
23
+ const HeadersSchema = Type.Record(Type.String(), Type.String(), {
24
+ description: "Request headers. Values resolve like apiKey.",
25
+ });
26
+ /** Model fields shared by models entries and modelOverrides entries. Defaults apply only to models entries. */
27
+ const ModelFieldDescriptions = {
28
+ name: "Display name, also matched by --model patterns.",
29
+ reasoning: "Whether the model supports thinking.",
30
+ contextWindow: "Context window in tokens.",
31
+ maxTokens: "Maximum output tokens.",
32
+ };
21
33
  const ModelDefinitionSchema = Type.Object({
22
- id: Type.String({ minLength: 1 }),
23
- name: Type.Optional(Type.String({ minLength: 1 })),
24
- api: Type.Optional(Type.String({ minLength: 1 })),
25
- baseUrl: Type.Optional(Type.String({ minLength: 1 })),
26
- reasoning: Type.Optional(Type.Boolean()),
34
+ id: Type.String({ minLength: 1, description: "Model ID sent to the API." }),
35
+ name: Type.Optional(Type.String({ minLength: 1, description: ModelFieldDescriptions.name })),
36
+ api: Type.Optional(Type.String({ minLength: 1, description: "Overrides the provider api." })),
37
+ baseUrl: Type.Optional(Type.String({ minLength: 1, description: "Overrides the provider baseUrl." })),
38
+ reasoning: Type.Optional(Type.Boolean({ default: false, description: ModelFieldDescriptions.reasoning })),
27
39
  thinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),
28
- input: Type.Optional(Type.Array(ModelInputModalitySchema)),
40
+ input: Type.Optional(Type.Array(ModelInputModalitySchema, { default: ["text"] })),
29
41
  inputLimits: Type.Optional(ModelInputLimitsSchema),
30
42
  cost: Type.Optional(ModelCostSchema),
31
43
  promptCache: Type.Optional(ModelPromptCacheSchema),
32
- contextWindow: Type.Optional(PositiveTokenCountSchema),
33
- maxTokens: Type.Optional(PositiveTokenCountSchema),
34
- samplingParams: Type.Optional(SamplingParamsSchema),
44
+ contextWindow: Type.Optional(Type.Number({ exclusiveMinimum: 0, default: 128000, description: ModelFieldDescriptions.contextWindow })),
45
+ maxTokens: Type.Optional(Type.Number({ exclusiveMinimum: 0, default: 16384, description: ModelFieldDescriptions.maxTokens })),
46
+ samplingParams: Type.Optional(SamplingParamsFieldSchema),
35
47
  samplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),
36
- headers: Type.Optional(Type.Record(Type.String(), Type.String())),
48
+ headers: Type.Optional(HeadersSchema),
37
49
  compat: Type.Optional(ProviderCompatSchema),
38
50
  });
39
51
  const ModelOverrideSchema = Type.Object({
40
- name: Type.Optional(Type.String({ minLength: 1 })),
41
- reasoning: Type.Optional(Type.Boolean()),
52
+ name: Type.Optional(Type.String({ minLength: 1, description: ModelFieldDescriptions.name })),
53
+ reasoning: Type.Optional(Type.Boolean({ description: ModelFieldDescriptions.reasoning })),
42
54
  thinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),
43
55
  input: Type.Optional(Type.Array(ModelInputModalitySchema)),
44
56
  inputLimits: Type.Optional(ModelInputLimitsSchema),
45
57
  cost: Type.Optional(Type.Partial(ModelCostSchema)),
46
58
  promptCache: Type.Optional(ModelPromptCacheSchema),
47
- contextWindow: Type.Optional(PositiveTokenCountSchema),
48
- maxTokens: Type.Optional(PositiveTokenCountSchema),
49
- samplingParams: Type.Optional(SamplingParamsSchema),
59
+ contextWindow: Type.Optional(Type.Number({ exclusiveMinimum: 0, description: ModelFieldDescriptions.contextWindow })),
60
+ maxTokens: Type.Optional(Type.Number({ exclusiveMinimum: 0, description: ModelFieldDescriptions.maxTokens })),
61
+ samplingParams: Type.Optional(SamplingParamsFieldSchema),
50
62
  samplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),
51
- headers: Type.Optional(Type.Record(Type.String(), Type.String())),
63
+ headers: Type.Optional(HeadersSchema),
52
64
  compat: Type.Optional(ProviderCompatSchema),
53
65
  });
54
66
  const ProviderConfigSchema = Type.Object({
55
- name: Type.Optional(Type.String({ minLength: 1 })),
56
- baseUrl: Type.Optional(Type.String({ minLength: 1 })),
57
- apiKey: Type.Optional(Type.String({ minLength: 1 })),
58
- api: Type.Optional(Type.String({ minLength: 1 })),
59
- oauth: Type.Optional(Type.Literal("radius")),
60
- headers: Type.Optional(Type.Record(Type.String(), Type.String())),
67
+ name: Type.Optional(Type.String({ minLength: 1, description: "Display name." })),
68
+ baseUrl: Type.Optional(Type.String({ minLength: 1, description: "API base URL. Also applies to the provider's built-in models." })),
69
+ apiKey: Type.Optional(Type.String({
70
+ minLength: 1,
71
+ description: 'Literal key, "$NAME" environment interpolation, or "!command" output.',
72
+ })),
73
+ api: Type.Optional(Type.String({
74
+ minLength: 1,
75
+ description: 'API for the provider\'s models, such as "openai-completions", "openai-responses", "anthropic-messages", or "google-generative-ai".',
76
+ })),
77
+ oauth: Type.Optional(Type.Literal("radius", { description: "OAuth login flow. Requires baseUrl." })),
78
+ headers: Type.Optional(HeadersSchema),
61
79
  compat: Type.Optional(ProviderCompatSchema),
62
- authHeader: Type.Optional(Type.Boolean()),
80
+ authHeader: Type.Optional(Type.Boolean({ default: false, description: "Whether to send the resolved API key as Authorization: Bearer." })),
63
81
  models: Type.Optional(Type.Array(ModelDefinitionSchema)),
64
82
  modelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),
65
83
  });
@@ -70,6 +88,12 @@ export const ModelsConfigSchema = Type.Object({
70
88
  $schema: Type.Optional(Type.String()),
71
89
  ...ModelsConfigProperties,
72
90
  });
91
+ /** Entry schemas rendered into docs/models-configuration.md. */
92
+ export const ModelsJsonSchemas = {
93
+ provider: ProviderConfigSchema,
94
+ model: ModelDefinitionSchema,
95
+ modelOverride: ModelOverrideSchema,
96
+ };
73
97
  const validateModelsConfig = Compile(ModelsConfigSchema);
74
98
  function formatValidationPath(error) {
75
99
  if (error.keyword === "required") {
@@ -1 +1 @@
1
- {"version":3,"file":"model-config.js","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AACrF,OAAO,EACN,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,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AC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,UAAkB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,cAAc;QACb,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD","sourcesContent":["/** Immutable, credential-blind models.json snapshot. */\n\nimport { readFile } from \"node:fs/promises\";\nimport { ProviderCompatSchema } from \"@earendil-works/pi-ai/providers/compat-schema\";\nimport {\n\tModelCostSchema,\n\tModelInputLimitsSchema,\n\tModelInputModalitySchema,\n\tModelPromptCacheSchema,\n\tThinkingLevelMapSchema,\n} from \"@earendil-works/pi-ai/providers/model-schema\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { stripJsonComments } from \"../utils/json.ts\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\n\nconst SamplingParamsSchema = Type.Record(Type.String(), Type.Unknown());\nconst SamplingParamsByThinkingLevelSchema = Type.Object({\n\toff: Type.Optional(SamplingParamsSchema),\n\tminimal: Type.Optional(SamplingParamsSchema),\n\tlow: Type.Optional(SamplingParamsSchema),\n\tmedium: Type.Optional(SamplingParamsSchema),\n\thigh: Type.Optional(SamplingParamsSchema),\n\txhigh: Type.Optional(SamplingParamsSchema),\n\tmax: Type.Optional(SamplingParamsSchema),\n});\n\nconst PositiveTokenCountSchema = Type.Number({ exclusiveMinimum: 0 });\n\nconst ModelDefinitionSchema = Type.Object({\n\tid: Type.String({ minLength: 1 }),\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tapi: Type.Optional(Type.String({ minLength: 1 })),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1 })),\n\treasoning: Type.Optional(Type.Boolean()),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(ModelInputModalitySchema)),\n\tinputLimits: Type.Optional(ModelInputLimitsSchema),\n\tcost: Type.Optional(ModelCostSchema),\n\tpromptCache: Type.Optional(ModelPromptCacheSchema),\n\tcontextWindow: Type.Optional(PositiveTokenCountSchema),\n\tmaxTokens: Type.Optional(PositiveTokenCountSchema),\n\tsamplingParams: Type.Optional(SamplingParamsSchema),\n\tsamplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ProviderCompatSchema),\n});\n\nconst ModelOverrideSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\treasoning: Type.Optional(Type.Boolean()),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(ModelInputModalitySchema)),\n\tinputLimits: Type.Optional(ModelInputLimitsSchema),\n\tcost: Type.Optional(Type.Partial(ModelCostSchema)),\n\tpromptCache: Type.Optional(ModelPromptCacheSchema),\n\tcontextWindow: Type.Optional(PositiveTokenCountSchema),\n\tmaxTokens: Type.Optional(PositiveTokenCountSchema),\n\tsamplingParams: Type.Optional(SamplingParamsSchema),\n\tsamplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ProviderCompatSchema),\n});\n\nconst ProviderConfigSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1 })),\n\tapiKey: Type.Optional(Type.String({ minLength: 1 })),\n\tapi: Type.Optional(Type.String({ minLength: 1 })),\n\toauth: Type.Optional(Type.Literal(\"radius\")),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ProviderCompatSchema),\n\tauthHeader: Type.Optional(Type.Boolean()),\n\tmodels: Type.Optional(Type.Array(ModelDefinitionSchema)),\n\tmodelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),\n});\n\nconst ModelsConfigProperties = {\n\tproviders: Type.Record(Type.String(), ProviderConfigSchema),\n};\n\nexport const ModelsConfigSchema = Type.Object({\n\t$schema: Type.Optional(Type.String()),\n\t...ModelsConfigProperties,\n});\n\nconst validateModelsConfig = Compile(ModelsConfigSchema);\n\nexport type ModelsJsonModel = Static<typeof ModelDefinitionSchema>;\nexport type ModelsJsonModelOverride = Static<typeof ModelOverrideSchema>;\nexport type ModelsJsonProvider = Static<typeof ProviderConfigSchema>;\n\nfunction formatValidationPath(error: TLocalizedValidationError): string {\n\tif (error.keyword === \"required\") {\n\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\tconst requiredProperty = requiredProperties?.[0];\n\t\tif (requiredProperty) {\n\t\t\tconst basePath = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\t\t\treturn basePath ? `${basePath}.${requiredProperty}` : requiredProperty;\n\t\t}\n\t}\n\tconst path = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\treturn path || \"root\";\n}\n\nfunction deepFreeze<T>(value: T): T {\n\tif (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n\tfor (const child of Object.values(value)) deepFreeze(child);\n\treturn Object.freeze(value);\n}\n\n/** One immutable load of models.json. */\nexport class ModelConfig {\n\tprivate readonly providers: ReadonlyMap<string, ModelsJsonProvider>;\n\tprivate readonly error: string | undefined;\n\n\tprivate constructor(providers: ReadonlyMap<string, ModelsJsonProvider>, error?: string) {\n\t\tthis.providers = providers;\n\t\tthis.error = error;\n\t}\n\n\tstatic async load(modelsJsonPath: string | undefined): Promise<ModelConfig> {\n\t\tif (!modelsJsonPath) return new ModelConfig(new Map());\n\t\tconst path = normalizePath(modelsJsonPath);\n\t\tlet content: string;\n\t\ttry {\n\t\t\tcontent = await readFile(path, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return new ModelConfig(new Map());\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\t`Failed to load models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(stripJsonComments(stripBom(content)));\n\t\t} catch (error) {\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\t`Failed to parse models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!validateModelsConfig.Check(parsed)) {\n\t\t\tconst errors =\n\t\t\t\tvalidateModelsConfig\n\t\t\t\t\t.Errors(parsed)\n\t\t\t\t\t.map((error) => ` - ${formatValidationPath(error)}: ${error.message}`)\n\t\t\t\t\t.join(\"\\n\") || \"Unknown schema error\";\n\t\t\treturn new ModelConfig(new Map(), `Invalid models.json schema:\\n${errors}\\n\\nFile: ${path}`);\n\t\t}\n\n\t\tconst providers = new Map<string, ModelsJsonProvider>();\n\t\tfor (const [providerId, provider] of Object.entries(parsed.providers)) {\n\t\t\tproviders.set(providerId, deepFreeze(structuredClone(provider)));\n\t\t}\n\t\treturn new ModelConfig(providers);\n\t}\n\n\tgetProvider(providerId: string): ModelsJsonProvider | undefined {\n\t\treturn this.providers.get(providerId);\n\t}\n\n\tgetProviderIds(): readonly string[] {\n\t\treturn [...this.providers.keys()];\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.error;\n\t}\n}\n"]}
1
+ {"version":3,"file":"model-config.js","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC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CAAC,IAAI,sBAAsB,CAAC;YACxC,OAAO,IAAI,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE,gCAAgC,MAAM,aAAa,IAAI,EAAE,CAAC,CAAC;QAC9F,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,GAAG,EAA8B,CAAC;QACxD,KAAK,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACvE,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,UAAkB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,cAAc;QACb,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD","sourcesContent":["/** Immutable, credential-blind models.json snapshot. */\n\nimport { readFile } from \"node:fs/promises\";\nimport { ProviderCompatSchema } from \"@earendil-works/pi-ai/providers/compat-schema\";\nimport {\n\tModelCostSchema,\n\tModelInputLimitsSchema,\n\tModelInputModalitySchema,\n\tModelPromptCacheSchema,\n\tThinkingLevelMapSchema,\n} from \"@earendil-works/pi-ai/providers/model-schema\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { stripJsonComments } from \"../utils/json.ts\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\n\nconst SamplingParamsSchema = Type.Record(Type.String(), Type.Unknown());\nconst SamplingParamsByThinkingLevelSchema = Type.Object(\n\t{\n\t\toff: Type.Optional(SamplingParamsSchema),\n\t\tminimal: Type.Optional(SamplingParamsSchema),\n\t\tlow: Type.Optional(SamplingParamsSchema),\n\t\tmedium: Type.Optional(SamplingParamsSchema),\n\t\thigh: Type.Optional(SamplingParamsSchema),\n\t\txhigh: Type.Optional(SamplingParamsSchema),\n\t\tmax: Type.Optional(SamplingParamsSchema),\n\t},\n\t{ description: \"samplingParams per thinking level, merged over samplingParams.\" },\n);\n\nconst SamplingParamsFieldSchema = Type.Record(Type.String(), Type.Unknown(), {\n\tdescription: \"Fields merged into every request body. Applies only to OpenAI-compatible APIs.\",\n});\nconst HeadersSchema = Type.Record(Type.String(), Type.String(), {\n\tdescription: \"Request headers. Values resolve like apiKey.\",\n});\n\n/** Model fields shared by models entries and modelOverrides entries. Defaults apply only to models entries. */\nconst ModelFieldDescriptions = {\n\tname: \"Display name, also matched by --model patterns.\",\n\treasoning: \"Whether the model supports thinking.\",\n\tcontextWindow: \"Context window in tokens.\",\n\tmaxTokens: \"Maximum output tokens.\",\n} as const;\n\nconst ModelDefinitionSchema = Type.Object({\n\tid: Type.String({ minLength: 1, description: \"Model ID sent to the API.\" }),\n\tname: Type.Optional(Type.String({ minLength: 1, description: ModelFieldDescriptions.name })),\n\tapi: Type.Optional(Type.String({ minLength: 1, description: \"Overrides the provider api.\" })),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1, description: \"Overrides the provider baseUrl.\" })),\n\treasoning: Type.Optional(Type.Boolean({ default: false, description: ModelFieldDescriptions.reasoning })),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(ModelInputModalitySchema, { default: [\"text\"] })),\n\tinputLimits: Type.Optional(ModelInputLimitsSchema),\n\tcost: Type.Optional(ModelCostSchema),\n\tpromptCache: Type.Optional(ModelPromptCacheSchema),\n\tcontextWindow: Type.Optional(\n\t\tType.Number({ exclusiveMinimum: 0, default: 128000, description: ModelFieldDescriptions.contextWindow }),\n\t),\n\tmaxTokens: Type.Optional(\n\t\tType.Number({ exclusiveMinimum: 0, default: 16384, description: ModelFieldDescriptions.maxTokens }),\n\t),\n\tsamplingParams: Type.Optional(SamplingParamsFieldSchema),\n\tsamplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),\n\theaders: Type.Optional(HeadersSchema),\n\tcompat: Type.Optional(ProviderCompatSchema),\n});\n\nconst ModelOverrideSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1, description: ModelFieldDescriptions.name })),\n\treasoning: Type.Optional(Type.Boolean({ description: ModelFieldDescriptions.reasoning })),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(ModelInputModalitySchema)),\n\tinputLimits: Type.Optional(ModelInputLimitsSchema),\n\tcost: Type.Optional(Type.Partial(ModelCostSchema)),\n\tpromptCache: Type.Optional(ModelPromptCacheSchema),\n\tcontextWindow: Type.Optional(\n\t\tType.Number({ exclusiveMinimum: 0, description: ModelFieldDescriptions.contextWindow }),\n\t),\n\tmaxTokens: Type.Optional(Type.Number({ exclusiveMinimum: 0, description: ModelFieldDescriptions.maxTokens })),\n\tsamplingParams: Type.Optional(SamplingParamsFieldSchema),\n\tsamplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),\n\theaders: Type.Optional(HeadersSchema),\n\tcompat: Type.Optional(ProviderCompatSchema),\n});\n\nconst ProviderConfigSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1, description: \"Display name.\" })),\n\tbaseUrl: Type.Optional(\n\t\tType.String({ minLength: 1, description: \"API base URL. Also applies to the provider's built-in models.\" }),\n\t),\n\tapiKey: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription: 'Literal key, \"$NAME\" environment interpolation, or \"!command\" output.',\n\t\t}),\n\t),\n\tapi: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t'API for the provider\\'s models, such as \"openai-completions\", \"openai-responses\", \"anthropic-messages\", or \"google-generative-ai\".',\n\t\t}),\n\t),\n\toauth: Type.Optional(Type.Literal(\"radius\", { description: \"OAuth login flow. Requires baseUrl.\" })),\n\theaders: Type.Optional(HeadersSchema),\n\tcompat: Type.Optional(ProviderCompatSchema),\n\tauthHeader: Type.Optional(\n\t\tType.Boolean({ default: false, description: \"Whether to send the resolved API key as Authorization: Bearer.\" }),\n\t),\n\tmodels: Type.Optional(Type.Array(ModelDefinitionSchema)),\n\tmodelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),\n});\n\nconst ModelsConfigProperties = {\n\tproviders: Type.Record(Type.String(), ProviderConfigSchema),\n};\n\nexport const ModelsConfigSchema = Type.Object({\n\t$schema: Type.Optional(Type.String()),\n\t...ModelsConfigProperties,\n});\n\n/** Entry schemas rendered into docs/models-configuration.md. */\nexport const ModelsJsonSchemas = {\n\tprovider: ProviderConfigSchema,\n\tmodel: ModelDefinitionSchema,\n\tmodelOverride: ModelOverrideSchema,\n};\n\nconst validateModelsConfig = Compile(ModelsConfigSchema);\n\nexport type ModelsJsonModel = Static<typeof ModelDefinitionSchema>;\nexport type ModelsJsonModelOverride = Static<typeof ModelOverrideSchema>;\nexport type ModelsJsonProvider = Static<typeof ProviderConfigSchema>;\n\nfunction formatValidationPath(error: TLocalizedValidationError): string {\n\tif (error.keyword === \"required\") {\n\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\tconst requiredProperty = requiredProperties?.[0];\n\t\tif (requiredProperty) {\n\t\t\tconst basePath = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\t\t\treturn basePath ? `${basePath}.${requiredProperty}` : requiredProperty;\n\t\t}\n\t}\n\tconst path = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\treturn path || \"root\";\n}\n\nfunction deepFreeze<T>(value: T): T {\n\tif (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n\tfor (const child of Object.values(value)) deepFreeze(child);\n\treturn Object.freeze(value);\n}\n\n/** One immutable load of models.json. */\nexport class ModelConfig {\n\tprivate readonly providers: ReadonlyMap<string, ModelsJsonProvider>;\n\tprivate readonly error: string | undefined;\n\n\tprivate constructor(providers: ReadonlyMap<string, ModelsJsonProvider>, error?: string) {\n\t\tthis.providers = providers;\n\t\tthis.error = error;\n\t}\n\n\tstatic async load(modelsJsonPath: string | undefined): Promise<ModelConfig> {\n\t\tif (!modelsJsonPath) return new ModelConfig(new Map());\n\t\tconst path = normalizePath(modelsJsonPath);\n\t\tlet content: string;\n\t\ttry {\n\t\t\tcontent = await readFile(path, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return new ModelConfig(new Map());\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\t`Failed to load models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(stripJsonComments(stripBom(content)));\n\t\t} catch (error) {\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\t`Failed to parse models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!validateModelsConfig.Check(parsed)) {\n\t\t\tconst errors =\n\t\t\t\tvalidateModelsConfig\n\t\t\t\t\t.Errors(parsed)\n\t\t\t\t\t.map((error) => ` - ${formatValidationPath(error)}: ${error.message}`)\n\t\t\t\t\t.join(\"\\n\") || \"Unknown schema error\";\n\t\t\treturn new ModelConfig(new Map(), `Invalid models.json schema:\\n${errors}\\n\\nFile: ${path}`);\n\t\t}\n\n\t\tconst providers = new Map<string, ModelsJsonProvider>();\n\t\tfor (const [providerId, provider] of Object.entries(parsed.providers)) {\n\t\t\tproviders.set(providerId, deepFreeze(structuredClone(provider)));\n\t\t}\n\t\treturn new ModelConfig(providers);\n\t}\n\n\tgetProvider(providerId: string): ModelsJsonProvider | undefined {\n\t\treturn this.providers.get(providerId);\n\t}\n\n\tgetProviderIds(): readonly string[] {\n\t\treturn [...this.providers.keys()];\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.error;\n\t}\n}\n"]}
@@ -11,48 +11,57 @@ export interface ScopedModel {
11
11
  /** Thinking level if explicitly specified in pattern (e.g., "model:high"), undefined otherwise */
12
12
  thinkingLevel?: ThinkingLevel;
13
13
  }
14
- /**
15
- * Find an exact model reference match.
16
- * Supports either a bare model id or a canonical provider/modelId reference.
17
- * When matching by bare id, ambiguous matches across providers are rejected.
18
- */
19
- export declare function findExactModelReferenceMatch(modelReference: string, availableModels: Model<Api>[]): Model<Api> | undefined;
20
- export interface ParsedModelResult {
21
- model: Model<Api> | undefined;
22
- /** Thinking level if explicitly specified in pattern, undefined otherwise */
14
+ export interface ModelReferenceRequest {
15
+ /** Bare model id or `provider/id`, optionally followed by `:<thinking>`. */
16
+ text: string;
17
+ /** Only consider models from this provider. */
18
+ provider?: string;
19
+ /**
20
+ * A trailing `:<suffix>` is only considered when the full text matches no model, since ids such as
21
+ * OpenRouter's `qwen/qwen3-coder:exacto` contain colons.
22
+ * - `none`: the suffix stays part of the id
23
+ * - `strict`: a valid thinking level is parsed; any other suffix stays part of the id
24
+ * - `lenient`: like `strict`, but an invalid suffix is dropped with a warning
25
+ */
26
+ thinkingSuffix: "none" | "strict" | "lenient";
27
+ /** Match id and name substrings when no exact match exists. */
28
+ fuzzy: boolean;
29
+ }
30
+ export type ModelReferenceResult = {
31
+ status: "resolved";
32
+ model: Model<Api>;
33
+ thinkingLevel?: ThinkingLevel;
34
+ warning?: string;
35
+ } | {
36
+ status: "ambiguous";
37
+ candidates: Model<Api>[];
38
+ usableCount: number;
39
+ thinkingLevel?: ThinkingLevel;
40
+ warning?: string;
41
+ } | {
42
+ status: "not-found";
43
+ /** Set when a provider is explicit or named by a `provider/` prefix, for building a custom model id. */
44
+ target?: ModelReferenceTarget;
45
+ };
46
+ export interface ModelReferenceTarget {
47
+ provider: string;
48
+ providerModels: [Model<Api>, ...Model<Api>[]];
49
+ /** Text after the provider prefix as typed, including any `:<suffix>`. */
50
+ modelText: string;
51
+ /** `modelText` without a valid thinking suffix (unless `thinkingSuffix` is `none`). */
52
+ modelId: string;
23
53
  thinkingLevel?: ThinkingLevel;
24
- warning: string | undefined;
25
54
  }
26
55
  /**
27
- * Parse a pattern to extract model and thinking level.
28
- * Handles models with colons in their IDs (e.g., OpenRouter's :exacto suffix).
29
- *
30
- * Algorithm:
31
- * 1. Try to match full pattern as a model
32
- * 2. If found, return it with "off" thinking level
33
- * 3. If not found and has colons, split on last colon:
34
- * - If suffix is valid thinking level, use it and recurse on prefix
35
- * - If suffix is invalid, warn and recurse on prefix with "off"
36
- *
37
- * @internal Exported for testing
38
- */
39
- export declare function parseModelPattern(pattern: string, availableModels: Model<Api>[], options?: {
40
- allowInvalidThinkingLevelFallback?: boolean;
41
- }): ParsedModelResult;
42
- /**
43
- * Resolve model patterns to actual Model objects with optional thinking levels
44
- * Format: "pattern:level" where :level is optional
45
- * For each pattern, finds all matching models and picks the best version:
46
- * 1. Prefer alias (e.g., claude-sonnet-4-5) over dated versions (claude-sonnet-4-5-20250929)
47
- * 2. If no alias, pick the latest dated version
48
- *
49
- * Supports models with colons in their IDs (e.g., OpenRouter's model:exacto).
50
- * The algorithm tries to match the full pattern first, then progressively
51
- * strips colon-suffixes to find a match.
56
+ * `usable` only breaks ties between providers, so a unique match resolves even without credentials
57
+ * (`--api-key` first-time setup).
52
58
  */
59
+ export declare function resolveModelReference(request: ModelReferenceRequest, models: readonly Model<Api>[], usable: (provider: string) => boolean): ModelReferenceResult;
60
+ /** Exact `provider/id` or bare id lookup without thinking suffixes or fuzzy matching. */
61
+ export declare function findExactModelReferenceMatch(modelReference: string, models: readonly Model<Api>[]): Model<Api> | undefined;
53
62
  export interface ModelScopeDiagnostic {
54
63
  type: "warning";
55
- code: "no-match" | "invalid-thinking-level";
64
+ code: "no-match" | "invalid-thinking-level" | "ambiguous";
56
65
  message: string;
57
66
  pattern: string;
58
67
  }
@@ -60,6 +69,12 @@ export interface ResolveModelScopeResult {
60
69
  scopedModels: ScopedModel[];
61
70
  diagnostics: ModelScopeDiagnostic[];
62
71
  }
72
+ /**
73
+ * Resolve scope patterns (`--models`, `enabledModels`) to models with optional thinking levels.
74
+ *
75
+ * Every model in `models` is usable, so credentials cannot choose between providers offering the same
76
+ * id. All of them are added, with a warning so the user can pick one with `provider/id`.
77
+ */
63
78
  export declare function resolveModelScopeFromModels(patterns: string[], models: readonly Model<Api>[]): ResolveModelScopeResult;
64
79
  export declare function resolveModelScopeWithDiagnostics(patterns: string[], modelRuntime: ModelRuntime, options?: AuthOperationOptions): Promise<ResolveModelScopeResult>;
65
80
  export declare function resolveModelScope(patterns: string[], modelRuntime: ModelRuntime, options?: AuthOperationOptions): Promise<ScopedModel[]>;
@@ -88,6 +103,8 @@ export declare function resolveCliModel(options: {
88
103
  cliProvider?: string;
89
104
  cliModel?: string;
90
105
  cliThinking?: ThinkingLevel;
106
+ /** `--api-key` was supplied for the selected provider. */
107
+ inlineApiKey?: boolean;
91
108
  modelRuntime: ModelRuntime;
92
109
  }): ResolveCliModelResult;
93
110
  export interface InitialModelResult {
@@ -97,15 +114,11 @@ export interface InitialModelResult {
97
114
  }
98
115
  /**
99
116
  * Find the initial model to use based on priority:
100
- * 1. CLI args (provider + model)
101
- * 2. First model from scoped models (if not continuing/resuming)
102
- * 3. Restored from session (if continuing/resuming)
103
- * 4. Saved default from settings
104
- * 5. First available model with valid API key
117
+ * 1. First model from scoped models (if not continuing/resuming)
118
+ * 2. Saved default from settings
119
+ * 3. First available model with valid API key
105
120
  */
106
121
  export declare function findInitialModel(options: {
107
- cliProvider?: string;
108
- cliModel?: string;
109
122
  scopedModels: ScopedModel[];
110
123
  isContinuing: boolean;
111
124
  defaultProvider?: string;
@@ -1 +1 @@
1
- {"version":3,"file":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