@akagilnc/pi-workflow-roles 0.1.4444 → 0.1.4503

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.
Files changed (50) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/dist/acp-host/description.js +2 -3
  4. package/dist/acp-host/production-host.js +512 -288
  5. package/dist/auditor-soul.js +8 -1
  6. package/dist/headless-host/description.js +3 -3
  7. package/dist/headless-host/production-host.js +519 -257
  8. package/dist/host-descriptions.js +3 -18
  9. package/dist/method-host-plugin/.claude-plugin/plugin.json +5 -0
  10. package/dist/method-host-plugin/skills/ak-cross-m-review/CONTEXT.md +48 -0
  11. package/dist/method-host-plugin/skills/ak-cross-m-review/LICENSE +21 -0
  12. package/dist/method-host-plugin/skills/ak-cross-m-review/SKILL.md +170 -0
  13. package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-completeness.md +118 -0
  14. package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-reviewer.md +128 -0
  15. package/dist/method-host-plugin/skills/ak-cross-m-review/provenance.json +41 -0
  16. package/dist/method-host-plugin/skills/diagnosing-bugs/SKILL.md +134 -0
  17. package/dist/method-host-plugin/skills/diagnosing-bugs/agents/openai.yaml +3 -0
  18. package/dist/method-host-plugin/skills/diagnosing-bugs/provenance.json +31 -0
  19. package/dist/method-host-plugin/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +41 -0
  20. package/dist/method-host-plugin/skills/resolving-merge-conflicts/SKILL.md +14 -0
  21. package/dist/method-host-plugin/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
  22. package/dist/method-host-plugin/skills/resolving-merge-conflicts/provenance.json +26 -0
  23. package/dist/method-host-plugin/skills/tdd/SKILL.md +38 -0
  24. package/dist/method-host-plugin/skills/tdd/agents/openai.yaml +3 -0
  25. package/dist/method-host-plugin/skills/tdd/mocking.md +59 -0
  26. package/dist/method-host-plugin/skills/tdd/provenance.json +36 -0
  27. package/dist/method-host-plugin/skills/tdd/tests.md +77 -0
  28. package/dist/public-cli/countersign-run.js +214 -155
  29. package/dist/public-cli/diarist-run.js +4 -1
  30. package/dist/public-cli/invocation.js +129 -21
  31. package/dist/public-cli/main.js +386 -202
  32. package/dist/session-opening-materials.js +17 -5
  33. package/extensions/role-runtime.ts +16 -6
  34. package/package.json +1 -1
  35. package/resources/method-host-plugin/.claude-plugin/plugin.json +5 -0
  36. package/scripts/build-package.mjs +6 -1
  37. package/src/acp-host/description.ts +2 -4
  38. package/src/acp-host/production-host.ts +0 -1
  39. package/src/auditor-soul.ts +10 -1
  40. package/src/headless-host/description.ts +4 -3
  41. package/src/headless-host/role-turn-host.ts +27 -4
  42. package/src/host-descriptions.ts +3 -23
  43. package/src/host-native-method.ts +67 -0
  44. package/src/public-cli/countersign-run.ts +326 -218
  45. package/src/public-cli/diarist-run.ts +4 -0
  46. package/src/public-cli/invocation.ts +205 -23
  47. package/src/role-envelope.ts +17 -47
  48. package/src/role-runtime-dependencies.ts +17 -2
  49. package/src/role-runtime.ts +12 -7
  50. package/src/session-opening-materials.ts +27 -11
@@ -1521,10 +1521,10 @@ __export(session_assistant_usage_exports, {
1521
1521
  });
1522
1522
  import { join as join8 } from "node:path";
