diff --git a/data/scripts/o b/data/scripts/o index c765609..2b7fe5e 100755 --- a/data/scripts/o +++ b/data/scripts/o @@ -286,19 +286,24 @@ cmd_bypass() { local bypass_path="session/$CTX_SESSION/bypass" local pending pending=$(ollie-9p read "$bypass_path" 2>/dev/null || true) - if [[ -z "$pending" ]]; then + if [[ -z "$pending" || "$pending" == "[]" || "$pending" == "null" ]]; then echo "no pending bypass request" return 0 fi - local id cmd cwd agent - id=$(echo "$pending" | jq -r '.id' 2>/dev/null) - cmd=$(echo "$pending" | jq -r '.cmd' 2>/dev/null) - cwd=$(echo "$pending" | jq -r '.cwd' 2>/dev/null) - agent=$(echo "$pending" | jq -r '.env.OLLIE_UNAME // "unknown"' 2>/dev/null) - echo "id: $id" - echo "agent: $agent" - echo "cwd: $cwd" - echo "cmd: $cmd" + # Handle both single object and array of objects + local count + count=$(echo "$pending" | jq 'if type == "array" then length else 1 end' 2>/dev/null) + if [[ "$count" -eq 0 ]]; then + echo "no pending bypass request" + return 0 + fi + echo "$count pending bypass request(s):" + echo + # Normalize to array and iterate + echo "$pending" | jq -r ' + (if type == "array" then . else [.] end) | .[] | + "id: \(.id)\nagent: \(.env.OLLIE_UNAME // "unknown")\ncwd: \(.cwd)\ncmd: \(.cmd | split("\n")[0])\n" + ' 2>/dev/null } cmd_approve() {