@kenkaiiii/gg-core 5.82.0 → 5.83.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.
@@ -2,9 +2,6 @@ import {
2
2
  getAppPaths
3
3
  } from "./chunk-EAIPT76S.js";
4
4
 
5
- // src/model-registry.ts
6
- import { resolveFastModeModel } from "@kenkaiiii/gg-ai";
7
-
8
5
  // src/oauth/kimi.ts
9
6
  import { execFileSync } from "child_process";
10
7
  import { randomUUID } from "crypto";
@@ -1449,6 +1446,8 @@ function providerStorageKeys(provider) {
1449
1446
  return dual ? [dual.oauthKey, dual.provider] : [provider];
1450
1447
  }
1451
1448
  var XIAOMI_CREDITS_KEY = "xiaomi-credits";
1449
+ var GEMINI_API_KEY = "gemini-api";
1450
+ var GEMINI_API_KEY_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
1452
1451
  var LOCAL_AUTH_KEY_PREFIX = "local:";
1453
1452
  var LOCAL_CREDENTIAL_LIFETIME_MS = 100 * 365 * 24 * 60 * 60 * 1e3;
1454
1453
  function activeBaseUrlEntry(data, provider) {
@@ -1552,6 +1551,9 @@ var AuthStorage = class {
1552
1551
  if (provider === "xiaomi") {
1553
1552
  return Boolean(this.data["xiaomi"] || this.data[XIAOMI_CREDITS_KEY]);
1554
1553
  }
1554
+ if (provider === "gemini") {
1555
+ return Boolean(this.data["gemini"] || this.data[GEMINI_API_KEY]);
1556
+ }
1555
1557
  if (provider === "local") {
1556
1558
  return Object.keys(this.data).some((key) => key.startsWith(LOCAL_AUTH_KEY_PREFIX));
1557
1559
  }
@@ -1780,6 +1782,12 @@ var AuthStorage = class {
1780
1782
  ...opts.rejectedToken !== void 0 ? { rejectedToken: opts.rejectedToken } : {}
1781
1783
  });
1782
1784
  }
1785
+ if (key === provider) {
1786
+ return await this.resolveCredentials(provider, {
1787
+ ...opts.forceRefresh ? { forceRefresh: true } : {},
1788
+ ...opts.rejectedToken !== void 0 ? { rejectedToken: opts.rejectedToken } : {}
1789
+ });
1790
+ }
1783
1791
  return creds2;
1784
1792
  }
1785
1793
  throw new NotLoggedInError(provider);
@@ -1921,6 +1929,24 @@ var NotLoggedInError = class extends Error {
1921
1929
  };
1922
1930
 
1923
1931
  // src/model-registry.ts
