Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Checkpoint: File edits

rUv5b5c798a27ce
diff --git a/v3/@claude-flow/cli/src/mcp-tools/neural-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/neural-tools.ts
index 884d8e5ca0..2d666f9dea 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/neural-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/neural-tools.ts
@@ -96,11 +96,52 @@ function saveNeuralStore(store: NeuralStore): void {
writeFileSync(getNeuralPath(), JSON.stringify(store, null, 2), 'utf-8');
}
-// Generate random embedding for demo
-function generateEmbedding(dims: number = 384): number[] {
+// Generate embedding - uses real embeddings if available, falls back to hash-based
+async function generateEmbedding(text?: string, dims: number = 384): Promise<number[]> {
+ // If real embeddings available and text provided, use them
+ if (realEmbeddings && text) {
+ try {
+ return await realEmbeddings.embed(text);
+ } catch {
+ // Fall back to hash-based
+ }
+ }
+
+ // Hash-based deterministic embedding (better than pure random for consistency)
+ if (text) {
+ const hash = text.split('').reduce((acc, char, i) => {
+ return acc + char.charCodeAt(0) * (i + 1);
+ }, 0);
+
+ // Use hash to seed a deterministic embedding
+ const embedding: number[] = [];
+ let seed = hash;
+ for (let i = 0; i < dims; i++) {
+ // Simple LCG random with seed
+ seed = (seed * 1103515245 + 12345) & 0x7fffffff;
+ embedding.push((seed / 0x7fffffff) * 2 - 1);
+ }
+ return embedding;
+ }
+
+ // Pure random fallback
return Array.from({ length: dims }, () => Math.random() * 2 - 1);
}
+// Cosine similarity for pattern search
+function cosineSimilarity(a: number[], b: number[]): number {
+ if (a.length !== b.length) return 0;
+ let dotProduct = 0;
+ let normA = 0;
+ let normB = 0;
+ for (let i = 0; i < a.length; i++) {
+ dotProduct += a[i] * b[i];
+ normA += a[i] * a[i];
+ normB += b[i] * b[i];
+ }
+ return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB) || 1);
+}
+
export const neuralTools: MCPTool[] = [
{
name: 'neural/train',