feat(tokens): report per-session token usage to the dashboard#52
Merged
Conversation
Codex CLI's rollout transcript uses a different shape than Claude Code, so the shared SDK summarizeTranscriptUsage (Anthropic-only) returns nothing for it. Add a Codex-specific parser (summarizeCodexTranscriptUsage) that reads the event_msg/token_count events (cumulative total_token_usage) and turn_context model, splitting cached tokens out of input_tokens to match the Claude convention. Post through the shared SDK transport (client.recordTokenUsage). Bumps @armoriq/sdk to ^0.4.3 (the token methods only exist in 0.4.x; the prior ^0.3.8 pin left the token code dead). Sends product="armorcodex" explicitly so a single generic API key works. Adds unit tests for the parser. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add config.productSlug ("armorcodex") and use it for the token-usage report
instead of a hard-coded string, matching ArmorClaude. Product attribution for
intent/audit/sessions is handled backend-side by classifyProductFromSource
(agent_id -> product), so no per-product API key is required.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Aniketvish0
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Reports per-session LLM token usage from ArmorCodex to the ArmorIQ dashboard so the Token Usage page (tools.armoriq) is populated — reaching parity with ArmorClaude.
Why it was broken
summarizeTranscriptUsage,recordTokenUsage) that only exist in@armoriq/sdk0.4.x, while the plugin pinned^0.3.8— so the code was dead.summarizeTranscriptUsageonly parses Claude Code'smessage.usageshape and returns[]for Codex CLI's rollout transcript (event_msg→token_count→total_token_usage).How
@armoriq/sdk→^0.4.3.summarizeCodexTranscriptUsage(scripts/lib/token-usage.mjs): reads the cumulativetotal_token_usageandturn_context.model, splittingcached_input_tokensout ofinput_tokensto match the Claude convention. Posts through the sharedclient.recordTokenUsage.product="armorcodex"(fromconfig.productSlug) explicitly, so a single product-agnostic API key works.Tests
node --test tests/*.test.mjs: 98 pass / 0 fail, including 6 new parser tests.🤖 Generated with Claude Code