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.
Files changed (383) hide show
  1. package/.claude/agents/MIGRATION_SUMMARY.md +222 -0
  2. package/.claude/agents/README.md +89 -0
  3. package/.claude/agents/analysis/code-analyzer.md +209 -0
  4. package/.claude/agents/analysis/code-review/analyze-code-quality.md +180 -0
  5. package/.claude/agents/architecture/system-design/arch-system-design.md +156 -0
  6. package/.claude/agents/base-template-generator.md +42 -0
  7. package/.claude/agents/consensus/README.md +253 -0
  8. package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
  9. package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
  10. package/.claude/agents/consensus/gossip-coordinator.md +63 -0
  11. package/.claude/agents/consensus/performance-benchmarker.md +851 -0
  12. package/.claude/agents/consensus/quorum-manager.md +823 -0
  13. package/.claude/agents/consensus/raft-manager.md +63 -0
  14. package/.claude/agents/consensus/security-manager.md +622 -0
  15. package/.claude/agents/core/coder.md +211 -0
  16. package/.claude/agents/core/planner.md +116 -0
  17. package/.claude/agents/core/researcher.md +136 -0
  18. package/.claude/agents/core/reviewer.md +272 -0
  19. package/.claude/agents/core/tester.md +266 -0
  20. package/.claude/agents/data/ml/data-ml-model.md +193 -0
  21. package/.claude/agents/development/backend/dev-backend-api.md +142 -0
  22. package/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
  23. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
  24. package/.claude/agents/flow-nexus/app-store.md +88 -0
  25. package/.claude/agents/flow-nexus/authentication.md +69 -0
  26. package/.claude/agents/flow-nexus/challenges.md +81 -0
  27. package/.claude/agents/flow-nexus/neural-network.md +88 -0
  28. package/.claude/agents/flow-nexus/payments.md +83 -0
  29. package/.claude/agents/flow-nexus/sandbox.md +76 -0
  30. package/.claude/agents/flow-nexus/swarm.md +76 -0
  31. package/.claude/agents/flow-nexus/user-tools.md +96 -0
  32. package/.claude/agents/flow-nexus/workflow.md +84 -0
  33. package/.claude/agents/github/code-review-swarm.md +538 -0
  34. package/.claude/agents/github/github-modes.md +173 -0
  35. package/.claude/agents/github/issue-tracker.md +319 -0
  36. package/.claude/agents/github/multi-repo-swarm.md +553 -0
  37. package/.claude/agents/github/pr-manager.md +191 -0
  38. package/.claude/agents/github/project-board-sync.md +509 -0
  39. package/.claude/agents/github/release-manager.md +367 -0
  40. package/.claude/agents/github/release-swarm.md +583 -0
  41. package/.claude/agents/github/repo-architect.md +398 -0
  42. package/.claude/agents/github/swarm-issue.md +573 -0
  43. package/.claude/agents/github/swarm-pr.md +428 -0
  44. package/.claude/agents/github/sync-coordinator.md +452 -0
  45. package/.claude/agents/github/workflow-automation.md +635 -0
  46. package/.claude/agents/goal/agent.md +816 -0
  47. package/.claude/agents/goal/goal-planner.md +73 -0
  48. package/.claude/agents/optimization/README.md +250 -0
  49. package/.claude/agents/optimization/benchmark-suite.md +665 -0
  50. package/.claude/agents/optimization/load-balancer.md +431 -0
  51. package/.claude/agents/optimization/performance-monitor.md +672 -0
  52. package/.claude/agents/optimization/resource-allocator.md +674 -0
  53. package/.claude/agents/optimization/topology-optimizer.md +808 -0
  54. package/.claude/agents/payments/agentic-payments.md +126 -0
  55. package/.claude/agents/sparc/architecture.md +472 -0
  56. package/.claude/agents/sparc/pseudocode.md +318 -0
  57. package/.claude/agents/sparc/refinement.md +525 -0
  58. package/.claude/agents/sparc/specification.md +276 -0
  59. package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +226 -0
  60. package/.claude/agents/sublinear/consensus-coordinator.md +338 -0
  61. package/.claude/agents/sublinear/matrix-optimizer.md +185 -0
  62. package/.claude/agents/sublinear/pagerank-analyzer.md +299 -0
  63. package/.claude/agents/sublinear/performance-optimizer.md +368 -0
  64. package/.claude/agents/sublinear/trading-predictor.md +246 -0
  65. package/.claude/agents/swarm/README.md +190 -0
  66. package/.claude/agents/swarm/adaptive-coordinator.md +396 -0
  67. package/.claude/agents/swarm/hierarchical-coordinator.md +256 -0
  68. package/.claude/agents/swarm/mesh-coordinator.md +392 -0
  69. package/.claude/agents/templates/automation-smart-agent.md +205 -0
  70. package/.claude/agents/templates/coordinator-swarm-init.md +90 -0
  71. package/.claude/agents/templates/github-pr-manager.md +177 -0
  72. package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
  73. package/.claude/agents/templates/memory-coordinator.md +187 -0
  74. package/.claude/agents/templates/migration-plan.md +746 -0
  75. package/.claude/agents/templates/orchestrator-task.md +139 -0
  76. package/.claude/agents/templates/performance-analyzer.md +199 -0
  77. package/.claude/agents/templates/sparc-coordinator.md +183 -0
  78. package/.claude/agents/test-neural.md +14 -0
  79. package/.claude/agents/testing/unit/tdd-london-swarm.md +244 -0
  80. package/.claude/agents/testing/validation/production-validator.md +395 -0
  81. package/.claude/commands/agents/README.md +10 -0
  82. package/.claude/commands/agents/agent-capabilities.md +21 -0
  83. package/.claude/commands/agents/agent-coordination.md +28 -0
  84. package/.claude/commands/agents/agent-spawning.md +28 -0
  85. package/.claude/commands/agents/agent-types.md +26 -0
  86. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
  87. package/.claude/commands/analysis/README.md +9 -0
  88. package/.claude/commands/analysis/bottleneck-detect.md +162 -0
  89. package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
  90. package/.claude/commands/analysis/performance-report.md +25 -0
  91. package/.claude/commands/analysis/token-efficiency.md +45 -0
  92. package/.claude/commands/analysis/token-usage.md +25 -0
  93. package/.claude/commands/automation/README.md +9 -0
  94. package/.claude/commands/automation/auto-agent.md +122 -0
  95. package/.claude/commands/automation/self-healing.md +106 -0
  96. package/.claude/commands/automation/session-memory.md +90 -0
  97. package/.claude/commands/automation/smart-agents.md +73 -0
  98. package/.claude/commands/automation/smart-spawn.md +25 -0
  99. package/.claude/commands/automation/workflow-select.md +25 -0
  100. package/.claude/commands/claude-flow-help.md +103 -0
  101. package/.claude/commands/claude-flow-memory.md +107 -0
  102. package/.claude/commands/claude-flow-swarm.md +205 -0
  103. package/.claude/commands/coordination/README.md +9 -0
  104. package/.claude/commands/coordination/agent-spawn.md +25 -0
  105. package/.claude/commands/coordination/init.md +44 -0
  106. package/.claude/commands/coordination/orchestrate.md +43 -0
  107. package/.claude/commands/coordination/spawn.md +45 -0
  108. package/.claude/commands/coordination/swarm-init.md +85 -0
  109. package/.claude/commands/coordination/task-orchestrate.md +25 -0
  110. package/.claude/commands/flow-nexus/app-store.md +124 -0
  111. package/.claude/commands/flow-nexus/challenges.md +120 -0
  112. package/.claude/commands/flow-nexus/login-registration.md +65 -0
  113. package/.claude/commands/flow-nexus/neural-network.md +134 -0
  114. package/.claude/commands/flow-nexus/payments.md +116 -0
  115. package/.claude/commands/flow-nexus/sandbox.md +83 -0
  116. package/.claude/commands/flow-nexus/swarm.md +87 -0
  117. package/.claude/commands/flow-nexus/user-tools.md +152 -0
  118. package/.claude/commands/flow-nexus/workflow.md +115 -0
  119. package/.claude/commands/github/README.md +11 -0
  120. package/.claude/commands/github/code-review-swarm.md +514 -0
  121. package/.claude/commands/github/code-review.md +25 -0
  122. package/.claude/commands/github/github-modes.md +147 -0
  123. package/.claude/commands/github/github-swarm.md +121 -0
  124. package/.claude/commands/github/issue-tracker.md +292 -0
  125. package/.claude/commands/github/issue-triage.md +25 -0
  126. package/.claude/commands/github/multi-repo-swarm.md +519 -0
  127. package/.claude/commands/github/pr-enhance.md +26 -0
  128. package/.claude/commands/github/pr-manager.md +170 -0
  129. package/.claude/commands/github/project-board-sync.md +471 -0
  130. package/.claude/commands/github/release-manager.md +338 -0
  131. package/.claude/commands/github/release-swarm.md +544 -0
  132. package/.claude/commands/github/repo-analyze.md +25 -0
  133. package/.claude/commands/github/repo-architect.md +367 -0
  134. package/.claude/commands/github/swarm-issue.md +482 -0
  135. package/.claude/commands/github/swarm-pr.md +285 -0
  136. package/.claude/commands/github/sync-coordinator.md +301 -0
  137. package/.claude/commands/github/workflow-automation.md +442 -0
  138. package/.claude/commands/hive-mind/README.md +17 -0
  139. package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -0
  140. package/.claude/commands/hive-mind/hive-mind-init.md +18 -0
  141. package/.claude/commands/hive-mind/hive-mind-memory.md +8 -0
  142. package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -0
  143. package/.claude/commands/hive-mind/hive-mind-resume.md +8 -0
  144. package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -0
  145. package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -0
  146. package/.claude/commands/hive-mind/hive-mind-status.md +8 -0
  147. package/.claude/commands/hive-mind/hive-mind-stop.md +8 -0
  148. package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -0
  149. package/.claude/commands/hive-mind/hive-mind.md +27 -0
  150. package/.claude/commands/hooks/README.md +11 -0
  151. package/.claude/commands/hooks/overview.md +58 -0
  152. package/.claude/commands/hooks/post-edit.md +117 -0
  153. package/.claude/commands/hooks/post-task.md +112 -0
  154. package/.claude/commands/hooks/pre-edit.md +113 -0
  155. package/.claude/commands/hooks/pre-task.md +111 -0
  156. package/.claude/commands/hooks/session-end.md +118 -0
  157. package/.claude/commands/hooks/setup.md +103 -0
  158. package/.claude/commands/memory/README.md +9 -0
  159. package/.claude/commands/memory/memory-persist.md +25 -0
  160. package/.claude/commands/memory/memory-search.md +25 -0
  161. package/.claude/commands/memory/memory-usage.md +25 -0
  162. package/.claude/commands/memory/neural.md +47 -0
  163. package/.claude/commands/memory/usage.md +46 -0
  164. package/.claude/commands/monitoring/README.md +9 -0
  165. package/.claude/commands/monitoring/agent-metrics.md +25 -0
  166. package/.claude/commands/monitoring/agents.md +44 -0
  167. package/.claude/commands/monitoring/real-time-view.md +25 -0
  168. package/.claude/commands/monitoring/status.md +46 -0
  169. package/.claude/commands/monitoring/swarm-monitor.md +25 -0
  170. package/.claude/commands/optimization/README.md +9 -0
  171. package/.claude/commands/optimization/auto-topology.md +62 -0
  172. package/.claude/commands/optimization/cache-manage.md +25 -0
  173. package/.claude/commands/optimization/parallel-execute.md +25 -0
  174. package/.claude/commands/optimization/parallel-execution.md +50 -0
  175. package/.claude/commands/optimization/topology-optimize.md +25 -0
  176. package/.claude/commands/pair/README.md +261 -0
  177. package/.claude/commands/pair/commands.md +546 -0
  178. package/.claude/commands/pair/config.md +510 -0
  179. package/.claude/commands/pair/examples.md +512 -0
  180. package/.claude/commands/pair/modes.md +348 -0
  181. package/.claude/commands/pair/session.md +407 -0
  182. package/.claude/commands/pair/start.md +209 -0
  183. package/.claude/commands/sparc/analyzer.md +52 -0
  184. package/.claude/commands/sparc/architect.md +53 -0
  185. package/.claude/commands/sparc/ask.md +97 -0
  186. package/.claude/commands/sparc/batch-executor.md +54 -0
  187. package/.claude/commands/sparc/code.md +89 -0
  188. package/.claude/commands/sparc/coder.md +54 -0
  189. package/.claude/commands/sparc/debug.md +83 -0
  190. package/.claude/commands/sparc/debugger.md +54 -0
  191. package/.claude/commands/sparc/designer.md +53 -0
  192. package/.claude/commands/sparc/devops.md +109 -0
  193. package/.claude/commands/sparc/docs-writer.md +80 -0
  194. package/.claude/commands/sparc/documenter.md +54 -0
  195. package/.claude/commands/sparc/innovator.md +54 -0
  196. package/.claude/commands/sparc/integration.md +83 -0
  197. package/.claude/commands/sparc/mcp.md +117 -0
  198. package/.claude/commands/sparc/memory-manager.md +54 -0
  199. package/.claude/commands/sparc/optimizer.md +54 -0
  200. package/.claude/commands/sparc/orchestrator.md +132 -0
  201. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -0
  202. package/.claude/commands/sparc/refinement-optimization-mode.md +83 -0
  203. package/.claude/commands/sparc/researcher.md +54 -0
  204. package/.claude/commands/sparc/reviewer.md +54 -0
  205. package/.claude/commands/sparc/security-review.md +80 -0
  206. package/.claude/commands/sparc/sparc-modes.md +174 -0
  207. package/.claude/commands/sparc/sparc.md +111 -0
  208. package/.claude/commands/sparc/spec-pseudocode.md +80 -0
  209. package/.claude/commands/sparc/supabase-admin.md +348 -0
  210. package/.claude/commands/sparc/swarm-coordinator.md +54 -0
  211. package/.claude/commands/sparc/tdd.md +54 -0
  212. package/.claude/commands/sparc/tester.md +54 -0
  213. package/.claude/commands/sparc/tutorial.md +79 -0
  214. package/.claude/commands/sparc/workflow-manager.md +54 -0
  215. package/.claude/commands/sparc.md +166 -0
  216. package/.claude/commands/stream-chain/pipeline.md +121 -0
  217. package/.claude/commands/stream-chain/run.md +70 -0
  218. package/.claude/commands/swarm/README.md +15 -0
  219. package/.claude/commands/swarm/analysis.md +95 -0
  220. package/.claude/commands/swarm/development.md +96 -0
  221. package/.claude/commands/swarm/examples.md +168 -0
  222. package/.claude/commands/swarm/maintenance.md +102 -0
  223. package/.claude/commands/swarm/optimization.md +117 -0
  224. package/.claude/commands/swarm/research.md +136 -0
  225. package/.claude/commands/swarm/swarm-analysis.md +8 -0
  226. package/.claude/commands/swarm/swarm-background.md +8 -0
  227. package/.claude/commands/swarm/swarm-init.md +19 -0
  228. package/.claude/commands/swarm/swarm-modes.md +8 -0
  229. package/.claude/commands/swarm/swarm-monitor.md +8 -0
  230. package/.claude/commands/swarm/swarm-spawn.md +19 -0
  231. package/.claude/commands/swarm/swarm-status.md +8 -0
  232. package/.claude/commands/swarm/swarm-strategies.md +8 -0
  233. package/.claude/commands/swarm/swarm.md +27 -0
  234. package/.claude/commands/swarm/testing.md +131 -0
  235. package/.claude/commands/training/README.md +9 -0
  236. package/.claude/commands/training/model-update.md +25 -0
  237. package/.claude/commands/training/neural-patterns.md +74 -0
  238. package/.claude/commands/training/neural-train.md +25 -0
  239. package/.claude/commands/training/pattern-learn.md +25 -0
  240. package/.claude/commands/training/specialization.md +63 -0
  241. package/.claude/commands/truth/start.md +143 -0
  242. package/.claude/commands/verify/check.md +50 -0
  243. package/.claude/commands/verify/start.md +128 -0
  244. package/.claude/commands/workflows/README.md +9 -0
  245. package/.claude/commands/workflows/development.md +78 -0
  246. package/.claude/commands/workflows/research.md +63 -0
  247. package/.claude/commands/workflows/workflow-create.md +25 -0
  248. package/.claude/commands/workflows/workflow-execute.md +25 -0
  249. package/.claude/commands/workflows/workflow-export.md +25 -0
  250. package/.claude/helpers/checkpoint-manager.sh +251 -0
  251. package/.claude/helpers/github-safe.js +106 -0
  252. package/.claude/helpers/github-setup.sh +28 -0
  253. package/.claude/helpers/quick-start.sh +19 -0
  254. package/.claude/helpers/setup-mcp.sh +18 -0
  255. package/.claude/helpers/standard-checkpoint-hooks.sh +179 -0
  256. package/.claude/mcp.json +13 -0
  257. package/.claude/settings-backup.json +130 -0
  258. package/.claude/settings-optimized.json +116 -0
  259. package/.claude/settings-simple.json +78 -0
  260. package/.claude/settings.json +114 -0
  261. package/.claude/settings.local.json +14 -0
  262. package/README.md +1280 -0
  263. package/dist/agents/claudeAgent.js +73 -0
  264. package/dist/agents/claudeFlowAgent.js +115 -0
  265. package/dist/agents/codeReviewAgent.js +34 -0
  266. package/dist/agents/dataAgent.js +34 -0
  267. package/dist/agents/directApiAgent.js +260 -0
  268. package/dist/agents/webResearchAgent.js +35 -0
  269. package/dist/cli/mcp.js +135 -0
  270. package/dist/cli-proxy.js +246 -0
  271. package/dist/cli.js +158 -0
  272. package/dist/config/claudeFlow.js +67 -0
  273. package/dist/config/tools.js +33 -0
  274. package/dist/coordination/parallelSwarm.js +226 -0
  275. package/dist/examples/multi-agent-orchestration.js +45 -0
  276. package/dist/examples/parallel-swarm-deployment.js +171 -0
  277. package/dist/examples/use-goal-planner.js +52 -0
  278. package/dist/health.js +46 -0
  279. package/dist/index-with-proxy.js +101 -0
  280. package/dist/index.js +167 -0
  281. package/dist/mcp/claudeFlowSdkServer.js +202 -0
  282. package/dist/mcp/fastmcp/servers/claude-flow-sdk.js +198 -0
  283. package/dist/mcp/fastmcp/servers/http-streaming-updated.js +421 -0
  284. package/dist/mcp/fastmcp/servers/poc-stdio.js +82 -0
  285. package/dist/mcp/fastmcp/servers/stdio-full.js +421 -0
  286. package/dist/mcp/fastmcp/tools/agent/add-agent.js +107 -0
  287. package/dist/mcp/fastmcp/tools/agent/add-command.js +117 -0
  288. package/dist/mcp/fastmcp/tools/agent/execute.js +56 -0
  289. package/dist/mcp/fastmcp/tools/agent/list.js +82 -0
  290. package/dist/mcp/fastmcp/tools/agent/parallel.js +63 -0
  291. package/dist/mcp/fastmcp/tools/memory/retrieve.js +38 -0
  292. package/dist/mcp/fastmcp/tools/memory/search.js +41 -0
  293. package/dist/mcp/fastmcp/tools/memory/store.js +56 -0
  294. package/dist/mcp/fastmcp/tools/swarm/init.js +41 -0
  295. package/dist/mcp/fastmcp/tools/swarm/orchestrate.js +47 -0
  296. package/dist/mcp/fastmcp/tools/swarm/spawn.js +40 -0
  297. package/dist/mcp/fastmcp/types/index.js +2 -0
  298. package/dist/proxy/anthropic-to-openrouter.js +246 -0
  299. package/dist/router/providers/anthropic.js +89 -0
  300. package/dist/router/providers/onnx-local-optimized.js +167 -0
  301. package/dist/router/providers/onnx-local.js +294 -0
  302. package/dist/router/providers/onnx-phi4.js +190 -0
  303. package/dist/router/providers/onnx.js +242 -0
  304. package/dist/router/providers/openrouter.js +242 -0
  305. package/dist/router/router.js +283 -0
  306. package/dist/router/test-integration.js +140 -0
  307. package/dist/router/test-onnx-benchmark.js +145 -0
  308. package/dist/router/test-onnx-integration.js +128 -0
  309. package/dist/router/test-onnx-local.js +37 -0
  310. package/dist/router/test-onnx.js +148 -0
  311. package/dist/router/test-openrouter.js +121 -0
  312. package/dist/router/test-phi4.js +137 -0
  313. package/dist/router/types.js +2 -0
  314. package/dist/utils/agentLoader.js +106 -0
  315. package/dist/utils/cli.js +128 -0
  316. package/dist/utils/logger.js +41 -0
  317. package/dist/utils/mcpCommands.js +214 -0
  318. package/dist/utils/model-downloader.js +182 -0
  319. package/dist/utils/retry.js +54 -0
  320. package/docs/.claude-flow/metrics/agent-metrics.json +1 -0
  321. package/docs/.claude-flow/metrics/performance.json +9 -0
  322. package/docs/.claude-flow/metrics/task-metrics.json +10 -0
  323. package/docs/CHANGELOG.md +155 -0
  324. package/docs/CLAUDE.md +352 -0
  325. package/docs/COMPLETE_VALIDATION_SUMMARY.md +405 -0
  326. package/docs/INDEX.md +183 -0
  327. package/docs/LICENSE +21 -0
  328. package/docs/ONNX_CLI_USAGE.md +344 -0
  329. package/docs/ONNX_ENV_VARS.md +564 -0
  330. package/docs/ONNX_INTEGRATION.md +422 -0
  331. package/docs/ONNX_OPTIMIZATION_GUIDE.md +665 -0
  332. package/docs/ONNX_OPTIMIZATION_SUMMARY.md +374 -0
  333. package/docs/ONNX_VS_CLAUDE_QUALITY.md +442 -0
  334. package/docs/OPENROUTER_DEPLOYMENT.md +495 -0
  335. package/docs/architecture/EXECUTIVE_SUMMARY.md +310 -0
  336. package/docs/architecture/IMPROVEMENT_PLAN.md +11 -0
  337. package/docs/architecture/INTEGRATION-STATUS.md +290 -0
  338. package/docs/architecture/MULTI_MODEL_ROUTER_PLAN.md +620 -0
  339. package/docs/architecture/QUICK_WINS.md +333 -0
  340. package/docs/architecture/README.md +15 -0
  341. package/docs/architecture/RESEARCH_SUMMARY.md +652 -0
  342. package/docs/archived/FASTMCP_COMPLETE.md +428 -0
  343. package/docs/archived/FASTMCP_INTEGRATION_STATUS.md +288 -0
  344. package/docs/archived/FLOW-NEXUS-COMPLETE.md +269 -0
  345. package/docs/archived/INTEGRATION_CONFIRMED.md +351 -0
  346. package/docs/archived/ONNX_FINAL_REPORT.md +312 -0
  347. package/docs/archived/ONNX_IMPLEMENTATION_COMPLETE.md +215 -0
  348. package/docs/archived/ONNX_IMPLEMENTATION_SUMMARY.md +197 -0
  349. package/docs/archived/ONNX_SUCCESS_REPORT.md +271 -0
  350. package/docs/archived/OPENROUTER_PROXY_COMPLETE.md +494 -0
  351. package/docs/archived/PACKAGE-COMPLETE.md +138 -0
  352. package/docs/archived/README.md +27 -0
  353. package/docs/archived/RESEARCH_COMPLETE.txt +335 -0
  354. package/docs/archived/SDK-SETUP-COMPLETE.md +252 -0
  355. package/docs/guides/ALTERNATIVE_LLM_MODELS.md +524 -0
  356. package/docs/guides/DOCKER_AGENT_USAGE.md +352 -0
  357. package/docs/guides/IMPLEMENTATION_EXAMPLES.md +960 -0
  358. package/docs/guides/NPM-PUBLISH.md +218 -0
  359. package/docs/guides/README.md +17 -0
  360. package/docs/guides/agent-sdk.md +234 -0
  361. package/docs/integrations/CLAUDE_AGENTS_INTEGRATION.md +356 -0
  362. package/docs/integrations/CLAUDE_FLOW_INTEGRATION.md +535 -0
  363. package/docs/integrations/FASTMCP_CLI_INTEGRATION.md +503 -0
  364. package/docs/integrations/FLOW-NEXUS-INTEGRATION.md +319 -0
  365. package/docs/integrations/README.md +18 -0
  366. package/docs/integrations/fastmcp-implementation-plan.md +2516 -0
  367. package/docs/integrations/fastmcp-poc-integration.md +198 -0
  368. package/docs/router/ONNX_PHI4_RESEARCH.md +220 -0
  369. package/docs/router/ONNX_RUNTIME_INTEGRATION_PLAN.md +866 -0
  370. package/docs/router/PHI4_HYPEROPTIMIZATION_PLAN.md +2488 -0
  371. package/docs/router/README.md +552 -0
  372. package/docs/router/ROUTER_CONFIG_REFERENCE.md +577 -0
  373. package/docs/router/ROUTER_USER_GUIDE.md +865 -0
  374. package/docs/validation/DOCKER_MCP_VALIDATION.md +358 -0
  375. package/docs/validation/DOCKER_OPENROUTER_VALIDATION.md +443 -0
  376. package/docs/validation/FINAL_SYSTEM_VALIDATION.md +458 -0
  377. package/docs/validation/FINAL_VALIDATION_SUMMARY.md +409 -0
  378. package/docs/validation/MCP_CLI_TOOLS_VALIDATION.md +266 -0
  379. package/docs/validation/MODEL_VALIDATION_REPORT.md +386 -0
  380. package/docs/validation/OPENROUTER_VALIDATION_COMPLETE.md +382 -0
  381. package/docs/validation/README.md +20 -0
  382. package/docs/validation/ROUTER_VALIDATION.md +311 -0
  383. package/package.json +140 -0
