@akagilnc/pi-workflow-roles 0.1.3565 → 0.1.3572

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 (35) hide show
  1. package/README.md +4 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/acp-host/production-host.js +755 -60
  4. package/dist/diarist-contracts.js +72 -0
  5. package/dist/package-contracts/terminating-tools.js +20 -2
  6. package/dist/packaged-role-registry.js +20 -0
  7. package/dist/public-cli/main.js +533 -634
  8. package/dist/public-cli/registry.js +4 -1
  9. package/extensions/role-runtime.ts +1 -0
  10. package/package.json +1 -1
  11. package/resources/diarist-collect.md +6 -10
  12. package/souls/diarist.md +9 -0
  13. package/src/acp-host/production-host.ts +1 -0
  14. package/src/acp-host/role-envelope.ts +2 -1
  15. package/src/diarist-contracts.ts +88 -0
  16. package/src/diarist-role.ts +60 -0
  17. package/src/diarist.ts +253 -179
  18. package/src/host-contracts.ts +6 -1
  19. package/src/package-contracts/terminating-tools.ts +22 -2
  20. package/src/packaged-role-registry.ts +20 -0
  21. package/src/pi/role-turn-host.ts +8 -0
  22. package/src/public-cli/cli.ts +29 -0
  23. package/src/public-cli/countersign-run.ts +9 -129
  24. package/src/public-cli/diarist-run.ts +312 -0
  25. package/src/public-cli/invocation.ts +23 -2
  26. package/src/public-cli/option-definitions.ts +18 -0
  27. package/src/public-cli/post-admission.ts +2 -2
  28. package/src/public-cli/registry.ts +3 -0
  29. package/src/public-cli/run-lifecycle.ts +31 -3
  30. package/src/public-cli/settlement.ts +50 -2
  31. package/src/public-cli/terminal.ts +2 -1
  32. package/src/role-runtime.ts +117 -6
  33. package/src/ticket-provenance-contracts.ts +1 -0
  34. package/src/ticket-provenance.ts +0 -23
  35. package/src/diarist-llm-collector.ts +0 -324
@@ -15023,6 +15023,45 @@ var init_inspector_contracts = __esm({
15023
15023
  }
15024
15024
  });
15025
15025
 
15026
+ // src/diarist-contracts.ts
15027
+ function validateRecordedDiaristOutput(value) {
15028
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
15029
+ throw new Error("Diarist output has no execution discriminator");
15030
+ }
15031
+ let status;
15032
+ try {
15033
+ status = value.status;
15034
+ } catch {
15035
+ throw new Error("Diarist output has no execution discriminator");
15036
+ }
15037
+ if (status === "completed") {
15038
+ return value;
15039
+ }
15040
+ throw new Error("Diarist output has no execution discriminator");
15041
+ }
15042
+ function diaristDecisiveFacts(output) {
15043
+ const facts = { status: output.status };
15044
+ const selections = output.selections;
15045
+ if (Array.isArray(selections)) facts.selections = selections;
15046
+ const sitian = output.sitian;
15047
+ if (sitian !== void 0) facts.sitian = sitian;
15048
+ return facts;
15049
+ }
15050
+ var DIARIST_OUTPUT_TOOL_NAME, DIARIST_SOURCES_FLAG;
15051
+ var init_diarist_contracts = __esm({
15052
+ "src/diarist-contracts.ts"() {
15053
+ "use strict";
15054
+ DIARIST_OUTPUT_TOOL_NAME = "ak_diarist_output";
15055
+ DIARIST_SOURCES_FLAG = {
15056
+ name: "ak-diarist-sources",
15057
+ definition: {
15058
+ description: "Frozen per-ticket source catalog the diarist selects from",
15059
+ type: "string"
15060
+ }
15061
+ };
15062
+ }
15063
+ });
15064
+
15026
15065
  // src/packaged-role-registry.ts
