@agentconnect.md/daemon 1.0.0-rc.279 → 1.0.0-rc.280

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.
@@ -9766,9 +9766,16 @@ var AcpHost = class {
9766
9766
  "pipe",
9767
9767
  "inherit"
9768
9768
  ],
9769
- env
9769
+ env,
9770
+ detached: process.platform !== "win32"
9770
9771
  });
9771
9772
  this.child = child;
9773
+ child.once("exit", () => {
9774
+ if (child.pid && process.platform !== "win32") try {
9775
+ process.kill(-child.pid, "SIGTERM");
9776
+ } catch {}
9777
+ if (this.child === child) this.child = void 0;
9778
+ });
9772
9779
  if (!child.stdin || !child.stdout) throw new Error("AcpHost: subprocess stdin/stdout are not piped");
9773
9780
  const stream = ndJsonStream(Writable.toWeb(child.stdin), Readable.toWeb(child.stdout));
9774
9781
  const self = this;
@@ -10025,26 +10032,42 @@ var AcpHost = class {
10025
10032
  async cancel(sessionId) {
10026
10033
  await this.conn.agent.notify(methods.agent.session.cancel, { sessionId });
10027
10034
  }
10028
- /** Stop the adapter child: SIGTERM, then escalate to SIGKILL if it hasn't exited
10029
- * within `deadlineMs` (a buggy/hung agent must never block daemon shutdown or an
10030
- * idle reap). Idempotent — the child handle is cleared up front so a concurrent
10031
- * stop (drain + reconcile racing) is a no-op rather than a double-kill. */
10035
+ /** Stop the adapter child: stdin EOF + SIGTERM, then escalate to SIGKILL if it
10036
+ * hasn't exited within `deadlineMs` (a buggy/hung agent must never block daemon
10037
+ * shutdown or an idle reap). Signals target the child's process group (it is
10038
+ * spawned detached) so they reach the real adapter behind an npx wrapper too.
10039
+ * Idempotent — the child handle is cleared up front so a concurrent stop (drain
10040
+ * + reconcile racing) is a no-op rather than a double-kill. */
10032
10041
  async stop(deadlineMs = 5e3) {
10033
10042
  const child = this.child;
10034
10043
  if (!child) return;
10035
10044
  this.child = void 0;
10036
- child.kill("SIGTERM");
10045
+ const kill = (sig) => {
10046
+ if (child.pid && process.platform !== "win32") try {
10047
+ process.kill(-child.pid, sig);
10048
+ return;
10049
+ } catch {}
10050
+ child.kill(sig);
10051
+ };
10052
+ if (child.exitCode !== null || child.signalCode !== null) return;
10053
+ try {
10054
+ child.stdin?.end();
10055
+ } catch {}
10056
+ kill("SIGTERM");
10037
10057
  await new Promise((resolve) => {
10038
10058
  let settled = false;
10059
+ let killFailsafe;
10039
10060
  const done = () => {
10040
10061
  if (settled) return;
10041
10062
  settled = true;
10042
10063
  clearTimeout(timer);
10064
+ clearTimeout(killFailsafe);
10043
10065
  resolve();
10044
10066
  };
10045
10067
  const timer = setTimeout(() => {
10046
10068
  this.opts.log?.warn(`acp: child ignored SIGTERM after ${deadlineMs}ms — sending SIGKILL`);
10047
- child.kill("SIGKILL");
10069
+ kill("SIGKILL");
10070
+ killFailsafe = setTimeout(done, 2e3);
10048
10071
  }, deadlineMs);
10049
10072
  child.once("exit", done);
10050
10073
  });
@@ -10053,4 +10076,4 @@ var AcpHost = class {
10053
10076
  //#endregion
10054
10077
  export { resolveRuntimes as S, writeMemoryFile as _, initGitInjection as a, cachedRuntimeNames as b, simpleGit as c, memoryProviderFor as d, MemoryConflictError as f, resolveInMemoryDir as g, listMemory as h, prepareWorkspace as i, createMemoryProvider as l, MemoryTooLargeError as m, installedRuntimes as n, probeGitVersion as o, MemoryPathError as p, prefetchWorkspace as r, sessionGitEnv as s, AcpHost as t, memoryKindOf as u, MEMORY_TOOL_NAMES as v, cachedRuntimeVersions as x, toolsForIntegrations as y };
10055
10078
 
10056
- //# sourceMappingURL=acp-host-BfCc6AlK.js.map
10079
+ //# sourceMappingURL=acp-host-CrjtbS3A.js.map