gm-skill 2.0.1600 → 2.0.1602

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.
@@ -230,7 +230,12 @@ async function validateBrowserEmbed() {
230
230
  if (!fs.existsSync(path.join(tbDir, 'docs'))) { v.skipped = true; v.errors.push('repo docs/ missing -- cannot serve a fixture page'); return v; }
231
231
 
232
232
  let serveProc = null;
233
- const port = 3088;
233
+ let port;
234
+ try {
235
+ const r = cp.spawnSync(process.execPath, ['-e', "const net=require('net');const s=net.createServer();s.listen(0,'127.0.0.1',()=>{const p=s.address().port;s.close(()=>process.stdout.write(String(p)));});s.on('error',e=>{process.stderr.write(e.message);process.exit(1);});"], { encoding: 'utf-8', timeout: 5000 });
236
+ if (r.status !== 0) throw new Error('could not allocate free port: ' + (r.stderr || 'unknown'));
237
+ port = parseInt(r.stdout.trim(), 10);
238
+ } catch (e) { v.errors.push('free-port alloc: ' + e.message); return v; }
234
239
  try {
235
240
  serveProc = cp.spawn(process.platform === 'win32' ? 'npx.cmd' : 'npx', ['serve', 'docs', '-l', String(port)], {
236
241
  cwd: tbDir, detached: true, stdio: 'ignore', windowsHide: true, shell: process.platform === 'win32',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1600",
3
+ "version": "2.0.1602",
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": {
@@ -165,13 +165,20 @@ function dispatchVerbToWasmInternal(instance, verb, body) {
165
165
  const bodyBytes = new TextEncoder().encode(body || '');
166
166
  const verbPtr = instance.exports.plugkit_alloc(verbBytes.length);
167
167
  const bodyPtr = instance.exports.plugkit_alloc(bodyBytes.length);
168
+ if ((verbBytes.length > 0 && verbPtr === 0) || (bodyBytes.length > 0 && bodyPtr === 0)) {
169
+ try { if (verbPtr !== 0) instance.exports.plugkit_free(verbPtr, verbBytes.length); } catch (_) {}
170
+ try { if (bodyPtr !== 0) instance.exports.plugkit_free(bodyPtr, bodyBytes.length); } catch (_) {}
171
+ throw new Error(`wasm-alloc-failed for dispatch_verb(${verb}): plugkit_alloc returned 0 (wasm OOM); refusing to write to a null offset and corrupt the heap`);
172
+ }
168
173
  try {
169
174
  new Uint8Array(instance.exports.memory.buffer, verbPtr, verbBytes.length).set(verbBytes);
170
175
  new Uint8Array(instance.exports.memory.buffer, bodyPtr, bodyBytes.length).set(bodyBytes);
171
176
  const result = dispatch(verbPtr, verbBytes.length, bodyPtr, bodyBytes.length);
172
177
  const ptr = Number(result & 0xffffffffn);
173
178
  const len = Number(result >> 32n);
174
- const out = new TextDecoder().decode(new Uint8Array(instance.exports.memory.buffer, ptr, len));
179
+ const buffer = instance.exports.memory.buffer;
180
+ guardWasmRange(buffer, ptr, len, `dispatch_verb(${verb})`);
181
+ const out = new TextDecoder().decode(new Uint8Array(buffer, ptr, len));
175
182
  try { instance.exports.plugkit_free(ptr, len); } catch (_) {}
176
183
  return out;
177
184
  } finally {
@@ -1234,7 +1241,7 @@ function createWasiShim(instanceRef) {
1234
1241
  const base = iovs_ptr + i * 8;
1235
1242
  const ptr = dv.getUint32(base, true);
1236
1243
  const len = dv.getUint32(base + 4, true);
1237
- if (len > 0) {
1244
+ if (len > 0 && ptr + len <= buf.byteLength) {
1238
1245
  chunks.push(new Uint8Array(buf, ptr, len).slice());
1239
1246
  total += len;
1240
1247
  }
@@ -1300,14 +1307,25 @@ function createWasiShim(instanceRef) {
1300
1307
  });
1301
1308
  }
1302
1309
 
1310
+ function guardWasmRange(buffer, ptr, len, where) {
1311
+ const total = buffer.byteLength;
1312
+ if (!Number.isInteger(ptr) || !Number.isInteger(len) || ptr < 0 || len < 0 || ptr + len > total) {
1313
+ throw new Error(`wasm-memory-read-out-of-bounds at ${where}: ptr=${ptr} len=${len} buffer=${total} -- corrupt (ptr,len) from wasm, refusing the read instead of crashing the dispatch loop`);
1314
+ }
1315
+ }
1316
+
1303
1317
  function readWasmBytes(instance, ptr, len) {
1304
1318
  if (ptr === 0 || len === 0) return new Uint8Array(0);
1305
- return new Uint8Array(instance.exports.memory.buffer, ptr, len).slice();
1319
+ const buffer = instance.exports.memory.buffer;
1320
+ guardWasmRange(buffer, ptr, len, 'readWasmBytes');
1321
+ return new Uint8Array(buffer, ptr, len).slice();
1306
1322
  }
1307
1323
 
1308
1324
  function readWasmStr(instance, ptr, len) {
1309
1325
  if (ptr === 0 || len === 0) return '';
1310
- const bytes = new Uint8Array(instance.exports.memory.buffer, ptr, len);
1326
+ const buffer = instance.exports.memory.buffer;
1327
+ guardWasmRange(buffer, ptr, len, 'readWasmStr');
1328
+ const bytes = new Uint8Array(buffer, ptr, len);
1311
1329
  return new TextDecoder('utf-8').decode(bytes);
1312
1330
  }
1313
1331
 
@@ -1 +1 @@
1
- 0.1.396
1
+ 0.1.681
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.1600",
3
+ "version": "2.0.1602",
4
4
  "description": "Spool-dispatch orchestration engine with unified state machine, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-skill",
3
- "version": "2.0.1600",
3
+ "version": "2.0.1602",
4
4
  "description": "Canonical universal harness — AI-native software engineering via skill-driven orchestration; bootstraps plugkit for task execution and session isolation. Install in any AI coding agent host.",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -32,7 +32,12 @@
32
32
  "lib/",
33
33
  "lang/",
34
34
  "scripts/",
35
- "bin/",
35
+ "bin/bootstrap.js",
36
+ "bin/gm-validate.js",
37
+ "bin/gm-shell-validate.js",
38
+ "bin/plugkit.sha256",
39
+ "bin/plugkit.version",
40
+ "bin/plugkit.wasm.sha256",
36
41
  "gm-plugkit/",
37
42
  "AGENTS.md",
38
43
  "README.md",