@mjasnikovs/pi-task 0.40.47 → 0.40.49
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.
- package/dist/shared/leftovers.js +7 -12
- package/dist/task/command-run.js +4 -1
- package/package.json +1 -1
package/dist/shared/leftovers.js
CHANGED
|
@@ -23,7 +23,7 @@ const USER_BASH_ENV = 'PI_TASK_USER_BASH_ENV';
|
|
|
23
23
|
/** Start tracking a child about to be spawned with `base` as its environment. */
|
|
24
24
|
export function trackLeftovers(platform, base, graceMs) {
|
|
25
25
|
if (platform === 'win32')
|
|
26
|
-
return trackShells(base
|
|
26
|
+
return trackShells(base);
|
|
27
27
|
if (platform === 'linux' || platform === 'darwin')
|
|
28
28
|
return trackToken(platform, base, graceMs);
|
|
29
29
|
return { env: base, reap: () => Promise.resolve() };
|
|
@@ -141,7 +141,7 @@ export const BASH_ENV_SCRIPT = [
|
|
|
141
141
|
`trap '__pi_task_now 1; printf "exited %s %s\\n" "$__pi_task_winpid" "$__pi_task_t" >> "$${SHELL_REGISTRY_ENV}"' EXIT`,
|
|
142
142
|
''
|
|
143
143
|
].join('\n');
|
|
144
|
-
function trackShells(base
|
|
144
|
+
function trackShells(base) {
|
|
145
145
|
let dir;
|
|
146
146
|
try {
|
|
147
147
|
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-task-shells-'));
|
|
@@ -165,8 +165,7 @@ function trackShells(base, graceMs) {
|
|
|
165
165
|
const shells = parseShells(fs.existsSync(registry) ? fs.readFileSync(registry, 'utf8') : '');
|
|
166
166
|
if (shells.length === 0)
|
|
167
167
|
return;
|
|
168
|
-
const
|
|
169
|
-
const started = startedByShells(parseProcessTable(table), shells);
|
|
168
|
+
const started = startedByShells(parseProcessTable(await processTable()), shells);
|
|
170
169
|
await Promise.all(started.map(taskkillTree));
|
|
171
170
|
}
|
|
172
171
|
catch {
|
|
@@ -238,22 +237,18 @@ export function parseProcessTable(text) {
|
|
|
238
237
|
return rows;
|
|
239
238
|
}
|
|
240
239
|
/**
|
|
241
|
-
* Every process as `pid ppid creation-FILETIME`, one per line.
|
|
242
|
-
*
|
|
240
|
+
* Every process as `pid ppid creation-FILETIME`, one per line. Not bounded: a cold
|
|
241
|
+
* WMI outlasted the kill grace on the windows runner, and a query cut short reaps nothing.
|
|
243
242
|
*/
|
|
244
|
-
function processTable(
|
|
243
|
+
function processTable() {
|
|
245
244
|
const query = 'Get-CimInstance Win32_Process -Property ProcessId,ParentProcessId,CreationDate'
|
|
246
245
|
+ ' | ForEach-Object { "$($_.ProcessId) $($_.ParentProcessId) $($_.CreationDate.ToFileTimeUtc())" }';
|
|
247
246
|
return new Promise(resolve => {
|
|
248
247
|
let out = '';
|
|
249
248
|
const ps = spawn(system32('WindowsPowerShell', 'v1.0', 'powershell.exe'), ['-NoProfile', '-NonInteractive', '-Command', query], { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
250
|
-
const giveUp = setTimeout(() => ps.kill(), graceMs);
|
|
251
249
|
ps.stdout.on('data', (d) => (out += d.toString()));
|
|
252
250
|
ps.on('error', () => resolve(''));
|
|
253
|
-
ps.on('close', () =>
|
|
254
|
-
clearTimeout(giveUp);
|
|
255
|
-
resolve(out);
|
|
256
|
-
});
|
|
251
|
+
ps.on('close', () => resolve(out));
|
|
257
252
|
});
|
|
258
253
|
}
|
|
259
254
|
function taskkillTree(pid) {
|
package/dist/task/command-run.js
CHANGED
|
@@ -95,6 +95,7 @@ export const spawnCommand = spec => new Promise(resolve => {
|
|
|
95
95
|
let settled = false;
|
|
96
96
|
let exitStatus = null;
|
|
97
97
|
let exited = false;
|
|
98
|
+
let killed = false;
|
|
98
99
|
let endedStreams = 0;
|
|
99
100
|
let drain;
|
|
100
101
|
// Its own process group: a pretest that backgrounds a daemon, a build that
|
|
@@ -145,6 +146,7 @@ export const spawnCommand = spec => new Promise(resolve => {
|
|
|
145
146
|
* `status: null` regardless.
|
|
146
147
|
*/
|
|
147
148
|
const killAndSettle = () => {
|
|
149
|
+
killed = true;
|
|
148
150
|
kill();
|
|
149
151
|
clearTimeout(drain);
|
|
150
152
|
drain = setTimeout(() => done(null), EXIT_DRAIN_MS);
|
|
@@ -175,7 +177,8 @@ export const spawnCommand = spec => new Promise(resolve => {
|
|
|
175
177
|
child.on('error', (e) => done(null, e.message));
|
|
176
178
|
child.on('exit', (code) => {
|
|
177
179
|
exited = true;
|
|
178
|
-
|
|
180
|
+
// taskkill /F ends a win32 child with exit code 1, which reads as a failed check.
|
|
181
|
+
exitStatus = killed ? null : code;
|
|
179
182
|
if (child.pid)
|
|
180
183
|
reapGroupAfterExit(child.pid);
|
|
181
184
|
// Both ends of the same question: settle now if the pipes are already
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mjasnikovs/pi-task",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.49",
|
|
4
4
|
"description": "Deterministic task planning and spec-orchestration for local models — crash-safe /task pipelines with verify/enforce gates, a real-time remote web view, and web/docs/fetch/worker subagent tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|