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

rUv817168033822
diff --git a/v3/@claude-flow/embeddings/src/embedding-service.ts b/v3/@claude-flow/embeddings/src/embedding-service.ts
index 2d69e43114..f7db109c6d 100644
--- a/v3/@claude-flow/embeddings/src/embedding-service.ts
+++ b/v3/@claude-flow/embeddings/src/embedding-service.ts
@@ -569,65 +569,58 @@ export class AgenticFlowEmbeddingService extends BaseEmbeddingService {
private async initialize(): Promise<void> {
if (this.initialized) return;
- try {
- // Try to import from agentic-flow package
- const { getOptimizedEmbedder } = await import('agentic-flow/dist/embeddings/optimized-embedder.js');
-
- this.embedder = getOptimizedEmbedder({
- modelId: this.modelId,
- dimension: this.dimensions,
- cacheSize: this.embedderCacheSize,
- modelDir: this.modelDir,
- autoDownload: this.autoDownload,
- });
-
- await this.embedder.init();
- this.initialized = true;
- } catch (error) {
- // Fallback: try node_modules path resolution
+ const createEmbedder = async (modulePath: string): Promise<boolean> => {
try {
- const path = await import('path');
- const { fileURLToPath } = await import('url');
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
-
- // Look for agentic-flow in parent node_modules
- const possiblePaths = [
- path.resolve(__dirname, '../../../../node_modules/agentic-flow/dist/embeddings/optimized-embedder.js'),
- path.resolve(__dirname, '../../../../../node_modules/agentic-flow/dist/embeddings/optimized-embedder.js'),
- path.resolve(process.cwd(), 'node_modules/agentic-flow/dist/embeddings/optimized-embedder.js'),
- ];
-
- let loaded = false;
- for (const modulePath of possiblePaths) {
- try {
- const { getOptimizedEmbedder } = await import(modulePath);
- this.embedder = getOptimizedEmbedder({
- modelId: this.modelId,
- dimension: this.dimensions,
- cacheSize: this.embedderCacheSize,
- modelDir: this.modelDir,
- autoDownload: this.autoDownload,
- });
- await this.embedder.init();
- this.initialized = true;
- loaded = true;
- break;
- } catch {
- continue;
- }
- }
+ const module = await import(/* webpackIgnore: true */ modulePath);
+ const getOptimizedEmbedder = module.getOptimizedEmbedder || module.default?.getOptimizedEmbedder;
+ if (!getOptimizedEmbedder) return false;
+
+ this.embedder = getOptimizedEmbedder({
+ modelId: this.modelId,
+ dimension: this.dimensions,
+ cacheSize: this.embedderCacheSize,
+ modelDir: this.modelDir,
+ autoDownload: this.autoDownload,
+ });
+ await this.embedder.init();
+ this.initialized = true;
+ return true;
+ } catch {
+ return false;
+ }
+ };
- if (!loaded) {
- throw new Error('Could not find agentic-flow embeddings module');
- }
- } catch (fallbackError) {
- throw new Error(
- `Failed to initialize agentic-flow embeddings: ${error}. ` +
- `Ensure agentic-flow is installed and ONNX model is downloaded: ` +
- `npx agentic-flow@alpha embeddings init`
- );
+ // Build list of possible module paths to try
+ const possiblePaths: string[] = [];
+
+ // Try standard package import path
+ const packagePath = 'agentic-flow/dist/embeddings/optimized-embedder.js';
+ possiblePaths.push(packagePath);
+
+ // Try node_modules resolution from different locations
+ try {
+ const path = await import('path');
+ const cwd = process.cwd();
+ possiblePaths.push(
+ path.join(cwd, 'node_modules/agentic-flow/dist/embeddings/optimized-embedder.js'),
+ path.join(cwd, '../node_modules/agentic-flow/dist/embeddings/optimized-embedder.js'),
+ );
+ } catch {
+ // path module not available, skip
+ }
+
+ // Try each path
+ for (const modulePath of possiblePaths) {
+ if (await createEmbedder(modulePath)) {
+ return;
}
}
+
+ throw new Error(
+ `Failed to initialize agentic-flow embeddings. ` +
+ `Ensure agentic-flow is installed and ONNX model is downloaded: ` +
+ `npx agentic-flow@alpha embeddings init`
+ );
}
async embed(text: string): Promise<EmbeddingResult> {