claude-flow 3.5.24 → 3.5.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.5.24",
3
+ "version": "3.5.26",
4
4
  "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -54,6 +54,7 @@
54
54
  "v3:security": "npm run security:audit && npm run security:test"
55
55
  },
56
56
  "dependencies": {
57
+ "@ruvector/ruvllm-wasm": "^2.0.0",
57
58
  "semver": "^7.6.0",
58
59
  "zod": "^3.22.4"
59
60
  },
@@ -61,6 +61,8 @@ const commandLoaders = {
61
61
  guidance: () => import('./guidance.js'),
62
62
  // RVFA Appliance Management
63
63
  appliance: () => import('./appliance.js'),
64
+ 'appliance-advanced': () => import('./appliance-advanced.js'),
65
+ 'transfer-store': () => import('./transfer-store.js'),
64
66
  };
65
67
  // Cache for loaded commands
66
68
  const loadedCommands = new Map();
@@ -10,10 +10,10 @@ const browserSessions = new Map();
10
10
  * Execute agent-browser CLI command
11
11
  */
12
12
  async function execBrowserCommand(args, session = 'default') {
13
- const { execSync } = await import('child_process');
13
+ const { execFileSync } = await import('child_process');
14
14
  try {
15
15
  const fullArgs = ['--session', session, '--json', ...args];
16
- const result = execSync(`agent-browser ${fullArgs.join(' ')}`, {
16
+ const result = execFileSync('agent-browser', fullArgs, {
17
17
  encoding: 'utf-8',
18
18
  timeout: 30000,
19
19
  });
@@ -30,7 +30,7 @@ function getConfigPath() {
30
30
  function ensureConfigDir() {
31
31
  const dir = getConfigDir();
32
32
  if (!existsSync(dir)) {
33
- mkdirSync(dir, { recursive: true });
33
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
34
34
  }
35
35
  }
36
36
  function loadConfigStore() {
@@ -80,7 +80,16 @@ function filterDangerousKeys(obj) {
80
80
  return filtered;
81
81
  }
82
82
  function setNestedValue(obj, key, value) {
83
+ const MAX_NESTING_DEPTH = 10;
83
84
  const parts = key.split('.');
85
+ if (parts.length > MAX_NESTING_DEPTH) {
86
+ throw new Error(`Key exceeds maximum nesting depth of ${MAX_NESTING_DEPTH}`);
87
+ }
88
+ for (const part of parts) {
89
+ if (DANGEROUS_KEYS.has(part)) {
90
+ throw new Error(`Dangerous key segment rejected: ${part}`);
91
+ }
92
+ }
84
93
  let current = obj;
85
94
  for (let i = 0; i < parts.length - 1; i++) {
86
95
  const part = parts[i];
@@ -20,4 +20,6 @@ export { transferTools } from './transfer-tools.js';
20
20
  export { securityTools } from './security-tools.js';
21
21
  export { embeddingsTools } from './embeddings-tools.js';
22
22
  export { claimsTools } from './claims-tools.js';
23
+ export { wasmAgentTools } from './wasm-agent-tools.js';
24
+ export { ruvllmWasmTools } from './ruvllm-tools.js';
23
25
  //# sourceMappingURL=index.d.ts.map
@@ -19,4 +19,6 @@ export { transferTools } from './transfer-tools.js';
19
19
  export { securityTools } from './security-tools.js';
20
20
  export { embeddingsTools } from './embeddings-tools.js';
21
21
  export { claimsTools } from './claims-tools.js';
22
+ export { wasmAgentTools } from './wasm-agent-tools.js';
23
+ export { ruvllmWasmTools } from './ruvllm-tools.js';
22
24
  //# sourceMappingURL=index.js.map
@@ -213,6 +213,7 @@ export const memoryTools = [
213
213
  const { getEntry } = await getMemoryFunctions();
214
214
  const key = input.key;
215
215
  const namespace = input.namespace || 'default';
216
+ validateMemoryInput(key);
216
217
  try {
217
218
  const result = await getEntry({ key, namespace });
218
219
  if (result.found && result.entry) {
@@ -337,6 +338,7 @@ export const memoryTools = [
337
338
  const { deleteEntry } = await getMemoryFunctions();
338
339
  const key = input.key;
339
340
  const namespace = input.namespace || 'default';
341
+ validateMemoryInput(key);
340
342
  try {
341
343
  const result = await deleteEntry({ key, namespace });
342
344
  return {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * RuVector LLM WASM MCP Tools
3
+ *
4
+ * Exposes @ruvector/ruvllm-wasm operations via MCP protocol.
5
+ * All tools gracefully degrade when the WASM package is not installed.
6
+ */
7
+ import type { MCPTool } from './types.js';
8
+ export declare const ruvllmWasmTools: MCPTool[];
9
+ //# sourceMappingURL=ruvllm-tools.d.ts.map
@@ -0,0 +1,283 @@
1
+ /**
2
+ * RuVector LLM WASM MCP Tools
3
+ *
4
+ * Exposes @ruvector/ruvllm-wasm operations via MCP protocol.
5
+ * All tools gracefully degrade when the WASM package is not installed.
6
+ */
7
+ async function loadRuvllmWasm() {
8
+ return import('../ruvector/ruvllm-wasm.js');
9
+ }
10
+ export const ruvllmWasmTools = [
11
+ {
12
+ name: 'ruvllm_status',
13
+ description: 'Get ruvllm-wasm availability and initialization status.',
14
+ inputSchema: { type: 'object', properties: {} },
15
+ handler: async () => {
16
+ try {
17
+ const mod = await loadRuvllmWasm();
18
+ const status = await mod.getRuvllmStatus();
19
+ return { content: [{ type: 'text', text: JSON.stringify(status, null, 2) }] };
20
+ }
21
+ catch (err) {
22
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
23
+ }
24
+ },
25
+ },
26
+ {
27
+ name: 'ruvllm_hnsw_create',
28
+ description: 'Create a WASM HNSW router for semantic pattern routing. Max ~11 patterns (v2.0.1 limit).',
29
+ inputSchema: {
30
+ type: 'object',
31
+ properties: {
32
+ dimensions: { type: 'number', description: 'Embedding dimensions (e.g., 64, 128, 384)' },
33
+ maxPatterns: { type: 'number', description: 'Max patterns capacity (limit ~11 in v2.0.1)' },
34
+ efSearch: { type: 'number', description: 'HNSW ef search parameter (higher = more accurate, slower)' },
35
+ },
36
+ required: ['dimensions', 'maxPatterns'],
37
+ },
38
+ handler: async (args) => {
39
+ try {
40
+ const mod = await loadRuvllmWasm();
41
+ const router = await mod.createHnswRouter({
42
+ dimensions: args.dimensions,
43
+ maxPatterns: args.maxPatterns,
44
+ efSearch: args.efSearch,
45
+ });
46
+ // Store router in module-level registry
47
+ const id = `hnsw-${Date.now().toString(36)}`;
48
+ hnswRouters.set(id, router);
49
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, routerId: id, dimensions: args.dimensions, maxPatterns: args.maxPatterns }) }] };
50
+ }
51
+ catch (err) {
52
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
53
+ }
54
+ },
55
+ },
56
+ {
57
+ name: 'ruvllm_hnsw_add',
58
+ description: 'Add a pattern to an HNSW router. Embedding must match router dimensions.',
59
+ inputSchema: {
60
+ type: 'object',
61
+ properties: {
62
+ routerId: { type: 'string', description: 'HNSW router ID from ruvllm_hnsw_create' },
63
+ name: { type: 'string', description: 'Pattern name/label' },
64
+ embedding: { type: 'array', description: 'Float array embedding vector' },
65
+ metadata: { type: 'object', description: 'Optional metadata object' },
66
+ },
67
+ required: ['routerId', 'name', 'embedding'],
68
+ },
69
+ handler: async (args) => {
70
+ try {
71
+ const router = hnswRouters.get(args.routerId);
72
+ if (!router)
73
+ return { content: [{ type: 'text', text: JSON.stringify({ error: `Router not found: ${args.routerId}` }) }], isError: true };
74
+ const embedding = new Float32Array(args.embedding);
75
+ const ok = router.addPattern({
76
+ name: args.name,
77
+ embedding,
78
+ metadata: args.metadata,
79
+ });
80
+ return { content: [{ type: 'text', text: JSON.stringify({ success: ok, patternCount: router.patternCount() }) }] };
81
+ }
82
+ catch (err) {
83
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
84
+ }
85
+ },
86
+ },
87
+ {
88
+ name: 'ruvllm_hnsw_route',
89
+ description: 'Route a query embedding to nearest patterns in HNSW index.',
90
+ inputSchema: {
91
+ type: 'object',
92
+ properties: {
93
+ routerId: { type: 'string', description: 'HNSW router ID' },
94
+ query: { type: 'array', description: 'Query embedding vector' },
95
+ k: { type: 'number', description: 'Number of nearest neighbors (default: 3)' },
96
+ },
97
+ required: ['routerId', 'query'],
98
+ },
99
+ handler: async (args) => {
100
+ try {
101
+ const router = hnswRouters.get(args.routerId);
102
+ if (!router)
103
+ return { content: [{ type: 'text', text: JSON.stringify({ error: `Router not found: ${args.routerId}` }) }], isError: true };
104
+ const query = new Float32Array(args.query);
105
+ const results = router.route(query, args.k ?? 3);
106
+ return { content: [{ type: 'text', text: JSON.stringify({ results }) }] };
107
+ }
108
+ catch (err) {
109
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
110
+ }
111
+ },
112
+ },
113
+ {
114
+ name: 'ruvllm_sona_create',
115
+ description: 'Create a SONA instant adaptation loop (<1ms adaptation cycles).',
116
+ inputSchema: {
117
+ type: 'object',
118
+ properties: {
119
+ hiddenDim: { type: 'number', description: 'Hidden dimension (default: 64)' },
120
+ learningRate: { type: 'number', description: 'Learning rate (default: 0.01)' },
121
+ patternCapacity: { type: 'number', description: 'Max stored patterns' },
122
+ },
123
+ },
124
+ handler: async (args) => {
125
+ try {
126
+ const mod = await loadRuvllmWasm();
127
+ const sona = await mod.createSonaInstant({
128
+ hiddenDim: args.hiddenDim,
129
+ learningRate: args.learningRate,
130
+ patternCapacity: args.patternCapacity,
131
+ });
132
+ const id = `sona-${Date.now().toString(36)}`;
133
+ sonaInstances.set(id, sona);
134
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, sonaId: id }) }] };
135
+ }
136
+ catch (err) {
137
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
138
+ }
139
+ },
140
+ },
141
+ {
142
+ name: 'ruvllm_sona_adapt',
143
+ description: 'Run SONA instant adaptation with a quality signal.',
144
+ inputSchema: {
145
+ type: 'object',
146
+ properties: {
147
+ sonaId: { type: 'string', description: 'SONA instance ID' },
148
+ quality: { type: 'number', description: 'Quality signal (0.0-1.0)' },
149
+ },
150
+ required: ['sonaId', 'quality'],
151
+ },
152
+ handler: async (args) => {
153
+ try {
154
+ const sona = sonaInstances.get(args.sonaId);
155
+ if (!sona)
156
+ return { content: [{ type: 'text', text: JSON.stringify({ error: `SONA not found: ${args.sonaId}` }) }], isError: true };
157
+ sona.adapt(args.quality);
158
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, stats: sona.stats() }) }] };
159
+ }
160
+ catch (err) {
161
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
162
+ }
163
+ },
164
+ },
165
+ {
166
+ name: 'ruvllm_microlora_create',
167
+ description: 'Create a MicroLoRA adapter (ultra-lightweight LoRA, ranks 1-4).',
168
+ inputSchema: {
169
+ type: 'object',
170
+ properties: {
171
+ inputDim: { type: 'number', description: 'Input dimension' },
172
+ outputDim: { type: 'number', description: 'Output dimension' },
173
+ rank: { type: 'number', description: 'LoRA rank (1-4, default: 2)' },
174
+ alpha: { type: 'number', description: 'LoRA alpha scaling (default: 1.0)' },
175
+ },
176
+ required: ['inputDim', 'outputDim'],
177
+ },
178
+ handler: async (args) => {
179
+ try {
180
+ const mod = await loadRuvllmWasm();
181
+ const lora = await mod.createMicroLora({
182
+ inputDim: args.inputDim,
183
+ outputDim: args.outputDim,
184
+ rank: args.rank,
185
+ alpha: args.alpha,
186
+ });
187
+ const id = `lora-${Date.now().toString(36)}`;
188
+ loraInstances.set(id, lora);
189
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, loraId: id }) }] };
190
+ }
191
+ catch (err) {
192
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
193
+ }
194
+ },
195
+ },
196
+ {
197
+ name: 'ruvllm_microlora_adapt',
198
+ description: 'Adapt MicroLoRA weights with quality feedback.',
199
+ inputSchema: {
200
+ type: 'object',
201
+ properties: {
202
+ loraId: { type: 'string', description: 'MicroLoRA instance ID' },
203
+ quality: { type: 'number', description: 'Quality signal (0.0-1.0)' },
204
+ learningRate: { type: 'number', description: 'Learning rate (default: 0.01)' },
205
+ success: { type: 'boolean', description: 'Whether the adaptation was successful (default: true)' },
206
+ },
207
+ required: ['loraId', 'quality'],
208
+ },
209
+ handler: async (args) => {
210
+ try {
211
+ const lora = loraInstances.get(args.loraId);
212
+ if (!lora)
213
+ return { content: [{ type: 'text', text: JSON.stringify({ error: `MicroLoRA not found: ${args.loraId}` }) }], isError: true };
214
+ lora.adapt(args.quality, args.learningRate, args.success);
215
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, stats: lora.stats() }) }] };
216
+ }
217
+ catch (err) {
218
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
219
+ }
220
+ },
221
+ },
222
+ {
223
+ name: 'ruvllm_chat_format',
224
+ description: 'Format chat messages using a template (llama3, mistral, chatml, phi, gemma, or auto-detect).',
225
+ inputSchema: {
226
+ type: 'object',
227
+ properties: {
228
+ messages: {
229
+ type: 'array',
230
+ description: 'Array of {role, content} message objects',
231
+ },
232
+ template: { type: 'string', description: 'Template preset (llama3, mistral, chatml, phi, gemma) or model ID for auto-detection' },
233
+ },
234
+ required: ['messages', 'template'],
235
+ },
236
+ handler: async (args) => {
237
+ try {
238
+ const mod = await loadRuvllmWasm();
239
+ const messages = args.messages;
240
+ const templateStr = args.template;
241
+ const presets = ['llama3', 'mistral', 'chatml', 'phi', 'gemma'];
242
+ const template = presets.includes(templateStr)
243
+ ? templateStr
244
+ : { modelId: templateStr };
245
+ const formatted = await mod.formatChat(messages, template);
246
+ return { content: [{ type: 'text', text: formatted }] };
247
+ }
248
+ catch (err) {
249
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
250
+ }
251
+ },
252
+ },
253
+ {
254
+ name: 'ruvllm_generate_config',
255
+ description: 'Create a generation config (maxTokens, temperature, topP, etc.) as JSON.',
256
+ inputSchema: {
257
+ type: 'object',
258
+ properties: {
259
+ maxTokens: { type: 'number', description: 'Max tokens to generate' },
260
+ temperature: { type: 'number', description: 'Sampling temperature (note: f32 precision)' },
261
+ topP: { type: 'number', description: 'Top-p sampling' },
262
+ topK: { type: 'number', description: 'Top-k sampling' },
263
+ repetitionPenalty: { type: 'number', description: 'Repetition penalty' },
264
+ stopSequences: { type: 'array', description: 'Stop sequences' },
265
+ },
266
+ },
267
+ handler: async (args) => {
268
+ try {
269
+ const mod = await loadRuvllmWasm();
270
+ const config = await mod.createGenerateConfig(args);
271
+ return { content: [{ type: 'text', text: config }] };
272
+ }
273
+ catch (err) {
274
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
275
+ }
276
+ },
277
+ },
278
+ ];
279
+ // ── Instance Registries ──────────────────────────────────────
280
+ const hnswRouters = new Map();
281
+ const sonaInstances = new Map();
282
+ const loraInstances = new Map();
283
+ //# sourceMappingURL=ruvllm-tools.js.map
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Swarm MCP Tools for CLI
3
3
  *
4
- * Tool definitions for swarm coordination.
4
+ * Tool definitions for swarm coordination with file-based state persistence.
5
+ * Replaces previous stub implementations with real state tracking.
5
6
  */
6
7
  import type { MCPTool } from './types.js';
7
8
  export declare const swarmTools: MCPTool[];