@cuylabs/agent-core 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +33 -17
  2. package/dist/chunk-2O4MCSQS.js +780 -0
  3. package/dist/chunk-2TTOLHBT.js +198 -0
  4. package/dist/chunk-5FMSGQVX.js +281 -0
  5. package/dist/chunk-5NVVNXPQ.js +288 -0
  6. package/dist/{chunk-CAA7FHIH.js → chunk-6HZBHFOL.js} +3 -103
  7. package/dist/chunk-CJI7PVS2.js +58 -0
  8. package/dist/{chunk-N6HWIEEA.js → chunk-CMYN2RCB.js} +278 -61
  9. package/dist/chunk-FII65CN7.js +117 -0
  10. package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
  11. package/dist/chunk-I6PKJ7XQ.js +292 -0
  12. package/dist/{chunk-BDBZ3SLK.js → chunk-ICZ66572.js} +48 -4
  13. package/dist/chunk-KYLPMBHD.js +316 -0
  14. package/dist/chunk-MXAP4UG6.js +2956 -0
  15. package/dist/{chunk-RZITT45F.js → chunk-N3VX7FEE.js} +39 -6
  16. package/dist/{chunk-YSLSEQ6B.js → chunk-NDZWXCBZ.js} +218 -95
  17. package/dist/{chunk-P6YF7USR.js → chunk-Q742PSH3.js} +23 -38
  18. package/dist/chunk-QAL3OMI3.js +943 -0
  19. package/dist/{chunk-RFEKJKTO.js → chunk-RN6WZEUF.js} +330 -280
  20. package/dist/{chunk-ZXAKHMWH.js → chunk-ROTGCYDW.js} +22 -84
  21. package/dist/chunk-SPBFQXOT.js +0 -0
  22. package/dist/{chunk-LRHOS4ZN.js → chunk-SPILYYDF.js} +3 -2
  23. package/dist/chunk-SSFBF3US.js +602 -0
  24. package/dist/chunk-SZ2XBPTW.js +8 -0
  25. package/dist/chunk-T4UIX5D7.js +115 -0
  26. package/dist/chunk-TIHPYVAJ.js +102 -0
  27. package/dist/{chunk-YUUJK53A.js → chunk-TOTDGK3P.js} +1 -1
  28. package/dist/chunk-V4RFNEET.js +563 -0
  29. package/dist/chunk-VOUEJSW6.js +0 -0
  30. package/dist/{chunk-4BDA7DQY.js → chunk-WBPOZ7CL.js} +673 -273
  31. package/dist/chunk-X4VN4GIJ.js +185 -0
  32. package/dist/dispatch/index.d.ts +93 -0
  33. package/dist/dispatch/index.js +37 -0
  34. package/dist/events/index.d.ts +93 -0
  35. package/dist/events/index.js +6 -0
  36. package/dist/{runtime → execution}/index.d.ts +120 -34
  37. package/dist/{runtime → execution}/index.js +18 -13
  38. package/dist/index-BCqEGzBj.d.ts +251 -0
  39. package/dist/index.d.ts +490 -122
  40. package/dist/index.js +2104 -615
  41. package/dist/{errors → inference/errors}/index.d.ts +2 -2
  42. package/dist/{errors → inference/errors}/index.js +1 -1
  43. package/dist/inference/index.d.ts +16 -23
  44. package/dist/inference/index.js +45 -16
  45. package/dist/instance-BqV2D5pc.d.ts +5723 -0
  46. package/dist/logger/index.d.ts +50 -0
  47. package/dist/logger/index.js +11 -0
  48. package/dist/mcp/index.d.ts +5 -9
  49. package/dist/mcp/index.js +2 -3
  50. package/dist/middleware/index.d.ts +10 -149
  51. package/dist/middleware/index.js +11 -3
  52. package/dist/model-messages-B4nK9D1-.d.ts +13 -0
  53. package/dist/models/index.d.ts +23 -18
  54. package/dist/models/index.js +48 -11
  55. package/dist/models/reasoning/index.d.ts +4 -0
  56. package/dist/{reasoning → models/reasoning}/index.js +3 -3
  57. package/dist/plugin/index.d.ts +458 -0
  58. package/dist/plugin/index.js +32 -0
  59. package/dist/profiles/index.d.ts +55 -0
  60. package/dist/profiles/index.js +30 -0
  61. package/dist/prompt/index.d.ts +8 -12
  62. package/dist/prompt/index.js +3 -2
  63. package/dist/safety/index.d.ts +109 -14
  64. package/dist/safety/index.js +59 -3
  65. package/dist/sandbox/index.d.ts +81 -0
  66. package/dist/sandbox/index.js +1 -0
  67. package/dist/skill/index.d.ts +10 -8
  68. package/dist/skill/index.js +3 -3
  69. package/dist/storage/index.d.ts +12 -4
  70. package/dist/storage/index.js +1 -1
  71. package/dist/subagents/index.d.ts +177 -0
  72. package/dist/subagents/index.js +78 -0
  73. package/dist/team/index.d.ts +544 -0
  74. package/dist/team/index.js +41 -0
  75. package/dist/tool/host/index.d.ts +41 -0
  76. package/dist/tool/host/index.js +10 -0
  77. package/dist/tool/index.d.ts +125 -21
  78. package/dist/tool/index.js +20 -13
  79. package/dist/{types-VQgymC1N.d.ts → types-Bj_J8u_W.d.ts} +44 -64
  80. package/dist/{types-CHiPh8U2.d.ts → types-C_LCeYNg.d.ts} +7 -7
  81. package/dist/types-RSCv7nQ4.d.ts +59 -0
  82. package/package.json +58 -53
  83. package/dist/builder-UpOWQMW3.d.ts +0 -34
  84. package/dist/chunk-7MUFEN4K.js +0 -559
  85. package/dist/chunk-7VKQ4WPB.js +0 -73
  86. package/dist/chunk-BFM2YHNM.js +0 -222
  87. package/dist/chunk-DWYX7ASF.js +0 -26
  88. package/dist/chunk-KUVSERLJ.js +0 -50
  89. package/dist/chunk-N7P4PN3O.js +0 -84
  90. package/dist/chunk-SDSBEQXG.js +0 -157
  91. package/dist/chunk-SQU2AJHO.js +0 -305
  92. package/dist/chunk-VBWWUHWI.js +0 -724
  93. package/dist/chunk-VEKUXUVF.js +0 -41
  94. package/dist/chunk-VNQBHPCT.js +0 -398
  95. package/dist/chunk-WWYYNWEW.js +0 -259
  96. package/dist/context/index.d.ts +0 -259
  97. package/dist/context/index.js +0 -26
  98. package/dist/events-CE72w8W4.d.ts +0 -149
  99. package/dist/host/index.d.ts +0 -45
  100. package/dist/host/index.js +0 -8
  101. package/dist/index-CWSchSql.d.ts +0 -1058
  102. package/dist/messages-BYWGn8TY.d.ts +0 -110
  103. package/dist/presets/index.d.ts +0 -53
  104. package/dist/presets/index.js +0 -28
  105. package/dist/reasoning/index.d.ts +0 -116
  106. package/dist/registry-DwYqsQkX.d.ts +0 -164
  107. package/dist/runner-e2YRcUoX.d.ts +0 -786
  108. package/dist/scope/index.d.ts +0 -10
  109. package/dist/scope/index.js +0 -14
  110. package/dist/session-manager-B_CWGTsl.d.ts +0 -274
  111. package/dist/signal/index.d.ts +0 -28
  112. package/dist/signal/index.js +0 -6
  113. package/dist/sub-agent/index.d.ts +0 -23
  114. package/dist/sub-agent/index.js +0 -15
  115. package/dist/tool-BHbyUAy3.d.ts +0 -150
  116. package/dist/tool-DLXAR9Ce.d.ts +0 -145
  117. package/dist/tracker-DClqYqTj.d.ts +0 -96
  118. package/dist/tracking/index.d.ts +0 -111
  119. package/dist/tracking/index.js +0 -20
  120. package/dist/types-BfNpU8NS.d.ts +0 -270
  121. package/dist/types-BnpEOYV-.d.ts +0 -50
  122. package/dist/types-CQL-SvTn.d.ts +0 -29
  123. package/dist/types-CWm-7rvB.d.ts +0 -55
  124. package/dist/types-KKDrdU9Y.d.ts +0 -325
  125. package/dist/types-QA4WhEfz.d.ts +0 -138
  126. package/dist/types-QKHHQLLq.d.ts +0 -336
  127. package/dist/types-YuWV4ag7.d.ts +0 -72
