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.
Files changed (52) hide show
  1. package/.claude/settings.json +16 -5
  2. package/.claude/settings.local.json +3 -2
  3. package/.claude-flow-novice/dist/src/api/auth-service.js +84 -38
  4. package/.claude-flow-novice/dist/src/api/auth-service.js.map +1 -1
  5. package/.claude-flow-novice/dist/src/coordination/index.js +3 -0
  6. package/.claude-flow-novice/dist/src/coordination/index.js.map +1 -1
  7. package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js +12 -0
  8. package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js.map +1 -0
  9. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js +433 -0
  10. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js.map +1 -0
  11. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js +1468 -0
  12. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js.map +1 -0
  13. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +724 -0
  14. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -0
  15. package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js +363 -0
  16. package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js.map +1 -0
  17. package/.claude-flow-novice/dist/src/monitoring/apm/index.js +97 -0
  18. package/.claude-flow-novice/dist/src/monitoring/apm/index.js.map +1 -0
  19. package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js +384 -0
  20. package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js.map +1 -0
  21. package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js +612 -0
  22. package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js.map +1 -0
  23. package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js +282 -0
  24. package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js.map +1 -0
  25. package/.claude-flow-novice/dist/src/providers/provider-manager.js +5 -3
  26. package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
  27. package/.claude-flow-novice/dist/src/providers/tiered-router.js +9 -17
  28. package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
  29. package/.claude-flow-novice/dist/src/web/api/apm-routes.js +355 -0
  30. package/.claude-flow-novice/dist/src/web/api/apm-routes.js.map +1 -0
  31. package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js +425 -0
  32. package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js.map +1 -0
  33. package/.claude-flow-novice/dist/src/web/security/security-middleware.js +379 -0
  34. package/.claude-flow-novice/dist/src/web/security/security-middleware.js.map +1 -0
  35. package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js +441 -0
  36. package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js.map +1 -0
  37. package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js +255 -1
  38. package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js.map +1 -1
  39. package/.claude-flow-novice/metrics.db +0 -0
  40. package/AGENT_PERFORMANCE_GUIDELINES.md +88 -0
  41. package/CLAUDE.md +103 -3
  42. package/config/hooks/post-edit-pipeline.js +68 -118
  43. package/config/hooks/pre-tool-memory-safety.js +209 -0
  44. package/package.json +9 -4
  45. package/scripts/cleanup-idle-sessions.sh +59 -0
  46. package/scripts/monitor-loop.sh +65 -0
  47. package/scripts/monitor-memory.sh +47 -0
  48. package/scripts/monitor.py +43 -0
  49. package/scripts/test-provider-routing.cjs +7 -9
  50. package/wiki/Provider-Routing.md +57 -69
  51. package/.claude-flow-novice/metrics.db-shm +0 -0
  52. 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 1: coordinator/architect/system-architect → Anthropic');
111
- console.log(' Tier 2: All other agents → Z.ai\n');
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 Z.ai (via global settings after restart)');
212
- console.log(' 2. Tier 1 Agents Anthropic (coordinator/architect/system-architect)');
213
- console.log(' 3. Tier 2 Agents Z.ai (all other agents)');
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 Z.ai (lowest cost)');
219
- console.log(' • Worker agents use Z.ai (bulk operations)');
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');
@@ -1,17 +1,17 @@
1
1
  # Provider Routing
2
2
 
3
- Intelligent tiered provider routing system that automatically selects optimal AI providers based on agent profiles, task complexity, and cost optimization goals.
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 cost-effective LLM usage by automatically routing agent requests to the most appropriate provider:
9
+ Provider routing enables optimal LLM usage by automatically routing requests to the most appropriate provider:
10
10
 
11
- - **Profile-based overrides** - Agent profiles specify preferred providers
12
- - **Tiered fallback** - Automatic failover from free to paid tiers
13
- - **Cost optimization** - Up to 64% reduction in API costs
14
- - **Quality preservation** - Maintains output quality while reducing costs
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 priority hierarchy:
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 1: zai (free, rate limited)
30
- ├─> Tier 2: deepseek (budget-friendly)
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 Characteristics
36
+ ### Current Tier Configuration
38
37
 
39
- | Tier | Provider | Cost | Rate Limit | Use Cases |
40
- |------|----------|------|------------|-----------|
41
- | **Tier 1** | zai | Free | 60 req/min | Non-critical tasks, research, drafting |
42
- | **Tier 2** | deepseek | Budget | 100 req/min | Standard development, testing |
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
- ### Global Routing Setup
50
-
51
- Enable tiered routing in `.claude-flow/settings.json`:
52
-
53
- ```json
54
- {
55
- "providers": {
56
- "routing": {
57
- "enabled": true,
58
- "strategy": "tiered",
59
- "tiers": [
60
- {
61
- "name": "zai",
62
- "priority": 1,
63
- "rateLimit": 60,
64
- "fallbackOnError": true
65
- },
66
- {
67
- "name": "deepseek",
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: Enable Tiered Routing
100
+ ### Example 1: Test Current Routing
112
101
 
113
102
  ```bash
114
- # Activate custom routing system
115
- /custom-routing-activate
103
+ # Test routing configuration
104
+ node scripts/test-provider-routing.cjs
116
105
 
117
106
  # Expected output:
118
- # ✅ Custom routing activated
119
- # Priority: Profile Tier 1 (zai) Tier 2 (deepseek) → Tier 3 (anthropic)
120
- # Cost savings: ~64% (free tier + budget fallback)
107
+ # ✅ Agents will route through tiered system:
108
+ # Tier 0: Main chatAnthropic Claude Max
109
+ # Tier 1: ALL Task tool agents Z.ai
121
110
  ```
122
111
 
123
112
  **What happens:**
124
- 1. All agents without profile overrides use zai (free) first
125
- 2. If zai fails/rate-limited, fallback to deepseek (budget)
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` (ignores tiered routing)
141
- - Other agents use tiered routing (zaideepseekanthropic)
128
+ - `system-architect` ALWAYS uses `anthropic` (profile override)
129
+ - Other agents use tiered routing (main-chatanthropic, 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 zai (free tier, Tier 1)
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 anthropic (premium, profile override)
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 zai (free tier, Tier 1)
149
+ // → Uses Z.ai (Tier 1, default for all agents)
162
150
  Task("Coder", "Implement endpoints", "coder")
163
151
 
164
- // Agent 4: security-specialist (profile: anthropic)
165
- // → Uses anthropic (premium, profile override)
166
- Task("Security Auditor", "Audit auth", "security-specialist")
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
- - 2 agents on zai (free) = $0
171
- - 2 agents on anthropic (premium) = standard cost
172
- - **Total savings: ~50%** vs all-anthropic approach
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