@akagilnc/pi-workflow-roles 0.1.4759 → 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.
- package/dist/acp-host/production-host.js +227 -428
- package/dist/headless-host/production-host.js +233 -434
- package/dist/migrate-book-topology.js +1255 -1087
- package/dist/notary-source-run.js +12 -2
- package/dist/public-cli/invocation.js +11 -8
- package/dist/public-cli/main.js +198 -399
- package/dist/public-cli/post-admission.js +27 -1
- package/dist/public-cli/run-lifecycle.js +25 -4
- package/dist/role-run-relocation.js +19 -18
- package/package.json +1 -1
- package/src/book-topology-migration-placement.ts +9 -1
- package/src/book-topology-runs-migrator.ts +156 -4
- package/src/notary-source-run.ts +18 -2
- package/src/public-cli/invocation.ts +13 -9
- package/src/public-cli/post-admission.ts +36 -0
- package/src/public-cli/run-lifecycle.ts +42 -4
- package/src/role-run-relocation.ts +27 -30
|
@@ -1907,10 +1907,10 @@ __export(session_assistant_usage_exports, {
|
|
|
1907
1907
|
});
|
|
1908
1908
|
import { join as join6 } from "node:path";
|
|
1909
1909
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
1910
|
-
const { readFile:
|
|
1910
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
1911
1911
|
let text;
|
|
1912
1912
|
try {
|
|
1913
|
-
text = await
|
|
1913
|
+
text = await readFile24(sessionFile, "utf8");
|
|
1914
1914
|
} catch (error) {
|
|
1915
1915
|
if (error?.code === "ENOENT") return void 0;
|
|
1916
1916
|
throw error;
|
|
@@ -4275,12 +4275,7 @@ var init_host_descriptions = __esm({
|
|
|
4275
4275
|
});
|
|
4276
4276
|
|
|
4277
4277
|
// src/role-run-relocation.ts
|
|
4278
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
4279
|
-
import { readdir as readdir3, readFile as readFile7, writeFile as writeFile2 } from "node:fs/promises";
|
|
4280
4278
|
import { join as join12, sep as sep2 } from "node:path";
|
|
4281
|
-
function isEnoent2(error) {
|
|
4282
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
4283
|
-
}
|
|
4284
4279
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
4285
4280
|
if (typeof value !== "string") return value;
|
|
4286
4281
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -4322,23 +4317,6 @@ function rewriteRunDirectoryPathFieldsAgainstRewrites(record4, fields, rewrites)
|
|
|
4322
4317
|
}
|
|
4323
4318
|
}
|
|
4324
4319
|
}
|
|
4325
|
-
function collectRewrites(input) {
|
|
4326
|
-
const own = {
|
|
4327
|
-
oldRunDirectory: input.oldRunDirectory,
|
|
4328
|
-
newRunDirectory: input.newRunDirectory
|
|
4329
|
-
};
|
|
4330
|
-
if (input.crossRunRewrites === void 0 || input.crossRunRewrites.length === 0) {
|
|
4331
|
-
return [own];
|
|
4332
|
-
}
|
|
4333
|
-
const seen = /* @__PURE__ */ new Set([own.oldRunDirectory]);
|
|
4334
|
-
const out = [own];
|
|
4335
|
-
for (const rewrite of input.crossRunRewrites) {
|
|
4336
|
-
if (seen.has(rewrite.oldRunDirectory)) continue;
|
|
4337
|
-
seen.add(rewrite.oldRunDirectory);
|
|
4338
|
-
out.push(rewrite);
|
|
4339
|
-
}
|
|
4340
|
-
return out;
|
|
4341
|
-
}
|
|
4342
4320
|
function isPlainObject(value) {
|
|
4343
4321
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4344
4322
|
}
|
|
@@ -4350,254 +4328,25 @@ function rewriteSourceRunLocator(value, rewrites) {
|
|
|
4350
4328
|
rewrites
|
|
4351
4329
|
);
|
|
4352
4330
|
}
|
|
4353
|
-
function
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
rewriteSourceRunLocator(value.sourceRun, rewrites);
|
|
4361
|
-
if (Array.isArray(value.attachmentPaths)) {
|
|
4362
|
-
value.attachmentPaths = value.attachmentPaths.map(
|
|
4363
|
-
(path) => rewriteRunDirectoryPathValueAgainstRewrites(path, rewrites)
|
|
4364
|
-
);
|
|
4365
|
-
}
|
|
4366
|
-
}
|
|
4367
|
-
async function rewriteJsonObjectFile(path, fields, rewrites) {
|
|
4368
|
-
if (!existsSync4(path)) return;
|
|
4369
|
-
const page = JSON.parse(await readFile7(path, "utf8"));
|
|
4370
|
-
if (!isPlainObject(page)) return;
|
|
4371
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(page, fields, rewrites);
|
|
4372
|
-
await writeFile2(path, `${JSON.stringify(page, null, 2)}
|
|
4373
|
-
`, "utf8");
|
|
4374
|
-
}
|
|
4375
|
-
async function rewriteOfficerPointerFile(path, rewrites) {
|
|
4376
|
-
if (!existsSync4(path)) return;
|
|
4377
|
-
const page = JSON.parse(await readFile7(path, "utf8"));
|
|
4378
|
-
if (!isPlainObject(page)) return;
|
|
4379
|
-
if (page.kind !== "direct-officer-run-pointer") return;
|
|
4380
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4381
|
-
page,
|
|
4382
|
-
OFFICER_POINTER_FIELDS,
|
|
4383
|
-
rewrites
|
|
4384
|
-
);
|
|
4385
|
-
await writeFile2(path, `${JSON.stringify(page)}
|
|
4386
|
-
`, "utf8");
|
|
4387
|
-
}
|
|
4388
|
-
async function rewriteSitianRecordsJsonl(path, rewrites) {
|
|
4389
|
-
if (!existsSync4(path)) return;
|
|
4390
|
-
const raw = await readFile7(path, "utf8");
|
|
4391
|
-
if (raw.length === 0) return;
|
|
4392
|
-
const endsWithNewline = raw.endsWith("\n");
|
|
4393
|
-
const lines = raw.split("\n");
|
|
4394
|
-
let changed = false;
|
|
4395
|
-
const out = [];
|
|
4396
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
4397
|
-
const line2 = lines[i];
|
|
4398
|
-
if (line2 === "" && i === lines.length - 1 && endsWithNewline) {
|
|
4399
|
-
out.push("");
|
|
4400
|
-
continue;
|
|
4401
|
-
}
|
|
4402
|
-
if (line2.trim() === "") {
|
|
4403
|
-
out.push(line2);
|
|
4404
|
-
continue;
|
|
4405
|
-
}
|
|
4406
|
-
let parsed;
|
|
4407
|
-
try {
|
|
4408
|
-
parsed = JSON.parse(line2);
|
|
4409
|
-
} catch {
|
|
4410
|
-
out.push(line2);
|
|
4411
|
-
continue;
|
|
4412
|
-
}
|
|
4413
|
-
if (!isPlainObject(parsed)) {
|
|
4414
|
-
out.push(line2);
|
|
4415
|
-
continue;
|
|
4416
|
-
}
|
|
4417
|
-
if (!("sessionParent" in parsed)) {
|
|
4418
|
-
out.push(line2);
|
|
4419
|
-
continue;
|
|
4420
|
-
}
|
|
4421
|
-
const before = parsed.sessionParent;
|
|
4422
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4423
|
-
parsed,
|
|
4424
|
-
SITIAN_RECORD_FIELDS,
|
|
4425
|
-
rewrites
|
|
4426
|
-
);
|
|
4427
|
-
if (parsed.sessionParent !== before) changed = true;
|
|
4428
|
-
out.push(JSON.stringify(parsed));
|
|
4429
|
-
}
|
|
4430
|
-
if (!changed) return;
|
|
4431
|
-
const body = out.join("\n");
|
|
4432
|
-
await writeFile2(
|
|
4433
|
-
path,
|
|
4434
|
-
endsWithNewline && !body.endsWith("\n") ? `${body}
|
|
4435
|
-
` : body,
|
|
4436
|
-
"utf8"
|
|
4437
|
-
);
|
|
4438
|
-
}
|
|
4439
|
-
async function rewriteSessionTranscriptBindings(path, rewrites) {
|
|
4440
|
-
if (!existsSync4(path)) return;
|
|
4441
|
-
const raw = await readFile7(path, "utf8");
|
|
4442
|
-
if (raw.length === 0) return;
|
|
4443
|
-
const endsWithNewline = raw.endsWith("\n");
|
|
4444
|
-
const lines = raw.split("\n");
|
|
4445
|
-
let changed = false;
|
|
4446
|
-
const out = [];
|
|
4447
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
4448
|
-
const line2 = lines[i];
|
|
4449
|
-
if (line2 === "" && i === lines.length - 1 && endsWithNewline) {
|
|
4450
|
-
out.push("");
|
|
4451
|
-
continue;
|
|
4452
|
-
}
|
|
4453
|
-
if (line2.trim() === "") {
|
|
4454
|
-
out.push(line2);
|
|
4455
|
-
continue;
|
|
4456
|
-
}
|
|
4457
|
-
let parsed;
|
|
4458
|
-
try {
|
|
4459
|
-
parsed = JSON.parse(line2);
|
|
4460
|
-
} catch {
|
|
4461
|
-
out.push(line2);
|
|
4462
|
-
continue;
|
|
4463
|
-
}
|
|
4464
|
-
if (!isPlainObject(parsed)) {
|
|
4465
|
-
out.push(line2);
|
|
4466
|
-
continue;
|
|
4467
|
-
}
|
|
4468
|
-
let lineChanged = false;
|
|
4469
|
-
if (parsed.type === "session" && "parentSession" in parsed) {
|
|
4470
|
-
const before = parsed.parentSession;
|
|
4471
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4472
|
-
parsed,
|
|
4473
|
-
SESSION_HEADER_FIELDS,
|
|
4474
|
-
rewrites
|
|
4475
|
-
);
|
|
4476
|
-
if (parsed.parentSession !== before) lineChanged = true;
|
|
4477
|
-
} else if (parsed.type === "custom" && parsed.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE && isPlainObject(parsed.data) && isPlainObject(parsed.data.parent)) {
|
|
4478
|
-
const parent = parsed.data.parent;
|
|
4479
|
-
const before = parent.sessionFile;
|
|
4480
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4481
|
-
parent,
|
|
4482
|
-
BINDING_PARENT_FIELDS,
|
|
4483
|
-
rewrites
|
|
4484
|
-
);
|
|
4485
|
-
if (parent.sessionFile !== before) lineChanged = true;
|
|
4486
|
-
}
|
|
4487
|
-
if (lineChanged) changed = true;
|
|
4488
|
-
out.push(lineChanged ? JSON.stringify(parsed) : line2);
|
|
4489
|
-
}
|
|
4490
|
-
if (!changed) return;
|
|
4491
|
-
const body = out.join("\n");
|
|
4492
|
-
await writeFile2(
|
|
4493
|
-
path,
|
|
4494
|
-
endsWithNewline && !body.endsWith("\n") ? `${body}
|
|
4495
|
-
` : body,
|
|
4496
|
-
"utf8"
|
|
4497
|
-
);
|
|
4498
|
-
}
|
|
4499
|
-
async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
4500
|
-
const sessionRoot = join12(pagesDirectory, "session");
|
|
4501
|
-
async function walk(directory) {
|
|
4502
|
-
let entries;
|
|
4503
|
-
try {
|
|
4504
|
-
entries = await readdir3(directory, { withFileTypes: true });
|
|
4505
|
-
} catch (error) {
|
|
4506
|
-
if (isEnoent2(error)) return;
|
|
4507
|
-
throw error;
|
|
4508
|
-
}
|
|
4509
|
-
for (const entry of entries) {
|
|
4510
|
-
const path = join12(directory, entry.name);
|
|
4511
|
-
if (entry.isDirectory()) {
|
|
4512
|
-
await walk(path);
|
|
4513
|
-
continue;
|
|
4514
|
-
}
|
|
4515
|
-
if (!entry.isFile()) continue;
|
|
4516
|
-
if (entry.name === "current-session.json") {
|
|
4517
|
-
await rewriteJsonObjectFile(path, CURRENT_SESSION_FIELDS, rewrites);
|
|
4518
|
-
} else if (entry.name.endsWith(".pointer.json")) {
|
|
4519
|
-
await rewriteOfficerPointerFile(path, rewrites);
|
|
4520
|
-
} else if (entry.name === "records.jsonl") {
|
|
4521
|
-
await rewriteSitianRecordsJsonl(path, rewrites);
|
|
4522
|
-
} else if (entry.name.endsWith(".jsonl")) {
|
|
4523
|
-
await rewriteSessionTranscriptBindings(path, rewrites);
|
|
4331
|
+
function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
4332
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
|
|
4333
|
+
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
4334
|
+
if (Array.isArray(page.attachments)) {
|
|
4335
|
+
for (const attachment of page.attachments) {
|
|
4336
|
+
if (isPlainObject(attachment)) {
|
|
4337
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
|
|
4524
4338
|
}
|
|
4525
4339
|
}
|
|
4526
4340
|
}
|
|
4527
|
-
|
|
4528
|
-
}
|
|
4529
|
-
async function rewriteRoleRunDurablePages(input) {
|
|
4530
|
-
const { pagesDirectory } = input;
|
|
4531
|
-
const rewrites = collectRewrites(input);
|
|
4532
|
-
const admittedPath = join12(pagesDirectory, "admitted-request.json");
|
|
4533
|
-
if (existsSync4(admittedPath)) {
|
|
4534
|
-
const page = JSON.parse(await readFile7(admittedPath, "utf8"));
|
|
4341
|
+
if (isPlainObject(page.principal)) {
|
|
4535
4342
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4536
|
-
page,
|
|
4537
|
-
|
|
4343
|
+
page.principal,
|
|
4344
|
+
["sessionDirectory", "sessionFile"],
|
|
4538
4345
|
rewrites
|
|
4539
4346
|
);
|
|
4540
|
-
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
4541
|
-
if (Array.isArray(page.attachments)) {
|
|
4542
|
-
for (const attachment of page.attachments) {
|
|
4543
|
-
if (isPlainObject(attachment)) {
|
|
4544
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4545
|
-
attachment,
|
|
4546
|
-
["frozenPath"],
|
|
4547
|
-
rewrites
|
|
4548
|
-
);
|
|
4549
|
-
}
|
|
4550
|
-
}
|
|
4551
|
-
}
|
|
4552
|
-
if (isPlainObject(page.principal)) {
|
|
4553
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4554
|
-
page.principal,
|
|
4555
|
-
["sessionDirectory", "sessionFile"],
|
|
4556
|
-
rewrites
|
|
4557
|
-
);
|
|
4558
|
-
}
|
|
4559
|
-
await writeFile2(admittedPath, `${JSON.stringify(page, null, 2)}
|
|
4560
|
-
`, "utf8");
|
|
4561
4347
|
}
|
|
4562
|
-
const invocationPath = join12(pagesDirectory, "invocation.json");
|
|
4563
|
-
if (existsSync4(invocationPath)) {
|
|
4564
|
-
const page = JSON.parse(await readFile7(invocationPath, "utf8"));
|
|
4565
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4566
|
-
page,
|
|
4567
|
-
INVOCATION_PAGE_FIELDS,
|
|
4568
|
-
rewrites
|
|
4569
|
-
);
|
|
4570
|
-
await writeFile2(
|
|
4571
|
-
invocationPath,
|
|
4572
|
-
`${JSON.stringify(page, null, 2)}
|
|
4573
|
-
`,
|
|
4574
|
-
"utf8"
|
|
4575
|
-
);
|
|
4576
|
-
}
|
|
4577
|
-
const statePath = join12(pagesDirectory, "run-state.json");
|
|
4578
|
-
if (existsSync4(statePath)) {
|
|
4579
|
-
const page = JSON.parse(await readFile7(statePath, "utf8"));
|
|
4580
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4581
|
-
page,
|
|
4582
|
-
RUN_STATE_PAGE_FIELDS,
|
|
4583
|
-
rewrites
|
|
4584
|
-
);
|
|
4585
|
-
if (isPlainObject(page.principal)) {
|
|
4586
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4587
|
-
page.principal,
|
|
4588
|
-
["sessionDirectory", "sessionFile"],
|
|
4589
|
-
rewrites
|
|
4590
|
-
);
|
|
4591
|
-
}
|
|
4592
|
-
if (isPlainObject(page.currentCourt)) {
|
|
4593
|
-
rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
|
|
4594
|
-
}
|
|
4595
|
-
await writeFile2(statePath, `${JSON.stringify(page, null, 2)}
|
|
4596
|
-
`, "utf8");
|
|
4597
|
-
}
|
|
4598
|
-
await rewriteNestedMachinePathPages(pagesDirectory, rewrites);
|
|
4599
4348
|
}
|
|
4600
|
-
var ADMITTED_PAGE_FIELDS,
|
|
4349
|
+
var ADMITTED_PAGE_FIELDS, SOURCE_RUN_LOCATOR_FIELDS;
|
|
4601
4350
|
var init_role_run_relocation = __esm({
|
|
4602
4351
|
"src/role-run-relocation.ts"() {
|
|
4603
4352
|
"use strict";
|
|
@@ -4614,24 +4363,7 @@ var init_role_run_relocation = __esm({
|
|
|
4614
4363
|
"mergerInputPath",
|
|
4615
4364
|
"sourceRunPath"
|
|
4616
4365
|
];
|
|
4617
|
-
INVOCATION_PAGE_FIELDS = [
|
|
4618
|
-
"runDirectory",
|
|
4619
|
-
"sessionDirectory",
|
|
4620
|
-
"sessionFile"
|
|
4621
|
-
];
|
|
4622
|
-
RUN_STATE_PAGE_FIELDS = [
|
|
4623
|
-
"runDirectory",
|
|
4624
|
-
"admittedRequestPath",
|
|
4625
|
-
"sessionDirectory",
|
|
4626
|
-
"sessionFile"
|
|
4627
|
-
];
|
|
4628
4366
|
SOURCE_RUN_LOCATOR_FIELDS = ["runDirectory"];
|
|
4629
|
-
SUMMONS_PATH_FIELDS = ["sourceRunPath"];
|
|
4630
|
-
CURRENT_SESSION_FIELDS = ["sessionFile"];
|
|
4631
|
-
OFFICER_POINTER_FIELDS = ["sessionFile", "runDirectory"];
|
|
4632
|
-
SITIAN_RECORD_FIELDS = ["sessionParent"];
|
|
4633
|
-
SESSION_HEADER_FIELDS = ["parentSession"];
|
|
4634
|
-
BINDING_PARENT_FIELDS = ["sessionFile"];
|
|
4635
4367
|
}
|
|
4636
4368
|
});
|
|
4637
4369
|
|
|
@@ -4764,7 +4496,7 @@ var init_terminating_tools = __esm({
|
|
|
4764
4496
|
});
|
|
4765
4497
|
|
|
4766
4498
|
// src/doctor-evidence.ts
|
|
4767
|
-
import { readdir as
|
|
4499
|
+
import { readdir as readdir3, readFile as readFile7, realpath as realpath3, stat } from "node:fs/promises";
|
|
4768
4500
|
import { dirname as dirname8, relative as relative2, resolve as resolve6, sep as sep3 } from "node:path";
|
|
4769
4501
|
function record3(value) {
|
|
4770
4502
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -4772,7 +4504,7 @@ function record3(value) {
|
|
|
4772
4504
|
async function discoverCaseFiles(root) {
|
|
4773
4505
|
const found = [];
|
|
4774
4506
|
async function walk(dir, depth) {
|
|
4775
|
-
for (const item of await
|
|
4507
|
+
for (const item of await readdir3(dir, { withFileTypes: true })) {
|
|
4776
4508
|
const path = resolve6(dir, item.name);
|
|
4777
4509
|
if (item.isDirectory()) {
|
|
4778
4510
|
await walk(path, depth + 1);
|
|
@@ -4880,7 +4612,7 @@ async function loadDoctorCase(runsPath) {
|
|
|
4880
4612
|
const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
|
|
4881
4613
|
for (const path of await discoverCaseFiles(root)) {
|
|
4882
4614
|
const id = relative2(root, path).split(sep3).join("/");
|
|
4883
|
-
const bytes = await
|
|
4615
|
+
const bytes = await readFile7(path);
|
|
4884
4616
|
const content = bytes.toString("utf8");
|
|
4885
4617
|
const kind = id.endsWith(".jsonl") ? "session" : "stderr";
|
|
4886
4618
|
evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
|
|
@@ -4893,7 +4625,7 @@ async function loadDoctorCase(runsPath) {
|
|
|
4893
4625
|
accumulate(calls, result.calls, id);
|
|
4894
4626
|
accumulate(tokens, result.tokens, id);
|
|
4895
4627
|
}
|
|
4896
|
-
const runDirs = (await
|
|
4628
|
+
const runDirs = (await readdir3(root, { withFileTypes: true })).filter((item) => item.isDirectory()).map((item) => item.name).sort();
|
|
4897
4629
|
const legs = evidence.filter((entry) => entry.kind === "session").map((entry) => entry.id);
|
|
4898
4630
|
const retryDirs = runDirs.filter((name) => /(?:^|[-_])retry(?:[-_]|$)/i.test(name));
|
|
4899
4631
|
const rawBytes = evidence.filter((entry) => entry.kind === "session").reduce((sum, entry) => sum + entry.byteLength, 0);
|
|
@@ -5120,7 +4852,7 @@ var init_git_object_id = __esm({
|
|
|
5120
4852
|
|
|
5121
4853
|
// src/merger-git-state.ts
|
|
5122
4854
|
import { execFile as execFile2 } from "node:child_process";
|
|
5123
|
-
import { access as access2, readFile as
|
|
4855
|
+
import { access as access2, readFile as readFile8 } from "node:fs/promises";
|
|
5124
4856
|
import { constants as fsConstants } from "node:fs";
|
|
5125
4857
|
import { isAbsolute as isAbsolute4, resolve as resolve7 } from "node:path";
|
|
5126
4858
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -5190,7 +4922,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
|
|
|
5190
4922
|
const mergeHeadPath = isAbsolute4(mergeHeadReported) ? mergeHeadReported : resolve7(repositoryRoot, mergeHeadReported);
|
|
5191
4923
|
let sourceObjectId = "";
|
|
5192
4924
|
if (await pathExists(mergeHeadPath)) {
|
|
5193
|
-
const raw = exactUtf8(await
|
|
4925
|
+
const raw = exactUtf8(await readFile8(mergeHeadPath), "Git MERGE_HEAD");
|
|
5194
4926
|
const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
|
|
5195
4927
|
if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
|
|
5196
4928
|
if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
|
|
@@ -5242,7 +4974,7 @@ var init_uuidv7 = __esm({
|
|
|
5242
4974
|
});
|
|
5243
4975
|
|
|
5244
4976
|
// src/typed-provider-http.ts
|
|
5245
|
-
import { readFile as
|
|
4977
|
+
import { readFile as readFile9, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
5246
4978
|
import { join as join13 } from "node:path";
|
|
5247
4979
|
function typedProviderHttpPath(runDirectory) {
|
|
5248
4980
|
return join13(runDirectory, TYPED_HTTP_FILE);
|
|
@@ -5266,7 +4998,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
|
|
|
5266
4998
|
httpStatus: observation.httpStatus,
|
|
5267
4999
|
provider: observation.provider
|
|
5268
5000
|
};
|
|
5269
|
-
await
|
|
5001
|
+
await writeFile2(
|
|
5270
5002
|
typedProviderHttpPath(runDirectory),
|
|
5271
5003
|
`${JSON.stringify(body)}
|
|
5272
5004
|
`,
|
|
@@ -5276,7 +5008,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
|
|
|
5276
5008
|
async function readLatestTypedProviderHttpObservation(runDirectory) {
|
|
5277
5009
|
let text;
|
|
5278
5010
|
try {
|
|
5279
|
-
text = await
|
|
5011
|
+
text = await readFile9(typedProviderHttpPath(runDirectory), "utf8");
|
|
5280
5012
|
} catch (error) {
|
|
5281
5013
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
5282
5014
|
return void 0;
|
|
@@ -5355,7 +5087,7 @@ __export(run_lifecycle_exports, {
|
|
|
5355
5087
|
selectResumeContinuationPrompt: () => selectResumeContinuationPrompt,
|
|
5356
5088
|
writeRoleRunState: () => writeRoleRunState
|
|
5357
5089
|
});
|
|
5358
|
-
import { chmod, lstat as lstat2, open, readdir as
|
|
5090
|
+
import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile10, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
5359
5091
|
import { basename as basename5, join as join14 } from "node:path";
|
|
5360
5092
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
5361
5093
|
const lines = message !== void 0 ? [message] : [];
|
|
@@ -5394,7 +5126,7 @@ function renderResumeCommand(runId) {
|
|
|
5394
5126
|
}
|
|
5395
5127
|
async function writeRoleRunState(runDirectory, record4) {
|
|
5396
5128
|
const payload = { ...record4, runDirectory };
|
|
5397
|
-
await
|
|
5129
|
+
await writeFile3(
|
|
5398
5130
|
join14(runDirectory, RUN_STATE_FILE),
|
|
5399
5131
|
`${JSON.stringify(payload, null, 2)}
|
|
5400
5132
|
`,
|
|
@@ -5445,7 +5177,7 @@ function parseCurrentCourtState(raw) {
|
|
|
5445
5177
|
async function readRoleRunStateDisk(runDirectory) {
|
|
5446
5178
|
let raw;
|
|
5447
5179
|
try {
|
|
5448
|
-
raw = JSON.parse(await
|
|
5180
|
+
raw = JSON.parse(await readFile10(join14(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
5449
5181
|
} catch (error) {
|
|
5450
5182
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
5451
5183
|
throw error;
|
|
@@ -5467,10 +5199,15 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
5467
5199
|
if (typeof record4.projectRoot !== "string") return void 0;
|
|
5468
5200
|
if (typeof record4.sessionDirectory !== "string") return void 0;
|
|
5469
5201
|
if (typeof record4.admittedRequestPath !== "string") return void 0;
|
|
5470
|
-
const
|
|
5202
|
+
const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
5203
|
+
const runDir = runDirectory;
|
|
5471
5204
|
const principalWire = {
|
|
5472
|
-
sessionDirectory:
|
|
5473
|
-
|
|
5205
|
+
sessionDirectory: rewriteRunDirectoryPathValue(
|
|
5206
|
+
record4.sessionDirectory,
|
|
5207
|
+
storedRunDirectory,
|
|
5208
|
+
runDirectory
|
|
5209
|
+
),
|
|
5210
|
+
...typeof record4.sessionFile === "string" ? { sessionFile: rewriteRunDirectoryPathValue(record4.sessionFile, storedRunDirectory, runDirectory) } : {}
|
|
5474
5211
|
};
|
|
5475
5212
|
let resumable;
|
|
5476
5213
|
if (record4.resumable !== void 0 && record4.resumable !== null) {
|
|
@@ -5490,7 +5227,11 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
5490
5227
|
bookKey: record4.bookKey,
|
|
5491
5228
|
projectRoot: record4.projectRoot,
|
|
5492
5229
|
runDirectory: runDir,
|
|
5493
|
-
admittedRequestPath:
|
|
5230
|
+
admittedRequestPath: rewriteRunDirectoryPathValue(
|
|
5231
|
+
record4.admittedRequestPath,
|
|
5232
|
+
storedRunDirectory,
|
|
5233
|
+
runDirectory
|
|
5234
|
+
),
|
|
5494
5235
|
principalWire,
|
|
5495
5236
|
...phase === void 0 ? {} : { phase },
|
|
5496
5237
|
...resumable === void 0 ? {} : { resumable },
|
|
@@ -5512,7 +5253,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
5512
5253
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
5513
5254
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
5514
5255
|
};
|
|
5515
|
-
await
|
|
5256
|
+
await writeFile3(
|
|
5516
5257
|
join14(runDirectory, RUN_STATE_FILE),
|
|
5517
5258
|
`${JSON.stringify(payload, null, 2)}
|
|
5518
5259
|
`,
|
|
@@ -5685,7 +5426,7 @@ function isProcessAlive(pid) {
|
|
|
5685
5426
|
async function autopsyWriterLock(lockPath) {
|
|
5686
5427
|
let content;
|
|
5687
5428
|
try {
|
|
5688
|
-
content = await
|
|
5429
|
+
content = await readFile10(lockPath, "utf8");
|
|
5689
5430
|
} catch (error) {
|
|
5690
5431
|
if (errorCodeOf2(error) === "ENOENT") return { verdict: "absent" };
|
|
5691
5432
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -5844,7 +5585,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
5844
5585
|
const booksRoot = join14(ledgerHome, "books");
|
|
5845
5586
|
let bookKeys;
|
|
5846
5587
|
try {
|
|
5847
|
-
bookKeys = await
|
|
5588
|
+
bookKeys = await readdir4(booksRoot);
|
|
5848
5589
|
} catch (error) {
|
|
5849
5590
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
5850
5591
|
throw error;
|
|
@@ -5882,7 +5623,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
5882
5623
|
let raw;
|
|
5883
5624
|
try {
|
|
5884
5625
|
raw = JSON.parse(
|
|
5885
|
-
await
|
|
5626
|
+
await readFile10(join14(runDirectory, "admitted-request.json"), "utf8")
|
|
5886
5627
|
);
|
|
5887
5628
|
} catch (error) {
|
|
5888
5629
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
@@ -6051,10 +5792,15 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
6051
5792
|
let sourceRun;
|
|
6052
5793
|
try {
|
|
6053
5794
|
const raw = JSON.parse(
|
|
6054
|
-
await
|
|
5795
|
+
await readFile10(run.admittedRequestPath, "utf8")
|
|
6055
5796
|
);
|
|
6056
5797
|
if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
6057
5798
|
const record4 = raw;
|
|
5799
|
+
const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : run.runDirectory;
|
|
5800
|
+
rewriteAdmittedRoleRunPage(record4, [{
|
|
5801
|
+
oldRunDirectory: storedRunDirectory,
|
|
5802
|
+
newRunDirectory: run.runDirectory
|
|
5803
|
+
}]);
|
|
6058
5804
|
if (typeof record4.instruction === "string") {
|
|
6059
5805
|
instruction = record4.instruction;
|
|
6060
5806
|
}
|
|
@@ -6169,7 +5915,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
6169
5915
|
let model;
|
|
6170
5916
|
try {
|
|
6171
5917
|
const invocationRaw = JSON.parse(
|
|
6172
|
-
await
|
|
5918
|
+
await readFile10(join14(run.runDirectory, "invocation.json"), "utf8")
|
|
6173
5919
|
);
|
|
6174
5920
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
6175
5921
|
const rec = invocationRaw;
|
|
@@ -6208,6 +5954,23 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
6208
5954
|
} else if (mergedSet.tickets !== void 0) {
|
|
6209
5955
|
courtTicketNumbers = mergedSet.tickets;
|
|
6210
5956
|
}
|
|
5957
|
+
const sourceRunLeaf = basename5(sourceRunPath ?? "").split("@");
|
|
5958
|
+
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
|
|
5959
|
+
const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
|
|
5960
|
+
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
5961
|
+
const currentSourceRunDirectory = await findRunDirectoryById(
|
|
5962
|
+
home,
|
|
5963
|
+
referencedRunId,
|
|
5964
|
+
run.bookKey,
|
|
5965
|
+
referencedRole
|
|
5966
|
+
);
|
|
5967
|
+
if (currentSourceRunDirectory !== void 0) {
|
|
5968
|
+
sourceRunPath = currentSourceRunDirectory;
|
|
5969
|
+
if (sourceRun !== void 0) {
|
|
5970
|
+
sourceRun = { ...sourceRun, runDirectory: currentSourceRunDirectory };
|
|
5971
|
+
}
|
|
5972
|
+
}
|
|
5973
|
+
}
|
|
6211
5974
|
return {
|
|
6212
5975
|
run,
|
|
6213
5976
|
principal,
|
|
@@ -6612,6 +6375,7 @@ var init_run_lifecycle = __esm({
|
|
|
6612
6375
|
init_typed_provider_http();
|
|
6613
6376
|
init_collector_config();
|
|
6614
6377
|
init_diarist_contracts();
|
|
6378
|
+
init_role_run_relocation();
|
|
6615
6379
|
init_engine_material();
|
|
6616
6380
|
init_invocation();
|
|
6617
6381
|
V1_RESUMABLE_PROVIDERS = ["openai-codex", "xai"];
|
|
@@ -6684,17 +6448,29 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
6684
6448
|
}
|
|
6685
6449
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
6686
6450
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
6687
|
-
const
|
|
6451
|
+
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
6452
|
+
const bookRunsRoot = join15(bookDirectory, "runs");
|
|
6688
6453
|
let candidate;
|
|
6689
6454
|
const bare = parseRunDirectoryName(raw);
|
|
6690
6455
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
6691
6456
|
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join15(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
6692
6457
|
} else {
|
|
6693
6458
|
candidate = isAbsolute6(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
6459
|
+
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
6460
|
+
const subjectDirectory = dirname9(dirname9(candidate));
|
|
6461
|
+
const isLegacyUnboundLocator = identity2 !== void 0 && basename6(dirname9(candidate)) === "runs" && basename6(subjectDirectory) === "unbound" && resolve8(dirname9(subjectDirectory)) === resolve8(bookDirectory);
|
|
6462
|
+
if (isLegacyUnboundLocator) {
|
|
6463
|
+
candidate = await findRunDirectoryById(
|
|
6464
|
+
options.home,
|
|
6465
|
+
identity2.runId,
|
|
6466
|
+
bookKey,
|
|
6467
|
+
identity2.role
|
|
6468
|
+
) ?? candidate;
|
|
6469
|
+
}
|
|
6694
6470
|
}
|
|
6695
6471
|
const real = await requireRunDirectory(candidate, raw);
|
|
6696
6472
|
const identity = parseRunDirectoryName(basename6(real));
|
|
6697
|
-
const bookIdentity = physicalPathIdentity(
|
|
6473
|
+
const bookIdentity = physicalPathIdentity(bookDirectory);
|
|
6698
6474
|
const parentIdentity = physicalPathIdentity(dirname9(real));
|
|
6699
6475
|
const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
|
|
6700
6476
|
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
@@ -7876,15 +7652,15 @@ __export(invocation_exports, {
|
|
|
7876
7652
|
withPreparedAttachments: () => withPreparedAttachments
|
|
7877
7653
|
});
|
|
7878
7654
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
7879
|
-
import { existsSync as
|
|
7655
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
7880
7656
|
import {
|
|
7881
7657
|
lstat as lstat4,
|
|
7882
7658
|
mkdtemp as mkdtemp2,
|
|
7883
|
-
readFile as
|
|
7659
|
+
readFile as readFile11,
|
|
7884
7660
|
realpath as realpath5,
|
|
7885
7661
|
rename,
|
|
7886
7662
|
rm as rm2,
|
|
7887
|
-
writeFile as
|
|
7663
|
+
writeFile as writeFile4
|
|
7888
7664
|
} from "node:fs/promises";
|
|
7889
7665
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
7890
7666
|
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute7, join as join16, resolve as resolve9, sep as sep4 } from "node:path";
|
|
@@ -7912,7 +7688,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
|
|
|
7912
7688
|
sessionDirectory: coordinates.sessionDirectory,
|
|
7913
7689
|
sessionFile: coordinates.sessionFile
|
|
7914
7690
|
};
|
|
7915
|
-
await
|
|
7691
|
+
await writeFile4(
|
|
7916
7692
|
admittedRequestPath,
|
|
7917
7693
|
`${JSON.stringify(projection, null, 2)}
|
|
7918
7694
|
`,
|
|
@@ -7940,7 +7716,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
7940
7716
|
...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
|
|
7941
7717
|
...effectiveModelLedgerFields(effectiveModel)
|
|
7942
7718
|
};
|
|
7943
|
-
await
|
|
7719
|
+
await writeFile4(
|
|
7944
7720
|
join16(source.runDirectory, "invocation.json"),
|
|
7945
7721
|
`${JSON.stringify(identity, null, 2)}
|
|
7946
7722
|
`,
|
|
@@ -7949,7 +7725,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
7949
7725
|
}
|
|
7950
7726
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
7951
7727
|
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
7952
|
-
const current = JSON.parse(await
|
|
7728
|
+
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
7953
7729
|
const next = { ...current };
|
|
7954
7730
|
if (model !== void 0) {
|
|
7955
7731
|
next.provider = model.provider;
|
|
@@ -7973,7 +7749,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
7973
7749
|
if (host !== void 0) {
|
|
7974
7750
|
next.host = host;
|
|
7975
7751
|
}
|
|
7976
|
-
await
|
|
7752
|
+
await writeFile4(
|
|
7977
7753
|
ledgerPath,
|
|
7978
7754
|
`${JSON.stringify(next, null, 2)}
|
|
7979
7755
|
`,
|
|
@@ -7982,8 +7758,8 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
7982
7758
|
}
|
|
7983
7759
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
7984
7760
|
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
7985
|
-
const current = JSON.parse(await
|
|
7986
|
-
await
|
|
7761
|
+
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
7762
|
+
await writeFile4(
|
|
7987
7763
|
ledgerPath,
|
|
7988
7764
|
`${JSON.stringify({
|
|
7989
7765
|
...current,
|
|
@@ -7998,14 +7774,14 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
|
|
|
7998
7774
|
throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
|
|
7999
7775
|
}
|
|
8000
7776
|
const admittedPath = admitted.admittedRequestPath;
|
|
8001
|
-
const current = JSON.parse(await
|
|
7777
|
+
const current = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
8002
7778
|
if (typeof current.sourceRunPath === "string") {
|
|
8003
7779
|
if (current.sourceRunPath === sourceRunPath) return;
|
|
8004
7780
|
throw new Error(
|
|
8005
7781
|
`persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
8006
7782
|
);
|
|
8007
7783
|
}
|
|
8008
|
-
await
|
|
7784
|
+
await writeFile4(
|
|
8009
7785
|
admittedPath,
|
|
8010
7786
|
`${JSON.stringify({ ...current, sourceRunPath }, null, 2)}
|
|
8011
7787
|
`,
|
|
@@ -8024,7 +7800,7 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
8024
7800
|
}
|
|
8025
7801
|
async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
8026
7802
|
const current = JSON.parse(
|
|
8027
|
-
await
|
|
7803
|
+
await readFile11(admitted.admittedRequestPath, "utf8")
|
|
8028
7804
|
);
|
|
8029
7805
|
const prior = [
|
|
8030
7806
|
...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
|
|
@@ -8033,7 +7809,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
8033
7809
|
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
8034
7810
|
];
|
|
8035
7811
|
const correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
8036
|
-
await
|
|
7812
|
+
await writeFile4(
|
|
8037
7813
|
admitted.admittedRequestPath,
|
|
8038
7814
|
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
8039
7815
|
`,
|
|
@@ -8072,8 +7848,8 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
|
8072
7848
|
}
|
|
8073
7849
|
const frozen = Object.freeze([...projected]);
|
|
8074
7850
|
const admittedPath = admitted.admittedRequestPath;
|
|
8075
|
-
const current = JSON.parse(await
|
|
8076
|
-
await
|
|
7851
|
+
const current = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
7852
|
+
await writeFile4(
|
|
8077
7853
|
admittedPath,
|
|
8078
7854
|
`${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
|
|
8079
7855
|
`,
|
|
@@ -8085,7 +7861,7 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
|
8085
7861
|
admitted.courtTicketNumbers = frozen;
|
|
8086
7862
|
}
|
|
8087
7863
|
async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
8088
|
-
if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) return;
|
|
7864
|
+
if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) return void 0;
|
|
8089
7865
|
const oldRunDirectory = admitted.runDirectory;
|
|
8090
7866
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
|
|
8091
7867
|
const target = roleRunPlacement(ledgerHome, {
|
|
@@ -8095,6 +7871,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8095
7871
|
role: admitted.role
|
|
8096
7872
|
});
|
|
8097
7873
|
ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
|
|
7874
|
+
const principal = authority.seal(target);
|
|
8098
7875
|
await rename(oldRunDirectory, target.runDirectory);
|
|
8099
7876
|
heldLease?.relocate(target.runDirectory);
|
|
8100
7877
|
const admittedRecord = admitted;
|
|
@@ -8119,13 +7896,8 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8119
7896
|
target.runDirectory
|
|
8120
7897
|
);
|
|
8121
7898
|
}
|
|
8122
|
-
const principal = authority.seal(target);
|
|
8123
7899
|
admitted.principal = principal;
|
|
8124
|
-
|
|
8125
|
-
pagesDirectory: target.runDirectory,
|
|
8126
|
-
oldRunDirectory,
|
|
8127
|
-
newRunDirectory: target.runDirectory
|
|
8128
|
-
});
|
|
7900
|
+
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
8129
7901
|
}
|
|
8130
7902
|
async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
8131
7903
|
requireSafePositiveTicketNumber(
|
|
@@ -8134,7 +7906,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
8134
7906
|
);
|
|
8135
7907
|
const admittedPath = join16(runDirectory, "admitted-request.json");
|
|
8136
7908
|
const invocationPath = join16(runDirectory, "invocation.json");
|
|
8137
|
-
const admitted = JSON.parse(await
|
|
7909
|
+
const admitted = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
8138
7910
|
const existing = admitted.ticketNumber;
|
|
8139
7911
|
if (typeof existing === "number") {
|
|
8140
7912
|
if (existing === ticketNumber) return;
|
|
@@ -8142,9 +7914,9 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
8142
7914
|
`bindTicketNumberOnRunDirectory refuses to replace existing ticket #${existing} with #${ticketNumber}`
|
|
8143
7915
|
);
|
|
8144
7916
|
}
|
|
8145
|
-
if (
|
|
7917
|
+
if (existsSync4(invocationPath)) {
|
|
8146
7918
|
const invocation = JSON.parse(
|
|
8147
|
-
await
|
|
7919
|
+
await readFile11(invocationPath, "utf8")
|
|
8148
7920
|
);
|
|
8149
7921
|
if (typeof invocation.ticketNumber === "number" && invocation.ticketNumber !== ticketNumber) {
|
|
8150
7922
|
throw new Error(
|
|
@@ -8152,7 +7924,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
8152
7924
|
);
|
|
8153
7925
|
}
|
|
8154
7926
|
}
|
|
8155
|
-
await
|
|
7927
|
+
await writeFile4(
|
|
8156
7928
|
admittedPath,
|
|
8157
7929
|
`${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
|
|
8158
7930
|
`,
|
|
@@ -8169,7 +7941,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
8169
7941
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
8170
7942
|
const rolePackageRoot = packageRoot;
|
|
8171
7943
|
const raw = JSON.parse(
|
|
8172
|
-
await
|
|
7944
|
+
await readFile11(join16(rolePackageRoot, "package.json"), "utf8")
|
|
8173
7945
|
);
|
|
8174
7946
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
8175
7947
|
throw new Error(
|
|
@@ -8454,7 +8226,7 @@ async function readRegularFileAttachment(sourcePath) {
|
|
|
8454
8226
|
);
|
|
8455
8227
|
}
|
|
8456
8228
|
try {
|
|
8457
|
-
return { absolute, bytes: await
|
|
8229
|
+
return { absolute, bytes: await readFile11(absolute) };
|
|
8458
8230
|
} catch (error) {
|
|
8459
8231
|
throw new CliUsageError(
|
|
8460
8232
|
`attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -8474,7 +8246,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
8474
8246
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
8475
8247
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
8476
8248
|
const snapshotPath = join16(stagingDirectory, String(index).padStart(6, "0"));
|
|
8477
|
-
await
|
|
8249
|
+
await writeFile4(snapshotPath, bytes);
|
|
8478
8250
|
prepared.push({ absolute, snapshotPath });
|
|
8479
8251
|
}
|
|
8480
8252
|
result = await use(prepared);
|
|
@@ -8498,7 +8270,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
|
|
|
8498
8270
|
destinationDir,
|
|
8499
8271
|
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
8500
8272
|
);
|
|
8501
|
-
await
|
|
8273
|
+
await writeFile4(frozenPath, bytes);
|
|
8502
8274
|
return {
|
|
8503
8275
|
provenancePath,
|
|
8504
8276
|
frozenPath,
|
|
@@ -8510,7 +8282,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
|
|
|
8510
8282
|
async function freezePreparedAttachment(prepared, destinationDir, index) {
|
|
8511
8283
|
return freezeAttachmentBytes(
|
|
8512
8284
|
prepared.absolute,
|
|
8513
|
-
await
|
|
8285
|
+
await readFile11(prepared.snapshotPath),
|
|
8514
8286
|
destinationDir,
|
|
8515
8287
|
index
|
|
8516
8288
|
);
|
|
@@ -8766,7 +8538,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
|
|
|
8766
8538
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
8767
8539
|
try {
|
|
8768
8540
|
const raw = JSON.parse(
|
|
8769
|
-
await
|
|
8541
|
+
await readFile11(join16(runDirectory, "admitted-request.json"), "utf8")
|
|
8770
8542
|
);
|
|
8771
8543
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
8772
8544
|
const record4 = raw;
|
|
@@ -8822,7 +8594,7 @@ async function admitCoderInvocation(options) {
|
|
|
8822
8594
|
});
|
|
8823
8595
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
8824
8596
|
const taskPath = join16(runDirectory, "task.md");
|
|
8825
|
-
await
|
|
8597
|
+
await writeFile4(taskPath, instruction, "utf8");
|
|
8826
8598
|
const admitted = {
|
|
8827
8599
|
role: "coder",
|
|
8828
8600
|
phase: options.phase,
|
|
@@ -8892,7 +8664,7 @@ async function admitFixerInvocation(options) {
|
|
|
8892
8664
|
if (options.prerequisitesPath !== void 0) {
|
|
8893
8665
|
const absolutePrereq = isAbsolute7(options.prerequisitesPath) ? options.prerequisitesPath : resolve9(options.prerequisitesPath);
|
|
8894
8666
|
try {
|
|
8895
|
-
prerequisitesSource = await
|
|
8667
|
+
prerequisitesSource = await readFile11(absolutePrereq, "utf8");
|
|
8896
8668
|
} catch (error) {
|
|
8897
8669
|
throw new CliUsageError(
|
|
8898
8670
|
`fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
|
|
@@ -8929,7 +8701,7 @@ async function admitFixerInvocation(options) {
|
|
|
8929
8701
|
let prerequisitesPath;
|
|
8930
8702
|
if (prerequisitesSource !== void 0) {
|
|
8931
8703
|
prerequisitesPath = join16(runDirectory, "prerequisites.json");
|
|
8932
|
-
await
|
|
8704
|
+
await writeFile4(
|
|
8933
8705
|
prerequisitesPath,
|
|
8934
8706
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
8935
8707
|
`,
|
|
@@ -8937,7 +8709,7 @@ async function admitFixerInvocation(options) {
|
|
|
8937
8709
|
);
|
|
8938
8710
|
}
|
|
8939
8711
|
const packetPath = join16(runDirectory, "fix-packet.md");
|
|
8940
|
-
await
|
|
8712
|
+
await writeFile4(packetPath, instruction, "utf8");
|
|
8941
8713
|
const admitted = {
|
|
8942
8714
|
role: "fixer",
|
|
8943
8715
|
phase: options.phase,
|
|
@@ -9183,7 +8955,7 @@ async function admitCollectorInvocation(options) {
|
|
|
9183
8955
|
let requestManifestPath;
|
|
9184
8956
|
if (manifestCanonicalJson !== void 0) {
|
|
9185
8957
|
requestManifestPath = join16(runDirectory, "request-manifest.json");
|
|
9186
|
-
await
|
|
8958
|
+
await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
9187
8959
|
}
|
|
9188
8960
|
const admitted = {
|
|
9189
8961
|
role: "collector",
|
|
@@ -9964,7 +9736,7 @@ async function admitMergerInvocation(options) {
|
|
|
9964
9736
|
authorizedChecks: []
|
|
9965
9737
|
});
|
|
9966
9738
|
const mergerInputPath = join16(runDirectory, "merger-input.json");
|
|
9967
|
-
await
|
|
9739
|
+
await writeFile4(
|
|
9968
9740
|
mergerInputPath,
|
|
9969
9741
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
9970
9742
|
`,
|
|
@@ -10277,7 +10049,7 @@ var init_invocation = __esm({
|
|
|
10277
10049
|
});
|
|
10278
10050
|
|
|
10279
10051
|
// src/public-cli/load-production-acp-host.ts
|
|
10280
|
-
import { existsSync as
|
|
10052
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
10281
10053
|
import { join as join17 } from "node:path";
|
|
10282
10054
|
import { pathToFileURL } from "node:url";
|
|
10283
10055
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
@@ -10287,7 +10059,7 @@ async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
|
10287
10059
|
}
|
|
10288
10060
|
const built = join17(packageRoot, "dist/acp-host/production-host.js");
|
|
10289
10061
|
const source = join17(packageRoot, "src/acp-host/production-host.ts");
|
|
10290
|
-
const target =
|
|
10062
|
+
const target = existsSync5(built) ? built : source;
|
|
10291
10063
|
const href = pathToFileURL(target).href;
|
|
10292
10064
|
const mod = await import(href);
|
|
10293
10065
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -10301,7 +10073,7 @@ var init_load_production_acp_host = __esm({
|
|
|
10301
10073
|
});
|
|
10302
10074
|
|
|
10303
10075
|
// src/public-cli/load-production-headless-host.ts
|
|
10304
|
-
import { existsSync as
|
|
10076
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
10305
10077
|
import { join as join18 } from "node:path";
|
|
10306
10078
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
10307
10079
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
@@ -10311,7 +10083,7 @@ async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
|
10311
10083
|
}
|
|
10312
10084
|
const built = join18(packageRoot, "dist/headless-host/production-host.js");
|
|
10313
10085
|
const source = join18(packageRoot, "src/headless-host/production-host.ts");
|
|
10314
|
-
const target =
|
|
10086
|
+
const target = existsSync6(built) ? built : source;
|
|
10315
10087
|
const href = pathToFileURL2(target).href;
|
|
10316
10088
|
const mod = await import(href);
|
|
10317
10089
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -10559,7 +10331,7 @@ __export(config_exports, {
|
|
|
10559
10331
|
setPersistentSeatHost: () => setPersistentSeatHost,
|
|
10560
10332
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
10561
10333
|
});
|
|
10562
|
-
import { mkdir, readFile as
|
|
10334
|
+
import { mkdir, readFile as readFile12, writeFile as writeFile5 } from "node:fs/promises";
|
|
10563
10335
|
import { dirname as dirname11, join as join19 } from "node:path";
|
|
10564
10336
|
function isGateOfficerSeat(value) {
|
|
10565
10337
|
return GATE_OFFICER_SEATS.includes(value);
|
|
@@ -10573,7 +10345,7 @@ function publicCliConfigPath(home) {
|
|
|
10573
10345
|
async function loadPublicCliConfig(home) {
|
|
10574
10346
|
const path = publicCliConfigPath(home);
|
|
10575
10347
|
try {
|
|
10576
|
-
const raw = await
|
|
10348
|
+
const raw = await readFile12(path, "utf8");
|
|
10577
10349
|
return parsePublicCliConfig(JSON.parse(raw));
|
|
10578
10350
|
} catch (error) {
|
|
10579
10351
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -10586,7 +10358,7 @@ async function savePublicCliConfig(config, home) {
|
|
|
10586
10358
|
const path = publicCliConfigPath(home);
|
|
10587
10359
|
await mkdir(dirname11(path), { recursive: true });
|
|
10588
10360
|
const normalized = parsePublicCliConfig(config);
|
|
10589
|
-
await
|
|
10361
|
+
await writeFile5(
|
|
10590
10362
|
path,
|
|
10591
10363
|
`${JSON.stringify(serializePublicCliConfig(normalized), null, 2)}
|
|
10592
10364
|
`,
|
|
@@ -11031,7 +10803,7 @@ function credentialProvidersFromAuthData(data) {
|
|
|
11031
10803
|
}
|
|
11032
10804
|
async function loadCredentialProviders(agentDir) {
|
|
11033
10805
|
try {
|
|
11034
|
-
const raw = await
|
|
10806
|
+
const raw = await readFile12(join19(agentDir, "auth.json"), "utf8");
|
|
11035
10807
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
11036
10808
|
} catch (error) {
|
|
11037
10809
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -11233,12 +11005,12 @@ var init_host_providers = __esm({
|
|
|
11233
11005
|
});
|
|
11234
11006
|
|
|
11235
11007
|
// src/ledger-session-read.ts
|
|
11236
|
-
import { readFile as
|
|
11008
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
11237
11009
|
function isRecord6(value) {
|
|
11238
11010
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11239
11011
|
}
|
|
11240
11012
|
async function readLedgerSessionJsonlLines(path) {
|
|
11241
|
-
const text = await
|
|
11013
|
+
const text = await readFile13(path, "utf8");
|
|
11242
11014
|
const lines = text.split("\n");
|
|
11243
11015
|
const out = [];
|
|
11244
11016
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -11336,7 +11108,7 @@ var init_ledger_session_read = __esm({
|
|
|
11336
11108
|
});
|
|
11337
11109
|
|
|
11338
11110
|
// src/analyst-gate-cycles-read.ts
|
|
11339
|
-
import { readdir as
|
|
11111
|
+
import { readdir as readdir5 } from "node:fs/promises";
|
|
11340
11112
|
import { join as join21 } from "node:path";
|
|
11341
11113
|
function isRecord7(value) {
|
|
11342
11114
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -11552,10 +11324,10 @@ function pairGateRounds(volumes) {
|
|
|
11552
11324
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
11553
11325
|
}
|
|
11554
11326
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
11555
|
-
const { readFile:
|
|
11327
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
11556
11328
|
let raw;
|
|
11557
11329
|
try {
|
|
11558
|
-
raw = JSON.parse(await
|
|
11330
|
+
raw = JSON.parse(await readFile24(pointerPath, "utf8"));
|
|
11559
11331
|
} catch (error) {
|
|
11560
11332
|
throw new Error(
|
|
11561
11333
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -11578,7 +11350,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
11578
11350
|
for (const directory of directories) {
|
|
11579
11351
|
let names;
|
|
11580
11352
|
try {
|
|
11581
|
-
const entries = await
|
|
11353
|
+
const entries = await readdir5(directory, { withFileTypes: true });
|
|
11582
11354
|
names = entries.filter(
|
|
11583
11355
|
(e) => e.isFile() && (e.name.endsWith(".jsonl") || e.name.endsWith(".pointer.json"))
|
|
11584
11356
|
).map((e) => e.name).sort();
|
|
@@ -12156,14 +11928,14 @@ var init_submission_ledger = __esm({
|
|
|
12156
11928
|
});
|
|
12157
11929
|
|
|
12158
11930
|
// src/session-opening-materials.ts
|
|
12159
|
-
import { existsSync as
|
|
12160
|
-
import { readFile as
|
|
11931
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
11932
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
12161
11933
|
import { dirname as dirname12, join as join23 } from "node:path";
|
|
12162
11934
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
12163
11935
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
12164
11936
|
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
12165
11937
|
for (let i = 0; i < 8; i += 1) {
|
|
12166
|
-
if (
|
|
11938
|
+
if (existsSync7(join23(dir, "package.json")) && existsSync7(join23(dir, "souls"))) {
|
|
12167
11939
|
return dir;
|
|
12168
11940
|
}
|
|
12169
11941
|
const parent = dirname12(dir);
|
|
@@ -12173,7 +11945,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
|
12173
11945
|
return fileURLToPath(new URL("..", moduleUrl));
|
|
12174
11946
|
}
|
|
12175
11947
|
async function readPackageMaterial(relativePath) {
|
|
12176
|
-
return
|
|
11948
|
+
return readFile14(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
12177
11949
|
}
|
|
12178
11950
|
async function joinPackageMaterials(relativePaths) {
|
|
12179
11951
|
const chunks = [];
|
|
@@ -13719,7 +13491,7 @@ var init_engine_detour_usage = __esm({
|
|
|
13719
13491
|
});
|
|
13720
13492
|
|
|
13721
13493
|
// src/dossier-resolution.ts
|
|
13722
|
-
import { existsSync as
|
|
13494
|
+
import { existsSync as existsSync8, statSync as statSync2 } from "node:fs";
|
|
13723
13495
|
import { resolve as resolve10 } from "node:path";
|
|
13724
13496
|
function isHostContext(value) {
|
|
13725
13497
|
return "sessionManager" in value;
|
|
@@ -13739,7 +13511,7 @@ function resolveAuditDossier(source) {
|
|
|
13739
13511
|
}
|
|
13740
13512
|
const runDirectory = resolve10(raw);
|
|
13741
13513
|
try {
|
|
13742
|
-
if (!
|
|
13514
|
+
if (!existsSync8(runDirectory) || !statSync2(runDirectory).isDirectory()) {
|
|
13743
13515
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
13744
13516
|
}
|
|
13745
13517
|
} catch {
|
|
@@ -13787,7 +13559,7 @@ var init_dossier_resolution = __esm({
|
|
|
13787
13559
|
|
|
13788
13560
|
// src/package-resources/method-skill.ts
|
|
13789
13561
|
import { createHash as createHash6 } from "node:crypto";
|
|
13790
|
-
import { readFile as
|
|
13562
|
+
import { readFile as readFile15, realpath as realpath6 } from "node:fs/promises";
|
|
13791
13563
|
import { join as join25 } from "node:path";
|
|
13792
13564
|
function gitBlobOid(bytes) {
|
|
13793
13565
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
@@ -13906,7 +13678,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
|
13906
13678
|
const provenancePath = join25(rootDirectory, "provenance.json");
|
|
13907
13679
|
let provenanceRaw;
|
|
13908
13680
|
try {
|
|
13909
|
-
provenanceRaw = await
|
|
13681
|
+
provenanceRaw = await readFile15(provenancePath, "utf8");
|
|
13910
13682
|
} catch (error) {
|
|
13911
13683
|
throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
|
|
13912
13684
|
}
|
|
@@ -13923,7 +13695,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
|
13923
13695
|
const absolute = join25(rootDirectory, rel);
|
|
13924
13696
|
let bytes;
|
|
13925
13697
|
try {
|
|
13926
|
-
bytes = await
|
|
13698
|
+
bytes = await readFile15(absolute);
|
|
13927
13699
|
} catch (error) {
|
|
13928
13700
|
throw new PackagedMethodSkillUnavailableError(name, absolute, error);
|
|
13929
13701
|
}
|
|
@@ -13939,7 +13711,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
|
13939
13711
|
let raw;
|
|
13940
13712
|
try {
|
|
13941
13713
|
skillPath = await realpath6(skillPathConfigured);
|
|
13942
|
-
raw = await
|
|
13714
|
+
raw = await readFile15(skillPath, "utf8");
|
|
13943
13715
|
} catch (error) {
|
|
13944
13716
|
throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
|
|
13945
13717
|
}
|
|
@@ -14400,7 +14172,7 @@ __export(settlement_exports, {
|
|
|
14400
14172
|
withSubmissions: () => withSubmissions
|
|
14401
14173
|
});
|
|
14402
14174
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
14403
|
-
import { appendFile as appendFile2, readFile as
|
|
14175
|
+
import { appendFile as appendFile2, readFile as readFile16, readdir as readdir6, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
|
|
14404
14176
|
import { dirname as dirname14, join as join26 } from "node:path";
|
|
14405
14177
|
function sealedLedgerHome(admitted) {
|
|
14406
14178
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
@@ -14551,7 +14323,7 @@ function presentControlledFailure(failure2, io) {
|
|
|
14551
14323
|
}
|
|
14552
14324
|
async function inspectJudgeSession(sessionFile) {
|
|
14553
14325
|
try {
|
|
14554
|
-
await
|
|
14326
|
+
await readFile16(sessionFile, "utf8");
|
|
14555
14327
|
return { state: "present" };
|
|
14556
14328
|
} catch (error) {
|
|
14557
14329
|
if (isMissingPathError4(error)) return { state: "missing" };
|
|
@@ -14786,7 +14558,7 @@ function sessionReadFailure(error, fallbackMessage) {
|
|
|
14786
14558
|
return failed;
|
|
14787
14559
|
}
|
|
14788
14560
|
async function readBoundSessionEntries(sessionFile) {
|
|
14789
|
-
const text = await
|
|
14561
|
+
const text = await readFile16(sessionFile, "utf8");
|
|
14790
14562
|
const entries = [];
|
|
14791
14563
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
14792
14564
|
try {
|
|
@@ -14888,7 +14660,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
14888
14660
|
for (const childDirectory of childDirectories) {
|
|
14889
14661
|
let names;
|
|
14890
14662
|
try {
|
|
14891
|
-
names = await
|
|
14663
|
+
names = await readdir6(childDirectory);
|
|
14892
14664
|
sawAnyDirectory = true;
|
|
14893
14665
|
} catch (error) {
|
|
14894
14666
|
if (isMissingPathError4(error)) continue;
|
|
@@ -15563,13 +15335,13 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
15563
15335
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
15564
15336
|
const reportPath = join26(artifactsDir, "report.json");
|
|
15565
15337
|
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
15566
|
-
await
|
|
15338
|
+
await writeFile6(
|
|
15567
15339
|
reportPath,
|
|
15568
15340
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
15569
15341
|
`,
|
|
15570
15342
|
"utf8"
|
|
15571
15343
|
);
|
|
15572
|
-
await
|
|
15344
|
+
await writeFile6(
|
|
15573
15345
|
evidencePath,
|
|
15574
15346
|
`${JSON.stringify(bodies.evidence, null, 2)}
|
|
15575
15347
|
`,
|
|
@@ -16483,7 +16255,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
16483
16255
|
const path = candidates[i];
|
|
16484
16256
|
const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
|
|
16485
16257
|
try {
|
|
16486
|
-
await
|
|
16258
|
+
await writeFile6(
|
|
16487
16259
|
path,
|
|
16488
16260
|
`${JSON.stringify(payload, null, 2)}
|
|
16489
16261
|
`,
|
|
@@ -16848,7 +16620,7 @@ var init_seat_ticket_binding = __esm({
|
|
|
16848
16620
|
});
|
|
16849
16621
|
|
|
16850
16622
|
// src/session-identity.ts
|
|
16851
|
-
import { mkdir as mkdir2, readFile as
|
|
16623
|
+
import { mkdir as mkdir2, readFile as readFile17, rename as rename2, writeFile as writeFile7 } from "node:fs/promises";
|
|
16852
16624
|
import { dirname as dirname15, join as join27 } from "node:path";
|
|
16853
16625
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
16854
16626
|
const bindingPath = (principal) => join27(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
@@ -16858,7 +16630,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
16858
16630
|
},
|
|
16859
16631
|
async load(principal) {
|
|
16860
16632
|
try {
|
|
16861
|
-
const value = JSON.parse(await
|
|
16633
|
+
const value = JSON.parse(await readFile17(bindingPath(principal), "utf8"));
|
|
16862
16634
|
if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
|
|
16863
16635
|
throw new Error("durable session binding is invalid");
|
|
16864
16636
|
}
|
|
@@ -16872,7 +16644,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
16872
16644
|
const target = bindingPath(principal);
|
|
16873
16645
|
await mkdir2(dirname15(target), { recursive: true });
|
|
16874
16646
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
16875
|
-
await
|
|
16647
|
+
await writeFile7(temporary, `${JSON.stringify({ sessionId })}
|
|
16876
16648
|
`, { encoding: "utf8", mode: 384 });
|
|
16877
16649
|
await rename2(temporary, target);
|
|
16878
16650
|
}
|
|
@@ -17019,7 +16791,7 @@ var init_session_dialogue = __esm({
|
|
|
17019
16791
|
|
|
17020
16792
|
// src/ticket-provenance.ts
|
|
17021
16793
|
import { createHash as createHash7 } from "node:crypto";
|
|
17022
|
-
import { readFile as
|
|
16794
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
17023
16795
|
import { basename as basename8, dirname as dirname16, join as join28, resolve as resolve12 } from "node:path";
|
|
17024
16796
|
function dialogueSessionSourceRoots(home) {
|
|
17025
16797
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
@@ -17115,7 +16887,7 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
|
|
|
17115
16887
|
const { recordFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
17116
16888
|
let text;
|
|
17117
16889
|
try {
|
|
17118
|
-
text = await
|
|
16890
|
+
text = await readFile18(recordFile, "utf8");
|
|
17119
16891
|
} catch (error) {
|
|
17120
16892
|
if (error.code === "ENOENT") {
|
|
17121
16893
|
return {
|
|
@@ -17595,7 +17367,7 @@ __export(case_dossier_delivery_exports, {
|
|
|
17595
17367
|
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
17596
17368
|
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
17597
17369
|
});
|
|
17598
|
-
import { mkdtemp as mkdtemp3, readFile as
|
|
17370
|
+
import { mkdtemp as mkdtemp3, readFile as readFile19, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
17599
17371
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
17600
17372
|
import { join as join29 } from "node:path";
|
|
17601
17373
|
async function projectCaseDossierPointerSection(input) {
|
|
@@ -17627,7 +17399,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
17627
17399
|
const stagingDir = await mkdtemp3(join29(tmpdir3(), "ak-case-dossier-"));
|
|
17628
17400
|
try {
|
|
17629
17401
|
const stagingPath = join29(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
17630
|
-
await
|
|
17402
|
+
await writeFile8(stagingPath, `${section}
|
|
17631
17403
|
`, "utf8");
|
|
17632
17404
|
return await freezeAttachmentsIntoRun(
|
|
17633
17405
|
[stagingPath],
|
|
@@ -17647,7 +17419,7 @@ async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
|
17647
17419
|
);
|
|
17648
17420
|
let section;
|
|
17649
17421
|
try {
|
|
17650
|
-
section = await
|
|
17422
|
+
section = await readFile19(frozenPath, "utf8");
|
|
17651
17423
|
} catch (error) {
|
|
17652
17424
|
if (error.code === "ENOENT") return void 0;
|
|
17653
17425
|
throw error;
|
|
@@ -17670,9 +17442,9 @@ var init_case_dossier_delivery = __esm({
|
|
|
17670
17442
|
});
|
|
17671
17443
|
|
|
17672
17444
|
// src/host-transition-prior-native.ts
|
|
17673
|
-
import { access as access3, readdir as
|
|
17445
|
+
import { access as access3, readdir as readdir7 } from "node:fs/promises";
|
|
17674
17446
|
import { dirname as dirname17, join as join30 } from "node:path";
|
|
17675
|
-
function
|
|
17447
|
+
function isEnoent2(error) {
|
|
17676
17448
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
17677
17449
|
}
|
|
17678
17450
|
async function listPiNativeRecordPaths(sessionFile) {
|
|
@@ -17680,7 +17452,7 @@ async function listPiNativeRecordPaths(sessionFile) {
|
|
|
17680
17452
|
await access3(sessionFile);
|
|
17681
17453
|
return [sessionFile];
|
|
17682
17454
|
} catch (error) {
|
|
17683
|
-
if (
|
|
17455
|
+
if (isEnoent2(error)) return [];
|
|
17684
17456
|
throw error;
|
|
17685
17457
|
}
|
|
17686
17458
|
}
|
|
@@ -17688,9 +17460,9 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
17688
17460
|
const sessionRoot = dirname17(sessionParent);
|
|
17689
17461
|
let entries;
|
|
17690
17462
|
try {
|
|
17691
|
-
entries = await
|
|
17463
|
+
entries = await readdir7(sessionRoot, { withFileTypes: true });
|
|
17692
17464
|
} catch (error) {
|
|
17693
|
-
if (
|
|
17465
|
+
if (isEnoent2(error)) return [];
|
|
17694
17466
|
throw error;
|
|
17695
17467
|
}
|
|
17696
17468
|
const recordPaths = [];
|
|
@@ -17701,7 +17473,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
17701
17473
|
await access3(recordFile);
|
|
17702
17474
|
recordPaths.push(recordFile);
|
|
17703
17475
|
} catch (error) {
|
|
17704
|
-
if (!
|
|
17476
|
+
if (!isEnoent2(error)) throw error;
|
|
17705
17477
|
}
|
|
17706
17478
|
}
|
|
17707
17479
|
recordPaths.sort();
|
|
@@ -18162,7 +17934,7 @@ var init_auto_resume = __esm({
|
|
|
18162
17934
|
|
|
18163
17935
|
// src/public-cli/post-admission.ts
|
|
18164
17936
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
18165
|
-
import { writeFile as
|
|
17937
|
+
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
18166
17938
|
import { isAbsolute as isAbsolute8, join as join32, resolve as resolve13 } from "node:path";
|
|
18167
17939
|
function describeCaughtError(error) {
|
|
18168
17940
|
if (error instanceof Error) {
|
|
@@ -18174,6 +17946,28 @@ function describeCaughtError(error) {
|
|
|
18174
17946
|
function isStationChildOfficerDialogue(role, env) {
|
|
18175
17947
|
return env.stationChild === true && isOfficerReviewSeat(role);
|
|
18176
17948
|
}
|
|
17949
|
+
function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
17950
|
+
const rewrite = (value) => rewriteRunDirectoryPathValue(
|
|
17951
|
+
value,
|
|
17952
|
+
relocation.oldRunDirectory,
|
|
17953
|
+
relocation.newRunDirectory
|
|
17954
|
+
);
|
|
17955
|
+
const mutableRequest = request;
|
|
17956
|
+
mutableRequest.runDirectory = admitted.runDirectory;
|
|
17957
|
+
mutableRequest.principal = admitted.principal;
|
|
17958
|
+
const activation = mutableRequest.activation;
|
|
17959
|
+
if (activation !== null && typeof activation === "object" && !Array.isArray(activation)) {
|
|
17960
|
+
for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath", "requestManifestPath"]) {
|
|
17961
|
+
const record4 = activation;
|
|
17962
|
+
if (field in record4) record4[field] = rewrite(record4[field]);
|
|
17963
|
+
}
|
|
17964
|
+
}
|
|
17965
|
+
if (result.terminal !== void 0) {
|
|
17966
|
+
for (const artifact of result.terminal.artifacts) {
|
|
17967
|
+
artifact.path = rewrite(artifact.path);
|
|
17968
|
+
}
|
|
17969
|
+
}
|
|
17970
|
+
}
|
|
18177
17971
|
function withProcessCancelSkipAutoResume(result, signal) {
|
|
18178
17972
|
if (processCancelSignalName(signal) === void 0) {
|
|
18179
17973
|
return result;
|
|
@@ -18230,7 +18024,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
18230
18024
|
} catch (appendError) {
|
|
18231
18025
|
try {
|
|
18232
18026
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
18233
|
-
await
|
|
18027
|
+
await writeFile9(
|
|
18234
18028
|
join32(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
18235
18029
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
18236
18030
|
`,
|
|
@@ -18406,6 +18200,10 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18406
18200
|
const ticketNumber = asserted === void 0 ? void 0 : asserted.ticketNumber;
|
|
18407
18201
|
if (ticketNumber !== void 0) await bindAdmittedTicketNumber(admitted, ticketNumber);
|
|
18408
18202
|
}
|
|
18203
|
+
const relocation = await relocateAdmittedRunToTicket(admitted, env.principalAuthority, lease);
|
|
18204
|
+
if (relocation !== void 0) {
|
|
18205
|
+
projectRelocatedTurnIdentity(request, result, admitted, relocation);
|
|
18206
|
+
}
|
|
18409
18207
|
if (adapters.afterDispatch !== void 0) await adapters.afterDispatch(admitted, lease);
|
|
18410
18208
|
return result;
|
|
18411
18209
|
} catch (error) {
|
|
@@ -18546,7 +18344,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18546
18344
|
}
|
|
18547
18345
|
let stderrLogWriteFailure;
|
|
18548
18346
|
try {
|
|
18549
|
-
await
|
|
18347
|
+
await writeFile9(
|
|
18550
18348
|
join32(admitted.runDirectory, "stderr.log"),
|
|
18551
18349
|
result.stderr,
|
|
18552
18350
|
"utf8"
|
|
@@ -19112,6 +18910,7 @@ var init_post_admission = __esm({
|
|
|
19112
18910
|
init_activation_ledger_topology();
|
|
19113
18911
|
init_engine_material();
|
|
19114
18912
|
init_session_identity();
|
|
18913
|
+
init_role_run_relocation();
|
|
19115
18914
|
init_host_contracts();
|
|
19116
18915
|
init_case_dossier_delivery();
|
|
19117
18916
|
init_engine_detour_usage();
|
|
@@ -21005,7 +20804,7 @@ __export(public_role_summons_exports, {
|
|
|
21005
20804
|
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
21006
20805
|
});
|
|
21007
20806
|
import { execFile as execFile3 } from "node:child_process";
|
|
21008
|
-
import { existsSync as
|
|
20807
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
21009
20808
|
import { mkdir as mkdir4, mkdtemp as mkdtemp4, realpath as realpath7, rm as rm5 } from "node:fs/promises";
|
|
21010
20809
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
21011
20810
|
import { join as join33, relative as relative3, sep as sep5 } from "node:path";
|
|
@@ -21032,7 +20831,7 @@ function parentDir(path) {
|
|
|
21032
20831
|
function walkPackageRoot(start) {
|
|
21033
20832
|
let dir = start;
|
|
21034
20833
|
for (let i = 0; i < 12; i += 1) {
|
|
21035
|
-
if (
|
|
20834
|
+
if (existsSync9(join33(dir, "package.json")) && existsSync9(join33(dir, "souls"))) {
|
|
21036
20835
|
return dir;
|
|
21037
20836
|
}
|
|
21038
20837
|
const parent = parentDir(dir);
|
|
@@ -21941,7 +21740,7 @@ __export(archivist_record_entry_exports, {
|
|
|
21941
21740
|
});
|
|
21942
21741
|
import {
|
|
21943
21742
|
closeSync,
|
|
21944
|
-
existsSync as
|
|
21743
|
+
existsSync as existsSync10,
|
|
21945
21744
|
mkdirSync as mkdirSync2,
|
|
21946
21745
|
openSync,
|
|
21947
21746
|
readdirSync as readdirSync2,
|
|
@@ -22104,7 +21903,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
22104
21903
|
}
|
|
22105
21904
|
function resolveNavigatorNestContinuation(sessionDir, cwd) {
|
|
22106
21905
|
const ledgerPath = currentSessionLedgerPath(sessionDir);
|
|
22107
|
-
if (
|
|
21906
|
+
if (existsSync10(ledgerPath)) {
|
|
22108
21907
|
const recentFile = readCurrentSession(sessionDir);
|
|
22109
21908
|
assertRecentFinalFileUnderSessionDir(sessionDir, recentFile);
|
|
22110
21909
|
return recentFile;
|
|
@@ -22189,7 +21988,7 @@ function createRecordSessionOpen(options) {
|
|
|
22189
21988
|
parentSession = parentFile;
|
|
22190
21989
|
mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
22191
21990
|
}
|
|
22192
|
-
const nestAlreadyExists =
|
|
21991
|
+
const nestAlreadyExists = existsSync10(sessionDir);
|
|
22193
21992
|
ensureRealDirectoryTree(ledgerHome, sessionDir);
|
|
22194
21993
|
if (mayResumeSameNest && nestAlreadyExists) {
|
|
22195
21994
|
if (options.kind === NAVIGATOR_RECORD_KIND) {
|
|
@@ -22216,7 +22015,7 @@ function createRecordSessionOpen(options) {
|
|
|
22216
22015
|
);
|
|
22217
22016
|
if (session.isPersisted()) {
|
|
22218
22017
|
const file = session.getSessionFile();
|
|
22219
|
-
if (file !== void 0 && !
|
|
22018
|
+
if (file !== void 0 && !existsSync10(file)) {
|
|
22220
22019
|
const header = session.getHeader();
|
|
22221
22020
|
if (header !== null && header.type === "session") {
|
|
22222
22021
|
writeFileSync2(file, `${JSON.stringify(header)}
|
|
@@ -22270,7 +22069,7 @@ var init_archivist_record_entry = __esm({
|
|
|
22270
22069
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
22271
22070
|
|
|
22272
22071
|
// src/role-runtime-dependencies.ts
|
|
22273
|
-
import { readFile as
|
|
22072
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
22274
22073
|
import { join as join40 } from "node:path";
|
|
22275
22074
|
|
|
22276
22075
|
// src/canonical-skill-binding.ts
|
|
@@ -23307,7 +23106,7 @@ ${helpContext}
|
|
|
23307
23106
|
// src/navigator-work-context.ts
|
|
23308
23107
|
init_doctor_evidence();
|
|
23309
23108
|
init_host_contracts();
|
|
23310
|
-
import { readFile as
|
|
23109
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
23311
23110
|
import { resolve as resolve17 } from "node:path";
|
|
23312
23111
|
init_notary_source_run();
|
|
23313
23112
|
init_packaged_role_registry();
|
|
@@ -23320,7 +23119,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
23320
23119
|
}
|
|
23321
23120
|
async function loadNavigatorWorkContext(options) {
|
|
23322
23121
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
23323
|
-
const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await
|
|
23122
|
+
const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile20(reference, "utf8");
|
|
23324
23123
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
23325
23124
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
23326
23125
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -23377,7 +23176,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
23377
23176
|
let authorityMaterial;
|
|
23378
23177
|
for (const path of authorityFiles) {
|
|
23379
23178
|
try {
|
|
23380
|
-
const content = await
|
|
23179
|
+
const content = await readFile20(path, "utf8");
|
|
23381
23180
|
if (content.trim() !== "") {
|
|
23382
23181
|
authorityMaterial = content;
|
|
23383
23182
|
break;
|
|
@@ -23869,18 +23668,18 @@ init_collector_evidence();
|
|
|
23869
23668
|
init_collector_github();
|
|
23870
23669
|
|
|
23871
23670
|
// src/collector-handbook.ts
|
|
23872
|
-
import { readFile as
|
|
23671
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
23873
23672
|
import { join as join38, sep as sep6 } from "node:path";
|
|
23874
23673
|
|
|
23875
23674
|
// src/atomic-write.ts
|
|
23876
23675
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
23877
|
-
import { rename as rename3, rm as rm6, writeFile as
|
|
23676
|
+
import { rename as rename3, rm as rm6, writeFile as writeFile10 } from "node:fs/promises";
|
|
23878
23677
|
import { dirname as dirname21, join as join37 } from "node:path";
|
|
23879
23678
|
async function writeFileAtomically(destination, contents) {
|
|
23880
23679
|
const parent = dirname21(destination);
|
|
23881
23680
|
const temporary = join37(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
23882
23681
|
try {
|
|
23883
|
-
await
|
|
23682
|
+
await writeFile10(temporary, contents);
|
|
23884
23683
|
await rename3(temporary, destination);
|
|
23885
23684
|
} catch (error) {
|
|
23886
23685
|
await rm6(temporary, { force: true }).catch(() => void 0);
|
|
@@ -24032,7 +23831,7 @@ function createCollectorHandbookStore(input) {
|
|
|
24032
23831
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
24033
23832
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
24034
23833
|
try {
|
|
24035
|
-
const body = await
|
|
23834
|
+
const body = await readFile21(path, "utf8");
|
|
24036
23835
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
24037
23836
|
return body;
|
|
24038
23837
|
} catch (error) {
|
|
@@ -25381,7 +25180,7 @@ init_sitian_facade();
|
|
|
25381
25180
|
init_submission_errors();
|
|
25382
25181
|
init_submission_errors();
|
|
25383
25182
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
25384
|
-
import { existsSync as
|
|
25183
|
+
import { existsSync as existsSync11, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
25385
25184
|
import { resolve as resolve19 } from "node:path";
|
|
25386
25185
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
25387
25186
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
@@ -25412,7 +25211,7 @@ function statusOf(error) {
|
|
|
25412
25211
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
25413
25212
|
}
|
|
25414
25213
|
function tryGetAll(file, key) {
|
|
25415
|
-
if (!
|
|
25214
|
+
if (!existsSync11(file)) return [];
|
|
25416
25215
|
try {
|
|
25417
25216
|
const out = gitFile(file, ["--get-all", key]);
|
|
25418
25217
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -25422,7 +25221,7 @@ function tryGetAll(file, key) {
|
|
|
25422
25221
|
}
|
|
25423
25222
|
}
|
|
25424
25223
|
function ownedHook(path) {
|
|
25425
|
-
if (!
|
|
25224
|
+
if (!existsSync11(path)) return false;
|
|
25426
25225
|
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
25427
25226
|
}
|
|
25428
25227
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -25449,11 +25248,11 @@ function rmOwnedDir(dir) {
|
|
|
25449
25248
|
const hookPath = resolve19(dir, HOOK_FILE);
|
|
25450
25249
|
if (!ownedHook(hookPath)) return;
|
|
25451
25250
|
rmSync(hookPath, { force: true });
|
|
25452
|
-
if (
|
|
25251
|
+
if (existsSync11(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
25453
25252
|
}
|
|
25454
25253
|
function linkedGitDirs(commonDir) {
|
|
25455
25254
|
const root = resolve19(commonDir, "worktrees");
|
|
25456
|
-
if (!
|
|
25255
|
+
if (!existsSync11(root)) return [];
|
|
25457
25256
|
return readdirSync3(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
25458
25257
|
}
|
|
25459
25258
|
function uninstallPackageWorkerHooks(cwd) {
|
|
@@ -27653,12 +27452,12 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27653
27452
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
27654
27453
|
loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
|
|
27655
27454
|
loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
|
|
27656
|
-
loadFixPacket: (path) =>
|
|
27455
|
+
loadFixPacket: (path) => readFile22(path, "utf8"),
|
|
27657
27456
|
loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
|
|
27658
|
-
loadCoderTask: (path) =>
|
|
27457
|
+
loadCoderTask: (path) => readFile22(path, "utf8"),
|
|
27659
27458
|
loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
|
|
27660
27459
|
loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
|
|
27661
|
-
loadCollectorHandbookSeed: () =>
|
|
27460
|
+
loadCollectorHandbookSeed: () => readFile22(collectorHandbookSeedPath, "utf8"),
|
|
27662
27461
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
27663
27462
|
loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
|
|
27664
27463
|
loadDoctorCase,
|
|
@@ -27673,7 +27472,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27673
27472
|
loadSecretariatSoul: () => loadMainRoleSessionMaterials("secretariat"),
|
|
27674
27473
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
27675
27474
|
loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
|
|
27676
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
27475
|
+
loadMergerInput: async (path) => JSON.parse(await readFile22(path, "utf8")),
|
|
27677
27476
|
async loadCanonicalSkillBinding(name) {
|
|
27678
27477
|
if (name === "tdd") {
|
|
27679
27478
|
return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
|
|
@@ -27699,7 +27498,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27699
27498
|
authority: options.authority,
|
|
27700
27499
|
invocationId: options.invocationId,
|
|
27701
27500
|
loadSoul: () => loadMainRoleSessionMaterials("navigator"),
|
|
27702
|
-
loadRoutePlaybook: () =>
|
|
27501
|
+
loadRoutePlaybook: () => readFile22(navigatorRoutePlaybookPath, "utf8"),
|
|
27703
27502
|
loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
|
|
27704
27503
|
createSession: navigatorSessionFactory,
|
|
27705
27504
|
...options.contextError === void 0 ? {} : { contextError: options.contextError },
|
|
@@ -27711,7 +27510,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27711
27510
|
// src/role-envelope.ts
|
|
27712
27511
|
init_engine_detour();
|
|
27713
27512
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
27714
|
-
import { appendFile as appendFile3, mkdir as mkdir6, writeFile as
|
|
27513
|
+
import { appendFile as appendFile3, mkdir as mkdir6, writeFile as writeFile11 } from "node:fs/promises";
|
|
27715
27514
|
import { createServer } from "node:net";
|
|
27716
27515
|
import { dirname as dirname23, join as join42 } from "node:path";
|
|
27717
27516
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -27809,7 +27608,7 @@ async function requireGatekeeperPass(options) {
|
|
|
27809
27608
|
}
|
|
27810
27609
|
|
|
27811
27610
|
// src/host-native-method.ts
|
|
27812
|
-
import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as
|
|
27611
|
+
import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as readdir8, readFile as readFile23, readlink, realpath as realpath8, symlink } from "node:fs/promises";
|
|
27813
27612
|
import { basename as basename10, dirname as dirname22, join as join41 } from "node:path";
|
|
27814
27613
|
var HOST_METHOD_PLUGIN_NAME = "ak-methods";
|
|
27815
27614
|
var packagedMethodsDir = (root) => join41(root, "resources", "methods");
|
|
@@ -27841,16 +27640,16 @@ function applyCodexSkillInvocation(methods, prompt) {
|
|
|
27841
27640
|
prompt
|
|
27842
27641
|
);
|
|
27843
27642
|
}
|
|
27844
|
-
var
|
|
27643
|
+
var isEnoent3 = (error) => error.code === "ENOENT";
|
|
27845
27644
|
async function packagedMethodSkillNames(packagedMethodsRealpath) {
|
|
27846
|
-
const entries = await
|
|
27645
|
+
const entries = await readdir8(packagedMethodsRealpath, { withFileTypes: true });
|
|
27847
27646
|
const names = [];
|
|
27848
27647
|
for (const entry of entries) {
|
|
27849
27648
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
27850
27649
|
try {
|
|
27851
27650
|
await access4(join41(packagedMethodsRealpath, entry.name, "SKILL.md"));
|
|
27852
27651
|
} catch (error) {
|
|
27853
|
-
if (
|
|
27652
|
+
if (isEnoent3(error)) continue;
|
|
27854
27653
|
throw error;
|
|
27855
27654
|
}
|
|
27856
27655
|
names.push(entry.name);
|
|
@@ -27861,12 +27660,12 @@ async function packagedSkillFileBytes(skillDir) {
|
|
|
27861
27660
|
try {
|
|
27862
27661
|
await access4(join41(skillDir, "SKILL.md"));
|
|
27863
27662
|
} catch (error) {
|
|
27864
|
-
if (
|
|
27663
|
+
if (isEnoent3(error)) return void 0;
|
|
27865
27664
|
throw error;
|
|
27866
27665
|
}
|
|
27867
27666
|
const files = /* @__PURE__ */ new Map();
|
|
27868
27667
|
async function walk(dir, prefix) {
|
|
27869
|
-
const entries = await
|
|
27668
|
+
const entries = await readdir8(dir, { withFileTypes: true });
|
|
27870
27669
|
for (const entry of entries) {
|
|
27871
27670
|
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
27872
27671
|
const full = join41(dir, entry.name);
|
|
@@ -27875,7 +27674,7 @@ async function packagedSkillFileBytes(skillDir) {
|
|
|
27875
27674
|
continue;
|
|
27876
27675
|
}
|
|
27877
27676
|
if (entry.isFile()) {
|
|
27878
|
-
files.set(rel, await
|
|
27677
|
+
files.set(rel, await readFile23(full));
|
|
27879
27678
|
}
|
|
27880
27679
|
}
|
|
27881
27680
|
}
|
|
@@ -27886,9 +27685,9 @@ async function catalogPublishesPackagedSkill(catalogSkillDir, required) {
|
|
|
27886
27685
|
for (const [rel, bytes] of required) {
|
|
27887
27686
|
let other;
|
|
27888
27687
|
try {
|
|
27889
|
-
other = await
|
|
27688
|
+
other = await readFile23(join41(catalogSkillDir, rel));
|
|
27890
27689
|
} catch (error) {
|
|
27891
|
-
if (
|
|
27690
|
+
if (isEnoent3(error)) return false;
|
|
27892
27691
|
throw error;
|
|
27893
27692
|
}
|
|
27894
27693
|
if (!bytes.equals(other)) return false;
|
|
@@ -27902,7 +27701,7 @@ async function isCompatibleMethodCatalog(link, packagedMethodsRealpath) {
|
|
|
27902
27701
|
try {
|
|
27903
27702
|
resolved = await realpath8(link);
|
|
27904
27703
|
} catch (error) {
|
|
27905
|
-
if (
|
|
27704
|
+
if (isEnoent3(error)) return false;
|
|
27906
27705
|
throw error;
|
|
27907
27706
|
}
|
|
27908
27707
|
if (resolved === packagedMethodsRealpath) return true;
|
|
@@ -27923,7 +27722,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
27923
27722
|
await lstat7(link);
|
|
27924
27723
|
present = true;
|
|
27925
27724
|
} catch (error) {
|
|
27926
|
-
if (!
|
|
27725
|
+
if (!isEnoent3(error)) throw error;
|
|
27927
27726
|
present = false;
|
|
27928
27727
|
}
|
|
27929
27728
|
if (present) {
|
|
@@ -27992,7 +27791,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
27992
27791
|
await mkdir6(dirname23(sessionFile), { recursive: true });
|
|
27993
27792
|
if (request.continuation.kind !== "resume") {
|
|
27994
27793
|
try {
|
|
27995
|
-
await
|
|
27794
|
+
await writeFile11(
|
|
27996
27795
|
sessionFile,
|
|
27997
27796
|
`${JSON.stringify({
|
|
27998
27797
|
type: "session",
|
|
@@ -28800,8 +28599,8 @@ function headlessMcpConfigDocument(mcpServers) {
|
|
|
28800
28599
|
// src/headless-host/role-turn-host.ts
|
|
28801
28600
|
import { spawn as spawn4, spawnSync } from "node:child_process";
|
|
28802
28601
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
28803
|
-
import { existsSync as
|
|
28804
|
-
import { writeFile as
|
|
28602
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
28603
|
+
import { writeFile as writeFile12 } from "node:fs/promises";
|
|
28805
28604
|
import { dirname as dirname24, isAbsolute as isAbsolute10, join as join44, resolve as resolve20 } from "node:path";
|
|
28806
28605
|
|
|
28807
28606
|
// src/external-host-turn-loop.ts
|
|
@@ -29022,7 +28821,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
29022
28821
|
function cwdIsGitWorkTree(cwd) {
|
|
29023
28822
|
let dir = cwd;
|
|
29024
28823
|
for (; ; ) {
|
|
29025
|
-
if (
|
|
28824
|
+
if (existsSync12(join44(dir, ".git"))) return true;
|
|
29026
28825
|
const parent = dirname24(dir);
|
|
29027
28826
|
if (parent === dir) return false;
|
|
29028
28827
|
dir = parent;
|
|
@@ -29231,7 +29030,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29231
29030
|
}
|
|
29232
29031
|
const env = { ...process.env, ...config.env ?? {} };
|
|
29233
29032
|
const systemPromptPath = join44(request.runDirectory, "headless-system-prompt.txt");
|
|
29234
|
-
await
|
|
29033
|
+
await writeFile12(systemPromptPath, systemPrompt, "utf8");
|
|
29235
29034
|
let mcpConfigPath;
|
|
29236
29035
|
let outputSchemaPath;
|
|
29237
29036
|
let pluginDir;
|
|
@@ -29239,7 +29038,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29239
29038
|
if (codex) {
|
|
29240
29039
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
29241
29040
|
outputSchemaPath = join44(request.runDirectory, "headless-output-schema.json");
|
|
29242
|
-
await
|
|
29041
|
+
await writeFile12(
|
|
29243
29042
|
outputSchemaPath,
|
|
29244
29043
|
`${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
|
|
29245
29044
|
`,
|
|
@@ -29248,7 +29047,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29248
29047
|
}
|
|
29249
29048
|
} else {
|
|
29250
29049
|
mcpConfigPath = join44(request.runDirectory, "headless-mcp-config.json");
|
|
29251
|
-
await
|
|
29050
|
+
await writeFile12(
|
|
29252
29051
|
mcpConfigPath,
|
|
29253
29052
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
29254
29053
|
`,
|