@prestyj/core 5.31.0 → 5.32.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.
@@ -20,11 +20,12 @@ function getAppPaths() {
20
20
  extensionsDir: path.join(agentDir, "extensions"),
21
21
  agentsDir: path.join(agentDir, "agents"),
22
22
  progressFile: path.join(agentDir, "progress.json"),
23
- progressBackupFile: path.join(agentDir, "progress.backup.json")
23
+ progressBackupFile: path.join(agentDir, "progress.backup.json"),
24
+ trophiesFile: path.join(agentDir, "trophies.json")
24
25
  };
25
26
  }
26
27
 
27
28
  export {
28
29
  getAppPaths
29
30
  };
30
- //# sourceMappingURL=chunk-CRU3SSNX.js.map
31
+ //# sourceMappingURL=chunk-W4NHU4UL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/paths.ts"],"sourcesContent":["import path from \"node:path\";\nimport os from \"node:os\";\n\nexport interface AppPaths {\n agentDir: string;\n sessionsDir: string;\n subagentSessionsDir: string;\n subagentsDir: string;\n settingsFile: string;\n authFile: string;\n telegramFile: string;\n agentHomeFile: string;\n mcpFile: string;\n mcpAuthFile: string;\n /** Cached MCP tool catalog, so a cold start can answer tool_search honestly. */\n mcpCatalogFile: string;\n logFile: string;\n skillsDir: string;\n extensionsDir: string;\n agentsDir: string;\n progressFile: string;\n progressBackupFile: string;\n /** Earned trophies and the counters that unlock them. */\n trophiesFile: string;\n}\n\nexport function getAppPaths(): AppPaths {\n const agentDir = path.join(os.homedir(), \".ezcoder\");\n return {\n agentDir,\n sessionsDir: path.join(agentDir, \"sessions\"),\n subagentSessionsDir: path.join(agentDir, \"subagent-sessions\"),\n subagentsDir: path.join(agentDir, \"subagents\"),\n settingsFile: path.join(agentDir, \"settings.json\"),\n authFile: path.join(agentDir, \"auth.json\"),\n telegramFile: path.join(agentDir, \"telegram.json\"),\n agentHomeFile: path.join(agentDir, \"agent-home.json\"),\n mcpFile: path.join(agentDir, \"mcp.json\"),\n mcpAuthFile: path.join(agentDir, \"mcp-auth.json\"),\n mcpCatalogFile: path.join(agentDir, \"mcp-catalog.json\"),\n logFile: path.join(agentDir, \"debug.log\"),\n skillsDir: path.join(agentDir, \"skills\"),\n extensionsDir: path.join(agentDir, \"extensions\"),\n agentsDir: path.join(agentDir, \"agents\"),\n progressFile: path.join(agentDir, \"progress.json\"),\n progressBackupFile: path.join(agentDir, \"progress.backup.json\"),\n trophiesFile: path.join(agentDir, \"trophies.json\"),\n };\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AAyBR,SAAS,cAAwB;AACtC,QAAM,WAAW,KAAK,KAAK,GAAG,QAAQ,GAAG,UAAU;AACnD,SAAO;AAAA,IACL;AAAA,IACA,aAAa,KAAK,KAAK,UAAU,UAAU;AAAA,IAC3C,qBAAqB,KAAK,KAAK,UAAU,mBAAmB;AAAA,IAC5D,cAAc,KAAK,KAAK,UAAU,WAAW;AAAA,IAC7C,cAAc,KAAK,KAAK,UAAU,eAAe;AAAA,IACjD,UAAU,KAAK,KAAK,UAAU,WAAW;AAAA,IACzC,cAAc,KAAK,KAAK,UAAU,eAAe;AAAA,IACjD,eAAe,KAAK,KAAK,UAAU,iBAAiB;AAAA,IACpD,SAAS,KAAK,KAAK,UAAU,UAAU;AAAA,IACvC,aAAa,KAAK,KAAK,UAAU,eAAe;AAAA,IAChD,gBAAgB,KAAK,KAAK,UAAU,kBAAkB;AAAA,IACtD,SAAS,KAAK,KAAK,UAAU,WAAW;AAAA,IACxC,WAAW,KAAK,KAAK,UAAU,QAAQ;AAAA,IACvC,eAAe,KAAK,KAAK,UAAU,YAAY;AAAA,IAC/C,WAAW,KAAK,KAAK,UAAU,QAAQ;AAAA,IACvC,cAAc,KAAK,KAAK,UAAU,eAAe;AAAA,IACjD,oBAAoB,KAAK,KAAK,UAAU,sBAAsB;AAAA,IAC9D,cAAc,KAAK,KAAK,UAAU,eAAe;AAAA,EACnD;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getAppPaths
3
- } from "./chunk-CRU3SSNX.js";
3
+ } from "./chunk-W4NHU4UL.js";
4
4
 
