Commit Graph

4 Commits

Author SHA1 Message Date
antonov b223f51540 Implement the session cost plugin
Host half wraps globalThis.fetch to read usage.cost out of provider
responses (tee, never clone) and listens on the llm/stream seam for the
session; the two halves join on the generation id. Client half adds one
pill to the composer dock under its own id, so the harness's native stats
stay where they are.

Verified against the live API: three calls in one session (agent reply,
compaction, session title) attributed with per-purpose totals, an unknown
session answered with null, the ledger written and reloaded across
instances, and the pill rendering only when a cost exists.
2026-10-15 13:33:05 +03:00
antonov aaeb0a908c Record install requirements and the restart constraint
The plugin manager accepts an absolute local path, so the package can be
installed from this workspace. Two requirements make or break it: a DSH
peer range (runtime is 0.2.0-rc.2) and a declared bundle patch. Notes that
HMR is absent from the desktop profile, so a restart is required and the
restart is therefore the last step.
2026-10-15 13:04:07 +03:00
antonov c9d2314bb2 Verify the tee interception on a live stream
Spike proves response.body.tee() splits a real routerai SSE stream: the
consumer sees chunks progressively (first at 1ms of 1643ms) and our branch
still recovers the generation id and usage.cost. It also found a real
defect -- a rebuilt Response loses url, which the OpenAI SDK reads -- and
that Object.defineProperty is the only way to restore it.
2026-10-15 13:02:32 +03:00
antonov 82f8b7baef Add design for session cost pill in the composer dock
Records what was verified against the live routerai API and the harness
code: the provider reports usage.cost on every response, the harness
discards it in mapUsage, and the cost can still be recovered by wrapping
globalThis.fetch while session attribution rides the llm/stream seam.
2026-10-15 13:00:55 +03:00