o: fix bypass agent filter to use agent ID instead of name

OLLIE_UNAME in bypass requests is the agent ID, not name.
Look up agent ID from idx before filtering.
This commit is contained in:
Levi Neely 2026-10-09 13:05:38 +02:00
parent 9fb150b6fe
commit 8793202ef5
1 changed files with 18 additions and 6 deletions

View File

@ -298,9 +298,13 @@ cmd_bypass() {
local arr local arr
arr=$(echo "$pending" | jq 'if type == "array" then . else [.] end' 2>/dev/null) arr=$(echo "$pending" | jq 'if type == "array" then . else [.] end' 2>/dev/null)
# Filter by agent if agent context is set # Filter by agent if agent context is set (need to look up agent ID)
if [[ -n "$CTX_AGENT" ]]; then if [[ -n "$CTX_AGENT" ]]; then
arr=$(echo "$arr" | jq --arg agent "$CTX_AGENT" '[.[] | select(.env.OLLIE_UNAME == $agent)]' 2>/dev/null) local agent_id
agent_id=$(ollie-9p read "session/$CTX_SESSION/agent/idx" 2>/dev/null | awk -F'\t' -v name="$CTX_AGENT" '$3 == name { print $2; exit }')
if [[ -n "$agent_id" ]]; then
arr=$(echo "$arr" | jq --arg agent "$agent_id" '[.[] | select(.env.OLLIE_UNAME == $agent)]' 2>/dev/null)
fi
fi fi
local count local count
@ -345,9 +349,13 @@ cmd_approve() {
local arr local arr
arr=$(echo "$pending" | jq 'if type == "array" then . else [.] end' 2>/dev/null) arr=$(echo "$pending" | jq 'if type == "array" then . else [.] end' 2>/dev/null)
# Filter by agent if agent context is set # Filter by agent if agent context is set (need to look up agent ID)
if [[ -n "$CTX_AGENT" ]]; then if [[ -n "$CTX_AGENT" ]]; then
arr=$(echo "$arr" | jq --arg agent "$CTX_AGENT" '[.[] | select(.env.OLLIE_UNAME == $agent)]' 2>/dev/null) local agent_id
agent_id=$(ollie-9p read "session/$CTX_SESSION/agent/idx" 2>/dev/null | awk -F'\t' -v name="$CTX_AGENT" '$3 == name { print $2; exit }')
if [[ -n "$agent_id" ]]; then
arr=$(echo "$arr" | jq --arg agent "$agent_id" '[.[] | select(.env.OLLIE_UNAME == $agent)]' 2>/dev/null)
fi
fi fi
# Find the request to approve # Find the request to approve
@ -413,9 +421,13 @@ cmd_deny() {
local arr local arr
arr=$(echo "$pending" | jq 'if type == "array" then . else [.] end' 2>/dev/null) arr=$(echo "$pending" | jq 'if type == "array" then . else [.] end' 2>/dev/null)
# Filter by agent if agent context is set # Filter by agent if agent context is set (need to look up agent ID)
if [[ -n "$CTX_AGENT" ]]; then if [[ -n "$CTX_AGENT" ]]; then
arr=$(echo "$arr" | jq --arg agent "$CTX_AGENT" '[.[] | select(.env.OLLIE_UNAME == $agent)]' 2>/dev/null) local agent_id
agent_id=$(ollie-9p read "session/$CTX_SESSION/agent/idx" 2>/dev/null | awk -F'\t' -v name="$CTX_AGENT" '$3 == name { print $2; exit }')
if [[ -n "$agent_id" ]]; then
arr=$(echo "$arr" | jq --arg agent "$agent_id" '[.[] | select(.env.OLLIE_UNAME == $agent)]' 2>/dev/null)
fi
fi fi
# Find the request to deny # Find the request to deny