@kenkaiiii/gg-core 5.106.0 → 5.107.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-757P7L4T.js → chunk-T367MVTP.js} +52 -20
- package/dist/chunk-T367MVTP.js.map +1 -0
- package/dist/index.cjs +53 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/model-registry.cjs +5 -6
- package/dist/model-registry.cjs.map +1 -1
- package/dist/model-registry.d.cts +5 -7
- package/dist/model-registry.d.ts +5 -7
- package/dist/model-registry.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-757P7L4T.js.map +0 -1
|
@@ -654,21 +654,48 @@ async function getChatGPTHostId(file = defaultHostIdFile()) {
|
|
|
654
654
|
await writePrivateFile(file, `urn:uuid:${crypto3.randomUUID()}`);
|
|
655
655
|
return (await fs3.readFile(file, "utf-8")).trim();
|
|
656
656
|
}
|
|
657
|
-
|
|
657
|
+
function asRegistration(value) {
|
|
658
|
+
const v = value;
|
|
659
|
+
if (!v || typeof v.clientId !== "string" || typeof v.subject !== "string") return void 0;
|
|
660
|
+
return {
|
|
661
|
+
clientId: v.clientId,
|
|
662
|
+
subject: v.subject,
|
|
663
|
+
...typeof v.email === "string" && v.email ? { email: v.email } : {},
|
|
664
|
+
...typeof v.usedAt === "number" ? { usedAt: v.usedAt } : {}
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
async function readRegistrations(file) {
|
|
658
668
|
try {
|
|
659
669
|
const value = JSON.parse(await fs3.readFile(file, "utf-8"));
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
}
|
|
670
|
+
const list = Array.isArray(value.registrations) ? value.registrations.map(asRegistration) : [asRegistration(value)];
|
|
671
|
+
return list.filter((r) => r !== void 0).sort((a, b) => (b.usedAt ?? 0) - (a.usedAt ?? 0));
|
|
663
672
|
} catch {
|
|
673
|
+
return [];
|
|
664
674
|
}
|
|
665
|
-
|
|
675
|
+
}
|
|
676
|
+
async function writeRegistrations(file, list) {
|
|
677
|
+
if (list.length === 0) {
|
|
678
|
+
await fs3.unlink(file).catch(() => {
|
|
679
|
+
});
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
await writePrivateFile(file, JSON.stringify({ registrations: list }));
|
|
683
|
+
}
|
|
684
|
+
async function savedChatGPTAccounts(file = defaultRegistrationFile()) {
|
|
685
|
+
return (await readRegistrations(file)).map((r) => r.email ?? "a ChatGPT account");
|
|
686
|
+
}
|
|
687
|
+
function chooseRegistration(saved, options) {
|
|
688
|
+
if (options.newAccount) return { current: false };
|
|
689
|
+
const own = options.previous?.clientId ? saved.find((r) => r.clientId === options.previous?.clientId) : void 0;
|
|
690
|
+
if (own) return { registration: own, current: true };
|
|
691
|
+
return { registration: saved[0], current: false };
|
|
666
692
|
}
|
|
667
693
|
async function loginChatGPT(callbacks, options = {}) {
|
|
668
694
|
const { signal } = options;
|
|
669
695
|
const hostId = await getChatGPTHostId(options.hostIdFile);
|
|
670
696
|
const registrationFile = options.registrationFile ?? defaultRegistrationFile();
|
|
671
|
-
const
|
|
697
|
+
const saved = await readRegistrations(registrationFile);
|
|
698
|
+
const { registration, current } = chooseRegistration(saved, options);
|
|
672
699
|
let issuedClientId;
|
|
673
700
|
const signIn = async (status) => {
|
|
674
701
|
if (signal?.aborted) throw cancelled();
|
|
@@ -683,9 +710,10 @@ async function loginChatGPT(callbacks, options = {}) {
|
|
|
683
710
|
url.searchParams.set("client_id", knownClientId ?? REGISTRATION_CLIENT_ID);
|
|
684
711
|
if (!knownClientId) url.searchParams.set("agent_name_hint", AGENT_NAME);
|
|
685
712
|
url.searchParams.set("ext_agent_host_id", hostId);
|
|
686
|
-
if (registration && options.previous?.idToken) {
|
|
713
|
+
if (registration && current && options.previous?.idToken) {
|
|
687
714
|
url.searchParams.set("id_token_hint", options.previous.idToken);
|
|
688
715
|
}
|
|
716
|
+
if (registration?.email) url.searchParams.set("login_hint", registration.email);
|
|
689
717
|
url.searchParams.set("response_type", "code");
|
|
690
718
|
url.searchParams.set("redirect_uri", redirectUri);
|
|
691
719
|
url.searchParams.set("scope", SCOPES);
|
|
@@ -731,20 +759,24 @@ async function loginChatGPT(callbacks, options = {}) {
|
|
|
731
759
|
const subject = String(claims.sub ?? "");
|
|
732
760
|
if (!subject) throw new Error("ChatGPT ID token has no subject.");
|
|
733
761
|
if (registration && registration.subject !== subject) {
|
|
734
|
-
await
|
|
735
|
-
|
|
762
|
+
await writeRegistrations(
|
|
763
|
+
registrationFile,
|
|
764
|
+
saved.filter((r) => r.clientId !== registration.clientId)
|
|
765
|
+
);
|
|
736
766
|
await revokeChatGPTSignIn({ refreshToken: tokens.refreshToken, clientId });
|
|
737
767
|
throw new Error(
|
|
738
|
-
"That was a different ChatGPT account.
|
|
768
|
+
"That was a different ChatGPT account. Choose Use a different account or workspace to connect it."
|
|
739
769
|
);
|
|
740
770
|
}
|
|
741
771
|
if (!tokens.scopes.includes(CHATGPT_PLAN_SCOPE)) {
|
|
742
772
|
await revokeChatGPTSignIn({ refreshToken: tokens.refreshToken, clientId });
|
|
743
773
|
throw new ChatGPTPlanNotEnabledError();
|
|
744
774
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
775
|
+
const email = typeof claims.email === "string" ? claims.email : void 0;
|
|
776
|
+
await writeRegistrations(registrationFile, [
|
|
777
|
+
{ clientId, subject, ...email ? { email } : {}, usedAt: Date.now() },
|
|
778
|
+
...saved.filter((r) => r.clientId !== clientId)
|
|
779
|
+
]);
|
|
748
780
|
return {
|
|
749
781
|
accessToken: tokens.accessToken,
|
|
750
782
|
refreshToken: tokens.refreshToken,
|
|
@@ -2145,8 +2177,8 @@ var CLAUDE_FABLE_FAST_BILLING = {
|
|
|
2145
2177
|
standardModel: "claude-fable-5-2"
|
|
2146
2178
|
};
|
|
2147
2179
|
var XIAOMI_ULTRASPEED_BILLING = {
|
|
2148
|
-
label: "
|
|
2149
|
-
detail: "UltraSpeed
|
|
2180
|
+
label: "10x credits",
|
|
2181
|
+
detail: "UltraSpeed uses your Token Plan credits at 10x MiMo-V2.6-Pro's rate (Pro and Max plans only), or bills your API Credits per token at a higher rate.",
|
|
2150
2182
|
paid: true,
|
|
2151
2183
|
standardModel: "mimo-v2.6-pro"
|
|
2152
2184
|
};
|
|
@@ -2857,9 +2889,8 @@ var MODELS = [
|
|
|
2857
2889
|
authStorageKeys: ["xiaomi", XIAOMI_CREDITS_KEY]
|
|
2858
2890
|
},
|
|
2859
2891
|
// UltraSpeed: lower-latency sibling of the Pro flagship, same full-modal
|
|
2860
|
-
// capability surface, premium-priced for the throughput gain.
|
|
2861
|
-
//
|
|
2862
|
-
// distinct API Credits key only (see authStorageKeys doc).
|
|
2892
|
+
// capability surface, premium-priced for the throughput gain. On the Token
|
|
2893
|
+
// Plan (Pro and Max tiers) since 2026-11 at 10x Pro's credit rate.
|
|
2863
2894
|
{
|
|
2864
2895
|
id: "mimo-v2.6-pro-ultraspeed",
|
|
2865
2896
|
name: "MiMo-V2.6-Pro-UltraSpeed",
|
|
@@ -2872,7 +2903,7 @@ var MODELS = [
|
|
|
2872
2903
|
maxVideoBytes: 36 * 1024 * 1024,
|
|
2873
2904
|
costTier: "high",
|
|
2874
2905
|
maxThinkingLevel: "high",
|
|
2875
|
-
authStorageKeys: [XIAOMI_CREDITS_KEY],
|
|
2906
|
+
authStorageKeys: ["xiaomi", XIAOMI_CREDITS_KEY],
|
|
2876
2907
|
billing: XIAOMI_ULTRASPEED_BILLING
|
|
2877
2908
|
},
|
|
2878
2909
|
// ── DeepSeek ───────────────────────────────────────────
|
|
@@ -3270,6 +3301,7 @@ export {
|
|
|
3270
3301
|
ChatGPTPlanNotEnabledError,
|
|
3271
3302
|
ChatGPTSignInError,
|
|
3272
3303
|
getChatGPTHostId,
|
|
3304
|
+
savedChatGPTAccounts,
|
|
3273
3305
|
loginChatGPT,
|
|
3274
3306
|
fetchChatGPTPlanModels,
|
|
3275
3307
|
parseCallbackInput,
|
|
@@ -3329,4 +3361,4 @@ export {
|
|
|
3329
3361
|
getDefaultThinkingLevel,
|
|
3330
3362
|
getSummaryModel
|
|
3331
3363
|
};
|
|
3332
|
-
//# sourceMappingURL=chunk-
|
|
3364
|
+
//# sourceMappingURL=chunk-T367MVTP.js.map
|