Repository navigation
Releases
v0.9.0 — OpenCode V2 support
OpenCode V2 support (dual V1 + V2)
One package now works on both OpenCode V2 (Plugin.define({ id, setup })) and OpenCode V1 (1.18.29+, via the server hook). The discovery core is shared; only the entrypoint differs.
Highlights
- New V2 plugin (
src/v2.ts) built withPlugin.define({ id: "9router", setup }), registering providers/models throughctx.provider.transform(...)and refreshing viactx.provider.reload() - New
src/v2-map.tsmapping the discoveredModelConfigonto V2Model.Info(capabilities, requiredlimit.context/limit.output, variants) - New
src/index.tsdual entrypoint: default export merges the V2 definition withserver: NineRouterPlugin(V1 1.18.29+); namedNineRouterPluginexport retained for older V1 - Package entry (
exports,main,types) now points atdist/index.js/dist/index.d.ts @opencode/plugin@^2.0.12added as a runtime dependency;@opencode-ai/plugin/@opencode-ai/sdkkept for V1 types
Install
{
"$schema": "https://opencode.ai/config.json",
"plugins": ["@vheins/opencode-9router@latest"]
}Config for V2 uses "plugins": [...]; custom providers use package: "@opencode/ai/providers/openai-compatible" + settings.baseURL under the providers key. See README "OpenCode V2" section for full config.
Compatibility & notes
- V1 behavior unchanged; discovery/capability/cache algorithms untouched (no V1 regression).
Changelog
v0.8.1 — Strict combo enrichment
Strict combo enrichment
- Combos count as enriched only on an exact models.dev segment match (no more loose substring hits like
vision→gpt-4-turbo-vision) - Ignore bare
/models/infocapability stubs ({tools: true}) for combos, so backends that return stubs still get forced multimodal defaults
Install: "plugin": ["@vheins/opencode-9router@0.8.1"] or @latest
v0.8.0 — Combo multimodal defaults
Combo multimodal defaults
- Detect combo models via
owned_by: "combo"(fallback: no provider prefix) - Force multimodal defaults on combos with no resolved capability info: text/image/audio input, tool calling, reasoning, 256K context, 128K output
- Add
low/medium/high/xhigh/max/minimal/thinkingvariants, plussearch: false,context_length, andmax_completion_tokens - Already-enriched combos (e.g.
gpt-5.6-luna) are left untouched - Version discovery cache so older entries are refetched
Install: "plugin": ["@vheins/opencode-9router@0.8.0"] or @latest
v0.7.10
v0.7.10 — fix(discovery): populate limit.context/output
Changes
- fix(discovery): populate
limit.context/limit.outputso context usage % is not stuck at 0 (#2) - hardened validation: numeric token limits normalized through a single
toPositiveIntpath — invalid/zero/negative values never produce a limit - refactor: split monolithic
src/plugin.ts(485 lines) intocache.ts,capabilities.ts,discovery.ts,types.ts,utils.ts(<500 lines/file) - test: add
test-limit.mjsregression suite — top-level fallback, nested-capability precedence, invalid-value rejection, models.dev catalog flow (5/5 minimal + 9/9 limit, all passing)
Artifacts
v0.7.9
Performance & Hardening Release
Performance Optimizations
- models.dev-first capability resolution — Fetch capability catalog before per-model API. Eliminates most HTTP calls when models exist in the models.dev catalog.
- Retry on transient failures —
fetchModelInfonow retries once with exponential backoff (500ms × 2^attempt) for network glitches. - Higher concurrency —
MAX_CONCURRENT_INFOincreased from 5 to 15. - Generous per-model timeout —
MODEL_INFO_TIMEOUTraised from 3s to 5s for slow networks. - Longer models.dev cache — TTL increased from 5 minutes to 1 hour.
- Cross-platform cache path — Uses
os.homedir()+XDG_CACHE_HOMEfallback (works on Windows). - Capability budget — 10-second cap on per-model API work to prevent startup blocking.
Security & Resilience Fixes
- Path traversal sanitizer —
safeFilename()in cache path construction preventsproviderKey-based directory escape. - Prototype pollution defense —
Object.create(null)for models dictionary. - Empty payload fallback —
/v1/modelsreturning empty/invalid data now throws to engage stale cache fallback. - Crash resilience —
cacheDir()falls back toos.tmpdir()ifhomedir()throws. - HTTP error fallback — Non-OK responses now throw to engage stale cache (instead of returning null).
Docs
- Added "Validate after publish" / "Validasi setelah publikasi" sections with the
opencode models 9router-local --print-logs --log-level DEBUGcommand for end-to-end validation after release.
Test
opencode models 9router-local --print-logs --log-level DEBUGInstallation
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@vheins/opencode-9router@latest"]
}v0.7.8
refactor(plugin): add provider prefix to cache filenames, fix models-dev cache storage
- Discovery cache filenames now include provider key prefix for clarity
- models-dev.json now stores raw API response (dict), flattened on read
instead of storing the flattened array (which broke cache reads) - Backward compat: old flat-array caches are treated as cache miss
- auth.json no longer needs metadata.baseURL — plugin handles URL
v0.7.7
fix(plugin): flatten models.dev catalog response
models.dev/api.json returns a dict of providers with nested models, not
an array. findModelsDevMatch iterated with for...of over the raw response,
causing TypeError: {} is not iterable. This fix flattens the nested
provider dict into a flat array of {id, capabilities} entries before use.
Also fixes the provider api field to ensure opencode's built-in plugin
can resolve the endpoint URL for 9router-family providers.
v0.7.6
fix(plugin): set provider api field for opencode internal resolution
opencode's built-in provider plugin reads m.api from the provider config
to construct the aisdk provider endpoint URL. Without entry.api being set,
the provider URL was undefined, causing 'Provider not found' for all
9router-family providers.
v0.7.5
fix(plugin): mutate existing provider entry instead of replacing it
Replacing the entire provider entry (provider[key] = {...}) broke
opencode's internal reference to the provider, causing 'Provider not
found' errors after the config hook completed. Mutation preserves the
object reference so opencode can still find the provider.