@stablekernel/opencode-bifrost
v0.6.0
Published
OpenCode plugin that routes models through the Bifrost gateway, resolving per-project virtual keys via gateway-cli.
Readme
@stablekernel/opencode-bifrost
OpenCode plugin that routes model traffic through a Bifrost LLM gateway, with per-project virtual-key resolution delegated to gateway-cli.
What it does
- Registers a
bifrostprovider on OpenCode's OpenAI-compatible surface. - Fetches the model list at startup through
gateway-cli models --wire=openai, with per-model context/output limits and pricing already applied — no catalog is checked in, so a model added to the gateway appears without a local edit. - Seeds reasoning capability per model: catalog-flagged models are registered
reasoning: truewith one variant per effort value they accept, and the config cascade's defaultreasoning_effortis seeded as the model'soptions.reasoningEffortwhen the model accepts it. The staticgateway-cli emit opencodeblock mirrors this. - Resolves the virtual key per project directory (
gateway-cli resolve/gateway-cli key print), so two projects on different keys never collide in OpenCode's global auth store. Falls back to a credential stored viaopencode auth loginon machines withoutgateway-cli.
No secret is held by the plugin; the key is read at runtime.
/bifrost-refresh
Registered on every startup, with or without gateway-cli — in a sandbox that
has no CLI at all the plugin registers no provider, so this command is the only
way to see what the gateway offers. It reconciles the model list whenever you
want it, without restarting OpenCode. Two modes, chosen by what is available at
the moment you run it:
gateway-clipresent — runsgateway-cli sync, which reconciles the saved selection on disk, and prints its output. Once that turn ends, the plugin disposes the instance so the TUI re-bootstraps and the model picker re-reads the reconciled list (disposing mid-turn would cut the turn short). Since the list was re-registered, the report does not tell you to restart.gateway-cligone (sandboxed machine) — asks$BIFROST_DISCOVERY_URL(or$BIFROST_GATEWAY_URL)/v1/modelsdirectly and reports what the gateway offers versus what this session registered: new ids, ids no longer offered, or "this session's list is current". Report only — nothing is written, here or anywhere else, and no instance is disposed; the text says to restart because this mode cannot re-register anything. The key comes from$BIFROST_VK, else the CLI's own~/.config/bifrost/keys/default.env, else the credential stored byopencode auth login.
Either way the result arrives as a message part, never as an error: a failure prints one line. The virtual key is never printed or logged.
Datasheet supplement (off by default)
Wildcard-provider models — e.g. a fresh Fireworks launch that the CLI's
models.dev source has not cataloged yet — never reach gateway-cli models,
so they cannot be listed here either. When configured, this plugin also reads
the datasheet feed Bifrost itself syncs from and appends the wildcard-provider
ids the CLI list lacks; CLI-listed ids always win. The supplement applies to
the single bifrost provider.
Activation (first wins):
- env
GATEWAY_DATASHEET_URL ~/.config/bifrost/datasheet.json—{"url": "..."}<project>/.gateway/datasheet.json— same shape
The URL must be https://; a source with anything else is treated as absent.
Behavior: the feed is fetched once per hour and cached under
~/.cache/opencode/datasheet-cache.json (or $XDG_CACHE_HOME), with a 3s
hard timeout and a stale-cache fallback on failure. A failed first fetch
also triggers a background cache fill, so a slow or cold feed costs one
session rather than every start. Unconfigured or unreachable, the
supplement is silently skipped — startup never blocks on it.
Provenance: supplement-only models are tagged limits_source: "datasheet"
and cost_source: "datasheet" in the gateway-cli models payload they ride
in. The tags stop there — opencode's config schema has no provenance field,
so they are not forwarded into the emitted opencode.json.
Requirements
gateway-clionPATH(or theGATEWAY_CLI_BINenv var pointing at it), connected once withgateway-cli connect.
Install
opencode plugin @stablekernel/opencode-bifrostLicense
UNLICENSED — published for installation convenience; all rights reserved. Intended for use within the organization that operates the Bifrost gateway.
