Revert "Remove 9p-read-inbox script"

This reverts commit 748c32aa05.
This commit is contained in:
Levi Neely 2026-02-18 22:18:29 +01:00
parent e5b77b0d27
commit 01efe06831
1 changed files with 46 additions and 0 deletions

46
scripts/9p-read-inbox Executable file
View File

@ -0,0 +1,46 @@
#!/bin/bash
# Read next message from bot's inbox and mark it complete
# Usage: 9p-read-inbox [--help]
set -e
if [ "$1" = "--help" ]; then
echo "Usage: 9p-read-inbox"
echo "Read the next message from the bot's inbox and mark it complete"
exit 0
fi
if [ -z "$AGENT_ID" ]; then
echo "Error: AGENT_ID environment variable not set" >&2
exit 1
fi
INBOX_PATH="agent/$AGENT_ID/inbox"
# List messages
MESSAGES=$(9p ls "$INBOX_PATH" 2>/dev/null) || {
echo "Error: Failed to list inbox" >&2
exit 1
}
if [ -z "$MESSAGES" ]; then
echo "No messages"
exit 0
fi
# Read first message
FIRST_MSG=$(echo "$MESSAGES" | head -1)
MSG_JSON=$(9p read "$INBOX_PATH/$FIRST_MSG") || {
echo "Error: Failed to read message" >&2
exit 1
}
# Display the message body
echo "$MSG_JSON" | jq -r '"[Message from \(.from)]", "Type: \(.type)", "Subject: \(.subject)", "", .body'
# Mark as complete by writing to ctl file (strip .json extension)
MSG_ID="${FIRST_MSG%.json}"
echo "complete $MSG_ID" | 9p write "agent/$AGENT_ID/ctl" || {
echo "Warning: Failed to mark message as complete" >&2
exit 1
}