agentic-flow 2.0.13 → 2.1.0
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/CHANGELOG.md +87 -0
- package/README.md +376 -186
- package/dist/.tsbuildinfo +1 -1
- package/dist/agent-booster/index.d.ts +14 -0
- package/dist/agent-booster/index.d.ts.map +1 -0
- package/dist/agent-booster/index.js +25 -0
- package/dist/agent-booster/index.js.map +1 -0
- package/dist/agents/directApiAgent.d.ts.map +1 -1
- package/dist/agents/directApiAgent.js +37 -19
- package/dist/agents/directApiAgent.js.map +1 -1
- package/dist/cli/commands/hooks.d.ts.map +1 -1
- package/dist/cli/commands/hooks.js +4 -1
- package/dist/cli/commands/hooks.js.map +1 -1
- package/dist/cli/mcp-manager.js +13 -6
- package/dist/cli/mcp-manager.js.map +1 -1
- package/dist/harness/provenance.d.ts +72 -0
- package/dist/harness/provenance.d.ts.map +1 -0
- package/dist/harness/provenance.js +92 -0
- package/dist/harness/provenance.js.map +1 -0
- package/dist/intelligence/EmbeddingService.js +3 -3
- package/dist/intelligence/EmbeddingService.js.map +1 -1
- package/dist/intelligence/agent-booster-enhanced.d.ts.map +1 -1
- package/dist/intelligence/agent-booster-enhanced.js +5 -3
- package/dist/intelligence/agent-booster-enhanced.js.map +1 -1
- package/dist/mcp/claudeFlowSdkServer.d.ts.map +1 -1
- package/dist/mcp/claudeFlowSdkServer.js +76 -29
- package/dist/mcp/claudeFlowSdkServer.js.map +1 -1
- package/dist/mcp/fastmcp/servers/claude-flow-sdk.js +27 -22
- package/dist/mcp/fastmcp/servers/claude-flow-sdk.js.map +1 -1
- package/dist/mcp/fastmcp/servers/http-sse.js +31 -20
- package/dist/mcp/fastmcp/servers/http-sse.js.map +1 -1
- package/dist/mcp/fastmcp/servers/http-streaming-updated.js +33 -32
- package/dist/mcp/fastmcp/servers/http-streaming-updated.js.map +1 -1
- package/dist/mcp/fastmcp/servers/poc-stdio.js +10 -11
- package/dist/mcp/fastmcp/servers/poc-stdio.js.map +1 -1
- package/dist/mcp/fastmcp/servers/stdio-full.js +33 -32
- package/dist/mcp/fastmcp/servers/stdio-full.js.map +1 -1
- package/dist/mcp/fastmcp/tools/agent/execute.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/agent/execute.js +8 -5
- package/dist/mcp/fastmcp/tools/agent/execute.js.map +1 -1
- package/dist/mcp/fastmcp/tools/agent/list.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/agent/list.js +4 -2
- package/dist/mcp/fastmcp/tools/agent/list.js.map +1 -1
- package/dist/mcp/fastmcp/tools/agent/parallel.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/agent/parallel.js +4 -2
- package/dist/mcp/fastmcp/tools/agent/parallel.js.map +1 -1
- package/dist/mcp/fastmcp/tools/hooks/pretrain.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/hooks/pretrain.js +11 -3
- package/dist/mcp/fastmcp/tools/hooks/pretrain.js.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/orchestrate.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/orchestrate.js +9 -5
- package/dist/mcp/fastmcp/tools/swarm/orchestrate.js.map +1 -1
- package/dist/mcp/standalone-stdio.js +76 -57
- package/dist/mcp/standalone-stdio.js.map +1 -1
- package/dist/mcp/tools/harness-tools.d.ts +28 -0
- package/dist/mcp/tools/harness-tools.d.ts.map +1 -0
- package/dist/mcp/tools/harness-tools.js +90 -0
- package/dist/mcp/tools/harness-tools.js.map +1 -0
- package/dist/optimizations/configuration-tuning.d.ts +1 -1
- package/dist/reasoningbank/utils/embeddings.d.ts +0 -6
- package/dist/reasoningbank/utils/embeddings.d.ts.map +1 -1
- package/dist/reasoningbank/utils/embeddings.js +9 -43
- package/dist/reasoningbank/utils/embeddings.js.map +1 -1
- package/dist/repair/cli.d.ts +24 -0
- package/dist/repair/cli.d.ts.map +1 -0
- package/dist/repair/cli.js +69 -0
- package/dist/repair/cli.js.map +1 -0
- package/dist/repair/darwin-repair.d.ts +80 -0
- package/dist/repair/darwin-repair.d.ts.map +1 -0
- package/dist/repair/darwin-repair.js +81 -0
- package/dist/repair/darwin-repair.js.map +1 -0
- package/dist/router/cost-optimal-router.d.ts +89 -0
- package/dist/router/cost-optimal-router.d.ts.map +1 -0
- package/dist/router/cost-optimal-router.js +94 -0
- package/dist/router/cost-optimal-router.js.map +1 -0
- package/dist/router/providers/onnx-local-optimized.d.ts +1 -10
- package/dist/router/providers/onnx-local-optimized.d.ts.map +1 -1
- package/dist/router/providers/onnx-local-optimized.js +9 -10
- package/dist/router/providers/onnx-local-optimized.js.map +1 -1
- package/dist/router/providers/onnx-local.d.ts +0 -9
- package/dist/router/providers/onnx-local.d.ts.map +1 -1
- package/dist/router/providers/onnx-local.js +7 -22
- package/dist/router/providers/onnx-local.js.map +1 -1
- package/dist/router/router.d.ts +29 -0
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +83 -0
- package/dist/router/router.js.map +1 -1
- package/dist/router/types.d.ts +1 -1
- package/dist/router/types.d.ts.map +1 -1
- package/dist/router/types.js.map +1 -1
- package/dist/sdk/plugins.d.ts +6 -6
- package/dist/sdk/plugins.d.ts.map +1 -1
- package/dist/sdk/plugins.js +37 -0
- package/dist/sdk/plugins.js.map +1 -1
- package/dist/transport/index.d.ts +1 -0
- package/dist/transport/index.d.ts.map +1 -1
- package/dist/transport/index.js +1 -0
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/quic-loader.d.ts +250 -0
- package/dist/transport/quic-loader.d.ts.map +1 -0
- package/dist/transport/quic-loader.js +507 -0
- package/dist/transport/quic-loader.js.map +1 -0
- package/dist/utils/agentBoosterPreprocessor.js +16 -22
- package/dist/utils/agentBoosterPreprocessor.js.map +1 -1
- package/package.json +21 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentBoosterPreprocessor.js","sourceRoot":"","sources":["../../src/utils/agentBoosterPreprocessor.ts"],"names":[],"mappings":"AA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AAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC;IAED;;OAEG;IACK,uBAAuB,CAAC,IAAY;QAC1C,qCAAqC;QACrC,MAAM,aAAa,GAAG;YACpB,eAAe;YACf,SAAS;YACT,YAAY;SACb,CAAC;QAEF,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;YACpC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,0CAA0C;gBAC1C,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,IAAY;QACpC,wCAAwC;QACxC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,0CAA0C;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,IAAY;QACpC,0CAA0C;QAC1C,0CAA0C;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACK,oBAAoB,CAAC,IAAY;QACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,wDAAwD;YACxD,mFAAmF;YACnF,OAAO,IAAI,CAAC,OAAO,CAAC,8DAA8D,EAAE,EAAE,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/**\n * Agent Booster Pre-Processor\n *\n * Detects code editing intents in agent tasks and attempts Agent Booster\n * pattern matching before falling back to LLM.\n */\n\nimport { execSync } from 'child_process';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { extname } from 'path';\n\nexport interface EditIntent {\n type: string;\n task: string;\n filePath?: string;\n originalCode?: string;\n targetCode?: string;\n confidence: number;\n}\n\nexport interface PreprocessorResult {\n success: boolean;\n method: 'agent_booster' | 'llm_required';\n output?: string;\n latency?: number;\n confidence?: number;\n strategy?: string;\n reason?: string;\n}\n\nexport class AgentBoosterPreprocessor {\n private confidenceThreshold: number;\n private enabledIntents: Set<string>;\n\n constructor(options: {\n confidenceThreshold?: number;\n enabledIntents?: string[];\n } = {}) {\n this.confidenceThreshold = options.confidenceThreshold || 0.7;\n this.enabledIntents = new Set(options.enabledIntents || [\n 'var_to_const',\n 'add_types',\n 'add_error_handling',\n 'async_await',\n 'add_logging',\n 'remove_console',\n 'format_code'\n ]);\n }\n\n /**\n * Detect if a task is a code editing intent that Agent Booster can handle\n */\n public detectIntent(task: string): EditIntent | null {\n const patterns = [\n {\n regex: /convert\\s+(all\\s+)?var\\s+to\\s+const/i,\n type: 'var_to_const',\n extractor: this.extractVarToConst.bind(this)\n },\n {\n regex: /add\\s+type\\s+(annotations?|hints?)/i,\n type: 'add_types',\n extractor: this.extractAddTypes.bind(this)\n },\n {\n regex: /add\\s+error\\s+handling/i,\n type: 'add_error_handling',\n extractor: this.extractAddErrorHandling.bind(this)\n },\n {\n regex: /convert\\s+to\\s+async\\s*\\/?\\s*await/i,\n type: 'async_await',\n extractor: this.extractAsyncAwait.bind(this)\n },\n {\n regex: /add\\s+(logging|console\\.log)/i,\n type: 'add_logging',\n extractor: this.extractAddLogging.bind(this)\n },\n {\n regex: /remove\\s+(all\\s+)?console\\.(log|debug|warn)/i,\n type: 'remove_console',\n extractor: this.extractRemoveConsole.bind(this)\n }\n ];\n\n for (const pattern of patterns) {\n if (pattern.regex.test(task) && this.enabledIntents.has(pattern.type)) {\n const filePath = this.extractFilePath(task);\n if (filePath && existsSync(filePath)) {\n const originalCode = readFileSync(filePath, 'utf-8');\n const targetCode = pattern.extractor(originalCode);\n\n if (targetCode) {\n return {\n type: pattern.type,\n task,\n filePath,\n originalCode,\n targetCode,\n confidence: 0.8 // Initial confidence for pattern match\n };\n }\n }\n }\n }\n\n return null;\n }\n\n /**\n * Try to apply edit using Agent Booster\n */\n public async tryApply(intent: EditIntent): Promise<PreprocessorResult> {\n if (!intent.filePath || !intent.originalCode || !intent.targetCode) {\n return {\n success: false,\n method: 'llm_required',\n reason: 'Missing file path or code'\n };\n }\n\n try {\n const language = this.detectLanguage(intent.filePath);\n\n const cmd = `npx --yes agent-booster@0.2.2 apply --language ${language}`;\n\n let result: string;\n try {\n result = execSync(cmd, {\n encoding: 'utf-8',\n input: JSON.stringify({\n code: intent.originalCode,\n edit: intent.targetCode\n }),\n maxBuffer: 10 * 1024 * 1024,\n timeout: 10000\n });\n } catch (execError: any) {\n // execSync throws on non-zero exit, but agent-booster returns JSON even on stderr\n // Try to parse stdout anyway\n if (execError.stdout) {\n result = execError.stdout.toString();\n } else {\n throw new Error(`execSync failed: ${execError.message}`);\n }\n }\n\n const parsed = JSON.parse(result);\n\n if (parsed.success && parsed.confidence >= this.confidenceThreshold) {\n // High confidence - use Agent Booster result\n writeFileSync(intent.filePath, parsed.output);\n\n return {\n success: true,\n method: 'agent_booster',\n output: parsed.output,\n latency: parsed.latency,\n confidence: parsed.confidence,\n strategy: parsed.strategy\n };\n } else {\n // Low confidence - require LLM\n return {\n success: false,\n method: 'llm_required',\n confidence: parsed.confidence,\n reason: `Agent Booster confidence too low (${(parsed.confidence * 100).toFixed(1)}%). Using LLM for complex edit.`\n };\n }\n } catch (error: any) {\n return {\n success: false,\n method: 'llm_required',\n reason: `Agent Booster error: ${error.message}`\n };\n }\n }\n\n /**\n * Extract file path from task description\n */\n private extractFilePath(task: string): string | null {\n // Pattern: \"in <file>\" or \"to <file>\" or just \"<file.ext>\"\n const patterns = [\n /(?:in|to|from|for|file:?)\\s+([^\\s]+\\.(?:js|ts|tsx|jsx|py|rs|go|java|c|cpp|h|hpp))/i,\n /([^\\s]+\\.(?:js|ts|tsx|jsx|py|rs|go|java|c|cpp|h|hpp))/i\n ];\n\n for (const pattern of patterns) {\n const match = task.match(pattern);\n if (match) {\n return match[1];\n }\n }\n\n return null;\n }\n\n /**\n * Detect programming language from file extension\n */\n private detectLanguage(filePath: string): string {\n const ext = extname(filePath).slice(1);\n const langMap: { [key: string]: string } = {\n 'ts': 'typescript',\n 'tsx': 'typescript',\n 'js': 'javascript',\n 'jsx': 'javascript',\n 'py': 'python',\n 'rs': 'rust',\n 'go': 'go',\n 'java': 'java',\n 'c': 'c',\n 'cpp': 'cpp',\n 'h': 'c',\n 'hpp': 'cpp'\n };\n return langMap[ext] || 'javascript';\n }\n\n /**\n * Extract var to const transformation\n */\n private extractVarToConst(code: string): string | null {\n // Simple transformation: replace var with const\n if (code.includes('var ')) {\n return code.replace(/\\bvar\\b/g, 'const');\n }\n return null;\n }\n\n /**\n * Extract add types transformation (TypeScript)\n */\n private extractAddTypes(code: string): string | null {\n // Simple type annotation: function params and return types\n const functionPattern = /function\\s+(\\w+)\\s*\\(([^)]*)\\)\\s*\\{/g;\n\n let hasUntypedFunctions = false;\n let transformed = code;\n\n code.replace(functionPattern, (match, name, params) => {\n if (!params.includes(':')) {\n hasUntypedFunctions = true;\n // Add basic type hints\n const typedParams = params.split(',').map((p: string) => {\n const trimmed = p.trim();\n if (trimmed && !trimmed.includes(':')) {\n return `${trimmed}: any`;\n }\n return p;\n }).join(', ');\n\n transformed = transformed.replace(\n match,\n `function ${name}(${typedParams}): any {`\n );\n }\n return match;\n });\n\n return hasUntypedFunctions ? transformed : null;\n }\n\n /**\n * Extract add error handling transformation\n */\n private extractAddErrorHandling(code: string): string | null {\n // Wrap risky operations in try-catch\n const riskyPatterns = [\n /JSON\\.parse\\(/,\n /fetch\\(/,\n /\\bawait\\s+/\n ];\n\n for (const pattern of riskyPatterns) {\n if (pattern.test(code)) {\n // This is complex - better handled by LLM\n return null;\n }\n }\n\n return null;\n }\n\n /**\n * Extract async/await transformation\n */\n private extractAsyncAwait(code: string): string | null {\n // Convert .then() chains to async/await\n if (code.includes('.then(')) {\n // This is complex - better handled by LLM\n return null;\n }\n return null;\n }\n\n /**\n * Extract add logging transformation\n */\n private extractAddLogging(code: string): string | null {\n // Add console.log before function returns\n // This is complex - better handled by LLM\n return null;\n }\n\n /**\n * Extract remove console transformation\n */\n private extractRemoveConsole(code: string): string | null {\n if (code.includes('console.')) {\n // Remove console statements but preserve line structure\n // Match optional leading whitespace, console call, and keep one newline if present\n return code.replace(/^[ \\t]*console\\.(log|debug|warn|info|error)\\([^)]*\\);?\\s*$/gm, '');\n }\n return null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agentBoosterPreprocessor.js","sourceRoot":"","sources":["../../src/utils/agentBoosterPreprocessor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAqB/B,MAAM,OAAO,wBAAwB;IAC3B,mBAAmB,CAAS;IAC5B,cAAc,CAAc;IAEpC,YAAY,UAGR,EAAE;QACJ,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,GAAG,CAAC;QAC9D,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI;YACtD,cAAc;YACd,WAAW;YACX,oBAAoB;YACpB,aAAa;YACb,aAAa;YACb,gBAAgB;YAChB,aAAa;SACd,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,IAAY;QAC9B,MAAM,QAAQ,GAAG;YACf;gBACE,KAAK,EAAE,sCAAsC;gBAC7C,IAAI,EAAE,cAAc;gBACpB,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;aAC7C;YACD;gBACE,KAAK,EAAE,qCAAqC;gBAC5C,IAAI,EAAE,WAAW;gBACjB,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;aAC3C;YACD;gBACE,KAAK,EAAE,y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,CAAC,EAAE,CAAC;YAC9B,wDAAwD;YACxD,mFAAmF;YACnF,OAAO,IAAI,CAAC,OAAO,CAAC,8DAA8D,EAAE,EAAE,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/**\n * Agent Booster Pre-Processor\n *\n * Detects code editing intents in agent tasks and attempts Agent Booster\n * pattern matching before falling back to LLM.\n */\n\nimport { spawnSync } from 'child_process';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { extname } from 'path';\n\nexport interface EditIntent {\n type: string;\n task: string;\n filePath?: string;\n originalCode?: string;\n targetCode?: string;\n confidence: number;\n}\n\nexport interface PreprocessorResult {\n success: boolean;\n method: 'agent_booster' | 'llm_required';\n output?: string;\n latency?: number;\n confidence?: number;\n strategy?: string;\n reason?: string;\n}\n\nexport class AgentBoosterPreprocessor {\n private confidenceThreshold: number;\n private enabledIntents: Set<string>;\n\n constructor(options: {\n confidenceThreshold?: number;\n enabledIntents?: string[];\n } = {}) {\n this.confidenceThreshold = options.confidenceThreshold || 0.7;\n this.enabledIntents = new Set(options.enabledIntents || [\n 'var_to_const',\n 'add_types',\n 'add_error_handling',\n 'async_await',\n 'add_logging',\n 'remove_console',\n 'format_code'\n ]);\n }\n\n /**\n * Detect if a task is a code editing intent that Agent Booster can handle\n */\n public detectIntent(task: string): EditIntent | null {\n const patterns = [\n {\n regex: /convert\\s+(all\\s+)?var\\s+to\\s+const/i,\n type: 'var_to_const',\n extractor: this.extractVarToConst.bind(this)\n },\n {\n regex: /add\\s+type\\s+(annotations?|hints?)/i,\n type: 'add_types',\n extractor: this.extractAddTypes.bind(this)\n },\n {\n regex: /add\\s+error\\s+handling/i,\n type: 'add_error_handling',\n extractor: this.extractAddErrorHandling.bind(this)\n },\n {\n regex: /convert\\s+to\\s+async\\s*\\/?\\s*await/i,\n type: 'async_await',\n extractor: this.extractAsyncAwait.bind(this)\n },\n {\n regex: /add\\s+(logging|console\\.log)/i,\n type: 'add_logging',\n extractor: this.extractAddLogging.bind(this)\n },\n {\n regex: /remove\\s+(all\\s+)?console\\.(log|debug|warn)/i,\n type: 'remove_console',\n extractor: this.extractRemoveConsole.bind(this)\n }\n ];\n\n for (const pattern of patterns) {\n if (pattern.regex.test(task) && this.enabledIntents.has(pattern.type)) {\n const filePath = this.extractFilePath(task);\n if (filePath && existsSync(filePath)) {\n const originalCode = readFileSync(filePath, 'utf-8');\n const targetCode = pattern.extractor(originalCode);\n\n if (targetCode) {\n return {\n type: pattern.type,\n task,\n filePath,\n originalCode,\n targetCode,\n confidence: 0.8 // Initial confidence for pattern match\n };\n }\n }\n }\n }\n\n return null;\n }\n\n /**\n * Try to apply edit using Agent Booster\n */\n public async tryApply(intent: EditIntent): Promise<PreprocessorResult> {\n if (!intent.filePath || !intent.originalCode || !intent.targetCode) {\n return {\n success: false,\n method: 'llm_required',\n reason: 'Missing file path or code'\n };\n }\n\n try {\n const language = this.detectLanguage(intent.filePath);\n\n // Use spawnSync with argument array to prevent shell injection from `language`\n const spawnResult = spawnSync(\n 'npx',\n ['--yes', 'agent-booster@0.2.2', 'apply', '--language', language],\n {\n encoding: 'utf-8',\n input: JSON.stringify({\n code: intent.originalCode,\n edit: intent.targetCode\n }),\n maxBuffer: 10 * 1024 * 1024,\n timeout: 10000\n }\n );\n\n if (spawnResult.error) {\n throw new Error(`spawnSync failed: ${spawnResult.error.message}`);\n }\n if (spawnResult.status !== 0 && !spawnResult.stdout) {\n throw new Error(`agent-booster exited with code ${spawnResult.status}: ${spawnResult.stderr}`);\n }\n const result: string = spawnResult.stdout || spawnResult.stderr || '';\n\n const parsed = JSON.parse(result);\n\n if (parsed.success && parsed.confidence >= this.confidenceThreshold) {\n // High confidence - use Agent Booster result\n writeFileSync(intent.filePath, parsed.output);\n\n return {\n success: true,\n method: 'agent_booster',\n output: parsed.output,\n latency: parsed.latency,\n confidence: parsed.confidence,\n strategy: parsed.strategy\n };\n } else {\n // Low confidence - require LLM\n return {\n success: false,\n method: 'llm_required',\n confidence: parsed.confidence,\n reason: `Agent Booster confidence too low (${(parsed.confidence * 100).toFixed(1)}%). Using LLM for complex edit.`\n };\n }\n } catch (error: any) {\n return {\n success: false,\n method: 'llm_required',\n reason: `Agent Booster error: ${error.message}`\n };\n }\n }\n\n /**\n * Extract file path from task description\n */\n private extractFilePath(task: string): string | null {\n // Pattern: \"in <file>\" or \"to <file>\" or just \"<file.ext>\"\n const patterns = [\n /(?:in|to|from|for|file:?)\\s+([^\\s]+\\.(?:js|ts|tsx|jsx|py|rs|go|java|c|cpp|h|hpp))/i,\n /([^\\s]+\\.(?:js|ts|tsx|jsx|py|rs|go|java|c|cpp|h|hpp))/i\n ];\n\n for (const pattern of patterns) {\n const match = task.match(pattern);\n if (match) {\n return match[1];\n }\n }\n\n return null;\n }\n\n /**\n * Detect programming language from file extension\n */\n private detectLanguage(filePath: string): string {\n const ext = extname(filePath).slice(1);\n const langMap: { [key: string]: string } = {\n 'ts': 'typescript',\n 'tsx': 'typescript',\n 'js': 'javascript',\n 'jsx': 'javascript',\n 'py': 'python',\n 'rs': 'rust',\n 'go': 'go',\n 'java': 'java',\n 'c': 'c',\n 'cpp': 'cpp',\n 'h': 'c',\n 'hpp': 'cpp'\n };\n return langMap[ext] || 'javascript';\n }\n\n /**\n * Extract var to const transformation\n */\n private extractVarToConst(code: string): string | null {\n // Simple transformation: replace var with const\n if (code.includes('var ')) {\n return code.replace(/\\bvar\\b/g, 'const');\n }\n return null;\n }\n\n /**\n * Extract add types transformation (TypeScript)\n */\n private extractAddTypes(code: string): string | null {\n // Simple type annotation: function params and return types\n const functionPattern = /function\\s+(\\w+)\\s*\\(([^)]*)\\)\\s*\\{/g;\n\n let hasUntypedFunctions = false;\n let transformed = code;\n\n code.replace(functionPattern, (match, name, params) => {\n if (!params.includes(':')) {\n hasUntypedFunctions = true;\n // Add basic type hints\n const typedParams = params.split(',').map((p: string) => {\n const trimmed = p.trim();\n if (trimmed && !trimmed.includes(':')) {\n return `${trimmed}: any`;\n }\n return p;\n }).join(', ');\n\n transformed = transformed.replace(\n match,\n `function ${name}(${typedParams}): any {`\n );\n }\n return match;\n });\n\n return hasUntypedFunctions ? transformed : null;\n }\n\n /**\n * Extract add error handling transformation\n */\n private extractAddErrorHandling(code: string): string | null {\n // Wrap risky operations in try-catch\n const riskyPatterns = [\n /JSON\\.parse\\(/,\n /fetch\\(/,\n /\\bawait\\s+/\n ];\n\n for (const pattern of riskyPatterns) {\n if (pattern.test(code)) {\n // This is complex - better handled by LLM\n return null;\n }\n }\n\n return null;\n }\n\n /**\n * Extract async/await transformation\n */\n private extractAsyncAwait(code: string): string | null {\n // Convert .then() chains to async/await\n if (code.includes('.then(')) {\n // This is complex - better handled by LLM\n return null;\n }\n return null;\n }\n\n /**\n * Extract add logging transformation\n */\n private extractAddLogging(code: string): string | null {\n // Add console.log before function returns\n // This is complex - better handled by LLM\n return null;\n }\n\n /**\n * Extract remove console transformation\n */\n private extractRemoveConsole(code: string): string | null {\n if (code.includes('console.')) {\n // Remove console statements but preserve line structure\n // Match optional leading whitespace, console call, and keep one newline if present\n return code.replace(/^[ \\t]*console\\.(log|debug|warn|info|error)\\([^)]*\\);?\\s*$/gm, '');\n }\n return null;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-flow",
|
|
3
|
-
"version": "2.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "The agentic meta-harness — freeze the model, evolve the harness. An open runtime that routes each query to the cost-optimal model, evolves its own harness (planner/context/reviewer/retry/tool/memory/score policy) and autonomously repairs code, then orchestrates 66 specialized agents, 213 MCP tools, ReasoningBank memory, and multi-agent swarms on top. Built by @ruvnet on the Claude Agent SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"agentic-flow": "dist/cli-proxy.js",
|
|
9
|
-
"agentdb": "dist/agentdb/cli/agentdb-cli.js"
|
|
9
|
+
"agentdb": "dist/agentdb/cli/agentdb-cli.js",
|
|
10
|
+
"agentic-flow-repair": "dist/repair/cli.js"
|
|
10
11
|
},
|
|
11
12
|
"exports": {
|
|
12
13
|
".": "./dist/index.js",
|
|
@@ -21,9 +22,13 @@
|
|
|
21
22
|
"./reasoningbank/backend-selector": "./dist/reasoningbank/backend-selector.js",
|
|
22
23
|
"./reasoningbank/wasm-adapter": "./dist/reasoningbank/wasm-adapter.js",
|
|
23
24
|
"./router": "./dist/router/index.js",
|
|
25
|
+
"./router/cost-optimal": "./dist/router/cost-optimal-router.js",
|
|
26
|
+
"./repair": "./dist/repair/darwin-repair.js",
|
|
27
|
+
"./harness/provenance": "./dist/harness/provenance.js",
|
|
24
28
|
"./agent-booster": "./dist/agent-booster/index.js",
|
|
25
29
|
"./transport/quic": "./dist/transport/quic.js",
|
|
26
|
-
"./embeddings": "./dist/embeddings/index.js"
|
|
30
|
+
"./embeddings": "./dist/embeddings/index.js",
|
|
31
|
+
"./transport/loader": "./dist/transport/quic-loader.js"
|
|
27
32
|
},
|
|
28
33
|
"scripts": {
|
|
29
34
|
"postinstall": "node scripts/postinstall.js || true",
|
|
@@ -65,6 +70,14 @@
|
|
|
65
70
|
"test:orchestration:smoke": "tsx tests/orchestration/orchestration-api.smoke.ts && tsx tests/orchestration/loop-policy.smoke.ts && tsx tests/orchestration/memory-plane.smoke.ts"
|
|
66
71
|
},
|
|
67
72
|
"keywords": [
|
|
73
|
+
"meta-harness",
|
|
74
|
+
"metaharness",
|
|
75
|
+
"agent-harness",
|
|
76
|
+
"harness-evolution",
|
|
77
|
+
"model-routing",
|
|
78
|
+
"cost-optimal-routing",
|
|
79
|
+
"self-improving",
|
|
80
|
+
"darwin",
|
|
68
81
|
"ai",
|
|
69
82
|
"ai-agents",
|
|
70
83
|
"ai-orchestration",
|
|
@@ -151,12 +164,15 @@
|
|
|
151
164
|
"@anthropic-ai/claude-agent-sdk": "^0.1.5",
|
|
152
165
|
"@anthropic-ai/sdk": "^0.65.0",
|
|
153
166
|
"@google/genai": "^1.22.0",
|
|
167
|
+
"@metaharness/darwin": "^0.7.0",
|
|
168
|
+
"@metaharness/router": "^0.3.2",
|
|
154
169
|
"@ruvector/core": "^0.1.29",
|
|
155
170
|
"@ruvector/edge-full": "^0.1.0",
|
|
156
171
|
"@ruvector/router": "^0.1.25",
|
|
157
172
|
"@ruvector/ruvllm": "^0.2.3",
|
|
158
173
|
"@ruvector/tiny-dancer": "^0.1.17",
|
|
159
174
|
"@supabase/supabase-js": "^2.78.0",
|
|
175
|
+
"@xenova/transformers": "^2.17.2",
|
|
160
176
|
"axios": "^1.12.2",
|
|
161
177
|
"dotenv": "^16.4.5",
|
|
162
178
|
"express": "^5.1.0",
|
|
@@ -168,7 +184,7 @@
|
|
|
168
184
|
"ruvector-onnx-embeddings-wasm": "^0.1.2",
|
|
169
185
|
"tiktoken": "^1.0.22",
|
|
170
186
|
"ulid": "^3.0.1",
|
|
171
|
-
"ws": "^8.
|
|
187
|
+
"ws": "^8.20.0",
|
|
172
188
|
"yaml": "^2.8.1",
|
|
173
189
|
"zod": "^3.25.76"
|
|
174
190
|
},
|
|
@@ -176,7 +192,6 @@
|
|
|
176
192
|
"@rollup/rollup-darwin-arm64": "^4.59.0",
|
|
177
193
|
"@ruvector/attention": "^0.1.4",
|
|
178
194
|
"@ruvector/sona": "^0.1.4",
|
|
179
|
-
"@xenova/transformers": "^2.17.2",
|
|
180
195
|
"agentdb": "^3.0.0-alpha.14",
|
|
181
196
|
"better-sqlite3": "^11.10.0",
|
|
182
197
|
"onnxruntime-node": "^1.23.2",
|