5
5
  // src/oauth/kimi.ts
6
6
  import { execFileSync } from "child_process";
@@ -268,16 +268,19 @@ import { environmentSecrets, redactText, redactValue } from "@prestyj/ai";
268
268
  var MAX_BYTES = 10 * 1024 * 1024;
269
269
  var MIN_HEADROOM_BYTES = 64 * 1024;
270
270
  var fd = null;
271
- var bytesWritten = 0;
271
+ var logPath = null;
272
+ var fileBytes = 0;
273
+ var processBytes = 0;
274
+ var rotationFailed = false;
272
275
  var capped = false;
273
276
  var sessionId = "";
274
277
  var appName = "app";
275
278
  var cleanups = [];
276
279
  var exactSecrets = [];
277
- function rotateIfNeeded(filePath) {
280
+ function rotateIfNeeded(filePath, force = false) {
278
281
  try {
279
282
  const st = fs.statSync(filePath);
280
- if (st.size <= MAX_BYTES - MIN_HEADROOM_BYTES) return;
283
+ if (!force && st.size <= MAX_BYTES - MIN_HEADROOM_BYTES) return;
281
284
  const rotated = `${filePath}.1`;
282
285
  try {
283
286
  fs.unlinkSync(rotated);
@@ -287,6 +290,32 @@ function rotateIfNeeded(filePath) {
287
290
  } catch {
288
291
  }
289
292
  }
293
+ function rotateOpenLog() {
294
+ if (fd === null || logPath === null) return false;
295
+ const sizeBefore = fileBytes;
296
+ try {
297
+ fs.closeSync(fd);
298
+ } catch {
299
+ }
300
+ fd = null;
301
+ rotateIfNeeded(logPath, true);
302
+ try {
303
+ fd = fs.openSync(logPath, "a");
304
+ fileBytes = fs.fstatSync(fd).size;
305
+ } catch {
306
+ if (fd !== null) {
307
+ try {
308
+ fs.closeSync(fd);
309
+ } catch {
310
+ }
311
+ }
312
+ fd = null;
313
+ capped = true;
314
+ return false;
315
+ }
316
+ if (fileBytes >= sizeBefore) rotationFailed = true;
317
+ return true;
318
+ }
290
319
  function openLog(filePath, name) {
291
320
  if (fd !== null || capped) return false;
292
321
  appName = name;
@@ -300,24 +329,29 @@ function openLog(filePath, name) {
300
329
  fd = fs.openSync(filePath, "a");
301
330
  } catch {
302
331
  fd = null;
303
- bytesWritten = 0;
332
+ fileBytes = 0;
304
333
  return false;
305
334
  }
306
335
  try {
307
- bytesWritten = fs.fstatSync(fd).size;
336
+ fileBytes = fs.fstatSync(fd).size;
308
337
  } catch {
309
338
  try {
310
339
  fs.closeSync(fd);
311
340
  } catch {
312
341
  }
313
342
  fd = null;
314
- bytesWritten = 0;
343
+ fileBytes = 0;
315
344
  return false;
316
345
  }
346
+ logPath = filePath;
347
+ processBytes = 0;
348
+ rotationFailed = false;
317
349
  sessionId = randomBytes(4).toString("hex");
318
350
  try {
319
- if (bytesWritten < MAX_BYTES) {
320
- bytesWritten += fs.writeSync(fd, "\n");
351
+ if (fileBytes < MAX_BYTES) {
352
+ const written = fs.writeSync(fd, "\n");
353
+ fileBytes += written;
354
+ processBytes += written;
321
355
  }
322
356
  } catch {
323
357
  }
@@ -345,12 +379,12 @@ function log(level, category, message, data) {
345
379
  }
346
380
  line += "\n";
347
381
  const lineBytes = Buffer.byteLength(line);
348
- if (bytesWritten + lineBytes > MAX_BYTES) {
382
+ if (processBytes + lineBytes > MAX_BYTES) {
349
383
  const capLine = `[${ts}] [sid=${sessionId}] [WARN] [logger] Log cap reached; file logging disabled until restart
350
384
  `;
351
385
  try {
352
- if (bytesWritten + Buffer.byteLength(capLine) <= MAX_BYTES) {
353
- bytesWritten += fs.writeSync(fd, capLine);
386
+ if (fileBytes + Buffer.byteLength(capLine) <= MAX_BYTES) {
387
+ fileBytes += fs.writeSync(fd, capLine);
354
388
  }
355
389
  fs.closeSync(fd);
356
390
  } catch {
@@ -359,8 +393,12 @@ function log(level, category, message, data) {
359
393
  capped = true;
360
394
  return;
361
395
  }
396
+ if (fileBytes + lineBytes > MAX_BYTES && !rotationFailed && !rotateOpenLog()) return;
397
+ if (fd === null) return;
362
398
  try {
363
- bytesWritten += fs.writeSync(fd, line);
399
+ const written = fs.writeSync(fd, line);
400
+ fileBytes += written;
401
+ processBytes += written;
364
402
  } catch {
365
403
  }
366
404
  }
@@ -376,7 +414,10 @@ function closeLogger(opts) {
376
414
  }
377
415
  }
378
416
  fd = null;
379
- bytesWritten = 0;
417
+ logPath = null;
418
+ fileBytes = 0;
419
+ processBytes = 0;
420
+ rotationFailed = false;
380
421
  capped = false;
381
422
  exactSecrets = [];
382
423
  for (const unsub of cleanups) unsub();
@@ -1532,6 +1573,8 @@ function providerStorageKeys(provider) {
1532
1573
  return dual ? [dual.oauthKey, dual.provider] : [provider];
1533
1574
  }
1534
1575
  var XIAOMI_CREDITS_KEY = "xiaomi-credits";
1576
+ var GEMINI_API_KEY = "gemini-api";
1577
+ var GEMINI_API_KEY_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
1535
1578
  var LOCAL_AUTH_KEY_PREFIX = "local:";
1536
1579
  var LOCAL_CREDENTIAL_LIFETIME_MS = 100 * 365 * 24 * 60 * 60 * 1e3;
1537
1580
  function activeBaseUrlEntry(data, provider) {
@@ -1635,6 +1678,9 @@ var AuthStorage = class {
1635
1678
  if (provider === "xiaomi") {
1636
1679
  return Boolean(this.data["xiaomi"] || this.data[XIAOMI_CREDITS_KEY]);
1637
1680
  }
1681
+ if (provider === "gemini") {
1682
+ return Boolean(this.data["gemini"] || this.data[GEMINI_API_KEY]);
1683
+ }
1638
1684
  if (provider === "local") {
1639
1685
  return Object.keys(this.data).some((key) => key.startsWith(LOCAL_AUTH_KEY_PREFIX));
1640
1686
  }
@@ -1869,6 +1915,12 @@ var AuthStorage = class {
1869
1915
  ...opts.rejectedToken !== void 0 ? { rejectedToken: opts.rejectedToken } : {}
1870
1916
  });
1871
1917
  }
1918
+ if (key === provider) {
1919
+ return await this.resolveCredentials(provider, {
1920
+ ...opts.forceRefresh ? { forceRefresh: true } : {},
1921
+ ...opts.rejectedToken !== void 0 ? { rejectedToken: opts.rejectedToken } : {}
1922
+ });
1923
+ }
1872
1924
  return creds2;
1873
1925
  }
1874
1926
  throw new NotLoggedInError(provider);
@@ -1942,9 +1994,20 @@ var AuthStorage = class {
1942
1994
  const msg = err instanceof Error ? err.message : String(err);
1943
1995
  const isAuthFailure = /\((401|400)\)/.test(msg) || /invalid_grant|invalid_token|invalid.*refresh/i.test(msg) || /unauthorized/i.test(msg);
1944
1996
  if (isAuthFailure) {
1945
- delete latest[provider];
1946
- this.data = latest;
1947
- await atomicWriteFile(this.filePath, JSON.stringify(latest, null, 2));
1997
+ const current = await readAuthData(this.filePath);
1998
+ const currentCreds = current[provider];
1999
+ if (currentCreds && currentCreds.refreshToken !== latestCreds.refreshToken) {
2000
+ log(
2001
+ "WARN",
2002
+ "auth",
2003
+ `${provider} token refresh was rejected, but another gg process already saved a newer credential \u2014 adopting it instead of signing out`
2004
+ );
2005
+ this.data = current;
2006
+ return currentCreds;
2007
+ }
2008
+ delete current[provider];
2009
+ this.data = current;
2010
+ await atomicWriteFile(this.filePath, JSON.stringify(current, null, 2));
1948
2011
  throw new NotLoggedInError(provider);
1949
2012
  }
1950
2013
  throw err;
@@ -2010,6 +2073,24 @@ var NotLoggedInError = class extends Error {
2010
2073
  };
2011
2074
 
2012
2075
  // src/model-registry.ts
2076
+ var CLAUDE_FAST_BILLING = {
2077
+ label: "bills usage credits",
2078
+ 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.",
2079
+ paid: true,
2080
+ standardModel: "claude-opus-5-5"
2081
+ };
2082
+ var XIAOMI_ULTRASPEED_BILLING = {
2083
+ label: "bills API Credits",
2084
+ 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.",
2085
+ paid: true,
2086
+ standardModel: "mimo-v2.6-pro"
2087
+ };
2088
+ var CODEX_FAST_BILLING = {
2089
+ label: "2.5x plan usage",
2090
+ detail: "Codex Fast mode uses your ChatGPT plan limits at 2.5x the standard rate (purchased credits at 2x).",
2091
+ paid: false
2092
+ };
2093
+ var GEMINI_AUTH_KEYS = [GEMINI_API_KEY, "gemini"];
2013
2094
  var MODELS = [
2014
2095
  // ── Anthropic ──────────────────────────────────────────
2015
2096
  // NOTE: Claude Mythos 5.1 (`claude-mythos-5-1`, 2026-09-01) is kept commented
@@ -2073,14 +2154,14 @@ var MODELS = [
2073
2154
  maxThinkingLevel: "max"
2074
2155
  },
2075
2156
  {
2076
- // Released 2026-07-24 — "For complex agentic coding and enterprise work".
2077
- // Near-Fable capability at half the price ($5/$25 vs $10/$50). Adaptive
2078
- // thinking with the full effort ladder (low→max, xhigh included); dateless
2079
- // ID is the canonical pinned snapshot (post-4.6 naming scheme). Kept as a
2080
- // legacy option now that Opus 5.5 leads the line: it's the last Opus that
2081
- // accepts disabled thinking and forced tool use.
2082
- id: "claude-opus-5",
2083
- name: "Claude Opus 5",
2157
+ // Opus 5.5 in fast mode (research preview): the same model at up to 2.5x
2158
+ // output tokens/sec, $8/$40 MTok. @prestyj/ai's `stream()` sends it as
2159
+ // `claude-opus-5-5` + `speed: "fast"` + the fast-mode beta. On a Claude
2160
+ // subscription it bills usage credits only — never included plan usage —
2161
+ // and Anthropic 429s "Usage credits are required for fast mode" until they
2162
+ // are turned on. Its prompt cache is separate from standard-speed Opus.
2163
+ id: "claude-opus-5-5-fast",
2164
+ name: "Claude Opus 5.5 Fast",
2084
2165
  provider: "anthropic",
2085
2166
  contextWindow: 1e6,
2086
2167
  maxOutputTokens: 128e3,
@@ -2088,11 +2169,9 @@ var MODELS = [
2088
2169
  supportsImages: true,
2089
2170
  supportsVideo: false,
2090
2171
  costTier: "high",
2091
- // Anthropic's API and Claude Code both start the 5.5 family at medium; at a
2092
- // given level 5.5 thinks more than 5, so the ladder ceiling (max) made fresh
2093
- // sessions slow and expensive. Users can still opt up.
2094
2172
  defaultThinkingLevel: "medium",
2095
- maxThinkingLevel: "max"
2173
+ maxThinkingLevel: "max",
2174
+ billing: CLAUDE_FAST_BILLING
2096
2175
  },
2097
2176
  {
2098
2177
  // Released 2026-09-28 — replaces Sonnet 5 at $2/$10 MTok, with the same
@@ -2106,9 +2185,10 @@ var MODELS = [
2106
2185
  supportsImages: true,
2107
2186
  supportsVideo: false,
2108
2187
  costTier: "medium",
2109
- // Anthropic's API and Claude Code both start the 5.5 family at medium; at a
2110
- // given level 5.5 thinks more than 5, so the ladder ceiling (max) made fresh
2111
- // sessions slow and expensive. Users can still opt up.
2188
+ // We start Sonnet 5.5 at medium like the rest of the 5.5 family (the API's
2189
+ // own default for Sonnet 5.5 is high). At a given level 5.5 thinks more
2190
+ // than 5, so the ladder ceiling (max) made fresh sessions slow and
2191
+ // expensive. Users can still opt up.
2112
2192
  defaultThinkingLevel: "medium",
2113
2193
  maxThinkingLevel: "max"
2114
2194
  },
@@ -2161,6 +2241,25 @@ var MODELS = [
2161
2241
  costTier: "high",
2162
2242
  maxThinkingLevel: "ultra"
2163
2243
  },
2244
+ {
2245
+ // Codex Fast mode for Astra (catalog `service_tiers: priority`, "2x speed,
2246
+ // increased usage"). @prestyj/ai's `stream()` sends it as `gpt-6-astra` +
2247
+ // `service_tier: "priority"`, exactly what the Codex CLI sends. On a
2248
+ // ChatGPT plan it draws included limits at 2.5x the standard rate.
2249
+ id: "gpt-6-astra-fast",
2250
+ name: "GPT-6 Astra Fast",
2251
+ provider: "openai",
2252
+ contextWindow: 105e4,
2253
+ codexContextWindow: 272e3,
2254
+ maxOutputTokens: 128e3,
2255
+ supportsThinking: true,
2256
+ defaultThinkingLevel: "low",
2257
+ supportsImages: true,
2258
+ supportsVideo: false,
2259
+ costTier: "high",
2260
+ maxThinkingLevel: "ultra",
2261
+ billing: CODEX_FAST_BILLING
2262
+ },
2164
2263
  // GPT-6 Sol + Luna — released 2026-09-22 below Astra, replacing the whole
2165
2264
  // GPT-5.6 family (Sol/Terra/Luna; there is no GPT-6 Terra — OpenAI's Codex
2166
2265
  // catalog upgrades 5.6 Terra to 6 Sol). GPT-6.1 Sol (2026-09-29) then replaced
@@ -2189,6 +2288,23 @@ var MODELS = [
2189
2288
  costTier: "medium",
2190
2289
  maxThinkingLevel: "ultra"
2191
2290
  },
2291
+ {
2292
+ // Codex Fast mode for 6.1 Sol ("2x speed, increased usage") — see
2293
+ // `gpt-6-astra-fast` for the wire mapping and billing.
2294
+ id: "gpt-6.1-sol-fast",
2295
+ name: "GPT-6.1 Sol Fast",
2296
+ provider: "openai",
2297
+ contextWindow: 105e4,
2298
+ codexContextWindow: 272e3,
2299
+ maxOutputTokens: 128e3,
2300
+ supportsThinking: true,
2301
+ defaultThinkingLevel: "low",
2302
+ supportsImages: true,
2303
+ supportsVideo: false,
2304
+ costTier: "medium",
2305
+ maxThinkingLevel: "ultra",
2306
+ billing: CODEX_FAST_BILLING
2307
+ },
2192
2308
  {
2193
2309
  // Luna — "Fast and affordable model for easier tasks." (Codex priority 4,
2194
2310
  // default medium, needs a Codex client >= 0.155.0). $0.10/$0.50 MTok.
@@ -2206,6 +2322,24 @@ var MODELS = [
2206
2322
  costTier: "low",
2207
2323
  maxThinkingLevel: "max"
2208
2324
  },
2325
+ {
2326
+ // Codex Fast mode for Luna ("1.5x speed") — see `gpt-6-astra-fast` for the
2327
+ // wire mapping and billing. Listed after Luna so compaction summaries
2328
+ // (first `low` OpenAI model) stay on standard-speed Luna.
2329
+ id: "gpt-6-luna-fast",
2330
+ name: "GPT-6 Luna Fast",
2331
+ provider: "openai",
2332
+ contextWindow: 105e4,
2333
+ codexContextWindow: 272e3,
2334
+ maxOutputTokens: 128e3,
2335
+ supportsThinking: true,
2336
+ defaultThinkingLevel: "medium",
2337
+ supportsImages: true,
2338
+ supportsVideo: false,
2339
+ costTier: "low",
2340
+ maxThinkingLevel: "max",
2341
+ billing: CODEX_FAST_BILLING
2342
+ },
2209
2343
  // ── Sakana (Fugu) ──────────────────────────────────────
2210
2344
  // Sakana Fugu is a multi-agent system surfaced as a standard LLM via the
2211
2345
  // OpenAI-compatible Sakana API (https://api.sakana.ai/v1). All three take
@@ -2288,10 +2422,14 @@ var MODELS = [
2288
2422
  supportsVideo: true,
2289
2423
  maxVideoBytes: 20 * 1024 * 1024,
2290
2424
  costTier: "low",
2291
- maxThinkingLevel: "high"
2425
+ maxThinkingLevel: "high",
2426
+ authStorageKeys: GEMINI_AUTH_KEYS
2292
2427
  },
2293
2428
  // Keep 3.1 Flash Lite first for the working OAuth default and fast-model routing.
2294
- // New GA models are opt-in; Code Assist access varies by account.
2429
+ // New GA models are opt-in; Code Assist access varies by account. Gemini 3.7
2430
+ // Flash is retired: Google deprecated it on 2026-10-08 and routes every
2431
+ // `gemini-3.7-flash` request to 3.8 Flash (ai.google.dev/gemini-api/docs/
2432
+ // changelog), so a saved session on it falls back to the provider default.
2295
2433
  {
2296
2434
  id: "gemini-3.8-flash",
2297
2435
  name: "Gemini 3.8 Flash",
@@ -2303,7 +2441,8 @@ var MODELS = [
2303
2441
  supportsVideo: true,
2304
2442
  maxVideoBytes: 20 * 1024 * 1024,
2305
2443
  costTier: "low",
2306
- maxThinkingLevel: "high"
2444
+ maxThinkingLevel: "high",
2445
+ authStorageKeys: GEMINI_AUTH_KEYS
2307
2446
  },
2308
2447
  {
2309
2448
  id: "gemini-3.5-flash-lite",
@@ -2316,27 +2455,8 @@ var MODELS = [
2316
2455
  supportsVideo: true,
2317
2456
  maxVideoBytes: 20 * 1024 * 1024,
2318
2457
  costTier: "low",
2319
- maxThinkingLevel: "high"
2320
- },
2321
- {
2322
- // Gemini 3.7 Flash (released 2026-08-13) — Google's most capable Flash for
2323
- // coding, agents, and multi-step execution; GA-stable on the Gemini API as
2324
- // `gemini-3.7-flash`. 1M context, 64K output, thinking low/medium/high.
2325
- // Sent over our Code Assist (OAuth) transport ahead of gemini-cli — upstream
2326
- // hasn't listed 3.7 yet (google-gemini/gemini-cli#28802, still open) — so
2327
- // free/personal accounts 404 (entitlement-gated) while Code Assist
2328
- // Standard/Enterprise accounts get it.
2329
- id: "gemini-3.7-flash",
2330
- name: "Gemini 3.7 Flash",
2331
- provider: "gemini",
2332
- contextWindow: 1048576,
2333
- maxOutputTokens: 65536,
2334
- supportsThinking: true,
2335
- supportsImages: true,
2336
- supportsVideo: true,
2337
- maxVideoBytes: 20 * 1024 * 1024,
2338
- costTier: "low",
2339
- maxThinkingLevel: "high"
2458
+ maxThinkingLevel: "high",
2459
+ authStorageKeys: GEMINI_AUTH_KEYS
2340
2460
  },
2341
2461
  {
2342
2462
  // Wire name `gemini-3-flash` — the Code Assist (OAuth) backend rejects the
@@ -2352,7 +2472,8 @@ var MODELS = [
2352
2472
  supportsVideo: true,
2353
2473
  maxVideoBytes: 20 * 1024 * 1024,
2354
2474
  costTier: "low",
2355
- maxThinkingLevel: "high"
2475
+ maxThinkingLevel: "high",
2476
+ authStorageKeys: GEMINI_AUTH_KEYS
2356
2477
  },
2357
2478
  {
2358
2479
  // Gemini 3.1 Pro is public preview — gated behind Code Assist preview
@@ -2368,7 +2489,8 @@ var MODELS = [
2368
2489
  supportsVideo: true,
2369
2490
  maxVideoBytes: 20 * 1024 * 1024,
2370
2491
  costTier: "high",
2371
- maxThinkingLevel: "high"
2492
+ maxThinkingLevel: "high",
2493
+ authStorageKeys: GEMINI_AUTH_KEYS
2372
2494
  },
2373
2495
  // ── Moonshot (Kimi) ────────────────────────────────────
2374
2496
  // K3 is Kimi's 2.8T-parameter flagship for long-horizon coding, knowledge
@@ -2573,9 +2695,13 @@ var MODELS = [
2573
2695
  maxVideoBytes: 36 * 1024 * 1024,
2574
2696
  costTier: "high",
2575
2697
  maxThinkingLevel: "high",
2576
- authStorageKeys: [XIAOMI_CREDITS_KEY]
2698
+ authStorageKeys: [XIAOMI_CREDITS_KEY],
2699
+ billing: XIAOMI_ULTRASPEED_BILLING
2577
2700
  },
2578
2701
  // ── DeepSeek ───────────────────────────────────────────
2702
+ // Window 1,000,000 tokens (decimal "1M"), as DeepSeek's own agent sizes it
2703
+ // (deepseek-ai/deepseek-harness DEFAULT_CONTEXT_WINDOW = 1_000_000; models.dev
2704
+ // via earendil-works/pi agrees) — not 1,048,576.
2579
2705
  // The live /models list (2026-09-28) serves exactly `deepseek-flash` and
2580
2706
  // `deepseek-v4-pro`. V4 Flash and V4 Flash Vision Exp are retired; their old
2581
2707
  // ids only temporarily route to V4.1 Flash, so they are retired here too.
@@ -2589,7 +2715,7 @@ var MODELS = [
2589
2715
  id: "deepseek-v4-pro",
2590
2716
  name: "DeepSeek V4 Pro",
2591
2717
  provider: "deepseek",
2592
- contextWindow: 1048576,
2718
+ contextWindow: 1e6,
2593
2719
  maxOutputTokens: 384e3,
2594
2720
  supportsThinking: true,
2595
2721
  supportsImages: false,
@@ -2603,7 +2729,7 @@ var MODELS = [
2603
2729
  id: "deepseek-flash",
2604
2730
  name: "DeepSeek V4.1 Flash",
2605
2731
  provider: "deepseek",
2606
- contextWindow: 1048576,
2732
+ contextWindow: 1e6,
2607
2733
  maxOutputTokens: 384e3,
2608
2734
  supportsThinking: true,
2609
2735
  supportsImages: true,
@@ -2667,7 +2793,7 @@ var MODELS = [
2667
2793
  id: "deepseek-ai/DeepSeek-V4.1-Flash",
2668
2794
  name: "DeepSeek V4.1 Flash",
2669
2795
  provider: "huggingface",
2670
- contextWindow: 1048576,
2796
+ contextWindow: 1e6,
2671
2797
  maxOutputTokens: 131072,
2672
2798
  supportsThinking: false,
2673
2799
  supportsImages: true,
@@ -2714,6 +2840,19 @@ function getModel(id) {
2714
2840
  function getModelsForProvider(provider) {
2715
2841
  return getAllModels().filter((m) => m.provider === provider);
2716
2842
  }
2843
+ function isPaidModel(modelId) {
2844
+ return getModel(modelId)?.billing?.paid === true;
2845
+ }
2846
+ function withoutPaidTier(modelId) {
2847
+ const model = getModel(modelId);
2848
+ if (model?.billing?.paid !== true) return modelId;
2849
+ const usable = (id) => id !== void 0 && getModel(id) !== void 0 && !isPaidModel(id);
2850
+ const standard = model.billing.standardModel;
2851
+ if (usable(standard)) return standard;
2852
+ const providerDefault = DEFAULT_MODEL_IDS[model.provider];
2853
+ if (usable(providerDefault)) return providerDefault;
2854
+ return FALLBACK_DEFAULT_MODEL_ID;
2855
+ }
2717
2856
  function getAuthStorageKeys(provider, modelId) {
2718
2857
  const model = getAllModels().find((m) => m.id === modelId && m.provider === provider);
2719
2858
  return model?.authStorageKeys ?? [provider];
@@ -2795,7 +2934,7 @@ var SUMMARY_COST_TIER = {
2795
2934
  };
2796
2935
  function getSummaryModel(provider, currentModelId) {
2797
2936
  const tier = SUMMARY_COST_TIER[provider];
2798
- const tagged = tier ? getModelsForProvider(provider).find((m) => m.costTier === tier) : void 0;
2937
+ const tagged = tier ? getModelsForProvider(provider).find((m) => m.costTier === tier && m.billing === void 0) : void 0;
2799
2938
  return tagged ?? getModel(currentModelId) ?? getDefaultModel(provider);
2800
2939
  }
2801
2940
 
@@ -2835,6 +2974,8 @@ export {
2835
2974
  oauthStorageKey,
2836
2975
  providerStorageKeys,
2837
2976
  XIAOMI_CREDITS_KEY,
2977
+ GEMINI_API_KEY,
2978
+ GEMINI_API_KEY_BASE_URL,
2838
2979
  LOCAL_AUTH_KEY_PREFIX,
2839
2980
  readStoredBaseUrlSync,
2840
2981
  AuthStorage,
@@ -2845,6 +2986,8 @@ export {
2845
2986
  getAllModels,
2846
2987
  getModel,
2847
2988
  getModelsForProvider,
2989
+ isPaidModel,
2990
+ withoutPaidTier,
2848
2991
  getAuthStorageKeys,
2849
2992
  getAuthStorageKey,
2850
2993
  DEFAULT_MAX_VIDEO_BYTES,
@@ -2857,4 +3000,4 @@ export {
2857
3000
  getDefaultThinkingLevel,
2858
3001
  getSummaryModel
2859
3002
  };
2860
- //# sourceMappingURL=chunk-GYAMOZYP.js.map
3003
+ //# sourceMappingURL=chunk-XPXWXKRZ.js.map