@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.
- package/dist/acp-host/production-host.js +278 -590
- package/dist/headless-host/production-host.js +284 -596
- 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 +250 -563
- package/dist/public-cli/post-admission.js +96 -131
- 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/cli.ts +0 -5
- package/src/public-cli/config.ts +0 -1
- package/src/public-cli/countersign-run.ts +1 -1
- package/src/public-cli/diarist-run.ts +1 -1
- package/src/public-cli/invocation.ts +13 -9
- package/src/public-cli/post-admission.ts +124 -187
- package/src/public-cli/run-lifecycle.ts +42 -4
- package/src/role-run-relocation.ts +27 -30
- package/dist/public-cli/public-run-credentials.js +0 -49
- package/src/public-cli/public-run-credentials.ts +0 -71
|
@@ -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();
|
|
@@ -17726,42 +17498,6 @@ var init_host_transition_prior_native = __esm({
|
|
|
17726
17498
|
}
|
|
17727
17499
|
});
|
|
17728
17500
|
|
|
17729
|
-
// src/public-cli/public-run-credentials.ts
|
|
17730
|
-
function knownFailureForMissingProviderCredential(model, credentials) {
|
|
17731
|
-
if (model === void 0 || credentials === void 0) return void 0;
|
|
17732
|
-
if (model.provider !== "openai-codex" && model.provider !== "xai") return void 0;
|
|
17733
|
-
if (!missingPublicProviderCredential(model.provider, credentials)) {
|
|
17734
|
-
return void 0;
|
|
17735
|
-
}
|
|
17736
|
-
return {
|
|
17737
|
-
cause: "provider",
|
|
17738
|
-
identity: {
|
|
17739
|
-
name: "MissingProviderCredential",
|
|
17740
|
-
code: model.provider
|
|
17741
|
-
}
|
|
17742
|
-
};
|
|
17743
|
-
}
|
|
17744
|
-
function missingCredentialPreDispatchFailure(model, credentials) {
|
|
17745
|
-
const knownFailure = knownFailureForMissingProviderCredential(model, credentials);
|
|
17746
|
-
if (knownFailure === void 0) return void 0;
|
|
17747
|
-
return {
|
|
17748
|
-
timedOut: false,
|
|
17749
|
-
code: 1,
|
|
17750
|
-
stderr: `Missing credential for provider ${String(knownFailure.identity?.code ?? "unknown")}`,
|
|
17751
|
-
knownFailure
|
|
17752
|
-
};
|
|
17753
|
-
}
|
|
17754
|
-
function postRunMissingCredentialFailure(result, model, credentials) {
|
|
17755
|
-
if (!(result.timedOut || result.code !== 0)) return void 0;
|
|
17756
|
-
return knownFailureForMissingProviderCredential(model, credentials);
|
|
17757
|
-
}
|
|
17758
|
-
var init_public_run_credentials = __esm({
|
|
17759
|
-
"src/public-cli/public-run-credentials.ts"() {
|
|
17760
|
-
"use strict";
|
|
17761
|
-
init_config();
|
|
17762
|
-
}
|
|
17763
|
-
});
|
|
17764
|
-
|
|
17765
17501
|
// src/public-cli/process-cancel.ts
|
|
17766
17502
|
function processCancelSignalName(signal) {
|
|
17767
17503
|
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
@@ -18198,7 +17934,7 @@ var init_auto_resume = __esm({
|
|
|
18198
17934
|
|
|
18199
17935
|
// src/public-cli/post-admission.ts
|
|
18200
17936
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
18201
|
-
import { writeFile as
|
|
17937
|
+
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
18202
17938
|
import { isAbsolute as isAbsolute8, join as join32, resolve as resolve13 } from "node:path";
|
|
18203
17939
|
function describeCaughtError(error) {
|
|
18204
17940
|
if (error instanceof Error) {
|
|
@@ -18210,6 +17946,28 @@ function describeCaughtError(error) {
|
|
|
18210
17946
|
function isStationChildOfficerDialogue(role, env) {
|
|
18211
17947
|
return env.stationChild === true && isOfficerReviewSeat(role);
|
|
18212
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
|
+
}
|
|
18213
17971
|
function withProcessCancelSkipAutoResume(result, signal) {
|
|
18214
17972
|
if (processCancelSignalName(signal) === void 0) {
|
|
18215
17973
|
return result;
|
|
@@ -18254,8 +18012,8 @@ function withOnceSuccessfulBeforeDispatch(adapters) {
|
|
|
18254
18012
|
};
|
|
18255
18013
|
}
|
|
18256
18014
|
async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic, io) {
|
|
18257
|
-
io.stderr(formatCliDiagnostic(diagnostic));
|
|
18258
18015
|
const payload = { diagnostic, recordedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
18016
|
+
let retentionFailure;
|
|
18259
18017
|
try {
|
|
18260
18018
|
await env.sessionAppender(
|
|
18261
18019
|
env.principalAuthority,
|
|
@@ -18263,24 +18021,26 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
18263
18021
|
POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE,
|
|
18264
18022
|
payload
|
|
18265
18023
|
);
|
|
18266
|
-
return;
|
|
18267
18024
|
} catch (appendError) {
|
|
18268
18025
|
try {
|
|
18269
18026
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
18270
|
-
await
|
|
18027
|
+
await writeFile9(
|
|
18271
18028
|
join32(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
18272
18029
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
18273
18030
|
`,
|
|
18274
18031
|
{ encoding: "utf8", flag: "wx" }
|
|
18275
18032
|
);
|
|
18276
18033
|
} catch (artifactError) {
|
|
18277
|
-
|
|
18278
|
-
formatCliDiagnostic(
|
|
18279
|
-
`post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`
|
|
18280
|
-
)
|
|
18281
|
-
);
|
|
18034
|
+
retentionFailure = `post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`;
|
|
18282
18035
|
}
|
|
18283
18036
|
}
|
|
18037
|
+
try {
|
|
18038
|
+
io.stderr(formatCliDiagnostic(diagnostic));
|
|
18039
|
+
if (retentionFailure !== void 0) {
|
|
18040
|
+
io.stderr(formatCliDiagnostic(retentionFailure));
|
|
18041
|
+
}
|
|
18042
|
+
} catch {
|
|
18043
|
+
}
|
|
18284
18044
|
}
|
|
18285
18045
|
async function resolveResumeMethodMaterialAdapters(input) {
|
|
18286
18046
|
if (input.shouldLoad === false) {
|
|
@@ -18440,15 +18200,18 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18440
18200
|
const ticketNumber = asserted === void 0 ? void 0 : asserted.ticketNumber;
|
|
18441
18201
|
if (ticketNumber !== void 0) await bindAdmittedTicketNumber(admitted, ticketNumber);
|
|
18442
18202
|
}
|
|
18203
|
+
const relocation = await relocateAdmittedRunToTicket(admitted, env.principalAuthority, lease);
|
|
18204
|
+
if (relocation !== void 0) {
|
|
18205
|
+
projectRelocatedTurnIdentity(request, result, admitted, relocation);
|
|
18206
|
+
}
|
|
18443
18207
|
if (adapters.afterDispatch !== void 0) await adapters.afterDispatch(admitted, lease);
|
|
18444
18208
|
return result;
|
|
18445
18209
|
} catch (error) {
|
|
18446
|
-
|
|
18447
|
-
if (primaryFailure) {
|
|
18210
|
+
if (result.terminal !== void 0) {
|
|
18448
18211
|
await recordBestEffortPostDispatchDiagnostic(
|
|
18449
18212
|
admitted,
|
|
18450
18213
|
env,
|
|
18451
|
-
`afterDispatch failed beside
|
|
18214
|
+
`afterDispatch failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
18452
18215
|
io
|
|
18453
18216
|
);
|
|
18454
18217
|
return result;
|
|
@@ -18474,23 +18237,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18474
18237
|
}
|
|
18475
18238
|
};
|
|
18476
18239
|
try {
|
|
18477
|
-
const missingCredential = missingCredentialPreDispatchFailure(
|
|
18478
|
-
env.model,
|
|
18479
|
-
env.credentials
|
|
18480
|
-
);
|
|
18481
|
-
if (missingCredential !== void 0) {
|
|
18482
|
-
return {
|
|
18483
|
-
...await presentControlledFailure2(
|
|
18484
|
-
admitted,
|
|
18485
|
-
withEngineDetourInvocationScope(missingCredential, request.invocationScopeId),
|
|
18486
|
-
adapters,
|
|
18487
|
-
env.principalAuthority,
|
|
18488
|
-
io,
|
|
18489
|
-
persistRunState
|
|
18490
|
-
),
|
|
18491
|
-
...deferredPersist
|
|
18492
|
-
};
|
|
18493
|
-
}
|
|
18494
18240
|
let previousHost;
|
|
18495
18241
|
const liveHost = env.host;
|
|
18496
18242
|
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
@@ -18598,7 +18344,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18598
18344
|
}
|
|
18599
18345
|
let stderrLogWriteFailure;
|
|
18600
18346
|
try {
|
|
18601
|
-
await
|
|
18347
|
+
await writeFile9(
|
|
18602
18348
|
join32(admitted.runDirectory, "stderr.log"),
|
|
18603
18349
|
result.stderr,
|
|
18604
18350
|
"utf8"
|
|
@@ -18623,19 +18369,14 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18623
18369
|
try {
|
|
18624
18370
|
const sessionFile = admitted.principal !== void 0 ? env.principalAuthority.decode(admitted.principal).sessionFile : "";
|
|
18625
18371
|
const runnerKnownFailure = adapters.resolveRunnerKnownFailure !== void 0 && sessionFile !== "" ? await adapters.resolveRunnerKnownFailure({ result, sessionFile }) : result.knownFailure;
|
|
18626
|
-
const credentialFailure = postRunMissingCredentialFailure(
|
|
18627
|
-
result,
|
|
18628
|
-
env.model,
|
|
18629
|
-
env.credentials
|
|
18630
|
-
);
|
|
18631
18372
|
resolution = await resolveAuditedRunnerFailureResolution({
|
|
18632
18373
|
runner: runnerKnownFailure,
|
|
18633
18374
|
sessionFile,
|
|
18634
|
-
credential:
|
|
18375
|
+
credential: void 0,
|
|
18635
18376
|
runDirectory: admitted.runDirectory
|
|
18636
18377
|
});
|
|
18637
18378
|
const processCancelName = processCancelSignalName(env.signal);
|
|
18638
|
-
const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 ||
|
|
18379
|
+
const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 || processCancelName !== void 0;
|
|
18639
18380
|
hostSignalFailed = directHostFailureSignal || result.code !== null && result.code !== 0 || resolution.knownFailure !== void 0;
|
|
18640
18381
|
settled = await adapters.trySettle(admitted, env.principalAuthority, courtScope);
|
|
18641
18382
|
if (settled !== void 0) {
|
|
@@ -18701,25 +18442,11 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18701
18442
|
try {
|
|
18702
18443
|
await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
|
|
18703
18444
|
} catch (error) {
|
|
18704
|
-
|
|
18445
|
+
await recordBestEffortPostDispatchDiagnostic(
|
|
18705
18446
|
admitted,
|
|
18706
|
-
|
|
18707
|
-
|
|
18708
|
-
|
|
18709
|
-
stderr: "",
|
|
18710
|
-
thrown: error,
|
|
18711
|
-
skipRunStateWrite: true
|
|
18712
|
-
}, request.invocationScopeId),
|
|
18713
|
-
adapters,
|
|
18714
|
-
env.principalAuthority,
|
|
18715
|
-
io,
|
|
18716
|
-
persistRunState
|
|
18717
|
-
);
|
|
18718
|
-
return await finishAfterTurn(
|
|
18719
|
-
withProcessCancelSkipAutoResume(
|
|
18720
|
-
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
18721
|
-
env.signal
|
|
18722
|
-
)
|
|
18447
|
+
env,
|
|
18448
|
+
`run-state persistence failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
18449
|
+
io
|
|
18723
18450
|
);
|
|
18724
18451
|
}
|
|
18725
18452
|
}
|
|
@@ -18800,25 +18527,11 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18800
18527
|
try {
|
|
18801
18528
|
await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
|
|
18802
18529
|
} catch (error) {
|
|
18803
|
-
|
|
18530
|
+
await recordBestEffortPostDispatchDiagnostic(
|
|
18804
18531
|
admitted,
|
|
18805
|
-
|
|
18806
|
-
|
|
18807
|
-
|
|
18808
|
-
stderr: "",
|
|
18809
|
-
thrown: error,
|
|
18810
|
-
skipRunStateWrite: true
|
|
18811
|
-
}, request.invocationScopeId),
|
|
18812
|
-
adapters,
|
|
18813
|
-
env.principalAuthority,
|
|
18814
|
-
io,
|
|
18815
|
-
persistRunState
|
|
18816
|
-
);
|
|
18817
|
-
return await finishAfterTurn(
|
|
18818
|
-
withProcessCancelSkipAutoResume(
|
|
18819
|
-
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
18820
|
-
env.signal
|
|
18821
|
-
)
|
|
18532
|
+
env,
|
|
18533
|
+
`run-state persistence failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
18534
|
+
io
|
|
18822
18535
|
);
|
|
18823
18536
|
}
|
|
18824
18537
|
}
|
|
@@ -18830,14 +18543,16 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18830
18543
|
...deferredPersist
|
|
18831
18544
|
});
|
|
18832
18545
|
} finally {
|
|
18833
|
-
|
|
18834
|
-
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18839
|
-
|
|
18840
|
-
|
|
18546
|
+
if (lease !== void 0) {
|
|
18547
|
+
try {
|
|
18548
|
+
await lease.release();
|
|
18549
|
+
} catch (error) {
|
|
18550
|
+
io.stderr(
|
|
18551
|
+
formatCliDiagnostic(
|
|
18552
|
+
`writer lease release failed unexpectedly (best-effort continue): ${describeErrorIdentity(error)}`
|
|
18553
|
+
)
|
|
18554
|
+
);
|
|
18555
|
+
}
|
|
18841
18556
|
}
|
|
18842
18557
|
}
|
|
18843
18558
|
}
|
|
@@ -19152,53 +18867,29 @@ async function runPostAdmissionManualResume(input) {
|
|
|
19152
18867
|
} = input;
|
|
19153
18868
|
let request = input.request;
|
|
19154
18869
|
const effectiveModel = env.model;
|
|
19155
|
-
let lease;
|
|
19156
|
-
let staleWriterLeaseReclaimed;
|
|
19157
|
-
try {
|
|
19158
|
-
lease = await acquireRunWriterLease(admitted.runDirectory, (diagnostic, kind) => {
|
|
19159
|
-
if (kind === "stale-reclaimed") staleWriterLeaseReclaimed = true;
|
|
19160
|
-
io.stderr(diagnostic);
|
|
19161
|
-
});
|
|
19162
|
-
} catch (error) {
|
|
19163
|
-
if (error instanceof RunWriterLeaseHeldError) {
|
|
19164
|
-
io.stderr(formatCliDiagnostic(error.message));
|
|
19165
|
-
return {
|
|
19166
|
-
exitCode: 1,
|
|
19167
|
-
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
19168
|
-
};
|
|
19169
|
-
}
|
|
19170
|
-
throw error;
|
|
19171
|
-
}
|
|
19172
18870
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
19173
18871
|
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19174
18872
|
});
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
|
|
19181
|
-
|
|
19182
|
-
|
|
19183
|
-
|
|
19184
|
-
|
|
19185
|
-
|
|
19186
|
-
|
|
19187
|
-
|
|
18873
|
+
if (request === void 0) {
|
|
18874
|
+
if (buildRequestAfterLease === void 0) {
|
|
18875
|
+
throw new Error(
|
|
18876
|
+
"runPostAdmissionManualResume requires request or buildRequestAfterLease"
|
|
18877
|
+
);
|
|
18878
|
+
}
|
|
18879
|
+
request = await buildRequestAfterLease();
|
|
18880
|
+
}
|
|
18881
|
+
request = withEngineDetourInvocationScope(request, invocationScopeId);
|
|
18882
|
+
const result = await dispatchPostAdmissionTurn({
|
|
18883
|
+
admitted,
|
|
18884
|
+
env: {
|
|
18885
|
+
...env,
|
|
18886
|
+
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
18887
|
+
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
19188
18888
|
},
|
|
19189
|
-
|
|
19190
|
-
|
|
19191
|
-
|
|
19192
|
-
|
|
19193
|
-
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
19194
|
-
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
19195
|
-
},
|
|
19196
|
-
io,
|
|
19197
|
-
request: turnRequest,
|
|
19198
|
-
lease,
|
|
19199
|
-
adapters,
|
|
19200
|
-
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19201
|
-
})
|
|
18889
|
+
io,
|
|
18890
|
+
request,
|
|
18891
|
+
adapters,
|
|
18892
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19202
18893
|
});
|
|
19203
18894
|
if (result.terminal !== void 0 && isLawfulTypedTerminalOutcome(result.terminal.roleOutcome)) {
|
|
19204
18895
|
io.stdout(formatTerminalResult(result.terminal));
|
|
@@ -19206,10 +18897,7 @@ async function runPostAdmissionManualResume(input) {
|
|
|
19206
18897
|
if (result.terminal !== void 0) {
|
|
19207
18898
|
result.terminal.autoResumeCount = 0;
|
|
19208
18899
|
}
|
|
19209
|
-
return
|
|
19210
|
-
...result,
|
|
19211
|
-
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
19212
|
-
};
|
|
18900
|
+
return result;
|
|
19213
18901
|
}
|
|
19214
18902
|
var StationChildExhaustedError, POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE;
|
|
19215
18903
|
var init_post_admission = __esm({
|
|
@@ -19222,11 +18910,11 @@ var init_post_admission = __esm({
|
|
|
19222
18910
|
init_activation_ledger_topology();
|
|
19223
18911
|
init_engine_material();
|
|
19224
18912
|
init_session_identity();
|
|
18913
|
+
init_role_run_relocation();
|
|
19225
18914
|
init_host_contracts();
|
|
19226
18915
|
init_case_dossier_delivery();
|
|
19227
18916
|
init_engine_detour_usage();
|
|
19228
18917
|
init_host_transition_prior_native();
|
|
19229
|
-
init_public_run_credentials();
|
|
19230
18918
|
init_run_lifecycle();
|
|
19231
18919
|
init_process_cancel();
|
|
19232
18920
|
init_activation_ledger_topology();
|
|
@@ -21116,7 +20804,7 @@ __export(public_role_summons_exports, {
|
|
|
21116
20804
|
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
21117
20805
|
});
|
|
21118
20806
|
import { execFile as execFile3 } from "node:child_process";
|
|
21119
|
-
import { existsSync as
|
|
20807
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
21120
20808
|
import { mkdir as mkdir4, mkdtemp as mkdtemp4, realpath as realpath7, rm as rm5 } from "node:fs/promises";
|
|
21121
20809
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
21122
20810
|
import { join as join33, relative as relative3, sep as sep5 } from "node:path";
|
|
@@ -21143,7 +20831,7 @@ function parentDir(path) {
|
|
|
21143
20831
|
function walkPackageRoot(start) {
|
|
21144
20832
|
let dir = start;
|
|
21145
20833
|
for (let i = 0; i < 12; i += 1) {
|
|
21146
|
-
if (
|
|
20834
|
+
if (existsSync9(join33(dir, "package.json")) && existsSync9(join33(dir, "souls"))) {
|
|
21147
20835
|
return dir;
|
|
21148
20836
|
}
|
|
21149
20837
|
const parent = parentDir(dir);
|
|
@@ -22052,7 +21740,7 @@ __export(archivist_record_entry_exports, {
|
|
|
22052
21740
|
});
|
|
22053
21741
|
import {
|
|
22054
21742
|
closeSync,
|
|
22055
|
-
existsSync as
|
|
21743
|
+
existsSync as existsSync10,
|
|
22056
21744
|
mkdirSync as mkdirSync2,
|
|
22057
21745
|
openSync,
|
|
22058
21746
|
readdirSync as readdirSync2,
|
|
@@ -22215,7 +21903,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
22215
21903
|
}
|
|
22216
21904
|
function resolveNavigatorNestContinuation(sessionDir, cwd) {
|
|
22217
21905
|
const ledgerPath = currentSessionLedgerPath(sessionDir);
|
|
22218
|
-
if (
|
|
21906
|
+
if (existsSync10(ledgerPath)) {
|
|
22219
21907
|
const recentFile = readCurrentSession(sessionDir);
|
|
22220
21908
|
assertRecentFinalFileUnderSessionDir(sessionDir, recentFile);
|
|
22221
21909
|
return recentFile;
|
|
@@ -22300,7 +21988,7 @@ function createRecordSessionOpen(options) {
|
|
|
22300
21988
|
parentSession = parentFile;
|
|
22301
21989
|
mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
22302
21990
|
}
|
|
22303
|
-
const nestAlreadyExists =
|
|
21991
|
+
const nestAlreadyExists = existsSync10(sessionDir);
|
|
22304
21992
|
ensureRealDirectoryTree(ledgerHome, sessionDir);
|
|
22305
21993
|
if (mayResumeSameNest && nestAlreadyExists) {
|
|
22306
21994
|
if (options.kind === NAVIGATOR_RECORD_KIND) {
|
|
@@ -22327,7 +22015,7 @@ function createRecordSessionOpen(options) {
|
|
|
22327
22015
|
);
|
|
22328
22016
|
if (session.isPersisted()) {
|
|
22329
22017
|
const file = session.getSessionFile();
|
|
22330
|
-
if (file !== void 0 && !
|
|
22018
|
+
if (file !== void 0 && !existsSync10(file)) {
|
|
22331
22019
|
const header = session.getHeader();
|
|
22332
22020
|
if (header !== null && header.type === "session") {
|
|
22333
22021
|
writeFileSync2(file, `${JSON.stringify(header)}
|
|
@@ -22381,7 +22069,7 @@ var init_archivist_record_entry = __esm({
|
|
|
22381
22069
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
22382
22070
|
|
|
22383
22071
|
// src/role-runtime-dependencies.ts
|
|
22384
|
-
import { readFile as
|
|
22072
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
22385
22073
|
import { join as join40 } from "node:path";
|
|
22386
22074
|
|
|
22387
22075
|
// src/canonical-skill-binding.ts
|
|
@@ -23418,7 +23106,7 @@ ${helpContext}
|
|
|
23418
23106
|
// src/navigator-work-context.ts
|
|
23419
23107
|
init_doctor_evidence();
|
|
23420
23108
|
init_host_contracts();
|
|
23421
|
-
import { readFile as
|
|
23109
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
23422
23110
|
import { resolve as resolve17 } from "node:path";
|
|
23423
23111
|
init_notary_source_run();
|
|
23424
23112
|
init_packaged_role_registry();
|
|
@@ -23431,7 +23119,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
23431
23119
|
}
|
|
23432
23120
|
async function loadNavigatorWorkContext(options) {
|
|
23433
23121
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
23434
|
-
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");
|
|
23435
23123
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
23436
23124
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
23437
23125
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -23488,7 +23176,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
23488
23176
|
let authorityMaterial;
|
|
23489
23177
|
for (const path of authorityFiles) {
|
|
23490
23178
|
try {
|
|
23491
|
-
const content = await
|
|
23179
|
+
const content = await readFile20(path, "utf8");
|
|
23492
23180
|
if (content.trim() !== "") {
|
|
23493
23181
|
authorityMaterial = content;
|
|
23494
23182
|
break;
|
|
@@ -23980,18 +23668,18 @@ init_collector_evidence();
|
|
|
23980
23668
|
init_collector_github();
|
|
23981
23669
|
|
|
23982
23670
|
// src/collector-handbook.ts
|
|
23983
|
-
import { readFile as
|
|
23671
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
23984
23672
|
import { join as join38, sep as sep6 } from "node:path";
|
|
23985
23673
|
|
|
23986
23674
|
// src/atomic-write.ts
|
|
23987
23675
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
23988
|
-
import { rename as rename3, rm as rm6, writeFile as
|
|
23676
|
+
import { rename as rename3, rm as rm6, writeFile as writeFile10 } from "node:fs/promises";
|
|
23989
23677
|
import { dirname as dirname21, join as join37 } from "node:path";
|
|
23990
23678
|
async function writeFileAtomically(destination, contents) {
|
|
23991
23679
|
const parent = dirname21(destination);
|
|
23992
23680
|
const temporary = join37(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
23993
23681
|
try {
|
|
23994
|
-
await
|
|
23682
|
+
await writeFile10(temporary, contents);
|
|
23995
23683
|
await rename3(temporary, destination);
|
|
23996
23684
|
} catch (error) {
|
|
23997
23685
|
await rm6(temporary, { force: true }).catch(() => void 0);
|
|
@@ -24143,7 +23831,7 @@ function createCollectorHandbookStore(input) {
|
|
|
24143
23831
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
24144
23832
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
24145
23833
|
try {
|
|
24146
|
-
const body = await
|
|
23834
|
+
const body = await readFile21(path, "utf8");
|
|
24147
23835
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
24148
23836
|
return body;
|
|
24149
23837
|
} catch (error) {
|
|
@@ -25492,7 +25180,7 @@ init_sitian_facade();
|
|
|
25492
25180
|
init_submission_errors();
|
|
25493
25181
|
init_submission_errors();
|
|
25494
25182
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
25495
|
-
import { existsSync as
|
|
25183
|
+
import { existsSync as existsSync11, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
25496
25184
|
import { resolve as resolve19 } from "node:path";
|
|
25497
25185
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
25498
25186
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
@@ -25523,7 +25211,7 @@ function statusOf(error) {
|
|
|
25523
25211
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
25524
25212
|
}
|
|
25525
25213
|
function tryGetAll(file, key) {
|
|
25526
|
-
if (!
|
|
25214
|
+
if (!existsSync11(file)) return [];
|
|
25527
25215
|
try {
|
|
25528
25216
|
const out = gitFile(file, ["--get-all", key]);
|
|
25529
25217
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -25533,7 +25221,7 @@ function tryGetAll(file, key) {
|
|
|
25533
25221
|
}
|
|
25534
25222
|
}
|
|
25535
25223
|
function ownedHook(path) {
|
|
25536
|
-
if (!
|
|
25224
|
+
if (!existsSync11(path)) return false;
|
|
25537
25225
|
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
25538
25226
|
}
|
|
25539
25227
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -25560,11 +25248,11 @@ function rmOwnedDir(dir) {
|
|
|
25560
25248
|
const hookPath = resolve19(dir, HOOK_FILE);
|
|
25561
25249
|
if (!ownedHook(hookPath)) return;
|
|
25562
25250
|
rmSync(hookPath, { force: true });
|
|
25563
|
-
if (
|
|
25251
|
+
if (existsSync11(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
25564
25252
|
}
|
|
25565
25253
|
function linkedGitDirs(commonDir) {
|
|
25566
25254
|
const root = resolve19(commonDir, "worktrees");
|
|
25567
|
-
if (!
|
|
25255
|
+
if (!existsSync11(root)) return [];
|
|
25568
25256
|
return readdirSync3(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
25569
25257
|
}
|
|
25570
25258
|
function uninstallPackageWorkerHooks(cwd) {
|
|
@@ -27764,12 +27452,12 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27764
27452
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
27765
27453
|
loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
|
|
27766
27454
|
loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
|
|
27767
|
-
loadFixPacket: (path) =>
|
|
27455
|
+
loadFixPacket: (path) => readFile22(path, "utf8"),
|
|
27768
27456
|
loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
|
|
27769
|
-
loadCoderTask: (path) =>
|
|
27457
|
+
loadCoderTask: (path) => readFile22(path, "utf8"),
|
|
27770
27458
|
loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
|
|
27771
27459
|
loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
|
|
27772
|
-
loadCollectorHandbookSeed: () =>
|
|
27460
|
+
loadCollectorHandbookSeed: () => readFile22(collectorHandbookSeedPath, "utf8"),
|
|
27773
27461
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
27774
27462
|
loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
|
|
27775
27463
|
loadDoctorCase,
|
|
@@ -27784,7 +27472,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27784
27472
|
loadSecretariatSoul: () => loadMainRoleSessionMaterials("secretariat"),
|
|
27785
27473
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
27786
27474
|
loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
|
|
27787
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
27475
|
+
loadMergerInput: async (path) => JSON.parse(await readFile22(path, "utf8")),
|
|
27788
27476
|
async loadCanonicalSkillBinding(name) {
|
|
27789
27477
|
if (name === "tdd") {
|
|
27790
27478
|
return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
|
|
@@ -27810,7 +27498,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27810
27498
|
authority: options.authority,
|
|
27811
27499
|
invocationId: options.invocationId,
|
|
27812
27500
|
loadSoul: () => loadMainRoleSessionMaterials("navigator"),
|
|
27813
|
-
loadRoutePlaybook: () =>
|
|
27501
|
+
loadRoutePlaybook: () => readFile22(navigatorRoutePlaybookPath, "utf8"),
|
|
27814
27502
|
loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
|
|
27815
27503
|
createSession: navigatorSessionFactory,
|
|
27816
27504
|
...options.contextError === void 0 ? {} : { contextError: options.contextError },
|
|
@@ -27822,7 +27510,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27822
27510
|
// src/role-envelope.ts
|
|
27823
27511
|
init_engine_detour();
|
|
27824
27512
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
27825
|
-
import { appendFile as appendFile3, mkdir as mkdir6, writeFile as
|
|
27513
|
+
import { appendFile as appendFile3, mkdir as mkdir6, writeFile as writeFile11 } from "node:fs/promises";
|
|
27826
27514
|
import { createServer } from "node:net";
|
|
27827
27515
|
import { dirname as dirname23, join as join42 } from "node:path";
|
|
27828
27516
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -27920,7 +27608,7 @@ async function requireGatekeeperPass(options) {
|
|
|
27920
27608
|
}
|
|
27921
27609
|
|
|
27922
27610
|
// src/host-native-method.ts
|
|
27923
|
-
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";
|
|
27924
27612
|
import { basename as basename10, dirname as dirname22, join as join41 } from "node:path";
|
|
27925
27613
|
var HOST_METHOD_PLUGIN_NAME = "ak-methods";
|
|
27926
27614
|
var packagedMethodsDir = (root) => join41(root, "resources", "methods");
|
|
@@ -27952,16 +27640,16 @@ function applyCodexSkillInvocation(methods, prompt) {
|
|
|
27952
27640
|
prompt
|
|
27953
27641
|
);
|
|
27954
27642
|
}
|
|
27955
|
-
var
|
|
27643
|
+
var isEnoent3 = (error) => error.code === "ENOENT";
|
|
27956
27644
|
async function packagedMethodSkillNames(packagedMethodsRealpath) {
|
|
27957
|
-
const entries = await
|
|
27645
|
+
const entries = await readdir8(packagedMethodsRealpath, { withFileTypes: true });
|
|
27958
27646
|
const names = [];
|
|
27959
27647
|
for (const entry of entries) {
|
|
27960
27648
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
27961
27649
|
try {
|
|
27962
27650
|
await access4(join41(packagedMethodsRealpath, entry.name, "SKILL.md"));
|
|
27963
27651
|
} catch (error) {
|
|
27964
|
-
if (
|
|
27652
|
+
if (isEnoent3(error)) continue;
|
|
27965
27653
|
throw error;
|
|
27966
27654
|
}
|
|
27967
27655
|
names.push(entry.name);
|
|
@@ -27972,12 +27660,12 @@ async function packagedSkillFileBytes(skillDir) {
|
|
|
27972
27660
|
try {
|
|
27973
27661
|
await access4(join41(skillDir, "SKILL.md"));
|
|
27974
27662
|
} catch (error) {
|
|
27975
|
-
if (
|
|
27663
|
+
if (isEnoent3(error)) return void 0;
|
|
27976
27664
|
throw error;
|
|
27977
27665
|
}
|
|
27978
27666
|
const files = /* @__PURE__ */ new Map();
|
|
27979
27667
|
async function walk(dir, prefix) {
|
|
27980
|
-
const entries = await
|
|
27668
|
+
const entries = await readdir8(dir, { withFileTypes: true });
|
|
27981
27669
|
for (const entry of entries) {
|
|
27982
27670
|
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
27983
27671
|
const full = join41(dir, entry.name);
|
|
@@ -27986,7 +27674,7 @@ async function packagedSkillFileBytes(skillDir) {
|
|
|
27986
27674
|
continue;
|
|
27987
27675
|
}
|
|
27988
27676
|
if (entry.isFile()) {
|
|
27989
|
-
files.set(rel, await
|
|
27677
|
+
files.set(rel, await readFile23(full));
|
|
27990
27678
|
}
|
|
27991
27679
|
}
|
|
27992
27680
|
}
|
|
@@ -27997,9 +27685,9 @@ async function catalogPublishesPackagedSkill(catalogSkillDir, required) {
|
|
|
27997
27685
|
for (const [rel, bytes] of required) {
|
|
27998
27686
|
let other;
|
|
27999
27687
|
try {
|
|
28000
|
-
other = await
|
|
27688
|
+
other = await readFile23(join41(catalogSkillDir, rel));
|
|
28001
27689
|
} catch (error) {
|
|
28002
|
-
if (
|
|
27690
|
+
if (isEnoent3(error)) return false;
|
|
28003
27691
|
throw error;
|
|
28004
27692
|
}
|
|
28005
27693
|
if (!bytes.equals(other)) return false;
|
|
@@ -28013,7 +27701,7 @@ async function isCompatibleMethodCatalog(link, packagedMethodsRealpath) {
|
|
|
28013
27701
|
try {
|
|
28014
27702
|
resolved = await realpath8(link);
|
|
28015
27703
|
} catch (error) {
|
|
28016
|
-
if (
|
|
27704
|
+
if (isEnoent3(error)) return false;
|
|
28017
27705
|
throw error;
|
|
28018
27706
|
}
|
|
28019
27707
|
if (resolved === packagedMethodsRealpath) return true;
|
|
@@ -28034,7 +27722,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
28034
27722
|
await lstat7(link);
|
|
28035
27723
|
present = true;
|
|
28036
27724
|
} catch (error) {
|
|
28037
|
-
if (!
|
|
27725
|
+
if (!isEnoent3(error)) throw error;
|
|
28038
27726
|
present = false;
|
|
28039
27727
|
}
|
|
28040
27728
|
if (present) {
|
|
@@ -28103,7 +27791,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
28103
27791
|
await mkdir6(dirname23(sessionFile), { recursive: true });
|
|
28104
27792
|
if (request.continuation.kind !== "resume") {
|
|
28105
27793
|
try {
|
|
28106
|
-
await
|
|
27794
|
+
await writeFile11(
|
|
28107
27795
|
sessionFile,
|
|
28108
27796
|
`${JSON.stringify({
|
|
28109
27797
|
type: "session",
|
|
@@ -28911,8 +28599,8 @@ function headlessMcpConfigDocument(mcpServers) {
|
|
|
28911
28599
|
// src/headless-host/role-turn-host.ts
|
|
28912
28600
|
import { spawn as spawn4, spawnSync } from "node:child_process";
|
|
28913
28601
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
28914
|
-
import { existsSync as
|
|
28915
|
-
import { writeFile as
|
|
28602
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
28603
|
+
import { writeFile as writeFile12 } from "node:fs/promises";
|
|
28916
28604
|
import { dirname as dirname24, isAbsolute as isAbsolute10, join as join44, resolve as resolve20 } from "node:path";
|
|
28917
28605
|
|
|
28918
28606
|
// src/external-host-turn-loop.ts
|
|
@@ -29133,7 +28821,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
29133
28821
|
function cwdIsGitWorkTree(cwd) {
|
|
29134
28822
|
let dir = cwd;
|
|
29135
28823
|
for (; ; ) {
|
|
29136
|
-
if (
|
|
28824
|
+
if (existsSync12(join44(dir, ".git"))) return true;
|
|
29137
28825
|
const parent = dirname24(dir);
|
|
29138
28826
|
if (parent === dir) return false;
|
|
29139
28827
|
dir = parent;
|
|
@@ -29342,7 +29030,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29342
29030
|
}
|
|
29343
29031
|
const env = { ...process.env, ...config.env ?? {} };
|
|
29344
29032
|
const systemPromptPath = join44(request.runDirectory, "headless-system-prompt.txt");
|
|
29345
|
-
await
|
|
29033
|
+
await writeFile12(systemPromptPath, systemPrompt, "utf8");
|
|
29346
29034
|
let mcpConfigPath;
|
|
29347
29035
|
let outputSchemaPath;
|
|
29348
29036
|
let pluginDir;
|
|
@@ -29350,7 +29038,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29350
29038
|
if (codex) {
|
|
29351
29039
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
29352
29040
|
outputSchemaPath = join44(request.runDirectory, "headless-output-schema.json");
|
|
29353
|
-
await
|
|
29041
|
+
await writeFile12(
|
|
29354
29042
|
outputSchemaPath,
|
|
29355
29043
|
`${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
|
|
29356
29044
|
`,
|
|
@@ -29359,7 +29047,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29359
29047
|
}
|
|
29360
29048
|
} else {
|
|
29361
29049
|
mcpConfigPath = join44(request.runDirectory, "headless-mcp-config.json");
|
|
29362
|
-
await
|
|
29050
|
+
await writeFile12(
|
|
29363
29051
|
mcpConfigPath,
|
|
29364
29052
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
29365
29053
|
`,
|