@cuylabs/agent-core 0.7.0 → 0.9.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 (79) hide show
  1. package/dist/{builder-BRvqCcIk.d.ts → builder-BgZ_j4Vs.d.ts} +3 -2
  2. package/dist/chunk-4QFNWPIF.js +202 -0
  3. package/dist/chunk-5ARZJWD2.js +259 -0
  4. package/dist/chunk-DXFBQMXP.js +53 -0
  5. package/dist/chunk-EKR6PKXU.js +180 -0
  6. package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
  7. package/dist/{chunk-IEFIQENH.js → chunk-H3FUYU52.js} +15 -7
  8. package/dist/chunk-I6PKJ7XQ.js +292 -0
  9. package/dist/chunk-IYWQOJMQ.js +102 -0
  10. package/dist/{chunk-3HNO5SVI.js → chunk-J4QDGZIA.js} +20 -4
  11. package/dist/{chunk-7MUFEN4K.js → chunk-JLXG2SH7.js} +349 -3
  12. package/dist/{chunk-CDTV2UYU.js → chunk-MAZ5DY5B.js} +64 -276
  13. package/dist/{chunk-P6YF7USR.js → chunk-MHKK374K.js} +12 -11
  14. package/dist/{chunk-VBWWUHWI.js → chunk-OFDKHNCX.js} +4 -1
  15. package/dist/{chunk-YUUJK53A.js → chunk-RKEW5WXI.js} +1 -1
  16. package/dist/{chunk-LRHOS4ZN.js → chunk-SPILYYDF.js} +3 -2
  17. package/dist/{chunk-QGOGIP7T.js → chunk-UDCZ673N.js} +385 -233
  18. package/dist/{chunk-BDBZ3SLK.js → chunk-UHCJEM2E.js} +39 -2
  19. package/dist/chunk-WGZAPU6N.js +929 -0
  20. package/dist/{chunk-5K7AQVOU.js → chunk-WKHDSSXG.js} +130 -209
  21. package/dist/{chunk-BNSHUWCV.js → chunk-WWYYNWEW.js} +1 -1
  22. package/dist/context/index.js +1 -1
  23. package/dist/events-CE72w8W4.d.ts +149 -0
  24. package/dist/index-BCqEGzBj.d.ts +251 -0
  25. package/dist/{index-C33hlD6H.d.ts → index-DQuTZ8xL.d.ts} +319 -56
  26. package/dist/index.d.ts +42 -121
  27. package/dist/index.js +951 -848
  28. package/dist/inference/errors/index.d.ts +11 -0
  29. package/dist/inference/errors/index.js +16 -0
  30. package/dist/inference/index.d.ts +12 -8
  31. package/dist/inference/index.js +35 -7
  32. package/dist/llm-error-D93FNNLY.d.ts +32 -0
  33. package/dist/middleware/index.d.ts +246 -7
  34. package/dist/middleware/index.js +3 -1
  35. package/dist/models/index.d.ts +132 -9
  36. package/dist/models/index.js +48 -8
  37. package/dist/models/reasoning/index.d.ts +4 -0
  38. package/dist/{reasoning → models/reasoning}/index.js +2 -7
  39. package/dist/plugin/index.d.ts +414 -0
  40. package/dist/plugin/index.js +32 -0
  41. package/dist/presets/index.d.ts +53 -0
  42. package/dist/presets/index.js +30 -0
  43. package/dist/prompt/index.d.ts +11 -8
  44. package/dist/prompt/index.js +3 -2
  45. package/dist/{registry-BDLIHOQB.d.ts → registry-DwYqsQkX.d.ts} +1 -1
  46. package/dist/runner-CI-XeR16.d.ts +91 -0
  47. package/dist/runtime/index.d.ts +12 -8
  48. package/dist/runtime/index.js +8 -7
  49. package/dist/safety/index.d.ts +38 -0
  50. package/dist/safety/index.js +12 -0
  51. package/dist/scope/index.d.ts +2 -2
  52. package/dist/{session-manager-B_CWGTsl.d.ts → session-manager-KbYt2WUh.d.ts} +8 -0
  53. package/dist/signal/index.d.ts +28 -0
  54. package/dist/signal/index.js +6 -0
  55. package/dist/skill/index.d.ts +7 -6
  56. package/dist/skill/index.js +3 -3
  57. package/dist/storage/index.d.ts +2 -2
  58. package/dist/storage/index.js +1 -1
  59. package/dist/sub-agent/index.d.ts +16 -10
  60. package/dist/sub-agent/index.js +21 -4
  61. package/dist/tool/index.d.ts +22 -6
  62. package/dist/tool/index.js +3 -3
  63. package/dist/tool-CZWN3KbO.d.ts +141 -0
  64. package/dist/{tool-HUtkiVBx.d.ts → tool-DkhSCV2Y.d.ts} +2 -2
  65. package/dist/tracking/index.d.ts +2 -2
  66. package/dist/tracking/index.js +1 -1
  67. package/dist/{tool-Db1Ue-1U.d.ts → types-BfNpU8NS.d.ts} +1 -150
  68. package/dist/{types-FRpzzg_9.d.ts → types-BlOKk-Bb.d.ts} +10 -35
  69. package/dist/types-BlZwmnuW.d.ts +50 -0
  70. package/dist/{types-9jGQUjqW.d.ts → types-CQL-SvTn.d.ts} +1 -1
  71. package/dist/types-CWm-7rvB.d.ts +55 -0
  72. package/dist/{runner-DSKaEz3z.d.ts → types-DTSkxakL.d.ts} +7 -235
  73. package/dist/{types-CqDZTh4d.d.ts → types-DmDwi2zI.d.ts} +8 -4
  74. package/dist/types-YuWV4ag7.d.ts +72 -0
  75. package/package.json +67 -6
  76. package/dist/capability-resolver-CgRGsWVX.d.ts +0 -254
  77. package/dist/chunk-ZPMACVZK.js +0 -305
  78. package/dist/index-CfBGYrpd.d.ts +0 -317
  79. package/dist/reasoning/index.d.ts +0 -117
