@akagilnc/pi-workflow-roles 0.1.4649 → 0.1.4673

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.
@@ -1740,10 +1740,10 @@ __export(session_assistant_usage_exports, {
1740
1740
  });
1741
1741
  import { join as join9 } from "node:path";
1742
1742
  async function readAssistantUsageFromSessionFile(sessionFile) {
1743
- const { readFile: readFile24 } = await import("node:fs/promises");
1743
+ const { readFile: readFile25 } = await import("node:fs/promises");
1744
1744
  let text;
1745
1745
  try {
1746
- text = await readFile24(sessionFile, "utf8");
1746
+ text = await readFile25(sessionFile, "utf8");
1747
1747
  } catch (error) {
1748
1748
  if (error?.code === "ENOENT") return void 0;
1749
1749
  throw error;
@@ -11931,10 +11931,10 @@ function pairGateRounds(volumes) {
11931
11931
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
11932
11932
  }
11933
11933
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
11934
- const { readFile: readFile24 } = await import("node:fs/promises");
11934
+ const { readFile: readFile25 } = await import("node:fs/promises");
11935
11935
  let raw;
11936
11936
  try {
11937
- raw = JSON.parse(await readFile24(pointerPath, "utf8"));
11937
+ raw = JSON.parse(await readFile25(pointerPath, "utf8"));
11938
11938
  } catch (error) {
11939
11939
  throw new Error(
11940
11940
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
@@ -22502,7 +22502,7 @@ async function requireGatekeeperPass(options) {
22502
22502
  }
22503
22503
 
22504
22504
  // src/host-native-method.ts
22505
- import { lstat as lstat7, mkdir as mkdir6, readlink, realpath as realpath7, symlink } from "node:fs/promises";
22505
+ import { access as access4, lstat as lstat7, mkdir as mkdir6, readdir as readdir9, readFile as readFile20, readlink, realpath as realpath7, symlink } from "node:fs/promises";
22506
22506
  import { basename as basename9, dirname as dirname18, join as join36 } from "node:path";
22507
22507
  var packagedMethodsDir = (root) => join36(root, "resources", "methods");
22508
22508
  function hostMethodSkills(methods) {
@@ -22512,25 +22512,103 @@ function hostMethodSkills(methods) {
22512
22512
  return name ? [Object.freeze({ name })] : [];
22513
22513
  }));
22514
22514
  }
22515
+ var isEnoent4 = (error) => error.code === "ENOENT";
22516
+ async function packagedMethodSkillNames(packagedMethodsRealpath) {
22517
+ const entries = await readdir9(packagedMethodsRealpath, { withFileTypes: true });
22518
+ const names = [];
22519
+ for (const entry of entries) {
22520
+ if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
22521
+ try {
22522
+ await access4(join36(packagedMethodsRealpath, entry.name, "SKILL.md"));
22523
+ } catch (error) {
22524
+ if (isEnoent4(error)) continue;
22525
+ throw error;
22526
+ }
22527
+ names.push(entry.name);
22528
+ }
22529
+ return names;
22530
+ }
22531
+ async function packagedSkillFileBytes(skillDir) {
22532
+ try {
22533
+ await access4(join36(skillDir, "SKILL.md"));
22534
+ } catch (error) {
22535
+ if (isEnoent4(error)) return void 0;
22536
+ throw error;
22537
+ }
22538
+ const files = /* @__PURE__ */ new Map();
22539
+ async function walk(dir, prefix) {
22540
+ const entries = await readdir9(dir, { withFileTypes: true });
22541
+ for (const entry of entries) {
22542
+ const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
22543
+ const full = join36(dir, entry.name);
22544
+ if (entry.isDirectory()) {
22545
+ await walk(full, rel);
22546
+ continue;
22547
+ }
22548
+ if (entry.isFile()) {
22549
+ files.set(rel, await readFile20(full));
22550
+ }
22551
+ }
22552
+ }
22553
+ await walk(skillDir, "");
22554
+ return files;
22555
+ }
22556
+ async function catalogPublishesPackagedSkill(catalogSkillDir, required) {
22557
+ for (const [rel, bytes] of required) {
22558
+ let other;
22559
+ try {
22560
+ other = await readFile20(join36(catalogSkillDir, rel));
22561
+ } catch (error) {
22562
+ if (isEnoent4(error)) return false;
22563
+ throw error;
22564
+ }
22565
+ if (!bytes.equals(other)) return false;
22566
+ }
22567
+ return true;
22568
+ }
22569
+ async function isCompatibleMethodCatalog(link, packagedMethodsRealpath) {
22570
+ const stat2 = await lstat7(link);
22571
+ if (!stat2.isSymbolicLink()) return false;
22572
+ let resolved;
22573
+ try {
22574
+ resolved = await realpath7(link);
22575
+ } catch (error) {
22576
+ if (isEnoent4(error)) return false;
22577
+ throw error;
22578
+ }
22579
+ if (resolved === packagedMethodsRealpath) return true;
22580
+ const names = await packagedMethodSkillNames(packagedMethodsRealpath);
22581
+ if (names.length === 0) return false;
22582
+ for (const name of names) {
22583
+ const required = await packagedSkillFileBytes(join36(packagedMethodsRealpath, name));
22584
+ if (required === void 0) return false;
22585
+ if (!await catalogPublishesPackagedSkill(join36(resolved, name), required)) return false;
22586
+ }
22587
+ return true;
22588
+ }
22515
22589
  async function installWorkspaceMethodSkills(cwd, packageRoot) {
22516
22590
  const target = await realpath7(packagedMethodsDir(packageRoot));
22517
22591
  const link = join36(cwd, ".agents", "skills");
22592
+ let present;
22518
22593
  try {
22519
- const stat2 = await lstat7(link);
22520
- if (!stat2.isSymbolicLink() || await realpath7(link) !== target) {
22521
- const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
22522
- throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
22523
- }
22524
- return;
22594
+ await lstat7(link);
22595
+ present = true;
22525
22596
  } catch (error) {
22526
- if (error.code !== "ENOENT") throw error;
22597
+ if (!isEnoent4(error)) throw error;
22598
+ present = false;
22599
+ }
22600
+ if (present) {
22601
+ if (await isCompatibleMethodCatalog(link, target)) return;
22602
+ const stat2 = await lstat7(link);
22603
+ const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
22604
+ throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
22527
22605
  }
22528
22606
  await mkdir6(dirname18(link), { recursive: true });
22529
22607
  try {
22530
22608
  await symlink(target, link);
22531
22609
  } catch (error) {
22532
22610
  if (error.code !== "EEXIST") throw error;
22533
- if (await realpath7(link).catch(() => "") !== target) {
22611
+ if (!await isCompatibleMethodCatalog(link, target)) {
22534
22612
  throw new Error(`workspace method catalog conflict at ${link}`);
22535
22613
  }
22536
22614
  }
@@ -22977,7 +23055,7 @@ init_collector_evidence();
22977
23055
  init_collector_github();
22978
23056
 
22979
23057
  // src/collector-handbook.ts
22980
- import { readFile as readFile20 } from "node:fs/promises";
23058
+ import { readFile as readFile21 } from "node:fs/promises";
22981
23059
  import { join as join38, sep as sep6 } from "node:path";
22982
23060
 
22983
23061
  // src/atomic-write.ts
@@ -23140,7 +23218,7 @@ function createCollectorHandbookStore(input) {
23140
23218
  ensureRealDirectoryTree(input.ledgerHome, parentDir2);
23141
23219
  assertLedgerFileInsideHome(path, input.ledgerHome);
23142
23220
  try {
23143
- const body = await readFile20(path, "utf8");
23221
+ const body = await readFile21(path, "utf8");
23144
23222
  assertHandbookBudget(body, "\u6B63\u6587");
23145
23223
  return body;
23146
23224
  } catch (error) {
@@ -24548,7 +24626,6 @@ function createNativeNavigatorSessionFactory(deps) {
24548
24626
  let providerFailure;
24549
24627
  let noReceipt;
24550
24628
  let disposed = false;
24551
- let inFlightPrompt;
24552
24629
  let hostRunId = readNavigatorHostRunPointer(sessionManager.getEntries());
24553
24630
  const summon = deps?.summonPublicRole ?? (async (options) => {
24554
24631
  const { summonPublicRole: summonPublicRole2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
@@ -24561,85 +24638,87 @@ function createNativeNavigatorSessionFactory(deps) {
24561
24638
  }
24562
24639
  providerFailure = void 0;
24563
24640
  noReceipt = void 0;
24564
- const run = (async () => {
24565
- try {
24566
- const summonHome = await resolveNavigatorLedgerHome(context);
24567
- const resumeRunId = hostRunId;
24568
- const baseSummon = {
24569
- role: "navigator",
24570
- argv: [text],
24571
- cwd: context.cwd,
24572
- ...summonHome === void 0 ? {} : { home: summonHome }
24573
- };
24574
- const resumable = deps?.hostRunResumable ?? navigatorHostRunResumable;
24575
- let summoned;
24576
- if (resumeRunId === void 0 || summonHome === void 0) {
24577
- summoned = await summon(baseSummon);
24578
- } else if (await resumable(summonHome, resumeRunId)) {
24641
+ try {
24642
+ const summonHome = await resolveNavigatorLedgerHome(context);
24643
+ if (disposed) return;
24644
+ const resumeRunId = hostRunId;
24645
+ const baseSummon = {
24646
+ role: "navigator",
24647
+ argv: [text],
24648
+ cwd: context.cwd,
24649
+ ...summonHome === void 0 ? {} : { home: summonHome },
24650
+ ...context.signal === void 0 ? {} : { signal: context.signal }
24651
+ };
24652
+ const resumable = deps?.hostRunResumable ?? navigatorHostRunResumable;
24653
+ let summoned;
24654
+ if (resumeRunId === void 0 || summonHome === void 0) {
24655
+ if (disposed) return;
24656
+ summoned = await summon(baseSummon);
24657
+ } else {
24658
+ const canResume = await resumable(summonHome, resumeRunId);
24659
+ if (disposed) return;
24660
+ if (canResume) {
24579
24661
  summoned = await summon({ ...baseSummon, resumeRunId });
24580
24662
  } else {
24581
24663
  hostRunId = void 0;
24582
24664
  summoned = await summon(baseSummon);
24583
24665
  }
24584
- const outcome = summoned.terminal?.roleOutcome;
24585
- if (outcome === void 0) {
24586
- const detail = summoned.stderr?.trim() || `exit ${summoned.exitCode}`;
24587
- providerFailure = { source: "transport", cause: "unknown" };
24588
- throw navigatorUnavailableError(
24589
- providerFailure.source,
24590
- new Error(`Navigator public summon produced no terminal (${detail})`),
24591
- providerFailure.cause
24592
- );
24593
- }
24594
- if (outcome.kind === "failure") {
24595
- providerFailure = navigatorProviderFailureFromPublicTerminal(outcome);
24596
- throw navigatorUnavailableError(
24597
- providerFailure.source,
24598
- new Error(outcome.diagnostic),
24599
- providerFailure.cause
24600
- );
24601
- }
24602
- if (outcome.kind === "no_receipt") {
24603
- noReceipt = outcome;
24604
- return;
24605
- }
24606
- const runDirectory = summoned.runDirectory ?? (typeof summoned.admitted?.runDirectory === "string" ? summoned.admitted.runDirectory : void 0);
24607
- if (typeof runDirectory === "string" && runDirectory.trim() !== "") {
24608
- const nextRunId = runIdFromNavigatorDirectory(runDirectory);
24609
- if (nextRunId !== void 0) {
24610
- hostRunId = nextRunId;
24611
- sessionManager.appendCustomEntry(NAVIGATOR_HOST_RUN_POINTER_ENTRY, { runId: nextRunId });
24612
- }
24613
- }
24614
- if (outcome.kind !== "accepted") {
24615
- return;
24616
- }
24617
- const { navigatorProseFromUnknown: navigatorProseFromUnknown2 } = await Promise.resolve().then(() => (init_navigator_output(), navigator_output_exports));
24618
- const proseParts = [];
24619
- for (const payload of outcome.payloads ?? []) {
24620
- const prose = navigatorProseFromUnknown2(payload);
24621
- if (prose !== void 0) proseParts.push(prose);
24622
- }
24623
- if (proseParts.length === 0) return;
24624
- await tool.execute(
24625
- "navigator-public-prepare",
24626
- { prose: proseParts.join("\n\n") },
24627
- void 0,
24628
- void 0,
24629
- context
24666
+ }
24667
+ if (disposed) return;
24668
+ const outcome = summoned.terminal?.roleOutcome;
24669
+ if (outcome === void 0) {
24670
+ const detail = summoned.stderr?.trim() || `exit ${summoned.exitCode}`;
24671
+ providerFailure = { source: "transport", cause: "unknown" };
24672
+ throw navigatorUnavailableError(
24673
+ providerFailure.source,
24674
+ new Error(`Navigator public summon produced no terminal (${detail})`),
24675
+ providerFailure.cause
24630
24676
  );
24631
- } catch (error) {
24632
- if (error instanceof NavigatorUnavailableError) throw error;
24633
- const fact = navigatorProviderFailureFromError(error);
24634
- providerFailure = fact ?? { source: "transport", cause: "unknown" };
24635
- throw navigatorUnavailableError(providerFailure.source, error, providerFailure.cause);
24636
24677
  }
24637
- })();
24638
- inFlightPrompt = run;
24639
- try {
24640
- await run;
24641
- } finally {
24642
- if (inFlightPrompt === run) inFlightPrompt = void 0;
24678
+ if (outcome.kind === "failure") {
24679
+ providerFailure = navigatorProviderFailureFromPublicTerminal(outcome);
24680
+ throw navigatorUnavailableError(
24681
+ providerFailure.source,
24682
+ new Error(outcome.diagnostic),
24683
+ providerFailure.cause
24684
+ );
24685
+ }
24686
+ if (outcome.kind === "no_receipt") {
24687
+ noReceipt = outcome;
24688
+ return;
24689
+ }
24690
+ const runDirectory = summoned.runDirectory ?? (typeof summoned.admitted?.runDirectory === "string" ? summoned.admitted.runDirectory : void 0);
24691
+ if (typeof runDirectory === "string" && runDirectory.trim() !== "") {
24692
+ const nextRunId = runIdFromNavigatorDirectory(runDirectory);
24693
+ if (nextRunId !== void 0) {
24694
+ hostRunId = nextRunId;
24695
+ sessionManager.appendCustomEntry(NAVIGATOR_HOST_RUN_POINTER_ENTRY, { runId: nextRunId });
24696
+ }
24697
+ }
24698
+ if (outcome.kind !== "accepted") {
24699
+ return;
24700
+ }
24701
+ const { navigatorProseFromUnknown: navigatorProseFromUnknown2 } = await Promise.resolve().then(() => (init_navigator_output(), navigator_output_exports));
24702
+ const proseParts = [];
24703
+ for (const payload of outcome.payloads ?? []) {
24704
+ const prose = navigatorProseFromUnknown2(payload);
24705
+ if (prose !== void 0) proseParts.push(prose);
24706
+ }
24707
+ if (proseParts.length === 0) return;
24708
+ if (disposed) return;
24709
+ await tool.execute(
24710
+ "navigator-public-prepare",
24711
+ { prose: proseParts.join("\n\n") },
24712
+ void 0,
24713
+ void 0,
24714
+ context
24715
+ );
24716
+ } catch (error) {
24717
+ if (disposed) return;
24718
+ if (error instanceof NavigatorUnavailableError) throw error;
24719
+ const fact = navigatorProviderFailureFromError(error);
24720
+ providerFailure = fact ?? { source: "transport", cause: "unknown" };
24721
+ throw navigatorUnavailableError(providerFailure.source, error, providerFailure.cause);
24643
24722
  }
24644
24723
  },
24645
24724
  providerFailure: () => providerFailure,
@@ -24672,8 +24751,6 @@ function createNativeNavigatorSessionFactory(deps) {
24672
24751
  recordPointer: () => sessionManager.getSessionDir(),
24673
24752
  dispose: async () => {
24674
24753
  disposed = true;
24675
- const pending = inFlightPrompt;
24676
- if (pending !== void 0) await pending.catch(() => void 0);
24677
24754
  }
24678
24755
  };
24679
24756
  };
@@ -24785,7 +24862,14 @@ function createNavigatorAttendance(options) {
24785
24862
  let preparationFailure;
24786
24863
  let routePlaybookReadFailure;
24787
24864
  let disposed = false;
24865
+ let closing;
24866
+ const nestCancel = new AbortController();
24788
24867
  let warmedHelp;
24868
+ const sessionHostContext = () => {
24869
+ const parentSignal = options.context.signal;
24870
+ const signal = parentSignal === void 0 ? nestCancel.signal : AbortSignal.any([nestCancel.signal, parentSignal]);
24871
+ return { ...options.context, signal };
24872
+ };
24789
24873
  const loadLiveHelp = async () => {
24790
24874
  try {
24791
24875
  return await Promise.all(
@@ -24875,7 +24959,7 @@ ${text}
24875
24959
  let created;
24876
24960
  try {
24877
24961
  created = await options.createSession({
24878
- context: options.context,
24962
+ context: sessionHostContext(),
24879
24963
  subject: subjectKey,
24880
24964
  ...options.modelSettingPath === void 0 ? {} : { modelSettingPath: options.modelSettingPath },
24881
24965
  tool
@@ -25072,17 +25156,17 @@ ${helpContext}
25072
25156
  };
25073
25157
  return {
25074
25158
  setWorkContext(next) {
25075
- let closing;
25159
+ let closing2;
25076
25160
  if (next.subjectKey !== subjectKey && session !== void 0) {
25077
25161
  const previous = session;
25078
25162
  session = void 0;
25079
- closing = previous.dispose();
25163
+ closing2 = previous.dispose();
25080
25164
  }
25081
25165
  subjectKey = next.subjectKey;
25082
25166
  subject = next.subject;
25083
25167
  authority = next.authority;
25084
25168
  contextError = next.contextError;
25085
- return closing;
25169
+ return closing2;
25086
25170
  },
25087
25171
  /**
25088
25172
  * Start live-help subprocesses during activation without beginning full
@@ -25120,10 +25204,19 @@ ${helpContext}
25120
25204
  },
25121
25205
  dispose() {
25122
25206
  disposed = true;
25123
- const current = session;
25124
- session = void 0;
25207
+ if (!nestCancel.signal.aborted) {
25208
+ nestCancel.abort(navigatorUnavailableError(
25209
+ "session",
25210
+ new Error("Navigator attendance was disposed")
25211
+ ));
25212
+ }
25125
25213
  activeInvocationId = void 0;
25126
- return current?.dispose();
25214
+ if (closing === void 0) {
25215
+ const current = session;
25216
+ session = void 0;
25217
+ closing = Promise.resolve(current?.dispose()).then(() => void 0);
25218
+ }
25219
+ return closing;
25127
25220
  }
25128
25221
  };
25129
25222
  async function settleOnce(settlement) {
@@ -26843,6 +26936,38 @@ function createRoleRuntimeExtension(dependencies) {
26843
26936
  let noReceiptRecorded = false;
26844
26937
  let priorFetch;
26845
26938
  let fetchWrapped = false;
26939
+ const disposeNavigatorAttendanceNonBlocking = (attendance) => {
26940
+ if (attendance === void 0) return;
26941
+ const recordDisposeFailure = (error) => {
26942
+ const diagnostic = error instanceof Error ? error.message : String(error);
26943
+ try {
26944
+ sitianReport({
26945
+ level: "event",
26946
+ kind: "navigator-dispose-failure",
26947
+ cwd: navigatorCwd,
26948
+ sessionParent: navigatorSessionParent,
26949
+ payload: { diagnostic },
26950
+ source: "role-runtime"
26951
+ });
26952
+ } catch (recordError) {
26953
+ try {
26954
+ envelopeHost.appendEntry?.("ak-navigator-dispose-failure", {
26955
+ diagnostic,
26956
+ recordFailure: recordError instanceof Error ? recordError.message : String(recordError)
26957
+ });
26958
+ } catch {
26959
+ }
26960
+ }
26961
+ };
26962
+ let pending;
26963
+ try {
26964
+ pending = attendance.dispose();
26965
+ } catch (error) {
26966
+ recordDisposeFailure(error);
26967
+ return;
26968
+ }
26969
+ void Promise.resolve(pending).then(void 0, recordDisposeFailure);
26970
+ };
26846
26971
  const settleNavigatorProjection = async (settlement) => {
26847
26972
  const attendance = navigatorAttendance;
26848
26973
  if (settlement === void 0 || attendance === void 0) return;
@@ -26875,27 +27000,7 @@ function createRoleRuntimeExtension(dependencies) {
26875
27000
  };
26876
27001
  pendingNavigatorPresentation = { event, report };
26877
27002
  }
26878
- void Promise.resolve(attendance.dispose()).then(
26879
- void 0,
26880
- (error) => {
26881
- const diagnostic = error instanceof Error ? error.message : String(error);
26882
- try {
26883
- sitianReport({
26884
- level: "event",
26885
- kind: "navigator-dispose-failure",
26886
- cwd: navigatorCwd,
26887
- sessionParent: navigatorSessionParent,
26888
- payload: { diagnostic },
26889
- source: "role-runtime"
26890
- });
26891
- } catch (recordError) {
26892
- envelopeHost.appendEntry?.("ak-navigator-dispose-failure", {
26893
- diagnostic,
26894
- recordFailure: recordError instanceof Error ? recordError.message : String(recordError)
26895
- });
26896
- }
26897
- }
26898
- );
27003
+ disposeNavigatorAttendanceNonBlocking(attendance);
26899
27004
  })();
26900
27005
  pendingNavigatorSettlement = pending;
26901
27006
  await pending;
@@ -27177,9 +27282,10 @@ function createRoleRuntimeExtension(dependencies) {
27177
27282
  } catch {
27178
27283
  }
27179
27284
  }
27180
- await navigatorAttendance?.dispose();
27285
+ const attendanceToDispose = navigatorAttendance;
27181
27286
  navigatorAttendance = void 0;
27182
27287
  pendingNavigatorSettlement = void 0;
27288
+ disposeNavigatorAttendanceNonBlocking(attendanceToDispose);
27183
27289
  pendingInfrastructureFailures.clear();
27184
27290
  pendingSubmissionNonPassByToolCallId.clear();
27185
27291
  observationFace.reset();
@@ -28266,11 +28372,11 @@ async function prepareRoleEnvelope(options) {
28266
28372
  }
28267
28373
 
28268
28374
  // src/role-runtime-dependencies.ts
28269
- import { readFile as readFile23 } from "node:fs/promises";
28375
+ import { readFile as readFile24 } from "node:fs/promises";
28270
28376
  import { join as join42 } from "node:path";
28271
28377
 
28272
28378
  // src/canonical-skill-binding.ts
28273
- import { readFile as readFile21, realpath as realpath8 } from "node:fs/promises";
28379
+ import { readFile as readFile22, realpath as realpath8 } from "node:fs/promises";
28274
28380
  import { homedir } from "node:os";
28275
28381
  import { dirname as dirname22, resolve as resolve18 } from "node:path";
28276
28382
  import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
@@ -28303,7 +28409,7 @@ async function loadCanonicalSkillBinding(name) {
28303
28409
  let raw;
28304
28410
  try {
28305
28411
  path = await realpath8(configuredPath);
28306
- raw = await readFile21(path, "utf8");
28412
+ raw = await readFile22(path, "utf8");
28307
28413
  } catch (error) {
28308
28414
  throw new CanonicalSkillUnavailableError(name, configuredPath, error);
28309
28415
  }
@@ -28342,7 +28448,7 @@ init_doctor_evidence();
28342
28448
  // src/navigator-work-context.ts
28343
28449
  init_doctor_evidence();
28344
28450
  init_host_contracts();
28345
- import { readFile as readFile22 } from "node:fs/promises";
28451
+ import { readFile as readFile23 } from "node:fs/promises";
28346
28452
  import { resolve as resolve19 } from "node:path";
28347
28453
  init_notary_source_run();
28348
28454
  init_packaged_role_registry();
@@ -28355,7 +28461,7 @@ function navigatorInputReference(getFlag, role) {
28355
28461
  }
28356
28462
  async function loadNavigatorWorkContext(options) {
28357
28463
  const reference = navigatorInputReference(options.getFlag, options.role);
28358
- const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile22(reference, "utf8");
28464
+ const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile23(reference, "utf8");
28359
28465
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
28360
28466
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
28361
28467
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -28412,7 +28518,7 @@ async function loadNavigatorWorkContext(options) {
28412
28518
  let authorityMaterial;
28413
28519
  for (const path of authorityFiles) {
28414
28520
  try {
28415
- const content = await readFile22(path, "utf8");
28521
+ const content = await readFile23(path, "utf8");
28416
28522
  if (content.trim() !== "") {
28417
28523
  authorityMaterial = content;
28418
28524
  break;
@@ -28481,12 +28587,12 @@ function createRoleRuntimeDependencies(packageRoot) {
28481
28587
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
28482
28588
  loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
28483
28589
  loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
28484
- loadFixPacket: (path) => readFile23(path, "utf8"),
28590
+ loadFixPacket: (path) => readFile24(path, "utf8"),
28485
28591
  loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
28486
- loadCoderTask: (path) => readFile23(path, "utf8"),
28592
+ loadCoderTask: (path) => readFile24(path, "utf8"),
28487
28593
  loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
28488
28594
  loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
28489
- loadCollectorHandbookSeed: () => readFile23(collectorHandbookSeedPath, "utf8"),
28595
+ loadCollectorHandbookSeed: () => readFile24(collectorHandbookSeedPath, "utf8"),
28490
28596
  createCollectorTransport: () => createGhCollectorGitHubTransport(),
28491
28597
  loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
28492
28598
  loadDoctorCase,
@@ -28501,7 +28607,7 @@ function createRoleRuntimeDependencies(packageRoot) {
28501
28607
  loadSecretariatSoul: () => loadMainRoleSessionMaterials("secretariat"),
28502
28608
  loadNotarySourceRun: loadNotarySourceRunLocator,
28503
28609
  loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
28504
- loadMergerInput: async (path) => JSON.parse(await readFile23(path, "utf8")),
28610
+ loadMergerInput: async (path) => JSON.parse(await readFile24(path, "utf8")),
28505
28611
  async loadCanonicalSkillBinding(name) {
28506
28612
  if (name === "tdd") {
28507
28613
  return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
@@ -28527,7 +28633,7 @@ function createRoleRuntimeDependencies(packageRoot) {
28527
28633
  authority: options.authority,
28528
28634
  invocationId: options.invocationId,
28529
28635
  loadSoul: () => loadMainRoleSessionMaterials("navigator"),
28530
- loadRoutePlaybook: () => readFile23(navigatorRoutePlaybookPath, "utf8"),
28636
+ loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
28531
28637
  loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
28532
28638
  createSession: navigatorSessionFactory,
28533
28639
  ...options.contextError === void 0 ? {} : { contextError: options.contextError },
@@ -29106,7 +29212,7 @@ function createAcpRoleTurnHost(config) {
29106
29212
 
29107
29213
  // src/acp-host/seat-profile-soul.ts
29108
29214
  import { constants as constants2 } from "node:fs";
29109
- import { access as access4, copyFile, lstat as lstat8, mkdir as mkdir8, readlink as readlink2, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
29215
+ import { access as access5, copyFile, lstat as lstat8, mkdir as mkdir8, readlink as readlink2, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
29110
29216
  import { dirname as dirname24, join as join44, relative as relative4, resolve as resolve20 } from "node:path";
29111
29217
  function seatProfileName(spec, role) {
29112
29218
  return `${spec.namePrefix}${role}`;
@@ -29116,7 +29222,7 @@ function packageRoleSoulPath(packageRoot, role) {
29116
29222
  }
29117
29223
  async function pathExists2(path) {
29118
29224
  try {
29119
- await access4(path, constants2.F_OK);
29225
+ await access5(path, constants2.F_OK);
29120
29226
  return true;
29121
29227
  } catch {
29122
29228
  return false;
@@ -2,6 +2,7 @@
2
2
  * Unique dossier-resolution seam for 审刑院 (#233).
3
3
  * Machine pointers only: cwd + per-turn HostContext (Pi child env fallback).
4
4
  * No latest-run / mtime / global scan.
5
+ * See ADR 0085(先立卷后审卷).
5
6
  */
6
7
  import { existsSync, statSync } from "node:fs";
7
8
  import { resolve } from "node:path";