@prestyj/core 5.33.0 → 5.35.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
@@ -19,6 +19,29 @@ interface ParsedOpenRouterCatalog {
19
19
  */
20
20
  declare function parseOpenRouterCatalog(body: unknown): ParsedOpenRouterCatalog;
21
21
 
22
+ /** The two OpenCode Console plans, each with its own endpoint and model list. */
23
+ type OpenCodeProvider = "opencode" | "opencode-go";
24
+ declare const OPENCODE_PROVIDERS: readonly OpenCodeProvider[];
25
+ /** Where each plan publishes its model list. Public: the list needs no key. */
26
+ declare const OPENCODE_CATALOG_URLS: Record<OpenCodeProvider, string>;
27
+ interface ParsedOpenCodeCatalog {
28
+ models: ModelInfo[];
29
+ /** Rows dropped: not served on Chat Completions, no tool calling, free tier, or malformed. */
30
+ skipped: number;
31
+ }
32
+ /** The registry id of a Console model: the plan's provider id, then the gateway's id. */
33
+ declare function formatOpenCodeModelId(provider: OpenCodeProvider, rawId: string): string;
34
+ /**
35
+ * Turn a Console `/v1/models` body into registry rows for one plan. Only models
36
+ * the gateway serves on Chat Completions are listed, since that is the one API
37
+ * @prestyj/ai sends OpenCode requests to: a Responses, Messages or Gemini model
38
+ * called there has failed for other clients (HTTP 500, "Model does not support
39
+ * this protocol"). Pay-as-you-go also drops the free tier: the gateway answers
40
+ * HTTP 403 for those models from any client but OpenCode itself. Go keeps its
41
+ * free models, which the subscription covers.
42
+ */
43
+ declare function parseOpenCodeCatalog(provider: OpenCodeProvider, body: unknown): ParsedOpenCodeCatalog;
44
+
22
45
  declare function getSupportedThinkingLevels(provider: Provider, model: string): readonly ThinkingLevel[];
23
46
  /**
24
47
  * The lowest effort `model` accepts — the first rung of its ladder, never
@@ -57,6 +80,8 @@ interface LocalEndpoint {
57
80
  custom?: boolean;
58
81
  /** User-pinned context window; wins over whatever the server reports. */
59
82
  contextLength?: number;
83
+ /** User-pinned image support (vLLM and most gateways never report it); wins over the server. */
84
+ supportsImages?: boolean;
60
85
  }
61
86
  /** One model as reported (and enriched) by a local server. */
