claude-flow-novice 2.15.2 → 2.15.3
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/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/.claude/hooks/cfn-invoke-security-validation.sh +69 -69
- package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/.claude/hooks/cfn-post-edit.config.json +44 -44
- package/.claude/skills/agent-lifecycle/SKILL.md +60 -0
- package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +573 -0
- package/.claude/skills/agent-lifecycle/simple-audit.sh +31 -0
- package/.claude/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/.claude/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/.claude/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/claude-assets/hooks/cfn-invoke-security-validation.sh +69 -69
- package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/claude-assets/hooks/cfn-post-edit.config.json +44 -44
- package/claude-assets/hooks/cfn-post-execution/memory-cleanup.sh +19 -19
- package/claude-assets/hooks/cfn-pre-execution/memory-check.sh +19 -19
- package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +572 -572
- package/claude-assets/skills/agent-lifecycle/simple-audit.sh +30 -30
- package/claude-assets/skills/cfn-automatic-memory-persistence/persist-agent-output.sh +48 -48
- package/claude-assets/skills/cfn-automatic-memory-persistence/query-agent-history.sh +34 -34
- package/claude-assets/skills/cfn-deliverable-validation/confidence-calculator.sh +261 -261
- package/claude-assets/skills/cfn-expert-update/update-expert.sh +345 -345
- package/claude-assets/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/claude-assets/skills/cfn-intervention-detector/detect-intervention.sh +110 -110
- package/claude-assets/skills/cfn-intervention-orchestrator/execute-intervention.sh +58 -58
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/claude-assets/skills/cfn-loop2-output-processing/process-validator-output.sh +275 -275
- package/claude-assets/skills/cfn-memory-management/check-memory.sh +159 -159
- package/claude-assets/skills/cfn-memory-management/cleanup-memory.sh +196 -196
- package/claude-assets/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +325 -325
- package/claude-assets/skills/cfn-playbook-auto-update/auto-update-playbook.sh +85 -85
- package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/claude-assets/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/claude-assets/skills/cfn-scope-simplifier/simplify-scope.sh +67 -67
- package/claude-assets/skills/cfn-specialist-injection/recommend-specialist.sh +56 -56
- package/claude-assets/skills/cfn-standardized-error-handling/capture-agent-error.sh +86 -86
- package/claude-assets/skills/cfn-standardized-error-handling/test-error-handling.sh +165 -165
- package/claude-assets/skills/cfn-task-config-init/initialize-config.sh +264 -264
- package/claude-assets/skills/cfn-task-decomposition/task-decomposer.sh +278 -278
- package/claude-assets/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/claude-assets/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/claude-assets/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/claude-assets/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/claude-assets/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/skills/docker-build/SKILL.md +96 -203
- package/claude-assets/skills/docker-build/build.sh +73 -73
- package/claude-assets/skills/integration/agent-handoff.sh +494 -0
- package/claude-assets/skills/integration/file-operations.sh +414 -0
- package/claude-assets/skills/workflow-codification/APPROVAL_WORKFLOW.md +806 -0
- package/claude-assets/skills/workflow-codification/COST_TRACKING.md +637 -0
- package/claude-assets/skills/workflow-codification/EDGE_CASE_TRACKING.md +404 -0
- package/claude-assets/skills/workflow-codification/README_PHASE4.md +457 -0
- package/claude-assets/skills/workflow-codification/SKILL.md +110 -0
- package/claude-assets/skills/workflow-codification/analyze-patterns.sh +899 -0
- package/claude-assets/skills/workflow-codification/approval-workflow.sh +514 -0
- package/claude-assets/skills/workflow-codification/generate-skill-update.sh +525 -0
- package/claude-assets/skills/workflow-codification/review-skill.sh +643 -0
- package/claude-assets/skills/workflow-codification/templates/email-notification.txt +114 -0
- package/claude-assets/skills/workflow-codification/templates/slack-notification.md +85 -0
- package/claude-assets/skills/workflow-codification/test-integration.sh +281 -0
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh +445 -0
- package/claude-assets/skills/workflow-codification/track-edge-case.sh +323 -0
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/integration/DatabaseHandoff.js +507 -0
- package/dist/integration/DatabaseHandoff.js.map +1 -0
- package/dist/integration/StandardAdapter.js +291 -0
- package/dist/integration/StandardAdapter.js.map +1 -0
- package/dist/lib/agent-output-parser.js +518 -0
- package/dist/lib/agent-output-parser.js.map +1 -0
- package/dist/lib/agent-output-validator.js +950 -0
- package/dist/lib/agent-output-validator.js.map +1 -0
- package/dist/lib/artifact-registry.js +443 -0
- package/dist/lib/artifact-registry.js.map +1 -0
- package/dist/lib/config-validator.js +687 -0
- package/dist/lib/config-validator.js.map +1 -0
- package/dist/types/agent-output.js +44 -0
- package/dist/types/agent-output.js.map +1 -0
- package/dist/types/config.js +28 -0
- package/dist/types/config.js.map +1 -0
- package/package.json +2 -1
- package/scripts/artifact-cleanup.sh +392 -0
- package/scripts/deploy-production.sh +355 -355
- package/scripts/docker-playwright-fix.sh +311 -311
- package/scripts/docker-rebuild-all-agents.sh +127 -127
- package/scripts/memory-leak-prevention.sh +305 -305
- package/scripts/migrate-artifacts.sh +563 -0
- package/scripts/migrate-yaml-to-json.sh +465 -0
- package/scripts/run-marketing-tests.sh +42 -42
- package/scripts/update_paths.sh +46 -46
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Input Validation and Security Test Suite
|
|
3
|
-
# Validates input handling and prevents potential injection scenarios
|
|
4
|
-
|
|
5
|
-
set -euo pipefail
|
|
6
|
-
|
|
7
|
-
# Source the main script to access validation functions
|
|
8
|
-
source "$(dirname "$0")/.claude/skills/cfn-cfn-test-integration.sh"
|
|
9
|
-
|
|
10
|
-
# Test Cases for validate_input function
|
|
11
|
-
test_input_validation() {
|
|
12
|
-
local test_cases=(
|
|
13
|
-
"valid_task_id:integration-test-task:task_id:pass"
|
|
14
|
-
"valid_agent_id:test-agent-1:agent_id:pass"
|
|
15
|
-
"invalid_task_id_with_space:test task:task_id:fail"
|
|
16
|
-
"invalid_task_id_with_special_chars:test@task:task_id:fail"
|
|
17
|
-
"invalid_agent_id_with_special_chars:test!agent:agent_id:fail"
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
for test_case in "${test_cases[@]}"; do
|
|
21
|
-
local name=$(echo "$test_case" | cut -d: -f1)
|
|
22
|
-
local input=$(echo "$test_case" | cut -d: -f2)
|
|
23
|
-
local input_type=$(echo "$test_case" | cut -d: -f3)
|
|
24
|
-
local expected=$(echo "$test_case" | cut -d: -f4)
|
|
25
|
-
|
|
26
|
-
echo "Running test case: $name"
|
|
27
|
-
|
|
28
|
-
if [[ "$expected" == "pass" ]]; then
|
|
29
|
-
validate_input "$input" "$input_type"
|
|
30
|
-
echo "✅ PASS: $name - Successfully validated"
|
|
31
|
-
else
|
|
32
|
-
set +e
|
|
33
|
-
validate_input "$input" "$input_type" 2>/dev/null
|
|
34
|
-
local exit_code=$?
|
|
35
|
-
set -e
|
|
36
|
-
|
|
37
|
-
if [ "$exit_code" -ne 0 ]; then
|
|
38
|
-
echo "✅ PASS: $name - Correctly rejected invalid input"
|
|
39
|
-
else
|
|
40
|
-
echo "❌ FAIL: $name - Failed to reject invalid input"
|
|
41
|
-
exit 1
|
|
42
|
-
fi
|
|
43
|
-
fi
|
|
44
|
-
done
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
# Test SQLite Query Safety
|
|
48
|
-
test_sqlite_query_safety() {
|
|
49
|
-
local db_file=$(mktemp)
|
|
50
|
-
local bad_input="'; DROP TABLE agent_memory; --"
|
|
51
|
-
|
|
52
|
-
# Setup test database
|
|
53
|
-
sqlite3 "$db_file" <<EOF
|
|
54
|
-
CREATE TABLE agent_memory (
|
|
55
|
-
task_id TEXT,
|
|
56
|
-
event_data TEXT
|
|
57
|
-
);
|
|
58
|
-
INSERT INTO agent_memory VALUES ('test-task', 'sample data');
|
|
59
|
-
EOF
|
|
60
|
-
|
|
61
|
-
# Attempt query with malicious input
|
|
62
|
-
set +e
|
|
63
|
-
local query_result=$(sqlite3 "$db_file" \
|
|
64
|
-
"SELECT COUNT(*) FROM agent_memory WHERE task_id = '$bad_input';" 2>/dev/null)
|
|
65
|
-
local exit_code=$?
|
|
66
|
-
set -e
|
|
67
|
-
|
|
68
|
-
# Verify query did not modify the database
|
|
69
|
-
local row_count=$(sqlite3 "$db_file" "SELECT COUNT(*) FROM agent_memory;")
|
|
70
|
-
|
|
71
|
-
if [ "$row_count" -eq 1 ] && [ "$exit_code" -eq 0 ]; then
|
|
72
|
-
echo "✅ PASS: SQLite query safety - Malicious input contained"
|
|
73
|
-
else
|
|
74
|
-
echo "❌ FAIL: SQLite query safety - Potential vulnerability"
|
|
75
|
-
exit 1
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
# Cleanup
|
|
79
|
-
rm -f "$db_file"
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
# Main test runner
|
|
83
|
-
main() {
|
|
84
|
-
echo "=== Input Validation Security Tests ==="
|
|
85
|
-
|
|
86
|
-
test_input_validation
|
|
87
|
-
test_sqlite_query_safety
|
|
88
|
-
|
|
89
|
-
echo "=== All Security Tests Passed ==="
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
# Run tests
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Input Validation and Security Test Suite
|
|
3
|
+
# Validates input handling and prevents potential injection scenarios
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
# Source the main script to access validation functions
|
|
8
|
+
source "$(dirname "$0")/.claude/skills/cfn-cfn-test-integration.sh"
|
|
9
|
+
|
|
10
|
+
# Test Cases for validate_input function
|
|
11
|
+
test_input_validation() {
|
|
12
|
+
local test_cases=(
|
|
13
|
+
"valid_task_id:integration-test-task:task_id:pass"
|
|
14
|
+
"valid_agent_id:test-agent-1:agent_id:pass"
|
|
15
|
+
"invalid_task_id_with_space:test task:task_id:fail"
|
|
16
|
+
"invalid_task_id_with_special_chars:test@task:task_id:fail"
|
|
17
|
+
"invalid_agent_id_with_special_chars:test!agent:agent_id:fail"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
for test_case in "${test_cases[@]}"; do
|
|
21
|
+
local name=$(echo "$test_case" | cut -d: -f1)
|
|
22
|
+
local input=$(echo "$test_case" | cut -d: -f2)
|
|
23
|
+
local input_type=$(echo "$test_case" | cut -d: -f3)
|
|
24
|
+
local expected=$(echo "$test_case" | cut -d: -f4)
|
|
25
|
+
|
|
26
|
+
echo "Running test case: $name"
|
|
27
|
+
|
|
28
|
+
if [[ "$expected" == "pass" ]]; then
|
|
29
|
+
validate_input "$input" "$input_type"
|
|
30
|
+
echo "✅ PASS: $name - Successfully validated"
|
|
31
|
+
else
|
|
32
|
+
set +e
|
|
33
|
+
validate_input "$input" "$input_type" 2>/dev/null
|
|
34
|
+
local exit_code=$?
|
|
35
|
+
set -e
|
|
36
|
+
|
|
37
|
+
if [ "$exit_code" -ne 0 ]; then
|
|
38
|
+
echo "✅ PASS: $name - Correctly rejected invalid input"
|
|
39
|
+
else
|
|
40
|
+
echo "❌ FAIL: $name - Failed to reject invalid input"
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
44
|
+
done
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Test SQLite Query Safety
|
|
48
|
+
test_sqlite_query_safety() {
|
|
49
|
+
local db_file=$(mktemp)
|
|
50
|
+
local bad_input="'; DROP TABLE agent_memory; --"
|
|
51
|
+
|
|
52
|
+
# Setup test database
|
|
53
|
+
sqlite3 "$db_file" <<EOF
|
|
54
|
+
CREATE TABLE agent_memory (
|
|
55
|
+
task_id TEXT,
|
|
56
|
+
event_data TEXT
|
|
57
|
+
);
|
|
58
|
+
INSERT INTO agent_memory VALUES ('test-task', 'sample data');
|
|
59
|
+
EOF
|
|
60
|
+
|
|
61
|
+
# Attempt query with malicious input
|
|
62
|
+
set +e
|
|
63
|
+
local query_result=$(sqlite3 "$db_file" \
|
|
64
|
+
"SELECT COUNT(*) FROM agent_memory WHERE task_id = '$bad_input';" 2>/dev/null)
|
|
65
|
+
local exit_code=$?
|
|
66
|
+
set -e
|
|
67
|
+
|
|
68
|
+
# Verify query did not modify the database
|
|
69
|
+
local row_count=$(sqlite3 "$db_file" "SELECT COUNT(*) FROM agent_memory;")
|
|
70
|
+
|
|
71
|
+
if [ "$row_count" -eq 1 ] && [ "$exit_code" -eq 0 ]; then
|
|
72
|
+
echo "✅ PASS: SQLite query safety - Malicious input contained"
|
|
73
|
+
else
|
|
74
|
+
echo "❌ FAIL: SQLite query safety - Potential vulnerability"
|
|
75
|
+
exit 1
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Cleanup
|
|
79
|
+
rm -f "$db_file"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# Main test runner
|
|
83
|
+
main() {
|
|
84
|
+
echo "=== Input Validation Security Tests ==="
|
|
85
|
+
|
|
86
|
+
test_input_validation
|
|
87
|
+
test_sqlite_query_safety
|
|
88
|
+
|
|
89
|
+
echo "=== All Security Tests Passed ==="
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# Run tests
|
|
93
93
|
main
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Transparency Middleware Wrapper
|
|
3
|
-
# Wraps agent execution with automatic memory capture
|
|
4
|
-
|
|
5
|
-
# Strict error handling
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
# Logging configuration
|
|
9
|
-
LOG_DIR="/var/log/claude-flow/transparency-middleware"
|
|
10
|
-
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
|
11
|
-
|
|
12
|
-
# Validate input arguments
|
|
13
|
-
if [[ $# -lt 3 ]]; then
|
|
14
|
-
echo "Error: Insufficient arguments" >&2
|
|
15
|
-
echo "Usage: $0 <AGENT_ROLE> <AGENT_ID> <TASK_ID> [ADDITIONAL_ARGS...]" >&2
|
|
16
|
-
exit 1
|
|
17
|
-
fi
|
|
18
|
-
|
|
19
|
-
# Parse arguments
|
|
20
|
-
AGENT_ROLE="$1"
|
|
21
|
-
AGENT_ID="$2"
|
|
22
|
-
TASK_ID="$3"
|
|
23
|
-
shift 3 # Remove first three arguments, leaving any additional args
|
|
24
|
-
|
|
25
|
-
# Create log directory if it doesn't exist
|
|
26
|
-
mkdir -p "${LOG_DIR}/${TASK_ID}"
|
|
27
|
-
|
|
28
|
-
# Initialize middleware and pre-execution hooks
|
|
29
|
-
initialize_middleware() {
|
|
30
|
-
node -e "
|
|
31
|
-
import {TransparencyMiddleware} from '.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-src/middleware/transparency-middleware.js';
|
|
32
|
-
const middleware = new TransparencyMiddleware();
|
|
33
|
-
await middleware.initialize({
|
|
34
|
-
agentRole: '${AGENT_ROLE}',
|
|
35
|
-
agentId: '${AGENT_ID}',
|
|
36
|
-
taskId: '${TASK_ID}'
|
|
37
|
-
});
|
|
38
|
-
await middleware.preExecutionHook();
|
|
39
|
-
" || {
|
|
40
|
-
echo "Middleware initialization failed" >&2
|
|
41
|
-
exit 2
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# Capture execution metrics
|
|
46
|
-
execute_agent() {
|
|
47
|
-
local log_file="${LOG_DIR}/${TASK_ID}/${AGENT_ID}_${TIMESTAMP}.log"
|
|
48
|
-
local metrics_file="${LOG_DIR}/${TASK_ID}/${AGENT_ID}_${TIMESTAMP}_metrics.json"
|
|
49
|
-
|
|
50
|
-
# Start time capture
|
|
51
|
-
local start_time=$(date +%s.%N)
|
|
52
|
-
|
|
53
|
-
# Execute the actual agent command with all remaining arguments
|
|
54
|
-
# Redirect output to log file
|
|
55
|
-
if ! "$@" 2>&1 | tee "${log_file}"; then
|
|
56
|
-
local exit_code=${PIPESTATUS[0]}
|
|
57
|
-
|
|
58
|
-
# Capture error metrics
|
|
59
|
-
node -e "
|
|
60
|
-
import fs from 'fs';
|
|
61
|
-
import {TransparencyMiddleware} from '.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-src/middleware/transparency-middleware.js';
|
|
62
|
-
const middleware = new TransparencyMiddleware();
|
|
63
|
-
|
|
64
|
-
const metrics = {
|
|
65
|
-
taskId: '${TASK_ID}',
|
|
66
|
-
agentId: '${AGENT_ID}',
|
|
67
|
-
agentRole: '${AGENT_ROLE}',
|
|
68
|
-
startTime: ${start_time},
|
|
69
|
-
endTime: $(date +%s.%N),
|
|
70
|
-
exitCode: ${exit_code},
|
|
71
|
-
status: 'FAILED'
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
await middleware.postExecutionHook(metrics);
|
|
75
|
-
fs.writeFileSync('${metrics_file}', JSON.stringify(metrics, null, 2));
|
|
76
|
-
" || echo "Error tracking failed"
|
|
77
|
-
|
|
78
|
-
return ${exit_code}
|
|
79
|
-
fi
|
|
80
|
-
|
|
81
|
-
# Capture successful execution metrics
|
|
82
|
-
node -e "
|
|
83
|
-
import fs from 'fs';
|
|
84
|
-
import {TransparencyMiddleware} from '.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-src/middleware/transparency-middleware.js';
|
|
85
|
-
const middleware = new TransparencyMiddleware();
|
|
86
|
-
|
|
87
|
-
const metrics = {
|
|
88
|
-
taskId: '${TASK_ID}',
|
|
89
|
-
agentId: '${AGENT_ID}',
|
|
90
|
-
agentRole: '${AGENT_ROLE}',
|
|
91
|
-
startTime: ${start_time},
|
|
92
|
-
endTime: $(date +%s.%N),
|
|
93
|
-
exitCode: 0,
|
|
94
|
-
status: 'SUCCESS'
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
await middleware.postExecutionHook(metrics);
|
|
98
|
-
fs.writeFileSync('${metrics_file}', JSON.stringify(metrics, null, 2));
|
|
99
|
-
" || echo "Metrics tracking failed"
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
# Main execution flow
|
|
103
|
-
main() {
|
|
104
|
-
# Initialize middleware before execution
|
|
105
|
-
initialize_middleware
|
|
106
|
-
|
|
107
|
-
# Execute agent with remaining arguments
|
|
108
|
-
execute_agent "$@"
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
# Execute main function and capture its exit status
|
|
112
|
-
main "$@"
|
|
113
|
-
exit_status=$?
|
|
114
|
-
|
|
115
|
-
# Signal completion to Redis coordination
|
|
116
|
-
redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete" > /dev/null
|
|
117
|
-
|
|
118
|
-
# Invoke waiting mode report
|
|
119
|
-
./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh report \
|
|
120
|
-
--task-id "${TASK_ID}" \
|
|
121
|
-
--agent-id "${AGENT_ID}" \
|
|
122
|
-
--confidence 0.80 \
|
|
123
|
-
--iteration 1
|
|
124
|
-
|
|
125
|
-
# Enter waiting mode
|
|
126
|
-
./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh enter \
|
|
127
|
-
--task-id "${TASK_ID}" \
|
|
128
|
-
--agent-id "${AGENT_ID}" \
|
|
129
|
-
--context "iteration-1-complete"
|
|
130
|
-
|
|
131
|
-
# Exit with original command's exit status
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Transparency Middleware Wrapper
|
|
3
|
+
# Wraps agent execution with automatic memory capture
|
|
4
|
+
|
|
5
|
+
# Strict error handling
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# Logging configuration
|
|
9
|
+
LOG_DIR="/var/log/claude-flow/transparency-middleware"
|
|
10
|
+
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
|
11
|
+
|
|
12
|
+
# Validate input arguments
|
|
13
|
+
if [[ $# -lt 3 ]]; then
|
|
14
|
+
echo "Error: Insufficient arguments" >&2
|
|
15
|
+
echo "Usage: $0 <AGENT_ROLE> <AGENT_ID> <TASK_ID> [ADDITIONAL_ARGS...]" >&2
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# Parse arguments
|
|
20
|
+
AGENT_ROLE="$1"
|
|
21
|
+
AGENT_ID="$2"
|
|
22
|
+
TASK_ID="$3"
|
|
23
|
+
shift 3 # Remove first three arguments, leaving any additional args
|
|
24
|
+
|
|
25
|
+
# Create log directory if it doesn't exist
|
|
26
|
+
mkdir -p "${LOG_DIR}/${TASK_ID}"
|
|
27
|
+
|
|
28
|
+
# Initialize middleware and pre-execution hooks
|
|
29
|
+
initialize_middleware() {
|
|
30
|
+
node -e "
|
|
31
|
+
import {TransparencyMiddleware} from '.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-src/middleware/transparency-middleware.js';
|
|
32
|
+
const middleware = new TransparencyMiddleware();
|
|
33
|
+
await middleware.initialize({
|
|
34
|
+
agentRole: '${AGENT_ROLE}',
|
|
35
|
+
agentId: '${AGENT_ID}',
|
|
36
|
+
taskId: '${TASK_ID}'
|
|
37
|
+
});
|
|
38
|
+
await middleware.preExecutionHook();
|
|
39
|
+
" || {
|
|
40
|
+
echo "Middleware initialization failed" >&2
|
|
41
|
+
exit 2
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Capture execution metrics
|
|
46
|
+
execute_agent() {
|
|
47
|
+
local log_file="${LOG_DIR}/${TASK_ID}/${AGENT_ID}_${TIMESTAMP}.log"
|
|
48
|
+
local metrics_file="${LOG_DIR}/${TASK_ID}/${AGENT_ID}_${TIMESTAMP}_metrics.json"
|
|
49
|
+
|
|
50
|
+
# Start time capture
|
|
51
|
+
local start_time=$(date +%s.%N)
|
|
52
|
+
|
|
53
|
+
# Execute the actual agent command with all remaining arguments
|
|
54
|
+
# Redirect output to log file
|
|
55
|
+
if ! "$@" 2>&1 | tee "${log_file}"; then
|
|
56
|
+
local exit_code=${PIPESTATUS[0]}
|
|
57
|
+
|
|
58
|
+
# Capture error metrics
|
|
59
|
+
node -e "
|
|
60
|
+
import fs from 'fs';
|
|
61
|
+
import {TransparencyMiddleware} from '.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-src/middleware/transparency-middleware.js';
|
|
62
|
+
const middleware = new TransparencyMiddleware();
|
|
63
|
+
|
|
64
|
+
const metrics = {
|
|
65
|
+
taskId: '${TASK_ID}',
|
|
66
|
+
agentId: '${AGENT_ID}',
|
|
67
|
+
agentRole: '${AGENT_ROLE}',
|
|
68
|
+
startTime: ${start_time},
|
|
69
|
+
endTime: $(date +%s.%N),
|
|
70
|
+
exitCode: ${exit_code},
|
|
71
|
+
status: 'FAILED'
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
await middleware.postExecutionHook(metrics);
|
|
75
|
+
fs.writeFileSync('${metrics_file}', JSON.stringify(metrics, null, 2));
|
|
76
|
+
" || echo "Error tracking failed"
|
|
77
|
+
|
|
78
|
+
return ${exit_code}
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
# Capture successful execution metrics
|
|
82
|
+
node -e "
|
|
83
|
+
import fs from 'fs';
|
|
84
|
+
import {TransparencyMiddleware} from '.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-src/middleware/transparency-middleware.js';
|
|
85
|
+
const middleware = new TransparencyMiddleware();
|
|
86
|
+
|
|
87
|
+
const metrics = {
|
|
88
|
+
taskId: '${TASK_ID}',
|
|
89
|
+
agentId: '${AGENT_ID}',
|
|
90
|
+
agentRole: '${AGENT_ROLE}',
|
|
91
|
+
startTime: ${start_time},
|
|
92
|
+
endTime: $(date +%s.%N),
|
|
93
|
+
exitCode: 0,
|
|
94
|
+
status: 'SUCCESS'
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
await middleware.postExecutionHook(metrics);
|
|
98
|
+
fs.writeFileSync('${metrics_file}', JSON.stringify(metrics, null, 2));
|
|
99
|
+
" || echo "Metrics tracking failed"
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# Main execution flow
|
|
103
|
+
main() {
|
|
104
|
+
# Initialize middleware before execution
|
|
105
|
+
initialize_middleware
|
|
106
|
+
|
|
107
|
+
# Execute agent with remaining arguments
|
|
108
|
+
execute_agent "$@"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# Execute main function and capture its exit status
|
|
112
|
+
main "$@"
|
|
113
|
+
exit_status=$?
|
|
114
|
+
|
|
115
|
+
# Signal completion to Redis coordination
|
|
116
|
+
redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete" > /dev/null
|
|
117
|
+
|
|
118
|
+
# Invoke waiting mode report
|
|
119
|
+
./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh report \
|
|
120
|
+
--task-id "${TASK_ID}" \
|
|
121
|
+
--agent-id "${AGENT_ID}" \
|
|
122
|
+
--confidence 0.80 \
|
|
123
|
+
--iteration 1
|
|
124
|
+
|
|
125
|
+
# Enter waiting mode
|
|
126
|
+
./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh enter \
|
|
127
|
+
--task-id "${TASK_ID}" \
|
|
128
|
+
--agent-id "${AGENT_ID}" \
|
|
129
|
+
--context "iteration-1-complete"
|
|
130
|
+
|
|
131
|
+
# Exit with original command's exit status
|
|
132
132
|
exit ${exit_status}
|