mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-25 01:35:31 +00:00
* feat(providers): let providers report session and turn metrics Providers know things about a session and a turn that Paseo cannot derive: timing, token flow, cache use, cost, the model that answered. They can now report them as label/value rows that Paseo carries to clients unchanged, so each provider decides which metrics make sense and how they read. Session metrics live on the agent record and snapshot. Turn metrics are stamped on the turn's footer row (last assistant message, else last tool call) so they survive reload, pagination and a daemon restart, and so the live turn_completed event and a later timeline fetch agree. Provider history replay restores both. Metrics are sanitized once where they enter the agent manager. The wire schemas validate whole messages, so one malformed row from a provider would otherwise make clients drop an entire snapshot, turn event or timeline page. A live completed turn with no Model metric gets the agent's model, so every provider shows model attribution before it is instrumented. Replayed turns do not: they may have run on a different model than the agent has now. Plugin providers publish session metrics behind a negotiated `session.metrics` capability because an older daemon closes a connection that sends an event type it does not know. Turn metrics ride an existing event that older daemons strip, so they need no gate. The wire additions are optional fields on existing schemas only. * feat(providers): report session and turn metrics from OpenCode, OMP, Pi and Claude Each provider now attaches metrics to turn_completed and emits session_metrics_updated, live and when history is replayed. - Live turns end on the adapter's clock. A provider's message timestamps can come from another clock. - Tool time merges overlapping runs, so parallel tools count once. - A total that is missing any part is hidden, so a partial total is never shown. - Replayed history reports metrics only for turns that finished, which matches live, where failed and interrupted turns report none. - Claude reports cost as a running total for each query(). A resumed query starts that total from a saved one, so a turn's cost is the change since the previous result of the same query. The first turn of a query shows no cost. - Claude transcripts do not record result messages, so replayed Claude history has no turn metrics. - Session metrics come from each provider's own cumulative counters. The cache hit is the last reply's or the last turn's, because a session-wide figure blends prompts from before and after compactions. * feat(app): show provider session and turn metrics Session metrics appear in the context window details, between the context summary and the account usage cards. A provider-reported Cost row replaces the app's own session cost line. Each completed turn with metrics gets a stats button in its footer: a hover card on web, a press-opened tooltip on native wide screens, and a sheet on compact screens. The context window sheet becomes a shared DetailsSheet so both use the same content-sized sheet. Metrics ride on the row that hosts the turn's footer (the turn's last assistant message, else its last tool call), the same row the daemon stamps. Live turn_completed events and timeline pages both stamp that row, so a refetch agrees with what the live event showed. The daemon updates session metrics without bumping updatedAt, like usage, so a stale buffered upsert may still carry the newest metrics and is accepted for that field. * fix(app): keep a turn's stats after the cached timeline reloads The local timeline cache dropped turnMetrics when it saved a turn's footer row. After a page reload the cached rows painted without the stats icon, and the catch-up fetch had no new entries to stamp them from. * fix(providers): keep imported session stats and never count a steered turn short Importing a Pi, Oh My Pi or OpenCode v2 session dropped the stats the provider returned with its history, so imported chats showed none until a forced replay. Import now carries them the way replay does. Replaying a Pi or Oh My Pi transcript read a prompt that steered a running turn as the start of a new turn, so the steered turn's stats counted only the steps after the steer. A turn that follows one ending on tools now reports no total, because the transcript reads the same as a stop and a new prompt. * fix(providers): keep stats through merged messages and plugin imports, start Pi first-token timing at the request A message the timeline merges from several chunks keeps the stats stamped on its last chunk. Plugin session imports carry the stats the plugin replayed, through the same history reader the other providers use. Steers queued together after an unclear turn stay unclear instead of attributing the final reply to the wrong turn. Pi measures time to first token from the request, not the first reply header. * fix(providers): carry a turn's stats onto the message the timeline merges from text chunks The previous change put the carry-over in the reasoning merge. The assistant message merge dropped the stats of its last chunk, so an imported reply of two text blocks lost its Turn stats button. * fix(providers): carry a turn's stats onto the tool card the timeline merges from updates An imported turn that ends on a tool call stamps the stats on the tool's last update. The tool merge kept the first update's fields, so the stats were lost. * fix(opencode): replay no session stats for a session that has none An empty OpenCode session replayed a session stats event with no metrics, which broke the empty-history check in the versioned runtime test.
@getpaseo/protocol
Shared Paseo protocol schemas, codecs, and wire types.
Stability
This package is public so Paseo's published packages can depend on it cleanly. It is not a stable public API yet.
Schemas, exports, wire helpers, and types may change or disappear in any release without advance notice. Use it outside Paseo at your own risk until the package is explicitly documented as stable.