@prestyj/core 5.32.1 → 5.33.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.
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var model_registry_exports = {};
32
32
  __export(model_registry_exports, {
33
33
  DEFAULT_MAX_VIDEO_BYTES: () => DEFAULT_MAX_VIDEO_BYTES,
34
+ HIDDEN_PROVIDERS: () => HIDDEN_PROVIDERS,
34
35
  MODELS: () => MODELS,
35
36
  clearRuntimeModels: () => clearRuntimeModels,
36
37
  getAllModels: () => getAllModels,
@@ -39,14 +40,18 @@ __export(model_registry_exports, {
39
40
  getContextWindow: () => getContextWindow,
40
41
  getDefaultModel: () => getDefaultModel,
41
42
  getDefaultThinkingLevel: () => getDefaultThinkingLevel,
43
+ getListedModels: () => getListedModels,
42
44
  getMaxThinkingLevel: () => getMaxThinkingLevel,
43
45
  getModel: () => getModel,
44
46
  getModelsForProvider: () => getModelsForProvider,
47
+ getProviderCatalog: () => getProviderCatalog,
45
48
  getSummaryModel: () => getSummaryModel,
46
49
  getToolResultCharLimit: () => getToolResultCharLimit,
47
50
  getVideoByteLimit: () => getVideoByteLimit,
51
+ isHiddenProvider: () => isHiddenProvider,
48
52
  isPaidModel: () => isPaidModel,
49
53
  registerRuntimeModels: () => registerRuntimeModels,
54
+ setProviderCatalog: () => setProviderCatalog,
50
55
  usesOpenAICodexTransport: () => usesOpenAICodexTransport,
51
56
  withoutPaidTier: () => withoutPaidTier
52
57
  });
@@ -76,40 +81,26 @@ function isKimiCodingEndpoint(baseUrl) {
76
81
  }
77
82
 
78
83
  // src/auth-storage.ts
79
- var import_promises4 = __toESM(require("fs/promises"), 1);
80
- var import_node_fs4 = require("fs");
81
- var import_node_crypto6 = __toESM(require("crypto"), 1);
84
+ var import_promises5 = __toESM(require("fs/promises"), 1);
85
+ var import_node_fs5 = require("fs");
86
+ var import_node_crypto7 = __toESM(require("crypto"), 1);
82
87
 
83
88
  // src/oauth/anthropic.ts
84
- var import_node_crypto3 = __toESM(require("crypto"), 1);
89
+ var import_node_crypto2 = __toESM(require("crypto"), 1);
85
90
 
86
91
  // src/claude-code-version.ts
87
- var import_promises = __toESM(require("fs/promises"), 1);
88
- var import_node_fs3 = require("fs");
89
- var import_node_path4 = __toESM(require("path"), 1);
90
-
91
- // src/logger.ts
92
- var import_node_fs2 = __toESM(require("fs"), 1);
93
- var import_node_path3 = __toESM(require("path"), 1);
94
- var import_node_crypto2 = require("crypto");
95
92
  var import_ai = require("@prestyj/ai");
96
- var MAX_BYTES = 10 * 1024 * 1024;
97
- var MIN_HEADROOM_BYTES = 64 * 1024;
98
-
99
- // src/claude-code-version.ts
100
- var CACHE_FRESH_MS = 60 * 60 * 1e3;
101
- var CACHE_HARD_MS = 24 * 60 * 60 * 1e3;
102
93
 
103
94
  // src/oauth/anthropic.ts
104
95
  var CLIENT_ID = atob("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
105
96
 
106
97
  // src/oauth/openai.ts
107
98
  var import_node_http = __toESM(require("http"), 1);
108
- var import_node_crypto4 = __toESM(require("crypto"), 1);
99
+ var import_node_crypto3 = __toESM(require("crypto"), 1);
109
100
 
110
101
  // src/oauth/gemini.ts
111
102
  var import_node_http2 = __toESM(require("http"), 1);
112
- var import_node_crypto5 = __toESM(require("crypto"), 1);
103
+ var import_node_crypto4 = __toESM(require("crypto"), 1);
113
104
  var SCOPE = [
114
105
  "https://www.googleapis.com/auth/cloud-platform",
115
106
  "https://www.googleapis.com/auth/userinfo.email",
@@ -120,14 +111,42 @@ var SCOPE = [
120
111
  var DEVICE_TIMEOUT_FALLBACK_MS = 10 * 60 * 1e3;
121
112
 
122
113
  // src/file-lock.ts
123
- var import_promises2 = __toESM(require("fs/promises"), 1);
124
- var import_promises3 = require("timers/promises");
114
+ var import_promises = __toESM(require("fs/promises"), 1);
115
+ var import_promises2 = require("timers/promises");
116
+
117
+ // 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");
121
+ var import_ai2 = require("@prestyj/ai");
122
+ var MAX_BYTES = 10 * 1024 * 1024;
123
+ var MIN_HEADROOM_BYTES = 64 * 1024;
124
+
125
+ // src/hidden-providers.ts
126
+ var HIDDEN_PROVIDERS = ["gemini"];
127
+ function isHiddenProvider(provider) {
128
+ return HIDDEN_PROVIDERS.includes(provider);
129
+ }
130
+
131
+ // src/claude-code/runtime.ts
132
+ var import_node_child_process2 = require("child_process");
133
+ var import_node_crypto6 = __toESM(require("crypto"), 1);
134
+ var import_node_fs4 = __toESM(require("fs"), 1);
135
+ var import_promises4 = __toESM(require("fs/promises"), 1);
136
+ var import_node_path4 = __toESM(require("path"), 1);
137
+
138
+ // src/claude-code/tar.ts
139
+ var import_node_fs3 = __toESM(require("fs"), 1);
140
+ var import_promises3 = __toESM(require("fs/promises"), 1);
141
+ var import_node_zlib = __toESM(require("zlib"), 1);
125
142
 
126
143
  // src/auth-storage.ts
144
+ var import_ai3 = require("@prestyj/ai");
127
145
  var MOONSHOT_OAUTH_KEY = "moonshot-oauth";
128
146
  var XIAOMI_CREDITS_KEY = "xiaomi-credits";
129
147
  var GEMINI_API_KEY = "gemini-api";
130
148
  var LOCAL_CREDENTIAL_LIFETIME_MS = 100 * 365 * 24 * 60 * 60 * 1e3;
149
+ var MINIMAX_REGION_RETRY_MS = 5 * 60 * 1e3;
131
150
  var USAGE_EXHAUSTED_DEFAULT_MS = 15 * 60 * 1e3;
132
151
 
133
152
  // src/model-registry.ts
@@ -137,6 +156,12 @@ var CLAUDE_FAST_BILLING = {
137
156
  paid: true,
138
157
  standardModel: "claude-opus-5-5"
139
158
  };
159
+ var CLAUDE_FABLE_FAST_BILLING = {
160
+ label: "bills usage credits",
161
+ detail: "Fast mode bills your Claude usage credits ($16 in / $80 out per million tokens) from the first token, never your plan's included usage.",
162
+ paid: true,
163
+ standardModel: "claude-fable-5-2"
164
+ };
140
165
  var XIAOMI_ULTRASPEED_BILLING = {
141
166
  label: "bills API Credits",
142
167
  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.",
@@ -151,18 +176,18 @@ var CODEX_FAST_BILLING = {
151
176
  var GEMINI_AUTH_KEYS = [GEMINI_API_KEY, "gemini"];
152
177
  var MODELS = [
153
178
  // ── Anthropic ──────────────────────────────────────────
154
- // NOTE: Claude Mythos 5.1 (`claude-mythos-5-1`, 2026-09-01) is kept commented
155
- // out — it's a Project Glasswing model, still "Active (invite only)" in
156
- // Anthropic's docs and unavailable to most users. Re-enable once it's
157
- // generally available.
158
- {
159
- // Released 2026-09-01 — replaces Fable 5 at the same $10/$50 MTok (cache
160
- // reads drop to $0.25). Always-on adaptive thinking steered by effort;
161
- // forced tool use is rejected with a 400, which @prestyj/ai never sends on the
162
- // Anthropic path. Fable 5 is retired here — a session that still has it
163
- // saved falls back to the provider default on next start.
164
- id: "claude-fable-5-1",
165
- name: "Claude Fable 5.1",
179
+ // NOTE: Claude Mythos 5.2 (`claude-mythos-5-2`, 2026-11-09) is kept commented
180
+ // out — it's only for organizations verified through Anthropic's verification
181
+ // programs and unavailable to most users. Re-enable once it's generally
182
+ // available.
183
+ {
184
+ // Released 2026-11-09 — replaces Fable 5.1 at $8/$40 MTok (down from
185
+ // $10/$50; cache reads $0.20). Same API surface as 5.1: always-on adaptive
186
+ // thinking steered by effort, forced tool use rejected with a 400 (@prestyj/ai
187
+ // never sends it on the Anthropic path). Fable 5.1 is retired here — a
188
+ // session that still has it saved falls back to the provider default.
189
+ id: "claude-fable-5-2",
190
+ name: "Claude Fable 5.2",
166
191
  provider: "anthropic",
167
192
  contextWindow: 1e6,
168
193
  maxOutputTokens: 128e3,
@@ -172,12 +197,28 @@ var MODELS = [
172
197
  costTier: "high",
173
198
  maxThinkingLevel: "max"
174
199
  },
200
+ {
201
+ // Fable 5.2 in fast mode: the same model at up to 2.5x output tokens/sec,
202
+ // $16/$80 MTok. Sent as `claude-fable-5-2` + `speed: "fast"`; on a Claude
203
+ // subscription it bills usage credits only, like Opus 5.5 Fast.
204
+ id: "claude-fable-5-2-fast",
205
+ name: "Claude Fable 5.2 Fast",
206
+ provider: "anthropic",
207
+ contextWindow: 1e6,
208
+ maxOutputTokens: 128e3,
209
+ supportsThinking: true,
210
+ supportsImages: true,
211
+ supportsVideo: false,
212
+ costTier: "high",
213
+ maxThinkingLevel: "max",
214
+ billing: CLAUDE_FABLE_FAST_BILLING
215
+ },
175
216
  // {
176
217
  // // Mythos-class model offered through Project Glasswing (limited
177
- // // availability, invitation-only). Same underlying model as Fable 5.1 with
178
- // // some safeguards lifted; kept here so approved accounts can select it.
179
- // id: "claude-mythos-5-1",
180
- // name: "Claude Mythos 5.1",
218
+ // // availability, verified organizations only). Same specs and pricing as
219
+ // // Fable 5.2; kept here so approved accounts can select it.
220
+ // id: "claude-mythos-5-2",
221
+ // name: "Claude Mythos 5.2",
181
222
  // provider: "anthropic",
182
223
  // contextWindow: 1_000_000,
183
224
  // maxOutputTokens: 128_000,
@@ -319,9 +360,9 @@ var MODELS = [
319
360
  billing: CODEX_FAST_BILLING
320
361
  },
321
362
  // GPT-6 Sol + Luna — released 2026-09-22 below Astra, replacing the whole
322
- // GPT-5.6 family (Sol/Terra/Luna; there is no GPT-6 Terra — OpenAI's Codex
363
+ // GPT-5.6 family (Sol/Terra/Luna; there was no GPT-6 Terra — OpenAI's Codex
323
364
  // catalog upgrades 5.6 Terra to 6 Sol). GPT-6.1 Sol (2026-09-29) then replaced
324
- // GPT-6 Sol. Same window split as Astra: 1.05M on the public Responses API,
365
+ // 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,
325
366
  // 272K on the Codex route; 128K output, text+image input, freeform
326
367
  // apply_patch, responses-lite transport. The GPT-5.6 ids and `gpt-6-sol` are
327
368
  // retired — a saved session on one falls back to the provider default on
@@ -363,6 +404,40 @@ var MODELS = [
363
404
  maxThinkingLevel: "ultra",
364
405
  billing: CODEX_FAST_BILLING
365
406
  },
407
+ {
408
+ // GPT-6.1 Terra (Codex priority 7, default low, client >= 0.153.0). $1/$5
409
+ // MTok, cached input $0.05. Unlike Sol/Astra the Codex route gets a 500K
410
+ // window (catalog `context_window`). Same ladder and Ultra preset as Sol.
411
+ id: "gpt-6.1-terra",
412
+ name: "GPT-6.1 Terra",
413
+ provider: "openai",
414
+ contextWindow: 105e4,
415
+ codexContextWindow: 5e5,
416
+ maxOutputTokens: 128e3,
417
+ supportsThinking: true,
418
+ defaultThinkingLevel: "low",
419
+ supportsImages: true,
420
+ supportsVideo: false,
421
+ costTier: "medium",
422
+ maxThinkingLevel: "ultra"
423
+ },
424
+ {
425
+ // Codex Fast mode for 6.1 Terra ("1.5x speed") — see `gpt-6-astra-fast`
426
+ // for the wire mapping and billing.
427
+ id: "gpt-6.1-terra-fast",
428
+ name: "GPT-6.1 Terra Fast",
429
+ provider: "openai",
430
+ contextWindow: 105e4,
431
+ codexContextWindow: 5e5,
432
+ maxOutputTokens: 128e3,
433
+ supportsThinking: true,
434
+ defaultThinkingLevel: "low",
435
+ supportsImages: true,
436
+ supportsVideo: false,
437
+ costTier: "medium",
438
+ maxThinkingLevel: "ultra",
439
+ billing: CODEX_FAST_BILLING
440
+ },
366
441
  {
367
442
  // Luna — "Fast and affordable model for easier tasks." (Codex priority 4,
368
443
  // default medium, needs a Codex client >= 0.155.0). $0.10/$0.50 MTok.
@@ -667,6 +742,23 @@ var MODELS = [
667
742
  maxThinkingLevel: "max"
668
743
  },
669
744
  // ── MiniMax ────────────────────────────────────────────
745
+ {
746
+ // The only text model M Plan / Token Plan keys cover; MiniMax-M3 on those
747
+ // keys fails with "insufficient balance (1008)". Pay-as-you-go serves both.
748
+ // Always thinks (`thinking: disabled` 400s; omitted = on) with a real
749
+ // low→max effort ladder on output_config.effort, API default max.
750
+ id: "MiniMax-M3.1-Flash",
751
+ name: "MiniMax M3.1 Flash",
752
+ provider: "minimax",
753
+ contextWindow: 1e6,
754
+ maxOutputTokens: 131072,
755
+ supportsThinking: true,
756
+ supportsImages: true,
757
+ supportsVideo: true,
758
+ maxVideoBytes: 50 * 1024 * 1024,
759
+ costTier: "low",
760
+ maxThinkingLevel: "max"
761
+ },
670
762
  {
671
763
  id: "MiniMax-M3",
672
764
  name: "MiniMax M3",
@@ -889,15 +981,51 @@ function clearRuntimeModels(predicate) {
889
981
  if (predicate(model)) runtimeModels.delete(id);
890
982
  }
891
983
  }
984
+ var providerCatalogs = /* @__PURE__ */ new Map();
985
+ function setProviderCatalog(provider, models) {
986
+ if (!models) {
987
+ providerCatalogs.delete(provider);
988
+ return [];
989
+ }
990
+ const installed = /* @__PURE__ */ new Map();
991
+ for (const model of models) {
992
+ if (model.provider !== provider) continue;
993
+ if (MODELS.some((m) => m.id === model.id && m.provider !== provider)) continue;
994
+ installed.set(model.id, model);
995
+ }
996
+ providerCatalogs.set(provider, installed);
997
+ return [...installed.values()];
998
+ }
999
+ function getProviderCatalog(provider) {
1000
+ const catalog = providerCatalogs.get(provider);
1001
+ return catalog ? [...catalog.values()] : void 0;
1002
+ }
892
1003
  function getAllModels() {
893
- return [...MODELS, ...runtimeModels.values()];
1004
+ const synced = [...providerCatalogs.values()].flatMap((c) => [...c.values()]);
1005
+ return [
1006
+ ...MODELS.filter((m) => !providerCatalogs.has(m.provider)),
1007
+ ...synced,
1008
+ ...runtimeModels.values()
1009
+ ];
894
1010
  }
895
1011
  function getModel(id) {
896
- return MODELS.find((m) => m.id === id) ?? runtimeModels.get(id);
1012
+ const fixed = MODELS.find((m) => m.id === id);
1013
+ if (fixed && !providerCatalogs.has(fixed.provider)) return fixed;
1014
+ return findSynced(id) ?? fixed ?? runtimeModels.get(id);
1015
+ }
1016
+ function findSynced(id) {
1017
+ for (const catalog of providerCatalogs.values()) {
1018
+ const hit = catalog.get(id);
1019
+ if (hit) return hit;
1020
+ }
1021
+ return void 0;
897
1022
  }
898
1023
  function getModelsForProvider(provider) {
899
1024
  return getAllModels().filter((m) => m.provider === provider);
900
1025
  }
1026
+ function getListedModels() {
1027
+ return getAllModels().filter((m) => !isHiddenProvider(m.provider));
1028
+ }
901
1029
  function isPaidModel(modelId) {
902
1030
  return getModel(modelId)?.billing?.paid === true;
903
1031
  }
@@ -930,7 +1058,7 @@ var DEFAULT_MODEL_IDS = {
930
1058
  gemini: "gemini-3.1-flash-lite",
931
1059
  glm: "glm-5.3",
932
1060
  moonshot: "kimi-k3",
933
- minimax: "MiniMax-M3",
1061
+ minimax: "MiniMax-M3.1-Flash",
934
1062
  deepseek: "deepseek-v4-pro",
935
1063
  huggingface: "moonshotai/Kimi-K2.7-Code",
936
1064
  openrouter: "qwen/qwen3.8-max",
@@ -998,6 +1126,7 @@ function getSummaryModel(provider, currentModelId) {
998
1126
  // Annotate the CommonJS export names for ESM import in node:
999
1127
  0 && (module.exports = {
1000
1128
  DEFAULT_MAX_VIDEO_BYTES,
1129
+ HIDDEN_PROVIDERS,
1001
1130
  MODELS,
1002
1131
  clearRuntimeModels,
1003
1132
  getAllModels,
@@ -1006,14 +1135,18 @@ function getSummaryModel(provider, currentModelId) {
1006
1135
  getContextWindow,
1007
1136
  getDefaultModel,
1008
1137
  getDefaultThinkingLevel,
1138
+ getListedModels,
1009
1139
  getMaxThinkingLevel,
1010
1140
  getModel,
1011
1141
  getModelsForProvider,
1142
+ getProviderCatalog,
1012
1143
  getSummaryModel,
1013
1144
  getToolResultCharLimit,
1014
1145
  getVideoByteLimit,
1146
+ isHiddenProvider,
1015
1147
  isPaidModel,
1016
1148
  registerRuntimeModels,
1149
+ setProviderCatalog,
1017
1150
  usesOpenAICodexTransport,
1018
1151
  withoutPaidTier
1019
1152
  });