@akagilnc/pi-workflow-roles 0.1.2048 → 0.1.2052

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.
@@ -15,6 +15,72 @@ var __export = (target, all) => {
15
15
  __defProp(target, name, { get: all[name], enumerable: true });
16
16
  };
17
17
 
18
+ // src/package-resources/engine-material.ts
19
+ import { existsSync as existsSync2, readdirSync } from "node:fs";
20
+ import { join as join2 } from "node:path";
21
+ function isEngineNameSyntax(name) {
22
+ if (typeof name !== "string") return false;
23
+ if (name.length === 0 || name.trim() !== name) return false;
24
+ if (name === "." || name === "..") return false;
25
+ if (name.includes("/") || name.includes("\\") || name.includes("\0")) return false;
26
+ if (name.includes("..")) return false;
27
+ return true;
28
+ }
29
+ function resolveEngineMaterialDirectory(packageRoot2) {
30
+ return join2(packageRoot2, ENGINE_MATERIAL_RELATIVE_ROOT);
31
+ }
32
+ function listEngineMaterialNames(packageRoot2) {
33
+ const dir = resolveEngineMaterialDirectory(packageRoot2);
34
+ if (!existsSync2(dir)) return Object.freeze([]);
35
+ const names = readdirSync(dir).filter((entry) => entry.endsWith(".md")).map((entry) => entry.slice(0, -".md".length)).filter((stem) => isEngineNameSyntax(stem)).sort();
36
+ return Object.freeze([...names]);
37
+ }
38
+ function resolveEngineMaterialPath(packageRoot2, name) {
39
+ const legal = assertLegalEngineName(packageRoot2, name);
40
+ return join2(resolveEngineMaterialDirectory(packageRoot2), `${legal}.md`);
41
+ }
42
+ function assertLegalEngineName(packageRoot2, name) {
43
+ if (!isEngineNameSyntax(name)) {
44
+ throw new Error(`illegal engine name: ${name}`);
45
+ }
46
+ const legal = listEngineMaterialNames(packageRoot2);
47
+ if (!legal.includes(name)) {
48
+ throw new Error(
49
+ `unknown engine: ${name} (known: ${legal.length === 0 ? "(none)" : legal.join(", ")})`
50
+ );
51
+ }
52
+ return name;
53
+ }
54
+ function engineSessionMaterialFromOptions(options) {
55
+ if (options.engine === void 0) return void 0;
56
+ if (options.packageRoot === void 0 || options.packageRoot.trim() === "") {
57
+ throw new Error("packageRoot is required when engine is configured");
58
+ }
59
+ const name = assertLegalEngineName(options.packageRoot, options.engine);
60
+ return Object.freeze({
61
+ name,
62
+ materialPath: resolveEngineMaterialPath(options.packageRoot, name)
63
+ });
64
+ }
65
+ function appendEngineSessionMaterial(lines, engineMaterial) {
66
+ if (engineMaterial === void 0) {
67
+ return [...lines];
68
+ }
69
+ const out = [...lines];
70
+ out.push("");
71
+ out.push("Engine method material (read these bytes and follow them):");
72
+ out.push(`- engine: ${engineMaterial.name}`);
73
+ out.push(`- ${engineMaterial.materialPath}`);
74
+ return out;
75
+ }
76
+ var ENGINE_MATERIAL_RELATIVE_ROOT;
77
+ var init_engine_material = __esm({
78
+ "src/package-resources/engine-material.ts"() {
79
+ "use strict";
80
+ ENGINE_MATERIAL_RELATIVE_ROOT = "resources/engines";
81
+ }
82
+ });
83
+
18
84
  // src/package-contracts/collector-output.ts
