@akagilnc/pi-workflow-roles 0.1.5762 → 0.1.5797

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.
Files changed (52) hide show
  1. package/dist/acp-host/production-host.js +685 -285
  2. package/dist/external-host-turn-loop.js +3 -0
  3. package/dist/headless-host/production-host.js +658 -258
  4. package/dist/migrate-book-topology.js +70 -29
  5. package/dist/navigator-attendance.js +1 -1
  6. package/dist/packaged-role-registry.js +3 -2
  7. package/dist/pi/role-turn-host.js +6 -1
  8. package/dist/public-cli/instruction-seat-run.js +152 -60
  9. package/dist/public-cli/invocation.js +98 -46
  10. package/dist/public-cli/main.js +482 -222
  11. package/dist/public-cli/option-definitions.js +4 -4
  12. package/dist/public-cli/post-admission.js +19 -28
  13. package/dist/public-cli/run-lifecycle.js +10 -21
  14. package/dist/public-cli/turn-request.js +3 -0
  15. package/dist/public-role-summons.js +11 -8
  16. package/dist/report-ticket-tool.js +3 -3
  17. package/dist/role-run-placement.js +14 -2
  18. package/dist/role-run-relocation.js +2 -2
  19. package/dist/run-dossier.js +5 -4
  20. package/dist/run-terminal-artifacts.js +0 -7
  21. package/dist/session-identity.js +3 -2
  22. package/dist/sitian-appender.js +12 -3
  23. package/dist/submission-ledger.js +24 -0
  24. package/dist/ticket-progress.js +306 -0
  25. package/dist/user-dialogue-stdin.js +23 -17
  26. package/package.json +1 -1
  27. package/src/external-host-turn-loop.ts +7 -1
  28. package/src/host-contracts.ts +1 -1
  29. package/src/navigator-attendance.ts +2 -1
  30. package/src/packaged-role-registry.ts +3 -2
  31. package/src/pi/adapter.ts +57 -45
  32. package/src/pi/role-turn-host.ts +6 -1
  33. package/src/prepared-role-turn.ts +6 -0
  34. package/src/public-cli/instruction-seat-run.ts +166 -68
  35. package/src/public-cli/invocation.ts +120 -46
  36. package/src/public-cli/option-definitions.ts +5 -4
  37. package/src/public-cli/post-admission.ts +19 -30
  38. package/src/public-cli/run-lifecycle.ts +10 -27
  39. package/src/public-cli/turn-request.ts +3 -0
  40. package/src/public-role-summons.ts +27 -16
  41. package/src/report-ticket-tool.ts +7 -3
  42. package/src/role-envelope.ts +5 -0
  43. package/src/role-run-placement.ts +19 -2
  44. package/src/role-run-relocation.ts +2 -2
  45. package/src/role-runtime.ts +19 -2
  46. package/src/run-dossier.ts +5 -3
  47. package/src/run-terminal-artifacts.ts +0 -8
  48. package/src/session-identity.ts +3 -2
  49. package/src/sitian-appender.ts +14 -3
  50. package/src/submission-ledger.ts +27 -0
  51. package/src/ticket-progress.ts +383 -0
  52. package/src/user-dialogue-stdin.ts +21 -14
@@ -1200,6 +1200,16 @@ function parseRunLeaf(name) {
1200
1200
  if (at <= 0 || at === name.length - 1) return void 0;
1201
1201
  return { runId: name.slice(0, at), role: name.slice(at + 1) };
1202
1202
  }
1203
+ function subjectDirectoryOfRun(runDirectory) {
1204
+ const runsParent = dirname2(runDirectory);
1205
+ if (basename2(runsParent) !== "runs") return void 0;
1206
+ const subjectDirectory = dirname2(runsParent);
1207
+ const subjectName = basename2(subjectDirectory);
1208
+ if (subjectName === "unbound" || /^[1-9]\d*$/.test(subjectName)) {
1209
+ return subjectDirectory;
1210
+ }
1211
+ return void 0;
1212
+ }
1203
1213
  function sessionDirectoryOf(runDirectory) {
1204
1214
  return join3(runDirectory, "session");
1205
1215
  }
@@ -1292,6 +1302,7 @@ function ensureRoleRunDirectory(ledgerHome, directory) {
1292
1302
  return ensureRealDirectoryTree(ledgerHome, directory);
1293
1303
  }
1294
1304
  function ensureRoleRunPlacement(ledgerHome, placement) {
1305
+ ensureRoleRunDirectory(ledgerHome, placement.runDirectory);
1295
1306
  ensureRoleRunDirectory(ledgerHome, placement.sessionDirectory);
1296
1307
  }
1297
1308
  var ROLE_RUN_SESSION_FILENAME;
@@ -1592,6 +1603,12 @@ function appendSitianRecordBlock(input, block) {
1592
1603
  function resolveSitianVolumeCategory(kind) {
1593
1604
  return kind;
1594
1605
  }
1606
+ function runDirectoryOwningSessionParent(sessionParentDir) {
1607
+ if (basename4(sessionParentDir) !== "session") return void 0;
1608
+ const runDirectory = dirname4(sessionParentDir);
1609
+ if (parseRunLeaf(basename4(runDirectory)) === void 0) return void 0;
1610
+ return runDirectory;
1611
+ }
1595
1612
  function sitianVolumeDirectory(sessionDirectory, category) {
1596
1613
  return join4(sessionDirectory, category);
1597
1614
  }
@@ -1623,8 +1640,8 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
1623
1640
  throw new Error("Sitian record ownership requires a parent session inside the ledger home");
1624
1641
  }
1625
1642
  const sessionParentDir = dirname4(input.sessionParent);
