@kenkaiiii/gg-core 5.94.0 → 5.95.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.
@@ -57,83 +57,68 @@ __export(model_registry_exports, {
57
57
  });
58
58
  module.exports = __toCommonJS(model_registry_exports);
59
59
 
60
- // src/oauth/kimi.ts
61
- var import_node_child_process = require("child_process");
62
- var import_node_crypto = require("crypto");
63
- var import_node_fs = require("fs");
64
- var import_node_os2 = require("os");
65
- var import_node_path2 = __toESM(require("path"), 1);
66
-
67
- // src/paths.ts
68
- var import_node_path = __toESM(require("path"), 1);
69
- var import_node_os = __toESM(require("os"), 1);
70
-
71
- // src/oauth/kimi.ts
72
- var DEFAULT_CODING_BASE_URL = "https://api.kimi.com/coding/v1";
73
- var DEVICE_TIMEOUT_MS = 15 * 60 * 1e3;
74
- function kimiCodeBaseUrl() {
75
- return (process.env.KIMI_CODE_BASE_URL ?? DEFAULT_CODING_BASE_URL).replace(/\/+$/, "");
76
- }
60
+ // src/kimi-region.ts
61
+ var import_gg_ai = require("@kenkaiiii/gg-ai");
77
62
  function isKimiCodingEndpoint(baseUrl) {
78
63
  if (typeof baseUrl !== "string" || baseUrl.length === 0) return false;
79
- const normalized = baseUrl.replace(/\/+$/, "");
80
- return normalized === kimiCodeBaseUrl() || /(^|\.)kimi\.com/i.test(normalized);
64
+ return /^https:\/\/api\.kimi\.(com|ai)\/coding(\/|$)/i.test(baseUrl);
81
65
  }
82
66
 
83
67
  // src/auth-storage.ts
84
- var import_promises5 = __toESM(require("fs/promises"), 1);
85
- var import_node_fs5 = require("fs");
86
- var import_node_crypto6 = __toESM(require("crypto"), 1);
68
+ var import_promises6 = __toESM(require("fs/promises"), 1);
69
+ var import_node_fs4 = require("fs");
70
+ var import_node_crypto4 = __toESM(require("crypto"), 1);
71
+
72
+ // src/paths.ts
73
+ var import_node_path = __toESM(require("path"), 1);
74
+ var import_node_os = __toESM(require("os"), 1);
87
75
 
88
76
  // src/claude-code/runtime.ts
89
- var import_node_child_process2 = require("child_process");
90
- var import_node_crypto2 = __toESM(require("crypto"), 1);
91
- var import_node_fs3 = __toESM(require("fs"), 1);
77
+ var import_node_child_process = require("child_process");
78
+ var import_node_crypto = __toESM(require("crypto"), 1);
79
+ var import_node_fs2 = __toESM(require("fs"), 1);
92
80
  var import_promises2 = __toESM(require("fs/promises"), 1);
93
- var import_node_path3 = __toESM(require("path"), 1);
81
+ var import_node_path2 = __toESM(require("path"), 1);
94
82
 
95
83
  // src/claude-code/tar.ts
96
- var import_node_fs2 = __toESM(require("fs"), 1);
84
+ var import_node_fs = __toESM(require("fs"), 1);
97
85
  var import_promises = __toESM(require("fs/promises"), 1);
98
86
  var import_node_zlib = __toESM(require("zlib"), 1);
99
87
 
100
88
  // src/oauth/openai.ts
101
89
  var import_node_http = __toESM(require("http"), 1);