19
85
  function safeGet(value, key) {
20
86
  if (typeof value !== "object" && typeof value !== "function" || value === null) return void 0;
@@ -14348,9 +14414,9 @@ var init_registry2 = __esm({
14348
14414
  // src/public-cli/config.ts
14349
14415
  import { mkdir, readFile, writeFile } from "node:fs/promises";
14350
14416
  import { homedir } from "node:os";
14351
- import { dirname as dirname2, join as join2 } from "node:path";
14417
+ import { dirname as dirname2, join as join3 } from "node:path";
14352
14418
  function publicCliConfigPath(home = homedir()) {
14353
- return join2(home, ".ak-roles", "public-cli.json");
14419
+ return join3(home, ".ak-roles", "public-cli.json");
14354
14420
  }
14355
14421
  async function loadPublicCliConfig(home = homedir()) {
14356
14422
  const path = publicCliConfigPath(home);
@@ -14372,13 +14438,66 @@ async function savePublicCliConfig(config, home = homedir()) {
14372
14438
  `, "utf8");
14373
14439
  }
14374
14440
  function setPersistentSeatConfig(config, seat, selection) {
14441
+ const previous = config.seats[seat];
14442
+ return {
14443
+ seats: {
14444
+ ...config.seats,
14445
+ [seat]: {
14446
+ ...selection,
14447
+ // Model rewrite preserves a previously configured engine axis.
14448
+ ...previous?.engine === void 0 ? {} : { engine: previous.engine }
14449
+ }
14450
+ }
14451
+ };
14452
+ }
14453
+ function setPersistentSeatEngine(config, seat, engine) {
14454
+ if (seat !== "judge") {
14455
+ throw new Error(`engine axis is judge-only; refused seat ${seat}`);
14456
+ }
14457
+ const previous = config.seats[seat];
14458
+ if (previous === void 0) {
14459
+ throw new Error(
14460
+ `config seat ${seat} has no persistent model; set provider/model:thinking before engine`
14461
+ );
14462
+ }
14463
+ if (engine === void 0) {
14464
+ const { engine: _dropped, ...modelOnly } = previous;
14465
+ return {
14466
+ seats: {
14467
+ ...config.seats,
14468
+ [seat]: modelOnly
14469
+ }
14470
+ };
14471
+ }
14375
14472
  return {
14376
14473
  seats: {
14377
14474
  ...config.seats,
14378
- [seat]: { ...selection }
14475
+ [seat]: { ...previous, engine }
14379
14476
  }
14380
14477
  };
14381
14478
  }
14479
+ function seatModelOnly(seat) {
14480
+ return seat.thinking === void 0 ? { provider: seat.provider, model: seat.model } : { provider: seat.provider, model: seat.model, thinking: seat.thinking };
14481
+ }
14482
+ function validatePublicCliConfigEngines(config, packageRoot2) {
14483
+ for (const seat of Object.keys(config.seats)) {
14484
+ const row = config.seats[seat];
14485
+ if (row?.engine === void 0) continue;
14486
+ if (seat !== "judge") {
14487
+ throw new Error(
14488
+ `config seat ${seat} engine is not allowed; engine axis is judge-only`
14489
+ );
14490
+ }
14491
+ try {
14492
+ assertLegalEngineName(packageRoot2, row.engine);
14493
+ } catch (error) {
14494
+ throw new Error(
14495
+ `config seat ${seat} engine is unknown: ${row.engine}`,
14496
+ { cause: error }
14497
+ );
14498
+ }
14499
+ }
14500
+ }
14382
14501
  function parseModelSpec(spec, fallbackThinking) {
14383
14502
  const trimmed = spec.trim();
14384
14503
  if (!trimmed) {
@@ -14470,11 +14589,18 @@ function parseSeatModelConfig(value, seat) {
14470
14589
  if (typeof raw.thinking !== "string" || !THINKING_LEVELS.has(raw.thinking)) {
14471
14590
  throw new Error(`config seat ${seat} requires a valid thinking level`);
14472
14591
  }
14473
- return {
14592
+ const parsed = {
14474
14593
  provider: raw.provider,
14475
14594
  model: raw.model,
14476
14595
  thinking: raw.thinking
14477
14596
  };
14597
+ if (raw.engine !== void 0) {
14598
+ if (typeof raw.engine !== "string") {
14599
+ throw new Error(`config seat ${seat} engine must be a string`);
14600
+ }
14601
+ parsed.engine = raw.engine;
14602
+ }
14603
+ return parsed;
14478
14604
  }
14479
14605
  function providerConfigured(credentials, provider) {
14480
14606
  if (provider === "openai-codex") return credentials["openai-codex"] === true;
@@ -14493,6 +14619,33 @@ function pickStartupCandidate(seat, credentials) {
14493
14619
  }
14494
14620
  return void 0;
14495
14621
  }
14622
+ function attachEngineAxis(seat, config, invocation) {
14623
+ if (seat.seat !== "judge") {
14624
+ return {
14625
+ ...seat,
14626
+ engineSource: "unconfigured"
14627
+ };
14628
+ }
14629
+ const persistentEngine = config.seats.judge?.engine;
14630
+ if (invocation?.engine !== void 0) {
14631
+ return {
14632
+ ...seat,
14633
+ engine: invocation.engine,
14634
+ engineSource: "invocation"
14635
+ };
14636
+ }
14637
+ if (persistentEngine !== void 0) {
14638
+ return {
14639
+ ...seat,
14640
+ engine: persistentEngine,
14641
+ engineSource: "persistent"
14642
+ };
14643
+ }
14644
+ return {
14645
+ ...seat,
14646
+ engineSource: "unconfigured"
14647
+ };
14648
+ }
14496
14649
  function resolveBaseSeat(config, seat, credentials) {
14497
14650
  const automatic = seat === AUTOMATIC_NAVIGATOR_SEAT;
14498
14651
  const persistent = config.seats[seat];
@@ -14501,7 +14654,8 @@ function resolveBaseSeat(config, seat, credentials) {
14501
14654
  seat,
14502
14655
  automatic,
14503
14656
  source: "persistent",
14504
- selection: { ...persistent }
14657
+ selection: seatModelOnly(persistent),
14658
+ engineSource: "unconfigured"
14505
14659
  };
14506
14660
  }
14507
14661
  const startup = pickStartupCandidate(seat, credentials);
@@ -14510,36 +14664,47 @@ function resolveBaseSeat(config, seat, credentials) {
14510
14664
  seat,
14511
14665
  automatic,
14512
14666
  source: "startup",
14513
- selection: startup
14667
+ selection: startup,
14668
+ engineSource: "unconfigured"
14514
14669
  };
14515
14670
  }
14516
- return { seat, automatic, source: "unconfigured" };
14671
+ return { seat, automatic, source: "unconfigured", engineSource: "unconfigured" };
14517
14672
  }
14518
14673
  function resolveEffectiveSeat(config, seat, credentials, invocation) {
14519
14674
  const automatic = seat === AUTOMATIC_NAVIGATOR_SEAT;
14520
- const hasInvocation = invocation !== void 0 && (invocation.model !== void 0 || invocation.thinking !== void 0);
14521
- if (!hasInvocation || invocation === void 0) {
14522
- return resolveBaseSeat(config, seat, credentials);
14523
- }
14524
- if (invocation.model !== void 0) {
14675
+ const hasModelInvocation = invocation !== void 0 && (invocation.model !== void 0 || invocation.thinking !== void 0);
14676
+ let modelSeat;
14677
+ if (!hasModelInvocation || invocation === void 0) {
14678
+ modelSeat = resolveBaseSeat(config, seat, credentials);
14679
+ } else if (invocation.model !== void 0) {
14525
14680
  const spec = invocation.model.includes(":") || invocation.thinking === void 0 ? invocation.model : `${invocation.model}:${invocation.thinking}`;
14526
- return {
14681
+ modelSeat = {
14527
14682
  seat,
14528
14683
  automatic,
14529
14684
  source: "invocation",
14530
- selection: parseModelSpec(spec)
14685
+ selection: parseModelSpec(spec),
14686
+ engineSource: "unconfigured"
14531
14687
  };
14688
+ } else {
14689
+ const base = resolveBaseSeat(config, seat, credentials);
14690
+ if (base.selection === void 0 || invocation.thinking === void 0) {
14691
+ modelSeat = {
14692
+ seat,
14693
+ automatic,
14694
+ source: "unconfigured",
14695
+ engineSource: "unconfigured"
14696
+ };
14697
+ } else {
14698
+ modelSeat = {
14699
+ seat,
14700
+ automatic,
14701
+ source: "invocation",
14702
+ selection: { ...base.selection, thinking: invocation.thinking },
14703
+ engineSource: "unconfigured"
14704
+ };
14705
+ }
14532
14706
  }
14533
- const base = resolveBaseSeat(config, seat, credentials);
14534
- if (base.selection === void 0 || invocation.thinking === void 0) {
14535
- return { seat, automatic, source: "unconfigured" };
14536
- }
14537
- return {
14538
- seat,
14539
- automatic,
14540
- source: "invocation",
14541
- selection: { ...base.selection, thinking: invocation.thinking }
14542
- };
14707
+ return attachEngineAxis(modelSeat, config, invocation);
14543
14708
  }
14544
14709
  function effectiveSeatConfigurations(config, credentials, invocation) {
14545
14710
  return PUBLIC_CONFIGURABLE_SEATS.map(
@@ -14558,7 +14723,7 @@ function credentialProvidersFromAuthData(data) {
14558
14723
  }
14559
14724
  async function loadCredentialProviders(agentDir) {
14560
14725
  try {
14561
- const raw = await readFile(join2(agentDir, "auth.json"), "utf8");
14726
+ const raw = await readFile(join3(agentDir, "auth.json"), "utf8");
14562
14727
  return credentialProvidersFromAuthData(JSON.parse(raw));
14563
14728
  } catch (error) {
14564
14729
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -14571,6 +14736,7 @@ var THINKING_LEVELS;
14571
14736
  var init_config2 = __esm({
14572
14737
  "src/public-cli/config.ts"() {
14573
14738
  "use strict";
14739
+ init_engine_material();
14574
14740
  init_registry2();
14575
14741
  THINKING_LEVELS = /* @__PURE__ */ new Set([
14576
14742
  "off",
@@ -14610,7 +14776,7 @@ import {
14610
14776
  statSync
14611
14777
  } from "node:fs";
14612
14778
  import { homedir as homedir2 } from "node:os";
14613
- import { basename, dirname as dirname3, isAbsolute, join as join3, relative, resolve, sep } from "node:path";
14779
+ import { basename, dirname as dirname3, isAbsolute, join as join4, relative, resolve, sep } from "node:path";
14614
14780
  function resolveActivationLedgerHome(home = homedir2) {
14615
14781
  const processHome = home();
14616
14782
  if (typeof processHome !== "string" || processHome.length === 0 || !isAbsolute(processHome)) {
@@ -14621,7 +14787,7 @@ function resolveActivationLedgerHome(home = homedir2) {
14621
14787
  return resolve(processHome, ".ak-roles");
14622
14788
  }
14623
14789
  function activationBookDirectory(ledgerHome, bookKey) {
14624
- return join3(ledgerHome, "books", bookKey);
14790
+ return join4(ledgerHome, "books", bookKey);
14625
14791
  }
14626
14792
  function pathContainedIn(root, candidate) {
14627
14793
  const rel = relative(root, candidate);
@@ -14634,7 +14800,7 @@ function physicalPathIdentity(path) {
14634
14800
  while (true) {
14635
14801
  try {
14636
14802
  const real = realpathSync2(cursor);
14637
- return missing.length === 0 ? real : join3(real, ...missing);
14803
+ return missing.length === 0 ? real : join4(real, ...missing);
14638
14804
  } catch (error) {
14639
14805
  if (errnoCode(error) !== "ENOENT") {
14640
14806
  return absolute;
@@ -14734,7 +14900,7 @@ function ensureRealDirectoryTree(root, targetDir) {
14734
14900
  if (part === "..") {
14735
14901
  throw new ActivationLedgerError(`activation ledger path contains '..': ${absoluteTarget}`);
14736
14902
  }
14737
- lexicalCursor = join3(lexicalCursor, part);
14903
+ lexicalCursor = join4(lexicalCursor, part);
14738
14904
  let st;
14739
14905
  try {
14740
14906
  st = lstatSync2(lexicalCursor);
@@ -14906,24 +15072,24 @@ var init_activation_ledger_git = __esm({
14906
15072
  });
14907
15073
 
14908
15074
  // src/sitian-role-run-coordinates.ts
14909
- import { join as join4 } from "node:path";
15075
+ import { join as join5 } from "node:path";
14910
15076
  function roleRunSessionCoordinates(options) {
14911
15077
  const ledgerHome = resolveActivationLedgerHome(
14912
15078
  options.home === void 0 ? void 0 : () => options.home
14913
15079
  );
14914
15080
  const bookKey = resolveBookKeyFromGit(options.cwd);
14915
- const runDirectory = join4(
15081
+ const runDirectory = join5(
14916
15082
  activationBookDirectory(ledgerHome, bookKey),
14917
15083
  "runs",
14918
15084
  `${options.runId}@${options.role}`
14919
15085
  );
14920
- const sessionDirectory = join4(runDirectory, "session");
15086
+ const sessionDirectory = join5(runDirectory, "session");
14921
15087
  return {
14922
15088
  ledgerHome,
14923
15089
  bookKey,
14924
15090
  runDirectory,
14925
15091
  sessionDirectory,
14926
- sessionFile: join4(sessionDirectory, "session.jsonl")
15092
+ sessionFile: join5(sessionDirectory, "session.jsonl")
14927
15093
  };
14928
15094
  }
14929
15095
  var init_sitian_role_run_coordinates = __esm({
@@ -15755,6 +15921,20 @@ var init_option_definitions = __esm({
15755
15921
  zh: "\u8986\u76D6 thinking \u6863\u4F4D\uFF1Aoff|minimal|low|medium|high|xhigh|max\u3002"
15756
15922
  }
15757
15923
  },
15924
+ {
15925
+ id: "engine",
15926
+ owner: "global",
15927
+ canonical: "--engine",
15928
+ aliases: [],
15929
+ valueMetavar: "name",
15930
+ required: false,
15931
+ repeatable: false,
15932
+ form: "option",
15933
+ description: {
15934
+ en: "Optional Judge labor engine for this invocation (name must exist in packaged engine materials; judge-only).",
15935
+ zh: "\u672C\u8C03\u7528\u53EF\u9009 Judge \u52B3\u52A8\u5F15\u64CE\uFF08\u540D\u5B57\u987B\u5B58\u5728\u4E8E\u5305\u5185\u5F15\u64CE\u8C03\u6CD5\u6750\u6599\uFF1B\u4EC5 Judge\uFF09\u3002"
15936
+ }
15937
+ },
15758
15938
  {
15759
15939
  id: "help",
15760
15940
  owner: "global",
@@ -16171,7 +16351,7 @@ import {
16171
16351
  realpath as realpath2,
16172
16352
  writeFile as writeFile2
16173
16353
  } from "node:fs/promises";
16174
- import { basename as basename3, isAbsolute as isAbsolute3, join as join5, resolve as resolve4, sep as sep3 } from "node:path";
16354
+ import { basename as basename3, isAbsolute as isAbsolute3, join as join6, resolve as resolve4, sep as sep3 } from "node:path";
16175
16355
  function effectiveModelLedgerFields(model) {
16176
16356
  if (model === void 0) return {};
16177
16357
  return {
@@ -16194,14 +16374,14 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
16194
16374
  ...effectiveModelLedgerFields(effectiveModel)
16195
16375
  };
16196
16376
  await writeFile2(
16197
- join5(source.runDirectory, "invocation.json"),
16377
+ join6(source.runDirectory, "invocation.json"),
16198
16378
  `${JSON.stringify(identity, null, 2)}
16199
16379
  `,
16200
16380
  "utf8"
16201
16381
  );
16202
16382
  }
16203
16383
  async function recordEffectiveInvocationModel(runDirectory, model) {
16204
- const ledgerPath = join5(runDirectory, "invocation.json");
16384
+ const ledgerPath = join6(runDirectory, "invocation.json");
16205
16385
  const current = JSON.parse(await readFile4(ledgerPath, "utf8"));
16206
16386
  const next = {
16207
16387
  ...current,
@@ -16221,7 +16401,7 @@ async function recordEffectiveInvocationModel(runDirectory, model) {
16221
16401
  );
16222
16402
  }
16223
16403
  async function mergeInvocationIdentityPage(runDirectory, fields) {
16224
- const ledgerPath = join5(runDirectory, "invocation.json");
16404
+ const ledgerPath = join6(runDirectory, "invocation.json");
16225
16405
  const current = JSON.parse(await readFile4(ledgerPath, "utf8"));
16226
16406
  await writeFile2(
16227
16407
  ledgerPath,
@@ -16242,7 +16422,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
16242
16422
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
16243
16423
  const rolePackageRoot = packageRoot2;
16244
16424
  const raw = JSON.parse(
16245
- await readFile4(join5(rolePackageRoot, "package.json"), "utf8")
16425
+ await readFile4(join6(rolePackageRoot, "package.json"), "utf8")
16246
16426
  );
16247
16427
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
16248
16428
  throw new Error(
@@ -16442,7 +16622,7 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
16442
16622
  }
16443
16623
  const bytes = await readFile4(absolute);
16444
16624
  const name = `${String(index).padStart(2, "0")}-${basename3(absolute)}`;
16445
- const frozenPath = join5(destinationDir, name);
16625
+ const frozenPath = join6(destinationDir, name);
16446
16626
  await writeFile2(frozenPath, bytes);
16447
16627
  return {
16448
16628
  attachment: {
@@ -16483,7 +16663,7 @@ async function admitJudgeInvocation(options) {
16483
16663
  const projectRoot = resolve4(options.project ?? options.cwd);
16484
16664
  const runId = (options.createRunId ?? uuidv7)();
16485
16665
  const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "judge", home: options.home });
16486
- const attachmentsDirectory = join5(runDirectory, "attachments");
16666
+ const attachmentsDirectory = join6(runDirectory, "attachments");
16487
16667
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16488
16668
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16489
16669
  const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
@@ -16512,7 +16692,7 @@ async function admitJudgeInvocation(options) {
16512
16692
  mediaKind: a.mediaKind
16513
16693
  }))
16514
16694
  };
16515
- const admittedRequestPath = join5(runDirectory, "admitted-request.json");
16695
+ const admittedRequestPath = join6(runDirectory, "admitted-request.json");
16516
16696
  await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
16517
16697
  `, "utf8");
16518
16698
  await writeRoleInvocationLedger(admitted, admitted.role, options.model);
@@ -16531,7 +16711,7 @@ async function admitJudgeInvocation(options) {
16531
16711
  ...ticketFields
16532
16712
  };
16533
16713
  }
16534
- function buildJudgeTransportPrompt(admitted) {
16714
+ function buildJudgeTransportPrompt(admitted, engineMaterial) {
16535
16715
  const lines = [admitted.instructionEmpty ? "" : admitted.instruction];
16536
16716
  if (admitted.attachments.length > 0) {
16537
16717
  lines.push("");
@@ -16540,10 +16720,10 @@ function buildJudgeTransportPrompt(admitted) {
16540
16720
  lines.push(`- ${attachment.frozenPath}`);
16541
16721
  }
16542
16722
  }
16543
- return lines.join("\n");
16723
+ return appendEngineSessionMaterial(lines, engineMaterial).join("\n");
16544
16724
  }
16545
16725
  async function ensureRunArtifactsDir(runDirectory) {
16546
- const dir = join5(runDirectory, "artifacts");
16726
+ const dir = join6(runDirectory, "artifacts");
16547
16727
  await mkdir2(dir, { recursive: true });
16548
16728
  return dir;
16549
16729
  }
@@ -16563,7 +16743,7 @@ async function admitCoderInvocation(options) {
16563
16743
  const projectRoot = resolve4(options.project ?? options.cwd);
16564
16744
  const runId = (options.createRunId ?? uuidv7)();
16565
16745
  const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "coder", home: options.home });
16566
- const attachmentsDirectory = join5(runDirectory, "attachments");
16746
+ const attachmentsDirectory = join6(runDirectory, "attachments");
16567
16747
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16568
16748
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16569
16749
  const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
@@ -16571,7 +16751,7 @@ async function admitCoderInvocation(options) {
16571
16751
  attachmentsDirectory
16572
16752
  );
16573
16753
  const ticketFields = ticketAdmissionFields(ticketNumber);
16574
- const taskPath = join5(runDirectory, "task.md");
16754
+ const taskPath = join6(runDirectory, "task.md");
16575
16755
  await writeFile2(taskPath, instruction, "utf8");
16576
16756
  const admitted = {
16577
16757
  role: "coder",
@@ -16594,7 +16774,7 @@ async function admitCoderInvocation(options) {
16594
16774
  mediaKind: a.mediaKind
16595
16775
  }))
16596
16776
  };
16597
- const admittedRequestPath = join5(runDirectory, "admitted-request.json");
16777
+ const admittedRequestPath = join6(runDirectory, "admitted-request.json");
16598
16778
  await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
16599
16779
  `, "utf8");
16600
16780
  await writeRoleInvocationLedger(admitted, admitted.role, options.model);
@@ -16663,7 +16843,7 @@ async function admitFixerInvocation(options) {
16663
16843
  const projectRoot = resolve4(options.project ?? options.cwd);
16664
16844
  const runId = (options.createRunId ?? uuidv7)();
16665
16845
  const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "fixer", home: options.home });
16666
- const attachmentsDirectory = join5(runDirectory, "attachments");
16846
+ const attachmentsDirectory = join6(runDirectory, "attachments");
16667
16847
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16668
16848
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16669
16849
  const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
@@ -16673,7 +16853,7 @@ async function admitFixerInvocation(options) {
16673
16853
  const ticketFields = ticketAdmissionFields(ticketNumber);
16674
16854
  let prerequisitesPath;
16675
16855
  if (prerequisitesSource !== void 0) {
16676
- prerequisitesPath = join5(runDirectory, "prerequisites.json");
16856
+ prerequisitesPath = join6(runDirectory, "prerequisites.json");
16677
16857
  await writeFile2(
16678
16858
  prerequisitesPath,
16679
16859
  `${JSON.stringify(prerequisites, null, 2)}
@@ -16681,7 +16861,7 @@ async function admitFixerInvocation(options) {
16681
16861
  "utf8"
16682
16862
  );
16683
16863
  }
