@akagilnc/pi-workflow-roles 0.1.4745 → 0.1.4772

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.
@@ -1761,10 +1761,10 @@ __export(session_assistant_usage_exports, {
1761
1761
  });
1762
1762
  import { join as join9 } from "node:path";
1763
1763
  async function readAssistantUsageFromSessionFile(sessionFile) {
1764
- const { readFile: readFile25 } = await import("node:fs/promises");
1764
+ const { readFile: readFile24 } = await import("node:fs/promises");
1765
1765
  let text;
1766
1766
  try {
1767
- text = await readFile25(sessionFile, "utf8");
1767
+ text = await readFile24(sessionFile, "utf8");
1768
1768
  } catch (error) {
1769
1769
  if (error?.code === "ENOENT") return void 0;
1770
1770
  throw error;
@@ -4114,12 +4114,7 @@ var init_compliance_transport = __esm({
4114
4114
  });
4115
4115
 
4116
4116
  // src/role-run-relocation.ts
4117
- import { existsSync as existsSync5 } from "node:fs";
4118
- import { readdir as readdir3, readFile as readFile5, writeFile as writeFile2 } from "node:fs/promises";
4119
4117
  import { join as join14, sep as sep2 } from "node:path";
4120
- function isEnoent2(error) {
4121
- return error instanceof Error && "code" in error && error.code === "ENOENT";
4122
- }
4123
4118
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
4124
4119
  if (typeof value !== "string") return value;
4125
4120
  if (value === oldRunDirectory) return newRunDirectory;
@@ -4161,23 +4156,6 @@ function rewriteRunDirectoryPathFieldsAgainstRewrites(record4, fields, rewrites)
4161
4156
  }
4162
4157
  }
4163
4158
  }
4164
- function collectRewrites(input) {
4165
- const own = {
4166
- oldRunDirectory: input.oldRunDirectory,
4167
- newRunDirectory: input.newRunDirectory
4168
- };
4169
- if (input.crossRunRewrites === void 0 || input.crossRunRewrites.length === 0) {
4170
- return [own];
4171
- }
4172
- const seen = /* @__PURE__ */ new Set([own.oldRunDirectory]);
4173
- const out = [own];
4174
- for (const rewrite of input.crossRunRewrites) {
4175
- if (seen.has(rewrite.oldRunDirectory)) continue;
4176
- seen.add(rewrite.oldRunDirectory);
4177
- out.push(rewrite);
4178
- }
4179
- return out;
4180
- }
4181
4159
  function isPlainObject(value) {
4182
4160
  return value !== null && typeof value === "object" && !Array.isArray(value);
4183
4161
  }
@@ -4189,254 +4167,25 @@ function rewriteSourceRunLocator(value, rewrites) {
4189
4167
  rewrites
4190
4168
  );
4191
4169
  }
4192
- function rewriteSummonsMaterials(value, rewrites) {
4193
- if (!isPlainObject(value)) return;
4194
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4195
- value,
4196
- SUMMONS_PATH_FIELDS,
4197
- rewrites
4198
- );
4199
- rewriteSourceRunLocator(value.sourceRun, rewrites);
4200
- if (Array.isArray(value.attachmentPaths)) {
4201
- value.attachmentPaths = value.attachmentPaths.map(
4202
- (path) => rewriteRunDirectoryPathValueAgainstRewrites(path, rewrites)
4203
- );
4204
- }
4205
- }
4206
- async function rewriteJsonObjectFile(path, fields, rewrites) {
4207
- if (!existsSync5(path)) return;
4208
- const page = JSON.parse(await readFile5(path, "utf8"));
4209
- if (!isPlainObject(page)) return;
4210
- rewriteRunDirectoryPathFieldsAgainstRewrites(page, fields, rewrites);
4211
- await writeFile2(path, `${JSON.stringify(page, null, 2)}
4212
- `, "utf8");
4213
- }
4214
- async function rewriteOfficerPointerFile(path, rewrites) {
4215
- if (!existsSync5(path)) return;
4216
- const page = JSON.parse(await readFile5(path, "utf8"));
4217
- if (!isPlainObject(page)) return;
4218
- if (page.kind !== "direct-officer-run-pointer") return;
4219
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4220
- page,
4221
- OFFICER_POINTER_FIELDS,
4222
- rewrites
4223
- );
4224
- await writeFile2(path, `${JSON.stringify(page)}
4225
- `, "utf8");
4226
- }
4227
- async function rewriteSitianRecordsJsonl(path, rewrites) {
4228
- if (!existsSync5(path)) return;
4229
- const raw = await readFile5(path, "utf8");
4230
- if (raw.length === 0) return;
4231
- const endsWithNewline = raw.endsWith("\n");
4232
- const lines = raw.split("\n");
4233
- let changed = false;
4234
- const out = [];
4235
- for (let i = 0; i < lines.length; i += 1) {
4236
- const line2 = lines[i];
4237
- if (line2 === "" && i === lines.length - 1 && endsWithNewline) {
4238
- out.push("");
4239
- continue;
4240
- }
4241
- if (line2.trim() === "") {
4242
- out.push(line2);
4243
- continue;
4244
- }
4245
- let parsed;
4246
- try {
4247
- parsed = JSON.parse(line2);
4248
- } catch {
4249
- out.push(line2);
4250
- continue;
4251
- }
4252
- if (!isPlainObject(parsed)) {
4253
- out.push(line2);
4254
- continue;
4255
- }
4256
- if (!("sessionParent" in parsed)) {
4257
- out.push(line2);
4258
- continue;
4259
- }
4260
- const before = parsed.sessionParent;
4261
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4262
- parsed,
4263
- SITIAN_RECORD_FIELDS,
4264
- rewrites
4265
- );
4266
- if (parsed.sessionParent !== before) changed = true;
4267
- out.push(JSON.stringify(parsed));
4268
- }
4269
- if (!changed) return;
4270
- const body = out.join("\n");
4271
- await writeFile2(
4272
- path,
4273
- endsWithNewline && !body.endsWith("\n") ? `${body}
4274
- ` : body,
4275
- "utf8"
4276
- );
4277
- }
4278
- async function rewriteSessionTranscriptBindings(path, rewrites) {
4279
- if (!existsSync5(path)) return;
4280
- const raw = await readFile5(path, "utf8");
4281
- if (raw.length === 0) return;
4282
- const endsWithNewline = raw.endsWith("\n");
4283
- const lines = raw.split("\n");
4284
- let changed = false;
4285
- const out = [];
4286
- for (let i = 0; i < lines.length; i += 1) {
4287
- const line2 = lines[i];
4288
- if (line2 === "" && i === lines.length - 1 && endsWithNewline) {
4289
- out.push("");
4290
- continue;
4291
- }
4292
- if (line2.trim() === "") {
4293
- out.push(line2);
4294
- continue;
4295
- }
4296
- let parsed;
4297
- try {
4298
- parsed = JSON.parse(line2);
4299
- } catch {
4300
- out.push(line2);
4301
- continue;
4302
- }
4303
- if (!isPlainObject(parsed)) {
4304
- out.push(line2);
4305
- continue;
4306
- }
4307
- let lineChanged = false;
4308
- if (parsed.type === "session" && "parentSession" in parsed) {
4309
- const before = parsed.parentSession;
4310
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4311
- parsed,
4312
- SESSION_HEADER_FIELDS,
4313
- rewrites
4314
- );
4315
- if (parsed.parentSession !== before) lineChanged = true;
4316
- } else if (parsed.type === "custom" && parsed.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE && isPlainObject(parsed.data) && isPlainObject(parsed.data.parent)) {
4317
- const parent = parsed.data.parent;
4318
- const before = parent.sessionFile;
4319
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4320
- parent,
4321
- BINDING_PARENT_FIELDS,
4322
- rewrites
4323
- );
4324
- if (parent.sessionFile !== before) lineChanged = true;
4325
- }
4326
- if (lineChanged) changed = true;
4327
- out.push(lineChanged ? JSON.stringify(parsed) : line2);
4328
- }
4329
- if (!changed) return;
4330
- const body = out.join("\n");
4331
- await writeFile2(
4332
- path,
4333
- endsWithNewline && !body.endsWith("\n") ? `${body}
4334
- ` : body,
4335
- "utf8"
4336
- );
4337
- }
4338
- async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
4339
- const sessionRoot = join14(pagesDirectory, "session");
4340
- async function walk(directory) {
4341
- let entries;
4342
- try {
4343
- entries = await readdir3(directory, { withFileTypes: true });
4344
- } catch (error) {
4345
- if (isEnoent2(error)) return;
4346
- throw error;
4347
- }
4348
- for (const entry of entries) {
4349
- const path = join14(directory, entry.name);
4350
- if (entry.isDirectory()) {
4351
- await walk(path);
4352
- continue;
4353
- }
4354
- if (!entry.isFile()) continue;
4355
- if (entry.name === "current-session.json") {
4356
- await rewriteJsonObjectFile(path, CURRENT_SESSION_FIELDS, rewrites);
4357
- } else if (entry.name.endsWith(".pointer.json")) {
4358
- await rewriteOfficerPointerFile(path, rewrites);
4359
- } else if (entry.name === "records.jsonl") {
4360
- await rewriteSitianRecordsJsonl(path, rewrites);
4361
- } else if (entry.name.endsWith(".jsonl")) {
4362
- await rewriteSessionTranscriptBindings(path, rewrites);
4170
+ function rewriteAdmittedRoleRunPage(page, rewrites) {
4171
+ rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
4172
+ rewriteSourceRunLocator(page.sourceRun, rewrites);
4173
+ if (Array.isArray(page.attachments)) {
4174
+ for (const attachment of page.attachments) {
4175
+ if (isPlainObject(attachment)) {
4176
+ rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
4363
4177
  }
4364
4178
  }
4365
4179
  }
4366
- await walk(sessionRoot);
4367
- }
4368
- async function rewriteRoleRunDurablePages(input) {
4369
- const { pagesDirectory } = input;
4370
- const rewrites = collectRewrites(input);
4371
- const admittedPath = join14(pagesDirectory, "admitted-request.json");
4372
- if (existsSync5(admittedPath)) {
4373
- const page = JSON.parse(await readFile5(admittedPath, "utf8"));
4180
+ if (isPlainObject(page.principal)) {
4374
4181
  rewriteRunDirectoryPathFieldsAgainstRewrites(
4375
- page,
4376
- ADMITTED_PAGE_FIELDS,
4182
+ page.principal,
4183
+ ["sessionDirectory", "sessionFile"],
4377
4184
  rewrites
4378
4185
  );
4379
- rewriteSourceRunLocator(page.sourceRun, rewrites);
4380
- if (Array.isArray(page.attachments)) {
4381
- for (const attachment of page.attachments) {
4382
- if (isPlainObject(attachment)) {
4383
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4384
- attachment,
4385
- ["frozenPath"],
4386
- rewrites
4387
- );
4388
- }
4389
- }
4390
- }
4391
- if (isPlainObject(page.principal)) {
4392
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4393
- page.principal,
4394
- ["sessionDirectory", "sessionFile"],
4395
- rewrites
4396
- );
4397
- }
4398
- await writeFile2(admittedPath, `${JSON.stringify(page, null, 2)}
4399
- `, "utf8");
4400
- }
4401
- const invocationPath = join14(pagesDirectory, "invocation.json");
4402
- if (existsSync5(invocationPath)) {
4403
- const page = JSON.parse(await readFile5(invocationPath, "utf8"));
4404
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4405
- page,
4406
- INVOCATION_PAGE_FIELDS,
4407
- rewrites
4408
- );
4409
- await writeFile2(
4410
- invocationPath,
4411
- `${JSON.stringify(page, null, 2)}
4412
- `,
4413
- "utf8"
4414
- );
4415
- }
4416
- const statePath = join14(pagesDirectory, "run-state.json");
4417
- if (existsSync5(statePath)) {
4418
- const page = JSON.parse(await readFile5(statePath, "utf8"));
4419
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4420
- page,
4421
- RUN_STATE_PAGE_FIELDS,
4422
- rewrites
4423
- );
4424
- if (isPlainObject(page.principal)) {
4425
- rewriteRunDirectoryPathFieldsAgainstRewrites(
4426
- page.principal,
4427
- ["sessionDirectory", "sessionFile"],
4428
- rewrites
4429
- );
4430
- }
4431
- if (isPlainObject(page.currentCourt)) {
4432
- rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
4433
- }
4434
- await writeFile2(statePath, `${JSON.stringify(page, null, 2)}
4435
- `, "utf8");
4436
4186
  }
4437
- await rewriteNestedMachinePathPages(pagesDirectory, rewrites);
4438
4187
  }
