zelio-cli 0.1.0-beta.3 → 0.1.0-beta.5

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.
@@ -33,7 +33,7 @@ import { consultWatchdog } from "../run/watchdog.js";
33
33
  import { consultReviewer } from "../run/auto-review.js";
34
34
  import { buildCheckFixPrompt, buildCommentPrompt, buildConflictPrompt, buildReviewPrompt, COMMENT_AGENT_PROMPT, CONFLICT_AGENT_PROMPT, REVIEW_AGENT_PROMPT, VERIFIED_CODING_AGENT_PROMPT, } from "../run/prompt.js";
35
35
  import { listCodexModels } from "../run/codex-client.js";
36
- import { listHarnessModels } from "../run/harnesses.js";
36
+ import { HARNESSES, listHarnessModels } from "../run/harnesses.js";
37
37
  import { profileFor } from "../run/profiles.js";
38
38
  import { readSkills, skillBriefs, skillStoreOf } from "../run/skills.js";
39
39
  import { asMaxAgents, asPlannerThinking } from "../run/settings.js";
@@ -83,6 +83,13 @@ function turnRefusal(c, cause) {
83
83
  }
84
84
  throw cause;
85
85
  }
86
+ /** A harness id the dialog sent that the server does not know; null when it is fine or absent. */
87
+ function unknownHarness(value) {
88
+ if (typeof value !== "string")
89
+ return null;
90
+ const id = value.trim();
91
+ return id && !HARNESSES.some((harness) => harness.id === id) ? id : null;
92
+ }
86
93
  /**
87
94
  * The bottom panel's shells are local only: a pseudoterminal is a shell on the
88
95
  * Mac, so the tunnel allowlist does not carry these routes, and the routes
@@ -211,10 +218,13 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
211
218
  const skills = skillStore ?? skillStoreOf(db);
212
219
  const setupStore = setup ?? memorySetupStore({ harness: "pi", modelChosen: true });
213
220
  const effectiveHarness = () => harness?.trim() || process.env.ZELIO_HARNESS?.trim() || setupStore.read().harness || "pi";
214
- const effectivePlannerModel = () => {
221
+ // A saved model belongs to the harness it was saved under, so a model picked
222
+ // on another harness never falls back to the saved one.
223
+ const plannerModelFor = (command) => {
215
224
  const saved = setupStore.read();
216
- return effectiveHarness() === saved.harness ? saved.plannerModel : "";
225
+ return command === saved.harness ? saved.plannerModel : "";
217
226
  };
227
+ const effectivePlannerModel = () => plannerModelFor(effectiveHarness());
218
228
  const effectiveDeveloperModel = () => {
219
229
  const saved = setupStore.read();
220
230
  return effectiveHarness() === saved.harness ? saved.developerModel : "";
@@ -895,36 +905,47 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
895
905
  skills: skillBriefs(readSkills(skills)),
896
906
  };
897
907
  };
908
+ /**
909
+ * The harness and model one planner turn runs on: the dialog's pick for the
910
+ * turn, else the board's harness and its saved model.
911
+ */
912
+ const plannerChoice = (turnHarness, turnModel) => {
913
+ const command = turnHarness || effectiveHarness();
914
+ return { command, model: turnModel || plannerModelFor(command) };
915
+ };
898
916
  const runPlan = plan ??
899
- (async (messages, brief, draft, board, onStatus, handoff, mode, onStats, attachments = [], images = [], thinking, findings, timeoutMs, linked, turnModel) => runOrchestrator({
900
- repoRoot: root,
901
- messages,
902
- brief,
903
- plan: draft,
904
- board,
905
- handoff,
906
- // The door changes the directive. Dropping it here silently gave every
907
- // real turn the chat prompt while tests saw the new-task one.
908
- mode,
909
- attachments,
910
- images,
911
- command: effectiveHarness(),
912
- // The dialog's choice for this turn, else the saved planner model.
913
- planner: createPlanner(effectiveHarness(), turnModel || effectivePlannerModel()),
914
- model: turnModel || effectivePlannerModel() || undefined,
915
- thinking: thinking ?? plannerThinkingForTurn(),
916
- budget: plannerToolBudget,
917
- // The planner and the run it writes for must agree on what "done" means;
918
- // otherwise every ticket it drafts asks for a check the run will skip.
919
- workflow: db.getStageWorkflow("in_progress"),
920
- onStatus,
921
- onStats,
922
- research: findings,
923
- timeoutMs,
924
- linkedBoards: linked,
925
- // The intake drafts no run, so it does not wait on a model list.
926
- developer: mode === "intake" ? null : await developerBrief(),
927
- }));
917
+ (async (messages, brief, draft, board, onStatus, handoff, mode, onStats, attachments = [], images = [], thinking, findings, timeoutMs, linked, turnModel, turnHarness) => {
918
+ const choice = plannerChoice(turnHarness, turnModel);
919
+ return runOrchestrator({
920
+ repoRoot: root,
921
+ messages,
922
+ brief,
923
+ plan: draft,
924
+ board,
925
+ handoff,
926
+ // The door changes the directive. Dropping it here silently gave every
927
+ // real turn the chat prompt while tests saw the new-task one.
928
+ mode,
929
+ attachments,
930
+ images,
931
+ command: choice.command,
932
+ // The dialog's choices for this turn, else the saved planner model for that harness.
933
+ planner: createPlanner(choice.command, choice.model),
934
+ model: choice.model || undefined,
935
+ thinking: thinking ?? plannerThinkingForTurn(),
936
+ budget: plannerToolBudget,
937
+ // The planner and the run it writes for must agree on what "done" means;
938
+ // otherwise every ticket it drafts asks for a check the run will skip.
939
+ workflow: db.getStageWorkflow("in_progress"),
940
+ onStatus,
941
+ onStats,
942
+ research: findings,
943
+ timeoutMs,
944
+ linkedBoards: linked,
945
+ // The intake drafts no run, so it does not wait on a model list.
946
+ developer: mode === "intake" ? null : await developerBrief(),
947
+ });
948
+ });
928
949
  // A test that injected the planner explicitly asked for no subprocess. Only