62
87
  interface LocalModel {
@@ -158,6 +183,14 @@ declare function findProbedModel(probes: readonly LocalEndpointProbe[], modelId:
158
183
  endpoint: LocalEndpoint;
159
184
  } | undefined;
160
185
 
186
+ /** How a vision model writes screen coordinates when asked to point at something. */
187
+ type PointScale = "pixels" | "norm1000";
188
+ /**
189
+ * The coordinate scale a model answers in, from its id. Works on bare ids (`qwen3-vl:8b`),
190
+ * local ids (`local/lmstudio/qwen/qwen3.5-27b`) and OpenRouter ids (`qwen/qwen3-vl-32b-instruct`).
191
+ */
192
+ declare function pointScale(modelId: string): PointScale;
193
+
161
194
  type LogLevel = "INFO" | "ERROR" | "WARN" | "DEBUG";
162
195
  /**
163
196
  * Open the debug log in append mode, tagging this process with a session id and
@@ -1052,4 +1085,5 @@ interface AutoUpdater {
1052
1085
  }
1053
1086
  declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
1054
1087
 
1055
- export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, 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, 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, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isClaudeCodeAuthMarker, isGrokCliEndpoint, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginClaudeCode, loginGemini, loginKimi, loginOpenAI, loginXai, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, resolveClaudeCodeBinary, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, toModelInfo, transcribeVoice, withFileLock };
1088
+ export { AUTH_PROVIDERS, AuthStorage, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, DEFAULT_LOCAL_ENDPOINTS, FALLBACK_CONTEXT_WINDOW, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, MINIMAX_CN_BASE_URL, MINIMAX_GLOBAL_BASE_URL, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, OPENCODE_CATALOG_URLS, OPENCODE_PROVIDERS, OPENROUTER_DEFAULT_BASE_URL, PLAN_MODE_THINKING_CAP, SubscriptionUsageError, TelegramBot, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, authPriorityNote, clampThinkingForPlanMode, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, formatOpenCodeModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isClaudeCodeAuthMarker, isGrokCliEndpoint, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginClaudeCode, loginGemini, loginKimi, loginOpenAI, loginXai, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, parseOpenCodeCatalog, parseOpenRouterCatalog, pointScale, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, resolveClaudeCodeBinary, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, toModelInfo, transcribeVoice, withFileLock };
1089
+ export type { ApiKeyVariant, AuthMethod, AuthMethodMeta, AuthProviderMeta, AutoUpdateConfig, AutoUpdater, ClaudeCodeAuthStatus, ClaudeCodeInstallProgress, ClaudeCodeManifest, ClaudeCodePlatformAsset, ClaudeCodeRateLimitInfo, ClaudeCodeRunOptions, ClaudeCodeRuntimeOptions, ClaudeCodeSignInOptions, DiscoverOptions, DiscoveryResult, DualAuthProvider, EnsureClaudeCodeOptions, FetchedSubscriptionUsageProvider, InlineButton, LocalEndpoint, LocalEndpointKind, LocalEndpointProbe, LocalModel, LogLevel, OAuthCredentials, OAuthLoginCallbacks, OpenCodeProvider, ParsedOpenCodeCatalog, ParsedOpenRouterCatalog, PointScale, ProbeOptions, ProgressCallback, SubscriptionUsageProvider, SubscriptionUsageSnapshot, SubscriptionUsageWindow, TelegramConfig, TelegramMessage, TelegramUpdate, TelegramVoiceMessage };
package/dist/index.d.ts CHANGED
@@ -19,6 +19,29 @@ interface ParsedOpenRouterCatalog {
19
19
  */
20
20
  declare function parseOpenRouterCatalog(body: unknown): ParsedOpenRouterCatalog;
21
21
 
22
+ /** The two OpenCode Console plans, each with its own endpoint and model list. */
23
+ type OpenCodeProvider = "opencode" | "opencode-go";
24
+ declare const OPENCODE_PROVIDERS: readonly OpenCodeProvider[];
25
+ /** Where each plan publishes its model list. Public: the list needs no key. */
26
+ declare const OPENCODE_CATALOG_URLS: Record<OpenCodeProvider, string>;
27
+ interface ParsedOpenCodeCatalog {
28
+ models: ModelInfo[];
29
+ /** Rows dropped: not served on Chat Completions, no tool calling, free tier, or malformed. */
30
+ skipped: number;
31
+ }
32
+ /** The registry id of a Console model: the plan's provider id, then the gateway's id. */
33
+ declare function formatOpenCodeModelId(provider: OpenCodeProvider, rawId: string): string;
34
+ /**
35
+ * Turn a Console `/v1/models` body into registry rows for one plan. Only models
36
+ * the gateway serves on Chat Completions are listed, since that is the one API
37
+ * @prestyj/ai sends OpenCode requests to: a Responses, Messages or Gemini model
38
+ * called there has failed for other clients (HTTP 500, "Model does not support
39
+ * this protocol"). Pay-as-you-go also drops the free tier: the gateway answers
40
+ * HTTP 403 for those models from any client but OpenCode itself. Go keeps its
41
+ * free models, which the subscription covers.
42
+ */
43
+ declare function parseOpenCodeCatalog(provider: OpenCodeProvider, body: unknown): ParsedOpenCodeCatalog;
44
+
22
45
  declare function getSupportedThinkingLevels(provider: Provider, model: string): readonly ThinkingLevel[];
23
46
  /**
24
47
  * The lowest effort `model` accepts — the first rung of its ladder, never
@@ -57,6 +80,8 @@ interface LocalEndpoint {
57
80
  custom?: boolean;
58
81
  /** User-pinned context window; wins over whatever the server reports. */
59
82
  contextLength?: number;
83
+ /** User-pinned image support (vLLM and most gateways never report it); wins over the server. */
84
+ supportsImages?: boolean;
60
85
  }
61
86
  /** One model as reported (and enriched) by a local server. */
