gm-plugkit 2.0.1249 → 2.0.1251

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1249",
3
+ "version": "2.0.1251",
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": {
@@ -477,31 +477,6 @@ function readCurrentSess() {
477
477
  return __sessCache.value;
478
478
  }
479
479
 
480
- // iter13: dedup set for host_vec_embed.failed event emissions — we only
481
- // want one event per distinct failure-reason per process, not one per
482
- // embed call.
483
- const _hostVecEmbedFailKeys = new Set();
484
-
485
- let _rsLearnEmbedPath = undefined;
486
- function resolveRsLearnEmbedPath() {
487
- if (_rsLearnEmbedPath !== undefined) return _rsLearnEmbedPath;
488
- const isWin = process.platform === 'win32';
489
- const exe = isWin ? 'rs-learn-embed.exe' : 'rs-learn-embed';
490
- const candidates = [];
491
- if (process.env.RS_LEARN_EMBED_PATH) candidates.push(process.env.RS_LEARN_EMBED_PATH);
492
- const home = os.homedir();
493
- if (home) candidates.push(path.join(home, '.cargo', 'bin', exe));
494
- if (process.env.RS_LEARN_DEV_ROOT) candidates.push(path.join(process.env.RS_LEARN_DEV_ROOT, 'target', 'release', exe));
495
- const devRoot = path.resolve(__dirname, '..', '..', '..', 'rs-learn');
496
- candidates.push(path.join(devRoot, 'target', 'release', exe));
497
- if (isWin) candidates.push(path.join('C:\\dev\\rs-learn\\target\\release', exe));
498
- for (const c of candidates) {
499
- try { if (c && fs.existsSync(c)) { _rsLearnEmbedPath = c; return c; } } catch (_) {}
500
- }
501
- _rsLearnEmbedPath = null;
502
- return null;
503
- }
504
-
505
480
  function logEvent(sub, event, fields) {
506
481
  if (process.env.GM_LOG_DISABLE) return;
507
482
  try {
@@ -1449,84 +1424,6 @@ function makeHostFunctions(instanceRef) {
1449
1424
  }
1450
1425
  },
1451
1426
 
1452
- host_vec_embed: (textPtr, textLen) => {
1453
- try {
1454
- const text = readWasmStr(instanceRef.value, textPtr, textLen);
1455
- if (!text) return 0n;
1456
- const binPath = resolveRsLearnEmbedPath();
1457
- if (!binPath) {
1458
- const key = 'no-binary';
1459
- if (!_hostVecEmbedFailKeys.has(key)) {
1460
- _hostVecEmbedFailKeys.add(key);
1461
- try {
1462
- logEvent('plugkit', 'host_vec_embed.no-binary', {
1463
- hint: 'rs-learn-embed sidecar not found. Set RS_LEARN_EMBED_PATH or cargo install --path C:\\dev\\rs-learn\\crates\\embed.',
1464
- });
1465
- } catch (_) {}
1466
- }
1467
- return 0n;
1468
- }
1469
- const reqLine = JSON.stringify({ id: 1, text }) + '\n';
1470
- const cacheDir = path.join(process.cwd(), '.gm', 'embed-cache');
1471
- try { fs.mkdirSync(cacheDir, { recursive: true }); } catch (_) {}
1472
- const result = spawnSync(binPath, [], {
1473
- input: reqLine,
1474
- encoding: 'utf-8',
1475
- timeout: 300000,
1476
- windowsHide: true,
1477
- env: { ...process.env, RS_LEARN_EMBED_CACHE: cacheDir },
1478
- });
1479
- if (result.status !== 0) {
1480
- const reason = (result.stderr || 'unknown').slice(0, 300);
1481
- const key = String(result.status) + '|' + reason;
1482
- if (!_hostVecEmbedFailKeys.has(key)) {
1483
- _hostVecEmbedFailKeys.add(key);
1484
- try {
1485
- logEvent('plugkit', 'host_vec_embed.failed', {
1486
- status: result.status,
1487
- reason,
1488
- text_len: text.length,
1489
- via: 'rs-learn-embed sidecar',
1490
- });
1491
- } catch (_) {}
1492
- }
1493
- return 0n;
1494
- }
1495
- const lines = (result.stdout || '').split('\n').filter(l => l.trim());
1496
- for (let i = lines.length - 1; i >= 0; i--) {
1497
- try {
1498
- const j = JSON.parse(lines[i]);
1499
- if (Array.isArray(j.embedding)) {
1500
- return writeWasmStr(instanceRef.value, JSON.stringify(j.embedding));
1501
- }
1502
- if (j.error) {
1503
- const key = 'sidecar-error|' + j.error;
1504
- if (!_hostVecEmbedFailKeys.has(key)) {
1505
- _hostVecEmbedFailKeys.add(key);
1506
- try { logEvent('plugkit', 'host_vec_embed.failed', { reason: j.error, via: 'rs-learn-embed sidecar' }); } catch (_) {}
1507
- }
1508
- return 0n;
1509
- }
1510
- } catch (_) {}
1511
- }
1512
- const key = 'no-embedding';
1513
- if (!_hostVecEmbedFailKeys.has(key)) {
1514
- _hostVecEmbedFailKeys.add(key);
1515
- try {
1516
- logEvent('plugkit', 'host_vec_embed.failed', {
1517
- reason: 'no embedding in sidecar response',
1518
- stdout_excerpt: (result.stdout || '').slice(0, 300),
1519
- via: 'rs-learn-embed sidecar',
1520
- });
1521
- } catch (_) {}
1522
- }
1523
- return 0n;
1524
- } catch (e) {
1525
- try { logEvent('plugkit', 'host_vec_embed.exception', { message: e.message }); } catch (_) {}
1526
- return 0n;
1527
- }
1528
- },
1529
-
1530
1427
  host_exec_js: (codePtr, codeLen, optsPtr, optsLen) => {
1531
1428
  try {
1532
1429
  const code = readWasmStr(instanceRef.value, codePtr, codeLen);
@@ -1588,6 +1485,16 @@ function makeHostFunctions(instanceRef) {
1588
1485
 
1589
1486
  host_now_ms: () => BigInt(Date.now()),
1590
1487
 
1488
+ host_random_fill: (ptr, len) => {
1489
+ try {
1490
+ const buf = instanceRef.value.exports.memory.buffer;
1491
+ crypto.randomFillSync(new Uint8Array(buf, ptr, len));
1492
+ return 1;
1493
+ } catch (_) {
1494
+ return 0;
1495
+ }
1496
+ },
1497
+
1591
1498
  host_browser_exec: (bodyPtr, bodyLen, cwdPtr, cwdLen, sidPtr, sidLen) => {
1592
1499
  try {
1593
1500
  const body = readWasmStr(instanceRef.value, bodyPtr, bodyLen);
package/plugkit.sha256 CHANGED
@@ -1 +1 @@
1
- {"plugkit.wasm":"75e1cce243a055d4d6e780dbe28744b89466dcb1c58fb2ebd87125206c78263d"}
1
+ {"plugkit.wasm":"ffebec63cb3af5b3e42837bbed5d166a0a6a83d5c3c5c549e4d9580334b8af4f"}
package/plugkit.version CHANGED
@@ -1 +1 @@
1
- 0.1.459
1
+ 0.1.460