@ycodium-ai/agent-antigravity 0.2.3020 → 0.2.3028

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.
Files changed (2) hide show
  1. package/dist/index.js +122 -68
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -26873,6 +26873,62 @@ function acpModelChoicesFromSessionModels(models) {
26873
26873
  return out;
26874
26874
  }
26875
26875
 
26876
+ // ../../packages/ycodium-acp-executor/src/apply-effort.ts
26877
+ var applyRequestedEffort = async (input2) => {
26878
+ const requested = input2.requestedEffort?.trim();
26879
+ if (!requested) return;
26880
+ const effort = findAcpEffortConfig(input2.configOptions);
26881
+ if (effort === void 0) return;
26882
+ const matched = effort.choices.find((choice) => choice.value === requested);
26883
+ if (matched === void 0) {
26884
+ input2.log?.info("requested effort is not in the agent catalog; keeping its own", {
26885
+ requestedEffort: requested,
26886
+ advertised: effort.choices.map((choice) => choice.value)
26887
+ });
26888
+ return;
26889
+ }
26890
+ if (matched.isDefault === true) return;
26891
+ if (!input2.isLive(input2.expectedGeneration)) return;
26892
+ try {
26893
+ await input2.connection.request("session/set_config_option", {
26894
+ sessionId: input2.acpSessionId,
26895
+ configId: effort.configId,
26896
+ value: requested
26897
+ });
26898
+ } catch (error62) {
26899
+ input2.log?.info("setting the effort level failed; the session keeps its own", {
26900
+ requestedEffort: requested,
26901
+ configId: effort.configId,
26902
+ error: error62 instanceof Error ? error62.message : String(error62)
26903
+ });
26904
+ }
26905
+ };
26906
+
26907
+ // ../../packages/ycodium-acp-executor/src/failureCategory.ts
26908
+ var ACP_FAILURE_CATEGORIES = [
26909
+ "quota",
26910
+ "rate-limit",
26911
+ "context-limit",
26912
+ "auth",
26913
+ "model-unavailable",
26914
+ "transport",
26915
+ "unknown"
26916
+ ];
26917
+ var isAcpFailureCategory = (value) => ACP_FAILURE_CATEGORIES.some((category) => category === value);
26918
+ var readAcpFailureCategory = (error62) => {
26919
+ if (typeof error62 !== "object" || error62 === null) return void 0;
26920
+ const value = error62.failureCategory;
26921
+ return isAcpFailureCategory(value) ? value : void 0;
26922
+ };
26923
+ var withFailureCategory = (error62, category) => category === void 0 ? error62 : Object.assign(error62, { failureCategory: category });
26924
+ var failureCategoryField = (category) => category === void 0 ? {} : { failureCategory: category };
26925
+ var acpTransportIfEstablished = (sessionEstablished, disposed) => sessionEstablished && !disposed ? "transport" : void 0;
26926
+ var acpPromptFailureCategory = (error62, input2) => {
26927
+ const signaled = readAcpFailureCategory(error62);
26928
+ if (signaled !== void 0) return signaled;
26929
+ return error62 instanceof AcpConnectionClosedError ? acpTransportIfEstablished(input2.sessionEstablished, input2.disposed) : void 0;
26930
+ };
26931
+
26876
26932
  // ../../packages/ycodium-acp-executor/src/runtime-mode.ts
26877
26933
  function isRecord5(value) {
26878
26934
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -26975,7 +27031,7 @@ var ACP_CONFIG_CATEGORY_HANDLING = {
26975
27031
  },
26976
27032
  thought_level: {
26977
27033
  consumed: true,
26978
- via: "config-options.ts:findAcpEffortConfig \u2192 executor.ts:applyRequestedEffort"
27034
+ via: "config-options.ts:findAcpEffortConfig \u2192 apply-effort.ts:applyRequestedEffort"
26979
27035
  },
26980
27036
  model_option: {
26981
27037
  consumed: true,
@@ -27463,11 +27519,16 @@ function createAcpExecutor(options2) {
27463
27519
  payload: { answers }
27464
27520
  });
27465
27521
  };
