@akagilnc/pi-workflow-roles 0.1.5583 → 0.1.5593

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.
@@ -1200,7 +1200,7 @@ async function runEngineDetourOnce(input) {
1200
1200
  }
1201
1201
  const command = input.argv[0];
1202
1202
  const args = input.argv.slice(1);
1203
- return await new Promise((resolve22, reject) => {
1203
+ return await new Promise((resolve21, reject) => {
1204
1204
  let settled = false;
1205
1205
  const signal = input.signal;
1206
1206
  const child = spawn(command, args, {
@@ -1230,7 +1230,7 @@ async function runEngineDetourOnce(input) {
1230
1230
  if (signal !== void 0) {
1231
1231
  signal.removeEventListener("abort", onAbort);
1232
1232
  }
1233
- resolve22(result);
1233
+ resolve21(result);
1234
1234
  };
1235
1235
  const onAbort = () => {
1236
1236
  fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
@@ -2825,19 +2825,7 @@ var init_cli_errors = __esm({
2825
2825
  }
2826
2826
  });
2827
2827
 
2828
- // src/sha256.ts
2829
- import { createHash } from "node:crypto";
2830
- function sha256Hex(bytes) {
2831
- return createHash("sha256").update(bytes).digest("hex");
2832
- }
2833
- var init_sha256 = __esm({
2834
- "src/sha256.ts"() {
2835
- "use strict";
2836
- }
2837
- });
2838
-
2839
2828
  // src/collector-config.ts
2840
- import { readFile as readFile3 } from "node:fs/promises";
2841
2829
  function fail3(message, cause) {
2842
2830
  throw new Error(message, cause === void 0 ? void 0 : { cause });
2843
2831
  }
@@ -2865,47 +2853,10 @@ function parseCollectorPrNumber(raw) {
2865
2853
  if (value === void 0) fail3(typeof raw === "string" && !isTicketNumberString(raw) ? "Collector pull request number must be a positive safe integer string" : "Collector pull request number must be a positive safe integer");
2866
2854
  return value;
2867
2855
  }
2868
- function canonicalManifest(requests) {
2869
- return `${JSON.stringify({ requests: requests.map((request) => ({ id: request.id, body: request.requestBody })) })}
2870
- `;
2871
- }
2872
- function emptyCollectorManifest() {
2873
- const canonicalJson2 = canonicalManifest([]);
2874
- return { requests: [], canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2) };
2875
- }
2876
- async function loadCollectorManifest(path) {
2877
- let bytes;
2878
- try {
2879
- bytes = await readFile3(path);
2880
- } catch (error) {
2881
- fail3(`Collector request manifest is unreadable at ${path}`, error);
2882
- }
2883
- let parsed;
2884
- try {
2885
- parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
2886
- } catch (error) {
2887
- fail3("Collector request manifest must be UTF-8 JSON", error);
2888
- }
2889
- if (!isRecord(parsed)) fail3("Collector request manifest must be an object");
2890
- const rawRequests = parsed.requests ?? [];
2891
- if (!Array.isArray(rawRequests)) fail3("Collector request manifest requests must be an array");
2892
- const requests = [];
2893
- const ids = /* @__PURE__ */ new Set();
2894
- for (const [index, item] of rawRequests.entries()) {
2895
- if (!isRecord(item) || typeof item.id !== "string" || item.id.length === 0 || typeof item.body !== "string" || item.body.trim() === "") fail3(`Collector request manifest requests[${index}] is invalid`);
2896
- if (ids.has(item.id)) fail3(`Collector request manifest has duplicate request id "${item.id}"`);
2897
- ids.add(item.id);
2898
- requests.push({ id: item.id, requestBody: item.body });
2899
- }
2900
- const canonicalJson2 = canonicalManifest(requests);
2901
- return { requests, canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2), sourcePath: path };
2902
- }
2903
2856
  var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
2904
2857
  var init_collector_config = __esm({
2905
2858
  "src/collector-config.ts"() {
2906
2859
  "use strict";
2907
- init_sha256();
2908
- init_unknown_value();
2909
2860
  init_run_ticket_number();
2910
2861
  COLLECTOR_OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
2911
2862
  COLLECTOR_REPO_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/;
@@ -3578,13 +3529,13 @@ var init_gatekeeper_role = __esm({
3578
3529
  });
3579
3530
 
3580
3531
  // src/ledger-session-read.ts
3581
- import { readFile as readFile4 } from "node:fs/promises";
3532
+ import { readFile as readFile3 } from "node:fs/promises";
3582
3533
  async function readStrictPiSessionJsonl(path) {
3583
- const text = await readFile4(path, "utf8");
3534
+ const text = await readFile3(path, "utf8");
3584
3535
  return text.trim().split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
3585
3536
  }
3586
3537
  async function readLedgerSessionJsonlLines(path) {
3587
- const text = await readFile4(path, "utf8");
3538
+ const text = await readFile3(path, "utf8");
3588
3539
  const lines = text.split("\n");
3589
3540
  const out = [];
3590
3541
  for (let index = 0; index < lines.length; index += 1) {
@@ -4997,6 +4948,17 @@ var init_dossier_resolution = __esm({
4997
4948
  }
4998
4949
  });
4999
4950
 
4951
+ // src/sha256.ts
4952
+ import { createHash } from "node:crypto";
4953
+ function sha256Hex(bytes) {
4954
+ return createHash("sha256").update(bytes).digest("hex");
4955
+ }
4956
+ var init_sha256 = __esm({
4957
+ "src/sha256.ts"() {
4958
+ "use strict";
4959
+ }
4960
+ });
4961
+
5000
4962
  // src/package-contracts/terminating-tools.ts
5001
4963
  function isTerminatingToolName(name) {
5002
4964
  return TERMINATING_TOOL_NAMES.includes(name);
@@ -5058,7 +5020,7 @@ var init_terminating_tools = __esm({
5058
5020
  });
5059
5021
 
5060
5022
  // src/doctor-evidence.ts
5061
- import { readdir as readdir2, readFile as readFile5, realpath, stat } from "node:fs/promises";
5023
+ import { readdir as readdir2, readFile as readFile4, realpath, stat } from "node:fs/promises";
5062
5024
  import { dirname as dirname6, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
5063
5025
  async function discoverCaseFiles(root) {
5064
5026
  const found = [];
@@ -5171,7 +5133,7 @@ async function loadDoctorCase(runsPath, projectRoot) {
5171
5133
  const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
5172
5134
  for (const path of await discoverCaseFiles(root)) {
5173
5135
  const id = relative2(root, path).split(sep2).join("/");
5174
- const bytes = await readFile5(path);
5136
+ const bytes = await readFile4(path);
5175
5137
  const content = bytes.toString("utf8");
5176
5138
  const kind = id.split("/").length === 2 && id.endsWith("/log.jsonl") ? "log" : "session";
5177
5139
  evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
@@ -5249,7 +5211,7 @@ var init_git_object_id = __esm({
5249
5211
 
5250
5212
  // src/merger-git-state.ts
5251
5213
  import { execFile } from "node:child_process";
5252
- import { access, readFile as readFile6 } from "node:fs/promises";
5214
+ import { access, readFile as readFile5 } from "node:fs/promises";
5253
5215
  import { constants as fsConstants } from "node:fs";
5254
5216
  import { isAbsolute as isAbsolute3, resolve as resolve6 } from "node:path";
5255
5217
  import { promisify } from "node:util";
@@ -5319,7 +5281,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
5319
5281
  const mergeHeadPath = isAbsolute3(mergeHeadReported) ? mergeHeadReported : resolve6(repositoryRoot, mergeHeadReported);
5320
5282
  let sourceObjectId = "";
5321
5283
  if (await pathExists(mergeHeadPath)) {
5322
- const raw = exactUtf8(await readFile6(mergeHeadPath), "Git MERGE_HEAD");
5284
+ const raw = exactUtf8(await readFile5(mergeHeadPath), "Git MERGE_HEAD");
5323
5285
  const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
5324
5286
  if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
5325
5287
  if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
@@ -5465,7 +5427,7 @@ var init_session_dialogue = __esm({
5465
5427
  });
5466
5428
 
5467
5429
  // src/ticket-provenance.ts
5468
- import { readFile as readFile7 } from "node:fs/promises";
5430
+ import { readFile as readFile6 } from "node:fs/promises";
5469
5431
  import { join as join9, resolve as resolve7 } from "node:path";
5470
5432
  function dialogueSessionSourceRoots(home) {
5471
5433
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
@@ -5513,7 +5475,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
5513
5475
  const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
5514
5476
  let history;
5515
5477
  try {
5516
- history = await readFile7(join9(runDirectory, RUN_HISTORY_FILE), "utf8");
5478
+ history = await readFile6(join9(runDirectory, RUN_HISTORY_FILE), "utf8");
5517
5479
  } catch (error) {
5518
5480
  if (errnoCode(error) === "ENOENT") return;
5519
5481
  throw error;
@@ -6356,8 +6318,8 @@ var init_option_definitions = __esm({
6356
6318
  repeatable: true,
6357
6319
  form: "option",
6358
6320
  description: {
6359
- en: "Attach a regular file; frozen at admission (repeatable).",
6360
- zh: "\u9644\u52A0\u666E\u901A\u6587\u4EF6\uFF1B\u53D7\u7406\u5373\u51BB\u7ED3\uFF08\u53EF\u91CD\u590D\uFF09\u3002"
6321
+ en: "Caller file path passed as-is to the role (repeatable). Package does not read, copy, or validate; use an absolute path when cwd differs from --project.",
6322
+ zh: "\u8C03\u7528\u65B9\u6587\u4EF6\u8DEF\u5F84\u539F\u6837\u9012\u7ED9\u8859\u95E8\uFF08\u53EF\u91CD\u590D\uFF09\u3002\u5305\u4E0D\u8BFB\u3001\u4E0D\u590D\u5236\u3001\u4E0D\u6821\u9A8C\uFF1B\u8C03\u7528\u65B9\u5F53\u524D\u76EE\u5F55\u4E0E --project \u4E0D\u540C\u65F6\u8BF7\u7ED9\u7EDD\u5BF9\u8DEF\u5F84\u3002"
6361
6323
  }
6362
6324
  };
6363
6325
  SHARED_PHASE_SEMANTICS = {
@@ -6532,8 +6494,8 @@ var init_option_definitions = __esm({
6532
6494
  repeatable: false,
6533
6495
  form: "option",
6534
6496
  description: {
6535
- en: "Optional request manifest JSON path ({requests:[{id,body}]}). Parsed for semantics and passed to the Collector as materials \u2014 not a machine collection directive.",
6536
- zh: "\u53EF\u9009 request manifest JSON \u8DEF\u5F84\uFF08{requests:[{id,body}]}\uFF09\u3002\u6309\u8BED\u4E49\u89E3\u6790\u540E\u4F5C\u4E3A\u6750\u6599\u9012\u7ED9\u901A\u8FDB\u53F8\uFF0C\u4E0D\u662F\u673A\u5668\u4EE3\u6536 finding \u7684\u6307\u4EE4\u3002"
6497
+ en: "Caller path to a request manifest JSON file, passed as-is. Package does not read, copy, or validate; use an absolute path when cwd differs from --project.",
6498
+ zh: "\u8C03\u7528\u65B9 request manifest JSON \u8DEF\u5F84\uFF0C\u539F\u6837\u4F20\u9012\u3002\u5305\u4E0D\u8BFB\u3001\u4E0D\u590D\u5236\u3001\u4E0D\u6821\u9A8C\uFF1B\u8C03\u7528\u65B9\u5F53\u524D\u76EE\u5F55\u4E0E --project \u4E0D\u540C\u65F6\u8BF7\u7ED9\u7EDD\u5BF9\u8DEF\u5F84\u3002"
6537
6499
  }
6538
6500
  }
6539
6501
  ];
@@ -6992,16 +6954,22 @@ var init_option_definitions = __esm({
6992
6954
  import { execFileSync as execFileSync2 } from "node:child_process";
6993
6955
  import { existsSync as existsSync3 } from "node:fs";
6994
6956
  import {
6995
- lstat as lstat2,
6996
- mkdtemp,
6997
- readFile as readFile8,
6957
+ readFile as readFile7,
6998
6958
  realpath as realpath3,
6999
6959
  rename,
7000
- rm,
7001
6960
  writeFile
7002
6961
  } from "node:fs/promises";
7003
- import { tmpdir } from "node:os";
7004
- import { basename as basename8, dirname as dirname8, isAbsolute as isAbsolute5, join as join11, resolve as resolve9 } from "node:path";
6962
+ import { dirname as dirname8, isAbsolute as isAbsolute5, join as join11, resolve as resolve9 } from "node:path";
6963
+ function normalizeAdmittedAttachment(raw) {
6964
+ if (typeof raw !== "object" || raw === null) return void 0;
6965
+ const record = raw;
6966
+ const path = record.path;
6967
+ if (typeof path === "string") return { path };
6968
+ return void 0;
6969
+ }
6970
+ function admitCallerAttachments(attachmentPaths) {
6971
+ return attachmentPaths.map((path) => ({ path }));
6972
+ }
7005
6973
  function issueAdmissionPlacement(authority, request) {
7006
6974
  const ledgerHome = resolveActivationLedgerHome(request.home);
7007
6975
  const bookKey = resolveBookKeyFromGit(request.cwd);
@@ -7180,19 +7148,11 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
7180
7148
  "taskPath",
7181
7149
  "packetPath",
7182
7150
  "prerequisitesPath",
7183
- "requestManifestPath",
7184
7151
  "mergerInputPath"
7185
7152
  ],
7186
7153
  oldRunDirectory,
7187
7154
  target.runDirectory
7188
7155
  );
7189
- for (const attachment of admitted.attachments) {
7190
- attachment.frozenPath = rewriteRunDirectoryPathValue(
7191
- attachment.frozenPath,
7192
- oldRunDirectory,
7193
- target.runDirectory
7194
- );
7195
- }
7196
7156
  admitted.principal = principal;
7197
7157
  renderCurrentSync(target.runDirectory);
7198
7158
  return { oldRunDirectory, newRunDirectory: target.runDirectory };
@@ -7229,7 +7189,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
7229
7189
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
7230
7190
  const rolePackageRoot = packageRoot;
7231
7191
  const raw = JSON.parse(
7232
- await readFile8(join11(rolePackageRoot, "package.json"), "utf8")
7192
+ await readFile7(join11(rolePackageRoot, "package.json"), "utf8")
7233
7193
  );
7234
7194
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
7235
7195
  throw new Error(
@@ -7285,7 +7245,7 @@ function assignPublicSeatOption(owner, taken, fields) {
7285
7245
  const value = taken.value;
7286
7246
  switch (taken.def.id) {
7287
7247
  case "attach":
7288
- fields.attachmentPaths.push(requireOptionPath(taken.def.canonical, value));
7248
+ fields.attachmentPaths.push(requireProvidedOptionValue(taken.def.canonical, value));
7289
7249
  return;
7290
7250
  case "project":
7291
7251
  fields.project = requireOptionPath(taken.def.canonical, value);
@@ -7329,7 +7289,7 @@ function assignPublicSeatOption(owner, taken, fields) {
7329
7289
  fields.repo = parseRepoOption(value);
7330
7290
  return;
7331
7291
  case "request-manifest":
7332
- fields.requestManifestPath = requireOptionPath(taken.def.canonical, value);
7292
+ fields.requestManifestPath = requireProvidedOptionValue(taken.def.canonical, value);
7333
7293
  return;
7334
7294
  case "issue": {
7335
7295
  if (value === void 0 || value.trim() === "") {
@@ -7444,6 +7404,12 @@ function requireOptionPath(flag, value) {
7444
7404
  }
7445
7405
  return value;
7446
7406
  }
7407
+ function requireProvidedOptionValue(flag, value) {
7408
+ if (value === void 0) {
7409
+ throw new CliUsageError(`${flag} requires a path`);
7410
+ }
7411
+ return value;
7412
+ }
7447
7413
  function skillArgTokenFault(value) {
7448
7414
  if (value === void 0 || value.trim() === "") return "empty";
7449
7415
  if (/\s/.test(value)) return "whitespace";
@@ -7496,124 +7462,6 @@ function requireAuthorityRef(value) {
7496
7462
  optionLike: "--authority-ref requires a durable reference, not inline Spec prose"
7497
7463
  });
7498
7464
  }
7499
- async function readRegularFileAttachment(sourcePath) {
7500
- const absolute = isAbsolute5(sourcePath) ? sourcePath : resolve9(sourcePath);
7501
- let st;
7502
- try {
7503
- st = await lstat2(absolute);
7504
- } catch (error) {
7505
- throw new CliUsageError(
7506
- `attachment is not a readable regular file: ${sourcePath}`,
7507
- { cause: error }
7508
- );
7509
- }
7510
- if (!st.isFile() || st.isSymbolicLink()) {
7511
- throw new CliUsageError(
7512
- `attachment must be a regular file (not a directory or symlink): ${sourcePath}`
7513
- );
7514
- }
7515
- try {
7516
- return { absolute, bytes: await readFile8(absolute) };
7517
- } catch (error) {
7518
- throw new CliUsageError(
7519
- `attachment is not a readable regular file: ${sourcePath}`,
7520
- { cause: error }
7521
- );
7522
- }
7523
- }
7524
- async function removePreparedAttachmentDirectory(stagingDirectory) {
7525
- await rm(stagingDirectory, { recursive: true, force: true });
7526
- }
7527
- async function withPreparedAttachments(attachmentPaths, use) {
7528
- if (attachmentPaths.length === 0) return await use([]);
7529
- const stagingDirectory = await mkdtemp(join11(tmpdir(), "ak-role-attachments-"));
7530
- const prepared = [];
7531
- let result;
7532
- try {
7533
- for (let index = 0; index < attachmentPaths.length; index += 1) {
7534
- const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
7535
- const snapshotPath = join11(stagingDirectory, String(index).padStart(6, "0"));
7536
- await writeFile(snapshotPath, bytes);
7537
- prepared.push({ absolute, snapshotPath });
7538
- }
7539
- result = await use(prepared);
7540
- } catch (primary) {
7541
- try {
7542
- await removePreparedAttachmentDirectory(stagingDirectory);
7543
- } catch (cleanup) {
7544
- throw new AggregateError(
7545
- [primary, cleanup],
7546
- "attachment snapshot operation failed and cleanup also failed",
7547
- { cause: primary }
7548
- );
7549
- }
7550
- throw primary;
7551
- }
7552
- await removePreparedAttachmentDirectory(stagingDirectory);
7553
- return result;
7554
- }
7555
- async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
7556
- const frozenPath = join11(
7557
- destinationDir,
7558
- `${String(index).padStart(2, "0")}-${basename8(provenancePath)}`
7559
- );
7560
- await writeFile(frozenPath, bytes);
7561
- return {
7562
- provenancePath,
7563
- frozenPath,
7564
- byteLength: bytes.byteLength,
7565
- sha256: sha256Hex(bytes),
7566
- mediaKind: "regular-file"
7567
- };
7568
- }
7569
- async function freezePreparedAttachment(prepared, destinationDir, index) {
7570
- return freezeAttachmentBytes(
7571
- prepared.absolute,
7572
- await readFile8(prepared.snapshotPath),
7573
- destinationDir,
7574
- index
7575
- );
7576
- }
7577
- async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
7578
- const { absolute, bytes } = await readRegularFileAttachment(sourcePath);
7579
- return {
7580
- attachment: await freezeAttachmentBytes(absolute, bytes, destinationDir, index),
7581
- body: bytes
7582
- };
7583
- }
7584
- async function freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory) {
7585
- const attachments = [];
7586
- if (attachmentPaths.length > 0) {
7587
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
7588
- }
7589
- for (let i = 0; i < attachmentPaths.length; i += 1) {
7590
- const frozen = await freezeRegularFileAttachment(
7591
- attachmentPaths[i],
7592
- attachmentsDirectory,
7593
- i
7594
- );
7595
- attachments.push(frozen.attachment);
7596
- }
7597
- return attachments;
7598
- }
7599
- async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
7600
- if (attachmentPaths.length === 0) return [];
7601
- const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
7602
- const attachmentsDirectory = join11(runDirectory, "attachments", summonsKey);
7603
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
7604
- return freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory);
7605
- }
7606
- async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
7607
- if (prepared.length === 0) return [];
7608
- const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
7609
- const attachmentsDirectory = summonsKey === void 0 ? join11(runDirectory, "attachments") : join11(runDirectory, "attachments", summonsKey);
7610
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
7611
- const attachments = [];
7612
- for (let index = 0; index < prepared.length; index += 1) {
7613
- attachments.push(await freezePreparedAttachment(prepared[index], attachmentsDirectory, index));
7614
- }
7615
- return attachments;
7616
- }
7617
7465
  function ticketAdmissionFields(ticketNumber) {
7618
7466
  if (ticketNumber === void 0) return {};
7619
7467
  return {
@@ -7702,7 +7550,7 @@ async function admitPublicRole(role, parsed, env, override) {
7702
7550
  if (parsed.prerequisitesPath !== void 0) {
7703
7551
  const absolutePrereq = isAbsolute5(parsed.prerequisitesPath) ? parsed.prerequisitesPath : resolve9(parsed.prerequisitesPath);
7704
7552
  try {
7705
- prerequisitesSource = await readFile8(absolutePrereq, "utf8");
7553
+ prerequisitesSource = await readFile7(absolutePrereq, "utf8");
7706
7554
  } catch (error) {
7707
7555
  throw new CliUsageError(
7708
7556
  `fixer prerequisites path is unreadable: ${parsed.prerequisitesPath}`,
@@ -7759,37 +7607,17 @@ async function admitPublicRole(role, parsed, env, override) {
7759
7607
  } else {
7760
7608
  repository = resolveGitHubRemoteRepository(projectRoot);
7761
7609
  }
7762
- let manifest = emptyCollectorManifest();
7763
- let manifestCanonicalJson;
7764
- if (parsed.requestManifestPath !== void 0) {
7765
- try {
7766
- manifest = await loadCollectorManifest(parsed.requestManifestPath);
7767
- manifestCanonicalJson = manifest.canonicalJson;
7768
- } catch (error) {
7769
- throw new CliUsageError(
7770
- errorText(error),
7771
- { cause: error }
7772
- );
7773
- }
7774
- }
7775
- const manifestDigest = manifest.digest;
7776
7610
  const admittedCollector = await admitStandardMaterialInvocation("collector", {
7777
7611
  ...shared,
7778
7612
  instruction,
7779
7613
  attachmentPaths,
7780
7614
  ...project,
7781
- placedFields: async (placed) => {
7782
- let requestManifestPath;
7783
- if (manifestCanonicalJson !== void 0) {
7784
- requestManifestPath = join11(placed.runDirectory, "request-manifest.json");
7785
- await writeFile(requestManifestPath, manifestCanonicalJson, "utf8");
7786
- }
7615
+ placedFields: async () => {
7787
7616
  return {
7788
7617
  ...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
7789
7618
  repository: repository.canonical,
7790
7619
  repositoryDisplay: repository.display,
7791
- ...requestManifestPath === void 0 ? {} : { requestManifestPath },
7792
- manifestDigest
7620
+ ...parsed.requestManifestPath === void 0 ? {} : { requestManifestPath: parsed.requestManifestPath }
7793
7621
  };
7794
7622
  }
7795
7623
  });
@@ -7802,12 +7630,10 @@ async function admitPublicRole(role, parsed, env, override) {
7802
7630
  );
7803
7631
  }
7804
7632
  const issueNumber = parsed.issueNumber;
7805
- let frozenAttachments = [];
7806
- const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
7633
+ return admitStandardMaterialInvocation("doctor", {
7807
7634
  ...shared,
7808
7635
  instruction,
7809
- attachmentPaths: [],
7810
- freezeAttachments: false,
7636
+ attachmentPaths,
7811
7637
  ...project,
7812
7638
  placedFields: async (placed) => {
7813
7639
  let caseRunsPath;
@@ -7848,16 +7674,13 @@ async function admitPublicRole(role, parsed, env, override) {
7848
7674
  { cause: error }
7849
7675
  );
7850
7676
  }
7851
- frozenAttachments = await freezeAttachments(placed.ledgerHome, attachmentPaths, placed.attachmentsDirectory);
7852
7677
  return {
7853
7678
  issueNumber,
7854
7679
  caseRunsPath,
7855
- caseIdentity,
7856
- attachments: persistedAttachmentRefs(frozenAttachments)
7680
+ caseIdentity
7857
7681
  };
7858
7682
  }
7859
7683
  });
7860
- return { ...admittedDoctor, attachments: frozenAttachments };
7861
7684
  }
7862
7685
  case "source-locator": {
7863
7686
  const projectRoot = resolve9(parsed.project ?? shared.cwd);
@@ -7884,7 +7707,7 @@ async function admitPublicRole(role, parsed, env, override) {
7884
7707
  instruction: "",
7885
7708
  attachmentPaths: [],
7886
7709
  ...project,
7887
- freezeAttachments: false,
7710
+ recordAttachments: false,
7888
7711
  admittedFields: {
7889
7712
  sourceRunPath: sourceRun.runDirectory,
7890
7713
  sourceRun
@@ -7901,7 +7724,7 @@ async function admitPublicRole(role, parsed, env, override) {
7901
7724
  instruction,
7902
7725
  attachmentPaths: [],
7903
7726
  ...project,
7904
- freezeAttachments: false,
7727
+ recordAttachments: false,
7905
7728
  admittedFields: { baseRevision }
7906
7729
  });
7907
7730
  }
@@ -8013,7 +7836,7 @@ async function placeRoleAdmission(options) {
8013
7836
  home: options.home,
8014
7837
  ...options.materialize === void 0 ? {} : { materialize: options.materialize }
8015
7838
  });
8016
- const attachments = options.freezeAttachments === false ? [] : await freezeAttachments(ledgerHome, options.attachmentPaths, attachmentsDirectory);
7839
+ const attachments = options.recordAttachments === false ? [] : admitCallerAttachments(options.attachmentPaths);
8017
7840
  return {
8018
7841
  runId,
8019
7842
  bookKey,
@@ -8029,13 +7852,7 @@ async function placeRoleAdmission(options) {
8029
7852
  };
8030
7853
  }
8031
7854
  function persistedAttachmentRefs(attachments) {
8032
- return attachments.map((attachment) => ({
8033
- provenancePath: attachment.provenancePath,
8034
- frozenPath: attachment.frozenPath,
8035
- byteLength: attachment.byteLength,
8036
- sha256: attachment.sha256,
8037
- mediaKind: attachment.mediaKind
8038
- }));
7855
+ return attachments.map((attachment) => ({ path: attachment.path }));
8039
7856
  }
8040
7857
  async function persistPlacedAdmission(admitted, placed, model) {
8041
7858
  writeAdmittedRequestPersistence(placed.runDirectory, admitted, {
@@ -8054,14 +7871,14 @@ async function persistPlacedAdmission(admitted, placed, model) {
8054
7871
  }
8055
7872
  async function admitStandardMaterialInvocation(role, options) {
8056
7873
  const defer = options.deferPersistence === true;
8057
- const skipFreeze = defer || options.freezeAttachments === false;
7874
+ const skipAttachments = defer || options.recordAttachments === false;
8058
7875
  const placed = await placeRoleAdmission({
8059
7876
  role,
8060
7877
  home: options.home,
8061
7878
  principalAuthority: options.principalAuthority,
8062
7879
  cwd: options.cwd,
8063
7880
  attachmentPaths: options.attachmentPaths,
8064
- ...skipFreeze ? { freezeAttachments: false } : {},
7881
+ ...skipAttachments ? { recordAttachments: false } : {},
8065
7882
  ...defer ? { materialize: false } : {},
8066
7883
  ...options.project === void 0 ? {} : { project: options.project },
8067
7884
  ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
@@ -8069,7 +7886,7 @@ async function admitStandardMaterialInvocation(role, options) {
8069
7886
  });
8070
7887
  const correlationFields = options.correlationId === void 0 ? {} : { correlationId: options.correlationId };
8071
7888
  const instruction = options.instruction;
8072
- const instructionEmpty = instruction.trim() === "";
7889
+ const instructionEmpty = instruction.length === 0;
8073
7890
  const placedExtra = options.placedFields === void 0 ? void 0 : await options.placedFields(placed);
8074
7891
  const admittedFields = {
8075
7892
  ...options.admittedFields ?? {},
@@ -8124,7 +7941,7 @@ function buildInstructionTransportPrompt(admitted) {
8124
7941
  throw new Error("baseline transport prompt is missing the bound revision");
8125
7942
  }
8126
7943
  const lines2 = [admitted.baseRevision];
8127
- if (!admitted.instructionEmpty) {
7944
+ if (admitted.instruction.length > 0) {
8128
7945
  lines2.push("", admitted.instruction);
8129
7946
  }
8130
7947
  return lines2.join("\n");
@@ -8138,17 +7955,21 @@ function buildInstructionTransportPrompt(admitted) {
8138
7955
  lens: admitted.lens,
8139
7956
  authorityRefs: admitted.authorityRefs
8140
7957
  })];
8141
- if (!admitted.instructionEmpty && admitted.instruction.trim() !== "") {
7958
+ if (admitted.instruction.length > 0) {
8142
7959
  lines2.push("", admitted.instruction);
8143
7960
  }
8144
7961
  return lines2.join("\n");
8145
7962
  }
8146
- const lines = [admitted.instructionEmpty ? "" : admitted.instruction];
8147
- if (admitted.attachments.length > 0) {
7963
+ const lines = [admitted.instruction];
7964
+ const flaggedPaths = [
7965
+ ...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
7966
+ ...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`]
7967
+ ];
7968
+ if (flaggedPaths.length > 0) {
8148
7969
  lines.push("");
8149
- lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF08\u51BB\u7ED3\u5FEB\u7167\u8DEF\u5F84\uFF09\uFF1A");
8150
- for (const attachment of admitted.attachments) {
8151
- lines.push(`- ${attachment.frozenPath}`);
7970
+ lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
7971
+ for (const entry of flaggedPaths) {
7972
+ lines.push(`- ${entry}`);
8152
7973
  }
8153
7974
  }
8154
7975
  return lines.join("\n");
@@ -8159,8 +7980,7 @@ async function materializeCountersignInvocation(admitted, options) {
8159
7980
  home: options.home,
8160
7981
  principalAuthority: options.principalAuthority,
8161
7982
  cwd: admitted.projectRoot,
8162
- attachmentPaths: [],
8163
- freezeAttachments: false,
7983
+ attachmentPaths: options.attachmentPaths,
8164
7984
  runId: admitted.runId,
8165
7985
  ...options.ticketNumber === void 0 ? {} : { assertedTicketNumber: options.ticketNumber }
8166
7986
  });
@@ -8171,11 +7991,7 @@ async function materializeCountersignInvocation(admitted, options) {
8171
7991
  if (ticketFields.ticketNumber !== void 0) {
8172
7992
  admitted.ticketNumber = ticketFields.ticketNumber;
8173
7993
  }
8174
- const attachments = await freezePreparedAttachmentsIntoRun(
8175
- options.preparedAttachments,
8176
- admitted.runDirectory
8177
- );
8178
- admitted.attachments = attachments;
7994
+ admitted.attachments = placement.attachments;
8179
7995
  writeAdmittedRequestPersistence(admitted.runDirectory, admitted, {
8180
7996
  sessionDirectory: placement.sessionDirectory,
8181
7997
  sessionFile: placement.sessionFile
@@ -8194,10 +8010,11 @@ async function loadAdmittedJudgeRequest(runDirectory) {
8194
8010
  if (typeof record.instruction !== "string") return void 0;
8195
8011
  if (typeof record.instructionEmpty !== "boolean") return void 0;
8196
8012
  if (!Array.isArray(record.attachments)) return void 0;
8013
+ const attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
8197
8014
  return {
8198
8015
  instruction: record.instruction,
8199
8016
  instructionEmpty: record.instructionEmpty,
8200
- attachments: record.attachments
8017
+ attachments
8201
8018
  };
8202
8019
  } catch {
8203
8020
  return void 0;
@@ -8432,7 +8249,7 @@ function parseAnalystArgv(args) {
8432
8249
  if (taken.def.id === "attach") {
8433
8250
  pushValue(
8434
8251
  "attach",
8435
- requireOptionPath(taken.def.canonical, taken.value)
8252
+ requireProvidedOptionValue(taken.def.canonical, taken.value)
8436
8253
  );
8437
8254
  return;
8438
8255
  }
@@ -9838,10 +9655,10 @@ function presentFailureTerminal(terminal, io) {
9838
9655
  }
9839
9656
  function defaultNavigatorGraceSleep() {
9840
9657
  let timer;
9841
- const sleep2 = ((ms) => new Promise((resolve22) => {
9658
+ const sleep2 = ((ms) => new Promise((resolve21) => {
9842
9659
  timer = setTimeout(() => {
9843
9660
  timer = void 0;
9844
- resolve22();
9661
+ resolve21();
9845
9662
  }, ms);
9846
9663
  }));
9847
9664
  sleep2.cancel = () => {
@@ -9853,7 +9670,7 @@ function defaultNavigatorGraceSleep() {
9853
9670
  return sleep2;
9854
9671
  }
9855
9672
  function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
9856
- return new Promise((resolve22, reject) => {
9673
+ return new Promise((resolve21, reject) => {
9857
9674
  let settled = false;
9858
9675
  const finish = (action) => {
9859
9676
  if (settled) return;
@@ -9862,11 +9679,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
9862
9679
  action();
9863
9680
  };
9864
9681
  void work.then(
9865
- (value) => finish(() => resolve22({ status: "done", value })),
9682
+ (value) => finish(() => resolve21({ status: "done", value })),
9866
9683
  (error) => finish(() => reject(error))
9867
9684
  );
9868
9685
  void sleep2(graceMs).then(() => {
9869
- finish(() => resolve22({ status: "timeout" }));
9686
+ finish(() => resolve21({ status: "timeout" }));
9870
9687
  });
9871
9688
  });
9872
9689
  }
@@ -10483,7 +10300,7 @@ __export(config_exports, {
10483
10300
  setPersistentSeatHost: () => setPersistentSeatHost,
10484
10301
  validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
10485
10302
  });
10486
- import { mkdir, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
10303
+ import { mkdir, readFile as readFile8, writeFile as writeFile2 } from "node:fs/promises";
10487
10304
  import { dirname as dirname11, join as join15 } from "node:path";
10488
10305
  function isGateOfficerSeat(value) {
10489
10306
  return packagedProvinceConfig(value);
@@ -10497,7 +10314,7 @@ function publicCliConfigPath(home) {
10497
10314
  async function loadPublicCliConfig(home) {
10498
10315
  const path = publicCliConfigPath(home);
10499
10316
  try {
10500
- const raw = await readFile9(path, "utf8");
10317
+ const raw = await readFile8(path, "utf8");
10501
10318
  return parsePublicCliConfig(JSON.parse(raw));
10502
10319
  } catch (error) {
10503
10320
  if (isEnoent(error)) return { seats: {} };
@@ -10956,7 +10773,7 @@ function resolvePublicAgentDir(explicit, home) {
10956
10773
  }
10957
10774
  async function loadCredentialProviders(agentDir) {
10958
10775
  try {
10959
- const raw = await readFile9(join15(agentDir, "auth.json"), "utf8");
10776
+ const raw = await readFile8(join15(agentDir, "auth.json"), "utf8");
10960
10777
  return credentialProvidersFromAuthData(JSON.parse(raw));
10961
10778
  } catch (error) {
10962
10779
  if (isEnoent(error)) return { "openai-codex": false, xai: false };
@@ -11340,7 +11157,7 @@ var init_role_seat_runtime = __esm({
11340
11157
  });
11341
11158
 
11342
11159
  // src/archivist-record-pointer.ts
11343
- import { basename as basename9, join as join19 } from "node:path";
11160
+ import { basename as basename8, join as join19 } from "node:path";
11344
11161
  function bookDirectOfficerRunPointer(options) {
11345
11162
  const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
11346
11163
  const pointer = {
@@ -11366,7 +11183,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
11366
11183
  let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
11367
11184
  let sessionFile = raw.sessionFile;
11368
11185
  const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
11369
- const leaf = parseRunLeaf(basename9(recordedRunDirectory));
11186
+ const leaf = parseRunLeaf(basename8(recordedRunDirectory));
11370
11187
  const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
11371
11188
  if (leaf !== void 0 && parentIdentity !== void 0) {
11372
11189
  const currentRunDirectory = await findRunDirectoryById(
@@ -11727,7 +11544,7 @@ var init_submission_gate = __esm({
11727
11544
 
11728
11545
  // src/session-opening-materials.ts
11729
11546
  import { existsSync as existsSync7 } from "node:fs";
11730
- import { readFile as readFile10 } from "node:fs/promises";
11547
+ import { readFile as readFile9 } from "node:fs/promises";
11731
11548
  import { dirname as dirname12, join as join20 } from "node:path";
11732
11549
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
11733
11550
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
@@ -11743,7 +11560,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
11743
11560
  return fileURLToPath(new URL("..", moduleUrl));
11744
11561
  }
11745
11562
  async function readPackageMaterial(relativePath) {
11746
- return readFile10(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
11563
+ return readFile9(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
11747
11564
  }
11748
11565
  async function joinPackageMaterials(relativePaths) {
11749
11566
  const chunks = [];
@@ -11801,7 +11618,7 @@ __export(auditor_soul_exports, {
11801
11618
  readAuditorResumeBinding: () => readAuditorResumeBinding,
11802
11619
  resolveAuditorSubject: () => resolveAuditorSubject
11803
11620
  });
11804
- import { basename as basename10 } from "node:path";
11621
+ import { basename as basename9 } from "node:path";
11805
11622
  function auditorSoulRelativePath(role) {
11806
11623
  return `souls/${role}-auditor.md`;
11807
11624
  }
@@ -11837,7 +11654,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
11837
11654
  return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
11838
11655
  }
11839
11656
  function subjectFromSourceDirectory(sourceRunDirectory) {
11840
- const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
11657
+ const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
11841
11658
  return isAuditorSoulRole(role) ? role : void 0;
11842
11659
  }
11843
11660
  async function readAuditorResumeBinding(runDirectory) {
@@ -11877,7 +11694,7 @@ var init_auditor_soul = __esm({
11877
11694
 
11878
11695
  // src/public-cli/machine-method-skills.ts
11879
11696
  import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
11880
- import { lstat as lstat3, mkdir as mkdir2, symlink } from "node:fs/promises";
11697
+ import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
11881
11698
  import { join as join22 } from "node:path";
11882
11699
  import { spawnSync as spawnSync2 } from "node:child_process";
11883
11700
  function skillRoot(home) {
@@ -11907,7 +11724,7 @@ function linkedSkillRoot(home, host) {
11907
11724
  }
11908
11725
  async function occupied(path) {
11909
11726
  try {
11910
- await lstat3(path);
11727
+ await lstat2(path);
11911
11728
  return true;
11912
11729
  } catch (error) {
11913
11730
  if (error.code !== "ENOENT") throw error;
@@ -12404,7 +12221,6 @@ var init_auto_resume = __esm({
12404
12221
 
12405
12222
  // src/public-cli/post-admission.ts
12406
12223
  import { randomUUID as randomUUID5 } from "node:crypto";
12407
- import { isAbsolute as isAbsolute7, join as join23, resolve as resolve12 } from "node:path";
12408
12224
  function describeCaughtError(error) {
12409
12225
  if (error instanceof Error) {
12410
12226
  const code = error.code;
@@ -12426,7 +12242,7 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
12426
12242
  mutableRequest.principal = admitted.principal;
12427
12243
  const activation = mutableRequest.activation;
12428
12244
  if (isRecord(activation)) {
12429
- for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath", "requestManifestPath"]) {
12245
+ for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath"]) {
12430
12246
  const record = activation;
12431
12247
  if (field in record) record[field] = rewrite(record[field]);
12432
12248
  }
@@ -13159,7 +12975,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
13159
12975
  prompt = request.message;
13160
12976
  }
13161
12977
  } else if (summonsPrepared !== void 0) {
13162
- prompt = officerDialogue ? summonsPrepared.instructionEmpty ? "" : summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
12978
+ prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
13163
12979
  } else if (request.summons !== void 0) {
13164
12980
  prompt = "";
13165
12981
  } else {
@@ -13240,24 +13056,14 @@ async function runSettledAutoResumeLoop(input) {
13240
13056
  })
13241
13057
  });
13242
13058
  }
13243
- function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
13244
- const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
13245
- return pathContainedIn(join23(runDirectory, "attachments"), absolute);
13246
- }
13247
- async function prepareSummonsResumeMaterials(runDirectory, summons) {
13059
+ async function prepareSummonsResumeMaterials(_runDirectory, summons) {
13248
13060
  if (summons === void 0) return void 0;
13249
13061
  if (summons.instruction === void 0 && (summons.attachmentPaths?.length ?? 0) === 0) {
13250
13062
  return void 0;
13251
13063
  }
13252
13064
  const instruction = summons.instruction ?? "";
13253
- const instructionEmpty = summons.instructionEmpty ?? instruction.trim() === "";
13254
- let attachments = [];
13255
- if (summons.attachmentPaths !== void 0 && summons.attachmentPaths.length > 0) {
13256
- const alreadyFrozen = summons.attachmentPaths.every(
13257
- (path) => isAlreadyFrozenSummonsAttachment(runDirectory, path)
13258
- );
13259
- attachments = alreadyFrozen ? summons.attachmentPaths.map((frozenPath) => ({ frozenPath })) : await freezeAttachmentsIntoRun(summons.attachmentPaths, runDirectory);
13260
- }
13065
+ const instructionEmpty = summons.instructionEmpty ?? instruction.length === 0;
13066
+ const attachments = (summons.attachmentPaths ?? []).map((path) => ({ path }));
13261
13067
  return { instruction, instructionEmpty, attachments };
13262
13068
  }
13263
13069
  async function runPostAdmissionSeatResume(input) {
@@ -13306,23 +13112,6 @@ async function runPostAdmissionSeatResume(input) {
13306
13112
  openCourtAttemptId = openCourt.courtAttemptId;
13307
13113
  }
13308
13114
  }
13309
- if (request.summons !== void 0) {
13310
- const prepared = await prepareSummonsResumeMaterials(
13311
- admittedForBuild.runDirectory,
13312
- request.summons
13313
- );
13314
- if (prepared !== void 0 && (request.summons.attachmentPaths?.length ?? 0) > 0) {
13315
- request = {
13316
- ...request,
13317
- summons: {
13318
- ...request.summons,
13319
- attachmentPaths: prepared.attachments.map(
13320
- (attachment) => attachment.frozenPath
13321
- )
13322
- }
13323
- };
13324
- }
13325
- }
13326
13115
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
13327
13116
  if (turnRequest.continuation.kind === "resume" && turnRequest.continuation.hostSessionId === void 0) {
13328
13117
  const hostSessionId = await readStoredHostSessionId(
@@ -13572,7 +13361,6 @@ var init_post_admission = __esm({
13572
13361
  init_invocation();
13573
13362
  init_submission_ledger();
13574
13363
  init_run_ticket_number();
13575
- init_activation_ledger_topology();
13576
13364
  init_session_identity();
13577
13365
  init_sitian_facade();
13578
13366
  init_receipt_delivery_policy();
@@ -13712,7 +13500,7 @@ __export(instruction_seat_run_exports, {
13712
13500
  runPublicInstructionSeat: () => runPublicInstructionSeat,
13713
13501
  runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
13714
13502
  });
13715
- import { dirname as dirname13, resolve as resolve13 } from "node:path";
13503
+ import { dirname as dirname13, resolve as resolve12 } from "node:path";
13716
13504
  function unreadablePostSubmissionStatus(admitted, terminal) {
13717
13505
  if (terminal?.roleOutcome.kind !== "accepted") return void 0;
13718
13506
  const route = POST_SUBMISSION_ROUTING[admitted.role];
@@ -13940,7 +13728,7 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
13940
13728
  const children = await summonParallelReviewerLenses2({
13941
13729
  argv,
13942
13730
  cwd: env.cwd,
13943
- projectRoot: resolve13(parsed.project ?? env.cwd),
13731
+ projectRoot: resolve12(parsed.project ?? env.cwd),
13944
13732
  baseRevision: parsed.baseRevision ?? "",
13945
13733
  home: env.home,
13946
13734
  agentDir: env.agentDir,
@@ -14022,14 +13810,14 @@ async function runCountersignBody(parsed, env, io) {
14022
13810
  const resumed = await resumeSameParentInstructionSeat({
14023
13811
  env,
14024
13812
  io,
14025
- projectRoot: resolve13(parsed.project ?? env.cwd),
13813
+ projectRoot: resolve12(parsed.project ?? env.cwd),
14026
13814
  role: "countersign",
14027
13815
  parentRunPath: gateParentRunPath,
14028
13816
  ...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
14029
13817
  summons: {
14030
13818
  sourceRunPath: gateParentRunPath,
14031
13819
  instruction: resumeInstruction,
14032
- instructionEmpty: resumeInstruction.trim() === ""
13820
+ instructionEmpty: resumeInstruction.length === 0
14033
13821
  }
14034
13822
  });
14035
13823
  if (resumed != null) return resumed;
@@ -14043,12 +13831,12 @@ async function runCountersignBody(parsed, env, io) {
14043
13831
  throw error;
14044
13832
  }
14045
13833
  try {
14046
- return await withPreparedAttachments(parsed.attachmentPaths ?? [], async (preparedAttachments) => {
13834
+ {
14047
13835
  const materializeAdmission = async (ticketNumber) => {
14048
13836
  await materializeCountersignInvocation(admitted, {
14049
13837
  home: env.home,
14050
13838
  principalAuthority: env.principalAuthority,
14051
- preparedAttachments,
13839
+ attachmentPaths: parsed.attachmentPaths ?? [],
14052
13840
  ...env.model === void 0 ? {} : { model: env.model },
14053
13841
  ...ticketNumber === void 0 ? {} : { ticketNumber }
14054
13842
  });
@@ -14083,7 +13871,7 @@ async function runCountersignBody(parsed, env, io) {
14083
13871
  });
14084
13872
  await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
14085
13873
  return result;
14086
- });
13874
+ }
14087
13875
  } catch (error) {
14088
13876
  const rejected = usageExit(error, io);
14089
13877
  if (rejected !== void 0) return rejected;
@@ -14148,7 +13936,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14148
13936
  const summons = {
14149
13937
  ...sameParentInstruction(env, {
14150
13938
  instruction: parsed.instruction ?? "",
14151
- instructionEmpty: (parsed.instruction ?? "").trim() === ""
13939
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14152
13940
  }),
14153
13941
  attachmentPaths: parsed.attachmentPaths ?? []
14154
13942
  };
@@ -14173,7 +13961,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14173
13961
  sourceRunPath: parentRunPath,
14174
13962
  ...sameParentInstruction(env, {
14175
13963
  instruction: parsed.instruction ?? "",
14176
- instructionEmpty: (parsed.instruction ?? "").trim() === ""
13964
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14177
13965
  }),
14178
13966
  attachmentPaths: parsed.attachmentPaths ?? []
14179
13967
  };
@@ -14257,7 +14045,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14257
14045
  instruction: parsed.instruction ?? "",
14258
14046
  projectRoot: admitted.projectRoot,
14259
14047
  failureLabel: "secretariat unbound summons",
14260
- attachmentPaths: admitted.attachments.map((attachment) => attachment.frozenPath),
14048
+ attachmentPaths: admitted.attachments.map((attachment) => attachment.path),
14261
14049
  correlationId: admitted.runId
14262
14050
  }, env, io);
14263
14051
  } catch (error) {
@@ -14816,7 +14604,7 @@ var init_instruction_seat_run = __esm({
14816
14604
 
14817
14605
  // src/analyst-book-key.ts
14818
14606
  import { statSync as statSync6 } from "node:fs";
14819
- import { isAbsolute as isAbsolute8 } from "node:path";
14607
+ import { isAbsolute as isAbsolute7 } from "node:path";
14820
14608
  function resolveAnalystBookKey(projectRoot) {
14821
14609
  const identity = physicalPathIdentity(projectRoot);
14822
14610
  let stats;
@@ -14838,7 +14626,7 @@ function resolveAnalystBookKey(projectRoot) {
14838
14626
  }
14839
14627
  }
14840
14628
  function isSyntheticAnalystBookKey(bookKey) {
14841
- return bookKey.startsWith("root:") && isAbsolute8(bookKey.slice("root:".length));
14629
+ return bookKey.startsWith("root:") && isAbsolute7(bookKey.slice("root:".length));
14842
14630
  }
14843
14631
  var init_analyst_book_key = __esm({
14844
14632
  "src/analyst-book-key.ts"() {
@@ -14850,16 +14638,16 @@ var init_analyst_book_key = __esm({
14850
14638
 
14851
14639
  // src/atomic-write.ts
14852
14640
  import { randomUUID as randomUUID6 } from "node:crypto";
14853
- import { rename as rename2, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
14854
- import { dirname as dirname14, join as join24 } from "node:path";
14641
+ import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
14642
+ import { dirname as dirname14, join as join23 } from "node:path";
14855
14643
  async function writeFileAtomically(destination, contents, options) {
14856
14644
  const parent = dirname14(destination);
14857
- const temporary = join24(parent, `.atomic-write-${randomUUID6()}.tmp`);
14645
+ const temporary = join23(parent, `.atomic-write-${randomUUID6()}.tmp`);
14858
14646
  try {
14859
14647
  await writeFile3(temporary, contents, options);
14860
14648
  await rename2(temporary, destination);
14861
14649
  } catch (error) {
14862
- await rm2(temporary, { force: true }).catch(() => void 0);
14650
+ await rm(temporary, { force: true }).catch(() => void 0);
14863
14651
  throw error;
14864
14652
  }
14865
14653
  }
@@ -14870,13 +14658,13 @@ var init_atomic_write = __esm({
14870
14658
  });
14871
14659
 
14872
14660
  // src/analyst-index.ts
14873
- import { open, readFile as readFile11, unlink } from "node:fs/promises";
14874
- import { dirname as dirname15, join as join25 } from "node:path";
14661
+ import { open, readFile as readFile10, unlink } from "node:fs/promises";
14662
+ import { dirname as dirname15, join as join24 } from "node:path";
14875
14663
  import { setTimeout as sleep } from "node:timers/promises";
14876
14664
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
14877
14665
  const indexPath = analystLibraryIndexPath(ledgerHome);
14878
14666
  ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
14879
- const lockPath = join25(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
14667
+ const lockPath = join24(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
14880
14668
  assertLedgerFileInsideHome(lockPath, ledgerHome);
14881
14669
  const startedAt = Date.now();
14882
14670
  while (true) {
@@ -14903,7 +14691,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
14903
14691
  }
14904
14692
  }
14905
14693
  function analystLibraryIndexPath(ledgerHome) {
14906
- return join25(ledgerHome, "analyst", "library-index.json");
14694
+ return join24(ledgerHome, "analyst", "library-index.json");
14907
14695
  }
14908
14696
  function rowFromIssueMetricsPage(page) {
14909
14697
  return {
@@ -14994,7 +14782,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
14994
14782
  const path = analystLibraryIndexPath(ledgerHome);
14995
14783
  let raw;
14996
14784
  try {
14997
- raw = await readFile11(path, "utf8");
14785
+ raw = await readFile10(path, "utf8");
14998
14786
  } catch (error) {
14999
14787
  if (isMissingPathError(error)) return void 0;
15000
14788
  throw error;
@@ -15449,7 +15237,7 @@ var init_analyst_gate_cycles_read = __esm({
15449
15237
 
15450
15238
  // src/analyst-ledger.ts
15451
15239
  import { readdir as readdir3 } from "node:fs/promises";
15452
- import { basename as basename11, join as join26 } from "node:path";
15240
+ import { basename as basename10, join as join25 } from "node:path";
15453
15241
  async function readExistingRunLifecycleState(runDirectory) {
15454
15242
  return (await readRoleRunIdentity(runDirectory))?.state;
15455
15243
  }
@@ -15469,7 +15257,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
15469
15257
  }
15470
15258
  }
15471
15259
  async function classifyGhostCandidate(input) {
15472
- const autopsy = await autopsyWriterLock(join26(input.runDirectory, "writer.lock"));
15260
+ const autopsy = await autopsyWriterLock(join25(input.runDirectory, "writer.lock"));
15473
15261
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
15474
15262
  if (leaseCheck === void 0) return { kind: "live" };
15475
15263
  return {
@@ -15759,7 +15547,7 @@ async function classifyScopedRun(input) {
15759
15547
  async function scanAnalystIssueRuns(input) {
15760
15548
  const ledgerHome = resolveActivationLedgerHome(input.home);
15761
15549
  const scopeTicketNumber = input.ticketNumber;
15762
- const booksRoot = join26(ledgerHome, "books");
15550
+ const booksRoot = join25(ledgerHome, "books");
15763
15551
  let wholeBook = false;
15764
15552
  let scopeRootIdentity;
15765
15553
  let bookNames;
@@ -15792,7 +15580,7 @@ async function scanAnalystIssueRuns(input) {
15792
15580
  const ghostLegs = [];
15793
15581
  const scopeConflicts = [];
15794
15582
  for (const book of bookNames) {
15795
- const bookDir = join26(booksRoot, book);
15583
+ const bookDir = join25(booksRoot, book);
15796
15584
  let runDirectories;
15797
15585
  try {
15798
15586
  runDirectories = await listBookRunDirectories(bookDir);
@@ -15801,7 +15589,7 @@ async function scanAnalystIssueRuns(input) {
15801
15589
  throw error;
15802
15590
  }
15803
15591
  for (const runDirectory of runDirectories) {
15804
- const runName = basename11(runDirectory);
15592
+ const runName = basename10(runDirectory);
15805
15593
  const parsed = parseRunLeaf(runName);
15806
15594
  if (parsed === void 0) continue;
15807
15595
  let scopeFields;
@@ -16538,7 +16326,7 @@ var init_analyst_metric_family = __esm({
16538
16326
  });
16539
16327
 
16540
16328
  // src/analyst-page.ts
16541
- import { dirname as dirname16, join as join27 } from "node:path";
16329
+ import { dirname as dirname16, join as join26 } from "node:path";
16542
16330
  function analystIssuePageKey(address) {
16543
16331
  const parts = ["book", address.bookKey];
16544
16332
  if (address.issueNumber !== void 0) {
@@ -16549,7 +16337,7 @@ function analystIssuePageKey(address) {
16549
16337
  return sha256Hex(parts.join("\0")).slice(0, 32);
16550
16338
  }
16551
16339
  function analystIssuePagePath(ledgerHome, address) {
16552
- return join27(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16340
+ return join26(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16553
16341
  }
16554
16342
  function analystIssuePageAddressFromPage(page) {
16555
16343
  return {
@@ -16785,7 +16573,7 @@ var init_analyst_model_groups = __esm({
16785
16573
  });
16786
16574
 
16787
16575
  // src/analyst-entry.ts
16788
- import { readFile as readFile13 } from "node:fs/promises";
16576
+ import { readFile as readFile12 } from "node:fs/promises";
16789
16577
  import { Type as Type17 } from "typebox";
16790
16578
  function cachedPageMatchesRequestedScope(page, input) {
16791
16579
  if (page.bookKey !== input.bookKey) return false;
@@ -16813,7 +16601,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
16813
16601
  ...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
16814
16602
  });
16815
16603
  try {
16816
- const raw = await readFile13(pagePath, "utf8");
16604
+ const raw = await readFile12(pagePath, "utf8");
16817
16605
  const page = JSON.parse(raw);
16818
16606
  if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
16819
16607
  const ghostScan = await scanAnalystIssueRuns({
@@ -16914,7 +16702,7 @@ async function runAnalystModelGroupsMode(input, home) {
16914
16702
  scopeRootIdentity: projectRoot
16915
16703
  });
16916
16704
  try {
16917
- const raw = await readFile13(pagePath, "utf8");
16705
+ const raw = await readFile12(pagePath, "utf8");
16918
16706
  JSON.parse(raw);
16919
16707
  } catch (error) {
16920
16708
  if (!isMissingPathError(error)) {
@@ -17011,8 +16799,8 @@ var init_analyst_entry = __esm({
17011
16799
  });
17012
16800
 
17013
16801
  // src/public-cli/analyst-run.ts
17014
- import { readFile as readFile14 } from "node:fs/promises";
17015
- import { isAbsolute as isAbsolute9, resolve as resolve14 } from "node:path";
16802
+ import { readFile as readFile13 } from "node:fs/promises";
16803
+ import { isAbsolute as isAbsolute8, resolve as resolve13 } from "node:path";
17016
16804
  import { Value as Value2 } from "typebox/value";
17017
16805
  function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
17018
16806
  try {
@@ -17062,10 +16850,10 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
17062
16850
  );
17063
16851
  }
17064
16852
  const sourcePath = attachmentPaths[0];
17065
- const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve14(sourcePath);
16853
+ const absolute = isAbsolute8(sourcePath) ? sourcePath : resolve13(sourcePath);
17066
16854
  let bytes;
17067
16855
  try {
17068
- bytes = await readFile14(absolute);
16856
+ bytes = await readFile13(absolute);
17069
16857
  } catch (error) {
17070
16858
  throw new CliUsageError(
17071
16859
  `analyst sweep attachment is not a readable regular file: ${sourcePath}`,
@@ -18095,7 +17883,7 @@ __export(public_role_summons_exports, {
18095
17883
  import { execFile as execFile3 } from "node:child_process";
18096
17884
  import { existsSync as existsSync8 } from "node:fs";
18097
17885
  import { realpath as realpath6 } from "node:fs/promises";
18098
- import { join as join28 } from "node:path";
17886
+ import { join as join27 } from "node:path";
18099
17887
  import { promisify as promisify3 } from "node:util";
18100
17888
  function createCapturingIo() {
18101
17889
  const chunks = [];
@@ -18119,7 +17907,7 @@ function parentDir(path) {
18119
17907
  function walkPackageRoot(start) {
18120
17908
  let dir = start;
18121
17909
  for (let i = 0; i < 12; i += 1) {
18122
- if (existsSync8(join28(dir, "package.json")) && existsSync8(join28(dir, "souls"))) {
17910
+ if (existsSync8(join27(dir, "package.json")) && existsSync8(join27(dir, "souls"))) {
18123
17911
  return dir;
18124
17912
  }
18125
17913
  const parent = parentDir(dir);
@@ -18339,7 +18127,7 @@ async function summonPublicRole(options) {
18339
18127
  runId: resumeRunId,
18340
18128
  summons: {
18341
18129
  instruction,
18342
- instructionEmpty: instruction.trim() === ""
18130
+ instructionEmpty: instruction.length === 0
18343
18131
  }
18344
18132
  },
18345
18133
  env,
@@ -18728,7 +18516,7 @@ var init_compliance_transport = __esm({
18728
18516
  });
18729
18517
 
18730
18518
  // src/role-run-relocation.ts
18731
- import { dirname as dirname17, join as join29, sep as sep4 } from "node:path";
18519
+ import { dirname as dirname17, join as join28, sep as sep4 } from "node:path";
18732
18520
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
18733
18521
  if (typeof value !== "string") return value;
18734
18522
  if (value === oldRunDirectory) return newRunDirectory;
@@ -18808,13 +18596,6 @@ function rewriteSourceRunLocator(value, rewrites) {
18808
18596
  function rewriteAdmittedRoleRunPage(page, rewrites) {
18809
18597
  rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
18810
18598
  rewriteSourceRunLocator(page.sourceRun, rewrites);
18811
- if (Array.isArray(page.attachments)) {
18812
- for (const attachment of page.attachments) {
18813
- if (isRecord(attachment)) {
18814
- rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
18815
- }
18816
- }
18817
- }
18818
18599
  if (isRecord(page.principal)) {
18819
18600
  rewriteRunDirectoryPathFieldsAgainstRewrites(
18820
18601
  page.principal,
@@ -18842,7 +18623,7 @@ var init_role_run_relocation = __esm({
18842
18623
  "taskPath",
18843
18624
  "packetPath",
18844
18625
  "prerequisitesPath",
18845
- "requestManifestPath",
18626
+ // #1165: requestManifestPath is a caller path — never rewrite.
18846
18627
  "mergerInputPath",
18847
18628
  "sourceRunPath"
18848
18629
  ];
@@ -18877,8 +18658,8 @@ __export(run_lifecycle_exports, {
18877
18658
  recordCurrentCourt: () => recordCurrentCourt,
18878
18659
  writeRoleRunState: () => writeRoleRunState
18879
18660
  });
18880
- import { chmod, lstat as lstat4, open as open2, readdir as readdir4, readFile as readFile15, unlink as unlink2 } from "node:fs/promises";
18881
- import { basename as basename12, join as join30 } from "node:path";
18661
+ import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
18662
+ import { basename as basename11, join as join29 } from "node:path";
18882
18663
  function buildAutoResumeContinuationPrompt() {
18883
18664
  return RESUME_TRANSPORT_ENVELOPE;
18884
18665
  }
@@ -18891,7 +18672,7 @@ function parseSameTicketSummonsMaterials(raw) {
18891
18672
  const record = raw;
18892
18673
  const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
18893
18674
  const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
18894
- const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string" && p.length > 0) : void 0;
18675
+ const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string") : void 0;
18895
18676
  const sourceRunPath = typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "" ? record.sourceRunPath : void 0;
18896
18677
  let sourceRun;
18897
18678
  if (isRecord(record.sourceRun)) {
@@ -19116,7 +18897,7 @@ function isProcessAlive(pid) {
19116
18897
  async function autopsyWriterLock(lockPath) {
19117
18898
  let content;
19118
18899
  try {
19119
- content = await readFile15(lockPath, "utf8");
18900
+ content = await readFile14(lockPath, "utf8");
19120
18901
  } catch (error) {
19121
18902
  if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
19122
18903
  return { verdict: "unknown", reason: "unreadable", readFailure: error };
@@ -19175,7 +18956,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
19175
18956
  },
19176
18957
  relocate(nextRunDirectory) {
19177
18958
  currentRunDirectory = nextRunDirectory;
19178
- currentLockPath = join30(nextRunDirectory, WRITER_LOCK_FILE);
18959
+ currentLockPath = join29(nextRunDirectory, WRITER_LOCK_FILE);
19179
18960
  },
19180
18961
  async release() {
19181
18962
  if (released) return;
@@ -19214,10 +18995,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19214
18995
  };
19215
18996
  const reportReadFailure = (error) => {
19216
18997
  reportDiagnostic(
19217
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join30(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18998
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join29(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
19218
18999
  );
19219
19000
  };
19220
- const lockPath = join30(runDirectory, WRITER_LOCK_FILE);
19001
+ const lockPath = join29(runDirectory, WRITER_LOCK_FILE);
19221
19002
  let lastAutopsy = { verdict: "absent" };
19222
19003
  let lastReclaimFailure;
19223
19004
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -19274,7 +19055,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19274
19055
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
19275
19056
  if (runId.trim() === "") return void 0;
19276
19057
  const ledgerHome = resolveActivationLedgerHome(home);
19277
- const booksRoot = join30(ledgerHome, "books");
19058
+ const booksRoot = join29(ledgerHome, "books");
19278
19059
  let bookKeys;
19279
19060
  try {
19280
19061
  bookKeys = await readdir4(booksRoot);
@@ -19309,7 +19090,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
19309
19090
  if (disk === void 0) return false;
19310
19091
  const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : sessionFileIn(disk.principalWire.sessionDirectory);
19311
19092
  try {
19312
- const stat2 = await lstat4(sessionFile);
19093
+ const stat2 = await lstat3(sessionFile);
19313
19094
  return stat2.isFile() && !stat2.isSymbolicLink();
19314
19095
  } catch (error) {
19315
19096
  if (errorCodeOf(error) === "ENOENT") return false;
@@ -19325,7 +19106,7 @@ async function findLatestRunIdForSeatTicket(input) {
19325
19106
  let runDirectories;
19326
19107
  try {
19327
19108
  runDirectories = await listBookRunDirectories(
19328
- input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
19109
+ input.ticketNumber === void 0 ? bookDir : join29(bookDir, String(input.ticketNumber))
19329
19110
  );
19330
19111
  } catch (error) {
19331
19112
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -19333,7 +19114,7 @@ async function findLatestRunIdForSeatTicket(input) {
19333
19114
  }
19334
19115
  let best;
19335
19116
  for (const runDirectory of runDirectories) {
19336
- const parsed = parseRunLeaf(basename12(runDirectory));
19117
+ const parsed = parseRunLeaf(basename11(runDirectory));
19337
19118
  if (parsed === void 0 || parsed.role !== input.role) continue;
19338
19119
  const runId = parsed.runId;
19339
19120
  const parentPath = await readRunParentPath(runDirectory);
@@ -19390,7 +19171,6 @@ async function loadResumableRunRecord(home, runId, authority) {
19390
19171
  let repository;
19391
19172
  let repositoryDisplay;
19392
19173
  let requestManifestPath;
19393
- let manifestDigest;
19394
19174
  let waitWindowMs;
19395
19175
  let issueNumber;
19396
19176
  let caseRunsPath;
@@ -19413,7 +19193,7 @@ async function loadResumableRunRecord(home, runId, authority) {
19413
19193
  instructionEmpty = record.instructionEmpty;
19414
19194
  }
19415
19195
  if (Array.isArray(record.attachments)) {
19416
- attachments = record.attachments;
19196
+ attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
19417
19197
  }
19418
19198
  if (record.phase === "plan" || record.phase === "apply") {
19419
19199
  phase = record.phase;
@@ -19445,12 +19225,9 @@ async function loadResumableRunRecord(home, runId, authority) {
19445
19225
  if (typeof record.repositoryDisplay === "string" && record.repositoryDisplay.trim() !== "") {
19446
19226
  repositoryDisplay = record.repositoryDisplay;
19447
19227
  }
19448
- if (typeof record.requestManifestPath === "string" && record.requestManifestPath.trim() !== "") {
19228
+ if (typeof record.requestManifestPath === "string") {
19449
19229
  requestManifestPath = record.requestManifestPath;
19450
19230
  }
19451
- if (typeof record.manifestDigest === "string" && record.manifestDigest.trim() !== "") {
19452
- manifestDigest = record.manifestDigest;
19453
- }
19454
19231
  if (typeof record.waitWindowMs === "number" && Number.isSafeInteger(record.waitWindowMs) && record.waitWindowMs >= 1) {
19455
19232
  waitWindowMs = record.waitWindowMs;
19456
19233
  }
@@ -19544,7 +19321,7 @@ async function loadResumableRunRecord(home, runId, authority) {
19544
19321
  );
19545
19322
  }
19546
19323
  }
19547
- const sourceRunLeaf = parseRunLeaf(basename12(sourceRunPath ?? ""));
19324
+ const sourceRunLeaf = parseRunLeaf(basename11(sourceRunPath ?? ""));
19548
19325
  const referencedRunId = sourceRun?.runId ?? sourceRunLeaf?.runId;
19549
19326
  const referencedRole = sourceRun?.role ?? sourceRunLeaf?.role;
19550
19327
  if (referencedRunId !== void 0 && referencedRunId !== "") {
@@ -19584,7 +19361,6 @@ async function loadResumableRunRecord(home, runId, authority) {
19584
19361
  ...repository === void 0 ? {} : { repository },
19585
19362
  ...repositoryDisplay === void 0 ? {} : { repositoryDisplay },
19586
19363
  ...requestManifestPath === void 0 ? {} : { requestManifestPath },
19587
- ...manifestDigest === void 0 ? {} : { manifestDigest },
19588
19364
  ...waitWindowMs === void 0 ? {} : { waitWindowMs },
19589
19365
  ...issueNumber === void 0 ? {} : { issueNumber },
19590
19366
  ...caseRunsPath === void 0 ? {} : { caseRunsPath },
@@ -19774,8 +19550,8 @@ function admitResumedRole(loaded) {
19774
19550
  return admitted;
19775
19551
  }
19776
19552
  case "collect-target": {
19777
- const { prNumber, repository, repositoryDisplay, manifestDigest } = fields;
19778
- if (repository === void 0 || repositoryDisplay === void 0 || manifestDigest === void 0) {
19553
+ const { prNumber, repository, repositoryDisplay } = fields;
19554
+ if (repository === void 0 || repositoryDisplay === void 0) {
19779
19555
  throw new CliUsageError(
19780
19556
  `role run admitted collector repository identity is missing: ${runId}`
19781
19557
  );
@@ -19798,8 +19574,7 @@ function admitResumedRole(loaded) {
19798
19574
  ...prNumber === void 0 ? {} : { prNumber },
19799
19575
  repository: parsedRepository,
19800
19576
  ...fields.requestManifestPath === void 0 ? {} : { requestManifestPath: fields.requestManifestPath },
19801
- ...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs },
19802
- manifestDigest
19577
+ ...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
19803
19578
  };
19804
19579
  return admitted;
19805
19580
  }
@@ -20105,7 +19880,7 @@ var init_receipt_delivery_policy = __esm({
20105
19880
  });
20106
19881
 
20107
19882
  // src/archivist-record-topology.ts
20108
- import { join as join32 } from "node:path";
19883
+ import { join as join31 } from "node:path";
20109
19884
  function resolveNavigatorWorkSubjectPlacement(input) {
20110
19885
  let ledgerHome;
20111
19886
  if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
@@ -20118,7 +19893,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
20118
19893
  const digest = sha256Hex(input.subject).slice(0, 32);
20119
19894
  return {
20120
19895
  ledgerHome,
20121
- sessionDir: join32(
19896
+ sessionDir: join31(
20122
19897
  activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
20123
19898
  NAVIGATOR_RECORD_KIND,
20124
19899
  digest
@@ -20191,7 +19966,7 @@ import {
20191
19966
  statSync as statSync8,
20192
19967
  writeFileSync as writeFileSync3
20193
19968
  } from "node:fs";
20194
- import { dirname as dirname19, resolve as resolve17, join as join33 } from "node:path";
19969
+ import { dirname as dirname19, resolve as resolve16, join as join32 } from "node:path";
20195
19970
  import { StringDecoder } from "node:string_decoder";
20196
19971
  function readCurrentSession(sessionDir) {
20197
19972
  const ledger = currentSessionLedgerPath(sessionDir);
@@ -20225,7 +20000,7 @@ function isCurrentSessionClaimRace(error) {
20225
20000
  return errnoCode(error.cause) === "EEXIST";
20226
20001
  }
20227
20002
  function currentSessionLedgerPath(sessionDir) {
20228
- return join33(sessionDir, CURRENT_SESSION_LEDGER);
20003
+ return join32(sessionDir, CURRENT_SESSION_LEDGER);
20229
20004
  }
20230
20005
  function readBoundedSessionHeader(filePath) {
20231
20006
  const fd = openSync(filePath, "r");
@@ -20298,8 +20073,8 @@ function parseSessionHeaderLine(line2) {
20298
20073
  };
20299
20074
  }
20300
20075
  function mostRecentNavigatorSessionFile(sessionDir, cwd) {
20301
- const absoluteSessionDir = resolve17(sessionDir);
20302
- const absoluteCwd = resolve17(cwd);
20076
+ const absoluteSessionDir = resolve16(sessionDir);
20077
+ const absoluteCwd = resolve16(cwd);
20303
20078
  let names;
20304
20079
  try {
20305
20080
  names = readdirSync3(absoluteSessionDir);
@@ -20312,7 +20087,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
20312
20087
  const matched = [];
20313
20088
  for (const name of names) {
20314
20089
  if (!name.endsWith(".jsonl")) continue;
20315
- const filePath = join33(absoluteSessionDir, name);
20090
+ const filePath = join32(absoluteSessionDir, name);
20316
20091
  let st;
20317
20092
  try {
20318
20093
  st = statSync8(filePath);
@@ -20334,7 +20109,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
20334
20109
  }
20335
20110
  if (header === void 0) continue;
20336
20111
  if (typeof header.cwd !== "string" || header.cwd.length === 0) continue;
20337
- if (resolve17(header.cwd) !== absoluteCwd) continue;
20112
+ if (resolve16(header.cwd) !== absoluteCwd) continue;
20338
20113
  matched.push({ path: filePath, mtimeMs: st.mtimeMs });
20339
20114
  }
20340
20115
  if (matched.length === 0) return void 0;
@@ -20364,8 +20139,8 @@ function resolveNavigatorNestContinuation(sessionDir, cwd) {
20364
20139
  }
20365
20140
  }
20366
20141
  function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
20367
- const absoluteSessionDir = resolve17(sessionDir);
20368
- const absoluteFile = resolve17(recentFile);
20142
+ const absoluteSessionDir = resolve16(sessionDir);
20143
+ const absoluteFile = resolve16(recentFile);
20369
20144
  if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
20370
20145
  throw new ActivationLedgerError(
20371
20146
  `archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
@@ -20420,7 +20195,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
20420
20195
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
20421
20196
  } else {
20422
20197
  ledgerHome = resolveActivationLedgerHomeForPath(parentFile);
20423
- const parentResolved = resolve17(parentFile);
20198
+ const parentResolved = resolve16(parentFile);
20424
20199
  if (!physicallyContainedIn(ledgerHome, parentResolved)) {
20425
20200
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
20426
20201
  }
@@ -20511,7 +20286,7 @@ init_submission_ledger();
20511
20286
  init_filed_submission();
20512
20287
  import { randomUUID as randomUUID7 } from "node:crypto";
20513
20288
  import { writeSync as writeSync2 } from "node:fs";
20514
- import { join as join35 } from "node:path";
20289
+ import { join as join34 } from "node:path";
20515
20290
  import { Value as Value4 } from "typebox/value";
20516
20291
 
20517
20292
  // src/activation-trace.ts
@@ -20563,7 +20338,7 @@ import {
20563
20338
  statSync as statSync7,
20564
20339
  writeFileSync as writeFileSync2
20565
20340
  } from "node:fs";
20566
- import { isAbsolute as isAbsolute11, resolve as resolve15 } from "node:path";
20341
+ import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
20567
20342
  var ActivationSessionFileMissingError = class extends Error {
20568
20343
  code = "AK_ACTIVATION_SESSION_FILE_MISSING";
20569
20344
  path;
@@ -20603,12 +20378,12 @@ function durableSessionPointer(sessionManager) {
20603
20378
  "Workflow role activation requires a durable Pi session file principal (getSessionFile); directory-only or --no-session invocations are rejected"
20604
20379
  );
20605
20380
  }
20606
- if (!isAbsolute11(file)) {
20381
+ if (!isAbsolute10(file)) {
20607
20382
  throw new Error(
20608
20383
  `Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
20609
20384
  );
20610
20385
  }
20611
- const resolvedFile = resolve15(file);
20386
+ const resolvedFile = resolve14(file);
20612
20387
  try {
20613
20388
  lstatSync2(resolvedFile);
20614
20389
  } catch (error) {
@@ -20852,7 +20627,7 @@ var COLLECTOR_TRANSPORT_FLAGS = Object.freeze([
20852
20627
  Object.freeze({
20853
20628
  name: "ak-collector-request-manifest",
20854
20629
  definition: Object.freeze({
20855
- description: "Path to the Collector v1 request manifest JSON file (caller guidance; not a machine collection directive).",
20630
+ description: "Caller path to a request manifest JSON file (passed as-is; package does not read or validate).",
20856
20631
  type: "string"
20857
20632
  })
20858
20633
  })
@@ -20863,19 +20638,9 @@ function buildMethodContext(activation) {
20863
20638
  `host: github.com`,
20864
20639
  `repository: ${activation.repository.canonical}`,
20865
20640
  `prNumber: ${activation.prNumber === void 0 ? "\u672A\u7ED1\u5B9A" : String(activation.prNumber)}`,
20866
- `requests: ${JSON.stringify(activation.manifest.requests.map((request) => ({ id: request.id })))}`,
20867
- `manifestDigest: ${activation.manifest.digest}`,
20641
+ ...activation.requestManifestPath === void 0 ? [] : [`requestManifestPath: ${activation.requestManifestPath}`],
20868
20642
  "</collector_method>"
20869
20643
  ];
20870
- if (activation.manifest.requests.length > 0) {
20871
- const payload = JSON.stringify({
20872
- requests: activation.manifest.requests.map((request) => ({
20873
- id: request.id,
20874
- body: request.requestBody
20875
- }))
20876
- }).replaceAll("<", "\\u003c");
20877
- lines.push("", "<collector_request_manifest>", payload, "</collector_request_manifest>");
20878
- }
20879
20644
  return lines.join("\n");
20880
20645
  }
20881
20646
  function createCollectorRoleRuntime(pi, dependencies) {
@@ -20897,12 +20662,12 @@ function createCollectorRoleRuntime(pi, dependencies) {
20897
20662
  } else if (typeof prFlag === "number") {
20898
20663
  prNumber = parseCollectorPrNumber(prFlag);
20899
20664
  }
20900
- const manifest = typeof requestManifestFlag === "string" && requestManifestFlag.trim().length > 0 ? await loadCollectorManifest(requestManifestFlag) : emptyCollectorManifest();
20665
+ const requestManifestPath = typeof requestManifestFlag === "string" ? requestManifestFlag : void 0;
20901
20666
  return {
20902
20667
  soul,
20903
20668
  repository,
20904
20669
  prNumber,
20905
- manifest
20670
+ ...requestManifestPath === void 0 ? {} : { requestManifestPath }
20906
20671
  };
20907
20672
  },
20908
20673
  assembleMaterials(activation, baseSystemPrompt) {
@@ -21189,14 +20954,14 @@ var AUDITOR_TOOL_SPEC = roleSubmissionDeclaration("auditor");
21189
20954
  init_navigator_invocation_identity();
21190
20955
  init_packaged_role_registry();
21191
20956
  init_activation_ledger_topology();
21192
- import { resolve as resolve18 } from "node:path";
20957
+ import { resolve as resolve17 } from "node:path";
21193
20958
  import "@earendil-works/pi-coding-agent";
21194
20959
  import { Type as Type21 } from "typebox";
21195
20960
 
21196
20961
  // src/navigator-public-session.ts
21197
20962
  init_host_session_record();
21198
20963
  import { existsSync as existsSync12 } from "node:fs";
21199
- import { basename as basename14 } from "node:path";
20964
+ import { basename as basename13 } from "node:path";
21200
20965
 
21201
20966
  // src/navigator-session-contracts.ts
21202
20967
  init_unknown_value();
@@ -21390,18 +21155,18 @@ init_packaged_role_registry();
21390
21155
  init_atomic_write();
21391
21156
  init_unknown_value();
21392
21157
  import { existsSync as existsSync9, realpathSync as realpathSync3 } from "node:fs";
21393
- import { readFile as readFile16 } from "node:fs/promises";
21394
- import { basename as basename13, dirname as dirname18, join as join31, resolve as resolve16 } from "node:path";
21158
+ import { readFile as readFile15 } from "node:fs/promises";
21159
+ import { basename as basename12, dirname as dirname18, join as join30, resolve as resolve15 } from "node:path";
21395
21160
  var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
21396
21161
  function navigatorWorkContextFile(sessionDir) {
21397
- return join31(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
21162
+ return join30(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
21398
21163
  }
21399
21164
  function isNavigatorWorkContextFile(path) {
21400
- const resolved = resolve16(path);
21401
- if (basename13(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
21165
+ const resolved = resolve15(path);
21166
+ if (basename12(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
21402
21167
  const nest = dirname18(resolved);
21403
- if (!/^[0-9a-f]{32}$/.test(basename13(nest))) return false;
21404
- return basename13(dirname18(nest)) === "navigator";
21168
+ if (!/^[0-9a-f]{32}$/.test(basename12(nest))) return false;
21169
+ return basename12(dirname18(nest)) === "navigator";
21405
21170
  }
21406
21171
  function canonicalNavigatorWorkContextFile(path) {
21407
21172
  if (!isNavigatorWorkContextFile(path)) return void 0;
@@ -21419,7 +21184,7 @@ async function persistNavigatorWorkBase(sessionDir, body) {
21419
21184
  const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}
21420
21185
  `;
21421
21186
  try {
21422
- const current = await readFile16(path, "utf8");
21187
+ const current = await readFile15(path, "utf8");
21423
21188
  if (current === next) return path;
21424
21189
  } catch (error) {
21425
21190
  if (!isEnoent(error)) throw error;
@@ -21432,7 +21197,7 @@ async function readNavigatorWorkBase(path) {
21432
21197
  if (canonical === void 0) return void 0;
21433
21198
  let text;
21434
21199
  try {
21435
- text = await readFile16(canonical, "utf8");
21200
+ text = await readFile15(canonical, "utf8");
21436
21201
  } catch (error) {
21437
21202
  if (isEnoent(error)) return void 0;
21438
21203
  throw error;
@@ -21506,7 +21271,7 @@ async function resolveNavigatorLedgerHome(context) {
21506
21271
  }
21507
21272
  var NAVIGATOR_HOST_RUN_POINTER_ENTRY = "ak-navigator-host-run";
21508
21273
  function runIdFromNavigatorDirectory(runDirectory) {
21509
- const parsed = parseRunLeaf(basename14(runDirectory));
21274
+ const parsed = parseRunLeaf(basename13(runDirectory));
21510
21275
  if (parsed === void 0 || parsed.role !== "navigator") return void 0;
21511
21276
  return parsed.runId;
21512
21277
  }
@@ -21743,7 +21508,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
21743
21508
  }
21744
21509
  function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
21745
21510
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
21746
- const resolvedReference = resolve18(cwd, reference);
21511
+ const resolvedReference = resolve17(cwd, reference);
21747
21512
  const marker = "/runs/";
21748
21513
  if (resolvedReference.includes(marker)) {
21749
21514
  return subjectRoot;
@@ -22188,7 +21953,7 @@ init_submission_errors();
22188
21953
  init_worker_submission_contracts();
22189
21954
  import { execFileSync as execFileSync3 } from "node:child_process";
22190
21955
  import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync3 } from "node:fs";
22191
- import { resolve as resolve19 } from "node:path";
21956
+ import { resolve as resolve18 } from "node:path";
22192
21957
  var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
22193
21958
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
22194
21959
  var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
@@ -22236,7 +22001,7 @@ function escapeGitConfigValueRegex(value) {
22236
22001
  function unsetOwnedHooksPath(file) {
22237
22002
  const owned = [];
22238
22003
  for (const value of tryGetAll(file, "core.hooksPath")) {
22239
- if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
22004
+ if (!ownedHook(resolve18(value, HOOK_FILE))) continue;
22240
22005
  try {
22241
22006
  gitFile(file, [
22242
22007
  "--unset-all",
@@ -22251,15 +22016,15 @@ function unsetOwnedHooksPath(file) {
22251
22016
  return owned;
22252
22017
  }
22253
22018
  function rmOwnedDir(dir) {
22254
- const hookPath = resolve19(dir, HOOK_FILE);
22019
+ const hookPath = resolve18(dir, HOOK_FILE);
22255
22020
  if (!ownedHook(hookPath)) return;
22256
22021
  rmSync3(hookPath, { force: true });
22257
22022
  if (existsSync13(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
22258
22023
  }
22259
22024
  function linkedGitDirs(commonDir) {
22260
- const root = resolve19(commonDir, "worktrees");
22025
+ const root = resolve18(commonDir, "worktrees");
22261
22026
  if (!existsSync13(root)) return [];
22262
- return readdirSync4(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22027
+ return readdirSync4(root).map((name) => resolve18(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22263
22028
  }
22264
22029
  function uninstallPackageWorkerHooks(cwd) {
22265
22030
  let inside;
@@ -22273,14 +22038,14 @@ function uninstallPackageWorkerHooks(cwd) {
22273
22038
  const clear = (configFile) => {
22274
22039
  for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
22275
22040
  };
22276
- clear(resolve19(commonDir, "config"));
22277
- clear(resolve19(commonDir, "config.worktree"));
22278
- rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
22279
- const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
22041
+ clear(resolve18(commonDir, "config"));
22042
+ clear(resolve18(commonDir, "config.worktree"));
22043
+ rmOwnedDir(resolve18(commonDir, HOOKS_DIR));
22044
+ const legacy = resolve18(commonDir, "hooks", HOOK_FILE);
22280
22045
  if (ownedHook(legacy)) rmSync3(legacy, { force: true });
22281
22046
  for (const gitDir of linkedGitDirs(commonDir)) {
22282
- clear(resolve19(gitDir, "config.worktree"));
22283
- rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
22047
+ clear(resolve18(gitDir, "config.worktree"));
22048
+ rmOwnedDir(resolve18(gitDir, HOOKS_DIR));
22284
22049
  }
22285
22050
  }
22286
22051
  function containsWrittenReason(value) {
@@ -23152,7 +22917,7 @@ function readRoleRunCoordinates(ctx, label) {
23152
22917
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
23153
22918
  const admitted = readPageSync(runDirectory, "admitted");
23154
22919
  if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
23155
- throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join35(runDirectory, RUN_STATE_FILE)})`);
22920
+ throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join34(runDirectory, RUN_STATE_FILE)})`);
23156
22921
  }
23157
22922
  return {
23158
22923
  runDirectory,
@@ -23991,11 +23756,11 @@ init_settlement();
23991
23756
  init_run_lifecycle();
23992
23757
  init_unknown_value();
23993
23758
  async function listen(server, path) {
23994
- await new Promise((resolve22, reject) => {
23759
+ await new Promise((resolve21, reject) => {
23995
23760
  server.once("error", reject);
23996
23761
  server.listen(path, () => {
23997
23762
  server.off("error", reject);
23998
- resolve22();
23763
+ resolve21();
23999
23764
  });
24000
23765
  });
24001
23766
  }
@@ -24420,8 +24185,8 @@ async function prepareRoleEnvelope(options) {
24420
24185
  try {
24421
24186
  const closeAll = server.closeAllConnections;
24422
24187
  if (typeof closeAll === "function") closeAll.call(server);
24423
- await new Promise((resolve22, reject) => {
24424
- server.close((error) => error ? reject(error) : resolve22());
24188
+ await new Promise((resolve21, reject) => {
24189
+ server.close((error) => error ? reject(error) : resolve21());
24425
24190
  });
24426
24191
  } catch (error) {
24427
24192
  await retainPackageFault({
@@ -24554,7 +24319,7 @@ async function prepareRoleEnvelope(options) {
24554
24319
  }
24555
24320
 
24556
24321
  // src/role-runtime-dependencies.ts
24557
- import { readFile as readFile18 } from "node:fs/promises";
24322
+ import { readFile as readFile17 } from "node:fs/promises";
24558
24323
  init_doctor_evidence();
24559
24324
 
24560
24325
  // src/navigator-work-context.ts
@@ -24562,8 +24327,8 @@ init_role_run_placement();
24562
24327
  init_doctor_evidence();
24563
24328
  init_unknown_value();
24564
24329
  init_host_contracts();
24565
- import { readFile as readFile17 } from "node:fs/promises";
24566
- import { resolve as resolve20 } from "node:path";
24330
+ import { readFile as readFile16 } from "node:fs/promises";
24331
+ import { resolve as resolve19 } from "node:path";
24567
24332
  init_notary_source_run();
24568
24333
  init_packaged_role_registry();
24569
24334
  init_invocation();
@@ -24571,12 +24336,12 @@ function navigatorInputReference(getFlag, role) {
24571
24336
  if (getFlag === void 0) return void 0;
24572
24337
  const name = packagedRoleInputFlag(role);
24573
24338
  const value = name === void 0 ? void 0 : getFlag(name);
24574
- return typeof value === "string" && value !== "" ? resolve20(value) : void 0;
24339
+ return typeof value === "string" && value !== "" ? resolve19(value) : void 0;
24575
24340
  }
24576
24341
  async function loadNavigatorWorkContext(options) {
24577
24342
  const reference = navigatorInputReference(options.getFlag, options.role);
24578
24343
  const subjectMode = packagedNavigatorSubject(options.role);
24579
- const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile17(reference, "utf8");
24344
+ const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile16(reference, "utf8");
24580
24345
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
24581
24346
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
24582
24347
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -24593,7 +24358,7 @@ async function loadNavigatorWorkContext(options) {
24593
24358
  }
24594
24359
  const publicRunDir = runDirectoryFromHostContext(options.context);
24595
24360
  const currentSessionDir = options.context.sessionManager.getSessionDir();
24596
- const isBoundPublicRun = publicRunDir !== void 0 && resolve20(currentSessionDir) === resolve20(sessionDirectoryOf(publicRunDir));
24361
+ const isBoundPublicRun = publicRunDir !== void 0 && resolve19(currentSessionDir) === resolve19(sessionDirectoryOf(publicRunDir));
24597
24362
  if (subjectMode === "public-instruction" && isBoundPublicRun) {
24598
24363
  let admitted;
24599
24364
  try {
@@ -24626,14 +24391,14 @@ async function loadNavigatorWorkContext(options) {
24626
24391
  }
24627
24392
  const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
24628
24393
  const authorityFiles = workRoot === void 0 ? [] : [
24629
- resolve20(workRoot, "authority.md"),
24630
- resolve20(workRoot, "authority.txt"),
24631
- resolve20(workRoot, "design-v2/owner-direction.md")
24394
+ resolve19(workRoot, "authority.md"),
24395
+ resolve19(workRoot, "authority.txt"),
24396
+ resolve19(workRoot, "design-v2/owner-direction.md")
24632
24397
  ];
24633
24398
  let authorityMaterial;
24634
24399
  for (const path of authorityFiles) {
24635
24400
  try {
24636
- const content = await readFile17(path, "utf8");
24401
+ const content = await readFile16(path, "utf8");
24637
24402
  if (content.trim() !== "") {
24638
24403
  authorityMaterial = content;
24639
24404
  break;
@@ -24675,11 +24440,11 @@ function createRoleRuntimeDependencies(packageRoot) {
24675
24440
  packageRoot,
24676
24441
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
24677
24442
  loadRoleSoul: loadRegisteredRoleSoul,
24678
- loadFixPacket: (path) => readFile18(path, "utf8"),
24679
- loadCoderTask: (path) => readFile18(path, "utf8"),
24443
+ loadFixPacket: (path) => readFile17(path, "utf8"),
24444
+ loadCoderTask: (path) => readFile17(path, "utf8"),
24680
24445
  loadDoctorCase,
24681
24446
  loadNotarySourceRun: loadNotarySourceRunLocator,
24682
- loadMergerInput: async (path) => JSON.parse(await readFile18(path, "utf8")),
24447
+ loadMergerInput: async (path) => JSON.parse(await readFile17(path, "utf8")),
24683
24448
  loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
24684
24449
  context: options.context,
24685
24450
  role: options.role,
@@ -24762,7 +24527,7 @@ function hostAbortedError(message = "host aborted") {
24762
24527
  function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
24763
24528
  if (abortSignal?.aborted) return Promise.reject(hostAbortedError(message));
24764
24529
  if (abortSignal === void 0) return work;
24765
- return new Promise((resolve22, reject) => {
24530
+ return new Promise((resolve21, reject) => {
24766
24531
  let settled = false;
24767
24532
  const onAbort = () => {
24768
24533
  if (settled) return;
@@ -24777,7 +24542,7 @@ function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
24777
24542
  if (settled) return;
24778
24543
  settled = true;
24779
24544
  abortSignal.removeEventListener("abort", onAbort);
24780
- resolve22(value);
24545
+ resolve21(value);
24781
24546
  },
24782
24547
  (error) => {
24783
24548
  if (settled) return;
@@ -25039,19 +24804,19 @@ function connectAcpStdio(options) {
25039
24804
  terminate(error);
25040
24805
  }
25041
24806
  });
25042
- const processClosed = new Promise((resolve22) => {
24807
+ const processClosed = new Promise((resolve21) => {
25043
24808
  child.once("close", (code, signal) => {
25044
24809
  if (spawned) nativeExit = { code, timedOut: false, ...signal === null ? {} : { signal } };
25045
24810
  settleClosed(acpError("acp-closed", "ACP process closed"));
25046
- resolve22();
24811
+ resolve21();
25047
24812
  });
25048
24813
  });
25049
24814
  return Promise.resolve({
25050
24815
  request(method, params) {
25051
24816
  if (closed) return Promise.reject(terminalError);
25052
24817
  const id = ++nextId;
25053
- return new Promise((resolve22, reject) => {
25054
- pending.set(id, { resolve: resolve22, reject });
24818
+ return new Promise((resolve21, reject) => {
24819
+ pending.set(id, { resolve: resolve21, reject });
25055
24820
  child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
25056
24821
  `, (error) => {
25057
24822
  if (error === null || error === void 0) return;
@@ -25332,13 +25097,13 @@ function createAcpRoleTurnHost(config) {
25332
25097
 
25333
25098
  // src/acp-host/seat-profile-soul.ts
25334
25099
  import { constants as constants3 } from "node:fs";
25335
- import { access as access3, copyFile, lstat as lstat5, mkdir as mkdir4, readlink, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
25336
- import { dirname as dirname22, join as join36, relative as relative3, resolve as resolve21 } from "node:path";
25100
+ import { access as access3, copyFile, lstat as lstat4, mkdir as mkdir4, readlink, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
25101
+ import { dirname as dirname22, join as join35, relative as relative3, resolve as resolve20 } from "node:path";
25337
25102
  function seatProfileName(spec, role) {
25338
25103
  return `${spec.namePrefix}${role}`;
25339
25104
  }
25340
25105
  function packageRoleSoulPath(packageRoot, role) {
25341
- return join36(packageRoot, "souls", `${role}.md`);
25106
+ return join35(packageRoot, "souls", `${role}.md`);
25342
25107
  }
25343
25108
  async function pathExists2(path) {
25344
25109
  try {
@@ -25351,20 +25116,20 @@ async function pathExists2(path) {
25351
25116
  async function ensureSeatProfileSoul(options) {
25352
25117
  const { spec, operatorHome, packageRoot, role } = options;
25353
25118
  const profileName = seatProfileName(spec, role);
25354
- const soulTarget = resolve21(packageRoleSoulPath(packageRoot, role));
25119
+ const soulTarget = resolve20(packageRoleSoulPath(packageRoot, role));
25355
25120
  if (!await pathExists2(soulTarget)) {
25356
25121
  throw new Error(`packaged role soul missing: ${soulTarget}`);
25357
25122
  }
25358
- const profilesRoot = join36(operatorHome, ...spec.profilesRootFromHome);
25359
- const profileDir = join36(profilesRoot, profileName);
25123
+ const profilesRoot = join35(operatorHome, ...spec.profilesRootFromHome);
25124
+ const profileDir = join35(profilesRoot, profileName);
25360
25125
  const hostRoot = dirname22(profilesRoot);
25361
- const soulPath = join36(profileDir, spec.soulFileName);
25126
+ const soulPath = join35(profileDir, spec.soulFileName);
25362
25127
  if (!await pathExists2(profileDir)) {
25363
25128
  await mkdir4(profileDir, { recursive: true });
25364
25129
  for (const name of ["auth.json", ".env", "config.yaml"]) {
25365
- const source = join36(hostRoot, name);
25130
+ const source = join35(hostRoot, name);
25366
25131
  if (!await pathExists2(source)) continue;
25367
- await copyFile(source, join36(profileDir, name));
25132
+ await copyFile(source, join35(profileDir, name));
25368
25133
  }
25369
25134
  } else {
25370
25135
  await mkdir4(profileDir, { recursive: true });
@@ -25372,7 +25137,7 @@ async function ensureSeatProfileSoul(options) {
25372
25137
  const desiredLink = relative3(profileDir, soulTarget);
25373
25138
  let current;
25374
25139
  try {
25375
- const st = await lstat5(soulPath);
25140
+ const st = await lstat4(soulPath);
25376
25141
  if (st.isSymbolicLink()) {
25377
25142
  current = await readlink(soulPath);
25378
25143
  }