@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.
@@ -3597,7 +3597,7 @@ var init_host_session_record = __esm({
3597
3597
  });
3598
3598
 
3599
3599
  // src/package-resources/engine-material.ts
3600
- import { existsSync as existsSync2, readdirSync as readdirSync2 } from "node:fs";
3600
+ import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
3601
3601
  import { join as join8 } from "node:path";
3602
3602
  function pickEngineAxis(source) {
3603
3603
  return {
@@ -3621,6 +3621,9 @@ function isEngineNameSyntax(name) {
3621
3621
  function resolveEngineMaterialDirectory(packageRoot) {
3622
3622
  return join8(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
3623
3623
  }
3624
+ function resolveEngineDispatchMaterialPath(packageRoot) {
3625
+ return join8(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
3626
+ }
3624
3627
  function resolveEngineMaterialPath(packageRoot, name) {
3625
3628
  const legal = assertLegalEngineName(name);
3626
3629
  return join8(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
@@ -3640,37 +3643,30 @@ function engineSessionMaterialFromOptions(options) {
3640
3643
  const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
3641
3644
  const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
3642
3645
  const modelField = model === void 0 ? {} : { model };
3643
- if (existsSync2(materialPath)) {
3644
- return Object.freeze({ name, materialPath, ...modelField });
3646
+ if (!existsSync2(materialPath)) {
3647
+ return Object.freeze({ name, ...modelField });
3645
3648
  }
3646
- return Object.freeze({ name, ...modelField });
3649
+ const handbook = readFileSync2(materialPath, "utf8");
3650
+ const dispatchPath = resolveEngineDispatchMaterialPath(options.packageRoot);
3651
+ const dispatchField = existsSync2(dispatchPath) ? { dispatchHandbook: readFileSync2(dispatchPath, "utf8") } : {};
3652
+ return Object.freeze({ name, handbook, ...dispatchField, ...modelField });
3647
3653
  }
3648
- function appendEngineSessionMaterial(lines, engineMaterial) {
3649
- if (engineMaterial === void 0) {
3650
- return [...lines];
3651
- }
3652
- const out = [...lines];
3653
- out.push("");
3654
- if (engineMaterial.materialPath !== void 0) {
3655
- out.push("\u672C\u6B21\u914D\u7F6E\u7684\u52B3\u52A1\u5F15\u64CE\u53CA\u5176\u624B\u518C\uFF1A");
3656
- out.push(`- engine: ${engineMaterial.name}`);
3657
- if (engineMaterial.model !== void 0) {
3658
- out.push(`- engineModel: ${engineMaterial.model}`);
3659
- }
3660
- out.push(`- ${engineMaterial.materialPath}`);
3661
- } else {
3662
- out.push(`- engine: ${engineMaterial.name}`);
3663
- if (engineMaterial.model !== void 0) {
3664
- out.push(`- engineModel: ${engineMaterial.model}`);
3665
- }
3666
- }
3667
- return out;
3654
+ function engineSessionReadingMaterial(engineMaterial) {
3655
+ if (engineMaterial === void 0) return void 0;
3656
+ return {
3657
+ kind: "engine-session-material",
3658
+ name: engineMaterial.name,
3659
+ ...engineMaterial.model === void 0 ? {} : { model: engineMaterial.model },
3660
+ ...engineMaterial.handbook === void 0 ? {} : { handbook: engineMaterial.handbook },
3661
+ ...engineMaterial.dispatchHandbook === void 0 ? {} : { dispatchHandbook: engineMaterial.dispatchHandbook }
3662
+ };
3668
3663
  }
3669
- var ENGINE_MATERIAL_RELATIVE_ROOT;
3664
+ var ENGINE_MATERIAL_RELATIVE_ROOT, ENGINE_DISPATCH_RELATIVE_PATH;
3670
3665
  var init_engine_material = __esm({
3671
3666
  "src/package-resources/engine-material.ts"() {
3672
3667
  "use strict";
3673
3668
  ENGINE_MATERIAL_RELATIVE_ROOT = "resources/engines";
3669
+ ENGINE_DISPATCH_RELATIVE_PATH = "resources/engine-dispatch.md";
3674
3670
  }
3675
3671
  });
3676
3672
 
@@ -4440,7 +4436,6 @@ var init_durable_principal = __esm({
4440
4436
  });
4441
4437
 
4442
4438
  // src/collector-config.ts
4443
- import { readFile as readFile6 } from "node:fs/promises";
4444
4439
  function fail3(message, cause) {
4445
4440
  throw new Error(message, cause === void 0 ? void 0 : { cause });
4446
4441
  }
@@ -4468,47 +4463,10 @@ function parseCollectorPrNumber(raw) {
4468
4463
  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");
4469
4464
  return value;
4470
4465
  }
4471
- function canonicalManifest(requests) {
4472
- return `${JSON.stringify({ requests: requests.map((request) => ({ id: request.id, body: request.requestBody })) })}
4473
- `;
4474
- }
4475
- function emptyCollectorManifest() {
4476
- const canonicalJson2 = canonicalManifest([]);
4477
- return { requests: [], canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2) };
4478
- }
4479
- async function loadCollectorManifest(path) {
4480
- let bytes;
4481
- try {
4482
- bytes = await readFile6(path);
4483
- } catch (error) {
4484
- fail3(`Collector request manifest is unreadable at ${path}`, error);
4485
- }
4486
- let parsed;
4487
- try {
4488
- parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
4489
- } catch (error) {
4490
- fail3("Collector request manifest must be UTF-8 JSON", error);
4491
- }
4492
- if (!isRecord(parsed)) fail3("Collector request manifest must be an object");
4493
- const rawRequests = parsed.requests ?? [];
4494
- if (!Array.isArray(rawRequests)) fail3("Collector request manifest requests must be an array");
4495
- const requests = [];
4496
- const ids = /* @__PURE__ */ new Set();
4497
- for (const [index, item] of rawRequests.entries()) {
4498
- 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`);
4499
- if (ids.has(item.id)) fail3(`Collector request manifest has duplicate request id "${item.id}"`);
4500
- ids.add(item.id);
4501
- requests.push({ id: item.id, requestBody: item.body });
4502
- }
4503
- const canonicalJson2 = canonicalManifest(requests);
4504
- return { requests, canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2), sourcePath: path };
4505
- }
4506
4466
  var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
4507
4467
  var init_collector_config = __esm({
4508
4468
  "src/collector-config.ts"() {
4509
4469
  "use strict";
4510
- init_sha256();
4511
- init_unknown_value();
4512
4470
  init_run_ticket_number();
4513
4471
  COLLECTOR_OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
4514
4472
  COLLECTOR_REPO_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/;
@@ -5314,13 +5272,13 @@ var init_receipt_delivery_policy = __esm({
5314
5272
  });
5315
5273
 
5316
5274
  // src/ledger-session-read.ts
5317
- import { readFile as readFile7 } from "node:fs/promises";
5275
+ import { readFile as readFile6 } from "node:fs/promises";
5318
5276
  async function readStrictPiSessionJsonl(path) {
5319
- const text = await readFile7(path, "utf8");
5277
+ const text = await readFile6(path, "utf8");
5320
5278
  return text.trim().split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
5321
5279
  }
5322
5280
  async function readLedgerSessionJsonlLines(path) {
5323
- const text = await readFile7(path, "utf8");
5281
+ const text = await readFile6(path, "utf8");
5324
5282
  const lines = text.split("\n");
5325
5283
  const out = [];
5326
5284
  for (let index = 0; index < lines.length; index += 1) {
@@ -5640,7 +5598,7 @@ async function runEngineDetourOnce(input) {
5640
5598
  }
5641
5599
  const command = input.argv[0];
5642
5600
  const args = input.argv.slice(1);
5643
- return await new Promise((resolve22, reject) => {
5601
+ return await new Promise((resolve21, reject) => {
5644
5602
  let settled = false;
5645
5603
  const signal = input.signal;
5646
5604
  const child = spawn(command, args, {
@@ -5670,7 +5628,7 @@ async function runEngineDetourOnce(input) {
5670
5628
  if (signal !== void 0) {
5671
5629
  signal.removeEventListener("abort", onAbort);
5672
5630
  }
5673
- resolve22(result);
5631
+ resolve21(result);
5674
5632
  };
5675
5633
  const onAbort = () => {
5676
5634
  fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
@@ -6449,7 +6407,7 @@ var init_git_object_id = __esm({
6449
6407
 
6450
6408
  // src/merger-git-state.ts
6451
6409
  import { execFile } from "node:child_process";
6452
- import { access, readFile as readFile8 } from "node:fs/promises";
6410
+ import { access, readFile as readFile7 } from "node:fs/promises";
6453
6411
  import { constants as fsConstants } from "node:fs";
6454
6412
  import { isAbsolute as isAbsolute3, resolve as resolve8 } from "node:path";
6455
6413
  import { promisify } from "node:util";
@@ -6519,7 +6477,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
6519
6477
  const mergeHeadPath = isAbsolute3(mergeHeadReported) ? mergeHeadReported : resolve8(repositoryRoot, mergeHeadReported);
6520
6478
  let sourceObjectId = "";
6521
6479
  if (await pathExists(mergeHeadPath)) {
6522
- const raw = exactUtf8(await readFile8(mergeHeadPath), "Git MERGE_HEAD");
6480
+ const raw = exactUtf8(await readFile7(mergeHeadPath), "Git MERGE_HEAD");
6523
6481
  const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
6524
6482
  if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
6525
6483
  if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
@@ -6665,7 +6623,7 @@ var init_session_dialogue = __esm({
6665
6623
  });
6666
6624
 
6667
6625
  // src/ticket-provenance.ts
6668
- import { readFile as readFile9 } from "node:fs/promises";
6626
+ import { readFile as readFile8 } from "node:fs/promises";
6669
6627
  import { join as join13, resolve as resolve9 } from "node:path";
6670
6628
  function dialogueSessionSourceRoots(home) {
6671
6629
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
@@ -6713,7 +6671,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
6713
6671
  const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
6714
6672
  let history;
6715
6673
  try {
6716
- history = await readFile9(join13(runDirectory, RUN_HISTORY_FILE), "utf8");
6674
+ history = await readFile8(join13(runDirectory, RUN_HISTORY_FILE), "utf8");
6717
6675
  } catch (error) {
6718
6676
  if (errnoCode(error) === "ENOENT") return;
6719
6677
  throw error;
@@ -7457,8 +7415,8 @@ var init_option_definitions = __esm({
7457
7415
  repeatable: true,
7458
7416
  form: "option",
7459
7417
  description: {
7460
- en: "Attach a regular file; frozen at admission (repeatable).",
7461
- zh: "\u9644\u52A0\u666E\u901A\u6587\u4EF6\uFF1B\u53D7\u7406\u5373\u51BB\u7ED3\uFF08\u53EF\u91CD\u590D\uFF09\u3002"
7418
+ 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.",
7419
+ 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"
7462
7420
  }
7463
7421
  };
7464
7422
  SHARED_PHASE_SEMANTICS = {
@@ -7633,8 +7591,8 @@ var init_option_definitions = __esm({
7633
7591
  repeatable: false,
7634
7592
  form: "option",
7635
7593
  description: {
7636
- 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.",
7637
- 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"
7594
+ 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.",
7595
+ 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"
7638
7596
  }
7639
7597
  }
7640
7598
  ];
@@ -8093,16 +8051,22 @@ var init_option_definitions = __esm({
8093
8051
  import { execFileSync as execFileSync2 } from "node:child_process";
8094
8052
  import { existsSync as existsSync5 } from "node:fs";
8095
8053
  import {
8096
- lstat as lstat2,
8097
- mkdtemp,
8098
- readFile as readFile10,
8054
+ readFile as readFile9,
8099
8055
  realpath as realpath3,
8100
8056
  rename as rename2,
8101
- rm as rm2,
8102
8057
  writeFile as writeFile3
8103
8058
  } from "node:fs/promises";
8104
- import { tmpdir } from "node:os";
8105
- import { basename as basename9, dirname as dirname11, isAbsolute as isAbsolute5, join as join15, resolve as resolve11 } from "node:path";
8059
+ import { dirname as dirname11, isAbsolute as isAbsolute5, join as join15, resolve as resolve11 } from "node:path";
8060
+ function normalizeAdmittedAttachment(raw) {
8061
+ if (typeof raw !== "object" || raw === null) return void 0;
8062
+ const record = raw;
8063
+ const path = record.path;
8064
+ if (typeof path === "string") return { path };
8065
+ return void 0;
8066
+ }
8067
+ function admitCallerAttachments(attachmentPaths) {
8068
+ return attachmentPaths.map((path) => ({ path }));
8069
+ }
8106
8070
  function issueAdmissionPlacement(authority, request) {
8107
8071
  const ledgerHome = resolveActivationLedgerHome(request.home);
8108
8072
  const bookKey = resolveBookKeyFromGit(request.cwd);
@@ -8281,19 +8245,11 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
8281
8245
  "taskPath",
8282
8246
  "packetPath",
8283
8247
  "prerequisitesPath",
8284
- "requestManifestPath",
8285
8248
  "mergerInputPath"
8286
8249
  ],
8287
8250
  oldRunDirectory,
8288
8251
  target.runDirectory
8289
8252
  );
8290
- for (const attachment of admitted.attachments) {
8291
- attachment.frozenPath = rewriteRunDirectoryPathValue(
8292
- attachment.frozenPath,
8293
- oldRunDirectory,
8294
- target.runDirectory
8295
- );
8296
- }
8297
8253
  admitted.principal = principal;
8298
8254
  renderCurrentSync(target.runDirectory);
8299
8255
  return { oldRunDirectory, newRunDirectory: target.runDirectory };
@@ -8330,7 +8286,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
8330
8286
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
8331
8287
  const rolePackageRoot = packageRoot;
8332
8288
  const raw = JSON.parse(
8333
- await readFile10(join15(rolePackageRoot, "package.json"), "utf8")
8289
+ await readFile9(join15(rolePackageRoot, "package.json"), "utf8")
8334
8290
  );
8335
8291
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
8336
8292
  throw new Error(
@@ -8386,7 +8342,7 @@ function assignPublicSeatOption(owner, taken, fields) {
8386
8342
  const value = taken.value;
8387
8343
  switch (taken.def.id) {
8388
8344
  case "attach":
8389
- fields.attachmentPaths.push(requireOptionPath(taken.def.canonical, value));
8345
+ fields.attachmentPaths.push(requireProvidedOptionValue(taken.def.canonical, value));
8390
8346
  return;
8391
8347
  case "project":
8392
8348
  fields.project = requireOptionPath(taken.def.canonical, value);
@@ -8430,7 +8386,7 @@ function assignPublicSeatOption(owner, taken, fields) {
8430
8386
  fields.repo = parseRepoOption(value);
8431
8387
  return;
8432
8388
  case "request-manifest":
8433
- fields.requestManifestPath = requireOptionPath(taken.def.canonical, value);
8389
+ fields.requestManifestPath = requireProvidedOptionValue(taken.def.canonical, value);
8434
8390
  return;
8435
8391
  case "issue": {
8436
8392
  if (value === void 0 || value.trim() === "") {
@@ -8545,6 +8501,12 @@ function requireOptionPath(flag, value) {
8545
8501
  }
8546
8502
  return value;
8547
8503
  }
8504
+ function requireProvidedOptionValue(flag, value) {
8505
+ if (value === void 0) {
8506
+ throw new CliUsageError(`${flag} requires a path`);
8507
+ }
8508
+ return value;
8509
+ }
8548
8510
  function skillArgTokenFault(value) {
8549
8511
  if (value === void 0 || value.trim() === "") return "empty";
8550
8512
  if (/\s/.test(value)) return "whitespace";
@@ -8597,124 +8559,6 @@ function requireAuthorityRef(value) {
8597
8559
  optionLike: "--authority-ref requires a durable reference, not inline Spec prose"
8598
8560
  });
8599
8561
  }
8600
- async function readRegularFileAttachment(sourcePath) {
8601
- const absolute = isAbsolute5(sourcePath) ? sourcePath : resolve11(sourcePath);
8602
- let st;
8603
- try {
8604
- st = await lstat2(absolute);
8605
- } catch (error) {
8606
- throw new CliUsageError(
8607
- `attachment is not a readable regular file: ${sourcePath}`,
8608
- { cause: error }
8609
- );
8610
- }
8611
- if (!st.isFile() || st.isSymbolicLink()) {
8612
- throw new CliUsageError(
8613
- `attachment must be a regular file (not a directory or symlink): ${sourcePath}`
8614
- );
8615
- }
8616
- try {
8617
- return { absolute, bytes: await readFile10(absolute) };
8618
- } catch (error) {
8619
- throw new CliUsageError(
8620
- `attachment is not a readable regular file: ${sourcePath}`,
8621
- { cause: error }
8622
- );
8623
- }
8624
- }
8625
- async function removePreparedAttachmentDirectory(stagingDirectory) {
8626
- await rm2(stagingDirectory, { recursive: true, force: true });
8627
- }
8628
- async function withPreparedAttachments(attachmentPaths, use) {
8629
- if (attachmentPaths.length === 0) return await use([]);
8630
- const stagingDirectory = await mkdtemp(join15(tmpdir(), "ak-role-attachments-"));
8631
- const prepared = [];
8632
- let result;
8633
- try {
8634
- for (let index = 0; index < attachmentPaths.length; index += 1) {
8635
- const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
8636
- const snapshotPath = join15(stagingDirectory, String(index).padStart(6, "0"));
8637
- await writeFile3(snapshotPath, bytes);
8638
- prepared.push({ absolute, snapshotPath });
8639
- }
8640
- result = await use(prepared);
8641
- } catch (primary) {
8642
- try {
8643
- await removePreparedAttachmentDirectory(stagingDirectory);
8644
- } catch (cleanup) {
8645
- throw new AggregateError(
8646
- [primary, cleanup],
8647
- "attachment snapshot operation failed and cleanup also failed",
8648
- { cause: primary }
8649
- );
8650
- }
8651
- throw primary;
8652
- }
8653
- await removePreparedAttachmentDirectory(stagingDirectory);
8654
- return result;
8655
- }
8656
- async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
8657
- const frozenPath = join15(
8658
- destinationDir,
8659
- `${String(index).padStart(2, "0")}-${basename9(provenancePath)}`
8660
- );
8661
- await writeFile3(frozenPath, bytes);
8662
- return {
8663
- provenancePath,
8664
- frozenPath,
8665
- byteLength: bytes.byteLength,
8666
- sha256: sha256Hex(bytes),
8667
- mediaKind: "regular-file"
8668
- };
8669
- }
8670
- async function freezePreparedAttachment(prepared, destinationDir, index) {
8671
- return freezeAttachmentBytes(
8672
- prepared.absolute,
8673
- await readFile10(prepared.snapshotPath),
8674
- destinationDir,
8675
- index
8676
- );
8677
- }
8678
- async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
8679
- const { absolute, bytes } = await readRegularFileAttachment(sourcePath);
8680
- return {
8681
- attachment: await freezeAttachmentBytes(absolute, bytes, destinationDir, index),
8682
- body: bytes
8683
- };
8684
- }
8685
- async function freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory) {
8686
- const attachments = [];
8687
- if (attachmentPaths.length > 0) {
8688
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
8689
- }
8690
- for (let i = 0; i < attachmentPaths.length; i += 1) {
8691
- const frozen = await freezeRegularFileAttachment(
8692
- attachmentPaths[i],
8693
- attachmentsDirectory,
8694
- i
8695
- );
8696
- attachments.push(frozen.attachment);
8697
- }
8698
- return attachments;
8699
- }
8700
- async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
8701
- if (attachmentPaths.length === 0) return [];
8702
- const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
8703
- const attachmentsDirectory = join15(runDirectory, "attachments", summonsKey);
8704
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
8705
- return freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory);
8706
- }
8707
- async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
8708
- if (prepared.length === 0) return [];
8709
- const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
8710
- const attachmentsDirectory = summonsKey === void 0 ? join15(runDirectory, "attachments") : join15(runDirectory, "attachments", summonsKey);
8711
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
8712
- const attachments = [];
8713
- for (let index = 0; index < prepared.length; index += 1) {
8714
- attachments.push(await freezePreparedAttachment(prepared[index], attachmentsDirectory, index));
8715
- }
8716
- return attachments;
8717
- }
8718
8562
  function ticketAdmissionFields(ticketNumber) {
8719
8563
  if (ticketNumber === void 0) return {};
8720
8564
  return {
@@ -8803,7 +8647,7 @@ async function admitPublicRole(role, parsed, env, override) {
8803
8647
  if (parsed.prerequisitesPath !== void 0) {
8804
8648
  const absolutePrereq = isAbsolute5(parsed.prerequisitesPath) ? parsed.prerequisitesPath : resolve11(parsed.prerequisitesPath);
8805
8649
  try {
8806
- prerequisitesSource = await readFile10(absolutePrereq, "utf8");
8650
+ prerequisitesSource = await readFile9(absolutePrereq, "utf8");
8807
8651
  } catch (error) {
8808
8652
  throw new CliUsageError(
8809
8653
  `fixer prerequisites path is unreadable: ${parsed.prerequisitesPath}`,
@@ -8860,37 +8704,17 @@ async function admitPublicRole(role, parsed, env, override) {
8860
8704
  } else {
8861
8705
  repository = resolveGitHubRemoteRepository(projectRoot);
8862
8706
  }
8863
- let manifest = emptyCollectorManifest();
8864
- let manifestCanonicalJson;
8865
- if (parsed.requestManifestPath !== void 0) {
8866
- try {
8867
- manifest = await loadCollectorManifest(parsed.requestManifestPath);
8868
- manifestCanonicalJson = manifest.canonicalJson;
8869
- } catch (error) {
8870
- throw new CliUsageError(
8871
- errorText(error),
8872
- { cause: error }
8873
- );
8874
- }
8875
- }
8876
- const manifestDigest = manifest.digest;
8877
8707
  const admittedCollector = await admitStandardMaterialInvocation("collector", {
8878
8708
  ...shared,
8879
8709
  instruction,
8880
8710
  attachmentPaths,
8881
8711
  ...project,
8882
- placedFields: async (placed) => {
8883
- let requestManifestPath;
8884
- if (manifestCanonicalJson !== void 0) {
8885
- requestManifestPath = join15(placed.runDirectory, "request-manifest.json");
8886
- await writeFile3(requestManifestPath, manifestCanonicalJson, "utf8");
8887
- }
8712
+ placedFields: async () => {
8888
8713
  return {
8889
8714
  ...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
8890
8715
  repository: repository.canonical,
8891
8716
  repositoryDisplay: repository.display,
8892
- ...requestManifestPath === void 0 ? {} : { requestManifestPath },
8893
- manifestDigest
8717
+ ...parsed.requestManifestPath === void 0 ? {} : { requestManifestPath: parsed.requestManifestPath }
8894
8718
  };
8895
8719
  }
8896
8720
  });
@@ -8903,12 +8727,10 @@ async function admitPublicRole(role, parsed, env, override) {
8903
8727
  );
8904
8728
  }
8905
8729
  const issueNumber = parsed.issueNumber;
8906
- let frozenAttachments = [];
8907
- const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
8730
+ return admitStandardMaterialInvocation("doctor", {
8908
8731
  ...shared,
8909
8732
  instruction,
8910
- attachmentPaths: [],
8911
- freezeAttachments: false,
8733
+ attachmentPaths,
8912
8734
  ...project,
8913
8735
  placedFields: async (placed) => {
8914
8736
  let caseRunsPath;
@@ -8949,16 +8771,13 @@ async function admitPublicRole(role, parsed, env, override) {
8949
8771
  { cause: error }
8950
8772
  );
8951
8773
  }
8952
- frozenAttachments = await freezeAttachments(placed.ledgerHome, attachmentPaths, placed.attachmentsDirectory);
8953
8774
  return {
8954
8775
  issueNumber,
8955
8776
  caseRunsPath,
8956
- caseIdentity,
8957
- attachments: persistedAttachmentRefs(frozenAttachments)
8777
+ caseIdentity
8958
8778
  };
8959
8779
  }
8960
8780
  });
8961
- return { ...admittedDoctor, attachments: frozenAttachments };
8962
8781
  }
8963
8782
  case "source-locator": {
8964
8783
  const projectRoot = resolve11(parsed.project ?? shared.cwd);
@@ -8985,7 +8804,7 @@ async function admitPublicRole(role, parsed, env, override) {
8985
8804
  instruction: "",
8986
8805
  attachmentPaths: [],
8987
8806
  ...project,
8988
- freezeAttachments: false,
8807
+ recordAttachments: false,
8989
8808
  admittedFields: {
8990
8809
  sourceRunPath: sourceRun.runDirectory,
8991
8810
  sourceRun
@@ -9002,7 +8821,7 @@ async function admitPublicRole(role, parsed, env, override) {
9002
8821
  instruction,
9003
8822
  attachmentPaths: [],
9004
8823
  ...project,
9005
- freezeAttachments: false,
8824
+ recordAttachments: false,
9006
8825
  admittedFields: { baseRevision }
9007
8826
  });
9008
8827
  }
@@ -9114,7 +8933,7 @@ async function placeRoleAdmission(options) {
9114
8933
  home: options.home,
9115
8934
  ...options.materialize === void 0 ? {} : { materialize: options.materialize }
9116
8935
  });
9117
- const attachments = options.freezeAttachments === false ? [] : await freezeAttachments(ledgerHome, options.attachmentPaths, attachmentsDirectory);
8936
+ const attachments = options.recordAttachments === false ? [] : admitCallerAttachments(options.attachmentPaths);
9118
8937
  return {
9119
8938
  runId,
9120
8939
  bookKey,
@@ -9130,13 +8949,7 @@ async function placeRoleAdmission(options) {
9130
8949
  };
9131
8950
  }
9132
8951
  function persistedAttachmentRefs(attachments) {
9133
- return attachments.map((attachment) => ({
9134
- provenancePath: attachment.provenancePath,
9135
- frozenPath: attachment.frozenPath,
9136
- byteLength: attachment.byteLength,
9137
- sha256: attachment.sha256,
9138
- mediaKind: attachment.mediaKind
9139
- }));
8952
+ return attachments.map((attachment) => ({ path: attachment.path }));
9140
8953
  }
9141
8954
  async function persistPlacedAdmission(admitted, placed, model) {
9142
8955
  writeAdmittedRequestPersistence(placed.runDirectory, admitted, {
@@ -9155,14 +8968,14 @@ async function persistPlacedAdmission(admitted, placed, model) {
9155
8968
  }
9156
8969
  async function admitStandardMaterialInvocation(role, options) {
9157
8970
  const defer = options.deferPersistence === true;
9158
- const skipFreeze = defer || options.freezeAttachments === false;
8971
+ const skipAttachments = defer || options.recordAttachments === false;
9159
8972
  const placed = await placeRoleAdmission({
9160
8973
  role,
9161
8974
  home: options.home,
9162
8975
  principalAuthority: options.principalAuthority,
9163
8976
  cwd: options.cwd,
9164
8977
  attachmentPaths: options.attachmentPaths,
9165
- ...skipFreeze ? { freezeAttachments: false } : {},
8978
+ ...skipAttachments ? { recordAttachments: false } : {},
9166
8979
  ...defer ? { materialize: false } : {},
9167
8980
  ...options.project === void 0 ? {} : { project: options.project },
9168
8981
  ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
@@ -9170,7 +8983,7 @@ async function admitStandardMaterialInvocation(role, options) {
9170
8983
  });
9171
8984
  const correlationFields = options.correlationId === void 0 ? {} : { correlationId: options.correlationId };
9172
8985
  const instruction = options.instruction;
9173
- const instructionEmpty = instruction.trim() === "";
8986
+ const instructionEmpty = instruction.length === 0;
9174
8987
  const placedExtra = options.placedFields === void 0 ? void 0 : await options.placedFields(placed);
9175
8988
  const admittedFields = {
9176
8989
  ...options.admittedFields ?? {},
@@ -9212,23 +9025,23 @@ function admittedTransportPromptKind(admitted) {
9212
9025
  if (record !== void 0 && "transportPrompt" in record) return record.transportPrompt;
9213
9026
  return "instruction";
9214
9027
  }
9215
- function buildInstructionTransportPrompt(admitted, engineMaterial) {
9028
+ function buildInstructionTransportPrompt(admitted) {
9216
9029
  const kind = admittedTransportPromptKind(admitted);
9217
9030
  if (kind === "fixed-kickoff") {
9218
9031
  if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
9219
9032
  throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
9220
9033
  }
9221
- return appendEngineSessionMaterial([admitted.sourceRunPath], engineMaterial).join("\n");
9034
+ return admitted.sourceRunPath;
9222
9035
  }
9223
9036
  if (kind === "baseline") {
9224
9037
  if (admitted.baseRevision === void 0) {
9225
9038
  throw new Error("baseline transport prompt is missing the bound revision");
9226
9039
  }
9227
9040
  const lines2 = [admitted.baseRevision];
9228
- if (!admitted.instructionEmpty) {
9041
+ if (admitted.instruction.length > 0) {
9229
9042
  lines2.push("", admitted.instruction);
9230
9043
  }
9231
- return appendEngineSessionMaterial(lines2, engineMaterial).join("\n");
9044
+ return lines2.join("\n");
9232
9045
  }
9233
9046
  if (kind === "skill-args") {
9234
9047
  if (admitted.baseRevision === void 0 || admitted.lens === void 0 || admitted.authorityRefs === void 0) {
@@ -9239,20 +9052,24 @@ function buildInstructionTransportPrompt(admitted, engineMaterial) {
9239
9052
  lens: admitted.lens,
9240
9053
  authorityRefs: admitted.authorityRefs
9241
9054
  })];
9242
- if (!admitted.instructionEmpty && admitted.instruction.trim() !== "") {
9055
+ if (admitted.instruction.length > 0) {
9243
9056
  lines2.push("", admitted.instruction);
9244
9057
  }
9245
- return appendEngineSessionMaterial(lines2, engineMaterial).join("\n");
9058
+ return lines2.join("\n");
9246
9059
  }
9247
- const lines = [admitted.instructionEmpty ? "" : admitted.instruction];
9248
- if (admitted.attachments.length > 0) {
9060
+ const lines = [admitted.instruction];
9061
+ const flaggedPaths = [
9062
+ ...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
9063
+ ...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`]
9064
+ ];
9065
+ if (flaggedPaths.length > 0) {
9249
9066
  lines.push("");
9250
- lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF08\u51BB\u7ED3\u5FEB\u7167\u8DEF\u5F84\uFF09\uFF1A");
9251
- for (const attachment of admitted.attachments) {
9252
- lines.push(`- ${attachment.frozenPath}`);
9067
+ lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
9068
+ for (const entry of flaggedPaths) {
9069
+ lines.push(`- ${entry}`);
9253
9070
  }
9254
9071
  }
9255
- return appendEngineSessionMaterial(lines, engineMaterial).join("\n");
9072
+ return lines.join("\n");
9256
9073
  }
9257
9074
  async function materializeCountersignInvocation(admitted, options) {
9258
9075
  const placed = await placeRoleAdmission({
@@ -9260,8 +9077,7 @@ async function materializeCountersignInvocation(admitted, options) {
9260
9077
  home: options.home,
9261
9078
  principalAuthority: options.principalAuthority,
9262
9079
  cwd: admitted.projectRoot,
9263
- attachmentPaths: [],
9264
- freezeAttachments: false,
9080
+ attachmentPaths: options.attachmentPaths,
9265
9081
  runId: admitted.runId,
9266
9082
  ...options.ticketNumber === void 0 ? {} : { assertedTicketNumber: options.ticketNumber }
9267
9083
  });
@@ -9272,11 +9088,7 @@ async function materializeCountersignInvocation(admitted, options) {
9272
9088
  if (ticketFields.ticketNumber !== void 0) {
9273
9089
  admitted.ticketNumber = ticketFields.ticketNumber;
9274
9090
  }
9275
- const attachments = await freezePreparedAttachmentsIntoRun(
9276
- options.preparedAttachments,
9277
- admitted.runDirectory
9278
- );
9279
- admitted.attachments = attachments;
9091
+ admitted.attachments = placement.attachments;
9280
9092
  writeAdmittedRequestPersistence(admitted.runDirectory, admitted, {
9281
9093
  sessionDirectory: placement.sessionDirectory,
9282
9094
  sessionFile: placement.sessionFile
@@ -9295,10 +9107,11 @@ async function loadAdmittedJudgeRequest(runDirectory) {
9295
9107
  if (typeof record.instruction !== "string") return void 0;
9296
9108
  if (typeof record.instructionEmpty !== "boolean") return void 0;
9297
9109
  if (!Array.isArray(record.attachments)) return void 0;
9110
+ const attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
9298
9111
  return {
9299
9112
  instruction: record.instruction,
9300
9113
  instructionEmpty: record.instructionEmpty,
9301
- attachments: record.attachments
9114
+ attachments
9302
9115
  };
9303
9116
  } catch {
9304
9117
  return void 0;
@@ -9533,7 +9346,7 @@ function parseAnalystArgv(args) {
9533
9346
  if (taken.def.id === "attach") {
9534
9347
  pushValue(
9535
9348
  "attach",
9536
- requireOptionPath(taken.def.canonical, taken.value)
9349
+ requireProvidedOptionValue(taken.def.canonical, taken.value)
9537
9350
  );
9538
9351
  return;
9539
9352
  }
@@ -9655,7 +9468,6 @@ var init_invocation = __esm({
9655
9468
  init_uuidv7();
9656
9469
  init_notary_contracts();
9657
9470
  init_notary_source_run();
9658
- init_engine_material();
9659
9471
  init_cli_errors();
9660
9472
  init_option_definitions();
9661
9473
  init_unknown_value();
@@ -10711,10 +10523,10 @@ function presentFailureTerminal(terminal, io) {
10711
10523
  }
10712
10524
  function defaultNavigatorGraceSleep() {
10713
10525
  let timer;
10714
- const sleep2 = ((ms) => new Promise((resolve22) => {
10526
+ const sleep2 = ((ms) => new Promise((resolve21) => {
10715
10527
  timer = setTimeout(() => {
10716
10528
  timer = void 0;
10717
- resolve22();
10529
+ resolve21();
10718
10530
  }, ms);
10719
10531
  }));
10720
10532
  sleep2.cancel = () => {
@@ -10726,7 +10538,7 @@ function defaultNavigatorGraceSleep() {
10726
10538
  return sleep2;
10727
10539
  }
10728
10540
  function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
10729
- return new Promise((resolve22, reject) => {
10541
+ return new Promise((resolve21, reject) => {
10730
10542
  let settled = false;
10731
10543
  const finish = (action) => {
10732
10544
  if (settled) return;
@@ -10735,11 +10547,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
10735
10547
  action();
10736
10548
  };
10737
10549
  void work.then(
10738
- (value) => finish(() => resolve22({ status: "done", value })),
10550
+ (value) => finish(() => resolve21({ status: "done", value })),
10739
10551
  (error) => finish(() => reject(error))
10740
10552
  );
10741
10553
  void sleep2(graceMs).then(() => {
10742
- finish(() => resolve22({ status: "timeout" }));
10554
+ finish(() => resolve21({ status: "timeout" }));
10743
10555
  });
10744
10556
  });
10745
10557
  }
@@ -11229,7 +11041,7 @@ var init_role_turn_host = __esm({
11229
11041
  });
11230
11042
 
11231
11043
  // src/public-cli/host-providers.ts
11232
- import { readFileSync as readFileSync2 } from "node:fs";
11044
+ import { readFileSync as readFileSync3 } from "node:fs";
11233
11045
  import { join as join18 } from "node:path";
11234
11046
  function hostProvidersPath(home) {
11235
11047
  if (typeof home !== "string" || home.trim() === "") {
@@ -11275,7 +11087,7 @@ function parseHostProvidersTable(value) {
11275
11087
  function loadHostProvidersTable(home) {
11276
11088
  const path = hostProvidersPath(home);
11277
11089
  try {
11278
- const raw = readFileSync2(path, "utf8");
11090
+ const raw = readFileSync3(path, "utf8");
11279
11091
  return parseHostProvidersTable(JSON.parse(raw));
11280
11092
  } catch (error) {
11281
11093
  if (isEnoent(error)) return {};
@@ -11291,7 +11103,7 @@ function listHermesProvidersForModel(home, seatModel) {
11291
11103
  const path = hermesProviderModelsCachePath(home);
11292
11104
  let text;
11293
11105
  try {
11294
- text = readFileSync2(path, "utf8");
11106
+ text = readFileSync3(path, "utf8");
11295
11107
  } catch (error) {
11296
11108
  if (isEnoent(error)) return [];
11297
11109
  throw error;
@@ -11589,7 +11401,7 @@ var init_role_seat_runtime = __esm({
11589
11401
  });
11590
11402
 
11591
11403
  // src/archivist-record-pointer.ts
11592
- import { basename as basename10, join as join21 } from "node:path";
11404
+ import { basename as basename9, join as join21 } from "node:path";
11593
11405
  function bookDirectOfficerRunPointer(options) {
11594
11406
  const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
11595
11407
  const pointer = {
@@ -11615,7 +11427,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
11615
11427
  let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
11616
11428
  let sessionFile = raw.sessionFile;
11617
11429
  const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
11618
- const leaf = parseRunLeaf(basename10(recordedRunDirectory));
11430
+ const leaf = parseRunLeaf(basename9(recordedRunDirectory));
11619
11431
  const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
11620
11432
  if (leaf !== void 0 && parentIdentity !== void 0) {
11621
11433
  const currentRunDirectory = await findRunDirectoryById(
@@ -11976,7 +11788,7 @@ var init_submission_gate = __esm({
11976
11788
 
11977
11789
  // src/session-opening-materials.ts
11978
11790
  import { existsSync as existsSync8 } from "node:fs";
11979
- import { readFile as readFile11 } from "node:fs/promises";
11791
+ import { readFile as readFile10 } from "node:fs/promises";
11980
11792
  import { dirname as dirname14, join as join22 } from "node:path";
11981
11793
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
11982
11794
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
@@ -11992,7 +11804,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
11992
11804
  return fileURLToPath(new URL("..", moduleUrl));
11993
11805
  }
11994
11806
  async function readPackageMaterial(relativePath) {
11995
- return readFile11(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
11807
+ return readFile10(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
11996
11808
  }
11997
11809
  async function joinPackageMaterials(relativePaths) {
11998
11810
  const chunks = [];
@@ -12050,7 +11862,7 @@ __export(auditor_soul_exports, {
12050
11862
  readAuditorResumeBinding: () => readAuditorResumeBinding,
12051
11863
  resolveAuditorSubject: () => resolveAuditorSubject
12052
11864
  });
12053
- import { basename as basename11 } from "node:path";
11865
+ import { basename as basename10 } from "node:path";
12054
11866
  function auditorSoulRelativePath(role) {
12055
11867
  return `souls/${role}-auditor.md`;
12056
11868
  }
@@ -12086,7 +11898,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
12086
11898
  return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
12087
11899
  }
12088
11900
  function subjectFromSourceDirectory(sourceRunDirectory) {
12089
- const role = parseRunLeaf(basename11(sourceRunDirectory))?.role;
11901
+ const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
12090
11902
  return isAuditorSoulRole(role) ? role : void 0;
12091
11903
  }
12092
11904
  async function readAuditorResumeBinding(runDirectory) {
@@ -12126,7 +11938,7 @@ var init_auditor_soul = __esm({
12126
11938
 
12127
11939
  // src/public-cli/machine-method-skills.ts
12128
11940
  import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
12129
- import { lstat as lstat3, mkdir as mkdir2, symlink } from "node:fs/promises";
11941
+ import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
12130
11942
  import { join as join24 } from "node:path";
12131
11943
  import { spawnSync as spawnSync2 } from "node:child_process";
12132
11944
  function skillRoot(home) {
@@ -12156,7 +11968,7 @@ function linkedSkillRoot(home, host) {
12156
11968
  }
12157
11969
  async function occupied(path) {
12158
11970
  try {
12159
- await lstat3(path);
11971
+ await lstat2(path);
12160
11972
  return true;
12161
11973
  } catch (error) {
12162
11974
  if (error.code !== "ENOENT") throw error;
@@ -12653,7 +12465,6 @@ var init_auto_resume = __esm({
12653
12465
 
12654
12466
  // src/public-cli/post-admission.ts
12655
12467
  import { randomUUID as randomUUID6 } from "node:crypto";
12656
- import { isAbsolute as isAbsolute7, join as join25, resolve as resolve13 } from "node:path";
12657
12468
  function describeCaughtError(error) {
12658
12469
  if (error instanceof Error) {
12659
12470
  const code = error.code;
@@ -12675,7 +12486,7 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
12675
12486
  mutableRequest.principal = admitted.principal;
12676
12487
  const activation = mutableRequest.activation;
12677
12488
  if (isRecord(activation)) {
12678
- for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath", "requestManifestPath"]) {
12489
+ for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath"]) {
12679
12490
  const record = activation;
12680
12491
  if (field in record) record[field] = rewrite(record[field]);
12681
12492
  }
@@ -13408,7 +13219,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
13408
13219
  prompt = request.message;
13409
13220
  }
13410
13221
  } else if (summonsPrepared !== void 0) {
13411
- prompt = officerDialogue ? summonsPrepared.instructionEmpty ? "" : summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
13222
+ prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
13412
13223
  } else if (request.summons !== void 0) {
13413
13224
  prompt = "";
13414
13225
  } else {
@@ -13489,24 +13300,14 @@ async function runSettledAutoResumeLoop(input) {
13489
13300
  })
13490
13301
  });
13491
13302
  }
13492
- function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
13493
- const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
13494
- return pathContainedIn(join25(runDirectory, "attachments"), absolute);
13495
- }
13496
- async function prepareSummonsResumeMaterials(runDirectory, summons) {
13303
+ async function prepareSummonsResumeMaterials(_runDirectory, summons) {
13497
13304
  if (summons === void 0) return void 0;
13498
13305
  if (summons.instruction === void 0 && (summons.attachmentPaths?.length ?? 0) === 0) {
13499
13306
  return void 0;
13500
13307
  }
13501
13308
  const instruction = summons.instruction ?? "";
13502
- const instructionEmpty = summons.instructionEmpty ?? instruction.trim() === "";
13503
- let attachments = [];
13504
- if (summons.attachmentPaths !== void 0 && summons.attachmentPaths.length > 0) {
13505
- const alreadyFrozen = summons.attachmentPaths.every(
13506
- (path) => isAlreadyFrozenSummonsAttachment(runDirectory, path)
13507
- );
13508
- attachments = alreadyFrozen ? summons.attachmentPaths.map((frozenPath) => ({ frozenPath })) : await freezeAttachmentsIntoRun(summons.attachmentPaths, runDirectory);
13509
- }
13309
+ const instructionEmpty = summons.instructionEmpty ?? instruction.length === 0;
13310
+ const attachments = (summons.attachmentPaths ?? []).map((path) => ({ path }));
13510
13311
  return { instruction, instructionEmpty, attachments };
13511
13312
  }
13512
13313
  async function runPostAdmissionSeatResume(input) {
@@ -13555,23 +13356,6 @@ async function runPostAdmissionSeatResume(input) {
13555
13356
  openCourtAttemptId = openCourt.courtAttemptId;
13556
13357
  }
13557
13358
  }
13558
- if (request.summons !== void 0) {
13559
- const prepared = await prepareSummonsResumeMaterials(
13560
- admittedForBuild.runDirectory,
13561
- request.summons
13562
- );
13563
- if (prepared !== void 0 && (request.summons.attachmentPaths?.length ?? 0) > 0) {
13564
- request = {
13565
- ...request,
13566
- summons: {
13567
- ...request.summons,
13568
- attachmentPaths: prepared.attachments.map(
13569
- (attachment) => attachment.frozenPath
13570
- )
13571
- }
13572
- };
13573
- }
13574
- }
13575
13359
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
13576
13360
  if (turnRequest.continuation.kind === "resume" && turnRequest.continuation.hostSessionId === void 0) {
13577
13361
  const hostSessionId = await readStoredHostSessionId(
@@ -13738,13 +13522,7 @@ async function runPostAdmissionOneShot(input) {
13738
13522
  ...input.request,
13739
13523
  continuation: {
13740
13524
  kind: "resume",
13741
- prompt: buildAutoResumeContinuationPrompt({
13742
- packageRoot: input.env.packageRoot,
13743
- ...pickEngineAxis({
13744
- engine: input.effectiveEngine ?? input.env.engine,
13745
- engineModel: input.env.engineModel
13746
- })
13747
- })
13525
+ prompt: buildAutoResumeContinuationPrompt()
13748
13526
  }
13749
13527
  }),
13750
13528
  adapters: input.adapters,
@@ -13827,8 +13605,6 @@ var init_post_admission = __esm({
13827
13605
  init_invocation();
13828
13606
  init_submission_ledger();
13829
13607
  init_run_ticket_number();
13830
- init_activation_ledger_topology();
13831
- init_engine_material();
13832
13608
  init_session_identity();
13833
13609
  init_sitian_facade();
13834
13610
  init_receipt_delivery_policy();
@@ -13968,7 +13744,7 @@ __export(instruction_seat_run_exports, {
13968
13744
  runPublicInstructionSeat: () => runPublicInstructionSeat,
13969
13745
  runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
13970
13746
  });
13971
- import { dirname as dirname15, resolve as resolve14 } from "node:path";
13747
+ import { dirname as dirname15, resolve as resolve13 } from "node:path";
13972
13748
  function unreadablePostSubmissionStatus(admitted, terminal) {
13973
13749
  if (terminal?.roleOutcome.kind !== "accepted") return void 0;
13974
13750
  const route = POST_SUBMISSION_ROUTING[admitted.role];
@@ -14059,13 +13835,7 @@ function initialPrompt(admitted, env) {
14059
13835
  if (reask !== void 0 && "reaskPrompt" in record && record.reaskPrompt === true) {
14060
13836
  return reask;
14061
13837
  }
14062
- return buildInstructionTransportPrompt(
14063
- admitted,
14064
- engineSessionMaterialFromOptions({
14065
- ...pickEngineAxis(env),
14066
- packageRoot: env.packageRoot
14067
- })
14068
- );
13838
+ return buildInstructionTransportPrompt(admitted);
14069
13839
  }
14070
13840
  function isBoardTicketSeat(seat) {
14071
13841
  return packagedBindsBoardTicket(seat.role);
@@ -14159,10 +13929,7 @@ async function dispatchAdmitted(admitted, env, io) {
14159
13929
  admitted,
14160
13930
  roleTurnOptions(activeEnv, admitted, {
14161
13931
  kind: "resume",
14162
- prompt: buildAutoResumeContinuationPrompt({
14163
- packageRoot: activeEnv.packageRoot,
14164
- ...pickEngineAxis(activeEnv)
14165
- })
13932
+ prompt: buildAutoResumeContinuationPrompt()
14166
13933
  })
14167
13934
  ),
14168
13935
  adapters,
@@ -14205,7 +13972,7 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
14205
13972
  const children = await summonParallelReviewerLenses2({
14206
13973
  argv,
14207
13974
  cwd: env.cwd,
14208
- projectRoot: resolve14(parsed.project ?? env.cwd),
13975
+ projectRoot: resolve13(parsed.project ?? env.cwd),
14209
13976
  baseRevision: parsed.baseRevision ?? "",
14210
13977
  home: env.home,
14211
13978
  agentDir: env.agentDir,
@@ -14287,14 +14054,14 @@ async function runCountersignBody(parsed, env, io) {
14287
14054
  const resumed = await resumeSameParentInstructionSeat({
14288
14055
  env,
14289
14056
  io,
14290
- projectRoot: resolve14(parsed.project ?? env.cwd),
14057
+ projectRoot: resolve13(parsed.project ?? env.cwd),
14291
14058
  role: "countersign",
14292
14059
  parentRunPath: gateParentRunPath,
14293
14060
  ...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
14294
14061
  summons: {
14295
14062
  sourceRunPath: gateParentRunPath,
14296
14063
  instruction: resumeInstruction,
14297
- instructionEmpty: resumeInstruction.trim() === ""
14064
+ instructionEmpty: resumeInstruction.length === 0
14298
14065
  }
14299
14066
  });
14300
14067
  if (resumed != null) return resumed;
@@ -14308,12 +14075,12 @@ async function runCountersignBody(parsed, env, io) {
14308
14075
  throw error;
14309
14076
  }
14310
14077
  try {
14311
- return await withPreparedAttachments(parsed.attachmentPaths ?? [], async (preparedAttachments) => {
14078
+ {
14312
14079
  const materializeAdmission = async (ticketNumber) => {
14313
14080
  await materializeCountersignInvocation(admitted, {
14314
14081
  home: env.home,
14315
14082
  principalAuthority: env.principalAuthority,
14316
- preparedAttachments,
14083
+ attachmentPaths: parsed.attachmentPaths ?? [],
14317
14084
  ...env.model === void 0 ? {} : { model: env.model },
14318
14085
  ...ticketNumber === void 0 ? {} : { ticketNumber }
14319
14086
  });
@@ -14328,13 +14095,7 @@ async function runCountersignBody(parsed, env, io) {
14328
14095
  }
14329
14096
  const turnProjection = roleTurnOptions(env, admitted, {
14330
14097
  kind: "initial",
14331
- prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(
14332
- admitted,
14333
- engineSessionMaterialFromOptions({
14334
- ...pickEngineAxis(env),
14335
- packageRoot: env.packageRoot
14336
- })
14337
- )
14098
+ prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(admitted)
14338
14099
  });
14339
14100
  const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
14340
14101
  const result = await runPostAdmissionOneShot({
@@ -14354,7 +14115,7 @@ async function runCountersignBody(parsed, env, io) {
14354
14115
  });
14355
14116
  await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
14356
14117
  return result;
14357
- });
14118
+ }
14358
14119
  } catch (error) {
14359
14120
  const rejected = usageExit(error, io);
14360
14121
  if (rejected !== void 0) return rejected;
@@ -14419,7 +14180,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14419
14180
  const summons = {
14420
14181
  ...sameParentInstruction(env, {
14421
14182
  instruction: parsed.instruction ?? "",
14422
- instructionEmpty: (parsed.instruction ?? "").trim() === ""
14183
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14423
14184
  }),
14424
14185
  attachmentPaths: parsed.attachmentPaths ?? []
14425
14186
  };
@@ -14444,7 +14205,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14444
14205
  sourceRunPath: parentRunPath,
14445
14206
  ...sameParentInstruction(env, {
14446
14207
  instruction: parsed.instruction ?? "",
14447
- instructionEmpty: (parsed.instruction ?? "").trim() === ""
14208
+ instructionEmpty: (parsed.instruction ?? "").length === 0
14448
14209
  }),
14449
14210
  attachmentPaths: parsed.attachmentPaths ?? []
14450
14211
  };
@@ -14528,7 +14289,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
14528
14289
  instruction: parsed.instruction ?? "",
14529
14290
  projectRoot: admitted.projectRoot,
14530
14291
  failureLabel: "secretariat unbound summons",
14531
- attachmentPaths: admitted.attachments.map((attachment) => attachment.frozenPath),
14292
+ attachmentPaths: admitted.attachments.map((attachment) => attachment.path),
14532
14293
  correlationId: admitted.runId
14533
14294
  }, env, io);
14534
14295
  } catch (error) {
@@ -15031,7 +14792,6 @@ var init_instruction_seat_run = __esm({
15031
14792
  init_submission_gate();
15032
14793
  init_run_ticket_number();
15033
14794
  init_notary_source_run();
15034
- init_engine_material();
15035
14795
  init_packaged_role_registry();
15036
14796
  init_auditor_soul();
15037
14797
  init_cli_errors();
@@ -15088,7 +14848,7 @@ var init_instruction_seat_run = __esm({
15088
14848
 
15089
14849
  // src/analyst-book-key.ts
15090
14850
  import { statSync as statSync6 } from "node:fs";
15091
- import { isAbsolute as isAbsolute8 } from "node:path";
14851
+ import { isAbsolute as isAbsolute7 } from "node:path";
15092
14852
  function resolveAnalystBookKey(projectRoot) {
15093
14853
  const identity = physicalPathIdentity(projectRoot);
15094
14854
  let stats;
@@ -15110,7 +14870,7 @@ function resolveAnalystBookKey(projectRoot) {
15110
14870
  }
15111
14871
  }
15112
14872
  function isSyntheticAnalystBookKey(bookKey) {
15113
- return bookKey.startsWith("root:") && isAbsolute8(bookKey.slice("root:".length));
14873
+ return bookKey.startsWith("root:") && isAbsolute7(bookKey.slice("root:".length));
15114
14874
  }
15115
14875
  var init_analyst_book_key = __esm({
15116
14876
  "src/analyst-book-key.ts"() {
@@ -15121,13 +14881,13 @@ var init_analyst_book_key = __esm({
15121
14881
  });
15122
14882
 
15123
14883
  // src/analyst-index.ts
15124
- import { open, readFile as readFile12, unlink } from "node:fs/promises";
15125
- import { dirname as dirname16, join as join26 } from "node:path";
14884
+ import { open, readFile as readFile11, unlink } from "node:fs/promises";
14885
+ import { dirname as dirname16, join as join25 } from "node:path";
15126
14886
  import { setTimeout as sleep } from "node:timers/promises";
15127
14887
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
15128
14888
  const indexPath = analystLibraryIndexPath(ledgerHome);
15129
14889
  ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
15130
- const lockPath = join26(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
14890
+ const lockPath = join25(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
15131
14891
  assertLedgerFileInsideHome(lockPath, ledgerHome);
15132
14892
  const startedAt = Date.now();
15133
14893
  while (true) {
@@ -15154,7 +14914,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
15154
14914
  }
15155
14915
  }
15156
14916
  function analystLibraryIndexPath(ledgerHome) {
15157
- return join26(ledgerHome, "analyst", "library-index.json");
14917
+ return join25(ledgerHome, "analyst", "library-index.json");
15158
14918
  }
15159
14919
  function rowFromIssueMetricsPage(page) {
15160
14920
  return {
@@ -15245,7 +15005,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
15245
15005
  const path = analystLibraryIndexPath(ledgerHome);
15246
15006
  let raw;
15247
15007
  try {
15248
- raw = await readFile12(path, "utf8");
15008
+ raw = await readFile11(path, "utf8");
15249
15009
  } catch (error) {
15250
15010
  if (isMissingPathError(error)) return void 0;
15251
15011
  throw error;
@@ -15700,7 +15460,7 @@ var init_analyst_gate_cycles_read = __esm({
15700
15460
 
15701
15461
  // src/analyst-ledger.ts
15702
15462
  import { readdir as readdir3 } from "node:fs/promises";
15703
- import { basename as basename12, join as join27 } from "node:path";
15463
+ import { basename as basename11, join as join26 } from "node:path";
15704
15464
  async function readExistingRunLifecycleState(runDirectory) {
15705
15465
  return (await readRoleRunIdentity(runDirectory))?.state;
15706
15466
  }
@@ -15720,7 +15480,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
15720
15480
  }
15721
15481
  }
15722
15482
  async function classifyGhostCandidate(input) {
15723
- const autopsy = await autopsyWriterLock(join27(input.runDirectory, "writer.lock"));
15483
+ const autopsy = await autopsyWriterLock(join26(input.runDirectory, "writer.lock"));
15724
15484
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
15725
15485
  if (leaseCheck === void 0) return { kind: "live" };
15726
15486
  return {
@@ -16010,7 +15770,7 @@ async function classifyScopedRun(input) {
16010
15770
  async function scanAnalystIssueRuns(input) {
16011
15771
  const ledgerHome = resolveActivationLedgerHome(input.home);
16012
15772
  const scopeTicketNumber = input.ticketNumber;
16013
- const booksRoot = join27(ledgerHome, "books");
15773
+ const booksRoot = join26(ledgerHome, "books");
16014
15774
  let wholeBook = false;
16015
15775
  let scopeRootIdentity;
16016
15776
  let bookNames;
@@ -16043,7 +15803,7 @@ async function scanAnalystIssueRuns(input) {
16043
15803
  const ghostLegs = [];
16044
15804
  const scopeConflicts = [];
16045
15805
  for (const book of bookNames) {
16046
- const bookDir = join27(booksRoot, book);
15806
+ const bookDir = join26(booksRoot, book);
16047
15807
  let runDirectories;
16048
15808
  try {
16049
15809
  runDirectories = await listBookRunDirectories(bookDir);
@@ -16052,7 +15812,7 @@ async function scanAnalystIssueRuns(input) {
16052
15812
  throw error;
16053
15813
  }
16054
15814
  for (const runDirectory of runDirectories) {
16055
- const runName = basename12(runDirectory);
15815
+ const runName = basename11(runDirectory);
16056
15816
  const parsed = parseRunLeaf(runName);
16057
15817
  if (parsed === void 0) continue;
16058
15818
  let scopeFields;
@@ -16789,7 +16549,7 @@ var init_analyst_metric_family = __esm({
16789
16549
  });
16790
16550
 
16791
16551
  // src/analyst-page.ts
16792
- import { dirname as dirname17, join as join28 } from "node:path";
16552
+ import { dirname as dirname17, join as join27 } from "node:path";
16793
16553
  function analystIssuePageKey(address) {
16794
16554
  const parts = ["book", address.bookKey];
16795
16555
  if (address.issueNumber !== void 0) {
@@ -16800,7 +16560,7 @@ function analystIssuePageKey(address) {
16800
16560
  return sha256Hex(parts.join("\0")).slice(0, 32);
16801
16561
  }
16802
16562
  function analystIssuePagePath(ledgerHome, address) {
16803
- return join28(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16563
+ return join27(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
16804
16564
  }
16805
16565
  function analystIssuePageAddressFromPage(page) {
16806
16566
  return {
@@ -17036,7 +16796,7 @@ var init_analyst_model_groups = __esm({
17036
16796
  });
17037
16797
 
17038
16798
  // src/analyst-entry.ts
17039
- import { readFile as readFile14 } from "node:fs/promises";
16799
+ import { readFile as readFile13 } from "node:fs/promises";
17040
16800
  import { Type as Type18 } from "typebox";
17041
16801
  function cachedPageMatchesRequestedScope(page, input) {
17042
16802
  if (page.bookKey !== input.bookKey) return false;
@@ -17064,7 +16824,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
17064
16824
  ...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
17065
16825
  });
17066
16826
  try {
17067
- const raw = await readFile14(pagePath, "utf8");
16827
+ const raw = await readFile13(pagePath, "utf8");
17068
16828
  const page = JSON.parse(raw);
17069
16829
  if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
17070
16830
  const ghostScan = await scanAnalystIssueRuns({
@@ -17165,7 +16925,7 @@ async function runAnalystModelGroupsMode(input, home) {
17165
16925
  scopeRootIdentity: projectRoot
17166
16926
  });
17167
16927
  try {
17168
- const raw = await readFile14(pagePath, "utf8");
16928
+ const raw = await readFile13(pagePath, "utf8");
17169
16929
  JSON.parse(raw);
17170
16930
  } catch (error) {
17171
16931
  if (!isMissingPathError(error)) {
@@ -17262,8 +17022,8 @@ var init_analyst_entry = __esm({
17262
17022
  });
17263
17023
 
17264
17024
  // src/public-cli/analyst-run.ts
17265
- import { readFile as readFile15 } from "node:fs/promises";
17266
- import { isAbsolute as isAbsolute9, resolve as resolve15 } from "node:path";
17025
+ import { readFile as readFile14 } from "node:fs/promises";
17026
+ import { isAbsolute as isAbsolute8, resolve as resolve14 } from "node:path";
17267
17027
  import { Value as Value3 } from "typebox/value";
17268
17028
  function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
17269
17029
  try {
@@ -17313,10 +17073,10 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
17313
17073
  );
17314
17074
  }
17315
17075
  const sourcePath = attachmentPaths[0];
17316
- const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve15(sourcePath);
17076
+ const absolute = isAbsolute8(sourcePath) ? sourcePath : resolve14(sourcePath);
17317
17077
  let bytes;
17318
17078
  try {
17319
- bytes = await readFile15(absolute);
17079
+ bytes = await readFile14(absolute);
17320
17080
  } catch (error) {
17321
17081
  throw new CliUsageError(
17322
17082
  `analyst sweep attachment is not a readable regular file: ${sourcePath}`,
@@ -18346,7 +18106,7 @@ __export(public_role_summons_exports, {
18346
18106
  import { execFile as execFile3 } from "node:child_process";
18347
18107
  import { existsSync as existsSync9 } from "node:fs";
18348
18108
  import { realpath as realpath6 } from "node:fs/promises";
18349
- import { join as join29 } from "node:path";
18109
+ import { join as join28 } from "node:path";
18350
18110
  import { promisify as promisify3 } from "node:util";
18351
18111
  function createCapturingIo() {
18352
18112
  const chunks = [];
@@ -18370,7 +18130,7 @@ function parentDir(path) {
18370
18130
  function walkPackageRoot(start) {
18371
18131
  let dir = start;
18372
18132
  for (let i = 0; i < 12; i += 1) {
18373
- if (existsSync9(join29(dir, "package.json")) && existsSync9(join29(dir, "souls"))) {
18133
+ if (existsSync9(join28(dir, "package.json")) && existsSync9(join28(dir, "souls"))) {
18374
18134
  return dir;
18375
18135
  }
18376
18136
  const parent = parentDir(dir);
@@ -18590,7 +18350,7 @@ async function summonPublicRole(options) {
18590
18350
  runId: resumeRunId,
18591
18351
  summons: {
18592
18352
  instruction,
18593
- instructionEmpty: instruction.trim() === ""
18353
+ instructionEmpty: instruction.length === 0
18594
18354
  }
18595
18355
  },
18596
18356
  env,
@@ -18979,7 +18739,7 @@ var init_compliance_transport = __esm({
18979
18739
  });
18980
18740
 
18981
18741
  // src/role-run-relocation.ts
18982
- import { dirname as dirname18, join as join30, sep as sep4 } from "node:path";
18742
+ import { dirname as dirname18, join as join29, sep as sep4 } from "node:path";
18983
18743
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
18984
18744
  if (typeof value !== "string") return value;
18985
18745
  if (value === oldRunDirectory) return newRunDirectory;
@@ -19059,13 +18819,6 @@ function rewriteSourceRunLocator(value, rewrites) {
19059
18819
  function rewriteAdmittedRoleRunPage(page, rewrites) {
19060
18820
  rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
19061
18821
  rewriteSourceRunLocator(page.sourceRun, rewrites);
19062
- if (Array.isArray(page.attachments)) {
19063
- for (const attachment of page.attachments) {
19064
- if (isRecord(attachment)) {
19065
- rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
19066
- }
19067
- }
19068
- }
19069
18822
  if (isRecord(page.principal)) {
19070
18823
  rewriteRunDirectoryPathFieldsAgainstRewrites(
19071
18824
  page.principal,
@@ -19093,7 +18846,7 @@ var init_role_run_relocation = __esm({
19093
18846
  "taskPath",
19094
18847
  "packetPath",
19095
18848
  "prerequisitesPath",
19096
- "requestManifestPath",
18849
+ // #1165: requestManifestPath is a caller path — never rewrite.
19097
18850
  "mergerInputPath",
19098
18851
  "sourceRunPath"
19099
18852
  ];
@@ -19128,16 +18881,10 @@ __export(run_lifecycle_exports, {
19128
18881
  recordCurrentCourt: () => recordCurrentCourt,
19129
18882
  writeRoleRunState: () => writeRoleRunState
19130
18883
  });
19131
- import { chmod, lstat as lstat4, open as open2, readdir as readdir4, readFile as readFile16, unlink as unlink2 } from "node:fs/promises";
19132
- import { basename as basename13, join as join31 } from "node:path";
19133
- function buildAutoResumeContinuationPrompt(options) {
19134
- return appendEngineSessionMaterial(
19135
- [RESUME_TRANSPORT_ENVELOPE],
19136
- engineSessionMaterialFromOptions({
19137
- packageRoot: options.packageRoot,
19138
- ...pickEngineAxis(options)
19139
- })
19140
- ).join("\n");
18884
+ import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile15, unlink as unlink2 } from "node:fs/promises";
18885
+ import { basename as basename12, join as join30 } from "node:path";
18886
+ function buildAutoResumeContinuationPrompt() {
18887
+ return RESUME_TRANSPORT_ENVELOPE;
19141
18888
  }
19142
18889
  async function writeRoleRunState(runDirectory, record) {
19143
18890
  const payload = { ...record, runDirectory };
@@ -19148,7 +18895,7 @@ function parseSameTicketSummonsMaterials(raw) {
19148
18895
  const record = raw;
19149
18896
  const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
19150
18897
  const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
19151
- const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string" && p.length > 0) : void 0;
18898
+ const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string") : void 0;
19152
18899
  const sourceRunPath = typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "" ? record.sourceRunPath : void 0;
19153
18900
  let sourceRun;
19154
18901
  if (isRecord(record.sourceRun)) {
@@ -19373,7 +19120,7 @@ function isProcessAlive(pid) {
19373
19120
  async function autopsyWriterLock(lockPath) {
19374
19121
  let content;
19375
19122
  try {
19376
- content = await readFile16(lockPath, "utf8");
19123
+ content = await readFile15(lockPath, "utf8");
19377
19124
  } catch (error) {
19378
19125
  if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
19379
19126
  return { verdict: "unknown", reason: "unreadable", readFailure: error };
@@ -19432,7 +19179,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
19432
19179
  },
19433
19180
  relocate(nextRunDirectory) {
19434
19181
  currentRunDirectory = nextRunDirectory;
19435
- currentLockPath = join31(nextRunDirectory, WRITER_LOCK_FILE);
19182
+ currentLockPath = join30(nextRunDirectory, WRITER_LOCK_FILE);
19436
19183
  },
19437
19184
  async release() {
19438
19185
  if (released) return;
@@ -19471,10 +19218,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19471
19218
  };
19472
19219
  const reportReadFailure = (error) => {
19473
19220
  reportDiagnostic(
19474
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join31(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
19221
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join30(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
19475
19222
  );
19476
19223
  };
19477
- const lockPath = join31(runDirectory, WRITER_LOCK_FILE);
19224
+ const lockPath = join30(runDirectory, WRITER_LOCK_FILE);
19478
19225
  let lastAutopsy = { verdict: "absent" };
19479
19226
  let lastReclaimFailure;
19480
19227
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -19531,7 +19278,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19531
19278
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
19532
19279
  if (runId.trim() === "") return void 0;
19533
19280
  const ledgerHome = resolveActivationLedgerHome(home);
19534
- const booksRoot = join31(ledgerHome, "books");
19281
+ const booksRoot = join30(ledgerHome, "books");
19535
19282
  let bookKeys;
19536
19283
  try {
19537
19284
  bookKeys = await readdir4(booksRoot);
@@ -19566,7 +19313,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
19566
19313
  if (disk === void 0) return false;
19567
19314
  const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : sessionFileIn(disk.principalWire.sessionDirectory);
19568
19315
  try {
19569
- const stat2 = await lstat4(sessionFile);
19316
+ const stat2 = await lstat3(sessionFile);
19570
19317
  return stat2.isFile() && !stat2.isSymbolicLink();
19571
19318
  } catch (error) {
19572
19319
  if (errorCodeOf(error) === "ENOENT") return false;
@@ -19582,7 +19329,7 @@ async function findLatestRunIdForSeatTicket(input) {
19582
19329
  let runDirectories;
19583
19330
  try {
19584
19331
  runDirectories = await listBookRunDirectories(
19585
- input.ticketNumber === void 0 ? bookDir : join31(bookDir, String(input.ticketNumber))
19332
+ input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
19586
19333
  );
19587
19334
  } catch (error) {
19588
19335
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -19590,7 +19337,7 @@ async function findLatestRunIdForSeatTicket(input) {
19590
19337
  }
19591
19338
  let best;
19592
19339
  for (const runDirectory of runDirectories) {
19593
- const parsed = parseRunLeaf(basename13(runDirectory));
19340
+ const parsed = parseRunLeaf(basename12(runDirectory));
19594
19341
  if (parsed === void 0 || parsed.role !== input.role) continue;
19595
19342
  const runId = parsed.runId;
19596
19343
  const parentPath = await readRunParentPath(runDirectory);
@@ -19647,7 +19394,6 @@ async function loadResumableRunRecord(home, runId, authority) {
19647
19394
  let repository;
19648
19395
  let repositoryDisplay;
19649
19396
  let requestManifestPath;
19650
- let manifestDigest;
19651
19397
  let waitWindowMs;
19652
19398
  let issueNumber;
19653
19399
  let caseRunsPath;
@@ -19670,7 +19416,7 @@ async function loadResumableRunRecord(home, runId, authority) {
19670
19416
  instructionEmpty = record.instructionEmpty;
19671
19417
  }
19672
19418
  if (Array.isArray(record.attachments)) {
19673
- attachments = record.attachments;
19419
+ attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
19674
19420
  }
19675
19421
  if (record.phase === "plan" || record.phase === "apply") {
19676
19422
  phase = record.phase;
@@ -19702,12 +19448,9 @@ async function loadResumableRunRecord(home, runId, authority) {
19702
19448
  if (typeof record.repositoryDisplay === "string" && record.repositoryDisplay.trim() !== "") {
19703
19449
  repositoryDisplay = record.repositoryDisplay;
19704
19450
  }
19705
- if (typeof record.requestManifestPath === "string" && record.requestManifestPath.trim() !== "") {
19451
+ if (typeof record.requestManifestPath === "string") {
19706
19452
  requestManifestPath = record.requestManifestPath;
19707
19453
  }
19708
- if (typeof record.manifestDigest === "string" && record.manifestDigest.trim() !== "") {
19709
- manifestDigest = record.manifestDigest;
19710
- }
19711
19454
  if (typeof record.waitWindowMs === "number" && Number.isSafeInteger(record.waitWindowMs) && record.waitWindowMs >= 1) {
19712
19455
  waitWindowMs = record.waitWindowMs;
19713
19456
  }
@@ -19801,7 +19544,7 @@ async function loadResumableRunRecord(home, runId, authority) {
19801
19544
  );
19802
19545
  }
19803
19546
  }
19804
- const sourceRunLeaf = parseRunLeaf(basename13(sourceRunPath ?? ""));
19547
+ const sourceRunLeaf = parseRunLeaf(basename12(sourceRunPath ?? ""));
19805
19548
  const referencedRunId = sourceRun?.runId ?? sourceRunLeaf?.runId;
19806
19549
  const referencedRole = sourceRun?.role ?? sourceRunLeaf?.role;
19807
19550
  if (referencedRunId !== void 0 && referencedRunId !== "") {
@@ -19841,7 +19584,6 @@ async function loadResumableRunRecord(home, runId, authority) {
19841
19584
  ...repository === void 0 ? {} : { repository },
19842
19585
  ...repositoryDisplay === void 0 ? {} : { repositoryDisplay },
19843
19586
  ...requestManifestPath === void 0 ? {} : { requestManifestPath },
19844
- ...manifestDigest === void 0 ? {} : { manifestDigest },
19845
19587
  ...waitWindowMs === void 0 ? {} : { waitWindowMs },
19846
19588
  ...issueNumber === void 0 ? {} : { issueNumber },
19847
19589
  ...caseRunsPath === void 0 ? {} : { caseRunsPath },
@@ -20031,8 +19773,8 @@ function admitResumedRole(loaded) {
20031
19773
  return admitted;
20032
19774
  }
20033
19775
  case "collect-target": {
20034
- const { prNumber, repository, repositoryDisplay, manifestDigest } = fields;
20035
- if (repository === void 0 || repositoryDisplay === void 0 || manifestDigest === void 0) {
19776
+ const { prNumber, repository, repositoryDisplay } = fields;
19777
+ if (repository === void 0 || repositoryDisplay === void 0) {
20036
19778
  throw new CliUsageError(
20037
19779
  `role run admitted collector repository identity is missing: ${runId}`
20038
19780
  );
@@ -20055,8 +19797,7 @@ function admitResumedRole(loaded) {
20055
19797
  ...prNumber === void 0 ? {} : { prNumber },
20056
19798
  repository: parsedRepository,
20057
19799
  ...fields.requestManifestPath === void 0 ? {} : { requestManifestPath: fields.requestManifestPath },
20058
- ...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs },
20059
- manifestDigest
19800
+ ...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
20060
19801
  };
20061
19802
  return admitted;
20062
19803
  }
@@ -20111,7 +19852,6 @@ var init_run_lifecycle = __esm({
20111
19852
  init_cli_errors();
20112
19853
  init_collector_config();
20113
19854
  init_role_run_relocation();
20114
- init_engine_material();
20115
19855
  init_packaged_role_registry();
20116
19856
  init_invocation();
20117
19857
  init_run_dossier();
@@ -20140,7 +19880,7 @@ var init_run_lifecycle = __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 realpathSync3,
20226
19966
  statSync as statSync7,
20227
19967
  writeFileSync as writeFileSync2
20228
19968
  } from "node:fs";
20229
- import { dirname as dirname19, resolve as resolve16, join as join33 } from "node:path";
19969
+ import { dirname as dirname19, resolve as resolve15, 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 = resolve16(sessionDir);
20337
- const absoluteCwd = resolve16(cwd);
20076
+ const absoluteSessionDir = resolve15(sessionDir);
20077
+ const absoluteCwd = resolve15(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 = statSync7(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 (resolve16(header.cwd) !== absoluteCwd) continue;
20112
+ if (resolve15(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 = resolve16(sessionDir);
20403
- const absoluteFile = resolve16(recentFile);
20142
+ const absoluteSessionDir = resolve15(sessionDir);
20143
+ const absoluteFile = resolve15(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 = resolve16(parentFile);
20198
+ const parentResolved = resolve15(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
  }
@@ -20527,21 +20267,21 @@ init_host_descriptions();
20527
20267
  import { randomUUID as randomUUID10 } from "node:crypto";
20528
20268
 
20529
20269
  // src/role-runtime-dependencies.ts
20530
- import { readFile as readFile18 } from "node:fs/promises";
20270
+ import { readFile as readFile17 } from "node:fs/promises";
20531
20271
  init_doctor_evidence();
20532
20272
 
20533
20273
  // src/navigator-attendance.ts
20534
20274
  init_navigator_invocation_identity();
20535
20275
  init_packaged_role_registry();
20536
20276
  init_activation_ledger_topology();
20537
- import { resolve as resolve17 } from "node:path";
20277
+ import { resolve as resolve16 } from "node:path";
20538
20278
  import "@earendil-works/pi-coding-agent";
20539
20279
  import { Type as Type19 } from "typebox";
20540
20280
 
20541
20281
  // src/navigator-public-session.ts
20542
20282
  init_host_session_record();
20543
20283
  import { existsSync as existsSync12 } from "node:fs";
20544
- import { basename as basename14 } from "node:path";
20284
+ import { basename as basename13 } from "node:path";
20545
20285
 
20546
20286
  // src/navigator-session-contracts.ts
20547
20287
  init_unknown_value();
@@ -20851,7 +20591,7 @@ async function resolveNavigatorLedgerHome(context) {
20851
20591
  }
20852
20592
  var NAVIGATOR_HOST_RUN_POINTER_ENTRY = "ak-navigator-host-run";
20853
20593
  function runIdFromNavigatorDirectory(runDirectory) {
20854
- const parsed = parseRunLeaf(basename14(runDirectory));
20594
+ const parsed = parseRunLeaf(basename13(runDirectory));
20855
20595
  if (parsed === void 0 || parsed.role !== "navigator") return void 0;
20856
20596
  return parsed.runId;
20857
20597
  }
@@ -21088,7 +20828,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
21088
20828
  }
21089
20829
  function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
21090
20830
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
21091
- const resolvedReference = resolve17(cwd, reference);
20831
+ const resolvedReference = resolve16(cwd, reference);
21092
20832
  const marker = "/runs/";
21093
20833
  if (resolvedReference.includes(marker)) {
21094
20834
  return subjectRoot;
@@ -21485,8 +21225,8 @@ init_role_run_placement();
21485
21225
  init_doctor_evidence();
21486
21226
  init_unknown_value();
21487
21227
  init_host_contracts();
21488
- import { readFile as readFile17 } from "node:fs/promises";
21489
- import { resolve as resolve18 } from "node:path";
21228
+ import { readFile as readFile16 } from "node:fs/promises";
21229
+ import { resolve as resolve17 } from "node:path";
21490
21230
  init_notary_source_run();
21491
21231
  init_packaged_role_registry();
21492
21232
  init_invocation();
@@ -21494,12 +21234,12 @@ function navigatorInputReference(getFlag, role) {
21494
21234
  if (getFlag === void 0) return void 0;
21495
21235
  const name = packagedRoleInputFlag(role);
21496
21236
  const value = name === void 0 ? void 0 : getFlag(name);
21497
- return typeof value === "string" && value !== "" ? resolve18(value) : void 0;
21237
+ return typeof value === "string" && value !== "" ? resolve17(value) : void 0;
21498
21238
  }
21499
21239
  async function loadNavigatorWorkContext(options) {
21500
21240
  const reference = navigatorInputReference(options.getFlag, options.role);
21501
21241
  const subjectMode = packagedNavigatorSubject(options.role);
21502
- const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile17(reference, "utf8");
21242
+ const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile16(reference, "utf8");
21503
21243
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
21504
21244
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
21505
21245
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -21516,7 +21256,7 @@ async function loadNavigatorWorkContext(options) {
21516
21256
  }
21517
21257
  const publicRunDir = runDirectoryFromHostContext(options.context);
21518
21258
  const currentSessionDir = options.context.sessionManager.getSessionDir();
21519
- const isBoundPublicRun = publicRunDir !== void 0 && resolve18(currentSessionDir) === resolve18(sessionDirectoryOf(publicRunDir));
21259
+ const isBoundPublicRun = publicRunDir !== void 0 && resolve17(currentSessionDir) === resolve17(sessionDirectoryOf(publicRunDir));
21520
21260
  if (subjectMode === "public-instruction" && isBoundPublicRun) {
21521
21261
  let admitted;
21522
21262
  try {
@@ -21549,14 +21289,14 @@ async function loadNavigatorWorkContext(options) {
21549
21289
  }
21550
21290
  const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
21551
21291
  const authorityFiles = workRoot === void 0 ? [] : [
21552
- resolve18(workRoot, "authority.md"),
21553
- resolve18(workRoot, "authority.txt"),
21554
- resolve18(workRoot, "design-v2/owner-direction.md")
21292
+ resolve17(workRoot, "authority.md"),
21293
+ resolve17(workRoot, "authority.txt"),
21294
+ resolve17(workRoot, "design-v2/owner-direction.md")
21555
21295
  ];
21556
21296
  let authorityMaterial;
21557
21297
  for (const path of authorityFiles) {
21558
21298
  try {
21559
- const content = await readFile17(path, "utf8");
21299
+ const content = await readFile16(path, "utf8");
21560
21300
  if (content.trim() !== "") {
21561
21301
  authorityMaterial = content;
21562
21302
  break;
@@ -21589,7 +21329,7 @@ init_submission_ledger();
21589
21329
  init_filed_submission();
21590
21330
  import { randomUUID as randomUUID7 } from "node:crypto";
21591
21331
  import { writeSync as writeSync2 } from "node:fs";
21592
- import { join as join35 } from "node:path";
21332
+ import { join as join34 } from "node:path";
21593
21333
  import { Value as Value4 } from "typebox/value";
21594
21334
 
21595
21335
  // src/activation-trace.ts
@@ -21641,7 +21381,7 @@ import {
21641
21381
  statSync as statSync8,
21642
21382
  writeFileSync as writeFileSync3
21643
21383
  } from "node:fs";
21644
- import { isAbsolute as isAbsolute11, resolve as resolve19 } from "node:path";
21384
+ import { isAbsolute as isAbsolute10, resolve as resolve18 } from "node:path";
21645
21385
  var ActivationSessionFileMissingError = class extends Error {
21646
21386
  code = "AK_ACTIVATION_SESSION_FILE_MISSING";
21647
21387
  path;
@@ -21681,12 +21421,12 @@ function durableSessionPointer(sessionManager) {
21681
21421
  "Workflow role activation requires a durable Pi session file principal (getSessionFile); directory-only or --no-session invocations are rejected"
21682
21422
  );
21683
21423
  }
21684
- if (!isAbsolute11(file)) {
21424
+ if (!isAbsolute10(file)) {
21685
21425
  throw new Error(
21686
21426
  `Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
21687
21427
  );
21688
21428
  }
21689
- const resolvedFile = resolve19(file);
21429
+ const resolvedFile = resolve18(file);
21690
21430
  try {
21691
21431
  lstatSync2(resolvedFile);
21692
21432
  } catch (error) {
@@ -21930,7 +21670,7 @@ var COLLECTOR_TRANSPORT_FLAGS = Object.freeze([
21930
21670
  Object.freeze({
21931
21671
  name: "ak-collector-request-manifest",
21932
21672
  definition: Object.freeze({
21933
- description: "Path to the Collector v1 request manifest JSON file (caller guidance; not a machine collection directive).",
21673
+ description: "Caller path to a request manifest JSON file (passed as-is; package does not read or validate).",
21934
21674
  type: "string"
21935
21675
  })
21936
21676
  })
@@ -21941,19 +21681,9 @@ function buildMethodContext(activation) {
21941
21681
  `host: github.com`,
21942
21682
  `repository: ${activation.repository.canonical}`,
21943
21683
  `prNumber: ${activation.prNumber === void 0 ? "\u672A\u7ED1\u5B9A" : String(activation.prNumber)}`,
21944
- `requests: ${JSON.stringify(activation.manifest.requests.map((request) => ({ id: request.id })))}`,
21945
- `manifestDigest: ${activation.manifest.digest}`,
21684
+ ...activation.requestManifestPath === void 0 ? [] : [`requestManifestPath: ${activation.requestManifestPath}`],
21946
21685
  "</collector_method>"
21947
21686
  ];
21948
- if (activation.manifest.requests.length > 0) {
21949
- const payload = JSON.stringify({
21950
- requests: activation.manifest.requests.map((request) => ({
21951
- id: request.id,
21952
- body: request.requestBody
21953
- }))
21954
- }).replaceAll("<", "\\u003c");
21955
- lines.push("", "<collector_request_manifest>", payload, "</collector_request_manifest>");
21956
- }
21957
21687
  return lines.join("\n");
21958
21688
  }
21959
21689
  function createCollectorRoleRuntime(pi, dependencies) {
@@ -21975,12 +21705,12 @@ function createCollectorRoleRuntime(pi, dependencies) {
21975
21705
  } else if (typeof prFlag === "number") {
21976
21706
  prNumber = parseCollectorPrNumber(prFlag);
21977
21707
  }
21978
- const manifest = typeof requestManifestFlag === "string" && requestManifestFlag.trim().length > 0 ? await loadCollectorManifest(requestManifestFlag) : emptyCollectorManifest();
21708
+ const requestManifestPath = typeof requestManifestFlag === "string" ? requestManifestFlag : void 0;
21979
21709
  return {
21980
21710
  soul,
21981
21711
  repository,
21982
21712
  prNumber,
21983
- manifest
21713
+ ...requestManifestPath === void 0 ? {} : { requestManifestPath }
21984
21714
  };
21985
21715
  },
21986
21716
  assembleMaterials(activation, baseSystemPrompt) {
@@ -22315,8 +22045,8 @@ init_unknown_value();
22315
22045
  init_submission_errors();
22316
22046
  init_worker_submission_contracts();
22317
22047
  import { execFileSync as execFileSync3 } from "node:child_process";
22318
- import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync4, rmdirSync, rmSync as rmSync3 } from "node:fs";
22319
- import { resolve as resolve20 } from "node:path";
22048
+ import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync3 } from "node:fs";
22049
+ import { resolve as resolve19 } from "node:path";
22320
22050
  var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
22321
22051
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
22322
22052
  var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
@@ -22356,7 +22086,7 @@ function tryGetAll(file, key) {
22356
22086
  }
22357
22087
  function ownedHook(path) {
22358
22088
  if (!existsSync13(path)) return false;
22359
- return readFileSync4(path, "utf8").includes(HOOK_MARKER);
22089
+ return readFileSync5(path, "utf8").includes(HOOK_MARKER);
22360
22090
  }
22361
22091
  function escapeGitConfigValueRegex(value) {
22362
22092
  return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
@@ -22364,7 +22094,7 @@ function escapeGitConfigValueRegex(value) {
22364
22094
  function unsetOwnedHooksPath(file) {
22365
22095
  const owned = [];
22366
22096
  for (const value of tryGetAll(file, "core.hooksPath")) {
22367
- if (!ownedHook(resolve20(value, HOOK_FILE))) continue;
22097
+ if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
22368
22098
  try {
22369
22099
  gitFile(file, [
22370
22100
  "--unset-all",
@@ -22379,15 +22109,15 @@ function unsetOwnedHooksPath(file) {
22379
22109
  return owned;
22380
22110
  }
22381
22111
  function rmOwnedDir(dir) {
22382
- const hookPath = resolve20(dir, HOOK_FILE);
22112
+ const hookPath = resolve19(dir, HOOK_FILE);
22383
22113
  if (!ownedHook(hookPath)) return;
22384
22114
  rmSync3(hookPath, { force: true });
22385
22115
  if (existsSync13(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
22386
22116
  }
22387
22117
  function linkedGitDirs(commonDir) {
22388
- const root = resolve20(commonDir, "worktrees");
22118
+ const root = resolve19(commonDir, "worktrees");
22389
22119
  if (!existsSync13(root)) return [];
22390
- return readdirSync4(root).map((name) => resolve20(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22120
+ return readdirSync4(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22391
22121
  }
22392
22122
  function uninstallPackageWorkerHooks(cwd) {
22393
22123
  let inside;
@@ -22401,14 +22131,14 @@ function uninstallPackageWorkerHooks(cwd) {
22401
22131
  const clear = (configFile) => {
22402
22132
  for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
22403
22133
  };
22404
- clear(resolve20(commonDir, "config"));
22405
- clear(resolve20(commonDir, "config.worktree"));
22406
- rmOwnedDir(resolve20(commonDir, HOOKS_DIR));
22407
- const legacy = resolve20(commonDir, "hooks", HOOK_FILE);
22134
+ clear(resolve19(commonDir, "config"));
22135
+ clear(resolve19(commonDir, "config.worktree"));
22136
+ rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
22137
+ const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
22408
22138
  if (ownedHook(legacy)) rmSync3(legacy, { force: true });
22409
22139
  for (const gitDir of linkedGitDirs(commonDir)) {
22410
- clear(resolve20(gitDir, "config.worktree"));
22411
- rmOwnedDir(resolve20(gitDir, HOOKS_DIR));
22140
+ clear(resolve19(gitDir, "config.worktree"));
22141
+ rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
22412
22142
  }
22413
22143
  }
22414
22144
  function containsWrittenReason(value) {
@@ -23280,7 +23010,7 @@ function readRoleRunCoordinates(ctx, label) {
23280
23010
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
23281
23011
  const admitted = readPageSync(runDirectory, "admitted");
23282
23012
  if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
23283
- throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join35(runDirectory, RUN_STATE_FILE)})`);
23013
+ throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join34(runDirectory, RUN_STATE_FILE)})`);
23284
23014
  }
23285
23015
  return {
23286
23016
  runDirectory,
@@ -23593,9 +23323,6 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23593
23323
  }
23594
23324
  });
23595
23325
  roleHost.on("before_agent_start", () => {
23596
- const role = selectedRole ?? roleHost.getFlag(ROLE_FLAG.name);
23597
- if (typeof role !== "string" || !isOfficerReviewSeat(role)) return;
23598
- if (roleHost.getFlag(STATION_CHILD_FLAG.name) !== true) return;
23599
23326
  const engine = resolveEngineName((name) => roleHost.getFlag(name));
23600
23327
  if (engine === void 0 || dependencies.packageRoot === void 0) return;
23601
23328
  const engineModel = resolveEngineModel((name) => roleHost.getFlag(name));
@@ -23604,15 +23331,9 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23604
23331
  ...engineModel === void 0 ? {} : { engineModel },
23605
23332
  packageRoot: dependencies.packageRoot
23606
23333
  });
23607
- if (material === void 0) return;
23608
- return {
23609
- readingMaterial: {
23610
- kind: "engine-session-material",
23611
- name: material.name,
23612
- ...material.model === void 0 ? {} : { model: material.model },
23613
- ...material.materialPath === void 0 ? {} : { materialPath: material.materialPath }
23614
- }
23615
- };
23334
+ const reading = engineSessionReadingMaterial(material);
23335
+ if (reading === void 0) return;
23336
+ return { readingMaterial: reading };
23616
23337
  });
23617
23338
  roleHost.on("before_agent_start", () => {
23618
23339
  const path = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
@@ -24139,11 +23860,11 @@ function createRoleRuntimeDependencies(packageRoot) {
24139
23860
  packageRoot,
24140
23861
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
24141
23862
  loadRoleSoul: loadRegisteredRoleSoul,
24142
- loadFixPacket: (path) => readFile18(path, "utf8"),
24143
- loadCoderTask: (path) => readFile18(path, "utf8"),
23863
+ loadFixPacket: (path) => readFile17(path, "utf8"),
23864
+ loadCoderTask: (path) => readFile17(path, "utf8"),
24144
23865
  loadDoctorCase,
24145
23866
  loadNotarySourceRun: loadNotarySourceRunLocator,
24146
- loadMergerInput: async (path) => JSON.parse(await readFile18(path, "utf8")),
23867
+ loadMergerInput: async (path) => JSON.parse(await readFile17(path, "utf8")),
24147
23868
  loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
24148
23869
  context: options.context,
24149
23870
  role: options.role,
@@ -24183,11 +23904,11 @@ init_settlement();
24183
23904
  init_run_lifecycle();
24184
23905
  init_unknown_value();
24185
23906
  async function listen(server, path) {
24186
- await new Promise((resolve22, reject) => {
23907
+ await new Promise((resolve21, reject) => {
24187
23908
  server.once("error", reject);
24188
23909
  server.listen(path, () => {
24189
23910
  server.off("error", reject);
24190
- resolve22();
23911
+ resolve21();
24191
23912
  });
24192
23913
  });
24193
23914
  }
@@ -24612,8 +24333,8 @@ async function prepareRoleEnvelope(options) {
24612
24333
  try {
24613
24334
  const closeAll = server.closeAllConnections;
24614
24335
  if (typeof closeAll === "function") closeAll.call(server);
24615
- await new Promise((resolve22, reject) => {
24616
- server.close((error) => error ? reject(error) : resolve22());
24336
+ await new Promise((resolve21, reject) => {
24337
+ server.close((error) => error ? reject(error) : resolve21());
24617
24338
  });
24618
24339
  } catch (error) {
24619
24340
  await retainPackageFault({
@@ -24753,9 +24474,9 @@ init_role_run_placement();
24753
24474
  import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
24754
24475
  import { randomUUID as randomUUID9 } from "node:crypto";
24755
24476
  import { existsSync as existsSync14 } from "node:fs";
24756
- import { mkdtemp as mkdtemp2, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
24757
- import { tmpdir as tmpdir2 } from "node:os";
24758
- import { dirname as dirname22, isAbsolute as isAbsolute12, join as join36, resolve as resolve21 } from "node:path";
24477
+ import { mkdtemp, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
24478
+ import { tmpdir } from "node:os";
24479
+ import { dirname as dirname22, isAbsolute as isAbsolute11, join as join35, resolve as resolve20 } from "node:path";
24759
24480
 
24760
24481
  // src/external-host-turn-loop.ts
24761
24482
  init_settlement();
@@ -25294,7 +25015,7 @@ function formatCodexFailurePayload(payload) {
25294
25015
  function cwdIsGitWorkTree(cwd) {
25295
25016
  let dir = cwd;
25296
25017
  for (; ; ) {
25297
- if (existsSync14(join36(dir, ".git"))) return true;
25018
+ if (existsSync14(join35(dir, ".git"))) return true;
25298
25019
  const parent = dirname22(dir);
25299
25020
  if (parent === dir) return false;
25300
25021
  dir = parent;
@@ -25323,10 +25044,10 @@ function resolveGitCommonDir(cwd) {
25323
25044
  if (raw === "") {
25324
25045
  throw new Error("git rev-parse --git-common-dir returned empty stdout");
25325
25046
  }
25326
- return isAbsolute12(raw) ? raw : resolve21(cwd, raw);
25047
+ return isAbsolute11(raw) ? raw : resolve20(cwd, raw);
25327
25048
  }
25328
25049
  function spawnHeadlessTurn(options) {
25329
- return new Promise((resolve22, reject) => {
25050
+ return new Promise((resolve21, reject) => {
25330
25051
  if (options.signal?.aborted) {
25331
25052
  reject(hostAbortedError("headless host aborted"));
25332
25053
  return;
@@ -25392,7 +25113,7 @@ function spawnHeadlessTurn(options) {
25392
25113
  if (timer !== void 0) clearTimeout(timer);
25393
25114
  options.signal?.removeEventListener("abort", onAbort);
25394
25115
  if (stdinDeliveryError !== void 0) packageErrors.push(stdinDeliveryError);
25395
- resolve22({
25116
+ resolve21({
25396
25117
  packageErrors,
25397
25118
  code,
25398
25119
  stdout: resultStdout,
@@ -25512,8 +25233,8 @@ function createHeadlessRoleTurnHost(config) {
25512
25233
  }
25513
25234
  const env = { ...process.env, ...config.env ?? {} };
25514
25235
  const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
25515
- const inputsDirectory = await mkdtemp2(join36(tmpdir2(), "ak-role-headless-"));
25516
- const systemPromptPath = join36(inputsDirectory, "system-prompt.txt");
25236
+ const inputsDirectory = await mkdtemp(join35(tmpdir(), "ak-role-headless-"));
25237
+ const systemPromptPath = join35(inputsDirectory, "system-prompt.txt");
25517
25238
  let mcpConfigPath;
25518
25239
  let outputSchemaPath;
25519
25240
  let startedWithSchema;
@@ -25522,13 +25243,13 @@ function createHeadlessRoleTurnHost(config) {
25522
25243
  let deliveredSchema;
25523
25244
  if (codex) {
25524
25245
  if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
25525
- outputSchemaPath = join36(inputsDirectory, "output-schema.json");
25246
+ outputSchemaPath = join35(inputsDirectory, "output-schema.json");
25526
25247
  deliveredSchema = closeJsonSchemaForCodex(prepared.jsonSchema);
25527
25248
  await writeFile6(outputSchemaPath, `${JSON.stringify(deliveredSchema, null, 2)}
25528
25249
  `, "utf8");
25529
25250
  }
25530
25251
  } else {
25531
- mcpConfigPath = join36(inputsDirectory, "mcp-config.json");
25252
+ mcpConfigPath = join35(inputsDirectory, "mcp-config.json");
25532
25253
  await writeFile6(
25533
25254
  mcpConfigPath,
25534
25255
  `${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
@@ -25540,7 +25261,7 @@ function createHeadlessRoleTurnHost(config) {
25540
25261
  startedWithSchema = deliveredSchema;
25541
25262
  } catch (setupError) {
25542
25263
  try {
25543
- await rm3(inputsDirectory, { recursive: true, force: true });
25264
+ await rm2(inputsDirectory, { recursive: true, force: true });
25544
25265
  } catch (cleanupError) {
25545
25266
  await retainPackageFault({
25546
25267
  runDirectory: request.runDirectory,
@@ -25751,7 +25472,7 @@ function createHeadlessRoleTurnHost(config) {
25751
25472
  });
25752
25473
  } finally {
25753
25474
  try {
25754
- await rm3(inputsDirectory, { recursive: true, force: true });
25475
+ await rm2(inputsDirectory, { recursive: true, force: true });
25755
25476
  } catch (error) {
25756
25477
  await retainPackageFault({
25757
25478
  runDirectory: request.runDirectory,