@akagilnc/pi-workflow-roles 0.1.5307 → 0.1.5312

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.
@@ -15711,6 +15711,10 @@ var init_institutional_resolution = __esm({
15711
15711
  });
15712
15712
 
15713
15713
  // src/host-descriptions.ts
15714
+ import { join as join7 } from "node:path";
15715
+ function resolveHostBinary(description, operatorHome) {
15716
+ return join7(operatorHome, ...description.binaryFromHome);
15717
+ }
15714
15718
  function lookupHostDescription(host) {
15715
15719
  return Object.hasOwn(HOST_DESCRIPTIONS, host) ? HOST_DESCRIPTIONS[host] : void 0;
15716
15720
  }
@@ -15839,7 +15843,7 @@ __export(config_exports, {
15839
15843
  validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
15840
15844
  });
15841
15845
  import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
15842
- import { dirname as dirname4, join as join7 } from "node:path";
15846
+ import { dirname as dirname4, join as join8 } from "node:path";
15843
15847
  function isGateOfficerSeat(value) {
15844
15848
  return packagedProvinceConfig(value);
15845
15849
  }
@@ -15847,7 +15851,7 @@ function publicCliConfigPath(home) {
15847
15851
  if (typeof home !== "string" || home.trim() === "") {
15848
15852
  throw new Error("home must be explicitly provided");
15849
15853
  }
15850
- return join7(home, ".ak-roles", "public-cli.json");
15854
+ return join8(home, ".ak-roles", "public-cli.json");
15851
15855
  }