1523
1523
  async function readAssistantUsageFromSessionFile(sessionFile) {
1524
- const { readFile: readFile24 } = await import("node:fs/promises");
1524
+ const { readFile: readFile23 } = await import("node:fs/promises");
1525
1525
  let text;
1526
1526
  try {
1527
- text = await readFile24(sessionFile, "utf8");
1527
+ text = await readFile23(sessionFile, "utf8");
1528
1528
  } catch (error) {
1529
1529
  if (error?.code === "ENOENT") return void 0;
1530
1530
  throw error;
@@ -3498,13 +3498,10 @@ function assertRegisteredHostName(host) {
3498
3498
  }
3499
3499
  throw new Error(`unregistered host: ${host}`);
3500
3500
  }
3501
- var PRIVATE_COMPAT_ENV, DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
3501
+ var DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
3502
3502
  var init_host_descriptions = __esm({
3503
3503
  "src/host-descriptions.ts"() {
3504
3504
  "use strict";
3505
- PRIVATE_COMPAT_ENV = Object.fromEntries(
3506
- ["CLAUDE", "CURSOR", "CODEX"].flatMap((vendor) => ["SKILLS", "RULES", "AGENTS", "MCPS", "HOOKS", "SESSIONS"].map((kind) => [`GROK_${vendor}_${kind}_ENABLED`, "false"]))
3507
- );
3508
3505
  DEFAULT_ROLE_TURN_HOST = "pi";
3509
3506
  HOST_DESCRIPTIONS = Object.freeze({
3510
3507
  /** Operator home `~/.grok`, native session/load resume, `agent [--model X] stdio`. */
@@ -3517,12 +3514,7 @@ var init_host_descriptions = __esm({
3517
3514
  }),
3518
3515
  modelPassing: "argv",
3519
3516
  boundResume: "session/load",
3520
- sessionBindingFile: "grok-acp-session.json",
3521
- childEnv: Object.freeze({
3522
- ...PRIVATE_COMPAT_ENV,
3523
- GROK_MEMORY: "0",
3524
- GROK_SUBAGENTS: "0"
3525
- })
3517
+ sessionBindingFile: "grok-acp-session.json"
3526
3518
  }),
3527
3519
  /**
3528
3520
  * Operator home `~/.hermes`, native session/load resume, `acp` subcommand.
@@ -3541,7 +3533,6 @@ var init_host_descriptions = __esm({
3541
3533
  modelPassing: "set_model",
3542
3534
  boundResume: "session/load",
3543
3535
  sessionBindingFile: "hermes-acp-session.json",
3544
- childEnv: Object.freeze({}),
3545
3536
  seatProfileSoul: Object.freeze({
3546
3537
  flag: "-p",
3547
3538
  namePrefix: "ak-",
@@ -3562,12 +3553,7 @@ var init_host_descriptions = __esm({
3562
3553
  // Intermediate assistant/tool/system events require verbose with stream-json.
3563
3554
  "--verbose",
3564
3555
  "--permission-mode",
3565
- "bypassPermissions",
3566
- // Empty sources: no user/project/local operator surface (envelope owns materials).
3567
- "--setting-sources",
3568
- "",
3569
- // With adapter-supplied --mcp-config only (AK relay); drops operator + claude.ai MCP.
3570
- "--strict-mcp-config"
3556
+ "bypassPermissions"
3571
3557
  ]),
3572
3558
  promptFlag: "-p",
3573
3559
  modelFlag: "--model",
@@ -7680,10 +7666,12 @@ __export(invocation_exports, {
7680
7666
  deriveMergerEnvelopeFromActiveMerge: () => deriveMergerEnvelopeFromActiveMerge,
7681
7667
  ensureRunArtifactsDir: () => ensureRunArtifactsDir,
7682
7668
  freezeAttachmentsIntoRun: () => freezeAttachmentsIntoRun,
7669
+ freezePreparedAttachmentsIntoRun: () => freezePreparedAttachmentsIntoRun,
7683
7670
  homeFromRunDirectory: () => homeFromRunDirectory,
7684
7671
  isReviewerLens: () => isReviewerLens,
7685
7672
  issueAdmissionPlacement: () => issueAdmissionPlacement,
7686
7673
  loadAdmittedJudgeRequest: () => loadAdmittedJudgeRequest,
7674
+ materializeCountersignInvocation: () => materializeCountersignInvocation,
7687
7675
  observeLaunchedRolePackageIdentity: () => observeLaunchedRolePackageIdentity,
7688
7676
  parseAnalystArgv: () => parseAnalystArgv,
7689
7677
  parseAnalystCohortIssueToken: () => parseAnalystCohortIssueToken,
@@ -7707,6 +7695,7 @@ __export(invocation_exports, {
7707
7695
  parseReviewerArgv: () => parseReviewerArgv,
7708
7696
  parseSecretariatArgv: () => parseSecretariatArgv,
7709
7697
  persistAdmittedSourceRunPath: () => persistAdmittedSourceRunPath,
7698
+ recordAdmittedCorrelation: () => recordAdmittedCorrelation,
7710
7699
  recordEffectiveInvocationModel: () => recordEffectiveInvocationModel,
7711
7700
  recordLaunchedPiIdentity: () => recordLaunchedPiIdentity,
7712
7701
  recordLaunchedRolePackageIdentity: () => recordLaunchedRolePackageIdentity,
@@ -7715,17 +7704,21 @@ __export(invocation_exports, {
7715
7704
  requireReviewerBaseRevision: () => requireReviewerBaseRevision,
7716
7705
  requireReviewerLens: () => requireReviewerLens,
7717
7706
  resolveDoctorCaseRunsPath: () => resolveDoctorCaseRunsPath,
7718
- resolveGitHubRemoteRepository: () => resolveGitHubRemoteRepository
7707
+ resolveGitHubRemoteRepository: () => resolveGitHubRemoteRepository,
7708
+ withPreparedAttachments: () => withPreparedAttachments
7719
7709
  });
7720
7710
  import { execFileSync as execFileSync3 } from "node:child_process";
7721
7711
  import { existsSync as existsSync6 } from "node:fs";
7722
7712
  import {
7723
7713
  lstat as lstat4,
7714
+ mkdtemp as mkdtemp2,
7724
7715
  readFile as readFile10,
7725
7716
  realpath as realpath4,
7726
7717
  rename,
7718
+ rm as rm2,
7727
7719
  writeFile as writeFile5
7728
7720
  } from "node:fs/promises";
7721
+ import { tmpdir as tmpdir2 } from "node:os";
7729
7722
  import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute7, join as join17, resolve as resolve9, sep as sep4 } from "node:path";
7730
7723
  function issueAdmissionPlacement(authority, request) {
7731
7724
  const ledgerHome = resolveActivationLedgerHome(request.home);
@@ -7736,7 +7729,7 @@ function issueAdmissionPlacement(authority, request) {
7736
7729
  runId: request.runId,
7737
7730
  role: request.role
7738
7731
  });
7739
- ensureRoleRunPlacement(ledgerHome, placement);
7732
+ if (request.materialize !== false) ensureRoleRunPlacement(ledgerHome, placement);
7740
7733
  return {
7741
7734
  principal: authority.seal(placement),
7742
7735
  ...placement,
@@ -7861,6 +7854,31 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
7861
7854
  await bindTicketNumberOnRunDirectory(admitted.runDirectory, ticketNumber);
7862
7855
  admitted.ticketNumber = ticketNumber;
7863
7856
  }
7857
+ async function recordAdmittedCorrelation(admitted, correlationId) {
7858
+ const current = JSON.parse(
7859
+ await readFile10(admitted.admittedRequestPath, "utf8")
7860
+ );
7861
+ const prior = [
7862
+ ...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
7863
+ (value) => typeof value === "string" && value.trim() !== ""
7864
+ ) : [],
7865
+ ...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
7866
+ ];
7867
+ const correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
7868
+ await writeFile5(
7869
+ admitted.admittedRequestPath,
7870
+ `${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
7871
+ `,
7872
+ "utf8"
7873
+ );
7874
+ await mergeInvocationIdentityPage(admitted.runDirectory, {
7875
+ correlationId,
7876
+ correlationIds
7877
+ });
7878
+ const mutable = admitted;
7879
+ mutable.correlationId = correlationId;
7880
+ mutable.correlationIds = correlationIds;
7881
+ }
7864
7882
  async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
7865
7883
  if (admitted.ticketNumber === void 0) {
7866
7884
  throw new Error(
@@ -8251,7 +8269,7 @@ function parseFixerArgv(args) {
8251
8269
  ...project === void 0 ? {} : { project }
8252
8270
  };
8253
8271
  }
8254
- async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
8272
+ async function readRegularFileAttachment(sourcePath) {
8255
8273
  const absolute = isAbsolute7(sourcePath) ? sourcePath : resolve9(sourcePath);
8256
8274
  let st;
8257
8275
  try {
@@ -8267,18 +8285,72 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
8267
8285
  `attachment must be a regular file (not a directory or symlink): ${sourcePath}`
8268
8286
  );
8269
8287
  }
8270
- const bytes = await readFile10(absolute);
8271
- const name = `${String(index).padStart(2, "0")}-${basename6(absolute)}`;
8272
- const frozenPath = join17(destinationDir, name);
8288
+ try {
8289
+ return { absolute, bytes: await readFile10(absolute) };
8290
+ } catch (error) {
8291
+ throw new CliUsageError(
8292
+ `attachment is not a readable regular file: ${sourcePath}`,
8293
+ { cause: error }
8294
+ );
8295
+ }
8296
+ }
8297
+ async function removePreparedAttachmentDirectory(stagingDirectory) {
8298
+ await rm2(stagingDirectory, { recursive: true, force: true });
8299
+ }
8300
+ async function withPreparedAttachments(attachmentPaths, use) {
8301
+ if (attachmentPaths.length === 0) return await use([]);
8302
+ const stagingDirectory = await mkdtemp2(join17(tmpdir2(), "ak-role-attachments-"));
8303
+ const prepared = [];
8304
+ let result;
8305
+ try {
8306
+ for (let index = 0; index < attachmentPaths.length; index += 1) {
8307
+ const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
8308
+ const snapshotPath = join17(stagingDirectory, String(index).padStart(6, "0"));
8309
+ await writeFile5(snapshotPath, bytes);
8310
+ prepared.push({ absolute, snapshotPath });
8311
+ }
8312
+ result = await use(prepared);
8313
+ } catch (primary) {
8314
+ try {
8315
+ await removePreparedAttachmentDirectory(stagingDirectory);
8316
+ } catch (cleanup) {
8317
+ throw new AggregateError(
8318
+ [primary, cleanup],
8319
+ "attachment snapshot operation failed and cleanup also failed",
8320
+ { cause: primary }
8321
+ );
8322
+ }
8323
+ throw primary;
8324
+ }
8325
+ await removePreparedAttachmentDirectory(stagingDirectory);
8326
+ return result;
8327
+ }
8328
+ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
8329
+ const frozenPath = join17(
8330
+ destinationDir,
8331
+ `${String(index).padStart(2, "0")}-${basename6(provenancePath)}`
8332
+ );
8273
8333
  await writeFile5(frozenPath, bytes);
8274
8334
  return {
8275
- attachment: {
8276
- provenancePath: absolute,
8277
- frozenPath,
8278
- byteLength: bytes.byteLength,
8279
- sha256: sha256Hex(bytes),
8280
- mediaKind: "regular-file"
8281
- },
8335
+ provenancePath,
8336
+ frozenPath,
8337
+ byteLength: bytes.byteLength,
8338
+ sha256: sha256Hex(bytes),
8339
+ mediaKind: "regular-file"
8340
+ };
8341
+ }
8342
+ async function freezePreparedAttachment(prepared, destinationDir, index) {
8343
+ return freezeAttachmentBytes(
8344
+ prepared.absolute,
8345
+ await readFile10(prepared.snapshotPath),
8346
+ destinationDir,
8347
+ index
8348
+ );
8349
+ }
8350
+ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
8351
+ const { absolute, bytes } = await readRegularFileAttachment(sourcePath);
8352
+ return {
8353
+ attachment: await freezeAttachmentBytes(absolute, bytes, destinationDir, index),
8282
8354
  body: bytes
8283
8355
  };
8284
8356
  }
@@ -8301,6 +8373,17 @@ async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKe
8301
8373
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
8302
8374
  return freezeAttachments(attachmentPaths, attachmentsDirectory);
8303
8375
  }
8376
+ async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
8377
+ if (prepared.length === 0) return [];
8378
+ const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
8379
+ const attachmentsDirectory = summonsKey === void 0 ? join17(runDirectory, "attachments") : join17(runDirectory, "attachments", summonsKey);
8380
+ ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
8381
+ const attachments = [];
8382
+ for (let index = 0; index < prepared.length; index += 1) {
8383
+ attachments.push(await freezePreparedAttachment(prepared[index], attachmentsDirectory, index));
8384
+ }
8385
+ return attachments;
8386
+ }
8304
8387
  function ticketAdmissionFields(ticketNumber) {
8305
8388
  if (ticketNumber === void 0) return {};
8306
8389
  return {
@@ -8440,9 +8523,10 @@ async function admitCountersignInvocation(options) {
8440
8523
  runId,
8441
8524
  role: "countersign",
8442
8525
  subject: { unbound: true },
8443
- home: options.home
8526
+ home: options.home,
8527
+ materialize: options.deferPersistence !== true
8444
8528
  });
8445
- const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
8529
+ const attachments = options.deferPersistence === true ? [] : await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
8446
8530
  const instruction = options.instruction;
8447
8531
  const instructionEmpty = instruction.trim() === "";
8448
8532
  const admitted = {
@@ -8464,11 +8548,13 @@ async function admitCountersignInvocation(options) {
8464
8548
  }))
8465
8549
  };
8466
8550
  const admittedRequestPath = join17(runDirectory, "admitted-request.json");
8467
- await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
8468
- sessionDirectory,
8469
- sessionFile
8470
- });
8471
- await writeRoleInvocationLedger({ ...admitted, sessionDirectory, sessionFile }, admitted.role, options.model);
8551
+ if (options.deferPersistence !== true) {
8552
+ await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
8553
+ sessionDirectory,
8554
+ sessionFile
8555
+ });
8556
+ await writeRoleInvocationLedger({ ...admitted, sessionDirectory, sessionFile }, admitted.role, options.model);
8557
+ }
8472
8558
  return {
8473
8559
  role: "countersign",
8474
8560
  runId,
@@ -8483,6 +8569,29 @@ async function admitCountersignInvocation(options) {
8483
8569
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
8484
8570
  };
8485
8571
  }
8572
+ async function materializeCountersignInvocation(admitted, options) {
8573
+ const placement = issueAdmissionPlacement(options.principalAuthority, {
8574
+ cwd: admitted.projectRoot,
8575
+ runId: admitted.runId,
8576
+ role: "countersign",
8577
+ subject: { unbound: true },
8578
+ home: options.home
8579
+ });
8580
+ const attachments = await freezePreparedAttachmentsIntoRun(
8581
+ options.preparedAttachments,
8582
+ admitted.runDirectory
8583
+ );
8584
+ admitted.attachments = attachments;
8585
+ await writeAdmittedRequestPersistence(admitted.admittedRequestPath, admitted, {
8586
+ sessionDirectory: placement.sessionDirectory,
8587
+ sessionFile: placement.sessionFile
8588
+ });
8589
+ await writeRoleInvocationLedger(
8590
+ { ...admitted, sessionDirectory: placement.sessionDirectory, sessionFile: placement.sessionFile },
8591
+ admitted.role,
8592
+ options.model
8593
+ );
8594
+ }
8486
8595
  function buildCountersignTransportPrompt(admitted, engineMaterial) {
8487
8596
  return buildInstructionTransportPrompt(admitted, engineMaterial);
8488
8597
  }
@@ -11273,10 +11382,10 @@ function pairGateRounds(volumes) {
11273
11382
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
11274
11383
  }
11275
11384
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
11276
- const { readFile: readFile24 } = await import("node:fs/promises");
11385
+ const { readFile: readFile23 } = await import("node:fs/promises");
11277
11386
  let raw;
11278
11387
  try {
11279
- raw = JSON.parse(await readFile24(pointerPath, "utf8"));
11388
+ raw = JSON.parse(await readFile23(pointerPath, "utf8"));
11280
11389
  } catch (error) {
11281
11390
  throw new Error(
11282
11391
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
@@ -11877,16 +11986,27 @@ async function readPackageMaterial(relativePath) {
11877
11986
  }
11878
11987
  async function joinPackageMaterials(relativePaths) {
11879
11988
  const chunks = [];
11880
- for (const relativePath of relativePaths) {
11881
- chunks.push(await readPackageMaterial(relativePath));
11882
- }
11989
+ for (const relativePath of relativePaths) chunks.push(await readPackageMaterial(relativePath));
11883
11990
  return chunks.join("\n\n");
11884
11991
  }
11992
+ function roleSoulPath(role, materials) {
11993
+ const suffix = `/souls/${role}.md`;
11994
+ const path = materials.find((candidate) => `/${candidate}`.endsWith(suffix));
11995
+ if (path === void 0) throw new Error(`session materials omit the ${role} Soul`);
11996
+ return path;
11997
+ }
11998
+ async function loadSeparatedSessionPart(role, materials, part) {
11999
+ const soul = roleSoulPath(role, materials);
12000
+ return part === "soul" ? readPackageMaterial(soul) : joinPackageMaterials(materials.filter((path) => path !== soul));
12001
+ }
11885
12002
  function loadMainRoleSessionMaterials(role) {
11886
- return joinPackageMaterials(MAIN_ROLE_SESSION_MATERIALS[role]);
12003
+ return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "soul");
12004
+ }
12005
+ function loadMainRoleReferenceMaterials(role) {
12006
+ return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "references");
11887
12007
  }
11888
12008
  function loadGatekeeperSessionMaterials(role) {
11889
- return joinPackageMaterials(GATEKEEPER_SESSION_MATERIALS[role]);
12009
+ return loadSeparatedSessionPart(role, GATEKEEPER_SESSION_MATERIALS[role], "soul");
11890
12010
  }
11891
12011
  var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
11892
12012
  var init_session_opening_materials = __esm({
@@ -11916,6 +12036,8 @@ __export(auditor_soul_exports, {
11916
12036
  AUDITOR_SESSION_MATERIALS: () => AUDITOR_SESSION_MATERIALS,
11917
12037
  AUDITOR_SOUL_ROLES: () => AUDITOR_SOUL_ROLES,
11918
12038
  isAuditorSoulRole: () => isAuditorSoulRole,
12039
+ loadAuditorReferenceMaterials: () => loadAuditorReferenceMaterials,
12040
+ loadAuditorReferenceMaterialsFromSubjectInput: () => loadAuditorReferenceMaterialsFromSubjectInput,
11919
12041
  loadAuditorSoul: () => loadAuditorSoul,
11920
12042
  loadAuditorSoulFromSubjectInput: () => loadAuditorSoulFromSubjectInput,
11921
12043
  resolveAuditorSubject: () => resolveAuditorSubject
@@ -11942,11 +12064,18 @@ async function loadAuditorSoul(role) {
11942
12064
  if (soul.trim().length === 0) {
11943
12065
  throw new Error(`The ${role} auditor Soul is blank`);
11944
12066
  }
11945
- return joinPackageMaterials(materials);
12067
+ return soul;
12068
+ }
12069
+ function loadAuditorReferenceMaterials(role) {
12070
+ const soulPath = auditorSoulRelativePath(role);
12071
+ return joinPackageMaterials(AUDITOR_SESSION_MATERIALS[role].filter((path) => path !== soulPath));
11946
12072
  }
11947
12073
  async function loadAuditorSoulFromSubjectInput(raw) {
11948
12074
  return loadAuditorSoul(resolveAuditorSubject(raw));
11949
12075
  }
12076
+ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
12077
+ return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
12078
+ }
11950
12079
  var AUDITOR_SOUL_ROLES, AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV, AUDITOR_SESSION_MATERIALS;
11951
12080
  var init_auditor_soul = __esm({
11952
12081
  "src/auditor-soul.ts"() {
@@ -17460,8 +17589,8 @@ __export(case_dossier_delivery_exports, {
17460
17589
  loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
17461
17590
  projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
17462
17591
  });
17463
- import { mkdtemp as mkdtemp2, readFile as readFile18, rm as rm2, writeFile as writeFile9 } from "node:fs/promises";
17464
- import { tmpdir as tmpdir2 } from "node:os";
17592
+ import { mkdtemp as mkdtemp3, readFile as readFile18, rm as rm3, writeFile as writeFile9 } from "node:fs/promises";
17593
+ import { tmpdir as tmpdir3 } from "node:os";
17465
17594
  import { join as join31 } from "node:path";
17466
17595
  async function projectCaseDossierPointerSection(input) {
17467
17596
  if (input.ticketNumber === void 0) {
@@ -17489,7 +17618,7 @@ async function deliverCaseDossierAsAttachment(input) {
17489
17618
  projectRoot: input.projectRoot,
17490
17619
  home: input.home
17491
17620
  });
17492
- const stagingDir = await mkdtemp2(join31(tmpdir2(), "ak-case-dossier-"));
17621
+ const stagingDir = await mkdtemp3(join31(tmpdir3(), "ak-case-dossier-"));
17493
17622
  try {
17494
17623
  const stagingPath = join31(stagingDir, CASE_DOSSIER_ATTACH_FILE);
17495
17624
  await writeFile9(stagingPath, `${section}
@@ -17500,7 +17629,7 @@ async function deliverCaseDossierAsAttachment(input) {
17500
17629
  CASE_DOSSIER_ATTACH_KEY
17501
17630
  );
17502
17631
  } finally {
17503
- await rm2(stagingDir, { recursive: true, force: true });
17632
+ await rm3(stagingDir, { recursive: true, force: true });
17504
17633
  }
17505
17634
  }
17506
17635
  async function loadCaseDossierReadingMaterial(runDirectory) {
@@ -19802,6 +19931,9 @@ function diaristAdapters(env) {
19802
19931
  shouldPresentSettled: () => true,
19803
19932
  // Resume interrupted state: board ticket already on pages, run still under unbound/.
19804
19933
  beforeDispatch: async (admitted, lease) => {
19934
+ if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
19935
+ await recordAdmittedCorrelation(admitted, env.correlationId);
19936
+ }
19805
19937
  await bindAndRelocateDiaristIfBoardBound(admitted, env.principalAuthority, lease);
19806
19938
  },
19807
19939
  // First post-turn assert: accept hook wrote board pages; relocate before lease release.
@@ -19986,7 +20118,8 @@ function courtDiaristEscalated(roleOutcome) {
19986
20118
  if (roleOutcome.kind === "audit_escalation") return true;
19987
20119
  if (roleOutcome.kind !== "accepted") return false;
19988
20120
  return (roleOutcome.payloads ?? []).some((payload) => {
19989
- if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return false;
20121
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload))
20122
+ return false;
19990
20123
  const record4 = payload;
19991
20124
  return record4.status === "escalate" || record4.countersignStatus === "escalate";
19992
20125
  });
@@ -20039,7 +20172,10 @@ async function invokeCourtDiarist(input, env, io) {
20039
20172
  }
20040
20173
  const asserted = result.admitted?.ticketNumber;
20041
20174
  if (isSafePositiveTicketNumber(asserted)) {
20042
- const courtTicketNumbers = courtTicketNumbersFromOutcome(roleOutcome, asserted);
20175
+ const courtTicketNumbers = courtTicketNumbersFromOutcome(
20176
+ roleOutcome,
20177
+ asserted
20178
+ );
20043
20179
  return {
20044
20180
  identity: {
20045
20181
  kind: "ticket",
@@ -20088,7 +20224,9 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
20088
20224
  );
20089
20225
  }
20090
20226
  if (outcome.failedWithoutEscalate !== void 0) {
20091
- throw new StationChildExhaustedError(outcome.failedWithoutEscalate.diagnostic);
20227
+ throw new StationChildExhaustedError(
20228
+ outcome.failedWithoutEscalate.diagnostic
20229
+ );
20092
20230
  }
20093
20231
  }
20094
20232
  }
@@ -20114,7 +20252,8 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
20114
20252
  ...parsed.project === void 0 ? {} : { project: parsed.project },
20115
20253
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
20116
20254
  ...env.model === void 0 ? {} : { model: env.model },
20117
- ...env.correlationId === void 0 ? {} : { correlationId: env.correlationId }
20255
+ ...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
20256
+ deferPersistence: true
20118
20257
  });
20119
20258
  } catch (error) {
20120
20259
  if (error instanceof CliUsageError) {
@@ -20123,160 +20262,216 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
20123
20262
  }
20124
20263
  throw error;
20125
20264
  }
20126
- await markRunAdmitted(admitted, env.principalAuthority);
20127
- let typedTicket;
20128
- let typedCourtTicketNumbers;
20129
- let identityDiaristRan = false;
20130
- if (env.runCourtDiaristStation === void 0) {
20131
- const outcome = await invokeCourtDiarist(
20132
- {
20133
- instruction: parsed.instruction,
20134
- projectRoot: admitted.projectRoot,
20135
- failureLabel: "unbound summons",
20136
- correlationId: admitted.runId
20137
- },
20138
- env,
20139
- io
20140
- );
20141
- identityDiaristRan = true;
20142
- if (outcome.identity.kind === "escalate") {
20143
- return await presentControlledFailure2(
20144
- admitted,
20145
- {
20146
- timedOut: false,
20147
- code: null,
20148
- stderr: "",
20149
- thrown: new Error(
20150
- "court diarist station escalated (cannot identify court target)"
20151
- )
20152
- },
20153
- countersignAdapters(),
20154
- env.principalAuthority,
20155
- io
20156
- );
20157
- }
20158
- if (outcome.failedWithoutEscalate !== void 0) {
20159
- return await presentControlledFailure2(
20160
- admitted,
20161
- {
20162
- timedOut: false,
20163
- code: null,
20164
- stderr: "",
20165
- thrown: new Error(outcome.failedWithoutEscalate.diagnostic)
20166
- },
20167
- countersignAdapters(),
20168
- env.principalAuthority,
20169
- io
20170
- );
20171
- }
20172
- if (outcome.identity.kind === "ticket") {
20173
- const assertedTicket = outcome.identity.ticketNumber;
20174
- typedTicket = assertedTicket;
20175
- typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
20176
- const summons = {
20177
- instruction: parsed.instruction,
20178
- instructionEmpty: parsed.instruction.trim() === "",
20179
- attachmentPaths: parsed.attachmentPaths
20180
- };
20181
- const resumed = await tryResumeSameTicketSeatRun({
20182
- home: env.home,
20183
- projectRoot: admitted.projectRoot,
20184
- role: "countersign",
20185
- ticketNumber: typedTicket,
20186
- freshSummons: env.freshSummons,
20187
- summons,
20188
- resume: async (runId, materials) => {
20189
- await bindAdmittedTicketNumber(admitted, assertedTicket);
20190
- await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
20191
- await markRunTerminal(admitted.runDirectory);
20192
- return await runPublicCountersignResume(
20193
- {
20194
- runId,
20195
- ...materials === void 0 ? {} : { summons: materials }
20196
- },
20197
- {
20198
- ...env,
20199
- ...typedCourtTicketNumbers === void 0 ? {} : { pendingCourtTicketNumbers: typedCourtTicketNumbers }
20200
- },
20201
- io
20202
- );
20265
+ try {
20266
+ return await withPreparedAttachments(
20267
+ parsed.attachmentPaths,
20268
+ async (preparedAttachments) => {
20269
+ const materializeAdmission = async () => {
20270
+ await materializeCountersignInvocation(admitted, {
20271
+ home: env.home,
20272
+ principalAuthority: env.principalAuthority,
20273
+ preparedAttachments,
20274
+ ...env.model === void 0 ? {} : { model: env.model }
20275
+ });
20276
+ };
20277
+ let typedTicket;
20278
+ let typedCourtTicketNumbers;
20279
+ let identityDiaristRan = false;
20280
+ if (env.runCourtDiaristStation === void 0) {
20281
+ let outcome;
20282
+ try {
20283
+ outcome = await invokeCourtDiarist(
20284
+ {
20285
+ instruction: parsed.instruction,
20286
+ projectRoot: admitted.projectRoot,
20287
+ failureLabel: "unbound summons"
20288
+ },
20289
+ env,
20290
+ io
20291
+ );
20292
+ } catch (error) {
20293
+ await materializeAdmission();
20294
+ await markRunAdmitted(admitted, env.principalAuthority);
20295
+ return await presentControlledFailure2(
20296
+ admitted,
20297
+ { timedOut: false, code: null, stderr: "", thrown: error },
20298
+ countersignAdapters(),
20299
+ env.principalAuthority,
20300
+ io
20301
+ );
20302
+ }
20303
+ identityDiaristRan = true;
20304
+ if (outcome.identity.kind === "escalate") {
20305
+ await materializeAdmission();
20306
+ await markRunAdmitted(admitted, env.principalAuthority);
20307
+ return await presentControlledFailure2(
20308
+ admitted,
20309
+ {
20310
+ timedOut: false,
20311
+ code: null,
20312
+ stderr: "",
20313
+ thrown: new Error(
20314
+ "court diarist station escalated (cannot identify court target)"
20315
+ )
20316
+ },
20317
+ countersignAdapters(),
20318
+ env.principalAuthority,
20319
+ io
20320
+ );
20321
+ }
20322
+ if (outcome.failedWithoutEscalate !== void 0) {
20323
+ await materializeAdmission();
20324
+ await markRunAdmitted(admitted, env.principalAuthority);
20325
+ return await presentControlledFailure2(
20326
+ admitted,
20327
+ {
20328
+ timedOut: false,
20329
+ code: null,
20330
+ stderr: "",
20331
+ thrown: new Error(outcome.failedWithoutEscalate.diagnostic)
20332
+ },
20333
+ countersignAdapters(),
20334
+ env.principalAuthority,
20335
+ io
20336
+ );
20337
+ }
20338
+ if (outcome.identity.kind === "ticket") {
20339
+ const assertedTicket = outcome.identity.ticketNumber;
20340
+ typedTicket = assertedTicket;
20341
+ typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
20342
+ const summons = {
20343
+ instruction: parsed.instruction,
20344
+ instructionEmpty: parsed.instruction.trim() === ""
20345
+ };
20346
+ const resumed = await tryResumeSameTicketSeatRun({
20347
+ home: env.home,
20348
+ projectRoot: admitted.projectRoot,
20349
+ role: "countersign",
20350
+ ticketNumber: typedTicket,
20351
+ freshSummons: env.freshSummons,
20352
+ summons,
20353
+ resume: async (runId, materials) => {
20354
+ const retained = await loadResumableCountersignRun(
20355
+ env.home,
20356
+ runId,
20357
+ env.principalAuthority
20358
+ );
20359
+ if (retained.admitted === void 0) {
20360
+ throw new Error(
20361
+ `retained countersign run disappeared before resume: ${runId}`
20362
+ );
20363
+ }
20364
+ const frozenPaths = (await freezePreparedAttachmentsIntoRun(
20365
+ preparedAttachments,
20366
+ retained.admitted.runDirectory,
20367
+ `s-${Date.now().toString(36)}`
20368
+ )).map((attachment) => attachment.frozenPath);
20369
+ const preparedMaterials = {
20370
+ ...materials ?? {},
20371
+ ...frozenPaths.length === 0 ? {} : { attachmentPaths: frozenPaths }
20372
+ };
20373
+ return await runPublicCountersignResume(
20374
+ {
20375
+ runId,
20376
+ summons: preparedMaterials
20377
+ },
20378
+ {
20379
+ ...env,
20380
+ ...typedCourtTicketNumbers === void 0 ? {} : { pendingCourtTicketNumbers: typedCourtTicketNumbers }
20381
+ },
20382
+ io
20383
+ );
20384
+ }
20385
+ });
20386
+ if (resumed !== void 0) {
20387
+ return resumed;
20388
+ }
20389
+ }
20203
20390
  }
20204
- });
20205
- if (resumed !== void 0) {
20206
- return resumed;
20207
- }
20208
- }
20209
- }
20210
- if (identityDiaristRan && typedTicket !== void 0) {
20211
- try {
20212
- await bindAdmittedTicketNumber(admitted, typedTicket);
20213
- await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
20214
- await bindCourtTicketNumbersOnAdmitted(
20215
- admitted,
20216
- typedCourtTicketNumbers ?? [typedTicket]
20217
- );
20218
- } catch (error) {
20219
- return await presentControlledFailure2(
20220
- admitted,
20221
- {
20222
- timedOut: false,
20223
- code: null,
20224
- stderr: "",
20225
- thrown: error
20226
- },
20227
- countersignAdapters(),
20228
- env.principalAuthority,
20229
- io
20230
- );
20231
- }
20232
- }
20233
- const turnProjection = {
20234
- packageRoot: env.packageRoot,
20235
- home: env.home,
20236
- agentDir: env.agentDir,
20237
- ...env.model === void 0 ? {} : { model: env.model },
20238
- ...pickEngineAxis(env),
20239
- ...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
20240
- ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
20241
- continuation: {
20242
- kind: "initial",
20243
- prompt: buildCountersignTransportPrompt(
20244
- admitted,
20245
- engineSessionMaterialFromOptions({
20246
- ...pickEngineAxis(env),
20247
- packageRoot: env.packageRoot
20248
- })
20249
- )
20250
- }
20251
- };
20252
- const turnRequest = buildCountersignTurnRequest(admitted, turnProjection);
20253
- const result = await runPostAdmissionOneShot({
20254
- admitted,
20255
- env,
20256
- io,
20257
- request: turnRequest,
20258
- adapters: countersignAdapters({
20259
- beforeDispatch: async (admittedSeat, lease) => {
20260
- if (!identityDiaristRan) {
20261
- await runCountersignCourtDiaristStation(admittedSeat, env, io);
20262
- } else if (typedTicket !== void 0) {
20263
- await runCountersignCourtDiaristStation(admittedSeat, env, io);
20391
+ await materializeAdmission();
20392
+ await markRunAdmitted(admitted, env.principalAuthority);
20393
+ if (identityDiaristRan && typedTicket !== void 0) {
20394
+ try {
20395
+ await bindAdmittedTicketNumber(admitted, typedTicket);
20396
+ await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
20397
+ await bindCourtTicketNumbersOnAdmitted(
20398
+ admitted,
20399
+ typedCourtTicketNumbers ?? [typedTicket]
20400
+ );
20401
+ } catch (error) {
20402
+ return await presentControlledFailure2(
20403
+ admitted,
20404
+ {
20405
+ timedOut: false,
20406
+ code: null,
20407
+ stderr: "",
20408
+ thrown: error
20409
+ },
20410
+ countersignAdapters(),
20411
+ env.principalAuthority,
20412
+ io
20413
+ );
20414
+ }
20264
20415
  }
20265
- await relocateAdmittedRunToTicket(
20266
- admittedSeat,
20267
- env.principalAuthority,
20268
- lease
20269
- );
20270
- Object.assign(
20271
- turnRequest,
20272
- buildCountersignTurnRequest(admittedSeat, turnProjection)
20416
+ const turnProjection = {
20417
+ packageRoot: env.packageRoot,
20418
+ home: env.home,
20419
+ agentDir: env.agentDir,
20420
+ ...env.model === void 0 ? {} : { model: env.model },
20421
+ ...pickEngineAxis(env),
20422
+ ...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
20423
+ ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
20424
+ continuation: {
20425
+ kind: "initial",
20426
+ prompt: buildCountersignTransportPrompt(
20427
+ admitted,
20428
+ engineSessionMaterialFromOptions({
20429
+ ...pickEngineAxis(env),
20430
+ packageRoot: env.packageRoot
20431
+ })
20432
+ )
20433
+ }
20434
+ };
20435
+ const turnRequest = buildCountersignTurnRequest(
20436
+ admitted,
20437
+ turnProjection
20273
20438
  );
20439
+ const result = await runPostAdmissionOneShot({
20440
+ admitted,
20441
+ env,
20442
+ io,
20443
+ request: turnRequest,
20444
+ adapters: countersignAdapters({
20445
+ beforeDispatch: async (admittedSeat, lease) => {
20446
+ if (!identityDiaristRan) {
20447
+ await runCountersignCourtDiaristStation(admittedSeat, env, io);
20448
+ } else if (typedTicket !== void 0) {
20449
+ await runCountersignCourtDiaristStation(admittedSeat, env, io);
20450
+ }
20451
+ await relocateAdmittedRunToTicket(
20452
+ admittedSeat,
20453
+ env.principalAuthority,
20454
+ lease
20455
+ );
20456
+ Object.assign(
20457
+ turnRequest,
20458
+ buildCountersignTurnRequest(admittedSeat, turnProjection)
20459
+ );
20460
+ }
20461
+ }),
20462
+ ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
20463
+ });
20464
+ await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
20465
+ return result;
20274
20466
  }
20275
- }),
20276
- ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
20277
- });
20278
- await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
20279
- return result;
20467
+ );
20468
+ } catch (error) {
20469
+ if (error instanceof CliUsageError) {
20470
+ presentStructuralRejection(error, io);
20471
+ return { exitCode: 2 };
20472
+ }
20473
+ throw error;
20474
+ }
20280
20475
  }
20281
20476
  function countersignAdapters(options) {
20282
20477
  return {
@@ -20314,7 +20509,9 @@ async function runPublicCountersignResume(request, env, io) {
20314
20509
  adapters: countersignAdapters({
20315
20510
  beforeDispatch: async (admitted) => {
20316
20511
  if (admitted.courtTicketNumbersDamage !== void 0) {
20317
- throw new StationChildExhaustedError(admitted.courtTicketNumbersDamage);
20512
+ throw new StationChildExhaustedError(
20513
+ admitted.courtTicketNumbersDamage
20514
+ );
20318
20515
  }
20319
20516
  if (env.pendingCourtTicketNumbers !== void 0) {
20320
20517
  await bindCourtTicketNumbersOnAdmitted(
@@ -20717,9 +20914,9 @@ import { randomUUID as randomUUID9 } from "node:crypto";
20717
20914
  // src/role-envelope.ts
20718
20915
  init_engine_detour();
20719
20916
  import { randomUUID as randomUUID8 } from "node:crypto";
20720
- import { mkdir as mkdir5, readFile as readFile20, writeFile as writeFile12 } from "node:fs/promises";
20917
+ import { mkdir as mkdir6, writeFile as writeFile12 } from "node:fs/promises";
20721
20918
  import { createServer } from "node:net";
20722
- import { basename as basename9, dirname as dirname21, join as join40 } from "node:path";
20919
+ import { dirname as dirname22, join as join41 } from "node:path";
20723
20920
  import { fileURLToPath as fileURLToPath2 } from "node:url";
20724
20921
 
20725
20922
  // src/gatekeeper-pass-envelope.ts
@@ -20804,9 +21001,43 @@ async function requireGatekeeperPass(options) {
20804
21001
  }
20805
21002
  }
20806
21003
 
21004
+ // src/host-native-method.ts
21005
+ import { lstat as lstat7, mkdir as mkdir5, readlink, realpath as realpath6, symlink } from "node:fs/promises";
21006
+ import { basename as basename9, dirname as dirname18, join as join36 } from "node:path";
21007
+ var packagedMethodsDir = (root) => join36(root, "resources", "methods");
21008
+ function hostMethodSkills(methods) {
21009
+ return Object.freeze(methods.flatMap((method) => {
21010
+ if (method.kind !== "skill") return [];
21011
+ const name = basename9(dirname18(method.path));
21012
+ return name ? [Object.freeze({ name })] : [];
21013
+ }));
21014
+ }
21015
+ async function installWorkspaceMethodSkills(cwd, packageRoot) {
21016
+ const target = await realpath6(packagedMethodsDir(packageRoot));
21017
+ const link = join36(cwd, ".agents", "skills");
21018
+ try {
21019
+ const stat2 = await lstat7(link);
21020
+ if (!stat2.isSymbolicLink() || await realpath6(link) !== target) {
21021
+ const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
21022
+ throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
21023
+ }
21024
+ return;
21025
+ } catch (error) {
21026
+ if (error.code !== "ENOENT") throw error;
21027
+ }
21028
+ await mkdir5(dirname18(link), { recursive: true });
21029
+ try {
21030
+ await symlink(target, link);
21031
+ } catch (error) {
21032
+ if (error.code !== "EEXIST") throw error;
21033
+ if (await realpath6(link).catch(() => "") !== target) {
21034
+ throw new Error(`workspace method catalog conflict at ${link}`);
21035
+ }
21036
+ }
21037
+ }
21038
+
20807
21039
  // src/role-envelope.ts
20808
21040
  init_packaged_role_registry();
20809
- init_method_skill();
20810
21041
 
20811
21042
  // src/role-runtime.ts
20812
21043
  init_host_contracts();
@@ -20814,7 +21045,7 @@ init_sitian_facade();
20814
21045
  init_submission_ledger();
20815
21046
  init_collector_ledger();
20816
21047
  import { readFileSync as readFileSync6, writeSync as writeSync4 } from "node:fs";
20817
- import { join as join39 } from "node:path";
21048
+ import { join as join40 } from "node:path";
20818
21049
  import { Value as Value4 } from "typebox/value";
20819
21050
 
20820
21051
  // src/activation-trace.ts
@@ -20864,7 +21095,7 @@ import {
20864
21095
  openSync as openSync2,
20865
21096
  writeSync
20866
21097
  } from "node:fs";
20867
- import { dirname as dirname18, isAbsolute as isAbsolute10, resolve as resolve15 } from "node:path";
21098
+ import { dirname as dirname19, isAbsolute as isAbsolute10, resolve as resolve15 } from "node:path";
20868
21099
 
20869
21100
  // src/activation-ledger-session.ts
20870
21101
  init_activation_ledger_topology();
@@ -21013,7 +21244,7 @@ function appendActivationLedgerLine(ledgerPath, line2, options) {
21013
21244
  }
21014
21245
  const resolvedLedger = resolve15(ledgerPath);
21015
21246
  const resolvedHome = resolve15(options.ledgerHome);
21016
- const parent = dirname18(resolvedLedger);
21247
+ const parent = dirname19(resolvedLedger);
21017
21248
  ensureRealDirectoryTree(resolvedHome, parent);
21018
21249
  assertLedgerFileInsideHome(resolvedLedger, resolvedHome);
21019
21250
  if (typeof constants2.O_NOFOLLOW !== "number") {
@@ -21373,20 +21604,20 @@ init_collector_github();
21373
21604
 
21374
21605
  // src/collector-handbook.ts
21375
21606
  import { readFile as readFile19 } from "node:fs/promises";
21376
- import { join as join37, sep as sep5 } from "node:path";
21607
+ import { join as join38, sep as sep5 } from "node:path";
21377
21608
 
21378
21609
  // src/atomic-write.ts
21379
21610
  import { randomUUID as randomUUID7 } from "node:crypto";
21380
- import { rename as rename3, rm as rm3, writeFile as writeFile11 } from "node:fs/promises";
21381
- import { dirname as dirname19, join as join36 } from "node:path";
21611
+ import { rename as rename3, rm as rm4, writeFile as writeFile11 } from "node:fs/promises";
21612
+ import { dirname as dirname20, join as join37 } from "node:path";
21382
21613
  async function writeFileAtomically(destination, contents) {
21383
- const parent = dirname19(destination);
21384
- const temporary = join36(parent, `.atomic-write-${randomUUID7()}.tmp`);
21614
+ const parent = dirname20(destination);
21615
+ const temporary = join37(parent, `.atomic-write-${randomUUID7()}.tmp`);
21385
21616
  try {
21386
21617
  await writeFile11(temporary, contents);
21387
21618
  await rename3(temporary, destination);
21388
21619
  } catch (error) {
21389
- await rm3(temporary, { force: true }).catch(() => void 0);
21620
+ await rm4(temporary, { force: true }).catch(() => void 0);
21390
21621
  throw error;
21391
21622
  }
21392
21623
  }
@@ -21507,7 +21738,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
21507
21738
  throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
21508
21739
  }
21509
21740
  const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
21510
- const root = join37(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
21741
+ const root = join38(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
21511
21742
  return { ledgerHome, bookKey, root };
21512
21743
  }
21513
21744
  function collectorHandbookRepoFileName(repositoryCanonical) {
@@ -21519,9 +21750,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
21519
21750
  return `${repositoryCanonical.replaceAll("/", "__")}.md`;
21520
21751
  }
21521
21752
  function createCollectorHandbookStore(input) {
21522
- const generalPath = join37(input.handbookRoot, "general.md");
21523
- const repoDir = join37(input.handbookRoot, "repos");
21524
- const repoPath = join37(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
21753
+ const generalPath = join38(input.handbookRoot, "general.md");
21754
+ const repoDir = join38(input.handbookRoot, "repos");
21755
+ const repoPath = join38(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
21525
21756
  const assertHandbookBudget = (body, label) => {
21526
21757
  const byteLength = Buffer.byteLength(body, "utf8");
21527
21758
  if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
@@ -24929,7 +25160,7 @@ function readDiaristTicketAssertion(submitted) {
24929
25160
  function readRoleRunCoordinates(ctx, label) {
24930
25161
  const runDirectory = runDirectoryFromHostContext(ctx);
24931
25162
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
24932
- const admittedPath = join39(runDirectory, "admitted-request.json");
25163
+ const admittedPath = join40(runDirectory, "admitted-request.json");
24933
25164
  const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
24934
25165
  if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
24935
25166
  throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
@@ -25162,6 +25393,7 @@ function createRoleRuntimeExtension(dependencies) {
25162
25393
  });
25163
25394
  let admitted = false;
25164
25395
  let selectedRole;
25396
+ let roleReferenceMaterials = "";
25165
25397
  let activeReviewerParent;
25166
25398
  let reviewerOriginalRequest;
25167
25399
  let reviewerExpansionCaptured = false;
@@ -25255,10 +25487,10 @@ function createRoleRuntimeExtension(dependencies) {
25255
25487
  activeReviewerParent.skillBinding.name,
25256
25488
  text
25257
25489
  ) ?? text;
25258
- return text === event.text ? { action: "continue" } : { action: "transform", text };
25259
25490
  }
25260
- return text === event.text ? { action: "continue" } : { action: "transform", text };
25491
+ return { action: "continue" };
25261
25492
  });
25493
+ roleHost.on("before_agent_start", () => roleReferenceMaterials === "" ? void 0 : { readingMaterial: { kind: "role-reference-materials", content: roleReferenceMaterials } });
25262
25494
  roleHost.on("before_agent_start", async (event, ctx) => {
25263
25495
  const role = roleHost.getFlag(ROLE_FLAG.name);
25264
25496
  const prompt = event.prompt;
@@ -25824,6 +26056,7 @@ function createRoleRuntimeExtension(dependencies) {
25824
26056
  }
25825
26057
  admitted = false;
25826
26058
  selectedRole = void 0;
26059
+ roleReferenceMaterials = "";
25827
26060
  activeReviewerParent = void 0;
25828
26061
  reviewerOriginalRequest = void 0;
25829
26062
  reviewerExpansionCaptured = false;
@@ -25958,6 +26191,7 @@ function createRoleRuntimeExtension(dependencies) {
25958
26191
  }
25959
26192
  }
25960
26193
  await executeActivationStage(entry.role, activationStage(entry.role, runtime), { clock, writeTrace });
26194
+ roleReferenceMaterials = await dependencies.loadRoleReferenceMaterials?.(entry.role) ?? "";
25961
26195
  if (!engineDetourRegistered) {
25962
26196
  engineDetourRegistered = registerEngineDetourTool(roleHost, hostActions);
25963
26197
  }
@@ -25992,19 +26226,6 @@ function createRoleRuntimeExtension(dependencies) {
25992
26226
  init_role_activation_flags();
25993
26227
  init_submission_correctable_error();
25994
26228
  init_navigator_invocation_identity();
25995
- function buildSkillExpansion(methodSkills, prompt) {
25996
- if (methodSkills.size !== 1) return void 0;
25997
- const entry = methodSkills.entries().next().value;
25998
- if (entry === void 0) return void 0;
25999
- const [name, method] = entry;
26000
- return Object.freeze({
26001
- name,
26002
- location: method.path,
26003
- content: method.body,
26004
- // Non-pi typed chain keeps original task bytes (ticket #822 r3); no consumer trim.
26005
- userMessage: prompt
26006
- });
26007
- }
26008
26229
  async function listen(server, path) {
26009
26230
  await new Promise((resolve21, reject) => {
26010
26231
  server.once("error", reject);
@@ -26039,21 +26260,14 @@ async function prepareRoleEnvelope(options) {
26039
26260
  const calls = [];
26040
26261
  const customEntries = [];
26041
26262
  const sessionEntries = [];
26042
- const methodSkills = /* @__PURE__ */ new Map();
26043
26263
  let preferredTools = [];
26044
26264
  let rejection;
26045
26265
  let infrastructureRoundFailure;
26046
26266
  const hostAbort = new AbortController();
26047
26267
  const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID8();
26048
- await mkdir5(request.runDirectory, { recursive: true });
26049
- for (const method of request.methods) {
26050
- if (method.kind !== "skill") continue;
26051
- const name = basename9(dirname21(method.path));
26052
- const raw = await readFile20(method.path, "utf8");
26053
- methodSkills.set(name, { path: method.path, body: stripSkillFrontmatter(raw).trim() });
26054
- }
26055
- let sessionFile = options.sessionFile ?? join40(request.runDirectory, "session", "session.jsonl");
26056
- await mkdir5(dirname21(sessionFile), { recursive: true });
26268
+ await mkdir6(request.runDirectory, { recursive: true });
26269
+ let sessionFile = options.sessionFile ?? join41(request.runDirectory, "session", "session.jsonl");
26270
+ await mkdir6(dirname22(sessionFile), { recursive: true });
26057
26271
  if (request.continuation.kind !== "resume") {
26058
26272
  try {
26059
26273
  await writeFile12(
@@ -26084,7 +26298,7 @@ async function prepareRoleEnvelope(options) {
26084
26298
  getLeafEntry: () => sessionEntries.at(-1),
26085
26299
  getLeafId: () => runId,
26086
26300
  getEntries: () => sessionEntries,
26087
- getSessionDir: () => dirname21(sessionFile),
26301
+ getSessionDir: () => dirname22(sessionFile),
26088
26302
  getSessionFile: () => sessionFile,
26089
26303
  getHeader: () => ({ type: "session", id: runId }),
26090
26304
  setSessionFile(path) {
@@ -26119,8 +26333,9 @@ async function prepareRoleEnvelope(options) {
26119
26333
  deliverSubmissionRejection(_value) {
26120
26334
  },
26121
26335
  capabilities: {
26122
- skillExpansion(prompt) {
26123
- return buildSkillExpansion(methodSkills, prompt);
26336
+ // #922: native loaders own expansion; package does not pre-read bodies (ADR 0032).
26337
+ skillExpansion() {
26338
+ return void 0;
26124
26339
  }
26125
26340
  },
26126
26341
  registerFlag(name, definition) {
@@ -26459,10 +26674,9 @@ async function prepareRoleEnvelope(options) {
26459
26674
  message: { role: "user", content: prompt }
26460
26675
  });
26461
26676
  }
26462
- const methodPrompt = (await Promise.all(request.methods.map(({ path }) => readFile20(path, "utf8")))).join("\n\n");
26463
26677
  const promptResults = await emit("before_agent_start", {
26464
26678
  prompt,
26465
- systemPrompt: methodPrompt,
26679
+ systemPrompt: "",
26466
26680
  systemPromptOptions: {}
26467
26681
  });
26468
26682
  const systemPromptParts = promptResults.flatMap((value) => {
@@ -26470,7 +26684,7 @@ async function prepareRoleEnvelope(options) {
26470
26684
  if (!("systemPrompt" in value) || typeof value.systemPrompt !== "string") return [];
26471
26685
  return [value.systemPrompt];
26472
26686
  });
26473
- const systemPromptBody = systemPromptParts.length > 0 ? systemPromptParts.join("\n\n") : methodPrompt;
26687
+ const systemPromptBody = systemPromptParts.join("\n\n");
26474
26688
  const readingMaterials = [];
26475
26689
  for (const value of promptResults) {
26476
26690
  if (typeof value !== "object" || value === null) continue;
@@ -26483,6 +26697,13 @@ async function prepareRoleEnvelope(options) {
26483
26697
  throw new Error(`terminating tool not registered after activation: ${terminatingToolName}`);
26484
26698
  }
26485
26699
  const jsonSchema = terminatingToolJsonSchema(terminating.parameters);
26700
+ if (request.host === "codex" && hostMethodSkills(request.methods).length > 0) {
26701
+ const packageRoot = options.dependencies.packageRoot;
26702
+ if (typeof packageRoot !== "string" || packageRoot === "") {
26703
+ throw new Error("codex project Skill catalog requires packageRoot");
26704
+ }
26705
+ await installWorkspaceMethodSkills(request.cwd, packageRoot);
26706
+ }
26486
26707
  return {
26487
26708
  mcpServers: [{
26488
26709
  name: `ak-${request.activation.role}`,
@@ -26517,18 +26738,18 @@ async function prepareRoleEnvelope(options) {
26517
26738
  }
26518
26739
 
26519
26740
  // src/role-runtime-dependencies.ts
26520
- import { readFile as readFile23 } from "node:fs/promises";
26741
+ import { readFile as readFile22 } from "node:fs/promises";
26521
26742
  import { fileURLToPath as fileURLToPath3 } from "node:url";
26522
26743
 
26523
26744
  // src/canonical-skill-binding.ts
26524
- import { readFile as readFile21, realpath as realpath6 } from "node:fs/promises";
26745
+ import { readFile as readFile20, realpath as realpath7 } from "node:fs/promises";
26525
26746
  import { homedir } from "node:os";
26526
- import { dirname as dirname22, resolve as resolve18 } from "node:path";
26747
+ import { dirname as dirname23, resolve as resolve18 } from "node:path";
26527
26748
  import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
26528
26749
  function captureCanonicalSkillExpansion(name, snapshot, configuredPath, evidence, originalRequest) {
26529
26750
  const matchedPath = evidence?.location === configuredPath ? configuredPath : evidence?.location === snapshot.path ? snapshot.path : void 0;
26530
26751
  const expectedContent = matchedPath === void 0 ? void 0 : snapshot.body;
26531
- const prefixedContent = matchedPath === void 0 ? void 0 : `References are relative to ${dirname22(matchedPath)}.
26752
+ const prefixedContent = matchedPath === void 0 ? void 0 : `References are relative to ${dirname23(matchedPath)}.
26532
26753
 
26533
26754
  ${snapshot.body}`;
26534
26755
  if (evidence?.name !== name || matchedPath === void 0 || evidence.content !== expectedContent && evidence.content !== prefixedContent || evidence.userMessage !== originalRequest) {
@@ -26553,8 +26774,8 @@ async function loadCanonicalSkillBinding(name) {
26553
26774
  let path;
26554
26775
  let raw;
26555
26776
  try {
26556
- path = await realpath6(configuredPath);
26557
- raw = await readFile21(path, "utf8");
26777
+ path = await realpath7(configuredPath);
26778
+ raw = await readFile20(path, "utf8");
26558
26779
  } catch (error) {
26559
26780
  throw new CanonicalSkillUnavailableError(name, configuredPath, error);
26560
26781
  }
@@ -26565,7 +26786,7 @@ async function loadCanonicalSkillBinding(name) {
26565
26786
  const snapshot = Object.freeze({
26566
26787
  raw,
26567
26788
  path,
26568
- baseDir: dirname22(path),
26789
+ baseDir: dirname23(path),
26569
26790
  body,
26570
26791
  snapshotIdentity: Object.freeze({ text: raw })
26571
26792
  });
@@ -26593,7 +26814,7 @@ init_doctor_evidence();
26593
26814
  // src/navigator-work-context.ts
26594
26815
  init_doctor_evidence();
26595
26816
  init_host_contracts();
26596
- import { readFile as readFile22 } from "node:fs/promises";
26817
+ import { readFile as readFile21 } from "node:fs/promises";
26597
26818
  import { resolve as resolve19 } from "node:path";
26598
26819
  init_notary_source_run();
26599
26820
  init_packaged_role_registry();
@@ -26606,7 +26827,7 @@ function navigatorInputReference(getFlag, role) {
26606
26827
  }
26607
26828
  async function loadNavigatorWorkContext(options) {
26608
26829
  const reference = navigatorInputReference(options.getFlag, options.role);
26609
- const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile22(reference, "utf8");
26830
+ const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile21(reference, "utf8");
26610
26831
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
26611
26832
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
26612
26833
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -26663,7 +26884,7 @@ async function loadNavigatorWorkContext(options) {
26663
26884
  let authorityMaterial;
26664
26885
  for (const path of authorityFiles) {
26665
26886
  try {
26666
- const content = await readFile22(path, "utf8");
26887
+ const content = await readFile21(path, "utf8");
26667
26888
  if (content.trim() !== "") {
26668
26889
  authorityMaterial = content;
26669
26890
  break;
@@ -26688,7 +26909,7 @@ async function loadNavigatorWorkContext(options) {
26688
26909
  init_notary_source_run();
26689
26910
 
26690
26911
  // src/package-resources/method-skill-binding.ts
26691
- import { dirname as dirname23 } from "node:path";
26912
+ import { dirname as dirname24 } from "node:path";
26692
26913
  init_method_skill();
26693
26914
  async function loadPackagedCanonicalSkillBinding(packageRoot, name) {
26694
26915
  const material = await loadPackagedMethodSkillMaterial(packageRoot, name);
@@ -26696,7 +26917,7 @@ async function loadPackagedCanonicalSkillBinding(packageRoot, name) {
26696
26917
  const snapshot = Object.freeze({
26697
26918
  raw: material.raw,
26698
26919
  path: material.skillPath,
26699
- baseDir: dirname23(material.skillPath),
26920
+ baseDir: dirname24(material.skillPath),
26700
26921
  body: material.body,
26701
26922
  snapshotIdentity: Object.freeze({ text: material.raw })
26702
26923
  });
@@ -26725,19 +26946,23 @@ var navigatorRoutePlaybookPath = fileURLToPath3(
26725
26946
  var collectorHandbookSeedPath = fileURLToPath3(
26726
26947
  new URL("../resources/collector-bot-handbook.md", import.meta.url)
26727
26948
  );
26949
+ function loadPackagedRoleReferenceMaterials(role) {
26950
+ return role === "auditor" ? loadAuditorReferenceMaterialsFromSubjectInput() : loadMainRoleReferenceMaterials(role);
26951
+ }
26728
26952
  function createRoleRuntimeDependencies(packageRoot) {
26729
26953
  const doctorAuditor = createPiDoctorAuditor();
26730
26954
  const navigatorSessionFactory = createNativeNavigatorSessionFactory();
26731
26955
  return {
26732
26956
  packageRoot,
26957
+ loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
26733
26958
  loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
26734
26959
  loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
26735
- loadFixPacket: (path) => readFile23(path, "utf8"),
26960
+ loadFixPacket: (path) => readFile22(path, "utf8"),
26736
26961
  loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
26737
- loadCoderTask: (path) => readFile23(path, "utf8"),
26962
+ loadCoderTask: (path) => readFile22(path, "utf8"),
26738
26963
  loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
26739
26964
  loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
26740
- loadCollectorHandbookSeed: () => readFile23(collectorHandbookSeedPath, "utf8"),
26965
+ loadCollectorHandbookSeed: () => readFile22(collectorHandbookSeedPath, "utf8"),
26741
26966
  createCollectorTransport: () => createGhCollectorGitHubTransport(),
26742
26967
  loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
26743
26968
  loadDoctorCase,
@@ -26752,7 +26977,7 @@ function createRoleRuntimeDependencies(packageRoot) {
26752
26977
  loadSecretariatSoul: () => loadMainRoleSessionMaterials("secretariat"),
26753
26978
  loadNotarySourceRun: loadNotarySourceRunLocator,
26754
26979
  loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
26755
- loadMergerInput: async (path) => JSON.parse(await readFile23(path, "utf8")),
26980
+ loadMergerInput: async (path) => JSON.parse(await readFile22(path, "utf8")),
26756
26981
  async loadCanonicalSkillBinding(name) {
26757
26982
  if (name === "tdd") {
26758
26983
  return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
@@ -26778,7 +27003,7 @@ function createRoleRuntimeDependencies(packageRoot) {
26778
27003
  authority: options.authority,
26779
27004
  invocationId: options.invocationId,
26780
27005
  loadSoul: () => loadMainRoleSessionMaterials("navigator"),
26781
- loadRoutePlaybook: () => readFile23(navigatorRoutePlaybookPath, "utf8"),
27006
+ loadRoutePlaybook: () => readFile22(navigatorRoutePlaybookPath, "utf8"),
26782
27007
  loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
26783
27008
  createSession: navigatorSessionFactory,
26784
27009
  ...options.contextError === void 0 ? {} : { contextError: options.contextError },
@@ -26791,9 +27016,9 @@ function createRoleRuntimeDependencies(packageRoot) {
26791
27016
  init_session_identity();
26792
27017
 
26793
27018
  // src/acp-host/description.ts
26794
- import { join as join41 } from "node:path";
27019
+ import { join as join42 } from "node:path";
26795
27020
  function resolveAcpBinary(description, operatorHome) {
26796
- return join41(operatorHome, ...description.binaryFromHome);
27021
+ return join42(operatorHome, ...description.binaryFromHome);
26797
27022
  }
26798
27023
  function acpStdioArgs(description, model, seat) {
26799
27024
  const { prefix, suffix, modelFlag, thinkingFlag } = description.argv;
@@ -27239,13 +27464,13 @@ function createAcpRoleTurnHost(config) {
27239
27464
 
27240
27465
  // src/acp-host/seat-profile-soul.ts
27241
27466
  import { constants as constants3 } from "node:fs";
27242
- import { access as access4, copyFile, lstat as lstat7, mkdir as mkdir6, readlink, symlink, unlink as unlink3 } from "node:fs/promises";
27243
- import { dirname as dirname24, join as join42, relative as relative3, resolve as resolve20 } from "node:path";
27467
+ import { access as access4, copyFile, lstat as lstat8, mkdir as mkdir7, readlink as readlink2, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
27468
+ import { dirname as dirname25, join as join43, relative as relative3, resolve as resolve20 } from "node:path";
27244
27469
  function seatProfileName(spec, role) {
27245
27470
  return `${spec.namePrefix}${role}`;
27246
27471
  }
27247
27472
  function packageRoleSoulPath(packageRoot, role) {
27248
- return join42(packageRoot, "souls", `${role}.md`);
27473
+ return join43(packageRoot, "souls", `${role}.md`);
27249
27474
  }
27250
27475
  async function pathExists2(path) {
27251
27476
  try {
@@ -27262,26 +27487,26 @@ async function ensureSeatProfileSoul(options) {
27262
27487
  if (!await pathExists2(soulTarget)) {
27263
27488
  throw new Error(`packaged role soul missing: ${soulTarget}`);
27264
27489
  }
27265
- const profilesRoot = join42(operatorHome, ...spec.profilesRootFromHome);
27266
- const profileDir = join42(profilesRoot, profileName);
27267
- const hostRoot = dirname24(profilesRoot);
27268
- const soulPath = join42(profileDir, spec.soulFileName);
27490
+ const profilesRoot = join43(operatorHome, ...spec.profilesRootFromHome);
27491
+ const profileDir = join43(profilesRoot, profileName);
27492
+ const hostRoot = dirname25(profilesRoot);
27493
+ const soulPath = join43(profileDir, spec.soulFileName);
27269
27494
  if (!await pathExists2(profileDir)) {
27270
- await mkdir6(profileDir, { recursive: true });
27495
+ await mkdir7(profileDir, { recursive: true });
27271
27496
  for (const name of ["auth.json", ".env", "config.yaml"]) {
27272
- const source = join42(hostRoot, name);
27497
+ const source = join43(hostRoot, name);
27273
27498
  if (!await pathExists2(source)) continue;
27274
- await copyFile(source, join42(profileDir, name));
27499
+ await copyFile(source, join43(profileDir, name));
27275
27500
  }
27276
27501
  } else {
27277
- await mkdir6(profileDir, { recursive: true });
27502
+ await mkdir7(profileDir, { recursive: true });
27278
27503
  }
27279
27504
  const desiredLink = relative3(profileDir, soulTarget);
27280
27505
  let current;
27281
27506
  try {
27282
- const st = await lstat7(soulPath);
27507
+ const st = await lstat8(soulPath);
27283
27508
  if (st.isSymbolicLink()) {
27284
- current = await readlink(soulPath);
27509
+ current = await readlink2(soulPath);
27285
27510
  }
27286
27511
  } catch {
27287
27512
  current = void 0;
@@ -27292,7 +27517,7 @@ async function ensureSeatProfileSoul(options) {
27292
27517
  if (await pathExists2(soulPath) || current !== void 0) {
27293
27518
  await unlink3(soulPath);
27294
27519
  }
27295
- await symlink(desiredLink, soulPath);
27520
+ await symlink2(desiredLink, soulPath);
27296
27521
  return profileName;
27297
27522
  }
27298
27523
 
@@ -27312,7 +27537,6 @@ function createProductionAcpRoleTurnHost(options) {
27312
27537
  const { packageRoot, principalAuthority, description, hostName } = options;
27313
27538
  const env = {
27314
27539
  ...process.env,
27315
- ...description.childEnv,
27316
27540
  AK_PACKAGE_ROOT: packageRoot
27317
27541
  };
27318
27542
  return createComposedAcpRoleTurnHost({