16684
- const packetPath = join5(runDirectory, "fix-packet.md");
16864
+ const packetPath = join6(runDirectory, "fix-packet.md");
16685
16865
  await writeFile2(packetPath, instruction, "utf8");
16686
16866
  const admitted = {
16687
16867
  role: "fixer",
@@ -16709,7 +16889,7 @@ async function admitFixerInvocation(options) {
16709
16889
  mediaKind: a.mediaKind
16710
16890
  }))
16711
16891
  };
16712
- const admittedRequestPath = join5(runDirectory, "admitted-request.json");
16892
+ const admittedRequestPath = join6(runDirectory, "admitted-request.json");
16713
16893
  await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
16714
16894
  `, "utf8");
16715
16895
  await writeRoleInvocationLedger(admitted, admitted.role, options.model);
@@ -16906,7 +17086,7 @@ async function admitCollectorInvocation(options) {
16906
17086
  const manifestDigest = manifest.digest;
16907
17087
  const runId = (options.createRunId ?? uuidv7)();
16908
17088
  const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "collector", home: options.home });
16909
- const attachmentsDirectory = join5(runDirectory, "attachments");
17089
+ const attachmentsDirectory = join6(runDirectory, "attachments");
16910
17090
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16911
17091
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16912
17092
  const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
@@ -16916,7 +17096,7 @@ async function admitCollectorInvocation(options) {
16916
17096
  const ticketFields = ticketAdmissionFields(ticketNumber);
16917
17097
  let requestManifestPath;
16918
17098
  if (manifestCanonicalJson !== void 0) {
16919
- requestManifestPath = join5(runDirectory, "request-manifest.json");
17099
+ requestManifestPath = join6(runDirectory, "request-manifest.json");
16920
17100
  await writeFile2(requestManifestPath, manifestCanonicalJson, "utf8");
16921
17101
  }
16922
17102
  const instruction = options.instruction ?? "";
@@ -16945,7 +17125,7 @@ async function admitCollectorInvocation(options) {
16945
17125
  mediaKind: a.mediaKind
16946
17126
  }))
16947
17127
  };
16948
- const admittedRequestPath = join5(runDirectory, "admitted-request.json");
17128
+ const admittedRequestPath = join6(runDirectory, "admitted-request.json");
16949
17129
  await writeFile2(
16950
17130
  admittedRequestPath,
16951
17131
  `${JSON.stringify(admitted, null, 2)}
@@ -17046,7 +17226,7 @@ function parseDoctorArgv(args) {
17046
17226
  }
17047
17227
  async function resolveDoctorCaseRunsPath(options) {
17048
17228
  const ledgerHome = resolveActivationLedgerHome(() => options.home);
17049
- const defaultRuns = join5(
17229
+ const defaultRuns = join6(
17050
17230
  activationBookDirectory(ledgerHome, options.bookKey),
17051
17231
  "issues",
17052
17232
  String(options.issueNumber),
@@ -17141,7 +17321,7 @@ async function admitDoctorInvocation(options) {
17141
17321
  { cause: error }
17142
17322
  );
17143
17323
  }
17144
- const attachmentsDirectory = join5(runDirectory, "attachments");
17324
+ const attachmentsDirectory = join6(runDirectory, "attachments");
17145
17325
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
17146
17326
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
17147
17327
  const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
@@ -17173,7 +17353,7 @@ async function admitDoctorInvocation(options) {
17173
17353
  mediaKind: a.mediaKind
17174
17354
  }))
17175
17355
  };
17176
- const admittedRequestPath = join5(runDirectory, "admitted-request.json");
17356
+ const admittedRequestPath = join6(runDirectory, "admitted-request.json");
17177
17357
  await writeFile2(
17178
17358
  admittedRequestPath,
17179
17359
  `${JSON.stringify(admitted, null, 2)}
@@ -17269,7 +17449,7 @@ async function admitReviewerInvocation(options) {
17269
17449
  const projectRoot = resolve4(options.project ?? options.cwd);
17270
17450
  const runId = (options.createRunId ?? uuidv7)();
17271
17451
  const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "reviewer", home: options.home });
17272
- const attachmentsDirectory = join5(runDirectory, "attachments");
17452
+ const attachmentsDirectory = join6(runDirectory, "attachments");
17273
17453
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
17274
17454
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
17275
17455
  const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
@@ -17300,7 +17480,7 @@ async function admitReviewerInvocation(options) {
17300
17480
  mediaKind: a.mediaKind
17301
17481
  }))
17302
17482
  };
17303
- const admittedRequestPath = join5(runDirectory, "admitted-request.json");
17483
+ const admittedRequestPath = join6(runDirectory, "admitted-request.json");
17304
17484
  await writeFile2(
17305
17485
  admittedRequestPath,
17306
17486
  `${JSON.stringify(admitted, null, 2)}
@@ -17419,7 +17599,7 @@ async function admitMergerInvocation(options) {
17419
17599
  );
17420
17600
  const runId = (options.createRunId ?? uuidv7)();
17421
17601
  const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "merger", home: options.home });
17422
- const attachmentsDirectory = join5(runDirectory, "attachments");
17602
+ const attachmentsDirectory = join6(runDirectory, "attachments");
17423
17603
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
17424
17604
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
17425
17605
  const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
@@ -17451,7 +17631,7 @@ async function admitMergerInvocation(options) {
17451
17631
  // Authorized checks remain available on the assignment; default none.
17452
17632
  authorizedChecks: []
17453
17633
  });