15027
15066
  function packagedRoleMetadata(role) {
15028
15067
  return PACKAGED_ROLE_REGISTRY.find((entry) => entry.role === role);
@@ -15043,6 +15082,7 @@ var init_packaged_role_registry = __esm({
15043
15082
  init_countersign_contracts();
15044
15083
  init_gleaner_left_contracts();
15045
15084
  init_inspector_contracts();
15085
+ init_diarist_contracts();
15046
15086
  NOTARY_SESSION_MATERIALS = [
15047
15087
  "CLAUDE.md",
15048
15088
  "souls/notary.md",
@@ -15208,6 +15248,22 @@ var init_packaged_role_registry = __esm({
15208
15248
  phaseFlag: void 0,
15209
15249
  activationStage: "load-and-install",
15210
15250
  sessionMaterials: ["CLAUDE.md", "souls/navigator.md"]
15251
+ },
15252
+ // #708 / ADR 0075 `diarist-is-role`: 起居郎 is a seat like any other. The
15253
+ // frozen source catalog rides the shared input-flag seam; it is absent for a
15254
+ // true-unbound summons (no ticket → no diary).
15255
+ {
15256
+ role: "diarist",
15257
+ phases: [null],
15258
+ outputTool: DIARIST_OUTPUT_TOOL_NAME,
15259
+ inputFlag: DIARIST_SOURCES_FLAG.name,
15260
+ phaseFlag: void 0,
15261
+ activationStage: "load-and-install",
15262
+ sessionMaterials: [
15263
+ "CLAUDE.md",
15264
+ "souls/diarist.md",
15265
+ "resources/diarist-collect.md"
15266
+ ]
15211
15267
  }
15212
15268
  ];
15213
15269
  PACKAGED_ROLE_REGISTRY = PUBLIC_ROLE_RECORDS.map(({ sessionMaterials: _omit, ...metadata }) => metadata);
@@ -15319,7 +15375,10 @@ var init_registry2 = __esm({
15319
15375
  navigator: [
15320
15376
  { provider: "openai-codex", model: "gpt-5.6-luna", thinking: "medium" },
15321
15377
  { provider: "xai", model: "grok-4.5", thinking: "high" }
15322
- ]
15378
+ ],
15379
+ // #708 `diarist-seat-default`: owner-set initial value; changed in the seat
15380
+ // table like any other seat. No engine axis, package-default host.
15381
+ diarist: [{ provider: "xai", model: "grok-4.5", thinking: "medium" }]
15323
15382
  };
15324
15383
  PUBLIC_DETERMINISTIC_COMMANDS = ["analyst"];
15325
15384
  }
@@ -16459,6 +16518,12 @@ function buildActivationFlagArgs(activation) {
16459
16518
  return ["--ak-role", "gatekeeper"];
16460
16519
  case "navigator":
16461
16520
  return ["--ak-role", "navigator"];
16521
+ case "diarist":
16522
+ return [
16523
+ "--ak-role",
16524
+ "diarist",
16525
+ ...activation.sourcesPath === void 0 ? [] : ["--ak-diarist-sources", activation.sourcesPath]
16526
+ ];
16462
16527
  default: {
16463
16528
  const _exhaustive = activation;
16464
16529
  return _exhaustive;
@@ -16803,7 +16868,8 @@ function validateAcceptedDetails(toolName, details) {
16803
16868
  [GLEANER_LEFT_OUTPUT_TOOL_NAME]: ["completed"],
16804
16869
  [INSPECTOR_OUTPUT_TOOL_NAME]: ["pass", "bounce"],
16805
16870
  [GATEKEEPER_OUTPUT_TOOL_NAME]: ["dispatch", "pass"],
16806
- [NAVIGATOR_OUTPUT_TOOL_NAME]: ["advice"]
16871
+ [NAVIGATOR_OUTPUT_TOOL_NAME]: ["advice"],
16872
+ [DIARIST_OUTPUT_TOOL_NAME]: ["completed"]
16807
16873
  };
16808
16874
  const collectorDiscriminator = toolName === COLLECTOR_OUTPUT_TOOL && Array.isArray(candidate?.groups);
16809
16875
  const baseDiscriminator = discriminator;
@@ -16839,6 +16905,8 @@ function validateAcceptedDetails(toolName, details) {
16839
16905
  return validateRecordedGatekeeperOutput(details);
16840
16906
  case NAVIGATOR_OUTPUT_TOOL_NAME:
16841
16907
  return validateRecordedNavigatorOutput(details);
16908
+ case DIARIST_OUTPUT_TOOL_NAME:
16909
+ return validateRecordedDiaristOutput(details);
16842
16910
  }
16843
16911
  } catch (error) {
16844
16912
  if (error instanceof Error && error.constructor === Error) throw new AcceptedDetailsContractError(error.message, { cause: error });
@@ -16856,6 +16924,7 @@ function acceptedFacts(toolName, details) {
16856
16924
  case INSPECTOR_OUTPUT_TOOL_NAME:
16857
16925
  case GATEKEEPER_OUTPUT_TOOL_NAME:
16858
16926
  case NAVIGATOR_OUTPUT_TOOL_NAME:
16927
+ case DIARIST_OUTPUT_TOOL_NAME:
16859
16928
  return { status: details.status };
16860
16929
  case JUDGE_OUTPUT_TOOL_NAME:
16861
16930
  return { status: details.judgeStatus };
@@ -16887,6 +16956,7 @@ var init_terminating_tools = __esm({
16887
16956
  init_countersign_contracts();
16888
16957
  init_gleaner_left_contracts();
16889
16958
  init_inspector_contracts();
16959
+ init_diarist_contracts();
16890
16960
  init_worker_output();
16891
16961
  TERMINATING_TOOL_NAMES = [
16892
16962
  CODER_OUTPUT_TOOL_NAME,
@@ -16901,7 +16971,8 @@ var init_terminating_tools = __esm({
16901
16971
  GLEANER_LEFT_OUTPUT_TOOL_NAME,
16902
16972
  INSPECTOR_OUTPUT_TOOL_NAME,
16903
16973
  GATEKEEPER_OUTPUT_TOOL_NAME,
16904
- NAVIGATOR_OUTPUT_TOOL_NAME
16974
+ NAVIGATOR_OUTPUT_TOOL_NAME,
16975
+ DIARIST_OUTPUT_TOOL_NAME
16905
16976
  ];
16906
16977
  AcceptedDetailsContractError = class extends CorrectableSubmissionError {
16907
16978
  code = "accepted_details_contract";
@@ -17380,7 +17451,7 @@ async function readRoleRunStateDisk(runDirectory) {
17380
17451
  if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
17381
17452
  return void 0;
17382
17453
  }
17383
- if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger" && record4.role !== "notary" && record4.role !== "countersign" && record4.role !== "gleaner-left" && record4.role !== "inspector" && record4.role !== "gatekeeper" && record4.role !== "navigator") {
17454
+ if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger" && record4.role !== "notary" && record4.role !== "countersign" && record4.role !== "gleaner-left" && record4.role !== "inspector" && record4.role !== "gatekeeper" && record4.role !== "navigator" && record4.role !== "diarist") {
17384
17455
  return void 0;
17385
17456
  }
17386
17457
  if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
@@ -18195,6 +18266,19 @@ async function loadResumableGleanerLeftRun(home, runId, authority) {
18195
18266
  };
18196
18267
  return seatLoadedResult(loaded, admitted);
18197
18268
  }
18269
+ async function loadResumableDiaristRun(home, runId, authority) {
18270
+ const loaded = await loadResumableRunRecord(home, runId, authority);
18271
+ if (loaded.run.role !== "diarist") {
18272
+ throw new CliUsageError(
18273
+ `role run ${runId} belongs to ${loaded.run.role}, not diarist`
18274
+ );
18275
+ }
18276
+ const admitted = {
18277
+ role: "diarist",
18278
+ ...resumedBaseAdmitted(loaded)
18279
+ };
18280
+ return seatLoadedResult(loaded, admitted);
18281
+ }
18198
18282
  async function loadResumableMergerRun(home, runId, authority) {
18199
18283
  const loaded = await loadResumableRunRecord(home, runId, authority);
18200
18284
  if (loaded.run.role !== "merger") {
@@ -18711,7 +18795,7 @@ function renderHumanOwnerOptionLines(owner, locale2 = "en") {
18711
18795
  }
18712
18796
  return lines;
18713
18797
  }
18714
- var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, JUDGE_OPTIONS, GLEANER_LEFT_OPTIONS, INSPECTOR_OPTIONS, GATEKEEPER_OPTIONS, NAVIGATOR_OPTIONS, COUNTERSIGN_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, PUBLIC_OPTION_TABLE, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
18798
+ var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, JUDGE_OPTIONS, GLEANER_LEFT_OPTIONS, INSPECTOR_OPTIONS, GATEKEEPER_OPTIONS, NAVIGATOR_OPTIONS, COUNTERSIGN_OPTIONS, DIARIST_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, PUBLIC_OPTION_TABLE, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
18715
18799
  var init_option_definitions = __esm({
18716
18800
  "src/public-cli/option-definitions.ts"() {
18717
18801
  "use strict";
@@ -18888,6 +18972,10 @@ var init_option_definitions = __esm({
18888
18972
  bindOwner("countersign", SHARED_PROJECT_SEMANTICS),
18889
18973
  bindOwner("countersign", SHARED_ATTACH_SEMANTICS)
18890
18974
  ];
18975
+ DIARIST_OPTIONS = [
18976
+ bindOwner("diarist", SHARED_PROJECT_SEMANTICS),
18977
+ bindOwner("diarist", SHARED_ATTACH_SEMANTICS)
18978
+ ];
18891
18979
  CODER_OPTIONS = [
18892
18980
  {
18893
18981
  id: "phase",
@@ -19233,6 +19321,7 @@ var init_option_definitions = __esm({
19233
19321
  inspector: INSPECTOR_OPTIONS,
19234
19322
  gatekeeper: GATEKEEPER_OPTIONS,
19235
19323
  navigator: NAVIGATOR_OPTIONS,
19324
+ diarist: DIARIST_OPTIONS,
19236
19325
  analyst: ANALYST_OPTIONS
19237
19326
  };
19238
19327
  PUBLIC_NAVIGATOR_HELP_NOTE = "Navigator also attends automatically on every run; that sidecar is unchanged by direct `ak-role navigator` calls.";
@@ -19351,6 +19440,15 @@ var init_option_definitions = __esm({
19351
19440
  'ak-role navigator "\u521A\u5B8C\u6210 coder apply \u6536\u655B\uFF0C\u4E0B\u4E00\u6B65\uFF1F"'
19352
19441
  ]
19353
19442
  },
19443
+ diarist: {
19444
+ command: "diarist",
19445
+ summary: "Direct Diarist (\u8D77\u5C45\u90CE) pass: gather and organize this case's decision basis into its \u8D77\u5C45\u5F55.",
19446
+ usage: ["ak-role diarist [options] [instruction]"],
19447
+ examples: [
19448
+ 'ak-role diarist "\u6574\u7406 #708 \u7684\u672C\u6848\u4F9D\u636E\u3002"',
19449
+ 'ak-role diarist --attach ./design.md "\u8865\u5F55\u672C\u8F6E\u8BBE\u8BA1\u4FEE\u8BA2\u3002"'
19450
+ ]
19451
+ },
19354
19452
  notary: {
19355
19453
  command: "notary",
19356
19454
  summary: "Direct Notary document check (quote fidelity + ticket alignment); zero prompt/attachment.",
@@ -19729,6 +19827,9 @@ function parseGatekeeperArgv(args) {
19729
19827
  function parseNavigatorArgv(args) {
19730
19828
  return parseInstructionArgv(args, "navigator");
19731
19829
  }
19830
+ function parseDiaristArgv(args) {
19831
+ return parseInstructionArgv(args, "diarist");
19832
+ }
19732
19833
  function parseCoderArgv(args) {
19733
19834
  const attachmentPaths = [];
19734
19835
  let project;
@@ -19948,6 +20049,9 @@ async function admitGatekeeperInvocation(options) {
19948
20049
  async function admitNavigatorInvocation(options) {
19949
20050
  return admitStandardMaterialInvocation("navigator", options);
19950
20051
  }
20052
+ async function admitDiaristInvocation(options) {
20053
+ return admitStandardMaterialInvocation("diarist", options);
20054
+ }
19951
20055
  function buildInstructionTransportPrompt(admitted, engineMaterial) {
19952
20056
  const lines = [admitted.instructionEmpty ? "" : admitted.instruction];
19953
20057
  if (admitted.attachments.length > 0) {
@@ -22450,21 +22554,6 @@ function extractCornerQuotes(text, minLength = DEFAULT_QUOTE_MIN) {
22450
22554
  }
22451
22555
  return out;
22452
22556
  }
22453
- function buildDiaristAnchors(input) {
22454
- const fromBody = input.ticketBody === void 0 ? [] : extractCornerQuotes(input.ticketBody);
22455
- const quotes = [...fromBody, ...input.extraQuotes ?? []];
22456
- const seen = /* @__PURE__ */ new Set();
22457
- const uniqueQuotes = [];
22458
- for (const q of quotes) {
22459
- if (seen.has(q)) continue;
22460
- seen.add(q);
22461
- uniqueQuotes.push(q);
22462
- }
22463
- return {
22464
- ticketNumber: input.ticketNumber,
22465
- quotes: uniqueQuotes
22466
- };
22467
- }
22468
22557
  function filterNotifications(blocks) {
22469
22558
  return blocks.filter((b) => !b.isNotification);
22470
22559
  }
@@ -22490,15 +22579,6 @@ function dedupeSourceBlocks(blocks) {
22490
22579
  }
22491
22580
  return out;
22492
22581
  }
22493
- function verifyQuotesVerbatim(sourceText, quotes) {
22494
- const failed = [];
22495
- for (const q of quotes) {
22496
- if (q.length === 0) continue;
22497
- if (!sourceText.includes(q)) failed.push(q);
22498
- }
22499
- if (failed.length === 0) return { ok: true };
22500
- return { ok: false, failedQuotes: failed };
22501
- }
22502
22582
  function mechanicalSafeguardPipeline(blocks) {
22503
22583
  return dedupeSourceBlocks(filterNotifications(blocks));
22504
22584
  }
@@ -22754,38 +22834,6 @@ function readAdrDecisionKeyBlocks(input) {
22754
22834
  }
22755
22835
  return blocks;
22756
22836
  }
22757
- function blockToLlmEntry(block, input) {
22758
- const verify = verifyQuotesVerbatim(block.transcript, input.quotes);
22759
- if (!verify.ok) {
22760
- return {
22761
- ok: false,
22762
- failedQuotes: verify.failedQuotes,
22763
- cause: `verbatim verify failed: ${verify.failedQuotes.join(" | ")}`
22764
- };
22765
- }
22766
- const anchorNotes = [`#${input.anchors.ticketNumber}`];
22767
- const seen = new Set(anchorNotes);
22768
- for (const q of [...input.anchors.quotes, ...input.quotes]) {
22769
- if (seen.has(q)) continue;
22770
- seen.add(q);
22771
- anchorNotes.push(q);
22772
- if (anchorNotes.length >= 12) break;
22773
- }
22774
- return {
22775
- ok: true,
22776
- entry: {
22777
- basis: {
22778
- method: "llm-semantic",
22779
- anchors: anchorNotes,
22780
- ...input.note === void 0 ? {} : { note: input.note }
22781
- },
22782
- sourceKind: block.sourceKind,
22783
- sourceRef: block.sourceRef,
22784
- transcript: block.transcript,
22785
- timestamp: block.timestamp
22786
- }
22787
- };
22788
- }
22789
22837
  var DEFAULT_QUOTE_MIN, DiaristSourceReadError, DIARIST_ADR_ROOT_REL;
22790
22838
  var init_diarist_mechanical = __esm({
22791
22839
  "src/diarist-mechanical.ts"() {
@@ -22807,193 +22855,6 @@ var init_diarist_mechanical = __esm({
22807
22855
  }
22808
22856
  });
22809
22857
 
22810
- // src/diarist-llm-collector.ts
22811
- import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
22812
- import { join as join19 } from "node:path";
22813
- import { fileURLToPath as fileURLToPath2 } from "node:url";
22814
- function resolveDiaristCollectMethodPath(packageRoot2 = fileURLToPath2(packageRootUrl)) {
22815
- return join19(packageRoot2, DIARIST_COLLECT_METHOD_RELATIVE);
22816
- }
22817
- function isRecord11(value) {
22818
- return typeof value === "object" && value !== null && !Array.isArray(value);
22819
- }
22820
- function parseDiaristLlmStdout(stdout, candidateCount) {
22821
- const trimmed = stdout.trim();
22822
- if (trimmed.length === 0) {
22823
- throw new DiaristLlmStdoutError("empty-stdout", "diarist collector stdout is empty");
22824
- }
22825
- let parsed;
22826
- try {
22827
- parsed = JSON.parse(trimmed);
22828
- } catch (error) {
22829
- throw new DiaristLlmStdoutError(
22830
- "unparseable-json",
22831
- "diarist collector stdout is not JSON",
22832
- { cause: error }
22833
- );
22834
- }
22835
- if (!isRecord11(parsed)) {
22836
- throw new DiaristLlmStdoutError(
22837
- "not-object",
22838
- "diarist collector stdout must be one JSON object"
22839
- );
22840
- }
22841
- if (!Object.prototype.hasOwnProperty.call(parsed, "selections")) {
22842
- throw new DiaristLlmStdoutError(
22843
- "selections-missing",
22844
- "diarist collector stdout missing selections"
22845
- );
22846
- }
22847
- if (!Array.isArray(parsed.selections)) {
22848
- throw new DiaristLlmStdoutError(
22849
- "selections-wrong-type",
22850
- "diarist collector selections must be an array"
22851
- );
22852
- }
22853
- const out = [];
22854
- for (let rowIndex = 0; rowIndex < parsed.selections.length; rowIndex += 1) {
22855
- const row = parsed.selections[rowIndex];
22856
- if (!isRecord11(row)) {
22857
- throw new DiaristLlmStdoutError(
22858
- "selection-uninterpretable",
22859
- `diarist collector selection[${rowIndex}] is not an object`
22860
- );
22861
- }
22862
- if (typeof row.candidateIndex !== "number" || !Number.isInteger(row.candidateIndex)) {
22863
- throw new DiaristLlmStdoutError(
22864
- "selection-uninterpretable",
22865
- `diarist collector selection[${rowIndex}].candidateIndex is not an integer`
22866
- );
22867
- }
22868
- const index = row.candidateIndex;
22869
- if (index < 0 || index >= candidateCount) {
22870
- throw new DiaristLlmStdoutError(
22871
- "selection-uninterpretable",
22872
- `diarist collector selection[${rowIndex}].candidateIndex ${index} out of range 0..${candidateCount - 1}`
22873
- );
22874
- }
22875
- if (!Object.prototype.hasOwnProperty.call(row, "quotes")) {
22876
- throw new DiaristLlmStdoutError(
22877
- "selection-uninterpretable",
22878
- `diarist collector selection[${rowIndex}].quotes missing`
22879
- );
22880
- }
22881
- if (!Array.isArray(row.quotes)) {
22882
- throw new DiaristLlmStdoutError(
22883
- "selection-uninterpretable",
22884
- `diarist collector selection[${rowIndex}].quotes must be an array`
22885
- );
22886
- }
22887
- const quotes = [];
22888
- for (let qIndex = 0; qIndex < row.quotes.length; qIndex += 1) {
22889
- const q = row.quotes[qIndex];
22890
- if (typeof q !== "string") {
22891
- throw new DiaristLlmStdoutError(
22892
- "selection-uninterpretable",
22893
- `diarist collector selection[${rowIndex}].quotes[${qIndex}] is not a string`
22894
- );
22895
- }
22896
- if (q.length > 0) quotes.push(q);
22897
- }
22898
- const triage = row.triage === "relevant" || row.triage === "context" || row.triage === "irrelevant" ? row.triage : void 0;
22899
- out.push({
22900
- candidateIndex: index,
22901
- quotes,
22902
- ...typeof row.note === "string" ? { note: row.note } : {},
22903
- ...triage === void 0 ? {} : { triage }
22904
- });
22905
- }
22906
- return out;
22907
- }
22908
- function buildDiaristCollectorEnginePayload(input) {
22909
- return {
22910
- method: input.method,
22911
- ticketNumber: input.ticketNumber,
22912
- candidates: input.candidates.map((block, index) => ({
22913
- candidateIndex: index,
22914
- sourceKind: block.sourceKind,
22915
- isUserTurn: block.isUserTurn,
22916
- timestamp: block.timestamp,
22917
- transcript: block.transcript
22918
- }))
22919
- };
22920
- }
22921
- function serializeDiaristCollectorEnginePayload(payload) {
22922
- return JSON.stringify(payload);
22923
- }
22924
- function createHermesDiaristCollector(options = {}) {
22925
- const executable = options.executable ?? "hermes";
22926
- const methodPath = resolveDiaristCollectMethodPath(options.packageRoot);
22927
- if (!existsSync8(methodPath)) {
22928
- throw new Error(`diarist collect method material missing (${methodPath})`);
22929
- }
22930
- const method = readFileSync4(methodPath, "utf8");
22931
- if (method.trim().length === 0) {
22932
- throw new Error(`diarist collect method material is empty (${methodPath})`);
22933
- }
22934
- return async (input) => {
22935
- const payload = buildDiaristCollectorEnginePayload({
22936
- ticketNumber: input.ticketNumber,
22937
- candidates: input.candidates,
22938
- method
22939
- });
22940
- const prompt = serializeDiaristCollectorEnginePayload(payload);
22941
- const argv = [
22942
- executable,
22943
- ...options.extraArgv ?? [],
22944
- "chat",
22945
- "--query-file",
22946
- ENGINE_DETOUR_STAGED_PROMPT_TOKEN,
22947
- "-Q",
22948
- "--no-restore-cwd",
22949
- "--ignore-rules",
22950
- "-t",
22951
- HERMES_DIARIST_COLLECTOR_TOOLSET
22952
- ];
22953
- const result2 = await runEngineDetourOnce({
22954
- argv,
22955
- stagedPrompt: prompt,
22956
- cwd: options.cwd ?? process.cwd(),
22957
- ...options.env === void 0 ? {} : { env: options.env },
22958
- ...input.signal === void 0 ? {} : { signal: input.signal }
22959
- });
22960
- if (result2.code !== 0) {
22961
- throw new Error(
22962
- `diarist LLM collector engine exited ${result2.code}: ${result2.stderr.slice(0, 500)}`
22963
- );
22964
- }
22965
- const selections = parseDiaristLlmStdout(
22966
- result2.stdout,
22967
- input.candidates.length
22968
- );
22969
- return {
22970
- selections,
22971
- rawStdout: result2.stdout,
22972
- // Staged body redacted — argv face shows the path token only.
22973
- engineArgv: argv
22974
- };
22975
- };
22976
- }
22977
- var DIARIST_COLLECT_METHOD_RELATIVE, packageRootUrl, DiaristLlmStdoutError, HERMES_DIARIST_COLLECTOR_TOOLSET;
22978
- var init_diarist_llm_collector = __esm({
22979
- "src/diarist-llm-collector.ts"() {
22980
- "use strict";
22981
- init_engine_detour();
22982
- DIARIST_COLLECT_METHOD_RELATIVE = "resources/diarist-collect.md";
22983
- packageRootUrl = new URL("..", import.meta.url);
22984
- DiaristLlmStdoutError = class extends Error {
22985
- code = "diarist-llm-stdout";
22986
- reason;
22987
- constructor(reason, message, options) {
22988
- super(message, options);
22989
- this.name = "DiaristLlmStdoutError";
22990
- this.reason = reason;
22991
- }
22992
- };
22993
- HERMES_DIARIST_COLLECTOR_TOOLSET = "context_engine";
22994
- }
22995
- });
22996
-
22997
22858
  // src/reviewer-git-snapshot.ts
22998
22859
  var init_reviewer_git_snapshot = __esm({
22999
22860
  "src/reviewer-git-snapshot.ts"() {
@@ -23052,11 +22913,11 @@ var init_reviewer_pinned_git = __esm({
23052
22913
  });
23053
22914
 
23054
22915
  // src/ticket-provenance-contracts.ts
23055
- function isRecord12(value) {
22916
+ function isRecord11(value) {
23056
22917
  return typeof value === "object" && value !== null && !Array.isArray(value);
23057
22918
  }
23058
22919
  function projectTicketProvenanceDiagnostic(value) {
23059
- if (!isRecord12(value)) return void 0;
22920
+ if (!isRecord11(value)) return void 0;
23060
22921
  if (value.recordClass !== TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC) {
23061
22922
  return void 0;
23062
22923
  }
@@ -23078,18 +22939,18 @@ function projectTicketProvenanceDiagnostic(value) {
23078
22939
  };
23079
22940
  }
23080
22941
  function projectTicketProvenanceEntry(value) {
23081
- if (!isRecord12(value)) return void 0;
22942
+ if (!isRecord11(value)) return void 0;
23082
22943
  if (value.recordClass === TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC) {
23083
22944
  return void 0;
23084
22945
  }
23085
- if (!isRecord12(value.basis)) return void 0;
22946
+ if (!isRecord11(value.basis)) return void 0;
23086
22947
  if (typeof value.basis.method !== "string" || !BASIS_METHODS.has(value.basis.method)) {
23087
22948
  return void 0;
23088
22949
  }
23089
22950
  if (typeof value.sourceKind !== "string" || !SOURCE_KINDS.has(value.sourceKind)) {
23090
22951
  return void 0;
23091
22952
  }
23092
- if (!isRecord12(value.sourceRef)) return void 0;
22953
+ if (!isRecord11(value.sourceRef)) return void 0;
23093
22954
  if (typeof value.transcript !== "string" || value.transcript.length === 0) {
23094
22955
  return void 0;
23095
22956
  }
@@ -23144,8 +23005,8 @@ var init_ticket_provenance_contracts = __esm({
23144
23005
 
23145
23006
  // src/ticket-provenance.ts
23146
23007
  import { createHash as createHash6 } from "node:crypto";
23147
- import { appendFileSync as appendFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "node:fs";
23148
- import { join as join20 } from "node:path";
23008
+ import { appendFileSync as appendFileSync2, existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
23009
+ import { join as join19 } from "node:path";
23149
23010
  function ticketProvenanceSubject(ticketNumber) {
23150
23011
  if (!Number.isSafeInteger(ticketNumber) || ticketNumber < 1) {
23151
23012
  throw new Error(`ticket-provenance subject requires a positive ticket number, got ${String(ticketNumber)}`);
@@ -23168,30 +23029,6 @@ function ticketProvenanceEntryIdentity(input) {
23168
23029
  ].join("\0");
23169
23030
  return createHash6("sha256").update(material, "utf8").digest("hex");
23170
23031
  }
23171
- function appendTicketProvenanceEntry(input) {
23172
- const subject = ticketProvenanceSubject(input.ticketNumber);
23173
- const identity = ticketProvenanceEntryIdentity({
23174
- ticketNumber: input.ticketNumber,
23175
- sourceKind: input.entry.sourceKind,
23176
- sourceRef: input.entry.sourceRef,
23177
- transcript: input.entry.transcript
23178
- });
23179
- return sitianReport({
23180
- level: "event",
23181
- kind: TICKET_PROVENANCE_KIND,
23182
- identity,
23183
- subject,
23184
- cwd: input.cwd,
23185
- ...input.home === void 0 ? {} : { home: input.home },
23186
- host: input.host ?? "diarist",
23187
- source: input.source ?? "diarist",
23188
- payload: input.entry,
23189
- raw: input.entry.sourceRef.sessionFile !== void 0 && input.entry.sourceRef.entryId !== void 0 ? {
23190
- sessionFile: input.entry.sourceRef.sessionFile,
23191
- entryId: input.entry.sourceRef.entryId
23192
- } : void 0
23193
- });
23194
- }
23195
23032
  function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
23196
23033
  const path = resolveSitianRecordPath({
23197
23034
  level: "event",
@@ -23203,16 +23040,16 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
23203
23040
  return {
23204
23041
  recordFile: path.recordFile,
23205
23042
  volumeDir: path.sessionDir,
23206
- humanViewFile: join20(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW),
23207
- offeredWatermarkFile: join20(path.sessionDir, TICKET_PROVENANCE_OFFERED_WATERMARK)
23043
+ humanViewFile: join19(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW),
23044
+ offeredWatermarkFile: join19(path.sessionDir, TICKET_PROVENANCE_OFFERED_WATERMARK)
23208
23045
  };
23209
23046
  }
23210
23047
  function readOfferedIdentities(ticketNumber, cwd, home) {
23211
23048
  const { offeredWatermarkFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
23212
- if (!existsSync9(offeredWatermarkFile)) return /* @__PURE__ */ new Set();
23049
+ if (!existsSync8(offeredWatermarkFile)) return /* @__PURE__ */ new Set();
23213
23050
  let text;
23214
23051
  try {
23215
- text = readFileSync5(offeredWatermarkFile, "utf8");
23052
+ text = readFileSync4(offeredWatermarkFile, "utf8");
23216
23053
  } catch (error) {
23217
23054
  throw new TicketProvenanceWatermarkError(
23218
23055
  "unreadable",
@@ -23245,25 +23082,6 @@ function readOfferedIdentities(ticketNumber, cwd, home) {
23245
23082
  }
23246
23083
  return seen;
23247
23084
  }
23248
- function recordOfferedIdentities(input) {
23249
- if (input.identities.length === 0) return;
23250
- const { volumeDir, offeredWatermarkFile } = resolveTicketProvenanceVolume(
23251
- input.ticketNumber,
23252
- input.cwd,
23253
- input.home
23254
- );
23255
- const already = new Set(readOfferedIdentities(input.ticketNumber, input.cwd, input.home));
23256
- const rows = [];
23257
- for (const identity of input.identities) {
23258
- if (identity.length === 0 || already.has(identity)) continue;
23259
- rows.push(`${JSON.stringify({ identity })}
23260
- `);
23261
- already.add(identity);
23262
- }
23263
- if (rows.length === 0) return;
23264
- mkdirSync3(volumeDir, { recursive: true });
23265
- appendFileSync2(offeredWatermarkFile, rows.join(""), "utf8");
23266
- }
23267
23085
  async function readTicketProvenance(ticketNumber, cwd, home) {
23268
23086
  const { recordFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
23269
23087
  const { records: records2 } = await readSitianRecords(recordFile);
@@ -23378,21 +23196,6 @@ function appendTicketProvenanceDiagnostic(input) {
23378
23196
  payload: input.diagnostic
23379
23197
  });
23380
23198
  }
23381
- function appendCollectorFailureDiagnostic(input) {
23382
- const recordedAt = input.recordedAt ?? (/* @__PURE__ */ new Date()).toISOString();
23383
- return appendTicketProvenanceDiagnostic({
23384
- ticketNumber: input.ticketNumber,
23385
- cwd: input.cwd,
23386
- ...input.home === void 0 ? {} : { home: input.home },
23387
- source: "diarist-collector-fail",
23388
- diagnostic: {
23389
- recordClass: TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC,
23390
- diagnosticKind: "collector-failed",
23391
- cause: input.collectorError,
23392
- recordedAt
23393
- }
23394
- });
23395
- }
23396
23199
  function appendIssueSourceFailureDiagnostic(input) {
23397
23200
  const recordedAt = input.recordedAt ?? (/* @__PURE__ */ new Date()).toISOString();
23398
23201
  return appendTicketProvenanceDiagnostic({
@@ -23409,21 +23212,6 @@ function appendIssueSourceFailureDiagnostic(input) {
23409
23212
  }
23410
23213
  });
23411
23214
  }
23412
- function appendQuoteVerifyFailureDiagnostic(input) {
23413
- const recordedAt = input.recordedAt ?? (/* @__PURE__ */ new Date()).toISOString();
23414
- return appendTicketProvenanceDiagnostic({
23415
- ticketNumber: input.ticketNumber,
23416
- cwd: input.cwd,
23417
- ...input.home === void 0 ? {} : { home: input.home },
23418
- source: "diarist-quote-verify",
23419
- diagnostic: {
23420
- recordClass: TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC,
23421
- diagnosticKind: "quote-verify-failed",
23422
- cause: input.cause,
23423
- recordedAt
23424
- }
23425
- });
23426
- }
23427
23215
  function writeTicketProvenanceHumanView(input) {
23428
23216
  const volume = ensureTicketProvenanceVolume(input.ticketNumber, input.cwd, input.home);
23429
23217
  const md = renderTicketProvenanceMarkdown({
@@ -23533,6 +23321,43 @@ function resolveDiaristGithubOrigin(projectRoot) {
23533
23321
  if (remoteUrl.length === 0) return void 0;
23534
23322
  return parseGitHubOriginRemote(remoteUrl);
23535
23323
  }
23324
+ async function loadDiaristIssueFace(input) {
23325
+ const persistAndThrow = (error) => {
23326
+ appendIssueSourceFailureDiagnostic({
23327
+ ticketNumber: input.ticketNumber,
23328
+ cwd: input.projectRoot,
23329
+ ...input.home === void 0 ? {} : { home: input.home },
23330
+ cause: error.message,
23331
+ reason: error.reason
23332
+ });
23333
+ return error;
23334
+ };
23335
+ const origin = resolveDiaristGithubOrigin(input.projectRoot);
23336
+ if (origin === void 0) {
23337
+ throw persistAndThrow(
23338
+ new DiaristIssueSourceError(
23339
+ "origin-unresolved",
23340
+ `bound ticket #${input.ticketNumber} issue face requires a resolvable github.com origin remote`
23341
+ )
23342
+ );
23343
+ }
23344
+ const fetcher = input.fetcher ?? createDiaristIssueFaceFetcher();
23345
+ try {
23346
+ return await fetcher({
23347
+ owner: origin.owner,
23348
+ repo: origin.repo,
23349
+ ticketNumber: input.ticketNumber
23350
+ });
23351
+ } catch (error) {
23352
+ throw persistAndThrow(
23353
+ error instanceof DiaristIssueSourceError ? error : new DiaristIssueSourceError(
23354
+ "issue-unavailable",
23355
+ `issue face fetch failed for ${origin.owner}/${origin.repo}#${input.ticketNumber}`,
23356
+ { cause: error }
23357
+ )
23358
+ );
23359
+ }
23360
+ }
23536
23361
  async function loadSeenEntryIdentities(ticketNumber, cwd, home) {
23537
23362
  const { recordFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
23538
23363
  const { records: records2 } = await readSitianRecords(recordFile);
@@ -23555,7 +23380,7 @@ function blockEntryIdentity(ticketNumber, block) {
23555
23380
  transcript: block.transcript
23556
23381
  });
23557
23382
  }
23558
- async function loadSourceBlocks(input) {
23383
+ function loadSourceBlocks(input) {
23559
23384
  const cwds = input.sessionCwds ?? [input.cwd];
23560
23385
  const blocks = [...readCcSessionBlocks({ cwds })];
23561
23386
  if (input.issueFace !== void 0) {
@@ -23576,124 +23401,31 @@ async function loadSourceBlocks(input) {
23576
23401
  }
23577
23402
  return blocks;
23578
23403
  }
23579
- function faceTextForAnchors(face) {
23580
- if (face === void 0) return void 0;
23581
- const parts = [face.body, ...face.comments.map((c) => c.body)].filter(
23582
- (t) => t.trim() !== ""
23583
- );
23584
- if (parts.length === 0) return void 0;
23585
- return parts.join("\n");
23586
- }
23587
- async function runDiarist(input) {
23588
- const homeOpt = input.home === void 0 ? {} : { home: input.home };
23589
- const volumePaths = ensureTicketProvenanceVolume(input.ticketNumber, input.cwd, input.home);
23590
- const anchorText = faceTextForAnchors(input.issueFace);
23591
- const anchors = buildDiaristAnchors({
23404
+ async function prepareDiaristSourceCatalog(input) {
23405
+ ensureTicketProvenanceVolume(input.ticketNumber, input.cwd, input.home);
23406
+ const volume = await readTicketProvenance(input.ticketNumber, input.cwd, input.home);
23407
+ writeTicketProvenanceHumanView({
23592
23408
  ticketNumber: input.ticketNumber,
23593
- ...anchorText === void 0 ? {} : { ticketBody: anchorText }
23409
+ cwd: input.cwd,
23410
+ ...input.home === void 0 ? {} : { home: input.home },
23411
+ entries: volume.entries
23594
23412
  });
23595
- const rawBlocks = await loadSourceBlocks(input);
23413
+ const rawBlocks = loadSourceBlocks(input);
23596
23414
  const safeguarded = mechanicalSafeguardPipeline(rawBlocks);
23597
23415
  const seen = await loadSeenEntryIdentities(input.ticketNumber, input.cwd, input.home);
23598
23416
  const fresh = safeguarded.filter(
23599
23417
  (block) => !seen.has(blockEntryIdentity(input.ticketNumber, block))
23600
23418
  );
23601
- let collectorStatus;
23602
- let collectorError;
23603
- let llmRawStdout;
23604
- let collect;
23605
- const collector = createHermesDiaristCollector({
23606
- cwd: input.cwd,
23607
- ...input.packageRoot === void 0 ? {} : { packageRoot: input.packageRoot }
23608
- });
23609
- if (fresh.length === 0) {
23610
- collectorStatus = "skipped-no-fresh";
23611
- } else {
23612
- try {
23613
- collect = await collector({
23614
- ticketNumber: input.ticketNumber,
23615
- candidates: fresh,
23616
- ...input.signal === void 0 ? {} : { signal: input.signal }
23617
- });
23618
- llmRawStdout = collect.rawStdout;
23619
- collectorStatus = collect.selections.length === 0 ? "empty-selection" : "ok";
23620
- } catch (error) {
23621
- collectorStatus = "failed";
23622
- collectorError = error instanceof Error ? error.message : String(error);
23623
- appendCollectorFailureDiagnostic({
23624
- ticketNumber: input.ticketNumber,
23625
- cwd: input.cwd,
23626
- ...homeOpt,
23627
- collectorError
23628
- });
23629
- }
23630
- }
23631
- const pointers = [];
23632
- const accepted = [];
23633
- let rejectedQuotes = 0;
23634
- if (collect !== void 0 && collectorStatus === "ok") {
23635
- for (const selection of collect.selections) {
23636
- const block = fresh[selection.candidateIndex];
23637
- if (block === void 0) continue;
23638
- const projected = blockToLlmEntry(block, {
23639
- anchors,
23640
- quotes: selection.quotes,
23641
- ...selection.note === void 0 ? {} : { note: selection.note }
23642
- });
23643
- if (!projected.ok) {
23644
- rejectedQuotes += 1;
23645
- const ptr2 = appendQuoteVerifyFailureDiagnostic({
23646
- ticketNumber: input.ticketNumber,
23647
- cwd: input.cwd,
23648
- ...homeOpt,
23649
- cause: projected.cause
23650
- });
23651
- pointers.push(ptr2);
23652
- continue;
23653
- }
23654
- const ptr = appendTicketProvenanceEntry({
23655
- ticketNumber: input.ticketNumber,
23656
- cwd: input.cwd,
23657
- ...homeOpt,
23658
- entry: projected.entry,
23659
- source: "diarist"
23660
- });
23661
- pointers.push(ptr);
23662
- accepted.push(projected.entry);
23663
- }
23664
- }
23665
- if (collect !== void 0 && (collectorStatus === "ok" || collectorStatus === "empty-selection")) {
23666
- recordOfferedIdentities({
23667
- ticketNumber: input.ticketNumber,
23668
- cwd: input.cwd,
23669
- ...homeOpt,
23670
- identities: fresh.map(
23671
- (block) => blockEntryIdentity(input.ticketNumber, block)
23672
- )
23673
- });
23674
- }
23675
- const volume = await readTicketProvenance(input.ticketNumber, input.cwd, input.home);
23676
- const humanViewFile = writeTicketProvenanceHumanView({
23677
- ticketNumber: input.ticketNumber,
23678
- cwd: input.cwd,
23679
- ...homeOpt,
23680
- entries: volume.entries
23681
- });
23682
23419
  return {
23683
23420
  ticketNumber: input.ticketNumber,
23684
- candidateCount: safeguarded.length,
23685
- freshCount: fresh.length,
23686
- appended: accepted.length,
23687
- rejectedQuotes,
23688
- pointers,
23689
- entries: volume.entries,
23690
- humanViewFile,
23691
- volumeRecordFile: volumePaths.recordFile,
23692
- collectorStatus,
23693
- ...collectorError === void 0 ? {} : { collectorError },
23694
- ...llmRawStdout === void 0 ? {} : { llmRawStdout }
23421
+ cwd: input.cwd,
23422
+ ...input.home === void 0 ? {} : { home: input.home },
23423
+ candidates: fresh.map((block, candidateIndex) => ({ ...block, candidateIndex }))
23695
23424
  };
23696
23425
  }
23426
+ function serializeDiaristSourceCatalog(catalog) {
23427
+ return JSON.stringify(catalog);
23428
+ }
23697
23429
  var DiaristIssueSourceError;
23698
23430
  var init_diarist = __esm({
23699
23431
  "src/diarist.ts"() {
@@ -23701,7 +23433,6 @@ var init_diarist = __esm({
23701
23433
  init_adr_path_refs();
23702
23434
  init_collector_github();
23703
23435
  init_diarist_mechanical();
23704
- init_diarist_llm_collector();
23705
23436
  init_reviewer_pinned_git();
23706
23437
  init_ticket_provenance();
23707
23438
  init_sitian_facade();
@@ -23826,27 +23557,27 @@ var init_engine_detour_tool = __esm({
23826
23557
  });
23827
23558
 
23828
23559
  // src/session-opening-materials.ts
23829
- import { existsSync as existsSync10 } from "node:fs";
23830
- import { dirname as dirname8, join as join21 } from "node:path";
23831
- import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
23560
+ import { existsSync as existsSync9 } from "node:fs";
23561
+ import { dirname as dirname8, join as join20 } from "node:path";
23562
+ import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
23832
23563
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
23833
- let dir = dirname8(fileURLToPath3(moduleUrl));
23564
+ let dir = dirname8(fileURLToPath2(moduleUrl));
23834
23565
  for (let i = 0; i < 8; i += 1) {
23835
- if (existsSync10(join21(dir, "package.json")) && existsSync10(join21(dir, "souls"))) {
23566
+ if (existsSync9(join20(dir, "package.json")) && existsSync9(join20(dir, "souls"))) {
23836
23567
  return dir;
23837
23568
  }
23838
23569
  const parent = dirname8(dir);
23839
23570
  if (parent === dir) break;
23840
23571
  dir = parent;
23841
23572
  }
23842
- return fileURLToPath3(new URL("..", moduleUrl));
23573
+ return fileURLToPath2(new URL("..", moduleUrl));
23843
23574
  }
23844
- var packageRootUrl2, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
23575
+ var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
23845
23576
  var init_session_opening_materials = __esm({
23846
23577
  "src/session-opening-materials.ts"() {
23847
23578
  "use strict";
23848
23579
  init_packaged_role_registry();
23849
- packageRootUrl2 = pathToFileURL2(resolvePackageRootDir() + "/").href;
23580
+ packageRootUrl = pathToFileURL2(resolvePackageRootDir() + "/").href;
23850
23581
  MAIN_ROLE_SESSION_MATERIALS = {
23851
23582
  ...Object.fromEntries(
23852
23583
  PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
@@ -23896,11 +23627,11 @@ var init_navigator_session_contracts = __esm({
23896
23627
  });
23897
23628
 
23898
23629
  // src/receipt-delivery-policy.ts
23899
- function isRecord13(value) {
23630
+ function isRecord12(value) {
23900
23631
  return typeof value === "object" && value !== null && !Array.isArray(value);
23901
23632
  }
23902
23633
  function parseNoReceiptLifecycleFacts(input) {
23903
- if (!isRecord13(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord13(item) && typeof item.reason === "string")) {
23634
+ if (!isRecord12(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord12(item) && typeof item.reason === "string")) {
23904
23635
  throw new TypeError("malformed no-receipt lifecycle facts");
23905
23636
  }
23906
23637
  return {
@@ -23990,7 +23721,7 @@ var init_compliance_transport = __esm({
23990
23721
 
23991
23722
  // src/ledger-session-read.ts
23992
23723
  import { readFile as readFile12 } from "node:fs/promises";
23993
- function isRecord14(value) {
23724
+ function isRecord13(value) {
23994
23725
  return typeof value === "object" && value !== null && !Array.isArray(value);
23995
23726
  }
23996
23727
  async function readLedgerSessionJsonl(path) {
@@ -24014,7 +23745,7 @@ async function readLedgerSessionJsonl(path) {
24014
23745
  }
24015
23746
  break;
24016
23747
  }
24017
- if (!isRecord14(row)) {
23748
+ if (!isRecord13(row)) {
24018
23749
  const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
24019
23750
  throw new LedgerSessionJsonlError(
24020
23751
  `complete non-object JSONL record in ${path} at line ${index + 1}: expected object, got ${kind}`,
@@ -24051,7 +23782,7 @@ function extractSessionModelSequence(rows) {
24051
23782
  if (row.type === "model_change" && typeof row.modelId === "string") {
24052
23783
  push(row.modelId);
24053
23784
  }
24054
- const message = isRecord14(row.message) ? row.message : void 0;
23785
+ const message = isRecord13(row.message) ? row.message : void 0;
24055
23786
  if (message?.role === "assistant" && typeof message.model === "string") {
24056
23787
  push(message.model);
24057
23788
  }
@@ -24067,11 +23798,11 @@ function extractSessionToolIntervals(rows) {
24067
23798
  const openById = /* @__PURE__ */ new Map();
24068
23799
  for (const row of rows) {
24069
23800
  const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
24070
- const message = isRecord14(row.message) ? row.message : void 0;
23801
+ const message = isRecord13(row.message) ? row.message : void 0;
24071
23802
  if (message?.role === "assistant" && Array.isArray(message.content)) {
24072
23803
  const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
24073
23804
  for (const part of message.content) {
24074
- if (!isRecord14(part) || part.type !== "toolCall") continue;
23805
+ if (!isRecord13(part) || part.type !== "toolCall") continue;
24075
23806
  if (typeof part.id !== "string" || part.id.length === 0) {
24076
23807
  throw new Error("toolCall frame missing string id");
24077
23808
  }
@@ -24084,7 +23815,7 @@ function extractSessionToolIntervals(rows) {
24084
23815
  if (openById.has(part.id)) {
24085
23816
  throw new Error(`duplicate toolCall id ${part.id}`);
24086
23817
  }
24087
- const args = isRecord14(part.arguments) ? part.arguments : void 0;
23818
+ const args = isRecord13(part.arguments) ? part.arguments : void 0;
24088
23819
  const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
24089
23820
  const interval = {
24090
23821
  toolCallId: part.id,
@@ -24169,8 +23900,8 @@ var init_ledger_session_read = __esm({
24169
23900
 
24170
23901
  // src/analyst-gate-cycles-read.ts
24171
23902
  import { readdir as readdir3 } from "node:fs/promises";
24172
- import { join as join22 } from "node:path";
24173
- function isRecord15(value) {
23903
+ import { join as join21 } from "node:path";
23904
+ function isRecord14(value) {
24174
23905
  return typeof value === "object" && value !== null && !Array.isArray(value);
24175
23906
  }
24176
23907
  function isParentAttemptBindingRow(row) {
@@ -24201,7 +23932,7 @@ function isGateTerminatingToolName(toolName) {
24201
23932
  function acceptedGateReceiptIds(rows) {
24202
23933
  const accepted = /* @__PURE__ */ new Set();
24203
23934
  for (const row of rows) {
24204
- const message = isRecord15(row.message) ? row.message : void 0;
23935
+ const message = isRecord14(row.message) ? row.message : void 0;
24205
23936
  if (message?.role !== "toolResult") continue;
24206
23937
  if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
24207
23938
  if (message.isError === false) accepted.add(message.toolCallId);
@@ -24240,7 +23971,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
24240
23971
  for (let i = beforeIndex - 1; i >= 0; i -= 1) {
24241
23972
  const row = rows[i];
24242
23973
  if (!isParentAttemptBindingRow(row)) continue;
24243
- if (!isRecord15(row.data) || !isRecord15(row.data.parent)) continue;
23974
+ if (!isRecord14(row.data) || !isRecord14(row.data.parent)) continue;
24244
23975
  const id = row.data.parent.attemptEntryId;
24245
23976
  const sessionFile = row.data.parent.sessionFile;
24246
23977
  return {
@@ -24255,10 +23986,10 @@ function extractAllAcceptedGateToolCalls(rows) {
24255
23986
  const out = [];
24256
23987
  for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
24257
23988
  const row = rows[rowIndex];
24258
- const message = isRecord15(row.message) ? row.message : void 0;
23989
+ const message = isRecord14(row.message) ? row.message : void 0;
24259
23990
  if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
24260
23991
  for (const part of message.content) {
24261
- if (!isRecord15(part) || part.type !== "toolCall") continue;
23992
+ if (!isRecord14(part) || part.type !== "toolCall") continue;
24262
23993
  if (typeof part.id !== "string" || part.id.length === 0) continue;
24263
23994
  if (typeof part.name !== "string" || part.name.length === 0) continue;
24264
23995
  if (!isGateTerminatingToolName(part.name)) continue;
@@ -24266,7 +23997,7 @@ function extractAllAcceptedGateToolCalls(rows) {
24266
23997
  const binding = nearestAttemptBindingBefore(rows, rowIndex);
24267
23998
  out.push({
24268
23999
  toolName: part.name,
24269
- args: isRecord15(part.arguments) ? part.arguments : void 0,
24000
+ args: isRecord14(part.arguments) ? part.arguments : void 0,
24270
24001
  accepted: true,
24271
24002
  rowIndex,
24272
24003
  ...binding
@@ -24408,7 +24139,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
24408
24139
  throw error;
24409
24140
  }
24410
24141
  for (const name of names) {
24411
- const classified = await classifyAuditorVolume(join22(directory, name));
24142
+ const classified = await classifyAuditorVolume(join21(directory, name));
24412
24143
  for (const volume of classified) {
24413
24144
  if (options.parentSessionFile !== void 0 && volume.parentSessionFile !== void 0 && volume.parentSessionFile !== options.parentSessionFile) {
24414
24145
  continue;
@@ -24466,21 +24197,21 @@ var init_gatekeeper_role = __esm({
24466
24197
 
24467
24198
  // src/run-terminal-artifacts.ts
24468
24199
  import { readdir as readdir4, readFile as readFile13 } from "node:fs/promises";
24469
- import { basename as basename7, dirname as dirname9, join as join23 } from "node:path";
24200
+ import { basename as basename7, dirname as dirname9, join as join22 } from "node:path";
24470
24201
  function isMissingPathError2(error) {
24471
24202
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
24472
24203
  }
24473
24204
  function errorText2(error) {
24474
24205
  return error instanceof Error ? error.message : String(error);
24475
24206
  }
24476
- function isRecord16(value) {
24207
+ function isRecord15(value) {
24477
24208
  return typeof value === "object" && value !== null && !Array.isArray(value);
24478
24209
  }
24479
24210
  function readUsableTerminalArtifactBody(body) {
24480
24211
  if (body === null) {
24481
24212
  return { ok: false, reason: "terminal artifact JSON value is null" };
24482
24213
  }
24483
- if (!isRecord16(body)) {
24214
+ if (!isRecord15(body)) {
24484
24215
  return {
24485
24216
  ok: false,
24486
24217
  reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
@@ -24541,7 +24272,7 @@ async function listUniqueErrorFallbackPaths(directories) {
24541
24272
  }
24542
24273
  for (const name of names.sort((a, b) => a.localeCompare(b))) {
24543
24274
  if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
24544
- found.push(join23(dir, name));
24275
+ found.push(join22(dir, name));
24545
24276
  }
24546
24277
  }
24547
24278
  return found;
@@ -24557,14 +24288,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
24557
24288
  return typeof body.runId === "string" && body.runId === expectedRunId;
24558
24289
  }
24559
24290
  async function readRunTerminalArtifact(runDirectory) {
24560
- const artifactsDir = join23(runDirectory, "artifacts");
24291
+ const artifactsDir = join22(runDirectory, "artifacts");
24561
24292
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
24562
- const path = join23(artifactsDir, file);
24293
+ const path = join22(artifactsDir, file);
24563
24294
  const read3 = await readTerminalArtifactAtPath(path, file);
24564
24295
  if (read3 !== void 0) return read3;
24565
24296
  }
24566
24297
  for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
24567
- const path = join23(runDirectory, relative3);
24298
+ const path = join22(runDirectory, relative3);
24568
24299
  const read3 = await readTerminalArtifactAtPath(path, "error.json");
24569
24300
  if (read3 !== void 0) return read3;
24570
24301
  }
@@ -24851,12 +24582,12 @@ var init_reviewer_dispatch = __esm({
24851
24582
 
24852
24583
  // src/public-cli/reviewer-dispatch-rejection.ts
24853
24584
  import { readFile as readFile14, unlink as unlink3 } from "node:fs/promises";
24854
- import { join as join24 } from "node:path";
24585
+ import { join as join23 } from "node:path";
24855
24586
  function isReviewerPreflightViolation(value) {
24856
24587
  return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
24857
24588
  }
24858
24589
  function reviewerDispatchRejectionPath(runDirectory) {
24859
- return join24(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
24590
+ return join23(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
24860
24591
  }
24861
24592
  async function clearReviewerDispatchRejection(runDirectory) {
24862
24593
  try {
@@ -25238,7 +24969,7 @@ var init_terminal = __esm({
25238
24969
  // src/public-cli/settlement.ts
25239
24970
  import { randomUUID as randomUUID3 } from "node:crypto";
25240
24971
  import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile7 } from "node:fs/promises";
25241
- import { dirname as dirname10, join as join25 } from "node:path";
24972
+ import { dirname as dirname10, join as join24 } from "node:path";
25242
24973
  function sealedLedgerHome(admitted) {
25243
24974
  return homeFromRunDirectory(admitted.runDirectory);
25244
24975
  }
@@ -25618,7 +25349,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
25618
25349
  const { records: records2 } = await readSitianRecords(recordFile);
25619
25350
  for (let i = records2.length - 1; i >= 0; i -= 1) {
25620
25351
  const payload = records2[i]?.payload;
25621
- if (!isRecord17(payload) || !isRecord17(payload.response)) continue;
25352
+ if (!isRecord16(payload) || !isRecord16(payload.response)) continue;
25622
25353
  if (typeof payload.type === "string") continue;
25623
25354
  const stop = sessionProviderStopFromAssistant(payload.response);
25624
25355
  if (stop !== void 0) return stop;
@@ -25639,7 +25370,7 @@ async function readSessionProviderStop(sessionFile) {
25639
25370
  }
25640
25371
  }
25641
25372
  async function readBoundEvidenceChildKnownFailure(sessionFile) {
25642
- const childDirectory = join25(dirname10(sessionFile), "evidence-children");
25373
+ const childDirectory = join24(dirname10(sessionFile), "evidence-children");
25643
25374
  let names;
25644
25375
  try {
25645
25376
  names = await readdir5(childDirectory);
@@ -25650,12 +25381,12 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
25650
25381
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
25651
25382
  let entries;
25652
25383
  try {
25653
- entries = await readBoundSessionEntries(join25(childDirectory, file));
25384
+ entries = await readBoundSessionEntries(join24(childDirectory, file));
25654
25385
  } catch (error) {
25655
25386
  throw sessionReadFailure(error, "failed to read discovered evidence-child session");
25656
25387
  }
25657
25388
  const header = entries.find((entry) => entry.type === "session");
25658
- if (!isRecord17(header) || header.parentSession !== sessionFile) continue;
25389
+ if (!isRecord16(header) || header.parentSession !== sessionFile) continue;
25659
25390
  const stop = extractSessionProviderStop(entries);
25660
25391
  if (stop === void 0) continue;
25661
25392
  const primary = knownFailureFromProviderStop(stop);
@@ -25687,12 +25418,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
25687
25418
  return firstLine === RESUME_ENVELOPE;
25688
25419
  };
25689
25420
  const isResumeEnvelope = (msg) => {
25690
- if (!isRecord17(msg) || msg.role !== "user") return false;
25421
+ if (!isRecord16(msg) || msg.role !== "user") return false;
25691
25422
  const text = typeof msg.text === "string" ? msg.text : typeof msg.content === "string" ? msg.content : void 0;
25692
25423
  if (isResumeEnvelopeBytes(text)) return true;
25693
25424
  const content = msg.content;
25694
25425
  if (Array.isArray(content)) {
25695
- return content.some((p) => isRecord17(p) && (isResumeEnvelopeBytes(p.text) || isResumeEnvelopeBytes(p.content)));
25426
+ return content.some((p) => isRecord16(p) && (isResumeEnvelopeBytes(p.text) || isResumeEnvelopeBytes(p.content)));
25696
25427
  }
25697
25428
  return false;
25698
25429
  };
@@ -25704,7 +25435,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
25704
25435
  latestParentUserIndex = i;
25705
25436
  break;
25706
25437
  }
25707
- const childDirectories = [join25(dirname10(sessionFile), "auditor-roles")];
25438
+ const childDirectories = [join24(dirname10(sessionFile), "auditor-roles")];
25708
25439
  const valid = [];
25709
25440
  let sawAnyDirectory = false;
25710
25441
  for (const childDirectory of childDirectories) {
@@ -25719,12 +25450,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
25719
25450
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
25720
25451
  let entries;
25721
25452
  try {
25722
- entries = await readBoundSessionEntries(join25(childDirectory, file));
25453
+ entries = await readBoundSessionEntries(join24(childDirectory, file));
25723
25454
  } catch (error) {
25724
25455
  throw sessionReadFailure(error, "failed to read discovered auditor session");
25725
25456
  }
25726
25457
  const header = entries.find((entry) => entry.type === "session");
25727
- if (!isRecord17(header)) continue;
25458
+ if (!isRecord16(header)) continue;
25728
25459
  const bindingIndexes = [];
25729
25460
  for (let i = 0; i < entries.length; i += 1) {
25730
25461
  const entry = entries[i];
@@ -25738,7 +25469,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
25738
25469
  end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
25739
25470
  })) : [{ entry: void 0, start: 0, end: entries.length }];
25740
25471
  for (const { entry: bindingEntry, start, end } of bindingPasses) {
25741
- const bindingParent = bindingEntry !== void 0 && isRecord17(bindingEntry.data) && isRecord17(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
25472
+ const bindingParent = bindingEntry !== void 0 && isRecord16(bindingEntry.data) && isRecord16(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
25742
25473
  const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
25743
25474
  const attemptEntryIndex = attemptEntryId === void 0 ? -1 : parentEntries.findIndex((entry) => entry.id === attemptEntryId);
25744
25475
  const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
@@ -25765,11 +25496,11 @@ function complianceFailureFromAuditorVolumes(volumes) {
25765
25496
  if (stop === void 0) continue;
25766
25497
  for (let i = entries.length - 1; i >= 0; i -= 1) {
25767
25498
  const entry = entries[i];
25768
- if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord17(entry.data)) continue;
25769
- const parent = isRecord17(entry.data.parent) ? entry.data.parent : void 0;
25770
- const failure = isRecord17(entry.data.failure) ? entry.data.failure : void 0;
25499
+ if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord16(entry.data)) continue;
25500
+ const parent = isRecord16(entry.data.parent) ? entry.data.parent : void 0;
25501
+ const failure = isRecord16(entry.data.failure) ? entry.data.failure : void 0;
25771
25502
  if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId || failure?.cause !== "provider" && failure?.cause !== "unrecognized") continue;
25772
- const identity = isRecord17(failure.identity) ? failure.identity : void 0;
25503
+ const identity = isRecord16(failure.identity) ? failure.identity : void 0;
25773
25504
  return {
25774
25505
  cause: failure.cause === "provider" ? "provider" : "unrecognized",
25775
25506
  ...identity === void 0 ? {} : { identity: {
@@ -25777,7 +25508,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
25777
25508
  ...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
25778
25509
  } },
25779
25510
  ...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
25780
- ...isRecord17(failure.details) ? { details: failure.details } : {}
25511
+ ...isRecord16(failure.details) ? { details: failure.details } : {}
25781
25512
  };
25782
25513
  }
25783
25514
  }
@@ -25824,9 +25555,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
25824
25555
  if (classification.kind !== "infrastructure") continue;
25825
25556
  if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
25826
25557
  if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
25827
- const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord17(part) && part.type === "text" && typeof part.text === "string") : void 0;
25828
- const diagnostic = isRecord17(textPart) ? textPart.text : void 0;
25829
- const details = isRecord17(message.details) ? message.details : classification.fact;
25558
+ const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord16(part) && part.type === "text" && typeof part.text === "string") : void 0;
25559
+ const diagnostic = isRecord16(textPart) ? textPart.text : void 0;
25560
+ const details = isRecord16(message.details) ? message.details : classification.fact;
25830
25561
  return {
25831
25562
  cause: "output",
25832
25563
  identity: { name: message.toolName, code: message.toolCallId },
@@ -25984,7 +25715,7 @@ function controlledFailureInputFromResolution(resolution) {
25984
25715
  } : {}
25985
25716
  };
25986
25717
  }
25987
- function isRecord17(value) {
25718
+ function isRecord16(value) {
25988
25719
  return typeof value === "object" && value !== null && !Array.isArray(value);
25989
25720
  }
25990
25721
  function safelyRead(object, key) {
@@ -26007,7 +25738,7 @@ function countersignDecisiveFacts(verdict, countersignStatus) {
26007
25738
  const facts = { countersignStatus };
26008
25739
  if (countersignStatus === "continue") {
26009
25740
  const fix = safelyRead(verdict, "fix");
26010
- if (fix.readable && isRecord17(fix.value)) {
25741
+ if (fix.readable && isRecord16(fix.value)) {
26011
25742
  const summary = safelyRead(fix.value, "summary");
26012
25743
  if (summary.readable && typeof summary.value === "string") {
26013
25744
  facts.fixSummary = summary.value;
@@ -26016,7 +25747,7 @@ function countersignDecisiveFacts(verdict, countersignStatus) {
26016
25747
  }
26017
25748
  if (countersignStatus === "escalate") {
26018
25749
  const gate = safelyRead(verdict, "decisionGate");
26019
- if (gate.readable && isRecord17(gate.value)) {
25750
+ if (gate.readable && isRecord16(gate.value)) {
26020
25751
  const question = safelyRead(gate.value, "question");
26021
25752
  const options = safelyRead(gate.value, "options");
26022
25753
  if (question.readable && typeof question.value === "string") {
@@ -26041,7 +25772,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
26041
25772
  const statusBase = judgeStatus;
26042
25773
  if (statusBase === "continue") {
26043
25774
  const fix = safelyRead(verdict, "fix");
26044
- if (fix.readable && isRecord17(fix.value)) {
25775
+ if (fix.readable && isRecord16(fix.value)) {
26045
25776
  const summary = safelyRead(fix.value, "summary");
26046
25777
  if (summary.readable && typeof summary.value === "string") {
26047
25778
  facts.fixSummary = summary.value;
@@ -26051,7 +25782,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
26051
25782
  if (classes.readable && Array.isArray(classes.value)) {
26052
25783
  try {
26053
25784
  facts.classes = classes.value.map((entry) => {
26054
- if (!isRecord17(entry)) throw new Error("unreadable Judge class");
25785
+ if (!isRecord16(entry)) throw new Error("unreadable Judge class");
26055
25786
  return {
26056
25787
  name: entry.name,
26057
25788
  owner: entry.owner,
@@ -26066,7 +25797,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
26066
25797
  }
26067
25798
  if (statusBase === "escalate") {
26068
25799
  const gate = safelyRead(verdict, "decisionGate");
26069
- if (gate.readable && isRecord17(gate.value)) {
25800
+ if (gate.readable && isRecord16(gate.value)) {
26070
25801
  const question = safelyRead(gate.value, "question");
26071
25802
  const options = safelyRead(gate.value, "options");
26072
25803
  if (question.readable && typeof question.value === "string") {
@@ -26112,7 +25843,7 @@ function fixerDecisiveFacts(output) {
26112
25843
  facts.reason = reason.value;
26113
25844
  }
26114
25845
  const blockerRead = safelyRead(candidate, "blocker");
26115
- if (statusBase === "refused" && blockerRead.readable && isRecord17(blockerRead.value)) {
25846
+ if (statusBase === "refused" && blockerRead.readable && isRecord16(blockerRead.value)) {
26116
25847
  const cause = safelyRead(blockerRead.value, "cause");
26117
25848
  if (cause.readable && typeof cause.value === "string") facts.blockerCause = cause.value;
26118
25849
  const prerequisiteId = safelyRead(blockerRead.value, "prerequisiteId");
@@ -26124,13 +25855,13 @@ function fixerDecisiveFacts(output) {
26124
25855
  const blockers = [];
26125
25856
  try {
26126
25857
  for (const entry of classResults.value) {
26127
- if (!isRecord17(entry)) throw new Error("unreadable class result");
25858
+ if (!isRecord16(entry)) throw new Error("unreadable class result");
26128
25859
  const name = safelyRead(entry, "name");
26129
25860
  const disposition = safelyRead(entry, "disposition");
26130
25861
  if (!name.readable || !disposition.readable) throw new Error("unreadable class result");
26131
25862
  rows.push({ name: name.value, disposition: disposition.value });
26132
25863
  const blocker = safelyRead(entry, "blocker");
26133
- if (disposition.value === "refused" && blocker.readable && isRecord17(blocker.value)) blockers.push(blocker.value);
25864
+ if (disposition.value === "refused" && blocker.readable && isRecord16(blocker.value)) blockers.push(blocker.value);
26134
25865
  }
26135
25866
  facts.classResultCount = rows.length;
26136
25867
  facts.classDispositions = rows;
@@ -26163,7 +25894,7 @@ function collectorDecisiveFacts(receipt) {
26163
25894
  if (groups.readable && Array.isArray(groups.value)) {
26164
25895
  try {
26165
25896
  facts.groups = groups.value.map((group) => {
26166
- if (!isRecord17(group)) throw new Error("unreadable Collector group");
25897
+ if (!isRecord16(group)) throw new Error("unreadable Collector group");
26167
25898
  const identity = safelyRead(group, "identity");
26168
25899
  const attendance = safelyRead(group, "attendance");
26169
25900
  const materials = safelyRead(group, "materials");
@@ -26197,7 +25928,7 @@ function doctorDecisiveFacts(output) {
26197
25928
  return facts;
26198
25929
  }
26199
25930
  const caseValue = safelyRead(candidate, "case");
26200
- if (caseValue.readable && isRecord17(caseValue.value)) {
25931
+ if (caseValue.readable && isRecord16(caseValue.value)) {
26201
25932
  const issueNumber = safelyRead(caseValue.value, "issueNumber");
26202
25933
  const runsPath = safelyRead(caseValue.value, "runsPath");
26203
25934
  if (issueNumber.readable && issueNumber.value !== void 0) facts.issueNumber = issueNumber.value;
@@ -26208,7 +25939,7 @@ function doctorDecisiveFacts(output) {
26208
25939
  return facts;
26209
25940
  }
26210
25941
  function reviewerAxes(value) {
26211
- if (!isRecord17(value)) return [];
25942
+ if (!isRecord16(value)) return [];
26212
25943
  return ["standards", "spec"].filter((axis) => {
26213
25944
  const projected = safelyRead(value, axis);
26214
25945
  return projected.readable && projected.value !== void 0;
@@ -26342,7 +26073,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
26342
26073
  const candidateMessage = entries[index]?.message;
26343
26074
  if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
26344
26075
  for (const part of candidateMessage.content) {
26345
- if (!isRecord17(part) || part.type !== "toolCall" || part.id !== callId) {
26076
+ if (!isRecord16(part) || part.type !== "toolCall" || part.id !== callId) {
26346
26077
  continue;
26347
26078
  }
26348
26079
  if (part.name !== outputToolName) return void 0;
@@ -26414,7 +26145,7 @@ function parseNavigatorAttendanceDetails(details) {
26414
26145
  const advisoryDiagnostic = typeof details.routePlaybookReadFailure === "string" ? { advisoryDiagnostic: details.routePlaybookReadFailure } : {};
26415
26146
  if (disposition === "recommendation") {
26416
26147
  const next = details.next;
26417
- if (!isRecord17(next) || typeof next.role !== "string") {
26148
+ if (!isRecord16(next) || typeof next.role !== "string") {
26418
26149
  return {
26419
26150
  disposition: "unavailable",
26420
26151
  source: "unknown",
@@ -26422,7 +26153,7 @@ function parseNavigatorAttendanceDetails(details) {
26422
26153
  };
26423
26154
  }
26424
26155
  const reason = typeof details.reason === "string" ? details.reason : "";
26425
- const route = Array.isArray(details.route) ? details.route.filter(isRecord17).map((target) => ({
26156
+ const route = Array.isArray(details.route) ? details.route.filter(isRecord16).map((target) => ({
26426
26157
  role: String(target.role),
26427
26158
  phase: navigatorPhaseValue(target.phase)
26428
26159
  })) : void 0;
@@ -26485,8 +26216,8 @@ function projectTerminalGateFact(rounds) {
26485
26216
  };
26486
26217
  }
26487
26218
  async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
26488
- const directories = [join25(sessionDirectory, "auditor-roles")];
26489
- const parentSessionFile = options.parentSessionFile ?? join25(sessionDirectory, "session.jsonl");
26219
+ const directories = [join24(sessionDirectory, "auditor-roles")];
26220
+ const parentSessionFile = options.parentSessionFile ?? join24(sessionDirectory, "session.jsonl");
26490
26221
  const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
26491
26222
  parentSessionFile
26492
26223
  });
@@ -26494,7 +26225,7 @@ async function extractGateFactFromSessionDirectory(sessionDirectory, options = {
26494
26225
  }
26495
26226
  async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
26496
26227
  const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
26497
- if (isRecord17(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary")) return base;
26228
+ if (isRecord16(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary")) return base;
26498
26229
  const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
26499
26230
  return gate === void 0 ? base : { ...base, gate };
26500
26231
  }
@@ -26534,7 +26265,7 @@ function extractNavigatorFact(entries) {
26534
26265
  const entry = entries[i];
26535
26266
  if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
26536
26267
  const details = entry.message?.details ?? entry.details;
26537
- if (!isRecord17(details)) {
26268
+ if (!isRecord16(details)) {
26538
26269
  return {
26539
26270
  disposition: "unavailable",
26540
26271
  source: "unknown",
@@ -26584,8 +26315,8 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
26584
26315
  async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
26585
26316
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26586
26317
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26587
- const reportPath = join25(artifactsDir, "report.json");
26588
- const evidencePath = join25(artifactsDir, "evidence.json");
26318
+ const reportPath = join24(artifactsDir, "report.json");
26319
+ const evidencePath = join24(artifactsDir, "evidence.json");
26589
26320
  await writeFile7(
26590
26321
  reportPath,
26591
26322
  `${JSON.stringify(
@@ -26629,8 +26360,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
26629
26360
  async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
26630
26361
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26631
26362
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26632
- const reportPath = join25(artifactsDir, "report.json");
26633
- const evidencePath = join25(artifactsDir, "evidence.json");
26363
+ const reportPath = join24(artifactsDir, "report.json");
26364
+ const evidencePath = join24(artifactsDir, "evidence.json");
26634
26365
  await writeFile7(
26635
26366
  reportPath,
26636
26367
  `${JSON.stringify(
@@ -26789,8 +26520,8 @@ function extractFixerMethodInvocations(entries, options) {
26789
26520
  async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
26790
26521
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26791
26522
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26792
- const reportPath = join25(artifactsDir, "report.json");
26793
- const evidencePath = join25(artifactsDir, "evidence.json");
26523
+ const reportPath = join24(artifactsDir, "report.json");
26524
+ const evidencePath = join24(artifactsDir, "evidence.json");
26794
26525
  await writeFile7(
26795
26526
  reportPath,
26796
26527
  `${JSON.stringify(
@@ -26889,8 +26620,8 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options) {
26889
26620
  async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
26890
26621
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26891
26622
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26892
- const reportPath = join25(artifactsDir, "report.json");
26893
- const evidencePath = join25(artifactsDir, "evidence.json");
26623
+ const reportPath = join24(artifactsDir, "report.json");
26624
+ const evidencePath = join24(artifactsDir, "evidence.json");
26894
26625
  await writeFile7(
26895
26626
  reportPath,
26896
26627
  `${JSON.stringify(
@@ -26949,7 +26680,7 @@ async function settleLawfulCollectorTerminalResult(admitted, authority) {
26949
26680
  const residual = boundErroredToolCandidate(entries, index, message, COLLECTOR_WAIT_TOOL);
26950
26681
  if (residual === void 0) continue;
26951
26682
  const candidate = residual.candidate;
26952
- const duration = isRecord17(candidate) ? candidate.durationMs : void 0;
26683
+ const duration = isRecord16(candidate) ? candidate.durationMs : void 0;
26953
26684
  if (Number.isSafeInteger(duration) && duration >= 1 && duration <= 9e5) {
26954
26685
  continue;
26955
26686
  }
@@ -26997,8 +26728,8 @@ async function trySettleCollectorTerminalResult(admitted, authority) {
26997
26728
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
26998
26729
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26999
26730
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
27000
- const reportPath = join25(artifactsDir, "report.json");
27001
- const evidencePath = join25(artifactsDir, "evidence.json");
26731
+ const reportPath = join24(artifactsDir, "report.json");
26732
+ const evidencePath = join24(artifactsDir, "evidence.json");
27002
26733
  await writeFile7(
27003
26734
  reportPath,
27004
26735
  `${JSON.stringify(
@@ -27257,6 +26988,27 @@ async function settleLawfulGleanerLeftTerminalResult(admitted, authority, scope)
27257
26988
  async function trySettleGleanerLeftTerminalResult(admitted, authority, scope) {
27258
26989
  return settleLawfulGleanerLeftTerminalResult(admitted, authority, scope);
27259
26990
  }
26991
+ async function settleLawfulDiaristTerminalResult(admitted, authority, scope) {
26992
+ return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
26993
+ role: "diarist",
26994
+ toolName: DIARIST_OUTPUT_TOOL_NAME,
26995
+ nonUsableDiagnostic: "\u8D77\u5C45\u90CE\u56DE\u6267\u65E0\u663E\u5F0F completed",
26996
+ tryAcceptDetails: tryAcceptWithValidator(validateRecordedDiaristOutput),
26997
+ projectAccepted: (sealed) => {
26998
+ const output = validateRecordedDiaristOutput(sealed.decisiveFacts);
26999
+ const accepted = {
27000
+ kind: "accepted",
27001
+ role: "diarist",
27002
+ status: sealed.status,
27003
+ decisiveFacts: diaristDecisiveFacts(output)
27004
+ };
27005
+ return accepted;
27006
+ }
27007
+ }, scope);
27008
+ }
27009
+ async function trySettleDiaristTerminalResult(admitted, authority, scope) {
27010
+ return settleLawfulDiaristTerminalResult(admitted, authority, scope);
27011
+ }
27260
27012
  async function settleLawfulInspectorTerminalResult(admitted, authority, scope) {
27261
27013
  return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
27262
27014
  role: "inspector",
@@ -27345,8 +27097,8 @@ function extractReviewerMethodInvocations(entries, options) {
27345
27097
  async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
27346
27098
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
27347
27099
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
27348
- const reportPath = join25(artifactsDir, "report.json");
27349
- const evidencePath = join25(artifactsDir, "evidence.json");
27100
+ const reportPath = join24(artifactsDir, "report.json");
27101
+ const evidencePath = join24(artifactsDir, "evidence.json");
27350
27102
  await writeFile7(
27351
27103
  reportPath,
27352
27104
  `${JSON.stringify(
@@ -27473,8 +27225,8 @@ function extractMergerMethodInvocations(entries, options) {
27473
27225
  async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
27474
27226
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
27475
27227
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
27476
- const reportPath = join25(artifactsDir, "report.json");
27477
- const evidencePath = join25(artifactsDir, "evidence.json");
27228
+ const reportPath = join24(artifactsDir, "report.json");
27229
+ const evidencePath = join24(artifactsDir, "evidence.json");
27478
27230
  await writeFile7(
27479
27231
  reportPath,
27480
27232
  `${JSON.stringify(
@@ -27541,7 +27293,7 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options) {
27541
27293
  if (message?.role !== "toolResult") continue;
27542
27294
  const residual = boundErroredToolCandidate(entries, index, message, MERGER_OUTPUT_TOOL_NAME);
27543
27295
  if (residual === void 0) continue;
27544
- const attemptId = isRecord17(residual.candidate) ? safelyRead(residual.candidate, "attemptId") : { readable: true, value: void 0 };
27296
+ const attemptId = isRecord16(residual.candidate) ? safelyRead(residual.candidate, "attemptId") : { readable: true, value: void 0 };
27545
27297
  if (!attemptId.readable || attemptId.value !== admitted.runId) continue;
27546
27298
  try {
27547
27299
  validateMergerOutput(residual.candidate, admitted.runId);
@@ -27623,7 +27375,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
27623
27375
  return dirs;
27624
27376
  }
27625
27377
  async function resolveFailureArtifactsBase(runDirectory) {
27626
- const artifactsDir = join25(runDirectory, "artifacts");
27378
+ const artifactsDir = join24(runDirectory, "artifacts");
27627
27379
  try {
27628
27380
  await ensureRunArtifactsDir(runDirectory);
27629
27381
  return { baseDir: artifactsDir };
@@ -27639,7 +27391,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
27639
27391
  const candidates = [
27640
27392
  ...preferredCandidates,
27641
27393
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
27642
- ...uniqueFallbackDirs.map((dir) => join25(dir, `${stem}.${randomUUID3()}.json`))
27394
+ ...uniqueFallbackDirs.map((dir) => join24(dir, `${stem}.${randomUUID3()}.json`))
27643
27395
  ];
27644
27396
  for (let i = 0; i < candidates.length; i += 1) {
27645
27397
  const path = candidates[i];
@@ -27684,26 +27436,26 @@ async function publishFailureArtifacts(admitted, failure, authority) {
27684
27436
  } catch (error) {
27685
27437
  priorIssues.push(publicationAttemptFromError(sessionFile, error));
27686
27438
  }
27687
- const underArtifacts = baseDir === join25(admitted.runDirectory, "artifacts");
27439
+ const underArtifacts = baseDir === join24(admitted.runDirectory, "artifacts");
27688
27440
  const uniqueFallbackDirs = uniqueFailureFallbackDirs(
27689
27441
  admitted.runDirectory,
27690
27442
  baseDir
27691
27443
  );
27692
27444
  const errorCandidates = underArtifacts ? [
27693
- join25(baseDir, "error.json"),
27694
- join25(baseDir, "error.settlement.json"),
27695
- join25(admitted.runDirectory, "error.settlement.json")
27445
+ join24(baseDir, "error.json"),
27446
+ join24(baseDir, "error.settlement.json"),
27447
+ join24(admitted.runDirectory, "error.settlement.json")
27696
27448
  ] : [
27697
- join25(baseDir, "error.settlement.json"),
27698
- join25(baseDir, "error.json")
27449
+ join24(baseDir, "error.settlement.json"),
27450
+ join24(baseDir, "error.json")
27699
27451
  ];
27700
27452
  const evidenceCandidates = underArtifacts ? [
27701
- join25(baseDir, "evidence.json"),
27702
- join25(baseDir, "evidence.settlement.json"),
27703
- join25(admitted.runDirectory, "evidence.settlement.json")
27453
+ join24(baseDir, "evidence.json"),
27454
+ join24(baseDir, "evidence.settlement.json"),
27455
+ join24(admitted.runDirectory, "evidence.settlement.json")
27704
27456
  ] : [
27705
- join25(baseDir, "evidence.settlement.json"),
27706
- join25(baseDir, "evidence.json")
27457
+ join24(baseDir, "evidence.settlement.json"),
27458
+ join24(baseDir, "evidence.json")
27707
27459
  ];
27708
27460
  const errorPayloadBase = {
27709
27461
  kind: "error",
@@ -27915,6 +27667,7 @@ var init_settlement = __esm({
27915
27667
  init_notary_contracts();
27916
27668
  init_countersign_contracts();
27917
27669
  init_gleaner_left_contracts();
27670
+ init_diarist_contracts();
27918
27671
  init_inspector_contracts();
27919
27672
  init_gatekeeper_output();
27920
27673
  init_navigator_output();
@@ -27975,7 +27728,7 @@ var init_turn_request = __esm({
27975
27728
 
27976
27729
  // src/host-transition-prior-native.ts
27977
27730
  import { access as access2, readdir as readdir6 } from "node:fs/promises";
27978
- import { dirname as dirname11, join as join26 } from "node:path";
27731
+ import { dirname as dirname11, join as join25 } from "node:path";
27979
27732
  function isEnoent2(error) {
27980
27733
  return typeof error === "object" && error !== null && error.code === "ENOENT";
27981
27734
  }
@@ -28000,7 +27753,7 @@ async function listSitianRecordPaths(sessionParent) {
28000
27753
  const recordPaths = [];
28001
27754
  for (const entry of entries) {
28002
27755
  if (!entry.isDirectory()) continue;
28003
- const recordFile = join26(sessionRoot, entry.name, "records.jsonl");
27756
+ const recordFile = join25(sessionRoot, entry.name, "records.jsonl");
28004
27757
  try {
28005
27758
  await access2(recordFile);
28006
27759
  recordPaths.push(recordFile);
@@ -28070,7 +27823,7 @@ var init_public_run_credentials = __esm({
28070
27823
  import { constants as fsConstants } from "node:fs";
28071
27824
  import { randomUUID as randomUUID4 } from "node:crypto";
28072
27825
  import { lstat as lstat5, mkdir as mkdir4, open as open2 } from "node:fs/promises";
28073
- import { join as join27 } from "node:path";
27826
+ import { join as join26 } from "node:path";
28074
27827
  function presentTerminal(terminal, io) {
28075
27828
  if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
28076
27829
  presentFailureTerminal(terminal, io);
@@ -28089,7 +27842,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
28089
27842
  }
28090
27843
  }
28091
27844
  function runArtifactsDirectory(runDirectory) {
28092
- return join27(runDirectory, "artifacts");
27845
+ return join26(runDirectory, "artifacts");
28093
27846
  }
28094
27847
  async function ensureRealArtifactsDirectory(runDirectory) {
28095
27848
  const runStat = await lstat5(runDirectory);
@@ -28172,7 +27925,7 @@ function jsonSafeReplacer() {
28172
27925
  }
28173
27926
  async function retainDispatchError(admitted, principalAuthority, sessionAppender, attempt, error) {
28174
27927
  const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
28175
- const filePath = join27(
27928
+ const filePath = join26(
28176
27929
  artifactsDir,
28177
27930
  `dispatch-error-attempt-${attempt}-${randomUUID4()}.json`
28178
27931
  );
@@ -28421,10 +28174,10 @@ var init_auto_resume = __esm({
28421
28174
  // src/public-cli/post-admission.ts
28422
28175
  import { randomUUID as randomUUID5 } from "node:crypto";
28423
28176
  import { readFile as readFile16, writeFile as writeFile8 } from "node:fs/promises";
28424
- import { isAbsolute as isAbsolute6, join as join28, resolve as resolve9 } from "node:path";
28177
+ import { isAbsolute as isAbsolute6, join as join27, resolve as resolve9 } from "node:path";
28425
28178
  async function readInvocationHost(runDirectory) {
28426
28179
  try {
28427
- const raw = JSON.parse(await readFile16(join28(runDirectory, "invocation.json"), "utf8"));
28180
+ const raw = JSON.parse(await readFile16(join27(runDirectory, "invocation.json"), "utf8"));
28428
28181
  return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
28429
28182
  } catch (error) {
28430
28183
  if (error.code === "ENOENT") return void 0;
@@ -28564,7 +28317,7 @@ async function dispatchPostAdmissionTurn(input) {
28564
28317
  }
28565
28318
  try {
28566
28319
  await writeFile8(
28567
- join28(admitted.runDirectory, "stderr.log"),
28320
+ join27(admitted.runDirectory, "stderr.log"),
28568
28321
  result2.stderr,
28569
28322
  "utf8"
28570
28323
  );
@@ -28676,7 +28429,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
28676
28429
  }
28677
28430
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
28678
28431
  const absolute = isAbsolute6(attachmentPath) ? attachmentPath : resolve9(attachmentPath);
28679
- return pathContainedIn(join28(runDirectory, "attachments"), absolute);
28432
+ return pathContainedIn(join27(runDirectory, "attachments"), absolute);
28680
28433
  }
28681
28434
  async function prepareSummonsResumeMaterials(runDirectory, summons) {
28682
28435
  if (summons === void 0) return void 0;
@@ -29479,7 +29232,6 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
29479
29232
  turnRequest,
29480
29233
  buildCountersignTurnRequest(admitted2, turnProjection)
29481
29234
  );
29482
- await runCountersignDiaristStation(admitted2, env);
29483
29235
  }
29484
29236
  }),
29485
29237
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
@@ -29518,97 +29270,219 @@ async function runPublicCountersignResume(request, env, io) {
29518
29270
  )
29519
29271
  );
29520
29272
  },
29521
- adapters: countersignAdapters({
29522
- beforeDispatch: async (admitted) => {
29523
- await runCountersignDiaristStation(admitted, env);
29524
- }
29525
- }),
29273
+ adapters: countersignAdapters(),
29526
29274
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29527
29275
  });
29528
29276
  }
29529
- async function runCountersignDiaristStation(admitted, env) {
29277
+ var init_countersign_run = __esm({
29278
+ "src/public-cli/countersign-run.ts"() {
29279
+ "use strict";
29280
+ init_engine_material();
29281
+ init_cli_errors();
29282
+ init_invocation();
29283
+ init_seat_ticket_binding();
29284
+ init_post_admission();
29285
+ init_run_lifecycle();
29286
+ init_settlement();
29287
+ init_turn_request();
29288
+ }
29289
+ });
29290
+
29291
+ // src/public-cli/diarist-run.ts
29292
+ import { existsSync as existsSync10 } from "node:fs";
29293
+ import { writeFile as writeFile9 } from "node:fs/promises";
29294
+ import { join as join28 } from "node:path";
29295
+ function withDiaristCatalogPath(prompt, sourcesPath) {
29296
+ if (sourcesPath === void 0 || sourcesPath.trim() === "") return prompt;
29297
+ return `${prompt}
29298
+
29299
+ \u5DF2\u51BB\u7ED3\u6765\u6E90\u6587\u4EF6\uFF08\u8DEF\u5F84\uFF09\uFF1A
29300
+ - ${sourcesPath}`;
29301
+ }
29302
+ function buildDiaristTurnRequest(admitted, options, sourcesPath) {
29303
+ const continuation = sourcesPath === void 0 ? options.continuation : {
29304
+ ...options.continuation,
29305
+ prompt: withDiaristCatalogPath(options.continuation.prompt, sourcesPath)
29306
+ };
29307
+ return projectRoleTurnRequest(
29308
+ admitted,
29309
+ {
29310
+ activation: {
29311
+ role: "diarist",
29312
+ ...sourcesPath === void 0 ? {} : { sourcesPath }
29313
+ }
29314
+ },
29315
+ { ...options, continuation }
29316
+ );
29317
+ }
29318
+ async function freezeDiaristSourceCatalog(admitted, env) {
29530
29319
  if (admitted.ticketNumber === void 0) return void 0;
29531
- const issueFace = await loadBoundIssueFace(admitted);
29532
- const home = tryHomeFromAkRolesPath(admitted.runDirectory);
29533
- const result2 = await runDiarist({
29320
+ const path = join28(admitted.runDirectory, DIARIST_SOURCE_CATALOG_FILE);
29321
+ if (existsSync10(path)) {
29322
+ const identity = await readRoleRunIdentity(admitted.runDirectory);
29323
+ if (identity !== void 0 && identity.state !== "terminal") return path;
29324
+ }
29325
+ const issueFace = await loadDiaristIssueFace({
29326
+ ticketNumber: admitted.ticketNumber,
29327
+ projectRoot: admitted.projectRoot,
29328
+ home: env.home
29329
+ });
29330
+ const catalog = await prepareDiaristSourceCatalog({
29534
29331
  ticketNumber: admitted.ticketNumber,
29535
29332
  cwd: admitted.projectRoot,
29536
- ...home === void 0 ? {} : { home },
29333
+ home: env.home,
29537
29334
  issueFace,
29538
- sessionCwds: [admitted.projectRoot, env.cwd],
29539
- ...env.packageRoot === void 0 ? {} : { packageRoot: env.packageRoot }
29335
+ sessionCwds: [admitted.projectRoot, env.cwd]
29540
29336
  });
29541
- return result2;
29337
+ await writeFile9(path, serializeDiaristSourceCatalog(catalog), "utf8");
29338
+ return path;
29542
29339
  }
29543
- function persistIssueSourceFailure(admitted, ticketNumber, error) {
29544
- const home = tryHomeFromAkRolesPath(admitted.runDirectory);
29545
- appendIssueSourceFailureDiagnostic({
29546
- ticketNumber,
29547
- cwd: admitted.projectRoot,
29548
- ...home === void 0 ? {} : { home },
29549
- cause: error.message,
29550
- reason: error.reason
29551
- });
29552
- throw error;
29340
+ function diaristAdapters(options) {
29341
+ return {
29342
+ trySettle: (admitted, authority, scope) => trySettleDiaristTerminalResult(admitted, authority, scope),
29343
+ shouldPresentSettled: () => true,
29344
+ ...options?.beforeDispatch === void 0 ? {} : { beforeDispatch: options.beforeDispatch }
29345
+ };
29553
29346
  }
29554
- async function loadBoundIssueFace(admitted) {
29555
- const ticketNumber = admitted.ticketNumber;
29556
- if (ticketNumber === void 0) {
29557
- throw new Error("loadBoundIssueFace requires a bound ticketNumber");
29347
+ async function runPublicDiarist(argv, env, io, parseDiaristArgv2) {
29348
+ let parsed;
29349
+ try {
29350
+ parsed = parseDiaristArgv2(argv);
29351
+ } catch (error) {
29352
+ if (error instanceof CliUsageError) {
29353
+ presentStructuralRejection(error, io);
29354
+ return { exitCode: 2 };
29355
+ }
29356
+ throw error;
29558
29357
  }
29559
- const origin = resolveDiaristGithubOrigin(admitted.projectRoot);
29560
- if (origin === void 0) {
29561
- persistIssueSourceFailure(
29562
- admitted,
29563
- ticketNumber,
29564
- new DiaristIssueSourceError(
29565
- "origin-unresolved",
29566
- `bound ticket #${ticketNumber} issue face requires a resolvable github.com origin remote`
29358
+ const projectRoot = parsed.project ?? env.cwd;
29359
+ const ticketProbe = await probeInstructionTicket(
29360
+ parsed.instruction,
29361
+ projectRoot,
29362
+ env
29363
+ );
29364
+ const probedTicketNumber = ticketNumberFromProbe(ticketProbe);
29365
+ if (probedTicketNumber !== void 0) {
29366
+ const summons = {
29367
+ instruction: parsed.instruction,
29368
+ instructionEmpty: parsed.instruction.trim() === "",
29369
+ attachmentPaths: parsed.attachmentPaths
29370
+ };
29371
+ const resumed = await tryResumeSameTicketSeatRun({
29372
+ home: env.home,
29373
+ projectRoot,
29374
+ role: "diarist",
29375
+ ticketNumber: probedTicketNumber,
29376
+ freshSummons: env.freshSummons,
29377
+ summons,
29378
+ resume: (runId, materials) => runPublicDiaristResume(
29379
+ { runId, ...materials === void 0 ? {} : { summons: materials } },
29380
+ env,
29381
+ io
29567
29382
  )
29568
- );
29383
+ });
29384
+ if (resumed !== void 0) return resumed;
29569
29385
  }
29570
- const fetcher = createDiaristIssueFaceFetcher();
29571
- let face;
29386
+ let admitted;
29572
29387
  try {
29573
- face = await fetcher({
29574
- owner: origin.owner,
29575
- repo: origin.repo,
29576
- ticketNumber
29388
+ admitted = await admitDiaristInvocation({
29389
+ home: env.home,
29390
+ principalAuthority: env.principalAuthority,
29391
+ cwd: env.cwd,
29392
+ instruction: parsed.instruction,
29393
+ attachmentPaths: parsed.attachmentPaths,
29394
+ ...parsed.project === void 0 ? {} : { project: parsed.project },
29395
+ ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
29396
+ ...env.model === void 0 ? {} : { model: env.model },
29397
+ ...env.correlationId === void 0 ? {} : { correlationId: env.correlationId }
29577
29398
  });
29578
29399
  } catch (error) {
29579
- const typed = error instanceof DiaristIssueSourceError ? error : new DiaristIssueSourceError(
29580
- "issue-unavailable",
29581
- `issue face fetch failed for ${origin.owner}/${origin.repo}#${ticketNumber}`,
29582
- { cause: error }
29583
- );
29584
- persistIssueSourceFailure(admitted, ticketNumber, typed);
29400
+ if (error instanceof CliUsageError) {
29401
+ presentStructuralRejection(error, io);
29402
+ return { exitCode: 2 };
29403
+ }
29404
+ throw error;
29585
29405
  }
29586
- if (face === void 0) {
29587
- persistIssueSourceFailure(
29588
- admitted,
29589
- ticketNumber,
29590
- new DiaristIssueSourceError(
29591
- "issue-unavailable",
29592
- `issue face unavailable for ${origin.owner}/${origin.repo}#${ticketNumber}`
29406
+ await markRunAdmitted(admitted, env.principalAuthority);
29407
+ const turnProjection = {
29408
+ packageRoot: env.packageRoot,
29409
+ home: env.home,
29410
+ agentDir: env.agentDir,
29411
+ ...env.model === void 0 ? {} : { model: env.model },
29412
+ ...env.engine === void 0 ? {} : { engine: env.engine },
29413
+ ...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
29414
+ ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
29415
+ continuation: {
29416
+ kind: "initial",
29417
+ prompt: buildInstructionTransportPrompt(
29418
+ admitted,
29419
+ engineSessionMaterialFromOptions({
29420
+ ...env.engine === void 0 ? {} : { engine: env.engine },
29421
+ packageRoot: env.packageRoot
29422
+ })
29593
29423
  )
29594
- );
29595
- }
29596
- return face;
29424
+ }
29425
+ };
29426
+ const turnRequest = buildDiaristTurnRequest(admitted, turnProjection);
29427
+ return await runPostAdmissionOneShot({
29428
+ admitted,
29429
+ env,
29430
+ io,
29431
+ request: turnRequest,
29432
+ adapters: diaristAdapters({
29433
+ beforeDispatch: async (admittedSeat) => {
29434
+ await applyInstructionTicketProbe(admittedSeat, ticketProbe);
29435
+ const sourcesPath = await freezeDiaristSourceCatalog(admittedSeat, env);
29436
+ Object.assign(
29437
+ turnRequest,
29438
+ buildDiaristTurnRequest(admittedSeat, turnProjection, sourcesPath)
29439
+ );
29440
+ }
29441
+ }),
29442
+ ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29443
+ });
29597
29444
  }
29598
- var init_countersign_run = __esm({
29599
- "src/public-cli/countersign-run.ts"() {
29445
+ async function runPublicDiaristResume(request, env, io) {
29446
+ return await runPostAdmissionSeatResume({
29447
+ request,
29448
+ env,
29449
+ io,
29450
+ load: (effective) => loadResumableDiaristRun(env.home, effective.runId, env.principalAuthority),
29451
+ buildTurnRequest: async (admitted, effective) => {
29452
+ const summonsPrepared = await prepareSummonsResumeMaterials(
29453
+ admitted.runDirectory,
29454
+ effective.summons
29455
+ );
29456
+ const sourcesPath = await freezeDiaristSourceCatalog(admitted, env);
29457
+ return buildDiaristTurnRequest(
29458
+ admitted,
29459
+ resumeTurnRequestProjectionOptions(
29460
+ admitted,
29461
+ effective,
29462
+ env,
29463
+ summonsPrepared
29464
+ ),
29465
+ sourcesPath
29466
+ );
29467
+ },
29468
+ adapters: diaristAdapters(),
29469
+ ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29470
+ });
29471
+ }
29472
+ var DIARIST_SOURCE_CATALOG_FILE;
29473
+ var init_diarist_run = __esm({
29474
+ "src/public-cli/diarist-run.ts"() {
29600
29475
  "use strict";
29601
29476
  init_diarist();
29602
- init_ticket_provenance();
29603
29477
  init_engine_material();
29604
29478
  init_cli_errors();
29605
29479
  init_invocation();
29606
29480
  init_seat_ticket_binding();
29607
- init_activation_ledger_topology();
29608
29481
  init_post_admission();
29609
29482
  init_run_lifecycle();
29610
29483
  init_settlement();
29611
29484
  init_turn_request();
29485
+ DIARIST_SOURCE_CATALOG_FILE = "diarist-sources.json";
29612
29486
  }
29613
29487
  });
29614
29488
 
@@ -30425,7 +30299,7 @@ var init_judge_run = __esm({
30425
30299
  });
30426
30300
 
30427
30301
  // src/public-cli/merger-run.ts
30428
- import { mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
30302
+ import { mkdir as mkdir5, writeFile as writeFile10 } from "node:fs/promises";
30429
30303
  import { join as join29, resolve as resolve10 } from "node:path";
30430
30304
  function mergerMethods(packageRoot2) {
30431
30305
  return [
@@ -30494,7 +30368,7 @@ async function admitMergerShellForActivationFailure(options) {
30494
30368
  };
30495
30369
  const admittedRequestPath = join29(runDirectory, "admitted-request.json");
30496
30370
  const mergerInputPath = join29(runDirectory, "merger-input.json");
30497
- await writeFile9(
30371
+ await writeFile10(
30498
30372
  admittedRequestPath,
30499
30373
  `${JSON.stringify(
30500
30374
  {
@@ -30932,13 +30806,13 @@ var init_analyst_book_key = __esm({
30932
30806
 
30933
30807
  // src/atomic-write.ts
30934
30808
  import { randomUUID as randomUUID6 } from "node:crypto";
30935
- import { rename, rm as rm2, writeFile as writeFile10 } from "node:fs/promises";
30809
+ import { rename, rm as rm2, writeFile as writeFile11 } from "node:fs/promises";
30936
30810
  import { dirname as dirname12, join as join30 } from "node:path";
30937
30811
  async function writeFileAtomically(destination, contents) {
30938
30812
  const parent = dirname12(destination);
30939
30813
  const temporary = join30(parent, `.atomic-write-${randomUUID6()}.tmp`);
30940
30814
  try {
30941
- await writeFile10(temporary, contents);
30815
+ await writeFile11(temporary, contents);
30942
30816
  await rename(temporary, destination);
30943
30817
  } catch (error) {
30944
30818
  await rm2(temporary, { force: true }).catch(() => void 0);
@@ -31292,7 +31166,7 @@ function isMissingPathError5(error) {
31292
31166
  function errorText3(error) {
31293
31167
  return error instanceof Error ? error.message : String(error);
31294
31168
  }
31295
- function isRecord18(value) {
31169
+ function isRecord17(value) {
31296
31170
  return typeof value === "object" && value !== null && !Array.isArray(value);
31297
31171
  }
31298
31172
  async function readExistingRunLifecycleState(runDirectory) {
@@ -31300,7 +31174,7 @@ async function readExistingRunLifecycleState(runDirectory) {
31300
31174
  const raw = JSON.parse(
31301
31175
  await readFile18(join32(runDirectory, "run-state.json"), "utf8")
31302
31176
  );
31303
- if (!isRecord18(raw) || typeof raw.state !== "string") return void 0;
31177
+ if (!isRecord17(raw) || typeof raw.state !== "string") return void 0;
31304
31178
  return raw.state;
31305
31179
  } catch {
31306
31180
  return void 0;
@@ -31336,7 +31210,7 @@ async function readInvocationScopeFields(runDirectory) {
31336
31210
  throw error;
31337
31211
  }
31338
31212
  const parsed = JSON.parse(raw);
31339
- if (!isRecord18(parsed)) return void 0;
31213
+ if (!isRecord17(parsed)) return void 0;
31340
31214
  if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
31341
31215
  return void 0;
31342
31216
  }
@@ -31364,7 +31238,7 @@ async function resolveSessionFile(runDirectory) {
31364
31238
  try {
31365
31239
  const raw = await readFile18(join32(runDirectory, "invocation.json"), "utf8");
31366
31240
  const parsed = JSON.parse(raw);
31367
- if (isRecord18(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
31241
+ if (isRecord17(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
31368
31242
  return parsed.sessionFile;
31369
31243
  }
31370
31244
  } catch (error) {
@@ -31669,7 +31543,7 @@ var init_analyst_ledger = __esm({
31669
31543
  });
31670
31544
 
31671
31545
  // src/analyst-metric-families/acceptance-success-rework.ts
31672
- function isRecord19(value) {
31546
+ function isRecord18(value) {
31673
31547
  return typeof value === "object" && value !== null && !Array.isArray(value);
31674
31548
  }
31675
31549
  function wallMsFromSpan(span) {
@@ -31678,21 +31552,21 @@ function wallMsFromSpan(span) {
31678
31552
  function findCollectorGroups(body) {
31679
31553
  if (Array.isArray(body.groups)) return body.groups;
31680
31554
  const receipt = body.receipt;
31681
- if (isRecord19(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
31555
+ if (isRecord18(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
31682
31556
  const outcome = body.outcome;
31683
- if (isRecord19(outcome)) {
31557
+ if (isRecord18(outcome)) {
31684
31558
  const facts = outcome.decisiveFacts;
31685
- if (isRecord19(facts) && Array.isArray(facts.groups)) return facts.groups;
31559
+ if (isRecord18(facts) && Array.isArray(facts.groups)) return facts.groups;
31686
31560
  }
31687
31561
  return void 0;
31688
31562
  }
31689
31563
  function extractStatus(body) {
31690
31564
  const outcome = body.outcome;
31691
- if (isRecord19(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
31565
+ if (isRecord18(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
31692
31566
  return outcome.status;
31693
31567
  }
31694
31568
  const receipt = body.receipt;
31695
- if (isRecord19(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
31569
+ if (isRecord18(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
31696
31570
  return receipt.status;
31697
31571
  }
31698
31572
  if (typeof body.status === "string" && body.status.trim() !== "") {
@@ -32317,21 +32191,21 @@ var init_leg_wall_clock = __esm({
32317
32191
  });
32318
32192
 
32319
32193
  // src/analyst-metric-families/round-timeline.ts
32320
- function isRecord20(value) {
32194
+ function isRecord19(value) {
32321
32195
  return typeof value === "object" && value !== null && !Array.isArray(value);
32322
32196
  }
32323
32197
  function wallMsFromSpan2(startedAt, endedAt) {
32324
32198
  return Date.parse(endedAt) - Date.parse(startedAt);
32325
32199
  }
32326
32200
  function readOutcomeStatus(body) {
32327
- if (!isRecord20(body.outcome)) return void 0;
32201
+ if (!isRecord19(body.outcome)) return void 0;
32328
32202
  const status = body.outcome.status;
32329
32203
  if (typeof status !== "string" || status.trim() === "") return void 0;
32330
32204
  return status;
32331
32205
  }
32332
32206
  function readClassCount(body) {
32333
- if (!isRecord20(body.outcome)) return void 0;
32334
- if (!isRecord20(body.outcome.decisiveFacts)) return void 0;
32207
+ if (!isRecord19(body.outcome)) return void 0;
32208
+ if (!isRecord19(body.outcome.decisiveFacts)) return void 0;
32335
32209
  const classCount = body.outcome.decisiveFacts.classCount;
32336
32210
  if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
32337
32211
  return void 0;
@@ -33773,6 +33647,28 @@ async function runAkRole(argv, env) {
33773
33647
  ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
33774
33648
  };
33775
33649
  }
33650
+ if (parsed.command === "diarist") {
33651
+ const agentDir = resolveAgentDir(env, home);
33652
+ const cwd = env.cwd ?? process.cwd();
33653
+ const config = await loadAndValidateConfig(home, env.packageRoot);
33654
+ const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
33655
+ const seat = resolveEffectiveSeat(
33656
+ config,
33657
+ "diarist",
33658
+ credentials,
33659
+ invocationFromParsed(parsed)
33660
+ );
33661
+ const result2 = await runPublicDiarist(
33662
+ parsed.args,
33663
+ createRoleEnvironment(env, { role: "diarist", home, agentDir, cwd, credentials, seat, config }),
33664
+ io,
33665
+ PUBLIC_ROLE_ARGV.diarist.parse
33666
+ );
33667
+ return {
33668
+ exitCode: result2.exitCode,
33669
+ ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
33670
+ };
33671
+ }
33776
33672
  if (parsed.command === "coder") {
33777
33673
  const agentDir = resolveAgentDir(env, home);
33778
33674
  const cwd = env.cwd ?? process.cwd();
@@ -34021,6 +33917,7 @@ var init_cli = __esm({
34021
33917
  init_instruction_seat_run();
34022
33918
  init_collector_run();
34023
33919
  init_countersign_run();
33920
+ init_diarist_run();
34024
33921
  init_gleaner_left_run();
34025
33922
  init_doctor_run();
34026
33923
  init_fixer_run();
@@ -34048,7 +33945,8 @@ var init_cli = __esm({
34048
33945
  notary: { seat: "notary", run: runPublicNotaryResume },
34049
33946
  inspector: { seat: "inspector", run: runPublicInspectorResume },
34050
33947
  gatekeeper: { seat: "gatekeeper", run: runPublicInstructionSeatResume },
34051
- navigator: { seat: "navigator", run: runPublicInstructionSeatResume }
33948
+ navigator: { seat: "navigator", run: runPublicInstructionSeatResume },
33949
+ diarist: { seat: "diarist", run: runPublicDiaristResume }
34052
33950
  };
34053
33951
  PUBLIC_ROLE_ARGV = {
34054
33952
  judge: { parse: parseJudgeArgv, options: optionsForOwner("judge") },
@@ -34064,6 +33962,7 @@ var init_cli = __esm({
34064
33962
  reviewer: { parse: parseReviewerArgv, options: optionsForOwner("reviewer") },
34065
33963
  gatekeeper: { parse: parseGatekeeperArgv, options: optionsForOwner("gatekeeper") },
34066
33964
  navigator: { parse: parseNavigatorArgv, options: optionsForOwner("navigator") },
33965
+ diarist: { parse: parseDiaristArgv, options: optionsForOwner("diarist") },
34067
33966
  /** Deterministic analysis seat (#336) — argv parse only; no LLM admission. */
34068
33967
  analyst: { parse: parseAnalystArgv, options: optionsForOwner("analyst") }
34069
33968
  };
@@ -34081,7 +33980,7 @@ var init_cli = __esm({
34081
33980
  // src/public-cli/main.ts
34082
33981
  import { existsSync as existsSync11 } from "node:fs";
34083
33982
  import { dirname as dirname15, join as join35 } from "node:path";
34084
- import { fileURLToPath as fileURLToPath4 } from "node:url";
33983
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
34085
33984
 
34086
33985
  // src/public-cli/host-pi-runtime.ts
34087
33986
  import { existsSync, lstatSync, mkdirSync, realpathSync, rmSync, symlinkSync } from "node:fs";
@@ -34167,7 +34066,7 @@ function linkPackage(packageRoot2, name, targetDir) {
34167
34066
  }
34168
34067
 
34169
34068
  // src/public-cli/main.ts
34170
- var here = dirname15(fileURLToPath4(import.meta.url));
34069
+ var here = dirname15(fileURLToPath3(import.meta.url));
34171
34070
  function resolvePackageRoot(binDir) {
34172
34071
  const canonical = join35(binDir, "..", "..");
34173
34072
  if (existsSync11(join35(canonical, "package.json"))) {