@yitom/acp-client 0.1.6 → 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.
@@ -1,5 +1,13 @@
1
1
  import type { AcpAgentQuota } from '../../contracts/quota';
2
2
  export declare function resolveGeminiHome(): string;
3
+ export declare function resolveAntigravityAccount(): {
4
+ email?: string;
5
+ name?: string;
6
+ };
7
+ export declare function resolveAntigravityLanguageServer(): {
8
+ port: number;
9
+ csrfToken: string;
10
+ } | null;
3
11
  export declare function probeAgyQuota(options?: {
4
12
  sessionId?: string;
5
13
  }): Promise<AcpAgentQuota | null>;
@@ -1,3 +1,3 @@
1
- import type { AcpAgentQuota } from '../../contracts/quota';
1
+ import type { AcpAgentQuota } from "../../contracts/quota";
2
2
  export declare function resolveOpencodeAuthPath(): string | null;
3
3
  export declare function probeOpencodeQuota(runtimeId?: string): Promise<AcpAgentQuota | null>;
package/dist/sidecar.cjs CHANGED
@@ -36,7 +36,7 @@ var __toESM = (mod, isNodeMode, target) => {
36
36
  var readline2 = __toESM(require("node:readline"), 1);
37
37
 
38
38
  // src/version.ts
39
- var ACP_CLIENT_VERSION = "0.1.6";
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 };
@@ -10349,8 +10349,8 @@ function decodeJwtPayload(token) {
10349
10349
  }
10350
10350
  }
10351
10351
  var cachedDynamicResult = null;
