claude-flow 2.7.34 → 2.7.36
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/CHANGELOG.md +82 -0
- package/bin/claude-flow +1 -1
- package/dist/src/__tests__/benchmarks/performance.bench.js +0 -19
- package/dist/src/__tests__/benchmarks/performance.bench.js.map +1 -1
- package/dist/src/__tests__/hook-matchers.test.js.map +1 -1
- package/dist/src/agents/agent-registry.js.map +1 -1
- package/dist/src/api/auth-service.js.map +1 -1
- package/dist/src/api/claude-client-enhanced.js +4 -2
- package/dist/src/api/claude-client-enhanced.js.map +1 -1
- package/dist/src/api/claude-client.js +4 -2
- package/dist/src/api/claude-client.js.map +1 -1
- package/dist/src/api/database-service.js.map +1 -1
- package/dist/src/api/swarm-api.js +1 -1
- package/dist/src/api/swarm-api.js.map +1 -1
- package/dist/src/cli/commands/hive-mind/wizard.js +1 -1
- package/dist/src/cli/commands/hive-mind/wizard.js.map +1 -1
- package/dist/src/cli/help-formatter.js +0 -5
- package/dist/src/cli/init/index.js +55 -33
- package/dist/src/cli/init/index.js.map +1 -1
- package/dist/src/cli/simple-commands/init/skills-copier.js +1 -1
- package/dist/src/cli/simple-commands/init/skills-copier.js.map +1 -1
- package/dist/src/cli/simple-orchestrator.js +1 -1
- package/dist/src/cli/simple-orchestrator.js.map +1 -1
- package/dist/src/coordination/conflict-resolution.js +1 -1
- package/dist/src/coordination/conflict-resolution.js.map +1 -1
- package/dist/src/coordination/load-balancer.js +1 -1
- package/dist/src/coordination/load-balancer.js.map +1 -1
- package/dist/src/core/DatabaseManager.js +39 -9
- package/dist/src/core/DatabaseManager.js.map +1 -1
- package/dist/src/core/config.js +1 -1
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/enterprise/audit-manager.js +1 -1
- package/dist/src/enterprise/audit-manager.js.map +1 -1
- package/dist/src/providers/openai-provider.js +2 -2
- package/dist/src/providers/openai-provider.js.map +1 -1
- package/dist/src/sdk/checkpoint-manager.js +1 -1
- package/dist/src/sdk/checkpoint-manager.js.map +1 -1
- package/dist/src/services/agentic-flow-hooks/workflow-hooks.js +1 -1
- package/dist/src/services/agentic-flow-hooks/workflow-hooks.js.map +1 -1
- package/dist/src/swarm/coordinator.js +1 -1
- package/dist/src/swarm/coordinator.js.map +1 -1
- package/dist/src/utils/error-recovery.js +215 -0
- package/dist/src/utils/error-recovery.js.map +1 -0
- package/dist/src/utils/key-redactor.js.map +1 -1
- package/dist/src/utils/metrics-reader.js +10 -0
- package/dist/src/verification/rollback.js +2 -2
- package/dist/src/verification/rollback.js.map +1 -1
- package/dist/src/verification/tests/mocks/false-reporting-scenarios.test.js +4 -2
- package/dist/src/verification/tests/mocks/false-reporting-scenarios.test.js.map +1 -1
- package/docs/.claude-flow/metrics/performance.json +3 -3
- package/docs/.claude-flow/metrics/task-metrics.json +3 -3
- package/docs/architecture/README.md +555 -0
- package/docs/architecture/github-workflows-optimization-strategy.md +1079 -0
- package/docs/architecture/workflow-architecture-diagram.md +615 -0
- package/docs/architecture/workflow-optimization-implementation-guide.md +593 -0
- package/docs/features/AUTOMATIC_ERROR_RECOVERY_v2.7.35.md +321 -0
- package/docs/features/automatic-error-recovery.md +333 -0
- package/docs/fixes/WORKFLOW_FIXES.md +292 -0
- package/docs/fixes/WORKFLOW_FIXES_FINAL_STATUS.md +291 -0
- package/docs/fixes/github-workflow-fixes-pr888.md +279 -0
- package/docs/fixes/workflow-fixes-action-plan.md +388 -0
- package/docs/github-issues/README.md +88 -0
- package/docs/github-issues/wsl-enotempty-automatic-recovery.md +470 -0
- package/docs/github-workflow-fixes.md +219 -0
- package/docs/reviews/github-workflows-analysis-report.md +820 -0
- package/docs/reviews/pr-888-review-report.md +560 -0
- package/docs/testing/CONFIRMATION_AUTOMATIC_ERROR_RECOVERY.md +384 -0
- package/docs/testing/DOCKER_TEST_RESULTS_v2.7.35.md +305 -0
- package/docs/troubleshooting/wsl-better-sqlite3-error.md +239 -0
- package/docs/validation/workflow-fix-verification.md +206 -0
- package/package.json +7 -7
- package/scripts/create-github-issue.sh +64 -0
- package/scripts/test-docker-wsl.sh +198 -0
- package/src/__tests__/benchmarks/performance.bench.ts +2 -25
- package/src/__tests__/hook-matchers.test.ts +2 -0
- package/src/agents/agent-registry.ts +1 -1
- package/src/api/auth-service.ts +1 -1
- package/src/api/claude-client-enhanced.ts +2 -1
- package/src/api/claude-client.ts +2 -2
- package/src/api/database-service.ts +1 -2
- package/src/api/swarm-api.ts +2 -2
- package/src/cli/commands/hive-mind/wizard.ts +1 -1
- package/src/cli/init/index.ts +72 -42
- package/src/cli/simple-commands/init/skills-copier.js +1 -1
- package/src/cli/simple-orchestrator.ts +1 -1
- package/src/coordination/conflict-resolution.ts +1 -1
- package/src/coordination/load-balancer.ts +1 -1
- package/src/core/DatabaseManager.ts +55 -9
- package/src/core/config.ts +1 -1
- package/src/enterprise/audit-manager.ts +1 -1
- package/src/providers/openai-provider.ts +2 -2
- package/src/sdk/checkpoint-manager.ts +1 -1
- package/src/services/agentic-flow-hooks/workflow-hooks.ts +1 -1
- package/src/swarm/coordinator.ts +1 -1
- package/src/utils/error-recovery.ts +325 -0
- package/src/verification/rollback.ts +2 -2
- package/src/verification/tests/mocks/false-reporting-scenarios.test.ts +6 -3
- /package/docs/{BUG_REPORT_MEMORY_STATS.md → bug-reports/BUG_REPORT_MEMORY_STATS.md} +0 -0
- /package/docs/{MCP_2025_FEATURE_CONFIRMATION.md → features/MCP_2025_FEATURE_CONFIRMATION.md} +0 -0
- /package/docs/{OPTIONAL_LOCAL_EMBEDDINGS.md → features/OPTIONAL_LOCAL_EMBEDDINGS.md} +0 -0
- /package/docs/{mcp-2025-implementation-summary.md → features/mcp-2025-implementation-summary.md} +0 -0
- /package/docs/{mcp-spec-2025-implementation-plan.md → features/mcp-spec-2025-implementation-plan.md} +0 -0
- /package/docs/{AGENTIC_FLOW_ENABLED_LOG_FIX.md → fixes/AGENTIC_FLOW_ENABLED_LOG_FIX.md} +0 -0
- /package/docs/{MEMORY_COMMAND_FIX.md → fixes/MEMORY_COMMAND_FIX.md} +0 -0
- /package/docs/{NPX_MEMORY_FIX_v2.7.19.md → fixes/NPX_MEMORY_FIX_v2.7.19.md} +0 -0
- /package/docs/{REMOTE_INSTALL_FIX.md → fixes/REMOTE_INSTALL_FIX.md} +0 -0
- /package/docs/{SQLITE_FIX_COMPLETE_v2.7.21.md → fixes/SQLITE_FIX_COMPLETE_v2.7.21.md} +0 -0
- /package/docs/{NPM_PUBLISH_GUIDE_v2.7.33.md → guides/NPM_PUBLISH_GUIDE_v2.7.33.md} +0 -0
- /package/docs/{SWARM_INITIALIZATION_GUIDE.md → guides/SWARM_INITIALIZATION_GUIDE.md} +0 -0
- /package/docs/{AGENTDB_BRANCH_MERGE_VERIFICATION.md → integration/AGENTDB_BRANCH_MERGE_VERIFICATION.md} +0 -0
- /package/docs/{INTEGRATION_STATUS_FINAL.md → integration/INTEGRATION_STATUS_FINAL.md} +0 -0
- /package/docs/{agentic-flow-agentdb-mcp-integration.md → integration/agentic-flow-agentdb-mcp-integration.md} +0 -0
- /package/docs/{phase-1-2-implementation-summary.md → integration/phase-1-2-implementation-summary.md} +0 -0
- /package/docs/{.github-release-issue-v2.7.33.md → releases/.github-release-issue-v2.7.33.md} +0 -0
- /package/docs/{RELEASE_NOTES_v2.7.15.md → releases/RELEASE_NOTES_v2.7.15.md} +0 -0
- /package/docs/{RELEASE_NOTES_v2.7.33.md → releases/RELEASE_NOTES_v2.7.33.md} +0 -0
- /package/docs/{RELEASE_READINESS_SUMMARY.md → releases/RELEASE_READINESS_SUMMARY.md} +0 -0
- /package/docs/{RELEASE_SUMMARY_v2.7.33.md → releases/RELEASE_SUMMARY_v2.7.33.md} +0 -0
- /package/docs/{V2.7.14_RELEASE_NOTES.md → releases/V2.7.14_RELEASE_NOTES.md} +0 -0
- /package/docs/{V2.7.25_RELEASE_NOTES.md → releases/V2.7.25_RELEASE_NOTES.md} +0 -0
- /package/docs/{V2.7.26_RELEASE_SUMMARY.md → releases/V2.7.26_RELEASE_SUMMARY.md} +0 -0
- /package/docs/{V2.7.27_RELEASE_NOTES.md → releases/V2.7.27_RELEASE_NOTES.md} +0 -0
- /package/docs/{V2.7.28_RELEASE_NOTES.md → releases/V2.7.28_RELEASE_NOTES.md} +0 -0
- /package/docs/{AGENTIC_FLOW_INTEGRATION_REVIEW.md → reviews/AGENTIC_FLOW_INTEGRATION_REVIEW.md} +0 -0
- /package/docs/{BRANCH_REVIEW_SUMMARY.md → reviews/BRANCH_REVIEW_SUMMARY.md} +0 -0
- /package/docs/{DEEP_CODE_REVIEW_v2.7.33.md → reviews/DEEP_CODE_REVIEW_v2.7.33.md} +0 -0
- /package/docs/{LATEST_LIBRARIES_REVIEW.md → reviews/LATEST_LIBRARIES_REVIEW.md} +0 -0
- /package/docs/{REGRESSION_TEST_REPORT_v2.7.33.md → testing/REGRESSION_TEST_REPORT_v2.7.33.md} +0 -0
- /package/docs/{V2.7.27_TEST_REPORT.md → testing/V2.7.27_TEST_REPORT.md} +0 -0
- /package/docs/{regression-analysis-phase-1-2.md → testing/regression-analysis-phase-1-2.md} +0 -0
- /package/docs/{TRANSFORMER_INITIALIZATION_ISSUE.md → troubleshooting/TRANSFORMER_INITIALIZATION_ISSUE.md} +0 -0
- /package/docs/{FIX_VERIFICATION_MEMORY_STATS.md → validation/FIX_VERIFICATION_MEMORY_STATS.md} +0 -0
- /package/docs/{TOOL_VALIDATION_REPORT.md → validation/TOOL_VALIDATION_REPORT.md} +0 -0
- /package/docs/{VALIDATION_REPORT_v2.7.1.md → validation/VALIDATION_REPORT_v2.7.1.md} +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Test automatic error recovery in Docker (simulates WSL)
|
|
3
|
+
# Run this before creating GitHub issue
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
echo "🐳 Testing Automatic Error Recovery in Docker"
|
|
8
|
+
echo ""
|
|
9
|
+
|
|
10
|
+
# Colors for output
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
RED='\033[0;31m'
|
|
13
|
+
YELLOW='\033[1;33m'
|
|
14
|
+
NC='\033[0m' # No Color
|
|
15
|
+
|
|
16
|
+
# Test configurations
|
|
17
|
+
DISTROS=("ubuntu:22.04" "ubuntu:20.04" "debian:11" "debian:12")
|
|
18
|
+
TEST_RESULTS=()
|
|
19
|
+
|
|
20
|
+
# Function to test on a distro
|
|
21
|
+
test_distro() {
|
|
22
|
+
local distro=$1
|
|
23
|
+
echo ""
|
|
24
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
25
|
+
echo "Testing on: $distro"
|
|
26
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
27
|
+
echo ""
|
|
28
|
+
|
|
29
|
+
# Run test in Docker
|
|
30
|
+
docker run --rm -i $distro bash -c "
|
|
31
|
+
set -e
|
|
32
|
+
|
|
33
|
+
echo '📦 Installing dependencies...'
|
|
34
|
+
apt-get update -qq
|
|
35
|
+
apt-get install -y -qq curl build-essential python3 git > /dev/null 2>&1
|
|
36
|
+
|
|
37
|
+
echo '📥 Installing Node.js...'
|
|
38
|
+
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - > /dev/null 2>&1
|
|
39
|
+
apt-get install -y -qq nodejs > /dev/null 2>&1
|
|
40
|
+
|
|
41
|
+
echo '🔍 Node version:'
|
|
42
|
+
node --version
|
|
43
|
+
npm --version
|
|
44
|
+
|
|
45
|
+
echo ''
|
|
46
|
+
echo '🚀 Running claude-flow init --force...'
|
|
47
|
+
echo ''
|
|
48
|
+
|
|
49
|
+
# Run the actual test
|
|
50
|
+
npx claude-flow@alpha init --force
|
|
51
|
+
|
|
52
|
+
echo ''
|
|
53
|
+
echo '✅ Test completed successfully on $distro'
|
|
54
|
+
" && {
|
|
55
|
+
echo -e "${GREEN}✅ PASS: $distro${NC}"
|
|
56
|
+
TEST_RESULTS+=("PASS: $distro")
|
|
57
|
+
} || {
|
|
58
|
+
echo -e "${RED}❌ FAIL: $distro${NC}"
|
|
59
|
+
TEST_RESULTS+=("FAIL: $distro")
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# Function to test with corrupted cache simulation
|
|
64
|
+
test_corrupted_cache() {
|
|
65
|
+
echo ""
|
|
66
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
67
|
+
echo "Testing with corrupted npm cache simulation"
|
|
68
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
69
|
+
echo ""
|
|
70
|
+
|
|
71
|
+
docker run --rm -i ubuntu:22.04 bash -c "
|
|
72
|
+
set -e
|
|
73
|
+
|
|
74
|
+
apt-get update -qq
|
|
75
|
+
apt-get install -y -qq curl build-essential python3 git > /dev/null 2>&1
|
|
76
|
+
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - > /dev/null 2>&1
|
|
77
|
+
apt-get install -y -qq nodejs > /dev/null 2>&1
|
|
78
|
+
|
|
79
|
+
echo '💥 Simulating corrupted npm cache...'
|
|
80
|
+
mkdir -p ~/.npm/_npx/test-corrupt/node_modules/better-sqlite3
|
|
81
|
+
touch ~/.npm/_npx/test-corrupt/node_modules/better-sqlite3/.lock
|
|
82
|
+
|
|
83
|
+
echo ''
|
|
84
|
+
echo '🚀 Running claude-flow init --force with corrupted cache...'
|
|
85
|
+
echo ''
|
|
86
|
+
|
|
87
|
+
npx claude-flow@alpha init --force
|
|
88
|
+
|
|
89
|
+
echo ''
|
|
90
|
+
echo '✅ Recovery from corrupted cache successful'
|
|
91
|
+
" && {
|
|
92
|
+
echo -e "${GREEN}✅ PASS: Corrupted cache recovery${NC}"
|
|
93
|
+
TEST_RESULTS+=("PASS: Corrupted cache recovery")
|
|
94
|
+
} || {
|
|
95
|
+
echo -e "${RED}❌ FAIL: Corrupted cache recovery${NC}"
|
|
96
|
+
TEST_RESULTS+=("FAIL: Corrupted cache recovery")
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# Function to test without --force flag
|
|
101
|
+
test_without_force() {
|
|
102
|
+
echo ""
|
|
103
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
104
|
+
echo "Testing without --force flag (3 retries max)"
|
|
105
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
106
|
+
echo ""
|
|
107
|
+
|
|
108
|
+
docker run --rm -i ubuntu:22.04 bash -c "
|
|
109
|
+
set -e
|
|
110
|
+
|
|
111
|
+
apt-get update -qq
|
|
112
|
+
apt-get install -y -qq curl build-essential python3 git > /dev/null 2>&1
|
|
113
|
+
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - > /dev/null 2>&1
|
|
114
|
+
apt-get install -y -qq nodejs > /dev/null 2>&1
|
|
115
|
+
|
|
116
|
+
echo '🚀 Running claude-flow init (no --force)...'
|
|
117
|
+
echo ''
|
|
118
|
+
|
|
119
|
+
npx claude-flow@alpha init
|
|
120
|
+
|
|
121
|
+
echo ''
|
|
122
|
+
echo '✅ Init without --force successful'
|
|
123
|
+
" && {
|
|
124
|
+
echo -e "${GREEN}✅ PASS: Init without --force${NC}"
|
|
125
|
+
TEST_RESULTS+=("PASS: Init without --force")
|
|
126
|
+
} || {
|
|
127
|
+
echo -e "${RED}❌ FAIL: Init without --force${NC}"
|
|
128
|
+
TEST_RESULTS+=("FAIL: Init without --force")
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# Main test execution
|
|
133
|
+
echo "Starting comprehensive Docker tests..."
|
|
134
|
+
echo ""
|
|
135
|
+
echo "This will test:"
|
|
136
|
+
echo " - Multiple Linux distributions"
|
|
137
|
+
echo " - Corrupted cache recovery"
|
|
138
|
+
echo " - With and without --force flag"
|
|
139
|
+
echo ""
|
|
140
|
+
|
|
141
|
+
read -p "Continue? (y/n) " -n 1 -r
|
|
142
|
+
echo ""
|
|
143
|
+
|
|
144
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
145
|
+
echo "Aborted"
|
|
146
|
+
exit 1
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
# Run tests
|
|
150
|
+
for distro in "${DISTROS[@]}"; do
|
|
151
|
+
test_distro "$distro"
|
|
152
|
+
done
|
|
153
|
+
|
|
154
|
+
test_corrupted_cache
|
|
155
|
+
test_without_force
|
|
156
|
+
|
|
157
|
+
# Print summary
|
|
158
|
+
echo ""
|
|
159
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
160
|
+
echo "TEST SUMMARY"
|
|
161
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
162
|
+
echo ""
|
|
163
|
+
|
|
164
|
+
PASS_COUNT=0
|
|
165
|
+
FAIL_COUNT=0
|
|
166
|
+
|
|
167
|
+
for result in "${TEST_RESULTS[@]}"; do
|
|
168
|
+
if [[ $result == PASS* ]]; then
|
|
169
|
+
echo -e "${GREEN}✅ $result${NC}"
|
|
170
|
+
((PASS_COUNT++))
|
|
171
|
+
else
|
|
172
|
+
echo -e "${RED}❌ $result${NC}"
|
|
173
|
+
((FAIL_COUNT++))
|
|
174
|
+
fi
|
|
175
|
+
done
|
|
176
|
+
|
|
177
|
+
echo ""
|
|
178
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
179
|
+
echo "Total: $((PASS_COUNT + FAIL_COUNT)) tests"
|
|
180
|
+
echo -e "${GREEN}Passed: $PASS_COUNT${NC}"
|
|
181
|
+
echo -e "${RED}Failed: $FAIL_COUNT${NC}"
|
|
182
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
183
|
+
echo ""
|
|
184
|
+
|
|
185
|
+
if [ $FAIL_COUNT -eq 0 ]; then
|
|
186
|
+
echo -e "${GREEN}✅ All tests passed!${NC}"
|
|
187
|
+
echo ""
|
|
188
|
+
echo "Next steps:"
|
|
189
|
+
echo "1. Review test results above"
|
|
190
|
+
echo "2. Run: bash scripts/create-github-issue.sh"
|
|
191
|
+
echo "3. Update issue with test results"
|
|
192
|
+
exit 0
|
|
193
|
+
else
|
|
194
|
+
echo -e "${RED}❌ Some tests failed${NC}"
|
|
195
|
+
echo ""
|
|
196
|
+
echo "Please fix failing tests before creating GitHub issue"
|
|
197
|
+
exit 1
|
|
198
|
+
fi
|
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
* Benchmarks session forking, hook matchers, and in-process MCP
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/* eslint-disable no-console */
|
|
9
|
+
|
|
8
10
|
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
|
9
11
|
import { performance } from 'perf_hooks';
|
|
10
|
-
import { ClaudeFlowSDKAdapter } from '../../sdk/sdk-config.js';
|
|
11
|
-
import { TaskExecutorSDK } from '../../swarm/executor-sdk.js';
|
|
12
|
-
import { ClaudeClientV25 } from '../../api/claude-client-v2.5.js';
|
|
13
12
|
|
|
14
13
|
interface BenchmarkResult {
|
|
15
14
|
name: string;
|
|
@@ -89,31 +88,9 @@ class PerformanceBenchmark {
|
|
|
89
88
|
|
|
90
89
|
describe('Performance Benchmarks', () => {
|
|
91
90
|
let benchmark: PerformanceBenchmark;
|
|
92
|
-
let adapter: ClaudeFlowSDKAdapter;
|
|
93
|
-
let executor: TaskExecutorSDK;
|
|
94
|
-
let client: ClaudeClientV25;
|
|
95
91
|
|
|
96
92
|
beforeAll(() => {
|
|
97
93
|
benchmark = new PerformanceBenchmark();
|
|
98
|
-
|
|
99
|
-
adapter = new ClaudeFlowSDKAdapter({
|
|
100
|
-
apiKey: 'test-api-key',
|
|
101
|
-
swarmMode: true,
|
|
102
|
-
persistenceEnabled: true,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
executor = new TaskExecutorSDK({
|
|
106
|
-
apiKey: 'test-api-key',
|
|
107
|
-
swarmMode: true,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
client = new ClaudeClientV25(
|
|
111
|
-
{
|
|
112
|
-
apiKey: 'test-api-key',
|
|
113
|
-
enableSwarmMode: true,
|
|
114
|
-
},
|
|
115
|
-
undefined
|
|
116
|
-
);
|
|
117
94
|
});
|
|
118
95
|
|
|
119
96
|
afterAll(() => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { DistributedMemorySystem } from '../memory/distributed-memory.js';
|
|
7
|
-
import type { AgentState,
|
|
7
|
+
import type { AgentState, AgentType, AgentStatus } from '../swarm/types.js';
|
|
8
8
|
import { EventEmitter } from 'node:events';
|
|
9
9
|
|
|
10
10
|
export interface AgentRegistryEntry {
|
package/src/api/auth-service.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ILogger } from '../core/logger.js';
|
|
7
|
-
import { AuthenticationError
|
|
7
|
+
import { AuthenticationError } from '../utils/errors.js';
|
|
8
8
|
import { nanoid } from 'nanoid';
|
|
9
9
|
import { createHash, createHmac, timingSafeEqual } from 'crypto';
|
|
10
10
|
|
|
@@ -483,9 +483,10 @@ export class EnhancedClaudeAPIClient extends EventEmitter {
|
|
|
483
483
|
case 401:
|
|
484
484
|
case 403:
|
|
485
485
|
return new ClaudeAuthenticationError(message, errorData);
|
|
486
|
-
case 429:
|
|
486
|
+
case 429: {
|
|
487
487
|
const retryAfter = errorData.error?.retry_after;
|
|
488
488
|
return new ClaudeRateLimitError(message, retryAfter, errorData);
|
|
489
|
+
}
|
|
489
490
|
case 500:
|
|
490
491
|
return new ClaudeInternalServerError(message, errorData);
|
|
491
492
|
case 503:
|
package/src/api/claude-client.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { EventEmitter } from 'events';
|
|
7
7
|
import { ILogger } from '../core/logger.js';
|
|
8
8
|
import { ConfigManager } from '../config/config-manager.js';
|
|
9
|
-
import { getErrorMessage } from '../utils/error-handler.js';
|
|
10
9
|
import {
|
|
11
10
|
ClaudeAPIError,
|
|
12
11
|
ClaudeInternalServerError,
|
|
@@ -655,9 +654,10 @@ export class ClaudeAPIClient extends EventEmitter {
|
|
|
655
654
|
case 401:
|
|
656
655
|
case 403:
|
|
657
656
|
return new ClaudeAuthenticationError(message, errorData);
|
|
658
|
-
case 429:
|
|
657
|
+
case 429: {
|
|
659
658
|
const retryAfter = errorData.error?.retry_after;
|
|
660
659
|
return new ClaudeRateLimitError(message, retryAfter, errorData);
|
|
660
|
+
}
|
|
661
661
|
case 500:
|
|
662
662
|
return new ClaudeInternalServerError(message, errorData);
|
|
663
663
|
case 503:
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ILogger } from '../core/logger.js';
|
|
7
|
-
import {
|
|
8
|
-
import { SwarmError, DatabaseError } from '../utils/errors.js';
|
|
7
|
+
import { DatabaseError } from '../utils/errors.js';
|
|
9
8
|
import { nanoid } from 'nanoid';
|
|
10
9
|
|
|
11
10
|
export interface DatabaseConfig {
|
package/src/api/swarm-api.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { ICoordinationManager } from '../coordination/manager.js';
|
|
|
11
11
|
import { SwarmCoordinator } from '../swarm/coordinator.js';
|
|
12
12
|
import { AgentManager } from '../agents/agent-manager.js';
|
|
13
13
|
import { ResourceManager } from '../resources/resource-manager.js';
|
|
14
|
-
import {
|
|
14
|
+
import { SwarmConfig } from '../utils/types.js';
|
|
15
15
|
import { ValidationError, SwarmError } from '../utils/errors.js';
|
|
16
16
|
import { nanoid } from 'nanoid';
|
|
17
17
|
|
|
@@ -123,7 +123,7 @@ export class SwarmApi {
|
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
// Error handling
|
|
126
|
-
this.router.use((err: Error, req: any, res: any,
|
|
126
|
+
this.router.use((err: Error, req: any, res: any, _next: any) => {
|
|
127
127
|
this.logger.error('Swarm API error', {
|
|
128
128
|
error: err.message,
|
|
129
129
|
stack: err.stack,
|
package/src/cli/init/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { createSwarmCommands } from './swarm-commands.js';
|
|
|
5
5
|
import { createSparcEnvironment } from './sparc-environment.js';
|
|
6
6
|
import { createClaudeConfig } from './claude-config.js';
|
|
7
7
|
import { createBatchToolsGuide } from './batch-tools.js';
|
|
8
|
+
import { errorRecovery } from '../../utils/error-recovery.js';
|
|
8
9
|
|
|
9
10
|
export interface InitOptions {
|
|
10
11
|
sparc?: boolean;
|
|
@@ -12,56 +13,85 @@ export interface InitOptions {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export async function initCommand(options: InitOptions = {}) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// Wrap entire initialization in retry logic with automatic recovery
|
|
17
|
+
return errorRecovery.retryWithRecovery(
|
|
18
|
+
async () => {
|
|
19
|
+
try {
|
|
20
|
+
const fs = await import('fs/promises');
|
|
21
|
+
const path = await import('path');
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
printSuccess('Initializing Claude-Flow project...');
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
// Check WSL environment and apply fixes proactively
|
|
26
|
+
if (errorRecovery.isWSL()) {
|
|
27
|
+
console.log('🔍 WSL environment detected');
|
|
28
|
+
const wslCheck = await errorRecovery.recoverWSLErrors();
|
|
29
|
+
if (wslCheck.recovered) {
|
|
30
|
+
console.log('✅ WSL environment optimized\n');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
// Phase 1: Create directory structure
|
|
35
|
+
console.log('\n📁 Phase 1: Creating directory structure...');
|
|
36
|
+
await createDirectoryStructure();
|
|
28
37
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
// Phase 2: Create base configuration
|
|
39
|
+
console.log('\n⚙️ Phase 2: Creating configuration...');
|
|
40
|
+
await createClaudeConfig(options);
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
// Phase 3: Create swarm commands and documentation
|
|
43
|
+
console.log('\n🤖 Phase 3: Creating swarm commands...');
|
|
44
|
+
await createSwarmCommands();
|
|
36
45
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
// Phase 4: Create batch tools guides
|
|
47
|
+
console.log('\n🔧 Phase 4: Creating batch tools guides...');
|
|
48
|
+
await createBatchToolsGuide();
|
|
49
|
+
|
|
50
|
+
// Phase 5: SPARC environment (if requested)
|
|
51
|
+
if (options.sparc) {
|
|
52
|
+
console.log('\n🚀 Phase 5: Creating SPARC environment...');
|
|
53
|
+
await createSparcEnvironment();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Success summary
|
|
57
|
+
console.log('\n🎉 Project initialized successfully!');
|
|
58
|
+
console.log(' 📁 Created .claude/ directory structure');
|
|
59
|
+
console.log(' 📋 Created comprehensive swarm command documentation');
|
|
60
|
+
console.log(' 🔧 Created batch tools coordination guides');
|
|
61
|
+
console.log(' 📖 Created detailed usage examples with orchestration');
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log(' 📖 Created detailed usage examples with orchestration');
|
|
63
|
+
console.log('\n Next steps:');
|
|
64
|
+
console.log(' 1. Run "claude-flow swarm --help" to see swarm options');
|
|
65
|
+
console.log(' 2. Check .claude/commands/swarm/ for detailed documentation');
|
|
66
|
+
console.log(' 3. Review batch tools guide for orchestration patterns');
|
|
67
|
+
console.log(' 4. Run "claude-flow help" for all available commands');
|
|
49
68
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
if (options.sparc) {
|
|
70
|
+
console.log(' 5. Run "claude-flow sparc modes" to see available SPARC modes');
|
|
71
|
+
console.log(' 6. Use TodoWrite/TodoRead for task coordination');
|
|
72
|
+
console.log(' 7. Use Task tool for parallel agent execution');
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
// Attempt automatic error recovery
|
|
76
|
+
const recovery = await errorRecovery.recoverInitErrors(error);
|
|
55
77
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
if (recovery.recovered) {
|
|
79
|
+
console.log('✅ Recovered from error, retrying initialization...\n');
|
|
80
|
+
throw error; // Trigger retry
|
|
81
|
+
} else {
|
|
82
|
+
printError(
|
|
83
|
+
`Failed to initialize project: ${error instanceof Error ? error.message : String(error)}`,
|
|
84
|
+
);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
maxRetries: options.force ? 5 : 3,
|
|
91
|
+
delay: 1000,
|
|
92
|
+
onRetry: (attempt, error) => {
|
|
93
|
+
console.log(`\n🔄 Retry attempt ${attempt} after error recovery...`);
|
|
94
|
+
}
|
|
60
95
|
}
|
|
61
|
-
|
|
62
|
-
printError(
|
|
63
|
-
`Failed to initialize project: ${error instanceof Error ? error.message : String(error)}`,
|
|
64
|
-
);
|
|
65
|
-
throw error;
|
|
66
|
-
}
|
|
96
|
+
);
|
|
67
97
|
}
|
|
@@ -12,7 +12,7 @@ const __dirname = dirname(__filename);
|
|
|
12
12
|
export async function copySkillFiles(targetDir, options = {}) {
|
|
13
13
|
console.log(' 🚀 copySkillFiles function called');
|
|
14
14
|
console.log(` 📂 Target directory: ${targetDir}`);
|
|
15
|
-
console.log(` ⚙️ Options
|
|
15
|
+
console.log(` ⚙️ Options: { force: ${options.force || 'false'}, dryRun: ${options.dryRun || 'false'} }`);
|
|
16
16
|
console.log(` 📍 __dirname: ${__dirname}`);
|
|
17
17
|
|
|
18
18
|
const { force = false, dryRun = false } = options;
|
|
@@ -277,7 +277,7 @@ export class ConflictResolver {
|
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
// Build context based on conflict type
|
|
280
|
-
|
|
280
|
+
const context: any = {};
|
|
281
281
|
|
|
282
282
|
if (preferredStrategy === 'priority') {
|
|
283
283
|
// In a real implementation, fetch agent priorities from configuration
|
|
@@ -228,7 +228,7 @@ export class LoadBalancer extends EventEmitter {
|
|
|
228
228
|
|
|
229
229
|
try {
|
|
230
230
|
// Filter agents based on constraints
|
|
231
|
-
|
|
231
|
+
const candidates = this.filterAgentsByConstraints(availableAgents, task, constraints);
|
|
232
232
|
|
|
233
233
|
if (candidates.length === 0) {
|
|
234
234
|
throw new Error('No suitable agents available for task');
|
|
@@ -12,6 +12,8 @@ export class DatabaseManager implements IDatabaseProvider {
|
|
|
12
12
|
private dbType: 'sqlite' | 'json';
|
|
13
13
|
private dbPath: string;
|
|
14
14
|
private initialized: boolean = false;
|
|
15
|
+
private retryCount: number = 0;
|
|
16
|
+
private maxRetries: number = 3;
|
|
15
17
|
|
|
16
18
|
constructor(dbType: 'sqlite' | 'json' = 'sqlite', dbPath?: string) {
|
|
17
19
|
this.dbType = dbType;
|
|
@@ -19,18 +21,36 @@ export class DatabaseManager implements IDatabaseProvider {
|
|
|
19
21
|
|
|
20
22
|
// Try SQLite first, fallback to JSON if needed
|
|
21
23
|
if (this.dbType === 'sqlite') {
|
|
22
|
-
|
|
23
|
-
this.provider = new SQLiteProvider(this.dbPath);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.warn('SQLite not available, falling back to JSON storage:', error);
|
|
26
|
-
this.provider = new JSONProvider(this.dbPath.replace('.sqlite', '.json'));
|
|
27
|
-
this.dbType = 'json';
|
|
28
|
-
}
|
|
24
|
+
this.provider = this.initializeSQLiteWithRecovery();
|
|
29
25
|
} else {
|
|
30
26
|
this.provider = new JSONProvider(this.dbPath);
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Initialize SQLite with automatic error recovery
|
|
32
|
+
*/
|
|
33
|
+
private initializeSQLiteWithRecovery(): IDatabaseProvider {
|
|
34
|
+
try {
|
|
35
|
+
return new SQLiteProvider(this.dbPath);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
38
|
+
|
|
39
|
+
// Check if it's an npm cache error
|
|
40
|
+
if (errorMsg.includes('ENOTEMPTY') || errorMsg.includes('better-sqlite3')) {
|
|
41
|
+
console.warn('⚠️ SQLite initialization failed due to npm cache error');
|
|
42
|
+
console.warn(' Will attempt automatic recovery during initialize()');
|
|
43
|
+
} else {
|
|
44
|
+
console.warn('SQLite not available, falling back to JSON storage:', error);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Fallback to JSON for now
|
|
48
|
+
this.provider = new JSONProvider(this.dbPath.replace('.sqlite', '.json'));
|
|
49
|
+
this.dbType = 'json';
|
|
50
|
+
return this.provider;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
private getDefaultPath(): string {
|
|
35
55
|
const baseDir = path.join(process.cwd(), '.claude-flow');
|
|
36
56
|
return this.dbType === 'sqlite'
|
|
@@ -40,8 +60,34 @@ export class DatabaseManager implements IDatabaseProvider {
|
|
|
40
60
|
|
|
41
61
|
async initialize(): Promise<void> {
|
|
42
62
|
await fs.ensureDir(path.dirname(this.dbPath));
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
await this.provider.initialize();
|
|
66
|
+
this.initialized = true;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
// If JSON provider failed, just propagate the error
|
|
69
|
+
if (this.dbType === 'json') {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// For SQLite errors, attempt recovery
|
|
74
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
75
|
+
if (this.retryCount < this.maxRetries) {
|
|
76
|
+
console.warn(`⚠️ Database initialization failed (attempt ${this.retryCount + 1}/${this.maxRetries})`);
|
|
77
|
+
console.warn(` Error: ${errorMsg}`);
|
|
78
|
+
|
|
79
|
+
// Attempt to recover by switching to JSON
|
|
80
|
+
console.log('🔄 Switching to JSON storage as fallback...');
|
|
81
|
+
this.provider = new JSONProvider(this.dbPath.replace('.sqlite', '.json'));
|
|
82
|
+
this.dbType = 'json';
|
|
83
|
+
this.retryCount++;
|
|
84
|
+
|
|
85
|
+
// Retry initialization with JSON provider
|
|
86
|
+
await this.initialize();
|
|
87
|
+
} else {
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
45
91
|
}
|
|
46
92
|
|
|
47
93
|
async store(key: string, value: any, namespace: string = 'default'): Promise<void> {
|
package/src/core/config.ts
CHANGED
|
@@ -81,7 +81,7 @@ const FORMAT_PARSERS: Record<string, FormatParser> = {
|
|
|
81
81
|
// Simple YAML parser for basic key-value pairs
|
|
82
82
|
const lines = content.split('\n');
|
|
83
83
|
const result: any = {};
|
|
84
|
-
|
|
84
|
+
const current = result;
|
|
85
85
|
const stack: any[] = [result];
|
|
86
86
|
|
|
87
87
|
for (const line of lines) {
|
|
@@ -728,7 +728,7 @@ export class AuditManager extends EventEmitter {
|
|
|
728
728
|
let totalEntries = 0;
|
|
729
729
|
let verifiedEntries = 0;
|
|
730
730
|
let corruptedEntries = 0;
|
|
731
|
-
|
|
731
|
+
const missingEntries = 0;
|
|
732
732
|
|
|
733
733
|
const trails = trailId
|
|
734
734
|
? ([this.auditTrails.get(trailId)].filter(Boolean) as AuditTrail[])
|
|
@@ -292,8 +292,8 @@ export class OpenAIProvider extends BaseProvider {
|
|
|
292
292
|
const reader = response.body!.getReader();
|
|
293
293
|
const decoder = new TextDecoder();
|
|
294
294
|
let buffer = '';
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
const totalPromptTokens = 0;
|
|
296
|
+
const totalCompletionTokens = 0;
|
|
297
297
|
|
|
298
298
|
while (true) {
|
|
299
299
|
const { done, value } = await reader.read();
|
|
@@ -70,7 +70,7 @@ export class RealCheckpointManager extends EventEmitter {
|
|
|
70
70
|
queryGenerator: Query,
|
|
71
71
|
autoCheckpoint: boolean = false
|
|
72
72
|
): Promise<void> {
|
|
73
|
-
|
|
73
|
+
const messages = this.sessionMessages.get(sessionId) || [];
|
|
74
74
|
this.sessionMessages.set(sessionId, messages);
|
|
75
75
|
|
|
76
76
|
let messageCount = this.messageCounters.get(sessionId) || 0;
|