opencode-model-router 1.1.15 → 1.1.16
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/package.json +1 -1
- package/src/index.ts +33 -0
- package/tiers.json +13 -14
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -907,6 +907,11 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
907
907
|
// intentionally NOT tracked here (per user decision: enforce on subagents only).
|
|
908
908
|
const subagentCapState = new Map<string, SubagentState>();
|
|
909
909
|
|
|
910
|
+
// Bypass mode: when true, the router skips all system prompt injection,
|
|
911
|
+
// subagent tracking, cap enforcement, and narration detection for the
|
|
912
|
+
// current plugin lifetime (i.e., until OpenCode is restarted).
|
|
913
|
+
let bypassed = false;
|
|
914
|
+
|
|
910
915
|
return {
|
|
911
916
|
// -----------------------------------------------------------------------
|
|
912
917
|
// Detect subagent calls via chat.message. When the agent name matches a
|
|
@@ -927,6 +932,7 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
927
932
|
// is fully populated and await-safe (yield* on the plugin trigger).
|
|
928
933
|
// -----------------------------------------------------------------------
|
|
929
934
|
"chat.message": async (input: any, output: any) => {
|
|
935
|
+
if (bypassed) return;
|
|
930
936
|
// Re-read cfg so /preset switches take effect without restart
|
|
931
937
|
try {
|
|
932
938
|
cfg = loadConfig();
|
|
@@ -960,6 +966,7 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
960
966
|
// treats them as ground truth rather than advisory system noise.
|
|
961
967
|
// -----------------------------------------------------------------------
|
|
962
968
|
"tool.execute.after": async (input: any, output: any) => {
|
|
969
|
+
if (bypassed) return;
|
|
963
970
|
const state = subagentCapState.get(input.sessionID);
|
|
964
971
|
if (!state) return; // not a tracked subagent session
|
|
965
972
|
if (!READ_ONLY_TOOLS.has(input.tool)) return;
|
|
@@ -990,6 +997,7 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
990
997
|
// post-hoc signal.
|
|
991
998
|
// -----------------------------------------------------------------------
|
|
992
999
|
"experimental.text.complete": async (input: any, output: any) => {
|
|
1000
|
+
if (bypassed) return;
|
|
993
1001
|
const text = output?.text;
|
|
994
1002
|
if (typeof text !== "string" || text.length < 20) return;
|
|
995
1003
|
|
|
@@ -1062,6 +1070,11 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
1062
1070
|
description:
|
|
1063
1071
|
"Show or switch routing mode (e.g., /budget, /budget budget, /budget quality)",
|
|
1064
1072
|
};
|
|
1073
|
+
opencodeConfig.command["bypass"] = {
|
|
1074
|
+
template: "$ARGUMENTS",
|
|
1075
|
+
description:
|
|
1076
|
+
"Toggle model-router bypass (disables delegation protocol for this session)",
|
|
1077
|
+
};
|
|
1065
1078
|
opencodeConfig.command["annotate-plan"] = {
|
|
1066
1079
|
template: [
|
|
1067
1080
|
"Annotate the plan with tier directives for model delegation.",
|
|
@@ -1099,6 +1112,7 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
1099
1112
|
// just execute a task (especially smaller models like Haiku).
|
|
1100
1113
|
// -----------------------------------------------------------------------
|
|
1101
1114
|
"experimental.chat.system.transform": async (_input: any, output: any) => {
|
|
1115
|
+
if (bypassed) return;
|
|
1102
1116
|
try {
|
|
1103
1117
|
cfg = loadConfig(); // Returns cache unless invalidated
|
|
1104
1118
|
} catch {
|
|
@@ -1148,6 +1162,25 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
1148
1162
|
});
|
|
1149
1163
|
}
|
|
1150
1164
|
|
|
1165
|
+
if (input.command === "bypass") {
|
|
1166
|
+
const arg = (input.arguments ?? "").trim().toLowerCase();
|
|
1167
|
+
if (arg === "on") {
|
|
1168
|
+
bypassed = true;
|
|
1169
|
+
} else if (arg === "off") {
|
|
1170
|
+
bypassed = false;
|
|
1171
|
+
} else {
|
|
1172
|
+
bypassed = !bypassed;
|
|
1173
|
+
}
|
|
1174
|
+
const status = bypassed ? "ON" : "OFF";
|
|
1175
|
+
const desc = bypassed
|
|
1176
|
+
? "Model-router is **bypassed**. Delegation protocol, cap enforcement, and narration detection are disabled. The model will run without routing rules until you run `/bypass off` or restart OpenCode."
|
|
1177
|
+
: "Model-router is **active**. Delegation protocol and all enforcement rules are in effect.";
|
|
1178
|
+
output.parts.push({
|
|
1179
|
+
type: "text" as const,
|
|
1180
|
+
text: `# Bypass: ${status}\n\n${desc}`,
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1151
1184
|
if (input.command === "budget") {
|
|
1152
1185
|
try {
|
|
1153
1186
|
cfg = loadConfig();
|
package/tiers.json
CHANGED
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
42
|
"heavy": {
|
|
43
|
-
"model": "anthropic/claude-opus-4-
|
|
43
|
+
"model": "anthropic/claude-opus-4-6",
|
|
44
44
|
"variant": "high",
|
|
45
45
|
"costRatio": 20,
|
|
46
|
-
"description": "Opus 4.
|
|
46
|
+
"description": "Opus 4.6 high for architecture, complex debugging, and security",
|
|
47
47
|
"steps": 120,
|
|
48
48
|
"whenToUse": [
|
|
49
49
|
"Architecture decisions",
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
68
|
"medium": {
|
|
69
|
-
"model": "openai/gpt-5.
|
|
69
|
+
"model": "openai/gpt-5.4-fast",
|
|
70
70
|
"variant": "high",
|
|
71
71
|
"costRatio": 5,
|
|
72
|
-
"description": "GPT-5.
|
|
72
|
+
"description": "GPT-5.4 fast default settings for implementation and standard coding",
|
|
73
73
|
"steps": 50,
|
|
74
74
|
"whenToUse": [
|
|
75
75
|
"Feature implementation",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
]
|
|
80
80
|
},
|
|
81
81
|
"heavy": {
|
|
82
|
-
"model": "openai/gpt-5.
|
|
82
|
+
"model": "openai/gpt-5.5-fast",
|
|
83
83
|
"variant": "xhigh",
|
|
84
84
|
"costRatio": 20,
|
|
85
85
|
"description": "GPT-5.4 xhigh for architecture and complex tasks",
|
|
@@ -173,9 +173,9 @@
|
|
|
173
173
|
},
|
|
174
174
|
"hybrid": {
|
|
175
175
|
"fast": {
|
|
176
|
-
"model": "
|
|
176
|
+
"model": "firepass/accounts/fireworks/routers/kimi-k2p6-turbo",
|
|
177
177
|
"costRatio": 1,
|
|
178
|
-
"description": "
|
|
178
|
+
"description": "Kimi 2.6 turbo for exploration, search, and simple reads",
|
|
179
179
|
"steps": 30,
|
|
180
180
|
"whenToUse": [
|
|
181
181
|
"Codebase exploration and search",
|
|
@@ -185,24 +185,23 @@
|
|
|
185
185
|
]
|
|
186
186
|
},
|
|
187
187
|
"medium": {
|
|
188
|
-
"model": "
|
|
189
|
-
"variant": "
|
|
188
|
+
"model": "openai/gpt-5.5-fast",
|
|
189
|
+
"variant": "high",
|
|
190
190
|
"costRatio": 5,
|
|
191
|
-
"description": "
|
|
191
|
+
"description": "GPT-5.5 fast default settings for implementation and standard coding",
|
|
192
192
|
"steps": 50,
|
|
193
193
|
"whenToUse": [
|
|
194
194
|
"Feature implementation",
|
|
195
195
|
"Refactoring",
|
|
196
196
|
"Writing tests",
|
|
197
|
-
"Code review",
|
|
198
197
|
"Bug fixes"
|
|
199
198
|
]
|
|
200
199
|
},
|
|
201
200
|
"heavy": {
|
|
202
|
-
"model": "anthropic/claude-opus-4-
|
|
203
|
-
"variant": "
|
|
201
|
+
"model": "anthropic/claude-opus-4-6",
|
|
202
|
+
"variant": "max",
|
|
204
203
|
"costRatio": 20,
|
|
205
|
-
"description": "Claude Opus 4.
|
|
204
|
+
"description": "Claude Opus 4.6 max for architecture, complex debugging, and security",
|
|
206
205
|
"steps": 120,
|
|
207
206
|
"whenToUse": [
|
|
208
207
|
"Architecture decisions",
|