agentic-flow 1.0.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/.claude/agents/MIGRATION_SUMMARY.md +222 -0
- package/.claude/agents/README.md +89 -0
- package/.claude/agents/analysis/code-analyzer.md +209 -0
- package/.claude/agents/analysis/code-review/analyze-code-quality.md +180 -0
- package/.claude/agents/architecture/system-design/arch-system-design.md +156 -0
- package/.claude/agents/base-template-generator.md +42 -0
- package/.claude/agents/consensus/README.md +253 -0
- package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
- package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
- package/.claude/agents/consensus/gossip-coordinator.md +63 -0
- package/.claude/agents/consensus/performance-benchmarker.md +851 -0
- package/.claude/agents/consensus/quorum-manager.md +823 -0
- package/.claude/agents/consensus/raft-manager.md +63 -0
- package/.claude/agents/consensus/security-manager.md +622 -0
- package/.claude/agents/core/coder.md +211 -0
- package/.claude/agents/core/planner.md +116 -0
- package/.claude/agents/core/researcher.md +136 -0
- package/.claude/agents/core/reviewer.md +272 -0
- package/.claude/agents/core/tester.md +266 -0
- package/.claude/agents/data/ml/data-ml-model.md +193 -0
- package/.claude/agents/development/backend/dev-backend-api.md +142 -0
- package/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
- package/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
- package/.claude/agents/flow-nexus/app-store.md +88 -0
- package/.claude/agents/flow-nexus/authentication.md +69 -0
- package/.claude/agents/flow-nexus/challenges.md +81 -0
- package/.claude/agents/flow-nexus/neural-network.md +88 -0
- package/.claude/agents/flow-nexus/payments.md +83 -0
- package/.claude/agents/flow-nexus/sandbox.md +76 -0
- package/.claude/agents/flow-nexus/swarm.md +76 -0
- package/.claude/agents/flow-nexus/user-tools.md +96 -0
- package/.claude/agents/flow-nexus/workflow.md +84 -0
- package/.claude/agents/github/code-review-swarm.md +538 -0
- package/.claude/agents/github/github-modes.md +173 -0
- package/.claude/agents/github/issue-tracker.md +319 -0
- package/.claude/agents/github/multi-repo-swarm.md +553 -0
- package/.claude/agents/github/pr-manager.md +191 -0
- package/.claude/agents/github/project-board-sync.md +509 -0
- package/.claude/agents/github/release-manager.md +367 -0
- package/.claude/agents/github/release-swarm.md +583 -0
- package/.claude/agents/github/repo-architect.md +398 -0
- package/.claude/agents/github/swarm-issue.md +573 -0
- package/.claude/agents/github/swarm-pr.md +428 -0
- package/.claude/agents/github/sync-coordinator.md +452 -0
- package/.claude/agents/github/workflow-automation.md +635 -0
- package/.claude/agents/goal/agent.md +816 -0
- package/.claude/agents/goal/goal-planner.md +73 -0
- package/.claude/agents/optimization/README.md +250 -0
- package/.claude/agents/optimization/benchmark-suite.md +665 -0
- package/.claude/agents/optimization/load-balancer.md +431 -0
- package/.claude/agents/optimization/performance-monitor.md +672 -0
- package/.claude/agents/optimization/resource-allocator.md +674 -0
- package/.claude/agents/optimization/topology-optimizer.md +808 -0
- package/.claude/agents/payments/agentic-payments.md +126 -0
- package/.claude/agents/sparc/architecture.md +472 -0
- package/.claude/agents/sparc/pseudocode.md +318 -0
- package/.claude/agents/sparc/refinement.md +525 -0
- package/.claude/agents/sparc/specification.md +276 -0
- package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +226 -0
- package/.claude/agents/sublinear/consensus-coordinator.md +338 -0
- package/.claude/agents/sublinear/matrix-optimizer.md +185 -0
- package/.claude/agents/sublinear/pagerank-analyzer.md +299 -0
- package/.claude/agents/sublinear/performance-optimizer.md +368 -0
- package/.claude/agents/sublinear/trading-predictor.md +246 -0
- package/.claude/agents/swarm/README.md +190 -0
- package/.claude/agents/swarm/adaptive-coordinator.md +396 -0
- package/.claude/agents/swarm/hierarchical-coordinator.md +256 -0
- package/.claude/agents/swarm/mesh-coordinator.md +392 -0
- package/.claude/agents/templates/automation-smart-agent.md +205 -0
- package/.claude/agents/templates/coordinator-swarm-init.md +90 -0
- package/.claude/agents/templates/github-pr-manager.md +177 -0
- package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
- package/.claude/agents/templates/memory-coordinator.md +187 -0
- package/.claude/agents/templates/migration-plan.md +746 -0
- package/.claude/agents/templates/orchestrator-task.md +139 -0
- package/.claude/agents/templates/performance-analyzer.md +199 -0
- package/.claude/agents/templates/sparc-coordinator.md +183 -0
- package/.claude/agents/test-neural.md +14 -0
- package/.claude/agents/testing/unit/tdd-london-swarm.md +244 -0
- package/.claude/agents/testing/validation/production-validator.md +395 -0
- package/.claude/commands/agents/README.md +10 -0
- package/.claude/commands/agents/agent-capabilities.md +21 -0
- package/.claude/commands/agents/agent-coordination.md +28 -0
- package/.claude/commands/agents/agent-spawning.md +28 -0
- package/.claude/commands/agents/agent-types.md +26 -0
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
- package/.claude/commands/analysis/README.md +9 -0
- package/.claude/commands/analysis/bottleneck-detect.md +162 -0
- package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
- package/.claude/commands/analysis/performance-report.md +25 -0
- package/.claude/commands/analysis/token-efficiency.md +45 -0
- package/.claude/commands/analysis/token-usage.md +25 -0
- package/.claude/commands/automation/README.md +9 -0
- package/.claude/commands/automation/auto-agent.md +122 -0
- package/.claude/commands/automation/self-healing.md +106 -0
- package/.claude/commands/automation/session-memory.md +90 -0
- package/.claude/commands/automation/smart-agents.md +73 -0
- package/.claude/commands/automation/smart-spawn.md +25 -0
- package/.claude/commands/automation/workflow-select.md +25 -0
- package/.claude/commands/claude-flow-help.md +103 -0
- package/.claude/commands/claude-flow-memory.md +107 -0
- package/.claude/commands/claude-flow-swarm.md +205 -0
- package/.claude/commands/coordination/README.md +9 -0
- package/.claude/commands/coordination/agent-spawn.md +25 -0
- package/.claude/commands/coordination/init.md +44 -0
- package/.claude/commands/coordination/orchestrate.md +43 -0
- package/.claude/commands/coordination/spawn.md +45 -0
- package/.claude/commands/coordination/swarm-init.md +85 -0
- package/.claude/commands/coordination/task-orchestrate.md +25 -0
- package/.claude/commands/flow-nexus/app-store.md +124 -0
- package/.claude/commands/flow-nexus/challenges.md +120 -0
- package/.claude/commands/flow-nexus/login-registration.md +65 -0
- package/.claude/commands/flow-nexus/neural-network.md +134 -0
- package/.claude/commands/flow-nexus/payments.md +116 -0
- package/.claude/commands/flow-nexus/sandbox.md +83 -0
- package/.claude/commands/flow-nexus/swarm.md +87 -0
- package/.claude/commands/flow-nexus/user-tools.md +152 -0
- package/.claude/commands/flow-nexus/workflow.md +115 -0
- package/.claude/commands/github/README.md +11 -0
- package/.claude/commands/github/code-review-swarm.md +514 -0
- package/.claude/commands/github/code-review.md +25 -0
- package/.claude/commands/github/github-modes.md +147 -0
- package/.claude/commands/github/github-swarm.md +121 -0
- package/.claude/commands/github/issue-tracker.md +292 -0
- package/.claude/commands/github/issue-triage.md +25 -0
- package/.claude/commands/github/multi-repo-swarm.md +519 -0
- package/.claude/commands/github/pr-enhance.md +26 -0
- package/.claude/commands/github/pr-manager.md +170 -0
- package/.claude/commands/github/project-board-sync.md +471 -0
- package/.claude/commands/github/release-manager.md +338 -0
- package/.claude/commands/github/release-swarm.md +544 -0
- package/.claude/commands/github/repo-analyze.md +25 -0
- package/.claude/commands/github/repo-architect.md +367 -0
- package/.claude/commands/github/swarm-issue.md +482 -0
- package/.claude/commands/github/swarm-pr.md +285 -0
- package/.claude/commands/github/sync-coordinator.md +301 -0
- package/.claude/commands/github/workflow-automation.md +442 -0
- package/.claude/commands/hive-mind/README.md +17 -0
- package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-init.md +18 -0
- package/.claude/commands/hive-mind/hive-mind-memory.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-resume.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -0
- package/.claude/commands/hive-mind/hive-mind-status.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-stop.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -0
- package/.claude/commands/hive-mind/hive-mind.md +27 -0
- package/.claude/commands/hooks/README.md +11 -0
- package/.claude/commands/hooks/overview.md +58 -0
- package/.claude/commands/hooks/post-edit.md +117 -0
- package/.claude/commands/hooks/post-task.md +112 -0
- package/.claude/commands/hooks/pre-edit.md +113 -0
- package/.claude/commands/hooks/pre-task.md +111 -0
- package/.claude/commands/hooks/session-end.md +118 -0
- package/.claude/commands/hooks/setup.md +103 -0
- package/.claude/commands/memory/README.md +9 -0
- package/.claude/commands/memory/memory-persist.md +25 -0
- package/.claude/commands/memory/memory-search.md +25 -0
- package/.claude/commands/memory/memory-usage.md +25 -0
- package/.claude/commands/memory/neural.md +47 -0
- package/.claude/commands/memory/usage.md +46 -0
- package/.claude/commands/monitoring/README.md +9 -0
- package/.claude/commands/monitoring/agent-metrics.md +25 -0
- package/.claude/commands/monitoring/agents.md +44 -0
- package/.claude/commands/monitoring/real-time-view.md +25 -0
- package/.claude/commands/monitoring/status.md +46 -0
- package/.claude/commands/monitoring/swarm-monitor.md +25 -0
- package/.claude/commands/optimization/README.md +9 -0
- package/.claude/commands/optimization/auto-topology.md +62 -0
- package/.claude/commands/optimization/cache-manage.md +25 -0
- package/.claude/commands/optimization/parallel-execute.md +25 -0
- package/.claude/commands/optimization/parallel-execution.md +50 -0
- package/.claude/commands/optimization/topology-optimize.md +25 -0
- package/.claude/commands/pair/README.md +261 -0
- package/.claude/commands/pair/commands.md +546 -0
- package/.claude/commands/pair/config.md +510 -0
- package/.claude/commands/pair/examples.md +512 -0
- package/.claude/commands/pair/modes.md +348 -0
- package/.claude/commands/pair/session.md +407 -0
- package/.claude/commands/pair/start.md +209 -0
- package/.claude/commands/sparc/analyzer.md +52 -0
- package/.claude/commands/sparc/architect.md +53 -0
- package/.claude/commands/sparc/ask.md +97 -0
- package/.claude/commands/sparc/batch-executor.md +54 -0
- package/.claude/commands/sparc/code.md +89 -0
- package/.claude/commands/sparc/coder.md +54 -0
- package/.claude/commands/sparc/debug.md +83 -0
- package/.claude/commands/sparc/debugger.md +54 -0
- package/.claude/commands/sparc/designer.md +53 -0
- package/.claude/commands/sparc/devops.md +109 -0
- package/.claude/commands/sparc/docs-writer.md +80 -0
- package/.claude/commands/sparc/documenter.md +54 -0
- package/.claude/commands/sparc/innovator.md +54 -0
- package/.claude/commands/sparc/integration.md +83 -0
- package/.claude/commands/sparc/mcp.md +117 -0
- package/.claude/commands/sparc/memory-manager.md +54 -0
- package/.claude/commands/sparc/optimizer.md +54 -0
- package/.claude/commands/sparc/orchestrator.md +132 -0
- package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -0
- package/.claude/commands/sparc/refinement-optimization-mode.md +83 -0
- package/.claude/commands/sparc/researcher.md +54 -0
- package/.claude/commands/sparc/reviewer.md +54 -0
- package/.claude/commands/sparc/security-review.md +80 -0
- package/.claude/commands/sparc/sparc-modes.md +174 -0
- package/.claude/commands/sparc/sparc.md +111 -0
- package/.claude/commands/sparc/spec-pseudocode.md +80 -0
- package/.claude/commands/sparc/supabase-admin.md +348 -0
- package/.claude/commands/sparc/swarm-coordinator.md +54 -0
- package/.claude/commands/sparc/tdd.md +54 -0
- package/.claude/commands/sparc/tester.md +54 -0
- package/.claude/commands/sparc/tutorial.md +79 -0
- package/.claude/commands/sparc/workflow-manager.md +54 -0
- package/.claude/commands/sparc.md +166 -0
- package/.claude/commands/stream-chain/pipeline.md +121 -0
- package/.claude/commands/stream-chain/run.md +70 -0
- package/.claude/commands/swarm/README.md +15 -0
- package/.claude/commands/swarm/analysis.md +95 -0
- package/.claude/commands/swarm/development.md +96 -0
- package/.claude/commands/swarm/examples.md +168 -0
- package/.claude/commands/swarm/maintenance.md +102 -0
- package/.claude/commands/swarm/optimization.md +117 -0
- package/.claude/commands/swarm/research.md +136 -0
- package/.claude/commands/swarm/swarm-analysis.md +8 -0
- package/.claude/commands/swarm/swarm-background.md +8 -0
- package/.claude/commands/swarm/swarm-init.md +19 -0
- package/.claude/commands/swarm/swarm-modes.md +8 -0
- package/.claude/commands/swarm/swarm-monitor.md +8 -0
- package/.claude/commands/swarm/swarm-spawn.md +19 -0
- package/.claude/commands/swarm/swarm-status.md +8 -0
- package/.claude/commands/swarm/swarm-strategies.md +8 -0
- package/.claude/commands/swarm/swarm.md +27 -0
- package/.claude/commands/swarm/testing.md +131 -0
- package/.claude/commands/training/README.md +9 -0
- package/.claude/commands/training/model-update.md +25 -0
- package/.claude/commands/training/neural-patterns.md +74 -0
- package/.claude/commands/training/neural-train.md +25 -0
- package/.claude/commands/training/pattern-learn.md +25 -0
- package/.claude/commands/training/specialization.md +63 -0
- package/.claude/commands/truth/start.md +143 -0
- package/.claude/commands/verify/check.md +50 -0
- package/.claude/commands/verify/start.md +128 -0
- package/.claude/commands/workflows/README.md +9 -0
- package/.claude/commands/workflows/development.md +78 -0
- package/.claude/commands/workflows/research.md +63 -0
- package/.claude/commands/workflows/workflow-create.md +25 -0
- package/.claude/commands/workflows/workflow-execute.md +25 -0
- package/.claude/commands/workflows/workflow-export.md +25 -0
- package/.claude/helpers/checkpoint-manager.sh +251 -0
- package/.claude/helpers/github-safe.js +106 -0
- package/.claude/helpers/github-setup.sh +28 -0
- package/.claude/helpers/quick-start.sh +19 -0
- package/.claude/helpers/setup-mcp.sh +18 -0
- package/.claude/helpers/standard-checkpoint-hooks.sh +179 -0
- package/.claude/mcp.json +13 -0
- package/.claude/settings-backup.json +130 -0
- package/.claude/settings-optimized.json +116 -0
- package/.claude/settings-simple.json +78 -0
- package/.claude/settings.json +114 -0
- package/.claude/settings.local.json +14 -0
- package/README.md +1280 -0
- package/dist/agents/claudeAgent.js +73 -0
- package/dist/agents/claudeFlowAgent.js +115 -0
- package/dist/agents/codeReviewAgent.js +34 -0
- package/dist/agents/dataAgent.js +34 -0
- package/dist/agents/directApiAgent.js +260 -0
- package/dist/agents/webResearchAgent.js +35 -0
- package/dist/cli/mcp.js +135 -0
- package/dist/cli-proxy.js +246 -0
- package/dist/cli.js +158 -0
- package/dist/config/claudeFlow.js +67 -0
- package/dist/config/tools.js +33 -0
- package/dist/coordination/parallelSwarm.js +226 -0
- package/dist/examples/multi-agent-orchestration.js +45 -0
- package/dist/examples/parallel-swarm-deployment.js +171 -0
- package/dist/examples/use-goal-planner.js +52 -0
- package/dist/health.js +46 -0
- package/dist/index-with-proxy.js +101 -0
- package/dist/index.js +167 -0
- package/dist/mcp/claudeFlowSdkServer.js +202 -0
- package/dist/mcp/fastmcp/servers/claude-flow-sdk.js +198 -0
- package/dist/mcp/fastmcp/servers/http-streaming-updated.js +421 -0
- package/dist/mcp/fastmcp/servers/poc-stdio.js +82 -0
- package/dist/mcp/fastmcp/servers/stdio-full.js +421 -0
- package/dist/mcp/fastmcp/tools/agent/add-agent.js +107 -0
- package/dist/mcp/fastmcp/tools/agent/add-command.js +117 -0
- package/dist/mcp/fastmcp/tools/agent/execute.js +56 -0
- package/dist/mcp/fastmcp/tools/agent/list.js +82 -0
- package/dist/mcp/fastmcp/tools/agent/parallel.js +63 -0
- package/dist/mcp/fastmcp/tools/memory/retrieve.js +38 -0
- package/dist/mcp/fastmcp/tools/memory/search.js +41 -0
- package/dist/mcp/fastmcp/tools/memory/store.js +56 -0
- package/dist/mcp/fastmcp/tools/swarm/init.js +41 -0
- package/dist/mcp/fastmcp/tools/swarm/orchestrate.js +47 -0
- package/dist/mcp/fastmcp/tools/swarm/spawn.js +40 -0
- package/dist/mcp/fastmcp/types/index.js +2 -0
- package/dist/proxy/anthropic-to-openrouter.js +246 -0
- package/dist/router/providers/anthropic.js +89 -0
- package/dist/router/providers/onnx-local-optimized.js +167 -0
- package/dist/router/providers/onnx-local.js +294 -0
- package/dist/router/providers/onnx-phi4.js +190 -0
- package/dist/router/providers/onnx.js +242 -0
- package/dist/router/providers/openrouter.js +242 -0
- package/dist/router/router.js +283 -0
- package/dist/router/test-integration.js +140 -0
- package/dist/router/test-onnx-benchmark.js +145 -0
- package/dist/router/test-onnx-integration.js +128 -0
- package/dist/router/test-onnx-local.js +37 -0
- package/dist/router/test-onnx.js +148 -0
- package/dist/router/test-openrouter.js +121 -0
- package/dist/router/test-phi4.js +137 -0
- package/dist/router/types.js +2 -0
- package/dist/utils/agentLoader.js +106 -0
- package/dist/utils/cli.js +128 -0
- package/dist/utils/logger.js +41 -0
- package/dist/utils/mcpCommands.js +214 -0
- package/dist/utils/model-downloader.js +182 -0
- package/dist/utils/retry.js +54 -0
- package/docs/.claude-flow/metrics/agent-metrics.json +1 -0
- package/docs/.claude-flow/metrics/performance.json +9 -0
- package/docs/.claude-flow/metrics/task-metrics.json +10 -0
- package/docs/CHANGELOG.md +155 -0
- package/docs/CLAUDE.md +352 -0
- package/docs/COMPLETE_VALIDATION_SUMMARY.md +405 -0
- package/docs/INDEX.md +183 -0
- package/docs/LICENSE +21 -0
- package/docs/ONNX_CLI_USAGE.md +344 -0
- package/docs/ONNX_ENV_VARS.md +564 -0
- package/docs/ONNX_INTEGRATION.md +422 -0
- package/docs/ONNX_OPTIMIZATION_GUIDE.md +665 -0
- package/docs/ONNX_OPTIMIZATION_SUMMARY.md +374 -0
- package/docs/ONNX_VS_CLAUDE_QUALITY.md +442 -0
- package/docs/OPENROUTER_DEPLOYMENT.md +495 -0
- package/docs/architecture/EXECUTIVE_SUMMARY.md +310 -0
- package/docs/architecture/IMPROVEMENT_PLAN.md +11 -0
- package/docs/architecture/INTEGRATION-STATUS.md +290 -0
- package/docs/architecture/MULTI_MODEL_ROUTER_PLAN.md +620 -0
- package/docs/architecture/QUICK_WINS.md +333 -0
- package/docs/architecture/README.md +15 -0
- package/docs/architecture/RESEARCH_SUMMARY.md +652 -0
- package/docs/archived/FASTMCP_COMPLETE.md +428 -0
- package/docs/archived/FASTMCP_INTEGRATION_STATUS.md +288 -0
- package/docs/archived/FLOW-NEXUS-COMPLETE.md +269 -0
- package/docs/archived/INTEGRATION_CONFIRMED.md +351 -0
- package/docs/archived/ONNX_FINAL_REPORT.md +312 -0
- package/docs/archived/ONNX_IMPLEMENTATION_COMPLETE.md +215 -0
- package/docs/archived/ONNX_IMPLEMENTATION_SUMMARY.md +197 -0
- package/docs/archived/ONNX_SUCCESS_REPORT.md +271 -0
- package/docs/archived/OPENROUTER_PROXY_COMPLETE.md +494 -0
- package/docs/archived/PACKAGE-COMPLETE.md +138 -0
- package/docs/archived/README.md +27 -0
- package/docs/archived/RESEARCH_COMPLETE.txt +335 -0
- package/docs/archived/SDK-SETUP-COMPLETE.md +252 -0
- package/docs/guides/ALTERNATIVE_LLM_MODELS.md +524 -0
- package/docs/guides/DOCKER_AGENT_USAGE.md +352 -0
- package/docs/guides/IMPLEMENTATION_EXAMPLES.md +960 -0
- package/docs/guides/NPM-PUBLISH.md +218 -0
- package/docs/guides/README.md +17 -0
- package/docs/guides/agent-sdk.md +234 -0
- package/docs/integrations/CLAUDE_AGENTS_INTEGRATION.md +356 -0
- package/docs/integrations/CLAUDE_FLOW_INTEGRATION.md +535 -0
- package/docs/integrations/FASTMCP_CLI_INTEGRATION.md +503 -0
- package/docs/integrations/FLOW-NEXUS-INTEGRATION.md +319 -0
- package/docs/integrations/README.md +18 -0
- package/docs/integrations/fastmcp-implementation-plan.md +2516 -0
- package/docs/integrations/fastmcp-poc-integration.md +198 -0
- package/docs/router/ONNX_PHI4_RESEARCH.md +220 -0
- package/docs/router/ONNX_RUNTIME_INTEGRATION_PLAN.md +866 -0
- package/docs/router/PHI4_HYPEROPTIMIZATION_PLAN.md +2488 -0
- package/docs/router/README.md +552 -0
- package/docs/router/ROUTER_CONFIG_REFERENCE.md +577 -0
- package/docs/router/ROUTER_USER_GUIDE.md +865 -0
- package/docs/validation/DOCKER_MCP_VALIDATION.md +358 -0
- package/docs/validation/DOCKER_OPENROUTER_VALIDATION.md +443 -0
- package/docs/validation/FINAL_SYSTEM_VALIDATION.md +458 -0
- package/docs/validation/FINAL_VALIDATION_SUMMARY.md +409 -0
- package/docs/validation/MCP_CLI_TOOLS_VALIDATION.md +266 -0
- package/docs/validation/MODEL_VALIDATION_REPORT.md +386 -0
- package/docs/validation/OPENROUTER_VALIDATION_COMPLETE.md +382 -0
- package/docs/validation/README.md +20 -0
- package/docs/validation/ROUTER_VALIDATION.md +311 -0
- package/package.json +140 -0
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
# Multi-Model Router Implementation Plan
|
|
2
|
+
|
|
3
|
+
## ๐ฏ Overview
|
|
4
|
+
|
|
5
|
+
Enable **agentic-flow** to work with alternative LLM providers beyond Anthropic, including OpenAI, OpenRouter, and local models (Ollama, LM Studio). This provides flexibility, cost optimization, and privacy options while maintaining the powerful Agent SDK capabilities.
|
|
6
|
+
|
|
7
|
+
## ๐ Research Summary
|
|
8
|
+
|
|
9
|
+
### Current State
|
|
10
|
+
- **Claude Agent SDK** v0.1.5 - Built for Anthropic models
|
|
11
|
+
- Supports Amazon Bedrock and Google Vertex AI routing
|
|
12
|
+
- MCP (Model Context Protocol) integration ready
|
|
13
|
+
- 111 MCP tools available
|
|
14
|
+
|
|
15
|
+
### Integration Patterns Discovered
|
|
16
|
+
|
|
17
|
+
1. **LiteLLM Approach**
|
|
18
|
+
- Universal LLM gateway supporting 100+ providers
|
|
19
|
+
- OpenAI-compatible API
|
|
20
|
+
- Supports cloud, self-hosted, and local models
|
|
21
|
+
|
|
22
|
+
2. **OpenRouter Integration**
|
|
23
|
+
- Access to 200+ models via single API
|
|
24
|
+
- Intelligent routing and fallback
|
|
25
|
+
- Cost optimization through model selection
|
|
26
|
+
|
|
27
|
+
3. **Direct Provider SDKs**
|
|
28
|
+
- OpenAI SDK with compatibility layer
|
|
29
|
+
- Direct Anthropic API (current)
|
|
30
|
+
- Custom endpoint support for local models
|
|
31
|
+
|
|
32
|
+
## ๐๏ธ Architecture Design
|
|
33
|
+
|
|
34
|
+
### Model Router Layer
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
38
|
+
โ Agentic Flow CLI โ
|
|
39
|
+
โ (--provider, --model, --router-mode) โ
|
|
40
|
+
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
41
|
+
โ
|
|
42
|
+
โผ
|
|
43
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
44
|
+
โ Model Router Middleware โ
|
|
45
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
46
|
+
โ โ Provider Abstraction Layer โ โ
|
|
47
|
+
โ โ - Normalize requests/responses โ โ
|
|
48
|
+
โ โ - Handle streaming โ โ
|
|
49
|
+
โ โ - Tool calling translation โ โ
|
|
50
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
51
|
+
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
52
|
+
โ
|
|
53
|
+
โโโโโโโโโโโโดโโโโโโโโโโโ
|
|
54
|
+
โผ โผ
|
|
55
|
+
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
|
|
56
|
+
โ LiteLLM โ โ Direct โ
|
|
57
|
+
โ Gateway โ โ Providers โ
|
|
58
|
+
โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ
|
|
59
|
+
โ โ
|
|
60
|
+
โโโโโดโโโโโฌโโโโโโโโโโโโฌโโโโดโโโโโ
|
|
61
|
+
โผ โผ โผ โผ
|
|
62
|
+
โโโโโโโโ โโโโโโโโ โโโโโโโโ โโโโโโโโ
|
|
63
|
+
โClaudeโ โOpenAIโ โOllamaโ โCustomโ
|
|
64
|
+
โโโโโโโโ โโโโโโโโ โโโโโโโโ โโโโโโโโ
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## ๐ง Implementation Plan
|
|
68
|
+
|
|
69
|
+
### Phase 1: Core Router Infrastructure (Week 1)
|
|
70
|
+
|
|
71
|
+
#### 1.1 Provider Abstraction Interface
|
|
72
|
+
```typescript
|
|
73
|
+
// src/router/types.ts
|
|
74
|
+
export interface LLMProvider {
|
|
75
|
+
name: string;
|
|
76
|
+
supportsStreaming: boolean;
|
|
77
|
+
supportsTools: boolean;
|
|
78
|
+
supportsMCP: boolean;
|
|
79
|
+
|
|
80
|
+
chat(params: ChatParams): Promise<ChatResponse>;
|
|
81
|
+
stream(params: ChatParams): AsyncIterator<StreamChunk>;
|
|
82
|
+
validateCapabilities(features: string[]): boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface ChatParams {
|
|
86
|
+
model: string;
|
|
87
|
+
messages: Message[];
|
|
88
|
+
tools?: Tool[];
|
|
89
|
+
temperature?: number;
|
|
90
|
+
maxTokens?: number;
|
|
91
|
+
stream?: boolean;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### 1.2 Provider Implementations
|
|
96
|
+
- **AnthropicProvider** (current, refactor)
|
|
97
|
+
- **OpenAIProvider** (new)
|
|
98
|
+
- **OpenRouterProvider** (new)
|
|
99
|
+
- **LiteLLMProvider** (new, universal fallback)
|
|
100
|
+
- **OllamaProvider** (new, local models)
|
|
101
|
+
|
|
102
|
+
#### 1.3 Router Core
|
|
103
|
+
```typescript
|
|
104
|
+
// src/router/router.ts
|
|
105
|
+
export class ModelRouter {
|
|
106
|
+
private providers: Map<string, LLMProvider>;
|
|
107
|
+
private config: RouterConfig;
|
|
108
|
+
|
|
109
|
+
async route(request: ChatParams): Promise<ChatResponse> {
|
|
110
|
+
const provider = this.selectProvider(request);
|
|
111
|
+
return provider.chat(request);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private selectProvider(request: ChatParams): LLMProvider {
|
|
115
|
+
// Intelligent routing based on:
|
|
116
|
+
// - Explicit provider selection
|
|
117
|
+
// - Model availability
|
|
118
|
+
// - Feature requirements
|
|
119
|
+
// - Cost optimization
|
|
120
|
+
// - Fallback chain
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Phase 2: CLI Integration (Week 1-2)
|
|
126
|
+
|
|
127
|
+
#### 2.1 New CLI Options
|
|
128
|
+
```bash
|
|
129
|
+
# Provider selection
|
|
130
|
+
npx agentic-flow --provider openai --model gpt-4 --task "..."
|
|
131
|
+
npx agentic-flow --provider claude --model claude-sonnet-4-5 --task "..."
|
|
132
|
+
npx agentic-flow --provider ollama --model llama3 --task "..."
|
|
133
|
+
npx agentic-flow --provider openrouter --model "anthropic/claude-3-opus" --task "..."
|
|
134
|
+
|
|
135
|
+
# Router modes
|
|
136
|
+
npx agentic-flow --router-mode fallback --task "..." # Try providers in order
|
|
137
|
+
npx agentic-flow --router-mode cost-optimized --task "..." # Cheapest capable model
|
|
138
|
+
npx agentic-flow --router-mode local-first --task "..." # Prefer local models
|
|
139
|
+
|
|
140
|
+
# Configuration file
|
|
141
|
+
npx agentic-flow --router-config ./router.config.json --task "..."
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### 2.2 CLI Implementation
|
|
145
|
+
```typescript
|
|
146
|
+
// src/cli/router.ts
|
|
147
|
+
export interface RouterCLIOptions {
|
|
148
|
+
provider?: 'anthropic' | 'openai' | 'openrouter' | 'ollama' | 'litellm' | 'auto';
|
|
149
|
+
model?: string;
|
|
150
|
+
routerMode?: 'fallback' | 'cost-optimized' | 'local-first' | 'performance';
|
|
151
|
+
routerConfig?: string;
|
|
152
|
+
apiKey?: string; // Provider-specific API key
|
|
153
|
+
baseUrl?: string; // For local models
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Phase 3: Configuration System (Week 2)
|
|
158
|
+
|
|
159
|
+
#### 3.1 Router Configuration File
|
|
160
|
+
```json
|
|
161
|
+
// router.config.json
|
|
162
|
+
{
|
|
163
|
+
"version": "1.0",
|
|
164
|
+
"defaultProvider": "anthropic",
|
|
165
|
+
"fallbackChain": ["anthropic", "openai", "ollama"],
|
|
166
|
+
|
|
167
|
+
"providers": {
|
|
168
|
+
"anthropic": {
|
|
169
|
+
"apiKey": "${ANTHROPIC_API_KEY}",
|
|
170
|
+
"models": ["claude-sonnet-4-5", "claude-3-opus"],
|
|
171
|
+
"defaultModel": "claude-sonnet-4-5",
|
|
172
|
+
"maxRetries": 3
|
|
173
|
+
},
|
|
174
|
+
"openai": {
|
|
175
|
+
"apiKey": "${OPENAI_API_KEY}",
|
|
176
|
+
"models": ["gpt-4", "gpt-4-turbo", "gpt-3.5-turbo"],
|
|
177
|
+
"defaultModel": "gpt-4-turbo",
|
|
178
|
+
"organization": "${OPENAI_ORG_ID}"
|
|
179
|
+
},
|
|
180
|
+
"openrouter": {
|
|
181
|
+
"apiKey": "${OPENROUTER_API_KEY}",
|
|
182
|
+
"models": ["*"],
|
|
183
|
+
"siteUrl": "https://agentic-flow.app",
|
|
184
|
+
"siteName": "Agentic Flow"
|
|
185
|
+
},
|
|
186
|
+
"ollama": {
|
|
187
|
+
"baseUrl": "http://localhost:11434",
|
|
188
|
+
"models": ["llama3", "codellama", "mistral"],
|
|
189
|
+
"defaultModel": "llama3"
|
|
190
|
+
},
|
|
191
|
+
"litellm": {
|
|
192
|
+
"proxyUrl": "http://localhost:4000",
|
|
193
|
+
"fallbackModels": ["gpt-3.5-turbo", "claude-3-haiku"]
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
"routing": {
|
|
198
|
+
"mode": "cost-optimized",
|
|
199
|
+
"rules": [
|
|
200
|
+
{
|
|
201
|
+
"condition": "task.includes('code')",
|
|
202
|
+
"provider": "anthropic",
|
|
203
|
+
"model": "claude-sonnet-4-5"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"condition": "task.length < 100",
|
|
207
|
+
"provider": "openai",
|
|
208
|
+
"model": "gpt-3.5-turbo"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"condition": "privacy === true",
|
|
212
|
+
"provider": "ollama",
|
|
213
|
+
"model": "llama3"
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
"features": {
|
|
219
|
+
"streaming": true,
|
|
220
|
+
"toolCalling": true,
|
|
221
|
+
"mcpIntegration": true,
|
|
222
|
+
"fallbackOnError": true,
|
|
223
|
+
"costTracking": true
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### 3.2 Environment Variables
|
|
229
|
+
```bash
|
|
230
|
+
# .env.router
|
|
231
|
+
# Anthropic
|
|
232
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
233
|
+
CLAUDE_CODE_USE_BEDROCK=0
|
|
234
|
+
CLAUDE_CODE_USE_VERTEX=0
|
|
235
|
+
|
|
236
|
+
# OpenAI
|
|
237
|
+
OPENAI_API_KEY=sk-...
|
|
238
|
+
OPENAI_ORG_ID=org-...
|
|
239
|
+
|
|
240
|
+
# OpenRouter
|
|
241
|
+
OPENROUTER_API_KEY=sk-or-...
|
|
242
|
+
|
|
243
|
+
# Ollama
|
|
244
|
+
OLLAMA_BASE_URL=http://localhost:11434
|
|
245
|
+
|
|
246
|
+
# LiteLLM
|
|
247
|
+
LITELLM_PROXY_URL=http://localhost:4000
|
|
248
|
+
|
|
249
|
+
# Router
|
|
250
|
+
ROUTER_DEFAULT_PROVIDER=anthropic
|
|
251
|
+
ROUTER_MODE=fallback
|
|
252
|
+
ROUTER_CONFIG_PATH=./router.config.json
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Phase 4: Provider Implementations (Week 2-3)
|
|
256
|
+
|
|
257
|
+
#### 4.1 OpenAI Provider
|
|
258
|
+
```typescript
|
|
259
|
+
// src/router/providers/openai.ts
|
|
260
|
+
import OpenAI from 'openai';
|
|
261
|
+
|
|
262
|
+
export class OpenAIProvider implements LLMProvider {
|
|
263
|
+
name = 'openai';
|
|
264
|
+
supportsStreaming = true;
|
|
265
|
+
supportsTools = true;
|
|
266
|
+
supportsMCP = true; // Via adapter
|
|
267
|
+
|
|
268
|
+
private client: OpenAI;
|
|
269
|
+
|
|
270
|
+
async chat(params: ChatParams): Promise<ChatResponse> {
|
|
271
|
+
const response = await this.client.chat.completions.create({
|
|
272
|
+
model: params.model,
|
|
273
|
+
messages: this.convertMessages(params.messages),
|
|
274
|
+
tools: this.convertTools(params.tools),
|
|
275
|
+
stream: false
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
return this.normalizeResponse(response);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private convertTools(tools?: Tool[]): any[] {
|
|
282
|
+
// Convert MCP tools to OpenAI function calling format
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private normalizeResponse(response: any): ChatResponse {
|
|
286
|
+
// Normalize to standard format
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
#### 4.2 OpenRouter Provider
|
|
292
|
+
```typescript
|
|
293
|
+
// src/router/providers/openrouter.ts
|
|
294
|
+
export class OpenRouterProvider implements LLMProvider {
|
|
295
|
+
name = 'openrouter';
|
|
296
|
+
private baseUrl = 'https://openrouter.ai/api/v1';
|
|
297
|
+
|
|
298
|
+
async chat(params: ChatParams): Promise<ChatResponse> {
|
|
299
|
+
const response = await fetch(`${this.baseUrl}/chat/completions`, {
|
|
300
|
+
method: 'POST',
|
|
301
|
+
headers: {
|
|
302
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
303
|
+
'HTTP-Referer': this.config.siteUrl,
|
|
304
|
+
'X-Title': this.config.siteName
|
|
305
|
+
},
|
|
306
|
+
body: JSON.stringify({
|
|
307
|
+
model: params.model,
|
|
308
|
+
messages: params.messages,
|
|
309
|
+
// OpenRouter-specific params
|
|
310
|
+
transforms: ['middle-out'],
|
|
311
|
+
route: 'fallback'
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
return this.normalizeResponse(await response.json());
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
#### 4.3 Ollama Provider
|
|
321
|
+
```typescript
|
|
322
|
+
// src/router/providers/ollama.ts
|
|
323
|
+
export class OllamaProvider implements LLMProvider {
|
|
324
|
+
name = 'ollama';
|
|
325
|
+
private baseUrl: string;
|
|
326
|
+
|
|
327
|
+
async chat(params: ChatParams): Promise<ChatResponse> {
|
|
328
|
+
const response = await fetch(`${this.baseUrl}/api/chat`, {
|
|
329
|
+
method: 'POST',
|
|
330
|
+
body: JSON.stringify({
|
|
331
|
+
model: params.model,
|
|
332
|
+
messages: params.messages,
|
|
333
|
+
stream: false,
|
|
334
|
+
options: {
|
|
335
|
+
temperature: params.temperature,
|
|
336
|
+
num_predict: params.maxTokens
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
return this.normalizeResponse(await response.json());
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
async listModels(): Promise<string[]> {
|
|
345
|
+
const response = await fetch(`${this.baseUrl}/api/tags`);
|
|
346
|
+
const data = await response.json();
|
|
347
|
+
return data.models.map((m: any) => m.name);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
#### 4.4 LiteLLM Universal Provider
|
|
353
|
+
```typescript
|
|
354
|
+
// src/router/providers/litellm.ts
|
|
355
|
+
export class LiteLLMProvider implements LLMProvider {
|
|
356
|
+
name = 'litellm';
|
|
357
|
+
|
|
358
|
+
async chat(params: ChatParams): Promise<ChatResponse> {
|
|
359
|
+
// LiteLLM handles routing to 100+ providers
|
|
360
|
+
const response = await fetch(`${this.proxyUrl}/chat/completions`, {
|
|
361
|
+
method: 'POST',
|
|
362
|
+
headers: {
|
|
363
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
364
|
+
'Content-Type': 'application/json'
|
|
365
|
+
},
|
|
366
|
+
body: JSON.stringify({
|
|
367
|
+
model: params.model, // e.g., "anthropic/claude-3-opus"
|
|
368
|
+
messages: params.messages,
|
|
369
|
+
stream: params.stream
|
|
370
|
+
})
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
return this.normalizeResponse(await response.json());
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Phase 5: Tool Calling Translation (Week 3)
|
|
379
|
+
|
|
380
|
+
#### 5.1 Tool Format Conversion
|
|
381
|
+
Different providers use different tool calling formats. Create adapters:
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
// src/router/adapters/tool-adapter.ts
|
|
385
|
+
export class ToolAdapter {
|
|
386
|
+
// MCP -> OpenAI function calling
|
|
387
|
+
mcpToOpenAI(mcpTools: MCPTool[]): OpenAIFunction[] {
|
|
388
|
+
return mcpTools.map(tool => ({
|
|
389
|
+
type: 'function',
|
|
390
|
+
function: {
|
|
391
|
+
name: tool.name,
|
|
392
|
+
description: tool.description,
|
|
393
|
+
parameters: tool.inputSchema
|
|
394
|
+
}
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// MCP -> Anthropic tool use
|
|
399
|
+
mcpToAnthropic(mcpTools: MCPTool[]): AnthropicTool[] {
|
|
400
|
+
return mcpTools.map(tool => ({
|
|
401
|
+
name: tool.name,
|
|
402
|
+
description: tool.description,
|
|
403
|
+
input_schema: tool.inputSchema
|
|
404
|
+
}));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Response normalization
|
|
408
|
+
normalizeToolCall(response: any, provider: string): ToolCall[] {
|
|
409
|
+
switch (provider) {
|
|
410
|
+
case 'openai':
|
|
411
|
+
return this.openAIToStandard(response);
|
|
412
|
+
case 'anthropic':
|
|
413
|
+
return this.anthropicToStandard(response);
|
|
414
|
+
// ... other providers
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Phase 6: MCP Integration (Week 3-4)
|
|
421
|
+
|
|
422
|
+
#### 6.1 MCP Compatibility Layer
|
|
423
|
+
Ensure all 111 MCP tools work across providers:
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
// src/router/mcp-bridge.ts
|
|
427
|
+
export class MCPBridge {
|
|
428
|
+
async executeToolViaProvider(
|
|
429
|
+
tool: MCPTool,
|
|
430
|
+
params: any,
|
|
431
|
+
provider: LLMProvider
|
|
432
|
+
): Promise<any> {
|
|
433
|
+
// Convert tool to provider format
|
|
434
|
+
const providerTool = this.adapter.convert(tool, provider.name);
|
|
435
|
+
|
|
436
|
+
// Execute via provider's tool calling
|
|
437
|
+
const response = await provider.chat({
|
|
438
|
+
model: provider.defaultModel,
|
|
439
|
+
messages: this.buildToolCallMessages(tool, params),
|
|
440
|
+
tools: [providerTool]
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
// Extract and return tool result
|
|
444
|
+
return this.extractToolResult(response);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Phase 7: Cost Optimization (Week 4)
|
|
450
|
+
|
|
451
|
+
#### 7.1 Cost Tracking
|
|
452
|
+
```typescript
|
|
453
|
+
// src/router/cost-tracker.ts
|
|
454
|
+
export class CostTracker {
|
|
455
|
+
private costs: Map<string, number> = new Map();
|
|
456
|
+
|
|
457
|
+
async trackRequest(
|
|
458
|
+
provider: string,
|
|
459
|
+
model: string,
|
|
460
|
+
inputTokens: number,
|
|
461
|
+
outputTokens: number
|
|
462
|
+
): Promise<void> {
|
|
463
|
+
const cost = this.calculateCost(provider, model, inputTokens, outputTokens);
|
|
464
|
+
this.costs.set(`${provider}:${model}`,
|
|
465
|
+
(this.costs.get(`${provider}:${model}`) || 0) + cost
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
private calculateCost(provider: string, model: string, input: number, output: number): number {
|
|
470
|
+
const pricing = PRICING_TABLE[`${provider}:${model}`];
|
|
471
|
+
return (input * pricing.inputPer1k / 1000) + (output * pricing.outputPer1k / 1000);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
getReport(): CostReport {
|
|
475
|
+
return {
|
|
476
|
+
total: Array.from(this.costs.values()).reduce((a, b) => a + b, 0),
|
|
477
|
+
byProvider: Object.fromEntries(this.costs),
|
|
478
|
+
cheapestProvider: this.findCheapest()
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
#### 7.2 Cost-Optimized Routing
|
|
485
|
+
```typescript
|
|
486
|
+
// Router selects cheapest capable model
|
|
487
|
+
async selectCostOptimizedProvider(params: ChatParams): Promise<LLMProvider> {
|
|
488
|
+
const capabilities = this.analyzeRequirements(params);
|
|
489
|
+
const capableProviders = this.providers.filter(p =>
|
|
490
|
+
p.validateCapabilities(capabilities)
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
return capableProviders.reduce((cheapest, current) => {
|
|
494
|
+
const cheapestCost = this.estimateCost(cheapest, params);
|
|
495
|
+
const currentCost = this.estimateCost(current, params);
|
|
496
|
+
return currentCost < cheapestCost ? current : cheapest;
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
## ๐ฆ Dependencies
|
|
502
|
+
|
|
503
|
+
### New Packages Required
|
|
504
|
+
```json
|
|
505
|
+
{
|
|
506
|
+
"dependencies": {
|
|
507
|
+
"openai": "^4.65.0", // OpenAI SDK
|
|
508
|
+
"litellm-node": "^1.0.0", // LiteLLM client (if available)
|
|
509
|
+
"axios": "^1.7.0", // HTTP client for custom endpoints
|
|
510
|
+
"zod": "^3.25.76" // Already included - schema validation
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### Optional Dependencies
|
|
516
|
+
```json
|
|
517
|
+
{
|
|
518
|
+
"optionalDependencies": {
|
|
519
|
+
"@google-cloud/vertex-ai": "^1.0.0", // Already supported
|
|
520
|
+
"@aws-sdk/client-bedrock": "^3.0.0" // Already supported
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
## ๐งช Testing Strategy
|
|
526
|
+
|
|
527
|
+
### Unit Tests
|
|
528
|
+
- Provider abstraction compliance
|
|
529
|
+
- Tool format conversion accuracy
|
|
530
|
+
- Response normalization
|
|
531
|
+
- Cost calculation accuracy
|
|
532
|
+
|
|
533
|
+
### Integration Tests
|
|
534
|
+
- End-to-end with each provider
|
|
535
|
+
- Fallback chain validation
|
|
536
|
+
- Streaming with different providers
|
|
537
|
+
- Tool calling across providers
|
|
538
|
+
|
|
539
|
+
### Performance Tests
|
|
540
|
+
- Latency comparison
|
|
541
|
+
- Token usage optimization
|
|
542
|
+
- Cost tracking accuracy
|
|
543
|
+
|
|
544
|
+
## ๐ Success Metrics
|
|
545
|
+
|
|
546
|
+
| Metric | Target |
|
|
547
|
+
|--------|--------|
|
|
548
|
+
| Provider Coverage | 5+ (Anthropic, OpenAI, OpenRouter, Ollama, Custom) |
|
|
549
|
+
| Tool Compatibility | 100% (all 111 MCP tools) |
|
|
550
|
+
| Fallback Success Rate | >99% |
|
|
551
|
+
| Cost Reduction | 30-50% (with optimization) |
|
|
552
|
+
| Local Model Support | Yes (Ollama, LM Studio) |
|
|
553
|
+
| Performance Overhead | <10ms routing latency |
|
|
554
|
+
|
|
555
|
+
## ๐ Deployment Options
|
|
556
|
+
|
|
557
|
+
### 1. Default (Anthropic Only)
|
|
558
|
+
```bash
|
|
559
|
+
npx agentic-flow --task "Build API"
|
|
560
|
+
# Uses Claude Sonnet 4.5 by default
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### 2. Cost-Optimized
|
|
564
|
+
```bash
|
|
565
|
+
npx agentic-flow --router-mode cost-optimized --task "Simple analysis"
|
|
566
|
+
# Automatically selects cheapest capable model
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### 3. Local Privacy
|
|
570
|
+
```bash
|
|
571
|
+
npx agentic-flow --provider ollama --model llama3 --task "Analyze sensitive data"
|
|
572
|
+
# All processing stays local
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### 4. Best Performance
|
|
576
|
+
```bash
|
|
577
|
+
npx agentic-flow --provider openrouter --model "anthropic/claude-3-opus" --task "Complex reasoning"
|
|
578
|
+
# Routes to most capable model via OpenRouter
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### 5. Hybrid (Recommended)
|
|
582
|
+
```bash
|
|
583
|
+
npx agentic-flow --router-config ./router.config.json --task "Multi-step task"
|
|
584
|
+
# Intelligent routing:
|
|
585
|
+
# - Simple tasks -> GPT-3.5 (cheap)
|
|
586
|
+
# - Code tasks -> Claude Sonnet 4.5 (best coding)
|
|
587
|
+
# - Privacy tasks -> Ollama (local)
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
## ๐ Documentation Deliverables
|
|
591
|
+
|
|
592
|
+
1. โ
**This Plan** - `MULTI_MODEL_ROUTER_PLAN.md`
|
|
593
|
+
2. **User Guide** - `ROUTER_USER_GUIDE.md`
|
|
594
|
+
3. **Configuration Reference** - `ROUTER_CONFIG_REFERENCE.md`
|
|
595
|
+
4. **Provider Setup Guides** - `providers/` directory
|
|
596
|
+
5. **Migration Guide** - `MIGRATION_TO_ROUTER.md`
|
|
597
|
+
6. **Cost Optimization Guide** - `COST_OPTIMIZATION.md`
|
|
598
|
+
|
|
599
|
+
## ๐ฏ Next Steps
|
|
600
|
+
|
|
601
|
+
1. **Week 1**: Core router infrastructure + CLI integration
|
|
602
|
+
2. **Week 2**: Provider implementations (OpenAI, OpenRouter, Ollama)
|
|
603
|
+
3. **Week 3**: Tool calling translation + MCP bridge
|
|
604
|
+
4. **Week 4**: Cost optimization + testing + documentation
|
|
605
|
+
5. **Week 5**: Beta release + user feedback
|
|
606
|
+
6. **Week 6**: Production release v2.0.0
|
|
607
|
+
|
|
608
|
+
## ๐ก Future Enhancements
|
|
609
|
+
|
|
610
|
+
- **Auto-scaling**: Automatically scale to cloud providers under load
|
|
611
|
+
- **A/B Testing**: Compare model performance on same tasks
|
|
612
|
+
- **Model Fine-tuning**: Support for custom fine-tuned models
|
|
613
|
+
- **Prompt Optimization**: Auto-optimize prompts per provider
|
|
614
|
+
- **Analytics Dashboard**: Real-time cost and performance metrics
|
|
615
|
+
|
|
616
|
+
---
|
|
617
|
+
|
|
618
|
+
**Status**: Planning Complete โ
|
|
619
|
+
**Next**: Implementation Phase 1 - Core Router Infrastructure
|
|
620
|
+
**Timeline**: 6 weeks to production release
|