package/README.md ADDED
@@ -0,0 +1,1280 @@
1
+ # 🤖 Agentic Flow
2
+
3
+ **Ephemeral AI Agent Orchestration Framework with Multi-Model Router, OpenRouter Integration & Free Local Inference**
4
+
5
+ Deploy autonomous multi-agent swarms with **99% cost savings** via OpenRouter integration. Features intelligent multi-model routing with **100+ LLM models** at 1/100th the cost, plus **100% free local CPU/GPU inference** via ONNX Runtime for privacy-sensitive workloads. Agents spin up on-demand, execute complex tasks, and automatically terminate.
6
+
7
+ Built on **[Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk)** by Anthropic, powered by **[Claude Flow](https://github.com/ruvnet/claude-flow)** (101 MCP tools), **[Flow Nexus](https://github.com/ruvnet/flow-nexus)** (96 cloud tools), **[OpenRouter](https://openrouter.ai)** (100+ LLM models), **[Agentic Payments](https://www.npmjs.com/package/agentic-payments)** (payment authorization), and **ONNX Runtime** (free local CPU or GPU inference).
8
+
9
+ [![npm version](https://img.shields.io/npm/v/agentic-flow.svg)](https://www.npmjs.com/package/agentic-flow)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
11
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
12
+
13
+ ---
14
+
15
+ ## Why Agentic Flow?
16
+
17
+ Traditional AI frameworks require persistent infrastructure and complex orchestration. **Agentic Flow** takes a different approach by combining the power of Anthropic's **Claude Agent SDK**, the orchestration capabilities of **Claude Flow**, OpenRouter's **100+ LLM models**, and the cloud infrastructure of **Flow Nexus**:
18
+
19
+ - **99% Cost Savings** - OpenRouter integration with Llama 3.1, DeepSeek, Gemini
20
+ - **Deploy Anywhere** - Local development, Docker containers, or cloud sandboxes
21
+ - **Ephemeral by Design** - Agents exist only while working, minimizing costs
22
+ - **Full MCP Support** - 203+ tools locally and in containers, cloud-ready
23
+ - **Auto-Scaling** - Spawn 1 or 100 agents based on workload
24
+ - **Zero Infrastructure** - No databases, queues, or persistent services required
25
+ - **Production-Ready** - Built on battle-tested Claude Agent SDK v0.1.5
26
+ - **Model Flexibility** - Use Claude, OpenRouter, or free local ONNX models
27
+
28
+ > **Deploy your way:** Run locally for development (all 203 tools), containerize for production (Docker/Kubernetes), or scale in cloud sandboxes (Flow Nexus E2B). **Use OpenRouter for 99% cost savings** or ONNX for 100% free local inference.
29
+
30
+ ### Built on Industry Standards
31
+
32
+ - **[Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk)** - Anthropic's official SDK for building AI agents
33
+ - **[Claude Flow](https://github.com/ruvnet/claude-flow)** - 101 MCP tools for orchestration, memory, GitHub, neural networks
34
+ - **[Flow Nexus](https://github.com/ruvnet/flow-nexus)** - 96 cloud tools for sandboxes, distributed swarms, workflows
35
+ - **[OpenRouter](https://openrouter.ai)** - Access to 100+ LLM models at 99% cost savings (Llama, DeepSeek, Gemini, etc.)
36
+ - **[Agentic Payments](https://www.npmjs.com/package/agentic-payments)** - Multi-agent payment authorization with Ed25519 cryptography
37
+ - **[ONNX Runtime](https://onnxruntime.ai)** - Free local CPU/GPU inference with Microsoft Phi-4
38
+
39
+ ---
40
+
41
+ ## 🚀 Quick Start
42
+
43
+ ### Local Installation (Recommended for Development)
44
+
45
+ ```bash
46
+ # Global installation
47
+ npm install -g agentic-flow
48
+
49
+ # Or use directly with npx (no installation)
50
+ npx agentic-flow --help
51
+
52
+ # Set your API key
53
+ export ANTHROPIC_API_KEY=sk-ant-...
54
+ ```
55
+
56
+ ### Your First Agent (Local Execution)
57
+
58
+ ```bash
59
+ # Run locally with full 203 MCP tool access (Claude)
60
+ npx agentic-flow \
61
+ --agent researcher \
62
+ --task "Analyze microservices architecture trends in 2025"
63
+
64
+ # Run with OpenRouter for 99% cost savings
65
+ export OPENROUTER_API_KEY=sk-or-v1-...
66
+ npx agentic-flow \
67
+ --agent coder \
68
+ --task "Build a REST API with authentication" \
69
+ --model "meta-llama/llama-3.1-8b-instruct"
70
+
71
+ # The agent executes on your machine, uses all MCP tools, and terminates
72
+ ```
73
+
74
+ ### Multi-Agent Swarm (Local)
75
+
76
+ ```bash
77
+ # 3 agents work in parallel on your machine
78
+ export TOPIC="API security best practices"
79
+ export DIFF="feat: add OAuth2 authentication"
80
+ export DATASET="API response times last 30 days"
81
+
82
+ npx agentic-flow # Spawns: researcher + code-reviewer + data-analyst
83
+ ```
84
+
85
+ **Local Benefits:**
86
+ - ✅ All 203 MCP tools work (full subprocess support)
87
+ - ✅ Fast iteration and debugging
88
+ - ✅ No cloud costs during development
89
+ - ✅ Full access to local filesystem and resources
90
+
91
+ ### Docker Deployment (Production)
92
+
93
+ ```bash
94
+ # Build container
95
+ docker build -f deployment/Dockerfile -t agentic-flow .
96
+
97
+ # Run agent with Claude (Anthropic)
98
+ docker run --rm \
99
+ -e ANTHROPIC_API_KEY=sk-ant-... \
100
+ agentic-flow \
101
+ --agent researcher \
102
+ --task "Analyze cloud patterns"
103
+
104
+ # Run agent with OpenRouter (99% cost savings)
105
+ docker run --rm \
106
+ -e OPENROUTER_API_KEY=sk-or-v1-... \
107
+ agentic-flow \
108
+ --agent coder \
109
+ --task "Build REST API" \
110
+ --model "meta-llama/llama-3.1-8b-instruct"
111
+ ```
112
+
113
+ **Container Benefits:**
114
+ - ✅ All 203 MCP tools work (full subprocess support)
115
+ - ✅ OpenRouter proxy auto-starts in container
116
+ - ✅ Reproducible builds and deployments
117
+ - ✅ Works on Kubernetes, ECS, Cloud Run, Fargate
118
+ - ✅ Isolated execution environment
119
+
120
+ ---
121
+
122
+ ## ✨ Key Features
123
+
124
+ ### 🔄 Ephemeral Architecture
125
+ - **On-Demand Spawning** - Agents created only when needed
126
+ - **Automatic Cleanup** - Terminate after task completion
127
+ - **Stateless Execution** - No persistent state between runs
128
+ - **Cost-Optimized** - Pay only for actual compute time
129
+
130
+ ### 🤖 Multi-Model Router with ONNX Local Inference
131
+ - **Intelligent Provider Routing** - Automatic selection between Anthropic, OpenRouter, and ONNX based on task requirements
132
+ - **100% Free Local Inference** - ONNX Runtime CPU/GPU execution with Microsoft Phi-4 (zero API costs)
133
+ - **Privacy-First Processing** - GDPR/HIPAA-compliant local processing for sensitive workloads
134
+ - **Cost Optimization** - Route privacy tasks to free ONNX, complex reasoning to cloud APIs
135
+ - **Rule-Based Routing** - Automatic provider selection based on privacy, cost, and performance
136
+ - **GPU Acceleration Ready** - CPU inference at 6 tokens/sec, GPU capable of 60-300 tokens/sec
137
+ - **Zero-Cost Agents** - Run agents entirely offline with local ONNX models
138
+
139
+ ### 💻 Local Development (Full Features)
140
+ - **Native Execution** - Run directly on macOS, Linux, Windows
141
+ - **All 203 MCP Tools** - Full subprocess support, no restrictions
142
+ - **Fast Iteration** - Instant feedback, no cold starts
143
+ - **Persistent Memory** - Claude Flow memory persists across runs
144
+ - **File System Access** - Full access to local files and directories
145
+ - **Git Integration** - Direct GitHub operations and repository management
146
+ - **Zero Cloud Costs** - Free during development
147
+
148
+ ### 🐳 Container Deployment (Production Ready)
149
+ - **Docker Support** - Complete feature set for ECS, Cloud Run, Kubernetes
150
+ - **All 203 MCP Tools** - Full subprocess support in containers
151
+ - **Reproducible Builds** - Same environment across dev/staging/prod
152
+ - **Orchestration Ready** - Works with Kubernetes Jobs, ECS Tasks, Cloud Run
153
+ - **Health Checks Built-in** - `/health` endpoint for load balancers
154
+ - **Resource Controls** - CPU/memory limits via container configs
155
+
156
+ ### ☁️ Cloud Sandboxes (Scalable Execution)
157
+ - **Flow Nexus E2B Sandboxes** - Fully isolated execution environments
158
+ - **All 203 MCP Tools** - Complete tool access in cloud sandboxes
159
+ - **Multi-Language Templates** - Node.js, Python, React, Next.js
160
+ - **Real-Time Streaming** - Live output and monitoring
161
+ - **Auto-Scaling** - Spin up 1 to 100+ sandboxes on demand
162
+ - **Pay-Per-Use** - Only pay for actual sandbox runtime (≈$1/hour)
163
+
164
+ ### 🤖 Intelligent Agents
165
+ - **75 Pre-Built Specialists** - Researchers, coders, testers, reviewers, architects
166
+ - **Swarm Coordination** - Agents collaborate via shared memory
167
+ - **Tool Access** - 200+ MCP tools for GitHub, neural networks, workflows
168
+ - **Custom Agents** - Define your own in YAML with system prompts
169
+
170
+ ### 📊 Observability
171
+ - **Real-Time Streaming** - See agent output as it happens
172
+ - **Structured Logging** - JSON logs for aggregation and analysis
173
+ - **Performance Metrics** - Track agent duration, tool usage, token consumption
174
+ - **Health Checks** - Built-in healthcheck endpoint for orchestrators
175
+
176
+ ---
177
+
178
+ ## 🚀 Deployment Options
179
+
180
+ ### 💻 Local Execution (Best for Development)
181
+
182
+ **Full-featured, all 203 MCP tools work:**
183
+
184
+ ```bash
185
+ # Install globally
186
+ npm install -g agentic-flow
187
+
188
+ # Set API key
189
+ export ANTHROPIC_API_KEY=sk-ant-...
190
+
191
+ # Run any agent locally
192
+ npx agentic-flow --agent coder --task "Build REST API"
193
+
194
+ # Multi-agent swarm (3 agents in parallel)
195
+ npx agentic-flow # Uses TOPIC, DIFF, DATASET env vars
196
+ ```
197
+
198
+ **Why Local Development?**
199
+ - ✅ **All 203 MCP Tools**: Full subprocess support (claude-flow, flow-nexus, agentic-payments)
200
+ - ✅ **Fast Iteration**: No cold starts, instant feedback
201
+ - ✅ **Free**: No cloud costs during development
202
+ - ✅ **File Access**: Direct access to local filesystem
203
+ - ✅ **Git Integration**: Full GitHub operations
204
+ - ✅ **Memory Persistence**: Claude Flow memory persists across runs
205
+ - ✅ **Easy Debugging**: Standard Node.js debugging tools work
206
+
207
+ **System Requirements:**
208
+ - Node.js ≥18.0.0
209
+ - npm or pnpm
210
+ - 2GB RAM minimum (4GB recommended for swarms)
211
+ - macOS, Linux, or Windows
212
+
213
+ ---
214
+
215
+ ### 🎯 Flow Nexus Cloud Sandboxes (Best for Production Scale)
216
+ ```javascript
217
+ // Create isolated sandbox and execute agent with full MCP tool access
218
+ const { query } = require('@anthropic-ai/claude-agent-sdk');
219
+
220
+ // 1. Login to Flow Nexus
221
+ await flowNexus.login({ email: 'user@example.com', password: 'secure' });
222
+
223
+ // 2. Create E2B sandbox with Node.js template
224
+ const sandbox = await flowNexus.sandboxCreate({
225
+ template: 'node',
226
+ name: 'agent-execution',
227
+ env_vars: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY }
228
+ });
229
+
230
+ // 3. Execute agent in sandbox with all 203 MCP tools
231
+ const result = await flowNexus.sandboxExecute({
232
+ sandbox_id: sandbox.id,
233
+ code: `
234
+ const { query } = require('@anthropic-ai/claude-agent-sdk');
235
+ const result = await query({
236
+ prompt: "Analyze API security patterns",
237
+ options: {
238
+ mcpServers: { /* all 3 MCP servers available */ }
239
+ }
240
+ });
241
+ console.log(result);
242
+ `
243
+ });
244
+
245
+ // 4. Automatic cleanup
246
+ await flowNexus.sandboxDelete({ sandbox_id: sandbox.id });
247
+ ```
248
+
249
+ **Why Flow Nexus?**
250
+ - ✅ Full 203 MCP tool support (all subprocess servers work)
251
+ - ✅ Persistent memory across sandbox instances
252
+ - ✅ Multi-language templates (Node.js, Python, React, Next.js)
253
+ - ✅ Real-time output streaming
254
+ - ✅ Secure process isolation
255
+ - ✅ Pay-per-use pricing (10 credits/hour)
256
+
257
+ ---
258
+
259
+ ### 🐳 Docker Containers (Best for Production Deployments)
260
+
261
+ **Full 203 MCP tool support in containers:**
262
+
263
+ ```bash
264
+ # Build image
265
+ docker build -t agentic-flow .
266
+
267
+ # Run single agent
268
+ docker run --rm \
269
+ -e ANTHROPIC_API_KEY=sk-ant-... \
270
+ agentic-flow \
271
+ --agent researcher \
272
+ --task "Analyze microservices patterns"
273
+
274
+ # Multi-agent swarm in container
275
+ docker run --rm \
276
+ -e ANTHROPIC_API_KEY=sk-ant-... \
277
+ -e TOPIC="API security" \
278
+ -e DIFF="feat: auth" \
279
+ -e DATASET="logs.json" \
280
+ agentic-flow
281
+ ```
282
+
283
+ **Why Docker?**
284
+ - ✅ **All 203 MCP Tools**: Full subprocess support
285
+ - ✅ **Production Ready**: Works on Kubernetes, ECS, Cloud Run, Fargate
286
+ - ✅ **Reproducible**: Same environment everywhere
287
+ - ✅ **Isolated**: Process isolation and security
288
+ - ✅ **Orchestration**: Integrates with container orchestrators
289
+ - ✅ **CI/CD**: Perfect for automated workflows
290
+
291
+ **Container Orchestration Examples:**
292
+
293
+ ```yaml
294
+ # Kubernetes Job
295
+ apiVersion: batch/v1
296
+ kind: Job
297
+ metadata:
298
+ name: code-review
299
+ spec:
300
+ template:
301
+ spec:
302
+ containers:
303
+ - name: agent
304
+ image: agentic-flow:latest
305
+ args: ["--agent", "code-review", "--task", "Review PR #123"]
306
+ env:
307
+ - name: ANTHROPIC_API_KEY
308
+ valueFrom:
309
+ secretKeyRef:
310
+ name: anthropic
311
+ key: api-key
312
+ restartPolicy: Never
313
+
314
+ # GitHub Actions
315
+ - name: AI Code Review
316
+ run: |
317
+ docker run -e ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }} \
318
+ agentic-flow:latest \
319
+ --agent code-review \
320
+ --task "${{ github.event.pull_request.diff }}"
321
+
322
+ # AWS ECS Task Definition
323
+ {
324
+ "family": "agentic-flow-task",
325
+ "containerDefinitions": [{
326
+ "name": "agent",
327
+ "image": "agentic-flow:latest",
328
+ "command": ["--agent", "researcher", "--task", "$(TASK)"],
329
+ "environment": [
330
+ {"name": "ANTHROPIC_API_KEY", "value": "from-secrets-manager"}
331
+ ]
332
+ }]
333
+ }
334
+ ```
335
+
336
+ ### ⚠️ AWS Lambda (Limited - Not Recommended)
337
+ ```javascript
338
+ // Lambda limitations: No MCP subprocesses, only 6 in-SDK tools
339
+ exports.handler = async (event) => {
340
+ // ❌ claude-flow MCP server won't work (subprocess not allowed)
341
+ // ❌ flow-nexus MCP server won't work (subprocess not allowed)
342
+ // ✅ Only claude-flow-sdk in-SDK tools available (6 tools)
343
+
344
+ const result = await query({
345
+ prompt: event.query,
346
+ options: {
347
+ mcpServers: {
348
+ 'claude-flow-sdk': claudeFlowSdkServer // Only 6 tools work
349
+ // 'claude-flow': subprocess blocked by Lambda
350
+ // 'flow-nexus': subprocess blocked by Lambda
351
+ }
352
+ }
353
+ });
354
+
355
+ return { statusCode: 200, body: JSON.stringify(result) };
356
+ };
357
+ ```
358
+
359
+ **Why Lambda Doesn't Work Well:**
360
+ - ❌ Cannot spawn MCP subprocess servers (npx blocked)
361
+ - ❌ No access to 197 tools (101 claude-flow + 96 flow-nexus)
362
+ - ❌ No persistent memory (Claude Flow memory unavailable)
363
+ - ❌ Limited to 6 in-SDK tools only
364
+ - ✅ **Solution**: Use Flow Nexus sandboxes instead for full functionality
365
+
366
+ ---
367
+
368
+ ## 🎯 Use Cases & Costs
369
+
370
+ | Use Case | Agent Type | Execution Time | Local Cost | Docker Cost | Flow Nexus Cost |
371
+ |----------|-----------|----------------|------------|-------------|-----------------|
372
+ | **Code Review** | `code-review` | 15-45s | Free* | Self-hosted | 0.13-0.38 credits |
373
+ | **API Testing** | `tester` | 10-30s | Free* | Self-hosted | 0.08-0.25 credits |
374
+ | **Documentation** | `api-docs` | 20-60s | Free* | Self-hosted | 0.17-0.50 credits |
375
+ | **Data Analysis** | `data-analyst` | 30-90s | Free* | Self-hosted | 0.25-0.75 credits |
376
+ | **Security Audit** | `reviewer` | 45-120s | Free* | Self-hosted | 0.38-1.00 credits |
377
+ | **Microservice Generation** | `backend-dev` | 60-180s | Free* | Self-hosted | 0.50-1.50 credits |
378
+ | **Performance Analysis** | `perf-analyzer` | 20-60s | Free* | Self-hosted | 0.17-0.50 credits |
379
+
380
+ *Local: Free infrastructure, Claude API costs only ($0.003-0.015 per input 1K tokens, $0.015-0.075 per output 1K tokens)
381
+ Flow Nexus: 10 credits/hour sandbox (≈$1/hour) + Claude API costs. 1 credit ≈ $0.10.
382
+ Docker: Infrastructure costs (AWS/GCP/Azure) + Claude API costs.*
383
+
384
+ **Recommendation by Scenario:**
385
+ - **Development/Testing**: Use **Local** - free, fast, full tools
386
+ - **CI/CD Pipelines**: Use **Docker** - reproducible, isolated
387
+ - **Production Scale**: Use **Flow Nexus** - auto-scaling, cloud-native
388
+
389
+ ---
390
+
391
+ ## 🤖 Agent Types
392
+
393
+ ### Core Development Agents
394
+ - **`coder`** - Implementation specialist for writing clean, efficient code
395
+ - **`reviewer`** - Code review and quality assurance
396
+ - **`tester`** - Comprehensive testing with 90%+ coverage
397
+ - **`planner`** - Strategic planning and task decomposition
398
+ - **`researcher`** - Deep research and information gathering
399
+
400
+ ### Specialized Agents
401
+ - **`backend-dev`** - REST/GraphQL API development
402
+ - **`mobile-dev`** - React Native mobile apps
403
+ - **`ml-developer`** - Machine learning model creation
404
+ - **`system-architect`** - System design and architecture
405
+ - **`cicd-engineer`** - CI/CD pipeline creation
406
+ - **`api-docs`** - OpenAPI/Swagger documentation
407
+
408
+ ### Swarm Coordinators
409
+ - **`hierarchical-coordinator`** - Tree-based leadership
410
+ - **`mesh-coordinator`** - Peer-to-peer coordination
411
+ - **`adaptive-coordinator`** - Dynamic topology switching
412
+ - **`swarm-memory-manager`** - Cross-agent memory sync
413
+
414
+ ### GitHub Integration
415
+ - **`pr-manager`** - Pull request lifecycle management
416
+ - **`code-review-swarm`** - Multi-agent code review
417
+ - **`issue-tracker`** - Intelligent issue management
418
+ - **`release-manager`** - Automated release coordination
419
+ - **`workflow-automation`** - GitHub Actions specialist
420
+
421
+ ### Performance & Analysis
422
+ - **`perf-analyzer`** - Performance bottleneck detection
423
+ - **`production-validator`** - Deployment readiness checks
424
+ - **`tdd-london-swarm`** - Test-driven development
425
+
426
+ *Use `npx agentic-flow --list` to see all 75 agents*
427
+
428
+ ---
429
+
430
+ ## 📋 Commands
431
+
432
+ ### Basic Operations (Works Locally, Docker, Cloud)
433
+
434
+ ```bash
435
+ # List all available agents (75 total)
436
+ npx agentic-flow --list
437
+
438
+ # Run specific agent (local execution)
439
+ npx agentic-flow --agent <name> --task "<description>"
440
+
441
+ # Enable real-time streaming
442
+ npx agentic-flow --agent coder --task "Build API" --stream
443
+
444
+ # Run parallel mode (3 agents simultaneously)
445
+ npx agentic-flow # Requires TOPIC, DIFF, DATASET env vars
446
+ ```
447
+
448
+ ### Environment Configuration
449
+
450
+ ```bash
451
+ # Required
452
+ export ANTHROPIC_API_KEY=sk-ant-...
453
+
454
+ # Agent mode (optional)
455
+ export AGENT=researcher
456
+ export TASK="Your task description"
457
+
458
+ # Parallel mode (optional)
459
+ export TOPIC="research topic"
460
+ export DIFF="code changes"
461
+ export DATASET="data to analyze"
462
+
463
+ # Options
464
+ export ENABLE_STREAMING=true
465
+ export HEALTH_PORT=8080
466
+ ```
467
+
468
+ ### Docker Deployment
469
+
470
+ ```bash
471
+ # Build image
472
+ docker build -t agentic-flow .
473
+
474
+ # Run agent in container
475
+ docker run --rm \
476
+ -e ANTHROPIC_API_KEY=sk-ant-... \
477
+ agentic-flow \
478
+ --agent researcher \
479
+ --task "Analyze cloud patterns"
480
+
481
+ # Run with streaming
482
+ docker run --rm \
483
+ -e ANTHROPIC_API_KEY=sk-ant-... \
484
+ -e ENABLE_STREAMING=true \
485
+ agentic-flow \
486
+ --agent coder --task "Build REST API" --stream
487
+ ```
488
+
489
+ ---
490
+
491
+ ---
492
+
493
+ ## 🎛️ Using the Multi-Model Router
494
+
495
+ ### Quick Start with Router
496
+
497
+ ```javascript
498
+ import { ModelRouter } from 'agentic-flow/router';
499
+
500
+ // Initialize router (auto-loads configuration)
501
+ const router = new ModelRouter();
502
+
503
+ // Use default provider (Anthropic)
504
+ const response = await router.chat({
505
+ model: 'claude-3-5-sonnet-20241022',
506
+ messages: [{ role: 'user', content: 'Your prompt here' }]
507
+ });
508
+
509
+ console.log(response.content[0].text);
510
+ console.log(`Cost: $${response.metadata.cost}`);
511
+ ```
512
+
513
+ ### Available Providers
514
+
515
+ The router supports multiple LLM providers with automatic fallback:
516
+
517
+ **Anthropic (Cloud)**
518
+ - Models: Claude 3.5 Sonnet, Claude 3.5 Haiku, Claude 3 Opus
519
+ - Cost: $0.003/1K input tokens, $0.015/1K output tokens
520
+ - Best for: Complex reasoning, advanced coding, long conversations
521
+
522
+ **OpenRouter (Multi-Model Gateway)**
523
+ - Models: 100+ models from multiple providers
524
+ - Cost: $0.002-0.10/1K tokens (varies by model)
525
+ - Best for: Cost optimization, model diversity, fallback
526
+
527
+ **ONNX Runtime (Free Local)**
528
+ - Models: Microsoft Phi-4-mini-instruct (INT4 quantized)
529
+ - Cost: **$0.00** (100% free)
530
+ - Best for: Privacy-sensitive data, offline operation, zero-cost development
531
+
532
+ **Ollama (Local Server - Coming Soon)**
533
+ - Models: Any Ollama-supported model
534
+ - Cost: Free (requires local Ollama server)
535
+ - Best for: Local development with larger models
536
+
537
+ **LiteLLM (Gateway - Coming Soon)**
538
+ - Models: Unified API for 100+ providers
539
+ - Cost: Varies by provider
540
+ - Best for: Multi-cloud deployments
541
+
542
+ **Configuration Example:**
543
+ ```json
544
+ // router.config.json
545
+ {
546
+ "defaultProvider": "anthropic",
547
+ "fallbackChain": ["anthropic", "onnx", "openrouter"],
548
+ "providers": {
549
+ "anthropic": {
550
+ "apiKey": "sk-ant-...",
551
+ "models": { "default": "claude-3-5-sonnet-20241022" }
552
+ },
553
+ "openrouter": {
554
+ "apiKey": "sk-or-...",
555
+ "baseUrl": "https://openrouter.ai/api/v1",
556
+ "models": { "default": "anthropic/claude-3.5-sonnet" }
557
+ },
558
+ "onnx": {
559
+ "modelPath": "./models/phi-4/.../model.onnx",
560
+ "executionProviders": ["cpu"],
561
+ "localInference": true
562
+ }
563
+ }
564
+ }
565
+ ```
566
+
567
+ ### OpenRouter Integration (99% Cost Savings)
568
+
569
+ Access 100+ LLM models through OpenRouter for dramatic cost savings while maintaining full functionality:
570
+
571
+ ```bash
572
+ # Set OpenRouter API key
573
+ export OPENROUTER_API_KEY=sk-or-v1-...
574
+
575
+ # Use any OpenRouter model (proxy auto-starts)
576
+ npx agentic-flow \
577
+ --agent coder \
578
+ --task "Build REST API" \
579
+ --model "meta-llama/llama-3.1-8b-instruct"
580
+
581
+ # Or force OpenRouter mode
582
+ export USE_OPENROUTER=true
583
+ npx agentic-flow --agent coder --task "Build REST API"
584
+ ```
585
+
586
+ **Popular OpenRouter Models:**
587
+ - `meta-llama/llama-3.1-8b-instruct` - 99% cost savings, excellent coding
588
+ - `deepseek/deepseek-chat-v3.1` - Superior code generation at 97% savings
589
+ - `google/gemini-2.5-flash-preview-09-2025` - Fastest responses, 95% savings
590
+ - `anthropic/claude-3.5-sonnet` - Full Claude via OpenRouter
591
+
592
+ **Cost Comparison:**
593
+ | Provider | Model | Input (1K tokens) | Output (1K tokens) | Savings |
594
+ |----------|-------|-------------------|-------------------|---------|
595
+ | Anthropic Direct | Claude 3.5 Sonnet | $0.003 | $0.015 | Baseline |
596
+ | OpenRouter | Llama 3.1 8B | $0.00003 | $0.00006 | **99%** |
597
+ | OpenRouter | DeepSeek V3.1 | $0.00014 | $0.00028 | **97%** |
598
+ | OpenRouter | Gemini 2.5 Flash | $0.000075 | $0.0003 | **95%** |
599
+
600
+ **How It Works:**
601
+ 1. Detects OpenRouter model (contains "/") or USE_OPENROUTER=true
602
+ 2. Auto-starts integrated proxy server on port 3000
603
+ 3. Translates Anthropic Messages API ↔ OpenAI Chat Completions API
604
+ 4. Claude Agent SDK transparently uses OpenRouter via ANTHROPIC_BASE_URL
605
+ 5. Full MCP tool support (all 203 tools work)
606
+
607
+ **Environment Variables:**
608
+ ```bash
609
+ # Required for OpenRouter
610
+ export OPENROUTER_API_KEY=sk-or-v1-...
611
+
612
+ # Optional configuration
613
+ export USE_OPENROUTER=true # Force OpenRouter usage
614
+ export COMPLETION_MODEL=meta-llama/... # Default OpenRouter model
615
+ export PROXY_PORT=3000 # Proxy server port
616
+ ```
617
+
618
+ ### Free ONNX Local Inference
619
+
620
+ Run agents with **zero API costs** using local ONNX models:
621
+
622
+ ```javascript
623
+ // CPU Inference (6 tokens/sec, 100% free)
624
+ const router = new ModelRouter();
625
+ const onnxProvider = router.providers.get('onnx');
626
+
627
+ const response = await onnxProvider.chat({
628
+ model: 'phi-4',
629
+ messages: [{ role: 'user', content: 'Analyze this sensitive data...' }],
630
+ maxTokens: 100
631
+ });
632
+
633
+ console.log(response.content[0].text);
634
+ console.log(`Cost: $${response.metadata.cost}`); // $0.00
635
+ console.log(`Latency: ${response.metadata.latency}ms`);
636
+ console.log(`Privacy: 100% local processing`);
637
+ ```
638
+
639
+ ### Privacy-Based Routing
640
+
641
+ Automatically route privacy-sensitive workloads to free local ONNX inference:
642
+
643
+ ```javascript
644
+ // Configure privacy routing in router.config.json
645
+ {
646
+ "routing": {
647
+ "mode": "rule-based",
648
+ "rules": [
649
+ {
650
+ "condition": { "privacy": "high", "localOnly": true },
651
+ "action": { "provider": "onnx" },
652
+ "reason": "Privacy-sensitive tasks use free ONNX local models"
653
+ }
654
+ ]
655
+ }
656
+ }
657
+
658
+ // Router automatically uses ONNX for privacy workloads
659
+ const response = await router.chat({
660
+ model: 'any-model',
661
+ messages: [{ role: 'user', content: 'Process medical records...' }],
662
+ metadata: { privacy: 'high', localOnly: true }
663
+ });
664
+
665
+ // Routed to ONNX automatically (zero cost, 100% local)
666
+ console.log(response.metadata.provider); // "onnx-local"
667
+ ```
668
+
669
+ ### GPU Acceleration
670
+
671
+ Enable GPU acceleration for 10-50x performance boost:
672
+
673
+ ```json
674
+ // router.config.json
675
+ {
676
+ "providers": {
677
+ "onnx": {
678
+ "executionProviders": ["cuda"], // or ["dml"] for Windows
679
+ "gpuAcceleration": true,
680
+ "modelPath": "./models/phi-4/...",
681
+ "maxTokens": 100
682
+ }
683
+ }
684
+ }
685
+ ```
686
+
687
+ **Performance Comparison:**
688
+ - CPU: 6 tokens/sec (free)
689
+ - GPU (CUDA): 60-300 tokens/sec (free)
690
+ - Cloud API: Variable (costs $0.002-0.003/request)
691
+
692
+ ### Zero-Cost Agent Execution
693
+
694
+ Run agents entirely offline with local ONNX models:
695
+
696
+ ```bash
697
+ # Use ONNX provider for free inference
698
+ npx agentic-flow \
699
+ --agent researcher \
700
+ --task "Analyze this privacy-sensitive data" \
701
+ --provider onnx \
702
+ --local-only
703
+
704
+ # Result: $0.00 cost, 100% local processing
705
+ ```
706
+
707
+ ### Cost Comparison
708
+
709
+ | Workload Type | Provider | Cost per Request | Privacy | Performance |
710
+ |---------------|----------|------------------|---------|-------------|
711
+ | **Privacy-Sensitive** | ONNX (CPU) | **$0.00** | 100% local | 6 tokens/sec |
712
+ | **Privacy-Sensitive** | ONNX (GPU) | **$0.00** | 100% local | 60-300 tokens/sec |
713
+ | **Complex Reasoning** | Anthropic Claude | $0.003 | Cloud | Fast |
714
+ | **General Tasks** | OpenRouter | $0.002 | Cloud | Variable |
715
+
716
+ **Example Monthly Costs (1000 requests/day):**
717
+ - 100% ONNX: **$0** (free local inference)
718
+ - 50% ONNX, 50% cloud: **$30-45** (50% savings)
719
+ - 100% cloud APIs: **$60-90**
720
+
721
+ ---
722
+
723
+ ## 🔧 MCP Tools (203+)
724
+
725
+ Agentic Flow integrates with **four MCP servers** providing 203+ tools:
726
+
727
+ ### Core Orchestration (claude-flow - 101 tools)
728
+
729
+ | Category | Tools | Capabilities |
730
+ |----------|-------|--------------|
731
+ | **Swarm Management** | 12 | Initialize, spawn, coordinate multi-agent swarms |
732
+ | **Memory & Storage** | 10 | Persistent memory with TTL and namespaces |
733
+ | **Neural Networks** | 12 | Training, inference, WASM-accelerated computation |
734
+ | **GitHub Integration** | 8 | PR management, code review, repository analysis |
735
+ | **Performance** | 11 | Metrics, bottleneck detection, optimization |
736
+ | **Workflow Automation** | 9 | Task orchestration, CI/CD integration |
737
+ | **Dynamic Agents** | 7 | Runtime agent creation and coordination |
738
+ | **System Utilities** | 8 | Health checks, diagnostics, feature detection |
739
+
740
+ ### Cloud Platform (flow-nexus - 96 tools)
741
+
742
+ | Category | Tools | Capabilities |
743
+ |----------|-------|--------------|
744
+ | **☁️ E2B Sandboxes** | 12 | Isolated execution environments (Node, Python, React) |
745
+ | **☁️ Distributed Swarms** | 8 | Cloud-based multi-agent deployment |
746
+ | **☁️ Neural Training** | 10 | Distributed model training clusters |
747
+ | **☁️ Workflows** | 9 | Event-driven automation with message queues |
748
+ | **☁️ Templates** | 8 | Pre-built project templates and marketplace |
749
+ | **☁️ Challenges** | 6 | Coding challenges with leaderboards |
750
+ | **☁️ User Management** | 7 | Authentication, profiles, credit management |
751
+ | **☁️ Storage** | 5 | Cloud file storage with real-time sync |
752
+
753
+ ### Payment Authorization (agentic-payments - MCP tools)
754
+
755
+ Multi-agent payment infrastructure for autonomous AI commerce:
756
+
757
+ | Category | Tools | Capabilities |
758
+ |----------|-------|--------------|
759
+ | **💳 Active Mandates** | MCP | Create spending limits, time windows, merchant restrictions |
760
+ | **🔐 Ed25519 Signatures** | MCP | Cryptographic transaction signing (<1ms verification) |
761
+ | **🤝 Multi-Agent Consensus** | MCP | Byzantine fault-tolerant transaction approval |
762
+ | **📊 Payment Tracking** | MCP | Authorization to settlement lifecycle monitoring |
763
+ | **🛡️ Security** | MCP | Spend caps, revocation, audit trails |
764
+
765
+ **Use Cases:**
766
+ - E-commerce: AI shopping agents with weekly budgets
767
+ - Finance: Robo-advisors executing trades within portfolios
768
+ - Enterprise: Multi-agent procurement with consensus approval
769
+ - Accounting: Automated AP/AR with policy-based workflows
770
+
771
+ **Protocols:**
772
+ - **AP2**: Agent Payments Protocol with Ed25519 signatures
773
+ - **ACP**: Agentic Commerce Protocol (Stripe-compatible)
774
+ - **MCP**: Natural language interface for AI assistants
775
+
776
+ ### In-Process Tools (claude-flow-sdk - 6 tools)
777
+
778
+ Fast, zero-latency tools running in-process:
779
+ - `memory_store`, `memory_retrieve`, `memory_list`
780
+ - `swarm_init`, `agent_spawn`, `coordination_sync`
781
+
782
+ ---
783
+
784
+ ## ⚡ FastMCP Integration (New)
785
+
786
+ Agentic Flow now supports **[FastMCP](https://github.com/QuantGeekDev/fastmcp)**, a modern TypeScript framework for building high-performance MCP servers with:
787
+
788
+ - **Dual Transport**: stdio (local/subprocess) + HTTP streaming (cloud/network)
789
+ - **Type Safety**: Full TypeScript + Zod schema validation
790
+ - **Progress Reporting**: Real-time execution feedback
791
+ - **Authentication**: JWT, API keys, OAuth 2.0 support
792
+ - **Rate Limiting**: Built-in abuse prevention
793
+
794
+ ### POC Server (Phase 0 - Completed ✅)
795
+
796
+ Basic stdio server with 2 tools to validate fastmcp integration:
797
+
798
+ ```bash
799
+ # Test the POC server
800
+ npm run test:fastmcp
801
+
802
+ # Or run directly
803
+ npm run mcp:fastmcp-poc
804
+ ```
805
+
806
+ ### Using with Claude Code
807
+
808
+ Add to your MCP config (`~/.config/claude/mcp.json`):
809
+
810
+ ```json
811
+ {
812
+ "mcpServers": {
813
+ "fastmcp-poc": {
814
+ "command": "node",
815
+ "args": ["/path/to/agentic-flow/dist/mcp/fastmcp/servers/poc-stdio.js"]
816
+ }
817
+ }
818
+ }
819
+ ```
820
+
821
+ ### Available FastMCP Tools (POC)
822
+
823
+ | Tool | Description | Status |
824
+ |------|-------------|--------|
825
+ | `memory_store` | Store value in persistent memory | ✅ Working |
826
+ | `memory_retrieve` | Retrieve value from memory | ✅ Working |
827
+
828
+ **Coming Soon (Phase 1):**
829
+ - Migration of 6 claude-flow-sdk tools to fastmcp
830
+ - HTTP streaming transport with authentication
831
+ - Direct in-process execution (no execSync)
832
+ - Comprehensive test suite
833
+
834
+ **Documentation:**
835
+ - [FastMCP Implementation Plan](docs/mcp/fastmcp-implementation-plan.md) - 10-week migration strategy
836
+ - [FastMCP POC Integration](docs/mcp/fastmcp-poc-integration.md) - Usage and testing guide
837
+
838
+ ---
839
+
840
+ ## 🔍 Deployment Comparison
841
+
842
+ | Feature | Local | Docker | Flow Nexus Sandboxes | AWS Lambda |
843
+ |---------|-------|--------|----------------------|------------|
844
+ | **MCP Tools Available** | 203 (100%) | 203 (100%) | 203 (100%) | 6 (3%) |
845
+ | **Setup Complexity** | Low | Medium | Medium | High |
846
+ | **Cold Start Time** | <500ms | <2s | <2s | <800ms |
847
+ | **Cost (Development)** | Free* | Free* | $1/hour | $0.20/1M |
848
+ | **Cost (Production)** | Free* | Infra costs | $1/hour | Limited tools |
849
+ | **Scaling** | Manual | Orchestrator | Automatic | Automatic |
850
+ | **Best For** | Dev/Testing | CI/CD/Prod | Cloud-Scale | ❌ Not Recommended |
851
+
852
+ *Free infrastructure, Claude API costs only
853
+
854
+ ---
855
+
856
+ ## 📦 Advanced Deployment Patterns
857
+
858
+ ### ☁️ Flow Nexus Cloud Sandboxes (Scalable Production)
859
+
860
+ **Best for cloud-native, auto-scaling workloads:**
861
+
862
+ ```javascript
863
+ // Full-featured agent execution in isolated E2B sandboxes
864
+ import { flowNexus } from 'flow-nexus';
865
+
866
+ // Setup: One-time authentication
867
+ await flowNexus.login({
868
+ email: process.env.FLOW_NEXUS_EMAIL,
869
+ password: process.env.FLOW_NEXUS_PASSWORD
870
+ });
871
+
872
+ // Deploy: Create sandbox and execute
873
+ async function deployAgent(task) {
874
+ // 1. Create isolated sandbox
875
+ const sandbox = await flowNexus.sandboxCreate({
876
+ template: 'node', // or 'python', 'react', 'nextjs'
877
+ name: `agent-${Date.now()}`,
878
+ env_vars: {
879
+ ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY
880
+ },
881
+ install_packages: ['@anthropic-ai/claude-agent-sdk'],
882
+ timeout: 3600 // 1 hour max
883
+ });
884
+
885
+ // 2. Execute agent with ALL 203 MCP tools
886
+ const result = await flowNexus.sandboxExecute({
887
+ sandbox_id: sandbox.id,
888
+ code: `
889
+ const { query } = require('@anthropic-ai/claude-agent-sdk');
890
+ const result = await query({
891
+ prompt: "${task}",
892
+ options: {
893
+ permissionMode: 'bypassPermissions',
894
+ mcpServers: {
895
+ 'claude-flow-sdk': /* 6 tools */,
896
+ 'claude-flow': /* 101 tools */,
897
+ 'flow-nexus': /* 96 tools */
898
+ }
899
+ }
900
+ });
901
+ console.log(JSON.stringify(result));
902
+ `,
903
+ language: 'javascript',
904
+ capture_output: true
905
+ });
906
+
907
+ // 3. Cleanup (automatic after timeout)
908
+ await flowNexus.sandboxDelete({ sandbox_id: sandbox.id });
909
+
910
+ return result;
911
+ }
912
+ ```
913
+
914
+ **Why Flow Nexus is Recommended:**
915
+ - ✅ **Full MCP Support**: All 203 tools work (subprocess servers supported)
916
+ - ✅ **Persistent Memory**: Claude Flow memory persists across sandboxes
917
+ - ✅ **Security**: Complete process isolation per sandbox
918
+ - ✅ **Multi-Language**: Node.js, Python, React, Next.js templates
919
+ - ✅ **Real-Time**: Live output streaming and monitoring
920
+ - ✅ **Cost-Effective**: Pay per use (10 credits/hour ≈ $1/hour)
921
+
922
+ **Flow Nexus Pricing:**
923
+ | Resource | Cost | Notes |
924
+ |----------|------|-------|
925
+ | Sandbox (hourly) | 10 credits | ≈ $1/hour per sandbox |
926
+ | Storage | 1 credit/GB/month | Files and environment data |
927
+ | Credits Package | $10 = 100 credits | 10+ hours of sandbox time |
928
+
929
+ ---
930
+
931
+ ### 🐳 Container Platforms (Production Orchestration)
932
+
933
+ #### Docker (ECS, Cloud Run, Fargate, Kubernetes)
934
+
935
+ ```dockerfile
936
+ FROM node:20-slim
937
+ WORKDIR /app
938
+ COPY package*.json ./
939
+ RUN npm ci --production
940
+ COPY . .
941
+ CMD ["npm", "start", "--", "--agent", "${AGENT}", "--task", "${TASK}"]
942
+ ```
943
+
944
+ **Best Practices:**
945
+ - Use multi-stage builds for smaller images
946
+ - Enable health checks for orchestrators
947
+ - Set resource limits (CPU/memory)
948
+ - All 203 MCP tools available (subprocess servers work)
949
+ - Use secrets managers for API keys
950
+
951
+ #### Kubernetes
952
+
953
+ ```yaml
954
+ apiVersion: batch/v1
955
+ kind: Job
956
+ metadata:
957
+ name: agentic-flow-job
958
+ spec:
959
+ template:
960
+ spec:
961
+ containers:
962
+ - name: agent
963
+ image: agentic-flow:latest
964
+ args: ["--agent", "researcher", "--task", "$(TASK)"]
965
+ env:
966
+ - name: ANTHROPIC_API_KEY
967
+ valueFrom:
968
+ secretKeyRef:
969
+ name: anthropic-secret
970
+ key: api-key
971
+ restartPolicy: Never
972
+ ```
973
+
974
+ **Best Practices:**
975
+ - Use Jobs for ephemeral executions
976
+ - Set activeDeadlineSeconds for timeouts
977
+ - Use node selectors for cost optimization
978
+ - Implement PodDisruptionBudgets
979
+ - All 203 MCP tools available
980
+
981
+ ### ⚠️ Serverless Functions (Limited - Not Recommended)
982
+
983
+ #### AWS Lambda (Restricted)
984
+
985
+ ```javascript
986
+ // ❌ THIS WON'T WORK AS EXPECTED
987
+ // Lambda blocks subprocess spawning, breaking MCP servers
988
+
989
+ import { query } from '@anthropic-ai/claude-agent-sdk';
990
+ import { claudeFlowSdkServer } from './mcp/claudeFlowSdkServer.js';
991
+
992
+ export const handler = async (event) => {
993
+ const result = await query({
994
+ prompt: event.task,
995
+ options: {
996
+ permissionMode: 'bypassPermissions',
997
+ mcpServers: {
998
+ // ✅ Works: In-SDK server (6 tools)
999
+ 'claude-flow-sdk': claudeFlowSdkServer,
1000
+
1001
+ // ❌ Blocked: Cannot spawn subprocess
1002
+ // 'claude-flow': { command: 'npx', args: [...] },
1003
+
1004
+ // ❌ Blocked: Cannot spawn subprocess
1005
+ // 'flow-nexus': { command: 'npx', args: [...] }
1006
+ }
1007
+ }
1008
+ });
1009
+
1010
+ return { statusCode: 200, body: JSON.stringify(result) };
1011
+ };
1012
+ ```
1013
+
1014
+ **Lambda Limitations:**
1015
+ | Feature | Status | Notes |
1016
+ |---------|--------|-------|
1017
+ | Claude Agent SDK | ✅ Works | Core SDK functions normally |
1018
+ | In-SDK MCP Tools | ✅ Works | 6 tools from claude-flow-sdk |
1019
+ | Claude Flow MCP | ❌ Blocked | Cannot spawn `npx claude-flow` subprocess |
1020
+ | Flow Nexus MCP | ❌ Blocked | Cannot spawn `npx flow-nexus` subprocess |
1021
+ | Persistent Memory | ❌ Unavailable | Claude Flow memory requires subprocess |
1022
+ | Total Tools | 6/203 | Only 3% of tools work |
1023
+
1024
+ **Why Lambda Fails:**
1025
+ 1. **Subprocess Restrictions**: Lambda blocks `child_process.spawn()` for security
1026
+ 2. **No npx**: Cannot run `npx claude-flow` or `npx flow-nexus`
1027
+ 3. **Memory Architecture**: Persistent memory requires subprocess MCP server
1028
+ 4. **File System**: Read-only `/tmp` prevents MCP server file operations
1029
+
1030
+ **Solution: Use Flow Nexus sandboxes instead** - Full 203 tool support with Lambda-triggered sandbox execution:
1031
+
1032
+ ```javascript
1033
+ // ✅ RECOMMENDED: Lambda triggers Flow Nexus sandbox
1034
+ import { flowNexus } from 'flow-nexus';
1035
+
1036
+ export const handler = async (event) => {
1037
+ // Lambda just orchestrates - execution happens in sandbox
1038
+ const sandbox = await flowNexus.sandboxCreate({
1039
+ template: 'node',
1040
+ env_vars: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY }
1041
+ });
1042
+
1043
+ const result = await flowNexus.sandboxExecute({
1044
+ sandbox_id: sandbox.id,
1045
+ code: `/* Full agent code with all 203 tools */`
1046
+ });
1047
+
1048
+ await flowNexus.sandboxDelete({ sandbox_id: sandbox.id });
1049
+
1050
+ return { statusCode: 200, body: JSON.stringify(result) };
1051
+ };
1052
+ ```
1053
+
1054
+ ---
1055
+
1056
+ ## 📊 Architecture
1057
+
1058
+ ### Ephemeral Agent Lifecycle
1059
+
1060
+ ```
1061
+ 1. REQUEST → Agent definition loaded from YAML
1062
+ 2. SPAWN → Agent initialized with system prompt + tools
1063
+ 3. EXECUTE → Task processed using Claude SDK + MCP tools
1064
+ 4. STREAM → Real-time output (optional)
1065
+ 5. COMPLETE → Result returned to caller
1066
+ 6. TERMINATE → Agent process exits, memory released
1067
+ ```
1068
+
1069
+ **Key Characteristics:**
1070
+ - **Cold Start**: <2s (includes MCP server initialization)
1071
+ - **Warm Start**: <500ms (MCP servers cached)
1072
+ - **Memory Usage**: 100-200MB per agent
1073
+ - **Concurrent Agents**: Limited only by host resources
1074
+
1075
+ ### Multi-Agent Coordination
1076
+
1077
+ ```
1078
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
1079
+ │ Researcher │────▶│ Memory │◀────│ Code Review │
1080
+ │ Agent │ │ Storage │ │ Agent │
1081
+ └─────────────┘ └─────────────┘ └─────────────┘
1082
+
1083
+
1084
+ ┌─────────────┐
1085
+ │ Data │
1086
+ │ Analyst │
1087
+ └─────────────┘
1088
+ ```
1089
+
1090
+ **Coordination via:**
1091
+ - Shared memory (in-process or external)
1092
+ - Claude Flow MCP tools
1093
+ - File system (for batch jobs)
1094
+ - Message queues (for async workflows)
1095
+
1096
+ ---
1097
+
1098
+ ## 🔍 Advanced Usage
1099
+
1100
+ ### Custom Agent Definition
1101
+
1102
+ Create `.claude/agents/custom/my-agent.md`:
1103
+
1104
+ ```markdown
1105
+ ---
1106
+ name: my-agent
1107
+ description: Custom agent for specific tasks
1108
+ ---
1109
+
1110
+ # System Prompt
1111
+
1112
+ You are a specialized agent for [your use case].
1113
+
1114
+ ## Capabilities
1115
+ - [List capabilities]
1116
+
1117
+ ## Guidelines
1118
+ - [Execution guidelines]
1119
+ ```
1120
+
1121
+ ### Programmatic API
1122
+
1123
+ ```javascript
1124
+ import { query } from '@anthropic-ai/claude-agent-sdk';
1125
+ import { getAgent } from 'agentic-flow/utils';
1126
+
1127
+ const agent = getAgent('researcher');
1128
+ const result = await query({
1129
+ prompt: 'Analyze AI trends',
1130
+ options: {
1131
+ systemPrompt: agent.systemPrompt,
1132
+ permissionMode: 'bypassPermissions'
1133
+ }
1134
+ });
1135
+
1136
+ console.log(result.output);
1137
+ ```
1138
+
1139
+ ### Flow Nexus Integration
1140
+
1141
+ Requires registration for cloud features:
1142
+
1143
+ ```bash
1144
+ # Register account
1145
+ npx agentic-flow --agent flow-nexus-auth \
1146
+ --task "Register with email: user@example.com"
1147
+
1148
+ # Login
1149
+ npx agentic-flow --agent flow-nexus-auth \
1150
+ --task "Login with email: user@example.com, password: ***"
1151
+
1152
+ # Create cloud sandbox
1153
+ npx agentic-flow --agent flow-nexus-sandbox \
1154
+ --task "Create Node.js sandbox and execute: console.log('Hello')"
1155
+ ```
1156
+
1157
+ ---
1158
+
1159
+ ## 📈 Performance & Scaling
1160
+
1161
+ ### Benchmarks
1162
+
1163
+ | Metric | Result |
1164
+ |--------|--------|
1165
+ | **Cold Start** | <2s (including MCP initialization) |
1166
+ | **Warm Start** | <500ms (cached MCP servers) |
1167
+ | **Agent Spawn** | 75 agents loaded in <2s |
1168
+ | **Tool Discovery** | 203 tools accessible in <1s |
1169
+ | **Memory Footprint** | 100-200MB per agent process |
1170
+ | **Concurrent Agents** | 10+ on t3.small, 100+ on c6a.xlarge |
1171
+ | **Token Efficiency** | 32% reduction via swarm coordination |
1172
+
1173
+ ### Cost Analysis (AWS Lambda arm64)
1174
+
1175
+ | Memory | Duration | Cost per Invocation | Monthly (10K requests) |
1176
+ |--------|----------|---------------------|------------------------|
1177
+ | 1GB | 30s | $0.0008 | $8 |
1178
+ | 2GB | 30s | $0.0016 | $16 |
1179
+ | 2GB | 60s | $0.0032 | $32 |
1180
+ | 4GB | 60s | $0.0064 | $64 |
1181
+
1182
+ *Free tier: 400,000 GB-seconds/month*
1183
+
1184
+ ---
1185
+
1186
+ ## 🛠️ Development
1187
+
1188
+ ### Build from Source
1189
+
1190
+ ```bash
1191
+ # Clone repository
1192
+ git clone https://github.com/ruvnet/agentic-flow.git
1193
+ cd agentic-flow
1194
+
1195
+ # Install dependencies
1196
+ npm install
1197
+
1198
+ # Build TypeScript
1199
+ npm run build
1200
+
1201
+ # Test locally
1202
+ node dist/cli.js --help
1203
+ ```
1204
+
1205
+ ### Testing
1206
+
1207
+ ```bash
1208
+ # Run all tests
1209
+ npm test
1210
+
1211
+ # Test specific agent
1212
+ node dist/cli.js --agent researcher --task "Test task"
1213
+
1214
+ # Validate MCP tools
1215
+ npm run validate
1216
+ ```
1217
+
1218
+ ### Adding Custom Agents
1219
+
1220
+ 1. Create agent definition: `.claude/agents/custom/my-agent.md`
1221
+ 2. Define system prompt and capabilities
1222
+ 3. Test: `npx agentic-flow --agent my-agent --task "Test"`
1223
+ 4. Deploy: `npm run build && docker build -t my-agents .`
1224
+
1225
+ ---
1226
+
1227
+ ## 🔗 Links
1228
+
1229
+ - **Documentation**: [docs/](docs/)
1230
+ - **GitHub**: [github.com/ruvnet/agentic-flow](https://github.com/ruvnet/agentic-flow)
1231
+ - **npm Package**: [npmjs.com/package/agentic-flow](https://www.npmjs.com/package/agentic-flow)
1232
+ - **Claude Agent SDK**: [docs.claude.com/en/api/agent-sdk](https://docs.claude.com/en/api/agent-sdk)
1233
+ - **Flow Nexus Platform**: [github.com/ruvnet/flow-nexus](https://github.com/ruvnet/flow-nexus)
1234
+
1235
+ ---
1236
+
1237
+ ## 🤝 Contributing
1238
+
1239
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
1240
+
1241
+ ### Development Setup
1242
+ 1. Fork the repository
1243
+ 2. Create feature branch: `git checkout -b feature/amazing-feature`
1244
+ 3. Make changes and add tests
1245
+ 4. Ensure tests pass: `npm test`
1246
+ 5. Commit: `git commit -m "feat: add amazing feature"`
1247
+ 6. Push: `git push origin feature/amazing-feature`
1248
+ 7. Open Pull Request
1249
+
1250
+ ---
1251
+
1252
+ ## 📄 License
1253
+
1254
+ MIT License - see [LICENSE](LICENSE) for details.
1255
+
1256
+ ---
1257
+
1258
+ ## 🙏 Acknowledgments
1259
+
1260
+ Built with:
1261
+ - [Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk) by Anthropic
1262
+ - [Claude Flow](https://github.com/ruvnet/claude-flow) - 101 MCP tools
1263
+ - [Flow Nexus](https://github.com/ruvnet/flow-nexus) - 96 cloud tools
1264
+ - [Model Context Protocol](https://modelcontextprotocol.io) by Anthropic
1265
+
1266
+ ---
1267
+
1268
+ ## 💬 Support
1269
+
1270
+ - **Documentation**: See [docs/](docs/) folder
1271
+ - **Issues**: [GitHub Issues](https://github.com/ruvnet/agentic-flow/issues)
1272
+ - **Discussions**: [GitHub Discussions](https://github.com/ruvnet/agentic-flow/discussions)
1273
+
1274
+ ---
1275
+
1276
+ **Deploy ephemeral AI agents in seconds. Scale to thousands. Pay only for what you use.** 🚀
1277
+
1278
+ ```bash
1279
+ npx agentic-flow --agent researcher --task "Your task here"
1280
+ ```