@ycodium-ai/agent-antigravity 0.2.3236 → 0.2.3240

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 +149 -101
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -26666,6 +26666,83 @@ function createAcpConnection(options2) {
26666
26666
  };
26667
26667
  }
26668
26668
 
26669
+ // ../../packages/ycodium-acp-executor/src/model-selection.ts
26670
+ function normalizeModelId(value) {
26671
+ return value?.trim() || void 0;
26672
+ }
26673
+ function modelSelectionStateFromSetup(setup) {
26674
+ const sessionModels = isRecord(setup.models) ? setup.models : void 0;
26675
+ const modelConfigId = extractModelConfigId(setup);
26676
+ const strategy = sessionModels === void 0 && modelConfigId !== void 0 ? "config-option" : "session/set_model";
26677
+ const modelConfigOption = modelConfigId === void 0 ? void 0 : findSessionConfigOption(setup.configOptions, modelConfigId);
26678
+ const configModel = modelConfigOption?.currentValue;
26679
+ const currentModelId = strategy === "config-option" ? typeof configModel === "string" ? normalizeModelId(configModel) : void 0 : typeof sessionModels?.["currentModelId"] === "string" ? normalizeModelId(sessionModels["currentModelId"]) : void 0;
26680
+ return {
26681
+ strategy,
26682
+ sessionModelsAdvertised: sessionModels !== void 0,
26683
+ modelConfigId,
26684
+ currentModelId,
26685
+ advertisedModelValues: strategy === "config-option" ? modelConfigOption === void 0 ? [] : collectSessionConfigOptionValues(modelConfigOption) : collectSessionModelIds(sessionModels),
26686
+ configOptions: setup.configOptions
26687
+ };
26688
+ }
26689
+
26690
+ // ../../packages/ycodium-acp-executor/src/mutex.ts
26691
+ var Mutex = class {
26692
+ locked = false;
26693
+ waiters = [];
26694
+ get isLocked() {
26695
+ return this.locked;
26696
+ }
26697
+ acquire() {
26698
+ if (!this.locked) {
26699
+ this.locked = true;
26700
+ return Promise.resolve();
26701
+ }
26702
+ return new Promise((resolve6) => {
26703
+ this.waiters.push(resolve6);
26704
+ });
26705
+ }
26706
+ tryAcquire() {
26707
+ if (this.locked) {
26708
+ return false;
26709
+ }
26710
+ this.locked = true;
26711
+ return true;
26712
+ }
26713
+ release() {
26714
+ const next = this.waiters.shift();
26715
+ if (next) {
26716
+ next();
26717
+ return;
26718
+ }
26719
+ this.locked = false;
26720
+ }
26721
+ async runExclusive(fn) {
26722
+ await this.acquire();
26723
+ try {
26724
+ return await fn();
26725
+ } finally {
26726
+ this.release();
26727
+ }
26728
+ }
26729
+ };
26730
+
26731
+ // ../../packages/ycodium-acp-executor/src/user-input-pending.ts
26732
+ var userInputAnswerOptionId = (question, answers) => {
26733
+ const answer = answers[question.id];
26734
+ const selected = typeof answer === "string" ? answer : Array.isArray(answer) && answer.length === 1 && typeof answer[0] === "string" ? answer[0] : void 0;
26735
+ return selected !== void 0 && question.options.some((option) => option.id === selected) ? selected : void 0;
26736
+ };
26737
+
26738
+ // ../../packages/ycodium-acp-executor/src/vendor-hooks.ts
26739
+ var defaultVendorHooks = {
26740
+ completedStopReason: (response) => response.stopReason
26741
+ };
26742
+
26743
+ // ../../packages/ycodium-acp-executor/src/executor/support.ts
26744
+ var DEFAULT_RESULT_DRAIN_TIMEOUT_MS = 2e3;
26745
+
26669
26746
  // ../../packages/ycodium-acp-executor/src/executor/lifecycle.ts