15852
15856
  async function loadPublicCliConfig(home) {
15853
15857
  const path = publicCliConfigPath(home);
@@ -16310,7 +16314,7 @@ function credentialProvidersFromAuthData(data) {
16310
16314
  }
16311
16315
  async function loadCredentialProviders(agentDir) {
16312
16316
  try {
16313
- const raw = await readFile2(join7(agentDir, "auth.json"), "utf8");
16317
+ const raw = await readFile2(join8(agentDir, "auth.json"), "utf8");
16314
16318
  return credentialProvidersFromAuthData(JSON.parse(raw));
16315
16319
  } catch (error) {
16316
16320
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -16348,15 +16352,15 @@ __export(host_providers_exports, {
16348
16352
  renderHostProvidersTable: () => renderHostProvidersTable
16349
16353
  });
16350
16354
  import { readFileSync } from "node:fs";
16351
- import { join as join8 } from "node:path";
16355
+ import { join as join9 } from "node:path";
16352
16356
  function hostProvidersPath(home) {
16353
16357
  if (typeof home !== "string" || home.trim() === "") {
16354
16358
  throw new Error("home must be explicitly provided");
16355
16359
  }
16356
- return join8(home, ".ak-roles", "host-providers.json");
16360
+ return join9(home, ".ak-roles", "host-providers.json");
16357
16361
  }
16358
16362
  function hermesProviderModelsCachePath(home) {
16359
- return join8(home, ".hermes", "provider_models_cache.json");
16363
+ return join9(home, ".hermes", "provider_models_cache.json");
16360
16364
  }
16361
16365
  function parseHostProvidersTable(value) {
16362
16366
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
@@ -16535,16 +16539,16 @@ var init_cli_errors = __esm({
16535
16539
  // src/public-cli/machine-method-skills.ts
16536
16540
  import { accessSync, constants, statSync as statSync2 } from "node:fs";
16537
16541
  import { lstat, mkdir as mkdir2, symlink } from "node:fs/promises";
16538
- import { join as join9 } from "node:path";
16542
+ import { join as join10 } from "node:path";
16539
16543
  import { spawnSync } from "node:child_process";
16540
16544
  function skillRoot(home) {
16541
- return join9(home, ".agents/skills");
16545
+ return join10(home, ".agents/skills");
16542
16546
  }
16543
16547
  function installedMethodSkillPath(home, name) {
16544
16548
  return installedSkillPath(skillRoot(home), name);
16545
16549
  }
16546
16550
  function installedSkillPath(root, name) {
16547
- const path = join9(root, name, "SKILL.md");
16551
+ const path = join10(root, name, "SKILL.md");
16548
16552
  try {
16549
16553
  if (!statSync2(path).isFile()) return void 0;
16550
16554
  accessSync(path, constants.R_OK);
@@ -16557,9 +16561,9 @@ function installedSkillPath(root, name) {
16557
16561
  }
16558
16562
  function linkedSkillRoot(home, host) {
16559
16563
  if (host === "claude" || host === "claude-code") {
16560
- return join9(process.env.CLAUDE_CONFIG_DIR?.trim() || join9(home, ".claude"), "skills");
16564
+ return join10(process.env.CLAUDE_CONFIG_DIR?.trim() || join10(home, ".claude"), "skills");
16561
16565
  }
16562
- if (host === "hermes") return join9(home, ".hermes/skills");
16566
+ if (host === "hermes") return join10(home, ".hermes/skills");
16563
16567
  return void 0;
16564
16568
  }
16565
16569
  async function occupied(path) {
@@ -16616,7 +16620,7 @@ async function runMachineSkillSetup(home, stdout) {
16616
16620
  const missingBySource = /* @__PURE__ */ new Map();
16617
16621
  let unsourced = false;
16618
16622
  for (const name of packagedMethodSkillNames()) {
16619
- const path = join9(canonical, name);
16623
+ const path = join10(canonical, name);
16620
16624
  if (await occupied(path)) {
16621
16625
  warnOccupied(path, stdout);
16622
16626
  continue;
@@ -16638,17 +16642,17 @@ async function runMachineSkillSetup(home, stdout) {
16638
16642
  if (unsourced) return 1;
16639
16643
  for (const host of ["claude-code", "hermes"]) {
16640
16644
  const root = linkedSkillRoot(home, host);
16641
- const binaryFromHome = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude.binaryFromHome : HOST_DESCRIPTIONS.hermes.binaryFromHome;
16645
+ const description = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude : HOST_DESCRIPTIONS.hermes;
16642
16646
  try {
16643
- accessSync(join9(home, ...binaryFromHome), constants.X_OK);
16647
+ accessSync(resolveHostBinary(description, home), constants.X_OK);
16644
16648
  } catch (error) {
16645
16649
  if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
16646
16650
  throw error;
16647
16651
  }
16648
16652
  for (const name of packagedMethodSkillNames()) {
16649
- const target = join9(canonical, name);
16653
+ const target = join10(canonical, name);
16650
16654
  if (installedMethodSkillPath(home, name) === void 0) continue;
16651
- const link = join9(root, name);
16655
+ const link = join10(root, name);
16652
16656
  if (await occupied(link)) {
16653
16657
  warnOccupied(link, stdout);
16654
16658
  continue;
@@ -16678,9 +16682,9 @@ var init_machine_method_skills = __esm({
16678
16682
 
16679
16683
  // src/typed-provider-http.ts
16680
16684
  import { readFile as readFile3, unlink, writeFile as writeFile2 } from "node:fs/promises";
16681
- import { join as join10 } from "node:path";
16685
+ import { join as join11 } from "node:path";
16682
16686
  function typedProviderHttpPath(runDirectory) {
16683
- return join10(runDirectory, TYPED_HTTP_FILE);
16687
+ return join11(runDirectory, TYPED_HTTP_FILE);
16684
16688
  }
16685
16689
  async function clearTypedProviderHttpObservation(runDirectory) {
16686
16690
  try {
@@ -16818,7 +16822,7 @@ var init_collector_config = __esm({
16818
16822
  });
16819
16823
 
16820
16824
  // src/auditor-dossier-tool.ts
16821
- import { dirname as dirname5, join as join11, resolve as resolve3 } from "node:path";
16825
+ import { dirname as dirname5, join as join12, resolve as resolve3 } from "node:path";
16822
16826
  function auditorRunDirectory(context) {
16823
16827
  const sessionFile = context.sessionManager?.getSessionFile?.();
16824
16828
  if (sessionFile === void 0) return void 0;
@@ -16901,7 +16905,7 @@ __export(run_terminal_artifacts_exports, {
16901
16905
  runIdFromRunDirectory: () => runIdFromRunDirectory
16902
16906
  });
16903
16907
  import { readdir as readdir2, readFile as readFile5 } from "node:fs/promises";
16904
- import { basename as basename3, dirname as dirname6, join as join12 } from "node:path";
16908
+ import { basename as basename3, dirname as dirname6, join as join13 } from "node:path";
16905
16909
  function isMissingPathError2(error) {
16906
16910
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
16907
16911
  }
@@ -16976,7 +16980,7 @@ async function listUniqueErrorFallbackPaths(directories) {
16976
16980
  }
16977
16981
  for (const name of names.sort((a, b) => a.localeCompare(b))) {
16978
16982
  if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
16979
- found.push(join12(dir, name));
16983
+ found.push(join13(dir, name));
16980
16984
  }
16981
16985
  }
16982
16986
  return found;
@@ -17022,11 +17026,11 @@ async function readRunTerminalArtifact(runDirectory) {
17022
17026
  unreadable.push(read);
17023
17027
  };
17024
17028
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
17025
- consider(await readTerminalArtifactAtPath(join12(artifactsDir, file), file));
17029
+ consider(await readTerminalArtifactAtPath(join13(artifactsDir, file), file));
17026
17030
  }
17027
17031
  for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
17028
17032
  consider(
17029
- await readTerminalArtifactAtPath(join12(runDirectory, relative3), "error.json")
17033
+ await readTerminalArtifactAtPath(join13(runDirectory, relative3), "error.json")
17030
17034
  );
17031
17035
  }
17032
17036
  for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
@@ -17368,7 +17372,7 @@ __export(session_assistant_usage_exports, {
17368
17372
  sessionFileFromPublicSummon: () => sessionFileFromPublicSummon,
17369
17373
  usageFromPublicSummon: () => usageFromPublicSummon
17370
17374
  });
17371
- import { join as join13 } from "node:path";
17375
+ import { join as join14 } from "node:path";
17372
17376
  async function readAssistantUsageFromSessionFile(sessionFile) {
17373
17377
  const { readFile: readFile22 } = await import("node:fs/promises");
17374
17378
  let text;
@@ -17438,7 +17442,7 @@ async function readAssistantUsageFromSessionFile(sessionFile) {
17438
17442
  }
17439
17443
  function sessionFileFromPublicSummon(summoned) {
17440
17444
  if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
17441
- return join13(summoned.runDirectory, "session", "session.jsonl");
17445
+ return join14(summoned.runDirectory, "session", "session.jsonl");
17442
17446
  }
17443
17447
  const fromArtifacts = summoned.terminal?.artifacts?.map((a) => a.path).find((p) => typeof p === "string" && p.endsWith("session.jsonl"));
17444
17448
  if (fromArtifacts !== void 0) return fromArtifacts;
@@ -17447,7 +17451,7 @@ function sessionFileFromPublicSummon(summoned) {
17447
17451
  const facts = outcome.decisiveFacts;
17448
17452
  const pointer = facts?.runPointer;
17449
17453
  if (typeof pointer === "string" && pointer.trim() !== "") {
17450
- return join13(pointer, "session", "session.jsonl");
17454
+ return join14(pointer, "session", "session.jsonl");
17451
17455
  }
17452
17456
  return void 0;
17453
17457
  }
@@ -17579,7 +17583,7 @@ var init_sitian_contracts = __esm({
17579
17583
  // src/sitian-appender.ts
17580
17584
  import { randomUUID } from "node:crypto";
17581
17585
  import { appendFileSync } from "node:fs";
17582
- import { dirname as dirname7, join as join14 } from "node:path";
17586
+ import { dirname as dirname7, join as join15 } from "node:path";
17583
17587
  function appendSitianRecordBlock(input, block) {
17584
17588
  if (block === "") return;
17585
17589
  try {
@@ -17601,8 +17605,8 @@ function resolveSitianVolumeCategory(kind) {
17601
17605
  return kind;
17602
17606
  }
17603
17607
  function ticketProvenanceUnderBookPaths(ledgerHome, bookKey, ticketId) {
17604
- const sessionDir = join14(activationBookDirectory(ledgerHome, bookKey), ticketId);
17605
- return { sessionDir, recordFile: join14(sessionDir, SITIAN_RECORDS_LEAF) };
17608
+ const sessionDir = join15(activationBookDirectory(ledgerHome, bookKey), ticketId);
17609
+ return { sessionDir, recordFile: join15(sessionDir, SITIAN_RECORDS_LEAF) };
17606
17610
  }
17607
17611
  function resolveSitianRecordPathInLedger(input, ledgerHome) {
17608
17612
  const category = resolveSitianVolumeCategory(input.kind);
@@ -17619,13 +17623,13 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
17619
17623
  recordFile = paths.recordFile;
17620
17624
  } else if (category === "ticket-provenance" && input.runDirectory !== void 0) {
17621
17625
  sessionDir = input.runDirectory;
17622
- recordFile = join14(sessionDir, SITIAN_RECORDS_LEAF);
17626
+ recordFile = join15(sessionDir, SITIAN_RECORDS_LEAF);
17623
17627
  } else {
17624
17628
  if (input.sessionParent === void 0 || input.sessionParent.length === 0 || !physicallyContainedIn(ledgerHome, input.sessionParent)) {
17625
17629
  throw new Error("Sitian record ownership requires a parent session inside the ledger home");
17626
17630
  }
17627
- sessionDir = join14(dirname7(input.sessionParent), category);
17628
- recordFile = join14(sessionDir, SITIAN_RECORDS_LEAF);
17631
+ sessionDir = join15(dirname7(input.sessionParent), category);
17632
+ recordFile = join15(sessionDir, SITIAN_RECORDS_LEAF);
17629
17633
  }
17630
17634
  if (!physicallyContainedIn(ledgerHome, sessionDir)) {
17631
17635
  throw new Error("Sitian record ownership requires a directory inside the ledger home");
@@ -17766,12 +17770,12 @@ __export(role_turn_host_exports, {
17766
17770
  import { execFile, spawn } from "node:child_process";
17767
17771
  import { constants as constants2 } from "node:fs";
17768
17772
  import { access, appendFile, readFile as readFile7, realpath } from "node:fs/promises";
17769
- import { delimiter as delimiter2, dirname as dirname8, isAbsolute as isAbsolute3, join as join15, resolve as resolve4 } from "node:path";
17773
+ import { delimiter as delimiter2, dirname as dirname8, isAbsolute as isAbsolute3, join as join16, resolve as resolve4 } from "node:path";
17770
17774
  import { platform } from "node:process";
17771
17775
  import { promisify } from "node:util";
17772
17776
  import { randomUUID as randomUUID2 } from "node:crypto";
17773
17777
  function resolveInternalRoleEntrypoint(packageRoot2) {
17774
- return join15(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
17778
+ return join16(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
17775
17779
  }
17776
17780
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
17777
17781
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -18644,7 +18648,7 @@ var init_session_dialogue = __esm({
18644
18648
 
18645
18649
  // src/ticket-provenance.ts
18646
18650
  import { readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
18647
- import { basename as basename4, dirname as dirname10, join as join16, resolve as resolve7 } from "node:path";
18651
+ import { basename as basename4, dirname as dirname10, join as join17, resolve as resolve7 } from "node:path";
18648
18652
  function ticketProvenanceSubject(ticketNumber) {
18649
18653
  if (!isSafePositiveTicketNumber(ticketNumber)) {
18650
18654
  throw new Error(
@@ -18664,7 +18668,7 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
18664
18668
  };
18665
18669
  }
18666
18670
  async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
18667
- const source = join16(runDirectory, "records.jsonl");
18671
+ const source = join17(runDirectory, "records.jsonl");
18668
18672
  let content;
18669
18673
  try {
18670
18674
  content = await readFile11(source, "utf8");
@@ -18713,7 +18717,7 @@ var init_uuidv7 = __esm({
18713
18717
  });
18714
18718
 
18715
18719
  // src/notary-source-run.ts
18716
- import { dirname as dirname11, isAbsolute as isAbsolute5, join as join17, resolve as resolve8, basename as basename5 } from "node:path";
18720
+ import { dirname as dirname11, isAbsolute as isAbsolute5, join as join18, resolve as resolve8, basename as basename5 } from "node:path";
18717
18721
  import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
18718
18722
  async function readRetainedIdentity(runDirectory) {
18719
18723
  try {
@@ -18770,11 +18774,11 @@ async function resolveNotarySourceRunLocator(options) {
18770
18774
  const ledgerHome = resolveActivationLedgerHome(options.home);
18771
18775
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
18772
18776
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
18773
- const bookRunsRoot = join17(bookDirectory, "runs");
18777
+ const bookRunsRoot = join18(bookDirectory, "runs");
18774
18778
  let candidate;
18775
18779
  const bare = parseRunDirectoryName(raw);
18776
18780
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
18777
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join17(bookRunsRoot, `${bare.runId}@${bare.role}`);
18781
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join18(bookRunsRoot, `${bare.runId}@${bare.role}`);
18778
18782
  } else {
18779
18783
  candidate = isAbsolute5(raw) ? raw : resolve8(options.projectRoot, raw);
18780
18784
  const identity2 = parseRunDirectoryName(basename5(candidate));
@@ -19890,7 +19894,7 @@ import {
19890
19894
  writeFile as writeFile3
19891
19895
  } from "node:fs/promises";
19892
19896
  import { tmpdir } from "node:os";
19893
- import { basename as basename6, dirname as dirname12, isAbsolute as isAbsolute6, join as join18, resolve as resolve9, sep as sep3 } from "node:path";
19897
+ import { basename as basename6, dirname as dirname12, isAbsolute as isAbsolute6, join as join19, resolve as resolve9, sep as sep3 } from "node:path";
19894
19898
  function issueAdmissionPlacement(authority, request) {
19895
19899
  const ledgerHome = resolveActivationLedgerHome(request.home);
19896
19900
  const bookKey = resolveBookKeyFromGit(request.cwd);
@@ -19944,14 +19948,14 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
19944
19948
  ...effectiveModelLedgerFields(effectiveModel)
19945
19949
  };
19946
19950
  await writeFile3(
19947
- join18(source.runDirectory, "invocation.json"),
19951
+ join19(source.runDirectory, "invocation.json"),
19948
19952
  `${JSON.stringify(identity, null, 2)}
19949
19953
  `,
19950
19954
  "utf8"
19951
19955
  );
19952
19956
  }
19953
19957
  async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
19954
- const ledgerPath = join18(runDirectory, "invocation.json");
19958
+ const ledgerPath = join19(runDirectory, "invocation.json");
19955
19959
  const current = JSON.parse(await readFile12(ledgerPath, "utf8"));
19956
19960
  const next = { ...current };
19957
19961
  if (model !== void 0) {
@@ -19984,7 +19988,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
19984
19988
  );
19985
19989
  }
19986
19990
  async function mergeInvocationIdentityPage(runDirectory, fields) {
19987
- const ledgerPath = join18(runDirectory, "invocation.json");
19991
+ const ledgerPath = join19(runDirectory, "invocation.json");
19988
19992
  const current = JSON.parse(await readFile12(ledgerPath, "utf8"));
19989
19993
  await writeFile3(
19990
19994
  ledgerPath,
@@ -20067,7 +20071,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
20067
20071
  const childRunIds = parentPage.childDiaristRunIds;
20068
20072
  for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
20069
20073
  if (typeof childRunId !== "string") continue;
20070
- const childDirectory = join18(dirname12(oldRunDirectory), `${childRunId}@diarist`);
20074
+ const childDirectory = join19(dirname12(oldRunDirectory), `${childRunId}@diarist`);
20071
20075
  if (!existsSync4(childDirectory)) continue;
20072
20076
  const childTarget = roleRunPlacement(ledgerHome, {
20073
20077
  bookKey: admitted.bookKey,
@@ -20124,7 +20128,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
20124
20128
  ticketNumber,
20125
20129
  "bindTicketNumberOnRunDirectory"
20126
20130
  );
20127
- const admittedPath = join18(runDirectory, "admitted-request.json");
20131
+ const admittedPath = join19(runDirectory, "admitted-request.json");
20128
20132
  const admitted = JSON.parse(await readFile12(admittedPath, "utf8"));
20129
20133
  if (admitted.ticketNumber === ticketNumber) return;
20130
20134
  await writeFile3(
@@ -20144,7 +20148,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
20144
20148
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
20145
20149
  const rolePackageRoot = packageRoot2;
20146
20150
  const raw = JSON.parse(
20147
- await readFile12(join18(rolePackageRoot, "package.json"), "utf8")
20151
+ await readFile12(join19(rolePackageRoot, "package.json"), "utf8")
20148
20152
  );
20149
20153
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
20150
20154
  throw new Error(
@@ -20432,13 +20436,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
20432
20436
  }
20433
20437
  async function withPreparedAttachments(attachmentPaths, use) {
20434
20438
  if (attachmentPaths.length === 0) return await use([]);
20435
- const stagingDirectory = await mkdtemp(join18(tmpdir(), "ak-role-attachments-"));
20439
+ const stagingDirectory = await mkdtemp(join19(tmpdir(), "ak-role-attachments-"));
20436
20440
  const prepared = [];
20437
20441
  let result;
20438
20442
  try {
20439
20443
  for (let index = 0; index < attachmentPaths.length; index += 1) {
20440
20444
  const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
20441
- const snapshotPath = join18(stagingDirectory, String(index).padStart(6, "0"));
20445
+ const snapshotPath = join19(stagingDirectory, String(index).padStart(6, "0"));
20442
20446
  await writeFile3(snapshotPath, bytes);
20443
20447
  prepared.push({ absolute, snapshotPath });
20444
20448
  }
@@ -20459,7 +20463,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
20459
20463
  return result;
20460
20464
  }
20461
20465
  async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
20462
- const frozenPath = join18(
20466
+ const frozenPath = join19(
20463
20467
  destinationDir,
20464
20468
  `${String(index).padStart(2, "0")}-${basename6(provenancePath)}`
20465
20469
  );
@@ -20502,14 +20506,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
20502
20506
  async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
20503
20507
  if (attachmentPaths.length === 0) return [];
20504
20508
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
20505
- const attachmentsDirectory = join18(runDirectory, "attachments", summonsKey);
20509
+ const attachmentsDirectory = join19(runDirectory, "attachments", summonsKey);
20506
20510
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20507
20511
  return freezeAttachments(attachmentPaths, attachmentsDirectory);
20508
20512
  }
20509
20513
  async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
20510
20514
  if (prepared.length === 0) return [];
20511
20515
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
20512
- const attachmentsDirectory = summonsKey === void 0 ? join18(runDirectory, "attachments") : join18(runDirectory, "attachments", summonsKey);
20516
+ const attachmentsDirectory = summonsKey === void 0 ? join19(runDirectory, "attachments") : join19(runDirectory, "attachments", summonsKey);
20513
20517
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20514
20518
  const attachments = [];
20515
20519
  for (let index = 0; index < prepared.length; index += 1) {
@@ -20586,7 +20590,7 @@ async function admitPublicRole(role, parsed, env, override) {
20586
20590
  attachmentPaths,
20587
20591
  ...project,
20588
20592
  placedFields: async (placed) => {
20589
- const taskPath = join18(placed.runDirectory, "task.md");
20593
+ const taskPath = join19(placed.runDirectory, "task.md");
20590
20594
  await writeFile3(taskPath, instruction, "utf8");
20591
20595
  return { phase, taskPath };
20592
20596
  }
@@ -20632,7 +20636,7 @@ async function admitPublicRole(role, parsed, env, override) {
20632
20636
  placedFields: async (placed) => {
20633
20637
  let prerequisitesPath;
20634
20638
  if (prerequisitesSource !== void 0) {
20635
- prerequisitesPath = join18(placed.runDirectory, "prerequisites.json");
20639
+ prerequisitesPath = join19(placed.runDirectory, "prerequisites.json");
20636
20640
  await writeFile3(
20637
20641
  prerequisitesPath,
20638
20642
  `${JSON.stringify(prerequisites, null, 2)}
@@ -20640,7 +20644,7 @@ async function admitPublicRole(role, parsed, env, override) {
20640
20644
  "utf8"
20641
20645
  );
20642
20646
  }
20643
- const packetPath = join18(placed.runDirectory, "fix-packet.md");
20647
+ const packetPath = join19(placed.runDirectory, "fix-packet.md");
20644
20648
  await writeFile3(packetPath, instruction, "utf8");
20645
20649
  return {
20646
20650
  phase,
@@ -20698,7 +20702,7 @@ async function admitPublicRole(role, parsed, env, override) {
20698
20702
  placedFields: async (placed) => {
20699
20703
  let requestManifestPath;
20700
20704
  if (manifestCanonicalJson !== void 0) {
20701
- requestManifestPath = join18(placed.runDirectory, "request-manifest.json");
20705
+ requestManifestPath = join19(placed.runDirectory, "request-manifest.json");
20702
20706
  await writeFile3(requestManifestPath, manifestCanonicalJson, "utf8");
20703
20707
  }
20704
20708
  return {
@@ -20888,7 +20892,7 @@ async function admitPublicRole(role, parsed, env, override) {
20888
20892
  resolutionScope: [...derived.resolutionScope],
20889
20893
  authorizedChecks: []
20890
20894
  });
20891
- const mergerInputPath = join18(placed.runDirectory, "merger-input.json");
20895
+ const mergerInputPath = join19(placed.runDirectory, "merger-input.json");
20892
20896
  await writeFile3(
20893
20897
  mergerInputPath,
20894
20898
  `${JSON.stringify(mergerInput, null, 2)}
@@ -20962,7 +20966,7 @@ function persistedAttachmentRefs(attachments) {
20962
20966
  }));
20963
20967
  }
20964
20968
  async function persistPlacedAdmission(admitted, placed, model) {
20965
- const admittedRequestPath = join18(placed.runDirectory, "admitted-request.json");
20969
+ const admittedRequestPath = join19(placed.runDirectory, "admitted-request.json");
20966
20970
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20967
20971
  sessionDirectory: placed.sessionDirectory,
20968
20972
  sessionFile: placed.sessionFile
@@ -21015,7 +21019,7 @@ async function admitStandardMaterialInvocation(role, options) {
21015
21019
  attachments: persistedAttachmentRefs(placed.attachments),
21016
21020
  ...placed.ticketFields
21017
21021
  };
21018
- const admittedRequestPath = defer ? join18(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
21022
+ const admittedRequestPath = defer ? join19(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
21019
21023
  return {
21020
21024
  role,
21021
21025
  runId: placed.runId,
@@ -21093,7 +21097,7 @@ async function materializeCountersignInvocation(admitted, options) {
21093
21097
  });
21094
21098
  const placement = placed;
21095
21099
  admitted.runDirectory = placement.runDirectory;
21096
- admitted.admittedRequestPath = join18(
21100
+ admitted.admittedRequestPath = join19(
21097
21101
  placement.runDirectory,
21098
21102
  "admitted-request.json"
21099
21103
  );
@@ -21189,7 +21193,7 @@ function parseDoctorIssueNumber(raw) {
21189
21193
  }
21190
21194
  async function resolveDoctorCaseRunsPath(options) {
21191
21195
  const ledgerHome = resolveActivationLedgerHome(options.home);
21192
- const defaultRuns = join18(
21196
+ const defaultRuns = join19(
21193
21197
  activationBookDirectory(ledgerHome, options.bookKey),
21194
21198
  String(options.issueNumber),
21195
21199
  "runs"
@@ -21510,15 +21514,15 @@ var init_invocation = __esm({
21510
21514
 
21511
21515
  // src/public-cli/load-production-acp-host.ts
21512
21516
  import { existsSync as existsSync5 } from "node:fs";
21513
- import { join as join19 } from "node:path";
21517
+ import { join as join20 } from "node:path";
21514
21518
  import { pathToFileURL } from "node:url";
21515
21519
  async function loadProductionAcpHostFactory(packageRoot2, host) {
21516
21520
  const description = lookupHostDescription(host);
21517
21521
  if (description === void 0) {
21518
21522
  throw new Error(`unregistered host: ${host}`);
21519
21523
  }
21520
- const built = join19(packageRoot2, "dist/acp-host/production-host.js");
21521
- const source = join19(packageRoot2, "src/acp-host/production-host.ts");
21524
+ const built = join20(packageRoot2, "dist/acp-host/production-host.js");
21525
+ const source = join20(packageRoot2, "src/acp-host/production-host.ts");
21522
21526
  const target = existsSync5(built) ? built : source;
21523
21527
  const href = pathToFileURL(target).href;
21524
21528
  const mod = await import(href);
@@ -21534,15 +21538,15 @@ var init_load_production_acp_host = __esm({
21534
21538
 
21535
21539
  // src/public-cli/load-production-headless-host.ts
21536
21540
  import { existsSync as existsSync6 } from "node:fs";
21537
- import { join as join20 } from "node:path";
21541
+ import { join as join21 } from "node:path";
21538
21542
  import { pathToFileURL as pathToFileURL2 } from "node:url";
21539
21543
  async function loadProductionHeadlessHostFactory(packageRoot2, host) {
21540
21544
  const description = lookupHeadlessHostDescription(host);
21541
21545
  if (description === void 0) {
21542
21546
  throw new Error(`unregistered headless host: ${host}`);
21543
21547
  }
21544
- const built = join20(packageRoot2, "dist/headless-host/production-host.js");
21545
- const source = join20(packageRoot2, "src/headless-host/production-host.ts");
21548
+ const built = join21(packageRoot2, "dist/headless-host/production-host.js");
21549
+ const source = join21(packageRoot2, "src/headless-host/production-host.ts");
21546
21550
  const target = existsSync6(built) ? built : source;
21547
21551
  const href = pathToFileURL2(target).href;
21548
21552
  const mod = await import(href);
@@ -21669,7 +21673,7 @@ var init_role_turn_host_resolution = __esm({
21669
21673
 
21670
21674
  // src/analyst-gate-cycles-read.ts
21671
21675
  import { readdir as readdir4 } from "node:fs/promises";
21672
- import { join as join21 } from "node:path";
21676
+ import { join as join22 } from "node:path";
21673
21677
  function isRecord4(value) {
21674
21678
  return typeof value === "object" && value !== null && !Array.isArray(value);
21675
21679
  }
@@ -21920,7 +21924,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
21920
21924
  throw error;
21921
21925
  }
21922
21926
  for (const name of names) {
21923
- const path = join21(directory, name);
21927
+ const path = join22(directory, name);
21924
21928
  const fromPointer = name.endsWith(".pointer.json");
21925
21929
  const pointer = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : void 0;
21926
21930
  const sessionPath = pointer?.sessionFile ?? path;
@@ -21962,14 +21966,14 @@ var init_analyst_gate_cycles_read = __esm({
21962
21966
  });
21963
21967
 
21964
21968
  // src/submission-ledger.ts
21965
- import { join as join22 } from "node:path";
21969
+ import { join as join23 } from "node:path";
21966
21970
  async function submissionRecordFile(cwd, runId, scope) {
21967
21971
  const ledgerHome = resolveActivationLedgerHome(scope.home);
21968
21972
  let sessionParent = scope.sessionParent;
21969
21973
  if (sessionParent === void 0) {
21970
21974
  const discoveredRun = await findRunDirectoryById(scope.home, runId);
21971
21975
  if (discoveredRun === void 0) return void 0;
21972
- sessionParent = join22(discoveredRun, "session", "session.jsonl");
21976
+ sessionParent = join23(discoveredRun, "session", "session.jsonl");
21973
21977
  }
21974
21978
  return resolveSitianRecordPathInLedger({
21975
21979
  level: "event",
@@ -22166,12 +22170,12 @@ var init_audit_escalation = __esm({
22166
22170
  // src/session-opening-materials.ts
22167
22171
  import { existsSync as existsSync7 } from "node:fs";
22168
22172
  import { readFile as readFile13 } from "node:fs/promises";
22169
- import { dirname as dirname13, join as join23 } from "node:path";
22173
+ import { dirname as dirname13, join as join24 } from "node:path";
22170
22174
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
22171
22175
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
22172
22176
  let dir = dirname13(fileURLToPath(moduleUrl));
22173
22177
  for (let i = 0; i < 8; i += 1) {
22174
- if (existsSync7(join23(dir, "package.json")) && existsSync7(join23(dir, "souls"))) {
22178
+ if (existsSync7(join24(dir, "package.json")) && existsSync7(join24(dir, "souls"))) {
22175
22179
  return dir;
22176
22180
  }
22177
22181
  const parent = dirname13(dir);
@@ -22224,7 +22228,7 @@ __export(auditor_soul_exports, {
22224
22228
  resolveAuditorSubject: () => resolveAuditorSubject
22225
22229
  });
22226
22230
  import { readFile as readFile14 } from "node:fs/promises";
22227
- import { basename as basename7, join as join24 } from "node:path";
22231
+ import { basename as basename7, join as join25 } from "node:path";
22228
22232
  function auditorSoulRelativePath(role) {
22229
22233
  return `souls/${role}-auditor.md`;
22230
22234
  }
@@ -22266,7 +22270,7 @@ function subjectFromSourceDirectory(sourceRunDirectory) {
22266
22270
  async function readAuditorResumeBinding(runDirectory) {
22267
22271
  let raw;
22268
22272
  try {
22269
- raw = JSON.parse(await readFile14(join24(runDirectory, "admitted-request.json"), "utf8"));
22273
+ raw = JSON.parse(await readFile14(join25(runDirectory, "admitted-request.json"), "utf8"));
22270
22274
  } catch (error) {
22271
22275
  if (error.code === "ENOENT") return void 0;
22272
22276
  throw error;
@@ -22379,7 +22383,7 @@ var init_serialize_thrown_value = __esm({
22379
22383
  // src/engine-detour-usage.ts
22380
22384
  import { randomUUID as randomUUID3 } from "node:crypto";
22381
22385
  import { readFileSync as readFileSync2 } from "node:fs";
22382
- import { dirname as dirname14, join as join25 } from "node:path";
22386
+ import { dirname as dirname14, join as join26 } from "node:path";
22383
22387
  function isRecord5(value) {
22384
22388
  return typeof value === "object" && value !== null && !Array.isArray(value);
22385
22389
  }
@@ -22464,7 +22468,7 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
22464
22468
  function readInvocationRecord(runDirectory) {
22465
22469
  try {
22466
22470
  const raw = JSON.parse(
22467
- readFileSync2(join25(runDirectory, "invocation.json"), "utf8")
22471
+ readFileSync2(join26(runDirectory, "invocation.json"), "utf8")
22468
22472
  );
22469
22473
  return isRecord5(raw) ? raw : void 0;
22470
22474
  } catch (error) {
@@ -22492,7 +22496,7 @@ function runDirectoryFromSessionDirectory(sessionDirectory) {
22492
22496
  return dirname14(sessionDirectory);
22493
22497
  }
22494
22498
  function sessionFileFromSessionDirectory(sessionDirectory) {
22495
- return join25(sessionDirectory, "session.jsonl");
22499
+ return join26(sessionDirectory, "session.jsonl");
22496
22500
  }
22497
22501
  function mintEngineDetourInvocationScope(input) {
22498
22502
  const engine = input.effectiveEngine?.trim();
@@ -22799,14 +22803,14 @@ __export(settlement_exports, {
22799
22803
  });
22800
22804
  import { randomUUID as randomUUID4 } from "node:crypto";
22801
22805
  import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
22802
- import { dirname as dirname15, join as join26 } from "node:path";
22806
+ import { dirname as dirname15, join as join27 } from "node:path";
22803
22807
  function sealedLedgerHome(admitted) {
22804
22808
  return homeFromRunDirectory(admitted.runDirectory);
22805
22809
  }
22806
22810
  function ledgerReadScope(admitted, scope) {
22807
22811
  return {
22808
22812
  home: sealedLedgerHome(admitted),
22809
- sessionParent: join26(admitted.runDirectory, "session", "session.jsonl"),
22813
+ sessionParent: join27(admitted.runDirectory, "session", "session.jsonl"),
22810
22814
  ...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
22811
22815
  };
22812
22816
  }
@@ -23307,7 +23311,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
23307
23311
  }
23308
23312
  const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
23309
23313
  if (parentId === void 0) return void 0;
23310
- const childDirectories = [join26(dirname15(sessionFile), "auditor-roles")];
23314
+ const childDirectories = [join27(dirname15(sessionFile), "auditor-roles")];
23311
23315
  const valid = [];
23312
23316
  let sawAnyDirectory = false;
23313
23317
  for (const childDirectory of childDirectories) {
@@ -23322,7 +23326,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
23322
23326
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
23323
23327
  let entries;
23324
23328
  try {
23325
- entries = await readBoundSessionEntries(join26(childDirectory, file));
23329
+ entries = await readBoundSessionEntries(join27(childDirectory, file));
23326
23330
  } catch (error) {
23327
23331
  throw sessionReadFailure(error, "failed to read discovered auditor session");
23328
23332
  }
@@ -23798,8 +23802,8 @@ function projectTerminalGateFact(rounds) {
23798
23802
  };
23799
23803
  }
23800
23804
  async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
23801
- const directories = [join26(sessionDirectory, "auditor-roles")];
23802
- const parentSessionFile = options.parentSessionFile ?? join26(sessionDirectory, "session.jsonl");
23805
+ const directories = [join27(sessionDirectory, "auditor-roles")];
23806
+ const parentSessionFile = options.parentSessionFile ?? join27(sessionDirectory, "session.jsonl");
23803
23807
  const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
23804
23808
  parentSessionFile
23805
23809
  });
@@ -23911,10 +23915,10 @@ async function removeFaceIfPresent(path) {
23911
23915
  async function clearOppositeTerminalArtifactFace(runDirectory) {
23912
23916
  const artifactsDir = roleRunArtifactsDirectory(runDirectory);
23913
23917
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
23914
- await removeFaceIfPresent(join26(artifactsDir, file));
23918
+ await removeFaceIfPresent(join27(artifactsDir, file));
23915
23919
  }
23916
23920
  for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
23917
- await removeFaceIfPresent(join26(runDirectory, relative3));
23921
+ await removeFaceIfPresent(join27(runDirectory, relative3));
23918
23922
  }
23919
23923
  for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
23920
23924
  await removeFaceIfPresent(path);
@@ -23943,8 +23947,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
23943
23947
  roleOutcome
23944
23948
  );
23945
23949
  const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
23946
- const reportPath = join26(artifactsDir, "report.json");
23947
- const evidencePath = join26(artifactsDir, "evidence.json");
23950
+ const reportPath = join27(artifactsDir, "report.json");
23951
+ const evidencePath = join27(artifactsDir, "evidence.json");
23948
23952
  await writeFile4(
23949
23953
  reportPath,
23950
23954
  `${JSON.stringify(bodies.report, null, 2)}
@@ -24353,7 +24357,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
24353
24357
  const candidates = [
24354
24358
  ...preferredCandidates,
24355
24359
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
24356
- ...uniqueFallbackDirs.map((dir) => join26(dir, `${stem}.${randomUUID4()}.json`))
24360
+ ...uniqueFallbackDirs.map((dir) => join27(dir, `${stem}.${randomUUID4()}.json`))
24357
24361
  ];
24358
24362
  for (let i = 0; i < candidates.length; i += 1) {
24359
24363
  const path = candidates[i];
@@ -24414,20 +24418,20 @@ async function publishFailureArtifacts(admitted, failure, authority, onErrorPubl
24414
24418
  baseDir
24415
24419
  );
24416
24420
  const errorCandidates = underArtifacts ? [
24417
- join26(baseDir, "error.json"),
24418
- join26(baseDir, "error.settlement.json"),
24419
- join26(admitted.runDirectory, "error.settlement.json")
24421
+ join27(baseDir, "error.json"),
24422
+ join27(baseDir, "error.settlement.json"),
24423
+ join27(admitted.runDirectory, "error.settlement.json")
24420
24424
  ] : [
24421
- join26(baseDir, "error.settlement.json"),
24422
- join26(baseDir, "error.json")
24425
+ join27(baseDir, "error.settlement.json"),
24426
+ join27(baseDir, "error.json")
24423
24427
  ];
24424
24428
  const evidenceCandidates = underArtifacts ? [
24425
- join26(baseDir, "evidence.json"),
24426
- join26(baseDir, "evidence.settlement.json"),
24427
- join26(admitted.runDirectory, "evidence.settlement.json")
24429
+ join27(baseDir, "evidence.json"),
24430
+ join27(baseDir, "evidence.settlement.json"),
24431
+ join27(admitted.runDirectory, "evidence.settlement.json")
24428
24432
  ] : [
24429
- join26(baseDir, "evidence.settlement.json"),
24430
- join26(baseDir, "evidence.json")
24433
+ join27(baseDir, "evidence.settlement.json"),
24434
+ join27(baseDir, "evidence.json")
24431
24435
  ];
24432
24436
  const errorPayloadBase = {
24433
24437
  kind: "error",
@@ -24682,9 +24686,9 @@ var init_settlement = __esm({
24682
24686
 
24683
24687
  // src/archivist-record-pointer.ts
24684
24688
  import { mkdirSync as mkdirSync3, writeFileSync } from "node:fs";
24685
- import { dirname as dirname16, join as join27 } from "node:path";
24689
+ import { dirname as dirname16, join as join28 } from "node:path";
24686
24690
  function bookDirectOfficerRunPointer(options) {
24687
- const nest = join27(dirname16(options.parentSessionFile), "auditor-roles");
24691
+ const nest = join28(dirname16(options.parentSessionFile), "auditor-roles");
24688
24692
  mkdirSync3(nest, { recursive: true });
24689
24693
  const pointer = {
24690
24694
  version: 1,
@@ -24694,7 +24698,7 @@ function bookDirectOfficerRunPointer(options) {
24694
24698
  ...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
24695
24699
  };
24696
24700
  writeFileSync(
24697
- join27(nest, `${options.officer}.pointer.json`),
24701
+ join28(nest, `${options.officer}.pointer.json`),
24698
24702
  `${JSON.stringify(pointer)}
24699
24703
  `,
24700
24704
  "utf8"
@@ -26094,7 +26098,7 @@ __export(public_role_summons_exports, {
26094
26098
  import { execFile as execFile3 } from "node:child_process";
26095
26099
  import { existsSync as existsSync9 } from "node:fs";
26096
26100
  import { realpath as realpath5 } from "node:fs/promises";
26097
- import { join as join28 } from "node:path";
26101
+ import { join as join29 } from "node:path";
26098
26102
  import { promisify as promisify3 } from "node:util";
26099
26103
  function createCapturingIo() {
26100
26104
  const chunks = [];
@@ -26118,7 +26122,7 @@ function parentDir(path) {
26118
26122
  function walkPackageRoot(start) {
26119
26123
  let dir = start;
26120
26124
  for (let i = 0; i < 12; i += 1) {
26121
- if (existsSync9(join28(dir, "package.json")) && existsSync9(join28(dir, "souls"))) {
26125
+ if (existsSync9(join29(dir, "package.json")) && existsSync9(join29(dir, "souls"))) {
26122
26126
  return dir;
26123
26127
  }
26124
26128
  const parent = parentDir(dir);
@@ -26234,7 +26238,7 @@ async function createSummonEnv(options, afterHost) {
26234
26238
  async function summonPublicRole(options) {
26235
26239
  const packageRoot2 = resolveSummonsPackageRoot(options.packageRoot);
26236
26240
  const home = await resolveSummonHome(options);
26237
- const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join28(home, ".pi", "agent");
26241
+ const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join29(home, ".pi", "agent");
26238
26242
  const {
26239
26243
  loadCredentialProviders: loadCredentialProviders2,
26240
26244
  loadPublicCliConfig: loadPublicCliConfig2,
@@ -26736,7 +26740,7 @@ var init_compliance_transport = __esm({
26736
26740
  });
26737
26741
 
26738
26742
  // src/role-run-relocation.ts
26739
- import { join as join29, sep as sep5 } from "node:path";
26743
+ import { join as join30, sep as sep5 } from "node:path";
26740
26744
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
26741
26745
  if (typeof value !== "string") return value;
26742
26746
  if (value === oldRunDirectory) return newRunDirectory;
@@ -26864,7 +26868,7 @@ __export(run_lifecycle_exports, {
26864
26868
  writeRoleRunState: () => writeRoleRunState
26865
26869
  });
26866
26870
  import { chmod, lstat as lstat5, open, readdir as readdir6, readFile as readFile16, unlink as unlink4, writeFile as writeFile5 } from "node:fs/promises";
26867
- import { basename as basename8, join as join30 } from "node:path";
26871
+ import { basename as basename8, join as join31 } from "node:path";
26868
26872
  function buildAutoResumeContinuationPrompt(options) {
26869
26873
  return appendEngineSessionMaterial(
26870
26874
  [RESUME_TRANSPORT_ENVELOPE],
@@ -26890,7 +26894,7 @@ function renderResumeCommand(runId) {
26890
26894
  async function writeRoleRunState(runDirectory, record4) {
26891
26895
  const payload = { ...record4, runDirectory };
26892
26896
  await writeFile5(
26893
- join30(runDirectory, RUN_STATE_FILE),
26897
+ join31(runDirectory, RUN_STATE_FILE),
26894
26898
  `${JSON.stringify(payload, null, 2)}
26895
26899
  `,
26896
26900
  "utf8"
@@ -26940,7 +26944,7 @@ function parseCurrentCourtState(raw) {
26940
26944
  async function readRoleRunStateRaw(runDirectory) {
26941
26945
  let raw;
26942
26946
  try {
26943
- raw = JSON.parse(await readFile16(join30(runDirectory, RUN_STATE_FILE), "utf8"));
26947
+ raw = JSON.parse(await readFile16(join31(runDirectory, RUN_STATE_FILE), "utf8"));
26944
26948
  } catch (error) {
26945
26949
  if (errorCodeOf(error) === "ENOENT") return void 0;
26946
26950
  throw error;
@@ -27034,7 +27038,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
27034
27038
  ...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
27035
27039
  };
27036
27040
  await writeFile5(
27037
- join30(runDirectory, RUN_STATE_FILE),
27041
+ join31(runDirectory, RUN_STATE_FILE),
27038
27042
  `${JSON.stringify(payload, null, 2)}
27039
27043
  `,
27040
27044
  "utf8"
@@ -27257,7 +27261,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
27257
27261
  },
27258
27262
  relocate(nextRunDirectory) {
27259
27263
  currentRunDirectory = nextRunDirectory;
27260
- currentLockPath = join30(nextRunDirectory, WRITER_LOCK_FILE);
27264
+ currentLockPath = join31(nextRunDirectory, WRITER_LOCK_FILE);
27261
27265
  },
27262
27266
  async release() {
27263
27267
  if (released) return;
@@ -27296,10 +27300,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
27296
27300
  };
27297
27301
  const reportReadFailure = (error) => {
27298
27302
  reportDiagnostic(
27299
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join30(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
27303
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join31(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
27300
27304
  );
27301
27305
  };
27302
- const lockPath = join30(runDirectory, WRITER_LOCK_FILE);
27306
+ const lockPath = join31(runDirectory, WRITER_LOCK_FILE);
27303
27307
  let lastAutopsy = { verdict: "absent" };
27304
27308
  let lastReclaimFailure;
27305
27309
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -27354,7 +27358,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
27354
27358
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
27355
27359
  if (runId.trim() === "") return void 0;
27356
27360
  const ledgerHome = resolveActivationLedgerHome(home);
27357
- const booksRoot = join30(ledgerHome, "books");
27361
+ const booksRoot = join31(ledgerHome, "books");
27358
27362
  let bookKeys;
27359
27363
  try {
27360
27364
  bookKeys = await readdir6(booksRoot);
@@ -27395,7 +27399,7 @@ async function readRunParentPath(runDirectory) {
27395
27399
  let raw;
27396
27400
  try {
27397
27401
  raw = JSON.parse(
27398
- await readFile16(join30(runDirectory, "admitted-request.json"), "utf8")
27402
+ await readFile16(join31(runDirectory, "admitted-request.json"), "utf8")
27399
27403
  );
27400
27404
  } catch (error) {
27401
27405
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -27416,7 +27420,7 @@ async function readRunParentPath(runDirectory) {
27416
27420
  async function runHasFormedSessionPrincipal(runDirectory) {
27417
27421
  const disk = await readRoleRunStateDisk(runDirectory);
27418
27422
  if (disk === void 0) return false;
27419
- const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join30(disk.principalWire.sessionDirectory, "session.jsonl");
27423
+ const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join31(disk.principalWire.sessionDirectory, "session.jsonl");
27420
27424
  try {
27421
27425
  const stat2 = await lstat5(sessionFile);
27422
27426
  return stat2.isFile() && !stat2.isSymbolicLink();
@@ -27434,7 +27438,7 @@ async function findLatestRunIdForSeatTicket(input) {
27434
27438
  let runDirectories;
27435
27439
  try {
27436
27440
  runDirectories = await listBookRunDirectories(
27437
- input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
27441
+ input.ticketNumber === void 0 ? bookDir : join31(bookDir, String(input.ticketNumber))
27438
27442
  );
27439
27443
  } catch (error) {
27440
27444
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -27632,7 +27636,7 @@ async function loadResumableRunRecord(home, runId, authority) {
27632
27636
  let model;
27633
27637
  try {
27634
27638
  const invocationRaw = JSON.parse(
27635
- await readFile16(join30(run.runDirectory, "invocation.json"), "utf8")
27639
+ await readFile16(join31(run.runDirectory, "invocation.json"), "utf8")
27636
27640
  );
27637
27641
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
27638
27642
  const rec = invocationRaw;
@@ -28001,9 +28005,9 @@ var init_run_lifecycle = __esm({
28001
28005
 
28002
28006
  // src/session-identity.ts
28003
28007
  import { mkdir as mkdir3, readFile as readFile17, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
28004
- import { dirname as dirname18, join as join31 } from "node:path";
28008
+ import { dirname as dirname18, join as join32 } from "node:path";
28005
28009
  function createSessionIdentityAuthority(authority, sessionBindingFile) {
28006
- const bindingPath = (principal) => join31(authority.decode(principal).sessionDirectory, sessionBindingFile);
28010
+ const bindingPath = (principal) => join32(authority.decode(principal).sessionDirectory, sessionBindingFile);
28007
28011
  return {
28008
28012
  resolveSessionFile(principal) {
28009
28013
  return authority.decode(principal).sessionFile;
@@ -28114,7 +28118,7 @@ import {
28114
28118
  rmSync as rmSync2,
28115
28119
  statSync as statSync4
28116
28120
  } from "node:fs";
28117
- import { dirname as dirname19, join as join32 } from "node:path";
28121
+ import { dirname as dirname19, join as join33 } from "node:path";
28118
28122
  function declareHostSessionFailure(error) {
28119
28123
  const message = error instanceof Error ? error.stack || error.message : String(error);
28120
28124
  process.stderr.write(`[host-session] Dossier record failure: ${message}
@@ -28122,7 +28126,7 @@ function declareHostSessionFailure(error) {
28122
28126
  }
28123
28127
  function recordRunStart(runDirectory) {
28124
28128
  try {
28125
- appendFileSync2(join32(runDirectory, ".run-starts"), "\n");
28129
+ appendFileSync2(join33(runDirectory, ".run-starts"), "\n");
28126
28130
  } catch (error) {
28127
28131
  declareHostSessionFailure(error);
28128
28132
  }
@@ -28138,7 +28142,7 @@ var init_host_session_record = __esm({
28138
28142
  import { constants as fsConstants2 } from "node:fs";
28139
28143
  import { randomUUID as randomUUID5 } from "node:crypto";
28140
28144
  import { lstat as lstat6, mkdir as mkdir4, open as open2 } from "node:fs/promises";
28141
- import { join as join33 } from "node:path";
28145
+ import { join as join34 } from "node:path";
28142
28146
  async function persistReturnedRunState(admitted, options) {
28143
28147
  if (options?.lawful === true) {
28144
28148
  await markRunTerminal(admitted.runDirectory);
@@ -28207,7 +28211,7 @@ function jsonSafeReplacer() {
28207
28211
  };
28208
28212
  }
28209
28213
  async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
28210
- const filePath = join33(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
28214
+ const filePath = join34(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
28211
28215
  const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
28212
28216
  `;
28213
28217
  const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
@@ -28462,7 +28466,7 @@ var init_auto_resume = __esm({
28462
28466
  // src/public-cli/post-admission.ts
28463
28467
  import { randomUUID as randomUUID6 } from "node:crypto";
28464
28468
  import { writeFile as writeFile7 } from "node:fs/promises";
28465
- import { isAbsolute as isAbsolute8, join as join34, resolve as resolve12 } from "node:path";
28469
+ import { isAbsolute as isAbsolute8, join as join35, resolve as resolve12 } from "node:path";
28466
28470
  function describeCaughtError(error) {
28467
28471
  if (error instanceof Error) {
28468
28472
  const code = error.code;
@@ -28558,7 +28562,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
28558
28562
  try {
28559
28563
  const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
28560
28564
  await writeFile7(
28561
- join34(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
28565
+ join35(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
28562
28566
  `${JSON.stringify({ version: 1, ...payload }, null, 2)}
28563
28567
  `,
28564
28568
  { encoding: "utf8", flag: "wx" }
@@ -28699,7 +28703,7 @@ async function dispatchPostAdmissionTurn(input) {
28699
28703
  const rows = await readRecordedSubmissionRows(
28700
28704
  admitted.projectRoot,
28701
28705
  admitted.runId,
28702
- { home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join34(admitted.runDirectory, "session", "session.jsonl") }
28706
+ { home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join35(admitted.runDirectory, "session", "session.jsonl") }
28703
28707
  );
28704
28708
  let ticketNumber;
28705
28709
  for (const row of rows) {
@@ -28826,7 +28830,7 @@ async function dispatchPostAdmissionTurn(input) {
28826
28830
  let stderrLogWriteFailure;
28827
28831
  try {
28828
28832
  await writeFile7(
28829
- join34(admitted.runDirectory, "stderr.log"),
28833
+ join35(admitted.runDirectory, "stderr.log"),
28830
28834
  result.stderr,
28831
28835
  "utf8"
28832
28836
  );
@@ -29105,7 +29109,7 @@ async function dispatchAfterWriterLease(input) {
29105
29109
  }
29106
29110
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
29107
29111
  const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
29108
- return pathContainedIn(join34(runDirectory, "attachments"), absolute);
29112
+ return pathContainedIn(join35(runDirectory, "attachments"), absolute);
29109
29113
  }
29110
29114
  async function prepareSummonsResumeMaterials(runDirectory, summons) {
29111
29115
  if (summons === void 0) return void 0;
@@ -29360,7 +29364,7 @@ async function presentResumeFailurePointer(io, thrown, publish) {
29360
29364
  }
29361
29365
  async function writeResumeDiagnosticFile(runDirectory, runId, failure, role) {
29362
29366
  const dir = await ensureRealArtifactsDirectory(runDirectory);
29363
- const path = join34(dir, `resume-diagnostic-${randomUUID6()}.json`);
29367
+ const path = join35(dir, `resume-diagnostic-${randomUUID6()}.json`);
29364
29368
  await writeFile7(
29365
29369
  path,
29366
29370
  `${JSON.stringify({
@@ -29541,10 +29545,10 @@ var init_analyst_book_key = __esm({
29541
29545
  // src/atomic-write.ts
29542
29546
  import { randomUUID as randomUUID7 } from "node:crypto";
29543
29547
  import { rename as rename3, rm as rm3, writeFile as writeFile8 } from "node:fs/promises";
29544
- import { dirname as dirname20, join as join35 } from "node:path";
29548
+ import { dirname as dirname20, join as join36 } from "node:path";
29545
29549
  async function writeFileAtomically(destination, contents) {
29546
29550
  const parent = dirname20(destination);
29547
- const temporary = join35(parent, `.atomic-write-${randomUUID7()}.tmp`);
29551
+ const temporary = join36(parent, `.atomic-write-${randomUUID7()}.tmp`);
29548
29552
  try {
29549
29553
  await writeFile8(temporary, contents);
29550
29554
  await rename3(temporary, destination);
@@ -29561,7 +29565,7 @@ var init_atomic_write = __esm({
29561
29565
 
29562
29566
  // src/analyst-index.ts
29563
29567
  import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
29564
- import { dirname as dirname21, join as join36 } from "node:path";
29568
+ import { dirname as dirname21, join as join37 } from "node:path";
29565
29569
  function sleep(ms) {
29566
29570
  return new Promise((resolve14) => {
29567
29571
  setTimeout(resolve14, ms);
@@ -29570,7 +29574,7 @@ function sleep(ms) {
29570
29574
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
29571
29575
  const indexPath = analystLibraryIndexPath(ledgerHome);
29572
29576
  ensureRealDirectoryTree(ledgerHome, dirname21(indexPath));
29573
- const lockPath = join36(dirname21(indexPath), LIBRARY_INDEX_LOCK_NAME);
29577
+ const lockPath = join37(dirname21(indexPath), LIBRARY_INDEX_LOCK_NAME);
29574
29578
  assertLedgerFileInsideHome(lockPath, ledgerHome);
29575
29579
  const startedAt = Date.now();
29576
29580
  while (true) {
@@ -29597,7 +29601,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
29597
29601
  }
29598
29602
  }
29599
29603
  function analystLibraryIndexPath(ledgerHome) {
29600
- return join36(ledgerHome, "analyst", "library-index.json");
29604
+ return join37(ledgerHome, "analyst", "library-index.json");
29601
29605
  }
29602
29606
  function rowFromIssueMetricsPage(page) {
29603
29607
  return {
@@ -29893,7 +29897,7 @@ var init_analyst_cohort = __esm({
29893
29897
 
29894
29898
  // src/analyst-ledger.ts
29895
29899
  import { readdir as readdir7, readFile as readFile19 } from "node:fs/promises";
29896
- import { basename as basename9, join as join37 } from "node:path";
29900
+ import { basename as basename9, join as join38 } from "node:path";
29897
29901
  function isMissingPathError6(error) {
29898
29902
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
29899
29903
  }
@@ -29922,7 +29926,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
29922
29926
  }
29923
29927
  }
29924
29928
  async function classifyGhostCandidate(input) {
29925
- const autopsy = await autopsyWriterLock(join37(input.runDirectory, "writer.lock"));
29929
+ const autopsy = await autopsyWriterLock(join38(input.runDirectory, "writer.lock"));
29926
29930
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
29927
29931
  if (leaseCheck === void 0) return { kind: "live" };
29928
29932
  return {
@@ -29951,7 +29955,7 @@ async function listLedgerBookNames(booksRoot) {
29951
29955
  async function readInvocationScopeFields(runDirectory) {
29952
29956
  let raw;
29953
29957
  try {
29954
- raw = await readFile19(join37(runDirectory, "invocation.json"), "utf8");
29958
+ raw = await readFile19(join38(runDirectory, "invocation.json"), "utf8");
29955
29959
  } catch (error) {
29956
29960
  if (isMissingPathError6(error)) return void 0;
29957
29961
  throw error;
@@ -29984,7 +29988,7 @@ function decideIssueScope(input) {
29984
29988
  }
29985
29989
  async function resolveSessionFile(runDirectory) {
29986
29990
  try {
29987
- const raw = await readFile19(join37(runDirectory, "invocation.json"), "utf8");
29991
+ const raw = await readFile19(join38(runDirectory, "invocation.json"), "utf8");
29988
29992
  const parsed = JSON.parse(raw);
29989
29993
  if (isRecord10(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
29990
29994
  return parsed.sessionFile;
@@ -29992,7 +29996,7 @@ async function resolveSessionFile(runDirectory) {
29992
29996
  } catch (error) {
29993
29997
  if (!isMissingPathError6(error)) throw error;
29994
29998
  }
29995
- return join37(runDirectory, "session", "session.jsonl");
29999
+ return join38(runDirectory, "session", "session.jsonl");
29996
30000
  }
29997
30001
  function attributeSessionRowsForRun(input) {
29998
30002
  if (pathContainedIn(input.runDirectory, input.sessionFile)) {
@@ -30194,9 +30198,9 @@ async function classifyScopedRun(input) {
30194
30198
  }
30195
30199
  let gateCycles;
30196
30200
  try {
30197
- const parentSessionFile = join37(input.runDirectory, "session", "session.jsonl");
30201
+ const parentSessionFile = join38(input.runDirectory, "session", "session.jsonl");
30198
30202
  gateCycles = await readAnalystGateCyclesFromAuditorRoles(
30199
- join37(input.runDirectory, "session", "auditor-roles"),
30203
+ join38(input.runDirectory, "session", "auditor-roles"),
30200
30204
  { parentSessionFile }
30201
30205
  );
30202
30206
  } catch (error) {
@@ -30231,7 +30235,7 @@ async function classifyScopedRun(input) {
30231
30235
  async function scanAnalystIssueRuns(input) {
30232
30236
  const ledgerHome = resolveActivationLedgerHome(input.home);
30233
30237
  const scopeTicketNumber = input.ticketNumber;
30234
- const booksRoot = join37(ledgerHome, "books");
30238
+ const booksRoot = join38(ledgerHome, "books");
30235
30239
  let wholeBook = false;
30236
30240
  let scopeRootIdentity;
30237
30241
  let bookNames;
@@ -30264,7 +30268,7 @@ async function scanAnalystIssueRuns(input) {
30264
30268
  const ghostLegs = [];
30265
30269
  const scopeConflicts = [];
30266
30270
  for (const book of bookNames) {
30267
- const bookDir = join37(booksRoot, book);
30271
+ const bookDir = join38(booksRoot, book);
30268
30272
  let runDirectories;
30269
30273
  try {
30270
30274
  runDirectories = await listBookRunDirectories(bookDir);
@@ -31001,7 +31005,7 @@ var init_analyst_metric_family = __esm({
31001
31005
 
31002
31006
  // src/analyst-page.ts
31003
31007
  import { createHash as createHash3 } from "node:crypto";
31004
- import { dirname as dirname22, join as join38 } from "node:path";
31008
+ import { dirname as dirname22, join as join39 } from "node:path";
31005
31009
  function analystIssuePageKey(address) {
31006
31010
  const parts = ["book", address.bookKey];
31007
31011
  if (address.issueNumber !== void 0) {
@@ -31012,7 +31016,7 @@ function analystIssuePageKey(address) {
31012
31016
  return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
31013
31017
  }
31014
31018
  function analystIssuePagePath(ledgerHome, address) {
31015
- return join38(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
31019
+ return join39(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
31016
31020
  }
31017
31021
  function analystIssuePageAddressFromPage(page) {
31018
31022
  return {
@@ -31651,7 +31655,7 @@ __export(cli_exports, {
31651
31655
  runAkRole: () => runAkRole
31652
31656
  });
31653
31657
  import { realpath as realpath6 } from "node:fs/promises";
31654
- import { join as join39 } from "node:path";
31658
+ import { join as join40 } from "node:path";
31655
31659
  function publicSeatArgv(owner) {
31656
31660
  return {
31657
31661
  parse: (args) => parsePublicSeatArgv(owner, args),
@@ -31790,7 +31794,7 @@ function resolveHome(env) {
31790
31794
  return env.home ?? packageMachineHome();
31791
31795
  }
31792
31796
  function resolveAgentDir(env, home) {
31793
- return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join39(home, ".pi", "agent");
31797
+ return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join40(home, ".pi", "agent");
31794
31798
  }
31795
31799
  function parseThinking(value) {
31796
31800
  return value;
@@ -32552,7 +32556,7 @@ var init_cli = __esm({
32552
32556
 
32553
32557
  // src/public-cli/main.ts
32554
32558
  import { existsSync as existsSync11 } from "node:fs";
32555
- import { dirname as dirname23, join as join40 } from "node:path";
32559
+ import { dirname as dirname23, join as join41 } from "node:path";
32556
32560
  import { fileURLToPath as fileURLToPath2 } from "node:url";
32557
32561
 
32558
32562
  // src/public-cli/host-pi-runtime.ts
@@ -32641,8 +32645,8 @@ function linkPackage(packageRoot2, name, targetDir) {
32641
32645
  // src/public-cli/main.ts
32642
32646
  var here = dirname23(fileURLToPath2(import.meta.url));
32643
32647
  function resolvePackageRoot(binDir) {
32644
- const canonical = join40(binDir, "..", "..");
32645
- if (existsSync11(join40(canonical, "package.json"))) {
32648
+ const canonical = join41(binDir, "..", "..");
32649
+ if (existsSync11(join41(canonical, "package.json"))) {
32646
32650
  return canonical;
32647
32651
  }
32648
32652
  return binDir;