@kenkaiiii/gg-core 5.97.1 → 5.98.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.
package/dist/index.d.cts CHANGED
@@ -18,6 +18,29 @@ interface ParsedOpenRouterCatalog {
18
18
  */
19
19
  declare function parseOpenRouterCatalog(body: unknown): ParsedOpenRouterCatalog;
20
20
 
21
+ /** The two OpenCode Console plans, each with its own endpoint and model list. */
22
+ type OpenCodeProvider = "opencode" | "opencode-go";
23
+ declare const OPENCODE_PROVIDERS: readonly OpenCodeProvider[];
24
+ /** Where each plan publishes its model list. Public: the list needs no key. */
25
+ declare const OPENCODE_CATALOG_URLS: Record<OpenCodeProvider, string>;
26
+ interface ParsedOpenCodeCatalog {
27
+ models: ModelInfo[];
28
+ /** Rows dropped: not served on Chat Completions, no tool calling, free tier, or malformed. */
29
+ skipped: number;
30
+ }
31
+ /** The registry id of a Console model: the plan's provider id, then the gateway's id. */
32
+ declare function formatOpenCodeModelId(provider: OpenCodeProvider, rawId: string): string;
33
+ /**
34
+ * Turn a Console `/v1/models` body into registry rows for one plan. Only models
35
+ * the gateway serves on Chat Completions are listed, since that is the one API
36
+ * gg-ai sends OpenCode requests to: a Responses, Messages or Gemini model
37
+ * called there has failed for other clients (HTTP 500, "Model does not support
38
+ * this protocol"). Pay-as-you-go also drops the free tier: the gateway answers
39
+ * HTTP 403 for those models from any client but OpenCode itself. Go keeps its
40
+ * free models, which the subscription covers.
41
+ */
42
+ declare function parseOpenCodeCatalog(provider: OpenCodeProvider, body: unknown): ParsedOpenCodeCatalog;
43
+
21
44
  declare function getSupportedThinkingLevels(provider: Provider, model: string): readonly ThinkingLevel[];
22
45
  /**
23
46
  * The lowest effort `model` accepts — the first rung of its ladder, never
@@ -1058,4 +1081,4 @@ interface AutoUpdater {
1058
1081
  }
1059
1082
  declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
1060
1083
 
1061
- export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, CHATGPT_PLAN_BASE_URL, CHATGPT_PLAN_NOT_ENABLED_MESSAGE, CHATGPT_PLAN_SCOPE, CHATGPT_USAGE_URL, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, type ChatGPTLoginOptions, ChatGPTPlanNotEnabledError, type ClaudeCodeAuthStatus, type ClaudeCodeInstallProgress, type ClaudeCodeManifest, type ClaudeCodePlatformAsset, type ClaudeCodeRateLimitInfo, type ClaudeCodeRunOptions, type ClaudeCodeRuntimeOptions, type ClaudeCodeSignInOptions, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, type EnsureClaudeCodeOptions, FALLBACK_CONTEXT_WINDOW, type FetchedSubscriptionUsageProvider, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, KIMI_CODE_DEFAULT_BASE_URL, KIMI_CODE_KEY, KIMI_CODE_OVERSEAS_BASE_URL, 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, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, OPENAI_CHATGPT_KEY, OPENROUTER_DEFAULT_BASE_URL, PLAN_MODE_THINKING_CAP, type ParsedOpenRouterCatalog, type ProbeOptions, type ProgressCallback, RETIRED_SIGN_INS, type RetiredSignIn, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, apiKeyStorageKeys, authPriorityNote, clampThinkingForPlanMode, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectKimiCodeBaseUrl, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchChatGPTPlanModels, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, generatePKCE, getAuthProvider, getChatGPTHostId, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, isClaudeCodeAuthMarker, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, localAuthStorageKey, localModelShortName, log, loginChatGPT, loginClaudeCode, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseCallbackInput, parseLocalModelId, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshChatGPTToken, registerLogCleanup, requiredKeyLabel, resample, resolveClaudeCodeBinary, revokeChatGPTSignIn, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, storageKeyProvider, toModelInfo, transcribeVoice, verifyIdToken, withFileLock };
1084
+ export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, CHATGPT_PLAN_BASE_URL, CHATGPT_PLAN_NOT_ENABLED_MESSAGE, CHATGPT_PLAN_SCOPE, CHATGPT_USAGE_URL, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, type ChatGPTLoginOptions, ChatGPTPlanNotEnabledError, type ClaudeCodeAuthStatus, type ClaudeCodeInstallProgress, type ClaudeCodeManifest, type ClaudeCodePlatformAsset, type ClaudeCodeRateLimitInfo, type ClaudeCodeRunOptions, type ClaudeCodeRuntimeOptions, type ClaudeCodeSignInOptions, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, type EnsureClaudeCodeOptions, FALLBACK_CONTEXT_WINDOW, type FetchedSubscriptionUsageProvider, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, KIMI_CODE_DEFAULT_BASE_URL, KIMI_CODE_KEY, KIMI_CODE_OVERSEAS_BASE_URL, 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, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, OPENAI_CHATGPT_KEY, OPENCODE_CATALOG_URLS, OPENCODE_PROVIDERS, OPENROUTER_DEFAULT_BASE_URL, type OpenCodeProvider, PLAN_MODE_THINKING_CAP, type ParsedOpenCodeCatalog, type ParsedOpenRouterCatalog, type ProbeOptions, type ProgressCallback, RETIRED_SIGN_INS, type RetiredSignIn, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, apiKeyStorageKeys, authPriorityNote, clampThinkingForPlanMode, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectKimiCodeBaseUrl, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchChatGPTPlanModels, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, formatOpenCodeModelId, generatePKCE, getAuthProvider, getChatGPTHostId, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, isClaudeCodeAuthMarker, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, localAuthStorageKey, localModelShortName, log, loginChatGPT, loginClaudeCode, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseCallbackInput, parseLocalModelId, parseOpenCodeCatalog, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshChatGPTToken, registerLogCleanup, requiredKeyLabel, resample, resolveClaudeCodeBinary, revokeChatGPTSignIn, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, storageKeyProvider, toModelInfo, transcribeVoice, verifyIdToken, withFileLock };
package/dist/index.d.ts CHANGED
@@ -18,6 +18,29 @@ interface ParsedOpenRouterCatalog {
18
18
  */
19
19
  declare function parseOpenRouterCatalog(body: unknown): ParsedOpenRouterCatalog;
20
20
 
21
+ /** The two OpenCode Console plans, each with its own endpoint and model list. */
22
+ type OpenCodeProvider = "opencode" | "opencode-go";
23
+ declare const OPENCODE_PROVIDERS: readonly OpenCodeProvider[];
24
+ /** Where each plan publishes its model list. Public: the list needs no key. */
25
+ declare const OPENCODE_CATALOG_URLS: Record<OpenCodeProvider, string>;
26
+ interface ParsedOpenCodeCatalog {
27
+ models: ModelInfo[];
28
+ /** Rows dropped: not served on Chat Completions, no tool calling, free tier, or malformed. */
29
+ skipped: number;
30
+ }
31
+ /** The registry id of a Console model: the plan's provider id, then the gateway's id. */
32
+ declare function formatOpenCodeModelId(provider: OpenCodeProvider, rawId: string): string;
33
+ /**
34
+ * Turn a Console `/v1/models` body into registry rows for one plan. Only models
35
+ * the gateway serves on Chat Completions are listed, since that is the one API
36
+ * gg-ai sends OpenCode requests to: a Responses, Messages or Gemini model
37
+ * called there has failed for other clients (HTTP 500, "Model does not support
38
+ * this protocol"). Pay-as-you-go also drops the free tier: the gateway answers
39
+ * HTTP 403 for those models from any client but OpenCode itself. Go keeps its
40
+ * free models, which the subscription covers.
41
+ */
42
+ declare function parseOpenCodeCatalog(provider: OpenCodeProvider, body: unknown): ParsedOpenCodeCatalog;
43
+
21
44
  declare function getSupportedThinkingLevels(provider: Provider, model: string): readonly ThinkingLevel[];
22
45
  /**
23
46
  * The lowest effort `model` accepts — the first rung of its ladder, never
@@ -1058,4 +1081,4 @@ interface AutoUpdater {
1058
1081
  }
1059
1082
  declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
1060
1083
 
1061
- export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, CHATGPT_PLAN_BASE_URL, CHATGPT_PLAN_NOT_ENABLED_MESSAGE, CHATGPT_PLAN_SCOPE, CHATGPT_USAGE_URL, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, type ChatGPTLoginOptions, ChatGPTPlanNotEnabledError, type ClaudeCodeAuthStatus, type ClaudeCodeInstallProgress, type ClaudeCodeManifest, type ClaudeCodePlatformAsset, type ClaudeCodeRateLimitInfo, type ClaudeCodeRunOptions, type ClaudeCodeRuntimeOptions, type ClaudeCodeSignInOptions, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, type EnsureClaudeCodeOptions, FALLBACK_CONTEXT_WINDOW, type FetchedSubscriptionUsageProvider, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, KIMI_CODE_DEFAULT_BASE_URL, KIMI_CODE_KEY, KIMI_CODE_OVERSEAS_BASE_URL, 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, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, OPENAI_CHATGPT_KEY, OPENROUTER_DEFAULT_BASE_URL, PLAN_MODE_THINKING_CAP, type ParsedOpenRouterCatalog, type ProbeOptions, type ProgressCallback, RETIRED_SIGN_INS, type RetiredSignIn, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, apiKeyStorageKeys, authPriorityNote, clampThinkingForPlanMode, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectKimiCodeBaseUrl, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchChatGPTPlanModels, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, generatePKCE, getAuthProvider, getChatGPTHostId, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, isClaudeCodeAuthMarker, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, localAuthStorageKey, localModelShortName, log, loginChatGPT, loginClaudeCode, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseCallbackInput, parseLocalModelId, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshChatGPTToken, registerLogCleanup, requiredKeyLabel, resample, resolveClaudeCodeBinary, revokeChatGPTSignIn, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, storageKeyProvider, toModelInfo, transcribeVoice, verifyIdToken, withFileLock };
1084
+ export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, CHATGPT_PLAN_BASE_URL, CHATGPT_PLAN_NOT_ENABLED_MESSAGE, CHATGPT_PLAN_SCOPE, CHATGPT_USAGE_URL, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, type ChatGPTLoginOptions, ChatGPTPlanNotEnabledError, type ClaudeCodeAuthStatus, type ClaudeCodeInstallProgress, type ClaudeCodeManifest, type ClaudeCodePlatformAsset, type ClaudeCodeRateLimitInfo, type ClaudeCodeRunOptions, type ClaudeCodeRuntimeOptions, type ClaudeCodeSignInOptions, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, type EnsureClaudeCodeOptions, FALLBACK_CONTEXT_WINDOW, type FetchedSubscriptionUsageProvider, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, KIMI_CODE_DEFAULT_BASE_URL, KIMI_CODE_KEY, KIMI_CODE_OVERSEAS_BASE_URL, 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, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, OPENAI_CHATGPT_KEY, OPENCODE_CATALOG_URLS, OPENCODE_PROVIDERS, OPENROUTER_DEFAULT_BASE_URL, type OpenCodeProvider, PLAN_MODE_THINKING_CAP, type ParsedOpenCodeCatalog, type ParsedOpenRouterCatalog, type ProbeOptions, type ProgressCallback, RETIRED_SIGN_INS, type RetiredSignIn, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, apiKeyStorageKeys, authPriorityNote, clampThinkingForPlanMode, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectKimiCodeBaseUrl, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchChatGPTPlanModels, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, formatOpenCodeModelId, generatePKCE, getAuthProvider, getChatGPTHostId, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, isClaudeCodeAuthMarker, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, localAuthStorageKey, localModelShortName, log, loginChatGPT, loginClaudeCode, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseCallbackInput, parseLocalModelId, parseOpenCodeCatalog, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshChatGPTToken, registerLogCleanup, requiredKeyLabel, resample, resolveClaudeCodeBinary, revokeChatGPTSignIn, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, storageKeyProvider, toModelInfo, transcribeVoice, verifyIdToken, withFileLock };
package/dist/index.js CHANGED
@@ -85,7 +85,7 @@ import {
85
85
  verifyIdToken,
86
86
  withFileLock,
87
87
  withoutPaidTier
88
- } from "./chunk-OVIBOKD4.js";
88
+ } from "./chunk-Q6ZD2VQV.js";
89
89
  import {
90
90
  getAppPaths
91
91
  } from "./chunk-GXOFTHM5.js";
@@ -143,6 +143,70 @@ function parseOpenRouterCatalog(body) {
143
143
  return { models, skipped };
144
144
  }
145
145
 
146
+ // src/opencode-catalog.ts
147
+ var OPENCODE_PROVIDERS = ["opencode-go", "opencode"];
148
+ var OPENCODE_CATALOG_URLS = {
149
+ opencode: "https://opencode.ai/inference/v1/models",
150
+ "opencode-go": "https://opencode.ai/inference/go/v1/models"
151
+ };
152
+ var EFFORT_LADDER2 = ["low", "medium", "high", "xhigh", "max"];
153
+ function positiveInt2(value) {
154
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
155
+ }
156
+ function strings2(value) {
157
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
158
+ }
159
+ function costTier2(price) {
160
+ if (typeof price !== "number" || !Number.isFinite(price) || price < 0.5) return "low";
161
+ return price < 3 ? "medium" : "high";
162
+ }
163
+ function formatOpenCodeModelId(provider, rawId) {
164
+ return `${provider}/${rawId}`;
165
+ }
166
+ function parseOpenCodeCatalog(provider, body) {
167
+ const data = body?.data;
168
+ if (!Array.isArray(data)) return { models: [], skipped: 0 };
169
+ const models = [];
170
+ let skipped = 0;
171
+ const seen = /* @__PURE__ */ new Set();
172
+ for (const raw of data) {
173
+ const rawId = typeof raw?.id === "string" ? raw.id.trim() : "";
174
+ const contextWindow = positiveInt2(raw?.limit?.context);
175
+ const price = raw?.cost?.text?.input?.price;
176
+ if (!/^[\w.:-]+$/.test(rawId) || seen.has(rawId) || raw.type !== "chat" || !raw.api?.["chat-completions"] || raw.capabilities?.tools?.supported !== true || !contextWindow || provider === "opencode" && price === 0) {
177
+ skipped++;
178
+ continue;
179
+ }
180
+ seen.add(rawId);
181
+ const reasoning = raw.capabilities.reasoning;
182
+ const efforts = strings2(reasoning?.effort);
183
+ const ladder = EFFORT_LADDER2.filter((rung) => efforts.includes(rung));
184
+ const defaultEffort = reasoning?.default?.type === "effort" ? reasoning.default.value : null;
185
+ const maxOutput = Math.min(
186
+ positiveInt2(raw.limit?.output) ?? 16384,
187
+ Math.floor(contextWindow / 2)
188
+ );
189
+ models.push({
190
+ id: formatOpenCodeModelId(provider, rawId),
191
+ name: typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : rawId,
192
+ provider,
193
+ contextWindow,
194
+ maxOutputTokens: Math.max(1, maxOutput),
195
+ // Only a declared effort ladder counts: a model without one is never sent
196
+ // a reasoning_effort it might reject.
197
+ supportsThinking: ladder.length > 0,
198
+ supportsImages: strings2(raw.modalities?.input).some((m) => m.startsWith("image")),
199
+ // Video needs a per-transport payload cap the catalog doesn't publish.
200
+ supportsVideo: false,
201
+ costTier: costTier2(price),
202
+ maxThinkingLevel: ladder[ladder.length - 1] ?? "low",
203
+ ...ladder.length > 0 ? { thinkingLevels: ladder } : {},
204
+ ...typeof defaultEffort === "string" && ladder.includes(defaultEffort) ? { defaultThinkingLevel: defaultEffort } : {}
205
+ });
206
+ }
207
+ return { models, skipped };
208
+ }
209
+
146
210
  // src/thinking-level.ts