1626
- const runDirectory = dirname4(sessionParentDir);
1627
- if (basename4(sessionParentDir) === "session" && parseRunLeaf(basename4(runDirectory)) !== void 0) {
1643
+ const runDirectory = runDirectoryOwningSessionParent(sessionParentDir);
1644
+ if (runDirectory !== void 0) {
1628
1645
  sessionDir = runDirectory;
1629
1646
  recordFile = join4(runDirectory, RUN_HISTORY_KINDS.has(input.kind) ? RUN_HISTORY_FILE : RUN_STATE_KINDS.has(input.kind) ? RUN_STATE_FILE : RUN_LOG_FILE);
1630
1647
  } else {
@@ -1857,7 +1874,9 @@ function render(runDirectory, history, state, log, unreadable) {
1857
1874
  original = payload.landingPath;
1858
1875
  }
1859
1876
  }
1860
- if (typeof original === "string") original = join5(runDirectory, "session", basename5(original));
1877
+ if (typeof original === "string") {
1878
+ original = join5(sessionDirectoryOf(runDirectory), basename5(original));
1879
+ }
1861
1880
  whole.host = { sessions, ...original === void 0 ? {} : { original } };
1862
1881
  whole.submission = latest === void 0 ? {} : { latest };
1863
1882
  if (Object.keys(unreadable).length > 0) whole.unreadable = unreadable;
@@ -2677,9 +2696,8 @@ var init_packaged_role_registry = __esm({
2677
2696
  bareCommand: false,
2678
2697
  outputTool: NOTARY_OUTPUT_TOOL_NAME,
2679
2698
  settlement: "accepted",
2680
- /** Court reask replaces the initial prompt. Otherwise the fixed kickoff. */
2699
+ /** Dialogue via shared resolveReviewSeatDialogueBody (review = fixed dispatch). */
2681
2700
  reaskPrompt: true,
2682
- transportPrompt: "fixed-kickoff",
2683
2701
  gateStageLabel: "\u7B26\u5B9D\u90CE",
2684
2702
  /** Gate summon binds --source-run and keeps dialogue off the argv. */
2685
2703
  gateSummon: "source-run",
@@ -2702,6 +2720,8 @@ var init_packaged_role_registry = __esm({
2702
2720
  phases: [null],
2703
2721
  outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
2704
2722
  settlement: "accepted",
2723
+ /** Same shared dialogue resolver as other review seats (#1208 C1). */
2724
+ reaskPrompt: true,
2705
2725
  gateStageLabel: "\u7ED9\u4E8B\u4E2D",
2706
2726
  /** Gate summon carries the parent payload as the instruction and a parent run id. */
2707
2727
  gateSummon: "parent-instruction",
@@ -4920,7 +4940,6 @@ var run_terminal_artifacts_exports = {};
4920
4940
  __export(run_terminal_artifacts_exports, {
4921
4941
  ATTEMPT_HISTORY_IDENTITY_FIELD: () => ATTEMPT_HISTORY_IDENTITY_FIELD,
4922
4942
  TERMINAL_COURT_ATTEMPT_FIELD: () => TERMINAL_COURT_ATTEMPT_FIELD,
4923
- isTicketCourtCountersignSource: () => isTicketCourtCountersignSource,
4924
4943
  readRunTerminal: () => readRunTerminal,
4925
4944
  roleFromRunDirectory: () => roleFromRunDirectory,
4926
4945
  runIdFromRunDirectory: () => runIdFromRunDirectory,
@@ -4981,9 +5000,6 @@ function runIdFromRunDirectory(runDirectory) {
4981
5000
  function roleFromRunDirectory(runDirectory) {
4982
5001
  return parseRunLeaf(basename6(runDirectory))?.role;
4983
5002
  }
4984
- function isTicketCourtCountersignSource(runDirectory) {
4985
- return roleFromRunDirectory(runDirectory) === "countersign";
4986
- }
4987
5003
  var ATTEMPT_HISTORY_IDENTITY_FIELD, TERMINAL_COURT_ATTEMPT_FIELD;
4988
5004
  var init_run_terminal_artifacts = __esm({
4989
5005
  "src/run-terminal-artifacts.ts"() {
@@ -5867,7 +5883,8 @@ var init_role_activation_flags = __esm({
5867
5883
 
5868
5884
  // src/user-dialogue-stdin.ts
5869
5885
  function encodeUserDialogueStdin(body) {
5870
- return JSON.stringify({ kind: USER_DIALOGUE_STDIN_KIND, body });
5886
+ const envelope = { kind: USER_DIALOGUE_STDIN_KIND, body };
5887
+ return JSON.stringify(envelope);
5871
5888
  }
5872
5889
  var USER_DIALOGUE_STDIN_KIND;
5873
5890
  var init_user_dialogue_stdin = __esm({
@@ -5878,6 +5895,242 @@ var init_user_dialogue_stdin = __esm({
5878
5895
  }
5879
5896
  });
5880
5897
 
5898
+ // src/ticket-progress.ts
5899
+ import { spawnSync as spawnSync2 } from "node:child_process";
5900
+ import {
5901
+ appendFileSync as appendFileSync2,
5902
+ existsSync as existsSync3,
5903
+ mkdirSync as mkdirSync3,
5904
+ readFileSync as readFileSync3,
5905
+ readdirSync as readdirSync3,
5906
+ rmSync as rmSync3,
5907
+ writeFileSync as writeFileSync2
5908
+ } from "node:fs";
5909
+ import { basename as basename7, dirname as dirname8, join as join10, relative as relative3, sep as sep4 } from "node:path";
5910
+ function parseProgressText(text, pathForDiagnostic) {
5911
+ if (text.trim() === "") return [];
5912
+ const { records, diagnostics } = parseSitianRecordText(text);
5913
+ for (const diagnostic of diagnostics) {
5914
+ process.stderr.write(
5915
+ `[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
5916
+ `
5917
+ );
5918
+ }
5919
+ const lines = [];
5920
+ for (const record of records) {
5921
+ const parsed = record;
5922
+ if (!isRecord(parsed)) continue;
5923
+ if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
5924
+ lines.push(parsed);
5925
+ }
5926
+ return lines;
5927
+ }
5928
+ function readProgressFile(path) {
5929
+ if (!existsSync3(path)) return [];
5930
+ return parseProgressText(readFileSync3(path, "utf8"), path);
5931
+ }
5932
+ function readTicketProgressLines(subjectDirectory) {
5933
+ if (basename7(subjectDirectory) === "unbound") {
5934
+ const runsDir = join10(subjectDirectory, "runs");
5935
+ if (!existsSync3(runsDir)) return [];
5936
+ const out = [];
5937
+ for (const name of readdirSync3(runsDir).sort()) {
5938
+ out.push(...readProgressFile(join10(runsDir, name, LEG_PROGRESS_FILENAME)));
5939
+ }
5940
+ return out;
5941
+ }
5942
+ return readProgressFile(join10(subjectDirectory, CURRENT_FILENAME));
5943
+ }
5944
+ function roundBaseNumber(round) {
5945
+ if (round.trim() === "") return 0;
5946
+ const base = round.includes(".") ? round.slice(0, round.indexOf(".")) : round;
5947
+ const n = Number(base);
5948
+ return Number.isSafeInteger(n) && n > 0 ? n : 0;
5949
+ }
5950
+ function roundLens(round) {
5951
+ return round.includes(".") ? round.slice(round.indexOf(".") + 1) : void 0;
5952
+ }
5953
+ function nextRoundFromLines(lines, seat, lens) {
5954
+ const want = lens === void 0 || lens.trim() === "" ? void 0 : lens;
5955
+ let max = 0;
5956
+ for (const line2 of lines) {
5957
+ if (line2.seat !== seat) continue;
5958
+ if (roundLens(line2.round) !== want) continue;
5959
+ max = Math.max(max, roundBaseNumber(line2.round));
5960
+ }
5961
+ const base = max + 1;
5962
+ return want === void 0 ? String(base) : `${base}.${want}`;
5963
+ }
5964
+ function nextLegReceiptIndex(runDirectory) {
5965
+ const dir = join10(runDirectory, RECEIPTS_DIRNAME);
5966
+ if (!existsSync3(dir)) return 1;
5967
+ let max = 0;
5968
+ for (const name of readdirSync3(dir)) {
5969
+ const match = /^(\d+)\.json$/.exec(name);
5970
+ if (match === null) continue;
5971
+ const n = Number(match[1]);
5972
+ if (Number.isSafeInteger(n) && n > max) max = n;
5973
+ }
5974
+ return max + 1;
5975
+ }
5976
+ function statusAndSummaryFromPayload(seat, payload) {
5977
+ if (!isRecord(payload)) return {};
5978
+ const toolName = packagedRoleOutputTool(seat);
5979
+ const status = toolName !== void 0 && isTerminatingToolName(toolName) ? acceptedFacts(toolName, payload).status : void 0;
5980
+ const summary = typeof payload.summary === "string" ? payload.summary : void 0;
5981
+ return {
5982
+ ...status === void 0 ? {} : { status },
5983
+ ...summary === void 0 ? {} : { summary }
5984
+ };
5985
+ }
5986
+ function captureWorktreeHead(projectRoot) {
5987
+ try {
5988
+ const result = spawnSync2("git", ["rev-parse", "HEAD"], {
5989
+ cwd: projectRoot,
5990
+ encoding: "utf8",
5991
+ maxBuffer: 1024 * 1024
5992
+ });
5993
+ if (result.error != null) {
5994
+ const err = result.error;
5995
+ const detail = err instanceof Error ? err.stack ?? err.message : String(err);
5996
+ return { head: "", fault: `git rev-parse HEAD spawn failed cwd=${projectRoot}: ${detail}` };
5997
+ }
5998
+ if (result.status !== 0) {
5999
+ const detail = [result.stderr, result.stdout].map((part) => typeof part === "string" ? part.trim() : "").filter((part) => part !== "").join(" | ");
6000
+ const status = result.status === null ? "null" : String(result.status);
6001
+ const signal = result.signal == null ? "" : ` signal=${result.signal}`;
6002
+ return {
6003
+ head: "",
6004
+ fault: detail === "" ? `git rev-parse HEAD failed (status=${status}${signal}) cwd=${projectRoot}` : `git rev-parse HEAD failed (status=${status}${signal}) cwd=${projectRoot}: ${detail}`
6005
+ };
6006
+ }
6007
+ return { head: (result.stdout ?? "").trim() };
6008
+ } catch (error) {
6009
+ const message = error instanceof Error ? error.stack ?? error.message : String(error);
6010
+ return { head: "", fault: `git rev-parse HEAD threw cwd=${projectRoot}: ${message}` };
6011
+ }
6012
+ }
6013
+ function progressSessionAbsolute(runDirectory, context) {
6014
+ const host = typeof context.host === "string" ? context.host.trim() : "";
6015
+ const sessionDirectory = sessionDirectoryOf(runDirectory);
6016
+ if (host !== "" && host !== "pi" && host !== "hermes") {
6017
+ return resolveHostDossierLandingPath({ host, sessionDirectory });
6018
+ }
6019
+ const issued = context.sessionManager.getSessionFile?.();
6020
+ if (typeof issued === "string" && issued.trim() !== "") {
6021
+ return issued;
6022
+ }
6023
+ return sessionFileOf(runDirectory);
6024
+ }
6025
+ function lensFromRunDirectory(runDirectory, role) {
6026
+ if (role !== "reviewer") return void 0;
6027
+ const lens = readPageSync(runDirectory, "admitted")?.lens;
6028
+ return lens === "completeness" || lens === "correctness" ? lens : void 0;
6029
+ }
6030
+ function landTicketProgressForSealedSubmission(input) {
6031
+ const runDirectory = runDirectoryFromHostContext(input.context);
6032
+ if (runDirectory === void 0) return void 0;
6033
+ const subjectDirectory = subjectDirectoryOfRun(runDirectory);
6034
+ if (subjectDirectory === void 0) return void 0;
6035
+ const lens = input.lens === "completeness" || input.lens === "correctness" ? input.lens : lensFromRunDirectory(runDirectory, input.role);
6036
+ const leaf = basename7(runDirectory);
6037
+ const unbound = basename7(subjectDirectory) === "unbound";
6038
+ const progressPath = unbound ? join10(runDirectory, LEG_PROGRESS_FILENAME) : join10(subjectDirectory, CURRENT_FILENAME);
6039
+ const receiptIndex = nextLegReceiptIndex(runDirectory);
6040
+ const relativePath = `runs/${leaf}/${RECEIPTS_DIRNAME}/${receiptIndex}.json`;
6041
+ const absolutePath = join10(subjectDirectory, relativePath);
6042
+ mkdirSync3(dirname8(absolutePath), { recursive: true });
6043
+ writeFileSync2(absolutePath, `${JSON.stringify(input.accepted, null, 2)}
6044
+ `, "utf8");
6045
+ if (!unbound) {
6046
+ relocateTicketProgressForLeg({ runDirectory });
6047
+ }
6048
+ const existing = unbound ? readProgressFile(progressPath) : readTicketProgressLines(subjectDirectory);
6049
+ const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
6050
+ const sessionFile = progressSessionAbsolute(runDirectory, input.context);
6051
+ const sessionRelative = relative3(subjectDirectory, sessionFile).split(sep4).join("/");
6052
+ const { status, summary } = statusAndSummaryFromPayload(input.role, input.accepted);
6053
+ const instruction = typeof input.context.summonsInstruction === "string" ? input.context.summonsInstruction : "";
6054
+ const line2 = {
6055
+ at: (/* @__PURE__ */ new Date()).toISOString(),
6056
+ seat: input.role,
6057
+ round,
6058
+ instruction,
6059
+ head: input.sealHead.head,
6060
+ ...status === void 0 ? {} : { status },
6061
+ ...summary === void 0 ? {} : { summary },
6062
+ receipt: relativePath,
6063
+ session: sessionRelative
6064
+ };
6065
+ mkdirSync3(dirname8(progressPath), { recursive: true });
6066
+ appendFileSync2(progressPath, `${JSON.stringify(line2)}
6067
+ `, "utf8");
6068
+ if (input.sealHead.fault !== void 0) {
6069
+ process.stderr.write(`${input.sealHead.fault}
6070
+ `);
6071
+ }
6072
+ return line2;
6073
+ }
6074
+ function relocateTicketProgressForLeg(input) {
6075
+ if (isUnboundRunDirectory(input.runDirectory)) return;
6076
+ const subjectDirectory = subjectDirectoryOfRun(input.runDirectory);
6077
+ if (subjectDirectory === void 0) return;
6078
+ const stagedPath = join10(input.runDirectory, LEG_PROGRESS_FILENAME);
6079
+ const mine = readProgressFile(stagedPath);
6080
+ if (mine.length === 0) {
6081
+ if (existsSync3(stagedPath)) {
6082
+ rmSync3(stagedPath, { force: true });
6083
+ }
6084
+ return;
6085
+ }
6086
+ const ticketLines = [...readTicketProgressLines(subjectDirectory)];
6087
+ const publishedReceipts = new Set(
6088
+ ticketLines.map((line2) => line2.receipt).filter((receipt) => typeof receipt === "string" && receipt !== "")
6089
+ );
6090
+ const pending = mine.filter((line2) => !publishedReceipts.has(line2.receipt));
6091
+ if (pending.length === 0) {
6092
+ rmSync3(stagedPath, { force: true });
6093
+ return;
6094
+ }
6095
+ const movedLines = [];
6096
+ for (const line2 of pending) {
6097
+ const lens = lensFromRunDirectory(input.runDirectory, line2.seat);
6098
+ const round = nextRoundFromLines(ticketLines, line2.seat, lens);
6099
+ const moved = {
6100
+ ...line2,
6101
+ round
6102
+ };
6103
+ movedLines.push(moved);
6104
+ ticketLines.push(moved);
6105
+ }
6106
+ const newCurrent = join10(subjectDirectory, CURRENT_FILENAME);
6107
+ mkdirSync3(dirname8(newCurrent), { recursive: true });
6108
+ appendFileSync2(
6109
+ newCurrent,
6110
+ `${movedLines.map((line2) => JSON.stringify(line2)).join("\n")}
6111
+ `,
6112
+ "utf8"
6113
+ );
6114
+ rmSync3(stagedPath, { force: true });
6115
+ }
6116
+ var CURRENT_FILENAME, RECEIPTS_DIRNAME, LEG_PROGRESS_FILENAME;
6117
+ var init_ticket_progress = __esm({
6118
+ "src/ticket-progress.ts"() {
6119
+ "use strict";
6120
+ init_host_session_record();
6121
+ init_host_contracts();
6122
+ init_terminating_tools();
6123
+ init_packaged_role_registry();
6124
+ init_role_run_placement();
6125
+ init_run_dossier();
6126
+ init_sitian_reader();
6127
+ init_unknown_value();
6128
+ CURRENT_FILENAME = "current.jsonl";
6129
+ RECEIPTS_DIRNAME = "receipts";
6130
+ LEG_PROGRESS_FILENAME = "progress.jsonl";
6131
+ }
6132
+ });
6133
+
5881
6134
  // src/public-cli/github-remote.ts
5882
6135
  function ownerRepoFromGitHubRemoteUrl(remoteUrl) {
5883
6136
  const trimmed = remoteUrl.trim();
@@ -6143,13 +6396,13 @@ var init_session_dialogue = __esm({
6143
6396
 
6144
6397
  // src/ticket-provenance.ts
6145
6398
  import { readFile as readFile7 } from "node:fs/promises";
6146
- import { join as join10, resolve as resolve7 } from "node:path";
6399
+ import { join as join11, resolve as resolve7 } from "node:path";
6147
6400
  function dialogueSessionSourceRoots(home) {
6148
6401
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
6149
6402
  return [
6150
- join10(machineHome, ".claude", "projects"),
6151
- join10(machineHome, ".codex", "sessions"),
6152
- join10(machineHome, ".pi", "agent", "sessions")
6403
+ join11(machineHome, ".claude", "projects"),
6404
+ join11(machineHome, ".codex", "sessions"),
6405
+ join11(machineHome, ".pi", "agent", "sessions")
6153
6406
  ];
6154
6407
  }
6155
6408
  function isLedgerRoleSessionFile(absolute, home) {
@@ -6190,7 +6443,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
6190
6443
  const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
6191
6444
  let history;
6192
6445
  try {
6193
- history = await readFile7(join10(runDirectory, RUN_HISTORY_FILE), "utf8");
6446
+ history = await readFile7(join11(runDirectory, RUN_HISTORY_FILE), "utf8");
6194
6447
  } catch (error) {
6195
6448
  if (errnoCode(error) === "ENOENT") return;
6196
6449
  throw error;
@@ -6382,7 +6635,7 @@ var init_ticket_provenance = __esm({
6382
6635
  });
6383
6636
 
6384
6637
  // src/notary-source-run.ts
6385
- import { dirname as dirname8, isAbsolute as isAbsolute4, join as join11, resolve as resolve8, basename as basename7 } from "node:path";
6638
+ import { dirname as dirname9, isAbsolute as isAbsolute4, join as join12, resolve as resolve8, basename as basename8 } from "node:path";
6386
6639
  import { lstat, realpath as realpath2 } from "node:fs/promises";
6387
6640
  async function readRetainedIdentity(runDirectory) {
6388
6641
  try {
@@ -6418,10 +6671,10 @@ async function requireRunDirectory(candidate, display) {
6418
6671
  `notary --source-run must be a run directory: ${display}`
6419
6672
  );
6420
6673
  }
6421
- const identity = parseRunLeaf(basename7(real));
6674
+ const identity = parseRunLeaf(basename8(real));
6422
6675
  if (identity === void 0) {
6423
6676
  throw new NotarySourceRunError(
6424
- `notary --source-run must be named <runId>@<role>: ${basename7(real)}`
6677
+ `notary --source-run must be named <runId>@<role>: ${basename8(real)}`
6425
6678
  );
6426
6679
  }
6427
6680
  return real;
@@ -6434,26 +6687,26 @@ async function resolveNotarySourceRunLocator(options) {
6434
6687
  const ledgerHome = resolveActivationLedgerHome(options.home);
6435
6688
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
6436
6689
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
6437
- const bookRunsRoot = join11(bookDirectory, "runs");
6690
+ const bookRunsRoot = join12(bookDirectory, "runs");
6438
6691
  let candidate;
6439
6692
  const bare = parseRunLeaf(raw);
6440
6693
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
6441
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join11(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
6694
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join12(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
6442
6695
  } else {
6443
6696
  candidate = isAbsolute4(raw) ? raw : resolve8(options.projectRoot, raw);
6444
- const identity2 = parseRunLeaf(basename7(candidate));
6445
- const subjectDirectory = dirname8(dirname8(candidate));
6446
- const isLegacyUnboundLocator = identity2 !== void 0 && basename7(dirname8(candidate)) === "runs" && basename7(subjectDirectory) === "unbound" && resolve8(dirname8(subjectDirectory)) === resolve8(bookDirectory);
6697
+ const identity2 = parseRunLeaf(basename8(candidate));
6698
+ const subjectDirectory = dirname9(dirname9(candidate));
6699
+ const isLegacyUnboundLocator = identity2 !== void 0 && basename8(dirname9(candidate)) === "runs" && basename8(subjectDirectory) === "unbound" && resolve8(dirname9(subjectDirectory)) === resolve8(bookDirectory);
6447
6700
  if (isLegacyUnboundLocator) {
6448
6701
  candidate = await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey) ?? candidate;
6449
6702
  }
6450
6703
  }
6451
6704
  const real = await requireRunDirectory(candidate, raw);
6452
- const identity = parseRunLeaf(basename7(real));
6705
+ const identity = parseRunLeaf(basename8(real));
6453
6706
  const bookIdentity = physicalPathIdentity(bookDirectory);
6454
- const parentIdentity = physicalPathIdentity(dirname8(real));
6455
- const subjectBookIdentity = physicalPathIdentity(dirname8(dirname8(dirname8(real))));
6456
- if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename7(dirname8(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
6707
+ const parentIdentity = physicalPathIdentity(dirname9(real));
6708
+ const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
6709
+ if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename8(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
6457
6710
  throw new NotarySourceRunError(
6458
6711
  "notary --source-run must resolve to a retained run under the project machine-ledger book"
6459
6712
  );
@@ -6487,7 +6740,7 @@ async function resolveNotarySourceRunLocator(options) {
6487
6740
  }
6488
6741
  async function loadNotarySourceRunLocator(path) {
6489
6742
  const real = await requireRunDirectory(path, path);
6490
- const identity = parseRunLeaf(basename7(real));
6743
+ const identity = parseRunLeaf(basename8(real));
6491
6744
  const runState = await readRetainedIdentity(real);
6492
6745
  if (runState === void 0) {
6493
6746
  throw new NotarySourceRunError(
@@ -7153,8 +7406,8 @@ var init_option_definitions = __esm({
7153
7406
  repeatable: false,
7154
7407
  form: "option",
7155
7408
  description: {
7156
- en: "Required source run locator (runId@role under the book home, or path to that run directory). Zero prompt/attachment projection.",
7157
- zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\u7C3F\u5185 runId@role\uFF0C\u6216\u8BE5 run \u76EE\u5F55\u8DEF\u5F84\uFF09\u3002\u96F6 prompt/\u9644\u4EF6\u6295\u5F71\u3002"
7409
+ en: "Required source run locator (runId@role under the book home, or path to that run directory). Binds the audited identity; review dialogue is the fixed Notary dispatch (verdict stays in the ledger). Missing-ticket and unreadable-status reasks keep their existing diagnostic text.",
7410
+ zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\u7C3F\u5185 runId@role\uFF0C\u6216\u8BE5 run \u76EE\u5F55\u8DEF\u5F84\uFF09\u3002\u7ED1\u5B9A\u53D7\u5BA1\u8EAB\u4EFD\uFF1B\u5BA1\u7A3F\u5BF9\u8BDD\u4E3A\u7B26\u5B9D\u90CE\u56FA\u5B9A\u6D3E\u5355\u6587\uFF08\u5224\u8BCD\u7559\u5728\u5377\u5B97\u81EA\u884C\u8BFB\u53D6\uFF09\u3002\u7F3A\u7968\u53F7\u4E0E\u8BFB\u4E0D\u51FA status \u7684\u91CD\u4EA4\u4ECD\u9012\u65E2\u6709\u8BCA\u65AD\u539F\u6587\u3002"
7158
7411
  }
7159
7412
  }
7160
7413
  ];
@@ -7489,7 +7742,7 @@ var init_option_definitions = __esm({
7489
7742
  },
7490
7743
  notary: {
7491
7744
  command: "notary",
7492
- summary: "Direct Notary summons; duties: souls/notary.md. Zero prompt/attachment.",
7745
+ summary: "Direct Notary summons; duties: souls/notary.md. Review uses fixed dispatch \u2014 binds --source-run identity; does not accept caller review prompt; verdict stays in the ledger. Missing-ticket (#1171) and unreadable-status reasks deliver their existing diagnostic text on the same seat, not the review sentence.",
7493
7746
  usage: ["ak-role notary --source-run <runId@role|path> [options]"],
7494
7747
  examples: [
7495
7748
  "ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@judge",
@@ -7550,7 +7803,7 @@ var init_option_definitions = __esm({
7550
7803
  },
7551
7804
  resume: {
7552
7805
  command: "resume",
7553
- summary: "Resume a role run under the live seat table (model/host/engine); session principal must still exist. Every callable seat, including Notary/\u7B26\u5B9D\u90CE, accepts the optional caller message and passes it through unchanged as the continuation prompt. Notary explicit new still accepts only its source-run locator, not a caller prompt. Global --model/--thinking/--host/--engine must be placed before <runId> (either before `resume` or between `resume` and <runId>); the one argv after <runId> is the opaque message, not a flag position (#471).",
7806
+ summary: "Resume a role run under the live seat table (model/host/engine); session principal must still exist. Every callable seat accepts the optional caller message and passes it through unchanged as the continuation prompt. Notary new/direct review calls use only --source-run plus the fixed review dispatch (no caller review prompt); public manual resume still passes the caller message. Global --model/--thinking/--host/--engine must be placed before <runId> (either before `resume` or between `resume` and <runId>); the one argv after <runId> is the opaque message, not a flag position (#471).",
7554
7807
  usage: ["ak-role resume <runId> [message]"],
7555
7808
  examples: [
7556
7809
  "ak-role resume 01abc\u2026",
@@ -7581,14 +7834,14 @@ var init_option_definitions = __esm({
7581
7834
 
7582
7835
  // src/public-cli/invocation.ts
7583
7836
  import { execFileSync as execFileSync2 } from "node:child_process";
7584
- import { existsSync as existsSync3 } from "node:fs";
7837
+ import { existsSync as existsSync4 } from "node:fs";
7585
7838
  import {
7586
7839
  readFile as readFile8,
7587
7840
  realpath as realpath3,
7588
7841
  rename,
7589
7842
  writeFile as writeFile2
7590
7843
  } from "node:fs/promises";
7591
- import { dirname as dirname9, isAbsolute as isAbsolute5, join as join12, resolve as resolve9 } from "node:path";
7844
+ import { dirname as dirname10, isAbsolute as isAbsolute5, join as join13, resolve as resolve9 } from "node:path";
7592
7845
  function admittedSourceRunPath(admitted) {
7593
7846
  if (!isRecord(admitted)) return void 0;
7594
7847
  const path = admitted.sourceRunPath;
@@ -7747,35 +8000,36 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
7747
8000
  mutable.correlationId = correlationId;
7748
8001
  mutable.correlationIds = correlationIds;
7749
8002
  }
7750
- async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
7751
- if (admitted.ticketNumber === void 0 || !isUnboundRunDirectory(admitted.runDirectory)) return void 0;
7752
- const oldRunDirectory = admitted.runDirectory;
7753
- const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
7754
- const target = roleRunPlacement(ledgerHome, {
7755
- bookKey: admitted.bookKey,
7756
- subject: { ticketNumber: admitted.ticketNumber },
7757
- runId: admitted.runId,
7758
- role: admitted.role
7759
- });
7760
- ensureRoleRunDirectory(ledgerHome, dirname9(target.runDirectory));
7761
- const principal = authority.seal(target);
7762
- if (admitted.role !== "diarist") {
7763
- const childRunIds = readPageSync(oldRunDirectory, "admitted")?.childDiaristRunIds;
7764
- for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
7765
- if (typeof childRunId !== "string") continue;
7766
- const childDirectory = join12(dirname9(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
7767
- if (!existsSync3(childDirectory)) continue;
7768
- const childTarget = roleRunPlacement(ledgerHome, {
7769
- bookKey: admitted.bookKey,
7770
- subject: { ticketNumber: admitted.ticketNumber },
7771
- runId: childRunId,
7772
- role: "diarist"
8003
+ async function relocateRegisteredChildDiarists(input) {
8004
+ const childRunIds = readPageSync(input.parentRunDirectory, "admitted")?.childDiaristRunIds;
8005
+ for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
8006
+ if (typeof childRunId !== "string") continue;
8007
+ const childTarget = roleRunPlacement(input.ledgerHome, {
8008
+ bookKey: input.bookKey,
8009
+ subject: { ticketNumber: input.ticketNumber },
8010
+ runId: childRunId,
8011
+ role: "diarist"
8012
+ });
8013
+ const unboundChildDirectory = roleRunPlacement(input.ledgerHome, {
8014
+ bookKey: input.bookKey,
8015
+ subject: { unbound: true },
8016
+ runId: childRunId,
8017
+ role: "diarist"
8018
+ }).runDirectory;
8019
+ if (existsSync4(unboundChildDirectory)) {
8020
+ input.authority.seal(childTarget);
8021
+ await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
8022
+ await rehomeUnboundTicketProvenance(
8023
+ unboundChildDirectory,
8024
+ input.ticketNumber,
8025
+ input.projectRoot,
8026
+ homeFromRunDirectory(input.parentRunDirectory)
8027
+ );
8028
+ ensureRoleRunDirectory(input.ledgerHome, dirname10(childTarget.runDirectory));
8029
+ await rename(unboundChildDirectory, childTarget.runDirectory);
8030
+ relocateTicketProgressForLeg({
8031
+ runDirectory: childTarget.runDirectory
7773
8032
  });
7774
- authority.seal(childTarget);
7775
- await bindTicketNumberOnRunDirectory(childDirectory, admitted.ticketNumber);
7776
- await rehomeUnboundTicketProvenance(childDirectory, admitted.ticketNumber, admitted.projectRoot, homeFromRunDirectory(oldRunDirectory));
7777
- ensureRoleRunDirectory(ledgerHome, dirname9(childTarget.runDirectory));
7778
- await rename(childDirectory, childTarget.runDirectory);
7779
8033
  try {
7780
8034
  renderCurrentSync(childTarget.runDirectory);
7781
8035
  } catch (error) {
@@ -7784,18 +8038,71 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
7784
8038
  `
7785
8039
  );
7786
8040
  }
8041
+ continue;
7787
8042
  }
8043
+ if (existsSync4(childTarget.runDirectory)) {
8044
+ relocateTicketProgressForLeg({
8045
+ runDirectory: childTarget.runDirectory
8046
+ });
8047
+ }
8048
+ }
8049
+ }
8050
+ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
8051
+ if (admitted.ticketNumber === void 0) return void 0;
8052
+ const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(admitted.runDirectory));
8053
+ if (!isUnboundRunDirectory(admitted.runDirectory)) {
8054
+ relocateTicketProgressForLeg({
8055
+ runDirectory: admitted.runDirectory
8056
+ });
8057
+ if (admitted.role !== "diarist") {
8058
+ await relocateRegisteredChildDiarists({
8059
+ parentRunDirectory: admitted.runDirectory,
8060
+ bookKey: admitted.bookKey,
8061
+ ticketNumber: admitted.ticketNumber,
8062
+ projectRoot: admitted.projectRoot,
8063
+ ledgerHome,
8064
+ authority
8065
+ });
8066
+ }
8067
+ return void 0;
8068
+ }
8069
+ const oldRunDirectory = admitted.runDirectory;
8070
+ const target = roleRunPlacement(ledgerHome, {
8071
+ bookKey: admitted.bookKey,
8072
+ subject: { ticketNumber: admitted.ticketNumber },
8073
+ runId: admitted.runId,
8074
+ role: admitted.role
8075
+ });
8076
+ ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
8077
+ authority.seal(target);
8078
+ if (admitted.role !== "diarist") {
8079
+ await relocateRegisteredChildDiarists({
8080
+ parentRunDirectory: oldRunDirectory,
8081
+ bookKey: admitted.bookKey,
8082
+ ticketNumber: admitted.ticketNumber,
8083
+ projectRoot: admitted.projectRoot,
8084
+ ledgerHome,
8085
+ authority
8086
+ });
7788
8087
  }
7789
8088
  if (admitted.role === "diarist") {
7790
8089
  await rehomeUnboundTicketProvenance(oldRunDirectory, admitted.ticketNumber, admitted.projectRoot, homeFromRunDirectory(oldRunDirectory));
7791
8090
  }
7792
8091
  await rename(oldRunDirectory, target.runDirectory);
7793
8092
  heldLease?.relocate(target.runDirectory);
8093
+ const actualSessionDirectory = sessionDirectoryOf(target.runDirectory);
8094
+ const principal = authority.seal({
8095
+ sessionDirectory: actualSessionDirectory,
8096
+ sessionFile: sessionFileIn(actualSessionDirectory)
8097
+ });
7794
8098
  rewriteAdmittedRoleRunPage(
7795
8099
  admitted,
7796
8100
  [{ oldRunDirectory, newRunDirectory: target.runDirectory }]
7797
8101
  );
7798
8102
  admitted.principal = principal;
8103
+ relocateTicketProgressForLeg({
8104
+ runDirectory: target.runDirectory
8105
+ });
7799
8106
  renderCurrentSync(target.runDirectory);
7800
8107
  return { oldRunDirectory, newRunDirectory: target.runDirectory };
7801
8108
  }
@@ -7831,7 +8138,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
7831
8138
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
7832
8139
  const rolePackageRoot = packageRoot;
7833
8140
  const raw = JSON.parse(
7834
- await readFile8(join12(rolePackageRoot, "package.json"), "utf8")
8141
+ await readFile8(join13(rolePackageRoot, "package.json"), "utf8")
7835
8142
  );
7836
8143
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
7837
8144
  throw new Error(
@@ -8389,7 +8696,7 @@ async function admitPublicRole(role, parsed, env, override) {
8389
8696
  resolutionScope: [...derived.resolutionScope],
8390
8697
  authorizedChecks: []
8391
8698
  });
8392
- const mergerInputPath = join12(placed.runDirectory, "merger-input.json");
8699
+ const mergerInputPath = join13(placed.runDirectory, "merger-input.json");
8393
8700
  await writeFile2(
8394
8701
  mergerInputPath,
8395
8702
  `${JSON.stringify(mergerInput, null, 2)}
@@ -8536,9 +8843,6 @@ function appendCallerFileFlagPaths(body, attachments, requestManifestPath, prere
8536
8843
  }
8537
8844
  function buildInstructionTransportPrompt(admitted) {
8538
8845
  const kind = admittedTransportPromptKind(admitted);
8539
- if (kind === "fixed-kickoff") {
8540
- return "";
8541
- }
8542
8846
  if (kind === "baseline") {
8543
8847
  if (admitted.baseRevision === void 0) {
8544
8848
  throw new Error("baseline transport prompt is missing the bound revision");
@@ -8674,7 +8978,7 @@ function parseDoctorIssueNumber(raw) {
8674
8978
  }
8675
8979
  async function resolveDoctorCaseRunsPath(options) {
8676
8980
  const ledgerHome = resolveActivationLedgerHome(options.home);
8677
- const defaultRuns = join12(
8981
+ const defaultRuns = join13(
8678
8982
  activationBookDirectory(ledgerHome, options.bookKey),
8679
8983
  String(options.issueNumber),
8680
8984
  "runs"
@@ -8747,11 +9051,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
8747
9051
  `${flag} requires a comma-separated list of N or book:N`
8748
9052
  );
8749
9053
  }
8750
- const sep5 = trimmed.lastIndexOf(":");
8751
- if (sep5 > 0) {
8752
- const rhs = trimmed.slice(sep5 + 1);
9054
+ const sep6 = trimmed.lastIndexOf(":");
9055
+ if (sep6 > 0) {
9056
+ const rhs = trimmed.slice(sep6 + 1);
8753
9057
  if (parseTicketNumber(rhs) !== void 0) {
8754
- const bookKey = trimmed.slice(0, sep5);
9058
+ const bookKey = trimmed.slice(0, sep6);
8755
9059
  if (bookKey.trim() === "") {
8756
9060
  throw new CliUsageError(
8757
9061
  `${flag} book:N requires a non-empty book key, got ${raw}`
@@ -8948,6 +9252,7 @@ var init_invocation = __esm({
8948
9252
  init_activation_ledger_topology();
8949
9253
  init_activation_ledger_git();
8950
9254
  init_role_run_placement();
9255
+ init_ticket_progress();
8951
9256
  init_packaged_role_registry();
8952
9257
  init_run_ticket_number();
8953
9258
  init_role_run_relocation();
@@ -8970,7 +9275,7 @@ var init_invocation = __esm({
8970
9275
 
8971
9276
  // src/report-ticket-tool.ts
8972
9277
  import { Type as Type16 } from "typebox";
8973
- import { existsSync as existsSync4 } from "node:fs";
9278
+ import { existsSync as existsSync5 } from "node:fs";
8974
9279
  function pageString(page, key) {
8975
9280
  const value = page?.[key];
8976
9281
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
@@ -9012,7 +9317,7 @@ async function reportTicketFromHostContext(context, rawTicketNumber, authority =
9012
9317
  if (runDirectory === void 0) {
9013
9318
  throw new Error("ak_report_ticket requires a per-turn run directory");
9014
9319
  }
9015
- if (!existsSync4(runDirectory)) {
9320
+ if (!existsSync5(runDirectory)) {
9016
9321
  throw new Error(`ak_report_ticket run directory missing: ${runDirectory}`);
9017
9322
  }
9018
9323
  const admitted = admittedForLiveTicketReport(runDirectory, authority);
@@ -9031,7 +9336,11 @@ async function reportTicketFromHostContext(context, rawTicketNumber, authority =
9031
9336
  context.sessionManager.setSessionFile?.(projectedSessionFile);
9032
9337
  }
9033
9338
  };
9034
- const relocation = alreadyPlaced ? void 0 : await relocateAdmittedRunToTicket(admitted, authority, { relocate: applyLiveHandles });
9339
+ const relocation = await relocateAdmittedRunToTicket(
9340
+ admitted,
9341
+ authority,
9342
+ alreadyPlaced ? void 0 : { relocate: applyLiveHandles }
9343
+ );
9035
9344
  const nextDirectory = relocation?.newRunDirectory ?? admitted.runDirectory;
9036
9345
  if (relocation === void 0) applyLiveHandles(nextDirectory);
9037
9346
  return {
@@ -9288,6 +9597,7 @@ async function sealAcceptedSubmission(options) {
9288
9597
  const attemptId = attemptIdentity(options.context, runId);
9289
9598
  const sessionParent = sessionParentFromHostContext(options.context);
9290
9599
  const home = homeFromHostContext(options.context, options.home);
9600
+ const sealHead = captureWorktreeHead(options.context.cwd);
9291
9601
  sitianReport({
9292
9602
  level: "event",
9293
9603
  kind: "sealed",
@@ -9304,6 +9614,12 @@ async function sealAcceptedSubmission(options) {
9304
9614
  ...home !== void 0 ? { home } : {},
9305
9615
  ...sessionParent === void 0 ? {} : { sessionParent }
9306
9616
  });
9617
+ landTicketProgressForSealedSubmission({
9618
+ context: options.context,
9619
+ role: options.role,
9620
+ accepted: options.accepted,
9621
+ sealHead
9622
+ });
9307
9623
  }
9308
9624
  function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (error) => {
9309
9625
  throw error;
@@ -9428,6 +9744,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
9428
9744
  kind: "accepted",
9429
9745
  accepted: params
9430
9746
  };
9747
+ const sealHead = captureWorktreeHead(context.cwd);
9431
9748
  append({
9432
9749
  type: "sealed",
9433
9750
  attemptId,
@@ -9435,6 +9752,14 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
9435
9752
  role,
9436
9753
  accepted: params
9437
9754
  });
9755
+ const rawLens = typeof host.getFlag === "function" ? host.getFlag("ak-review-lens") : void 0;
9756
+ landTicketProgressForSealedSubmission({
9757
+ context,
9758
+ role,
9759
+ accepted: params,
9760
+ sealHead,
9761
+ ...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
9762
+ });
9438
9763
  await projectClosure(closed, context);
9439
9764
  return result;
9440
9765
  }
@@ -9456,6 +9781,7 @@ var init_submission_ledger = __esm({
9456
9781
  init_report_ticket_tool();
9457
9782
  init_review_submission();
9458
9783
  init_run_ticket_number();
9784
+ init_ticket_progress();
9459
9785
  init_unknown_value();
9460
9786
  }
9461
9787
  });
@@ -9642,7 +9968,7 @@ var init_engine_detour_usage = __esm({
9642
9968
  });
9643
9969
 
9644
9970
  // src/dossier-resolution.ts
9645
- import { existsSync as existsSync5, statSync as statSync4 } from "node:fs";
9971
+ import { existsSync as existsSync6, statSync as statSync4 } from "node:fs";
9646
9972
  import { resolve as resolve10 } from "node:path";
9647
9973
  function isHostContext(value) {
9648
9974
  return "sessionManager" in value;
@@ -9662,7 +9988,7 @@ function resolveAuditDossier(source) {
9662
9988
  }
9663
9989
  const runDirectory = resolve10(raw);
9664
9990
  try {
9665
- if (!existsSync5(runDirectory) || !statSync4(runDirectory).isDirectory()) {
9991
+ if (!existsSync6(runDirectory) || !statSync4(runDirectory).isDirectory()) {
9666
9992
  return { status: "incomplete", observation: { kind: "missing-dossier" } };
9667
9993
  }
9668
9994
  } catch {
@@ -10751,12 +11077,12 @@ var init_settlement = __esm({
10751
11077
  });
10752
11078
 
10753
11079
  // src/external-host-turn-loop.ts
10754
- import { existsSync as existsSync6 } from "node:fs";
10755
- import { basename as basename8 } from "node:path";
11080
+ import { existsSync as existsSync7 } from "node:fs";
11081
+ import { basename as basename9 } from "node:path";
10756
11082
  async function syncTurnRequestLivePlacement(request, authority) {
10757
11083
  const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
10758
11084
  if (live === void 0) {
10759
- const parsed = parseRunLeaf(basename8(request.runDirectory));
11085
+ const parsed = parseRunLeaf(basename9(request.runDirectory));
10760
11086
  throw new Error(
10761
11087
  `admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
10762
11088
  );
@@ -10775,7 +11101,7 @@ async function trySyncTurnRequestLivePlacement(request, authority) {
10775
11101
  }
10776
11102
  async function retainPackageFaultBesideLivePlacement(request, input) {
10777
11103
  let runDirectory = request.runDirectory;
10778
- if (!existsSync6(runDirectory)) {
11104
+ if (!existsSync7(runDirectory)) {
10779
11105
  try {
10780
11106
  const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
10781
11107
  if (found === void 0) {
@@ -10917,6 +11243,7 @@ async function driveExternalRoleTurnRounds(prepared, request, driver) {
10917
11243
  }
10918
11244
  }
10919
11245
  prompt = closure.retry.message;
11246
+ prepared.recordSentInstruction?.(prompt);
10920
11247
  driver.afterRetry?.();
10921
11248
  }
10922
11249
  }
@@ -10959,9 +11286,9 @@ var init_external_host_turn_loop = __esm({
10959
11286
  });
10960
11287
 
10961
11288
  // src/session-identity.ts
10962
- import { dirname as dirname10, join as join13 } from "node:path";
11289
+ import { join as join14 } from "node:path";
10963
11290
  function createSessionIdentityAuthority(authority, hostName) {
10964
- const runDirectoryOf = (principal) => dirname10(authority.decode(principal).sessionDirectory);
11291
+ const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
10965
11292
  return {
10966
11293
  principalAuthority: authority,
10967
11294
  resolveSessionFile(principal) {
@@ -10969,7 +11296,7 @@ function createSessionIdentityAuthority(authority, hostName) {
10969
11296
  },
10970
11297
  async load(principal) {
10971
11298
  const runDirectory = runDirectoryOf(principal);
10972
- const { records, diagnostics } = await readSitianRecords(join13(runDirectory, RUN_STATE_FILE));
11299
+ const { records, diagnostics } = await readSitianRecords(join14(runDirectory, RUN_STATE_FILE));
10973
11300
  if (diagnostics.length > 0) {
10974
11301
  throw new Error(
10975
11302
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -11016,6 +11343,7 @@ var init_session_identity = __esm({
11016
11343
  "src/session-identity.ts"() {
11017
11344
  "use strict";
11018
11345
  init_host_descriptions();
11346
+ init_role_run_placement();
11019
11347
  init_run_dossier();
11020
11348
  init_sitian_facade();
11021
11349
  init_unknown_value();
@@ -11038,14 +11366,14 @@ __export(role_turn_host_exports, {
11038
11366
  });
11039
11367
  import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
11040
11368
  import { constants } from "node:fs";
11041
- import { existsSync as existsSync7 } from "node:fs";
11369
+ import { existsSync as existsSync8 } from "node:fs";
11042
11370
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
11043
- import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join14, resolve as resolve11 } from "node:path";
11371
+ import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join15, resolve as resolve11 } from "node:path";
11044
11372
  import { platform } from "node:process";
11045
11373
  import { promisify as promisify2 } from "node:util";
11046
11374
  import { randomUUID as randomUUID4 } from "node:crypto";
11047
11375
  function resolveInternalRoleEntrypoint(packageRoot) {
11048
- return join14(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
11376
+ return join15(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
11049
11377
  }
11050
11378
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
11051
11379
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -11235,7 +11563,7 @@ function createDefaultPiSpawnRunner(options) {
11235
11563
  homeFromRunDirectory(spawnDir)
11236
11564
  );
11237
11565
  } catch (resolveError) {
11238
- runDirectory = existsSync7(spawnDir) ? spawnDir : void 0;
11566
+ runDirectory = existsSync8(spawnDir) ? spawnDir : void 0;
11239
11567
  const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
11240
11568
  if (runDirectory !== void 0) {
11241
11569
  await retainPackageFault({
@@ -11288,7 +11616,8 @@ function createPiRoleTurnHost(config) {
11288
11616
  config.extraPiArgs ?? []
11289
11617
  );
11290
11618
  const args = buildExplicitInternalActivationArgs(roleEntry, extraArgs);
11291
- const stdin = encodeUserDialogueStdin(piUserDialogueBody(turnRequest));
11619
+ const transportBody = piUserDialogueBody(turnRequest);
11620
+ const stdin = encodeUserDialogueStdin(transportBody);
11292
11621
  const env = {
11293
11622
  ...process.env,
11294
11623
  HOME: request.home,
@@ -11304,6 +11633,7 @@ function createPiRoleTurnHost(config) {
11304
11633
  else env.AK_ROLE_INVOCATION_SCOPE = request.invocationScopeId;
11305
11634
  if (request.host === void 0 || request.host.trim() === "") delete env.AK_ROLE_HOST;
11306
11635
  else env.AK_ROLE_HOST = request.host.trim();
11636
+ delete env.AK_ROLE_SUMMONS_INSTRUCTION;
11307
11637
  if (request.deliveryRequestLimit === void 0) delete env[RECEIPT_DELIVERY_LIMIT_ENV];
11308
11638
  else env[RECEIPT_DELIVERY_LIMIT_ENV] = String(request.deliveryRequestLimit);
11309
11639
  applyEngineChildEnv(env, request.engine);
@@ -11436,16 +11766,16 @@ var init_role_turn_host = __esm({
11436
11766
  });
11437
11767
 
11438
11768
  // src/public-cli/host-providers.ts
11439
- import { readFileSync as readFileSync3 } from "node:fs";
11440
- import { join as join15 } from "node:path";
11769
+ import { readFileSync as readFileSync4 } from "node:fs";
11770
+ import { join as join16 } from "node:path";
11441
11771
  function hostProvidersPath(home) {
11442
11772
  if (typeof home !== "string" || home.trim() === "") {
11443
11773
  throw new Error("home must be explicitly provided");
11444
11774
  }
11445
- return join15(home, ".ak-roles", "host-providers.json");
11775
+ return join16(home, ".ak-roles", "host-providers.json");
11446
11776
  }
11447
11777
  function hermesProviderModelsCachePath(home) {
11448
- return join15(home, ".hermes", "provider_models_cache.json");
11778
+ return join16(home, ".hermes", "provider_models_cache.json");
11449
11779
  }
11450
11780
  function parseHostProvidersTable(value) {
11451
11781
  if (!isRecord(value)) {
@@ -11482,7 +11812,7 @@ function parseHostProvidersTable(value) {
11482
11812
  function loadHostProvidersTable(home) {
11483
11813
  const path = hostProvidersPath(home);
11484
11814
  try {
11485
- const raw = readFileSync3(path, "utf8");
11815
+ const raw = readFileSync4(path, "utf8");
11486
11816
  return parseHostProvidersTable(JSON.parse(raw));
11487
11817
  } catch (error) {
11488
11818
  if (isEnoent(error)) return {};
@@ -11498,7 +11828,7 @@ function listHermesProvidersForModel(home, seatModel) {
11498
11828
  const path = hermesProviderModelsCachePath(home);
11499
11829
  let text;
11500
11830
  try {
11501
- text = readFileSync3(path, "utf8");
11831
+ text = readFileSync4(path, "utf8");
11502
11832
  } catch (error) {
11503
11833
  if (isEnoent(error)) return [];
11504
11834
  throw error;
@@ -11595,17 +11925,17 @@ var init_host_providers = __esm({
11595
11925
  });
11596
11926
 
11597
11927
  // src/public-cli/load-production-acp-host.ts
11598
- import { existsSync as existsSync8 } from "node:fs";
11599
- import { join as join16 } from "node:path";
11928
+ import { existsSync as existsSync9 } from "node:fs";
11929
+ import { join as join17 } from "node:path";
11600
11930
  import { pathToFileURL } from "node:url";
11601
11931
  async function loadProductionAcpHostFactory(packageRoot, host) {
11602
11932
  const description = lookupHostDescription(host);
11603
11933
  if (description === void 0) {
11604
11934
  throw new Error(`unregistered host: ${host}`);
11605
11935
  }
11606
- const built = join16(packageRoot, "dist/acp-host/production-host.js");
11607
- const source = join16(packageRoot, "src/acp-host/production-host.ts");
11608
- const target = existsSync8(built) ? built : source;
11936
+ const built = join17(packageRoot, "dist/acp-host/production-host.js");
11937
+ const source = join17(packageRoot, "src/acp-host/production-host.ts");
11938
+ const target = existsSync9(built) ? built : source;
11609
11939
  const href = pathToFileURL(target).href;
11610
11940
  const mod = await import(href);
11611
11941
  const create = mod.createProductionAcpRoleTurnHost;
@@ -11619,17 +11949,17 @@ var init_load_production_acp_host = __esm({
11619
11949
  });
11620
11950
 
11621
11951
  // src/public-cli/load-production-headless-host.ts
11622
- import { existsSync as existsSync9 } from "node:fs";
11623
- import { join as join17 } from "node:path";
11952
+ import { existsSync as existsSync10 } from "node:fs";
11953
+ import { join as join18 } from "node:path";
11624
11954
  import { pathToFileURL as pathToFileURL2 } from "node:url";
11625
11955
  async function loadProductionHeadlessHostFactory(packageRoot, host) {
11626
11956
  const description = lookupHeadlessHostDescription(host);
11627
11957
  if (description === void 0) {
11628
11958
  throw new Error(`unregistered headless host: ${host}`);
11629
11959
  }
11630
- const built = join17(packageRoot, "dist/headless-host/production-host.js");
11631
- const source = join17(packageRoot, "src/headless-host/production-host.ts");
11632
- const target = existsSync9(built) ? built : source;
11960
+ const built = join18(packageRoot, "dist/headless-host/production-host.js");
11961
+ const source = join18(packageRoot, "src/headless-host/production-host.ts");
11962
+ const target = existsSync10(built) ? built : source;
11633
11963
  const href = pathToFileURL2(target).href;
11634
11964
  const mod = await import(href);
11635
11965
  const create = mod.createProductionHeadlessRoleTurnHost;
@@ -11796,14 +12126,14 @@ var init_role_seat_runtime = __esm({
11796
12126
  });
11797
12127
 
11798
12128
  // src/session-opening-materials.ts
11799
- import { existsSync as existsSync10 } from "node:fs";
12129
+ import { existsSync as existsSync11 } from "node:fs";
11800
12130
  import { readFile as readFile9 } from "node:fs/promises";
11801
- import { dirname as dirname12, join as join18 } from "node:path";
12131
+ import { dirname as dirname12, join as join19 } from "node:path";
11802
12132
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
11803
12133
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
11804
12134
  let dir = dirname12(fileURLToPath(moduleUrl));
11805
12135
  for (let i = 0; i < 8; i += 1) {
11806
- if (existsSync10(join18(dir, "package.json")) && existsSync10(join18(dir, "souls"))) {
12136
+ if (existsSync11(join19(dir, "package.json")) && existsSync11(join19(dir, "souls"))) {
11807
12137
  return dir;
11808
12138
  }
11809
12139
  const parent = dirname12(dir);
@@ -12163,7 +12493,7 @@ __export(auditor_soul_exports, {
12163
12493
  readAuditorResumeBinding: () => readAuditorResumeBinding,
12164
12494
  resolveAuditorSubject: () => resolveAuditorSubject
12165
12495
  });
12166
- import { basename as basename9 } from "node:path";
12496
+ import { basename as basename10 } from "node:path";
12167
12497
  function auditorSoulRelativePath(role) {
12168
12498
  return `souls/${role}-auditor.md`;
12169
12499
  }
@@ -12199,7 +12529,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
12199
12529
  return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
12200
12530
  }
12201
12531
  function subjectFromSourceDirectory(sourceRunDirectory) {
12202
- const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
12532
+ const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
12203
12533
  return isAuditorSoulRole(role) ? role : void 0;
12204
12534
  }
12205
12535
  async function readAuditorResumeBinding(admitted) {
@@ -12242,16 +12572,16 @@ var init_auditor_soul = __esm({
12242
12572
  // src/public-cli/machine-method-skills.ts
12243
12573
  import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
12244
12574
  import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
12245
- import { join as join20 } from "node:path";
12246
- import { spawnSync as spawnSync2 } from "node:child_process";
12575
+ import { join as join21 } from "node:path";
12576
+ import { spawnSync as spawnSync3 } from "node:child_process";
12247
12577
  function skillRoot(home) {
12248
- return join20(home, ".agents/skills");
12578
+ return join21(home, ".agents/skills");
12249
12579
  }
12250
12580
  function installedMethodSkillPath(home, name) {
12251
12581
  return installedSkillPath(skillRoot(home), name);
12252
12582
  }
12253
12583
  function installedSkillPath(root, name) {
12254
- const path = join20(root, name, "SKILL.md");
12584
+ const path = join21(root, name, "SKILL.md");
12255
12585
  try {
12256
12586
  if (!statSync5(path).isFile()) return void 0;
12257
12587
  accessSync(path, constants2.R_OK);
@@ -12264,9 +12594,9 @@ function installedSkillPath(root, name) {
12264
12594
  }
12265
12595
  function linkedSkillRoot(home, host) {
12266
12596
  if (host === "claude" || host === "claude-code") {
12267
- return join20(process.env.CLAUDE_CONFIG_DIR?.trim() || join20(home, ".claude"), "skills");
12597
+ return join21(process.env.CLAUDE_CONFIG_DIR?.trim() || join21(home, ".claude"), "skills");
12268
12598
  }
12269
- if (host === "hermes") return join20(home, ".hermes/skills");
12599
+ if (host === "hermes") return join21(home, ".hermes/skills");
12270
12600
  return void 0;
12271
12601
  }
12272
12602
  async function occupied(path) {
@@ -12294,7 +12624,7 @@ async function warnMissingMethodSkills(home, host, role, skills, stdout) {
12294
12624
  }
12295
12625
  }
12296
12626
  function runSkillsCli(args, home) {
12297
- const result = spawnSync2("npx", ["--yes", "skills", ...args], {
12627
+ const result = spawnSync3("npx", ["--yes", "skills", ...args], {
12298
12628
  stdio: "inherit",
12299
12629
  env: { ...process.env, HOME: home }
12300
12630
  });
@@ -12323,7 +12653,7 @@ async function runMachineSkillSetup(home, stdout) {
12323
12653
  const missingBySource = /* @__PURE__ */ new Map();
12324
12654
  let unsourced = false;
12325
12655
  for (const name of packagedMethodSkillNames()) {
12326
- const path = join20(canonical, name);
12656
+ const path = join21(canonical, name);
12327
12657
  if (await occupied(path)) {
12328
12658
  warnOccupied(path, stdout);
12329
12659
  continue;
@@ -12353,9 +12683,9 @@ async function runMachineSkillSetup(home, stdout) {
12353
12683
  throw error;
12354
12684
  }
12355
12685
  for (const name of packagedMethodSkillNames()) {
12356
- const target = join20(canonical, name);
12686
+ const target = join21(canonical, name);
12357
12687
  if (installedMethodSkillPath(home, name) === void 0) continue;
12358
- const link = join20(root, name);
12688
+ const link = join21(root, name);
12359
12689
  if (await occupied(link)) {
12360
12690
  warnOccupied(link, stdout);
12361
12691
  continue;
@@ -12415,7 +12745,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
12415
12745
  ...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
12416
12746
  ...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
12417
12747
  ...options.navigatorByStatusPrepare === void 0 ? {} : { navigatorByStatusPrepare: options.navigatorByStatusPrepare },
12418
- ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
12748
+ ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit },
12749
+ ...options.host === void 0 || options.host.trim() === "" ? {} : { host: options.host.trim() }
12419
12750
  };
12420
12751
  }
12421
12752
  function packagedSettleSkill(admitted) {
@@ -13055,10 +13386,7 @@ function buildReceiptDeliveryRequest(input) {
13055
13386
  ...request,
13056
13387
  continuation: {
13057
13388
  kind: "resume",
13058
- prompt: JSON.stringify({
13059
- ...receiptDelivery.deliveryState(),
13060
- deliveryTurns: receiptDelivery.issuedDeliveryRequests() + 1
13061
- })
13389
+ prompt: request.continuation.prompt
13062
13390
  },
13063
13391
  deliveryRequestLimit: receiptDelivery.limit
13064
13392
  };
@@ -13821,7 +14149,7 @@ async function runPostAdmissionSeatResume(input) {
13821
14149
  ...firstTurn,
13822
14150
  continuation: {
13823
14151
  kind: "resume",
13824
- prompt: RESUME_TRANSPORT_ENVELOPE
14152
+ prompt: firstTurn.continuation.prompt
13825
14153
  }
13826
14154
  };
13827
14155
  }
@@ -13940,7 +14268,7 @@ async function runPostAdmissionOneShot(input) {
13940
14268
  ...input.request,
13941
14269
  continuation: {
13942
14270
  kind: "resume",
13943
- prompt: buildAutoResumeContinuationPrompt()
14271
+ prompt: input.request.continuation.prompt
13944
14272
  }
13945
14273
  }),
13946
14274
  adapters: input.adapters,
@@ -14161,6 +14489,7 @@ __export(instruction_seat_run_exports, {
14161
14489
  NOTARY_FIXED_DISPATCH: () => NOTARY_FIXED_DISPATCH,
14162
14490
  buildInstructionSeatTurnRequest: () => buildInstructionSeatTurnRequest,
14163
14491
  continueParentAfterChild: () => continueParentAfterChild,
14492
+ resolveReviewSeatDialogueBody: () => resolveReviewSeatDialogueBody,
14164
14493
  runPublicInstructionSeat: () => runPublicInstructionSeat,
14165
14494
  runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
14166
14495
  });
@@ -14231,7 +14560,8 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io,
14231
14560
  {
14232
14561
  runId: admitted.runId,
14233
14562
  runDirectory: admitted.runDirectory,
14234
- summons: { instruction: message }
14563
+ message,
14564
+ summons: { instructionEmpty: true }
14235
14565
  },
14236
14566
  next,
14237
14567
  io
@@ -14258,7 +14588,8 @@ async function reaskMissingTicketOnce(admitted, terminal, env, io) {
14258
14588
  {
14259
14589
  runId: admitted.runId,
14260
14590
  runDirectory: admitted.runDirectory,
14261
- summons: { instruction }
14591
+ message: instruction,
14592
+ summons: { instructionEmpty: true }
14262
14593
  },
14263
14594
  softReaskEnv,
14264
14595
  io
@@ -14371,26 +14702,26 @@ async function loadLedgerPeerBody(sourceRunDirectory, projectRoot, home) {
14371
14702
  return readableGateItem(latest.accepted);
14372
14703
  }
14373
14704
  async function resolveReviewSeatDialogueBody(input) {
14374
- const reask = input.reask;
14375
- if (reask !== void 0 && reask.length > 0) return reask;
14705
+ if (input.role === "notary") {
14706
+ if (input.reviewReask !== void 0) return input.reviewReask;
14707
+ return NOTARY_FIXED_DISPATCH;
14708
+ }
14709
+ const preferred = input.reviewReask ?? input.gateReviewInstruction;
14710
+ if (preferred !== void 0 && preferred.length > 0) return preferred;
14376
14711
  const caller = input.callerInstruction ?? "";
14377
14712
  if (caller.length > 0) return caller;
14378
14713
  const sourceRunPath = admittedSourceRunPath(input)?.trim();
14379
14714
  if (sourceRunPath === void 0) return void 0;
14380
- if (input.role === "notary") {
14381
- const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
14382
- if (isTicketCourtCountersignSource2(sourceRunPath)) return NOTARY_FIXED_DISPATCH;
14383
- }
14384
14715
  return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
14385
14716
  }
14386
- async function resolveInitialPrompt(admitted, env) {
14717
+ async function resolveInitialTurnPrompt(admitted, env) {
14387
14718
  const record = roleRecord(admitted.role);
14388
14719
  if ("reaskPrompt" in record && record.reaskPrompt === true) {
14389
14720
  const sourceRunPath = admittedSourceRunPath(admitted);
14390
- const reask = env.reviewReask ?? env.gateReviewInstruction;
14391
14721
  const body = await resolveReviewSeatDialogueBody({
14392
14722
  role: admitted.role,
14393
- ...reask === void 0 ? {} : { reask },
14723
+ ...env.reviewReask === void 0 ? {} : { reviewReask: env.reviewReask },
14724
+ ...env.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: env.gateReviewInstruction },
14394
14725
  callerInstruction: admitted.instruction,
14395
14726
  ...sourceRunPath === void 0 ? {} : { sourceRunPath },
14396
14727
  projectRoot: admitted.projectRoot,
@@ -14480,7 +14811,7 @@ async function dispatchAdmitted(admitted, env, io) {
14480
14811
  if (activeEnv.correlationId !== void 0 && activeEnv.correlationId.trim() !== "") {
14481
14812
  await recordAdmittedCorrelation(admitted, activeEnv.correlationId);
14482
14813
  }
14483
- const initialPromptText = await resolveInitialPrompt(admitted, activeEnv);
14814
+ const initialPrompt = await resolveInitialTurnPrompt(admitted, activeEnv);
14484
14815
  const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
14485
14816
  if (auto) {
14486
14817
  return await runPostAdmissionResumable({
@@ -14491,14 +14822,14 @@ async function dispatchAdmitted(admitted, env, io) {
14491
14822
  admitted,
14492
14823
  roleTurnOptions(activeEnv, admitted, {
14493
14824
  kind: "initial",
14494
- prompt: initialPromptText
14825
+ prompt: initialPrompt
14495
14826
  })
14496
14827
  ),
14497
14828
  buildResumeRequest: () => buildInstructionSeatTurnRequest(
14498
14829
  admitted,
14499
14830
  roleTurnOptions(activeEnv, admitted, {
14500
14831
  kind: "resume",
14501
- prompt: buildAutoResumeContinuationPrompt()
14832
+ prompt: initialPrompt
14502
14833
  })
14503
14834
  ),
14504
14835
  adapters,
@@ -14513,7 +14844,7 @@ async function dispatchAdmitted(admitted, env, io) {
14513
14844
  admitted,
14514
14845
  roleTurnOptions(activeEnv, admitted, {
14515
14846
  kind: "initial",
14516
- prompt: initialPromptText
14847
+ prompt: initialPrompt
14517
14848
  })
14518
14849
  ),
14519
14850
  adapters,
@@ -14598,22 +14929,26 @@ function resumeSameParentInstructionSeat(input) {
14598
14929
  ...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
14599
14930
  freshSummons: input.env.freshSummons,
14600
14931
  summons: input.summons,
14601
- resume: (runId, materials, runDirectory) => runPublicInstructionSeatResume(
14602
- {
14603
- runId,
14604
- runDirectory,
14605
- ...materials === void 0 ? {} : { summons: materials }
14606
- },
14607
- input.env,
14608
- input.io
14609
- )
14932
+ resume: (runId, materials, runDirectory) => {
14933
+ const reask = input.env.reviewReask;
14934
+ return runPublicInstructionSeatResume(
14935
+ {
14936
+ runId,
14937
+ runDirectory,
14938
+ ...reask === void 0 ? {} : { message: reask },
14939
+ ...materials === void 0 ? {} : { summons: materials }
14940
+ },
14941
+ input.env,
14942
+ input.io
14943
+ );
14944
+ }
14610
14945
  });
14611
14946
  }
14612
14947
  async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, role) {
14613
- const reask = env.reviewReask ?? env.gateReviewInstruction;
14614
14948
  const body = await resolveReviewSeatDialogueBody({
14615
14949
  role,
14616
- ...reask === void 0 ? {} : { reask },
14950
+ ...env.reviewReask === void 0 ? {} : { reviewReask: env.reviewReask },
14951
+ ...env.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: env.gateReviewInstruction },
14617
14952
  callerInstruction: fallback.instruction,
14618
14953
  sourceRunPath,
14619
14954
  projectRoot,
@@ -14625,20 +14960,30 @@ async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, rol
14625
14960
  return fallback;
14626
14961
  }
14627
14962
  async function runCountersignBody(parsed, env, io) {
14963
+ const projectRoot = resolve12(parsed.project ?? env.cwd);
14628
14964
  const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
14629
14965
  if (gateParentRunPath !== void 0) {
14630
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction ?? "";
14966
+ const dialogue = await sameParentDialogue(
14967
+ env,
14968
+ {
14969
+ instruction: parsed.instruction ?? "",
14970
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14971
+ },
14972
+ gateParentRunPath,
14973
+ projectRoot,
14974
+ "countersign"
14975
+ );
14631
14976
  const resumed = await resumeSameParentInstructionSeat({
14632
14977
  env,
14633
14978
  io,
14634
- projectRoot: resolve12(parsed.project ?? env.cwd),
14979
+ projectRoot,
14635
14980
  role: "countersign",
14636
14981
  parentRunPath: gateParentRunPath,
14637
14982
  ...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
14638
14983
  summons: {
14639
14984
  sourceRunPath: gateParentRunPath,
14640
- instruction: resumeInstruction,
14641
- instructionEmpty: resumeInstruction.length === 0,
14985
+ instruction: dialogue.instruction,
14986
+ instructionEmpty: dialogue.instructionEmpty,
14642
14987
  // #1166 J11: same-parent resume delivers this call's file-flag paths
14643
14988
  // through the shared summons → appendCallerFileFlagPaths rule.
14644
14989
  attachmentPaths: parsed.attachmentPaths ?? []
@@ -14673,10 +15018,9 @@ async function runCountersignBody(parsed, env, io) {
14673
15018
  await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
14674
15019
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
14675
15020
  }
14676
- const reviewBody = env.reviewReask ?? env.gateReviewInstruction;
14677
15021
  const turnProjection = roleTurnOptions(env, admitted, {
14678
15022
  kind: "initial",
14679
- prompt: reviewBody !== void 0 ? appendCallerFileFlagPaths(reviewBody, admitted.attachments) : buildInstructionTransportPrompt(admitted)
15023
+ prompt: await resolveInitialTurnPrompt(admitted, env)
14680
15024
  });
14681
15025
  const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
14682
15026
  const result = await runPostAdmissionOneShot({
@@ -14887,6 +15231,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14887
15231
  await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
14888
15232
  admitted = { ...admitted, sourceRunPath: auditorSource };
14889
15233
  }
15234
+ admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
14890
15235
  const runAdmitted = async () => {
14891
15236
  await markRunAdmitted(admitted, env.principalAuthority);
14892
15237
  if (role === "secretariat") {
@@ -14949,6 +15294,16 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14949
15294
  }
14950
15295
  return runAdmitted();
14951
15296
  }
15297
+ async function inheritKnownTicketFromSource(admitted, authority) {
15298
+ if (admitted.ticketNumber !== void 0) return admitted;
15299
+ const sourcePath = admittedSourceRunPath(admitted);
15300
+ if (sourcePath === void 0) return admitted;
15301
+ const sourceTicket = await readBoardTicketNumber(sourcePath);
15302
+ if (sourceTicket === void 0) return admitted;
15303
+ await bindAdmittedTicketNumber(admitted, sourceTicket);
15304
+ await relocateAdmittedRunToTicket(admitted, authority);
15305
+ return admitted;
15306
+ }
14952
15307
  async function runPublicInstructionSeatResume(request, env, io) {
14953
15308
  let selectedRequest = request;
14954
15309
  const resume = async () => {
@@ -14968,26 +15323,45 @@ async function runPublicInstructionSeatResume(request, env, io) {
14968
15323
  env.principalAuthority,
14969
15324
  effective.runDirectory === void 0 ? void 0 : { runDirectory: effective.runDirectory }
14970
15325
  );
14971
- if (packagedRebindSourceOnResume(loaded.admitted.role) && effective.summons?.sourceRunPath !== void 0 && effective.summons.sourceRun !== void 0) {
14972
- return {
14973
- ...loaded,
14974
- admitted: {
14975
- ...loaded.admitted,
14976
- sourceRunPath: effective.summons.sourceRunPath,
14977
- sourceRun: effective.summons.sourceRun
14978
- }
15326
+ let admitted = loaded.admitted;
15327
+ if (packagedRebindSourceOnResume(admitted.role) && effective.summons?.sourceRunPath !== void 0 && effective.summons.sourceRun !== void 0) {
15328
+ admitted = {
15329
+ ...admitted,
15330
+ sourceRunPath: effective.summons.sourceRunPath,
15331
+ sourceRun: effective.summons.sourceRun
14979
15332
  };
14980
15333
  }
14981
- return loaded;
15334
+ admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
15335
+ return { ...loaded, admitted };
14982
15336
  },
14983
15337
  buildTurnRequest: async (admitted, effective) => {
14984
15338
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
14985
- return buildInstructionSeatTurnRequest(
15339
+ const projection = resumeTurnRequestProjectionOptions(
14986
15340
  admitted,
14987
- {
14988
- ...resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared)
14989
- }
15341
+ effective,
15342
+ env,
15343
+ summonsPrepared
14990
15344
  );
15345
+ if (effective.summons === void 0 || effective.message !== void 0) {
15346
+ return buildInstructionSeatTurnRequest(admitted, { ...projection });
15347
+ }
15348
+ const sourceRunPath = admittedSourceRunPath(admitted);
15349
+ const body = await resolveReviewSeatDialogueBody({
15350
+ role: admitted.role,
15351
+ callerInstruction: summonsPrepared?.instruction ?? "",
15352
+ ...sourceRunPath === void 0 ? {} : { sourceRunPath },
15353
+ projectRoot: admitted.projectRoot,
15354
+ home: env.home
15355
+ });
15356
+ if (body === void 0) {
15357
+ return buildInstructionSeatTurnRequest(admitted, { ...projection });
15358
+ }
15359
+ const fileFlags = summonsPrepared?.attachments ?? [];
15360
+ const prompt = fileFlags.length === 0 ? body : appendCallerFileFlagPaths(body, fileFlags);
15361
+ return buildInstructionSeatTurnRequest(admitted, {
15362
+ ...projection,
15363
+ continuation: { kind: "resume", prompt }
15364
+ });
14991
15365
  },
14992
15366
  adapters: {
14993
15367
  trySettle: async () => void 0
@@ -15182,7 +15556,8 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
15182
15556
  return runPublicInstructionSeatResume({
15183
15557
  runId: admitted.runId,
15184
15558
  runDirectory: admitted.runDirectory,
15185
- summons: { instruction: SECRETARIAT_STATUS_REASK }
15559
+ message: SECRETARIAT_STATUS_REASK,
15560
+ summons: { instructionEmpty: true }
15186
15561
  }, next, io);
15187
15562
  }
15188
15563
  if (admitted.role === "countersign" && (typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status))) {
@@ -15196,7 +15571,8 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
15196
15571
  return runPublicInstructionSeatResume({
15197
15572
  runId: admitted.runId,
15198
15573
  runDirectory: admitted.runDirectory,
15199
- summons: { instruction: officerConclusionReask(status) }
15574
+ message: officerConclusionReask(status),
15575
+ summons: { instructionEmpty: true }
15200
15576
  }, next, io);
15201
15577
  }
15202
15578
  const selfEscalationSkipsAudit = status === "escalate" && (admitted.role === "judge" || admitted.role === "secretariat" || admitted.role === "countersign");
@@ -15451,6 +15827,20 @@ var init_instruction_seat_run = __esm({
15451
15827
  judge: {
15452
15828
  statuses: REVIEW_QUEUE_STATUSES
15453
15829
  },
15830
+ // #1208 C1 / ADR 0055: every review-queue seat uses the shared
15831
+ // unreadable-status seam (officerConclusionReask). Independent public
15832
+ // entry for notary/auditor/inspector was the same miss — route here, do
15833
+ // not invent a parallel loop. Gate summons still own the outer budget
15834
+ // via nestedIncomplete when this seat exhausts unsettled.
15835
+ notary: {
15836
+ statuses: REVIEW_QUEUE_STATUSES
15837
+ },
15838
+ auditor: {
15839
+ statuses: REVIEW_QUEUE_STATUSES
15840
+ },
15841
+ inspector: {
15842
+ statuses: REVIEW_QUEUE_STATUSES
15843
+ },
15454
15844
  coder: {
15455
15845
  statuses: WORKER_ROUTING_STATUSES,
15456
15846
  reask: WORKER_STATUS_REASK
@@ -15513,10 +15903,10 @@ var init_analyst_book_key = __esm({
15513
15903
  // src/atomic-write.ts
15514
15904
  import { randomUUID as randomUUID6 } from "node:crypto";
15515
15905
  import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
15516
- import { dirname as dirname14, join as join21 } from "node:path";
15906
+ import { dirname as dirname14, join as join22 } from "node:path";
15517
15907
  async function writeFileAtomically(destination, contents, options) {
15518
15908
  const parent = dirname14(destination);
15519
- const temporary = join21(parent, `.atomic-write-${randomUUID6()}.tmp`);
15909
+ const temporary = join22(parent, `.atomic-write-${randomUUID6()}.tmp`);
15520
15910
  try {
15521
15911
  await writeFile3(temporary, contents, options);
15522
15912
  await rename2(temporary, destination);
@@ -15533,12 +15923,12 @@ var init_atomic_write = __esm({
15533
15923
 
15534
15924
  // src/analyst-index.ts
15535
15925
  import { open, readFile as readFile10, unlink } from "node:fs/promises";
15536
- import { dirname as dirname15, join as join22 } from "node:path";
15926
+ import { dirname as dirname15, join as join23 } from "node:path";
15537
15927
  import { setTimeout as sleep } from "node:timers/promises";
15538
15928
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
15539
15929
  const indexPath = analystLibraryIndexPath(ledgerHome);
15540
15930
  ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
15541
- const lockPath = join22(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
15931
+ const lockPath = join23(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
15542
15932
  assertLedgerFileInsideHome(lockPath, ledgerHome);
15543
15933
  const startedAt = Date.now();
15544
15934
  while (true) {
@@ -15565,7 +15955,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
15565
15955
  }
15566
15956
  }
15567
15957
  function analystLibraryIndexPath(ledgerHome) {
15568
- return join22(ledgerHome, "analyst", "library-index.json");
15958
+ return join23(ledgerHome, "analyst", "library-index.json");
15569
15959
  }
15570
15960
  function rowFromIssueMetricsPage(page) {
15571
15961
  return {
@@ -15859,7 +16249,7 @@ var init_analyst_cohort = __esm({
15859
16249
  });
15860
16250
 
15861
16251
  // src/archivist-record-pointer.ts
15862
- import { basename as basename10, join as join23 } from "node:path";
16252
+ import { basename as basename11, join as join24 } from "node:path";
15863
16253
  async function resolveOfficerPointer(raw, parentRunDirectory) {
15864
16254
  const where = `${parentRunDirectory} officers`;
15865
16255
  if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
@@ -15872,7 +16262,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
15872
16262
  let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
15873
16263
  let sessionFile = raw.sessionFile;
15874
16264
  const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
15875
- const leaf = parseRunLeaf(basename10(recordedRunDirectory));
16265
+ const leaf = parseRunLeaf(basename11(recordedRunDirectory));
15876
16266
  const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
15877
16267
  if (leaf !== void 0 && parentIdentity !== void 0) {
15878
16268
  const currentRunDirectory = await resolveLiveRunDirectoryPath(
@@ -15892,7 +16282,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
15892
16282
  };
15893
16283
  }
15894
16284
  async function readBookedOfficerPointers(parentRunDirectory) {
15895
- const { records, diagnostics } = await readSitianRecords(join23(parentRunDirectory, RUN_HISTORY_FILE));
16285
+ const { records, diagnostics } = await readSitianRecords(join24(parentRunDirectory, RUN_HISTORY_FILE));
15896
16286
  if (diagnostics.length > 0) {
15897
16287
  throw new Error(
15898
16288
  `${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
@@ -16175,7 +16565,7 @@ var init_analyst_gate_cycles_read = __esm({
16175
16565
 
16176
16566
  // src/analyst-ledger.ts
16177
16567
  import { readdir as readdir3 } from "node:fs/promises";
16178
- import { basename as basename11, join as join24 } from "node:path";
16568
+ import { basename as basename12, join as join25 } from "node:path";
16179
16569
  async function readExistingRunLifecycleState(runDirectory) {
16180
16570
  return (await readRoleRunIdentity(runDirectory))?.state;
16181
16571
  }
@@ -16195,7 +16585,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
16195
16585
  }
16196
16586
  }
16197
16587
  async function classifyGhostCandidate(input) {
16198
- const autopsy = await autopsyWriterLock(join24(input.runDirectory, "writer.lock"));
16588
+ const autopsy = await autopsyWriterLock(join25(input.runDirectory, "writer.lock"));
16199
16589
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
16200
16590
  if (leaseCheck === void 0) return { kind: "live" };
16201
16591
  return {
@@ -16485,7 +16875,7 @@ async function classifyScopedRun(input) {
16485
16875
  async function scanAnalystIssueRuns(input) {
16486
16876
  const ledgerHome = resolveActivationLedgerHome(input.home);
16487
16877
  const scopeTicketNumber = input.ticketNumber;
16488
- const booksRoot = join24(ledgerHome, "books");
16878
+ const booksRoot = join25(ledgerHome, "books");
16489
16879
  let wholeBook = false;
16490
16880
  let scopeRootIdentity;
16491
16881
  let bookNames;
@@ -16518,7 +16908,7 @@ async function scanAnalystIssueRuns(input) {
16518
16908
  const ghostLegs = [];
16519
16909
  const scopeConflicts = [];
16520
16910
  for (const book of bookNames) {
16521
- const bookDir = join24(booksRoot, book);
16911
+ const bookDir = join25(booksRoot, book);
16522
16912
  let runDirectories;
16523
16913
  try {
16524
16914
  runDirectories = await listBookRunDirectories(bookDir);
@@ -16527,7 +16917,7 @@ async function scanAnalystIssueRuns(input) {
16527
16917
  throw error;
16528
16918
  }
16529
16919
  for (const runDirectory of runDirectories) {
16530
- const runName = basename11(runDirectory);
16920
+ const runName = basename12(runDirectory);
16531
16921
  const parsed = parseRunLeaf(runName);
16532
16922
  if (parsed === void 0) continue;
16533
16923
  let scopeFields;
@@ -17264,7 +17654,7 @@ var init_analyst_metric_family = __esm({
17264
17654
  });
17265
17655
 
17266
17656
  // src/analyst-page.ts
17267
- import { dirname as dirname16, join as join25 } from "node:path";
17657
+ import { dirname as dirname16, join as join26 } from "node:path";
17268
17658
  function analystIssuePageKey(address) {
17269
17659
  const parts = ["book", address.bookKey];
17270
17660
  if (address.issueNumber !== void 0) {
@@ -17275,7 +17665,7 @@ function analystIssuePageKey(address) {
17275
17665
  return sha256Hex(parts.join("\0")).slice(0, 32);
17276
17666
  }
17277
17667
  function analystIssuePagePath(ledgerHome, address) {
17278
- return join25(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
17668
+ return join26(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
17279
17669
  }
17280
17670
  function analystIssuePageAddressFromPage(page) {
17281
17671
  return {
@@ -18831,9 +19221,9 @@ __export(public_role_summons_exports, {
18831
19221
  summonPublicRole: () => summonPublicRole
18832
19222
  });
18833
19223
  import { execFile as execFile3 } from "node:child_process";
18834
- import { existsSync as existsSync11 } from "node:fs";
19224
+ import { existsSync as existsSync12 } from "node:fs";
18835
19225
  import { realpath as realpath6 } from "node:fs/promises";
18836
- import { join as join26 } from "node:path";
19226
+ import { join as join27 } from "node:path";
18837
19227
  import { promisify as promisify3 } from "node:util";
18838
19228
  function createCapturingIo() {
18839
19229
  const chunks = [];
@@ -18857,7 +19247,7 @@ function parentDir(path) {
18857
19247
  function walkPackageRoot(start) {
18858
19248
  let dir = start;
18859
19249
  for (let i = 0; i < 12; i += 1) {
18860
- if (existsSync11(join26(dir, "package.json")) && existsSync11(join26(dir, "souls"))) {
19250
+ if (existsSync12(join27(dir, "package.json")) && existsSync12(join27(dir, "souls"))) {
18861
19251
  return dir;
18862
19252
  }
18863
19253
  const parent = parentDir(dir);
@@ -19179,13 +19569,9 @@ async function summonGateOfficer(options) {
19179
19569
  home = homeFromRunDirectory2(options.sourceRunDirectory);
19180
19570
  }
19181
19571
  let gateReviewInstruction;
19182
- if (options.reask === void 0 && options.submission !== void 0) {
19183
- const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
19184
- const blindTicketCourt = options.officer === "notary" && isTicketCourtCountersignSource2(options.sourceRunDirectory);
19185
- if (!blindTicketCourt) {
19186
- const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
19187
- gateReviewInstruction = readableGateItem2(options.submission);
19188
- }
19572
+ if (options.reask === void 0 && options.submission !== void 0 && options.officer !== "notary") {
19573
+ const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
19574
+ gateReviewInstruction = readableGateItem2(options.submission);
19189
19575
  }
19190
19576
  const { runIdFromRunDirectory: runIdFromRunDirectory2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
19191
19577
  const parentRunId = runIdFromRunDirectory2(options.sourceRunDirectory);
@@ -19236,7 +19622,14 @@ async function summonGateOfficer(options) {
19236
19622
  const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
19237
19623
  const submittedTicket = isRecord(options.submission) ? options.submission.ticketNumber : void 0;
19238
19624
  const courtTicket = isSafePositiveTicketNumber3(submittedTicket) ? submittedTicket : parentTicket;
19239
- const instruction = options.reask ?? gateReviewInstruction ?? "";
19625
+ const { resolveReviewSeatDialogueBody: resolveReviewSeatDialogueBody2 } = await Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports));
19626
+ const instruction = await resolveReviewSeatDialogueBody2({
19627
+ role: options.officer,
19628
+ ...options.reask === void 0 ? {} : { reviewReask: options.reask },
19629
+ ...gateReviewInstruction === void 0 ? {} : { gateReviewInstruction },
19630
+ projectRoot: options.cwd,
19631
+ home
19632
+ }) ?? "";
19240
19633
  return summonPublicRole({
19241
19634
  role: options.officer,
19242
19635
  argv: ["--project", options.cwd, "--", instruction],
@@ -19402,7 +19795,7 @@ var init_compliance_transport = __esm({
19402
19795
  });
19403
19796
 
19404
19797
  // src/role-run-relocation.ts
19405
- import { dirname as dirname17, join as join27 } from "node:path";
19798
+ import { dirname as dirname17, join as join28 } from "node:path";
19406
19799
  async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirectory) {
19407
19800
  if (recordedPath === currentPath) return true;
19408
19801
  if (typeof recordedPath !== "string") return false;
@@ -19447,11 +19840,9 @@ var init_role_run_relocation = __esm({
19447
19840
  var run_lifecycle_exports = {};
19448
19841
  __export(run_lifecycle_exports, {
19449
19842
  AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
19450
- RESUME_TRANSPORT_ENVELOPE: () => RESUME_TRANSPORT_ENVELOPE,
19451
19843
  RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
19452
19844
  acquireRunWriterLease: () => acquireRunWriterLease,
19453
19845
  autopsyWriterLock: () => autopsyWriterLock,
19454
- buildAutoResumeContinuationPrompt: () => buildAutoResumeContinuationPrompt,
19455
19846
  clearCurrentCourt: () => clearCurrentCourt,
19456
19847
  describeErrorIdentity: () => describeErrorIdentity,
19457
19848
  findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
@@ -19470,12 +19861,9 @@ __export(run_lifecycle_exports, {
19470
19861
  resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
19471
19862
  writeRoleRunState: () => writeRoleRunState
19472
19863
  });
19473
- import { existsSync as existsSync12 } from "node:fs";
19864
+ import { existsSync as existsSync13 } from "node:fs";
19474
19865
  import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
19475
- import { basename as basename12, join as join28 } from "node:path";
19476
- function buildAutoResumeContinuationPrompt() {
19477
- return RESUME_TRANSPORT_ENVELOPE;
19478
- }
19866
+ import { basename as basename13, join as join29 } from "node:path";
19479
19867
  async function writeRoleRunState(runDirectory, record) {
19480
19868
  const payload = { ...record, runDirectory };
19481
19869
  writeSectionSync(runDirectory, "runState", { ...payload });
@@ -19557,13 +19945,14 @@ async function readRoleRunStateDisk(runDirectory) {
19557
19945
  if (typeof record.sessionDirectory !== "string") throw new TypeError("Invalid state.jsonl run-state");
19558
19946
  const storedRunDirectory = typeof record.runDirectory === "string" && record.runDirectory.trim() !== "" ? record.runDirectory : runDirectory;
19559
19947
  const runDir = runDirectory;
19948
+ const principalCoords = {
19949
+ sessionDirectory: record.sessionDirectory,
19950
+ ...typeof record.sessionFile === "string" ? { sessionFile: record.sessionFile } : {}
19951
+ };
19952
+ rewritePrincipalSessionPaths(principalCoords, storedRunDirectory, runDirectory);
19560
19953
  const principalWire = {
19561
- sessionDirectory: rewriteRunDirectoryPathValue(
19562
- record.sessionDirectory,
19563
- storedRunDirectory,
19564
- runDirectory
19565
- ),
19566
- ...typeof record.sessionFile === "string" ? { sessionFile: rewriteRunDirectoryPathValue(record.sessionFile, storedRunDirectory, runDirectory) } : {}
19954
+ sessionDirectory: principalCoords.sessionDirectory,
19955
+ ...typeof principalCoords.sessionFile === "string" ? { sessionFile: principalCoords.sessionFile } : {}
19567
19956
  };
19568
19957
  const phase = record.phase === "plan" || record.phase === "apply" ? record.phase : void 0;
19569
19958
  const currentCourt = parseCurrentCourtState(record.currentCourt);
@@ -19769,7 +20158,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
19769
20158
  },
19770
20159
  relocate(nextRunDirectory) {
19771
20160
  currentRunDirectory = nextRunDirectory;
19772
- currentLockPath = join28(nextRunDirectory, WRITER_LOCK_FILE);
20161
+ currentLockPath = join29(nextRunDirectory, WRITER_LOCK_FILE);
19773
20162
  },
19774
20163
  async release() {
19775
20164
  if (released) return;
@@ -19808,10 +20197,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19808
20197
  };
19809
20198
  const reportReadFailure = (error) => {
19810
20199
  reportDiagnostic(
19811
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join28(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
20200
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join29(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
19812
20201
  );
19813
20202
  };
19814
- const lockPath = join28(runDirectory, WRITER_LOCK_FILE);
20203
+ const lockPath = join29(runDirectory, WRITER_LOCK_FILE);
19815
20204
  let lastAutopsy = { verdict: "absent" };
19816
20205
  let lastReclaimFailure;
19817
20206
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -19867,7 +20256,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19867
20256
  }
19868
20257
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
19869
20258
  if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
19870
- const parsed = parseRunLeaf(basename12(knownRunDirectory));
20259
+ const parsed = parseRunLeaf(basename13(knownRunDirectory));
19871
20260
  if (parsed === void 0 || parsed.runId !== runId) {
19872
20261
  throw new CliUsageError(
19873
20262
  `run directory does not match run id ${runId}: ${knownRunDirectory}`
@@ -19877,7 +20266,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
19877
20266
  }
19878
20267
  if (runId.trim() === "") return void 0;
19879
20268
  const ledgerHome = resolveActivationLedgerHome(home);
19880
- const booksRoot = join28(ledgerHome, "books");
20269
+ const booksRoot = join29(ledgerHome, "books");
19881
20270
  let bookKeys;
19882
20271
  try {
19883
20272
  bookKeys = await readdir4(booksRoot);
@@ -19892,8 +20281,8 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
19892
20281
  );
19893
20282
  }
19894
20283
  async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
19895
- if (existsSync12(recordedPath)) return recordedPath;
19896
- const parsed = parseRunLeaf(basename12(recordedPath));
20284
+ if (existsSync13(recordedPath)) return recordedPath;
20285
+ const parsed = parseRunLeaf(basename13(recordedPath));
19897
20286
  const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
19898
20287
  if (parsed === void 0 || bookKey === void 0) return void 0;
19899
20288
  return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
@@ -19927,7 +20316,7 @@ async function findLatestRunForSeatTicket(input) {
19927
20316
  let runDirectories;
19928
20317
  try {
19929
20318
  runDirectories = await listBookRunDirectories(
19930
- input.ticketNumber === void 0 ? bookDir : join28(bookDir, String(input.ticketNumber))
20319
+ input.ticketNumber === void 0 ? bookDir : join29(bookDir, String(input.ticketNumber))
19931
20320
  );
19932
20321
  } catch (error) {
19933
20322
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -19935,7 +20324,7 @@ async function findLatestRunForSeatTicket(input) {
19935
20324
  }
19936
20325
  let best;
19937
20326
  for (const runDirectory of runDirectories) {
19938
- const parsed = parseRunLeaf(basename12(runDirectory));
20327
+ const parsed = parseRunLeaf(basename13(runDirectory));
19939
20328
  if (parsed === void 0 || parsed.role !== input.role) continue;
19940
20329
  const runId = parsed.runId;
19941
20330
  const parentPath = await readRunParentPath(runDirectory);
@@ -20406,7 +20795,7 @@ function resumedWorkerPhase(phase, phases, role, runId) {
20406
20795
  }
20407
20796
  throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
20408
20797
  }
20409
- var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
20798
+ var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
20410
20799
  var init_run_lifecycle = __esm({
20411
20800
  "src/public-cli/run-lifecycle.ts"() {
20412
20801
  "use strict";
@@ -20421,7 +20810,6 @@ var init_run_lifecycle = __esm({
20421
20810
  init_run_dossier();
20422
20811
  init_unknown_value();
20423
20812
  AUTO_RESUME_LIMIT = 2;
20424
- RESUME_TRANSPORT_ENVELOPE = "\u7EE7\u7EED\u3002";
20425
20813
  WRITER_LOCK_FILE = "writer.lock";
20426
20814
  RunWriterLeaseHeldError = class extends Error {
20427
20815
  code = "AK_RUN_WRITER_LEASE_HELD";
@@ -20459,7 +20847,7 @@ import "typebox";
20459
20847
 
20460
20848
  // src/navigator-public-session.ts
20461
20849
  init_host_session_record();
20462
- import { basename as basename13 } from "node:path";
20850
+ import { basename as basename14 } from "node:path";
20463
20851
 
20464
20852
  // src/navigator-session-contracts.ts
20465
20853
  init_unknown_value();
@@ -20663,7 +21051,7 @@ async function resolveNavigatorLedgerHome(context) {
20663
21051
  return void 0;
20664
21052
  }
20665
21053
  function runIdFromNavigatorDirectory(runDirectory) {
20666
- const parsed = parseRunLeaf(basename13(runDirectory));
21054
+ const parsed = parseRunLeaf(basename14(runDirectory));
20667
21055
  if (parsed === void 0 || parsed.role !== "navigator") return void 0;
20668
21056
  return parsed.runId;
20669
21057
  }
@@ -21067,7 +21455,7 @@ function createNavigatorAttendance(options) {
21067
21455
  await promptAllowingRejectedPrepare(request);
21068
21456
  while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
21069
21457
  delivery.recordDeliveryRequest();
21070
- await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()));
21458
+ await promptAllowingRejectedPrepare(request);
21071
21459
  }
21072
21460
  if (output === void 0 && delivery.nextAction() === "request-delivery") {
21073
21461
  delivery.closeBudget();
@@ -21307,7 +21695,7 @@ init_filed_submission();
21307
21695
  init_report_ticket_tool();
21308
21696
  import { randomUUID as randomUUID7 } from "node:crypto";
21309
21697
  import { writeSync as writeSync2 } from "node:fs";
21310
- import { join as join30 } from "node:path";
21698
+ import { join as join31 } from "node:path";
21311
21699
  import { Value as Value3 } from "typebox/value";
21312
21700
 
21313
21701
  // src/activation-trace.ts
@@ -21357,7 +21745,7 @@ import {
21357
21745
  lstatSync as lstatSync2,
21358
21746
  realpathSync as realpathSync2,
21359
21747
  statSync as statSync7,
21360
- writeFileSync as writeFileSync2
21748
+ writeFileSync as writeFileSync3
21361
21749
  } from "node:fs";
21362
21750
  import { isAbsolute as isAbsolute10, resolve as resolve16 } from "node:path";
21363
21751
  var ActivationSessionFileMissingError = class extends Error {
@@ -21378,7 +21766,7 @@ function materializeDeferredSessionFile(sessionManager, resolvedFile) {
21378
21766
  throw new ActivationSessionFileMissingError(resolvedFile);
21379
21767
  }
21380
21768
  try {
21381
- writeFileSync2(resolvedFile, `${JSON.stringify(header)}
21769
+ writeFileSync3(resolvedFile, `${JSON.stringify(header)}
21382
21770
  `, { flag: "wx" });
21383
21771
  } catch (error) {
21384
21772
  if (errnoCode(error) !== "EEXIST") {
@@ -21814,10 +22202,10 @@ init_run_ticket_number();
21814
22202
 
21815
22203
  // src/audited-run-identity.ts
21816
22204
  init_role_run_placement();
21817
- import { basename as basename14 } from "node:path";
22205
+ import { basename as basename15 } from "node:path";
21818
22206
  var AUDITED_RUN_IDENTITY_KIND = "audited-run-identity";
21819
22207
  function auditedRunIdentityFromDirectory(runDirectory) {
21820
- const parsed = parseRunLeaf(basename14(runDirectory));
22208
+ const parsed = parseRunLeaf(basename15(runDirectory));
21821
22209
  if (parsed === void 0) return void 0;
21822
22210
  return formatRunLeaf(parsed.runId, parsed.role);
21823
22211
  }
@@ -22041,7 +22429,7 @@ init_unknown_value();
22041
22429
  init_submission_errors();
22042
22430
  init_worker_submission_contracts();
22043
22431
  import { execFileSync as execFileSync3 } from "node:child_process";
22044
- import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync4, rmdirSync, rmSync as rmSync3 } from "node:fs";
22432
+ import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync4 } from "node:fs";
22045
22433
  import { resolve as resolve17 } from "node:path";
22046
22434
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
22047
22435
  var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
@@ -22071,7 +22459,7 @@ function statusOf(error) {
22071
22459
  return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
22072
22460
  }
22073
22461
  function tryGetAll(file, key) {
22074
- if (!existsSync13(file)) return [];
22462
+ if (!existsSync14(file)) return [];
22075
22463
  try {
22076
22464
  const out = gitFile(file, ["--get-all", key]);
22077
22465
  return out.length === 0 ? [] : out.split("\n");
@@ -22081,8 +22469,8 @@ function tryGetAll(file, key) {
22081
22469
  }
22082
22470
  }
22083
22471
  function ownedHook(path) {
22084
- if (!existsSync13(path)) return false;
22085
- return readFileSync4(path, "utf8").includes(HOOK_MARKER);
22472
+ if (!existsSync14(path)) return false;
22473
+ return readFileSync5(path, "utf8").includes(HOOK_MARKER);
22086
22474
  }
22087
22475
  function escapeGitConfigValueRegex(value) {
22088
22476
  return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
@@ -22107,13 +22495,13 @@ function unsetOwnedHooksPath(file) {
22107
22495
  function rmOwnedDir(dir) {
22108
22496
  const hookPath = resolve17(dir, HOOK_FILE);
22109
22497
  if (!ownedHook(hookPath)) return;
22110
- rmSync3(hookPath, { force: true });
22111
- if (existsSync13(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
22498
+ rmSync4(hookPath, { force: true });
22499
+ if (existsSync14(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
22112
22500
  }
22113
22501
  function linkedGitDirs(commonDir) {
22114
22502
  const root = resolve17(commonDir, "worktrees");
22115
- if (!existsSync13(root)) return [];
22116
- return readdirSync3(root).map((name) => resolve17(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22503
+ if (!existsSync14(root)) return [];
22504
+ return readdirSync4(root).map((name) => resolve17(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22117
22505
  }
22118
22506
  function uninstallPackageWorkerHooks(cwd) {
22119
22507
  let inside;
@@ -22131,7 +22519,7 @@ function uninstallPackageWorkerHooks(cwd) {
22131
22519
  clear(resolve17(commonDir, "config.worktree"));
22132
22520
  rmOwnedDir(resolve17(commonDir, HOOKS_DIR));
22133
22521
  const legacy = resolve17(commonDir, "hooks", HOOK_FILE);
22134
- if (ownedHook(legacy)) rmSync3(legacy, { force: true });
22522
+ if (ownedHook(legacy)) rmSync4(legacy, { force: true });
22135
22523
  for (const gitDir of linkedGitDirs(commonDir)) {
22136
22524
  clear(resolve17(gitDir, "config.worktree"));
22137
22525
  rmOwnedDir(resolve17(gitDir, HOOKS_DIR));
@@ -22209,11 +22597,11 @@ function reliableWindow(cwd, baseline, head) {
22209
22597
  const raw = git2(cwd, ["log", "--format=%P%x1e%s", range]);
22210
22598
  if (raw.length === 0) return [];
22211
22599
  return raw.split("\n").flatMap((line2) => {
22212
- const sep5 = line2.indexOf("");
22213
- if (sep5 < 0) return [];
22600
+ const sep6 = line2.indexOf("");
22601
+ if (sep6 < 0) return [];
22214
22602
  return [{
22215
- subject: line2.slice(sep5 + 1),
22216
- merge: line2.slice(0, sep5).trim().includes(" ")
22603
+ subject: line2.slice(sep6 + 1),
22604
+ merge: line2.slice(0, sep6).trim().includes(" ")
22217
22605
  }];
22218
22606
  });
22219
22607
  }
@@ -22951,7 +23339,7 @@ function readRoleRunCoordinates(ctx, label) {
22951
23339
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
22952
23340
  const admitted = readPageSync(runDirectory, "admitted");
22953
23341
  if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
22954
- throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join30(runDirectory, RUN_STATE_FILE)})`);
23342
+ throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join31(runDirectory, RUN_STATE_FILE)})`);
22955
23343
  }
22956
23344
  return {
22957
23345
  runDirectory,
@@ -23139,6 +23527,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23139
23527
  let engineDetourRegistered = false;
23140
23528
  let receiptDelivery = createReceiptDeliveryPolicy(deliveryLimit);
23141
23529
  let noReceiptRecorded = false;
23530
+ let turnDialoguePrompt;
23142
23531
  const disposeNavigatorAttendanceNonBlocking = (attendance) => {
23143
23532
  if (attendance === void 0) return;
23144
23533
  const recordDisposeFailure = (error) => {
@@ -23216,7 +23605,10 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23216
23605
  settleNavigatorProjection
23217
23606
  );
23218
23607
  };
23219
- roleHost.on("input", (_event) => {
23608
+ roleHost.on("input", (event, ctx) => {
23609
+ if (typeof event.text === "string" && ctx.summonsInstruction === void 0) {
23610
+ ctx.summonsInstruction = event.text;
23611
+ }
23220
23612
  const role = roleHost.getFlag(ROLE_FLAG.name);
23221
23613
  if (role !== void 0 && !admitted) return { action: "handled" };
23222
23614
  return { action: "continue" };
@@ -23225,6 +23617,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23225
23617
  roleHost.on("before_agent_start", async (event, ctx) => {
23226
23618
  const role = roleHost.getFlag(ROLE_FLAG.name);
23227
23619
  const prompt = event.prompt;
23620
+ if (typeof prompt === "string") turnDialoguePrompt = prompt;
23228
23621
  if (role === void 0) return;
23229
23622
  if (!admitted || selectedRole !== role) {
23230
23623
  failInfrastructure(new ActivationBarrierError(role), ctx);
@@ -23370,6 +23763,8 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23370
23763
  }
23371
23764
  if (receiptDelivery.nextAction() === "request-delivery") {
23372
23765
  receiptDelivery.recordDeliveryRequest();
23766
+ const deliveryContent = turnDialoguePrompt ?? "";
23767
+ ctx.summonsInstruction = deliveryContent;
23373
23768
  const scopeId = ctx.invocationScopeId?.trim() ?? "";
23374
23769
  envelopeHost.appendEntry(
23375
23770
  RECEIPT_DELIVERY_REQUEST_ENTRY,
@@ -23385,7 +23780,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23385
23780
  });
23386
23781
  envelopeHost.sendMessage({
23387
23782
  customType: "ak-receipt-delivery-prompt",
23388
- content: JSON.stringify(receiptDelivery.deliveryState()),
23783
+ content: deliveryContent,
23389
23784
  display: false
23390
23785
  }, { triggerTurn: true, deliverAs: "followUp" });
23391
23786
  } else if (receiptDelivery.nextAction() === "no-receipt" && !noReceiptRecorded) {
@@ -23625,6 +24020,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23625
24020
  activeCollector = void 0;
23626
24021
  receiptDelivery = createReceiptDeliveryPolicy(deliveryLimit);
23627
24022
  noReceiptRecorded = false;
24023
+ turnDialoguePrompt = void 0;
23628
24024
  pendingNavigatorPresentation = void 0;
23629
24025
  navigatorActivation += 1;
23630
24026
  navigatorDeliveryClosed = false;
@@ -24367,6 +24763,7 @@ async function prepareRoleEnvelope(options) {
24367
24763
  const record = value;
24368
24764
  if (record.action === "transform" && typeof record.text === "string") prompt = record.text;
24369
24765
  }
24766
+ context.summonsInstruction = prompt;
24370
24767
  if (typeof prompt === "string" && prompt.trim() !== "") {
24371
24768
  sessionEntries.push({
24372
24769
  type: "message",
@@ -24408,6 +24805,9 @@ async function prepareRoleEnvelope(options) {
24408
24805
  }],
24409
24806
  systemPrompt: { body: systemPromptBody, materials: readingMaterials },
24410
24807
  prompt,
24808
+ recordSentInstruction(text) {
24809
+ context.summonsInstruction = text;
24810
+ },
24411
24811
  abortSignal: hostAbort.signal,
24412
24812
  closeRound,
24413
24813
  dispose,
@@ -24437,12 +24837,12 @@ init_role_run_placement();
24437
24837
  init_external_host_turn_loop();
24438
24838
  init_run_lifecycle();
24439
24839
  init_settlement();
24440
- import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
24840
+ import { spawn as spawn3, spawnSync as spawnSync4 } from "node:child_process";
24441
24841
  import { randomUUID as randomUUID10 } from "node:crypto";
24442
- import { existsSync as existsSync14 } from "node:fs";
24842
+ import { existsSync as existsSync15 } from "node:fs";
24443
24843
  import { mkdtemp, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
24444
24844
  import { tmpdir } from "node:os";
24445
- import { dirname as dirname20, isAbsolute as isAbsolute11, join as join31, resolve as resolve18 } from "node:path";
24845
+ import { dirname as dirname20, isAbsolute as isAbsolute11, join as join32, resolve as resolve18 } from "node:path";
24446
24846
 
24447
24847
  // src/agent-start-materials.ts
24448
24848
  function renderAgentStartMaterials(body, materials) {
@@ -24829,7 +25229,7 @@ function formatCodexFailurePayload(payload) {
24829
25229
  function cwdIsGitWorkTree(cwd) {
24830
25230
  let dir = cwd;
24831
25231
  for (; ; ) {
24832
- if (existsSync14(join31(dir, ".git"))) return true;
25232
+ if (existsSync15(join32(dir, ".git"))) return true;
24833
25233
  const parent = dirname20(dir);
24834
25234
  if (parent === dir) return false;
24835
25235
  dir = parent;
@@ -24839,7 +25239,7 @@ function resolveGitCommonDir(cwd) {
24839
25239
  if (!cwdIsGitWorkTree(cwd)) return void 0;
24840
25240
  let result;
24841
25241
  try {
24842
- result = spawnSync3("git", ["rev-parse", "--git-common-dir"], {
25242
+ result = spawnSync4("git", ["rev-parse", "--git-common-dir"], {
24843
25243
  cwd,
24844
25244
  encoding: "utf8"
24845
25245
  });
@@ -25048,8 +25448,8 @@ function createHeadlessRoleTurnHost(config) {
25048
25448
  }
25049
25449
  const env = { ...process.env, ...config.env ?? {} };
25050
25450
  const liveSessionParent = () => config.sessionIdentity.resolveSessionFile(request.principal);
25051
- const inputsDirectory = await mkdtemp(join31(tmpdir(), "ak-role-headless-"));
25052
- const systemPromptPath = join31(inputsDirectory, "system-prompt.txt");
25451
+ const inputsDirectory = await mkdtemp(join32(tmpdir(), "ak-role-headless-"));
25452
+ const systemPromptPath = join32(inputsDirectory, "system-prompt.txt");
25053
25453
  let mcpConfigPath;
25054
25454
  let outputSchemaPath;
25055
25455
  let startedWithSchema;
@@ -25058,13 +25458,13 @@ function createHeadlessRoleTurnHost(config) {
25058
25458
  let deliveredSchema;
25059
25459
  if (codex) {
25060
25460
  if (!navigatorProseExit) {
25061
- outputSchemaPath = join31(inputsDirectory, "output-schema.json");
25461
+ outputSchemaPath = join32(inputsDirectory, "output-schema.json");
25062
25462
  deliveredSchema = closeJsonSchemaForCodex(prepared.jsonSchema);
25063
25463
  await writeFile6(outputSchemaPath, `${JSON.stringify(deliveredSchema, null, 2)}
25064
25464
  `, "utf8");
25065
25465
  }
25066
25466
  } else {
25067
- mcpConfigPath = join31(inputsDirectory, "mcp-config.json");
25467
+ mcpConfigPath = join32(inputsDirectory, "mcp-config.json");
25068
25468
  await writeFile6(
25069
25469
  mcpConfigPath,
25070
25470
  `${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}