@bizzywork/routing 0.2.0 → 0.4.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/dist/bundle/bizzy-routing.js +4 -4
- package/dist/bundle/{clack-ui-KUXMJI7C.js → clack-ui-KG2I32T5.js} +1 -0
- package/dist/bundle/harnesses/claude-code/hooks/register.ts +23 -4
- package/dist/bundle/harnesses/omp/index.ts +13 -2
- package/dist/bundle/{main-7NNVOX2S.js → main-7SKYJ7DD.js} +497 -101
- package/dist/bundle/{ui-4PTMUQQ4.js → ui-PEKFVWX7.js} +4 -0
- package/package.json +1 -1
|
@@ -24,9 +24,9 @@ async function readStdin() {
|
|
|
24
24
|
for await (const chunk of process.stdin) text += String(chunk);
|
|
25
25
|
return text;
|
|
26
26
|
}
|
|
27
|
-
var { run } = await import("./main-
|
|
28
|
-
var { plainUi } = await import("./ui-
|
|
29
|
-
var { clackUi, showError } = await import("./clack-ui-
|
|
27
|
+
var { run } = await import("./main-7SKYJ7DD.js");
|
|
28
|
+
var { plainUi } = await import("./ui-PEKFVWX7.js");
|
|
29
|
+
var { clackUi, showError } = await import("./clack-ui-KG2I32T5.js");
|
|
30
30
|
var interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
31
31
|
try {
|
|
32
32
|
const result = await run({
|
|
@@ -35,7 +35,7 @@ try {
|
|
|
35
35
|
home: homedir(),
|
|
36
36
|
execPath: process.execPath,
|
|
37
37
|
bundleDir: dirname(fileURLToPath(import.meta.url)),
|
|
38
|
-
version: true ? "0.
|
|
38
|
+
version: true ? "0.4.0" : "dev",
|
|
39
39
|
platform: process.platform,
|
|
40
40
|
uid: process.getuid?.(),
|
|
41
41
|
interactive,
|
|
@@ -1370,6 +1370,7 @@ function clackUi() {
|
|
|
1370
1370
|
intro: (title) => intro(styleText3(["bgCyan", "black"], ` ${title} `)),
|
|
1371
1371
|
outro: (message) => outro(message),
|
|
1372
1372
|
note: (body, title) => note(body, title),
|
|
1373
|
+
command: (command, title) => note(styleText3(["bold", "cyan"], command), title),
|
|
1373
1374
|
message: (text) => log.message(text),
|
|
1374
1375
|
warn: (message) => log.warn(message),
|
|
1375
1376
|
step: async (message, work, done) => {
|
|
@@ -24,6 +24,8 @@ interface Decision {
|
|
|
24
24
|
rule: string;
|
|
25
25
|
reason: string;
|
|
26
26
|
notice?: string;
|
|
27
|
+
/** Set when a live routing-vs-control comparison sampled this turn. "control" keeps the native model. */
|
|
28
|
+
arm?: "treatment" | "control";
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const WINDOW = 24;
|
|
@@ -233,7 +235,13 @@ async function fallback<E extends { model: string; turnId: string }>(
|
|
|
233
235
|
error: unknown,
|
|
234
236
|
): Promise<E | undefined> {
|
|
235
237
|
const text = error instanceof Error ? error.message : String(error ?? "");
|
|
236
|
-
|
|
238
|
+
// Bare "model" matched too much: "Fable requires usage credits. /model to switch models." is a
|
|
239
|
+
// hard refusal, not a flaky retry, but only by luck of containing the word "model" at all —
|
|
240
|
+
// "the model is temporarily overloaded, please retry" would have matched the same way.
|
|
241
|
+
const transient =
|
|
242
|
+
!/not.?found|permission denied|40[34]|usage credit|insufficient.?credit|quota exceeded/i.test(
|
|
243
|
+
text,
|
|
244
|
+
);
|
|
237
245
|
let model = e.model;
|
|
238
246
|
try {
|
|
239
247
|
const decision = await post<{ model: string | null }>($, "/v1/harness/fallback", {
|
|
@@ -296,7 +304,10 @@ export const register: Register = (on) => {
|
|
|
296
304
|
on("command.run", { command: "model" }, async ($, e, next) => {
|
|
297
305
|
const result = await next(e);
|
|
298
306
|
await sync($);
|
|
299
|
-
|
|
307
|
+
// Gating on e.args meant picking a model from /model's own interactive menu (no inline
|
|
308
|
+
// argument) never paused Bizzy Auto: the next turn routed right over the manual pick. By the
|
|
309
|
+
// time next(e) resolves the pick is final either way, so just check whether Bizzy is on.
|
|
310
|
+
if (enabled) pause($, await $.session.model());
|
|
300
311
|
return result;
|
|
301
312
|
}).catch(($, e, next) => (next.called ? {} : next(e)));
|
|
302
313
|
|
|
@@ -329,12 +340,20 @@ export const register: Register = (on) => {
|
|
|
329
340
|
);
|
|
330
341
|
if (!claudeModel.test(decision.model)) throw new Error("not a Claude model id");
|
|
331
342
|
if (first) notice = decision.notice;
|
|
332
|
-
|
|
343
|
+
// Control keeps the request on Claude Code's own model: the comparison needs a sample of
|
|
344
|
+
// turns Bizzy never touched, not just an opinion it kept to itself.
|
|
345
|
+
const control = decision.arm === "control";
|
|
346
|
+
show(
|
|
347
|
+
$,
|
|
348
|
+
control
|
|
349
|
+
? `Bizzy Auto · control · keeping ${current}`
|
|
350
|
+
: `Bizzy Auto · ${decision.model} · ${notice ? "own rules" : decision.rule}${decision.arm ? " · treatment" : ""}`,
|
|
351
|
+
);
|
|
333
352
|
if (notice && !noticed) {
|
|
334
353
|
noticed = true;
|
|
335
354
|
$.ui.toast(`Bizzy Auto: ${notice}`);
|
|
336
355
|
}
|
|
337
|
-
routed = { ...e, model: decision.model };
|
|
356
|
+
if (!control) routed = { ...e, model: decision.model };
|
|
338
357
|
}
|
|
339
358
|
} catch (error) {
|
|
340
359
|
show(
|
|
@@ -33,6 +33,8 @@ interface Decision {
|
|
|
33
33
|
rule: string;
|
|
34
34
|
reason: string;
|
|
35
35
|
notice?: string;
|
|
36
|
+
/** Set when a live routing-vs-control comparison sampled this turn. "control" keeps the native model. */
|
|
37
|
+
arm?: "treatment" | "control";
|
|
36
38
|
}
|
|
37
39
|
interface ModelsReply {
|
|
38
40
|
picks: { efficient: string; capable: string } | null;
|
|
@@ -245,6 +247,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
245
247
|
const session = safeId(options?.sessionId ?? "omp");
|
|
246
248
|
const turn = turnOf(context.messages as never);
|
|
247
249
|
let target: Model = fallbackModel;
|
|
250
|
+
// Set once Bizzy samples this turn into control: the comparison needs turns Bizzy never
|
|
251
|
+
// touched, including on failure, not just an opinion it kept to itself.
|
|
252
|
+
let control = false;
|
|
248
253
|
if (shared.enabled) {
|
|
249
254
|
try {
|
|
250
255
|
if (shared.sent !== JSON.stringify(candidates(c).map(modelId))) await sendModels(c);
|
|
@@ -269,9 +274,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
269
274
|
return ask();
|
|
270
275
|
});
|
|
271
276
|
shared.compacted = false;
|
|
272
|
-
|
|
277
|
+
control = decision.arm === "control";
|
|
278
|
+
target = control ? fallbackModel : (pick(c, decision.model) ?? fallbackModel);
|
|
273
279
|
if (turn.index === 0) shared.notice = decision.notice;
|
|
274
|
-
show(
|
|
280
|
+
show(
|
|
281
|
+
control
|
|
282
|
+
? `Bizzy Auto · control · keeping ${modelId(target)}`
|
|
283
|
+
: `Bizzy Auto · ${modelId(target)} · ${shared.notice ? "own rules" : decision.rule}${decision.arm ? " · treatment" : ""}`,
|
|
284
|
+
);
|
|
275
285
|
if (shared.notice && !shared.noticed) {
|
|
276
286
|
shared.noticed = true;
|
|
277
287
|
c.ui.notify(`Bizzy Auto: ${shared.notice}`, "info");
|
|
@@ -321,6 +331,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
321
331
|
opened.failed &&
|
|
322
332
|
opened.failed.stopReason !== "aborted" &&
|
|
323
333
|
shared.enabled &&
|
|
334
|
+
!control &&
|
|
324
335
|
!options?.signal?.aborted
|
|
325
336
|
) {
|
|
326
337
|
const text = opened.failed.errorMessage ?? "";
|