agent-relay-plugin 0.4.30 → 0.4.33
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/approval-gate.sh
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
# Agent Relay plugin — approval gate for PreToolUse and PermissionDenied hooks.
|
|
3
3
|
# Enforces AGENT_RELAY_APPROVAL/profile approval policy: open (default), guarded, read-only.
|
|
4
4
|
|
|
5
|
+
if [ "${AGENT_RELAY_DISABLED:-}" = "1" ]; then
|
|
6
|
+
exit 0
|
|
7
|
+
fi
|
|
8
|
+
|
|
5
9
|
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
6
10
|
source "${script_dir}/profile-lib.sh"
|
|
7
11
|
project=$(basename "${PWD:-unknown}")
|
package/hooks/poll-inbox.sh
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
# Each new message prints one stdout line (consumed by Monitor as a notification).
|
|
4
4
|
# Usage: poll-inbox.sh <relay-url> <agent-id> [interval-seconds]
|
|
5
5
|
|
|
6
|
+
if [ "${AGENT_RELAY_DISABLED:-}" = "1" ]; then
|
|
7
|
+
exit 0
|
|
8
|
+
fi
|
|
9
|
+
|
|
6
10
|
RELAY_URL="$1"
|
|
7
11
|
AGENT_ID="$2"
|
|
8
12
|
INTERVAL="${3:-10}"
|
|
@@ -88,6 +92,11 @@ marked_ready=false
|
|
|
88
92
|
# Save parent PID (Claude Code wrapper) — if it dies, we're orphaned.
|
|
89
93
|
_parent_pid="$PPID"
|
|
90
94
|
while true; do
|
|
95
|
+
if [ "${AGENT_RELAY_DISABLED:-}" = "1" ]; then
|
|
96
|
+
set_status "offline"
|
|
97
|
+
exit 0
|
|
98
|
+
fi
|
|
99
|
+
|
|
91
100
|
# Exit if parent process is gone — prevents orphaned monitors from heartbeating forever.
|
|
92
101
|
if ! kill -0 "$_parent_pid" 2>/dev/null; then
|
|
93
102
|
set_status "offline"
|
package/hooks/relay-monitor.sh
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
# Agent Relay — self-contained native monitor
|
|
3
3
|
# Registers this session as an agent, outputs messaging context, then polls inbox.
|
|
4
4
|
# Runs automatically via monitors.json — no user interaction required.
|
|
5
|
-
#
|
|
5
|
+
# CLAUDE_CODE_SESSION_ID = stable session key for state file coordination between monitor and hooks.
|
|
6
|
+
|
|
7
|
+
if [ "${AGENT_RELAY_DISABLED:-}" = "1" ]; then
|
|
8
|
+
exit 0
|
|
9
|
+
fi
|
|
6
10
|
|
|
7
11
|
RELAY_URL="${AGENT_RELAY_URL:-http://localhost:4850}"
|
|
8
12
|
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
@@ -33,15 +37,16 @@ else
|
|
|
33
37
|
fi
|
|
34
38
|
ar_init_profile "claude" "$rig" "$project"
|
|
35
39
|
|
|
40
|
+
session_key="${CLAUDE_CODE_SESSION_ID:-$PPID}"
|
|
36
41
|
if command -v shasum >/dev/null 2>&1; then
|
|
37
|
-
short_pid=$(printf '%s' "$
|
|
42
|
+
short_pid=$(printf '%s' "$session_key" | shasum -a 1 | head -c 6)
|
|
38
43
|
else
|
|
39
|
-
short_pid=$(printf '%s' "$
|
|
44
|
+
short_pid=$(printf '%s' "$session_key" | md5sum | head -c 6)
|
|
40
45
|
fi
|
|
41
46
|
agent_id="${machine}-${rig}-${project}-${short_pid}"
|
|
42
47
|
|
|
43
48
|
# --- Clean up previous agent from this instance ---
|
|
44
|
-
instance_state="/tmp/agent-relay-instance-${
|
|
49
|
+
instance_state="/tmp/agent-relay-instance-${session_key}.state"
|
|
45
50
|
if [ -f "$instance_state" ]; then
|
|
46
51
|
old_agent_id=$(head -1 "$instance_state" 2>/dev/null)
|
|
47
52
|
if [ -n "$old_agent_id" ] && [ "$old_agent_id" != "$agent_id" ]; then
|
package/hooks/session-end.sh
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
# Agent Relay plugin — SessionEnd hook
|
|
3
3
|
# Marks this session's agent as offline using state file written by relay-monitor.
|
|
4
4
|
|
|
5
|
+
if [ "${AGENT_RELAY_DISABLED:-}" = "1" ]; then
|
|
6
|
+
exit 0
|
|
7
|
+
fi
|
|
8
|
+
|
|
5
9
|
RELAY_URL="${AGENT_RELAY_URL:-http://localhost:4850}"
|
|
6
10
|
auth_header_args=()
|
|
7
11
|
if [ -n "${AGENT_RELAY_TOKEN:-}" ]; then
|
|
8
12
|
auth_header_args=(-H "X-Agent-Relay-Token: ${AGENT_RELAY_TOKEN}")
|
|
9
13
|
fi
|
|
10
|
-
|
|
14
|
+
session_key="${CLAUDE_CODE_SESSION_ID:-$PPID}"
|
|
15
|
+
instance_state="/tmp/agent-relay-instance-${session_key}.state"
|
|
11
16
|
|
|
12
17
|
if [ -f "$instance_state" ]; then
|
|
13
18
|
agent_id=$(head -1 "$instance_state" 2>/dev/null)
|
package/hooks/set-status.sh
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
# Agent Relay plugin — status update helper for Claude turn hooks.
|
|
3
3
|
# Usage: set-status.sh <online|idle|busy|offline>
|
|
4
4
|
|
|
5
|
+
if [ "${AGENT_RELAY_DISABLED:-}" = "1" ]; then
|
|
6
|
+
exit 0
|
|
7
|
+
fi
|
|
8
|
+
|
|
5
9
|
status="${1:-}"
|
|
6
10
|
case "$status" in
|
|
7
11
|
online|idle|busy|offline) ;;
|
|
@@ -13,7 +17,8 @@ auth_header_args=()
|
|
|
13
17
|
if [ -n "${AGENT_RELAY_TOKEN:-}" ]; then
|
|
14
18
|
auth_header_args=(-H "X-Agent-Relay-Token: ${AGENT_RELAY_TOKEN}")
|
|
15
19
|
fi
|
|
16
|
-
|
|
20
|
+
session_key="${CLAUDE_CODE_SESSION_ID:-$PPID}"
|
|
21
|
+
instance_state="/tmp/agent-relay-instance-${session_key}.state"
|
|
17
22
|
|
|
18
23
|
if [ ! -f "$instance_state" ]; then
|
|
19
24
|
exit 0
|
package/package.json
CHANGED