@cjhyy/code-shell 0.1.0-alpha.2 → 0.1.5

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 (157) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/anthropic-IBTI4WL2.cjs +10 -0
  3. package/dist/anthropic-PRZZKHEZ.js +10 -0
  4. package/dist/arena/index.cjs +7 -6
  5. package/dist/arena/index.js +6 -5
  6. package/dist/arena/model-presets.d.ts +10 -1
  7. package/dist/{arena-HHDYYVHJ.cjs → arena-KBQOPLFV.cjs} +25 -23
  8. package/dist/{arena-ENHBHB2W.js → arena-O2L4TN6A.js} +9 -7
  9. package/dist/{chunk-SW3L7HIM.js → chunk-2EP3CLEN.js} +2 -2
  10. package/dist/{chunk-EL2RL5DG.cjs → chunk-2YW4FPFG.cjs} +2 -2
  11. package/dist/chunk-3OA5G4TM.js +47 -0
  12. package/dist/chunk-52LGZKT3.cjs +47 -0
  13. package/dist/{chunk-KOGV6PDQ.cjs → chunk-55XGPMAP.cjs} +44 -9
  14. package/dist/chunk-5ECBT4YA.js +450 -0
  15. package/dist/{chunk-YD7XTI7T.cjs → chunk-6QVAYW7C.cjs} +116 -28
  16. package/dist/{chunk-SCDKLTN3.js → chunk-6S4BJ65N.js} +5 -4
  17. package/dist/{chunk-ZLPJJZUW.js → chunk-76HYEPDM.js} +2 -2
  18. package/dist/{chunk-FA5KD34T.js → chunk-76W334S4.js} +2 -2
  19. package/dist/{chunk-GZBD6QRS.cjs → chunk-7EG3V4JY.cjs} +13 -12
  20. package/dist/{chunk-LMEKCQX4.js → chunk-7JVTYEEC.js} +6 -6
  21. package/dist/{chunk-ID6EJUHP.js → chunk-7K6SDRRF.js} +1262 -212
  22. package/dist/{chunk-5C5HIOML.js → chunk-7Y6S3OCX.js} +109 -21
  23. package/dist/{chunk-G76E5FOB.cjs → chunk-A5LCRPDP.cjs} +4 -4
  24. package/dist/{chunk-F5BS3GUC.js → chunk-BSW22MPA.js} +39 -4
  25. package/dist/{chunk-VWFET3MG.cjs → chunk-BUU5PZK2.cjs} +1474 -423
  26. package/dist/{chunk-HOXQLX5R.cjs → chunk-BWTOS5BH.cjs} +444 -103
  27. package/dist/{chunk-ZRVPCXI7.js → chunk-BXCY2FSE.js} +2 -1
  28. package/dist/{chunk-Y7TSCDF6.js → chunk-C5YQBIRK.js} +347 -6
  29. package/dist/{chunk-C7C7ZZY4.cjs → chunk-HEKQCI7B.cjs} +10 -10
  30. package/dist/{chunk-JHXNOB5G.cjs → chunk-HS2MFNUC.cjs} +6 -6
  31. package/dist/{chunk-JHNCK7JP.cjs → chunk-IK4EWJBP.cjs} +4 -3
  32. package/dist/{chunk-M2QI5X3X.cjs → chunk-JMR33QVF.cjs} +2 -2
  33. package/dist/{chunk-YAFCN7ZW.cjs → chunk-KOVYSDHZ.cjs} +15 -15
  34. package/dist/{chunk-IJSHQGMP.cjs → chunk-KS3RYAYL.cjs} +4 -4
  35. package/dist/{chunk-DI7RDLOS.js → chunk-MD32R22I.js} +7 -4
  36. package/dist/chunk-MY5XHADU.cjs +216 -0
  37. package/dist/{chunk-OP57WUWQ.cjs → chunk-NUNC3VFB.cjs} +6 -6
  38. package/dist/{chunk-TATCTZSB.cjs → chunk-QRM7IF2S.cjs} +133 -175
  39. package/dist/chunk-R47ROHGL.cjs +298 -0
  40. package/dist/{chunk-OUC2DFA7.js → chunk-RMYKO74M.js} +3 -3
  41. package/dist/{chunk-FUOKLKR2.js → chunk-SFXHZSRF.js} +1 -1
  42. package/dist/{chunk-2EUAE7AY.js → chunk-SIHHIQLO.js} +2 -2
  43. package/dist/{chunk-3CAZIWUA.cjs → chunk-SNT563K3.cjs} +9 -9
  44. package/dist/{chunk-SK62UVS6.js → chunk-T6VYG46N.js} +1 -1
  45. package/dist/{chunk-3QR52LL5.cjs → chunk-TUY2T5KP.cjs} +2 -2
  46. package/dist/{chunk-I57ZD5IQ.js → chunk-VIAGTYYW.js} +1 -1
  47. package/dist/{chunk-X2DNIMPC.cjs → chunk-VYL4EFRC.cjs} +32 -32
  48. package/dist/chunk-W22P377T.js +299 -0
  49. package/dist/chunk-WASS5YWB.js +215 -0
  50. package/dist/{chunk-OMRGA6TI.js → chunk-XDIQWQJ4.js} +132 -174
  51. package/dist/{chunk-BUJ5KYCI.cjs → chunk-YIQBXAYU.cjs} +13 -13
  52. package/dist/{chunk-REFCCVDM.js → chunk-YJ77GQK5.js} +2 -2
  53. package/dist/chunk-YUI524OE.cjs +450 -0
  54. package/dist/{chunk-M2SVOKC6.js → chunk-ZBPSQCPU.js} +6 -6
  55. package/dist/cli/commands/builtin/export-md.d.ts +19 -0
  56. package/dist/cli/commands/builtin/init/detect.d.ts +25 -0
  57. package/dist/cli/commands/builtin/init/index.d.ts +19 -0
  58. package/dist/cli/main.cjs +2374 -1455
  59. package/dist/cli/main.js +2505 -1586
  60. package/dist/cli/migrate-models.d.ts +45 -0
  61. package/dist/cli/onboarding.d.ts +110 -5
  62. package/dist/cli/updater.d.ts +51 -4
  63. package/dist/client-base-HTF236ZD.cjs +9 -0
  64. package/dist/client-base-QKRKCOWB.js +9 -0
  65. package/dist/{compaction-YNWCEF7B.js → compaction-6VU2T643.js} +4 -2
  66. package/dist/compaction-OKUNTCA7.cjs +33 -0
  67. package/dist/context/compaction.d.ts +35 -3
  68. package/dist/context/manager.d.ts +40 -3
  69. package/dist/context/tool-result-storage.d.ts +96 -0
  70. package/dist/devtools-T2NIZBJK.cjs +6 -0
  71. package/dist/{devtools-IRQQPIRY.js → devtools-YXWHOVKR.js} +1 -1
  72. package/dist/engine/engine.d.ts +40 -0
  73. package/dist/engine/turn-loop.d.ts +6 -0
  74. package/dist/export-md-RXDW6F5W.cjs +135 -0
  75. package/dist/export-md-XXKZANW5.js +135 -0
  76. package/dist/file-history-KYPE3ECT.cjs +7 -0
  77. package/dist/file-history-LF4F7X26.js +7 -0
  78. package/dist/index.cjs +42 -22
  79. package/dist/index.d.ts +5 -2
  80. package/dist/index.js +40 -20
  81. package/dist/llm/client-base.d.ts +1 -1
  82. package/dist/llm/model-cache.d.ts +21 -0
  83. package/dist/llm/model-fetcher.d.ts +29 -0
  84. package/dist/llm/model-pool.d.ts +13 -0
  85. package/dist/llm/provider-catalog.d.ts +30 -0
  86. package/dist/llm/provider-kinds.d.ts +21 -0
  87. package/dist/llm/types.d.ts +8 -0
  88. package/dist/logging/session-recorder.d.ts +77 -0
  89. package/dist/manager-C2IUXKRC.js +7 -0
  90. package/dist/manager-YYKWYTRM.cjs +7 -0
  91. package/dist/mcp-manager-QMKWPBZ4.js +8 -0
  92. package/dist/mcp-manager-Z3OKI74O.cjs +8 -0
  93. package/dist/memory-5LWZ6FI2.cjs +9 -0
  94. package/dist/{memory-EPFDBPII.js → memory-VIJLBAMQ.js} +2 -2
  95. package/dist/model-cache-5KIYL5SL.js +13 -0
  96. package/dist/model-cache-OED3IM4R.cjs +13 -0
  97. package/dist/model-fetcher-HKGICACL.js +8 -0
  98. package/dist/model-fetcher-UR6WJOQP.cjs +8 -0
  99. package/dist/openai-JR2WEKOF.js +10 -0
  100. package/dist/openai-YBTOET4O.cjs +10 -0
  101. package/dist/openrouter-models-OU4GRZQY.cjs +15 -0
  102. package/dist/{openrouter-models-OL725CL6.js → openrouter-models-TGKDKY52.js} +2 -2
  103. package/dist/openrouter-sync-BBHUM3R6.cjs +11 -0
  104. package/dist/{openrouter-sync-CWD5VNW2.js → openrouter-sync-UXUSJCIR.js} +3 -3
  105. package/dist/product/index.cjs +17 -15
  106. package/dist/product/index.js +16 -14
  107. package/dist/protocol/server.d.ts +3 -1
  108. package/dist/protocol/types.d.ts +36 -2
  109. package/dist/run/index.cjs +17 -15
  110. package/dist/run/index.js +16 -14
  111. package/dist/services/index.d.ts +0 -1
  112. package/dist/session-manager-Q22BBMD3.js +8 -0
  113. package/dist/session-manager-XODQVL3C.cjs +8 -0
  114. package/dist/settings/schema.d.ts +267 -42
  115. package/dist/{tool-summary-RYNR4DDB.cjs → tool-summary-63DPIS7G.cjs} +4 -4
  116. package/dist/{tool-summary-2RUFL5QK.js → tool-summary-NP5CDBKG.js} +2 -2
  117. package/dist/tool-system/builtin/ask-user.d.ts +9 -1
  118. package/dist/tool-system/context.d.ts +31 -2
  119. package/dist/tool-system/executor.d.ts +4 -0
  120. package/dist/tool-system/investigation-guard.d.ts +37 -0
  121. package/dist/types.d.ts +13 -2
  122. package/dist/ui/components/AskUserPrompt.d.ts +8 -1
  123. package/dist/ui/components/DiffLine.d.ts +33 -0
  124. package/dist/ui/components/ModelManager.d.ts +34 -1
  125. package/dist/ui/components/OnboardingPrompt.d.ts +10 -1
  126. package/dist/ui/components/ProviderModelFlow.d.ts +58 -0
  127. package/dist/ui/components/UpdateBanner.d.ts +1 -0
  128. package/dist/updater-QW473OF4.cjs +17 -0
  129. package/dist/updater-VFUAHCVY.js +17 -0
  130. package/dist/utils/semver.d.ts +1 -0
  131. package/dist/utils/task-sanitizer.d.ts +6 -0
  132. package/package.json +4 -2
  133. package/scripts/check-node.cjs +21 -0
  134. package/dist/anthropic-P5VETAFI.cjs +0 -10
  135. package/dist/anthropic-W2GU3D76.js +0 -10
  136. package/dist/chunk-75E4BBFC.js +0 -224
  137. package/dist/chunk-FV2ARONZ.cjs +0 -224
  138. package/dist/client-base-TOVE25FA.js +0 -9
  139. package/dist/client-base-VDDIADAC.cjs +0 -9
  140. package/dist/compaction-D3KV2NWY.cjs +0 -31
  141. package/dist/devtools-WTC3NFNE.cjs +0 -6
  142. package/dist/file-history-HZWO2WQ5.js +0 -7
  143. package/dist/file-history-UQQILIY7.cjs +0 -7
  144. package/dist/manager-FWLOVEEK.cjs +0 -7
  145. package/dist/manager-GEXJLOIS.js +0 -7
  146. package/dist/mcp-manager-37GQLFGX.js +0 -8
  147. package/dist/mcp-manager-U77NEXBY.cjs +0 -8
  148. package/dist/memory-ADGOWADP.cjs +0 -9
  149. package/dist/openai-RXU5URYI.js +0 -10
  150. package/dist/openai-SQW4H2K4.cjs +0 -10
  151. package/dist/openrouter-models-UM3AOGZ4.cjs +0 -15
  152. package/dist/openrouter-sync-HYZZC6RX.cjs +0 -11
  153. package/dist/services/compact.d.ts +0 -56
  154. package/dist/session-manager-HRSKENKB.cjs +0 -8
  155. package/dist/session-manager-NEKFEHF3.js +0 -8
  156. package/dist/updater-M7L42ASZ.cjs +0 -183
  157. package/dist/updater-ZRTONIR4.js +0 -183
