@akagilnc/pi-workflow-roles 0.1.5577 → 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;
@@ -5880,84 +5842,6 @@ var init_notary_source_run = __esm({
5880
5842
  }
5881
5843
  });
5882
5844
 
5883
- // src/package-resources/engine-material.ts
5884
- import { existsSync as existsSync3, readdirSync as readdirSync2 } from "node:fs";
5885
- import { join as join11 } from "node:path";
5886
- function pickEngineAxis(source) {
5887
- return {
5888
- ...source.engine === void 0 ? {} : { engine: source.engine },
5889
- ...source.engineModel === void 0 ? {} : { engineModel: source.engineModel }
5890
- };
5891
- }
5892
- function assertLegalEngineModel(model) {
5893
- if (typeof model !== "string" || model.trim() === "" || model.trim() !== model) {
5894
- throw new Error(`illegal engine model: ${JSON.stringify(model)}`);
5895
- }
5896
- return model;
5897
- }
5898
- function isEngineNameSyntax(name) {
5899
- if (typeof name !== "string") return false;
5900
- if (name.length === 0 || name.trim() !== name) return false;
5901
- if (name === "." || name === "..") return false;
5902
- if (name.includes("/") || name.includes("\\") || name.includes("\0")) return false;
5903
- return true;
5904
- }
5905
- function resolveEngineMaterialDirectory(packageRoot) {
5906
- return join11(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
5907
- }
5908
- function resolveEngineMaterialPath(packageRoot, name) {
5909
- const legal = assertLegalEngineName(name);
5910
- return join11(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
5911
- }
5912
- function assertLegalEngineName(name) {
5913
- if (!isEngineNameSyntax(name)) {
5914
- throw new Error(`illegal engine name: ${name}`);
5915
- }
5916
- return name;
5917
- }
5918
- function engineSessionMaterialFromOptions(options) {
5919
- if (options.engine === void 0) return void 0;
5920
- if (options.packageRoot === void 0 || options.packageRoot.trim() === "") {
5921
- throw new Error("packageRoot is required when engine is configured");
5922
- }
5923
- const name = assertLegalEngineName(options.engine);
5924
- const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
5925
- const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
5926
- const modelField = model === void 0 ? {} : { model };
5927
- if (existsSync3(materialPath)) {
5928
- return Object.freeze({ name, materialPath, ...modelField });
5929
- }
5930
- return Object.freeze({ name, ...modelField });
5931
- }
5932
- function appendEngineSessionMaterial(lines, engineMaterial) {
5933
- if (engineMaterial === void 0) {
5934
- return [...lines];
5935
- }
5936
- const out = [...lines];
5937
- out.push("");
5938
- if (engineMaterial.materialPath !== void 0) {
5939
- out.push("\u672C\u6B21\u914D\u7F6E\u7684\u52B3\u52A1\u5F15\u64CE\u53CA\u5176\u624B\u518C\uFF1A");
5940
- out.push(`- engine: ${engineMaterial.name}`);
5941
- if (engineMaterial.model !== void 0) {
5942
- out.push(`- engineModel: ${engineMaterial.model}`);
5943
- }
5944
- out.push(`- ${engineMaterial.materialPath}`);
5945
- } else {
5946
- out.push(`- engine: ${engineMaterial.name}`);
5947
- if (engineMaterial.model !== void 0) {
5948
- out.push(`- engineModel: ${engineMaterial.model}`);
5949
- }
5950
- }
5951
- return out;
5952
- }
5953
- var ENGINE_MATERIAL_RELATIVE_ROOT;
5954
- var init_engine_material = __esm({
5955
- "src/package-resources/engine-material.ts"() {
5956
- "use strict";
5957
- ENGINE_MATERIAL_RELATIVE_ROOT = "resources/engines";
5958
- }
5959
- });
5960
-
5961
5845
  // src/public-cli/registry.ts
5962
5846
  var registry_exports = {};
5963
5847
  __export(registry_exports, {
@@ -6434,8 +6318,8 @@ var init_option_definitions = __esm({
6434
6318
  repeatable: true,
6435
6319
  form: "option",
6436
6320
  description: {
6437
- en: "Attach a regular file; frozen at admission (repeatable).",
6438
- 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"
6439
6323
  }
6440
6324
  };
6441
6325
  SHARED_PHASE_SEMANTICS = {
@@ -6610,8 +6494,8 @@ var init_option_definitions = __esm({
6610
6494
  repeatable: false,
6611
6495
  form: "option",
6612
6496
  description: {
6613
- 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.",
6614
- 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"
6615
6499
  }
6616
6500
  }
6617
6501
  ];
@@ -7068,18 +6952,24 @@ var init_option_definitions = __esm({
7068
6952
 
7069
6953
  // src/public-cli/invocation.ts
7070
6954
  import { execFileSync as execFileSync2 } from "node:child_process";
7071
- import { existsSync as existsSync4 } from "node:fs";
6955
+ import { existsSync as existsSync3 } from "node:fs";
7072
6956
  import {
7073
- lstat as lstat2,
7074
- mkdtemp,
7075
- readFile as readFile8,
6957
+ readFile as readFile7,
7076
6958
  realpath as realpath3,
7077
6959
  rename,
7078
- rm,
7079
6960
  writeFile
7080
6961
  } from "node:fs/promises";
7081
- import { tmpdir } from "node:os";
7082
- import { basename as basename8, dirname as dirname8, isAbsolute as isAbsolute5, join as join12, 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
+ }
7083
6973
  function issueAdmissionPlacement(authority, request) {
7084
6974
  const ledgerHome = resolveActivationLedgerHome(request.home);
7085
6975
  const bookKey = resolveBookKeyFromGit(request.cwd);
@@ -7222,8 +7112,8 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
7222
7112
  const childRunIds = readPageSync(oldRunDirectory, "admitted")?.childDiaristRunIds;
7223
7113
  for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
7224
7114
  if (typeof childRunId !== "string") continue;
7225
- const childDirectory = join12(dirname8(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
7226
- if (!existsSync4(childDirectory)) continue;
7115
+ const childDirectory = join11(dirname8(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
7116
+ if (!existsSync3(childDirectory)) continue;
7227
7117
  const childTarget = roleRunPlacement(ledgerHome, {
7228
7118
  bookKey: admitted.bookKey,
7229
7119
  subject: { ticketNumber: admitted.ticketNumber },
@@ -7258,19 +7148,11 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
7258
7148
  "taskPath",
7259
7149
  "packetPath",
7260
7150
  "prerequisitesPath",
7261
- "requestManifestPath",
7262
7151
  "mergerInputPath"
7263
7152
  ],
7264
7153
  oldRunDirectory,
7265
7154
  target.runDirectory
7266
7155
  );
7267
- for (const attachment of admitted.attachments) {
7268
- attachment.frozenPath = rewriteRunDirectoryPathValue(
7269
- attachment.frozenPath,
7270
- oldRunDirectory,
7271
- target.runDirectory
7272
- );
7273
- }
7274
7156
  admitted.principal = principal;
7275
7157
  renderCurrentSync(target.runDirectory);
7276
7158
  return { oldRunDirectory, newRunDirectory: target.runDirectory };
@@ -7307,7 +7189,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
7307
7189
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
7308
7190
  const rolePackageRoot = packageRoot;
7309
7191
  const raw = JSON.parse(
7310
- await readFile8(join12(rolePackageRoot, "package.json"), "utf8")
7192
+ await readFile7(join11(rolePackageRoot, "package.json"), "utf8")
7311
7193
  );
7312
7194
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
7313
7195
  throw new Error(
@@ -7363,7 +7245,7 @@ function assignPublicSeatOption(owner, taken, fields) {
7363
7245
  const value = taken.value;
7364
7246
  switch (taken.def.id) {
7365
7247
  case "attach":
7366
- fields.attachmentPaths.push(requireOptionPath(taken.def.canonical, value));
7248
+ fields.attachmentPaths.push(requireProvidedOptionValue(taken.def.canonical, value));
7367
7249
  return;
7368
7250
  case "project":
7369
7251
  fields.project = requireOptionPath(taken.def.canonical, value);
@@ -7407,7 +7289,7 @@ function assignPublicSeatOption(owner, taken, fields) {
7407
7289
  fields.repo = parseRepoOption(value);
7408
7290
  return;
7409
7291
  case "request-manifest":
7410
- fields.requestManifestPath = requireOptionPath(taken.def.canonical, value);
7292
+ fields.requestManifestPath = requireProvidedOptionValue(taken.def.canonical, value);
7411
7293
  return;
7412
7294
  case "issue": {
7413
7295
  if (value === void 0 || value.trim() === "") {
@@ -7522,6 +7404,12 @@ function requireOptionPath(flag, value) {
7522
7404
  }
7523
7405
  return value;
7524
7406
  }
7407
+ function requireProvidedOptionValue(flag, value) {
7408
+ if (value === void 0) {
7409
+ throw new CliUsageError(`${flag} requires a path`);
7410
+ }
7411
+ return value;
7412
+ }
7525
7413
  function skillArgTokenFault(value) {
7526
7414
  if (value === void 0 || value.trim() === "") return "empty";
7527
7415
  if (/\s/.test(value)) return "whitespace";
@@ -7574,124 +7462,6 @@ function requireAuthorityRef(value) {
7574
7462
  optionLike: "--authority-ref requires a durable reference, not inline Spec prose"
7575
7463
  });
7576
7464
  }
7577
- async function readRegularFileAttachment(sourcePath) {
7578
- const absolute = isAbsolute5(sourcePath) ? sourcePath : resolve9(sourcePath);
7579
- let st;
7580
- try {
7581
- st = await lstat2(absolute);
7582
- } catch (error) {
7583
- throw new CliUsageError(
7584
- `attachment is not a readable regular file: ${sourcePath}`,
7585
- { cause: error }
7586
- );
7587
- }
7588
- if (!st.isFile() || st.isSymbolicLink()) {
7589
- throw new CliUsageError(
7590
- `attachment must be a regular file (not a directory or symlink): ${sourcePath}`
7591
- );
7592
- }
7593
- try {
7594
- return { absolute, bytes: await readFile8(absolute) };
7595
- } catch (error) {
7596
- throw new CliUsageError(
7597
- `attachment is not a readable regular file: ${sourcePath}`,
7598
- { cause: error }
7599
- );
7600
- }
7601
- }
7602
- async function removePreparedAttachmentDirectory(stagingDirectory) {
7603
- await rm(stagingDirectory, { recursive: true, force: true });
7604
- }
7605
- async function withPreparedAttachments(attachmentPaths, use) {
7606
- if (attachmentPaths.length === 0) return await use([]);
7607
- const stagingDirectory = await mkdtemp(join12(tmpdir(), "ak-role-attachments-"));
7608
- const prepared = [];
7609
- let result;
7610
- try {
7611
- for (let index = 0; index < attachmentPaths.length; index += 1) {
7612
- const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
7613
- const snapshotPath = join12(stagingDirectory, String(index).padStart(6, "0"));
7614
- await writeFile(snapshotPath, bytes);
7615
- prepared.push({ absolute, snapshotPath });
7616
- }
7617
- result = await use(prepared);
7618
- } catch (primary) {
7619
- try {
7620
- await removePreparedAttachmentDirectory(stagingDirectory);
7621
- } catch (cleanup) {
7622
- throw new AggregateError(
7623
- [primary, cleanup],
7624
- "attachment snapshot operation failed and cleanup also failed",
7625
- { cause: primary }
7626
- );
7627
- }
7628
- throw primary;
7629
- }
7630
- await removePreparedAttachmentDirectory(stagingDirectory);
7631
- return result;
7632
- }
7633
- async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
7634
- const frozenPath = join12(
7635
- destinationDir,
7636
- `${String(index).padStart(2, "0")}-${basename8(provenancePath)}`
7637
- );
7638
- await writeFile(frozenPath, bytes);
7639
- return {
7640
- provenancePath,
7641
- frozenPath,
7642
- byteLength: bytes.byteLength,
7643
- sha256: sha256Hex(bytes),
7644
- mediaKind: "regular-file"
7645
- };
7646
- }
7647
- async function freezePreparedAttachment(prepared, destinationDir, index) {
7648
- return freezeAttachmentBytes(
7649
- prepared.absolute,
7650
- await readFile8(prepared.snapshotPath),
7651
- destinationDir,
7652
- index
7653
- );
7654
- }
7655
- async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
7656
- const { absolute, bytes } = await readRegularFileAttachment(sourcePath);
7657
- return {
7658
- attachment: await freezeAttachmentBytes(absolute, bytes, destinationDir, index),
7659
- body: bytes
7660
- };
7661
- }
7662
- async function freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory) {
7663
- const attachments = [];
7664
- if (attachmentPaths.length > 0) {
7665
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
7666
- }
7667
- for (let i = 0; i < attachmentPaths.length; i += 1) {
7668
- const frozen = await freezeRegularFileAttachment(
7669
- attachmentPaths[i],
7670
- attachmentsDirectory,
7671
- i
7672
- );
7673
- attachments.push(frozen.attachment);
7674
- }
7675
- return attachments;
7676
- }
7677
- async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
7678
- if (attachmentPaths.length === 0) return [];
7679
- const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
7680
- const attachmentsDirectory = join12(runDirectory, "attachments", summonsKey);
7681
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
7682
- return freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory);
7683
- }
7684
- async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
7685
- if (prepared.length === 0) return [];
7686
- const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
7687
- const attachmentsDirectory = summonsKey === void 0 ? join12(runDirectory, "attachments") : join12(runDirectory, "attachments", summonsKey);
7688
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
7689
- const attachments = [];
7690
- for (let index = 0; index < prepared.length; index += 1) {
7691
- attachments.push(await freezePreparedAttachment(prepared[index], attachmentsDirectory, index));
7692
- }
7693
- return attachments;
7694
- }
7695
7465
  function ticketAdmissionFields(ticketNumber) {
7696
7466
  if (ticketNumber === void 0) return {};
7697
7467
  return {
@@ -7761,7 +7531,7 @@ async function admitPublicRole(role, parsed, env, override) {
7761
7531
  attachmentPaths,
7762
7532
  ...project,
7763
7533
  placedFields: async (placed) => {
7764
- const taskPath = join12(placed.runDirectory, "task.md");
7534
+ const taskPath = join11(placed.runDirectory, "task.md");
7765
7535
  await writeFile(taskPath, instruction, "utf8");
7766
7536
  return { phase, taskPath };
7767
7537
  }
@@ -7780,7 +7550,7 @@ async function admitPublicRole(role, parsed, env, override) {
7780
7550
  if (parsed.prerequisitesPath !== void 0) {
7781
7551
  const absolutePrereq = isAbsolute5(parsed.prerequisitesPath) ? parsed.prerequisitesPath : resolve9(parsed.prerequisitesPath);
7782
7552
  try {
7783
- prerequisitesSource = await readFile8(absolutePrereq, "utf8");
7553
+ prerequisitesSource = await readFile7(absolutePrereq, "utf8");
7784
7554
  } catch (error) {
7785
7555
  throw new CliUsageError(
7786
7556
  `fixer prerequisites path is unreadable: ${parsed.prerequisitesPath}`,
@@ -7804,7 +7574,7 @@ async function admitPublicRole(role, parsed, env, override) {
7804
7574
  placedFields: async (placed) => {
7805
7575
  let prerequisitesPath;
7806
7576
  if (prerequisitesSource !== void 0) {
7807
- prerequisitesPath = join12(placed.runDirectory, "prerequisites.json");
7577
+ prerequisitesPath = join11(placed.runDirectory, "prerequisites.json");
7808
7578
  await writeFile(
7809
7579
  prerequisitesPath,
7810
7580
  `${JSON.stringify(prerequisites, null, 2)}
@@ -7812,7 +7582,7 @@ async function admitPublicRole(role, parsed, env, override) {
7812
7582
  "utf8"
7813
7583
  );
7814
7584
  }
7815
- const packetPath = join12(placed.runDirectory, "fix-packet.md");
7585
+ const packetPath = join11(placed.runDirectory, "fix-packet.md");
7816
7586
  await writeFile(packetPath, instruction, "utf8");
7817
7587
  return {
7818
7588
  phase,
@@ -7837,37 +7607,17 @@ async function admitPublicRole(role, parsed, env, override) {
7837
7607
  } else {
7838
7608
  repository = resolveGitHubRemoteRepository(projectRoot);
7839
7609
  }
7840
- let manifest = emptyCollectorManifest();
7841
- let manifestCanonicalJson;
7842
- if (parsed.requestManifestPath !== void 0) {
7843
- try {
7844
- manifest = await loadCollectorManifest(parsed.requestManifestPath);
7845
- manifestCanonicalJson = manifest.canonicalJson;
7846
- } catch (error) {
7847
- throw new CliUsageError(
7848
- errorText(error),
7849
- { cause: error }
7850
- );
7851
- }
7852
- }
7853
- const manifestDigest = manifest.digest;
7854
7610
  const admittedCollector = await admitStandardMaterialInvocation("collector", {
7855
7611
  ...shared,
7856
7612
  instruction,
7857
7613
  attachmentPaths,
7858
7614
  ...project,
7859
- placedFields: async (placed) => {
7860
- let requestManifestPath;
7861
- if (manifestCanonicalJson !== void 0) {
7862
- requestManifestPath = join12(placed.runDirectory, "request-manifest.json");
7863
- await writeFile(requestManifestPath, manifestCanonicalJson, "utf8");
7864
- }
7615
+ placedFields: async () => {
7865
7616
  return {
7866
7617
  ...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
7867
7618
  repository: repository.canonical,
7868
7619
  repositoryDisplay: repository.display,
7869
- ...requestManifestPath === void 0 ? {} : { requestManifestPath },
7870
- manifestDigest
7620
+ ...parsed.requestManifestPath === void 0 ? {} : { requestManifestPath: parsed.requestManifestPath }
7871
7621
  };
7872
7622
  }
7873
7623
  });
@@ -7880,12 +7630,10 @@ async function admitPublicRole(role, parsed, env, override) {
7880
7630
  );
7881
7631
  }
7882
7632
  const issueNumber = parsed.issueNumber;
7883
- let frozenAttachments = [];
7884
- const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
7633
+ return admitStandardMaterialInvocation("doctor", {
7885
7634
  ...shared,
7886
7635
  instruction,
7887
- attachmentPaths: [],
7888
- freezeAttachments: false,
7636
+ attachmentPaths,
7889
7637
  ...project,
7890
7638
  placedFields: async (placed) => {
7891
7639
  let caseRunsPath;
@@ -7926,16 +7674,13 @@ async function admitPublicRole(role, parsed, env, override) {
7926
7674
  { cause: error }
7927
7675
  );
7928
7676
  }
7929
- frozenAttachments = await freezeAttachments(placed.ledgerHome, attachmentPaths, placed.attachmentsDirectory);
7930
7677
  return {
7931
7678
  issueNumber,
7932
7679
  caseRunsPath,
7933
- caseIdentity,
7934
- attachments: persistedAttachmentRefs(frozenAttachments)
7680
+ caseIdentity
7935
7681
  };
7936
7682
  }
7937
7683
  });
7938
- return { ...admittedDoctor, attachments: frozenAttachments };
7939
7684
  }
7940
7685
  case "source-locator": {
7941
7686
  const projectRoot = resolve9(parsed.project ?? shared.cwd);
@@ -7962,7 +7707,7 @@ async function admitPublicRole(role, parsed, env, override) {
7962
7707
  instruction: "",
7963
7708
  attachmentPaths: [],
7964
7709
  ...project,
7965
- freezeAttachments: false,
7710
+ recordAttachments: false,
7966
7711
  admittedFields: {
7967
7712
  sourceRunPath: sourceRun.runDirectory,
7968
7713
  sourceRun
@@ -7979,7 +7724,7 @@ async function admitPublicRole(role, parsed, env, override) {
7979
7724
  instruction,
7980
7725
  attachmentPaths: [],
7981
7726
  ...project,
7982
- freezeAttachments: false,
7727
+ recordAttachments: false,
7983
7728
  admittedFields: { baseRevision }
7984
7729
  });
7985
7730
  }
@@ -8045,7 +7790,7 @@ async function admitPublicRole(role, parsed, env, override) {
8045
7790
  resolutionScope: [...derived.resolutionScope],
8046
7791
  authorizedChecks: []
8047
7792
  });
8048
- const mergerInputPath = join12(placed.runDirectory, "merger-input.json");
7793
+ const mergerInputPath = join11(placed.runDirectory, "merger-input.json");
8049
7794
  await writeFile(
8050
7795
  mergerInputPath,
8051
7796
  `${JSON.stringify(mergerInput, null, 2)}
@@ -8091,7 +7836,7 @@ async function placeRoleAdmission(options) {
8091
7836
  home: options.home,
8092
7837
  ...options.materialize === void 0 ? {} : { materialize: options.materialize }
8093
7838
  });
8094
- const attachments = options.freezeAttachments === false ? [] : await freezeAttachments(ledgerHome, options.attachmentPaths, attachmentsDirectory);
7839
+ const attachments = options.recordAttachments === false ? [] : admitCallerAttachments(options.attachmentPaths);
8095
7840
  return {
8096
7841
  runId,
8097
7842
  bookKey,
@@ -8107,13 +7852,7 @@ async function placeRoleAdmission(options) {
8107
7852
  };
8108
7853
  }
8109
7854
  function persistedAttachmentRefs(attachments) {
8110
- return attachments.map((attachment) => ({
8111
- provenancePath: attachment.provenancePath,
8112
- frozenPath: attachment.frozenPath,
8113
- byteLength: attachment.byteLength,
8114
- sha256: attachment.sha256,
8115
- mediaKind: attachment.mediaKind
8116
- }));
7855
+ return attachments.map((attachment) => ({ path: attachment.path }));
8117
7856
  }
8118
7857
  async function persistPlacedAdmission(admitted, placed, model) {
8119
7858
  writeAdmittedRequestPersistence(placed.runDirectory, admitted, {
@@ -8132,14 +7871,14 @@ async function persistPlacedAdmission(admitted, placed, model) {
8132
7871
  }
8133
7872
  async function admitStandardMaterialInvocation(role, options) {
8134
7873
  const defer = options.deferPersistence === true;
8135
- const skipFreeze = defer || options.freezeAttachments === false;
7874
+ const skipAttachments = defer || options.recordAttachments === false;
8136
7875
  const placed = await placeRoleAdmission({
8137
7876
  role,
8138
7877
  home: options.home,
8139
7878
  principalAuthority: options.principalAuthority,
8140
7879
  cwd: options.cwd,
8141
7880
  attachmentPaths: options.attachmentPaths,
8142
- ...skipFreeze ? { freezeAttachments: false } : {},
7881
+ ...skipAttachments ? { recordAttachments: false } : {},
8143
7882
  ...defer ? { materialize: false } : {},
8144
7883
  ...options.project === void 0 ? {} : { project: options.project },
8145
7884
  ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
@@ -8147,7 +7886,7 @@ async function admitStandardMaterialInvocation(role, options) {
8147
7886
  });
8148
7887
  const correlationFields = options.correlationId === void 0 ? {} : { correlationId: options.correlationId };
8149
7888
  const instruction = options.instruction;
8150
- const instructionEmpty = instruction.trim() === "";
7889
+ const instructionEmpty = instruction.length === 0;
8151
7890
  const placedExtra = options.placedFields === void 0 ? void 0 : await options.placedFields(placed);
8152
7891
  const admittedFields = {
8153
7892
  ...options.admittedFields ?? {},
@@ -8189,23 +7928,23 @@ function admittedTransportPromptKind(admitted) {
8189
7928
  if (record !== void 0 && "transportPrompt" in record) return record.transportPrompt;
8190
7929
  return "instruction";
8191
7930
  }
8192
- function buildInstructionTransportPrompt(admitted, engineMaterial) {
7931
+ function buildInstructionTransportPrompt(admitted) {
8193
7932
  const kind = admittedTransportPromptKind(admitted);
8194
7933
  if (kind === "fixed-kickoff") {
8195
7934
  if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
8196
7935
  throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
8197
7936
  }
8198
- return appendEngineSessionMaterial([admitted.sourceRunPath], engineMaterial).join("\n");
7937
+ return admitted.sourceRunPath;
8199
7938
  }
8200
7939
  if (kind === "baseline") {
8201
7940
  if (admitted.baseRevision === void 0) {
8202
7941
  throw new Error("baseline transport prompt is missing the bound revision");
8203
7942
  }
8204
7943
  const lines2 = [admitted.baseRevision];
8205
- if (!admitted.instructionEmpty) {
7944
+ if (admitted.instruction.length > 0) {
8206
7945
  lines2.push("", admitted.instruction);
8207
7946
  }
8208
- return appendEngineSessionMaterial(lines2, engineMaterial).join("\n");
7947
+ return lines2.join("\n");
8209
7948
  }
8210
7949
  if (kind === "skill-args") {
8211
7950
  if (admitted.baseRevision === void 0 || admitted.lens === void 0 || admitted.authorityRefs === void 0) {
@@ -8216,20 +7955,24 @@ function buildInstructionTransportPrompt(admitted, engineMaterial) {
8216
7955
  lens: admitted.lens,
8217
7956
  authorityRefs: admitted.authorityRefs
8218
7957
  })];
8219
- if (!admitted.instructionEmpty && admitted.instruction.trim() !== "") {
7958
+ if (admitted.instruction.length > 0) {
8220
7959
  lines2.push("", admitted.instruction);
8221
7960
  }
8222
- return appendEngineSessionMaterial(lines2, engineMaterial).join("\n");
7961
+ return lines2.join("\n");
8223
7962
  }
8224
- const lines = [admitted.instructionEmpty ? "" : admitted.instruction];
8225
- 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) {
8226
7969
  lines.push("");
8227
- lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF08\u51BB\u7ED3\u5FEB\u7167\u8DEF\u5F84\uFF09\uFF1A");
8228
- for (const attachment of admitted.attachments) {
8229
- lines.push(`- ${attachment.frozenPath}`);
7970
+ lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
7971
+ for (const entry of flaggedPaths) {
7972
+ lines.push(`- ${entry}`);
8230
7973
  }
8231
7974
  }
8232
- return appendEngineSessionMaterial(lines, engineMaterial).join("\n");
7975
+ return lines.join("\n");
8233
7976
  }
8234
7977
  async function materializeCountersignInvocation(admitted, options) {
8235
7978
  const placed = await placeRoleAdmission({
@@ -8237,8 +7980,7 @@ async function materializeCountersignInvocation(admitted, options) {
8237
7980
  home: options.home,
8238
7981
  principalAuthority: options.principalAuthority,
8239
7982
  cwd: admitted.projectRoot,
8240
- attachmentPaths: [],
8241
- freezeAttachments: false,
7983
+ attachmentPaths: options.attachmentPaths,
8242
7984
  runId: admitted.runId,
8243
7985
  ...options.ticketNumber === void 0 ? {} : { assertedTicketNumber: options.ticketNumber }
8244
7986
  });
@@ -8249,11 +7991,7 @@ async function materializeCountersignInvocation(admitted, options) {
8249
7991
  if (ticketFields.ticketNumber !== void 0) {
8250
7992
  admitted.ticketNumber = ticketFields.ticketNumber;
8251
7993
  }
8252
- const attachments = await freezePreparedAttachmentsIntoRun(
8253
- options.preparedAttachments,
8254
- admitted.runDirectory
8255
- );
8256
- admitted.attachments = attachments;
7994
+ admitted.attachments = placement.attachments;
8257
7995
  writeAdmittedRequestPersistence(admitted.runDirectory, admitted, {
8258
7996
  sessionDirectory: placement.sessionDirectory,
8259
7997
  sessionFile: placement.sessionFile
@@ -8272,10 +8010,11 @@ async function loadAdmittedJudgeRequest(runDirectory) {
8272
8010
  if (typeof record.instruction !== "string") return void 0;
8273
8011
  if (typeof record.instructionEmpty !== "boolean") return void 0;
8274
8012
  if (!Array.isArray(record.attachments)) return void 0;
8013
+ const attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
8275
8014
  return {
8276
8015
  instruction: record.instruction,
8277
8016
  instructionEmpty: record.instructionEmpty,
8278
- attachments: record.attachments
8017
+ attachments
8279
8018
  };
8280
8019
  } catch {
8281
8020
  return void 0;
@@ -8343,7 +8082,7 @@ function parseDoctorIssueNumber(raw) {
8343
8082
  }
8344
8083
  async function resolveDoctorCaseRunsPath(options) {
8345
8084
  const ledgerHome = resolveActivationLedgerHome(options.home);
8346
- const defaultRuns = join12(
8085
+ const defaultRuns = join11(
8347
8086
  activationBookDirectory(ledgerHome, options.bookKey),
8348
8087
  String(options.issueNumber),
8349
8088
  "runs"
@@ -8510,7 +8249,7 @@ function parseAnalystArgv(args) {
8510
8249
  if (taken.def.id === "attach") {
8511
8250
  pushValue(
8512
8251
  "attach",
8513
- requireOptionPath(taken.def.canonical, taken.value)
8252
+ requireProvidedOptionValue(taken.def.canonical, taken.value)
8514
8253
  );
8515
8254
  return;
8516
8255
  }
@@ -8632,7 +8371,6 @@ var init_invocation = __esm({
8632
8371
  init_uuidv7();
8633
8372
  init_notary_contracts();
8634
8373
  init_notary_source_run();
8635
- init_engine_material();
8636
8374
  init_cli_errors();
8637
8375
  init_option_definitions();
8638
8376
  init_unknown_value();
@@ -9917,10 +9655,10 @@ function presentFailureTerminal(terminal, io) {
9917
9655
  }
9918
9656
  function defaultNavigatorGraceSleep() {
9919
9657
  let timer;
9920
- const sleep2 = ((ms) => new Promise((resolve22) => {
9658
+ const sleep2 = ((ms) => new Promise((resolve21) => {
9921
9659
  timer = setTimeout(() => {
9922
9660
  timer = void 0;
9923
- resolve22();
9661
+ resolve21();
9924
9662
  }, ms);
9925
9663
  }));
9926
9664
  sleep2.cancel = () => {
@@ -9932,7 +9670,7 @@ function defaultNavigatorGraceSleep() {
9932
9670
  return sleep2;
9933
9671
  }
9934
9672
  function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
9935
- return new Promise((resolve22, reject) => {
9673
+ return new Promise((resolve21, reject) => {
9936
9674
  let settled = false;
9937
9675
  const finish = (action) => {
9938
9676
  if (settled) return;
@@ -9941,11 +9679,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
9941
9679
  action();
9942
9680
  };
9943
9681
  void work.then(
9944
- (value) => finish(() => resolve22({ status: "done", value })),
9682
+ (value) => finish(() => resolve21({ status: "done", value })),
9945
9683
  (error) => finish(() => reject(error))
9946
9684
  );
9947
9685
  void sleep2(graceMs).then(() => {
9948
- finish(() => resolve22({ status: "timeout" }));
9686
+ finish(() => resolve21({ status: "timeout" }));
9949
9687
  });
9950
9688
  });
9951
9689
  }
@@ -9989,7 +9727,7 @@ var init_settlement = __esm({
9989
9727
  });
9990
9728
 
9991
9729
  // src/session-identity.ts
9992
- import { dirname as dirname9, join as join13 } from "node:path";
9730
+ import { dirname as dirname9, join as join12 } from "node:path";
9993
9731
  function createSessionIdentityAuthority(authority, hostName) {
9994
9732
  const runDirectoryOf = (principal) => dirname9(authority.decode(principal).sessionDirectory);
9995
9733
  return {
@@ -9998,7 +9736,7 @@ function createSessionIdentityAuthority(authority, hostName) {
9998
9736
  },
9999
9737
  async load(principal) {
10000
9738
  const runDirectory = runDirectoryOf(principal);
10001
- const { records, diagnostics } = await readSitianRecords(join13(runDirectory, RUN_STATE_FILE));
9739
+ const { records, diagnostics } = await readSitianRecords(join12(runDirectory, RUN_STATE_FILE));
10002
9740
  if (diagnostics.length > 0) {
10003
9741
  throw new Error(
10004
9742
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -10068,12 +9806,12 @@ __export(role_turn_host_exports, {
10068
9806
  import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
10069
9807
  import { constants } from "node:fs";
10070
9808
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
10071
- import { delimiter, dirname as dirname10, isAbsolute as isAbsolute6, join as join14, resolve as resolve11 } from "node:path";
9809
+ import { delimiter, dirname as dirname10, isAbsolute as isAbsolute6, join as join13, resolve as resolve11 } from "node:path";
10072
9810
  import { platform } from "node:process";
10073
9811
  import { promisify as promisify2 } from "node:util";
10074
9812
  import { randomUUID as randomUUID4 } from "node:crypto";
10075
9813
  function resolveInternalRoleEntrypoint(packageRoot) {
10076
- return join14(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
9814
+ return join13(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
10077
9815
  }
10078
9816
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
10079
9817
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -10434,6 +10172,80 @@ var init_role_turn_host = __esm({
10434
10172
  }
10435
10173
  });
10436
10174
 
10175
+ // src/package-resources/engine-material.ts
10176
+ import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
10177
+ import { join as join14 } from "node:path";
10178
+ function pickEngineAxis(source) {
10179
+ return {
10180
+ ...source.engine === void 0 ? {} : { engine: source.engine },
10181
+ ...source.engineModel === void 0 ? {} : { engineModel: source.engineModel }
10182
+ };
10183
+ }
10184
+ function assertLegalEngineModel(model) {
10185
+ if (typeof model !== "string" || model.trim() === "" || model.trim() !== model) {
10186
+ throw new Error(`illegal engine model: ${JSON.stringify(model)}`);
10187
+ }
10188
+ return model;
10189
+ }
10190
+ function isEngineNameSyntax(name) {
10191
+ if (typeof name !== "string") return false;
10192
+ if (name.length === 0 || name.trim() !== name) return false;
10193
+ if (name === "." || name === "..") return false;
10194
+ if (name.includes("/") || name.includes("\\") || name.includes("\0")) return false;
10195
+ return true;
10196
+ }
10197
+ function resolveEngineMaterialDirectory(packageRoot) {
10198
+ return join14(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
10199
+ }
10200
+ function resolveEngineDispatchMaterialPath(packageRoot) {
10201
+ return join14(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
10202
+ }
10203
+ function resolveEngineMaterialPath(packageRoot, name) {
10204
+ const legal = assertLegalEngineName(name);
10205
+ return join14(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
10206
+ }
10207
+ function assertLegalEngineName(name) {
10208
+ if (!isEngineNameSyntax(name)) {
10209
+ throw new Error(`illegal engine name: ${name}`);
10210
+ }
10211
+ return name;
10212
+ }
10213
+ function engineSessionMaterialFromOptions(options) {
10214
+ if (options.engine === void 0) return void 0;
10215
+ if (options.packageRoot === void 0 || options.packageRoot.trim() === "") {
10216
+ throw new Error("packageRoot is required when engine is configured");
10217
+ }
10218
+ const name = assertLegalEngineName(options.engine);
10219
+ const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
10220
+ const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
10221
+ const modelField = model === void 0 ? {} : { model };
10222
+ if (!existsSync4(materialPath)) {
10223
+ return Object.freeze({ name, ...modelField });
10224
+ }
10225
+ const handbook = readFileSync2(materialPath, "utf8");
10226
+ const dispatchPath = resolveEngineDispatchMaterialPath(options.packageRoot);
10227
+ const dispatchField = existsSync4(dispatchPath) ? { dispatchHandbook: readFileSync2(dispatchPath, "utf8") } : {};
10228
+ return Object.freeze({ name, handbook, ...dispatchField, ...modelField });
10229
+ }
10230
+ function engineSessionReadingMaterial(engineMaterial) {
10231
+ if (engineMaterial === void 0) return void 0;
10232
+ return {
10233
+ kind: "engine-session-material",
10234
+ name: engineMaterial.name,
10235
+ ...engineMaterial.model === void 0 ? {} : { model: engineMaterial.model },
10236
+ ...engineMaterial.handbook === void 0 ? {} : { handbook: engineMaterial.handbook },
10237
+ ...engineMaterial.dispatchHandbook === void 0 ? {} : { dispatchHandbook: engineMaterial.dispatchHandbook }
10238
+ };
10239
+ }
10240
+ var ENGINE_MATERIAL_RELATIVE_ROOT, ENGINE_DISPATCH_RELATIVE_PATH;
10241
+ var init_engine_material = __esm({
10242
+ "src/package-resources/engine-material.ts"() {
10243
+ "use strict";
10244
+ ENGINE_MATERIAL_RELATIVE_ROOT = "resources/engines";
10245
+ ENGINE_DISPATCH_RELATIVE_PATH = "resources/engine-dispatch.md";
10246
+ }
10247
+ });
10248
+
10437
10249
  // src/institutional-resolution.ts
10438
10250
  function resolveConfiguredProvinceOfficer(config, officer) {
10439
10251
  const ownModel = seatModelOnly(config.seats[officer]);
@@ -10488,7 +10300,7 @@ __export(config_exports, {
10488
10300
  setPersistentSeatHost: () => setPersistentSeatHost,
10489
10301
  validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
10490
10302
  });
10491
- 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";
10492
10304
  import { dirname as dirname11, join as join15 } from "node:path";
10493
10305
  function isGateOfficerSeat(value) {
10494
10306
  return packagedProvinceConfig(value);
@@ -10502,7 +10314,7 @@ function publicCliConfigPath(home) {
10502
10314
  async function loadPublicCliConfig(home) {
10503
10315
  const path = publicCliConfigPath(home);
10504
10316
  try {
10505
- const raw = await readFile9(path, "utf8");
10317
+ const raw = await readFile8(path, "utf8");
10506
10318
  return parsePublicCliConfig(JSON.parse(raw));
10507
10319
  } catch (error) {
10508
10320
  if (isEnoent(error)) return { seats: {} };
@@ -10961,7 +10773,7 @@ function resolvePublicAgentDir(explicit, home) {
10961
10773
  }
10962
10774
  async function loadCredentialProviders(agentDir) {
10963
10775
  try {
10964
- const raw = await readFile9(join15(agentDir, "auth.json"), "utf8");
10776
+ const raw = await readFile8(join15(agentDir, "auth.json"), "utf8");
10965
10777
  return credentialProvidersFromAuthData(JSON.parse(raw));
10966
10778
  } catch (error) {
10967
10779
  if (isEnoent(error)) return { "openai-codex": false, xai: false };
@@ -10985,7 +10797,7 @@ var init_config = __esm({
10985
10797
  });
10986
10798
 
10987
10799
  // src/public-cli/host-providers.ts
10988
- import { readFileSync as readFileSync2 } from "node:fs";
10800
+ import { readFileSync as readFileSync3 } from "node:fs";
10989
10801
  import { join as join16 } from "node:path";
10990
10802
  function hostProvidersPath(home) {
10991
10803
  if (typeof home !== "string" || home.trim() === "") {
@@ -11031,7 +10843,7 @@ function parseHostProvidersTable(value) {
11031
10843
  function loadHostProvidersTable(home) {
11032
10844
  const path = hostProvidersPath(home);
11033
10845
  try {
11034
- const raw = readFileSync2(path, "utf8");
10846
+ const raw = readFileSync3(path, "utf8");
11035
10847
  return parseHostProvidersTable(JSON.parse(raw));
11036
10848
  } catch (error) {
11037
10849
  if (isEnoent(error)) return {};
@@ -11047,7 +10859,7 @@ function listHermesProvidersForModel(home, seatModel) {
11047
10859
  const path = hermesProviderModelsCachePath(home);
11048
10860
  let text;
11049
10861
  try {
11050
- text = readFileSync2(path, "utf8");
10862
+ text = readFileSync3(path, "utf8");
11051
10863
  } catch (error) {
11052
10864
  if (isEnoent(error)) return [];
11053
10865
  throw error;
@@ -11345,7 +11157,7 @@ var init_role_seat_runtime = __esm({
11345
11157
  });
11346
11158
 
11347
11159
  // src/archivist-record-pointer.ts
11348
- import { basename as basename9, join as join19 } from "node:path";
11160
+ import { basename as basename8, join as join19 } from "node:path";
11349
11161
  function bookDirectOfficerRunPointer(options) {
11350
11162
  const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
11351
11163
  const pointer = {
@@ -11371,7 +11183,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
11371
11183
  let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
11372
11184
  let sessionFile = raw.sessionFile;
11373
11185
  const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
11374
- const leaf = parseRunLeaf(basename9(recordedRunDirectory));
11186
+ const leaf = parseRunLeaf(basename8(recordedRunDirectory));
11375
11187
  const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
11376
11188
  if (leaf !== void 0 && parentIdentity !== void 0) {
11377
11189
  const currentRunDirectory = await findRunDirectoryById(
@@ -11732,7 +11544,7 @@ var init_submission_gate = __esm({
11732
11544
 
11733
11545
  // src/session-opening-materials.ts
11734
11546
  import { existsSync as existsSync7 } from "node:fs";
11735
- import { readFile as readFile10 } from "node:fs/promises";
11547
+ import { readFile as readFile9 } from "node:fs/promises";
11736
11548
  import { dirname as dirname12, join as join20 } from "node:path";
11737
11549
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
11738
11550
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
@@ -11748,7 +11560,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
11748
11560
  return fileURLToPath(new URL("..", moduleUrl));
11749
11561
  }
11750
11562
  async function readPackageMaterial(relativePath) {
11751
- return readFile10(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
11563
+ return readFile9(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
11752
11564
  }
11753
11565
  async function joinPackageMaterials(relativePaths) {
11754
11566
  const chunks = [];
@@ -11806,7 +11618,7 @@ __export(auditor_soul_exports, {
11806
11618
  readAuditorResumeBinding: () => readAuditorResumeBinding,
11807
11619
  resolveAuditorSubject: () => resolveAuditorSubject
11808
11620
  });
11809
- import { basename as basename10 } from "node:path";
11621
+ import { basename as basename9 } from "node:path";
11810
11622
  function auditorSoulRelativePath(role) {
11811
11623
  return `souls/${role}-auditor.md`;
11812
11624
  }
@@ -11842,7 +11654,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
11842
11654
  return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
11843
11655
  }
11844
11656
  function subjectFromSourceDirectory(sourceRunDirectory) {
11845
- const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
11657
+ const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
11846
11658
  return isAuditorSoulRole(role) ? role : void 0;
11847
11659
  }
11848
11660
  async function readAuditorResumeBinding(runDirectory) {
@@ -11882,7 +11694,7 @@ var init_auditor_soul = __esm({
11882
11694
 
11883
11695
  // src/public-cli/machine-method-skills.ts
11884
11696
  import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
11885
- 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";
11886
11698
  import { join as join22 } from "node:path";
11887
11699
  import { spawnSync as spawnSync2 } from "node:child_process";
11888
11700
  function skillRoot(home) {
@@ -11912,7 +11724,7 @@ function linkedSkillRoot(home, host) {
11912
11724
  }
11913
11725
  async function occupied(path) {
11914
11726
  try {
11915
- await lstat3(path);
11727
+ await lstat2(path);
11916
11728
  return true;
11917
11729
  } catch (error) {
11918
11730
  if (error.code !== "ENOENT") throw error;
@@ -12409,7 +12221,6 @@ var init_auto_resume = __esm({
12409
12221
 
12410
12222
  // src/public-cli/post-admission.ts
12411
12223
  import { randomUUID as randomUUID5 } from "node:crypto";
12412
- import { isAbsolute as isAbsolute7, join as join23, resolve as resolve12 } from "node:path";
12413
12224
  function describeCaughtError(error) {
12414
12225
  if (error instanceof Error) {
12415
12226
  const code = error.code;
@@ -12431,7 +12242,7 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
12431
12242
  mutableRequest.principal = admitted.principal;
12432
12243
  const activation = mutableRequest.activation;
12433
12244
  if (isRecord(activation)) {
12434
- for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath", "requestManifestPath"]) {
12245
+ for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath"]) {
12435
12246
  const record = activation;
12436
12247
  if (field in record) record[field] = rewrite(record[field]);
12437
12248
  }
@@ -13164,7 +12975,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
13164
12975
  prompt = request.message;
13165
12976
  }
13166
12977
  } else if (summonsPrepared !== void 0) {
13167
- prompt = officerDialogue ? summonsPrepared.instructionEmpty ? "" : summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
12978
+ prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
13168
12979
  } else if (request.summons !== void 0) {
13169
12980
  prompt = "";
13170
12981
  } else {
@@ -13245,24 +13056,14 @@ async function runSettledAutoResumeLoop(input) {
13245
13056
  })
13246
13057
  });
13247
13058
  }
13248
- function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
13249
- const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
13250
- return pathContainedIn(join23(runDirectory, "attachments"), absolute);
13251
- }
13252
- async function prepareSummonsResumeMaterials(runDirectory, summons) {
13059
+ async function prepareSummonsResumeMaterials(_runDirectory, summons) {
13253
13060
  if (summons === void 0) return void 0;
13254
13061
  if (summons.instruction === void 0 && (summons.attachmentPaths?.length ?? 0) === 0) {
13255
13062
  return void 0;
13256
13063
  }
13257
13064
  const instruction = summons.instruction ?? "";
13258
- const instructionEmpty = summons.instructionEmpty ?? instruction.trim() === "";
13259
- let attachments = [];
13260
- if (summons.attachmentPaths !== void 0 && summons.attachmentPaths.length > 0) {
13261
- const alreadyFrozen = summons.attachmentPaths.every(
13262
- (path) => isAlreadyFrozenSummonsAttachment(runDirectory, path)
13263
- );
13264
- attachments = alreadyFrozen ? summons.attachmentPaths.map((frozenPath) => ({ frozenPath })) : await freezeAttachmentsIntoRun(summons.attachmentPaths, runDirectory);
13265
- }
13065
+ const instructionEmpty = summons.instructionEmpty ?? instruction.length === 0;
13066
+ const attachments = (summons.attachmentPaths ?? []).map((path) => ({ path }));
13266
13067
  return { instruction, instructionEmpty, attachments };
13267
13068
  }
13268
13069
  async function runPostAdmissionSeatResume(input) {
@@ -13311,23 +13112,6 @@ async function runPostAdmissionSeatResume(input) {
13311
13112
  openCourtAttemptId = openCourt.courtAttemptId;
13312
13113
  }
13313
13114
  }
13314
- if (request.summons !== void 0) {
13315
- const prepared = await prepareSummonsResumeMaterials(
13316
- admittedForBuild.runDirectory,
13317
- request.summons
13318
- );
13319
- if (prepared !== void 0 && (request.summons.attachmentPaths?.length ?? 0) > 0) {
13320
- request = {
13321
- ...request,
13322
- summons: {
13323
- ...request.summons,
13324
- attachmentPaths: prepared.attachments.map(
13325
- (attachment) => attachment.frozenPath
13326
- )
13327
- }
13328
- };
13329
- }
13330
- }
13331
13115
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
13332
13116
  if (turnRequest.continuation.kind === "resume" && turnRequest.continuation.hostSessionId === void 0) {
13333
13117
  const hostSessionId = await readStoredHostSessionId(
@@ -13494,13 +13278,7 @@ async function runPostAdmissionOneShot(input) {
13494
13278
  ...input.request,
13495
13279
  continuation: {
13496
13280
  kind: "resume",
13497
- prompt: buildAutoResumeContinuationPrompt({
13498
- packageRoot: input.env.packageRoot,
13499
- ...pickEngineAxis({
13500
- engine: input.effectiveEngine ?? input.env.engine,
13501
- engineModel: input.env.engineModel
13502
- })
13503
- })
13281
+ prompt: buildAutoResumeContinuationPrompt()
13504
13282
  }
13505
13283
  }),
13506
13284
  adapters: input.adapters,
@@ -13583,8 +13361,6 @@ var init_post_admission = __esm({
13583
13361
  init_invocation();
13584
13362
  init_submission_ledger();
13585
13363
  init_run_ticket_number();
13586
- init_activation_ledger_topology();
13587
- init_engine_material();
13588
13364
  init_session_identity();
13589
13365
  init_sitian_facade();
13590
13366
  init_receipt_delivery_policy();
@@ -13724,7 +13500,7 @@ __export(instruction_seat_run_exports, {
13724
13500
  runPublicInstructionSeat: () => runPublicInstructionSeat,
13725
13501
  runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
13726
13502
  });
13727
- import { dirname as dirname13, resolve as resolve13 } from "node:path";
13503
+ import { dirname as dirname13, resolve as resolve12 } from "node:path";
13728
13504
  function unreadablePostSubmissionStatus(admitted, terminal) {
13729
13505
  if (terminal?.roleOutcome.kind !== "accepted") return void 0;
13730
13506
  const route = POST_SUBMISSION_ROUTING[admitted.role];
@@ -13815,13 +13591,7 @@ function initialPrompt(admitted, env) {
13815
13591
  if (reask !== void 0 && "reaskPrompt" in record && record.reaskPrompt === true) {
13816
13592
  return reask;
13817
13593
  }
13818
- return buildInstructionTransportPrompt(
13819
- admitted,
13820
- engineSessionMaterialFromOptions({
13821
- ...pickEngineAxis(env),
13822
- packageRoot: env.packageRoot
13823
- })
13824
- );
13594
+ return buildInstructionTransportPrompt(admitted);
13825
13595
  }
13826
13596
  function isBoardTicketSeat(seat) {
13827
13597
  return packagedBindsBoardTicket(seat.role);
@@ -13915,10 +13685,7 @@ async function dispatchAdmitted(admitted, env, io) {
13915
13685
  admitted,
13916
13686
  roleTurnOptions(activeEnv, admitted, {
13917
13687
  kind: "resume",
13918
- prompt: buildAutoResumeContinuationPrompt({
13919
- packageRoot: activeEnv.packageRoot,
13920
- ...pickEngineAxis(activeEnv)
13921
- })
13688
+ prompt: buildAutoResumeContinuationPrompt()
13922
13689
  })
13923
13690
  ),
13924
13691
  adapters,
@@ -13961,7 +13728,7 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
13961
13728
  const children = await summonParallelReviewerLenses2({
13962
13729
  argv,
13963
13730
  cwd: env.cwd,
13964
- projectRoot: resolve13(parsed.project ?? env.cwd),
13731
+ projectRoot: resolve12(parsed.project ?? env.cwd),
13965
13732
  baseRevision: parsed.baseRevision ?? "",
13966
13733
  home: env.home,
13967
13734
  agentDir: env.agentDir,
@@ -14043,14 +13810,14 @@ async function runCountersignBody(parsed, env, io) {
14043
13810
  const resumed = await resumeSameParentInstructionSeat({
14044
13811
  env,
14045
13812
  io,
14046
- projectRoot: resolve13(parsed.project ?? env.cwd),
13813
+ projectRoot: resolve12(parsed.project ?? env.cwd),
14047
13814
  role: "countersign",
14048
13815
  parentRunPath: gateParentRunPath,
14049
13816
  ...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
14050
13817
  summons: {
14051
13818
  sourceRunPath: gateParentRunPath,
14052
13819
  instruction: resumeInstruction,
14053
- instructionEmpty: resumeInstruction.trim() === ""
13820
+ instructionEmpty: resumeInstruction.length === 0
14054
13821
  }
14055
13822
  });
14056
13823
  if (resumed != null) return resumed;
@@ -14064,12 +13831,12 @@ async function runCountersignBody(parsed, env, io) {
14064
13831
  throw error;
14065
13832
  }
14066
13833
  try {
14067
- return await withPreparedAttachments(parsed.attachmentPaths ?? [], async (preparedAttachments) => {
13834
+ {
14068
13835
  const materializeAdmission = async (ticketNumber) => {
14069
13836
  await materializeCountersignInvocation(admitted, {
14070
13837
  home: env.home,
14071
13838
  principalAuthority: env.principalAuthority,
14072
- preparedAttachments,
13839
+ attachmentPaths: parsed.attachmentPaths ?? [],
14073
13840
  ...env.model === void 0 ? {} : { model: env.model },
14074
13841
  ...ticketNumber === void 0 ? {} : { ticketNumber }
14075
13842
  });
@@ -14084,13 +13851,7 @@ async function runCountersignBody(parsed, env, io) {
14084
13851
  }
14085
13852
  const turnProjection = roleTurnOptions(env, admitted, {
14086
13853
  kind: "initial",
14087
- prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(
14088
- admitted,
14089
- engineSessionMaterialFromOptions({
14090
- ...pickEngineAxis(env),
14091
- packageRoot: env.packageRoot
14092
- })
14093
- )
13854
+ prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(admitted)
14094
13855
  });
14095
13856
  const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
14096
13857
  const result = await runPostAdmissionOneShot({
@@ -14110,7 +13871,7 @@ async function runCountersignBody(parsed, env, io) {
14110
13871
  });
14111
13872
  await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
14112
13873
  return result;
14113
- });
13874
+ }
14114
13875
  } catch (error) {
14115
13876
  const rejected = usageExit(error, io);
14116
13877
  if (rejected !== void 0) return rejected;
@@ -14175,7 +13936,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14175
13936
  const summons = {
14176
13937
  ...sameParentInstruction(env, {
14177
13938
  instruction: parsed.instruction ?? "",
14178
- instructionEmpty: (parsed.instruction ?? "").trim() === ""
13939
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14179
13940
  }),
14180
13941
  attachmentPaths: parsed.attachmentPaths ?? []
14181
13942
  };
@@ -14200,7 +13961,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14200
13961
  sourceRunPath: parentRunPath,
14201
13962
  ...sameParentInstruction(env, {
14202
13963
  instruction: parsed.instruction ?? "",
14203
- instructionEmpty: (parsed.instruction ?? "").trim() === ""
13964
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14204
13965
  }),
14205
13966
  attachmentPaths: parsed.attachmentPaths ?? []
14206
13967
  };
@@ -14284,7 +14045,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14284
14045
  instruction: parsed.instruction ?? "",
14285
14046
  projectRoot: admitted.projectRoot,
14286
14047
  failureLabel: "secretariat unbound summons",
14287
- attachmentPaths: admitted.attachments.map((attachment) => attachment.frozenPath),
14048
+ attachmentPaths: admitted.attachments.map((attachment) => attachment.path),
14288
14049
  correlationId: admitted.runId
14289
14050
  }, env, io);
14290
14051
  } catch (error) {
@@ -14787,7 +14548,6 @@ var init_instruction_seat_run = __esm({
14787
14548
  init_submission_gate();
14788
14549
  init_run_ticket_number();
14789
14550
  init_notary_source_run();
14790
- init_engine_material();
14791
14551
  init_packaged_role_registry();
14792
14552
  init_auditor_soul();
14793
14553
  init_cli_errors();
@@ -14844,7 +14604,7 @@ var init_instruction_seat_run = __esm({
14844
14604
 
14845
14605
  // src/analyst-book-key.ts
14846
14606
  import { statSync as statSync6 } from "node:fs";
14847
- import { isAbsolute as isAbsolute8 } from "node:path";
14607
+ import { isAbsolute as isAbsolute7 } from "node:path";
14848
14608
  function resolveAnalystBookKey(projectRoot) {
14849
14609
  const identity = physicalPathIdentity(projectRoot);
14850
14610
  let stats;
@@ -14866,7 +14626,7 @@ function resolveAnalystBookKey(projectRoot) {
14866
14626
  }
14867
14627
  }
14868
14628
  function isSyntheticAnalystBookKey(bookKey) {
14869
- return bookKey.startsWith("root:") && isAbsolute8(bookKey.slice("root:".length));
14629
+ return bookKey.startsWith("root:") && isAbsolute7(bookKey.slice("root:".length));
14870
14630
  }
14871
14631
  var init_analyst_book_key = __esm({
14872
14632
  "src/analyst-book-key.ts"() {
@@ -14878,16 +14638,16 @@ var init_analyst_book_key = __esm({
14878
14638
 
14879
14639
  // src/atomic-write.ts
14880
14640
  import { randomUUID as randomUUID6 } from "node:crypto";
14881
- import { rename as rename2, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
14882
- 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";
14883
14643
  async function writeFileAtomically(destination, contents, options) {
14884
14644
  const parent = dirname14(destination);
14885
- const temporary = join24(parent, `.atomic-write-${randomUUID6()}.tmp`);
14645
+ const temporary = join23(parent, `.atomic-write-${randomUUID6()}.tmp`);
14886
14646
  try {
14887
14647
  await writeFile3(temporary, contents, options);
14888
14648
  await rename2(temporary, destination);
14889
14649
  } catch (error) {
14890
- await rm2(temporary, { force: true }).catch(() => void 0);
14650
+ await rm(temporary, { force: true }).catch(() => void 0);
14891
14651
  throw error;
14892
14652
  }
14893
14653
  }
@@ -14898,13 +14658,13 @@ var init_atomic_write = __esm({
14898
14658
  });
14899
14659
 
14900
14660
  // src/analyst-index.ts
14901
- import { open, readFile as readFile11, unlink } from "node:fs/promises";
14902
- 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";
14903
14663
  import { setTimeout as sleep } from "node:timers/promises";
14904
14664
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
14905
14665
  const indexPath = analystLibraryIndexPath(ledgerHome);
14906
14666
  ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
14907
- const lockPath = join25(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
14667
+ const lockPath = join24(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
14908
14668
  assertLedgerFileInsideHome(lockPath, ledgerHome);
14909
14669
  const startedAt = Date.now();
14910
14670
  while (true) {
@@ -14931,7 +14691,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
14931
14691
  }
14932
14692
  }
14933
14693
  function analystLibraryIndexPath(ledgerHome) {
14934
- return join25(ledgerHome, "analyst", "library-index.json");
14694
+ return join24(ledgerHome, "analyst", "library-index.json");
14935
14695
  }
14936
14696
  function rowFromIssueMetricsPage(page) {
14937
14697
  return {
@@ -15022,7 +14782,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
15022
14782
  const path = analystLibraryIndexPath(ledgerHome);
15023
14783
  let raw;
15024
14784
  try {
15025
- raw = await readFile11(path, "utf8");
14785
+ raw = await readFile10(path, "utf8");
15026
14786
  } catch (error) {
15027
14787
  if (isMissingPathError(error)) return void 0;
15028
14788
  throw error;
@@ -15477,7 +15237,7 @@ var init_analyst_gate_cycles_read = __esm({
15477
15237
 
15478
15238
  // src/analyst-ledger.ts
15479
15239
  import { readdir as readdir3 } from "node:fs/promises";
15480
- import { basename as basename11, join as join26 } from "node:path";
15240
+ import { basename as basename10, join as join25 } from "node:path";
15481
15241
  async function readExistingRunLifecycleState(runDirectory) {
15482
15242
  return (await readRoleRunIdentity(runDirectory))?.state;
15483
15243
  }
@@ -15497,7 +15257,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
15497
15257
  }
15498
15258
  }
15499
15259
  async function classifyGhostCandidate(input) {
15500
- const autopsy = await autopsyWriterLock(join26(input.runDirectory, "writer.lock"));
15260
+ const autopsy = await autopsyWriterLock(join25(input.runDirectory, "writer.lock"));
15501
15261
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
15502
15262
  if (leaseCheck === void 0) return { kind: "live" };
15503
15263
  return {
@@ -15787,7 +15547,7 @@ async function classifyScopedRun(input) {
15787
15547
  async function scanAnalystIssueRuns(input) {
15788
15548
  const ledgerHome = resolveActivationLedgerHome(input.home);
15789
15549
  const scopeTicketNumber = input.ticketNumber;
15790
- const booksRoot = join26(ledgerHome, "books");
15550
+ const booksRoot = join25(ledgerHome, "books");
15791
15551
  let wholeBook = false;
15792
15552
  let scopeRootIdentity;
15793
15553
  let bookNames;
@@ -15820,7 +15580,7 @@ async function scanAnalystIssueRuns(input) {
15820
15580
  const ghostLegs = [];
15821
15581
  const scopeConflicts = [];
15822
15582
  for (const book of bookNames) {
15823
- const bookDir = join26(booksRoot, book);
15583
+ const bookDir = join25(booksRoot, book);
15824
15584
  let runDirectories;
15825
15585
  try {
15826
15586
  runDirectories = await listBookRunDirectories(bookDir);
@@ -15829,7 +15589,7 @@ async function scanAnalystIssueRuns(input) {
15829
15589
  throw error;
15830
15590
  }
15831
15591
  for (const runDirectory of runDirectories) {
15832
- const runName = basename11(runDirectory);
15592
+ const runName = basename10(runDirectory);
15833
15593
  const parsed = parseRunLeaf(runName);
15834
15594
  if (parsed === void 0) continue;
15835
15595
  let scopeFields;
@@ -16566,7 +16326,7 @@ var init_analyst_metric_family = __esm({
16566
16326
  });
16567
16327
 
16568
16328
  // src/analyst-page.ts
16569
- import { dirname as dirname16, join as join27 } from "node:path";
16329
+ import { dirname as dirname16, join as join26 } from "node:path";
16570
16330
  function analystIssuePageKey(address) {
16571
16331
  const parts = ["book", address.bookKey];
16572
16332
  if (address.issueNumber !== void 0) {
@@ -16577,7 +16337,7 @@ function analystIssuePageKey(address) {
16577
16337
  return sha256Hex(parts.join("\0")).slice(0, 32);
16578
16338
  }
16579
16339
  function analystIssuePagePath(ledgerHome, address) {
16580
- return join27(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16340
+ return join26(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16581
16341
  }
16582
16342
  function analystIssuePageAddressFromPage(page) {
16583
16343
  return {
@@ -16813,7 +16573,7 @@ var init_analyst_model_groups = __esm({
16813
16573
  });
16814
16574
 
16815
16575
  // src/analyst-entry.ts
16816
- import { readFile as readFile13 } from "node:fs/promises";
16576
+ import { readFile as readFile12 } from "node:fs/promises";
16817
16577
  import { Type as Type17 } from "typebox";
16818
16578
  function cachedPageMatchesRequestedScope(page, input) {
16819
16579
  if (page.bookKey !== input.bookKey) return false;
@@ -16841,7 +16601,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
16841
16601
  ...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
16842
16602
  });
16843
16603
  try {
16844
- const raw = await readFile13(pagePath, "utf8");
16604
+ const raw = await readFile12(pagePath, "utf8");
16845
16605
  const page = JSON.parse(raw);
16846
16606
  if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
16847
16607
  const ghostScan = await scanAnalystIssueRuns({
@@ -16942,7 +16702,7 @@ async function runAnalystModelGroupsMode(input, home) {
16942
16702
  scopeRootIdentity: projectRoot
16943
16703
  });
16944
16704
  try {
16945
- const raw = await readFile13(pagePath, "utf8");
16705
+ const raw = await readFile12(pagePath, "utf8");
16946
16706
  JSON.parse(raw);
16947
16707
  } catch (error) {
16948
16708
  if (!isMissingPathError(error)) {
@@ -17039,8 +16799,8 @@ var init_analyst_entry = __esm({
17039
16799
  });
17040
16800
 
17041
16801
  // src/public-cli/analyst-run.ts
17042
- import { readFile as readFile14 } from "node:fs/promises";
17043
- 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";
17044
16804
  import { Value as Value2 } from "typebox/value";
17045
16805
  function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
17046
16806
  try {
@@ -17090,10 +16850,10 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
17090
16850
  );
17091
16851
  }
17092
16852
  const sourcePath = attachmentPaths[0];
17093
- const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve14(sourcePath);
16853
+ const absolute = isAbsolute8(sourcePath) ? sourcePath : resolve13(sourcePath);
17094
16854
  let bytes;
17095
16855
  try {
17096
- bytes = await readFile14(absolute);
16856
+ bytes = await readFile13(absolute);
17097
16857
  } catch (error) {
17098
16858
  throw new CliUsageError(
17099
16859
  `analyst sweep attachment is not a readable regular file: ${sourcePath}`,
@@ -18123,7 +17883,7 @@ __export(public_role_summons_exports, {
18123
17883
  import { execFile as execFile3 } from "node:child_process";
18124
17884
  import { existsSync as existsSync8 } from "node:fs";
18125
17885
  import { realpath as realpath6 } from "node:fs/promises";
18126
- import { join as join28 } from "node:path";
17886
+ import { join as join27 } from "node:path";
18127
17887
  import { promisify as promisify3 } from "node:util";
18128
17888
  function createCapturingIo() {
18129
17889
  const chunks = [];
@@ -18147,7 +17907,7 @@ function parentDir(path) {
18147
17907
  function walkPackageRoot(start) {
18148
17908
  let dir = start;
18149
17909
  for (let i = 0; i < 12; i += 1) {
18150
- if (existsSync8(join28(dir, "package.json")) && existsSync8(join28(dir, "souls"))) {
17910
+ if (existsSync8(join27(dir, "package.json")) && existsSync8(join27(dir, "souls"))) {
18151
17911
  return dir;
18152
17912
  }
18153
17913
  const parent = parentDir(dir);
@@ -18367,7 +18127,7 @@ async function summonPublicRole(options) {
18367
18127
  runId: resumeRunId,
18368
18128
  summons: {
18369
18129
  instruction,
18370
- instructionEmpty: instruction.trim() === ""
18130
+ instructionEmpty: instruction.length === 0
18371
18131
  }
18372
18132
  },
18373
18133
  env,
@@ -18756,7 +18516,7 @@ var init_compliance_transport = __esm({
18756
18516
  });
18757
18517
 
18758
18518
  // src/role-run-relocation.ts
18759
- 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";
18760
18520
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
18761
18521
  if (typeof value !== "string") return value;
18762
18522
  if (value === oldRunDirectory) return newRunDirectory;
@@ -18836,13 +18596,6 @@ function rewriteSourceRunLocator(value, rewrites) {
18836
18596
  function rewriteAdmittedRoleRunPage(page, rewrites) {
18837
18597
  rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
18838
18598
  rewriteSourceRunLocator(page.sourceRun, rewrites);
18839
- if (Array.isArray(page.attachments)) {
18840
- for (const attachment of page.attachments) {
18841
- if (isRecord(attachment)) {
18842
- rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
18843
- }
18844
- }
18845
- }
18846
18599
  if (isRecord(page.principal)) {
18847
18600
  rewriteRunDirectoryPathFieldsAgainstRewrites(
18848
18601
  page.principal,
@@ -18870,7 +18623,7 @@ var init_role_run_relocation = __esm({
18870
18623
  "taskPath",
18871
18624
  "packetPath",
18872
18625
  "prerequisitesPath",
18873
- "requestManifestPath",
18626
+ // #1165: requestManifestPath is a caller path — never rewrite.
18874
18627
  "mergerInputPath",
18875
18628
  "sourceRunPath"
18876
18629
  ];
@@ -18905,16 +18658,10 @@ __export(run_lifecycle_exports, {
18905
18658
  recordCurrentCourt: () => recordCurrentCourt,
18906
18659
  writeRoleRunState: () => writeRoleRunState
18907
18660
  });
18908
- import { chmod, lstat as lstat4, open as open2, readdir as readdir4, readFile as readFile15, unlink as unlink2 } from "node:fs/promises";
18909
- import { basename as basename12, join as join30 } from "node:path";
18910
- function buildAutoResumeContinuationPrompt(options) {
18911
- return appendEngineSessionMaterial(
18912
- [RESUME_TRANSPORT_ENVELOPE],
18913
- engineSessionMaterialFromOptions({
18914
- packageRoot: options.packageRoot,
18915
- ...pickEngineAxis(options)
18916
- })
18917
- ).join("\n");
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";
18663
+ function buildAutoResumeContinuationPrompt() {
18664
+ return RESUME_TRANSPORT_ENVELOPE;
18918
18665
  }
18919
18666
  async function writeRoleRunState(runDirectory, record) {
18920
18667
  const payload = { ...record, runDirectory };
@@ -18925,7 +18672,7 @@ function parseSameTicketSummonsMaterials(raw) {
18925
18672
  const record = raw;
18926
18673
  const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
18927
18674
  const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
18928
- 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;
18929
18676
  const sourceRunPath = typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "" ? record.sourceRunPath : void 0;
18930
18677
  let sourceRun;
18931
18678
  if (isRecord(record.sourceRun)) {
@@ -19150,7 +18897,7 @@ function isProcessAlive(pid) {
19150
18897
  async function autopsyWriterLock(lockPath) {
19151
18898
  let content;
19152
18899
  try {
19153
- content = await readFile15(lockPath, "utf8");
18900
+ content = await readFile14(lockPath, "utf8");
19154
18901
  } catch (error) {
19155
18902
  if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
19156
18903
  return { verdict: "unknown", reason: "unreadable", readFailure: error };
@@ -19209,7 +18956,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
19209
18956
  },
19210
18957
  relocate(nextRunDirectory) {
19211
18958
  currentRunDirectory = nextRunDirectory;
19212
- currentLockPath = join30(nextRunDirectory, WRITER_LOCK_FILE);
18959
+ currentLockPath = join29(nextRunDirectory, WRITER_LOCK_FILE);
19213
18960
  },
19214
18961
  async release() {
19215
18962
  if (released) return;
@@ -19248,10 +18995,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19248
18995
  };
19249
18996
  const reportReadFailure = (error) => {
19250
18997
  reportDiagnostic(
19251
- `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)}`
19252
18999
  );
19253
19000
  };
19254
- const lockPath = join30(runDirectory, WRITER_LOCK_FILE);
19001
+ const lockPath = join29(runDirectory, WRITER_LOCK_FILE);
19255
19002
  let lastAutopsy = { verdict: "absent" };
19256
19003
  let lastReclaimFailure;
19257
19004
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -19308,7 +19055,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19308
19055
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
19309
19056
  if (runId.trim() === "") return void 0;
19310
19057
  const ledgerHome = resolveActivationLedgerHome(home);
19311
- const booksRoot = join30(ledgerHome, "books");
19058
+ const booksRoot = join29(ledgerHome, "books");
19312
19059
  let bookKeys;
19313
19060
  try {
19314
19061
  bookKeys = await readdir4(booksRoot);
@@ -19343,7 +19090,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
19343
19090
  if (disk === void 0) return false;
19344
19091
  const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : sessionFileIn(disk.principalWire.sessionDirectory);
19345
19092
  try {
19346
- const stat2 = await lstat4(sessionFile);
19093
+ const stat2 = await lstat3(sessionFile);
19347
19094
  return stat2.isFile() && !stat2.isSymbolicLink();
19348
19095
  } catch (error) {
19349
19096
  if (errorCodeOf(error) === "ENOENT") return false;
@@ -19359,7 +19106,7 @@ async function findLatestRunIdForSeatTicket(input) {
19359
19106
  let runDirectories;
19360
19107
  try {
19361
19108
  runDirectories = await listBookRunDirectories(
19362
- input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
19109
+ input.ticketNumber === void 0 ? bookDir : join29(bookDir, String(input.ticketNumber))
19363
19110
  );
19364
19111
  } catch (error) {
19365
19112
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -19367,7 +19114,7 @@ async function findLatestRunIdForSeatTicket(input) {
19367
19114
  }
19368
19115
  let best;
19369
19116
  for (const runDirectory of runDirectories) {
19370
- const parsed = parseRunLeaf(basename12(runDirectory));
19117
+ const parsed = parseRunLeaf(basename11(runDirectory));
19371
19118
  if (parsed === void 0 || parsed.role !== input.role) continue;
19372
19119
  const runId = parsed.runId;
19373
19120
  const parentPath = await readRunParentPath(runDirectory);
@@ -19424,7 +19171,6 @@ async function loadResumableRunRecord(home, runId, authority) {
19424
19171
  let repository;
19425
19172
  let repositoryDisplay;
19426
19173
  let requestManifestPath;
19427
- let manifestDigest;
19428
19174
  let waitWindowMs;
19429
19175
  let issueNumber;
19430
19176
  let caseRunsPath;
@@ -19447,7 +19193,7 @@ async function loadResumableRunRecord(home, runId, authority) {
19447
19193
  instructionEmpty = record.instructionEmpty;
19448
19194
  }
19449
19195
  if (Array.isArray(record.attachments)) {
19450
- attachments = record.attachments;
19196
+ attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
19451
19197
  }
19452
19198
  if (record.phase === "plan" || record.phase === "apply") {
19453
19199
  phase = record.phase;
@@ -19479,12 +19225,9 @@ async function loadResumableRunRecord(home, runId, authority) {
19479
19225
  if (typeof record.repositoryDisplay === "string" && record.repositoryDisplay.trim() !== "") {
19480
19226
  repositoryDisplay = record.repositoryDisplay;
19481
19227
  }
19482
- if (typeof record.requestManifestPath === "string" && record.requestManifestPath.trim() !== "") {
19228
+ if (typeof record.requestManifestPath === "string") {
19483
19229
  requestManifestPath = record.requestManifestPath;
19484
19230
  }
19485
- if (typeof record.manifestDigest === "string" && record.manifestDigest.trim() !== "") {
19486
- manifestDigest = record.manifestDigest;
19487
- }
19488
19231
  if (typeof record.waitWindowMs === "number" && Number.isSafeInteger(record.waitWindowMs) && record.waitWindowMs >= 1) {
19489
19232
  waitWindowMs = record.waitWindowMs;
19490
19233
  }
@@ -19578,7 +19321,7 @@ async function loadResumableRunRecord(home, runId, authority) {
19578
19321
  );
19579
19322
  }
19580
19323
  }
19581
- const sourceRunLeaf = parseRunLeaf(basename12(sourceRunPath ?? ""));
19324
+ const sourceRunLeaf = parseRunLeaf(basename11(sourceRunPath ?? ""));
19582
19325
  const referencedRunId = sourceRun?.runId ?? sourceRunLeaf?.runId;
19583
19326
  const referencedRole = sourceRun?.role ?? sourceRunLeaf?.role;
19584
19327
  if (referencedRunId !== void 0 && referencedRunId !== "") {
@@ -19618,7 +19361,6 @@ async function loadResumableRunRecord(home, runId, authority) {
19618
19361
  ...repository === void 0 ? {} : { repository },
19619
19362
  ...repositoryDisplay === void 0 ? {} : { repositoryDisplay },
19620
19363
  ...requestManifestPath === void 0 ? {} : { requestManifestPath },
19621
- ...manifestDigest === void 0 ? {} : { manifestDigest },
19622
19364
  ...waitWindowMs === void 0 ? {} : { waitWindowMs },
19623
19365
  ...issueNumber === void 0 ? {} : { issueNumber },
19624
19366
  ...caseRunsPath === void 0 ? {} : { caseRunsPath },
@@ -19808,8 +19550,8 @@ function admitResumedRole(loaded) {
19808
19550
  return admitted;
19809
19551
  }
19810
19552
  case "collect-target": {
19811
- const { prNumber, repository, repositoryDisplay, manifestDigest } = fields;
19812
- if (repository === void 0 || repositoryDisplay === void 0 || manifestDigest === void 0) {
19553
+ const { prNumber, repository, repositoryDisplay } = fields;
19554
+ if (repository === void 0 || repositoryDisplay === void 0) {
19813
19555
  throw new CliUsageError(
19814
19556
  `role run admitted collector repository identity is missing: ${runId}`
19815
19557
  );
@@ -19832,8 +19574,7 @@ function admitResumedRole(loaded) {
19832
19574
  ...prNumber === void 0 ? {} : { prNumber },
19833
19575
  repository: parsedRepository,
19834
19576
  ...fields.requestManifestPath === void 0 ? {} : { requestManifestPath: fields.requestManifestPath },
19835
- ...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs },
19836
- manifestDigest
19577
+ ...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
19837
19578
  };
19838
19579
  return admitted;
19839
19580
  }
@@ -19888,7 +19629,6 @@ var init_run_lifecycle = __esm({
19888
19629
  init_cli_errors();
19889
19630
  init_collector_config();
19890
19631
  init_role_run_relocation();
19891
- init_engine_material();
19892
19632
  init_packaged_role_registry();
19893
19633
  init_invocation();
19894
19634
  init_run_dossier();
@@ -20140,7 +19880,7 @@ var init_receipt_delivery_policy = __esm({
20140
19880
  });
20141
19881
 
20142
19882
  // src/archivist-record-topology.ts
20143
- import { join as join32 } from "node:path";
19883
+ import { join as join31 } from "node:path";
20144
19884
  function resolveNavigatorWorkSubjectPlacement(input) {
20145
19885
  let ledgerHome;
20146
19886
  if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
@@ -20153,7 +19893,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
20153
19893
  const digest = sha256Hex(input.subject).slice(0, 32);
20154
19894
  return {
20155
19895
  ledgerHome,
20156
- sessionDir: join32(
19896
+ sessionDir: join31(
20157
19897
  activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
20158
19898
  NAVIGATOR_RECORD_KIND,
20159
19899
  digest
@@ -20220,18 +19960,18 @@ import {
20220
19960
  existsSync as existsSync11,
20221
19961
  openSync,
20222
19962
  readdirSync as readdirSync3,
20223
- readFileSync as readFileSync3,
19963
+ readFileSync as readFileSync4,
20224
19964
  readSync,
20225
19965
  realpathSync as realpathSync4,
20226
19966
  statSync as statSync8,
20227
19967
  writeFileSync as writeFileSync3
20228
19968
  } from "node:fs";
20229
- 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";
20230
19970
  import { StringDecoder } from "node:string_decoder";
20231
19971
  function readCurrentSession(sessionDir) {
20232
19972
  const ledger = currentSessionLedgerPath(sessionDir);
20233
19973
  try {
20234
- const value = JSON.parse(readFileSync3(ledger, "utf8"));
19974
+ const value = JSON.parse(readFileSync4(ledger, "utf8"));
20235
19975
  if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
20236
19976
  throw new Error("sessionFile is missing");
20237
19977
  }
@@ -20260,7 +20000,7 @@ function isCurrentSessionClaimRace(error) {
20260
20000
  return errnoCode(error.cause) === "EEXIST";
20261
20001
  }
20262
20002
  function currentSessionLedgerPath(sessionDir) {
20263
- return join33(sessionDir, CURRENT_SESSION_LEDGER);
20003
+ return join32(sessionDir, CURRENT_SESSION_LEDGER);
20264
20004
  }
20265
20005
  function readBoundedSessionHeader(filePath) {
20266
20006
  const fd = openSync(filePath, "r");
@@ -20333,8 +20073,8 @@ function parseSessionHeaderLine(line2) {
20333
20073
  };
20334
20074
  }
20335
20075
  function mostRecentNavigatorSessionFile(sessionDir, cwd) {
20336
- const absoluteSessionDir = resolve17(sessionDir);
20337
- const absoluteCwd = resolve17(cwd);
20076
+ const absoluteSessionDir = resolve16(sessionDir);
20077
+ const absoluteCwd = resolve16(cwd);
20338
20078
  let names;
20339
20079
  try {
20340
20080
  names = readdirSync3(absoluteSessionDir);
@@ -20347,7 +20087,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
20347
20087
  const matched = [];
20348
20088
  for (const name of names) {
20349
20089
  if (!name.endsWith(".jsonl")) continue;
20350
- const filePath = join33(absoluteSessionDir, name);
20090
+ const filePath = join32(absoluteSessionDir, name);
20351
20091
  let st;
20352
20092
  try {
20353
20093
  st = statSync8(filePath);
@@ -20369,7 +20109,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
20369
20109
  }
20370
20110
  if (header === void 0) continue;
20371
20111
  if (typeof header.cwd !== "string" || header.cwd.length === 0) continue;
20372
- if (resolve17(header.cwd) !== absoluteCwd) continue;
20112
+ if (resolve16(header.cwd) !== absoluteCwd) continue;
20373
20113
  matched.push({ path: filePath, mtimeMs: st.mtimeMs });
20374
20114
  }
20375
20115
  if (matched.length === 0) return void 0;
@@ -20399,8 +20139,8 @@ function resolveNavigatorNestContinuation(sessionDir, cwd) {
20399
20139
  }
20400
20140
  }
20401
20141
  function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
20402
- const absoluteSessionDir = resolve17(sessionDir);
20403
- const absoluteFile = resolve17(recentFile);
20142
+ const absoluteSessionDir = resolve16(sessionDir);
20143
+ const absoluteFile = resolve16(recentFile);
20404
20144
  if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
20405
20145
  throw new ActivationLedgerError(
20406
20146
  `archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
@@ -20455,7 +20195,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
20455
20195
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
20456
20196
  } else {
20457
20197
  ledgerHome = resolveActivationLedgerHomeForPath(parentFile);
20458
- const parentResolved = resolve17(parentFile);
20198
+ const parentResolved = resolve16(parentFile);
20459
20199
  if (!physicallyContainedIn(ledgerHome, parentResolved)) {
20460
20200
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
20461
20201
  }
@@ -20546,7 +20286,7 @@ init_submission_ledger();
20546
20286
  init_filed_submission();
20547
20287
  import { randomUUID as randomUUID7 } from "node:crypto";
20548
20288
  import { writeSync as writeSync2 } from "node:fs";
20549
- import { join as join35 } from "node:path";
20289
+ import { join as join34 } from "node:path";
20550
20290
  import { Value as Value4 } from "typebox/value";
20551
20291
 
20552
20292
  // src/activation-trace.ts
@@ -20598,7 +20338,7 @@ import {
20598
20338
  statSync as statSync7,
20599
20339
  writeFileSync as writeFileSync2
20600
20340
  } from "node:fs";
20601
- import { isAbsolute as isAbsolute11, resolve as resolve15 } from "node:path";
20341
+ import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
20602
20342
  var ActivationSessionFileMissingError = class extends Error {
20603
20343
  code = "AK_ACTIVATION_SESSION_FILE_MISSING";
20604
20344
  path;
@@ -20638,12 +20378,12 @@ function durableSessionPointer(sessionManager) {
20638
20378
  "Workflow role activation requires a durable Pi session file principal (getSessionFile); directory-only or --no-session invocations are rejected"
20639
20379
  );
20640
20380
  }
20641
- if (!isAbsolute11(file)) {
20381
+ if (!isAbsolute10(file)) {
20642
20382
  throw new Error(
20643
20383
  `Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
20644
20384
  );
20645
20385
  }
20646
- const resolvedFile = resolve15(file);
20386
+ const resolvedFile = resolve14(file);
20647
20387
  try {
20648
20388
  lstatSync2(resolvedFile);
20649
20389
  } catch (error) {
@@ -20887,7 +20627,7 @@ var COLLECTOR_TRANSPORT_FLAGS = Object.freeze([
20887
20627
  Object.freeze({
20888
20628
  name: "ak-collector-request-manifest",
20889
20629
  definition: Object.freeze({
20890
- 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).",
20891
20631
  type: "string"
20892
20632
  })
20893
20633
  })
@@ -20898,19 +20638,9 @@ function buildMethodContext(activation) {
20898
20638
  `host: github.com`,
20899
20639
  `repository: ${activation.repository.canonical}`,
20900
20640
  `prNumber: ${activation.prNumber === void 0 ? "\u672A\u7ED1\u5B9A" : String(activation.prNumber)}`,
20901
- `requests: ${JSON.stringify(activation.manifest.requests.map((request) => ({ id: request.id })))}`,
20902
- `manifestDigest: ${activation.manifest.digest}`,
20641
+ ...activation.requestManifestPath === void 0 ? [] : [`requestManifestPath: ${activation.requestManifestPath}`],
20903
20642
  "</collector_method>"
20904
20643
  ];
20905
- if (activation.manifest.requests.length > 0) {
20906
- const payload = JSON.stringify({
20907
- requests: activation.manifest.requests.map((request) => ({
20908
- id: request.id,
20909
- body: request.requestBody
20910
- }))
20911
- }).replaceAll("<", "\\u003c");
20912
- lines.push("", "<collector_request_manifest>", payload, "</collector_request_manifest>");
20913
- }
20914
20644
  return lines.join("\n");
20915
20645
  }
20916
20646
  function createCollectorRoleRuntime(pi, dependencies) {
@@ -20932,12 +20662,12 @@ function createCollectorRoleRuntime(pi, dependencies) {
20932
20662
  } else if (typeof prFlag === "number") {
20933
20663
  prNumber = parseCollectorPrNumber(prFlag);
20934
20664
  }
20935
- const manifest = typeof requestManifestFlag === "string" && requestManifestFlag.trim().length > 0 ? await loadCollectorManifest(requestManifestFlag) : emptyCollectorManifest();
20665
+ const requestManifestPath = typeof requestManifestFlag === "string" ? requestManifestFlag : void 0;
20936
20666
  return {
20937
20667
  soul,
20938
20668
  repository,
20939
20669
  prNumber,
20940
- manifest
20670
+ ...requestManifestPath === void 0 ? {} : { requestManifestPath }
20941
20671
  };
20942
20672
  },
20943
20673
  assembleMaterials(activation, baseSystemPrompt) {
@@ -21224,14 +20954,14 @@ var AUDITOR_TOOL_SPEC = roleSubmissionDeclaration("auditor");
21224
20954
  init_navigator_invocation_identity();
21225
20955
  init_packaged_role_registry();
21226
20956
  init_activation_ledger_topology();
21227
- import { resolve as resolve18 } from "node:path";
20957
+ import { resolve as resolve17 } from "node:path";
21228
20958
  import "@earendil-works/pi-coding-agent";
21229
20959
  import { Type as Type21 } from "typebox";
21230
20960
 
21231
20961
  // src/navigator-public-session.ts
21232
20962
  init_host_session_record();
21233
20963
  import { existsSync as existsSync12 } from "node:fs";
21234
- import { basename as basename14 } from "node:path";
20964
+ import { basename as basename13 } from "node:path";
21235
20965
 
21236
20966
  // src/navigator-session-contracts.ts
21237
20967
  init_unknown_value();
@@ -21425,18 +21155,18 @@ init_packaged_role_registry();
21425
21155
  init_atomic_write();
21426
21156
  init_unknown_value();
21427
21157
  import { existsSync as existsSync9, realpathSync as realpathSync3 } from "node:fs";
21428
- import { readFile as readFile16 } from "node:fs/promises";
21429
- 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";
21430
21160
  var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
21431
21161
  function navigatorWorkContextFile(sessionDir) {
21432
- return join31(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
21162
+ return join30(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
21433
21163
  }
21434
21164
  function isNavigatorWorkContextFile(path) {
21435
- const resolved = resolve16(path);
21436
- if (basename13(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
21165
+ const resolved = resolve15(path);
21166
+ if (basename12(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
21437
21167
  const nest = dirname18(resolved);
21438
- if (!/^[0-9a-f]{32}$/.test(basename13(nest))) return false;
21439
- return basename13(dirname18(nest)) === "navigator";
21168
+ if (!/^[0-9a-f]{32}$/.test(basename12(nest))) return false;
21169
+ return basename12(dirname18(nest)) === "navigator";
21440
21170
  }
21441
21171
  function canonicalNavigatorWorkContextFile(path) {
21442
21172
  if (!isNavigatorWorkContextFile(path)) return void 0;
@@ -21454,7 +21184,7 @@ async function persistNavigatorWorkBase(sessionDir, body) {
21454
21184
  const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}
21455
21185
  `;
21456
21186
  try {
21457
- const current = await readFile16(path, "utf8");
21187
+ const current = await readFile15(path, "utf8");
21458
21188
  if (current === next) return path;
21459
21189
  } catch (error) {
21460
21190
  if (!isEnoent(error)) throw error;
@@ -21467,7 +21197,7 @@ async function readNavigatorWorkBase(path) {
21467
21197
  if (canonical === void 0) return void 0;
21468
21198
  let text;
21469
21199
  try {
21470
- text = await readFile16(canonical, "utf8");
21200
+ text = await readFile15(canonical, "utf8");
21471
21201
  } catch (error) {
21472
21202
  if (isEnoent(error)) return void 0;
21473
21203
  throw error;
@@ -21541,7 +21271,7 @@ async function resolveNavigatorLedgerHome(context) {
21541
21271
  }
21542
21272
  var NAVIGATOR_HOST_RUN_POINTER_ENTRY = "ak-navigator-host-run";
21543
21273
  function runIdFromNavigatorDirectory(runDirectory) {
21544
- const parsed = parseRunLeaf(basename14(runDirectory));
21274
+ const parsed = parseRunLeaf(basename13(runDirectory));
21545
21275
  if (parsed === void 0 || parsed.role !== "navigator") return void 0;
21546
21276
  return parsed.runId;
21547
21277
  }
@@ -21778,7 +21508,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
21778
21508
  }
21779
21509
  function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
21780
21510
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
21781
- const resolvedReference = resolve18(cwd, reference);
21511
+ const resolvedReference = resolve17(cwd, reference);
21782
21512
  const marker = "/runs/";
21783
21513
  if (resolvedReference.includes(marker)) {
21784
21514
  return subjectRoot;
@@ -22222,8 +21952,8 @@ init_unknown_value();
22222
21952
  init_submission_errors();
22223
21953
  init_worker_submission_contracts();
22224
21954
  import { execFileSync as execFileSync3 } from "node:child_process";
22225
- import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync4, rmdirSync, rmSync as rmSync3 } from "node:fs";
22226
- import { resolve as resolve19 } from "node:path";
21955
+ import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync3 } from "node:fs";
21956
+ import { resolve as resolve18 } from "node:path";
22227
21957
  var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
22228
21958
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
22229
21959
  var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
@@ -22263,7 +21993,7 @@ function tryGetAll(file, key) {
22263
21993
  }
22264
21994
  function ownedHook(path) {
22265
21995
  if (!existsSync13(path)) return false;
22266
- return readFileSync4(path, "utf8").includes(HOOK_MARKER);
21996
+ return readFileSync5(path, "utf8").includes(HOOK_MARKER);
22267
21997
  }
22268
21998
  function escapeGitConfigValueRegex(value) {
22269
21999
  return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
@@ -22271,7 +22001,7 @@ function escapeGitConfigValueRegex(value) {
22271
22001
  function unsetOwnedHooksPath(file) {
22272
22002
  const owned = [];
22273
22003
  for (const value of tryGetAll(file, "core.hooksPath")) {
22274
- if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
22004
+ if (!ownedHook(resolve18(value, HOOK_FILE))) continue;
22275
22005
  try {
22276
22006
  gitFile(file, [
22277
22007
  "--unset-all",
@@ -22286,15 +22016,15 @@ function unsetOwnedHooksPath(file) {
22286
22016
  return owned;
22287
22017
  }
22288
22018
  function rmOwnedDir(dir) {
22289
- const hookPath = resolve19(dir, HOOK_FILE);
22019
+ const hookPath = resolve18(dir, HOOK_FILE);
22290
22020
  if (!ownedHook(hookPath)) return;
22291
22021
  rmSync3(hookPath, { force: true });
22292
22022
  if (existsSync13(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
22293
22023
  }
22294
22024
  function linkedGitDirs(commonDir) {
22295
- const root = resolve19(commonDir, "worktrees");
22025
+ const root = resolve18(commonDir, "worktrees");
22296
22026
  if (!existsSync13(root)) return [];
22297
- 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());
22298
22028
  }
22299
22029
  function uninstallPackageWorkerHooks(cwd) {
22300
22030
  let inside;
@@ -22308,14 +22038,14 @@ function uninstallPackageWorkerHooks(cwd) {
22308
22038
  const clear = (configFile) => {
22309
22039
  for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
22310
22040
  };
22311
- clear(resolve19(commonDir, "config"));
22312
- clear(resolve19(commonDir, "config.worktree"));
22313
- rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
22314
- 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);
22315
22045
  if (ownedHook(legacy)) rmSync3(legacy, { force: true });
22316
22046
  for (const gitDir of linkedGitDirs(commonDir)) {
22317
- clear(resolve19(gitDir, "config.worktree"));
22318
- rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
22047
+ clear(resolve18(gitDir, "config.worktree"));
22048
+ rmOwnedDir(resolve18(gitDir, HOOKS_DIR));
22319
22049
  }
22320
22050
  }
22321
22051
  function containsWrittenReason(value) {
@@ -23187,7 +22917,7 @@ function readRoleRunCoordinates(ctx, label) {
23187
22917
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
23188
22918
  const admitted = readPageSync(runDirectory, "admitted");
23189
22919
  if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
23190
- 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)})`);
23191
22921
  }
23192
22922
  return {
23193
22923
  runDirectory,
@@ -23500,9 +23230,6 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23500
23230
  }
23501
23231
  });
23502
23232
  roleHost.on("before_agent_start", () => {
23503
- const role = selectedRole ?? roleHost.getFlag(ROLE_FLAG.name);
23504
- if (typeof role !== "string" || !isOfficerReviewSeat(role)) return;
23505
- if (roleHost.getFlag(STATION_CHILD_FLAG.name) !== true) return;
23506
23233
  const engine = resolveEngineName((name) => roleHost.getFlag(name));
23507
23234
  if (engine === void 0 || dependencies.packageRoot === void 0) return;
23508
23235
  const engineModel = resolveEngineModel((name) => roleHost.getFlag(name));
@@ -23511,15 +23238,9 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23511
23238
  ...engineModel === void 0 ? {} : { engineModel },
23512
23239
  packageRoot: dependencies.packageRoot
23513
23240
  });
23514
- if (material === void 0) return;
23515
- return {
23516
- readingMaterial: {
23517
- kind: "engine-session-material",
23518
- name: material.name,
23519
- ...material.model === void 0 ? {} : { model: material.model },
23520
- ...material.materialPath === void 0 ? {} : { materialPath: material.materialPath }
23521
- }
23522
- };
23241
+ const reading = engineSessionReadingMaterial(material);
23242
+ if (reading === void 0) return;
23243
+ return { readingMaterial: reading };
23523
23244
  });
23524
23245
  roleHost.on("before_agent_start", () => {
23525
23246
  const path = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
@@ -24035,11 +23756,11 @@ init_settlement();
24035
23756
  init_run_lifecycle();
24036
23757
  init_unknown_value();
24037
23758
  async function listen(server, path) {
24038
- await new Promise((resolve22, reject) => {
23759
+ await new Promise((resolve21, reject) => {
24039
23760
  server.once("error", reject);
24040
23761
  server.listen(path, () => {
24041
23762
  server.off("error", reject);
24042
- resolve22();
23763
+ resolve21();
24043
23764
  });
24044
23765
  });
24045
23766
  }
@@ -24464,8 +24185,8 @@ async function prepareRoleEnvelope(options) {
24464
24185
  try {
24465
24186
  const closeAll = server.closeAllConnections;
24466
24187
  if (typeof closeAll === "function") closeAll.call(server);
24467
- await new Promise((resolve22, reject) => {
24468
- server.close((error) => error ? reject(error) : resolve22());
24188
+ await new Promise((resolve21, reject) => {
24189
+ server.close((error) => error ? reject(error) : resolve21());
24469
24190
  });
24470
24191
  } catch (error) {
24471
24192
  await retainPackageFault({
@@ -24598,7 +24319,7 @@ async function prepareRoleEnvelope(options) {
24598
24319
  }
24599
24320
 
24600
24321
  // src/role-runtime-dependencies.ts
24601
- import { readFile as readFile18 } from "node:fs/promises";
24322
+ import { readFile as readFile17 } from "node:fs/promises";
24602
24323
  init_doctor_evidence();
24603
24324
 
24604
24325
  // src/navigator-work-context.ts
@@ -24606,8 +24327,8 @@ init_role_run_placement();
24606
24327
  init_doctor_evidence();
24607
24328
  init_unknown_value();
24608
24329
  init_host_contracts();
24609
- import { readFile as readFile17 } from "node:fs/promises";
24610
- import { resolve as resolve20 } from "node:path";
24330
+ import { readFile as readFile16 } from "node:fs/promises";
24331
+ import { resolve as resolve19 } from "node:path";
24611
24332
  init_notary_source_run();
24612
24333
  init_packaged_role_registry();
24613
24334
  init_invocation();
@@ -24615,12 +24336,12 @@ function navigatorInputReference(getFlag, role) {
24615
24336
  if (getFlag === void 0) return void 0;
24616
24337
  const name = packagedRoleInputFlag(role);
24617
24338
  const value = name === void 0 ? void 0 : getFlag(name);
24618
- return typeof value === "string" && value !== "" ? resolve20(value) : void 0;
24339
+ return typeof value === "string" && value !== "" ? resolve19(value) : void 0;
24619
24340
  }
24620
24341
  async function loadNavigatorWorkContext(options) {
24621
24342
  const reference = navigatorInputReference(options.getFlag, options.role);
24622
24343
  const subjectMode = packagedNavigatorSubject(options.role);
24623
- 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");
24624
24345
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
24625
24346
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
24626
24347
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -24637,7 +24358,7 @@ async function loadNavigatorWorkContext(options) {
24637
24358
  }
24638
24359
  const publicRunDir = runDirectoryFromHostContext(options.context);
24639
24360
  const currentSessionDir = options.context.sessionManager.getSessionDir();
24640
- const isBoundPublicRun = publicRunDir !== void 0 && resolve20(currentSessionDir) === resolve20(sessionDirectoryOf(publicRunDir));
24361
+ const isBoundPublicRun = publicRunDir !== void 0 && resolve19(currentSessionDir) === resolve19(sessionDirectoryOf(publicRunDir));
24641
24362
  if (subjectMode === "public-instruction" && isBoundPublicRun) {
24642
24363
  let admitted;
24643
24364
  try {
@@ -24670,14 +24391,14 @@ async function loadNavigatorWorkContext(options) {
24670
24391
  }
24671
24392
  const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
24672
24393
  const authorityFiles = workRoot === void 0 ? [] : [
24673
- resolve20(workRoot, "authority.md"),
24674
- resolve20(workRoot, "authority.txt"),
24675
- 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")
24676
24397
  ];
24677
24398
  let authorityMaterial;
24678
24399
  for (const path of authorityFiles) {
24679
24400
  try {
24680
- const content = await readFile17(path, "utf8");
24401
+ const content = await readFile16(path, "utf8");
24681
24402
  if (content.trim() !== "") {
24682
24403
  authorityMaterial = content;
24683
24404
  break;
@@ -24719,11 +24440,11 @@ function createRoleRuntimeDependencies(packageRoot) {
24719
24440
  packageRoot,
24720
24441
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
24721
24442
  loadRoleSoul: loadRegisteredRoleSoul,
24722
- loadFixPacket: (path) => readFile18(path, "utf8"),
24723
- loadCoderTask: (path) => readFile18(path, "utf8"),
24443
+ loadFixPacket: (path) => readFile17(path, "utf8"),
24444
+ loadCoderTask: (path) => readFile17(path, "utf8"),
24724
24445
  loadDoctorCase,
24725
24446
  loadNotarySourceRun: loadNotarySourceRunLocator,
24726
- loadMergerInput: async (path) => JSON.parse(await readFile18(path, "utf8")),
24447
+ loadMergerInput: async (path) => JSON.parse(await readFile17(path, "utf8")),
24727
24448
  loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
24728
24449
  context: options.context,
24729
24450
  role: options.role,
@@ -24806,7 +24527,7 @@ function hostAbortedError(message = "host aborted") {
24806
24527
  function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
24807
24528
  if (abortSignal?.aborted) return Promise.reject(hostAbortedError(message));
24808
24529
  if (abortSignal === void 0) return work;
24809
- return new Promise((resolve22, reject) => {
24530
+ return new Promise((resolve21, reject) => {
24810
24531
  let settled = false;
24811
24532
  const onAbort = () => {
24812
24533
  if (settled) return;
@@ -24821,7 +24542,7 @@ function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
24821
24542
  if (settled) return;
24822
24543
  settled = true;
24823
24544
  abortSignal.removeEventListener("abort", onAbort);
24824
- resolve22(value);
24545
+ resolve21(value);
24825
24546
  },
24826
24547
  (error) => {
24827
24548
  if (settled) return;
@@ -25083,19 +24804,19 @@ function connectAcpStdio(options) {
25083
24804
  terminate(error);
25084
24805
  }
25085
24806
  });
25086
- const processClosed = new Promise((resolve22) => {
24807
+ const processClosed = new Promise((resolve21) => {
25087
24808
  child.once("close", (code, signal) => {
25088
24809
  if (spawned) nativeExit = { code, timedOut: false, ...signal === null ? {} : { signal } };
25089
24810
  settleClosed(acpError("acp-closed", "ACP process closed"));
25090
- resolve22();
24811
+ resolve21();
25091
24812
  });
25092
24813
  });
25093
24814
  return Promise.resolve({
25094
24815
  request(method, params) {
25095
24816
  if (closed) return Promise.reject(terminalError);
25096
24817
  const id = ++nextId;
25097
- return new Promise((resolve22, reject) => {
25098
- pending.set(id, { resolve: resolve22, reject });
24818
+ return new Promise((resolve21, reject) => {
24819
+ pending.set(id, { resolve: resolve21, reject });
25099
24820
  child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
25100
24821
  `, (error) => {
25101
24822
  if (error === null || error === void 0) return;
@@ -25376,13 +25097,13 @@ function createAcpRoleTurnHost(config) {
25376
25097
 
25377
25098
  // src/acp-host/seat-profile-soul.ts
25378
25099
  import { constants as constants3 } from "node:fs";
25379
- import { access as access3, copyFile, lstat as lstat5, mkdir as mkdir4, readlink, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
25380
- 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";
25381
25102
  function seatProfileName(spec, role) {
25382
25103
  return `${spec.namePrefix}${role}`;
25383
25104
  }
25384
25105
  function packageRoleSoulPath(packageRoot, role) {
25385
- return join36(packageRoot, "souls", `${role}.md`);
25106
+ return join35(packageRoot, "souls", `${role}.md`);
25386
25107
  }
25387
25108
  async function pathExists2(path) {
25388
25109
  try {
@@ -25395,20 +25116,20 @@ async function pathExists2(path) {
25395
25116
  async function ensureSeatProfileSoul(options) {
25396
25117
  const { spec, operatorHome, packageRoot, role } = options;
25397
25118
  const profileName = seatProfileName(spec, role);
25398
- const soulTarget = resolve21(packageRoleSoulPath(packageRoot, role));
25119
+ const soulTarget = resolve20(packageRoleSoulPath(packageRoot, role));
25399
25120
  if (!await pathExists2(soulTarget)) {
25400
25121
  throw new Error(`packaged role soul missing: ${soulTarget}`);
25401
25122
  }
25402
- const profilesRoot = join36(operatorHome, ...spec.profilesRootFromHome);
25403
- const profileDir = join36(profilesRoot, profileName);
25123
+ const profilesRoot = join35(operatorHome, ...spec.profilesRootFromHome);
25124
+ const profileDir = join35(profilesRoot, profileName);
25404
25125
  const hostRoot = dirname22(profilesRoot);
25405
- const soulPath = join36(profileDir, spec.soulFileName);
25126
+ const soulPath = join35(profileDir, spec.soulFileName);
25406
25127
  if (!await pathExists2(profileDir)) {
25407
25128
  await mkdir4(profileDir, { recursive: true });
25408
25129
  for (const name of ["auth.json", ".env", "config.yaml"]) {
25409
- const source = join36(hostRoot, name);
25130
+ const source = join35(hostRoot, name);
25410
25131
  if (!await pathExists2(source)) continue;
25411
- await copyFile(source, join36(profileDir, name));
25132
+ await copyFile(source, join35(profileDir, name));
25412
25133
  }
25413
25134
  } else {
25414
25135
  await mkdir4(profileDir, { recursive: true });
@@ -25416,7 +25137,7 @@ async function ensureSeatProfileSoul(options) {
25416
25137
  const desiredLink = relative3(profileDir, soulTarget);
25417
25138
  let current;
25418
25139
  try {
25419
- const st = await lstat5(soulPath);
25140
+ const st = await lstat4(soulPath);
25420
25141
  if (st.isSymbolicLink()) {
25421
25142
  current = await readlink(soulPath);
25422
25143
  }