@akagilnc/pi-workflow-roles 0.1.5079 → 0.1.5122

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 (71) hide show
  1. package/dist/acp-host/production-host.js +545 -334
  2. package/dist/atomic-write.js +13 -19
  3. package/dist/auditor-soul.js +2 -1
  4. package/dist/doctor-contracts.js +1 -1
  5. package/dist/gatekeeper-role.js +2 -16
  6. package/dist/headless-host/production-host.js +577 -366
  7. package/dist/merger-contracts.js +1 -1
  8. package/dist/migrate-book-topology.js +18 -14
  9. package/dist/navigator-attendance.js +28 -143
  10. package/dist/navigator-invocation-identity.js +2 -0
  11. package/dist/navigator-public-session.js +13 -1
  12. package/dist/navigator-work-base.js +113 -0
  13. package/dist/notary-contracts.js +0 -2
  14. package/dist/package-contracts/fixer-output.js +1 -1
  15. package/dist/package-contracts/gatekeeper-output.js +1 -1
  16. package/dist/package-contracts/navigator-output.js +1 -1
  17. package/dist/package-contracts/terminating-infrastructure.js +3 -3
  18. package/dist/packaged-role-registry.js +9 -5
  19. package/dist/public-cli/cli.js +24 -1
  20. package/dist/public-cli/countersign-run.js +1 -1
  21. package/dist/public-cli/instruction-seat-run.js +8 -6
  22. package/dist/public-cli/invocation.js +6 -3
  23. package/dist/public-cli/main.js +6711 -6523
  24. package/dist/public-cli/post-admission.js +125 -26
  25. package/dist/public-cli/settlement.js +48 -5
  26. package/dist/receipt-delivery-policy.js +9 -2
  27. package/dist/review-submission.js +3 -3
  28. package/docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md +9 -0
  29. package/extensions/role-runtime.ts +0 -27
  30. package/package.json +2 -1
  31. package/resources/836-deleted-machine-instruction-inventory.md +3 -3
  32. package/resources/collector-bot-handbook.md +4 -0
  33. package/resources/navigator-route-playbook.md +4 -6
  34. package/scripts/build-package.mjs +4 -0
  35. package/souls/coder-output-guide.md +1 -0
  36. package/src/auditor-soul.ts +2 -1
  37. package/src/collector-role.ts +6 -7
  38. package/src/collector-tool-schemas.ts +5 -5
  39. package/src/diarist-role.ts +2 -2
  40. package/src/doctor-contracts.ts +1 -1
  41. package/src/gatekeeper-role.ts +1 -18
  42. package/src/gleaner-left-role.ts +2 -2
  43. package/src/inspector-role.ts +1 -1
  44. package/src/judge-role.ts +1 -1
  45. package/src/merger-contracts.ts +1 -1
  46. package/src/navigator-attendance.ts +38 -164
  47. package/src/navigator-invocation-identity.ts +2 -0
  48. package/src/navigator-public-session.ts +17 -1
  49. package/src/navigator-role.ts +4 -0
  50. package/src/navigator-session-contracts.ts +2 -0
  51. package/src/navigator-work-base.ts +123 -0
  52. package/src/notary-contracts.ts +0 -4
  53. package/src/package-contracts/fixer-output.ts +1 -1
  54. package/src/package-contracts/gatekeeper-output.ts +3 -3
  55. package/src/package-contracts/navigator-output.ts +1 -1
  56. package/src/package-contracts/terminating-infrastructure.ts +3 -6
  57. package/src/packaged-role-registry.ts +5 -1
  58. package/src/public-cli/cli-io.ts +2 -0
  59. package/src/public-cli/cli.ts +38 -4
  60. package/src/public-cli/countersign-run.ts +1 -1
  61. package/src/public-cli/instruction-seat-run.ts +10 -6
  62. package/src/public-cli/invocation.ts +12 -4
  63. package/src/public-cli/post-admission.ts +189 -34
  64. package/src/public-cli/settlement.ts +58 -4
  65. package/src/receipt-delivery-policy.ts +9 -1
  66. package/src/review-submission.ts +3 -3
  67. package/src/reviewer-role.ts +3 -3
  68. package/src/role-runtime-dependencies.ts +1 -5
  69. package/src/role-runtime.ts +52 -38
  70. package/src/secretariat-role.ts +3 -3
  71. package/src/worker-role.ts +3 -3
