claude-flow-novice 2.14.36 → 2.15.0
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/commands/cfn-loop-cli.md +491 -456
- package/.claude/commands/switch-api.md +33 -12
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +107 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +59 -0
- package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +24 -6
- package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +18 -9
- package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +220 -220
- package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +5 -0
- package/claude-assets/agents/custom/claude-code-expert.md +151 -2
- package/claude-assets/agents/docker-coordinators/cfn-docker-v3-coordinator.md +43 -3
- package/claude-assets/commands/cfn-loop-cli.md +491 -456
- package/claude-assets/commands/switch-api.md +33 -12
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +107 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +59 -0
- package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +24 -6
- package/claude-assets/skills/cfn-error-logging/SKILL.md +339 -0
- package/claude-assets/skills/cfn-error-logging/cleanup-error-logs.sh +334 -0
- package/claude-assets/skills/cfn-error-logging/integrate-cli.sh +232 -0
- package/claude-assets/skills/cfn-error-logging/integrate-docker.sh +294 -0
- package/claude-assets/skills/cfn-error-logging/invoke-error-logging.sh +839 -0
- package/claude-assets/skills/cfn-error-logging/test-error-logging.sh +475 -0
- package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +18 -9
- package/claude-assets/skills/cfn-process-instrumentation/instrument-process.sh +5 -3
- package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +220 -220
- package/claude-assets/skills/cfn-task-mode-sanitize/task-mode-env-sanitizer.sh +21 -9
- package/claude-assets/skills/cfn-validation-runner-instrumentation/wrapped-executor.sh +3 -1
- package/dist/hello.js +27 -3
- package/dist/hello.js.map +1 -1
- package/dist/server.js +194 -0
- package/dist/server.js.map +1 -0
- package/dist/server.test.js +207 -0
- package/dist/server.test.js.map +1 -0
- package/package.json +2 -1
- package/scripts/switch-api.sh +140 -12
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
#
|
|
3
|
-
# Invoke Waiting Mode - Agent Coordination for CFN Loop
|
|
4
|
-
# Purpose: Handle coordination between agents using waiting mode and collection
|
|
5
|
-
# Usage: invoke-waiting-mode.sh <collect|wait|signal> [task-id] [agent-id] [timeout]
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
set -euo pipefail
|
|
9
|
-
|
|
10
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
-
REDIS_COORD_SKILL="$SCRIPT_DIR"
|
|
12
|
-
|
|
13
|
-
# Parse arguments
|
|
14
|
-
COMMAND=${1:-"collect"}
|
|
15
|
-
TASK_ID=${2:-""}
|
|
16
|
-
AGENT_ID=${3:-""}
|
|
17
|
-
TIMEOUT=${4:-120}
|
|
18
|
-
|
|
19
|
-
# Redis configuration
|
|
20
|
-
REDIS_HOST=${REDIS_HOST:-"localhost"}
|
|
21
|
-
REDIS_PORT=${REDIS_PORT:-6379}
|
|
22
|
-
REDIS_DB=${REDIS_DB:-0}
|
|
23
|
-
|
|
24
|
-
# Debug output
|
|
25
|
-
DEBUG=${DEBUG:-false}
|
|
26
|
-
if [[ "$DEBUG" == "true" ]]; then
|
|
27
|
-
echo "DEBUG: invoke-waiting-mode called with: $*" >&2
|
|
28
|
-
echo "DEBUG: REDIS_HOST=$REDIS_HOST, REDIS_PORT=$REDIS_PORT, REDIS_DB=$REDIS_DB" >&2
|
|
29
|
-
fi
|
|
30
|
-
|
|
31
|
-
# Function to connect to Redis with error handling
|
|
32
|
-
redis_cmd() {
|
|
33
|
-
local cmd="$1"
|
|
34
|
-
shift
|
|
35
|
-
|
|
36
|
-
if command -v redis-cli >/dev/null 2>&1; then
|
|
37
|
-
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" -n "$REDIS_DB" "$cmd" "$@" 2>/dev/null
|
|
38
|
-
else
|
|
39
|
-
echo "Warning: redis-cli not available, using mock mode" >&2
|
|
40
|
-
return 0
|
|
41
|
-
fi
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
# Function to collect agent signals
|
|
45
|
-
collect_signals() {
|
|
46
|
-
local task_id="$1"
|
|
47
|
-
local agent_type="$2"
|
|
48
|
-
local timeout="${3:-120}"
|
|
49
|
-
|
|
50
|
-
echo "📡 Collecting ${agent_type} signals for task: $task_id (timeout: ${timeout}s)" >&2
|
|
51
|
-
|
|
52
|
-
local signals_key="swarm:${task_id}:signals:${agent_type}"
|
|
53
|
-
local start_time=$(date +%s)
|
|
54
|
-
local signals_collected=()
|
|
55
|
-
|
|
56
|
-
while true; do
|
|
57
|
-
# Get all available signals
|
|
58
|
-
local signals=($(redis_cmd SMEMBERS "$signals_key" 2>/dev/null || echo ""))
|
|
59
|
-
|
|
60
|
-
if [[ ${#signals[@]} -gt 0 ]]; then
|
|
61
|
-
for signal in "${signals[@]}"; do
|
|
62
|
-
if [[ ! " ${signals_collected[@]} " =~ " ${signal} " ]]; then
|
|
63
|
-
signals_collected+=("$signal")
|
|
64
|
-
echo " ✓ Signal collected: $signal" >&2
|
|
65
|
-
|
|
66
|
-
# Get detailed signal data
|
|
67
|
-
local signal_key="swarm:${task_id}:agent:${signal}:data"
|
|
68
|
-
local signal_data=$(redis_cmd HGETALL "$signal_key" 2>/dev/null || echo "")
|
|
69
|
-
|
|
70
|
-
if [[ -n "$signal_data" ]]; then
|
|
71
|
-
echo " Data: $signal_data" >&2
|
|
72
|
-
fi
|
|
73
|
-
fi
|
|
74
|
-
done
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
# Check if we have all expected signals (this would be based on agent count)
|
|
78
|
-
local expected_signals=${EXPECTED_AGENTS:-1}
|
|
79
|
-
if [[ ${#signals_collected[@]} -ge $expected_signals ]]; then
|
|
80
|
-
echo "✅ All signals collected" >&2
|
|
81
|
-
break
|
|
82
|
-
fi
|
|
83
|
-
|
|
84
|
-
# Check timeout
|
|
85
|
-
local current_time=$(date +%s)
|
|
86
|
-
if [[ $((current_time - start_time)) -ge $timeout ]]; then
|
|
87
|
-
echo "⚠️ Timeout reached, proceeding with collected signals" >&2
|
|
88
|
-
break
|
|
89
|
-
fi
|
|
90
|
-
|
|
91
|
-
sleep 2
|
|
92
|
-
done
|
|
93
|
-
|
|
94
|
-
# Return collected signals as JSON
|
|
95
|
-
local json_output="{"
|
|
96
|
-
json_output+="\"task_id\":\"$task_id\","
|
|
97
|
-
json_output+="\"agent_type\":\"$agent_type\","
|
|
98
|
-
json_output+="\"signals\":["
|
|
99
|
-
|
|
100
|
-
for i in "${!signals_collected[@]}"; do
|
|
101
|
-
if [[ $i -gt 0 ]]; then
|
|
102
|
-
json_output+=","
|
|
103
|
-
fi
|
|
104
|
-
json_output+='"'"${signals_collected[$i]}"'"'
|
|
105
|
-
done
|
|
106
|
-
|
|
107
|
-
json_output+="],"
|
|
108
|
-
json_output+="\"count\":${#signals_collected[@]},"
|
|
109
|
-
json_output+="\"timeout\":$timeout"
|
|
110
|
-
json_output+="}"
|
|
111
|
-
|
|
112
|
-
echo "$json_output"
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
# Function to wait for specific condition
|
|
116
|
-
wait_for_signal() {
|
|
117
|
-
local task_id="$1"
|
|
118
|
-
local condition="$2"
|
|
119
|
-
local timeout="${3:-120}"
|
|
120
|
-
|
|
121
|
-
echo "⏳ Waiting for signal: $condition (timeout: ${timeout}s)" >&2
|
|
122
|
-
|
|
123
|
-
local start_time=$(date +%s)
|
|
124
|
-
local condition_key="swarm:${task_id}:condition:${condition}"
|
|
125
|
-
|
|
126
|
-
while true; do
|
|
127
|
-
local condition_met=$(redis_cmd GET "$condition_key" 2>/dev/null || echo "")
|
|
128
|
-
|
|
129
|
-
if [[ "$condition_met" == "true" ]]; then
|
|
130
|
-
echo "✅ Condition met: $condition" >&2
|
|
131
|
-
redis_cmd DEL "$condition_key" 2>/dev/null
|
|
132
|
-
echo "true"
|
|
133
|
-
return 0
|
|
134
|
-
fi
|
|
135
|
-
|
|
136
|
-
# Check timeout
|
|
137
|
-
local current_time=$(date +%s)
|
|
138
|
-
if [[ $((current_time - start_time)) -ge $timeout ]]; then
|
|
139
|
-
echo "⚠️ Timeout waiting for: $condition" >&2
|
|
140
|
-
echo "false"
|
|
141
|
-
return 1
|
|
142
|
-
fi
|
|
143
|
-
|
|
144
|
-
sleep 2
|
|
145
|
-
done
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
# Function to signal completion
|
|
149
|
-
signal_completion() {
|
|
150
|
-
local task_id="$1"
|
|
151
|
-
local agent_id="$2"
|
|
152
|
-
local status="${3:-complete}"
|
|
153
|
-
|
|
154
|
-
echo "📤 Signaling completion: $agent_id -> $status" >&2
|
|
155
|
-
|
|
156
|
-
# Add to completed set
|
|
157
|
-
redis_cmd SADD "swarm:${task_id}:completed" "$agent_id" 2>/dev/null || true
|
|
158
|
-
|
|
159
|
-
# Set completion status
|
|
160
|
-
redis_cmd HSET "swarm:${task_id}:agent:${agent_id}:status" "status" "$status" 2>/dev/null || true
|
|
161
|
-
redis_cmd HSET "swarm:${task_id}:agent:${agent_id}:status" "completed_at" "$(date +%s)" 2>/dev/null || true
|
|
162
|
-
|
|
163
|
-
# Broadcast completion signal
|
|
164
|
-
redis_cmd PUBLISH "swarm:${task_id}:signals" "agent:$agent_id:status:$status" 2>/dev/null || true
|
|
165
|
-
|
|
166
|
-
echo "✅ Signal sent: $agent_id completed"
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
# Main command routing
|
|
170
|
-
case "$COMMAND" in
|
|
171
|
-
"collect")
|
|
172
|
-
if [[ -z "$TASK_ID" ]]; then
|
|
173
|
-
echo "Error: collect command requires task-id" >&2
|
|
174
|
-
echo "Usage: $0 collect <task-id> <agent-type> [timeout]" >&2
|
|
175
|
-
exit 1
|
|
176
|
-
fi
|
|
177
|
-
collect_signals "$TASK_ID" "${AGENT_ID:-"loop3"}" "$TIMEOUT"
|
|
178
|
-
;;
|
|
179
|
-
"wait")
|
|
180
|
-
if [[ -z "$TASK_ID" ]] || [[ -z "$AGENT_ID" ]]; then
|
|
181
|
-
echo "Error: wait command requires task-id and condition" >&2
|
|
182
|
-
echo "Usage: $0 wait <task-id> <condition> [timeout]" >&2
|
|
183
|
-
exit 1
|
|
184
|
-
fi
|
|
185
|
-
wait_for_signal "$TASK_ID" "$AGENT_ID" "$TIMEOUT"
|
|
186
|
-
;;
|
|
187
|
-
"signal")
|
|
188
|
-
if [[ -z "$TASK_ID" ]] || [[ -z "$AGENT_ID" ]]; then
|
|
189
|
-
echo "Error: signal command requires task-id and agent-id" >&2
|
|
190
|
-
echo "Usage: $0 signal <task-id> <agent-id> [status]" >&2
|
|
191
|
-
exit 1
|
|
192
|
-
fi
|
|
193
|
-
signal_completion "$TASK_ID" "$AGENT_ID" "$TIMEOUT"
|
|
194
|
-
;;
|
|
195
|
-
"help"|"-h"|"--help")
|
|
196
|
-
cat <<EOF
|
|
197
|
-
Usage: $0 <command> [arguments]
|
|
198
|
-
|
|
199
|
-
Commands:
|
|
200
|
-
collect <task-id> <agent-type> [timeout] Collect signals from agents
|
|
201
|
-
wait <task-id> <condition> [timeout] Wait for condition to be met
|
|
202
|
-
signal <task-id> <agent-id> [status] Signal agent completion
|
|
203
|
-
|
|
204
|
-
Examples:
|
|
205
|
-
$0 collect cfn-cli-12345 loop3 300
|
|
206
|
-
$0 wait cfn-cli-12345 gate-passed 60
|
|
207
|
-
$0 signal cfn-cli-12345 backend-developer-1 complete
|
|
208
|
-
|
|
209
|
-
Environment Variables:
|
|
210
|
-
REDIS_HOST Redis host (default: localhost)
|
|
211
|
-
REDIS_PORT Redis port (default: 6379)
|
|
212
|
-
REDIS_DB Redis database (default: 0)
|
|
213
|
-
DEBUG Enable debug output (true/false)
|
|
214
|
-
EOF
|
|
215
|
-
;;
|
|
216
|
-
*)
|
|
217
|
-
echo "Error: Unknown command '$COMMAND'" >&2
|
|
218
|
-
echo "Use '$0 help' for usage information" >&2
|
|
219
|
-
exit 1
|
|
220
|
-
;;
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Invoke Waiting Mode - Agent Coordination for CFN Loop
|
|
4
|
+
# Purpose: Handle coordination between agents using waiting mode and collection
|
|
5
|
+
# Usage: invoke-waiting-mode.sh <collect|wait|signal> [task-id] [agent-id] [timeout]
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
+
REDIS_COORD_SKILL="$SCRIPT_DIR"
|
|
12
|
+
|
|
13
|
+
# Parse arguments
|
|
14
|
+
COMMAND=${1:-"collect"}
|
|
15
|
+
TASK_ID=${2:-""}
|
|
16
|
+
AGENT_ID=${3:-""}
|
|
17
|
+
TIMEOUT=${4:-120}
|
|
18
|
+
|
|
19
|
+
# Redis configuration
|
|
20
|
+
REDIS_HOST=${REDIS_HOST:-"localhost"}
|
|
21
|
+
REDIS_PORT=${REDIS_PORT:-6379}
|
|
22
|
+
REDIS_DB=${REDIS_DB:-0}
|
|
23
|
+
|
|
24
|
+
# Debug output
|
|
25
|
+
DEBUG=${DEBUG:-false}
|
|
26
|
+
if [[ "$DEBUG" == "true" ]]; then
|
|
27
|
+
echo "DEBUG: invoke-waiting-mode called with: $*" >&2
|
|
28
|
+
echo "DEBUG: REDIS_HOST=$REDIS_HOST, REDIS_PORT=$REDIS_PORT, REDIS_DB=$REDIS_DB" >&2
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Function to connect to Redis with error handling
|
|
32
|
+
redis_cmd() {
|
|
33
|
+
local cmd="$1"
|
|
34
|
+
shift
|
|
35
|
+
|
|
36
|
+
if command -v redis-cli >/dev/null 2>&1; then
|
|
37
|
+
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" -n "$REDIS_DB" "$cmd" "$@" 2>/dev/null
|
|
38
|
+
else
|
|
39
|
+
echo "Warning: redis-cli not available, using mock mode" >&2
|
|
40
|
+
return 0
|
|
41
|
+
fi
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# Function to collect agent signals
|
|
45
|
+
collect_signals() {
|
|
46
|
+
local task_id="$1"
|
|
47
|
+
local agent_type="$2"
|
|
48
|
+
local timeout="${3:-120}"
|
|
49
|
+
|
|
50
|
+
echo "📡 Collecting ${agent_type} signals for task: $task_id (timeout: ${timeout}s)" >&2
|
|
51
|
+
|
|
52
|
+
local signals_key="swarm:${task_id}:signals:${agent_type}"
|
|
53
|
+
local start_time=$(date +%s)
|
|
54
|
+
local signals_collected=()
|
|
55
|
+
|
|
56
|
+
while true; do
|
|
57
|
+
# Get all available signals
|
|
58
|
+
local signals=($(redis_cmd SMEMBERS "$signals_key" 2>/dev/null || echo ""))
|
|
59
|
+
|
|
60
|
+
if [[ ${#signals[@]} -gt 0 ]]; then
|
|
61
|
+
for signal in "${signals[@]}"; do
|
|
62
|
+
if [[ ! " ${signals_collected[@]} " =~ " ${signal} " ]]; then
|
|
63
|
+
signals_collected+=("$signal")
|
|
64
|
+
echo " ✓ Signal collected: $signal" >&2
|
|
65
|
+
|
|
66
|
+
# Get detailed signal data
|
|
67
|
+
local signal_key="swarm:${task_id}:agent:${signal}:data"
|
|
68
|
+
local signal_data=$(redis_cmd HGETALL "$signal_key" 2>/dev/null || echo "")
|
|
69
|
+
|
|
70
|
+
if [[ -n "$signal_data" ]]; then
|
|
71
|
+
echo " Data: $signal_data" >&2
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
done
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
# Check if we have all expected signals (this would be based on agent count)
|
|
78
|
+
local expected_signals=${EXPECTED_AGENTS:-1}
|
|
79
|
+
if [[ ${#signals_collected[@]} -ge $expected_signals ]]; then
|
|
80
|
+
echo "✅ All signals collected" >&2
|
|
81
|
+
break
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
# Check timeout
|
|
85
|
+
local current_time=$(date +%s)
|
|
86
|
+
if [[ $((current_time - start_time)) -ge $timeout ]]; then
|
|
87
|
+
echo "⚠️ Timeout reached, proceeding with collected signals" >&2
|
|
88
|
+
break
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
sleep 2
|
|
92
|
+
done
|
|
93
|
+
|
|
94
|
+
# Return collected signals as JSON
|
|
95
|
+
local json_output="{"
|
|
96
|
+
json_output+="\"task_id\":\"$task_id\","
|
|
97
|
+
json_output+="\"agent_type\":\"$agent_type\","
|
|
98
|
+
json_output+="\"signals\":["
|
|
99
|
+
|
|
100
|
+
for i in "${!signals_collected[@]}"; do
|
|
101
|
+
if [[ $i -gt 0 ]]; then
|
|
102
|
+
json_output+=","
|
|
103
|
+
fi
|
|
104
|
+
json_output+='"'"${signals_collected[$i]}"'"'
|
|
105
|
+
done
|
|
106
|
+
|
|
107
|
+
json_output+="],"
|
|
108
|
+
json_output+="\"count\":${#signals_collected[@]},"
|
|
109
|
+
json_output+="\"timeout\":$timeout"
|
|
110
|
+
json_output+="}"
|
|
111
|
+
|
|
112
|
+
echo "$json_output"
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
# Function to wait for specific condition
|
|
116
|
+
wait_for_signal() {
|
|
117
|
+
local task_id="$1"
|
|
118
|
+
local condition="$2"
|
|
119
|
+
local timeout="${3:-120}"
|
|
120
|
+
|
|
121
|
+
echo "⏳ Waiting for signal: $condition (timeout: ${timeout}s)" >&2
|
|
122
|
+
|
|
123
|
+
local start_time=$(date +%s)
|
|
124
|
+
local condition_key="swarm:${task_id}:condition:${condition}"
|
|
125
|
+
|
|
126
|
+
while true; do
|
|
127
|
+
local condition_met=$(redis_cmd GET "$condition_key" 2>/dev/null || echo "")
|
|
128
|
+
|
|
129
|
+
if [[ "$condition_met" == "true" ]]; then
|
|
130
|
+
echo "✅ Condition met: $condition" >&2
|
|
131
|
+
redis_cmd DEL "$condition_key" 2>/dev/null
|
|
132
|
+
echo "true"
|
|
133
|
+
return 0
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
# Check timeout
|
|
137
|
+
local current_time=$(date +%s)
|
|
138
|
+
if [[ $((current_time - start_time)) -ge $timeout ]]; then
|
|
139
|
+
echo "⚠️ Timeout waiting for: $condition" >&2
|
|
140
|
+
echo "false"
|
|
141
|
+
return 1
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
sleep 2
|
|
145
|
+
done
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# Function to signal completion
|
|
149
|
+
signal_completion() {
|
|
150
|
+
local task_id="$1"
|
|
151
|
+
local agent_id="$2"
|
|
152
|
+
local status="${3:-complete}"
|
|
153
|
+
|
|
154
|
+
echo "📤 Signaling completion: $agent_id -> $status" >&2
|
|
155
|
+
|
|
156
|
+
# Add to completed set
|
|
157
|
+
redis_cmd SADD "swarm:${task_id}:completed" "$agent_id" 2>/dev/null || true
|
|
158
|
+
|
|
159
|
+
# Set completion status
|
|
160
|
+
redis_cmd HSET "swarm:${task_id}:agent:${agent_id}:status" "status" "$status" 2>/dev/null || true
|
|
161
|
+
redis_cmd HSET "swarm:${task_id}:agent:${agent_id}:status" "completed_at" "$(date +%s)" 2>/dev/null || true
|
|
162
|
+
|
|
163
|
+
# Broadcast completion signal
|
|
164
|
+
redis_cmd PUBLISH "swarm:${task_id}:signals" "agent:$agent_id:status:$status" 2>/dev/null || true
|
|
165
|
+
|
|
166
|
+
echo "✅ Signal sent: $agent_id completed"
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
# Main command routing
|
|
170
|
+
case "$COMMAND" in
|
|
171
|
+
"collect")
|
|
172
|
+
if [[ -z "$TASK_ID" ]]; then
|
|
173
|
+
echo "Error: collect command requires task-id" >&2
|
|
174
|
+
echo "Usage: $0 collect <task-id> <agent-type> [timeout]" >&2
|
|
175
|
+
exit 1
|
|
176
|
+
fi
|
|
177
|
+
collect_signals "$TASK_ID" "${AGENT_ID:-"loop3"}" "$TIMEOUT"
|
|
178
|
+
;;
|
|
179
|
+
"wait")
|
|
180
|
+
if [[ -z "$TASK_ID" ]] || [[ -z "$AGENT_ID" ]]; then
|
|
181
|
+
echo "Error: wait command requires task-id and condition" >&2
|
|
182
|
+
echo "Usage: $0 wait <task-id> <condition> [timeout]" >&2
|
|
183
|
+
exit 1
|
|
184
|
+
fi
|
|
185
|
+
wait_for_signal "$TASK_ID" "$AGENT_ID" "$TIMEOUT"
|
|
186
|
+
;;
|
|
187
|
+
"signal")
|
|
188
|
+
if [[ -z "$TASK_ID" ]] || [[ -z "$AGENT_ID" ]]; then
|
|
189
|
+
echo "Error: signal command requires task-id and agent-id" >&2
|
|
190
|
+
echo "Usage: $0 signal <task-id> <agent-id> [status]" >&2
|
|
191
|
+
exit 1
|
|
192
|
+
fi
|
|
193
|
+
signal_completion "$TASK_ID" "$AGENT_ID" "$TIMEOUT"
|
|
194
|
+
;;
|
|
195
|
+
"help"|"-h"|"--help")
|
|
196
|
+
cat <<EOF
|
|
197
|
+
Usage: $0 <command> [arguments]
|
|
198
|
+
|
|
199
|
+
Commands:
|
|
200
|
+
collect <task-id> <agent-type> [timeout] Collect signals from agents
|
|
201
|
+
wait <task-id> <condition> [timeout] Wait for condition to be met
|
|
202
|
+
signal <task-id> <agent-id> [status] Signal agent completion
|
|
203
|
+
|
|
204
|
+
Examples:
|
|
205
|
+
$0 collect cfn-cli-12345 loop3 300
|
|
206
|
+
$0 wait cfn-cli-12345 gate-passed 60
|
|
207
|
+
$0 signal cfn-cli-12345 backend-developer-1 complete
|
|
208
|
+
|
|
209
|
+
Environment Variables:
|
|
210
|
+
REDIS_HOST Redis host (default: localhost)
|
|
211
|
+
REDIS_PORT Redis port (default: 6379)
|
|
212
|
+
REDIS_DB Redis database (default: 0)
|
|
213
|
+
DEBUG Enable debug output (true/false)
|
|
214
|
+
EOF
|
|
215
|
+
;;
|
|
216
|
+
*)
|
|
217
|
+
echo "Error: Unknown command '$COMMAND'" >&2
|
|
218
|
+
echo "Use '$0 help' for usage information" >&2
|
|
219
|
+
exit 1
|
|
220
|
+
;;
|
|
221
221
|
esac
|
|
@@ -75,8 +75,12 @@ sanitize_cli_environment() {
|
|
|
75
75
|
export CFN_MODE="cli"
|
|
76
76
|
export CFN_SANITIZER_ACTIVE=true
|
|
77
77
|
|
|
78
|
-
#
|
|
79
|
-
|
|
78
|
+
# NOTE: DO NOT set ulimit -u as it causes fork failures
|
|
79
|
+
# The MAX_AGENT_PROCESSES constant is for monitoring only, not for ulimit
|
|
80
|
+
# Setting ulimit -u to a low value (50) when 200+ processes exist causes all forks to fail
|
|
81
|
+
# Instead, we monitor process count and warn if exceeded
|
|
82
|
+
|
|
83
|
+
# Set conservative memory limit only
|
|
80
84
|
ulimit -v $((MAX_MEMORY_MB * 1024)) 2>/dev/null || true
|
|
81
85
|
|
|
82
86
|
# Disable debug features in production
|
|
@@ -92,7 +96,7 @@ sanitize_task_environment() {
|
|
|
92
96
|
export CFN_SANITIZER_ACTIVE=true
|
|
93
97
|
|
|
94
98
|
# More permissive limits for debugging
|
|
95
|
-
ulimit -u
|
|
99
|
+
# NOTE: DO NOT set ulimit -u (see CLI mode comment above)
|
|
96
100
|
ulimit -v $((MAX_MEMORY_MB * 1024 * 2)) 2>/dev/null || true
|
|
97
101
|
|
|
98
102
|
# Enable debug features for task mode
|
|
@@ -108,7 +112,7 @@ sanitize_default_environment() {
|
|
|
108
112
|
export CFN_SANITIZER_ACTIVE=true
|
|
109
113
|
|
|
110
114
|
# Conservative limits
|
|
111
|
-
ulimit -u
|
|
115
|
+
# NOTE: DO NOT set ulimit -u (see CLI mode comment above)
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
##############################################################################
|
|
@@ -170,12 +174,20 @@ environment_cleanup_on_signal() {
|
|
|
170
174
|
cleanup_cli_environment() {
|
|
171
175
|
echo " CLI mode cleanup..." >&2
|
|
172
176
|
|
|
173
|
-
# Clean up any lingering agent processes
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
# Clean up any lingering agent processes (using /proc to avoid fork)
|
|
178
|
+
# This approach reads /proc directly instead of calling external pgrep command
|
|
179
|
+
# to prevent kernel fork rate limiting in nested process chains
|
|
180
|
+
local agent_pids=""
|
|
181
|
+
for pid in /proc/[0-9]*/; do
|
|
182
|
+
[[ -e "$pid/cmdline" ]] || continue
|
|
183
|
+
if grep -q "claude-flow-novice.*agent" "$pid/cmdline" 2>/dev/null; then
|
|
184
|
+
local pid_num=$(basename "$pid")
|
|
185
|
+
agent_pids="$agent_pids $pid_num"
|
|
178
186
|
fi
|
|
187
|
+
done
|
|
188
|
+
|
|
189
|
+
if [[ -n "$agent_pids" ]]; then
|
|
190
|
+
echo " Warning: Found agent processes:$agent_pids" >&2
|
|
179
191
|
fi
|
|
180
192
|
}
|
|
181
193
|
|
|
@@ -28,7 +28,9 @@ readonly MAX_TIMEOUT=3600 # 1 hour
|
|
|
28
28
|
readonly WARNING_TIMEOUT=240 # 4 minutes
|
|
29
29
|
|
|
30
30
|
# Resource limits
|
|
31
|
-
|
|
31
|
+
# Note: MAX_MEMORY_MB may be set by task-mode-env-sanitizer.sh (4096)
|
|
32
|
+
# Only set if not already defined
|
|
33
|
+
: "${MAX_MEMORY_MB:=2048}"
|
|
32
34
|
readonly MAX_CPU_PERCENT=80
|
|
33
35
|
|
|
34
36
|
##############################################################################
|
package/dist/hello.js
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Enhanced Hello World function with customizable greeting
|
|
3
|
+
* @param {string} name - Optional name to greet
|
|
3
4
|
* @returns {string} The greeting message
|
|
4
|
-
*/ export function hello() {
|
|
5
|
-
return
|
|
5
|
+
*/ export function hello(name = 'World') {
|
|
6
|
+
return `Hello ${name}!`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Health check function
|
|
10
|
+
* @returns {Object} Health status with timestamp
|
|
11
|
+
*/ export function healthCheck() {
|
|
12
|
+
return {
|
|
13
|
+
status: 'healthy',
|
|
14
|
+
timestamp: new Date().toISOString(),
|
|
15
|
+
uptime: process.uptime()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* API response wrapper
|
|
20
|
+
* @param {any} data - Response data
|
|
21
|
+
* @param {string} message - Response message
|
|
22
|
+
* @returns {Object} Formatted API response
|
|
23
|
+
*/ export function createApiResponse(data, message = 'Success') {
|
|
24
|
+
return {
|
|
25
|
+
success: true,
|
|
26
|
+
message,
|
|
27
|
+
data,
|
|
28
|
+
timestamp: new Date().toISOString()
|
|
29
|
+
};
|
|
6
30
|
}
|
|
7
31
|
|
|
8
32
|
//# sourceMappingURL=hello.js.map
|
package/dist/hello.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hello.js"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"sources":["../src/hello.js"],"sourcesContent":["/**\n * Enhanced Hello World function with customizable greeting\n * @param {string} name - Optional name to greet\n * @returns {string} The greeting message\n */\nexport function hello(name = 'World') {\n return `Hello ${name}!`;\n}\n\n/**\n * Health check function\n * @returns {Object} Health status with timestamp\n */\nexport function healthCheck() {\n return {\n status: 'healthy',\n timestamp: new Date().toISOString(),\n uptime: process.uptime()\n };\n}\n\n/**\n * API response wrapper\n * @param {any} data - Response data\n * @param {string} message - Response message\n * @returns {Object} Formatted API response\n */\nexport function createApiResponse(data, message = 'Success') {\n return {\n success: true,\n message,\n data,\n timestamp: new Date().toISOString()\n };\n}"],"names":["hello","name","healthCheck","status","timestamp","Date","toISOString","uptime","process","createApiResponse","data","message","success"],"mappings":"AAAA;;;;CAIC,GACD,OAAO,SAASA,MAAMC,OAAO,OAAO;IAClC,OAAO,CAAC,MAAM,EAAEA,KAAK,CAAC,CAAC;AACzB;AAEA;;;CAGC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,QAAQ;QACRC,WAAW,IAAIC,OAAOC,WAAW;QACjCC,QAAQC,QAAQD,MAAM;IACxB;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASE,kBAAkBC,IAAI,EAAEC,UAAU,SAAS;IACzD,OAAO;QACLC,SAAS;QACTD;QACAD;QACAN,WAAW,IAAIC,OAAOC,WAAW;IACnC;AACF"}
|