@prestyj/core 5.7.0 → 5.8.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.
- package/dist/{chunk-RQADK6HE.js → chunk-GMAX7TES.js} +89 -6
- package/dist/chunk-GMAX7TES.js.map +1 -0
- package/dist/index.cjs +99 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/model-registry.cjs +48 -2
- package/dist/model-registry.cjs.map +1 -1
- package/dist/model-registry.d.cts +11 -2
- package/dist/model-registry.d.ts +11 -2
- package/dist/model-registry.js +3 -1
- package/package.json +2 -2
- package/dist/chunk-RQADK6HE.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ __export(index_exports, {
|
|
|
59
59
|
getSessionId: () => getSessionId,
|
|
60
60
|
getSummaryModel: () => getSummaryModel,
|
|
61
61
|
getSupportedThinkingLevels: () => getSupportedThinkingLevels,
|
|
62
|
+
getToolResultCharLimit: () => getToolResultCharLimit,
|
|
62
63
|
getVideoByteLimit: () => getVideoByteLimit,
|
|
63
64
|
isKimiCodingEndpoint: () => isKimiCodingEndpoint,
|
|
64
65
|
isLoggerOpen: () => isLoggerOpen,
|
|
@@ -1231,6 +1232,7 @@ function isAlive(pid) {
|
|
|
1231
1232
|
var MOONSHOT_OAUTH_KEY = "moonshot-oauth";
|
|
1232
1233
|
var XIAOMI_CREDITS_KEY = "xiaomi-credits";
|
|
1233
1234
|
var REFRESH_SKEW_MS = 6e4;
|
|
1235
|
+
var USAGE_EXHAUSTED_DEFAULT_MS = 15 * 60 * 1e3;
|
|
1234
1236
|
var STATIC_API_KEY_PROVIDERS = /* @__PURE__ */ new Set([
|
|
1235
1237
|
"glm",
|
|
1236
1238
|
"moonshot",
|
|
@@ -1238,7 +1240,8 @@ var STATIC_API_KEY_PROVIDERS = /* @__PURE__ */ new Set([
|
|
|
1238
1240
|
"minimax",
|
|
1239
1241
|
"deepseek",
|
|
1240
1242
|
"openrouter",
|
|
1241
|
-
"sakana"
|
|
1243
|
+
"sakana",
|
|
1244
|
+
"xai"
|
|
1242
1245
|
]);
|
|
1243
1246
|
var AuthStorage = class {
|
|
1244
1247
|
data = {};
|
|
@@ -1297,7 +1300,9 @@ var AuthStorage = class {
|
|
|
1297
1300
|
async isStaticApiKey(provider) {
|
|
1298
1301
|
await this.ensureLoaded();
|
|
1299
1302
|
if (provider === "moonshot" && this.data[MOONSHOT_OAUTH_KEY]) {
|
|
1300
|
-
|
|
1303
|
+
const exhaustedUntil = this.data[MOONSHOT_OAUTH_KEY].usageExhaustedUntil ?? 0;
|
|
1304
|
+
const apiKeyActive = Date.now() < exhaustedUntil && Boolean(this.data["moonshot"]);
|
|
1305
|
+
if (!apiKeyActive) return false;
|
|
1301
1306
|
}
|
|
1302
1307
|
return STATIC_API_KEY_PROVIDERS.has(provider);
|
|
1303
1308
|
}
|
|
@@ -1354,6 +1359,30 @@ var AuthStorage = class {
|
|
|
1354
1359
|
delete this.data[provider];
|
|
1355
1360
|
await this.save();
|
|
1356
1361
|
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Mark the credential stored under `storageKey` as usage-exhausted until
|
|
1364
|
+
* `resetsAt` (unix SECONDS, from the provider's rate-limit response) or a
|
|
1365
|
+
* 15-minute default when no reset time is known. While the mark is in the
|
|
1366
|
+
* future, `resolveCredentials("moonshot")` serves the Moonshot API key
|
|
1367
|
+
* instead of the Kimi OAuth credential (when both are configured) — OAuth
|
|
1368
|
+
* stays the preferred credential and is retried automatically once the mark
|
|
1369
|
+
* lapses. Persisted to auth.json so a restart (or another ezcoder-app window)
|
|
1370
|
+
* doesn't burn a request rediscovering the same exhausted window. No-op if
|
|
1371
|
+
* nothing is stored under `storageKey`.
|
|
1372
|
+
*/
|
|
1373
|
+
async markUsageExhausted(storageKey, resetsAt) {
|
|
1374
|
+
await this.ensureLoaded();
|
|
1375
|
+
const creds = this.data[storageKey];
|
|
1376
|
+
if (!creds) return;
|
|
1377
|
+
const until = resetsAt !== void 0 && resetsAt * 1e3 > Date.now() ? resetsAt * 1e3 : Date.now() + USAGE_EXHAUSTED_DEFAULT_MS;
|
|
1378
|
+
creds.usageExhaustedUntil = until;
|
|
1379
|
+
await this.save();
|
|
1380
|
+
log(
|
|
1381
|
+
"WARN",
|
|
1382
|
+
"auth",
|
|
1383
|
+
`Marked ${storageKey} usage-exhausted until ${new Date(until).toISOString()}`
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1357
1386
|
async clearAll() {
|
|
1358
1387
|
this.data = {};
|
|
1359
1388
|
await this.save();
|
|
@@ -1374,8 +1403,19 @@ var AuthStorage = class {
|
|
|
1374
1403
|
throw new NotLoggedInError(provider);
|
|
1375
1404
|
}
|
|
1376
1405
|
if (provider === "moonshot" && this.data[MOONSHOT_OAUTH_KEY]) {
|
|
1406
|
+
const exhaustedUntil = this.data[MOONSHOT_OAUTH_KEY].usageExhaustedUntil ?? 0;
|
|
1407
|
+
if (Date.now() < exhaustedUntil && this.data["moonshot"]) {
|
|
1408
|
+
log(
|
|
1409
|
+
"WARN",
|
|
1410
|
+
"auth",
|
|
1411
|
+
`Kimi OAuth usage window is exhausted \u2014 using the Moonshot API key until ${new Date(exhaustedUntil).toISOString()} (OAuth resumes automatically).`
|
|
1412
|
+
);
|
|
1413
|
+
return this.data["moonshot"];
|
|
1414
|
+
}
|
|
1377
1415
|
try {
|
|
1378
|
-
return await this.resolveCredentials(MOONSHOT_OAUTH_KEY,
|
|
1416
|
+
return await this.resolveCredentials(MOONSHOT_OAUTH_KEY, {
|
|
1417
|
+
...opts?.forceRefresh ? { forceRefresh: true } : {}
|
|
1418
|
+
});
|
|
1379
1419
|
} catch (err) {
|
|
1380
1420
|
if (err instanceof NotLoggedInError && this.data["moonshot"]) {
|
|
1381
1421
|
log(
|
|
@@ -1644,6 +1684,26 @@ var MODELS = [
|
|
|
1644
1684
|
costTier: "high",
|
|
1645
1685
|
maxThinkingLevel: "xhigh"
|
|
1646
1686
|
},
|
|
1687
|
+
// ── xAI (Grok) ─────────────────────────────────────────
|
|
1688
|
+
// Grok 4.5 (released 2026-07-08) is xAI's flagship for coding, agentic
|
|
1689
|
+
// tasks, and knowledge work — 500K context, text+image input, configurable
|
|
1690
|
+
// `reasoning_effort` (low/medium/high, server default high; reasoning can't
|
|
1691
|
+
// be fully disabled). Served over the OpenAI-compatible API at
|
|
1692
|
+
// https://api.x.ai/v1 (API key from console.x.ai). xAI hasn't published an
|
|
1693
|
+
// official max-output cap for 4.5; 131K matches the Grok Responses ceiling
|
|
1694
|
+
// third-party integrations use.
|
|
1695
|
+
{
|
|
1696
|
+
id: "grok-4.5",
|
|
1697
|
+
name: "Grok 4.5",
|
|
1698
|
+
provider: "xai",
|
|
1699
|
+
contextWindow: 5e5,
|
|
1700
|
+
maxOutputTokens: 131072,
|
|
1701
|
+
supportsThinking: true,
|
|
1702
|
+
supportsImages: true,
|
|
1703
|
+
supportsVideo: false,
|
|
1704
|
+
costTier: "medium",
|
|
1705
|
+
maxThinkingLevel: "high"
|
|
1706
|
+
},
|
|
1647
1707
|
// ── Gemini ─────────────────────────────────────────────
|
|
1648
1708
|
{
|
|
1649
1709
|
id: "gemini-3.1-flash-lite",
|
|
@@ -1691,9 +1751,28 @@ var MODELS = [
|
|
|
1691
1751
|
maxThinkingLevel: "high"
|
|
1692
1752
|
},
|
|
1693
1753
|
// ── Moonshot (Kimi) ────────────────────────────────────
|
|
1754
|
+
// K3 is Kimi's 2.8T-parameter flagship for long-horizon coding, knowledge
|
|
1755
|
+
// work, and deep reasoning. It always reasons at the `max` effort; the public
|
|
1756
|
+
// API uses `reasoning_effort`, while Kimi Code OAuth keeps its managed wire shape.
|
|
1757
|
+
{
|
|
1758
|
+
id: "kimi-k3",
|
|
1759
|
+
name: "Kimi K3",
|
|
1760
|
+
provider: "moonshot",
|
|
1761
|
+
contextWindow: 1048576,
|
|
1762
|
+
// The API can be raised as high as the full context window, but 131K is the
|
|
1763
|
+
// documented default and keeps room for input in AgentSession's fixed cap.
|
|
1764
|
+
maxOutputTokens: 131072,
|
|
1765
|
+
supportsThinking: true,
|
|
1766
|
+
supportsImages: true,
|
|
1767
|
+
supportsVideo: true,
|
|
1768
|
+
maxVideoBytes: 100 * 1024 * 1024,
|
|
1769
|
+
costTier: "high",
|
|
1770
|
+
maxThinkingLevel: "max"
|
|
1771
|
+
},
|
|
1772
|
+
// Retain the cheaper dedicated coding model as an explicit alternative.
|
|
1694
1773
|
{
|
|
1695
1774
|
id: "kimi-k2.7-code",
|
|
1696
|
-
name: "Kimi K2.7",
|
|
1775
|
+
name: "Kimi K2.7 Code",
|
|
1697
1776
|
provider: "moonshot",
|
|
1698
1777
|
contextWindow: 262144,
|
|
1699
1778
|
maxOutputTokens: 262144,
|
|
@@ -1883,16 +1962,20 @@ function getDefaultModel(provider) {
|
|
|
1883
1962
|
if (provider === "openai") return MODELS.find((m) => m.id === "gpt-5.6-sol");
|
|
1884
1963
|
if (provider === "gemini") return MODELS.find((m) => m.id === "gemini-3.1-flash-lite");
|
|
1885
1964
|
if (provider === "glm") return MODELS.find((m) => m.id === "glm-5.2");
|
|
1886
|
-
if (provider === "moonshot") return MODELS.find((m) => m.id === "kimi-
|
|
1965
|
+
if (provider === "moonshot") return MODELS.find((m) => m.id === "kimi-k3");
|
|
1887
1966
|
if (provider === "minimax") return MODELS.find((m) => m.id === "MiniMax-M3");
|
|
1888
1967
|
if (provider === "deepseek") return MODELS.find((m) => m.id === "deepseek-v4-pro");
|
|
1889
1968
|
if (provider === "openrouter") return MODELS.find((m) => m.id === "qwen/qwen3.6-plus");
|
|
1890
1969
|
if (provider === "sakana") return MODELS.find((m) => m.id === "fugu");
|
|
1970
|
+
if (provider === "xai") return MODELS.find((m) => m.id === "grok-4.5");
|
|
1891
1971
|
return MODELS.find((m) => m.id === "claude-sonnet-5");
|
|
1892
1972
|
}
|
|
1893
1973
|
function usesOpenAICodexTransport(options) {
|
|
1894
1974
|
return options?.provider === "openai" && Boolean(options.accountId);
|
|
1895
1975
|
}
|
|
1976
|
+
function getToolResultCharLimit(_modelId, options) {
|
|
1977
|
+
return usesOpenAICodexTransport(options) ? 1e4 * 4 : void 0;
|
|
1978
|
+
}
|
|
1896
1979
|
function getContextWindow(modelId, options) {
|
|
1897
1980
|
const model = getModel(modelId);
|
|
1898
1981
|
if (!model) return 2e5;
|
|
@@ -1930,6 +2013,7 @@ var OPENAI_GPT_56_THINKING_LEVELS = [
|
|
|
1930
2013
|
"ultra"
|
|
1931
2014
|
];
|
|
1932
2015
|
var SAKANA_THINKING_LEVELS = ["high", "xhigh"];
|
|
2016
|
+
var XAI_THINKING_LEVELS = ["low", "medium", "high"];
|
|
1933
2017
|
var ANTHROPIC_OPUS_48_47_THINKING_LEVELS = [
|
|
1934
2018
|
"low",
|
|
1935
2019
|
"medium",
|
|
@@ -1949,6 +2033,9 @@ function isOpenAIGptModel(provider, model) {
|
|
|
1949
2033
|
function isSakanaModel(provider) {
|
|
1950
2034
|
return provider === "sakana";
|
|
1951
2035
|
}
|
|
2036
|
+
function isXaiModel(provider) {
|
|
2037
|
+
return provider === "xai";
|
|
2038
|
+
}
|
|
1952
2039
|
function isAnthropicOpus48Or47Model(provider, model) {
|
|
1953
2040
|
return provider === "anthropic" && /opus-4-8|opus-4-7/.test(model);
|
|
1954
2041
|
}
|
|
@@ -1968,6 +2055,11 @@ function getSupportedThinkingLevels(provider, model) {
|
|
|
1968
2055
|
if (maxIndex2 === -1) return SAKANA_THINKING_LEVELS;
|
|
1969
2056
|
return SAKANA_THINKING_LEVELS.slice(0, maxIndex2 + 1);
|
|
1970
2057
|
}
|
|
2058
|
+
if (isXaiModel(provider)) {
|
|
2059
|
+
const maxIndex2 = XAI_THINKING_LEVELS.indexOf(maxLevel);
|
|
2060
|
+
if (maxIndex2 === -1) return XAI_THINKING_LEVELS;
|
|
2061
|
+
return XAI_THINKING_LEVELS.slice(0, maxIndex2 + 1);
|
|
2062
|
+
}
|
|
1971
2063
|
if (!isOpenAIGptModel(provider, model)) return [maxLevel];
|
|
1972
2064
|
const levels = model.startsWith("gpt-5.6-") ? OPENAI_GPT_56_THINKING_LEVELS : OPENAI_GPT_THINKING_LEVELS;
|
|
1973
2065
|
const maxIndex = levels.indexOf(maxLevel);
|
|
@@ -1979,7 +2071,7 @@ function isThinkingLevelSupported(provider, model, level) {
|
|
|
1979
2071
|
}
|
|
1980
2072
|
function getNextThinkingLevel(provider, model, current) {
|
|
1981
2073
|
const supportedLevels = getSupportedThinkingLevels(provider, model);
|
|
1982
|
-
const shouldCycleLevels = isOpenAIGptModel(provider, model) || isAnthropicAdaptiveModel(provider, model) || isSakanaModel(provider);
|
|
2074
|
+
const shouldCycleLevels = isOpenAIGptModel(provider, model) || isAnthropicAdaptiveModel(provider, model) || isSakanaModel(provider) || isXaiModel(provider);
|
|
1983
2075
|
if (!shouldCycleLevels) {
|
|
1984
2076
|
return current ? void 0 : supportedLevels[0];
|
|
1985
2077
|
}
|
|
@@ -2640,6 +2732,7 @@ function createAutoUpdater(config) {
|
|
|
2640
2732
|
getSessionId,
|
|
2641
2733
|
getSummaryModel,
|
|
2642
2734
|
getSupportedThinkingLevels,
|
|
2735
|
+
getToolResultCharLimit,
|
|
2643
2736
|
getVideoByteLimit,
|
|
2644
2737
|
isKimiCodingEndpoint,
|
|
2645
2738
|
isLoggerOpen,
|