CostEstimate interface and getSessionInfo() extracts cost from agents — but there's no persistent storage, no CLI reports, no dashboard widget, and no team aggregation.| Aspect | Status |
|---|---|
| Cost interface | ✓ Exists — CostEstimate { inputTokens, outputTokens, estimatedCostUsd } in types.ts |
| Agent extraction | ✓ Exists — Agent.getSessionInfo() returns AgentSessionInfo with optional cost field |
| Session timestamps | ✓ Exists — Session.createdAt, Session.lastActivityAt, Session.restoredAt |
| Persistent storage | ✗ Missing — cost data lives only in memory during session, not persisted |
| CLI reports | ✗ Missing — no ao usage command |
| Dashboard widget | ✗ Missing — dashboard shows session status but not cost/token consumption |
| Team aggregation | ✗ Missing — no per-model, per-day, or per-team reports |
CostEstimate, getSessionInfo(), timestamps) but the data evaporates when a session ends. Teams running 5-10 agents need historical reports: "How much did this sprint cost?" and "Is Claude Code more cost-effective than Codex for our codebase?" The data is there — it just needs to be persisted and surfaced.ao usage CLI command for quick terminal reportsgithub.com/Yeachan-Heo/oh-my-claudecode/src/team/usage-tracker.ts
The oh-my-claudecode tracker is designed for their team/worker model. AO's equivalent concepts:
| oh-my-claudecode | AO equivalent |
|---|---|
| Worker | Session (one agent working on one task) |
| Team | Orchestrator instance (all sessions for a project) |
| Task | Issue/ticket being worked on |
| Prompt chars | Prompt chars (keep as-is, or upgrade to token counts if available) |
// ~/.agent-orchestrator/usage.jsonl
// One entry per completed interaction
{"sessionId":"abc-123","taskId":"#42","model":"claude-code","startTime":"2026-03-19T06:00:00Z","endTime":"2026-03-19T06:12:34Z","wallClockMs":754000,"promptChars":24500,"responseChars":18200,"promptTokens":null,"responseTokens":null,"status":"completed"}
{"sessionId":"abc-123","taskId":"#42","model":"claude-code","startTime":"2026-03-19T06:12:35Z","endTime":"2026-03-19T06:15:02Z","wallClockMs":147000,"promptChars":8200,"responseChars":5100,"promptTokens":null,"responseTokens":null,"status":"completed"}
| Source | What to take |
|---|---|
| oh-my-claudecode/usage-tracker.ts | Core tracking logic, JSONL write pattern, report aggregation. ~150 lines, port directly. |
| oh-my-claudecode/worker-health.ts | Complementary — tracks uptime, error rates. Could merge into same tracker for richer data. |
AO types.ts (39K) | Already defines CostEstimate { inputTokens, outputTokens, estimatedCostUsd } and AgentSessionInfo.cost. Build on this, don't reinvent. |
AO session-manager.ts (82K) | Session lifecycle events already exist (created, started, completed, failed). Hook into these for usage data capture. |
| AO dashboard | packages/web/src/components/ — add usage widget to SessionDetail and Dashboard views. |
Read oh-my-claudecode/src/team/usage-tracker.ts end-to-end. Note the interface, storage pattern, and report generation methods. ~30 minutes.
Create packages/core/src/usage-tracker.ts. Reuse existing interfaces from types.ts:
// Already in types.ts:
// interface CostEstimate { inputTokens: number; outputTokens: number; estimatedCostUsd: number }
// interface AgentSessionInfo { agentSessionId; summary; cost?: CostEstimate }
// interface Session { id; createdAt; lastActivityAt; agentInfo: AgentSessionInfo | null }
// NEW: Persistent usage entry (combines existing data)
interface UsageEntry {
sessionId: string;
projectId: string;
issueId: string | null;
agentName: string; // from Session.agentInfo or agent plugin name
startTime: string; // from Session.createdAt
endTime: string; // from Session.lastActivityAt at completion
wallClockMs: number; // endTime - startTime
inputTokens: number; // from CostEstimate
outputTokens: number; // from CostEstimate
estimatedCostUsd: number; // from CostEstimate
status: 'completed' | 'failed' | 'timeout';
}
Implement append-only JSONL writer. File: ~/.agent-orchestrator/usage.jsonl
appendEntry(entry: UsageEntry) — append one JSON linereadEntries(filter?: { since?: Date, sessionId?: string }) — read and parseusage.jsonl.1No external deps — just fs.appendFileSync.
In AO's core session manager, add hooks:
Look at packages/core/src/ for existing lifecycle events to hook into.
Create report functions (port from oh-my-claudecode):
generateReport(entries: UsageEntry[]): UsageReportperSessionReport(sessionId: string) — time, chars, model for one sessionperModelReport() — aggregate by model (Claude vs Codex vs Aider)dailyReport(date: Date) — all usage for one daycostEstimate(report: UsageReport) — rough $ estimate based on model pricingao usage CLI CommandAdd to packages/cli/src/commands/usage.ts:
$ ao usage
# Shows today's usage summary
$ ao usage --session abc-123
# Shows usage for specific session
$ ao usage --since 2026-03-15
# Shows usage since date
$ ao usage --by-model
# Breakdown by model (Claude vs Codex vs Aider)
$ ao usage --cost
# Rough cost estimate based on model pricing
Add usage visualization to packages/web/:
Use simple SVG charts — no charting library needed for v1.
ao usage shows accurate datausage.jsonlao usage CLI command shows summary, per-session, per-model, and cost estimates