@claude-flow/cli 3.38.20 → 3.38.21
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/.claude/helpers/.helpers-version +1 -1
- package/.claude/helpers/helpers.manifest.json +2 -2
- package/catalog-manifest.json +4 -4
- package/dist/src/commands/proxy-lifecycle.js +6 -5
- package/dist/src/log-filters.d.ts +3 -3
- package/dist/src/memory/memory-initializer.js +28 -8
- package/dist/src/proxy/activation.d.ts +14 -0
- package/dist/src/proxy/activation.js +210 -0
- package/dist/src/proxy/install.js +3 -0
- package/dist/src/proxy/paths.d.ts +2 -0
- package/dist/src/proxy/paths.js +4 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts +6 -6
- package/package.json +1 -1
- package/dist/src/ruvector/lattice-wasm.d.ts +0 -14
- package/dist/src/ruvector/lattice-wasm.js +0 -144
- package/plugins/ruflo-metaharness/.claude-flow/daemon-state.json +0 -178
- package/plugins/ruflo-metaharness/.claude-flow/daemon.pid +0 -1
- package/plugins/ruflo-metaharness/.claude-flow/data/pending-insights.jsonl +0 -5
- package/plugins/ruflo-metaharness/.claude-flow/logs/daemon.log +0 -269
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783604774864_ozbujc_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783604774864_ozbujc_result.log +0 -108
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783605513587_ulvmpb_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783605513587_ulvmpb_result.log +0 -209
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783606368867_ahysui_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783606368867_ahysui_result.log +0 -192
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783607120257_lh05rb_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783607120257_lh05rb_result.log +0 -13
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783608020362_j3096j_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783608020362_j3096j_result.log +0 -120
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783608776347_261b61_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783608776347_261b61_result.log +0 -85
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783609621359_s5i6ye_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783609621359_s5i6ye_result.log +0 -13
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783610087998_qihv9v_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783610087998_qihv9v_result.log +0 -17
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783610773920_qlzmxo_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783610773920_qlzmxo_result.log +0 -17
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783611376090_xpqf1z_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783611376090_xpqf1z_result.log +0 -16
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783612097184_9rqfor_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783612097184_9rqfor_result.log +0 -138
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783612811574_4u602j_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783612811574_4u602j_result.log +0 -16
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783613750487_a46ttn_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783613750487_a46ttn_result.log +0 -107
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783614289360_figwc0_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783614289360_figwc0_result.log +0 -200
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783615067640_l7tm6a_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783615067640_l7tm6a_result.log +0 -54
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783615825308_44nor5_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783615825308_44nor5_result.log +0 -85
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783616524771_ut1ftw_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783616524771_ut1ftw_result.log +0 -266
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783617323039_fs3x5a_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783617323039_fs3x5a_result.log +0 -56
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783618049184_1f4yah_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783618049184_1f4yah_result.log +0 -96
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783618793925_4ee7tf_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783618793925_4ee7tf_result.log +0 -481
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783619642574_yjr4mm_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783619642574_yjr4mm_result.log +0 -104
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783620392771_oduto0_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783620392771_oduto0_result.log +0 -148
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783621183670_gd0p1x_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783621183670_gd0p1x_result.log +0 -111
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783621738388_z4k48b_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783621738388_z4k48b_result.log +0 -89
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783622493677_zwc35w_prompt.log +0 -19
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/audit_1783622493677_zwc35w_result.log +0 -207
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783604894861_v6n3ut_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783604894861_v6n3ut_result.log +0 -66
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783605934532_9h8ikb_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783605934532_9h8ikb_result.log +0 -68
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783607181736_t12f4y_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783607181736_t12f4y_result.log +0 -78
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783608341266_zhk0fl_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783608341266_zhk0fl_result.log +0 -68
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783609420180_7xw817_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783609420180_7xw817_result.log +0 -72
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783610535307_2pxofp_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783610535307_2pxofp_result.log +0 -17
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783611437445_ofwnpb_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783611437445_ofwnpb_result.log +0 -60
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783612556827_1cb112_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783612556827_1cb112_result.log +0 -56
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783613579531_18xiax_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783613579531_18xiax_result.log +0 -74
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783614650481_2zdz7w_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783614650481_2zdz7w_result.log +0 -68
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783615742328_rjj69d_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783615742328_rjj69d_result.log +0 -65
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783616767230_1iad99_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783616767230_1iad99_result.log +0 -68
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783617783537_rqagku_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783617783537_rqagku_result.log +0 -56
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783618817343_r1lbhr_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783618817343_r1lbhr_result.log +0 -65
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783619907773_8msfw3_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783619907773_8msfw3_result.log +0 -77
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783621009302_hybdum_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783621009302_hybdum_result.log +0 -64
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783622083681_nznpnx_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783622083681_nznpnx_result.log +0 -56
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/optimize_1783623208340_olsbaw_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783605134860_9jssz9_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783605134860_9jssz9_result.log +0 -69
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783606516743_zftbaa_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783606516743_zftbaa_result.log +0 -92
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783608038317_jrd66e_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783608038317_jrd66e_result.log +0 -92
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783609388416_mc3zoe_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783609388416_mc3zoe_result.log +0 -82
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783610821384_tzqvlb_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783610821384_tzqvlb_result.log +0 -17
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783612023285_buygpo_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783612023285_buygpo_result.log +0 -57
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783613599301_6f78cw_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783613599301_6f78cw_result.log +0 -60
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783615000844_v95ues_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783615000844_v95ues_result.log +0 -69
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783616341693_bl5d9o_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783616341693_bl5d9o_result.log +0 -64
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783617832831_ha6s8d_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783617832831_ha6s8d_result.log +0 -42
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783619384959_s5iiwf_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783619384959_s5iiwf_result.log +0 -47
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783620946263_d7ovai_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783620946263_d7ovai_result.log +0 -52
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783622473846_t839e5_prompt.log +0 -14
- package/plugins/ruflo-metaharness/.claude-flow/logs/headless/testgaps_1783622473846_t839e5_result.log +0 -96
- package/plugins/ruflo-metaharness/.claude-flow/metrics/backup.json +0 -7
- package/plugins/ruflo-metaharness/.claude-flow/metrics/codebase-map.json +0 -11
- package/plugins/ruflo-metaharness/.claude-flow/metrics/consolidation.json +0 -16
- package/plugins/ruflo-metaharness/.claude-flow/metrics/harness-loop.json +0 -83
- package/plugins/ruflo-metaharness/.claude-flow/metrics/performance.json +0 -55
- package/plugins/ruflo-metaharness/.claude-flow/metrics/security-audit.json +0 -206
- package/plugins/ruflo-metaharness/.claude-flow/metrics/test-gaps.json +0 -95
- package/plugins/ruflo-metaharness/.claude-flow/neural/stats.json +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
3.38.
|
|
1
|
+
3.38.21
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest": {
|
|
3
|
-
"version": "3.38.
|
|
3
|
+
"version": "3.38.21",
|
|
4
4
|
"files": {
|
|
5
5
|
"auto-memory-hook.mjs": "85fe05c757421c52137c0bc8545a0896bab6b4714538c2a11d1d0835bfcc8c1c",
|
|
6
6
|
"hook-handler.cjs": "dae295fb9ae2626b89899c19a20cc911541af82b52d2eeb9b214d618b96e9a86",
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"statusline.cjs": "4a48353b4f1566fa4379b00fd0321b6676a22b6cc91fbbd8380ac5183d619468"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
|
-
"signature": "
|
|
11
|
+
"signature": "wxXkWxgHyxCi4QwBfHeomKd+yB4yFN7BGjt34e4fo/Y8TuhUuRqSiw7y+WV2euDa734J/lEx9mP7xMwg4dw2Cw==",
|
|
12
12
|
"algorithm": "ed25519"
|
|
13
13
|
}
|
package/catalog-manifest.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generation":
|
|
4
|
-
"generatedAt": "2026-
|
|
5
|
-
"gitSha": "
|
|
3
|
+
"generation": 6,
|
|
4
|
+
"generatedAt": "2026-09-02T13:38:52.286Z",
|
|
5
|
+
"gitSha": "b3db0180",
|
|
6
6
|
"catalog": {
|
|
7
|
-
"agents":
|
|
7
|
+
"agents": 167,
|
|
8
8
|
"tools": 397,
|
|
9
9
|
"skills": 34
|
|
10
10
|
},
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { output } from '../output.js';
|
|
9
9
|
import { hasConsent, recordConsent, revokeConsent } from '../funnel/index.js';
|
|
10
|
-
import {
|
|
10
|
+
import { uninstallProxy } from '../proxy/install.js';
|
|
11
|
+
import { installAndActivateProxy } from '../proxy/activation.js';
|
|
11
12
|
import { startForeground, startBackground, stopProxy, getProxyStatus, readProxyLogTail, watchProxyLog, ProxyNotInstalledError, ProxyAlreadyRunningError, } from '../proxy/lifecycle.js';
|
|
12
13
|
import { proxyTokenPath } from '../proxy/paths.js';
|
|
13
14
|
import { removeInjectedToken, startTokenRefreshPump } from '../proxy/token-bridge.js';
|
|
@@ -135,8 +136,8 @@ const installSub = {
|
|
|
135
136
|
try {
|
|
136
137
|
const spinner = output.createSpinner({ text: `Installing meta-proxy ${version}...`, spinner: 'dots' });
|
|
137
138
|
spinner.start();
|
|
138
|
-
const result = await
|
|
139
|
-
spinner.succeed(`meta-proxy ${version} installed`);
|
|
139
|
+
const result = await installAndActivateProxy(version, (line) => spinner.setText(line));
|
|
140
|
+
spinner.succeed(`meta-proxy ${version} installed and verified effective`);
|
|
140
141
|
output.writeln(` binary: ${result.binaryPath}`);
|
|
141
142
|
output.writeln(` sha256: ${result.sha256}`);
|
|
142
143
|
return { success: true, data: result };
|
|
@@ -172,8 +173,8 @@ const updateSub = {
|
|
|
172
173
|
try {
|
|
173
174
|
const spinner = output.createSpinner({ text: `Updating meta-proxy to ${version}...`, spinner: 'dots' });
|
|
174
175
|
spinner.start();
|
|
175
|
-
const result = await
|
|
176
|
-
spinner.succeed(`meta-proxy updated to ${version}`);
|
|
176
|
+
const result = await installAndActivateProxy(version, (line) => spinner.setText(line));
|
|
177
|
+
spinner.succeed(`meta-proxy updated to ${version} and verified effective`);
|
|
177
178
|
output.writeln(` binary: ${result.binaryPath}`);
|
|
178
179
|
return { success: true, data: result };
|
|
179
180
|
}
|
|
@@ -40,7 +40,7 @@ declare const STDERR_REDIRECT_PREFIXES: string[];
|
|
|
40
40
|
declare const AGENTDB_MOCK_FALLBACK_DROP_PREFIXES: string[];
|
|
41
41
|
declare const shouldRedirectToStderr: (msg: unknown) => boolean;
|
|
42
42
|
declare const isAgentdbMockFallbackNoise: (msg: unknown) => boolean;
|
|
43
|
-
declare const origWarn: (
|
|
44
|
-
declare const origLog: (
|
|
45
|
-
declare const origError: (
|
|
43
|
+
declare const origWarn: (...data: any[]) => void;
|
|
44
|
+
declare const origLog: (...data: any[]) => void;
|
|
45
|
+
declare const origError: (...data: any[]) => void;
|
|
46
46
|
//# sourceMappingURL=log-filters.d.ts.map
|
|
@@ -1250,13 +1250,33 @@ export async function checkAndMigrateLegacy(options) {
|
|
|
1250
1250
|
* (ReasoningBank, SkillLibrary, ExplainableRecall, etc.) are instantiated.
|
|
1251
1251
|
*
|
|
1252
1252
|
* Uses the memory-bridge's getControllerRegistry() which lazily creates
|
|
1253
|
-
* a singleton ControllerRegistry
|
|
1254
|
-
*
|
|
1253
|
+
* a singleton ControllerRegistry. Deliberately called with NO dbPath so the
|
|
1254
|
+
* bridge resolves its own dedicated file via `getAgentDbPath()` — the same
|
|
1255
|
+
* resolution every other bridge call (bridgeStoreEntry, bridgeGetEntry, ...)
|
|
1256
|
+
* uses when it omits `dbPath`. After this call, all enabled controllers are
|
|
1257
|
+
* ready for immediate use.
|
|
1255
1258
|
*
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1259
|
+
* #3155: this used to be called with the sql.js-facing `memory.db` path
|
|
1260
|
+
* (the one just written by the block above, via `resolveDbPath()`), which
|
|
1261
|
+
* seeded the process-wide ControllerRegistry singleton with THAT file as
|
|
1262
|
+
* AgentDB's native better-sqlite3 database — instead of the dedicated
|
|
1263
|
+
* `agentdb-memory.db` sibling `getAgentDbPath()` exists specifically to
|
|
1264
|
+
* provide (#2786, so native better-sqlite3 doesn't hit a possibly-encrypted
|
|
1265
|
+
* `memory.db`). Because `initializeMemoryDatabase()` only reaches this call
|
|
1266
|
+
* on a database's FIRST-EVER init (the `#1791.6` already-exists branch above
|
|
1267
|
+
* returns early without activating anything), a bridge started against a
|
|
1268
|
+
* brand-new `.swarm/` directory would activate the registry against
|
|
1269
|
+
* `memory.db`, store/retrieve correctly for that process's lifetime, and
|
|
1270
|
+
* then a SUBSEQUENT process — where `.swarm/memory.db` already exists so
|
|
1271
|
+
* this init path is skipped — would have its first bridge call activate the
|
|
1272
|
+
* registry against `agentdb-memory.db` instead (via the `dbPath ||
|
|
1273
|
+
* getAgentDbPath()` fallback in memory-bridge.ts's `getRegistry()`), an
|
|
1274
|
+
* empty file that never received the earlier writes. Restarting the bridge
|
|
1275
|
+
* therefore silently lost read access to everything it had written, with no
|
|
1276
|
+
* error anywhere. Passing no dbPath here makes both code paths agree on
|
|
1277
|
+
* `agentdb-memory.db` every time, regardless of init history.
|
|
1258
1278
|
*/
|
|
1259
|
-
async function activateControllerRegistry(
|
|
1279
|
+
async function activateControllerRegistry(verbose) {
|
|
1260
1280
|
const startTime = performance.now();
|
|
1261
1281
|
const activated = [];
|
|
1262
1282
|
const failed = [];
|
|
@@ -1265,7 +1285,7 @@ async function activateControllerRegistry(dbPath, verbose) {
|
|
|
1265
1285
|
if (!bridge) {
|
|
1266
1286
|
return { activated, failed, initTimeMs: performance.now() - startTime };
|
|
1267
1287
|
}
|
|
1268
|
-
const registry = await bridge.getControllerRegistry(
|
|
1288
|
+
const registry = await bridge.getControllerRegistry();
|
|
1269
1289
|
if (!registry) {
|
|
1270
1290
|
return { activated, failed, initTimeMs: performance.now() - startTime };
|
|
1271
1291
|
}
|
|
@@ -1708,7 +1728,7 @@ export async function initializeMemoryDatabase(options) {
|
|
|
1708
1728
|
fs.writeFileSync(schemaPath, MEMORY_SCHEMA_V3 + '\n' + getInitialMetadata(backend));
|
|
1709
1729
|
// ADR-053: Activate ControllerRegistry so controllers (ReasoningBank,
|
|
1710
1730
|
// SkillLibrary, ExplainableRecall, etc.) are instantiated during init
|
|
1711
|
-
const controllerResult = await activateControllerRegistry(
|
|
1731
|
+
const controllerResult = await activateControllerRegistry(verbose);
|
|
1712
1732
|
return {
|
|
1713
1733
|
success: true,
|
|
1714
1734
|
backend,
|
|
@@ -1768,7 +1788,7 @@ export async function initializeMemoryDatabase(options) {
|
|
|
1768
1788
|
sqliteHeader[27] = 0x20; // leaf payload
|
|
1769
1789
|
writeFileRestricted(dbPath, sqliteHeader, { encrypt: true });
|
|
1770
1790
|
// ADR-053: Activate ControllerRegistry even on fallback path
|
|
1771
|
-
const controllerResult = await activateControllerRegistry(
|
|
1791
|
+
const controllerResult = await activateControllerRegistry(verbose);
|
|
1772
1792
|
return {
|
|
1773
1793
|
success: true,
|
|
1774
1794
|
backend,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type InstallResult } from './install.js';
|
|
2
|
+
export interface EffectiveProxy {
|
|
3
|
+
version: string;
|
|
4
|
+
pid: number;
|
|
5
|
+
executable: string;
|
|
6
|
+
}
|
|
7
|
+
type Wait = (milliseconds: number) => Promise<void>;
|
|
8
|
+
export declare function probeEffectiveProxy(fetcher?: typeof fetch, platform?: NodeJS.Platform): Promise<EffectiveProxy | null>;
|
|
9
|
+
export declare function acquireProxyInstallLease(wait?: Wait): Promise<() => void>;
|
|
10
|
+
export declare function installAndActivateProxy(version: string, log?: (line: string) => void): Promise<InstallResult & {
|
|
11
|
+
pid: number;
|
|
12
|
+
}>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=activation.d.ts.map
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/** Transactional activation of the daemon that actually owns the proxy port. */
|
|
2
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import { installProxy } from './install.js';
|
|
7
|
+
import { isLoopbackBind, proxyBinaryPath, proxyConfigPath, proxyInstallLockPath, proxyInstallManifestPath, proxyLogFilePath, proxyPidFilePath, } from './paths.js';
|
|
8
|
+
const waitNormally = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
9
|
+
function processExists(pid) {
|
|
10
|
+
try {
|
|
11
|
+
process.kill(pid, 0);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return error.code === 'EPERM';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function effectiveEndpoint() {
|
|
19
|
+
let bind = '127.0.0.1:11435';
|
|
20
|
+
try {
|
|
21
|
+
const match = fs.readFileSync(proxyConfigPath(), 'utf8').match(/^bind\s*=\s*"([^"]+)"\s*$/m);
|
|
22
|
+
if (match?.[1])
|
|
23
|
+
bind = match[1];
|
|
24
|
+
}
|
|
25
|
+
catch { /* documented default */ }
|
|
26
|
+
if (!isLoopbackBind(bind))
|
|
27
|
+
throw new Error(`Refusing to probe non-loopback Meta-Proxy bind "${bind}".`);
|
|
28
|
+
return `http://${bind}`;
|
|
29
|
+
}
|
|
30
|
+
function executableFor(pid, platform) {
|
|
31
|
+
try {
|
|
32
|
+
if (platform === 'linux') {
|
|
33
|
+
const result = spawnSync('readlink', ['-f', `/proc/${pid}/exe`], { encoding: 'utf8', timeout: 2_000 });
|
|
34
|
+
return result.status === 0 ? result.stdout.trim() || null : null;
|
|
35
|
+
}
|
|
36
|
+
if (platform === 'win32') {
|
|
37
|
+
const command = `$p = Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}'; if ($null -ne $p) { [Console]::Out.Write($p.ExecutablePath) }`;
|
|
38
|
+
const result = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', command], { encoding: 'utf8', timeout: 2_000, windowsHide: true });
|
|
39
|
+
return result.status === 0 ? result.stdout.trim() || null : null;
|
|
40
|
+
}
|
|
41
|
+
const result = spawnSync('ps', ['-p', String(pid), '-o', 'comm='], { encoding: 'utf8', timeout: 2_000 });
|
|
42
|
+
return result.status === 0 ? result.stdout.trim() || null : null;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function isSupportedOwner(executable, platform) {
|
|
49
|
+
const name = platform === 'win32' ? 'meta-proxy.exe' : 'meta-proxy';
|
|
50
|
+
const normalize = (value) => platform === 'win32' ? path.resolve(value).toLowerCase() : path.resolve(value);
|
|
51
|
+
const allowed = [
|
|
52
|
+
proxyBinaryPath(),
|
|
53
|
+
path.join(homedir(), '.metaharness', 'meta-proxy', 'bin', name),
|
|
54
|
+
path.join(homedir(), '.metaharness', 'bin', name),
|
|
55
|
+
path.join(homedir(), '.cargo', 'bin', name),
|
|
56
|
+
].map(normalize);
|
|
57
|
+
return allowed.includes(normalize(executable));
|
|
58
|
+
}
|
|
59
|
+
export async function probeEffectiveProxy(fetcher = globalThis.fetch, platform = process.platform) {
|
|
60
|
+
const endpoint = effectiveEndpoint();
|
|
61
|
+
try {
|
|
62
|
+
const controller = new AbortController();
|
|
63
|
+
const timer = setTimeout(() => controller.abort(), 1_000);
|
|
64
|
+
let response;
|
|
65
|
+
try {
|
|
66
|
+
response = await fetcher(`${endpoint}/version`, { signal: controller.signal });
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
}
|
|
71
|
+
if (!response.ok)
|
|
72
|
+
return null;
|
|
73
|
+
const body = await response.json();
|
|
74
|
+
if (typeof body.version !== 'string' || !/^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/.test(body.version))
|
|
75
|
+
return null;
|
|
76
|
+
if (!Number.isSafeInteger(body.pid) || Number(body.pid) <= 0)
|
|
77
|
+
return null;
|
|
78
|
+
const executable = executableFor(Number(body.pid), platform);
|
|
79
|
+
return executable ? { version: body.version, pid: Number(body.pid), executable } : null;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export async function acquireProxyInstallLease(wait = waitNormally) {
|
|
86
|
+
const lock = proxyInstallLockPath();
|
|
87
|
+
fs.mkdirSync(path.dirname(lock), { recursive: true, mode: 0o700 });
|
|
88
|
+
for (let attempt = 0; attempt < 200; attempt++) {
|
|
89
|
+
try {
|
|
90
|
+
fs.mkdirSync(lock, { mode: 0o700 });
|
|
91
|
+
fs.writeFileSync(path.join(lock, 'owner'), `${process.pid}\n`, { mode: 0o600 });
|
|
92
|
+
return () => fs.rmSync(lock, { recursive: true, force: true });
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error.code !== 'EEXIST')
|
|
96
|
+
throw error;
|
|
97
|
+
try {
|
|
98
|
+
const age = Date.now() - fs.statSync(lock).mtimeMs;
|
|
99
|
+
const owner = Number.parseInt(fs.readFileSync(path.join(lock, 'owner'), 'utf8').trim(), 10);
|
|
100
|
+
if (age > 120_000 && (!Number.isSafeInteger(owner) || owner <= 0 || !processExists(owner))) {
|
|
101
|
+
fs.rmSync(lock, { recursive: true, force: true });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch { /* another installer may still be writing its owner */ }
|
|
106
|
+
await wait(50);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
throw new Error('Another Ruflo/MetaHarness installer still owns the Meta-Proxy install lease.');
|
|
110
|
+
}
|
|
111
|
+
async function stopEffective(wait) {
|
|
112
|
+
const owner = await probeEffectiveProxy();
|
|
113
|
+
if (!owner)
|
|
114
|
+
return null;
|
|
115
|
+
if (!isSupportedOwner(owner.executable, process.platform)) {
|
|
116
|
+
throw new Error(`Meta-Proxy port owner pid ${owner.pid} is not a recognized Ruflo/MetaHarness binary; refusing to signal it.`);
|
|
117
|
+
}
|
|
118
|
+
process.kill(owner.pid, 'SIGTERM');
|
|
119
|
+
for (let attempt = 0; attempt < 40; attempt++) {
|
|
120
|
+
await wait(50);
|
|
121
|
+
const current = await probeEffectiveProxy();
|
|
122
|
+
if (!current || current.pid !== owner.pid)
|
|
123
|
+
return owner;
|
|
124
|
+
}
|
|
125
|
+
throw new Error(`Stale Meta-Proxy pid ${owner.pid} did not stop.`);
|
|
126
|
+
}
|
|
127
|
+
function launch(binary) {
|
|
128
|
+
fs.mkdirSync(path.dirname(proxyLogFilePath()), { recursive: true, mode: 0o700 });
|
|
129
|
+
const log = fs.openSync(proxyLogFilePath(), 'a', 0o600);
|
|
130
|
+
try {
|
|
131
|
+
const child = spawn(binary, [], { detached: true, stdio: ['ignore', log, log], windowsHide: true });
|
|
132
|
+
if (!child.pid)
|
|
133
|
+
throw new Error('Meta-Proxy did not return a process id.');
|
|
134
|
+
child.unref();
|
|
135
|
+
fs.writeFileSync(proxyPidFilePath(), `${child.pid}\n`, { mode: 0o600 });
|
|
136
|
+
return child.pid;
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
fs.closeSync(log);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function launchAndVerify(binary, version, wait) {
|
|
143
|
+
const pid = launch(binary);
|
|
144
|
+
for (let attempt = 0; attempt < 100; attempt++) {
|
|
145
|
+
await wait(50);
|
|
146
|
+
const current = await probeEffectiveProxy();
|
|
147
|
+
if (current?.pid === pid && current.version === version && path.resolve(current.executable) === path.resolve(binary))
|
|
148
|
+
return current;
|
|
149
|
+
if (current && current.pid !== pid) {
|
|
150
|
+
try {
|
|
151
|
+
process.kill(pid, 'SIGTERM');
|
|
152
|
+
}
|
|
153
|
+
catch { /* already exited */ }
|
|
154
|
+
throw new Error(`Competing Meta-Proxy pid ${current.pid} won the port with version ${current.version}.`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
process.kill(pid, 'SIGTERM');
|
|
159
|
+
}
|
|
160
|
+
catch { /* already exited */ }
|
|
161
|
+
throw new Error(`Meta-Proxy v${version} did not become the effective daemon.`);
|
|
162
|
+
}
|
|
163
|
+
export async function installAndActivateProxy(version, log) {
|
|
164
|
+
const wait = waitNormally;
|
|
165
|
+
const binary = proxyBinaryPath();
|
|
166
|
+
const manifest = proxyInstallManifestPath();
|
|
167
|
+
const binaryBackup = `${binary}.rollback`;
|
|
168
|
+
const manifestBackup = `${manifest}.rollback`;
|
|
169
|
+
let release = null;
|
|
170
|
+
let prior = null;
|
|
171
|
+
try {
|
|
172
|
+
release = await acquireProxyInstallLease(wait);
|
|
173
|
+
prior = await stopEffective(wait);
|
|
174
|
+
fs.rmSync(binaryBackup, { force: true });
|
|
175
|
+
fs.rmSync(manifestBackup, { force: true });
|
|
176
|
+
if (fs.existsSync(binary))
|
|
177
|
+
fs.copyFileSync(binary, binaryBackup);
|
|
178
|
+
if (fs.existsSync(manifest))
|
|
179
|
+
fs.copyFileSync(manifest, manifestBackup);
|
|
180
|
+
const installed = await installProxy({ version, log });
|
|
181
|
+
const effective = await launchAndVerify(installed.binaryPath, installed.version, wait);
|
|
182
|
+
return { ...installed, pid: effective.pid };
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
const failure = error instanceof Error ? error.message : String(error);
|
|
186
|
+
if (fs.existsSync(binaryBackup)) {
|
|
187
|
+
try {
|
|
188
|
+
await stopEffective(wait);
|
|
189
|
+
fs.rmSync(binary, { force: true });
|
|
190
|
+
fs.renameSync(binaryBackup, binary);
|
|
191
|
+
fs.rmSync(manifest, { force: true });
|
|
192
|
+
if (fs.existsSync(manifestBackup))
|
|
193
|
+
fs.renameSync(manifestBackup, manifest);
|
|
194
|
+
if (prior)
|
|
195
|
+
await launchAndVerify(prior.executable === binary ? binary : prior.executable, prior.version, wait);
|
|
196
|
+
}
|
|
197
|
+
catch (rollbackError) {
|
|
198
|
+
throw new Error(`${failure} Rollback failed: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`);
|
|
199
|
+
}
|
|
200
|
+
throw new Error(`${failure} Previous Meta-Proxy ${prior ? 'was restored and verified' : 'binary was restored; it was not running before the upgrade'}.`);
|
|
201
|
+
}
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
fs.rmSync(binaryBackup, { force: true });
|
|
206
|
+
fs.rmSync(manifestBackup, { force: true });
|
|
207
|
+
release?.();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=activation.js.map
|
|
@@ -143,6 +143,9 @@ export async function installProxy(opts) {
|
|
|
143
143
|
const tmp = `${finalPath}.tmp`;
|
|
144
144
|
fs.copyFileSync(extractedBinaryPath, tmp);
|
|
145
145
|
fs.chmodSync(tmp, 0o755);
|
|
146
|
+
// The activation transaction has already stopped and backed up the old
|
|
147
|
+
// daemon. Windows rename does not replace an existing executable.
|
|
148
|
+
fs.rmSync(finalPath, { force: true });
|
|
146
149
|
fs.renameSync(tmp, finalPath);
|
|
147
150
|
const liveSha = sha256Hex(fs.readFileSync(finalPath));
|
|
148
151
|
const manifest = {
|
|
@@ -10,6 +10,8 @@ export declare function proxyPidFilePath(): string;
|
|
|
10
10
|
export declare function proxyLockFilePath(): string;
|
|
11
11
|
export declare function proxyLogFilePath(): string;
|
|
12
12
|
export declare function proxyInstallManifestPath(): string;
|
|
13
|
+
/** Shared by Ruflo and MetaHarness so two IDE windows cannot race an upgrade. */
|
|
14
|
+
export declare function proxyInstallLockPath(): string;
|
|
13
15
|
export declare function proxyConfigPath(): string;
|
|
14
16
|
export declare function proxyTokenPath(): string;
|
|
15
17
|
export declare function proxyInjectedTokenPath(): string;
|
package/dist/src/proxy/paths.js
CHANGED
|
@@ -23,6 +23,10 @@ export function proxyLogFilePath() {
|
|
|
23
23
|
export function proxyInstallManifestPath() {
|
|
24
24
|
return join(funnelStateDir(), 'proxy', 'install-manifest.json');
|
|
25
25
|
}
|
|
26
|
+
/** Shared by Ruflo and MetaHarness so two IDE windows cannot race an upgrade. */
|
|
27
|
+
export function proxyInstallLockPath() {
|
|
28
|
+
return join(funnelStateDir(), 'meta-proxy-install.lock');
|
|
29
|
+
}
|
|
26
30
|
export function proxyConfigPath() {
|
|
27
31
|
return join(funnelStateDir(), 'proxy-config.toml');
|
|
28
32
|
}
|
|
@@ -159,14 +159,14 @@ export declare const SpawnAgentSchema: z.ZodObject<{
|
|
|
159
159
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
160
160
|
}, "strip", z.ZodTypeAny, {
|
|
161
161
|
type: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
|
|
162
|
-
id?: string | undefined;
|
|
163
162
|
config?: Record<string, unknown> | undefined;
|
|
164
163
|
timeout?: number | undefined;
|
|
164
|
+
id?: string | undefined;
|
|
165
165
|
}, {
|
|
166
166
|
type: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
|
|
167
|
-
id?: string | undefined;
|
|
168
167
|
config?: Record<string, unknown> | undefined;
|
|
169
168
|
timeout?: number | undefined;
|
|
169
|
+
id?: string | undefined;
|
|
170
170
|
}>;
|
|
171
171
|
/**
|
|
172
172
|
* Task input schema
|
|
@@ -181,13 +181,13 @@ export declare const TaskInputSchema: z.ZodObject<{
|
|
|
181
181
|
taskId: string;
|
|
182
182
|
content: string;
|
|
183
183
|
agentType: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
|
|
184
|
-
priority?: "
|
|
184
|
+
priority?: "critical" | "high" | "medium" | "low" | undefined;
|
|
185
185
|
metadata?: Record<string, unknown> | undefined;
|
|
186
186
|
}, {
|
|
187
187
|
taskId: string;
|
|
188
188
|
content: string;
|
|
189
189
|
agentType: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
|
|
190
|
-
priority?: "
|
|
190
|
+
priority?: "critical" | "high" | "medium" | "low" | undefined;
|
|
191
191
|
metadata?: Record<string, unknown> | undefined;
|
|
192
192
|
}>;
|
|
193
193
|
/**
|
|
@@ -234,16 +234,16 @@ export declare const ExecutorConfigSchema: z.ZodObject<{
|
|
|
234
234
|
cwd: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
235
235
|
allowSudo: z.ZodDefault<z.ZodBoolean>;
|
|
236
236
|
}, "strip", z.ZodTypeAny, {
|
|
237
|
-
timeout: number;
|
|
238
237
|
allowedCommands: string[];
|
|
238
|
+
timeout: number;
|
|
239
239
|
maxBuffer: number;
|
|
240
240
|
allowSudo: boolean;
|
|
241
241
|
blockedPatterns?: string[] | undefined;
|
|
242
242
|
cwd?: string | undefined;
|
|
243
243
|
}, {
|
|
244
244
|
allowedCommands: string[];
|
|
245
|
-
timeout?: number | undefined;
|
|
246
245
|
blockedPatterns?: string[] | undefined;
|
|
246
|
+
timeout?: number | undefined;
|
|
247
247
|
maxBuffer?: number | undefined;
|
|
248
248
|
cwd?: string | undefined;
|
|
249
249
|
allowSudo?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.38.
|
|
3
|
+
"version": "3.38.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Default package name (ruvnet WASM convention); override with RUFLO_LATTICE_WASM_PKG. */
|
|
2
|
-
export declare const LATTICE_WASM_PKG: string;
|
|
3
|
-
export type LatticeModel = 'minilm' | 'bge' | 'paraphrase-minilm' | 'qwen3-0.6b' | string;
|
|
4
|
-
export declare const DEFAULT_LATTICE_MODEL: LatticeModel;
|
|
5
|
-
/** Is the Lattice WASM embedder installed + initializable? Cached; never throws. */
|
|
6
|
-
export declare function latticeAvailable(): Promise<boolean>;
|
|
7
|
-
/** The models Lattice reports (empty until availability is probed). */
|
|
8
|
-
export declare function latticeModels(): LatticeModel[];
|
|
9
|
-
/**
|
|
10
|
-
* Embed `text` with `model` via Lattice WASM. Returns null on any failure so the
|
|
11
|
-
* caller can fall through to the next tier. Never throws.
|
|
12
|
-
*/
|
|
13
|
-
export declare function latticeEmbed(text: string, model?: LatticeModel): Promise<number[] | null>;
|
|
14
|
-
//# sourceMappingURL=lattice-wasm.d.ts.map
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lattice WASM embedder adapter — the primary embedding tier (ADR: embedding
|
|
3
|
-
* substrate upgrade). Replaces hash placeholders with real semantic embeddings
|
|
4
|
-
* and adds multiple models (miniLM, bge, multi-paraphrase-miniLM, GPU qwen3-0.6B).
|
|
5
|
-
*
|
|
6
|
-
* Built on the proven `@ruvector/ruvllm-wasm` optional-dependency convention:
|
|
7
|
-
* - dynamically imported (never a hard dependency),
|
|
8
|
-
* - WASM initialized from bundled bytes,
|
|
9
|
-
* - fully FAIL-CLOSED: if the package is absent, the WASM fails to init, or the
|
|
10
|
-
* embed API differs, `latticeAvailable()` returns false and callers fall
|
|
11
|
-
* through to the existing ruvector-ONNX → hash tiers with ZERO regression.
|
|
12
|
-
*
|
|
13
|
-
* The package specifier is configurable (`RUFLO_LATTICE_WASM_PKG`) so the exact
|
|
14
|
-
* published name can be set without a code change; the API is probed tolerantly.
|
|
15
|
-
* Opt-in for the GPU model: qwen3 is only selected when explicitly requested.
|
|
16
|
-
*/
|
|
17
|
-
import { createRequire } from 'module';
|
|
18
|
-
import { readFileSync } from 'fs';
|
|
19
|
-
const require_ = createRequire(import.meta.url);
|
|
20
|
-
/** Default package name (ruvnet WASM convention); override with RUFLO_LATTICE_WASM_PKG. */
|
|
21
|
-
export const LATTICE_WASM_PKG = process.env.RUFLO_LATTICE_WASM_PKG || '@ruvector/lattice-wasm';
|
|
22
|
-
export const DEFAULT_LATTICE_MODEL = process.env.RUFLO_EMBED_MODEL || 'minilm';
|
|
23
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
24
|
-
let _mod = null;
|
|
25
|
-
let _ready = false;
|
|
26
|
-
let _probed = false;
|
|
27
|
-
let _available = false;
|
|
28
|
-
let _models = [];
|
|
29
|
-
async function loadModule() {
|
|
30
|
-
if (_mod)
|
|
31
|
-
return _mod;
|
|
32
|
-
const spec = LATTICE_WASM_PKG;
|
|
33
|
-
_mod = await import(spec).catch(() => null); // optional — absent ⇒ null ⇒ unavailable
|
|
34
|
-
return _mod;
|
|
35
|
-
}
|
|
36
|
-
async function ensureInit() {
|
|
37
|
-
if (_ready)
|
|
38
|
-
return true;
|
|
39
|
-
const mod = await loadModule();
|
|
40
|
-
if (!mod)
|
|
41
|
-
return false;
|
|
42
|
-
try {
|
|
43
|
-
// ruvnet WASM convention: initSync({ module: <wasm bytes> }); tolerate variants.
|
|
44
|
-
if (!_ready && typeof mod.initSync === 'function') {
|
|
45
|
-
let wasmBytes;
|
|
46
|
-
for (const cand of ['lattice_wasm_bg.wasm', 'lattice_bg.wasm', 'index_bg.wasm']) {
|
|
47
|
-
try {
|
|
48
|
-
wasmBytes = readFileSync(require_.resolve(`${LATTICE_WASM_PKG}/${cand}`));
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
catch { /* try next */ }
|
|
52
|
-
}
|
|
53
|
-
mod.initSync(wasmBytes ? { module: wasmBytes } : undefined);
|
|
54
|
-
}
|
|
55
|
-
else if (typeof mod.default === 'function') {
|
|
56
|
-
await mod.default(); // some wasm-bindgen builds export an async default init
|
|
57
|
-
}
|
|
58
|
-
_ready = true;
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return false; // init failed ⇒ fail closed
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/** Extract a plain number[] from whatever shape the module's embed returns. */
|
|
66
|
-
function toVec(r) {
|
|
67
|
-
const v = (r && typeof r === 'object' && 'embedding' in r) ? r.embedding : r;
|
|
68
|
-
if (!v)
|
|
69
|
-
return null;
|
|
70
|
-
if (Array.isArray(v))
|
|
71
|
-
return v;
|
|
72
|
-
if (v.length !== undefined)
|
|
73
|
-
return Array.from(v);
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
/** Is the Lattice WASM embedder installed + initializable? Cached; never throws. */
|
|
77
|
-
export async function latticeAvailable() {
|
|
78
|
-
if (_probed)
|
|
79
|
-
return _available;
|
|
80
|
-
_probed = true;
|
|
81
|
-
try {
|
|
82
|
-
if (!(await ensureInit())) {
|
|
83
|
-
_available = false;
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
const mod = _mod;
|
|
87
|
-
// discover models (tolerant): listModels() / models / MODELS
|
|
88
|
-
try {
|
|
89
|
-
const list = typeof mod.listModels === 'function' ? mod.listModels() : (mod.models ?? mod.MODELS);
|
|
90
|
-
if (Array.isArray(list) && list.length)
|
|
91
|
-
_models = list;
|
|
92
|
-
}
|
|
93
|
-
catch { /* leave default */ }
|
|
94
|
-
if (!_models.length)
|
|
95
|
-
_models = [DEFAULT_LATTICE_MODEL];
|
|
96
|
-
// verify an actual embed succeeds (the ADR-086 "loads but runtime-fails" trap).
|
|
97
|
-
const probe = await latticeEmbedRaw('probe', DEFAULT_LATTICE_MODEL);
|
|
98
|
-
_available = !!probe && probe.length > 0;
|
|
99
|
-
return _available;
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
_available = false;
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/** The models Lattice reports (empty until availability is probed). */
|
|
107
|
-
export function latticeModels() { return [..._models]; }
|
|
108
|
-
async function latticeEmbedRaw(text, model) {
|
|
109
|
-
const mod = _mod;
|
|
110
|
-
if (!mod)
|
|
111
|
-
return null;
|
|
112
|
-
// tolerant API probing across plausible wasm-bindgen surfaces.
|
|
113
|
-
const attempts = [
|
|
114
|
-
() => typeof mod.embed === 'function' ? mod.embed(text, model) : undefined,
|
|
115
|
-
() => typeof mod.embed === 'function' ? mod.embed(text) : undefined,
|
|
116
|
-
() => typeof mod.embedText === 'function' ? mod.embedText(text, model) : undefined,
|
|
117
|
-
() => typeof mod.Embedder === 'function' ? new mod.Embedder(model).embed(text) : undefined,
|
|
118
|
-
];
|
|
119
|
-
for (const a of attempts) {
|
|
120
|
-
try {
|
|
121
|
-
const r = await a();
|
|
122
|
-
const v = toVec(r);
|
|
123
|
-
if (v)
|
|
124
|
-
return v;
|
|
125
|
-
}
|
|
126
|
-
catch { /* try next surface */ }
|
|
127
|
-
}
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Embed `text` with `model` via Lattice WASM. Returns null on any failure so the
|
|
132
|
-
* caller can fall through to the next tier. Never throws.
|
|
133
|
-
*/
|
|
134
|
-
export async function latticeEmbed(text, model = DEFAULT_LATTICE_MODEL) {
|
|
135
|
-
try {
|
|
136
|
-
if (!(await latticeAvailable()))
|
|
137
|
-
return null;
|
|
138
|
-
return await latticeEmbedRaw(text, model);
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=lattice-wasm.js.map
|