OpenCode Plugin

nexus-cost-control

v2.0.0Published

Token usage and cost tracking for Nexus sessions using native OpenCode message data. Zero external dependencies.

Overview

Tracks token usage and estimated cost for the current Nexus session by aggregating data from OpenCode's native AssistantMessage objects. Each message carries provider-computed cost and detailed token counts (input, output, reasoning, cache read/write). v2.0.0 removed all Helicone dependencies — no external API keys or HTTP requests required. Cost snapshots are automatically appended to the active Nexus session timeline during idle periods.

Key Features

  • Per-session token & cost tracking
  • Auto-snapshot to session timeline
  • Per-model breakdown (input/output/cache)

Registered Hooks

Events this plugin listens to in the OpenCode runtime.

event (session.idle)

Auto-appends cost snapshots to the active Nexus session timeline. Debounced at 5-minute intervals to avoid noise.

Custom Tools

MCP tools this plugin exposes to agents.

nexus_cost_summary

On-demand cost snapshot with input/output/reasoning/cache token counts and estimated cost in USD.

nexus_show_plugins

Discovers all loaded Nexus plugins by scanning .opencode/plugins/ for nexus-*.ts files. Shows versions, API connection status, and registered hooks.

Technical Details

DistributionTypeScript source via nexus pull into .opencode/plugins/ — no npm install required.
Dependency@opencode-ai/plugin (auto-installed via .opencode/package.json).
Agent OwnerOnly distributed to projects where the agent owner is set to opencode or both.
ArchitecturePure local data — no Helicone or external service dependencies. All cost data from OpenCode AssistantMessage.info.cost/tokens.