102
- var import_node_crypto3 = __toESM(require("crypto"), 1);
103
-
104
- // src/oauth/gemini.ts
105
- var import_node_http2 = __toESM(require("http"), 1);
106
- var import_node_crypto4 = __toESM(require("crypto"), 1);
107
- var SCOPE = [
108
- "https://www.googleapis.com/auth/cloud-platform",
109
- "https://www.googleapis.com/auth/userinfo.email",
110
- "https://www.googleapis.com/auth/userinfo.profile"
111
- ].join(" ");
112
-
113
- // src/oauth/xai.ts
114
- var DEVICE_TIMEOUT_FALLBACK_MS = 10 * 60 * 1e3;
90
+ var import_node_crypto2 = __toESM(require("crypto"), 1);
91
+ var import_promises3 = __toESM(require("fs/promises"), 1);
92
+ var import_node_path3 = __toESM(require("path"), 1);
93
+ var ISSUER = "https://auth.openai.com";
94
+ var AUTHORIZE_URL = `${ISSUER}/api/accounts/authorize`;
95
+ var TOKEN_URL = `${ISSUER}/api/accounts/oauth/token`;
96
+ var REVOKE_URL = `${ISSUER}/api/accounts/oauth/revoke`;
97
+ var JWKS_URL = `${ISSUER}/.well-known/jwks.json`;
98
+ var CHATGPT_PLAN_SCOPE = "chatgpt.tokens.use.direct";
99
+ var SCOPES = `openid profile email offline_access resource.invoke ${CHATGPT_PLAN_SCOPE}`;
115
100
 
116
101
  // src/file-lock.ts
117
- var import_promises3 = __toESM(require("fs/promises"), 1);
118
- var import_promises4 = require("timers/promises");
102
+ var import_promises4 = __toESM(require("fs/promises"), 1);
103
+ var import_promises5 = require("timers/promises");
119
104
 
120
105
  // src/logger.ts
121
- var import_node_fs4 = __toESM(require("fs"), 1);
106
+ var import_node_fs3 = __toESM(require("fs"), 1);
122
107
  var import_node_path4 = __toESM(require("path"), 1);
123
- var import_node_crypto5 = require("crypto");
124
- var import_gg_ai = require("@kenkaiiii/gg-ai");
108
+ var import_node_crypto3 = require("crypto");
109
+ var import_gg_ai2 = require("@kenkaiiii/gg-ai");
125
110
  var MAX_BYTES = 10 * 1024 * 1024;
126
111
  var MIN_HEADROOM_BYTES = 64 * 1024;
127
112
 
128
113
  // src/hidden-providers.ts
129
- var HIDDEN_PROVIDERS = ["gemini"];
114
+ var HIDDEN_PROVIDERS = [];
130
115
  function isHiddenProvider(provider) {
131
116
  return HIDDEN_PROVIDERS.includes(provider);
132
117
  }
133
118
 
134
119
  // src/auth-storage.ts
135
- var import_gg_ai2 = require("@kenkaiiii/gg-ai");
136
- var MOONSHOT_OAUTH_KEY = "moonshot-oauth";
120
+ var import_gg_ai3 = require("@kenkaiiii/gg-ai");
121
+ var KIMI_CODE_KEY = "kimi-code";
137
122
  var XIAOMI_CREDITS_KEY = "xiaomi-credits";
138
123
  var GEMINI_API_KEY = "gemini-api";
139
124
  var LOCAL_CREDENTIAL_LIFETIME_MS = 100 * 365 * 24 * 60 * 60 * 1e3;
@@ -158,7 +143,8 @@ var CODEX_FAST_BILLING = {
158
143
  detail: "Codex Fast mode uses your ChatGPT plan limits at 2.5x the standard rate (purchased credits at 2x).",
159
144
  paid: false
160
145
  };
