diff --git a/v3/@claude-flow/embeddings/src/embedding-service.ts b/v3/@claude-flow/embeddings/src/embedding-service.ts index 0ecf11a98d..5e60052094 100644 --- a/v3/@claude-flow/embeddings/src/embedding-service.ts +++ b/v3/@claude-flow/embeddings/src/embedding-service.ts @@ -788,6 +788,35 @@ async function isAgenticFlowAvailable(): Promise { } } +/** + * Auto-install agentic-flow and initialize model + */ +async function autoInstallAgenticFlow(): Promise { + const { exec } = await import('child_process'); + const { promisify } = await import('util'); + const execAsync = promisify(exec); + + try { + // Check if already available + if (await isAgenticFlowAvailable()) { + return true; + } + + console.log('[embeddings] Installing agentic-flow@alpha...'); + await execAsync('npm install agentic-flow@alpha --save', { timeout: 120000 }); + + // Initialize the model + console.log('[embeddings] Downloading embedding model...'); + await execAsync('npx agentic-flow@alpha embeddings init', { timeout: 300000 }); + + // Verify installation + return await isAgenticFlowAvailable(); + } catch (error) { + console.warn('[embeddings] Auto-install failed:', error instanceof Error ? error.message : error); + return false; + } +} + /** * Create embedding service based on configuration (sync version) * Note: For 'auto' provider or smart fallback, use createEmbeddingServiceAsync