agentic-flow 1.1.10 β†’ 1.1.12

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/README.md CHANGED
@@ -1,476 +1,250 @@
1
1
  # πŸ€– Agentic Flow
2
2
 
3
- **Production-Ready AI Agent Orchestration with Multi-Model Router, OpenRouter Integration & Free Local Inference**
4
-
5
- Agentic Flow works with any agent or command built or used in Claude Code. It automatically runs through the Claude Agent SDK, forming swarms of intelligent, cost and performance-optimized agents that decide how to execute each task. Built for business, government, and commercial use where cost, traceability, and reliability matter.
6
-
7
- Agentic Flow runs Claude Code agents at near zero cost without rewriting a thing. It routes every task to the cheapest lane that still meets the bar. Local ONNX when privacy or price wins. OpenRouter for breadth. Gemini for speed. Anthropic when quality matters most. One agent. Any model. Lowest viable cost.
8
-
9
- The system takes the Claude SDK's logic and merges it with Claude Flow memory to give every agent a durable brain. Each run logs inputs, outputs, and route decisions with artifacts, manifests, and checksums for proof and reproducibility. It self-optimizes in real time, balancing price, latency, and accuracy through a simple policy file.
10
-
11
- Strict mode keeps sensitive data offline. Economy mode prefers ONNX or OpenRouter. Premium mode goes Anthropic first. The policy defines the rules, and the swarm enforces them automatically.
12
-
13
- It runs anywhere: local for dev, Docker for CI, or Flow Nexus for scale. With project-scoped settings, explicit tool allowlists, and an offline privacy lane, it stays secure by default.
14
-
15
- **Agentic Flow is the framework for autonomous efficiencyβ€”one unified runner for every Claude Code agent, self-tuning, self-routing, and built for real-world deployment.**
16
-
17
- 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), **Google Gemini** (fast, cost-effective inference), **[Agentic Payments](https://www.npmjs.com/package/agentic-payments)** (payment authorization), and **ONNX Runtime** (free local CPU or GPU inference).
18
-
19
3
  [![npm version](https://img.shields.io/npm/v/agentic-flow.svg)](https://www.npmjs.com/package/agentic-flow)
20
4
  [![npm downloads](https://img.shields.io/npm/dm/agentic-flow.svg)](https://www.npmjs.com/package/agentic-flow)
21
- [![npm total downloads](https://img.shields.io/npm/dt/agentic-flow.svg)](https://www.npmjs.com/package/agentic-flow)
22
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
23
6
  [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
24
7
  [![rUv](https://img.shields.io/badge/by-rUv-purple.svg)](https://github.com/ruvnet/)
25
- [![Agentic Engineering](https://img.shields.io/badge/Agentic-Engineering-orange.svg)](https://github.com/ruvnet/agentic-flow#-agent-types)
26
-
27
- ---
28
-
29
- ## Why Agentic Flow?
30
-
31
- **The Problem:** You need agents that actually complete tasks, not chatbots that need constant supervision. Long-running workflows - migrating codebases, generating documentation, analyzing datasets - shouldn't require you to sit there clicking "continue."
32
8
 
33
- **What True Agentic Systems Need:**
34
- - **Autonomy** - Agents that plan, execute, and recover from errors without hand-holding
35
- - **Persistence** - Tasks that run for hours, even when you're offline
36
- - **Collaboration** - Multiple agents coordinating on complex work
37
- - **Tool Access** - Real capabilities: file systems, APIs, databases, not just text generation
38
- - **Cost Control** - Run cheap models for grunt work, expensive ones only when needed
9
+ **Production-ready AI agent orchestration with 66+ specialized agents, 213 MCP tools, and multi-model routing (Anthropic, OpenRouter, Gemini, ONNX).**
39
10
 
40
- **What You Get:**
41
-
42
- - **150+ Specialized Agents** - Researcher, coder, reviewer, tester, architect - each with domain expertise and tool access
43
- - **Multi-Agent Swarms** - Deploy 3, 10, or 100 agents that collaborate via shared memory to complete complex projects
44
- - **Long-Running Tasks** - Agents persist through hours-long operations: full codebase refactors, comprehensive audits, dataset processing
45
- - **213 MCP Tools** - Agents have real capabilities: GitHub operations, neural network training, workflow automation, memory persistence
46
- - **Auto Model Optimization** - `--optimize` flag intelligently selects best model for each task. DeepSeek R1 costs 85% less than Claude with similar quality. Save $2,400/month on 100 daily reviews.
47
- - **Deploy Anywhere** - Same agentic capabilities locally, in Docker/Kubernetes, or cloud sandboxes
11
+ ---
48
12
 
49
- **Real Agentic Use Cases:**
50
- - **Overnight Code Migration** - Deploy a swarm to migrate a 50K line codebase from JavaScript to TypeScript while you sleep
51
- - **Continuous Security Audits** - Agents monitor repos, analyze PRs, and flag vulnerabilities 24/7
52
- - **Automated API Development** - One agent designs schema, another implements endpoints, a third writes tests - all coordinated
53
- - **Data Pipeline Processing** - Agents process TBs of data across distributed sandboxes, checkpoint progress, and recover from failures
13
+ ## πŸ“– Introduction
54
14
 
55
- > **True autonomy at commodity prices.** Your agents work independently on long-running tasks, coordinate when needed, and cost pennies per hour instead of dollars.
15
+ Agentic Flow is a framework for running AI agents at scale with intelligent cost optimization. It runs any Claude Code agent through the [Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk), automatically routing tasks to the cheapest model that meets quality requirements.
56
16
 
57
- ### Built on Industry Standards
17
+ **Key Capabilities:**
18
+ - βœ… **66 Specialized Agents** - Pre-built experts for coding, research, review, testing, DevOps
19
+ - βœ… **213 MCP Tools** - Memory, GitHub, neural networks, sandboxes, workflows, payments
20
+ - βœ… **Multi-Model Router** - Anthropic, OpenRouter (100+ models), Gemini, ONNX (free local)
21
+ - βœ… **Cost Optimization** - 85-99% savings with DeepSeek, Llama, Gemini vs Claude
22
+ - βœ… **Standalone Proxy** - Use Gemini/OpenRouter with Claude Code at 85% cost savings
58
23
 
59
- - **[Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk)** - Anthropic's official SDK for building AI agents
60
- - **[Claude Flow](https://github.com/ruvnet/claude-flow)** - 101 MCP tools for orchestration, memory, GitHub, neural networks
61
- - **[Flow Nexus](https://github.com/ruvnet/flow-nexus)** - 96 cloud tools for sandboxes, distributed swarms, workflows
62
- - **[OpenRouter](https://openrouter.ai)** - Access to 100+ LLM models at 99% cost savings (Llama, DeepSeek, Gemini, etc.)
63
- - **[Agentic Payments](https://www.npmjs.com/package/agentic-payments)** - Multi-agent payment authorization with Ed25519 cryptography
64
- - **[ONNX Runtime](https://onnxruntime.ai)** - Free local CPU/GPU inference with Microsoft Phi-4
24
+ **Built On:**
25
+ - [Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk) by Anthropic
26
+ - [Claude Flow](https://github.com/ruvnet/claude-flow) - 101 MCP tools
27
+ - [Flow Nexus](https://github.com/ruvnet/flow-nexus) - 96 cloud tools
28
+ - [OpenRouter](https://openrouter.ai) - 100+ LLM models
29
+ - [Agentic Payments](https://www.npmjs.com/package/agentic-payments) - Multi-agent payments
65
30
 
66
31
  ---
67
32
 
68
33
  ## πŸš€ Quick Start
69
34
 
70
- ### Local Installation (Recommended for Development)
35
+ ### Option 1: CLI Agent Execution (Fastest)
36
+
37
+ Run specialized agents for coding, research, testing, and more:
71
38
 
72
39
  ```bash
73
- # Global installation
40
+ # Install globally
74
41
  npm install -g agentic-flow
75
42
 
76
- # Or use directly with npx (no installation)
77
- npx agentic-flow --help
78
-
79
- # Set your API key
43
+ # Run with Claude (Anthropic)
80
44
  export ANTHROPIC_API_KEY=sk-ant-...
81
- ```
45
+ npx agentic-flow --agent coder --task "Build a REST API with authentication"
82
46
 
83
- ### Your First Agent (Local Execution)
84
-
85
- ```bash
86
- # Run locally with full 203 MCP tool access (Claude)
87
- npx agentic-flow \
88
- --agent researcher \
89
- --task "Analyze microservices architecture trends in 2025"
90
-
91
- # Run with OpenRouter for 99% cost savings
47
+ # Run with OpenRouter (99% cost savings)
92
48
  export OPENROUTER_API_KEY=sk-or-v1-...
93
- npx agentic-flow \
94
- --agent coder \
95
- --task "Build a REST API with authentication" \
96
- --model "meta-llama/llama-3.1-8b-instruct"
49
+ npx agentic-flow --agent coder --task "Build REST API" --model "meta-llama/llama-3.1-8b-instruct"
97
50
 
98
- # The agent executes on your machine, uses all MCP tools, and terminates
99
- ```
51
+ # Run with Gemini (free tier)
52
+ export GOOGLE_GEMINI_API_KEY=AIza...
53
+ npx agentic-flow --agent coder --task "Build REST API" --provider gemini
100
54
 
101
- ### Multi-Agent Swarm (Local)
55
+ # List all 66 available agents
56
+ npx agentic-flow --list
57
+ ```
102
58
 
103
- ```bash
104
- # 3 agents work in parallel on your machine
105
- export TOPIC="API security best practices"
106
- export DIFF="feat: add OAuth2 authentication"
107
- export DATASET="API response times last 30 days"
59
+ **Available Agents:**
60
+ - `coder`, `reviewer`, `tester`, `planner`, `researcher`
61
+ - `backend-dev`, `mobile-dev`, `ml-developer`, `cicd-engineer`
62
+ - `pr-manager`, `code-review-swarm`, `release-manager`
63
+ - `perf-analyzer`, `production-validator`, `system-architect`
64
+ - And 50+ more...
108
65
 
109
- npx agentic-flow # Spawns: researcher + code-reviewer + data-analyst
110
- ```
66
+ ---
111
67
 
112
- **Local Benefits:**
113
- - βœ… All 203 MCP tools work (full subprocess support)
114
- - βœ… Fast iteration and debugging
115
- - βœ… No cloud costs during development
116
- - βœ… Full access to local filesystem and resources
68
+ ### Option 2: MCP Tools (Direct Access)
117
69
 
118
- ### Docker Deployment (Production)
70
+ Access 213 MCP tools for memory, swarms, GitHub, neural networks, and cloud sandboxes:
119
71
 
120
72
  ```bash
121
- # Build container
122
- docker build -f deployment/Dockerfile -t agentic-flow .
123
-
124
- # Run agent with Claude (Anthropic)
125
- docker run --rm \
126
- -e ANTHROPIC_API_KEY=sk-ant-... \
127
- agentic-flow \
128
- --agent researcher \
129
- --task "Analyze cloud patterns"
73
+ # Start all MCP servers (213 tools)
74
+ npx agentic-flow mcp start
130
75
 
131
- # Run agent with OpenRouter (99% cost savings)
132
- docker run --rm \
133
- -e OPENROUTER_API_KEY=sk-or-v1-... \
134
- agentic-flow \
135
- --agent coder \
136
- --task "Build REST API" \
137
- --model "meta-llama/llama-3.1-8b-instruct"
138
- ```
76
+ # List all available tools
77
+ npx agentic-flow mcp list
139
78
 
140
- **Container Benefits:**
141
- - βœ… All 203 MCP tools work (full subprocess support)
142
- - βœ… OpenRouter proxy auto-starts in container
143
- - βœ… Reproducible builds and deployments
144
- - βœ… Works on Kubernetes, ECS, Cloud Run, Fargate
145
- - βœ… Isolated execution environment
79
+ # Check server status
80
+ npx agentic-flow mcp status
146
81
 
147
- ---
82
+ # Use tools in any agent automatically
83
+ export ENABLE_CLAUDE_FLOW_SDK=true
84
+ npx agentic-flow --agent coder --task "Store config in memory using memory_store"
85
+ ```
148
86
 
149
- ## ✨ Key Features
150
-
151
- ### πŸ”„ Ephemeral Architecture
152
- - **On-Demand Spawning** - Agents created only when needed
153
- - **Automatic Cleanup** - Terminate after task completion
154
- - **Stateless Execution** - No persistent state between runs
155
- - **Cost-Optimized** - Pay only for actual compute time
156
-
157
- ### πŸ€– Multi-Model Router with ONNX Local Inference
158
- - **Intelligent Provider Routing** - Automatic selection between Anthropic, OpenRouter, and ONNX based on task requirements
159
- - **100% Free Local Inference** - ONNX Runtime CPU/GPU execution with Microsoft Phi-4 (zero API costs)
160
- - **Privacy-First Processing** - GDPR/HIPAA-compliant local processing for sensitive workloads
161
- - **Cost Optimization** - Route privacy tasks to free ONNX, complex reasoning to cloud APIs
162
- - **Rule-Based Routing** - Automatic provider selection based on privacy, cost, and performance
163
- - **GPU Acceleration Ready** - CPU inference at 6 tokens/sec, GPU capable of 60-300 tokens/sec
164
- - **Zero-Cost Agents** - Run agents entirely offline with local ONNX models
165
-
166
- ### πŸ’» Local Development (Full Features)
167
- - **Native Execution** - Run directly on macOS, Linux, Windows
168
- - **All 203 MCP Tools** - Full subprocess support, no restrictions
169
- - **Fast Iteration** - Instant feedback, no cold starts
170
- - **Persistent Memory** - Claude Flow memory persists across runs
171
- - **File System Access** - Full access to local files and directories
172
- - **Git Integration** - Direct GitHub operations and repository management
173
- - **Zero Cloud Costs** - Free during development
174
-
175
- ### 🐳 Container Deployment (Production Ready)
176
- - **Docker Support** - Complete feature set for ECS, Cloud Run, Kubernetes
177
- - **All 203 MCP Tools** - Full subprocess support in containers
178
- - **Reproducible Builds** - Same environment across dev/staging/prod
179
- - **Orchestration Ready** - Works with Kubernetes Jobs, ECS Tasks, Cloud Run
180
- - **Health Checks Built-in** - `/health` endpoint for load balancers
181
- - **Resource Controls** - CPU/memory limits via container configs
182
-
183
- ### ☁️ Cloud Sandboxes (Scalable Execution)
184
- - **Flow Nexus E2B Sandboxes** - Fully isolated execution environments
185
- - **All 203 MCP Tools** - Complete tool access in cloud sandboxes
186
- - **Multi-Language Templates** - Node.js, Python, React, Next.js
187
- - **Real-Time Streaming** - Live output and monitoring
188
- - **Auto-Scaling** - Spin up 1 to 100+ sandboxes on demand
189
- - **Pay-Per-Use** - Only pay for actual sandbox runtime (β‰ˆ$1/hour)
190
-
191
- ### πŸ€– Intelligent Agents
192
- - **150+ Pre-Built Specialists** - Researchers, coders, testers, reviewers, architects
193
- - **Swarm Coordination** - Agents collaborate via shared memory
194
- - **Tool Access** - 200+ MCP tools for GitHub, neural networks, workflows
195
- - **Custom Agents** - Define your own in YAML with system prompts
196
-
197
- ### πŸ“Š Observability
198
- - **Real-Time Streaming** - See agent output as it happens
199
- - **Structured Logging** - JSON logs for aggregation and analysis
200
- - **Performance Metrics** - Track agent duration, tool usage, token consumption
201
- - **Health Checks** - Built-in healthcheck endpoint for orchestrators
87
+ **MCP Tool Categories:**
88
+ - **Claude Flow SDK** (6 tools): In-process memory and swarm coordination
89
+ - **Claude Flow** (101 tools): Neural networks, GitHub, workflows, performance, DAA
90
+ - **Flow Nexus** (96 tools): E2B sandboxes, distributed swarms, templates, storage
91
+ - **Agentic Payments** (10 tools): Payment authorization, Ed25519 signatures, consensus
202
92
 
203
93
  ---
204
94
 
205
- ## πŸš€ Deployment Options
95
+ ### Option 3: Standalone Proxy (NEW in v1.1.11)
206
96
 
207
- ### πŸ’» Local Execution (Best for Development)
208
-
209
- **Full-featured, all 203 MCP tools work:**
97
+ Use Gemini or OpenRouter with Claude Code at 85-90% cost savings:
210
98
 
211
99
  ```bash
212
- # Install globally
213
- npm install -g agentic-flow
100
+ # Terminal 1: Start proxy server
101
+ export GOOGLE_GEMINI_API_KEY=your-key-here
102
+ npx agentic-flow proxy
214
103
 
215
- # Set API key
216
- export ANTHROPIC_API_KEY=sk-ant-...
217
-
218
- # Run any agent locally
219
- npx agentic-flow --agent coder --task "Build REST API"
104
+ # Terminal 2: Use Claude Code with proxy
105
+ export ANTHROPIC_BASE_URL=http://localhost:3000
106
+ export ANTHROPIC_API_KEY=sk-ant-proxy-dummy-key
107
+ claude # Now uses Gemini instead of Anthropic!
220
108
 
221
- # Multi-agent swarm (3 agents in parallel)
222
- npx agentic-flow # Uses TOPIC, DIFF, DATASET env vars
109
+ # Or use OpenRouter (90% savings)
110
+ npx agentic-flow proxy --provider openrouter --model "openai/gpt-4o-mini"
223
111
  ```
224
112
 
225
- **Why Local Development?**
226
- - βœ… **All 203 MCP Tools**: Full subprocess support (claude-flow, flow-nexus, agentic-payments)
227
- - βœ… **Fast Iteration**: No cold starts, instant feedback
228
- - βœ… **Free**: No cloud costs during development
229
- - βœ… **File Access**: Direct access to local filesystem
230
- - βœ… **Git Integration**: Full GitHub operations
231
- - βœ… **Memory Persistence**: Claude Flow memory persists across runs
232
- - βœ… **Easy Debugging**: Standard Node.js debugging tools work
113
+ **Features:**
114
+ - βœ… MCP tools work through proxy (all 213 tools)
115
+ - βœ… Compatible with Claude Code official CLI
116
+ - βœ… Future Cursor IDE support (waiting for ANTHROPIC_BASE_URL)
117
+ - βœ… 85-90% cost savings vs direct Anthropic API
233
118
 
234
- **System Requirements:**
235
- - Node.js β‰₯18.0.0
236
- - npm or pnpm
237
- - 2GB RAM minimum (4GB recommended for swarms)
238
- - macOS, Linux, or Windows
119
+ **Cost Savings:**
120
+ | Provider | Model | Cost per 1M tokens | Savings |
121
+ |----------|-------|-------------------|---------|
122
+ | Anthropic | Claude Sonnet 4.5 | $3.00 | Baseline |
123
+ | Gemini (proxy) | gemini-2.0-flash | $0.00 (free tier) | **100%** |
124
+ | OpenRouter (proxy) | gpt-4o-mini | $0.15 | **95%** |
125
+ | OpenRouter (proxy) | deepseek-v3 | $0.014 | **99.5%** |
126
+
127
+ πŸ“š **See [Standalone Proxy Guide](docs/STANDALONE_PROXY_GUIDE.md) for details**
239
128
 
240
129
  ---
241
130
 
242
- ### 🎯 Flow Nexus Cloud Sandboxes (Best for Production Scale)
243
- ```javascript
244
- // Create isolated sandbox and execute agent with full MCP tool access
245
- const { query } = require('@anthropic-ai/claude-agent-sdk');
131
+ ## πŸ“š Tutorial: Agent Execution
246
132
 
247
- // 1. Login to Flow Nexus
248
- await flowNexus.login({ email: 'user@example.com', password: 'secure' });
133
+ ### 1. Basic Agent Usage
249
134
 
250
- // 2. Create E2B sandbox with Node.js template
251
- const sandbox = await flowNexus.sandboxCreate({
252
- template: 'node',
253
- name: 'agent-execution',
254
- env_vars: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY }
255
- });
135
+ **What it does:** Runs a specialized agent with Claude SDK and all 213 MCP tools.
256
136
 
257
- // 3. Execute agent in sandbox with all 203 MCP tools
258
- const result = await flowNexus.sandboxExecute({
259
- sandbox_id: sandbox.id,
260
- code: `
261
- const { query } = require('@anthropic-ai/claude-agent-sdk');
262
- const result = await query({
263
- prompt: "Analyze API security patterns",
264
- options: {
265
- mcpServers: { /* all 3 MCP servers available */ }
266
- }
267
- });
268
- console.log(result);
269
- `
270
- });
137
+ **When to use:** Quick tasks that need one expert (code review, API generation, testing).
271
138
 
272
- // 4. Automatic cleanup
273
- await flowNexus.sandboxDelete({ sandbox_id: sandbox.id });
139
+ ```bash
140
+ # Code generation
141
+ npx agentic-flow --agent coder --task "Create a REST API with OAuth2 authentication"
142
+
143
+ # Security review
144
+ npx agentic-flow --agent reviewer --task "Review this code for security vulnerabilities"
145
+
146
+ # Test generation
147
+ npx agentic-flow --agent tester --task "Write comprehensive tests for this API"
274
148
  ```
275
149
 
276
- **Why Flow Nexus?**
277
- - βœ… Full 203 MCP tool support (all subprocess servers work)
278
- - βœ… Persistent memory across sandbox instances
279
- - βœ… Multi-language templates (Node.js, Python, React, Next.js)
280
- - βœ… Real-time output streaming
281
- - βœ… Secure process isolation
282
- - βœ… Pay-per-use pricing (10 credits/hour)
150
+ **Technical Details:**
151
+ - Uses Claude Agent SDK's `query()` function
152
+ - Automatically loads agent's system prompt from `.claude/agents/`
153
+ - All 213 MCP tools available via `mcpServers` configuration
154
+ - Streams output in real-time with `--stream` flag
283
155
 
284
156
  ---
285
157
 
286
- ### 🐳 Docker Containers (Best for Production Deployments)
158
+ ### 2. Multi-Agent Swarms
287
159
 
288
- **Full 203 MCP tool support in containers:**
160
+ **What it does:** Runs 3 agents in parallel for complex workflows.
289
161
 
290
- ```bash
291
- # Build image
292
- docker build -t agentic-flow .
162
+ **When to use:** Multi-faceted tasks requiring research + coding + analysis.
293
163
 
294
- # Run single agent
295
- docker run --rm \
296
- -e ANTHROPIC_API_KEY=sk-ant-... \
297
- agentic-flow \
298
- --agent researcher \
299
- --task "Analyze microservices patterns"
164
+ ```bash
165
+ # Set environment variables
166
+ export TOPIC="API security best practices"
167
+ export DIFF="feat: add OAuth2 authentication"
168
+ export DATASET="API response times last 30 days"
300
169
 
301
- # Multi-agent swarm in container
302
- docker run --rm \
303
- -e ANTHROPIC_API_KEY=sk-ant-... \
304
- -e TOPIC="API security" \
305
- -e DIFF="feat: auth" \
306
- -e DATASET="logs.json" \
307
- agentic-flow
170
+ # Run parallel swarm (researcher + code-reviewer + data-analyst)
171
+ npx agentic-flow
308
172
  ```
309
173
 
310
- **Why Docker?**
311
- - βœ… **All 203 MCP Tools**: Full subprocess support
312
- - βœ… **Production Ready**: Works on Kubernetes, ECS, Cloud Run, Fargate
313
- - βœ… **Reproducible**: Same environment everywhere
314
- - βœ… **Isolated**: Process isolation and security
315
- - βœ… **Orchestration**: Integrates with container orchestrators
316
- - βœ… **CI/CD**: Perfect for automated workflows
174
+ **Technical Details:**
175
+ - Spawns 3 agents concurrently: `researcher`, `code-review`, `data-analyst`
176
+ - Agents coordinate via Claude Flow memory tools
177
+ - Each agent has access to all 213 MCP tools
178
+ - Results aggregated and returned together
317
179
 
318
- **Container Orchestration Examples:**
180
+ ---
319
181
 
320
- ```yaml
321
- # Kubernetes Job
322
- apiVersion: batch/v1
323
- kind: Job
324
- metadata:
325
- name: code-review
326
- spec:
327
- template:
328
- spec:
329
- containers:
330
- - name: agent
331
- image: agentic-flow:latest
332
- args: ["--agent", "code-review", "--task", "Review PR #123"]
333
- env:
334
- - name: ANTHROPIC_API_KEY
335
- valueFrom:
336
- secretKeyRef:
337
- name: anthropic
338
- key: api-key
339
- restartPolicy: Never
182
+ ### 3. Cost Optimization with OpenRouter
340
183
 
341
- # GitHub Actions
342
- - name: AI Code Review
343
- run: |
344
- docker run -e ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }} \
345
- agentic-flow:latest \
346
- --agent code-review \
347
- --task "${{ github.event.pull_request.diff }}"
184
+ **What it does:** Uses OpenRouter models for 90-99% cost savings vs Claude.
348
185
 
349
- # AWS ECS Task Definition
350
- {
351
- "family": "agentic-flow-task",
352
- "containerDefinitions": [{
353
- "name": "agent",
354
- "image": "agentic-flow:latest",
355
- "command": ["--agent", "researcher", "--task", "$(TASK)"],
356
- "environment": [
357
- {"name": "ANTHROPIC_API_KEY", "value": "from-secrets-manager"}
358
- ]
359
- }]
360
- }
361
- ```
186
+ **When to use:** Development, testing, or budget-conscious production workloads.
187
+
188
+ ```bash
189
+ # Ultra-low cost with Llama 3.1 8B (99% savings)
190
+ export OPENROUTER_API_KEY=sk-or-v1-...
191
+ npx agentic-flow --agent coder --task "Build REST API" --model "meta-llama/llama-3.1-8b-instruct"
362
192
 
363
- ### πŸ”“ ONNX Local Inference (Free Offline AI)
193
+ # Balanced cost/quality with DeepSeek (97% savings)
194
+ npx agentic-flow --agent coder --task "Production code" --model "deepseek/deepseek-chat-v3.1"
364
195
 
365
- **Run agents completely offline with zero API costs:**
196
+ # Fast responses with Gemini (95% savings)
197
+ npx agentic-flow --agent researcher --task "Analyze trends" --model "google/gemini-2.5-flash-preview"
198
+ ```
366
199
 
367
- ```bash
368
- # Auto-downloads Phi-4 model (~4.9GB one-time download)
369
- npx agentic-flow \
370
- --agent coder \
371
- --task "Build a REST API" \
372
- --provider onnx
200
+ **Technical Details:**
201
+ - Proxy auto-starts on port 3000 when OpenRouter model detected
202
+ - Translates Anthropic Messages API ↔ OpenAI Chat Completions API
203
+ - All 213 MCP tools work through proxy
204
+ - No code changes needed - transparent to Claude SDK
373
205
 
374
- # Router auto-selects ONNX for privacy-sensitive tasks
375
- npx agentic-flow \
376
- --agent researcher \
377
- --task "Analyze confidential medical records" \
378
- --privacy high \
379
- --local-only
206
+ **Cost Comparison:**
380
207
  ```
208
+ Task: Generate 100K tokens (200 functions)
381
209
 
382
- **ONNX Capabilities:**
383
- - βœ… 100% free local inference (Microsoft Phi-4 model)
384
- - βœ… Privacy: All processing stays on your machine
385
- - βœ… Offline: No internet required after model download
386
- - βœ… Performance: ~6 tokens/sec CPU, 60-300 tokens/sec GPU
387
- - βœ… Auto-download: Model fetches automatically on first use
388
- - βœ… Quantized: INT4 optimization for efficiency (~4.9GB total)
389
- - ⚠️ Limited to 6 in-SDK tools (no subprocess MCP servers)
390
- - πŸ“š See [docs](docs/ONNX_INTEGRATION.md) for full capabilities
210
+ Anthropic Claude Sonnet 4.5: $1.80
211
+ DeepSeek V3 (OpenRouter): $0.028 (98% savings)
212
+ Llama 3.1 8B (OpenRouter): $0.011 (99% savings)
213
+ ```
391
214
 
392
215
  ---
393
216
 
394
- ## 🎯 Use Cases & Costs
217
+ ### 4. Free Local Inference with ONNX
395
218
 
396
- | Use Case | Agent Type | Execution Time | Local Cost | Docker Cost | Flow Nexus Cost |
397
- |----------|-----------|----------------|------------|-------------|-----------------|
398
- | **Code Review** | `code-review` | 15-45s | Free* | Self-hosted | 0.13-0.38 credits |
399
- | **API Testing** | `tester` | 10-30s | Free* | Self-hosted | 0.08-0.25 credits |
400
- | **Documentation** | `api-docs` | 20-60s | Free* | Self-hosted | 0.17-0.50 credits |
401
- | **Data Analysis** | `data-analyst` | 30-90s | Free* | Self-hosted | 0.25-0.75 credits |
402
- | **Security Audit** | `reviewer` | 45-120s | Free* | Self-hosted | 0.38-1.00 credits |
403
- | **Microservice Generation** | `backend-dev` | 60-180s | Free* | Self-hosted | 0.50-1.50 credits |
404
- | **Performance Analysis** | `perf-analyzer` | 20-60s | Free* | Self-hosted | 0.17-0.50 credits |
219
+ **What it does:** Runs agents completely offline with zero API costs.
405
220
 
406
- *Local: Free infrastructure, Claude API costs only ($0.003-0.015 per input 1K tokens, $0.015-0.075 per output 1K tokens)
407
- Flow Nexus: 10 credits/hour sandbox (β‰ˆ$1/hour) + Claude API costs. 1 credit β‰ˆ $0.10.
408
- Docker: Infrastructure costs (AWS/GCP/Azure) + Claude API costs.*
221
+ **When to use:** Privacy-sensitive data, air-gapped environments, development without API costs.
409
222
 
410
- **Recommendation by Scenario:**
411
- - **Development/Testing**: Use **Local** - free, fast, full tools
412
- - **CI/CD Pipelines**: Use **Docker** - reproducible, isolated
413
- - **Production Scale**: Use **Flow Nexus** - auto-scaling, cloud-native
223
+ ```bash
224
+ # Auto-downloads Phi-4 model (~4.9GB one-time)
225
+ npx agentic-flow --agent coder --task "Build REST API" --provider onnx
414
226
 
415
- ---
227
+ # Privacy-first routing (auto-selects ONNX)
228
+ npx agentic-flow --agent researcher --task "Analyze medical records" --privacy high --local-only
229
+ ```
416
230
 
417
- ## πŸ€– Agent Types
418
-
419
- ### Core Development Agents
420
- - **`coder`** - Implementation specialist for writing clean, efficient code
421
- - **`reviewer`** - Code review and quality assurance
422
- - **`tester`** - Comprehensive testing with 90%+ coverage
423
- - **`planner`** - Strategic planning and task decomposition
424
- - **`researcher`** - Deep research and information gathering
425
-
426
- ### Specialized Agents
427
- - **`backend-dev`** - REST/GraphQL API development
428
- - **`mobile-dev`** - React Native mobile apps
429
- - **`ml-developer`** - Machine learning model creation
430
- - **`system-architect`** - System design and architecture
431
- - **`cicd-engineer`** - CI/CD pipeline creation
432
- - **`api-docs`** - OpenAPI/Swagger documentation
433
-
434
- ### Swarm Coordinators
435
- - **`hierarchical-coordinator`** - Tree-based leadership
436
- - **`mesh-coordinator`** - Peer-to-peer coordination
437
- - **`adaptive-coordinator`** - Dynamic topology switching
438
- - **`swarm-memory-manager`** - Cross-agent memory sync
439
-
440
- ### GitHub Integration
441
- - **`pr-manager`** - Pull request lifecycle management
442
- - **`code-review-swarm`** - Multi-agent code review
443
- - **`issue-tracker`** - Intelligent issue management
444
- - **`release-manager`** - Automated release coordination
445
- - **`workflow-automation`** - GitHub Actions specialist
446
-
447
- ### Performance & Analysis
448
- - **`perf-analyzer`** - Performance bottleneck detection
449
- - **`production-validator`** - Deployment readiness checks
450
- - **`tdd-london-swarm`** - Test-driven development
451
-
452
- *Use `npx agentic-flow --list` to see all 150+ agents*
231
+ **Technical Details:**
232
+ - Uses Microsoft Phi-4 (INT4 quantized) via ONNX Runtime
233
+ - CPU: ~6 tokens/sec, GPU: 60-300 tokens/sec
234
+ - 100% offline after model download
235
+ - Limited to 6 in-SDK tools (no subprocess MCP servers)
236
+ - Zero API costs forever
453
237
 
454
238
  ---
455
239
 
456
- ## 🎯 Model Optimization (NEW!)
457
-
458
- **Automatically select the optimal model for any agent and task**, balancing quality, cost, and speed based on your priorities.
459
-
460
- ### Why Model Optimization?
240
+ ### 5. Model Optimization (Auto-Select Best Model)
461
241
 
462
- Different tasks need different models:
463
- - **Production code** β†’ Claude Sonnet 4.5 (highest quality)
464
- - **Code reviews** β†’ DeepSeek R1 (85% cheaper, nearly same quality)
465
- - **Simple functions** β†’ Llama 3.1 8B (99% cheaper)
466
- - **Privacy-critical** β†’ ONNX Phi-4 (free, local, offline)
242
+ **What it does:** Automatically picks optimal model based on task complexity and priorities.
467
243
 
468
- **The optimizer analyzes your agent type + task complexity and recommends the best model automatically.**
469
-
470
- ### Quick Examples
244
+ **When to use:** You want best quality/cost/speed balance without manual selection.
471
245
 
472
246
  ```bash
473
- # Let the optimizer choose (balanced quality vs cost)
247
+ # Let optimizer choose (balanced quality vs cost)
474
248
  npx agentic-flow --agent coder --task "Build REST API" --optimize
475
249
 
476
250
  # Optimize for lowest cost
@@ -479,975 +253,526 @@ npx agentic-flow --agent coder --task "Simple function" --optimize --priority co
479
253
  # Optimize for highest quality
480
254
  npx agentic-flow --agent reviewer --task "Security audit" --optimize --priority quality
481
255
 
482
- # Optimize for speed
483
- npx agentic-flow --agent researcher --task "Quick analysis" --optimize --priority speed
484
-
485
- # Set maximum budget ($0.001 per task)
256
+ # Set budget cap ($0.001 per task max)
486
257
  npx agentic-flow --agent coder --task "Code cleanup" --optimize --max-cost 0.001
487
258
  ```
488
259
 
489
- ### Optimization Priorities
490
-
491
- - **`quality`** (70% quality, 20% speed, 10% cost) - Best results, production code
492
- - **`balanced`** (40% quality, 40% cost, 20% speed) - Default, good mix
493
- - **`cost`** (70% cost, 20% quality, 10% speed) - Cheapest, development/testing
494
- - **`speed`** (70% speed, 20% quality, 10% cost) - Fastest responses
495
- - **`privacy`** - Local-only models (ONNX), zero cloud API calls
496
-
497
- ### Model Tier Examples
498
-
499
- The optimizer chooses from 10+ models across 5 tiers:
500
-
501
- **Tier 1: Flagship** (premium quality)
502
- - Claude Sonnet 4.5 - $3/$15 per 1M tokens
503
- - GPT-4o - $2.50/$10 per 1M tokens
504
- - Gemini 2.5 Pro - $0.00/$2.00 per 1M tokens
505
-
506
- **Tier 2: Cost-Effective** (2025 breakthrough models)
507
- - **DeepSeek R1** - $0.55/$2.19 per 1M tokens (85% cheaper, flagship quality)
508
- - **DeepSeek Chat V3** - $0.14/$0.28 per 1M tokens (98% cheaper)
509
-
510
- **Tier 3: Balanced**
511
- - Gemini 2.5 Flash - $0.07/$0.30 per 1M tokens (fastest)
512
- - Llama 3.3 70B - $0.30/$0.30 per 1M tokens (open-source)
513
-
514
- **Tier 4: Budget**
515
- - Llama 3.1 8B - $0.055/$0.055 per 1M tokens (ultra-low cost)
516
-
517
- **Tier 5: Local/Privacy**
518
- - **ONNX Phi-4** - FREE (offline, private, no API)
519
-
520
- ### Agent-Specific Recommendations
521
-
522
- The optimizer knows what each agent needs:
523
-
524
- ```bash
525
- # Coder agent β†’ prefers high quality (min 85/100)
526
- npx agentic-flow --agent coder --task "Production API" --optimize
527
- # β†’ Selects: DeepSeek R1 (quality 90, cost 85)
528
-
529
- # Researcher agent β†’ flexible, can use cheaper models
530
- npx agentic-flow --agent researcher --task "Trend analysis" --optimize --priority cost
531
- # β†’ Selects: Gemini 2.5 Flash (quality 78, cost 98)
532
-
533
- # Reviewer agent β†’ needs reasoning (min 85/100)
534
- npx agentic-flow --agent reviewer --task "Security review" --optimize
535
- # β†’ Selects: DeepSeek R1 (quality 90, reasoning-optimized)
536
-
537
- # Tester agent β†’ simple tasks, use budget models
538
- npx agentic-flow --agent tester --task "Unit tests" --optimize --priority cost
539
- # β†’ Selects: Llama 3.1 8B (cost 95)
540
- ```
541
-
542
- ### Cost Savings Examples
543
-
544
- **Without Optimization** (always using Claude Sonnet 4.5):
545
- - 100 code reviews/day Γ— $0.08 each = **$8/day = $240/month**
546
-
547
- **With Optimization** (DeepSeek R1 for reviews):
548
- - 100 code reviews/day Γ— $0.012 each = **$1.20/day = $36/month**
549
- - **Savings: $204/month (85% reduction)**
550
-
551
- ### Comprehensive Model Guide
552
-
553
- For detailed analysis of all 10 models, see:
554
- πŸ“– **[Model Capabilities Guide](docs/agentic-flow/benchmarks/MODEL_CAPABILITIES.md)**
260
+ **Technical Details:**
261
+ - Analyzes agent requirements (coder needs 85+ quality score)
262
+ - Evaluates task complexity via keyword analysis
263
+ - Scores 10+ models across quality, cost, speed, privacy
264
+ - Returns recommendation with reasoning
555
265
 
556
- Includes:
557
- - Full benchmark results across 6 task types
558
- - Cost comparison tables
559
- - Use case decision matrices
560
- - Performance characteristics
561
- - Best practices by model
266
+ **Optimization Priorities:**
267
+ - `quality` - Best results (70% quality, 20% speed, 10% cost)
268
+ - `balanced` - Default mix (40% quality, 40% cost, 20% speed)
269
+ - `cost` - Cheapest (70% cost, 20% quality, 10% speed)
270
+ - `speed` - Fastest (70% speed, 20% quality, 10% cost)
271
+ - `privacy` - Local-only (ONNX models, zero cloud API calls)
562
272
 
563
- ### MCP Tool for Optimization
564
-
565
- ```javascript
566
- // Get model recommendation via MCP tool
567
- await query({
568
- mcp: {
569
- server: 'agentic-flow',
570
- tool: 'agentic_flow_optimize_model',
571
- params: {
572
- agent: 'coder',
573
- task: 'Build REST API with auth',
574
- priority: 'balanced', // quality | balanced | cost | speed | privacy
575
- max_cost: 0.01 // optional budget cap in dollars
576
- }
577
- }
578
- });
579
- ```
273
+ ---
580
274
 
581
- **Learn More:**
582
- - See [benchmarks/README.md](docs/agentic-flow/benchmarks/README.md) for quick results
583
- - Run your own tests: `cd docs/agentic-flow/benchmarks && ./quick-benchmark.sh`
275
+ ## πŸ“š Tutorial: MCP Tools
584
276
 
585
- ---
277
+ ### What are MCP Tools?
586
278
 
587
- ## πŸ“‹ Commands
279
+ MCP (Model Context Protocol) tools extend agent capabilities beyond text generation. They provide:
280
+ - **Memory** - Persistent storage across sessions
281
+ - **GitHub** - Repository operations, PR management, code review
282
+ - **Sandboxes** - Isolated execution environments in the cloud
283
+ - **Neural Networks** - Training, inference, model management
284
+ - **Workflows** - Event-driven automation with message queues
285
+ - **Payments** - Multi-agent payment authorization
588
286
 
589
- ### MCP Server Management (Direct Tool Access)
287
+ ### Starting MCP Servers
590
288
 
591
289
  ```bash
592
- # Start all MCP servers (213 tools)
290
+ # Start all 213 tools (4 servers)
593
291
  npx agentic-flow mcp start
594
292
 
595
- # Start specific MCP server
293
+ # Start specific server
596
294
  npx agentic-flow mcp start claude-flow # 101 tools
597
- npx agentic-flow mcp start flow-nexus # 96 cloud tools
598
- npx agentic-flow mcp start agentic-payments # Payment tools
295
+ npx agentic-flow mcp start flow-nexus # 96 tools (requires registration)
296
+ npx agentic-flow mcp start agentic-payments # 10 tools
599
297
 
600
- # List all available MCP tools (213 total)
298
+ # List all tools
601
299
  npx agentic-flow mcp list
602
300
 
603
- # Check MCP server status
301
+ # Check status
604
302
  npx agentic-flow mcp status
605
303
 
606
- # Stop MCP servers
607
- npx agentic-flow mcp stop [server]
304
+ # Stop servers
305
+ npx agentic-flow mcp stop
608
306
  ```
609
307
 
610
- **MCP Servers Available:**
611
- - **claude-flow** (101 tools): Neural networks, GitHub integration, workflows, DAA, performance
612
- - **flow-nexus** (96 tools): E2B sandboxes, distributed swarms, templates, cloud storage
613
- - **agentic-payments** (10 tools): Payment authorization, Ed25519 signatures, consensus
614
- - **claude-flow-sdk** (6 tools): In-process memory and swarm coordination
615
-
616
- ### Basic Operations (Works Locally, Docker, Cloud)
308
+ ### Using MCP Tools in Agents
617
309
 
310
+ **Automatic (Recommended):**
618
311
  ```bash
619
- # List all available agents (150+ total)
620
- npx agentic-flow --list
621
-
622
- # Run specific agent (local execution)
623
- npx agentic-flow --agent <name> --task "<description>"
624
-
625
- # Enable real-time streaming
626
- npx agentic-flow --agent coder --task "Build API" --stream
627
-
628
- # Run parallel mode (3 agents simultaneously)
629
- npx agentic-flow # Requires TOPIC, DIFF, DATASET env vars
630
- ```
631
-
632
- ### Environment Configuration
633
-
634
- ```bash
635
- # Required
636
- export ANTHROPIC_API_KEY=sk-ant-...
637
-
638
- # Agent mode (optional)
639
- export AGENT=researcher
640
- export TASK="Your task description"
641
-
642
- # Parallel mode (optional)
643
- export TOPIC="research topic"
644
- export DIFF="code changes"
645
- export DATASET="data to analyze"
646
-
647
- # Options
648
- export ENABLE_STREAMING=true
649
- export HEALTH_PORT=8080
650
- ```
651
-
652
- ### Docker Deployment
653
-
654
- ```bash
655
- # Build image
656
- docker build -t agentic-flow .
657
-
658
- # Run agent in container
659
- docker run --rm \
660
- -e ANTHROPIC_API_KEY=sk-ant-... \
661
- agentic-flow \
662
- --agent researcher \
663
- --task "Analyze cloud patterns"
664
-
665
- # Run with streaming
666
- docker run --rm \
667
- -e ANTHROPIC_API_KEY=sk-ant-... \
668
- -e ENABLE_STREAMING=true \
669
- agentic-flow \
670
- --agent coder --task "Build REST API" --stream
312
+ # Tools available automatically when ENABLE_CLAUDE_FLOW_SDK=true
313
+ export ENABLE_CLAUDE_FLOW_SDK=true
314
+ npx agentic-flow --agent coder --task "Store config in memory_store"
671
315
  ```
672
316
 
673
- ---
674
-
675
- ---
676
-
677
- ## πŸŽ›οΈ Using the Multi-Model Router
678
-
679
- ### Quick Start with Router
680
-
317
+ **Manual (Advanced):**
681
318
  ```javascript
682
- import { ModelRouter } from 'agentic-flow/router';
683
-
684
- // Initialize router (auto-loads configuration)
685
- const router = new ModelRouter();
686
-
687
- // Use default provider (Anthropic)
688
- const response = await router.chat({
689
- model: 'claude-3-5-sonnet-20241022',
690
- messages: [{ role: 'user', content: 'Your prompt here' }]
691
- });
692
-
693
- console.log(response.content[0].text);
694
- console.log(`Cost: $${response.metadata.cost}`);
695
- ```
319
+ import { query } from '@anthropic-ai/claude-agent-sdk';
696
320
 
697
- ### Available Providers
698
-
699
- The router supports multiple LLM providers with automatic fallback:
700
-
701
- **Anthropic (Cloud)**
702
- - Models: Claude 3.5 Sonnet, Claude 3.5 Haiku, Claude 3 Opus
703
- - Cost: $0.003/1K input tokens, $0.015/1K output tokens
704
- - Best for: Complex reasoning, advanced coding, long conversations
705
-
706
- **OpenRouter (Multi-Model Gateway)**
707
- - Models: 100+ models from multiple providers
708
- - Cost: $0.002-0.10/1K tokens (varies by model)
709
- - Best for: Cost optimization, model diversity, fallback
710
-
711
- **ONNX Runtime (Free Local)**
712
- - Models: Microsoft Phi-4-mini-instruct (INT4 quantized)
713
- - Cost: **$0.00** (100% free)
714
- - Best for: Privacy-sensitive data, offline operation, zero-cost development
715
-
716
- **Ollama (Local Server - Coming Soon)**
717
- - Models: Any Ollama-supported model
718
- - Cost: Free (requires local Ollama server)
719
- - Best for: Local development with larger models
720
-
721
- **LiteLLM (Gateway - Coming Soon)**
722
- - Models: Unified API for 100+ providers
723
- - Cost: Varies by provider
724
- - Best for: Multi-cloud deployments
725
-
726
- **Configuration Example:**
727
- ```json
728
- // router.config.json
729
- {
730
- "defaultProvider": "anthropic",
731
- "fallbackChain": ["anthropic", "onnx", "openrouter"],
732
- "providers": {
733
- "anthropic": {
734
- "apiKey": "sk-ant-...",
735
- "models": { "default": "claude-3-5-sonnet-20241022" }
736
- },
737
- "openrouter": {
738
- "apiKey": "sk-or-...",
739
- "baseUrl": "https://openrouter.ai/api/v1",
740
- "models": { "default": "anthropic/claude-3.5-sonnet" }
741
- },
742
- "onnx": {
743
- "modelPath": "./models/phi-4/.../model.onnx",
744
- "executionProviders": ["cpu"],
745
- "localInference": true
321
+ const result = await query({
322
+ prompt: 'Store API key in memory',
323
+ options: {
324
+ mcpServers: {
325
+ 'claude-flow-sdk': {
326
+ command: 'npx',
327
+ args: ['claude-flow', 'mcp', 'start'],
328
+ env: { ENABLE_CLAUDE_FLOW_SDK: 'true' }
329
+ }
746
330
  }
747
331
  }
748
- }
332
+ });
749
333
  ```
750
334
 
751
- ### OpenRouter Integration (99% Cost Savings)
335
+ ### MCP Tool Categories
336
+
337
+ **1. Memory & Storage (claude-flow-sdk)**
338
+ - `memory_store` - Store persistent key-value data
339
+ - `memory_retrieve` - Retrieve stored data
340
+ - `memory_search` - Search memory by pattern
341
+ - `memory_list` - List all stored keys
342
+ - `memory_delete` - Delete stored data
343
+
344
+ **2. Swarm Coordination (claude-flow)**
345
+ - `swarm_init` - Initialize multi-agent swarm
346
+ - `agent_spawn` - Create specialized agents
347
+ - `task_orchestrate` - Distribute work across agents
348
+ - `swarm_status` - Monitor swarm health
349
+ - `coordination_sync` - Synchronize agent state
350
+
351
+ **3. GitHub Integration (claude-flow)**
352
+ - `github_repo_analyze` - Repository analysis
353
+ - `github_pr_manage` - PR lifecycle management
354
+ - `github_code_review` - Automated code review
355
+ - `github_issue_track` - Issue triage and tracking
356
+ - `github_workflow_auto` - CI/CD automation
357
+
358
+ **4. Cloud Sandboxes (flow-nexus)**
359
+ - `sandbox_create` - Isolated execution environments
360
+ - `sandbox_execute` - Run code in sandbox
361
+ - `sandbox_upload` - Upload files to sandbox
362
+ - `sandbox_status` - Check sandbox health
363
+ - `sandbox_delete` - Cleanup sandbox
364
+
365
+ **5. Neural Networks (claude-flow)**
366
+ - `neural_train` - Train models with WASM acceleration
367
+ - `neural_predict` - Run inference
368
+ - `neural_patterns` - Analyze cognitive patterns
369
+ - `neural_status` - Model metrics
370
+
371
+ **6. Workflows (flow-nexus)**
372
+ - `workflow_create` - Event-driven automation
373
+ - `workflow_execute` - Run workflow with message queues
374
+ - `workflow_status` - Monitor execution
375
+ - `workflow_agent_assign` - Optimal agent assignment
376
+
377
+ **7. Payments (agentic-payments)**
378
+ - `create_active_mandate` - Payment authorization with spend caps
379
+ - `sign_mandate` - Ed25519 cryptographic signing
380
+ - `verify_mandate` - Signature verification
381
+ - `verify_consensus` - Multi-agent Byzantine consensus
752
382
 
753
- Access 100+ LLM models through OpenRouter for dramatic cost savings while maintaining full functionality:
383
+ ---
754
384
 
755
- ```bash
756
- # Set OpenRouter API key
757
- export OPENROUTER_API_KEY=sk-or-v1-...
385
+ ## πŸ“š Tutorial: Standalone Proxy
758
386
 
759
- # Use any OpenRouter model (proxy auto-starts)
760
- npx agentic-flow \
761
- --agent coder \
762
- --task "Build REST API" \
763
- --model "meta-llama/llama-3.1-8b-instruct"
387
+ ### What is the Standalone Proxy?
764
388
 
765
- # Or force OpenRouter mode
766
- export USE_OPENROUTER=true
767
- npx agentic-flow --agent coder --task "Build REST API"
768
- ```
389
+ The standalone proxy lets you use **cheaper models** (Gemini, OpenRouter) with tools that expect the **Anthropic API** (Claude Code, future Cursor).
769
390
 
770
- **Popular OpenRouter Models:**
771
- - `meta-llama/llama-3.1-8b-instruct` - 99% cost savings, excellent coding
772
- - `deepseek/deepseek-chat-v3.1` - Superior code generation at 97% savings
773
- - `google/gemini-2.5-flash-preview-09-2025` - Fastest responses, 95% savings
774
- - `anthropic/claude-3.5-sonnet` - Full Claude via OpenRouter
391
+ **How it works:**
392
+ 1. Proxy server translates Anthropic API ↔ Gemini/OpenRouter API
393
+ 2. Claude Code sends requests to proxy instead of Anthropic
394
+ 3. Proxy forwards to cheaper provider and translates responses
395
+ 4. MCP tools work seamlessly through proxy
775
396
 
776
- **Cost Comparison:**
777
- | Provider | Model | Input (1K tokens) | Output (1K tokens) | Savings |
778
- |----------|-------|-------------------|-------------------|---------|
779
- | Anthropic Direct | Claude 3.5 Sonnet | $0.003 | $0.015 | Baseline |
780
- | OpenRouter | Llama 3.1 8B | $0.00003 | $0.00006 | **99%** |
781
- | OpenRouter | DeepSeek V3.1 | $0.00014 | $0.00028 | **97%** |
782
- | OpenRouter | Gemini 2.5 Flash | $0.000075 | $0.0003 | **95%** |
783
-
784
- **How It Works:**
785
- 1. Detects OpenRouter model (contains "/") or USE_OPENROUTER=true
786
- 2. Auto-starts integrated proxy server on port 3000
787
- 3. Translates Anthropic Messages API ↔ OpenAI Chat Completions API
788
- 4. Claude Agent SDK transparently uses OpenRouter via ANTHROPIC_BASE_URL
789
- 5. Full MCP tool support (all 203 tools work)
790
-
791
- **Environment Variables:**
792
- ```bash
793
- # Required for OpenRouter
794
- export OPENROUTER_API_KEY=sk-or-v1-...
397
+ ### Setup: Gemini Proxy (85% savings)
795
398
 
796
- # Optional configuration
797
- export USE_OPENROUTER=true # Force OpenRouter usage
798
- export COMPLETION_MODEL=meta-llama/... # Default OpenRouter model
799
- export PROXY_PORT=3000 # Proxy server port
800
- ```
399
+ ```bash
400
+ # Terminal 1: Start Gemini proxy
401
+ export GOOGLE_GEMINI_API_KEY=your-key-here
402
+ npx agentic-flow proxy
801
403
 
802
- ### Free ONNX Local Inference
404
+ # Proxy starts on http://localhost:3000
405
+ # Instructions displayed for configuring Claude Code
803
406
 
804
- Run agents with **zero API costs** using local ONNX models:
407
+ # Terminal 2: Configure Claude Code to use proxy
408
+ export ANTHROPIC_BASE_URL=http://localhost:3000
409
+ export ANTHROPIC_API_KEY=sk-ant-proxy-dummy-key # Any value works
805
410
 
806
- ```javascript
807
- // CPU Inference (6 tokens/sec, 100% free)
808
- const router = new ModelRouter();
809
- const onnxProvider = router.providers.get('onnx');
810
-
811
- const response = await onnxProvider.chat({
812
- model: 'phi-4',
813
- messages: [{ role: 'user', content: 'Analyze this sensitive data...' }],
814
- maxTokens: 100
815
- });
411
+ # Now use Claude Code normally
412
+ claude
816
413
 
817
- console.log(response.content[0].text);
818
- console.log(`Cost: $${response.metadata.cost}`); // $0.00
819
- console.log(`Latency: ${response.metadata.latency}ms`);
820
- console.log(`Privacy: 100% local processing`);
414
+ # Or run agent directly
415
+ claude --agent coder --task "Build REST API"
821
416
  ```
822
417
 
823
- ### Privacy-Based Routing
824
-
825
- Automatically route privacy-sensitive workloads to free local ONNX inference:
826
-
827
- ```javascript
828
- // Configure privacy routing in router.config.json
829
- {
830
- "routing": {
831
- "mode": "rule-based",
832
- "rules": [
833
- {
834
- "condition": { "privacy": "high", "localOnly": true },
835
- "action": { "provider": "onnx" },
836
- "reason": "Privacy-sensitive tasks use free ONNX local models"
837
- }
838
- ]
839
- }
840
- }
841
-
842
- // Router automatically uses ONNX for privacy workloads
843
- const response = await router.chat({
844
- model: 'any-model',
845
- messages: [{ role: 'user', content: 'Process medical records...' }],
846
- metadata: { privacy: 'high', localOnly: true }
847
- });
848
-
849
- // Routed to ONNX automatically (zero cost, 100% local)
850
- console.log(response.metadata.provider); // "onnx-local"
851
- ```
418
+ **Cost Savings:**
419
+ - Gemini free tier: 100% savings vs Anthropic
420
+ - All MCP tools work through proxy
421
+ - Real-time streaming supported
852
422
 
853
- ### GPU Acceleration
423
+ ### Setup: OpenRouter Proxy (90-99% savings)
854
424
 
855
- Enable GPU acceleration for 10-50x performance boost:
425
+ ```bash
426
+ # Terminal 1: Start OpenRouter proxy
427
+ export OPENROUTER_API_KEY=sk-or-v1-...
428
+ npx agentic-flow proxy --provider openrouter --model "openai/gpt-4o-mini"
856
429
 
857
- ```json
858
- // router.config.json
859
- {
860
- "providers": {
861
- "onnx": {
862
- "executionProviders": ["cuda"], // or ["dml"] for Windows
863
- "gpuAcceleration": true,
864
- "modelPath": "./models/phi-4/...",
865
- "maxTokens": 100
866
- }
867
- }
868
- }
430
+ # Terminal 2: Use Claude Code
431
+ export ANTHROPIC_BASE_URL=http://localhost:3000
432
+ export ANTHROPIC_API_KEY=sk-ant-proxy-dummy-key
433
+ claude --agent coder --task "Build web scraper"
869
434
  ```
870
435
 
871
- **Performance Comparison:**
872
- - CPU: 6 tokens/sec (free)
873
- - GPU (CUDA): 60-300 tokens/sec (free)
874
- - Cloud API: Variable (costs $0.002-0.003/request)
875
-
876
- ### Zero-Cost Agent Execution
436
+ **Popular OpenRouter Models:**
437
+ - `openai/gpt-4o-mini` - $0.15/1M tokens (95% savings)
438
+ - `deepseek/deepseek-chat-v3.1` - $0.014/1M tokens (99.5% savings)
439
+ - `meta-llama/llama-3.3-70b-instruct` - $0.30/1M tokens (90% savings)
877
440
 
878
- Run agents entirely offline with local ONNX models:
441
+ ### Proxy Command Reference
879
442
 
880
443
  ```bash
881
- # Use ONNX provider for free inference
882
- npx agentic-flow \
883
- --agent researcher \
884
- --task "Analyze this privacy-sensitive data" \
885
- --provider onnx \
886
- --local-only
444
+ # Start Gemini proxy (default)
445
+ npx agentic-flow proxy
887
446
 
888
- # Result: $0.00 cost, 100% local processing
889
- ```
447
+ # Start OpenRouter proxy
448
+ npx agentic-flow proxy --provider openrouter
890
449
 
891
- ### Cost Comparison
450
+ # Custom port
451
+ npx agentic-flow proxy --port 8080
892
452
 
893
- | Workload Type | Provider | Cost per Request | Privacy | Performance |
894
- |---------------|----------|------------------|---------|-------------|
895
- | **Privacy-Sensitive** | ONNX (CPU) | **$0.00** | 100% local | 6 tokens/sec |
896
- | **Privacy-Sensitive** | ONNX (GPU) | **$0.00** | 100% local | 60-300 tokens/sec |
897
- | **Complex Reasoning** | Anthropic Claude | $0.003 | Cloud | Fast |
898
- | **General Tasks** | OpenRouter | $0.002 | Cloud | Variable |
453
+ # Specific model
454
+ npx agentic-flow proxy --provider openrouter --model "anthropic/claude-3.5-sonnet"
899
455
 
900
- **Example Monthly Costs (1000 requests/day):**
901
- - 100% ONNX: **$0** (free local inference)
902
- - 50% ONNX, 50% cloud: **$30-45** (50% savings)
903
- - 100% cloud APIs: **$60-90**
456
+ # Help
457
+ npx agentic-flow proxy --help
458
+ ```
904
459
 
905
- ---
460
+ ### How MCP Tools Work Through Proxy
906
461
 
907
- ## πŸ”§ MCP Tools (213 Total)
462
+ **Technical Implementation:**
908
463
 
909
- Agentic Flow integrates with **four MCP servers** providing 213 tools total:
464
+ 1. **Tool Schema Forwarding**
465
+ - Anthropic format: `{ name, description, input_schema }`
466
+ - OpenRouter format: `{ type: 'function', function: {...} }`
467
+ - Gemini format: `{ functionDeclarations: [{...}] }`
910
468
 
911
- ### Direct MCP Access
469
+ 2. **Schema Cleaning for Gemini**
470
+ - Removes unsupported fields: `$schema`, `additionalProperties`
471
+ - Recursively cleans nested objects
912
472
 
913
- You can now directly manage MCP servers via the CLI:
473
+ 3. **Response Conversion**
474
+ - OpenRouter: `tool_calls` β†’ `tool_use`
475
+ - Gemini: `functionCall` β†’ `tool_use`
914
476
 
477
+ **Example:**
915
478
  ```bash
916
- # Start all MCP servers
917
- npx agentic-flow mcp start
918
-
919
- # List all 213 available tools
920
- npx agentic-flow mcp list
921
-
922
- # Check server status
923
- npx agentic-flow mcp status
479
+ # MCP tools work automatically through proxy
480
+ export ENABLE_CLAUDE_FLOW_SDK=true
481
+ export ANTHROPIC_BASE_URL=http://localhost:3000
482
+ export ANTHROPIC_API_KEY=sk-ant-proxy-dummy-key
924
483
 
925
- # Start specific server
926
- npx agentic-flow mcp start claude-flow
484
+ # memory_store MCP tool works with Gemini (85% cost savings)
485
+ npx agentic-flow --agent coder --task "Store API config in memory_store"
927
486
  ```
928
487
 
929
- **How It Works:**
930
- 1. **Automatic** (Recommended): Agents automatically access all 213 tools when you run tasks
931
- 2. **Manual**: Use `npx agentic-flow mcp <command>` for direct server management
932
- 3. **Integrated**: All tools work seamlessly whether accessed automatically or manually
933
-
934
- ### Tool Breakdown
935
-
936
- ### Core Orchestration (claude-flow - 101 tools)
937
-
938
- | Category | Tools | Capabilities |
939
- |----------|-------|--------------|
940
- | **Swarm Management** | 12 | Initialize, spawn, coordinate multi-agent swarms |
941
- | **Memory & Storage** | 10 | Persistent memory with TTL and namespaces |
942
- | **Neural Networks** | 12 | Training, inference, WASM-accelerated computation |
943
- | **GitHub Integration** | 8 | PR management, code review, repository analysis |
944
- | **Performance** | 11 | Metrics, bottleneck detection, optimization |
945
- | **Workflow Automation** | 9 | Task orchestration, CI/CD integration |
946
- | **Dynamic Agents** | 7 | Runtime agent creation and coordination |
947
- | **System Utilities** | 8 | Health checks, diagnostics, feature detection |
948
-
949
- ### Cloud Platform (flow-nexus - 96 tools)
950
-
951
- | Category | Tools | Capabilities |
952
- |----------|-------|--------------|
953
- | **☁️ E2B Sandboxes** | 12 | Isolated execution environments (Node, Python, React) |
954
- | **☁️ Distributed Swarms** | 8 | Cloud-based multi-agent deployment |
955
- | **☁️ Neural Training** | 10 | Distributed model training clusters |
956
- | **☁️ Workflows** | 9 | Event-driven automation with message queues |
957
- | **☁️ Templates** | 8 | Pre-built project templates and marketplace |
958
- | **☁️ Challenges** | 6 | Coding challenges with leaderboards |
959
- | **☁️ User Management** | 7 | Authentication, profiles, credit management |
960
- | **☁️ Storage** | 5 | Cloud file storage with real-time sync |
961
-
962
- ### Payment Authorization (agentic-payments - MCP tools)
963
-
964
- Multi-agent payment infrastructure for autonomous AI commerce:
965
-
966
- | Category | Tools | Capabilities |
967
- |----------|-------|--------------|
968
- | **πŸ’³ Active Mandates** | MCP | Create spending limits, time windows, merchant restrictions |
969
- | **πŸ” Ed25519 Signatures** | MCP | Cryptographic transaction signing (<1ms verification) |
970
- | **🀝 Multi-Agent Consensus** | MCP | Byzantine fault-tolerant transaction approval |
971
- | **πŸ“Š Payment Tracking** | MCP | Authorization to settlement lifecycle monitoring |
972
- | **πŸ›‘οΈ Security** | MCP | Spend caps, revocation, audit trails |
973
-
974
- **Use Cases:**
975
- - E-commerce: AI shopping agents with weekly budgets
976
- - Finance: Robo-advisors executing trades within portfolios
977
- - Enterprise: Multi-agent procurement with consensus approval
978
- - Accounting: Automated AP/AR with policy-based workflows
979
-
980
- **Protocols:**
981
- - **AP2**: Agent Payments Protocol with Ed25519 signatures
982
- - **ACP**: Agentic Commerce Protocol (Stripe-compatible)
983
- - **MCP**: Natural language interface for AI assistants
984
-
985
- ### In-Process Tools (claude-flow-sdk - 6 tools)
986
-
987
- Fast, zero-latency tools running in-process:
988
- - `memory_store`, `memory_retrieve`, `memory_list`
989
- - `swarm_init`, `agent_spawn`, `coordination_sync`
990
-
991
488
  ---
992
489
 
993
- ## ⚑ FastMCP Integration (New)
994
-
995
- Agentic Flow now supports **[FastMCP](https://github.com/QuantGeekDev/fastmcp)**, a modern TypeScript framework for building high-performance MCP servers with:
490
+ ## πŸ“š Tutorial: Deployment Options
996
491
 
997
- - **Dual Transport**: stdio (local/subprocess) + HTTP streaming (cloud/network)
998
- - **Type Safety**: Full TypeScript + Zod schema validation
999
- - **Progress Reporting**: Real-time execution feedback
1000
- - **Authentication**: JWT, API keys, OAuth 2.0 support
1001
- - **Rate Limiting**: Built-in abuse prevention
492
+ ### Local Development (Best for Prototyping)
1002
493
 
1003
- ### POC Server (Phase 0 - Completed βœ…)
494
+ **What it does:** Runs agents directly on your machine with full MCP tool access.
1004
495
 
1005
- Basic stdio server with 2 tools to validate fastmcp integration:
496
+ **When to use:** Development, testing, debugging, low-cost experimentation.
1006
497
 
1007
498
  ```bash
1008
- # Test the POC server
1009
- npm run test:fastmcp
1010
-
1011
- # Or run directly
1012
- npm run mcp:fastmcp-poc
1013
- ```
1014
-
1015
- ### Using with Claude Code
1016
-
1017
- Add to your MCP config (`~/.config/claude/mcp.json`):
499
+ # Install globally
500
+ npm install -g agentic-flow
1018
501
 
1019
- ```json
1020
- {
1021
- "mcpServers": {
1022
- "fastmcp-poc": {
1023
- "command": "node",
1024
- "args": ["/path/to/agentic-flow/dist/mcp/fastmcp/servers/poc-stdio.js"]
1025
- }
1026
- }
1027
- }
502
+ # Run locally
503
+ export ANTHROPIC_API_KEY=sk-ant-...
504
+ npx agentic-flow --agent coder --task "Build REST API"
1028
505
  ```
1029
506
 
1030
- ### Available FastMCP Tools (POC)
1031
-
1032
- | Tool | Description | Status |
1033
- |------|-------------|--------|
1034
- | `memory_store` | Store value in persistent memory | βœ… Working |
1035
- | `memory_retrieve` | Retrieve value from memory | βœ… Working |
1036
-
1037
- **Coming Soon (Phase 1):**
1038
- - Migration of 6 claude-flow-sdk tools to fastmcp
1039
- - HTTP streaming transport with authentication
1040
- - Direct in-process execution (no execSync)
1041
- - Comprehensive test suite
1042
-
1043
- **Documentation:**
1044
- - [FastMCP Implementation Plan](docs/mcp/fastmcp-implementation-plan.md) - 10-week migration strategy
1045
- - [FastMCP POC Integration](docs/mcp/fastmcp-poc-integration.md) - Usage and testing guide
507
+ **Benefits:**
508
+ - βœ… All 213 MCP tools work
509
+ - βœ… Fast iteration (<500ms warm start)
510
+ - βœ… Free infrastructure (API costs only)
511
+ - βœ… Full filesystem access
512
+ - βœ… Git integration
1046
513
 
1047
- ---
1048
-
1049
- ## πŸ” Deployment Comparison
1050
-
1051
- | Feature | Local | Docker | Flow Nexus Sandboxes | ONNX Local |
1052
- |---------|-------|--------|----------------------|------------|
1053
- | **MCP Tools Available** | 203 (100%) | 203 (100%) | 203 (100%) | 6 (3%) |
1054
- | **Setup Complexity** | Low | Medium | Medium | Low |
1055
- | **Cold Start Time** | <500ms | <2s | <2s | ~2s (first load) |
1056
- | **Cost (Development)** | Free* | Free* | $1/hour | $0 (100% free) |
1057
- | **Cost (Production)** | Free* | Infra costs | $1/hour | $0 (100% free) |
1058
- | **Privacy** | Local | Local | Cloud | 100% Offline |
1059
- | **Scaling** | Manual | Orchestrator | Automatic | Manual |
1060
- | **Best For** | Dev/Testing | CI/CD/Prod | Cloud-Scale | Privacy/Offline |
1061
-
1062
- *Free infrastructure, Claude API costs only
514
+ **Requirements:**
515
+ - Node.js β‰₯18.0.0
516
+ - 2GB RAM minimum (4GB for swarms)
517
+ - macOS, Linux, or Windows
1063
518
 
1064
519
  ---
1065
520
 
1066
- ## πŸ“¦ Advanced Deployment Patterns
1067
-
1068
- ### ☁️ Flow Nexus Cloud Sandboxes (Scalable Production)
1069
-
1070
- **Best for cloud-native, auto-scaling workloads:**
1071
-
1072
- ```javascript
1073
- // Full-featured agent execution in isolated E2B sandboxes
1074
- import { flowNexus } from 'flow-nexus';
1075
-
1076
- // Setup: One-time authentication
1077
- await flowNexus.login({
1078
- email: process.env.FLOW_NEXUS_EMAIL,
1079
- password: process.env.FLOW_NEXUS_PASSWORD
1080
- });
1081
-
1082
- // Deploy: Create sandbox and execute
1083
- async function deployAgent(task) {
1084
- // 1. Create isolated sandbox
1085
- const sandbox = await flowNexus.sandboxCreate({
1086
- template: 'node', // or 'python', 'react', 'nextjs'
1087
- name: `agent-${Date.now()}`,
1088
- env_vars: {
1089
- ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY
1090
- },
1091
- install_packages: ['@anthropic-ai/claude-agent-sdk'],
1092
- timeout: 3600 // 1 hour max
1093
- });
1094
-
1095
- // 2. Execute agent with ALL 203 MCP tools
1096
- const result = await flowNexus.sandboxExecute({
1097
- sandbox_id: sandbox.id,
1098
- code: `
1099
- const { query } = require('@anthropic-ai/claude-agent-sdk');
1100
- const result = await query({
1101
- prompt: "${task}",
1102
- options: {
1103
- permissionMode: 'bypassPermissions',
1104
- mcpServers: {
1105
- 'claude-flow-sdk': /* 6 tools */,
1106
- 'claude-flow': /* 101 tools */,
1107
- 'flow-nexus': /* 96 tools */
1108
- }
1109
- }
1110
- });
1111
- console.log(JSON.stringify(result));
1112
- `,
1113
- language: 'javascript',
1114
- capture_output: true
1115
- });
1116
-
1117
- // 3. Cleanup (automatic after timeout)
1118
- await flowNexus.sandboxDelete({ sandbox_id: sandbox.id });
1119
-
1120
- return result;
1121
- }
1122
- ```
521
+ ### Docker Containers (Best for Production)
1123
522
 
1124
- **Why Flow Nexus is Recommended:**
1125
- - βœ… **Full MCP Support**: All 203 tools work (subprocess servers supported)
1126
- - βœ… **Persistent Memory**: Claude Flow memory persists across sandboxes
1127
- - βœ… **Security**: Complete process isolation per sandbox
1128
- - βœ… **Multi-Language**: Node.js, Python, React, Next.js templates
1129
- - βœ… **Real-Time**: Live output streaming and monitoring
1130
- - βœ… **Cost-Effective**: Pay per use (10 credits/hour β‰ˆ $1/hour)
1131
-
1132
- **Flow Nexus Pricing:**
1133
- | Resource | Cost | Notes |
1134
- |----------|------|-------|
1135
- | Sandbox (hourly) | 10 credits | β‰ˆ $1/hour per sandbox |
1136
- | Storage | 1 credit/GB/month | Files and environment data |
1137
- | Credits Package | $10 = 100 credits | 10+ hours of sandbox time |
523
+ **What it does:** Packages agents in containers for Kubernetes, ECS, Cloud Run.
1138
524
 
1139
- ---
525
+ **When to use:** CI/CD pipelines, production deployments, reproducible environments.
1140
526
 
1141
- ### 🐳 Container Platforms (Production Orchestration)
527
+ ```bash
528
+ # Build image
529
+ docker build -t agentic-flow .
1142
530
 
1143
- #### Docker (ECS, Cloud Run, Fargate, Kubernetes)
531
+ # Run agent in container
532
+ docker run --rm \
533
+ -e ANTHROPIC_API_KEY=sk-ant-... \
534
+ agentic-flow \
535
+ --agent researcher \
536
+ --task "Analyze cloud patterns"
1144
537
 
1145
- ```dockerfile
1146
- FROM node:20-slim
1147
- WORKDIR /app
1148
- COPY package*.json ./
1149
- RUN npm ci --production
1150
- COPY . .
1151
- CMD ["npm", "start", "--", "--agent", "${AGENT}", "--task", "${TASK}"]
538
+ # Run with OpenRouter (99% cost savings)
539
+ docker run --rm \
540
+ -e OPENROUTER_API_KEY=sk-or-v1-... \
541
+ agentic-flow \
542
+ --agent coder \
543
+ --task "Build API" \
544
+ --model "meta-llama/llama-3.1-8b-instruct"
1152
545
  ```
1153
546
 
1154
- **Best Practices:**
1155
- - Use multi-stage builds for smaller images
1156
- - Enable health checks for orchestrators
1157
- - Set resource limits (CPU/memory)
1158
- - All 203 MCP tools available (subprocess servers work)
1159
- - Use secrets managers for API keys
547
+ **Benefits:**
548
+ - βœ… All 213 MCP tools work
549
+ - βœ… Reproducible builds
550
+ - βœ… Works on Kubernetes, ECS, Cloud Run, Fargate
551
+ - βœ… Process isolation
552
+ - βœ… CI/CD integration
1160
553
 
1161
- #### Kubernetes
554
+ **Orchestration Examples:**
1162
555
 
556
+ **Kubernetes Job:**
1163
557
  ```yaml
1164
558
  apiVersion: batch/v1
1165
559
  kind: Job
1166
560
  metadata:
1167
- name: agentic-flow-job
561
+ name: code-review
1168
562
  spec:
1169
563
  template:
1170
564
  spec:
1171
565
  containers:
1172
566
  - name: agent
1173
567
  image: agentic-flow:latest
1174
- args: ["--agent", "researcher", "--task", "$(TASK)"]
568
+ args: ["--agent", "code-review", "--task", "Review PR #123"]
1175
569
  env:
1176
570
  - name: ANTHROPIC_API_KEY
1177
571
  valueFrom:
1178
572
  secretKeyRef:
1179
- name: anthropic-secret
573
+ name: anthropic
1180
574
  key: api-key
1181
575
  restartPolicy: Never
1182
576
  ```
1183
577
 
1184
- **Best Practices:**
1185
- - Use Jobs for ephemeral executions
1186
- - Set activeDeadlineSeconds for timeouts
1187
- - Use node selectors for cost optimization
1188
- - Implement PodDisruptionBudgets
1189
- - All 203 MCP tools available
1190
-
1191
- ### πŸ’‘ ONNX Local Inference - Extended Configuration
1192
-
1193
- **Advanced ONNX setup with router integration:**
1194
-
1195
- ```javascript
1196
- // router.config.json - Auto-route privacy tasks to ONNX
1197
- {
1198
- "routing": {
1199
- "rules": [
1200
- {
1201
- "condition": { "privacy": "high", "localOnly": true },
1202
- "action": { "provider": "onnx" }
1203
- },
1204
- {
1205
- "condition": { "cost": "free" },
1206
- "action": { "provider": "onnx" }
1207
- }
1208
- ]
1209
- },
1210
- "providers": {
1211
- "onnx": {
1212
- "modelPath": "./models/phi-4/model.onnx",
1213
- "maxTokens": 2048,
1214
- "temperature": 0.7
1215
- }
1216
- }
1217
- }
1218
- ```
1219
-
1220
- **Performance Benchmarks:**
1221
- | Metric | CPU (Intel i7) | GPU (NVIDIA RTX 3060) |
1222
- |--------|---------------|----------------------|
1223
- | Tokens/sec | ~6 | 60-300 |
1224
- | First Token | ~2s | ~500ms |
1225
- | Model Load | ~3s | ~2s |
1226
- | Memory Usage | ~2GB | ~3GB |
1227
- | Cost | $0 | $0 |
1228
-
1229
- **Use Cases:**
1230
- - βœ… Privacy-sensitive data processing
1231
- - βœ… Offline/air-gapped environments
1232
- - βœ… Cost-conscious development
1233
- - βœ… Compliance requirements (HIPAA, GDPR)
1234
- - βœ… Prototype/testing without API costs
1235
-
1236
- **Documentation:**
1237
- - [ONNX Integration Guide](docs/ONNX_INTEGRATION.md)
1238
- - [ONNX CLI Usage](docs/ONNX_CLI_USAGE.md)
1239
- - [ONNX vs Claude Quality Analysis](docs/ONNX_VS_CLAUDE_QUALITY.md)
1240
- const sandbox = await flowNexus.sandboxCreate({
1241
- template: 'node',
1242
- env_vars: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY }
1243
- });
1244
-
1245
- const result = await flowNexus.sandboxExecute({
1246
- sandbox_id: sandbox.id,
1247
- code: `/* Full agent code with all 203 tools */`
1248
- });
1249
-
1250
- await flowNexus.sandboxDelete({ sandbox_id: sandbox.id });
1251
-
1252
- return { statusCode: 200, body: JSON.stringify(result) };
1253
- };
1254
- ```
1255
-
1256
- ---
1257
-
1258
- ## πŸ“Š Architecture
1259
-
1260
- ### Ephemeral Agent Lifecycle
1261
-
1262
- ```
1263
- 1. REQUEST β†’ Agent definition loaded from YAML
1264
- 2. SPAWN β†’ Agent initialized with system prompt + tools
1265
- 3. EXECUTE β†’ Task processed using Claude SDK + MCP tools
1266
- 4. STREAM β†’ Real-time output (optional)
1267
- 5. COMPLETE β†’ Result returned to caller
1268
- 6. TERMINATE β†’ Agent process exits, memory released
1269
- ```
1270
-
1271
- **Key Characteristics:**
1272
- - **Cold Start**: <2s (includes MCP server initialization)
1273
- - **Warm Start**: <500ms (MCP servers cached)
1274
- - **Memory Usage**: 100-200MB per agent
1275
- - **Concurrent Agents**: Limited only by host resources
1276
-
1277
- ### Multi-Agent Coordination
1278
-
1279
- ```
1280
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
1281
- β”‚ Researcher │────▢│ Memory │◀────│ Code Review β”‚
1282
- β”‚ Agent β”‚ β”‚ Storage β”‚ β”‚ Agent β”‚
1283
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1284
- β”‚
1285
- β–Ό
1286
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
1287
- β”‚ Data β”‚
1288
- β”‚ Analyst β”‚
1289
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
578
+ **GitHub Actions:**
579
+ ```yaml
580
+ - name: AI Code Review
581
+ run: |
582
+ docker run -e ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }} \
583
+ agentic-flow:latest \
584
+ --agent code-review \
585
+ --task "${{ github.event.pull_request.diff }}"
1290
586
  ```
1291
587
 
1292
- **Coordination via:**
1293
- - Shared memory (in-process or external)
1294
- - Claude Flow MCP tools
1295
- - File system (for batch jobs)
1296
- - Message queues (for async workflows)
1297
-
1298
- ---
1299
-
1300
- ## πŸ” Advanced Usage
1301
-
1302
- ### Custom Agent Definition
1303
-
1304
- Create `.claude/agents/custom/my-agent.md`:
1305
-
1306
- ```markdown
1307
- ---
1308
- name: my-agent
1309
- description: Custom agent for specific tasks
1310
588
  ---
1311
589
 
1312
- # System Prompt
590
+ ### Cloud Sandboxes (Best for Scale)
1313
591
 
1314
- You are a specialized agent for [your use case].
592
+ **What it does:** Isolated E2B sandboxes with auto-scaling and cloud-native features.
1315
593
 
1316
- ## Capabilities
1317
- - [List capabilities]
594
+ **When to use:** Production scale, multi-tenant workloads, distributed processing.
1318
595
 
1319
- ## Guidelines
1320
- - [Execution guidelines]
1321
- ```
596
+ ```javascript
597
+ // Requires Flow Nexus registration (https://flow-nexus.ruv.io)
598
+ const { flowNexus } = require('flow-nexus');
1322
599
 
1323
- ### Programmatic API
600
+ // 1. Login
601
+ await flowNexus.login({ email: 'user@example.com', password: '***' });
1324
602
 
1325
- ```javascript
1326
- import { query } from '@anthropic-ai/claude-agent-sdk';
1327
- import { getAgent } from 'agentic-flow/utils';
603
+ // 2. Create sandbox
604
+ const sandbox = await flowNexus.sandboxCreate({
605
+ template: 'node',
606
+ name: 'agent-execution',
607
+ env_vars: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY }
608
+ });
1328
609
 
1329
- const agent = getAgent('researcher');
1330
- const result = await query({
1331
- prompt: 'Analyze AI trends',
1332
- options: {
1333
- systemPrompt: agent.systemPrompt,
1334
- permissionMode: 'bypassPermissions'
1335
- }
610
+ // 3. Execute agent with all 213 MCP tools
611
+ const result = await flowNexus.sandboxExecute({
612
+ sandbox_id: sandbox.id,
613
+ code: `
614
+ const { query } = require('@anthropic-ai/claude-agent-sdk');
615
+ await query({ prompt: "Analyze API security", options: { mcpServers: {...} } });
616
+ `
1336
617
  });
1337
618
 
1338
- console.log(result.output);
619
+ // 4. Cleanup
620
+ await flowNexus.sandboxDelete({ sandbox_id: sandbox.id });
1339
621
  ```
1340
622
 
1341
- ### Flow Nexus Integration
1342
-
1343
- Requires registration for cloud features:
1344
-
1345
- ```bash
1346
- # Register account
1347
- npx agentic-flow --agent flow-nexus-auth \
1348
- --task "Register with email: user@example.com"
1349
-
1350
- # Login
1351
- npx agentic-flow --agent flow-nexus-auth \
1352
- --task "Login with email: user@example.com, password: ***"
1353
-
1354
- # Create cloud sandbox
1355
- npx agentic-flow --agent flow-nexus-sandbox \
1356
- --task "Create Node.js sandbox and execute: console.log('Hello')"
1357
- ```
623
+ **Benefits:**
624
+ - βœ… All 213 MCP tools work
625
+ - βœ… Auto-scaling (1 to 100+ sandboxes)
626
+ - βœ… Multi-language templates (Node, Python, React, Next.js)
627
+ - βœ… Real-time streaming
628
+ - βœ… Pay-per-use (10 credits/hour β‰ˆ $1/hour)
1358
629
 
1359
630
  ---
1360
631
 
1361
- ## πŸ“ˆ Performance & Scaling
1362
-
1363
- ### Benchmarks
1364
-
1365
- | Metric | Result |
1366
- |--------|--------|
1367
- | **Cold Start** | <2s (including MCP initialization) |
1368
- | **Warm Start** | <500ms (cached MCP servers) |
1369
- | **Agent Spawn** | 75 agents loaded in <2s |
1370
- | **Tool Discovery** | 203 tools accessible in <1s |
1371
- | **Memory Footprint** | 100-200MB per agent process |
1372
- | **Concurrent Agents** | 10+ on t3.small, 100+ on c6a.xlarge |
1373
- | **Token Efficiency** | 32% reduction via swarm coordination |
632
+ ## πŸ“Š Cost Analysis
1374
633
 
1375
- ### Cost Analysis - ONNX vs Cloud APIs
634
+ ### Monthly Costs for 100 Daily Code Reviews
1376
635
 
1377
- | Provider | Model | Tokens/sec | Cost per 1M tokens | Monthly (100K tasks) |
1378
- |----------|-------|------------|-------------------|---------------------|
1379
- | ONNX Local | Phi-4 | 6-300 | $0 | $0 |
1380
- | OpenRouter | Llama 3.1 8B | API | $0.06 | $6 |
1381
- | OpenRouter | DeepSeek | API | $0.14 | $14 |
1382
- | Claude | Sonnet 3.5 | API | $3.00 | $300 |
636
+ | Provider | Model | Cost per Review | Monthly Total | Savings |
637
+ |----------|-------|----------------|---------------|---------|
638
+ | Anthropic | Claude Sonnet 4.5 | $0.08 | **$240** | Baseline |
639
+ | DeepSeek (OpenRouter) | deepseek-chat-v3.1 | $0.012 | **$36** | **85%** |
640
+ | Llama (OpenRouter) | llama-3.1-8b | $0.003 | **$9** | **96%** |
641
+ | Gemini (Proxy) | gemini-2.0-flash | $0.00 (free tier) | **$0** | **100%** |
642
+ | ONNX (Local) | phi-4 | $0.00 | **$0** | **100%** |
1383
643
 
1384
- **ONNX Savings:** Up to $3,600/year for typical development workloads
644
+ **Real Savings:**
645
+ - **$204/month** switching to DeepSeek
646
+ - **$231/month** switching to Llama 3.1
647
+ - **$240/month** using Gemini free tier or ONNX
1385
648
 
1386
649
  ---
1387
650
 
1388
- ## πŸ› οΈ Development
651
+ ## πŸ› οΈ Configuration
1389
652
 
1390
- ### Build from Source
653
+ ### Environment Variables
1391
654
 
1392
655
  ```bash
1393
- # Clone repository
1394
- git clone https://github.com/ruvnet/agentic-flow.git
1395
- cd agentic-flow
656
+ # Required (choose one provider)
657
+ export ANTHROPIC_API_KEY=sk-ant-... # For Claude models
658
+ export OPENROUTER_API_KEY=sk-or-v1-... # For OpenRouter models
659
+ export GOOGLE_GEMINI_API_KEY=AIza... # For Gemini models
1396
660
 
1397
- # Install dependencies
1398
- npm install
661
+ # MCP Tools (optional)
662
+ export ENABLE_CLAUDE_FLOW_SDK=true # Enable in-SDK MCP tools
1399
663
 
1400
- # Build TypeScript
1401
- npm run build
664
+ # Proxy (optional)
665
+ export ANTHROPIC_BASE_URL=http://localhost:3000 # For proxy usage
1402
666
 
1403
- # Test locally
1404
- node dist/cli.js --help
667
+ # Model Selection (optional)
668
+ export COMPLETION_MODEL=meta-llama/llama-3.1-8b-instruct # Override default
669
+
670
+ # Execution (optional)
671
+ export ENABLE_STREAMING=true # Enable real-time streaming
672
+ export HEALTH_PORT=8080 # Health check port
1405
673
  ```
1406
674
 
1407
- ### Testing
675
+ ### Configuration File (.env)
1408
676
 
1409
677
  ```bash
1410
- # Run all tests
1411
- npm test
1412
-
1413
- # Test specific agent
1414
- node dist/cli.js --agent researcher --task "Test task"
1415
-
1416
- # Validate MCP tools
1417
- npm run validate
678
+ # .env file (auto-loaded)
679
+ ANTHROPIC_API_KEY=sk-ant-...
680
+ OPENROUTER_API_KEY=sk-or-v1-...
681
+ GOOGLE_GEMINI_API_KEY=AIza...
682
+ ENABLE_CLAUDE_FLOW_SDK=true
683
+ COMPLETION_MODEL=deepseek/deepseek-chat-v3.1
1418
684
  ```
1419
685
 
1420
- ### Adding Custom Agents
1421
-
1422
- 1. Create agent definition: `.claude/agents/custom/my-agent.md`
1423
- 2. Define system prompt and capabilities
1424
- 3. Test: `npx agentic-flow --agent my-agent --task "Test"`
1425
- 4. Deploy: `npm run build && docker build -t my-agents .`
1426
-
1427
686
  ---
1428
687
 
1429
- ## πŸ”— Links
1430
-
1431
- - **Documentation**: [docs/](docs/)
1432
- - **GitHub**: [github.com/ruvnet/agentic-flow](https://github.com/ruvnet/agentic-flow)
1433
- - **npm Package**: [npmjs.com/package/agentic-flow](https://www.npmjs.com/package/agentic-flow)
1434
- - **Claude Agent SDK**: [docs.claude.com/en/api/agent-sdk](https://docs.claude.com/en/api/agent-sdk)
1435
- - **Flow Nexus Platform**: [github.com/ruvnet/flow-nexus](https://github.com/ruvnet/flow-nexus)
688
+ ## πŸ“š Complete Agent List
689
+
690
+ ### Core Development (5 agents)
691
+ - `coder` - Implementation specialist
692
+ - `reviewer` - Code review and QA
693
+ - `tester` - Comprehensive testing
694
+ - `planner` - Strategic planning
695
+ - `researcher` - Research and analysis
696
+
697
+ ### Specialized Development (8 agents)
698
+ - `backend-dev` - REST/GraphQL APIs
699
+ - `mobile-dev` - React Native
700
+ - `ml-developer` - Machine learning
701
+ - `system-architect` - Architecture design
702
+ - `cicd-engineer` - CI/CD pipelines
703
+ - `api-docs` - API documentation
704
+ - `production-validator` - Deployment checks
705
+ - `base-template-generator` - Boilerplate generation
706
+
707
+ ### GitHub Integration (10 agents)
708
+ - `pr-manager` - PR lifecycle
709
+ - `code-review-swarm` - Multi-agent review
710
+ - `issue-tracker` - Issue management
711
+ - `release-manager` - Release coordination
712
+ - `workflow-automation` - GitHub Actions
713
+ - `repo-architect` - Repository structure
714
+ - `multi-repo-swarm` - Multi-repo coordination
715
+ - `sync-coordinator` - Cross-repo sync
716
+ - `project-board-sync` - Project boards
717
+ - `swarm-pr`, `swarm-issue` - Issue/PR swarms
718
+
719
+ ### Performance & Analysis (3 agents)
720
+ - `perf-analyzer` - Bottleneck detection
721
+ - `performance-benchmarker` - Benchmarking
722
+ - `code-analyzer` - Code quality
723
+
724
+ ### Swarm Coordinators (5 agents)
725
+ - `hierarchical-coordinator` - Tree structure
726
+ - `mesh-coordinator` - Peer-to-peer
727
+ - `adaptive-coordinator` - Dynamic topology
728
+ - `swarm-memory-manager` - Memory sync
729
+ - `collective-intelligence-coordinator` - Hive mind
730
+
731
+ ### Consensus & Distributed (6 agents)
732
+ - `byzantine-coordinator` - Byzantine fault tolerance
733
+ - `raft-manager` - Raft consensus
734
+ - `gossip-coordinator` - Gossip protocol
735
+ - `crdt-synchronizer` - CRDT sync
736
+ - `quorum-manager` - Quorum management
737
+ - `security-manager` - Security protocols
738
+
739
+ ### SPARC Methodology (6 agents)
740
+ - `sparc-coord` - SPARC orchestration
741
+ - `sparc-coder` - TDD implementation
742
+ - `specification` - Requirements analysis
743
+ - `pseudocode` - Algorithm design
744
+ - `architecture` - System design
745
+ - `refinement` - Iterative improvement
746
+
747
+ ### Testing (2 agents)
748
+ - `tdd-london-swarm` - Mock-driven TDD
749
+ - `production-validator` - Deployment validation
750
+
751
+ ### Planning (4 agents)
752
+ - `goal-planner` - GOAP planning
753
+ - `code-goal-planner` - Code-centric planning
754
+ - `task-orchestrator` - Task coordination
755
+ - `smart-agent` - Intelligent spawning
756
+
757
+ ### Specialized (7+ agents)
758
+ - `migration-planner` - Code migration
759
+ - `swarm-init` - Topology optimization
760
+ - `memory-coordinator` - Cross-session memory
761
+ - And 20+ more...
762
+
763
+ **Total: 66+ agents** | Use `npx agentic-flow --list` to see all
1436
764
 
1437
765
  ---
1438
766
 
1439
- ## 🀝 Contributing
767
+ ## πŸ”— Links & Resources
1440
768
 
1441
- We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
1442
-
1443
- ### Development Setup
1444
- 1. Fork the repository
1445
- 2. Create feature branch: `git checkout -b feature/amazing-feature`
1446
- 3. Make changes and add tests
1447
- 4. Ensure tests pass: `npm test`
1448
- 5. Commit: `git commit -m "feat: add amazing feature"`
1449
- 6. Push: `git push origin feature/amazing-feature`
1450
- 7. Open Pull Request
769
+ - **πŸ“¦ NPM Package**: [npmjs.com/package/agentic-flow](https://www.npmjs.com/package/agentic-flow)
770
+ - **πŸ™ GitHub**: [github.com/ruvnet/agentic-flow](https://github.com/ruvnet/agentic-flow)
771
+ - **πŸ“– Documentation**: [docs/](docs/)
772
+ - **πŸ€– Claude Agent SDK**: [docs.claude.com/en/api/agent-sdk](https://docs.claude.com/en/api/agent-sdk)
773
+ - **⚑ Claude Flow**: [github.com/ruvnet/claude-flow](https://github.com/ruvnet/claude-flow)
774
+ - **☁️ Flow Nexus**: [github.com/ruvnet/flow-nexus](https://github.com/ruvnet/flow-nexus)
775
+ - **πŸ”€ OpenRouter**: [openrouter.ai](https://openrouter.ai)
1451
776
 
1452
777
  ---
1453
778
 
@@ -1467,16 +792,8 @@ Built with:
1467
792
 
1468
793
  ---
1469
794
 
1470
- ## πŸ’¬ Support
1471
-
1472
- - **Documentation**: See [docs/](docs/) folder
1473
- - **Issues**: [GitHub Issues](https://github.com/ruvnet/agentic-flow/issues)
1474
- - **Discussions**: [GitHub Discussions](https://github.com/ruvnet/agentic-flow/discussions)
1475
-
1476
- ---
1477
-
1478
- **Deploy ephemeral AI agents in seconds. Scale to thousands. Pay only for what you use.** πŸš€
795
+ **Deploy AI agents in seconds. Scale to thousands. Pay only for what you use.** πŸš€
1479
796
 
1480
797
  ```bash
1481
- npx agentic-flow --agent researcher --task "Your task here"
798
+ npx agentic-flow --agent coder --task "Your task here"
1482
799
  ```