27466
- const abortPendingSettlement = (reason) => {
27522
+ const abortPendingSettlement = (reason, failureCategory) => {
27467
27523
  const waiting = pendingSettlement;
27468
27524
  if (waiting === void 0) return;
27469
27525
  pendingSettlement = void 0;
27470
- waiting.settle({ error: new AcpExecutorRequestError("session/prompt", reason) });
27526
+ waiting.settle({
27527
+ error: withFailureCategory(
27528
+ new AcpExecutorRequestError("session/prompt", reason),
27529
+ failureCategory
27530
+ )
27531
+ });
27471
27532
  };
27472
27533
  const settleAllUserInputs = () => {
27473
27534
  for (const pending of pendingUserInputs.values()) {
@@ -27491,9 +27552,12 @@ function createAcpExecutor(options2) {
27491
27552
  rememberSettledPromptKey(waiting.promptKey);
27492
27553
  if (signal.outcome === "error") {
27493
27554
  waiting.settle({
27494
- error: new AcpExecutorRequestError(
27495
- "session/prompt",
27496
- signal.detail ?? "prompt failed without an error detail"
27555
+ error: withFailureCategory(
27556
+ new AcpExecutorRequestError(
27557
+ "session/prompt",
27558
+ signal.detail ?? "prompt failed without an error detail"
27559
+ ),
27560
+ signal.failureCategory
27497
27561
  )
27498
27562
  });
27499
27563
  } else {
@@ -27648,7 +27712,10 @@ function createAcpExecutor(options2) {
27648
27712
  }
27649
27713
  settleAllApprovals("cancel");
27650
27714
  settleAllUserInputs();
27651
- abortPendingSettlement("connection closed");
27715
+ abortPendingSettlement(
27716
+ "connection closed",
27717
+ acpTransportIfEstablished(startResult !== void 0, disposed)
27718
+ );
27652
27719
  promptWaiters.splice(0).forEach((wake) => wake());
27653
27720
  },
27654
27721
  () => {
@@ -27703,35 +27770,6 @@ function createAcpExecutor(options2) {
27703
27770
  }
27704
27771
  return { ...input2.state, currentModelId: value, configOptions };
27705
27772
  };
27706
- const applyRequestedEffort = async (input2) => {
27707
- const requested = input2.requestedEffort?.trim();
27708
- if (!requested) return;
27709
- const effort = findAcpEffortConfig(input2.configOptions);
27710
- if (effort === void 0) return;
27711
- const matched = effort.choices.find((choice) => choice.value === requested);
27712
- if (matched === void 0) {
27713
- options2.log?.info("requested effort is not in the agent catalog; keeping its own", {
27714
- requestedEffort: requested,
27715
- advertised: effort.choices.map((choice) => choice.value)
27716
- });
27717
- return;
27718
- }
27719
- if (matched.isDefault === true) return;
27720
- if (!isLive(input2.expectedGeneration)) return;
27721
- try {
27722
- await connection.request("session/set_config_option", {
27723
- sessionId: input2.acpSessionId,
27724
- configId: effort.configId,
27725
- value: requested
27726
- });
27727
- } catch (error62) {
27728
- options2.log?.info("setting the effort level failed; the session keeps its own", {
27729
- requestedEffort: requested,
27730
- configId: effort.configId,
27731
- error: error62 instanceof Error ? error62.message : String(error62)
27732
- });
27733
- }
27734
- };
27735
27773
  const startOnce = async (expectedGeneration) => {
27736
27774
  const initializePayload = acpInitializePayload(options2.clientInfo, options2.clientCapabilities);
27737
27775
  const initialized = await connection.request(
@@ -27806,6 +27844,9 @@ function createAcpExecutor(options2) {
27806
27844
  expectedGeneration
27807
27845
  });
27808
27846
  await applyRequestedEffort({
27847
+ connection,
27848
+ log: options2.log,
27849
+ isLive,
27809
27850
  configOptions: nextModelSelectionState.configOptions,
27810
27851
  acpSessionId: nextSessionId,
27811
27852
  requestedEffort: options2.requestedEffort,
@@ -27928,7 +27969,8 @@ function createAcpExecutor(options2) {
27928
27969
  payload: {
27929
27970
  state: input2.state,
27930
27971
  stopReason: input2.stopReason,
27931
- ...input2.errorMessage === void 0 ? {} : { errorMessage: input2.errorMessage }
27972
+ ...input2.errorMessage === void 0 ? {} : { errorMessage: input2.errorMessage },
27973
+ ...input2.state === "failed" ? failureCategoryField(input2.failureCategory) : {}
27932
27974
  }
27933
27975
  });
27934
27976
  interruptedTurnIds.delete(input2.turnId);
@@ -28025,15 +28067,25 @@ function createAcpExecutor(options2) {
28025
28067
  if (disposed) {
28026
28068
  throw new AcpExecutorDisposedError();
28027
28069
  }
28070
+ const failureCategory = acpPromptFailureCategory(error62, {
28071
+ sessionEstablished: startResult !== void 0,
28072
+ disposed
28073
+ });
28028
28074
  if (written && input2.onDispatched !== void 0 && !interruptedTurnIds.has(turnId)) {
28029
28075
  const errorMessage2 = error62 instanceof Error && error62.message.trim() || "ACP prompt failed";
28030
- if (settle2({ turnId, stopReason: "error", state: "failed", errorMessage: errorMessage2 }))
28076
+ if (settle2({
28077
+ turnId,
28078
+ stopReason: "error",
28079
+ state: "failed",
28080
+ errorMessage: errorMessage2,
28081
+ ...failureCategory === void 0 ? {} : { failureCategory }
28082
+ }))
28031
28083
  options2.log?.warn?.("turn failed after dispatch", {
28032
28084
  threadId: options2.threadId,
28033
28085
  failure: errorMessage2
28034
28086
  });
28035
28087
  }
28036
- throw error62;
28088
+ throw error62 instanceof Error ? withFailureCategory(error62, failureCategory) : error62;
28037
28089
  }
28038
28090
  await connection.awaitInboundIdle();
28039
28091
  if (options2.beforeApplyResult) {
@@ -28677,17 +28729,38 @@ async function* watchAgentStderr(source, onLoginPrompt, onBrowserHelperLine) {
28677
28729
  // src/agentProcess.ts
28678
28730
  async function waitForExit(handle, timeoutMs) {
28679
28731
  let timer;
28680
- await Promise.race([
28732
+ const exited = await Promise.race([
28681
28733
  handle.exited.then(
28682
- () => void 0,
28683
- () => void 0
28734
+ () => true,
28735
+ () => true
28684
28736
  ),
28685
28737
  new Promise((resolve6) => {
28686
- timer = setTimeout(resolve6, timeoutMs);
28738
+ timer = setTimeout(() => resolve6(false), timeoutMs);
28687
28739
  timer.unref?.();
28688
28740
  })
28689
28741
  ]);
28690
28742
  clearTimeout(timer);
28743
+ return exited;
28744
+ }
28745
+ function stopAgentProcess(handle, exitWaitMs, log) {
28746
+ let stopping = stoppingByHandle.get(handle);
28747
+ if (stopping === void 0) {
28748
+ stopping = terminate(handle, exitWaitMs, log);
28749
+ stoppingByHandle.set(handle, stopping);
28750
+ }
28751
+ return stopping;
28752
+ }
28753
+ var stoppingByHandle = /* @__PURE__ */ new WeakMap();
28754
+ async function terminate(handle, exitWaitMs, log) {
28755
+ await handle.kill("SIGTERM").catch(() => void 0);
28756
+ if (await waitForExit(handle, exitWaitMs)) return;
28757
+ log.warn("the agent process ignored SIGTERM; killing it", { pid: handle.pid, exitWaitMs });
28758
+ await handle.kill("SIGKILL").catch(() => void 0);
28759
+ if (await waitForExit(handle, exitWaitMs)) return;
28760
+ log.error("the agent process is still running after SIGKILL; leaving it behind", {
28761
+ pid: handle.pid,
28762
+ exitWaitMs
28763
+ });
28691
28764
  }
28692
28765
  async function openAgentProcess(input2) {
28693
28766
  await prepareAntigravityProfile(input2.profile);
@@ -28752,8 +28825,7 @@ async function openAgentProcess(input2) {
28752
28825
  const close = () => {
28753
28826
  closing ??= (async () => {
28754
28827
  await connection.close().catch(() => void 0);
28755
- await handle.kill("SIGTERM").catch(() => void 0);
28756
- await waitForExit(handle, input2.exitWaitMs);
28828
+ await stopAgentProcess(handle, input2.exitWaitMs, input2.host.log);
28757
28829
  await removeRuntimeTempDir(directory);
28758
28830
  })();
28759
28831
  return closing;
@@ -30851,9 +30923,8 @@ function createAntigravityTextGeneration(deps) {
30851
30923
  const closeAll = async () => {
30852
30924
  stopped = true;
30853
30925
  await executor?.dispose().catch(() => void 0);
30854
- await handle?.kill("SIGTERM").catch(() => void 0);
30926
+ if (handle !== void 0) await stopAgentProcess(handle, deps.exitWaitMs, deps.host.log);
30855
30927
  await pump?.catch(() => void 0);
30856
- if (handle !== void 0) await waitForExit(handle, deps.exitWaitMs);
30857
30928
  if (runtimeTemp !== void 0) await removeRuntimeTempDir(runtimeTemp);
30858
30929
  if (workspace !== void 0) {
30859
30930
  await removeTemporarySessionFiles({ profile: deps.profile, sessionId, workspace });
@@ -31461,9 +31532,8 @@ async function createAntigravityInstance(config2, host, deps) {
31461
31532
  const stopBooked = async (booked) => {
31462
31533
  for (const stopped of booked.background.finish()) events.push(stopped);
31463
31534
  await booked.executor.dispose().catch(() => void 0);
31464
- await booked.handle.kill("SIGTERM").catch(() => void 0);
31535
+ await stopAgentProcess(booked.handle, exitWaitMs, host.log);
31465
31536
  await booked.forwarding.catch(() => void 0);
31466
- await waitForExit(booked.handle, exitWaitMs);
31467
31537
  if (!await removeRuntimeTempDir(booked.runtimeTemp)) {
31468
31538
  host.log.warn("could not remove a runtime temp directory; it is swept on the next start", {
31469
31539
  directory: booked.runtimeTemp
@@ -31705,7 +31775,7 @@ async function createAntigravityInstance(config2, host, deps) {
31705
31775
  if (sessionReady) {
31706
31776
  void noteSession(() => login.noteSessionSignedOut());
31707
31777
  host.log.warn("antigravity asked to sign in during a session; stopping the process");
31708
- void handle.kill("SIGTERM").catch(() => void 0);
31778
+ void stopAgentProcess(handle, exitWaitMs, host.log);
31709
31779
  }
31710
31780
  };
31711
31781
  const aborted2 = new Promise((_, reject) => {
@@ -31847,9 +31917,8 @@ async function createAntigravityInstance(config2, host, deps) {
31847
31917
  return session;
31848
31918
  } catch (error62) {
31849
31919
  await executor.dispose().catch(() => void 0);
31850
- await handle.kill("SIGTERM").catch(() => void 0);
31920
+ await stopAgentProcess(handle, exitWaitMs, host.log);
31851
31921
  await forwarding.catch(() => void 0);
31852
- await waitForExit(handle, exitWaitMs);
31853
31922
  await removeRuntimeTempDir(runtimeTemp);
31854
31923
  if (live.signInRequired || isSignInRequiredError(error62)) {
31855
31924
  await noteSession(() => login.noteSessionSignedOut());
@@ -32523,20 +32592,6 @@ function matchesExpectedRuntime(initializeResult, expectedVersion) {
32523
32592
  const auth = capabilities["auth"];
32524
32593
  return agentInfo["name"] === EXPECTED_AGENT_NAME && runtimeVersionNumber(acpAgentVersion(initializeResult) ?? "") === runtimeVersionNumber(expectedVersion) && initializeResult["protocolVersion"] === 1 && capabilities["loadSession"] === true && isRecord18(sessionCapabilities) && Boolean(sessionCapabilities["resume"]) && isRecord18(auth) && Boolean(auth["logout"]) && authMethods.some((method) => isRecord18(method) && method["id"] === "oauth-personal");
32525
32594
  }
32526
- async function waitForExit2(handle) {
32527
- let timer;
32528
- await Promise.race([
32529
- handle.exited.then(
32530
- () => void 0,
32531
- () => void 0
32532
- ),
32533
- new Promise((resolve6) => {
32534
- timer = setTimeout(resolve6, EXIT_WAIT_MS);
32535
- timer.unref?.();
32536
- })
32537
- ]);
32538
- clearTimeout(timer);
32539
- }
32540
32595
  async function validateInstalledRuntime(input2) {
32541
32596
  const platform2 = input2.platform ?? HOST_PLATFORM;
32542
32597
  const profileRoot = NodePath12.join(input2.dataDir, "tmp", "validate-profile");
@@ -32591,8 +32646,7 @@ async function validateInstalledRuntime(input2) {
32591
32646
  } finally {
32592
32647
  await closeHandshake?.().catch(() => void 0);
32593
32648
  if (handle !== void 0) {
32594
- await handle.kill("SIGTERM").catch(() => void 0);
32595
- await waitForExit2(handle);
32649
+ await stopAgentProcess(handle, EXIT_WAIT_MS, input2.host.log);
32596
32650
  }
32597
32651
  await removeRuntimeTempDir(runtimeTemp);
32598
32652
  await removeRuntimeTempDir(profile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-antigravity",
3
- "version": "0.2.3020",
3
+ "version": "0.2.3028",
4
4
  "description": "Google Antigravity executor: runs the Antigravity agent over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -31,8 +31,8 @@
31
31
  "typescript": "~6.0.3",
32
32
  "vite-plus": "0.2.2",
33
33
  "yauzl": "^3.4.0",
34
- "@ycodium-ai/plugin-api": "0.2.3020",
35
- "ycodium-acp-executor": "0.2.0",
34
+ "@ycodium-ai/plugin-api": "0.2.3028",
35
+ "ycodium-acp-executor": "0.2.3028",
36
36
  "ycodium-executor-testing": "0.0.0"
37
37
  },
38
38
  "ycodium": {