@kenkaiiii/gg-core 5.17.0 → 5.19.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-YP4GA3HW.js → chunk-6PHNOYJZ.js} +89 -6
- package/dist/chunk-6PHNOYJZ.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-YP4GA3HW.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
|
}
|
|
@@ -1343,6 +1348,30 @@ var AuthStorage = class {
|
|
|
1343
1348
|
delete this.data[provider];
|
|
1344
1349
|
await this.save();
|
|
1345
1350
|
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Mark the credential stored under `storageKey` as usage-exhausted until
|
|
1353
|
+
* `resetsAt` (unix SECONDS, from the provider's rate-limit response) or a
|
|
1354
|
+
* 15-minute default when no reset time is known. While the mark is in the
|
|
1355
|
+
* future, `resolveCredentials("moonshot")` serves the Moonshot API key
|
|
1356
|
+
* instead of the Kimi OAuth credential (when both are configured) — OAuth
|
|
1357
|
+
* stays the preferred credential and is retried automatically once the mark
|
|
1358
|
+
* lapses. Persisted to auth.json so a restart (or another gg-app window)
|
|
1359
|
+
* doesn't burn a request rediscovering the same exhausted window. No-op if
|
|
1360
|
+
* nothing is stored under `storageKey`.
|
|
1361
|
+
*/
|
|
1362
|
+
async markUsageExhausted(storageKey, resetsAt) {
|
|
1363
|
+
await this.ensureLoaded();
|
|
1364
|
+
const creds = this.data[storageKey];
|
|
1365
|
+
if (!creds) return;
|
|
1366
|
+
const until = resetsAt !== void 0 && resetsAt * 1e3 > Date.now() ? resetsAt * 1e3 : Date.now() + USAGE_EXHAUSTED_DEFAULT_MS;
|
|
1367
|
+
creds.usageExhaustedUntil = until;
|
|
1368
|
+
await this.save();
|
|
1369
|
+
log(
|
|
1370
|
+
"WARN",
|
|
1371
|
+
"auth",
|
|
1372
|
+
`Marked ${storageKey} usage-exhausted until ${new Date(until).toISOString()}`
|
|
1373
|
+
);
|
|
1374
|
+
}
|
|
1346
1375
|
async clearAll() {
|
|
1347
1376
|
this.data = {};
|
|
1348
1377
|
await this.save();
|
|
@@ -1363,8 +1392,19 @@ var AuthStorage = class {
|
|
|
1363
1392
|
throw new NotLoggedInError(provider);
|
|
1364
1393
|
}
|
|
1365
1394
|
if (provider === "moonshot" && this.data[MOONSHOT_OAUTH_KEY]) {
|
|
1395
|
+
const exhaustedUntil = this.data[MOONSHOT_OAUTH_KEY].usageExhaustedUntil ?? 0;
|
|
1396
|
+
if (Date.now() < exhaustedUntil && this.data["moonshot"]) {
|
|
1397
|
+
log(
|
|
1398
|
+
"WARN",
|
|
1399
|
+
"auth",
|
|
1400
|
+
`Kimi OAuth usage window is exhausted \u2014 using the Moonshot API key until ${new Date(exhaustedUntil).toISOString()} (OAuth resumes automatically).`
|
|
1401
|
+
);
|
|
1402
|
+
return this.data["moonshot"];
|
|
1403
|
+
}
|
|
1366
1404
|
try {
|
|
1367
|
-
return await this.resolveCredentials(MOONSHOT_OAUTH_KEY,
|
|
1405
|
+
return await this.resolveCredentials(MOONSHOT_OAUTH_KEY, {
|
|
1406
|
+
...opts?.forceRefresh ? { forceRefresh: true } : {}
|
|
1407
|
+
});
|
|
1368
1408
|
} catch (err) {
|
|
1369
1409
|
if (err instanceof NotLoggedInError && this.data["moonshot"]) {
|
|
1370
1410
|
log(
|
|
@@ -1633,6 +1673,26 @@ var MODELS = [
|
|
|
1633
1673
|
costTier: "high",
|
|
1634
1674
|
maxThinkingLevel: "xhigh"
|
|
1635
1675
|
},
|
|
1676
|
+
// ── xAI (Grok) ─────────────────────────────────────────
|
|
1677
|
+
// Grok 4.5 (released 2026-07-08) is xAI's flagship for coding, agentic
|
|
1678
|
+
// tasks, and knowledge work — 500K context, text+image input, configurable
|
|
1679
|
+
// `reasoning_effort` (low/medium/high, server default high; reasoning can't
|
|
1680
|
+
// be fully disabled). Served over the OpenAI-compatible API at
|
|
1681
|
+
// https://api.x.ai/v1 (API key from console.x.ai). xAI hasn't published an
|
|
1682
|
+
// official max-output cap for 4.5; 131K matches the Grok Responses ceiling
|
|
1683
|
+
// third-party integrations use.
|
|
1684
|
+
{
|
|
1685
|
+
id: "grok-4.5",
|
|
1686
|
+
name: "Grok 4.5",
|
|
1687
|
+
provider: "xai",
|
|
1688
|
+
contextWindow: 5e5,
|
|
1689
|
+
maxOutputTokens: 131072,
|
|
1690
|
+
supportsThinking: true,
|
|
1691
|
+
supportsImages: true,
|
|
1692
|
+
supportsVideo: false,
|
|
1693
|
+
costTier: "medium",
|
|
1694
|
+
maxThinkingLevel: "high"
|
|
1695
|
+
},
|
|
1636
1696
|
// ── Gemini ─────────────────────────────────────────────
|
|
1637
1697
|
{
|
|
1638
1698
|
id: "gemini-3.1-flash-lite",
|
|
@@ -1680,9 +1740,28 @@ var MODELS = [
|
|
|
1680
1740
|
maxThinkingLevel: "high"
|
|
1681
1741
|
},
|
|
1682
1742
|
// ── Moonshot (Kimi) ────────────────────────────────────
|
|
1743
|
+
// K3 is Kimi's 2.8T-parameter flagship for long-horizon coding, knowledge
|
|
1744
|
+
// work, and deep reasoning. It always reasons at the `max` effort; the public
|
|
1745
|
+
// API uses `reasoning_effort`, while Kimi Code OAuth keeps its managed wire shape.
|
|
1746
|
+
{
|
|
1747
|
+
id: "kimi-k3",
|
|
1748
|
+
name: "Kimi K3",
|
|
1749
|
+
provider: "moonshot",
|
|
1750
|
+
contextWindow: 1048576,
|
|
1751
|
+
// The API can be raised as high as the full context window, but 131K is the
|
|
1752
|
+
// documented default and keeps room for input in AgentSession's fixed cap.
|
|
1753
|
+
maxOutputTokens: 131072,
|
|
1754
|
+
supportsThinking: true,
|
|
1755
|
+
supportsImages: true,
|
|
1756
|
+
supportsVideo: true,
|
|
1757
|
+
maxVideoBytes: 100 * 1024 * 1024,
|
|
1758
|
+
costTier: "high",
|
|
1759
|
+
maxThinkingLevel: "max"
|
|
1760
|
+
},
|
|
1761
|
+
// Retain the cheaper dedicated coding model as an explicit alternative.
|
|
1683
1762
|
{
|
|
1684
1763
|
id: "kimi-k2.7-code",
|
|
1685
|
-
name: "Kimi K2.7",
|
|
1764
|
+
name: "Kimi K2.7 Code",
|
|
1686
1765
|
provider: "moonshot",
|
|
1687
1766
|
contextWindow: 262144,
|
|
1688
1767
|
maxOutputTokens: 262144,
|
|
@@ -1872,16 +1951,20 @@ function getDefaultModel(provider) {
|
|
|
1872
1951
|
if (provider === "openai") return MODELS.find((m) => m.id === "gpt-5.6-sol");
|
|
1873
1952
|
if (provider === "gemini") return MODELS.find((m) => m.id === "gemini-3.1-flash-lite");
|
|
1874
1953
|
if (provider === "glm") return MODELS.find((m) => m.id === "glm-5.2");
|
|
1875
|
-
if (provider === "moonshot") return MODELS.find((m) => m.id === "kimi-
|
|
1954
|
+
if (provider === "moonshot") return MODELS.find((m) => m.id === "kimi-k3");
|
|
1876
1955
|
if (provider === "minimax") return MODELS.find((m) => m.id === "MiniMax-M3");
|
|
1877
1956
|
if (provider === "deepseek") return MODELS.find((m) => m.id === "deepseek-v4-pro");
|
|
1878
1957
|
if (provider === "openrouter") return MODELS.find((m) => m.id === "qwen/qwen3.6-plus");
|
|
1879
1958
|
if (provider === "sakana") return MODELS.find((m) => m.id === "fugu");
|
|
1959
|
+
if (provider === "xai") return MODELS.find((m) => m.id === "grok-4.5");
|
|
1880
1960
|
return MODELS.find((m) => m.id === "claude-sonnet-5");
|
|
1881
1961
|
}
|
|
1882
1962
|
function usesOpenAICodexTransport(options) {
|
|
1883
1963
|
return options?.provider === "openai" && Boolean(options.accountId);
|
|
1884
1964
|
}
|
|
1965
|
+
function getToolResultCharLimit(_modelId, options) {
|
|
1966
|
+
return usesOpenAICodexTransport(options) ? 1e4 * 4 : void 0;
|
|
1967
|
+
}
|
|
1885
1968
|
function getContextWindow(modelId, options) {
|
|
1886
1969
|
const model = getModel(modelId);
|
|
1887
1970
|
if (!model) return 2e5;
|
|
@@ -1919,6 +2002,7 @@ var OPENAI_GPT_56_THINKING_LEVELS = [
|
|
|
1919
2002
|
"ultra"
|
|
1920
2003
|
];
|
|
1921
2004
|
var SAKANA_THINKING_LEVELS = ["high", "xhigh"];
|
|
2005
|
+
var XAI_THINKING_LEVELS = ["low", "medium", "high"];
|
|
1922
2006
|
var ANTHROPIC_OPUS_48_47_THINKING_LEVELS = [
|
|
1923
2007
|
"low",
|
|
1924
2008
|
"medium",
|
|
@@ -1938,6 +2022,9 @@ function isOpenAIGptModel(provider, model) {
|
|
|
1938
2022
|
function isSakanaModel(provider) {
|
|
1939
2023
|
return provider === "sakana";
|
|
1940
2024
|
}
|
|
2025
|
+
function isXaiModel(provider) {
|
|
2026
|
+
return provider === "xai";
|
|
2027
|
+
}
|
|
1941
2028
|
function isAnthropicOpus48Or47Model(provider, model) {
|
|
1942
2029
|
return provider === "anthropic" && /opus-4-8|opus-4-7/.test(model);
|
|
1943
2030
|
}
|
|
@@ -1957,6 +2044,11 @@ function getSupportedThinkingLevels(provider, model) {
|
|
|
1957
2044
|
if (maxIndex2 === -1) return SAKANA_THINKING_LEVELS;
|
|
1958
2045
|
return SAKANA_THINKING_LEVELS.slice(0, maxIndex2 + 1);
|
|
1959
2046
|
}
|
|
2047
|
+
if (isXaiModel(provider)) {
|
|
2048
|
+
const maxIndex2 = XAI_THINKING_LEVELS.indexOf(maxLevel);
|
|
2049
|
+
if (maxIndex2 === -1) return XAI_THINKING_LEVELS;
|
|
2050
|
+
return XAI_THINKING_LEVELS.slice(0, maxIndex2 + 1);
|
|
2051
|
+
}
|
|
1960
2052
|
if (!isOpenAIGptModel(provider, model)) return [maxLevel];
|
|
1961
2053
|
const levels = model.startsWith("gpt-5.6-") ? OPENAI_GPT_56_THINKING_LEVELS : OPENAI_GPT_THINKING_LEVELS;
|
|
1962
2054
|
const maxIndex = levels.indexOf(maxLevel);
|
|
@@ -1968,7 +2060,7 @@ function isThinkingLevelSupported(provider, model, level) {
|
|
|
1968
2060
|
}
|
|
1969
2061
|
function getNextThinkingLevel(provider, model, current) {
|
|
1970
2062
|
const supportedLevels = getSupportedThinkingLevels(provider, model);
|
|
1971
|
-
const shouldCycleLevels = isOpenAIGptModel(provider, model) || isAnthropicAdaptiveModel(provider, model) || isSakanaModel(provider);
|
|
2063
|
+
const shouldCycleLevels = isOpenAIGptModel(provider, model) || isAnthropicAdaptiveModel(provider, model) || isSakanaModel(provider) || isXaiModel(provider);
|
|
1972
2064
|
if (!shouldCycleLevels) {
|
|
1973
2065
|
return current ? void 0 : supportedLevels[0];
|
|
1974
2066
|
}
|
|
@@ -2629,6 +2721,7 @@ function createAutoUpdater(config) {
|
|
|
2629
2721
|
getSessionId,
|
|
2630
2722
|
getSummaryModel,
|
|
2631
2723
|
getSupportedThinkingLevels,
|
|
2724
|
+
getToolResultCharLimit,
|
|
2632
2725
|
getVideoByteLimit,
|
|
2633
2726
|
isKimiCodingEndpoint,
|
|
2634
2727
|
isLoggerOpen,
|