@akagilnc/pi-workflow-roles 0.1.3771 → 0.1.3783

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.
@@ -15453,16 +15453,24 @@ var init_institutional_resolution = __esm({
15453
15453
  function lookupHostDescription(host) {
15454
15454
  return Object.hasOwn(HOST_DESCRIPTIONS, host) ? HOST_DESCRIPTIONS[host] : void 0;
15455
15455
  }
15456
+ function lookupHeadlessHostDescription(host) {
15457
+ return Object.hasOwn(HEADLESS_HOST_DESCRIPTIONS, host) ? HEADLESS_HOST_DESCRIPTIONS[host] : void 0;
15458
+ }
15459
+ function lookupHostFamily(host) {
15460
+ if (lookupHostDescription(host) !== void 0) return "acp";
15461
+ if (lookupHeadlessHostDescription(host) !== void 0) return "headless";
15462
+ return void 0;
15463
+ }
15456
15464
  function packagedExternalHostNames() {
15457
- return Object.keys(HOST_DESCRIPTIONS);
15465
+ return [...Object.keys(HOST_DESCRIPTIONS), ...Object.keys(HEADLESS_HOST_DESCRIPTIONS)];
15458
15466
  }
15459
15467
  function assertRegisteredHostName(host) {
15460
- if (host === DEFAULT_ROLE_TURN_HOST || lookupHostDescription(host) !== void 0) {
15468
+ if (host === DEFAULT_ROLE_TURN_HOST || lookupHostFamily(host) !== void 0) {
15461
15469
  return host;
15462
15470
  }
15463
15471
  throw new Error(`unregistered host: ${host}`);
15464
15472
  }
15465
- var PRIVATE_COMPAT_ENV, DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS;
15473
+ var PRIVATE_COMPAT_ENV, DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
15466
15474
  var init_host_descriptions = __esm({
15467
15475
  "src/host-descriptions.ts"() {
15468
15476
  "use strict";
@@ -15514,6 +15522,33 @@ var init_host_descriptions = __esm({
15514
15522
  })
15515
15523
  })
15516
15524
  });
15525
+ HEADLESS_HOST_DESCRIPTIONS = Object.freeze({
15526
+ "claude": Object.freeze({
15527
+ binaryFromHome: Object.freeze([".local", "bin", "claude"]),
15528
+ sessionBindingFile: "claude-headless-session.json",
15529
+ fixedArgs: Object.freeze([
15530
+ // One result envelope (not stream-json): typed receipt only; no event-stream copy.
15531
+ "--output-format",
15532
+ "json",
15533
+ "--permission-mode",
15534
+ "bypassPermissions",
15535
+ // Empty sources: no user/project/local operator surface (envelope owns materials).
15536
+ "--setting-sources",
15537
+ "",
15538
+ // With adapter-supplied --mcp-config only (AK relay); drops operator + claude.ai MCP.
15539
+ "--strict-mcp-config"
15540
+ ]),
15541
+ promptFlag: "-p",
15542
+ modelFlag: "--model",
15543
+ effortFlag: "--effort",
15544
+ // File path keeps large role envelopes off ARG_MAX.
15545
+ systemPromptFlag: "--system-prompt-file",
15546
+ jsonSchemaFlag: "--json-schema",
15547
+ mcpConfigFlag: "--mcp-config",
15548
+ sessionIdFlag: "--session-id",
15549
+ resumeFlag: "--resume"
15550
+ })
15551
+ });
15517
15552
  }
15518
15553
  });
15519
15554
 
@@ -16154,6 +16189,50 @@ var init_load_production_acp_host = __esm({
16154
16189
  }
16155
16190
  });
16156
16191
 
16192
+ // src/public-cli/load-production-headless-host.ts
16193
+ import { existsSync as existsSync4 } from "node:fs";
16194
+ import { join as join8 } from "node:path";
16195
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
16196
+ async function loadProductionHeadlessHostFactory(packageRoot2, host) {
16197
+ const description = lookupHeadlessHostDescription(host);
16198
+ if (description === void 0) {
16199
+ throw new Error(`unregistered headless host: ${host}`);
16200
+ }
16201
+ const built = join8(packageRoot2, "dist/headless-host/production-host.js");
16202
+ const source = join8(packageRoot2, "src/headless-host/production-host.ts");
16203
+ const target = existsSync4(built) ? built : source;
16204
+ const href = pathToFileURL2(target).href;
16205
+ const mod = await import(href);
16206
+ const create = mod.createProductionHeadlessRoleTurnHost;
16207
+ return (options) => create({ ...options, description });
16208
+ }
16209
+ var init_load_production_headless_host = __esm({
16210
+ "src/public-cli/load-production-headless-host.ts"() {
16211
+ "use strict";
16212
+ init_host_descriptions();
16213
+ }
16214
+ });
16215
+
16216
+ // src/public-cli/load-production-external-host.ts
16217
+ async function loadProductionExternalHostFactory(packageRoot2, host) {
16218
+ const family = lookupHostFamily(host);
16219
+ if (family === "acp") {
16220
+ return loadProductionAcpHostFactory(packageRoot2, host);
16221
+ }
16222
+ if (family === "headless") {
16223
+ return loadProductionHeadlessHostFactory(packageRoot2, host);
16224
+ }
16225
+ throw new Error(`unregistered host: ${host}`);
16226
+ }
16227
+ var init_load_production_external_host = __esm({
16228
+ "src/public-cli/load-production-external-host.ts"() {
16229
+ "use strict";
16230
+ init_host_descriptions();
16231
+ init_load_production_acp_host();
16232
+ init_load_production_headless_host();
16233
+ }
16234
+ });
16235
+
16157
16236
  // src/host-contracts.ts
16158
16237
  var ExplicitInternalActivationError;