@@ -1,24 +1,10 @@
1
- // src/models/identifiers.ts
2
- function getModelId(model) {
3
- if (typeof model === "string") return model;
4
- if (typeof model === "object" && model !== null && "modelId" in model) {
5
- return String(model.modelId);
6
- }
7
- return String(model);
8
- }
9
- function getProviderId(model) {
10
- if (typeof model === "string") {
11
- if (model.includes("/")) {
12
- return model.split("/")[0];
13
- }
14
- return void 0;
15
- }
16
- if (typeof model === "object" && model !== null && "provider" in model) {
17
- const provider = String(model.provider);
18
- return provider.split(".")[0];
19
- }
20
- return void 0;
21
- }
1
+ import {
2
+ DEFAULT_RESOLVER_OPTIONS,
3
+ PatternCapabilitySource,
4
+ extractModelId,
5
+ extractProvider,
6
+ likelySupportsReasoning
7
+ } from "./chunk-I6PKJ7XQ.js";
22
8
 
23
9
  // src/models/resolver.ts
24
10
  function parseKey(input) {
@@ -102,6 +88,69 @@ async function createFactory(adapter, settings) {
102
88
  });
103
89
  return (modelId) => provider.languageModel(modelId);
104
90
  }
91
+ case "openrouter": {
92
+ const { createOpenRouter } = await import("@openrouter/ai-sdk-provider").catch(() => {
93
+ throw new Error(
94
+ `Provider "@openrouter/ai-sdk-provider" is required for the "openrouter" adapter. Install it with: pnpm add @openrouter/ai-sdk-provider`
95
+ );
96
+ });
97
+ const provider = createOpenRouter(opts);
98
+ return (modelId) => asModel(provider.languageModel(modelId));
99
+ }
100
+ case "azure": {
101
+ const { createAzure } = await import("@ai-sdk/azure").catch(() => {
102
+ throw new Error(
103
+ `Provider "@ai-sdk/azure" is required for the "azure" adapter. Install it with: pnpm add @ai-sdk/azure`
104
+ );
105
+ });
106
+ const provider = createAzure(opts);
107
+ return (modelId) => provider.languageModel(modelId);
108
+ }
109
+ case "bedrock": {
110
+ const { createAmazonBedrock } = await import("@ai-sdk/amazon-bedrock").catch(() => {
111
+ throw new Error(
112
+ `Provider "@ai-sdk/amazon-bedrock" is required for the "bedrock" adapter. Install it with: pnpm add @ai-sdk/amazon-bedrock`
113
+ );
114
+ });
115
+ const provider = createAmazonBedrock(opts);
116
+ return (modelId) => provider.languageModel(modelId);
117
+ }
118
+ case "vertex": {
119
+ const { createVertex } = await import("@ai-sdk/google-vertex").catch(() => {
120
+ throw new Error(
121
+ `Provider "@ai-sdk/google-vertex" is required for the "vertex" adapter. Install it with: pnpm add @ai-sdk/google-vertex`
122
+ );
123
+ });
124
+ const provider = createVertex(opts);
125
+ return (modelId) => asModel(provider.languageModel(modelId));
126
+ }
127
+ case "xai": {
128
+ const { createXai } = await import("@ai-sdk/xai").catch(() => {
129
+ throw new Error(
130
+ `Provider "@ai-sdk/xai" is required for the "xai" adapter. Install it with: pnpm add @ai-sdk/xai`
131
+ );
132
+ });
133
+ const provider = createXai(opts);
134
+ return (modelId) => provider.languageModel(modelId);
135
+ }
136
+ case "mistral": {
137
+ const { createMistral } = await import("@ai-sdk/mistral").catch(() => {
138
+ throw new Error(
139
+ `Provider "@ai-sdk/mistral" is required for the "mistral" adapter. Install it with: pnpm add @ai-sdk/mistral`
140
+ );
141
+ });
142
+ const provider = createMistral(opts);
143
+ return (modelId) => provider.languageModel(modelId);
144
+ }
145
+ case "groq": {
146
+ const { createGroq } = await import("@ai-sdk/groq").catch(() => {
147
+ throw new Error(
148
+ `Provider "@ai-sdk/groq" is required for the "groq" adapter. Install it with: pnpm add @ai-sdk/groq`
149
+ );
150
+ });
151
+ const provider = createGroq(opts);
152
+ return (modelId) => provider.languageModel(modelId);
153
+ }
105
154
  default:
106
155
  throw new Error(`No factory registered for adapter: ${adapter}`);
107
156
  }
@@ -133,197 +182,6 @@ function createResolver(directory) {
133
182
  };
134
183
  }
135
184
 
136
- // src/models/types.ts
137
- var SourcePriority = /* @__PURE__ */ ((SourcePriority3) => {
138
- SourcePriority3[SourcePriority3["UserConfig"] = 0] = "UserConfig";
139
- SourcePriority3[SourcePriority3["LocalCache"] = 1] = "LocalCache";
140
- SourcePriority3[SourcePriority3["BundledData"] = 2] = "BundledData";
141
- SourcePriority3[SourcePriority3["PatternMatch"] = 3] = "PatternMatch";
142
- SourcePriority3[SourcePriority3["RemoteAPI"] = 4] = "RemoteAPI";
143
- return SourcePriority3;
144
- })(SourcePriority || {});
145
- var DEFAULT_RESOLVER_OPTIONS = {
146
- enableRemoteFetch: false,
147
- remoteApiUrl: "https://models.dev",
148
- cachePath: ".agent-core/cache",
149
- cacheTtlMs: 60 * 60 * 1e3,
150
- // 1 hour
151
- networkTimeoutMs: 10 * 1e3,
152
- // 10 seconds
153
- modelOverrides: {}
154
- };
155
-
156
- // src/models/profiles.ts
157
- var REASONING_PATTERNS = [
158
- // OpenAI o-series
159
- {
160
- pattern: /^o[134]-?(mini|pro|preview)?$/i,
161
- provider: "openai",
162
- capabilities: { reasoning: true, toolCalling: true },
163
- compatibility: { supportsReasoningEffort: true, thinkingFormat: "openai" },
164
- confidence: 0.95
165
- },
166
- // OpenAI GPT-5.x
167
- {
168
- pattern: /gpt-?5(\.\d)?/i,
169
- provider: "openai",
170
- capabilities: { reasoning: true, toolCalling: true },
171
- compatibility: { supportsReasoningEffort: true, thinkingFormat: "openai" },
172
- confidence: 0.9
173
- },
174
- // DeepSeek R1 variants
175
- {
176
- pattern: /deepseek[_-]?r1|r1[_-]distill/i,
177
- capabilities: { reasoning: true, toolCalling: false },
178
- confidence: 0.95
179
- },
180
- // Anthropic Claude with thinking
181
- {
182
- pattern: /claude.*thinking|thinking.*claude/i,
183
- provider: "anthropic",
184
- capabilities: { reasoning: true, toolCalling: true },
185
- compatibility: { thinkingFormat: "anthropic" },
186
- confidence: 0.9
187
- },
188
- // Claude 4.x series (reasoning capable)
189
- {
190
- pattern: /claude[_-]?(opus|sonnet)[_-]?4/i,
191
- provider: "anthropic",
192
- capabilities: { reasoning: true, toolCalling: true },
193
- compatibility: { thinkingFormat: "anthropic" },
194
- confidence: 0.85
195
- },
196
- // Gemini thinking models
197
- {
198
- pattern: /gemini.*thinking|gemini[_-]?2\.5[_-]?pro/i,
199
- provider: "google",
200
- capabilities: { reasoning: true, toolCalling: true },
201
- compatibility: { thinkingFormat: "google" },
202
- confidence: 0.85
203
- },
204
- // Gemini 3.x (future-proofing)
205
- {
206
- pattern: /gemini[_-]?3/i,
207
- provider: "google",
208
- capabilities: { reasoning: true, toolCalling: true },
209
- compatibility: { thinkingFormat: "google" },
210
- confidence: 0.8
211
- },
212
- // Grok reasoning models
213
- {
214
- pattern: /grok[_-]?\d[_-]?(mini|reasoning)/i,
215
- provider: "xai",
216
- capabilities: { reasoning: true, toolCalling: true },
217
- confidence: 0.85
218
- },
219
- // Qwen thinking models
220
- {
221
- pattern: /qwen.*thinking|qwen3/i,
222
- capabilities: { reasoning: true, toolCalling: true },
223
- confidence: 0.8
224
- },
225
- // Generic reasoning/thinking in name
226
- {
227
- pattern: /reasoning|thinking/i,
228
- capabilities: { reasoning: true },
229
- confidence: 0.7
230
- }
231
- ];
232
- var PROVIDER_PATTERNS = [
233
- { pattern: /^(gpt|o[134]|chatgpt|davinci)/i, provider: "openai" },
234
- { pattern: /^claude/i, provider: "anthropic" },
235
- { pattern: /^gemini|^palm/i, provider: "google" },
236
- { pattern: /^grok/i, provider: "xai" },
237
- { pattern: /^deepseek/i, provider: "deepseek" },
238
- { pattern: /^mistral|^mixtral|codestral/i, provider: "mistral" },
239
- { pattern: /^llama/i, provider: "meta" },
240
- { pattern: /^qwen/i, provider: "alibaba" },
241
- { pattern: /^command/i, provider: "cohere" }
242
- ];
243
- function inferProvider(modelId) {
244
- const normalized = modelId.toLowerCase();
245
- for (const { pattern, provider } of PROVIDER_PATTERNS) {
246
- if (pattern.test(normalized)) {
247
- return provider;
248
- }
249
- }
250
- if (modelId.includes("/")) {
251
- return modelId.split("/")[0];
252
- }
253
- return void 0;
254
- }
255
- function matchPatterns(modelId, providerHint) {
256
- const normalized = modelId.toLowerCase();
257
- for (const rule of REASONING_PATTERNS) {
258
- if (rule.provider && providerHint && rule.provider !== providerHint) {
259
- continue;
260
- }
261
- const matches = typeof rule.pattern === "string" ? normalized.includes(rule.pattern.toLowerCase()) : rule.pattern.test(normalized);
262
- if (matches) {
263
- return { rule, confidence: rule.confidence };
264
- }
265
- }
266
- return void 0;
267
- }
268
- function createDefaultCapabilities() {
269
- return {
270
- reasoning: false,
271
- toolCalling: true,
272
- temperature: true,
273
- attachments: false,
274
- streaming: true,
275
- inputModalities: ["text"],
276
- outputModalities: ["text"]
277
- };
278
- }
279
- var PatternCapabilitySource = class {
280
- priority = 3 /* PatternMatch */;
281
- name = "Pattern Matching";
282
- async lookup(modelId, providerHint) {
283
- const provider = providerHint || inferProvider(modelId);
284
- const match = matchPatterns(modelId, provider);
285
- const baseCapabilities = createDefaultCapabilities();
286
- if (match) {
287
- const entry = {
288
- id: modelId,
289
- name: modelId,
290
- provider: match.rule.provider || provider || "unknown",
291
- capabilities: {
292
- ...baseCapabilities,
293
- ...match.rule.capabilities
294
- },
295
- compatibility: match.rule.compatibility
296
- };
297
- return {
298
- entry,
299
- source: this.priority,
300
- confident: match.confidence > 0.8
301
- };
302
- }
303
- return {
304
- entry: {
305
- id: modelId,
306
- name: modelId,
307
- provider: provider || "unknown",
308
- capabilities: baseCapabilities
309
- },
310
- source: this.priority,
311
- confident: false
312
- };
313
- }
314
- async isAvailable() {
315
- return true;
316
- }
317
- };
318
- function likelySupportsReasoning(modelId) {
319
- const match = matchPatterns(modelId);
320
- return match !== void 0 && match.rule.capabilities.reasoning === true;
321
- }
322
- function getProviderCompatibility(modelId, provider) {
323
- const match = matchPatterns(modelId, provider);
324
- return match?.rule.compatibility;
325
- }
326
-
327
185
  // src/models/overrides.ts
