@ycodium-ai/agent-antigravity 0.2.3122 → 0.2.3130

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 +46 -26
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -28742,6 +28742,18 @@ function acpAgentVersion(initializeResult) {
28742
28742
  }
28743
28743
  var MAX_VERSION_OUTPUT_BYTES = 64 * 1024;
28744
28744
 
28745
+ // src/clock.ts
28746
+ var realAgentClock = {
28747
+ now: () => Date.now(),
28748
+ delay(ms, callback) {
28749
+ const timer = setTimeout(callback, ms);
28750
+ timer.unref?.();
28751
+ return () => {
28752
+ clearTimeout(timer);
28753
+ };
28754
+ }
28755
+ };
28756
+
28745
28757
  // src/profile.ts
28746
28758
  import * as NodeCrypto2 from "node:crypto";
28747
28759
  import * as NodeFSP from "node:fs/promises";
@@ -29000,36 +29012,36 @@ async function* watchAgentStderr(source, onLoginPrompt, onBrowserHelperLine) {
29000
29012
  }
29001
29013
 
29002
29014
  // src/agentProcess.ts
29003
- async function waitForExit(handle, timeoutMs) {
29004
- let timer;
29015
+ async function waitForExit(handle, timeoutMs, clock) {
29016
+ let cancel = () => {
29017
+ };
29005
29018
  const exited = await Promise.race([
29006
29019
  handle.exited.then(
29007
29020
  () => true,
29008
29021
  () => true
29009
29022
  ),
29010
29023
  new Promise((resolve6) => {
29011
- timer = setTimeout(() => resolve6(false), timeoutMs);
29012
- timer.unref?.();
29024
+ cancel = clock.delay(timeoutMs, () => resolve6(false));
29013
29025
  })
29014
29026
  ]);
29015
- clearTimeout(timer);
29027
+ cancel();
29016
29028
  return exited;
29017
29029
  }
29018
- function stopAgentProcess(handle, exitWaitMs, log) {
29030
+ function stopAgentProcess(handle, exitWaitMs, log, clock = realAgentClock) {
29019
29031
  let stopping = stoppingByHandle.get(handle);
29020
29032
  if (stopping === void 0) {
29021
- stopping = terminate(handle, exitWaitMs, log);
29033
+ stopping = terminate(handle, exitWaitMs, log, clock);
29022
29034
  stoppingByHandle.set(handle, stopping);
29023
29035
  }
29024
29036
  return stopping;
29025
29037
  }
29026
29038
  var stoppingByHandle = /* @__PURE__ */ new WeakMap();
29027
- async function terminate(handle, exitWaitMs, log) {
29039
+ async function terminate(handle, exitWaitMs, log, clock) {
29028
29040
  await handle.kill("SIGTERM").catch(() => void 0);
29029
- if (await waitForExit(handle, exitWaitMs)) return;
29041
+ if (await waitForExit(handle, exitWaitMs, clock)) return;
29030
29042
  log.warn("the agent process ignored SIGTERM; killing it", { pid: handle.pid, exitWaitMs });
29031
29043
  await handle.kill("SIGKILL").catch(() => void 0);
29032
- if (await waitForExit(handle, exitWaitMs)) return;
29044
+ if (await waitForExit(handle, exitWaitMs, clock)) return;
29033
29045
  log.error("the agent process is still running after SIGKILL; leaving it behind", {
29034
29046
  pid: handle.pid,
29035
29047
  exitWaitMs
@@ -29062,6 +29074,7 @@ async function openAgentProcess(input2) {
29062
29074
  await removeRuntimeTempDir(directory);
29063
29075
  throw error62;
29064
29076
  }
29077
+ const clock = input2.clock ?? realAgentClock;
29065
29078
  const { readable, writable } = nodeStreamsFromHandle({
29066
29079
  stdout: filterAgentStdout(handle.stdout, { onLoginPrompt: input2.onLoginPrompt }),
29067
29080
  stderr: watchAgentStderr(handle.stderr, input2.onLoginPrompt, input2.onBrowserHelperLine),
@@ -29073,22 +29086,21 @@ async function openAgentProcess(input2) {
29073
29086
  const pending = connection.request(method, params);
29074
29087
  if (timeoutMs === void 0) return pending;
29075
29088
  return new Promise((resolve6, reject) => {
29076
- const timer = setTimeout(() => {
29089
+ const cancel = clock.delay(timeoutMs, () => {
29077
29090
  reject(
29078
29091
  new AntigravityAuthError(
29079
29092
  "agent-timeout",
29080
29093
  `Antigravity did not answer '${method}' in time. It may still be starting up; try again.`
29081
29094
  )
29082
29095
  );
29083
- }, timeoutMs);
29084
- timer.unref?.();
29096
+ });
29085
29097
  pending.then(
29086
29098
  (value) => {
29087
- clearTimeout(timer);
29099
+ cancel();
29088
29100
  resolve6(value);
29089
29101
  },
29090
29102
  (error62) => {
29091
- clearTimeout(timer);
29103
+ cancel();
29092
29104
  reject(error62);
29093
29105
  }
29094
29106
  );
@@ -29098,7 +29110,7 @@ async function openAgentProcess(input2) {
29098
29110
  const close = () => {
29099
29111
  closing ??= (async () => {
29100
29112
  await connection.close().catch(() => void 0);
29101
- await stopAgentProcess(handle, input2.exitWaitMs, input2.host.log);
29113
+ await stopAgentProcess(handle, input2.exitWaitMs, input2.host.log, clock);
29102
29114
  await removeRuntimeTempDir(directory);
29103
29115
  })();
29104
29116
  return closing;
@@ -30054,6 +30066,7 @@ function createAntigravitySession({
30054
30066
  platform: platform2,
30055
30067
  processEnv,
30056
30068
  exitWaitMs,
30069
+ clock,
30057
30070
  userHome,
30058
30071
  dirs,
30059
30072
  events,
@@ -30135,7 +30148,7 @@ function createAntigravitySession({
30135
30148
  if (sessionReady) {
30136
30149
  void noteSession(() => login.noteSessionSignedOut());
30137
30150
  host.log.warn("antigravity asked to sign in during a session; stopping the process");
30138
- void stopAgentProcess(handle, exitWaitMs, host.log);
30151
+ void stopAgentProcess(handle, exitWaitMs, host.log, clock);
30139
30152
  }
30140
30153
  };
30141
30154
  const { readable, writable, stderrTail } = nodeStreamsFromHandle2({
@@ -30282,7 +30295,7 @@ function createAntigravitySession({
30282
30295
  return session;
30283
30296
  } catch (error62) {
30284
30297
  await executor.dispose().catch(() => void 0);
30285
- await stopAgentProcess(handle, exitWaitMs, host.log);
30298
+ await stopAgentProcess(handle, exitWaitMs, host.log, clock);
30286
30299
  await forwarding.catch(() => void 0);
30287
30300
  await removeRuntimeTempDir(runtimeTemp);
30288
30301
  if (live.signInRequired || isSignInRequiredError(error62)) {
@@ -30876,6 +30889,7 @@ function createLoginController(deps) {
30876
30889
  const { host } = deps;
30877
30890
  const authDeadlineMs = deps.authDeadlineMs ?? AUTH_DEADLINE_MS;
30878
30891
  const startupMs = deps.startupTimeoutMs ?? AGENT_STARTUP_TIMEOUT_MS;
30892
+ const clock = deps.clock ?? realAgentClock;
30879
30893
  const forward = deps.forward ?? forwardCallback;
30880
30894
  const markerFile = signedInMarkerFile(deps.dirs.profile);
30881
30895
  const browserCommand = buildBrowserCommand({ nodePath: deps.nodePath, platform: deps.platform });
@@ -30944,6 +30958,7 @@ function createLoginController(deps) {
30944
30958
  platform: deps.platform,
30945
30959
  processEnv: deps.processEnv,
30946
30960
  exitWaitMs: deps.exitWaitMs,
30961
+ clock,
30947
30962
  clientInfo: deps.clientInfo,
30948
30963
  browserCommand: hooks.browser ? browserCommand : void 0,
30949
30964
  onLoginPrompt: hooks.onLoginPrompt,
@@ -31039,13 +31054,12 @@ function createLoginController(deps) {
31039
31054
  };
31040
31055
  const runSignIn = async (target) => {
31041
31056
  const guard = (promise2) => Promise.race([promise2, target.interrupted]);
31042
- const deadline = setTimeout(() => {
31057
+ const cancelDeadline = clock.delay(authDeadlineMs, () => {
31043
31058
  abortFlow(target, {
31044
31059
  kind: "failed",
31045
31060
  failure: failure2("expired", "Google sign-in expired. Start sign-in again.")
31046
31061
  });
31047
- }, authDeadlineMs);
31048
- deadline.unref?.();
31062
+ });
31049
31063
  const opening = open4({
31050
31064
  browser: true,
31051
31065
  onLoginPrompt: (detail) => receiveAuthorizationUrl(target, detail),
@@ -31089,7 +31103,7 @@ function createLoginController(deps) {
31089
31103
  });
31090
31104
  }
31091
31105
  } finally {
31092
- clearTimeout(deadline);
31106
+ cancelDeadline();
31093
31107
  const agent = await opening.catch(() => void 0);
31094
31108
  if (agent !== void 0) await release(agent);
31095
31109
  if (refreshAfter) requestRefresh();
@@ -31116,7 +31130,7 @@ function createLoginController(deps) {
31116
31130
  phase = "starting";
31117
31131
  authorizationUrl = null;
31118
31132
  error62 = null;
31119
- expiresAt = new Date(Date.now() + authDeadlineMs).toISOString();
31133
+ expiresAt = new Date(clock.now() + authDeadlineMs).toISOString();
31120
31134
  publish();
31121
31135
  target.done = track(runSignIn(target));
31122
31136
  return snapshot();
@@ -31812,6 +31826,7 @@ var TextGenerationRejection = class extends Error {
31812
31826
  };
31813
31827
  function createAntigravityTextGeneration(deps) {
31814
31828
  const timeoutMs = deps.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31829
+ const clock = deps.clock ?? realAgentClock;
31815
31830
  const running = /* @__PURE__ */ new Set();
31816
31831
  const runJson = async (request2) => {
31817
31832
  const { operation, signal } = request2;
@@ -31839,7 +31854,8 @@ function createAntigravityTextGeneration(deps) {
31839
31854
  const closeAll = async () => {
31840
31855
  stopped = true;
31841
31856
  await executor?.dispose().catch(() => void 0);
31842
- if (handle !== void 0) await stopAgentProcess(handle, deps.exitWaitMs, deps.host.log);
31857
+ if (handle !== void 0)
31858
+ await stopAgentProcess(handle, deps.exitWaitMs, deps.host.log, clock);
31843
31859
  await pump?.catch(() => void 0);
31844
31860
  if (runtimeTemp !== void 0) await removeRuntimeTempDir(runtimeTemp);
31845
31861
  if (workspace !== void 0) {
@@ -32133,6 +32149,7 @@ async function createAntigravityInstance(config2, host, deps) {
32133
32149
  const platform2 = deps.platform ?? HOST_PLATFORM;
32134
32150
  const processEnv = deps.processEnv ?? process.env;
32135
32151
  const exitWaitMs = deps.exitWaitMs ?? DEFAULT_EXIT_WAIT_MS;
32152
+ const clock = deps.clock ?? realAgentClock;
32136
32153
  const userHome = deps.userHome ?? resolveAntigravityUserHome(platform2, { ...processEnv, ...recipe.environment });
32137
32154
  const dirs = resolveAntigravityDirectories({
32138
32155
  dataDir: deps.dataDir,
@@ -32165,7 +32182,7 @@ async function createAntigravityInstance(config2, host, deps) {
32165
32182
  const stopBooked = async (booked) => {
32166
32183
  for (const stopped of booked.background.finish()) events.push(stopped);
32167
32184
  await booked.executor.dispose().catch(() => void 0);
32168
- await stopAgentProcess(booked.handle, exitWaitMs, host.log);
32185
+ await stopAgentProcess(booked.handle, exitWaitMs, host.log, clock);
32169
32186
  await booked.forwarding.catch(() => void 0);
32170
32187
  if (!await removeRuntimeTempDir(booked.runtimeTemp)) {
32171
32188
  host.log.warn("could not remove a runtime temp directory; it is swept on the next start", {
@@ -32181,6 +32198,7 @@ async function createAntigravityInstance(config2, host, deps) {
32181
32198
  platform: platform2,
32182
32199
  processEnv,
32183
32200
  exitWaitMs,
32201
+ clock,
32184
32202
  clientInfo: CLIENT_INFO,
32185
32203
  acquireExecutable: () => deps.runtime.acquire(resolveInput),
32186
32204
  ...deps.textGenerationTimeoutMs === void 0 ? {} : { timeoutMs: deps.textGenerationTimeoutMs }
@@ -32200,6 +32218,7 @@ async function createAntigravityInstance(config2, host, deps) {
32200
32218
  acquireExecutable: () => deps.runtime.acquire(resolveInput),
32201
32219
  stopSessions: stopAllSessions,
32202
32220
  exitWaitMs,
32221
+ clock,
32203
32222
  clientInfo: CLIENT_INFO,
32204
32223
  nodePath: deps.nodePath ?? process.execPath,
32205
32224
  ...deps.authDeadlineMs === void 0 ? {} : { authDeadlineMs: deps.authDeadlineMs },
@@ -32278,6 +32297,7 @@ async function createAntigravityInstance(config2, host, deps) {
32278
32297
  platform: platform2,
32279
32298
  processEnv,
32280
32299
  exitWaitMs,
32300
+ clock,
32281
32301
  userHome,
32282
32302
  dirs,
32283
32303
  events,
@@ -33478,7 +33498,7 @@ var executors = [
33478
33498
  ];
33479
33499
  var index_default = definePlugin({
33480
33500
  id: "agent-antigravity",
33481
- apiVersion: 13,
33501
+ apiVersion: 14,
33482
33502
  executors,
33483
33503
  activate(ctx) {
33484
33504
  const runtime = createRuntimeManager({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-antigravity",
3
- "version": "0.2.3122",
3
+ "version": "0.2.3130",
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-acp-executor": "0.2.3122",
35
- "@ycodium-ai/plugin-api": "0.2.3122",
34
+ "@ycodium-ai/plugin-api": "0.2.3130",
35
+ "ycodium-acp-executor": "0.2.3130",
36
36
  "ycodium-executor-testing": "0.0.0"
37
37
  },
38
38
  "ycodium": {