10352
- async function queryCodexAppServer(timeoutMs = 4000) {
10353
- if (cachedDynamicResult && Date.now() - cachedDynamicResult.time < 15000) {
10352
+ async function queryCodexAppServer(timeoutMs = 1e4) {
10353
+ if (cachedDynamicResult && Date.now() - cachedDynamicResult.time < 120000) {
10354
10354
  return cachedDynamicResult.res;
10355
10355
  }
10356
10356
  return new Promise((resolve) => {
@@ -10375,7 +10375,8 @@ async function queryCodexAppServer(timeoutMs = 4000) {
10375
10375
  };
10376
10376
  timer = setTimeout(() => cleanup(null), timeoutMs);
10377
10377
  try {
10378
- proc = import_node_child_process.spawn("codex", ["app-server"], {
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"], {
10379
10380
  stdio: ["pipe", "pipe", "pipe"],
10380
10381
  shell: process.platform === "win32",
10381
10382
  windowsHide: true
@@ -10476,7 +10477,7 @@ async function probeCodexQuota(options) {
10476
10477
  isLoggedIn = true;
10477
10478
  accountPlan = "API Key (Env)";
10478
10479
  }
10479
- const dynamic = await queryCodexAppServer(4000);
10480
+ const dynamic = await queryCodexAppServer(1e4);
10480
10481
  if (dynamic) {
10481
10482
  isLoggedIn = true;
10482
10483
  if (dynamic.account?.email)
@@ -10861,6 +10862,8 @@ var copilotAdapter = {
10861
10862
  // src/runtimes/opencode/quota.ts
10862
10863
  var import_node_fs8 = require("node:fs");
10863
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);
10864
10867
  function resolveOpencodeAuthPath() {
10865
10868
  const candidates = resolveOpencodeAuthCandidates();
10866
10869
  for (const c of candidates) {
@@ -10907,10 +10910,166 @@ async function queryOpencodeAuthList(timeoutMs = 1200) {
10907
10910
  }
10908
10911
  });
10909
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
+ }
10910
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
+ }
10911
11069
  const authPath = resolveOpencodeAuthPath();
10912
- let isLoggedIn = false;
10913
- let accountEmail;
11070
+ let isLoggedIn = Boolean(dbCreds.token || dbCreds.email);
11071
+ let accountEmail = dbCreds.email;
11072
+ let accountName = dbCreds.name;
10914
11073
  let plan = "OpenCode Community";
10915
11074
  if (authPath && import_node_fs8.existsSync(authPath)) {
10916
11075
  try {
@@ -10934,7 +11093,9 @@ async function probeOpencodeQuota(runtimeId = "opencode") {
10934
11093
  if (authList.length > 0) {
10935
11094
  isLoggedIn = true;
10936
11095
  const providers = authList.map((l) => l.split(/\s{2,}/)[0]).filter(Boolean);
10937
- if (providers.length > 0) {
11096
+ if (providers.some((p) => p.toLowerCase().includes("go"))) {
11097
+ plan = "OpenCode Go";
11098
+ } else if (providers.length > 0) {
10938
11099
  plan = `OpenCode (${providers.join(", ")})`;
10939
11100
  }
10940
11101
  }
@@ -10953,7 +11114,7 @@ async function probeOpencodeQuota(runtimeId = "opencode") {
10953
11114
  let credits;
10954
11115
  if (stats && typeof stats.cost === "number") {
10955
11116
  credits = {
10956
- balance: stats.cost > 0 ? `$${stats.cost.toFixed(2)} spent` : "0.00"
11117
+ balance: stats.cost > 0 ? `$${stats.cost.toFixed(2)} spent` : "$0.00"
10957
11118
  };
10958
11119
  }
10959
11120
  return {
@@ -10961,6 +11122,7 @@ async function probeOpencodeQuota(runtimeId = "opencode") {
10961
11122
  provider: "OpenCode",
10962
11123
  account: {
10963
11124
  email: accountEmail,
11125
+ name: accountName,
10964
11126
  plan,
10965
11127
  type: "provider_oauth"
10966
11128
  },
@@ -11326,21 +11488,240 @@ var deepseekAdapter = {
11326
11488
  // src/runtimes/agy/quota.ts
11327
11489
  var import_node_fs11 = require("node:fs");
11328
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);
11329
11493
  function resolveGeminiHome2() {
11330
11494
  const home = process.env.USERPROFILE || process.env.HOME || "";
11331
11495
  return import_node_path12.join(home, ".gemini");
11332
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
+ }
11333
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
+ }
11334
11715
  const geminiHome = resolveGeminiHome2();
11335
11716
  const hasAgyDir = import_node_fs11.existsSync(import_node_path12.join(geminiHome, "antigravity")) || import_node_fs11.existsSync(import_node_path12.join(geminiHome, "antigravity-cli"));
11336
11717
  const hasApiKey = Boolean(process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY);
11337
- const isAvailable = hasAgyDir || hasApiKey;
11718
+ const isAvailable = hasAgyDir || hasApiKey || Boolean(acc.email || acc.name);
11338
11719
  if (!isAvailable) {
11339
11720
  return {
11340
11721
  runtimeId: "agy",
11341
11722
  provider: "Google Antigravity",
11342
11723
  status: "unauthorized",
11343
- message: "wenjianlingu antigravity cli",
11724
+ message: "未检测到 Antigravity 登录凭据",
11344
11725
  updatedAt: Date.now()
11345
11726
  };
11346
11727
  }
@@ -11348,21 +11729,41 @@ async function probeAgyQuota(options) {
11348
11729
  runtimeId: "agy",
11349
11730
  provider: "Google Antigravity",
11350
11731
  account: {
11351
- plan: "Antigravity / Gemini",
11732
+ email: acc.email,
11733
+ name: acc.name || "Google Developer",
11734
+ plan: "Google AI Pro",
11352
11735
  type: "gemini"
11353
11736
  },
11354
11737
  primaryWindow: {
11355
11738
  label: "5-Hour limit",
11739
+ group: "Gemini Models",
11356
11740
  percentLeft: 100,
11357
11741
  usedPercent: 0,
11358
11742
  windowDurationMins: 300
11359
11743
  },
11360
11744
  secondaryWindow: {
11361
11745
  label: "Weekly limit",
11746
+ group: "Gemini Models",
11362
11747
  percentLeft: 100,
11363
11748
  usedPercent: 0,
11364
11749
  windowDurationMins: 10080
11365
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
+ ],
11366
11767
  credits: {
11367
11768
  unlimited: true,
11368
11769
  balance: "unlimited"
@@ -11423,7 +11824,7 @@ function getAcpRuntimeAdapter(runtimeId) {
11423
11824
  }
11424
11825
 
11425
11826
  // src/process/process-manager.ts
11426
- var import_node_child_process4 = require("node:child_process");
11827
+ var import_node_child_process5 = require("node:child_process");
11427
11828
  var active = new Map;
11428
11829
  var ACP_EARLY_EXIT_STDERR_TAIL_LINES = 20;
11429
11830
  function isSpawnedAcpProcessAlive(handle) {
@@ -11434,7 +11835,7 @@ function killProcessTree(pid) {
11434
11835
  if (process.platform !== "win32")
11435
11836
  return;
11436
11837
  try {
11437
- import_node_child_process4.spawnSync("taskkill", ["/F", "/T", "/PID", String(pid)], {
11838
+ import_node_child_process5.spawnSync("taskkill", ["/F", "/T", "/PID", String(pid)], {
11438
11839
  windowsHide: true,
11439
11840
  timeout: 8000
11440
11841
  });
@@ -11477,7 +11878,7 @@ function spawnAcpProcess(options) {
11477
11878
  } else {
11478
11879
  delete env.NO_BROWSER;
11479
11880
  }
11480
- const child = import_node_child_process4.spawn(file, options.runtime.args, {
11881
+ const child = import_node_child_process5.spawn(file, options.runtime.args, {
11481
11882
  cwd: options.cwd,
11482
11883
  env,
11483
11884
  stdio: ["pipe", "pipe", "pipe"],
@@ -12114,7 +12515,7 @@ async function restoreOrCreateAcpSession(input) {
12114
12515
  }
12115
12516
 
12116
12517
  // src/client/acp-terminal.ts
12117
- var import_node_child_process5 = require("node:child_process");
12518
+ var import_node_child_process6 = require("node:child_process");
12118
12519
  var import_node_crypto = require("node:crypto");
12119
12520
 
12120
12521
  // src/transport/terminal-output-buffer.ts
@@ -12167,7 +12568,7 @@ class AcpTerminalManager {
12167
12568
  throw new Error("terminal/create 需要 command");
12168
12569
  const cwd = resolveCwd(params.cwd, params.workspaceRoot);
12169
12570
  const outputByteLimit = typeof params.outputByteLimit === "number" && params.outputByteLimit > 0 ? params.outputByteLimit : DEFAULT_OUTPUT_BYTE_LIMIT;
12170
- const child = import_node_child_process5.spawn(command, params.args ?? [], {
12571
+ const child = import_node_child_process6.spawn(command, params.args ?? [], {
12171
12572
  cwd,
12172
12573
  env: buildEnv(params.env),
12173
12574
  windowsHide: true,
@@ -12263,7 +12664,7 @@ class AcpTerminalManager {
12263
12664
  return;
12264
12665
  if (process.platform === "win32") {
12265
12666
  try {
12266
- import_node_child_process5.spawn("taskkill", ["/pid", String(pid), "/T", "/F"], {
12667
+ import_node_child_process6.spawn("taskkill", ["/pid", String(pid), "/T", "/F"], {
12267
12668
  windowsHide: true,
12268
12669
  stdio: "ignore"
12269
12670
  });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const ACP_CLIENT_VERSION = "0.1.6";
1
+ export declare const ACP_CLIENT_VERSION = "0.1.7";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yitom/acp-client",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Headless ACP (Agent Client Protocol) SDK for connecting to Codex, Claude, Cursor, DeepSeek and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",