@@ -417,7 +417,7 @@ function normalizeReviewComment(raw) {
417
417
  function createGhApiRunner(options = {}) {
418
418
  const spawnImpl = options.spawnImpl ?? spawn;
419
419
  return async (args, runOptions = {}) => {
420
- return await new Promise((resolve21, reject) => {
420
+ return await new Promise((resolve22, reject) => {
421
421
  const signal = runOptions.signal;
422
422
  if (signal?.aborted) {
423
423
  reject(signal.reason ?? new Error("aborted"));
@@ -490,11 +490,11 @@ function createGhApiRunner(options = {}) {
490
490
  const value = line2.slice(idx + 1).trim();
491
491
  headers[name] = value;
492
492
  }
493
- resolve21({ status, headers, bodyText });
493
+ resolve22({ status, headers, bodyText });
494
494
  return;
495
495
  }
496
496
  if (code === 0) {
497
- resolve21({ status: 200, headers: {}, bodyText: stdout });
497
+ resolve22({ status: 200, headers: {}, bodyText: stdout });
498
498
  return;
499
499
  }
500
500
  const failure2 = new Error(
@@ -1179,12 +1179,12 @@ function createSystemCollectorClock() {
1179
1179
  return {
1180
1180
  wallNow: () => /* @__PURE__ */ new Date(),
1181
1181
  monoNow: () => Number(process.hrtime.bigint() - start) / 1e6,
1182
- sleep: (ms, signal) => new Promise((resolve21, reject) => {
1182
+ sleep: (ms, signal) => new Promise((resolve22, reject) => {
1183
1183
  if (signal?.aborted) {
1184
1184
  reject(signal.reason ?? new Error("aborted"));
1185
1185
  return;
1186
1186
  }
1187
- const timer = setTimeout(resolve21, ms);
1187
+ const timer = setTimeout(resolve22, ms);
1188
1188
  const onAbort = () => {
1189
1189
  clearTimeout(timer);
1190
1190
  reject(signal?.reason ?? new Error("aborted"));
@@ -2507,7 +2507,7 @@ function withTerminatingOutputDeclarations(schema) {
2507
2507
  ...baseProperties ?? {},
2508
2508
  ...baseProperties?.ticketNumber === void 0 ? {
2509
2509
  ticketNumber: Type3.Unknown({
2510
- description: "\u53EF\u9009\u672C\u7968\u53F7\uFF1A\u5C1A\u672A\u7ED1\u5B9A\u65F6\u7531\u89D2\u8272\u5728\u65E2\u6709\u56DE\u6267\u4E2D\u7533\u62A5\uFF1B\u673A\u68B0\u5C42\u53EA\u8BB0\u5F55\u5408\u6CD5\u6B63\u6574\u6570\uFF0C\u4E0D\u4ECE\u6563\u6587\u63A8\u5BFC\u3001\u4E0D\u9A8C\u771F\u3002\u7F3A\u5931\u6216\u9519\u5F62\u4E0D\u62D2\u6536\u3002"
2510
+ description: "\u53EF\u9009\u672C\u7968\u53F7\u3002\u5C1A\u672A\u7ED1\u5B9A\u65F6\u7531\u89D2\u8272\u5728\u65E2\u6709\u56DE\u6267\u4E2D\u7533\u62A5\u3002"
2511
2511
  })
2512
2512
  } : {},
2513
2513
  [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
@@ -2564,12 +2564,12 @@ var init_terminating_infrastructure = __esm({
2564
2564
  infrastructureFailureNested = Type3.Object(
2565
2565
  {
2566
2566
  [INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY]: Type3.Unknown({
2567
- description: "\u975E\u7A7A\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8BCA\u65AD\u5B57\u7B26\u4E32\u3002\u65E0\u5931\u8D25\u65F6\u5FC5\u987B\u7701\u7565\u6574\u4E2A infrastructureFailure\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
2567
+ description: "\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8BCA\u65AD\u5B57\u7B26\u4E32\u3002"
2568
2568
  })
2569
2569
  },
2570
2570
  {
2571
2571
  additionalProperties: true,
2572
- description: "\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\u58F0\u660E\uFF08\u5982\u9700\uFF09\u3002\u89C4\u8303\u5F62\uFF1A{ diagnostic: \u975E\u7A7A\u8BCA\u65AD\u5B57\u7B26\u4E32 }\uFF1B\u65E0\u5931\u8D25\u65F6\u5FC5\u987B\u7701\u7565\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
2572
+ description: "\u4EC5\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\u65F6\u51FA\u73B0\u3002"
2573
2573
  }
2574
2574
  );
2575
2575
  infrastructureFailureNested.required = [];
@@ -2594,7 +2594,7 @@ var init_gatekeeper_output = __esm({
2594
2594
  gatekeeperDecisionSchema = openToolObject(
2595
2595
  Type4.Object({
2596
2596
  status: Type4.Unknown({
2597
- description: "dispatch | pass \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
2597
+ description: "dispatch | pass"
2598
2598
  }),
2599
2599
  officer: Type4.Unknown({
2600
2600
  description: "status \u4E3A dispatch \u65F6\u4E3A inspector | notary"
@@ -2663,7 +2663,7 @@ var init_navigator_output = __esm({
2663
2663
  openToolObject(
2664
2664
  Type5.Object({
2665
2665
  prose: Type5.Unknown({
2666
- description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7B49\u7ED3\u6784\u5316\u5B57\u6BB5\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
2666
+ description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7B49\u7ED3\u6784\u5316\u5B57\u6BB5\u3002"
2667
2667
  })
2668
2668
  })
2669
2669
  )
@@ -2690,7 +2690,7 @@ var init_review_submission = __esm({
2690
2690
  Type6.Literal(REVIEW_QUEUE_WORDS[2])
2691
2691
  ],
2692
2692
  {
2693
- description: "\u5BA1\u6838\u961F\u5217\u4E09\u6001\u679A\u4E3E\uFF0C\u5FC5\u586B\u3002\u5BA1\u6838\u5E2D\u4ECD\u80FD\u4EA4\u5377\u800C\u5B8C\u6210\u5BA1\u6838\u6240\u9700\u7684\u5916\u90E8\u4F9D\u8D56\u53D1\u751F\u771F\u5B9E\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u65F6\uFF0Cstatus \u53D6 escalate\uFF0C\u7EC6\u8282\u5199\u5165 infrastructureFailure\u3002\u4E0D\u5F97\u7701\u7565 status\uFF0C\u4E0D\u5F97\u7528\u53E6\u4E24\u4E2A\u679A\u4E3E\u503C\u5145\u5F53\u653E\u884C\u6216\u5C01\u9A73\u3002\u5305\u4FA7\u4E0D\u56E0\u683C\u5F0F\u62D2\u6536\u3002"
2693
+ description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
2694
2694
  }
2695
2695
  ),
2696
2696
  findings: Type6.Optional(Type6.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
@@ -2763,7 +2763,7 @@ var init_fixer_output = __esm({
2763
2763
  });
2764
2764
  classResultSchema = Type7.Union([completedClassResultSchema, refusedClassResultSchema]);
2765
2765
  completedClassResultsSchema = Type7.Array(completedClassResultSchema);
2766
- FIXER_STATUS_DESCRIPTION = "planned | completed | refused | unfinished | partially_completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bunfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
2766
+ FIXER_STATUS_DESCRIPTION = "planned | completed | refused | unfinished | partially_completed\u3002unfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
2767
2767
  fixerOutputVariants = Type7.Union([
2768
2768
  Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
2769
2769
  Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type7.String({ description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type7.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
@@ -2923,7 +2923,7 @@ var init_doctor_contracts = __esm({
2923
2923
  Type9.Object({ targetKey: nonblank, targetKind: Type9.Optional(Type9.Union(assetKinds.map((kind) => Type9.Literal(kind)))), assetEvidence: Type9.Optional(Type9.Object({ targetKey: nonblank, targetKind: Type9.Optional(Type9.Union(assetKinds.map((kind) => Type9.Literal(kind)))), evidenceId: nonblank }, { additionalProperties: true })), ...findingBody }, { additionalProperties: true })
2924
2924
  ]);
2925
2925
  caseIdentity = Type9.Object({ issueNumber: Type9.Optional(Type9.Integer()), runsPath: nonblank }, { additionalProperties: true });
2926
- DOCTOR_STATUS_DESCRIPTION = "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bcompleted \u5141\u8BB8\u7A7A findings\uFF1Brefused \u4EC5\u5F53\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD";
2926
+ DOCTOR_STATUS_DESCRIPTION = "completed | refused\u3002completed \u5141\u8BB8\u7A7A findings\uFF1Brefused \u4EC5\u5F53\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD";
2927
2927
  doctorSubmissionVariants = Type9.Union([
2928
2928
  Type9.Object({
2929
2929
  status: Type9.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
@@ -3049,7 +3049,7 @@ var init_merger_contracts = __esm({
3049
3049
  resolutionScope: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
3050
3050
  authorizedChecks: Type10.Array(checkSchema)
3051
3051
  }, { additionalProperties: false });
3052
- MERGER_STATUS_DESCRIPTION = "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8";
3052
+ MERGER_STATUS_DESCRIPTION = "completed | escalate";
3053
3053
  mergerOutputVariants = Type10.Union([
3054
3054
  Type10.Object({ status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type10.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type10.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type10.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
3055
3055
  Type10.Object({ status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type10.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type10.String({ description: "\u5408\u5E76\u65E0\u6CD5\u6216\u4E0D\u5E94\u7531\u672C\u5E2D\u5B8C\u6210\u7684\u539F\u56E0\uFF08\u542B\u65E0\u8FDB\u884C\u4E2D\u5408\u5E76\u3001\u65E0\u6D3B\u53EF\u5E72\u3001\u9700\u65B0\u7684\u4EA7\u54C1/\u6743\u529B\u51B3\u5B9A\uFF09" }), report: Type10.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
@@ -3070,7 +3070,7 @@ var init_merger_contracts = __esm({
3070
3070
  });
3071
3071
 
3072
3072
  // src/notary-contracts.ts
3073
- var NOTARY_OUTPUT_TOOL_NAME, NOTARY_SOURCE_RUN_FLAG, NOTARY_TICKET_FLAG, NOTARY_FIXED_KICKOFF, notaryOutputSchema;
3073
+ var NOTARY_OUTPUT_TOOL_NAME, NOTARY_SOURCE_RUN_FLAG, NOTARY_TICKET_FLAG, notaryOutputSchema;
3074
3074
  var init_notary_contracts = __esm({
3075
3075
  "src/notary-contracts.ts"() {
3076
3076
  "use strict";
@@ -3090,7 +3090,6 @@ var init_notary_contracts = __esm({
3090
3090
  type: "string"
3091
3091
  }
3092
3092
  };
3093
- NOTARY_FIXED_KICKOFF = "\u7B26\u5B9D\u90CE\u6848\u5377\u5DF2\u53D7\u7406\uFF1B\u6765\u6E90 run \u5B9A\u4F4D\u89C1\u4F1A\u8BDD\u6750\u6599\u3002";
3094
3093
  notaryOutputSchema = reviewSubmissionSchema;
3095
3094
  }
3096
3095
  });
@@ -3587,21 +3586,24 @@ var init_packaged_role_registry = __esm({
3587
3586
  "souls/notary.md",
3588
3587
  "souls/audit-law.md",
3589
3588
  "souls/ticket-law.md",
3590
- "souls/gate-output-guide.md"
3589
+ "souls/gate-output-guide.md",
3590
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3591
3591
  ];
3592
3592
  INSPECTOR_SESSION_MATERIALS = [
3593
3593
  "CLAUDE.md",
3594
3594
  "souls/inspector.md",
3595
3595
  "souls/audit-law.md",
3596
3596
  "souls/quality-law.md",
3597
- "souls/gate-output-guide.md"
3597
+ "souls/gate-output-guide.md",
3598
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3598
3599
  ];
3599
3600
  AUDITOR_PUBLIC_SESSION_MATERIALS = [
3600
3601
  "CLAUDE.md",
3601
3602
  "souls/judge-auditor.md",
3602
3603
  "souls/doctor-auditor.md",
3603
3604
  "souls/audit-law.md",
3604
- "souls/quality-law.md"
3605
+ "souls/quality-law.md",
3606
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3605
3607
  ];
3606
3608
  PUBLIC_ROLE_RECORDS = [
3607
3609
  {
@@ -3629,7 +3631,8 @@ var init_packaged_role_registry = __esm({
3629
3631
  "souls/judge.md",
3630
3632
  "souls/audit-law.md",
3631
3633
  "souls/quality-law.md",
3632
- "souls/judge-output-guide.md"
3634
+ "souls/judge-output-guide.md",
3635
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3633
3636
  ]
3634
3637
  },
3635
3638
  {
@@ -3907,7 +3910,7 @@ var init_packaged_role_registry = __esm({
3907
3910
  activationStage: "load-and-install",
3908
3911
  receiptStatusKey: "status",
3909
3912
  // #924: 公用《票面法》三席同装
3910
- sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md"]
3913
+ sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md", "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"]
3911
3914
  },
3912
3915
  {
3913
3916
  role: "secretariat",
@@ -4443,7 +4446,7 @@ var init_gatekeeper_role = __esm({
4443
4446
  GATEKEEPER_TOOL_SPEC = {
4444
4447
  name: GATEKEEPER_OUTPUT_TOOL_NAME,
4445
4448
  label: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
4446
- description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\uFF0C\u72B6\u6001\u4E3A dispatch \u6216 pass\u3002",
4449
+ description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\u3002status \u4E3A dispatch \u6216 pass\u3002",
4447
4450
  promptSnippet: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
4448
4451
  parameters: gatekeeperOutputSchema
4449
4452
  };
@@ -4567,10 +4570,10 @@ __export(session_assistant_usage_exports, {
4567
4570
  });
4568
4571
  import { join as join6 } from "node:path";
4569
4572
  async function readAssistantUsageFromSessionFile(sessionFile) {
4570
- const { readFile: readFile25 } = await import("node:fs/promises");
4573
+ const { readFile: readFile26 } = await import("node:fs/promises");
4571
4574
  let text;
4572
4575
  try {
4573
- text = await readFile25(sessionFile, "utf8");
4576
+ text = await readFile26(sessionFile, "utf8");
4574
4577
  } catch (error) {
4575
4578
  if (error?.code === "ENOENT") return void 0;
4576
4579
  throw error;
@@ -4969,7 +4972,7 @@ async function spawnEngineDetourOnce(input) {
4969
4972
  }
4970
4973
  const command = input.argv[0];
4971
4974
  const args = input.argv.slice(1);
4972
- return await new Promise((resolve21, reject) => {
4975
+ return await new Promise((resolve22, reject) => {
4973
4976
  let settled = false;
4974
4977
  const signal = input.signal;
4975
4978
  const child = spawn2(command, args, {
@@ -4999,7 +5002,7 @@ async function spawnEngineDetourOnce(input) {
4999
5002
  if (signal !== void 0) {
5000
5003
  signal.removeEventListener("abort", onAbort);
5001
5004
  }
5002
- resolve21(result);
5005
+ resolve22(result);
5003
5006
  };
5004
5007
  const onAbort = () => {
5005
5008
  fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
@@ -11259,13 +11262,16 @@ function admittedTransportPromptKind(admitted) {
11259
11262
  function buildInstructionTransportPrompt(admitted, engineMaterial) {
11260
11263
  const kind = admittedTransportPromptKind(admitted);
11261
11264
  if (kind === "fixed-kickoff") {
11262
- return appendEngineSessionMaterial([NOTARY_FIXED_KICKOFF], engineMaterial).join("\n");
11265
+ if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
11266
+ throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
11267
+ }
11268
+ return appendEngineSessionMaterial([admitted.sourceRunPath], engineMaterial).join("\n");
11263
11269
  }
11264
11270
  if (kind === "baseline") {
11265
11271
  if (admitted.baseRevision === void 0) {
11266
11272
  throw new Error("baseline transport prompt is missing the bound revision");
11267
11273
  }
11268
- const lines2 = [`\u5DE6\u62FE\u9057\u6848\u5DF2\u53D7\u7406\u3002\u6BD4\u8F83\u57FA\u7EBF\uFF1A${admitted.baseRevision}`];
11274
+ const lines2 = [admitted.baseRevision];
11269
11275
  if (!admitted.instructionEmpty) {
11270
11276
  lines2.push("", admitted.instruction);
11271
11277
  }
@@ -12846,10 +12852,10 @@ function pairGateRounds(volumes) {
12846
12852
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
12847
12853
  }
12848
12854
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
12849
- const { readFile: readFile25 } = await import("node:fs/promises");
12855
+ const { readFile: readFile26 } = await import("node:fs/promises");
12850
12856
  let raw;
12851
12857
  try {
12852
- raw = JSON.parse(await readFile25(pointerPath, "utf8"));
12858
+ raw = JSON.parse(await readFile26(pointerPath, "utf8"));
12853
12859
  } catch (error) {
12854
12860
  throw new Error(
12855
12861
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
@@ -13604,9 +13610,10 @@ var init_auditor_soul = __esm({
13604
13610
  "CLAUDE.md",
13605
13611
  "souls/judge-auditor.md",
13606
13612
  "souls/audit-law.md",
13607
- "souls/quality-law.md"
13613
+ "souls/quality-law.md",
13614
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
13608
13615
  ],
13609
- doctor: ["CLAUDE.md", "souls/doctor-auditor.md"]
13616
+ doctor: ["CLAUDE.md", "souls/doctor-auditor.md", "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"]
13610
13617
  };
13611
13618
  }
13612
13619
  });
@@ -14135,7 +14142,7 @@ function resolveLifecycleInvocationPrincipal(entries, expected) {
14135
14142
  }
14136
14143
  return { invocationId: marker.invocationId, resume: true };
14137
14144
  }
14138
- var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS, PACKAGED_ROLE_OUTPUT_TOOLS;
14145
+ var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS, PACKAGED_ROLE_OUTPUT_TOOLS;
14139
14146
  var init_navigator_invocation_identity = __esm({
14140
14147
  "src/navigator-invocation-identity.ts"() {
14141
14148
  "use strict";
@@ -14143,6 +14150,7 @@ var init_navigator_invocation_identity = __esm({
14143
14150
  init_uuidv7();
14144
14151
  init_work_subject_identity();
14145
14152
  NAVIGATOR_INVOCATION_ENTRY = "ak-navigator-invocation";
14153
+ NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY = "ak-navigator-route-playbook-failure";
14146
14154
  NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND = "role_infrastructure_failure";
14147
14155
  NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS = [
14148
14156
  "kind",
@@ -14236,17 +14244,25 @@ function createReceiptDeliveryPolicy() {
14236
14244
  if (accepted) return "accepted";
14237
14245
  return deliveryTurns < RECEIPT_DELIVERY_TURN_LIMIT ? "request-delivery" : "no-receipt";
14238
14246
  },
14247
+ /** Current typed delivery facts. No prose. */
14248
+ deliveryState() {
14249
+ return {
14250
+ terminalToolCalled,
14251
+ rejectedReceipts: rejectedReceipts.map((item) => ({ ...item })),
14252
+ deliveryTurns,
14253
+ acceptedReceipt: false
14254
+ };
14255
+ },
14239
14256
  facts(binding) {
14240
14257
  return noReceiptLifecycleFacts({ terminalToolCalled, rejectedReceipts: [...rejectedReceipts], deliveryTurns, ...binding });
14241
14258
  }
14242
14259
  };
14243
14260
  }
14244
- var RECEIPT_DELIVERY_TURN_LIMIT, RECEIPT_DELIVERY_PROMPT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
14261
+ var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
14245
14262
  var init_receipt_delivery_policy = __esm({
14246
14263
  "src/receipt-delivery-policy.ts"() {
14247
14264
  "use strict";
14248
14265
  RECEIPT_DELIVERY_TURN_LIMIT = 2;
14249
- RECEIPT_DELIVERY_PROMPT = "\u672C\u4F1A\u8BDD\u5C1A\u65E0\u5DF2\u63A5\u53D7\u7684 typed \u56DE\u6267\u3002";
14250
14266
  NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
14251
14267
  }
14252
14268
  });
@@ -14282,6 +14298,7 @@ __export(settlement_exports, {
14282
14298
  projectThrownFailureLeaf: () => projectThrownFailureLeaf,
14283
14299
  publishFailureArtifacts: () => publishFailureArtifacts,
14284
14300
  publishSeatAcceptedArtifacts: () => publishSeatAcceptedArtifacts,
14301
+ publishedFailureErrorPath: () => publishedFailureErrorPath,
14285
14302
  raceNavigatorGrace: () => raceNavigatorGrace,
14286
14303
  readCollectorInfrastructureFailure: () => readCollectorInfrastructureFailure,
14287
14304
  readEngineDetourInfrastructureFailure: () => readEngineDetourInfrastructureFailure,
@@ -14290,6 +14307,7 @@ __export(settlement_exports, {
14290
14307
  resolveAuditedRunnerFailureResolution: () => resolveAuditedRunnerFailureResolution,
14291
14308
  resolveAuditedRunnerKnownFailure: () => resolveAuditedRunnerKnownFailure,
14292
14309
  resolveControlledFailureResumeObservation: () => resolveControlledFailureResumeObservation,
14310
+ rewritePublishedFailureErrorPath: () => rewritePublishedFailureErrorPath,
14293
14311
  seatKnownFailureResolver: () => seatKnownFailureResolver,
14294
14312
  settleFailureTerminalResult: () => settleFailureTerminalResult,
14295
14313
  settleHostEndedNoReceipt: () => settleHostEndedNoReceipt,
@@ -14383,10 +14401,13 @@ function withSubmissions(terminal, submissions) {
14383
14401
  }
14384
14402
  async function attachRecordedSubmissions(admitted, terminal, scope) {
14385
14403
  void scope;
14386
- return withSubmissions(
14404
+ const result = withSubmissions(
14387
14405
  terminal,
14388
14406
  await recordedSubmissionPayloads(admitted, void 0)
14389
14407
  );
14408
+ const errorPath = privateFailureErrorPaths.get(terminal);
14409
+ if (errorPath !== void 0) privateFailureErrorPaths.set(result, errorPath);
14410
+ return result;
14390
14411
  }
14391
14412
  async function settleHostEndedNoReceipt(admitted, authority, scope) {
14392
14413
  const facts = noReceiptLifecycleFacts({
@@ -14418,6 +14439,18 @@ async function settleHostEndedNoReceipt(admitted, authority, scope) {
14418
14439
  function coordinatesFromAdmitted(authority, admitted) {
14419
14440
  return authority.decode(admitted.principal);
14420
14441
  }
14442
+ function publishedFailureErrorPath(terminal) {
14443
+ return privateFailureErrorPaths.get(terminal);
14444
+ }
14445
+ function rewritePublishedFailureErrorPath(terminal, oldRunDirectory, newRunDirectory) {
14446
+ const errorPath = privateFailureErrorPaths.get(terminal);
14447
+ if (errorPath !== void 0) {
14448
+ privateFailureErrorPaths.set(
14449
+ terminal,
14450
+ rewriteRunDirectoryPathValue(errorPath, oldRunDirectory, newRunDirectory)
14451
+ );
14452
+ }
14453
+ }
14421
14454
  function conciseChildDiagnostic(stderr, fallback) {
14422
14455
  const trimmed = stderr.trim();
14423
14456
  return trimmed.length > 0 ? stderr : fallback;
@@ -15367,7 +15400,23 @@ async function withOptionalGateProjection(base, sessionDirectory, gateContext =
15367
15400
  }
15368
15401
  return attachEngineDetourToolUsage(next, sessionDirectory, gateContext);
15369
15402
  }
15403
+ function routePlaybookFailureMessage(entries) {
15404
+ for (let i = entries.length - 1; i >= 0; i -= 1) {
15405
+ const entry = entries[i];
15406
+ if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
15407
+ const data = entry.data;
15408
+ if (!isRecord12(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
15409
+ return data.message;
15410
+ }
15411
+ return void 0;
15412
+ }
15370
15413
  function extractNavigatorFact(entries) {
15414
+ const fact = extractNavigatorAttendanceFact(entries);
15415
+ if (fact.advisoryDiagnostic !== void 0) return fact;
15416
+ const message = routePlaybookFailureMessage(entries);
15417
+ return message === void 0 ? fact : { ...fact, advisoryDiagnostic: message };
15418
+ }
15419
+ function extractNavigatorAttendanceFact(entries) {
15371
15420
  const terminal = findLatestDurablePackagedRoleTerminal(entries);
15372
15421
  if (terminal === void 0) {
15373
15422
  return {
@@ -15923,7 +15972,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
15923
15972
  error.publicationAttempts = issues;
15924
15973
  throw error;
15925
15974
  }
15926
- async function publishFailureArtifacts(admitted, failure2, authority) {
15975
+ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPublished) {
15927
15976
  const { sessionDirectory, sessionFile } = coordinatesFromAdmitted(authority, admitted);
15928
15977
  const { baseDir, attempt: baseAttempt } = await resolveFailureArtifactsBase(
15929
15978
  admitted.runDirectory
@@ -15985,6 +16034,7 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
15985
16034
  errorPayloadBase,
15986
16035
  priorIssues
15987
16036
  );
16037
+ onErrorPublished?.(errorWrite.path);
15988
16038
  const evidencePayload = {
15989
16039
  runId: admitted.runId,
15990
16040
  sessionDirectory,
@@ -16067,7 +16117,8 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
16067
16117
  }
16068
16118
  }
16069
16119
  const navigator = await extractNavigatorFactFromAdmittedSession(sessionFile);
16070
- const artifacts = await publishFailureArtifacts(admitted, failure2, authority);
16120
+ const artifacts = await publishFailureArtifacts(admitted, failure2, authority, options.onErrorPublished);
16121
+ const errorPath = artifacts.find((artifact) => artifact.kind === "error")?.path;
16071
16122
  const decisiveFacts = {
16072
16123
  ...failure2.cause === void 0 ? {} : { cause: failure2.cause },
16073
16124
  diagnostic: failure2.diagnostic
@@ -16089,7 +16140,7 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
16089
16140
  diagnostic: failure2.diagnostic,
16090
16141
  decisiveFacts
16091
16142
  };
16092
- return withOptionalGateProjection(
16143
+ const terminal = await withOptionalGateProjection(
16093
16144
  {
16094
16145
  roleOutcome: roleOutcome2,
16095
16146
  navigator,
@@ -16099,6 +16150,8 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
16099
16150
  sessionDirectory,
16100
16151
  detourGateContext(admitted, options)
16101
16152
  );
16153
+ if (errorPath !== void 0) privateFailureErrorPaths.set(terminal, errorPath);
16154
+ return terminal;
16102
16155
  }
16103
16156
  const roleOutcome = {
16104
16157
  kind: "failure",
@@ -16127,6 +16180,7 @@ function presentFailureTerminal(terminal, io) {
16127
16180
  }
16128
16181
  io.stdout(formatTerminalResult(terminal));
16129
16182
  if (terminal.roleOutcome.kind === "failure") {
16183
+ if (io.omitFailureStderrDiagnostic) return;
16130
16184
  io.stderr(formatFailureStderrDiagnostic({
16131
16185
  ...terminal.roleOutcome.cause === void 0 ? {} : { cause: terminal.roleOutcome.cause },
16132
16186
  diagnostic: terminal.roleOutcome.diagnostic
@@ -16143,10 +16197,10 @@ function presentFailureTerminal(terminal, io) {
16143
16197
  }
16144
16198
  function defaultNavigatorGraceSleep() {
16145
16199
  let timer;
16146
- const sleep2 = ((ms) => new Promise((resolve21) => {
16200
+ const sleep2 = ((ms) => new Promise((resolve22) => {
16147
16201
  timer = setTimeout(() => {
16148
16202
  timer = void 0;
16149
- resolve21();
16203
+ resolve22();
16150
16204
  }, ms);
16151
16205
  }));
16152
16206
  sleep2.cancel = () => {
@@ -16158,7 +16212,7 @@ function defaultNavigatorGraceSleep() {
16158
16212
  return sleep2;
16159
16213
  }
16160
16214
  function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
16161
- return new Promise((resolve21, reject) => {
16215
+ return new Promise((resolve22, reject) => {
16162
16216
  let settled = false;
16163
16217
  const finish = (action) => {
16164
16218
  if (settled) return;
@@ -16167,15 +16221,15 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
16167
16221
  action();
16168
16222
  };
16169
16223
  void work.then(
16170
- (value) => finish(() => resolve21({ status: "done", value })),
16224
+ (value) => finish(() => resolve22({ status: "done", value })),
16171
16225
  (error) => finish(() => reject(error))
16172
16226
  );
16173
16227
  void sleep2(graceMs).then(() => {
16174
- finish(() => resolve21({ status: "timeout" }));
16228
+ finish(() => resolve22({ status: "timeout" }));
16175
16229
  });
16176
16230
  });
16177
16231
  }
16178
- var NAVIGATOR_POST_ROLE_GRACE_MS, COLLECTOR_INFRASTRUCTURE_TOOLS, COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC, ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC, RUNNER_FAILURE_POLICY, ATTEMPT_HISTORY_ENTRY_TYPE, EMPTY_ARTIFACT_FACE;
16232
+ var privateFailureErrorPaths, NAVIGATOR_POST_ROLE_GRACE_MS, COLLECTOR_INFRASTRUCTURE_TOOLS, COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC, ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC, RUNNER_FAILURE_POLICY, ATTEMPT_HISTORY_ENTRY_TYPE, EMPTY_ARTIFACT_FACE;
16179
16233
  var init_settlement = __esm({
16180
16234
  "src/public-cli/settlement.ts"() {
16181
16235
  "use strict";
@@ -16202,9 +16256,11 @@ var init_settlement = __esm({
16202
16256
  init_navigator_invocation_identity();
16203
16257
  init_receipt_delivery_policy();
16204
16258
  init_role_run_placement();
16259
+ init_role_run_relocation();
16205
16260
  init_run_terminal_artifacts();
16206
16261
  init_invocation();
16207
16262
  init_terminal();
16263
+ privateFailureErrorPaths = /* @__PURE__ */ new WeakMap();
16208
16264
  NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
16209
16265
  COLLECTOR_INFRASTRUCTURE_TOOLS = /* @__PURE__ */ new Set([
16210
16266
  COLLECTOR_OBSERVE_TOOL,
@@ -16847,6 +16903,11 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
16847
16903
  }
16848
16904
  }
16849
16905
  if (result.terminal !== void 0) {
16906
+ rewritePublishedFailureErrorPath(
16907
+ result.terminal,
16908
+ relocation.oldRunDirectory,
16909
+ relocation.newRunDirectory
16910
+ );
16850
16911
  for (const artifact of result.terminal.artifacts) {
16851
16912
  artifact.path = rewrite(artifact.path);
16852
16913
  }
@@ -16960,18 +17021,23 @@ async function presentControlledFailure2(admitted, failureInput, adapters, autho
16960
17021
  if (persistRunState && !failureInput.skipRunStateWrite) {
16961
17022
  await persistReturnedRunState(admitted, authority);
16962
17023
  }
16963
- const terminal = await attachRecordedSubmissions(
16964
- admitted,
16965
- await settleFailureTerminalResult(
16966
- admitted,
16967
- failure2,
16968
- authority,
16969
- {
16970
- ...resumable ? { resume: { command: renderResumeCommand(admitted.runId) } } : {},
16971
- ...failureInput.invocationScopeId === void 0 || failureInput.invocationScopeId.length === 0 ? {} : { invocationScopeId: failureInput.invocationScopeId }
17024
+ let publishedErrorPath;
17025
+ let terminal;
17026
+ try {
17027
+ const settled = await settleFailureTerminalResult(admitted, failure2, authority, {
17028
+ ...resumable ? { resume: { command: renderResumeCommand(admitted.runId) } } : {},
17029
+ ...failureInput.invocationScopeId === void 0 || failureInput.invocationScopeId.length === 0 ? {} : { invocationScopeId: failureInput.invocationScopeId },
17030
+ onErrorPublished: (path) => {
17031
+ publishedErrorPath = path;
16972
17032
  }
16973
- )
16974
- );
17033
+ });
17034
+ terminal = await attachRecordedSubmissions(admitted, settled);
17035
+ } catch (error) {
17036
+ if (io.omitFailureStderrDiagnostic && publishedErrorPath !== void 0) {
17037
+ writeResumeFailurePointer(io, publishedErrorPath);
17038
+ }
17039
+ throw error;
17040
+ }
16975
17041
  presentFailureTerminal(terminal, io);
16976
17042
  return {
16977
17043
  exitCode: exitCodeForTerminalOutcome(terminal.roleOutcome),
@@ -17065,7 +17131,10 @@ async function dispatchPostAdmissionTurn(input) {
17065
17131
  if (relocation !== void 0) {
17066
17132
  projectRelocatedTurnIdentity(request, result, admitted, relocation);
17067
17133
  }
17068
- if (adapters.afterDispatch !== void 0) await adapters.afterDispatch(admitted, lease);
17134
+ const afterDispatchRelocation = adapters.afterDispatch === void 0 ? void 0 : await adapters.afterDispatch(admitted, lease);
17135
+ if (afterDispatchRelocation !== void 0) {
17136
+ projectRelocatedTurnIdentity(request, result, admitted, afterDispatchRelocation);
17137
+ }
17069
17138
  return result;
17070
17139
  } catch (error) {
17071
17140
  if (result.terminal !== void 0) {
@@ -17512,16 +17581,28 @@ async function runPostAdmissionSeatResume(input) {
17512
17581
  try {
17513
17582
  loaded = await input.load(request);
17514
17583
  } catch (error) {
17515
- if (error instanceof CliUsageError) {
17516
- presentStructuralRejection(error, input.io);
17517
- return { exitCode: 2 };
17584
+ const usageError = error instanceof CliUsageError;
17585
+ const recorded = await pointExistingRunFailure(
17586
+ input.env.home,
17587
+ request.runId,
17588
+ input.env.principalAuthority,
17589
+ input.io,
17590
+ error
17591
+ );
17592
+ if (!recorded) {
17593
+ if (usageError) {
17594
+ presentStructuralRejection(error, input.io);
17595
+ return { exitCode: 2 };
17596
+ }
17597
+ throw error;
17518
17598
  }
17519
- throw error;
17599
+ return { exitCode: usageError ? 2 : 1 };
17520
17600
  }
17521
17601
  let adapters = input.adapters;
17522
17602
  if (input.afterAdmittedLoad !== void 0) {
17523
17603
  const prepared = await input.afterAdmittedLoad(loaded.admitted);
17524
17604
  if (prepared.kind === "terminal") {
17605
+ showResumeErrorPointer(input.io, prepared.exitCode, prepared.terminal);
17525
17606
  return {
17526
17607
  exitCode: prepared.exitCode,
17527
17608
  admitted: prepared.admitted,
@@ -17647,22 +17728,110 @@ async function runPostAdmissionSeatResume(input) {
17647
17728
  })
17648
17729
  });
17649
17730
  }
17650
- return await runPostAdmissionManualResume({
17731
+ const resumed = await runPostAdmissionManualResume({
17651
17732
  admitted: loaded.admitted,
17652
17733
  env,
17653
- io: input.io,
17734
+ io: { ...input.io, omitFailureStderrDiagnostic: true },
17654
17735
  adapters,
17655
17736
  ...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
17656
17737
  buildRequestAfterLease
17657
17738
  });
17739
+ showResumeErrorPointer(input.io, resumed.exitCode, resumed.terminal);
17740
+ return resumed;
17658
17741
  } catch (error) {
17659
- if (error instanceof CliUsageError) {
17660
- presentStructuralRejection(error, input.io);
17661
- return { exitCode: 2 };
17742
+ if (error instanceof TurnDispatchedFailure) throw error;
17743
+ await presentResumeFailurePointer(
17744
+ input.io,
17745
+ error,
17746
+ (failure2) => writeResumeDiagnosticFile(
17747
+ loaded.admitted.runDirectory,
17748
+ loaded.admitted.runId,
17749
+ failure2,
17750
+ loaded.admitted.role
17751
+ )
17752
+ );
17753
+ return { exitCode: error instanceof CliUsageError ? 2 : 1 };
17754
+ }
17755
+ }
17756
+ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
17757
+ let foundRunDirectory;
17758
+ try {
17759
+ foundRunDirectory = await findRunDirectoryById(home, runId);
17760
+ } catch {
17761
+ return false;
17762
+ }
17763
+ if (foundRunDirectory === void 0) return false;
17764
+ const runDirectory = foundRunDirectory;
17765
+ let record4;
17766
+ try {
17767
+ record4 = await readRoleRunState(runDirectory, authority);
17768
+ } catch {
17769
+ await presentResumeFailurePointer(
17770
+ io,
17771
+ thrown,
17772
+ (failure2) => writeResumeDiagnosticFile(runDirectory, runId, failure2)
17773
+ );
17774
+ return true;
17775
+ }
17776
+ if (record4 === void 0) return false;
17777
+ await presentResumeFailurePointer(
17778
+ io,
17779
+ thrown,
17780
+ (failure2) => writeResumeDiagnosticFile(runDirectory, runId, failure2, record4.role)
17781
+ );
17782
+ return true;
17783
+ }
17784
+ async function presentLocatedResumeFailure(home, runId, authority, io, thrown) {
17785
+ return await pointExistingRunFailure(home, runId, authority, io, thrown);
17786
+ }
17787
+ function writeResumeFailurePointer(io, errorPath) {
17788
+ io.stderr(formatCliDiagnostic(`\u7EED\u8DD1\u5931\u8D25\uFF0C\u5F53\u6B21\u9519\u8BEF\u8BB0\u5F55\uFF1A${errorPath}`));
17789
+ }
17790
+ function showResumeErrorPointer(io, exitCode, terminal) {
17791
+ if (exitCode === 0 || terminal === void 0) return;
17792
+ const publishedError = terminal.artifacts.find((artifact) => artifact.kind === "error")?.path ?? publishedFailureErrorPath(terminal);
17793
+ if (publishedError !== void 0) writeResumeFailurePointer(io, publishedError);
17794
+ }
17795
+ async function presentResumeFailurePointer(io, thrown, publish) {
17796
+ const failure2 = classifyPostAdmissionFailure({
17797
+ timedOut: false,
17798
+ code: null,
17799
+ stderr: "",
17800
+ thrown
17801
+ });
17802
+ try {
17803
+ writeResumeFailurePointer(io, await publish(failure2));
17804
+ } catch (publishError) {
17805
+ const cause = {
17806
+ publishError: formatErrorCauseDetail(publishError)
17807
+ };
17808
+ if (thrown instanceof Error && thrown.cause !== void 0) {
17809
+ cause.thrownCause = formatErrorCauseDetail(thrown.cause);
17662
17810
  }
17663
- throw error;
17811
+ presentStructuralRejection({
17812
+ message: thrown instanceof Error ? thrown.message : String(thrown),
17813
+ cause
17814
+ }, io);
17664
17815
  }
17665
17816
  }
17817
+ async function writeResumeDiagnosticFile(runDirectory, runId, failure2, role) {
17818
+ const dir = await ensureRealArtifactsDirectory(runDirectory);
17819
+ const path = join31(dir, `resume-diagnostic-${randomUUID6()}.json`);
17820
+ await writeFile9(
17821
+ path,
17822
+ `${JSON.stringify({
17823
+ runId,
17824
+ ...role === void 0 ? {} : { role },
17825
+ diagnostic: failure2.diagnostic,
17826
+ ...failure2.cause === void 0 ? {} : { cause: failure2.cause },
17827
+ ...failure2.identity === void 0 ? {} : { identity: failure2.identity },
17828
+ ...failure2.details === void 0 ? {} : { details: failure2.details }
17829
+ }, null, 2)}
17830
+ `,
17831
+ { encoding: "utf8", flag: "wx" }
17832
+ );
17833
+ return path;
17834
+ }
17666
17835
  async function runPostAdmissionOneShot(input) {
17667
17836
  return await runPostAdmissionResumable({
17668
17837
  admitted: input.admitted,
@@ -18214,7 +18383,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io, afterTicketN
18214
18383
  for (const ticketNumber of refreshTickets.slice(completedIndex + 1)) {
18215
18384
  const outcome = await invokeCourtDiarist(
18216
18385
  {
18217
- instruction: `\u6574\u7406 #${ticketNumber} \u7684\u672C\u6848\u4F9D\u636E\u3002`,
18386
+ instruction: admitted.instruction,
18218
18387
  projectRoot: admitted.projectRoot,
18219
18388
  failureLabel: `ticket #${ticketNumber}`,
18220
18389
  correlationId: admitted.runId,
@@ -18293,11 +18462,11 @@ function isBoardTicketSeat(seat) {
18293
18462
  }
18294
18463
  async function bindAndRelocateDiarist(admitted, authority, lease) {
18295
18464
  const boardTicket = await readBoardTicketNumber(admitted.runDirectory);
18296
- if (boardTicket === void 0) return;
18465
+ if (boardTicket === void 0) return void 0;
18297
18466
  if (admitted.ticketNumber === void 0) {
18298
18467
  await bindAdmittedTicketNumber(admitted, boardTicket);
18299
18468
  }
18300
- await relocateAdmittedRunToTicket(admitted, authority, lease);
18469
+ return await relocateAdmittedRunToTicket(admitted, authority, lease);
18301
18470
  }
18302
18471
  function seatAdapters(admitted, env) {
18303
18472
  const record4 = roleRecord(admitted.role);
@@ -18316,8 +18485,8 @@ function seatAdapters(admitted, env) {
18316
18485
  await bindAndRelocateDiarist(seat, env.principalAuthority, lease);
18317
18486
  },
18318
18487
  afterDispatch: async (seat, lease) => {
18319
- if (!isBoardTicketSeat(seat)) return;
18320
- await bindAndRelocateDiarist(seat, env.principalAuthority, lease);
18488
+ if (!isBoardTicketSeat(seat)) return void 0;
18489
+ return await bindAndRelocateDiarist(seat, env.principalAuthority, lease);
18321
18490
  }
18322
18491
  } : {}
18323
18492
  };
@@ -18879,7 +19048,9 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
18879
19048
  return { exitCode: 0, admitted, terminal: refresh.terminal };
18880
19049
  }
18881
19050
  }
18882
- return dispatchAdmitted(admitted, env, io);
19051
+ const result = await dispatchAdmitted(admitted, env, { ...io, omitFailureStderrDiagnostic: true });
19052
+ showResumeErrorPointer(io, result.exitCode, result.terminal);
19053
+ return result;
18883
19054
  }
18884
19055
  var init_instruction_seat_run = __esm({
18885
19056
  "src/public-cli/instruction-seat-run.ts"() {
@@ -18961,8 +19132,8 @@ var init_atomic_write = __esm({
18961
19132
  import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
18962
19133
  import { dirname as dirname18, join as join34 } from "node:path";
18963
19134
  function sleep(ms) {
18964
- return new Promise((resolve21) => {
18965
- setTimeout(resolve21, ms);
19135
+ return new Promise((resolve22) => {
19136
+ setTimeout(resolve22, ms);
18966
19137
  });
18967
19138
  }
18968
19139
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
@@ -21746,6 +21917,7 @@ function commandNeedsProcessCancel(argv) {
21746
21917
  }
21747
21918
  async function runAkRole(argv, env) {
21748
21919
  const io = env.io ?? defaultIo();
21920
+ let resumeFailureContext;
21749
21921
  try {
21750
21922
  env = {
21751
21923
  ...env,
@@ -21818,11 +21990,16 @@ async function runAkRole(argv, env) {
21818
21990
  env = { ...env, freshSummons: true };
21819
21991
  }
21820
21992
  if (parsed.command === "resume") {
21993
+ const resumeRequest = parseResumeRequest(parsed.args);
21994
+ resumeFailureContext = {
21995
+ home,
21996
+ runId: resumeRequest.runId,
21997
+ authority: env.principalAuthority ?? piDurablePrincipalAuthority
21998
+ };
21821
21999
  const agentDir = resolveAgentDir(env, home);
21822
22000
  const cwd = env.cwd ?? process.cwd();
21823
22001
  const config = await loadAndValidateConfig(home, env.packageRoot);
21824
22002
  const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
21825
- const resumeRequest = parseResumeRequest(parsed.args);
21826
22003
  const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
21827
22004
  const seatRole = resumeRole ?? "judge";
21828
22005
  const seat = resolveEffectiveSeat(
@@ -21847,6 +22024,11 @@ async function runAkRole(argv, env) {
21847
22024
  let current = result;
21848
22025
  while (current.exitCode === 0 && current.admitted?.correlationId !== void 0 && current.terminal?.roleOutcome.kind === "accepted" && !courtDiaristEscalated(current.terminal.roleOutcome)) {
21849
22026
  const parentRunId = current.admitted.correlationId;
22027
+ resumeFailureContext = {
22028
+ home,
22029
+ runId: parentRunId,
22030
+ authority: env.principalAuthority ?? piDurablePrincipalAuthority
22031
+ };
21850
22032
  const parentRole = await peekRoleRunRole(home, parentRunId);
21851
22033
  if (parentRole === void 0) break;
21852
22034
  const parentSeat = resolveEffectiveSeat(config, parentRole, credentials, invocationFromParsed(parsed));
@@ -21889,6 +22071,18 @@ async function runAkRole(argv, env) {
21889
22071
  }
21890
22072
  throw new CliUsageError(`unknown command: ${parsed.command}`);
21891
22073
  } catch (error) {
22074
+ if (resumeFailureContext !== void 0 && !(error instanceof TurnDispatchedFailure) && await presentLocatedResumeFailure(
22075
+ resumeFailureContext.home,
22076
+ resumeFailureContext.runId,
22077
+ resumeFailureContext.authority,
22078
+ io,
22079
+ error
22080
+ )) {
22081
+ return {
22082
+ exitCode: error instanceof CliUsageError ? 2 : 1,
22083
+ ...error instanceof HostSelectionError ? { hostFailure: error.failure } : {}
22084
+ };
22085
+ }
21892
22086
  if (error instanceof HostSelectionError) {
21893
22087
  io.stderr(formatCliDiagnostic(formatHostSelectionFailure(error.failure)));
21894
22088
  return { exitCode: 1, hostFailure: error.failure };
@@ -21926,10 +22120,12 @@ var init_cli = __esm({
21926
22120
  init_registry();
21927
22121
  init_cli_errors();
21928
22122
  init_machine_method_skills();
22123
+ init_post_admission();
21929
22124
  init_role_turn_host();
21930
22125
  init_role_turn_host_resolution();
21931
22126
  init_invocation();
21932
22127
  init_option_definitions();
22128
+ init_auto_resume();
21933
22129
  init_instruction_seat_run();
21934
22130
  init_countersign_run();
21935
22131
  init_analyst_run();
@@ -22608,7 +22804,7 @@ var init_compliance_transport = __esm({
22608
22804
 
22609
22805
  // src/archivist-record-topology.ts
22610
22806
  import { createHash as createHash8 } from "node:crypto";
22611
- import { join as join39 } from "node:path";
22807
+ import { join as join40 } from "node:path";
22612
22808
  function resolveNavigatorWorkSubjectPlacement(input) {
22613
22809
  let ledgerHome;
22614
22810
  if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
@@ -22621,7 +22817,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
22621
22817
  const digest = createHash8("sha256").update(input.subject).digest("hex").slice(0, 32);
22622
22818
  return {
22623
22819
  ledgerHome,
22624
- sessionDir: join39(
22820
+ sessionDir: join40(
22625
22821
  activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
22626
22822
  NAVIGATOR_RECORD_KIND,
22627
22823
  digest
@@ -22639,7 +22835,7 @@ var init_archivist_record_topology = __esm({
22639
22835
  });
22640
22836
 
22641
22837
  // src/pi/record-session-host.ts
22642
- import { existsSync as existsSync10 } from "node:fs";
22838
+ import { existsSync as existsSync11 } from "node:fs";
22643
22839
  import { SessionManager } from "@earendil-works/pi-coding-agent";
22644
22840
  var piRecordSessionHost;
22645
22841
  var init_record_session_host = __esm({
@@ -22661,7 +22857,7 @@ var init_record_session_host = __esm({
22661
22857
  const sessionFile = session.getSessionFile();
22662
22858
  return {
22663
22859
  session,
22664
- resumed: sessionFile !== void 0 && existsSync10(sessionFile)
22860
+ resumed: sessionFile !== void 0 && existsSync11(sessionFile)
22665
22861
  };
22666
22862
  },
22667
22863
  inMemoryRecordSession(cwd) {
@@ -22684,20 +22880,20 @@ __export(archivist_record_entry_exports, {
22684
22880
  });
22685
22881
  import {
22686
22882
  closeSync,
22687
- existsSync as existsSync11,
22883
+ existsSync as existsSync12,
22688
22884
  mkdirSync as mkdirSync2,
22689
22885
  openSync,
22690
22886
  readdirSync as readdirSync2,
22691
22887
  readFileSync as readFileSync4,
22692
22888
  readSync,
22693
- realpathSync as realpathSync2,
22889
+ realpathSync as realpathSync3,
22694
22890
  statSync as statSync5,
22695
22891
  writeFileSync as writeFileSync2
22696
22892
  } from "node:fs";
22697
- import { dirname as dirname20, resolve as resolve15, join as join40 } from "node:path";
22893
+ import { dirname as dirname21, resolve as resolve16, join as join41 } from "node:path";
22698
22894
  import { StringDecoder } from "node:string_decoder";
22699
22895
  function readCurrentSession(sessionDir) {
22700
- const ledger = join40(sessionDir, CURRENT_SESSION_LEDGER);
22896
+ const ledger = join41(sessionDir, CURRENT_SESSION_LEDGER);
22701
22897
  try {
22702
22898
  const value = JSON.parse(readFileSync4(ledger, "utf8"));
22703
22899
  if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
@@ -22712,7 +22908,7 @@ function readCurrentSession(sessionDir) {
22712
22908
  }
22713
22909
  }
22714
22910
  function writeCurrentSession(sessionDir, sessionFile) {
22715
- const ledger = join40(sessionDir, CURRENT_SESSION_LEDGER);
22911
+ const ledger = join41(sessionDir, CURRENT_SESSION_LEDGER);
22716
22912
  try {
22717
22913
  writeFileSync2(ledger, `${JSON.stringify({ sessionFile })}
22718
22914
  `, { flag: "wx" });
@@ -22728,7 +22924,7 @@ function isCurrentSessionClaimRace(error) {
22728
22924
  return errnoCode(error.cause) === "EEXIST";
22729
22925
  }
22730
22926
  function currentSessionLedgerPath(sessionDir) {
22731
- return join40(sessionDir, CURRENT_SESSION_LEDGER);
22927
+ return join41(sessionDir, CURRENT_SESSION_LEDGER);
22732
22928
  }
22733
22929
  function readBoundedSessionHeader(filePath) {
22734
22930
  const fd = openSync(filePath, "r");
@@ -22801,8 +22997,8 @@ function parseSessionHeaderLine(line2) {
22801
22997
  };
22802
22998
  }
22803
22999
  function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22804
- const absoluteSessionDir = resolve15(sessionDir);
22805
- const absoluteCwd = resolve15(cwd);
23000
+ const absoluteSessionDir = resolve16(sessionDir);
23001
+ const absoluteCwd = resolve16(cwd);
22806
23002
  let names;
22807
23003
  try {
22808
23004
  names = readdirSync2(absoluteSessionDir);
@@ -22815,7 +23011,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22815
23011
  const matched = [];
22816
23012
  for (const name of names) {
22817
23013
  if (!name.endsWith(".jsonl")) continue;
22818
- const filePath = join40(absoluteSessionDir, name);
23014
+ const filePath = join41(absoluteSessionDir, name);
22819
23015
  let st;
22820
23016
  try {
22821
23017
  st = statSync5(filePath);
@@ -22837,7 +23033,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22837
23033
  }
22838
23034
  if (header === void 0) continue;
22839
23035
  if (typeof header.cwd !== "string" || header.cwd.length === 0) continue;
22840
- if (resolve15(header.cwd) !== absoluteCwd) continue;
23036
+ if (resolve16(header.cwd) !== absoluteCwd) continue;
22841
23037
  matched.push({ path: filePath, mtimeMs: st.mtimeMs });
22842
23038
  }
22843
23039
  if (matched.length === 0) return void 0;
@@ -22846,7 +23042,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22846
23042
  }
22847
23043
  function resolveNavigatorNestContinuation(sessionDir, cwd) {
22848
23044
  const ledgerPath = currentSessionLedgerPath(sessionDir);
22849
- if (existsSync11(ledgerPath)) {
23045
+ if (existsSync12(ledgerPath)) {
22850
23046
  const recentFile = readCurrentSession(sessionDir);
22851
23047
  assertRecentFinalFileUnderSessionDir(sessionDir, recentFile);
22852
23048
  return recentFile;
@@ -22867,8 +23063,8 @@ function resolveNavigatorNestContinuation(sessionDir, cwd) {
22867
23063
  }
22868
23064
  }
22869
23065
  function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22870
- const absoluteSessionDir = resolve15(sessionDir);
22871
- const absoluteFile = resolve15(recentFile);
23066
+ const absoluteSessionDir = resolve16(sessionDir);
23067
+ const absoluteFile = resolve16(recentFile);
22872
23068
  if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
22873
23069
  throw new ActivationLedgerError(
22874
23070
  `archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
@@ -22876,7 +23072,7 @@ function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22876
23072
  }
22877
23073
  let realSessionDir;
22878
23074
  try {
22879
- realSessionDir = realpathSync2(absoluteSessionDir);
23075
+ realSessionDir = realpathSync3(absoluteSessionDir);
22880
23076
  } catch (error) {
22881
23077
  throw new ActivationLedgerError(
22882
23078
  `archivist record sessionDir is not resolvable (${absoluteSessionDir}): ${errorText(error)}`,
@@ -22885,7 +23081,7 @@ function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22885
23081
  }
22886
23082
  let realFile;
22887
23083
  try {
22888
- realFile = realpathSync2(absoluteFile);
23084
+ realFile = realpathSync3(absoluteFile);
22889
23085
  } catch (error) {
22890
23086
  throw new ActivationLedgerError(
22891
23087
  `archivist record session file is not resolvable (${absoluteFile}): ${errorText(error)}`,
@@ -22923,15 +23119,15 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
22923
23119
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
22924
23120
  } else {
22925
23121
  ledgerHome = resolveActivationLedgerHomeForPath(parentFile);
22926
- const parentResolved = resolve15(parentFile);
23122
+ const parentResolved = resolve16(parentFile);
22927
23123
  if (!physicallyContainedIn(ledgerHome, parentResolved)) {
22928
23124
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
22929
23125
  }
22930
- sessionDir = join40(dirname20(parentResolved), options.kind);
23126
+ sessionDir = join41(dirname21(parentResolved), options.kind);
22931
23127
  parentSession = parentFile;
22932
23128
  mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
22933
23129
  }
22934
- const nestAlreadyExists = existsSync11(sessionDir);
23130
+ const nestAlreadyExists = existsSync12(sessionDir);
22935
23131
  ensureRealDirectoryTree(ledgerHome, sessionDir);
22936
23132
  if (mayResumeSameNest && nestAlreadyExists) {
22937
23133
  if (options.kind === NAVIGATOR_RECORD_KIND) {
@@ -22956,7 +23152,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
22956
23152
  });
22957
23153
  if (session.isPersisted()) {
22958
23154
  const file = session.getSessionFile();
22959
- if (file !== void 0 && !existsSync11(file)) {
23155
+ if (file !== void 0 && !existsSync12(file)) {
22960
23156
  const header = session.getHeader();
22961
23157
  if (header !== null && header.type === "session") {
22962
23158
  writeFileSync2(file, `${JSON.stringify(header)}
@@ -22974,7 +23170,7 @@ function createRecordSession(options) {
22974
23170
  return createRecordSessionOpen(options).session;
22975
23171
  }
22976
23172
  function bookDirectOfficerRunPointer(options) {
22977
- const nest = join40(dirname20(options.parentSessionFile), "auditor-roles");
23173
+ const nest = join41(dirname21(options.parentSessionFile), "auditor-roles");
22978
23174
  mkdirSync2(nest, { recursive: true });
22979
23175
  const pointer = {
22980
23176
  version: 1,
@@ -22984,7 +23180,7 @@ function bookDirectOfficerRunPointer(options) {
22984
23180
  ...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
22985
23181
  };
22986
23182
  writeFileSync2(
22987
- join40(nest, `${options.officer}.pointer.json`),
23183
+ join41(nest, `${options.officer}.pointer.json`),
22988
23184
  `${JSON.stringify(pointer)}
22989
23185
  `,
22990
23186
  "utf8"
@@ -23012,8 +23208,8 @@ import { randomUUID as randomUUID11 } from "node:crypto";
23012
23208
 
23013
23209
  // src/role-runtime-dependencies.ts
23014
23210
  init_collector_github();
23015
- import { readFile as readFile24 } from "node:fs/promises";
23016
- import { join as join44 } from "node:path";
23211
+ import { readFile as readFile25 } from "node:fs/promises";
23212
+ import { join as join45 } from "node:path";
23017
23213
 
23018
23214
  // src/doctor-auditor.ts
23019
23215
  init_auditor_dossier_tool();
@@ -23045,13 +23241,14 @@ import { createHash as createHash9 } from "node:crypto";
23045
23241
  init_navigator_invocation_identity();
23046
23242
  init_packaged_role_registry();
23047
23243
  init_activation_ledger_topology();
23048
- import { resolve as resolve16 } from "node:path";
23244
+ import { resolve as resolve17 } from "node:path";
23049
23245
  import "@earendil-works/pi-coding-agent";
23050
23246
  import { Type as Type13 } from "typebox";
23051
23247
 
23052
23248
  // src/navigator-public-session.ts
23053
23249
  init_sitian_facade();
23054
- import { basename as basename9 } from "node:path";
23250
+ import { existsSync as existsSync13 } from "node:fs";
23251
+ import { basename as basename10 } from "node:path";
23055
23252
 
23056
23253
  // src/navigator-session-contracts.ts
23057
23254
  import { Type as Type12 } from "typebox";
@@ -23241,6 +23438,113 @@ async function resolveNavigatorSeatSelection(context) {
23241
23438
  init_host_contracts();
23242
23439
  init_cli_errors();
23243
23440
  init_packaged_role_registry();
23441
+
23442
+ // src/navigator-work-base.ts
23443
+ init_atomic_write();
23444
+ import { existsSync as existsSync10, realpathSync as realpathSync2 } from "node:fs";
23445
+ import { readFile as readFile22 } from "node:fs/promises";
23446
+ import { basename as basename9, dirname as dirname20, join as join39, resolve as resolve15 } from "node:path";
23447
+ var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
23448
+ function navigatorWorkContextFile(sessionDir) {
23449
+ return join39(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
23450
+ }
23451
+ function isNavigatorWorkContextFile(path) {
23452
+ const resolved = resolve15(path);
23453
+ if (basename9(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
23454
+ const nest = dirname20(resolved);
23455
+ if (!/^[0-9a-f]{32}$/.test(basename9(nest))) return false;
23456
+ return basename9(dirname20(nest)) === "navigator";
23457
+ }
23458
+ function canonicalNavigatorWorkContextFile(path) {
23459
+ if (!isNavigatorWorkContextFile(path)) return void 0;
23460
+ try {
23461
+ const real = realpathSync2(path);
23462
+ return isNavigatorWorkContextFile(real) ? real : void 0;
23463
+ } catch {
23464
+ return void 0;
23465
+ }
23466
+ }
23467
+ async function persistNavigatorWorkBase(sessionDir, body) {
23468
+ if (sessionDir.trim() === "" || !existsSync10(sessionDir)) return void 0;
23469
+ if (body.authority.trim() === "") return void 0;
23470
+ const path = navigatorWorkContextFile(sessionDir);
23471
+ const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}
23472
+ `;
23473
+ try {
23474
+ const current = await readFile22(path, "utf8");
23475
+ if (current === next) return path;
23476
+ } catch (error) {
23477
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
23478
+ throw error;
23479
+ }
23480
+ }
23481
+ await writeFileAtomically(path, next);
23482
+ return path;
23483
+ }
23484
+ async function readNavigatorWorkBase(path) {
23485
+ const canonical = canonicalNavigatorWorkContextFile(path);
23486
+ if (canonical === void 0) return void 0;
23487
+ let text;
23488
+ try {
23489
+ text = await readFile22(canonical, "utf8");
23490
+ } catch (error) {
23491
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
23492
+ return void 0;
23493
+ }
23494
+ throw error;
23495
+ }
23496
+ let parsed;
23497
+ try {
23498
+ parsed = JSON.parse(text);
23499
+ } catch {
23500
+ return void 0;
23501
+ }
23502
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
23503
+ const record4 = parsed;
23504
+ if (typeof record4.subject !== "string" || typeof record4.authority !== "string") return void 0;
23505
+ if (record4.authority.trim() === "") return void 0;
23506
+ return { subject: record4.subject, authority: record4.authority };
23507
+ }
23508
+ function jsonObjectFromPrompt(prompt) {
23509
+ const head = prompt.trimStart().split("\n\n", 1)[0] ?? "";
23510
+ if (!head.startsWith("{")) return void 0;
23511
+ try {
23512
+ const parsed = JSON.parse(head);
23513
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
23514
+ return parsed;
23515
+ } catch {
23516
+ return void 0;
23517
+ }
23518
+ }
23519
+ function workContextPathFromPrompt(prompt) {
23520
+ const record4 = jsonObjectFromPrompt(prompt);
23521
+ const path = record4?.workContextPath;
23522
+ if (typeof path !== "string" || path.trim() === "") return void 0;
23523
+ return isNavigatorWorkContextFile(path) ? path : void 0;
23524
+ }
23525
+ function attachWorkContextPointer(text, workContextPath) {
23526
+ const record4 = jsonObjectFromPrompt(text);
23527
+ if (record4 === void 0) return text;
23528
+ if (typeof record4.workContextPath === "string" && record4.workContextPath.trim() !== "") return text;
23529
+ const head = text.trimStart().split("\n\n", 1)[0] ?? "";
23530
+ const rest = text.trimStart().slice(head.length);
23531
+ return `${JSON.stringify({ ...record4, workContextPath })}${rest}`;
23532
+ }
23533
+ async function loadNavigatorWorkBaseSuffix(prompt) {
23534
+ const path = workContextPathFromPrompt(prompt);
23535
+ if (path === void 0) return void 0;
23536
+ const body = await readNavigatorWorkBase(path);
23537
+ if (body === void 0) return void 0;
23538
+ return `<work_subject>
23539
+ ${body.subject}
23540
+ </work_subject>
23541
+
23542
+ <controlling_authority>
23543
+ ${body.authority}
23544
+ </controlling_authority>`;
23545
+ }
23546
+
23547
+ // src/navigator-public-session.ts
23244
23548
  async function resolveNavigatorLedgerHome(context) {
23245
23549
  const { tryHomeFromAkRolesPath: tryHomeFromAkRolesPath2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
23246
23550
  const runDirectory = runDirectoryFromHostContext(context);
@@ -23260,7 +23564,7 @@ function exactRecord2(value) {
23260
23564
  return typeof value === "object" && value !== null && !Array.isArray(value);
23261
23565
  }
23262
23566
  function runIdFromNavigatorDirectory(runDirectory) {
23263
- const entry = basename9(runDirectory);
23567
+ const entry = basename10(runDirectory);
23264
23568
  const suffix = "@navigator";
23265
23569
  if (!entry.endsWith(suffix)) return void 0;
23266
23570
  const runId = entry.slice(0, entry.length - suffix.length);
@@ -23304,6 +23608,7 @@ function createNativeNavigatorSessionFactory(deps) {
23304
23608
  });
23305
23609
  let providerFailure;
23306
23610
  let noReceipt;
23611
+ let routePlaybookReadFailure;
23307
23612
  let disposed = false;
23308
23613
  let hostRunId = readNavigatorHostRunPointer(sessionManager.getEntries());
23309
23614
  const summon = deps?.summonPublicRole ?? (async (options) => {
@@ -23317,13 +23622,16 @@ function createNativeNavigatorSessionFactory(deps) {
23317
23622
  }
23318
23623
  providerFailure = void 0;
23319
23624
  noReceipt = void 0;
23625
+ routePlaybookReadFailure = void 0;
23320
23626
  try {
23321
23627
  const summonHome = await resolveNavigatorLedgerHome(context);
23322
23628
  if (disposed) return;
23323
23629
  const resumeRunId = hostRunId;
23630
+ const workContextPath = navigatorWorkContextFile(sessionManager.getSessionDir());
23631
+ const argvText = existsSync13(workContextPath) ? attachWorkContextPointer(text, workContextPath) : text;
23324
23632
  const baseSummon = {
23325
23633
  role: "navigator",
23326
- argv: [text],
23634
+ argv: [argvText],
23327
23635
  cwd: context.cwd,
23328
23636
  ...summonHome === void 0 ? {} : { home: summonHome },
23329
23637
  ...context.signal === void 0 ? {} : { signal: context.signal }
@@ -23344,6 +23652,8 @@ function createNativeNavigatorSessionFactory(deps) {
23344
23652
  }
23345
23653
  }
23346
23654
  if (disposed) return;
23655
+ const playbookFailure = summoned.terminal?.navigator?.advisoryDiagnostic;
23656
+ routePlaybookReadFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
23347
23657
  const outcome = summoned.terminal?.roleOutcome;
23348
23658
  if (outcome === void 0) {
23349
23659
  const detail = summoned.stderr?.trim() || `exit ${summoned.exitCode}`;
@@ -23402,6 +23712,7 @@ function createNativeNavigatorSessionFactory(deps) {
23402
23712
  },
23403
23713
  providerFailure: () => providerFailure,
23404
23714
  noReceipt: () => noReceipt,
23715
+ routePlaybookReadFailure: () => routePlaybookReadFailure,
23405
23716
  appendEntry: (customType, data) => {
23406
23717
  sessionManager.appendCustomEntry(customType, data);
23407
23718
  try {
@@ -23441,7 +23752,6 @@ init_work_subject_identity();
23441
23752
  init_receipt_delivery_policy();
23442
23753
  init_navigator_output();
23443
23754
  var NAVIGATOR_EVENT_TYPE = "ak-navigator-attendance";
23444
- var NAVIGATOR_PREPARE_ACCEPTED_TEXT = "\u6E38\u5955\u4F7F\u51C6\u5907\u5DF2\u63A5\u53D7";
23445
23755
  function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
23446
23756
  if (roleInput !== void 0 && roleInput.trim() !== "") return roleInput;
23447
23757
  if (fileAuthority !== void 0 && fileAuthority.trim() !== "") return fileAuthority;
@@ -23450,10 +23760,9 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
23450
23760
  var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
23451
23761
  var prepareSchema = Type13.Object({
23452
23762
  prose: Type13.Optional(Type13.Unknown({
23453
- description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002\u975E\u53D7\u7406\u95F8"
23763
+ description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
23454
23764
  }))
23455
23765
  }, { additionalProperties: true });
23456
- var CONTEXT_ENTRY = "ak-navigator-context";
23457
23766
  var INVOCATION_ENTRY = NAVIGATOR_INVOCATION_ENTRY;
23458
23767
  var SETTLEMENT_ENTRY = "ak-navigator-settlement";
23459
23768
  function exactRecord3(value) {
@@ -23493,7 +23802,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
23493
23802
  }
23494
23803
  function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
23495
23804
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
23496
- const resolvedReference = resolve16(cwd, reference);
23805
+ const resolvedReference = resolve17(cwd, reference);
23497
23806
  const marker = "/runs/";
23498
23807
  if (resolvedReference.includes(marker)) {
23499
23808
  return subjectRoot;
@@ -23508,12 +23817,12 @@ function createNavigatorPrepareTool(onOutput) {
23508
23817
  parameters: prepareSchema,
23509
23818
  async execute(_id, value) {
23510
23819
  onOutput(value);
23511
- return { content: [{ type: "text", text: NAVIGATOR_PREPARE_ACCEPTED_TEXT }], details: value, terminate: true };
23820
+ return { content: [], details: value, terminate: true };
23512
23821
  }
23513
23822
  };
23514
23823
  }
23515
23824
  function formatNavigatorReport(report) {
23516
- const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [`\u8DEF\u4E66\u8BFB\u53D6\u5931\u8D25\uFF1A${report.routePlaybookReadFailure}`];
23825
+ const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [report.routePlaybookReadFailure];
23517
23826
  if (report.disposition === "no-advice") return playbookFailure.join("\n");
23518
23827
  if (report.disposition === "unavailable") {
23519
23828
  return [...playbookFailure, ...report.unavailableReason ? [report.unavailableReason] : []].join("\n");
@@ -23539,28 +23848,15 @@ function createNavigatorAttendance(options) {
23539
23848
  let settlementTail = Promise.resolve();
23540
23849
  let settlementFailure;
23541
23850
  let preparationFailure;
23542
- let routePlaybookReadFailure;
23851
+ let observedRoutePlaybookFailure;
23543
23852
  let disposed = false;
23544
23853
  let closing;
23545
23854
  const nestCancel = new AbortController();
23546
- let warmedHelp;
23547
23855
  const sessionHostContext = () => {
23548
23856
  const parentSignal = options.context.signal;
23549
23857
  const signal = parentSignal === void 0 ? nestCancel.signal : AbortSignal.any([nestCancel.signal, parentSignal]);
23550
23858
  return { ...options.context, signal };
23551
23859
  };
23552
- const loadLiveHelp = async () => {
23553
- try {
23554
- return await Promise.all(
23555
- NAVIGATOR_TARGETS.map(async ({ role }) => ({
23556
- role,
23557
- help: await options.loadRoleHelp(role)
23558
- }))
23559
- );
23560
- } catch (error) {
23561
- throw navigatorUnavailableError("transport", error);
23562
- }
23563
- };
23564
23860
  const unavailable = (invocationId, reason) => {
23565
23861
  const failure2 = reason instanceof NavigatorUnavailableError ? reason : navigatorUnavailableError("unknown", reason);
23566
23862
  return {
@@ -23570,7 +23866,6 @@ function createNavigatorAttendance(options) {
23570
23866
  unavailableCause: failure2.unavailableCause
23571
23867
  };
23572
23868
  };
23573
- let routePlaybookSettlement;
23574
23869
  let prepareBoundSettlement;
23575
23870
  const loadMaterialsAndSession = async (invocationId) => {
23576
23871
  if (contextError !== void 0) throw navigatorUnavailableError("context", contextError);
@@ -23580,30 +23875,6 @@ function createNavigatorAttendance(options) {
23580
23875
  new Error("controlling authority content was not supplied as typed work context")
23581
23876
  );
23582
23877
  }
23583
- let soul;
23584
- let modelSetting;
23585
- let help;
23586
- let routePlaybook = "";
23587
- routePlaybookReadFailure = void 0;
23588
- const soulPromise = (async () => {
23589
- try {
23590
- const text = (await options.loadSoul()).trim();
23591
- if (!text) throw new Error("Navigator soul is empty");
23592
- return text;
23593
- } catch (error) {
23594
- throw navigatorUnavailableError("context", error);
23595
- }
23596
- })();
23597
- const routePlaybookPromise = (async () => {
23598
- if (options.loadRoutePlaybook === void 0) return "";
23599
- try {
23600
- return await options.loadRoutePlaybook();
23601
- } catch (error) {
23602
- routePlaybookReadFailure = error instanceof Error ? error.message : String(error);
23603
- return "";
23604
- }
23605
- })();
23606
- routePlaybookSettlement = routePlaybookPromise.then(() => void 0);
23607
23878
  const modelPromise = (async () => {
23608
23879
  try {
23609
23880
  const resolved = await resolveNavigatorSeatSelection(options.context);
@@ -23613,23 +23884,13 @@ function createNavigatorAttendance(options) {
23613
23884
  throw navigatorUnavailableError("model", error);
23614
23885
  }
23615
23886
  })();
23616
- const helpPromise = warmedHelp ?? loadLiveHelp();
23617
- warmedHelp = void 0;
23618
- [soul, routePlaybook, modelSetting, help] = await Promise.all([
23619
- soulPromise,
23620
- routePlaybookPromise,
23621
- modelPromise,
23622
- helpPromise
23623
- ]);
23887
+ const modelSetting = await modelPromise;
23624
23888
  let model;
23625
23889
  try {
23626
23890
  model = parseNavigatorModelSetting(modelSetting);
23627
23891
  } catch (error) {
23628
23892
  throw navigatorUnavailableError("model", error);
23629
23893
  }
23630
- const helpContext = help.map(({ role, help: text }) => `<role_help role="${role}">
23631
- ${text}
23632
- </role_help>`).join("\n");
23633
23894
  const tool = createNavigatorPrepareTool((value) => {
23634
23895
  outputSink?.(value);
23635
23896
  });
@@ -23674,9 +23935,9 @@ ${text}
23674
23935
  }
23675
23936
  if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
23676
23937
  if (session === void 0) throw new Error("Navigator session was not created");
23677
- return { soul, routePlaybook, helpContext, modelSetting, model, help, activeSession: session };
23938
+ return session;
23678
23939
  };
23679
- const prepare = async (materialsBundle) => {
23940
+ const prepare = async (existingSession) => {
23680
23941
  const boundSettlement = prepareBoundSettlement;
23681
23942
  prepareBoundSettlement = void 0;
23682
23943
  const invocationId = invocationPrincipal;
@@ -23693,73 +23954,19 @@ ${text}
23693
23954
  const merged = [prior, next].filter((part) => part.trim() !== "").join("\n\n");
23694
23955
  output = { prose: merged };
23695
23956
  };
23696
- const { soul, routePlaybook, helpContext, help, activeSession } = materialsBundle ?? await loadMaterialsAndSession(invocationId);
23697
- const publicSettlementHistory = activeSession.entries().filter((entry) => exactRecord3(entry) && entry.type === "custom" && entry.customType === SETTLEMENT_ENTRY && exactRecord3(entry.data)).map((entry) => entry.data);
23698
- const projection = {
23699
- subjectKey,
23700
- subject,
23701
- authority,
23702
- currentRole: { role: options.role, phase: options.phase },
23703
- ...boundSettlement === void 0 ? {} : { currentSettlement: boundSettlement },
23704
- publicSettlementHistory,
23705
- liveRoleHelp: help
23706
- };
23707
- activeSession.appendEntry(CONTEXT_ENTRY, projection);
23708
- const request = boundSettlement === void 0 ? [
23709
- "\u672C\u8F6E\u4E3A\u5F85\u547D\u8F6E\u3002",
23710
- `<navigator_soul>
23711
- ${soul}
23712
- </navigator_soul>`,
23713
- ...routePlaybookReadFailure === void 0 ? [`<route_playbook>
23714
- ${routePlaybook}
23715
- </route_playbook>`] : ["\u53EF\u9009\u8DEF\u7EBF\u624B\u518C\u672A\u80FD\u8BFB\u53D6\u3002"],
23716
- `<work_subject>
23717
- ${subject}
23718
- </work_subject>`,
23719
- `<controlling_authority>
23720
- ${authority}
23721
- </controlling_authority>`,
23722
- `<current_role>
23723
- ${JSON.stringify({ role: options.role, phase: options.phase })}
23724
- </current_role>`,
23725
- `<public_settlement_history>
23726
- ${JSON.stringify(projection.publicSettlementHistory)}
23727
- </public_settlement_history>`,
23728
- `<live_role_help>
23729
- ${helpContext}
23730
- </live_role_help>`
23731
- ].join("\n\n") : [
23732
- "\u672C\u8F6E\u4E3A\u7ED3\u7B97\u6295\u5582\u8F6E\u3002",
23733
- `<navigator_soul>
23734
- ${soul}
23735
- </navigator_soul>`,
23736
- ...routePlaybookReadFailure === void 0 ? [`<route_playbook>
23737
- ${routePlaybook}
23738
- </route_playbook>`] : ["\u53EF\u9009\u8DEF\u7EBF\u624B\u518C\u672A\u80FD\u8BFB\u53D6\u3002"],
23739
- `<work_subject>
23740
- ${subject}
23741
- </work_subject>`,
23742
- `<controlling_authority>
23743
- ${authority}
23744
- </controlling_authority>`,
23745
- `<current_role>
23746
- ${JSON.stringify({ role: options.role, phase: options.phase })}
23747
- </current_role>`,
23748
- `<current_settlement>
23749
- ${JSON.stringify(boundSettlement)}
23750
- </current_settlement>`,
23751
- `<public_settlement_history>
23752
- ${JSON.stringify(projection.publicSettlementHistory)}
23753
- </public_settlement_history>`,
23754
- `<live_role_help>
23755
- ${helpContext}
23756
- </live_role_help>`
23757
- ].join("\n\n");
23957
+ const activeSession = existingSession ?? await loadMaterialsAndSession(invocationId);
23958
+ if (boundSettlement === void 0) return void 0;
23959
+ const request = JSON.stringify({
23960
+ ...boundSettlement,
23961
+ invocationId,
23962
+ subjectKey
23963
+ });
23758
23964
  try {
23759
23965
  try {
23760
23966
  if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
23761
23967
  const delivery = createReceiptDeliveryPolicy();
23762
23968
  const promptAllowingRejectedPrepare = async (text, deliveryRequest) => {
23969
+ await persistNavigatorWorkBase(activeSession.recordPointer(), { subject, authority });
23763
23970
  const entryStart = activeSession.entries().length;
23764
23971
  prepareBatchRejected = false;
23765
23972
  let promptFailure;
@@ -23790,7 +23997,7 @@ ${helpContext}
23790
23997
  await promptAllowingRejectedPrepare(request, false);
23791
23998
  if (boundSettlement !== void 0) {
23792
23999
  while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
23793
- await promptAllowingRejectedPrepare(RECEIPT_DELIVERY_PROMPT, true);
24000
+ await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()), true);
23794
24001
  }
23795
24002
  if (output === void 0 && delivery.nextAction() === "request-delivery") {
23796
24003
  while (delivery.nextAction() === "request-delivery") {
@@ -23830,6 +24037,8 @@ ${helpContext}
23830
24037
  preparedProse = normalizePrepareProse(output);
23831
24038
  return preparedProse;
23832
24039
  } finally {
24040
+ const playbookFailure = activeSession.routePlaybookReadFailure?.();
24041
+ observedRoutePlaybookFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
23833
24042
  outputSink = void 0;
23834
24043
  }
23835
24044
  };
@@ -23847,16 +24056,6 @@ ${helpContext}
23847
24056
  contextError = next.contextError;
23848
24057
  return closing2;
23849
24058
  },
23850
- /**
23851
- * Start live-help subprocesses during activation without beginning full
23852
- * preparation. Next prepare() consumes the warm result; a later prepare
23853
- * reloads so live help edits remain visible.
23854
- */
23855
- warmHelp() {
23856
- if (disposed || warmedHelp !== void 0 || preparation !== void 0) return;
23857
- warmedHelp = loadLiveHelp();
23858
- void warmedHelp.catch(() => void 0);
23859
- },
23860
24059
  prepare() {
23861
24060
  if (disposed || preparation !== void 0) return;
23862
24061
  preparationFailure = void 0;
@@ -23871,9 +24070,6 @@ ${helpContext}
23871
24070
  isPreparing() {
23872
24071
  return preparationInFlight;
23873
24072
  },
23874
- knownRoutePlaybookReadFailure() {
23875
- return routePlaybookReadFailure;
23876
- },
23877
24073
  settle(settlement) {
23878
24074
  const next = settlementTail.then(() => settleOnce(settlement));
23879
24075
  settlementTail = next.catch((error) => {
@@ -23900,6 +24096,7 @@ ${helpContext}
23900
24096
  };
23901
24097
  async function settleOnce(settlement) {
23902
24098
  if (disposed) return;
24099
+ observedRoutePlaybookFailure = void 0;
23903
24100
  const invocationId = activeInvocationId ?? invocationPrincipal;
23904
24101
  let report;
23905
24102
  if (sessionReady !== void 0) {
@@ -23938,10 +24135,10 @@ ${helpContext}
23938
24135
  }
23939
24136
  } else {
23940
24137
  if (session !== void 0) preparationFailure = void 0;
23941
- let coldMaterials;
24138
+ let coldSession;
23942
24139
  if (session === void 0 && preparationFailure === void 0) {
23943
24140
  try {
23944
- coldMaterials = await loadMaterialsAndSession(invocationId);
24141
+ coldSession = await loadMaterialsAndSession(invocationId);
23945
24142
  } catch (error) {
23946
24143
  preparationFailure = error;
23947
24144
  }
@@ -23949,7 +24146,7 @@ ${helpContext}
23949
24146
  session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
23950
24147
  if (preparationFailure === void 0) {
23951
24148
  prepareBoundSettlement = settlement;
23952
- preparation = prepare(coldMaterials);
24149
+ preparation = prepare(coldSession);
23953
24150
  void preparation.catch((error) => {
23954
24151
  preparationFailure = error;
23955
24152
  });
@@ -23968,9 +24165,8 @@ ${helpContext}
23968
24165
  report = { disposition: "no-advice" };
23969
24166
  }
23970
24167
  }
23971
- await routePlaybookSettlement;
23972
- if (routePlaybookReadFailure !== void 0) {
23973
- report = { ...report, routePlaybookReadFailure };
24168
+ if (observedRoutePlaybookFailure !== void 0) {
24169
+ report = { ...report, routePlaybookReadFailure: observedRoutePlaybookFailure };
23974
24170
  }
23975
24171
  const event = {
23976
24172
  version: 1,
@@ -23997,16 +24193,14 @@ ${helpContext}
23997
24193
  sessionReady = void 0;
23998
24194
  preparedProse = void 0;
23999
24195
  preparationFailure = void 0;
24000
- routePlaybookSettlement = void 0;
24001
- routePlaybookReadFailure = void 0;
24002
24196
  }
24003
24197
  }
24004
24198
 
24005
24199
  // src/navigator-work-context.ts
24006
24200
  init_doctor_evidence();
24007
24201
  init_host_contracts();
24008
- import { readFile as readFile22 } from "node:fs/promises";
24009
- import { resolve as resolve17 } from "node:path";
24202
+ import { readFile as readFile23 } from "node:fs/promises";
24203
+ import { resolve as resolve18 } from "node:path";
24010
24204
  init_notary_source_run();
24011
24205
  init_packaged_role_registry();
24012
24206
  init_invocation();
@@ -24014,12 +24208,12 @@ function navigatorInputReference(getFlag, role) {
24014
24208
  if (getFlag === void 0) return void 0;
24015
24209
  const name = packagedRoleInputFlag(role);
24016
24210
  const value = name === void 0 ? void 0 : getFlag(name);
24017
- return typeof value === "string" && value !== "" ? resolve17(value) : void 0;
24211
+ return typeof value === "string" && value !== "" ? resolve18(value) : void 0;
24018
24212
  }
24019
24213
  async function loadNavigatorWorkContext(options) {
24020
24214
  const reference = navigatorInputReference(options.getFlag, options.role);
24021
24215
  const subjectMode = packagedNavigatorSubject(options.role);
24022
- const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile22(reference, "utf8");
24216
+ const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile23(reference, "utf8");
24023
24217
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
24024
24218
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
24025
24219
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -24036,7 +24230,7 @@ async function loadNavigatorWorkContext(options) {
24036
24230
  }
24037
24231
  const publicRunDir = runDirectoryFromHostContext(options.context);
24038
24232
  const currentSessionDir = options.context.sessionManager.getSessionDir();
24039
- const isBoundPublicRun = publicRunDir !== void 0 && resolve17(currentSessionDir) === resolve17(publicRunDir, "session");
24233
+ const isBoundPublicRun = publicRunDir !== void 0 && resolve18(currentSessionDir) === resolve18(publicRunDir, "session");
24040
24234
  if (subjectMode === "public-instruction" && isBoundPublicRun) {
24041
24235
  let admitted;
24042
24236
  try {
@@ -24069,14 +24263,14 @@ async function loadNavigatorWorkContext(options) {
24069
24263
  }
24070
24264
  const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
24071
24265
  const authorityFiles = workRoot === void 0 ? [] : [
24072
- resolve17(workRoot, "authority.md"),
24073
- resolve17(workRoot, "authority.txt"),
24074
- resolve17(workRoot, "design-v2/owner-direction.md")
24266
+ resolve18(workRoot, "authority.md"),
24267
+ resolve18(workRoot, "authority.txt"),
24268
+ resolve18(workRoot, "design-v2/owner-direction.md")
24075
24269
  ];
24076
24270
  let authorityMaterial;
24077
24271
  for (const path of authorityFiles) {
24078
24272
  try {
24079
- const content = await readFile22(path, "utf8");
24273
+ const content = await readFile23(path, "utf8");
24080
24274
  if (content.trim() !== "") {
24081
24275
  authorityMaterial = content;
24082
24276
  break;
@@ -24108,7 +24302,7 @@ init_submission_ledger();
24108
24302
  init_collector_ledger();
24109
24303
  import { randomUUID as randomUUID8 } from "node:crypto";
24110
24304
  import { readFileSync as readFileSync6, writeSync as writeSync3 } from "node:fs";
24111
- import { join as join43 } from "node:path";
24305
+ import { join as join44 } from "node:path";
24112
24306
  import { Value as Value5 } from "typebox/value";
24113
24307
 
24114
24308
  // src/activation-trace.ts
@@ -24155,11 +24349,11 @@ init_activation_ledger_git();
24155
24349
  init_activation_ledger_topology();
24156
24350
  import {
24157
24351
  lstatSync as lstatSync2,
24158
- realpathSync as realpathSync3,
24352
+ realpathSync as realpathSync4,
24159
24353
  statSync as statSync6,
24160
24354
  writeFileSync as writeFileSync3
24161
24355
  } from "node:fs";
24162
- import { isAbsolute as isAbsolute11, resolve as resolve18 } from "node:path";
24356
+ import { isAbsolute as isAbsolute11, resolve as resolve19 } from "node:path";
24163
24357
  var ActivationSessionFileMissingError = class extends Error {
24164
24358
  code = "AK_ACTIVATION_SESSION_FILE_MISSING";
24165
24359
  path;
@@ -24204,7 +24398,7 @@ function durableSessionPointer(sessionManager) {
24204
24398
  `Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
24205
24399
  );
24206
24400
  }
24207
- const resolvedFile = resolve18(file);
24401
+ const resolvedFile = resolve19(file);
24208
24402
  try {
24209
24403
  lstatSync2(resolvedFile);
24210
24404
  } catch (error) {
@@ -24225,7 +24419,7 @@ function durableSessionPointer(sessionManager) {
24225
24419
  }
24226
24420
  let realFile;
24227
24421
  try {
24228
- realFile = realpathSync3(resolvedFile);
24422
+ realFile = realpathSync4(resolvedFile);
24229
24423
  } catch (error) {
24230
24424
  throw new ActivationSessionFileMissingError(resolvedFile, { cause: error });
24231
24425
  }
@@ -24254,6 +24448,9 @@ function durableSessionPointer(sessionManager) {
24254
24448
  // src/activation-ledger.ts
24255
24449
  init_activation_ledger_topology();
24256
24450
 
24451
+ // src/role-runtime.ts
24452
+ init_session_opening_materials();
24453
+
24257
24454
  // src/stderr-jsonl.ts
24258
24455
  import { writeSync } from "node:fs";
24259
24456
  var STDERR_JSONL_WRITE_RETRY_LIMIT = 100;
@@ -24540,8 +24737,8 @@ init_collector_github();
24540
24737
  // src/collector-handbook.ts
24541
24738
  init_atomic_write();
24542
24739
  init_activation_ledger_topology();
24543
- import { readFile as readFile23 } from "node:fs/promises";
24544
- import { join as join42, sep as sep6 } from "node:path";
24740
+ import { readFile as readFile24 } from "node:fs/promises";
24741
+ import { join as join43, sep as sep6 } from "node:path";
24545
24742
 
24546
24743
  // src/collector-tool-schemas.ts
24547
24744
  init_open_tool_schema();
@@ -24587,10 +24784,10 @@ var collectorOpenWaitWindowArgsSchema = Type17.Object({
24587
24784
  }, { additionalProperties: true });
24588
24785
  var collectorBindTargetArgsSchema = Type17.Object({
24589
24786
  prNumber: Type17.Optional(Type17.Unknown({
24590
- description: "\u89D2\u8272\u5224\u5B9A\u7684\u672C\u4ED3 PR \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002\u4E0E issueNumber \u4E8C\u9009\u4E00\u6216\u540C\u6307\u552F\u4E00\u76EE\u6807\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
24787
+ description: "\u672C\u4ED3 PR \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
24591
24788
  })),
24592
24789
  issueNumber: Type17.Optional(Type17.Unknown({
24593
- description: "\u89D2\u8272\u5224\u5B9A\u7684\u672C\u4ED3 issue \u53F7\uFF08\u6B63\u6574\u6570\uFF09\uFF1Bruntime \u7ECF\u7EBF\u4E0A\u5173\u8054\u89E3\u6790\u552F\u4E00 PR\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
24790
+ description: "\u672C\u4ED3 issue \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
24594
24791
  }))
24595
24792
  }, { additionalProperties: true });
24596
24793
  var collectorFindingItemDeclaration = (() => {
@@ -24608,7 +24805,7 @@ var collectorFindingItemDeclaration = (() => {
24608
24805
  },
24609
24806
  {
24610
24807
  additionalProperties: true,
24611
- description: "\u5355\u6761 finding \u6307\u9488\uFF1AevidenceId + \u53EF\u9009 category/summary\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
24808
+ description: "\u5355\u6761 finding \u6307\u9488\uFF1AevidenceId\uFF0C\u4EE5\u53CA\u53EF\u9009 category\u3001summary\u3002"
24612
24809
  }
24613
24810
  );
24614
24811
  item.required = [];
@@ -24619,11 +24816,11 @@ var collectorOutputBaseSchema = openToolObject(
24619
24816
  // No root type:array — host must not shape-reject non-array findings (#676 C).
24620
24817
  // Nested item declarations ride `items` for registration preservation (ADR 0057).
24621
24818
  findings: Type17.Unsafe({
24622
- description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings\uFF08\u6307\u9488\u6570\u7EC4\u4E3A\u89C4\u8303\u5F62\uFF09\u3002\u96F6 finding \u7684\u6A21\u677F\u901A\u77E5\u4E0D\u5F97\u8FDB\u5165\uFF1B\u6B63\u5E38\u5B8C\u5DE5\u65E0 finding \u65F6\u7701\u7565\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002",
24819
+ description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings \u6307\u9488\u3002",
24623
24820
  items: collectorFindingItemDeclaration
24624
24821
  }),
24625
24822
  unfinishedReasons: Type17.Unknown({
24626
- description: "\u672A\u5B8C\u6210\u539F\u56E0\u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u989D\u5EA6/\u6545\u969C/\u7B49\u5F85\u5C4A\u6EE1\u7B49\u73B0\u573A\u4F9D\u636E\uFF09\uFF1B\u4E0D\u5F97\u628A\u672A\u5B8C\u6210\u8868\u8FF0\u4E3A\u65E0\u95EE\u9898\u3002\u65E0\u53EF\u62A5\u544A\u65F6\u7701\u7565\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
24823
+ description: "\u672A\u5B8C\u6210\u539F\u56E0\u3002"
24627
24824
  })
24628
24825
  })
24629
24826
  );
@@ -24656,7 +24853,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
24656
24853
  throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
24657
24854
  }
24658
24855
  const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
24659
- const root = join42(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
24856
+ const root = join43(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
24660
24857
  return { ledgerHome, bookKey, root };
24661
24858
  }
24662
24859
  function collectorHandbookRepoFileName(repositoryCanonical) {
@@ -24668,9 +24865,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
24668
24865
  return `${repositoryCanonical.replaceAll("/", "__")}.md`;
24669
24866
  }
24670
24867
  function createCollectorHandbookStore(input) {
24671
- const generalPath = join42(input.handbookRoot, "general.md");
24672
- const repoDir = join42(input.handbookRoot, "repos");
24673
- const repoPath = join42(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
24868
+ const generalPath = join43(input.handbookRoot, "general.md");
24869
+ const repoDir = join43(input.handbookRoot, "repos");
24870
+ const repoPath = join43(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
24674
24871
  const assertHandbookBudget = (body, label) => {
24675
24872
  const byteLength = Buffer.byteLength(body, "utf8");
24676
24873
  if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
@@ -24684,7 +24881,7 @@ function createCollectorHandbookStore(input) {
24684
24881
  ensureRealDirectoryTree(input.ledgerHome, parentDir2);
24685
24882
  assertLedgerFileInsideHome(path, input.ledgerHome);
24686
24883
  try {
24687
- const body = await readFile23(path, "utf8");
24884
+ const body = await readFile24(path, "utf8");
24688
24885
  assertHandbookBudget(body, "\u6B63\u6587");
24689
24886
  return body;
24690
24887
  } catch (error) {
@@ -24938,7 +25135,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
24938
25135
  pi.registerTool({
24939
25136
  name: COLLECTOR_BIND_TARGET_TOOL,
24940
25137
  label: "\u901A\u8FDB\u53F8\u8BA4\u7968\u7ED1\u5B9A",
24941
- description: "\u89D2\u8272\u5224\u5B9A\u4EFB\u52A1\u6750\u6599\u540E\u7ED1\u5B9A\u672C\u4ED3\u552F\u4E00 PR \u76EE\u6807\u3002\u53EF\u63D0\u4EA4 prNumber \u6216 issueNumber\uFF08\u7EBF\u4E0A\u5173\u8054\u552F\u4E00 PR\uFF09\uFF1B\u663E\u5F0F --pr \u5DF2\u7ED1\u5B9A\u65F6\u65E0\u9700\u518D\u8C03\u3002\u591A\u4E49\u6216\u65E0\u6CD5\u786E\u5B9A\u65F6\u4F1A\u6B63\u786E\u9A73\u56DE\uFF0C\u8981\u6C42\u8C03\u7528\u65B9\u660E\u786E --pr\u3002",
25138
+ description: "\u7ED1\u5B9A\u672C\u4ED3\u552F\u4E00 PR \u76EE\u6807\u3002",
24942
25139
  promptSnippet: "\u7ED1\u5B9A\u89D2\u8272\u5224\u5B9A\u7684 issue/PR \u76EE\u6807",
24943
25140
  parameters: bindSchema,
24944
25141
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25015,7 +25212,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25015
25212
  pi.registerTool({
25016
25213
  name: COLLECTOR_OBSERVE_TOOL,
25017
25214
  label: "\u901A\u8FDB\u53F8\u89C2\u5BDF",
25018
- description: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807\u7684\u5B8C\u6574 GitHub PR \u8BC1\u636E\uFF0C\u5B58\u4E0D\u53EF\u53D8\u5FEB\u7167\u5165\u5377\u3002\u6B63\u6587\u5728\u4E0A\u4E0B\u6587\u4E2D\u53EA\u7ED9\u5934\u90E8\u6458\u5F55\u52A0\u6307\u9488\uFF1B\u9700\u8981\u5934\u90E8\u4E4B\u5916\u7684\u6B63\u6587\u65F6\uFF0C\u7528 ak_collector_read \u6309 evidenceId \u5F00\u5377\uFF1Bfindings \u7684\u62C6\u5206\u4E0E\u5F52\u7C7B\u7531\u4F60\u5728\u4EA4\u4EF6\u65F6\u5B8C\u6210\u3002\u76EE\u6807\u672A\u7ED1\u5B9A\u524D\u987B\u5148 ak_collector_bind_target\u3002",
25215
+ description: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807\u7684 GitHub PR \u8BC1\u636E\u3002",
25019
25216
  promptSnippet: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807 PR \u8BC1\u636E",
25020
25217
  parameters: observeSchema,
25021
25218
  async execute(toolCallId, _params, signal, _onUpdate, ctx) {
@@ -25045,7 +25242,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25045
25242
  pi.registerTool({
25046
25243
  name: COLLECTOR_READ_TOOL,
25047
25244
  label: "\u901A\u8FDB\u53F8\u5F00\u5377",
25048
- description: "\u6309 evidenceId \u5F00\u5377\u8BFB\u53D6\u4E00\u6761\u5DF2\u89C2\u6D4B\u6750\u6599\u7684\u5168\u91CF\u6B63\u6587\u4E0E\u6307\u9488\uFF1B\u53EA\u5728\u89C2\u5BDF\u5934\u90E8\u6458\u5F55\u4E0D\u8DB3\u4EE5\u5224\u8BFB\u65F6\u8C03\u7528\u3002",
25245
+ description: "\u6309 evidenceId \u5F00\u5377\u8BFB\u53D6\u4E00\u6761\u5DF2\u89C2\u6D4B\u6750\u6599\u7684\u5168\u91CF\u6B63\u6587\u4E0E\u6307\u9488\u3002",
25049
25246
  promptSnippet: "\u6309\u6307\u9488\u5F00\u5377\u8BFB\u6750\u6599",
25050
25247
  parameters: readSchema,
25051
25248
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25075,7 +25272,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25075
25272
  pi.registerTool({
25076
25273
  name: COLLECTOR_REQUEST_TOOL,
25077
25274
  label: "\u901A\u8FDB\u53F8\u8BF7\u6C42",
25078
- description: "\u5728\u6240\u5F15\u6700\u65B0\u5FEB\u7167 HEAD \u53D1\u4E00\u6B21\u8BF7\u6C42\u3002requestId \u53EF\u53D6\u914D\u7F6E\u6E05\u5355\uFF0C\u6216\u89D2\u8272\u4F9D\u624B\u518C/\u73B0\u573A\u5224\u5B9A\u7684\u7A33\u5B9A id\uFF1B\u540E\u8005\u987B\u540C\u65F6\u63D0\u4F9B body\u3002",
25275
+ description: "\u53D1\u4E00\u6B21\u8BF7\u6C42\u3002",
25079
25276
  promptSnippet: "\u53D1\u4E00\u6B21\u8BC4\u5BA1\u8BF7\u6C42",
25080
25277
  parameters: requestSchema,
25081
25278
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
@@ -25194,7 +25391,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25194
25391
  pi.registerTool({
25195
25392
  name: COLLECTOR_WAIT_TOOL,
25196
25393
  label: "\u901A\u8FDB\u53F8\u7B49\u5F85",
25197
- description: "\u518D\u89C2\u5BDF\u524D\u7B49\u5F85\uFF1B\u5B9E\u9645\u7761\u7720\u4E0D\u8D85\u8FC7\u5269\u4F59\u7B49\u5F85\u7A97\u3002",
25394
+ description: "\u7B49\u5F85\u3002\u5B9E\u9645\u7761\u7720\u4E0D\u8D85\u8FC7\u5269\u4F59\u7B49\u5F85\u7A97\u3002",
25198
25395
  promptSnippet: "\u7B49\u5F85\u7A97\u5185\u7B49\u5F85",
25199
25396
  parameters: waitSchema,
25200
25397
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
@@ -25224,7 +25421,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25224
25421
  pi.registerTool({
25225
25422
  name: COLLECTOR_OUTPUT_TOOL,
25226
25423
  label: "\u901A\u8FDB\u53F8\u8F93\u51FA",
25227
- description: "\u89C2\u5BDF\u5B8C\u6210\u540E\u63D0\u4EA4\u539F\u4EA4\u5377\u3002\u6B63\u5E38\u5B8C\u5DE5\u63D0\u4EA4\u7A7A\u5BF9\u8C61 {}\uFF08\u5982\u9700\u62A5 finding\uFF0C\u586B findings \u6307\u9488\u6570\u7EC4\uFF09\uFF1B\u4EC5\u5728\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\u65F6\u624D\u53EF\u586B infrastructureFailure\uFF0C\u65E0\u5931\u8D25\u65F6\u5FC5\u987B\u7701\u7565\u8BE5\u5B57\u6BB5\u3002",
25424
+ description: "\u63D0\u4EA4\u901A\u8FDB\u53F8\u56DE\u6267\u3002",
25228
25425
  promptSnippet: "\u63D0\u4EA4\u901A\u8FDB\u53F8\u56DE\u6267",
25229
25426
  parameters: outputSchema,
25230
25427
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25489,7 +25686,7 @@ var gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
25489
25686
  openToolObject(
25490
25687
  Type18.Object({
25491
25688
  status: Type18.Unknown({
25492
- description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25689
+ description: "completed"
25493
25690
  }),
25494
25691
  findings: Type18.Array(
25495
25692
  Type18.Object(
@@ -25540,7 +25737,7 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
25540
25737
  openToolObject(
25541
25738
  Type19.Object({
25542
25739
  status: Type19.Unknown({
25543
- description: "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25740
+ description: "completed | escalate"
25544
25741
  }),
25545
25742
  ticketNumber: Type19.Optional(
25546
25743
  Type19.Unknown({
@@ -25626,7 +25823,7 @@ var secretariatVerdictSchema = withTerminatingOutputDeclarations(
25626
25823
  Type20.Object(
25627
25824
  {
25628
25825
  secretariatStatus: Type20.Unknown({
25629
- description: "converged | escalate\uFF08\u7EC8\u5C40\u5F62\u72B6\u6307\u5F15\uFF0C\u975E\u95F8\uFF09"
25826
+ description: "converged | escalate"
25630
25827
  }),
25631
25828
  ticketNumber: Type20.Optional(
25632
25829
  Type20.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
@@ -25650,7 +25847,7 @@ secretariatVerdictSchema.required = [];
25650
25847
  var SECRETARIAT_OUTPUT_TOOL_SPEC = {
25651
25848
  name: SECRETARIAT_OUTPUT_TOOL_NAME,
25652
25849
  label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
25653
- description: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267\uFF08\u7F72\u6216\u4E0A\u5448\uFF09\uFF1B\u7ED9\u4E8B\u4E2D\u5C01\u9A73\u987B\u6539\u7968\u91CD\u9001\uFF0C\u4E0D\u5728\u6B64\u7EC8\u5C40\u3002",
25850
+ description: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267\u3002",
25654
25851
  promptSnippet: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267",
25655
25852
  parameters: secretariatVerdictSchema
25656
25853
  };
@@ -25727,7 +25924,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
25727
25924
  pi.registerTool({
25728
25925
  name: JUDGE_OUTPUT_TOOL_NAME,
25729
25926
  label: "\u5927\u7406\u5BFA\u8F93\u51FA",
25730
- description: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD\uFF1B\u53D7\u7406\u524D\u7ECF\u7B26\u5B9D\u90CE\u5185\u95F8\u4E0E\u5BA1\u5211\u9662\u5408\u89C4\u5BA1\u6838\u3002",
25927
+ description: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD\u3002",
25731
25928
  promptSnippet: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD",
25732
25929
  parameters: judgeVerdictSchema,
25733
25930
  async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
@@ -25822,9 +26019,9 @@ var reviewerAmendmentsSchema = Type21.Object({
25822
26019
  }))
25823
26020
  }, {
25824
26021
  additionalProperties: true,
25825
- description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
26022
+ description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002"
25826
26023
  });
25827
- var REVIEWER_STATUS_DESCRIPTION = "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
26024
+ var REVIEWER_STATUS_DESCRIPTION = "completed | refused\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
25828
26025
  var reviewerOutputVariants = Type21.Union([
25829
26026
  Type21.Object({
25830
26027
  status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
@@ -25853,7 +26050,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
25853
26050
  pi.registerTool({
25854
26051
  name: REVIEWER_OUTPUT_TOOL_NAME,
25855
26052
  label: "\u5FA1\u53F2\u53F0\u8F93\u51FA",
25856
- description: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267\u3002\u672C\u5E2D\u81EA\u8C03 ak-cross-m-review skill\u3002",
26053
+ description: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267\u3002",
25857
26054
  promptSnippet: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267",
25858
26055
  parameters: reviewerOutputSchema,
25859
26056
  async execute(_id, parameters) {
@@ -25893,8 +26090,8 @@ init_sitian_facade();
25893
26090
  init_submission_errors();
25894
26091
  init_submission_errors();
25895
26092
  import { execFileSync as execFileSync4 } from "node:child_process";
25896
- import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
25897
- import { resolve as resolve19 } from "node:path";
26093
+ import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
26094
+ import { resolve as resolve20 } from "node:path";
25898
26095
  var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
25899
26096
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
25900
26097
  var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
@@ -25924,7 +26121,7 @@ function statusOf(error) {
25924
26121
  return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
25925
26122
  }
25926
26123
  function tryGetAll(file, key) {
25927
- if (!existsSync12(file)) return [];
26124
+ if (!existsSync14(file)) return [];
25928
26125
  try {
25929
26126
  const out = gitFile(file, ["--get-all", key]);
25930
26127
  return out.length === 0 ? [] : out.split("\n");
@@ -25934,7 +26131,7 @@ function tryGetAll(file, key) {
25934
26131
  }
25935
26132
  }
25936
26133
  function ownedHook(path) {
25937
- if (!existsSync12(path)) return false;
26134
+ if (!existsSync14(path)) return false;
25938
26135
  return readFileSync5(path, "utf8").includes(HOOK_MARKER);
25939
26136
  }
25940
26137
  function escapeGitConfigValueRegex(value) {
@@ -25943,7 +26140,7 @@ function escapeGitConfigValueRegex(value) {
25943
26140
  function unsetOwnedHooksPath(file) {
25944
26141
  const owned = [];
25945
26142
  for (const value of tryGetAll(file, "core.hooksPath")) {
25946
- if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
26143
+ if (!ownedHook(resolve20(value, HOOK_FILE))) continue;
25947
26144
  try {
25948
26145
  gitFile(file, [
25949
26146
  "--unset-all",
@@ -25958,15 +26155,15 @@ function unsetOwnedHooksPath(file) {
25958
26155
  return owned;
25959
26156
  }
25960
26157
  function rmOwnedDir(dir) {
25961
- const hookPath = resolve19(dir, HOOK_FILE);
26158
+ const hookPath = resolve20(dir, HOOK_FILE);
25962
26159
  if (!ownedHook(hookPath)) return;
25963
26160
  rmSync(hookPath, { force: true });
25964
- if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
26161
+ if (existsSync14(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
25965
26162
  }
25966
26163
  function linkedGitDirs(commonDir) {
25967
- const root = resolve19(commonDir, "worktrees");
25968
- if (!existsSync12(root)) return [];
25969
- return readdirSync3(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
26164
+ const root = resolve20(commonDir, "worktrees");
26165
+ if (!existsSync14(root)) return [];
26166
+ return readdirSync3(root).map((name) => resolve20(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
25970
26167
  }
25971
26168
  function uninstallPackageWorkerHooks(cwd) {
25972
26169
  let inside;
@@ -25980,14 +26177,14 @@ function uninstallPackageWorkerHooks(cwd) {
25980
26177
  const clear = (configFile) => {
25981
26178
  for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
25982
26179
  };
25983
- clear(resolve19(commonDir, "config"));
25984
- clear(resolve19(commonDir, "config.worktree"));
25985
- rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
25986
- const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
26180
+ clear(resolve20(commonDir, "config"));
26181
+ clear(resolve20(commonDir, "config.worktree"));
26182
+ rmOwnedDir(resolve20(commonDir, HOOKS_DIR));
26183
+ const legacy = resolve20(commonDir, "hooks", HOOK_FILE);
25987
26184
  if (ownedHook(legacy)) rmSync(legacy, { force: true });
25988
26185
  for (const gitDir of linkedGitDirs(commonDir)) {
25989
- clear(resolve19(gitDir, "config.worktree"));
25990
- rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
26186
+ clear(resolve20(gitDir, "config.worktree"));
26187
+ rmOwnedDir(resolve20(gitDir, HOOKS_DIR));
25991
26188
  }
25992
26189
  }
25993
26190
  function isRecord17(value) {
@@ -26149,7 +26346,7 @@ function fixerBashSeatbeltDenyReason(matched) {
26149
26346
  }
26150
26347
 
26151
26348
  // src/worker-role.ts
26152
- var CODER_STATUS_DESCRIPTION = "planned | completed | refused | partially_completed | unfinished \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bcompleted \u56DE\u6267\u542B TDD\u3001\u540C\u6A21\u5F0F\u3001\u5F15\u5165\u56DE\u5F52\u3001\u884C\u4E3A\u4E8B\u5B9E\u56DB\u9879\u8BC1\u636E\uFF1Bunfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
26349
+ var CODER_STATUS_DESCRIPTION = "planned | completed | refused | partially_completed | unfinished\u3002unfinished\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u3002";
26153
26350
  var coderOutputVariants = Type22.Union([
26154
26351
  Type22.Object({
26155
26352
  status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
@@ -26292,7 +26489,7 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
26292
26489
  pi.registerTool({
26293
26490
  name: FIXER_OUTPUT_TOOL_NAME,
26294
26491
  label: "\u4FEE\u5185\u53F8\u8F93\u51FA",
26295
- description: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267\uFF1B\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8D70 abort\uFF0C\u4E0D\u7ECF\u672C\u5DE5\u5177\u3002",
26492
+ description: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267\u3002",
26296
26493
  promptSnippet: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267",
26297
26494
  parameters: fixerOutputSchema,
26298
26495
  async execute(toolCallId, parameters, _signal, _onUpdate, ctx) {
@@ -26419,7 +26616,7 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
26419
26616
  pi.registerTool({
26420
26617
  name: CODER_OUTPUT_TOOL_NAME,
26421
26618
  label: "\u5C06\u4F5C\u76D1\u8F93\u51FA",
26422
- description: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267\uFF1B\u672C\u5DE5\u5177\u65E0 escalate \u901A\u9053\u3002",
26619
+ description: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267\u3002",
26423
26620
  promptSnippet: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267",
26424
26621
  parameters: coderOutputSchema,
26425
26622
  async execute(toolCallId, parameters, _signal, _onUpdate, ctx2) {
@@ -26722,25 +26919,6 @@ var ROLE_FLAG = {
26722
26919
  type: "string"
26723
26920
  }
26724
26921
  };
26725
- function formatNavigatorRoleHelp(role) {
26726
- const metadata = packagedRoleMetadata(role);
26727
- const lines = [
26728
- `Usage: ak-role ${role}`,
26729
- ROLE_FLAG.definition.description
26730
- ];
26731
- const inputFlag = packagedRoleInputFlag(role);
26732
- if (inputFlag !== void 0) {
26733
- lines.push(` --${inputFlag} <value> ${role} input material`);
26734
- }
26735
- const phaseFlag = packagedRolePhaseFlag(role);
26736
- if (phaseFlag !== void 0 && metadata !== void 0) {
26737
- lines.push(
26738
- ` --${phaseFlag} <value> ${role} phase: ${metadata.phases.filter((p) => p !== null).join(" | ")}`
26739
- );
26740
- }
26741
- lines.push(`Public next-command form: ak-role ${role}`);
26742
- return lines.join("\n");
26743
- }
26744
26922
  function abortContext(ctx) {
26745
26923
  ctx.abort();
26746
26924
  }
@@ -26901,7 +27079,7 @@ function createGatekeeperRoleRuntime(roleHost, dependencies) {
26901
27079
  );
26902
27080
  }
26903
27081
  function createNavigatorRoleRuntime(roleHost, dependencies) {
26904
- return createFiledOfficerRuntime(
27082
+ const base = createFiledOfficerRuntime(
26905
27083
  roleHost,
26906
27084
  {
26907
27085
  role: "navigator",
@@ -26910,6 +27088,42 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
26910
27088
  },
26911
27089
  dependencies
26912
27090
  );
27091
+ let playbookBound = false;
27092
+ return {
27093
+ async activate() {
27094
+ await base.activate();
27095
+ if (playbookBound) return;
27096
+ playbookBound = true;
27097
+ const loadRoutePlaybook = dependencies.loadRoutePlaybook ?? (() => readPackageMaterial("resources/navigator-route-playbook.md"));
27098
+ let playbookRead;
27099
+ roleHost.on("before_agent_start", async (event) => {
27100
+ const basePrompt = typeof event.systemPrompt === "string" ? event.systemPrompt : "";
27101
+ const parts = [];
27102
+ try {
27103
+ playbookRead ??= loadRoutePlaybook();
27104
+ const content = await playbookRead;
27105
+ dependencies.recordRoutePlaybookReadFailure?.(void 0);
27106
+ if (content.trim() !== "") parts.push(content);
27107
+ } catch (error) {
27108
+ const message = error instanceof Error ? error.message : String(error);
27109
+ if (message.trim() !== "") {
27110
+ dependencies.recordRoutePlaybookReadFailure?.(message);
27111
+ parts.push(message);
27112
+ }
27113
+ }
27114
+ const prompt = typeof event.prompt === "string" ? event.prompt : "";
27115
+ const work = await loadNavigatorWorkBaseSuffix(prompt);
27116
+ if (work !== void 0 && work.trim() !== "") parts.push(work);
27117
+ if (parts.length === 0) return;
27118
+ const text = parts.join("\n\n");
27119
+ return {
27120
+ systemPrompt: basePrompt.trim() === "" ? text : `${basePrompt}
27121
+
27122
+ ${text}`
27123
+ };
27124
+ });
27125
+ }
27126
+ };
26913
27127
  }
26914
27128
  function createAuditorRoleRuntime(roleHost, dependencies) {
26915
27129
  const base = createFiledOfficerRuntime(
@@ -26953,7 +27167,7 @@ function readDiaristTicketAssertion(submitted) {
26953
27167
  function readRoleRunCoordinates(ctx, label) {
26954
27168
  const runDirectory = runDirectoryFromHostContext(ctx);
26955
27169
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
26956
- const admittedPath = join43(runDirectory, "admitted-request.json");
27170
+ const admittedPath = join44(runDirectory, "admitted-request.json");
26957
27171
  const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
26958
27172
  if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
26959
27173
  throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
@@ -27293,13 +27507,11 @@ function createRoleRuntimeExtension(dependencies) {
27293
27507
  const raced = await raceNavigatorGrace(settlePromise, NAVIGATOR_POST_ROLE_GRACE_MS);
27294
27508
  if (raced.status !== "timeout") return;
27295
27509
  if (pendingNavigatorPresentation === void 0) {
27296
- const routePlaybookReadFailure = attendance.knownRoutePlaybookReadFailure?.();
27297
27510
  const report = {
27298
27511
  disposition: "unavailable",
27299
27512
  unavailableReason: "Navigator exceeded post-role delivery grace",
27300
27513
  unavailableSource: "unknown",
27301
- unavailableCause: "unknown",
27302
- ...routePlaybookReadFailure === void 0 ? {} : { routePlaybookReadFailure }
27514
+ unavailableCause: "unknown"
27303
27515
  };
27304
27516
  const event = {
27305
27517
  version: 1,
@@ -27310,8 +27522,7 @@ function createRoleRuntimeExtension(dependencies) {
27310
27522
  subjectKey: workContext?.subjectKey ?? "",
27311
27523
  unavailableReason: "Navigator exceeded post-role delivery grace",
27312
27524
  unavailableSource: "unknown",
27313
- unavailableCause: "unknown",
27314
- ...routePlaybookReadFailure === void 0 ? {} : { routePlaybookReadFailure }
27525
+ unavailableCause: "unknown"
27315
27526
  };
27316
27527
  pendingNavigatorPresentation = { event, report };
27317
27528
  }
@@ -27522,7 +27733,7 @@ function createRoleRuntimeExtension(dependencies) {
27522
27733
  }
27523
27734
  envelopeHost.sendMessage({
27524
27735
  customType: "ak-receipt-delivery-prompt",
27525
- content: RECEIPT_DELIVERY_PROMPT,
27736
+ content: JSON.stringify(receiptDelivery.deliveryState()),
27526
27737
  display: false
27527
27738
  }, { triggerTurn: true, deliverAs: "followUp" });
27528
27739
  } else if (receiptDelivery.nextAction() === "no-receipt" && !noReceiptRecorded) {
@@ -27686,7 +27897,12 @@ function createRoleRuntimeExtension(dependencies) {
27686
27897
  loadSoul: () => requireRoleSoul("gatekeeper")
27687
27898
  });
27688
27899
  const navigator = createNavigatorRoleRuntime(roleHost, {
27689
- loadSoul: () => requireRoleSoul("navigator")
27900
+ loadSoul: () => requireRoleSoul("navigator"),
27901
+ recordRoutePlaybookReadFailure: (message) => {
27902
+ envelopeHost.appendEntry(NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY, {
27903
+ message: message ?? ""
27904
+ });
27905
+ }
27690
27906
  });
27691
27907
  const auditor = createAuditorRoleRuntime(roleHost, {
27692
27908
  loadSoul: () => requireRoleSoul("auditor")
@@ -27993,7 +28209,6 @@ function createRoleRuntimeExtension(dependencies) {
27993
28209
  pendingNavigatorPresentation = { event: navigatorEvent, report };
27994
28210
  }
27995
28211
  });
27996
- navigatorAttendance.warmHelp?.();
27997
28212
  if (navigatorWorkContext.contextError === void 0 && navigatorWorkContext.subjectProvenance !== "placeholder") {
27998
28213
  navigatorAttendance.prepare();
27999
28214
  }
@@ -28035,21 +28250,20 @@ function loadRegisteredRoleSoul(role) {
28035
28250
  return usesSubjectSoul(role) ? loadAuditorSoulFromSubjectInput() : loadMainRoleSessionMaterials(role);
28036
28251
  }
28037
28252
  function createRoleRuntimeDependencies(packageRoot) {
28038
- const navigatorRoutePlaybookPath = join44(packageRoot, "resources/navigator-route-playbook.md");
28039
- const collectorHandbookSeedPath = join44(packageRoot, "resources/collector-bot-handbook.md");
28253
+ const collectorHandbookSeedPath = join45(packageRoot, "resources/collector-bot-handbook.md");
28040
28254
  const doctorAuditor = createPiDoctorAuditor();
28041
28255
  const navigatorSessionFactory = createNativeNavigatorSessionFactory();
28042
28256
  return {
28043
28257
  packageRoot,
28044
28258
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
28045
28259
  loadRoleSoul: loadRegisteredRoleSoul,
28046
- loadFixPacket: (path) => readFile24(path, "utf8"),
28047
- loadCoderTask: (path) => readFile24(path, "utf8"),
28048
- loadCollectorHandbookSeed: () => readFile24(collectorHandbookSeedPath, "utf8"),
28260
+ loadFixPacket: (path) => readFile25(path, "utf8"),
28261
+ loadCoderTask: (path) => readFile25(path, "utf8"),
28262
+ loadCollectorHandbookSeed: () => readFile25(collectorHandbookSeedPath, "utf8"),
28049
28263
  createCollectorTransport: () => createGhCollectorGitHubTransport(),
28050
28264
  loadDoctorCase,
28051
28265
  loadNotarySourceRun: loadNotarySourceRunLocator,
28052
- loadMergerInput: async (path) => JSON.parse(await readFile24(path, "utf8")),
28266
+ loadMergerInput: async (path) => JSON.parse(await readFile25(path, "utf8")),
28053
28267
  // #590: doctor compliance still on disposeCompliance path; judge→auditor is gate queue (#756).
28054
28268
  auditDoctorCompliance: (options) => doctorAuditor(options),
28055
28269
  loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
@@ -28065,9 +28279,6 @@ function createRoleRuntimeDependencies(packageRoot) {
28065
28279
  subject: options.subject,
28066
28280
  authority: options.authority,
28067
28281
  invocationId: options.invocationId,
28068
- loadSoul: () => loadRegisteredRoleSoul("navigator"),
28069
- loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
28070
- loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
28071
28282
  createSession: navigatorSessionFactory,
28072
28283
  ...options.contextError === void 0 ? {} : { contextError: options.contextError },
28073
28284
  onEvent: options.onEvent
@@ -28080,7 +28291,7 @@ init_engine_detour();
28080
28291
  import { randomUUID as randomUUID9 } from "node:crypto";
28081
28292
  import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
28082
28293
  import { createServer } from "node:net";
28083
- import { dirname as dirname22, join as join45 } from "node:path";
28294
+ import { dirname as dirname23, join as join46 } from "node:path";
28084
28295
  import { fileURLToPath as fileURLToPath2 } from "node:url";
28085
28296
 
28086
28297
  // src/submission-gate.ts
@@ -28191,11 +28402,11 @@ init_submission_correctable_error();
28191
28402
  init_navigator_invocation_identity();
28192
28403
  init_serialize_thrown_value();
28193
28404
  async function listen(server, path) {
28194
- await new Promise((resolve21, reject) => {
28405
+ await new Promise((resolve22, reject) => {
28195
28406
  server.once("error", reject);
28196
28407
  server.listen(path, () => {
28197
28408
  server.off("error", reject);
28198
- resolve21();
28409
+ resolve22();
28199
28410
  });
28200
28411
  });
28201
28412
  }
@@ -28230,8 +28441,8 @@ async function prepareRoleEnvelope(options) {
28230
28441
  const hostAbort = new AbortController();
28231
28442
  const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
28232
28443
  await mkdir5(request.runDirectory, { recursive: true });
28233
- let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
28234
- await mkdir5(dirname22(sessionFile), { recursive: true });
28444
+ let sessionFile = options.sessionFile ?? join46(request.runDirectory, "session", "session.jsonl");
28445
+ await mkdir5(dirname23(sessionFile), { recursive: true });
28235
28446
  if (request.continuation.kind !== "resume") {
28236
28447
  try {
28237
28448
  await writeFile11(
@@ -28281,7 +28492,7 @@ async function prepareRoleEnvelope(options) {
28281
28492
  getLeafEntry: () => sessionEntries.at(-1),
28282
28493
  getLeafId: () => runId,
28283
28494
  getEntries: () => sessionEntries,
28284
- getSessionDir: () => dirname22(sessionFile),
28495
+ getSessionDir: () => dirname23(sessionFile),
28285
28496
  getSessionFile: () => sessionFile,
28286
28497
  getHeader: () => ({ type: "session", id: runId }),
28287
28498
  setSessionFile(path) {
@@ -28639,8 +28850,8 @@ async function prepareRoleEnvelope(options) {
28639
28850
  try {
28640
28851
  const closeAll = server.closeAllConnections;
28641
28852
  if (typeof closeAll === "function") closeAll.call(server);
28642
- await new Promise((resolve21, reject) => {
28643
- server.close((error) => error ? reject(error) : resolve21());
28853
+ await new Promise((resolve22, reject) => {
28854
+ server.close((error) => error ? reject(error) : resolve22());
28644
28855
  });
28645
28856
  } catch (error) {
28646
28857
  cleanupFailures.push(error);
@@ -28772,7 +28983,7 @@ async function prepareRoleEnvelope(options) {
28772
28983
  init_session_identity();
28773
28984
 
28774
28985
  // src/headless-host/description.ts
28775
- import { join as join46 } from "node:path";
28986
+ import { join as join47 } from "node:path";
28776
28987
  function isClaudePrintDescription(description) {
28777
28988
  return description.protocol === "claude-print";
28778
28989
  }
@@ -28780,7 +28991,7 @@ function isCodexExecDescription(description) {
28780
28991
  return description.protocol === "codex-exec";
28781
28992
  }
28782
28993
  function resolveHeadlessBinary(description, operatorHome) {
28783
- return join46(operatorHome, ...description.binaryFromHome);
28994
+ return join47(operatorHome, ...description.binaryFromHome);
28784
28995
  }
28785
28996
  function headlessTurnArgs(options) {
28786
28997
  const { description } = options;
@@ -29042,9 +29253,9 @@ function headlessMcpConfigDocument(mcpServers) {
29042
29253
  // src/headless-host/role-turn-host.ts
29043
29254
  import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
29044
29255
  import { randomUUID as randomUUID10 } from "node:crypto";
29045
- import { existsSync as existsSync13 } from "node:fs";
29256
+ import { existsSync as existsSync15 } from "node:fs";
29046
29257
  import { writeFile as writeFile12 } from "node:fs/promises";
29047
- import { dirname as dirname23, isAbsolute as isAbsolute12, join as join47, resolve as resolve20 } from "node:path";
29258
+ import { dirname as dirname24, isAbsolute as isAbsolute12, join as join48, resolve as resolve21 } from "node:path";
29048
29259
 
29049
29260
  // src/external-host-turn-loop.ts
29050
29261
  init_packaged_role_registry();
@@ -29264,8 +29475,8 @@ function formatCodexFailurePayload(payload) {
29264
29475
  function cwdIsGitWorkTree(cwd) {
29265
29476
  let dir = cwd;
29266
29477
  for (; ; ) {
29267
- if (existsSync13(join47(dir, ".git"))) return true;
29268
- const parent = dirname23(dir);
29478
+ if (existsSync15(join48(dir, ".git"))) return true;
29479
+ const parent = dirname24(dir);
29269
29480
  if (parent === dir) return false;
29270
29481
  dir = parent;
29271
29482
  }
@@ -29293,10 +29504,10 @@ function resolveGitCommonDir(cwd) {
29293
29504
  if (raw === "") {
29294
29505
  throw new Error("git rev-parse --git-common-dir returned empty stdout");
29295
29506
  }
29296
- return isAbsolute12(raw) ? raw : resolve20(cwd, raw);
29507
+ return isAbsolute12(raw) ? raw : resolve21(cwd, raw);
29297
29508
  }
29298
29509
  function spawnHeadlessTurn(options) {
29299
- return new Promise((resolve21, reject) => {
29510
+ return new Promise((resolve22, reject) => {
29300
29511
  if (options.signal?.aborted) {
29301
29512
  reject(hostAbortedError("headless host aborted"));
29302
29513
  return;
@@ -29371,7 +29582,7 @@ function spawnHeadlessTurn(options) {
29371
29582
  reject(stdinDeliveryError);
29372
29583
  return;
29373
29584
  }
29374
- resolve21({ code, stdout: resultStdout, stderr, timedOut });
29585
+ resolve22({ code, stdout: resultStdout, stderr, timedOut });
29375
29586
  };
29376
29587
  const onAbort = () => {
29377
29588
  child.kill("SIGTERM");
@@ -29472,13 +29683,13 @@ function createHeadlessRoleTurnHost(config) {
29472
29683
  await config.sessionIdentity.bind(request.principal, sessionId);
29473
29684
  }
29474
29685
  const env = { ...process.env, ...config.env ?? {} };
29475
- const systemPromptPath = join47(request.runDirectory, "headless-system-prompt.txt");
29686
+ const systemPromptPath = join48(request.runDirectory, "headless-system-prompt.txt");
29476
29687
  await writeFile12(systemPromptPath, systemPrompt, "utf8");
29477
29688
  let mcpConfigPath;
29478
29689
  let outputSchemaPath;
29479
29690
  if (codex) {
29480
29691
  if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
29481
- outputSchemaPath = join47(request.runDirectory, "headless-output-schema.json");
29692
+ outputSchemaPath = join48(request.runDirectory, "headless-output-schema.json");
29482
29693
  await writeFile12(
29483
29694
  outputSchemaPath,
29484
29695
  `${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
@@ -29487,7 +29698,7 @@ function createHeadlessRoleTurnHost(config) {
29487
29698
  );
29488
29699
  }
29489
29700
  } else {
29490
- mcpConfigPath = join47(request.runDirectory, "headless-mcp-config.json");
29701
+ mcpConfigPath = join48(request.runDirectory, "headless-mcp-config.json");
29491
29702
  await writeFile12(
29492
29703
  mcpConfigPath,
29493
29704
  `${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}