@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
@@ -1054,7 +1054,7 @@ var init_auditor_output = __esm({
1054
1054
 
1055
1055
  // src/role-run-placement.ts
1056
1056
  import { readdir } from "node:fs/promises";
1057
- import { basename as basename2, dirname as dirname2, join as join3 } from "node:path";
1057
+ import { basename as basename2, dirname as dirname2, join as join3, resolve as resolve2 } from "node:path";
1058
1058
  function formatRunLeaf(runId, role) {
1059
1059
  return `${runId}@${role}`;
1060
1060
  }
@@ -1075,6 +1075,11 @@ function sessionFileOf(runDirectory) {
1075
1075
  function runDirectoryOfSessionFile(sessionFile) {
1076
1076
  return dirname2(dirname2(sessionFile));
1077
1077
  }
1078
+ function auditorRunDirectory(context) {
1079
+ const sessionFile = context.sessionManager?.getSessionFile?.();
1080
+ if (sessionFile === void 0) return void 0;
1081
+ return resolve2(runDirectoryOfSessionFile(sessionFile));
1082
+ }
1078
1083
  function runDirectoryFromSessionDirectory(sessionDirectory) {
1079
1084
  return dirname2(sessionDirectory);
1080
1085
  }
@@ -1196,7 +1201,7 @@ var init_run_dossier_files = __esm({
1196
1201
 
1197
1202
  // src/activation-ledger-git.ts
1198
1203
  import { execFileSync } from "node:child_process";
1199
- import { basename as basename3, dirname as dirname3, isAbsolute as isAbsolute2, resolve as resolve2 } from "node:path";
1204
+ import { basename as basename3, dirname as dirname3, isAbsolute as isAbsolute2, resolve as resolve3 } from "node:path";
1200
1205
  function envWithoutGitDiscovery(base = process.env) {
1201
1206
  const env = { ...base, LC_ALL: "C" };
1202
1207
  for (const key of GIT_DISCOVERY_ENV_KEYS) {
@@ -1239,7 +1244,7 @@ function resolveBookKeyFromGit(cwd) {
1239
1244
  if (commonDir.length === 0) {
1240
1245
  throw new Error("git rev-parse --git-common-dir returned an empty path");
1241
1246
  }
1242
- const absoluteCommon = isAbsolute2(commonDir) ? commonDir : resolve2(cwd, commonDir);
1247
+ const absoluteCommon = isAbsolute2(commonDir) ? commonDir : resolve3(cwd, commonDir);
1243
1248
  const hostDirectory = basename3(absoluteCommon) === ".git" ? dirname3(absoluteCommon) : absoluteCommon;
1244
1249
  const bookKey = basename3(hostDirectory);
1245
1250
  if (bookKey.length === 0 || bookKey === "." || bookKey === "/") {
@@ -2505,7 +2510,8 @@ var init_packaged_role_registry = __esm({
2505
2510
  presentSettled: "always",
2506
2511
  summonResume: false,
2507
2512
  admission: "instruction",
2508
- sameParent: "gate-pointer",
2513
+ /** Structured --source-run only; instruction stays opaque caller/peer bytes (#1166). */
2514
+ sameParent: "source-run",
2509
2515
  /** Resume restores an optional source-run path onto the admitted face. */
2510
2516
  resumeSourcePath: true,
2511
2517
  /** 台院 is a review officer and inherits the gatekeeper model. */
@@ -2518,11 +2524,12 @@ var init_packaged_role_registry = __esm({
2518
2524
  /** Court reask replaces the initial prompt. */
2519
2525
  reaskPrompt: true,
2520
2526
  gateStageLabel: "\u53F0\u9662",
2527
+ /** Gate summon binds --source-run; identity is startup material (#1166). */
2528
+ gateSummon: "source-run",
2521
2529
  activationFlags: [
2522
2530
  {
2523
2531
  field: "sourceRun",
2524
2532
  from: "sourceRunPath",
2525
- fallback: "gate-pointer",
2526
2533
  flag: "ak-inspector-source-run",
2527
2534
  binds: "input"
2528
2535
  }
@@ -2801,12 +2808,12 @@ var init_terminating_tools = __esm({
2801
2808
 
2802
2809
  // src/doctor-evidence.ts
2803
2810
  import { readdir as readdir2, readFile as readFile3, realpath, stat } from "node:fs/promises";
2804
- import { dirname as dirname5, relative as relative2, resolve as resolve3, sep as sep2 } from "node:path";
2811
+ import { dirname as dirname5, relative as relative2, resolve as resolve4, sep as sep2 } from "node:path";
2805
2812
  async function discoverCaseFiles(root) {
2806
2813
  const found = [];
2807
2814
  async function walk(dir, depth) {
2808
2815
  for (const item of await readdir2(dir, { withFileTypes: true })) {
2809
- const path = resolve3(dir, item.name);
2816
+ const path = resolve4(dir, item.name);
2810
2817
  if (item.isDirectory()) {
2811
2818
  await walk(path, depth + 1);
2812
2819
  } else if (item.isFile() && (item.name.endsWith(".jsonl") && item.name !== "state.jsonl" && !(item.name === "log.jsonl" && depth === 1) || item.name === "log.jsonl" && depth === 1)) found.push(path);
@@ -2829,7 +2836,7 @@ async function stableRunsIdentity(root) {
2829
2836
  let cursor = root;
2830
2837
  while (true) {
2831
2838
  try {
2832
- const git3 = await stat(resolve3(cursor, ".git"));
2839
+ const git3 = await stat(resolve4(cursor, ".git"));
2833
2840
  if (git3.isDirectory() || git3.isFile()) return relative2(cursor, root).split(sep2).join("/");
2834
2841
  } catch (error) {
2835
2842
  if (!isMissingPathError(error)) throw error;
@@ -2969,7 +2976,7 @@ var init_uuidv7 = __esm({
2969
2976
  });
2970
2977
 
2971
2978
  // src/work-subject-identity.ts
2972
- import { resolve as resolve4 } from "node:path";
2979
+ import { resolve as resolve5 } from "node:path";
2973
2980
  function issueRoot(value) {
2974
2981
  const normalized = value.replaceAll("\\", "/");
2975
2982
  const marker = ".ak/work/issues/";
@@ -2979,7 +2986,7 @@ function issueRoot(value) {
2979
2986
  return issue === void 0 || issue === "" ? void 0 : normalized.slice(0, index + marker.length) + issue;
2980
2987
  }
2981
2988
  function workIdentityFromCwd(cwd) {
2982
- const resolvedCwd = resolve4(cwd, ".");
2989
+ const resolvedCwd = resolve5(cwd, ".");
2983
2990
  const cwdIssue = issueRoot(resolvedCwd);
2984
2991
  if (cwdIssue !== void 0) return cwdIssue;
2985
2992
  if (resolvedCwd.includes("/.ak/work/")) return resolvedCwd;
@@ -2990,11 +2997,11 @@ function isMachineLedgerSessionPath(sessionPath) {
2990
2997
  }
2991
2998
  function subjectPath(sessionDir, cwd = process.cwd()) {
2992
2999
  if (sessionDir === "") {
2993
- return workIdentityFromCwd(cwd) ?? resolve4(cwd, ".ak/work");
3000
+ return workIdentityFromCwd(cwd) ?? resolve5(cwd, ".ak/work");
2994
3001
  }
2995
- const resolvedSession = resolve4(cwd, sessionDir || ".ak/work");
3002
+ const resolvedSession = resolve5(cwd, sessionDir || ".ak/work");
2996
3003
  if (isMachineLedgerSessionPath(resolvedSession)) {
2997
- return workIdentityFromCwd(cwd) ?? resolve4(cwd, ".ak/work");
3004
+ return workIdentityFromCwd(cwd) ?? resolve5(cwd, ".ak/work");
2998
3005
  }
2999
3006
  const issue = issueRoot(resolvedSession);
3000
3007
  if (issue !== void 0) return issue;
@@ -4400,61 +4407,8 @@ var init_collector_config = __esm({
4400
4407
  }
4401
4408
  });
4402
4409
 
4403
- // src/auditor-dossier-tool.ts
4404
- var auditor_dossier_tool_exports = {};
4405
- __export(auditor_dossier_tool_exports, {
4406
- AUDITOR_DOSSIER_TOOL_NAME: () => AUDITOR_DOSSIER_TOOL_NAME,
4407
- auditorRunDirectory: () => auditorRunDirectory,
4408
- createAuditorDossierTool: () => createAuditorDossierTool
4409
- });
4410
- import { join as join12, resolve as resolve6 } from "node:path";
4411
- import { Type as Type15 } from "typebox";
4412
- function auditorRunDirectory(context) {
4413
- const sessionFile = context.sessionManager?.getSessionFile?.();
4414
- if (sessionFile === void 0) return void 0;
4415
- return resolve6(runDirectoryOfSessionFile(sessionFile));
4416
- }
4417
- function createAuditorDossierTool(runDirectory) {
4418
- return {
4419
- name: AUDITOR_DOSSIER_TOOL_NAME,
4420
- description: "\u5B9A\u4F4D\u672C\u5BA1\u8BA1\u5E2D\u7ED1\u5B9A\u7684 run \u5377\u5B97\u53CA\u5176\u8BC1\u636E\u5165\u53E3\u3002",
4421
- // #836 r16 class 3: execute() ignores `_params` entirely — a closed root
4422
- // only rejects the role for saying more.
4423
- parameters: Type15.Object({}, { additionalProperties: true }),
4424
- async execute(_id, _params) {
4425
- if (runDirectory === void 0) {
4426
- return {
4427
- content: [{ type: "text", text: "\u672C\u5BA1\u8BA1\u5E2D\u65E0\u7ED1\u5B9A run \u5377\u5B97\u8BB0\u5F55\u3002" }],
4428
- details: void 0
4429
- };
4430
- }
4431
- const details = {
4432
- runDirectory,
4433
- current: runCurrentPath(runDirectory),
4434
- parentSessionCandidate: sessionFileOf(runDirectory),
4435
- attachments: join12(runDirectory, "attachments"),
4436
- log: join12(runDirectory, RUN_LOG_FILE),
4437
- history: join12(runDirectory, RUN_HISTORY_FILE)
4438
- };
4439
- return {
4440
- content: [{ type: "text", text: JSON.stringify(details) }],
4441
- details
4442
- };
4443
- }
4444
- };
4445
- }
4446
- var AUDITOR_DOSSIER_TOOL_NAME;
4447
- var init_auditor_dossier_tool = __esm({
4448
- "src/auditor-dossier-tool.ts"() {
4449
- "use strict";
4450
- init_run_dossier();
4451
- init_role_run_placement();
4452
- AUDITOR_DOSSIER_TOOL_NAME = "ak_get_run_dossier";
4453
- }
4454
- });
4455
-
4456
4410
  // src/collector-tool-schemas.ts
4457
- import { Type as Type16 } from "typebox";
4411
+ import { Type as Type15 } from "typebox";
4458
4412
  var collectorOutputBaseSchema, collectorOutputArgsSchema;
4459
4413
  var init_collector_tool_schemas = __esm({
4460
4414
  "src/collector-tool-schemas.ts"() {
@@ -4462,11 +4416,11 @@ var init_collector_tool_schemas = __esm({
4462
4416
  init_open_tool_schema();
4463
4417
  init_terminating_infrastructure();
4464
4418
  collectorOutputBaseSchema = openToolObject(
4465
- Type16.Object({
4466
- groups: Type16.Unsafe({
4419
+ Type15.Object({
4420
+ groups: Type15.Unsafe({
4467
4421
  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"
4468
4422
  }),
4469
- unfinishedReasons: Type16.Unknown({
4423
+ unfinishedReasons: Type15.Unknown({
4470
4424
  description: "\u672A\u5B8C\u6210\u539F\u56E0\uFF1B\u53D6\u8BC1\u53D7\u9650\u65F6\u5982\u5B9E\u62A5\u544A\u3002"
4471
4425
  })
4472
4426
  })
@@ -4952,7 +4906,7 @@ var GATE_OFFICER_BY_SUBJECT, GATEKEEPER_TOOL_SPEC;
4952
4906
  var init_gatekeeper_role = __esm({
4953
4907
  "src/gatekeeper-role.ts"() {
4954
4908
  "use strict";
4955
- init_auditor_dossier_tool();
4909
+ init_role_run_placement();
4956
4910
  init_packaged_role_registry();
4957
4911
  init_submission_errors();
4958
4912
  init_inspector_contracts();
@@ -6551,13 +6505,13 @@ var init_session_dialogue = __esm({
6551
6505
 
6552
6506
  // src/ticket-provenance.ts
6553
6507
  import { readFile as readFile8 } from "node:fs/promises";
6554
- import { join as join13, resolve as resolve9 } from "node:path";
6508
+ import { join as join12, resolve as resolve9 } from "node:path";
6555
6509
  function dialogueSessionSourceRoots(home) {
6556
6510
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
6557
6511
  return [
6558
- join13(machineHome, ".claude", "projects"),
6559
- join13(machineHome, ".codex", "sessions"),
6560
- join13(machineHome, ".pi", "agent", "sessions")
6512
+ join12(machineHome, ".claude", "projects"),
6513
+ join12(machineHome, ".codex", "sessions"),
6514
+ join12(machineHome, ".pi", "agent", "sessions")
6561
6515
  ];
6562
6516
  }
6563
6517
  function isLedgerRoleSessionFile(absolute, home) {
@@ -6598,7 +6552,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
6598
6552
  const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
6599
6553
  let history;
6600
6554
  try {
6601
- history = await readFile8(join13(runDirectory, RUN_HISTORY_FILE), "utf8");
6555
+ history = await readFile8(join12(runDirectory, RUN_HISTORY_FILE), "utf8");
6602
6556
  } catch (error) {
6603
6557
  if (errnoCode(error) === "ENOENT") return;
6604
6558
  throw error;
@@ -6790,7 +6744,7 @@ var init_ticket_provenance = __esm({
6790
6744
  });
6791
6745
 
6792
6746
  // src/notary-source-run.ts
6793
- import { dirname as dirname10, isAbsolute as isAbsolute4, join as join14, resolve as resolve10, basename as basename8 } from "node:path";
6747
+ import { dirname as dirname10, isAbsolute as isAbsolute4, join as join13, resolve as resolve10, basename as basename8 } from "node:path";
6794
6748
  import { lstat, realpath as realpath2 } from "node:fs/promises";
6795
6749
  async function readRetainedIdentity(runDirectory) {
6796
6750
  try {
@@ -6842,11 +6796,11 @@ async function resolveNotarySourceRunLocator(options) {
6842
6796
  const ledgerHome = resolveActivationLedgerHome(options.home);
6843
6797
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
6844
6798
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
6845
- const bookRunsRoot = join14(bookDirectory, "runs");
6799
+ const bookRunsRoot = join13(bookDirectory, "runs");
6846
6800
  let candidate;
6847
6801
  const bare = parseRunLeaf(raw);
6848
6802
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
6849
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join14(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
6803
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join13(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
6850
6804
  } else {
6851
6805
  candidate = isAbsolute4(raw) ? raw : resolve10(options.projectRoot, raw);
6852
6806
  const identity2 = parseRunLeaf(basename8(candidate));
@@ -7206,7 +7160,7 @@ function renderHumanOwnerOptionLines(owner, locale = "en") {
7206
7160
  }
7207
7161
  return lines;
7208
7162
  }
7209
- 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;
7163
+ 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;
7210
7164
  var init_option_definitions = __esm({
7211
7165
  "src/public-cli/option-definitions.ts"() {
7212
7166
  "use strict";
@@ -7571,6 +7525,23 @@ var init_option_definitions = __esm({
7571
7525
  }
7572
7526
  }
7573
7527
  ];
7528
+ INSPECTOR_OPTIONS = [
7529
+ ...projectAndAttach("inspector"),
7530
+ {
7531
+ id: "source-run",
7532
+ owner: "inspector",
7533
+ canonical: "--source-run",
7534
+ aliases: [],
7535
+ valueMetavar: "runId@role|path",
7536
+ required: false,
7537
+ repeatable: false,
7538
+ form: "option",
7539
+ description: {
7540
+ en: "Optional audited source-run locator (runId@role or path). Gate summons always supply it; identity rides startup materials.",
7541
+ 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"
7542
+ }
7543
+ }
7544
+ ];
7574
7545
  MERGER_OPTIONS = [
7575
7546
  // Merger project face: worktree whose Git materials are handed to the role.
7576
7547
  {
@@ -7729,7 +7700,8 @@ var init_option_definitions = __esm({
7729
7700
  doctor: DOCTOR_OPTIONS,
7730
7701
  merger: MERGER_OPTIONS,
7731
7702
  notary: NOTARY_OPTIONS,
7732
- auditor: AUDITOR_OPTIONS
7703
+ auditor: AUDITOR_OPTIONS,
7704
+ inspector: INSPECTOR_OPTIONS
7733
7705
  };
7734
7706
  PUBLIC_OPTION_TABLE = publicOptionTable();
7735
7707
  PUBLIC_ROLE_OPTION_OWNERS = [
@@ -7983,7 +7955,7 @@ import {
7983
7955
  rename as rename2,
7984
7956
  writeFile as writeFile3
7985
7957
  } from "node:fs/promises";
7986
- import { dirname as dirname11, isAbsolute as isAbsolute5, join as join15, resolve as resolve11 } from "node:path";
7958
+ import { dirname as dirname11, isAbsolute as isAbsolute5, join as join14, resolve as resolve11 } from "node:path";
7987
7959
  function normalizeAdmittedAttachment(raw) {
7988
7960
  if (typeof raw !== "object" || raw === null) return void 0;
7989
7961
  const record = raw;
@@ -8136,7 +8108,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
8136
8108
  const childRunIds = readPageSync(oldRunDirectory, "admitted")?.childDiaristRunIds;
8137
8109
  for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
8138
8110
  if (typeof childRunId !== "string") continue;
8139
- const childDirectory = join15(dirname11(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
8111
+ const childDirectory = join14(dirname11(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
8140
8112
  if (!existsSync5(childDirectory)) continue;
8141
8113
  const childTarget = roleRunPlacement(ledgerHome, {
8142
8114
  bookKey: admitted.bookKey,
@@ -8210,7 +8182,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
8210
8182
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
8211
8183
  const rolePackageRoot = packageRoot;
8212
8184
  const raw = JSON.parse(
8213
- await readFile9(join15(rolePackageRoot, "package.json"), "utf8")
8185
+ await readFile9(join14(rolePackageRoot, "package.json"), "utf8")
8214
8186
  );
8215
8187
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
8216
8188
  throw new Error(
@@ -8768,7 +8740,7 @@ async function admitPublicRole(role, parsed, env, override) {
8768
8740
  resolutionScope: [...derived.resolutionScope],
8769
8741
  authorizedChecks: []
8770
8742
  });
8771
- const mergerInputPath = join15(placed.runDirectory, "merger-input.json");
8743
+ const mergerInputPath = join14(placed.runDirectory, "merger-input.json");
8772
8744
  await writeFile3(
8773
8745
  mergerInputPath,
8774
8746
  `${JSON.stringify(mergerInput, null, 2)}
@@ -8906,52 +8878,50 @@ function admittedTransportPromptKind(admitted) {
8906
8878
  if (record !== void 0 && "transportPrompt" in record) return record.transportPrompt;
8907
8879
  return "instruction";
8908
8880
  }
8881
+ function appendCallerFileFlagPaths(body, attachments, requestManifestPath, prerequisitesPath) {
8882
+ const flaggedPaths = [
8883
+ ...attachments.map((attachment) => `--attach ${attachment.path}`),
8884
+ ...requestManifestPath === void 0 ? [] : [`--request-manifest ${requestManifestPath}`],
8885
+ ...prerequisitesPath === void 0 ? [] : [`--prerequisites ${prerequisitesPath}`]
8886
+ ];
8887
+ if (flaggedPaths.length === 0) return body;
8888
+ return [body, "", ...flaggedPaths].join("\n");
8889
+ }
8909
8890
  function buildInstructionTransportPrompt(admitted) {
8910
8891
  const kind = admittedTransportPromptKind(admitted);
8911
8892
  if (kind === "fixed-kickoff") {
8912
- if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
8913
- throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
8914
- }
8915
- return admitted.sourceRunPath;
8893
+ return "";
8916
8894
  }
8917
8895
  if (kind === "baseline") {
8918
8896
  if (admitted.baseRevision === void 0) {
8919
8897
  throw new Error("baseline transport prompt is missing the bound revision");
8920
8898
  }
8921
- const lines2 = [admitted.baseRevision];
8899
+ const lines = [admitted.baseRevision];
8922
8900
  if (admitted.instruction.length > 0) {
8923
- lines2.push("", admitted.instruction);
8901
+ lines.push("", admitted.instruction);
8924
8902
  }
8925
- return lines2.join("\n");
8903
+ return lines.join("\n");
8926
8904
  }
8927
8905
  if (kind === "skill-args") {
8928
8906
  if (admitted.baseRevision === void 0 || admitted.lens === void 0 || admitted.authorityRefs === void 0) {
8929
8907
  throw new Error("skill-args transport prompt is missing frozen skill args");
8930
8908
  }
8931
- const lines2 = [buildReviewerSkillArgProjection({
8909
+ const lines = [buildReviewerSkillArgProjection({
8932
8910
  baseRevision: admitted.baseRevision,
8933
8911
  lens: admitted.lens,
8934
8912
  authorityRefs: admitted.authorityRefs
8935
8913
  })];
8936
8914
  if (admitted.instruction.length > 0) {
8937
- lines2.push("", admitted.instruction);
8915
+ lines.push("", admitted.instruction);
8938
8916
  }
8939
- return lines2.join("\n");
8917
+ return lines.join("\n");
8940
8918
  }
8941
- const lines = [admitted.instruction];
8942
- const flaggedPaths = [
8943
- ...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
8944
- ...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`],
8945
- ...admitted.prerequisitesPath === void 0 ? [] : [`--prerequisites ${admitted.prerequisitesPath}`]
8946
- ];
8947
- if (flaggedPaths.length > 0) {
8948
- lines.push("");
8949
- lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
8950
- for (const entry of flaggedPaths) {
8951
- lines.push(`- ${entry}`);
8952
- }
8953
- }
8954
- return lines.join("\n");
8919
+ return appendCallerFileFlagPaths(
8920
+ admitted.instruction,
8921
+ admitted.attachments,
8922
+ admitted.requestManifestPath,
8923
+ admitted.prerequisitesPath
8924
+ );
8955
8925
  }
8956
8926
  async function materializeCountersignInvocation(admitted, options) {
8957
8927
  const placed = await placeRoleAdmission({
@@ -9061,7 +9031,7 @@ function parseDoctorIssueNumber(raw) {
9061
9031
  }
9062
9032
  async function resolveDoctorCaseRunsPath(options) {
9063
9033
  const ledgerHome = resolveActivationLedgerHome(options.home);
9064
- const defaultRuns = join15(
9034
+ const defaultRuns = join14(
9065
9035
  activationBookDirectory(ledgerHome, options.bookKey),
9066
9036
  String(options.issueNumber),
9067
9037
  "runs"
@@ -10476,7 +10446,7 @@ var init_settlement = __esm({
10476
10446
  });
10477
10447
 
10478
10448
  // src/session-identity.ts
10479
- import { dirname as dirname12, join as join16 } from "node:path";
10449
+ import { dirname as dirname12, join as join15 } from "node:path";
10480
10450
  function createSessionIdentityAuthority(authority, hostName) {
10481
10451
  const runDirectoryOf = (principal) => dirname12(authority.decode(principal).sessionDirectory);
10482
10452
  return {
@@ -10485,7 +10455,7 @@ function createSessionIdentityAuthority(authority, hostName) {
10485
10455
  },
10486
10456
  async load(principal) {
10487
10457
  const runDirectory = runDirectoryOf(principal);
10488
- const { records, diagnostics } = await readSitianRecords(join16(runDirectory, RUN_STATE_FILE));
10458
+ const { records, diagnostics } = await readSitianRecords(join15(runDirectory, RUN_STATE_FILE));
10489
10459
  if (diagnostics.length > 0) {
10490
10460
  throw new Error(
10491
10461
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -10555,12 +10525,12 @@ __export(role_turn_host_exports, {
10555
10525
  import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
10556
10526
  import { constants } from "node:fs";
10557
10527
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
10558
- import { delimiter, dirname as dirname13, isAbsolute as isAbsolute6, join as join17, resolve as resolve12 } from "node:path";
10528
+ import { delimiter, dirname as dirname13, isAbsolute as isAbsolute6, join as join16, resolve as resolve12 } from "node:path";
10559
10529
  import { platform } from "node:process";
10560
10530
  import { promisify as promisify2 } from "node:util";
10561
10531
  import { randomUUID as randomUUID5 } from "node:crypto";
10562
10532
  function resolveInternalRoleEntrypoint(packageRoot) {
10563
- return join17(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
10533
+ return join16(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
10564
10534
  }
10565
10535
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
10566
10536
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -10801,6 +10771,11 @@ function createPiRoleTurnHost(config) {
10801
10771
  if (typeof process.env.AK_ROLE_AUDITOR_SUBJECT === "string" && process.env.AK_ROLE_AUDITOR_SUBJECT.trim() !== "") {
10802
10772
  env.AK_ROLE_AUDITOR_SUBJECT = process.env.AK_ROLE_AUDITOR_SUBJECT;
10803
10773
  }
10774
+ if (typeof request.navigatorWorkContextPath === "string" && request.navigatorWorkContextPath.trim() !== "") {
10775
+ env.AK_ROLE_NAVIGATOR_WORK_CONTEXT = request.navigatorWorkContextPath.trim();
10776
+ } else {
10777
+ delete env.AK_ROLE_NAVIGATOR_WORK_CONTEXT;
10778
+ }
10804
10779
  if (config.recordLaunchedRolePackageIdentity !== void 0 && config.observeLaunchedRolePackageIdentity !== void 0) {
10805
10780
  await config.recordLaunchedRolePackageIdentity(
10806
10781
  request.runDirectory,
@@ -10923,15 +10898,15 @@ var init_role_turn_host = __esm({
10923
10898
 
10924
10899
  // src/public-cli/host-providers.ts
10925
10900
  import { readFileSync as readFileSync3 } from "node:fs";
10926
- import { join as join18 } from "node:path";
10901
+ import { join as join17 } from "node:path";
10927
10902
  function hostProvidersPath(home) {
10928
10903
  if (typeof home !== "string" || home.trim() === "") {
10929
10904
  throw new Error("home must be explicitly provided");
10930
10905
  }
10931
- return join18(home, ".ak-roles", "host-providers.json");
10906
+ return join17(home, ".ak-roles", "host-providers.json");
10932
10907
  }
10933
10908
  function hermesProviderModelsCachePath(home) {
10934
- return join18(home, ".hermes", "provider_models_cache.json");
10909
+ return join17(home, ".hermes", "provider_models_cache.json");
10935
10910
  }
10936
10911
  function parseHostProvidersTable(value) {
10937
10912
  if (!isRecord(value)) {
@@ -11082,15 +11057,15 @@ var init_host_providers = __esm({
11082
11057
 
11083
11058
  // src/public-cli/load-production-acp-host.ts
11084
11059
  import { existsSync as existsSync6 } from "node:fs";
11085
- import { join as join19 } from "node:path";
11060
+ import { join as join18 } from "node:path";
11086
11061
  import { pathToFileURL } from "node:url";
11087
11062
  async function loadProductionAcpHostFactory(packageRoot, host) {
11088
11063
  const description = lookupHostDescription(host);
11089
11064
  if (description === void 0) {
11090
11065
  throw new Error(`unregistered host: ${host}`);
11091
11066
  }
11092
- const built = join19(packageRoot, "dist/acp-host/production-host.js");
11093
- const source = join19(packageRoot, "src/acp-host/production-host.ts");
11067
+ const built = join18(packageRoot, "dist/acp-host/production-host.js");
11068
+ const source = join18(packageRoot, "src/acp-host/production-host.ts");
11094
11069
  const target = existsSync6(built) ? built : source;
11095
11070
  const href = pathToFileURL(target).href;
11096
11071
  const mod = await import(href);
@@ -11106,15 +11081,15 @@ var init_load_production_acp_host = __esm({
11106
11081
 
11107
11082
  // src/public-cli/load-production-headless-host.ts
11108
11083
  import { existsSync as existsSync7 } from "node:fs";
11109
- import { join as join20 } from "node:path";
11084
+ import { join as join19 } from "node:path";
11110
11085
  import { pathToFileURL as pathToFileURL2 } from "node:url";
11111
11086
  async function loadProductionHeadlessHostFactory(packageRoot, host) {
11112
11087
  const description = lookupHeadlessHostDescription(host);
11113
11088
  if (description === void 0) {
11114
11089
  throw new Error(`unregistered headless host: ${host}`);
11115
11090
  }
11116
- const built = join20(packageRoot, "dist/headless-host/production-host.js");
11117
- const source = join20(packageRoot, "src/headless-host/production-host.ts");
11091
+ const built = join19(packageRoot, "dist/headless-host/production-host.js");
11092
+ const source = join19(packageRoot, "src/headless-host/production-host.ts");
11118
11093
  const target = existsSync7(built) ? built : source;
11119
11094
  const href = pathToFileURL2(target).href;
11120
11095
  const mod = await import(href);
@@ -11282,7 +11257,7 @@ var init_role_seat_runtime = __esm({
11282
11257
  });
11283
11258
 
11284
11259
  // src/archivist-record-pointer.ts
11285
- import { basename as basename9, join as join21 } from "node:path";
11260
+ import { basename as basename9, join as join20 } from "node:path";
11286
11261
  function bookDirectOfficerRunPointer(options) {
11287
11262
  const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
11288
11263
  const pointer = {
@@ -11331,7 +11306,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
11331
11306
  };
11332
11307
  }
11333
11308
  async function readBookedOfficerPointers(parentRunDirectory) {
11334
- const { records, diagnostics } = await readSitianRecords(join21(parentRunDirectory, RUN_HISTORY_FILE));
11309
+ const { records, diagnostics } = await readSitianRecords(join20(parentRunDirectory, RUN_HISTORY_FILE));
11335
11310
  if (diagnostics.length > 0) {
11336
11311
  throw new Error(
11337
11312
  `${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
@@ -11395,7 +11370,7 @@ function createPiDoctorAuditor() {
11395
11370
  var init_doctor_auditor = __esm({
11396
11371
  "src/doctor-auditor.ts"() {
11397
11372
  "use strict";
11398
- init_auditor_dossier_tool();
11373
+ init_role_run_placement();
11399
11374
  init_compliance_transport();
11400
11375
  init_dossier_resolution();
11401
11376
  init_doctor_contracts();
@@ -11670,12 +11645,12 @@ var init_submission_gate = __esm({
11670
11645
  // src/session-opening-materials.ts
11671
11646
  import { existsSync as existsSync8 } from "node:fs";
11672
11647
  import { readFile as readFile10 } from "node:fs/promises";
11673
- import { dirname as dirname14, join as join22 } from "node:path";
11648
+ import { dirname as dirname14, join as join21 } from "node:path";
11674
11649
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
11675
11650
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
11676
11651
  let dir = dirname14(fileURLToPath(moduleUrl));
11677
11652
  for (let i = 0; i < 8; i += 1) {
11678
- if (existsSync8(join22(dir, "package.json")) && existsSync8(join22(dir, "souls"))) {
11653
+ if (existsSync8(join21(dir, "package.json")) && existsSync8(join21(dir, "souls"))) {
11679
11654
  return dir;
11680
11655
  }
11681
11656
  const parent = dirname14(dir);
@@ -11820,16 +11795,16 @@ var init_auditor_soul = __esm({
11820
11795
  // src/public-cli/machine-method-skills.ts
11821
11796
  import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
11822
11797
  import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
11823
- import { join as join24 } from "node:path";
11798
+ import { join as join23 } from "node:path";
11824
11799
  import { spawnSync as spawnSync2 } from "node:child_process";
11825
11800
  function skillRoot(home) {
11826
- return join24(home, ".agents/skills");
11801
+ return join23(home, ".agents/skills");
11827
11802
  }
11828
11803
  function installedMethodSkillPath(home, name) {
11829
11804
  return installedSkillPath(skillRoot(home), name);
11830
11805
  }
11831
11806
  function installedSkillPath(root, name) {
11832
- const path = join24(root, name, "SKILL.md");
11807
+ const path = join23(root, name, "SKILL.md");
11833
11808
  try {
11834
11809
  if (!statSync5(path).isFile()) return void 0;
11835
11810
  accessSync(path, constants2.R_OK);
@@ -11842,9 +11817,9 @@ function installedSkillPath(root, name) {
11842
11817
  }
11843
11818
  function linkedSkillRoot(home, host) {
11844
11819
  if (host === "claude" || host === "claude-code") {
11845
- return join24(process.env.CLAUDE_CONFIG_DIR?.trim() || join24(home, ".claude"), "skills");
11820
+ return join23(process.env.CLAUDE_CONFIG_DIR?.trim() || join23(home, ".claude"), "skills");
11846
11821
  }
11847
- if (host === "hermes") return join24(home, ".hermes/skills");
11822
+ if (host === "hermes") return join23(home, ".hermes/skills");
11848
11823
  return void 0;
11849
11824
  }
11850
11825
  async function occupied(path) {
@@ -11901,7 +11876,7 @@ async function runMachineSkillSetup(home, stdout) {
11901
11876
  const missingBySource = /* @__PURE__ */ new Map();
11902
11877
  let unsourced = false;
11903
11878
  for (const name of packagedMethodSkillNames()) {
11904
- const path = join24(canonical, name);
11879
+ const path = join23(canonical, name);
11905
11880
  if (await occupied(path)) {
11906
11881
  warnOccupied(path, stdout);
11907
11882
  continue;
@@ -11931,9 +11906,9 @@ async function runMachineSkillSetup(home, stdout) {
11931
11906
  throw error;
11932
11907
  }
11933
11908
  for (const name of packagedMethodSkillNames()) {
11934
- const target = join24(canonical, name);
11909
+ const target = join23(canonical, name);
11935
11910
  if (installedMethodSkillPath(home, name) === void 0) continue;
11936
- const link = join24(root, name);
11911
+ const link = join23(root, name);
11937
11912
  if (await occupied(link)) {
11938
11913
  warnOccupied(link, stdout);
11939
11914
  continue;
@@ -11992,7 +11967,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
11992
11967
  ...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
11993
11968
  ...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
11994
11969
  ...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
11995
- ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
11970
+ ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit },
11971
+ ...options.navigatorWorkContextPath === void 0 || options.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: options.navigatorWorkContextPath }
11996
11972
  };
11997
11973
  }
11998
11974
  function packagedSettleSkill(admitted) {
@@ -12019,11 +11995,6 @@ function activationForAdmitted(admitted) {
12019
11995
  const activation = { role: admitted.role };
12020
11996
  for (const spec of packagedRoleActivationFlags(admitted.role)) {
12021
11997
  let value = readAdmittedPath(admitted, spec.from ?? spec.field);
12022
- if (spec.fallback === "gate-pointer") {
12023
- const trimmed = typeof value === "string" ? value.trim() : "";
12024
- value = trimmed !== "" ? trimmed : parentRunPathFromGatePointerInstruction(admitted.instruction);
12025
- if (typeof value !== "string" || value === "") continue;
12026
- }
12027
11998
  if (value === void 0) continue;
12028
11999
  if (spec.text === true) {
12029
12000
  if (typeof value !== "number") continue;
@@ -12065,7 +12036,6 @@ var init_turn_request = __esm({
12065
12036
  init_engine_material();
12066
12037
  init_packaged_role_registry();
12067
12038
  init_machine_method_skills();
12068
- init_run_lifecycle();
12069
12039
  }
12070
12040
  });
12071
12041
 
@@ -13086,21 +13056,19 @@ async function dispatchPostAdmissionTurn(input) {
13086
13056
  }
13087
13057
  function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
13088
13058
  const officerDialogue = isStationChildOfficerDialogue(admitted.role, env);
13059
+ const fileFlags = summonsPrepared?.attachments ?? [];
13089
13060
  let prompt;
13090
13061
  if (request.message !== void 0) {
13091
13062
  if (summonsPrepared !== void 0) {
13092
- prompt = officerDialogue ? request.message : buildInstructionTransportPrompt({
13093
- instruction: request.message,
13094
- instructionEmpty: false,
13095
- attachments: summonsPrepared.attachments
13096
- });
13063
+ prompt = officerDialogue && fileFlags.length === 0 ? request.message : appendCallerFileFlagPaths(request.message, fileFlags);
13097
13064
  } else if (request.summons !== void 0) {
13098
13065
  prompt = request.message;
13099
13066
  } else {
13100
13067
  prompt = request.message;
13101
13068
  }
13102
13069
  } else if (summonsPrepared !== void 0) {
13103
- prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
13070
+ const body = summonsPrepared.instruction;
13071
+ prompt = officerDialogue && fileFlags.length === 0 ? body : appendCallerFileFlagPaths(body, fileFlags);
13104
13072
  } else if (request.summons !== void 0) {
13105
13073
  prompt = "";
13106
13074
  } else {
@@ -13116,7 +13084,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
13116
13084
  },
13117
13085
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
13118
13086
  // #1132: one configured ceiling, already resolved by the caller (#422).
13119
- deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
13087
+ deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit),
13088
+ ...env.navigatorWorkContextPath === void 0 || env.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: env.navigatorWorkContextPath }
13120
13089
  };
13121
13090
  }
13122
13091
  function roleTurnOptions(env, admitted, continuation) {
@@ -13128,7 +13097,8 @@ function roleTurnOptions(env, admitted, continuation) {
13128
13097
  continuation,
13129
13098
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
13130
13099
  // #1132: one configured ceiling, already resolved by the caller (#422).
13131
- deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
13100
+ deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit),
13101
+ ...env.navigatorWorkContextPath === void 0 || env.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: env.navigatorWorkContextPath }
13132
13102
  };
13133
13103
  }
13134
13104
  async function dispatchAfterWriterLease(input) {
@@ -13710,11 +13680,44 @@ function buildInstructionSeatTurnRequest(admitted, options) {
13710
13680
  options
13711
13681
  );
13712
13682
  }
13713
- function initialPrompt(admitted, env) {
13683
+ async function loadLedgerPeerBody(sourceRunDirectory, projectRoot, home) {
13684
+ const runId = runIdFromRunDirectory(sourceRunDirectory);
13685
+ if (runId === void 0) return void 0;
13686
+ const rows = await readRecordedSubmissionRows(projectRoot, runId, {
13687
+ home,
13688
+ sessionParent: sessionFileOf(sourceRunDirectory)
13689
+ });
13690
+ const latest = rows.at(-1);
13691
+ if (latest === void 0) return void 0;
13692
+ return readableGateItem(latest.accepted);
13693
+ }
13694
+ async function resolveReviewSeatDialogueBody(input) {
13695
+ const reask = input.reask;
13696
+ if (reask !== void 0 && reask.length > 0) return reask;
13697
+ const caller = input.callerInstruction ?? "";
13698
+ if (caller.length > 0) return caller;
13699
+ const sourceRunPath = input.sourceRunPath?.trim() ?? "";
13700
+ if (sourceRunPath === "") return void 0;
13701
+ return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
13702
+ }
13703
+ function admittedSourceRunPath(admitted) {
13704
+ return "sourceRunPath" in admitted && typeof admitted.sourceRunPath === "string" ? admitted.sourceRunPath.trim() : "";
13705
+ }
13706
+ async function resolveInitialPrompt(admitted, env) {
13714
13707
  const record = roleRecord(admitted.role);
13715
- const reask = env.reviewReask ?? env.gateReviewInstruction;
13716
- if (reask !== void 0 && "reaskPrompt" in record && record.reaskPrompt === true) {
13717
- return reask;
13708
+ if ("reaskPrompt" in record && record.reaskPrompt === true) {
13709
+ const sourceRunPath = admittedSourceRunPath(admitted);
13710
+ const reask = env.reviewReask ?? env.gateReviewInstruction;
13711
+ const body = await resolveReviewSeatDialogueBody({
13712
+ ...reask === void 0 ? {} : { reask },
13713
+ callerInstruction: admitted.instruction,
13714
+ ...sourceRunPath === "" ? {} : { sourceRunPath },
13715
+ projectRoot: admitted.projectRoot,
13716
+ home: env.home
13717
+ });
13718
+ if (body !== void 0) {
13719
+ return appendCallerFileFlagPaths(body, admitted.attachments);
13720
+ }
13718
13721
  }
13719
13722
  return buildInstructionTransportPrompt(admitted);
13720
13723
  }
@@ -13796,6 +13799,7 @@ async function dispatchAdmitted(admitted, env, io) {
13796
13799
  if (activeEnv.correlationId !== void 0 && activeEnv.correlationId.trim() !== "") {
13797
13800
  await recordAdmittedCorrelation(admitted, activeEnv.correlationId);
13798
13801
  }
13802
+ const initialPromptText = await resolveInitialPrompt(admitted, activeEnv);
13799
13803
  const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
13800
13804
  if (auto) {
13801
13805
  return await runPostAdmissionResumable({
@@ -13804,7 +13808,10 @@ async function dispatchAdmitted(admitted, env, io) {
13804
13808
  io: turnIo,
13805
13809
  buildInitialRequest: () => buildInstructionSeatTurnRequest(
13806
13810
  admitted,
13807
- roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
13811
+ roleTurnOptions(activeEnv, admitted, {
13812
+ kind: "initial",
13813
+ prompt: initialPromptText
13814
+ })
13808
13815
  ),
13809
13816
  buildResumeRequest: () => buildInstructionSeatTurnRequest(
13810
13817
  admitted,
@@ -13823,7 +13830,10 @@ async function dispatchAdmitted(admitted, env, io) {
13823
13830
  io: turnIo,
13824
13831
  request: buildInstructionSeatTurnRequest(
13825
13832
  admitted,
13826
- roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
13833
+ roleTurnOptions(activeEnv, admitted, {
13834
+ kind: "initial",
13835
+ prompt: initialPromptText
13836
+ })
13827
13837
  ),
13828
13838
  adapters,
13829
13839
  ...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
@@ -13923,10 +13933,19 @@ function resumeSameParentInstructionSeat(input) {
13923
13933
  )
13924
13934
  });
13925
13935
  }
13926
- function sameParentInstruction(env, fallback) {
13927
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
13928
- if (resumeInstruction === void 0) return fallback;
13929
- return { instruction: resumeInstruction, instructionEmpty: false };
13936
+ async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot) {
13937
+ const reask = env.reviewReask ?? env.gateReviewInstruction;
13938
+ const body = await resolveReviewSeatDialogueBody({
13939
+ ...reask === void 0 ? {} : { reask },
13940
+ callerInstruction: fallback.instruction,
13941
+ sourceRunPath,
13942
+ projectRoot,
13943
+ home: env.home
13944
+ });
13945
+ if (body !== void 0) {
13946
+ return { instruction: body, instructionEmpty: false };
13947
+ }
13948
+ return fallback;
13930
13949
  }
13931
13950
  async function runCountersignBody(parsed, env, io) {
13932
13951
  const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
@@ -13942,7 +13961,10 @@ async function runCountersignBody(parsed, env, io) {
13942
13961
  summons: {
13943
13962
  sourceRunPath: gateParentRunPath,
13944
13963
  instruction: resumeInstruction,
13945
- instructionEmpty: resumeInstruction.length === 0
13964
+ instructionEmpty: resumeInstruction.length === 0,
13965
+ // #1166 J11: same-parent resume delivers this call's file-flag paths
13966
+ // through the shared summons → appendCallerFileFlagPaths rule.
13967
+ attachmentPaths: parsed.attachmentPaths ?? []
13946
13968
  }
13947
13969
  });
13948
13970
  if (resumed != null) return resumed;
@@ -13974,9 +13996,10 @@ async function runCountersignBody(parsed, env, io) {
13974
13996
  await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
13975
13997
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
13976
13998
  }
13999
+ const reviewBody = env.reviewReask ?? env.gateReviewInstruction;
13977
14000
  const turnProjection = roleTurnOptions(env, admitted, {
13978
14001
  kind: "initial",
13979
- prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(admitted)
14002
+ prompt: reviewBody !== void 0 ? appendCallerFileFlagPaths(reviewBody, admitted.attachments) : buildInstructionTransportPrompt(admitted)
13980
14003
  });
13981
14004
  const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
13982
14005
  const result = await runPostAdmissionOneShot({
@@ -14059,10 +14082,15 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14059
14082
  if (auditorSource === void 0) return { exitCode: 2 };
14060
14083
  const sourceDirectory = auditorSource;
14061
14084
  const summons = {
14062
- ...sameParentInstruction(env, {
14063
- instruction: parsed.instruction ?? "",
14064
- instructionEmpty: (parsed.instruction ?? "").length === 0
14065
- }),
14085
+ ...await sameParentDialogue(
14086
+ env,
14087
+ {
14088
+ instruction: parsed.instruction ?? "",
14089
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14090
+ },
14091
+ sourceDirectory,
14092
+ projectRoot
14093
+ ),
14066
14094
  attachmentPaths: parsed.attachmentPaths ?? []
14067
14095
  };
14068
14096
  const resumed = await withAuditorSoulEnv({
@@ -14079,15 +14107,33 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14079
14107
  });
14080
14108
  if (resumed != null) return resumed;
14081
14109
  }
14082
- if (record.sameParent === "gate-pointer") {
14083
- const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
14084
- if (parentRunPath !== void 0) {
14110
+ if (record.sameParent === "source-run") {
14111
+ if (parsed.sourceRun !== void 0) {
14112
+ let parentRunPath;
14113
+ try {
14114
+ parentRunPath = (await resolveNotarySourceRunLocator({
14115
+ projectRoot,
14116
+ sourceRun: parsed.sourceRun,
14117
+ home: env.home
14118
+ })).runDirectory;
14119
+ } catch (error) {
14120
+ if (error instanceof NotarySourceRunError) {
14121
+ presentStructuralRejection(new CliUsageError(error.message, { cause: error }), io);
14122
+ return { exitCode: 2 };
14123
+ }
14124
+ throw error;
14125
+ }
14085
14126
  const summons = {
14086
14127
  sourceRunPath: parentRunPath,
14087
- ...sameParentInstruction(env, {
14088
- instruction: parsed.instruction ?? "",
14089
- instructionEmpty: (parsed.instruction ?? "").length === 0
14090
- }),
14128
+ ...await sameParentDialogue(
14129
+ env,
14130
+ {
14131
+ instruction: parsed.instruction ?? "",
14132
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14133
+ },
14134
+ parentRunPath,
14135
+ projectRoot
14136
+ ),
14091
14137
  attachmentPaths: parsed.attachmentPaths ?? []
14092
14138
  };
14093
14139
  const resumed = await resumeSameParentInstructionSeat({
@@ -14116,11 +14162,15 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14116
14162
  }
14117
14163
  throw error;
14118
14164
  }
14119
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
14120
14165
  const summons = {
14121
14166
  sourceRunPath: source.runDirectory,
14122
14167
  sourceRun: source,
14123
- ...resumeInstruction === void 0 ? {} : { instruction: resumeInstruction, instructionEmpty: false }
14168
+ ...await sameParentDialogue(
14169
+ env,
14170
+ { instruction: "", instructionEmpty: true },
14171
+ source.runDirectory,
14172
+ projectRoot
14173
+ )
14124
14174
  };
14125
14175
  resolvedNotarySource = source;
14126
14176
  const resumed = await resumeSameParentInstructionSeat({
@@ -14150,16 +14200,18 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14150
14200
  if (rejected !== void 0) return rejected;
14151
14201
  throw error;
14152
14202
  }
14153
- if (record.sameParent === "gate-pointer") {
14154
- const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
14155
- if (parentRunPath !== void 0) {
14156
- await persistAdmittedSourceRunPath(admitted, parentRunPath);
14157
- const sourcePatch = { sourceRunPath: parentRunPath };
14158
- admitted = { ...admitted, ...sourcePatch };
14159
- }
14203
+ if (record.sameParent === "source-run" && parsed.sourceRun !== void 0) {
14204
+ const parentRunPath = (await resolveNotarySourceRunLocator({
14205
+ projectRoot,
14206
+ sourceRun: parsed.sourceRun,
14207
+ home: env.home
14208
+ })).runDirectory;
14209
+ await persistAdmittedSourceRunPath(admitted, parentRunPath);
14210
+ admitted = { ...admitted, sourceRunPath: parentRunPath };
14160
14211
  }
14161
14212
  if (record.sameParent === "subject-source" && auditorSource !== void 0) {
14162
14213
  await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
14214
+ admitted = { ...admitted, sourceRunPath: auditorSource };
14163
14215
  }
14164
14216
  const runAdmitted = async () => {
14165
14217
  await markRunAdmitted(admitted, env.principalAuthority);
@@ -14488,13 +14540,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
14488
14540
  summonAuditor: async (subject, sourceRunDirectory, signal, reask, submission) => {
14489
14541
  const summoned = await summonPublicRole({
14490
14542
  role: "auditor",
14491
- argv: [
14492
- "--subject",
14493
- subject,
14494
- "--source-run",
14495
- sourceRunDirectory,
14496
- `${AUDITOR_DOSSIER_PROMPT}${sourceRunDirectory}`
14497
- ],
14543
+ argv: ["--subject", subject, "--source-run", sourceRunDirectory],
14498
14544
  cwd: admitted.projectRoot,
14499
14545
  home: env.home,
14500
14546
  packageRoot: env.packageRoot,
@@ -14654,7 +14700,6 @@ var init_instruction_seat_run = __esm({
14654
14700
  "src/public-cli/instruction-seat-run.ts"() {
14655
14701
  "use strict";
14656
14702
  init_role_run_placement();
14657
- init_compliance_transport();
14658
14703
  init_archivist_record_pointer();
14659
14704
  init_doctor_auditor();
14660
14705
  init_gatekeeper_role();
@@ -14763,12 +14808,12 @@ var init_analyst_book_key = __esm({
14763
14808
 
14764
14809
  // src/analyst-index.ts
14765
14810
  import { open, readFile as readFile11, unlink } from "node:fs/promises";
14766
- import { dirname as dirname16, join as join25 } from "node:path";
14811
+ import { dirname as dirname16, join as join24 } from "node:path";
14767
14812
  import { setTimeout as sleep } from "node:timers/promises";
14768
14813
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
14769
14814
  const indexPath = analystLibraryIndexPath(ledgerHome);
14770
14815
  ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
14771
- const lockPath = join25(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
14816
+ const lockPath = join24(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
14772
14817
  assertLedgerFileInsideHome(lockPath, ledgerHome);
14773
14818
  const startedAt = Date.now();
14774
14819
  while (true) {
@@ -14795,7 +14840,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
14795
14840
  }
14796
14841
  }
14797
14842
  function analystLibraryIndexPath(ledgerHome) {
14798
- return join25(ledgerHome, "analyst", "library-index.json");
14843
+ return join24(ledgerHome, "analyst", "library-index.json");
14799
14844
  }
14800
14845
  function rowFromIssueMetricsPage(page) {
14801
14846
  return {
@@ -15341,7 +15386,7 @@ var init_analyst_gate_cycles_read = __esm({
15341
15386
 
15342
15387
  // src/analyst-ledger.ts
15343
15388
  import { readdir as readdir3 } from "node:fs/promises";
15344
- import { basename as basename11, join as join26 } from "node:path";
15389
+ import { basename as basename11, join as join25 } from "node:path";
15345
15390
  async function readExistingRunLifecycleState(runDirectory) {
15346
15391
  return (await readRoleRunIdentity(runDirectory))?.state;
15347
15392
  }
@@ -15361,7 +15406,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
15361
15406
  }
15362
15407
  }
15363
15408
  async function classifyGhostCandidate(input) {
15364
- const autopsy = await autopsyWriterLock(join26(input.runDirectory, "writer.lock"));
15409
+ const autopsy = await autopsyWriterLock(join25(input.runDirectory, "writer.lock"));
15365
15410
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
15366
15411
  if (leaseCheck === void 0) return { kind: "live" };
15367
15412
  return {
@@ -15651,7 +15696,7 @@ async function classifyScopedRun(input) {
15651
15696
  async function scanAnalystIssueRuns(input) {
15652
15697
  const ledgerHome = resolveActivationLedgerHome(input.home);
15653
15698
  const scopeTicketNumber = input.ticketNumber;
15654
- const booksRoot = join26(ledgerHome, "books");
15699
+ const booksRoot = join25(ledgerHome, "books");
15655
15700
  let wholeBook = false;
15656
15701
  let scopeRootIdentity;
15657
15702
  let bookNames;
@@ -15684,7 +15729,7 @@ async function scanAnalystIssueRuns(input) {
15684
15729
  const ghostLegs = [];
15685
15730
  const scopeConflicts = [];
15686
15731
  for (const book of bookNames) {
15687
- const bookDir = join26(booksRoot, book);
15732
+ const bookDir = join25(booksRoot, book);
15688
15733
  let runDirectories;
15689
15734
  try {
15690
15735
  runDirectories = await listBookRunDirectories(bookDir);
@@ -16430,7 +16475,7 @@ var init_analyst_metric_family = __esm({
16430
16475
  });
16431
16476
 
16432
16477
  // src/analyst-page.ts
16433
- import { dirname as dirname17, join as join27 } from "node:path";
16478
+ import { dirname as dirname17, join as join26 } from "node:path";
16434
16479
  function analystIssuePageKey(address) {
16435
16480
  const parts = ["book", address.bookKey];
16436
16481
  if (address.issueNumber !== void 0) {
@@ -16441,7 +16486,7 @@ function analystIssuePageKey(address) {
16441
16486
  return sha256Hex(parts.join("\0")).slice(0, 32);
16442
16487
  }
16443
16488
  function analystIssuePagePath(ledgerHome, address) {
16444
- return join27(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16489
+ return join26(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16445
16490
  }
16446
16491
  function analystIssuePageAddressFromPage(page) {
16447
16492
  return {
@@ -16678,7 +16723,7 @@ var init_analyst_model_groups = __esm({
16678
16723
 
16679
16724
  // src/analyst-entry.ts
16680
16725
  import { readFile as readFile13 } from "node:fs/promises";
16681
- import { Type as Type17 } from "typebox";
16726
+ import { Type as Type16 } from "typebox";
16682
16727
  function cachedPageMatchesRequestedScope(page, input) {
16683
16728
  if (page.bookKey !== input.bookKey) return false;
16684
16729
  const requestedTicket = input.ticketNumber ?? input.issueNumber;
@@ -16883,16 +16928,16 @@ var init_analyst_entry = __esm({
16883
16928
  }
16884
16929
  }
16885
16930
  };
16886
- analystSweepModeInputSchema = Type17.Object(
16931
+ analystSweepModeInputSchema = Type16.Object(
16887
16932
  {
16888
- mode: Type17.Literal("sweep"),
16889
- mergedPullRequests: Type17.Array(
16890
- Type17.Object(
16933
+ mode: Type16.Literal("sweep"),
16934
+ mergedPullRequests: Type16.Array(
16935
+ Type16.Object(
16891
16936
  {
16892
- projectRoot: Type17.String(),
16937
+ projectRoot: Type16.String(),
16893
16938
  /** 排除后改动行数 — omit or 0 → typed 空缺; finite ≥ 0 only. */
16894
- changedLines: Type17.Optional(
16895
- Type17.Number({ minimum: 0, maximum: Number.MAX_VALUE })
16939
+ changedLines: Type16.Optional(
16940
+ Type16.Number({ minimum: 0, maximum: Number.MAX_VALUE })
16896
16941
  )
16897
16942
  }
16898
16943
  )
@@ -17987,7 +18032,7 @@ __export(public_role_summons_exports, {
17987
18032
  import { execFile as execFile3 } from "node:child_process";
17988
18033
  import { existsSync as existsSync9 } from "node:fs";
17989
18034
  import { realpath as realpath6 } from "node:fs/promises";
17990
- import { join as join28 } from "node:path";
18035
+ import { join as join27 } from "node:path";
17991
18036
  import { promisify as promisify3 } from "node:util";
17992
18037
  function createCapturingIo() {
17993
18038
  const chunks = [];
@@ -18011,7 +18056,7 @@ function parentDir(path) {
18011
18056
  function walkPackageRoot(start) {
18012
18057
  let dir = start;
18013
18058
  for (let i = 0; i < 12; i += 1) {
18014
- if (existsSync9(join28(dir, "package.json")) && existsSync9(join28(dir, "souls"))) {
18059
+ if (existsSync9(join27(dir, "package.json")) && existsSync9(join27(dir, "souls"))) {
18015
18060
  return dir;
18016
18061
  }
18017
18062
  const parent = parentDir(dir);
@@ -18179,7 +18224,8 @@ async function summonPublicRole(options) {
18179
18224
  ...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
18180
18225
  ...options.parentRunPath === void 0 || options.parentRunPath.trim() === "" ? {} : { parentRunPath: options.parentRunPath },
18181
18226
  ...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
18182
- ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
18227
+ ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
18228
+ ...options.navigatorWorkContextPath === void 0 || options.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: options.navigatorWorkContextPath }
18183
18229
  }
18184
18230
  };
18185
18231
  } catch (error) {
@@ -18436,7 +18482,8 @@ async function summonGateOfficer(options) {
18436
18482
  "judge",
18437
18483
  "--source-run",
18438
18484
  options.sourceRunDirectory,
18439
- `\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`
18485
+ "--project",
18486
+ options.cwd
18440
18487
  ],
18441
18488
  ...common
18442
18489
  });
@@ -18464,7 +18511,7 @@ async function summonGateOfficer(options) {
18464
18511
  }
18465
18512
  return summonPublicRole({
18466
18513
  role: options.officer,
18467
- argv: [`\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`],
18514
+ argv: ["--source-run", options.sourceRunDirectory, "--project", options.cwd],
18468
18515
  ...common
18469
18516
  });
18470
18517
  }
@@ -18572,8 +18619,7 @@ async function runComplianceAudit(options) {
18572
18619
  "--subject",
18573
18620
  auditSubject,
18574
18621
  "--source-run",
18575
- sourceRunDirectory,
18576
- `${AUDITOR_DOSSIER_PROMPT}${sourceRunDirectory}`
18622
+ sourceRunDirectory
18577
18623
  ],
18578
18624
  cwd: options.context.cwd ?? process.cwd(),
18579
18625
  home,
@@ -18597,18 +18643,17 @@ async function runComplianceAudit(options) {
18597
18643
  return decision;
18598
18644
  }
18599
18645
  }
18600
- var AUDITOR_DOSSIER_PROMPT, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, ComplianceResponseRetentionError;
18646
+ var AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, ComplianceResponseRetentionError;
18601
18647
  var init_compliance_transport = __esm({
18602
18648
  "src/compliance-transport.ts"() {
18603
18649
  "use strict";
18604
- init_auditor_dossier_tool();
18650
+ init_role_run_placement();
18605
18651
  init_gatekeeper_role();
18606
18652
  init_submission_errors();
18607
18653
  init_terminal();
18608
18654
  init_readable_gate_item();
18609
18655
  init_receipt_delivery_policy();
18610
18656
  init_unknown_value();
18611
- AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
18612
18657
  AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
18613
18658
  ComplianceResponseRetentionError = class extends Error {
18614
18659
  constructor(message, options) {
@@ -18620,7 +18665,7 @@ var init_compliance_transport = __esm({
18620
18665
  });
18621
18666
 
18622
18667
  // src/role-run-relocation.ts
18623
- import { dirname as dirname18, join as join29, sep as sep4 } from "node:path";
18668
+ import { dirname as dirname18, join as join28, sep as sep4 } from "node:path";
18624
18669
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
18625
18670
  if (typeof value !== "string") return value;
18626
18671
  if (value === oldRunDirectory) return newRunDirectory;
@@ -18738,7 +18783,6 @@ var init_role_run_relocation = __esm({
18738
18783
  var run_lifecycle_exports = {};
18739
18784
  __export(run_lifecycle_exports, {
18740
18785
  AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
18741
- GATE_DOSSIER_POINTER_PREFIX: () => GATE_DOSSIER_POINTER_PREFIX,
18742
18786
  RESUME_TRANSPORT_ENVELOPE: () => RESUME_TRANSPORT_ENVELOPE,
18743
18787
  RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
18744
18788
  acquireRunWriterLease: () => acquireRunWriterLease,
@@ -18752,7 +18796,6 @@ __export(run_lifecycle_exports, {
18752
18796
  markRunAdmitted: () => markRunAdmitted,
18753
18797
  markRunRunning: () => markRunRunning,
18754
18798
  markRunTerminal: () => markRunTerminal,
18755
- parentRunPathFromGatePointerInstruction: () => parentRunPathFromGatePointerInstruction,
18756
18799
  peekRoleRunRole: () => peekRoleRunRole,
18757
18800
  readCurrentCourt: () => readCurrentCourt,
18758
18801
  readRoleRunIdentity: () => readRoleRunIdentity,
@@ -18762,7 +18805,7 @@ __export(run_lifecycle_exports, {
18762
18805
  writeRoleRunState: () => writeRoleRunState
18763
18806
  });
18764
18807
  import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile15, unlink as unlink2 } from "node:fs/promises";
18765
- import { basename as basename12, join as join30 } from "node:path";
18808
+ import { basename as basename12, join as join29 } from "node:path";
18766
18809
  function buildAutoResumeContinuationPrompt() {
18767
18810
  return RESUME_TRANSPORT_ENVELOPE;
18768
18811
  }
@@ -19059,7 +19102,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
19059
19102
  },
19060
19103
  relocate(nextRunDirectory) {
19061
19104
  currentRunDirectory = nextRunDirectory;
19062
- currentLockPath = join30(nextRunDirectory, WRITER_LOCK_FILE);
19105
+ currentLockPath = join29(nextRunDirectory, WRITER_LOCK_FILE);
19063
19106
  },
19064
19107
  async release() {
19065
19108
  if (released) return;
@@ -19098,10 +19141,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19098
19141
  };
19099
19142
  const reportReadFailure = (error) => {
19100
19143
  reportDiagnostic(
19101
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join30(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
19144
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join29(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
19102
19145
  );
19103
19146
  };
19104
- const lockPath = join30(runDirectory, WRITER_LOCK_FILE);
19147
+ const lockPath = join29(runDirectory, WRITER_LOCK_FILE);
19105
19148
  let lastAutopsy = { verdict: "absent" };
19106
19149
  let lastReclaimFailure;
19107
19150
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -19158,7 +19201,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19158
19201
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
19159
19202
  if (runId.trim() === "") return void 0;
19160
19203
  const ledgerHome = resolveActivationLedgerHome(home);
19161
- const booksRoot = join30(ledgerHome, "books");
19204
+ const booksRoot = join29(ledgerHome, "books");
19162
19205
  let bookKeys;
19163
19206
  try {
19164
19207
  bookKeys = await readdir4(booksRoot);
@@ -19172,20 +19215,12 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
19172
19215
  onlyRole
19173
19216
  );
19174
19217
  }
19175
- function parentRunPathFromGatePointerInstruction(instruction) {
19176
- if (!instruction.startsWith(GATE_DOSSIER_POINTER_PREFIX)) return void 0;
19177
- const path = instruction.slice(GATE_DOSSIER_POINTER_PREFIX.length).trim();
19178
- return path === "" ? void 0 : path;
19179
- }
19180
19218
  async function readRunParentPath(runDirectory) {
19181
19219
  const record = readPageSync(runDirectory, "admitted");
19182
19220
  if (record === void 0) return void 0;
19183
19221
  if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
19184
19222
  return record.sourceRunPath;
19185
19223
  }
19186
- if (typeof record.instruction === "string") {
19187
- return parentRunPathFromGatePointerInstruction(record.instruction);
19188
- }
19189
19224
  return void 0;
19190
19225
  }
19191
19226
  async function runHasFormedSessionPrincipal(runDirectory) {
@@ -19209,7 +19244,7 @@ async function findLatestRunIdForSeatTicket(input) {
19209
19244
  let runDirectories;
19210
19245
  try {
19211
19246
  runDirectories = await listBookRunDirectories(
19212
- input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
19247
+ input.ticketNumber === void 0 ? bookDir : join29(bookDir, String(input.ticketNumber))
19213
19248
  );
19214
19249
  } catch (error) {
19215
19250
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -19691,7 +19726,7 @@ function resumedWorkerPhase(phase, phases, role, runId) {
19691
19726
  }
19692
19727
  throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
19693
19728
  }
19694
- var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS, GATE_DOSSIER_POINTER_PREFIX;
19729
+ var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
19695
19730
  var init_run_lifecycle = __esm({
19696
19731
  "src/public-cli/run-lifecycle.ts"() {
19697
19732
  "use strict";
@@ -19724,12 +19759,11 @@ var init_run_lifecycle = __esm({
19724
19759
  }
19725
19760
  };
19726
19761
  WRITER_LEASE_RECLAIM_ROUNDS = 3;
19727
- GATE_DOSSIER_POINTER_PREFIX = "\u5377\u5B97\u6307\u9488\uFF1A";
19728
19762
  }
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 statSync7,
19816
19850
  writeFileSync as writeFileSync2
19817
19851
  } from "node:fs";
19818
- import { dirname as dirname19, resolve as resolve15, join as join32 } from "node:path";
19852
+ import { dirname as dirname19, resolve as resolve15, 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 = statSync7(filePath);
@@ -20125,7 +20159,7 @@ init_packaged_role_registry();
20125
20159
  init_activation_ledger_topology();
20126
20160
  import { resolve as resolve16 } from "node:path";
20127
20161
  import "@earendil-works/pi-coding-agent";
20128
- import { Type as Type18 } from "typebox";
20162
+ import { Type as Type17 } from "typebox";
20129
20163
 
20130
20164
  // src/navigator-public-session.ts
20131
20165
  init_host_session_record();
@@ -20325,13 +20359,14 @@ init_atomic_write();
20325
20359
  init_unknown_value();
20326
20360
  import { existsSync as existsSync3, realpathSync as realpathSync2 } from "node:fs";
20327
20361
  import { readFile as readFile5 } from "node:fs/promises";
20328
- import { basename as basename6, dirname as dirname9, join as join11, resolve as resolve5 } from "node:path";
20362
+ import { basename as basename6, dirname as dirname9, join as join11, resolve as resolve6 } from "node:path";
20329
20363
  var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
20364
+ var AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV = "AK_ROLE_NAVIGATOR_WORK_CONTEXT";
20330
20365
  function navigatorWorkContextFile(sessionDir) {
20331
20366
  return join11(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
20332
20367
  }
20333
20368
  function isNavigatorWorkContextFile(path) {
20334
- const resolved = resolve5(path);
20369
+ const resolved = resolve6(path);
20335
20370
  if (basename6(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
20336
20371
  const nest = dirname9(resolved);
20337
20372
  if (!/^[0-9a-f]{32}$/.test(basename6(nest))) return false;
@@ -20383,33 +20418,8 @@ async function readNavigatorWorkBase(path) {
20383
20418
  if (record.authority.trim() === "") return void 0;
20384
20419
  return { subject: record.subject, authority: record.authority };
20385
20420
  }
20386
- function jsonObjectFromPrompt(prompt) {
20387
- const head = prompt.trimStart().split("\n\n", 1)[0] ?? "";
20388
- if (!head.startsWith("{")) return void 0;
20389
- try {
20390
- const parsed = JSON.parse(head);
20391
- if (!isRecord(parsed)) return void 0;
20392
- return parsed;
20393
- } catch {
20394
- return void 0;
20395
- }
20396
- }
20397
- function workContextPathFromPrompt(prompt) {
20398
- const record = jsonObjectFromPrompt(prompt);
20399
- const path = record?.workContextPath;
20400
- if (typeof path !== "string" || path.trim() === "") return void 0;
20401
- return isNavigatorWorkContextFile(path) ? path : void 0;
20402
- }
20403
- function attachWorkContextPointer(text, workContextPath) {
20404
- const record = jsonObjectFromPrompt(text);
20405
- if (record === void 0) return text;
20406
- if (typeof record.workContextPath === "string" && record.workContextPath.trim() !== "") return text;
20407
- const head = text.trimStart().split("\n\n", 1)[0] ?? "";
20408
- const rest = text.trimStart().slice(head.length);
20409
- return `${JSON.stringify({ ...record, workContextPath })}${rest}`;
20410
- }
20411
- async function loadNavigatorWorkBaseSuffix(prompt) {
20412
- const path = workContextPathFromPrompt(prompt);
20421
+ async function loadNavigatorWorkBaseSuffix(sessionDir, locatorPath) {
20422
+ 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;
20413
20423
  if (path === void 0) return void 0;
20414
20424
  const body = await readNavigatorWorkBase(path);
20415
20425
  if (body === void 0) return void 0;
@@ -20502,13 +20512,14 @@ function createNativeNavigatorSessionFactory(deps) {
20502
20512
  if (disposed) return;
20503
20513
  const resumeRunId = hostRunId;
20504
20514
  const workContextPath = navigatorWorkContextFile(sessionManager.getSessionDir());
20505
- const argvText = existsSync12(workContextPath) ? attachWorkContextPointer(text, workContextPath) : text;
20515
+ const workContextLocator = existsSync12(workContextPath) ? workContextPath : void 0;
20506
20516
  const baseSummon = {
20507
20517
  role: "navigator",
20508
- argv: [argvText],
20518
+ argv: [text],
20509
20519
  cwd: context.cwd,
20510
20520
  ...summonHome === void 0 ? {} : { home: summonHome },
20511
- ...context.signal === void 0 ? {} : { signal: context.signal }
20521
+ ...context.signal === void 0 ? {} : { signal: context.signal },
20522
+ ...workContextLocator === void 0 ? {} : { navigatorWorkContextPath: workContextLocator }
20512
20523
  };
20513
20524
  const resumable = deps?.hostRunResumable ?? navigatorHostRunResumable;
20514
20525
  let summoned;
@@ -20636,8 +20647,8 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
20636
20647
  return void 0;
20637
20648
  }
20638
20649
  var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
20639
- var prepareSchema = Type18.Object({
20640
- prose: Type18.Optional(Type18.Unknown({
20650
+ var prepareSchema = Type17.Object({
20651
+ prose: Type17.Optional(Type17.Unknown({
20641
20652
  description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
20642
20653
  }))
20643
20654
  }, { additionalProperties: true });
@@ -21178,22 +21189,22 @@ init_submission_ledger();
21178
21189
  init_filed_submission();
21179
21190
  import { randomUUID as randomUUID7 } from "node:crypto";
21180
21191
  import { writeSync as writeSync2 } from "node:fs";
21181
- import { join as join34 } from "node:path";
21192
+ import { join as join33 } from "node:path";
21182
21193
  import { Value as Value3 } from "typebox/value";
21183
21194
 
21184
21195
  // src/activation-trace.ts
21185
- import { Type as Type19 } from "typebox";
21186
- var causeSchema = Type19.Object({
21187
- identity: Type19.String({ minLength: 1 }),
21188
- name: Type19.String({ minLength: 1 }),
21189
- message: Type19.String(),
21190
- evidenceId: Type19.Optional(Type19.String({ minLength: 1 }))
21196
+ import { Type as Type18 } from "typebox";
21197
+ var causeSchema = Type18.Object({
21198
+ identity: Type18.String({ minLength: 1 }),
21199
+ name: Type18.String({ minLength: 1 }),
21200
+ message: Type18.String(),
21201
+ evidenceId: Type18.Optional(Type18.String({ minLength: 1 }))
21191
21202
  }, { additionalProperties: false });
21192
- var activationTraceRecordSchema = Type19.Object({
21193
- role: Type19.String({ minLength: 1 }),
21194
- stageId: Type19.String({ pattern: "^[a-z][a-z0-9-]*$" }),
21195
- status: Type19.Literal("failed"),
21196
- timestamp: Type19.String({ format: "date-time" }),
21203
+ var activationTraceRecordSchema = Type18.Object({
21204
+ role: Type18.String({ minLength: 1 }),
21205
+ stageId: Type18.String({ pattern: "^[a-z][a-z0-9-]*$" }),
21206
+ status: Type18.Literal("failed"),
21207
+ timestamp: Type18.String({ format: "date-time" }),
21197
21208
  cause: causeSchema
21198
21209
  }, { additionalProperties: false });
21199
21210
  var activationCauseEvidence = 0;
@@ -21358,10 +21369,10 @@ init_engine_material();
21358
21369
  init_engine_detour();
21359
21370
  init_engine_detour_usage();
21360
21371
  init_run_terminal_artifacts();
21361
- import { Type as Type20 } from "typebox";
21362
- var engineDetourArgsSchema = Type20.Object(
21372
+ import { Type as Type19 } from "typebox";
21373
+ var engineDetourArgsSchema = Type19.Object(
21363
21374
  {
21364
- argv: Type20.Array(Type20.String({ minLength: 1 }), {
21375
+ argv: Type19.Array(Type19.String({ minLength: 1 }), {
21365
21376
  minItems: 1,
21366
21377
  description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
21367
21378
  })
@@ -21682,6 +21693,24 @@ ${JSON.stringify(catalog)}
21682
21693
  init_filed_submission();
21683
21694
  init_role_submission_declarations();
21684
21695
  init_run_ticket_number();
21696
+
21697
+ // src/audited-run-identity.ts
21698
+ init_role_run_placement();
21699
+ import { basename as basename14 } from "node:path";
21700
+ var AUDITED_RUN_IDENTITY_KIND = "audited-run-identity";
21701
+ function auditedRunIdentityFromDirectory(runDirectory) {
21702
+ const parsed = parseRunLeaf(basename14(runDirectory));
21703
+ if (parsed === void 0) return void 0;
21704
+ return formatRunLeaf(parsed.runId, parsed.role);
21705
+ }
21706
+ function auditedRunIdentityMaterial(identity) {
21707
+ return { kind: AUDITED_RUN_IDENTITY_KIND, identity };
21708
+ }
21709
+ function auditedRunIdentityFromParts(runId, role) {
21710
+ return formatRunLeaf(runId, role);
21711
+ }
21712
+
21713
+ // src/notary-role.ts
21685
21714
  init_notary_contracts();
21686
21715
  function readNotaryTicketFlag(flag) {
21687
21716
  if (flag === void 0) return void 0;
@@ -21699,11 +21728,10 @@ function readNotaryTicketFlag(flag) {
21699
21728
  }
21700
21729
  return n;
21701
21730
  }
21702
- function projectNotarySessionBound(input) {
21703
- return {
21704
- sourceRun: input.sourceRun,
21705
- ...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
21706
- };
21731
+ function projectNotaryAuditedRunIdentity(input) {
21732
+ return auditedRunIdentityMaterial(
21733
+ auditedRunIdentityFromParts(input.sourceRun.runId, input.sourceRun.role)
21734
+ );
21707
21735
  }
21708
21736
  var NOTARY_SESSION_BOUND_ENTRY = "notary-session-bound";
21709
21737
  function projectNotaryBoundFromFlags(getFlag) {
@@ -21761,9 +21789,8 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
21761
21789
  baseSystemPrompt: event.systemPrompt,
21762
21790
  soul: activation.soul
21763
21791
  }),
21764
- readingMaterial: projectNotarySessionBound({
21765
- sourceRun: activation.sourceRun,
21766
- ...activation.ticketNumber === void 0 ? {} : { ticketNumber: activation.ticketNumber }
21792
+ readingMaterial: projectNotaryAuditedRunIdentity({
21793
+ sourceRun: activation.sourceRun
21767
21794
  })
21768
21795
  };
21769
21796
  });
@@ -21843,6 +21870,7 @@ init_role_submission_declarations();
21843
21870
  var AUDITOR_TOOL_SPEC = roleSubmissionDeclaration("auditor");
21844
21871
 
21845
21872
  // src/role-runtime.ts
21873
+ init_auditor_soul();
21846
21874
  init_navigator_invocation_identity();
21847
21875
  init_settlement();
21848
21876
  init_packaged_role_registry();
@@ -22732,7 +22760,7 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
22732
22760
  playbookBound = true;
22733
22761
  const loadRoutePlaybook = dependencies.loadRoutePlaybook ?? (() => readPackageMaterial("resources/navigator-route-playbook.md"));
22734
22762
  let playbookRead;
22735
- roleHost.on("before_agent_start", async (event) => {
22763
+ roleHost.on("before_agent_start", async (event, ctx) => {
22736
22764
  const basePrompt = typeof event.systemPrompt === "string" ? event.systemPrompt : "";
22737
22765
  const parts = [];
22738
22766
  try {
@@ -22747,8 +22775,10 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
22747
22775
  parts.push(message);
22748
22776
  }
22749
22777
  }
22750
- const prompt = typeof event.prompt === "string" ? event.prompt : "";
22751
- const work = await loadNavigatorWorkBaseSuffix(prompt);
22778
+ const work = await loadNavigatorWorkBaseSuffix(
22779
+ ctx.sessionManager?.getSessionDir?.(),
22780
+ ctx.navigatorWorkContextPath
22781
+ );
22752
22782
  if (work !== void 0 && work.trim() !== "") parts.push(work);
22753
22783
  if (parts.length === 0) return;
22754
22784
  const text = parts.join("\n\n");
@@ -22762,7 +22792,7 @@ ${text}`
22762
22792
  };
22763
22793
  }
22764
22794
  function createAuditorRoleRuntime(roleHost, dependencies) {
22765
- const base = createFiledOfficerRuntime(
22795
+ return createFiledOfficerRuntime(
22766
22796
  roleHost,
22767
22797
  {
22768
22798
  role: "auditor",
@@ -22771,17 +22801,27 @@ function createAuditorRoleRuntime(roleHost, dependencies) {
22771
22801
  },
22772
22802
  dependencies
22773
22803
  );
22774
- return {
22775
- async activate() {
22776
- await base.activate();
22777
- const { createAuditorDossierTool: createAuditorDossierTool2, AUDITOR_DOSSIER_TOOL_NAME: AUDITOR_DOSSIER_TOOL_NAME2 } = await Promise.resolve().then(() => (init_auditor_dossier_tool(), auditor_dossier_tool_exports));
22778
- const { AK_ROLE_AUDITOR_SOURCE_RUN_ENV: AK_ROLE_AUDITOR_SOURCE_RUN_ENV2 } = await Promise.resolve().then(() => (init_auditor_soul(), auditor_soul_exports));
22779
- const already = roleHost.getAllTools().some((tool) => tool.name === AUDITOR_DOSSIER_TOOL_NAME2);
22780
- if (already) return;
22781
- 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;
22782
- roleHost.registerTool(createAuditorDossierTool2(sourceRun));
22804
+ }
22805
+ function isAuditedIdentitySeat(role) {
22806
+ return role === "notary" || role === "inspector" || role === "auditor" || role === "countersign";
22807
+ }
22808
+ function resolveAuditedSourceRunDirectory(roleHost, ctx, role) {
22809
+ const notary = roleHost.getFlag(NOTARY_SOURCE_RUN_FLAG.name);
22810
+ if (typeof notary === "string" && notary.trim() !== "") return notary.trim();
22811
+ const inspector = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
22812
+ if (typeof inspector === "string" && inspector.trim() !== "") return inspector.trim();
22813
+ const runDirectory = runDirectoryFromHostContext(ctx);
22814
+ if (runDirectory !== void 0) {
22815
+ const admitted = readPageSync(runDirectory, "admitted");
22816
+ if (typeof admitted?.sourceRunPath === "string" && admitted.sourceRunPath.trim() !== "") {
22817
+ return admitted.sourceRunPath.trim();
22783
22818
  }
22784
- };
22819
+ }
22820
+ if (role === "auditor") {
22821
+ const auditor = typeof process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV] === "string" ? process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV].trim() : "";
22822
+ if (auditor !== "") return auditor;
22823
+ }
22824
+ return void 0;
22785
22825
  }
22786
22826
  function readDiaristTicketAssertion(submitted) {
22787
22827
  if (submitted === void 0 || !("ticketNumber" in submitted)) {
@@ -22798,7 +22838,7 @@ function readRoleRunCoordinates(ctx, label) {
22798
22838
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
22799
22839
  const admitted = readPageSync(runDirectory, "admitted");
22800
22840
  if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
22801
- throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join34(runDirectory, RUN_STATE_FILE)})`);
22841
+ throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join33(runDirectory, RUN_STATE_FILE)})`);
22802
22842
  }
22803
22843
  return {
22804
22844
  runDirectory,
@@ -23123,15 +23163,14 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23123
23163
  if (reading === void 0) return;
23124
23164
  return { readingMaterial: reading };
23125
23165
  });
23126
- roleHost.on("before_agent_start", () => {
23127
- const path = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
23128
- if (typeof path !== "string" || path.trim() === "") return;
23129
- return {
23130
- readingMaterial: {
23131
- kind: "inspector-parent-binding",
23132
- sourceRunPath: path
23133
- }
23134
- };
23166
+ roleHost.on("before_agent_start", (_event, ctx) => {
23167
+ const role = selectedRole ?? roleHost.getFlag(ROLE_FLAG.name);
23168
+ if (typeof role !== "string" || !isAuditedIdentitySeat(role) || role === "notary") return;
23169
+ const sourceDirectory = resolveAuditedSourceRunDirectory(roleHost, ctx, role);
23170
+ if (sourceDirectory === void 0) return;
23171
+ const identity = auditedRunIdentityFromDirectory(sourceDirectory);
23172
+ if (identity === void 0) return;
23173
+ return { readingMaterial: auditedRunIdentityMaterial(identity) };
23135
23174
  });
23136
23175
  roleHost.on("tool_result", async (event, ctx) => {
23137
23176
  const role = selectedRole;
@@ -23764,6 +23803,7 @@ async function prepareRoleEnvelope(options) {
23764
23803
  ...request.courtAttemptId === void 0 ? {} : { courtAttemptId: request.courtAttemptId },
23765
23804
  ...request.invocationScopeId === void 0 ? {} : { invocationScopeId: request.invocationScopeId },
23766
23805
  ...request.host === void 0 || request.host.trim() === "" ? {} : { host: request.host.trim() },
23806
+ ...request.navigatorWorkContextPath === void 0 || request.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: request.navigatorWorkContextPath },
23767
23807
  sessionManager: {
23768
23808
  getLeafEntry: () => sessionEntries.at(-1),
23769
23809
  getLeafId: () => runId,
@@ -24250,7 +24290,7 @@ import { randomUUID as randomUUID9 } from "node:crypto";
24250
24290
  import { existsSync as existsSync14 } from "node:fs";
24251
24291
  import { mkdtemp, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
24252
24292
  import { tmpdir } from "node:os";
24253
- import { dirname as dirname22, isAbsolute as isAbsolute11, join as join35, resolve as resolve20 } from "node:path";
24293
+ import { dirname as dirname22, isAbsolute as isAbsolute11, join as join34, resolve as resolve20 } from "node:path";
24254
24294
 
24255
24295
  // src/external-host-turn-loop.ts
24256
24296
  init_settlement();
@@ -24789,7 +24829,7 @@ function formatCodexFailurePayload(payload) {
24789
24829
  function cwdIsGitWorkTree(cwd) {
24790
24830
  let dir = cwd;
24791
24831
  for (; ; ) {
24792
- if (existsSync14(join35(dir, ".git"))) return true;
24832
+ if (existsSync14(join34(dir, ".git"))) return true;
24793
24833
  const parent = dirname22(dir);
24794
24834
  if (parent === dir) return false;
24795
24835
  dir = parent;
@@ -25007,8 +25047,8 @@ function createHeadlessRoleTurnHost(config) {
25007
25047
  }
25008
25048
  const env = { ...process.env, ...config.env ?? {} };
25009
25049
  const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
25010
- const inputsDirectory = await mkdtemp(join35(tmpdir(), "ak-role-headless-"));
25011
- const systemPromptPath = join35(inputsDirectory, "system-prompt.txt");
25050
+ const inputsDirectory = await mkdtemp(join34(tmpdir(), "ak-role-headless-"));
25051
+ const systemPromptPath = join34(inputsDirectory, "system-prompt.txt");
25012
25052
  let mcpConfigPath;
25013
25053
  let outputSchemaPath;
25014
25054
  let startedWithSchema;
@@ -25017,13 +25057,13 @@ function createHeadlessRoleTurnHost(config) {
25017
25057
  let deliveredSchema;
25018
25058
  if (codex) {
25019
25059
  if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
25020
- outputSchemaPath = join35(inputsDirectory, "output-schema.json");
25060
+ outputSchemaPath = join34(inputsDirectory, "output-schema.json");
25021
25061
  deliveredSchema = closeJsonSchemaForCodex(prepared.jsonSchema);
25022
25062
  await writeFile6(outputSchemaPath, `${JSON.stringify(deliveredSchema, null, 2)}
25023
25063
  `, "utf8");
25024
25064
  }
25025
25065
  } else {
25026
- mcpConfigPath = join35(inputsDirectory, "mcp-config.json");
25066
+ mcpConfigPath = join34(inputsDirectory, "mcp-config.json");
25027
25067
  await writeFile6(
25028
25068
  mcpConfigPath,
25029
25069
  `${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}