@prestyj/core 5.28.1 → 5.29.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-CK6UIITE.js → chunk-N73LFQ3N.js} +39 -25
- package/dist/chunk-N73LFQ3N.js.map +1 -0
- package/dist/index.cjs +70 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +35 -12
- package/dist/index.js.map +1 -1
- package/dist/model-registry.cjs +11 -17
- package/dist/model-registry.cjs.map +1 -1
- package/dist/model-registry.d.cts +11 -19
- package/dist/model-registry.d.ts +11 -19
- package/dist/model-registry.js +1 -3
- package/package.json +2 -2
- package/dist/chunk-CK6UIITE.js.map +0 -1
|
@@ -8,6 +8,14 @@ import { randomUUID } from "crypto";
|
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
9
9
|
import { arch, hostname, release, type } from "os";
|
|
10
10
|
import path from "path";
|
|
11
|
+
|
|
12
|
+
// src/oauth/request-timeout.ts
|
|
13
|
+
var OAUTH_REQUEST_TIMEOUT_MS = 3e4;
|
|
14
|
+
function oauthRequestSignal() {
|
|
15
|
+
return AbortSignal.timeout(OAUTH_REQUEST_TIMEOUT_MS);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/oauth/kimi.ts
|
|
11
19
|
var CLIENT_ID = "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
12
20
|
var DEFAULT_OAUTH_HOST = "https://auth.kimi.com";
|
|
13
21
|
var DEFAULT_CODING_BASE_URL = "https://api.kimi.com/coding/v1";
|
|
@@ -94,7 +102,8 @@ async function postForm(endpoint, params) {
|
|
|
94
102
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
95
103
|
Accept: "application/json"
|
|
96
104
|
},
|
|
97
|
-
body: new URLSearchParams(params).toString()
|
|
105
|
+
body: new URLSearchParams(params).toString(),
|
|
106
|
+
signal: oauthRequestSignal()
|
|
98
107
|
});
|
|
99
108
|
let data = {};
|
|
100
109
|
try {
|
|
@@ -568,7 +577,12 @@ async function postTokenRequest(body, label) {
|
|
|
568
577
|
for (const url of TOKEN_URLS) {
|
|
569
578
|
let response;
|
|
570
579
|
try {
|
|
571
|
-
response = await fetch(url, {
|
|
580
|
+
response = await fetch(url, {
|
|
581
|
+
method: "POST",
|
|
582
|
+
headers,
|
|
583
|
+
body: encoded,
|
|
584
|
+
signal: oauthRequestSignal()
|
|
585
|
+
});
|
|
572
586
|
} catch (err) {
|
|
573
587
|
lastError = err instanceof Error ? err : new Error(String(err));
|
|
574
588
|
continue;
|
|
@@ -817,7 +831,8 @@ async function exchangeOpenAICode(code, verifier) {
|
|
|
817
831
|
code,
|
|
818
832
|
redirect_uri: REDIRECT_URI2,
|
|
819
833
|
code_verifier: verifier
|
|
820
|
-
})
|
|
834
|
+
}),
|
|
835
|
+
signal: oauthRequestSignal()
|
|
821
836
|
});
|
|
822
837
|
if (!response.ok) {
|
|
823
838
|
const text = await response.text();
|
|
@@ -838,7 +853,8 @@ async function refreshOpenAIToken(refreshToken) {
|
|
|
838
853
|
grant_type: "refresh_token",
|
|
839
854
|
refresh_token: refreshToken,
|
|
840
855
|
client_id: CLIENT_ID3
|
|
841
|
-
})
|
|
856
|
+
}),
|
|
857
|
+
signal: oauthRequestSignal()
|
|
842
858
|
});
|
|
843
859
|
if (!response.ok) {
|
|
844
860
|
const text = await response.text();
|
|
@@ -1048,7 +1064,8 @@ async function postTokenRequest2(body) {
|
|
|
1048
1064
|
const response = await fetch(TOKEN_URL2, {
|
|
1049
1065
|
method: "POST",
|
|
1050
1066
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1051
|
-
body: new URLSearchParams(body)
|
|
1067
|
+
body: new URLSearchParams(body),
|
|
1068
|
+
signal: oauthRequestSignal()
|
|
1052
1069
|
});
|
|
1053
1070
|
if (!response.ok) {
|
|
1054
1071
|
const text = await response.text();
|
|
@@ -1177,7 +1194,8 @@ async function codeAssistGet(accessToken, operationName) {
|
|
|
1177
1194
|
async function codeAssistRequest(url, accessToken, label, init) {
|
|
1178
1195
|
const response = await fetch(url, {
|
|
1179
1196
|
...init,
|
|
1180
|
-
headers: codeAssistHeaders(accessToken)
|
|
1197
|
+
headers: codeAssistHeaders(accessToken),
|
|
1198
|
+
signal: oauthRequestSignal()
|
|
1181
1199
|
});
|
|
1182
1200
|
if (!response.ok) {
|
|
1183
1201
|
const text = await response.text();
|
|
@@ -1263,7 +1281,8 @@ async function postForm2(endpoint, params) {
|
|
|
1263
1281
|
Accept: "application/json",
|
|
1264
1282
|
"User-Agent": `grok-cli/${grokCliVersion()}`
|
|
1265
1283
|
},
|
|
1266
|
-
body: new URLSearchParams(params).toString()
|
|
1284
|
+
body: new URLSearchParams(params).toString(),
|
|
1285
|
+
signal: oauthRequestSignal()
|
|
1267
1286
|
});
|
|
1268
1287
|
let data = {};
|
|
1269
1288
|
try {
|
|
@@ -2285,9 +2304,7 @@ var MODELS = [
|
|
|
2285
2304
|
// Sent over our Code Assist (OAuth) transport ahead of gemini-cli — upstream
|
|
2286
2305
|
// hasn't listed 3.7 yet (google-gemini/gemini-cli#28802, still open) — so
|
|
2287
2306
|
// free/personal accounts 404 (entitlement-gated) while Code Assist
|
|
2288
|
-
// Standard/Enterprise accounts get it.
|
|
2289
|
-
// getFastModel picks the first low-tier entry, and flash-lite is the one
|
|
2290
|
-
// that works on every account.
|
|
2307
|
+
// Standard/Enterprise accounts get it.
|
|
2291
2308
|
id: "gemini-3.7-flash",
|
|
2292
2309
|
name: "Gemini 3.7 Flash",
|
|
2293
2310
|
provider: "gemini",
|
|
@@ -2698,19 +2715,17 @@ function getDefaultThinkingLevel(modelId, options) {
|
|
|
2698
2715
|
if (model?.id === "kimi-k3" && isKimiCodingEndpoint(options?.baseUrl)) return "high";
|
|
2699
2716
|
return model?.defaultThinkingLevel ?? model?.maxThinkingLevel ?? "high";
|
|
2700
2717
|
}
|
|
2718
|
+
var SUMMARY_COST_TIER = {
|
|
2719
|
+
anthropic: "medium",
|
|
2720
|
+
openai: "low",
|
|
2721
|
+
glm: "low",
|
|
2722
|
+
deepseek: "low",
|
|
2723
|
+
huggingface: "low"
|
|
2724
|
+
};
|
|
2701
2725
|
function getSummaryModel(provider, currentModelId) {
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
if (provider === "openai" || provider === "glm" || provider === "deepseek" || provider === "huggingface") {
|
|
2706
|
-
const low = getModelsForProvider(provider).find((m) => m.costTier === "low");
|
|
2707
|
-
if (low) return low;
|
|
2708
|
-
}
|
|
2709
|
-
return getModel(currentModelId) ?? getDefaultModel(provider);
|
|
2710
|
-
}
|
|
2711
|
-
function getFastModel(provider, currentModelId) {
|
|
2712
|
-
const low = getModelsForProvider(provider).find((m) => m.costTier === "low");
|
|
2713
|
-
return low ?? getModel(currentModelId) ?? getDefaultModel(provider);
|
|
2726
|
+
const tier = SUMMARY_COST_TIER[provider];
|
|
2727
|
+
const tagged = tier ? getModelsForProvider(provider).find((m) => m.costTier === tier) : void 0;
|
|
2728
|
+
return tagged ?? getModel(currentModelId) ?? getDefaultModel(provider);
|
|
2714
2729
|
}
|
|
2715
2730
|
|
|
2716
2731
|
export {
|
|
@@ -2769,7 +2784,6 @@ export {
|
|
|
2769
2784
|
getContextWindow,
|
|
2770
2785
|
getMaxThinkingLevel,
|
|
2771
2786
|
getDefaultThinkingLevel,
|
|
2772
|
-
getSummaryModel
|
|
2773
|
-
getFastModel
|
|
2787
|
+
getSummaryModel
|
|
2774
2788
|
};
|
|
2775
|
-
//# sourceMappingURL=chunk-
|
|
2789
|
+
//# sourceMappingURL=chunk-N73LFQ3N.js.map
|