agent-relay-plugin 0.4.34 → 0.4.35
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 +19 -8
- package/package.json +1 -1
package/hooks/poll-inbox.sh
CHANGED
|
@@ -56,11 +56,12 @@ current_status() {
|
|
|
56
56
|
deliver_message() {
|
|
57
57
|
local line="$1"
|
|
58
58
|
if [ "${AGENT_RELAY_CLAUDE_DELIVERY:-monitor}" = "tmux" ] && [ -n "${AGENT_RELAY_CLAUDE_TMUX_SESSION:-}" ] && command -v tmux >/dev/null 2>&1; then
|
|
59
|
-
if tmux
|
|
60
|
-
tmux paste-buffer -t "$AGENT_RELAY_CLAUDE_TMUX_SESSION" 2>/dev/null &&
|
|
59
|
+
if tmux send-keys -t "$AGENT_RELAY_CLAUDE_TMUX_SESSION" -l "$line" 2>/dev/null &&
|
|
61
60
|
tmux send-keys -t "$AGENT_RELAY_CLAUDE_TMUX_SESSION" C-m 2>/dev/null; then
|
|
62
61
|
return 0
|
|
63
62
|
fi
|
|
63
|
+
echo "warn: tmux delivery failed for ${AGENT_RELAY_CLAUDE_TMUX_SESSION}" >&2
|
|
64
|
+
return 1
|
|
64
65
|
fi
|
|
65
66
|
|
|
66
67
|
printf '%s\n' "$line"
|
|
@@ -175,7 +176,8 @@ while true; do
|
|
|
175
176
|
|
|
176
177
|
count=$(echo "$msgs" | jq 'length' 2>/dev/null || echo 0)
|
|
177
178
|
if [ "$count" -gt 0 ] 2>/dev/null && [ "$count" != "0" ]; then
|
|
178
|
-
|
|
179
|
+
delivery_failed=false
|
|
180
|
+
while IFS= read -r msg; do
|
|
179
181
|
mid=$(printf '%s' "$msg" | jq -r '.id')
|
|
180
182
|
claimable=$(printf '%s' "$msg" | jq -r '.claimable // false')
|
|
181
183
|
if [ "$(ar_message_matches_channels "$msg")" != "true" ]; then
|
|
@@ -192,11 +194,20 @@ while true; do
|
|
|
192
194
|
fi
|
|
193
195
|
fi
|
|
194
196
|
|
|
195
|
-
line=$(printf '%s' "$msg" | jq -r '(.meta.pairId //
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
if ! line=$(printf '%s' "$msg" | jq -r '(.meta.pairId // "") as $pair | (if $pair != "" then " [pair:\($pair)]" else "" end) as $pairText | (.body | gsub("\r"; "\\r") | gsub("\n"; "\\n")) as $body | if .type == "system" then "⚠ SYSTEM [msg:\(.id)]\($pairText): \($body)" else "[msg:\(.id)]\($pairText) \(.from) → \(.to) | \(.subject // "(no subject)"): \($body)" end') || [ -z "$line" ]; then
|
|
198
|
+
echo "warn: failed to format relay message ${mid}" >&2
|
|
199
|
+
delivery_failed=true
|
|
200
|
+
continue
|
|
201
|
+
fi
|
|
202
|
+
if deliver_message "$line"; then
|
|
203
|
+
mark_read_or_queue "$mid"
|
|
204
|
+
else
|
|
205
|
+
delivery_failed=true
|
|
206
|
+
fi
|
|
207
|
+
done < <(echo "$msgs" | jq -c '.[]')
|
|
208
|
+
if [ "$delivery_failed" = "false" ]; then
|
|
209
|
+
since_id=$(echo "$msgs" | jq '[.[].id] | max')
|
|
210
|
+
fi
|
|
200
211
|
fi
|
|
201
212
|
|
|
202
213
|
sleep "$INTERVAL"
|
package/package.json
CHANGED