gm-plugkit 2.0.1221 → 2.0.1222
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 +65 -9
- package/plugkit.sha256 +1 -1
- package/plugkit.version +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-plugkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1222",
|
|
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
|
@@ -78,6 +78,17 @@ function isBrowserRunningFileLocal(rel) {
|
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
function hashFileShortLocal(cwd, rel) {
|
|
82
|
+
try {
|
|
83
|
+
const fs = require('fs');
|
|
84
|
+
const path = require('path');
|
|
85
|
+
const crypto = require('crypto');
|
|
86
|
+
const abs = path.isAbsolute(rel) ? rel : path.join(cwd, rel);
|
|
87
|
+
const buf = fs.readFileSync(abs);
|
|
88
|
+
return crypto.createHash('sha256').update(buf).digest('hex').slice(0, 12);
|
|
89
|
+
} catch (_) { return ''; }
|
|
90
|
+
}
|
|
91
|
+
|
|
81
92
|
function recordBrowserEditLocal(cwd, filePath) {
|
|
82
93
|
try {
|
|
83
94
|
const fs = require('fs');
|
|
@@ -89,8 +100,11 @@ function recordBrowserEditLocal(cwd, filePath) {
|
|
|
89
100
|
fs.mkdirSync(path.dirname(editsFile), { recursive: true });
|
|
90
101
|
let list = [];
|
|
91
102
|
try { list = JSON.parse(fs.readFileSync(editsFile, 'utf8')); if (!Array.isArray(list)) list = []; } catch (_) {}
|
|
92
|
-
const
|
|
93
|
-
|
|
103
|
+
const relPath = rel.replace(/\\\\/g, '/');
|
|
104
|
+
const hash = hashFileShortLocal(cwd, relPath);
|
|
105
|
+
const idx = list.findIndex(e => e && e.file === relPath);
|
|
106
|
+
const entry = { file: relPath, ts: Date.now(), hash };
|
|
107
|
+
if (idx === -1) list.push(entry); else list[idx] = entry;
|
|
94
108
|
fs.writeFileSync(editsFile, JSON.stringify(list));
|
|
95
109
|
return true;
|
|
96
110
|
} catch (_) { return false; }
|
|
@@ -322,9 +336,24 @@ function dispatchAutoRecall(instance, queryPrompt) {
|
|
|
322
336
|
function tryAutoRecallForTurnEntry(instance, sess, cwd) {
|
|
323
337
|
try {
|
|
324
338
|
const prompt = readUserPromptForRecall(cwd);
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
339
|
+
let emptyPromptFallback = false;
|
|
340
|
+
let effectivePrompt = prompt;
|
|
341
|
+
if (!prompt || !String(prompt).trim()) {
|
|
342
|
+
emptyPromptFallback = true;
|
|
343
|
+
const key = sess || '(no-session)';
|
|
344
|
+
const t = _turns.get(key);
|
|
345
|
+
const phase = (t && t.lastPhase) || 'PLAN';
|
|
346
|
+
const phaseQueryMap = {
|
|
347
|
+
PLAN: 'PLAN orient',
|
|
348
|
+
EXECUTE: 'EXECUTE work',
|
|
349
|
+
EMIT: 'EMIT closure',
|
|
350
|
+
VERIFY: 'VERIFY trajectory',
|
|
351
|
+
COMPLETE: 'COMPLETE residual',
|
|
352
|
+
};
|
|
353
|
+
effectivePrompt = phaseQueryMap[phase] || 'PLAN orient';
|
|
354
|
+
}
|
|
355
|
+
const primary = dispatchAutoRecall(instance, effectivePrompt);
|
|
356
|
+
const fallbackQuery = deriveFallbackQuery(effectivePrompt);
|
|
328
357
|
let fallback = null;
|
|
329
358
|
if (fallbackQuery && fallbackQuery !== (primary && primary.query)) {
|
|
330
359
|
fallback = dispatchAutoRecall(instance, fallbackQuery);
|
|
@@ -344,12 +373,16 @@ function tryAutoRecallForTurnEntry(instance, sess, cwd) {
|
|
|
344
373
|
if (primary && primary.query) queries.push(primary.query);
|
|
345
374
|
if (fallback && fallback.query && !queries.includes(fallback.query)) queries.push(fallback.query);
|
|
346
375
|
const payload = {
|
|
347
|
-
query: (primary && primary.query) || '',
|
|
376
|
+
query: (primary && primary.query) || effectivePrompt || '',
|
|
348
377
|
queries,
|
|
349
378
|
hits: merged.slice(0, 20),
|
|
350
379
|
fired_at: new Date().toISOString(),
|
|
351
380
|
turn_entry: true,
|
|
352
381
|
};
|
|
382
|
+
if (emptyPromptFallback) {
|
|
383
|
+
payload.fallback_reason = 'empty-prompt';
|
|
384
|
+
if (!payload.query) payload.query = effectivePrompt;
|
|
385
|
+
}
|
|
353
386
|
logEvent('plugkit', 'auto_recall.turn-entry', { sess, queries, count: merged.length });
|
|
354
387
|
return payload;
|
|
355
388
|
} catch (e) {
|
|
@@ -1276,6 +1309,7 @@ function makeHostFunctions(instanceRef) {
|
|
|
1276
1309
|
const lang = opts.lang || 'nodejs';
|
|
1277
1310
|
const cwd = opts.cwd || process.cwd();
|
|
1278
1311
|
const rawTimeout = opts.timeoutMs;
|
|
1312
|
+
const MIN_TIMEOUT_MS = 100;
|
|
1279
1313
|
if (rawTimeout === undefined || rawTimeout === null || typeof rawTimeout !== 'number' || !Number.isFinite(rawTimeout) || rawTimeout <= 0 || !Number.isInteger(rawTimeout)) {
|
|
1280
1314
|
return writeWasmJson(instanceRef.value, {
|
|
1281
1315
|
ok: false,
|
|
@@ -1285,6 +1319,15 @@ function makeHostFunctions(instanceRef) {
|
|
|
1285
1319
|
received: rawTimeout === undefined ? null : rawTimeout,
|
|
1286
1320
|
});
|
|
1287
1321
|
}
|
|
1322
|
+
if (rawTimeout < MIN_TIMEOUT_MS) {
|
|
1323
|
+
return writeWasmJson(instanceRef.value, {
|
|
1324
|
+
ok: false,
|
|
1325
|
+
error: 'timeoutMs below floor',
|
|
1326
|
+
min: MIN_TIMEOUT_MS,
|
|
1327
|
+
received: rawTimeout,
|
|
1328
|
+
paper_ref: '§20',
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1288
1331
|
const timeoutMs = rawTimeout;
|
|
1289
1332
|
let cmd, args;
|
|
1290
1333
|
if (lang === 'nodejs' || lang === 'js') { cmd = process.execPath; args = ['-e', code]; }
|
|
@@ -1852,10 +1895,23 @@ async function runSpoolWatcher(instance, spoolDir) {
|
|
|
1852
1895
|
|
|
1853
1896
|
if (verb === 'browser') {
|
|
1854
1897
|
try {
|
|
1855
|
-
const
|
|
1898
|
+
const cwd_ = process.cwd();
|
|
1899
|
+
const editsFile = path.join(cwd_, '.gm', 'exec-spool', '.turn-browser-edits.json');
|
|
1900
|
+
const witnessFile = path.join(cwd_, '.gm', 'exec-spool', '.turn-browser-witnessed');
|
|
1856
1901
|
fs.mkdirSync(path.dirname(witnessFile), { recursive: true });
|
|
1857
|
-
|
|
1858
|
-
|
|
1902
|
+
let edits = [];
|
|
1903
|
+
try { edits = JSON.parse(fs.readFileSync(editsFile, 'utf8')); if (!Array.isArray(edits)) edits = []; } catch (_) {}
|
|
1904
|
+
const witnessed_hashes = {};
|
|
1905
|
+
for (const e of edits) {
|
|
1906
|
+
if (!e || !e.file) continue;
|
|
1907
|
+
try {
|
|
1908
|
+
const abs = path.isAbsolute(e.file) ? e.file : path.join(cwd_, e.file);
|
|
1909
|
+
const buf = fs.readFileSync(abs);
|
|
1910
|
+
witnessed_hashes[e.file] = crypto.createHash('sha256').update(buf).digest('hex').slice(0, 12);
|
|
1911
|
+
} catch (_) { witnessed_hashes[e.file] = ''; }
|
|
1912
|
+
}
|
|
1913
|
+
fs.writeFileSync(witnessFile, JSON.stringify({ ts: Date.now(), task: taskBase, dur_ms, witnessed_hashes }));
|
|
1914
|
+
logEvent('plugkit', 'browser.witness-marked', { task: taskBase, files: Object.keys(witnessed_hashes) });
|
|
1859
1915
|
} catch (_) {}
|
|
1860
1916
|
}
|
|
1861
1917
|
|
package/plugkit.sha256
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"plugkit.wasm":"
|
|
1
|
+
{"plugkit.wasm":"0cac0a48e7346d2f75779c9972efe47c3f4ab38063a077660906a53028d2e70a"}
|
package/plugkit.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.449
|