@yitom/acp-client 0.1.5 → 0.1.7
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/contracts/quota.d.ts +2 -0
- package/dist/index.cjs +682 -18
- package/dist/index.js +688 -47
- package/dist/runtimes/agy/quota.d.ts +8 -0
- package/dist/runtimes/opencode/quota.d.ts +1 -1
- package/dist/sidecar.cjs +656 -18
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,6 +7,30 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
5
7
|
function __accessProp(key) {
|
|
6
8
|
return this[key];
|
|
7
9
|
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (canCache)
|
|
31
|
+
cache.set(mod, to);
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
8
34
|
var __toCommonJS = (from) => {
|
|
9
35
|
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
36
|
if (entry)
|
|
@@ -337,7 +363,7 @@ function findBuiltinAcpRuntime(id) {
|
|
|
337
363
|
return BUILTIN_ACP_RUNTIMES.find((item) => item.id === id);
|
|
338
364
|
}
|
|
339
365
|
// src/version.ts
|
|
340
|
-
var ACP_CLIENT_VERSION = "0.1.
|
|
366
|
+
var ACP_CLIENT_VERSION = "0.1.7";
|
|
341
367
|
// src/session/available-commands.ts
|
|
342
368
|
function normalizeCommand(raw) {
|
|
343
369
|
if (!raw || typeof raw !== "object")
|
|
@@ -587,6 +613,8 @@ var import_sdk4 = require("@agentclientprotocol/sdk");
|
|
|
587
613
|
// src/runtimes/codex/quota.ts
|
|
588
614
|
var import_node_fs2 = require("node:fs");
|
|
589
615
|
var import_node_path2 = require("node:path");
|
|
616
|
+
var import_node_child_process = require("node:child_process");
|
|
617
|
+
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
590
618
|
|
|
591
619
|
// src/runtimes/codex/codex-auth-preflight.ts
|
|
592
620
|
var import_node_fs = require("node:fs");
|
|
@@ -636,6 +664,102 @@ function decodeJwtPayload(token) {
|
|
|
636
664
|
return null;
|
|
637
665
|
}
|
|
638
666
|
}
|
|
667
|
+
var cachedDynamicResult = null;
|
|
668
|
+
async function queryCodexAppServer(timeoutMs = 1e4) {
|
|
669
|
+
if (cachedDynamicResult && Date.now() - cachedDynamicResult.time < 120000) {
|
|
670
|
+
return cachedDynamicResult.res;
|
|
671
|
+
}
|
|
672
|
+
return new Promise((resolve) => {
|
|
673
|
+
let timer = null;
|
|
674
|
+
let proc = null;
|
|
675
|
+
let finished = false;
|
|
676
|
+
const cleanup = (res) => {
|
|
677
|
+
if (finished)
|
|
678
|
+
return;
|
|
679
|
+
finished = true;
|
|
680
|
+
if (timer)
|
|
681
|
+
clearTimeout(timer);
|
|
682
|
+
if (proc) {
|
|
683
|
+
try {
|
|
684
|
+
proc.kill();
|
|
685
|
+
} catch {}
|
|
686
|
+
}
|
|
687
|
+
if (res) {
|
|
688
|
+
cachedDynamicResult = { res, time: Date.now() };
|
|
689
|
+
}
|
|
690
|
+
resolve(res);
|
|
691
|
+
};
|
|
692
|
+
timer = setTimeout(() => cleanup(null), timeoutMs);
|
|
693
|
+
try {
|
|
694
|
+
const cmd = process.platform === "win32" ? "codex" : import_node_fs2.existsSync("/mnt/c/Users") ? "codex.exe" : "codex";
|
|
695
|
+
proc = import_node_child_process.spawn(cmd, ["app-server"], {
|
|
696
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
697
|
+
shell: process.platform === "win32",
|
|
698
|
+
windowsHide: true
|
|
699
|
+
});
|
|
700
|
+
if (!proc.stdin || !proc.stdout) {
|
|
701
|
+
return cleanup(null);
|
|
702
|
+
}
|
|
703
|
+
const rl = import_node_readline.default.createInterface({ input: proc.stdout });
|
|
704
|
+
let reqSeq = 1;
|
|
705
|
+
const pending = new Map;
|
|
706
|
+
const result = {};
|
|
707
|
+
rl.on("line", (line) => {
|
|
708
|
+
try {
|
|
709
|
+
const data = JSON.parse(line.trim());
|
|
710
|
+
if (data && typeof data.id === "number" && pending.has(data.id)) {
|
|
711
|
+
const cb = pending.get(data.id);
|
|
712
|
+
pending.delete(data.id);
|
|
713
|
+
cb(data.result);
|
|
714
|
+
}
|
|
715
|
+
} catch {}
|
|
716
|
+
});
|
|
717
|
+
proc.on("error", () => cleanup(null));
|
|
718
|
+
proc.on("exit", () => cleanup(Object.keys(result).length > 0 ? result : null));
|
|
719
|
+
const send = (method, params) => {
|
|
720
|
+
const id = reqSeq++;
|
|
721
|
+
const msg = JSON.stringify({ jsonrpc: "2.0", id, method, params }) + `
|
|
722
|
+
`;
|
|
723
|
+
proc.stdin.write(msg);
|
|
724
|
+
return new Promise((res) => {
|
|
725
|
+
pending.set(id, res);
|
|
726
|
+
});
|
|
727
|
+
};
|
|
728
|
+
(async () => {
|
|
729
|
+
try {
|
|
730
|
+
await send("initialize", {
|
|
731
|
+
clientInfo: { name: "acp-client", version: "0.1.6" }
|
|
732
|
+
});
|
|
733
|
+
const acc = await send("account/read", { refreshToken: false });
|
|
734
|
+
if (acc?.account) {
|
|
735
|
+
result.account = acc.account;
|
|
736
|
+
}
|
|
737
|
+
const limits = await send("account/rateLimits/read");
|
|
738
|
+
if (limits?.rateLimits) {
|
|
739
|
+
result.rateLimits = limits.rateLimits;
|
|
740
|
+
}
|
|
741
|
+
cleanup(result);
|
|
742
|
+
} catch {
|
|
743
|
+
cleanup(null);
|
|
744
|
+
}
|
|
745
|
+
})();
|
|
746
|
+
} catch {
|
|
747
|
+
cleanup(null);
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
function formatEpochTime(epochSeconds) {
|
|
752
|
+
if (!epochSeconds)
|
|
753
|
+
return;
|
|
754
|
+
try {
|
|
755
|
+
const d = new Date(epochSeconds * 1000);
|
|
756
|
+
const hours = String(d.getHours()).padStart(2, "0");
|
|
757
|
+
const mins = String(d.getMinutes()).padStart(2, "0");
|
|
758
|
+
return `${hours}:${mins}`;
|
|
759
|
+
} catch {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
639
763
|
async function probeCodexQuota(options) {
|
|
640
764
|
const codexHome = resolveCodexHome();
|
|
641
765
|
const authPath = import_node_path2.join(codexHome, "auth.json");
|
|
@@ -669,6 +793,14 @@ async function probeCodexQuota(options) {
|
|
|
669
793
|
isLoggedIn = true;
|
|
670
794
|
accountPlan = "API Key (Env)";
|
|
671
795
|
}
|
|
796
|
+
const dynamic = await queryCodexAppServer(1e4);
|
|
797
|
+
if (dynamic) {
|
|
798
|
+
isLoggedIn = true;
|
|
799
|
+
if (dynamic.account?.email)
|
|
800
|
+
accountEmail = dynamic.account.email;
|
|
801
|
+
if (dynamic.account?.planType)
|
|
802
|
+
accountPlan = `ChatGPT ${dynamic.account.planType}`;
|
|
803
|
+
}
|
|
672
804
|
if (!isLoggedIn) {
|
|
673
805
|
return {
|
|
674
806
|
runtimeId: "codex-acp",
|
|
@@ -678,14 +810,49 @@ async function probeCodexQuota(options) {
|
|
|
678
810
|
updatedAt: Date.now()
|
|
679
811
|
};
|
|
680
812
|
}
|
|
813
|
+
let primaryWindow;
|
|
814
|
+
let secondaryWindow;
|
|
815
|
+
let credits;
|
|
816
|
+
if (dynamic?.rateLimits) {
|
|
817
|
+
const rl = dynamic.rateLimits;
|
|
818
|
+
if (rl.primary) {
|
|
819
|
+
const used = rl.primary.usedPercent ?? 0;
|
|
820
|
+
primaryWindow = {
|
|
821
|
+
label: "5h limit",
|
|
822
|
+
percentLeft: Math.max(0, Math.min(100, Math.round(100 - used))),
|
|
823
|
+
usedPercent: used,
|
|
824
|
+
windowDurationMins: rl.primary.windowDurationMins || 300,
|
|
825
|
+
resetsAt: formatEpochTime(rl.primary.resetsAt) || (rl.primary.resetsAt ? String(rl.primary.resetsAt) : undefined)
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
if (rl.secondary) {
|
|
829
|
+
const used = rl.secondary.usedPercent ?? 0;
|
|
830
|
+
secondaryWindow = {
|
|
831
|
+
label: "Weekly limit",
|
|
832
|
+
percentLeft: Math.max(0, Math.min(100, Math.round(100 - used))),
|
|
833
|
+
usedPercent: used,
|
|
834
|
+
windowDurationMins: rl.secondary.windowDurationMins || 10080,
|
|
835
|
+
resetsAt: formatEpochTime(rl.secondary.resetsAt) || (rl.secondary.resetsAt ? String(rl.secondary.resetsAt) : undefined)
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
if (rl.credits) {
|
|
839
|
+
credits = {
|
|
840
|
+
balance: rl.credits.balance,
|
|
841
|
+
unlimited: rl.credits.unlimited
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
}
|
|
681
845
|
return {
|
|
682
846
|
runtimeId: "codex-acp",
|
|
683
847
|
provider: "OpenAI / Codex",
|
|
684
848
|
account: {
|
|
685
849
|
email: accountEmail,
|
|
686
850
|
plan: accountPlan,
|
|
687
|
-
type: "chatgpt"
|
|
851
|
+
type: dynamic?.account?.type || "chatgpt"
|
|
688
852
|
},
|
|
853
|
+
primaryWindow,
|
|
854
|
+
secondaryWindow,
|
|
855
|
+
credits,
|
|
689
856
|
status: "ok",
|
|
690
857
|
updatedAt: Date.now()
|
|
691
858
|
};
|
|
@@ -861,6 +1028,30 @@ var codexAdapter = {
|
|
|
861
1028
|
var import_node_fs4 = require("node:fs");
|
|
862
1029
|
var import_node_os3 = require("node:os");
|
|
863
1030
|
var import_node_path6 = require("node:path");
|
|
1031
|
+
var import_node_child_process2 = require("node:child_process");
|
|
1032
|
+
var cachedClaudeAuth = null;
|
|
1033
|
+
async function queryClaudeAuthStatus(timeoutMs = 1200) {
|
|
1034
|
+
if (cachedClaudeAuth && Date.now() - cachedClaudeAuth.time < 30000) {
|
|
1035
|
+
return cachedClaudeAuth.res;
|
|
1036
|
+
}
|
|
1037
|
+
return new Promise((resolve) => {
|
|
1038
|
+
try {
|
|
1039
|
+
import_node_child_process2.execFile("claude", ["auth", "status", "--json"], { timeout: timeoutMs, windowsHide: true, shell: process.platform === "win32" }, (err, stdout) => {
|
|
1040
|
+
if (!stdout)
|
|
1041
|
+
return resolve(null);
|
|
1042
|
+
try {
|
|
1043
|
+
const data = JSON.parse(stdout.trim());
|
|
1044
|
+
cachedClaudeAuth = { res: data, time: Date.now() };
|
|
1045
|
+
resolve(data);
|
|
1046
|
+
} catch {
|
|
1047
|
+
resolve(null);
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
} catch {
|
|
1051
|
+
resolve(null);
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
864
1055
|
async function probeClaudeQuota(options) {
|
|
865
1056
|
const claudeHome = resolveClaudeHome();
|
|
866
1057
|
const claudeJsonPath = import_node_path6.join(import_node_os3.homedir(), ".claude.json");
|
|
@@ -893,6 +1084,17 @@ async function probeClaudeQuota(options) {
|
|
|
893
1084
|
isLoggedIn = true;
|
|
894
1085
|
plan = "API Key (Env)";
|
|
895
1086
|
}
|
|
1087
|
+
const dynamic = await queryClaudeAuthStatus(1200);
|
|
1088
|
+
if (dynamic) {
|
|
1089
|
+
if (dynamic.loggedIn)
|
|
1090
|
+
isLoggedIn = true;
|
|
1091
|
+
if (dynamic.email)
|
|
1092
|
+
accountEmail = dynamic.email;
|
|
1093
|
+
if (dynamic.subscriptionType)
|
|
1094
|
+
plan = dynamic.subscriptionType;
|
|
1095
|
+
else if (dynamic.plan)
|
|
1096
|
+
plan = dynamic.plan;
|
|
1097
|
+
}
|
|
896
1098
|
if (isBanned) {
|
|
897
1099
|
return {
|
|
898
1100
|
runtimeId: "claude",
|
|
@@ -916,7 +1118,8 @@ async function probeClaudeQuota(options) {
|
|
|
916
1118
|
provider: "Anthropic / Claude Code",
|
|
917
1119
|
account: {
|
|
918
1120
|
email: accountEmail,
|
|
919
|
-
plan
|
|
1121
|
+
plan,
|
|
1122
|
+
type: dynamic?.authMethod || "oauth"
|
|
920
1123
|
},
|
|
921
1124
|
status: "ok",
|
|
922
1125
|
updatedAt: Date.now()
|
|
@@ -1022,6 +1225,9 @@ var copilotAdapter = {
|
|
|
1022
1225
|
|
|
1023
1226
|
// src/runtimes/opencode/quota.ts
|
|
1024
1227
|
var import_node_fs8 = require("node:fs");
|
|
1228
|
+
var import_node_child_process3 = require("node:child_process");
|
|
1229
|
+
var os = __toESM(require("node:os"), 1);
|
|
1230
|
+
var path = __toESM(require("node:path"), 1);
|
|
1025
1231
|
function resolveOpencodeAuthPath() {
|
|
1026
1232
|
const candidates = resolveOpencodeAuthCandidates();
|
|
1027
1233
|
for (const c of candidates) {
|
|
@@ -1030,10 +1236,204 @@ function resolveOpencodeAuthPath() {
|
|
|
1030
1236
|
}
|
|
1031
1237
|
return candidates[0] ?? null;
|
|
1032
1238
|
}
|
|
1239
|
+
var cachedStats = null;
|
|
1240
|
+
async function queryOpencodeStats(timeoutMs = 1200) {
|
|
1241
|
+
if (cachedStats && Date.now() - cachedStats.time < 30000) {
|
|
1242
|
+
return cachedStats.res;
|
|
1243
|
+
}
|
|
1244
|
+
return new Promise((resolve) => {
|
|
1245
|
+
try {
|
|
1246
|
+
import_node_child_process3.execFile("opencode", ["stats", "--standalone", "--cost", "--json"], { timeout: timeoutMs, windowsHide: true }, (err, stdout) => {
|
|
1247
|
+
if (!stdout)
|
|
1248
|
+
return resolve(null);
|
|
1249
|
+
try {
|
|
1250
|
+
const data = JSON.parse(stdout.trim());
|
|
1251
|
+
cachedStats = { res: data, time: Date.now() };
|
|
1252
|
+
resolve(data);
|
|
1253
|
+
} catch {
|
|
1254
|
+
resolve(null);
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
} catch {
|
|
1258
|
+
resolve(null);
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
async function queryOpencodeAuthList(timeoutMs = 1200) {
|
|
1263
|
+
return new Promise((resolve) => {
|
|
1264
|
+
try {
|
|
1265
|
+
import_node_child_process3.execFile("opencode", ["auth", "list"], { timeout: timeoutMs, windowsHide: true }, (err, stdout) => {
|
|
1266
|
+
if (!stdout)
|
|
1267
|
+
return resolve([]);
|
|
1268
|
+
const lines = stdout.split(`
|
|
1269
|
+
`).map((l) => l.trim()).filter((l) => l.includes("stored"));
|
|
1270
|
+
resolve(lines);
|
|
1271
|
+
});
|
|
1272
|
+
} catch {
|
|
1273
|
+
resolve([]);
|
|
1274
|
+
}
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
function readLocalOpencodeCredentials() {
|
|
1278
|
+
const home = os.homedir();
|
|
1279
|
+
const dbPaths = [
|
|
1280
|
+
path.join(home, ".local", "share", "opencode", "opencode.db"),
|
|
1281
|
+
process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, "opencode", "opencode.db") : null,
|
|
1282
|
+
path.join(home, ".config", "opencode", "opencode.db")
|
|
1283
|
+
].filter(Boolean);
|
|
1284
|
+
for (const dbPath of dbPaths) {
|
|
1285
|
+
if (!import_node_fs8.existsSync(dbPath))
|
|
1286
|
+
continue;
|
|
1287
|
+
try {
|
|
1288
|
+
let rows = [];
|
|
1289
|
+
if (typeof process.versions?.bun !== "undefined") {
|
|
1290
|
+
const { Database } = require("bun:sqlite");
|
|
1291
|
+
const db = new Database(dbPath, { readonly: true });
|
|
1292
|
+
rows = db.query("SELECT integration_id, value FROM credential").all();
|
|
1293
|
+
db.close();
|
|
1294
|
+
} else {
|
|
1295
|
+
const { DatabaseSync } = require("node:sqlite");
|
|
1296
|
+
const db = new DatabaseSync(dbPath, { readOnly: true });
|
|
1297
|
+
rows = db.prepare("SELECT integration_id, value FROM credential").all();
|
|
1298
|
+
db.close();
|
|
1299
|
+
}
|
|
1300
|
+
const opencodeCred = rows.find((r) => r.integration_id === "opencode");
|
|
1301
|
+
if (opencodeCred?.value) {
|
|
1302
|
+
const parsed = JSON.parse(opencodeCred.value);
|
|
1303
|
+
const meta = parsed.metadata || {};
|
|
1304
|
+
return {
|
|
1305
|
+
email: meta.email || undefined,
|
|
1306
|
+
name: meta.email ? meta.email.split("@")[0] : meta.orgName || undefined,
|
|
1307
|
+
token: parsed.access || undefined,
|
|
1308
|
+
orgId: meta.orgID || undefined,
|
|
1309
|
+
accountId: meta.accountID || undefined
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
} catch {
|
|
1313
|
+
try {
|
|
1314
|
+
const buf = import_node_fs8.readFileSync(dbPath, "utf8");
|
|
1315
|
+
const emailMatch = buf.match(/"email"\s*:\s*"([^"]+)"/);
|
|
1316
|
+
const tokenMatch = buf.match(/"access"\s*:\s*"(st_[a-zA-Z0-9_\\-]+)"/);
|
|
1317
|
+
const orgMatch = buf.match(/"orgID"\s*:\s*"(wrk_[a-zA-Z0-9_\\-]+)"/);
|
|
1318
|
+
const accMatch = buf.match(/"accountID"\s*:\s*"(acc_[a-zA-Z0-9_\\-]+)"/);
|
|
1319
|
+
if (emailMatch || tokenMatch) {
|
|
1320
|
+
return {
|
|
1321
|
+
email: emailMatch?.[1],
|
|
1322
|
+
name: emailMatch?.[1]?.split("@")[0],
|
|
1323
|
+
token: tokenMatch?.[1],
|
|
1324
|
+
orgId: orgMatch?.[1],
|
|
1325
|
+
accountId: accMatch?.[1]
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
} catch {}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
return {};
|
|
1332
|
+
}
|
|
1333
|
+
async function probeOpencodeGoOnlineQuota(creds, runtimeId = "opencode") {
|
|
1334
|
+
if (!creds.token || !creds.orgId)
|
|
1335
|
+
return null;
|
|
1336
|
+
try {
|
|
1337
|
+
const res = await fetch("https://opencode.ai/console/api/go/status", {
|
|
1338
|
+
headers: {
|
|
1339
|
+
Authorization: `Bearer ${creds.token}`,
|
|
1340
|
+
"x-opencode-org-id": creds.orgId,
|
|
1341
|
+
"x-opencode-account-id": creds.accountId || ""
|
|
1342
|
+
},
|
|
1343
|
+
signal: AbortSignal.timeout(3500)
|
|
1344
|
+
});
|
|
1345
|
+
if (!res.ok)
|
|
1346
|
+
return null;
|
|
1347
|
+
const data = await res.json();
|
|
1348
|
+
const meters = data?.access?.meters;
|
|
1349
|
+
if (!meters)
|
|
1350
|
+
return null;
|
|
1351
|
+
const formatReset = (isoStr) => {
|
|
1352
|
+
if (!isoStr)
|
|
1353
|
+
return;
|
|
1354
|
+
const diffMs = new Date(isoStr).getTime() - Date.now();
|
|
1355
|
+
if (diffMs <= 0)
|
|
1356
|
+
return "已重置";
|
|
1357
|
+
const totalMins = Math.floor(diffMs / 60000);
|
|
1358
|
+
const hours = Math.floor(totalMins / 60);
|
|
1359
|
+
const days = Math.floor(hours / 24);
|
|
1360
|
+
if (days > 0) {
|
|
1361
|
+
const remH = hours % 24;
|
|
1362
|
+
return `Resets in ${days}d ${remH}h`;
|
|
1363
|
+
}
|
|
1364
|
+
const remM = totalMins % 60;
|
|
1365
|
+
return `Resets in ${hours}h ${remM}m`;
|
|
1366
|
+
};
|
|
1367
|
+
const calcWindow = (m, label, durMins) => {
|
|
1368
|
+
if (!m || !m.limitMicroCents)
|
|
1369
|
+
return;
|
|
1370
|
+
const limit = Number(m.limitMicroCents);
|
|
1371
|
+
const used = Number(m.usedMicroCents || 0);
|
|
1372
|
+
const usedPercent = limit > 0 ? Math.round(used / limit * 100) : 0;
|
|
1373
|
+
const percentLeft = Math.max(0, 100 - usedPercent);
|
|
1374
|
+
return {
|
|
1375
|
+
label,
|
|
1376
|
+
usedPercent,
|
|
1377
|
+
percentLeft,
|
|
1378
|
+
windowDurationMins: durMins,
|
|
1379
|
+
resetsAt: formatReset(m.resetsAt)
|
|
1380
|
+
};
|
|
1381
|
+
};
|
|
1382
|
+
const rolling = calcWindow(meters.fiveHour, "Rolling", 300);
|
|
1383
|
+
const weekly = calcWindow(meters.week, "Weekly", 10080);
|
|
1384
|
+
const monthly = calcWindow(meters.month, "Monthly", 43200);
|
|
1385
|
+
let creditBalance = "$0.00";
|
|
1386
|
+
try {
|
|
1387
|
+
const bRes = await fetch("https://opencode.ai/console/api/billing/status", {
|
|
1388
|
+
headers: {
|
|
1389
|
+
Authorization: `Bearer ${creds.token}`,
|
|
1390
|
+
"x-opencode-org-id": creds.orgId,
|
|
1391
|
+
"x-opencode-account-id": creds.accountId || ""
|
|
1392
|
+
},
|
|
1393
|
+
signal: AbortSignal.timeout(2000)
|
|
1394
|
+
});
|
|
1395
|
+
if (bRes.ok) {
|
|
1396
|
+
const bData = await bRes.json();
|
|
1397
|
+
const availMicro = Number(bData.availableMicroCents || 0);
|
|
1398
|
+
creditBalance = `$${(availMicro / 1e8).toFixed(2)}`;
|
|
1399
|
+
}
|
|
1400
|
+
} catch {}
|
|
1401
|
+
const quota = {
|
|
1402
|
+
runtimeId,
|
|
1403
|
+
provider: "OpenCode",
|
|
1404
|
+
account: {
|
|
1405
|
+
email: creds.email,
|
|
1406
|
+
name: creds.name || "OpenCode User",
|
|
1407
|
+
plan: "OpenCode Go",
|
|
1408
|
+
type: "opencode"
|
|
1409
|
+
},
|
|
1410
|
+
primaryWindow: rolling,
|
|
1411
|
+
secondaryWindow: weekly,
|
|
1412
|
+
extraWindows: monthly ? [monthly] : undefined,
|
|
1413
|
+
credits: {
|
|
1414
|
+
balance: creditBalance,
|
|
1415
|
+
currency: "USD",
|
|
1416
|
+
unlimited: false
|
|
1417
|
+
},
|
|
1418
|
+
status: "ok",
|
|
1419
|
+
updatedAt: Date.now()
|
|
1420
|
+
};
|
|
1421
|
+
return quota;
|
|
1422
|
+
} catch {
|
|
1423
|
+
return null;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1033
1426
|
async function probeOpencodeQuota(runtimeId = "opencode") {
|
|
1427
|
+
const dbCreds = readLocalOpencodeCredentials();
|
|
1428
|
+
if (dbCreds.token) {
|
|
1429
|
+
const goQuota = await probeOpencodeGoOnlineQuota(dbCreds, runtimeId);
|
|
1430
|
+
if (goQuota)
|
|
1431
|
+
return goQuota;
|
|
1432
|
+
}
|
|
1034
1433
|
const authPath = resolveOpencodeAuthPath();
|
|
1035
|
-
let isLoggedIn =
|
|
1036
|
-
let accountEmail;
|
|
1434
|
+
let isLoggedIn = Boolean(dbCreds.token || dbCreds.email);
|
|
1435
|
+
let accountEmail = dbCreds.email;
|
|
1436
|
+
let accountName = dbCreds.name;
|
|
1037
1437
|
let plan = "OpenCode Community";
|
|
1038
1438
|
if (authPath && import_node_fs8.existsSync(authPath)) {
|
|
1039
1439
|
try {
|
|
@@ -1050,22 +1450,47 @@ async function probeOpencodeQuota(runtimeId = "opencode") {
|
|
|
1050
1450
|
}
|
|
1051
1451
|
} catch {}
|
|
1052
1452
|
}
|
|
1453
|
+
const [stats, authList] = await Promise.all([
|
|
1454
|
+
queryOpencodeStats(1200),
|
|
1455
|
+
queryOpencodeAuthList(1200)
|
|
1456
|
+
]);
|
|
1457
|
+
if (authList.length > 0) {
|
|
1458
|
+
isLoggedIn = true;
|
|
1459
|
+
const providers = authList.map((l) => l.split(/\s{2,}/)[0]).filter(Boolean);
|
|
1460
|
+
if (providers.some((p) => p.toLowerCase().includes("go"))) {
|
|
1461
|
+
plan = "OpenCode Go";
|
|
1462
|
+
} else if (providers.length > 0) {
|
|
1463
|
+
plan = `OpenCode (${providers.join(", ")})`;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
if (process.env.OPENCODE_API_KEY || process.env.OPENAI_API_KEY) {
|
|
1467
|
+
isLoggedIn = true;
|
|
1468
|
+
}
|
|
1053
1469
|
if (!isLoggedIn) {
|
|
1054
1470
|
return {
|
|
1055
1471
|
runtimeId,
|
|
1056
1472
|
provider: "OpenCode",
|
|
1057
1473
|
status: "unauthorized",
|
|
1058
|
-
message: "
|
|
1474
|
+
message: "未登录 OpenCode 或未配置 Provider (No stored credentials)",
|
|
1059
1475
|
updatedAt: Date.now()
|
|
1060
1476
|
};
|
|
1061
1477
|
}
|
|
1478
|
+
let credits;
|
|
1479
|
+
if (stats && typeof stats.cost === "number") {
|
|
1480
|
+
credits = {
|
|
1481
|
+
balance: stats.cost > 0 ? `$${stats.cost.toFixed(2)} spent` : "$0.00"
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1062
1484
|
return {
|
|
1063
1485
|
runtimeId,
|
|
1064
1486
|
provider: "OpenCode",
|
|
1065
1487
|
account: {
|
|
1066
1488
|
email: accountEmail,
|
|
1067
|
-
|
|
1489
|
+
name: accountName,
|
|
1490
|
+
plan,
|
|
1491
|
+
type: "provider_oauth"
|
|
1068
1492
|
},
|
|
1493
|
+
credits,
|
|
1069
1494
|
status: "ok",
|
|
1070
1495
|
updatedAt: Date.now()
|
|
1071
1496
|
};
|
|
@@ -1201,7 +1626,7 @@ async function probeCursorQuota() {
|
|
|
1201
1626
|
}
|
|
1202
1627
|
|
|
1203
1628
|
// src/runtimes/cursor/index.ts
|
|
1204
|
-
var
|
|
1629
|
+
var import_node_child_process4 = require("node:child_process");
|
|
1205
1630
|
var import_node_fs10 = require("node:fs");
|
|
1206
1631
|
var import_node_os8 = require("node:os");
|
|
1207
1632
|
var import_node_path11 = require("node:path");
|
|
@@ -1446,7 +1871,7 @@ function getCursorCatalogIds(execFile, overrides) {
|
|
|
1446
1871
|
}
|
|
1447
1872
|
try {
|
|
1448
1873
|
const shell = command.toLowerCase().endsWith(".cmd");
|
|
1449
|
-
const result =
|
|
1874
|
+
const result = import_node_child_process4.spawnSync(command, ["--list-models"], {
|
|
1450
1875
|
encoding: "utf8",
|
|
1451
1876
|
timeout: 6000,
|
|
1452
1877
|
windowsHide: true,
|
|
@@ -1519,21 +1944,240 @@ var deepseekAdapter = {
|
|
|
1519
1944
|
// src/runtimes/agy/quota.ts
|
|
1520
1945
|
var import_node_fs11 = require("node:fs");
|
|
1521
1946
|
var import_node_path12 = require("node:path");
|
|
1947
|
+
var import_node_child_process5 = require("node:child_process");
|
|
1948
|
+
var os2 = __toESM(require("node:os"), 1);
|
|
1522
1949
|
function resolveGeminiHome2() {
|
|
1523
1950
|
const home = process.env.USERPROFILE || process.env.HOME || "";
|
|
1524
1951
|
return import_node_path12.join(home, ".gemini");
|
|
1525
1952
|
}
|
|
1953
|
+
function resolveAntigravityAccount() {
|
|
1954
|
+
if (process.env.GOOGLE_ACCOUNT?.trim()) {
|
|
1955
|
+
const email = process.env.GOOGLE_ACCOUNT.trim();
|
|
1956
|
+
return { email, name: email.split("@")[0] };
|
|
1957
|
+
}
|
|
1958
|
+
if (process.env.ANTIGRAVITY_ACCOUNT?.trim()) {
|
|
1959
|
+
const email = process.env.ANTIGRAVITY_ACCOUNT.trim();
|
|
1960
|
+
return { email, name: email.split("@")[0] };
|
|
1961
|
+
}
|
|
1962
|
+
const home = process.env.USERPROFILE || process.env.HOME || os2.homedir() || "";
|
|
1963
|
+
const candidates = [
|
|
1964
|
+
process.env.APPDATA ? import_node_path12.join(process.env.APPDATA, "Antigravity", "app_storage.json") : null,
|
|
1965
|
+
import_node_path12.join(home, ".config", "Antigravity", "app_storage.json"),
|
|
1966
|
+
import_node_path12.join(home, "Library", "Application Support", "Antigravity", "app_storage.json")
|
|
1967
|
+
].filter(Boolean);
|
|
1968
|
+
for (const file of candidates) {
|
|
1969
|
+
try {
|
|
1970
|
+
if (import_node_fs11.existsSync(file)) {
|
|
1971
|
+
const raw = import_node_fs11.readFileSync(file, "utf8");
|
|
1972
|
+
const json = JSON.parse(raw);
|
|
1973
|
+
const username = json["jetski.onboarding.lastLoginUsername"];
|
|
1974
|
+
if (username && typeof username === "string" && username.trim()) {
|
|
1975
|
+
const u = username.trim();
|
|
1976
|
+
return {
|
|
1977
|
+
email: u,
|
|
1978
|
+
name: u.includes("@") ? u.split("@")[0] : u
|
|
1979
|
+
};
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
} catch {}
|
|
1983
|
+
}
|
|
1984
|
+
const osUser = process.env.USERNAME || process.env.USER;
|
|
1985
|
+
if (osUser?.trim()) {
|
|
1986
|
+
return { name: osUser.trim() };
|
|
1987
|
+
}
|
|
1988
|
+
return {};
|
|
1989
|
+
}
|
|
1990
|
+
function resolveAntigravityLanguageServer() {
|
|
1991
|
+
const home = process.env.USERPROFILE || process.env.HOME || os2.homedir() || "";
|
|
1992
|
+
const appData = process.env.APPDATA || (process.platform === "win32" ? import_node_path12.join(home, "AppData", "Roaming") : "");
|
|
1993
|
+
const baseDirs = [
|
|
1994
|
+
appData ? import_node_path12.join(appData, "Antigravity IDE", "logs") : null,
|
|
1995
|
+
appData ? import_node_path12.join(appData, "Antigravity", "logs") : null,
|
|
1996
|
+
import_node_path12.join(home, ".config", "Antigravity IDE", "logs"),
|
|
1997
|
+
import_node_path12.join(home, ".config", "Antigravity", "logs"),
|
|
1998
|
+
import_node_path12.join(home, "Library", "Application Support", "Antigravity IDE", "logs"),
|
|
1999
|
+
import_node_path12.join(home, "Library", "Application Support", "Antigravity", "logs")
|
|
2000
|
+
].filter(Boolean);
|
|
2001
|
+
for (const base of baseDirs) {
|
|
2002
|
+
try {
|
|
2003
|
+
if (!import_node_fs11.existsSync(base))
|
|
2004
|
+
continue;
|
|
2005
|
+
const sessionDirs = import_node_fs11.readdirSync(base).map((d) => {
|
|
2006
|
+
try {
|
|
2007
|
+
return { name: d, time: import_node_fs11.statSync(import_node_path12.join(base, d)).mtimeMs };
|
|
2008
|
+
} catch {
|
|
2009
|
+
return null;
|
|
2010
|
+
}
|
|
2011
|
+
}).filter((d) => Boolean(d)).sort((a, b) => b.time - a.time);
|
|
2012
|
+
for (const s of sessionDirs) {
|
|
2013
|
+
const logFile = import_node_path12.join(base, s.name, "ls-main.log");
|
|
2014
|
+
if (import_node_fs11.existsSync(logFile)) {
|
|
2015
|
+
const content = import_node_fs11.readFileSync(logFile, "utf8");
|
|
2016
|
+
const csrfMatch = content.match(/--csrf_token\s+([a-f0-9\-]+)/);
|
|
2017
|
+
const portMatch = content.match(/LS started on port\s+(\d+)/) || content.match(/--https_server_port\s+(\d+)/);
|
|
2018
|
+
if (csrfMatch && portMatch) {
|
|
2019
|
+
return {
|
|
2020
|
+
port: parseInt(portMatch[1], 10),
|
|
2021
|
+
csrfToken: csrfMatch[1]
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
} catch {}
|
|
2027
|
+
}
|
|
2028
|
+
try {
|
|
2029
|
+
let out = "";
|
|
2030
|
+
if (process.platform === "win32") {
|
|
2031
|
+
out = import_node_child_process5.execFileSync("powershell", [
|
|
2032
|
+
"-NoProfile",
|
|
2033
|
+
"-Command",
|
|
2034
|
+
`Get-CimInstance Win32_Process -Filter "Name like '%language_server%'" | Select-Object -ExpandProperty CommandLine`
|
|
2035
|
+
], { encoding: "utf8", timeout: 4000, windowsHide: true });
|
|
2036
|
+
} else {
|
|
2037
|
+
out = import_node_child_process5.execFileSync("ps", ["aux"], { encoding: "utf8", timeout: 4000 });
|
|
2038
|
+
}
|
|
2039
|
+
const lines = out.split(/\r?\n/);
|
|
2040
|
+
for (const l of lines) {
|
|
2041
|
+
const portMatch = l.match(/--https_server_port\s+(\d+)/);
|
|
2042
|
+
const csrfMatch = l.match(/--csrf_token\s+([a-f0-9\-]+)/);
|
|
2043
|
+
if (portMatch && csrfMatch) {
|
|
2044
|
+
return { port: parseInt(portMatch[1], 10), csrfToken: csrfMatch[1] };
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
} catch {}
|
|
2048
|
+
return null;
|
|
2049
|
+
}
|
|
1526
2050
|
async function probeAgyQuota(options) {
|
|
2051
|
+
const acc = resolveAntigravityAccount();
|
|
2052
|
+
const lsInfo = resolveAntigravityLanguageServer();
|
|
2053
|
+
if (lsInfo) {
|
|
2054
|
+
try {
|
|
2055
|
+
let data = null;
|
|
2056
|
+
const prevReject = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
|
2057
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
2058
|
+
try {
|
|
2059
|
+
const res = await fetch(`https://127.0.0.1:${lsInfo.port}/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary`, {
|
|
2060
|
+
method: "POST",
|
|
2061
|
+
headers: {
|
|
2062
|
+
"Content-Type": "application/json",
|
|
2063
|
+
"x-codeium-csrf-token": lsInfo.csrfToken
|
|
2064
|
+
},
|
|
2065
|
+
body: JSON.stringify({}),
|
|
2066
|
+
signal: AbortSignal.timeout(4000),
|
|
2067
|
+
tls: { rejectUnauthorized: false }
|
|
2068
|
+
});
|
|
2069
|
+
if (res.ok) {
|
|
2070
|
+
data = await res.json();
|
|
2071
|
+
}
|
|
2072
|
+
} catch {
|
|
2073
|
+
try {
|
|
2074
|
+
const raw = import_node_child_process5.execFileSync(process.platform === "win32" ? "curl.exe" : "curl", [
|
|
2075
|
+
"-k",
|
|
2076
|
+
"-s",
|
|
2077
|
+
"-X",
|
|
2078
|
+
"POST",
|
|
2079
|
+
"-H",
|
|
2080
|
+
"Content-Type: application/json",
|
|
2081
|
+
"-H",
|
|
2082
|
+
`x-codeium-csrf-token: ${lsInfo.csrfToken}`,
|
|
2083
|
+
"-d",
|
|
2084
|
+
"{}",
|
|
2085
|
+
`https://127.0.0.1:${lsInfo.port}/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary`
|
|
2086
|
+
], { encoding: "utf8", timeout: 4000 });
|
|
2087
|
+
data = JSON.parse(raw);
|
|
2088
|
+
} catch {}
|
|
2089
|
+
} finally {
|
|
2090
|
+
if (prevReject !== undefined) {
|
|
2091
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = prevReject;
|
|
2092
|
+
} else {
|
|
2093
|
+
delete process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
if (data?.response?.groups) {
|
|
2097
|
+
const groups = data.response.groups;
|
|
2098
|
+
const formatReset = (isoStr, fallbackDesc) => {
|
|
2099
|
+
if (fallbackDesc && fallbackDesc.includes("it will fully refresh in ")) {
|
|
2100
|
+
const m = fallbackDesc.match(/it will fully refresh in (.+?)\.?$/);
|
|
2101
|
+
if (m?.[1])
|
|
2102
|
+
return `Resets in ${m[1].trim()}`;
|
|
2103
|
+
}
|
|
2104
|
+
if (!isoStr)
|
|
2105
|
+
return;
|
|
2106
|
+
const diffMs = new Date(isoStr).getTime() - Date.now();
|
|
2107
|
+
if (diffMs <= 0)
|
|
2108
|
+
return "已重置";
|
|
2109
|
+
const totalMins = Math.floor(diffMs / 60000);
|
|
2110
|
+
const hours = Math.floor(totalMins / 60);
|
|
2111
|
+
const days = Math.floor(hours / 24);
|
|
2112
|
+
if (days > 0)
|
|
2113
|
+
return `Resets in ${days}d ${hours % 24}h`;
|
|
2114
|
+
return `Resets in ${hours}h ${totalMins % 60}m`;
|
|
2115
|
+
};
|
|
2116
|
+
const toWindow = (b, groupName, label, durMins) => {
|
|
2117
|
+
if (!b)
|
|
2118
|
+
return;
|
|
2119
|
+
const frac = typeof b.remainingFraction === "number" ? b.remainingFraction : 1;
|
|
2120
|
+
const percentLeft = Math.max(0, Math.min(100, Math.round(frac * 100)));
|
|
2121
|
+
const usedPercent = 100 - percentLeft;
|
|
2122
|
+
return {
|
|
2123
|
+
label,
|
|
2124
|
+
group: groupName,
|
|
2125
|
+
percentLeft,
|
|
2126
|
+
usedPercent,
|
|
2127
|
+
windowDurationMins: durMins,
|
|
2128
|
+
resetsAt: formatReset(b.resetTime, b.description)
|
|
2129
|
+
};
|
|
2130
|
+
};
|
|
2131
|
+
const geminiGroup = groups.find((g) => g.displayName?.toLowerCase().includes("gemini"));
|
|
2132
|
+
const thirdPartyGroup = groups.find((g) => g.displayName?.toLowerCase().includes("claude") || g.displayName?.toLowerCase().includes("gpt"));
|
|
2133
|
+
const gemini5h = geminiGroup?.buckets?.find((b) => b.displayName?.toLowerCase().includes("five hour") || b.bucketId?.includes("5h") || b.window === "5h");
|
|
2134
|
+
const geminiWeekly = geminiGroup?.buckets?.find((b) => b.displayName?.toLowerCase().includes("weekly") || b.bucketId?.includes("weekly") || b.window === "weekly");
|
|
2135
|
+
const tp5h = thirdPartyGroup?.buckets?.find((b) => b.displayName?.toLowerCase().includes("five hour") || b.bucketId?.includes("5h") || b.window === "5h");
|
|
2136
|
+
const tpWeekly = thirdPartyGroup?.buckets?.find((b) => b.displayName?.toLowerCase().includes("weekly") || b.bucketId?.includes("weekly") || b.window === "weekly");
|
|
2137
|
+
const primaryWindow = toWindow(gemini5h, "Gemini Models", "5-Hour limit", 300) || {
|
|
2138
|
+
label: "5-Hour limit",
|
|
2139
|
+
group: "Gemini Models",
|
|
2140
|
+
percentLeft: 100,
|
|
2141
|
+
usedPercent: 0,
|
|
2142
|
+
windowDurationMins: 300
|
|
2143
|
+
};
|
|
2144
|
+
const secondaryWindow = toWindow(geminiWeekly, "Gemini Models", "Weekly limit", 10080);
|
|
2145
|
+
const extraWindows = [
|
|
2146
|
+
toWindow(tp5h, "Claude and GPT models", "5-Hour limit", 300),
|
|
2147
|
+
toWindow(tpWeekly, "Claude and GPT models", "Weekly limit", 10080)
|
|
2148
|
+
].filter(Boolean);
|
|
2149
|
+
return {
|
|
2150
|
+
runtimeId: "agy",
|
|
2151
|
+
provider: "Google Antigravity",
|
|
2152
|
+
account: {
|
|
2153
|
+
email: acc.email,
|
|
2154
|
+
name: acc.name || "Google Developer",
|
|
2155
|
+
plan: "Google AI Pro",
|
|
2156
|
+
type: "gemini"
|
|
2157
|
+
},
|
|
2158
|
+
primaryWindow,
|
|
2159
|
+
secondaryWindow,
|
|
2160
|
+
extraWindows: extraWindows.length > 0 ? extraWindows : undefined,
|
|
2161
|
+
credits: {
|
|
2162
|
+
unlimited: true,
|
|
2163
|
+
balance: "unlimited"
|
|
2164
|
+
},
|
|
2165
|
+
status: "ok",
|
|
2166
|
+
updatedAt: Date.now()
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
} catch {}
|
|
2170
|
+
}
|
|
1527
2171
|
const geminiHome = resolveGeminiHome2();
|
|
1528
2172
|
const hasAgyDir = import_node_fs11.existsSync(import_node_path12.join(geminiHome, "antigravity")) || import_node_fs11.existsSync(import_node_path12.join(geminiHome, "antigravity-cli"));
|
|
1529
2173
|
const hasApiKey = Boolean(process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY);
|
|
1530
|
-
const isAvailable = hasAgyDir || hasApiKey;
|
|
2174
|
+
const isAvailable = hasAgyDir || hasApiKey || Boolean(acc.email || acc.name);
|
|
1531
2175
|
if (!isAvailable) {
|
|
1532
2176
|
return {
|
|
1533
2177
|
runtimeId: "agy",
|
|
1534
2178
|
provider: "Google Antigravity",
|
|
1535
2179
|
status: "unauthorized",
|
|
1536
|
-
message: "
|
|
2180
|
+
message: "未检测到 Antigravity 登录凭据",
|
|
1537
2181
|
updatedAt: Date.now()
|
|
1538
2182
|
};
|
|
1539
2183
|
}
|
|
@@ -1541,21 +2185,41 @@ async function probeAgyQuota(options) {
|
|
|
1541
2185
|
runtimeId: "agy",
|
|
1542
2186
|
provider: "Google Antigravity",
|
|
1543
2187
|
account: {
|
|
1544
|
-
|
|
2188
|
+
email: acc.email,
|
|
2189
|
+
name: acc.name || "Google Developer",
|
|
2190
|
+
plan: "Google AI Pro",
|
|
1545
2191
|
type: "gemini"
|
|
1546
2192
|
},
|
|
1547
2193
|
primaryWindow: {
|
|
1548
2194
|
label: "5-Hour limit",
|
|
2195
|
+
group: "Gemini Models",
|
|
1549
2196
|
percentLeft: 100,
|
|
1550
2197
|
usedPercent: 0,
|
|
1551
2198
|
windowDurationMins: 300
|
|
1552
2199
|
},
|
|
1553
2200
|
secondaryWindow: {
|
|
1554
2201
|
label: "Weekly limit",
|
|
2202
|
+
group: "Gemini Models",
|
|
1555
2203
|
percentLeft: 100,
|
|
1556
2204
|
usedPercent: 0,
|
|
1557
2205
|
windowDurationMins: 10080
|
|
1558
2206
|
},
|
|
2207
|
+
extraWindows: [
|
|
2208
|
+
{
|
|
2209
|
+
label: "5-Hour limit",
|
|
2210
|
+
group: "Claude and GPT models",
|
|
2211
|
+
percentLeft: 100,
|
|
2212
|
+
usedPercent: 0,
|
|
2213
|
+
windowDurationMins: 300
|
|
2214
|
+
},
|
|
2215
|
+
{
|
|
2216
|
+
label: "Weekly limit",
|
|
2217
|
+
group: "Claude and GPT models",
|
|
2218
|
+
percentLeft: 100,
|
|
2219
|
+
usedPercent: 0,
|
|
2220
|
+
windowDurationMins: 10080
|
|
2221
|
+
}
|
|
2222
|
+
],
|
|
1559
2223
|
credits: {
|
|
1560
2224
|
unlimited: true,
|
|
1561
2225
|
balance: "unlimited"
|
|
@@ -1616,7 +2280,7 @@ function getAcpRuntimeAdapter(runtimeId) {
|
|
|
1616
2280
|
}
|
|
1617
2281
|
|
|
1618
2282
|
// src/process/process-manager.ts
|
|
1619
|
-
var
|
|
2283
|
+
var import_node_child_process6 = require("node:child_process");
|
|
1620
2284
|
var active = new Map;
|
|
1621
2285
|
var ACP_EARLY_EXIT_WINDOW_MS = 3000;
|
|
1622
2286
|
var ACP_EARLY_EXIT_STDERR_TAIL_LINES = 20;
|
|
@@ -1628,7 +2292,7 @@ function killProcessTree(pid) {
|
|
|
1628
2292
|
if (process.platform !== "win32")
|
|
1629
2293
|
return;
|
|
1630
2294
|
try {
|
|
1631
|
-
|
|
2295
|
+
import_node_child_process6.spawnSync("taskkill", ["/F", "/T", "/PID", String(pid)], {
|
|
1632
2296
|
windowsHide: true,
|
|
1633
2297
|
timeout: 8000
|
|
1634
2298
|
});
|
|
@@ -1671,7 +2335,7 @@ function spawnAcpProcess(options) {
|
|
|
1671
2335
|
} else {
|
|
1672
2336
|
delete env.NO_BROWSER;
|
|
1673
2337
|
}
|
|
1674
|
-
const child =
|
|
2338
|
+
const child = import_node_child_process6.spawn(file, options.runtime.args, {
|
|
1675
2339
|
cwd: options.cwd,
|
|
1676
2340
|
env,
|
|
1677
2341
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -2391,7 +3055,7 @@ async function restoreOrCreateAcpSession(input) {
|
|
|
2391
3055
|
}
|
|
2392
3056
|
|
|
2393
3057
|
// src/client/acp-terminal.ts
|
|
2394
|
-
var
|
|
3058
|
+
var import_node_child_process7 = require("node:child_process");
|
|
2395
3059
|
var import_node_crypto = require("node:crypto");
|
|
2396
3060
|
|
|
2397
3061
|
// src/transport/terminal-output-buffer.ts
|
|
@@ -2444,7 +3108,7 @@ class AcpTerminalManager {
|
|
|
2444
3108
|
throw new Error("terminal/create 需要 command");
|
|
2445
3109
|
const cwd = resolveCwd(params.cwd, params.workspaceRoot);
|
|
2446
3110
|
const outputByteLimit = typeof params.outputByteLimit === "number" && params.outputByteLimit > 0 ? params.outputByteLimit : DEFAULT_OUTPUT_BYTE_LIMIT;
|
|
2447
|
-
const child =
|
|
3111
|
+
const child = import_node_child_process7.spawn(command, params.args ?? [], {
|
|
2448
3112
|
cwd,
|
|
2449
3113
|
env: buildEnv(params.env),
|
|
2450
3114
|
windowsHide: true,
|
|
@@ -2540,7 +3204,7 @@ class AcpTerminalManager {
|
|
|
2540
3204
|
return;
|
|
2541
3205
|
if (process.platform === "win32") {
|
|
2542
3206
|
try {
|
|
2543
|
-
|
|
3207
|
+
import_node_child_process7.spawn("taskkill", ["/pid", String(pid), "/T", "/F"], {
|
|
2544
3208
|
windowsHide: true,
|
|
2545
3209
|
stdio: "ignore"
|
|
2546
3210
|
});
|