@akagilnc/pi-workflow-roles 0.1.5598 → 0.1.5614

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 (43) hide show
  1. package/dist/acp-host/production-host.js +406 -366
  2. package/dist/compliance-transport.js +2 -5
  3. package/dist/doctor-auditor.js +1 -1
  4. package/dist/gatekeeper-role.js +1 -1
  5. package/dist/headless-host/production-host.js +370 -330
  6. package/dist/migrate-book-topology.js +301 -291
  7. package/dist/navigator-public-session.js +4 -4
  8. package/dist/navigator-work-base.js +5 -30
  9. package/dist/packaged-role-registry.js +4 -2
  10. package/dist/pi/role-turn-host.js +10 -1
  11. package/dist/public-cli/instruction-seat-run.js +133 -38
  12. package/dist/public-cli/invocation.js +23 -26
  13. package/dist/public-cli/main.js +250 -179
  14. package/dist/public-cli/option-definitions.js +19 -0
  15. package/dist/public-cli/post-admission.js +23 -22
  16. package/dist/public-cli/run-lifecycle.js +2 -14
  17. package/dist/public-cli/turn-request.js +4 -9
  18. package/dist/public-role-summons.js +5 -3
  19. package/dist/role-run-placement.js +7 -1
  20. package/package.json +1 -1
  21. package/scripts/build-package.mjs +2 -3
  22. package/src/audited-run-identity.ts +30 -0
  23. package/src/compliance-transport.ts +1 -4
  24. package/src/doctor-auditor.ts +1 -1
  25. package/src/gatekeeper-role.ts +1 -1
  26. package/src/host-contracts.ts +6 -1
  27. package/src/navigator-public-session.ts +9 -5
  28. package/src/navigator-work-base.ts +19 -34
  29. package/src/notary-role.ts +12 -21
  30. package/src/packaged-role-registry.ts +4 -4
  31. package/src/pi/role-turn-host.ts +11 -1
  32. package/src/public-cli/instruction-seat-run.ts +162 -42
  33. package/src/public-cli/invocation.ts +35 -26
  34. package/src/public-cli/option-definitions.ts +20 -0
  35. package/src/public-cli/post-admission.ts +28 -22
  36. package/src/public-cli/run-lifecycle.ts +2 -17
  37. package/src/public-cli/turn-request.ts +9 -8
  38. package/src/public-role-summons.ts +17 -6
  39. package/src/role-envelope.ts +4 -0
  40. package/src/role-run-placement.ts +10 -1
  41. package/src/role-runtime.ts +54 -31
  42. package/dist/auditor-dossier-tool.js +0 -47
  43. package/src/auditor-dossier-tool.ts +0 -63
