@ycodium-ai/agent-antigravity 0.2.2808 → 0.2.2834

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 +68 -53
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -25499,22 +25499,28 @@ function createAcpConnection(options2) {
25499
25499
  options2.readable.on("end", onEnd);
25500
25500
  options2.readable.on("error", onError);
25501
25501
  options2.writable.once("error", onWritableError);
25502
- const request2 = (async (method, params) => {
25502
+ const begin = (method, params) => {
25503
25503
  failIfClosed();
25504
25504
  const id = nextRequestId;
25505
25505
  nextRequestId += 1;
25506
25506
  const { promise: promise2, resolve: resolve6, reject } = Promise.withResolvers();
25507
25507
  pending.set(String(id), { method, resolve: resolve6, reject });
25508
25508
  const message = params === void 0 ? { jsonrpc: "2.0", id, method } : { jsonrpc: "2.0", id, method, params };
25509
- try {
25510
- await Promise.race([writeMessage(message), promise2]);
25511
- } catch (error62) {
25512
- if (pending.delete(String(id))) {
25513
- reject(error62);
25509
+ const written = Promise.race([writeMessage(message), promise2]).then(
25510
+ () => void 0,
25511
+ (error62) => {
25512
+ if (pending.delete(String(id))) {
25513
+ reject(error62);
25514
+ }
25515
+ throw error62;
25514
25516
  }
25515
- throw error62;
25516
- }
25517
- return promise2;
25517
+ );
25518
+ return { written, response: promise2 };
25519
+ };
25520
+ const request2 = (async (method, params) => {
25521
+ const { written, response } = begin(method, params);
25522
+ await written;
25523
+ return response;
25518
25524
  });
25519
25525
  const notify = async (method, params) => {
25520
25526
  failIfClosed();
@@ -25535,6 +25541,7 @@ function createAcpConnection(options2) {
25535
25541
  const close = (error62) => shutdown(error62 ?? new AcpConnectionClosedError());
25536
25542
  return {
25537
25543
  request: request2,
25544
+ begin,
25538
25545
  notify,
25539
25546
  awaitInboundIdle,
25540
25547
  close,
@@ -26967,6 +26974,13 @@ function modelSelectionStateFromSetup(setup) {
26967
26974
  };
26968
26975
  }
26969
26976
 
26977
+ // ../../packages/ycodium-acp-executor/src/user-input-pending.ts
26978
+ var userInputAnswerOptionId = (question, answers) => {
26979
+ const answer = answers[question.id];
26980
+ const selected = typeof answer === "string" ? answer : Array.isArray(answer) && answer.length === 1 && typeof answer[0] === "string" ? answer[0] : void 0;
26981
+ return selected !== void 0 && question.options.some((option) => option.id === selected) ? selected : void 0;
26982
+ };
26983
+
26970
26984
  // ../../packages/ycodium-acp-executor/src/vendor-hooks.ts
26971
26985
  var defaultVendorHooks = {
26972
26986
  completedStopReason: (response) => response.stopReason
@@ -26974,11 +26988,6 @@ var defaultVendorHooks = {
26974
26988
 
26975
26989
  // ../../packages/ycodium-acp-executor/src/executor.ts
26976
26990
  var DEFAULT_CANCEL_GRACE_MS = 5e3;
26977
- var userInputAnswerOptionId = (question, answers) => {
26978
- const answer = answers[question.id];
26979
- const selected = typeof answer === "string" ? answer : Array.isArray(answer) && answer.length === 1 && typeof answer[0] === "string" ? answer[0] : void 0;
26980
- return selected !== void 0 && question.options.some((option) => option.id === selected) ? selected : void 0;
26981
- };
26982
26991
  function defaultNowIso() {
26983
26992
  return (/* @__PURE__ */ new Date()).toISOString();
26984
26993
  }
@@ -27802,7 +27811,7 @@ function createAcpExecutor(options2) {
27802
27811
  };
27803
27812
  const settleTurn = (input2) => {
27804
27813
  if (!isLive(input2.expectedGeneration)) {
27805
- return;
27814
+ return false;
27806
27815
  }
27807
27816
  if (!acpPromptSettlementBelongsToContext({
27808
27817
  liveAcpSessionId: sessionId ?? "",
@@ -27811,37 +27820,40 @@ function createAcpExecutor(options2) {
27811
27820
  liveSessionActiveTurnId: activeTurnId,
27812
27821
  turnId: input2.turnId
27813
27822
  })) {
27814
- return;
27823
+ return false;
27815
27824
  }
27816
27825
  closeActiveAssistantSegment(input2.turnId);
27817
27826
  promptsInFlight = Math.max(0, promptsInFlight - 1);
27818
- if (promptsInFlight === 0 && activeTurnId === input2.turnId) {
27819
- activeTurnId = void 0;
27820
- if (status !== "disposed") {
27821
- status = "ready";
27822
- }
27823
- emit({
27824
- type: "turn.completed",
27825
- ...stamp(),
27826
- provider: options2.provider,
27827
- threadId: options2.threadId,
27828
- turnId: input2.turnId,
27829
- payload: {
27830
- state: input2.state,
27831
- stopReason: input2.stopReason
27832
- }
27833
- });
27834
- interruptedTurnIds.delete(input2.turnId);
27827
+ if (promptsInFlight !== 0 || activeTurnId !== input2.turnId) return false;
27828
+ activeTurnId = void 0;
27829
+ if (status !== "disposed") {
27830
+ status = "ready";
27835
27831
  }
27832
+ emit({
27833
+ type: "turn.completed",
27834
+ ...stamp(),
27835
+ provider: options2.provider,
27836
+ threadId: options2.threadId,
27837
+ turnId: input2.turnId,
27838
+ payload: {
27839
+ state: input2.state,
27840
+ stopReason: input2.stopReason,
27841
+ ...input2.errorMessage === void 0 ? {} : { errorMessage: input2.errorMessage }
27842
+ }
27843
+ });
27844
+ interruptedTurnIds.delete(input2.turnId);
27845
+ return true;
27836
27846
  };
27837
- const sendPromptRpc = async (sessionId2, promptParts) => {
27847
+ const sendPromptRpc = async (sessionId2, promptParts, onWritten) => {
27838
27848
  const settlementHooks = hooks.promptSettlement;
27839
27849
  const promptKey = settlementHooks === void 0 ? void 0 : randomId();
27840
- const promptRpc = connection.request("session/prompt", {
27850
+ const pending = connection.begin("session/prompt", {
27841
27851
  sessionId: sessionId2,
27842
27852
  prompt: promptParts,
27843
27853
  ...settlementHooks !== void 0 && promptKey !== void 0 ? settlementHooks.requestFields(promptKey) : {}
27844
27854
  });
27855
+ void pending.written.then(onWritten, () => void 0);
27856
+ const promptRpc = pending.response;
27845
27857
  if (settlementHooks === void 0 || promptKey === void 0) {
27846
27858
  return await promptRpc;
27847
27859
  } else {
@@ -27867,6 +27879,11 @@ function createAcpExecutor(options2) {
27867
27879
  const prompt = async (input2) => {
27868
27880
  failIfDisposed();
27869
27881
  const started = requireStarted();
27882
+ const settle2 = (rest) => settleTurn({
27883
+ expectedGeneration: started.generation,
27884
+ expectedSessionId: started.sessionId,
27885
+ ...rest
27886
+ });
27870
27887
  let turnId;
27871
27888
  await threadMutex.acquire();
27872
27889
  try {
@@ -27894,13 +27911,7 @@ function createAcpExecutor(options2) {
27894
27911
  try {
27895
27912
  failIfDisposed();
27896
27913
  if (interruptedTurnIds.has(turnId)) {
27897
- settleTurn({
27898
- expectedGeneration: started.generation,
27899
- expectedSessionId: started.sessionId,
27900
- turnId,
27901
- stopReason: "cancelled",
27902
- state: "cancelled"
27903
- });
27914
+ settle2({ turnId, stopReason: "cancelled", state: "cancelled" });
27904
27915
  return {
27905
27916
  threadId: options2.threadId,
27906
27917
  turnId,
@@ -27914,12 +27925,24 @@ function createAcpExecutor(options2) {
27914
27925
  expectedGeneration: started.generation
27915
27926
  });
27916
27927
  closeActiveAssistantSegment(turnId);
27928
+ let written = false;
27917
27929
  try {
27918
- response = await sendPromptRpc(started.sessionId, promptParts);
27930
+ response = await sendPromptRpc(started.sessionId, promptParts, () => {
27931
+ written = true;
27932
+ input2.onDispatched?.(turnId);
27933
+ });
27919
27934
  } catch (error62) {
27920
27935
  if (disposed) {
27921
27936
  throw new AcpExecutorDisposedError();
27922
27937
  }
27938
+ if (written && input2.onDispatched !== void 0 && !interruptedTurnIds.has(turnId)) {
27939
+ const errorMessage2 = error62 instanceof Error && error62.message.trim() || "ACP prompt failed";
27940
+ if (settle2({ turnId, stopReason: "error", state: "failed", errorMessage: errorMessage2 }))
27941
+ options2.log?.warn?.("turn failed after dispatch", {
27942
+ threadId: options2.threadId,
27943
+ failure: errorMessage2
27944
+ });
27945
+ }
27923
27946
  throw error62;
27924
27947
  }
27925
27948
  await connection.awaitInboundIdle();
@@ -27950,13 +27973,7 @@ function createAcpExecutor(options2) {
27950
27973
  }
27951
27974
  const finishPrompt = () => {
27952
27975
  if (interruptedTurnIds.has(settledTurnId)) {
27953
- settleTurn({
27954
- expectedGeneration: started.generation,
27955
- expectedSessionId: started.sessionId,
27956
- turnId: settledTurnId,
27957
- stopReason: "cancelled",
27958
- state: "cancelled"
27959
- });
27976
+ settle2({ turnId: settledTurnId, stopReason: "cancelled", state: "cancelled" });
27960
27977
  return {
27961
27978
  threadId: options2.threadId,
27962
27979
  turnId: settledTurnId,
@@ -27979,9 +27996,7 @@ function createAcpExecutor(options2) {
27979
27996
  }
27980
27997
  });
27981
27998
  }
27982
- settleTurn({
27983
- expectedGeneration: started.generation,
27984
- expectedSessionId: started.sessionId,
27999
+ settle2({
27985
28000
  turnId: settledTurnId,
27986
28001
  stopReason,
27987
28002
  state: response.stopReason === "cancelled" ? "cancelled" : "completed"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-antigravity",
3
- "version": "0.2.2808",
3
+ "version": "0.2.2834",
4
4
  "description": "Google Antigravity executor: runs the Antigravity agent over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -31,9 +31,9 @@
31
31
  "typescript": "~6.0.3",
32
32
  "vite-plus": "0.2.2",
33
33
  "yauzl": "^3.4.0",
34
- "ycodium-executor-testing": "0.0.0",
35
- "@ycodium-ai/plugin-api": "0.2.2808",
36
- "ycodium-acp-executor": "0.2.2808"
34
+ "@ycodium-ai/plugin-api": "0.2.2834",
35
+ "ycodium-acp-executor": "0.2.2834",
36
+ "ycodium-executor-testing": "0.0.0"
37
37
  },
38
38
  "ycodium": {
39
39
  "plugin": "./dist/index.js",