agent-relay-plugin 0.4.19 → 0.4.24
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/hooks/poll-inbox.sh
CHANGED
|
@@ -85,7 +85,15 @@ since_id=$(fetch_cursor || echo 0)
|
|
|
85
85
|
|
|
86
86
|
fail_streak=0
|
|
87
87
|
marked_ready=false
|
|
88
|
+
# Save parent PID (Claude Code wrapper) — if it dies, we're orphaned.
|
|
89
|
+
_parent_pid="$PPID"
|
|
88
90
|
while true; do
|
|
91
|
+
# Exit if parent process is gone — prevents orphaned monitors from heartbeating forever.
|
|
92
|
+
if ! kill -0 "$_parent_pid" 2>/dev/null; then
|
|
93
|
+
set_status "offline"
|
|
94
|
+
exit 0
|
|
95
|
+
fi
|
|
96
|
+
|
|
89
97
|
hb_code=$(curl -s -o /dev/null -w '%{http_code}' -X POST "${auth_header_args[@]}" \
|
|
90
98
|
"${RELAY_URL}/api/agents/${AGENT_ID}/heartbeat" 2>/dev/null)
|
|
91
99
|
|
package/hooks/profile-lib.sh
CHANGED
|
@@ -57,12 +57,13 @@ ar_init_profile() {
|
|
|
57
57
|
esac
|
|
58
58
|
profile_meta=$(printf '%s' "$AR_PROFILE_JSON" | jq -c 'if (.meta | type) == "object" then .meta else {} end' 2>/dev/null || printf '{}')
|
|
59
59
|
AR_META_JSON=$(jq -n \
|
|
60
|
+
--arg provider "$provider" \
|
|
60
61
|
--arg cwd "${PWD:-}" \
|
|
61
62
|
--arg approval "$AR_APPROVAL" \
|
|
62
63
|
--arg profile "$AR_PROFILE_NAME" \
|
|
63
64
|
--argjson channels "$AR_CHANNELS_JSON" \
|
|
64
65
|
--argjson profileMeta "$profile_meta" \
|
|
65
|
-
'$profileMeta + {cwd: $cwd, approvalMode: $approval, channels: $channels} + (if $profile != "" then {profile: $profile} else {} end)')
|
|
66
|
+
'$profileMeta + {provider: $provider, cwd: $cwd, approvalMode: $approval, channels: $channels} + (if $profile != "" then {profile: $profile} else {} end)')
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
ar_message_matches_channels() {
|
package/hooks/session-end.sh
CHANGED
|
@@ -12,6 +12,15 @@ instance_state="/tmp/agent-relay-instance-${PPID}.state"
|
|
|
12
12
|
if [ -f "$instance_state" ]; then
|
|
13
13
|
agent_id=$(head -1 "$instance_state" 2>/dev/null)
|
|
14
14
|
if [ -n "$agent_id" ]; then
|
|
15
|
+
# Kill the poll-inbox process so it stops heartbeating.
|
|
16
|
+
poll_pid_file="/tmp/agent-relay-poll-${agent_id}.pid"
|
|
17
|
+
if [ -f "$poll_pid_file" ]; then
|
|
18
|
+
poll_pid=$(cat "$poll_pid_file" 2>/dev/null)
|
|
19
|
+
if [ -n "$poll_pid" ] && kill -0 "$poll_pid" 2>/dev/null; then
|
|
20
|
+
kill "$poll_pid" 2>/dev/null
|
|
21
|
+
fi
|
|
22
|
+
rm -f "$poll_pid_file"
|
|
23
|
+
fi
|
|
15
24
|
printf 'offline\n' > "/tmp/agent-relay-status-${agent_id}.state"
|
|
16
25
|
curl -s -X PATCH "${RELAY_URL}/api/agents/${agent_id}/status" "${auth_header_args[@]}" \
|
|
17
26
|
-H 'Content-Type: application/json' \
|
package/package.json
CHANGED