328
186
  function normalizeKey(value) {
329
187
  const trimmed = value?.trim();
@@ -359,6 +217,9 @@ function applyCapabilityOverride(entry, override) {
359
217
  }
360
218
 
361
219
  // src/models/cache/adapters.ts
220
+ function logLocalStorageWarning(error) {
221
+ console.warn("[agent-core] Failed to write to localStorage:", error);
222
+ }
362
223
  function isNodeEnvironment() {
363
224
  return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
364
225
  }
@@ -423,7 +284,7 @@ var LocalStorageAdapter = class {
423
284
  try {
424
285
  localStorage.setItem(this.key, JSON.stringify(data));
425
286
  } catch (error) {
426
- console.warn("[agent-core] Failed to write to localStorage:", error);
287
+ logLocalStorageWarning(error);
427
288
  }
428
289
  }
429
290
  async clear() {
@@ -465,6 +326,9 @@ function isExpired(data) {
465
326
  }
466
327
 
467
328
  // src/models/cache/manager.ts
329
+ function logCapabilityCacheWarning(error) {
330
+ console.warn("[agent-core] Failed to load capability cache:", error);
331
+ }
468
332
  var CapabilityCache = class {
469
333
  adapter;
470
334
  memoryCache = /* @__PURE__ */ new Map();
@@ -485,7 +349,7 @@ var CapabilityCache = class {
485
349
  }
486
350
  }
487
351
  } catch (error) {
488
- console.warn("[agent-core] Failed to load capability cache:", error);
352
+ logCapabilityCacheWarning(error);
489
353
  }
490
354
  this.loaded = true;
491
355
  }
