gm-plugkit 2.0.1974 → 2.0.1976
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 +27 -14
- package/package.json +1 -1
- package/plugkit-wasm-wrapper.js +57 -0
package/cli.js
CHANGED
|
@@ -248,21 +248,34 @@ function writeCliError(phase, err) {
|
|
|
248
248
|
// This is the actual code-level enforcement of what was previously only a
|
|
249
249
|
// documented convention (SKILL.md telling an LLM agent to manually prefer
|
|
250
250
|
// gm-runner) -- with this in place bun/node are only ever exercised on a
|
|
251
|
-
// platform
|
|
252
|
-
// one-time install before
|
|
253
|
-
|
|
251
|
+
// platform neither runner has a published binary for, or during the
|
|
252
|
+
// one-time install before either runner lands on disk.
|
|
253
|
+
//
|
|
254
|
+
// agentplug-runner is tried FIRST, gm-runner second -- agentplug-runner
|
|
255
|
+
// serves the identical spool ABI (same in/out layout, same verb names;
|
|
256
|
+
// gm.wasm is just one of its loadable plugins now) so it's a strict
|
|
257
|
+
// superset, not an alternative; gm-runner stays as the fallback for any
|
|
258
|
+
// install that has it but hasn't picked up agentplug-runner yet (installer
|
|
259
|
+
// re-run pending, or a platform agentplug-bin hasn't published for yet
|
|
260
|
+
// while gm-runner-bin already has).
|
|
261
|
+
function tryDelegateToRunner(args) {
|
|
254
262
|
if (process.env.GM_PLUGKIT_NO_RUNNER_DELEGATE === '1') return false;
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
263
|
+
const candidates = process.platform === 'win32'
|
|
264
|
+
? ['agentplug-runner.exe', 'gm-runner.exe']
|
|
265
|
+
: ['agentplug-runner', 'gm-runner'];
|
|
266
|
+
for (const exeName of candidates) {
|
|
267
|
+
const runnerPath = path.join(gmToolsDir(), exeName);
|
|
268
|
+
if (!fs.existsSync(runnerPath)) continue;
|
|
269
|
+
try {
|
|
270
|
+
const result = cp.spawnSync(runnerPath, args, { stdio: 'inherit', windowsHide: true });
|
|
271
|
+
if (result.error) continue; // this candidate genuinely failed to start -- try the next one
|
|
272
|
+
process.exit(typeof result.status === 'number' ? result.status : 0);
|
|
273
|
+
} catch (_) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
return true;
|
|
264
277
|
}
|
|
265
|
-
return
|
|
278
|
+
return false;
|
|
266
279
|
}
|
|
267
280
|
|
|
268
281
|
(async () => {
|
|
@@ -273,7 +286,7 @@ function tryDelegateToGmRunner(args) {
|
|
|
273
286
|
process.exit(0);
|
|
274
287
|
}
|
|
275
288
|
|
|
276
|
-
|
|
289
|
+
tryDelegateToRunner(args);
|
|
277
290
|
|
|
278
291
|
if (args.includes('--kill-stale-watchers')) {
|
|
279
292
|
process.exit(killStaleWatchers());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-plugkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1976",
|
|
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
|
@@ -2548,6 +2548,55 @@ function hostEmbedViaGmRunner(text) {
|
|
|
2548
2548
|
}
|
|
2549
2549
|
}
|
|
2550
2550
|
|
|
2551
|
+
let _agentplugRunnerBinPath;
|
|
2552
|
+
function resolveAgentplugRunnerBin() {
|
|
2553
|
+
if (_agentplugRunnerBinPath !== undefined) return _agentplugRunnerBinPath;
|
|
2554
|
+
const exe = path.join(GM_TOOLS_ROOT, process.platform === 'win32' ? 'agentplug-runner.exe' : 'agentplug-runner');
|
|
2555
|
+
_agentplugRunnerBinPath = fs.existsSync(exe) ? exe : null;
|
|
2556
|
+
return _agentplugRunnerBinPath;
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
// plugkit-core's wasm now imports env:host_plugin_call unconditionally (the
|
|
2560
|
+
// agentplug migration routes libsql/bert/treesitter through it instead of
|
|
2561
|
+
// linking them in-process) -- WITHOUT this import registered, WebAssembly.
|
|
2562
|
+
// instantiate throws a hard LinkError and the wasm never boots at all, not
|
|
2563
|
+
// just a degraded-capability fallback like host_vec_embed's absence. This
|
|
2564
|
+
// delegates to agentplug-runner's `dispatch <plugin> <verb> <body>` one-shot
|
|
2565
|
+
// subcommand (same synchronous spawnSync shape as hostEmbedViaGmRunner
|
|
2566
|
+
// above) when a real ~/.gm-tools/agentplug-runner(.exe) is present; when
|
|
2567
|
+
// absent, returns a real, typed {"ok":false,"error":"not_implemented_js_wrapper"}
|
|
2568
|
+
// envelope instead of a JS-side exception -- lets wasm instantiation and
|
|
2569
|
+
// every non-plugin-dependent verb keep working, with only the specific
|
|
2570
|
+
// libsql/bert/treesitter-backed verbs (sql_*, recall, memorize, codesearch)
|
|
2571
|
+
// failing loud and typed rather than the whole session going dark.
|
|
2572
|
+
function hostPluginCallViaAgentplugRunner(plugin, verb, body) {
|
|
2573
|
+
const bin = resolveAgentplugRunnerBin();
|
|
2574
|
+
if (!bin) return null;
|
|
2575
|
+
try {
|
|
2576
|
+
const r = spawnSync(bin, ['dispatch', plugin, verb, body], {
|
|
2577
|
+
encoding: 'utf-8',
|
|
2578
|
+
windowsHide: true,
|
|
2579
|
+
timeout: 30000,
|
|
2580
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
2581
|
+
});
|
|
2582
|
+
if (r.error || r.status !== 0) return null;
|
|
2583
|
+
return r.stdout;
|
|
2584
|
+
} catch (_) {
|
|
2585
|
+
return null;
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
globalThis.__hostPluginCallSync = function __hostPluginCallSync(pluginPtr, pluginLen, verbPtr, verbLen, bodyPtr, bodyLen, instance) {
|
|
2590
|
+
const plugin = readWasmStr(instance, pluginPtr, pluginLen);
|
|
2591
|
+
const verb = readWasmStr(instance, verbPtr, verbLen);
|
|
2592
|
+
const body = readWasmStr(instance, bodyPtr, bodyLen);
|
|
2593
|
+
const result = hostPluginCallViaAgentplugRunner(plugin, verb, body);
|
|
2594
|
+
const out = result != null
|
|
2595
|
+
? result
|
|
2596
|
+
: JSON.stringify({ ok: false, error: 'not_implemented_js_wrapper', plugin });
|
|
2597
|
+
return writeWasmJson(instance, JSON.parse(out));
|
|
2598
|
+
};
|
|
2599
|
+
|
|
2551
2600
|
globalThis.__hostEmbedSync = function __hostEmbedSync(textPtr, textLen, outPtr, outLen, instance) {
|
|
2552
2601
|
try {
|
|
2553
2602
|
const text = readWasmStr(instance, textPtr, textLen);
|
|
@@ -2737,6 +2786,14 @@ function makeHostFunctions(instanceRef) {
|
|
|
2737
2786
|
return -1;
|
|
2738
2787
|
},
|
|
2739
2788
|
|
|
2789
|
+
host_plugin_call: (pluginPtr, pluginLen, verbPtr, verbLen, bodyPtr, bodyLen) => {
|
|
2790
|
+
try {
|
|
2791
|
+
return globalThis.__hostPluginCallSync(pluginPtr, pluginLen, verbPtr, verbLen, bodyPtr, bodyLen, instanceRef.value);
|
|
2792
|
+
} catch (_) {
|
|
2793
|
+
return 0n;
|
|
2794
|
+
}
|
|
2795
|
+
},
|
|
2796
|
+
|
|
2740
2797
|
host_vec_search: (qPtr, qLen, k) => {
|
|
2741
2798
|
try {
|
|
2742
2799
|
const raw = readWasmStr(instanceRef.value, qPtr, qLen);
|