gm-plugkit 2.0.1293 → 2.0.1295

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1293",
3
+ "version": "2.0.1295",
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": {
@@ -877,10 +877,25 @@ function cosineSim(a, b) {
877
877
  return dot / (Math.sqrt(na) * Math.sqrt(nb));
878
878
  }
879
879
 
880
+ let __wasmAbortFlag = { aborted: false, code: 0 };
880
881
  function createWasiShim(instanceRef) {
881
882
  const getMemory = () => instanceRef.value.exports.memory.buffer;
882
883
  const shim = {
883
- proc_exit: (code) => process.exit(code),
884
+ proc_exit: (code) => {
885
+ __wasmAbortFlag.aborted = true;
886
+ __wasmAbortFlag.code = code;
887
+ try {
888
+ const spoolDir = spoolDirForSentinel();
889
+ fs.mkdirSync(spoolDir, { recursive: true });
890
+ fs.writeFileSync(path.join(spoolDir, '.wasm-abort.json'), JSON.stringify({
891
+ ts: Date.now(),
892
+ exit_code: code,
893
+ verb_in_flight: __currentVerbContext,
894
+ }));
895
+ } catch (_) {}
896
+ try { console.error(`[plugkit-wasm] wasm proc_exit(${code}) intercepted; throwing to abort current verb without killing watcher`); } catch (_) {}
897
+ throw new Error(`wasm proc_exit(${code}) during verb ${__currentVerbContext && __currentVerbContext.verb}`);
898
+ },
884
899
  fd_write: (fd, iovs_ptr, iovs_len, nwritten_ptr) => {
885
900
  try {
886
901
  const buf = getMemory();
@@ -2024,6 +2039,27 @@ async function runSpoolWatcher(instance, spoolDir) {
2024
2039
  if (isProcessed(key)) return;
2025
2040
  markProcessed(key);
2026
2041
 
2042
+ if (__wasmAbortFlag.aborted) {
2043
+ try {
2044
+ const taskBase = path.basename(filePath, path.extname(filePath));
2045
+ const relPath = path.relative(inDir, filePath);
2046
+ const dir = path.dirname(relPath);
2047
+ const verb = dir === '.' ? taskBase : dir;
2048
+ const outName = dir === '.' ? `${taskBase}.json` : `${verb}-${taskBase}.json`;
2049
+ fs.writeFileSync(path.join(outDir, outName), JSON.stringify({
2050
+ ok: false,
2051
+ error: `wasm aborted earlier (exit_code=${__wasmAbortFlag.code}); watcher will respawn`,
2052
+ wasm_aborted: true,
2053
+ }));
2054
+ try { fs.unlinkSync(filePath); } catch (_) {}
2055
+ } catch (_) {}
2056
+ unmarkProcessed(key);
2057
+ emitShutdownReason('wasm-abort-graceful', new Error(`wasm proc_exit(${__wasmAbortFlag.code}) earlier; clean watcher restart`));
2058
+ try { console.error('[plugkit-wasm] exiting after wasm abort to allow supervisor respawn'); } catch (_) {}
2059
+ setTimeout(() => process.exit(2), 100).unref();
2060
+ return;
2061
+ }
2062
+
2027
2063
  try {
2028
2064
  const content = fs.readFileSync(filePath, 'utf8');
2029
2065
  const relPath = path.relative(inDir, filePath);
package/plugkit.sha256 CHANGED
@@ -1 +1 @@
1
- {"plugkit.wasm":"d22156c2ef672875557c91649ddc0dfb86a403b431bbdb2b5048ab8870b95dd5"}
1
+ {"plugkit.wasm":"8d3e95567b644e3ad4429bfa1026220eaf3674afa317dc511997ec52fff5c8e8"}
package/plugkit.version CHANGED
@@ -1 +1 @@
1
- 0.1.479
1
+ 0.1.480