opencode-model-router 2.10.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +306 -0
- package/README.md +3 -2
- package/package.json +8 -1
- package/src/compat/background.ts +5 -0
- package/src/compat/session-lookup.ts +21 -0
- package/src/compat/v2-hooks.ts +256 -88
- package/src/compat/v2-observations.ts +1 -0
- package/src/compat/v2-vocabulary.ts +14 -0
- package/src/executor/create.ts +3 -0
- package/src/executor/git.ts +110 -26
- package/src/executor/integrate/checks.ts +29 -11
- package/src/executor/integrate/queue.ts +95 -13
- package/src/executor/ledger.ts +16 -12
- package/src/executor/lfs-restore.ts +492 -0
- package/src/executor/paths.ts +7 -2
- package/src/executor/recovery.ts +2 -1
- package/src/executor/runtime.ts +1010 -226
- package/src/executor/slots/pool.ts +120 -19
- package/src/executor/slots/provision.ts +111 -23
- package/src/executor/slots/root.ts +81 -0
- package/src/executor/types.ts +28 -2
- package/src/executor/unattended.ts +6 -1
- package/src/executor/verify-trees.ts +507 -0
- package/src/guard/enforce.ts +2 -1
- package/src/guard/fingerprint.ts +9 -0
- package/src/guard/guards.ts +7 -1
- package/src/index.ts +107 -27
- package/src/router/answer-dedup.ts +198 -0
- package/src/router/common-dir.ts +241 -0
- package/src/router/config.ts +71 -12
- package/src/router/diff-handles.ts +322 -0
- package/src/router/diff-summary.ts +318 -0
- package/src/router/git-metadata-guard.ts +144 -7
- package/src/router/git-tools.ts +930 -73
- package/src/router/role-agents.ts +100 -36
- package/src/router/run-summary.ts +253 -0
- package/src/router/run-tools.ts +145 -23
- package/src/router/sessions.ts +14 -1
- package/src/routing/classify/rules.ts +93 -14
- package/src/routing/wire/hint.ts +9 -2
- package/src/v2.ts +3 -1
- package/src/verify/exec.ts +454 -2
- package/src/verify/plan-task.ts +86 -26
- package/src/verify/runner.ts +14 -6
- package/src/verify/tree.ts +5 -1
- package/src/verify/types.ts +44 -0
- package/src/verify/wiring.ts +87 -10
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,278 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.11.0] - 2026-11-28
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **OpenCode v2: an overrides file can remove a key it inherits inside `presets` by setting it to `null` (#80).** The
|
|
15
|
+
bundled `anthropic` preset sets `effort` on every tier and no overrides file could take it away, so the cost doctor's
|
|
16
|
+
`variant-effort` advice (drop `effort`, list `candidates`) could not be followed: `"effort": null` was an invalid
|
|
17
|
+
value, and its key path was dropped with a notice. On OpenCode v2 a `null` at any depth inside `presets` (a preset, a
|
|
18
|
+
tier, a tier key) now removes that key from the merged config before validation, as if no layer had set it; a `null`
|
|
19
|
+
with nothing to remove is a no-op. A removal that leaves the config invalid (a tier without `model`) is dropped with
|
|
20
|
+
its key-path notice like any invalid value, and the project-local file still cannot touch a global-only key. Outside
|
|
21
|
+
`presets` a `null` keeps its meaning as a value (`enforcement.maxDelegationDepth: null`,
|
|
22
|
+
`enforcement.verify.graderTemperature: null`). OpenCode v1 is unchanged. See "Removing an inherited key with
|
|
23
|
+
`null`" in docs/CONFIG_REFERENCE.md.
|
|
24
|
+
- **OpenCode v2 roles mode: a role agent's `router_git_diff` is stat-first (#108).** Without `path`, in mode `patch`
|
|
25
|
+
or `cached`, lockfiles, snapshots, goldens and fixtures (a fixed list, by a file's new path; goldens and fixtures
|
|
26
|
+
never include code or tests) are left out of the patch and listed after it as `content excluded (<kind>, +a/-b)`.
|
|
27
|
+
When the rest of the patch exceeds 8 KiB, or the excluded paths cannot be left out of it (more than 200, or a git
|
|
28
|
+
command line above 30000 characters), the answer is a summary instead: one `+added -removed` line per file,
|
|
29
|
+
excluded files marked, sensitive files (either name of a rename) by name only as `sensitive: content withheld`,
|
|
30
|
+
at most 4096 bytes, with the exact count of entries left out. `path`, `mode: "stat"` and `mode: "name-only"` answer
|
|
31
|
+
as before; tiers mode, the root session and OpenCode v1 are unchanged. See docs/ROLES.md.
|
|
32
|
+
- **OpenCode v2 roles mode: `router_run({ summary: "failures" })` for vitest npm scripts (#108).** Opt-in. The router
|
|
33
|
+
appends `--reporter=json --outputFile=<OS temp file>` to the script, reads the report (up to 8 MiB, its size
|
|
34
|
+
checked first) and deletes it, also after a timeout or a failed start, and answers with the counts and the failing
|
|
35
|
+
tests grouped by file, each with the first block of its error, within 4096 bytes (names first, then error blocks
|
|
36
|
+
while they fit, then the exact count of what was left out). Names and paths are kept on one line with URL
|
|
37
|
+
credentials redacted. Without a usable report it gives the reason and the output's last lines. Another entry, a
|
|
38
|
+
script body that is not one plain `vitest` command, a caller `--reporter`, `--outputFile` or `--`, and a relative
|
|
39
|
+
OS temp directory are refused before anything runs; without `summary` nothing changes. See docs/ROLES.md.
|
|
40
|
+
- **OpenCode v2 roles mode: `gd_` handles on a role agent's `router_git_diff` summary, expanded by `router_git_show`
|
|
41
|
+
(#108).** Every shown, non-sensitive line of a summary or excluded list that has a side with lines ends with
|
|
42
|
+
` | gd_<10 hex>`, a keyed digest of that file version for this session (not a content hash). Lines left out by the
|
|
43
|
+
4096-byte bound, binary files, symlinks, submodules and unmerged paths get none.
|
|
44
|
+
`router_git_show({ handle, lines: "a-b", side? })` returns a header line, then those lines of the blob of that side
|
|
45
|
+
(`new` by default, `old` for a deleted file), at most 400 lines or 16 KiB per call, with where to continue. Blobs
|
|
46
|
+
are read with `git cat-file blob` (at most 4 MiB). The working-tree side is never read: the call refuses and points
|
|
47
|
+
to `read`. Handles are kept in memory per session (2 hours after last use, 1024 per session) and are lost on
|
|
48
|
+
restart. Every expansion resolves the work root or `root` again, re-checks sensitive names, and passes only the
|
|
49
|
+
stored blob id to git. Under a role's guard profile an expansion is a read: `redundant_read` refuses an identical
|
|
50
|
+
repeat, `read_budget` applies to producers, and the read-only cap banner counts it. Tiers mode, the root session and
|
|
51
|
+
OpenCode v1 are unchanged. See docs/ROLES.md and docs/ENFORCEMENT.md.
|
|
52
|
+
- **OpenCode v2 roles mode: a repeated identical answer is a one-line stub; `force: true` gives it in full (#108).**
|
|
53
|
+
`router_git_diff`, `router_git_status`, `router_git_show`, `router_git_log` and `router_run` declare `force`. When a
|
|
54
|
+
role agent repeats a call (same tool, repository and arguments, defaults filled in; for a `gd_` expansion the same
|
|
55
|
+
handle, `lines` and `side`) and the answer is byte-identical to the last one that call got in full, the answer
|
|
56
|
+
names the earlier call and its size instead. The guards still see every call as before. `router_run` still
|
|
57
|
+
runs and is recorded, keeps its status line and ignores the duration in it. Only answers above 512 bytes are
|
|
58
|
+
compared; errors, aborted calls and refusals never are, and make the next identical call answer in full. A stub is
|
|
59
|
+
given only within 20 completed tool calls of the full answer it names. The SHA-256 and length of the last answer per
|
|
60
|
+
call stay in memory (128 calls per session, 4096 in all) until the session is compacted, reverted or deleted; without
|
|
61
|
+
the host's compaction hook dedup is off (one warning). Other sessions, tiers mode and OpenCode v1 are unchanged, and
|
|
62
|
+
no tool description changes. See docs/ROLES.md.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- **OpenCode v2: a restart no longer re-verifies a plan task over the dead server's still-running checks (#189,
|
|
67
|
+
R2-pre-2).** A server killed by a signal skips the exit hook that ends its verification process trees, so the
|
|
68
|
+
restart's re-verification raced them (its clean, files held open on Windows, ports and locks) and could judge the
|
|
69
|
+
wrong tree. Plan-task verifications now record each process tree at spawn (its start, deadline and exit) in
|
|
70
|
+
`<executor home>/verify-trees/<plan>/<task>#<n>.json`. Before recovered work runs, one bounded sweep per activation
|
|
71
|
+
kills the trees of dead servers, and only these processes. On Windows: a recorded root still running whose creation
|
|
72
|
+
time lies in its spawn window (and before both the process now holding the dead server's PID and the sweep's process
|
|
73
|
+
snapshot), whose parent is the dead server and whose command line names its command or the slot, with its tree; and
|
|
74
|
+
a child of a recorded root that exited, created before that root's run ended (its exit, else its deadline plus the
|
|
75
|
+
kill grace, and at most 5 s after the dead server's last heartbeat: a journal with roots in flight has its
|
|
76
|
+
modification time refreshed every 2 s), whose command line names the slot, with its tree. On POSIX: a recorded
|
|
77
|
+
process group whose leader has the start ticks recorded at spawn. Any other process found where a recorded tree would
|
|
78
|
+
be is reported, never killed. A kill that cannot be confirmed (for example Constrained Language Mode, or a process
|
|
79
|
+
that does not name the slot) parks the slot's recovered work as `verify-tree-alive`, with one blocking item naming the
|
|
80
|
+
PIDs (a process started after the dead server's run could still start processes is listed apart, as possibly the
|
|
81
|
+
user's own); a journal that cannot be read or fails validation parks its task and is kept. `/plan resume` sweeps
|
|
82
|
+
again and closes the items of slots it finds clear. A restart's slot reset now removes a stale `index.lock` (git's
|
|
83
|
+
`Unable to create` error only) at most once, never in such a slot, and reports a reset that still fails. OpenCode v1
|
|
84
|
+
is unchanged.
|
|
85
|
+
- **OpenCode v2: the advise route hint is no longer lost after a dispatch (#191).** The hint is classified from the
|
|
86
|
+
latest user text. OpenCode 2.3+ reports every child to the orchestrator as a user-role entry after the tool result,
|
|
87
|
+
so the hint classified that entry (the host's `<background-result>`, the router's held placeholder or its
|
|
88
|
+
`<router-verdict>`) instead of the user's ask, and the turn-state tail lost the hint or got another one within the
|
|
89
|
+
same turn (seen on OpenCode 2.4.2). A user text that starts with a child report or a router verdict is now skipped,
|
|
90
|
+
as the `Instructions from:` attachments already were; the 2.0.x `<subagent …>` report of a background child is
|
|
91
|
+
skipped too. Requests without such an entry pick the same text as before. OpenCode v1 is unchanged.
|
|
92
|
+
- **OpenCode v2: off Windows the executor-home deny for role agents no longer fails open (#192, QA-62C-15).** Off
|
|
93
|
+
Windows the router finds `<git common dir>/omr-executor` on disk, without git, and denies it to role agents. A bare
|
|
94
|
+
repository, or under WSL a `.git` or `commondir` naming a Windows drive path (`gitdir: D:/…`, as Git for Windows
|
|
95
|
+
writes it), resolved no common directory, so the home was not denied and nothing was logged. The lookup now walks up
|
|
96
|
+
in git's order (`.git`, then a bare repository with a `HEAD` git accepts, then the parent directory), goes on past a
|
|
97
|
+
bare repository to the repository around it (a bare shape can be committed to a checkout) and denies every home it
|
|
98
|
+
finds, and under WSL reads a drive path at its automount path (`/mnt/d/…`, or below the `[automount] root` of
|
|
99
|
+
`/etc/wsl.conf`). On a Windows drive, where letter case does not matter, every `external_directory` rule that could
|
|
100
|
+
reach a home in another case is not granted (one warning). When a repository is found but its executor home cannot
|
|
101
|
+
be denied (a linked or unparsable `.git`, a pointer to a network or device path, a drive path outside WSL or missing
|
|
102
|
+
there, or a home with no canonical form: a `.git` pointer naming no git directory, or a home path with a glob
|
|
103
|
+
character or a `~N` segment), the router logs one warning and role agents get no `external_directory` rule at all
|
|
104
|
+
(fail closed). Windows is unchanged. See docs/ROLES.md.
|
|
105
|
+
- **OpenCode v2: a held `<router-verdict>` uses v2 vocabulary (#191).** The verdict of a background-verified dispatch
|
|
106
|
+
(every verified dispatch on OpenCode 2.3 and later) carried the OpenCode v1 tool result: a `task_id: …` line, the
|
|
107
|
+
child's text inside `<task_result>`, and the escalation hint ``re-run via `Task(subagent_type="medium")` ``. It now
|
|
108
|
+
carries what a foreground result shows on v2: the child's own text, unchanged, then the router's lines in v2
|
|
109
|
+
vocabulary, for example ``re-run via `subagent(agent="medium")` (escalated from fast)``. OpenCode v1 is unchanged.
|
|
110
|
+
- **OpenCode v2: the plan executor applies filters set only in system or global configuration (#162).** Its hardened
|
|
111
|
+
git reads no system or global configuration, so a filter (or merge driver) set only there, such as a globally
|
|
112
|
+
installed Git LFS or git-crypt, was not applied: executor commits stored the raw content and checkouts wrote LFS
|
|
113
|
+
pointer files. Every filter `clean`, `smudge`, `process` and `required` and merge `driver` whose value comes from
|
|
114
|
+
system, global or command-line configuration is now passed to the executor's git with `-c`, so it runs the filter
|
|
115
|
+
programs plain git runs, and a global Git LFS works without `git lfs install --local`. Those programs still run
|
|
116
|
+
without the rest of the user's system and global configuration (`credential.helper`, `lfs.*`, a custom
|
|
117
|
+
`core.attributesFile`, the system gitattributes). Git LFS objects already in the local store are checked out as
|
|
118
|
+
content; the executor's git never downloads one (#208, under Security). A forwarded filter program (git-lfs) also
|
|
119
|
+
reads the repository's configuration and `.lfsconfig` itself: see #184 under Security.
|
|
120
|
+
A driver only the repository's own configuration sets (or sets differently) is still blanked, and nothing is taken
|
|
121
|
+
from it. A user value `-c` cannot carry as git reads it (a line break, or a byte that is not UTF-8) is not passed
|
|
122
|
+
on: that filter is blanked and marked required, so git refuses only where it is used. The verification snapshot and
|
|
123
|
+
reference pass nothing on and send the same git commands as before; one change reaches them: an include target
|
|
124
|
+
whose existence check hangs now fails the snapshot closed after its own 10 s timeout (OpenCode v1 and v2).
|
|
125
|
+
- **Repository tools: `npm run soak:analyze` runs on Node 26, and the development Node floor is documented (#195).**
|
|
126
|
+
The analyzer's loader called `module.stripTypeScriptTypes` with `mode: "transform"`, which Node 26 removed, so every
|
|
127
|
+
run exited 2 with `The property 'options.mode' must be one of: 'strip'`. It now uses strip mode (Node 22.13 and
|
|
128
|
+
later); the product modules it imports already use erasable syntax only. `engines.node` stays `>=22`: it describes
|
|
129
|
+
the published plugin, not the repository tools. CONTRIBUTING.md now states the development floor separately: Node
|
|
130
|
+
22.18 / 23.6 or newer for the coverage merge and `npm run routing:stats`, Node 22.13 or newer for the soak analyzer.
|
|
131
|
+
- **OpenCode v2: plan executor restart and recovery edge cases (#189).** A repository toplevel spelled with a Windows
|
|
132
|
+
8.3 short name is now the same repository as its long form, so its plans are no longer treated as foreign. At start,
|
|
133
|
+
a plan of this repository whose writer lock is stale is taken over and reconciled even when the restart report
|
|
134
|
+
missed it, instead of waiting for an adopt or another restart; a live holder is still refused. A plan whose
|
|
135
|
+
recovery cannot classify its tasks is no longer run unrecovered: it is paused with one blocking item naming the
|
|
136
|
+
cause, and resuming it runs the recovery again. Recovery adopts a child only when the attempt records it. Adopting a
|
|
137
|
+
completed or aborted plan is refused before its attachment closes, so an abort's cleanup (child stops, slot saves
|
|
138
|
+
and releases) is no longer cut off. Recovered work that waits for leases another holder has no longer wakes the
|
|
139
|
+
orchestrator. Once the slot pool closes, no slot claim waits on its base lookup any more, and none claims a slot.
|
|
140
|
+
A task held because another holder has its leases, whose slot record vanishes meanwhile, stays held (QA-4.2-31): its
|
|
141
|
+
slot is re-provisioned from the task branch and kept, and the task resumes once (commit, verification or the
|
|
142
|
+
integration queue) when the leases are free. It no longer loses the new slot and gets an item asking to restore a
|
|
143
|
+
task branch that was fine; a task held this way for the first time gets the hold item. When re-provisioning fails,
|
|
144
|
+
the item names the reason (a lease registry at capacity, a failed checkout, …); it asks to restore the task branch
|
|
145
|
+
only when the branch is missing or does not reach the attempt's commit. Such a failure also ends the task's hold, so
|
|
146
|
+
a later lease release no longer resumes it on its old slot after that slot went back to the pool. A held task whose
|
|
147
|
+
slot the pool now records as free or leased to another task is re-provisioned as well, instead of being resumed on
|
|
148
|
+
that slot.
|
|
149
|
+
- **OpenCode v2: a held background verification whose verdict cannot be settled no longer stays `verifying` (#193).**
|
|
150
|
+
When a step before the held gate settled its pending entry threw, the entry stayed `verifying` with no verdict posted,
|
|
151
|
+
and `router_verify` on its handle waited for that run until its deadline. The entry now settles exactly once as
|
|
152
|
+
`UNVERIFIABLE` with the scrubbed error as its reason, the verdict is posted to the parent session, and the error is
|
|
153
|
+
logged. OpenCode v1 is unchanged.
|
|
154
|
+
- **OpenCode v2: plan executor integration lineage, regression runs and breaker window (#188).** When a reverted
|
|
155
|
+
task's retry branch is reused, it is rebased from the newest journaled upstream its tip contains (also when its retry
|
|
156
|
+
landed as a rebased copy), so it does not replay other tasks' reverted changes. A revert whose culprit has no failing
|
|
157
|
+
test ids is no longer landed without its regression run: the phase suite commands are resolved once more, and if they
|
|
158
|
+
still do not resolve the revert is not built and the item gives the reason; a suite setting pauses only that phase
|
|
159
|
+
(unpausing reruns the suite), a resolver error pauses the plan (unpausing rebuilds the revert). After a restart, a
|
|
160
|
+
completed task's commit is looked up on its task branch, whose tip its slot is then re-provisioned from; a commit only
|
|
161
|
+
another ref reaches raises the blocking item, naming it. A commit failure cancelled by an abort stays in the
|
|
162
|
+
circuit-breaker window.
|
|
163
|
+
- **OpenCode v2: observation and visibility gaps outside the soak (#194).** The plan executor's streak of launches
|
|
164
|
+
lost before their child started remembers every capture of the streak, not only the last, so interleaved losses
|
|
165
|
+
under captures C1, C2, C1 count C1 once; a capture is its boot id, epoch and router call, not the call id alone.
|
|
166
|
+
A role decision row's `trace.riskSources.term` names an open high-risk term by its vocabulary stem (`deploy`), never
|
|
167
|
+
the rest of the prompt's word (`deploySecretAlice`), and a term that can span words by its table id, also when the
|
|
168
|
+
prompt joins them with hyphens (`npm-acme-internal-publish`). A failed verification snapshot is labelled `harden` or
|
|
169
|
+
`finalize` when it fails outside a git call. Recovered work parked without a root context, or behind held leases,
|
|
170
|
+
is counted once per park in the ledger (`recovered-work-parked`, with task, attempt, work kind and reason).
|
|
171
|
+
- **OpenCode v2: plan executor lifecycle (#190).** A hot-reload copy no longer takes the old copy's `/plan` for a
|
|
172
|
+
user command; a failed adopt is undone; the runtime starts only after its retry hook is registered and never after
|
|
173
|
+
dispose. An executor whose wiring fails at startup is disposed with one warning
|
|
174
|
+
(`executor: it could not be wired; it is disposed and plans are not executed`), and the plugin starts without it.
|
|
175
|
+
A user-defined `/plan` with exactly the router's `/plan` description is treated as the router's own. Disposal now
|
|
176
|
+
waits, at most 10 s, for a start in flight; a start that ends later attaches nothing and closes the ledger it opened.
|
|
177
|
+
- **OpenCode v2: the plan executor's slot release, lock release and purge fail closed (#187).** `purge` now refuses
|
|
178
|
+
while the gc leaves a slot of the plan behind (files in use, a folder git does not list as locked by the executor,
|
|
179
|
+
an entry without a slot marker): the refs and the ledger are kept, and the error names each slot and the way out
|
|
180
|
+
(close what holds the files; or check the folder for work, then `git worktree unlock` and
|
|
181
|
+
`git worktree remove --force` it, see [EXECUTOR.md](docs/EXECUTOR.md#interrupted-attempts)). A slot the gc began
|
|
182
|
+
deleting after its unsaved-work check passed is marked `removing`, so the next purge finishes it instead of refusing
|
|
183
|
+
the half-deleted folder as unsaved work. A slot whose pool record cannot be read is no longer released on a guess. A
|
|
184
|
+
repo lock the integration queue cannot remove on release is reported and retried in the background (5 times, only
|
|
185
|
+
while the file is still that lock's), and a failed restart `reset`/`clean` of a slot (non-zero git exits included)
|
|
186
|
+
is logged; the task's next launch still resets that slot through the pool and is skipped if that reset fails. A
|
|
187
|
+
package manager install lock whose owner died on this host is no longer taken over at once (the install's process
|
|
188
|
+
tree can outlive the killed server), and a fresh rerun deletes `.venv` or `node_modules` only under that lock:
|
|
189
|
+
provisioning after a crash waits until the lock's heartbeat is 60 s old. This supersedes the rule in the phase 2.4
|
|
190
|
+
report ("stale when the pid is dead on this host or the heartbeat is older than 60 s").
|
|
191
|
+
- **Roles mode: `trace.needTerms` no longer logs prompt words (#200).** A needs-table term whose pattern has a gap
|
|
192
|
+
(`\s`, `[^\n]`, `.`, `*`, `+`, `{m,n}`) logged what it matched, so "remote acme internal push" was recorded as
|
|
193
|
+
`network:remote acme internal push`. Such a term now logs its id in the needs table (`network:term-5`), also when
|
|
194
|
+
the prompt joins the words with hyphens, by the same rule as `trace.riskSources.term` (#194). Single-word terms
|
|
195
|
+
still log the word, and a match is never logged with blanks. Rows written earlier are not rewritten.
|
|
196
|
+
- **OpenCode v2: purging a plan no longer touches another plan's slots (#202).** `router_plan action=purge` collected
|
|
197
|
+
the clean slots of every other plan in the repository, a paused one included, once their slot marker was more than
|
|
198
|
+
7 days old. It now follows the manual gc's rule: the slots of a plan whose ledger exists are kept, whatever their
|
|
199
|
+
age. Unsaved work in another plan's slot no longer refuses the purge; unsaved work in a slot under this plan's slots
|
|
200
|
+
directory still does.
|
|
201
|
+
- **OpenCode v2: with `routing.background.mode: "off"`, a verified dispatch is verified again on OpenCode 2.3+
|
|
202
|
+
(#191).** Since 2.3 the host runs every native subagent child in the background and returns only a running
|
|
203
|
+
acknowledgement, so under `off` the router never saw the child's final text: the call got `[router] This subagent is
|
|
204
|
+
still running. Its result has not been verified…` and no verification ever followed. Under `off` the router still asks
|
|
205
|
+
for the foreground, but a root orchestrator's verifying call the host backgrounds anyway is now held and verified as
|
|
206
|
+
under `auto`: the acknowledgement says `Its result is held until verification finishes.`, the `<background-result>`
|
|
207
|
+
text stays hidden until the verdict, the `<router-verdict>` entry is posted once, and the router state lists the hold.
|
|
208
|
+
The check of a background completion waits for the file leases of its tree, held or not. This also covers a verified
|
|
209
|
+
call the user backgrounds on 2.0.x, which was only marked unverified. A role-routed call is tracked without a hold
|
|
210
|
+
(`Router guarantees apply when it completes.`): it keeps its binding and its budget and authority notices, its
|
|
211
|
+
child's report gets the `[router` line defang of a foreground role result, and after a restart a lost role call wakes
|
|
212
|
+
the orchestrator once. Other calls, foreground results (OpenCode 2.0.x, still verified without a lease wait), the
|
|
213
|
+
dispatch arguments and the protocol are unchanged under `off`. The pending journal is now read under `off` too; while
|
|
214
|
+
it cannot be read, a report the router cannot prove processed is withheld and a resume of a child it does not know is
|
|
215
|
+
refused, as under `auto`, but an untracked call dispatched by this process and session keeps its report and its
|
|
216
|
+
resume in that session. A verified dispatch made by a child session is still not verified on 2.3+, in any mode.
|
|
217
|
+
- **OpenCode v2: a same-process adopt and the old attachment's verification (#190).** Work of the cut attachment stops
|
|
218
|
+
at its next checkpoint without an inbox item: a re-provisioning slot claim still queued is cancelled (a provisioning
|
|
219
|
+
already running finishes), and no trailer search, commit or `cleanForChecks` starts after the cut. The adopt still
|
|
220
|
+
waits for work in progress; after 5 s it logs one warning naming what it waits for (`close-wait-slow` observation).
|
|
221
|
+
A plan-task grader is cancelled with its gate's deadline, also one whose session the host creates after the cut, and
|
|
222
|
+
a cut or timed-out gate is drained, at most 5 s with one warning, before its lease exemptions go or a retry starts.
|
|
223
|
+
The next attachment waits for an observation the old one started and verifies the observed attempt instead of the
|
|
224
|
+
restart fallback, which counted an attempt whose child committed on its own as `unverifiable`. A user `abort` cuts
|
|
225
|
+
that work the same way: a just-aborted plan gets no "restore the task branch" item.
|
|
226
|
+
- **OpenCode v2: Git LFS no longer stops the plan executor (#215).** Every Git LFS filter run (checkout, commit)
|
|
227
|
+
installs its `pre-push`, `post-checkout`, `post-commit` and `post-merge` hooks into `core.hooksPath`, which was
|
|
228
|
+
the executor's empty hooks directory: git ran `post-checkout` in the same call, and every later executor call failed
|
|
229
|
+
with `hooks directory is not empty`. The executor's `core.hooksPath` is now an empty regular file
|
|
230
|
+
(`<executor home>/git/hooks-off`, checked before every call), under which git finds no hook and Git LFS installs
|
|
231
|
+
none. An older home's `git/no-hooks` directory is no longer used.
|
|
232
|
+
|
|
233
|
+
### Security
|
|
234
|
+
|
|
235
|
+
- **OpenCode v2: the plan executor's git-lfs no longer runs programs the repository or its `.lfsconfig` names (#184).**
|
|
236
|
+
A filter program the executor's git runs (git-lfs, forwarded since #162 or kept as a `git lfs install --local` copy)
|
|
237
|
+
reads the repository's configuration and `.lfsconfig` itself. An agent in a slot could
|
|
238
|
+
`git config lfs.extension.x.clean evil` and have the executor's next `add` run `evil`, and a committed `.lfsconfig`
|
|
239
|
+
could register a custom transfer agent that the LFS server it names then selects for a download. Before every
|
|
240
|
+
executor git call the executor now derives what git-lfs would read: every repository entry (local, worktree, include
|
|
241
|
+
targets of any condition) and the `.lfsconfig` present when the call starts (the work tree's, else the index's, else
|
|
242
|
+
`HEAD`'s, as git-lfs picks it; read only when a filter or merge program is configured) is rebuilt as the `key=value`
|
|
243
|
+
lines of `git config -l`, split at line breaks and each line at its first `=`, as git-lfs splits them. So a key
|
|
244
|
+
holding `=` or a value holding a line break cannot forge a setting. Every derived key that is an extension
|
|
245
|
+
`clean`/`smudge`, holds a custom transfer agent's path or args, names a standalone transfer agent, or is
|
|
246
|
+
`core.sshCommand`, `core.askPass` or `lfs.storage` is blanked with `-c`, matched after case folding as Go's
|
|
247
|
+
`strings.ToLower` or JavaScript would fold it; from `.lfsconfig`, an extension's `clean`/`smudge` is left alone, as
|
|
248
|
+
git-lfs ignores it there. A credential helper resets the helper list with `-c credential.helper=`. Nothing is kept
|
|
249
|
+
for also being in the user's configuration. A blanked extension makes git-lfs fail, so with `filter.lfs.required`
|
|
250
|
+
git refuses the write. An LFS download that needs a repository-configured credential helper now fails with `E_GIT`.
|
|
251
|
+
The call is refused (`E_GIT`) when a derived key cannot be passed with `-c` exactly (a CR, a byte that is not UTF-8,
|
|
252
|
+
a malformed name, a section or variable that is not lowercase); when the `.lfsconfig` is a link, is not a regular
|
|
253
|
+
file or includes another file (git would read the included file, perhaps from a network share); and when a
|
|
254
|
+
repository include target (any condition, existing or not) is inside a work tree of the repository, since the
|
|
255
|
+
call's own checkout may write it before git-lfs reads it: a tracked config included with
|
|
256
|
+
`include.path=../.gitconfig` (or similar) refuses every executor call. Not covered yet: a `.lfsconfig` the call's
|
|
257
|
+
own checkout, cherry-pick or rebase writes before git-lfs starts (a server it names could still select a custom
|
|
258
|
+
transfer agent). Config-based hooks (`hook.<name>.command` with `hook.<name>.event`, which git 2.56 runs whatever
|
|
259
|
+
`core.hooksPath` says) are refused too, whatever the git version and with or without forwarding: when the
|
|
260
|
+
repository's configuration (local, worktree, an include target of any condition) sets any `hook.<name>.command` or
|
|
261
|
+
`hook.<name>.event`, every executor git call fails with `E_GIT` ("repository config defines git hooks"). The
|
|
262
|
+
verification snapshot and reference (OpenCode v1 and v2), whose `worktree add` and index writes fire hook events
|
|
263
|
+
too, refuse the same way through one more `git config` pre-check listing; their own git commands are unchanged.
|
|
264
|
+
- **OpenCode v2: the plan executor's git never downloads Git LFS objects (#208).** Every executor git call sets
|
|
265
|
+
`GIT_LFS_SKIP_SMUDGE=1`: during a checkout, cherry-pick, rebase, fast-forward merge or `worktree add`, Git LFS asks
|
|
266
|
+
no endpoint and starts no transfer program the repository's configuration names (`lfs.customtransfer.*`), even
|
|
267
|
+
when the same checkout writes the `.lfsconfig` naming the endpoint. The executor then restores, offline, each LFS
|
|
268
|
+
file whose object is already in the local LFS store, in slots and in the owner checkout when landing: it copies the
|
|
269
|
+
object itself (size and sha256 checked) and git re-hashes the file through Git LFS's clean filter. Nothing is
|
|
270
|
+
restored when the configuration names a Git LFS extension (`lfs.extension.*` in any letter case, whose programs
|
|
271
|
+
clean would run) or opts out (`--skip`); `lfs.fetchinclude`/`lfs.fetchexclude` select the files (an include read
|
|
272
|
+
conservatively: case-sensitive, a pattern with a `/` anchored at the root). A missing object stays a pointer file
|
|
273
|
+
(`git lfs pull` fetches it). The restore never fails the call: over 10,000 files or 4 GiB, or on an error, the files
|
|
274
|
+
stay pointer files and the executor logs a warning, which also names a temporary `.omr-lfs-*` file it could not
|
|
275
|
+
remove (slots ignore that name). See [Safety model](docs/EXECUTOR.md#safety-model).
|
|
276
|
+
- **Development dependencies: patched `toml`, `zod`, `effect` and `minimatch`.** The lockfile resolved vulnerable
|
|
277
|
+
versions through the `@opencode-ai/plugin` peer (`effect` 4.0.0-beta.83 with `toml` 4.3.0, `zod` 4.1.8) and the
|
|
278
|
+
`@opencode/plugin` dev dependency (`minimatch` 9 and 10). `package.json` now overrides them to `effect` ^4.1.0 (which
|
|
279
|
+
no longer depends on `toml`), `zod` ^4.6.6 and `minimatch` ^11.0.1. The published package has no dependencies, so
|
|
280
|
+
installs of the plugin are not affected; this only changes what a clone of the repository installs.
|
|
281
|
+
|
|
10
282
|
## [2.10.0] - 2026-11-27
|
|
11
283
|
|
|
12
284
|
### Changed
|
|
@@ -147,9 +419,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
147
419
|
`file_path`), and the session's repository (its git and common directories). After the host moved the session these
|
|
148
420
|
were checked against the old directory. The guard now uses the call's own lookup, the one the relative path uses. The
|
|
149
421
|
file leases and the role checks still use the session's first directory.
|
|
422
|
+
- **OpenCode v2: a tool call's bookkeeping uses the directory its checks used (#161).** After a tool ran, the router
|
|
423
|
+
looked the session's directory up again to resolve the call's relative `read`/`write`/`edit` path for the
|
|
424
|
+
changed-file record, the session's tool history and the guard's after-call step. That lookup could wait up to about
|
|
425
|
+
12 seconds on a host that did not answer (2 seconds for its own lookup, then up to 10 for the session record when no
|
|
426
|
+
earlier directory was known), could see a session the host had moved since, and when no directory was known it
|
|
427
|
+
skipped that bookkeeping for the call. The router now keeps, per call, the directory the call was checked against
|
|
428
|
+
and reuses it, without asking the host again. So the after-call step records the directory the call was checked
|
|
429
|
+
against: a session the host moves while the call waits (for example on a permission prompt) is recorded at its old
|
|
430
|
+
location. It keeps at most 1000 calls, for up to an hour each (a call can wait that long on a permission prompt),
|
|
431
|
+
only for the session that made the call, and drops a call's entry when the call is refused and a session's entries
|
|
432
|
+
when the session is deleted. Past that, or when the call's checks needed no directory, it looks the directory up as
|
|
433
|
+
before.
|
|
434
|
+
- **OpenCode v2: five more host lookups no longer wait forever on a host that does not answer (#161).** Each now gives
|
|
435
|
+
up after 10 seconds, the bound of the session record, and then counts as a failed lookup, with the same result as
|
|
436
|
+
before:
|
|
437
|
+
- reading a role child's session to bind it to its dispatch: the child stays unbound, so its role calls are refused;
|
|
438
|
+
- reading that child's first message for the binding: the child is bound by its title, as when that read fails;
|
|
439
|
+
- reading a session's first message to check a plan task: the tool call is not checked and the next call tries again;
|
|
440
|
+
- reading a resume target's first message for the stale-resume check: the target counts as one that could not be
|
|
441
|
+
checked, so the resume is not refused as stale;
|
|
442
|
+
- checking whether a session is the root (the legacy plugin's lookup): the session is not proven to be the root, so
|
|
443
|
+
the git metadata guard refuses only the writes it refuses for a delegated session (paths that name git metadata,
|
|
444
|
+
or any write while the session's directory is unknown), and the delegation instructions are still added to its
|
|
445
|
+
prompt. On OpenCode v1 this lookup is not bounded, as before.
|
|
150
446
|
|
|
151
447
|
### Security
|
|
152
448
|
|
|
449
|
+
- **A bare repository opened as the project is protected as git metadata (#161).** When OpenCode is opened at a bare
|
|
450
|
+
repository that holds its worktrees (`proj.git`), the git metadata guard did not see a repository there (it looks
|
|
451
|
+
for `.git`), so delegated agents could write the repository's own files: `config`, `hooks/`, `HEAD`, `objects/`,
|
|
452
|
+
`refs/`. The guard now recognises git's bare shape (a `HEAD` file and `objects` and `refs` directories, which may be
|
|
453
|
+
links to local directories) in the session directory or the nearest directory above it with that shape, unless a
|
|
454
|
+
checkout comes first, and refuses writes into that repository with the usual refusal. The files of its linked
|
|
455
|
+
worktrees inside it stay writable, if the worktree's admin directory and its `.git` file point at each other and the
|
|
456
|
+
admin directory's `commondir` names the repository (the `.git` file itself stays refused); a worktree inside one of
|
|
457
|
+
git's own directories (`hooks`, `objects`, `refs`, `lfs`, …) never is. A session in a linked worktree is checked as
|
|
458
|
+
before. OpenCode v1 and v2.
|
|
153
459
|
- **A patch call whose extra patch text cannot be read is refused (#161).** The host reads the first string among
|
|
154
460
|
`patchText`, `patch_text`, `patch` and `input`; the git metadata guard also reads the others. One of those with a file
|
|
155
461
|
header that names no path (`*** Add File:` and nothing after it) was skipped, and now makes the call refused like an
|
package/README.md
CHANGED
|
@@ -265,7 +265,8 @@ Then install and configure model-router to handle the rest.
|
|
|
265
265
|
### OpenCode v2
|
|
266
266
|
|
|
267
267
|
The v2 adapter supports OpenCode hosts **2.0.20 or later** and typechecks against
|
|
268
|
-
`@opencode/plugin` **2.3.2
|
|
268
|
+
`@opencode/plugin` **2.3.2**; hosts 2.3 and later were checked live on 2.4.2. Use
|
|
269
|
+
the v2 `plugins` key:
|
|
269
270
|
|
|
270
271
|
```json
|
|
271
272
|
{
|
|
@@ -1332,7 +1333,7 @@ These are character counts of the prompts the shipped config actually produces,
|
|
|
1332
1333
|
## Requirements
|
|
1333
1334
|
|
|
1334
1335
|
- [OpenCode](https://opencode.ai) v1 (`>=1.0.0 <2.0.0`) or v2 **2.0.20+** (TUI status: 2.0.24+)
|
|
1335
|
-
- Node.js 22+
|
|
1336
|
+
- Node.js 22+ (developing the plugin itself needs Node 22.18+, see [CONTRIBUTING.md](CONTRIBUTING.md#node-versions))
|
|
1336
1337
|
- Provider API keys configured in OpenCode
|
|
1337
1338
|
|
|
1338
1339
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-model-router",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "OpenCode plugin that routes tasks to tiered subagents (fast/medium/heavy) based on complexity",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -71,5 +71,12 @@
|
|
|
71
71
|
"solid-js": "1.9.17",
|
|
72
72
|
"typescript": "^7.0.2",
|
|
73
73
|
"vitest": "^5.1.1"
|
|
74
|
+
},
|
|
75
|
+
"overrides": {
|
|
76
|
+
"@opencode-ai/plugin": {
|
|
77
|
+
"effect": "^4.1.0",
|
|
78
|
+
"zod": "^4.6.6"
|
|
79
|
+
},
|
|
80
|
+
"minimatch": "^11.0.1"
|
|
74
81
|
}
|
|
75
82
|
}
|
package/src/compat/background.ts
CHANGED
|
@@ -379,6 +379,11 @@ export type FinishAttach = (deps: {
|
|
|
379
379
|
held: HeldSink;
|
|
380
380
|
/** The lease gate before plugin verification runs (memo §2.5); absent when `routing.leases.mode` is not `enforce`. */
|
|
381
381
|
leaseGate?: Pick<LeaseGuard, "waitTreeFree">;
|
|
382
|
+
/**
|
|
383
|
+
* #191: which checks wait for `leaseGate`. Absent: every plugin check. `"held"` (`routing.background.mode: "off"`): only the
|
|
384
|
+
* gate of a held result; a foreground check keeps the timing and result it had without a lease gate.
|
|
385
|
+
*/
|
|
386
|
+
leaseGateScope?: "held";
|
|
382
387
|
}) => FinishApi | undefined;
|
|
383
388
|
|
|
384
389
|
// ---- in-flight registry ----------------------------------------------------------------------
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #161: the bound of the OpenCode v2 host's session reads, shared by the v2 adapter (compat/v2-hooks.ts) and the legacy plugin
|
|
3
|
+
* surface it bridges (index.ts, on the v2 host only). A leaf module: OpenCode v1 loads it with index.ts and never uses it.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* #161: how long the shared session record (`sessionInfoOf`: the directory, parent and agent the role checks, the file leases and
|
|
8
|
+
* the stale-resume check read) waits for the host's `session.get`; past it the lookup counts as failed. Long on purpose, above
|
|
9
|
+
* background.ts's 5 s LOOKUP_TIMEOUT_MS: a miss refuses a role agent's call, so a slow but healthy host must not cause one.
|
|
10
|
+
*/
|
|
11
|
+
export const SESSION_INFO_LOOKUP_MS = 10_000;
|
|
12
|
+
|
|
13
|
+
/** #161: `lookup`'s answer, or a rejection once `ms` pass without one (the host call itself is left running). */
|
|
14
|
+
export function sessionLookupWithin<T>(lookup: PromiseLike<T>, ms: number): Promise<T> {
|
|
15
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
16
|
+
const timeout = new Promise<never>((_resolve, reject) => {
|
|
17
|
+
timer = setTimeout(() => reject(new Error(`session lookup timed out after ${ms} ms`)), ms);
|
|
18
|
+
if (typeof timer === "object" && typeof timer.unref === "function") timer.unref();
|
|
19
|
+
});
|
|
20
|
+
return Promise.race([lookup, timeout]).finally(() => clearTimeout(timer));
|
|
21
|
+
}
|