Skip to main content

imbue-mngr-claude-usage

Claude data provider for mngr usage. Single responsibility: install a tiny statusline shim into each Claude agent so each render appends one event to $MNGR_AGENT_STATE_DIR/events/claude/usage/events.jsonl. The event carries three things from the Claude Code statusline payload: rate_limits (Pro/Max only), cost (always), and session_id (always). The mngr usage CLI walks those events files itself (see imbue-mngr-usage).

How the pieces fit

mngr_claude_usage's on_before_provisioning hookimpl
  └─→ writes <work_dir>/.claude/settings.local.json statusLine.command
  └─→ installs <state_dir>/commands/claude_statusline.sh (the shim)
  └─→ installs <state_dir>/commands/claude_usage_writer.sh (the writer)
  └─→ captures any pre-existing user statusLine.command into
      <state_dir>/commands/user_statusline_cmd (the sidecar)

Claude Code statusline render (every turn)
  └─→ <work_dir>/.claude/settings.local.json's statusLine.command
        └─→ claude_statusline.sh
              ├─→ claude_usage_writer.sh
              │     └─→ events/claude/usage/events.jsonl (append one event)
              └─→ user's pre-existing statusLine.command (chain through, if any)

mngr usage
  └─→ list_agents (mngr core's CEL-filterable enumeration)
        └─→ for each matching agent: scan events, aggregate by (source, session_id),
            render per-session costs + freshest rate limits

All file I/O goes through host.read_text_file / host.write_file, so the provisioner works for local and remote agents (Modal, vps_docker, lima, etc.).

What gets captured under each auth mode

The Claude Code statusline payload's contents depend on how the user is authenticated:

Field Pro/Max subscription API key (ANTHROPIC_API_KEY)
rate_limits Present after the first API response of the session Not emitted at all
cost Present Present
session_id Present Present

So mngr usage shows rate-limit windows only for subscribers, but cost-per-session works under both auth modes. The writer emits one event whenever either rate_limits or cost is present -- so an API-key user still gets cost tracking. The reader uses the presence/absence of rate_limits to classify each Claude Code process as SUBSCRIPTION (cost is imputed by Claude Code, not billable) or API_KEY (cost is real billable spend), and exposes the two aggregates separately: api_cost.total_cost_usd > 5.0 predicates real spend (the case here), while subscription_cost.total_cost_usd > 50.0 predicates imputed value-received under a flat subscription.

session_id is carried alongside cost to anchor the cost reading to a specific Claude Code session. Cost resets per session, so a delta across snapshots is only meaningful within one session_id.

Caveat: multiple Pro/Max accounts share the claude source

What's not filtered is the case where multiple Pro/Max accounts contribute to the same claude source -- the statusline payload has no per-account identifier, so mngr usage can't tell "used 5h: 73%" from account A apart from "5h: 9%" from account B. The aggregation rules will silently mix them:

  • Rate-limit windows are reduced freshest-wins per source, so the displayed five_hour / seven_day reading is for whichever account rendered most recently -- not any specific one.
  • Cost is grouped per-session (and per-(agent, Claude Code process) upstream), so per-session records in sessions[] stay correct individually. But the per-mode aggregates subscription_cost.* / api_cost.* (and the human subscription cost (imputed): / api cost: lines) sum across every session in the recency window of the corresponding mode regardless of account, and sessions[0] is just whichever session last rendered. Subscription accounts and API-key accounts stay distinguishable in the split (the auth mode is detected per process), but two Pro/Max accounts both contributing to subscription_cost are not.

This is rare in practice (one user = one Anthropic account), but if you run multiple Claude Code sessions logged into different Pro/Max accounts, treat the aggregated mngr usage view as ambiguous across accounts. There's no field in the payload that would let us label or warn from inside the writer; the only paths to resolution are (a) capture auth-source from a different surface (e.g. Claude Code hooks expose apiKeySource in their input -- not implemented here) or (b) shard the source name per account via writer config (also not implemented).

Metadata

Release files for imbue-mngr-claude-usage 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imbue-mngr-claude-usage 0.1.6
File Size Uploaded
imbue_mngr_claude_usage-0.1.6.tar.gz 23.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for imbue-mngr-claude-usage 0.1.6
File Interpreter ABI Platform
imbue_mngr_claude_usage-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 35.1 kB

Release files / imbue_mngr_claude_usage-0.1.6.tar.gz

Download URL imbue_mngr_claude_usage-0.1.6.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
87138fb5aa9942c566539c869e0b94ac38ebe618394ba844a20b12fe50571072
BLAKE2b-256 checksum
How to use checksums
67179d0cd28041196d034835335949e8c998c3548963ff2c10b122a79384308d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.

Transparency log

Release files / imbue_mngr_claude_usage-0.1.6-py3-none-any.whl

Download URL imbue_mngr_claude_usage-0.1.6-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d9d847c4b30af878b8338fe6c1887039c60e0627ffffef33a08441a29244a05
BLAKE2b-256 checksum
How to use checksums
a03e84ebc6a7bf6617964589a9f23c9f920e9a43700c2a61d9f6e4b7813debd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page