@@ -1058,7 +1058,7 @@ var init_run_ticket_number = __esm({
1058
1058
 
1059
1059
  // src/role-run-placement.ts
1060
1060
  import { readdir } from "node:fs/promises";
1061
- import { basename as basename5, dirname as dirname4, join as join6 } from "node:path";
1061
+ import { basename as basename5, dirname as dirname4, join as join6, resolve as resolve3 } from "node:path";
1062
1062
  function formatRunLeaf(runId, role) {
1063
1063
  return `${runId}@${role}`;
1064
1064
  }
@@ -1079,6 +1079,11 @@ function sessionFileOf(runDirectory) {
1079
1079
  function runDirectoryOfSessionFile(sessionFile) {
1080
1080
  return dirname4(dirname4(sessionFile));
1081
1081
  }
1082
+ function auditorRunDirectory(context) {
1083
+ const sessionFile = context.sessionManager?.getSessionFile?.();
1084
+ if (sessionFile === void 0) return void 0;
1085
+ return resolve3(runDirectoryOfSessionFile(sessionFile));
1086
+ }
1082
1087
  function runDirectoryFromSessionDirectory(sessionDirectory) {
1083
1088
  return dirname4(sessionDirectory);
1084
1089
  }
@@ -2624,7 +2629,8 @@ var init_packaged_role_registry = __esm({
2624
2629
  presentSettled: "always",
2625
2630
  summonResume: false,
2626
2631
  admission: "instruction",
2627
- sameParent: "gate-pointer",
2632
+ /** Structured --source-run only; instruction stays opaque caller/peer bytes (#1166). */
2633
+ sameParent: "source-run",
2628
2634
  /** Resume restores an optional source-run path onto the admitted face. */
2629
2635
  resumeSourcePath: true,
2630
2636
  /** 台院 is a review officer and inherits the gatekeeper model. */
@@ -2637,11 +2643,12 @@ var init_packaged_role_registry = __esm({
2637
2643
  /** Court reask replaces the initial prompt. */
2638
2644
  reaskPrompt: true,
2639
2645
  gateStageLabel: "\u53F0\u9662",
2646
+ /** Gate summon binds --source-run; identity is startup material (#1166). */
2647
+ gateSummon: "source-run",
2640
2648
  activationFlags: [
2641
2649
  {
2642
2650
  field: "sourceRun",
2643
2651
  from: "sourceRunPath",
2644
- fallback: "gate-pointer",
2645
2652
  flag: "ak-inspector-source-run",
2646
2653
  binds: "input"
2647
2654
  }
@@ -2790,59 +2797,6 @@ var init_collector_config = __esm({
2790
2797
  }
2791
2798
  });
2792
2799
 
2793
- // src/auditor-dossier-tool.ts
2794
- var auditor_dossier_tool_exports = {};
2795
- __export(auditor_dossier_tool_exports, {
2796
- AUDITOR_DOSSIER_TOOL_NAME: () => AUDITOR_DOSSIER_TOOL_NAME,
2797
- auditorRunDirectory: () => auditorRunDirectory,
2798
- createAuditorDossierTool: () => createAuditorDossierTool
2799
- });
2800
- import { join as join7, resolve as resolve3 } from "node:path";
2801
- import { Type as Type14 } from "typebox";
2802
- function auditorRunDirectory(context) {
2803
- const sessionFile = context.sessionManager?.getSessionFile?.();
2804
- if (sessionFile === void 0) return void 0;
2805
- return resolve3(runDirectoryOfSessionFile(sessionFile));
2806
- }
2807
- function createAuditorDossierTool(runDirectory) {
2808
- return {
2809
- name: AUDITOR_DOSSIER_TOOL_NAME,
2810
- description: "\u5B9A\u4F4D\u672C\u5BA1\u8BA1\u5E2D\u7ED1\u5B9A\u7684 run \u5377\u5B97\u53CA\u5176\u8BC1\u636E\u5165\u53E3\u3002",
2811
- // #836 r16 class 3: execute() ignores `_params` entirely — a closed root
2812
- // only rejects the role for saying more.
2813
- parameters: Type14.Object({}, { additionalProperties: true }),
2814
- async execute(_id, _params) {
2815
- if (runDirectory === void 0) {
2816
- return {
2817
- content: [{ type: "text", text: "\u672C\u5BA1\u8BA1\u5E2D\u65E0\u7ED1\u5B9A run \u5377\u5B97\u8BB0\u5F55\u3002" }],
2818
- details: void 0
2819
- };
2820
- }
2821
- const details = {
2822
- runDirectory,
2823
- current: runCurrentPath(runDirectory),
2824
- parentSessionCandidate: sessionFileOf(runDirectory),
2825
- attachments: join7(runDirectory, "attachments"),
2826
- log: join7(runDirectory, RUN_LOG_FILE),
2827
- history: join7(runDirectory, RUN_HISTORY_FILE)
2828
- };
2829
- return {
2830
- content: [{ type: "text", text: JSON.stringify(details) }],
2831
- details
2832
- };
2833
- }
2834
- };
2835
- }
2836
- var AUDITOR_DOSSIER_TOOL_NAME;
2837
- var init_auditor_dossier_tool = __esm({
2838
- "src/auditor-dossier-tool.ts"() {
2839
- "use strict";
2840
- init_run_dossier();
2841
- init_role_run_placement();
2842
- AUDITOR_DOSSIER_TOOL_NAME = "ak_get_run_dossier";
2843
- }
2844
- });
2845
-
2846
2800
  // src/readable-gate-item.ts
2847
2801
  var readable_gate_item_exports = {};
2848
2802
  __export(readable_gate_item_exports, {
@@ -2934,7 +2888,7 @@ var init_submission_errors = __esm({
2934
2888
  });
2935
2889
 
2936
2890
  // src/collector-tool-schemas.ts
2937
- import { Type as Type15 } from "typebox";
2891
+ import { Type as Type14 } from "typebox";
2938
2892
  var collectorOutputBaseSchema, collectorOutputArgsSchema;
2939
2893
  var init_collector_tool_schemas = __esm({
2940
2894
  "src/collector-tool-schemas.ts"() {
@@ -2942,11 +2896,11 @@ var init_collector_tool_schemas = __esm({
2942
2896
  init_open_tool_schema();
2943
2897
  init_terminating_infrastructure();
2944
2898
  collectorOutputBaseSchema = openToolObject(
2945
- Type15.Object({
2946
- groups: Type15.Unsafe({
2899
+ Type14.Object({
2900
+ groups: Type14.Unsafe({
2947
2901
  description: "\u6309\u673A\u5668\u8EAB\u4EFD\u5F52\u7EC4\u7684\u51FA\u5E2D\u3001\u6750\u6599\u4E0E\u9010\u6761 findings\uFF08LLM \u81EA\u884C\u4ECE\u5BBF\u4E3B CLI \u53D6\u8BC1\u6574\u7406\uFF1B\u4EE3\u7801\u4E0D\u4EE3\u6536\u4E0D\u5F52\u5E76\uFF09\u3002"
2948
2902
  }),
2949
- unfinishedReasons: Type15.Unknown({
2903
+ unfinishedReasons: Type14.Unknown({
2950
2904
  description: "\u672A\u5B8C\u6210\u539F\u56E0\uFF1B\u53D6\u8BC1\u53D7\u9650\u65F6\u5982\u5B9E\u62A5\u544A\u3002"
2951
2905
  })
2952
2906
  })
@@ -3432,7 +3386,7 @@ var GATE_OFFICER_BY_SUBJECT, GATEKEEPER_TOOL_SPEC;
3432
3386
  var init_gatekeeper_role = __esm({
3433
3387
  "src/gatekeeper-role.ts"() {
3434
3388
  "use strict";
3435
- init_auditor_dossier_tool();
3389
+ init_role_run_placement();
3436
3390
  init_packaged_role_registry();
3437
3391
  init_submission_errors();
3438
3392
  init_inspector_contracts();
@@ -3928,7 +3882,7 @@ import {
3928
3882
  statSync as statSync3
3929
3883
  } from "node:fs";
3930
3884
  import { homedir } from "node:os";
3931
- import { dirname as dirname5, join as join8 } from "node:path";
3885
+ import { dirname as dirname5, join as join7 } from "node:path";
3932
3886
  function declareHostSessionFailure(error) {
3933
3887
  const message = error instanceof Error ? error.stack || error.message : String(error);
3934
3888
  process.stderr.write(`[host-session] Dossier record failure: ${message}
@@ -3953,7 +3907,7 @@ function findCodexRollout(sessionsDir, sessionId) {
3953
3907
  throw error;
3954
3908
  }
3955
3909
  for (const entry of entries) {
3956
- const fullPath = join8(dir, entry.name);
3910
+ const fullPath = join7(dir, entry.name);
3957
3911
  if (entry.isDirectory()) {
3958
3912
  scan(fullPath, depth + 1);
3959
3913
  } else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
@@ -3983,24 +3937,24 @@ function sanitizeClaudeCwd(cwd) {
3983
3937
  function resolveNativeSessionPath(options) {
3984
3938
  const home = options.home || homedir();
3985
3939
  if (options.host === "claude") {
3986
- const configDir = process.env.CLAUDE_CONFIG_DIR || join8(home, ".claude");
3940
+ const configDir = process.env.CLAUDE_CONFIG_DIR || join7(home, ".claude");
3987
3941
  const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
3988
- return join8(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
3942
+ return join7(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
3989
3943
  }
3990
3944
  if (options.host === "codex") {
3991
3945
  return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
3992
3946
  }
3993
3947
  if (options.host === "grok-build") {
3994
- const grokHome = process.env.GROK_HOME || join8(home, ".grok");
3995
- return join8(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
3948
+ const grokHome = process.env.GROK_HOME || join7(home, ".grok");
3949
+ return join7(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
3996
3950
  }
3997
3951
  return void 0;
3998
3952
  }
3999
3953
  function codexSessionsDirectory(home) {
4000
- return join8(process.env.CODEX_HOME || join8(home || homedir(), ".codex"), "sessions");
3954
+ return join7(process.env.CODEX_HOME || join7(home || homedir(), ".codex"), "sessions");
4001
3955
  }
4002
3956
  function resolveHostDossierLandingPath(options) {
4003
- return options.host === "grok-build" ? join8(options.sessionDirectory, options.host) : join8(options.sessionDirectory, `${options.host}.jsonl`);
3957
+ return options.host === "grok-build" ? join7(options.sessionDirectory, options.host) : join7(options.sessionDirectory, `${options.host}.jsonl`);
4004
3958
  }
4005
3959
  function recordNativeSessionPointer(options) {
4006
3960
  if (options.host === "pi" || options.host === "hermes") {
@@ -4033,8 +3987,8 @@ function copyFileCloneOrFallback(src, dest) {
4033
3987
  }
4034
3988
  function copyGrokDossier(srcDir, destDir) {
4035
3989
  mkdirSync2(destDir, { recursive: true });
4036
- copyFileCloneOrFallback(join8(srcDir, "chat_history.jsonl"), join8(destDir, "chat_history.jsonl"));
4037
- copyFileCloneOrFallback(join8(srcDir, "usage.json"), join8(destDir, "usage.json"));
3990
+ copyFileCloneOrFallback(join7(srcDir, "chat_history.jsonl"), join7(destDir, "chat_history.jsonl"));
3991
+ copyFileCloneOrFallback(join7(srcDir, "usage.json"), join7(destDir, "usage.json"));
4038
3992
  }
4039
3993
  function copyAndRecordHostDossier(options) {
4040
3994
  if (options.host === "hermes") {
@@ -5355,13 +5309,13 @@ var init_session_dialogue = __esm({
5355
5309
 
5356
5310
  // src/ticket-provenance.ts
5357
5311
  import { readFile as readFile6 } from "node:fs/promises";
5358
- import { join as join9, resolve as resolve7 } from "node:path";
5312
+ import { join as join8, resolve as resolve7 } from "node:path";
5359
5313
  function dialogueSessionSourceRoots(home) {
5360
5314
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
5361
5315
  return [
5362
- join9(machineHome, ".claude", "projects"),
5363
- join9(machineHome, ".codex", "sessions"),
5364
- join9(machineHome, ".pi", "agent", "sessions")
5316
+ join8(machineHome, ".claude", "projects"),
5317
+ join8(machineHome, ".codex", "sessions"),
5318
+ join8(machineHome, ".pi", "agent", "sessions")
5365
5319
  ];
5366
5320
  }
5367
5321
  function isLedgerRoleSessionFile(absolute, home) {
@@ -5402,7 +5356,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
5402
5356
  const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
5403
5357
  let history;
5404
5358
  try {
5405
- history = await readFile6(join9(runDirectory, RUN_HISTORY_FILE), "utf8");
5359
+ history = await readFile6(join8(runDirectory, RUN_HISTORY_FILE), "utf8");
5406
5360
  } catch (error) {
5407
5361
  if (errnoCode(error) === "ENOENT") return;
5408
5362
  throw error;
@@ -5619,7 +5573,7 @@ var init_uuidv7 = __esm({
5619
5573
  });
5620
5574
 
5621
5575
  // src/notary-source-run.ts
5622
- import { dirname as dirname7, isAbsolute as isAbsolute4, join as join10, resolve as resolve8, basename as basename7 } from "node:path";
5576
+ import { dirname as dirname7, isAbsolute as isAbsolute4, join as join9, resolve as resolve8, basename as basename7 } from "node:path";
5623
5577
  import { lstat, realpath as realpath2 } from "node:fs/promises";
5624
5578
  async function readRetainedIdentity(runDirectory) {
5625
5579
  try {
@@ -5671,11 +5625,11 @@ async function resolveNotarySourceRunLocator(options) {
5671
5625
  const ledgerHome = resolveActivationLedgerHome(options.home);
5672
5626
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
5673
5627
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
5674
- const bookRunsRoot = join10(bookDirectory, "runs");
5628
+ const bookRunsRoot = join9(bookDirectory, "runs");
5675
5629
  let candidate;
5676
5630
  const bare = parseRunLeaf(raw);
5677
5631
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
5678
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join10(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
5632
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join9(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
5679
5633
  } else {
5680
5634
  candidate = isAbsolute4(raw) ? raw : resolve8(options.projectRoot, raw);
5681
5635
  const identity2 = parseRunLeaf(basename7(candidate));
@@ -6109,7 +6063,7 @@ function renderHumanOwnerOptionLines(owner, locale = "en") {
6109
6063
  }
6110
6064
  return lines;
6111
6065
  }
6112
- var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, SHARED_PHASE_SEMANTICS, GLEANER_LEFT_OPTIONS, AUDITOR_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, SEAT_OPTION_ROWS, PUBLIC_OPTION_TABLE, PUBLIC_ROLE_OPTION_OWNERS, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
6066
+ var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, SHARED_PHASE_SEMANTICS, GLEANER_LEFT_OPTIONS, AUDITOR_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, INSPECTOR_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, SEAT_OPTION_ROWS, PUBLIC_OPTION_TABLE, PUBLIC_ROLE_OPTION_OWNERS, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
6113
6067
  var init_option_definitions = __esm({
6114
6068
  "src/public-cli/option-definitions.ts"() {
6115
6069
  "use strict";
@@ -6474,6 +6428,23 @@ var init_option_definitions = __esm({
6474
6428
  }
6475
6429
  }
6476
6430
  ];
6431
+ INSPECTOR_OPTIONS = [
6432
+ ...projectAndAttach("inspector"),
6433
+ {
6434
+ id: "source-run",
6435
+ owner: "inspector",
6436
+ canonical: "--source-run",
6437
+ aliases: [],
6438
+ valueMetavar: "runId@role|path",
6439
+ required: false,
6440
+ repeatable: false,
6441
+ form: "option",
6442
+ description: {
6443
+ en: "Optional audited source-run locator (runId@role or path). Gate summons always supply it; identity rides startup materials.",
6444
+ zh: "\u53EF\u9009\u88AB\u5BA1\u817F\u5B9A\u4F4D\u7B26\uFF08runId@role \u6216\u8DEF\u5F84\uFF09\u3002\u95F8\u4F20\u53EC\u5FC5\u5E26\uFF1B\u8EAB\u4EFD\u5728\u542F\u52A8\u6750\u6599\u91CC\u3002"
6445
+ }
6446
+ }
6447
+ ];
6477
6448
  MERGER_OPTIONS = [
6478
6449
  // Merger project face: worktree whose Git materials are handed to the role.
6479
6450
  {
@@ -6632,7 +6603,8 @@ var init_option_definitions = __esm({
6632
6603
  doctor: DOCTOR_OPTIONS,
6633
6604
  merger: MERGER_OPTIONS,
6634
6605
  notary: NOTARY_OPTIONS,
6635
- auditor: AUDITOR_OPTIONS
6606
+ auditor: AUDITOR_OPTIONS,
6607
+ inspector: INSPECTOR_OPTIONS
6636
6608
  };
6637
6609
  PUBLIC_OPTION_TABLE = publicOptionTable();
6638
6610
  PUBLIC_ROLE_OPTION_OWNERS = [
@@ -6886,7 +6858,7 @@ import {
6886
6858
  rename,
6887
6859
  writeFile
6888
6860
  } from "node:fs/promises";
6889
- import { dirname as dirname8, isAbsolute as isAbsolute5, join as join11, resolve as resolve9 } from "node:path";
6861
+ import { dirname as dirname8, isAbsolute as isAbsolute5, join as join10, resolve as resolve9 } from "node:path";
6890
6862
  function normalizeAdmittedAttachment(raw) {
6891
6863
  if (typeof raw !== "object" || raw === null) return void 0;
6892
6864
  const record = raw;
@@ -7039,7 +7011,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
7039
7011
  const childRunIds = readPageSync(oldRunDirectory, "admitted")?.childDiaristRunIds;
7040
7012
  for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
7041
7013
  if (typeof childRunId !== "string") continue;
7042
- const childDirectory = join11(dirname8(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
7014
+ const childDirectory = join10(dirname8(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
7043
7015
  if (!existsSync3(childDirectory)) continue;
7044
7016
  const childTarget = roleRunPlacement(ledgerHome, {
7045
7017
  bookKey: admitted.bookKey,
@@ -7113,7 +7085,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
7113
7085
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
7114
7086
  const rolePackageRoot = packageRoot;
7115
7087
  const raw = JSON.parse(
7116
- await readFile7(join11(rolePackageRoot, "package.json"), "utf8")
7088
+ await readFile7(join10(rolePackageRoot, "package.json"), "utf8")
7117
7089
  );
7118
7090
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
7119
7091
  throw new Error(
@@ -7671,7 +7643,7 @@ async function admitPublicRole(role, parsed, env, override) {
7671
7643
  resolutionScope: [...derived.resolutionScope],
7672
7644
  authorizedChecks: []
7673
7645
  });
7674
- const mergerInputPath = join11(placed.runDirectory, "merger-input.json");
7646
+ const mergerInputPath = join10(placed.runDirectory, "merger-input.json");
7675
7647
  await writeFile(
7676
7648
  mergerInputPath,
7677
7649
  `${JSON.stringify(mergerInput, null, 2)}
@@ -7809,52 +7781,50 @@ function admittedTransportPromptKind(admitted) {
7809
7781
  if (record !== void 0 && "transportPrompt" in record) return record.transportPrompt;
7810
7782
  return "instruction";
7811
7783
  }
7784
+ function appendCallerFileFlagPaths(body, attachments, requestManifestPath, prerequisitesPath) {
7785
+ const flaggedPaths = [
7786
+ ...attachments.map((attachment) => `--attach ${attachment.path}`),
7787
+ ...requestManifestPath === void 0 ? [] : [`--request-manifest ${requestManifestPath}`],
7788
+ ...prerequisitesPath === void 0 ? [] : [`--prerequisites ${prerequisitesPath}`]
7789
+ ];
7790
+ if (flaggedPaths.length === 0) return body;
7791
+ return [body, "", ...flaggedPaths].join("\n");
7792
+ }
7812
7793
  function buildInstructionTransportPrompt(admitted) {
7813
7794
  const kind = admittedTransportPromptKind(admitted);
7814
7795
  if (kind === "fixed-kickoff") {
7815
- if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
7816
- throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
7817
- }
7818
- return admitted.sourceRunPath;
7796
+ return "";
7819
7797
  }
7820
7798
  if (kind === "baseline") {
7821
7799
  if (admitted.baseRevision === void 0) {
7822
7800
  throw new Error("baseline transport prompt is missing the bound revision");
7823
7801
  }
7824
- const lines2 = [admitted.baseRevision];
7802
+ const lines = [admitted.baseRevision];
7825
7803
  if (admitted.instruction.length > 0) {
7826
- lines2.push("", admitted.instruction);
7804
+ lines.push("", admitted.instruction);
7827
7805
  }
7828
- return lines2.join("\n");
7806
+ return lines.join("\n");
7829
7807
  }
7830
7808
  if (kind === "skill-args") {
7831
7809
  if (admitted.baseRevision === void 0 || admitted.lens === void 0 || admitted.authorityRefs === void 0) {
7832
7810
  throw new Error("skill-args transport prompt is missing frozen skill args");
7833
7811
  }
7834
- const lines2 = [buildReviewerSkillArgProjection({
7812
+ const lines = [buildReviewerSkillArgProjection({
7835
7813
  baseRevision: admitted.baseRevision,
7836
7814
  lens: admitted.lens,
7837
7815
  authorityRefs: admitted.authorityRefs
7838
7816
  })];
7839
7817
  if (admitted.instruction.length > 0) {
7840
- lines2.push("", admitted.instruction);
7818
+ lines.push("", admitted.instruction);
7841
7819
  }
7842
- return lines2.join("\n");
7820
+ return lines.join("\n");
7843
7821
  }
7844
- const lines = [admitted.instruction];
7845
- const flaggedPaths = [
7846
- ...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
7847
- ...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`],
7848
- ...admitted.prerequisitesPath === void 0 ? [] : [`--prerequisites ${admitted.prerequisitesPath}`]
7849
- ];
7850
- if (flaggedPaths.length > 0) {
7851
- lines.push("");
7852
- lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
7853
- for (const entry of flaggedPaths) {
7854
- lines.push(`- ${entry}`);
7855
- }
7856
- }
7857
- return lines.join("\n");
7822
+ return appendCallerFileFlagPaths(
7823
+ admitted.instruction,
7824
+ admitted.attachments,
7825
+ admitted.requestManifestPath,
7826
+ admitted.prerequisitesPath
7827
+ );
7858
7828
  }
7859
7829
  async function materializeCountersignInvocation(admitted, options) {
7860
7830
  const placed = await placeRoleAdmission({
@@ -7964,7 +7934,7 @@ function parseDoctorIssueNumber(raw) {
7964
7934
  }
7965
7935
  async function resolveDoctorCaseRunsPath(options) {
7966
7936
  const ledgerHome = resolveActivationLedgerHome(options.home);
7967
- const defaultRuns = join11(
7937
+ const defaultRuns = join10(
7968
7938
  activationBookDirectory(ledgerHome, options.bookKey),
7969
7939
  String(options.issueNumber),
7970
7940
  "runs"
@@ -9608,7 +9578,7 @@ var init_settlement = __esm({
9608
9578
  });
9609
9579
 
9610
9580
  // src/session-identity.ts
9611
- import { dirname as dirname9, join as join12 } from "node:path";
9581
+ import { dirname as dirname9, join as join11 } from "node:path";
9612
9582
  function createSessionIdentityAuthority(authority, hostName) {
9613
9583
  const runDirectoryOf = (principal) => dirname9(authority.decode(principal).sessionDirectory);
9614
9584
  return {
@@ -9617,7 +9587,7 @@ function createSessionIdentityAuthority(authority, hostName) {
9617
9587
  },
9618
9588
  async load(principal) {
9619
9589
  const runDirectory = runDirectoryOf(principal);
9620
- const { records, diagnostics } = await readSitianRecords(join12(runDirectory, RUN_STATE_FILE));
9590
+ const { records, diagnostics } = await readSitianRecords(join11(runDirectory, RUN_STATE_FILE));
9621
9591
  if (diagnostics.length > 0) {
9622
9592
  throw new Error(
9623
9593
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -9687,12 +9657,12 @@ __export(role_turn_host_exports, {
9687
9657
  import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
9688
9658
  import { constants } from "node:fs";
9689
9659
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
9690
- import { delimiter, dirname as dirname10, isAbsolute as isAbsolute6, join as join13, resolve as resolve11 } from "node:path";
9660
+ import { delimiter, dirname as dirname10, isAbsolute as isAbsolute6, join as join12, resolve as resolve11 } from "node:path";
9691
9661
  import { platform } from "node:process";
9692
9662
  import { promisify as promisify2 } from "node:util";
9693
9663
  import { randomUUID as randomUUID4 } from "node:crypto";
9694
9664
  function resolveInternalRoleEntrypoint(packageRoot) {
9695
- return join13(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
9665
+ return join12(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
9696
9666
  }
9697
9667
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
9698
9668
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -9933,6 +9903,11 @@ function createPiRoleTurnHost(config) {
9933
9903
  if (typeof process.env.AK_ROLE_AUDITOR_SUBJECT === "string" && process.env.AK_ROLE_AUDITOR_SUBJECT.trim() !== "") {
9934
9904
  env.AK_ROLE_AUDITOR_SUBJECT = process.env.AK_ROLE_AUDITOR_SUBJECT;
9935
9905
  }
9906
+ if (typeof request.navigatorWorkContextPath === "string" && request.navigatorWorkContextPath.trim() !== "") {
9907
+ env.AK_ROLE_NAVIGATOR_WORK_CONTEXT = request.navigatorWorkContextPath.trim();
9908
+ } else {
9909
+ delete env.AK_ROLE_NAVIGATOR_WORK_CONTEXT;
9910
+ }
9936
9911
  if (config.recordLaunchedRolePackageIdentity !== void 0 && config.observeLaunchedRolePackageIdentity !== void 0) {
9937
9912
  await config.recordLaunchedRolePackageIdentity(
9938
9913
  request.runDirectory,
@@ -10055,7 +10030,7 @@ var init_role_turn_host = __esm({
10055
10030
 
10056
10031
  // src/package-resources/engine-material.ts
10057
10032
  import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
10058
- import { join as join14 } from "node:path";
10033
+ import { join as join13 } from "node:path";
10059
10034
  function pickEngineAxis(source) {
10060
10035
  return {
10061
10036
  ...source.engine === void 0 ? {} : { engine: source.engine },
@@ -10076,14 +10051,14 @@ function isEngineNameSyntax(name) {
10076
10051
  return true;
10077
10052
  }
10078
10053
  function resolveEngineMaterialDirectory(packageRoot) {
10079
- return join14(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
10054
+ return join13(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
10080
10055
  }
10081
10056
  function resolveEngineDispatchMaterialPath(packageRoot) {
10082
- return join14(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
10057
+ return join13(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
10083
10058
  }
10084
10059
  function resolveEngineMaterialPath(packageRoot, name) {
10085
10060
  const legal = assertLegalEngineName(name);
10086
- return join14(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
10061
+ return join13(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
10087
10062
  }
10088
10063
  function assertLegalEngineName(name) {
10089
10064
  if (!isEngineNameSyntax(name)) {
@@ -10182,7 +10157,7 @@ __export(config_exports, {
10182
10157
  validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
10183
10158
  });
10184
10159
  import { mkdir, readFile as readFile8, writeFile as writeFile2 } from "node:fs/promises";
10185
- import { dirname as dirname11, join as join15 } from "node:path";
10160
+ import { dirname as dirname11, join as join14 } from "node:path";
10186
10161
  function isGateOfficerSeat(value) {
10187
10162
  return packagedProvinceConfig(value);
10188
10163
  }
@@ -10190,7 +10165,7 @@ function publicCliConfigPath(home) {
10190
10165
  if (typeof home !== "string" || home.trim() === "") {
10191
10166
  throw new Error("home must be explicitly provided");
10192
10167
  }
10193
- return join15(home, ".ak-roles", "public-cli.json");
10168
+ return join14(home, ".ak-roles", "public-cli.json");
10194
10169
  }
10195
10170
  async function loadPublicCliConfig(home) {
10196
10171
  const path = publicCliConfigPath(home);
@@ -10650,11 +10625,11 @@ function credentialProvidersFromAuthData(data) {
10650
10625
  };
10651
10626
  }
10652
10627
  function resolvePublicAgentDir(explicit, home) {
10653
- return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join15(home, ".pi", "agent");
10628
+ return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join14(home, ".pi", "agent");
10654
10629
  }
10655
10630
  async function loadCredentialProviders(agentDir) {
10656
10631
  try {
10657
- const raw = await readFile8(join15(agentDir, "auth.json"), "utf8");
10632
+ const raw = await readFile8(join14(agentDir, "auth.json"), "utf8");
10658
10633
  return credentialProvidersFromAuthData(JSON.parse(raw));
10659
10634
  } catch (error) {
10660
10635
  if (isEnoent(error)) return { "openai-codex": false, xai: false };
@@ -10679,15 +10654,15 @@ var init_config = __esm({
10679
10654
 
10680
10655
  // src/public-cli/host-providers.ts
10681
10656
  import { readFileSync as readFileSync3 } from "node:fs";
10682
- import { join as join16 } from "node:path";
10657
+ import { join as join15 } from "node:path";
10683
10658
  function hostProvidersPath(home) {
10684
10659
  if (typeof home !== "string" || home.trim() === "") {
10685
10660
  throw new Error("home must be explicitly provided");
10686
10661
  }
10687
- return join16(home, ".ak-roles", "host-providers.json");
10662
+ return join15(home, ".ak-roles", "host-providers.json");
10688
10663
  }
10689
10664
  function hermesProviderModelsCachePath(home) {
10690
- return join16(home, ".hermes", "provider_models_cache.json");
10665
+ return join15(home, ".hermes", "provider_models_cache.json");
10691
10666
  }
10692
10667
  function parseHostProvidersTable(value) {
10693
10668
  if (!isRecord(value)) {
@@ -10838,15 +10813,15 @@ var init_host_providers = __esm({
10838
10813
 
10839
10814
  // src/public-cli/load-production-acp-host.ts
10840
10815
  import { existsSync as existsSync5 } from "node:fs";
10841
- import { join as join17 } from "node:path";
10816
+ import { join as join16 } from "node:path";
10842
10817
  import { pathToFileURL } from "node:url";
10843
10818
  async function loadProductionAcpHostFactory(packageRoot, host) {
10844
10819
  const description = lookupHostDescription(host);
10845
10820
  if (description === void 0) {
10846
10821
  throw new Error(`unregistered host: ${host}`);
10847
10822
  }
10848
- const built = join17(packageRoot, "dist/acp-host/production-host.js");
10849
- const source = join17(packageRoot, "src/acp-host/production-host.ts");
10823
+ const built = join16(packageRoot, "dist/acp-host/production-host.js");
10824
+ const source = join16(packageRoot, "src/acp-host/production-host.ts");
10850
10825
  const target = existsSync5(built) ? built : source;
10851
10826
  const href = pathToFileURL(target).href;
10852
10827
  const mod = await import(href);
@@ -10862,15 +10837,15 @@ var init_load_production_acp_host = __esm({
10862
10837
 
10863
10838
  // src/public-cli/load-production-headless-host.ts
10864
10839
  import { existsSync as existsSync6 } from "node:fs";
10865
- import { join as join18 } from "node:path";
10840
+ import { join as join17 } from "node:path";
10866
10841
  import { pathToFileURL as pathToFileURL2 } from "node:url";
10867
10842
  async function loadProductionHeadlessHostFactory(packageRoot, host) {
10868
10843
  const description = lookupHeadlessHostDescription(host);
10869
10844
  if (description === void 0) {
10870
10845
  throw new Error(`unregistered headless host: ${host}`);
10871
10846
  }
10872
- const built = join18(packageRoot, "dist/headless-host/production-host.js");
10873
- const source = join18(packageRoot, "src/headless-host/production-host.ts");
10847
+ const built = join17(packageRoot, "dist/headless-host/production-host.js");
10848
+ const source = join17(packageRoot, "src/headless-host/production-host.ts");
10874
10849
  const target = existsSync6(built) ? built : source;
10875
10850
  const href = pathToFileURL2(target).href;
10876
10851
  const mod = await import(href);
@@ -11038,7 +11013,7 @@ var init_role_seat_runtime = __esm({
11038
11013
  });
11039
11014
 
11040
11015
  // src/archivist-record-pointer.ts
11041
- import { basename as basename8, join as join19 } from "node:path";
11016
+ import { basename as basename8, join as join18 } from "node:path";
11042
11017
  function bookDirectOfficerRunPointer(options) {
11043
11018
  const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
11044
11019
  const pointer = {
@@ -11087,7 +11062,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
11087
11062
  };
11088
11063
  }
11089
11064
  async function readBookedOfficerPointers(parentRunDirectory) {
11090
- const { records, diagnostics } = await readSitianRecords(join19(parentRunDirectory, RUN_HISTORY_FILE));
11065
+ const { records, diagnostics } = await readSitianRecords(join18(parentRunDirectory, RUN_HISTORY_FILE));
11091
11066
  if (diagnostics.length > 0) {
11092
11067
  throw new Error(
11093
11068
  `${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
@@ -11151,7 +11126,7 @@ function createPiDoctorAuditor() {
11151
11126
  var init_doctor_auditor = __esm({
11152
11127
  "src/doctor-auditor.ts"() {
11153
11128
  "use strict";
11154
- init_auditor_dossier_tool();
11129
+ init_role_run_placement();
11155
11130
  init_compliance_transport();
11156
11131
  init_dossier_resolution();
11157
11132
  init_doctor_contracts();
@@ -11426,12 +11401,12 @@ var init_submission_gate = __esm({
11426
11401
  // src/session-opening-materials.ts
11427
11402
  import { existsSync as existsSync7 } from "node:fs";
11428
11403
  import { readFile as readFile9 } from "node:fs/promises";
11429
- import { dirname as dirname12, join as join20 } from "node:path";
11404
+ import { dirname as dirname12, join as join19 } from "node:path";
11430
11405
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
11431
11406
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
11432
11407
  let dir = dirname12(fileURLToPath(moduleUrl));
11433
11408
  for (let i = 0; i < 8; i += 1) {
11434
- if (existsSync7(join20(dir, "package.json")) && existsSync7(join20(dir, "souls"))) {
11409
+ if (existsSync7(join19(dir, "package.json")) && existsSync7(join19(dir, "souls"))) {
11435
11410
  return dir;
11436
11411
  }
11437
11412
  const parent = dirname12(dir);
@@ -11576,16 +11551,16 @@ var init_auditor_soul = __esm({
11576
11551
  // src/public-cli/machine-method-skills.ts
11577
11552
  import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
11578
11553
  import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
11579
- import { join as join22 } from "node:path";
11554
+ import { join as join21 } from "node:path";
11580
11555
  import { spawnSync as spawnSync2 } from "node:child_process";
11581
11556
  function skillRoot(home) {
11582
- return join22(home, ".agents/skills");
11557
+ return join21(home, ".agents/skills");
11583
11558
  }
11584
11559
  function installedMethodSkillPath(home, name) {
11585
11560
  return installedSkillPath(skillRoot(home), name);
11586
11561
  }
11587
11562
  function installedSkillPath(root, name) {
11588
- const path = join22(root, name, "SKILL.md");
11563
+ const path = join21(root, name, "SKILL.md");
11589
11564
  try {
11590
11565
  if (!statSync5(path).isFile()) return void 0;
11591
11566
  accessSync(path, constants2.R_OK);
@@ -11598,9 +11573,9 @@ function installedSkillPath(root, name) {
11598
11573
  }
11599
11574
  function linkedSkillRoot(home, host) {
11600
11575
  if (host === "claude" || host === "claude-code") {
11601
- return join22(process.env.CLAUDE_CONFIG_DIR?.trim() || join22(home, ".claude"), "skills");
11576
+ return join21(process.env.CLAUDE_CONFIG_DIR?.trim() || join21(home, ".claude"), "skills");
11602
11577
  }
11603
- if (host === "hermes") return join22(home, ".hermes/skills");
11578
+ if (host === "hermes") return join21(home, ".hermes/skills");
11604
11579
  return void 0;
11605
11580
  }
11606
11581
  async function occupied(path) {
@@ -11657,7 +11632,7 @@ async function runMachineSkillSetup(home, stdout) {
11657
11632
  const missingBySource = /* @__PURE__ */ new Map();
11658
11633
  let unsourced = false;
11659
11634
  for (const name of packagedMethodSkillNames()) {
11660
- const path = join22(canonical, name);
11635
+ const path = join21(canonical, name);
11661
11636
  if (await occupied(path)) {
11662
11637
  warnOccupied(path, stdout);
11663
11638
  continue;
@@ -11687,9 +11662,9 @@ async function runMachineSkillSetup(home, stdout) {
11687
11662
  throw error;
11688
11663
  }
11689
11664
  for (const name of packagedMethodSkillNames()) {
11690
- const target = join22(canonical, name);
11665
+ const target = join21(canonical, name);
11691
11666
  if (installedMethodSkillPath(home, name) === void 0) continue;
11692
- const link = join22(root, name);
11667
+ const link = join21(root, name);
11693
11668
  if (await occupied(link)) {
11694
11669
  warnOccupied(link, stdout);
11695
11670
  continue;
@@ -11748,7 +11723,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
11748
11723
  ...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
11749
11724
  ...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
11750
11725
  ...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
11751
- ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
11726
+ ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit },
11727
+ ...options.navigatorWorkContextPath === void 0 || options.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: options.navigatorWorkContextPath }
11752
11728
  };
11753
11729
  }
11754
11730
  function packagedSettleSkill(admitted) {
@@ -11775,11 +11751,6 @@ function activationForAdmitted(admitted) {
11775
11751
  const activation = { role: admitted.role };
11776
11752
  for (const spec of packagedRoleActivationFlags(admitted.role)) {
11777
11753
  let value = readAdmittedPath(admitted, spec.from ?? spec.field);
11778
- if (spec.fallback === "gate-pointer") {
11779
- const trimmed = typeof value === "string" ? value.trim() : "";
11780
- value = trimmed !== "" ? trimmed : parentRunPathFromGatePointerInstruction(admitted.instruction);
11781
- if (typeof value !== "string" || value === "") continue;
11782
- }
11783
11754
  if (value === void 0) continue;
11784
11755
  if (spec.text === true) {
11785
11756
  if (typeof value !== "number") continue;
@@ -11821,7 +11792,6 @@ var init_turn_request = __esm({
11821
11792
  init_engine_material();
11822
11793
  init_packaged_role_registry();
11823
11794
  init_machine_method_skills();
11824
- init_run_lifecycle();
11825
11795
  }
11826
11796
  });
11827
11797
 
@@ -12842,21 +12812,19 @@ async function dispatchPostAdmissionTurn(input) {
12842
12812
  }
12843
12813
  function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
12844
12814
  const officerDialogue = isStationChildOfficerDialogue(admitted.role, env);
12815
+ const fileFlags = summonsPrepared?.attachments ?? [];
12845
12816
  let prompt;
12846
12817
  if (request.message !== void 0) {
12847
12818
  if (summonsPrepared !== void 0) {
12848
- prompt = officerDialogue ? request.message : buildInstructionTransportPrompt({
12849
- instruction: request.message,
12850
- instructionEmpty: false,
12851
- attachments: summonsPrepared.attachments
12852
- });
12819
+ prompt = officerDialogue && fileFlags.length === 0 ? request.message : appendCallerFileFlagPaths(request.message, fileFlags);
12853
12820
  } else if (request.summons !== void 0) {
12854
12821
  prompt = request.message;
12855
12822
  } else {
12856
12823
  prompt = request.message;
12857
12824
  }
12858
12825
  } else if (summonsPrepared !== void 0) {
12859
- prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
12826
+ const body = summonsPrepared.instruction;
12827
+ prompt = officerDialogue && fileFlags.length === 0 ? body : appendCallerFileFlagPaths(body, fileFlags);
12860
12828
  } else if (request.summons !== void 0) {
12861
12829
  prompt = "";
12862
12830
  } else {
@@ -12872,7 +12840,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
12872
12840
  },
12873
12841
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
12874
12842
  // #1132: one configured ceiling, already resolved by the caller (#422).
12875
- deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
12843
+ deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit),
12844
+ ...env.navigatorWorkContextPath === void 0 || env.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: env.navigatorWorkContextPath }
12876
12845
  };
12877
12846
  }
12878
12847
  function roleTurnOptions(env, admitted, continuation) {
@@ -12884,7 +12853,8 @@ function roleTurnOptions(env, admitted, continuation) {
12884
12853
  continuation,
12885
12854
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
12886
12855
  // #1132: one configured ceiling, already resolved by the caller (#422).
12887
- deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
12856
+ deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit),
12857
+ ...env.navigatorWorkContextPath === void 0 || env.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: env.navigatorWorkContextPath }
12888
12858
  };
12889
12859
  }
12890
12860
  async function dispatchAfterWriterLease(input) {
@@ -13466,11 +13436,44 @@ function buildInstructionSeatTurnRequest(admitted, options) {
13466
13436
  options
13467
13437
  );
13468
13438
  }
13469
- function initialPrompt(admitted, env) {
13439
+ async function loadLedgerPeerBody(sourceRunDirectory, projectRoot, home) {
13440
+ const runId = runIdFromRunDirectory(sourceRunDirectory);
13441
+ if (runId === void 0) return void 0;
13442
+ const rows = await readRecordedSubmissionRows(projectRoot, runId, {
13443
+ home,
13444
+ sessionParent: sessionFileOf(sourceRunDirectory)
13445
+ });
13446
+ const latest = rows.at(-1);
13447
+ if (latest === void 0) return void 0;
13448
+ return readableGateItem(latest.accepted);
13449
+ }
13450
+ async function resolveReviewSeatDialogueBody(input) {
13451
+ const reask = input.reask;
13452
+ if (reask !== void 0 && reask.length > 0) return reask;
13453
+ const caller = input.callerInstruction ?? "";
13454
+ if (caller.length > 0) return caller;
13455
+ const sourceRunPath = input.sourceRunPath?.trim() ?? "";
13456
+ if (sourceRunPath === "") return void 0;
13457
+ return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
13458
+ }
13459
+ function admittedSourceRunPath(admitted) {
13460
+ return "sourceRunPath" in admitted && typeof admitted.sourceRunPath === "string" ? admitted.sourceRunPath.trim() : "";
13461
+ }
13462
+ async function resolveInitialPrompt(admitted, env) {
13470
13463
  const record = roleRecord(admitted.role);
13471
- const reask = env.reviewReask ?? env.gateReviewInstruction;
13472
- if (reask !== void 0 && "reaskPrompt" in record && record.reaskPrompt === true) {
13473
- return reask;
13464
+ if ("reaskPrompt" in record && record.reaskPrompt === true) {
13465
+ const sourceRunPath = admittedSourceRunPath(admitted);
13466
+ const reask = env.reviewReask ?? env.gateReviewInstruction;
13467
+ const body = await resolveReviewSeatDialogueBody({
13468
+ ...reask === void 0 ? {} : { reask },
13469
+ callerInstruction: admitted.instruction,
13470
+ ...sourceRunPath === "" ? {} : { sourceRunPath },
13471
+ projectRoot: admitted.projectRoot,
13472
+ home: env.home
13473
+ });
13474
+ if (body !== void 0) {
13475
+ return appendCallerFileFlagPaths(body, admitted.attachments);
13476
+ }
13474
13477
  }
13475
13478
  return buildInstructionTransportPrompt(admitted);
13476
13479
  }
@@ -13552,6 +13555,7 @@ async function dispatchAdmitted(admitted, env, io) {
13552
13555
  if (activeEnv.correlationId !== void 0 && activeEnv.correlationId.trim() !== "") {
13553
13556
  await recordAdmittedCorrelation(admitted, activeEnv.correlationId);
13554
13557
  }
13558
+ const initialPromptText = await resolveInitialPrompt(admitted, activeEnv);
13555
13559
  const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
13556
13560
  if (auto) {
13557
13561
  return await runPostAdmissionResumable({
@@ -13560,7 +13564,10 @@ async function dispatchAdmitted(admitted, env, io) {
13560
13564
  io: turnIo,
13561
13565
  buildInitialRequest: () => buildInstructionSeatTurnRequest(
13562
13566
  admitted,
13563
- roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
13567
+ roleTurnOptions(activeEnv, admitted, {
13568
+ kind: "initial",
13569
+ prompt: initialPromptText
13570
+ })
13564
13571
  ),
13565
13572
  buildResumeRequest: () => buildInstructionSeatTurnRequest(
13566
13573
  admitted,
@@ -13579,7 +13586,10 @@ async function dispatchAdmitted(admitted, env, io) {
13579
13586
  io: turnIo,
13580
13587
  request: buildInstructionSeatTurnRequest(
13581
13588
  admitted,
13582
- roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
13589
+ roleTurnOptions(activeEnv, admitted, {
13590
+ kind: "initial",
13591
+ prompt: initialPromptText
13592
+ })
13583
13593
  ),
13584
13594
  adapters,
13585
13595
  ...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
@@ -13679,10 +13689,19 @@ function resumeSameParentInstructionSeat(input) {
13679
13689
  )
13680
13690
  });
13681
13691
  }
13682
- function sameParentInstruction(env, fallback) {
13683
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
13684
- if (resumeInstruction === void 0) return fallback;
13685
- return { instruction: resumeInstruction, instructionEmpty: false };
13692
+ async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot) {
13693
+ const reask = env.reviewReask ?? env.gateReviewInstruction;
13694
+ const body = await resolveReviewSeatDialogueBody({
13695
+ ...reask === void 0 ? {} : { reask },
13696
+ callerInstruction: fallback.instruction,
13697
+ sourceRunPath,
13698
+ projectRoot,
13699
+ home: env.home
13700
+ });
13701
+ if (body !== void 0) {
13702
+ return { instruction: body, instructionEmpty: false };
13703
+ }
13704
+ return fallback;
13686
13705
  }
13687
13706
  async function runCountersignBody(parsed, env, io) {
13688
13707
  const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
@@ -13698,7 +13717,10 @@ async function runCountersignBody(parsed, env, io) {
13698
13717
  summons: {
13699
13718
  sourceRunPath: gateParentRunPath,
13700
13719
  instruction: resumeInstruction,
13701
- instructionEmpty: resumeInstruction.length === 0
13720
+ instructionEmpty: resumeInstruction.length === 0,
13721
+ // #1166 J11: same-parent resume delivers this call's file-flag paths
13722
+ // through the shared summons → appendCallerFileFlagPaths rule.
13723
+ attachmentPaths: parsed.attachmentPaths ?? []
13702
13724
  }
13703
13725
  });
13704
13726
  if (resumed != null) return resumed;
@@ -13730,9 +13752,10 @@ async function runCountersignBody(parsed, env, io) {
13730
13752
  await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
13731
13753
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
13732
13754
  }
13755
+ const reviewBody = env.reviewReask ?? env.gateReviewInstruction;
13733
13756
  const turnProjection = roleTurnOptions(env, admitted, {
13734
13757
  kind: "initial",
13735
- prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(admitted)
13758
+ prompt: reviewBody !== void 0 ? appendCallerFileFlagPaths(reviewBody, admitted.attachments) : buildInstructionTransportPrompt(admitted)
13736
13759
  });
13737
13760
  const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
13738
13761
  const result = await runPostAdmissionOneShot({
@@ -13815,10 +13838,15 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
13815
13838
  if (auditorSource === void 0) return { exitCode: 2 };
13816
13839
  const sourceDirectory = auditorSource;
13817
13840
  const summons = {
13818
- ...sameParentInstruction(env, {
13819
- instruction: parsed.instruction ?? "",
13820
- instructionEmpty: (parsed.instruction ?? "").length === 0
13821
- }),
13841
+ ...await sameParentDialogue(
13842
+ env,
13843
+ {
13844
+ instruction: parsed.instruction ?? "",
13845
+ instructionEmpty: (parsed.instruction ?? "").length === 0
13846
+ },
13847
+ sourceDirectory,
13848
+ projectRoot
13849
+ ),
13822
13850
  attachmentPaths: parsed.attachmentPaths ?? []
13823
13851
  };
13824
13852
  const resumed = await withAuditorSoulEnv({
@@ -13835,15 +13863,33 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
13835
13863
  });
13836
13864
  if (resumed != null) return resumed;
13837
13865
  }
13838
- if (record.sameParent === "gate-pointer") {
13839
- const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
13840
- if (parentRunPath !== void 0) {
13866
+ if (record.sameParent === "source-run") {
13867
+ if (parsed.sourceRun !== void 0) {
13868
+ let parentRunPath;
13869
+ try {
13870
+ parentRunPath = (await resolveNotarySourceRunLocator({
13871
+ projectRoot,
13872
+ sourceRun: parsed.sourceRun,
13873
+ home: env.home
13874
+ })).runDirectory;
13875
+ } catch (error) {
13876
+ if (error instanceof NotarySourceRunError) {
13877
+ presentStructuralRejection(new CliUsageError(error.message, { cause: error }), io);
13878
+ return { exitCode: 2 };
13879
+ }
13880
+ throw error;
13881
+ }
13841
13882
  const summons = {
13842
13883
  sourceRunPath: parentRunPath,
13843
- ...sameParentInstruction(env, {
13844
- instruction: parsed.instruction ?? "",
13845
- instructionEmpty: (parsed.instruction ?? "").length === 0
13846
- }),
13884
+ ...await sameParentDialogue(
13885
+ env,
13886
+ {
13887
+ instruction: parsed.instruction ?? "",
13888
+ instructionEmpty: (parsed.instruction ?? "").length === 0
13889
+ },
13890
+ parentRunPath,
13891
+ projectRoot
13892
+ ),
13847
13893
  attachmentPaths: parsed.attachmentPaths ?? []
13848
13894
  };
13849
13895
  const resumed = await resumeSameParentInstructionSeat({
@@ -13872,11 +13918,15 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
13872
13918
  }
13873
13919
  throw error;
13874
13920
  }
13875
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
13876
13921
  const summons = {
13877
13922
  sourceRunPath: source.runDirectory,
13878
13923
  sourceRun: source,
13879
- ...resumeInstruction === void 0 ? {} : { instruction: resumeInstruction, instructionEmpty: false }
13924
+ ...await sameParentDialogue(
13925
+ env,
13926
+ { instruction: "", instructionEmpty: true },
13927
+ source.runDirectory,
13928
+ projectRoot
13929
+ )
13880
13930
  };
13881
13931
  resolvedNotarySource = source;
13882
13932
  const resumed = await resumeSameParentInstructionSeat({
@@ -13906,16 +13956,18 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
13906
13956
  if (rejected !== void 0) return rejected;
13907
13957
  throw error;
13908
13958
  }
13909
- if (record.sameParent === "gate-pointer") {
13910
- const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
13911
- if (parentRunPath !== void 0) {
13912
- await persistAdmittedSourceRunPath(admitted, parentRunPath);
13913
- const sourcePatch = { sourceRunPath: parentRunPath };
13914
- admitted = { ...admitted, ...sourcePatch };
13915
- }
13959
+ if (record.sameParent === "source-run" && parsed.sourceRun !== void 0) {
13960
+ const parentRunPath = (await resolveNotarySourceRunLocator({
13961
+ projectRoot,
13962
+ sourceRun: parsed.sourceRun,
13963
+ home: env.home
13964
+ })).runDirectory;
13965
+ await persistAdmittedSourceRunPath(admitted, parentRunPath);
13966
+ admitted = { ...admitted, sourceRunPath: parentRunPath };
13916
13967
  }
13917
13968
  if (record.sameParent === "subject-source" && auditorSource !== void 0) {
13918
13969
  await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
13970
+ admitted = { ...admitted, sourceRunPath: auditorSource };
13919
13971
  }
13920
13972
  const runAdmitted = async () => {
13921
13973
  await markRunAdmitted(admitted, env.principalAuthority);
@@ -14244,13 +14296,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
14244
14296
  summonAuditor: async (subject, sourceRunDirectory, signal, reask, submission) => {
14245
14297
  const summoned = await summonPublicRole({
14246
14298
  role: "auditor",
14247
- argv: [
14248
- "--subject",
14249
- subject,
14250
- "--source-run",
14251
- sourceRunDirectory,
14252
- `${AUDITOR_DOSSIER_PROMPT}${sourceRunDirectory}`
14253
- ],
14299
+ argv: ["--subject", subject, "--source-run", sourceRunDirectory],
14254
14300
  cwd: admitted.projectRoot,
14255
14301
  home: env.home,
14256
14302
  packageRoot: env.packageRoot,
@@ -14410,7 +14456,6 @@ var init_instruction_seat_run = __esm({
14410
14456
  "src/public-cli/instruction-seat-run.ts"() {
14411
14457
  "use strict";
14412
14458
  init_role_run_placement();
14413
- init_compliance_transport();
14414
14459
  init_archivist_record_pointer();
14415
14460
  init_doctor_auditor();
14416
14461
  init_gatekeeper_role();
@@ -14520,10 +14565,10 @@ var init_analyst_book_key = __esm({
14520
14565
  // src/atomic-write.ts
14521
14566
  import { randomUUID as randomUUID6 } from "node:crypto";
14522
14567
  import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
14523
- import { dirname as dirname14, join as join23 } from "node:path";
14568
+ import { dirname as dirname14, join as join22 } from "node:path";
14524
14569
  async function writeFileAtomically(destination, contents, options) {
14525
14570
  const parent = dirname14(destination);
14526
- const temporary = join23(parent, `.atomic-write-${randomUUID6()}.tmp`);
14571
+ const temporary = join22(parent, `.atomic-write-${randomUUID6()}.tmp`);
14527
14572
  try {
14528
14573
  await writeFile3(temporary, contents, options);
14529
14574
  await rename2(temporary, destination);
@@ -14540,12 +14585,12 @@ var init_atomic_write = __esm({
14540
14585
 
14541
14586
  // src/analyst-index.ts
14542
14587
  import { open, readFile as readFile10, unlink } from "node:fs/promises";
14543
- import { dirname as dirname15, join as join24 } from "node:path";
14588
+ import { dirname as dirname15, join as join23 } from "node:path";
14544
14589
  import { setTimeout as sleep } from "node:timers/promises";
14545
14590
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
14546
14591
  const indexPath = analystLibraryIndexPath(ledgerHome);
14547
14592
  ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
14548
- const lockPath = join24(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
14593
+ const lockPath = join23(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
14549
14594
  assertLedgerFileInsideHome(lockPath, ledgerHome);
14550
14595
  const startedAt = Date.now();
14551
14596
  while (true) {
@@ -14572,7 +14617,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
14572
14617
  }
14573
14618
  }
14574
14619
  function analystLibraryIndexPath(ledgerHome) {
14575
- return join24(ledgerHome, "analyst", "library-index.json");
14620
+ return join23(ledgerHome, "analyst", "library-index.json");
14576
14621
  }
14577
14622
  function rowFromIssueMetricsPage(page) {
14578
14623
  return {
@@ -15118,7 +15163,7 @@ var init_analyst_gate_cycles_read = __esm({
15118
15163
 
15119
15164
  // src/analyst-ledger.ts
15120
15165
  import { readdir as readdir3 } from "node:fs/promises";
15121
- import { basename as basename10, join as join25 } from "node:path";
15166
+ import { basename as basename10, join as join24 } from "node:path";
15122
15167
  async function readExistingRunLifecycleState(runDirectory) {
15123
15168
  return (await readRoleRunIdentity(runDirectory))?.state;
15124
15169
  }
@@ -15138,7 +15183,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
15138
15183
  }
15139
15184
  }
15140
15185
  async function classifyGhostCandidate(input) {
15141
- const autopsy = await autopsyWriterLock(join25(input.runDirectory, "writer.lock"));
15186
+ const autopsy = await autopsyWriterLock(join24(input.runDirectory, "writer.lock"));
15142
15187
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
15143
15188
  if (leaseCheck === void 0) return { kind: "live" };
15144
15189
  return {
@@ -15428,7 +15473,7 @@ async function classifyScopedRun(input) {
15428
15473
  async function scanAnalystIssueRuns(input) {
15429
15474
  const ledgerHome = resolveActivationLedgerHome(input.home);
15430
15475
  const scopeTicketNumber = input.ticketNumber;
15431
- const booksRoot = join25(ledgerHome, "books");
15476
+ const booksRoot = join24(ledgerHome, "books");
15432
15477
  let wholeBook = false;
15433
15478
  let scopeRootIdentity;
15434
15479
  let bookNames;
@@ -15461,7 +15506,7 @@ async function scanAnalystIssueRuns(input) {
15461
15506
  const ghostLegs = [];
15462
15507
  const scopeConflicts = [];
15463
15508
  for (const book of bookNames) {
15464
- const bookDir = join25(booksRoot, book);
15509
+ const bookDir = join24(booksRoot, book);
15465
15510
  let runDirectories;
15466
15511
  try {
15467
15512
  runDirectories = await listBookRunDirectories(bookDir);
@@ -16207,7 +16252,7 @@ var init_analyst_metric_family = __esm({
16207
16252
  });
16208
16253
 
16209
16254
  // src/analyst-page.ts
16210
- import { dirname as dirname16, join as join26 } from "node:path";
16255
+ import { dirname as dirname16, join as join25 } from "node:path";
16211
16256
  function analystIssuePageKey(address) {
16212
16257
  const parts = ["book", address.bookKey];
16213
16258
  if (address.issueNumber !== void 0) {
@@ -16218,7 +16263,7 @@ function analystIssuePageKey(address) {
16218
16263
  return sha256Hex(parts.join("\0")).slice(0, 32);
16219
16264
  }
16220
16265
  function analystIssuePagePath(ledgerHome, address) {
16221
- return join26(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16266
+ return join25(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16222
16267
  }
16223
16268
  function analystIssuePageAddressFromPage(page) {
16224
16269
  return {
@@ -16455,7 +16500,7 @@ var init_analyst_model_groups = __esm({
16455
16500
 
16456
16501
  // src/analyst-entry.ts
16457
16502
  import { readFile as readFile12 } from "node:fs/promises";
16458
- import { Type as Type16 } from "typebox";
16503
+ import { Type as Type15 } from "typebox";
16459
16504
  function cachedPageMatchesRequestedScope(page, input) {
16460
16505
  if (page.bookKey !== input.bookKey) return false;
16461
16506
  const requestedTicket = input.ticketNumber ?? input.issueNumber;
@@ -16660,16 +16705,16 @@ var init_analyst_entry = __esm({
16660
16705
  }
16661
16706
  }
16662
16707
  };
16663
- analystSweepModeInputSchema = Type16.Object(
16708
+ analystSweepModeInputSchema = Type15.Object(
16664
16709
  {
16665
- mode: Type16.Literal("sweep"),
16666
- mergedPullRequests: Type16.Array(
16667
- Type16.Object(
16710
+ mode: Type15.Literal("sweep"),
16711
+ mergedPullRequests: Type15.Array(
16712
+ Type15.Object(
16668
16713
  {
16669
- projectRoot: Type16.String(),
16714
+ projectRoot: Type15.String(),
16670
16715
  /** 排除后改动行数 — omit or 0 → typed 空缺; finite ≥ 0 only. */
16671
- changedLines: Type16.Optional(
16672
- Type16.Number({ minimum: 0, maximum: Number.MAX_VALUE })
16716
+ changedLines: Type15.Optional(
16717
+ Type15.Number({ minimum: 0, maximum: Number.MAX_VALUE })
16673
16718
  )
16674
16719
  }
16675
16720
  )
@@ -17764,7 +17809,7 @@ __export(public_role_summons_exports, {
17764
17809
  import { execFile as execFile3 } from "node:child_process";
17765
17810
  import { existsSync as existsSync8 } from "node:fs";
17766
17811
  import { realpath as realpath6 } from "node:fs/promises";
17767
- import { join as join27 } from "node:path";
17812
+ import { join as join26 } from "node:path";
17768
17813
  import { promisify as promisify3 } from "node:util";
17769
17814
  function createCapturingIo() {
17770
17815
  const chunks = [];
@@ -17788,7 +17833,7 @@ function parentDir(path) {
17788
17833
  function walkPackageRoot(start) {
17789
17834
  let dir = start;
17790
17835
  for (let i = 0; i < 12; i += 1) {
17791
- if (existsSync8(join27(dir, "package.json")) && existsSync8(join27(dir, "souls"))) {
17836
+ if (existsSync8(join26(dir, "package.json")) && existsSync8(join26(dir, "souls"))) {
17792
17837
  return dir;
17793
17838
  }
17794
17839
  const parent = parentDir(dir);
@@ -17956,7 +18001,8 @@ async function summonPublicRole(options) {
17956
18001
  ...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
17957
18002
  ...options.parentRunPath === void 0 || options.parentRunPath.trim() === "" ? {} : { parentRunPath: options.parentRunPath },
17958
18003
  ...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
17959
- ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
18004
+ ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
18005
+ ...options.navigatorWorkContextPath === void 0 || options.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: options.navigatorWorkContextPath }
17960
18006
  }
17961
18007
  };
17962
18008
  } catch (error) {
@@ -18213,7 +18259,8 @@ async function summonGateOfficer(options) {
18213
18259
  "judge",
18214
18260
  "--source-run",
18215
18261
  options.sourceRunDirectory,
18216
- `\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`
18262
+ "--project",
18263
+ options.cwd
18217
18264
  ],
18218
18265
  ...common
18219
18266
  });
@@ -18241,7 +18288,7 @@ async function summonGateOfficer(options) {
18241
18288
  }
18242
18289
  return summonPublicRole({
18243
18290
  role: options.officer,
18244
- argv: [`\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`],
18291
+ argv: ["--source-run", options.sourceRunDirectory, "--project", options.cwd],
18245
18292
  ...common
18246
18293
  });
18247
18294
  }
@@ -18349,8 +18396,7 @@ async function runComplianceAudit(options) {
18349
18396
  "--subject",
18350
18397
  auditSubject,
18351
18398
  "--source-run",
18352
- sourceRunDirectory,
18353
- `${AUDITOR_DOSSIER_PROMPT}${sourceRunDirectory}`
18399
+ sourceRunDirectory
18354
18400
  ],
18355
18401
  cwd: options.context.cwd ?? process.cwd(),
18356
18402
  home,
@@ -18374,18 +18420,17 @@ async function runComplianceAudit(options) {
18374
18420
  return decision;
18375
18421
  }
18376
18422
  }
18377
- var AUDITOR_DOSSIER_PROMPT, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, ComplianceResponseRetentionError;
18423
+ var AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, ComplianceResponseRetentionError;
18378
18424
  var init_compliance_transport = __esm({
18379
18425
  "src/compliance-transport.ts"() {
18380
18426
  "use strict";
18381
- init_auditor_dossier_tool();
18427
+ init_role_run_placement();
18382
18428
  init_gatekeeper_role();
18383
18429
  init_submission_errors();
18384
18430
  init_terminal();
18385
18431
  init_readable_gate_item();
18386
18432
  init_receipt_delivery_policy();
18387
18433
  init_unknown_value();
18388
- AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
18389
18434
  AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
18390
18435
  ComplianceResponseRetentionError = class extends Error {
18391
18436
  constructor(message, options) {
@@ -18397,7 +18442,7 @@ var init_compliance_transport = __esm({
18397
18442
  });
18398
18443
 
18399
18444
  // src/role-run-relocation.ts
18400
- import { dirname as dirname17, join as join28, sep as sep4 } from "node:path";
18445
+ import { dirname as dirname17, join as join27, sep as sep4 } from "node:path";
18401
18446
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
18402
18447
  if (typeof value !== "string") return value;
18403
18448
  if (value === oldRunDirectory) return newRunDirectory;
@@ -18515,7 +18560,6 @@ var init_role_run_relocation = __esm({
18515
18560
  var run_lifecycle_exports = {};
18516
18561
  __export(run_lifecycle_exports, {
18517
18562
  AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
18518
- GATE_DOSSIER_POINTER_PREFIX: () => GATE_DOSSIER_POINTER_PREFIX,
18519
18563
  RESUME_TRANSPORT_ENVELOPE: () => RESUME_TRANSPORT_ENVELOPE,
18520
18564
  RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
18521
18565
  acquireRunWriterLease: () => acquireRunWriterLease,
@@ -18529,7 +18573,6 @@ __export(run_lifecycle_exports, {
18529
18573
  markRunAdmitted: () => markRunAdmitted,
18530
18574
  markRunRunning: () => markRunRunning,
18531
18575
  markRunTerminal: () => markRunTerminal,
18532
- parentRunPathFromGatePointerInstruction: () => parentRunPathFromGatePointerInstruction,
18533
18576
  peekRoleRunRole: () => peekRoleRunRole,
18534
18577
  readCurrentCourt: () => readCurrentCourt,
18535
18578
  readRoleRunIdentity: () => readRoleRunIdentity,
@@ -18539,7 +18582,7 @@ __export(run_lifecycle_exports, {
18539
18582
  writeRoleRunState: () => writeRoleRunState
18540
18583
  });
18541
18584
  import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
18542
- import { basename as basename11, join as join29 } from "node:path";
18585
+ import { basename as basename11, join as join28 } from "node:path";
18543
18586
  function buildAutoResumeContinuationPrompt() {
18544
18587
  return RESUME_TRANSPORT_ENVELOPE;
18545
18588
  }
@@ -18836,7 +18879,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
18836
18879
  },
18837
18880
  relocate(nextRunDirectory) {
18838
18881
  currentRunDirectory = nextRunDirectory;
18839
- currentLockPath = join29(nextRunDirectory, WRITER_LOCK_FILE);
18882
+ currentLockPath = join28(nextRunDirectory, WRITER_LOCK_FILE);
18840
18883
  },
18841
18884
  async release() {
18842
18885
  if (released) return;
@@ -18875,10 +18918,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
18875
18918
  };
18876
18919
  const reportReadFailure = (error) => {
18877
18920
  reportDiagnostic(
18878
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join29(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18921
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join28(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18879
18922
  );
18880
18923
  };
18881
- const lockPath = join29(runDirectory, WRITER_LOCK_FILE);
18924
+ const lockPath = join28(runDirectory, WRITER_LOCK_FILE);
18882
18925
  let lastAutopsy = { verdict: "absent" };
18883
18926
  let lastReclaimFailure;
18884
18927
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -18935,7 +18978,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
18935
18978
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
18936
18979
  if (runId.trim() === "") return void 0;
18937
18980
  const ledgerHome = resolveActivationLedgerHome(home);
18938
- const booksRoot = join29(ledgerHome, "books");
18981
+ const booksRoot = join28(ledgerHome, "books");
18939
18982
  let bookKeys;
18940
18983
  try {
18941
18984
  bookKeys = await readdir4(booksRoot);
@@ -18949,20 +18992,12 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
18949
18992
  onlyRole
18950
18993
  );
18951
18994
  }
18952
- function parentRunPathFromGatePointerInstruction(instruction) {
18953
- if (!instruction.startsWith(GATE_DOSSIER_POINTER_PREFIX)) return void 0;
18954
- const path = instruction.slice(GATE_DOSSIER_POINTER_PREFIX.length).trim();
18955
- return path === "" ? void 0 : path;
18956
- }
18957
18995
  async function readRunParentPath(runDirectory) {
18958
18996
  const record = readPageSync(runDirectory, "admitted");
18959
18997
  if (record === void 0) return void 0;
18960
18998
  if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
18961
18999
  return record.sourceRunPath;
18962
19000
  }
18963
- if (typeof record.instruction === "string") {
18964
- return parentRunPathFromGatePointerInstruction(record.instruction);
18965
- }
18966
19001
  return void 0;
18967
19002
  }
18968
19003
  async function runHasFormedSessionPrincipal(runDirectory) {
@@ -18986,7 +19021,7 @@ async function findLatestRunIdForSeatTicket(input) {
18986
19021
  let runDirectories;
18987
19022
  try {
18988
19023
  runDirectories = await listBookRunDirectories(
18989
- input.ticketNumber === void 0 ? bookDir : join29(bookDir, String(input.ticketNumber))
19024
+ input.ticketNumber === void 0 ? bookDir : join28(bookDir, String(input.ticketNumber))
18990
19025
  );
18991
19026
  } catch (error) {
18992
19027
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -19468,7 +19503,7 @@ function resumedWorkerPhase(phase, phases, role, runId) {
19468
19503
  }
19469
19504
  throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
19470
19505
  }
19471
- var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS, GATE_DOSSIER_POINTER_PREFIX;
19506
+ var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
19472
19507
  var init_run_lifecycle = __esm({
19473
19508
  "src/public-cli/run-lifecycle.ts"() {
19474
19509
  "use strict";
@@ -19501,7 +19536,6 @@ var init_run_lifecycle = __esm({
19501
19536
  }
19502
19537
  };
19503
19538
  WRITER_LEASE_RECLAIM_ROUNDS = 3;
19504
- GATE_DOSSIER_POINTER_PREFIX = "\u5377\u5B97\u6307\u9488\uFF1A";
19505
19539
  }
19506
19540
  });
19507
19541
 
@@ -19729,7 +19763,7 @@ var init_receipt_delivery_policy = __esm({
19729
19763
  });
19730
19764
 
19731
19765
  // src/archivist-record-topology.ts
19732
- import { join as join31 } from "node:path";
19766
+ import { join as join30 } from "node:path";
19733
19767
  function resolveNavigatorWorkSubjectPlacement(input) {
19734
19768
  let ledgerHome;
19735
19769
  if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
@@ -19742,7 +19776,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
19742
19776
  const digest = sha256Hex(input.subject).slice(0, 32);
19743
19777
  return {
19744
19778
  ledgerHome,
19745
- sessionDir: join31(
19779
+ sessionDir: join30(
19746
19780
  activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
19747
19781
  NAVIGATOR_RECORD_KIND,
19748
19782
  digest
@@ -19815,7 +19849,7 @@ import {
19815
19849
  statSync as statSync8,
19816
19850
  writeFileSync as writeFileSync3
19817
19851
  } from "node:fs";
19818
- import { dirname as dirname19, resolve as resolve16, join as join32 } from "node:path";
19852
+ import { dirname as dirname19, resolve as resolve16, join as join31 } from "node:path";
19819
19853
  import { StringDecoder } from "node:string_decoder";
19820
19854
  function readCurrentSession(sessionDir) {
19821
19855
  const ledger = currentSessionLedgerPath(sessionDir);
@@ -19849,7 +19883,7 @@ function isCurrentSessionClaimRace(error) {
19849
19883
  return errnoCode(error.cause) === "EEXIST";
19850
19884
  }
19851
19885
  function currentSessionLedgerPath(sessionDir) {
19852
- return join32(sessionDir, CURRENT_SESSION_LEDGER);
19886
+ return join31(sessionDir, CURRENT_SESSION_LEDGER);
19853
19887
  }
19854
19888
  function readBoundedSessionHeader(filePath) {
19855
19889
  const fd = openSync(filePath, "r");
@@ -19936,7 +19970,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
19936
19970
  const matched = [];
19937
19971
  for (const name of names) {
19938
19972
  if (!name.endsWith(".jsonl")) continue;
19939
- const filePath = join32(absoluteSessionDir, name);
19973
+ const filePath = join31(absoluteSessionDir, name);
19940
19974
  let st;
19941
19975
  try {
19942
19976
  st = statSync8(filePath);
@@ -20135,22 +20169,22 @@ init_submission_ledger();
20135
20169
  init_filed_submission();
20136
20170
  import { randomUUID as randomUUID7 } from "node:crypto";
20137
20171
  import { writeSync as writeSync2 } from "node:fs";
20138
- import { join as join34 } from "node:path";
20172
+ import { join as join33 } from "node:path";
20139
20173
  import { Value as Value3 } from "typebox/value";
20140
20174
 
20141
20175
  // src/activation-trace.ts
20142
- import { Type as Type17 } from "typebox";
20143
- var causeSchema = Type17.Object({
20144
- identity: Type17.String({ minLength: 1 }),
20145
- name: Type17.String({ minLength: 1 }),
20146
- message: Type17.String(),
20147
- evidenceId: Type17.Optional(Type17.String({ minLength: 1 }))
20176
+ import { Type as Type16 } from "typebox";
20177
+ var causeSchema = Type16.Object({
20178
+ identity: Type16.String({ minLength: 1 }),
20179
+ name: Type16.String({ minLength: 1 }),
20180
+ message: Type16.String(),
20181
+ evidenceId: Type16.Optional(Type16.String({ minLength: 1 }))
20148
20182
  }, { additionalProperties: false });
20149
- var activationTraceRecordSchema = Type17.Object({
20150
- role: Type17.String({ minLength: 1 }),
20151
- stageId: Type17.String({ pattern: "^[a-z][a-z0-9-]*$" }),
20152
- status: Type17.Literal("failed"),
20153
- timestamp: Type17.String({ format: "date-time" }),
20183
+ var activationTraceRecordSchema = Type16.Object({
20184
+ role: Type16.String({ minLength: 1 }),
20185
+ stageId: Type16.String({ pattern: "^[a-z][a-z0-9-]*$" }),
20186
+ status: Type16.Literal("failed"),
20187
+ timestamp: Type16.String({ format: "date-time" }),
20154
20188
  cause: causeSchema
20155
20189
  }, { additionalProperties: false });
20156
20190
  var activationCauseEvidence = 0;
@@ -20315,10 +20349,10 @@ init_engine_material();
20315
20349
  init_engine_detour();
20316
20350
  init_engine_detour_usage();
20317
20351
  init_run_terminal_artifacts();
20318
- import { Type as Type18 } from "typebox";
20319
- var engineDetourArgsSchema = Type18.Object(
20352
+ import { Type as Type17 } from "typebox";
20353
+ var engineDetourArgsSchema = Type17.Object(
20320
20354
  {
20321
- argv: Type18.Array(Type18.String({ minLength: 1 }), {
20355
+ argv: Type17.Array(Type17.String({ minLength: 1 }), {
20322
20356
  minItems: 1,
20323
20357
  description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
20324
20358
  })
@@ -20639,6 +20673,24 @@ ${JSON.stringify(catalog)}
20639
20673
  init_filed_submission();
20640
20674
  init_role_submission_declarations();
20641
20675
  init_run_ticket_number();
20676
+
20677
+ // src/audited-run-identity.ts
20678
+ init_role_run_placement();
20679
+ import { basename as basename12 } from "node:path";
20680
+ var AUDITED_RUN_IDENTITY_KIND = "audited-run-identity";
20681
+ function auditedRunIdentityFromDirectory(runDirectory) {
20682
+ const parsed = parseRunLeaf(basename12(runDirectory));
20683
+ if (parsed === void 0) return void 0;
20684
+ return formatRunLeaf(parsed.runId, parsed.role);
20685
+ }
20686
+ function auditedRunIdentityMaterial(identity) {
20687
+ return { kind: AUDITED_RUN_IDENTITY_KIND, identity };
20688
+ }
20689
+ function auditedRunIdentityFromParts(runId, role) {
20690
+ return formatRunLeaf(runId, role);
20691
+ }
20692
+
20693
+ // src/notary-role.ts
20642
20694
  init_notary_contracts();
20643
20695
  function readNotaryTicketFlag(flag) {
20644
20696
  if (flag === void 0) return void 0;
@@ -20656,11 +20708,10 @@ function readNotaryTicketFlag(flag) {
20656
20708
  }
20657
20709
  return n;
20658
20710
  }
20659
- function projectNotarySessionBound(input) {
20660
- return {
20661
- sourceRun: input.sourceRun,
20662
- ...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
20663
- };
20711
+ function projectNotaryAuditedRunIdentity(input) {
20712
+ return auditedRunIdentityMaterial(
20713
+ auditedRunIdentityFromParts(input.sourceRun.runId, input.sourceRun.role)
20714
+ );
20664
20715
  }
20665
20716
  var NOTARY_SESSION_BOUND_ENTRY = "notary-session-bound";
20666
20717
  function projectNotaryBoundFromFlags(getFlag) {
@@ -20718,9 +20769,8 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
20718
20769
  baseSystemPrompt: event.systemPrompt,
20719
20770
  soul: activation.soul
20720
20771
  }),
20721
- readingMaterial: projectNotarySessionBound({
20722
- sourceRun: activation.sourceRun,
20723
- ...activation.ticketNumber === void 0 ? {} : { ticketNumber: activation.ticketNumber }
20772
+ readingMaterial: projectNotaryAuditedRunIdentity({
20773
+ sourceRun: activation.sourceRun
20724
20774
  })
20725
20775
  };
20726
20776
  });
@@ -20805,16 +20855,16 @@ init_packaged_role_registry();
20805
20855
  init_activation_ledger_topology();
20806
20856
  import { resolve as resolve17 } from "node:path";
20807
20857
  import "@earendil-works/pi-coding-agent";
20808
- import { Type as Type20 } from "typebox";
20858
+ import { Type as Type19 } from "typebox";
20809
20859
 
20810
20860
  // src/navigator-public-session.ts
20811
20861
  init_host_session_record();
20812
20862
  import { existsSync as existsSync12 } from "node:fs";
20813
- import { basename as basename13 } from "node:path";
20863
+ import { basename as basename14 } from "node:path";
20814
20864
 
20815
20865
  // src/navigator-session-contracts.ts
20816
20866
  init_unknown_value();
20817
- import { Type as Type19 } from "typebox";
20867
+ import { Type as Type18 } from "typebox";
20818
20868
  import { Value as Value2 } from "typebox/value";
20819
20869
  var NAVIGATOR_PREPARE_TOOL_NAME = "ak_navigator_prepare";
20820
20870
  var NAVIGATOR_UNAVAILABLE_KEYS = /* @__PURE__ */ new Set([
@@ -20919,26 +20969,26 @@ function navigatorProviderFailureFromPublicTerminal(outcome) {
20919
20969
  if (typed !== void 0) return { source: typed, cause: typed };
20920
20970
  return { source: "unknown", cause: "unknown" };
20921
20971
  }
20922
- var navigatorProviderFailureSchema = Type19.Object({
20923
- source: Type19.Union([
20924
- Type19.Literal("context"),
20925
- Type19.Literal("session"),
20926
- Type19.Literal("model"),
20927
- Type19.Literal("thinking"),
20928
- Type19.Literal("auth"),
20929
- Type19.Literal("quota"),
20930
- Type19.Literal("transport"),
20931
- Type19.Literal("unknown")
20972
+ var navigatorProviderFailureSchema = Type18.Object({
20973
+ source: Type18.Union([
20974
+ Type18.Literal("context"),
20975
+ Type18.Literal("session"),
20976
+ Type18.Literal("model"),
20977
+ Type18.Literal("thinking"),
20978
+ Type18.Literal("auth"),
20979
+ Type18.Literal("quota"),
20980
+ Type18.Literal("transport"),
20981
+ Type18.Literal("unknown")
20932
20982
  ]),
20933
- cause: Type19.Union([
20934
- Type19.Literal("context"),
20935
- Type19.Literal("session"),
20936
- Type19.Literal("model"),
20937
- Type19.Literal("thinking"),
20938
- Type19.Literal("auth"),
20939
- Type19.Literal("quota"),
20940
- Type19.Literal("transport"),
20941
- Type19.Literal("unknown")
20983
+ cause: Type18.Union([
20984
+ Type18.Literal("context"),
20985
+ Type18.Literal("session"),
20986
+ Type18.Literal("model"),
20987
+ Type18.Literal("thinking"),
20988
+ Type18.Literal("auth"),
20989
+ Type18.Literal("quota"),
20990
+ Type18.Literal("transport"),
20991
+ Type18.Literal("unknown")
20942
20992
  ])
20943
20993
  }, { additionalProperties: false });
20944
20994
  function parseNavigatorModelSetting(value) {
@@ -21005,17 +21055,18 @@ init_atomic_write();
21005
21055
  init_unknown_value();
21006
21056
  import { existsSync as existsSync9, realpathSync as realpathSync3 } from "node:fs";
21007
21057
  import { readFile as readFile15 } from "node:fs/promises";
21008
- import { basename as basename12, dirname as dirname18, join as join30, resolve as resolve15 } from "node:path";
21058
+ import { basename as basename13, dirname as dirname18, join as join29, resolve as resolve15 } from "node:path";
21009
21059
  var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
21060
+ var AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV = "AK_ROLE_NAVIGATOR_WORK_CONTEXT";
21010
21061
  function navigatorWorkContextFile(sessionDir) {
21011
- return join30(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
21062
+ return join29(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
21012
21063
  }
21013
21064
  function isNavigatorWorkContextFile(path) {
21014
21065
  const resolved = resolve15(path);
21015
- if (basename12(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
21066
+ if (basename13(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
21016
21067
  const nest = dirname18(resolved);
21017
- if (!/^[0-9a-f]{32}$/.test(basename12(nest))) return false;
21018
- return basename12(dirname18(nest)) === "navigator";
21068
+ if (!/^[0-9a-f]{32}$/.test(basename13(nest))) return false;
21069
+ return basename13(dirname18(nest)) === "navigator";
21019
21070
  }
21020
21071
  function canonicalNavigatorWorkContextFile(path) {
21021
21072
  if (!isNavigatorWorkContextFile(path)) return void 0;
@@ -21063,33 +21114,8 @@ async function readNavigatorWorkBase(path) {
21063
21114
  if (record.authority.trim() === "") return void 0;
21064
21115
  return { subject: record.subject, authority: record.authority };
21065
21116
  }
21066
- function jsonObjectFromPrompt(prompt) {
21067
- const head = prompt.trimStart().split("\n\n", 1)[0] ?? "";
21068
- if (!head.startsWith("{")) return void 0;
21069
- try {
21070
- const parsed = JSON.parse(head);
21071
- if (!isRecord(parsed)) return void 0;
21072
- return parsed;
21073
- } catch {
21074
- return void 0;
21075
- }
21076
- }
21077
- function workContextPathFromPrompt(prompt) {
21078
- const record = jsonObjectFromPrompt(prompt);
21079
- const path = record?.workContextPath;
21080
- if (typeof path !== "string" || path.trim() === "") return void 0;
21081
- return isNavigatorWorkContextFile(path) ? path : void 0;
21082
- }
21083
- function attachWorkContextPointer(text, workContextPath) {
21084
- const record = jsonObjectFromPrompt(text);
21085
- if (record === void 0) return text;
21086
- if (typeof record.workContextPath === "string" && record.workContextPath.trim() !== "") return text;
21087
- const head = text.trimStart().split("\n\n", 1)[0] ?? "";
21088
- const rest = text.trimStart().slice(head.length);
21089
- return `${JSON.stringify({ ...record, workContextPath })}${rest}`;
21090
- }
21091
- async function loadNavigatorWorkBaseSuffix(prompt) {
21092
- const path = workContextPathFromPrompt(prompt);
21117
+ async function loadNavigatorWorkBaseSuffix(sessionDir, locatorPath) {
21118
+ const path = typeof locatorPath === "string" && locatorPath.trim() !== "" ? locatorPath.trim() : typeof process.env[AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV] === "string" && process.env[AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV].trim() !== "" ? process.env[AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV].trim() : sessionDir !== void 0 && sessionDir.trim() !== "" ? navigatorWorkContextFile(sessionDir) : void 0;
21093
21119
  if (path === void 0) return void 0;
21094
21120
  const body = await readNavigatorWorkBase(path);
21095
21121
  if (body === void 0) return void 0;
@@ -21120,7 +21146,7 @@ async function resolveNavigatorLedgerHome(context) {
21120
21146
  }
21121
21147
  var NAVIGATOR_HOST_RUN_POINTER_ENTRY = "ak-navigator-host-run";
21122
21148
  function runIdFromNavigatorDirectory(runDirectory) {
21123
- const parsed = parseRunLeaf(basename13(runDirectory));
21149
+ const parsed = parseRunLeaf(basename14(runDirectory));
21124
21150
  if (parsed === void 0 || parsed.role !== "navigator") return void 0;
21125
21151
  return parsed.runId;
21126
21152
  }
@@ -21182,13 +21208,14 @@ function createNativeNavigatorSessionFactory(deps) {
21182
21208
  if (disposed) return;
21183
21209
  const resumeRunId = hostRunId;
21184
21210
  const workContextPath = navigatorWorkContextFile(sessionManager.getSessionDir());
21185
- const argvText = existsSync12(workContextPath) ? attachWorkContextPointer(text, workContextPath) : text;
21211
+ const workContextLocator = existsSync12(workContextPath) ? workContextPath : void 0;
21186
21212
  const baseSummon = {
21187
21213
  role: "navigator",
21188
- argv: [argvText],
21214
+ argv: [text],
21189
21215
  cwd: context.cwd,
21190
21216
  ...summonHome === void 0 ? {} : { home: summonHome },
21191
- ...context.signal === void 0 ? {} : { signal: context.signal }
21217
+ ...context.signal === void 0 ? {} : { signal: context.signal },
21218
+ ...workContextLocator === void 0 ? {} : { navigatorWorkContextPath: workContextLocator }
21192
21219
  };
21193
21220
  const resumable = deps?.hostRunResumable ?? navigatorHostRunResumable;
21194
21221
  let summoned;
@@ -21316,8 +21343,8 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
21316
21343
  return void 0;
21317
21344
  }
21318
21345
  var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
21319
- var prepareSchema = Type20.Object({
21320
- prose: Type20.Optional(Type20.Unknown({
21346
+ var prepareSchema = Type19.Object({
21347
+ prose: Type19.Optional(Type19.Unknown({
21321
21348
  description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
21322
21349
  }))
21323
21350
  }, { additionalProperties: true });
@@ -21750,6 +21777,7 @@ function createNavigatorAttendance(options) {
21750
21777
  }
21751
21778
 
21752
21779
  // src/role-runtime.ts
21780
+ init_auditor_soul();
21753
21781
  init_navigator_invocation_identity();
21754
21782
  init_settlement();
21755
21783
  init_packaged_role_registry();
@@ -22639,7 +22667,7 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
22639
22667
  playbookBound = true;
22640
22668
  const loadRoutePlaybook = dependencies.loadRoutePlaybook ?? (() => readPackageMaterial("resources/navigator-route-playbook.md"));
22641
22669
  let playbookRead;
22642
- roleHost.on("before_agent_start", async (event) => {
22670
+ roleHost.on("before_agent_start", async (event, ctx) => {
22643
22671
  const basePrompt = typeof event.systemPrompt === "string" ? event.systemPrompt : "";
22644
22672
  const parts = [];
22645
22673
  try {
@@ -22654,8 +22682,10 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
22654
22682
  parts.push(message);
22655
22683
  }
22656
22684
  }
22657
- const prompt = typeof event.prompt === "string" ? event.prompt : "";
22658
- const work = await loadNavigatorWorkBaseSuffix(prompt);
22685
+ const work = await loadNavigatorWorkBaseSuffix(
22686
+ ctx.sessionManager?.getSessionDir?.(),
22687
+ ctx.navigatorWorkContextPath
22688
+ );
22659
22689
  if (work !== void 0 && work.trim() !== "") parts.push(work);
22660
22690
  if (parts.length === 0) return;
22661
22691
  const text = parts.join("\n\n");
@@ -22669,7 +22699,7 @@ ${text}`
22669
22699
  };
22670
22700
  }
22671
22701
  function createAuditorRoleRuntime(roleHost, dependencies) {
22672
- const base = createFiledOfficerRuntime(
22702
+ return createFiledOfficerRuntime(
22673
22703
  roleHost,
22674
22704
  {
22675
22705
  role: "auditor",
@@ -22678,17 +22708,27 @@ function createAuditorRoleRuntime(roleHost, dependencies) {
22678
22708
  },
22679
22709
  dependencies
22680
22710
  );
22681
- return {
22682
- async activate() {
22683
- await base.activate();
22684
- const { createAuditorDossierTool: createAuditorDossierTool2, AUDITOR_DOSSIER_TOOL_NAME: AUDITOR_DOSSIER_TOOL_NAME2 } = await Promise.resolve().then(() => (init_auditor_dossier_tool(), auditor_dossier_tool_exports));
22685
- const { AK_ROLE_AUDITOR_SOURCE_RUN_ENV: AK_ROLE_AUDITOR_SOURCE_RUN_ENV2 } = await Promise.resolve().then(() => (init_auditor_soul(), auditor_soul_exports));
22686
- const already = roleHost.getAllTools().some((tool) => tool.name === AUDITOR_DOSSIER_TOOL_NAME2);
22687
- if (already) return;
22688
- const sourceRun = typeof process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV2] === "string" && process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV2].trim() !== "" ? process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV2].trim() : void 0;
22689
- roleHost.registerTool(createAuditorDossierTool2(sourceRun));
22711
+ }
22712
+ function isAuditedIdentitySeat(role) {
22713
+ return role === "notary" || role === "inspector" || role === "auditor" || role === "countersign";
22714
+ }
22715
+ function resolveAuditedSourceRunDirectory(roleHost, ctx, role) {
22716
+ const notary = roleHost.getFlag(NOTARY_SOURCE_RUN_FLAG.name);
22717
+ if (typeof notary === "string" && notary.trim() !== "") return notary.trim();
22718
+ const inspector = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
22719
+ if (typeof inspector === "string" && inspector.trim() !== "") return inspector.trim();
22720
+ const runDirectory = runDirectoryFromHostContext(ctx);
22721
+ if (runDirectory !== void 0) {
22722
+ const admitted = readPageSync(runDirectory, "admitted");
22723
+ if (typeof admitted?.sourceRunPath === "string" && admitted.sourceRunPath.trim() !== "") {
22724
+ return admitted.sourceRunPath.trim();
22690
22725
  }
22691
- };
22726
+ }
22727
+ if (role === "auditor") {
22728
+ const auditor = typeof process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV] === "string" ? process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV].trim() : "";
22729
+ if (auditor !== "") return auditor;
22730
+ }
22731
+ return void 0;
22692
22732
  }
22693
22733
  function readDiaristTicketAssertion(submitted) {
22694
22734
  if (submitted === void 0 || !("ticketNumber" in submitted)) {
@@ -22705,7 +22745,7 @@ function readRoleRunCoordinates(ctx, label) {
22705
22745
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
22706
22746
  const admitted = readPageSync(runDirectory, "admitted");
22707
22747
  if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
22708
- throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join34(runDirectory, RUN_STATE_FILE)})`);
22748
+ throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join33(runDirectory, RUN_STATE_FILE)})`);
22709
22749
  }
22710
22750
  return {
22711
22751
  runDirectory,
@@ -23030,15 +23070,14 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23030
23070
  if (reading === void 0) return;
23031
23071
  return { readingMaterial: reading };
23032
23072
  });
23033
- roleHost.on("before_agent_start", () => {
23034
- const path = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
23035
- if (typeof path !== "string" || path.trim() === "") return;
23036
- return {
23037
- readingMaterial: {
23038
- kind: "inspector-parent-binding",
23039
- sourceRunPath: path
23040
- }
23041
- };
23073
+ roleHost.on("before_agent_start", (_event, ctx) => {
23074
+ const role = selectedRole ?? roleHost.getFlag(ROLE_FLAG.name);
23075
+ if (typeof role !== "string" || !isAuditedIdentitySeat(role) || role === "notary") return;
23076
+ const sourceDirectory = resolveAuditedSourceRunDirectory(roleHost, ctx, role);
23077
+ if (sourceDirectory === void 0) return;
23078
+ const identity = auditedRunIdentityFromDirectory(sourceDirectory);
23079
+ if (identity === void 0) return;
23080
+ return { readingMaterial: auditedRunIdentityMaterial(identity) };
23042
23081
  });
23043
23082
  roleHost.on("tool_result", async (event, ctx) => {
23044
23083
  const role = selectedRole;
@@ -23618,6 +23657,7 @@ async function prepareRoleEnvelope(options) {
23618
23657
  ...request.courtAttemptId === void 0 ? {} : { courtAttemptId: request.courtAttemptId },
23619
23658
  ...request.invocationScopeId === void 0 ? {} : { invocationScopeId: request.invocationScopeId },
23620
23659
  ...request.host === void 0 || request.host.trim() === "" ? {} : { host: request.host.trim() },
23660
+ ...request.navigatorWorkContextPath === void 0 || request.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: request.navigatorWorkContextPath },
23621
23661
  sessionManager: {
23622
23662
  getLeafEntry: () => sessionEntries.at(-1),
23623
23663
  getLeafId: () => runId,
@@ -24872,12 +24912,12 @@ function createAcpRoleTurnHost(config) {
24872
24912
  // src/acp-host/seat-profile-soul.ts
24873
24913
  import { constants as constants3 } from "node:fs";
24874
24914
  import { access as access3, copyFile, lstat as lstat4, mkdir as mkdir4, readlink, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
24875
- import { dirname as dirname22, join as join35, relative as relative3, resolve as resolve20 } from "node:path";
24915
+ import { dirname as dirname22, join as join34, relative as relative3, resolve as resolve20 } from "node:path";
24876
24916
  function seatProfileName(spec, role) {
24877
24917
  return `${spec.namePrefix}${role}`;
24878
24918
  }
24879
24919
  function packageRoleSoulPath(packageRoot, role) {
24880
- return join35(packageRoot, "souls", `${role}.md`);
24920
+ return join34(packageRoot, "souls", `${role}.md`);
24881
24921
  }
24882
24922
  async function pathExists2(path) {
24883
24923
  try {
@@ -24894,16 +24934,16 @@ async function ensureSeatProfileSoul(options) {
24894
24934
  if (!await pathExists2(soulTarget)) {
24895
24935
  throw new Error(`packaged role soul missing: ${soulTarget}`);
24896
24936
  }
24897
- const profilesRoot = join35(operatorHome, ...spec.profilesRootFromHome);
24898
- const profileDir = join35(profilesRoot, profileName);
24937
+ const profilesRoot = join34(operatorHome, ...spec.profilesRootFromHome);
24938
+ const profileDir = join34(profilesRoot, profileName);
24899
24939
  const hostRoot = dirname22(profilesRoot);
24900
- const soulPath = join35(profileDir, spec.soulFileName);
24940
+ const soulPath = join34(profileDir, spec.soulFileName);
24901
24941
  if (!await pathExists2(profileDir)) {
24902
24942
  await mkdir4(profileDir, { recursive: true });
24903
24943
  for (const name of ["auth.json", ".env", "config.yaml"]) {
24904
- const source = join35(hostRoot, name);
24944
+ const source = join34(hostRoot, name);
24905
24945
  if (!await pathExists2(source)) continue;
24906
- await copyFile(source, join35(profileDir, name));
24946
+ await copyFile(source, join34(profileDir, name));
24907
24947
  }
24908
24948
  } else {
24909
24949
  await mkdir4(profileDir, { recursive: true });