@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/sidecar.cjs
CHANGED
|
@@ -33,10 +33,10 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
// src/sidecar/main.ts
|
|
36
|
-
var
|
|
36
|
+
var readline2 = __toESM(require("node:readline"), 1);
|
|
37
37
|
|
|
38
38
|
// src/version.ts
|
|
39
|
-
var ACP_CLIENT_VERSION = "0.1.
|
|
39
|
+
var ACP_CLIENT_VERSION = "0.1.7";
|
|
40
40
|
// src/contracts/index.ts
|
|
41
41
|
function ok(value) {
|
|
42
42
|
return { ok: true, value };
|
|
@@ -10300,6 +10300,8 @@ var legacyClientNotificationMethods = new Set([
|
|
|
10300
10300
|
// src/runtimes/codex/quota.ts
|
|
10301
10301
|
var import_node_fs2 = require("node:fs");
|
|
10302
10302
|
var import_node_path2 = require("node:path");
|
|
10303
|
+
var import_node_child_process = require("node:child_process");
|
|
10304
|
+
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
10303
10305
|
|
|
10304
10306
|
// src/runtimes/codex/codex-auth-preflight.ts
|
|
10305
10307
|
var import_node_fs = require("node:fs");
|
|
@@ -10346,6 +10348,102 @@ function decodeJwtPayload(token) {
|
|
|
10346
10348
|
return null;
|
|
10347
10349
|
}
|
|
10348
10350
|
}
|
|
10351
|
+
var cachedDynamicResult = null;
|
|
10352
|
+
async function queryCodexAppServer(timeoutMs = 1e4) {
|
|
10353
|
+
if (cachedDynamicResult && Date.now() - cachedDynamicResult.time < 120000) {
|
|
10354
|
+
return cachedDynamicResult.res;
|
|
10355
|
+
}
|
|
10356
|
+
return new Promise((resolve) => {
|
|
10357
|
+
let timer = null;
|
|
10358
|
+
let proc = null;
|
|
10359
|
+
let finished = false;
|
|
10360
|
+
const cleanup = (res) => {
|
|
10361
|
+
if (finished)
|
|
10362
|
+
return;
|
|
10363
|
+
finished = true;
|
|
10364
|
+
if (timer)
|
|
10365
|
+
clearTimeout(timer);
|
|
10366
|
+
if (proc) {
|
|
10367
|
+
try {
|
|
10368
|
+
proc.kill();
|
|
10369
|
+
} catch {}
|
|
10370
|
+
}
|
|
10371
|
+
if (res) {
|
|
10372
|
+
cachedDynamicResult = { res, time: Date.now() };
|
|
10373
|
+
}
|
|
10374
|
+
resolve(res);
|
|
10375
|
+
};
|
|
10376
|
+
timer = setTimeout(() => cleanup(null), timeoutMs);
|
|
10377
|
+
try {
|
|
10378
|
+
const cmd = process.platform === "win32" ? "codex" : import_node_fs2.existsSync("/mnt/c/Users") ? "codex.exe" : "codex";
|
|
10379
|
+
proc = import_node_child_process.spawn(cmd, ["app-server"], {
|
|
10380
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
10381
|
+
shell: process.platform === "win32",
|
|
10382
|
+
windowsHide: true
|
|
10383
|
+
});
|
|
10384
|
+
if (!proc.stdin || !proc.stdout) {
|
|
10385
|
+
return cleanup(null);
|
|
10386
|
+
}
|
|
10387
|
+
const rl = import_node_readline.default.createInterface({ input: proc.stdout });
|
|
10388
|
+
let reqSeq = 1;
|
|
10389
|
+
const pending = new Map;
|
|
10390
|
+
const result = {};
|
|
10391
|
+
rl.on("line", (line) => {
|
|
10392
|
+
try {
|
|
10393
|
+
const data = JSON.parse(line.trim());
|
|
10394
|
+
if (data && typeof data.id === "number" && pending.has(data.id)) {
|
|
10395
|
+
const cb = pending.get(data.id);
|
|
10396
|
+
pending.delete(data.id);
|
|
10397
|
+
cb(data.result);
|
|
10398
|
+
}
|
|
10399
|
+
} catch {}
|
|
10400
|
+
});
|
|
10401
|
+
proc.on("error", () => cleanup(null));
|
|
10402
|
+
proc.on("exit", () => cleanup(Object.keys(result).length > 0 ? result : null));
|
|
10403
|
+
const send = (method, params) => {
|
|
10404
|
+
const id = reqSeq++;
|
|
10405
|
+
const msg = JSON.stringify({ jsonrpc: "2.0", id, method, params }) + `
|
|
10406
|
+
`;
|
|
10407
|
+
proc.stdin.write(msg);
|
|
10408
|
+
return new Promise((res) => {
|
|
10409
|
+
pending.set(id, res);
|
|
10410
|
+
});
|
|
10411
|
+
};
|
|
10412
|
+
(async () => {
|
|
10413
|
+
try {
|
|
10414
|
+
await send("initialize", {
|
|
10415
|
+
clientInfo: { name: "acp-client", version: "0.1.6" }
|
|
10416
|
+
});
|
|
10417
|
+
const acc = await send("account/read", { refreshToken: false });
|
|
10418
|
+
if (acc?.account) {
|
|
10419
|
+
result.account = acc.account;
|
|
10420
|
+
}
|
|
10421
|
+
const limits = await send("account/rateLimits/read");
|
|
10422
|
+
if (limits?.rateLimits) {
|
|
10423
|
+
result.rateLimits = limits.rateLimits;
|
|
10424
|
+
}
|
|
10425
|
+
cleanup(result);
|
|
10426
|
+
} catch {
|
|
10427
|
+
cleanup(null);
|
|
10428
|
+
}
|
|
10429
|
+
})();
|
|
10430
|
+
} catch {
|
|
10431
|
+
cleanup(null);
|
|
10432
|
+
}
|
|
10433
|
+
});
|
|
10434
|
+
}
|
|
10435
|
+
function formatEpochTime(epochSeconds) {
|
|
10436
|
+
if (!epochSeconds)
|
|
10437
|
+
return;
|
|
10438
|
+
try {
|
|
10439
|
+
const d = new Date(epochSeconds * 1000);
|
|
10440
|
+
const hours = String(d.getHours()).padStart(2, "0");
|
|
10441
|
+
const mins = String(d.getMinutes()).padStart(2, "0");
|
|
10442
|
+
return `${hours}:${mins}`;
|
|
10443
|
+
} catch {
|
|
10444
|
+
return;
|
|
10445
|
+
}
|
|
10446
|
+
}
|
|
10349
10447
|
async function probeCodexQuota(options) {
|
|
10350
10448
|
const codexHome = resolveCodexHome();
|
|
10351
10449
|
const authPath = import_node_path2.join(codexHome, "auth.json");
|
|
@@ -10379,6 +10477,14 @@ async function probeCodexQuota(options) {
|
|
|
10379
10477
|
isLoggedIn = true;
|
|
10380
10478
|
accountPlan = "API Key (Env)";
|
|
10381
10479
|
}
|
|
10480
|
+
const dynamic = await queryCodexAppServer(1e4);
|
|
10481
|
+
if (dynamic) {
|
|
10482
|
+
isLoggedIn = true;
|
|
10483
|
+
if (dynamic.account?.email)
|
|
10484
|
+
accountEmail = dynamic.account.email;
|
|
10485
|
+
if (dynamic.account?.planType)
|
|
10486
|
+
accountPlan = `ChatGPT ${dynamic.account.planType}`;
|
|
10487
|
+
}
|
|
10382
10488
|
if (!isLoggedIn) {
|
|
10383
10489
|
return {
|
|
10384
10490
|
runtimeId: "codex-acp",
|
|
@@ -10388,14 +10494,49 @@ async function probeCodexQuota(options) {
|
|
|
10388
10494
|
updatedAt: Date.now()
|
|
10389
10495
|
};
|
|
10390
10496
|
}
|
|
10497
|
+
let primaryWindow;
|
|
10498
|
+
let secondaryWindow;
|
|
10499
|
+
let credits;
|
|
10500
|
+
if (dynamic?.rateLimits) {
|
|
10501
|
+
const rl = dynamic.rateLimits;
|
|
10502
|
+
if (rl.primary) {
|
|
10503
|
+
const used = rl.primary.usedPercent ?? 0;
|
|
10504
|
+
primaryWindow = {
|
|
10505
|
+
label: "5h limit",
|
|
10506
|
+
percentLeft: Math.max(0, Math.min(100, Math.round(100 - used))),
|
|
10507
|
+
usedPercent: used,
|
|
10508
|
+
windowDurationMins: rl.primary.windowDurationMins || 300,
|
|
10509
|
+
resetsAt: formatEpochTime(rl.primary.resetsAt) || (rl.primary.resetsAt ? String(rl.primary.resetsAt) : undefined)
|
|
10510
|
+
};
|
|
10511
|
+
}
|
|
10512
|
+
if (rl.secondary) {
|
|
10513
|
+
const used = rl.secondary.usedPercent ?? 0;
|
|
10514
|
+
secondaryWindow = {
|
|
10515
|
+
label: "Weekly limit",
|
|
10516
|
+
percentLeft: Math.max(0, Math.min(100, Math.round(100 - used))),
|
|
10517
|
+
usedPercent: used,
|
|
10518
|
+
windowDurationMins: rl.secondary.windowDurationMins || 10080,
|
|
10519
|
+
resetsAt: formatEpochTime(rl.secondary.resetsAt) || (rl.secondary.resetsAt ? String(rl.secondary.resetsAt) : undefined)
|
|
10520
|
+
};
|
|
10521
|
+
}
|
|
10522
|
+
if (rl.credits) {
|
|
10523
|
+
credits = {
|
|
10524
|
+
balance: rl.credits.balance,
|
|
10525
|
+
unlimited: rl.credits.unlimited
|
|
10526
|
+
};
|
|
10527
|
+
}
|
|
10528
|
+
}
|
|
10391
10529
|
return {
|
|
10392
10530
|
runtimeId: "codex-acp",
|
|
10393
10531
|
provider: "OpenAI / Codex",
|
|
10394
10532
|
account: {
|
|
10395
10533
|
email: accountEmail,
|
|
10396
10534
|
plan: accountPlan,
|
|
10397
|
-
type: "chatgpt"
|
|
10535
|
+
type: dynamic?.account?.type || "chatgpt"
|
|
10398
10536
|
},
|
|
10537
|
+
primaryWindow,
|
|
10538
|
+
secondaryWindow,
|
|
10539
|
+
credits,
|
|
10399
10540
|
status: "ok",
|
|
10400
10541
|
updatedAt: Date.now()
|
|
10401
10542
|
};
|
|
@@ -10523,6 +10664,30 @@ var codexAdapter = {
|
|
|
10523
10664
|
var import_node_fs4 = require("node:fs");
|
|
10524
10665
|
var import_node_os3 = require("node:os");
|
|
10525
10666
|
var import_node_path6 = require("node:path");
|
|
10667
|
+
var import_node_child_process2 = require("node:child_process");
|
|
10668
|
+
var cachedClaudeAuth = null;
|
|
10669
|
+
async function queryClaudeAuthStatus(timeoutMs = 1200) {
|
|
10670
|
+
if (cachedClaudeAuth && Date.now() - cachedClaudeAuth.time < 30000) {
|
|
10671
|
+
return cachedClaudeAuth.res;
|
|
10672
|
+
}
|
|
10673
|
+
return new Promise((resolve) => {
|
|
10674
|
+
try {
|
|
10675
|
+
import_node_child_process2.execFile("claude", ["auth", "status", "--json"], { timeout: timeoutMs, windowsHide: true, shell: process.platform === "win32" }, (err, stdout) => {
|
|
10676
|
+
if (!stdout)
|
|
10677
|
+
return resolve(null);
|
|
10678
|
+
try {
|
|
10679
|
+
const data = JSON.parse(stdout.trim());
|
|
10680
|
+
cachedClaudeAuth = { res: data, time: Date.now() };
|
|
10681
|
+
resolve(data);
|
|
10682
|
+
} catch {
|
|
10683
|
+
resolve(null);
|
|
10684
|
+
}
|
|
10685
|
+
});
|
|
10686
|
+
} catch {
|
|
10687
|
+
resolve(null);
|
|
10688
|
+
}
|
|
10689
|
+
});
|
|
10690
|
+
}
|
|
10526
10691
|
async function probeClaudeQuota(options) {
|
|
10527
10692
|
const claudeHome = resolveClaudeHome();
|
|
10528
10693
|
const claudeJsonPath = import_node_path6.join(import_node_os3.homedir(), ".claude.json");
|
|
@@ -10555,6 +10720,17 @@ async function probeClaudeQuota(options) {
|
|
|
10555
10720
|
isLoggedIn = true;
|
|
10556
10721
|
plan = "API Key (Env)";
|
|
10557
10722
|
}
|
|
10723
|
+
const dynamic = await queryClaudeAuthStatus(1200);
|
|
10724
|
+
if (dynamic) {
|
|
10725
|
+
if (dynamic.loggedIn)
|
|
10726
|
+
isLoggedIn = true;
|
|
10727
|
+
if (dynamic.email)
|
|
10728
|
+
accountEmail = dynamic.email;
|
|
10729
|
+
if (dynamic.subscriptionType)
|
|
10730
|
+
plan = dynamic.subscriptionType;
|
|
10731
|
+
else if (dynamic.plan)
|
|
10732
|
+
plan = dynamic.plan;
|
|
10733
|
+
}
|
|
10558
10734
|
if (isBanned) {
|
|
10559
10735
|
return {
|
|
10560
10736
|
runtimeId: "claude",
|
|
@@ -10578,7 +10754,8 @@ async function probeClaudeQuota(options) {
|
|
|
10578
10754
|
provider: "Anthropic / Claude Code",
|
|
10579
10755
|
account: {
|
|
10580
10756
|
email: accountEmail,
|
|
10581
|
-
plan
|
|
10757
|
+
plan,
|
|
10758
|
+
type: dynamic?.authMethod || "oauth"
|
|
10582
10759
|
},
|
|
10583
10760
|
status: "ok",
|
|
10584
10761
|
updatedAt: Date.now()
|
|
@@ -10684,6 +10861,9 @@ var copilotAdapter = {
|
|
|
10684
10861
|
|
|
10685
10862
|
// src/runtimes/opencode/quota.ts
|
|
10686
10863
|
var import_node_fs8 = require("node:fs");
|
|
10864
|
+
var import_node_child_process3 = require("node:child_process");
|
|
10865
|
+
var os = __toESM(require("node:os"), 1);
|
|
10866
|
+
var path = __toESM(require("node:path"), 1);
|
|
10687
10867
|
function resolveOpencodeAuthPath() {
|
|
10688
10868
|
const candidates = resolveOpencodeAuthCandidates();
|
|
10689
10869
|
for (const c of candidates) {
|
|
@@ -10692,10 +10872,204 @@ function resolveOpencodeAuthPath() {
|
|
|
10692
10872
|
}
|
|
10693
10873
|
return candidates[0] ?? null;
|
|
10694
10874
|
}
|
|
10875
|
+
var cachedStats = null;
|
|
10876
|
+
async function queryOpencodeStats(timeoutMs = 1200) {
|
|
10877
|
+
if (cachedStats && Date.now() - cachedStats.time < 30000) {
|
|
10878
|
+
return cachedStats.res;
|
|
10879
|
+
}
|
|
10880
|
+
return new Promise((resolve) => {
|
|
10881
|
+
try {
|
|
10882
|
+
import_node_child_process3.execFile("opencode", ["stats", "--standalone", "--cost", "--json"], { timeout: timeoutMs, windowsHide: true }, (err, stdout) => {
|
|
10883
|
+
if (!stdout)
|
|
10884
|
+
return resolve(null);
|
|
10885
|
+
try {
|
|
10886
|
+
const data = JSON.parse(stdout.trim());
|
|
10887
|
+
cachedStats = { res: data, time: Date.now() };
|
|
10888
|
+
resolve(data);
|
|
10889
|
+
} catch {
|
|
10890
|
+
resolve(null);
|
|
10891
|
+
}
|
|
10892
|
+
});
|
|
10893
|
+
} catch {
|
|
10894
|
+
resolve(null);
|
|
10895
|
+
}
|
|
10896
|
+
});
|
|
10897
|
+
}
|
|
10898
|
+
async function queryOpencodeAuthList(timeoutMs = 1200) {
|
|
10899
|
+
return new Promise((resolve) => {
|
|
10900
|
+
try {
|
|
10901
|
+
import_node_child_process3.execFile("opencode", ["auth", "list"], { timeout: timeoutMs, windowsHide: true }, (err, stdout) => {
|
|
10902
|
+
if (!stdout)
|
|
10903
|
+
return resolve([]);
|
|
10904
|
+
const lines = stdout.split(`
|
|
10905
|
+
`).map((l) => l.trim()).filter((l) => l.includes("stored"));
|
|
10906
|
+
resolve(lines);
|
|
10907
|
+
});
|
|
10908
|
+
} catch {
|
|
10909
|
+
resolve([]);
|
|
10910
|
+
}
|
|
10911
|
+
});
|
|
10912
|
+
}
|
|
10913
|
+
function readLocalOpencodeCredentials() {
|
|
10914
|
+
const home = os.homedir();
|
|
10915
|
+
const dbPaths = [
|
|
10916
|
+
path.join(home, ".local", "share", "opencode", "opencode.db"),
|
|
10917
|
+
process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, "opencode", "opencode.db") : null,
|
|
10918
|
+
path.join(home, ".config", "opencode", "opencode.db")
|
|
10919
|
+
].filter(Boolean);
|
|
10920
|
+
for (const dbPath of dbPaths) {
|
|
10921
|
+
if (!import_node_fs8.existsSync(dbPath))
|
|
10922
|
+
continue;
|
|
10923
|
+
try {
|
|
10924
|
+
let rows = [];
|
|
10925
|
+
if (typeof process.versions?.bun !== "undefined") {
|
|
10926
|
+
const { Database } = require("bun:sqlite");
|
|
10927
|
+
const db = new Database(dbPath, { readonly: true });
|
|
10928
|
+
rows = db.query("SELECT integration_id, value FROM credential").all();
|
|
10929
|
+
db.close();
|
|
10930
|
+
} else {
|
|
10931
|
+
const { DatabaseSync } = require("node:sqlite");
|
|
10932
|
+
const db = new DatabaseSync(dbPath, { readOnly: true });
|
|
10933
|
+
rows = db.prepare("SELECT integration_id, value FROM credential").all();
|
|
10934
|
+
db.close();
|
|
10935
|
+
}
|
|
10936
|
+
const opencodeCred = rows.find((r) => r.integration_id === "opencode");
|
|
10937
|
+
if (opencodeCred?.value) {
|
|
10938
|
+
const parsed = JSON.parse(opencodeCred.value);
|
|
10939
|
+
const meta = parsed.metadata || {};
|
|
10940
|
+
return {
|
|
10941
|
+
email: meta.email || undefined,
|
|
10942
|
+
name: meta.email ? meta.email.split("@")[0] : meta.orgName || undefined,
|
|
10943
|
+
token: parsed.access || undefined,
|
|
10944
|
+
orgId: meta.orgID || undefined,
|
|
10945
|
+
accountId: meta.accountID || undefined
|
|
10946
|
+
};
|
|
10947
|
+
}
|
|
10948
|
+
} catch {
|
|
10949
|
+
try {
|
|
10950
|
+
const buf = import_node_fs8.readFileSync(dbPath, "utf8");
|
|
10951
|
+
const emailMatch = buf.match(/"email"\s*:\s*"([^"]+)"/);
|
|
10952
|
+
const tokenMatch = buf.match(/"access"\s*:\s*"(st_[a-zA-Z0-9_\\-]+)"/);
|
|
10953
|
+
const orgMatch = buf.match(/"orgID"\s*:\s*"(wrk_[a-zA-Z0-9_\\-]+)"/);
|
|
10954
|
+
const accMatch = buf.match(/"accountID"\s*:\s*"(acc_[a-zA-Z0-9_\\-]+)"/);
|
|
10955
|
+
if (emailMatch || tokenMatch) {
|
|
10956
|
+
return {
|
|
10957
|
+
email: emailMatch?.[1],
|
|
10958
|
+
name: emailMatch?.[1]?.split("@")[0],
|
|
10959
|
+
token: tokenMatch?.[1],
|
|
10960
|
+
orgId: orgMatch?.[1],
|
|
10961
|
+
accountId: accMatch?.[1]
|
|
10962
|
+
};
|
|
10963
|
+
}
|
|
10964
|
+
} catch {}
|
|
10965
|
+
}
|
|
10966
|
+
}
|
|
10967
|
+
return {};
|
|
10968
|
+
}
|
|
10969
|
+
async function probeOpencodeGoOnlineQuota(creds, runtimeId = "opencode") {
|
|
10970
|
+
if (!creds.token || !creds.orgId)
|
|
10971
|
+
return null;
|
|
10972
|
+
try {
|
|
10973
|
+
const res = await fetch("https://opencode.ai/console/api/go/status", {
|
|
10974
|
+
headers: {
|
|
10975
|
+
Authorization: `Bearer ${creds.token}`,
|
|
10976
|
+
"x-opencode-org-id": creds.orgId,
|
|
10977
|
+
"x-opencode-account-id": creds.accountId || ""
|
|
10978
|
+
},
|
|
10979
|
+
signal: AbortSignal.timeout(3500)
|
|
10980
|
+
});
|
|
10981
|
+
if (!res.ok)
|
|
10982
|
+
return null;
|
|
10983
|
+
const data = await res.json();
|
|
10984
|
+
const meters = data?.access?.meters;
|
|
10985
|
+
if (!meters)
|
|
10986
|
+
return null;
|
|
10987
|
+
const formatReset = (isoStr) => {
|
|
10988
|
+
if (!isoStr)
|
|
10989
|
+
return;
|
|
10990
|
+
const diffMs = new Date(isoStr).getTime() - Date.now();
|
|
10991
|
+
if (diffMs <= 0)
|
|
10992
|
+
return "已重置";
|
|
10993
|
+
const totalMins = Math.floor(diffMs / 60000);
|
|
10994
|
+
const hours = Math.floor(totalMins / 60);
|
|
10995
|
+
const days = Math.floor(hours / 24);
|
|
10996
|
+
if (days > 0) {
|
|
10997
|
+
const remH = hours % 24;
|
|
10998
|
+
return `Resets in ${days}d ${remH}h`;
|
|
10999
|
+
}
|
|
11000
|
+
const remM = totalMins % 60;
|
|
11001
|
+
return `Resets in ${hours}h ${remM}m`;
|
|
11002
|
+
};
|
|
11003
|
+
const calcWindow = (m, label, durMins) => {
|
|
11004
|
+
if (!m || !m.limitMicroCents)
|
|
11005
|
+
return;
|
|
11006
|
+
const limit = Number(m.limitMicroCents);
|
|
11007
|
+
const used = Number(m.usedMicroCents || 0);
|
|
11008
|
+
const usedPercent = limit > 0 ? Math.round(used / limit * 100) : 0;
|
|
11009
|
+
const percentLeft = Math.max(0, 100 - usedPercent);
|
|
11010
|
+
return {
|
|
11011
|
+
label,
|
|
11012
|
+
usedPercent,
|
|
11013
|
+
percentLeft,
|
|
11014
|
+
windowDurationMins: durMins,
|
|
11015
|
+
resetsAt: formatReset(m.resetsAt)
|
|
11016
|
+
};
|
|
11017
|
+
};
|
|
11018
|
+
const rolling = calcWindow(meters.fiveHour, "Rolling", 300);
|
|
11019
|
+
const weekly = calcWindow(meters.week, "Weekly", 10080);
|
|
11020
|
+
const monthly = calcWindow(meters.month, "Monthly", 43200);
|
|
11021
|
+
let creditBalance = "$0.00";
|
|
11022
|
+
try {
|
|
11023
|
+
const bRes = await fetch("https://opencode.ai/console/api/billing/status", {
|
|
11024
|
+
headers: {
|
|
11025
|
+
Authorization: `Bearer ${creds.token}`,
|
|
11026
|
+
"x-opencode-org-id": creds.orgId,
|
|
11027
|
+
"x-opencode-account-id": creds.accountId || ""
|
|
11028
|
+
},
|
|
11029
|
+
signal: AbortSignal.timeout(2000)
|
|
11030
|
+
});
|
|
11031
|
+
if (bRes.ok) {
|
|
11032
|
+
const bData = await bRes.json();
|
|
11033
|
+
const availMicro = Number(bData.availableMicroCents || 0);
|
|
11034
|
+
creditBalance = `$${(availMicro / 1e8).toFixed(2)}`;
|
|
11035
|
+
}
|
|
11036
|
+
} catch {}
|
|
11037
|
+
const quota = {
|
|
11038
|
+
runtimeId,
|
|
11039
|
+
provider: "OpenCode",
|
|
11040
|
+
account: {
|
|
11041
|
+
email: creds.email,
|
|
11042
|
+
name: creds.name || "OpenCode User",
|
|
11043
|
+
plan: "OpenCode Go",
|
|
11044
|
+
type: "opencode"
|
|
11045
|
+
},
|
|
11046
|
+
primaryWindow: rolling,
|
|
11047
|
+
secondaryWindow: weekly,
|
|
11048
|
+
extraWindows: monthly ? [monthly] : undefined,
|
|
11049
|
+
credits: {
|
|
11050
|
+
balance: creditBalance,
|
|
11051
|
+
currency: "USD",
|
|
11052
|
+
unlimited: false
|
|
11053
|
+
},
|
|
11054
|
+
status: "ok",
|
|
11055
|
+
updatedAt: Date.now()
|
|
11056
|
+
};
|
|
11057
|
+
return quota;
|
|
11058
|
+
} catch {
|
|
11059
|
+
return null;
|
|
11060
|
+
}
|
|
11061
|
+
}
|
|
10695
11062
|
async function probeOpencodeQuota(runtimeId = "opencode") {
|
|
11063
|
+
const dbCreds = readLocalOpencodeCredentials();
|
|
11064
|
+
if (dbCreds.token) {
|
|
11065
|
+
const goQuota = await probeOpencodeGoOnlineQuota(dbCreds, runtimeId);
|
|
11066
|
+
if (goQuota)
|
|
11067
|
+
return goQuota;
|
|
11068
|
+
}
|
|
10696
11069
|
const authPath = resolveOpencodeAuthPath();
|
|
10697
|
-
let isLoggedIn =
|
|
10698
|
-
let accountEmail;
|
|
11070
|
+
let isLoggedIn = Boolean(dbCreds.token || dbCreds.email);
|
|
11071
|
+
let accountEmail = dbCreds.email;
|
|
11072
|
+
let accountName = dbCreds.name;
|
|
10699
11073
|
let plan = "OpenCode Community";
|
|
10700
11074
|
if (authPath && import_node_fs8.existsSync(authPath)) {
|
|
10701
11075
|
try {
|
|
@@ -10712,22 +11086,47 @@ async function probeOpencodeQuota(runtimeId = "opencode") {
|
|
|
10712
11086
|
}
|
|
10713
11087
|
} catch {}
|
|
10714
11088
|
}
|
|
11089
|
+
const [stats, authList] = await Promise.all([
|
|
11090
|
+
queryOpencodeStats(1200),
|
|
11091
|
+
queryOpencodeAuthList(1200)
|
|
11092
|
+
]);
|
|
11093
|
+
if (authList.length > 0) {
|
|
11094
|
+
isLoggedIn = true;
|
|
11095
|
+
const providers = authList.map((l) => l.split(/\s{2,}/)[0]).filter(Boolean);
|
|
11096
|
+
if (providers.some((p) => p.toLowerCase().includes("go"))) {
|
|
11097
|
+
plan = "OpenCode Go";
|
|
11098
|
+
} else if (providers.length > 0) {
|
|
11099
|
+
plan = `OpenCode (${providers.join(", ")})`;
|
|
11100
|
+
}
|
|
11101
|
+
}
|
|
11102
|
+
if (process.env.OPENCODE_API_KEY || process.env.OPENAI_API_KEY) {
|
|
11103
|
+
isLoggedIn = true;
|
|
11104
|
+
}
|
|
10715
11105
|
if (!isLoggedIn) {
|
|
10716
11106
|
return {
|
|
10717
11107
|
runtimeId,
|
|
10718
11108
|
provider: "OpenCode",
|
|
10719
11109
|
status: "unauthorized",
|
|
10720
|
-
message: "
|
|
11110
|
+
message: "未登录 OpenCode 或未配置 Provider (No stored credentials)",
|
|
10721
11111
|
updatedAt: Date.now()
|
|
10722
11112
|
};
|
|
10723
11113
|
}
|
|
11114
|
+
let credits;
|
|
11115
|
+
if (stats && typeof stats.cost === "number") {
|
|
11116
|
+
credits = {
|
|
11117
|
+
balance: stats.cost > 0 ? `$${stats.cost.toFixed(2)} spent` : "$0.00"
|
|
11118
|
+
};
|
|
11119
|
+
}
|
|
10724
11120
|
return {
|
|
10725
11121
|
runtimeId,
|
|
10726
11122
|
provider: "OpenCode",
|
|
10727
11123
|
account: {
|
|
10728
11124
|
email: accountEmail,
|
|
10729
|
-
|
|
11125
|
+
name: accountName,
|
|
11126
|
+
plan,
|
|
11127
|
+
type: "provider_oauth"
|
|
10730
11128
|
},
|
|
11129
|
+
credits,
|
|
10731
11130
|
status: "ok",
|
|
10732
11131
|
updatedAt: Date.now()
|
|
10733
11132
|
};
|
|
@@ -11089,21 +11488,240 @@ var deepseekAdapter = {
|
|
|
11089
11488
|
// src/runtimes/agy/quota.ts
|
|
11090
11489
|
var import_node_fs11 = require("node:fs");
|
|
11091
11490
|
var import_node_path12 = require("node:path");
|
|
11491
|
+
var import_node_child_process4 = require("node:child_process");
|
|
11492
|
+
var os2 = __toESM(require("node:os"), 1);
|
|
11092
11493
|
function resolveGeminiHome2() {
|
|
11093
11494
|
const home = process.env.USERPROFILE || process.env.HOME || "";
|
|
11094
11495
|
return import_node_path12.join(home, ".gemini");
|
|
11095
11496
|
}
|
|
11497
|
+
function resolveAntigravityAccount() {
|
|
11498
|
+
if (process.env.GOOGLE_ACCOUNT?.trim()) {
|
|
11499
|
+
const email = process.env.GOOGLE_ACCOUNT.trim();
|
|
11500
|
+
return { email, name: email.split("@")[0] };
|
|
11501
|
+
}
|
|
11502
|
+
if (process.env.ANTIGRAVITY_ACCOUNT?.trim()) {
|
|
11503
|
+
const email = process.env.ANTIGRAVITY_ACCOUNT.trim();
|
|
11504
|
+
return { email, name: email.split("@")[0] };
|
|
11505
|
+
}
|
|
11506
|
+
const home = process.env.USERPROFILE || process.env.HOME || os2.homedir() || "";
|
|
11507
|
+
const candidates = [
|
|
11508
|
+
process.env.APPDATA ? import_node_path12.join(process.env.APPDATA, "Antigravity", "app_storage.json") : null,
|
|
11509
|
+
import_node_path12.join(home, ".config", "Antigravity", "app_storage.json"),
|
|
11510
|
+
import_node_path12.join(home, "Library", "Application Support", "Antigravity", "app_storage.json")
|
|
11511
|
+
].filter(Boolean);
|
|
11512
|
+
for (const file of candidates) {
|
|
11513
|
+
try {
|
|
11514
|
+
if (import_node_fs11.existsSync(file)) {
|
|
11515
|
+
const raw = import_node_fs11.readFileSync(file, "utf8");
|
|
11516
|
+
const json = JSON.parse(raw);
|
|
11517
|
+
const username = json["jetski.onboarding.lastLoginUsername"];
|
|
11518
|
+
if (username && typeof username === "string" && username.trim()) {
|
|
11519
|
+
const u = username.trim();
|
|
11520
|
+
return {
|
|
11521
|
+
email: u,
|
|
11522
|
+
name: u.includes("@") ? u.split("@")[0] : u
|
|
11523
|
+
};
|
|
11524
|
+
}
|
|
11525
|
+
}
|
|
11526
|
+
} catch {}
|
|
11527
|
+
}
|
|
11528
|
+
const osUser = process.env.USERNAME || process.env.USER;
|
|
11529
|
+
if (osUser?.trim()) {
|
|
11530
|
+
return { name: osUser.trim() };
|
|
11531
|
+
}
|
|
11532
|
+
return {};
|
|
11533
|
+
}
|
|
11534
|
+
function resolveAntigravityLanguageServer() {
|
|
11535
|
+
const home = process.env.USERPROFILE || process.env.HOME || os2.homedir() || "";
|
|
11536
|
+
const appData = process.env.APPDATA || (process.platform === "win32" ? import_node_path12.join(home, "AppData", "Roaming") : "");
|
|
11537
|
+
const baseDirs = [
|
|
11538
|
+
appData ? import_node_path12.join(appData, "Antigravity IDE", "logs") : null,
|
|
11539
|
+
appData ? import_node_path12.join(appData, "Antigravity", "logs") : null,
|
|
11540
|
+
import_node_path12.join(home, ".config", "Antigravity IDE", "logs"),
|
|
11541
|
+
import_node_path12.join(home, ".config", "Antigravity", "logs"),
|
|
11542
|
+
import_node_path12.join(home, "Library", "Application Support", "Antigravity IDE", "logs"),
|
|
11543
|
+
import_node_path12.join(home, "Library", "Application Support", "Antigravity", "logs")
|
|
11544
|
+
].filter(Boolean);
|
|
11545
|
+
for (const base of baseDirs) {
|
|
11546
|
+
try {
|
|
11547
|
+
if (!import_node_fs11.existsSync(base))
|
|
11548
|
+
continue;
|
|
11549
|
+
const sessionDirs = import_node_fs11.readdirSync(base).map((d) => {
|
|
11550
|
+
try {
|
|
11551
|
+
return { name: d, time: import_node_fs11.statSync(import_node_path12.join(base, d)).mtimeMs };
|
|
11552
|
+
} catch {
|
|
11553
|
+
return null;
|
|
11554
|
+
}
|
|
11555
|
+
}).filter((d) => Boolean(d)).sort((a, b) => b.time - a.time);
|
|
11556
|
+
for (const s of sessionDirs) {
|
|
11557
|
+
const logFile = import_node_path12.join(base, s.name, "ls-main.log");
|
|
11558
|
+
if (import_node_fs11.existsSync(logFile)) {
|
|
11559
|
+
const content = import_node_fs11.readFileSync(logFile, "utf8");
|
|
11560
|
+
const csrfMatch = content.match(/--csrf_token\s+([a-f0-9\-]+)/);
|
|
11561
|
+
const portMatch = content.match(/LS started on port\s+(\d+)/) || content.match(/--https_server_port\s+(\d+)/);
|
|
11562
|
+
if (csrfMatch && portMatch) {
|
|
11563
|
+
return {
|
|
11564
|
+
port: parseInt(portMatch[1], 10),
|
|
11565
|
+
csrfToken: csrfMatch[1]
|
|
11566
|
+
};
|
|
11567
|
+
}
|
|
11568
|
+
}
|
|
11569
|
+
}
|
|
11570
|
+
} catch {}
|
|
11571
|
+
}
|
|
11572
|
+
try {
|
|
11573
|
+
let out = "";
|
|
11574
|
+
if (process.platform === "win32") {
|
|
11575
|
+
out = import_node_child_process4.execFileSync("powershell", [
|
|
11576
|
+
"-NoProfile",
|
|
11577
|
+
"-Command",
|
|
11578
|
+
`Get-CimInstance Win32_Process -Filter "Name like '%language_server%'" | Select-Object -ExpandProperty CommandLine`
|
|
11579
|
+
], { encoding: "utf8", timeout: 4000, windowsHide: true });
|
|
11580
|
+
} else {
|
|
11581
|
+
out = import_node_child_process4.execFileSync("ps", ["aux"], { encoding: "utf8", timeout: 4000 });
|
|
11582
|
+
}
|
|
11583
|
+
const lines = out.split(/\r?\n/);
|
|
11584
|
+
for (const l of lines) {
|
|
11585
|
+
const portMatch = l.match(/--https_server_port\s+(\d+)/);
|
|
11586
|
+
const csrfMatch = l.match(/--csrf_token\s+([a-f0-9\-]+)/);
|
|
11587
|
+
if (portMatch && csrfMatch) {
|
|
11588
|
+
return { port: parseInt(portMatch[1], 10), csrfToken: csrfMatch[1] };
|
|
11589
|
+
}
|
|
11590
|
+
}
|
|
11591
|
+
} catch {}
|
|
11592
|
+
return null;
|
|
11593
|
+
}
|
|
11096
11594
|
async function probeAgyQuota(options) {
|
|
11595
|
+
const acc = resolveAntigravityAccount();
|
|
11596
|
+
const lsInfo = resolveAntigravityLanguageServer();
|
|
11597
|
+
if (lsInfo) {
|
|
11598
|
+
try {
|
|
11599
|
+
let data = null;
|
|
11600
|
+
const prevReject = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
|
11601
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
11602
|
+
try {
|
|
11603
|
+
const res = await fetch(`https://127.0.0.1:${lsInfo.port}/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary`, {
|
|
11604
|
+
method: "POST",
|
|
11605
|
+
headers: {
|
|
11606
|
+
"Content-Type": "application/json",
|
|
11607
|
+
"x-codeium-csrf-token": lsInfo.csrfToken
|
|
11608
|
+
},
|
|
11609
|
+
body: JSON.stringify({}),
|
|
11610
|
+
signal: AbortSignal.timeout(4000),
|
|
11611
|
+
tls: { rejectUnauthorized: false }
|
|
11612
|
+
});
|
|
11613
|
+
if (res.ok) {
|
|
11614
|
+
data = await res.json();
|
|
11615
|
+
}
|
|
11616
|
+
} catch {
|
|
11617
|
+
try {
|
|
11618
|
+
const raw = import_node_child_process4.execFileSync(process.platform === "win32" ? "curl.exe" : "curl", [
|
|
11619
|
+
"-k",
|
|
11620
|
+
"-s",
|
|
11621
|
+
"-X",
|
|
11622
|
+
"POST",
|
|
11623
|
+
"-H",
|
|
11624
|
+
"Content-Type: application/json",
|
|
11625
|
+
"-H",
|
|
11626
|
+
`x-codeium-csrf-token: ${lsInfo.csrfToken}`,
|
|
11627
|
+
"-d",
|
|
11628
|
+
"{}",
|
|
11629
|
+
`https://127.0.0.1:${lsInfo.port}/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary`
|
|
11630
|
+
], { encoding: "utf8", timeout: 4000 });
|
|
11631
|
+
data = JSON.parse(raw);
|
|
11632
|
+
} catch {}
|
|
11633
|
+
} finally {
|
|
11634
|
+
if (prevReject !== undefined) {
|
|
11635
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = prevReject;
|
|
11636
|
+
} else {
|
|
11637
|
+
delete process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
|
11638
|
+
}
|
|
11639
|
+
}
|
|
11640
|
+
if (data?.response?.groups) {
|
|
11641
|
+
const groups = data.response.groups;
|
|
11642
|
+
const formatReset = (isoStr, fallbackDesc) => {
|
|
11643
|
+
if (fallbackDesc && fallbackDesc.includes("it will fully refresh in ")) {
|
|
11644
|
+
const m = fallbackDesc.match(/it will fully refresh in (.+?)\.?$/);
|
|
11645
|
+
if (m?.[1])
|
|
11646
|
+
return `Resets in ${m[1].trim()}`;
|
|
11647
|
+
}
|
|
11648
|
+
if (!isoStr)
|
|
11649
|
+
return;
|
|
11650
|
+
const diffMs = new Date(isoStr).getTime() - Date.now();
|
|
11651
|
+
if (diffMs <= 0)
|
|
11652
|
+
return "已重置";
|
|
11653
|
+
const totalMins = Math.floor(diffMs / 60000);
|
|
11654
|
+
const hours = Math.floor(totalMins / 60);
|
|
11655
|
+
const days = Math.floor(hours / 24);
|
|
11656
|
+
if (days > 0)
|
|
11657
|
+
return `Resets in ${days}d ${hours % 24}h`;
|
|
11658
|
+
return `Resets in ${hours}h ${totalMins % 60}m`;
|
|
11659
|
+
};
|
|
11660
|
+
const toWindow = (b, groupName, label, durMins) => {
|
|
11661
|
+
if (!b)
|
|
11662
|
+
return;
|
|
11663
|
+
const frac = typeof b.remainingFraction === "number" ? b.remainingFraction : 1;
|
|
11664
|
+
const percentLeft = Math.max(0, Math.min(100, Math.round(frac * 100)));
|
|
11665
|
+
const usedPercent = 100 - percentLeft;
|
|
11666
|
+
return {
|
|
11667
|
+
label,
|
|
11668
|
+
group: groupName,
|
|
11669
|
+
percentLeft,
|
|
11670
|
+
usedPercent,
|
|
11671
|
+
windowDurationMins: durMins,
|
|
11672
|
+
resetsAt: formatReset(b.resetTime, b.description)
|
|
11673
|
+
};
|
|
11674
|
+
};
|
|
11675
|
+
const geminiGroup = groups.find((g) => g.displayName?.toLowerCase().includes("gemini"));
|
|
11676
|
+
const thirdPartyGroup = groups.find((g) => g.displayName?.toLowerCase().includes("claude") || g.displayName?.toLowerCase().includes("gpt"));
|
|
11677
|
+
const gemini5h = geminiGroup?.buckets?.find((b) => b.displayName?.toLowerCase().includes("five hour") || b.bucketId?.includes("5h") || b.window === "5h");
|
|
11678
|
+
const geminiWeekly = geminiGroup?.buckets?.find((b) => b.displayName?.toLowerCase().includes("weekly") || b.bucketId?.includes("weekly") || b.window === "weekly");
|
|
11679
|
+
const tp5h = thirdPartyGroup?.buckets?.find((b) => b.displayName?.toLowerCase().includes("five hour") || b.bucketId?.includes("5h") || b.window === "5h");
|
|
11680
|
+
const tpWeekly = thirdPartyGroup?.buckets?.find((b) => b.displayName?.toLowerCase().includes("weekly") || b.bucketId?.includes("weekly") || b.window === "weekly");
|
|
11681
|
+
const primaryWindow = toWindow(gemini5h, "Gemini Models", "5-Hour limit", 300) || {
|
|
11682
|
+
label: "5-Hour limit",
|
|
11683
|
+
group: "Gemini Models",
|
|
11684
|
+
percentLeft: 100,
|
|
11685
|
+
usedPercent: 0,
|
|
11686
|
+
windowDurationMins: 300
|
|
11687
|
+
};
|
|
11688
|
+
const secondaryWindow = toWindow(geminiWeekly, "Gemini Models", "Weekly limit", 10080);
|
|
11689
|
+
const extraWindows = [
|
|
11690
|
+
toWindow(tp5h, "Claude and GPT models", "5-Hour limit", 300),
|
|
11691
|
+
toWindow(tpWeekly, "Claude and GPT models", "Weekly limit", 10080)
|
|
11692
|
+
].filter(Boolean);
|
|
11693
|
+
return {
|
|
11694
|
+
runtimeId: "agy",
|
|
11695
|
+
provider: "Google Antigravity",
|
|
11696
|
+
account: {
|
|
11697
|
+
email: acc.email,
|
|
11698
|
+
name: acc.name || "Google Developer",
|
|
11699
|
+
plan: "Google AI Pro",
|
|
11700
|
+
type: "gemini"
|
|
11701
|
+
},
|
|
11702
|
+
primaryWindow,
|
|
11703
|
+
secondaryWindow,
|
|
11704
|
+
extraWindows: extraWindows.length > 0 ? extraWindows : undefined,
|
|
11705
|
+
credits: {
|
|
11706
|
+
unlimited: true,
|
|
11707
|
+
balance: "unlimited"
|
|
11708
|
+
},
|
|
11709
|
+
status: "ok",
|
|
11710
|
+
updatedAt: Date.now()
|
|
11711
|
+
};
|
|
11712
|
+
}
|
|
11713
|
+
} catch {}
|
|
11714
|
+
}
|
|
11097
11715
|
const geminiHome = resolveGeminiHome2();
|
|
11098
11716
|
const hasAgyDir = import_node_fs11.existsSync(import_node_path12.join(geminiHome, "antigravity")) || import_node_fs11.existsSync(import_node_path12.join(geminiHome, "antigravity-cli"));
|
|
11099
11717
|
const hasApiKey = Boolean(process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY);
|
|
11100
|
-
const isAvailable = hasAgyDir || hasApiKey;
|
|
11718
|
+
const isAvailable = hasAgyDir || hasApiKey || Boolean(acc.email || acc.name);
|
|
11101
11719
|
if (!isAvailable) {
|
|
11102
11720
|
return {
|
|
11103
11721
|
runtimeId: "agy",
|
|
11104
11722
|
provider: "Google Antigravity",
|
|
11105
11723
|
status: "unauthorized",
|
|
11106
|
-
message: "
|
|
11724
|
+
message: "未检测到 Antigravity 登录凭据",
|
|
11107
11725
|
updatedAt: Date.now()
|
|
11108
11726
|
};
|
|
11109
11727
|
}
|
|
@@ -11111,21 +11729,41 @@ async function probeAgyQuota(options) {
|
|
|
11111
11729
|
runtimeId: "agy",
|
|
11112
11730
|
provider: "Google Antigravity",
|
|
11113
11731
|
account: {
|
|
11114
|
-
|
|
11732
|
+
email: acc.email,
|
|
11733
|
+
name: acc.name || "Google Developer",
|
|
11734
|
+
plan: "Google AI Pro",
|
|
11115
11735
|
type: "gemini"
|
|
11116
11736
|
},
|
|
11117
11737
|
primaryWindow: {
|
|
11118
11738
|
label: "5-Hour limit",
|
|
11739
|
+
group: "Gemini Models",
|
|
11119
11740
|
percentLeft: 100,
|
|
11120
11741
|
usedPercent: 0,
|
|
11121
11742
|
windowDurationMins: 300
|
|
11122
11743
|
},
|
|
11123
11744
|
secondaryWindow: {
|
|
11124
11745
|
label: "Weekly limit",
|
|
11746
|
+
group: "Gemini Models",
|
|
11125
11747
|
percentLeft: 100,
|
|
11126
11748
|
usedPercent: 0,
|
|
11127
11749
|
windowDurationMins: 10080
|
|
11128
11750
|
},
|
|
11751
|
+
extraWindows: [
|
|
11752
|
+
{
|
|
11753
|
+
label: "5-Hour limit",
|
|
11754
|
+
group: "Claude and GPT models",
|
|
11755
|
+
percentLeft: 100,
|
|
11756
|
+
usedPercent: 0,
|
|
11757
|
+
windowDurationMins: 300
|
|
11758
|
+
},
|
|
11759
|
+
{
|
|
11760
|
+
label: "Weekly limit",
|
|
11761
|
+
group: "Claude and GPT models",
|
|
11762
|
+
percentLeft: 100,
|
|
11763
|
+
usedPercent: 0,
|
|
11764
|
+
windowDurationMins: 10080
|
|
11765
|
+
}
|
|
11766
|
+
],
|
|
11129
11767
|
credits: {
|
|
11130
11768
|
unlimited: true,
|
|
11131
11769
|
balance: "unlimited"
|
|
@@ -11186,7 +11824,7 @@ function getAcpRuntimeAdapter(runtimeId) {
|
|
|
11186
11824
|
}
|
|
11187
11825
|
|
|
11188
11826
|
// src/process/process-manager.ts
|
|
11189
|
-
var
|
|
11827
|
+
var import_node_child_process5 = require("node:child_process");
|
|
11190
11828
|
var active = new Map;
|
|
11191
11829
|
var ACP_EARLY_EXIT_STDERR_TAIL_LINES = 20;
|
|
11192
11830
|
function isSpawnedAcpProcessAlive(handle) {
|
|
@@ -11197,7 +11835,7 @@ function killProcessTree(pid) {
|
|
|
11197
11835
|
if (process.platform !== "win32")
|
|
11198
11836
|
return;
|
|
11199
11837
|
try {
|
|
11200
|
-
|
|
11838
|
+
import_node_child_process5.spawnSync("taskkill", ["/F", "/T", "/PID", String(pid)], {
|
|
11201
11839
|
windowsHide: true,
|
|
11202
11840
|
timeout: 8000
|
|
11203
11841
|
});
|
|
@@ -11240,7 +11878,7 @@ function spawnAcpProcess(options) {
|
|
|
11240
11878
|
} else {
|
|
11241
11879
|
delete env.NO_BROWSER;
|
|
11242
11880
|
}
|
|
11243
|
-
const child =
|
|
11881
|
+
const child = import_node_child_process5.spawn(file, options.runtime.args, {
|
|
11244
11882
|
cwd: options.cwd,
|
|
11245
11883
|
env,
|
|
11246
11884
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -11877,7 +12515,7 @@ async function restoreOrCreateAcpSession(input) {
|
|
|
11877
12515
|
}
|
|
11878
12516
|
|
|
11879
12517
|
// src/client/acp-terminal.ts
|
|
11880
|
-
var
|
|
12518
|
+
var import_node_child_process6 = require("node:child_process");
|
|
11881
12519
|
var import_node_crypto = require("node:crypto");
|
|
11882
12520
|
|
|
11883
12521
|
// src/transport/terminal-output-buffer.ts
|
|
@@ -11930,7 +12568,7 @@ class AcpTerminalManager {
|
|
|
11930
12568
|
throw new Error("terminal/create 需要 command");
|
|
11931
12569
|
const cwd = resolveCwd(params.cwd, params.workspaceRoot);
|
|
11932
12570
|
const outputByteLimit = typeof params.outputByteLimit === "number" && params.outputByteLimit > 0 ? params.outputByteLimit : DEFAULT_OUTPUT_BYTE_LIMIT;
|
|
11933
|
-
const child =
|
|
12571
|
+
const child = import_node_child_process6.spawn(command, params.args ?? [], {
|
|
11934
12572
|
cwd,
|
|
11935
12573
|
env: buildEnv(params.env),
|
|
11936
12574
|
windowsHide: true,
|
|
@@ -12026,7 +12664,7 @@ class AcpTerminalManager {
|
|
|
12026
12664
|
return;
|
|
12027
12665
|
if (process.platform === "win32") {
|
|
12028
12666
|
try {
|
|
12029
|
-
|
|
12667
|
+
import_node_child_process6.spawn("taskkill", ["/pid", String(pid), "/T", "/F"], {
|
|
12030
12668
|
windowsHide: true,
|
|
12031
12669
|
stdio: "ignore"
|
|
12032
12670
|
});
|
|
@@ -13212,7 +13850,7 @@ async function handleRpcRequest(id, method, params) {
|
|
|
13212
13850
|
}
|
|
13213
13851
|
}
|
|
13214
13852
|
function startSidecar() {
|
|
13215
|
-
const rl =
|
|
13853
|
+
const rl = readline2.createInterface({
|
|
13216
13854
|
input: process.stdin,
|
|
13217
13855
|
terminal: false
|
|
13218
13856
|
});
|