agentic-flow 3.0.0 → 3.2.0
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/.agents/skills/agentic-flow-ecosystem/SKILL.md +50 -0
- package/.claude/skills/agentic-flow-ecosystem/skill.md +58 -0
- package/.claude/skills/agentic-flow-quickstart/skill.md +6 -6
- package/.claude/skills/hooks-automation/skill.md +11 -11
- package/.claude/skills/memory-patterns/skill.md +7 -7
- package/.claude/skills/sparc-methodology/skill.md +13 -13
- package/.claude/skills/swarm-coordination/skill.md +5 -5
- package/.claude/skills/worker-benchmarks/skill.md +5 -5
- package/.claude/skills/worker-integration/skill.md +5 -5
- package/.claude/statusline.mjs +22 -5
- package/CHANGELOG.md +48 -0
- package/README.md +83 -71
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli/commands/hooks.d.ts.map +1 -1
- package/dist/cli/commands/hooks.js +17 -17
- package/dist/cli/commands/hooks.js.map +1 -1
- package/dist/cli/commands/init.d.ts +2 -5
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +11 -15
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/swarm.d.ts.map +1 -1
- package/dist/cli/commands/swarm.js +3 -2
- package/dist/cli/commands/swarm.js.map +1 -1
- package/dist/core/agentdb-fast.d.ts +21 -11
- package/dist/core/agentdb-fast.d.ts.map +1 -1
- package/dist/core/agentdb-fast.js +39 -14
- package/dist/core/agentdb-fast.js.map +1 -1
- package/dist/integrations/agent-booster.d.ts +35 -0
- package/dist/integrations/agent-booster.d.ts.map +1 -0
- package/dist/integrations/agent-booster.js +45 -0
- package/dist/integrations/agent-booster.js.map +1 -0
- package/dist/integrations/index.d.ts +15 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +11 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/onnx-wasm-embedder.d.ts +59 -0
- package/dist/integrations/onnx-wasm-embedder.d.ts.map +1 -0
- package/dist/integrations/onnx-wasm-embedder.js +145 -0
- package/dist/integrations/onnx-wasm-embedder.js.map +1 -0
- package/dist/integrations/optional.d.ts +44 -0
- package/dist/integrations/optional.d.ts.map +1 -0
- package/dist/integrations/optional.js +107 -0
- package/dist/integrations/optional.js.map +1 -0
- package/dist/integrations/prompt-injection.d.ts +52 -0
- package/dist/integrations/prompt-injection.d.ts.map +1 -0
- package/dist/integrations/prompt-injection.js +126 -0
- package/dist/integrations/prompt-injection.js.map +1 -0
- package/dist/integrations/sublinear.d.ts +71 -0
- package/dist/integrations/sublinear.d.ts.map +1 -0
- package/dist/integrations/sublinear.js +227 -0
- package/dist/integrations/sublinear.js.map +1 -0
- package/dist/integrations/task-partition.d.ts +40 -0
- package/dist/integrations/task-partition.d.ts.map +1 -0
- package/dist/integrations/task-partition.js +173 -0
- package/dist/integrations/task-partition.js.map +1 -0
- package/dist/mcp/mcp-policy.d.ts.map +1 -1
- package/dist/mcp/mcp-policy.js +2 -0
- package/dist/mcp/mcp-policy.js.map +1 -1
- package/dist/mcp/standalone-stdio.js +12 -26
- package/dist/mcp/standalone-stdio.js.map +1 -1
- package/dist/mcp/tools/ecosystem-tools.d.ts +49 -0
- package/dist/mcp/tools/ecosystem-tools.d.ts.map +1 -0
- package/dist/mcp/tools/ecosystem-tools.js +126 -0
- package/dist/mcp/tools/ecosystem-tools.js.map +1 -0
- package/dist/proxy/anthropic-to-gemini.d.ts.map +1 -1
- package/dist/proxy/anthropic-to-gemini.js +10 -14
- package/dist/proxy/anthropic-to-gemini.js.map +1 -1
- package/dist/proxy/anthropic-to-openrouter.d.ts.map +1 -1
- package/dist/proxy/anthropic-to-openrouter.js +6 -25
- package/dist/proxy/anthropic-to-openrouter.js.map +1 -1
- package/dist/proxy/anthropic-to-requesty.d.ts.map +1 -1
- package/dist/proxy/anthropic-to-requesty.js +8 -10
- package/dist/proxy/anthropic-to-requesty.js.map +1 -1
- package/dist/proxy/sse-lines.d.ts +9 -0
- package/dist/proxy/sse-lines.d.ts.map +1 -0
- package/dist/proxy/sse-lines.js +37 -0
- package/dist/proxy/sse-lines.js.map +1 -0
- package/dist/reasoningbank/index.d.ts +2 -1
- package/dist/reasoningbank/index.d.ts.map +1 -1
- package/dist/reasoningbank/index.js +1 -1
- package/dist/reasoningbank/index.js.map +1 -1
- package/dist/reasoningbank/utils/embeddings.d.ts +17 -0
- package/dist/reasoningbank/utils/embeddings.d.ts.map +1 -1
- package/dist/reasoningbank/utils/embeddings.js +48 -17
- package/dist/reasoningbank/utils/embeddings.js.map +1 -1
- package/dist/routing/SemanticRouter.d.ts +25 -9
- package/dist/routing/SemanticRouter.d.ts.map +1 -1
- package/dist/routing/SemanticRouter.js +63 -12
- package/dist/routing/SemanticRouter.js.map +1 -1
- package/dist/utils/input-validator.d.ts +10 -2
- package/dist/utils/input-validator.d.ts.map +1 -1
- package/dist/utils/input-validator.js +30 -2
- package/dist/utils/input-validator.js.map +1 -1
- package/dist/utils/model-cache.d.ts.map +1 -1
- package/dist/utils/model-cache.js +6 -25
- package/dist/utils/model-cache.js.map +1 -1
- package/dist/utils/package-version.d.ts +9 -0
- package/dist/utils/package-version.d.ts.map +1 -0
- package/dist/utils/package-version.js +39 -0
- package/dist/utils/package-version.js.map +1 -0
- package/dist/wasm/onnx-embeddings-wasm.d.ts.map +1 -1
- package/dist/wasm/onnx-embeddings-wasm.js +21 -10
- package/dist/wasm/onnx-embeddings-wasm.js.map +1 -1
- package/docs/docker-tests/TEST-V1.7.8.Dockerfile +2 -2
- package/docs/docker-tests/TEST-V1.7.9-NODE20.Dockerfile +2 -2
- package/docs/docker-tests/TEST-V1.7.9.Dockerfile +2 -2
- package/docs/guides/CLAUDE-CODE-INTEGRATION.md +25 -8
- package/docs/guides/PROXY-ARCHITECTURE-AND-EXTENSION.md +22 -9
- package/docs/guides/STANDALONE_PROXY_GUIDE.md +16 -6
- package/docs/integrations/FASTMCP_CLI_INTEGRATION.md +1 -1
- package/docs/plans/requesty/02-architecture.md +5 -6
- package/docs/plans/requesty/03-implementation-phases.md +3 -4
- package/docs/plans/requesty/05-migration-guide.md +2 -2
- package/package.json +12 -7
- package/scripts/validate-providers.sh +7 -4
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split a task-dependency graph into two groups with the least coupling.
|
|
3
|
+
*
|
|
4
|
+
* A global minimum cut over the (undirected, weighted) dependency graph finds
|
|
5
|
+
* the split that severs the fewest/lightest dependencies — the natural seam for
|
|
6
|
+
* handing work to two agent teams so they block on each other least.
|
|
7
|
+
*
|
|
8
|
+
* Engine: `@ruvector/mincut-wasm` (optionalDependency) when installed; a
|
|
9
|
+
* built-in Stoer-Wagner implementation otherwise (O(n^3), capped at
|
|
10
|
+
* BUILTIN_MAX_TASKS). Both are exact, so they agree on the cut weight.
|
|
11
|
+
*
|
|
12
|
+
* A global min cut can be lopsided (one loosely-attached task vs the rest):
|
|
13
|
+
* that is the correct answer to "where is the weakest seam", not a balance
|
|
14
|
+
* guarantee. Tasks with no dependencies have nothing to cut and are reported
|
|
15
|
+
* in `isolated` rather than forced into a side.
|
|
16
|
+
*/
|
|
17
|
+
import { importOptional } from './optional.js';
|
|
18
|
+
export const BUILTIN_MAX_TASKS = 400;
|
|
19
|
+
function normalize(tasks, deps) {
|
|
20
|
+
const ids = new Map();
|
|
21
|
+
const names = [];
|
|
22
|
+
const add = (t) => {
|
|
23
|
+
if (!ids.has(t)) {
|
|
24
|
+
ids.set(t, names.length);
|
|
25
|
+
names.push(t);
|
|
26
|
+
}
|
|
27
|
+
return ids.get(t);
|
|
28
|
+
};
|
|
29
|
+
for (const t of tasks)
|
|
30
|
+
add(String(t));
|
|
31
|
+
const weights = new Map();
|
|
32
|
+
for (const d of deps) {
|
|
33
|
+
const w = d.weight ?? 1;
|
|
34
|
+
if (!Number.isFinite(w) || w < 0)
|
|
35
|
+
throw new Error(`invalid dependency weight ${w} (${d.from} -> ${d.to})`);
|
|
36
|
+
const a = add(String(d.from));
|
|
37
|
+
const b = add(String(d.to));
|
|
38
|
+
if (a === b || w === 0)
|
|
39
|
+
continue;
|
|
40
|
+
const key = a < b ? `${a},${b}` : `${b},${a}`;
|
|
41
|
+
weights.set(key, (weights.get(key) ?? 0) + w);
|
|
42
|
+
}
|
|
43
|
+
const edges = [];
|
|
44
|
+
for (const [key, w] of weights) {
|
|
45
|
+
const [a, b] = key.split(',').map(Number);
|
|
46
|
+
edges.push([a, b, w]);
|
|
47
|
+
}
|
|
48
|
+
return { names, edges };
|
|
49
|
+
}
|
|
50
|
+
/** Exact global min cut (Stoer-Wagner) over vertices that appear in `edges`. */
|
|
51
|
+
function stoerWagner(n, edges) {
|
|
52
|
+
const W = Array.from({ length: n }, () => new Array(n).fill(0));
|
|
53
|
+
for (const [a, b, w] of edges) {
|
|
54
|
+
W[a][b] += w;
|
|
55
|
+
W[b][a] += w;
|
|
56
|
+
}
|
|
57
|
+
const members = Array.from({ length: n }, (_, i) => [i]);
|
|
58
|
+
let active = Array.from({ length: n }, (_, i) => i);
|
|
59
|
+
let best = Infinity;
|
|
60
|
+
let bestSide = [];
|
|
61
|
+
while (active.length > 1) {
|
|
62
|
+
const added = new Set();
|
|
63
|
+
const conn = new Map(active.map((v) => [v, 0]));
|
|
64
|
+
let prev = -1;
|
|
65
|
+
let last = -1;
|
|
66
|
+
for (let step = 0; step < active.length; step++) {
|
|
67
|
+
let pick = -1;
|
|
68
|
+
for (const v of active) {
|
|
69
|
+
if (!added.has(v) && (pick === -1 || conn.get(v) > conn.get(pick)))
|
|
70
|
+
pick = v;
|
|
71
|
+
}
|
|
72
|
+
added.add(pick);
|
|
73
|
+
prev = last;
|
|
74
|
+
last = pick;
|
|
75
|
+
if (step === active.length - 1) {
|
|
76
|
+
const cutOfPhase = conn.get(pick);
|
|
77
|
+
if (cutOfPhase < best) {
|
|
78
|
+
best = cutOfPhase;
|
|
79
|
+
bestSide = [...members[pick]];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const v of active)
|
|
83
|
+
if (!added.has(v))
|
|
84
|
+
conn.set(v, conn.get(v) + W[pick][v]);
|
|
85
|
+
}
|
|
86
|
+
// merge `last` into `prev`
|
|
87
|
+
for (const v of active) {
|
|
88
|
+
W[prev][v] += W[last][v];
|
|
89
|
+
W[v][prev] = W[prev][v];
|
|
90
|
+
}
|
|
91
|
+
members[prev].push(...members[last]);
|
|
92
|
+
active = active.filter((v) => v !== last);
|
|
93
|
+
}
|
|
94
|
+
return { cut: best === Infinity ? 0 : best, side: new Set(bestSide) };
|
|
95
|
+
}
|
|
96
|
+
function components(n, edges) {
|
|
97
|
+
const parent = Array.from({ length: n }, (_, i) => i);
|
|
98
|
+
const find = (x) => (parent[x] === x ? x : (parent[x] = find(parent[x])));
|
|
99
|
+
for (const [a, b] of edges)
|
|
100
|
+
parent[find(a)] = find(b);
|
|
101
|
+
const groups = new Map();
|
|
102
|
+
for (let i = 0; i < n; i++) {
|
|
103
|
+
const r = find(i);
|
|
104
|
+
if (!groups.has(r))
|
|
105
|
+
groups.set(r, []);
|
|
106
|
+
groups.get(r).push(i);
|
|
107
|
+
}
|
|
108
|
+
return [...groups.values()];
|
|
109
|
+
}
|
|
110
|
+
export async function partitionTaskGraph(tasks, dependencies, options = {}) {
|
|
111
|
+
const { names, edges } = normalize(tasks, dependencies);
|
|
112
|
+
const touched = new Set();
|
|
113
|
+
for (const [a, b] of edges) {
|
|
114
|
+
touched.add(a);
|
|
115
|
+
touched.add(b);
|
|
116
|
+
}
|
|
117
|
+
const isolated = names.filter((_, i) => !touched.has(i));
|
|
118
|
+
const toEdges = (list) => list.map((e) => ({ from: names[e.u], to: names[e.v], weight: e.weight }));
|
|
119
|
+
if (touched.size < 2) {
|
|
120
|
+
return { groups: [names.filter((_, i) => touched.has(i)), []], isolated, cutWeight: 0, cutEdges: [], engine: 'builtin' };
|
|
121
|
+
}
|
|
122
|
+
if (options.engine !== 'builtin') {
|
|
123
|
+
const mod = await importOptional('@ruvector/mincut-wasm');
|
|
124
|
+
if (mod?.WasmMinCut) {
|
|
125
|
+
const g = mod.WasmMinCut.fromEdges(edges);
|
|
126
|
+
try {
|
|
127
|
+
const p = g.partition();
|
|
128
|
+
return {
|
|
129
|
+
groups: [p.s.map((i) => names[i]), p.t.map((i) => names[i])],
|
|
130
|
+
isolated,
|
|
131
|
+
cutWeight: g.minCutValue(),
|
|
132
|
+
cutEdges: toEdges(g.cutEdges()),
|
|
133
|
+
engine: 'mincut-wasm',
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
g.free?.();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Built-in: disconnected graphs cut at weight 0 between components.
|
|
142
|
+
const comps = components(names.length, edges).filter((c) => c.some((v) => touched.has(v)));
|
|
143
|
+
let side;
|
|
144
|
+
let cut;
|
|
145
|
+
if (comps.length > 1) {
|
|
146
|
+
side = new Set(comps[0]);
|
|
147
|
+
cut = 0;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
if (touched.size > BUILTIN_MAX_TASKS) {
|
|
151
|
+
throw new Error(`built-in min cut is limited to ${BUILTIN_MAX_TASKS} connected tasks; install @ruvector/mincut-wasm for larger graphs`);
|
|
152
|
+
}
|
|
153
|
+
// Re-index the touched vertices densely for Stoer-Wagner.
|
|
154
|
+
const order = [...touched];
|
|
155
|
+
const local = new Map(order.map((v, i) => [v, i]));
|
|
156
|
+
const r = stoerWagner(order.length, edges.map(([a, b, w]) => [local.get(a), local.get(b), w]));
|
|
157
|
+
side = new Set([...r.side].map((i) => order[i]));
|
|
158
|
+
cut = r.cut;
|
|
159
|
+
}
|
|
160
|
+
const s = [...touched].filter((v) => side.has(v));
|
|
161
|
+
const t = [...touched].filter((v) => !side.has(v));
|
|
162
|
+
const crossing = edges
|
|
163
|
+
.filter(([a, b]) => side.has(a) !== side.has(b))
|
|
164
|
+
.map(([u, v, weight]) => ({ u, v, weight }));
|
|
165
|
+
return {
|
|
166
|
+
groups: [s.map((i) => names[i]), t.map((i) => names[i])],
|
|
167
|
+
isolated,
|
|
168
|
+
cutWeight: cut,
|
|
169
|
+
cutEdges: toEdges(crossing),
|
|
170
|
+
engine: 'builtin',
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=task-partition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-partition.js","sourceRoot":"","sources":["../../src/integrations/task-partition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAmB/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAarC,SAAS,SAAS,CAAC,KAAe,EAAE,IAAsB;IACxD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE;QACxB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;QACD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAE,CAAC;IACrB,CAAC,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC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,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC/C,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,QAAQ;QACR,SAAS,EAAE,GAAG;QACd,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC;QAC3B,MAAM,EAAE,SAAS;KAClB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Split a task-dependency graph into two groups with the least coupling.\n *\n * A global minimum cut over the (undirected, weighted) dependency graph finds\n * the split that severs the fewest/lightest dependencies — the natural seam for\n * handing work to two agent teams so they block on each other least.\n *\n * Engine: `@ruvector/mincut-wasm` (optionalDependency) when installed; a\n * built-in Stoer-Wagner implementation otherwise (O(n^3), capped at\n * BUILTIN_MAX_TASKS). Both are exact, so they agree on the cut weight.\n *\n * A global min cut can be lopsided (one loosely-attached task vs the rest):\n * that is the correct answer to \"where is the weakest seam\", not a balance\n * guarantee. Tasks with no dependencies have nothing to cut and are reported\n * in `isolated` rather than forced into a side.\n */\n\nimport { importOptional } from './optional.js';\n\nexport interface TaskDependency {\n from: string;\n to: string;\n /** Coupling strength, default 1. Must be finite and >= 0. */\n weight?: number;\n}\n\nexport interface TaskPartition {\n groups: [string[], string[]];\n /** Tasks that have no dependencies at all. */\n isolated: string[];\n /** Sum of weights of the dependencies crossing between the groups. */\n cutWeight: number;\n cutEdges: Array<{ from: string; to: string; weight: number }>;\n engine: 'mincut-wasm' | 'builtin';\n}\n\nexport const BUILTIN_MAX_TASKS = 400;\n\ninterface MinCutModule {\n WasmMinCut: {\n fromEdges(edges: Array<[number, number, number]>): {\n minCutValue(): number;\n partition(): { s: number[]; t: number[] };\n cutEdges(): Array<{ u: number; v: number; weight: number }>;\n free?(): void;\n };\n };\n}\n\nfunction normalize(tasks: string[], deps: TaskDependency[]) {\n const ids = new Map<string, number>();\n const names: string[] = [];\n const add = (t: string) => {\n if (!ids.has(t)) {\n ids.set(t, names.length);\n names.push(t);\n }\n return ids.get(t)!;\n };\n for (const t of tasks) add(String(t));\n const weights = new Map<string, number>();\n for (const d of deps) {\n const w = d.weight ?? 1;\n if (!Number.isFinite(w) || w < 0) throw new Error(`invalid dependency weight ${w} (${d.from} -> ${d.to})`);\n const a = add(String(d.from));\n const b = add(String(d.to));\n if (a === b || w === 0) continue;\n const key = a < b ? `${a},${b}` : `${b},${a}`;\n weights.set(key, (weights.get(key) ?? 0) + w);\n }\n const edges: Array<[number, number, number]> = [];\n for (const [key, w] of weights) {\n const [a, b] = key.split(',').map(Number);\n edges.push([a, b, w]);\n }\n return { names, edges };\n}\n\n/** Exact global min cut (Stoer-Wagner) over vertices that appear in `edges`. */\nfunction stoerWagner(n: number, edges: Array<[number, number, number]>): { cut: number; side: Set<number> } {\n const W: number[][] = Array.from({ length: n }, () => new Array(n).fill(0));\n for (const [a, b, w] of edges) {\n W[a][b] += w;\n W[b][a] += w;\n }\n const members: number[][] = Array.from({ length: n }, (_, i) => [i]);\n let active = Array.from({ length: n }, (_, i) => i);\n let best = Infinity;\n let bestSide: number[] = [];\n while (active.length > 1) {\n const added = new Set<number>();\n const conn = new Map<number, number>(active.map((v) => [v, 0]));\n let prev = -1;\n let last = -1;\n for (let step = 0; step < active.length; step++) {\n let pick = -1;\n for (const v of active) {\n if (!added.has(v) && (pick === -1 || conn.get(v)! > conn.get(pick)!)) pick = v;\n }\n added.add(pick);\n prev = last;\n last = pick;\n if (step === active.length - 1) {\n const cutOfPhase = conn.get(pick)!;\n if (cutOfPhase < best) {\n best = cutOfPhase;\n bestSide = [...members[pick]];\n }\n }\n for (const v of active) if (!added.has(v)) conn.set(v, conn.get(v)! + W[pick][v]);\n }\n // merge `last` into `prev`\n for (const v of active) {\n W[prev][v] += W[last][v];\n W[v][prev] = W[prev][v];\n }\n members[prev].push(...members[last]);\n active = active.filter((v) => v !== last);\n }\n return { cut: best === Infinity ? 0 : best, side: new Set(bestSide) };\n}\n\nfunction components(n: number, edges: Array<[number, number, number]>): number[][] {\n const parent = Array.from({ length: n }, (_, i) => i);\n const find = (x: number): number => (parent[x] === x ? x : (parent[x] = find(parent[x])));\n for (const [a, b] of edges) parent[find(a)] = find(b);\n const groups = new Map<number, number[]>();\n for (let i = 0; i < n; i++) {\n const r = find(i);\n if (!groups.has(r)) groups.set(r, []);\n groups.get(r)!.push(i);\n }\n return [...groups.values()];\n}\n\nexport async function partitionTaskGraph(\n tasks: string[],\n dependencies: TaskDependency[],\n options: { engine?: 'auto' | 'builtin' } = {},\n): Promise<TaskPartition> {\n const { names, edges } = normalize(tasks, dependencies);\n const touched = new Set<number>();\n for (const [a, b] of edges) {\n touched.add(a);\n touched.add(b);\n }\n const isolated = names.filter((_, i) => !touched.has(i));\n const toEdges = (list: Array<{ u: number; v: number; weight: number }>) =>\n list.map((e) => ({ from: names[e.u], to: names[e.v], weight: e.weight }));\n\n if (touched.size < 2) {\n return { groups: [names.filter((_, i) => touched.has(i)), []], isolated, cutWeight: 0, cutEdges: [], engine: 'builtin' };\n }\n\n if (options.engine !== 'builtin') {\n const mod = await importOptional<MinCutModule>('@ruvector/mincut-wasm');\n if (mod?.WasmMinCut) {\n const g = mod.WasmMinCut.fromEdges(edges);\n try {\n const p = g.partition();\n return {\n groups: [p.s.map((i) => names[i]), p.t.map((i) => names[i])],\n isolated,\n cutWeight: g.minCutValue(),\n cutEdges: toEdges(g.cutEdges()),\n engine: 'mincut-wasm',\n };\n } finally {\n g.free?.();\n }\n }\n }\n\n // Built-in: disconnected graphs cut at weight 0 between components.\n const comps = components(names.length, edges).filter((c) => c.some((v) => touched.has(v)));\n let side: Set<number>;\n let cut: number;\n if (comps.length > 1) {\n side = new Set(comps[0]);\n cut = 0;\n } else {\n if (touched.size > BUILTIN_MAX_TASKS) {\n throw new Error(\n `built-in min cut is limited to ${BUILTIN_MAX_TASKS} connected tasks; install @ruvector/mincut-wasm for larger graphs`,\n );\n }\n // Re-index the touched vertices densely for Stoer-Wagner.\n const order = [...touched];\n const local = new Map(order.map((v, i) => [v, i]));\n const r = stoerWagner(order.length, edges.map(([a, b, w]) => [local.get(a)!, local.get(b)!, w] as [number, number, number]));\n side = new Set([...r.side].map((i) => order[i]));\n cut = r.cut;\n }\n const s = [...touched].filter((v) => side.has(v));\n const t = [...touched].filter((v) => !side.has(v));\n const crossing = edges\n .filter(([a, b]) => side.has(a) !== side.has(b))\n .map(([u, v, weight]) => ({ u, v, weight }));\n return {\n groups: [s.map((i) => names[i]), t.map((i) => names[i])],\n isolated,\n cutWeight: cut,\n cutEdges: toEdges(crossing),\n engine: 'builtin',\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-policy.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-policy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-policy.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-policy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;AAazE,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAMrE;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/D,OAAO,CAQT;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAA;CAAE,EACzF,MAAM,EAAE,CAAC,EACT,OAAO,EAAE;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/D,CAAC,CAOH"}
|
package/dist/mcp/mcp-policy.js
CHANGED
|
@@ -3,6 +3,8 @@ const READONLY = [
|
|
|
3
3
|
/^agentdb_(stats|pattern_search|pattern_stats)$/,
|
|
4
4
|
/^harness_(capabilities|manifest|verify)$/,
|
|
5
5
|
/_(stats|get_profile|list_profiles|benchmark)$/,
|
|
6
|
+
// Ecosystem tools: pure computations over their arguments, no side effects.
|
|
7
|
+
/^(ecosystem_status|swarm_partition_tasks|sublinear_solve|sublinear_pagerank|prompt_injection_scan)$/,
|
|
6
8
|
];
|
|
7
9
|
const RETRIEVAL = [...READONLY, /search$/, /context$/];
|
|
8
10
|
const LEARNING = [...RETRIEVAL, /^agentic_flow_agent$/, /^agentdb_pattern_store$/, /^sona_/];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-policy.js","sourceRoot":"","sources":["../../src/mcp/mcp-policy.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG;IACf,0DAA0D;IAC1D,gDAAgD;IAChD,0CAA0C;IAC1C,+CAA+C;
|
|
1
|
+
{"version":3,"file":"mcp-policy.js","sourceRoot":"","sources":["../../src/mcp/mcp-policy.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG;IACf,0DAA0D;IAC1D,gDAAgD;IAChD,0CAA0C;IAC1C,+CAA+C;IAC/C,4EAA4E;IAC5E,qGAAqG;CACtG,CAAC;AACF,MAAM,SAAS,GAAG,CAAC,GAAG,QAAQ,EAAE,SAAS,EAAE,UAAU,CAA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,EAAE,OAAO,CAAC;YAAE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/D,OAAO,SAAS,CAAC;IACnB,CAAC,CAAiB,CAAC;IACnB,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["export type McpProfile = 'readonly' | 'retrieval' | 'learning' | 'admin';\n\nconst READONLY = [\n /^agentic_flow_(list|list_all|agent_info|check_conflicts)/,\n /^agentdb_(stats|pattern_search|pattern_stats)$/,\n /^harness_(capabilities|manifest|verify)$/,\n /_(stats|get_profile|list_profiles|benchmark)$/,\n // Ecosystem tools: pure computations over their arguments, no side effects.\n /^(ecosystem_status|swarm_partition_tasks|sublinear_solve|sublinear_pagerank|prompt_injection_scan)$/,\n];\nconst RETRIEVAL = [...READONLY, /search$/, /context$/];\nconst LEARNING = [...RETRIEVAL, /^agentic_flow_agent$/, /^agentdb_pattern_store$/, /^sona_/];\n\nexport function parseMcpProfile(value: string | undefined): McpProfile {\n const profile = value ?? 'readonly';\n if (!['readonly', 'retrieval', 'learning', 'admin'].includes(profile)) {\n throw new Error(`invalid MCP profile: ${profile}`);\n }\n return profile as McpProfile;\n}\n\nexport function isMcpToolAllowed(\n name: string,\n options: { profile: McpProfile; allowDarwinExecution?: boolean },\n): boolean {\n if (name === 'harness_repair') {\n return options.profile === 'admin' && options.allowDarwinExecution === true;\n }\n if (options.profile === 'admin') return true;\n const rules = options.profile === 'learning' ? LEARNING :\n options.profile === 'retrieval' ? RETRIEVAL : READONLY;\n return rules.some((rule) => rule.test(name));\n}\n\nexport function installMcpPolicy<T extends { addTool: (tool: { name: string }) => unknown }>(\n server: T,\n options: { profile: McpProfile; allowDarwinExecution?: boolean },\n): T {\n const addTool = server.addTool.bind(server);\n server.addTool = ((tool: { name: string }) => {\n if (isMcpToolAllowed(tool.name, options)) return addTool(tool);\n return undefined;\n }) as T['addTool'];\n return server;\n}\n"]}
|
|
@@ -5,6 +5,8 @@ import { FastMCP } from 'fastmcp';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { execFileSync } from 'child_process';
|
|
7
7
|
import { registerHarnessTools } from './tools/harness-tools.js';
|
|
8
|
+
import { registerEcosystemTools, ECOSYSTEM_TOOL_NAMES } from './tools/ecosystem-tools.js';
|
|
9
|
+
import { applyAgentBoosterEdit } from '../integrations/agent-booster.js';
|
|
8
10
|
import { installMcpPolicy, parseMcpProfile } from './mcp-policy.js';
|
|
9
11
|
import { assertCategoryPath, resolveInsideCwd } from '../utils/path-safety.js';
|
|
10
12
|
// Security: All shell-outs use execFileSync with argv arrays (shell: false) to
|
|
@@ -39,6 +41,9 @@ console.error(`🔐 MCP capability profile: ${mcpProfile}`);
|
|
|
39
41
|
// ADR-075: harness evolution/repair + provenance tools (harness_repair,
|
|
40
42
|
// harness_manifest, harness_verify).
|
|
41
43
|
registerHarnessTools(server);
|
|
44
|
+
// Ecosystem tools backed by optional ruvnet packages (aidefence, mincut-wasm,
|
|
45
|
+
// sublinear-time-solver); each has a built-in fallback. Pure computations.
|
|
46
|
+
registerEcosystemTools(server);
|
|
42
47
|
// Tool: Run agentic-flow agent
|
|
43
48
|
server.addTool({
|
|
44
49
|
name: 'agentic_flow_agent',
|
|
@@ -352,15 +357,9 @@ server.addTool({
|
|
|
352
357
|
};
|
|
353
358
|
language = langMap[ext] || 'javascript';
|
|
354
359
|
}
|
|
355
|
-
// Apply edit
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
encoding: 'utf-8',
|
|
359
|
-
input: JSON.stringify({ code: originalCode, edit: code_edit }),
|
|
360
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
361
|
-
timeout: 30000 // Allow time for npx to download package on first run
|
|
362
|
-
});
|
|
363
|
-
const parsed = JSON.parse(result);
|
|
360
|
+
// Apply edit in-process via the optional agent-booster package; falls back
|
|
361
|
+
// to the pinned agent-booster@0.2.2 CLI through npx when it is not installed.
|
|
362
|
+
const parsed = await applyAgentBoosterEdit(originalCode, code_edit, language, { npxTimeoutMs: 30000 });
|
|
364
363
|
if (parsed.success && parsed.confidence >= 0.7) {
|
|
365
364
|
// High confidence - use Agent Booster result
|
|
366
365
|
fs.writeFileSync(safePath, parsed.output);
|
|
@@ -437,14 +436,7 @@ server.addTool({
|
|
|
437
436
|
language = langMap[ext] || 'javascript';
|
|
438
437
|
}
|
|
439
438
|
// Apply edit
|
|
440
|
-
const
|
|
441
|
-
...NPX_EXEC_OPTS,
|
|
442
|
-
encoding: 'utf-8',
|
|
443
|
-
input: JSON.stringify({ code: originalCode, edit: edit.code_edit }),
|
|
444
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
445
|
-
timeout: 5000
|
|
446
|
-
});
|
|
447
|
-
const parsed = JSON.parse(result);
|
|
439
|
+
const parsed = await applyAgentBoosterEdit(originalCode, edit.code_edit, language, { npxTimeoutMs: 5000 });
|
|
448
440
|
totalLatency += parsed.latency;
|
|
449
441
|
if (parsed.success && parsed.confidence >= 0.7) {
|
|
450
442
|
fs.writeFileSync(safePath, parsed.output);
|
|
@@ -528,14 +520,7 @@ server.addTool({
|
|
|
528
520
|
};
|
|
529
521
|
language = langMap[ext] || 'javascript';
|
|
530
522
|
}
|
|
531
|
-
const
|
|
532
|
-
...NPX_EXEC_OPTS,
|
|
533
|
-
encoding: 'utf-8',
|
|
534
|
-
input: JSON.stringify({ code: originalCode, edit: edit.code_edit }),
|
|
535
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
536
|
-
timeout: 5000
|
|
537
|
-
});
|
|
538
|
-
const parsed = JSON.parse(result);
|
|
523
|
+
const parsed = await applyAgentBoosterEdit(originalCode, edit.code_edit, language, { npxTimeoutMs: 5000 });
|
|
539
524
|
totalLatency += parsed.latency;
|
|
540
525
|
if (parsed.success && parsed.confidence >= 0.7) {
|
|
541
526
|
fs.writeFileSync(safePath, parsed.output);
|
|
@@ -761,7 +746,7 @@ server.addTool({
|
|
|
761
746
|
}
|
|
762
747
|
}
|
|
763
748
|
});
|
|
764
|
-
console.error(
|
|
749
|
+
console.error(`✅ Tools (subject to the ${mcpProfile} profile): 7 agentic-flow + 3 agent-booster + 5 agentdb + harness + ${ECOSYSTEM_TOOL_NAMES.length} ecosystem:`);
|
|
765
750
|
console.error(' • agentic_flow_agent (execute agent with 13 parameters)');
|
|
766
751
|
console.error(' • agentic_flow_list_agents (list 66+ agents)');
|
|
767
752
|
console.error(' • agentic_flow_create_agent (create custom agent)');
|
|
@@ -777,6 +762,7 @@ console.error(' • agentdb_pattern_store (store reasoning patterns) 🧠 NEW'
|
|
|
777
762
|
console.error(' • agentdb_pattern_search (search similar patterns) 🧠 NEW');
|
|
778
763
|
console.error(' • agentdb_pattern_stats (pattern analytics) 🧠 NEW');
|
|
779
764
|
console.error(' • agentdb_clear_cache (clear query cache) 🧠 NEW');
|
|
765
|
+
console.error(` • ${ECOSYSTEM_TOOL_NAMES.join(', ')}`);
|
|
780
766
|
console.error('🔌 Starting stdio transport...');
|
|
781
767
|
server.start({ transportType: 'stdio' }).then(() => {
|
|
782
768
|
console.error('✅ Agentic-Flow MCP server running on stdio');
|