opencode-model-router 2.0.0 → 2.1.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 +68 -0
- package/README.md +70 -4
- package/package.json +2 -2
- package/src/compat/child-session.ts +5 -0
- package/src/compat/v2-hooks.ts +47 -14
- package/src/escalate/effort-override.ts +165 -0
- package/src/escalate/ladder.ts +57 -7
- package/src/index.ts +180 -14
- package/src/router/agent-options.ts +43 -12
- package/src/router/config.ts +131 -20
- package/src/router/depth-guard.ts +152 -0
- package/src/router/depth.ts +826 -0
- package/src/v2.ts +1 -0
- package/src/verify/wiring.ts +16 -2
package/src/v2.ts
CHANGED
|
@@ -17,6 +17,7 @@ export default {
|
|
|
17
17
|
worktree: ctx.location.project.directory,
|
|
18
18
|
client: runtime.client,
|
|
19
19
|
routerChildRunner: runtime.childRunner,
|
|
20
|
+
routerHost: "v2" as const,
|
|
20
21
|
};
|
|
21
22
|
const hooks = await ModelRouterPlugin(input as unknown as PluginInput);
|
|
22
23
|
return registerV2Hooks(ctx, hooks, runtime);
|
package/src/verify/wiring.ts
CHANGED
|
@@ -914,7 +914,7 @@ export interface VerificationWiring {
|
|
|
914
914
|
* the changed files are "unavailable" and the reference is the untracked default. `deadline`
|
|
915
915
|
* bounds every testsPass step (T3); without it each testsPass check owns one of gateBudgetMs.
|
|
916
916
|
*/
|
|
917
|
-
buildGateDeps(parentSessionID?: string, inFlight?: Set<string>, prepared?: PreparedVerification, deadline?: Deadline): GateDeps;
|
|
917
|
+
buildGateDeps(parentSessionID?: string, inFlight?: Set<string>, prepared?: PreparedVerification, deadline?: Deadline, forceLowPriority?: boolean, creatorSessionID?: string | null): GateDeps;
|
|
918
918
|
/**
|
|
919
919
|
* 2.2.3: the idle-TTL sweep's hook into the plugin's one S5 batch coordinator (batch.ts B11):
|
|
920
920
|
* evicts windows with no live member and batches whose seam hung past BATCH_STALE_GRACE_MS.
|
|
@@ -969,6 +969,8 @@ export function createVerificationWiring(deps: {
|
|
|
969
969
|
getConfig: () => RouterConfig;
|
|
970
970
|
/** Default: console.warn, no debug output. */
|
|
971
971
|
logger?: WiringLogger;
|
|
972
|
+
/** Record each grader's creator before its first prompt, independently of its backend parent. */
|
|
973
|
+
onChildSessionCreated?: (sid: string, creatorSid: string | null) => void;
|
|
972
974
|
/** Test seams of the S5 batch coordinator (clock, timers, platform, maximum window size). */
|
|
973
975
|
batch?: Omit<BatchCoordinatorOptions, "logger">;
|
|
974
976
|
/** Test seams of the pending registry (clock, random source). */
|
|
@@ -1197,10 +1199,19 @@ export function createVerificationWiring(deps: {
|
|
|
1197
1199
|
}
|
|
1198
1200
|
};
|
|
1199
1201
|
|
|
1202
|
+
const notifyChildCreated = (sid: string, creatorSid: string | null): void => {
|
|
1203
|
+
try {
|
|
1204
|
+
deps.onChildSessionCreated?.(sid, creatorSid);
|
|
1205
|
+
} catch (error) {
|
|
1206
|
+
logger.warn("[verify] child-session hook failed", { error: errorText(error) });
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1200
1210
|
const dispatchGrader = async (
|
|
1201
1211
|
req: GraderRequest,
|
|
1202
1212
|
parentSessionID?: string,
|
|
1203
1213
|
inFlight?: Set<string>,
|
|
1214
|
+
creatorSessionID: string | null = parentSessionID ?? null,
|
|
1204
1215
|
): Promise<{ sessionID: string; text: string }> => {
|
|
1205
1216
|
if (deps.childRunner) {
|
|
1206
1217
|
const cfg = getConfig();
|
|
@@ -1218,6 +1229,7 @@ export function createVerificationWiring(deps: {
|
|
|
1218
1229
|
sid = sessionID;
|
|
1219
1230
|
graderSessions.add(sessionID);
|
|
1220
1231
|
inFlight?.add(sessionID);
|
|
1232
|
+
notifyChildCreated(sessionID, creatorSessionID);
|
|
1221
1233
|
},
|
|
1222
1234
|
}), graderTimeoutMs(req.tier, cfg.enforcement?.verify?.graderTimeoutMs), "grader prompt");
|
|
1223
1235
|
} finally {
|
|
@@ -1242,6 +1254,7 @@ export function createVerificationWiring(deps: {
|
|
|
1242
1254
|
if (!sid) return { sessionID: "", text: "" };
|
|
1243
1255
|
graderSessions.add(sid);
|
|
1244
1256
|
inFlight?.add(sid);
|
|
1257
|
+
notifyChildCreated(sid, creatorSessionID);
|
|
1245
1258
|
try {
|
|
1246
1259
|
const cfg = getConfig();
|
|
1247
1260
|
const model = tierModel(cfg, req.tier) ?? undefined;
|
|
@@ -1315,6 +1328,7 @@ export function createVerificationWiring(deps: {
|
|
|
1315
1328
|
prepared?: PreparedVerification,
|
|
1316
1329
|
deadline?: Deadline,
|
|
1317
1330
|
forceLowPriority = false,
|
|
1331
|
+
creatorSessionID: string | null = parentSessionID ?? null,
|
|
1318
1332
|
): GateDeps => {
|
|
1319
1333
|
const cfg = getConfig();
|
|
1320
1334
|
const resolved = resolveVerifyBudget(cfg);
|
|
@@ -1393,7 +1407,7 @@ export function createVerificationWiring(deps: {
|
|
|
1393
1407
|
},
|
|
1394
1408
|
checker: {
|
|
1395
1409
|
dispatchGrader: (req: GraderRequest) =>
|
|
1396
|
-
dispatchGrader(req, parentSessionID, inFlight),
|
|
1410
|
+
dispatchGrader(req, parentSessionID, inFlight, creatorSessionID),
|
|
1397
1411
|
ladder: ["fast", "medium", "heavy"],
|
|
1398
1412
|
minGraderTier: cfg.enforcement?.verify?.minGraderTier ?? null,
|
|
1399
1413
|
},
|