Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/omarchy-agent-usage-codex
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def fetch_codex_rpc():

try:
proc = subprocess.Popen(
[codex, "-s", "read-only", "-a", "untrusted", "app-server"],
[codex, "-s", "read-only", "-a", "never", "app-server"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
Expand Down
10 changes: 9 additions & 1 deletion test/shell.d/agent-usage-codex-scanner-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ mkdir -p "$TEST_HOME/.codex/sessions/$(date +%Y/%m/%d)" "$TEST_HOME/bin"
cat >"$TEST_HOME/bin/codex" <<'EOF'
#!/bin/bash

if [[ -n ${CODEX_ARGS_LOG:-} ]]; then
printf '%s\n' "$*" >"$CODEX_ARGS_LOG"
fi

while read -r request; do
id=$(jq -r '.id // empty' <<<"$request")
method=$(jq -r '.method // empty' <<<"$request")
Expand Down Expand Up @@ -40,9 +44,13 @@ cat >"$session" <<EOF
{"timestamp":"$timestamp","type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":180,"cached_input_tokens":110,"output_tokens":30,"reasoning_output_tokens":8,"total_tokens":210},"last_token_usage":{"input_tokens":80,"cached_input_tokens":50,"output_tokens":10,"reasoning_output_tokens":3,"total_tokens":90}}}}
EOF

result=$(HOME="$TEST_HOME" CODEX_HOME="$TEST_HOME/.codex" XDG_DATA_HOME="$TEST_HOME/.local/share" PATH="$TEST_HOME/bin:$PATH" \
result=$(HOME="$TEST_HOME" CODEX_HOME="$TEST_HOME/.codex" XDG_DATA_HOME="$TEST_HOME/.local/share" CODEX_ARGS_LOG="$TEST_HOME/codex-args" PATH="$TEST_HOME/bin:$PATH" \
"$ROOT/bin/omarchy-agent-usage-codex")

[[ $(<"$TEST_HOME/codex-args") == "-s read-only -a never app-server" ]] ||
fail "Codex collector uses the current non-interactive approval policy" "$(<"$TEST_HOME/codex-args")"
pass "Codex collector uses the current non-interactive approval policy"

[[ $(jq -r '.todayTotalTokens' <<<"$result") == "210" ]] ||
fail "Codex collector counts each turn once" "$result"
pass "Codex collector counts each turn once"
Expand Down