Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@231self/opencode-router

Latest version: v0.6.3

Overview

Last scanned
29 Nov 2026
Published
29 Nov 2026
npm package Publisher: amit231self
4 Stars
0 Forks
23 Versions
3.8K Downloads
JavaScript Repo language

Scan summary

@231self/opencode-router was last scanned on 29 Nov 2026 at version 0.6.3. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 23 versions; the latest 5 were published within 4 days (26–29 Nov 2026).
  • Findings: No rules fired in version 0.6.3.
  • Downloads: 3,807 downloads.

Versions

23 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.6.3 LATEST 29 Nov 2026 No rules fired
0.6.2 29 Nov 2026 No rules fired
0.6.1 29 Nov 2026 No rules fired
0.6.0 26 Nov 2026 Not shown
0.5.0 26 Nov 2026 Not shown

No rules fired in 0.6.3

Findings

Findings for v0.6.3. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.6.3; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

opencode-router

Per-turn model routing for OpenCode V2 and Kilo.

A small model running on your machine picks the right model for every turn — so a one-line question doesn't cost frontier tokens, and a hard refactor doesn't run on a model that will fail it.

npm ci license node

Status: v0.6.3. Routing, subagent policy, the TUI /router surface, per-turn timing, the CLI, and the Kilo shim are implemented and tested. The context optimiser moved to @231self/opencode-compaction (install both for pruning). Design of record: docs/specs/2026-11-15-opencode-omlx-router-design.md.

Local dashboard

/router web opens a dashboard on 127.0.0.1: plan burn first, per-model unit prices (the cost of 1M tokens of a typical turn on each — measured from your own turns where you have them, a labelled stand-in where you don't), consumption bars by day or hour, and the recent routing decisions, each expandable to its reason. Every table sorts, filters, and searches.

The server binds loopback only and every response is an allow-list projection — counts, sizes, prices, and labels, never prompt text or tool output. /router web stop closes it.

The local dashboard: plan burn, spend by model with unit prices, and consumption bars

Why

A coding agent makes you pick one model for a whole session. A one-line question then costs frontier-model tokens, while a hard refactor on a small model burns retries. This plugin routes each turn to the model that fits it, from a pool you control.

It ports the transferable ideas from pi-smart-router — turn envelope, deterministic triage, context-fit gate, cache-aware pinning, loop escalation, decision logging — and drops the heavy machinery (HyDRA/ONNX embeddings, benchmark calibration, virtual cost, planning delegate).

The pool can mix cloud models with local oMLX or llama.cpp models. Loopback providers are priced at zero, so a capable local model can take routine turns while cloud models handle the hard ones.

Quick start

# 1. install
opencode plugin add @231self/opencode-router

# 2. choose the models the router may pick from
opencode-model-router config set pool.source list
opencode-model-router config set pool.models '["deepseek/deepseek-flash","deepseek/deepseek-v4-pro"]'

# 3. make sure a small judge model is served locally
opencode-model-router judge probe

# 4. talk normally; inspect the first decisions
opencode-model-router status
opencode-model-router history 5

In the TUI, /router opens the full menu, /router explain shows why the last turn picked its model, and /router debug prints the diagnostic bundle.

Documentation

Requirements

Requirement Notes
OpenCode ≥ 2.3 First-class; V2 plugin API
Kilo CLI ≥ 7.6.2 Best-effort mode; see Kilo limitations
oMLX or llama.cpp Local OpenAI-compatible server; oMLX defaults to http://127.0.0.1:1234/v1, llama-server to :8080
A small judge model e.g. a ~4B instruct model; oMLX, llama.cpp, or any OpenAI-compatible server; see Choose a judge
Node/Bun Provided by OpenCode and Kilo; nothing extra to install

No Rust toolchain is needed to install a released package. Building from source requires Rust with the wasm32-unknown-unknown target.

Install

Release/build details: docs/releasing.md.

OpenCode V2
opencode plugin add @231self/opencode-router
// ~/.config/opencode/opencode.jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["@231self/opencode-router"]
}
Kilo
kilo plugin @231self/opencode-router
// ~/.config/kilo/kilo.jsonc or project kilo.jsonc
{
  "$schema": "https://app.kilo.ai/config.json",
  "plugin": ["@231self/opencode-router"]
}
From a checkout (development)
git clone https://github.com/231self/opencode-router
cd opencode-router
bun install
bun run build:wasm       # needs Rust with wasm32-unknown-unknown

Then point the host at the checkout:

// OpenCode
{ "plugins": ["/absolute/path/to/opencode-router"] }
// Kilo
{ "plugin": ["/absolute/path/to/opencode-router/src/index.js"] }

Kilo applies a decision at the next request boundary; see Kilo limitations.

The CLI installs as opencode-model-router. omlx-router remains an alias. Config, state, plugin IDs, and OMLX_ROUTER_* env vars keep their historical names, so existing setups keep working.

How it works

Three layers: a plain-JS adapter for the host, a Rust decision engine compiled to WebAssembly, and a short JSON-verdict call to a small local model.

prompt hook
  ├─ envelope: cheap Rust heuristics → signals + complexity hint
  ├─ short-circuit? (trivial · forced pin · escalation · empty pool)
  ├─ judge: 4B local model → JSON verdict        [5 s budget]
  ├─ reconcile: judge + deterministic floor (judge can raise, never lower)
  ├─ gates → score → pin → chosen model
  └─ session.switchModel(...) + write pin + decision record
context hook (same turn, from @231self/opencode-compaction)
  ├─ optimiser: token estimate → prune plan → afterTokens
  └─ afterTokens feeds the next routing decision
telemetry (after the turn)
  └─ turns.jsonl: routing/judge/core/switch time, tokens, cost

