claude-flow 2.5.0-alpha.141 → 2.7.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/reasoning/README.md +171 -0
- package/.claude/agents/reasoning/agent.md +816 -0
- package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
- package/.claude/agents/reasoning/goal-planner.md +73 -0
- package/.claude/commands/coordination/README.md +9 -0
- package/.claude/commands/memory/README.md +9 -0
- package/.claude/settings.json +3 -3
- package/.claude/sparc-modes.json +108 -0
- package/README.md +1 -6
- package/bin/claude-flow +1 -1
- package/dist/src/cli/command-registry.js +70 -6
- package/dist/src/cli/command-registry.js.map +1 -1
- package/dist/src/cli/help-formatter.js +0 -3
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/help-text.js +53 -5
- package/dist/src/cli/help-text.js.map +1 -1
- package/dist/src/cli/simple-cli.js +182 -172
- package/dist/src/cli/simple-cli.js.map +1 -1
- package/dist/src/cli/simple-commands/agent-booster.js +415 -0
- package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
- package/dist/src/cli/simple-commands/agent.js +856 -13
- package/dist/src/cli/simple-commands/agent.js.map +1 -1
- package/dist/src/cli/simple-commands/env-template.js +180 -0
- package/dist/src/cli/simple-commands/env-template.js.map +1 -0
- package/dist/src/cli/simple-commands/init/help.js +23 -0
- package/dist/src/cli/simple-commands/init/help.js.map +1 -1
- package/dist/src/cli/simple-commands/init/index.js +63 -0
- package/dist/src/cli/simple-commands/init/index.js.map +1 -1
- package/dist/src/cli/simple-commands/memory.js +307 -16
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/cli/simple-commands/proxy.js +304 -0
- package/dist/src/cli/simple-commands/proxy.js.map +1 -0
- package/dist/src/cli/simple-commands/sparc.js +16 -19
- package/dist/src/cli/simple-commands/sparc.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/core/version.js +1 -1
- package/dist/src/execution/agent-executor.js +181 -0
- package/dist/src/execution/agent-executor.js.map +1 -0
- package/dist/src/execution/index.js +12 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/provider-manager.js +110 -0
- package/dist/src/execution/provider-manager.js.map +1 -0
- package/dist/src/hooks/redaction-hook.js +89 -0
- package/dist/src/hooks/redaction-hook.js.map +1 -0
- package/dist/src/memory/swarm-memory.js +340 -421
- package/dist/src/memory/swarm-memory.js.map +1 -1
- package/dist/src/utils/key-redactor.js +108 -0
- package/dist/src/utils/key-redactor.js.map +1 -0
- package/dist/src/utils/metrics-reader.js +37 -39
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
- package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
- package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
- package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
- package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
- package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
- package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
- package/docs/COMMIT_SUMMARY.md +247 -0
- package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
- package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
- package/docs/ENV-SETUP-GUIDE.md +270 -0
- package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
- package/docs/FINAL_VALIDATION_REPORT.md +165 -0
- package/docs/HOOKS-V2-MODIFICATION.md +146 -0
- package/docs/INDEX.md +568 -0
- package/docs/INTEGRATION_COMPLETE.md +414 -0
- package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
- package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
- package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
- package/docs/README.md +35 -0
- package/docs/REASONING-AGENTS.md +482 -0
- package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
- package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
- package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
- package/docs/REASONINGBANK-BENCHMARK.md +396 -0
- package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
- package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
- package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
- package/docs/REASONINGBANK-DEMO.md +419 -0
- package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
- package/docs/REASONINGBANK-VALIDATION.md +532 -0
- package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
- package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
- package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
- package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
- package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
- package/docs/api/API_DOCUMENTATION.md +721 -0
- package/docs/architecture/ARCHITECTURE.md +1690 -0
- package/docs/ci-cd/README.md +368 -0
- package/docs/development/DEPLOYMENT.md +2348 -0
- package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
- package/docs/development/build-analysis-report.md +252 -0
- package/docs/development/pair-optimization.md +156 -0
- package/docs/development/token-tracking-status.md +103 -0
- package/docs/development/training-pipeline-demo.md +163 -0
- package/docs/development/training-pipeline-real-only.md +196 -0
- package/docs/epic-sdk-integration.md +1269 -0
- package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
- package/docs/experimental/computational_verification.py +436 -0
- package/docs/experimental/novel_approaches.md +560 -0
- package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
- package/docs/experimental/riemann_proof_attempt.md +124 -0
- package/docs/experimental/riemann_synthesis.md +277 -0
- package/docs/experimental/verification_results.json +12 -0
- package/docs/experimental/visualization_insights.md +720 -0
- package/docs/guides/USER_GUIDE.md +1138 -0
- package/docs/guides/token-tracking-guide.md +291 -0
- package/docs/reference/AGENTS.md +1011 -0
- package/docs/reference/MCP_TOOLS.md +2188 -0
- package/docs/reference/SPARC.md +717 -0
- package/docs/reference/SWARM.md +2000 -0
- package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
- package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
- package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
- package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
- package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
- package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
- package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
- package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
- package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
- package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
- package/docs/sdk/epic-sdk-integration.md +1269 -0
- package/docs/setup/remote-setup.md +93 -0
- package/docs/validation/final-validation-summary.md +220 -0
- package/docs/validation/verification-integration.md +190 -0
- package/docs/validation/verification-validation.md +349 -0
- package/docs/wiki/background-commands.md +1213 -0
- package/docs/wiki/session-persistence.md +342 -0
- package/docs/wiki/stream-chain-command.md +537 -0
- package/package.json +4 -2
- package/src/cli/command-registry.js +70 -5
- package/src/cli/help-text.js +26 -5
- package/src/cli/simple-cli.ts +18 -7
- package/src/cli/simple-commands/agent-booster.js +515 -0
- package/src/cli/simple-commands/agent.js +1001 -12
- package/src/cli/simple-commands/agent.ts +137 -0
- package/src/cli/simple-commands/config.ts +127 -0
- package/src/cli/simple-commands/env-template.js +190 -0
- package/src/cli/simple-commands/init/help.js +23 -0
- package/src/cli/simple-commands/init/index.js +84 -6
- package/src/cli/simple-commands/memory.js +363 -16
- package/src/cli/simple-commands/proxy.js +384 -0
- package/src/cli/simple-commands/sparc.js +16 -19
- package/src/execution/agent-executor.ts +306 -0
- package/src/execution/index.ts +19 -0
- package/src/execution/provider-manager.ts +187 -0
- package/src/hooks/redaction-hook.ts +115 -0
- package/src/utils/key-redactor.js +178 -0
- package/src/utils/key-redactor.ts +184 -0
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
# Claude-Flow Integration: Network Sandboxing & DevTools
|
|
2
|
+
## Advanced SDK Feature Integration for Swarm Orchestration
|
|
3
|
+
|
|
4
|
+
**Version**: 2.5.0-alpha.130
|
|
5
|
+
**Date**: 2025-09-30
|
|
6
|
+
**Status**: Design Phase
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 🎯 Overview
|
|
11
|
+
|
|
12
|
+
This document explores how to integrate two advanced Claude Code SDK features into Claude-Flow's swarm orchestration system:
|
|
13
|
+
|
|
14
|
+
1. **Network Request Sandboxing** - Per-agent network isolation and governance
|
|
15
|
+
2. **React DevTools Integration** - Real-time swarm visualization and profiling
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 1️⃣ Network Request Sandboxing Integration
|
|
20
|
+
|
|
21
|
+
### SDK Feature Analysis
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// Discovered in @anthropic-ai/claude-code CLI source
|
|
25
|
+
interface NetworkPermission {
|
|
26
|
+
hostPattern: { host: string; port: number };
|
|
27
|
+
allow: boolean;
|
|
28
|
+
rememberForSession: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Implementation pattern (inferred from minified code)
|
|
32
|
+
function promptNetworkAccess(
|
|
33
|
+
hostPattern: { host: string; port: number }
|
|
34
|
+
): Promise<NetworkPermissionResponse> {
|
|
35
|
+
// SDK prompts user for approval
|
|
36
|
+
// Returns: { allow: boolean, rememberForSession: boolean }
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Key Capabilities**:
|
|
41
|
+
- ✅ Host-level network isolation
|
|
42
|
+
- ✅ Port-specific access control
|
|
43
|
+
- ✅ Session-persistent permissions
|
|
44
|
+
- ✅ Interactive approval flow
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### 🚀 Claude-Flow Integration Strategy
|
|
49
|
+
|
|
50
|
+
#### **Use Case 1: Per-Agent Network Policies**
|
|
51
|
+
|
|
52
|
+
**Scenario**: Different agents need different network access levels
|
|
53
|
+
- Research agents → Full internet access
|
|
54
|
+
- Code analysis agents → GitHub API only
|
|
55
|
+
- Validation agents → No network access (sandboxed)
|
|
56
|
+
|
|
57
|
+
**Implementation**:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// src/swarm/network-policy-manager.ts
|
|
61
|
+
import { AgentType, SwarmConfig } from './types';
|
|
62
|
+
|
|
63
|
+
interface AgentNetworkPolicy {
|
|
64
|
+
agentType: AgentType;
|
|
65
|
+
allowedHosts: Array<{ host: string; port: number }>;
|
|
66
|
+
deniedHosts: Array<{ host: string; port: number }>;
|
|
67
|
+
defaultBehavior: 'allow' | 'deny' | 'prompt';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class NetworkPolicyManager {
|
|
71
|
+
private policies: Map<AgentType, AgentNetworkPolicy> = new Map();
|
|
72
|
+
|
|
73
|
+
constructor() {
|
|
74
|
+
this.initializeDefaultPolicies();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private initializeDefaultPolicies() {
|
|
78
|
+
// Research agent - broad access
|
|
79
|
+
this.policies.set('researcher', {
|
|
80
|
+
agentType: 'researcher',
|
|
81
|
+
allowedHosts: [
|
|
82
|
+
{ host: '*.anthropic.com', port: 443 },
|
|
83
|
+
{ host: '*.github.com', port: 443 },
|
|
84
|
+
{ host: '*.stackoverflow.com', port: 443 },
|
|
85
|
+
{ host: '*.npmjs.com', port: 443 }
|
|
86
|
+
],
|
|
87
|
+
deniedHosts: [],
|
|
88
|
+
defaultBehavior: 'prompt'
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Coder agent - restricted to documentation and package registries
|
|
92
|
+
this.policies.set('coder', {
|
|
93
|
+
agentType: 'coder',
|
|
94
|
+
allowedHosts: [
|
|
95
|
+
{ host: 'api.github.com', port: 443 },
|
|
96
|
+
{ host: 'registry.npmjs.org', port: 443 },
|
|
97
|
+
{ host: 'pypi.org', port: 443 }
|
|
98
|
+
],
|
|
99
|
+
deniedHosts: [],
|
|
100
|
+
defaultBehavior: 'deny'
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Analyst agent - no network access (sandboxed)
|
|
104
|
+
this.policies.set('analyst', {
|
|
105
|
+
agentType: 'analyst',
|
|
106
|
+
allowedHosts: [],
|
|
107
|
+
deniedHosts: [{ host: '*', port: '*' }],
|
|
108
|
+
defaultBehavior: 'deny'
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Optimizer agent - metrics endpoints only
|
|
112
|
+
this.policies.set('optimizer', {
|
|
113
|
+
agentType: 'optimizer',
|
|
114
|
+
allowedHosts: [
|
|
115
|
+
{ host: 'api.anthropic.com', port: 443 }
|
|
116
|
+
],
|
|
117
|
+
deniedHosts: [],
|
|
118
|
+
defaultBehavior: 'deny'
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async checkNetworkAccess(
|
|
123
|
+
agentType: AgentType,
|
|
124
|
+
host: string,
|
|
125
|
+
port: number,
|
|
126
|
+
sessionId: string
|
|
127
|
+
): Promise<{ allowed: boolean; reason: string }> {
|
|
128
|
+
const policy = this.policies.get(agentType);
|
|
129
|
+
if (!policy) {
|
|
130
|
+
return { allowed: false, reason: 'No policy found for agent type' };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Check explicit denials first
|
|
134
|
+
if (this.isHostDenied(host, port, policy.deniedHosts)) {
|
|
135
|
+
return {
|
|
136
|
+
allowed: false,
|
|
137
|
+
reason: `Host ${host}:${port} is explicitly denied for ${agentType} agents`
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Check explicit allows
|
|
142
|
+
if (this.isHostAllowed(host, port, policy.allowedHosts)) {
|
|
143
|
+
return {
|
|
144
|
+
allowed: true,
|
|
145
|
+
reason: `Host ${host}:${port} is whitelisted for ${agentType} agents`
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Apply default behavior
|
|
150
|
+
switch (policy.defaultBehavior) {
|
|
151
|
+
case 'allow':
|
|
152
|
+
return { allowed: true, reason: 'Default allow policy' };
|
|
153
|
+
case 'deny':
|
|
154
|
+
return { allowed: false, reason: 'Default deny policy' };
|
|
155
|
+
case 'prompt':
|
|
156
|
+
// Delegate to SDK's interactive prompt
|
|
157
|
+
return await this.promptUserForAccess(agentType, host, port, sessionId);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private isHostAllowed(
|
|
162
|
+
host: string,
|
|
163
|
+
port: number,
|
|
164
|
+
allowedHosts: Array<{ host: string; port: number }>
|
|
165
|
+
): boolean {
|
|
166
|
+
return allowedHosts.some(pattern =>
|
|
167
|
+
this.matchesPattern(host, pattern.host) &&
|
|
168
|
+
(pattern.port === '*' || pattern.port === port)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private isHostDenied(
|
|
173
|
+
host: string,
|
|
174
|
+
port: number,
|
|
175
|
+
deniedHosts: Array<{ host: string; port: number }>
|
|
176
|
+
): boolean {
|
|
177
|
+
return deniedHosts.some(pattern =>
|
|
178
|
+
this.matchesPattern(host, pattern.host) &&
|
|
179
|
+
(pattern.port === '*' || pattern.port === port)
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private matchesPattern(host: string, pattern: string): boolean {
|
|
184
|
+
// Wildcard pattern matching
|
|
185
|
+
const regex = new RegExp(
|
|
186
|
+
'^' + pattern.replace(/\*/g, '.*').replace(/\./g, '\\.') + '$'
|
|
187
|
+
);
|
|
188
|
+
return regex.test(host);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private async promptUserForAccess(
|
|
192
|
+
agentType: AgentType,
|
|
193
|
+
host: string,
|
|
194
|
+
port: number,
|
|
195
|
+
sessionId: string
|
|
196
|
+
): Promise<{ allowed: boolean; reason: string }> {
|
|
197
|
+
// Use SDK's native network prompt
|
|
198
|
+
const response = await this.sdkNetworkPrompt({ host, port });
|
|
199
|
+
|
|
200
|
+
if (response.rememberForSession) {
|
|
201
|
+
// Cache decision for this session
|
|
202
|
+
this.cacheSessionDecision(sessionId, host, port, response.allow);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
allowed: response.allow,
|
|
207
|
+
reason: response.allow
|
|
208
|
+
? `User approved access to ${host}:${port}`
|
|
209
|
+
: `User denied access to ${host}:${port}`
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async setAgentPolicy(agentType: AgentType, policy: AgentNetworkPolicy): Promise<void> {
|
|
214
|
+
this.policies.set(agentType, policy);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async getAgentPolicy(agentType: AgentType): Promise<AgentNetworkPolicy | undefined> {
|
|
218
|
+
return this.policies.get(agentType);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
#### **Use Case 2: Swarm-Level Network Isolation**
|
|
226
|
+
|
|
227
|
+
**Scenario**: Entire swarm operates in restricted network environment
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
// src/swarm/swarm-network-manager.ts
|
|
231
|
+
export class SwarmNetworkManager {
|
|
232
|
+
private policyManager: NetworkPolicyManager;
|
|
233
|
+
private swarmSessions: Map<string, NetworkSessionData> = new Map();
|
|
234
|
+
|
|
235
|
+
async initializeSwarm(
|
|
236
|
+
swarmId: string,
|
|
237
|
+
config: SwarmNetworkConfig
|
|
238
|
+
): Promise<void> {
|
|
239
|
+
this.swarmSessions.set(swarmId, {
|
|
240
|
+
isolationMode: config.isolationMode,
|
|
241
|
+
allowedHosts: config.allowedHosts || [],
|
|
242
|
+
deniedHosts: config.deniedHosts || [],
|
|
243
|
+
agentPermissions: new Map()
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async beforeAgentNetworkRequest(
|
|
248
|
+
agentId: string,
|
|
249
|
+
agentType: AgentType,
|
|
250
|
+
request: NetworkRequest
|
|
251
|
+
): Promise<NetworkRequestResult> {
|
|
252
|
+
const swarmId = this.getSwarmIdForAgent(agentId);
|
|
253
|
+
const session = this.swarmSessions.get(swarmId);
|
|
254
|
+
|
|
255
|
+
if (!session) {
|
|
256
|
+
throw new Error(`No network session found for swarm ${swarmId}`);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Check swarm-level restrictions first
|
|
260
|
+
if (session.isolationMode === 'strict') {
|
|
261
|
+
const swarmAllowed = this.isHostAllowedInSwarm(
|
|
262
|
+
request.host,
|
|
263
|
+
request.port,
|
|
264
|
+
session
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
if (!swarmAllowed) {
|
|
268
|
+
return {
|
|
269
|
+
allowed: false,
|
|
270
|
+
reason: `Swarm ${swarmId} operates in strict isolation mode`,
|
|
271
|
+
blockedBy: 'swarm-policy'
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Check agent-level policy
|
|
277
|
+
const agentCheck = await this.policyManager.checkNetworkAccess(
|
|
278
|
+
agentType,
|
|
279
|
+
request.host,
|
|
280
|
+
request.port,
|
|
281
|
+
agentId
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
if (!agentCheck.allowed) {
|
|
285
|
+
return {
|
|
286
|
+
allowed: false,
|
|
287
|
+
reason: agentCheck.reason,
|
|
288
|
+
blockedBy: 'agent-policy'
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Record permission grant for audit
|
|
293
|
+
this.recordNetworkAccess(swarmId, agentId, request);
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
allowed: true,
|
|
297
|
+
reason: 'Approved by swarm and agent policies'
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async getSwarmNetworkAudit(swarmId: string): Promise<NetworkAuditLog> {
|
|
302
|
+
// Return complete audit trail of network requests
|
|
303
|
+
return {
|
|
304
|
+
swarmId,
|
|
305
|
+
totalRequests: this.getTotalRequests(swarmId),
|
|
306
|
+
approvedRequests: this.getApprovedRequests(swarmId),
|
|
307
|
+
deniedRequests: this.getDeniedRequests(swarmId),
|
|
308
|
+
requestsByAgent: this.getRequestsByAgent(swarmId),
|
|
309
|
+
requestsByHost: this.getRequestsByHost(swarmId)
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
#### **Use Case 3: Dynamic Network Policy Updates**
|
|
318
|
+
|
|
319
|
+
**Scenario**: Adjust network policies based on swarm behavior
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
// src/swarm/adaptive-network-policy.ts
|
|
323
|
+
export class AdaptiveNetworkPolicy {
|
|
324
|
+
async analyzeSwarmBehavior(swarmId: string): Promise<PolicyRecommendations> {
|
|
325
|
+
const audit = await this.networkManager.getSwarmNetworkAudit(swarmId);
|
|
326
|
+
|
|
327
|
+
const recommendations: PolicyRecommendations = {
|
|
328
|
+
expansions: [],
|
|
329
|
+
restrictions: [],
|
|
330
|
+
warnings: []
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// Detect patterns of denied requests
|
|
334
|
+
const frequentlyDenied = this.findFrequentlyDeniedHosts(audit);
|
|
335
|
+
if (frequentlyDenied.length > 0) {
|
|
336
|
+
recommendations.warnings.push({
|
|
337
|
+
type: 'frequent-denials',
|
|
338
|
+
hosts: frequentlyDenied,
|
|
339
|
+
suggestion: 'Consider adding these hosts to allowlist if trusted'
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Detect suspicious network patterns
|
|
344
|
+
const suspiciousActivity = this.detectSuspiciousPatterns(audit);
|
|
345
|
+
if (suspiciousActivity.length > 0) {
|
|
346
|
+
recommendations.restrictions.push({
|
|
347
|
+
type: 'suspicious-activity',
|
|
348
|
+
details: suspiciousActivity,
|
|
349
|
+
action: 'Recommend restricting network access for affected agents'
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return recommendations;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
private detectSuspiciousPatterns(audit: NetworkAuditLog): SuspiciousPattern[] {
|
|
357
|
+
const patterns: SuspiciousPattern[] = [];
|
|
358
|
+
|
|
359
|
+
// Port scanning detection
|
|
360
|
+
const portScans = this.detectPortScanning(audit);
|
|
361
|
+
if (portScans.length > 0) {
|
|
362
|
+
patterns.push({
|
|
363
|
+
type: 'port-scan',
|
|
364
|
+
agents: portScans,
|
|
365
|
+
severity: 'high'
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Unusual TLD access
|
|
370
|
+
const unusualTLDs = this.detectUnusualTLDs(audit);
|
|
371
|
+
if (unusualTLDs.length > 0) {
|
|
372
|
+
patterns.push({
|
|
373
|
+
type: 'unusual-tld',
|
|
374
|
+
hosts: unusualTLDs,
|
|
375
|
+
severity: 'medium'
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return patterns;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## 2️⃣ React DevTools Integration
|
|
387
|
+
|
|
388
|
+
### SDK Feature Analysis
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
// Discovered in @anthropic-ai/claude-code CLI source
|
|
392
|
+
window.__REACT_DEVTOOLS_COMPONENT_FILTERS__
|
|
393
|
+
|
|
394
|
+
// SDK includes full React DevTools backend for TUI rendering
|
|
395
|
+
// React Fiber profiling
|
|
396
|
+
// Component tree inspection
|
|
397
|
+
// Performance timeline tracking
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**Key Capabilities**:
|
|
401
|
+
- ✅ Real-time component tree visualization
|
|
402
|
+
- ✅ Performance profiling (render times, re-renders)
|
|
403
|
+
- ✅ State inspection
|
|
404
|
+
- ✅ Props tracking
|
|
405
|
+
- ✅ Timeline analysis
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
### 🚀 Claude-Flow Integration Strategy
|
|
410
|
+
|
|
411
|
+
#### **Use Case 1: Swarm Visualization Dashboard**
|
|
412
|
+
|
|
413
|
+
**Scenario**: Real-time visualization of swarm topology and agent states
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
// src/ui/swarm-devtools.tsx
|
|
417
|
+
import React, { useEffect, useState } from 'react';
|
|
418
|
+
import { Box, Text, useApp } from 'ink';
|
|
419
|
+
|
|
420
|
+
interface SwarmNode {
|
|
421
|
+
id: string;
|
|
422
|
+
type: string;
|
|
423
|
+
status: 'idle' | 'busy' | 'failed';
|
|
424
|
+
connections: string[];
|
|
425
|
+
metrics: {
|
|
426
|
+
tasksCompleted: number;
|
|
427
|
+
avgExecutionTime: number;
|
|
428
|
+
errorRate: number;
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export const SwarmDevToolsDashboard: React.FC<{
|
|
433
|
+
swarmId: string;
|
|
434
|
+
}> = ({ swarmId }) => {
|
|
435
|
+
const [topology, setTopology] = useState<SwarmNode[]>([]);
|
|
436
|
+
const [selectedNode, setSelectedNode] = useState<string | null>(null);
|
|
437
|
+
|
|
438
|
+
useEffect(() => {
|
|
439
|
+
// Subscribe to swarm state updates
|
|
440
|
+
const unsubscribe = SwarmMonitor.subscribe(swarmId, (state) => {
|
|
441
|
+
setTopology(state.agents);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
return unsubscribe;
|
|
445
|
+
}, [swarmId]);
|
|
446
|
+
|
|
447
|
+
return (
|
|
448
|
+
<Box flexDirection="column" padding={1}>
|
|
449
|
+
<Box borderStyle="round" borderColor="cyan">
|
|
450
|
+
<Text bold color="cyan">
|
|
451
|
+
🐝 Swarm Topology: {swarmId}
|
|
452
|
+
</Text>
|
|
453
|
+
</Box>
|
|
454
|
+
|
|
455
|
+
<Box flexDirection="row" marginTop={1}>
|
|
456
|
+
{/* Agent Grid */}
|
|
457
|
+
<Box flexDirection="column" width="50%">
|
|
458
|
+
{topology.map((node) => (
|
|
459
|
+
<AgentCard
|
|
460
|
+
key={node.id}
|
|
461
|
+
node={node}
|
|
462
|
+
selected={selectedNode === node.id}
|
|
463
|
+
onSelect={() => setSelectedNode(node.id)}
|
|
464
|
+
/>
|
|
465
|
+
))}
|
|
466
|
+
</Box>
|
|
467
|
+
|
|
468
|
+
{/* Agent Details Panel */}
|
|
469
|
+
<Box flexDirection="column" width="50%" paddingLeft={2}>
|
|
470
|
+
{selectedNode && (
|
|
471
|
+
<AgentDetailsPanel
|
|
472
|
+
node={topology.find((n) => n.id === selectedNode)!}
|
|
473
|
+
/>
|
|
474
|
+
)}
|
|
475
|
+
</Box>
|
|
476
|
+
</Box>
|
|
477
|
+
|
|
478
|
+
{/* Network Graph Visualization */}
|
|
479
|
+
<Box marginTop={2}>
|
|
480
|
+
<SwarmNetworkGraph topology={topology} />
|
|
481
|
+
</Box>
|
|
482
|
+
</Box>
|
|
483
|
+
);
|
|
484
|
+
};
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
#### **Use Case 2: Agent Performance Profiling**
|
|
490
|
+
|
|
491
|
+
**Scenario**: Profile individual agent performance using React Fiber data
|
|
492
|
+
|
|
493
|
+
```typescript
|
|
494
|
+
// src/profiling/agent-profiler.ts
|
|
495
|
+
export class AgentProfiler {
|
|
496
|
+
private fiberData: Map<string, FiberPerformanceData> = new Map();
|
|
497
|
+
|
|
498
|
+
async captureAgentProfile(agentId: string): Promise<AgentProfile> {
|
|
499
|
+
// Hook into React DevTools profiling API
|
|
500
|
+
const profiler = this.getReactProfiler();
|
|
501
|
+
|
|
502
|
+
// Start profiling
|
|
503
|
+
profiler.startProfiling();
|
|
504
|
+
|
|
505
|
+
// Let agent execute
|
|
506
|
+
await this.executeAgentTasks(agentId);
|
|
507
|
+
|
|
508
|
+
// Stop and collect data
|
|
509
|
+
const profilingData = profiler.stopProfiling();
|
|
510
|
+
|
|
511
|
+
return this.analyzeProfilingData(agentId, profilingData);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
private analyzeProfilingData(
|
|
515
|
+
agentId: string,
|
|
516
|
+
data: ReactProfilingData
|
|
517
|
+
): AgentProfile {
|
|
518
|
+
return {
|
|
519
|
+
agentId,
|
|
520
|
+
totalRenderTime: data.commitTime,
|
|
521
|
+
componentBreakdown: data.durations.map(([id, duration]) => ({
|
|
522
|
+
component: this.getComponentName(id),
|
|
523
|
+
renderTime: duration,
|
|
524
|
+
percentage: (duration / data.commitTime) * 100
|
|
525
|
+
})),
|
|
526
|
+
slowestComponents: this.findSlowestComponents(data),
|
|
527
|
+
renderCount: data.durations.length,
|
|
528
|
+
recommendations: this.generateOptimizationRecommendations(data)
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
private generateOptimizationRecommendations(
|
|
533
|
+
data: ReactProfilingData
|
|
534
|
+
): Recommendation[] {
|
|
535
|
+
const recommendations: Recommendation[] = [];
|
|
536
|
+
|
|
537
|
+
// Detect unnecessary re-renders
|
|
538
|
+
const unnecessaryRerenders = this.detectUnnecessaryRerenders(data);
|
|
539
|
+
if (unnecessaryRerenders.length > 0) {
|
|
540
|
+
recommendations.push({
|
|
541
|
+
type: 'unnecessary-rerenders',
|
|
542
|
+
severity: 'medium',
|
|
543
|
+
components: unnecessaryRerenders,
|
|
544
|
+
suggestion: 'Add React.memo or useMemo to prevent unnecessary renders'
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// Detect expensive computations
|
|
549
|
+
const expensiveComputations = this.detectExpensiveComputations(data);
|
|
550
|
+
if (expensiveComputations.length > 0) {
|
|
551
|
+
recommendations.push({
|
|
552
|
+
type: 'expensive-computations',
|
|
553
|
+
severity: 'high',
|
|
554
|
+
components: expensiveComputations,
|
|
555
|
+
suggestion: 'Move expensive computations to useMemo or worker threads'
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return recommendations;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
#### **Use Case 3: Real-Time Swarm Monitoring UI**
|
|
567
|
+
|
|
568
|
+
**Scenario**: Live dashboard showing all swarm activity
|
|
569
|
+
|
|
570
|
+
```typescript
|
|
571
|
+
// src/ui/swarm-monitor.tsx
|
|
572
|
+
export const SwarmMonitorUI: React.FC = () => {
|
|
573
|
+
const [swarms, setSwarms] = useState<SwarmState[]>([]);
|
|
574
|
+
const [metrics, setMetrics] = useState<SwarmMetrics>({});
|
|
575
|
+
|
|
576
|
+
useEffect(() => {
|
|
577
|
+
// Enable React DevTools bridge
|
|
578
|
+
if (typeof window !== 'undefined') {
|
|
579
|
+
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
|
|
580
|
+
inject: (renderer) => {
|
|
581
|
+
// Hook into React renderer for swarm components
|
|
582
|
+
this.interceptSwarmComponents(renderer);
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// Subscribe to swarm updates
|
|
588
|
+
const unsubscribe = SwarmCoordinator.subscribeToAll((updates) => {
|
|
589
|
+
setSwarms(updates.swarms);
|
|
590
|
+
setMetrics(updates.metrics);
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
return unsubscribe;
|
|
594
|
+
}, []);
|
|
595
|
+
|
|
596
|
+
return (
|
|
597
|
+
<Box flexDirection="column">
|
|
598
|
+
{/* Header */}
|
|
599
|
+
<Box borderStyle="double" borderColor="green">
|
|
600
|
+
<Text bold color="green">
|
|
601
|
+
🌊 Claude-Flow Swarm Monitor v2.5.0
|
|
602
|
+
</Text>
|
|
603
|
+
</Box>
|
|
604
|
+
|
|
605
|
+
{/* Active Swarms Grid */}
|
|
606
|
+
<Box flexDirection="row" flexWrap="wrap" marginTop={1}>
|
|
607
|
+
{swarms.map((swarm) => (
|
|
608
|
+
<SwarmCard
|
|
609
|
+
key={swarm.id}
|
|
610
|
+
swarm={swarm}
|
|
611
|
+
metrics={metrics[swarm.id]}
|
|
612
|
+
/>
|
|
613
|
+
))}
|
|
614
|
+
</Box>
|
|
615
|
+
|
|
616
|
+
{/* Global Metrics */}
|
|
617
|
+
<Box marginTop={2} borderStyle="single" borderColor="cyan">
|
|
618
|
+
<GlobalMetricsPanel metrics={this.aggregateMetrics(metrics)} />
|
|
619
|
+
</Box>
|
|
620
|
+
|
|
621
|
+
{/* Performance Timeline */}
|
|
622
|
+
<Box marginTop={2}>
|
|
623
|
+
<PerformanceTimeline swarms={swarms} />
|
|
624
|
+
</Box>
|
|
625
|
+
</Box>
|
|
626
|
+
);
|
|
627
|
+
};
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
---
|
|
631
|
+
|
|
632
|
+
## 🔧 Implementation Plan
|
|
633
|
+
|
|
634
|
+
### Phase 1: Network Sandboxing (Week 1)
|
|
635
|
+
1. Create `NetworkPolicyManager` class
|
|
636
|
+
2. Implement per-agent network policies
|
|
637
|
+
3. Add SDK network prompt integration
|
|
638
|
+
4. Create swarm-level network isolation
|
|
639
|
+
5. Build network audit logging
|
|
640
|
+
|
|
641
|
+
### Phase 2: React DevTools Bridge (Week 2)
|
|
642
|
+
1. Set up React DevTools hook integration
|
|
643
|
+
2. Create swarm visualization components
|
|
644
|
+
3. Implement agent profiling system
|
|
645
|
+
4. Build real-time monitoring dashboard
|
|
646
|
+
5. Add performance recommendations
|
|
647
|
+
|
|
648
|
+
### Phase 3: Integration & Testing (Week 3)
|
|
649
|
+
1. Integrate with existing swarm coordinator
|
|
650
|
+
2. Add configuration options
|
|
651
|
+
3. Create comprehensive test suite
|
|
652
|
+
4. Performance benchmarking
|
|
653
|
+
5. Documentation
|
|
654
|
+
|
|
655
|
+
---
|
|
656
|
+
|
|
657
|
+
## 📊 Expected Benefits
|
|
658
|
+
|
|
659
|
+
### Network Sandboxing
|
|
660
|
+
- ✅ **Security**: Prevent unauthorized network access by agents
|
|
661
|
+
- ✅ **Compliance**: Audit trail for all network requests
|
|
662
|
+
- ✅ **Control**: Fine-grained per-agent network policies
|
|
663
|
+
- ✅ **Visibility**: Real-time monitoring of network activity
|
|
664
|
+
|
|
665
|
+
### React DevTools Integration
|
|
666
|
+
- ✅ **Monitoring**: Real-time swarm state visualization
|
|
667
|
+
- ✅ **Debugging**: Component-level agent inspection
|
|
668
|
+
- ✅ **Performance**: Identify bottlenecks in agent execution
|
|
669
|
+
- ✅ **Optimization**: Data-driven performance improvements
|
|
670
|
+
|
|
671
|
+
---
|
|
672
|
+
|
|
673
|
+
## 🎯 Success Metrics
|
|
674
|
+
|
|
675
|
+
| Metric | Target | Measurement |
|
|
676
|
+
|--------|--------|-------------|
|
|
677
|
+
| Network Policy Violations | 0 | Audit log analysis |
|
|
678
|
+
| Dashboard Render Performance | <16ms | React DevTools profiler |
|
|
679
|
+
| Agent Profile Collection Overhead | <5% | Benchmark comparison |
|
|
680
|
+
| Network Request Latency | <2ms added | Performance tests |
|
|
681
|
+
|
|
682
|
+
---
|
|
683
|
+
|
|
684
|
+
## 📝 Configuration Examples
|
|
685
|
+
|
|
686
|
+
### Network Policy Configuration
|
|
687
|
+
```typescript
|
|
688
|
+
// claude-flow.config.ts
|
|
689
|
+
export default {
|
|
690
|
+
swarm: {
|
|
691
|
+
networkPolicies: {
|
|
692
|
+
researcher: {
|
|
693
|
+
allowedHosts: ['*.github.com', '*.stackoverflow.com'],
|
|
694
|
+
defaultBehavior: 'prompt'
|
|
695
|
+
},
|
|
696
|
+
coder: {
|
|
697
|
+
allowedHosts: ['registry.npmjs.org', 'pypi.org'],
|
|
698
|
+
defaultBehavior: 'deny'
|
|
699
|
+
},
|
|
700
|
+
analyst: {
|
|
701
|
+
allowedHosts: [],
|
|
702
|
+
defaultBehavior: 'deny' // Fully sandboxed
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
networkIsolation: {
|
|
706
|
+
mode: 'strict', // 'strict' | 'permissive' | 'audit-only'
|
|
707
|
+
allowedGlobalHosts: ['api.anthropic.com']
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
devTools: {
|
|
711
|
+
enabled: true,
|
|
712
|
+
dashboard: {
|
|
713
|
+
port: 3000,
|
|
714
|
+
enableProfiling: true,
|
|
715
|
+
updateInterval: 1000
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
---
|
|
722
|
+
|
|
723
|
+
*Integration design for Claude-Flow v2.5.0-alpha.130*
|