agent-relay-plugin 0.6.0 → 0.6.1
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-plugin/plugin.json +1 -1
- package/hooks/poll-inbox.sh +21 -8
- package/package.json +1 -1
package/hooks/poll-inbox.sh
CHANGED
|
@@ -26,6 +26,7 @@ fi
|
|
|
26
26
|
pid_file="/tmp/agent-relay-poll-${AGENT_ID}.pid"
|
|
27
27
|
status_file="/tmp/agent-relay-status-${AGENT_ID}.state"
|
|
28
28
|
delivered_file="/tmp/agent-relay-delivered-${AGENT_ID}.queue"
|
|
29
|
+
cursor_file="/tmp/agent-relay-cursor-${AGENT_ID}.state"
|
|
29
30
|
project=$(basename "${PWD:-unknown}")
|
|
30
31
|
if [ -n "$CLAUDE_RIG_NAME" ]; then rig="$CLAUDE_RIG_NAME"
|
|
31
32
|
elif [ -n "$CLAUDE_CONFIG_DIR" ]; then rig=$(basename "$CLAUDE_CONFIG_DIR")
|
|
@@ -44,6 +45,19 @@ fetch_cursor() {
|
|
|
44
45
|
esac
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
read_saved_cursor() {
|
|
49
|
+
local cursor
|
|
50
|
+
cursor=$(head -1 "$cursor_file" 2>/dev/null || true)
|
|
51
|
+
case "$cursor" in
|
|
52
|
+
''|*[!0-9]*) return 1 ;;
|
|
53
|
+
*) printf '%s\n' "$cursor" ;;
|
|
54
|
+
esac
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
save_cursor() {
|
|
58
|
+
printf '%s\n' "$1" > "$cursor_file"
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
current_status() {
|
|
48
62
|
local status
|
|
49
63
|
status=$(head -1 "$status_file" 2>/dev/null || true)
|
|
@@ -107,8 +121,10 @@ set_status() {
|
|
|
107
121
|
-H 'Content-Type: application/json' -d "{\"status\":\"$1\"}" 2>/dev/null
|
|
108
122
|
}
|
|
109
123
|
|
|
110
|
-
#
|
|
111
|
-
|
|
124
|
+
# First start bootstraps at current max; restarted monitors resume their saved
|
|
125
|
+
# cursor so messages that arrived during downtime are still delivered.
|
|
126
|
+
since_id=$(read_saved_cursor || fetch_cursor || echo 0)
|
|
127
|
+
save_cursor "$since_id"
|
|
112
128
|
|
|
113
129
|
fail_streak=0
|
|
114
130
|
marked_ready=false
|
|
@@ -132,12 +148,8 @@ while true; do
|
|
|
132
148
|
# Agent was pruned — re-register instead of exiting.
|
|
133
149
|
if [ "$hb_code" = "404" ]; then
|
|
134
150
|
if re_register; then
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
hb_code="200"
|
|
138
|
-
else
|
|
139
|
-
hb_code="000"
|
|
140
|
-
fi
|
|
151
|
+
marked_ready=false
|
|
152
|
+
hb_code="200"
|
|
141
153
|
else
|
|
142
154
|
hb_code="000"
|
|
143
155
|
fi
|
|
@@ -207,6 +219,7 @@ while true; do
|
|
|
207
219
|
done < <(echo "$msgs" | jq -c '.[]')
|
|
208
220
|
if [ "$delivery_failed" = "false" ]; then
|
|
209
221
|
since_id=$(echo "$msgs" | jq '[.[].id] | max')
|
|
222
|
+
save_cursor "$since_id"
|
|
210
223
|
fi
|
|
211
224
|
fi
|
|
212
225
|
|
package/package.json
CHANGED