claude-flow-novice 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +16 -5
- package/.claude/settings.local.json +3 -2
- package/.claude-flow-novice/dist/src/api/auth-service.js +84 -38
- package/.claude-flow-novice/dist/src/api/auth-service.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/index.js +3 -0
- package/.claude-flow-novice/dist/src/coordination/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js +12 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js +433 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js +1468 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +724 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js +363 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/index.js +97 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js +384 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js +612 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js +282 -0
- package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/providers/provider-manager.js +5 -3
- package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/tiered-router.js +9 -17
- package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
- package/.claude-flow-novice/dist/src/web/api/apm-routes.js +355 -0
- package/.claude-flow-novice/dist/src/web/api/apm-routes.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js +425 -0
- package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/security/security-middleware.js +379 -0
- package/.claude-flow-novice/dist/src/web/security/security-middleware.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js +441 -0
- package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js +255 -1
- package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js.map +1 -1
- package/.claude-flow-novice/metrics.db +0 -0
- package/AGENT_PERFORMANCE_GUIDELINES.md +88 -0
- package/CLAUDE.md +103 -3
- package/config/hooks/post-edit-pipeline.js +68 -118
- package/config/hooks/pre-tool-memory-safety.js +209 -0
- package/package.json +9 -4
- package/scripts/cleanup-idle-sessions.sh +59 -0
- package/scripts/monitor-loop.sh +65 -0
- package/scripts/monitor-memory.sh +47 -0
- package/scripts/monitor.py +43 -0
- package/scripts/test-provider-routing.cjs +7 -9
- package/wiki/Provider-Routing.md +57 -69
- package/.claude-flow-novice/metrics.db-shm +0 -0
- package/.claude-flow-novice/metrics.db-wal +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import subprocess
|
|
3
|
+
import time
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
ITERATIONS = 20
|
|
7
|
+
INTERVAL = 30
|
|
8
|
+
|
|
9
|
+
print("=== Memory Monitor Started ===")
|
|
10
|
+
print(f"Monitoring for {ITERATIONS * INTERVAL} seconds ({ITERATIONS} checks)")
|
|
11
|
+
print(f"Timestamp: {datetime.now()}")
|
|
12
|
+
print()
|
|
13
|
+
|
|
14
|
+
for i in range(1, ITERATIONS + 1):
|
|
15
|
+
timestamp = datetime.now().strftime('%H:%M:%S')
|
|
16
|
+
|
|
17
|
+
# Total memory
|
|
18
|
+
mem_cmd = "ps aux | grep -E '(claude|node)' | grep -v grep | awk '{sum+=$6} END {printf \"%.1f\", sum/1024}'"
|
|
19
|
+
total_mem = subprocess.getoutput(mem_cmd)
|
|
20
|
+
|
|
21
|
+
# Process counts
|
|
22
|
+
node_count = subprocess.getoutput("ps aux | grep node | grep -v grep | grep -v snapfuse | wc -l").strip()
|
|
23
|
+
claude_count = subprocess.getoutput("ps aux | grep claude | grep -v grep | wc -l").strip()
|
|
24
|
+
zombie_count = subprocess.getoutput("ps aux | grep '<defunct>' | grep -v grep | wc -l").strip()
|
|
25
|
+
find_count = subprocess.getoutput("ps aux | grep 'find /mnt/c' | grep -v grep | wc -l").strip()
|
|
26
|
+
|
|
27
|
+
print(f"[{i}/{ITERATIONS}] [{timestamp}] MEM: {total_mem}MB | Node: {node_count} | Claude: {claude_count} | Zombies: {zombie_count} | Find: {find_count}")
|
|
28
|
+
|
|
29
|
+
# Alerts
|
|
30
|
+
if total_mem and float(total_mem) > 10000:
|
|
31
|
+
print(" ⚠️ WARNING: Memory usage exceeds 10GB!")
|
|
32
|
+
|
|
33
|
+
if find_count and int(find_count) > 0:
|
|
34
|
+
print(f" 🔴 CRITICAL: {find_count} find commands on /mnt/c (MEMORY BOMB!)")
|
|
35
|
+
|
|
36
|
+
if zombie_count and int(zombie_count) > 0:
|
|
37
|
+
print(f" 💀 ZOMBIE: {zombie_count} zombie processes detected")
|
|
38
|
+
|
|
39
|
+
if i < ITERATIONS:
|
|
40
|
+
time.sleep(INTERVAL)
|
|
41
|
+
|
|
42
|
+
print()
|
|
43
|
+
print("=== Monitoring Complete ===")
|
|
@@ -107,8 +107,8 @@ if (fs.existsSync(routerPath)) {
|
|
|
107
107
|
|
|
108
108
|
if (hasTiers && hasZai) {
|
|
109
109
|
console.log(' ✅ Agents will route through tiered system:\n');
|
|
110
|
-
console.log(' Tier
|
|
111
|
-
console.log(' Tier
|
|
110
|
+
console.log(' Tier 0: Main chat → Anthropic Claude Max');
|
|
111
|
+
console.log(' Tier 1: ALL Task tool agents → Z.ai\n');
|
|
112
112
|
}
|
|
113
113
|
} else {
|
|
114
114
|
console.log(' ⚠️ Compiled router not found (run npm run build)\n');
|
|
@@ -208,16 +208,14 @@ console.log('═'.repeat(80) + '\n');
|
|
|
208
208
|
console.log('📊 Configuration Summary\n');
|
|
209
209
|
|
|
210
210
|
console.log('✅ WORKING AS DESIGNED:\n');
|
|
211
|
-
console.log(' 1. Main Chat
|
|
212
|
-
console.log(' 2.
|
|
213
|
-
console.log(' 3.
|
|
214
|
-
console.log(' 4. Agent SDK → Anthropic (hardcoded, no alternative)');
|
|
211
|
+
console.log(' 1. Main Chat → Anthropic Claude Max (default routing)');
|
|
212
|
+
console.log(' 2. ALL Task Tool Agents → Z.ai (coder, tester, reviewer, backend-dev, etc.)');
|
|
213
|
+
console.log(' 3. Agent SDK → Anthropic (hardcoded, no alternative)');
|
|
215
214
|
console.log();
|
|
216
215
|
|
|
217
216
|
console.log('💰 COST OPTIMIZATION:\n');
|
|
218
|
-
console.log(' • Main chat uses
|
|
219
|
-
console.log(' •
|
|
220
|
-
console.log(' • Strategic agents use Anthropic (quality-critical)');
|
|
217
|
+
console.log(' • Main chat uses Claude Max subscription (highest quality)');
|
|
218
|
+
console.log(' • ALL Task tool agents use Z.ai (cost-effective bulk operations)');
|
|
221
219
|
console.log(' • Agent SDK provides 90% cost savings via caching\n');
|
|
222
220
|
|
|
223
221
|
console.log('🔍 VERIFICATION:\n');
|
package/wiki/Provider-Routing.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Provider Routing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**UPDATED 2025-10-05:** Simplified 2-tier routing system for clarity and cost optimization.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
9
|
-
Provider routing enables
|
|
9
|
+
Provider routing enables optimal LLM usage by automatically routing requests to the most appropriate provider:
|
|
10
10
|
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
11
|
+
- **Main chat quality** - Claude Max subscription for user-facing interactions
|
|
12
|
+
- **Agent cost optimization** - Z.ai for all Task tool agents
|
|
13
|
+
- **Simple configuration** - Only 2 tiers, easy to understand and maintain
|
|
14
|
+
- **Predictable routing** - Clear separation between main chat and agent operations
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -19,68 +19,57 @@ Provider routing enables cost-effective LLM usage by automatically routing agent
|
|
|
19
19
|
|
|
20
20
|
### Routing Priority
|
|
21
21
|
|
|
22
|
-
Provider selection follows this
|
|
22
|
+
Provider selection follows this simplified hierarchy:
|
|
23
23
|
|
|
24
24
|
```
|
|
25
25
|
1. Agent Profile Override (highest priority)
|
|
26
26
|
└─> Profile.provider field (zai, anthropic, custom)
|
|
27
27
|
|
|
28
28
|
2. Tiered Provider Router
|
|
29
|
-
├─> Tier
|
|
30
|
-
|
|
31
|
-
└─> Tier 3: anthropic (premium, fallback)
|
|
29
|
+
├─> Tier 0: main-chat → Anthropic Claude Max
|
|
30
|
+
└─> Tier 1: ALL Task tool agents → Z.ai
|
|
32
31
|
|
|
33
32
|
3. Default Provider
|
|
34
33
|
└─> anthropic (if no routing configured)
|
|
35
34
|
```
|
|
36
35
|
|
|
37
|
-
### Tier
|
|
36
|
+
### Current Tier Configuration
|
|
38
37
|
|
|
39
|
-
| Tier | Provider |
|
|
40
|
-
|
|
41
|
-
| **Tier
|
|
42
|
-
| **Tier
|
|
43
|
-
| **Tier 3** | anthropic | Premium | 1000 req/min | Critical tasks, production code |
|
|
38
|
+
| Tier | Provider | Agent Types | Use Case |
|
|
39
|
+
|------|----------|-------------|----------|
|
|
40
|
+
| **Tier 0** | Anthropic Claude Max | `main-chat` (default) | Main conversational interface |
|
|
41
|
+
| **Tier 1** | Z.ai | ALL other agents | Task tool agent swarms |
|
|
44
42
|
|
|
45
43
|
---
|
|
46
44
|
|
|
47
45
|
## Configuration
|
|
48
46
|
|
|
49
|
-
###
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"priority": 2,
|
|
69
|
-
"rateLimit": 100,
|
|
70
|
-
"fallbackOnError": true
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"name": "anthropic",
|
|
74
|
-
"priority": 3,
|
|
75
|
-
"rateLimit": 1000,
|
|
76
|
-
"fallbackOnError": false
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
47
|
+
### Current Configuration (Simplified 2-Tier System)
|
|
48
|
+
|
|
49
|
+
Tiered routing is configured in `src/providers/tiered-router.ts`:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const TIER_CONFIGS: TierConfig[] = [
|
|
53
|
+
{
|
|
54
|
+
name: "Tier 0: Main Chat (Claude Max)",
|
|
55
|
+
provider: "anthropic",
|
|
56
|
+
agentTypes: ["main-chat"],
|
|
57
|
+
priority: 0,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "Tier 1: Z.ai Agent Orchestration (ALL Task Tool Agents)",
|
|
61
|
+
provider: "zai",
|
|
62
|
+
agentTypes: [], // All agents EXCEPT "main-chat"
|
|
63
|
+
priority: 1,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
82
66
|
```
|
|
83
67
|
|
|
68
|
+
**Key Points:**
|
|
69
|
+
- **No configuration file needed** - routing is built into the code
|
|
70
|
+
- **Tier 0**: Only `main-chat` (default when no agentType)
|
|
71
|
+
- **Tier 1**: Everything else (fallback for all Task tool agents)
|
|
72
|
+
|
|
84
73
|
### Agent Profile Overrides
|
|
85
74
|
|
|
86
75
|
Override routing for specific agents in `.claude/agents/[agent-name].md`:
|
|
@@ -108,22 +97,21 @@ Critical security auditing agent that requires premium provider.
|
|
|
108
97
|
|
|
109
98
|
## Usage Examples
|
|
110
99
|
|
|
111
|
-
### Example 1:
|
|
100
|
+
### Example 1: Test Current Routing
|
|
112
101
|
|
|
113
102
|
```bash
|
|
114
|
-
#
|
|
115
|
-
/
|
|
103
|
+
# Test routing configuration
|
|
104
|
+
node scripts/test-provider-routing.cjs
|
|
116
105
|
|
|
117
106
|
# Expected output:
|
|
118
|
-
# ✅
|
|
119
|
-
#
|
|
120
|
-
#
|
|
107
|
+
# ✅ Agents will route through tiered system:
|
|
108
|
+
# Tier 0: Main chat → Anthropic Claude Max
|
|
109
|
+
# Tier 1: ALL Task tool agents → Z.ai
|
|
121
110
|
```
|
|
122
111
|
|
|
123
112
|
**What happens:**
|
|
124
|
-
1.
|
|
125
|
-
2.
|
|
126
|
-
3. If deepseek fails, fallback to anthropic (premium)
|
|
113
|
+
1. Main chat (no agentType) defaults to "main-chat" → Anthropic Claude Max
|
|
114
|
+
2. ALL Task tool agents route to Z.ai (coder, tester, reviewer, etc.)
|
|
127
115
|
|
|
128
116
|
### Example 2: Profile-Based Override
|
|
129
117
|
|
|
@@ -137,8 +125,8 @@ reasoning: Architecture decisions require highest quality reasoning
|
|
|
137
125
|
```
|
|
138
126
|
|
|
139
127
|
**Routing behavior:**
|
|
140
|
-
- `system-architect` ALWAYS uses `anthropic` (
|
|
141
|
-
- Other agents use tiered routing (
|
|
128
|
+
- `system-architect` ALWAYS uses `anthropic` (profile override)
|
|
129
|
+
- Other agents use tiered routing (main-chat → anthropic, all others → zai)
|
|
142
130
|
|
|
143
131
|
### Example 3: Mixed Agent Swarm
|
|
144
132
|
|
|
@@ -150,26 +138,26 @@ mcp__claude-flow-novice__swarm_init({
|
|
|
150
138
|
})
|
|
151
139
|
|
|
152
140
|
// Agent 1: researcher (no profile override)
|
|
153
|
-
// → Uses
|
|
141
|
+
// → Uses Z.ai (Tier 1, default for all agents)
|
|
154
142
|
Task("Researcher", "Research JWT libraries", "researcher")
|
|
155
143
|
|
|
156
144
|
// Agent 2: system-architect (profile: anthropic)
|
|
157
|
-
// → Uses
|
|
145
|
+
// → Uses Anthropic (profile override)
|
|
158
146
|
Task("Architect", "Design auth system", "system-architect")
|
|
159
147
|
|
|
160
148
|
// Agent 3: coder (no profile override)
|
|
161
|
-
// → Uses
|
|
149
|
+
// → Uses Z.ai (Tier 1, default for all agents)
|
|
162
150
|
Task("Coder", "Implement endpoints", "coder")
|
|
163
151
|
|
|
164
|
-
// Agent 4:
|
|
165
|
-
// → Uses
|
|
166
|
-
Task("
|
|
152
|
+
// Agent 4: tester (no profile override)
|
|
153
|
+
// → Uses Z.ai (Tier 1, default for all agents)
|
|
154
|
+
Task("Tester", "Test endpoints", "tester")
|
|
167
155
|
```
|
|
168
156
|
|
|
169
157
|
**Cost breakdown:**
|
|
170
|
-
-
|
|
171
|
-
-
|
|
172
|
-
- **Total savings: ~
|
|
158
|
+
- 3 agents on Z.ai (coder, researcher, tester) = lowest cost
|
|
159
|
+
- 1 agent on Anthropic (system-architect) = standard cost
|
|
160
|
+
- **Total savings: ~75%** vs all-anthropic approach
|
|
173
161
|
|
|
174
162
|
### Example 4: Disable Custom Routing
|
|
175
163
|
|
|
Binary file
|
|
Binary file
|