Add docs/toys.md: inbox_refresh.py and msgtrace.py
This commit is contained in:
parent
dc18f005e2
commit
cd487a61bc
|
|
@ -0,0 +1,24 @@
|
|||
# Toys
|
||||
|
||||
Small utilities in `scripts/` that build on the 9P API.
|
||||
|
||||
## inbox_refresh.py
|
||||
|
||||
Auto-refreshes the `/AnviLLM/inbox` window in Acme whenever a new message arrives. Listens to `anvillm/events` for `UserRecv` events and rewrites the inbox window body via the Acme 9P filesystem.
|
||||
|
||||
```sh
|
||||
python3 scripts/inbox_refresh.py
|
||||
```
|
||||
|
||||
Requires an open `/AnviLLM/inbox` window in Acme.
|
||||
|
||||
## msgtrace.py
|
||||
|
||||
Real-time message sequence diagram generator. Listens to `anvillm/events` for `UserSend`/`BotSend` events and renders a PlantUML sequence diagram in a local web UI. Useful for visualizing inter-agent communication.
|
||||
|
||||
```sh
|
||||
python3 scripts/msgtrace.py
|
||||
# Open http://localhost:8089
|
||||
```
|
||||
|
||||
The web UI auto-refreshes every 2 seconds, supports pan/zoom, and has a reset button to clear the trace. Requires `plantuml` in PATH.
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#!/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
|
||||
}
|
||||
12
scripts/Alog
12
scripts/Alog
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env rc
|
||||
|
||||
# Alog - Stream AnviLLM audit log to Acme window
|
||||
|
||||
# Create window and get its ID
|
||||
winid=`{9p read acme/new/ctl | awk '{print $1}'}
|
||||
echo name /AnviLLM/Audit | 9p write acme/$winid/ctl
|
||||
echo clean | 9p write acme/$winid/ctl
|
||||
|
||||
# Stream audit log to window
|
||||
9p read anvillm/audit | 9p write acme/$winid/data
|
||||
|
||||
Reference in New Issue