claude-flow 3.71.0 → 3.71.2
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/proven-config.json +42 -0
- package/node_modules/@claude-flow/mcp/dist/server.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/server.js +6 -0
- package/node_modules/@claude-flow/mcp/dist/server.js.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/session-manager.d.ts +6 -0
- package/node_modules/@claude-flow/mcp/dist/session-manager.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/session-manager.js +20 -0
- package/node_modules/@claude-flow/mcp/dist/session-manager.js.map +1 -1
- package/node_modules/@claude-flow/mcp/package.json +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js +3 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/package.json +1 -1
- package/package.json +4 -4
- package/v3/@claude-flow/cli/catalog-manifest.json +2 -2
- package/v3/@claude-flow/cli/dist/src/commands/deployment.js +1 -1
- package/v3/@claude-flow/cli/dist/src/commands/embeddings.js +6 -6
- package/v3/@claude-flow/cli/dist/src/commands/init.js +4 -0
- package/v3/@claude-flow/cli/dist/src/commands/ruvector/backup.js +1 -1
- package/v3/@claude-flow/cli/dist/src/commands/ruvector/migrate.js +1 -1
- package/v3/@claude-flow/cli/dist/src/commands/session.js +10 -7
- package/v3/@claude-flow/cli/dist/src/init/executor.js +15 -5
- package/v3/@claude-flow/cli/dist/src/init/types.d.ts +2 -0
- package/v3/@claude-flow/cli/dist/src/init/types.js +4 -1
- package/v3/@claude-flow/cli/dist/src/mcp-tools/claims-tools.js +7 -1
- package/v3/@claude-flow/cli/dist/src/mcp-tools/daa-tools.js +22 -2
- package/v3/@claude-flow/cli/dist/src/mcp-tools/embeddings-tools.js +2 -1
- package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +8 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/session-tools.js +42 -4
- package/v3/@claude-flow/cli/dist/src/mcp-tools/terminal-tools.js +5 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/workflow-tools.js +22 -3
- package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.d.ts +6 -0
- package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.js +98 -15
- package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +32 -10
- package/v3/@claude-flow/cli/dist/src/services/claims-store.js +5 -2
- package/v3/@claude-flow/cli/dist/src/services/ruvector-training.js +18 -5
- package/v3/@claude-flow/cli/package.json +4 -4
- package/v3/@claude-flow/shared/dist/resilience/rate-limiter.js +2 -2
- package/v3/@claude-flow/shared/dist/resilience/retry.js +2 -2
- package/v3/@claude-flow/shared/package.json +1 -1
|
@@ -29,11 +29,9 @@ const SKILLS_MAP = {
|
|
|
29
29
|
core: [
|
|
30
30
|
'swarm-orchestration',
|
|
31
31
|
'swarm-advanced',
|
|
32
|
-
'sparc-methodology',
|
|
33
32
|
'hooks-automation',
|
|
34
33
|
'pair-programming',
|
|
35
34
|
'verification-quality',
|
|
36
|
-
'stream-chain',
|
|
37
35
|
'skill-builder',
|
|
38
36
|
],
|
|
39
37
|
browser: ['browser'], // agent-browser integration
|
|
@@ -47,12 +45,11 @@ const SKILLS_MAP = {
|
|
|
47
45
|
'reasoningbank-agentdb',
|
|
48
46
|
'reasoningbank-intelligence',
|
|
49
47
|
],
|
|
48
|
+
// github-code-review and github-project-management only use hooks, which v3
|
|
49
|
+
// ships; the other three drive `ruflo github`, so they live in skills.legacy.
|
|
50
50
|
github: [
|
|
51
51
|
'github-code-review',
|
|
52
|
-
'github-multi-repo',
|
|
53
52
|
'github-project-management',
|
|
54
|
-
'github-release-management',
|
|
55
|
-
'github-workflow-automation',
|
|
56
53
|
],
|
|
57
54
|
flowNexus: [
|
|
58
55
|
'flow-nexus-neural',
|
|
@@ -70,6 +67,17 @@ const SKILLS_MAP = {
|
|
|
70
67
|
'v3-security-overhaul',
|
|
71
68
|
'v3-swarm-coordination',
|
|
72
69
|
],
|
|
70
|
+
// ADR-128 / #4539: skills that document v2-era verbs v3 does not ship
|
|
71
|
+
// (`stream-chain`, `sparc`, `github`). Their examples fail with `Unknown
|
|
72
|
+
// command`, so they are opt-in like skills.v3 instead of being installed by
|
|
73
|
+
// default.
|
|
74
|
+
legacy: [
|
|
75
|
+
'github-multi-repo',
|
|
76
|
+
'github-release-management',
|
|
77
|
+
'github-workflow-automation',
|
|
78
|
+
'sparc-methodology',
|
|
79
|
+
'stream-chain',
|
|
80
|
+
],
|
|
73
81
|
};
|
|
74
82
|
/**
|
|
75
83
|
* Commands to copy based on configuration
|
|
@@ -1077,6 +1085,8 @@ async function copySkills(targetDir, options, result) {
|
|
|
1077
1085
|
skillsToCopy.push(...SKILLS_MAP.v3);
|
|
1078
1086
|
if (skillsConfig.dualMode)
|
|
1079
1087
|
skillsToCopy.push(...SKILLS_MAP.dualMode);
|
|
1088
|
+
if (skillsConfig.legacy)
|
|
1089
|
+
skillsToCopy.push(...SKILLS_MAP.legacy);
|
|
1080
1090
|
}
|
|
1081
1091
|
// Find source skills directory
|
|
1082
1092
|
const sourceSkillsDir = findSourceDir('skills', options.sourceBaseDir);
|
|
@@ -76,6 +76,8 @@ export interface SkillsConfig {
|
|
|
76
76
|
v3: boolean;
|
|
77
77
|
/** Include dual-mode skills (Claude Code + Codex hybrid) */
|
|
78
78
|
dualMode: boolean;
|
|
79
|
+
/** Include legacy skills that document commands v3 does not ship (opt-in) */
|
|
80
|
+
legacy: boolean;
|
|
79
81
|
/** Include all available skills */
|
|
80
82
|
all: boolean;
|
|
81
83
|
}
|
|
@@ -73,11 +73,12 @@ export const DEFAULT_INIT_OPTIONS = {
|
|
|
73
73
|
skills: {
|
|
74
74
|
core: true,
|
|
75
75
|
agentdb: true,
|
|
76
|
-
github: true,
|
|
76
|
+
github: true, // #4539: only the hook-only GitHub skills remain; the rest are skills.legacy
|
|
77
77
|
flowNexus: false,
|
|
78
78
|
browser: true,
|
|
79
79
|
v3: false, // ADR-128: opt-in like agents.v3; use --full or `init skills --v3`
|
|
80
80
|
dualMode: false, // Optional: enable with --dual flag
|
|
81
|
+
legacy: false, // #4539: stream-chain/sparc document verbs v3 does not ship
|
|
81
82
|
all: false,
|
|
82
83
|
},
|
|
83
84
|
commands: {
|
|
@@ -186,6 +187,7 @@ export const MINIMAL_INIT_OPTIONS = {
|
|
|
186
187
|
browser: false,
|
|
187
188
|
v3: false,
|
|
188
189
|
dualMode: false,
|
|
190
|
+
legacy: false,
|
|
189
191
|
all: false,
|
|
190
192
|
},
|
|
191
193
|
agents: {
|
|
@@ -246,6 +248,7 @@ export const FULL_INIT_OPTIONS = {
|
|
|
246
248
|
browser: true,
|
|
247
249
|
v3: true,
|
|
248
250
|
dualMode: true, // Include in full init
|
|
251
|
+
legacy: true, // Include in full init
|
|
249
252
|
all: true,
|
|
250
253
|
},
|
|
251
254
|
commands: {
|
|
@@ -402,6 +402,10 @@ export const claimsTools = [
|
|
|
402
402
|
if (progress !== undefined) {
|
|
403
403
|
claim.progress = Math.min(100, Math.max(0, progress));
|
|
404
404
|
}
|
|
405
|
+
// claims_status never sets 'stealable', so a claim it updates is no
|
|
406
|
+
// longer up for grabs: drop it from the list claims_stealable and
|
|
407
|
+
// claims_steal read.
|
|
408
|
+
delete store.stealable[issueId];
|
|
405
409
|
store.claims[issueId] = claim;
|
|
406
410
|
saveClaims(store);
|
|
407
411
|
return {
|
|
@@ -592,7 +596,9 @@ export const claimsTools = [
|
|
|
592
596
|
claim.claimant = stealer;
|
|
593
597
|
claim.status = 'active';
|
|
594
598
|
claim.statusChangedAt = now;
|
|
595
|
-
|
|
599
|
+
// The context given to claims_mark-stealable is the handoff note for the
|
|
600
|
+
// stealer; without one, keep the context recorded with the claim.
|
|
601
|
+
claim.context = stealableInfo.context ?? claim.context;
|
|
596
602
|
delete store.stealable[issueId];
|
|
597
603
|
store.claims[issueId] = claim;
|
|
598
604
|
saveClaims(store);
|
|
@@ -28,17 +28,37 @@ function ensureDAADir() {
|
|
|
28
28
|
mkdirSync(dir, { recursive: true });
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* SECURITY: record maps are keyed by ids taken from MCP tool input, and
|
|
33
|
+
* validateIdentifier accepts names like `__proto__` and `constructor`. On a
|
|
34
|
+
* plain object those resolve to Object.prototype or a built-in, which a handler
|
|
35
|
+
* would then write into. Null-prototype maps only ever return own records.
|
|
36
|
+
*/
|
|
37
|
+
function withRecordMaps(store, keys) {
|
|
38
|
+
const maps = store;
|
|
39
|
+
for (const key of keys) {
|
|
40
|
+
const map = maps[key];
|
|
41
|
+
if (map && typeof map === 'object' && !Array.isArray(map))
|
|
42
|
+
Object.setPrototypeOf(map, null);
|
|
43
|
+
else
|
|
44
|
+
maps[key] = Object.create(null);
|
|
45
|
+
}
|
|
46
|
+
return store;
|
|
47
|
+
}
|
|
48
|
+
const DAA_MAPS = ['agents', 'workflows', 'knowledge'];
|
|
31
49
|
function loadDAAStore() {
|
|
32
50
|
try {
|
|
33
51
|
const path = getDAAPath();
|
|
34
52
|
if (existsSync(path)) {
|
|
35
|
-
|
|
53
|
+
const parsed = JSON.parse(readFileSync(path, 'utf-8'));
|
|
54
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
|
|
55
|
+
return withRecordMaps(parsed, DAA_MAPS);
|
|
36
56
|
}
|
|
37
57
|
}
|
|
38
58
|
catch {
|
|
39
59
|
// Return empty store
|
|
40
60
|
}
|
|
41
|
-
return { agents: {}, workflows: {}, knowledge: {}, version: '3.0.0' };
|
|
61
|
+
return withRecordMaps({ agents: {}, workflows: {}, knowledge: {}, version: '3.0.0' }, DAA_MAPS);
|
|
42
62
|
}
|
|
43
63
|
function saveDAAStore(store) {
|
|
44
64
|
ensureDAADir();
|
|
@@ -425,7 +425,8 @@ export const embeddingsTools = [
|
|
|
425
425
|
}
|
|
426
426
|
const query = input.query;
|
|
427
427
|
const topK = input.topK || 5;
|
|
428
|
-
|
|
428
|
+
// `??`, not `||`: threshold 0 is a valid request for every match, as in memory_search.
|
|
429
|
+
const threshold = input.threshold ?? 0.5;
|
|
429
430
|
const namespace = input.namespace;
|
|
430
431
|
{
|
|
431
432
|
const v = validateText(query, 'query');
|
|
@@ -203,6 +203,14 @@ function resolveProjectMemoryDir(claudeProjectsDir, projectPathOverride) {
|
|
|
203
203
|
if (/^[A-Za-z]:[\\/]/.test(source)) {
|
|
204
204
|
candidates.add(source.replace(/[:\\/]/g, '-').replace(/\s+/g, '-'));
|
|
205
205
|
}
|
|
206
|
+
// Candidate 6: Claude Code's own rule, which replaces every character
|
|
207
|
+
// other than [A-Za-z0-9] with `-` (the cost tracker's
|
|
208
|
+
// _encode-project-path.mjs does the same, #4366). The candidates above
|
|
209
|
+
// keep `_`, `.` and the like, so `/work/my_app` never found its folder
|
|
210
|
+
// `-work-my-app`. A WSL path is also tried in its Windows form.
|
|
211
|
+
candidates.add(source.replace(/[^a-zA-Z0-9]/g, '-'));
|
|
212
|
+
if (wsl)
|
|
213
|
+
candidates.add(`${wsl[1].toUpperCase()}:${wsl[2] ?? ''}`.replace(/[^a-zA-Z0-9]/g, '-'));
|
|
206
214
|
}
|
|
207
215
|
for (const projectHash of candidates) {
|
|
208
216
|
const memDir = join(claudeProjectsDir, projectHash, 'memory');
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Tool definitions for session management with file persistence.
|
|
5
5
|
*/
|
|
6
|
-
import { existsSync, readFileSync, readdirSync, unlinkSync, statSync, writeFileSync } from 'node:fs';
|
|
6
|
+
import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync, unlinkSync, statSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { randomUUID } from 'node:crypto';
|
|
8
8
|
import { gunzipSync } from 'node:zlib';
|
|
9
|
-
import { join } from 'node:path';
|
|
9
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
10
10
|
import { getProjectCwd } from './types.js';
|
|
11
11
|
import { mkdirRestricted, readFileMaybeEncrypted, writeFileRestricted, } from '../fs-secure.js';
|
|
12
12
|
import { validateIdentifier, validateText } from './validate-input.js';
|
|
@@ -351,6 +351,41 @@ function isSessionRecordLike(value) {
|
|
|
351
351
|
const v = value;
|
|
352
352
|
return 'data' in v || 'stats' in v || 'sessionId' in v || 'savedAt' in v;
|
|
353
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* SECURITY: `outputPath` comes from MCP tool input. Resolve it against the
|
|
356
|
+
* project root and require the real (symlink-resolved) parent directory to stay
|
|
357
|
+
* inside the real project root, and refuse an existing symlink as the target,
|
|
358
|
+
* so session_export cannot write files elsewhere on the host. The CLI's
|
|
359
|
+
* `session export` writes its own file and does not pass outputPath.
|
|
360
|
+
*/
|
|
361
|
+
function containedExportPath(outputPath) {
|
|
362
|
+
if (!outputPath || outputPath.includes('\0'))
|
|
363
|
+
return null;
|
|
364
|
+
try {
|
|
365
|
+
const root = realpathSync(getProjectCwd());
|
|
366
|
+
const abs = resolve(root, outputPath);
|
|
367
|
+
const parent = realpathSync(dirname(abs));
|
|
368
|
+
const target = join(parent, basename(abs));
|
|
369
|
+
const rel = relative(root, target);
|
|
370
|
+
if (!rel || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel))
|
|
371
|
+
return null;
|
|
372
|
+
const existing = lstatOrNull(target);
|
|
373
|
+
if (existing && (existing.isSymbolicLink() || !existing.isFile()))
|
|
374
|
+
return null;
|
|
375
|
+
return target;
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function lstatOrNull(p) {
|
|
382
|
+
try {
|
|
383
|
+
return lstatSync(p);
|
|
384
|
+
}
|
|
385
|
+
catch {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
354
389
|
export const sessionTools = [
|
|
355
390
|
{
|
|
356
391
|
name: 'session_save',
|
|
@@ -705,9 +740,12 @@ export const sessionTools = [
|
|
|
705
740
|
let path = null;
|
|
706
741
|
const outputPath = input.outputPath ? String(input.outputPath) : null;
|
|
707
742
|
if (outputPath) {
|
|
743
|
+
const target = containedExportPath(outputPath);
|
|
744
|
+
if (!target)
|
|
745
|
+
return { sessionId, error: 'outputPath must be a file inside the project directory (no symlinks)' };
|
|
708
746
|
try {
|
|
709
|
-
writeFileSync(
|
|
710
|
-
path =
|
|
747
|
+
writeFileSync(target, JSON.stringify(session, null, 2), 'utf-8');
|
|
748
|
+
path = target;
|
|
711
749
|
}
|
|
712
750
|
catch (e) {
|
|
713
751
|
return { sessionId, error: `Could not write ${outputPath}: ${e.message}` };
|
|
@@ -132,6 +132,11 @@ export const terminalTools = [
|
|
|
132
132
|
const store = loadTerminalStore();
|
|
133
133
|
const sessionId = input.sessionId;
|
|
134
134
|
const command = input.command;
|
|
135
|
+
// An explicit sessionId must name a stored session; only fall back to
|
|
136
|
+
// (or create) the default session when no sessionId was given.
|
|
137
|
+
if (sessionId && !store.sessions[sessionId]) {
|
|
138
|
+
return { success: false, error: 'Session not found' };
|
|
139
|
+
}
|
|
135
140
|
// Find or create default session
|
|
136
141
|
let session = sessionId ? store.sessions[sessionId] : Object.values(store.sessions).find(s => s.status === 'active');
|
|
137
142
|
if (!session) {
|
|
@@ -55,18 +55,37 @@ function ensureWorkflowDir() {
|
|
|
55
55
|
mkdirSync(dir, { recursive: true });
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* SECURITY: record maps are keyed by ids taken from MCP tool input, and
|
|
60
|
+
* validateIdentifier accepts names like `__proto__` and `constructor`. On a
|
|
61
|
+
* plain object those resolve to Object.prototype or a built-in, which a handler
|
|
62
|
+
* would then write into. Null-prototype maps only ever return own records.
|
|
63
|
+
*/
|
|
64
|
+
function withRecordMaps(store, keys) {
|
|
65
|
+
const maps = store;
|
|
66
|
+
for (const key of keys) {
|
|
67
|
+
const map = maps[key];
|
|
68
|
+
if (map && typeof map === 'object' && !Array.isArray(map))
|
|
69
|
+
Object.setPrototypeOf(map, null);
|
|
70
|
+
else
|
|
71
|
+
maps[key] = Object.create(null);
|
|
72
|
+
}
|
|
73
|
+
return store;
|
|
74
|
+
}
|
|
75
|
+
const WORKFLOW_MAPS = ['workflows', 'templates'];
|
|
58
76
|
function loadWorkflowStore() {
|
|
59
77
|
try {
|
|
60
78
|
const path = getWorkflowPath();
|
|
61
79
|
if (existsSync(path)) {
|
|
62
|
-
const data = readFileSync(path, 'utf-8');
|
|
63
|
-
|
|
80
|
+
const data = JSON.parse(readFileSync(path, 'utf-8'));
|
|
81
|
+
if (data && typeof data === 'object' && !Array.isArray(data))
|
|
82
|
+
return withRecordMaps(data, WORKFLOW_MAPS);
|
|
64
83
|
}
|
|
65
84
|
}
|
|
66
85
|
catch {
|
|
67
86
|
// Return default store on error
|
|
68
87
|
}
|
|
69
|
-
return { workflows: {}, templates: {}, version: '3.0.0' };
|
|
88
|
+
return withRecordMaps({ workflows: {}, templates: {}, version: '3.0.0' }, WORKFLOW_MAPS);
|
|
70
89
|
}
|
|
71
90
|
function saveWorkflowStore(store) {
|
|
72
91
|
ensureWorkflowDir();
|
|
@@ -614,6 +614,12 @@ export declare function bridgeHealthCheck(dbPath?: string): Promise<{
|
|
|
614
614
|
hits: number;
|
|
615
615
|
misses: number;
|
|
616
616
|
};
|
|
617
|
+
/** Why AgentDB failed to open, or null when it opened (#4654). */
|
|
618
|
+
agentdbInitError?: string | null;
|
|
619
|
+
/** Last bridge-level failure, including the AgentDB lock cause (#4622/#4654). */
|
|
620
|
+
bridgeFailureReason?: string | null;
|
|
621
|
+
/** Actionable next step when a second process owns the native store. */
|
|
622
|
+
hint?: string;
|
|
617
623
|
hierarchicalMemory?: {
|
|
618
624
|
controller: string;
|
|
619
625
|
durable: boolean;
|
|
@@ -964,8 +964,27 @@ export async function rescueAgentdbEmbedder(agentdb) {
|
|
|
964
964
|
? out.embedding
|
|
965
965
|
: new Float32Array(out.embedding ?? []);
|
|
966
966
|
};
|
|
967
|
+
const newBatch = async (texts) => Promise.all(texts.map(t => newEmbed(t)));
|
|
967
968
|
emb.embed = newEmbed;
|
|
968
|
-
emb.embedBatch =
|
|
969
|
+
emb.embedBatch = newBatch;
|
|
970
|
+
// #4643: agentdb 3.x's ReasoningBank calls embedQuery()/embedPassage(),
|
|
971
|
+
// which route through embedFor() → generateEmbedding() → mockEmbedding()
|
|
972
|
+
// and never touch embed(). Patch the role methods too, or the rescue never
|
|
973
|
+
// reaches pattern store/search. The model is symmetric, so both roles share
|
|
974
|
+
// one function; drop any mock vectors already cached under the old space.
|
|
975
|
+
const roles = emb;
|
|
976
|
+
if (typeof roles.embedQuery === 'function')
|
|
977
|
+
roles.embedQuery = newEmbed;
|
|
978
|
+
if (typeof roles.embedPassage === 'function')
|
|
979
|
+
roles.embedPassage = newEmbed;
|
|
980
|
+
if (typeof roles.embedQueryBatch === 'function')
|
|
981
|
+
roles.embedQueryBatch = newBatch;
|
|
982
|
+
if (typeof roles.embedPassageBatch === 'function')
|
|
983
|
+
roles.embedPassageBatch = newBatch;
|
|
984
|
+
try {
|
|
985
|
+
roles.clearCache?.();
|
|
986
|
+
}
|
|
987
|
+
catch { /* best-effort */ }
|
|
969
988
|
emb.__ruvectorRescued = true;
|
|
970
989
|
}
|
|
971
990
|
/** AgentDB uses a null pipeline while its transformer failed and it serves mock vectors. */
|
|
@@ -1521,15 +1540,39 @@ export async function bridgeListEntries(options) {
|
|
|
1521
1540
|
// List
|
|
1522
1541
|
const entries = [];
|
|
1523
1542
|
try {
|
|
1524
|
-
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1543
|
+
const columns = 'id, key, namespace, content, embedding, access_count, created_at, updated_at, provenance_type, expires_at, tags';
|
|
1544
|
+
const listLimit = options.includeEmbedding ? Math.min(safeLimit, MAX_LIST_EMBEDDINGS) : safeLimit;
|
|
1545
|
+
// #4686: sort only row identities first, then fetch the payload for the
|
|
1546
|
+
// page. The old query sorted full `content`/`embedding` payloads for
|
|
1547
|
+
// every row and discarded all but the requested page.
|
|
1548
|
+
const pagedSql = `
|
|
1549
|
+
SELECT ${columns}
|
|
1550
|
+
FROM memory_entries
|
|
1551
|
+
WHERE _rowid_ IN (
|
|
1552
|
+
SELECT _rowid_
|
|
1553
|
+
FROM memory_entries
|
|
1554
|
+
WHERE ${statusFilter} ${extraFilter}
|
|
1555
|
+
ORDER BY updated_at DESC
|
|
1556
|
+
LIMIT ? OFFSET ?
|
|
1557
|
+
)
|
|
1558
|
+
ORDER BY updated_at DESC
|
|
1559
|
+
`;
|
|
1560
|
+
const originalSql = `
|
|
1561
|
+
SELECT ${columns}
|
|
1527
1562
|
FROM memory_entries
|
|
1528
1563
|
WHERE ${statusFilter} ${extraFilter}
|
|
1529
1564
|
ORDER BY updated_at DESC
|
|
1530
1565
|
LIMIT ? OFFSET ?
|
|
1531
|
-
|
|
1532
|
-
|
|
1566
|
+
`;
|
|
1567
|
+
let rows;
|
|
1568
|
+
try {
|
|
1569
|
+
rows = ctx.db.prepare(pagedSql).all(...filterParams, listLimit, safeOffset);
|
|
1570
|
+
}
|
|
1571
|
+
catch {
|
|
1572
|
+
// WITHOUT ROWID/legacy tables have no _rowid_: preserve the original
|
|
1573
|
+
// query rather than failing the page.
|
|
1574
|
+
rows = ctx.db.prepare(originalSql).all(...filterParams, listLimit, safeOffset);
|
|
1575
|
+
}
|
|
1533
1576
|
for (const row of rows) {
|
|
1534
1577
|
let tags = [];
|
|
1535
1578
|
if (row.tags) {
|
|
@@ -2432,6 +2475,24 @@ export async function bridgeStorePattern(options) {
|
|
|
2432
2475
|
return null;
|
|
2433
2476
|
}
|
|
2434
2477
|
}
|
|
2478
|
+
/**
|
|
2479
|
+
* Case-insensitive substring match over agentdb's reasoning_patterns table —
|
|
2480
|
+
* the rows ReasoningBank.storePattern() writes. Used only when the vector
|
|
2481
|
+
* search returns nothing. Returns [] when the table or handle is unavailable.
|
|
2482
|
+
*/
|
|
2483
|
+
function substringSearchReasoningPatterns(registry, query, k) {
|
|
2484
|
+
try {
|
|
2485
|
+
const db = registry?.getAgentDB?.()?.database;
|
|
2486
|
+
if (!db || typeof db.prepare !== 'function')
|
|
2487
|
+
return [];
|
|
2488
|
+
const like = `%${query.toLowerCase().replace(/[\\%_]/g, (c) => `\\${c}`)}%`;
|
|
2489
|
+
const rows = db.prepare("SELECT id, approach, success_rate FROM reasoning_patterns WHERE lower(approach) LIKE ? ESCAPE '\\' ORDER BY id DESC LIMIT ?").all(like, k);
|
|
2490
|
+
return rows.map((r) => ({ id: String(r.id), content: r.approach, score: r.success_rate ?? 0 }));
|
|
2491
|
+
}
|
|
2492
|
+
catch {
|
|
2493
|
+
return [];
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2435
2496
|
/**
|
|
2436
2497
|
* Search patterns via ReasoningBank controller.
|
|
2437
2498
|
*/
|
|
@@ -2458,14 +2519,19 @@ export async function bridgeSearchPatterns(options) {
|
|
|
2458
2519
|
// mapping produced `content: ''` and `score: 0` for every hit even when
|
|
2459
2520
|
// the search itself succeeded. Read the real fields first, keeping the
|
|
2460
2521
|
// legacy names as fallbacks for the pre-agentdb shape.
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2522
|
+
let mapped = Array.isArray(results) ? results.map((r) => ({
|
|
2523
|
+
id: String(r.id ?? r.patternId ?? ''),
|
|
2524
|
+
content: r.approach ?? r.content ?? r.pattern ?? '',
|
|
2525
|
+
score: r.similarity ?? r.score ?? r.successRate ?? r.confidence ?? 0,
|
|
2526
|
+
})) : [];
|
|
2527
|
+
// #4643 — with agentdb's mock embedder (Transformers.js failed to load:
|
|
2528
|
+
// offline, or a failed `sharp` install) a passage and a query embed to
|
|
2529
|
+
// unrelated hash vectors, so the vector search misses a pattern that
|
|
2530
|
+
// storePattern just wrote. Scan the same reasoning_patterns table for the
|
|
2531
|
+
// query text, as the LocalReasoningBank branch below does over getAll().
|
|
2532
|
+
if (mapped.length === 0)
|
|
2533
|
+
mapped = substringSearchReasoningPatterns(registry, options.query, options.topK || 5);
|
|
2534
|
+
return { results: mapped, controller: 'reasoningBank' };
|
|
2469
2535
|
}
|
|
2470
2536
|
// #2226 — the wired-in LocalReasoningBank implements store() + findSimilar()/getAll()
|
|
2471
2537
|
// but NOT searchPatterns()/search(). bridgeStorePattern commits patterns to its
|
|
@@ -3244,6 +3310,12 @@ export async function bridgeHealthCheck(dbPath) {
|
|
|
3244
3310
|
return null;
|
|
3245
3311
|
try {
|
|
3246
3312
|
const controllers = registry.listControllers();
|
|
3313
|
+
const resolvedPath = canonicalDbPath(dbPath);
|
|
3314
|
+
const agentdbInitError = agentdbInitFailure(registry, resolvedPath);
|
|
3315
|
+
const bridgeFailureReason = getBridgeFailureReason(dbPath);
|
|
3316
|
+
const lockHint = agentdbInitError && /already open|cannot acquire lock|locked/i.test(agentdbInitError)
|
|
3317
|
+
? 'Another process (often the ruflo daemon or a second MCP server) owns the native vector store. Stop one owner and reconnect; reads currently use the volatile fallback.'
|
|
3318
|
+
: undefined;
|
|
3247
3319
|
// Phase 4: AttestationLog stats
|
|
3248
3320
|
let attestationCount = 0;
|
|
3249
3321
|
const attestation = registry.get('attestationLog');
|
|
@@ -3268,7 +3340,18 @@ export async function bridgeHealthCheck(dbPath) {
|
|
|
3268
3340
|
persistedRows: typeof hm.countPersisted === 'function' ? hm.countPersisted() : null,
|
|
3269
3341
|
};
|
|
3270
3342
|
}
|
|
3271
|
-
return {
|
|
3343
|
+
return {
|
|
3344
|
+
// A registry with a failed AgentDB still serves its other controllers,
|
|
3345
|
+
// but it is not a working persistent bridge (#4622/#4654).
|
|
3346
|
+
available: agentdbInitError === null,
|
|
3347
|
+
controllers,
|
|
3348
|
+
attestationCount,
|
|
3349
|
+
cacheStats,
|
|
3350
|
+
agentdbInitError,
|
|
3351
|
+
bridgeFailureReason,
|
|
3352
|
+
...(lockHint ? { hint: lockHint } : {}),
|
|
3353
|
+
hierarchicalMemory,
|
|
3354
|
+
};
|
|
3272
3355
|
}
|
|
3273
3356
|
catch {
|
|
3274
3357
|
return null;
|
|
@@ -3115,16 +3115,38 @@ export async function listEntries(options) {
|
|
|
3115
3115
|
const total = countRows[0]?.[0] || 0;
|
|
3116
3116
|
// Get entries. ADR-472: embedding rows are capped at MAX_LIST_EMBEDDINGS.
|
|
3117
3117
|
const listLimit = options.includeEmbedding ? Math.min(safeLimit, MAX_LIST_EMBEDDINGS) : safeLimit;
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3118
|
+
const columns = 'id, key, namespace, content, embedding, access_count, created_at, updated_at, provenance_type, expires_at, tags';
|
|
3119
|
+
// #4686: page row identities first so the temporary sort B-tree does not
|
|
3120
|
+
// carry full content/embedding payloads for rows outside the page.
|
|
3121
|
+
const pagedSql = `SELECT ${columns} FROM memory_entries
|
|
3122
|
+
WHERE _rowid_ IN (
|
|
3123
|
+
SELECT _rowid_ FROM memory_entries WHERE ${whereSql}
|
|
3124
|
+
ORDER BY updated_at DESC LIMIT ? OFFSET ?
|
|
3125
|
+
)
|
|
3126
|
+
ORDER BY updated_at DESC`;
|
|
3127
|
+
const originalSql = `SELECT ${columns} FROM memory_entries WHERE ${whereSql}
|
|
3128
|
+
ORDER BY updated_at DESC LIMIT ? OFFSET ?`;
|
|
3129
|
+
let listRows = [];
|
|
3130
|
+
const runList = (sql) => {
|
|
3131
|
+
const stmt = db.prepare(sql);
|
|
3132
|
+
try {
|
|
3133
|
+
stmt.bind([...whereParams, listLimit, safeOffset]);
|
|
3134
|
+
const rows = [];
|
|
3135
|
+
while (stmt.step())
|
|
3136
|
+
rows.push(stmt.get());
|
|
3137
|
+
return rows;
|
|
3138
|
+
}
|
|
3139
|
+
finally {
|
|
3140
|
+
stmt.free();
|
|
3141
|
+
}
|
|
3142
|
+
};
|
|
3143
|
+
try {
|
|
3144
|
+
listRows = runList(pagedSql);
|
|
3145
|
+
}
|
|
3146
|
+
catch {
|
|
3147
|
+
// Legacy WITHOUT ROWID tables have no _rowid_: keep the original query.
|
|
3148
|
+
listRows = runList(originalSql);
|
|
3149
|
+
}
|
|
3128
3150
|
const entries = [];
|
|
3129
3151
|
for (const row of listRows) {
|
|
3130
3152
|
const [id, key, ns, content, embedding, accessCount, createdAt, updatedAt, provenanceTypeVal, expiresAtVal, tagsJson] = row;
|
|
@@ -11,7 +11,7 @@ export function readClaimsStore(file) {
|
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
13
13
|
if (error.code === 'ENOENT')
|
|
14
|
-
return { claims:
|
|
14
|
+
return { claims: Object.create(null), stealable: Object.create(null), contests: Object.create(null) };
|
|
15
15
|
throw error;
|
|
16
16
|
}
|
|
17
17
|
const data = JSON.parse(text);
|
|
@@ -35,6 +35,9 @@ export function readClaimsStore(file) {
|
|
|
35
35
|
if (data[key] !== undefined && !record(data[key]))
|
|
36
36
|
throw new Error(`Invalid claims store: ${key} must be an object`);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
// SECURITY: issue ids come from tool input; null-prototype maps keep a lookup
|
|
39
|
+
// by `constructor`/`__proto__` from resolving to an inherited built-in.
|
|
40
|
+
const nullProto = (map) => Object.assign(Object.create(null), map ?? {});
|
|
41
|
+
return { ...data, claims, stealable: nullProto(data.stealable), contests: nullProto(data.contests) };
|
|
39
42
|
}
|
|
40
43
|
//# sourceMappingURL=claims-store.js.map
|
|
@@ -423,7 +423,8 @@ export function computeFlashAttention(query, keys, values) {
|
|
|
423
423
|
if (!flashAttention) {
|
|
424
424
|
throw new Error('Flash attention not initialized');
|
|
425
425
|
}
|
|
426
|
-
|
|
426
|
+
// #4610: the @ruvector/attention classes expose compute(), not computeRaw().
|
|
427
|
+
return flashAttention.compute(query, keys, values);
|
|
427
428
|
}
|
|
428
429
|
/**
|
|
429
430
|
* Compute MoE routing
|
|
@@ -432,7 +433,7 @@ export function computeMoEAttention(query, keys, values) {
|
|
|
432
433
|
if (!moeAttention) {
|
|
433
434
|
throw new Error('MoE attention not initialized');
|
|
434
435
|
}
|
|
435
|
-
return moeAttention.
|
|
436
|
+
return moeAttention.compute(query, keys, values);
|
|
436
437
|
}
|
|
437
438
|
/**
|
|
438
439
|
* Compute hyperbolic attention (for hierarchical patterns)
|
|
@@ -441,7 +442,7 @@ export function computeHyperbolicAttention(query, keys, values) {
|
|
|
441
442
|
if (!hyperbolicAttention) {
|
|
442
443
|
throw new Error('Hyperbolic attention not initialized');
|
|
443
444
|
}
|
|
444
|
-
return hyperbolicAttention.
|
|
445
|
+
return hyperbolicAttention.compute(query, keys, values);
|
|
445
446
|
}
|
|
446
447
|
/**
|
|
447
448
|
* Compute contrastive loss for training
|
|
@@ -450,8 +451,20 @@ export function computeContrastiveLoss(anchor, positives, negatives) {
|
|
|
450
451
|
if (!contrastiveLoss) {
|
|
451
452
|
throw new Error('Contrastive loss not initialized');
|
|
452
453
|
}
|
|
453
|
-
|
|
454
|
-
|
|
454
|
+
// #4610: InfoNceLoss has no backward(); computeWithGradients(anchor, positive,
|
|
455
|
+
// negatives) takes one positive and returns { loss, gradients }. Average over
|
|
456
|
+
// the positives so the list signature keeps its meaning.
|
|
457
|
+
if (positives.length === 0) {
|
|
458
|
+
throw new Error('Contrastive loss needs at least one positive');
|
|
459
|
+
}
|
|
460
|
+
let loss = 0;
|
|
461
|
+
const gradient = new Float32Array(anchor.length);
|
|
462
|
+
for (const positive of positives) {
|
|
463
|
+
const result = contrastiveLoss.computeWithGradients(anchor, positive, negatives);
|
|
464
|
+
loss += result.loss / positives.length;
|
|
465
|
+
for (let i = 0; i < gradient.length; i++)
|
|
466
|
+
gradient[i] += result.gradients[i] / positives.length;
|
|
467
|
+
}
|
|
455
468
|
return { loss, gradient };
|
|
456
469
|
}
|
|
457
470
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.71.
|
|
3
|
+
"version": "3.71.2",
|
|
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",
|
|
@@ -103,11 +103,11 @@
|
|
|
103
103
|
"@electron/asar": "^4.3.1",
|
|
104
104
|
"@claude-flow/cli-core": "3.7.5",
|
|
105
105
|
"@claude-flow/codex": "3.0.5",
|
|
106
|
-
"@claude-flow/mcp": "3.1.
|
|
106
|
+
"@claude-flow/mcp": "3.1.6",
|
|
107
107
|
"@claude-flow/neural": "3.0.2",
|
|
108
|
-
"@claude-flow/plugin-agent-federation": "1.0.
|
|
108
|
+
"@claude-flow/plugin-agent-federation": "1.0.5",
|
|
109
109
|
"@claude-flow/security": "3.0.6",
|
|
110
|
-
"@claude-flow/shared": "3.0.
|
|
110
|
+
"@claude-flow/shared": "3.0.7",
|
|
111
111
|
"@iarna/toml": "^2.2.5",
|
|
112
112
|
"@noble/ed25519": "2.3.0",
|
|
113
113
|
"@ruvector/rabitq-wasm": "0.1.0",
|
|
@@ -89,7 +89,7 @@ export class SlidingWindowRateLimiter {
|
|
|
89
89
|
* Reset rate limit for a key
|
|
90
90
|
*/
|
|
91
91
|
reset(key) {
|
|
92
|
-
if (key) {
|
|
92
|
+
if (key !== undefined) {
|
|
93
93
|
this.requests.delete(key);
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
@@ -227,7 +227,7 @@ export class TokenBucketRateLimiter {
|
|
|
227
227
|
* Reset bucket for a key
|
|
228
228
|
*/
|
|
229
229
|
reset(key) {
|
|
230
|
-
if (key) {
|
|
230
|
+
if (key !== undefined) {
|
|
231
231
|
this.buckets.delete(key);
|
|
232
232
|
}
|
|
233
233
|
else {
|