opencode-model-router 1.11.0 → 1.12.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 +145 -0
- package/README.md +10 -8
- package/package.json +1 -1
- package/src/escalate/ladder.ts +6 -0
- package/src/guard/fingerprint.ts +11 -2
- package/src/guard/guards.ts +9 -0
- package/src/index.ts +309 -38
- package/src/router/config.ts +61 -1
- package/src/router/dispatch-header.ts +36 -0
- package/src/router/false-refusal.ts +43 -0
- package/src/router/instructions.ts +65 -0
- package/src/router/prompts.ts +23 -6
- package/src/router/protocol.ts +2 -1
- package/src/router/sessions.ts +27 -2
- package/src/telemetry/trajectory.ts +10 -0
- package/src/verify/baseline.ts +78 -0
- package/src/verify/checker.ts +6 -0
- package/src/verify/deterministic.ts +45 -5
- package/src/verify/dispatch.ts +159 -8
- package/src/verify/gate.ts +31 -9
- package/src/verify/timeout.ts +8 -0
- package/src/verify/tree.ts +52 -0
- package/src/verify/types.ts +10 -0
- package/src/verify/wiring.ts +52 -15
- package/tiers.json +26 -25
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,151 @@ 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.12.0] - 2026-09-23
|
|
9
|
+
|
|
10
|
+
A subagent was refusing dispatched work outright — returning `ESCALATE: The Task tool
|
|
11
|
+
is not available in this session` or `the available tools here are not the
|
|
12
|
+
Read/Grep/Glob/Bash tools described in the request` — without making a single tool
|
|
13
|
+
call. This release is about the several independent causes behind that, and about an
|
|
14
|
+
acceptance gate that was rejecting work for its own inability to check it.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **The orchestrator delegation protocol no longer leaks into subagent sessions.**
|
|
19
|
+
Classification was an allowlist of tier names: `if (!input.agent ||
|
|
20
|
+
!tierNames.includes(input.agent))`. So `general`, `explore`, every
|
|
21
|
+
markdown-defined agent and — by construction — every agent mapped through
|
|
22
|
+
`subagentTiers` was never recognised as a child, because
|
|
23
|
+
`resolveSubagentOverrides` deliberately skips any name that collides with a tier.
|
|
24
|
+
The two features were mutually exclusive. Unrecognised children were then told
|
|
25
|
+
`You are the orchestrator: route each task to the right tier and delegate it with
|
|
26
|
+
Task(...)`, which is a MANDATORY instruction they have no tool to satisfy, and a
|
|
27
|
+
literal-minded model refuses the dispatch rather than improvising. Children are now
|
|
28
|
+
classified by `parentID`, from the `session.created` event with a memoised
|
|
29
|
+
`session.get` fallback — the code comment had claimed this mechanism for some time,
|
|
30
|
+
but the only event handler began `if (event?.type !== "session.idle") return;` and
|
|
31
|
+
no `session.created` branch existed. Grader sessions are excluded too; they are
|
|
32
|
+
created synchronously and would otherwise stall until their budget expired. The
|
|
33
|
+
guard also now fails closed: a transform with no session id no longer injects.
|
|
34
|
+
|
|
35
|
+
- **Tier prompts no longer assert a missing capability.** All six shipped prompts
|
|
36
|
+
ended their opening paragraph with `You have no Task tool and cannot sub-delegate.`
|
|
37
|
+
The statement is true — the runtime denies `task` to children on its own — but
|
|
38
|
+
training a hand-back reflex next to orchestrator text demanding delegation is what
|
|
39
|
+
produced `I cannot invoke a medium subagent… dispatch it from the orchestrator`.
|
|
40
|
+
The sentence is replaced with `You execute this dispatch yourself and do not
|
|
41
|
+
re-delegate it`, and a provider-neutral tool-authority clause is appended once at
|
|
42
|
+
agent assembly: your own schema is authoritative, tool names in a dispatch are
|
|
43
|
+
descriptive and vary by provider, an empty search result is a result, and refusing
|
|
44
|
+
because a named tool looks unavailable is not an acceptable answer. This matters
|
|
45
|
+
most in a mixed-family setup, where a dispatch written in one vendor's tool
|
|
46
|
+
vocabulary reads to another vendor's model as a list of tools it does not have.
|
|
47
|
+
|
|
48
|
+
- **Reading a different region of an already-opened file is no longer flagged as
|
|
49
|
+
redundant.** The read fingerprint was the path alone, so lines 400–600 of a file
|
|
50
|
+
whose first 200 lines had been read collided with the earlier call and produced
|
|
51
|
+
`[⚠ REDUNDANT]`. Combined with prompts that said to stop immediately on that
|
|
52
|
+
marker, it halted legitimate work. The fingerprint now includes any range
|
|
53
|
+
arguments; a read with no range keeps its previous fingerprint exactly, so no
|
|
54
|
+
banner output moved. The prompts now say the marker means stop repeating ground you
|
|
55
|
+
already covered, and that a different region is not a repeat.
|
|
56
|
+
|
|
57
|
+
- **The announced read-only budget is the one actually charged.** The dispatch header
|
|
58
|
+
resolved the cap from `tierCaps`, while enforcement resolved it from the dispatch's
|
|
59
|
+
own `CAP:` directive and the `reason:` justification rule, so the header could
|
|
60
|
+
announce a budget the guard would not honour. Both sides now read the same
|
|
61
|
+
directive through the same parser, and a test pins their equality so neither can
|
|
62
|
+
drift alone.
|
|
63
|
+
|
|
64
|
+
- **Subagent-tier mappings now carry a tier.** An agent listed in `subagentTiers` was
|
|
65
|
+
correctly excluded from protocol injection but remained untiered, which silently
|
|
66
|
+
disabled its caps, verification and escalation. It now resolves to its mapped tier.
|
|
67
|
+
Alongside it: a non-2xx `session.get` is no longer cached as "root" (the generated
|
|
68
|
+
client resolves rather than throws, so the error object was read as an absent
|
|
69
|
+
`parentID`), failed lookups are retried after 30s instead of every step, and
|
|
70
|
+
`session.deleted` evicts the classification state.
|
|
71
|
+
|
|
72
|
+
- **A polynomial-ReDoS finding in delegate instruction filtering.** CodeQL flagged the
|
|
73
|
+
path normalizer behind `delegateInstructions`, the same class as the two 1.11.1
|
|
74
|
+
fixes. Its trailing-slash strip, `/\/+$/`, re-scanned a run of slashes from every
|
|
75
|
+
start offset, so a project directory or an `Instructions from:` marker path made of
|
|
76
|
+
many slashes cost O(n²). It is now a linear backwards scan with identical semantics:
|
|
77
|
+
trim, backslashes to slashes, lower-case, then drop trailing slashes.
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- **Orchestrator instruction files are stripped from delegate sessions**
|
|
82
|
+
(`delegateInstructions`, default `strip-global`). opencode injects instruction
|
|
83
|
+
files — `AGENTS.md`, a global `CLAUDE.md` — into every session, children included.
|
|
84
|
+
A global orchestrator persona therefore reached every delegate telling it to fire
|
|
85
|
+
a `fast` agent via `Task` for any read-only work, and to treat a dispatch's
|
|
86
|
+
`REQUIRED TOOLS` list as a whitelist. Project-local files are kept by default
|
|
87
|
+
because they usually carry conventions the delegate needs; `strip-all` removes
|
|
88
|
+
every instruction file, `keep` restores the previous behaviour.
|
|
89
|
+
|
|
90
|
+
- **A mechanical dispatch header on every tier dispatch** (`dispatchHeader`, default
|
|
91
|
+
on). Roughly 260 tokens stating the tier identity, that the delegate executes the
|
|
92
|
+
work itself, the working directory and that it is already there, that tool names
|
|
93
|
+
are descriptive rather than restrictive, that empty results are results and
|
|
94
|
+
`.gitignore` filtering is not a broken tool, and the resolved read budget with what
|
|
95
|
+
the runtime's banners mean. This is dispatch hygiene that previously had to be
|
|
96
|
+
retyped by hand into every prompt, which is exactly the kind of thing that stops
|
|
97
|
+
being done.
|
|
98
|
+
|
|
99
|
+
- **Hand-backs made without trying are detected** (`falseRefusalDetection`, default
|
|
100
|
+
on). A child that returns `ESCALATE:` / `NEED MORE:` / `SCOPE GROWTH:` with a
|
|
101
|
+
capability complaint and **zero recorded tool calls** gets its result annotated for
|
|
102
|
+
the orchestrator: no tool call was observed, so the capability claim is untested
|
|
103
|
+
rather than demonstrated, and a tier escalation on that result is suppressed. The
|
|
104
|
+
detector requires all three signals together, so a genuine scope hand-back after
|
|
105
|
+
real work is untouched.
|
|
106
|
+
|
|
107
|
+
- **A third verification outcome: `unverifiable`, distinct from a failed check**
|
|
108
|
+
(`enforcement.verify.strictUnverifiable`, default off). The gate was rejecting —
|
|
109
|
+
and the ladder escalating a tier on — its own inability to check: a command the
|
|
110
|
+
allowlist refused, `buildPasses` in a repo with no build script, a grader that
|
|
111
|
+
timed out, a path it could not resolve. None of those are evidence that the
|
|
112
|
+
producer failed. They are now reported as caveats on an accepted result, which
|
|
113
|
+
never claims the check passed; `strictUnverifiable` restores rejection, but
|
|
114
|
+
terminates the ladder instead of escalating. Grader timeouts also scale with tier
|
|
115
|
+
(60s / 180s / 600s) rather than a flat 60s a thinking model cannot meet.
|
|
116
|
+
|
|
117
|
+
- **`testsPass` is judged against a measured baseline** (`enforcement.verify.testBaseline`,
|
|
118
|
+
default on; `baselineTimeoutMs`, default 60s). A suite with pre-existing unrelated
|
|
119
|
+
failures made every delegation unacceptable. A dispatch-time baseline is now
|
|
120
|
+
captured out of band, keyed by working directory, `HEAD`, a working-tree
|
|
121
|
+
fingerprint and the exact test command, and cached across dispatches. It is
|
|
122
|
+
discarded the moment it could have been contaminated by the producer's own edits,
|
|
123
|
+
because a contaminated baseline errs in the dangerous direction: a newly introduced
|
|
124
|
+
failure would appear in both runs and be excused. Equal failure counts or equal
|
|
125
|
+
non-zero exit codes do not prove the identities are unchanged, so they yield
|
|
126
|
+
`unverifiable` rather than a pass. A green baseline followed by a failure still
|
|
127
|
+
rejects. The grader is also handed the producer's own change delta instead of an
|
|
128
|
+
unqualified dirty tree, so it stops reporting "no files were modified" against
|
|
129
|
+
changes that predate the dispatch.
|
|
130
|
+
|
|
131
|
+
## [1.11.1] - 2026-08-24
|
|
132
|
+
|
|
133
|
+
### Added
|
|
134
|
+
|
|
135
|
+
- **Community health files.** `CONTRIBUTING.md`, `SECURITY.md`, `CODE_OF_CONDUCT.md`, a
|
|
136
|
+
pull request template, and a bug report form. The contributing guide writes down the
|
|
137
|
+
parts that are easy to miss from outside: golden snapshots are parameterized over every
|
|
138
|
+
preset and must be regenerated, model refs are only format-validated so the provider id
|
|
139
|
+
has to be checked against the models.dev catalog, and a new preset also needs a
|
|
140
|
+
`fallback.global` chain plus the README and config-reference counts.
|
|
141
|
+
|
|
142
|
+
### Fixed
|
|
143
|
+
|
|
144
|
+
- **Two polynomial-ReDoS findings on LLM-influenced input.** CodeQL flagged the guard's
|
|
145
|
+
ad-hoc script detection (`isSelfScript`) and the subagent task-result parser. The guard
|
|
146
|
+
now caps the command it scans at 20k characters and fails closed above that: truncating
|
|
147
|
+
would let padding push a redirect past the scan window, and a shell command that long is
|
|
148
|
+
itself a signal. The task-result parser dropped its regex entirely for a linear `indexOf`
|
|
149
|
+
scan — even a lazy capture backtracks polynomially on repeated open tags with no close —
|
|
150
|
+
keeping the same semantics: first open tag, first close tag after it, case-insensitive,
|
|
151
|
+
trimmed at the use site, raw output as the fallback.
|
|
152
|
+
|
|
8
153
|
## [1.11.0] - 2026-08-24
|
|
9
154
|
|
|
10
155
|
### Added
|
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
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
|
-
An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,
|
|
7
|
+
An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,120–5,111 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
|
|
6
8
|
|
|
7
9
|
## Why it's different
|
|
8
10
|
|
|
@@ -12,7 +14,7 @@ Most AI coding tools give you one model for everything. You pay Opus prices to r
|
|
|
12
14
|
The orchestrator runs on *every* message. Put Sonnet there, not Opus. Sonnet reads a routing protocol and delegates just as well as Opus — at 4x lower cost. Reserve Opus for when it genuinely matters.
|
|
13
15
|
|
|
14
16
|
**Inject a compressed, LLM-optimized routing protocol.**
|
|
15
|
-
Instead of duplicated prose, the plugin injects a dense, machine-readable routing protocol. The protocol itself is 3,
|
|
17
|
+
Instead of duplicated prose, the plugin injects a dense, machine-readable routing protocol. The protocol itself is 3,120 characters; a Claude orchestrator receives 3,892 characters after its authority prefix (roughly 965–1,075 tokens at 3.6–4.0 characters per token). Every message, every session.
|
|
16
18
|
|
|
17
19
|
**Match task to tier using a configurable taxonomy.**
|
|
18
20
|
A keyword routing guide (`@fast→search/grep/read`, `@medium→impl/refactor/test`, `@heavy→arch/debug/security`) tells the orchestrator exactly which tier fits each task type. Fully customizable. No ambiguity.
|
|
@@ -65,7 +67,7 @@ opencode-model-router injects a **delegation protocol** into the system prompt t
|
|
|
65
67
|
4. **Never over-qualify** — use the cheapest tier that can reliably handle the task
|
|
66
68
|
5. **Fallback** across providers when one fails
|
|
67
69
|
|
|
68
|
-
All of this adds 3,
|
|
70
|
+
All of this adds 3,120 characters for a non-Claude orchestrator or 3,892 characters for a Claude orchestrator (roughly 770–1,075 tokens at 3.6–4.0 characters per token).
|
|
69
71
|
|
|
70
72
|
## Understanding how it works
|
|
71
73
|
|
|
@@ -166,7 +168,7 @@ Task distribution: 18 exploration (60%), 10 implementation (33%), 2 architecture
|
|
|
166
168
|
|
|
167
169
|
## How it works
|
|
168
170
|
|
|
169
|
-
On every message, the plugin injects a 3,
|
|
171
|
+
On every message, the plugin injects a 3,120-character routing protocol. A Claude orchestrator receives 3,892 characters after its authority prefix (roughly 965–1,075 tokens at 3.6–4.0 characters per token). The notation is intentionally dense and compressed — it's **optimized for LLM comprehension, not human readability**. An agent reads it as a precise routing grammar; a human might squint at it.
|
|
170
172
|
|
|
171
173
|
What the orchestrator sees (Anthropic preset, normal mode):
|
|
172
174
|
|
|
@@ -218,7 +220,7 @@ With router → split:
|
|
|
218
220
|
| Cross-provider fallback | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
219
221
|
| Cost ratio awareness | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
220
222
|
| Plan annotation with tiers | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
221
|
-
| Measured prompt overhead: 3,
|
|
223
|
+
| Measured prompt overhead: 3,120–5,111 chars | ✅ | — | ❌ | ❌ | ❌ |
|
|
222
224
|
|
|
223
225
|
**Claude native**: single model for everything, no cost routing. If you're using claude.ai or OpenCode without plugins, you're paying the same price for `grep` as for architecture design.
|
|
224
226
|
|
|
@@ -871,7 +873,7 @@ Defines provider fallback order when a delegated task fails:
|
|
|
871
873
|
|
|
872
874
|
## Delegation enforcement (advisory by default)
|
|
873
875
|
|
|
874
|
-
The read-only cap banners described above are advisory: a well-behaved subagent will respect them, but nothing prevents a model from making one more read after the `[⚠ CAP REACHED]` banner. The **enforcement layer** turns delegation into a produce → verify → accept/escalate loop with independent acceptance and quality escalation. As of v1.3.0 it runs in **`advisory` mode by default**: every non-trivial delegation is verified and any
|
|
876
|
+
The read-only cap banners described above are advisory: a well-behaved subagent will respect them, but nothing prevents a model from making one more read after the `[⚠ CAP REACHED]` banner. The **enforcement layer** turns delegation into a produce → verify → accept/escalate loop with independent acceptance and quality escalation. As of v1.3.0 it runs in **`advisory` mode by default**: every non-trivial delegation is verified and any genuine failure surfaces a forcing-note, but nothing is ever hard-blocked (the DoD/acceptance section adds 1,219 characters to the orchestrator system prompt, roughly 305–340 tokens at 3.6–4.0 characters per token, and subagents may receive non-blocking guard banners). Unavailable verification is accepted with explicit caveats by default; `enforcement.verify.strictUnverifiable: true` restores rejection without producer escalation. Set `"mode": "off"` — or run `/router enforce off` — to restore byte-for-byte-unchanged routing with zero added prompt tokens and zero new latency. Hard-blocks only activate in `"mode": "enforced"`.
|
|
875
877
|
|
|
876
878
|
### The three enforcement layers
|
|
877
879
|
|
|
@@ -918,7 +920,7 @@ explicitly in `tiers.json`:
|
|
|
918
920
|
| Key | Bundled default | Bounds |
|
|
919
921
|
|-----|-----------------|--------|
|
|
920
922
|
| `delegateTimeoutMs` | `600000` (10 min) | One producer turn. |
|
|
921
|
-
| `graderTimeoutMs` | `60000`
|
|
923
|
+
| `graderTimeoutMs` | fast `60000` / medium `180000` / heavy `600000` | One grader turn; explicit override wins. |
|
|
922
924
|
| `gateBudgetMs` | `90000` (90 s) | The whole acceptance gate. |
|
|
923
925
|
|
|
924
926
|
Each budget is per **ladder attempt**, not per delegation: a fast → medium → heavy
|
|
@@ -993,7 +995,7 @@ After `/annotate-plan`:
|
|
|
993
995
|
|
|
994
996
|
## Token overhead
|
|
995
997
|
|
|
996
|
-
Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,
|
|
998
|
+
Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,120 characters for a non-Claude orchestrator. A Claude orchestrator receives 3,892 characters after its authority prefix, or 5,111 characters when the 1,219-character DoD/enforcement section is enabled. That is roughly 780–1,420 tokens across the three paths at 3.6–4.0 characters per token. The optional anti-narration clause adds another 650 characters to the Claude path.
|
|
997
999
|
|
|
998
1000
|
These are character counts of the prompts the shipped config actually produces, so they move whenever the protocol text does. `test/unit/docs-drift.test.ts` recomputes all three from `tiers.json` on every run and fails unless this section still quotes them, so a change that grows the protocol cannot land without updating these numbers.
|
|
999
1001
|
|
package/package.json
CHANGED
package/src/escalate/ladder.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface LadderAction {
|
|
|
32
32
|
|
|
33
33
|
export interface LadderVerdict {
|
|
34
34
|
pass: boolean;
|
|
35
|
+
outcome?: "pass" | "fail" | "unverifiable";
|
|
35
36
|
reasons?: string[];
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -113,6 +114,11 @@ export function nextAction(
|
|
|
113
114
|
if (verdict?.pass === true) {
|
|
114
115
|
return { action: "accept" };
|
|
115
116
|
}
|
|
117
|
+
// Strict policy may reject an unavailable check, but paying another producer
|
|
118
|
+
// cannot repair the verifier. Only actual failures enter the retry ladder.
|
|
119
|
+
if (verdict?.outcome === "unverifiable") {
|
|
120
|
+
return { action: "give_up", reason: "verification unavailable; no producer escalation" };
|
|
121
|
+
}
|
|
116
122
|
|
|
117
123
|
// (2) cost check
|
|
118
124
|
const costExceeded =
|
package/src/guard/fingerprint.ts
CHANGED
|
@@ -2,8 +2,17 @@
|
|
|
2
2
|
export function fingerprintToolCall(tool: string, args: unknown): string {
|
|
3
3
|
const a = (args ?? {}) as Record<string, unknown>;
|
|
4
4
|
switch (tool) {
|
|
5
|
-
case "read":
|
|
6
|
-
|
|
5
|
+
case "read": {
|
|
6
|
+
// Fixed field order preserves repeats regardless of argument insertion order.
|
|
7
|
+
// Keep path-only fingerprints unchanged when no range was supplied.
|
|
8
|
+
const range = Object.fromEntries(
|
|
9
|
+
["offset", "limit", "start", "end", "line", "lines", "range"]
|
|
10
|
+
.filter((key) => a[key] != null)
|
|
11
|
+
.map((key) => [key, a[key]]),
|
|
12
|
+
);
|
|
13
|
+
const suffix = Object.keys(range).length ? `:${JSON.stringify(range)}` : "";
|
|
14
|
+
return `read:${a.file_path ?? a.filePath ?? ""}${suffix}`;
|
|
15
|
+
}
|
|
7
16
|
case "grep":
|
|
8
17
|
return `grep:${a.pattern ?? ""}:${a.path ?? a.glob ?? ""}`;
|
|
9
18
|
case "glob":
|
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) ||
|