147
211
  var OPENAI_GPT_THINKING_LEVELS = ["medium", "high", "xhigh"];
148
212
  var OPENAI_GPT_56_THINKING_LEVELS = [
@@ -881,6 +945,30 @@ var ALL_AUTH_PROVIDERS = [
881
945
  apiKeyLabel: "Sakana",
882
946
  methodDetails: apiKeyDetails("Sakana API key", "Pay-per-token from your Sakana API account.")
883
947
  },
948
+ {
949
+ value: "opencode-go",
950
+ label: "OpenCode Go",
951
+ description: "Kimi K3, GLM-5.3, GLM-5.3-Flash and more Go models",
952
+ methods: ["apikey"],
953
+ apiKeyLabel: "OpenCode",
954
+ methodDetails: apiKeyDetails(
955
+ "OpenCode API key",
956
+ "Uses your OpenCode Go subscription.",
957
+ "Create a personal API key in the OpenCode Console, in a workspace subscribed to Go."
958
+ )
959
+ },
960
+ {
961
+ value: "opencode",
962
+ label: "OpenCode",
963
+ description: "Kimi K3, GLM-5.3, GLM-5.3-Flash and more paid Console models",
964
+ methods: ["apikey"],
965
+ apiKeyLabel: "OpenCode",
966
+ methodDetails: apiKeyDetails(
967
+ "OpenCode API key",
968
+ "Pay-per-token from your OpenCode Console credits.",
969
+ "Free-tier models only run inside OpenCode, so they are not listed here."
970
+ )
971
+ },
884
972
  {
885
973
  value: "openrouter",
886
974
  label: "OpenRouter",
@@ -1609,6 +1697,8 @@ export {
1609
1697
  MODELS,
1610
1698
  NotLoggedInError,
1611
1699
  OPENAI_CHATGPT_KEY,
1700
+ OPENCODE_CATALOG_URLS,
1701
+ OPENCODE_PROVIDERS,
1612
1702
  OPENROUTER_DEFAULT_BASE_URL,
1613
1703
  PLAN_MODE_THINKING_CAP,
1614
1704
  RETIRED_SIGN_INS,
@@ -1647,6 +1737,7 @@ export {
1647
1737
  findProbedModel,
1648
1738
  formatClaudeCodeInstallProgress,
1649
1739
  formatLocalModelId,
1740
+ formatOpenCodeModelId,
1650
1741
  generatePKCE,
1651
1742
  getAllModels,
1652
1743
  getAppPaths,
@@ -1690,6 +1781,7 @@ export {
1690
1781
  openLog,
1691
1782
  parseCallbackInput,
1692
1783
  parseLocalModelId,
1784
+ parseOpenCodeCatalog,
1693
1785
  parseOpenRouterCatalog,
1694
1786
  probeEndpoint,
1695
1787
  providerStorageKeys,