@kenkaiiii/gg-core 5.91.0 → 5.91.2
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/LICENSE +661 -21
- package/NOTICE +52 -0
- package/README.md +11 -11
- package/dist/{chunk-M53JVW2V.js → chunk-YXPGQIOD.js} +45 -6
- package/dist/chunk-YXPGQIOD.js.map +1 -0
- package/dist/index.cjs +110 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +67 -4
- package/dist/index.js.map +1 -1
- package/dist/model-registry.cjs +39 -2
- package/dist/model-registry.cjs.map +1 -1
- package/dist/model-registry.d.cts +15 -1
- package/dist/model-registry.d.ts +15 -1
- package/dist/model-registry.js +5 -1
- package/package.json +5 -4
- package/dist/chunk-M53JVW2V.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { ModelInfo } from './model-registry.cjs';
|
|
2
|
-
export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, HIDDEN_PROVIDERS, MODELS, ModelBilling, clearRuntimeModels, getAllModels, getAuthStorageKey, getAuthStorageKeys, getContextWindow, getDefaultModel, getDefaultThinkingLevel, getListedModels, getMaxThinkingLevel, getModel, getModelsForProvider, getSummaryModel, getToolResultCharLimit, getVideoByteLimit, isHiddenProvider, isPaidModel, registerRuntimeModels, usesOpenAICodexTransport, withoutPaidTier } from './model-registry.cjs';
|
|
2
|
+
export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, HIDDEN_PROVIDERS, MODELS, ModelBilling, clearRuntimeModels, getAllModels, getAuthStorageKey, getAuthStorageKeys, getContextWindow, getDefaultModel, getDefaultThinkingLevel, getListedModels, getMaxThinkingLevel, getModel, getModelsForProvider, getProviderCatalog, getSummaryModel, getToolResultCharLimit, getVideoByteLimit, isHiddenProvider, isPaidModel, registerRuntimeModels, setProviderCatalog, usesOpenAICodexTransport, withoutPaidTier } from './model-registry.cjs';
|
|
3
3
|
import { ThinkingLevel, Provider } from '@kenkaiiii/gg-ai';
|
|
4
4
|
export { getClaudeCliUserAgent, getClaudeCodeVersion, pendingClaudeCodeVersionRefresh } from '@kenkaiiii/gg-ai';
|
|
5
5
|
export { AppPaths, getAppPaths } from './paths.cjs';
|
|
6
6
|
|
|
7
|
+
/** gg-ai's OPENROUTER_BASE_URL — where the openrouter transport goes with no override. */
|
|
8
|
+
declare const OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
|
|
9
|
+
interface ParsedOpenRouterCatalog {
|
|
10
|
+
models: ModelInfo[];
|
|
11
|
+
/** Rows dropped because they can't call tools (the agent needs tools) or are malformed. */
|
|
12
|
+
skipped: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Turn an OpenRouter-style `/models` body into registry rows. Field mapping is
|
|
16
|
+
* the live schema: tools from `supported_parameters`, image input from
|
|
17
|
+
* `architecture.input_modalities`, the effort ladder from
|
|
18
|
+
* `reasoning.supported_efforts`, output cap from `top_provider`.
|
|
19
|
+
*/
|
|
20
|
+
declare function parseOpenRouterCatalog(body: unknown): ParsedOpenRouterCatalog;
|
|
21
|
+
|
|
7
22
|
declare function getSupportedThinkingLevels(provider: Provider, model: string): readonly ThinkingLevel[];
|
|
8
23
|
/**
|
|
9
24
|
* The lowest effort `model` accepts — the first rung of its ladder, never
|
|
@@ -40,6 +55,8 @@ interface LocalEndpoint {
|
|
|
40
55
|
apiKey?: string;
|
|
41
56
|
/** True for endpoints the user added by hand (removable). */
|
|
42
57
|
custom?: boolean;
|
|
58
|
+
/** User-pinned context window; wins over whatever the server reports. */
|
|
59
|
+
contextLength?: number;
|
|
43
60
|
}
|
|
44
61
|
/** One model as reported (and enriched) by a local server. */
|
|
45
62
|
interface LocalModel {
|
|
@@ -890,4 +907,4 @@ interface AutoUpdater {
|
|
|
890
907
|
}
|
|
891
908
|
declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
|
|
892
909
|
|
|
893
|
-
export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, FALLBACK_CONTEXT_WINDOW, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MINIMAX_CN_BASE_URL, MINIMAX_GLOBAL_BASE_URL, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, PLAN_MODE_THINKING_CAP, type ProbeOptions, type ProgressCallback, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, authPriorityNote, clampThinkingForPlanMode, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, fetchSubscriptionUsage, findProbedModel, formatLocalModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isGrokCliEndpoint, isKimiCodingEndpoint, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, loginXai, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, probeEndpoint, providerStorageKeys, readStoredBaseUrlSync, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
|
910
|
+
export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, FALLBACK_CONTEXT_WINDOW, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MINIMAX_CN_BASE_URL, MINIMAX_GLOBAL_BASE_URL, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, OPENROUTER_DEFAULT_BASE_URL, PLAN_MODE_THINKING_CAP, type ParsedOpenRouterCatalog, type ProbeOptions, type ProgressCallback, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, authPriorityNote, clampThinkingForPlanMode, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, fetchSubscriptionUsage, findProbedModel, formatLocalModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isGrokCliEndpoint, isKimiCodingEndpoint, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, loginXai, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readStoredBaseUrlSync, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { ModelInfo } from './model-registry.js';
|
|
2
|
-
export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, HIDDEN_PROVIDERS, MODELS, ModelBilling, clearRuntimeModels, getAllModels, getAuthStorageKey, getAuthStorageKeys, getContextWindow, getDefaultModel, getDefaultThinkingLevel, getListedModels, getMaxThinkingLevel, getModel, getModelsForProvider, getSummaryModel, getToolResultCharLimit, getVideoByteLimit, isHiddenProvider, isPaidModel, registerRuntimeModels, usesOpenAICodexTransport, withoutPaidTier } from './model-registry.js';
|
|
2
|
+
export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, HIDDEN_PROVIDERS, MODELS, ModelBilling, clearRuntimeModels, getAllModels, getAuthStorageKey, getAuthStorageKeys, getContextWindow, getDefaultModel, getDefaultThinkingLevel, getListedModels, getMaxThinkingLevel, getModel, getModelsForProvider, getProviderCatalog, getSummaryModel, getToolResultCharLimit, getVideoByteLimit, isHiddenProvider, isPaidModel, registerRuntimeModels, setProviderCatalog, usesOpenAICodexTransport, withoutPaidTier } from './model-registry.js';
|
|
3
3
|
import { ThinkingLevel, Provider } from '@kenkaiiii/gg-ai';
|
|
4
4
|
export { getClaudeCliUserAgent, getClaudeCodeVersion, pendingClaudeCodeVersionRefresh } from '@kenkaiiii/gg-ai';
|
|
5
5
|
export { AppPaths, getAppPaths } from './paths.js';
|
|
6
6
|
|
|
7
|
+
/** gg-ai's OPENROUTER_BASE_URL — where the openrouter transport goes with no override. */
|
|
8
|
+
declare const OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
|
|
9
|
+
interface ParsedOpenRouterCatalog {
|
|
10
|
+
models: ModelInfo[];
|
|
11
|
+
/** Rows dropped because they can't call tools (the agent needs tools) or are malformed. */
|
|
12
|
+
skipped: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Turn an OpenRouter-style `/models` body into registry rows. Field mapping is
|
|
16
|
+
* the live schema: tools from `supported_parameters`, image input from
|
|
17
|
+
* `architecture.input_modalities`, the effort ladder from
|
|
18
|
+
* `reasoning.supported_efforts`, output cap from `top_provider`.
|
|
19
|
+
*/
|
|
20
|
+
declare function parseOpenRouterCatalog(body: unknown): ParsedOpenRouterCatalog;
|
|
21
|
+
|
|
7
22
|
declare function getSupportedThinkingLevels(provider: Provider, model: string): readonly ThinkingLevel[];
|
|
8
23
|
/**
|
|
9
24
|
* The lowest effort `model` accepts — the first rung of its ladder, never
|
|
@@ -40,6 +55,8 @@ interface LocalEndpoint {
|
|
|
40
55
|
apiKey?: string;
|
|
41
56
|
/** True for endpoints the user added by hand (removable). */
|
|
42
57
|
custom?: boolean;
|
|
58
|
+
/** User-pinned context window; wins over whatever the server reports. */
|
|
59
|
+
contextLength?: number;
|
|
43
60
|
}
|
|
44
61
|
/** One model as reported (and enriched) by a local server. */
|
|
45
62
|
interface LocalModel {
|
|
@@ -890,4 +907,4 @@ interface AutoUpdater {
|
|
|
890
907
|
}
|
|
891
908
|
declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
|
|
892
909
|
|
|
893
|
-
export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, FALLBACK_CONTEXT_WINDOW, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MINIMAX_CN_BASE_URL, MINIMAX_GLOBAL_BASE_URL, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, PLAN_MODE_THINKING_CAP, type ProbeOptions, type ProgressCallback, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, authPriorityNote, clampThinkingForPlanMode, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, fetchSubscriptionUsage, findProbedModel, formatLocalModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isGrokCliEndpoint, isKimiCodingEndpoint, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, loginXai, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, probeEndpoint, providerStorageKeys, readStoredBaseUrlSync, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
|
910
|
+
export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, FALLBACK_CONTEXT_WINDOW, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MINIMAX_CN_BASE_URL, MINIMAX_GLOBAL_BASE_URL, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, OPENROUTER_DEFAULT_BASE_URL, PLAN_MODE_THINKING_CAP, type ParsedOpenRouterCatalog, type ProbeOptions, type ProgressCallback, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, authPriorityNote, clampThinkingForPlanMode, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, fetchSubscriptionUsage, findProbedModel, formatLocalModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isGrokCliEndpoint, isKimiCodingEndpoint, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, loginXai, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readStoredBaseUrlSync, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
getMaxThinkingLevel,
|
|
33
33
|
getModel,
|
|
34
34
|
getModelsForProvider,
|
|
35
|
+
getProviderCatalog,
|
|
35
36
|
getSessionId,
|
|
36
37
|
getSummaryModel,
|
|
37
38
|
getToolResultCharLimit,
|
|
@@ -63,14 +64,68 @@ import {
|
|
|
63
64
|
refreshXaiToken,
|
|
64
65
|
registerLogCleanup,
|
|
65
66
|
registerRuntimeModels,
|
|
67
|
+
setProviderCatalog,
|
|
66
68
|
usesOpenAICodexTransport,
|
|
67
69
|
withFileLock,
|
|
68
70
|
withoutPaidTier
|
|
69
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-YXPGQIOD.js";
|
|
70
72
|
import {
|
|
71
73
|
getAppPaths
|
|
72
74
|
} from "./chunk-2X5L6U4Z.js";
|
|
73
75
|
|
|
76
|
+
// src/openrouter-catalog.ts
|
|
77
|
+
var OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
|
|
78
|
+
var EFFORT_LADDER = ["low", "medium", "high", "xhigh", "max"];
|
|
79
|
+
function positiveInt(value) {
|
|
80
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
|
|
81
|
+
}
|
|
82
|
+
function strings(value) {
|
|
83
|
+
return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
|
|
84
|
+
}
|
|
85
|
+
function costTier(prompt) {
|
|
86
|
+
const perToken = typeof prompt === "string" ? Number(prompt) : NaN;
|
|
87
|
+
if (!Number.isFinite(perToken) || perToken < 5e-7) return "low";
|
|
88
|
+
return perToken < 3e-6 ? "medium" : "high";
|
|
89
|
+
}
|
|
90
|
+
function parseOpenRouterCatalog(body) {
|
|
91
|
+
const data = body?.data;
|
|
92
|
+
if (!Array.isArray(data)) return { models: [], skipped: 0 };
|
|
93
|
+
const models = [];
|
|
94
|
+
let skipped = 0;
|
|
95
|
+
const seen = /* @__PURE__ */ new Set();
|
|
96
|
+
for (const raw of data) {
|
|
97
|
+
const id = typeof raw?.id === "string" ? raw.id.trim() : "";
|
|
98
|
+
const params = strings(raw?.supported_parameters);
|
|
99
|
+
const contextWindow = positiveInt(raw?.top_provider?.context_length) ?? positiveInt(raw?.context_length);
|
|
100
|
+
if (!id || seen.has(id) || !params.includes("tools") || !contextWindow) {
|
|
101
|
+
skipped++;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
seen.add(id);
|
|
105
|
+
const efforts = strings(raw.reasoning?.supported_efforts);
|
|
106
|
+
const ladder = EFFORT_LADDER.filter((rung) => efforts.includes(rung));
|
|
107
|
+
const supportsThinking = ladder.length > 0 || params.includes("reasoning") || params.includes("reasoning_effort");
|
|
108
|
+
const defaultEffort = raw.reasoning?.default_effort;
|
|
109
|
+
const maxOutput = positiveInt(raw.top_provider?.max_completion_tokens) ?? Math.min(contextWindow, 16384);
|
|
110
|
+
models.push({
|
|
111
|
+
id,
|
|
112
|
+
name: typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : id,
|
|
113
|
+
provider: "openrouter",
|
|
114
|
+
contextWindow,
|
|
115
|
+
maxOutputTokens: Math.min(maxOutput, contextWindow),
|
|
116
|
+
supportsThinking,
|
|
117
|
+
supportsImages: strings(raw.architecture?.input_modalities).includes("image"),
|
|
118
|
+
// Video needs a per-transport payload cap the catalog doesn't publish.
|
|
119
|
+
supportsVideo: false,
|
|
120
|
+
costTier: costTier(raw.pricing?.prompt),
|
|
121
|
+
maxThinkingLevel: ladder[ladder.length - 1] ?? "high",
|
|
122
|
+
...ladder.length > 0 ? { thinkingLevels: ladder } : {},
|
|
123
|
+
...typeof defaultEffort === "string" && ladder.includes(defaultEffort) ? { defaultThinkingLevel: defaultEffort } : {}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return { models, skipped };
|
|
127
|
+
}
|
|
128
|
+
|
|
74
129
|
// src/thinking-level.ts
|
|
75
130
|
var OPENAI_GPT_THINKING_LEVELS = ["medium", "high", "xhigh"];
|
|
76
131
|
var OPENAI_GPT_56_THINKING_LEVELS = [
|
|
@@ -138,6 +193,8 @@ function getSupportedThinkingLevels(provider, model) {
|
|
|
138
193
|
const maxIndex2 = LOCAL_THINKING_LEVELS.indexOf(info.maxThinkingLevel);
|
|
139
194
|
return maxIndex2 === -1 ? LOCAL_THINKING_LEVELS.slice(0, 3) : LOCAL_THINKING_LEVELS.slice(0, maxIndex2 + 1);
|
|
140
195
|
}
|
|
196
|
+
const declared = getModel(model)?.thinkingLevels;
|
|
197
|
+
if (declared && declared.length > 0) return declared;
|
|
141
198
|
const maxLevel = getMaxThinkingLevel(model);
|
|
142
199
|
if (isAnthropicAdaptiveModel(provider, model)) {
|
|
143
200
|
const levels2 = isAnthropicXhighModel(provider, model) ? ANTHROPIC_XHIGH_THINKING_LEVELS : ANTHROPIC_ADAPTIVE_THINKING_LEVELS;
|
|
@@ -293,7 +350,9 @@ async function probeEndpoint(endpoint, { timeoutMs = DEFAULT_PROBE_TIMEOUT_MS, s
|
|
|
293
350
|
const entries = (list.data ?? []).filter(
|
|
294
351
|
(entry) => typeof entry.id === "string" && entry.id.length > 0 && !NON_CHAT_ID_PATTERN.test(entry.id)
|
|
295
352
|
);
|
|
296
|
-
const
|
|
353
|
+
const enriched = await enrich(endpoint, entries, { timeoutMs, signal });
|
|
354
|
+
const pinned = contextLength(endpoint.contextLength);
|
|
355
|
+
const models = pinned === void 0 ? enriched : enriched.map((m) => ({ ...m, contextWindow: pinned, contextWindowKnown: true }));
|
|
297
356
|
log("INFO", "local-models", `Probed ${endpoint.label}`, {
|
|
298
357
|
baseUrl: endpoint.baseUrl,
|
|
299
358
|
models: String(models.length)
|
|
@@ -319,7 +378,7 @@ async function enrichCustom(endpoint, entries, options) {
|
|
|
319
378
|
return generic;
|
|
320
379
|
}
|
|
321
380
|
function genericModel(endpoint, entry) {
|
|
322
|
-
const declared = contextLength(entry.max_model_len) ?? contextLength(entry.context_length);
|
|
381
|
+
const declared = contextLength(entry.max_model_len) ?? contextLength(entry.context_length) ?? contextLength(entry.meta?.n_ctx);
|
|
323
382
|
return {
|
|
324
383
|
rawId: entry.id,
|
|
325
384
|
endpointId: endpoint.id,
|
|
@@ -499,7 +558,7 @@ function toModelInfo(model, endpoint) {
|
|
|
499
558
|
}
|
|
500
559
|
var cache;
|
|
501
560
|
function cacheKey(endpoints) {
|
|
502
|
-
return endpoints.map((e) => `${e.id}@${e.baseUrl}`).join("|");
|
|
561
|
+
return endpoints.map((e) => `${e.id}@${e.baseUrl}#${e.contextLength ?? ""}`).join("|");
|
|
503
562
|
}
|
|
504
563
|
async function discoverLocalModels(endpoints = DEFAULT_LOCAL_ENDPOINTS, options = {}) {
|
|
505
564
|
const key = cacheKey(endpoints);
|
|
@@ -1457,6 +1516,7 @@ export {
|
|
|
1457
1516
|
MODELS,
|
|
1458
1517
|
MOONSHOT_OAUTH_KEY,
|
|
1459
1518
|
NotLoggedInError,
|
|
1519
|
+
OPENROUTER_DEFAULT_BASE_URL,
|
|
1460
1520
|
PLAN_MODE_THINKING_CAP,
|
|
1461
1521
|
SubscriptionUsageError,
|
|
1462
1522
|
TelegramBot,
|
|
@@ -1498,6 +1558,7 @@ export {
|
|
|
1498
1558
|
getModel,
|
|
1499
1559
|
getModelsForProvider,
|
|
1500
1560
|
getNextThinkingLevel,
|
|
1561
|
+
getProviderCatalog,
|
|
1501
1562
|
getSessionId,
|
|
1502
1563
|
getSummaryModel,
|
|
1503
1564
|
getSupportedThinkingLevels,
|
|
@@ -1527,6 +1588,7 @@ export {
|
|
|
1527
1588
|
ollamaServedContext,
|
|
1528
1589
|
openLog,
|
|
1529
1590
|
parseLocalModelId,
|
|
1591
|
+
parseOpenRouterCatalog,
|
|
1530
1592
|
pendingClaudeCodeVersionRefresh,
|
|
1531
1593
|
probeEndpoint,
|
|
1532
1594
|
providerStorageKeys,
|
|
@@ -1540,6 +1602,7 @@ export {
|
|
|
1540
1602
|
registerRuntimeModels,
|
|
1541
1603
|
resample,
|
|
1542
1604
|
setProgressCallback,
|
|
1605
|
+
setProviderCatalog,
|
|
1543
1606
|
toModelInfo,
|
|
1544
1607
|
transcribeVoice,
|
|
1545
1608
|
usesOpenAICodexTransport,
|