docks-kit 0.22.3 → 0.22.4
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.
|
@@ -133,6 +133,9 @@ export function spawnProcess(
|
|
|
133
133
|
child = spawn(invocation.command, [...invocation.args], {
|
|
134
134
|
stdio: options.stdio ?? ["ignore", "pipe", "ignore"],
|
|
135
135
|
...(options.cwd !== undefined ? { cwd: options.cwd } : {}),
|
|
136
|
+
// A bounded child leads its own process group on POSIX, so a timeout
|
|
137
|
+
// can end the processes that it started too (see killProcessTree).
|
|
138
|
+
...(options.timeoutMs !== undefined && !WINDOWS_PROCESS ? { detached: true } : {}),
|
|
136
139
|
windowsVerbatimArguments: invocation.windowsVerbatimArguments,
|
|
137
140
|
});
|
|
138
141
|
} catch (cause) {
|
|
@@ -165,15 +168,18 @@ export function spawnProcess(
|
|
|
165
168
|
child.once("error", (cause) => {
|
|
166
169
|
error ??= cause;
|
|
167
170
|
});
|
|
171
|
+
if (options.timeoutMs !== undefined) trackBoundedChild(child);
|
|
168
172
|
const timer =
|
|
169
173
|
options.timeoutMs === undefined
|
|
170
174
|
? undefined
|
|
171
175
|
: setTimeout(() => {
|
|
172
|
-
//
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
|
|
176
|
+
// A version proxy, such as rustup, runs the real tool as its own
|
|
177
|
+
// child, so end the whole process tree, not only the direct child.
|
|
178
|
+
// A process that holds the pipes could still keep them open, and
|
|
179
|
+
// "close" waits for the pipes. Close our ends and unref the child,
|
|
180
|
+
// so neither this promise nor the event loop waits for it.
|
|
181
|
+
killProcessTree(child);
|
|
182
|
+
boundedChildren.delete(child);
|
|
177
183
|
child.stdout?.destroy();
|
|
178
184
|
child.stderr?.destroy();
|
|
179
185
|
child.unref();
|
|
@@ -181,11 +187,64 @@ export function spawnProcess(
|
|
|
181
187
|
}, options.timeoutMs);
|
|
182
188
|
child.once("close", (exitCode) => {
|
|
183
189
|
clearTimeout(timer);
|
|
190
|
+
boundedChildren.delete(child);
|
|
184
191
|
resolve({ exitCode, stdout, stderr, ...(error !== undefined ? { error } : {}) });
|
|
185
192
|
});
|
|
186
193
|
return promise;
|
|
187
194
|
}
|
|
188
195
|
|
|
196
|
+
/**
|
|
197
|
+
* The kill strategy follows the real platform, not the injected `host`: the
|
|
198
|
+
* host only shapes command resolution and argv.
|
|
199
|
+
*/
|
|
200
|
+
const WINDOWS_PROCESS = process.platform === "win32";
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Bounded children that still run. On POSIX they lead their own process
|
|
204
|
+
* groups, so a terminal Ctrl-C does not reach them; when the CLI exits first,
|
|
205
|
+
* the exit handler ends their groups.
|
|
206
|
+
*/
|
|
207
|
+
const boundedChildren = new Set<ChildProcess>();
|
|
208
|
+
let exitHandlerInstalled = false;
|
|
209
|
+
|
|
210
|
+
function trackBoundedChild(child: ChildProcess): void {
|
|
211
|
+
boundedChildren.add(child);
|
|
212
|
+
if (exitHandlerInstalled) return;
|
|
213
|
+
exitHandlerInstalled = true;
|
|
214
|
+
process.once("exit", () => {
|
|
215
|
+
for (const running of boundedChildren) killProcessTree(running);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Ends `child` and every process it started. On POSIX the child leads its own
|
|
221
|
+
* process group (`detached`), so a signal to the negative pid reaches the
|
|
222
|
+
* group; the group id stays reserved while any member runs, so it cannot name
|
|
223
|
+
* an unrelated process. On Windows, `taskkill /T` ends the process tree; its
|
|
224
|
+
* absolute path keeps CreateProcess from finding a `taskkill` in the current
|
|
225
|
+
* directory. A child that already exited is skipped there, because Windows can
|
|
226
|
+
* give its pid to an unrelated process.
|
|
227
|
+
*/
|
|
228
|
+
function killProcessTree(child: ChildProcess): void {
|
|
229
|
+
const pid = child.pid;
|
|
230
|
+
if (pid === undefined) return;
|
|
231
|
+
if (WINDOWS_PROCESS) {
|
|
232
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
233
|
+
const taskkill = `${process.env["SystemRoot"] ?? "C:\\Windows"}\\System32\\taskkill.exe`;
|
|
234
|
+
spawnSync(taskkill, ["/pid", String(pid), "/T", "/F"], {
|
|
235
|
+
stdio: "ignore",
|
|
236
|
+
windowsHide: true,
|
|
237
|
+
});
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
process.kill(-pid, "SIGKILL");
|
|
242
|
+
} catch {
|
|
243
|
+
// The group is already gone; kill the child in case it left the group.
|
|
244
|
+
child.kill("SIGKILL");
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
189
248
|
export async function capture(cmd: string, args: ReadonlyArray<string>): Promise<string> {
|
|
190
249
|
const res = await spawnProcess(cmd, args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
191
250
|
if (res.error !== undefined || res.exitCode !== 0) return "";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by cli/scripts/generate-sot-payload.ts. DO NOT EDIT.
|
|
2
2
|
// Edit SoT/, notification.mp3, or package.json, then run: bun cli/scripts/generate-sot-payload.ts
|
|
3
3
|
|
|
4
|
-
export const GENERATED_PACKAGE_VERSION = "0.22.
|
|
4
|
+
export const GENERATED_PACKAGE_VERSION = "0.22.4"
|
|
5
5
|
|
|
6
6
|
export const GENERATED_PAYLOAD_TEXT = {
|
|
7
7
|
"SoT/.agents/skills.txt": "# Universal AI-agent skill manifest intentionally empty.\n# Global skill discovery is opt-in: add one slug per installed skill: <owner>/<repo>@<skill-name> (or a path to one skill directory).\n# EngineNative ignores comments and blank lines.\n",
|
package/cli/src/main.ts
CHANGED
|
@@ -95,6 +95,11 @@ const rawChannel = process.env["DOCKS_KIT_ENGINE"];
|
|
|
95
95
|
if (rawChannel === "native-raw" || rawChannel === "native-capture") {
|
|
96
96
|
const rawArgs = process.argv.slice(2);
|
|
97
97
|
const rawOperation = rawArgs.join(" ") || "default";
|
|
98
|
+
// The raw channels bypass BunRuntime.runMain, which turns a signal into
|
|
99
|
+
// process.exit. Without a handler a signal ends the process without the
|
|
100
|
+
// `exit` event, and exec.ts then cannot end its bounded probes.
|
|
101
|
+
process.once("SIGINT", () => process.exit(130));
|
|
102
|
+
process.once("SIGTERM", () => process.exit(143));
|
|
98
103
|
try {
|
|
99
104
|
process.exit(
|
|
100
105
|
await runEngineNative(rawArgs, undefined, { envGlobals: rawChannel === "native-raw" }),
|
package/package.json
CHANGED