diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a748ff..a4102810 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - **The Overview no longer replaces itself with "This screen hit an error" when the act report has no totals.** The realized-savings figure read `actReport.data.totals.realizedCostUSD` behind a guard on the payload only, so an act report without a `totals` block threw during render and the section's error boundary latched — and because the desktop app repaints the durable report snapshot instantly on the next launch, a single such payload persisted in `localStorage` (one written by an older build that answered `{}`) crashed the Overview on every relaunch. The read now tolerates a missing block and reports $0 saved, which is what the card already shows before the first act report arrives. - **Codex sub-agent rollouts no longer double-count their parent's usage.** A thread spawned as a sub-agent replays its parent's history, including every `token_count` event with its original timestamp, and names the parent under `source.subagent.thread_spawn.parent_thread_id` rather than `forked_from_id`, so the fork guard never saw it and the replayed prefix was counted again per child. The parent id is now read from either field, and the replayed events drop like a fork's. On a corpus with 381 spawned children this removed 405 duplicate calls and 403,712 duplicate cache tokens; rollouts without sub-agents are unchanged. (#1380) - **Shared and MCP-redacted payloads no longer carry pull request urls or owner/repo labels.** `current.pullRequests` survived both passes verbatim: each row's full GitHub url and its `owner/repo#123` label named the repository to a paired peer device and to a name-redacted MCP client, the same class of leak #1337 closed for branch names. Sharing now drops the block outright, the way it already drops the project, session and per-branch rows. The MCP pass with `include_project_names: false` pseudonymizes `url` and `label` from the url — the aggregation key — with the same salted hash as the project and branch pseudonyms, domain-separated so rows referring to the same PR still line up while the cost, calls and totals stay untouched; `include_project_names: true` still sees the real urls and labels. (#1346) +- **Codex sessions routed through codex-cliproxy-gateway now price as the model they wrap instead of silently reading $0.** That gateway keeps Codex's own OpenAI OAuth routing native and forwards only `cliproxy/*` model ids to a local CLIProxyAPI, so every routed session lands in the rollout with a `cliproxy/` model name — sometimes with a CLIProxyAPI provider path behind the wrapper, e.g. `cliproxy/zcode/glm-5.3-flash`. No such name matches a pricing row, so the tokens were counted but the dollars were not: the largest line of a day could sit at $0, and because the models table hides zero-cost rows, routed spend looked absent rather than unpriced. The `cliproxy/` wrapper now peels like the other routing wrappers (OrcaRouter, Cline Pass, `cmd/`, …), and `zcode` joins the known vendor namespaces so a provider path strips to its priced `glm-*` leaf; an unknown vendor behind the wrapper still fails closed rather than pricing at a coincidental row, and routed rows keep their Codex provider while displaying the wrapped model's name. (#1364) - **The menubar refreshes usage within five minutes while a session is running, instead of up to thirty.** The background change guard only stats directories, so a session appending to its transcript looked unchanged and the app skipped every refresh for half an hour; the skip now lasts at most five minutes, and the Kimi Code session store joined the watched roots. - **The Capacity Dock card lists running sessions for providers whose CLI id differs from the dock id.** The card matched live rows against the dock's own identifier ("kimi"), while the CLI reports "kimicode", so a running Kimi Code session read "none running"; the card now matches the provider's payload ids, which also lets the Cursor card count cursor-agent sessions. - **Shared and MCP-redacted payloads no longer carry git branch names or the working directory of a session.** Two identities were riding along in `current`: the `topSessions` rows added in #1316 carry `projectKey`, a dash-encoded absolute path such as `-Users--Projects-`, which `redactProjectNames` left verbatim even when an MCP client asked not to see project names, and the per-branch rows added in #788 carry the raw branch, which both `sanitizeForSharing` and the MCP pass let through, so a branch such as `exp/extraction-arms` reached a shared payload as typed. The MCP pass now hashes `projectKey` with the same salted pseudonym it already applies to `topProjects[].id`, hashes the drill-through `sessionId` on both `topSessions` and `topProjects[].sessionDetails` (a Codex id embeds the rollout timestamp the pass blanks out of `date`), and gives each distinct branch a stable `branch-xxxxxx` pseudonym, keeping the cost, calls and session counts untouched; a `null` branch stays null, because unbranched spend is not a name. Sharing drops the per-branch block outright, the way it already drops the project and session rows, since a pseudonymized branch tells a peer device nothing anyway. Nothing changes for the local menubar, the desktop app or the web dashboard, which read the unsanitized payload, and nothing changes for an MCP caller that passes `include_project_names: true` — it still gets every name as recorded. (#1325, #1321) diff --git a/README.md b/README.md index 40ceab18..52cb3b31 100644 --- a/README.md +++ b/README.md @@ -559,7 +559,7 @@ Left/right arrow keys switch between Today, 7 Days, 30 Days, Month, 6 Months, an ### Pricing -Prices every API call using input, output, cache read, cache write, and web search token counts, with a fast mode multiplier for Claude. Prices are fetched from [LiteLLM](https://github.com/BerriAI/litellm) and cached locally for 24 hours at `~/.cache/codeburn/`. Hardcoded fallbacks for all Claude and GPT-5 models prevent fuzzy-matching mispricing. Routing-gateway model ids are priced as the model they wrap: [OrcaRouter](https://www.orcarouter.ai) fusion route ids peel to their current upstream (`openai/gpt-oss-120b`), `orcarouter/auto` stays unpriced until a live probe pins the rotating target, and a nested upstream spelling (`orcarouter/deepseek/deepseek-v4-pro`) prices at that exact row, so a gateway-routed session reports real spend instead of $0. +Prices every API call using input, output, cache read, cache write, and web search token counts, with a fast mode multiplier for Claude. Prices are fetched from [LiteLLM](https://github.com/BerriAI/litellm) and cached locally for 24 hours at `~/.cache/codeburn/`. Hardcoded fallbacks for all Claude and GPT-5 models prevent fuzzy-matching mispricing. Routing-gateway model ids are priced as the model they wrap: [OrcaRouter](https://www.orcarouter.ai) fusion route ids peel to their current upstream (`openai/gpt-oss-120b`), `orcarouter/auto` stays unpriced until a live probe pins the rotating target, and a nested upstream spelling (`orcarouter/deepseek/deepseek-v4-pro`) prices at that exact row, so a gateway-routed session reports real spend instead of $0. Codex sessions routed through [codex-cliproxy-gateway](https://github.com/aceHubert/codex-cliproxy-gateway) record `cliproxy/` ids — including CLIProxyAPI provider paths like `cliproxy/zcode/glm-5.3-flash` — and the wrapper and the known provider segment peel the same way. ### Task Categories diff --git a/src/models.ts b/src/models.ts index d8c1d7a3..63884d86 100644 --- a/src/models.ts +++ b/src/models.ts @@ -889,14 +889,17 @@ export function resolveCanonicalModelId(model: string): string { // rather than hand-listed so a vendor LiteLLM already knows (`x-ai/`, `qwen/`, // `nousresearch/`, …) is never dropped by a stale list. const EXTRA_NAMESPACES = [ - // Routing wrappers (see ROUTER_PREFIXES); no catalog lists them. - 'cp', 'cline-pass', 'cline-free', 'cmd', 'antigravity', 'orcarouter', + // Routing wrappers (see ROUTER_PREFIXES); no catalog lists them. `cliproxy/` + // is codex-cliproxy-gateway's default route prefix over CLIProxyAPI. + 'cp', 'cline-pass', 'cline-free', 'cmd', 'antigravity', 'orcarouter', 'cliproxy', // LiteLLM route prefixes that never appear as a key prefix. 'litellm_proxy', 'openai_like', // Vendor spellings the catalog indexes under another name: `zhipu` is `z-ai`, // `mimo` is `xiaomi` (BUILTIN_ALIASES maps the bare MiMo ids to `xiaomi/`), // and `kimi/` is a client-side prefix (Codex records `kimi/k3[1m]`). - 'zhipu', 'mimo', 'kimi', + // `zcode/` is CLIProxyAPI's provider spelling for the Z.ai coding plans; the + // bare `glm-*` leaf already prices via its own catalog row, which carries an explicit zero cache-write cost. + 'zhipu', 'mimo', 'kimi', 'zcode', ] // Local runners. Their catalog rows are $0 stubs, so an unlisted local tag must @@ -943,6 +946,12 @@ const ROUTER_PREFIXES = [ /^cmd\//i, /^antigravity\//i, /^orcarouter\//i, + // codex-cliproxy-gateway keeps Codex's own OAuth routing native and forwards + // only `cliproxy/*` ids to CLIProxyAPI, so a routed session records + // `cliproxy/` — and `` can itself be a provider path + // (`cliproxy/zcode/glm-5.3-flash`). Peeling the wrapper lets the one + // known-namespace strip in getCanonicalName reach the priced leaf. + /^cliproxy\//i, // `xiaomi/` is NOT peeled: it is the vendor namespace LiteLLM prices under, // and BUILTIN_ALIASES maps the bare MiMo ids INTO it. Peeling would pull the // opposite way. It stays a known namespace via the catalog-derived set. diff --git a/tests/models.test.ts b/tests/models.test.ts index 80695b09..2eb3637d 100644 --- a/tests/models.test.ts +++ b/tests/models.test.ts @@ -164,7 +164,8 @@ describe('getModelCosts', () => { const known = ['anthropic', 'x-ai', 'xai', 'qwen', 'moonshotai', 'nousresearch', 'kimi', 'litellm_proxy', 'openai_like', 'zhipu', 'mimo', 'xiaomi', - 'cp', 'cline-pass', 'cline-free', 'cmd', 'antigravity', 'orcarouter'] + 'cp', 'cline-pass', 'cline-free', 'cmd', 'antigravity', 'orcarouter', + 'cliproxy', 'zcode'] for (const ns of known) { expect(getModelCosts(`${ns}/zzz-namespace-probe`), ns).not.toBeNull() } @@ -186,12 +187,19 @@ describe('getModelCosts', () => { 'omniroute:antigravity/zzz-router-probe', 'omniroute:cmd/zzz-router-probe', 'omniroute:orcarouter/zzz-router-probe', + 'cliproxy/zzz-router-probe', + 'omniroute:cliproxy/zzz-router-probe', + // codex-cliproxy-gateway ids can carry a CLIProxyAPI provider path behind + // the `cliproxy/` wrapper; the wrapper peels and the known provider + // namespace strips, reaching the priced leaf. + 'cliproxy/zcode/zzz-router-probe', ] for (const id of routed) expect(getModelCosts(id), id).not.toBeNull() expect(getModelCosts('omniroute:nosuchvendor/zzz-router-probe')).toBeNull() // A nested unknown vendor inside a known routing wrapper must fail closed. expect(getModelCosts('omniroute:orcarouter/nosuchvendor/zzz-router-probe')).toBeNull() + expect(getModelCosts('cliproxy/nosuchvendor/zzz-router-probe')).toBeNull() }) it('lets a user price override for a bare id win over the routed catalog row', () => { @@ -236,6 +244,8 @@ describe('resolveCanonicalModelId', () => { expect(resolveCanonicalModelId('kimi-k3')).toBe('kimi-k3') expect(resolveCanonicalModelId('accounts/fireworks/models/glm-5p2')).toBe('glm-5p2') expect(resolveCanonicalModelId('glm-5p2')).toBe('glm-5p2') + expect(resolveCanonicalModelId('cliproxy/claude-fable-5-1')).toBe('claude-fable-5-1') + expect(resolveCanonicalModelId('cliproxy/zcode/glm-5.3-flash')).toBe('glm-5.3-flash') expect(resolveCanonicalModelId('GLM-5.2')).toBe('glm-5p1') expect(resolveCanonicalModelId('gpt-5-fast')).toBe('gpt-5') expect(resolveCanonicalModelId('gpt-5-untracked-xyz')).toBe('gpt-5-untracked-xyz')