claude-flow 3.75.3 → 3.76.1
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/.proven-config-version +1 -0
- package/.claude/helpers/auto-memory-hook.mjs +4 -4
- package/.claude/proven-config.json +42 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts +3 -3
- package/package.json +1 -1
- package/v3/@claude-flow/cli/README.md +78 -194
- package/v3/@claude-flow/cli/catalog-manifest.json +6 -6
- package/v3/@claude-flow/cli/dist/src/commands/hooks.js +1 -1
- package/v3/@claude-flow/cli/dist/src/init/helpers-generator.js +7 -6
- package/v3/@claude-flow/cli/dist/src/init/settings-risk-scanner.js +16 -1
- package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +64 -6
- package/v3/@claude-flow/cli/dist/src/mcp-tools/metaharness-tools.js +1 -1
- package/v3/@claude-flow/cli/dist/src/mcp-tools/task-tools.js +4 -2
- package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.d.ts +2 -0
- package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +7 -3
- package/v3/@claude-flow/cli/dist/src/ruvector/centroid-router.d.ts +87 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/centroid-router.js +154 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/router-embedder.d.ts +2 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/router-embedder.js +7 -0
- package/v3/@claude-flow/cli/dist/src/services/distill-oracle.d.ts +1 -1
- package/v3/@claude-flow/cli/dist/src/services/distill-oracle.js +2 -2
- package/v3/@claude-flow/cli/package.json +9 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319
|
|
@@ -528,7 +528,7 @@ async function doImport() {
|
|
|
528
528
|
const { pkg: memPkg, searched } = await resolveMemoryPackage({ record: true });
|
|
529
529
|
if (!memPkg) {
|
|
530
530
|
warnMemoryUnavailable(searched);
|
|
531
|
-
return;
|
|
531
|
+
return 1; // #4963: nothing was imported/synced, so this is a failure, not a success
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
const config = readConfig();
|
|
@@ -614,7 +614,7 @@ async function doSync() {
|
|
|
614
614
|
const { pkg: memPkg, searched } = await resolveMemoryPackage({ record: true });
|
|
615
615
|
if (!memPkg) {
|
|
616
616
|
warnMemoryUnavailable(searched);
|
|
617
|
-
return;
|
|
617
|
+
return 1; // #4963: nothing was imported/synced, so this is a failure, not a success
|
|
618
618
|
}
|
|
619
619
|
|
|
620
620
|
const config = readConfig();
|
|
@@ -870,8 +870,8 @@ process.on('unhandledRejection', (reason) => {
|
|
|
870
870
|
let exitCode = 0;
|
|
871
871
|
try {
|
|
872
872
|
switch (command) {
|
|
873
|
-
case 'import': await doImport(); break;
|
|
874
|
-
case 'sync': await doSync(); break;
|
|
873
|
+
case 'import': exitCode = (await doImport()) || 0; break;
|
|
874
|
+
case 'sync': exitCode = (await doSync()) || 0; break;
|
|
875
875
|
case 'status': await doStatus(); break;
|
|
876
876
|
case 'read': exitCode = await doRead(commandArgs); break;
|
|
877
877
|
case 'read-id': exitCode = await doReadId(commandArgs); break;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"adoptedAt": 1794515699232,
|
|
3
|
+
"championId": "sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319",
|
|
4
|
+
"manifest": {
|
|
5
|
+
"schema": "ruflo.proven-config/v1",
|
|
6
|
+
"policy": {
|
|
7
|
+
"ref": "sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319",
|
|
8
|
+
"value": {
|
|
9
|
+
"alpha": 0.3,
|
|
10
|
+
"subjectWeight": 1,
|
|
11
|
+
"mmrLambda": 0.5,
|
|
12
|
+
"bodyWeight": 1.5,
|
|
13
|
+
"typePenaltyFactor": 0.5
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"layer": "framework/node-cli",
|
|
17
|
+
"compatibility": {
|
|
18
|
+
"ruflo": ">=3.24.0"
|
|
19
|
+
},
|
|
20
|
+
"benchmark": {
|
|
21
|
+
"corpus": "ADR-081-labelled-v1",
|
|
22
|
+
"corpusHash": "sha256:2f700b5c363e20a3bd88ce2bc9b87bbbbaa61732c6177894c6ec37890f888982"
|
|
23
|
+
},
|
|
24
|
+
"receipt": {
|
|
25
|
+
"heldOutDelta": 0.07381404928570845,
|
|
26
|
+
"redblue": "PASS",
|
|
27
|
+
"drift": 0,
|
|
28
|
+
"canary": {
|
|
29
|
+
"rollbackRate": 0,
|
|
30
|
+
"latencyP95": 244.612458000076,
|
|
31
|
+
"costPerTask": 0
|
|
32
|
+
},
|
|
33
|
+
"receiptCoverage": 1
|
|
34
|
+
},
|
|
35
|
+
"platform": [
|
|
36
|
+
"linux",
|
|
37
|
+
"macOS",
|
|
38
|
+
"windows"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"previous": ""
|
|
42
|
+
}
|
|
@@ -243,10 +243,10 @@ export declare const TaskInputSchema: z.ZodObject<{
|
|
|
243
243
|
"project-coordinator": "project-coordinator";
|
|
244
244
|
}>;
|
|
245
245
|
priority: z.ZodOptional<z.ZodEnum<{
|
|
246
|
-
low: "low";
|
|
247
|
-
medium: "medium";
|
|
248
|
-
high: "high";
|
|
249
246
|
critical: "critical";
|
|
247
|
+
high: "high";
|
|
248
|
+
medium: "medium";
|
|
249
|
+
low: "low";
|
|
250
250
|
}>>;
|
|
251
251
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
252
252
|
}, z.core.$strip>;
|
package/package.json
CHANGED
|
@@ -1,101 +1,22 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**An agent meta-harness for Claude Code and Codex.**
|
|
3
|
+
[](https://cognitum.one/agentic-engineering)
|
|
6
4
|
|
|
7
5
|
<!-- Try Ruflo — the 3 badges first-time visitors actually act on -->
|
|
8
6
|
[](https://www.npmjs.com/package/ruflo)
|
|
9
7
|
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://x.com/rUv)
|
|
12
|
-
|
|
13
|
-
<p align="center">
|
|
14
|
-
<a href="docs/harness-origins.md"><img src="https://raw.githubusercontent.com/ruvnet/ruflo/e69e4b95aa08d65ea0f7715489bbf8e62a83a0d2/docs/assets/readme/badges/first-commit.svg" width="300" height="76" alt="Claude Flow lineage: first commit June 2, 2025 by rUv; inspect the evidence"></a>
|
|
15
|
-
<a href="data/npm-downloads.latest.json"><img src="https://raw.githubusercontent.com/ruvnet/ruflo/275aff65a198af758923669acff36f03d1f41623/docs/assets/readme/badges/downloads.svg" width="300" height="76" alt="Illustrative download counter starts at 98,000,000 and adds varied amounts each second in a 30 second loop. Verified dataset: 97,022,120 download events."></a>
|
|
16
|
-
<br>
|
|
17
|
-
<a href="https://github.com/ruvnet/claude-flow"><img src="https://raw.githubusercontent.com/ruvnet/ruflo/d1e80400bdefe01d3b13e70395f88fffab76bb18/docs/assets/readme/badges/claude.svg" width="300" height="76" alt="Claude Code plugin"></a>
|
|
18
|
-
<a href="https://www.npmjs.com/package/@claude-flow/codex"><img src="https://raw.githubusercontent.com/ruvnet/ruflo/d1e80400bdefe01d3b13e70395f88fffab76bb18/docs/assets/readme/badges/codex.svg" width="300" height="76" alt="Codex plugin"></a>
|
|
19
|
-
<a href="https://chatgpt.com/plugins/plugin_asdk_app_6ab674ff53c48191bb37040c343e31f3"><img src="docs/assets/readme/badges/chatgpt.svg" width="300" height="76" alt="ChatGPT plugin: RuFlo Federation"></a>
|
|
20
|
-
</p>
|
|
21
|
-
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
<a id="start-here"></a>
|
|
25
|
-
|
|
26
|
-
## <img src="docs/assets/readme/icons/terminal.svg" width="32" height="32" alt=""> Get started in one command
|
|
27
|
-
|
|
28
|
-
Run this in your project folder:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npx ruflo@latest init
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Then open Claude Code in the same folder and give it a real task, for example:
|
|
35
|
-
|
|
36
|
-
```text
|
|
37
|
-
Use a ruflo swarm to review this repo: find the riskiest module, write tests for it, and summarise what you changed.
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
`init` adds ruflo's agents, hooks, memory and MCP server to the project, and Claude Code picks them up on its next start. Codex and other MCP clients work too: point them at `npx -y ruflo@latest mcp start`.
|
|
41
|
-
|
|
42
|
-
<p align="center"><img src="docs/assets/ruflo-console-tour.gif" width="720" alt="Looping recording of the ruflo console: overview, swarm view and missions in a sample project"></p>
|
|
43
|
-
|
|
44
|
-
[First useful task, step by step](docs/ruflo-explained.md) · [User guide](docs/USERGUIDE.md) · [Compare install paths](#quick-start)
|
|
45
|
-
|
|
46
|
-
<details>
|
|
47
|
-
<summary><b>Other ways to install</b> (Claude Code plugins only, MCP-only clients, terminal UI)</summary>
|
|
48
|
-
|
|
49
|
-
**Claude Code plugins only.** This route installs core tools, the visual console and runtime mods, with no files added to your project. It needs Claude Code **2.1.287 or later**. Run inside Claude Code:
|
|
50
|
-
|
|
51
|
-
```text
|
|
52
|
-
/plugin marketplace add ruvnet/ruflo
|
|
53
|
-
/plugin install ruflo-core@ruflo
|
|
54
|
-
/plugin install ruflo-console@ruflo
|
|
55
|
-
/plugin install ruflo-mods@ruflo
|
|
56
|
-
/reload-plugins
|
|
57
|
-
/ruflo
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
From a terminal, on Claude Code 2.1.292 or later: `claude plugin install ruflo-core@ruflo --marketplace ruvnet/ruflo`. Mods run with your account's permissions, so review their code before installing.
|
|
61
|
-
|
|
62
|
-
**Codex or another MCP client, without project setup.** Configure the **command** `npx` with the **arguments** `["-y", "ruflo@latest", "mcp", "start"]`. To set up a project interactively, run `npx ruflo@latest init wizard`.
|
|
63
|
-
|
|
64
|
-
**Plain terminal.** The console also runs on its own, without Claude Code: `npx ruflo tui`. Add `--plain` to print one frame for scripts. See the [terminal UI guide](docs/USERGUIDE.md#terminal-ui-optional).
|
|
65
|
-
|
|
66
|
-
<p align="center"><img src="docs/assets/ruflo-tui-compact.svg" width="640" alt="Looping recording of the optional ruflo terminal UI with its pictures: Overview in the Classic BBS look, the Orbital look with its moving globe, and the Swarm graph, in a sample project"></p>
|
|
67
|
-
|
|
68
|
-
</details>
|
|
69
|
-
|
|
70
|
-
<div align="center">
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
### Optional: ruOS Desktop
|
|
74
|
-
|
|
75
|
-
<a href="https://ruos.cognitum.one"><img src="ruflo/assets/ruos-animated.svg" alt="ruOS — A desktop that runs itself" width="100%"></a>
|
|
76
|
-
|
|
77
|
-
**Connect ruOS to ChatGPT or Claude via MCP:**
|
|
78
|
-
|
|
79
|
-
```text
|
|
80
|
-
https://ruos.cognitum.one/mcp
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<!-- RuVector promo -->
|
|
86
|
-
<a href="https://github.com/ruvnet/ruvector"><img src="docs/assets/readme/ruvector-promo-depth.svg" width="100%" alt="RuVector: Give your agents memory. Local vector search, persistent context, graph relationships and feedback learning. Explore RuVector."></a>
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
npx ruvector
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
|
|
8
|
+
[](https://github.com/ruvnet/claude-flow)
|
|
93
9
|
|
|
10
|
+
<!-- Ecosystem strip (collapsed visually with flat-square) -->
|
|
11
|
+
[](https://github.com/ruvnet/ruvector)
|
|
12
|
+
[](https://github.com/ruvnet/ruflo/blob/main/data/clone-data.proof.json)
|
|
13
|
+
[](https://github.com/ruvnet/ruflo/blob/main/data/clone-data.ledger.json)
|
|
14
|
+
[](https://github.com/ruvnet/claude-flow)
|
|
15
|
+
[](https://www.npmjs.com/package/@claude-flow/codex)
|
|
94
16
|
|
|
95
17
|
# Ruflo
|
|
96
18
|
|
|
97
|
-
|
|
98
|
-
|
|
19
|
+
**An agent meta-harness for Claude Code and Codex.**
|
|
99
20
|
|
|
100
21
|
[](docs/ruflo-explained.md)
|
|
101
22
|
|
|
@@ -108,29 +29,16 @@ A 14-chapter guide: from the basic idea to a first useful task, then memory, age
|
|
|
108
29
|
|
|
109
30
|
One `npx ruflo init` gives Claude Code a nervous system: agents self-organize into swarms, learn from every task, remember across sessions, and — with federation — securely talk to agents on other machines without leaking data. You keep writing code. Ruflo handles the coordination.
|
|
110
31
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<sub>Conceptual learning loop. Local vector retrieval and contrastive updates can run without an LLM; embeddings and configured learning modules are still required. See the <a href="v3/@claude-flow/cli/src/services/ruvector-training.ts">RuVector training integration</a> and <a href="v3/@claude-flow/neural/src/modes/balanced.ts">trajectory contrastive learning</a>.</sub>
|
|
114
|
-
|
|
115
|
-
<details>
|
|
116
|
-
<summary>Architecture in text</summary>
|
|
117
|
-
|
|
118
|
-
User → Ruflo (CLI/MCP) → Router → Swarm → Agents → Memory → LLM providers. Memory feeds useful experience back into routing. This is a conceptual flow, not a live execution trace.
|
|
32
|
+
```
|
|
33
|
+
Self-Learning / Self-Optimizing Agent Architecture
|
|
119
34
|
|
|
120
|
-
|
|
35
|
+
User --> Ruflo (CLI/MCP) --> Router --> Swarm --> Agents --> Memory --> LLM Providers
|
|
36
|
+
^ |
|
|
37
|
+
+---- Learning Loop <-------+
|
|
38
|
+
```
|
|
121
39
|
|
|
122
40
|
> **New to Ruflo?** You don't need to learn 406 MCP tools or 61 CLI commands. After `init`, just use Claude Code normally — the hooks system automatically routes tasks, learns from successful patterns, and coordinates agents in the background.
|
|
123
41
|
|
|
124
|
-
### An origin you can inspect
|
|
125
|
-
|
|
126
|
-
[](docs/harness-origins.md)
|
|
127
|
-
|
|
128
|
-
**Built by [Reuven Cohen (rUv)](https://github.com/ruvnet), originally as Claude Flow.** The [first commit, June 2, 2025](https://github.com/ruvnet/ruflo/commit/7c1f9402d70e7af56c01a879073cbac92564dc4e), describes a code orchestration layer for recursive agent cycles: Claude writes, edits, tests and improves. The [June 10 source snapshot](https://github.com/ruvnet/ruflo/tree/dba545f012ea92a2375a26332bbf3797495e93c9) adds orchestration, task scheduling, memory and terminal modules.
|
|
129
|
-
|
|
130
|
-
A harness is the workbench around the model: it organizes tasks, carries context between steps and helps check results. **This establishes Ruflo's lineage, not a universal first across every Claude Code tool.** [See the illustrated explainer, exact commits and earlier ecosystem context](docs/harness-origins.md).
|
|
131
|
-
|
|
132
|
-
**Grok Build:** `npx ruflo init --grok` writes the project host surface (`.grok/`, the team bus, and the operator guide) and nothing outside the project; add `--dry-run` to preview. Setup, the `spawn_subagent` contract, the optional status row, and what to re-check when Grok updates: [the Grok operator guide](v3/@claude-flow/cli/templates/grok/docs/README.md).
|
|
133
|
-
|
|
134
42
|
<details>
|
|
135
43
|
<summary><strong>📖 Background — where the name comes from</strong></summary>
|
|
136
44
|
|
|
@@ -140,52 +48,10 @@ A harness is the workbench around the model: it organizes tasks, carries context
|
|
|
140
48
|
|
|
141
49
|
---
|
|
142
50
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<p align="center"><a href="https://raw.githubusercontent.com/ruvnet/ruflo/main/docs/assets/ruflo-console-theme-compact.svg"><img src="docs/assets/ruflo-console-theme-compact.svg" width="100%" alt="Ruflo Orbital theme: animated boot checks, block logo, menu icons, rotating globe, swarm routing, six color palettes and responsive Theme Studio"></a></p>
|
|
146
|
-
|
|
147
|
-
[Open animated demo](https://raw.githubusercontent.com/ruvnet/ruflo/main/docs/assets/ruflo-console-theme-compact.svg) · [Theme Studio guide](plugins/ruflo-console/README.md) · [Workflow demo](docs/assets/ruflo-console-workflows.svg)
|
|
148
|
-
|
|
149
|
-
<img src="docs/assets/readme/console-icon-workflows.svg" width="28" height="28" alt=""> **Your agent cockpit.** Track workflows, agents, models, tokens and cost beside Claude Code. The 38 second animation shows **Orbital and Theme Studio** through actual renderer frames, including boot checks, six palettes, customization, saved themes, JSON import and resizing. This compact 3.84 MB SVG retains all 456 frames. Native host and AI provider execution are not demonstrated.
|
|
150
|
-
|
|
151
|
-
<img src="docs/assets/readme/console-icon-inspect.svg" width="28" height="28" alt=""> **Inspect any run.** Open agent logs and results, search, triage failures, replay and compare. Start with `npx ruflo init`, restart Claude Code, then `/ruflo`. [Full console tour](docs/assets/ruflo-console-walkthrough-wide.gif).
|
|
152
|
-
|
|
153
|
-
<img src="docs/assets/readme/console-icon-control.svg" width="28" height="28" alt=""> **Let Claude drive. You set the limits.** Enable **Settings → Claude control** to navigate and run console actions. Choose `read`, `write`, `manage` or `full`, with `ask` or `auto` approval. The current default is **read + ask**; raising the level is your choice. Actions above your permission level are refused, and network, spending and destructive actions require confirmation even in `auto`. Review the live action log or press **Take back control** to stop Claude control. [Details](v3/docs/adr/ADR-444-claude-controls-the-console.md).
|
|
154
|
-
|
|
155
|
-
<a id="console-walkthrough"></a>
|
|
156
|
-
|
|
157
|
-
### One task: create a mission with Claude
|
|
158
|
-
|
|
159
|
-
<img src="docs/assets/readme/console-icon-workflows.svg" width="28" height="28" alt=""> **Watch the recorded console session below.** Claude creates a mission, opens the Learning and Security pages, and reports its actions in Overview.
|
|
160
|
-
|
|
161
|
-
1. **Set the boundary.** Install the console using the commands below, open `/ruflo`, then choose **Settings → Claude control → write + ask**.
|
|
162
|
-
2. **Give a concrete request.** Try: “Create a mission to add a dark mode toggle. Show me the mission and its status.”
|
|
163
|
-
3. **Approve creation.** Claude opens Missions and sets the goal. Confirm the pending create action in the console.
|
|
164
|
-
4. **Verify the result.** Check that Missions contains the goal and Overview records the action. Creating a mission does not mean the feature has been implemented.
|
|
165
|
-
5. **Keep control.** **Take back control** pauses Claude's console tools. A later call should be refused until you restore control.
|
|
166
|
-
|
|
167
|
-
**What the recording demonstrates:** a real Claude Haiku session with `write + auto`, mission creation, page navigation, a refused swarm stop, and control being taken back. The steps above use `ask` so you approve creation yourself. The linked workflow animation uses sample data, while the theme demo replays renderer frames. Neither is evidence of completed swarm work or memory recall.
|
|
168
|
-
|
|
169
|
-
[Implementation and recorded test findings](v3/docs/adr/ADR-444-claude-controls-the-console.md) · [Reproduction script](plugins/ruflo-console/scripts/e2e-control.sh)
|
|
170
|
-
|
|
171
|
-
<p align="center"><img src="docs/assets/ruflo-console-claude-control.gif" alt="Claude Code with the ruflo console beside it: Claude sets a mission goal, creates the mission and opens the Learning, Security and Overview pages through the console tools; the Claude control dashboard logs each action; swarm-stop is refused because it needs the full level; the person clicks Take back control and the next request is refused"></p>
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
**Install the mods from the ruflo marketplace** (Claude Code 2.1.287 or later; mods run with your account's permissions and are not sandboxed, so read the code first):
|
|
175
|
-
|
|
176
|
-
```text
|
|
177
|
-
/plugin marketplace add ruvnet/ruflo
|
|
178
|
-
/plugin install ruflo-console@ruflo
|
|
179
|
-
/plugin install ruflo-mods@ruflo
|
|
180
|
-
/reload-plugins
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
`ruflo-console` is the cockpit above, `ruflo-mods` routes prompts and enforces policy in-process, `ruflo-swarm` shows the swarm in a pane, and `ruflo-ruos` adds the ruOS status segment. Open `/plugin` to confirm they appear in the active mods line. Inside the console, `/ruflo market` is the Plugin Catalog: every ruflo plugin, mod and skill with what it ships, and buttons to install, enable, disable and update (each asks first).
|
|
51
|
+

|
|
184
52
|
|
|
185
53
|
## Quick Start
|
|
186
54
|
|
|
187
|
-
<p align="center"><img src="docs/assets/readme/quick-start.svg" alt="Start building with Ruflo" width="100%"></p>
|
|
188
|
-
|
|
189
55
|
There are **two different install paths** with very different surface areas. Pick based on what you need (#1744):
|
|
190
56
|
|
|
191
57
|
| | **Claude Code Plugin** | **CLI install (`npx ruflo init`)** |
|
|
@@ -212,7 +78,7 @@ There are **two different install paths** with very different surface areas. Pic
|
|
|
212
78
|
This adds slash commands and agent definitions. `ruflo-core` (installed above) does register its own MCP server on install — its tools are callable as `mcp__plugin_ruflo-core_ruflo__*` (e.g. `mcp__plugin_ruflo-core_ruflo__memory_store`), not the bare `memory_store`/`swarm_init`/`agent_spawn` names the CLI-track scaffold uses. Other plugins generally don't ship their own MCP server. For the full loop with the CLI-track tool names, use Path B below.
|
|
213
79
|
|
|
214
80
|
<details>
|
|
215
|
-
<summary><strong>🔌 All 48 plugins</strong
|
|
81
|
+
<summary><strong>🔌 All 48 plugins</strong></summary>
|
|
216
82
|
|
|
217
83
|
#### Core & Orchestration
|
|
218
84
|
|
|
@@ -263,9 +129,6 @@ This adds slash commands and agent definitions. `ruflo-core` (installed above) d
|
|
|
263
129
|
| [**ruflo-jujutsu**](plugins/ruflo-jujutsu/README.md) | Analyze git diffs, score risk, suggest reviewers |
|
|
264
130
|
| [**ruflo-rure**](plugins/ruflo-rure/) | Static analysis of a local JS/Electron app you are authorized to study, with file and line evidence |
|
|
265
131
|
| [**ruflo-docs**](plugins/ruflo-docs/README.md) | Generate and maintain documentation automatically |
|
|
266
|
-
| [**agentic-qe-fleet**](https://github.com/proffesor-for-testing/agentic-qe/tree/v3.15.17/plugins/agentic-qe-fleet) | External, maintained by [Agentic QE](https://github.com/proffesor-for-testing/agentic-qe): 11 QE agents, test generation, coverage, chaos and TDD skills, the `agentic-qe` MCP server, and a guard for AQE learning data (`/plugin install agentic-qe-fleet@ruflo`). Install it from one marketplace only, `agentic-qe` or `ruflo`: enabled from both, its mod and commands load twice |
|
|
267
|
-
| [**agentdb**](https://github.com/ruvnet/agentdb/tree/plugin-v3.2.0/plugins/agentdb) | External, maintained in [ruvnet/agentdb](https://github.com/ruvnet/agentdb): agentdb's own MCP server (pinned `agentdb@3.2.0`: hybrid keyword + vector search, opt-in cross-encoder rerank), a memory-specialist agent, vector-memory / learning / diagnostics skills, `/agentdb-status`, and a guard that keeps secrets out of memory and refuses delete/reset unless allowed (`/plugin install agentdb@ruflo`). Use `ruflo-agentdb` instead if you want AgentDB through ruflo's server; the two can coexist. Install it from one marketplace only, `agentdb` or `ruflo` |
|
|
268
|
-
| [**agentic-flow**](https://github.com/ruvnet/agentic-flow/tree/plugin-v3.1.0/plugins/agentic-flow) | External, maintained in [ruvnet/agentic-flow](https://github.com/ruvnet/agentic-flow): the agentic-flow MCP server (pinned `agentic-flow@3.1.0`, `readonly` profile by default, nothing pre-approved), ReasoningBank and model-router agents, routing / learning / autopilot skills, `/agentic-flow-status`, and a guard on `agentic_flow_agent` (`/plugin install agentic-flow@ruflo`). Install it from one marketplace only, `agentic-flow` or `ruflo` |
|
|
269
132
|
|
|
270
133
|
#### Security & Compliance
|
|
271
134
|
|
|
@@ -298,7 +161,7 @@ This adds slash commands and agent definitions. `ruflo-core` (installed above) d
|
|
|
298
161
|
|
|
299
162
|
| Plugin | What it does |
|
|
300
163
|
|--------|-------------|
|
|
301
|
-
| [**ruflo-agent**](plugins/ruflo-agent/README.md) | Run agents — local WASM sandbox (rvagent) + Anthropic Claude Managed Agents (cloud)
|
|
164
|
+
| [**ruflo-agent**](plugins/ruflo-agent/README.md) | Run agents — local WASM sandbox (rvagent) + Anthropic Claude Managed Agents (cloud) |
|
|
302
165
|
| [**ruflo-plugin-creator**](plugins/ruflo-plugin-creator/README.md) | Scaffold, validate, and publish your own plugins |
|
|
303
166
|
|
|
304
167
|
#### Domain-Specific
|
|
@@ -312,7 +175,7 @@ This adds slash commands and agent definitions. `ruflo-core` (installed above) d
|
|
|
312
175
|
|
|
313
176
|
</details>
|
|
314
177
|
|
|
315
|
-
###
|
|
178
|
+
### CLI Install
|
|
316
179
|
|
|
317
180
|
**macOS / Linux / WSL / Git-Bash:**
|
|
318
181
|
|
|
@@ -336,52 +199,82 @@ npm install -g ruflo@latest
|
|
|
336
199
|
|
|
337
200
|
> 💡 **Windows users:** the `curl ... | bash` form needs a POSIX shell (Git-Bash, WSL, MSYS). The `npx ruflo@latest init wizard` line works natively in PowerShell and cmd. If you hit an `'bash' is not recognized` error, use the `npx` line instead — both end up running the same init flow.
|
|
338
201
|
|
|
339
|
-
###
|
|
202
|
+
### MCP Server
|
|
340
203
|
|
|
341
204
|
```bash
|
|
342
205
|
# Add Ruflo as an MCP server in Claude Code
|
|
343
206
|
claude mcp add claude-flow -- npx ruflo@latest mcp start
|
|
344
207
|
```
|
|
345
208
|
|
|
346
|
-
|
|
209
|
+
#### HTTP transport security
|
|
347
210
|
|
|
348
|
-
|
|
211
|
+
`ruflo mcp start -t http` exposes every registered tool over HTTP (`/rpc`, `/mcp`, `/ws`). The default `stdio` transport is not affected.
|
|
349
212
|
|
|
350
|
-
|
|
213
|
+
| Setting | Effect |
|
|
214
|
+
|---|---|
|
|
215
|
+
| `RUFLO_MCP_HTTP_TOKEN=<token>` | Require `Authorization: Bearer <token>` on every request. Failure is a bare `401`. The token is compared in constant time and is never logged. Prefer this over `--auth-token`, which is visible in `ps`. |
|
|
216
|
+
| `--auth-token-file <path>` | Read the token from a file (one line). Takes precedence over the env var. |
|
|
217
|
+
| `--auth-token <token>` | Same, on the command line (visible in argv; highest precedence). |
|
|
218
|
+
| `RUFLO_MCP_ALLOW_UNAUTHENTICATED_HTTP=1` | Allow an unauthenticated bind to a non-loopback `--host`. Only for a trusted network boundary or an authenticating reverse proxy. |
|
|
351
219
|
|
|
352
|
-
|
|
220
|
+
A token must be 16-512 printable ASCII characters (no spaces). `GET /health` stays public and returns only `{"status":"ok"}` when a token is set. Tokens are supported for `-t http` only; `-t websocket` rejects one.
|
|
353
221
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
</table>
|
|
222
|
+
| `--host` | no token | token set |
|
|
223
|
+
|---|---|---|
|
|
224
|
+
| `localhost`, `127.0.0.1`, `::1` | starts, **unauthenticated** | starts, token required |
|
|
225
|
+
| anything else (`0.0.0.0`, `::`, a LAN IP, `127.0.0.2`, `[::1]`, `LOCALHOST`) | **refuses to start** unless `RUFLO_MCP_ALLOW_UNAUTHENTICATED_HTTP=1` | starts, token required |
|
|
359
226
|
|
|
360
|
-
|
|
361
|
-
|------------|-------------|
|
|
362
|
-
| <img src="docs/assets/readme/icons/agents.svg" width="28" height="28" alt=""> **100+ Agents** | Specialized agents for coding, testing, security, docs, architecture |
|
|
363
|
-
| <img src="docs/assets/readme/icons/network.svg" width="28" height="28" alt=""> **Comms Layer** | Zero-trust federation — agents across machines/orgs discover, authenticate, and exchange work securely |
|
|
364
|
-
| <img src="docs/assets/readme/icons/swarm.svg" width="28" height="28" alt=""> **Swarm Coordination** | Hierarchical, mesh, and adaptive topologies with consensus |
|
|
365
|
-
| <img src="docs/assets/readme/icons/learning.svg" width="28" height="28" alt=""> **Self-Learning** | SONA neural patterns, ReasoningBank, trajectory learning |
|
|
366
|
-
| <img src="docs/assets/readme/icons/memory.svg" width="28" height="28" alt=""> **Vector Memory** | HNSW-indexed AgentDB — measured ~1.9x faster at N=20k, ~3.2x–4.7x at N=5k vs brute force (recall@10 ~0.99); ANN wins above the crossover, ties/loses at small N. See [audit](docs/reviews/intelligence-system-audit-2026-05-29.md) + [`scripts/benchmark-intelligence.mjs`](scripts/benchmark-intelligence.mjs) |
|
|
367
|
-
| <img src="docs/assets/readme/icons/workers.svg" width="28" height="28" alt=""> **Background Workers** | 12 auto-triggered workers (audit, optimize, testgaps, etc.) |
|
|
368
|
-
| <img src="docs/assets/readme/icons/plugins.svg" width="28" height="28" alt=""> **Plugin Marketplace** | 48 native Claude Code plugins + 14 in-tree npm plugins |
|
|
369
|
-
| <img src="docs/assets/readme/icons/routing.svg" width="28" height="28" alt=""> **Multi-Provider** | Claude, GPT, Gemini, Cohere, Ollama with smart routing |
|
|
370
|
-
| <img src="docs/assets/readme/icons/security.svg" width="28" height="28" alt=""> **Security** | AIDefence, input validation, CVE remediation, path traversal prevention |
|
|
371
|
-
| <img src="docs/assets/readme/icons/federation.svg" width="28" height="28" alt=""> **Agent Federation** | Cross-installation agent collaboration with zero-trust security |
|
|
372
|
-
| <img src="docs/assets/readme/icons/audit.svg" width="28" height="28" alt=""> **[MetaHarness](docs/metaharness-user-guide.md)** | Audit your AI agent setup before you ship. Grade readiness (1-100), scan tool configs for security issues, snapshot the whole project to catch regressions over time, and find templates that match your repo. `ruflo eject` turns a ruflo project into a standalone agent toolkit with its own name. [Full guide](docs/metaharness-user-guide.md). |
|
|
227
|
+
Without a token, a loopback server is still unauthenticated: any process on the machine, and any web page that can reach it via DNS rebinding, can call tools. Set `RUFLO_MCP_HTTP_TOKEN` whenever the HTTP transport is used.
|
|
373
228
|
|
|
374
|
-
|
|
229
|
+
**Upgrading:** binding off loopback (for example `--host 0.0.0.0` in Docker) now needs a token or the opt-out above; otherwise the server exits with an error.
|
|
375
230
|
|
|
376
|
-
|
|
231
|
+
---
|
|
377
232
|
|
|
378
|
-
|
|
233
|
+
Startup checks report available updates without installing them. To opt in to
|
|
234
|
+
automatic patch installation, set `RUFLO_AUTO_UPDATE=true` (`1`, `yes` and `on`
|
|
235
|
+
also work). Minor and major updates remain manual; critical package priority
|
|
236
|
+
does not bypass an opt-out. CI detection and `CLAUDE_FLOW_AUTO_UPDATE=false`
|
|
237
|
+
still disable the update check.
|
|
379
238
|
|
|
380
|
-
|
|
239
|
+
## What You Get
|
|
240
|
+
|
|
241
|
+
Companion helper refresh (`session.cjs` / `memory.cjs`) skips symlinked helper
|
|
242
|
+
directories and symlinked/non-file targets. Regular files are preserved on
|
|
243
|
+
startup and replaced on an explicit upgrade through an exclusive temporary
|
|
244
|
+
file and rename. A skipped companion is left in place; remove or repair the
|
|
245
|
+
unsafe path before retrying. These pathname checks do not protect against an
|
|
246
|
+
attacker concurrently replacing ancestor directories, and do not extend the
|
|
247
|
+
signed helper set or protect other state writers.
|
|
248
|
+
|
|
249
|
+
| Capability | Description |
|
|
250
|
+
|------------|-------------|
|
|
251
|
+
| 🤖 **100+ Agents** | Specialized agents for coding, testing, security, docs, architecture |
|
|
252
|
+
| 📡 **Comms Layer** | Zero-trust federation — agents across machines/orgs discover, authenticate, and exchange work securely |
|
|
253
|
+
| 🐝 **Swarm Coordination** | Hierarchical, mesh, and adaptive topologies with consensus |
|
|
254
|
+
| 🧠 **Self-Learning** | SONA neural patterns, ReasoningBank, trajectory learning |
|
|
255
|
+
| 💾 **Vector Memory** | HNSW-indexed AgentDB — measured ~1.9x faster at N=20k, ~3.2x–4.7x at N=5k vs brute force (recall@10 ~0.99); ANN wins above the crossover, ties/loses at small N. See [audit](docs/reviews/intelligence-system-audit-2026-05-29.md) + [`scripts/benchmark-intelligence.mjs`](scripts/benchmark-intelligence.mjs) |
|
|
256
|
+
| ⚡ **Background Workers** | 12 auto-triggered workers (audit, optimize, testgaps, etc.) |
|
|
257
|
+
| 🧩 **Plugin Marketplace** | 48 native Claude Code plugins + 14 in-tree npm plugins |
|
|
258
|
+
| 🔌 **Multi-Provider** | Claude, GPT, Gemini, Cohere, Ollama with smart routing |
|
|
259
|
+
| 🛡️ **Security** | AIDefence, input validation, CVE remediation, path traversal prevention |
|
|
260
|
+
| 🌐 **Agent Federation** | Cross-installation agent collaboration with zero-trust security |
|
|
261
|
+
| 🔬 **[MetaHarness](docs/metaharness-user-guide.md)** | Audit your AI agent setup before you ship. Grade readiness (1-100), scan tool configs for security issues, snapshot the whole project to catch regressions over time, and find templates that match your repo. `ruflo eject` turns a ruflo project into a standalone agent toolkit with its own name. [Full guide](docs/metaharness-user-guide.md). |
|
|
381
262
|
|
|
382
|
-
|
|
263
|
+
### Agent Federation — Slack for Agents
|
|
383
264
|
|
|
384
|
-
|
|
265
|
+
```
|
|
266
|
+
Your Agent --> [ Remove secrets ] --> [ Sign message ] --> [ Encrypted channel ]
|
|
267
|
+
Emails, SSNs, Proves it came No one reads it
|
|
268
|
+
keys stripped from you in transit
|
|
269
|
+
|
|
|
270
|
+
v
|
|
271
|
+
Their Agent <-- [ Block attacks ] <-- [ Check identity ] <------+
|
|
272
|
+
Stops prompt Rejects forgeries
|
|
273
|
+
injection
|
|
274
|
+
|
|
275
|
+
Audit trail on both sides.
|
|
276
|
+
Trust builds over time. Bad behavior = instant downgrade.
|
|
277
|
+
```
|
|
385
278
|
|
|
386
279
|
Slack gave teams channels. Federation gives agents the same thing — **shared workspaces across trust boundaries**, where agents on different machines, orgs, or cloud regions can discover each other, prove who they are, and collaborate on tasks.
|
|
387
280
|
|
|
@@ -483,15 +376,12 @@ User --> Claude Code / CLI
|
|
|
483
376
|
|
|
484
377
|
## Documentation
|
|
485
378
|
|
|
486
|
-
<p align="center"><img src="docs/assets/readme/documentation.svg" alt="Guides, architecture and verification" width="100%"></p>
|
|
487
|
-
|
|
488
379
|
Four docs for four audiences:
|
|
489
380
|
|
|
490
381
|
| Doc | When to read it |
|
|
491
382
|
|-----|-----------------|
|
|
492
383
|
| **[Status](docs/STATUS.md)** | See what currently works — capability counts, test baselines, recent fixes, what's next. The *is-it-ready* doc. |
|
|
493
384
|
| **[User Guide](docs/USERGUIDE.md)** | Daily reference — every command, every config flag, every plugin. The *how-do-I* doc. |
|
|
494
|
-
| **[Compare frameworks](docs/compare.md)** | Deciding between Ruflo, Claude Code built-in agents, CrewAI, LangGraph, or AutoGen. The *which-one-for-me* doc. |
|
|
495
385
|
| **[MetaHarness Guide](docs/metaharness-user-guide.md)** | How to grade your agent setup, scan tool configs for security, detect changes between runs, and eject a project into a standalone agent toolkit. The *audit-my-setup* doc. |
|
|
496
386
|
| **[Benchmarks](https://gist.github.com/ruvnet/298f8c668c8859b369f91734a0e9cbbe)** | v3.8.0 SOTA matrix vs LangGraph / AutoGen / CrewAI on darwin-arm64 + linux-x64. ruflo wins cold start, single turn, RSS by 1.3×–1953×. The *is-it-fast* doc. |
|
|
497
387
|
| **[Verification](verification.md)** | Cryptographically prove your installed bytes match the signed witness — `ruflo verify`. The *trust-but-verify* doc. |
|
|
@@ -516,8 +406,6 @@ User Guide section index:
|
|
|
516
406
|
|
|
517
407
|
## Support
|
|
518
408
|
|
|
519
|
-
<p align="center"><img src="docs/assets/readme/support.svg" alt="Build with the Ruflo community" width="100%"></p>
|
|
520
|
-
|
|
521
409
|
| Resource | Link |
|
|
522
410
|
|----------|------|
|
|
523
411
|
| Documentation | [User Guide](docs/USERGUIDE.md) |
|
|
@@ -526,10 +414,6 @@ User Guide section index:
|
|
|
526
414
|
| Community | [Agentics Foundation Discord](https://discord.com/invite/dfxmpwkG2D) |
|
|
527
415
|
| Powered by | [Cognitum.one](https://cognitum.one) |
|
|
528
416
|
|
|
529
|
-
<p align="center"><img src="docs/assets/readme/signal-divider.svg" alt="Ruflo" width="100%"></p>
|
|
530
|
-
|
|
531
417
|
## License
|
|
532
418
|
|
|
533
419
|
MIT - [RuvNet](https://github.com/ruvnet)
|
|
534
|
-
|
|
535
|
-
<a href="https://cognitum.one"><img src="docs/assets/readme/cognitum-banner-v2.svg" width="100%" alt="Cognitum One: Ambient Intelligence at the edge of the Physical World. Explore cognitum.one."></a>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generation":
|
|
4
|
-
"generatedAt": "2026-
|
|
5
|
-
"gitSha": "
|
|
3
|
+
"generation": 6,
|
|
4
|
+
"generatedAt": "2026-09-17T21:28:47.530Z",
|
|
5
|
+
"gitSha": "702d1461",
|
|
6
6
|
"catalog": {
|
|
7
|
-
"agents":
|
|
8
|
-
"tools":
|
|
9
|
-
"skills":
|
|
7
|
+
"agents": 167,
|
|
8
|
+
"tools": 418,
|
|
9
|
+
"skills": 34
|
|
10
10
|
},
|
|
11
11
|
"benchmark": null
|
|
12
12
|
}
|
|
@@ -600,7 +600,7 @@ const routeCommand = {
|
|
|
600
600
|
if (result.routing) {
|
|
601
601
|
output.writeln();
|
|
602
602
|
output.writeln(output.bold('Routing Method'));
|
|
603
|
-
const methodDisplay = result.routing.method.startsWith('semantic')
|
|
603
|
+
const methodDisplay = result.routing.method.startsWith('semantic') || result.routing.method === 'centroid'
|
|
604
604
|
? output.success(`${result.routing.method} (${result.routing.backend || 'semantic'})`)
|
|
605
605
|
: 'keyword';
|
|
606
606
|
output.printList([
|
|
@@ -1374,7 +1374,7 @@ async function doImport() {
|
|
|
1374
1374
|
|
|
1375
1375
|
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
1376
1376
|
warnMemoryUnavailable();
|
|
1377
|
-
return;
|
|
1377
|
+
return 1; // #4963: nothing was imported/synced
|
|
1378
1378
|
}
|
|
1379
1379
|
|
|
1380
1380
|
// Full implementation deferred to copied version
|
|
@@ -1391,7 +1391,7 @@ async function doSync() {
|
|
|
1391
1391
|
|
|
1392
1392
|
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
1393
1393
|
warnMemoryUnavailable();
|
|
1394
|
-
return;
|
|
1394
|
+
return 1; // #4963: nothing was imported/synced
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
1397
1397
|
dim('Auto memory sync available — run init --upgrade for full support');
|
|
@@ -1412,10 +1412,11 @@ process.on('unhandledRejection', () => {});
|
|
|
1412
1412
|
const COMMANDS = ['import', 'sync', 'status'];
|
|
1413
1413
|
const command = process.argv[2] || (COMMANDS.includes(process.argv[1]) ? process.argv[1] : 'status');
|
|
1414
1414
|
|
|
1415
|
+
let exitCode = 0;
|
|
1415
1416
|
try {
|
|
1416
1417
|
switch (command) {
|
|
1417
|
-
case 'import': await doImport(); break;
|
|
1418
|
-
case 'sync': await doSync(); break;
|
|
1418
|
+
case 'import': exitCode = (await doImport()) || 0; break;
|
|
1419
|
+
case 'sync': exitCode = (await doSync()) || 0; break;
|
|
1419
1420
|
case 'status': doStatus(); break;
|
|
1420
1421
|
default:
|
|
1421
1422
|
console.log('Usage: auto-memory-hook.mjs <import|sync|status>');
|
|
@@ -1425,8 +1426,8 @@ try {
|
|
|
1425
1426
|
// Hooks must never crash Claude Code - fail silently
|
|
1426
1427
|
dim(\`Error (non-critical): \${err.message}\`);
|
|
1427
1428
|
}
|
|
1428
|
-
//
|
|
1429
|
-
process.exit(
|
|
1429
|
+
// A missing memory package exits 1 (#4963); other failures above stay non-critical.
|
|
1430
|
+
process.exit(exitCode);
|
|
1430
1431
|
`;
|
|
1431
1432
|
}
|
|
1432
1433
|
/**
|
|
@@ -48,11 +48,26 @@ const STANDALONE_RISK_PATTERNS = [
|
|
|
48
48
|
/\bnc\s+-e\b/i,
|
|
49
49
|
/base64\s+(-d|--decode)\b/i,
|
|
50
50
|
];
|
|
51
|
+
// General-purpose scripting interpreters with the same GTFOBins-documented
|
|
52
|
+
// shell-breakout capability as `python`/`ruby`/`perl` (already in
|
|
53
|
+
// SHELL_EXEC_WORDS) — e.g. `node -e "require('child_process').execSync(...)"`
|
|
54
|
+
// — but deliberately NOT merged into SHELL_EXEC_WORDS: that array also
|
|
55
|
+
// drives scanCommandStringForRisk's downloader+shell-exec co-occurrence
|
|
56
|
+
// check on fixed hook *command strings*, where ruflo's own hooks
|
|
57
|
+
// legitimately invoke `node <script>` (see the dedicated "does not flag"
|
|
58
|
+
// cases in settings-risk-scanner.test.ts) and must stay exempt there. This
|
|
59
|
+
// array only ever feeds RISKY_PREAPPROVE_WORDS below, so it tightens
|
|
60
|
+
// scanAllowRuleForRisk's permissions.allow heuristic without touching
|
|
61
|
+
// scanCommandStringForRisk's already-correct behavior. `osascript`/`pwsh`
|
|
62
|
+
// are deliberately excluded: macOS/Windows-only and out of scope for this
|
|
63
|
+
// Linux-focused heuristic; `powershell` already has a dedicated, more
|
|
64
|
+
// precise detector (hasEncodedPowershell) rather than a blunt word match.
|
|
65
|
+
const INTERPRETER_WORDS = ['node', 'deno', 'bun', 'php'];
|
|
51
66
|
// Words a Bash allow-rule should never blanket-preapprove without a
|
|
52
67
|
// specific argument scope, even though they aren't "dangerous" on their
|
|
53
68
|
// own the way `rm`/`chmod` are — pre-approving them removes the human
|
|
54
69
|
// review step for exactly the commands download-and-execute attacks use.
|
|
55
|
-
const RISKY_PREAPPROVE_WORDS = [...DANGEROUS_COMMAND_WORDS, ...SHELL_EXEC_WORDS, ...DOWNLOADER_WORDS];
|
|
70
|
+
const RISKY_PREAPPROVE_WORDS = [...DANGEROUS_COMMAND_WORDS, ...SHELL_EXEC_WORDS, ...DOWNLOADER_WORDS, ...INTERPRETER_WORDS];
|
|
56
71
|
// Encoded PowerShell (`powershell[.exe] ... -e|-enc|-encodedcommand <payload>`),
|
|
57
72
|
// matched on whitespace-separated tokens in ONE linear pass. The earlier regex
|
|
58
73
|
// (`powershell\\s+(?:\\S+\\s+)*?-e...`) is quadratic on repeated "powershell "
|
|
@@ -14,7 +14,8 @@ import { commandRecordingDisabled, redactCommandForStorage } from '../services/c
|
|
|
14
14
|
import { checkCommandLoop, recordCommandOutcome } from './tool-loop-guardrail.js';
|
|
15
15
|
import { buildLearnedRoutingPatterns, } from '../services/learned-routing.js';
|
|
16
16
|
import { applyTypesafeRouting, getTypesafeRouter } from '../ruvector/typesafe-router.js';
|
|
17
|
-
import { DEFAULT_ROUTER_EMBEDDER, embedForRouter, resolveRouterEmbedder, } from '../ruvector/router-embedder.js';
|
|
17
|
+
import { DEFAULT_ROUTER_EMBEDDER, embedForRouter, resolveRouterEmbedder, routerEmbedderModel, } from '../ruvector/router-embedder.js';
|
|
18
|
+
import { ABSTAIN_LABEL, centroidRouterEnabled, classify, loadCentroidArtifact, resolveMargin, } from '../ruvector/centroid-router.js';
|
|
18
19
|
// Real vector search functions - lazy loaded to avoid circular imports
|
|
19
20
|
let searchEntriesFn = null;
|
|
20
21
|
/**
|
|
@@ -1172,6 +1173,7 @@ export const hooksRoute = {
|
|
|
1172
1173
|
complexity,
|
|
1173
1174
|
},
|
|
1174
1175
|
swarmRecommendation: agents.length > 2 ? { topology: 'hierarchical', agents, coordination: 'queen-led' } : null,
|
|
1176
|
+
...centroidBypassed(`AgentDB ${agentdbRoute.controller}`, agents[0]),
|
|
1175
1177
|
};
|
|
1176
1178
|
}
|
|
1177
1179
|
}
|
|
@@ -1220,6 +1222,7 @@ export const hooksRoute = {
|
|
|
1220
1222
|
},
|
|
1221
1223
|
swarmRecommendation: null,
|
|
1222
1224
|
learning: { source: suggestion.source, matchedKeywords: suggestion.matchedKeywords },
|
|
1225
|
+
...centroidBypassed('a persisted SONA pattern', suggestion.agent),
|
|
1223
1226
|
};
|
|
1224
1227
|
}
|
|
1225
1228
|
}
|
|
@@ -1236,6 +1239,37 @@ export const hooksRoute = {
|
|
|
1236
1239
|
* so the benchmark measures this local path. (Body kept at its original
|
|
1237
1240
|
* indentation to keep this refactor's diff small.)
|
|
1238
1241
|
*/
|
|
1242
|
+
/**
|
|
1243
|
+
* ADR-527 centroid routing for one query. Returns null when the flag is off.
|
|
1244
|
+
* Never throws: an unusable artifact or embedder comes back as `unavailable`.
|
|
1245
|
+
*/
|
|
1246
|
+
/**
|
|
1247
|
+
* ADR-527: learned routes (AgentDB, persisted SONA patterns) answer before the
|
|
1248
|
+
* centroid router. Say so under the flag, so a pilot's fallback rate counts them.
|
|
1249
|
+
*/
|
|
1250
|
+
function centroidBypassed(by, agent) {
|
|
1251
|
+
return centroidRouterEnabled()
|
|
1252
|
+
? { centroid: { status: 'bypassed', reason: `${by} answered before the centroid router`, baselineAgent: agent } }
|
|
1253
|
+
: {};
|
|
1254
|
+
}
|
|
1255
|
+
async function centroidRoute(queryText, task, baselineAgent) {
|
|
1256
|
+
if (!centroidRouterEnabled())
|
|
1257
|
+
return null;
|
|
1258
|
+
try {
|
|
1259
|
+
if (!hasRoutableText(task)) {
|
|
1260
|
+
return { status: 'unavailable', reason: 'task has no letters or digits', baselineAgent };
|
|
1261
|
+
}
|
|
1262
|
+
const { artifact, error } = loadCentroidArtifact();
|
|
1263
|
+
if (!artifact)
|
|
1264
|
+
return { status: 'unavailable', reason: error ?? 'centroid artifact unavailable', baselineAgent };
|
|
1265
|
+
const q = await embedForRouter([queryText], 'minilm');
|
|
1266
|
+
const d = classify(artifact, q.vectors[0], q.embedder, routerEmbedderModel(), resolveMargin(artifact));
|
|
1267
|
+
return { ...d, ...(d.status === 'unavailable' && q.reason ? { reason: `${d.reason}; ${q.reason}` } : {}), baselineAgent };
|
|
1268
|
+
}
|
|
1269
|
+
catch (err) {
|
|
1270
|
+
return { status: 'unavailable', reason: `centroid router failed: ${err instanceof Error ? err.message : String(err)}`, baselineAgent };
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1239
1273
|
async function routeTaskLocal(task, context, useSemanticRouter, embedderOverride) {
|
|
1240
1274
|
// Get router (tries native VectorDb first, falls back to pure JS)
|
|
1241
1275
|
let handle = useSemanticRouter
|
|
@@ -1346,6 +1380,27 @@ async function routeTaskLocal(task, context, useSemanticRouter, embedderOverride
|
|
|
1346
1380
|
noMatchDetail = suggestion.note ?? 'No pattern matched.';
|
|
1347
1381
|
}
|
|
1348
1382
|
}
|
|
1383
|
+
// ADR-527: opt-in nearest-centroid router. The current router's pick is
|
|
1384
|
+
// kept as `baselineAgent` so a pilot can compare the two on outcomes.
|
|
1385
|
+
const centroid = await centroidRoute(queryText, task, agents[0]);
|
|
1386
|
+
if (centroid?.status === 'decided') {
|
|
1387
|
+
if (centroid.label === ABSTAIN_LABEL) {
|
|
1388
|
+
noMatchDetail = `Centroid router: no agent fits (closest is "none", score ${centroid.score}).`;
|
|
1389
|
+
matchedPattern = 'centroid-abstain';
|
|
1390
|
+
confidence = NO_MATCH_CONFIDENCE; // #3567: a no-match ranks below every real match
|
|
1391
|
+
}
|
|
1392
|
+
else {
|
|
1393
|
+
agents = [centroid.label, ...agents.filter(a => a !== centroid.label)];
|
|
1394
|
+
// Cosine runs about 0.2-0.6 here, so a raw score could rank a real match
|
|
1395
|
+
// below a no-match (#3567). Rescale monotonically into (NO_MATCH, 1];
|
|
1396
|
+
// the raw cosine stays in `centroid.score`. Not a probability.
|
|
1397
|
+
confidence = Math.round((NO_MATCH_CONFIDENCE + 0.01 + (0.99 - NO_MATCH_CONFIDENCE) * Math.max(0, Math.min(1, centroid.score))) * 100) / 100;
|
|
1398
|
+
matchedPattern = `centroid:${centroid.label}`;
|
|
1399
|
+
noMatchDetail = null;
|
|
1400
|
+
}
|
|
1401
|
+
routingMethod = 'centroid';
|
|
1402
|
+
backendInfo = 'nearest centroid (MiniLM)';
|
|
1403
|
+
}
|
|
1349
1404
|
// Determine complexity
|
|
1350
1405
|
const taskLower = task.toLowerCase();
|
|
1351
1406
|
const complexity = taskLower.includes('complex') || taskLower.includes('architecture') || task.length > 200
|
|
@@ -1372,11 +1427,13 @@ async function routeTaskLocal(task, context, useSemanticRouter, embedderOverride
|
|
|
1372
1427
|
primaryAgent: {
|
|
1373
1428
|
type: agents[0],
|
|
1374
1429
|
confidence: Math.round(confidence * 100) / 100,
|
|
1375
|
-
reason: routingMethod
|
|
1376
|
-
? `
|
|
1377
|
-
:
|
|
1378
|
-
? `
|
|
1379
|
-
:
|
|
1430
|
+
reason: routingMethod === 'centroid' && noMatchDetail === null
|
|
1431
|
+
? `Nearest agent centroid (${Math.round(confidence * 100)}% cosine)`
|
|
1432
|
+
: routingMethod.startsWith('semantic')
|
|
1433
|
+
? `Semantic similarity to "${matchedPattern}" pattern (${Math.round(confidence * 100)}%)`
|
|
1434
|
+
: noMatchDetail !== null
|
|
1435
|
+
? `Nothing matched; default suggestion only. ${noMatchDetail}`
|
|
1436
|
+
: `Task contains keywords matching ${agents[0]} specialization`,
|
|
1380
1437
|
},
|
|
1381
1438
|
alternativeAgents: agents.slice(1).map((agent, i) => ({
|
|
1382
1439
|
type: agent,
|
|
@@ -1396,6 +1453,7 @@ async function routeTaskLocal(task, context, useSemanticRouter, embedderOverride
|
|
|
1396
1453
|
} : null,
|
|
1397
1454
|
// ADR-390: which embedder the semantic index + query used ('hash' when degraded).
|
|
1398
1455
|
embedder: handle.embedder,
|
|
1456
|
+
...(centroid ? { centroid } : {}),
|
|
1399
1457
|
...(handle.embedderReason ? { embedderReason: handle.embedderReason } : {}),
|
|
1400
1458
|
};
|
|
1401
1459
|
}
|
|
@@ -400,7 +400,7 @@ export const metaharnessTools = [
|
|
|
400
400
|
},
|
|
401
401
|
// ───────────────────────────────────────────────────────────────────────
|
|
402
402
|
// ADR-153 — @metaharness/darwin integration (3 tools).
|
|
403
|
-
// Backed by the separate `@metaharness/darwin@~0.
|
|
403
|
+
// Backed by the separate `@metaharness/darwin@~0.14.0` npm package, NOT
|
|
404
404
|
// the umbrella `metaharness`. Plugin scripts shell out via _darwin.mjs.
|
|
405
405
|
// Same {success, data, degraded, exitCode} contract.
|
|
406
406
|
// ───────────────────────────────────────────────────────────────────────
|
|
@@ -323,13 +323,15 @@ export const taskTools = [
|
|
|
323
323
|
task.completedAt = new Date().toISOString();
|
|
324
324
|
task.result = input.result || {};
|
|
325
325
|
saveTaskStore(store);
|
|
326
|
-
// Sync assigned agents back to idle and increment taskCount
|
|
326
|
+
// Sync assigned agents back to idle and increment taskCount. Credited only to a worker
|
|
327
|
+
// still holding this task, as task_update does, so completing a reopened task again
|
|
328
|
+
// (complete -> pending -> complete, no reassignment) never counts the same work twice.
|
|
327
329
|
updateAgents(task.assignedTo, (agent) => {
|
|
328
330
|
if (agent.currentTask === taskId) {
|
|
329
331
|
agent.status = 'idle';
|
|
330
332
|
agent.currentTask = null;
|
|
333
|
+
agent.taskCount = (agent.taskCount || 0) + 1;
|
|
331
334
|
}
|
|
332
|
-
agent.taskCount = (agent.taskCount || 0) + 1;
|
|
333
335
|
});
|
|
334
336
|
return {
|
|
335
337
|
taskId: task.taskId,
|
|
@@ -390,6 +390,8 @@ export declare function generateLocalEmbedding(text: string, options?: {
|
|
|
390
390
|
embedding: number[];
|
|
391
391
|
dimensions: number;
|
|
392
392
|
model: string;
|
|
393
|
+
/** Model id behind an onnx vector, when known (ADR-527). */
|
|
394
|
+
modelId?: string;
|
|
393
395
|
backend: 'onnx' | 'mock';
|
|
394
396
|
}>;
|
|
395
397
|
/**
|
|
@@ -2154,7 +2154,8 @@ async function loadLocalEmbeddingChain(verbose = false, startTime = Date.now())
|
|
|
2154
2154
|
loaded: true,
|
|
2155
2155
|
model: embedder,
|
|
2156
2156
|
tokenizer: null,
|
|
2157
|
-
dimensions: embCfg.dimension
|
|
2157
|
+
dimensions: embCfg.dimension,
|
|
2158
|
+
modelId: embCfg.model,
|
|
2158
2159
|
};
|
|
2159
2160
|
return {
|
|
2160
2161
|
success: true,
|
|
@@ -2189,7 +2190,8 @@ async function loadLocalEmbeddingChain(verbose = false, startTime = Date.now())
|
|
|
2189
2190
|
loaded: true,
|
|
2190
2191
|
model: (text) => reasoningBank.computeEmbedding(text),
|
|
2191
2192
|
tokenizer: null,
|
|
2192
|
-
dimensions: 384
|
|
2193
|
+
dimensions: 384,
|
|
2194
|
+
modelId: 'agentic-flow/all-MiniLM-L6-v2',
|
|
2193
2195
|
};
|
|
2194
2196
|
return {
|
|
2195
2197
|
success: true,
|
|
@@ -2219,7 +2221,8 @@ async function loadLocalEmbeddingChain(verbose = false, startTime = Date.now())
|
|
|
2219
2221
|
loaded: true,
|
|
2220
2222
|
model: (text) => onnxEmb.embed(text),
|
|
2221
2223
|
tokenizer: null,
|
|
2222
|
-
dimensions: probe.length || 384
|
|
2224
|
+
dimensions: probe.length || 384,
|
|
2225
|
+
modelId: 'ruvector/all-MiniLM-L6-v2',
|
|
2223
2226
|
};
|
|
2224
2227
|
return {
|
|
2225
2228
|
success: true,
|
|
@@ -2359,6 +2362,7 @@ export async function generateLocalEmbedding(text, options) {
|
|
|
2359
2362
|
embedding,
|
|
2360
2363
|
dimensions: embedding.length,
|
|
2361
2364
|
model: 'onnx',
|
|
2365
|
+
...(state.modelId ? { modelId: state.modelId } : {}),
|
|
2362
2366
|
backend: 'onnx'
|
|
2363
2367
|
};
|
|
2364
2368
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* centroid-router.ts — opt-in nearest-centroid agent router (ADR-527).
|
|
3
|
+
*
|
|
4
|
+
* Each agent label has one unit-length centroid: the mean MiniLM embedding of
|
|
5
|
+
* its labelled example prompts (the ADR-391 corpus dev split, built by
|
|
6
|
+
* `benchmarks/router/build-centroids.mjs`). A task goes to the label whose
|
|
7
|
+
* centroid is most cosine-similar. When the top two scores are closer than
|
|
8
|
+
* `margin`, the caller keeps the current router's pick instead.
|
|
9
|
+
*
|
|
10
|
+
* The artifact records the embedding model and dimension it was built with.
|
|
11
|
+
* A query embedded any other way (for example MiniLM degraded to the hash
|
|
12
|
+
* embedder) is never scored against it: `classify` returns `unavailable`.
|
|
13
|
+
*
|
|
14
|
+
* Gate: `CLAUDE_FLOW_ROUTER_CENTROID=1`. Off by default; the current router
|
|
15
|
+
* is unchanged unless the flag is set.
|
|
16
|
+
*
|
|
17
|
+
* @module centroid-router
|
|
18
|
+
*/
|
|
19
|
+
export declare const CENTROID_ROUTER_ENV = "CLAUDE_FLOW_ROUTER_CENTROID";
|
|
20
|
+
export declare const CENTROID_MARGIN_ENV = "CLAUDE_FLOW_ROUTER_CENTROID_MARGIN";
|
|
21
|
+
export declare const CENTROID_ARTIFACT_ENV = "CLAUDE_FLOW_ROUTER_CENTROID_PATH";
|
|
22
|
+
export declare const CENTROID_SCHEMA = "ruflo.agent-centroids/1";
|
|
23
|
+
/** Label meaning "no agent fits"; the router abstains instead of picking one. */
|
|
24
|
+
export declare const ABSTAIN_LABEL = "none";
|
|
25
|
+
export interface CentroidArtifact {
|
|
26
|
+
schema: typeof CENTROID_SCHEMA;
|
|
27
|
+
/** Embedder kind the centroids live in. Only 'minilm' is built today. */
|
|
28
|
+
embedder: 'minilm';
|
|
29
|
+
/** Embedding model id reported by the local embedder when the artifact was built. */
|
|
30
|
+
model: string;
|
|
31
|
+
dim: number;
|
|
32
|
+
/** Default top-two margin below which the caller falls back. */
|
|
33
|
+
margin: number;
|
|
34
|
+
/** sha256 of the corpus file the centroids were built from. */
|
|
35
|
+
corpusSha256: string;
|
|
36
|
+
split: string;
|
|
37
|
+
labels: string[];
|
|
38
|
+
/** Examples per label, aligned with `labels`. */
|
|
39
|
+
support: number[];
|
|
40
|
+
/** Unit-length centroids, aligned with `labels`. */
|
|
41
|
+
centroids: number[][];
|
|
42
|
+
}
|
|
43
|
+
export type CentroidDecision = {
|
|
44
|
+
status: 'decided';
|
|
45
|
+
label: string;
|
|
46
|
+
score: number;
|
|
47
|
+
runnerUp: string;
|
|
48
|
+
runnerUpScore: number;
|
|
49
|
+
margin: number;
|
|
50
|
+
} | {
|
|
51
|
+
status: 'fallback';
|
|
52
|
+
label: string;
|
|
53
|
+
score: number;
|
|
54
|
+
runnerUp: string;
|
|
55
|
+
runnerUpScore: number;
|
|
56
|
+
margin: number;
|
|
57
|
+
reason: string;
|
|
58
|
+
} | {
|
|
59
|
+
status: 'unavailable';
|
|
60
|
+
reason: string;
|
|
61
|
+
}
|
|
62
|
+
/** A learned route (AgentDB or a persisted SONA pattern) answered before the centroid router ran. */
|
|
63
|
+
| {
|
|
64
|
+
status: 'bypassed';
|
|
65
|
+
reason: string;
|
|
66
|
+
};
|
|
67
|
+
export declare function centroidRouterEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
68
|
+
/** Margin from the env when it is a finite number in [0, 1], else the artifact default. */
|
|
69
|
+
export declare function resolveMargin(artifact: Pick<CentroidArtifact, 'margin'>, env?: NodeJS.ProcessEnv): number;
|
|
70
|
+
/** Throws with a specific message when the artifact is malformed. */
|
|
71
|
+
export declare function validateArtifact(a: unknown): CentroidArtifact;
|
|
72
|
+
/** Load (and cache) the artifact. Returns the error instead of throwing. */
|
|
73
|
+
export declare function loadCentroidArtifact(env?: NodeJS.ProcessEnv): {
|
|
74
|
+
artifact: CentroidArtifact | null;
|
|
75
|
+
error: string | null;
|
|
76
|
+
path: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Score one query embedding.
|
|
80
|
+
* @param query the query vector (any length; normalised here)
|
|
81
|
+
* @param queryEmbedder the embedder that actually produced `query`
|
|
82
|
+
* @param queryModel the model id that produced it, when known
|
|
83
|
+
*/
|
|
84
|
+
export declare function classify(artifact: CentroidArtifact, query: ArrayLike<number>, queryEmbedder: string, queryModel: string | undefined, margin: number): CentroidDecision;
|
|
85
|
+
/** Test hook. */
|
|
86
|
+
export declare function __resetCentroidRouterForTests(): void;
|
|
87
|
+
//# sourceMappingURL=centroid-router.d.ts.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* centroid-router.ts — opt-in nearest-centroid agent router (ADR-527).
|
|
3
|
+
*
|
|
4
|
+
* Each agent label has one unit-length centroid: the mean MiniLM embedding of
|
|
5
|
+
* its labelled example prompts (the ADR-391 corpus dev split, built by
|
|
6
|
+
* `benchmarks/router/build-centroids.mjs`). A task goes to the label whose
|
|
7
|
+
* centroid is most cosine-similar. When the top two scores are closer than
|
|
8
|
+
* `margin`, the caller keeps the current router's pick instead.
|
|
9
|
+
*
|
|
10
|
+
* The artifact records the embedding model and dimension it was built with.
|
|
11
|
+
* A query embedded any other way (for example MiniLM degraded to the hash
|
|
12
|
+
* embedder) is never scored against it: `classify` returns `unavailable`.
|
|
13
|
+
*
|
|
14
|
+
* Gate: `CLAUDE_FLOW_ROUTER_CENTROID=1`. Off by default; the current router
|
|
15
|
+
* is unchanged unless the flag is set.
|
|
16
|
+
*
|
|
17
|
+
* @module centroid-router
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
20
|
+
import { dirname, resolve as resolvePath } from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
22
|
+
export const CENTROID_ROUTER_ENV = 'CLAUDE_FLOW_ROUTER_CENTROID';
|
|
23
|
+
export const CENTROID_MARGIN_ENV = 'CLAUDE_FLOW_ROUTER_CENTROID_MARGIN';
|
|
24
|
+
export const CENTROID_ARTIFACT_ENV = 'CLAUDE_FLOW_ROUTER_CENTROID_PATH';
|
|
25
|
+
export const CENTROID_SCHEMA = 'ruflo.agent-centroids/1';
|
|
26
|
+
/** Label meaning "no agent fits"; the router abstains instead of picking one. */
|
|
27
|
+
export const ABSTAIN_LABEL = 'none';
|
|
28
|
+
export function centroidRouterEnabled(env = process.env) {
|
|
29
|
+
return env[CENTROID_ROUTER_ENV] === '1';
|
|
30
|
+
}
|
|
31
|
+
/** Margin from the env when it is a finite number in [0, 1], else the artifact default. */
|
|
32
|
+
export function resolveMargin(artifact, env = process.env) {
|
|
33
|
+
const raw = env[CENTROID_MARGIN_ENV];
|
|
34
|
+
if (raw !== undefined && raw.trim() !== '') {
|
|
35
|
+
const m = Number(raw);
|
|
36
|
+
if (Number.isFinite(m) && m >= 0 && m <= 1)
|
|
37
|
+
return m;
|
|
38
|
+
}
|
|
39
|
+
return artifact.margin;
|
|
40
|
+
}
|
|
41
|
+
/** Throws with a specific message when the artifact is malformed. */
|
|
42
|
+
export function validateArtifact(a) {
|
|
43
|
+
const x = a;
|
|
44
|
+
if (!x || x.schema !== CENTROID_SCHEMA)
|
|
45
|
+
throw new Error(`centroid artifact schema is not ${CENTROID_SCHEMA}`);
|
|
46
|
+
if (x.embedder !== 'minilm')
|
|
47
|
+
throw new Error(`centroid artifact embedder '${String(x.embedder)}' is not supported`);
|
|
48
|
+
if (typeof x.model !== 'string' || !x.model)
|
|
49
|
+
throw new Error('centroid artifact has no model id');
|
|
50
|
+
if (!Number.isInteger(x.dim) || x.dim <= 0)
|
|
51
|
+
throw new Error('centroid artifact dim is invalid');
|
|
52
|
+
if (typeof x.margin !== 'number' || !(x.margin >= 0 && x.margin <= 1))
|
|
53
|
+
throw new Error('centroid artifact margin is invalid');
|
|
54
|
+
const labels = x.labels, cents = x.centroids, support = x.support;
|
|
55
|
+
if (!Array.isArray(labels) || labels.length < 2)
|
|
56
|
+
throw new Error('centroid artifact needs at least two labels');
|
|
57
|
+
if (!Array.isArray(cents) || cents.length !== labels.length)
|
|
58
|
+
throw new Error('centroid artifact labels and centroids differ in length');
|
|
59
|
+
if (!Array.isArray(support) || support.length !== labels.length)
|
|
60
|
+
throw new Error('centroid artifact labels and support differ in length');
|
|
61
|
+
for (const c of cents) {
|
|
62
|
+
if (!Array.isArray(c) || c.length !== x.dim || !c.every(Number.isFinite)) {
|
|
63
|
+
throw new Error(`centroid artifact has a centroid that is not ${x.dim} finite numbers`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return x;
|
|
67
|
+
}
|
|
68
|
+
let _cache = null;
|
|
69
|
+
function defaultArtifactPath() {
|
|
70
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
71
|
+
// src/ruvector → assets, dist/src/ruvector → assets (package root)
|
|
72
|
+
const candidates = [
|
|
73
|
+
resolvePath(here, '..', '..', 'assets', 'agent-router', 'centroids.minilm.json'),
|
|
74
|
+
resolvePath(here, '..', '..', '..', 'assets', 'agent-router', 'centroids.minilm.json'),
|
|
75
|
+
];
|
|
76
|
+
return candidates.find(existsSync) ?? candidates[0];
|
|
77
|
+
}
|
|
78
|
+
/** Load (and cache) the artifact. Returns the error instead of throwing. */
|
|
79
|
+
export function loadCentroidArtifact(env = process.env) {
|
|
80
|
+
const path = env[CENTROID_ARTIFACT_ENV] || defaultArtifactPath();
|
|
81
|
+
if (_cache && _cache.path === path)
|
|
82
|
+
return _cache;
|
|
83
|
+
try {
|
|
84
|
+
if (!existsSync(path))
|
|
85
|
+
throw new Error(`centroid artifact not found at ${path}`);
|
|
86
|
+
_cache = { path, artifact: validateArtifact(JSON.parse(readFileSync(path, 'utf8'))), error: null };
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
_cache = { path, artifact: null, error: err instanceof Error ? err.message : String(err) };
|
|
90
|
+
}
|
|
91
|
+
return _cache;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Score one query embedding.
|
|
95
|
+
* @param query the query vector (any length; normalised here)
|
|
96
|
+
* @param queryEmbedder the embedder that actually produced `query`
|
|
97
|
+
* @param queryModel the model id that produced it, when known
|
|
98
|
+
*/
|
|
99
|
+
export function classify(artifact, query, queryEmbedder, queryModel, margin) {
|
|
100
|
+
if (queryEmbedder !== artifact.embedder) {
|
|
101
|
+
return { status: 'unavailable', reason: `query embedded with '${queryEmbedder}', centroids are '${artifact.embedder}'` };
|
|
102
|
+
}
|
|
103
|
+
if (queryModel !== undefined && normaliseModel(queryModel) !== normaliseModel(artifact.model)) {
|
|
104
|
+
return { status: 'unavailable', reason: `query model '${queryModel}' differs from centroid model '${artifact.model}'` };
|
|
105
|
+
}
|
|
106
|
+
if (query.length !== artifact.dim) {
|
|
107
|
+
return { status: 'unavailable', reason: `query is ${query.length}-d, centroids are ${artifact.dim}-d` };
|
|
108
|
+
}
|
|
109
|
+
let norm = 0;
|
|
110
|
+
for (let i = 0; i < query.length; i++)
|
|
111
|
+
norm += query[i] * query[i];
|
|
112
|
+
norm = Math.sqrt(norm);
|
|
113
|
+
if (!(norm > 0))
|
|
114
|
+
return { status: 'unavailable', reason: 'query embedding is all zeros' };
|
|
115
|
+
let best = -1, second = -1, bestScore = -Infinity, secondScore = -Infinity;
|
|
116
|
+
for (let k = 0; k < artifact.centroids.length; k++) {
|
|
117
|
+
const c = artifact.centroids[k];
|
|
118
|
+
let dot = 0;
|
|
119
|
+
for (let i = 0; i < c.length; i++)
|
|
120
|
+
dot += c[i] * query[i];
|
|
121
|
+
const s = dot / norm;
|
|
122
|
+
if (s > bestScore) {
|
|
123
|
+
second = best;
|
|
124
|
+
secondScore = bestScore;
|
|
125
|
+
best = k;
|
|
126
|
+
bestScore = s;
|
|
127
|
+
}
|
|
128
|
+
else if (s > secondScore) {
|
|
129
|
+
second = k;
|
|
130
|
+
secondScore = s;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const out = {
|
|
134
|
+
label: artifact.labels[best], score: round(bestScore),
|
|
135
|
+
runnerUp: artifact.labels[second], runnerUpScore: round(secondScore),
|
|
136
|
+
margin: round(bestScore - secondScore),
|
|
137
|
+
};
|
|
138
|
+
if (bestScore - secondScore < margin) {
|
|
139
|
+
return { status: 'fallback', ...out, reason: `top two within margin ${margin}` };
|
|
140
|
+
}
|
|
141
|
+
return { status: 'decided', ...out };
|
|
142
|
+
}
|
|
143
|
+
/** 'Xenova/all-MiniLM-L6-v2' and 'all-MiniLM-L6-v2' name the same model; other runtimes keep their prefix. */
|
|
144
|
+
function normaliseModel(m) {
|
|
145
|
+
return m.replace(/^Xenova\//i, '').toLowerCase();
|
|
146
|
+
}
|
|
147
|
+
function round(x) {
|
|
148
|
+
return Math.round(x * 10000) / 10000;
|
|
149
|
+
}
|
|
150
|
+
/** Test hook. */
|
|
151
|
+
export function __resetCentroidRouterForTests() {
|
|
152
|
+
_cache = null;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=centroid-router.js.map
|
|
@@ -48,6 +48,8 @@ export declare function resolveRouterEmbedder(override?: RouterEmbedderKind, env
|
|
|
48
48
|
* and thresholds were calibrated against it.
|
|
49
49
|
*/
|
|
50
50
|
export declare function generateSimpleEmbedding(text: string, dimension?: number): Float32Array;
|
|
51
|
+
/** Model id behind the most recent MiniLM vector, or undefined before the first one. */
|
|
52
|
+
export declare function routerEmbedderModel(): string | undefined;
|
|
51
53
|
/**
|
|
52
54
|
* Embed texts for the router. All vectors in one result come from ONE embedder.
|
|
53
55
|
* `hash` never touches the model (no load cost for default users).
|
|
@@ -86,6 +86,12 @@ function l2Normalize(v) {
|
|
|
86
86
|
// changes, so this survives router rebuilds (e.g. after saveRoutingOutcomes).
|
|
87
87
|
const MINILM_CACHE = new Map();
|
|
88
88
|
const MINILM_CACHE_MAX = 2048;
|
|
89
|
+
/** Model id the local embedder last reported for a MiniLM vector (ADR-527 version check). */
|
|
90
|
+
let lastMiniLMModel;
|
|
91
|
+
/** Model id behind the most recent MiniLM vector, or undefined before the first one. */
|
|
92
|
+
export function routerEmbedderModel() {
|
|
93
|
+
return lastMiniLMModel;
|
|
94
|
+
}
|
|
89
95
|
async function embedOneMiniLM(text) {
|
|
90
96
|
const cached = MINILM_CACHE.get(text);
|
|
91
97
|
if (cached)
|
|
@@ -98,6 +104,7 @@ async function embedOneMiniLM(text) {
|
|
|
98
104
|
if (!out.embedding || out.embedding.length !== ROUTER_EMBEDDING_DIM) {
|
|
99
105
|
throw new RouterEmbedderDegraded(`local embedder returned ${out.embedding?.length ?? 0}-d vectors; router index is ${ROUTER_EMBEDDING_DIM}-d`);
|
|
100
106
|
}
|
|
107
|
+
lastMiniLMModel = out.modelId ?? out.model;
|
|
101
108
|
const vec = l2Normalize(Float32Array.from(out.embedding));
|
|
102
109
|
if (MINILM_CACHE.size >= MINILM_CACHE_MAX) {
|
|
103
110
|
const oldest = MINILM_CACHE.keys().next().value;
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
*/
|
|
37
37
|
import { type VerifyTaskKind } from '../ruvector/output-verifier.js';
|
|
38
38
|
import { FableHarness, type ReflectItem, type ReflectResult } from './fable-harness.js';
|
|
39
|
-
export declare const MH_DARWIN_PIN = "0.
|
|
39
|
+
export declare const MH_DARWIN_PIN = "0.14.0";
|
|
40
40
|
export type ResolvedProvenance = 'oracle:test-exec' | 'judge:fable' | 'proxy:structural';
|
|
41
41
|
/** SWE-bench-shaped / bench-suite-mapped test spec that Tier 1 can execute. */
|
|
42
42
|
export interface TestSpec {
|
|
@@ -43,9 +43,9 @@ import { FableHarness, } from './fable-harness.js';
|
|
|
43
43
|
// behavior mid-run (the #142 pin-drift failure mode). Pin it, and let
|
|
44
44
|
// scripts/check-metaharness-pins.mjs watch this constant for drift. Kept in
|
|
45
45
|
// lock-step with the optionalDependencies pin in package.json and the plugin
|
|
46
|
-
// darwin cache (versioned by the plugin's own `~0.
|
|
46
|
+
// darwin cache (versioned by the plugin's own `~0.14.0` pin in _darwin.mjs;
|
|
47
47
|
// both are checked by scripts/check-metaharness-pins.mjs — #3366).
|
|
48
|
-
export const MH_DARWIN_PIN = '0.
|
|
48
|
+
export const MH_DARWIN_PIN = '0.14.0';
|
|
49
49
|
// ── Public API ───────────────────────────────────────────────────────────
|
|
50
50
|
/**
|
|
51
51
|
* Label each trajectory with `resolved` + honest provenance, trying the tiers
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.76.1",
|
|
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",
|
|
@@ -76,6 +76,10 @@
|
|
|
76
76
|
"!dist/**/*.tsbuildinfo",
|
|
77
77
|
"bin",
|
|
78
78
|
"scripts/postinstall.cjs",
|
|
79
|
+
"assets/agent-router",
|
|
80
|
+
"assets/model-router/seed-router.krr*.json",
|
|
81
|
+
"assets/model-router/seed-router.calibrator*.json",
|
|
82
|
+
"assets/model-router/seed-rows.json",
|
|
79
83
|
"templates",
|
|
80
84
|
".claude",
|
|
81
85
|
"plugins",
|
|
@@ -109,7 +113,7 @@
|
|
|
109
113
|
"@claude-flow/security": "3.0.7",
|
|
110
114
|
"@claude-flow/shared": "3.0.8",
|
|
111
115
|
"@iarna/toml": "^2.2.5",
|
|
112
|
-
"@metaharness/darwin": "~0.
|
|
116
|
+
"@metaharness/darwin": "~0.14.0",
|
|
113
117
|
"@noble/ed25519": "2.3.0",
|
|
114
118
|
"@ruvector/rabitq-wasm": "0.1.2",
|
|
115
119
|
"agentic-flow": "^3.0.0",
|
|
@@ -130,17 +134,17 @@
|
|
|
130
134
|
"ws": "^8.21.0",
|
|
131
135
|
"yaml": "^2.8.0",
|
|
132
136
|
"zod": "^3.22.0",
|
|
133
|
-
"@claude-flow/memory": "3.3.
|
|
137
|
+
"@claude-flow/memory": "3.3.2"
|
|
134
138
|
},
|
|
135
139
|
"optionalDependencies": {
|
|
136
140
|
"@agntcy/slim-bindings": "2.1.1",
|
|
137
141
|
"@claude-flow/aidefence": "3.2.1",
|
|
138
|
-
"@claude-flow/memory": "3.3.
|
|
142
|
+
"@claude-flow/memory": "3.3.2",
|
|
139
143
|
"@metaharness/flywheel": "~0.1.10",
|
|
140
144
|
"@metaharness/radio": "~0.1.0",
|
|
141
145
|
"@metaharness/turn-credit": "~0.1.0",
|
|
142
146
|
"@napi-rs/keyring": "1.3.0",
|
|
143
|
-
"agentdb": "^3.
|
|
147
|
+
"agentdb": "^3.10.0",
|
|
144
148
|
"better-sqlite3": "^12.9.0",
|
|
145
149
|
"ruvector": "^0.3.13",
|
|
146
150
|
"nostr-tools": "^2.7.0",
|