OpenCode usage data provider for `mngr usage` (per-agent in-process plugin that captures per-message cost + tokens)
Project description
imbue-mngr-opencode-usage
OpenCode data provider for mngr usage. Single responsibility: install a second
in-process TypeScript plugin into each OpenCode agent so each assistant message
appends one event to $MNGR_AGENT_STATE_DIR/events/opencode/usage/events.jsonl.
The mngr usage CLI walks those events files itself (see imbue-mngr-usage).
How the pieces fit
mngr_opencode_usage's on_after_provisioning hookimpl
└─→ installs <config_dir>/plugin/mngr_opencode_usage_plugin.ts
(alongside mngr_opencode's lifecycle plugin; OpenCode auto-loads plugin/*.ts)
OpenCode serve process, on each assistant message.updated
└─→ mngr_opencode_usage_plugin.ts
└─→ events/opencode/usage/events.jsonl (append one cost_snapshot event)
mngr usage
└─→ aggregate_usage_source hookimpl (claims the "opencode" source)
└─→ aggregate_session_incremental: sum each session's messages
All file I/O goes through host.write_text_file, so provisioning works for local
and remote agents.
What gets captured
OpenCode computes cost and tokens per message and exposes them on each assistant
message.updated event. The writer emits, per message, a self-contained event
carrying:
cost.total_cost_usd-- OpenCode's own per-message cost (provenance is REPORTED; no estimation needed).tokens--{input, output, cache_read, cache_creation}(reasoning folded into output), for auditability.model-- the provider-qualified<providerID>/<modelID>.session_id+message_id-- the reader sums per session, keeping the freshest event permessage_idso a streaming message's re-fires collapse to its final reading.
Why session-incremental
OpenCode reports each message's own cost, not a session running total. So the
writer is stateless -- it appends one self-contained event per message and keeps
nothing in memory. The reader (aggregate_session_incremental) recomputes each
session's total from the append-only log, which makes it robust across
mngr stop/start (a fresh serve process with empty memory loses no history).
cost_mode is API_KEY: OpenCode bills against a real provider key, so the cost
is real spend, never an imputed subscription value.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file imbue_mngr_opencode_usage-0.1.1.tar.gz.
File metadata
- Download URL: imbue_mngr_opencode_usage-0.1.1.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67cdbaca301001f7b76854be9489e48e3d7743836ddf88c1dc963e2467e8dbc6
|
|
| MD5 |
bf2f178c57c973caee85610096d1f05c
|
|
| BLAKE2b-256 |
3790b51032ea030b70599330ae98643d8e47812c0405f1a617cb2876d4302373
|
Provenance
The following attestation bundles were made for imbue_mngr_opencode_usage-0.1.1.tar.gz:
Publisher:
publish.yml on imbue-ai/mngr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imbue_mngr_opencode_usage-0.1.1.tar.gz -
Subject digest:
67cdbaca301001f7b76854be9489e48e3d7743836ddf88c1dc963e2467e8dbc6 - Sigstore transparency entry: 1858307629
- Sigstore integration time:
-
Permalink:
imbue-ai/mngr@ed465f3fc2a0b4ad935d473b03bcffb205fac223 -
Branch / Tag:
refs/tags/v0.2.17 - Owner: https://github.com/imbue-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ed465f3fc2a0b4ad935d473b03bcffb205fac223 -
Trigger Event:
push
-
Statement type:
File details
Details for the file imbue_mngr_opencode_usage-0.1.1-py3-none-any.whl.
File metadata
- Download URL: imbue_mngr_opencode_usage-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c110d614539546cf0c5499308bf7a7c2ff9848fc624a0415be01e3c75cc2769
|
|
| MD5 |
199ae022cbde80635a12c2da0e24e520
|
|
| BLAKE2b-256 |
56005ba60b32f5162ec0eab3c7c2f4fa80a05c6b26ca44f9b09fa04228631b86
|
Provenance
The following attestation bundles were made for imbue_mngr_opencode_usage-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on imbue-ai/mngr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imbue_mngr_opencode_usage-0.1.1-py3-none-any.whl -
Subject digest:
7c110d614539546cf0c5499308bf7a7c2ff9848fc624a0415be01e3c75cc2769 - Sigstore transparency entry: 1858308310
- Sigstore integration time:
-
Permalink:
imbue-ai/mngr@ed465f3fc2a0b4ad935d473b03bcffb205fac223 -
Branch / Tag:
refs/tags/v0.2.17 - Owner: https://github.com/imbue-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ed465f3fc2a0b4ad935d473b03bcffb205fac223 -
Trigger Event:
push
-
Statement type: