@kenkaiiii/gg-core 5.93.0 → 5.95.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.
@@ -57,80 +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_promises3 = __toESM(require("fs/promises"), 1);
85
- var import_node_fs3 = 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);
87
71
 
88
- // src/oauth/anthropic.ts
89
- var import_node_crypto2 = __toESM(require("crypto"), 1);
72
+ // src/paths.ts
73
+ var import_node_path = __toESM(require("path"), 1);
74
+ var import_node_os = __toESM(require("os"), 1);
90
75
 
91
- // src/claude-code-version.ts
92
- var import_gg_ai = require("@kenkaiiii/gg-ai");
76
+ // src/claude-code/runtime.ts
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);
80
+ var import_promises2 = __toESM(require("fs/promises"), 1);
81
+ var import_node_path2 = __toESM(require("path"), 1);
93
82
 
94
- // src/oauth/anthropic.ts
95
- var CLIENT_ID = atob("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
83
+ // src/claude-code/tar.ts
84
+ var import_node_fs = __toESM(require("fs"), 1);
85
+ var import_promises = __toESM(require("fs/promises"), 1);
86
+ var import_node_zlib = __toESM(require("zlib"), 1);
96
87
 
97
88
  // src/oauth/openai.ts
98
89
  var import_node_http = __toESM(require("http"), 1);
99
- var import_node_crypto3 = __toESM(require("crypto"), 1);
100
-
101
- // src/oauth/gemini.ts
102
- var import_node_http2 = __toESM(require("http"), 1);
103
- var import_node_crypto4 = __toESM(require("crypto"), 1);
104
- var SCOPE = [
105
- "https://www.googleapis.com/auth/cloud-platform",
106
- "https://www.googleapis.com/auth/userinfo.email",
107
- "https://www.googleapis.com/auth/userinfo.profile"
108
- ].join(" ");
109
-
110
- // src/oauth/xai.ts
111
- 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}`;
112
100
 
113
101
  // src/file-lock.ts
114
- var import_promises = __toESM(require("fs/promises"), 1);
115
- var import_promises2 = require("timers/promises");
102
+ var import_promises4 = __toESM(require("fs/promises"), 1);
103
+ var import_promises5 = require("timers/promises");
116
104
 
117
105
  // src/logger.ts
118
- var import_node_fs2 = __toESM(require("fs"), 1);
119
- var import_node_path3 = __toESM(require("path"), 1);
120
- var import_node_crypto5 = require("crypto");
106
+ var import_node_fs3 = __toESM(require("fs"), 1);
107
+ var import_node_path4 = __toESM(require("path"), 1);
108
+ var import_node_crypto3 = require("crypto");
121
109
  var import_gg_ai2 = require("@kenkaiiii/gg-ai");
122
110
  var MAX_BYTES = 10 * 1024 * 1024;
123
111
  var MIN_HEADROOM_BYTES = 64 * 1024;
124
112
 
125
113
  // src/hidden-providers.ts
126
- var HIDDEN_PROVIDERS = ["gemini"];
114
+ var HIDDEN_PROVIDERS = [];
127
115
  function isHiddenProvider(provider) {
128
116
  return HIDDEN_PROVIDERS.includes(provider);
129
117
  }
130
118
 
131
119
  // src/auth-storage.ts
132
120
  var import_gg_ai3 = require("@kenkaiiii/gg-ai");
133
- var MOONSHOT_OAUTH_KEY = "moonshot-oauth";
121
+ var KIMI_CODE_KEY = "kimi-code";
134
122
  var XIAOMI_CREDITS_KEY = "xiaomi-credits";
135
123
  var GEMINI_API_KEY = "gemini-api";
136
124
  var LOCAL_CREDENTIAL_LIFETIME_MS = 100 * 365 * 24 * 60 * 60 * 1e3;
@@ -155,7 +143,8 @@ var CODEX_FAST_BILLING = {
155
143
  detail: "Codex Fast mode uses your ChatGPT plan limits at 2.5x the standard rate (purchased credits at 2x).",
156
144
  paid: false
157
145
  };
158
- 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"];
159
148
  var MODELS = [
160
149
  // ── Anthropic ──────────────────────────────────────────
161
150
  // NOTE: Claude Mythos 5.1 (`claude-mythos-5-1`, 2026-09-01) is kept commented
@@ -285,14 +274,13 @@ var MODELS = [
285
274
  {
286
275
  // GPT-6 Astra — "Our most capable model for complex, demanding work."
287
276
  // (Codex catalog priority 2, listed for every ChatGPT plan, requires a
288
- // Codex client >= 0.153.0 — see CODEX_CLIENT_VERSION). Same split as 5.6:
289
- // 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
290
279
  // (openai/codex models.json, `gpt-6-astra`). Reasoning ladder low → medium
291
280
  // → high → xhigh → max → ultra; `ultra` is the Codex orchestration preset
292
281
  // (multi_agent v2) and is Codex-only — the public API tops out at `max`.
293
- // Note: through a plain API key OpenAI requires the Responses API for tool
294
- // calling on Astra, so the Chat Completions path is text-only; the OAuth
295
- // 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.
296
284
  id: "gpt-6-astra",
297
285
  name: "GPT-6 Astra",
298
286
  provider: "openai",
@@ -326,18 +314,16 @@ var MODELS = [
326
314
  billing: CODEX_FAST_BILLING
327
315
  },
328
316
  // GPT-6 Sol + Luna — released 2026-09-22 below Astra, replacing the whole
329
- // GPT-5.6 family (Sol/Terra/Luna; there is no GPT-6 Terra — OpenAI's Codex
317
+ // GPT-5.6 family (Sol/Terra/Luna; there was no GPT-6 Terra — OpenAI's Codex
330
318
  // catalog upgrades 5.6 Terra to 6 Sol). GPT-6.1 Sol (2026-09-29) then replaced
331
- // GPT-6 Sol. Same window split as Astra: 1.05M on the public Responses API,
319
+ // GPT-6 Sol, and GPT-6.1 Terra (2026-10-26) sits between Sol and Luna. Same window split as Astra: 1.05M on the public Responses API,
332
320
  // 272K on the Codex route; 128K output, text+image input, freeform
333
321
  // apply_patch, responses-lite transport. The GPT-5.6 ids and `gpt-6-sol` are
334
322
  // retired — a saved session on one falls back to the provider default on
335
323
  // next start.
336
324
  {
337
325
  // GPT-6.1 Sol — "Latest workhorse model for coding and everyday work."
338
- // (Codex priority 1, default low). The catalog says Codex client >= 0.153.0,
339
- // but the ChatGPT backend only serves it from 0.159.0 (see
340
- // 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 →
341
327
  // medium → high → xhigh → max → ultra; ultra is the Codex orchestration
342
328
  // preset (xhigh effort on the wire + proactive local subagent delegation).
343
329
  id: "gpt-6.1-sol",
@@ -370,6 +356,40 @@ var MODELS = [
370
356
  maxThinkingLevel: "ultra",
371
357
  billing: CODEX_FAST_BILLING
372
358
  },
359
+ {
360
+ // GPT-6.1 Terra (Codex priority 7, default low, client >= 0.153.0). $1/$5
361
+ // MTok, cached input $0.05. Unlike Sol/Astra the Codex route gets a 500K
362
+ // window (catalog `context_window`). Same ladder and Ultra preset as Sol.
363
+ id: "gpt-6.1-terra",
364
+ name: "GPT-6.1 Terra",
365
+ provider: "openai",
366
+ contextWindow: 105e4,
367
+ codexContextWindow: 5e5,
368
+ maxOutputTokens: 128e3,
369
+ supportsThinking: true,
370
+ defaultThinkingLevel: "low",
371
+ supportsImages: true,
372
+ supportsVideo: false,
373
+ costTier: "medium",
374
+ maxThinkingLevel: "ultra"
375
+ },
376
+ {
377
+ // Codex Fast mode for 6.1 Terra ("1.5x speed") — see `gpt-6-astra-fast`
378
+ // for the wire mapping and billing.
379
+ id: "gpt-6.1-terra-fast",
380
+ name: "GPT-6.1 Terra Fast",
381
+ provider: "openai",
382
+ contextWindow: 105e4,
383
+ codexContextWindow: 5e5,
384
+ maxOutputTokens: 128e3,
385
+ supportsThinking: true,
386
+ defaultThinkingLevel: "low",
387
+ supportsImages: true,
388
+ supportsVideo: false,
389
+ costTier: "medium",
390
+ maxThinkingLevel: "ultra",
391
+ billing: CODEX_FAST_BILLING
392
+ },
373
393
  {
374
394
  // Luna — "Fast and affordable model for easier tasks." (Codex priority 4,
375
395
  // default medium, needs a Codex client >= 0.155.0). $0.10/$0.50 MTok.
@@ -490,8 +510,8 @@ var MODELS = [
490
510
  maxThinkingLevel: "high",
491
511
  authStorageKeys: GEMINI_AUTH_KEYS
492
512
  },
493
- // Keep 3.1 Flash Lite first for the working OAuth default and fast-model routing.
494
- // 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
495
515
  // Flash is retired: Google deprecated it on 2026-10-08 and routes every
496
516
  // `gemini-3.7-flash` request to 3.8 Flash (ai.google.dev/gemini-api/docs/
497
517
  // changelog), so a saved session on it falls back to the provider default.
@@ -524,9 +544,7 @@ var MODELS = [
524
544
  authStorageKeys: GEMINI_AUTH_KEYS
525
545
  },
526
546
  {
527
- // Wire name `gemini-3-flash` — the Code Assist (OAuth) backend rejects the
528
- // display string `gemini-3.5-flash` with a 404, so gemini-cli keeps this
529
- // 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.
530
548
  id: "gemini-3-flash",
531
549
  name: "Gemini 3.5 Flash",
532
550
  provider: "gemini",
@@ -541,9 +559,7 @@ var MODELS = [
541
559
  authStorageKeys: GEMINI_AUTH_KEYS
542
560
  },
543
561
  {
544
- // Gemini 3.1 Pro is public preview — gated behind Code Assist preview
545
- // enablement, so free/personal OAuth accounts 404 on it (see
546
- // ACCOUNT_GATED_MODELS in gg-ai's gemini provider).
562
+ // Gemini 3.1 Pro is public preview.
547
563
  id: "gemini-3.1-pro-preview",
548
564
  name: "Gemini 3.1 Pro (Preview)",
549
565
  provider: "gemini",
@@ -560,8 +576,8 @@ var MODELS = [
560
576
  // ── Moonshot (Kimi) ────────────────────────────────────
561
577
  // K3 is Kimi's 2.8T-parameter flagship for long-horizon coding, knowledge
562
578
  // work, and deep reasoning. Its effort ladder is server-declared as
563
- // low/high/max on both the public API (default max) and the Kimi For Coding
564
- // 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.
565
581
  {
566
582
  id: "kimi-k3",
567
583
  name: "Kimi K3",
@@ -575,13 +591,14 @@ var MODELS = [
575
591
  supportsVideo: true,
576
592
  maxVideoBytes: 100 * 1024 * 1024,
577
593
  costTier: "high",
578
- maxThinkingLevel: "max"
594
+ maxThinkingLevel: "max",
595
+ authStorageKeys: KIMI_AUTH_KEYS
579
596
  },
580
- // K2.8 Preview (2026-09-11) is served only on the Kimi For Coding OAuth
581
- // 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:
582
599
  // display_name "K2.8 Preview", 1M context, image + video input, efforts
583
- // low/high/max default max). The public API-key endpoint does not serve it,
584
- // 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.
585
602
  {
586
603
  id: "kimi-for-coding",
587
604
  name: "Kimi K2.8 Preview",
@@ -594,7 +611,7 @@ var MODELS = [
594
611
  maxVideoBytes: 100 * 1024 * 1024,
595
612
  costTier: "medium",
596
613
  maxThinkingLevel: "max",
597
- authStorageKeys: [MOONSHOT_OAUTH_KEY]
614
+ authStorageKeys: [KIMI_CODE_KEY]
598
615
  },
599
616
  // K2.7 Code is requested by its pinned id (not the `kimi-for-coding` alias
600
617
  // that moved to K2.8), so it stays the real K2.7 on both endpoints.
@@ -609,7 +626,8 @@ var MODELS = [
609
626
  supportsVideo: true,
610
627
  maxVideoBytes: 100 * 1024 * 1024,
611
628
  costTier: "medium",
612
- maxThinkingLevel: "high"
629
+ maxThinkingLevel: "high",
630
+ authStorageKeys: KIMI_AUTH_KEYS
613
631
  },
614
632
  // K2.7 Code HighSpeed — the same model as K2.7 Code served at ~180 tok/s
615
633
  // (up to ~260 on short contexts), 256K context (platform.kimi.ai model list,
@@ -628,7 +646,8 @@ var MODELS = [
628
646
  supportsVideo: true,
629
647
  maxVideoBytes: 100 * 1024 * 1024,
630
648
  costTier: "medium",
631
- maxThinkingLevel: "high"
649
+ maxThinkingLevel: "high",
650
+ authStorageKeys: KIMI_AUTH_KEYS
632
651
  },
633
652
  // ── Z.AI (GLM) ─────────────────────────────────────────
634
653
  // Two GLM entries, both live on the coding endpoint (verified against its