4439
- var ADMITTED_PAGE_FIELDS, INVOCATION_PAGE_FIELDS, RUN_STATE_PAGE_FIELDS, SOURCE_RUN_LOCATOR_FIELDS, SUMMONS_PATH_FIELDS, CURRENT_SESSION_FIELDS, OFFICER_POINTER_FIELDS, SITIAN_RECORD_FIELDS, SESSION_HEADER_FIELDS, BINDING_PARENT_FIELDS;
4188
+ var ADMITTED_PAGE_FIELDS, SOURCE_RUN_LOCATOR_FIELDS;
4440
4189
  var init_role_run_relocation = __esm({
4441
4190
  "src/role-run-relocation.ts"() {
4442
4191
  "use strict";
@@ -4453,24 +4202,7 @@ var init_role_run_relocation = __esm({
4453
4202
  "mergerInputPath",
4454
4203
  "sourceRunPath"
4455
4204
  ];
4456
- INVOCATION_PAGE_FIELDS = [
4457
- "runDirectory",
4458
- "sessionDirectory",
4459
- "sessionFile"
4460
- ];
4461
- RUN_STATE_PAGE_FIELDS = [
4462
- "runDirectory",
4463
- "admittedRequestPath",
4464
- "sessionDirectory",
4465
- "sessionFile"
4466
- ];
4467
4205
  SOURCE_RUN_LOCATOR_FIELDS = ["runDirectory"];
4468
- SUMMONS_PATH_FIELDS = ["sourceRunPath"];
4469
- CURRENT_SESSION_FIELDS = ["sessionFile"];
4470
- OFFICER_POINTER_FIELDS = ["sessionFile", "runDirectory"];
4471
- SITIAN_RECORD_FIELDS = ["sessionParent"];
4472
- SESSION_HEADER_FIELDS = ["parentSession"];
4473
- BINDING_PARENT_FIELDS = ["sessionFile"];
4474
4206
  }
4475
4207
  });
4476
4208
 
@@ -4603,7 +4335,7 @@ var init_terminating_tools = __esm({
4603
4335
  });
4604
4336
 
4605
4337
  // src/doctor-evidence.ts
4606
- import { readdir as readdir4, readFile as readFile6, realpath as realpath2, stat } from "node:fs/promises";
4338
+ import { readdir as readdir3, readFile as readFile5, realpath as realpath2, stat } from "node:fs/promises";
4607
4339
  import { dirname as dirname8, relative as relative2, resolve as resolve6, sep as sep3 } from "node:path";
4608
4340
  function record2(value) {
4609
4341
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -4611,7 +4343,7 @@ function record2(value) {
4611
4343
  async function discoverCaseFiles(root) {
4612
4344
  const found = [];
4613
4345
  async function walk(dir, depth) {
4614
- for (const item of await readdir4(dir, { withFileTypes: true })) {
4346
+ for (const item of await readdir3(dir, { withFileTypes: true })) {
4615
4347
  const path = resolve6(dir, item.name);
4616
4348
  if (item.isDirectory()) {
4617
4349
  await walk(path, depth + 1);
@@ -4719,7 +4451,7 @@ async function loadDoctorCase(runsPath) {
4719
4451
  const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
4720
4452
  for (const path of await discoverCaseFiles(root)) {
4721
4453
  const id = relative2(root, path).split(sep3).join("/");
4722
- const bytes = await readFile6(path);
4454
+ const bytes = await readFile5(path);
4723
4455
  const content = bytes.toString("utf8");
4724
4456
  const kind = id.endsWith(".jsonl") ? "session" : "stderr";
4725
4457
  evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
@@ -4732,7 +4464,7 @@ async function loadDoctorCase(runsPath) {
4732
4464
  accumulate(calls, result.calls, id);
4733
4465
  accumulate(tokens, result.tokens, id);
4734
4466
  }
4735
- const runDirs = (await readdir4(root, { withFileTypes: true })).filter((item) => item.isDirectory()).map((item) => item.name).sort();
4467
+ const runDirs = (await readdir3(root, { withFileTypes: true })).filter((item) => item.isDirectory()).map((item) => item.name).sort();
4736
4468
  const legs = evidence.filter((entry) => entry.kind === "session").map((entry) => entry.id);
4737
4469
  const retryDirs = runDirs.filter((name) => /(?:^|[-_])retry(?:[-_]|$)/i.test(name));
4738
4470
  const rawBytes = evidence.filter((entry) => entry.kind === "session").reduce((sum, entry) => sum + entry.byteLength, 0);
@@ -4749,7 +4481,7 @@ var init_doctor_evidence = __esm({
4749
4481
 
4750
4482
  // src/collector-config.ts
4751
4483
  import { createHash as createHash4 } from "node:crypto";
4752
- import { readFile as readFile7 } from "node:fs/promises";
4484
+ import { readFile as readFile6 } from "node:fs/promises";
4753
4485
  function fail3(message, cause) {
4754
4486
  throw new Error(message, cause === void 0 ? void 0 : { cause });
4755
4487
  }
@@ -4792,7 +4524,7 @@ function emptyCollectorManifest() {
4792
4524
  async function loadCollectorManifest(path) {
4793
4525
  let bytes;
4794
4526
  try {
4795
- bytes = await readFile7(path);
4527
+ bytes = await readFile6(path);
4796
4528
  } catch (error) {
4797
4529
  fail3(`Collector request manifest is unreadable at ${path}`, error);
4798
4530
  }
@@ -5632,7 +5364,7 @@ var init_git_object_id = __esm({
5632
5364
 
5633
5365
  // src/merger-git-state.ts
5634
5366
  import { execFile as execFile2 } from "node:child_process";
5635
- import { access as access2, readFile as readFile8 } from "node:fs/promises";
5367
+ import { access as access2, readFile as readFile7 } from "node:fs/promises";
5636
5368
  import { constants as fsConstants } from "node:fs";
5637
5369
  import { isAbsolute as isAbsolute4, resolve as resolve7 } from "node:path";
5638
5370
  import { promisify as promisify2 } from "node:util";
@@ -5702,7 +5434,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
5702
5434
  const mergeHeadPath = isAbsolute4(mergeHeadReported) ? mergeHeadReported : resolve7(repositoryRoot, mergeHeadReported);
5703
5435
  let sourceObjectId = "";
5704
5436
  if (await pathExists(mergeHeadPath)) {
5705
- const raw = exactUtf8(await readFile8(mergeHeadPath), "Git MERGE_HEAD");
5437
+ const raw = exactUtf8(await readFile7(mergeHeadPath), "Git MERGE_HEAD");
5706
5438
  const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
5707
5439
  if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
5708
5440
  if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
@@ -5754,7 +5486,7 @@ var init_uuidv7 = __esm({
5754
5486
  });
5755
5487
 
5756
5488
  // src/typed-provider-http.ts
5757
- import { readFile as readFile9, unlink, writeFile as writeFile3 } from "node:fs/promises";
5489
+ import { readFile as readFile8, unlink, writeFile as writeFile2 } from "node:fs/promises";
5758
5490
  import { join as join15 } from "node:path";
5759
5491
  function typedProviderHttpPath(runDirectory) {
5760
5492
  return join15(runDirectory, TYPED_HTTP_FILE);
@@ -5778,7 +5510,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
5778
5510
  httpStatus: observation.httpStatus,
5779
5511
  provider: observation.provider
5780
5512
  };
5781
- await writeFile3(
5513
+ await writeFile2(
5782
5514
  typedProviderHttpPath(runDirectory),
5783
5515
  `${JSON.stringify(body)}
5784
5516
  `,
@@ -5788,7 +5520,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
5788
5520
  async function readLatestTypedProviderHttpObservation(runDirectory) {
5789
5521
  let text;
5790
5522
  try {
5791
- text = await readFile9(typedProviderHttpPath(runDirectory), "utf8");
5523
+ text = await readFile8(typedProviderHttpPath(runDirectory), "utf8");
5792
5524
  } catch (error) {
5793
5525
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
5794
5526
  return void 0;
@@ -5867,7 +5599,7 @@ __export(run_lifecycle_exports, {
5867
5599
  selectResumeContinuationPrompt: () => selectResumeContinuationPrompt,
5868
5600
  writeRoleRunState: () => writeRoleRunState
5869
5601
  });
5870
- import { chmod, lstat as lstat2, open, readdir as readdir5, readFile as readFile10, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
5602
+ import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile9, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
5871
5603
  import { basename as basename5, join as join16 } from "node:path";
5872
5604
  function selectResumeContinuationPrompt(message, engineMaterial) {
5873
5605
  const lines = message !== void 0 ? [message] : [];
@@ -5906,7 +5638,7 @@ function renderResumeCommand(runId) {
5906
5638
  }
5907
5639
  async function writeRoleRunState(runDirectory, record4) {
5908
5640
  const payload = { ...record4, runDirectory };
5909
- await writeFile4(
5641
+ await writeFile3(
5910
5642
  join16(runDirectory, RUN_STATE_FILE),
5911
5643
  `${JSON.stringify(payload, null, 2)}
5912
5644
  `,
@@ -5957,7 +5689,7 @@ function parseCurrentCourtState(raw) {
5957
5689
  async function readRoleRunStateDisk(runDirectory) {
5958
5690
  let raw;
5959
5691
  try {
5960
- raw = JSON.parse(await readFile10(join16(runDirectory, RUN_STATE_FILE), "utf8"));
5692
+ raw = JSON.parse(await readFile9(join16(runDirectory, RUN_STATE_FILE), "utf8"));
5961
5693
  } catch (error) {
5962
5694
  if (errorCodeOf2(error) === "ENOENT") return void 0;
5963
5695
  throw error;
@@ -5979,10 +5711,15 @@ async function readRoleRunStateDisk(runDirectory) {
5979
5711
  if (typeof record4.projectRoot !== "string") return void 0;
5980
5712
  if (typeof record4.sessionDirectory !== "string") return void 0;
5981
5713
  if (typeof record4.admittedRequestPath !== "string") return void 0;
5982
- const runDir = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
5714
+ const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
5715
+ const runDir = runDirectory;
5983
5716
  const principalWire = {
5984
- sessionDirectory: record4.sessionDirectory,
5985
- ...typeof record4.sessionFile === "string" ? { sessionFile: record4.sessionFile } : {}
5717
+ sessionDirectory: rewriteRunDirectoryPathValue(
5718
+ record4.sessionDirectory,
5719
+ storedRunDirectory,
5720
+ runDirectory
5721
+ ),
5722
+ ...typeof record4.sessionFile === "string" ? { sessionFile: rewriteRunDirectoryPathValue(record4.sessionFile, storedRunDirectory, runDirectory) } : {}
5986
5723
  };
5987
5724
  let resumable;
5988
5725
  if (record4.resumable !== void 0 && record4.resumable !== null) {
@@ -6002,7 +5739,11 @@ async function readRoleRunStateDisk(runDirectory) {
6002
5739
  bookKey: record4.bookKey,
6003
5740
  projectRoot: record4.projectRoot,
6004
5741
  runDirectory: runDir,
6005
- admittedRequestPath: record4.admittedRequestPath,
5742
+ admittedRequestPath: rewriteRunDirectoryPathValue(
5743
+ record4.admittedRequestPath,
5744
+ storedRunDirectory,
5745
+ runDirectory
5746
+ ),
6006
5747
  principalWire,
6007
5748
  ...phase === void 0 ? {} : { phase },
6008
5749
  ...resumable === void 0 ? {} : { resumable },
@@ -6024,7 +5765,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
6024
5765
  ...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
6025
5766
  ...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
6026
5767
  };
6027
- await writeFile4(
5768
+ await writeFile3(
6028
5769
  join16(runDirectory, RUN_STATE_FILE),
6029
5770
  `${JSON.stringify(payload, null, 2)}
6030
5771
  `,
@@ -6197,7 +5938,7 @@ function isProcessAlive(pid) {
6197
5938
  async function autopsyWriterLock(lockPath) {
6198
5939
  let content;
6199
5940
  try {
6200
- content = await readFile10(lockPath, "utf8");
5941
+ content = await readFile9(lockPath, "utf8");
6201
5942
  } catch (error) {
6202
5943
  if (errorCodeOf2(error) === "ENOENT") return { verdict: "absent" };
6203
5944
  return { verdict: "unknown", reason: "unreadable", readFailure: error };
@@ -6356,7 +6097,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
6356
6097
  const booksRoot = join16(ledgerHome, "books");
6357
6098
  let bookKeys;
6358
6099
  try {
6359
- bookKeys = await readdir5(booksRoot);
6100
+ bookKeys = await readdir4(booksRoot);
6360
6101
  } catch (error) {
6361
6102
  if (errorCodeOf2(error) === "ENOENT") return void 0;
6362
6103
  throw error;
@@ -6394,7 +6135,7 @@ async function readRunParentPath(runDirectory) {
6394
6135
  let raw;
6395
6136
  try {
6396
6137
  raw = JSON.parse(
6397
- await readFile10(join16(runDirectory, "admitted-request.json"), "utf8")
6138
+ await readFile9(join16(runDirectory, "admitted-request.json"), "utf8")
6398
6139
  );
6399
6140
  } catch (error) {
6400
6141
  if (errorCodeOf2(error) === "ENOENT") return void 0;
@@ -6563,10 +6304,15 @@ async function loadResumableRunRecord(home, runId, authority) {
6563
6304
  let sourceRun;
6564
6305
  try {
6565
6306
  const raw = JSON.parse(
6566
- await readFile10(run.admittedRequestPath, "utf8")
6307
+ await readFile9(run.admittedRequestPath, "utf8")
6567
6308
  );
6568
6309
  if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
6569
6310
  const record4 = raw;
6311
+ const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : run.runDirectory;
6312
+ rewriteAdmittedRoleRunPage(record4, [{
6313
+ oldRunDirectory: storedRunDirectory,
6314
+ newRunDirectory: run.runDirectory
6315
+ }]);
6570
6316
  if (typeof record4.instruction === "string") {
6571
6317
  instruction = record4.instruction;
6572
6318
  }
@@ -6681,7 +6427,7 @@ async function loadResumableRunRecord(home, runId, authority) {
6681
6427
  let model;
6682
6428
  try {
6683
6429
  const invocationRaw = JSON.parse(
6684
- await readFile10(join16(run.runDirectory, "invocation.json"), "utf8")
6430
+ await readFile9(join16(run.runDirectory, "invocation.json"), "utf8")
6685
6431
  );
6686
6432
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
6687
6433
  const rec = invocationRaw;
@@ -6720,6 +6466,23 @@ async function loadResumableRunRecord(home, runId, authority) {
6720
6466
  } else if (mergedSet.tickets !== void 0) {
6721
6467
  courtTicketNumbers = mergedSet.tickets;
6722
6468
  }
6469
+ const sourceRunLeaf = basename5(sourceRunPath ?? "").split("@");
6470
+ const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
6471
+ const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
6472
+ if (referencedRunId !== void 0 && referencedRunId !== "") {
6473
+ const currentSourceRunDirectory = await findRunDirectoryById(
6474
+ home,
6475
+ referencedRunId,
6476
+ run.bookKey,
6477
+ referencedRole
6478
+ );
6479
+ if (currentSourceRunDirectory !== void 0) {
6480
+ sourceRunPath = currentSourceRunDirectory;
6481
+ if (sourceRun !== void 0) {
6482
+ sourceRun = { ...sourceRun, runDirectory: currentSourceRunDirectory };
6483
+ }
6484
+ }
6485
+ }
6723
6486
  return {
6724
6487
  run,
6725
6488
  principal,
@@ -7124,6 +6887,7 @@ var init_run_lifecycle = __esm({
7124
6887
  init_typed_provider_http();
7125
6888
  init_collector_config();
7126
6889
  init_diarist_contracts();
6890
+ init_role_run_relocation();
7127
6891
  init_engine_material();
7128
6892
  init_invocation();
7129
6893
  V1_RESUMABLE_PROVIDERS = ["openai-codex", "xai"];
@@ -7196,17 +6960,29 @@ async function resolveNotarySourceRunLocator(options) {
7196
6960
  }
7197
6961
  const ledgerHome = resolveActivationLedgerHome(options.home);
7198
6962
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
7199
- const bookRunsRoot = join17(activationBookDirectory(ledgerHome, bookKey), "runs");
6963
+ const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
6964
+ const bookRunsRoot = join17(bookDirectory, "runs");
7200
6965
  let candidate;
7201
6966
  const bare = parseRunDirectoryName(raw);
7202
6967
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
7203
6968
  candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join17(bookRunsRoot, `${bare.runId}@${bare.role}`);
7204
6969
  } else {
7205
6970
  candidate = isAbsolute6(raw) ? raw : resolve8(options.projectRoot, raw);
6971
+ const identity2 = parseRunDirectoryName(basename6(candidate));
6972
+ const subjectDirectory = dirname9(dirname9(candidate));
6973
+ const isLegacyUnboundLocator = identity2 !== void 0 && basename6(dirname9(candidate)) === "runs" && basename6(subjectDirectory) === "unbound" && resolve8(dirname9(subjectDirectory)) === resolve8(bookDirectory);
6974
+ if (isLegacyUnboundLocator) {
6975
+ candidate = await findRunDirectoryById(
6976
+ options.home,
6977
+ identity2.runId,
6978
+ bookKey,
6979
+ identity2.role
6980
+ ) ?? candidate;
6981
+ }
7206
6982
  }
7207
6983
  const real = await requireRunDirectory(candidate, raw);
7208
6984
  const identity = parseRunDirectoryName(basename6(real));
7209
- const bookIdentity = physicalPathIdentity(activationBookDirectory(ledgerHome, bookKey));
6985
+ const bookIdentity = physicalPathIdentity(bookDirectory);
7210
6986
  const parentIdentity = physicalPathIdentity(dirname9(real));
7211
6987
  const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
7212
6988
  if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
@@ -8388,15 +8164,15 @@ __export(invocation_exports, {
8388
8164
  withPreparedAttachments: () => withPreparedAttachments
8389
8165
  });
8390
8166
  import { execFileSync as execFileSync3 } from "node:child_process";
8391
- import { existsSync as existsSync6 } from "node:fs";
8167
+ import { existsSync as existsSync5 } from "node:fs";
8392
8168
  import {
8393
8169
  lstat as lstat4,
8394
8170
  mkdtemp as mkdtemp2,
8395
- readFile as readFile11,
8171
+ readFile as readFile10,
8396
8172
  realpath as realpath4,
8397
8173
  rename,
8398
8174
  rm as rm2,
8399
- writeFile as writeFile5
8175
+ writeFile as writeFile4
8400
8176
  } from "node:fs/promises";
8401
8177
  import { tmpdir as tmpdir2 } from "node:os";
8402
8178
  import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute7, join as join18, resolve as resolve9, sep as sep4 } from "node:path";
@@ -8424,7 +8200,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
8424
8200
  sessionDirectory: coordinates.sessionDirectory,
8425
8201
  sessionFile: coordinates.sessionFile
8426
8202
  };
8427
- await writeFile5(
8203
+ await writeFile4(
8428
8204
  admittedRequestPath,
8429
8205
  `${JSON.stringify(projection, null, 2)}
8430
8206
  `,
@@ -8452,7 +8228,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
8452
8228
  ...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
8453
8229
  ...effectiveModelLedgerFields(effectiveModel)
8454
8230
  };
8455
- await writeFile5(
8231
+ await writeFile4(
8456
8232
  join18(source.runDirectory, "invocation.json"),
8457
8233
  `${JSON.stringify(identity, null, 2)}
8458
8234
  `,
@@ -8461,7 +8237,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
8461
8237
  }
8462
8238
  async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
8463
8239
  const ledgerPath = join18(runDirectory, "invocation.json");
8464
- const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
8240
+ const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
8465
8241
  const next = { ...current };
8466
8242
  if (model !== void 0) {
8467
8243
  next.provider = model.provider;
@@ -8485,7 +8261,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
8485
8261
  if (host !== void 0) {
8486
8262
  next.host = host;
8487
8263
  }
8488
- await writeFile5(
8264
+ await writeFile4(
8489
8265
  ledgerPath,
8490
8266
  `${JSON.stringify(next, null, 2)}
8491
8267
  `,
@@ -8494,8 +8270,8 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
8494
8270
  }
8495
8271
  async function mergeInvocationIdentityPage(runDirectory, fields) {
8496
8272
  const ledgerPath = join18(runDirectory, "invocation.json");
8497
- const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
8498
- await writeFile5(
8273
+ const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
8274
+ await writeFile4(
8499
8275
  ledgerPath,
8500
8276
  `${JSON.stringify({
8501
8277
  ...current,
@@ -8510,14 +8286,14 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
8510
8286
  throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
8511
8287
  }
8512
8288
  const admittedPath = admitted.admittedRequestPath;
8513
- const current = JSON.parse(await readFile11(admittedPath, "utf8"));
8289
+ const current = JSON.parse(await readFile10(admittedPath, "utf8"));
8514
8290
  if (typeof current.sourceRunPath === "string") {
8515
8291
  if (current.sourceRunPath === sourceRunPath) return;
8516
8292
  throw new Error(
8517
8293
  `persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
8518
8294
  );
8519
8295
  }
8520
- await writeFile5(
8296
+ await writeFile4(
8521
8297
  admittedPath,
8522
8298
  `${JSON.stringify({ ...current, sourceRunPath }, null, 2)}
8523
8299
  `,
@@ -8536,7 +8312,7 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
8536
8312
  }
8537
8313
  async function recordAdmittedCorrelation(admitted, correlationId) {
8538
8314
  const current = JSON.parse(
8539
- await readFile11(admitted.admittedRequestPath, "utf8")
8315
+ await readFile10(admitted.admittedRequestPath, "utf8")
8540
8316
  );
8541
8317
  const prior = [
8542
8318
  ...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
@@ -8545,7 +8321,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
8545
8321
  ...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
8546
8322
  ];
8547
8323
  const correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
8548
- await writeFile5(
8324
+ await writeFile4(
8549
8325
  admitted.admittedRequestPath,
8550
8326
  `${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
8551
8327
  `,
@@ -8584,8 +8360,8 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
8584
8360
  }
8585
8361
  const frozen = Object.freeze([...projected]);
8586
8362
  const admittedPath = admitted.admittedRequestPath;
8587
- const current = JSON.parse(await readFile11(admittedPath, "utf8"));
8588
- await writeFile5(
8363
+ const current = JSON.parse(await readFile10(admittedPath, "utf8"));
8364
+ await writeFile4(
8589
8365
  admittedPath,
8590
8366
  `${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
8591
8367
  `,
@@ -8597,7 +8373,7 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
8597
8373
  admitted.courtTicketNumbers = frozen;
8598
8374
  }
8599
8375
  async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
8600
- if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) return;
8376
+ if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) return void 0;
8601
8377
  const oldRunDirectory = admitted.runDirectory;
8602
8378
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
8603
8379
  const target = roleRunPlacement(ledgerHome, {
@@ -8607,6 +8383,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
8607
8383
  role: admitted.role
8608
8384
  });
8609
8385
  ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
8386
+ const principal = authority.seal(target);
8610
8387
  await rename(oldRunDirectory, target.runDirectory);
8611
8388
  heldLease?.relocate(target.runDirectory);
8612
8389
  const admittedRecord = admitted;
@@ -8631,13 +8408,8 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
8631
8408
  target.runDirectory
8632
8409
  );
8633
8410
  }
8634
- const principal = authority.seal(target);
8635
8411
  admitted.principal = principal;
8636
- await rewriteRoleRunDurablePages({
8637
- pagesDirectory: target.runDirectory,
8638
- oldRunDirectory,
8639
- newRunDirectory: target.runDirectory
8640
- });
8412
+ return { oldRunDirectory, newRunDirectory: target.runDirectory };
8641
8413
  }
8642
8414
  async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
8643
8415
  requireSafePositiveTicketNumber(
@@ -8646,7 +8418,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
8646
8418
  );
8647
8419
  const admittedPath = join18(runDirectory, "admitted-request.json");
8648
8420
  const invocationPath = join18(runDirectory, "invocation.json");
8649
- const admitted = JSON.parse(await readFile11(admittedPath, "utf8"));
8421
+ const admitted = JSON.parse(await readFile10(admittedPath, "utf8"));
8650
8422
  const existing = admitted.ticketNumber;
8651
8423
  if (typeof existing === "number") {
8652
8424
  if (existing === ticketNumber) return;
@@ -8654,9 +8426,9 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
8654
8426
  `bindTicketNumberOnRunDirectory refuses to replace existing ticket #${existing} with #${ticketNumber}`
8655
8427
  );
8656
8428
  }
8657
- if (existsSync6(invocationPath)) {
8429
+ if (existsSync5(invocationPath)) {
8658
8430
  const invocation = JSON.parse(
8659
- await readFile11(invocationPath, "utf8")
8431
+ await readFile10(invocationPath, "utf8")
8660
8432
  );
8661
8433
  if (typeof invocation.ticketNumber === "number" && invocation.ticketNumber !== ticketNumber) {
8662
8434
  throw new Error(
@@ -8664,7 +8436,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
8664
8436
  );
8665
8437
  }
8666
8438
  }
8667
- await writeFile5(
8439
+ await writeFile4(
8668
8440
  admittedPath,
8669
8441
  `${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
8670
8442
  `,
@@ -8681,7 +8453,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
8681
8453
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
8682
8454
  const rolePackageRoot = packageRoot;
8683
8455
  const raw = JSON.parse(
8684
- await readFile11(join18(rolePackageRoot, "package.json"), "utf8")
8456
+ await readFile10(join18(rolePackageRoot, "package.json"), "utf8")
8685
8457
  );
8686
8458
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
8687
8459
  throw new Error(
@@ -8966,7 +8738,7 @@ async function readRegularFileAttachment(sourcePath) {
8966
8738
  );
8967
8739
  }
8968
8740
  try {
8969
- return { absolute, bytes: await readFile11(absolute) };
8741
+ return { absolute, bytes: await readFile10(absolute) };
8970
8742
  } catch (error) {
8971
8743
  throw new CliUsageError(
8972
8744
  `attachment is not a readable regular file: ${sourcePath}`,
@@ -8986,7 +8758,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
8986
8758
  for (let index = 0; index < attachmentPaths.length; index += 1) {
8987
8759
  const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
8988
8760
  const snapshotPath = join18(stagingDirectory, String(index).padStart(6, "0"));
8989
- await writeFile5(snapshotPath, bytes);
8761
+ await writeFile4(snapshotPath, bytes);
8990
8762
  prepared.push({ absolute, snapshotPath });
8991
8763
  }
8992
8764
  result = await use(prepared);
@@ -9010,7 +8782,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
9010
8782
  destinationDir,
9011
8783
  `${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
9012
8784
  );
9013
- await writeFile5(frozenPath, bytes);
8785
+ await writeFile4(frozenPath, bytes);
9014
8786
  return {
9015
8787
  provenancePath,
9016
8788
  frozenPath,
@@ -9022,7 +8794,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
9022
8794
  async function freezePreparedAttachment(prepared, destinationDir, index) {
9023
8795
  return freezeAttachmentBytes(
9024
8796
  prepared.absolute,
9025
- await readFile11(prepared.snapshotPath),
8797
+ await readFile10(prepared.snapshotPath),
9026
8798
  destinationDir,
9027
8799
  index
9028
8800
  );
@@ -9278,7 +9050,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
9278
9050
  async function loadAdmittedJudgeRequest(runDirectory) {
9279
9051
  try {
9280
9052
  const raw = JSON.parse(
9281
- await readFile11(join18(runDirectory, "admitted-request.json"), "utf8")
9053
+ await readFile10(join18(runDirectory, "admitted-request.json"), "utf8")
9282
9054
  );
9283
9055
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
9284
9056
  const record4 = raw;
@@ -9334,7 +9106,7 @@ async function admitCoderInvocation(options) {
9334
9106
  });
9335
9107
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
9336
9108
  const taskPath = join18(runDirectory, "task.md");
9337
- await writeFile5(taskPath, instruction, "utf8");
9109
+ await writeFile4(taskPath, instruction, "utf8");
9338
9110
  const admitted = {
9339
9111
  role: "coder",
9340
9112
  phase: options.phase,
@@ -9404,7 +9176,7 @@ async function admitFixerInvocation(options) {
9404
9176
  if (options.prerequisitesPath !== void 0) {
9405
9177
  const absolutePrereq = isAbsolute7(options.prerequisitesPath) ? options.prerequisitesPath : resolve9(options.prerequisitesPath);
9406
9178
  try {
9407
- prerequisitesSource = await readFile11(absolutePrereq, "utf8");
9179
+ prerequisitesSource = await readFile10(absolutePrereq, "utf8");
9408
9180
  } catch (error) {
9409
9181
  throw new CliUsageError(
9410
9182
  `fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
@@ -9441,7 +9213,7 @@ async function admitFixerInvocation(options) {
9441
9213
  let prerequisitesPath;
9442
9214
  if (prerequisitesSource !== void 0) {
9443
9215
  prerequisitesPath = join18(runDirectory, "prerequisites.json");
9444
- await writeFile5(
9216
+ await writeFile4(
9445
9217
  prerequisitesPath,
9446
9218
  `${JSON.stringify(prerequisites, null, 2)}
9447
9219
  `,
@@ -9449,7 +9221,7 @@ async function admitFixerInvocation(options) {
9449
9221
  );
9450
9222
  }
9451
9223
  const packetPath = join18(runDirectory, "fix-packet.md");
9452
- await writeFile5(packetPath, instruction, "utf8");
9224
+ await writeFile4(packetPath, instruction, "utf8");
9453
9225
  const admitted = {
9454
9226
  role: "fixer",
9455
9227
  phase: options.phase,
@@ -9695,7 +9467,7 @@ async function admitCollectorInvocation(options) {
9695
9467
  let requestManifestPath;
9696
9468
  if (manifestCanonicalJson !== void 0) {
9697
9469
  requestManifestPath = join18(runDirectory, "request-manifest.json");
9698
- await writeFile5(requestManifestPath, manifestCanonicalJson, "utf8");
9470
+ await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
9699
9471
  }
9700
9472
  const admitted = {
9701
9473
  role: "collector",
@@ -10476,7 +10248,7 @@ async function admitMergerInvocation(options) {
10476
10248
  authorizedChecks: []
10477
10249
  });
10478
10250
  const mergerInputPath = join18(runDirectory, "merger-input.json");
10479
- await writeFile5(
10251
+ await writeFile4(
10480
10252
  mergerInputPath,
10481
10253
  `${JSON.stringify(mergerInput, null, 2)}
10482
10254
  `,
@@ -10789,7 +10561,7 @@ var init_invocation = __esm({
10789
10561
  });
10790
10562
 
10791
10563
  // src/public-cli/load-production-acp-host.ts
10792
- import { existsSync as existsSync7 } from "node:fs";
10564
+ import { existsSync as existsSync6 } from "node:fs";
10793
10565
  import { join as join19 } from "node:path";
10794
10566
  import { pathToFileURL } from "node:url";
10795
10567
  async function loadProductionAcpHostFactory(packageRoot, host) {
@@ -10799,7 +10571,7 @@ async function loadProductionAcpHostFactory(packageRoot, host) {
10799
10571
  }
10800
10572
  const built = join19(packageRoot, "dist/acp-host/production-host.js");
10801
10573
  const source = join19(packageRoot, "src/acp-host/production-host.ts");
10802
- const target = existsSync7(built) ? built : source;
10574
+ const target = existsSync6(built) ? built : source;
10803
10575
  const href = pathToFileURL(target).href;
10804
10576
  const mod = await import(href);
10805
10577
  const create = mod.createProductionAcpRoleTurnHost;
@@ -10813,7 +10585,7 @@ var init_load_production_acp_host = __esm({
10813
10585
  });
10814
10586
 
10815
10587
  // src/public-cli/load-production-headless-host.ts
10816
- import { existsSync as existsSync8 } from "node:fs";
10588
+ import { existsSync as existsSync7 } from "node:fs";
10817
10589
  import { join as join20 } from "node:path";
10818
10590
  import { pathToFileURL as pathToFileURL2 } from "node:url";
10819
10591
  async function loadProductionHeadlessHostFactory(packageRoot, host) {
@@ -10823,7 +10595,7 @@ async function loadProductionHeadlessHostFactory(packageRoot, host) {
10823
10595
  }
10824
10596
  const built = join20(packageRoot, "dist/headless-host/production-host.js");
10825
10597
  const source = join20(packageRoot, "src/headless-host/production-host.ts");
10826
- const target = existsSync8(built) ? built : source;
10598
+ const target = existsSync7(built) ? built : source;
10827
10599
  const href = pathToFileURL2(target).href;
10828
10600
  const mod = await import(href);
10829
10601
  const create = mod.createProductionHeadlessRoleTurnHost;
@@ -11071,7 +10843,7 @@ __export(config_exports, {
11071
10843
  setPersistentSeatHost: () => setPersistentSeatHost,
11072
10844
  validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
11073
10845
  });
11074
- import { mkdir, readFile as readFile12, writeFile as writeFile6 } from "node:fs/promises";
10846
+ import { mkdir, readFile as readFile11, writeFile as writeFile5 } from "node:fs/promises";
11075
10847
  import { dirname as dirname11, join as join21 } from "node:path";
11076
10848
  function isGateOfficerSeat(value) {
11077
10849
  return GATE_OFFICER_SEATS.includes(value);
@@ -11085,7 +10857,7 @@ function publicCliConfigPath(home) {
11085
10857
  async function loadPublicCliConfig(home) {
11086
10858
  const path = publicCliConfigPath(home);
11087
10859
  try {
11088
- const raw = await readFile12(path, "utf8");
10860
+ const raw = await readFile11(path, "utf8");
11089
10861
  return parsePublicCliConfig(JSON.parse(raw));
11090
10862
  } catch (error) {
11091
10863
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -11098,7 +10870,7 @@ async function savePublicCliConfig(config, home) {
11098
10870
  const path = publicCliConfigPath(home);
11099
10871
  await mkdir(dirname11(path), { recursive: true });
11100
10872
  const normalized = parsePublicCliConfig(config);
11101
- await writeFile6(
10873
+ await writeFile5(
11102
10874
  path,
11103
10875
  `${JSON.stringify(serializePublicCliConfig(normalized), null, 2)}
11104
10876
  `,
@@ -11543,7 +11315,7 @@ function credentialProvidersFromAuthData(data) {
11543
11315
  }
11544
11316
  async function loadCredentialProviders(agentDir) {
11545
11317
  try {
11546
- const raw = await readFile12(join21(agentDir, "auth.json"), "utf8");
11318
+ const raw = await readFile11(join21(agentDir, "auth.json"), "utf8");
11547
11319
  return credentialProvidersFromAuthData(JSON.parse(raw));
11548
11320
  } catch (error) {
11549
11321
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -11745,12 +11517,12 @@ var init_host_providers = __esm({
11745
11517
  });
11746
11518
 
11747
11519
  // src/ledger-session-read.ts
11748
- import { readFile as readFile13 } from "node:fs/promises";
11520
+ import { readFile as readFile12 } from "node:fs/promises";
11749
11521
  function isRecord6(value) {
11750
11522
  return typeof value === "object" && value !== null && !Array.isArray(value);
11751
11523
  }
11752
11524
  async function readLedgerSessionJsonlLines(path) {
11753
- const text = await readFile13(path, "utf8");
11525
+ const text = await readFile12(path, "utf8");
11754
11526
  const lines = text.split("\n");
11755
11527
  const out = [];
11756
11528
  for (let index = 0; index < lines.length; index += 1) {
@@ -11848,7 +11620,7 @@ var init_ledger_session_read = __esm({
11848
11620
  });
11849
11621
 
11850
11622
  // src/analyst-gate-cycles-read.ts
11851
- import { readdir as readdir6 } from "node:fs/promises";
11623
+ import { readdir as readdir5 } from "node:fs/promises";
11852
11624
  import { join as join23 } from "node:path";
11853
11625
  function isRecord7(value) {
11854
11626
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -12064,10 +11836,10 @@ function pairGateRounds(volumes) {
12064
11836
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
12065
11837
  }
12066
11838
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
12067
- const { readFile: readFile25 } = await import("node:fs/promises");
11839
+ const { readFile: readFile24 } = await import("node:fs/promises");
12068
11840
  let raw;
12069
11841
  try {
12070
- raw = JSON.parse(await readFile25(pointerPath, "utf8"));
11842
+ raw = JSON.parse(await readFile24(pointerPath, "utf8"));
12071
11843
  } catch (error) {
12072
11844
  throw new Error(
12073
11845
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
@@ -12090,7 +11862,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
12090
11862
  for (const directory of directories) {
12091
11863
  let names;
12092
11864
  try {
12093
- const entries = await readdir6(directory, { withFileTypes: true });
11865
+ const entries = await readdir5(directory, { withFileTypes: true });
12094
11866
  names = entries.filter(
12095
11867
  (e) => e.isFile() && (e.name.endsWith(".jsonl") || e.name.endsWith(".pointer.json"))
12096
11868
  ).map((e) => e.name).sort();
@@ -12668,14 +12440,14 @@ var init_submission_ledger = __esm({
12668
12440
  });
12669
12441
 
12670
12442
  // src/session-opening-materials.ts
12671
- import { existsSync as existsSync9 } from "node:fs";
12672
- import { readFile as readFile14 } from "node:fs/promises";
12443
+ import { existsSync as existsSync8 } from "node:fs";
12444
+ import { readFile as readFile13 } from "node:fs/promises";
12673
12445
  import { dirname as dirname12, join as join25 } from "node:path";
12674
12446
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
12675
12447
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
12676
12448
  let dir = dirname12(fileURLToPath(moduleUrl));
12677
12449
  for (let i = 0; i < 8; i += 1) {
12678
- if (existsSync9(join25(dir, "package.json")) && existsSync9(join25(dir, "souls"))) {
12450
+ if (existsSync8(join25(dir, "package.json")) && existsSync8(join25(dir, "souls"))) {
12679
12451
  return dir;
12680
12452
  }
12681
12453
  const parent = dirname12(dir);
@@ -12685,7 +12457,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
12685
12457
  return fileURLToPath(new URL("..", moduleUrl));
12686
12458
  }
12687
12459
  async function readPackageMaterial(relativePath) {
12688
- return readFile14(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
12460
+ return readFile13(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
12689
12461
  }
12690
12462
  async function joinPackageMaterials(relativePaths) {
12691
12463
  const chunks = [];
@@ -12803,7 +12575,7 @@ var init_auditor_soul = __esm({
12803
12575
  });
12804
12576
 
12805
12577
  // src/dossier-resolution.ts
12806
- import { existsSync as existsSync10, statSync as statSync3 } from "node:fs";
12578
+ import { existsSync as existsSync9, statSync as statSync3 } from "node:fs";
12807
12579
  import { resolve as resolve10 } from "node:path";
12808
12580
  function isHostContext(value) {
12809
12581
  return "sessionManager" in value;
@@ -12823,7 +12595,7 @@ function resolveAuditDossier(source) {
12823
12595
  }
12824
12596
  const runDirectory = resolve10(raw);
12825
12597
  try {
12826
- if (!existsSync10(runDirectory) || !statSync3(runDirectory).isDirectory()) {
12598
+ if (!existsSync9(runDirectory) || !statSync3(runDirectory).isDirectory()) {
12827
12599
  return { status: "incomplete", observation: { kind: "missing-dossier" } };
12828
12600
  }
12829
12601
  } catch {
@@ -14324,7 +14096,7 @@ var init_engine_detour_usage = __esm({
14324
14096
 
14325
14097
  // src/package-resources/method-skill.ts
14326
14098
  import { createHash as createHash7 } from "node:crypto";
14327
- import { readFile as readFile15, realpath as realpath5 } from "node:fs/promises";
14099
+ import { readFile as readFile14, realpath as realpath5 } from "node:fs/promises";
14328
14100
  import { join as join27 } from "node:path";
14329
14101
  function gitBlobOid(bytes) {
14330
14102
  const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
@@ -14443,7 +14215,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
14443
14215
  const provenancePath = join27(rootDirectory, "provenance.json");
14444
14216
  let provenanceRaw;
14445
14217
  try {
14446
- provenanceRaw = await readFile15(provenancePath, "utf8");
14218
+ provenanceRaw = await readFile14(provenancePath, "utf8");
14447
14219
  } catch (error) {
14448
14220
  throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
14449
14221
  }
@@ -14460,7 +14232,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
14460
14232
  const absolute = join27(rootDirectory, rel);
14461
14233
  let bytes;
14462
14234
  try {
14463
- bytes = await readFile15(absolute);
14235
+ bytes = await readFile14(absolute);
14464
14236
  } catch (error) {
14465
14237
  throw new PackagedMethodSkillUnavailableError(name, absolute, error);
14466
14238
  }
@@ -14476,7 +14248,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
14476
14248
  let raw;
14477
14249
  try {
14478
14250
  skillPath = await realpath5(skillPathConfigured);
14479
- raw = await readFile15(skillPath, "utf8");
14251
+ raw = await readFile14(skillPath, "utf8");
14480
14252
  } catch (error) {
14481
14253
  throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
14482
14254
  }
@@ -14937,7 +14709,7 @@ __export(settlement_exports, {
14937
14709
  withSubmissions: () => withSubmissions
14938
14710
  });
14939
14711
  import { randomUUID as randomUUID4 } from "node:crypto";
14940
- import { appendFile as appendFile2, readFile as readFile16, readdir as readdir7, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
14712
+ import { appendFile as appendFile2, readFile as readFile15, readdir as readdir6, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
14941
14713
  import { dirname as dirname14, join as join28 } from "node:path";
14942
14714
  function sealedLedgerHome(admitted) {
14943
14715
  return homeFromRunDirectory(admitted.runDirectory);
@@ -15088,7 +14860,7 @@ function presentControlledFailure(failure2, io) {
15088
14860
  }
15089
14861
  async function inspectJudgeSession(sessionFile) {
15090
14862
  try {
15091
- await readFile16(sessionFile, "utf8");
14863
+ await readFile15(sessionFile, "utf8");
15092
14864
  return { state: "present" };
15093
14865
  } catch (error) {
15094
14866
  if (isMissingPathError4(error)) return { state: "missing" };
@@ -15323,7 +15095,7 @@ function sessionReadFailure(error, fallbackMessage) {
15323
15095
  return failed;
15324
15096
  }
15325
15097
  async function readBoundSessionEntries(sessionFile) {
15326
- const text = await readFile16(sessionFile, "utf8");
15098
+ const text = await readFile15(sessionFile, "utf8");
15327
15099
  const entries = [];
15328
15100
  for (const line2 of text.trim().split("\n").filter(Boolean)) {
15329
15101
  try {
@@ -15425,7 +15197,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
15425
15197
  for (const childDirectory of childDirectories) {
15426
15198
  let names;
15427
15199
  try {
15428
- names = await readdir7(childDirectory);
15200
+ names = await readdir6(childDirectory);
15429
15201
  sawAnyDirectory = true;
15430
15202
  } catch (error) {
15431
15203
  if (isMissingPathError4(error)) continue;
@@ -16100,13 +15872,13 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
16100
15872
  const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
16101
15873
  const reportPath = join28(artifactsDir, "report.json");
16102
15874
  const evidencePath = join28(artifactsDir, "evidence.json");
16103
- await writeFile7(
15875
+ await writeFile6(
16104
15876
  reportPath,
16105
15877
  `${JSON.stringify(bodies.report, null, 2)}
16106
15878
  `,
16107
15879
  "utf8"
16108
15880
  );
16109
- await writeFile7(
15881
+ await writeFile6(
16110
15882
  evidencePath,
16111
15883
  `${JSON.stringify(bodies.evidence, null, 2)}
16112
15884
  `,
@@ -17020,7 +16792,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
17020
16792
  const path = candidates[i];
17021
16793
  const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
17022
16794
  try {
17023
- await writeFile7(
16795
+ await writeFile6(
17024
16796
  path,
17025
16797
  `${JSON.stringify(payload, null, 2)}
17026
16798
  `,
@@ -17385,7 +17157,7 @@ var init_seat_ticket_binding = __esm({
17385
17157
  });
17386
17158
 
17387
17159
  // src/session-identity.ts
17388
- import { mkdir as mkdir2, readFile as readFile17, rename as rename2, writeFile as writeFile8 } from "node:fs/promises";
17160
+ import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as writeFile7 } from "node:fs/promises";
17389
17161
  import { dirname as dirname15, join as join29 } from "node:path";
17390
17162
  function createSessionIdentityAuthority(authority, sessionBindingFile) {
17391
17163
  const bindingPath = (principal) => join29(authority.decode(principal).sessionDirectory, sessionBindingFile);
@@ -17395,7 +17167,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
17395
17167
  },
17396
17168
  async load(principal) {
17397
17169
  try {
17398
- const value = JSON.parse(await readFile17(bindingPath(principal), "utf8"));
17170
+ const value = JSON.parse(await readFile16(bindingPath(principal), "utf8"));
17399
17171
  if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
17400
17172
  throw new Error("durable session binding is invalid");
17401
17173
  }
@@ -17409,7 +17181,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
17409
17181
  const target = bindingPath(principal);
17410
17182
  await mkdir2(dirname15(target), { recursive: true });
17411
17183
  const temporary = `${target}.${process.pid}.tmp`;
17412
- await writeFile8(temporary, `${JSON.stringify({ sessionId })}
17184
+ await writeFile7(temporary, `${JSON.stringify({ sessionId })}
17413
17185
  `, { encoding: "utf8", mode: 384 });
17414
17186
  await rename2(temporary, target);
17415
17187
  }
@@ -17556,7 +17328,7 @@ var init_session_dialogue = __esm({
17556
17328
 
17557
17329
  // src/ticket-provenance.ts
17558
17330
  import { createHash as createHash8 } from "node:crypto";
17559
- import { readFile as readFile18 } from "node:fs/promises";
17331
+ import { readFile as readFile17 } from "node:fs/promises";
17560
17332
  import { basename as basename8, dirname as dirname16, join as join30, resolve as resolve12 } from "node:path";
17561
17333
  function dialogueSessionSourceRoots(home) {
17562
17334
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
@@ -17652,7 +17424,7 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
17652
17424
  const { recordFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
17653
17425
  let text;
17654
17426
  try {
17655
- text = await readFile18(recordFile, "utf8");
17427
+ text = await readFile17(recordFile, "utf8");
17656
17428
  } catch (error) {
17657
17429
  if (error.code === "ENOENT") {
17658
17430
  return {
@@ -18132,7 +17904,7 @@ __export(case_dossier_delivery_exports, {
18132
17904
  loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
18133
17905
  projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
18134
17906
  });
18135
- import { mkdtemp as mkdtemp3, readFile as readFile19, rm as rm4, writeFile as writeFile9 } from "node:fs/promises";
17907
+ import { mkdtemp as mkdtemp3, readFile as readFile18, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
18136
17908
  import { tmpdir as tmpdir3 } from "node:os";
18137
17909
  import { join as join31 } from "node:path";
18138
17910
  async function projectCaseDossierPointerSection(input) {
@@ -18164,7 +17936,7 @@ async function deliverCaseDossierAsAttachment(input) {
18164
17936
  const stagingDir = await mkdtemp3(join31(tmpdir3(), "ak-case-dossier-"));
18165
17937
  try {
18166
17938
  const stagingPath = join31(stagingDir, CASE_DOSSIER_ATTACH_FILE);
18167
- await writeFile9(stagingPath, `${section}
17939
+ await writeFile8(stagingPath, `${section}
18168
17940
  `, "utf8");
18169
17941
  return await freezeAttachmentsIntoRun(
18170
17942
  [stagingPath],
@@ -18184,7 +17956,7 @@ async function loadCaseDossierReadingMaterial(runDirectory) {
18184
17956
  );
18185
17957
  let section;
18186
17958
  try {
18187
- section = await readFile19(frozenPath, "utf8");
17959
+ section = await readFile18(frozenPath, "utf8");
18188
17960
  } catch (error) {
18189
17961
  if (error.code === "ENOENT") return void 0;
18190
17962
  throw error;
@@ -18207,9 +17979,9 @@ var init_case_dossier_delivery = __esm({
18207
17979
  });
18208
17980
 
18209
17981
  // src/host-transition-prior-native.ts
18210
- import { access as access3, readdir as readdir8 } from "node:fs/promises";
17982
+ import { access as access3, readdir as readdir7 } from "node:fs/promises";
18211
17983
  import { dirname as dirname17, join as join32 } from "node:path";
18212
- function isEnoent3(error) {
17984
+ function isEnoent2(error) {
18213
17985
  return typeof error === "object" && error !== null && error.code === "ENOENT";
18214
17986
  }
18215
17987
  async function listPiNativeRecordPaths(sessionFile) {
@@ -18217,7 +17989,7 @@ async function listPiNativeRecordPaths(sessionFile) {
18217
17989
  await access3(sessionFile);
18218
17990
  return [sessionFile];
18219
17991
  } catch (error) {
18220
- if (isEnoent3(error)) return [];
17992
+ if (isEnoent2(error)) return [];
18221
17993
  throw error;
18222
17994
  }
18223
17995
  }
@@ -18225,9 +17997,9 @@ async function listSitianRecordPaths(sessionParent) {
18225
17997
  const sessionRoot = dirname17(sessionParent);
18226
17998
  let entries;
18227
17999
  try {
18228
- entries = await readdir8(sessionRoot, { withFileTypes: true });
18000
+ entries = await readdir7(sessionRoot, { withFileTypes: true });
18229
18001
  } catch (error) {
18230
- if (isEnoent3(error)) return [];
18002
+ if (isEnoent2(error)) return [];
18231
18003
  throw error;
18232
18004
  }
18233
18005
  const recordPaths = [];
@@ -18238,7 +18010,7 @@ async function listSitianRecordPaths(sessionParent) {
18238
18010
  await access3(recordFile);
18239
18011
  recordPaths.push(recordFile);
18240
18012
  } catch (error) {
18241
- if (!isEnoent3(error)) throw error;
18013
+ if (!isEnoent2(error)) throw error;
18242
18014
  }
18243
18015
  }
18244
18016
  recordPaths.sort();
@@ -18263,42 +18035,6 @@ var init_host_transition_prior_native = __esm({
18263
18035
  }
18264
18036
  });
18265
18037
 
18266
- // src/public-cli/public-run-credentials.ts
18267
- function knownFailureForMissingProviderCredential(model, credentials) {
18268
- if (model === void 0 || credentials === void 0) return void 0;
18269
- if (model.provider !== "openai-codex" && model.provider !== "xai") return void 0;
18270
- if (!missingPublicProviderCredential(model.provider, credentials)) {
18271
- return void 0;
18272
- }
18273
- return {
18274
- cause: "provider",
18275
- identity: {
18276
- name: "MissingProviderCredential",
18277
- code: model.provider
18278
- }
18279
- };
18280
- }
18281
- function missingCredentialPreDispatchFailure(model, credentials) {
18282
- const knownFailure = knownFailureForMissingProviderCredential(model, credentials);
18283
- if (knownFailure === void 0) return void 0;
18284
- return {
18285
- timedOut: false,
18286
- code: 1,
18287
- stderr: `Missing credential for provider ${String(knownFailure.identity?.code ?? "unknown")}`,
18288
- knownFailure
18289
- };
18290
- }
18291
- function postRunMissingCredentialFailure(result, model, credentials) {
18292
- if (!(result.timedOut || result.code !== 0)) return void 0;
18293
- return knownFailureForMissingProviderCredential(model, credentials);
18294
- }
18295
- var init_public_run_credentials = __esm({
18296
- "src/public-cli/public-run-credentials.ts"() {
18297
- "use strict";
18298
- init_config();
18299
- }
18300
- });
18301
-
18302
18038
  // src/public-cli/process-cancel.ts
18303
18039
  function processCancelSignalName(signal) {
18304
18040
  if (signal === void 0 || signal.aborted !== true) return void 0;
@@ -18735,7 +18471,7 @@ var init_auto_resume = __esm({
18735
18471
 
18736
18472
  // src/public-cli/post-admission.ts
18737
18473
  import { randomUUID as randomUUID6 } from "node:crypto";
18738
- import { writeFile as writeFile10 } from "node:fs/promises";
18474
+ import { writeFile as writeFile9 } from "node:fs/promises";
18739
18475
  import { isAbsolute as isAbsolute8, join as join34, resolve as resolve13 } from "node:path";
18740
18476
  function describeCaughtError(error) {
18741
18477
  if (error instanceof Error) {
@@ -18747,6 +18483,28 @@ function describeCaughtError(error) {
18747
18483
  function isStationChildOfficerDialogue(role, env) {
18748
18484
  return env.stationChild === true && isOfficerReviewSeat(role);
18749
18485
  }
18486
+ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
18487
+ const rewrite = (value) => rewriteRunDirectoryPathValue(
18488
+ value,
18489
+ relocation.oldRunDirectory,
18490
+ relocation.newRunDirectory
18491
+ );
18492
+ const mutableRequest = request;
18493
+ mutableRequest.runDirectory = admitted.runDirectory;
18494
+ mutableRequest.principal = admitted.principal;
18495
+ const activation = mutableRequest.activation;
18496
+ if (activation !== null && typeof activation === "object" && !Array.isArray(activation)) {
18497
+ for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath", "requestManifestPath"]) {
18498
+ const record4 = activation;
18499
+ if (field in record4) record4[field] = rewrite(record4[field]);
18500
+ }
18501
+ }
18502
+ if (result.terminal !== void 0) {
18503
+ for (const artifact of result.terminal.artifacts) {
18504
+ artifact.path = rewrite(artifact.path);
18505
+ }
18506
+ }
18507
+ }
18750
18508
  function withProcessCancelSkipAutoResume(result, signal) {
18751
18509
  if (processCancelSignalName(signal) === void 0) {
18752
18510
  return result;
@@ -18791,8 +18549,8 @@ function withOnceSuccessfulBeforeDispatch(adapters) {
18791
18549
  };
18792
18550
  }
18793
18551
  async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic, io) {
18794
- io.stderr(formatCliDiagnostic(diagnostic));
18795
18552
  const payload = { diagnostic, recordedAt: (/* @__PURE__ */ new Date()).toISOString() };
18553
+ let retentionFailure;
18796
18554
  try {
18797
18555
  await env.sessionAppender(
18798
18556
  env.principalAuthority,
@@ -18800,24 +18558,26 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
18800
18558
  POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE,
18801
18559
  payload
18802
18560
  );
18803
- return;
18804
18561
  } catch (appendError) {
18805
18562
  try {
18806
18563
  const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
18807
- await writeFile10(
18564
+ await writeFile9(
18808
18565
  join34(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
18809
18566
  `${JSON.stringify({ version: 1, ...payload }, null, 2)}
18810
18567
  `,
18811
18568
  { encoding: "utf8", flag: "wx" }
18812
18569
  );
18813
18570
  } catch (artifactError) {
18814
- io.stderr(
18815
- formatCliDiagnostic(
18816
- `post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`
18817
- )
18818
- );
18571
+ retentionFailure = `post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`;
18819
18572
  }
18820
18573
  }
18574
+ try {
18575
+ io.stderr(formatCliDiagnostic(diagnostic));
18576
+ if (retentionFailure !== void 0) {
18577
+ io.stderr(formatCliDiagnostic(retentionFailure));
18578
+ }
18579
+ } catch {
18580
+ }
18821
18581
  }
18822
18582
  async function resolveResumeMethodMaterialAdapters(input) {
18823
18583
  if (input.shouldLoad === false) {
@@ -18977,15 +18737,18 @@ async function dispatchPostAdmissionTurn(input) {
18977
18737
  const ticketNumber = asserted === void 0 ? void 0 : asserted.ticketNumber;
18978
18738
  if (ticketNumber !== void 0) await bindAdmittedTicketNumber(admitted, ticketNumber);
18979
18739
  }
18740
+ const relocation = await relocateAdmittedRunToTicket(admitted, env.principalAuthority, lease);
18741
+ if (relocation !== void 0) {
18742
+ projectRelocatedTurnIdentity(request, result, admitted, relocation);
18743
+ }
18980
18744
  if (adapters.afterDispatch !== void 0) await adapters.afterDispatch(admitted, lease);
18981
18745
  return result;
18982
18746
  } catch (error) {
18983
- const primaryFailure = result.terminal !== void 0 && !isLawfulTypedTerminalOutcome(result.terminal.roleOutcome);
18984
- if (primaryFailure) {
18747
+ if (result.terminal !== void 0) {
18985
18748
  await recordBestEffortPostDispatchDiagnostic(
18986
18749
  admitted,
18987
18750
  env,
18988
- `afterDispatch failed beside primary terminal (best-effort continue): ${describeErrorIdentity(error)}`,
18751
+ `afterDispatch failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
18989
18752
  io
18990
18753
  );
18991
18754
  return result;
@@ -19011,23 +18774,6 @@ async function dispatchPostAdmissionTurn(input) {
19011
18774
  }
19012
18775
  };
19013
18776
  try {
19014
- const missingCredential = missingCredentialPreDispatchFailure(
19015
- env.model,
19016
- env.credentials
19017
- );
19018
- if (missingCredential !== void 0) {
19019
- return {
19020
- ...await presentControlledFailure2(
19021
- admitted,
19022
- withEngineDetourInvocationScope(missingCredential, request.invocationScopeId),
19023
- adapters,
19024
- env.principalAuthority,
19025
- io,
19026
- persistRunState
19027
- ),
19028
- ...deferredPersist
19029
- };
19030
- }
19031
18777
  let previousHost;
19032
18778
  const liveHost = env.host;
19033
18779
  const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
@@ -19135,7 +18881,7 @@ async function dispatchPostAdmissionTurn(input) {
19135
18881
  }
19136
18882
  let stderrLogWriteFailure;
19137
18883
  try {
19138
- await writeFile10(
18884
+ await writeFile9(
19139
18885
  join34(admitted.runDirectory, "stderr.log"),
19140
18886
  result.stderr,
19141
18887
  "utf8"
@@ -19160,19 +18906,14 @@ async function dispatchPostAdmissionTurn(input) {
19160
18906
  try {
19161
18907
  const sessionFile = admitted.principal !== void 0 ? env.principalAuthority.decode(admitted.principal).sessionFile : "";
19162
18908
  const runnerKnownFailure = adapters.resolveRunnerKnownFailure !== void 0 && sessionFile !== "" ? await adapters.resolveRunnerKnownFailure({ result, sessionFile }) : result.knownFailure;
19163
- const credentialFailure = postRunMissingCredentialFailure(
19164
- result,
19165
- env.model,
19166
- env.credentials
19167
- );
19168
18909
  resolution = await resolveAuditedRunnerFailureResolution({
19169
18910
  runner: runnerKnownFailure,
19170
18911
  sessionFile,
19171
- credential: credentialFailure,
18912
+ credential: void 0,
19172
18913
  runDirectory: admitted.runDirectory
19173
18914
  });
19174
18915
  const processCancelName = processCancelSignalName(env.signal);
19175
- const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 || credentialFailure !== void 0 || processCancelName !== void 0;
18916
+ const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 || processCancelName !== void 0;
19176
18917
  hostSignalFailed = directHostFailureSignal || result.code !== null && result.code !== 0 || resolution.knownFailure !== void 0;
19177
18918
  settled = await adapters.trySettle(admitted, env.principalAuthority, courtScope);
19178
18919
  if (settled !== void 0) {
@@ -19238,25 +18979,11 @@ async function dispatchPostAdmissionTurn(input) {
19238
18979
  try {
19239
18980
  await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
19240
18981
  } catch (error) {
19241
- const failed = await settleAfterTurnStarted(
18982
+ await recordBestEffortPostDispatchDiagnostic(
19242
18983
  admitted,
19243
- withEngineDetourInvocationScope({
19244
- timedOut: false,
19245
- code: null,
19246
- stderr: "",
19247
- thrown: error,
19248
- skipRunStateWrite: true
19249
- }, request.invocationScopeId),
19250
- adapters,
19251
- env.principalAuthority,
19252
- io,
19253
- persistRunState
19254
- );
19255
- return await finishAfterTurn(
19256
- withProcessCancelSkipAutoResume(
19257
- { ...failed, turnDispatched: true, ...deferredPersist },
19258
- env.signal
19259
- )
18984
+ env,
18985
+ `run-state persistence failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
18986
+ io
19260
18987
  );
19261
18988
  }
19262
18989
  }
@@ -19337,25 +19064,11 @@ async function dispatchPostAdmissionTurn(input) {
19337
19064
  try {
19338
19065
  await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
19339
19066
  } catch (error) {
19340
- const failed = await settleAfterTurnStarted(
19067
+ await recordBestEffortPostDispatchDiagnostic(
19341
19068
  admitted,
19342
- withEngineDetourInvocationScope({
19343
- timedOut: false,
19344
- code: null,
19345
- stderr: "",
19346
- thrown: error,
19347
- skipRunStateWrite: true
19348
- }, request.invocationScopeId),
19349
- adapters,
19350
- env.principalAuthority,
19351
- io,
19352
- persistRunState
19353
- );
19354
- return await finishAfterTurn(
19355
- withProcessCancelSkipAutoResume(
19356
- { ...failed, turnDispatched: true, ...deferredPersist },
19357
- env.signal
19358
- )
19069
+ env,
19070
+ `run-state persistence failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
19071
+ io
19359
19072
  );
19360
19073
  }
19361
19074
  }
@@ -19367,14 +19080,16 @@ async function dispatchPostAdmissionTurn(input) {
19367
19080
  ...deferredPersist
19368
19081
  });
19369
19082
  } finally {
19370
- try {
19371
- await lease.release();
19372
- } catch (error) {
19373
- io.stderr(
19374
- formatCliDiagnostic(
19375
- `writer lease release failed unexpectedly (best-effort continue): ${describeErrorIdentity(error)}`
19376
- )
19377
- );
19083
+ if (lease !== void 0) {
19084
+ try {
19085
+ await lease.release();
19086
+ } catch (error) {
19087
+ io.stderr(
19088
+ formatCliDiagnostic(
19089
+ `writer lease release failed unexpectedly (best-effort continue): ${describeErrorIdentity(error)}`
19090
+ )
19091
+ );
19092
+ }
19378
19093
  }
19379
19094
  }
19380
19095
  }
@@ -19689,53 +19404,29 @@ async function runPostAdmissionManualResume(input) {
19689
19404
  } = input;
19690
19405
  let request = input.request;
19691
19406
  const effectiveModel = env.model;
19692
- let lease;
19693
- let staleWriterLeaseReclaimed;
19694
- try {
19695
- lease = await acquireRunWriterLease(admitted.runDirectory, (diagnostic, kind) => {
19696
- if (kind === "stale-reclaimed") staleWriterLeaseReclaimed = true;
19697
- io.stderr(diagnostic);
19698
- });
19699
- } catch (error) {
19700
- if (error instanceof RunWriterLeaseHeldError) {
19701
- io.stderr(formatCliDiagnostic(error.message));
19702
- return {
19703
- exitCode: 1,
19704
- ...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
19705
- };
19706
- }
19707
- throw error;
19708
- }
19709
19407
  const invocationScopeId = mintEngineDetourInvocationScope({
19710
19408
  ...effectiveEngine === void 0 ? {} : { effectiveEngine }
19711
19409
  });
19712
- const result = await dispatchAfterWriterLease({
19713
- lease,
19714
- build: async () => {
19715
- if (request === void 0) {
19716
- if (buildRequestAfterLease === void 0) {
19717
- throw new Error(
19718
- "runPostAdmissionManualResume requires request or buildRequestAfterLease"
19719
- );
19720
- }
19721
- request = await buildRequestAfterLease();
19722
- }
19723
- request = withEngineDetourInvocationScope(request, invocationScopeId);
19724
- return request;
19410
+ if (request === void 0) {
19411
+ if (buildRequestAfterLease === void 0) {
19412
+ throw new Error(
19413
+ "runPostAdmissionManualResume requires request or buildRequestAfterLease"
19414
+ );
19415
+ }
19416
+ request = await buildRequestAfterLease();
19417
+ }
19418
+ request = withEngineDetourInvocationScope(request, invocationScopeId);
19419
+ const result = await dispatchPostAdmissionTurn({
19420
+ admitted,
19421
+ env: {
19422
+ ...env,
19423
+ ...effectiveModel === void 0 ? {} : { model: effectiveModel },
19424
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
19725
19425
  },
19726
- dispatch: (turnRequest) => dispatchPostAdmissionTurn({
19727
- admitted,
19728
- env: {
19729
- ...env,
19730
- ...effectiveModel === void 0 ? {} : { model: effectiveModel },
19731
- ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
19732
- },
19733
- io,
19734
- request: turnRequest,
19735
- lease,
19736
- adapters,
19737
- ...effectiveEngine === void 0 ? {} : { effectiveEngine }
19738
- })
19426
+ io,
19427
+ request,
19428
+ adapters,
19429
+ ...effectiveEngine === void 0 ? {} : { effectiveEngine }
19739
19430
  });
19740
19431
  if (result.terminal !== void 0 && isLawfulTypedTerminalOutcome(result.terminal.roleOutcome)) {
19741
19432
  io.stdout(formatTerminalResult(result.terminal));
@@ -19743,10 +19434,7 @@ async function runPostAdmissionManualResume(input) {
19743
19434
  if (result.terminal !== void 0) {
19744
19435
  result.terminal.autoResumeCount = 0;
19745
19436
  }
19746
- return {
19747
- ...result,
19748
- ...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
19749
- };
19437
+ return result;
19750
19438
  }
19751
19439
  var StationChildExhaustedError, POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE;
19752
19440
  var init_post_admission = __esm({
@@ -19759,11 +19447,11 @@ var init_post_admission = __esm({
19759
19447
  init_activation_ledger_topology();
19760
19448
  init_engine_material();
19761
19449
  init_session_identity();
19450
+ init_role_run_relocation();
19762
19451
  init_host_contracts();
19763
19452
  init_case_dossier_delivery();
19764
19453
  init_engine_detour_usage();
19765
19454
  init_host_transition_prior_native();
19766
- init_public_run_credentials();
19767
19455
  init_run_lifecycle();
19768
19456
  init_process_cancel();
19769
19457
  init_activation_ledger_topology();
@@ -21653,7 +21341,7 @@ __export(public_role_summons_exports, {
21653
21341
  withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
21654
21342
  });
21655
21343
  import { execFile as execFile3 } from "node:child_process";
21656
- import { existsSync as existsSync11 } from "node:fs";
21344
+ import { existsSync as existsSync10 } from "node:fs";
21657
21345
  import { mkdir as mkdir4, mkdtemp as mkdtemp4, realpath as realpath6, rm as rm5 } from "node:fs/promises";
21658
21346
  import { tmpdir as tmpdir4 } from "node:os";
21659
21347
  import { join as join35, relative as relative3, sep as sep5 } from "node:path";
@@ -21680,7 +21368,7 @@ function parentDir(path) {
21680
21368
  function walkPackageRoot(start) {
21681
21369
  let dir = start;
21682
21370
  for (let i = 0; i < 12; i += 1) {
21683
- if (existsSync11(join35(dir, "package.json")) && existsSync11(join35(dir, "souls"))) {
21371
+ if (existsSync10(join35(dir, "package.json")) && existsSync10(join35(dir, "souls"))) {
21684
21372
  return dir;
21685
21373
  }
21686
21374
  const parent = parentDir(dir);
@@ -22383,7 +22071,7 @@ import { randomUUID as randomUUID10 } from "node:crypto";
22383
22071
  // src/role-envelope.ts
22384
22072
  init_engine_detour();
22385
22073
  import { randomUUID as randomUUID9 } from "node:crypto";
22386
- import { appendFile as appendFile3, mkdir as mkdir6, writeFile as writeFile12 } from "node:fs/promises";
22074
+ import { appendFile as appendFile3, mkdir as mkdir6, writeFile as writeFile11 } from "node:fs/promises";
22387
22075
  import { createServer } from "node:net";
22388
22076
  import { dirname as dirname21, join as join41 } from "node:path";
22389
22077
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -22481,7 +22169,7 @@ async function requireGatekeeperPass(options) {
22481
22169
  }
22482
22170
 
22483
22171
  // src/host-native-method.ts
22484
- import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as readdir9, readFile as readFile20, readlink, realpath as realpath7, symlink } from "node:fs/promises";
22172
+ import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as readdir8, readFile as readFile19, readlink, realpath as realpath7, symlink } from "node:fs/promises";
22485
22173
  import { basename as basename9, dirname as dirname18, join as join36 } from "node:path";
22486
22174
  var packagedMethodsDir = (root) => join36(root, "resources", "methods");
22487
22175
  function hostMethodSkills(methods) {
@@ -22491,16 +22179,16 @@ function hostMethodSkills(methods) {
22491
22179
  return name ? [Object.freeze({ name })] : [];
22492
22180
  }));
22493
22181
  }
22494
- var isEnoent4 = (error) => error.code === "ENOENT";
22182
+ var isEnoent3 = (error) => error.code === "ENOENT";
22495
22183
  async function packagedMethodSkillNames(packagedMethodsRealpath) {
22496
- const entries = await readdir9(packagedMethodsRealpath, { withFileTypes: true });
22184
+ const entries = await readdir8(packagedMethodsRealpath, { withFileTypes: true });
22497
22185
  const names = [];
22498
22186
  for (const entry of entries) {
22499
22187
  if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
22500
22188
  try {
22501
22189
  await access4(join36(packagedMethodsRealpath, entry.name, "SKILL.md"));
22502
22190
  } catch (error) {
22503
- if (isEnoent4(error)) continue;
22191
+ if (isEnoent3(error)) continue;
22504
22192
  throw error;
22505
22193
  }
22506
22194
  names.push(entry.name);
@@ -22511,12 +22199,12 @@ async function packagedSkillFileBytes(skillDir) {
22511
22199
  try {
22512
22200
  await access4(join36(skillDir, "SKILL.md"));
22513
22201
  } catch (error) {
22514
- if (isEnoent4(error)) return void 0;
22202
+ if (isEnoent3(error)) return void 0;
22515
22203
  throw error;
22516
22204
  }
22517
22205
  const files = /* @__PURE__ */ new Map();
22518
22206
  async function walk(dir, prefix) {
22519
- const entries = await readdir9(dir, { withFileTypes: true });
22207
+ const entries = await readdir8(dir, { withFileTypes: true });
22520
22208
  for (const entry of entries) {
22521
22209
  const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
22522
22210
  const full = join36(dir, entry.name);
@@ -22525,7 +22213,7 @@ async function packagedSkillFileBytes(skillDir) {
22525
22213
  continue;
22526
22214
  }
22527
22215
  if (entry.isFile()) {
22528
- files.set(rel, await readFile20(full));
22216
+ files.set(rel, await readFile19(full));
22529
22217
  }
22530
22218
  }
22531
22219
  }
@@ -22536,9 +22224,9 @@ async function catalogPublishesPackagedSkill(catalogSkillDir, required) {
22536
22224
  for (const [rel, bytes] of required) {
22537
22225
  let other;
22538
22226
  try {
22539
- other = await readFile20(join36(catalogSkillDir, rel));
22227
+ other = await readFile19(join36(catalogSkillDir, rel));
22540
22228
  } catch (error) {
22541
- if (isEnoent4(error)) return false;
22229
+ if (isEnoent3(error)) return false;
22542
22230
  throw error;
22543
22231
  }
22544
22232
  if (!bytes.equals(other)) return false;
@@ -22552,7 +22240,7 @@ async function isCompatibleMethodCatalog(link, packagedMethodsRealpath) {
22552
22240
  try {
22553
22241
  resolved = await realpath7(link);
22554
22242
  } catch (error) {
22555
- if (isEnoent4(error)) return false;
22243
+ if (isEnoent3(error)) return false;
22556
22244
  throw error;
22557
22245
  }
22558
22246
  if (resolved === packagedMethodsRealpath) return true;
@@ -22573,7 +22261,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
22573
22261
  await lstat7(link);
22574
22262
  present = true;
22575
22263
  } catch (error) {
22576
- if (!isEnoent4(error)) throw error;
22264
+ if (!isEnoent3(error)) throw error;
22577
22265
  present = false;
22578
22266
  }
22579
22267
  if (present) {
@@ -23035,18 +22723,18 @@ init_collector_evidence();
23035
22723
  init_collector_github();
23036
22724
 
23037
22725
  // src/collector-handbook.ts
23038
- import { readFile as readFile21 } from "node:fs/promises";
22726
+ import { readFile as readFile20 } from "node:fs/promises";
23039
22727
  import { join as join38, sep as sep6 } from "node:path";
23040
22728
 
23041
22729
  // src/atomic-write.ts
23042
22730
  import { randomUUID as randomUUID7 } from "node:crypto";
23043
- import { rename as rename3, rm as rm6, writeFile as writeFile11 } from "node:fs/promises";
22731
+ import { rename as rename3, rm as rm6, writeFile as writeFile10 } from "node:fs/promises";
23044
22732
  import { dirname as dirname19, join as join37 } from "node:path";
23045
22733
  async function writeFileAtomically(destination, contents) {
23046
22734
  const parent = dirname19(destination);
23047
22735
  const temporary = join37(parent, `.atomic-write-${randomUUID7()}.tmp`);
23048
22736
  try {
23049
- await writeFile11(temporary, contents);
22737
+ await writeFile10(temporary, contents);
23050
22738
  await rename3(temporary, destination);
23051
22739
  } catch (error) {
23052
22740
  await rm6(temporary, { force: true }).catch(() => void 0);
@@ -23198,7 +22886,7 @@ function createCollectorHandbookStore(input) {
23198
22886
  ensureRealDirectoryTree(input.ledgerHome, parentDir2);
23199
22887
  assertLedgerFileInsideHome(path, input.ledgerHome);
23200
22888
  try {
23201
- const body = await readFile21(path, "utf8");
22889
+ const body = await readFile20(path, "utf8");
23202
22890
  assertHandbookBudget(body, "\u6B63\u6587");
23203
22891
  return body;
23204
22892
  } catch (error) {
@@ -25510,7 +25198,7 @@ init_sitian_facade();
25510
25198
  init_submission_errors();
25511
25199
  init_submission_errors();
25512
25200
  import { execFileSync as execFileSync4 } from "node:child_process";
25513
- import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
25201
+ import { existsSync as existsSync11, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
25514
25202
  import { resolve as resolve17 } from "node:path";
25515
25203
  var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
25516
25204
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
@@ -25541,7 +25229,7 @@ function statusOf(error) {
25541
25229
  return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
25542
25230
  }
25543
25231
  function tryGetAll(file, key) {
25544
- if (!existsSync12(file)) return [];
25232
+ if (!existsSync11(file)) return [];
25545
25233
  try {
25546
25234
  const out = gitFile(file, ["--get-all", key]);
25547
25235
  return out.length === 0 ? [] : out.split("\n");
@@ -25551,7 +25239,7 @@ function tryGetAll(file, key) {
25551
25239
  }
25552
25240
  }
25553
25241
  function ownedHook(path) {
25554
- if (!existsSync12(path)) return false;
25242
+ if (!existsSync11(path)) return false;
25555
25243
  return readFileSync5(path, "utf8").includes(HOOK_MARKER);
25556
25244
  }
25557
25245
  function escapeGitConfigValueRegex(value) {
@@ -25578,11 +25266,11 @@ function rmOwnedDir(dir) {
25578
25266
  const hookPath = resolve17(dir, HOOK_FILE);
25579
25267
  if (!ownedHook(hookPath)) return;
25580
25268
  rmSync(hookPath, { force: true });
25581
- if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
25269
+ if (existsSync11(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
25582
25270
  }
25583
25271
  function linkedGitDirs(commonDir) {
25584
25272
  const root = resolve17(commonDir, "worktrees");
25585
- if (!existsSync12(root)) return [];
25273
+ if (!existsSync11(root)) return [];
25586
25274
  return readdirSync3(root).map((name) => resolve17(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
25587
25275
  }
25588
25276
  function uninstallPackageWorkerHooks(cwd) {
@@ -27814,7 +27502,7 @@ async function prepareRoleEnvelope(options) {
27814
27502
  await mkdir6(dirname21(sessionFile), { recursive: true });
27815
27503
  if (request.continuation.kind !== "resume") {
27816
27504
  try {
27817
- await writeFile12(
27505
+ await writeFile11(
27818
27506
  sessionFile,
27819
27507
  `${JSON.stringify({
27820
27508
  type: "session",
@@ -28354,11 +28042,11 @@ async function prepareRoleEnvelope(options) {
28354
28042
  }
28355
28043
 
28356
28044
  // src/role-runtime-dependencies.ts
28357
- import { readFile as readFile24 } from "node:fs/promises";
28045
+ import { readFile as readFile23 } from "node:fs/promises";
28358
28046
  import { join as join42 } from "node:path";
28359
28047
 
28360
28048
  // src/canonical-skill-binding.ts
28361
- import { readFile as readFile22, realpath as realpath8 } from "node:fs/promises";
28049
+ import { readFile as readFile21, realpath as realpath8 } from "node:fs/promises";
28362
28050
  import { homedir } from "node:os";
28363
28051
  import { dirname as dirname22, resolve as resolve18 } from "node:path";
28364
28052
  import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
@@ -28391,7 +28079,7 @@ async function loadCanonicalSkillBinding(name) {
28391
28079
  let raw;
28392
28080
  try {
28393
28081
  path = await realpath8(configuredPath);
28394
- raw = await readFile22(path, "utf8");
28082
+ raw = await readFile21(path, "utf8");
28395
28083
  } catch (error) {
28396
28084
  throw new CanonicalSkillUnavailableError(name, configuredPath, error);
28397
28085
  }
@@ -28430,7 +28118,7 @@ init_doctor_evidence();
28430
28118
  // src/navigator-work-context.ts
28431
28119
  init_doctor_evidence();
28432
28120
  init_host_contracts();
28433
- import { readFile as readFile23 } from "node:fs/promises";
28121
+ import { readFile as readFile22 } from "node:fs/promises";
28434
28122
  import { resolve as resolve19 } from "node:path";
28435
28123
  init_notary_source_run();
28436
28124
  init_packaged_role_registry();
@@ -28443,7 +28131,7 @@ function navigatorInputReference(getFlag, role) {
28443
28131
  }
28444
28132
  async function loadNavigatorWorkContext(options) {
28445
28133
  const reference = navigatorInputReference(options.getFlag, options.role);
28446
- const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile23(reference, "utf8");
28134
+ const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile22(reference, "utf8");
28447
28135
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
28448
28136
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
28449
28137
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -28500,7 +28188,7 @@ async function loadNavigatorWorkContext(options) {
28500
28188
  let authorityMaterial;
28501
28189
  for (const path of authorityFiles) {
28502
28190
  try {
28503
- const content = await readFile23(path, "utf8");
28191
+ const content = await readFile22(path, "utf8");
28504
28192
  if (content.trim() !== "") {
28505
28193
  authorityMaterial = content;
28506
28194
  break;
@@ -28569,12 +28257,12 @@ function createRoleRuntimeDependencies(packageRoot) {
28569
28257
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
28570
28258
  loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
28571
28259
  loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
28572
- loadFixPacket: (path) => readFile24(path, "utf8"),
28260
+ loadFixPacket: (path) => readFile23(path, "utf8"),
28573
28261
  loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
28574
- loadCoderTask: (path) => readFile24(path, "utf8"),
28262
+ loadCoderTask: (path) => readFile23(path, "utf8"),
28575
28263
  loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
28576
28264
  loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
28577
- loadCollectorHandbookSeed: () => readFile24(collectorHandbookSeedPath, "utf8"),
28265
+ loadCollectorHandbookSeed: () => readFile23(collectorHandbookSeedPath, "utf8"),
28578
28266
  createCollectorTransport: () => createGhCollectorGitHubTransport(),
28579
28267
  loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
28580
28268
  loadDoctorCase,
@@ -28589,7 +28277,7 @@ function createRoleRuntimeDependencies(packageRoot) {
28589
28277
  loadSecretariatSoul: () => loadMainRoleSessionMaterials("secretariat"),
28590
28278
  loadNotarySourceRun: loadNotarySourceRunLocator,
28591
28279
  loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
28592
- loadMergerInput: async (path) => JSON.parse(await readFile24(path, "utf8")),
28280
+ loadMergerInput: async (path) => JSON.parse(await readFile23(path, "utf8")),
28593
28281
  async loadCanonicalSkillBinding(name) {
28594
28282
  if (name === "tdd") {
28595
28283
  return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
@@ -28615,7 +28303,7 @@ function createRoleRuntimeDependencies(packageRoot) {
28615
28303
  authority: options.authority,
28616
28304
  invocationId: options.invocationId,
28617
28305
  loadSoul: () => loadMainRoleSessionMaterials("navigator"),
28618
- loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
28306
+ loadRoutePlaybook: () => readFile23(navigatorRoutePlaybookPath, "utf8"),
28619
28307
  loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
28620
28308
  createSession: navigatorSessionFactory,
28621
28309
  ...options.contextError === void 0 ? {} : { contextError: options.contextError },