@akagilnc/pi-workflow-roles 0.1.4035 → 0.1.4062

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 (54) hide show
  1. package/dist/acp-host/production-host.js +476 -250
  2. package/dist/doctor-auditor.js +1 -1
  3. package/dist/dossier-resolution.js +21 -8
  4. package/dist/gatekeeper-role.js +34 -27
  5. package/dist/headless-host/description.js +7 -8
  6. package/dist/headless-host/production-host.js +503 -264
  7. package/dist/host-contracts.js +16 -0
  8. package/dist/inspector-contracts.js +8 -0
  9. package/dist/packaged-role-registry.js +1 -1
  10. package/dist/pi/role-turn-host.js +43 -13
  11. package/dist/public-cli/case-dossier-delivery.js +60 -1
  12. package/dist/public-cli/inspector-run.js +17 -3
  13. package/dist/public-cli/instruction-seat-run.js +9 -6
  14. package/dist/public-cli/main.js +239 -112
  15. package/dist/public-cli/notary-run.js +7 -4
  16. package/dist/public-cli/post-admission.js +66 -59
  17. package/dist/public-cli/run-lifecycle.js +3 -0
  18. package/dist/public-cli/settlement.js +24 -7
  19. package/dist/public-role-summons.js +8 -0
  20. package/dist/submission-ledger.js +30 -8
  21. package/dist/user-dialogue-stdin.js +33 -0
  22. package/extensions/role-runtime.ts +1 -0
  23. package/package.json +1 -1
  24. package/resources/836-deleted-machine-instruction-inventory.md +1 -1
  25. package/src/doctor-auditor.ts +1 -1
  26. package/src/dossier-resolution.ts +26 -8
  27. package/src/external-host-turn-loop.ts +9 -0
  28. package/src/gatekeeper-pass-envelope.ts +6 -0
  29. package/src/gatekeeper-role.ts +47 -28
  30. package/src/headless-host/description.ts +8 -11
  31. package/src/headless-host/role-turn-host.ts +20 -5
  32. package/src/host-contracts.ts +22 -3
  33. package/src/inspector-contracts.ts +7 -0
  34. package/src/judge-role.ts +4 -0
  35. package/src/navigator-work-context.ts +3 -4
  36. package/src/notary-role.ts +1 -0
  37. package/src/packaged-role-registry.ts +1 -1
  38. package/src/pi/adapter.ts +19 -4
  39. package/src/pi/role-turn-host.ts +48 -14
  40. package/src/public-cli/case-dossier-delivery.ts +86 -1
  41. package/src/public-cli/inspector-run.ts +26 -2
  42. package/src/public-cli/instruction-seat-run.ts +17 -9
  43. package/src/public-cli/invocation.ts +2 -0
  44. package/src/public-cli/notary-run.ts +13 -4
  45. package/src/public-cli/post-admission.ts +74 -65
  46. package/src/public-cli/run-lifecycle.ts +3 -0
  47. package/src/public-cli/settlement.ts +32 -6
  48. package/src/public-role-summons.ts +31 -7
  49. package/src/role-envelope.ts +9 -30
  50. package/src/role-runtime-dependencies.ts +1 -0
  51. package/src/role-runtime.ts +95 -19
  52. package/src/submission-ledger.ts +48 -13
  53. package/src/user-dialogue-stdin.ts +37 -0
  54. package/src/worker-role.ts +4 -0
