gm-plugkit 2.0.1097 → 2.0.1099
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 +11 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-plugkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1099",
|
|
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
|
@@ -187,19 +187,24 @@ function makeHostFunctions(instanceRef) {
|
|
|
187
187
|
|
|
188
188
|
host_vec_search: (qPtr, qLen, k) => {
|
|
189
189
|
try {
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
190
|
+
const raw = readWasmStr(instanceRef.value, qPtr, qLen);
|
|
191
|
+
if (!raw) return writeWasmJson(instanceRef.value, []);
|
|
192
|
+
let parsedQ;
|
|
193
|
+
try { parsedQ = JSON.parse(raw); } catch (_) { parsedQ = { query: raw }; }
|
|
194
|
+
const q = parsedQ.query || raw;
|
|
195
|
+
const scope = parsedQ.scope || 'all';
|
|
192
196
|
const k_ = k > 0 ? k : VEC_K_DEFAULT;
|
|
193
|
-
const body = JSON.stringify({ query: q, limit: k_, scope
|
|
197
|
+
const body = JSON.stringify({ query: q, limit: k_, scope });
|
|
194
198
|
const result = spawnSync(process.execPath, ['-e', `
|
|
195
199
|
fetch('${RS_LEARN_URL}/search', { method: 'POST', headers: { 'content-type': 'application/json' }, body: ${JSON.stringify(body)} })
|
|
196
200
|
.then(r => r.text().then(t => process.stdout.write(t)))
|
|
197
|
-
.catch(e => process.stdout.write(JSON.stringify({ error: e.message
|
|
201
|
+
.catch(e => process.stdout.write(JSON.stringify({ error: e.message })));
|
|
198
202
|
`], { encoding: 'utf-8', timeout: 5000 });
|
|
199
203
|
if (result.status !== 0 || !result.stdout) return writeWasmJson(instanceRef.value, []);
|
|
200
204
|
try {
|
|
201
205
|
const parsed = JSON.parse(result.stdout);
|
|
202
|
-
|
|
206
|
+
const hits = parsed.hits || parsed.results || parsed.episodes || [];
|
|
207
|
+
return writeWasmJson(instanceRef.value, hits);
|
|
203
208
|
} catch (_) {
|
|
204
209
|
return writeWasmJson(instanceRef.value, []);
|
|
205
210
|
}
|
|
@@ -375,7 +380,7 @@ async function runSpoolWatcher(instance, spoolDir) {
|
|
|
375
380
|
try { instance.exports.plugkit_free(bodyPtr, bodyBytes.length); } catch (_) {}
|
|
376
381
|
try { instance.exports.plugkit_free(ptr, len); } catch (_) {}
|
|
377
382
|
|
|
378
|
-
fs.unlinkSync(filePath);
|
|
383
|
+
try { if (fs.existsSync(filePath)) fs.unlinkSync(filePath); } catch (_) {}
|
|
379
384
|
processed.delete(key);
|
|
380
385
|
} catch (e) {
|
|
381
386
|
console.error(`[plugkit-wasm] error processing ${key}: ${e.message}`);
|