17454
- const mergerInputPath = join5(runDirectory, "merger-input.json");
17634
+ const mergerInputPath = join6(runDirectory, "merger-input.json");
17455
17635
  await writeFile2(
17456
17636
  mergerInputPath,
17457
17637
  `${JSON.stringify(mergerInput, null, 2)}
@@ -17485,7 +17665,7 @@ async function admitMergerInvocation(options) {
17485
17665
  mediaKind: a.mediaKind
17486
17666
  }))
17487
17667
  };
17488
- const admittedRequestPath = join5(runDirectory, "admitted-request.json");
17668
+ const admittedRequestPath = join6(runDirectory, "admitted-request.json");
17489
17669
  await writeFile2(
17490
17670
  admittedRequestPath,
17491
17671
  `${JSON.stringify(admitted, null, 2)}
@@ -17695,6 +17875,7 @@ var init_invocation = __esm({
17695
17875
  init_merger_contracts();
17696
17876
  init_sha256();
17697
17877
  init_uuidv7();
17878
+ init_engine_material();
17698
17879
  init_cli_errors();
17699
17880
  init_option_definitions();
17700
17881
  MergerEnvelopeDerivationError = class extends Error {
@@ -17837,14 +18018,14 @@ var init_upstream_error_testimony = __esm({
17837
18018
  import { execFile as execFile3, spawn } from "node:child_process";
17838
18019
  import { constants, writeFileSync } from "node:fs";
17839
18020
  import { access, readFile as readFile5, realpath as realpath3, unlink } from "node:fs/promises";
17840
- import { delimiter as delimiter2, isAbsolute as isAbsolute4, join as join6, resolve as resolve5 } from "node:path";
18021
+ import { delimiter as delimiter2, isAbsolute as isAbsolute4, join as join7, resolve as resolve5 } from "node:path";
17841
18022
  import { platform } from "node:process";
17842
18023
  import { promisify as promisify3 } from "node:util";
17843
18024
  function isReviewerPreflightViolation(value) {
17844
18025
  return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
17845
18026
  }
17846
18027
  function reviewerDispatchRejectionPath(runDirectory) {
17847
- return join6(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
18028
+ return join7(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
17848
18029
  }
17849
18030
  async function clearReviewerDispatchRejection(runDirectory) {
17850
18031
  try {
@@ -17886,7 +18067,7 @@ async function readReviewerDispatchRejection(runDirectory) {
17886
18067
  };
17887
18068
  }
17888
18069
  function resolveInternalRoleEntrypoint(packageRoot2) {
17889
- return join6(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE);
18070
+ return join7(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE);
17890
18071
  }
17891
18072
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
17892
18073
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -18044,7 +18225,7 @@ var init_explicit_internal = __esm({
18044
18225
  // src/package-resources/method-skill.ts
18045
18226
  import { createHash as createHash3 } from "node:crypto";
18046
18227
  import { readFile as readFile6, realpath as realpath4 } from "node:fs/promises";
18047
- import { join as join7 } from "node:path";
18228
+ import { join as join8 } from "node:path";
18048
18229
  function gitBlobOid(bytes) {
18049
18230
  const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
18050
18231
  const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
@@ -18061,10 +18242,10 @@ function packagedMethodSkillRelativeDirectory(name) {
18061
18242
  return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
18062
18243
  }
18063
18244
  function resolvePackagedMethodSkillRoot(packageRoot2, name) {
18064
- return join7(packageRoot2, packagedMethodSkillRelativeDirectory(name));
18245
+ return join8(packageRoot2, packagedMethodSkillRelativeDirectory(name));
18065
18246
  }
18066
18247
  function resolvePackagedMethodSkillPath(packageRoot2, name) {
18067
- return join7(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
18248
+ return join8(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
18068
18249
  }
18069
18250
  function isRecord3(value) {
18070
18251
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -18158,8 +18339,8 @@ function parseProvenance(raw, expectedName) {
18158
18339
  }
18159
18340
  async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
18160
18341
  const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
18161
- const skillPathConfigured = join7(rootDirectory, "SKILL.md");
18162
- const provenancePath = join7(rootDirectory, "provenance.json");
18342
+ const skillPathConfigured = join8(rootDirectory, "SKILL.md");
18343
+ const provenancePath = join8(rootDirectory, "provenance.json");
18163
18344
  let provenanceRaw;
18164
18345
  try {
18165
18346
  provenanceRaw = await readFile6(provenancePath, "utf8");
@@ -18176,7 +18357,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
18176
18357
  }
18177
18358
  const provenance = parseProvenance(provenanceJson, name);
18178
18359
  for (const [rel, expected] of Object.entries(provenance.files)) {
18179
- const absolute = join7(rootDirectory, rel);
18360
+ const absolute = join8(rootDirectory, rel);
18180
18361
  let bytes;
18181
18362
  try {
18182
18363
  bytes = await readFile6(absolute);
@@ -18311,9 +18492,9 @@ var init_public_run_credentials = __esm({
18311
18492
 
18312
18493
  // src/typed-provider-http.ts
18313
18494
  import { readFile as readFile7, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
18314
- import { join as join8 } from "node:path";
18495
+ import { join as join9 } from "node:path";
18315
18496
  function typedProviderHttpPath(runDirectory) {
18316
- return join8(runDirectory, TYPED_HTTP_FILE);
18497
+ return join9(runDirectory, TYPED_HTTP_FILE);
18317
18498
  }
18318
18499
  async function clearTypedProviderHttpObservation(runDirectory) {
18319
18500
  try {
@@ -18358,7 +18539,7 @@ var init_typed_provider_http = __esm({
18358
18539
 
18359
18540
  // src/public-cli/run-lifecycle.ts
18360
18541
  import { lstat as lstat2, open, readdir as readdir2, readFile as readFile8, unlink as unlink3, writeFile as writeFile4 } from "node:fs/promises";
18361
- import { join as join9 } from "node:path";
18542
+ import { join as join10 } from "node:path";
18362
18543
  function isV1ResumableProvider(provider) {
18363
18544
  return V1_RESUMABLE_PROVIDERS.includes(provider);
18364
18545
  }
@@ -18379,7 +18560,7 @@ function renderResumeCommand(runId) {
18379
18560
  async function writeRoleRunState(runDirectory, record4) {
18380
18561
  const payload = { ...record4, runDirectory };
18381
18562
  await writeFile4(
18382
- join9(runDirectory, RUN_STATE_FILE),
18563
+ join10(runDirectory, RUN_STATE_FILE),
18383
18564
  `${JSON.stringify(payload, null, 2)}
18384
18565
  `,
18385
18566
  "utf8"
@@ -18388,7 +18569,7 @@ async function writeRoleRunState(runDirectory, record4) {
18388
18569
  async function readRoleRunState(runDirectory) {
18389
18570
  let raw;
18390
18571
  try {
18391
- raw = JSON.parse(await readFile8(join9(runDirectory, RUN_STATE_FILE), "utf8"));
18572
+ raw = JSON.parse(await readFile8(join10(runDirectory, RUN_STATE_FILE), "utf8"));
18392
18573
  } catch {
18393
18574
  return void 0;
18394
18575
  }
@@ -18410,7 +18591,7 @@ async function readRoleRunState(runDirectory) {
18410
18591
  if (typeof record4.sessionDirectory !== "string") return void 0;
18411
18592
  if (typeof record4.admittedRequestPath !== "string") return void 0;
18412
18593
  const runDir = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
18413
- const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join9(record4.sessionDirectory, "session.jsonl");
18594
+ const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join10(record4.sessionDirectory, "session.jsonl");
18414
18595
  let resumable;
18415
18596
  if (record4.resumable !== void 0 && record4.resumable !== null) {
18416
18597
  if (typeof record4.resumable === "object" && !Array.isArray(record4.resumable)) {
@@ -18506,7 +18687,7 @@ async function isSessionPrincipalAvailable(sessionFile) {
18506
18687
  }
18507
18688
  }
18508
18689
  async function acquireRunWriterLease(runDirectory) {
18509
- const lockPath = join9(runDirectory, WRITER_LOCK_FILE);
18690
+ const lockPath = join10(runDirectory, WRITER_LOCK_FILE);
18510
18691
  try {
18511
18692
  const handle = await open(lockPath, "wx");
18512
18693
  try {
@@ -18537,7 +18718,7 @@ async function acquireRunWriterLease(runDirectory) {
18537
18718
  async function findRunDirectoryById(home, runId) {
18538
18719
  if (runId.trim() === "") return void 0;
18539
18720
  const ledgerHome = resolveActivationLedgerHome(() => home);
18540
- const booksRoot = join9(ledgerHome, "books");
18721
+ const booksRoot = join10(ledgerHome, "books");
18541
18722
  let bookKeys;
18542
18723
  try {
18543
18724
  bookKeys = await readdir2(booksRoot);
@@ -18545,7 +18726,7 @@ async function findRunDirectoryById(home, runId) {
18545
18726
  return void 0;
18546
18727
  }
18547
18728
  for (const bookKey of bookKeys) {
18548
- const runsDir = join9(activationBookDirectory(ledgerHome, bookKey), "runs");
18729
+ const runsDir = join10(activationBookDirectory(ledgerHome, bookKey), "runs");
18549
18730
  let entries;
18550
18731
  try {
18551
18732
  entries = await readdir2(runsDir);
@@ -18554,7 +18735,7 @@ async function findRunDirectoryById(home, runId) {
18554
18735
  }
18555
18736
  for (const entry of entries) {
18556
18737
  if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
18557
- return join9(runsDir, entry);
18738
+ return join10(runsDir, entry);
18558
18739
  }
18559
18740
  }
18560
18741
  }
@@ -18682,7 +18863,7 @@ async function loadResumableRunRecord(home, runId) {
18682
18863
  if (correlationId === void 0 || ticketNumber === void 0) {
18683
18864
  try {
18684
18865
  const invocationRaw = JSON.parse(
18685
- await readFile8(join9(run.runDirectory, "invocation.json"), "utf8")
18866
+ await readFile8(join10(run.runDirectory, "invocation.json"), "utf8")
18686
18867
  );
18687
18868
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
18688
18869
  const fromInvocation = parsePersistedTicketIdentity(
@@ -19602,7 +19783,7 @@ var init_terminal = __esm({
19602
19783
  // src/public-cli/settlement.ts
19603
19784
  import { randomUUID } from "node:crypto";
19604
19785
  import { lstat as lstat3, mkdir as mkdir3, open as open2, readFile as readFile9, readdir as readdir3, writeFile as writeFile5 } from "node:fs/promises";
19605
- import { dirname as dirname6, join as join10 } from "node:path";
19786
+ import { dirname as dirname6, join as join11 } from "node:path";
19606
19787
  function isChildDiagnosticFloodLine(line2) {
19607
19788
  if (/^at\s+/.test(line2)) return true;
19608
19789
  if (line2.startsWith("event:")) return true;
@@ -19875,7 +20056,7 @@ async function readSessionProviderStop(sessionFile) {
19875
20056
  }
19876
20057
  }
19877
20058
  async function readBoundEvidenceChildKnownFailure(sessionFile) {
19878
- const childDirectory = join10(dirname6(sessionFile), "evidence-children");
20059
+ const childDirectory = join11(dirname6(sessionFile), "evidence-children");
19879
20060
  let names;
19880
20061
  try {
19881
20062
  names = await readdir3(childDirectory);
@@ -19886,7 +20067,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
19886
20067
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
19887
20068
  let entries;
19888
20069
  try {
19889
- entries = await readBoundSessionEntries(join10(childDirectory, file));
20070
+ entries = await readBoundSessionEntries(join11(childDirectory, file));
19890
20071
  } catch (error) {
19891
20072
  throw sessionReadFailure(error, "failed to read discovered evidence-child session");
19892
20073
  }
@@ -19922,7 +20103,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
19922
20103
  break;
19923
20104
  }
19924
20105
  }
19925
- const childDirectory = join10(dirname6(sessionFile), "auditor-roles");
20106
+ const childDirectory = join11(dirname6(sessionFile), "auditor-roles");
19926
20107
  let names;
19927
20108
  try {
19928
20109
  names = await readdir3(childDirectory);
@@ -19933,7 +20114,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
19933
20114
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
19934
20115
  let entries;
19935
20116
  try {
19936
- entries = await readBoundSessionEntries(join10(childDirectory, file));
20117
+ entries = await readBoundSessionEntries(join11(childDirectory, file));
19937
20118
  } catch (error) {
19938
20119
  throw sessionReadFailure(error, "failed to read discovered auditor session");
19939
20120
  }
@@ -20639,7 +20820,7 @@ function auditArtifactPublicationError(message, code) {
20639
20820
  return error;
20640
20821
  }
20641
20822
  async function ensureAuditEvidenceDirectory(runDirectory) {
20642
- const artifactsDir = join10(runDirectory, "artifacts");
20823
+ const artifactsDir = join11(runDirectory, "artifacts");
20643
20824
  const runStat = await lstat3(runDirectory);
20644
20825
  if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
20645
20826
  throw auditArtifactPublicationError(
@@ -20676,7 +20857,7 @@ async function ensureAuditEvidenceDirectory(runDirectory) {
20676
20857
  }
20677
20858
  async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
20678
20859
  const artifactsDir = await ensureAuditEvidenceDirectory(admitted.runDirectory);
20679
- const evidencePath = join10(artifactsDir, "audit-incomplete.json");
20860
+ const evidencePath = join11(artifactsDir, "audit-incomplete.json");
20680
20861
  try {
20681
20862
  const existing = await lstat3(evidencePath);
20682
20863
  throw auditArtifactPublicationError(
@@ -20698,7 +20879,7 @@ async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
20698
20879
  }
20699
20880
  function auditPublicationFailureTerminal(admitted, entries, outcome, error) {
20700
20881
  const attempt = publicationAttemptFromError(
20701
- join10(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
20882
+ join11(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
20702
20883
  error
20703
20884
  );
20704
20885
  const diagnostic = `audit-incomplete evidence publication failed: ${attempt.diagnostic}`;
@@ -20992,8 +21173,8 @@ async function extractNavigatorFactFromAdmittedSession(admitted) {
20992
21173
  }
20993
21174
  async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
20994
21175
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20995
- const reportPath = join10(artifactsDir, "report.json");
20996
- const evidencePath = join10(artifactsDir, "evidence.json");
21176
+ const reportPath = join11(artifactsDir, "report.json");
21177
+ const evidencePath = join11(artifactsDir, "evidence.json");
20997
21178
  await writeFile5(
20998
21179
  reportPath,
20999
21180
  `${JSON.stringify(
@@ -21036,8 +21217,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
21036
21217
  }
21037
21218
  async function publishCoderArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
21038
21219
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
21039
- const reportPath = join10(artifactsDir, "report.json");
21040
- const evidencePath = join10(artifactsDir, "evidence.json");
21220
+ const reportPath = join11(artifactsDir, "report.json");
21221
+ const evidencePath = join11(artifactsDir, "evidence.json");
21041
21222
  await writeFile5(
21042
21223
  reportPath,
21043
21224
  `${JSON.stringify(
@@ -21211,8 +21392,8 @@ function extractFixerMethodInvocations(entries, options) {
21211
21392
  }
21212
21393
  async function publishFixerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
21213
21394
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
21214
- const reportPath = join10(artifactsDir, "report.json");
21215
- const evidencePath = join10(artifactsDir, "evidence.json");
21395
+ const reportPath = join11(artifactsDir, "report.json");
21396
+ const evidencePath = join11(artifactsDir, "evidence.json");
21216
21397
  await writeFile5(
21217
21398
  reportPath,
21218
21399
  `${JSON.stringify(
@@ -21325,8 +21506,8 @@ async function settleLawfulFixerTerminalResult(admitted, options) {
21325
21506
  }
21326
21507
  async function publishCollectorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
21327
21508
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
21328
- const reportPath = join10(artifactsDir, "report.json");
21329
- const evidencePath = join10(artifactsDir, "evidence.json");
21509
+ const reportPath = join11(artifactsDir, "report.json");
21510
+ const evidencePath = join11(artifactsDir, "evidence.json");
21330
21511
  await writeFile5(
21331
21512
  reportPath,
21332
21513
  `${JSON.stringify(
@@ -21447,8 +21628,8 @@ async function trySettleCollectorTerminalResult(admitted) {
21447
21628
  }
21448
21629
  async function publishDoctorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
21449
21630
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
21450
- const reportPath = join10(artifactsDir, "report.json");
21451
- const evidencePath = join10(artifactsDir, "evidence.json");
21631
+ const reportPath = join11(artifactsDir, "report.json");
21632
+ const evidencePath = join11(artifactsDir, "evidence.json");
21452
21633
  await writeFile5(
21453
21634
  reportPath,
21454
21635
  `${JSON.stringify(
@@ -21616,8 +21797,8 @@ function extractReviewerMethodInvocations(entries, options) {
21616
21797
  }
21617
21798
  async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
21618
21799
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
21619
- const reportPath = join10(artifactsDir, "report.json");
21620
- const evidencePath = join10(artifactsDir, "evidence.json");
21800
+ const reportPath = join11(artifactsDir, "report.json");
21801
+ const evidencePath = join11(artifactsDir, "evidence.json");
21621
21802
  await writeFile5(
21622
21803
  reportPath,
21623
21804
  `${JSON.stringify(
@@ -21786,8 +21967,8 @@ function extractMergerMethodInvocations(entries, options) {
21786
21967
  }
21787
21968
  async function publishMergerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
21788
21969
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
21789
- const reportPath = join10(artifactsDir, "report.json");
21790
- const evidencePath = join10(artifactsDir, "evidence.json");
21970
+ const reportPath = join11(artifactsDir, "report.json");
21971
+ const evidencePath = join11(artifactsDir, "evidence.json");
21791
21972
  await writeFile5(
21792
21973
  reportPath,
21793
21974
  `${JSON.stringify(
@@ -21958,7 +22139,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
21958
22139
  return dirs;
21959
22140
  }
21960
22141
  async function resolveFailureArtifactsBase(runDirectory) {
21961
- const artifactsDir = join10(runDirectory, "artifacts");
22142
+ const artifactsDir = join11(runDirectory, "artifacts");
21962
22143
  try {
21963
22144
  await ensureRunArtifactsDir(runDirectory);
21964
22145
  return { baseDir: artifactsDir };
@@ -21974,7 +22155,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
21974
22155
  const candidates = [
21975
22156
  ...preferredCandidates,
21976
22157
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
21977
- ...uniqueFallbackDirs.map((dir) => join10(dir, `${stem}.${randomUUID()}.json`))
22158
+ ...uniqueFallbackDirs.map((dir) => join11(dir, `${stem}.${randomUUID()}.json`))
21978
22159
  ];
21979
22160
  for (let i = 0; i < candidates.length; i += 1) {
21980
22161
  const path = candidates[i];
@@ -22009,26 +22190,26 @@ async function publishFailureArtifacts(admitted, failure) {
22009
22190
  admitted.runDirectory
22010
22191
  );
22011
22192
  const priorIssues = baseAttempt === void 0 ? [] : [baseAttempt];
22012
- const underArtifacts = baseDir === join10(admitted.runDirectory, "artifacts");
22193
+ const underArtifacts = baseDir === join11(admitted.runDirectory, "artifacts");
22013
22194
  const uniqueFallbackDirs = uniqueFailureFallbackDirs(
22014
22195
  admitted.runDirectory,
22015
22196
  baseDir
22016
22197
  );
22017
22198
  const errorCandidates = underArtifacts ? [
22018
- join10(baseDir, "error.json"),
22019
- join10(baseDir, "error.settlement.json"),
22020
- join10(admitted.runDirectory, "error.settlement.json")
22199
+ join11(baseDir, "error.json"),
22200
+ join11(baseDir, "error.settlement.json"),
22201
+ join11(admitted.runDirectory, "error.settlement.json")
22021
22202
  ] : [
22022
- join10(baseDir, "error.settlement.json"),
22023
- join10(baseDir, "error.json")
22203
+ join11(baseDir, "error.settlement.json"),
22204
+ join11(baseDir, "error.json")
22024
22205
  ];
22025
22206
  const evidenceCandidates = underArtifacts ? [
22026
- join10(baseDir, "evidence.json"),
22027
- join10(baseDir, "evidence.settlement.json"),
22028
- join10(admitted.runDirectory, "evidence.settlement.json")
22207
+ join11(baseDir, "evidence.json"),
22208
+ join11(baseDir, "evidence.settlement.json"),
22209
+ join11(admitted.runDirectory, "evidence.settlement.json")
22029
22210
  ] : [
22030
- join10(baseDir, "evidence.settlement.json"),
22031
- join10(baseDir, "evidence.json")
22211
+ join11(baseDir, "evidence.settlement.json"),
22212
+ join11(baseDir, "evidence.json")
22032
22213
  ];
22033
22214
  const errorPayloadBase = {
22034
22215
  kind: "error",
@@ -22243,7 +22424,7 @@ var init_settlement = __esm({
22243
22424
 
22244
22425
  // src/public-cli/coder-run.ts
22245
22426
  import { writeFile as writeFile6 } from "node:fs/promises";
22246
- import { join as join11 } from "node:path";
22427
+ import { join as join12 } from "node:path";
22247
22428
  function buildCoderActivationExtraArgs(admitted, options) {
22248
22429
  const prompt = buildCoderTransportPrompt(admitted);
22249
22430
  const skillArgs = admitted.phase === "apply" ? [
@@ -22401,7 +22582,7 @@ async function dispatchAdmittedCoder(input) {
22401
22582
  }
22402
22583
  try {
22403
22584
  await writeFile6(
22404
- join11(admitted.runDirectory, "stderr.log"),
22585
+ join12(admitted.runDirectory, "stderr.log"),
22405
22586
  result2.stderr,
22406
22587
  "utf8"
22407
22588
  );
@@ -22623,7 +22804,7 @@ var init_coder_run = __esm({
22623
22804
 
22624
22805
  // src/public-cli/collector-run.ts
22625
22806
  import { writeFile as writeFile7 } from "node:fs/promises";
22626
- import { join as join12 } from "node:path";
22807
+ import { join as join13 } from "node:path";
22627
22808
  function buildCollectorActivationExtraArgs(admitted, options = {}) {
22628
22809
  const prompt = buildCollectorTransportPrompt(admitted);
22629
22810
  return [
@@ -22724,7 +22905,7 @@ async function dispatchAdmittedCollector(input) {
22724
22905
  }
22725
22906
  try {
22726
22907
  await writeFile7(
22727
- join12(admitted.runDirectory, "stderr.log"),
22908
+ join13(admitted.runDirectory, "stderr.log"),
22728
22909
  result2.stderr,
22729
22910
  "utf8"
22730
22911
  );
@@ -22850,7 +23031,7 @@ var init_collector_run = __esm({
22850
23031
 
22851
23032
  // src/public-cli/doctor-run.ts
22852
23033
  import { writeFile as writeFile8 } from "node:fs/promises";
22853
- import { join as join13 } from "node:path";
23034
+ import { join as join14 } from "node:path";
22854
23035
  function buildDoctorActivationExtraArgs(admitted, options = {}) {
22855
23036
  const prompt = buildDoctorTransportPrompt(admitted);
22856
23037
  return [
@@ -22944,7 +23125,7 @@ async function dispatchAdmittedDoctor(input) {
22944
23125
  }
22945
23126
  try {
22946
23127
  await writeFile8(
22947
- join13(admitted.runDirectory, "stderr.log"),
23128
+ join14(admitted.runDirectory, "stderr.log"),
22948
23129
  result2.stderr,
22949
23130
  "utf8"
22950
23131
  );
@@ -23073,7 +23254,7 @@ var init_doctor_run = __esm({
23073
23254
 
23074
23255
  // src/public-cli/fixer-run.ts
23075
23256
  import { writeFile as writeFile9 } from "node:fs/promises";
23076
- import { join as join14 } from "node:path";
23257
+ import { join as join15 } from "node:path";
23077
23258
  function buildFixerActivationExtraArgs(admitted, options) {
23078
23259
  const prompt = buildFixerTransportPrompt(admitted);
23079
23260
  const diagnosisSkillPath = resolvePackagedMethodSkillPath(
@@ -23240,7 +23421,7 @@ async function dispatchAdmittedFixer(input) {
23240
23421
  }
23241
23422
  try {
23242
23423
  await writeFile9(
23243
- join14(admitted.runDirectory, "stderr.log"),
23424
+ join15(admitted.runDirectory, "stderr.log"),
23244
23425
  result2.stderr,
23245
23426
  "utf8"
23246
23427
  );
@@ -23471,9 +23652,12 @@ var init_fixer_run = __esm({
23471
23652
 
23472
23653
  // src/public-cli/judge-run.ts
23473
23654
  import { writeFile as writeFile10 } from "node:fs/promises";
23474
- import { join as join15 } from "node:path";
23655
+ import { join as join16 } from "node:path";
23475
23656
  function buildJudgeActivationExtraArgs(admitted, options = {}) {
23476
- const prompt = buildJudgeTransportPrompt(admitted);
23657
+ const prompt = buildJudgeTransportPrompt(
23658
+ admitted,
23659
+ engineSessionMaterialFromOptions(options)
23660
+ );
23477
23661
  return [
23478
23662
  "--no-skills",
23479
23663
  "--no-prompt-templates",
@@ -23611,7 +23795,7 @@ async function dispatchAdmittedJudge(input) {
23611
23795
  }
23612
23796
  try {
23613
23797
  await writeFile10(
23614
- join15(admitted.runDirectory, "stderr.log"),
23798
+ join16(admitted.runDirectory, "stderr.log"),
23615
23799
  result2.stderr,
23616
23800
  "utf8"
23617
23801
  );
@@ -23712,7 +23896,9 @@ async function runPublicJudge(argv, env, io, parseJudgeArgv2) {
23712
23896
  throw error;
23713
23897
  }
23714
23898
  const extraArgs = buildJudgeActivationExtraArgs(admitted, {
23899
+ packageRoot: env.packageRoot,
23715
23900
  ...env.model === void 0 ? {} : { model: env.model },
23901
+ ...env.engine === void 0 ? {} : { engine: env.engine },
23716
23902
  ...env.extraPiArgs === void 0 ? {} : { extraPiArgs: env.extraPiArgs }
23717
23903
  });
23718
23904
  return await dispatchAdmittedJudge({
@@ -23781,6 +23967,7 @@ async function runPublicResume(argv, env, io) {
23781
23967
  var init_judge_run = __esm({
23782
23968
  "src/public-cli/judge-run.ts"() {
23783
23969
  "use strict";
23970
+ init_engine_material();
23784
23971
  init_explicit_internal();
23785
23972
  init_cli_errors();
23786
23973
  init_invocation();
@@ -23793,7 +23980,7 @@ var init_judge_run = __esm({
23793
23980
 
23794
23981
  // src/public-cli/merger-run.ts
23795
23982
  import { mkdir as mkdir4, writeFile as writeFile11 } from "node:fs/promises";
23796
- import { join as join16, resolve as resolve7 } from "node:path";
23983
+ import { join as join17, resolve as resolve7 } from "node:path";
23797
23984
  function buildMergerActivationExtraArgs(admitted, options) {
23798
23985
  const prompt = buildMergerTransportPrompt(admitted);
23799
23986
  const skillPath = resolvePackagedMethodSkillPath(
@@ -23949,7 +24136,7 @@ async function dispatchAdmittedMerger(input) {
23949
24136
  }
23950
24137
  try {
23951
24138
  await writeFile11(
23952
- join16(admitted.runDirectory, "stderr.log"),
24139
+ join17(admitted.runDirectory, "stderr.log"),
23953
24140
  result2.stderr,
23954
24141
  "utf8"
23955
24142
  );
@@ -24030,8 +24217,8 @@ async function admitMergerShellForActivationFailure(options) {
24030
24217
  expectedConflictPaths: [],
24031
24218
  resolutionScope: []
24032
24219
  };
24033
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
24034
- const mergerInputPath = join16(runDirectory, "merger-input.json");
24220
+ const admittedRequestPath = join17(runDirectory, "admitted-request.json");
24221
+ const mergerInputPath = join17(runDirectory, "merger-input.json");
24035
24222
  await writeFile11(
24036
24223
  admittedRequestPath,
24037
24224
  `${JSON.stringify(
@@ -24254,7 +24441,7 @@ var init_merger_run = __esm({
24254
24441
 
24255
24442
  // src/public-cli/reviewer-run.ts
24256
24443
  import { writeFile as writeFile12 } from "node:fs/promises";
24257
- import { join as join17 } from "node:path";
24444
+ import { join as join18 } from "node:path";
24258
24445
  function buildReviewerTicketNumberArgs(ticketNumber) {
24259
24446
  return ticketNumber === void 0 ? [] : ["--ak-review-ticket-number", String(ticketNumber)];
24260
24447
  }
@@ -24419,7 +24606,7 @@ async function dispatchAdmittedReviewer(input) {
24419
24606
  }
24420
24607
  try {
24421
24608
  await writeFile12(
24422
- join17(admitted.runDirectory, "stderr.log"),
24609
+ join18(admitted.runDirectory, "stderr.log"),
24423
24610
  result2.stderr,
24424
24611
  "utf8"
24425
24612
  );
@@ -24651,10 +24838,10 @@ var init_reviewer_run = __esm({
24651
24838
  // src/atomic-write.ts
24652
24839
  import { randomUUID as randomUUID2 } from "node:crypto";
24653
24840
  import { rename, rm, writeFile as writeFile13 } from "node:fs/promises";
24654
- import { dirname as dirname7, join as join18 } from "node:path";
24841
+ import { dirname as dirname7, join as join19 } from "node:path";
24655
24842
  async function writeFileAtomically(destination, contents) {
24656
24843
  const parent = dirname7(destination);
24657
- const temporary = join18(parent, `.atomic-write-${randomUUID2()}.tmp`);
24844
+ const temporary = join19(parent, `.atomic-write-${randomUUID2()}.tmp`);
24658
24845
  try {
24659
24846
  await writeFile13(temporary, contents);
24660
24847
  await rename(temporary, destination);
@@ -24671,7 +24858,7 @@ var init_atomic_write = __esm({
24671
24858
 
24672
24859
  // src/taishi-index.ts
24673
24860
  import { open as open3, readFile as readFile10, unlink as unlink4 } from "node:fs/promises";
24674
- import { dirname as dirname8, join as join19 } from "node:path";
24861
+ import { dirname as dirname8, join as join20 } from "node:path";
24675
24862
  function sleep(ms) {
24676
24863
  return new Promise((resolve9) => {
24677
24864
  setTimeout(resolve9, ms);
@@ -24680,7 +24867,7 @@ function sleep(ms) {
24680
24867
  async function withTaishiLibraryIndexLock(ledgerHome, fn) {
24681
24868
  const indexPath = taishiLibraryIndexPath(ledgerHome);
24682
24869
  ensureRealDirectoryTree(ledgerHome, dirname8(indexPath));
24683
- const lockPath = join19(dirname8(indexPath), LIBRARY_INDEX_LOCK_NAME);
24870
+ const lockPath = join20(dirname8(indexPath), LIBRARY_INDEX_LOCK_NAME);
24684
24871
  assertLedgerFileInsideHome(lockPath, ledgerHome);
24685
24872
  const startedAt = Date.now();
24686
24873
  while (true) {
@@ -24707,7 +24894,7 @@ async function withTaishiLibraryIndexLock(ledgerHome, fn) {
24707
24894
  }
24708
24895
  }
24709
24896
  function taishiLibraryIndexPath(ledgerHome) {
24710
- return join19(ledgerHome, "taishi", "library-index.json");
24897
+ return join20(ledgerHome, "taishi", "library-index.json");
24711
24898
  }
24712
24899
  function rowFromIssueMetricsPage(page) {
24713
24900
  return {
@@ -25097,7 +25284,7 @@ var init_ledger_session_read = __esm({
25097
25284
 
25098
25285
  // src/run-terminal-artifacts.ts
25099
25286
  import { readdir as readdir4, readFile as readFile12 } from "node:fs/promises";
25100
- import { basename as basename4, dirname as dirname9, join as join20 } from "node:path";
25287
+ import { basename as basename4, dirname as dirname9, join as join21 } from "node:path";
25101
25288
  function isMissingPathError3(error) {
25102
25289
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
25103
25290
  }
@@ -25172,7 +25359,7 @@ async function listUniqueErrorFallbackPaths(directories) {
25172
25359
  }
25173
25360
  for (const name of names.sort((a, b) => a.localeCompare(b))) {
25174
25361
  if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
25175
- found.push(join20(dir, name));
25362
+ found.push(join21(dir, name));
25176
25363
  }
25177
25364
  }
25178
25365
  return found;
@@ -25188,14 +25375,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
25188
25375
  return typeof body.runId === "string" && body.runId === expectedRunId;
25189
25376
  }
25190
25377
  async function readRunTerminalArtifact(runDirectory) {
25191
- const artifactsDir = join20(runDirectory, "artifacts");
25378
+ const artifactsDir = join21(runDirectory, "artifacts");
25192
25379
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
25193
- const path = join20(artifactsDir, file);
25380
+ const path = join21(artifactsDir, file);
25194
25381
  const read3 = await readTerminalArtifactAtPath(path, file);
25195
25382
  if (read3 !== void 0) return read3;
25196
25383
  }
25197
25384
  for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
25198
- const path = join20(runDirectory, relative3);
25385
+ const path = join21(runDirectory, relative3);
25199
25386
  const read3 = await readTerminalArtifactAtPath(path, "error.json");
25200
25387
  if (read3 !== void 0) return read3;
25201
25388
  }
@@ -25233,7 +25420,7 @@ var init_run_terminal_artifacts = __esm({
25233
25420
 
25234
25421
  // src/taishi-ledger.ts
25235
25422
  import { readdir as readdir5, readFile as readFile13 } from "node:fs/promises";
25236
- import { join as join21 } from "node:path";
25423
+ import { join as join22 } from "node:path";
25237
25424
  function isMissingPathError4(error) {
25238
25425
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
25239
25426
  }
@@ -25246,7 +25433,7 @@ function isRecord8(value) {
25246
25433
  async function readExistingRunLifecycleState(runDirectory) {
25247
25434
  try {
25248
25435
  const raw = JSON.parse(
25249
- await readFile13(join21(runDirectory, "run-state.json"), "utf8")
25436
+ await readFile13(join22(runDirectory, "run-state.json"), "utf8")
25250
25437
  );
25251
25438
  if (!isRecord8(raw) || typeof raw.state !== "string") return void 0;
25252
25439
  return raw.state;
@@ -25262,7 +25449,7 @@ function parseRunDirectoryName(name) {
25262
25449
  async function readInvocationScopeFields(runDirectory) {
25263
25450
  let raw;
25264
25451
  try {
25265
- raw = await readFile13(join21(runDirectory, "invocation.json"), "utf8");
25452
+ raw = await readFile13(join22(runDirectory, "invocation.json"), "utf8");
25266
25453
  } catch (error) {
25267
25454
  if (isMissingPathError4(error)) return void 0;
25268
25455
  throw error;
@@ -25290,7 +25477,7 @@ function decideIssueScope(input) {
25290
25477
  }
25291
25478
  async function resolveSessionFile(runDirectory) {
25292
25479
  try {
25293
- const raw = await readFile13(join21(runDirectory, "invocation.json"), "utf8");
25480
+ const raw = await readFile13(join22(runDirectory, "invocation.json"), "utf8");
25294
25481
  const parsed = JSON.parse(raw);
25295
25482
  if (isRecord8(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
25296
25483
  return parsed.sessionFile;
@@ -25298,7 +25485,7 @@ async function resolveSessionFile(runDirectory) {
25298
25485
  } catch (error) {
25299
25486
  if (!isMissingPathError4(error)) throw error;
25300
25487
  }
25301
- return join21(runDirectory, "session", "session.jsonl");
25488
+ return join22(runDirectory, "session", "session.jsonl");
25302
25489
  }
25303
25490
  async function classifyScopedRun(input) {
25304
25491
  const missingSources = [];
@@ -25423,7 +25610,7 @@ async function scanTaishiIssueRuns(input) {
25423
25610
  const ledgerHome = resolveActivationLedgerHome();
25424
25611
  const scopeIdentity = physicalPathIdentity(input.projectRoot);
25425
25612
  const scopeTicketNumber = input.ticketNumber;
25426
- const booksRoot = join21(ledgerHome, "books");
25613
+ const booksRoot = join22(ledgerHome, "books");
25427
25614
  let bookNames;
25428
25615
  try {
25429
25616
  const entries = await readdir5(booksRoot, { withFileTypes: true });
@@ -25438,7 +25625,7 @@ async function scanTaishiIssueRuns(input) {
25438
25625
  const unreadable = [];
25439
25626
  const scopeConflicts = [];
25440
25627
  for (const book of bookNames) {
25441
- const runsDir = join21(booksRoot, book, "runs");
25628
+ const runsDir = join22(booksRoot, book, "runs");
25442
25629
  let runNames;
25443
25630
  try {
25444
25631
  const entries = await readdir5(runsDir, { withFileTypes: true });
@@ -25450,7 +25637,7 @@ async function scanTaishiIssueRuns(input) {
25450
25637
  for (const runName of runNames) {
25451
25638
  const parsed = parseRunDirectoryName(runName);
25452
25639
  if (parsed === void 0) continue;
25453
- const runDirectory = join21(runsDir, runName);
25640
+ const runDirectory = join22(runsDir, runName);
25454
25641
  let scopeFields;
25455
25642
  try {
25456
25643
  scopeFields = await readInvocationScopeFields(runDirectory);
@@ -26229,13 +26416,13 @@ var init_taishi_metric_family = __esm({
26229
26416
 
26230
26417
  // src/taishi-page.ts
26231
26418
  import { createHash as createHash4 } from "node:crypto";
26232
- import { dirname as dirname10, join as join22 } from "node:path";
26419
+ import { dirname as dirname10, join as join23 } from "node:path";
26233
26420
  function taishiIssuePageKey(projectRoot) {
26234
26421
  const identity = physicalPathIdentity(projectRoot);
26235
26422
  return createHash4("sha256").update(identity).digest("hex").slice(0, 32);
26236
26423
  }
26237
26424
  function taishiIssuePagePath(ledgerHome, projectRoot) {
26238
- return join22(ledgerHome, "taishi", "issues", `${taishiIssuePageKey(projectRoot)}.json`);
26425
+ return join23(ledgerHome, "taishi", "issues", `${taishiIssuePageKey(projectRoot)}.json`);
26239
26426
  }
26240
26427
  function sortLegs(legs) {
26241
26428
  return [...legs].sort((a, b) => {
@@ -26720,7 +26907,7 @@ __export(cli_exports, {
26720
26907
  });
26721
26908
  import { realpath as realpath5 } from "node:fs/promises";
26722
26909
  import { homedir as homedir3 } from "node:os";
26723
- import { join as join23 } from "node:path";
26910
+ import { join as join24 } from "node:path";
26724
26911
  function takePublicGlobalFlag(argv, index, options) {
26725
26912
  const tokens = argv.slice(index);
26726
26913
  const taken = options.takeDashed(tokens);
@@ -26743,6 +26930,13 @@ function takePublicGlobalFlag(argv, index, options) {
26743
26930
  raw: taken.value
26744
26931
  };
26745
26932
  }
26933
+ if (taken.def.id === "engine") {
26934
+ return {
26935
+ flag: "engine",
26936
+ consume: consumed,
26937
+ value: taken.value
26938
+ };
26939
+ }
26746
26940
  return void 0;
26747
26941
  }
26748
26942
  function defaultIo() {
@@ -26759,7 +26953,7 @@ function resolveHome(env) {
26759
26953
  return env.home ?? process.env.HOME ?? homedir3();
26760
26954
  }
26761
26955
  function resolveAgentDir(env, home) {
26762
- return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join23(home, ".pi", "agent");
26956
+ return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join24(home, ".pi", "agent");
26763
26957
  }
26764
26958
  function parseThinking(value) {
26765
26959
  if (!THINKING_LEVELS2.has(value)) {
@@ -26771,6 +26965,7 @@ function parseArgv(argv) {
26771
26965
  const args = [...argv];
26772
26966
  let model;
26773
26967
  let thinking;
26968
+ let engine;
26774
26969
  let help = false;
26775
26970
  const positional = [];
26776
26971
  const globalOptions = createTypedOptionConsumer(PUBLIC_GLOBAL_OPTIONS);
@@ -26795,12 +26990,23 @@ function parseArgv(argv) {
26795
26990
  args.splice(0, taken.consume);
26796
26991
  continue;
26797
26992
  }
26798
- if (taken.raw === void 0) {
26799
- throw new CliUsageError("--thinking requires a value");
26993
+ if (taken.flag === "thinking") {
26994
+ if (taken.raw === void 0) {
26995
+ throw new CliUsageError("--thinking requires a value");
26996
+ }
26997
+ thinking = parseThinking(taken.raw);
26998
+ args.splice(0, taken.consume);
26999
+ continue;
26800
27000
  }
26801
- thinking = parseThinking(taken.raw);
26802
- args.splice(0, taken.consume);
26803
- continue;
27001
+ if (taken.flag === "engine") {
27002
+ if (taken.value === void 0) {
27003
+ throw new CliUsageError("--engine requires a value");
27004
+ }
27005
+ engine = taken.value;
27006
+ args.splice(0, taken.consume);
27007
+ continue;
27008
+ }
27009
+ throw new CliUsageError(`unhandled global option: ${String(taken.flag)}`);
26804
27010
  }
26805
27011
  positional.push(args.shift());
26806
27012
  }
@@ -26810,16 +27016,43 @@ function parseArgv(argv) {
26810
27016
  args: rest,
26811
27017
  ...model === void 0 ? {} : { model },
26812
27018
  ...thinking === void 0 ? {} : { thinking },
27019
+ ...engine === void 0 ? {} : { engine },
26813
27020
  help
26814
27021
  };
26815
27022
  }
26816
27023
  function invocationFromParsed(parsed) {
26817
- if (parsed.model === void 0 && parsed.thinking === void 0) return void 0;
27024
+ if (parsed.model === void 0 && parsed.thinking === void 0 && parsed.engine === void 0) {
27025
+ return void 0;
27026
+ }
26818
27027
  return {
26819
27028
  ...parsed.model === void 0 ? {} : { model: parsed.model },
26820
- ...parsed.thinking === void 0 ? {} : { thinking: parsed.thinking }
27029
+ ...parsed.thinking === void 0 ? {} : { thinking: parsed.thinking },
27030
+ ...parsed.engine === void 0 ? {} : { engine: parsed.engine }
26821
27031
  };
26822
27032
  }
27033
+ function requireLegalEngineName(packageRoot2, name) {
27034
+ try {
27035
+ return assertLegalEngineName(packageRoot2, name);
27036
+ } catch (error) {
27037
+ throw new CliUsageError(
27038
+ error instanceof Error ? error.message : String(error),
27039
+ { cause: error }
27040
+ );
27041
+ }
27042
+ }
27043
+ function loadAndValidateConfig(home, packageRoot2) {
27044
+ return loadPublicCliConfig(home).then((config) => {
27045
+ try {
27046
+ validatePublicCliConfigEngines(config, packageRoot2);
27047
+ } catch (error) {
27048
+ throw new CliUsageError(
27049
+ error instanceof Error ? error.message : String(error),
27050
+ { cause: error }
27051
+ );
27052
+ }
27053
+ return config;
27054
+ });
27055
+ }
26823
27056
  function helpDocument() {
26824
27057
  return {
26825
27058
  executable: "ak-role",
@@ -26878,6 +27111,7 @@ function renderHelp() {
26878
27111
  "",
26879
27112
  "Role options: ak-role help <command>",
26880
27113
  "Persistent config: ak-role config set <seat> <provider/model:thinking>",
27114
+ "Persistent engine (judge only): ak-role config set-engine judge <name> | unset-engine judge",
26881
27115
  "Effective seats: ak-role roles"
26882
27116
  );
26883
27117
  return `${lines.join("\n")}
@@ -26918,7 +27152,7 @@ function renderRoles(seats) {
26918
27152
  `;
26919
27153
  }
26920
27154
  function renderConfig(config) {
26921
- const lines = ["seat model"];
27155
+ const lines = ["seat model engine"];
26922
27156
  const keys = Object.keys(config.seats);
26923
27157
  if (keys.length === 0) {
26924
27158
  lines.push("(empty)");
@@ -26926,15 +27160,16 @@ function renderConfig(config) {
26926
27160
  for (const seat of keys.sort()) {
26927
27161
  const selection = config.seats[seat];
26928
27162
  if (selection === void 0) continue;
26929
- lines.push(`${seat} ${formatModelSpec(selection)}`);
27163
+ const engine = selection.engine === void 0 ? "-" : selection.engine;
27164
+ lines.push(`${seat} ${formatModelSpec(selection)} ${engine}`);
26930
27165
  }
26931
27166
  }
26932
27167
  return `${lines.join("\n")}
26933
27168
  `;
26934
27169
  }
26935
- async function runConfigCommand(args, home, io) {
27170
+ async function runConfigCommand(args, home, packageRoot2, io) {
26936
27171
  if (args.length === 0 || args[0] === "get" || args[0] === "list" || args[0] === "show") {
26937
- const config = await loadPublicCliConfig(home);
27172
+ const config = await loadAndValidateConfig(home, packageRoot2);
26938
27173
  if (args[0] === "get" && args[1] !== void 0) {
26939
27174
  if (!isPublicConfigurableSeat(args[1])) {
26940
27175
  throw new CliUsageError(`unknown configurable seat: ${args[1]}`);
@@ -26944,7 +27179,8 @@ async function runConfigCommand(args, home, io) {
26944
27179
  io.stdout(`${args[1]} (unconfigured)
26945
27180
  `);
26946
27181
  } else {
26947
- io.stdout(`${args[1]} ${formatModelSpec(selection)}
27182
+ const engine = selection.engine === void 0 ? "-" : selection.engine;
27183
+ io.stdout(`${args[1]} ${formatModelSpec(selection)} ${engine}
26948
27184
  `);
26949
27185
  }
26950
27186
  return 0;
@@ -26964,7 +27200,7 @@ async function runConfigCommand(args, home, io) {
26964
27200
  "config set requires seat/spec pairs: ak-role config set <seat> <spec> [<seat> <spec> ...]"
26965
27201
  );
26966
27202
  }
26967
- let config = await loadPublicCliConfig(home);
27203
+ let config = await loadAndValidateConfig(home, packageRoot2);
26968
27204
  for (let i = 0; i < pairs.length; i += 2) {
26969
27205
  const seat = pairs[i];
26970
27206
  const spec = pairs[i + 1];
@@ -26977,6 +27213,64 @@ async function runConfigCommand(args, home, io) {
26977
27213
  io.stdout(renderConfig(config));
26978
27214
  return 0;
26979
27215
  }
27216
+ if (args[0] === "set-engine") {
27217
+ if (args.length !== 3) {
27218
+ throw new CliUsageError(
27219
+ "usage: ak-role config set-engine judge <name>"
27220
+ );
27221
+ }
27222
+ const seat = args[1];
27223
+ const name = args[2];
27224
+ if (!isPublicConfigurableSeat(seat)) {
27225
+ throw new CliUsageError(`unknown configurable seat: ${seat}`);
27226
+ }
27227
+ if (seat !== "judge") {
27228
+ throw new CliUsageError(
27229
+ `engine axis is judge-only; refused seat ${seat}`
27230
+ );
27231
+ }
27232
+ requireLegalEngineName(packageRoot2, name);
27233
+ let config = await loadAndValidateConfig(home, packageRoot2);
27234
+ try {
27235
+ config = setPersistentSeatEngine(config, seat, name);
27236
+ } catch (error) {
27237
+ throw new CliUsageError(
27238
+ error instanceof Error ? error.message : String(error),
27239
+ { cause: error }
27240
+ );
27241
+ }
27242
+ await savePublicCliConfig(config, home);
27243
+ io.stdout(renderConfig(config));
27244
+ return 0;
27245
+ }
27246
+ if (args[0] === "unset-engine") {
27247
+ if (args.length !== 2) {
27248
+ throw new CliUsageError(
27249
+ "usage: ak-role config unset-engine judge"
27250
+ );
27251
+ }
27252
+ const seat = args[1];
27253
+ if (!isPublicConfigurableSeat(seat)) {
27254
+ throw new CliUsageError(`unknown configurable seat: ${seat}`);
27255
+ }
27256
+ if (seat !== "judge") {
27257
+ throw new CliUsageError(
27258
+ `engine axis is judge-only; refused seat ${seat}`
27259
+ );
27260
+ }
27261
+ let config = await loadAndValidateConfig(home, packageRoot2);
27262
+ try {
27263
+ config = setPersistentSeatEngine(config, seat, void 0);
27264
+ } catch (error) {
27265
+ throw new CliUsageError(
27266
+ error instanceof Error ? error.message : String(error),
27267
+ { cause: error }
27268
+ );
27269
+ }
27270
+ await savePublicCliConfig(config, home);
27271
+ io.stdout(renderConfig(config));
27272
+ return 0;
27273
+ }
26980
27274
  throw new CliUsageError(`unknown config subcommand: ${args[0]}`);
26981
27275
  }
26982
27276
  async function runAkRole(argv, env) {
@@ -26985,6 +27279,14 @@ async function runAkRole(argv, env) {
26985
27279
  try {
26986
27280
  env = { ...env, packageRoot: await realpath5(env.packageRoot) };
26987
27281
  const parsed = parseArgv(argv);
27282
+ if (parsed.engine !== void 0) {
27283
+ requireLegalEngineName(env.packageRoot, parsed.engine);
27284
+ if (!parsed.help && parsed.command !== void 0 && parsed.command !== "help" && parsed.command !== "judge") {
27285
+ throw new CliUsageError(
27286
+ `engine axis is judge-only; refused command ${parsed.command}`
27287
+ );
27288
+ }
27289
+ }
26988
27290
  if (parsed.help || parsed.command === void 0 || parsed.command === "help") {
26989
27291
  if (parsed.command === "help" && parsed.args[0] !== void 0) {
26990
27292
  const topic = parsed.args[0];
@@ -27002,7 +27304,7 @@ async function runAkRole(argv, env) {
27002
27304
  if (parsed.args.length > 0) {
27003
27305
  throw new CliUsageError("roles takes no arguments");
27004
27306
  }
27005
- const config = await loadPublicCliConfig(home);
27307
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27006
27308
  const credentials = env.credentials ?? await loadCredentialProviders(resolveAgentDir(env, home));
27007
27309
  const seats = effectiveSeatConfigurations(
27008
27310
  config,
@@ -27013,12 +27315,14 @@ async function runAkRole(argv, env) {
27013
27315
  return { exitCode: 0 };
27014
27316
  }
27015
27317
  if (parsed.command === "config") {
27016
- return { exitCode: await runConfigCommand(parsed.args, home, io) };
27318
+ return {
27319
+ exitCode: await runConfigCommand(parsed.args, home, env.packageRoot, io)
27320
+ };
27017
27321
  }
27018
27322
  if (parsed.command === "resume") {
27019
27323
  const agentDir = resolveAgentDir(env, home);
27020
27324
  const cwd = env.cwd ?? process.cwd();
27021
- const config = await loadPublicCliConfig(home);
27325
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27022
27326
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
27023
27327
  const resumeRunId = parsed.args[0];
27024
27328
  const resumeRole = resumeRunId === void 0 || resumeRunId.trim() === "" ? void 0 : await peekRoleRunRole(home, resumeRunId);
@@ -27154,7 +27458,7 @@ async function runAkRole(argv, env) {
27154
27458
  if (parsed.command === "judge") {
27155
27459
  const agentDir = resolveAgentDir(env, home);
27156
27460
  const cwd = env.cwd ?? process.cwd();
27157
- const config = await loadPublicCliConfig(home);
27461
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27158
27462
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
27159
27463
  const seat = resolveEffectiveSeat(
27160
27464
  config,
@@ -27173,6 +27477,7 @@ async function runAkRole(argv, env) {
27173
27477
  ...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
27174
27478
  ...env.piRunner === void 0 ? {} : { piRunner: env.piRunner },
27175
27479
  ...seat.selection === void 0 ? {} : { model: seat.selection },
27480
+ ...seat.engine === void 0 ? {} : { engine: seat.engine },
27176
27481
  ...env.judgeExtraPiArgs === void 0 ? {} : { extraPiArgs: env.judgeExtraPiArgs },
27177
27482
  ...env.judgeTimeoutMs === void 0 ? {} : { timeoutMs: env.judgeTimeoutMs },
27178
27483
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
@@ -27188,7 +27493,7 @@ async function runAkRole(argv, env) {
27188
27493
  if (parsed.command === "coder") {
27189
27494
  const agentDir = resolveAgentDir(env, home);
27190
27495
  const cwd = env.cwd ?? process.cwd();
27191
- const config = await loadPublicCliConfig(home);
27496
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27192
27497
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
27193
27498
  const seat = resolveEffectiveSeat(
27194
27499
  config,
@@ -27222,7 +27527,7 @@ async function runAkRole(argv, env) {
27222
27527
  if (parsed.command === "fixer") {
27223
27528
  const agentDir = resolveAgentDir(env, home);
27224
27529
  const cwd = env.cwd ?? process.cwd();
27225
- const config = await loadPublicCliConfig(home);
27530
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27226
27531
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
27227
27532
  const seat = resolveEffectiveSeat(
27228
27533
  config,
@@ -27256,7 +27561,7 @@ async function runAkRole(argv, env) {
27256
27561
  if (parsed.command === "collector") {
27257
27562
  const agentDir = resolveAgentDir(env, home);
27258
27563
  const cwd = env.cwd ?? process.cwd();
27259
- const config = await loadPublicCliConfig(home);
27564
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27260
27565
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
27261
27566
  const seat = resolveEffectiveSeat(
27262
27567
  config,
@@ -27290,7 +27595,7 @@ async function runAkRole(argv, env) {
27290
27595
  if (parsed.command === "reviewer") {
27291
27596
  const agentDir = resolveAgentDir(env, home);
27292
27597
  const cwd = env.cwd ?? process.cwd();
27293
- const config = await loadPublicCliConfig(home);
27598
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27294
27599
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
27295
27600
  const seat = resolveEffectiveSeat(
27296
27601
  config,
@@ -27324,7 +27629,7 @@ async function runAkRole(argv, env) {
27324
27629
  if (parsed.command === "doctor") {
27325
27630
  const agentDir = resolveAgentDir(env, home);
27326
27631
  const cwd = env.cwd ?? process.cwd();
27327
- const config = await loadPublicCliConfig(home);
27632
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27328
27633
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
27329
27634
  const seat = resolveEffectiveSeat(
27330
27635
  config,
@@ -27358,7 +27663,7 @@ async function runAkRole(argv, env) {
27358
27663
  if (parsed.command === "merger") {
27359
27664
  const agentDir = resolveAgentDir(env, home);
27360
27665
  const cwd = env.cwd ?? process.cwd();
27361
- const config = await loadPublicCliConfig(home);
27666
+ const config = await loadAndValidateConfig(home, env.packageRoot);
27362
27667
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
27363
27668
  const seat = resolveEffectiveSeat(
27364
27669
  config,
@@ -27417,6 +27722,7 @@ var PUBLIC_ROLE_ARGV, PUBLIC_GLOBAL_OPTIONS, THINKING_LEVELS2;
27417
27722
  var init_cli = __esm({
27418
27723
  "src/public-cli/cli.ts"() {
27419
27724
  "use strict";
27725
+ init_engine_material();
27420
27726
  init_config2();
27421
27727
  init_cli_errors();
27422
27728
  init_explicit_internal();
@@ -27460,8 +27766,8 @@ var init_cli = __esm({
27460
27766
  });
27461
27767
 
27462
27768
  // src/public-cli/main.ts
27463
- import { existsSync as existsSync2 } from "node:fs";
27464
- import { dirname as dirname11, join as join24 } from "node:path";
27769
+ import { existsSync as existsSync3 } from "node:fs";
27770
+ import { dirname as dirname11, join as join25 } from "node:path";
27465
27771
  import { fileURLToPath as fileURLToPath2 } from "node:url";
27466
27772
 
27467
27773
  // src/public-cli/host-pi-runtime.ts
@@ -27550,8 +27856,8 @@ function linkPackage(packageRoot2, name, targetDir) {
27550
27856
  // src/public-cli/main.ts
27551
27857
  var here = dirname11(fileURLToPath2(import.meta.url));
27552
27858
  function resolvePackageRoot(binDir) {
27553
- const canonical = join24(binDir, "..", "..");
27554
- if (existsSync2(join24(canonical, "package.json"))) {
27859
+ const canonical = join25(binDir, "..", "..");
27860
+ if (existsSync3(join25(canonical, "package.json"))) {
27555
27861
  return canonical;
27556
27862
  }
27557
27863
  return binDir;