@@ -790,12 +654,8 @@ var RemoteCapabilitySource = class {
790
654
  };
791
655
 
792
656
  // src/models/capability-resolver.ts
793
- function extractModelId(model) {
794
- return getModelId(model);
795
- }
796
- function extractProvider(model) {
797
- const provider = getProviderId(model);
798
- return provider ?? inferProvider(extractModelId(model));
657
+ function logCapabilityResolverWarning(message, error) {
658
+ console.warn(message, error);
799
659
  }
800
660
  var ModelCapabilityResolver = class {
801
661
  options;
@@ -828,7 +688,10 @@ var ModelCapabilityResolver = class {
828
688
  );
829
689
  if (remoteSource) {
830
690
  remoteSource.refresh().catch((err) => {
831
- console.warn("[agent-core] Background refresh failed:", err);
691
+ logCapabilityResolverWarning(
692
+ "[agent-core] Background refresh failed:",
693
+ err
694
+ );
832
695
  });
833
696
  }
834
697
  }
@@ -859,7 +722,10 @@ var ModelCapabilityResolver = class {
859
722
  }
860
723
  }
861
724
  } catch (error) {
862
- console.warn(`[agent-core] Source ${source.name} failed:`, error);
725
+ logCapabilityResolverWarning(
726
+ `[agent-core] Source ${source.name} failed:`,
727
+ error
728
+ );
863
729
  }
864
730
  }
