diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-22 13:56:04 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-22 13:56:04 -0500 |
| commit | 05ba59526425e1d2c2614b6444735da06c6dcf7f (patch) | |
| tree | e074f170052279004d69bfb62fb765c752e8c7e5 /Omni/Agent | |
| parent | 10a2b488519c061eb86c9147cc96b38c82f51ef8 (diff) | |
| parent | 326309f82408eb29c520ec83cff9bf66c9dd780a (diff) | |
Merge branch 'review/t-rWcqsDZFM.3' into live
Diffstat (limited to 'Omni/Agent')
| -rw-r--r-- | Omni/Agent/DESIGN.md | 2 | ||||
| -rwxr-xr-x | Omni/Agent/monitor-worker.sh | 47 | ||||
| -rwxr-xr-x | Omni/Agent/monitor.sh | 68 |
3 files changed, 58 insertions, 59 deletions
diff --git a/Omni/Agent/DESIGN.md b/Omni/Agent/DESIGN.md index 2d1e6e3..3ff00fc 100644 --- a/Omni/Agent/DESIGN.md +++ b/Omni/Agent/DESIGN.md @@ -72,7 +72,7 @@ The Haskell implementation should replicate the logic of `start-worker.sh` but w ### 4.3 Logging - Continue writing raw Amp logs to `_/llm/amp.log` in the worker directory. -- `agent log` reads this file and applies the filtering logic (currently in `monitor-worker.sh` jq script) using Haskell (Aeson). +- `agent log` reads this file and applies the filtering logic (currently in `monitor.sh` jq script) using Haskell (Aeson). - **UI Design**: - **Two-line Status**: The CLI should maintain two reserved lines at the bottom (or top) of the output for each worker: - **Line 1 (Meta)**: `[Worker: omni-worker-1] Task: t-123 | Files: 3 | Credits: $0.45 | Time: 05:23` diff --git a/Omni/Agent/monitor-worker.sh b/Omni/Agent/monitor-worker.sh deleted file mode 100755 index 2638e2d..0000000 --- a/Omni/Agent/monitor-worker.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -set -e - -# Omni/Agent/monitor-worker.sh -# Monitors the worker agent's activity by filtering the debug log. -# Usage: ./Omni/Agent/monitor-worker.sh [worker-directory-name] - -WORKER_NAME="${1:-omni-worker-1}" -REPO_ROOT="$(git rev-parse --show-toplevel)" -WORKER_PATH="$REPO_ROOT/../$WORKER_NAME" -LOG_FILE="$WORKER_PATH/_/llm/amp.log" - -if [ ! -f "$LOG_FILE" ]; then - echo "Waiting for log file at $LOG_FILE..." - while [ ! -f "$LOG_FILE" ]; do sleep 1; done -fi - -echo "Monitoring Worker Agent in '$WORKER_PATH'..." -echo "Press Ctrl+C to stop." -echo "------------------------------------------------" - -# Tail the log and use jq to parse/filter relevant events -# We handle JSON parse errors gracefully (in case of partial writes) -tail -f "$LOG_FILE" | grep --line-buffered "^{" | jq -R -r ' -try ( - fromjson | - if .message == "executing 1 tools in 1 batch(es)" then - "🤖 THOUGHT: Planning tool execution (" + (.batches[0][0] // "unknown") + ")" - elif .message == "Tool Bash - checking permissions" then - empty - elif .message == "Tool Bash permitted - action: allow" then - "🔧 TOOL: Bash command executed" - elif .toolName != null and .message == "Processing tool completion for ledger" then - "✅ TOOL: " + .toolName + " completed" - elif .message == "ide-fs" and .method == "readFile" then - "📂 READ: " + .path - elif .message == "System prompt build complete (no changes)" then - "🧠 THINKING..." - elif .message == "System prompt build complete (first build)" then - "🚀 STARTING new task context" - elif .level == "error" then - "❌ ERROR: " + .message - else - empty - end -) catch empty -' diff --git a/Omni/Agent/monitor.sh b/Omni/Agent/monitor.sh index 1626354..e57611f 100755 --- a/Omni/Agent/monitor.sh +++ b/Omni/Agent/monitor.sh @@ -1,29 +1,75 @@ #!/usr/bin/env bash # Omni/Agent/monitor.sh # Monitor the logs of a worker agent -# Usage: ./Omni/Agent/monitor.sh [worker-name] +# Usage: ./Omni/Agent/monitor.sh [--raw] [worker-name] + +set -e + +RAW_MODE=false +WORKER="omni-worker-1" + +# Parse arguments +while [[ "$#" -gt 0 ]]; do + case $1 in + --raw) RAW_MODE=true ;; + *) WORKER="$1" ;; + esac + shift +done -WORKER="${1:-omni-worker-1}" REPO_ROOT="$(git rev-parse --show-toplevel)" WORKER_DIR="$REPO_ROOT/../$WORKER" +LOG_FILE="$WORKER_DIR/_/llm/amp.log" if [ ! -d "$WORKER_DIR" ]; then echo "Error: Worker directory '$WORKER_DIR' not found." - echo "Usage: $0 [worker-name]" + echo "Usage: $0 [--raw] [worker-name]" exit 1 fi -LOG_FILE="$WORKER_DIR/_/llm/amp.log" - echo "Monitoring worker: $WORKER" echo "Watching log: $LOG_FILE" +if [ "$RAW_MODE" = true ]; then + echo "Mode: RAW output" +else + echo "Mode: FORMATTED output" +fi echo "---------------------------------------------------" # Wait for log file to appear -while [ ! -f "$LOG_FILE" ]; do - echo "Waiting for log file to be created..." - sleep 2 -done +if [ ! -f "$LOG_FILE" ]; then + echo "Waiting for log file at $LOG_FILE..." + while [ ! -f "$LOG_FILE" ]; do + sleep 1 + done +fi -# Tail the log file -tail -f "$LOG_FILE" +if [ "$RAW_MODE" = true ]; then + tail -f "$LOG_FILE" +else + # Tail the log and use jq to parse/filter relevant events + tail -f "$LOG_FILE" | grep --line-buffered "^{" | jq -R -r ' + try ( + fromjson | + if .message == "executing 1 tools in 1 batch(es)" then + "🤖 THOUGHT: Planning tool execution (" + (.batches[0][0] // "unknown") + ")" + elif .message == "Tool Bash - checking permissions" then + empty + elif .message == "Tool Bash permitted - action: allow" then + "🔧 TOOL: Bash command executed" + elif .toolName != null and .message == "Processing tool completion for ledger" then + "✅ TOOL: " + .toolName + " completed" + elif .message == "ide-fs" and .method == "readFile" then + "📂 READ: " + .path + elif .message == "System prompt build complete (no changes)" then + "🧠 THINKING..." + elif .message == "System prompt build complete (first build)" then + "🚀 STARTING new task context" + elif .level == "error" then + "❌ ERROR: " + .message + else + empty + end + ) catch empty + ' +fi |