1932
+ var CLAUDE_FAST_BILLING = {
1933
+ label: "bills usage credits",
1934
+ detail: "Fast mode bills your Claude usage credits ($8 in / $40 out per million tokens) from the first token, never your plan's included usage.",
1935
+ paid: true,
1936
+ standardModel: "claude-opus-5-5"
1937
+ };
1938
+ var XIAOMI_ULTRASPEED_BILLING = {
1939
+ label: "bills API Credits",
1940
+ detail: "UltraSpeed runs only on your Xiaomi API Credits, billed per token at a higher rate than MiMo-V2.6-Pro, never on the Token Plan.",
1941
+ paid: true,
1942
+ standardModel: "mimo-v2.6-pro"
1943
+ };
1944
+ var CODEX_FAST_BILLING = {
1945
+ label: "2.5x plan usage",
1946
+ detail: "Codex Fast mode uses your ChatGPT plan limits at 2.5x the standard rate (purchased credits at 2x).",
1947
+ paid: false
1948
+ };
1949
+ var GEMINI_AUTH_KEYS = [GEMINI_API_KEY, "gemini"];
1924
1950
  var MODELS = [
1925
1951
  // ── Anthropic ──────────────────────────────────────────
1926
1952
  // NOTE: Claude Mythos 5.1 (`claude-mythos-5-1`, 2026-09-01) is kept commented
@@ -2000,7 +2026,8 @@ var MODELS = [
2000
2026
  supportsVideo: false,
2001
2027
  costTier: "high",
2002
2028
  defaultThinkingLevel: "medium",
2003
- maxThinkingLevel: "max"
2029
+ maxThinkingLevel: "max",
2030
+ billing: CLAUDE_FAST_BILLING
2004
2031
  },
2005
2032
  {
2006
2033
  // Released 2026-09-28 — replaces Sonnet 5 at $2/$10 MTok, with the same
@@ -2014,9 +2041,10 @@ var MODELS = [
2014
2041
  supportsImages: true,
2015
2042
  supportsVideo: false,
2016
2043
  costTier: "medium",
2017
- // Anthropic's API and Claude Code both start the 5.5 family at medium; at a
2018
- // given level 5.5 thinks more than 5, so the ladder ceiling (max) made fresh
2019
- // sessions slow and expensive. Users can still opt up.
2044
+ // We start Sonnet 5.5 at medium like the rest of the 5.5 family (the API's
2045
+ // own default for Sonnet 5.5 is high). At a given level 5.5 thinks more
2046
+ // than 5, so the ladder ceiling (max) made fresh sessions slow and
2047
+ // expensive. Users can still opt up.
2020
2048
  defaultThinkingLevel: "medium",
2021
2049
  maxThinkingLevel: "max"
2022
2050
  },
@@ -2085,7 +2113,8 @@ var MODELS = [
2085
2113
  supportsImages: true,
2086
2114
  supportsVideo: false,
2087
2115
  costTier: "high",
2088
- maxThinkingLevel: "ultra"
2116
+ maxThinkingLevel: "ultra",
2117
+ billing: CODEX_FAST_BILLING
2089
2118
  },
2090
2119
  // GPT-6 Sol + Luna — released 2026-09-22 below Astra, replacing the whole
2091
2120
  // GPT-5.6 family (Sol/Terra/Luna; there is no GPT-6 Terra — OpenAI's Codex
@@ -2129,7 +2158,8 @@ var MODELS = [
2129
2158
  supportsImages: true,
2130
2159
  supportsVideo: false,
2131
2160
  costTier: "medium",
2132
- maxThinkingLevel: "ultra"
2161
+ maxThinkingLevel: "ultra",
2162
+ billing: CODEX_FAST_BILLING
2133
2163
  },
2134
2164
  {
2135
2165
  // Luna — "Fast and affordable model for easier tasks." (Codex priority 4,
@@ -2163,7 +2193,8 @@ var MODELS = [
2163
2193
  supportsImages: true,
2164
2194
  supportsVideo: false,
2165
2195
  costTier: "low",
2166
- maxThinkingLevel: "max"
2196
+ maxThinkingLevel: "max",
2197
+ billing: CODEX_FAST_BILLING
2167
2198
  },
2168
2199
  // ── Sakana (Fugu) ──────────────────────────────────────
2169
2200
  // Sakana Fugu is a multi-agent system surfaced as a standard LLM via the
@@ -2247,10 +2278,14 @@ var MODELS = [
2247
2278
  supportsVideo: true,
2248
2279
  maxVideoBytes: 20 * 1024 * 1024,
2249
2280
  costTier: "low",
2250
- maxThinkingLevel: "high"
2281
+ maxThinkingLevel: "high",
2282
+ authStorageKeys: GEMINI_AUTH_KEYS
2251
2283
  },
2252
2284
  // Keep 3.1 Flash Lite first for the working OAuth default and fast-model routing.
2253
- // New GA models are opt-in; Code Assist access varies by account.
2285
+ // New GA models are opt-in; Code Assist access varies by account. Gemini 3.7
2286
+ // Flash is retired: Google deprecated it on 2026-10-08 and routes every
2287
+ // `gemini-3.7-flash` request to 3.8 Flash (ai.google.dev/gemini-api/docs/
2288
+ // changelog), so a saved session on it falls back to the provider default.
2254
2289
  {
2255
2290
  id: "gemini-3.8-flash",
2256
2291
  name: "Gemini 3.8 Flash",
@@ -2262,7 +2297,8 @@ var MODELS = [
2262
2297
  supportsVideo: true,
2263
2298
  maxVideoBytes: 20 * 1024 * 1024,
2264
2299
  costTier: "low",
2265
- maxThinkingLevel: "high"
2300
+ maxThinkingLevel: "high",
2301
+ authStorageKeys: GEMINI_AUTH_KEYS
2266
2302
  },
2267
2303
  {
2268
2304
  id: "gemini-3.5-flash-lite",
@@ -2275,27 +2311,8 @@ var MODELS = [
2275
2311
  supportsVideo: true,
2276
2312
  maxVideoBytes: 20 * 1024 * 1024,
2277
2313
  costTier: "low",
2278
- maxThinkingLevel: "high"
2279
- },
2280
- {
2281
- // Gemini 3.7 Flash (released 2026-08-13) — Google's most capable Flash for
2282
- // coding, agents, and multi-step execution; GA-stable on the Gemini API as
2283
- // `gemini-3.7-flash`. 1M context, 64K output, thinking low/medium/high.
2284
- // Sent over our Code Assist (OAuth) transport ahead of gemini-cli — upstream
2285
- // hasn't listed 3.7 yet (google-gemini/gemini-cli#28802, still open) — so
2286
- // free/personal accounts 404 (entitlement-gated) while Code Assist
2287
- // Standard/Enterprise accounts get it.
2288
- id: "gemini-3.7-flash",
2289
- name: "Gemini 3.7 Flash",
2290
- provider: "gemini",
2291
- contextWindow: 1048576,
2292
- maxOutputTokens: 65536,
2293
- supportsThinking: true,
2294
- supportsImages: true,
2295
- supportsVideo: true,
2296
- maxVideoBytes: 20 * 1024 * 1024,
2297
- costTier: "low",
2298
- maxThinkingLevel: "high"
2314
+ maxThinkingLevel: "high",
2315
+ authStorageKeys: GEMINI_AUTH_KEYS
2299
2316
  },
2300
2317
  {
2301
2318
  // Wire name `gemini-3-flash` — the Code Assist (OAuth) backend rejects the
@@ -2311,7 +2328,8 @@ var MODELS = [
2311
2328
  supportsVideo: true,
2312
2329
  maxVideoBytes: 20 * 1024 * 1024,
2313
2330
  costTier: "low",
2314
- maxThinkingLevel: "high"
2331
+ maxThinkingLevel: "high",
2332
+ authStorageKeys: GEMINI_AUTH_KEYS
2315
2333
  },
2316
2334
  {
2317
2335
  // Gemini 3.1 Pro is public preview — gated behind Code Assist preview
@@ -2327,7 +2345,8 @@ var MODELS = [
2327
2345
  supportsVideo: true,
2328
2346
  maxVideoBytes: 20 * 1024 * 1024,
2329
2347
  costTier: "high",
2330
- maxThinkingLevel: "high"
2348
+ maxThinkingLevel: "high",
2349
+ authStorageKeys: GEMINI_AUTH_KEYS
2331
2350
  },
2332
2351
  // ── Moonshot (Kimi) ────────────────────────────────────
2333
2352
  // K3 is Kimi's 2.8T-parameter flagship for long-horizon coding, knowledge
@@ -2516,9 +2535,13 @@ var MODELS = [
2516
2535
  maxVideoBytes: 36 * 1024 * 1024,
2517
2536
  costTier: "high",
2518
2537
  maxThinkingLevel: "high",
2519
- authStorageKeys: [XIAOMI_CREDITS_KEY]
2538
+ authStorageKeys: [XIAOMI_CREDITS_KEY],
2539
+ billing: XIAOMI_ULTRASPEED_BILLING
2520
2540
  },
2521
2541
  // ── DeepSeek ───────────────────────────────────────────
2542
+ // Window 1,000,000 tokens (decimal "1M"), as DeepSeek's own agent sizes it
2543
+ // (deepseek-ai/deepseek-harness DEFAULT_CONTEXT_WINDOW = 1_000_000; models.dev
2544
+ // via earendil-works/pi agrees) — not 1,048,576.
2522
2545
  // The live /models list (2026-09-28) serves exactly `deepseek-flash` and
2523
2546
  // `deepseek-v4-pro`. V4 Flash and V4 Flash Vision Exp are retired; their old
2524
2547
  // ids only temporarily route to V4.1 Flash, so they are retired here too.
@@ -2532,7 +2555,7 @@ var MODELS = [
2532
2555
  id: "deepseek-v4-pro",
2533
2556
  name: "DeepSeek V4 Pro",
2534
2557
  provider: "deepseek",
2535
- contextWindow: 1048576,
2558
+ contextWindow: 1e6,
2536
2559
  maxOutputTokens: 384e3,
2537
2560
  supportsThinking: true,
2538
2561
  supportsImages: false,
@@ -2546,7 +2569,7 @@ var MODELS = [
2546
2569
  id: "deepseek-flash",
2547
2570
  name: "DeepSeek V4.1 Flash",
2548
2571
  provider: "deepseek",
2549
- contextWindow: 1048576,
2572
+ contextWindow: 1e6,
2550
2573
  maxOutputTokens: 384e3,
2551
2574
  supportsThinking: true,
2552
2575
  supportsImages: true,
@@ -2610,7 +2633,7 @@ var MODELS = [
2610
2633
  id: "deepseek-ai/DeepSeek-V4.1-Flash",
2611
2634
  name: "DeepSeek V4.1 Flash",
2612
2635
  provider: "huggingface",
2613
- contextWindow: 1048576,
2636
+ contextWindow: 1e6,
2614
2637
  maxOutputTokens: 131072,
2615
2638
  supportsThinking: false,
2616
2639
  supportsImages: true,
@@ -2657,6 +2680,19 @@ function getModel(id) {
2657
2680
  function getModelsForProvider(provider) {
2658
2681
  return getAllModels().filter((m) => m.provider === provider);
2659
2682
  }
2683
+ function isPaidModel(modelId) {
2684
+ return getModel(modelId)?.billing?.paid === true;
2685
+ }
2686
+ function withoutPaidTier(modelId) {
2687
+ const model = getModel(modelId);
2688
+ if (model?.billing?.paid !== true) return modelId;
2689
+ const usable = (id) => id !== void 0 && getModel(id) !== void 0 && !isPaidModel(id);
2690
+ const standard = model.billing.standardModel;
2691
+ if (usable(standard)) return standard;
2692
+ const providerDefault = DEFAULT_MODEL_IDS[model.provider];
2693
+ if (usable(providerDefault)) return providerDefault;
2694
+ return FALLBACK_DEFAULT_MODEL_ID;
2695
+ }
2660
2696
  function getAuthStorageKeys(provider, modelId) {
2661
2697
  const model = getAllModels().find((m) => m.id === modelId && m.provider === provider);
2662
2698
  return model?.authStorageKeys ?? [provider];
@@ -2738,9 +2774,7 @@ var SUMMARY_COST_TIER = {
2738
2774
  };
2739
2775
  function getSummaryModel(provider, currentModelId) {
2740
2776
  const tier = SUMMARY_COST_TIER[provider];
2741
- const tagged = tier ? getModelsForProvider(provider).find(
2742
- (m) => m.costTier === tier && !resolveFastModeModel(provider, m.id).fast
2743
- ) : void 0;
2777
+ const tagged = tier ? getModelsForProvider(provider).find((m) => m.costTier === tier && m.billing === void 0) : void 0;
2744
2778
  return tagged ?? getModel(currentModelId) ?? getDefaultModel(provider);
2745
2779
  }
2746
2780
 
@@ -2778,6 +2812,8 @@ export {
2778
2812
  oauthStorageKey,
2779
2813
  providerStorageKeys,
2780
2814
  XIAOMI_CREDITS_KEY,
2815
+ GEMINI_API_KEY,
2816
+ GEMINI_API_KEY_BASE_URL,
2781
2817
  LOCAL_AUTH_KEY_PREFIX,
2782
2818
  readStoredBaseUrlSync,
2783
2819
  AuthStorage,
@@ -2788,6 +2824,8 @@ export {
2788
2824
  getAllModels,
2789
2825
  getModel,
2790
2826
  getModelsForProvider,
2827
+ isPaidModel,
2828
+ withoutPaidTier,
2791
2829
  getAuthStorageKeys,
2792
2830
  getAuthStorageKey,
2793
2831
  DEFAULT_MAX_VIDEO_BYTES,
@@ -2800,4 +2838,4 @@ export {
2800
2838
  getDefaultThinkingLevel,
2801
2839
  getSummaryModel
2802
2840
  };
2803
- //# sourceMappingURL=chunk-6MT277JN.js.map
2841
+ //# sourceMappingURL=chunk-JJED477O.js.map