161
- var GEMINI_AUTH_KEYS = [GEMINI_API_KEY, "gemini"];
146
+ var GEMINI_AUTH_KEYS = [GEMINI_API_KEY];
147
+ var KIMI_AUTH_KEYS = [KIMI_CODE_KEY, "moonshot"];
162
148
  var MODELS = [
163
149
  // ── Anthropic ──────────────────────────────────────────
164
150
  // NOTE: Claude Mythos 5.1 (`claude-mythos-5-1`, 2026-09-01) is kept commented
@@ -288,14 +274,13 @@ var MODELS = [
288
274
  {
289
275
  // GPT-6 Astra — "Our most capable model for complex, demanding work."
290
276
  // (Codex catalog priority 2, listed for every ChatGPT plan, requires a
291
- // Codex client >= 0.153.0 — see CODEX_CLIENT_VERSION). Same split as 5.6:
292
- // 1.05M on the public Responses API, 272K on the ChatGPT OAuth route
277
+ // Codex client >= 0.153.0). Same split as 5.6:
278
+ // 1.05M on the public Responses API, 272K on the ChatGPT plan route
293
279
  // (openai/codex models.json, `gpt-6-astra`). Reasoning ladder low → medium
294
280
  // → high → xhigh → max → ultra; `ultra` is the Codex orchestration preset
295
281
  // (multi_agent v2) and is Codex-only — the public API tops out at `max`.
296
- // Note: through a plain API key OpenAI requires the Responses API for tool
297
- // calling on Astra, so the Chat Completions path is text-only; the OAuth
298
- // Codex route is the supported way to use it as an agent.
282
+ // OpenAI requires the Responses API for tool calling on Astra, so both
283
+ // the ChatGPT plan and API keys ride gg-ai's Responses transport.
299
284
  id: "gpt-6-astra",
300
285
  name: "GPT-6 Astra",
301
286
  provider: "openai",
@@ -338,9 +323,7 @@ var MODELS = [
338
323
  // next start.
339
324
  {
340
325
  // GPT-6.1 Sol — "Latest workhorse model for coding and everyday work."
341
- // (Codex priority 1, default low). The catalog says Codex client >= 0.153.0,
342
- // but the ChatGPT backend only serves it from 0.159.0 (see
343
- // CODEX_CLIENT_VERSION). $2/$10 MTok, cached input $0.10. Ladder low →
326
+ // (Codex priority 1, default low). $2/$10 MTok, cached input $0.10. Ladder low →
344
327
  // medium → high → xhigh → max → ultra; ultra is the Codex orchestration
345
328
  // preset (xhigh effort on the wire + proactive local subagent delegation).
346
329
  id: "gpt-6.1-sol",
@@ -527,8 +510,8 @@ var MODELS = [
527
510
  maxThinkingLevel: "high",
528
511
  authStorageKeys: GEMINI_AUTH_KEYS
529
512
  },
530
- // Keep 3.1 Flash Lite first for the working OAuth default and fast-model routing.
531
- // New GA models are opt-in; Code Assist access varies by account. Gemini 3.7
513
+ // Keep 3.1 Flash Lite first for the default and fast-model routing.
514
+ // Gemini 3.7
532
515
  // Flash is retired: Google deprecated it on 2026-10-08 and routes every
533
516
  // `gemini-3.7-flash` request to 3.8 Flash (ai.google.dev/gemini-api/docs/
534
517
  // changelog), so a saved session on it falls back to the provider default.
@@ -561,9 +544,7 @@ var MODELS = [
561
544
  authStorageKeys: GEMINI_AUTH_KEYS
562
545
  },
563
546
  {
564
- // Wire name `gemini-3-flash` — the Code Assist (OAuth) backend rejects the
565
- // display string `gemini-3.5-flash` with a 404, so gemini-cli keeps this
566
- // alternative name (SECONDARY_GEMINI_3_5_FLASH_MODEL) for that endpoint.
547
+ // Wire name `gemini-3-flash`, the id Google serves 3.5 Flash under.
567
548
  id: "gemini-3-flash",
568
549
  name: "Gemini 3.5 Flash",
569
550
  provider: "gemini",
@@ -578,9 +559,7 @@ var MODELS = [
578
559
  authStorageKeys: GEMINI_AUTH_KEYS
579
560
  },
580
561
  {
581
- // Gemini 3.1 Pro is public preview — gated behind Code Assist preview
582
- // enablement, so free/personal OAuth accounts 404 on it (see
583
- // ACCOUNT_GATED_MODELS in gg-ai's gemini provider).
562
+ // Gemini 3.1 Pro is public preview.
584
563
  id: "gemini-3.1-pro-preview",
585
564
  name: "Gemini 3.1 Pro (Preview)",
586
565
  provider: "gemini",
@@ -597,8 +576,8 @@ var MODELS = [
597
576
  // ── Moonshot (Kimi) ────────────────────────────────────
598
577
  // K3 is Kimi's 2.8T-parameter flagship for long-horizon coding, knowledge
599
578
  // work, and deep reasoning. Its effort ladder is server-declared as
600
- // low/high/max on both the public API (default max) and the Kimi For Coding
601
- // OAuth endpoint (default high); thinking can also be fully disabled.
579
+ // low/high/max on both the public API (default max) and the Kimi Code plan
580
+ // endpoint (default high); thinking can also be fully disabled.
602
581
  {
603
582
  id: "kimi-k3",
604
583
  name: "Kimi K3",
@@ -612,13 +591,14 @@ var MODELS = [
612
591
  supportsVideo: true,
613
592
  maxVideoBytes: 100 * 1024 * 1024,
614
593
  costTier: "high",
615
- maxThinkingLevel: "max"
594
+ maxThinkingLevel: "max",
595
+ authStorageKeys: KIMI_AUTH_KEYS
616
596
  },
617
- // K2.8 Preview (2026-09-11) is served only on the Kimi For Coding OAuth
618
- // endpoint, under its rolling `kimi-for-coding` id (live /models, 2026-09-28:
597
+ // K2.8 Preview (2026-09-11) is served only on the Kimi Code plan endpoint,
598
+ // under its rolling `kimi-for-coding` id (live /models, 2026-09-28:
619
599
  // display_name "K2.8 Preview", 1M context, image + video input, efforts
620
- // low/high/max default max). The public API-key endpoint does not serve it,
621
- // so it resolves from the Kimi sign-in credential only.
600
+ // low/high/max default max). The public Moonshot API does not serve it, so
601
+ // it resolves from a Kimi Code plan key only.
622
602
  {
623
603
  id: "kimi-for-coding",
624
604
  name: "Kimi K2.8 Preview",
@@ -631,7 +611,7 @@ var MODELS = [
631
611
  maxVideoBytes: 100 * 1024 * 1024,
632
612
  costTier: "medium",
633
613
  maxThinkingLevel: "max",
634
- authStorageKeys: [MOONSHOT_OAUTH_KEY]
614
+ authStorageKeys: [KIMI_CODE_KEY]
635
615
  },
636
616
  // K2.7 Code is requested by its pinned id (not the `kimi-for-coding` alias
637
617
  // that moved to K2.8), so it stays the real K2.7 on both endpoints.
@@ -646,7 +626,8 @@ var MODELS = [
646
626
  supportsVideo: true,
647
627
  maxVideoBytes: 100 * 1024 * 1024,
648
628
  costTier: "medium",
649
- maxThinkingLevel: "high"
629
+ maxThinkingLevel: "high",
630
+ authStorageKeys: KIMI_AUTH_KEYS
650
631
  },
651
632
  // K2.7 Code HighSpeed — the same model as K2.7 Code served at ~180 tok/s
652
633
  // (up to ~260 on short contexts), 256K context (platform.kimi.ai model list,
@@ -665,7 +646,8 @@ var MODELS = [
665
646
  supportsVideo: true,
666
647
  maxVideoBytes: 100 * 1024 * 1024,
667
648
  costTier: "medium",
668
- maxThinkingLevel: "high"
649
+ maxThinkingLevel: "high",
650
+ authStorageKeys: KIMI_AUTH_KEYS
669
651
  },
670
652
  // ── Z.AI (GLM) ─────────────────────────────────────────
671
653
  // Two GLM entries, both live on the coding endpoint (verified against its