@akagilnc/pi-workflow-roles 0.1.6017 → 0.1.6021
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/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/acp-host/production-host.js +172 -249
- package/dist/headless-host/production-host.js +181 -258
- package/dist/public-cli/instruction-seat-run.js +9 -146
- package/dist/public-cli/main.js +125 -213
- package/dist/public-cli/post-admission.js +1 -19
- package/dist/report-ticket-tool.js +1 -4
- package/dist/submission-ledger.js +16 -1
- package/package.json +1 -1
- package/resources/ticket-at-receipt.md +1 -0
- package/src/public-cli/instruction-seat-run.ts +9 -182
- package/src/public-cli/post-admission.ts +1 -37
- package/src/report-ticket-tool.ts +1 -5
- package/src/submission-ledger.ts +16 -1
- package/resources/missing-ticket-reask.md +0 -1
|
@@ -4374,6 +4374,67 @@ var init_host_session_record = __esm({
|
|
|
4374
4374
|
}
|
|
4375
4375
|
});
|
|
4376
4376
|
|
|
4377
|
+
// src/session-opening-materials.ts
|
|
4378
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
4379
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
4380
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
4381
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4382
|
+
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
4383
|
+
let dir = dirname6(fileURLToPath(moduleUrl));
|
|
4384
|
+
for (let i = 0; i < 8; i += 1) {
|
|
4385
|
+
if (existsSync2(join8(dir, "package.json")) && existsSync2(join8(dir, "souls"))) {
|
|
4386
|
+
return dir;
|
|
4387
|
+
}
|
|
4388
|
+
const parent = dirname6(dir);
|
|
4389
|
+
if (parent === dir) break;
|
|
4390
|
+
dir = parent;
|
|
4391
|
+
}
|
|
4392
|
+
return fileURLToPath(new URL("..", moduleUrl));
|
|
4393
|
+
}
|
|
4394
|
+
async function readPackageMaterial(relativePath) {
|
|
4395
|
+
return readFile4(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
4396
|
+
}
|
|
4397
|
+
async function joinPackageMaterials(relativePaths) {
|
|
4398
|
+
const chunks = [];
|
|
4399
|
+
for (const relativePath of relativePaths) chunks.push(await readPackageMaterial(relativePath));
|
|
4400
|
+
return chunks.join("\n\n");
|
|
4401
|
+
}
|
|
4402
|
+
function roleSoulPath(role, materials) {
|
|
4403
|
+
const suffix = `/souls/${role}.md`;
|
|
4404
|
+
const path = materials.find((candidate) => `/${candidate}`.endsWith(suffix));
|
|
4405
|
+
if (path === void 0) throw new Error(`session materials omit the ${role} Soul`);
|
|
4406
|
+
return path;
|
|
4407
|
+
}
|
|
4408
|
+
async function loadSeparatedSessionPart(role, materials, part) {
|
|
4409
|
+
const soul = roleSoulPath(role, materials);
|
|
4410
|
+
return part === "soul" ? readPackageMaterial(soul) : joinPackageMaterials(materials.filter((path) => path !== soul));
|
|
4411
|
+
}
|
|
4412
|
+
function loadMainRoleSessionMaterials(role) {
|
|
4413
|
+
return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "soul");
|
|
4414
|
+
}
|
|
4415
|
+
function loadMainRoleReferenceMaterials(role) {
|
|
4416
|
+
return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "references");
|
|
4417
|
+
}
|
|
4418
|
+
var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
|
|
4419
|
+
var init_session_opening_materials = __esm({
|
|
4420
|
+
"src/session-opening-materials.ts"() {
|
|
4421
|
+
"use strict";
|
|
4422
|
+
init_packaged_role_registry();
|
|
4423
|
+
packageRootUrl = pathToFileURL(resolvePackageRootDir() + "/").href;
|
|
4424
|
+
MAIN_ROLE_SESSION_MATERIALS = {
|
|
4425
|
+
...Object.fromEntries(
|
|
4426
|
+
PUBLIC_ROLE_RECORDS.map((record) => [record.role, record.sessionMaterials])
|
|
4427
|
+
)
|
|
4428
|
+
};
|
|
4429
|
+
GATEKEEPER_SESSION_MATERIALS = {
|
|
4430
|
+
// #639: single authority — the public gatekeeper record owns the province list.
|
|
4431
|
+
gatekeeper: packagedRoleSessionMaterials("gatekeeper"),
|
|
4432
|
+
inspector: INSPECTOR_SESSION_MATERIALS,
|
|
4433
|
+
notary: NOTARY_SESSION_MATERIALS
|
|
4434
|
+
};
|
|
4435
|
+
}
|
|
4436
|
+
});
|
|
4437
|
+
|
|
4377
4438
|
// src/submission-correctable-error.ts
|
|
4378
4439
|
function isCorrectableSubmissionError(error) {
|
|
4379
4440
|
return error instanceof CorrectableSubmissionError;
|
|
@@ -4471,14 +4532,14 @@ var init_terminating_tools = __esm({
|
|
|
4471
4532
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
4472
4533
|
import {
|
|
4473
4534
|
appendFileSync as appendFileSync2,
|
|
4474
|
-
existsSync as
|
|
4535
|
+
existsSync as existsSync3,
|
|
4475
4536
|
mkdirSync as mkdirSync3,
|
|
4476
4537
|
readFileSync as readFileSync2,
|
|
4477
4538
|
readdirSync as readdirSync2,
|
|
4478
4539
|
rmSync as rmSync3,
|
|
4479
4540
|
writeFileSync as writeFileSync2
|
|
4480
4541
|
} from "node:fs";
|
|
4481
|
-
import { basename as basename7, dirname as
|
|
4542
|
+
import { basename as basename7, dirname as dirname7, join as join9, relative as relative2, sep as sep3 } from "node:path";
|
|
4482
4543
|
function parseProgressText(text, pathForDiagnostic) {
|
|
4483
4544
|
if (text.trim() === "") return [];
|
|
4484
4545
|
const { records, diagnostics } = parseSitianRecordText(text);
|
|
@@ -4498,20 +4559,20 @@ function parseProgressText(text, pathForDiagnostic) {
|
|
|
4498
4559
|
return lines;
|
|
4499
4560
|
}
|
|
4500
4561
|
function readProgressFile(path) {
|
|
4501
|
-
if (!
|
|
4562
|
+
if (!existsSync3(path)) return [];
|
|
4502
4563
|
return parseProgressText(readFileSync2(path, "utf8"), path);
|
|
4503
4564
|
}
|
|
4504
4565
|
function readTicketProgressLines(subjectDirectory) {
|
|
4505
4566
|
if (basename7(subjectDirectory) === "unbound") {
|
|
4506
|
-
const runsDir =
|
|
4507
|
-
if (!
|
|
4567
|
+
const runsDir = join9(subjectDirectory, "runs");
|
|
4568
|
+
if (!existsSync3(runsDir)) return [];
|
|
4508
4569
|
const out = [];
|
|
4509
4570
|
for (const name of readdirSync2(runsDir).sort()) {
|
|
4510
|
-
out.push(...readProgressFile(
|
|
4571
|
+
out.push(...readProgressFile(join9(runsDir, name, LEG_PROGRESS_FILENAME)));
|
|
4511
4572
|
}
|
|
4512
4573
|
return out;
|
|
4513
4574
|
}
|
|
4514
|
-
return readProgressFile(
|
|
4575
|
+
return readProgressFile(join9(subjectDirectory, CURRENT_FILENAME));
|
|
4515
4576
|
}
|
|
4516
4577
|
function roundBaseNumber(round) {
|
|
4517
4578
|
if (round.trim() === "") return 0;
|
|
@@ -4534,8 +4595,8 @@ function nextRoundFromLines(lines, seat, lens) {
|
|
|
4534
4595
|
return want === void 0 ? String(base) : `${base}.${want}`;
|
|
4535
4596
|
}
|
|
4536
4597
|
function nextLegReceiptIndex(runDirectory) {
|
|
4537
|
-
const dir =
|
|
4538
|
-
if (!
|
|
4598
|
+
const dir = join9(runDirectory, RECEIPTS_DIRNAME);
|
|
4599
|
+
if (!existsSync3(dir)) return 1;
|
|
4539
4600
|
let max = 0;
|
|
4540
4601
|
for (const name of readdirSync2(dir)) {
|
|
4541
4602
|
const match = /^(\d+)\.json$/.exec(name);
|
|
@@ -4619,11 +4680,11 @@ function landTicketProgress(input) {
|
|
|
4619
4680
|
const lens = input.lens === "completeness" || input.lens === "correctness" ? input.lens : lensFromRunDirectory(runDirectory, input.role);
|
|
4620
4681
|
const leaf = basename7(runDirectory);
|
|
4621
4682
|
const unbound = basename7(subjectDirectory) === "unbound";
|
|
4622
|
-
const progressPath = unbound ?
|
|
4683
|
+
const progressPath = unbound ? join9(runDirectory, LEG_PROGRESS_FILENAME) : join9(subjectDirectory, CURRENT_FILENAME);
|
|
4623
4684
|
const receiptIndex = nextLegReceiptIndex(runDirectory);
|
|
4624
4685
|
const relativePath = `runs/${leaf}/${RECEIPTS_DIRNAME}/${receiptIndex}.json`;
|
|
4625
|
-
const absolutePath =
|
|
4626
|
-
mkdirSync3(
|
|
4686
|
+
const absolutePath = join9(subjectDirectory, relativePath);
|
|
4687
|
+
mkdirSync3(dirname7(absolutePath), { recursive: true });
|
|
4627
4688
|
writeFileSync2(absolutePath, `${JSON.stringify(input.accepted, null, 2)}
|
|
4628
4689
|
`, "utf8");
|
|
4629
4690
|
if (!unbound) {
|
|
@@ -4645,7 +4706,7 @@ function landTicketProgress(input) {
|
|
|
4645
4706
|
receipt: relativePath,
|
|
4646
4707
|
session: sessionRelative
|
|
4647
4708
|
};
|
|
4648
|
-
mkdirSync3(
|
|
4709
|
+
mkdirSync3(dirname7(progressPath), { recursive: true });
|
|
4649
4710
|
appendFileSync2(progressPath, `${JSON.stringify(line2)}
|
|
4650
4711
|
`, "utf8");
|
|
4651
4712
|
if (input.sealHead.fault !== void 0) {
|
|
@@ -4658,10 +4719,10 @@ function relocateTicketProgressForLeg(input) {
|
|
|
4658
4719
|
if (isUnboundRunDirectory(input.runDirectory)) return;
|
|
4659
4720
|
const subjectDirectory = subjectDirectoryOfRun(input.runDirectory);
|
|
4660
4721
|
if (subjectDirectory === void 0) return;
|
|
4661
|
-
const stagedPath =
|
|
4722
|
+
const stagedPath = join9(input.runDirectory, LEG_PROGRESS_FILENAME);
|
|
4662
4723
|
const mine = readProgressFile(stagedPath);
|
|
4663
4724
|
if (mine.length === 0) {
|
|
4664
|
-
if (
|
|
4725
|
+
if (existsSync3(stagedPath)) {
|
|
4665
4726
|
rmSync3(stagedPath, { force: true });
|
|
4666
4727
|
}
|
|
4667
4728
|
return;
|
|
@@ -4686,8 +4747,8 @@ function relocateTicketProgressForLeg(input) {
|
|
|
4686
4747
|
movedLines.push(moved);
|
|
4687
4748
|
ticketLines.push(moved);
|
|
4688
4749
|
}
|
|
4689
|
-
const newCurrent =
|
|
4690
|
-
mkdirSync3(
|
|
4750
|
+
const newCurrent = join9(subjectDirectory, CURRENT_FILENAME);
|
|
4751
|
+
mkdirSync3(dirname7(newCurrent), { recursive: true });
|
|
4691
4752
|
appendFileSync2(
|
|
4692
4753
|
newCurrent,
|
|
4693
4754
|
`${movedLines.map((line2) => JSON.stringify(line2)).join("\n")}
|
|
@@ -4726,8 +4787,8 @@ var init_sha256 = __esm({
|
|
|
4726
4787
|
});
|
|
4727
4788
|
|
|
4728
4789
|
// src/doctor-evidence.ts
|
|
4729
|
-
import { readdir as readdir2, readFile as
|
|
4730
|
-
import { dirname as
|
|
4790
|
+
import { readdir as readdir2, readFile as readFile5, realpath, stat } from "node:fs/promises";
|
|
4791
|
+
import { dirname as dirname8, relative as relative3, resolve as resolve4, sep as sep4 } from "node:path";
|
|
4731
4792
|
async function discoverCaseFiles(root) {
|
|
4732
4793
|
const found = [];
|
|
4733
4794
|
async function walk(dir, depth) {
|
|
@@ -4760,7 +4821,7 @@ async function stableRunsIdentity(root) {
|
|
|
4760
4821
|
} catch (error) {
|
|
4761
4822
|
if (!isMissingPathError(error)) throw error;
|
|
4762
4823
|
}
|
|
4763
|
-
const parent =
|
|
4824
|
+
const parent = dirname8(cursor);
|
|
4764
4825
|
if (parent === cursor) return root;
|
|
4765
4826
|
cursor = parent;
|
|
4766
4827
|
}
|
|
@@ -4839,7 +4900,7 @@ async function loadDoctorCase(runsPath, projectRoot) {
|
|
|
4839
4900
|
const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
|
|
4840
4901
|
for (const path of await discoverCaseFiles(root)) {
|
|
4841
4902
|
const id = relative3(root, path).split(sep4).join("/");
|
|
4842
|
-
const bytes = await
|
|
4903
|
+
const bytes = await readFile5(path);
|
|
4843
4904
|
const content = bytes.toString("utf8");
|
|
4844
4905
|
const kind = id.split("/").length === 2 && id.endsWith("/log.jsonl") ? "log" : "session";
|
|
4845
4906
|
evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
|
|
@@ -4917,7 +4978,7 @@ var init_git_object_id = __esm({
|
|
|
4917
4978
|
|
|
4918
4979
|
// src/merger-git-state.ts
|
|
4919
4980
|
import { execFile } from "node:child_process";
|
|
4920
|
-
import { access, readFile as
|
|
4981
|
+
import { access, readFile as readFile6 } from "node:fs/promises";
|
|
4921
4982
|
import { constants as fsConstants } from "node:fs";
|
|
4922
4983
|
import { isAbsolute as isAbsolute3, resolve as resolve5 } from "node:path";
|
|
4923
4984
|
import { promisify } from "node:util";
|
|
@@ -4987,7 +5048,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
|
|
|
4987
5048
|
const mergeHeadPath = isAbsolute3(mergeHeadReported) ? mergeHeadReported : resolve5(repositoryRoot, mergeHeadReported);
|
|
4988
5049
|
let sourceObjectId = "";
|
|
4989
5050
|
if (await pathExists(mergeHeadPath)) {
|
|
4990
|
-
const raw = exactUtf8(await
|
|
5051
|
+
const raw = exactUtf8(await readFile6(mergeHeadPath), "Git MERGE_HEAD");
|
|
4991
5052
|
const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
|
|
4992
5053
|
if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
|
|
4993
5054
|
if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
|
|
@@ -5130,14 +5191,14 @@ var init_session_dialogue = __esm({
|
|
|
5130
5191
|
});
|
|
5131
5192
|
|
|
5132
5193
|
// src/ticket-provenance.ts
|
|
5133
|
-
import { readFile as
|
|
5134
|
-
import { join as
|
|
5194
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
5195
|
+
import { join as join10, resolve as resolve6 } from "node:path";
|
|
5135
5196
|
function dialogueSessionSourceRoots(home) {
|
|
5136
5197
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
5137
5198
|
return [
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5199
|
+
join10(machineHome, ".claude", "projects"),
|
|
5200
|
+
join10(machineHome, ".codex", "sessions"),
|
|
5201
|
+
join10(machineHome, ".pi", "agent", "sessions")
|
|
5141
5202
|
];
|
|
5142
5203
|
}
|
|
5143
5204
|
function isLedgerRoleSessionFile(absolute, home) {
|
|
@@ -5178,7 +5239,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
|
|
|
5178
5239
|
const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
|
|
5179
5240
|
let history;
|
|
5180
5241
|
try {
|
|
5181
|
-
history = await
|
|
5242
|
+
history = await readFile7(join10(runDirectory, RUN_HISTORY_FILE), "utf8");
|
|
5182
5243
|
} catch (error) {
|
|
5183
5244
|
if (errnoCode(error) === "ENOENT") return;
|
|
5184
5245
|
throw error;
|
|
@@ -5395,7 +5456,7 @@ var init_uuidv7 = __esm({
|
|
|
5395
5456
|
});
|
|
5396
5457
|
|
|
5397
5458
|
// src/notary-source-run.ts
|
|
5398
|
-
import { dirname as
|
|
5459
|
+
import { dirname as dirname9, isAbsolute as isAbsolute4, join as join11, resolve as resolve7, basename as basename8 } from "node:path";
|
|
5399
5460
|
import { lstat, realpath as realpath2 } from "node:fs/promises";
|
|
5400
5461
|
async function readRetainedIdentity(runDirectory) {
|
|
5401
5462
|
try {
|
|
@@ -5447,16 +5508,16 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5447
5508
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
5448
5509
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
5449
5510
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
5450
|
-
const bookRunsRoot =
|
|
5511
|
+
const bookRunsRoot = join11(bookDirectory, "runs");
|
|
5451
5512
|
let candidate;
|
|
5452
5513
|
const bare = parseRunLeaf(raw);
|
|
5453
5514
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
5454
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
5515
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join11(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
|
|
5455
5516
|
} else {
|
|
5456
5517
|
candidate = isAbsolute4(raw) ? raw : resolve7(options.projectRoot, raw);
|
|
5457
5518
|
const identity2 = parseRunLeaf(basename8(candidate));
|
|
5458
|
-
const subjectDirectory =
|
|
5459
|
-
const isLegacyUnboundLocator = identity2 !== void 0 && basename8(
|
|
5519
|
+
const subjectDirectory = dirname9(dirname9(candidate));
|
|
5520
|
+
const isLegacyUnboundLocator = identity2 !== void 0 && basename8(dirname9(candidate)) === "runs" && basename8(subjectDirectory) === "unbound" && resolve7(dirname9(subjectDirectory)) === resolve7(bookDirectory);
|
|
5460
5521
|
if (isLegacyUnboundLocator) {
|
|
5461
5522
|
candidate = await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey) ?? candidate;
|
|
5462
5523
|
}
|
|
@@ -5464,9 +5525,9 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5464
5525
|
const real = await requireRunDirectory(candidate, raw);
|
|
5465
5526
|
const identity = parseRunLeaf(basename8(real));
|
|
5466
5527
|
const bookIdentity = physicalPathIdentity(bookDirectory);
|
|
5467
|
-
const parentIdentity = physicalPathIdentity(
|
|
5468
|
-
const subjectBookIdentity = physicalPathIdentity(
|
|
5469
|
-
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename8(
|
|
5528
|
+
const parentIdentity = physicalPathIdentity(dirname9(real));
|
|
5529
|
+
const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
|
|
5530
|
+
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename8(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
5470
5531
|
throw new NotarySourceRunError(
|
|
5471
5532
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
5472
5533
|
);
|
|
@@ -6683,14 +6744,14 @@ var init_option_definitions = __esm({
|
|
|
6683
6744
|
|
|
6684
6745
|
// src/public-cli/invocation.ts
|
|
6685
6746
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6686
|
-
import { existsSync as
|
|
6747
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
6687
6748
|
import {
|
|
6688
|
-
readFile as
|
|
6749
|
+
readFile as readFile8,
|
|
6689
6750
|
realpath as realpath3,
|
|
6690
6751
|
rename,
|
|
6691
6752
|
writeFile
|
|
6692
6753
|
} from "node:fs/promises";
|
|
6693
|
-
import { dirname as
|
|
6754
|
+
import { dirname as dirname10, isAbsolute as isAbsolute5, join as join12, resolve as resolve8 } from "node:path";
|
|
6694
6755
|
function admittedSourceRunPath(admitted) {
|
|
6695
6756
|
if (!isRecord(admitted)) return void 0;
|
|
6696
6757
|
const path = admitted.sourceRunPath;
|
|
@@ -6865,7 +6926,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
6865
6926
|
runId: childRunId,
|
|
6866
6927
|
role: "diarist"
|
|
6867
6928
|
}).runDirectory;
|
|
6868
|
-
if (
|
|
6929
|
+
if (existsSync4(unboundChildDirectory)) {
|
|
6869
6930
|
input.authority.seal(childTarget);
|
|
6870
6931
|
await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
|
|
6871
6932
|
await rehomeUnboundTicketProvenance(
|
|
@@ -6874,7 +6935,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
6874
6935
|
input.projectRoot,
|
|
6875
6936
|
homeFromRunDirectory(input.parentRunDirectory)
|
|
6876
6937
|
);
|
|
6877
|
-
ensureRoleRunDirectory(input.ledgerHome,
|
|
6938
|
+
ensureRoleRunDirectory(input.ledgerHome, dirname10(childTarget.runDirectory));
|
|
6878
6939
|
await rename(unboundChildDirectory, childTarget.runDirectory);
|
|
6879
6940
|
relocateTicketProgressForLeg({
|
|
6880
6941
|
runDirectory: childTarget.runDirectory
|
|
@@ -6889,7 +6950,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
6889
6950
|
}
|
|
6890
6951
|
continue;
|
|
6891
6952
|
}
|
|
6892
|
-
if (
|
|
6953
|
+
if (existsSync4(childTarget.runDirectory)) {
|
|
6893
6954
|
relocateTicketProgressForLeg({
|
|
6894
6955
|
runDirectory: childTarget.runDirectory
|
|
6895
6956
|
});
|
|
@@ -6922,7 +6983,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
6922
6983
|
runId: admitted.runId,
|
|
6923
6984
|
role: admitted.role
|
|
6924
6985
|
});
|
|
6925
|
-
ensureRoleRunDirectory(ledgerHome,
|
|
6986
|
+
ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
|
|
6926
6987
|
authority.seal(target);
|
|
6927
6988
|
if (admitted.role !== "diarist") {
|
|
6928
6989
|
await relocateRegisteredChildDiarists({
|
|
@@ -6987,7 +7048,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
6987
7048
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
6988
7049
|
const rolePackageRoot = packageRoot;
|
|
6989
7050
|
const raw = JSON.parse(
|
|
6990
|
-
await
|
|
7051
|
+
await readFile8(join12(rolePackageRoot, "package.json"), "utf8")
|
|
6991
7052
|
);
|
|
6992
7053
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
6993
7054
|
throw new Error(
|
|
@@ -7558,7 +7619,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7558
7619
|
resolutionScope: [...derived.resolutionScope],
|
|
7559
7620
|
authorizedChecks: []
|
|
7560
7621
|
});
|
|
7561
|
-
const mergerInputPath =
|
|
7622
|
+
const mergerInputPath = join12(placed.runDirectory, "merger-input.json");
|
|
7562
7623
|
await writeFile(
|
|
7563
7624
|
mergerInputPath,
|
|
7564
7625
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -7826,7 +7887,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
7826
7887
|
}
|
|
7827
7888
|
async function resolveDoctorCaseRunsPath(options) {
|
|
7828
7889
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
7829
|
-
const defaultRuns =
|
|
7890
|
+
const defaultRuns = join12(
|
|
7830
7891
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
7831
7892
|
String(options.issueNumber),
|
|
7832
7893
|
"runs"
|
|
@@ -8124,7 +8185,7 @@ var init_invocation = __esm({
|
|
|
8124
8185
|
|
|
8125
8186
|
// src/report-ticket-tool.ts
|
|
8126
8187
|
import { Type as Type16 } from "typebox";
|
|
8127
|
-
import { existsSync as
|
|
8188
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
8128
8189
|
function pageString(page, key) {
|
|
8129
8190
|
const value = page?.[key];
|
|
8130
8191
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
@@ -8162,7 +8223,7 @@ async function reportTicketFromHostContext(context, ticketNumber, authority = pi
|
|
|
8162
8223
|
if (runDirectory === void 0) {
|
|
8163
8224
|
throw new Error("ak_report_ticket requires a per-turn run directory");
|
|
8164
8225
|
}
|
|
8165
|
-
if (!
|
|
8226
|
+
if (!existsSync5(runDirectory)) {
|
|
8166
8227
|
throw new Error(`ak_report_ticket run directory missing: ${runDirectory}`);
|
|
8167
8228
|
}
|
|
8168
8229
|
const admitted = admittedForLiveTicketReport(runDirectory, authority);
|
|
@@ -8219,7 +8280,7 @@ function registerReportTicketTool(roleHost, hostActions) {
|
|
|
8219
8280
|
}
|
|
8220
8281
|
});
|
|
8221
8282
|
}
|
|
8222
|
-
var REPORT_TICKET_TOOL_NAME, reportTicketArgsSchema, REPORT_TICKET_TOOL_DESCRIPTION
|
|
8283
|
+
var REPORT_TICKET_TOOL_NAME, reportTicketArgsSchema, REPORT_TICKET_TOOL_DESCRIPTION;
|
|
8223
8284
|
var init_report_ticket_tool = __esm({
|
|
8224
8285
|
"src/report-ticket-tool.ts"() {
|
|
8225
8286
|
"use strict";
|
|
@@ -8240,8 +8301,7 @@ var init_report_ticket_tool = __esm({
|
|
|
8240
8301
|
},
|
|
8241
8302
|
{ additionalProperties: true }
|
|
8242
8303
|
);
|
|
8243
|
-
REPORT_TICKET_TOOL_DESCRIPTION = "\u5411\u5305\u7533\u62A5\u672C\u7968\u53F7\u3002\u5DF2\u77E5\u7968\u53F7\u65F6\u5F00\u5DE5\u7B2C\u4E00\u4EF6\u4E8B\u8C03\u7528\uFF1B\u5305\u5F53\u573A\u628A\u672C\u817F\u5F52\u5230\u7968\u53F7\u76EE\u5F55\u3002\u5C1A\u65E0\u7968\u53F7\uFF08\u4F8B\u5982\u4E2D\u4E66\u7701\u5EFA\u7968\u524D\uFF09\u4E0D\u8981\u8C03\u7528\uFF0C\u53D6\u5F97\u540E\u518D\u62A5\u3002
|
|
8244
|
-
MISSING_TICKET_REASK_MATERIAL = "resources/missing-ticket-reask.md";
|
|
8304
|
+
REPORT_TICKET_TOOL_DESCRIPTION = "\u5411\u5305\u7533\u62A5\u672C\u7968\u53F7\u3002\u5DF2\u77E5\u7968\u53F7\u65F6\u5F00\u5DE5\u7B2C\u4E00\u4EF6\u4E8B\u8C03\u7528\uFF1B\u5305\u5F53\u573A\u628A\u672C\u817F\u5F52\u5230\u7968\u53F7\u76EE\u5F55\u3002\u5C1A\u65E0\u7968\u53F7\uFF08\u4F8B\u5982\u4E2D\u4E66\u7701\u5EFA\u7968\u524D\uFF09\u4E0D\u8981\u8C03\u7528\uFF0C\u53D6\u5F97\u540E\u518D\u62A5\u3002";
|
|
8245
8305
|
}
|
|
8246
8306
|
});
|
|
8247
8307
|
|
|
@@ -8613,6 +8673,17 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
8613
8673
|
sealHead,
|
|
8614
8674
|
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
|
|
8615
8675
|
});
|
|
8676
|
+
const runDirectory = runDirectoryFromHostContext(context);
|
|
8677
|
+
if (context.host !== "claude" && context.host !== "codex" && runDirectory !== void 0 && isUnboundRunDirectory(runDirectory)) {
|
|
8678
|
+
result = {
|
|
8679
|
+
...result,
|
|
8680
|
+
terminate: false,
|
|
8681
|
+
content: [...result.content, {
|
|
8682
|
+
type: "text",
|
|
8683
|
+
text: (await readPackageMaterial("resources/ticket-at-receipt.md")).trim()
|
|
8684
|
+
}]
|
|
8685
|
+
};
|
|
8686
|
+
}
|
|
8616
8687
|
} catch (error) {
|
|
8617
8688
|
if (toolThrew) throw error;
|
|
8618
8689
|
return failInfrastructure2(error, context, toolCallId);
|
|
@@ -8628,6 +8699,7 @@ var init_submission_ledger = __esm({
|
|
|
8628
8699
|
"src/submission-ledger.ts"() {
|
|
8629
8700
|
"use strict";
|
|
8630
8701
|
init_role_run_placement();
|
|
8702
|
+
init_session_opening_materials();
|
|
8631
8703
|
init_activation_ledger_topology();
|
|
8632
8704
|
init_host_contracts();
|
|
8633
8705
|
init_run_terminal_artifacts();
|
|
@@ -8823,7 +8895,7 @@ var init_engine_detour_usage = __esm({
|
|
|
8823
8895
|
});
|
|
8824
8896
|
|
|
8825
8897
|
// src/dossier-resolution.ts
|
|
8826
|
-
import { existsSync as
|
|
8898
|
+
import { existsSync as existsSync6, statSync as statSync4 } from "node:fs";
|
|
8827
8899
|
import { resolve as resolve9 } from "node:path";
|
|
8828
8900
|
function isHostContext(value) {
|
|
8829
8901
|
return "sessionManager" in value;
|
|
@@ -8843,7 +8915,7 @@ function resolveAuditDossier(source) {
|
|
|
8843
8915
|
}
|
|
8844
8916
|
const runDirectory = resolve9(raw);
|
|
8845
8917
|
try {
|
|
8846
|
-
if (!
|
|
8918
|
+
if (!existsSync6(runDirectory) || !statSync4(runDirectory).isDirectory()) {
|
|
8847
8919
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
8848
8920
|
}
|
|
8849
8921
|
} catch {
|
|
@@ -10134,7 +10206,7 @@ var init_settlement = __esm({
|
|
|
10134
10206
|
});
|
|
10135
10207
|
|
|
10136
10208
|
// src/external-host-turn-loop.ts
|
|
10137
|
-
import { existsSync as
|
|
10209
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
10138
10210
|
import { basename as basename9 } from "node:path";
|
|
10139
10211
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
10140
10212
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
@@ -10158,7 +10230,7 @@ async function trySyncTurnRequestLivePlacement(request, authority) {
|
|
|
10158
10230
|
}
|
|
10159
10231
|
async function retainPackageFaultBesideLivePlacement(request, input) {
|
|
10160
10232
|
let runDirectory = request.runDirectory;
|
|
10161
|
-
if (!
|
|
10233
|
+
if (!existsSync7(runDirectory)) {
|
|
10162
10234
|
try {
|
|
10163
10235
|
const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
10164
10236
|
if (found === void 0) {
|
|
@@ -10372,7 +10444,7 @@ var init_external_host_turn_loop = __esm({
|
|
|
10372
10444
|
});
|
|
10373
10445
|
|
|
10374
10446
|
// src/session-identity.ts
|
|
10375
|
-
import { join as
|
|
10447
|
+
import { join as join13 } from "node:path";
|
|
10376
10448
|
function createSessionIdentityAuthority(authority, hostName) {
|
|
10377
10449
|
const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
|
|
10378
10450
|
return {
|
|
@@ -10382,7 +10454,7 @@ function createSessionIdentityAuthority(authority, hostName) {
|
|
|
10382
10454
|
},
|
|
10383
10455
|
async load(principal) {
|
|
10384
10456
|
const runDirectory = runDirectoryOf(principal);
|
|
10385
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
10457
|
+
const { records, diagnostics } = await readSitianRecords(join13(runDirectory, RUN_STATE_FILE));
|
|
10386
10458
|
if (diagnostics.length > 0) {
|
|
10387
10459
|
throw new Error(
|
|
10388
10460
|
`${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
|
|
@@ -10452,14 +10524,14 @@ __export(role_turn_host_exports, {
|
|
|
10452
10524
|
});
|
|
10453
10525
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
10454
10526
|
import { constants } from "node:fs";
|
|
10455
|
-
import { existsSync as
|
|
10527
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
10456
10528
|
import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
|
|
10457
|
-
import { delimiter, dirname as
|
|
10529
|
+
import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join14, resolve as resolve11 } from "node:path";
|
|
10458
10530
|
import { platform } from "node:process";
|
|
10459
10531
|
import { promisify as promisify2 } from "node:util";
|
|
10460
10532
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
10461
10533
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
10462
|
-
return
|
|
10534
|
+
return join14(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
10463
10535
|
}
|
|
10464
10536
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
10465
10537
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -10487,7 +10559,7 @@ function buildMethodArgs(methods) {
|
|
|
10487
10559
|
const skillArgs = [];
|
|
10488
10560
|
for (const method of methods) {
|
|
10489
10561
|
if (method.kind === "skill") {
|
|
10490
|
-
skillArgs.push("--skill",
|
|
10562
|
+
skillArgs.push("--skill", dirname11(method.path));
|
|
10491
10563
|
}
|
|
10492
10564
|
}
|
|
10493
10565
|
return skillArgs;
|
|
@@ -10649,7 +10721,7 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
10649
10721
|
homeFromRunDirectory(spawnDir)
|
|
10650
10722
|
);
|
|
10651
10723
|
} catch (resolveError) {
|
|
10652
|
-
runDirectory =
|
|
10724
|
+
runDirectory = existsSync8(spawnDir) ? spawnDir : void 0;
|
|
10653
10725
|
const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
|
|
10654
10726
|
if (runDirectory !== void 0) {
|
|
10655
10727
|
await retainPackageFault({
|
|
@@ -10851,8 +10923,8 @@ var init_role_turn_host = __esm({
|
|
|
10851
10923
|
});
|
|
10852
10924
|
|
|
10853
10925
|
// src/package-resources/engine-material.ts
|
|
10854
|
-
import { existsSync as
|
|
10855
|
-
import { join as
|
|
10926
|
+
import { existsSync as existsSync9, readFileSync as readFileSync3 } from "node:fs";
|
|
10927
|
+
import { join as join15 } from "node:path";
|
|
10856
10928
|
function pickEngineAxis(source) {
|
|
10857
10929
|
return {
|
|
10858
10930
|
...source.engine === void 0 ? {} : { engine: source.engine },
|
|
@@ -10873,14 +10945,14 @@ function isEngineNameSyntax(name) {
|
|
|
10873
10945
|
return true;
|
|
10874
10946
|
}
|
|
10875
10947
|
function resolveEngineMaterialDirectory(packageRoot) {
|
|
10876
|
-
return
|
|
10948
|
+
return join15(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
10877
10949
|
}
|
|
10878
10950
|
function resolveEngineDispatchMaterialPath(packageRoot) {
|
|
10879
|
-
return
|
|
10951
|
+
return join15(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
|
|
10880
10952
|
}
|
|
10881
10953
|
function resolveEngineMaterialPath(packageRoot, name) {
|
|
10882
10954
|
const legal = assertLegalEngineName(name);
|
|
10883
|
-
return
|
|
10955
|
+
return join15(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
|
|
10884
10956
|
}
|
|
10885
10957
|
function assertLegalEngineName(name) {
|
|
10886
10958
|
if (!isEngineNameSyntax(name)) {
|
|
@@ -10897,12 +10969,12 @@ function engineSessionMaterialFromOptions(options) {
|
|
|
10897
10969
|
const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
|
|
10898
10970
|
const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
|
|
10899
10971
|
const modelField = model === void 0 ? {} : { model };
|
|
10900
|
-
if (!
|
|
10972
|
+
if (!existsSync9(materialPath)) {
|
|
10901
10973
|
return Object.freeze({ name, ...modelField });
|
|
10902
10974
|
}
|
|
10903
10975
|
const handbook = readFileSync3(materialPath, "utf8");
|
|
10904
10976
|
const dispatchPath = resolveEngineDispatchMaterialPath(options.packageRoot);
|
|
10905
|
-
const dispatchField =
|
|
10977
|
+
const dispatchField = existsSync9(dispatchPath) ? { dispatchHandbook: readFileSync3(dispatchPath, "utf8") } : {};
|
|
10906
10978
|
return Object.freeze({ name, handbook, ...dispatchField, ...modelField });
|
|
10907
10979
|
}
|
|
10908
10980
|
function engineSessionReadingMaterial(engineMaterial) {
|
|
@@ -11064,8 +11136,8 @@ __export(config_exports, {
|
|
|
11064
11136
|
setPersistentSeatHost: () => setPersistentSeatHost,
|
|
11065
11137
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
11066
11138
|
});
|
|
11067
|
-
import { mkdir, readFile as
|
|
11068
|
-
import { dirname as
|
|
11139
|
+
import { mkdir, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
|
|
11140
|
+
import { dirname as dirname12, join as join16 } from "node:path";
|
|
11069
11141
|
function isGateOfficerSeat(value) {
|
|
11070
11142
|
return packagedProvinceConfig(value);
|
|
11071
11143
|
}
|
|
@@ -11073,12 +11145,12 @@ function publicCliConfigPath(home) {
|
|
|
11073
11145
|
if (typeof home !== "string" || home.trim() === "") {
|
|
11074
11146
|
throw new Error("home must be explicitly provided");
|
|
11075
11147
|
}
|
|
11076
|
-
return
|
|
11148
|
+
return join16(home, ".ak-roles", "public-cli.json");
|
|
11077
11149
|
}
|
|
11078
11150
|
async function loadPublicCliConfig(home) {
|
|
11079
11151
|
const path = publicCliConfigPath(home);
|
|
11080
11152
|
try {
|
|
11081
|
-
const raw = await
|
|
11153
|
+
const raw = await readFile9(path, "utf8");
|
|
11082
11154
|
return parsePublicCliConfig(JSON.parse(raw));
|
|
11083
11155
|
} catch (error) {
|
|
11084
11156
|
if (isEnoent(error)) return { seats: {} };
|
|
@@ -11087,7 +11159,7 @@ async function loadPublicCliConfig(home) {
|
|
|
11087
11159
|
}
|
|
11088
11160
|
async function savePublicCliConfig(config, home) {
|
|
11089
11161
|
const path = publicCliConfigPath(home);
|
|
11090
|
-
await mkdir(
|
|
11162
|
+
await mkdir(dirname12(path), { recursive: true });
|
|
11091
11163
|
const normalized = parsePublicCliConfig(config);
|
|
11092
11164
|
await writeFile2(
|
|
11093
11165
|
path,
|
|
@@ -11533,11 +11605,11 @@ function credentialProvidersFromAuthData(data) {
|
|
|
11533
11605
|
};
|
|
11534
11606
|
}
|
|
11535
11607
|
function resolvePublicAgentDir(explicit, home) {
|
|
11536
|
-
return explicit ?? process.env.PI_CODING_AGENT_DIR ??
|
|
11608
|
+
return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join16(home, ".pi", "agent");
|
|
11537
11609
|
}
|
|
11538
11610
|
async function loadCredentialProviders(agentDir) {
|
|
11539
11611
|
try {
|
|
11540
|
-
const raw = await
|
|
11612
|
+
const raw = await readFile9(join16(agentDir, "auth.json"), "utf8");
|
|
11541
11613
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
11542
11614
|
} catch (error) {
|
|
11543
11615
|
if (isEnoent(error)) return { "openai-codex": false, xai: false };
|
|
@@ -11558,15 +11630,15 @@ var init_config = __esm({
|
|
|
11558
11630
|
|
|
11559
11631
|
// src/public-cli/host-providers.ts
|
|
11560
11632
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
11561
|
-
import { join as
|
|
11633
|
+
import { join as join17 } from "node:path";
|
|
11562
11634
|
function hostProvidersPath(home) {
|
|
11563
11635
|
if (typeof home !== "string" || home.trim() === "") {
|
|
11564
11636
|
throw new Error("home must be explicitly provided");
|
|
11565
11637
|
}
|
|
11566
|
-
return
|
|
11638
|
+
return join17(home, ".ak-roles", "host-providers.json");
|
|
11567
11639
|
}
|
|
11568
11640
|
function hermesProviderModelsCachePath(home) {
|
|
11569
|
-
return
|
|
11641
|
+
return join17(home, ".hermes", "provider_models_cache.json");
|
|
11570
11642
|
}
|
|
11571
11643
|
function parseHostProvidersTable(value) {
|
|
11572
11644
|
if (!isRecord(value)) {
|
|
@@ -11716,18 +11788,18 @@ var init_host_providers = __esm({
|
|
|
11716
11788
|
});
|
|
11717
11789
|
|
|
11718
11790
|
// src/public-cli/load-production-acp-host.ts
|
|
11719
|
-
import { existsSync as
|
|
11720
|
-
import { join as
|
|
11721
|
-
import { pathToFileURL } from "node:url";
|
|
11791
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
11792
|
+
import { join as join18 } from "node:path";
|
|
11793
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
11722
11794
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
11723
11795
|
const description = lookupHostDescription(host);
|
|
11724
11796
|
if (description === void 0) {
|
|
11725
11797
|
throw new Error(`unregistered host: ${host}`);
|
|
11726
11798
|
}
|
|
11727
|
-
const built =
|
|
11728
|
-
const source =
|
|
11729
|
-
const target =
|
|
11730
|
-
const href =
|
|
11799
|
+
const built = join18(packageRoot, "dist/acp-host/production-host.js");
|
|
11800
|
+
const source = join18(packageRoot, "src/acp-host/production-host.ts");
|
|
11801
|
+
const target = existsSync10(built) ? built : source;
|
|
11802
|
+
const href = pathToFileURL2(target).href;
|
|
11731
11803
|
const mod = await import(href);
|
|
11732
11804
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
11733
11805
|
return (options) => create({ ...options, description, hostName: host });
|
|
@@ -11740,18 +11812,18 @@ var init_load_production_acp_host = __esm({
|
|
|
11740
11812
|
});
|
|
11741
11813
|
|
|
11742
11814
|
// src/public-cli/load-production-headless-host.ts
|
|
11743
|
-
import { existsSync as
|
|
11744
|
-
import { join as
|
|
11745
|
-
import { pathToFileURL as
|
|
11815
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
11816
|
+
import { join as join19 } from "node:path";
|
|
11817
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11746
11818
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
11747
11819
|
const description = lookupHeadlessHostDescription(host);
|
|
11748
11820
|
if (description === void 0) {
|
|
11749
11821
|
throw new Error(`unregistered headless host: ${host}`);
|
|
11750
11822
|
}
|
|
11751
|
-
const built =
|
|
11752
|
-
const source =
|
|
11753
|
-
const target =
|
|
11754
|
-
const href =
|
|
11823
|
+
const built = join19(packageRoot, "dist/headless-host/production-host.js");
|
|
11824
|
+
const source = join19(packageRoot, "src/headless-host/production-host.ts");
|
|
11825
|
+
const target = existsSync11(built) ? built : source;
|
|
11826
|
+
const href = pathToFileURL3(target).href;
|
|
11755
11827
|
const mod = await import(href);
|
|
11756
11828
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
11757
11829
|
return (options) => create({ ...options, description, hostName: host });
|
|
@@ -11927,67 +11999,6 @@ var init_role_seat_runtime = __esm({
|
|
|
11927
11999
|
}
|
|
11928
12000
|
});
|
|
11929
12001
|
|
|
11930
|
-
// src/session-opening-materials.ts
|
|
11931
|
-
import { existsSync as existsSync11 } from "node:fs";
|
|
11932
|
-
import { readFile as readFile9 } from "node:fs/promises";
|
|
11933
|
-
import { dirname as dirname12, join as join19 } from "node:path";
|
|
11934
|
-
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11935
|
-
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
11936
|
-
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
11937
|
-
for (let i = 0; i < 8; i += 1) {
|
|
11938
|
-
if (existsSync11(join19(dir, "package.json")) && existsSync11(join19(dir, "souls"))) {
|
|
11939
|
-
return dir;
|
|
11940
|
-
}
|
|
11941
|
-
const parent = dirname12(dir);
|
|
11942
|
-
if (parent === dir) break;
|
|
11943
|
-
dir = parent;
|
|
11944
|
-
}
|
|
11945
|
-
return fileURLToPath(new URL("..", moduleUrl));
|
|
11946
|
-
}
|
|
11947
|
-
async function readPackageMaterial(relativePath) {
|
|
11948
|
-
return readFile9(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
11949
|
-
}
|
|
11950
|
-
async function joinPackageMaterials(relativePaths) {
|
|
11951
|
-
const chunks = [];
|
|
11952
|
-
for (const relativePath of relativePaths) chunks.push(await readPackageMaterial(relativePath));
|
|
11953
|
-
return chunks.join("\n\n");
|
|
11954
|
-
}
|
|
11955
|
-
function roleSoulPath(role, materials) {
|
|
11956
|
-
const suffix = `/souls/${role}.md`;
|
|
11957
|
-
const path = materials.find((candidate) => `/${candidate}`.endsWith(suffix));
|
|
11958
|
-
if (path === void 0) throw new Error(`session materials omit the ${role} Soul`);
|
|
11959
|
-
return path;
|
|
11960
|
-
}
|
|
11961
|
-
async function loadSeparatedSessionPart(role, materials, part) {
|
|
11962
|
-
const soul = roleSoulPath(role, materials);
|
|
11963
|
-
return part === "soul" ? readPackageMaterial(soul) : joinPackageMaterials(materials.filter((path) => path !== soul));
|
|
11964
|
-
}
|
|
11965
|
-
function loadMainRoleSessionMaterials(role) {
|
|
11966
|
-
return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "soul");
|
|
11967
|
-
}
|
|
11968
|
-
function loadMainRoleReferenceMaterials(role) {
|
|
11969
|
-
return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "references");
|
|
11970
|
-
}
|
|
11971
|
-
var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
|
|
11972
|
-
var init_session_opening_materials = __esm({
|
|
11973
|
-
"src/session-opening-materials.ts"() {
|
|
11974
|
-
"use strict";
|
|
11975
|
-
init_packaged_role_registry();
|
|
11976
|
-
packageRootUrl = pathToFileURL3(resolvePackageRootDir() + "/").href;
|
|
11977
|
-
MAIN_ROLE_SESSION_MATERIALS = {
|
|
11978
|
-
...Object.fromEntries(
|
|
11979
|
-
PUBLIC_ROLE_RECORDS.map((record) => [record.role, record.sessionMaterials])
|
|
11980
|
-
)
|
|
11981
|
-
};
|
|
11982
|
-
GATEKEEPER_SESSION_MATERIALS = {
|
|
11983
|
-
// #639: single authority — the public gatekeeper record owns the province list.
|
|
11984
|
-
gatekeeper: packagedRoleSessionMaterials("gatekeeper"),
|
|
11985
|
-
inspector: INSPECTOR_SESSION_MATERIALS,
|
|
11986
|
-
notary: NOTARY_SESSION_MATERIALS
|
|
11987
|
-
};
|
|
11988
|
-
}
|
|
11989
|
-
});
|
|
11990
|
-
|
|
11991
12002
|
// src/doctor-auditor.ts
|
|
11992
12003
|
function createPiDoctorAuditor() {
|
|
11993
12004
|
return async (options) => {
|
|
@@ -13427,12 +13438,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13427
13438
|
}
|
|
13428
13439
|
if (pendingSettlement !== void 0 && pendingTerminal !== void 0 && result.terminal === pendingTerminal) {
|
|
13429
13440
|
try {
|
|
13430
|
-
const
|
|
13431
|
-
const noSealScope = softTicketReaskNoSeal ? {
|
|
13432
|
-
...courtScope,
|
|
13433
|
-
previewOnly: true,
|
|
13434
|
-
recordAttemptHistory: true
|
|
13435
|
-
} : { ...courtScope, recordAttemptHistory: true };
|
|
13441
|
+
const noSealScope = { ...courtScope, recordAttemptHistory: true };
|
|
13436
13442
|
const terminal = pendingSettlement === "sealed" ? await adapters.trySettle(
|
|
13437
13443
|
admitted,
|
|
13438
13444
|
env.principalAuthority,
|
|
@@ -13449,9 +13455,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13449
13455
|
);
|
|
13450
13456
|
if (terminal === void 0) throw new Error("settled host attempt vanished before publication");
|
|
13451
13457
|
result = { ...result, terminal, exitCode: exitCodeForTerminalOutcome(terminal.roleOutcome) };
|
|
13452
|
-
if (pendingSettlement === "sealed" && env.softTicketReaskTurn === true && env.softTicketReaskOwnership !== void 0) {
|
|
13453
|
-
env.softTicketReaskOwnership.sealedSubstitute = true;
|
|
13454
|
-
}
|
|
13455
13458
|
if (pendingSettlement === "sealed" && terminal.roleOutcome.kind === "accepted" && request.courtAttemptId !== void 0 && request.courtAttemptId.length > 0) {
|
|
13456
13459
|
try {
|
|
13457
13460
|
await clearCurrentCourt(admitted.runDirectory, request.courtAttemptId);
|
|
@@ -14355,14 +14358,10 @@ function unreadablePostSubmissionStatus(admitted, terminal) {
|
|
|
14355
14358
|
const status = receivedDiscriminator(payload, "status");
|
|
14356
14359
|
return typeof status === "string" && route.statuses.has(status) ? void 0 : route.reask ?? officerConclusionReask(status);
|
|
14357
14360
|
}
|
|
14358
|
-
function withoutSoftTicketReaskTurn(env) {
|
|
14359
|
-
const { softTicketReaskTurn: _softTicketReaskTurn, ...rest } = env;
|
|
14360
|
-
return rest;
|
|
14361
|
-
}
|
|
14362
14361
|
function withUnreadableReask(env) {
|
|
14363
14362
|
const spent = env.unreadableReasksSpent ?? 0;
|
|
14364
14363
|
if (spent >= deliveryLimitFromConfig(env.autoResumeLimit)) return void 0;
|
|
14365
|
-
return { ...
|
|
14364
|
+
return { ...env, unreadableReasksSpent: spent + 1 };
|
|
14366
14365
|
}
|
|
14367
14366
|
function isUnreadableReaskExhausted(value) {
|
|
14368
14367
|
return value === UNREADABLE_REASK_EXHAUSTED;
|
|
@@ -14474,68 +14473,8 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io,
|
|
|
14474
14473
|
io
|
|
14475
14474
|
);
|
|
14476
14475
|
}
|
|
14477
|
-
async function reaskMissingTicketOnce(admitted, terminal, env, io) {
|
|
14478
|
-
if ((env.ticketReasksSpent ?? 0) >= 1) return { kind: "none" };
|
|
14479
|
-
if (isNavigatorSeat(admitted.role)) return { kind: "none" };
|
|
14480
|
-
if (admitted.ticketNumber !== void 0) return { kind: "none" };
|
|
14481
|
-
if (!isUnboundRunDirectory(admitted.runDirectory)) return { kind: "none" };
|
|
14482
|
-
if (terminal?.roleOutcome.kind !== "accepted" && terminal?.roleOutcome.kind !== "audit_escalation") {
|
|
14483
|
-
return { kind: "none" };
|
|
14484
|
-
}
|
|
14485
|
-
const payloads = terminal.roleOutcome.payloads ?? [];
|
|
14486
|
-
if (payloads.length === 0) return { kind: "none" };
|
|
14487
|
-
const instruction = (await readPackageMaterial(MISSING_TICKET_REASK_MATERIAL)).trim();
|
|
14488
|
-
const softTicketReaskOwnership = { sealedSubstitute: false };
|
|
14489
|
-
const softReaskEnv = {
|
|
14490
|
-
...env,
|
|
14491
|
-
ticketReasksSpent: 1,
|
|
14492
|
-
softTicketReaskTurn: true,
|
|
14493
|
-
softTicketReaskOwnership
|
|
14494
|
-
};
|
|
14495
|
-
const result = await runPublicInstructionSeatResume(
|
|
14496
|
-
{
|
|
14497
|
-
runId: admitted.runId,
|
|
14498
|
-
runDirectory: admitted.runDirectory,
|
|
14499
|
-
message: instruction,
|
|
14500
|
-
summons: { instructionEmpty: true }
|
|
14501
|
-
},
|
|
14502
|
-
softReaskEnv,
|
|
14503
|
-
io
|
|
14504
|
-
);
|
|
14505
|
-
if (softTicketReaskOwnership.sealedSubstitute || terminalCarriesSealedSubmission(result.terminal)) {
|
|
14506
|
-
return { kind: "nested_owns", result };
|
|
14507
|
-
}
|
|
14508
|
-
return { kind: "no_substitute", result };
|
|
14509
|
-
}
|
|
14510
14476
|
function envForCourtContinue(env) {
|
|
14511
|
-
return { ...
|
|
14512
|
-
}
|
|
14513
|
-
function terminalCarriesSealedSubmission(terminal) {
|
|
14514
|
-
const kind = terminal?.roleOutcome.kind;
|
|
14515
|
-
if (kind !== "accepted" && kind !== "audit_escalation") return false;
|
|
14516
|
-
return (terminal?.roleOutcome.payloads ?? []).length > 0;
|
|
14517
|
-
}
|
|
14518
|
-
function projectKeptOriginalArtifactsOntoLiveAdmitted(original, kept) {
|
|
14519
|
-
const oldRunDirectory = original.admitted?.runDirectory;
|
|
14520
|
-
const newRunDirectory = kept.admitted?.runDirectory;
|
|
14521
|
-
if (oldRunDirectory === void 0 || newRunDirectory === void 0 || oldRunDirectory === newRunDirectory || kept.terminal === void 0) {
|
|
14522
|
-
return;
|
|
14523
|
-
}
|
|
14524
|
-
for (const artifact of kept.terminal.artifacts) {
|
|
14525
|
-
artifact.path = rewriteRunDirectoryPathValue(
|
|
14526
|
-
artifact.path,
|
|
14527
|
-
oldRunDirectory,
|
|
14528
|
-
newRunDirectory
|
|
14529
|
-
);
|
|
14530
|
-
}
|
|
14531
|
-
}
|
|
14532
|
-
function mergeMissingTicketReaskKeepOriginal(original, ticketReask) {
|
|
14533
|
-
if (ticketReask.exitCode !== 0) return ticketReask;
|
|
14534
|
-
const admitted = ticketReask.admitted ?? original.admitted;
|
|
14535
|
-
if (admitted === void 0) return { ...original };
|
|
14536
|
-
const kept = { ...original, admitted };
|
|
14537
|
-
projectKeptOriginalArtifactsOntoLiveAdmitted(original, kept);
|
|
14538
|
-
return kept;
|
|
14477
|
+
return { ...env, unreadableReasksSpent: 0 };
|
|
14539
14478
|
}
|
|
14540
14479
|
async function continueAfterPostSubmissionGuards(result, admittedRole, env, io, held) {
|
|
14541
14480
|
const live = result.admitted;
|
|
@@ -14549,30 +14488,18 @@ async function continueAfterPostSubmissionGuards(result, admittedRole, env, io,
|
|
|
14549
14488
|
env,
|
|
14550
14489
|
io
|
|
14551
14490
|
);
|
|
14552
|
-
let
|
|
14491
|
+
let continued = result;
|
|
14553
14492
|
if (isUnreadableReaskExhausted(unreadableReask)) {
|
|
14554
14493
|
const terminal = result.terminal === void 0 ? void 0 : withUnsettledDirection(result.terminal);
|
|
14555
|
-
|
|
14494
|
+
continued = terminal === void 0 ? { ...result, admitted: live } : { ...result, admitted: live, terminal };
|
|
14556
14495
|
} else if (unreadableReask !== void 0) {
|
|
14557
14496
|
return unreadableReask;
|
|
14558
14497
|
}
|
|
14559
|
-
const forTicket = afterStatus.admitted ?? live;
|
|
14560
|
-
const softReask = await reaskMissingTicketOnce(
|
|
14561
|
-
forTicket,
|
|
14562
|
-
afterStatus.terminal ?? result.terminal,
|
|
14563
|
-
env,
|
|
14564
|
-
io
|
|
14565
|
-
);
|
|
14566
|
-
if (softReask.kind === "nested_owns") {
|
|
14567
|
-
return softReask.result;
|
|
14568
|
-
}
|
|
14569
|
-
const continued = softReask.kind === "none" ? afterStatus : mergeMissingTicketReaskKeepOriginal(afterStatus, softReask.result);
|
|
14570
14498
|
const continuedAdmitted = continued.admitted ?? live;
|
|
14571
|
-
const continuedEnv = softReask.kind !== "none" ? { ...env, ticketReasksSpent: 1 } : env;
|
|
14572
14499
|
if (AUDITED_ROLES.has(admittedRole) && continued.terminal?.roleOutcome.kind === "accepted") {
|
|
14573
14500
|
return auditSubmittedRole(
|
|
14574
14501
|
{ ...continued, admitted: continuedAdmitted },
|
|
14575
|
-
|
|
14502
|
+
env,
|
|
14576
14503
|
io
|
|
14577
14504
|
);
|
|
14578
14505
|
}
|
|
@@ -15448,7 +15375,6 @@ function officerSatisfiedByLiveChild(officer, resumedOfficer, passedReceipt, cha
|
|
|
15448
15375
|
return childIndex >= 0 && officerIndex >= 0 && officerIndex < childIndex;
|
|
15449
15376
|
}
|
|
15450
15377
|
async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt) {
|
|
15451
|
-
env = withoutSoftTicketReaskTurn(env);
|
|
15452
15378
|
const admitted = turn.admitted;
|
|
15453
15379
|
if (admitted === void 0 || !AUDITED_ROLES.has(admitted.role) || turn.terminal?.roleOutcome.kind !== "accepted") return turn;
|
|
15454
15380
|
const accepted = turn.terminal.roleOutcome.payloads?.at(-1);
|
|
@@ -15735,10 +15661,7 @@ var AUDITED_ROLES, SECRETARIAT_STATUS_REASK, WORKER_ROUTING_STATUSES, WORKER_STA
|
|
|
15735
15661
|
var init_instruction_seat_run = __esm({
|
|
15736
15662
|
"src/public-cli/instruction-seat-run.ts"() {
|
|
15737
15663
|
"use strict";
|
|
15738
|
-
init_report_ticket_tool();
|
|
15739
15664
|
init_role_run_placement();
|
|
15740
|
-
init_role_run_relocation();
|
|
15741
|
-
init_session_opening_materials();
|
|
15742
15665
|
init_doctor_auditor();
|
|
15743
15666
|
init_gatekeeper_role();
|
|
15744
15667
|
init_submission_errors();
|