Provider & subscription

panto-opencode-go

rock 0.2.0-1Source

OpenCode Go defaults for panto. Mark named tables; the extension fills the boilerplate.

Setup

Requires panto's configure(config) extension hook (before auth/provider validation).

TOML
[extensions]
rocks = ["panto-opencode-go"]

[auth.opencode]
panto_opencode_go_extension = true

[providers.go]
auth = "opencode"
panto_opencode_go_extension = true
SH
export OPENCODE_API_KEY='your-key'
panto models sync
panto models list go:

Defaults

SettingValue
AuthAPI key via ${env:OPENCODE_API_KEY}; no OAuth login
APIsChat Completions (default), Responses, Anthropic Messages, Google Interactions
OpenAI endpointhttps://opencode.ai/zen/go/v1
Anthropic endpointhttps://opencode.ai/zen/go
Google endpointhttps://opencode.ai/inference/go/google/v1beta (needs a panto with google_interactions)
Catalogopencode-go
HeadersUser-Agent: panto, x-opencode-session: ${session:id}

Rules

  • Only panto_opencode_go_extension = true opts in; auth/provider names are arbitrary.
  • Keep providers.<name>.auth explicit; the extension never guesses linkage.
  • Explicit values win, including nested endpoints and case-insensitive headers.
  • Defaults are independent per table/load; no config files are rewritten.
  • No network or credentials in Lua; env/session placeholders stay raw for panto.
  • Rigs inherit user connection settings after this configuration hook runs; they need not include this extension unless their own config uses its markers. --no-extensions skips the hook.

Existing flat base_url configurations stay flat; otherwise all four endpoints are filled. Overrides must remain valid panto configuration.

Quota display requires panto's http_request API and the render_footer event. It runs only when this extension is permitted and at least one marked auth or provider subscription is configured.

  • It queries every distinct named auth, not only the current model.
  • Polls begin at session_ready, repeat about every 60 seconds when luv is available, and fire after each completed assistant response (the end of every inference response) and at turn end, throttled to one batch per 10 seconds.
  • Requests are non-blocking: panto's HTTP worker fetches while the TUI keeps drawing; the footer updates when the response arrives.
  • Failed snapshots are retained and marked stale, with bounded retry backoff.
  • Session end cancels the timer and any in-flight request.
  • One shared logical usage row wraps to the terminal width.

The data source is OpenCode Go's own usage endpoint, https://opencode.ai/zen/go/v1/usage, called through panto's named-auth HTTP API with the same API key as inference. It reports three used percentages with exact reset instants, shown as lowercase labels with green/yellow/red percentages at 33% and 66%:

TEXT
opencode go 5h 4%  reset in 2h 14m    7d 30%  reset in 6d 4h

A shared, unreferenced minute timer keeps countdowns current while idle; it does not fetch usage. Other subscriptions appear on the same row when their extensions are enabled.

Packaging / checks

SH
panto lua _selfcheck.lua
panto lua _footer-selfcheck.lua
luarocks lint panto-opencode-go-0.2.0-1.rockspec

The rockspec maps require("panto-opencode-go") to init.lua, the quota poller and shared footer helper to their modules; no dependencies beyond Lua.

References

  • OpenCode Go
  • Defaults match the existing panto OpenCode Go configuration.