paseo-acp-agy 1.2.11 → 1.2.12

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.
@@ -610,7 +610,25 @@ export class ACPServer extends EventEmitter {
610
610
  }
611
611
  };
612
612
  try {
613
- const resultEvent = await session.process.sendPrompt(promptText, onStepUpdate);
613
+ let resultEvent;
614
+ try {
615
+ resultEvent = await session.process.sendPrompt(promptText, onStepUpdate);
616
+ }
617
+ catch (firstErr) {
618
+ const firstMsg = firstErr.message || "";
619
+ if (stepCount === 0 &&
620
+ !session.isCancelled &&
621
+ firstMsg.includes("agy process exited prematurely")) {
622
+ logger.warn("agy process exited before streaming any steps; retrying prompt with fresh process", {
623
+ sessionId,
624
+ error: firstMsg,
625
+ });
626
+ resultEvent = await session.process.sendPrompt(promptText, onStepUpdate);
627
+ }
628
+ else {
629
+ throw firstErr;
630
+ }
631
+ }
614
632
  const turnUsage = resultEvent.result?.usage;
615
633
  const numTurns = resultEvent.result?.num_turns || stepCount || 1;
616
634
  // Usage is billable even when the turn terminates with ERROR
@@ -642,12 +660,14 @@ export class ACPServer extends EventEmitter {
642
660
  }
643
661
  }
644
662
  catch (promptErr) {
645
- if (session.isCancelled) {
663
+ const errorMsg = promptErr.message || "Turn execution failed";
664
+ if (session.isCancelled ||
665
+ errorMsg.includes("cancelled") ||
666
+ errorMsg.includes("Turn was cancelled")) {
646
667
  if (!isNotification)
647
668
  this.sendSuccess(id, { stopReason: "cancelled" });
648
669
  }
649
670
  else {
650
- const errorMsg = promptErr.message || "Turn execution failed";
651
671
  logger.error("Error executing prompt turn", { error: errorMsg, sessionId });
652
672
  this.sendNotification(ACP_METHODS.SESSION_UPDATE, {
653
673
  sessionId: session.id,
@@ -399,6 +399,7 @@ export class AntigravityProcess extends EventEmitter {
399
399
  child.stderr.setEncoding("utf-8");
400
400
  let stdoutBuffer = "";
401
401
  let stderrBuffer = "";
402
+ const recentStderrLines = [];
402
403
  child.stdout.on("data", (chunk) => {
403
404
  this.emit("activity");
404
405
  stdoutBuffer += chunk;
@@ -424,8 +425,13 @@ export class AntigravityProcess extends EventEmitter {
424
425
  const lines = stderrBuffer.split("\n");
425
426
  stderrBuffer = lines.pop() || "";
426
427
  for (const line of lines) {
427
- if (line.trim())
428
- logger.warn("agy stderr: " + line.trim());
428
+ const trimmed = line.trim();
429
+ if (trimmed) {
430
+ logger.warn("agy stderr: " + trimmed);
431
+ recentStderrLines.push(trimmed);
432
+ if (recentStderrLines.length > 20)
433
+ recentStderrLines.shift();
434
+ }
429
435
  }
430
436
  });
431
437
  child.on("error", (err) => {
@@ -438,9 +444,24 @@ export class AntigravityProcess extends EventEmitter {
438
444
  });
439
445
  child.on("close", (code, signal) => {
440
446
  logger.info("agy process exited", { code, signal, pid: child.pid });
447
+ if (stderrBuffer.trim()) {
448
+ recentStderrLines.push(stderrBuffer.trim());
449
+ if (recentStderrLines.length > 20)
450
+ recentStderrLines.shift();
451
+ }
452
+ const stderrDiagnostic = recentStderrLines.join(" ").trim();
453
+ const exitDiagnostic = stderrDiagnostic
454
+ ? `agy process exited prematurely with code ${code} signal ${signal}: ${stderrDiagnostic}`
455
+ : `agy process exited prematurely with code ${code} signal ${signal}`;
441
456
  if (this.currentTurnPromise?.child === child) {
442
- this.currentTurnPromise.reject(new Error(`agy process exited prematurely with code ${code} signal ${signal}`));
457
+ const turn = this.currentTurnPromise;
443
458
  this.currentTurnPromise = null;
459
+ if (turn.cancelled) {
460
+ turn.reject(new Error("Turn was cancelled"));
461
+ }
462
+ else {
463
+ turn.reject(new Error(exitDiagnostic));
464
+ }
444
465
  }
445
466
  // The leader can die while a tool subprocess remains in its process
446
467
  // group. Keep the group identity long enough to reap those descendants.
@@ -742,6 +763,11 @@ export class AntigravityProcess extends EventEmitter {
742
763
  logger.info("Cancelling active agy turn", { hasChild: Boolean(active.child) });
743
764
  if (active.child) {
744
765
  const child = active.child;
766
+ // Immediately detach this.child so subsequent turns will NOT attach to this dying process!
767
+ if (this.child === child) {
768
+ this.child = null;
769
+ this.initialInfo = null;
770
+ }
745
771
  this.signalProcessTree(child, "SIGINT");
746
772
  setTimeout(() => {
747
773
  if (this.isProcessTreeAlive(child)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-acp-agy",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "description": "ACP (Agent Client Protocol) provider for Google Antigravity in Paseo and Zed",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",