@@ -2,7 +2,7 @@ import {
2
2
  __esm,
3
3
  __export,
4
4
  init_esm_shims
5
- } from "./chunk-DI7RDLOS.js";
5
+ } from "./chunk-MD32R22I.js";
6
6
 
7
7
  // src/context/token-counter.ts
8
8
  function estimateStringTokens(text) {
@@ -70,6 +70,7 @@ var init_token_counter = __esm({
70
70
  // src/context/compaction.ts
71
71
  var compaction_exports = {};
72
72
  __export(compaction_exports, {
73
+ COMPACTABLE_TOOL_NAMES: () => COMPACTABLE_TOOL_NAMES,
73
74
  adjustIndexToPreserveAPIInvariants: () => adjustIndexToPreserveAPIInvariants,
74
75
  applySummaryCompaction: () => applySummaryCompaction,
75
76
  applyToolResultBudget: () => applyToolResultBudget,
@@ -143,35 +144,108 @@ function windowCompact(messages, keepLastN) {
143
144
  if (startIndex <= 1) return messages;
144
145
  return [messages[0], ...messages.slice(startIndex)];
145
146
  }
146
- function microcompact(messages, keepRecentN = 3) {
147
- let toolResultCount = 0;
148
- const indices = [];
147
+ function buildToolUseIdToNameMap(messages) {
148
+ const map = /* @__PURE__ */ new Map();
149
+ for (const msg of messages) {
150
+ if (!Array.isArray(msg.content)) continue;
151
+ for (const block of msg.content) {
152
+ if (block.type === "tool_use" && block.id && block.name) {
153
+ map.set(block.id, block.name);
154
+ }
155
+ }
156
+ }
157
+ return map;
158
+ }
159
+ function summarizeToolCallArgs(toolName, input) {
160
+ if (!input || typeof input !== "object") return "";
161
+ const pick = (keys) => {
162
+ const parts = [];
163
+ for (const key of keys) {
164
+ const v = input[key];
165
+ if (typeof v === "string" && v.length > 0) {
166
+ parts.push(`${key}=${v.length > 80 ? v.slice(0, 77) + "..." : v}`);
167
+ }
168
+ }
169
+ return parts.join(" ");
170
+ };
171
+ switch (toolName) {
172
+ case "Read":
173
+ case "Write":
174
+ case "Edit":
175
+ case "NotebookEdit":
176
+ return pick(["file_path", "path", "notebook_path"]);
177
+ case "Glob":
178
+ case "Grep":
179
+ return pick(["pattern", "path", "glob"]);
180
+ case "Bash":
181
+ case "PowerShell":
182
+ case "REPL":
183
+ return pick(["command"]);
184
+ case "WebFetch":
185
+ case "WebSearch":
186
+ return pick(["url", "query"]);
187
+ default: {
188
+ const json = JSON.stringify(input);
189
+ return json.length > 100 ? json.slice(0, 97) + "..." : json;
190
+ }
191
+ }
192
+ }
193
+ function microcompact(messages, options = {}) {
194
+ const keepRecentN = options.keepRecentN ?? 5;
195
+ const compactable = options.compactableTools ?? COMPACTABLE_TOOL_NAMES;
196
+ const idToName = buildToolUseIdToNameMap(messages);
197
+ const idToInput = /* @__PURE__ */ new Map();
198
+ for (const msg of messages) {
199
+ if (!Array.isArray(msg.content)) continue;
200
+ for (const block of msg.content) {
201
+ if (block.type === "tool_use" && block.id) {
202
+ idToInput.set(block.id, block.input);
203
+ }
204
+ }
205
+ }
206
+ let compactableRoundCount = 0;
207
+ const indicesToTouch = [];
149
208
  for (let i = messages.length - 1; i >= 0; i--) {
150
209
  const msg = messages[i];
151
- if (Array.isArray(msg.content)) {
152
- const hasToolResult = msg.content.some((b) => b.type === "tool_result");
153
- if (hasToolResult) {
154
- toolResultCount++;
155
- if (toolResultCount > keepRecentN) {
156
- indices.push(i);
157
- }
158
- }
210
+ if (!Array.isArray(msg.content)) continue;
211
+ const hasEligible = msg.content.some(
212
+ (b) => b.type === "tool_result" && b.tool_use_id != null && compactable.has(idToName.get(b.tool_use_id) ?? "") && typeof b.content === "string" && !b.content.startsWith("[Old tool result cleared")
213
+ );
214
+ if (!hasEligible) continue;
215
+ compactableRoundCount++;
216
+ if (compactableRoundCount > keepRecentN) {
217
+ indicesToTouch.push(i);
159
218
  }
160
219
  }
161
- if (indices.length === 0) return messages;
162
- return messages.map((msg, i) => {
163
- if (!indices.includes(i)) return msg;
164
- if (!Array.isArray(msg.content)) return msg;
220
+ if (indicesToTouch.length === 0) return messages;
221
+ const touchSet = new Set(indicesToTouch);
222
+ const clearedToolNames = /* @__PURE__ */ new Set();
223
+ let clearedBlocks = 0;
224
+ const result = messages.map((msg, i) => {
225
+ if (!touchSet.has(i) || !Array.isArray(msg.content)) return msg;
165
226
  return {
166
227
  ...msg,
167
228
  content: msg.content.map((block) => {
168
- if (block.type === "tool_result") {
169
- return { ...block, content: "[Old tool result content cleared]" };
170
- }
171
- return block;
229
+ if (block.type !== "tool_result" || !block.tool_use_id) return block;
230
+ const toolName = idToName.get(block.tool_use_id);
231
+ if (!toolName || !compactable.has(toolName)) return block;
232
+ if (typeof block.content !== "string") return block;
233
+ if (block.content.startsWith("[Old tool result cleared")) return block;
234
+ const argsSummary = summarizeToolCallArgs(toolName, idToInput.get(block.tool_use_id));
235
+ const fingerprint = argsSummary ? `[Old tool result cleared \u2014 ${toolName} ${argsSummary}]` : `[Old tool result cleared \u2014 ${toolName}]`;
236
+ clearedToolNames.add(toolName);
237
+ clearedBlocks++;
238
+ return { ...block, content: fingerprint };
172
239
  })
173
240
  };
174
241
  });
242
+ if (clearedBlocks > 0) {
243
+ options.onClear?.({
244
+ clearedRounds: indicesToTouch.length,
245
+ toolNames: [...clearedToolNames].sort()
246
+ });
247
+ }
248
+ return result;
175
249
  }
176
250
  function applyToolResultBudget(messages, maxTotalChars = 1e5) {
177
251
  return messages.map((msg) => {
@@ -200,9 +274,10 @@ function applyToolResultBudget(messages, maxTotalChars = 1e5) {
200
274
  const newContent = msg.content.map((block, i) => {
201
275
  if (!toTruncate.has(i)) return block;
202
276
  const preview = typeof block.content === "string" ? block.content.slice(0, 500) : "";
277
+ const sizeKb = (block.content.length / 1e3).toFixed(0);
203
278
  return {
204
279
  ...block,
205
- content: `Output too large (${(block.content.length / 1e3).toFixed(0)}KB). Full output saved to session transcript. Use Read tool to view the source file if needed.
280
+ content: `Output too large (${sizeKb}KB) \u2014 truncated to fit the per-message budget. Re-run the originating tool if you need the full output.
206
281
 
207
282
  Preview (first 500 chars):
208
283
  ${preview}`
@@ -325,10 +400,22 @@ function extractReferencedFilePaths(messages) {
325
400
  }
326
401
  return [...paths];
327
402
  }
403
+ var COMPACTABLE_TOOL_NAMES;
328
404
  var init_compaction = __esm({
329
405
  "src/context/compaction.ts"() {
330
406
  init_esm_shims();
331
407
  init_token_counter();
408
+ COMPACTABLE_TOOL_NAMES = /* @__PURE__ */ new Set([
409
+ "Read",
410
+ "Glob",
411
+ "Grep",
412
+ "Bash",
413
+ "PowerShell",
414
+ "NotebookEdit",
415
+ "WebFetch",
416
+ "WebSearch",
417
+ "REPL"
418
+ ]);
332
419
  }
333
420
  });
334
421
 
@@ -337,6 +424,7 @@ export {
337
424
  adjustIndexToPreserveAPIInvariants,
338
425
  snipCompact,
339
426
  windowCompact,
427
+ COMPACTABLE_TOOL_NAMES,
340
428
  microcompact,
341
429
  applyToolResultBudget,
342
430
  truncateToolResult,
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkTATCTZSBcjs = require('./chunk-TATCTZSB.cjs');
3
+ var _chunkQRM7IF2Scjs = require('./chunk-QRM7IF2S.cjs');
4
4
 
5
5
 
6
- var _chunkIJSHQGMPcjs = require('./chunk-IJSHQGMP.cjs');
6
+ var _chunkKS3RYAYLcjs = require('./chunk-KS3RYAYL.cjs');
7
7
 
8
8
  // src/data/openrouter-sync.ts
9
- _chunkIJSHQGMPcjs.init_cjs_shims.call(void 0, );
9
+ _chunkKS3RYAYLcjs.init_cjs_shims.call(void 0, );
10
10
  var ENDPOINT = "https://openrouter.ai/api/v1/models";
11
11
  function priceToPerMillion(raw) {
12
12
  if (!raw) return 0;
@@ -37,7 +37,7 @@ async function syncOpenRouterCatalog(timeoutMs = 15e3) {
37
37
  const payload = await res.json();
38
38
  const raw = _nullishCoalesce(payload.data, () => ( []));
39
39
  const models = raw.map(slim).sort((a, b) => b.created - a.created);
40
- _chunkTATCTZSBcjs.setOpenRouterSnapshot.call(void 0, {
40
+ _chunkQRM7IF2Scjs.setOpenRouterSnapshot.call(void 0, {
41
41
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
42
42
  source: ENDPOINT,
43
43
  count: models.length,
@@ -1,6 +1,9 @@
1
+ import {
2
+ readCache
3
+ } from "./chunk-3OA5G4TM.js";
1
4
  import {
2
5
  init_esm_shims
3
- } from "./chunk-DI7RDLOS.js";
6
+ } from "./chunk-MD32R22I.js";
4
7
 
5
8
  // src/llm/model-pool.ts
6
9
  init_esm_shims();
@@ -18,6 +21,32 @@ function lookupBuiltinContextWindow(model) {
18
21
  var ModelPool = class {
19
22
  models = /* @__PURE__ */ new Map();
20
23
  activeKey;
24
+ providerCatalog;
25
+ cacheDir;
26
+ setProviderCatalog(cat) {
27
+ this.providerCatalog = cat;
28
+ }
29
+ setCacheDir(dir) {
30
+ this.cacheDir = dir;
31
+ }
32
+ /**
33
+ * For each entry in the pool that lacks an explicit maxContextTokens
34
+ * but has a providerKey, look up the contextLength from the cached
35
+ * model list and patch it in.
36
+ */
37
+ reloadCachedContextWindows() {
38
+ if (!this.cacheDir) return;
39
+ for (const [key, entry] of this.models) {
40
+ if (entry.maxContextTokens != null) continue;
41
+ if (!entry.providerKey) continue;
42
+ const file = readCache(this.cacheDir, entry.providerKey);
43
+ if (!file) continue;
44
+ const match = file.models.find((m) => m.id === entry.model);
45
+ if (match?.contextLength) {
46
+ this.models.set(key, { ...entry, maxContextTokens: match.contextLength });
47
+ }
48
+ }
49
+ }
21
50
  /**
22
51
  * Build a pool from an array of model entries.
23
52
  * The first entry (or the one matching `defaultKey`) becomes active.
@@ -85,11 +114,17 @@ var ModelPool = class {
85
114
  * (inherits apiKey, baseUrl, etc. from the base if not set on the entry).
86
115
  */
87
116
  toLLMConfig(entry, base) {
117
+ const fromCat = entry.providerKey && this.providerCatalog ? this.providerCatalog.get(entry.providerKey) : void 0;
118
+ const kindToClientProvider = (kind) => {
119
+ if (!kind) return "openai";
120
+ if (kind === "anthropic") return "anthropic";
121
+ return "openai";
122
+ };
88
123
  return {
89
- provider: entry.provider,
124
+ provider: entry.provider || kindToClientProvider(fromCat?.kind) || "openai",
90
125
  model: entry.model,
91
- apiKey: entry.apiKey ?? base?.apiKey,
92
- baseUrl: entry.baseUrl ?? base?.baseUrl,
126
+ apiKey: entry.apiKey ?? fromCat?.apiKey ?? base?.apiKey,
127
+ baseUrl: entry.baseUrl ?? fromCat?.baseUrl ?? base?.baseUrl,
93
128
  temperature: base?.temperature ?? 0.3,
94
129
  maxTokens: entry.maxOutputTokens ?? base?.maxTokens ?? 8192,
95
130
  enableStreaming: base?.enableStreaming ?? true