16159
16238
  var init_host_contracts = __esm({
@@ -16221,12 +16300,12 @@ var init_sitian_contracts = __esm({
16221
16300
  import { createHash as createHash2, randomUUID } from "node:crypto";
16222
16301
  import {
16223
16302
  appendFileSync,
16224
- existsSync as existsSync4,
16303
+ existsSync as existsSync5,
16225
16304
  readFileSync as readFileSync2,
16226
16305
  unlinkSync,
16227
16306
  writeFileSync
16228
16307
  } from "node:fs";
16229
- import { basename as basename3, dirname as dirname5, join as join8, resolve as resolve3 } from "node:path";
16308
+ import { basename as basename3, dirname as dirname5, join as join9, resolve as resolve3 } from "node:path";
16230
16309
  function isRecord7(value) {
16231
16310
  return typeof value === "object" && value !== null && !Array.isArray(value);
16232
16311
  }
@@ -16241,14 +16320,14 @@ function createExclusiveFile(path, contents) {
16241
16320
  writeFileSync(path, contents, { encoding: "utf8", flag: "wx" });
16242
16321
  }
16243
16322
  function sealTornTail(recordFile) {
16244
- if (!existsSync4(recordFile)) return;
16323
+ if (!existsSync5(recordFile)) return;
16245
16324
  const buffer = readFileSync2(recordFile);
16246
16325
  if (buffer.length > 0 && buffer[buffer.length - 1] !== 10) {
16247
16326
  appendFileSync(recordFile, "\n", "utf8");
16248
16327
  }
16249
16328
  }
16250
16329
  function findIdentityPointer(recordFile, identity, kind, level) {
16251
- if (!existsSync4(recordFile)) return void 0;
16330
+ if (!existsSync5(recordFile)) return void 0;
16252
16331
  const text = readFileSync2(recordFile, "utf8");
16253
16332
  for (const line2 of text.split("\n")) {
16254
16333
  const trimmed = line2.trim();
@@ -16365,7 +16444,7 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
16365
16444
  const category = resolveSitianVolumeCategory(input.kind);
16366
16445
  let sessionDir;
16367
16446
  if (input.sessionParent !== void 0 && input.sessionParent.length > 0 && physicallyContainedIn(ledgerHome, input.sessionParent)) {
16368
- sessionDir = join8(dirname5(input.sessionParent), category);
16447
+ sessionDir = join9(dirname5(input.sessionParent), category);
16369
16448
  } else {
16370
16449
  const bookKey = safeBookKey(cwd);
16371
16450
  const bookDir = activationBookDirectory(ledgerHome, bookKey);
@@ -16379,12 +16458,12 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
16379
16458
  subjectStr = JSON.stringify(input.subject);
16380
16459
  }
16381
16460
  const digest = createHash2("sha256").update(subjectStr).digest("hex").slice(0, 32);
16382
- sessionDir = join8(bookDir, category, digest);
16461
+ sessionDir = join9(bookDir, category, digest);
16383
16462
  } else {
16384
- sessionDir = join8(bookDir, category);
16463
+ sessionDir = join9(bookDir, category);
16385
16464
  }
16386
16465
  }
16387
- const recordFile = join8(sessionDir, "records.jsonl");
16466
+ const recordFile = join9(sessionDir, "records.jsonl");
16388
16467
  return { sessionDir, recordFile, ledgerHome };
16389
16468
  }
16390
16469
  function resolveSitianRecordPath(input) {
@@ -16441,13 +16520,13 @@ var init_sitian_appender = __esm({
16441
16520
  });
16442
16521
 
16443
16522
  // src/sitian-reader.ts
16444
- import { existsSync as existsSync5 } from "node:fs";
16523
+ import { existsSync as existsSync6 } from "node:fs";
16445
16524
  import { readFile as readFile2 } from "node:fs/promises";
16446
16525
  function isRecord8(value) {
16447
16526
  return typeof value === "object" && value !== null && !Array.isArray(value);
16448
16527
  }
16449
16528
  async function readSitianRecords(recordFile) {
16450
- if (!existsSync5(recordFile)) {
16529
+ if (!existsSync6(recordFile)) {
16451
16530
  return { records: [], diagnostics: [] };
16452
16531
  }
16453
16532
  const text = await readFile2(recordFile, "utf8");
@@ -16505,12 +16584,12 @@ var init_sitian_facade = __esm({
16505
16584
  import { execFile, spawn } from "node:child_process";
16506
16585
  import { constants } from "node:fs";
16507
16586
  import { access, appendFile, readFile as readFile3, realpath } from "node:fs/promises";
16508
- import { delimiter as delimiter2, isAbsolute as isAbsolute3, join as join9, resolve as resolve4 } from "node:path";
16587
+ import { delimiter as delimiter2, isAbsolute as isAbsolute3, join as join10, resolve as resolve4 } from "node:path";
16509
16588
  import { platform } from "node:process";
16510
16589
  import { promisify } from "node:util";
16511
16590
  import { randomUUID as randomUUID2 } from "node:crypto";
16512
16591
  function resolveInternalRoleEntrypoint(packageRoot2) {
16513
- return join9(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
16592
+ return join10(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
16514
16593
  }
16515
16594
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
16516
16595
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -16854,7 +16933,7 @@ var init_role_turn_host = __esm({
16854
16933
 
16855
16934
  // src/run-ticket-number.ts
16856
16935
  import { readFile as readFile4 } from "node:fs/promises";
16857
- import { join as join10 } from "node:path";
16936
+ import { join as join11 } from "node:path";
16858
16937
  function isEnoent(error) {
16859
16938
  return error instanceof Error && "code" in error && error.code === "ENOENT";
16860
16939
  }
@@ -16867,7 +16946,7 @@ function ticketFromRecord(record4) {
16867
16946
  }
16868
16947
  async function readPageTicketNumber(runDirectory, page) {
16869
16948
  try {
16870
- const raw = JSON.parse(await readFile4(join10(runDirectory, page), "utf8"));
16949
+ const raw = JSON.parse(await readFile4(join11(runDirectory, page), "utf8"));
16871
16950
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
16872
16951
  return void 0;
16873
16952
  }
@@ -17763,9 +17842,9 @@ var init_uuidv7 = __esm({
17763
17842
 
17764
17843
  // src/typed-provider-http.ts
17765
17844
  import { readFile as readFile7, unlink, writeFile as writeFile2 } from "node:fs/promises";
17766
- import { join as join11 } from "node:path";
17845
+ import { join as join12 } from "node:path";
17767
17846
  function typedProviderHttpPath(runDirectory) {
17768
- return join11(runDirectory, TYPED_HTTP_FILE);
17847
+ return join12(runDirectory, TYPED_HTTP_FILE);
17769
17848
  }
17770
17849
  async function clearTypedProviderHttpObservation(runDirectory) {
17771
17850
  try {
@@ -17810,7 +17889,7 @@ var init_typed_provider_http = __esm({
17810
17889
 
17811
17890
  // src/public-cli/run-lifecycle.ts
17812
17891
  import { chmod, open, readdir as readdir2, readFile as readFile8, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
17813
- import { isAbsolute as isAbsolute4, join as join12 } from "node:path";
17892
+ import { isAbsolute as isAbsolute4, join as join13 } from "node:path";
17814
17893
  function resumeRereadInstruction(materialPath, handbook) {
17815
17894
  return handbook ? `\u91CD\u65B0\u8BFB ${materialPath}\uFF0C\u518D\u7EC4\u88C5\u5916\u5305 argv` : `\u91CD\u65B0\u8BFB ${materialPath}`;
17816
17895
  }
@@ -17858,7 +17937,7 @@ function renderResumeCommand(runId) {
17858
17937
  async function writeRoleRunState(runDirectory, record4) {
17859
17938
  const payload = { ...record4, runDirectory };
17860
17939
  await writeFile3(
17861
- join12(runDirectory, RUN_STATE_FILE),
17940
+ join13(runDirectory, RUN_STATE_FILE),
17862
17941
  `${JSON.stringify(payload, null, 2)}
17863
17942
  `,
17864
17943
  "utf8"
@@ -17908,7 +17987,7 @@ function parseCurrentCourtState(raw) {
17908
17987
  async function readRoleRunStateDisk(runDirectory) {
17909
17988
  let raw;
17910
17989
  try {
17911
- raw = JSON.parse(await readFile8(join12(runDirectory, RUN_STATE_FILE), "utf8"));
17990
+ raw = JSON.parse(await readFile8(join13(runDirectory, RUN_STATE_FILE), "utf8"));
17912
17991
  } catch {
17913
17992
  return void 0;
17914
17993
  }
@@ -17975,7 +18054,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
17975
18054
  ...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
17976
18055
  };
17977
18056
  await writeFile3(
17978
- join12(runDirectory, RUN_STATE_FILE),
18057
+ join13(runDirectory, RUN_STATE_FILE),
17979
18058
  `${JSON.stringify(payload, null, 2)}
17980
18059
  `,
17981
18060
  "utf8"
@@ -18219,15 +18298,15 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
18219
18298
  };
18220
18299
  const reportCleanupFailure = (error) => {
18221
18300
  reportDiagnostic(
18222
- `writer lease lock cleanup failed (release is best-effort; residual lock left in place) at ${join12(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18301
+ `writer lease lock cleanup failed (release is best-effort; residual lock left in place) at ${join13(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18223
18302
  );
18224
18303
  };
18225
18304
  const reportReadFailure = (error) => {
18226
18305
  reportDiagnostic(
18227
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join12(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18306
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join13(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18228
18307
  );
18229
18308
  };
18230
- const lockPath = join12(runDirectory, WRITER_LOCK_FILE);
18309
+ const lockPath = join13(runDirectory, WRITER_LOCK_FILE);
18231
18310
  let lastAutopsy = { verdict: "absent" };
18232
18311
  let lastReclaimFailure;
18233
18312
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -18277,7 +18356,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
18277
18356
  async function findRunDirectoryById(home, runId) {
18278
18357
  if (runId.trim() === "") return void 0;
18279
18358
  const ledgerHome = resolveActivationLedgerHome(home);
18280
- const booksRoot = join12(ledgerHome, "books");
18359
+ const booksRoot = join13(ledgerHome, "books");
18281
18360
  let bookKeys;
18282
18361
  try {
18283
18362
  bookKeys = await readdir2(booksRoot);
@@ -18285,7 +18364,7 @@ async function findRunDirectoryById(home, runId) {
18285
18364
  return void 0;
18286
18365
  }
18287
18366
  for (const bookKey of bookKeys) {
18288
- const runsDir = join12(activationBookDirectory(ledgerHome, bookKey), "runs");
18367
+ const runsDir = join13(activationBookDirectory(ledgerHome, bookKey), "runs");
18289
18368
  let entries;
18290
18369
  try {
18291
18370
  entries = await readdir2(runsDir);
@@ -18294,7 +18373,7 @@ async function findRunDirectoryById(home, runId) {
18294
18373
  }
18295
18374
  for (const entry of entries) {
18296
18375
  if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
18297
- return join12(runsDir, entry);
18376
+ return join13(runsDir, entry);
18298
18377
  }
18299
18378
  }
18300
18379
  }
@@ -18309,7 +18388,7 @@ async function readRunParentPath(runDirectory) {
18309
18388
  let raw;
18310
18389
  try {
18311
18390
  raw = JSON.parse(
18312
- await readFile8(join12(runDirectory, "admitted-request.json"), "utf8")
18391
+ await readFile8(join13(runDirectory, "admitted-request.json"), "utf8")
18313
18392
  );
18314
18393
  } catch (error) {
18315
18394
  if (errorCodeOf2(error) === "ENOENT") return void 0;
@@ -18329,7 +18408,7 @@ async function readRunParentPath(runDirectory) {
18329
18408
  }
18330
18409
  async function findLatestRunIdForSeatTicket(input) {
18331
18410
  const ledgerHome = resolveActivationLedgerHome(input.home);
18332
- const runsDir = join12(
18411
+ const runsDir = join13(
18333
18412
  activationBookDirectory(ledgerHome, input.bookKey),
18334
18413
  "runs"
18335
18414
  );
@@ -18346,7 +18425,7 @@ async function findLatestRunIdForSeatTicket(input) {
18346
18425
  if (!entry.endsWith(suffix)) continue;
18347
18426
  const runId = entry.slice(0, entry.length - suffix.length);
18348
18427
  if (runId.length === 0) continue;
18349
- const runDirectory = join12(runsDir, entry);
18428
+ const runDirectory = join13(runsDir, entry);
18350
18429
  if (input.parentRunPath !== void 0) {
18351
18430
  const parentPath = await readRunParentPath(runDirectory);
18352
18431
  if (parentPath !== input.parentRunPath) continue;
@@ -18531,7 +18610,7 @@ async function loadResumableRunRecord(home, runId, authority) {
18531
18610
  let model;
18532
18611
  try {
18533
18612
  const invocationRaw = JSON.parse(
18534
- await readFile8(join12(run.runDirectory, "invocation.json"), "utf8")
18613
+ await readFile8(join13(run.runDirectory, "invocation.json"), "utf8")
18535
18614
  );
18536
18615
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
18537
18616
  const rec = invocationRaw;
@@ -18939,7 +19018,7 @@ __export(notary_source_run_exports, {
18939
19018
  loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
18940
19019
  resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
18941
19020
  });
18942
- import { dirname as dirname7, isAbsolute as isAbsolute5, join as join13, resolve as resolve6, basename as basename4 } from "node:path";
19021
+ import { dirname as dirname7, isAbsolute as isAbsolute5, join as join14, resolve as resolve6, basename as basename4 } from "node:path";
18943
19022
  import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
18944
19023
  function parseRunDirectoryName(name) {
18945
19024
  const match = RUN_DIR_NAME.exec(name);
@@ -18985,11 +19064,11 @@ async function resolveNotarySourceRunLocator(options) {
18985
19064
  }
18986
19065
  const ledgerHome = resolveActivationLedgerHome(options.home);
18987
19066
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
18988
- const bookRunsRoot = join13(activationBookDirectory(ledgerHome, bookKey), "runs");
19067
+ const bookRunsRoot = join14(activationBookDirectory(ledgerHome, bookKey), "runs");
18989
19068
  let candidate;
18990
19069
  const bare = parseRunDirectoryName(raw);
18991
19070
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
18992
- candidate = join13(bookRunsRoot, `${bare.runId}@${bare.role}`);
19071
+ candidate = join14(bookRunsRoot, `${bare.runId}@${bare.role}`);
18993
19072
  } else {
18994
19073
  candidate = isAbsolute5(raw) ? raw : resolve6(options.projectRoot, raw);
18995
19074
  }
@@ -20115,11 +20194,11 @@ import {
20115
20194
  realpath as realpath4,
20116
20195
  writeFile as writeFile4
20117
20196
  } from "node:fs/promises";
20118
- import { basename as basename5, isAbsolute as isAbsolute6, join as join14, resolve as resolve7, sep as sep3 } from "node:path";
20197
+ import { basename as basename5, isAbsolute as isAbsolute6, join as join15, resolve as resolve7, sep as sep3 } from "node:path";
20119
20198
  function issueAdmissionPlacement(authority, request) {
20120
20199
  const principal = authority.issue(request);
20121
20200
  const { sessionDirectory, sessionFile } = authority.decode(principal);
20122
- const runDirectory = join14(sessionDirectory, "..");
20201
+ const runDirectory = join15(sessionDirectory, "..");
20123
20202
  const ledgerHome = resolveActivationLedgerHome(request.home);
20124
20203
  const bookKey = resolveBookKeyFromGit(request.cwd);
20125
20204
  return {
@@ -20167,14 +20246,14 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
20167
20246
  ...effectiveModelLedgerFields(effectiveModel)
20168
20247
  };
20169
20248
  await writeFile4(
20170
- join14(source.runDirectory, "invocation.json"),
20249
+ join15(source.runDirectory, "invocation.json"),
20171
20250
  `${JSON.stringify(identity, null, 2)}
20172
20251
  `,
20173
20252
  "utf8"
20174
20253
  );
20175
20254
  }
20176
20255
  async function recordEffectiveInvocationModel(runDirectory, model, engine, host) {
20177
- const ledgerPath = join14(runDirectory, "invocation.json");
20256
+ const ledgerPath = join15(runDirectory, "invocation.json");
20178
20257
  const current = JSON.parse(await readFile9(ledgerPath, "utf8"));
20179
20258
  const next = { ...current };
20180
20259
  if (model !== void 0) {
@@ -20202,7 +20281,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host)
20202
20281
  );
20203
20282
  }
20204
20283
  async function mergeInvocationIdentityPage(runDirectory, fields) {
20205
- const ledgerPath = join14(runDirectory, "invocation.json");
20284
+ const ledgerPath = join15(runDirectory, "invocation.json");
20206
20285
  const current = JSON.parse(await readFile9(ledgerPath, "utf8"));
20207
20286
  await writeFile4(
20208
20287
  ledgerPath,
@@ -20263,7 +20342,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
20263
20342
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
20264
20343
  const rolePackageRoot = packageRoot2;
20265
20344
  const raw = JSON.parse(
20266
- await readFile9(join14(rolePackageRoot, "package.json"), "utf8")
20345
+ await readFile9(join15(rolePackageRoot, "package.json"), "utf8")
20267
20346
  );
20268
20347
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
20269
20348
  throw new Error(
@@ -20510,7 +20589,7 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
20510
20589
  }
20511
20590
  const bytes = await readFile9(absolute);
20512
20591
  const name = `${String(index).padStart(2, "0")}-${basename5(absolute)}`;
20513
- const frozenPath = join14(destinationDir, name);
20592
+ const frozenPath = join15(destinationDir, name);
20514
20593
  await writeFile4(frozenPath, bytes);
20515
20594
  return {
20516
20595
  attachment: {
@@ -20538,7 +20617,7 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
20538
20617
  async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
20539
20618
  if (attachmentPaths.length === 0) return [];
20540
20619
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
20541
- const attachmentsDirectory = join14(runDirectory, "attachments", summonsKey);
20620
+ const attachmentsDirectory = join15(runDirectory, "attachments", summonsKey);
20542
20621
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20543
20622
  return freezeAttachments(attachmentPaths, attachmentsDirectory);
20544
20623
  }
@@ -20564,7 +20643,7 @@ async function admitStandardMaterialInvocation(role, options) {
20564
20643
  role,
20565
20644
  home: options.home
20566
20645
  });
20567
- const attachmentsDirectory = join14(runDirectory, "attachments");
20646
+ const attachmentsDirectory = join15(runDirectory, "attachments");
20568
20647
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20569
20648
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20570
20649
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
@@ -20589,7 +20668,7 @@ async function admitStandardMaterialInvocation(role, options) {
20589
20668
  mediaKind: a.mediaKind
20590
20669
  }))
20591
20670
  };
20592
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20671
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20593
20672
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20594
20673
  sessionDirectory,
20595
20674
  sessionFile
@@ -20667,7 +20746,7 @@ async function admitCountersignInvocation(options) {
20667
20746
  role: "countersign",
20668
20747
  home: options.home
20669
20748
  });
20670
- const attachmentsDirectory = join14(runDirectory, "attachments");
20749
+ const attachmentsDirectory = join15(runDirectory, "attachments");
20671
20750
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20672
20751
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20673
20752
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
@@ -20691,7 +20770,7 @@ async function admitCountersignInvocation(options) {
20691
20770
  mediaKind: a.mediaKind
20692
20771
  }))
20693
20772
  };
20694
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20773
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20695
20774
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20696
20775
  sessionDirectory,
20697
20776
  sessionFile
@@ -20715,7 +20794,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
20715
20794
  return buildInstructionTransportPrompt(admitted, engineMaterial);
20716
20795
  }
20717
20796
  async function ensureRunArtifactsDir(runDirectory) {
20718
- const dir = join14(runDirectory, "artifacts");
20797
+ const dir = join15(runDirectory, "artifacts");
20719
20798
  await mkdir2(dir, { recursive: true });
20720
20799
  return dir;
20721
20800
  }
@@ -20747,11 +20826,11 @@ async function admitCoderInvocation(options) {
20747
20826
  role: "coder",
20748
20827
  home: options.home
20749
20828
  });
20750
- const attachmentsDirectory = join14(runDirectory, "attachments");
20829
+ const attachmentsDirectory = join15(runDirectory, "attachments");
20751
20830
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20752
20831
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20753
20832
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
20754
- const taskPath = join14(runDirectory, "task.md");
20833
+ const taskPath = join15(runDirectory, "task.md");
20755
20834
  await writeFile4(taskPath, instruction, "utf8");
20756
20835
  const admitted = {
20757
20836
  role: "coder",
@@ -20772,7 +20851,7 @@ async function admitCoderInvocation(options) {
20772
20851
  mediaKind: a.mediaKind
20773
20852
  }))
20774
20853
  };
20775
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20854
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20776
20855
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20777
20856
  sessionDirectory,
20778
20857
  sessionFile
@@ -20853,13 +20932,13 @@ async function admitFixerInvocation(options) {
20853
20932
  role: "fixer",
20854
20933
  home: options.home
20855
20934
  });
20856
- const attachmentsDirectory = join14(runDirectory, "attachments");
20935
+ const attachmentsDirectory = join15(runDirectory, "attachments");
20857
20936
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20858
20937
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20859
20938
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
20860
20939
  let prerequisitesPath;
20861
20940
  if (prerequisitesSource !== void 0) {
20862
- prerequisitesPath = join14(runDirectory, "prerequisites.json");
20941
+ prerequisitesPath = join15(runDirectory, "prerequisites.json");
20863
20942
  await writeFile4(
20864
20943
  prerequisitesPath,
20865
20944
  `${JSON.stringify(prerequisites, null, 2)}
@@ -20867,7 +20946,7 @@ async function admitFixerInvocation(options) {
20867
20946
  "utf8"
20868
20947
  );
20869
20948
  }
20870
- const packetPath = join14(runDirectory, "fix-packet.md");
20949
+ const packetPath = join15(runDirectory, "fix-packet.md");
20871
20950
  await writeFile4(packetPath, instruction, "utf8");
20872
20951
  const admitted = {
20873
20952
  role: "fixer",
@@ -20893,7 +20972,7 @@ async function admitFixerInvocation(options) {
20893
20972
  mediaKind: a.mediaKind
20894
20973
  }))
20895
20974
  };
20896
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20975
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20897
20976
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20898
20977
  sessionDirectory,
20899
20978
  sessionFile
@@ -21087,7 +21166,7 @@ async function admitCollectorInvocation(options) {
21087
21166
  role: "collector",
21088
21167
  home: options.home
21089
21168
  });
21090
- const attachmentsDirectory = join14(runDirectory, "attachments");
21169
+ const attachmentsDirectory = join15(runDirectory, "attachments");
21091
21170
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
21092
21171
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
21093
21172
  const attachments = await freezeAttachments(options.attachmentPaths ?? [], attachmentsDirectory);
@@ -21101,7 +21180,7 @@ async function admitCollectorInvocation(options) {
21101
21180
  const prNumber = target.kind === "bound" ? target.prNumber : void 0;
21102
21181
  let requestManifestPath;
21103
21182
  if (manifestCanonicalJson !== void 0) {
21104
- requestManifestPath = join14(runDirectory, "request-manifest.json");
21183
+ requestManifestPath = join15(runDirectory, "request-manifest.json");
21105
21184
  await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
21106
21185
  }
21107
21186
  const admitted = {
@@ -21126,7 +21205,7 @@ async function admitCollectorInvocation(options) {
21126
21205
  mediaKind: a.mediaKind
21127
21206
  }))
21128
21207
  };
21129
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21208
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21130
21209
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21131
21210
  sessionDirectory,
21132
21211
  sessionFile
@@ -21223,7 +21302,7 @@ function parseDoctorArgv(args) {
21223
21302
  }
21224
21303
  async function resolveDoctorCaseRunsPath(options) {
21225
21304
  const ledgerHome = resolveActivationLedgerHome(options.home);
21226
- const defaultRuns = join14(
21305
+ const defaultRuns = join15(
21227
21306
  activationBookDirectory(ledgerHome, options.bookKey),
21228
21307
  "issues",
21229
21308
  String(options.issueNumber),
@@ -21330,7 +21409,7 @@ async function admitDoctorInvocation(options) {
21330
21409
  { cause: error }
21331
21410
  );
21332
21411
  }
21333
- const attachmentsDirectory = join14(runDirectory, "attachments");
21412
+ const attachmentsDirectory = join15(runDirectory, "attachments");
21334
21413
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
21335
21414
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
21336
21415
  const attachments = await freezeAttachments(options.attachmentPaths ?? [], attachmentsDirectory);
@@ -21356,7 +21435,7 @@ async function admitDoctorInvocation(options) {
21356
21435
  mediaKind: a.mediaKind
21357
21436
  }))
21358
21437
  };
21359
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21438
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21360
21439
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21361
21440
  sessionDirectory,
21362
21441
  sessionFile
@@ -21488,7 +21567,7 @@ async function admitNotaryInvocation(options) {
21488
21567
  ...ticketFields,
21489
21568
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
21490
21569
  };
21491
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21570
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21492
21571
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21493
21572
  sessionDirectory,
21494
21573
  sessionFile
@@ -21590,7 +21669,7 @@ async function admitGleanerLeftInvocation(options) {
21590
21669
  attachments: [],
21591
21670
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
21592
21671
  };
21593
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21672
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21594
21673
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21595
21674
  sessionDirectory,
21596
21675
  sessionFile
@@ -21695,7 +21774,7 @@ async function admitReviewerInvocation(options) {
21695
21774
  role: "reviewer",
21696
21775
  home: options.home
21697
21776
  });
21698
- const attachmentsDirectory = join14(runDirectory, "attachments");
21777
+ const attachmentsDirectory = join15(runDirectory, "attachments");
21699
21778
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
21700
21779
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
21701
21780
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
@@ -21720,7 +21799,7 @@ async function admitReviewerInvocation(options) {
21720
21799
  mediaKind: a.mediaKind
21721
21800
  }))
21722
21801
  };
21723
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21802
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21724
21803
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21725
21804
  sessionDirectory,
21726
21805
  sessionFile
@@ -21847,7 +21926,7 @@ async function admitMergerInvocation(options) {
21847
21926
  role: "merger",
21848
21927
  home: options.home
21849
21928
  });
21850
- const attachmentsDirectory = join14(runDirectory, "attachments");
21929
+ const attachmentsDirectory = join15(runDirectory, "attachments");
21851
21930
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
21852
21931
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
21853
21932
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
@@ -21875,7 +21954,7 @@ async function admitMergerInvocation(options) {
21875
21954
  // Authorized checks remain available on the assignment; default none.
21876
21955
  authorizedChecks: []
21877
21956
  });
21878
- const mergerInputPath = join14(runDirectory, "merger-input.json");
21957
+ const mergerInputPath = join15(runDirectory, "merger-input.json");
21879
21958
  await writeFile4(
21880
21959
  mergerInputPath,
21881
21960
  `${JSON.stringify(mergerInput, null, 2)}
@@ -21907,7 +21986,7 @@ async function admitMergerInvocation(options) {
21907
21986
  mediaKind: a.mediaKind
21908
21987
  }))
21909
21988
  };
21910
- const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21989
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21911
21990
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21912
21991
  sessionDirectory,
21913
21992
  sessionFile
@@ -22200,7 +22279,7 @@ var init_invocation = __esm({
22200
22279
  // src/package-resources/method-skill.ts
22201
22280
  import { createHash as createHash4 } from "node:crypto";
22202
22281
  import { readFile as readFile10, realpath as realpath5 } from "node:fs/promises";
22203
- import { join as join15 } from "node:path";
22282
+ import { join as join16 } from "node:path";
22204
22283
  function gitBlobOid(bytes) {
22205
22284
  const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
22206
22285
  const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
@@ -22217,10 +22296,10 @@ function packagedMethodSkillRelativeDirectory(name) {
22217
22296
  return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
22218
22297
  }
22219
22298
  function resolvePackagedMethodSkillRoot(packageRoot2, name) {
22220
- return join15(packageRoot2, packagedMethodSkillRelativeDirectory(name));
22299
+ return join16(packageRoot2, packagedMethodSkillRelativeDirectory(name));
22221
22300
  }
22222
22301
  function resolvePackagedMethodSkillPath(packageRoot2, name) {
22223
- return join15(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
22302
+ return join16(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
22224
22303
  }
22225
22304
  function isRecord10(value) {
22226
22305
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -22314,8 +22393,8 @@ function parseProvenance(raw, expectedName) {
22314
22393
  }
22315
22394
  async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
22316
22395
  const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
22317
- const skillPathConfigured = join15(rootDirectory, "SKILL.md");
22318
- const provenancePath = join15(rootDirectory, "provenance.json");
22396
+ const skillPathConfigured = join16(rootDirectory, "SKILL.md");
22397
+ const provenancePath = join16(rootDirectory, "provenance.json");
22319
22398
  let provenanceRaw;
22320
22399
  try {
22321
22400
  provenanceRaw = await readFile10(provenancePath, "utf8");
@@ -22332,7 +22411,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
22332
22411
  }
22333
22412
  const provenance = parseProvenance(provenanceJson, name);
22334
22413
  for (const [rel, expected] of Object.entries(provenance.files)) {
22335
- const absolute = join15(rootDirectory, rel);
22414
+ const absolute = join16(rootDirectory, rel);
22336
22415
  let bytes;
22337
22416
  try {
22338
22417
  bytes = await readFile10(absolute);
@@ -22634,7 +22713,7 @@ var init_ledger_session_read = __esm({
22634
22713
 
22635
22714
  // src/analyst-gate-cycles-read.ts
22636
22715
  import { readdir as readdir3 } from "node:fs/promises";
22637
- import { join as join16 } from "node:path";
22716
+ import { join as join17 } from "node:path";
22638
22717
  function isRecord12(value) {
22639
22718
  return typeof value === "object" && value !== null && !Array.isArray(value);
22640
22719
  }
@@ -22896,7 +22975,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
22896
22975
  throw error;
22897
22976
  }
22898
22977
  for (const name of names) {
22899
- const path = join16(directory, name);
22978
+ const path = join17(directory, name);
22900
22979
  const fromPointer = name.endsWith(".pointer.json");
22901
22980
  const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
22902
22981
  if (sessionPath === void 0) continue;
@@ -22939,7 +23018,7 @@ var init_analyst_gate_cycles_read = __esm({
22939
23018
 
22940
23019
  // src/run-terminal-artifacts.ts
22941
23020
  import { readdir as readdir4, readFile as readFile12 } from "node:fs/promises";
22942
- import { basename as basename6, dirname as dirname8, join as join17 } from "node:path";
23021
+ import { basename as basename6, dirname as dirname8, join as join18 } from "node:path";
22943
23022
  function isMissingPathError2(error) {
22944
23023
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
22945
23024
  }
@@ -23014,7 +23093,7 @@ async function listUniqueErrorFallbackPaths(directories) {
23014
23093
  }
23015
23094
  for (const name of names.sort((a, b) => a.localeCompare(b))) {
23016
23095
  if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
23017
- found.push(join17(dir, name));
23096
+ found.push(join18(dir, name));
23018
23097
  }
23019
23098
  }
23020
23099
  return found;
@@ -23030,14 +23109,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
23030
23109
  return typeof body.runId === "string" && body.runId === expectedRunId;
23031
23110
  }
23032
23111
  async function readRunTerminalArtifact(runDirectory) {
23033
- const artifactsDir = join17(runDirectory, "artifacts");
23112
+ const artifactsDir = join18(runDirectory, "artifacts");
23034
23113
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
23035
- const path = join17(artifactsDir, file);
23114
+ const path = join18(artifactsDir, file);
23036
23115
  const read3 = await readTerminalArtifactAtPath(path, file);
23037
23116
  if (read3 !== void 0) return read3;
23038
23117
  }
23039
23118
  for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
23040
- const path = join17(runDirectory, relative3);
23119
+ const path = join18(runDirectory, relative3);
23041
23120
  const read3 = await readTerminalArtifactAtPath(path, "error.json");
23042
23121
  if (read3 !== void 0) return read3;
23043
23122
  }
@@ -23175,14 +23254,14 @@ var init_submission_ledger = __esm({
23175
23254
  });
23176
23255
 
23177
23256
  // src/session-opening-materials.ts
23178
- import { existsSync as existsSync6 } from "node:fs";
23257
+ import { existsSync as existsSync7 } from "node:fs";
23179
23258
  import { readFile as readFile13 } from "node:fs/promises";
23180
- import { dirname as dirname9, join as join18 } from "node:path";
23181
- import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
23259
+ import { dirname as dirname9, join as join19 } from "node:path";
23260
+ import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
23182
23261
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
23183
23262
  let dir = dirname9(fileURLToPath(moduleUrl));
23184
23263
  for (let i = 0; i < 8; i += 1) {
23185
- if (existsSync6(join18(dir, "package.json")) && existsSync6(join18(dir, "souls"))) {
23264
+ if (existsSync7(join19(dir, "package.json")) && existsSync7(join19(dir, "souls"))) {
23186
23265
  return dir;
23187
23266
  }
23188
23267
  const parent = dirname9(dir);
@@ -23206,7 +23285,7 @@ var init_session_opening_materials = __esm({
23206
23285
  "src/session-opening-materials.ts"() {
23207
23286
  "use strict";
23208
23287
  init_packaged_role_registry();
23209
- packageRootUrl = pathToFileURL2(resolvePackageRootDir() + "/").href;
23288
+ packageRootUrl = pathToFileURL3(resolvePackageRootDir() + "/").href;
23210
23289
  MAIN_ROLE_SESSION_MATERIALS = {
23211
23290
  ...Object.fromEntries(
23212
23291
  PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
@@ -23462,12 +23541,12 @@ var init_reviewer_dispatch = __esm({
23462
23541
 
23463
23542
  // src/public-cli/reviewer-dispatch-rejection.ts
23464
23543
  import { readFile as readFile14, unlink as unlink3 } from "node:fs/promises";
23465
- import { join as join19 } from "node:path";
23544
+ import { join as join20 } from "node:path";
23466
23545
  function isReviewerPreflightViolation(value) {
23467
23546
  return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
23468
23547
  }
23469
23548
  function reviewerDispatchRejectionPath(runDirectory) {
23470
- return join19(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
23549
+ return join20(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
23471
23550
  }
23472
23551
  async function clearReviewerDispatchRejection(runDirectory) {
23473
23552
  try {
@@ -23919,7 +23998,7 @@ var init_terminal = __esm({
23919
23998
  // src/public-cli/settlement.ts
23920
23999
  import { randomUUID as randomUUID3 } from "node:crypto";
23921
24000
  import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile5 } from "node:fs/promises";
23922
- import { dirname as dirname10, join as join20 } from "node:path";
24001
+ import { dirname as dirname10, join as join21 } from "node:path";
23923
24002
  function sealedLedgerHome(admitted) {
23924
24003
  return homeFromRunDirectory(admitted.runDirectory);
23925
24004
  }
@@ -24339,7 +24418,7 @@ async function readSessionProviderStop(sessionFile) {
24339
24418
  }
24340
24419
  }
24341
24420
  async function readBoundEvidenceChildKnownFailure(sessionFile) {
24342
- const childDirectory = join20(dirname10(sessionFile), "evidence-children");
24421
+ const childDirectory = join21(dirname10(sessionFile), "evidence-children");
24343
24422
  let names;
24344
24423
  try {
24345
24424
  names = await readdir5(childDirectory);
@@ -24350,7 +24429,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
24350
24429
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
24351
24430
  let entries;
24352
24431
  try {
24353
- entries = await readBoundSessionEntries(join20(childDirectory, file));
24432
+ entries = await readBoundSessionEntries(join21(childDirectory, file));
24354
24433
  } catch (error) {
24355
24434
  throw sessionReadFailure(error, "failed to read discovered evidence-child session");
24356
24435
  }
@@ -24404,7 +24483,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
24404
24483
  latestParentUserIndex = i;
24405
24484
  break;
24406
24485
  }
24407
- const childDirectories = [join20(dirname10(sessionFile), "auditor-roles")];
24486
+ const childDirectories = [join21(dirname10(sessionFile), "auditor-roles")];
24408
24487
  const valid = [];
24409
24488
  let sawAnyDirectory = false;
24410
24489
  for (const childDirectory of childDirectories) {
@@ -24419,7 +24498,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
24419
24498
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
24420
24499
  let entries;
24421
24500
  try {
24422
- entries = await readBoundSessionEntries(join20(childDirectory, file));
24501
+ entries = await readBoundSessionEntries(join21(childDirectory, file));
24423
24502
  } catch (error) {
24424
24503
  throw sessionReadFailure(error, "failed to read discovered auditor session");
24425
24504
  }
@@ -24967,8 +25046,8 @@ function projectTerminalGateFact(rounds) {
24967
25046
  };
24968
25047
  }
24969
25048
  async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
24970
- const directories = [join20(sessionDirectory, "auditor-roles")];
24971
- const parentSessionFile = options.parentSessionFile ?? join20(sessionDirectory, "session.jsonl");
25049
+ const directories = [join21(sessionDirectory, "auditor-roles")];
25050
+ const parentSessionFile = options.parentSessionFile ?? join21(sessionDirectory, "session.jsonl");
24972
25051
  const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
24973
25052
  parentSessionFile
24974
25053
  });
@@ -25066,8 +25145,8 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
25066
25145
  async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
25067
25146
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
25068
25147
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
25069
- const reportPath = join20(artifactsDir, "report.json");
25070
- const evidencePath = join20(artifactsDir, "evidence.json");
25148
+ const reportPath = join21(artifactsDir, "report.json");
25149
+ const evidencePath = join21(artifactsDir, "evidence.json");
25071
25150
  await writeFile5(
25072
25151
  reportPath,
25073
25152
  `${JSON.stringify(
@@ -25111,8 +25190,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
25111
25190
  async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
25112
25191
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
25113
25192
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
25114
- const reportPath = join20(artifactsDir, "report.json");
25115
- const evidencePath = join20(artifactsDir, "evidence.json");
25193
+ const reportPath = join21(artifactsDir, "report.json");
25194
+ const evidencePath = join21(artifactsDir, "evidence.json");
25116
25195
  await writeFile5(
25117
25196
  reportPath,
25118
25197
  `${JSON.stringify(
@@ -25263,8 +25342,8 @@ function extractFixerMethodInvocations(entries, options) {
25263
25342
  async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
25264
25343
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
25265
25344
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
25266
- const reportPath = join20(artifactsDir, "report.json");
25267
- const evidencePath = join20(artifactsDir, "evidence.json");
25345
+ const reportPath = join21(artifactsDir, "report.json");
25346
+ const evidencePath = join21(artifactsDir, "evidence.json");
25268
25347
  await writeFile5(
25269
25348
  reportPath,
25270
25349
  `${JSON.stringify(
@@ -25354,8 +25433,8 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options) {
25354
25433
  async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
25355
25434
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
25356
25435
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
25357
- const reportPath = join20(artifactsDir, "report.json");
25358
- const evidencePath = join20(artifactsDir, "evidence.json");
25436
+ const reportPath = join21(artifactsDir, "report.json");
25437
+ const evidencePath = join21(artifactsDir, "evidence.json");
25359
25438
  await writeFile5(
25360
25439
  reportPath,
25361
25440
  `${JSON.stringify(
@@ -25462,8 +25541,8 @@ async function trySettleCollectorTerminalResult(admitted, authority) {
25462
25541
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
25463
25542
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
25464
25543
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
25465
- const reportPath = join20(artifactsDir, "report.json");
25466
- const evidencePath = join20(artifactsDir, "evidence.json");
25544
+ const reportPath = join21(artifactsDir, "report.json");
25545
+ const evidencePath = join21(artifactsDir, "evidence.json");
25467
25546
  await writeFile5(
25468
25547
  reportPath,
25469
25548
  `${JSON.stringify(
@@ -25723,8 +25802,8 @@ function extractReviewerMethodInvocations(entries, options) {
25723
25802
  async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
25724
25803
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
25725
25804
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
25726
- const reportPath = join20(artifactsDir, "report.json");
25727
- const evidencePath = join20(artifactsDir, "evidence.json");
25805
+ const reportPath = join21(artifactsDir, "report.json");
25806
+ const evidencePath = join21(artifactsDir, "evidence.json");
25728
25807
  await writeFile5(
25729
25808
  reportPath,
25730
25809
  `${JSON.stringify(
@@ -25838,8 +25917,8 @@ function extractMergerMethodInvocations(entries, options) {
25838
25917
  async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
25839
25918
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
25840
25919
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
25841
- const reportPath = join20(artifactsDir, "report.json");
25842
- const evidencePath = join20(artifactsDir, "evidence.json");
25920
+ const reportPath = join21(artifactsDir, "report.json");
25921
+ const evidencePath = join21(artifactsDir, "evidence.json");
25843
25922
  await writeFile5(
25844
25923
  reportPath,
25845
25924
  `${JSON.stringify(
@@ -25984,7 +26063,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
25984
26063
  return dirs;
25985
26064
  }
25986
26065
  async function resolveFailureArtifactsBase(runDirectory) {
25987
- const artifactsDir = join20(runDirectory, "artifacts");
26066
+ const artifactsDir = join21(runDirectory, "artifacts");
25988
26067
  try {
25989
26068
  await ensureRunArtifactsDir(runDirectory);
25990
26069
  return { baseDir: artifactsDir };
@@ -26000,7 +26079,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
26000
26079
  const candidates = [
26001
26080
  ...preferredCandidates,
26002
26081
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
26003
- ...uniqueFallbackDirs.map((dir) => join20(dir, `${stem}.${randomUUID3()}.json`))
26082
+ ...uniqueFallbackDirs.map((dir) => join21(dir, `${stem}.${randomUUID3()}.json`))
26004
26083
  ];
26005
26084
  for (let i = 0; i < candidates.length; i += 1) {
26006
26085
  const path = candidates[i];
@@ -26045,26 +26124,26 @@ async function publishFailureArtifacts(admitted, failure, authority) {
26045
26124
  } catch (error) {
26046
26125
  priorIssues.push(publicationAttemptFromError(sessionFile, error));
26047
26126
  }
26048
- const underArtifacts = baseDir === join20(admitted.runDirectory, "artifacts");
26127
+ const underArtifacts = baseDir === join21(admitted.runDirectory, "artifacts");
26049
26128
  const uniqueFallbackDirs = uniqueFailureFallbackDirs(
26050
26129
  admitted.runDirectory,
26051
26130
  baseDir
26052
26131
  );
26053
26132
  const errorCandidates = underArtifacts ? [
26054
- join20(baseDir, "error.json"),
26055
- join20(baseDir, "error.settlement.json"),
26056
- join20(admitted.runDirectory, "error.settlement.json")
26133
+ join21(baseDir, "error.json"),
26134
+ join21(baseDir, "error.settlement.json"),
26135
+ join21(admitted.runDirectory, "error.settlement.json")
26057
26136
  ] : [
26058
- join20(baseDir, "error.settlement.json"),
26059
- join20(baseDir, "error.json")
26137
+ join21(baseDir, "error.settlement.json"),
26138
+ join21(baseDir, "error.json")
26060
26139
  ];
26061
26140
  const evidenceCandidates = underArtifacts ? [
26062
- join20(baseDir, "evidence.json"),
26063
- join20(baseDir, "evidence.settlement.json"),
26064
- join20(admitted.runDirectory, "evidence.settlement.json")
26141
+ join21(baseDir, "evidence.json"),
26142
+ join21(baseDir, "evidence.settlement.json"),
26143
+ join21(admitted.runDirectory, "evidence.settlement.json")
26065
26144
  ] : [
26066
- join20(baseDir, "evidence.settlement.json"),
26067
- join20(baseDir, "evidence.json")
26145
+ join21(baseDir, "evidence.settlement.json"),
26146
+ join21(baseDir, "evidence.json")
26068
26147
  ];
26069
26148
  const errorPayloadBase = {
26070
26149
  kind: "error",
@@ -26366,7 +26445,7 @@ var init_ticket_provenance_contracts = __esm({
26366
26445
  });
26367
26446
 
26368
26447
  // src/ticket-provenance.ts
26369
- import { join as join21 } from "node:path";
26448
+ import { join as join22 } from "node:path";
26370
26449
  function ticketProvenanceSubject(ticketNumber) {
26371
26450
  if (!Number.isSafeInteger(ticketNumber) || ticketNumber < 1) {
26372
26451
  throw new Error(`ticket-provenance subject requires a positive ticket number, got ${String(ticketNumber)}`);
@@ -26384,7 +26463,7 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
26384
26463
  return {
26385
26464
  recordFile: path.recordFile,
26386
26465
  volumeDir: path.sessionDir,
26387
- humanViewFile: join21(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW)
26466
+ humanViewFile: join22(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW)
26388
26467
  };
26389
26468
  }
26390
26469
  var init_ticket_provenance = __esm({
@@ -26434,7 +26513,7 @@ var init_case_dossier_delivery = __esm({
26434
26513
 
26435
26514
  // src/host-transition-prior-native.ts
26436
26515
  import { access as access2, readdir as readdir6 } from "node:fs/promises";
26437
- import { dirname as dirname11, join as join22 } from "node:path";
26516
+ import { dirname as dirname11, join as join23 } from "node:path";
26438
26517
  function isEnoent2(error) {
26439
26518
  return typeof error === "object" && error !== null && error.code === "ENOENT";
26440
26519
  }
@@ -26459,7 +26538,7 @@ async function listSitianRecordPaths(sessionParent) {
26459
26538
  const recordPaths = [];
26460
26539
  for (const entry of entries) {
26461
26540
  if (!entry.isDirectory()) continue;
26462
- const recordFile = join22(sessionRoot, entry.name, "records.jsonl");
26541
+ const recordFile = join23(sessionRoot, entry.name, "records.jsonl");
26463
26542
  try {
26464
26543
  await access2(recordFile);
26465
26544
  recordPaths.push(recordFile);
@@ -26529,7 +26608,7 @@ var init_public_run_credentials = __esm({
26529
26608
  import { constants as fsConstants } from "node:fs";
26530
26609
  import { randomUUID as randomUUID4 } from "node:crypto";
26531
26610
  import { lstat as lstat5, mkdir as mkdir4, open as open2 } from "node:fs/promises";
26532
- import { join as join23 } from "node:path";
26611
+ import { join as join24 } from "node:path";
26533
26612
  function presentTerminal(terminal, io) {
26534
26613
  if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
26535
26614
  presentFailureTerminal(terminal, io);
@@ -26548,7 +26627,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
26548
26627
  }
26549
26628
  }
26550
26629
  function runArtifactsDirectory(runDirectory) {
26551
- return join23(runDirectory, "artifacts");
26630
+ return join24(runDirectory, "artifacts");
26552
26631
  }
26553
26632
  async function ensureRealArtifactsDirectory(runDirectory) {
26554
26633
  const runStat = await lstat5(runDirectory);
@@ -26631,7 +26710,7 @@ function jsonSafeReplacer() {
26631
26710
  }
26632
26711
  async function retainDispatchError(admitted, principalAuthority, sessionAppender, attempt, error) {
26633
26712
  const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
26634
- const filePath = join23(
26713
+ const filePath = join24(
26635
26714
  artifactsDir,
26636
26715
  `dispatch-error-attempt-${attempt}-${randomUUID4()}.json`
26637
26716
  );
@@ -26880,7 +26959,7 @@ var init_auto_resume = __esm({
26880
26959
  // src/public-cli/post-admission.ts
26881
26960
  import { randomUUID as randomUUID5 } from "node:crypto";
26882
26961
  import { readFile as readFile16, writeFile as writeFile6 } from "node:fs/promises";
26883
- import { isAbsolute as isAbsolute7, join as join24, resolve as resolve8 } from "node:path";
26962
+ import { isAbsolute as isAbsolute7, join as join25, resolve as resolve8 } from "node:path";
26884
26963
  function appendContinuationSection(continuation, section) {
26885
26964
  const prompt = `${continuation.prompt}
26886
26965
 
@@ -26889,7 +26968,7 @@ ${section}`;
26889
26968
  }
26890
26969
  async function readInvocationHost(runDirectory) {
26891
26970
  try {
26892
- const raw = JSON.parse(await readFile16(join24(runDirectory, "invocation.json"), "utf8"));
26971
+ const raw = JSON.parse(await readFile16(join25(runDirectory, "invocation.json"), "utf8"));
26893
26972
  return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
26894
26973
  } catch (error) {
26895
26974
  if (error.code === "ENOENT") return void 0;
@@ -27043,7 +27122,7 @@ async function dispatchPostAdmissionTurn(input) {
27043
27122
  }
27044
27123
  try {
27045
27124
  await writeFile6(
27046
- join24(admitted.runDirectory, "stderr.log"),
27125
+ join25(admitted.runDirectory, "stderr.log"),
27047
27126
  result2.stderr,
27048
27127
  "utf8"
27049
27128
  );
@@ -27152,7 +27231,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
27152
27231
  }
27153
27232
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
27154
27233
  const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve8(attachmentPath);
27155
- return pathContainedIn(join24(runDirectory, "attachments"), absolute);
27234
+ return pathContainedIn(join25(runDirectory, "attachments"), absolute);
27156
27235
  }
27157
27236
  async function prepareSummonsResumeMaterials(runDirectory, summons) {
27158
27237
  if (summons === void 0) return void 0;
@@ -29321,7 +29400,7 @@ var init_judge_run = __esm({
29321
29400
 
29322
29401
  // src/public-cli/merger-run.ts
29323
29402
  import { mkdir as mkdir5, writeFile as writeFile7 } from "node:fs/promises";
29324
- import { join as join25, resolve as resolve9 } from "node:path";
29403
+ import { join as join26, resolve as resolve9 } from "node:path";
29325
29404
  function mergerMethods(packageRoot2) {
29326
29405
  return [
29327
29406
  {
@@ -29387,8 +29466,8 @@ async function admitMergerShellForActivationFailure(options) {
29387
29466
  expectedConflictPaths: [],
29388
29467
  resolutionScope: []
29389
29468
  };
29390
- const admittedRequestPath = join25(runDirectory, "admitted-request.json");
29391
- const mergerInputPath = join25(runDirectory, "merger-input.json");
29469
+ const admittedRequestPath = join26(runDirectory, "admitted-request.json");
29470
+ const mergerInputPath = join26(runDirectory, "merger-input.json");
29392
29471
  await writeFile7(
29393
29472
  admittedRequestPath,
29394
29473
  `${JSON.stringify(
@@ -29828,10 +29907,10 @@ var init_analyst_book_key = __esm({
29828
29907
  // src/atomic-write.ts
29829
29908
  import { randomUUID as randomUUID6 } from "node:crypto";
29830
29909
  import { rename, rm, writeFile as writeFile8 } from "node:fs/promises";
29831
- import { dirname as dirname12, join as join26 } from "node:path";
29910
+ import { dirname as dirname12, join as join27 } from "node:path";
29832
29911
  async function writeFileAtomically(destination, contents) {
29833
29912
  const parent = dirname12(destination);
29834
- const temporary = join26(parent, `.atomic-write-${randomUUID6()}.tmp`);
29913
+ const temporary = join27(parent, `.atomic-write-${randomUUID6()}.tmp`);
29835
29914
  try {
29836
29915
  await writeFile8(temporary, contents);
29837
29916
  await rename(temporary, destination);
@@ -29848,7 +29927,7 @@ var init_atomic_write = __esm({
29848
29927
 
29849
29928
  // src/analyst-index.ts
29850
29929
  import { open as open3, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
29851
- import { dirname as dirname13, join as join27 } from "node:path";
29930
+ import { dirname as dirname13, join as join28 } from "node:path";
29852
29931
  function sleep(ms) {
29853
29932
  return new Promise((resolve11) => {
29854
29933
  setTimeout(resolve11, ms);
@@ -29857,7 +29936,7 @@ function sleep(ms) {
29857
29936
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
29858
29937
  const indexPath = analystLibraryIndexPath(ledgerHome);
29859
29938
  ensureRealDirectoryTree(ledgerHome, dirname13(indexPath));
29860
- const lockPath = join27(dirname13(indexPath), LIBRARY_INDEX_LOCK_NAME);
29939
+ const lockPath = join28(dirname13(indexPath), LIBRARY_INDEX_LOCK_NAME);
29861
29940
  assertLedgerFileInsideHome(lockPath, ledgerHome);
29862
29941
  const startedAt = Date.now();
29863
29942
  while (true) {
@@ -29884,7 +29963,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
29884
29963
  }
29885
29964
  }
29886
29965
  function analystLibraryIndexPath(ledgerHome) {
29887
- return join27(ledgerHome, "analyst", "library-index.json");
29966
+ return join28(ledgerHome, "analyst", "library-index.json");
29888
29967
  }
29889
29968
  function rowFromIssueMetricsPage(page) {
29890
29969
  return {
@@ -30180,7 +30259,7 @@ var init_analyst_cohort = __esm({
30180
30259
 
30181
30260
  // src/analyst-ledger.ts
30182
30261
  import { readdir as readdir7, readFile as readFile18 } from "node:fs/promises";
30183
- import { join as join28 } from "node:path";
30262
+ import { join as join29 } from "node:path";
30184
30263
  function isMissingPathError5(error) {
30185
30264
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
30186
30265
  }
@@ -30193,7 +30272,7 @@ function isRecord16(value) {
30193
30272
  async function readExistingRunLifecycleState(runDirectory) {
30194
30273
  try {
30195
30274
  const raw = JSON.parse(
30196
- await readFile18(join28(runDirectory, "run-state.json"), "utf8")
30275
+ await readFile18(join29(runDirectory, "run-state.json"), "utf8")
30197
30276
  );
30198
30277
  if (!isRecord16(raw) || typeof raw.state !== "string") return void 0;
30199
30278
  return raw.state;
@@ -30225,7 +30304,7 @@ async function listLedgerBookNames(booksRoot) {
30225
30304
  async function readInvocationScopeFields(runDirectory) {
30226
30305
  let raw;
30227
30306
  try {
30228
- raw = await readFile18(join28(runDirectory, "invocation.json"), "utf8");
30307
+ raw = await readFile18(join29(runDirectory, "invocation.json"), "utf8");
30229
30308
  } catch (error) {
30230
30309
  if (isMissingPathError5(error)) return void 0;
30231
30310
  throw error;
@@ -30257,7 +30336,7 @@ function decideIssueScope(input) {
30257
30336
  }
30258
30337
  async function resolveSessionFile(runDirectory) {
30259
30338
  try {
30260
- const raw = await readFile18(join28(runDirectory, "invocation.json"), "utf8");
30339
+ const raw = await readFile18(join29(runDirectory, "invocation.json"), "utf8");
30261
30340
  const parsed = JSON.parse(raw);
30262
30341
  if (isRecord16(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
30263
30342
  return parsed.sessionFile;
@@ -30265,7 +30344,7 @@ async function resolveSessionFile(runDirectory) {
30265
30344
  } catch (error) {
30266
30345
  if (!isMissingPathError5(error)) throw error;
30267
30346
  }
30268
- return join28(runDirectory, "session", "session.jsonl");
30347
+ return join29(runDirectory, "session", "session.jsonl");
30269
30348
  }
30270
30349
  function attributeSessionRowsForRun(input) {
30271
30350
  if (pathContainedIn(input.runDirectory, input.sessionFile)) {
@@ -30437,9 +30516,9 @@ async function classifyScopedRun(input) {
30437
30516
  }
30438
30517
  let gateCycles;
30439
30518
  try {
30440
- const parentSessionFile = join28(input.runDirectory, "session", "session.jsonl");
30519
+ const parentSessionFile = join29(input.runDirectory, "session", "session.jsonl");
30441
30520
  gateCycles = await readAnalystGateCyclesFromAuditorRoles(
30442
- join28(input.runDirectory, "session", "auditor-roles"),
30521
+ join29(input.runDirectory, "session", "auditor-roles"),
30443
30522
  { parentSessionFile }
30444
30523
  );
30445
30524
  } catch (error) {
@@ -30472,7 +30551,7 @@ async function classifyScopedRun(input) {
30472
30551
  async function scanAnalystIssueRuns(input) {
30473
30552
  const ledgerHome = resolveActivationLedgerHome(input.home);
30474
30553
  const scopeTicketNumber = input.ticketNumber;
30475
- const booksRoot = join28(ledgerHome, "books");
30554
+ const booksRoot = join29(ledgerHome, "books");
30476
30555
  let wholeBook = false;
30477
30556
  let scopeRootIdentity;
30478
30557
  let bookNames;
@@ -30504,7 +30583,7 @@ async function scanAnalystIssueRuns(input) {
30504
30583
  const unreadable = [];
30505
30584
  const scopeConflicts = [];
30506
30585
  for (const book of bookNames) {
30507
- const runsDir = join28(booksRoot, book, "runs");
30586
+ const runsDir = join29(booksRoot, book, "runs");
30508
30587
  let runNames;
30509
30588
  try {
30510
30589
  const entries = await readdir7(runsDir, { withFileTypes: true });
@@ -30516,7 +30595,7 @@ async function scanAnalystIssueRuns(input) {
30516
30595
  for (const runName of runNames) {
30517
30596
  const parsed = parseRunDirectoryName2(runName);
30518
30597
  if (parsed === void 0) continue;
30519
- const runDirectory = join28(runsDir, runName);
30598
+ const runDirectory = join29(runsDir, runName);
30520
30599
  let scopeFields;
30521
30600
  try {
30522
30601
  scopeFields = await readInvocationScopeFields(runDirectory);
@@ -31370,7 +31449,7 @@ var init_analyst_metric_family = __esm({
31370
31449
 
31371
31450
  // src/analyst-page.ts
31372
31451
  import { createHash as createHash5 } from "node:crypto";
31373
- import { dirname as dirname14, join as join29 } from "node:path";
31452
+ import { dirname as dirname14, join as join30 } from "node:path";
31374
31453
  function analystIssuePageKey(address) {
31375
31454
  const parts = ["book", address.bookKey];
31376
31455
  if (address.issueNumber !== void 0) {
@@ -31381,7 +31460,7 @@ function analystIssuePageKey(address) {
31381
31460
  return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
31382
31461
  }
31383
31462
  function analystIssuePagePath(ledgerHome, address) {
31384
- return join29(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
31463
+ return join30(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
31385
31464
  }
31386
31465
  function analystIssuePageAddressFromPage(page) {
31387
31466
  return {
@@ -31914,7 +31993,7 @@ __export(cli_exports, {
31914
31993
  runAkRole: () => runAkRole
31915
31994
  });
31916
31995
  import { realpath as realpath6 } from "node:fs/promises";
31917
- import { join as join30 } from "node:path";
31996
+ import { join as join31 } from "node:path";
31918
31997
  function takePublicGlobalFlag(argv, index, options) {
31919
31998
  const tokens = argv.slice(index);
31920
31999
  const taken = options.takeDashed(tokens);
@@ -31966,7 +32045,7 @@ function resolveRoleTurnHost(env, options) {
31966
32045
  ok: true,
31967
32046
  host: {
31968
32047
  executeTurn: async (request) => {
31969
- hostPromise ??= loadProductionAcpHostFactory(env.packageRoot, name).then(
32048
+ hostPromise ??= loadProductionExternalHostFactory(env.packageRoot, name).then(
31970
32049
  (create) => create({
31971
32050
  packageRoot: env.packageRoot,
31972
32051
  principalAuthority: options.principalAuthority
@@ -32053,7 +32132,7 @@ function resolveHome(env) {
32053
32132
  return env.home ?? packageMachineHome();
32054
32133
  }
32055
32134
  function resolveAgentDir(env, home) {
32056
- return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join30(home, ".pi", "agent");
32135
+ return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join31(home, ".pi", "agent");
32057
32136
  }
32058
32137
  function parseThinking(value) {
32059
32138
  return value;
@@ -32946,7 +33025,7 @@ var init_cli = __esm({
32946
33025
  init_registry2();
32947
33026
  init_cli_errors();
32948
33027
  init_host_descriptions();
32949
- init_load_production_acp_host();
33028
+ init_load_production_external_host();
32950
33029
  init_role_turn_host();
32951
33030
  init_invocation();
32952
33031
  init_option_definitions();
@@ -33017,8 +33096,8 @@ var init_cli = __esm({
33017
33096
  });
33018
33097
 
33019
33098
  // src/public-cli/main.ts
33020
- import { existsSync as existsSync7 } from "node:fs";
33021
- import { dirname as dirname15, join as join31 } from "node:path";
33099
+ import { existsSync as existsSync8 } from "node:fs";
33100
+ import { dirname as dirname15, join as join32 } from "node:path";
33022
33101
  import { fileURLToPath as fileURLToPath2 } from "node:url";
33023
33102
 
33024
33103
  // src/public-cli/host-pi-runtime.ts
@@ -33107,13 +33186,14 @@ function linkPackage(packageRoot2, name, targetDir) {
33107
33186
  // src/public-cli/main.ts
33108
33187
  var here = dirname15(fileURLToPath2(import.meta.url));
33109
33188
  function resolvePackageRoot(binDir) {
33110
- const canonical = join31(binDir, "..", "..");
33111
- if (existsSync7(join31(canonical, "package.json"))) {
33189
+ const canonical = join32(binDir, "..", "..");
33190
+ if (existsSync8(join32(canonical, "package.json"))) {
33112
33191
  return canonical;
33113
33192
  }
33114
33193
  return binDir;
33115
33194
  }
33116
33195
  var packageRoot = resolvePackageRoot(here);
33196
+ process.env.AK_ROLE_PACKAGE_ROOT = packageRoot;
33117
33197
  ensureHostPiRuntimeResolvable(packageRoot);
33118
33198
  var { runAkRole: runAkRole2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
33119
33199
  var result = await runAkRole2(process.argv.slice(2), { packageRoot });