Files
omarchy/test/shell.d/agent-usage-fireworks-scanner-test.sh
T
+14 75250d37ac Fix Codex limits, Claude counting, and agent usage reliability from community PRs (#14049)
* Read Codex app-server replies from the raw fd (#13703)

* Resolve Codex through mise which instead of running the lazy launcher (#13109)

* Skip the Codex app-server probe when there are no credentials (#13106)

Adapted: credentials are checked in the home being probed rather than in
the CODEX_HOME environment variable, since each registered account is
probed in its own home, so a signed-out secondary account isn't hidden
behind the primary's login. A home without credentials reports "Waiting
for auth" like any other signed-out home. The credentials store setting is
read with tomllib, so a single-quoted value counts too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Show the Codex CLI's own error when its app-server dies (#8977)

Detect an app-server that exits or stops answering, and report the end of
its stderr instead of a bare RPC method name. Rebased onto the raw-fd
reply reader; the switch from "-a on-request" to "-a never" is left out,
keeping the current approval flags.

* Count pi sessions when HOME is a git checkout (#13209)

* Count only OpenAI-backed native sessions as Codex usage (#12032)

* Deduplicate Pi usage across forked sessions (#8602)

* Skip unchanged native Codex token snapshots (#10531)

* Count omp and pi profile sessions in the agent usage collectors (#9546)

`omp --profile=<name>` (and pi's equivalent) relocates the whole agent
tree under <base>/profiles/<name>/. The Claude and Codex collectors only
ever scanned <base>/agent/sessions, so a subscription driven entirely
through a profile was invisible to the agents panel: no tokens by day, no
tokens by model, no prompt or session counts.

Discover the profile roots alongside the default one. Sessions are keyed
by file path, so a profile adds sessions instead of double-counting the
default root, and a missing or unreadable profiles directory leaves the
existing behavior untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014zFbJcDEEpV5BAmsH6kAB3

* Skip unrelated Codex session lines before JSON parsing (#12803)

Adapted: session_meta lines also pass the pre-filter, since the provider
filter from #12032 reads them to skip rollouts served by a non-OpenAI
provider.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Read only the Codex session files that changed since the last scan (#12595)

Native Codex rollouts keep per-file totals between runs, replayed while a
file's mtime and size are unchanged. Rebased onto the session_meta
provider filter, snapshot dedup, and line pre-filter, which now live in
the per-file reader. pi and omp sessions are left out of the per-file
cache: a forked pi session repeats its parent's messages, so they are
deduplicated across the whole tree on every scan.

* Count streamed Claude messages by their highest-output usage line (#10606)

Claude Code writes a streamed assistant response as several transcript
lines that share one message id, one per content block. Each line
carries a usage object. The first line's output_tokens is a placeholder,
often 1, and the last line has the real count. Input and cache fields
usually match across the lines.

The scanner dedupes by message id and keeps the first line it sees, so
it under-counts output tokens. On a machine with 2,577 transcripts it
reported 39.0M output tokens against 60.1M used, a 35% shortfall. Input
and both cache fields differed by under 0.01%.

Keep the line with the highest output count, with the last one scanned
winning a tie. The whole line is kept because a response can fall back
to another model mid-stream. Those lines are separate snapshots with
different cache figures and a different model, and taking a maximum per
field across them over-counts cache tokens and credits the wrong model.

The zero-usage check now runs before dedup, so a zero-usage first line
no longer claims a message id and hides a later line with real usage.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: GPT-6 Astra <noreply@openai.com>

* Index Claude transcripts so the agents refresh reads only what was appended (#8313)

omarchy-agent-usage-claude re-parsed every line of every transcript under
~/.claude/projects on each refresh: no mtime cutoff, no memory of the last
pass. The agents widget is on by default and ticks every 15 minutes, so the
cost grew for the life of the machine. After one month here that was 803
files, 640 MB, 127k lines and 57k JSON parses per tick, about 1 core-second,
pushed through the page cache every quarter hour forever.

Keep a per-file index next to the scan cache: the unique usage records
already parsed out of each transcript and the byte offset they end at. A
file whose size and mtime match is not opened; a file that grew is read
from the stored offset; a file that shrank or was rewritten is read from
the start. --force drops the index and rescans from scratch.

The summary is built from the indexed records in the same directory order
the walk always used. That matters: when a resumed session carries earlier
messages, the same message id appears in two files with different usage,
and the first file visited wins. 91 ids differed on this machine; sorting
the walk moved one model's output total by 25k tokens. Output is now
byte-identical to the previous scan on a frozen copy of the corpus, cold,
warm, and after an append.

Warm refresh: 1.0 s -> 0.10 s of CPU, of which the scan itself is 70 ms;
the index for this corpus is 2.9 MB.

Adapted:
- Rebased onto #10606: the highest-output rule for streamed messages now
  lives where the index parses records, and decides between files too.
- The index records the timezone it was written in, and a change rereads
  every transcript, since its records hold local days.
- A file only counts as appended to when its inode and the hash of what
  was already read still match, so a transcript replaced by a larger one,
  or rewritten in place, is read from the start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Label a Claude Team seat by its subscription, not its rate-limit tier (#11109)

The collector built the plan label from the OAuth rateLimitTier first, so a
Team premium seat, which runs on default_claude_max_5x, showed in the agents
panel as "Max 5x". Lead with subscriptionType and keep the multiplier as its
qualifier: Max still reads "Max 5x", a Team seat reads "Team 5x".

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Label the Claude plan from the profile the CLI refreshes (#7225)

Adapted: the profile is found the same way current_account_id() finds it,
now shared as profile_path(): ~/.claude.json for the default home, the
home's own .claude.json otherwise. The original fell back to ~/.claude.json
for any home without CLAUDE_CONFIG_DIR set, so a secondary account read the
primary's tier. The profile's tier also keeps the subscription in the label,
so a Team seat stays "Team" (#11109).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Call a lapsed Claude access token paused, not signed out (#8093)

* Refresh Claude usage after the clock moves backwards (#9956)

* Bound unreadable Claude transcript warnings (#12414)

* Count Claude usage from opencode v2 sessions (#13894)

* Reload agent usage records when an inotify watch fails to rearm (#10067)

* Reload agent usage records after each update run instead of on a timer

Rather than #10067's two-minute timer per record, reload every record when
the omarchy-agent-usage-update process exits, the moment its files can have
been replaced. A reload that finds a file unchanged keeps its record, so the
panel isn't stirred up by identical data. The grep test now runs the QML
functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Show the agent status when the trouble line has no help text (#8497)

* Clear stale agent login guidance after a successful probe (#8892)

* Clear the Grok login hint after a successful probe

#8892 cleared the default login hint after a successful probe in the
Claude and Codex collectors; Grok's collector had the same stale hint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Read Fireworks credentials from pi's auth.json (#7455)

The Fireworks collector skipped pi, Omarchy's default agent, when
walking its credential ladder, so a machine signed in to Fireworks only
through pi (/login fireworks) never showed the tab. Insert the key pi
stores in $PI_CODING_AGENT_DIR/auth.json (default ~/.pi/agent) between
the firectl auth.ini and the opencode fallback.

pi keys can be literals, $ENV_VAR/${ENV_VAR} references, or !command
shell lookups. The collector resolves the first two; command lookups
stay pi-only and are skipped rather than sent to the API verbatim.

* Call a lapsed Grok access token paused, not signed out

Grok's access token lives six hours and Grok mints a new one from its
refresh token whenever it starts, so a lapsed one is routine. Reporting
it as an expired sign-in made the panel offer Sign-in required several
times a day, sending people through grok login for nothing. With a
refresh token present it now reads as paused, like Claude's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep showing Grok's last limits while it sits idle

While Grok hasn't run, nothing on the machine has spent its allowance,
so with a refresh token on hand the last numbers still stand: they show
as current rather than dimmed under a status line. A weekly window that
reset in the meantime starts over at 0%, a whole number of weeks on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Ask for a Grok sign-in once its refresh token is past 30 days

A refresh token older than Grok's 30-day sign-in can't renew anything,
so the panel offers Sign-in required again instead of showing the last
limits as current. With nothing cached yet it says to start Grok, rather
than showing an empty section without a word.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Check both ends of what the Claude index read before resuming a transcript

A transcript rewritten in place could grow and change only after its
first kilobytes, and the index took it for an append. It now compares
the last kilobytes before the resume point too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Simplify the agent usage collectors

- Codex: pass the forced-scan choice down instead of a module global, make
  the per-file reader's cache arguments required, shrink the cache record
  check, and drop guards for shapes that can't occur: an empty launcher
  path, realpath raising, mise itself being a lazy launcher, multi-line
  `mise which` output, and probing without a temp file for stderr.
- Claude: decide an append by the digest of both ends of what was read
  alone; the inode and mtime checks it made redundant are gone.
- Snapshot: the device id falls back to the hostname, which always exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Share fixture setup in the agent usage scanner tests

Every fixture home lives under one scratch directory with a single cleanup
trap, instead of a trap rewritten with a longer list for each new home, and
the Codex test builds its signed-in homes with one helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Treat a replaced Claude transcript as new even when its ends match

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Probe Codex without its error text when there's no temporary space

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: tossbaws <17258053+tossbaws@users.noreply.github.com>
Co-authored-by: surim0n <suritech@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: anonwurcod <anonwurcod@proton.me>
Co-authored-by: Kevin Rajan <7121943+kvnloo@users.noreply.github.com>
Co-authored-by: Nate Ashby <nate.ashby11@gmail.com>
Co-authored-by: Aris Gysel <aris.gysel@me.com>
Co-authored-by: Brams <76213579+Brams-s@users.noreply.github.com>
Co-authored-by: This_Is_NPC <gabrielfollone27@gmail.com>
Co-authored-by: sanjyay <102979855+sanjyay@users.noreply.github.com>
Co-authored-by: PapistProtocol <12738904+PapistProtocol@users.noreply.github.com>
Co-authored-by: steez <stevedimakos97@gmail.com>
Co-authored-by: GPT-6 Astra <noreply@openai.com>
Co-authored-by: Ryan Yogan <ryanyogan@gmail.com>
Co-authored-by: Oli Denton <41393837+omdenton@users.noreply.github.com>
Co-authored-by: Igor Kramar <i@ikramar.ru>
Co-authored-by: Martin Eidensten <martin@meibe.se>
Co-authored-by: Romain Perron <rdj.perron@gmail.com>
Co-authored-by: Omarchy Contributor <contributor@users.noreply.github.com>
Co-authored-by: manuaudio <manu@arimaka.com>
Co-authored-by: Tyler South <tsouth2@gmail.com>
Co-authored-by: whathek <Hek846@users.noreply.github.com>
Co-authored-by: Ty Richards <me@tyrichards.com>
2026-10-02 22:03:07 -04:00

281 lines
12 KiB
Bash
Executable File

#!/bin/bash
source "$(dirname "$0")/base-test.sh"
require_command jq
require_command python3
TEST_HOME=$(mktemp -d)
trap 'rm -rf "$TEST_HOME"' EXIT
auth_file="$TEST_HOME/auth.ini"
cat >"$auth_file" <<'EOF'
[default]
api_key = fw_test
account_id = example
EOF
mkdir -p "$TEST_HOME/.config/omarchy/agents"
cat >"$TEST_HOME/.config/omarchy/agents/fireworks.json" <<'EOF'
{
"accountId": "example",
"fundedAmount": 20,
"fundedAt": "2026-07-01"
}
EOF
# Without credentials the collector must still print a full, hidden-by-default
# record: the update runner writes whatever valid JSON appears on stdout.
no_key=$(HOME="$TEST_HOME" XDG_CONFIG_HOME="$TEST_HOME/.config" XDG_DATA_HOME="$TEST_HOME/.local/share" \
PI_CODING_AGENT_DIR="$TEST_HOME/.pi/agent" FIREWORKS_API_KEY="" FIREWORKS_AUTH_PATH="$TEST_HOME/missing.ini" "$ROOT/bin/omarchy-agent-usage-fireworks")
[[ $(jq -r '.id + ":" + (.ready | tostring) + ":" + (.hasPromptStats | tostring)' <<<"$no_key") == "fireworks:false:false" ]] ||
fail "Fireworks collector prints a valid record without credentials" "$no_key"
pass "Fireworks collector prints a valid record without credentials"
result=$(python3 - "$ROOT/bin/omarchy-agent-usage-fireworks" "$auth_file" "$TEST_HOME/.config" "$TEST_HOME/.local/share" "$TEST_HOME/.pi/agent" <<'PY'
import importlib.machinery
import importlib.util
import json
import os
import sys
import time
from datetime import date
from decimal import Decimal
from pathlib import Path
collector_path = str(Path(sys.argv[1]))
auth_path = Path(sys.argv[2])
os.environ["XDG_CONFIG_HOME"] = sys.argv[3]
os.environ["XDG_DATA_HOME"] = sys.argv[4]
# Bucket dates resolve in local time, so pin the zone or the fixtures below
# would shift by a day depending on where the test runs. The env account id
# would override the config file, so it must not leak in from the runner.
os.environ["TZ"] = "UTC"
time.tzset()
os.environ.pop("FIREWORKS_ACCOUNT_ID", None)
loader = importlib.machinery.SourceFileLoader("fireworks_collector", collector_path)
spec = importlib.util.spec_from_loader(loader.name, loader)
scanner = importlib.util.module_from_spec(spec)
loader.exec_module(scanner)
RealFireworksClient = scanner.FireworksClient
payload = {
"serverlessCosts": [
{
"startTime": "2026-07-31T00:00:00Z",
"promptTokens": "100",
"cachedPromptTokens": "40",
"uncachedPromptTokens": "60",
"completionTokens": "20",
"group": {"model_name": "accounts/fireworks/models/kimi-k2p5"},
},
{
"startTime": "2026-07-30T00:00:00Z",
"promptTokens": "300",
"cachedPromptTokens": "0",
"completionTokens": "50",
"group": {"model_name": "accounts/fireworks/models/deepseek-v3p2"},
},
{
"startTime": "2026-07-20T00:00:00Z",
"promptTokens": "500",
"cachedPromptTokens": "0",
"completionTokens": "100",
"group": {"model_name": "accounts/fireworks/models/kimi-k2p5"},
},
]
}
summary = scanner.summarize_usage(payload, date(2026, 7, 31))
api_key, account_id = scanner.read_auth_file(auth_path)
summary["apiKey"] = api_key
summary["accountId"] = account_id
summary["money"] = float(scanner.money_value({"units": "12", "nanos": 430000000}))
# The opencode key only wins when no explicit key, firectl login, or pi
# login exists. Pin the pi dir first so a developer's real ~/.pi/agent
# credentials cannot leak into the fixture run.
pi_dir = Path(sys.argv[5])
os.environ["PI_CODING_AGENT_DIR"] = str(pi_dir)
data_home = Path(os.environ["XDG_DATA_HOME"])
opencode_auth = data_home / "opencode" / "auth.json"
opencode_auth.parent.mkdir(parents=True, exist_ok=True)
opencode_auth.write_text(json.dumps({"fireworks-ai": {"type": "api", "key": "fw_opencode"}}))
os.environ.pop("FIREWORKS_API_KEY", None)
opencode_key, _ = scanner.credentials(Path("/nonexistent/auth.ini"), {})
firectl_key, _ = scanner.credentials(auth_path, {})
summary["opencodeFallback"] = opencode_key == "fw_opencode" and firectl_key == "fw_test"
# A pi login is the next rung below firectl, above opencode.
pi_dir.mkdir(parents=True, exist_ok=True)
(pi_dir / "auth.json").write_text(json.dumps({"fireworks": {"type": "api_key", "key": "fw_pi"}}))
pi_key, _ = scanner.credentials(Path("/nonexistent/auth.ini"), {})
firectl_still_wins, _ = scanner.credentials(auth_path, {})
summary["piFallback"] = pi_key == "fw_pi" and firectl_still_wins == "fw_test"
# pi key syntax: $ENV references resolve, missing ones stay unresolved, and
# !command lookups are skipped and fall through to opencode.
os.environ["FW_TEST_ENV_KEY"] = "fw_from_env"
summary["piEnvKey"] = scanner.resolve_pi_key("$FW_TEST_ENV_KEY") == "fw_from_env"
summary["piMissingEnvKey"] = scanner.resolve_pi_key("$FW_DEFINITELY_MISSING") == ""
(pi_dir / "auth.json").write_text(json.dumps({"fireworks": {"type": "api_key", "key": "!secret-tool lookup fw"}}))
command_key, _ = scanner.credentials(Path("/nonexistent/auth.ini"), {})
summary["piCommandKeySkipped"] = command_key == "fw_opencode"
class WorkingClient:
def __init__(self, api_key, base_url):
pass
def request(self, path, query=None, body=None):
raise scanner.FireworksError("The Fireworks API key cannot read billing data")
def usage(self, account_id, start_day, end_day):
return payload
def account(self, account_id):
return {}
def spent(self, account_id, start_at, end_at):
return Decimal("8.60")
class BalanceFailureClient(WorkingClient):
def spent(self, account_id, start_at, end_at):
raise scanner.FireworksError("Billing scope denied")
class LiveBalanceClient(WorkingClient):
def request(self, path, query=None, body=None):
assert path.endswith(":getBalance")
return {"balance": {"units": "12", "nanos": 500000000}}
os.environ["FIREWORKS_API_KEY"] = "fw_test"
scanner.FireworksClient = WorkingClient
record = scanner.scan("https://example.invalid", auth_path)
summary["record"] = {
"schemaVersion": record["schemaVersion"],
"id": record["id"],
"ready": record["ready"],
"hasPromptStats": record["hasPromptStats"],
"scope": record["scope"],
"tierLabel": record["tierLabel"],
"limits": record["limits"],
"balance": record["balance"],
}
# billingUsage pages long ranges; usage() must follow continuation tokens.
pages = {
"": {"serverlessCosts": [{"startTime": "2026-07-30T00:00:00Z"}], "nextPageToken": "p2"},
"p2": {"serverlessCosts": [{"startTime": "2026-07-31T00:00:00Z"}]},
}
paging_client = RealFireworksClient("fw_test", "https://example.invalid")
paging_queries = []
def paged_request(path, query=None, body=None):
paging_queries.append(dict(query or {}))
return pages[str((query or {}).get("pageToken") or "")]
paging_client.request = paged_request
merged = paging_client.usage("example", date(2026, 7, 1), date(2026, 8, 1))
summary["paginationMerges"] = (
len(merged["serverlessCosts"]) == 2
and len(paging_queries) == 2
and paging_queries[0]["startTime"] == "2026-07-01T00:00:00Z"
)
scanner.FireworksClient = LiveBalanceClient
live = scanner.scan("https://example.invalid", auth_path)
summary["liveBalance"] = live["balance"]
scanner.FireworksClient = BalanceFailureClient
scanned = scanner.scan("https://example.invalid", auth_path)
summary["balanceFailurePreservesTokens"] = (
scanned["ready"] is True
and "balance" not in scanned
and scanned["modelUsage"]["kimi-k2.5"]["outputTokens"] == 120
and scanned["usageStatusText"] == "Balance unavailable"
)
# East of Greenwich, a local-midnight bucket starts on the previous UTC date;
# the row must still land on the local day it names, and the query window
# must ask for local midnights expressed in UTC.
os.environ["TZ"] = "Etc/GMT-2"
time.tzset()
summary["bucketDayIsLocal"] = scanner.row_date({"startTime": "2026-07-30T22:00:00Z"}) == "2026-07-31"
summary["windowIsLocalMidnight"] = scanner.local_midnight_utc(date(2026, 7, 31)) == "2026-07-30T22:00:00Z"
print(json.dumps(summary, separators=(",", ":")))
PY
)
[[ $(jq -r '.todayTotalTokens' <<<"$result") == "120" ]] ||
fail "Fireworks collector totals today's uncached, cached, and output tokens once" "$result"
pass "Fireworks collector totals today's token categories once"
[[ $(jq -c '.modelUsage["kimi-k2.5"]' <<<"$result") == '{"inputTokens":560,"outputTokens":120,"cacheReadInputTokens":40,"cacheCreationInputTokens":0}' ]] ||
fail "Fireworks collector keeps cache separate in model totals" "$result"
pass "Fireworks collector keeps cache separate in model totals"
[[ $(jq -r '.recentDays[-1].messageCount' <<<"$result") == "120" ]] ||
fail "Fireworks collector builds the seven-day token series" "$result"
pass "Fireworks collector builds the seven-day token series"
[[ $(jq -r '.activeDays' <<<"$result") == "3" ]] ||
fail "Fireworks collector retains the 30-day model window" "$result"
pass "Fireworks collector retains the 30-day model window"
[[ $(jq -r '.apiKey + ":" + .accountId' <<<"$result") == "fw_test:example" ]] ||
fail "Fireworks collector reads firectl credentials" "$result"
pass "Fireworks collector reads firectl credentials"
[[ $(jq -r '.money' <<<"$result") == "12.43" ]] ||
fail "Fireworks collector parses Money units and nanos" "$result"
pass "Fireworks collector parses Money units and nanos"
[[ $(jq -c '.record | {schemaVersion, id, ready, hasPromptStats, scope, tierLabel, limits}' <<<"$result") == '{"schemaVersion":1,"id":"fireworks","ready":true,"hasPromptStats":false,"scope":"account","tierLabel":"Prepaid","limits":[]}' ]] ||
fail "Fireworks collector prints the display-ready record contract" "$result"
pass "Fireworks collector prints the display-ready record contract"
[[ $(jq -r '.paginationMerges' <<<"$result") == "true" ]] ||
fail "Fireworks collector follows billingUsage continuation tokens" "$result"
pass "Fireworks collector follows billingUsage continuation tokens"
[[ $(jq -r '.windowIsLocalMidnight' <<<"$result") == "true" ]] ||
fail "Fireworks collector requests local-midnight windows in UTC" "$result"
pass "Fireworks collector requests local-midnight windows in UTC"
[[ $(jq -c '.record.balance' <<<"$result") == '{"remaining":11.4,"funded":20.0,"spent":8.6,"currency":"USD","estimated":true}' ]] ||
fail "Fireworks collector estimates the balance from configured funding" "$result"
pass "Fireworks collector estimates the balance from configured funding"
[[ $(jq -c '.liveBalance' <<<"$result") == '{"remaining":12.5,"funded":20.0,"spent":7.5,"currency":"USD","estimated":false}' ]] ||
fail "Fireworks collector prefers the live getBalance ledger when the key can read it" "$result"
pass "Fireworks collector prefers the live getBalance ledger when the key can read it"
[[ $(jq -r '.balanceFailurePreservesTokens' <<<"$result") == "true" ]] ||
fail "Fireworks collector preserves tokens when balance lookup fails" "$result"
pass "Fireworks collector preserves tokens when balance lookup fails"
[[ $(jq -r '.bucketDayIsLocal' <<<"$result") == "true" ]] ||
fail "Fireworks collector dates buckets by local day east of Greenwich" "$result"
pass "Fireworks collector dates buckets by local day east of Greenwich"
[[ $(jq -r '.opencodeFallback' <<<"$result") == "true" ]] ||
fail "Fireworks collector falls back to the opencode key last" "$result"
pass "Fireworks collector falls back to the opencode key last"
[[ $(jq -r '.piFallback' <<<"$result") == "true" ]] ||
fail "Fireworks collector falls back to the pi login before opencode" "$result"
pass "Fireworks collector falls back to the pi login before opencode"
[[ $(jq -r '.piEnvKey' <<<"$result") == "true" ]] ||
fail "Fireworks collector resolves env-var pi keys" "$result"
pass "Fireworks collector resolves env-var pi keys"
[[ $(jq -r '.piMissingEnvKey' <<<"$result") == "true" ]] ||
fail "Fireworks collector treats missing env references as unresolved" "$result"
pass "Fireworks collector treats missing env references as unresolved"
[[ $(jq -r '.piCommandKeySkipped' <<<"$result") == "true" ]] ||
fail "Fireworks collector skips command-lookup pi keys and falls through" "$result"
pass "Fireworks collector skips command-lookup pi keys and falls through"