gm-plugkit 2.0.1990 → 2.0.1992

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/cli.js CHANGED
@@ -6,24 +6,12 @@ const os = require('os');
6
6
  const path = require('path');
7
7
  const cp = require('child_process');
8
8
  const { ensureReady, startSpoolDaemon, gmToolsDir, readVersionFile, ensureGmPlugkitVersionFresh, ensureSkillMdFresh, ensureWrapperFresh, isReady, getWasmPath, readPinnedGmPlugkitVersion, spawnPinnedBoot, resolveProjectRoot } = require('./bootstrap');
9
+ const { pidAliveSync, waitForPidDeath } = require('./gm-process');
9
10
 
10
11
  function getWasmPathSafe() {
11
12
  try { return getWasmPath(); } catch (_) { return null; }
12
13
  }
13
14
 
14
- function pidAliveSync(pid) {
15
- try { process.kill(pid, 0); return true; } catch (_) { return false; }
16
- }
17
-
18
- function waitForPidDeath(pid, timeoutMs) {
19
- const deadline = Date.now() + timeoutMs;
20
- while (Date.now() < deadline) {
21
- if (!pidAliveSync(pid)) return true;
22
- try { cp.execFileSync(process.platform === 'win32' ? 'ping' : 'sleep', process.platform === 'win32' ? ['-n', '2', '127.0.0.1'] : ['0.3'], { stdio: 'ignore', windowsHide: true }); } catch (_) {}
23
- }
24
- return !pidAliveSync(pid);
25
- }
26
-
27
15
  function spawnBackgroundFreshnessCheck(reason) {
28
16
  try {
29
17
  const child = cp.spawn(process.execPath, [__filename.replace(/cli\.js$/, 'bootstrap.js')], {
package/gm-process.js CHANGED
@@ -13,4 +13,22 @@ function pidCommandLineForKillGuard(pid) {
13
13
  } catch (_) { return ''; }
14
14
  }
15
15
 
16
- module.exports = { pidCommandLineForKillGuard };
16
+ // Is `pid` still alive? signal-0 probe (throws ESRCH once the process is gone).
17
+ function pidAliveSync(pid) {
18
+ try { process.kill(pid, 0); return true; } catch (_) { return false; }
19
+ }
20
+
21
+ // Block (via a short spawnSync sleep, no async) until `pid` dies or timeoutMs
22
+ // elapses. Shared by cli.js (daemon recycle) and supervisor.js (killChild) —
23
+ // both previously carried a byte-divergent inline copy (execFileSync vs
24
+ // spawnSync) of this exact loop.
25
+ function waitForPidDeath(pid, timeoutMs) {
26
+ const deadline = Date.now() + timeoutMs;
27
+ while (Date.now() < deadline) {
28
+ if (!pidAliveSync(pid)) return true;
29
+ try { spawnSync(process.platform === 'win32' ? 'ping' : 'sleep', process.platform === 'win32' ? ['-n', '2', '127.0.0.1'] : ['0.3'], { stdio: 'ignore', windowsHide: true }); } catch (_) {}
30
+ }
31
+ return !pidAliveSync(pid);
32
+ }
33
+
34
+ module.exports = { pidCommandLineForKillGuard, pidAliveSync, waitForPidDeath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1990",
3
+ "version": "2.0.1992",
4
4
  "description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform binary, verifies SHA256, and starts the spool watcher daemon. Includes plugkit-wasm-wrapper for WASM-based spool watching.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/plugkit.version CHANGED
@@ -1 +1 @@
1
- 0.1.915
1
+ 0.1.916
package/supervisor.js CHANGED
@@ -8,7 +8,7 @@ const crypto = require('crypto');
8
8
  const { spawn, spawnSync } = require('child_process');
9
9
  const { gmToolsDir, resolveProjectRoot } = require('./bootstrap');
10
10
  const { logEvent: _sharedLogEvent, GM_LOG_ROOT: _sharedGmLogRoot } = require('./gm-log');
11
- const { pidCommandLineForKillGuard: _sharedPidCommandLine } = require('./gm-process');
11
+ const { pidCommandLineForKillGuard: _sharedPidCommandLine, pidAliveSync, waitForPidDeath } = require('./gm-process');
12
12
 
13
13
  function wrapperSha12OnDisk() {
14
14
  try {
@@ -149,19 +149,6 @@ function readShutdownReason() {
149
149
  // deliberate upgrade recycle as a SILENT ABORT / unplanned-restart critical. Write
150
150
  // the planned reason on the child's behalf BEFORE killing, so the next boot reads a
151
151
  // fresh planned shutdown reason and classifies the restart correctly.
152
- function pidAliveSync(pid) {
153
- try { process.kill(pid, 0); return true; } catch (_) { return false; }
154
- }
155
-
156
- function waitForPidDeath(pid, timeoutMs) {
157
- const deadline = Date.now() + timeoutMs;
158
- while (Date.now() < deadline) {
159
- if (!pidAliveSync(pid)) return true;
160
- try { spawnSync(process.platform === 'win32' ? 'ping' : 'sleep', process.platform === 'win32' ? ['-n', '2', '127.0.0.1'] : ['0.3'], { stdio: 'ignore', windowsHide: true }); } catch (_) {}
161
- }
162
- return !pidAliveSync(pid);
163
- }
164
-
165
152
  function killChild(reason) {
166
153
  if (!currentChildPid) return;
167
154
  const pid = currentChildPid;