@yitom/acp-client 0.1.14 → 0.1.15

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/index.js CHANGED
@@ -148,10 +148,19 @@ var BUILTIN_ACP_RUNTIMES = [
148
148
  args: ["-y", `${DEEPSEEK_DSH_NPM_PACKAGE}@latest`, "--profile", "acp"],
149
149
  requiredEnvKeys: ["DEEPSEEK_API_KEY"]
150
150
  },
151
+ {
152
+ id: "antigravity-cli",
153
+ name: "Antigravity",
154
+ description: "启动 Google Antigravity CLI 自带的 agy acp 服务",
155
+ authHint: "复用 Antigravity CLI 登录。需要登录时选择 Agent 提供的方式,或在终端运行 agy acp --login",
156
+ command: isWindowsPlatform() ? "agy.exe" : "agy",
157
+ args: ["acp"],
158
+ requiredEnvKeys: []
159
+ },
151
160
  {
152
161
  id: "agy",
153
- name: "agy",
154
- description: "经 bunx 直调官方桥 JS 入口(免安装,跨平台;版本跟随 bunx 解析)",
162
+ name: "Antigravity (legacy bridge)",
163
+ description: "通过 bunx 启动 @yitom/agy-acp-map,兼容旧会话 ID 和桥接扩展",
155
164
  authHint: "复用 Antigravity CLI 本地登录态;未登录先在本机终端完成 agy 登录后再连接",
156
165
  command: "bunx",
157
166
  args: ["-y", `${AGY_ACP_NPM_PACKAGE}@latest`],
@@ -162,7 +171,7 @@ function findBuiltinAcpRuntime(id) {
162
171
  return BUILTIN_ACP_RUNTIMES.find((item) => item.id === id);
163
172
  }
164
173
  // src/version.ts
165
- var ACP_CLIENT_VERSION = "0.1.14";
174
+ var ACP_CLIENT_VERSION = "0.1.15";
166
175
  // src/client/session-open.ts
167
176
  import { RequestError } from "@agentclientprotocol/sdk";
168
177
 
@@ -395,6 +404,8 @@ async function restoreOrCreateAcpSession(input) {
395
404
  return result;
396
405
  } catch (error) {
397
406
  lastError = errorMessage(error);
407
+ if (isAuthenticationRequired(lastError))
408
+ throw error;
398
409
  log("warn", "session restore failed", {
399
410
  method: rpcMethod,
400
411
  sessionId: resumeId,
@@ -426,7 +437,7 @@ async function restoreOrCreateAcpSession(input) {
426
437
  try {
427
438
  return await request("session/new", baseParams);
428
439
  } catch (firstError) {
429
- if (isTransientAcpTransportError(firstError))
440
+ if (isAuthenticationRequired(errorMessage(firstError)) || isTransientAcpTransportError(firstError))
430
441
  throw firstError;
431
442
  if ((input.mcpServers ?? []).length === 0)
432
443
  throw firstError;
@@ -1975,6 +1986,7 @@ var APP_RESOURCE_CAPABILITIES = {
1975
1986
  gemini: { entry: null, strategy: "compatibility", configHome: "GEMINI_CLI_HOME" },
1976
1987
  copilot: { entry: null, strategy: "compatibility", configHome: "COPILOT_HOME", candidateEntry: "COPILOT_CUSTOM_INSTRUCTIONS_DIRS" },
1977
1988
  "cursor-cli": { entry: null, strategy: "compatibility", configHome: "CURSOR_CONFIG_DIR" },
1989
+ "antigravity-cli": { entry: null, strategy: "compatibility", configHome: null },
1978
1990
  agy: { entry: "_meta.appResources.directory", strategy: "native-session", configHome: null },
1979
1991
  deepseek: { entry: null, strategy: "compatibility", configHome: null }
1980
1992
  };
@@ -3263,6 +3275,11 @@ var deepseekAdapter = {
3263
3275
  canSkipInteractiveAuth: () => false
3264
3276
  };
3265
3277
 
3278
+ // src/runtimes/agy/index.ts
3279
+ import { existsSync as existsSync17 } from "node:fs";
3280
+ import { homedir as homedir15 } from "node:os";
3281
+ import { delimiter as delimiter2, join as join20 } from "node:path";
3282
+
3266
3283
  // src/runtimes/agy/quota.ts
3267
3284
  import { existsSync as existsSync16, readFileSync as readFileSync9, readdirSync as readdirSync2, statSync as statSync3 } from "node:fs";
3268
3285
  import { join as join19 } from "node:path";
@@ -3370,6 +3387,7 @@ function resolveAntigravityLanguageServer() {
3370
3387
  return null;
3371
3388
  }
3372
3389
  async function probeAgyQuota(options) {
3390
+ const runtimeId = options?.runtimeId ?? "agy";
3373
3391
  const acc = resolveAntigravityAccount();
3374
3392
  const lsInfo = resolveAntigravityLanguageServer();
3375
3393
  if (lsInfo) {
@@ -3469,7 +3487,7 @@ async function probeAgyQuota(options) {
3469
3487
  toWindow(tpWeekly, "Claude and GPT models", "Weekly limit", 10080)
3470
3488
  ].filter(Boolean);
3471
3489
  return {
3472
- runtimeId: "agy",
3490
+ runtimeId,
3473
3491
  provider: "Google Antigravity",
3474
3492
  account: {
3475
3493
  email: acc.email,
@@ -3496,7 +3514,7 @@ async function probeAgyQuota(options) {
3496
3514
  const isAvailable = hasAgyDir || hasApiKey || Boolean(acc.email || acc.name);
3497
3515
  if (!isAvailable) {
3498
3516
  return {
3499
- runtimeId: "agy",
3517
+ runtimeId,
3500
3518
  provider: "Google Antigravity",
3501
3519
  status: "unauthorized",
3502
3520
  message: "未检测到 Antigravity 登录凭据",
@@ -3504,7 +3522,7 @@ async function probeAgyQuota(options) {
3504
3522
  };
3505
3523
  }
3506
3524
  return {
3507
- runtimeId: "agy",
3525
+ runtimeId,
3508
3526
  provider: "Google Antigravity",
3509
3527
  account: {
3510
3528
  email: acc.email,
@@ -3552,6 +3570,53 @@ async function probeAgyQuota(options) {
3552
3570
  }
3553
3571
 
3554
3572
  // src/runtimes/agy/index.ts
3573
+ function isExecutableOnPath(command, env, platform) {
3574
+ const pathValue = env.PATH ?? env.Path ?? "";
3575
+ if (!pathValue.trim())
3576
+ return false;
3577
+ const sep = platform === "win32" ? ";" : delimiter2;
3578
+ for (const dir of pathValue.split(sep)) {
3579
+ const trimmed = dir.trim().replace(/^"|"$/g, "");
3580
+ if (!trimmed)
3581
+ continue;
3582
+ try {
3583
+ if (existsSync17(join20(trimmed, command)))
3584
+ return true;
3585
+ } catch {}
3586
+ }
3587
+ return false;
3588
+ }
3589
+ function resolveAntigravityCliCommand(overrides) {
3590
+ const args = ["acp"];
3591
+ const platform = overrides?.platform ?? process.platform;
3592
+ const env = overrides?.env ?? process.env;
3593
+ const home = overrides?.home ?? homedir15();
3594
+ const binaries = platform === "win32" ? ["agy.exe", "agy.cmd"] : ["agy"];
3595
+ for (const binary of binaries) {
3596
+ if (isExecutableOnPath(binary, env, platform)) {
3597
+ return { command: binary, args };
3598
+ }
3599
+ }
3600
+ const candidates = [];
3601
+ if (platform === "win32") {
3602
+ const localAppData = env.LOCALAPPDATA?.trim() || (env.USERPROFILE?.trim() ? join20(env.USERPROFILE.trim(), "AppData", "Local") : "");
3603
+ const userProfile = env.USERPROFILE?.trim() || home;
3604
+ if (localAppData)
3605
+ candidates.push(join20(localAppData, "antigravity", "agy.exe"));
3606
+ if (userProfile)
3607
+ candidates.push(join20(userProfile, ".local", "bin", "agy.exe"));
3608
+ } else if (home) {
3609
+ candidates.push(join20(home, ".local", "bin", "agy"));
3610
+ }
3611
+ for (const candidate of candidates) {
3612
+ try {
3613
+ if (candidate && existsSync17(candidate)) {
3614
+ return { command: candidate, args };
3615
+ }
3616
+ } catch {}
3617
+ }
3618
+ return null;
3619
+ }
3555
3620
  function probeAgyAuth() {
3556
3621
  return {
3557
3622
  codexHome: "",
@@ -3575,6 +3640,16 @@ var agyAdapter = {
3575
3640
  canSkipInteractiveAuth: () => false,
3576
3641
  tryDirectSessionFirst: true
3577
3642
  };
3643
+ var antigravityCliAdapter = {
3644
+ id: "antigravity-cli",
3645
+ prepareAppResources: async ({ directory }) => prepareCompatibilityResources(directory, "runtime-not-supported"),
3646
+ probeAuth: () => probeAgyAuth(),
3647
+ probeQuota: (options) => probeAgyQuota({ ...options, runtimeId: "antigravity-cli" }),
3648
+ resolveSpawnCommand: () => resolveAntigravityCliCommand(),
3649
+ orderAuthMethods: (methods) => methods,
3650
+ canSkipInteractiveAuth: () => false,
3651
+ tryDirectSessionFirst: true
3652
+ };
3578
3653
 
3579
3654
  // src/runtimes/index.ts
3580
3655
  function getAcpRuntimeAdapter(runtimeId) {
@@ -3599,6 +3674,8 @@ function getAcpRuntimeAdapter(runtimeId) {
3599
3674
  return deepseekAdapter;
3600
3675
  case agyAdapter.id:
3601
3676
  return agyAdapter;
3677
+ case antigravityCliAdapter.id:
3678
+ return antigravityCliAdapter;
3602
3679
  default:
3603
3680
  return {
3604
3681
  id: runtimeId,
@@ -3883,9 +3960,10 @@ function registerAcpClientHandlers(app, deps) {
3883
3960
  try {
3884
3961
  const outcome = await deps.onPermission({
3885
3962
  sessionId: typeof params.sessionId === "string" ? params.sessionId : undefined,
3886
- params
3963
+ params,
3964
+ signal: ctx.signal
3887
3965
  });
3888
- return { outcome };
3966
+ return { outcome: !ctx.signal.aborted && isAcpPermissionOutcome(outcome, params) ? outcome : { outcome: "cancelled" } };
3889
3967
  } catch (error) {
3890
3968
  console.error("[acp] request_permission 失败", error);
3891
3969
  return { outcome: { outcome: "cancelled" } };
@@ -4022,26 +4100,23 @@ function permissionOptionId(option) {
4022
4100
  return option.id;
4023
4101
  return null;
4024
4102
  }
4103
+ function permissionOptions(params) {
4104
+ return Array.isArray(params.options) ? params.options.filter((option) => !!option && typeof option === "object") : [];
4105
+ }
4106
+ function isAcpPermissionOutcome(outcome, params) {
4107
+ if (!outcome || typeof outcome !== "object")
4108
+ return false;
4109
+ const value = outcome;
4110
+ if (value.outcome === "cancelled")
4111
+ return true;
4112
+ return value.outcome === "selected" && typeof value.optionId === "string" && value.optionId.length > 0 && permissionOptions(params).some((option) => permissionOptionId(option) === value.optionId);
4113
+ }
4025
4114
  function pickAllowOptionId(params) {
4026
- const options = params.options;
4027
- if (!Array.isArray(options))
4028
- return null;
4029
- for (const item of options) {
4030
- if (!item || typeof item !== "object")
4031
- continue;
4032
- const option = item;
4033
- const id = permissionOptionId(option);
4034
- const kind = typeof option.kind === "string" ? option.kind : "";
4035
- if (id && (kind.includes("allow") || kind === "allow_once" || kind === "allow_always")) {
4036
- return id;
4037
- }
4038
- }
4039
- for (const item of options) {
4040
- if (!item || typeof item !== "object")
4041
- continue;
4042
- const id = permissionOptionId(item);
4043
- if (id)
4044
- return id;
4115
+ const options = permissionOptions(params);
4116
+ for (const kind of ["allow_once", "allow", "allow_always"]) {
4117
+ const option = options.find((entry) => entry.kind === kind && permissionOptionId(entry));
4118
+ if (option)
4119
+ return permissionOptionId(option);
4045
4120
  }
4046
4121
  return null;
4047
4122
  }
@@ -4232,8 +4307,8 @@ class AcpTerminalManager {
4232
4307
 
4233
4308
  // src/client/acp-proxy-service.ts
4234
4309
  import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile6 } from "node:fs/promises";
4235
- import { existsSync as existsSync17 } from "node:fs";
4236
- import { join as join20 } from "node:path";
4310
+ import { existsSync as existsSync18 } from "node:fs";
4311
+ import { join as join21 } from "node:path";
4237
4312
  var DEFAULT_ACP_PROXY_SETTINGS = {
4238
4313
  enabled: false,
4239
4314
  host: "127.0.0.1",
@@ -4242,7 +4317,7 @@ var DEFAULT_ACP_PROXY_SETTINGS = {
4242
4317
  var PROXY_ENV_KEYS = ["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY"];
4243
4318
  var LOWERCASE_PROXY_ENV_KEYS = ["http_proxy", "https_proxy", "all_proxy", "no_proxy"];
4244
4319
  function proxyFilePath(dir) {
4245
- return join20(dir, "agent", "proxy.json");
4320
+ return join21(dir, "agent", "proxy.json");
4246
4321
  }
4247
4322
  function validate2(settings) {
4248
4323
  if (!settings.host.trim())
@@ -4254,7 +4329,7 @@ function validate2(settings) {
4254
4329
  }
4255
4330
  async function readAcpProxySettings(dir = getDefaultAgentDataDir()) {
4256
4331
  const file = proxyFilePath(dir);
4257
- if (!existsSync17(file))
4332
+ if (!existsSync18(file))
4258
4333
  return { ...DEFAULT_ACP_PROXY_SETTINGS };
4259
4334
  try {
4260
4335
  const raw = JSON.parse(await readFile6(file, "utf8"));
@@ -4276,7 +4351,7 @@ async function saveAcpProxySettings(payload, dir = getDefaultAgentDataDir()) {
4276
4351
  host: payload.host.trim() || DEFAULT_ACP_PROXY_SETTINGS.host,
4277
4352
  port: payload.port
4278
4353
  };
4279
- await mkdir6(join20(dir, "agent"), { recursive: true });
4354
+ await mkdir6(join21(dir, "agent"), { recursive: true });
4280
4355
  await writeFile6(proxyFilePath(dir), JSON.stringify(stored, null, 2), "utf8");
4281
4356
  return ok(stored);
4282
4357
  }
@@ -4332,9 +4407,9 @@ function compatDeliveryKey(sessionId, generation, digest) {
4332
4407
  }
4333
4408
 
4334
4409
  // src/mcp/app-skills-mcp.ts
4335
- import { dirname as dirname6, join as join21 } from "node:path";
4410
+ import { dirname as dirname6, join as join22 } from "node:path";
4336
4411
  import { fileURLToPath } from "node:url";
4337
- import { existsSync as existsSync18, readFileSync as readFileSync10, statSync as statSync4 } from "node:fs";
4412
+ import { existsSync as existsSync19, readFileSync as readFileSync10, statSync as statSync4 } from "node:fs";
4338
4413
  var APP_SKILLS_MCP_SERVER_NAME = "app-skills";
4339
4414
  var APP_SKILLS_TOOLS = [
4340
4415
  {
@@ -4370,11 +4445,11 @@ function buildAppSkillsMcpServer(directory, opts) {
4370
4445
  function resolveAppSkillsRunnerPath(fromFile) {
4371
4446
  const base = fromFile ?? fileURLToPath(import.meta.url);
4372
4447
  const candidates = [
4373
- join21(dirname6(base), "app-skills-mcp-serve.cjs"),
4374
- join21(dirname6(base), "app-skills-mcp-serve.ts")
4448
+ join22(dirname6(base), "app-skills-mcp-serve.cjs"),
4449
+ join22(dirname6(base), "app-skills-mcp-serve.ts")
4375
4450
  ];
4376
4451
  for (const candidate of candidates) {
4377
- if (existsSync18(candidate))
4452
+ if (existsSync19(candidate))
4378
4453
  return candidate;
4379
4454
  }
4380
4455
  throw new Error(`技能 MCP 入口缺失(dist 未构建?): ${candidates[0]}`);
@@ -4411,10 +4486,10 @@ function isSupportedBridgeVersion(runtimeId, version) {
4411
4486
 
4412
4487
  // src/session/session-capabilities.ts
4413
4488
  function parseLoadSessionSupported(caps) {
4414
- return caps.loadSession === true;
4489
+ return caps?.loadSession === true;
4415
4490
  }
4416
4491
  function parseResumeSessionSupported(caps) {
4417
- const sessionCaps = caps.sessionCapabilities && typeof caps.sessionCapabilities === "object" ? caps.sessionCapabilities : null;
4492
+ const sessionCaps = caps?.sessionCapabilities && typeof caps.sessionCapabilities === "object" ? caps.sessionCapabilities : null;
4418
4493
  if (!sessionCaps)
4419
4494
  return false;
4420
4495
  const resume = sessionCaps.resume;
@@ -4480,6 +4555,7 @@ class AcpClient {
4480
4555
  commandsCache = new AvailableCommandsCache;
4481
4556
  quotaCache = new QuotaCache;
4482
4557
  runtimeInfo;
4558
+ hasCustomRuntime;
4483
4559
  adapter;
4484
4560
  workspaceRoot;
4485
4561
  clientInfo;
@@ -4488,6 +4564,8 @@ class AcpClient {
4488
4564
  configurationScope;
4489
4565
  sessionConfig = null;
4490
4566
  resourcesDir;
4567
+ authenticatingAgent;
4568
+ permissionRequests = new Map;
4491
4569
  processScopeKey = randomUUID2();
4492
4570
  callbacks;
4493
4571
  terminals = new AcpTerminalManager;
@@ -4544,8 +4622,10 @@ class AcpClient {
4544
4622
  const runtimeId = typeof options.runtime === "string" ? options.runtime : options.runtime?.id ?? DEFAULT_ACP_RUNTIME_ID;
4545
4623
  this.adapter = getAcpRuntimeAdapter(runtimeId);
4546
4624
  if (typeof options.runtime === "object" && options.runtime !== null) {
4625
+ this.hasCustomRuntime = true;
4547
4626
  this.runtimeInfo = options.runtime;
4548
4627
  } else {
4628
+ this.hasCustomRuntime = false;
4549
4629
  const found = findBuiltinAcpRuntime(runtimeId);
4550
4630
  if (!found) {
4551
4631
  throw new Error(`未知或未注册的 ACP 运行时模板: ${runtimeId}`);
@@ -4565,6 +4645,39 @@ class AcpClient {
4565
4645
  get initializeResponse() {
4566
4646
  return this.initResponse;
4567
4647
  }
4648
+ async authenticate(methodId) {
4649
+ const agent = this.sdkConnection?.agent;
4650
+ if (!agent || !this.isConnected) {
4651
+ return err({ code: "ACP_NOT_CONNECTED", message: "尚未连接到 Agent 服务端" });
4652
+ }
4653
+ const method = this.initResponse?.authMethods?.find((entry) => entry.id === methodId);
4654
+ if (!method) {
4655
+ return err({ code: "INVALID_ARGUMENT", message: "Agent 未声明此认证方式" });
4656
+ }
4657
+ if ("type" in method && method.type === "terminal") {
4658
+ return err({ code: "INVALID_ARGUMENT", message: "此认证方式需要在交互式终端中运行" });
4659
+ }
4660
+ if (this.authenticatingAgent === agent) {
4661
+ return err({ code: "INVALID_STATE", message: "Agent 正在认证" });
4662
+ }
4663
+ this.authenticatingAgent = agent;
4664
+ try {
4665
+ await sdkRequest(agent, methods2.agent.authenticate, { methodId });
4666
+ if (this.sdkConnection?.agent !== agent) {
4667
+ return err({ code: "CANCELLED", message: "认证期间 Agent 连接已关闭" });
4668
+ }
4669
+ return ok(undefined);
4670
+ } catch (error) {
4671
+ if (this.sdkConnection?.agent !== agent) {
4672
+ return err({ code: "CANCELLED", message: "认证期间 Agent 连接已关闭" });
4673
+ }
4674
+ const message = error instanceof Error ? error.message : String(error);
4675
+ return err({ code: isAuthenticationRequired(message) ? "UNAUTHORIZED" : "ACP_PROTOCOL_ERROR", message });
4676
+ } finally {
4677
+ if (this.authenticatingAgent === agent)
4678
+ this.authenticatingAgent = undefined;
4679
+ }
4680
+ }
4568
4681
  async connect() {
4569
4682
  if (this.inflightPrompts.size > 0)
4570
4683
  return err({ code: "ACP_PROTOCOL_ERROR", message: "Agent 正在回答,请结束后重新连接" });
@@ -4583,7 +4696,7 @@ class AcpClient {
4583
4696
  return err({ code: "ACP_SPAWN_ERROR", message: blocker });
4584
4697
  }
4585
4698
  let effectiveRuntime = { ...this.runtimeInfo };
4586
- if (this.adapter.resolveSpawnCommand) {
4699
+ if (!this.hasCustomRuntime && this.adapter.resolveSpawnCommand) {
4587
4700
  const resolved = this.adapter.resolveSpawnCommand();
4588
4701
  if (!resolved) {
4589
4702
  const message = `运行时 CLI 未安装: ${this.runtimeInfo.id}`;
@@ -4716,14 +4829,31 @@ class AcpClient {
4716
4829
  return this.callbacks.readSnapshot(resource);
4717
4830
  },
4718
4831
  onPermission: async (payload) => {
4719
- if (this.callbacks.onPermissionRequest) {
4720
- return this.callbacks.onPermissionRequest({
4832
+ const callback = this.callbacks.onPermissionRequest;
4833
+ const cancelled = { outcome: "cancelled" };
4834
+ if (!callback || payload.signal.aborted)
4835
+ return cancelled;
4836
+ const controller = new AbortController;
4837
+ const signal = AbortSignal.any([payload.signal, controller.signal]);
4838
+ this.permissionRequests.set(controller, payload.sessionId);
4839
+ let resolveCancellation;
4840
+ const cancellation = new Promise((resolve) => {
4841
+ resolveCancellation = resolve;
4842
+ });
4843
+ const onAbort = () => resolveCancellation(cancelled);
4844
+ signal.addEventListener("abort", onAbort, { once: true });
4845
+ try {
4846
+ const outcome = await Promise.race([cancellation, callback({
4721
4847
  sessionId: payload.sessionId,
4722
4848
  toolCall: payload.params?.toolCall,
4723
- params: payload.params
4724
- });
4849
+ params: payload.params,
4850
+ signal
4851
+ })]);
4852
+ return signal.aborted ? cancelled : outcome;
4853
+ } finally {
4854
+ signal.removeEventListener("abort", onAbort);
4855
+ this.permissionRequests.delete(controller);
4725
4856
  }
4726
- return { outcome: "cancelled" };
4727
4857
  },
4728
4858
  onSessionUpdate: (params) => {
4729
4859
  this.commandsCache.observe(params);
@@ -4880,7 +5010,7 @@ class AcpClient {
4880
5010
  return ok(handle);
4881
5011
  } catch (e) {
4882
5012
  const message = e instanceof Error ? e.message : String(e);
4883
- return err({ code: "ACP_PROTOCOL_ERROR", message });
5013
+ return err({ code: isAuthenticationRequired(message) ? "UNAUTHORIZED" : "ACP_PROTOCOL_ERROR", message });
4884
5014
  }
4885
5015
  }
4886
5016
  async promptSession(sessionId, promptText, options) {
@@ -4913,7 +5043,9 @@ class AcpClient {
4913
5043
  return ok(response);
4914
5044
  } catch (e) {
4915
5045
  const message = e instanceof Error ? e.message : String(e);
4916
- return err({ code: e instanceof AcpMcpRecoveryCancelledError ? "CANCELLED" : "ACP_PROTOCOL_ERROR", message });
5046
+ if (e instanceof AcpMcpRecoveryCancelledError)
5047
+ return err({ code: "CANCELLED", message });
5048
+ return err({ code: isAuthenticationRequired(message) ? "UNAUTHORIZED" : "ACP_PROTOCOL_ERROR", message });
4917
5049
  } finally {
4918
5050
  if (generation === this.connectionGen)
4919
5051
  this.inflightPrompts.delete(sessionId);
@@ -4956,7 +5088,9 @@ class AcpClient {
4956
5088
  if (!this.sdkConnection?.agent)
4957
5089
  return err({ code: "ACP_NOT_CONNECTED", message: "Agent is not connected" });
4958
5090
  try {
4959
- await this.sdkConnection.agent.notify(methods2.agent.session.cancel, { sessionId });
5091
+ const notifying = this.sdkConnection.agent.notify(methods2.agent.session.cancel, { sessionId });
5092
+ this.cancelPermissionRequests("session_cancelled", sessionId);
5093
+ await notifying;
4960
5094
  return ok(undefined);
4961
5095
  } catch (error) {
4962
5096
  return err({ code: "ACP_PROTOCOL_ERROR", message: error instanceof Error ? error.message : String(error) });
@@ -4982,6 +5116,7 @@ class AcpClient {
4982
5116
  ++this.connectionGen;
4983
5117
  this.mcpRecovery.reset();
4984
5118
  this.inflightPrompts.clear();
5119
+ this.cancelPermissionRequests("connection_closed");
4985
5120
  this.setStatus("disconnected", reason);
4986
5121
  this.resourcePrep = null;
4987
5122
  const capabilities = this.initResponse?.agentCapabilities?.sessionCapabilities;
@@ -5018,6 +5153,12 @@ class AcpClient {
5018
5153
  }
5019
5154
  }
5020
5155
  }
5156
+ cancelPermissionRequests(reason, sessionId) {
5157
+ for (const [controller, pendingSessionId] of this.permissionRequests) {
5158
+ if (sessionId === undefined || pendingSessionId === sessionId)
5159
+ controller.abort(reason);
5160
+ }
5161
+ }
5021
5162
  setStatus(status, detail) {
5022
5163
  this.status = status;
5023
5164
  this.callbacks.onStatusChange?.(status, detail);
@@ -6031,6 +6172,7 @@ export {
6031
6172
  acpReadTextFile,
6032
6173
  acpWriteTextFile,
6033
6174
  agyAdapter,
6175
+ antigravityCliAdapter,
6034
6176
  appendTerminalOutput,
6035
6177
  assertPathInsideWorkspace,
6036
6178
  buildAcpProxySpawnEnv,
@@ -6076,6 +6218,7 @@ export {
6076
6218
  handleInkdownMcpRpc,
6077
6219
  hasDeepseekHarnessCredentials,
6078
6220
  isAbsolutePathLike,
6221
+ isAcpPermissionOutcome,
6079
6222
  isAppError,
6080
6223
  isAuthenticationRequired,
6081
6224
  isBinaryDocumentPath,
@@ -6116,6 +6259,7 @@ export {
6116
6259
  prepareCompatibilityResources,
6117
6260
  prepareOpenCodeResources,
6118
6261
  probeAgyAuth,
6262
+ probeAgyQuota,
6119
6263
  probeClaudeAuth,
6120
6264
  probeClaudeQuota,
6121
6265
  probeCodexAuth,
@@ -6135,6 +6279,9 @@ export {
6135
6279
  readStoredAcpProvider,
6136
6280
  registerAcpClientHandlers,
6137
6281
  requestSessionWithResources,
6282
+ resolveAntigravityAccount,
6283
+ resolveAntigravityCliCommand,
6284
+ resolveAntigravityLanguageServer,
6138
6285
  resolveAppCodexHome,
6139
6286
  resolveClaudeHome,
6140
6287
  resolveCodexHome,
@@ -37,6 +37,11 @@ export declare const APP_RESOURCE_CAPABILITIES: {
37
37
  readonly strategy: 'compatibility';
38
38
  readonly configHome: 'CURSOR_CONFIG_DIR';
39
39
  };
40
+ readonly 'antigravity-cli': {
41
+ readonly entry: null;
42
+ readonly strategy: 'compatibility';
43
+ readonly configHome: null;
44
+ };
40
45
  readonly agy: {
41
46
  readonly entry: '_meta.appResources.directory';
42
47
  readonly strategy: 'native-session';
@@ -1,4 +1,19 @@
1
1
  import type { CodexAuthPreflight } from '../../contracts';
2
2
  import type { GenericRuntimeAdapter } from '../index';
3
+ export { probeAgyQuota, resolveAntigravityAccount, resolveAntigravityLanguageServer, } from './quota';
4
+ export interface AntigravityCliPathOverrides {
5
+ platform?: NodeJS.Platform;
6
+ env?: NodeJS.ProcessEnv;
7
+ home?: string;
8
+ }
9
+ /**
10
+ * Resolve `agy acp` spawn command from PATH or standard per-user install locations.
11
+ * Returns `null` when `agy` is not installed anywhere so connect() surfaces a clear ACP_SPAWN_ERROR.
12
+ */
13
+ export declare function resolveAntigravityCliCommand(overrides?: AntigravityCliPathOverrides): {
14
+ command: string;
15
+ args: string[];
16
+ } | null;
3
17
  export declare function probeAgyAuth(): CodexAuthPreflight;
4
18
  export declare const agyAdapter: GenericRuntimeAdapter;
19
+ export declare const antigravityCliAdapter: GenericRuntimeAdapter;
@@ -10,4 +10,5 @@ export declare function resolveAntigravityLanguageServer(): {
10
10
  } | null;
11
11
  export declare function probeAgyQuota(options?: {
12
12
  sessionId?: string;
13
+ runtimeId?: string;
13
14
  }): Promise<AcpAgentQuota | null>;
@@ -1,10 +1,10 @@
1
1
  /** 从 initialize 的 agentCapabilities 解析会话恢复与 prompt 能力 */
2
2
  import type { AcpPromptCapabilities } from "../contracts";
3
- export declare function parseLoadSessionSupported(caps: Record<string, unknown>): boolean;
3
+ export declare function parseLoadSessionSupported(caps?: Record<string, unknown> | null): boolean;
4
4
  /**
5
5
  * ACP:`sessionCapabilities.resume` 可为 `true` 或非空对象(codex-acp 用 `{}`)。
6
6
  */
7
- export declare function parseResumeSessionSupported(caps: Record<string, unknown>): boolean;
7
+ export declare function parseResumeSessionSupported(caps?: Record<string, unknown> | null): boolean;
8
8
  /** ACP:HTTP 传输的 MCP server 是可选能力,Agent 未声明时不能注入 */
9
9
  export declare function parseMcpHttpSupported(caps: Record<string, unknown>): boolean;
10
10
  export declare function parsePromptCapabilities(caps: Record<string, unknown>): AcpPromptCapabilities;