UsageMeter
Plan usage or AI credits against a limit: total, usage by category, daily bars toned against the cap, and a warning near the limit.
What one agent run has spent against its cap, live: a credit bar with a tick where the run pauses, and Raise cap near it.
What one agent run is costing as it goes. Not plan usage. Not ContextWindow.
Spend ticks up on a kit Meter. A thin tick marks where the run pauses; near it the card warns and offers Raise cap. Raising the cap keeps the tick where it is and the fill eases down to its new share, so there is more room.
RunCost is one run's spend against its cap. Pass spent and cap as amounts, not a percent, and set status yourself: near-cap and paused show Raise cap, paused shows Resume, done has no actions. Raise cap passes the new cap back; the tick stays at pauseAt% of it. Change pauseAt to move the tick. State words come with an icon, never colour alone. One polite live region announces only near cap, paused at cap and cap raised; translate them with KitLabelsProvider (runNearCap, runPausedAtCap, runCapRaised, runPausesAt).
import { RunCost } from "agentic-ds-kit";From contracts/runcost.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.
| Name | Type | Required | Default | Notes |
|---|---|---|---|---|
| spent | number | Yes | — | Amount spent so far in unit (or currency), not a percent. Without currency, spent and cap share one number of decimals (0–2), e.g. 3.1 / 10.0 credits. |
| cap | number | Yes | — | The run's spend cap. The track runs from 0 to cap. |
| pauseAt | number | No | 80 | Percent of cap where the run pauses: a thin tick on the track with a kit Tooltip (KitLabels runPausesAt, "Pauses at 80%"). Raising cap keeps the tick at pauseAt% and the fill shrinks to its new share; change pauseAt to move the tick, and it slides there. |
| unit | string | No | credits | Word after the amounts, e.g. "credits". Ignored when currency is set. |
| currency | string | No | — | ISO 4217 code, e.g. "USD". Amounts show as money. |
| status | running | near-cap | paused | done | No | running | Set by the caller. running: KitLabels running shimmers. near-cap: KitLabels runNearCap ("Near cap") with a TriangleAlert in status.warningText and icon.warning, and Raise cap. paused: KitLabels paused, Raise cap and Resume; when the fill has reached the tick, a short muted KitLabels runPausedAtCap ("Paused at cap") line too (a manual pause below the tick has none and announces KitLabels paused). done: KitLabels runDone and the final total, no actions. |
| onRaiseCap | function | No | — | Raise cap: outline neutral sm Button, the main action, shown in near-cap and paused. The caller passes the new cap. |
| onPause | function | No | — | Pause: ghost neutral sm Button in running and near-cap. |
| onResume | function | No | — | Resume: ghost neutral sm Button in paused. |
Plan usage or AI credits against a limit: total, usage by category, daily bars toned against the cap, and a warning near the limit.
How full the prompt context is and what uses the space, by segment, with a warning near the limit, Trim oldest and compaction with Undo.
One agent at work: a live clock and running cost lead; finished steps sit in a time strip you can open.
The brief a person hands an agent before it plans: a goal, one-line "done when" checks, optional spend, time and step limits, allowed tools, model and check-in level.