@hanhnd/agent-kit 1.0.18 → 1.0.19

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.
@@ -21212,20 +21212,32 @@ function registerAgentTools(server2) {
21212
21212
  const jobId = randomUUID();
21213
21213
  const child = spawn(usedAgent, agentArgs, {
21214
21214
  cwd: workspaceRoot,
21215
- env: { ...process.env, GEMINI_WORKSPACE: workspaceRoot }
21215
+ env: { ...process.env, GEMINI_WORKSPACE: workspaceRoot },
21216
+ detached: process.platform !== "win32"
21216
21217
  });
21218
+ const killTree = (sig) => {
21219
+ if (process.platform !== "win32" && child.pid) {
21220
+ try {
21221
+ process.kill(-child.pid, sig);
21222
+ } catch {
21223
+ child.kill(sig);
21224
+ }
21225
+ } else {
21226
+ child.kill(sig);
21227
+ }
21228
+ };
21217
21229
  job = {
21218
21230
  agent: usedAgent,
21219
21231
  process: child,
21220
21232
  startedAt: /* @__PURE__ */ new Date(),
21221
21233
  chunks: [],
21222
21234
  logStream,
21223
- timeoutHandle: setTimeout(() => child.kill("SIGTERM"), AGENT_TIMEOUT)
21235
+ timeoutHandle: setTimeout(() => killTree("SIGTERM"), AGENT_TIMEOUT)
21224
21236
  };
21225
21237
  jobRegistry.set(jobId, job);
21226
21238
  killChild = () => {
21227
- child.kill("SIGTERM");
21228
- setTimeout(() => child.kill("SIGKILL"), 5e3).unref();
21239
+ killTree("SIGTERM");
21240
+ setTimeout(() => killTree("SIGKILL"), 5e3).unref();
21229
21241
  };
21230
21242
  if (extra.signal.aborted) killChild();
21231
21243
  else extra.signal.addEventListener("abort", killChild);
@@ -86,23 +86,39 @@ export function registerAgentTools(server) {
86
86
  const { logPath: lp, logStream } = initAgentLog(workspaceRoot, taskSlug(task), usedAgent);
87
87
  logPath = lp;
88
88
  const jobId = randomUUID();
89
+ // detached=true on Unix creates a new process group so we can kill the
90
+ // entire tree (CLI + its sub-agents) with process.kill(-pid, signal).
89
91
  const child = spawn(usedAgent, agentArgs, {
90
92
  cwd: workspaceRoot,
91
93
  env: { ...process.env, GEMINI_WORKSPACE: workspaceRoot },
94
+ detached: process.platform !== 'win32',
92
95
  });
96
+ const killTree = (sig) => {
97
+ if (process.platform !== 'win32' && child.pid) {
98
+ try {
99
+ process.kill(-child.pid, sig);
100
+ }
101
+ catch {
102
+ child.kill(sig);
103
+ }
104
+ }
105
+ else {
106
+ child.kill(sig);
107
+ }
108
+ };
93
109
  job = {
94
110
  agent: usedAgent,
95
111
  process: child,
96
112
  startedAt: new Date(),
97
113
  chunks: [],
98
114
  logStream,
99
- timeoutHandle: setTimeout(() => child.kill('SIGTERM'), AGENT_TIMEOUT),
115
+ timeoutHandle: setTimeout(() => killTree('SIGTERM'), AGENT_TIMEOUT),
100
116
  };
101
117
  jobRegistry.set(jobId, job);
102
118
  // Kill child if the MCP request is cancelled (e.g. user presses ESC)
103
119
  killChild = () => {
104
- child.kill('SIGTERM');
105
- setTimeout(() => child.kill('SIGKILL'), 5000).unref();
120
+ killTree('SIGTERM');
121
+ setTimeout(() => killTree('SIGKILL'), 5000).unref();
106
122
  };
107
123
  if (extra.signal.aborted)
108
124
  killChild();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanhnd/agent-kit",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Super Engineer - Team of AI Agents for software development (Claude Code Plugin)",
5
5
  "type": "module",
6
6
  "main": "dist/kit-server.js",