@dexto/core 1.6.1 → 1.6.3
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.
- package/dist/agent/DextoAgent.cjs +54 -0
- package/dist/agent/DextoAgent.d.ts +12 -1
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +54 -0
- package/dist/agent/agent-options.d.ts +6 -1
- package/dist/agent/agent-options.d.ts.map +1 -1
- package/dist/events/index.d.ts +9 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/llm/executor/provider-options.cjs +223 -28
- package/dist/llm/executor/provider-options.d.ts +3 -37
- package/dist/llm/executor/provider-options.d.ts.map +1 -1
- package/dist/llm/executor/provider-options.js +227 -27
- package/dist/llm/executor/stream-processor.cjs +54 -31
- package/dist/llm/executor/stream-processor.d.ts +9 -2
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +52 -29
- package/dist/llm/executor/turn-executor.cjs +63 -41
- package/dist/llm/executor/turn-executor.d.ts +2 -2
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +53 -31
- package/dist/llm/formatters/vercel.cjs +15 -3
- package/dist/llm/formatters/vercel.d.ts +1 -0
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +15 -3
- package/dist/llm/index.cjs +8 -0
- package/dist/llm/index.d.ts +2 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +7 -0
- package/dist/llm/providers/local/schemas.d.ts +2 -2
- package/dist/llm/providers/openrouter-model-registry.cjs +66 -11
- package/dist/llm/providers/openrouter-model-registry.d.ts +26 -0
- package/dist/llm/providers/openrouter-model-registry.d.ts.map +1 -1
- package/dist/llm/providers/openrouter-model-registry.js +65 -11
- package/dist/{utils/user-info.cjs → llm/reasoning/anthropic-betas.cjs} +9 -8
- package/dist/llm/reasoning/anthropic-betas.d.ts +3 -0
- package/dist/llm/reasoning/anthropic-betas.d.ts.map +1 -0
- package/dist/llm/reasoning/anthropic-betas.js +7 -0
- package/dist/llm/reasoning/anthropic-thinking.cjs +79 -0
- package/dist/llm/reasoning/anthropic-thinking.d.ts +15 -0
- package/dist/llm/reasoning/anthropic-thinking.d.ts.map +1 -0
- package/dist/llm/reasoning/anthropic-thinking.js +52 -0
- package/dist/llm/reasoning/openai-reasoning-effort.cjs +86 -0
- package/dist/llm/reasoning/openai-reasoning-effort.d.ts +5 -0
- package/dist/llm/reasoning/openai-reasoning-effort.d.ts.map +1 -0
- package/dist/llm/reasoning/openai-reasoning-effort.js +61 -0
- package/dist/llm/reasoning/profile.cjs +113 -0
- package/dist/llm/reasoning/profile.d.ts +13 -0
- package/dist/llm/reasoning/profile.d.ts.map +1 -0
- package/dist/llm/reasoning/profile.js +92 -0
- package/dist/llm/reasoning/profiles/anthropic.cjs +61 -0
- package/dist/llm/reasoning/profiles/anthropic.d.ts +8 -0
- package/dist/llm/reasoning/profiles/anthropic.d.ts.map +1 -0
- package/dist/llm/reasoning/profiles/anthropic.js +45 -0
- package/dist/llm/reasoning/profiles/bedrock.cjs +54 -0
- package/dist/llm/reasoning/profiles/bedrock.d.ts +3 -0
- package/dist/llm/reasoning/profiles/bedrock.d.ts.map +1 -0
- package/dist/llm/reasoning/profiles/bedrock.js +36 -0
- package/dist/llm/reasoning/profiles/google.cjs +45 -0
- package/dist/llm/reasoning/profiles/google.d.ts +9 -0
- package/dist/llm/reasoning/profiles/google.d.ts.map +1 -0
- package/dist/llm/reasoning/profiles/google.js +21 -0
- package/dist/llm/reasoning/profiles/openai-compatible.cjs +39 -0
- package/dist/llm/reasoning/profiles/openai-compatible.d.ts +3 -0
- package/dist/llm/reasoning/profiles/openai-compatible.d.ts.map +1 -0
- package/dist/llm/reasoning/profiles/openai-compatible.js +16 -0
- package/dist/llm/reasoning/profiles/openai.cjs +41 -0
- package/dist/llm/reasoning/profiles/openai.d.ts +3 -0
- package/dist/llm/reasoning/profiles/openai.d.ts.map +1 -0
- package/dist/llm/reasoning/profiles/openai.js +18 -0
- package/dist/llm/reasoning/profiles/openrouter.cjs +83 -0
- package/dist/llm/reasoning/profiles/openrouter.d.ts +10 -0
- package/dist/llm/reasoning/profiles/openrouter.d.ts.map +1 -0
- package/dist/llm/reasoning/profiles/openrouter.js +59 -0
- package/dist/llm/reasoning/profiles/shared.cjs +80 -0
- package/dist/llm/reasoning/profiles/shared.d.ts +25 -0
- package/dist/llm/reasoning/profiles/shared.d.ts.map +1 -0
- package/dist/llm/reasoning/profiles/shared.js +53 -0
- package/dist/llm/reasoning/profiles/vertex.cjs +46 -0
- package/dist/llm/reasoning/profiles/vertex.d.ts +3 -0
- package/dist/llm/reasoning/profiles/vertex.d.ts.map +1 -0
- package/dist/llm/reasoning/profiles/vertex.js +23 -0
- package/dist/llm/registry/auto-update.cjs +18 -0
- package/dist/llm/registry/auto-update.d.ts.map +1 -1
- package/dist/llm/registry/auto-update.js +18 -0
- package/dist/llm/registry/index.cjs +126 -26
- package/dist/llm/registry/index.d.ts +48 -4
- package/dist/llm/registry/index.d.ts.map +1 -1
- package/dist/llm/registry/index.js +136 -28
- package/dist/llm/registry/models.generated.cjs +5198 -59
- package/dist/llm/registry/models.generated.d.ts +1893 -76
- package/dist/llm/registry/models.generated.d.ts.map +1 -1
- package/dist/llm/registry/models.generated.js +5196 -58
- package/dist/llm/registry/sync.cjs +72 -1
- package/dist/llm/registry/sync.d.ts +21 -1
- package/dist/llm/registry/sync.d.ts.map +1 -1
- package/dist/llm/registry/sync.js +72 -1
- package/dist/llm/resolver.cjs +13 -1
- package/dist/llm/resolver.d.ts.map +1 -1
- package/dist/llm/resolver.js +13 -1
- package/dist/llm/schemas.cjs +75 -14
- package/dist/llm/schemas.d.ts +80 -23
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +75 -14
- package/dist/llm/services/factory.cjs +55 -8
- package/dist/llm/services/factory.d.ts +1 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +58 -8
- package/dist/llm/services/vercel.cjs +1 -1
- package/dist/llm/services/vercel.js +1 -1
- package/dist/llm/types.d.ts +9 -0
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/prompts/index.cjs +9 -0
- package/dist/prompts/index.d.ts +1 -0
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +10 -0
- package/dist/prompts/prompt-manager.cjs +2 -0
- package/dist/prompts/prompt-manager.d.ts.map +1 -1
- package/dist/prompts/prompt-manager.js +2 -0
- package/dist/prompts/providers/config-prompt-provider.cjs +11 -1
- package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.js +11 -1
- package/dist/prompts/schemas.cjs +2 -2
- package/dist/prompts/schemas.js +2 -2
- package/dist/prompts/types.d.ts +6 -2
- package/dist/prompts/types.d.ts.map +1 -1
- package/dist/tools/confirmation/allowed-tools-provider/types.d.ts +1 -1
- package/dist/tools/tool-manager.cjs +88 -2
- package/dist/tools/tool-manager.d.ts +15 -1
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +88 -2
- package/dist/utils/service-initializer.d.ts +1 -0
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/package.json +7 -5
- package/dist/utils/schema-metadata.cjs +0 -235
- package/dist/utils/schema-metadata.d.ts +0 -82
- package/dist/utils/schema-metadata.d.ts.map +0 -1
- package/dist/utils/schema-metadata.js +0 -208
- package/dist/utils/user-info.d.ts +0 -2
- package/dist/utils/user-info.d.ts.map +0 -1
- package/dist/utils/user-info.js +0 -7
|
@@ -5,8 +5,16 @@ import { DextoRuntimeError } from "../../errors/DextoRuntimeError.js";
|
|
|
5
5
|
import {
|
|
6
6
|
LLM_PROVIDERS
|
|
7
7
|
} from "../types.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import {
|
|
9
|
+
getCachedOpenRouterModelsWithInfo,
|
|
10
|
+
getOpenRouterModelCacheInfo,
|
|
11
|
+
getOpenRouterModelContextLength,
|
|
12
|
+
scheduleOpenRouterModelRefresh
|
|
13
|
+
} from "../providers/openrouter-model-registry.js";
|
|
14
|
+
import {
|
|
15
|
+
MODELS_BY_PROVIDER,
|
|
16
|
+
MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER
|
|
17
|
+
} from "./models.generated.js";
|
|
10
18
|
import { MANUAL_MODELS_BY_PROVIDER } from "./models.manual.js";
|
|
11
19
|
const LEGACY_MODEL_ID_ALIASES = {
|
|
12
20
|
anthropic: {
|
|
@@ -67,8 +75,9 @@ const LLM_REGISTRY = {
|
|
|
67
75
|
openai: {
|
|
68
76
|
models: mergeModels(MODELS_BY_PROVIDER.openai, MANUAL_MODELS_BY_PROVIDER.openai),
|
|
69
77
|
baseURLSupport: "none",
|
|
70
|
-
supportedFileTypes: []
|
|
78
|
+
supportedFileTypes: [],
|
|
71
79
|
// No defaults - models must explicitly specify support
|
|
80
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.openai
|
|
72
81
|
},
|
|
73
82
|
"openai-compatible": {
|
|
74
83
|
models: [],
|
|
@@ -81,52 +90,59 @@ const LLM_REGISTRY = {
|
|
|
81
90
|
anthropic: {
|
|
82
91
|
models: MODELS_BY_PROVIDER.anthropic,
|
|
83
92
|
baseURLSupport: "none",
|
|
84
|
-
supportedFileTypes: []
|
|
93
|
+
supportedFileTypes: [],
|
|
85
94
|
// No defaults - models must explicitly specify support
|
|
95
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.anthropic
|
|
86
96
|
},
|
|
87
97
|
google: {
|
|
88
98
|
models: MODELS_BY_PROVIDER.google,
|
|
89
99
|
baseURLSupport: "none",
|
|
90
|
-
supportedFileTypes: []
|
|
100
|
+
supportedFileTypes: [],
|
|
91
101
|
// No defaults - models must explicitly specify support
|
|
102
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.google
|
|
92
103
|
},
|
|
93
104
|
// https://console.groq.com/docs/models
|
|
94
105
|
groq: {
|
|
95
106
|
models: MODELS_BY_PROVIDER.groq,
|
|
96
107
|
baseURLSupport: "none",
|
|
97
|
-
supportedFileTypes: []
|
|
108
|
+
supportedFileTypes: [],
|
|
98
109
|
// Groq currently doesn't support file uploads
|
|
110
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.groq
|
|
99
111
|
},
|
|
100
112
|
// https://docs.x.ai/docs/models
|
|
101
113
|
// Note: XAI API only supports image uploads (JPG/PNG up to 20MB), not PDFs
|
|
102
114
|
xai: {
|
|
103
115
|
models: MODELS_BY_PROVIDER.xai,
|
|
104
116
|
baseURLSupport: "none",
|
|
105
|
-
supportedFileTypes: []
|
|
117
|
+
supportedFileTypes: [],
|
|
106
118
|
// No defaults - models must explicitly specify support
|
|
119
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.xai
|
|
107
120
|
},
|
|
108
121
|
// https://docs.cohere.com/reference/models
|
|
109
122
|
cohere: {
|
|
110
123
|
models: MODELS_BY_PROVIDER.cohere,
|
|
111
124
|
baseURLSupport: "none",
|
|
112
|
-
supportedFileTypes: []
|
|
125
|
+
supportedFileTypes: [],
|
|
113
126
|
// No defaults - models must explicitly specify support
|
|
127
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.cohere
|
|
114
128
|
},
|
|
115
129
|
// https://platform.minimax.io/docs/api-reference/text-openai-api
|
|
116
130
|
// MiniMax provides an OpenAI-compatible endpoint at https://api.minimax.chat/v1
|
|
117
131
|
minimax: {
|
|
118
132
|
models: MODELS_BY_PROVIDER.minimax,
|
|
119
133
|
baseURLSupport: "none",
|
|
120
|
-
supportedFileTypes: []
|
|
134
|
+
supportedFileTypes: [],
|
|
121
135
|
// No defaults - models must explicitly specify support
|
|
136
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.minimax
|
|
122
137
|
},
|
|
123
138
|
// https://open.bigmodel.cn/dev/api/normal-model/glm-4
|
|
124
139
|
// GLM (Zhipu AI) provides an OpenAI-compatible endpoint
|
|
125
140
|
glm: {
|
|
126
141
|
models: MODELS_BY_PROVIDER.glm,
|
|
127
142
|
baseURLSupport: "none",
|
|
128
|
-
supportedFileTypes: []
|
|
143
|
+
supportedFileTypes: [],
|
|
129
144
|
// No defaults - models must explicitly specify support
|
|
145
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.glm
|
|
130
146
|
},
|
|
131
147
|
// https://openrouter.ai/docs
|
|
132
148
|
// OpenRouter is a unified API gateway providing access to 100+ models from various providers.
|
|
@@ -138,8 +154,9 @@ const LLM_REGISTRY = {
|
|
|
138
154
|
supportedFileTypes: ["pdf", "image", "audio"],
|
|
139
155
|
// Allow all types - user assumes responsibility
|
|
140
156
|
supportsCustomModels: true,
|
|
141
|
-
supportsAllRegistryModels: true
|
|
157
|
+
supportsAllRegistryModels: true,
|
|
142
158
|
// Can serve models from all other providers
|
|
159
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.openrouter
|
|
143
160
|
},
|
|
144
161
|
// https://docs.litellm.ai/
|
|
145
162
|
// LiteLLM is an OpenAI-compatible proxy that unifies 100+ LLM providers.
|
|
@@ -163,8 +180,9 @@ const LLM_REGISTRY = {
|
|
|
163
180
|
vertex: {
|
|
164
181
|
models: MODELS_BY_PROVIDER.vertex,
|
|
165
182
|
baseURLSupport: "none",
|
|
166
|
-
supportedFileTypes: []
|
|
183
|
+
supportedFileTypes: [],
|
|
167
184
|
// No defaults - models must explicitly specify support
|
|
185
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.vertex
|
|
168
186
|
},
|
|
169
187
|
// https://docs.aws.amazon.com/bedrock/latest/userguide/models.html
|
|
170
188
|
bedrock: {
|
|
@@ -172,7 +190,8 @@ const LLM_REGISTRY = {
|
|
|
172
190
|
baseURLSupport: "none",
|
|
173
191
|
supportedFileTypes: [],
|
|
174
192
|
// No defaults - models must explicitly specify support
|
|
175
|
-
supportsCustomModels: true
|
|
193
|
+
supportsCustomModels: true,
|
|
194
|
+
modelsDev: MODELS_DEV_PROVIDER_METADATA_BY_PROVIDER.bedrock
|
|
176
195
|
},
|
|
177
196
|
// Native local model execution via node-llama-cpp
|
|
178
197
|
local: {
|
|
@@ -200,7 +219,7 @@ const LLM_REGISTRY = {
|
|
|
200
219
|
// Claude models (Anthropic via OpenRouter)
|
|
201
220
|
{
|
|
202
221
|
name: "anthropic/claude-haiku-4.5",
|
|
203
|
-
displayName: "Claude 4.5
|
|
222
|
+
displayName: "Claude Haiku 4.5",
|
|
204
223
|
maxInputTokens: 2e5,
|
|
205
224
|
default: true,
|
|
206
225
|
supportedFileTypes: ["pdf", "image"],
|
|
@@ -215,7 +234,7 @@ const LLM_REGISTRY = {
|
|
|
215
234
|
},
|
|
216
235
|
{
|
|
217
236
|
name: "anthropic/claude-sonnet-4.5",
|
|
218
|
-
displayName: "Claude 4.5
|
|
237
|
+
displayName: "Claude Sonnet 4.5",
|
|
219
238
|
maxInputTokens: 2e5,
|
|
220
239
|
supportedFileTypes: ["pdf", "image"],
|
|
221
240
|
pricing: {
|
|
@@ -229,7 +248,7 @@ const LLM_REGISTRY = {
|
|
|
229
248
|
},
|
|
230
249
|
{
|
|
231
250
|
name: "anthropic/claude-opus-4.5",
|
|
232
|
-
displayName: "Claude 4.5
|
|
251
|
+
displayName: "Claude Opus 4.5",
|
|
233
252
|
maxInputTokens: 2e5,
|
|
234
253
|
supportedFileTypes: ["pdf", "image"],
|
|
235
254
|
pricing: {
|
|
@@ -463,20 +482,91 @@ function pickExistingOpenRouterModelId(candidates) {
|
|
|
463
482
|
return null;
|
|
464
483
|
}
|
|
465
484
|
function findModelInfo(provider, model) {
|
|
485
|
+
if (provider === "openrouter" && model.includes("/")) {
|
|
486
|
+
const dynamicOpenRouterModel = getOpenRouterGatewayModelById(model);
|
|
487
|
+
if (dynamicOpenRouterModel) return dynamicOpenRouterModel;
|
|
488
|
+
}
|
|
466
489
|
const providerInfo = LLM_REGISTRY[provider];
|
|
467
490
|
const normalizedModel = getNormalizedModelIdForLookup(provider, model);
|
|
468
491
|
const direct = providerInfo.models.find((m) => m.name.toLowerCase() === normalizedModel);
|
|
469
492
|
if (direct) return direct;
|
|
470
493
|
if (provider !== "openrouter" && hasAllRegistryModelsSupport(provider) && model.includes("/")) {
|
|
471
|
-
const openrouterModel =
|
|
472
|
-
(m) => m.name.toLowerCase() === model.toLowerCase()
|
|
473
|
-
);
|
|
494
|
+
const openrouterModel = getOpenRouterGatewayModelById(model);
|
|
474
495
|
if (openrouterModel) return openrouterModel;
|
|
475
496
|
}
|
|
476
497
|
return null;
|
|
477
498
|
}
|
|
499
|
+
function ensureOpenRouterCatalogRefreshScheduled() {
|
|
500
|
+
const cacheInfo = getOpenRouterModelCacheInfo();
|
|
501
|
+
if (cacheInfo.modelCount === 0) {
|
|
502
|
+
scheduleOpenRouterModelRefresh({ force: true });
|
|
503
|
+
} else if (!cacheInfo.isFresh) {
|
|
504
|
+
scheduleOpenRouterModelRefresh();
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function findOpenRouterSnapshotModelById(modelId) {
|
|
508
|
+
const normalized = modelId.toLowerCase();
|
|
509
|
+
return LLM_REGISTRY.openrouter.models.find((m) => m.name.toLowerCase() === normalized) ?? null;
|
|
510
|
+
}
|
|
511
|
+
function buildOpenRouterGatewayModelInfo(cachedModel, snapshot) {
|
|
512
|
+
const providerDefaults = LLM_REGISTRY.openrouter.supportedFileTypes;
|
|
513
|
+
const displayName = snapshot?.displayName ?? cachedModel.displayName;
|
|
514
|
+
const supportedFileTypes = snapshot?.supportedFileTypes ?? providerDefaults;
|
|
515
|
+
const maxInputTokens = typeof cachedModel.contextLength === "number" && cachedModel.contextLength > 0 ? cachedModel.contextLength : snapshot?.maxInputTokens ?? DEFAULT_MAX_INPUT_TOKENS;
|
|
516
|
+
const inferredReasoning = cachedModel.supportedParameters?.includes("reasoning") === true ? true : void 0;
|
|
517
|
+
const inferredSupportsTemperature = cachedModel.supportedParameters?.includes("temperature") === true ? true : void 0;
|
|
518
|
+
return {
|
|
519
|
+
name: snapshot?.name ?? cachedModel.id,
|
|
520
|
+
maxInputTokens,
|
|
521
|
+
supportedFileTypes,
|
|
522
|
+
...snapshot?.default ? { default: true } : {},
|
|
523
|
+
...displayName ? { displayName } : {},
|
|
524
|
+
...typeof snapshot?.reasoning === "boolean" ? { reasoning: snapshot.reasoning } : typeof inferredReasoning === "boolean" ? { reasoning: inferredReasoning } : {},
|
|
525
|
+
...typeof snapshot?.supportsTemperature === "boolean" ? { supportsTemperature: snapshot.supportsTemperature } : typeof inferredSupportsTemperature === "boolean" ? { supportsTemperature: inferredSupportsTemperature } : {},
|
|
526
|
+
...typeof snapshot?.supportsInterleaved === "boolean" ? { supportsInterleaved: snapshot.supportsInterleaved } : {},
|
|
527
|
+
...snapshot?.releaseDate ? { releaseDate: snapshot.releaseDate } : {},
|
|
528
|
+
...typeof snapshot?.supportsToolCall === "boolean" ? { supportsToolCall: snapshot.supportsToolCall } : {},
|
|
529
|
+
...snapshot?.status ? { status: snapshot.status } : {},
|
|
530
|
+
...snapshot?.modalities ? { modalities: snapshot.modalities } : {},
|
|
531
|
+
...snapshot?.providerMetadata ? { providerMetadata: snapshot.providerMetadata } : {},
|
|
532
|
+
...snapshot?.interleaved ? { interleaved: snapshot.interleaved } : {},
|
|
533
|
+
...snapshot?.pricing ? { pricing: snapshot.pricing } : {}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function getOpenRouterGatewayModelById(modelId) {
|
|
537
|
+
ensureOpenRouterCatalogRefreshScheduled();
|
|
538
|
+
const snapshot = findOpenRouterSnapshotModelById(modelId);
|
|
539
|
+
const cached = getCachedOpenRouterModelsWithInfo();
|
|
540
|
+
if (!cached || cached.length === 0) {
|
|
541
|
+
return snapshot ? { ...snapshot } : null;
|
|
542
|
+
}
|
|
543
|
+
const normalized = modelId.toLowerCase();
|
|
544
|
+
const cachedModel = cached.find((m) => m.id.toLowerCase() === normalized);
|
|
545
|
+
if (!cachedModel) return snapshot ? { ...snapshot } : null;
|
|
546
|
+
return buildOpenRouterGatewayModelInfo(cachedModel, snapshot);
|
|
547
|
+
}
|
|
548
|
+
function getOpenRouterGatewayCatalogModels() {
|
|
549
|
+
ensureOpenRouterCatalogRefreshScheduled();
|
|
550
|
+
const cached = getCachedOpenRouterModelsWithInfo();
|
|
551
|
+
if (!cached || cached.length === 0) {
|
|
552
|
+
return LLM_REGISTRY.openrouter.models.map((m) => ({ ...m }));
|
|
553
|
+
}
|
|
554
|
+
const models = cached.map(
|
|
555
|
+
(cachedModel) => buildOpenRouterGatewayModelInfo(
|
|
556
|
+
cachedModel,
|
|
557
|
+
findOpenRouterSnapshotModelById(cachedModel.id)
|
|
558
|
+
)
|
|
559
|
+
).sort((a, b) => a.name.localeCompare(b.name));
|
|
560
|
+
return models;
|
|
561
|
+
}
|
|
478
562
|
function getAllModelsForProvider(provider) {
|
|
479
563
|
const providerInfo = LLM_REGISTRY[provider];
|
|
564
|
+
if (provider === "openrouter") {
|
|
565
|
+
return getOpenRouterGatewayCatalogModels().map((m) => ({
|
|
566
|
+
...m,
|
|
567
|
+
originalProvider: "openrouter"
|
|
568
|
+
}));
|
|
569
|
+
}
|
|
480
570
|
if (!providerInfo.supportsAllRegistryModels) {
|
|
481
571
|
return providerInfo.models.map((m) => ({ ...m }));
|
|
482
572
|
}
|
|
@@ -488,13 +578,11 @@ function getAllModelsForProvider(provider) {
|
|
|
488
578
|
seen.add(key);
|
|
489
579
|
allModels.push({ ...model, originalProvider: provider });
|
|
490
580
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
allModels.push({ ...model, originalProvider: "openrouter" });
|
|
497
|
-
}
|
|
581
|
+
for (const model of getOpenRouterGatewayCatalogModels()) {
|
|
582
|
+
const key = model.name.toLowerCase();
|
|
583
|
+
if (seen.has(key)) continue;
|
|
584
|
+
seen.add(key);
|
|
585
|
+
allModels.push({ ...model, originalProvider: "openrouter" });
|
|
498
586
|
}
|
|
499
587
|
return allModels;
|
|
500
588
|
}
|
|
@@ -701,8 +789,28 @@ function getModelDisplayName(model, provider) {
|
|
|
701
789
|
return model;
|
|
702
790
|
}
|
|
703
791
|
}
|
|
704
|
-
function isReasoningCapableModel(model,
|
|
705
|
-
const
|
|
792
|
+
function isReasoningCapableModel(model, provider) {
|
|
793
|
+
const registryProvider = (() => {
|
|
794
|
+
if (model.includes("/")) return "openrouter";
|
|
795
|
+
if (provider) return provider;
|
|
796
|
+
try {
|
|
797
|
+
return getProviderFromModel(model);
|
|
798
|
+
} catch {
|
|
799
|
+
return void 0;
|
|
800
|
+
}
|
|
801
|
+
})();
|
|
802
|
+
if (registryProvider === "openrouter" && model.includes("/")) {
|
|
803
|
+
const dynamicModel = getOpenRouterGatewayModelById(model);
|
|
804
|
+
if (dynamicModel?.reasoning === true) return true;
|
|
805
|
+
if (dynamicModel?.reasoning === false) return false;
|
|
806
|
+
}
|
|
807
|
+
if (registryProvider) {
|
|
808
|
+
const modelInfo = findModelInfo(registryProvider, model);
|
|
809
|
+
if (modelInfo?.reasoning === true) return true;
|
|
810
|
+
if (modelInfo?.reasoning === false) return false;
|
|
811
|
+
}
|
|
812
|
+
const modelIdForHeuristics = model.includes("/") ? model.split("/").pop() ?? model : model;
|
|
813
|
+
const modelLower = modelIdForHeuristics.toLowerCase();
|
|
706
814
|
if (modelLower.includes("codex")) {
|
|
707
815
|
return true;
|
|
708
816
|
}
|