@akagilnc/pi-workflow-roles 0.1.4759 → 0.1.4774
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +227 -428
- package/dist/headless-host/production-host.js +233 -434
- package/dist/migrate-book-topology.js +1255 -1087
- package/dist/notary-source-run.js +12 -2
- package/dist/public-cli/invocation.js +11 -8
- package/dist/public-cli/main.js +198 -399
- package/dist/public-cli/post-admission.js +27 -1
- package/dist/public-cli/run-lifecycle.js +25 -4
- package/dist/role-run-relocation.js +19 -18
- package/package.json +1 -1
- package/src/book-topology-migration-placement.ts +9 -1
- package/src/book-topology-runs-migrator.ts +156 -4
- package/src/notary-source-run.ts +18 -2
- package/src/public-cli/invocation.ts +13 -9
- package/src/public-cli/post-admission.ts +36 -0
- package/src/public-cli/run-lifecycle.ts +42 -4
- package/src/role-run-relocation.ts +27 -30
package/dist/public-cli/main.js
CHANGED
|
@@ -17221,12 +17221,7 @@ var init_compliance_transport = __esm({
|
|
|
17221
17221
|
});
|
|
17222
17222
|
|
|
17223
17223
|
// src/role-run-relocation.ts
|
|
17224
|
-
import { existsSync as existsSync5 } from "node:fs";
|
|
17225
|
-
import { readdir as readdir3, readFile as readFile6, writeFile as writeFile2 } from "node:fs/promises";
|
|
17226
17224
|
import { join as join12, sep as sep2 } from "node:path";
|
|
17227
|
-
function isEnoent2(error) {
|
|
17228
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
17229
|
-
}
|
|
17230
17225
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
17231
17226
|
if (typeof value !== "string") return value;
|
|
17232
17227
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -17268,23 +17263,6 @@ function rewriteRunDirectoryPathFieldsAgainstRewrites(record4, fields, rewrites)
|
|
|
17268
17263
|
}
|
|
17269
17264
|
}
|
|
17270
17265
|
}
|
|
17271
|
-
function collectRewrites(input) {
|
|
17272
|
-
const own = {
|
|
17273
|
-
oldRunDirectory: input.oldRunDirectory,
|
|
17274
|
-
newRunDirectory: input.newRunDirectory
|
|
17275
|
-
};
|
|
17276
|
-
if (input.crossRunRewrites === void 0 || input.crossRunRewrites.length === 0) {
|
|
17277
|
-
return [own];
|
|
17278
|
-
}
|
|
17279
|
-
const seen = /* @__PURE__ */ new Set([own.oldRunDirectory]);
|
|
17280
|
-
const out = [own];
|
|
17281
|
-
for (const rewrite of input.crossRunRewrites) {
|
|
17282
|
-
if (seen.has(rewrite.oldRunDirectory)) continue;
|
|
17283
|
-
seen.add(rewrite.oldRunDirectory);
|
|
17284
|
-
out.push(rewrite);
|
|
17285
|
-
}
|
|
17286
|
-
return out;
|
|
17287
|
-
}
|
|
17288
17266
|
function isPlainObject(value) {
|
|
17289
17267
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
17290
17268
|
}
|
|
@@ -17296,254 +17274,25 @@ function rewriteSourceRunLocator(value, rewrites) {
|
|
|
17296
17274
|
rewrites
|
|
17297
17275
|
);
|
|
17298
17276
|
}
|
|
17299
|
-
function
|
|
17300
|
-
|
|
17301
|
-
|
|
17302
|
-
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
-
|
|
17306
|
-
rewriteSourceRunLocator(value.sourceRun, rewrites);
|
|
17307
|
-
if (Array.isArray(value.attachmentPaths)) {
|
|
17308
|
-
value.attachmentPaths = value.attachmentPaths.map(
|
|
17309
|
-
(path) => rewriteRunDirectoryPathValueAgainstRewrites(path, rewrites)
|
|
17310
|
-
);
|
|
17311
|
-
}
|
|
17312
|
-
}
|
|
17313
|
-
async function rewriteJsonObjectFile(path, fields, rewrites) {
|
|
17314
|
-
if (!existsSync5(path)) return;
|
|
17315
|
-
const page = JSON.parse(await readFile6(path, "utf8"));
|
|
17316
|
-
if (!isPlainObject(page)) return;
|
|
17317
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(page, fields, rewrites);
|
|
17318
|
-
await writeFile2(path, `${JSON.stringify(page, null, 2)}
|
|
17319
|
-
`, "utf8");
|
|
17320
|
-
}
|
|
17321
|
-
async function rewriteOfficerPointerFile(path, rewrites) {
|
|
17322
|
-
if (!existsSync5(path)) return;
|
|
17323
|
-
const page = JSON.parse(await readFile6(path, "utf8"));
|
|
17324
|
-
if (!isPlainObject(page)) return;
|
|
17325
|
-
if (page.kind !== "direct-officer-run-pointer") return;
|
|
17326
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17327
|
-
page,
|
|
17328
|
-
OFFICER_POINTER_FIELDS,
|
|
17329
|
-
rewrites
|
|
17330
|
-
);
|
|
17331
|
-
await writeFile2(path, `${JSON.stringify(page)}
|
|
17332
|
-
`, "utf8");
|
|
17333
|
-
}
|
|
17334
|
-
async function rewriteSitianRecordsJsonl(path, rewrites) {
|
|
17335
|
-
if (!existsSync5(path)) return;
|
|
17336
|
-
const raw = await readFile6(path, "utf8");
|
|
17337
|
-
if (raw.length === 0) return;
|
|
17338
|
-
const endsWithNewline = raw.endsWith("\n");
|
|
17339
|
-
const lines = raw.split("\n");
|
|
17340
|
-
let changed = false;
|
|
17341
|
-
const out = [];
|
|
17342
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
17343
|
-
const line2 = lines[i];
|
|
17344
|
-
if (line2 === "" && i === lines.length - 1 && endsWithNewline) {
|
|
17345
|
-
out.push("");
|
|
17346
|
-
continue;
|
|
17347
|
-
}
|
|
17348
|
-
if (line2.trim() === "") {
|
|
17349
|
-
out.push(line2);
|
|
17350
|
-
continue;
|
|
17351
|
-
}
|
|
17352
|
-
let parsed;
|
|
17353
|
-
try {
|
|
17354
|
-
parsed = JSON.parse(line2);
|
|
17355
|
-
} catch {
|
|
17356
|
-
out.push(line2);
|
|
17357
|
-
continue;
|
|
17358
|
-
}
|
|
17359
|
-
if (!isPlainObject(parsed)) {
|
|
17360
|
-
out.push(line2);
|
|
17361
|
-
continue;
|
|
17362
|
-
}
|
|
17363
|
-
if (!("sessionParent" in parsed)) {
|
|
17364
|
-
out.push(line2);
|
|
17365
|
-
continue;
|
|
17366
|
-
}
|
|
17367
|
-
const before = parsed.sessionParent;
|
|
17368
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17369
|
-
parsed,
|
|
17370
|
-
SITIAN_RECORD_FIELDS,
|
|
17371
|
-
rewrites
|
|
17372
|
-
);
|
|
17373
|
-
if (parsed.sessionParent !== before) changed = true;
|
|
17374
|
-
out.push(JSON.stringify(parsed));
|
|
17375
|
-
}
|
|
17376
|
-
if (!changed) return;
|
|
17377
|
-
const body = out.join("\n");
|
|
17378
|
-
await writeFile2(
|
|
17379
|
-
path,
|
|
17380
|
-
endsWithNewline && !body.endsWith("\n") ? `${body}
|
|
17381
|
-
` : body,
|
|
17382
|
-
"utf8"
|
|
17383
|
-
);
|
|
17384
|
-
}
|
|
17385
|
-
async function rewriteSessionTranscriptBindings(path, rewrites) {
|
|
17386
|
-
if (!existsSync5(path)) return;
|
|
17387
|
-
const raw = await readFile6(path, "utf8");
|
|
17388
|
-
if (raw.length === 0) return;
|
|
17389
|
-
const endsWithNewline = raw.endsWith("\n");
|
|
17390
|
-
const lines = raw.split("\n");
|
|
17391
|
-
let changed = false;
|
|
17392
|
-
const out = [];
|
|
17393
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
17394
|
-
const line2 = lines[i];
|
|
17395
|
-
if (line2 === "" && i === lines.length - 1 && endsWithNewline) {
|
|
17396
|
-
out.push("");
|
|
17397
|
-
continue;
|
|
17398
|
-
}
|
|
17399
|
-
if (line2.trim() === "") {
|
|
17400
|
-
out.push(line2);
|
|
17401
|
-
continue;
|
|
17402
|
-
}
|
|
17403
|
-
let parsed;
|
|
17404
|
-
try {
|
|
17405
|
-
parsed = JSON.parse(line2);
|
|
17406
|
-
} catch {
|
|
17407
|
-
out.push(line2);
|
|
17408
|
-
continue;
|
|
17409
|
-
}
|
|
17410
|
-
if (!isPlainObject(parsed)) {
|
|
17411
|
-
out.push(line2);
|
|
17412
|
-
continue;
|
|
17413
|
-
}
|
|
17414
|
-
let lineChanged = false;
|
|
17415
|
-
if (parsed.type === "session" && "parentSession" in parsed) {
|
|
17416
|
-
const before = parsed.parentSession;
|
|
17417
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17418
|
-
parsed,
|
|
17419
|
-
SESSION_HEADER_FIELDS,
|
|
17420
|
-
rewrites
|
|
17421
|
-
);
|
|
17422
|
-
if (parsed.parentSession !== before) lineChanged = true;
|
|
17423
|
-
} else if (parsed.type === "custom" && parsed.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE && isPlainObject(parsed.data) && isPlainObject(parsed.data.parent)) {
|
|
17424
|
-
const parent = parsed.data.parent;
|
|
17425
|
-
const before = parent.sessionFile;
|
|
17426
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17427
|
-
parent,
|
|
17428
|
-
BINDING_PARENT_FIELDS,
|
|
17429
|
-
rewrites
|
|
17430
|
-
);
|
|
17431
|
-
if (parent.sessionFile !== before) lineChanged = true;
|
|
17432
|
-
}
|
|
17433
|
-
if (lineChanged) changed = true;
|
|
17434
|
-
out.push(lineChanged ? JSON.stringify(parsed) : line2);
|
|
17435
|
-
}
|
|
17436
|
-
if (!changed) return;
|
|
17437
|
-
const body = out.join("\n");
|
|
17438
|
-
await writeFile2(
|
|
17439
|
-
path,
|
|
17440
|
-
endsWithNewline && !body.endsWith("\n") ? `${body}
|
|
17441
|
-
` : body,
|
|
17442
|
-
"utf8"
|
|
17443
|
-
);
|
|
17444
|
-
}
|
|
17445
|
-
async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
17446
|
-
const sessionRoot = join12(pagesDirectory, "session");
|
|
17447
|
-
async function walk(directory) {
|
|
17448
|
-
let entries;
|
|
17449
|
-
try {
|
|
17450
|
-
entries = await readdir3(directory, { withFileTypes: true });
|
|
17451
|
-
} catch (error) {
|
|
17452
|
-
if (isEnoent2(error)) return;
|
|
17453
|
-
throw error;
|
|
17454
|
-
}
|
|
17455
|
-
for (const entry of entries) {
|
|
17456
|
-
const path = join12(directory, entry.name);
|
|
17457
|
-
if (entry.isDirectory()) {
|
|
17458
|
-
await walk(path);
|
|
17459
|
-
continue;
|
|
17277
|
+
function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
17278
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
|
|
17279
|
+
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
17280
|
+
if (Array.isArray(page.attachments)) {
|
|
17281
|
+
for (const attachment of page.attachments) {
|
|
17282
|
+
if (isPlainObject(attachment)) {
|
|
17283
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
|
|
17460
17284
|
}
|
|
17461
|
-
if (!entry.isFile()) continue;
|
|
17462
|
-
if (entry.name === "current-session.json") {
|
|
17463
|
-
await rewriteJsonObjectFile(path, CURRENT_SESSION_FIELDS, rewrites);
|
|
17464
|
-
} else if (entry.name.endsWith(".pointer.json")) {
|
|
17465
|
-
await rewriteOfficerPointerFile(path, rewrites);
|
|
17466
|
-
} else if (entry.name === "records.jsonl") {
|
|
17467
|
-
await rewriteSitianRecordsJsonl(path, rewrites);
|
|
17468
|
-
} else if (entry.name.endsWith(".jsonl")) {
|
|
17469
|
-
await rewriteSessionTranscriptBindings(path, rewrites);
|
|
17470
|
-
}
|
|
17471
|
-
}
|
|
17472
|
-
}
|
|
17473
|
-
await walk(sessionRoot);
|
|
17474
|
-
}
|
|
17475
|
-
async function rewriteRoleRunDurablePages(input) {
|
|
17476
|
-
const { pagesDirectory } = input;
|
|
17477
|
-
const rewrites = collectRewrites(input);
|
|
17478
|
-
const admittedPath = join12(pagesDirectory, "admitted-request.json");
|
|
17479
|
-
if (existsSync5(admittedPath)) {
|
|
17480
|
-
const page = JSON.parse(await readFile6(admittedPath, "utf8"));
|
|
17481
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17482
|
-
page,
|
|
17483
|
-
ADMITTED_PAGE_FIELDS,
|
|
17484
|
-
rewrites
|
|
17485
|
-
);
|
|
17486
|
-
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
17487
|
-
if (Array.isArray(page.attachments)) {
|
|
17488
|
-
for (const attachment of page.attachments) {
|
|
17489
|
-
if (isPlainObject(attachment)) {
|
|
17490
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17491
|
-
attachment,
|
|
17492
|
-
["frozenPath"],
|
|
17493
|
-
rewrites
|
|
17494
|
-
);
|
|
17495
|
-
}
|
|
17496
|
-
}
|
|
17497
|
-
}
|
|
17498
|
-
if (isPlainObject(page.principal)) {
|
|
17499
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17500
|
-
page.principal,
|
|
17501
|
-
["sessionDirectory", "sessionFile"],
|
|
17502
|
-
rewrites
|
|
17503
|
-
);
|
|
17504
17285
|
}
|
|
17505
|
-
await writeFile2(admittedPath, `${JSON.stringify(page, null, 2)}
|
|
17506
|
-
`, "utf8");
|
|
17507
17286
|
}
|
|
17508
|
-
|
|
17509
|
-
if (existsSync5(invocationPath)) {
|
|
17510
|
-
const page = JSON.parse(await readFile6(invocationPath, "utf8"));
|
|
17287
|
+
if (isPlainObject(page.principal)) {
|
|
17511
17288
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17512
|
-
page,
|
|
17513
|
-
|
|
17289
|
+
page.principal,
|
|
17290
|
+
["sessionDirectory", "sessionFile"],
|
|
17514
17291
|
rewrites
|
|
17515
17292
|
);
|
|
17516
|
-
await writeFile2(
|
|
17517
|
-
invocationPath,
|
|
17518
|
-
`${JSON.stringify(page, null, 2)}
|
|
17519
|
-
`,
|
|
17520
|
-
"utf8"
|
|
17521
|
-
);
|
|
17522
|
-
}
|
|
17523
|
-
const statePath = join12(pagesDirectory, "run-state.json");
|
|
17524
|
-
if (existsSync5(statePath)) {
|
|
17525
|
-
const page = JSON.parse(await readFile6(statePath, "utf8"));
|
|
17526
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17527
|
-
page,
|
|
17528
|
-
RUN_STATE_PAGE_FIELDS,
|
|
17529
|
-
rewrites
|
|
17530
|
-
);
|
|
17531
|
-
if (isPlainObject(page.principal)) {
|
|
17532
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17533
|
-
page.principal,
|
|
17534
|
-
["sessionDirectory", "sessionFile"],
|
|
17535
|
-
rewrites
|
|
17536
|
-
);
|
|
17537
|
-
}
|
|
17538
|
-
if (isPlainObject(page.currentCourt)) {
|
|
17539
|
-
rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
|
|
17540
|
-
}
|
|
17541
|
-
await writeFile2(statePath, `${JSON.stringify(page, null, 2)}
|
|
17542
|
-
`, "utf8");
|
|
17543
17293
|
}
|
|
17544
|
-
await rewriteNestedMachinePathPages(pagesDirectory, rewrites);
|
|
17545
17294
|
}
|
|
17546
|
-
var ADMITTED_PAGE_FIELDS,
|
|
17295
|
+
var ADMITTED_PAGE_FIELDS, SOURCE_RUN_LOCATOR_FIELDS;
|
|
17547
17296
|
var init_role_run_relocation = __esm({
|
|
17548
17297
|
"src/role-run-relocation.ts"() {
|
|
17549
17298
|
"use strict";
|
|
@@ -17560,24 +17309,7 @@ var init_role_run_relocation = __esm({
|
|
|
17560
17309
|
"mergerInputPath",
|
|
17561
17310
|
"sourceRunPath"
|
|
17562
17311
|
];
|
|
17563
|
-
INVOCATION_PAGE_FIELDS = [
|
|
17564
|
-
"runDirectory",
|
|
17565
|
-
"sessionDirectory",
|
|
17566
|
-
"sessionFile"
|
|
17567
|
-
];
|
|
17568
|
-
RUN_STATE_PAGE_FIELDS = [
|
|
17569
|
-
"runDirectory",
|
|
17570
|
-
"admittedRequestPath",
|
|
17571
|
-
"sessionDirectory",
|
|
17572
|
-
"sessionFile"
|
|
17573
|
-
];
|
|
17574
17312
|
SOURCE_RUN_LOCATOR_FIELDS = ["runDirectory"];
|
|
17575
|
-
SUMMONS_PATH_FIELDS = ["sourceRunPath"];
|
|
17576
|
-
CURRENT_SESSION_FIELDS = ["sessionFile"];
|
|
17577
|
-
OFFICER_POINTER_FIELDS = ["sessionFile", "runDirectory"];
|
|
17578
|
-
SITIAN_RECORD_FIELDS = ["sessionParent"];
|
|
17579
|
-
SESSION_HEADER_FIELDS = ["parentSession"];
|
|
17580
|
-
BINDING_PARENT_FIELDS = ["sessionFile"];
|
|
17581
17313
|
}
|
|
17582
17314
|
});
|
|
17583
17315
|
|
|
@@ -17686,7 +17418,7 @@ var init_terminating_tools = __esm({
|
|
|
17686
17418
|
});
|
|
17687
17419
|
|
|
17688
17420
|
// src/doctor-evidence.ts
|
|
17689
|
-
import { readdir as
|
|
17421
|
+
import { readdir as readdir3, readFile as readFile6, realpath as realpath2, stat } from "node:fs/promises";
|
|
17690
17422
|
import { dirname as dirname8, relative as relative2, resolve as resolve4, sep as sep3 } from "node:path";
|
|
17691
17423
|
function record2(value) {
|
|
17692
17424
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -17694,7 +17426,7 @@ function record2(value) {
|
|
|
17694
17426
|
async function discoverCaseFiles(root) {
|
|
17695
17427
|
const found = [];
|
|
17696
17428
|
async function walk(dir, depth) {
|
|
17697
|
-
for (const item of await
|
|
17429
|
+
for (const item of await readdir3(dir, { withFileTypes: true })) {
|
|
17698
17430
|
const path = resolve4(dir, item.name);
|
|
17699
17431
|
if (item.isDirectory()) {
|
|
17700
17432
|
await walk(path, depth + 1);
|
|
@@ -17802,7 +17534,7 @@ async function loadDoctorCase(runsPath) {
|
|
|
17802
17534
|
const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
|
|
17803
17535
|
for (const path of await discoverCaseFiles(root)) {
|
|
17804
17536
|
const id = relative2(root, path).split(sep3).join("/");
|
|
17805
|
-
const bytes = await
|
|
17537
|
+
const bytes = await readFile6(path);
|
|
17806
17538
|
const content = bytes.toString("utf8");
|
|
17807
17539
|
const kind = id.endsWith(".jsonl") ? "session" : "stderr";
|
|
17808
17540
|
evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
|
|
@@ -17815,7 +17547,7 @@ async function loadDoctorCase(runsPath) {
|
|
|
17815
17547
|
accumulate(calls, result.calls, id);
|
|
17816
17548
|
accumulate(tokens, result.tokens, id);
|
|
17817
17549
|
}
|
|
17818
|
-
const runDirs = (await
|
|
17550
|
+
const runDirs = (await readdir3(root, { withFileTypes: true })).filter((item) => item.isDirectory()).map((item) => item.name).sort();
|
|
17819
17551
|
const legs = evidence.filter((entry) => entry.kind === "session").map((entry) => entry.id);
|
|
17820
17552
|
const retryDirs = runDirs.filter((name) => /(?:^|[-_])retry(?:[-_]|$)/i.test(name));
|
|
17821
17553
|
const rawBytes = evidence.filter((entry) => entry.kind === "session").reduce((sum, entry) => sum + entry.byteLength, 0);
|
|
@@ -17832,7 +17564,7 @@ var init_doctor_evidence = __esm({
|
|
|
17832
17564
|
|
|
17833
17565
|
// src/collector-config.ts
|
|
17834
17566
|
import { createHash as createHash3 } from "node:crypto";
|
|
17835
|
-
import { readFile as
|
|
17567
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
17836
17568
|
function fail3(message, cause) {
|
|
17837
17569
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
17838
17570
|
}
|
|
@@ -17875,7 +17607,7 @@ function emptyCollectorManifest() {
|
|
|
17875
17607
|
async function loadCollectorManifest(path) {
|
|
17876
17608
|
let bytes;
|
|
17877
17609
|
try {
|
|
17878
|
-
bytes = await
|
|
17610
|
+
bytes = await readFile7(path);
|
|
17879
17611
|
} catch (error) {
|
|
17880
17612
|
fail3(`Collector request manifest is unreadable at ${path}`, error);
|
|
17881
17613
|
}
|
|
@@ -18266,7 +17998,7 @@ var init_git_object_id = __esm({
|
|
|
18266
17998
|
|
|
18267
17999
|
// src/merger-git-state.ts
|
|
18268
18000
|
import { execFile as execFile2 } from "node:child_process";
|
|
18269
|
-
import { access as access2, readFile as
|
|
18001
|
+
import { access as access2, readFile as readFile8 } from "node:fs/promises";
|
|
18270
18002
|
import { constants as fsConstants } from "node:fs";
|
|
18271
18003
|
import { isAbsolute as isAbsolute4, resolve as resolve5 } from "node:path";
|
|
18272
18004
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -18336,7 +18068,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
|
|
|
18336
18068
|
const mergeHeadPath = isAbsolute4(mergeHeadReported) ? mergeHeadReported : resolve5(repositoryRoot, mergeHeadReported);
|
|
18337
18069
|
let sourceObjectId = "";
|
|
18338
18070
|
if (await pathExists(mergeHeadPath)) {
|
|
18339
|
-
const raw = exactUtf8(await
|
|
18071
|
+
const raw = exactUtf8(await readFile8(mergeHeadPath), "Git MERGE_HEAD");
|
|
18340
18072
|
const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
|
|
18341
18073
|
if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
|
|
18342
18074
|
if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
|
|
@@ -18388,7 +18120,7 @@ var init_uuidv7 = __esm({
|
|
|
18388
18120
|
});
|
|
18389
18121
|
|
|
18390
18122
|
// src/typed-provider-http.ts
|
|
18391
|
-
import { readFile as
|
|
18123
|
+
import { readFile as readFile9, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
18392
18124
|
import { join as join13 } from "node:path";
|
|
18393
18125
|
function typedProviderHttpPath(runDirectory) {
|
|
18394
18126
|
return join13(runDirectory, TYPED_HTTP_FILE);
|
|
@@ -18406,7 +18138,7 @@ async function clearTypedProviderHttpObservation(runDirectory) {
|
|
|
18406
18138
|
async function readLatestTypedProviderHttpObservation(runDirectory) {
|
|
18407
18139
|
let text;
|
|
18408
18140
|
try {
|
|
18409
|
-
text = await
|
|
18141
|
+
text = await readFile9(typedProviderHttpPath(runDirectory), "utf8");
|
|
18410
18142
|
} catch (error) {
|
|
18411
18143
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
18412
18144
|
return void 0;
|
|
@@ -18435,7 +18167,7 @@ var init_typed_provider_http = __esm({
|
|
|
18435
18167
|
});
|
|
18436
18168
|
|
|
18437
18169
|
// src/public-cli/run-lifecycle.ts
|
|
18438
|
-
import { chmod, lstat as lstat2, open, readdir as
|
|
18170
|
+
import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile10, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
18439
18171
|
import { basename as basename5, join as join14 } from "node:path";
|
|
18440
18172
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
18441
18173
|
const lines = message !== void 0 ? [message] : [];
|
|
@@ -18474,7 +18206,7 @@ function renderResumeCommand(runId) {
|
|
|
18474
18206
|
}
|
|
18475
18207
|
async function writeRoleRunState(runDirectory, record4) {
|
|
18476
18208
|
const payload = { ...record4, runDirectory };
|
|
18477
|
-
await
|
|
18209
|
+
await writeFile3(
|
|
18478
18210
|
join14(runDirectory, RUN_STATE_FILE),
|
|
18479
18211
|
`${JSON.stringify(payload, null, 2)}
|
|
18480
18212
|
`,
|
|
@@ -18525,7 +18257,7 @@ function parseCurrentCourtState(raw) {
|
|
|
18525
18257
|
async function readRoleRunStateDisk(runDirectory) {
|
|
18526
18258
|
let raw;
|
|
18527
18259
|
try {
|
|
18528
|
-
raw = JSON.parse(await
|
|
18260
|
+
raw = JSON.parse(await readFile10(join14(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
18529
18261
|
} catch (error) {
|
|
18530
18262
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
18531
18263
|
throw error;
|
|
@@ -18547,10 +18279,15 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
18547
18279
|
if (typeof record4.projectRoot !== "string") return void 0;
|
|
18548
18280
|
if (typeof record4.sessionDirectory !== "string") return void 0;
|
|
18549
18281
|
if (typeof record4.admittedRequestPath !== "string") return void 0;
|
|
18550
|
-
const
|
|
18282
|
+
const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
18283
|
+
const runDir = runDirectory;
|
|
18551
18284
|
const principalWire = {
|
|
18552
|
-
sessionDirectory:
|
|
18553
|
-
|
|
18285
|
+
sessionDirectory: rewriteRunDirectoryPathValue(
|
|
18286
|
+
record4.sessionDirectory,
|
|
18287
|
+
storedRunDirectory,
|
|
18288
|
+
runDirectory
|
|
18289
|
+
),
|
|
18290
|
+
...typeof record4.sessionFile === "string" ? { sessionFile: rewriteRunDirectoryPathValue(record4.sessionFile, storedRunDirectory, runDirectory) } : {}
|
|
18554
18291
|
};
|
|
18555
18292
|
let resumable;
|
|
18556
18293
|
if (record4.resumable !== void 0 && record4.resumable !== null) {
|
|
@@ -18570,7 +18307,11 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
18570
18307
|
bookKey: record4.bookKey,
|
|
18571
18308
|
projectRoot: record4.projectRoot,
|
|
18572
18309
|
runDirectory: runDir,
|
|
18573
|
-
admittedRequestPath:
|
|
18310
|
+
admittedRequestPath: rewriteRunDirectoryPathValue(
|
|
18311
|
+
record4.admittedRequestPath,
|
|
18312
|
+
storedRunDirectory,
|
|
18313
|
+
runDirectory
|
|
18314
|
+
),
|
|
18574
18315
|
principalWire,
|
|
18575
18316
|
...phase === void 0 ? {} : { phase },
|
|
18576
18317
|
...resumable === void 0 ? {} : { resumable },
|
|
@@ -18592,7 +18333,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
18592
18333
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
18593
18334
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
18594
18335
|
};
|
|
18595
|
-
await
|
|
18336
|
+
await writeFile3(
|
|
18596
18337
|
join14(runDirectory, RUN_STATE_FILE),
|
|
18597
18338
|
`${JSON.stringify(payload, null, 2)}
|
|
18598
18339
|
`,
|
|
@@ -18760,7 +18501,7 @@ function isProcessAlive(pid) {
|
|
|
18760
18501
|
async function autopsyWriterLock(lockPath) {
|
|
18761
18502
|
let content;
|
|
18762
18503
|
try {
|
|
18763
|
-
content = await
|
|
18504
|
+
content = await readFile10(lockPath, "utf8");
|
|
18764
18505
|
} catch (error) {
|
|
18765
18506
|
if (errorCodeOf2(error) === "ENOENT") return { verdict: "absent" };
|
|
18766
18507
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -18919,7 +18660,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
18919
18660
|
const booksRoot = join14(ledgerHome, "books");
|
|
18920
18661
|
let bookKeys;
|
|
18921
18662
|
try {
|
|
18922
|
-
bookKeys = await
|
|
18663
|
+
bookKeys = await readdir4(booksRoot);
|
|
18923
18664
|
} catch (error) {
|
|
18924
18665
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
18925
18666
|
throw error;
|
|
@@ -18957,7 +18698,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
18957
18698
|
let raw;
|
|
18958
18699
|
try {
|
|
18959
18700
|
raw = JSON.parse(
|
|
18960
|
-
await
|
|
18701
|
+
await readFile10(join14(runDirectory, "admitted-request.json"), "utf8")
|
|
18961
18702
|
);
|
|
18962
18703
|
} catch (error) {
|
|
18963
18704
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
@@ -19126,10 +18867,15 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19126
18867
|
let sourceRun;
|
|
19127
18868
|
try {
|
|
19128
18869
|
const raw = JSON.parse(
|
|
19129
|
-
await
|
|
18870
|
+
await readFile10(run.admittedRequestPath, "utf8")
|
|
19130
18871
|
);
|
|
19131
18872
|
if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
19132
18873
|
const record4 = raw;
|
|
18874
|
+
const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : run.runDirectory;
|
|
18875
|
+
rewriteAdmittedRoleRunPage(record4, [{
|
|
18876
|
+
oldRunDirectory: storedRunDirectory,
|
|
18877
|
+
newRunDirectory: run.runDirectory
|
|
18878
|
+
}]);
|
|
19133
18879
|
if (typeof record4.instruction === "string") {
|
|
19134
18880
|
instruction = record4.instruction;
|
|
19135
18881
|
}
|
|
@@ -19244,7 +18990,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19244
18990
|
let model;
|
|
19245
18991
|
try {
|
|
19246
18992
|
const invocationRaw = JSON.parse(
|
|
19247
|
-
await
|
|
18993
|
+
await readFile10(join14(run.runDirectory, "invocation.json"), "utf8")
|
|
19248
18994
|
);
|
|
19249
18995
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
19250
18996
|
const rec = invocationRaw;
|
|
@@ -19283,6 +19029,23 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19283
19029
|
} else if (mergedSet.tickets !== void 0) {
|
|
19284
19030
|
courtTicketNumbers = mergedSet.tickets;
|
|
19285
19031
|
}
|
|
19032
|
+
const sourceRunLeaf = basename5(sourceRunPath ?? "").split("@");
|
|
19033
|
+
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
|
|
19034
|
+
const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
|
|
19035
|
+
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
19036
|
+
const currentSourceRunDirectory = await findRunDirectoryById(
|
|
19037
|
+
home,
|
|
19038
|
+
referencedRunId,
|
|
19039
|
+
run.bookKey,
|
|
19040
|
+
referencedRole
|
|
19041
|
+
);
|
|
19042
|
+
if (currentSourceRunDirectory !== void 0) {
|
|
19043
|
+
sourceRunPath = currentSourceRunDirectory;
|
|
19044
|
+
if (sourceRun !== void 0) {
|
|
19045
|
+
sourceRun = { ...sourceRun, runDirectory: currentSourceRunDirectory };
|
|
19046
|
+
}
|
|
19047
|
+
}
|
|
19048
|
+
}
|
|
19286
19049
|
return {
|
|
19287
19050
|
run,
|
|
19288
19051
|
principal,
|
|
@@ -19687,6 +19450,7 @@ var init_run_lifecycle = __esm({
|
|
|
19687
19450
|
init_typed_provider_http();
|
|
19688
19451
|
init_collector_config();
|
|
19689
19452
|
init_diarist_contracts();
|
|
19453
|
+
init_role_run_relocation();
|
|
19690
19454
|
init_engine_material();
|
|
19691
19455
|
init_invocation();
|
|
19692
19456
|
V1_RESUMABLE_PROVIDERS = ["openai-codex", "xai"];
|
|
@@ -19759,17 +19523,29 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
19759
19523
|
}
|
|
19760
19524
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
19761
19525
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
19762
|
-
const
|
|
19526
|
+
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
19527
|
+
const bookRunsRoot = join15(bookDirectory, "runs");
|
|
19763
19528
|
let candidate;
|
|
19764
19529
|
const bare = parseRunDirectoryName(raw);
|
|
19765
19530
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
19766
19531
|
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join15(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
19767
19532
|
} else {
|
|
19768
19533
|
candidate = isAbsolute6(raw) ? raw : resolve6(options.projectRoot, raw);
|
|
19534
|
+
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
19535
|
+
const subjectDirectory = dirname9(dirname9(candidate));
|
|
19536
|
+
const isLegacyUnboundLocator = identity2 !== void 0 && basename6(dirname9(candidate)) === "runs" && basename6(subjectDirectory) === "unbound" && resolve6(dirname9(subjectDirectory)) === resolve6(bookDirectory);
|
|
19537
|
+
if (isLegacyUnboundLocator) {
|
|
19538
|
+
candidate = await findRunDirectoryById(
|
|
19539
|
+
options.home,
|
|
19540
|
+
identity2.runId,
|
|
19541
|
+
bookKey,
|
|
19542
|
+
identity2.role
|
|
19543
|
+
) ?? candidate;
|
|
19544
|
+
}
|
|
19769
19545
|
}
|
|
19770
19546
|
const real = await requireRunDirectory(candidate, raw);
|
|
19771
19547
|
const identity = parseRunDirectoryName(basename6(real));
|
|
19772
|
-
const bookIdentity = physicalPathIdentity(
|
|
19548
|
+
const bookIdentity = physicalPathIdentity(bookDirectory);
|
|
19773
19549
|
const parentIdentity = physicalPathIdentity(dirname9(real));
|
|
19774
19550
|
const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
|
|
19775
19551
|
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
@@ -21011,15 +20787,15 @@ __export(invocation_exports, {
|
|
|
21011
20787
|
withPreparedAttachments: () => withPreparedAttachments
|
|
21012
20788
|
});
|
|
21013
20789
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
21014
|
-
import { existsSync as
|
|
20790
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
21015
20791
|
import {
|
|
21016
20792
|
lstat as lstat4,
|
|
21017
20793
|
mkdtemp,
|
|
21018
|
-
readFile as
|
|
20794
|
+
readFile as readFile11,
|
|
21019
20795
|
realpath as realpath4,
|
|
21020
20796
|
rename,
|
|
21021
20797
|
rm,
|
|
21022
|
-
writeFile as
|
|
20798
|
+
writeFile as writeFile4
|
|
21023
20799
|
} from "node:fs/promises";
|
|
21024
20800
|
import { tmpdir } from "node:os";
|
|
21025
20801
|
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute7, join as join16, resolve as resolve7, sep as sep4 } from "node:path";
|
|
@@ -21047,7 +20823,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
|
|
|
21047
20823
|
sessionDirectory: coordinates.sessionDirectory,
|
|
21048
20824
|
sessionFile: coordinates.sessionFile
|
|
21049
20825
|
};
|
|
21050
|
-
await
|
|
20826
|
+
await writeFile4(
|
|
21051
20827
|
admittedRequestPath,
|
|
21052
20828
|
`${JSON.stringify(projection, null, 2)}
|
|
21053
20829
|
`,
|
|
@@ -21075,7 +20851,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
21075
20851
|
...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
|
|
21076
20852
|
...effectiveModelLedgerFields(effectiveModel)
|
|
21077
20853
|
};
|
|
21078
|
-
await
|
|
20854
|
+
await writeFile4(
|
|
21079
20855
|
join16(source.runDirectory, "invocation.json"),
|
|
21080
20856
|
`${JSON.stringify(identity, null, 2)}
|
|
21081
20857
|
`,
|
|
@@ -21084,7 +20860,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
21084
20860
|
}
|
|
21085
20861
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
21086
20862
|
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
21087
|
-
const current = JSON.parse(await
|
|
20863
|
+
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
21088
20864
|
const next = { ...current };
|
|
21089
20865
|
if (model !== void 0) {
|
|
21090
20866
|
next.provider = model.provider;
|
|
@@ -21108,7 +20884,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
21108
20884
|
if (host !== void 0) {
|
|
21109
20885
|
next.host = host;
|
|
21110
20886
|
}
|
|
21111
|
-
await
|
|
20887
|
+
await writeFile4(
|
|
21112
20888
|
ledgerPath,
|
|
21113
20889
|
`${JSON.stringify(next, null, 2)}
|
|
21114
20890
|
`,
|
|
@@ -21117,8 +20893,8 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
21117
20893
|
}
|
|
21118
20894
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
21119
20895
|
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
21120
|
-
const current = JSON.parse(await
|
|
21121
|
-
await
|
|
20896
|
+
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
20897
|
+
await writeFile4(
|
|
21122
20898
|
ledgerPath,
|
|
21123
20899
|
`${JSON.stringify({
|
|
21124
20900
|
...current,
|
|
@@ -21133,14 +20909,14 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
|
|
|
21133
20909
|
throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
|
|
21134
20910
|
}
|
|
21135
20911
|
const admittedPath = admitted.admittedRequestPath;
|
|
21136
|
-
const current = JSON.parse(await
|
|
20912
|
+
const current = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
21137
20913
|
if (typeof current.sourceRunPath === "string") {
|
|
21138
20914
|
if (current.sourceRunPath === sourceRunPath) return;
|
|
21139
20915
|
throw new Error(
|
|
21140
20916
|
`persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
21141
20917
|
);
|
|
21142
20918
|
}
|
|
21143
|
-
await
|
|
20919
|
+
await writeFile4(
|
|
21144
20920
|
admittedPath,
|
|
21145
20921
|
`${JSON.stringify({ ...current, sourceRunPath }, null, 2)}
|
|
21146
20922
|
`,
|
|
@@ -21159,7 +20935,7 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
21159
20935
|
}
|
|
21160
20936
|
async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
21161
20937
|
const current = JSON.parse(
|
|
21162
|
-
await
|
|
20938
|
+
await readFile11(admitted.admittedRequestPath, "utf8")
|
|
21163
20939
|
);
|
|
21164
20940
|
const prior = [
|
|
21165
20941
|
...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
|
|
@@ -21168,7 +20944,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
21168
20944
|
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
21169
20945
|
];
|
|
21170
20946
|
const correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
21171
|
-
await
|
|
20947
|
+
await writeFile4(
|
|
21172
20948
|
admitted.admittedRequestPath,
|
|
21173
20949
|
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
21174
20950
|
`,
|
|
@@ -21207,8 +20983,8 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
|
21207
20983
|
}
|
|
21208
20984
|
const frozen = Object.freeze([...projected]);
|
|
21209
20985
|
const admittedPath = admitted.admittedRequestPath;
|
|
21210
|
-
const current = JSON.parse(await
|
|
21211
|
-
await
|
|
20986
|
+
const current = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
20987
|
+
await writeFile4(
|
|
21212
20988
|
admittedPath,
|
|
21213
20989
|
`${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
|
|
21214
20990
|
`,
|
|
@@ -21220,7 +20996,7 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
|
21220
20996
|
admitted.courtTicketNumbers = frozen;
|
|
21221
20997
|
}
|
|
21222
20998
|
async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
21223
|
-
if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) return;
|
|
20999
|
+
if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) return void 0;
|
|
21224
21000
|
const oldRunDirectory = admitted.runDirectory;
|
|
21225
21001
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
|
|
21226
21002
|
const target = roleRunPlacement(ledgerHome, {
|
|
@@ -21230,6 +21006,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
21230
21006
|
role: admitted.role
|
|
21231
21007
|
});
|
|
21232
21008
|
ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
|
|
21009
|
+
const principal = authority.seal(target);
|
|
21233
21010
|
await rename(oldRunDirectory, target.runDirectory);
|
|
21234
21011
|
heldLease?.relocate(target.runDirectory);
|
|
21235
21012
|
const admittedRecord = admitted;
|
|
@@ -21254,13 +21031,8 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
21254
21031
|
target.runDirectory
|
|
21255
21032
|
);
|
|
21256
21033
|
}
|
|
21257
|
-
const principal = authority.seal(target);
|
|
21258
21034
|
admitted.principal = principal;
|
|
21259
|
-
|
|
21260
|
-
pagesDirectory: target.runDirectory,
|
|
21261
|
-
oldRunDirectory,
|
|
21262
|
-
newRunDirectory: target.runDirectory
|
|
21263
|
-
});
|
|
21035
|
+
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
21264
21036
|
}
|
|
21265
21037
|
async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
21266
21038
|
requireSafePositiveTicketNumber(
|
|
@@ -21269,7 +21041,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
21269
21041
|
);
|
|
21270
21042
|
const admittedPath = join16(runDirectory, "admitted-request.json");
|
|
21271
21043
|
const invocationPath = join16(runDirectory, "invocation.json");
|
|
21272
|
-
const admitted = JSON.parse(await
|
|
21044
|
+
const admitted = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
21273
21045
|
const existing = admitted.ticketNumber;
|
|
21274
21046
|
if (typeof existing === "number") {
|
|
21275
21047
|
if (existing === ticketNumber) return;
|
|
@@ -21277,9 +21049,9 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
21277
21049
|
`bindTicketNumberOnRunDirectory refuses to replace existing ticket #${existing} with #${ticketNumber}`
|
|
21278
21050
|
);
|
|
21279
21051
|
}
|
|
21280
|
-
if (
|
|
21052
|
+
if (existsSync5(invocationPath)) {
|
|
21281
21053
|
const invocation = JSON.parse(
|
|
21282
|
-
await
|
|
21054
|
+
await readFile11(invocationPath, "utf8")
|
|
21283
21055
|
);
|
|
21284
21056
|
if (typeof invocation.ticketNumber === "number" && invocation.ticketNumber !== ticketNumber) {
|
|
21285
21057
|
throw new Error(
|
|
@@ -21287,7 +21059,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
21287
21059
|
);
|
|
21288
21060
|
}
|
|
21289
21061
|
}
|
|
21290
|
-
await
|
|
21062
|
+
await writeFile4(
|
|
21291
21063
|
admittedPath,
|
|
21292
21064
|
`${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
|
|
21293
21065
|
`,
|
|
@@ -21304,7 +21076,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
21304
21076
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
21305
21077
|
const rolePackageRoot = packageRoot2;
|
|
21306
21078
|
const raw = JSON.parse(
|
|
21307
|
-
await
|
|
21079
|
+
await readFile11(join16(rolePackageRoot, "package.json"), "utf8")
|
|
21308
21080
|
);
|
|
21309
21081
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
21310
21082
|
throw new Error(
|
|
@@ -21589,7 +21361,7 @@ async function readRegularFileAttachment(sourcePath) {
|
|
|
21589
21361
|
);
|
|
21590
21362
|
}
|
|
21591
21363
|
try {
|
|
21592
|
-
return { absolute, bytes: await
|
|
21364
|
+
return { absolute, bytes: await readFile11(absolute) };
|
|
21593
21365
|
} catch (error) {
|
|
21594
21366
|
throw new CliUsageError(
|
|
21595
21367
|
`attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -21609,7 +21381,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
21609
21381
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
21610
21382
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
21611
21383
|
const snapshotPath = join16(stagingDirectory, String(index).padStart(6, "0"));
|
|
21612
|
-
await
|
|
21384
|
+
await writeFile4(snapshotPath, bytes);
|
|
21613
21385
|
prepared.push({ absolute, snapshotPath });
|
|
21614
21386
|
}
|
|
21615
21387
|
result = await use(prepared);
|
|
@@ -21633,7 +21405,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
|
|
|
21633
21405
|
destinationDir,
|
|
21634
21406
|
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
21635
21407
|
);
|
|
21636
|
-
await
|
|
21408
|
+
await writeFile4(frozenPath, bytes);
|
|
21637
21409
|
return {
|
|
21638
21410
|
provenancePath,
|
|
21639
21411
|
frozenPath,
|
|
@@ -21645,7 +21417,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
|
|
|
21645
21417
|
async function freezePreparedAttachment(prepared, destinationDir, index) {
|
|
21646
21418
|
return freezeAttachmentBytes(
|
|
21647
21419
|
prepared.absolute,
|
|
21648
|
-
await
|
|
21420
|
+
await readFile11(prepared.snapshotPath),
|
|
21649
21421
|
destinationDir,
|
|
21650
21422
|
index
|
|
21651
21423
|
);
|
|
@@ -21901,7 +21673,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
|
|
|
21901
21673
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
21902
21674
|
try {
|
|
21903
21675
|
const raw = JSON.parse(
|
|
21904
|
-
await
|
|
21676
|
+
await readFile11(join16(runDirectory, "admitted-request.json"), "utf8")
|
|
21905
21677
|
);
|
|
21906
21678
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
21907
21679
|
const record4 = raw;
|
|
@@ -21957,7 +21729,7 @@ async function admitCoderInvocation(options) {
|
|
|
21957
21729
|
});
|
|
21958
21730
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
21959
21731
|
const taskPath = join16(runDirectory, "task.md");
|
|
21960
|
-
await
|
|
21732
|
+
await writeFile4(taskPath, instruction, "utf8");
|
|
21961
21733
|
const admitted = {
|
|
21962
21734
|
role: "coder",
|
|
21963
21735
|
phase: options.phase,
|
|
@@ -22027,7 +21799,7 @@ async function admitFixerInvocation(options) {
|
|
|
22027
21799
|
if (options.prerequisitesPath !== void 0) {
|
|
22028
21800
|
const absolutePrereq = isAbsolute7(options.prerequisitesPath) ? options.prerequisitesPath : resolve7(options.prerequisitesPath);
|
|
22029
21801
|
try {
|
|
22030
|
-
prerequisitesSource = await
|
|
21802
|
+
prerequisitesSource = await readFile11(absolutePrereq, "utf8");
|
|
22031
21803
|
} catch (error) {
|
|
22032
21804
|
throw new CliUsageError(
|
|
22033
21805
|
`fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
|
|
@@ -22064,7 +21836,7 @@ async function admitFixerInvocation(options) {
|
|
|
22064
21836
|
let prerequisitesPath;
|
|
22065
21837
|
if (prerequisitesSource !== void 0) {
|
|
22066
21838
|
prerequisitesPath = join16(runDirectory, "prerequisites.json");
|
|
22067
|
-
await
|
|
21839
|
+
await writeFile4(
|
|
22068
21840
|
prerequisitesPath,
|
|
22069
21841
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
22070
21842
|
`,
|
|
@@ -22072,7 +21844,7 @@ async function admitFixerInvocation(options) {
|
|
|
22072
21844
|
);
|
|
22073
21845
|
}
|
|
22074
21846
|
const packetPath = join16(runDirectory, "fix-packet.md");
|
|
22075
|
-
await
|
|
21847
|
+
await writeFile4(packetPath, instruction, "utf8");
|
|
22076
21848
|
const admitted = {
|
|
22077
21849
|
role: "fixer",
|
|
22078
21850
|
phase: options.phase,
|
|
@@ -22318,7 +22090,7 @@ async function admitCollectorInvocation(options) {
|
|
|
22318
22090
|
let requestManifestPath;
|
|
22319
22091
|
if (manifestCanonicalJson !== void 0) {
|
|
22320
22092
|
requestManifestPath = join16(runDirectory, "request-manifest.json");
|
|
22321
|
-
await
|
|
22093
|
+
await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
22322
22094
|
}
|
|
22323
22095
|
const admitted = {
|
|
22324
22096
|
role: "collector",
|
|
@@ -23099,7 +22871,7 @@ async function admitMergerInvocation(options) {
|
|
|
23099
22871
|
authorizedChecks: []
|
|
23100
22872
|
});
|
|
23101
22873
|
const mergerInputPath = join16(runDirectory, "merger-input.json");
|
|
23102
|
-
await
|
|
22874
|
+
await writeFile4(
|
|
23103
22875
|
mergerInputPath,
|
|
23104
22876
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
23105
22877
|
`,
|
|
@@ -23412,7 +23184,7 @@ var init_invocation = __esm({
|
|
|
23412
23184
|
});
|
|
23413
23185
|
|
|
23414
23186
|
// src/public-cli/load-production-acp-host.ts
|
|
23415
|
-
import { existsSync as
|
|
23187
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
23416
23188
|
import { join as join17 } from "node:path";
|
|
23417
23189
|
import { pathToFileURL } from "node:url";
|
|
23418
23190
|
async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
@@ -23422,7 +23194,7 @@ async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
|
23422
23194
|
}
|
|
23423
23195
|
const built = join17(packageRoot2, "dist/acp-host/production-host.js");
|
|
23424
23196
|
const source = join17(packageRoot2, "src/acp-host/production-host.ts");
|
|
23425
|
-
const target =
|
|
23197
|
+
const target = existsSync6(built) ? built : source;
|
|
23426
23198
|
const href = pathToFileURL(target).href;
|
|
23427
23199
|
const mod = await import(href);
|
|
23428
23200
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -23436,7 +23208,7 @@ var init_load_production_acp_host = __esm({
|
|
|
23436
23208
|
});
|
|
23437
23209
|
|
|
23438
23210
|
// src/public-cli/load-production-headless-host.ts
|
|
23439
|
-
import { existsSync as
|
|
23211
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
23440
23212
|
import { join as join18 } from "node:path";
|
|
23441
23213
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
23442
23214
|
async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
@@ -23446,7 +23218,7 @@ async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
|
23446
23218
|
}
|
|
23447
23219
|
const built = join18(packageRoot2, "dist/headless-host/production-host.js");
|
|
23448
23220
|
const source = join18(packageRoot2, "src/headless-host/production-host.ts");
|
|
23449
|
-
const target =
|
|
23221
|
+
const target = existsSync7(built) ? built : source;
|
|
23450
23222
|
const href = pathToFileURL2(target).href;
|
|
23451
23223
|
const mod = await import(href);
|
|
23452
23224
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -23572,7 +23344,7 @@ var init_role_turn_host_resolution = __esm({
|
|
|
23572
23344
|
|
|
23573
23345
|
// src/package-resources/method-skill.ts
|
|
23574
23346
|
import { createHash as createHash4 } from "node:crypto";
|
|
23575
|
-
import { readFile as
|
|
23347
|
+
import { readFile as readFile12, realpath as realpath5 } from "node:fs/promises";
|
|
23576
23348
|
import { join as join19 } from "node:path";
|
|
23577
23349
|
function gitBlobOid(bytes) {
|
|
23578
23350
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
@@ -23691,7 +23463,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
23691
23463
|
const provenancePath = join19(rootDirectory, "provenance.json");
|
|
23692
23464
|
let provenanceRaw;
|
|
23693
23465
|
try {
|
|
23694
|
-
provenanceRaw = await
|
|
23466
|
+
provenanceRaw = await readFile12(provenancePath, "utf8");
|
|
23695
23467
|
} catch (error) {
|
|
23696
23468
|
throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
|
|
23697
23469
|
}
|
|
@@ -23708,7 +23480,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
23708
23480
|
const absolute = join19(rootDirectory, rel);
|
|
23709
23481
|
let bytes;
|
|
23710
23482
|
try {
|
|
23711
|
-
bytes = await
|
|
23483
|
+
bytes = await readFile12(absolute);
|
|
23712
23484
|
} catch (error) {
|
|
23713
23485
|
throw new PackagedMethodSkillUnavailableError(name, absolute, error);
|
|
23714
23486
|
}
|
|
@@ -23724,7 +23496,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
23724
23496
|
let raw;
|
|
23725
23497
|
try {
|
|
23726
23498
|
skillPath = await realpath5(skillPathConfigured);
|
|
23727
|
-
raw = await
|
|
23499
|
+
raw = await readFile12(skillPath, "utf8");
|
|
23728
23500
|
} catch (error) {
|
|
23729
23501
|
throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
|
|
23730
23502
|
}
|
|
@@ -23808,12 +23580,12 @@ var init_method_skill = __esm({
|
|
|
23808
23580
|
});
|
|
23809
23581
|
|
|
23810
23582
|
// src/ledger-session-read.ts
|
|
23811
|
-
import { readFile as
|
|
23583
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
23812
23584
|
function isRecord6(value) {
|
|
23813
23585
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23814
23586
|
}
|
|
23815
23587
|
async function readLedgerSessionJsonlLines(path) {
|
|
23816
|
-
const text = await
|
|
23588
|
+
const text = await readFile13(path, "utf8");
|
|
23817
23589
|
const lines = text.split("\n");
|
|
23818
23590
|
const out = [];
|
|
23819
23591
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -24004,7 +23776,7 @@ var init_ledger_session_read = __esm({
|
|
|
24004
23776
|
});
|
|
24005
23777
|
|
|
24006
23778
|
// src/analyst-gate-cycles-read.ts
|
|
24007
|
-
import { readdir as
|
|
23779
|
+
import { readdir as readdir5 } from "node:fs/promises";
|
|
24008
23780
|
import { join as join20 } from "node:path";
|
|
24009
23781
|
function isRecord7(value) {
|
|
24010
23782
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -24220,10 +23992,10 @@ function pairGateRounds(volumes) {
|
|
|
24220
23992
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
24221
23993
|
}
|
|
24222
23994
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
24223
|
-
const { readFile:
|
|
23995
|
+
const { readFile: readFile22 } = await import("node:fs/promises");
|
|
24224
23996
|
let raw;
|
|
24225
23997
|
try {
|
|
24226
|
-
raw = JSON.parse(await
|
|
23998
|
+
raw = JSON.parse(await readFile22(pointerPath, "utf8"));
|
|
24227
23999
|
} catch (error) {
|
|
24228
24000
|
throw new Error(
|
|
24229
24001
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -24246,7 +24018,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
24246
24018
|
for (const directory of directories) {
|
|
24247
24019
|
let names;
|
|
24248
24020
|
try {
|
|
24249
|
-
const entries = await
|
|
24021
|
+
const entries = await readdir5(directory, { withFileTypes: true });
|
|
24250
24022
|
names = entries.filter(
|
|
24251
24023
|
(e) => e.isFile() && (e.name.endsWith(".jsonl") || e.name.endsWith(".pointer.json"))
|
|
24252
24024
|
).map((e) => e.name).sort();
|
|
@@ -24499,14 +24271,14 @@ var init_submission_ledger = __esm({
|
|
|
24499
24271
|
});
|
|
24500
24272
|
|
|
24501
24273
|
// src/session-opening-materials.ts
|
|
24502
|
-
import { existsSync as
|
|
24503
|
-
import { readFile as
|
|
24274
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
24275
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
24504
24276
|
import { dirname as dirname11, join as join22 } from "node:path";
|
|
24505
24277
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
24506
24278
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
24507
24279
|
let dir = dirname11(fileURLToPath(moduleUrl));
|
|
24508
24280
|
for (let i = 0; i < 8; i += 1) {
|
|
24509
|
-
if (
|
|
24281
|
+
if (existsSync8(join22(dir, "package.json")) && existsSync8(join22(dir, "souls"))) {
|
|
24510
24282
|
return dir;
|
|
24511
24283
|
}
|
|
24512
24284
|
const parent = dirname11(dir);
|
|
@@ -24516,7 +24288,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
|
24516
24288
|
return fileURLToPath(new URL("..", moduleUrl));
|
|
24517
24289
|
}
|
|
24518
24290
|
async function readPackageMaterial(relativePath) {
|
|
24519
|
-
return
|
|
24291
|
+
return readFile14(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
24520
24292
|
}
|
|
24521
24293
|
async function joinPackageMaterials(relativePaths) {
|
|
24522
24294
|
const chunks = [];
|
|
@@ -25120,7 +24892,7 @@ __export(settlement_exports, {
|
|
|
25120
24892
|
withSubmissions: () => withSubmissions
|
|
25121
24893
|
});
|
|
25122
24894
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
25123
|
-
import { appendFile as appendFile2, readFile as
|
|
24895
|
+
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir6, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
|
|
25124
24896
|
import { dirname as dirname13, join as join24 } from "node:path";
|
|
25125
24897
|
function sealedLedgerHome(admitted) {
|
|
25126
24898
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
@@ -25271,7 +25043,7 @@ function presentControlledFailure(failure, io) {
|
|
|
25271
25043
|
}
|
|
25272
25044
|
async function inspectJudgeSession(sessionFile) {
|
|
25273
25045
|
try {
|
|
25274
|
-
await
|
|
25046
|
+
await readFile15(sessionFile, "utf8");
|
|
25275
25047
|
return { state: "present" };
|
|
25276
25048
|
} catch (error) {
|
|
25277
25049
|
if (isMissingPathError4(error)) return { state: "missing" };
|
|
@@ -25506,7 +25278,7 @@ function sessionReadFailure(error, fallbackMessage) {
|
|
|
25506
25278
|
return failed;
|
|
25507
25279
|
}
|
|
25508
25280
|
async function readBoundSessionEntries(sessionFile) {
|
|
25509
|
-
const text = await
|
|
25281
|
+
const text = await readFile15(sessionFile, "utf8");
|
|
25510
25282
|
const entries = [];
|
|
25511
25283
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
25512
25284
|
try {
|
|
@@ -25608,7 +25380,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25608
25380
|
for (const childDirectory of childDirectories) {
|
|
25609
25381
|
let names;
|
|
25610
25382
|
try {
|
|
25611
|
-
names = await
|
|
25383
|
+
names = await readdir6(childDirectory);
|
|
25612
25384
|
sawAnyDirectory = true;
|
|
25613
25385
|
} catch (error) {
|
|
25614
25386
|
if (isMissingPathError4(error)) continue;
|
|
@@ -26283,13 +26055,13 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
26283
26055
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
26284
26056
|
const reportPath = join24(artifactsDir, "report.json");
|
|
26285
26057
|
const evidencePath = join24(artifactsDir, "evidence.json");
|
|
26286
|
-
await
|
|
26058
|
+
await writeFile5(
|
|
26287
26059
|
reportPath,
|
|
26288
26060
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
26289
26061
|
`,
|
|
26290
26062
|
"utf8"
|
|
26291
26063
|
);
|
|
26292
|
-
await
|
|
26064
|
+
await writeFile5(
|
|
26293
26065
|
evidencePath,
|
|
26294
26066
|
`${JSON.stringify(bodies.evidence, null, 2)}
|
|
26295
26067
|
`,
|
|
@@ -27203,7 +26975,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
27203
26975
|
const path = candidates[i];
|
|
27204
26976
|
const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
|
|
27205
26977
|
try {
|
|
27206
|
-
await
|
|
26978
|
+
await writeFile5(
|
|
27207
26979
|
path,
|
|
27208
26980
|
`${JSON.stringify(payload, null, 2)}
|
|
27209
26981
|
`,
|
|
@@ -27574,7 +27346,7 @@ var init_turn_request = __esm({
|
|
|
27574
27346
|
});
|
|
27575
27347
|
|
|
27576
27348
|
// src/session-identity.ts
|
|
27577
|
-
import { mkdir as mkdir2, readFile as
|
|
27349
|
+
import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
|
|
27578
27350
|
import { dirname as dirname14, join as join25 } from "node:path";
|
|
27579
27351
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
27580
27352
|
const bindingPath = (principal) => join25(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
@@ -27584,7 +27356,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
27584
27356
|
},
|
|
27585
27357
|
async load(principal) {
|
|
27586
27358
|
try {
|
|
27587
|
-
const value = JSON.parse(await
|
|
27359
|
+
const value = JSON.parse(await readFile16(bindingPath(principal), "utf8"));
|
|
27588
27360
|
if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
|
|
27589
27361
|
throw new Error("durable session binding is invalid");
|
|
27590
27362
|
}
|
|
@@ -27598,7 +27370,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
27598
27370
|
const target = bindingPath(principal);
|
|
27599
27371
|
await mkdir2(dirname14(target), { recursive: true });
|
|
27600
27372
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
27601
|
-
await
|
|
27373
|
+
await writeFile6(temporary, `${JSON.stringify({ sessionId })}
|
|
27602
27374
|
`, { encoding: "utf8", mode: 384 });
|
|
27603
27375
|
await rename2(temporary, target);
|
|
27604
27376
|
}
|
|
@@ -27667,7 +27439,7 @@ var init_ticket_provenance = __esm({
|
|
|
27667
27439
|
});
|
|
27668
27440
|
|
|
27669
27441
|
// src/public-cli/case-dossier-delivery.ts
|
|
27670
|
-
import { mkdtemp as mkdtemp2, readFile as
|
|
27442
|
+
import { mkdtemp as mkdtemp2, readFile as readFile17, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
|
|
27671
27443
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
27672
27444
|
import { join as join26 } from "node:path";
|
|
27673
27445
|
async function projectCaseDossierPointerSection(input) {
|
|
@@ -27699,7 +27471,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
27699
27471
|
const stagingDir = await mkdtemp2(join26(tmpdir2(), "ak-case-dossier-"));
|
|
27700
27472
|
try {
|
|
27701
27473
|
const stagingPath = join26(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
27702
|
-
await
|
|
27474
|
+
await writeFile7(stagingPath, `${section}
|
|
27703
27475
|
`, "utf8");
|
|
27704
27476
|
return await freezeAttachmentsIntoRun(
|
|
27705
27477
|
[stagingPath],
|
|
@@ -27725,9 +27497,9 @@ var init_case_dossier_delivery = __esm({
|
|
|
27725
27497
|
});
|
|
27726
27498
|
|
|
27727
27499
|
// src/host-transition-prior-native.ts
|
|
27728
|
-
import { access as access3, readdir as
|
|
27500
|
+
import { access as access3, readdir as readdir7 } from "node:fs/promises";
|
|
27729
27501
|
import { dirname as dirname15, join as join27 } from "node:path";
|
|
27730
|
-
function
|
|
27502
|
+
function isEnoent2(error) {
|
|
27731
27503
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
27732
27504
|
}
|
|
27733
27505
|
async function listPiNativeRecordPaths(sessionFile) {
|
|
@@ -27735,7 +27507,7 @@ async function listPiNativeRecordPaths(sessionFile) {
|
|
|
27735
27507
|
await access3(sessionFile);
|
|
27736
27508
|
return [sessionFile];
|
|
27737
27509
|
} catch (error) {
|
|
27738
|
-
if (
|
|
27510
|
+
if (isEnoent2(error)) return [];
|
|
27739
27511
|
throw error;
|
|
27740
27512
|
}
|
|
27741
27513
|
}
|
|
@@ -27743,9 +27515,9 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
27743
27515
|
const sessionRoot = dirname15(sessionParent);
|
|
27744
27516
|
let entries;
|
|
27745
27517
|
try {
|
|
27746
|
-
entries = await
|
|
27518
|
+
entries = await readdir7(sessionRoot, { withFileTypes: true });
|
|
27747
27519
|
} catch (error) {
|
|
27748
|
-
if (
|
|
27520
|
+
if (isEnoent2(error)) return [];
|
|
27749
27521
|
throw error;
|
|
27750
27522
|
}
|
|
27751
27523
|
const recordPaths = [];
|
|
@@ -27756,7 +27528,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
27756
27528
|
await access3(recordFile);
|
|
27757
27529
|
recordPaths.push(recordFile);
|
|
27758
27530
|
} catch (error) {
|
|
27759
|
-
if (!
|
|
27531
|
+
if (!isEnoent2(error)) throw error;
|
|
27760
27532
|
}
|
|
27761
27533
|
}
|
|
27762
27534
|
recordPaths.sort();
|
|
@@ -28252,7 +28024,7 @@ var init_auto_resume = __esm({
|
|
|
28252
28024
|
|
|
28253
28025
|
// src/public-cli/post-admission.ts
|
|
28254
28026
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
28255
|
-
import { writeFile as
|
|
28027
|
+
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
28256
28028
|
import { isAbsolute as isAbsolute8, join as join29, resolve as resolve8 } from "node:path";
|
|
28257
28029
|
function describeCaughtError(error) {
|
|
28258
28030
|
if (error instanceof Error) {
|
|
@@ -28264,6 +28036,28 @@ function describeCaughtError(error) {
|
|
|
28264
28036
|
function isStationChildOfficerDialogue(role, env) {
|
|
28265
28037
|
return env.stationChild === true && isOfficerReviewSeat(role);
|
|
28266
28038
|
}
|
|
28039
|
+
function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
28040
|
+
const rewrite = (value) => rewriteRunDirectoryPathValue(
|
|
28041
|
+
value,
|
|
28042
|
+
relocation.oldRunDirectory,
|
|
28043
|
+
relocation.newRunDirectory
|
|
28044
|
+
);
|
|
28045
|
+
const mutableRequest = request;
|
|
28046
|
+
mutableRequest.runDirectory = admitted.runDirectory;
|
|
28047
|
+
mutableRequest.principal = admitted.principal;
|
|
28048
|
+
const activation = mutableRequest.activation;
|
|
28049
|
+
if (activation !== null && typeof activation === "object" && !Array.isArray(activation)) {
|
|
28050
|
+
for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath", "requestManifestPath"]) {
|
|
28051
|
+
const record4 = activation;
|
|
28052
|
+
if (field in record4) record4[field] = rewrite(record4[field]);
|
|
28053
|
+
}
|
|
28054
|
+
}
|
|
28055
|
+
if (result.terminal !== void 0) {
|
|
28056
|
+
for (const artifact of result.terminal.artifacts) {
|
|
28057
|
+
artifact.path = rewrite(artifact.path);
|
|
28058
|
+
}
|
|
28059
|
+
}
|
|
28060
|
+
}
|
|
28267
28061
|
function withProcessCancelSkipAutoResume(result, signal) {
|
|
28268
28062
|
if (processCancelSignalName(signal) === void 0) {
|
|
28269
28063
|
return result;
|
|
@@ -28320,7 +28114,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
28320
28114
|
} catch (appendError) {
|
|
28321
28115
|
try {
|
|
28322
28116
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
28323
|
-
await
|
|
28117
|
+
await writeFile8(
|
|
28324
28118
|
join29(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
28325
28119
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
28326
28120
|
`,
|
|
@@ -28496,6 +28290,10 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28496
28290
|
const ticketNumber = asserted === void 0 ? void 0 : asserted.ticketNumber;
|
|
28497
28291
|
if (ticketNumber !== void 0) await bindAdmittedTicketNumber(admitted, ticketNumber);
|
|
28498
28292
|
}
|
|
28293
|
+
const relocation = await relocateAdmittedRunToTicket(admitted, env.principalAuthority, lease);
|
|
28294
|
+
if (relocation !== void 0) {
|
|
28295
|
+
projectRelocatedTurnIdentity(request, result, admitted, relocation);
|
|
28296
|
+
}
|
|
28499
28297
|
if (adapters.afterDispatch !== void 0) await adapters.afterDispatch(admitted, lease);
|
|
28500
28298
|
return result;
|
|
28501
28299
|
} catch (error) {
|
|
@@ -28636,7 +28434,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28636
28434
|
}
|
|
28637
28435
|
let stderrLogWriteFailure;
|
|
28638
28436
|
try {
|
|
28639
|
-
await
|
|
28437
|
+
await writeFile8(
|
|
28640
28438
|
join29(admitted.runDirectory, "stderr.log"),
|
|
28641
28439
|
result.stderr,
|
|
28642
28440
|
"utf8"
|
|
@@ -29202,6 +29000,7 @@ var init_post_admission = __esm({
|
|
|
29202
29000
|
init_activation_ledger_topology();
|
|
29203
29001
|
init_engine_material();
|
|
29204
29002
|
init_session_identity();
|
|
29003
|
+
init_role_run_relocation();
|
|
29205
29004
|
init_host_contracts();
|
|
29206
29005
|
init_case_dossier_delivery();
|
|
29207
29006
|
init_engine_detour_usage();
|
|
@@ -30855,7 +30654,7 @@ __export(public_role_summons_exports, {
|
|
|
30855
30654
|
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
30856
30655
|
});
|
|
30857
30656
|
import { execFile as execFile3 } from "node:child_process";
|
|
30858
|
-
import { existsSync as
|
|
30657
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
30859
30658
|
import { mkdir as mkdir4, mkdtemp as mkdtemp3, realpath as realpath6, rm as rm4 } from "node:fs/promises";
|
|
30860
30659
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
30861
30660
|
import { join as join30, relative as relative3, sep as sep5 } from "node:path";
|
|
@@ -30882,7 +30681,7 @@ function parentDir(path) {
|
|
|
30882
30681
|
function walkPackageRoot(start) {
|
|
30883
30682
|
let dir = start;
|
|
30884
30683
|
for (let i = 0; i < 12; i += 1) {
|
|
30885
|
-
if (
|
|
30684
|
+
if (existsSync9(join30(dir, "package.json")) && existsSync9(join30(dir, "souls"))) {
|
|
30886
30685
|
return dir;
|
|
30887
30686
|
}
|
|
30888
30687
|
const parent = parentDir(dir);
|
|
@@ -32747,13 +32546,13 @@ var init_analyst_book_key = __esm({
|
|
|
32747
32546
|
|
|
32748
32547
|
// src/atomic-write.ts
|
|
32749
32548
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
32750
|
-
import { rename as rename3, rm as rm5, writeFile as
|
|
32549
|
+
import { rename as rename3, rm as rm5, writeFile as writeFile9 } from "node:fs/promises";
|
|
32751
32550
|
import { dirname as dirname16, join as join31 } from "node:path";
|
|
32752
32551
|
async function writeFileAtomically(destination, contents) {
|
|
32753
32552
|
const parent = dirname16(destination);
|
|
32754
32553
|
const temporary = join31(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
32755
32554
|
try {
|
|
32756
|
-
await
|
|
32555
|
+
await writeFile9(temporary, contents);
|
|
32757
32556
|
await rename3(temporary, destination);
|
|
32758
32557
|
} catch (error) {
|
|
32759
32558
|
await rm5(temporary, { force: true }).catch(() => void 0);
|
|
@@ -32767,7 +32566,7 @@ var init_atomic_write = __esm({
|
|
|
32767
32566
|
});
|
|
32768
32567
|
|
|
32769
32568
|
// src/analyst-index.ts
|
|
32770
|
-
import { open as open3, readFile as
|
|
32569
|
+
import { open as open3, readFile as readFile18, unlink as unlink4 } from "node:fs/promises";
|
|
32771
32570
|
import { dirname as dirname17, join as join32 } from "node:path";
|
|
32772
32571
|
function sleep(ms) {
|
|
32773
32572
|
return new Promise((resolve11) => {
|
|
@@ -32895,7 +32694,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
32895
32694
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
32896
32695
|
let raw;
|
|
32897
32696
|
try {
|
|
32898
|
-
raw = await
|
|
32697
|
+
raw = await readFile18(path, "utf8");
|
|
32899
32698
|
} catch (error) {
|
|
32900
32699
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
32901
32700
|
return void 0;
|
|
@@ -33099,7 +32898,7 @@ var init_analyst_cohort = __esm({
|
|
|
33099
32898
|
});
|
|
33100
32899
|
|
|
33101
32900
|
// src/analyst-ledger.ts
|
|
33102
|
-
import { readdir as
|
|
32901
|
+
import { readdir as readdir8, readFile as readFile19 } from "node:fs/promises";
|
|
33103
32902
|
import { basename as basename8, join as join33 } from "node:path";
|
|
33104
32903
|
function isMissingPathError6(error) {
|
|
33105
32904
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -33113,7 +32912,7 @@ function isRecord12(value) {
|
|
|
33113
32912
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
33114
32913
|
try {
|
|
33115
32914
|
const raw = JSON.parse(
|
|
33116
|
-
await
|
|
32915
|
+
await readFile19(join33(runDirectory, "run-state.json"), "utf8")
|
|
33117
32916
|
);
|
|
33118
32917
|
if (!isRecord12(raw) || typeof raw.state !== "string") return void 0;
|
|
33119
32918
|
return raw.state;
|
|
@@ -33163,7 +32962,7 @@ function tryResolveBookKeyFromProjectRoot(projectRoot) {
|
|
|
33163
32962
|
}
|
|
33164
32963
|
async function listLedgerBookNames(booksRoot) {
|
|
33165
32964
|
try {
|
|
33166
|
-
const entries = await
|
|
32965
|
+
const entries = await readdir8(booksRoot, { withFileTypes: true });
|
|
33167
32966
|
return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
33168
32967
|
} catch (error) {
|
|
33169
32968
|
if (isMissingPathError6(error)) return [];
|
|
@@ -33173,7 +32972,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
33173
32972
|
async function readInvocationScopeFields(runDirectory) {
|
|
33174
32973
|
let raw;
|
|
33175
32974
|
try {
|
|
33176
|
-
raw = await
|
|
32975
|
+
raw = await readFile19(join33(runDirectory, "invocation.json"), "utf8");
|
|
33177
32976
|
} catch (error) {
|
|
33178
32977
|
if (isMissingPathError6(error)) return void 0;
|
|
33179
32978
|
throw error;
|
|
@@ -33206,7 +33005,7 @@ function decideIssueScope(input) {
|
|
|
33206
33005
|
}
|
|
33207
33006
|
async function resolveSessionFile(runDirectory) {
|
|
33208
33007
|
try {
|
|
33209
|
-
const raw = await
|
|
33008
|
+
const raw = await readFile19(join33(runDirectory, "invocation.json"), "utf8");
|
|
33210
33009
|
const parsed = JSON.parse(raw);
|
|
33211
33010
|
if (isRecord12(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
33212
33011
|
return parsed.sessionFile;
|
|
@@ -34493,7 +34292,7 @@ var init_analyst_page = __esm({
|
|
|
34493
34292
|
});
|
|
34494
34293
|
|
|
34495
34294
|
// src/analyst-entry.ts
|
|
34496
|
-
import { readFile as
|
|
34295
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
34497
34296
|
function isMissingPathError7(error) {
|
|
34498
34297
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
34499
34298
|
}
|
|
@@ -34523,7 +34322,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
34523
34322
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
34524
34323
|
});
|
|
34525
34324
|
try {
|
|
34526
|
-
const raw = await
|
|
34325
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
34527
34326
|
const page = JSON.parse(raw);
|
|
34528
34327
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
34529
34328
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -34624,7 +34423,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
34624
34423
|
scopeRootIdentity: projectRoot
|
|
34625
34424
|
});
|
|
34626
34425
|
try {
|
|
34627
|
-
const raw = await
|
|
34426
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
34628
34427
|
JSON.parse(raw);
|
|
34629
34428
|
} catch (error) {
|
|
34630
34429
|
if (!isMissingPathError7(error)) {
|
|
@@ -34723,7 +34522,7 @@ var init_analyst_entry = __esm({
|
|
|
34723
34522
|
});
|
|
34724
34523
|
|
|
34725
34524
|
// src/public-cli/analyst-run.ts
|
|
34726
|
-
import { readFile as
|
|
34525
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
34727
34526
|
import { isAbsolute as isAbsolute10, resolve as resolve10 } from "node:path";
|
|
34728
34527
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
34729
34528
|
try {
|
|
@@ -34776,7 +34575,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
34776
34575
|
const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve10(sourcePath);
|
|
34777
34576
|
let bytes;
|
|
34778
34577
|
try {
|
|
34779
|
-
bytes = await
|
|
34578
|
+
bytes = await readFile21(absolute);
|
|
34780
34579
|
} catch (error) {
|
|
34781
34580
|
throw new CliUsageError(
|
|
34782
34581
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -35929,7 +35728,7 @@ var init_cli = __esm({
|
|
|
35929
35728
|
});
|
|
35930
35729
|
|
|
35931
35730
|
// src/public-cli/main.ts
|
|
35932
|
-
import { existsSync as
|
|
35731
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
35933
35732
|
import { dirname as dirname19, join as join36 } from "node:path";
|
|
35934
35733
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
35935
35734
|
|
|
@@ -36020,7 +35819,7 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
36020
35819
|
var here = dirname19(fileURLToPath2(import.meta.url));
|
|
36021
35820
|
function resolvePackageRoot(binDir) {
|
|
36022
35821
|
const canonical = join36(binDir, "..", "..");
|
|
36023
|
-
if (
|
|
35822
|
+
if (existsSync10(join36(canonical, "package.json"))) {
|
|
36024
35823
|
return canonical;
|
|
36025
35824
|
}
|
|
36026
35825
|
return binDir;
|