929
950
  // an explicitly named harness (or a summary injection) opts back in.
930
951
  const harnessNamed = harness !== undefined || process.env.ZELIO_HARNESS !== undefined;
@@ -2231,7 +2252,7 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
2231
2252
  }, attachments, images, passThinking, findings,
2232
2253
  // What is left of the request, not a fresh clock per pass: the intake,
2233
2254
  // the scouts and the draft share one deadline, and the planner is told it.
2234
- Math.max(MIN_PASS_MS, PLAN_TURN_DEADLINE_MS - (Date.now() - startedAt)), repoBriefs, options.model);
2255
+ Math.max(MIN_PASS_MS, PLAN_TURN_DEADLINE_MS - (Date.now() - startedAt)), repoBriefs, options.model, options.harness);
2235
2256
  };
2236
2257
  // Saves what the planner decided. Research is a planner input, not part of
2237
2258
  // the plan the dialog reads, so it is not stored.
@@ -2341,10 +2362,13 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
2341
2362
  .catch(() => ({}));
2342
2363
  const text = typeof body.text === "string" ? body.text.trim() : "";
2343
2364
  const thinking = asThinking(body.thinking);
2365
+ const badHarness = unknownHarness(body.harness);
2344
2366
  if (!text)
2345
2367
  return c.json({ error: "text is required" }, 400);
2346
2368
  if (thinking === null)
2347
2369
  return c.json({ error: "unknown thinking level" }, 400);
2370
+ if (badHarness)
2371
+ return c.json({ error: `unknown harness: ${badHarness}` }, 400);
2348
2372
  if (text.length > MAX_MESSAGE_CHARS)
2349
2373
  return c.json({ error: "message too long" }, 400);
2350
2374
  const attachments = attachmentPaths(body.attachments);
@@ -2358,6 +2382,7 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
2358
2382
  attachments,
2359
2383
  thinking: thinking ?? undefined,
2360
2384
  model: typeof body.model === "string" ? body.model.trim() || undefined : undefined,
2385
+ harness: typeof body.harness === "string" ? body.harness.trim() || undefined : undefined,
2361
2386
  }),
2362
2387
  });
2363
2388
  }
@@ -2396,10 +2421,13 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
2396
2421
  .catch(() => ({}));
2397
2422
  const text = typeof body.text === "string" ? body.text.trim() : "";
2398
2423
  const thinking = asThinking(body.thinking);
2424
+ const badHarness = unknownHarness(body.harness);
2399
2425
  if (!text)
2400
2426
  return c.json({ error: "a description is required" }, 400);
2401
2427
  if (thinking === null)
2402
2428
  return c.json({ error: "unknown thinking level" }, 400);
2429
+ if (badHarness)
2430
+ return c.json({ error: `unknown harness: ${badHarness}` }, 400);
2403
2431
  if (text.length > MAX_MESSAGE_CHARS) {
2404
2432
  return c.json({ error: "that description is too long" }, 400);
2405
2433
  }
@@ -2419,6 +2447,7 @@ export function createApp({ db, token, port, webRoot, repoRoot, accountAvatarUrl
2419
2447
  attachments,
2420
2448
  thinking: thinking ?? undefined,
2421
2449
  model: typeof body.model === "string" ? body.model.trim() || undefined : undefined,
2450
+ harness: typeof body.harness === "string" ? body.harness.trim() || undefined : undefined,
2422
2451
  }),
2423
2452
  });
2424
2453
  }