@kenkaiiii/gg-core 5.97.1 → 5.98.1

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.cjs CHANGED
@@ -56,6 +56,8 @@ __export(index_exports, {
56
56
  MODELS: () => MODELS,
57
57
  NotLoggedInError: () => NotLoggedInError,
58
58
  OPENAI_CHATGPT_KEY: () => OPENAI_CHATGPT_KEY,
59
+ OPENCODE_CATALOG_URLS: () => OPENCODE_CATALOG_URLS,
60
+ OPENCODE_PROVIDERS: () => OPENCODE_PROVIDERS,
59
61
  OPENROUTER_DEFAULT_BASE_URL: () => OPENROUTER_DEFAULT_BASE_URL,
60
62
  PLAN_MODE_THINKING_CAP: () => PLAN_MODE_THINKING_CAP,
61
63
  RETIRED_SIGN_INS: () => RETIRED_SIGN_INS,
@@ -94,6 +96,7 @@ __export(index_exports, {
94
96
  findProbedModel: () => findProbedModel,
95
97
  formatClaudeCodeInstallProgress: () => formatClaudeCodeInstallProgress,
96
98
  formatLocalModelId: () => formatLocalModelId,
99
+ formatOpenCodeModelId: () => formatOpenCodeModelId,
97
100
  generatePKCE: () => generatePKCE,
98
101
  getAllModels: () => getAllModels,
99
102
  getAppPaths: () => getAppPaths,
@@ -137,6 +140,7 @@ __export(index_exports, {
137
140
  openLog: () => openLog,
138
141
  parseCallbackInput: () => parseCallbackInput,
139
142
  parseLocalModelId: () => parseLocalModelId,
143
+ parseOpenCodeCatalog: () => parseOpenCodeCatalog,
140
144
  parseOpenRouterCatalog: () => parseOpenRouterCatalog,
141
145
  probeEndpoint: () => probeEndpoint,
142
146
  providerStorageKeys: () => providerStorageKeys,
@@ -2958,6 +2962,93 @@ var MODELS = [
2958
2962
  costTier: "medium",
2959
2963
  maxThinkingLevel: "high"
2960
2964
  },
2965
+ // ── OpenCode Console (Go subscription, then pay-as-you-go) ────────
2966
+ // One Console API key reaches many labs' models through opencode.ai. Ids
2967
+ // carry the plan prefix (`opencode-go/kimi-k3`) because the gateway reuses
2968
+ // the vendors' own ids; gg-ai strips it at the wire. These rows are only the
2969
+ // offline fallback: the desktop app replaces them with each plan's live,
2970
+ // public model list (core/opencode-catalog-store.ts). Limits, image input
2971
+ // and effort ladders are from GET /inference[/go]/v1/models (2026-11-11);
2972
+ // all three speak Chat Completions natively.
2973
+ {
2974
+ // Go declares `max` as K3's only effort; pay-as-you-go adds low and high.
2975
+ id: "opencode-go/kimi-k3",
2976
+ name: "Kimi K3",
2977
+ provider: "opencode-go",
2978
+ contextWindow: 1048576,
2979
+ maxOutputTokens: 131072,
2980
+ supportsThinking: true,
2981
+ supportsImages: true,
2982
+ supportsVideo: false,
2983
+ costTier: "high",
2984
+ maxThinkingLevel: "max",
2985
+ thinkingLevels: ["max"]
2986
+ },
2987
+ {
2988
+ id: "opencode-go/glm-5.3",
2989
+ name: "GLM-5.3",
2990
+ provider: "opencode-go",
2991
+ contextWindow: 1e6,
2992
+ maxOutputTokens: 131072,
2993
+ supportsThinking: true,
2994
+ supportsImages: false,
2995
+ supportsVideo: false,
2996
+ costTier: "medium",
2997
+ maxThinkingLevel: "max",
2998
+ thinkingLevels: ["low", "high", "max"]
2999
+ },
3000
+ {
3001
+ id: "opencode-go/glm-5.3-flash",
3002
+ name: "GLM-5.3-Flash",
3003
+ provider: "opencode-go",
3004
+ contextWindow: 1e6,
3005
+ maxOutputTokens: 131072,
3006
+ supportsThinking: true,
3007
+ supportsImages: true,
3008
+ supportsVideo: false,
3009
+ costTier: "low",
3010
+ maxThinkingLevel: "max",
3011
+ thinkingLevels: ["low", "high", "max"]
3012
+ },
3013
+ {
3014
+ id: "opencode/kimi-k3",
3015
+ name: "Kimi K3",
3016
+ provider: "opencode",
3017
+ contextWindow: 1048576,
3018
+ maxOutputTokens: 131072,
3019
+ supportsThinking: true,
3020
+ supportsImages: true,
3021
+ supportsVideo: false,
3022
+ costTier: "high",
3023
+ maxThinkingLevel: "max",
3024
+ thinkingLevels: ["low", "high", "max"]
3025
+ },
3026
+ {
3027
+ id: "opencode/glm-5.3",
3028
+ name: "GLM-5.3",
3029
+ provider: "opencode",
3030
+ contextWindow: 1e6,
3031
+ maxOutputTokens: 131072,
3032
+ supportsThinking: true,
3033
+ supportsImages: false,
3034
+ supportsVideo: false,
3035
+ costTier: "medium",
3036
+ maxThinkingLevel: "max",
3037
+ thinkingLevels: ["low", "high", "max"]
3038
+ },
3039
+ {
3040
+ id: "opencode/glm-5.3-flash",
3041
+ name: "GLM-5.3-Flash",
3042
+ provider: "opencode",
3043
+ contextWindow: 1e6,
3044
+ maxOutputTokens: 131072,
3045
+ supportsThinking: true,
3046
+ supportsImages: true,
3047
+ supportsVideo: false,
3048
+ costTier: "low",
3049
+ maxThinkingLevel: "max",
3050
+ thinkingLevels: ["low", "high", "max"]
3051
+ },
2961
3052
  // ── Hugging Face (Inference Providers router) ────────
2962
3053
  // One HF token (hf.co/settings/tokens, "Make calls to Inference Providers"
2963
3054
  // permission) routes to whichever hosted backend serves each open model;
@@ -3115,6 +3206,8 @@ var DEFAULT_MODEL_IDS = {
3115
3206
  minimax: "MiniMax-M3.1-Flash",
3116
3207
  deepseek: "deepseek-v4-pro",
3117
3208
  huggingface: "moonshotai/Kimi-K2.7-Code",
3209
+ opencode: "opencode/kimi-k3",
3210
+ "opencode-go": "opencode-go/kimi-k3",
3118
3211
  openrouter: "qwen/qwen3.8-max",
3119
3212
  sakana: "fugu",
3120
3213
  xai: "grok-4.7"
@@ -3231,6 +3324,70 @@ function parseOpenRouterCatalog(body) {
3231
3324
  return { models, skipped };
3232
3325
  }
3233
3326
 
3327
+ // src/opencode-catalog.ts
3328
+ var OPENCODE_PROVIDERS = ["opencode-go", "opencode"];
3329
+ var OPENCODE_CATALOG_URLS = {
3330
+ opencode: "https://opencode.ai/inference/v1/models",
3331
+ "opencode-go": "https://opencode.ai/inference/go/v1/models"
3332
+ };
3333
+ var EFFORT_LADDER2 = ["low", "medium", "high", "xhigh", "max"];
3334
+ function positiveInt2(value) {
3335
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
3336
+ }
3337
+ function strings2(value) {
3338
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
3339
+ }
3340
+ function costTier2(price) {
3341
+ if (typeof price !== "number" || !Number.isFinite(price) || price < 0.5) return "low";
3342
+ return price < 3 ? "medium" : "high";
3343
+ }
3344
+ function formatOpenCodeModelId(provider, rawId) {
3345
+ return `${provider}/${rawId}`;
3346
+ }
3347
+ function parseOpenCodeCatalog(provider, body) {
3348
+ const data = body?.data;
3349
+ if (!Array.isArray(data)) return { models: [], skipped: 0 };
3350
+ const models = [];
3351
+ let skipped = 0;
3352
+ const seen = /* @__PURE__ */ new Set();
3353
+ for (const raw of data) {
3354
+ const rawId = typeof raw?.id === "string" ? raw.id.trim() : "";
3355
+ const contextWindow = positiveInt2(raw?.limit?.context);
3356
+ const price = raw?.cost?.text?.input?.price;
3357
+ if (!/^[\w.:-]+$/.test(rawId) || seen.has(rawId) || raw.type !== "chat" || !raw.api?.["chat-completions"] || raw.capabilities?.tools?.supported !== true || !contextWindow || provider === "opencode" && price === 0) {
3358
+ skipped++;
3359
+ continue;
3360
+ }
3361
+ seen.add(rawId);
3362
+ const reasoning = raw.capabilities.reasoning;
3363
+ const efforts = strings2(reasoning?.effort);
3364
+ const ladder = EFFORT_LADDER2.filter((rung) => efforts.includes(rung));
3365
+ const defaultEffort = reasoning?.default?.type === "effort" ? reasoning.default.value : null;
3366
+ const maxOutput = Math.min(
3367
+ positiveInt2(raw.limit?.output) ?? 16384,
3368
+ Math.floor(contextWindow / 2)
3369
+ );
3370
+ models.push({
3371
+ id: formatOpenCodeModelId(provider, rawId),
3372
+ name: typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : rawId,
3373
+ provider,
3374
+ contextWindow,
3375
+ maxOutputTokens: Math.max(1, maxOutput),
3376
+ // Only a declared effort ladder counts: a model without one is never sent
3377
+ // a reasoning_effort it might reject.
3378
+ supportsThinking: ladder.length > 0,
3379
+ supportsImages: strings2(raw.modalities?.input).some((m) => m.startsWith("image")),
3380
+ // Video needs a per-transport payload cap the catalog doesn't publish.
3381
+ supportsVideo: false,
3382
+ costTier: costTier2(price),
3383
+ maxThinkingLevel: ladder[ladder.length - 1] ?? "low",
3384
+ ...ladder.length > 0 ? { thinkingLevels: ladder } : {},
3385
+ ...typeof defaultEffort === "string" && ladder.includes(defaultEffort) ? { defaultThinkingLevel: defaultEffort } : {}
3386
+ });
3387
+ }
3388
+ return { models, skipped };
3389
+ }
3390
+
3234
3391
  // src/thinking-level.ts
3235
3392
  var OPENAI_GPT_THINKING_LEVELS = ["medium", "high", "xhigh"];
3236
3393
  var OPENAI_GPT_56_THINKING_LEVELS = [
@@ -3969,6 +4126,30 @@ var ALL_AUTH_PROVIDERS = [
3969
4126
  apiKeyLabel: "Sakana",
3970
4127
  methodDetails: apiKeyDetails("Sakana API key", "Pay-per-token from your Sakana API account.")
3971
4128
  },
4129
+ {
4130
+ value: "opencode-go",
4131
+ label: "OpenCode Go",
4132
+ description: "Kimi K3, GLM-5.3, GLM-5.3-Flash and more Go models",
4133
+ methods: ["apikey"],
4134
+ apiKeyLabel: "OpenCode",
4135
+ methodDetails: apiKeyDetails(
4136
+ "OpenCode API key",
4137
+ "Uses your OpenCode Go subscription.",
4138
+ "Create a personal API key in the OpenCode Console, in a workspace subscribed to Go."
4139
+ )
4140
+ },
4141
+ {
4142
+ value: "opencode",
4143
+ label: "OpenCode",
4144
+ description: "Kimi K3, GLM-5.3, GLM-5.3-Flash and more paid Console models",
4145
+ methods: ["apikey"],
4146
+ apiKeyLabel: "OpenCode",
4147
+ methodDetails: apiKeyDetails(
4148
+ "OpenCode API key",
4149
+ "Pay-per-token from your OpenCode Console credits.",
4150
+ "Free-tier models only run inside OpenCode, so they are not listed here."
4151
+ )
4152
+ },
3972
4153
  {
3973
4154
  value: "openrouter",
3974
4155
  label: "OpenRouter",
@@ -4698,6 +4879,8 @@ function createAutoUpdater(config) {
4698
4879
  MODELS,
4699
4880
  NotLoggedInError,
4700
4881
  OPENAI_CHATGPT_KEY,
4882
+ OPENCODE_CATALOG_URLS,
4883
+ OPENCODE_PROVIDERS,
4701
4884
  OPENROUTER_DEFAULT_BASE_URL,
4702
4885
  PLAN_MODE_THINKING_CAP,
4703
4886
  RETIRED_SIGN_INS,
@@ -4736,6 +4919,7 @@ function createAutoUpdater(config) {
4736
4919
  findProbedModel,
4737
4920
  formatClaudeCodeInstallProgress,
4738
4921
  formatLocalModelId,
4922
+ formatOpenCodeModelId,
4739
4923
  generatePKCE,
4740
4924
  getAllModels,
4741
4925
  getAppPaths,
@@ -4779,6 +4963,7 @@ function createAutoUpdater(config) {
4779
4963
  openLog,
4780
4964
  parseCallbackInput,
4781
4965
  parseLocalModelId,
4966
+ parseOpenCodeCatalog,
4782
4967
  parseOpenRouterCatalog,
4783
4968
  probeEndpoint,
4784
4969
  providerStorageKeys,