865
731
  if (!bestResult?.entry) {
@@ -987,16 +853,298 @@ function configureResolver(options) {
987
853
  defaultResolver = new ModelCapabilityResolver(options);
988
854
  }
989
855
 
856
+ // src/models/reasoning/types.ts
857
+ var STANDARD_LEVELS = ["off", "low", "medium", "high"];
858
+ var EXTENDED_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
859
+ var FIXED_LEVELS = ["medium"];
860
+ function shouldIncludeReasoningSummary() {
861
+ if (typeof process !== "undefined" && process.env) {
862
+ return process.env.CODE_AGENT_DISABLE_REASONING_SUMMARY !== "true";
863
+ }
864
+ return true;
865
+ }
866
+
867
+ // src/models/reasoning/providers.ts
868
+ function buildOpenAIOptions(level, compat) {
869
+ if (level === "off") return void 0;
870
+ const options = {};
871
+ if (compat?.supportsReasoningEffort !== false) {
872
+ options.reasoningEffort = level;
873
+ }
874
+ if (shouldIncludeReasoningSummary()) {
875
+ options.reasoningSummary = "auto";
876
+ }
877
+ return options;
878
+ }
879
+ var ANTHROPIC_BUDGETS = {
880
+ off: 0,
881
+ minimal: 2e3,
882
+ low: 4e3,
883
+ medium: 8e3,
884
+ high: 16e3,
885
+ xhigh: 31999
886
+ };
887
+ function buildAnthropicOptions(level) {
888
+ if (level === "off") return void 0;
889
+ return {
890
+ thinking: {
891
+ type: "enabled",
892
+ budgetTokens: ANTHROPIC_BUDGETS[level]
893
+ }
894
+ };
895
+ }
896
+ var GOOGLE_BUDGETS = {
897
+ off: 0,
898
+ minimal: 2e3,
899
+ low: 4e3,
900
+ medium: 8e3,
901
+ high: 16e3,
902
+ xhigh: 24576
903
+ };
904
+ function buildGoogleOptions(level, modelId) {
905
+ if (level === "off") return void 0;
906
+ if (modelId?.includes("gemini-3") || modelId?.includes("gemini-4")) {
907
+ return {
908
+ thinkingConfig: {
909
+ includeThoughts: true,
910
+ thinkingLevel: level === "high" || level === "xhigh" ? "high" : "low"
911
+ }
912
+ };
913
+ }
914
+ return {
915
+ thinkingConfig: {
916
+ includeThoughts: true,
917
+ thinkingBudget: GOOGLE_BUDGETS[level]
918
+ }
919
+ };
920
+ }
921
+ function buildXAIOptions(level) {
922
+ if (level === "off") return void 0;
923
+ return { reasoningEffort: level };
924
+ }
925
+ function buildGroqOptions(level) {
926
+ if (level === "off") return void 0;
927
+ return {
928
+ includeThoughts: true,
929
+ thinkingLevel: level === "high" || level === "xhigh" ? "high" : "low"
930
+ };
931
+ }
932
+ var BEDROCK_ANTHROPIC_BUDGETS = {
933
+ off: 0,
934
+ minimal: 2e3,
935
+ low: 4e3,
936
+ medium: 8e3,
937
+ high: 16e3,
938
+ xhigh: 31999
939
+ };
940
+ function buildBedrockOptions(level, modelId) {
941
+ if (level === "off") return void 0;
942
+ if (modelId?.includes("anthropic") || modelId?.includes("claude")) {
943
+ return {
944
+ reasoningConfig: {
945
+ type: "enabled",
946
+ budgetTokens: BEDROCK_ANTHROPIC_BUDGETS[level]
947
+ }
948
+ };
949
+ }
950
+ return {
951
+ reasoningConfig: {
952
+ type: "enabled",
953
+ maxReasoningEffort: level
954
+ }
955
+ };
956
+ }
957
+ function buildOpenRouterOptions(level) {
958
+ if (level === "off") return void 0;
959
+ return {
960
+ reasoning: { effort: level }
961
+ };
962
+ }
963
+ var PROVIDER_KEY_MAP = {
964
+ "openai.chat": "openai",
965
+ "openai.responses": "openai",
966
+ "anthropic.messages": "anthropic",
967
+ "google.generative-ai": "google",
968
+ "bedrock": "bedrock",
969
+ "azure": "azure",
970
+ "xai": "xai",
971
+ "deepinfra": "deepinfra",
972
+ "togetherai": "togetherai",
973
+ "groq": "groq",
974
+ "mistral": "mistral"
975
+ };
976
+ function getProviderOptionsKey(provider) {
977
+ return PROVIDER_KEY_MAP[provider] || provider.split(".")[0] || "unknown";
978
+ }
979
+
980
+ // src/models/reasoning/config.ts
981
+ async function getReasoningConfig(model) {
982
+ const resolver = getDefaultResolver();
983
+ const result = await resolver.resolve(model);
984
+ const { capabilities, compatibility } = result.entry;
985
+ const provider = extractProvider(model);
986
+ const modelId = extractModelId(model).toLowerCase();
987
+ if (!capabilities.reasoning) {
988
+ return {
989
+ supportsReasoning: false,
990
+ availableLevels: ["off"],
991
+ getProviderOptions: () => void 0
992
+ };
993
+ }
994
+ if (provider?.includes("openai") || modelId.includes("gpt") || modelId.match(/^o[134]/)) {
995
+ if (modelId === "o1-mini") {
996
+ return {
997
+ supportsReasoning: true,
998
+ availableLevels: FIXED_LEVELS,
999
+ getProviderOptions: () => void 0
1000
+ };
1001
+ }
1002
+ const isAdvanced = modelId.includes("gpt-5") || modelId.includes("o3") || modelId.includes("o4");
1003
+ return {
1004
+ supportsReasoning: true,
1005
+ availableLevels: isAdvanced ? EXTENDED_LEVELS : STANDARD_LEVELS,
1006
+ getProviderOptions: (level) => buildOpenAIOptions(level, compatibility)
1007
+ };
1008
+ }
1009
+ if (provider?.includes("anthropic") || modelId.includes("claude")) {
1010
+ return {
1011
+ supportsReasoning: true,
1012
+ availableLevels: ["off", "low", "medium", "high"],
1013
+ getProviderOptions: buildAnthropicOptions
1014
+ };
1015
+ }
1016
+ if (provider?.includes("google") || modelId.includes("gemini")) {
1017
+ return {
1018
+ supportsReasoning: true,
1019
+ availableLevels: STANDARD_LEVELS,
1020
+ getProviderOptions: (level) => buildGoogleOptions(level, modelId)
1021
+ };
1022
+ }
1023
+ if (provider?.includes("xai") || modelId.includes("grok")) {
1024
+ return {
1025
+ supportsReasoning: true,
1026
+ availableLevels: STANDARD_LEVELS,
1027
+ getProviderOptions: buildXAIOptions
1028
+ };
1029
+ }
1030
+ if (provider?.includes("bedrock")) {
1031
+ return {
1032
+ supportsReasoning: true,
1033
+ availableLevels: STANDARD_LEVELS,
1034
+ getProviderOptions: (level) => buildBedrockOptions(level, modelId)
1035
+ };
1036
+ }
1037
+ if (provider?.includes("groq")) {
1038
+ return {
1039
+ supportsReasoning: true,
1040
+ availableLevels: ["off", "low", "high"],
1041
+ getProviderOptions: buildGroqOptions
1042
+ };
1043
+ }
1044
+ if (provider?.includes("openrouter")) {
1045
+ return {
1046
+ supportsReasoning: true,
1047
+ availableLevels: STANDARD_LEVELS,
1048
+ getProviderOptions: buildOpenRouterOptions
1049
+ };
1050
+ }
1051
+ if (modelId.includes("r1") || modelId.includes("deepseek")) {
1052
+ return {
1053
+ supportsReasoning: true,
1054
+ availableLevels: FIXED_LEVELS,
1055
+ getProviderOptions: () => void 0
1056
+ };
1057
+ }
1058
+ return {
1059
+ supportsReasoning: true,
1060
+ availableLevels: STANDARD_LEVELS,
1061
+ getProviderOptions: (level) => buildOpenAIOptions(level, compatibility)
1062
+ };
1063
+ }
1064
+ function getReasoningConfigSync(model) {
1065
+ const modelId = extractModelId(model).toLowerCase();
1066
+ const provider = extractProvider(model) || "";
1067
+ 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");
1068
+ if (!supportsReasoning2) {
1069
+ return {
1070
+ supportsReasoning: false,
1071
+ availableLevels: ["off"],
1072
+ getProviderOptions: () => void 0
1073
+ };
1074
+ }
1075
+ const isOpenAI = provider.includes("openai") || !!modelId.match(/^o[134]/) || modelId.includes("gpt");
1076
+ const isAnthropic = provider.includes("anthropic") || modelId.includes("claude");
1077
+ const isGoogle = provider.includes("google") || modelId.includes("gemini");
1078
+ const isXAI = provider.includes("xai") || modelId.includes("grok");
1079
+ const isBedrock = provider.includes("bedrock");
1080
+ const isGroq = provider.includes("groq");
1081
+ const isOpenRouter = provider.includes("openrouter");
1082
+ return {
1083
+ supportsReasoning: true,
1084
+ availableLevels: STANDARD_LEVELS,
1085
+ getProviderOptions: (level) => {
1086
+ if (level === "off") return void 0;
1087
+ if (isOpenAI) {
1088
+ const opts = { reasoningEffort: level };
1089
+ if (shouldIncludeReasoningSummary()) opts.reasoningSummary = "auto";
1090
+ return opts;
1091
+ }
1092
+ if (isAnthropic) return buildAnthropicOptions(level);
1093
+ if (isGoogle) return buildGoogleOptions(level, modelId);
1094
+ if (isXAI) return buildXAIOptions(level);
1095
+ if (isBedrock) return buildBedrockOptions(level, modelId);
1096
+ if (isGroq) return buildGroqOptions(level);
1097
+ if (isOpenRouter) return buildOpenRouterOptions(level);
1098
+ const defaultOpts = { reasoningEffort: level };
1099
+ if (shouldIncludeReasoningSummary()) defaultOpts.reasoningSummary = "auto";
1100
+ return defaultOpts;
1101
+ }
1102
+ };
1103
+ }
1104
+ async function buildReasoningOptions(model, level) {
1105
+ if (level === "off") return void 0;
1106
+ const config = await getReasoningConfig(model);
1107
+ if (!config.supportsReasoning) return void 0;
1108
+ const effectiveLevel = config.availableLevels.includes(level) ? level : config.availableLevels[config.availableLevels.length - 1];
1109
+ const options = config.getProviderOptions(effectiveLevel);
1110
+ if (!options) return void 0;
1111
+ const provider = extractProvider(model) || "";
1112
+ const providerKey = getProviderOptionsKey(provider);
1113
+ return { [providerKey]: options };
1114
+ }
1115
+ function buildReasoningOptionsSync(model, level) {
1116
+ if (level === "off") return void 0;
1117
+ const config = getReasoningConfigSync(model);
1118
+ if (!config.supportsReasoning) return void 0;
1119
+ const effectiveLevel = config.availableLevels.includes(level) ? level : config.availableLevels[config.availableLevels.length - 1];
1120
+ const options = config.getProviderOptions(effectiveLevel);
1121
+ if (!options) return void 0;
1122
+ const provider = extractProvider(model) || "";
1123
+ const providerKey = getProviderOptionsKey(provider);
1124
+ return { [providerKey]: options };
1125
+ }
1126
+ async function supportsReasoning(model) {
1127
+ const resolver = getDefaultResolver();
1128
+ return resolver.supportsReasoning(model);
1129
+ }
1130
+ function supportsReasoningSync(model) {
1131
+ return likelySupportsReasoning(extractModelId(model));
1132
+ }
1133
+
990
1134
  export {
991
- getModelId,
992
- getProviderId,
1135
+ STANDARD_LEVELS,
1136
+ EXTENDED_LEVELS,
1137
+ FIXED_LEVELS,
1138
+ shouldIncludeReasoningSummary,
1139
+ buildOpenAIOptions,
1140
+ buildAnthropicOptions,
1141
+ buildGoogleOptions,
1142
+ buildXAIOptions,
1143
+ buildGroqOptions,
1144
+ buildBedrockOptions,
1145
+ buildOpenRouterOptions,
1146
+ getProviderOptionsKey,
993
1147
  createResolver,
994
- SourcePriority,
995
- DEFAULT_RESOLVER_OPTIONS,
996
- inferProvider,
997
- PatternCapabilitySource,
998
- likelySupportsReasoning,
999
- getProviderCompatibility,
1000
1148
  findCapabilityOverride,
1001
1149
  applyCapabilityOverride,
1002
1150
  CapabilityCache,
@@ -1004,9 +1152,13 @@ export {
1004
1152
  getNetworkStatus,
1005
1153
  RemoteCapabilityFetcher,
1006
1154
  RemoteCapabilitySource,
1007
- extractModelId,
1008
- extractProvider,
1009
1155
  ModelCapabilityResolver,
1010
1156
  getDefaultResolver,
1011
- configureResolver
1157
+ configureResolver,
1158
+ getReasoningConfig,
1159
+ getReasoningConfigSync,
1160
+ buildReasoningOptions,
1161
+ buildReasoningOptionsSync,
1162
+ supportsReasoning,
1163
+ supportsReasoningSync
1012
1164
  };