26670
26747
  function createExecutorLifecycle({
26671
26748
  failIfDisposed,
@@ -26808,16 +26885,30 @@ function createExecutorLifecycle({
26808
26885
  }
26809
26886
  };
26810
26887
  let disposing;
26811
- const dispose = () => {
26888
+ const dispose = (exitCode) => {
26812
26889
  if (disposing) return disposing;
26813
26890
  shared.disposing = true;
26814
- promptResults.stop();
26815
- settleAllApprovals("cancel");
26816
- settleAllUserInputs();
26817
- abortPendingSettlement("executor disposed");
26818
- notifyPromptSettled();
26819
- shared.abortLocalPrompt?.();
26820
26891
  disposing = (async () => {
26892
+ if (exitCode !== void 0) {
26893
+ let timer;
26894
+ await Promise.race([
26895
+ connection.closed.catch(() => void 0),
26896
+ new Promise((resolve6) => {
26897
+ timer = setTimeout(
26898
+ resolve6,
26899
+ options2.resultDrainTimeoutMs ?? DEFAULT_RESULT_DRAIN_TIMEOUT_MS
26900
+ );
26901
+ })
26902
+ ]);
26903
+ clearTimeout(timer);
26904
+ await promptResults.wait(void 0, true);
26905
+ }
26906
+ promptResults.stop();
26907
+ settleAllApprovals("cancel");
26908
+ settleAllUserInputs();
26909
+ abortPendingSettlement("executor disposed");
26910
+ notifyPromptSettled();
26911
+ shared.abortLocalPrompt?.();
26821
26912
  promptResults.finishUnreceived();
26822
26913
  await promptResults.wait();
26823
26914
  emit({
@@ -26825,7 +26916,10 @@ function createExecutorLifecycle({
26825
26916
  ...stamp(),
26826
26917
  provider: options2.provider,
26827
26918
  threadId: options2.threadId,
26828
- payload: { reason: "disposed" }
26919
+ payload: exitCode === void 0 ? { reason: "disposed" } : {
26920
+ reason: exitCode === null ? "process exited without an exit code" : `process exited with code ${exitCode}`,
26921
+ exitKind: exitCode === 0 ? "graceful" : "error"
26922
+ }
26829
26923
  });
26830
26924
  shared.disposed = true;
26831
26925
  shared.generation += 1;
@@ -26920,11 +27014,6 @@ var acpPromptFailureCategory = (error62, input2) => {
26920
27014
  return error62 instanceof AcpConnectionClosedError ? acpTransportIfEstablished(input2.sessionEstablished, input2.disposed) : void 0;
26921
27015
  };
26922
27016
 
26923
- // ../../packages/ycodium-acp-executor/src/vendor-hooks.ts
26924
- var defaultVendorHooks = {
26925
- completedStopReason: (response) => response.stopReason
26926
- };
26927
-
26928
27017
  // ../../packages/ycodium-acp-executor/src/executor/prompt.ts
26929
27018
  function createExecutorPrompt({
26930
27019
  isLive,
@@ -27030,8 +27119,12 @@ function createExecutorPrompt({
27030
27119
  }
27031
27120
  }
27032
27121
  };
27033
- const prompt = async (input2) => {
27122
+ const failIfPromptUnavailable = () => {
27034
27123
  failIfDisposed();
27124
+ if (shared.connectionClosed) throw new AcpExecutorDisposedError();
27125
+ };
27126
+ const prompt = async (input2) => {
27127
+ failIfPromptUnavailable();
27035
27128
  const started = requireStarted();
27036
27129
  let record2;
27037
27130
  const settle2 = (rest) => settleTurn({
@@ -27043,7 +27136,7 @@ function createExecutorPrompt({
27043
27136
  let turnId;
27044
27137
  await threadMutex.acquire();
27045
27138
  try {
27046
- failIfDisposed();
27139
+ failIfPromptUnavailable();
27047
27140
  turnId = selectPromptTurnId(
27048
27141
  input2,
27049
27142
  shared.promptsInFlight > 0 ? shared.activeTurnId : void 0,
@@ -27152,7 +27245,7 @@ function createExecutorPrompt({
27152
27245
  sessionEstablished: shared.startResult !== void 0,
27153
27246
  disposed: shared.disposed
27154
27247
  });
27155
- if (written && input2.onDispatched !== void 0 && !interruptedTurnIds.has(turnId)) {
27248
+ if (!interruptedTurnIds.has(turnId)) {
27156
27249
  const errorMessage2 = error62 instanceof Error && error62.message.trim() || "ACP prompt failed";
27157
27250
  if (settle2({
27158
27251
  turnId,
@@ -27160,7 +27253,7 @@ function createExecutorPrompt({
27160
27253
  state: "failed",
27161
27254
  errorMessage: errorMessage2,
27162
27255
  ...failureCategory === void 0 ? {} : { failureCategory }
27163
- }))
27256
+ }) && written && input2.onDispatched !== void 0)
27164
27257
  options2.log?.warn?.("turn failed after dispatch", {
27165
27258
  threadId: options2.threadId,
27166
27259
  failure: errorMessage2
@@ -27261,9 +27354,9 @@ function createPromptResults({
27261
27354
  }
27262
27355
  }
27263
27356
  };
27264
- const wait = async (turnId) => {
27357
+ const wait = async (turnId, includeUnreceived = false) => {
27265
27358
  const claimed = [...prompts.values()].filter(
27266
- (record2) => !record2.finished && record2.response !== void 0 && (turnId === void 0 || record2.turnId === turnId)
27359
+ (record2) => !record2.finished && (includeUnreceived || record2.response !== void 0) && (turnId === void 0 || record2.turnId === turnId)
27267
27360
  );
27268
27361
  if (claimed.length === 0) return;
27269
27362
  let timer;
@@ -27271,7 +27364,10 @@ function createPromptResults({
27271
27364
  const drained = await Promise.race([
27272
27365
  Promise.all(claimed.map((record2) => record2.done)).then(() => true),
27273
27366
  new Promise((resolve6) => {
27274
- timer = setTimeout(() => resolve6(false), options2.resultDrainTimeoutMs ?? 2e3);
27367
+ timer = setTimeout(
27368
+ () => resolve6(false),
27369
+ options2.resultDrainTimeoutMs ?? DEFAULT_RESULT_DRAIN_TIMEOUT_MS
27370
+ );
27275
27371
  })
27276
27372
  ]);
27277
27373
  if (drained) return;
@@ -27295,13 +27391,6 @@ function createPromptResults({
27295
27391
  return { add, receive, reject, stop, complete, hasInterrupted, forget, wait, finishUnreceived };
27296
27392
  }
27297
27393
 
27298
- // ../../packages/ycodium-acp-executor/src/user-input-pending.ts
27299
- var userInputAnswerOptionId = (question, answers) => {
27300
- const answer = answers[question.id];
27301
- const selected = typeof answer === "string" ? answer : Array.isArray(answer) && answer.length === 1 && typeof answer[0] === "string" ? answer[0] : void 0;
27302
- return selected !== void 0 && question.options.some((option) => option.id === selected) ? selected : void 0;
27303
- };
27304
-
27305
27394
  // ../../packages/ycodium-acp-executor/src/executor/requests.ts
27306
27395
  function createExecutorRequests({
27307
27396
  emit,
@@ -27865,27 +27954,6 @@ function acpInitializePayload(clientInfo, overrides) {
27865
27954
  };
27866
27955
  }
27867
27956
 
27868
- // ../../packages/ycodium-acp-executor/src/model-selection.ts
27869
- function normalizeModelId(value) {
27870
- return value?.trim() || void 0;
27871
- }
27872
- function modelSelectionStateFromSetup(setup) {
27873
- const sessionModels = isRecord(setup.models) ? setup.models : void 0;
27874
- const modelConfigId = extractModelConfigId(setup);
27875
- const strategy = sessionModels === void 0 && modelConfigId !== void 0 ? "config-option" : "session/set_model";
27876
- const modelConfigOption = modelConfigId === void 0 ? void 0 : findSessionConfigOption(setup.configOptions, modelConfigId);
27877
- const configModel = modelConfigOption?.currentValue;
27878
- const currentModelId = strategy === "config-option" ? typeof configModel === "string" ? normalizeModelId(configModel) : void 0 : typeof sessionModels?.["currentModelId"] === "string" ? normalizeModelId(sessionModels["currentModelId"]) : void 0;
27879
- return {
27880
- strategy,
27881
- sessionModelsAdvertised: sessionModels !== void 0,
27882
- modelConfigId,
27883
- currentModelId,
27884
- advertisedModelValues: strategy === "config-option" ? modelConfigOption === void 0 ? [] : collectSessionConfigOptionValues(modelConfigOption) : collectSessionModelIds(sessionModels),
27885
- configOptions: setup.configOptions
27886
- };
27887
- }
27888
-
27889
27957
  // ../../packages/ycodium-acp-executor/src/runtime-mode.ts
27890
27958
  function isRecord5(value) {
27891
27959
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -28482,47 +28550,6 @@ function createExecutorUpdates({
28482
28550
  return { emitCompactionState, handleSessionUpdate };
28483
28551
  }
28484
28552
 
28485
- // ../../packages/ycodium-acp-executor/src/mutex.ts
28486
- var Mutex = class {
28487
- locked = false;
28488
- waiters = [];
28489
- get isLocked() {
28490
- return this.locked;
28491
- }
28492
- acquire() {
28493
- if (!this.locked) {
28494
- this.locked = true;
28495
- return Promise.resolve();
28496
- }
28497
- return new Promise((resolve6) => {
28498
- this.waiters.push(resolve6);
28499
- });
28500
- }
28501
- tryAcquire() {
28502
- if (this.locked) {
28503
- return false;
28504
- }
28505
- this.locked = true;
28506
- return true;
28507
- }
28508
- release() {
28509
- const next = this.waiters.shift();
28510
- if (next) {
28511
- next();
28512
- return;
28513
- }
28514
- this.locked = false;
28515
- }
28516
- async runExclusive(fn) {
28517
- await this.acquire();
28518
- try {
28519
- return await fn();
28520
- } finally {
28521
- this.release();
28522
- }
28523
- }
28524
- };
28525
-
28526
28553
  // ../../packages/ycodium-acp-executor/src/openCommands.ts
28527
28554
  function readOpenToolCalls(toolCalls, turnId) {
28528
28555
  const running = [];
@@ -28894,10 +28921,10 @@ function createAcpExecutor(options2) {
28894
28921
  setNativeMode,
28895
28922
  compact,
28896
28923
  openToolCalls: () => readOpenToolCalls(toolCalls, shared.activeTurnId),
28897
- dispose: () => {
28924
+ dispose: (exitCode) => {
28898
28925
  disposeOnce ??= (async () => {
28899
28926
  try {
28900
- await disposeLifecycle();
28927
+ await disposeLifecycle(exitCode);
28901
28928
  } finally {
28902
28929
  await protocolLogSink?.close();
28903
28930
  }
@@ -28908,7 +28935,8 @@ function createAcpExecutor(options2) {
28908
28935
  }
28909
28936
 
28910
28937
  // ../../packages/ycodium-acp-executor/src/session-registry.ts
28911
- function createAcpSessionRegistry(threads, stopBooked) {
28938
+ function createAcpSessionRegistry(threads, stopBooked, log) {
28939
+ const exits = /* @__PURE__ */ new WeakMap();
28912
28940
  const requireThread = (threadId) => {
28913
28941
  const booked = threads.get(threadId);
28914
28942
  if (!booked) throw new Error(`unknown thread ${threadId}`);
@@ -28917,7 +28945,8 @@ function createAcpSessionRegistry(threads, stopBooked) {
28917
28945
  };
28918
28946
  const stopSession = (threadId, booked = threads.get(threadId)) => {
28919
28947
  if (!booked) return Promise.resolve();
28920
- booked.closing ??= Promise.resolve().then(() => stopBooked(booked)).then(() => {
28948
+ const close = { exitCode: exits.get(booked), hasExited: () => exits.has(booked) };
28949
+ booked.closing ??= Promise.resolve().then(() => stopBooked(booked, close)).then(() => {
28921
28950
  if (threads.get(threadId) === booked) threads.delete(threadId);
28922
28951
  }).catch((cause) => {
28923
28952
  if (threads.get(threadId) === booked) delete booked.closing;
@@ -28928,7 +28957,16 @@ function createAcpSessionRegistry(threads, stopBooked) {
28928
28957
  const stopAll = () => Promise.all([...threads].map(([threadId, booked]) => stopSession(threadId, booked))).then(
28929
28958
  () => void 0
28930
28959
  );
28931
- return { requireThread, stopSession, stopAll };
28960
+ const registerSession = (threadId, booked) => {
28961
+ threads.set(threadId, booked);
28962
+ void booked.handle.exited.then(async (exitCode) => {
28963
+ exits.set(booked, exitCode);
28964
+ await stopSession(threadId, booked);
28965
+ }).catch((cause) => {
28966
+ log?.warn("ACP process exit cleanup failed", { threadId, error: String(cause) });
28967
+ });
28968
+ };
28969
+ return { requireThread, registerSession, stopSession, stopAll };
28932
28970
  }
28933
28971
 
28934
28972
  // ../../packages/ycodium-acp-executor/src/session-cleanup.ts
@@ -28941,8 +28979,11 @@ async function cleanupAcpSession(input2) {
28941
28979
  failures.push(new Error(`forwarding failed: ${String(cause)}`, { cause }));
28942
28980
  });
28943
28981
  for (const [step, cleanup] of [
28944
- ["executor.dispose", () => input2.executor.dispose()],
28945
- ["stopProcess", input2.stopProcess],
28982
+ ["executor.dispose", () => input2.executor.dispose(input2.processExit?.exitCode)],
28983
+ [
28984
+ "stopProcess",
28985
+ () => input2.processExit?.hasExited() ? Promise.resolve() : input2.stopProcess()
28986
+ ],
28946
28987
  ["forwarding", () => forwarding]
28947
28988
  ]) {
28948
28989
  try {
@@ -30440,6 +30481,7 @@ function createAntigravitySession({
30440
30481
  dirs,
30441
30482
  events,
30442
30483
  threads,
30484
+ registerSession,
30443
30485
  mutable,
30444
30486
  resolveInput,
30445
30487
  stopSession,
@@ -30643,7 +30685,7 @@ function createAntigravitySession({
30643
30685
  ...started.modelId === void 0 ? {} : { model: started.modelId },
30644
30686
  ...input2.bindingGeneration === void 0 ? {} : { bindingGeneration: input2.bindingGeneration }
30645
30687
  };
30646
- threads.set(input2.threadId, {
30688
+ registerSession(input2.threadId, {
30647
30689
  session,
30648
30690
  turns: [],
30649
30691
  executor,
@@ -32551,12 +32593,13 @@ async function createAntigravityInstance(config2, host, deps) {
32551
32593
  processEnv
32552
32594
  };
32553
32595
  const resolveExecutable = () => deps.runtime.resolve(resolveInput);
32554
- const stopBooked = async (booked) => {
32596
+ const stopBooked = async (booked, processExit) => {
32555
32597
  for (const stopped of booked.background.finish()) events.push(stopped);
32556
32598
  await cleanupAcpSession({
32557
32599
  executor: booked.executor,
32558
32600
  stopProcess: () => stopAgentProcess(booked.handle, exitWaitMs, host.log, clock),
32559
- forwarding: booked.forwarding
32601
+ forwarding: booked.forwarding,
32602
+ processExit
32560
32603
  });
32561
32604
  if (!await removeRuntimeTempDir(booked.runtimeTemp)) {
32562
32605
  host.log.warn("could not remove a runtime temp directory; it is swept on the next start", {
@@ -32564,7 +32607,11 @@ async function createAntigravityInstance(config2, host, deps) {
32564
32607
  });
32565
32608
  }
32566
32609
  };
32567
- const { requireThread, stopSession, stopAll } = createAcpSessionRegistry(threads, stopBooked);
32610
+ const { requireThread, registerSession, stopSession, stopAll } = createAcpSessionRegistry(
32611
+ threads,
32612
+ stopBooked,
32613
+ host.log
32614
+ );
32568
32615
  const helpers = createAntigravityTextGeneration({
32569
32616
  host,
32570
32617
  profile: dirs.profile,
@@ -32694,6 +32741,7 @@ async function createAntigravityInstance(config2, host, deps) {
32694
32741
  dirs,
32695
32742
  events,
32696
32743
  threads,
32744
+ registerSession,
32697
32745
  mutable,
32698
32746
  resolveInput,
32699
32747
  stopSession,
@@ -33879,7 +33927,7 @@ var executors = [
33879
33927
  ];
33880
33928
  var index_default = definePlugin({
33881
33929
  id: "agent-antigravity",
33882
- apiVersion: 25,
33930
+ apiVersion: 26,
33883
33931
  executors,
33884
33932
  activate(ctx) {
33885
33933
  const runtime = createRuntimeManager({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-antigravity",
3
- "version": "0.2.3236",
3
+ "version": "0.2.3240",
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.3236",
35
- "ycodium-acp-executor": "0.2.3236",
34
+ "@ycodium-ai/plugin-api": "0.2.3240",
35
+ "ycodium-acp-executor": "0.2.3240",
36
36
  "ycodium-executor-testing": "0.0.0"
37
37
  },
38
38
  "ycodium": {