62
87
  interface LocalModel {
@@ -158,6 +183,14 @@ declare function findProbedModel(probes: readonly LocalEndpointProbe[], modelId:
158
183
  endpoint: LocalEndpoint;
159
184
  } | undefined;
160
185
 
186
+ /** How a vision model writes screen coordinates when asked to point at something. */
187
+ type PointScale = "pixels" | "norm1000";
188
+ /**
189
+ * The coordinate scale a model answers in, from its id. Works on bare ids (`qwen3-vl:8b`),
190
+ * local ids (`local/lmstudio/qwen/qwen3.5-27b`) and OpenRouter ids (`qwen/qwen3-vl-32b-instruct`).
191
+ */
192
+ declare function pointScale(modelId: string): PointScale;
193
+
161
194
  type LogLevel = "INFO" | "ERROR" | "WARN" | "DEBUG";
162
195
  /**
163
196
  * Open the debug log in append mode, tagging this process with a session id and
@@ -1052,4 +1085,5 @@ interface AutoUpdater {
1052
1085
  }
1053
1086
  declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
1054
1087
 
1055
- export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, 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, 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, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isClaudeCodeAuthMarker, isGrokCliEndpoint, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginClaudeCode, loginGemini, loginKimi, loginOpenAI, loginXai, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, resolveClaudeCodeBinary, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, toModelInfo, transcribeVoice, withFileLock };
1088
+ export { AUTH_PROVIDERS, AuthStorage, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, DEFAULT_LOCAL_ENDPOINTS, FALLBACK_CONTEXT_WINDOW, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, MINIMAX_CN_BASE_URL, MINIMAX_GLOBAL_BASE_URL, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, OPENCODE_CATALOG_URLS, OPENCODE_PROVIDERS, OPENROUTER_DEFAULT_BASE_URL, PLAN_MODE_THINKING_CAP, SubscriptionUsageError, TelegramBot, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, XIAOMI_TOKEN_PLAN_BASE_URLS, authPriorityNote, clampThinkingForPlanMode, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, formatOpenCodeModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isClaudeCodeAuthMarker, isGrokCliEndpoint, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginClaudeCode, loginGemini, loginKimi, loginOpenAI, loginXai, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, parseOpenCodeCatalog, parseOpenRouterCatalog, pointScale, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, resolveClaudeCodeBinary, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, toModelInfo, transcribeVoice, withFileLock };
1089
+ export type { ApiKeyVariant, AuthMethod, AuthMethodMeta, AuthProviderMeta, AutoUpdateConfig, AutoUpdater, ClaudeCodeAuthStatus, ClaudeCodeInstallProgress, ClaudeCodeManifest, ClaudeCodePlatformAsset, ClaudeCodeRateLimitInfo, ClaudeCodeRunOptions, ClaudeCodeRuntimeOptions, ClaudeCodeSignInOptions, DiscoverOptions, DiscoveryResult, DualAuthProvider, EnsureClaudeCodeOptions, FetchedSubscriptionUsageProvider, InlineButton, LocalEndpoint, LocalEndpointKind, LocalEndpointProbe, LocalModel, LogLevel, OAuthCredentials, OAuthLoginCallbacks, OpenCodeProvider, ParsedOpenCodeCatalog, ParsedOpenRouterCatalog, PointScale, ProbeOptions, ProgressCallback, SubscriptionUsageProvider, SubscriptionUsageSnapshot, SubscriptionUsageWindow, TelegramConfig, TelegramMessage, TelegramUpdate, TelegramVoiceMessage };
package/dist/index.js CHANGED
@@ -85,7 +85,7 @@ import {
85
85
  usesOpenAICodexTransport,
86
86
  withFileLock,
87
87
  withoutPaidTier
88
- } from "./chunk-G3ZS4V2K.js";
88
+ } from "./chunk-WSFHVWQ4.js";
89
89
  import {
90
90
  getAppPaths
91
91
  } from "./chunk-DVWS2KEW.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 = [
@@ -369,7 +433,12 @@ async function probeEndpoint(endpoint, { timeoutMs = DEFAULT_PROBE_TIMEOUT_MS, s
369
433
  );
370
434
  const enriched = await enrich(endpoint, entries, { timeoutMs, signal });
371
435
  const pinned = contextLength(endpoint.contextLength);
372
- const models = pinned === void 0 ? enriched : enriched.map((m) => ({ ...m, contextWindow: pinned, contextWindowKnown: true }));
436
+ const images = typeof endpoint.supportsImages === "boolean" ? endpoint.supportsImages : void 0;
437
+ const models = enriched.map((m) => ({
438
+ ...m,
439
+ ...pinned === void 0 ? {} : { contextWindow: pinned, contextWindowKnown: true },
440
+ ...images === void 0 ? {} : { supportsImages: images }
441
+ }));
373
442
  log("INFO", "local-models", `Probed ${endpoint.label}`, {
374
443
  baseUrl: endpoint.baseUrl,
375
444
  models: String(models.length)
@@ -389,7 +458,7 @@ async function enrichCustom(endpoint, entries, options) {
389
458
  const root = endpointRoot(endpoint.baseUrl);
390
459
  const props = await fetchJson(`${root}/props`, endpoint, options);
391
460
  const nCtx = contextLength(props?.default_generation_settings?.n_ctx);
392
- if (nCtx !== void 0) return llamaCppModels(endpoint, entries, nCtx);
461
+ if (nCtx !== void 0) return llamaCppModels(endpoint, entries, nCtx, props);
393
462
  const lmStudio = await fetchJson(`${root}/api/v1/models`, endpoint, options);
394
463
  if (Array.isArray(lmStudio?.models)) return enrichLmStudio(endpoint, entries, options, lmStudio);
395
464
  return generic;
@@ -532,14 +601,16 @@ async function enrichLlamaCpp(endpoint, entries, options) {
532
601
  return llamaCppModels(
533
602
  endpoint,
534
603
  entries,
535
- contextLength(props?.default_generation_settings?.n_ctx)
604
+ contextLength(props?.default_generation_settings?.n_ctx),
605
+ props
536
606
  );
537
607
  }
538
- function llamaCppModels(endpoint, entries, nCtx) {
608
+ function llamaCppModels(endpoint, entries, nCtx, props) {
539
609
  return entries.map((entry) => ({
540
610
  ...genericModel(endpoint, entry),
541
611
  contextWindow: nCtx ?? FALLBACK_CONTEXT_WINDOW,
542
- contextWindowKnown: nCtx !== void 0
612
+ contextWindowKnown: nCtx !== void 0,
613
+ supportsImages: props?.modalities?.vision === true
543
614
  }));
544
615
  }
545
616
  async function mapLimited(items, limit, fn) {
@@ -575,7 +646,7 @@ function toModelInfo(model, endpoint) {
575
646
  }
576
647
  var cache;
577
648
  function cacheKey(endpoints) {
578
- return endpoints.map((e) => `${e.id}@${e.baseUrl}#${e.contextLength ?? ""}`).join("|");
649
+ return endpoints.map((e) => `${e.id}@${e.baseUrl}#${e.contextLength ?? ""}#${e.supportsImages ?? ""}`).join("|");
579
650
  }
580
651
  async function discoverLocalModels(endpoints = DEFAULT_LOCAL_ENDPOINTS, options = {}) {
581
652
  const key = cacheKey(endpoints);
@@ -604,6 +675,12 @@ function findProbedModel(probes, modelId) {
604
675
  return void 0;
605
676
  }
606
677
 
678
+ // src/point-scale.ts
679
+ var NORM1000_PATTERN = /qwen3[-_.]?vl|qwen3[._]?[56](?![\d])/i;
680
+ function pointScale(modelId) {
681
+ return NORM1000_PATTERN.test(modelId) ? "norm1000" : "pixels";
682
+ }
683
+
607
684
  // src/claude-code/usage.ts
608
685
  import fsp from "fs/promises";
609
686
  import path from "path";
@@ -709,6 +786,9 @@ async function signOutOfClaudeCode(auth, opts = {}) {
709
786
  }
710
787
 
711
788
  // src/auth-providers.ts
789
+ function apiKeyDetails(label, billing, when = "") {
790
+ return { apikey: { method: "apikey", label, billing, when } };
791
+ }
712
792
  var ALL_AUTH_PROVIDERS = [
713
793
  {
714
794
  value: "anthropic",
@@ -719,13 +799,13 @@ var ALL_AUTH_PROVIDERS = [
719
799
  {
720
800
  value: "openai",
721
801
  label: "OpenAI",
722
- description: "GPT-6 Astra, GPT-6 Astra Fast, GPT-6.1 Sol, GPT-6.1 Sol Fast, GPT-6.1 Terra, GPT-6.1 Terra Fast, GPT-6 Luna, GPT-6 Luna Fast",
802
+ description: "GPT-6.2 Astra, GPT-6.2 Astra Fast, GPT-6.2 Sol, GPT-6.2 Sol Fast, GPT-6.1 Terra, GPT-6.1 Terra Fast, GPT-6 Luna, GPT-6 Luna Fast",
723
803
  methods: ["oauth"]
724
804
  },
725
805
  {
726
806
  value: "gemini",
727
807
  label: "Gemini",
728
- description: "Gemini 3.8 Flash, 3.5 Flash Lite, 3.1 Flash Lite, 3.5 Flash, 3.1 Pro (Preview)",
808
+ description: "Gemini 4 Hydrogen, 4 Argon, 4 Carbon, 3.8 Flash, 3.6 Flash, 3.5 Flash Lite, 3.1 Flash Lite, 3.5 Flash, 3.1 Pro (Preview)",
729
809
  methods: ["oauth", "apikey"],
730
810
  apiKeyLabel: "Gemini",
731
811
  apiKeyBaseUrl: GEMINI_API_KEY_BASE_URL,
@@ -838,6 +918,30 @@ var ALL_AUTH_PROVIDERS = [
838
918
  methods: ["apikey"],
839
919
  apiKeyLabel: "Sakana"
840
920
  },
921
+ {
922
+ value: "opencode-go",
923
+ label: "OpenCode Go",
924
+ description: "Kimi K3, GLM-5.3, GLM-5.3-Flash and more Go models",
925
+ methods: ["apikey"],
926
+ apiKeyLabel: "OpenCode",
927
+ methodDetails: apiKeyDetails(
928
+ "OpenCode API key",
929
+ "Uses your OpenCode Go subscription.",
930
+ "Create a personal API key in the OpenCode Console, in a workspace subscribed to Go."
931
+ )
932
+ },
933
+ {
934
+ value: "opencode",
935
+ label: "OpenCode",
936
+ description: "Kimi K3, GLM-5.3, GLM-5.3-Flash and more paid Console models",
937
+ methods: ["apikey"],
938
+ apiKeyLabel: "OpenCode",
939
+ methodDetails: apiKeyDetails(
940
+ "OpenCode API key",
941
+ "Pay-per-token from your OpenCode Console credits.",
942
+ "Free-tier models only run inside OpenCode, so they are not listed here."
943
+ )
944
+ },
841
945
  {
842
946
  value: "openrouter",
843
947
  label: "OpenRouter",
@@ -895,6 +999,8 @@ var SubscriptionUsageError = class extends Error {
895
999
  this.retryAfterMs = retryAfterMs2;
896
1000
  this.name = "SubscriptionUsageError";
897
1001
  }
1002
+ status;
1003
+ retryAfterMs;
898
1004
  };
899
1005
  var ANTHROPIC_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
900
1006
  var CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
@@ -1640,6 +1746,8 @@ export {
1640
1746
  MODELS,
1641
1747
  MOONSHOT_OAUTH_KEY,
1642
1748
  NotLoggedInError,
1749
+ OPENCODE_CATALOG_URLS,
1750
+ OPENCODE_PROVIDERS,
1643
1751
  OPENROUTER_DEFAULT_BASE_URL,
1644
1752
  PLAN_MODE_THINKING_CAP,
1645
1753
  SubscriptionUsageError,
@@ -1675,6 +1783,7 @@ export {
1675
1783
  findProbedModel,
1676
1784
  formatClaudeCodeInstallProgress,
1677
1785
  formatLocalModelId,
1786
+ formatOpenCodeModelId,
1678
1787
  generatePKCE,
1679
1788
  getAllModels,
1680
1789
  getAppPaths,
@@ -1727,8 +1836,10 @@ export {
1727
1836
  ollamaServedContext,
1728
1837
  openLog,
1729
1838
  parseLocalModelId,
1839
+ parseOpenCodeCatalog,
1730
1840
  parseOpenRouterCatalog,
1731
1841
  pendingClaudeCodeVersionRefresh,
1842
+ pointScale,
1732
1843
  probeEndpoint,
1733
1844
  providerStorageKeys,
1734
1845
  readClaudeCodeUsage,