The routing brain is deterministic, has no I/O, and is unit-tested on its own. The only model call the plugin makes for a decision is the short verdict prompt to the judge endpoint you configure (localhost by default). If it is slow or down, deterministic heuristics take over and routing continues.

The judge

A classifier, not a chat model. It is asked one question per turn, and sees only:

  • the turn truncated to 1,200 characters,
  • token counts, image count, and tool-failure count,
  • the deterministic signals (code, error, planning, review),
  • the candidate table — context, tools, vision, price, local flag.

It never sees the transcript, file contents, or tool output.

Input Value
Temperature 0
Max tokens 220
Format response_format: json_object, one repair retry
Timeout judge.timeoutMs (default 5 s)

It returns:

{"task":"edit","complexity":2,"needsTools":true,"needsVision":false,
 "contextNeed":"small","reasoningNeed":"medium","confidence":0.8}

The judge is a floor-adder. reconcile lets it raise complexity, reasoning, or context need, but never lower what the deterministic signals already proved. That is why a 4B that under-classifies a multi-file refactor cannot cause an under-route. confidence is recorded but does not steer selection. On timeout, HTTP, or parse failure the heuristic verdict is used, the decision log records used: false, and the turn continues.

Signals and complexity

Before any judge call, the envelope computes word-boundary-aware markers:

Signal Trigger
code code fences, source extensions, cargo/bun/npm/git
agentic implement, fix, refactor, migrate, debug, add, run, test, …
error_trace panic, traceback, exception, error:, exit code, …
planning plan, design, architect, approach, trade-off, spec
review review, audit, critique, security, look for bugs
trivial short, no signals, small prompt and context
multi_file ≥ 3 code files, or 2 across files
large_context estimated input over 60k tokens
repeated_failures 3+ consecutive identical tool failures

Complexity starts at 1 and adds a point per signal (clamped to 5), with planning and review floored at 3. Trivial turns skip the judge entirely.

Scoring
  1. Gates. Deprecated models, context fit (input ≤ context × 0.9), minimum context, required tools, and required vision are hard filters.
  2. Required quality. Complexity maps to 0.25 / 0.40 / 0.55 / 0.75 / 0.90, plus 0.10 for high reasoning and 0.05 for planning or review, then the agent's quality floor.
  3. Quality estimate. 45% price percentile, 25% parameter-size heuristic, 15% context percentile, 15% reasoning support. Overrides win; free local models default to 0.35.
  4. Expected cost. Input plus expected output at the model's context tier, with a cache-read discount: the measured cache-hit share of the session's last turn when the pinned model served it (a fresh pin is priced cold), or pin.cacheHitRatio (0.8) when nothing is measured yet. With a plan billing record configured (/router plan, or the compaction plugin's /ctx plan), the models the plan covers are priced at the plan's own shadow prices — plan credits are what the user actually spends — and marked plan rate in /router pool. A plan that publishes a dollar budget rather than a token count (GitHub Copilot) is priced against the model's own list price: the budget buys allowanceUsd / listPrice tokens, so the model costs list × priceUsd / allowanceUsd. A plan with no published allowance has no shadow price, so it changes no price: those models keep catalog prices. Local models stay free: they burn no allowance. This precedence is not decided here — it lives in @231self/opencode-shared/cost-resolution.js, which the compaction plugin calls too, so a model's price is one fact shared by both.
  5. Policy weights.
Policy Cost Quality Latency Use when
cost (default) 0.6 0.3 0.1 Cheapest model that clears the bar
quality 0.1 0.8 0.1 Quality matters more than spend
latency 0.2 0.2 0.6 Interactive work; favours local and flash tiers

Changing the policy clears pins so the next turn is scored from scratch.

Sidebar

The router adds a block to the OpenCode sidebar showing this session's model, pin source, policy, judge, and quality score. It refreshes on model changes and finished turns. Where the host has no OpenTUI or no sidebar slot, the block is skipped and everything else works.

Custom weights

Override any preset, and optionally vary the blend by turn class:

{
  "policy": "cost",
  "policyWeights": { "cost": 0.6, "quality": 0.35, "latency": 0.05 },
  "policyByClass": {
    "planning": { "cost": 0.1, "quality": 0.8, "latency": 0.1 },
    "review":   { "cost": 0.1, "quality": 0.8, "latency": 0.1 },
    "trivial":  { "cost": 0.85, "quality": 0.1, "latency": 0.05 }
  }
}

Turn classes are trivial, routine, agentic, planning, review, and tool_continuation. A class override wins over policyWeights; omitted fields inherit. /router policy custom prints the active weights and the config path. Weights change which model wins a turn; pin thresholds decide whether the router switches at all.

Pinning

Provider prompt caches are per model and per provider. A switch pays one full prefill, so routing alone would thrash the cache. The pin is the counterweight.

Mode Behaviour
cache Keep the incumbent to reuse its cache; switch only on hard breaks
balanced (default) Keep unless a challenger wins by pin.switchThreshold (0.12)
switch Take the best every turn, with cold-cache scoring

Even in cache or balanced, a pin is released by:

  • idle TTL (pin.idleTtlMs, 5 min),
  • a complexity jump of two or more,
  • pin age (pin.maxAgeMs, 30 min) or pinned turns (pin.maxTurns, 8),
  • an incumbent costing over pin.costSwitchRatio (4×) the cheapest adequate challenger,
  • a flip-flop guard (pin.flipFlopTurns, 3),
  • a gate failure, context overflow, compaction, policy change, or user override.

Picking a model yourself (/model) becomes a forced pin until you run /router auto, the session compacts, or the model disappears.

Smaller context windows

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @231self/opencode-router

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

Frame 2085668439 (1)
Group 1261154229