@@ -14892,7 +14892,7 @@ var init_packaged_role_registry = __esm({
14892
14892
  role: "inspector",
14893
14893
  phases: [null],
14894
14894
  outputTool: INSPECTOR_OUTPUT_TOOL_NAME,
14895
- inputFlag: void 0,
14895
+ inputFlag: "ak-inspector-source-run",
14896
14896
  phaseFlag: void 0,
14897
14897
  activationStage: "load-and-install",
14898
14898
  sessionMaterials: INSPECTOR_SESSION_MATERIALS
@@ -15926,6 +15926,9 @@ var init_cli_errors = __esm({
15926
15926
  });
15927
15927
 
15928
15928
  // src/host-contracts.ts
15929
+ function isOfficerReviewSeat(role) {
15930
+ return role === "notary" || role === "inspector" || role === "auditor";
15931
+ }
15929
15932
  var ExplicitInternalActivationError;
15930
15933
  var init_host_contracts = __esm({
15931
15934
  "src/host-contracts.ts"() {
@@ -15963,12 +15966,13 @@ function applyEngineChildEnv(childEnv, engine) {
15963
15966
  childEnv[AK_ROLE_ENGINE_ENV] = void 0;
15964
15967
  }
15965
15968
  }
15966
- var ENGINE_DETOUR_TOOL_NAME, AK_ROLE_ENGINE_ENV;
15969
+ var ENGINE_DETOUR_TOOL_NAME, AK_ROLE_ENGINE_ENV, ENGINE_MODEL_FLAG_NAME;
15967
15970
  var init_engine_detour = __esm({
15968
15971
  "src/engine-detour.ts"() {
15969
15972
  "use strict";
15970
15973
  ENGINE_DETOUR_TOOL_NAME = "ak_engine_detour";
15971
15974
  AK_ROLE_ENGINE_ENV = "AK_ROLE_ENGINE";
15975
+ ENGINE_MODEL_FLAG_NAME = "ak-engine-model";
15972
15976
  }
15973
15977
  });
15974
15978
 
@@ -16019,6 +16023,18 @@ var init_role_activation_flags = __esm({
16019
16023
  }
16020
16024
  });
16021
16025
 
16026
+ // src/user-dialogue-stdin.ts
16027
+ function encodeUserDialogueStdin(body) {
16028
+ return JSON.stringify({ kind: USER_DIALOGUE_STDIN_KIND, body });
16029
+ }
16030
+ var USER_DIALOGUE_STDIN_KIND;
16031
+ var init_user_dialogue_stdin = __esm({
16032
+ "src/user-dialogue-stdin.ts"() {
16033
+ "use strict";
16034
+ USER_DIALOGUE_STDIN_KIND = "ak-user-dialogue";
16035
+ }
16036
+ });
16037
+
16022
16038
  // src/sitian-contracts.ts
16023
16039
  function attachDirectErrnoCode(error, cause) {
16024
16040
  if (cause === null || typeof cause !== "object" || !("code" in cause)) return;
@@ -16392,11 +16408,6 @@ function applyPiNativeSkillInvocation(methods, prompt) {
16392
16408
  }
16393
16409
  function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
16394
16410
  const { sessionFile, sessionDirectory } = authority.decode(request.principal);
16395
- const rawPrompt = request.continuation.kind === "initial" || request.continuation.kind === "resume" ? request.continuation.prompt : (() => {
16396
- const _exhaustive = request.continuation;
16397
- return _exhaustive;
16398
- })();
16399
- const prompt = applyPiNativeSkillInvocation(request.methods, rawPrompt);
16400
16411
  return [
16401
16412
  "--no-skills",
16402
16413
  ...buildMethodArgs(request.methods),
@@ -16410,12 +16421,24 @@ function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
16410
16421
  ...extraPiArgs,
16411
16422
  // Envelope assembly = projectActivationFlags; pi only renders argv pairs.
16412
16423
  ...activationFlagsToPiArgv(projectActivationFlags(request)),
16424
+ ...piEngineModelArgs(request),
16413
16425
  "--mode",
16414
16426
  "json",
16415
- ...buildSeatModelCliArgs2(request.model),
16416
- prompt
16427
+ ...buildSeatModelCliArgs2(request.model)
16417
16428
  ];
16418
16429
  }
16430
+ function piEngineModelArgs(request) {
16431
+ const model = normalizeEngineName(request.engineModel);
16432
+ if (model === void 0) return [];
16433
+ return [`--${ENGINE_MODEL_FLAG_NAME}`, model];
16434
+ }
16435
+ function piUserDialogueBody(request) {
16436
+ const rawPrompt = request.continuation.kind === "initial" || request.continuation.kind === "resume" ? request.continuation.prompt : (() => {
16437
+ const _exhaustive = request.continuation;
16438
+ return _exhaustive;
16439
+ })();
16440
+ return applyPiNativeSkillInvocation(request.methods, rawPrompt);
16441
+ }
16419
16442
  async function resolveSelectedPi(command, cwd, env) {
16420
16443
  const searchPath = env.PATH ?? (platform === "win32" ? process.env.PATH ?? "" : "/usr/bin:/bin");
16421
16444
  const candidates = isAbsolute3(command) || command.includes("/") ? [resolve4(cwd, command)] : searchPath.split(delimiter2).map((dir) => resolve4(cwd, dir, command));
@@ -16455,11 +16478,22 @@ function createDefaultPiSpawnRunner(options) {
16455
16478
  const child = spawn(piIdentity.executable, [...args], {
16456
16479
  cwd: spawnOptions.cwd,
16457
16480
  env: spawnOptions.env,
16458
- stdio: ["ignore", "ignore", "pipe"]
16481
+ stdio: ["pipe", "ignore", "pipe"]
16459
16482
  });
16483
+ if (child.stdin === null) {
16484
+ throw new Error("Pi child stdin pipe was not created");
16485
+ }
16460
16486
  if (child.stderr === null) {
16461
16487
  throw new Error("Pi child stderr pipe was not created");
16462
16488
  }
16489
+ let stdinDeliveryError;
16490
+ child.stdin.on("error", (error) => {
16491
+ stdinDeliveryError ??= error;
16492
+ });
16493
+ if (spawnOptions.stdin !== void 0) {
16494
+ child.stdin.write(spawnOptions.stdin);
16495
+ }
16496
+ child.stdin.end();
16463
16497
  let stderr = "";
16464
16498
  let timedOut = false;
16465
16499
  let timer;
@@ -16512,6 +16546,10 @@ function createDefaultPiSpawnRunner(options) {
16512
16546
  reject(executionError);
16513
16547
  return;
16514
16548
  }
16549
+ if (stdinDeliveryError !== void 0) {
16550
+ reject(stdinDeliveryError);
16551
+ return;
16552
+ }
16515
16553
  resolveResult({
16516
16554
  code,
16517
16555
  stderr,
@@ -16535,7 +16573,8 @@ function createPiRoleTurnHost(config) {
16535
16573
  return {
16536
16574
  async executeTurn(request) {
16537
16575
  let turnRequest = request;
16538
- const paths = request.hostTransition?.priorNativeKind === "sitian" ? request.hostTransition.priorNativePaths : void 0;
16576
+ const officerStationChild = request.stationChild === true && isOfficerReviewSeat(request.activation.role);
16577
+ const paths = !officerStationChild && request.hostTransition?.priorNativeKind === "sitian" ? request.hostTransition.priorNativePaths : void 0;
16539
16578
  if (request.continuation.kind === "resume" && paths !== void 0 && paths.length > 0) {
16540
16579
  turnRequest = {
16541
16580
  ...request,
@@ -16553,6 +16592,7 @@ ${paths.join("\n")}`
16553
16592
  config.extraPiArgs ?? []
16554
16593
  );
16555
16594
  const args = buildExplicitInternalActivationArgs(roleEntry, extraArgs);
16595
+ const stdin = encodeUserDialogueStdin(piUserDialogueBody(turnRequest));
16556
16596
  const env = {
16557
16597
  ...process.env,
16558
16598
  HOME: request.home,
@@ -16584,6 +16624,7 @@ ${paths.join("\n")}`
16584
16624
  return await spawnRunner(args, {
16585
16625
  cwd: request.cwd,
16586
16626
  env,
16627
+ stdin,
16587
16628
  ...timeoutMs === void 0 ? {} : { timeoutMs },
16588
16629
  ...request.signal === void 0 ? {} : { signal: request.signal }
16589
16630
  });
@@ -16627,6 +16668,7 @@ var init_role_turn_host = __esm({
16627
16668
  init_host_contracts();
16628
16669
  init_engine_detour();
16629
16670
  init_role_activation_flags();
16671
+ init_user_dialogue_stdin();
16630
16672
  init_sitian_facade();
16631
16673
  INTERNAL_ROLE_ENTRYPOINT_RELATIVE2 = "extensions/role-runtime.ts";
16632
16674
  EXPLICIT_INTERNAL_LOAD_PROBE_ARGS = [
@@ -16687,6 +16729,17 @@ var init_sha256 = __esm({
16687
16729
  });
16688
16730
 
16689
16731
  // src/readable-gate-item.ts
16732
+ var readable_gate_item_exports = {};
16733
+ __export(readable_gate_item_exports, {
16734
+ joinReadableGateItems: () => joinReadableGateItems,
16735
+ readableGateItem: () => readableGateItem
16736
+ });
16737
+ function readableGateItem(value) {
16738
+ return typeof value === "string" ? value : JSON.stringify(value);
16739
+ }
16740
+ function joinReadableGateItems(items, separator = "; ") {
16741
+ return items.map(readableGateItem).join(separator);
16742
+ }
16690
16743
  var init_readable_gate_item = __esm({
16691
16744
  "src/readable-gate-item.ts"() {
16692
16745
  "use strict";
@@ -18614,7 +18667,8 @@ async function loadResumableInspectorRun(home, runId, authority) {
18614
18667
  }
18615
18668
  const admitted = {
18616
18669
  role: "inspector",
18617
- ...resumedBaseAdmitted(loaded)
18670
+ ...resumedBaseAdmitted(loaded),
18671
+ ...loaded.admittedFields.sourceRunPath === void 0 ? {} : { sourceRunPath: loaded.admittedFields.sourceRunPath }
18618
18672
  };
18619
18673
  return seatLoadedResult(loaded, admitted);
18620
18674
  }
@@ -22887,10 +22941,10 @@ function pairGateRounds(volumes) {
22887
22941
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
22888
22942
  }
22889
22943
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
22890
- const { readFile: readFile23 } = await import("node:fs/promises");
22944
+ const { readFile: readFile24 } = await import("node:fs/promises");
22891
22945
  let raw;
22892
22946
  try {
22893
- raw = JSON.parse(await readFile23(pointerPath, "utf8"));
22947
+ raw = JSON.parse(await readFile24(pointerPath, "utf8"));
22894
22948
  } catch (error) {
22895
22949
  throw new Error(
22896
22950
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
@@ -23191,10 +23245,8 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
23191
23245
  ...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
23192
23246
  };
23193
23247
  }
23194
- async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
23195
- const scope = resolveReadScope(homeOrScope);
23196
- const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
23197
- const scoped = recordsForAttempt(owned, scope.attemptId);
23248
+ function mapOwnedToSubmissionRows(owned) {
23249
+ const scoped = owned;
23198
23250
  const out = [];
23199
23251
  const indexByCall = /* @__PURE__ */ new Map();
23200
23252
  const roleByCall = /* @__PURE__ */ new Map();
@@ -23258,6 +23310,17 @@ async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
23258
23310
  }
23259
23311
  return out;
23260
23312
  }
23313
+ async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
23314
+ const scope = resolveReadScope(homeOrScope);
23315
+ const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
23316
+ const scoped = recordsForAttempt(owned, scope.attemptId);
23317
+ return mapOwnedToSubmissionRows(scoped);
23318
+ }
23319
+ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, home) {
23320
+ if (attemptId.length === 0) return [];
23321
+ const { owned } = await readOwnedSubmissionRecords(cwd, runId, home);
23322
+ return mapOwnedToSubmissionRows(owned.filter((record4) => recordAttemptId(record4) === attemptId));
23323
+ }
23261
23324
  async function readRecordedSubmissions(cwd, runId, homeOrScope) {
23262
23325
  return (await readRecordedSubmissionRows(cwd, runId, homeOrScope)).map((row) => row.accepted);
23263
23326
  }
@@ -23265,6 +23328,7 @@ var init_submission_ledger = __esm({
23265
23328
  "src/submission-ledger.ts"() {
23266
23329
  "use strict";
23267
23330
  init_activation_ledger_topology();
23331
+ init_host_contracts();
23268
23332
  init_audit_escalation();
23269
23333
  init_run_terminal_artifacts();
23270
23334
  init_sitian_facade();
@@ -23387,6 +23451,7 @@ var DOCTOR_CANDIDATE_ENTRY_TYPE;
23387
23451
  var init_dossier_resolution = __esm({
23388
23452
  "src/dossier-resolution.ts"() {
23389
23453
  "use strict";
23454
+ init_host_contracts();
23390
23455
  DOCTOR_CANDIDATE_ENTRY_TYPE = "ak_doctor_audit_candidate";
23391
23456
  }
23392
23457
  });
@@ -23934,6 +23999,16 @@ function roleOutcomeFromRows(role, rows) {
23934
23999
  return { kind: "accepted", role, payloads };
23935
24000
  }
23936
24001
  async function sealedLedgerOutcome(admitted, role, scope) {
24002
+ const home = sealedLedgerHome(admitted);
24003
+ if (scope?.courtAttemptId !== void 0 && scope.courtAttemptId.length > 0) {
24004
+ const thisCourt = await readAttemptScopedSubmissionRows(
24005
+ admitted.projectRoot,
24006
+ admitted.runId,
24007
+ scope.courtAttemptId,
24008
+ home
24009
+ );
24010
+ return roleOutcomeFromRows(role, thisCourt);
24011
+ }
23937
24012
  const rows = await readRecordedSubmissionRows(
23938
24013
  admitted.projectRoot,
23939
24014
  admitted.runId,
@@ -23960,11 +24035,15 @@ async function recordedSubmissionPayloads(admitted, scope) {
23960
24035
  function withSubmissions(terminal, submissions) {
23961
24036
  if (submissions.length === 0) return terminal;
23962
24037
  const roleOutcome = terminal.roleOutcome;
23963
- const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" || roleOutcome.kind === "failure" ? { ...roleOutcome, payloads: submissions } : roleOutcome;
24038
+ const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" ? { ...roleOutcome, payloads: (roleOutcome.payloads ?? []).length > 0 ? roleOutcome.payloads : submissions } : roleOutcome.kind === "failure" ? { ...roleOutcome, payloads: roleOutcome.payloads ?? submissions } : roleOutcome;
23964
24039
  return { ...terminal, roleOutcome: withPayloads, submissions };
23965
24040
  }
23966
24041
  async function attachRecordedSubmissions(admitted, terminal, scope) {
23967
- return withSubmissions(terminal, await recordedSubmissionPayloads(admitted, scope));
24042
+ void scope;
24043
+ return withSubmissions(
24044
+ terminal,
24045
+ await recordedSubmissionPayloads(admitted, void 0)
24046
+ );
23968
24047
  }
23969
24048
  async function settleHostEndedNoReceipt(admitted, authority) {
23970
24049
  const facts = noReceiptLifecycleFacts({
@@ -26337,6 +26416,9 @@ var init_ticket_provenance = __esm({
26337
26416
  });
26338
26417
 
26339
26418
  // src/public-cli/case-dossier-delivery.ts
26419
+ import { mkdtemp, readFile as readFile18, rm, writeFile as writeFile7 } from "node:fs/promises";
26420
+ import { tmpdir } from "node:os";
26421
+ import { join as join24 } from "node:path";
26340
26422
  function describeDossierFile(path) {
26341
26423
  return path;
26342
26424
  }
@@ -26355,18 +26437,42 @@ async function projectCaseDossierPointerSection(input) {
26355
26437
  `\u8BB0\u5F55\u5377\u5B97\uFF1A${describeDossierFile(volume.recordFile)}`
26356
26438
  ].join("\n");
26357
26439
  }
26358
- var CASE_DOSSIER_SECTION_HEADING;
26440
+ async function deliverCaseDossierAsAttachment(input) {
26441
+ const section = await projectCaseDossierPointerSection({
26442
+ ticketNumber: input.ticketNumber,
26443
+ projectRoot: input.projectRoot,
26444
+ home: input.home
26445
+ });
26446
+ if (section === void 0) return void 0;
26447
+ const stagingDir = await mkdtemp(join24(tmpdir(), "ak-case-dossier-"));
26448
+ try {
26449
+ const stagingPath = join24(stagingDir, CASE_DOSSIER_ATTACH_FILE);
26450
+ await writeFile7(stagingPath, `${section}
26451
+ `, "utf8");
26452
+ return await freezeAttachmentsIntoRun(
26453
+ [stagingPath],
26454
+ input.runDirectory,
26455
+ CASE_DOSSIER_ATTACH_KEY
26456
+ );
26457
+ } finally {
26458
+ await rm(stagingDir, { recursive: true, force: true });
26459
+ }
26460
+ }
26461
+ var CASE_DOSSIER_SECTION_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
26359
26462
  var init_case_dossier_delivery = __esm({
26360
26463
  "src/public-cli/case-dossier-delivery.ts"() {
26361
26464
  "use strict";
26362
26465
  init_ticket_provenance();
26466
+ init_invocation();
26363
26467
  CASE_DOSSIER_SECTION_HEADING = "## \u672C\u7968\u8D77\u5C45\u5F55\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
26468
+ CASE_DOSSIER_ATTACH_KEY = "case-dossier";
26469
+ CASE_DOSSIER_ATTACH_FILE = "case-dossier-pointer.md";
26364
26470
  }
26365
26471
  });
26366
26472
 
26367
26473
  // src/host-transition-prior-native.ts
26368
26474
  import { access as access3, readdir as readdir6 } from "node:fs/promises";
26369
- import { dirname as dirname13, join as join24 } from "node:path";
26475
+ import { dirname as dirname13, join as join25 } from "node:path";
26370
26476
  function isEnoent2(error) {
26371
26477
  return typeof error === "object" && error !== null && error.code === "ENOENT";
26372
26478
  }
@@ -26391,7 +26497,7 @@ async function listSitianRecordPaths(sessionParent) {
26391
26497
  const recordPaths = [];
26392
26498
  for (const entry of entries) {
26393
26499
  if (!entry.isDirectory()) continue;
26394
- const recordFile = join24(sessionRoot, entry.name, "records.jsonl");
26500
+ const recordFile = join25(sessionRoot, entry.name, "records.jsonl");
26395
26501
  try {
26396
26502
  await access3(recordFile);
26397
26503
  recordPaths.push(recordFile);
@@ -26461,7 +26567,7 @@ var init_public_run_credentials = __esm({
26461
26567
  import { constants as fsConstants2 } from "node:fs";
26462
26568
  import { randomUUID as randomUUID4 } from "node:crypto";
26463
26569
  import { lstat as lstat5, mkdir as mkdir5, open as open2 } from "node:fs/promises";
26464
- import { join as join25 } from "node:path";
26570
+ import { join as join26 } from "node:path";
26465
26571
  async function persistReturnedRunState(admitted, authority, options) {
26466
26572
  if (options?.lawful === true) {
26467
26573
  await markRunTerminal(admitted.runDirectory);
@@ -26497,7 +26603,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
26497
26603
  }
26498
26604
  }
26499
26605
  function runArtifactsDirectory(runDirectory) {
26500
- return join25(runDirectory, "artifacts");
26606
+ return join26(runDirectory, "artifacts");
26501
26607
  }
26502
26608
  async function ensureRealArtifactsDirectory(runDirectory) {
26503
26609
  const runStat = await lstat5(runDirectory);
@@ -26579,7 +26685,7 @@ function jsonSafeReplacer() {
26579
26685
  };
26580
26686
  }
26581
26687
  async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
26582
- const filePath = join25(artifactsDir, `${namePrefix}-${randomUUID4()}.json`);
26688
+ const filePath = join26(artifactsDir, `${namePrefix}-${randomUUID4()}.json`);
26583
26689
  const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
26584
26690
  `;
26585
26691
  const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
@@ -26850,8 +26956,8 @@ var init_auto_resume = __esm({
26850
26956
 
26851
26957
  // src/public-cli/post-admission.ts
26852
26958
  import { randomUUID as randomUUID5 } from "node:crypto";
26853
- import { readFile as readFile18, writeFile as writeFile7 } from "node:fs/promises";
26854
- import { isAbsolute as isAbsolute8, join as join26, resolve as resolve9 } from "node:path";
26959
+ import { readFile as readFile19, writeFile as writeFile8 } from "node:fs/promises";
26960
+ import { isAbsolute as isAbsolute8, join as join27, resolve as resolve9 } from "node:path";
26855
26961
  function describeCaughtError(error) {
26856
26962
  if (error instanceof Error) {
26857
26963
  const code = error.code;
@@ -26865,6 +26971,9 @@ function appendContinuationSection(continuation, section) {
26865
26971
  ${section}`;
26866
26972
  return continuation.kind === "initial" ? { kind: "initial", prompt } : { kind: "resume", prompt };
26867
26973
  }
26974
+ function isStationChildOfficerDialogue(role, env) {
26975
+ return env.stationChild === true && isOfficerReviewSeat(role);
26976
+ }
26868
26977
  function withOnceSuccessfulBeforeDispatch(adapters) {
26869
26978
  const hook = adapters.beforeDispatch;
26870
26979
  if (hook === void 0) return adapters;
@@ -26892,8 +27001,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
26892
27001
  } catch (appendError) {
26893
27002
  try {
26894
27003
  const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
26895
- await writeFile7(
26896
- join26(artifactsDir, `post-admission-diagnostic-${randomUUID5()}.json`),
27004
+ await writeFile8(
27005
+ join27(artifactsDir, `post-admission-diagnostic-${randomUUID5()}.json`),
26897
27006
  `${JSON.stringify({ version: 1, ...payload }, null, 2)}
26898
27007
  `,
26899
27008
  { encoding: "utf8", flag: "wx" }
@@ -26909,7 +27018,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
26909
27018
  }
26910
27019
  async function readInvocationHost(runDirectory) {
26911
27020
  try {
26912
- const raw = JSON.parse(await readFile18(join26(runDirectory, "invocation.json"), "utf8"));
27021
+ const raw = JSON.parse(await readFile19(join27(runDirectory, "invocation.json"), "utf8"));
26913
27022
  return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
26914
27023
  } catch (error) {
26915
27024
  if (error.code === "ENOENT") return void 0;
@@ -27106,19 +27215,28 @@ async function dispatchPostAdmissionTurn(input) {
27106
27215
  if (hostTransition !== void 0) {
27107
27216
  turnRequest = { ...turnRequest, hostTransition };
27108
27217
  }
27109
- const dossierSection = await projectCaseDossierPointerSection({
27110
- ticketNumber: admitted.ticketNumber,
27111
- projectRoot: admitted.projectRoot,
27112
- home: env.home
27113
- });
27114
- if (dossierSection !== void 0) {
27115
- turnRequest = {
27116
- ...turnRequest,
27117
- continuation: appendContinuationSection(
27118
- turnRequest.continuation,
27119
- dossierSection
27120
- )
27121
- };
27218
+ if (isStationChildOfficerDialogue(admitted.role, env)) {
27219
+ await deliverCaseDossierAsAttachment({
27220
+ ticketNumber: admitted.ticketNumber,
27221
+ projectRoot: admitted.projectRoot,
27222
+ home: env.home,
27223
+ runDirectory: admitted.runDirectory
27224
+ });
27225
+ } else {
27226
+ const dossierSection = await projectCaseDossierPointerSection({
27227
+ ticketNumber: admitted.ticketNumber,
27228
+ projectRoot: admitted.projectRoot,
27229
+ home: env.home
27230
+ });
27231
+ if (dossierSection !== void 0) {
27232
+ turnRequest = {
27233
+ ...turnRequest,
27234
+ continuation: appendContinuationSection(
27235
+ turnRequest.continuation,
27236
+ dossierSection
27237
+ )
27238
+ };
27239
+ }
27122
27240
  }
27123
27241
  await markRunRunning(
27124
27242
  admitted.runDirectory,
@@ -27148,8 +27266,8 @@ async function dispatchPostAdmissionTurn(input) {
27148
27266
  }
27149
27267
  let stderrLogWriteFailure;
27150
27268
  try {
27151
- await writeFile7(
27152
- join26(admitted.runDirectory, "stderr.log"),
27269
+ await writeFile8(
27270
+ join27(admitted.runDirectory, "stderr.log"),
27153
27271
  result2.stderr,
27154
27272
  "utf8"
27155
27273
  );
@@ -27338,25 +27456,17 @@ async function dispatchPostAdmissionTurn(input) {
27338
27456
  }
27339
27457
  }
27340
27458
  function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
27341
- const officerSourcePath = request.summons?.sourceRunPath;
27342
- const withReread = (body) => {
27343
- if (officerSourcePath === void 0 || admitted.role !== "notary" && admitted.role !== "inspector" && admitted.role !== "auditor") {
27344
- return body;
27345
- }
27346
- if (body.startsWith("\u8BF7\u91CD\u8BFB")) return body;
27347
- return `\u8BF7\u91CD\u8BFB
27348
- ${body}`;
27349
- };
27459
+ const officerDialogue = isStationChildOfficerDialogue(admitted.role, env);
27350
27460
  let prompt;
27351
27461
  if (request.message !== void 0) {
27352
27462
  if (summonsPrepared !== void 0) {
27353
- prompt = withReread(buildInstructionTransportPrompt({
27463
+ prompt = officerDialogue ? request.message : buildInstructionTransportPrompt({
27354
27464
  instruction: request.message,
27355
27465
  instructionEmpty: false,
27356
27466
  attachments: summonsPrepared.attachments
27357
- }));
27467
+ });
27358
27468
  } else if (request.summons !== void 0) {
27359
- prompt = withReread(request.message);
27469
+ prompt = request.message;
27360
27470
  } else {
27361
27471
  prompt = buildResumeContinuationPrompt({
27362
27472
  packageRoot: env.packageRoot,
@@ -27365,17 +27475,9 @@ ${body}`;
27365
27475
  });
27366
27476
  }
27367
27477
  } else if (summonsPrepared !== void 0) {
27368
- prompt = withReread(buildInstructionTransportPrompt(summonsPrepared));
27478
+ prompt = officerDialogue ? summonsPrepared.instructionEmpty ? "" : summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
27369
27479
  } else if (request.summons !== void 0) {
27370
- const path = request.summons.sourceRunPath;
27371
- if (path !== void 0 && (admitted.role === "notary" || admitted.role === "inspector" || admitted.role === "auditor")) {
27372
- prompt = `\u8BF7\u91CD\u8BFB
27373
- ${GATE_DOSSIER_POINTER_PREFIX}${path}`;
27374
- } else if (admitted.role === "notary" || admitted.role === "inspector" || admitted.role === "auditor") {
27375
- prompt = "\u8BF7\u91CD\u8BFB";
27376
- } else {
27377
- prompt = "";
27378
- }
27480
+ prompt = "";
27379
27481
  } else {
27380
27482
  prompt = buildResumeContinuationPrompt({
27381
27483
  packageRoot: env.packageRoot,
@@ -27412,7 +27514,7 @@ async function dispatchAfterWriterLease(input) {
27412
27514
  }
27413
27515
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
27414
27516
  const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve9(attachmentPath);
27415
- return pathContainedIn(join26(runDirectory, "attachments"), absolute);
27517
+ return pathContainedIn(join27(runDirectory, "attachments"), absolute);
27416
27518
  }
27417
27519
  async function prepareSummonsResumeMaterials(runDirectory, summons) {
27418
27520
  if (summons === void 0) return void 0;
@@ -27708,6 +27810,7 @@ var init_post_admission = __esm({
27708
27810
  init_activation_ledger_topology();
27709
27811
  init_engine_material();
27710
27812
  init_session_identity();
27813
+ init_host_contracts();
27711
27814
  init_case_dossier_delivery();
27712
27815
  init_host_transition_prior_native();
27713
27816
  init_public_run_credentials();
@@ -28069,7 +28172,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
28069
28172
  return { exitCode: 2 };
28070
28173
  }
28071
28174
  }
28072
- const resumeInstruction = env.reviewReask;
28175
+ const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
28073
28176
  const summons = {
28074
28177
  ...resumeInstruction === void 0 ? {
28075
28178
  instruction: parsed.instruction,
@@ -28135,7 +28238,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
28135
28238
  ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
28136
28239
  continuation: {
28137
28240
  kind: "initial",
28138
- prompt: buildInstructionTransportPrompt(
28241
+ // #879: gate first mint uses parent payload as content when present.
28242
+ prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(
28139
28243
  admitted,
28140
28244
  engineSessionMaterialFromOptions({
28141
28245
  ...pickEngineAxis(env),
@@ -28340,7 +28444,7 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
28340
28444
  throw error;
28341
28445
  }
28342
28446
  {
28343
- const resumeInstruction = env.reviewReask;
28447
+ const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
28344
28448
  const summons = {
28345
28449
  sourceRunPath: source.runDirectory,
28346
28450
  sourceRun: source,
@@ -28395,7 +28499,9 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
28395
28499
  ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
28396
28500
  continuation: {
28397
28501
  kind: "initial",
28398
- prompt: buildNotaryTransportPrompt(admitted, engineMaterial)
28502
+ // #879: gate path first mint carries parent payload as dialogue content;
28503
+ // external zero-prompt kickoff unchanged when no body/reask.
28504
+ prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildNotaryTransportPrompt(admitted, engineMaterial)
28399
28505
  }
28400
28506
  });
28401
28507
  return await runPostAdmissionOneShot({
@@ -28483,12 +28589,20 @@ __export(inspector_run_exports, {
28483
28589
  runPublicInspector: () => runPublicInspector,
28484
28590
  runPublicInspectorResume: () => runPublicInspectorResume
28485
28591
  });
28592
+ function inspectorParentRunPath(admitted) {
28593
+ if (typeof admitted.sourceRunPath === "string" && admitted.sourceRunPath.trim() !== "") {
28594
+ return admitted.sourceRunPath;
28595
+ }
28596
+ return parentRunPathFromGatePointerInstruction(admitted.instruction);
28597
+ }
28486
28598
  function buildInspectorTurnRequest(admitted, options) {
28599
+ const sourceRun = inspectorParentRunPath(admitted);
28487
28600
  return projectRoleTurnRequest(
28488
28601
  admitted,
28489
28602
  {
28490
28603
  activation: {
28491
- role: "inspector"
28604
+ role: "inspector",
28605
+ ...sourceRun === void 0 ? {} : { sourceRun }
28492
28606
  }
28493
28607
  },
28494
28608
  options
@@ -28508,7 +28622,7 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
28508
28622
  const projectRoot = parsed.project ?? env.cwd;
28509
28623
  const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction);
28510
28624
  if (parentRunPath !== void 0) {
28511
- const resumeInstruction = env.reviewReask;
28625
+ const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
28512
28626
  const summons = {
28513
28627
  sourceRunPath: parentRunPath,
28514
28628
  ...resumeInstruction === void 0 ? {
@@ -28553,6 +28667,10 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
28553
28667
  throw error;
28554
28668
  }
28555
28669
  await markRunAdmitted(admitted, env.principalAuthority);
28670
+ if (parentRunPath !== void 0) {
28671
+ await persistAdmittedSourceRunPath(admitted, parentRunPath);
28672
+ admitted = { ...admitted, sourceRunPath: parentRunPath };
28673
+ }
28556
28674
  const engineMaterial = engineSessionMaterialFromOptions({
28557
28675
  ...pickEngineAxis(env),
28558
28676
  packageRoot: env.packageRoot
@@ -28567,7 +28685,8 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
28567
28685
  ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
28568
28686
  continuation: {
28569
28687
  kind: "initial",
28570
- prompt: buildInspectorTransportPrompt(admitted, engineMaterial)
28688
+ // #879: gate first mint uses parent payload as content; binding stays typed activation.
28689
+ prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInspectorTransportPrompt(admitted, engineMaterial)
28571
28690
  }
28572
28691
  });
28573
28692
  return await runPostAdmissionOneShot({
@@ -29017,7 +29136,7 @@ __export(public_role_summons_exports, {
29017
29136
  summonPublicRole: () => summonPublicRole
29018
29137
  });
29019
29138
  import { existsSync as existsSync9 } from "node:fs";
29020
- import { join as join27 } from "node:path";
29139
+ import { join as join28 } from "node:path";
29021
29140
  function createCapturingIo() {
29022
29141
  const chunks = [];
29023
29142
  return {
@@ -29040,7 +29159,7 @@ function parentDir(path) {
29040
29159
  function walkPackageRoot(start) {
29041
29160
  let dir = start;
29042
29161
  for (let i = 0; i < 12; i += 1) {
29043
- if (existsSync9(join27(dir, "package.json")) && existsSync9(join27(dir, "souls"))) {
29162
+ if (existsSync9(join28(dir, "package.json")) && existsSync9(join28(dir, "souls"))) {
29044
29163
  return dir;
29045
29164
  }
29046
29165
  const parent = parentDir(dir);
@@ -29134,7 +29253,7 @@ async function createSummonEnv(options) {
29134
29253
  async function summonPublicRole(options) {
29135
29254
  const packageRoot2 = resolveSummonsPackageRoot(options.packageRoot);
29136
29255
  const home = await resolveSummonHome(options);
29137
- const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join27(home, ".pi", "agent");
29256
+ const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join28(home, ".pi", "agent");
29138
29257
  const {
29139
29258
  loadCredentialProviders: loadCredentialProviders2,
29140
29259
  loadPublicCliConfig: loadPublicCliConfig2,
@@ -29175,6 +29294,8 @@ async function summonPublicRole(options) {
29175
29294
  ...options.signal === void 0 ? {} : { signal: options.signal },
29176
29295
  // #753: reask rides the existing notary same-ticket resume summons.instruction.
29177
29296
  ...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
29297
+ // #879: verbatim submission body on officer dialogue content channel.
29298
+ ...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
29178
29299
  ...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
29179
29300
  // createRunId is the only remaining env overlay — host is seat-selected above.
29180
29301
  ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
@@ -29282,6 +29403,11 @@ async function summonGateOfficer(options) {
29282
29403
  const { homeFromRunDirectory: homeFromRunDirectory3 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
29283
29404
  home = homeFromRunDirectory3(options.sourceRunDirectory);
29284
29405
  }
29406
+ let gateReviewInstruction;
29407
+ if (options.reask === void 0 && options.submission !== void 0) {
29408
+ const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
29409
+ gateReviewInstruction = readableGateItem2(options.submission);
29410
+ }
29285
29411
  const common = {
29286
29412
  cwd: options.cwd,
29287
29413
  ...home === void 0 ? {} : { home },
@@ -29289,6 +29415,7 @@ async function summonGateOfficer(options) {
29289
29415
  ...options.io === void 0 ? {} : { io: options.io },
29290
29416
  ...options.signal === void 0 ? {} : { signal: options.signal },
29291
29417
  ...options.reask === void 0 ? {} : { reviewReask: options.reask },
29418
+ ...gateReviewInstruction === void 0 ? {} : { gateReviewInstruction },
29292
29419
  ...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
29293
29420
  ...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
29294
29421
  ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
@@ -30276,16 +30403,16 @@ var init_analyst_book_key = __esm({
30276
30403
 
30277
30404
  // src/atomic-write.ts
30278
30405
  import { randomUUID as randomUUID6 } from "node:crypto";
30279
- import { rename as rename2, rm, writeFile as writeFile8 } from "node:fs/promises";
30280
- import { dirname as dirname14, join as join28 } from "node:path";
30406
+ import { rename as rename2, rm as rm2, writeFile as writeFile9 } from "node:fs/promises";
30407
+ import { dirname as dirname14, join as join29 } from "node:path";
30281
30408
  async function writeFileAtomically(destination, contents) {
30282
30409
  const parent = dirname14(destination);
30283
- const temporary = join28(parent, `.atomic-write-${randomUUID6()}.tmp`);
30410
+ const temporary = join29(parent, `.atomic-write-${randomUUID6()}.tmp`);
30284
30411
  try {
30285
- await writeFile8(temporary, contents);
30412
+ await writeFile9(temporary, contents);
30286
30413
  await rename2(temporary, destination);
30287
30414
  } catch (error) {
30288
- await rm(temporary, { force: true }).catch(() => void 0);
30415
+ await rm2(temporary, { force: true }).catch(() => void 0);
30289
30416
  throw error;
30290
30417
  }
30291
30418
  }
@@ -30296,8 +30423,8 @@ var init_atomic_write = __esm({
30296
30423
  });
30297
30424
 
30298
30425
  // src/analyst-index.ts
30299
- import { open as open3, readFile as readFile19, unlink as unlink4 } from "node:fs/promises";
30300
- import { dirname as dirname15, join as join29 } from "node:path";
30426
+ import { open as open3, readFile as readFile20, unlink as unlink4 } from "node:fs/promises";
30427
+ import { dirname as dirname15, join as join30 } from "node:path";
30301
30428
  function sleep(ms) {
30302
30429
  return new Promise((resolve11) => {
30303
30430
  setTimeout(resolve11, ms);
@@ -30306,7 +30433,7 @@ function sleep(ms) {
30306
30433
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
30307
30434
  const indexPath = analystLibraryIndexPath(ledgerHome);
30308
30435
  ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
30309
- const lockPath = join29(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
30436
+ const lockPath = join30(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
30310
30437
  assertLedgerFileInsideHome(lockPath, ledgerHome);
30311
30438
  const startedAt = Date.now();
30312
30439
  while (true) {
@@ -30333,7 +30460,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
30333
30460
  }
30334
30461
  }
30335
30462
  function analystLibraryIndexPath(ledgerHome) {
30336
- return join29(ledgerHome, "analyst", "library-index.json");
30463
+ return join30(ledgerHome, "analyst", "library-index.json");
30337
30464
  }
30338
30465
  function rowFromIssueMetricsPage(page) {
30339
30466
  return {
@@ -30424,7 +30551,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
30424
30551
  const path = analystLibraryIndexPath(ledgerHome);
30425
30552
  let raw;
30426
30553
  try {
30427
- raw = await readFile19(path, "utf8");
30554
+ raw = await readFile20(path, "utf8");
30428
30555
  } catch (error) {
30429
30556
  if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
30430
30557
  return void 0;
@@ -30628,8 +30755,8 @@ var init_analyst_cohort = __esm({
30628
30755
  });
30629
30756
 
30630
30757
  // src/analyst-ledger.ts
30631
- import { readdir as readdir7, readFile as readFile20 } from "node:fs/promises";
30632
- import { join as join30 } from "node:path";
30758
+ import { readdir as readdir7, readFile as readFile21 } from "node:fs/promises";
30759
+ import { join as join31 } from "node:path";
30633
30760
  function isMissingPathError5(error) {
30634
30761
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
30635
30762
  }
@@ -30642,7 +30769,7 @@ function isRecord10(value) {
30642
30769
  async function readExistingRunLifecycleState(runDirectory) {
30643
30770
  try {
30644
30771
  const raw = JSON.parse(
30645
- await readFile20(join30(runDirectory, "run-state.json"), "utf8")
30772
+ await readFile21(join31(runDirectory, "run-state.json"), "utf8")
30646
30773
  );
30647
30774
  if (!isRecord10(raw) || typeof raw.state !== "string") return void 0;
30648
30775
  return raw.state;
@@ -30674,7 +30801,7 @@ async function listLedgerBookNames(booksRoot) {
30674
30801
  async function readInvocationScopeFields(runDirectory) {
30675
30802
  let raw;
30676
30803
  try {
30677
- raw = await readFile20(join30(runDirectory, "invocation.json"), "utf8");
30804
+ raw = await readFile21(join31(runDirectory, "invocation.json"), "utf8");
30678
30805
  } catch (error) {
30679
30806
  if (isMissingPathError5(error)) return void 0;
30680
30807
  throw error;
@@ -30706,7 +30833,7 @@ function decideIssueScope(input) {
30706
30833
  }
30707
30834
  async function resolveSessionFile(runDirectory) {
30708
30835
  try {
30709
- const raw = await readFile20(join30(runDirectory, "invocation.json"), "utf8");
30836
+ const raw = await readFile21(join31(runDirectory, "invocation.json"), "utf8");
30710
30837
  const parsed = JSON.parse(raw);
30711
30838
  if (isRecord10(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
30712
30839
  return parsed.sessionFile;
@@ -30714,7 +30841,7 @@ async function resolveSessionFile(runDirectory) {
30714
30841
  } catch (error) {
30715
30842
  if (!isMissingPathError5(error)) throw error;
30716
30843
  }
30717
- return join30(runDirectory, "session", "session.jsonl");
30844
+ return join31(runDirectory, "session", "session.jsonl");
30718
30845
  }
30719
30846
  function attributeSessionRowsForRun(input) {
30720
30847
  if (pathContainedIn(input.runDirectory, input.sessionFile)) {
@@ -30886,9 +31013,9 @@ async function classifyScopedRun(input) {
30886
31013
  }
30887
31014
  let gateCycles;
30888
31015
  try {
30889
- const parentSessionFile = join30(input.runDirectory, "session", "session.jsonl");
31016
+ const parentSessionFile = join31(input.runDirectory, "session", "session.jsonl");
30890
31017
  gateCycles = await readAnalystGateCyclesFromAuditorRoles(
30891
- join30(input.runDirectory, "session", "auditor-roles"),
31018
+ join31(input.runDirectory, "session", "auditor-roles"),
30892
31019
  { parentSessionFile }
30893
31020
  );
30894
31021
  } catch (error) {
@@ -30921,7 +31048,7 @@ async function classifyScopedRun(input) {
30921
31048
  async function scanAnalystIssueRuns(input) {
30922
31049
  const ledgerHome = resolveActivationLedgerHome(input.home);
30923
31050
  const scopeTicketNumber = input.ticketNumber;
30924
- const booksRoot = join30(ledgerHome, "books");
31051
+ const booksRoot = join31(ledgerHome, "books");
30925
31052
  let wholeBook = false;
30926
31053
  let scopeRootIdentity;
30927
31054
  let bookNames;
@@ -30953,7 +31080,7 @@ async function scanAnalystIssueRuns(input) {
30953
31080
  const unreadable = [];
30954
31081
  const scopeConflicts = [];
30955
31082
  for (const book of bookNames) {
30956
- const runsDir = join30(booksRoot, book, "runs");
31083
+ const runsDir = join31(booksRoot, book, "runs");
30957
31084
  let runNames;
30958
31085
  try {
30959
31086
  const entries = await readdir7(runsDir, { withFileTypes: true });
@@ -30965,7 +31092,7 @@ async function scanAnalystIssueRuns(input) {
30965
31092
  for (const runName of runNames) {
30966
31093
  const parsed = parseRunDirectoryName2(runName);
30967
31094
  if (parsed === void 0) continue;
30968
- const runDirectory = join30(runsDir, runName);
31095
+ const runDirectory = join31(runsDir, runName);
30969
31096
  let scopeFields;
30970
31097
  try {
30971
31098
  scopeFields = await readInvocationScopeFields(runDirectory);
@@ -31819,7 +31946,7 @@ var init_analyst_metric_family = __esm({
31819
31946
 
31820
31947
  // src/analyst-page.ts
31821
31948
  import { createHash as createHash5 } from "node:crypto";
31822
- import { dirname as dirname16, join as join31 } from "node:path";
31949
+ import { dirname as dirname16, join as join32 } from "node:path";
31823
31950
  function analystIssuePageKey(address) {
31824
31951
  const parts = ["book", address.bookKey];
31825
31952
  if (address.issueNumber !== void 0) {
@@ -31830,7 +31957,7 @@ function analystIssuePageKey(address) {
31830
31957
  return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
31831
31958
  }
31832
31959
  function analystIssuePagePath(ledgerHome, address) {
31833
- return join31(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
31960
+ return join32(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
31834
31961
  }
31835
31962
  function analystIssuePageAddressFromPage(page) {
31836
31963
  return {
@@ -31966,7 +32093,7 @@ var init_analyst_page = __esm({
31966
32093
  });
31967
32094
 
31968
32095
  // src/analyst-entry.ts
31969
- import { readFile as readFile21 } from "node:fs/promises";
32096
+ import { readFile as readFile22 } from "node:fs/promises";
31970
32097
  function isMissingPathError6(error) {
31971
32098
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
31972
32099
  }
@@ -31996,7 +32123,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
31996
32123
  ...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
31997
32124
  });
31998
32125
  try {
31999
- const raw = await readFile21(pagePath, "utf8");
32126
+ const raw = await readFile22(pagePath, "utf8");
32000
32127
  const page = JSON.parse(raw);
32001
32128
  if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
32002
32129
  return { mode: "issue", page, pagePath };
@@ -32091,7 +32218,7 @@ async function runAnalystModelGroupsMode(input, home) {
32091
32218
  scopeRootIdentity: projectRoot
32092
32219
  });
32093
32220
  try {
32094
- const raw = await readFile21(pagePath, "utf8");
32221
+ const raw = await readFile22(pagePath, "utf8");
32095
32222
  JSON.parse(raw);
32096
32223
  } catch (error) {
32097
32224
  if (!isMissingPathError6(error)) {
@@ -32190,7 +32317,7 @@ var init_analyst_entry = __esm({
32190
32317
  });
32191
32318
 
32192
32319
  // src/public-cli/analyst-run.ts
32193
- import { readFile as readFile22 } from "node:fs/promises";
32320
+ import { readFile as readFile23 } from "node:fs/promises";
32194
32321
  import { isAbsolute as isAbsolute10, resolve as resolve10 } from "node:path";
32195
32322
  function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
32196
32323
  try {
@@ -32243,7 +32370,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
32243
32370
  const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve10(sourcePath);
32244
32371
  let bytes;
32245
32372
  try {
32246
- bytes = await readFile22(absolute);
32373
+ bytes = await readFile23(absolute);
32247
32374
  } catch (error) {
32248
32375
  throw new CliUsageError(
32249
32376
  `analyst sweep attachment is not a readable regular file: ${sourcePath}`,
@@ -32363,7 +32490,7 @@ __export(cli_exports, {
32363
32490
  runAkRole: () => runAkRole
32364
32491
  });
32365
32492
  import { realpath as realpath6 } from "node:fs/promises";
32366
- import { join as join32 } from "node:path";
32493
+ import { join as join33 } from "node:path";
32367
32494
  function takePublicGlobalFlag(argv, index, options) {
32368
32495
  const tokens = argv.slice(index);
32369
32496
  const taken = options.takeDashed(tokens);
@@ -32460,7 +32587,7 @@ function resolveHome(env) {
32460
32587
  return env.home ?? packageMachineHome();
32461
32588
  }
32462
32589
  function resolveAgentDir(env, home) {
32463
- return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join32(home, ".pi", "agent");
32590
+ return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join33(home, ".pi", "agent");
32464
32591
  }
32465
32592
  function parseThinking(value) {
32466
32593
  return value;
@@ -33475,7 +33602,7 @@ var init_cli = __esm({
33475
33602
 
33476
33603
  // src/public-cli/main.ts
33477
33604
  import { existsSync as existsSync10 } from "node:fs";
33478
- import { dirname as dirname17, join as join33 } from "node:path";
33605
+ import { dirname as dirname17, join as join34 } from "node:path";
33479
33606
  import { fileURLToPath as fileURLToPath2 } from "node:url";
33480
33607
 
33481
33608
  // src/public-cli/host-pi-runtime.ts
@@ -33564,8 +33691,8 @@ function linkPackage(packageRoot2, name, targetDir) {
33564
33691
  // src/public-cli/main.ts
33565
33692
  var here = dirname17(fileURLToPath2(import.meta.url));
33566
33693
  function resolvePackageRoot(binDir) {
33567
- const canonical = join33(binDir, "..", "..");
33568
- if (existsSync10(join33(canonical, "package.json"))) {
33694
+ const canonical = join34(binDir, "..", "..");
33695
+ if (existsSync10(join34(canonical, "package.json"))) {
33569
33696
  return canonical;
33570
33697
  }
33571
33698
  return binDir;