opencode-model-router 1.11.0 → 1.11.1
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 +22 -0
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/guard/guards.ts +9 -0
- package/src/verify/dispatch.ts +20 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,28 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.11.1] - 2026-08-24
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Community health files.** `CONTRIBUTING.md`, `SECURITY.md`, `CODE_OF_CONDUCT.md`, a
|
|
13
|
+
pull request template, and a bug report form. The contributing guide writes down the
|
|
14
|
+
parts that are easy to miss from outside: golden snapshots are parameterized over every
|
|
15
|
+
preset and must be regenerated, model refs are only format-validated so the provider id
|
|
16
|
+
has to be checked against the models.dev catalog, and a new preset also needs a
|
|
17
|
+
`fallback.global` chain plus the README and config-reference counts.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- **Two polynomial-ReDoS findings on LLM-influenced input.** CodeQL flagged the guard's
|
|
22
|
+
ad-hoc script detection (`isSelfScript`) and the subagent task-result parser. The guard
|
|
23
|
+
now caps the command it scans at 20k characters and fails closed above that: truncating
|
|
24
|
+
would let padding push a redirect past the scan window, and a shell command that long is
|
|
25
|
+
itself a signal. The task-result parser dropped its regex entirely for a linear `indexOf`
|
|
26
|
+
scan — even a lazy capture backtracks polynomially on repeated open tags with no close —
|
|
27
|
+
keeping the same semantics: first open tag, first close tag after it, case-insensitive,
|
|
28
|
+
trimmed at the use site, raw output as the fallback.
|
|
29
|
+
|
|
8
30
|
## [1.11.0] - 2026-08-24
|
|
9
31
|
|
|
10
32
|
### Added
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# opencode-model-router
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/opencode-model-router)
|
|
4
|
+
|
|
3
5
|
> **Use the cheapest model that can do the job. Automatically.**
|
|
4
6
|
|
|
5
7
|
An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,116–4,686 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
|
package/package.json
CHANGED
package/src/guard/guards.ts
CHANGED
|
@@ -64,6 +64,13 @@ const INLINE_SCRIPT_RE = /\b(node|python3?|deno|bun)\s+-(e|c)\b/i;
|
|
|
64
64
|
const CAT_WRITE_RE = /\bcat\s+>\s*\S/i;
|
|
65
65
|
const BASH_C_RE = /\bbash\s+-c\b/i;
|
|
66
66
|
|
|
67
|
+
// Upper bound on the command length we are willing to scan with the regexes
|
|
68
|
+
// above. Several of them are polynomial on adversarial input (CodeQL
|
|
69
|
+
// js/polynomial-redos), and a shell command this long is itself a signal.
|
|
70
|
+
// Truncating instead would let padding push a redirect past the scan window, so
|
|
71
|
+
// an over-length command is flagged, not waved through.
|
|
72
|
+
const MAX_GUARD_SCAN_CHARS = 20_000;
|
|
73
|
+
|
|
67
74
|
// ---------------------------------------------------------------------------
|
|
68
75
|
// Write tools set (module-level)
|
|
69
76
|
// ---------------------------------------------------------------------------
|
|
@@ -113,6 +120,8 @@ export function isSelfScript(call: GuardCall, policy: GuardPolicy): boolean {
|
|
|
113
120
|
if (call.tool === "bash" || call.tool === "shell") {
|
|
114
121
|
const cmd = String(args.command ?? args.cmd ?? "");
|
|
115
122
|
if (!cmd) return false;
|
|
123
|
+
// Fail closed: too long to scan safely, so treat it as suspicious.
|
|
124
|
+
if (cmd.length > MAX_GUARD_SCAN_CHARS) return true;
|
|
116
125
|
return (
|
|
117
126
|
HEREDOC_RE.test(cmd) ||
|
|
118
127
|
REDIRECT_SCRIPT_RE.test(cmd) ||
|
package/src/verify/dispatch.ts
CHANGED
|
@@ -90,7 +90,24 @@ export function createChangedFileStore(options: ChangedFileStoreOptions = {}) {
|
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const
|
|
93
|
+
const TASK_RESULT_OPEN = "<task_result>";
|
|
94
|
+
const TASK_RESULT_CLOSE = "</task_result>";
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Linear-time extraction of the <task_result> body. Any regex scan here, even a
|
|
98
|
+
* lazy one, backtracks polynomially on repeated open tags with no close
|
|
99
|
+
* (CodeQL js/polynomial-redos), so this walks the string with indexOf instead.
|
|
100
|
+
* Case-insensitive, like the regex it replaced: first open tag, then the first
|
|
101
|
+
* close tag after it. Returns null when either tag is missing.
|
|
102
|
+
*/
|
|
103
|
+
function extractTaskResult(raw: string): string | null {
|
|
104
|
+
const lower = raw.toLowerCase();
|
|
105
|
+
const start = lower.indexOf(TASK_RESULT_OPEN);
|
|
106
|
+
if (start === -1) return null;
|
|
107
|
+
const end = lower.indexOf(TASK_RESULT_CLOSE, start + TASK_RESULT_OPEN.length);
|
|
108
|
+
if (end === -1) return null;
|
|
109
|
+
return raw.slice(start + TASK_RESULT_OPEN.length, end);
|
|
110
|
+
}
|
|
94
111
|
|
|
95
112
|
/**
|
|
96
113
|
* Parse the built-in `task` tool's after-hook output: the child's final return
|
|
@@ -103,8 +120,8 @@ export function parseTaskResult(output: unknown): {
|
|
|
103
120
|
} {
|
|
104
121
|
const o = (output ?? {}) as Record<string, unknown>;
|
|
105
122
|
const raw = typeof o.output === "string" ? o.output : "";
|
|
106
|
-
const
|
|
107
|
-
const finalReturnText = (
|
|
123
|
+
const inner = extractTaskResult(raw);
|
|
124
|
+
const finalReturnText = (inner ?? raw).trim();
|
|
108
125
|
const meta = (o.metadata ?? {}) as Record<string, unknown>;
|
|
109
126
|
const childSessionID =
|
|
110
127
|
typeof meta.sessionId === "string"
|