gm-plugkit 2.0.1154 → 2.0.1156
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 +1 -1
- package/plugkit-wasm-wrapper.js +29 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-plugkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1156",
|
|
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-wasm-wrapper.js
CHANGED
|
@@ -4,10 +4,17 @@ import os from 'os';
|
|
|
4
4
|
import crypto from 'crypto';
|
|
5
5
|
import https from 'https';
|
|
6
6
|
import { watch } from 'fs';
|
|
7
|
-
import { spawn, spawnSync } from 'child_process';
|
|
7
|
+
import { spawn as _rawSpawn, spawnSync as _rawSpawnSync } from 'child_process';
|
|
8
8
|
import net from 'net';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
10
|
|
|
11
|
+
function spawnSync(cmd, args, opts) {
|
|
12
|
+
return _rawSpawnSync(cmd, args, { windowsHide: true, ...(opts || {}) });
|
|
13
|
+
}
|
|
14
|
+
function spawn(cmd, args, opts) {
|
|
15
|
+
return _rawSpawn(cmd, args, { windowsHide: true, ...(opts || {}) });
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
19
|
const __dirname = path.dirname(__filename);
|
|
13
20
|
|
|
@@ -871,6 +878,7 @@ async function runSpoolWatcher(instance, spoolDir) {
|
|
|
871
878
|
|
|
872
879
|
const UPDATE_AVAILABLE_PATH = path.join(spoolDir, '.update-available.json');
|
|
873
880
|
const UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1000;
|
|
881
|
+
let _lastKnownDrift = null;
|
|
874
882
|
function checkForUpdate() {
|
|
875
883
|
const installed = resolveVersion(instance);
|
|
876
884
|
const req = https.get({
|
|
@@ -879,7 +887,11 @@ async function runSpoolWatcher(instance, spoolDir) {
|
|
|
879
887
|
headers: { 'user-agent': 'plugkit-watcher', 'accept': 'application/json' },
|
|
880
888
|
timeout: 5000,
|
|
881
889
|
}, (res) => {
|
|
882
|
-
if (res.statusCode !== 200) {
|
|
890
|
+
if (res.statusCode !== 200) {
|
|
891
|
+
res.resume();
|
|
892
|
+
logEvent('plugkit', 'update.check.error', { installed, status: res.statusCode });
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
883
895
|
const chunks = [];
|
|
884
896
|
res.on('data', c => chunks.push(c));
|
|
885
897
|
res.on('end', () => {
|
|
@@ -890,21 +902,32 @@ async function runSpoolWatcher(instance, spoolDir) {
|
|
|
890
902
|
const latest = tag.replace(/^v/, '');
|
|
891
903
|
if (latest === installed) {
|
|
892
904
|
try { fs.unlinkSync(UPDATE_AVAILABLE_PATH); } catch (_) {}
|
|
905
|
+
if (_lastKnownDrift) {
|
|
906
|
+
logEvent('plugkit', 'update.cleared', { installed, was: _lastKnownDrift });
|
|
907
|
+
_lastKnownDrift = null;
|
|
908
|
+
}
|
|
893
909
|
return;
|
|
894
910
|
}
|
|
911
|
+
const update_url = `https://github.com/AnEntrypoint/plugkit-bin/releases/tag/v${latest}`;
|
|
895
912
|
fs.writeFileSync(UPDATE_AVAILABLE_PATH, JSON.stringify({
|
|
896
913
|
installed,
|
|
897
914
|
latest,
|
|
898
915
|
checked_at_ms: Date.now(),
|
|
899
916
|
instruction: 'plugkit is out of date. To update, close the running watcher and re-bootstrap with the @latest flag, e.g. node ~/.claude/gm-tools/plugkit-wasm-wrapper.js spool & after running bootstrap with {latest: true}.',
|
|
900
|
-
update_url
|
|
917
|
+
update_url,
|
|
901
918
|
}, null, 2));
|
|
902
919
|
console.log(`[update] available: installed=${installed} latest=${latest} → wrote ${UPDATE_AVAILABLE_PATH}`);
|
|
903
|
-
|
|
920
|
+
if (_lastKnownDrift !== latest) {
|
|
921
|
+
logEvent('plugkit', 'update.available', { installed, latest, update_url });
|
|
922
|
+
_lastKnownDrift = latest;
|
|
923
|
+
}
|
|
924
|
+
} catch (e) {
|
|
925
|
+
logEvent('plugkit', 'update.check.error', { error: String(e && e.message || e) });
|
|
926
|
+
}
|
|
904
927
|
});
|
|
905
928
|
});
|
|
906
|
-
req.on('timeout', () => req.destroy());
|
|
907
|
-
req.on('error', () => {});
|
|
929
|
+
req.on('timeout', () => { req.destroy(); logEvent('plugkit', 'update.check.error', { error: 'timeout' }); });
|
|
930
|
+
req.on('error', (e) => logEvent('plugkit', 'update.check.error', { error: String(e && e.message || e) }));
|
|
908
931
|
}
|
|
909
932
|
setTimeout(checkForUpdate, 10_000);
|
|
910
933
|
setInterval(checkForUpdate, UPDATE_CHECK_INTERVAL_MS);
|