agent-valley 3.0.4 → 3.0.5

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "av",
4
- "version": "3.0.4",
4
+ "version": "3.0.5",
5
5
  "description": "Delegate repository goals to Agent Valley and inspect mission progress and verification evidence.",
6
6
  "author": {
7
7
  "name": "Agent Valley"
package/dist/index.js CHANGED
@@ -15926,13 +15926,16 @@ function signalProcessTree(proc, signal) {
15926
15926
  try {
15927
15927
  proc.kill(signal);
15928
15928
  } catch (handleError) {
15929
- if (handleError.code === "EPERM" && absent(-proc.pid) && absent(proc.pid))
15929
+ if (handleError.code === "EPERM" && rootAndGroupAbsent(proc.pid))
15930
15930
  return;
15931
15931
  throw handleError;
15932
15932
  }
15933
15933
  }
15934
15934
  }
15935
15935
  }
15936
+ function rootAndGroupAbsent(pid) {
15937
+ return absent(-pid) && absent(pid);
15938
+ }
15936
15939
  function absent(pid) {
15937
15940
  try {
15938
15941
  process.kill(pid, 0);
@@ -16380,6 +16383,15 @@ function waitForReap(proc, timeoutMs) {
16380
16383
  onExit();
16381
16384
  });
16382
16385
  }
16386
+ async function waitForRootAndGroupAbsence(pid, timeoutMs) {
16387
+ const deadline = Date.now() + Math.min(250, timeoutMs);
16388
+ while (Date.now() < deadline) {
16389
+ await new Promise((resolve) => setTimeout(resolve, Math.min(25, deadline - Date.now())));
16390
+ if (rootAndGroupAbsent(pid))
16391
+ return true;
16392
+ }
16393
+ return false;
16394
+ }
16383
16395
  function waitForStreamCompletion(proc, graceMs = 250) {
16384
16396
  return new Promise((resolve) => {
16385
16397
  if (!proc.stdout) {
@@ -16540,6 +16552,7 @@ class BaseSession {
16540
16552
  async terminateProcess(proc) {
16541
16553
  if (!proc.pid)
16542
16554
  return;
16555
+ const deadline = Date.now() + 5000;
16543
16556
  let signalError;
16544
16557
  try {
16545
16558
  signalProcessTree(proc, "SIGKILL");
@@ -16548,13 +16561,15 @@ class BaseSession {
16548
16561
  throw error;
16549
16562
  signalError = error;
16550
16563
  }
16551
- if (!await waitForReap(proc, 5000)) {
16564
+ if (!await waitForReap(proc, Math.max(0, deadline - Date.now()))) {
16552
16565
  throw signalError ?? new Error(`Agent process ${proc.pid} did not exit within 5000ms after SIGKILL; inspect it before retrying.`);
16553
16566
  }
16554
16567
  if (signalError) {
16555
16568
  try {
16556
16569
  signalProcessTree(proc, "SIGKILL");
16557
- } catch {
16570
+ } catch (retryError) {
16571
+ if (retryError.code === "EPERM" && await waitForRootAndGroupAbsence(proc.pid, Math.max(0, deadline - Date.now())))
16572
+ return;
16558
16573
  throw signalError;
16559
16574
  }
16560
16575
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-valley",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=26.10.0",