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.
Metadata
Release files for imbue-mngr-opencode-usage 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| imbue_mngr_opencode_usage-0.1.1.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| imbue_mngr_opencode_usage-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.8 kB
Release files / imbue_mngr_opencode_usage-0.1.1.tar.gz
| Download URL | imbue_mngr_opencode_usage-0.1.1.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67cdbaca301001f7b76854be9489e48e3d7743836ddf88c1dc963e2467e8dbc6
|
|
BLAKE2b-256 checksum How to use checksums |
3790b51032ea030b70599330ae98643d8e47812c0405f1a617cb2876d4302373
|
| 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 logRelease files / imbue_mngr_opencode_usage-0.1.1-py3-none-any.whl
| Download URL | imbue_mngr_opencode_usage-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c110d614539546cf0c5499308bf7a7c2ff9848fc624a0415be01e3c75cc2769
|
|
BLAKE2b-256 checksum How to use checksums |
56005ba60b32f5162ec0eab3c7c2f4fa80a05c6b26ca44f9b09fa04228631b86
|
| 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