@@ -1,7 +1,13 @@
1
1
  import {
2
- getModelId,
3
- getProviderId
4
- } from "./chunk-DWYX7ASF.js";
2
+ DEFAULT_RESOLVER_OPTIONS,
3
+ PatternCapabilitySource,
4
+ extractModelId,
5
+ extractProvider,
6
+ likelySupportsReasoning
7
+ } from "./chunk-I6PKJ7XQ.js";
8
+ import {
9
+ silentLogger
10
+ } from "./chunk-T4UIX5D7.js";
5
11
 
6
12
  // src/models/resolver.ts
7
13
  function parseKey(input) {
@@ -179,258 +185,6 @@ function createResolver(directory) {
179
185
  };
180
186
  }
181
187
 
182
- // src/models/types.ts
183
- var SourcePriority = /* @__PURE__ */ ((SourcePriority3) => {
184
- SourcePriority3[SourcePriority3["UserConfig"] = 0] = "UserConfig";
185
- SourcePriority3[SourcePriority3["LocalCache"] = 1] = "LocalCache";
186
- SourcePriority3[SourcePriority3["BundledData"] = 2] = "BundledData";
187
- SourcePriority3[SourcePriority3["PatternMatch"] = 3] = "PatternMatch";
188
- SourcePriority3[SourcePriority3["RemoteAPI"] = 4] = "RemoteAPI";
189
- return SourcePriority3;
190
- })(SourcePriority || {});
191
- var DEFAULT_RESOLVER_OPTIONS = {
192
- enableRemoteFetch: false,
193
- remoteApiUrl: "https://models.dev",
194
- cachePath: ".agent-core/cache",
195
- cacheTtlMs: 60 * 60 * 1e3,
196
- // 1 hour
197
- networkTimeoutMs: 10 * 1e3,
198
- // 10 seconds
199
- modelOverrides: {}
200
- };
201
-
202
- // src/models/profiles.ts
203
- var REASONING_PATTERNS = [
204
- // OpenAI o-series
205
- {
206
- pattern: /^o[134]-?(mini|pro|preview)?$/i,
207
- provider: "openai",
208
- capabilities: { reasoning: true, toolCalling: true },
209
- compatibility: { supportsReasoningEffort: true, thinkingFormat: "openai" },
210
- confidence: 0.95
211
- },
212
- // OpenAI GPT-5.x
213
- {
214
- pattern: /gpt-?5(\.\d)?/i,
215
- provider: "openai",
216
- capabilities: { reasoning: true, toolCalling: true },
217
- compatibility: { supportsReasoningEffort: true, thinkingFormat: "openai" },
218
- confidence: 0.9
219
- },
220
- // DeepSeek R1 variants
221
- {
222
- pattern: /deepseek[_-]?r1|r1[_-]distill/i,
223
- capabilities: { reasoning: true, toolCalling: false },
224
- confidence: 0.95
225
- },
226
- // Anthropic Claude with thinking
227
- {
228
- pattern: /claude.*thinking|thinking.*claude/i,
229
- provider: "anthropic",
230
- capabilities: { reasoning: true, toolCalling: true },
231
- compatibility: { thinkingFormat: "anthropic" },
232
- confidence: 0.9
233
- },
234
- // Claude 4.x series (reasoning capable)
235
- {
236
- pattern: /claude[_-]?(opus|sonnet)[_-]?4/i,
237
- provider: "anthropic",
238
- capabilities: { reasoning: true, toolCalling: true },
239
- compatibility: { thinkingFormat: "anthropic" },
240
- confidence: 0.85
241
- },
242
- // Gemini thinking models
243
- {
244
- pattern: /gemini.*thinking|gemini[_-]?2\.5[_-]?pro/i,
245
- provider: "google",
246
- capabilities: { reasoning: true, toolCalling: true },
247
- compatibility: { thinkingFormat: "google" },
248
- confidence: 0.85
249
- },
250
- // Gemini 3.x (future-proofing)
251
- {
252
- pattern: /gemini[_-]?3/i,
253
- provider: "google",
254
- capabilities: { reasoning: true, toolCalling: true },
255
- compatibility: { thinkingFormat: "google" },
256
- confidence: 0.8
257
- },
258
- // Grok reasoning models
259
- {
260
- pattern: /grok[_-]?\d[_-]?(mini|reasoning)/i,
261
- provider: "xai",
262
- capabilities: { reasoning: true, toolCalling: true },
263
- confidence: 0.85
264
- },
265
- // Qwen thinking models
266
- {
267
- pattern: /qwen.*thinking|qwen3/i,
268
- capabilities: { reasoning: true, toolCalling: true },
269
- confidence: 0.8
270
- },
271
- // Generic reasoning/thinking in name
272
- {
273
- pattern: /reasoning|thinking/i,
274
- capabilities: { reasoning: true },
275
- confidence: 0.7
276
- }
277
- ];
278
- var PROVIDER_PATTERNS = [
279
- { pattern: /^(gpt|o[134]|chatgpt|davinci)/i, provider: "openai" },
280
- { pattern: /^claude/i, provider: "anthropic" },
281
- { pattern: /^gemini|^palm/i, provider: "google" },
282
- { pattern: /^grok/i, provider: "xai" },
283
- { pattern: /^deepseek/i, provider: "deepseek" },
284
- { pattern: /^mistral|^mixtral|codestral/i, provider: "mistral" },
285
- { pattern: /^llama/i, provider: "meta" },
286
- { pattern: /^qwen/i, provider: "alibaba" },
287
- { pattern: /^command/i, provider: "cohere" }
288
- ];
289
- var CONTEXT_WINDOW_PROFILES = [
290
- // Anthropic Claude 4.x — 200k
291
- { pattern: /claude[_-]?(opus|sonnet)[_-]?4/i, tokens: 2e5 },
292
- // Anthropic Claude 3.5 — 200k
293
- { pattern: /claude[_-]?3[._-]?5/i, tokens: 2e5 },
294
- // Anthropic Claude 3 Opus/Sonnet/Haiku — 200k
295
- { pattern: /claude[_-]?3/i, tokens: 2e5 },
296
- // Anthropic Claude 2 — 100k
297
- { pattern: /claude[_-]?2/i, tokens: 1e5 },
298
- // OpenAI o-series (o1, o3, o4) — 200k
299
- { pattern: /^o[134]-?(mini|pro|preview)?$/i, tokens: 2e5 },
300
- // OpenAI GPT-5.x — 1M
301
- { pattern: /gpt-?5/i, tokens: 1e6 },
302
- // OpenAI GPT-4o — 128k
303
- { pattern: /gpt-?4o/i, tokens: 128e3 },
304
- // OpenAI GPT-4 turbo — 128k
305
- { pattern: /gpt-?4[_-]?turbo/i, tokens: 128e3 },
306
- // OpenAI GPT-4 — 8k (original)
307
- { pattern: /gpt-?4(?!o|[_-]?turbo)/i, tokens: 8192 },
308
- // OpenAI GPT-3.5 turbo — 16k
309
- { pattern: /gpt-?3[._-]?5/i, tokens: 16384 },
310
- // Google Gemini 2.5 Pro — 1M
311
- { pattern: /gemini[_-]?2[._-]?5[_-]?pro/i, tokens: 1e6 },
312
- // Google Gemini 2.x Flash — 1M
313
- { pattern: /gemini[_-]?2.*flash/i, tokens: 1e6 },
314
- // Google Gemini 2.x Pro — 1M
315
- { pattern: /gemini[_-]?2[._-]?\d?[_-]?pro/i, tokens: 1e6 },
316
- // Google Gemini 1.5 Pro/Flash — 1M
317
- { pattern: /gemini[_-]?1[._-]?5/i, tokens: 1e6 },
318
- // xAI Grok 3+ — 128k
319
- { pattern: /grok[_-]?\d/i, tokens: 128e3 },
320
- // Mistral Large — 128k
321
- { pattern: /mistral[_-]?large/i, tokens: 128e3 },
322
- // Mistral Medium — 32k
323
- { pattern: /mistral[_-]?medium/i, tokens: 32768 },
324
- // Codestral — 256k
325
- { pattern: /codestral/i, tokens: 256e3 },
326
- // Mistral generic — 32k
327
- { pattern: /mistral|mixtral/i, tokens: 32768 },
328
- // DeepSeek R1/V3 — 128k
329
- { pattern: /deepseek/i, tokens: 128e3 },
330
- // Qwen 3 — 128k
331
- { pattern: /qwen/i, tokens: 128e3 },
332
- // Meta Llama 3 — 128k
333
- { pattern: /llama[_-]?3/i, tokens: 128e3 },
334
- // Cohere Command R+ — 128k
335
- { pattern: /command[_-]?r/i, tokens: 128e3 }
336
- ];
337
- function inferContextWindow(modelId) {
338
- const normalized = modelId.toLowerCase();
339
- for (const { pattern, tokens } of CONTEXT_WINDOW_PROFILES) {
340
- if (pattern.test(normalized)) {
341
- return tokens;
342
- }
343
- }
344
- return void 0;
345
- }
346
- function inferProvider(modelId) {
347
- const normalized = modelId.toLowerCase();
348
- for (const { pattern, provider } of PROVIDER_PATTERNS) {
349
- if (pattern.test(normalized)) {
350
- return provider;
351
- }
352
- }
353
- if (modelId.includes("/")) {
354
- return modelId.split("/")[0];
355
- }
356
- return void 0;
357
- }
358
- function matchPatterns(modelId, providerHint) {
359
- const normalized = modelId.toLowerCase();
360
- for (const rule of REASONING_PATTERNS) {
361
- if (rule.provider && providerHint && rule.provider !== providerHint) {
362
- continue;
363
- }
364
- const matches = typeof rule.pattern === "string" ? normalized.includes(rule.pattern.toLowerCase()) : rule.pattern.test(normalized);
365
- if (matches) {
366
- return { rule, confidence: rule.confidence };
367
- }
368
- }
369
- return void 0;
370
- }
371
- function createDefaultCapabilities() {
372
- return {
373
- reasoning: false,
374
- toolCalling: true,
375
- temperature: true,
376
- attachments: false,
377
- streaming: true,
378
- inputModalities: ["text"],
379
- outputModalities: ["text"]
380
- };
381
- }
382
- var PatternCapabilitySource = class {
383
- priority = 3 /* PatternMatch */;
384
- name = "Pattern Matching";
385
- async lookup(modelId, providerHint) {
386
- const provider = providerHint || inferProvider(modelId);
387
- const match = matchPatterns(modelId, provider);
388
- const baseCapabilities = createDefaultCapabilities();
389
- if (match) {
390
- const entry = {
391
- id: modelId,
392
- name: modelId,
393
- provider: match.rule.provider || provider || "unknown",
394
- capabilities: {
395
- ...baseCapabilities,
396
- ...match.rule.capabilities,
397
- contextWindow: inferContextWindow(modelId)
398
- },
399
- compatibility: match.rule.compatibility
400
- };
401
- return {
402
- entry,
403
- source: this.priority,
404
- confident: match.confidence > 0.8
405
- };
406
- }
407
- return {
408
- entry: {
409
- id: modelId,
410
- name: modelId,
411
- provider: provider || "unknown",
412
- capabilities: {
413
- ...baseCapabilities,
414
- contextWindow: inferContextWindow(modelId)
415
- }
416
- },
417
- source: this.priority,
418
- confident: false
419
- };
420
- }
421
- async isAvailable() {
422
- return true;
423
- }
424
- };
425
- function likelySupportsReasoning(modelId) {
426
- const match = matchPatterns(modelId);
427
- return match !== void 0 && match.rule.capabilities.reasoning === true;
428
- }
429
- function getProviderCompatibility(modelId, provider) {
430
- const match = matchPatterns(modelId, provider);
431
- return match?.rule.compatibility;
432
- }
433
-
434
188
  // src/models/overrides.ts
435
189
  function normalizeKey(value) {
436
190
  const trimmed = value?.trim();
@@ -517,6 +271,10 @@ var FileSystemAdapter = class {
517
271
  };
518
272
  var LocalStorageAdapter = class {
519
273
  key = "agent-core:model-capabilities";
274
+ log;
275
+ constructor(logger) {
276
+ this.log = logger;
277
+ }
520
278
  async read() {
521
279
  try {
522
280
  const content = localStorage.getItem(this.key);
@@ -530,7 +288,9 @@ var LocalStorageAdapter = class {
530
288
  try {
531
289
  localStorage.setItem(this.key, JSON.stringify(data));
532
290
  } catch (error) {
533
- console.warn("[agent-core] Failed to write to localStorage:", error);
291
+ this.log.warn("Failed to write to localStorage", {
292
+ error: error instanceof Error ? error.message : String(error)
293
+ });
534
294
  }
535
295
  }
536
296
  async clear() {
@@ -552,12 +312,12 @@ var MemoryAdapter = class {
552
312
  this.data = void 0;
553
313
  }
554
314
  };
555
- function createCapabilityCacheAdapter(cachePath) {
315
+ function createCapabilityCacheAdapter(cachePath, logger) {
556
316
  if (isNodeEnvironment()) {
557
317
  return new FileSystemAdapter(cachePath);
558
318
  }
559
319
  if (hasLocalStorage()) {
560
- return new LocalStorageAdapter();
320
+ return new LocalStorageAdapter(logger ?? silentLogger);
561
321
  }
562
322
  return new MemoryAdapter();
563
323
  }
@@ -577,10 +337,12 @@ var CapabilityCache = class {
577
337
  memoryCache = /* @__PURE__ */ new Map();
578
338
  ttlMs;
579
339
  loaded = false;
580
- constructor(options = {}) {
340
+ log;
341
+ constructor(options = {}, logger) {
581
342
  const opts = { ...DEFAULT_RESOLVER_OPTIONS, ...options };
582
343
  this.ttlMs = opts.cacheTtlMs;
583
344
  this.adapter = createCapabilityCacheAdapter(opts.cachePath);
345
+ this.log = logger?.child("cache") ?? silentLogger;
584
346
  }
585
347
  async load() {
586
348
  if (this.loaded) return;
@@ -592,7 +354,9 @@ var CapabilityCache = class {
592
354
  }
593
355
  }
594
356
  } catch (error) {
595
- console.warn("[agent-core] Failed to load capability cache:", error);
357
+ this.log.warn("Failed to load capability cache", {
358
+ error: error instanceof Error ? error.message : String(error)
359
+ });
596
360
  }
597
361
  this.loaded = true;
598
362
  }
@@ -897,22 +661,17 @@ var RemoteCapabilitySource = class {
897
661
  };
898
662
 
899
663
  // src/models/capability-resolver.ts
900
- function extractModelId(model) {
901
- return getModelId(model);
902
- }
903
- function extractProvider(model) {
904
- const provider = getProviderId(model);
905
- return provider ?? inferProvider(extractModelId(model));
906
- }
907
664
  var ModelCapabilityResolver = class {
908
665
  options;
909
666
  cache;
910
667
  sources;
911
668
  initialized = false;
912
669
  initPromise;
913
- constructor(options = {}) {
670
+ log;
671
+ constructor(options = {}, logger) {
914
672
  this.options = { ...DEFAULT_RESOLVER_OPTIONS, ...options };
915
673
  this.cache = new CapabilityCache(this.options);
674
+ this.log = logger?.child("models") ?? silentLogger;
916
675
  this.sources = [
917
676
  new CacheCapabilitySource(this.cache),
918
677
  new PatternCapabilitySource()
@@ -935,7 +694,9 @@ var ModelCapabilityResolver = class {
935
694
  );
936
695
  if (remoteSource) {
937
696
  remoteSource.refresh().catch((err) => {
938
- console.warn("[agent-core] Background refresh failed:", err);
697
+ this.log.warn("Background refresh failed", {
698
+ error: err instanceof Error ? err.message : String(err)
699
+ });
939
700
  });
940
701
  }
941
702
  }
@@ -966,7 +727,9 @@ var ModelCapabilityResolver = class {
966
727
  }
967
728
  }
968
729
  } catch (error) {
969
- console.warn(`[agent-core] Source ${source.name} failed:`, error);
730
+ this.log.warn(`Source ${source.name} failed`, {
731
+ error: error instanceof Error ? error.message : String(error)
732
+ });
970
733
  }
971
734
  }
972
735
  if (!bestResult?.entry) {
@@ -1094,15 +857,298 @@ function configureResolver(options) {
1094
857
  defaultResolver = new ModelCapabilityResolver(options);
1095
858
  }
1096
859
 
860
+ // src/models/reasoning/types.ts
861
+ var STANDARD_LEVELS = ["off", "low", "medium", "high"];
862
+ var EXTENDED_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
863
+ var FIXED_LEVELS = ["medium"];
864
+ function shouldIncludeReasoningSummary() {
865
+ if (typeof process !== "undefined" && process.env) {
866
+ return process.env.CODE_AGENT_DISABLE_REASONING_SUMMARY !== "true";
867
+ }
868
+ return true;
869
+ }
870
+
871
+ // src/models/reasoning/providers.ts
872
+ function buildOpenAIOptions(level, compat) {
873
+ if (level === "off") return void 0;
874
+ const options = {};
875
+ if (compat?.supportsReasoningEffort !== false) {
876
+ options.reasoningEffort = level;
877
+ }
878
+ if (shouldIncludeReasoningSummary()) {
879
+ options.reasoningSummary = "auto";
880
+ }
881
+ return options;
882
+ }
883
+ var ANTHROPIC_BUDGETS = {
884
+ off: 0,
885
+ minimal: 2e3,
886
+ low: 4e3,
887
+ medium: 8e3,
888
+ high: 16e3,
889
+ xhigh: 31999
890
+ };
891
+ function buildAnthropicOptions(level) {
892
+ if (level === "off") return void 0;
893
+ return {
894
+ thinking: {
895
+ type: "enabled",
896
+ budgetTokens: ANTHROPIC_BUDGETS[level]
897
+ }
898
+ };
899
+ }
900
+ var GOOGLE_BUDGETS = {
901
+ off: 0,
902
+ minimal: 2e3,
903
+ low: 4e3,
904
+ medium: 8e3,
905
+ high: 16e3,
906
+ xhigh: 24576
907
+ };
908
+ function buildGoogleOptions(level, modelId) {
909
+ if (level === "off") return void 0;
910
+ if (modelId?.includes("gemini-3") || modelId?.includes("gemini-4")) {
911
+ return {
912
+ thinkingConfig: {
913
+ includeThoughts: true,
914
+ thinkingLevel: level === "high" || level === "xhigh" ? "high" : "low"
915
+ }
916
+ };
917
+ }
918
+ return {
919
+ thinkingConfig: {
920
+ includeThoughts: true,
921
+ thinkingBudget: GOOGLE_BUDGETS[level]
922
+ }
923
+ };
924
+ }
925
+ function buildXAIOptions(level) {
926
+ if (level === "off") return void 0;
927
+ return { reasoningEffort: level };
928
+ }
929
+ function buildGroqOptions(level) {
930
+ if (level === "off") return void 0;
931
+ return {
932
+ includeThoughts: true,
933
+ thinkingLevel: level === "high" || level === "xhigh" ? "high" : "low"
934
+ };
935
+ }
936
+ var BEDROCK_ANTHROPIC_BUDGETS = {
937
+ off: 0,
938
+ minimal: 2e3,
939
+ low: 4e3,
940
+ medium: 8e3,
941
+ high: 16e3,
942
+ xhigh: 31999
943
+ };
944
+ function buildBedrockOptions(level, modelId) {
945
+ if (level === "off") return void 0;
946
+ if (modelId?.includes("anthropic") || modelId?.includes("claude")) {
947
+ return {
948
+ reasoningConfig: {
949
+ type: "enabled",
950
+ budgetTokens: BEDROCK_ANTHROPIC_BUDGETS[level]
951
+ }
952
+ };
953
+ }
954
+ return {
955
+ reasoningConfig: {
956
+ type: "enabled",
957
+ maxReasoningEffort: level
958
+ }
959
+ };
960
+ }
961
+ function buildOpenRouterOptions(level) {
962
+ if (level === "off") return void 0;
963
+ return {
964
+ reasoning: { effort: level }
965
+ };
966
+ }
967
+ var PROVIDER_KEY_MAP = {
968
+ "openai.chat": "openai",
969
+ "openai.responses": "openai",
970
+ "anthropic.messages": "anthropic",
971
+ "google.generative-ai": "google",
972
+ "bedrock": "bedrock",
973
+ "azure": "azure",
974
+ "xai": "xai",
975
+ "deepinfra": "deepinfra",
976
+ "togetherai": "togetherai",
977
+ "groq": "groq",
978
+ "mistral": "mistral"
979
+ };
980
+ function getProviderOptionsKey(provider) {
981
+ return PROVIDER_KEY_MAP[provider] || provider.split(".")[0] || "unknown";
982
+ }
983
+
984
+ // src/models/reasoning/config.ts
985
+ async function getReasoningConfig(model) {
986
+ const resolver = getDefaultResolver();
987
+ const result = await resolver.resolve(model);
988
+ const { capabilities, compatibility } = result.entry;
989
+ const provider = extractProvider(model);
990
+ const modelId = extractModelId(model).toLowerCase();
991
+ if (!capabilities.reasoning) {
992
+ return {
993
+ supportsReasoning: false,
994
+ availableLevels: ["off"],
995
+ getProviderOptions: () => void 0
996
+ };
997
+ }
998
+ if (provider?.includes("openai") || modelId.includes("gpt") || modelId.match(/^o[134]/)) {
999
+ if (modelId === "o1-mini") {
1000
+ return {
1001
+ supportsReasoning: true,
1002
+ availableLevels: FIXED_LEVELS,
1003
+ getProviderOptions: () => void 0
1004
+ };
1005
+ }
1006
+ const isAdvanced = modelId.includes("gpt-5") || modelId.includes("o3") || modelId.includes("o4");
1007
+ return {
1008
+ supportsReasoning: true,
1009
+ availableLevels: isAdvanced ? EXTENDED_LEVELS : STANDARD_LEVELS,
1010
+ getProviderOptions: (level) => buildOpenAIOptions(level, compatibility)
1011
+ };
1012
+ }
1013
+ if (provider?.includes("anthropic") || modelId.includes("claude")) {
1014
+ return {
1015
+ supportsReasoning: true,
1016
+ availableLevels: ["off", "low", "medium", "high"],
1017
+ getProviderOptions: buildAnthropicOptions
1018
+ };
1019
+ }
1020
+ if (provider?.includes("google") || modelId.includes("gemini")) {
1021
+ return {
1022
+ supportsReasoning: true,
1023
+ availableLevels: STANDARD_LEVELS,
1024
+ getProviderOptions: (level) => buildGoogleOptions(level, modelId)
1025
+ };
1026
+ }
1027
+ if (provider?.includes("xai") || modelId.includes("grok")) {
1028
+ return {
1029
+ supportsReasoning: true,
1030
+ availableLevels: STANDARD_LEVELS,
1031
+ getProviderOptions: buildXAIOptions
1032
+ };
1033
+ }
1034
+ if (provider?.includes("bedrock")) {
1035
+ return {
1036
+ supportsReasoning: true,
1037
+ availableLevels: STANDARD_LEVELS,
1038
+ getProviderOptions: (level) => buildBedrockOptions(level, modelId)
1039
+ };
1040
+ }
1041
+ if (provider?.includes("groq")) {
1042
+ return {
1043
+ supportsReasoning: true,
1044
+ availableLevels: ["off", "low", "high"],
1045
+ getProviderOptions: buildGroqOptions
1046
+ };
1047
+ }
1048
+ if (provider?.includes("openrouter")) {
1049
+ return {
1050
+ supportsReasoning: true,
1051
+ availableLevels: STANDARD_LEVELS,
1052
+ getProviderOptions: buildOpenRouterOptions
1053
+ };
1054
+ }
1055
+ if (modelId.includes("r1") || modelId.includes("deepseek")) {
1056
+ return {
1057
+ supportsReasoning: true,
1058
+ availableLevels: FIXED_LEVELS,
1059
+ getProviderOptions: () => void 0
1060
+ };
1061
+ }
1062
+ return {
1063
+ supportsReasoning: true,
1064
+ availableLevels: STANDARD_LEVELS,
1065
+ getProviderOptions: (level) => buildOpenAIOptions(level, compatibility)
1066
+ };
1067
+ }
1068
+ function getReasoningConfigSync(model) {
1069
+ const modelId = extractModelId(model).toLowerCase();
1070
+ const provider = extractProvider(model) || "";
1071
+ const supportsReasoning2 = modelId.match(/^o[134]/) !== null || modelId.includes("gpt-5") || modelId.includes("r1") || modelId.includes("thinking") || modelId.includes("reasoning") || modelId.includes("grok") && modelId.includes("mini");
1072
+ if (!supportsReasoning2) {
1073
+ return {
1074
+ supportsReasoning: false,
1075
+ availableLevels: ["off"],
1076
+ getProviderOptions: () => void 0
1077
+ };
1078
+ }
1079
+ const isOpenAI = provider.includes("openai") || !!modelId.match(/^o[134]/) || modelId.includes("gpt");
1080
+ const isAnthropic = provider.includes("anthropic") || modelId.includes("claude");
1081
+ const isGoogle = provider.includes("google") || modelId.includes("gemini");
1082
+ const isXAI = provider.includes("xai") || modelId.includes("grok");
1083
+ const isBedrock = provider.includes("bedrock");
1084
+ const isGroq = provider.includes("groq");
1085
+ const isOpenRouter = provider.includes("openrouter");
1086
+ return {
1087
+ supportsReasoning: true,
1088
+ availableLevels: STANDARD_LEVELS,
1089
+ getProviderOptions: (level) => {
1090
+ if (level === "off") return void 0;
1091
+ if (isOpenAI) {
1092
+ const opts = { reasoningEffort: level };
1093
+ if (shouldIncludeReasoningSummary()) opts.reasoningSummary = "auto";
1094
+ return opts;
1095
+ }
1096
+ if (isAnthropic) return buildAnthropicOptions(level);
1097
+ if (isGoogle) return buildGoogleOptions(level, modelId);
1098
+ if (isXAI) return buildXAIOptions(level);
1099
+ if (isBedrock) return buildBedrockOptions(level, modelId);
1100
+ if (isGroq) return buildGroqOptions(level);
1101
+ if (isOpenRouter) return buildOpenRouterOptions(level);
1102
+ const defaultOpts = { reasoningEffort: level };
1103
+ if (shouldIncludeReasoningSummary()) defaultOpts.reasoningSummary = "auto";
1104
+ return defaultOpts;
1105
+ }
1106
+ };
1107
+ }
1108
+ async function buildReasoningOptions(model, level) {
1109
+ if (level === "off") return void 0;
1110
+ const config = await getReasoningConfig(model);
1111
+ if (!config.supportsReasoning) return void 0;
1112
+ const effectiveLevel = config.availableLevels.includes(level) ? level : config.availableLevels[config.availableLevels.length - 1];
1113
+ const options = config.getProviderOptions(effectiveLevel);
1114
+ if (!options) return void 0;
1115
+ const provider = extractProvider(model) || "";
1116
+ const providerKey = getProviderOptionsKey(provider);
1117
+ return { [providerKey]: options };
1118
+ }
1119
+ function buildReasoningOptionsSync(model, level) {
1120
+ if (level === "off") return void 0;
1121
+ const config = getReasoningConfigSync(model);
1122
+ if (!config.supportsReasoning) return void 0;
1123
+ const effectiveLevel = config.availableLevels.includes(level) ? level : config.availableLevels[config.availableLevels.length - 1];
1124
+ const options = config.getProviderOptions(effectiveLevel);
1125
+ if (!options) return void 0;
1126
+ const provider = extractProvider(model) || "";
1127
+ const providerKey = getProviderOptionsKey(provider);
1128
+ return { [providerKey]: options };
1129
+ }
1130
+ async function supportsReasoning(model) {
1131
+ const resolver = getDefaultResolver();
1132
+ return resolver.supportsReasoning(model);
1133
+ }
1134
+ function supportsReasoningSync(model) {
1135
+ return likelySupportsReasoning(extractModelId(model));
1136
+ }
1137
+
1097
1138
  export {
1139
+ STANDARD_LEVELS,
1140
+ EXTENDED_LEVELS,
1141
+ FIXED_LEVELS,
1142
+ shouldIncludeReasoningSummary,
1143
+ buildOpenAIOptions,
1144
+ buildAnthropicOptions,
1145
+ buildGoogleOptions,
1146
+ buildXAIOptions,
1147
+ buildGroqOptions,
1148
+ buildBedrockOptions,
1149
+ buildOpenRouterOptions,
1150
+ getProviderOptionsKey,
1098
1151
  createResolver,
1099
- SourcePriority,
1100
- DEFAULT_RESOLVER_OPTIONS,
1101
- inferContextWindow,
1102
- inferProvider,
1103
- PatternCapabilitySource,
1104
- likelySupportsReasoning,
1105
- getProviderCompatibility,
1106
1152
  findCapabilityOverride,
1107
1153
  applyCapabilityOverride,
1108
1154
  CapabilityCache,
@@ -1110,9 +1156,13 @@ export {
1110
1156
  getNetworkStatus,
1111
1157
  RemoteCapabilityFetcher,
1112
1158
  RemoteCapabilitySource,
1113
- extractModelId,
1114
- extractProvider,
1115
1159
  ModelCapabilityResolver,
1116
1160
  getDefaultResolver,
1117
- configureResolver
1161
+ configureResolver,
1162
+ getReasoningConfig,
1163
+ getReasoningConfigSync,
1164
+ buildReasoningOptions,
1165
+ buildReasoningOptionsSync,
1166
+ supportsReasoning,
1167
+ supportsReasoningSync
1118
1168
  };