@akagilnc/pi-workflow-roles 0.1.5762 → 0.1.5797
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 +685 -285
- package/dist/external-host-turn-loop.js +3 -0
- package/dist/headless-host/production-host.js +658 -258
- package/dist/migrate-book-topology.js +70 -29
- package/dist/navigator-attendance.js +1 -1
- package/dist/packaged-role-registry.js +3 -2
- package/dist/pi/role-turn-host.js +6 -1
- package/dist/public-cli/instruction-seat-run.js +152 -60
- package/dist/public-cli/invocation.js +98 -46
- package/dist/public-cli/main.js +482 -222
- package/dist/public-cli/option-definitions.js +4 -4
- package/dist/public-cli/post-admission.js +19 -28
- package/dist/public-cli/run-lifecycle.js +10 -21
- package/dist/public-cli/turn-request.js +3 -0
- package/dist/public-role-summons.js +11 -8
- package/dist/report-ticket-tool.js +3 -3
- package/dist/role-run-placement.js +14 -2
- package/dist/role-run-relocation.js +2 -2
- package/dist/run-dossier.js +5 -4
- package/dist/run-terminal-artifacts.js +0 -7
- package/dist/session-identity.js +3 -2
- package/dist/sitian-appender.js +12 -3
- package/dist/submission-ledger.js +24 -0
- package/dist/ticket-progress.js +306 -0
- package/dist/user-dialogue-stdin.js +23 -17
- package/package.json +1 -1
- package/src/external-host-turn-loop.ts +7 -1
- package/src/host-contracts.ts +1 -1
- package/src/navigator-attendance.ts +2 -1
- package/src/packaged-role-registry.ts +3 -2
- package/src/pi/adapter.ts +57 -45
- package/src/pi/role-turn-host.ts +6 -1
- package/src/prepared-role-turn.ts +6 -0
- package/src/public-cli/instruction-seat-run.ts +166 -68
- package/src/public-cli/invocation.ts +120 -46
- package/src/public-cli/option-definitions.ts +5 -4
- package/src/public-cli/post-admission.ts +19 -30
- package/src/public-cli/run-lifecycle.ts +10 -27
- package/src/public-cli/turn-request.ts +3 -0
- package/src/public-role-summons.ts +27 -16
- package/src/report-ticket-tool.ts +7 -3
- package/src/role-envelope.ts +5 -0
- package/src/role-run-placement.ts +19 -2
- package/src/role-run-relocation.ts +2 -2
- package/src/role-runtime.ts +19 -2
- package/src/run-dossier.ts +5 -3
- package/src/run-terminal-artifacts.ts +0 -8
- package/src/session-identity.ts +3 -2
- package/src/sitian-appender.ts +14 -3
- package/src/submission-ledger.ts +27 -0
- package/src/ticket-progress.ts +383 -0
- package/src/user-dialogue-stdin.ts +21 -14
|
@@ -711,6 +711,12 @@ function appendSitianRecordBlock(input, block) {
|
|
|
711
711
|
function resolveSitianVolumeCategory(kind) {
|
|
712
712
|
return kind;
|
|
713
713
|
}
|
|
714
|
+
function runDirectoryOwningSessionParent(sessionParentDir) {
|
|
715
|
+
if (basename3(sessionParentDir) !== "session") return void 0;
|
|
716
|
+
const runDirectory = dirname3(sessionParentDir);
|
|
717
|
+
if (parseRunLeaf(basename3(runDirectory)) === void 0) return void 0;
|
|
718
|
+
return runDirectory;
|
|
719
|
+
}
|
|
714
720
|
function sitianVolumeDirectory(sessionDirectory, category) {
|
|
715
721
|
return join3(sessionDirectory, category);
|
|
716
722
|
}
|
|
@@ -742,8 +748,8 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
742
748
|
throw new Error("Sitian record ownership requires a parent session inside the ledger home");
|
|
743
749
|
}
|
|
744
750
|
const sessionParentDir = dirname3(input.sessionParent);
|
|
745
|
-
const runDirectory =
|
|
746
|
-
if (
|
|
751
|
+
const runDirectory = runDirectoryOwningSessionParent(sessionParentDir);
|
|
752
|
+
if (runDirectory !== void 0) {
|
|
747
753
|
sessionDir = runDirectory;
|
|
748
754
|
recordFile = join3(runDirectory, RUN_HISTORY_KINDS.has(input.kind) ? RUN_HISTORY_FILE : RUN_STATE_KINDS.has(input.kind) ? RUN_STATE_FILE : RUN_LOG_FILE);
|
|
749
755
|
} else {
|
|
@@ -976,7 +982,9 @@ function render(runDirectory, history, state, log, unreadable) {
|
|
|
976
982
|
original = payload.landingPath;
|
|
977
983
|
}
|
|
978
984
|
}
|
|
979
|
-
if (typeof original === "string")
|
|
985
|
+
if (typeof original === "string") {
|
|
986
|
+
original = join4(sessionDirectoryOf(runDirectory), basename4(original));
|
|
987
|
+
}
|
|
980
988
|
whole.host = { sessions, ...original === void 0 ? {} : { original } };
|
|
981
989
|
whole.submission = latest === void 0 ? {} : { latest };
|
|
982
990
|
if (Object.keys(unreadable).length > 0) whole.unreadable = unreadable;
|
|
@@ -1214,6 +1222,16 @@ function parseRunLeaf(name) {
|
|
|
1214
1222
|
if (at <= 0 || at === name.length - 1) return void 0;
|
|
1215
1223
|
return { runId: name.slice(0, at), role: name.slice(at + 1) };
|
|
1216
1224
|
}
|
|
1225
|
+
function subjectDirectoryOfRun(runDirectory) {
|
|
1226
|
+
const runsParent = dirname4(runDirectory);
|
|
1227
|
+
if (basename5(runsParent) !== "runs") return void 0;
|
|
1228
|
+
const subjectDirectory = dirname4(runsParent);
|
|
1229
|
+
const subjectName = basename5(subjectDirectory);
|
|
1230
|
+
if (subjectName === "unbound" || /^[1-9]\d*$/.test(subjectName)) {
|
|
1231
|
+
return subjectDirectory;
|
|
1232
|
+
}
|
|
1233
|
+
return void 0;
|
|
1234
|
+
}
|
|
1217
1235
|
function sessionDirectoryOf(runDirectory) {
|
|
1218
1236
|
return join6(runDirectory, "session");
|
|
1219
1237
|
}
|
|
@@ -1306,6 +1324,7 @@ function ensureRoleRunDirectory(ledgerHome, directory) {
|
|
|
1306
1324
|
return ensureRealDirectoryTree(ledgerHome, directory);
|
|
1307
1325
|
}
|
|
1308
1326
|
function ensureRoleRunPlacement(ledgerHome, placement) {
|
|
1327
|
+
ensureRoleRunDirectory(ledgerHome, placement.runDirectory);
|
|
1309
1328
|
ensureRoleRunDirectory(ledgerHome, placement.sessionDirectory);
|
|
1310
1329
|
}
|
|
1311
1330
|
var ROLE_RUN_SESSION_FILENAME;
|
|
@@ -2796,9 +2815,8 @@ var init_packaged_role_registry = __esm({
|
|
|
2796
2815
|
bareCommand: false,
|
|
2797
2816
|
outputTool: NOTARY_OUTPUT_TOOL_NAME,
|
|
2798
2817
|
settlement: "accepted",
|
|
2799
|
-
/**
|
|
2818
|
+
/** Dialogue via shared resolveReviewSeatDialogueBody (review = fixed dispatch). */
|
|
2800
2819
|
reaskPrompt: true,
|
|
2801
|
-
transportPrompt: "fixed-kickoff",
|
|
2802
2820
|
gateStageLabel: "\u7B26\u5B9D\u90CE",
|
|
2803
2821
|
/** Gate summon binds --source-run and keeps dialogue off the argv. */
|
|
2804
2822
|
gateSummon: "source-run",
|
|
@@ -2821,6 +2839,8 @@ var init_packaged_role_registry = __esm({
|
|
|
2821
2839
|
phases: [null],
|
|
2822
2840
|
outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
|
|
2823
2841
|
settlement: "accepted",
|
|
2842
|
+
/** Same shared dialogue resolver as other review seats (#1208 C1). */
|
|
2843
|
+
reaskPrompt: true,
|
|
2824
2844
|
gateStageLabel: "\u7ED9\u4E8B\u4E2D",
|
|
2825
2845
|
/** Gate summon carries the parent payload as the instruction and a parent run id. */
|
|
2826
2846
|
gateSummon: "parent-instruction",
|
|
@@ -3421,7 +3441,6 @@ var run_terminal_artifacts_exports = {};
|
|
|
3421
3441
|
__export(run_terminal_artifacts_exports, {
|
|
3422
3442
|
ATTEMPT_HISTORY_IDENTITY_FIELD: () => ATTEMPT_HISTORY_IDENTITY_FIELD,
|
|
3423
3443
|
TERMINAL_COURT_ATTEMPT_FIELD: () => TERMINAL_COURT_ATTEMPT_FIELD,
|
|
3424
|
-
isTicketCourtCountersignSource: () => isTicketCourtCountersignSource,
|
|
3425
3444
|
readRunTerminal: () => readRunTerminal,
|
|
3426
3445
|
roleFromRunDirectory: () => roleFromRunDirectory,
|
|
3427
3446
|
runIdFromRunDirectory: () => runIdFromRunDirectory,
|
|
@@ -3482,9 +3501,6 @@ function runIdFromRunDirectory(runDirectory) {
|
|
|
3482
3501
|
function roleFromRunDirectory(runDirectory) {
|
|
3483
3502
|
return parseRunLeaf(basename6(runDirectory))?.role;
|
|
3484
3503
|
}
|
|
3485
|
-
function isTicketCourtCountersignSource(runDirectory) {
|
|
3486
|
-
return roleFromRunDirectory(runDirectory) === "countersign";
|
|
3487
|
-
}
|
|
3488
3504
|
var ATTEMPT_HISTORY_IDENTITY_FIELD, TERMINAL_COURT_ATTEMPT_FIELD;
|
|
3489
3505
|
var init_run_terminal_artifacts = __esm({
|
|
3490
3506
|
"src/run-terminal-artifacts.ts"() {
|
|
@@ -4113,7 +4129,8 @@ var init_role_activation_flags = __esm({
|
|
|
4113
4129
|
|
|
4114
4130
|
// src/user-dialogue-stdin.ts
|
|
4115
4131
|
function encodeUserDialogueStdin(body) {
|
|
4116
|
-
|
|
4132
|
+
const envelope = { kind: USER_DIALOGUE_STDIN_KIND, body };
|
|
4133
|
+
return JSON.stringify(envelope);
|
|
4117
4134
|
}
|
|
4118
4135
|
var USER_DIALOGUE_STDIN_KIND;
|
|
4119
4136
|
var init_user_dialogue_stdin = __esm({
|
|
@@ -4488,17 +4505,6 @@ var init_submission_correctable_error = __esm({
|
|
|
4488
4505
|
}
|
|
4489
4506
|
});
|
|
4490
4507
|
|
|
4491
|
-
// src/sha256.ts
|
|
4492
|
-
import { createHash } from "node:crypto";
|
|
4493
|
-
function sha256Hex(bytes) {
|
|
4494
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
4495
|
-
}
|
|
4496
|
-
var init_sha256 = __esm({
|
|
4497
|
-
"src/sha256.ts"() {
|
|
4498
|
-
"use strict";
|
|
4499
|
-
}
|
|
4500
|
-
});
|
|
4501
|
-
|
|
4502
4508
|
// src/package-contracts/terminating-tools.ts
|
|
4503
4509
|
function isTerminatingToolName(name) {
|
|
4504
4510
|
return TERMINATING_TOOL_NAMES.includes(name);
|
|
@@ -4559,9 +4565,256 @@ var init_terminating_tools = __esm({
|
|
|
4559
4565
|
}
|
|
4560
4566
|
});
|
|
4561
4567
|
|
|
4568
|
+
// src/ticket-progress.ts
|
|
4569
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
4570
|
+
import {
|
|
4571
|
+
appendFileSync as appendFileSync2,
|
|
4572
|
+
existsSync as existsSync2,
|
|
4573
|
+
mkdirSync as mkdirSync3,
|
|
4574
|
+
readFileSync as readFileSync2,
|
|
4575
|
+
readdirSync as readdirSync2,
|
|
4576
|
+
rmSync as rmSync3,
|
|
4577
|
+
writeFileSync as writeFileSync2
|
|
4578
|
+
} from "node:fs";
|
|
4579
|
+
import { basename as basename7, dirname as dirname6, join as join8, relative as relative2, sep as sep3 } from "node:path";
|
|
4580
|
+
function parseProgressText(text, pathForDiagnostic) {
|
|
4581
|
+
if (text.trim() === "") return [];
|
|
4582
|
+
const { records, diagnostics } = parseSitianRecordText(text);
|
|
4583
|
+
for (const diagnostic of diagnostics) {
|
|
4584
|
+
process.stderr.write(
|
|
4585
|
+
`[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
|
|
4586
|
+
`
|
|
4587
|
+
);
|
|
4588
|
+
}
|
|
4589
|
+
const lines = [];
|
|
4590
|
+
for (const record of records) {
|
|
4591
|
+
const parsed = record;
|
|
4592
|
+
if (!isRecord(parsed)) continue;
|
|
4593
|
+
if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
|
|
4594
|
+
lines.push(parsed);
|
|
4595
|
+
}
|
|
4596
|
+
return lines;
|
|
4597
|
+
}
|
|
4598
|
+
function readProgressFile(path) {
|
|
4599
|
+
if (!existsSync2(path)) return [];
|
|
4600
|
+
return parseProgressText(readFileSync2(path, "utf8"), path);
|
|
4601
|
+
}
|
|
4602
|
+
function readTicketProgressLines(subjectDirectory) {
|
|
4603
|
+
if (basename7(subjectDirectory) === "unbound") {
|
|
4604
|
+
const runsDir = join8(subjectDirectory, "runs");
|
|
4605
|
+
if (!existsSync2(runsDir)) return [];
|
|
4606
|
+
const out = [];
|
|
4607
|
+
for (const name of readdirSync2(runsDir).sort()) {
|
|
4608
|
+
out.push(...readProgressFile(join8(runsDir, name, LEG_PROGRESS_FILENAME)));
|
|
4609
|
+
}
|
|
4610
|
+
return out;
|
|
4611
|
+
}
|
|
4612
|
+
return readProgressFile(join8(subjectDirectory, CURRENT_FILENAME));
|
|
4613
|
+
}
|
|
4614
|
+
function roundBaseNumber(round) {
|
|
4615
|
+
if (round.trim() === "") return 0;
|
|
4616
|
+
const base = round.includes(".") ? round.slice(0, round.indexOf(".")) : round;
|
|
4617
|
+
const n = Number(base);
|
|
4618
|
+
return Number.isSafeInteger(n) && n > 0 ? n : 0;
|
|
4619
|
+
}
|
|
4620
|
+
function roundLens(round) {
|
|
4621
|
+
return round.includes(".") ? round.slice(round.indexOf(".") + 1) : void 0;
|
|
4622
|
+
}
|
|
4623
|
+
function nextRoundFromLines(lines, seat, lens) {
|
|
4624
|
+
const want = lens === void 0 || lens.trim() === "" ? void 0 : lens;
|
|
4625
|
+
let max = 0;
|
|
4626
|
+
for (const line2 of lines) {
|
|
4627
|
+
if (line2.seat !== seat) continue;
|
|
4628
|
+
if (roundLens(line2.round) !== want) continue;
|
|
4629
|
+
max = Math.max(max, roundBaseNumber(line2.round));
|
|
4630
|
+
}
|
|
4631
|
+
const base = max + 1;
|
|
4632
|
+
return want === void 0 ? String(base) : `${base}.${want}`;
|
|
4633
|
+
}
|
|
4634
|
+
function nextLegReceiptIndex(runDirectory) {
|
|
4635
|
+
const dir = join8(runDirectory, RECEIPTS_DIRNAME);
|
|
4636
|
+
if (!existsSync2(dir)) return 1;
|
|
4637
|
+
let max = 0;
|
|
4638
|
+
for (const name of readdirSync2(dir)) {
|
|
4639
|
+
const match = /^(\d+)\.json$/.exec(name);
|
|
4640
|
+
if (match === null) continue;
|
|
4641
|
+
const n = Number(match[1]);
|
|
4642
|
+
if (Number.isSafeInteger(n) && n > max) max = n;
|
|
4643
|
+
}
|
|
4644
|
+
return max + 1;
|
|
4645
|
+
}
|
|
4646
|
+
function statusAndSummaryFromPayload(seat, payload) {
|
|
4647
|
+
if (!isRecord(payload)) return {};
|
|
4648
|
+
const toolName = packagedRoleOutputTool(seat);
|
|
4649
|
+
const status = toolName !== void 0 && isTerminatingToolName(toolName) ? acceptedFacts(toolName, payload).status : void 0;
|
|
4650
|
+
const summary = typeof payload.summary === "string" ? payload.summary : void 0;
|
|
4651
|
+
return {
|
|
4652
|
+
...status === void 0 ? {} : { status },
|
|
4653
|
+
...summary === void 0 ? {} : { summary }
|
|
4654
|
+
};
|
|
4655
|
+
}
|
|
4656
|
+
function captureWorktreeHead(projectRoot) {
|
|
4657
|
+
try {
|
|
4658
|
+
const result = spawnSync2("git", ["rev-parse", "HEAD"], {
|
|
4659
|
+
cwd: projectRoot,
|
|
4660
|
+
encoding: "utf8",
|
|
4661
|
+
maxBuffer: 1024 * 1024
|
|
4662
|
+
});
|
|
4663
|
+
if (result.error != null) {
|
|
4664
|
+
const err = result.error;
|
|
4665
|
+
const detail = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
4666
|
+
return { head: "", fault: `git rev-parse HEAD spawn failed cwd=${projectRoot}: ${detail}` };
|
|
4667
|
+
}
|
|
4668
|
+
if (result.status !== 0) {
|
|
4669
|
+
const detail = [result.stderr, result.stdout].map((part) => typeof part === "string" ? part.trim() : "").filter((part) => part !== "").join(" | ");
|
|
4670
|
+
const status = result.status === null ? "null" : String(result.status);
|
|
4671
|
+
const signal = result.signal == null ? "" : ` signal=${result.signal}`;
|
|
4672
|
+
return {
|
|
4673
|
+
head: "",
|
|
4674
|
+
fault: detail === "" ? `git rev-parse HEAD failed (status=${status}${signal}) cwd=${projectRoot}` : `git rev-parse HEAD failed (status=${status}${signal}) cwd=${projectRoot}: ${detail}`
|
|
4675
|
+
};
|
|
4676
|
+
}
|
|
4677
|
+
return { head: (result.stdout ?? "").trim() };
|
|
4678
|
+
} catch (error) {
|
|
4679
|
+
const message = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
4680
|
+
return { head: "", fault: `git rev-parse HEAD threw cwd=${projectRoot}: ${message}` };
|
|
4681
|
+
}
|
|
4682
|
+
}
|
|
4683
|
+
function progressSessionAbsolute(runDirectory, context) {
|
|
4684
|
+
const host = typeof context.host === "string" ? context.host.trim() : "";
|
|
4685
|
+
const sessionDirectory = sessionDirectoryOf(runDirectory);
|
|
4686
|
+
if (host !== "" && host !== "pi" && host !== "hermes") {
|
|
4687
|
+
return resolveHostDossierLandingPath({ host, sessionDirectory });
|
|
4688
|
+
}
|
|
4689
|
+
const issued = context.sessionManager.getSessionFile?.();
|
|
4690
|
+
if (typeof issued === "string" && issued.trim() !== "") {
|
|
4691
|
+
return issued;
|
|
4692
|
+
}
|
|
4693
|
+
return sessionFileOf(runDirectory);
|
|
4694
|
+
}
|
|
4695
|
+
function lensFromRunDirectory(runDirectory, role) {
|
|
4696
|
+
if (role !== "reviewer") return void 0;
|
|
4697
|
+
const lens = readPageSync(runDirectory, "admitted")?.lens;
|
|
4698
|
+
return lens === "completeness" || lens === "correctness" ? lens : void 0;
|
|
4699
|
+
}
|
|
4700
|
+
function landTicketProgressForSealedSubmission(input) {
|
|
4701
|
+
const runDirectory = runDirectoryFromHostContext(input.context);
|
|
4702
|
+
if (runDirectory === void 0) return void 0;
|
|
4703
|
+
const subjectDirectory = subjectDirectoryOfRun(runDirectory);
|
|
4704
|
+
if (subjectDirectory === void 0) return void 0;
|
|
4705
|
+
const lens = input.lens === "completeness" || input.lens === "correctness" ? input.lens : lensFromRunDirectory(runDirectory, input.role);
|
|
4706
|
+
const leaf = basename7(runDirectory);
|
|
4707
|
+
const unbound = basename7(subjectDirectory) === "unbound";
|
|
4708
|
+
const progressPath = unbound ? join8(runDirectory, LEG_PROGRESS_FILENAME) : join8(subjectDirectory, CURRENT_FILENAME);
|
|
4709
|
+
const receiptIndex = nextLegReceiptIndex(runDirectory);
|
|
4710
|
+
const relativePath = `runs/${leaf}/${RECEIPTS_DIRNAME}/${receiptIndex}.json`;
|
|
4711
|
+
const absolutePath = join8(subjectDirectory, relativePath);
|
|
4712
|
+
mkdirSync3(dirname6(absolutePath), { recursive: true });
|
|
4713
|
+
writeFileSync2(absolutePath, `${JSON.stringify(input.accepted, null, 2)}
|
|
4714
|
+
`, "utf8");
|
|
4715
|
+
if (!unbound) {
|
|
4716
|
+
relocateTicketProgressForLeg({ runDirectory });
|
|
4717
|
+
}
|
|
4718
|
+
const existing = unbound ? readProgressFile(progressPath) : readTicketProgressLines(subjectDirectory);
|
|
4719
|
+
const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
|
|
4720
|
+
const sessionFile = progressSessionAbsolute(runDirectory, input.context);
|
|
4721
|
+
const sessionRelative = relative2(subjectDirectory, sessionFile).split(sep3).join("/");
|
|
4722
|
+
const { status, summary } = statusAndSummaryFromPayload(input.role, input.accepted);
|
|
4723
|
+
const instruction = typeof input.context.summonsInstruction === "string" ? input.context.summonsInstruction : "";
|
|
4724
|
+
const line2 = {
|
|
4725
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4726
|
+
seat: input.role,
|
|
4727
|
+
round,
|
|
4728
|
+
instruction,
|
|
4729
|
+
head: input.sealHead.head,
|
|
4730
|
+
...status === void 0 ? {} : { status },
|
|
4731
|
+
...summary === void 0 ? {} : { summary },
|
|
4732
|
+
receipt: relativePath,
|
|
4733
|
+
session: sessionRelative
|
|
4734
|
+
};
|
|
4735
|
+
mkdirSync3(dirname6(progressPath), { recursive: true });
|
|
4736
|
+
appendFileSync2(progressPath, `${JSON.stringify(line2)}
|
|
4737
|
+
`, "utf8");
|
|
4738
|
+
if (input.sealHead.fault !== void 0) {
|
|
4739
|
+
process.stderr.write(`${input.sealHead.fault}
|
|
4740
|
+
`);
|
|
4741
|
+
}
|
|
4742
|
+
return line2;
|
|
4743
|
+
}
|
|
4744
|
+
function relocateTicketProgressForLeg(input) {
|
|
4745
|
+
if (isUnboundRunDirectory(input.runDirectory)) return;
|
|
4746
|
+
const subjectDirectory = subjectDirectoryOfRun(input.runDirectory);
|
|
4747
|
+
if (subjectDirectory === void 0) return;
|
|
4748
|
+
const stagedPath = join8(input.runDirectory, LEG_PROGRESS_FILENAME);
|
|
4749
|
+
const mine = readProgressFile(stagedPath);
|
|
4750
|
+
if (mine.length === 0) {
|
|
4751
|
+
if (existsSync2(stagedPath)) {
|
|
4752
|
+
rmSync3(stagedPath, { force: true });
|
|
4753
|
+
}
|
|
4754
|
+
return;
|
|
4755
|
+
}
|
|
4756
|
+
const ticketLines = [...readTicketProgressLines(subjectDirectory)];
|
|
4757
|
+
const publishedReceipts = new Set(
|
|
4758
|
+
ticketLines.map((line2) => line2.receipt).filter((receipt) => typeof receipt === "string" && receipt !== "")
|
|
4759
|
+
);
|
|
4760
|
+
const pending = mine.filter((line2) => !publishedReceipts.has(line2.receipt));
|
|
4761
|
+
if (pending.length === 0) {
|
|
4762
|
+
rmSync3(stagedPath, { force: true });
|
|
4763
|
+
return;
|
|
4764
|
+
}
|
|
4765
|
+
const movedLines = [];
|
|
4766
|
+
for (const line2 of pending) {
|
|
4767
|
+
const lens = lensFromRunDirectory(input.runDirectory, line2.seat);
|
|
4768
|
+
const round = nextRoundFromLines(ticketLines, line2.seat, lens);
|
|
4769
|
+
const moved = {
|
|
4770
|
+
...line2,
|
|
4771
|
+
round
|
|
4772
|
+
};
|
|
4773
|
+
movedLines.push(moved);
|
|
4774
|
+
ticketLines.push(moved);
|
|
4775
|
+
}
|
|
4776
|
+
const newCurrent = join8(subjectDirectory, CURRENT_FILENAME);
|
|
4777
|
+
mkdirSync3(dirname6(newCurrent), { recursive: true });
|
|
4778
|
+
appendFileSync2(
|
|
4779
|
+
newCurrent,
|
|
4780
|
+
`${movedLines.map((line2) => JSON.stringify(line2)).join("\n")}
|
|
4781
|
+
`,
|
|
4782
|
+
"utf8"
|
|
4783
|
+
);
|
|
4784
|
+
rmSync3(stagedPath, { force: true });
|
|
4785
|
+
}
|
|
4786
|
+
var CURRENT_FILENAME, RECEIPTS_DIRNAME, LEG_PROGRESS_FILENAME;
|
|
4787
|
+
var init_ticket_progress = __esm({
|
|
4788
|
+
"src/ticket-progress.ts"() {
|
|
4789
|
+
"use strict";
|
|
4790
|
+
init_host_session_record();
|
|
4791
|
+
init_host_contracts();
|
|
4792
|
+
init_terminating_tools();
|
|
4793
|
+
init_packaged_role_registry();
|
|
4794
|
+
init_role_run_placement();
|
|
4795
|
+
init_run_dossier();
|
|
4796
|
+
init_sitian_reader();
|
|
4797
|
+
init_unknown_value();
|
|
4798
|
+
CURRENT_FILENAME = "current.jsonl";
|
|
4799
|
+
RECEIPTS_DIRNAME = "receipts";
|
|
4800
|
+
LEG_PROGRESS_FILENAME = "progress.jsonl";
|
|
4801
|
+
}
|
|
4802
|
+
});
|
|
4803
|
+
|
|
4804
|
+
// src/sha256.ts
|
|
4805
|
+
import { createHash } from "node:crypto";
|
|
4806
|
+
function sha256Hex(bytes) {
|
|
4807
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
4808
|
+
}
|
|
4809
|
+
var init_sha256 = __esm({
|
|
4810
|
+
"src/sha256.ts"() {
|
|
4811
|
+
"use strict";
|
|
4812
|
+
}
|
|
4813
|
+
});
|
|
4814
|
+
|
|
4562
4815
|
// src/doctor-evidence.ts
|
|
4563
4816
|
import { readdir as readdir2, readFile as readFile4, realpath, stat } from "node:fs/promises";
|
|
4564
|
-
import { dirname as
|
|
4817
|
+
import { dirname as dirname7, relative as relative3, resolve as resolve4, sep as sep4 } from "node:path";
|
|
4565
4818
|
async function discoverCaseFiles(root) {
|
|
4566
4819
|
const found = [];
|
|
4567
4820
|
async function walk(dir, depth) {
|
|
@@ -4590,11 +4843,11 @@ async function stableRunsIdentity(root) {
|
|
|
4590
4843
|
while (true) {
|
|
4591
4844
|
try {
|
|
4592
4845
|
const git3 = await stat(resolve4(cursor, ".git"));
|
|
4593
|
-
if (git3.isDirectory() || git3.isFile()) return
|
|
4846
|
+
if (git3.isDirectory() || git3.isFile()) return relative3(cursor, root).split(sep4).join("/");
|
|
4594
4847
|
} catch (error) {
|
|
4595
4848
|
if (!isMissingPathError(error)) throw error;
|
|
4596
4849
|
}
|
|
4597
|
-
const parent =
|
|
4850
|
+
const parent = dirname7(cursor);
|
|
4598
4851
|
if (parent === cursor) return root;
|
|
4599
4852
|
cursor = parent;
|
|
4600
4853
|
}
|
|
@@ -4667,12 +4920,12 @@ async function loadDoctorCase(runsPath, projectRoot) {
|
|
|
4667
4920
|
if (projectRoot !== void 0 && !physicallyContainedIn(projectRoot, root)) {
|
|
4668
4921
|
throw new Error("doctor --runs escapes the project root");
|
|
4669
4922
|
}
|
|
4670
|
-
const match = root.split(
|
|
4923
|
+
const match = root.split(sep4).join("/").match(/\/\.ak-roles\/books\/[^/]+\/(?:issues\/)?([1-9]\d*)\/runs$/);
|
|
4671
4924
|
if (!match) throw new Error("Doctor case must be an .ak-roles/books/<book>/<n>/runs directory");
|
|
4672
4925
|
const evidence = [], sessions = [], statuses = [], commits = [];
|
|
4673
4926
|
const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
|
|
4674
4927
|
for (const path of await discoverCaseFiles(root)) {
|
|
4675
|
-
const id =
|
|
4928
|
+
const id = relative3(root, path).split(sep4).join("/");
|
|
4676
4929
|
const bytes = await readFile4(path);
|
|
4677
4930
|
const content = bytes.toString("utf8");
|
|
4678
4931
|
const kind = id.split("/").length === 2 && id.endsWith("/log.jsonl") ? "log" : "session";
|
|
@@ -4968,13 +5221,13 @@ var init_session_dialogue = __esm({
|
|
|
4968
5221
|
|
|
4969
5222
|
// src/ticket-provenance.ts
|
|
4970
5223
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
4971
|
-
import { join as
|
|
5224
|
+
import { join as join9, resolve as resolve6 } from "node:path";
|
|
4972
5225
|
function dialogueSessionSourceRoots(home) {
|
|
4973
5226
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
4974
5227
|
return [
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
5228
|
+
join9(machineHome, ".claude", "projects"),
|
|
5229
|
+
join9(machineHome, ".codex", "sessions"),
|
|
5230
|
+
join9(machineHome, ".pi", "agent", "sessions")
|
|
4978
5231
|
];
|
|
4979
5232
|
}
|
|
4980
5233
|
function isLedgerRoleSessionFile(absolute, home) {
|
|
@@ -5015,7 +5268,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
|
|
|
5015
5268
|
const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
|
|
5016
5269
|
let history;
|
|
5017
5270
|
try {
|
|
5018
|
-
history = await readFile6(
|
|
5271
|
+
history = await readFile6(join9(runDirectory, RUN_HISTORY_FILE), "utf8");
|
|
5019
5272
|
} catch (error) {
|
|
5020
5273
|
if (errnoCode(error) === "ENOENT") return;
|
|
5021
5274
|
throw error;
|
|
@@ -5232,7 +5485,7 @@ var init_uuidv7 = __esm({
|
|
|
5232
5485
|
});
|
|
5233
5486
|
|
|
5234
5487
|
// src/notary-source-run.ts
|
|
5235
|
-
import { dirname as
|
|
5488
|
+
import { dirname as dirname8, isAbsolute as isAbsolute4, join as join10, resolve as resolve7, basename as basename8 } from "node:path";
|
|
5236
5489
|
import { lstat, realpath as realpath2 } from "node:fs/promises";
|
|
5237
5490
|
async function readRetainedIdentity(runDirectory) {
|
|
5238
5491
|
try {
|
|
@@ -5268,10 +5521,10 @@ async function requireRunDirectory(candidate, display) {
|
|
|
5268
5521
|
`notary --source-run must be a run directory: ${display}`
|
|
5269
5522
|
);
|
|
5270
5523
|
}
|
|
5271
|
-
const identity = parseRunLeaf(
|
|
5524
|
+
const identity = parseRunLeaf(basename8(real));
|
|
5272
5525
|
if (identity === void 0) {
|
|
5273
5526
|
throw new NotarySourceRunError(
|
|
5274
|
-
`notary --source-run must be named <runId>@<role>: ${
|
|
5527
|
+
`notary --source-run must be named <runId>@<role>: ${basename8(real)}`
|
|
5275
5528
|
);
|
|
5276
5529
|
}
|
|
5277
5530
|
return real;
|
|
@@ -5284,26 +5537,26 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5284
5537
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
5285
5538
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
5286
5539
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
5287
|
-
const bookRunsRoot =
|
|
5540
|
+
const bookRunsRoot = join10(bookDirectory, "runs");
|
|
5288
5541
|
let candidate;
|
|
5289
5542
|
const bare = parseRunLeaf(raw);
|
|
5290
5543
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
5291
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
5544
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join10(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
|
|
5292
5545
|
} else {
|
|
5293
5546
|
candidate = isAbsolute4(raw) ? raw : resolve7(options.projectRoot, raw);
|
|
5294
|
-
const identity2 = parseRunLeaf(
|
|
5295
|
-
const subjectDirectory =
|
|
5296
|
-
const isLegacyUnboundLocator = identity2 !== void 0 &&
|
|
5547
|
+
const identity2 = parseRunLeaf(basename8(candidate));
|
|
5548
|
+
const subjectDirectory = dirname8(dirname8(candidate));
|
|
5549
|
+
const isLegacyUnboundLocator = identity2 !== void 0 && basename8(dirname8(candidate)) === "runs" && basename8(subjectDirectory) === "unbound" && resolve7(dirname8(subjectDirectory)) === resolve7(bookDirectory);
|
|
5297
5550
|
if (isLegacyUnboundLocator) {
|
|
5298
5551
|
candidate = await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey) ?? candidate;
|
|
5299
5552
|
}
|
|
5300
5553
|
}
|
|
5301
5554
|
const real = await requireRunDirectory(candidate, raw);
|
|
5302
|
-
const identity = parseRunLeaf(
|
|
5555
|
+
const identity = parseRunLeaf(basename8(real));
|
|
5303
5556
|
const bookIdentity = physicalPathIdentity(bookDirectory);
|
|
5304
|
-
const parentIdentity = physicalPathIdentity(
|
|
5305
|
-
const subjectBookIdentity = physicalPathIdentity(
|
|
5306
|
-
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(
|
|
5557
|
+
const parentIdentity = physicalPathIdentity(dirname8(real));
|
|
5558
|
+
const subjectBookIdentity = physicalPathIdentity(dirname8(dirname8(dirname8(real))));
|
|
5559
|
+
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename8(dirname8(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
5307
5560
|
throw new NotarySourceRunError(
|
|
5308
5561
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
5309
5562
|
);
|
|
@@ -5337,7 +5590,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5337
5590
|
}
|
|
5338
5591
|
async function loadNotarySourceRunLocator(path) {
|
|
5339
5592
|
const real = await requireRunDirectory(path, path);
|
|
5340
|
-
const identity = parseRunLeaf(
|
|
5593
|
+
const identity = parseRunLeaf(basename8(real));
|
|
5341
5594
|
const runState = await readRetainedIdentity(real);
|
|
5342
5595
|
if (runState === void 0) {
|
|
5343
5596
|
throw new NotarySourceRunError(
|
|
@@ -6077,8 +6330,8 @@ var init_option_definitions = __esm({
|
|
|
6077
6330
|
repeatable: false,
|
|
6078
6331
|
form: "option",
|
|
6079
6332
|
description: {
|
|
6080
|
-
en: "Required source run locator (runId@role under the book home, or path to that run directory).
|
|
6081
|
-
zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\u7C3F\u5185 runId@role\uFF0C\u6216\u8BE5 run \u76EE\u5F55\u8DEF\u5F84\uFF09\u3002\
|
|
6333
|
+
en: "Required source run locator (runId@role under the book home, or path to that run directory). Binds the audited identity; review dialogue is the fixed Notary dispatch (verdict stays in the ledger). Missing-ticket and unreadable-status reasks keep their existing diagnostic text.",
|
|
6334
|
+
zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\u7C3F\u5185 runId@role\uFF0C\u6216\u8BE5 run \u76EE\u5F55\u8DEF\u5F84\uFF09\u3002\u7ED1\u5B9A\u53D7\u5BA1\u8EAB\u4EFD\uFF1B\u5BA1\u7A3F\u5BF9\u8BDD\u4E3A\u7B26\u5B9D\u90CE\u56FA\u5B9A\u6D3E\u5355\u6587\uFF08\u5224\u8BCD\u7559\u5728\u5377\u5B97\u81EA\u884C\u8BFB\u53D6\uFF09\u3002\u7F3A\u7968\u53F7\u4E0E\u8BFB\u4E0D\u51FA status \u7684\u91CD\u4EA4\u4ECD\u9012\u65E2\u6709\u8BCA\u65AD\u539F\u6587\u3002"
|
|
6082
6335
|
}
|
|
6083
6336
|
}
|
|
6084
6337
|
];
|
|
@@ -6413,7 +6666,7 @@ var init_option_definitions = __esm({
|
|
|
6413
6666
|
},
|
|
6414
6667
|
notary: {
|
|
6415
6668
|
command: "notary",
|
|
6416
|
-
summary: "Direct Notary summons; duties: souls/notary.md.
|
|
6669
|
+
summary: "Direct Notary summons; duties: souls/notary.md. Review uses fixed dispatch \u2014 binds --source-run identity; does not accept caller review prompt; verdict stays in the ledger. Missing-ticket (#1171) and unreadable-status reasks deliver their existing diagnostic text on the same seat, not the review sentence.",
|
|
6417
6670
|
usage: ["ak-role notary --source-run <runId@role|path> [options]"],
|
|
6418
6671
|
examples: [
|
|
6419
6672
|
"ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@judge",
|
|
@@ -6474,7 +6727,7 @@ var init_option_definitions = __esm({
|
|
|
6474
6727
|
},
|
|
6475
6728
|
resume: {
|
|
6476
6729
|
command: "resume",
|
|
6477
|
-
summary: "Resume a role run under the live seat table (model/host/engine); session principal must still exist. Every callable seat
|
|
6730
|
+
summary: "Resume a role run under the live seat table (model/host/engine); session principal must still exist. Every callable seat accepts the optional caller message and passes it through unchanged as the continuation prompt. Notary new/direct review calls use only --source-run plus the fixed review dispatch (no caller review prompt); public manual resume still passes the caller message. Global --model/--thinking/--host/--engine must be placed before <runId> (either before `resume` or between `resume` and <runId>); the one argv after <runId> is the opaque message, not a flag position (#471).",
|
|
6478
6731
|
usage: ["ak-role resume <runId> [message]"],
|
|
6479
6732
|
examples: [
|
|
6480
6733
|
"ak-role resume 01abc\u2026",
|
|
@@ -6505,14 +6758,14 @@ var init_option_definitions = __esm({
|
|
|
6505
6758
|
|
|
6506
6759
|
// src/public-cli/invocation.ts
|
|
6507
6760
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6508
|
-
import { existsSync as
|
|
6761
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
6509
6762
|
import {
|
|
6510
6763
|
readFile as readFile7,
|
|
6511
6764
|
realpath as realpath3,
|
|
6512
6765
|
rename,
|
|
6513
6766
|
writeFile
|
|
6514
6767
|
} from "node:fs/promises";
|
|
6515
|
-
import { dirname as
|
|
6768
|
+
import { dirname as dirname9, isAbsolute as isAbsolute5, join as join11, resolve as resolve8 } from "node:path";
|
|
6516
6769
|
function admittedSourceRunPath(admitted) {
|
|
6517
6770
|
if (!isRecord(admitted)) return void 0;
|
|
6518
6771
|
const path = admitted.sourceRunPath;
|
|
@@ -6671,35 +6924,36 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
6671
6924
|
mutable.correlationId = correlationId;
|
|
6672
6925
|
mutable.correlationIds = correlationIds;
|
|
6673
6926
|
}
|
|
6674
|
-
async function
|
|
6675
|
-
|
|
6676
|
-
const
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6927
|
+
async function relocateRegisteredChildDiarists(input) {
|
|
6928
|
+
const childRunIds = readPageSync(input.parentRunDirectory, "admitted")?.childDiaristRunIds;
|
|
6929
|
+
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
6930
|
+
if (typeof childRunId !== "string") continue;
|
|
6931
|
+
const childTarget = roleRunPlacement(input.ledgerHome, {
|
|
6932
|
+
bookKey: input.bookKey,
|
|
6933
|
+
subject: { ticketNumber: input.ticketNumber },
|
|
6934
|
+
runId: childRunId,
|
|
6935
|
+
role: "diarist"
|
|
6936
|
+
});
|
|
6937
|
+
const unboundChildDirectory = roleRunPlacement(input.ledgerHome, {
|
|
6938
|
+
bookKey: input.bookKey,
|
|
6939
|
+
subject: { unbound: true },
|
|
6940
|
+
runId: childRunId,
|
|
6941
|
+
role: "diarist"
|
|
6942
|
+
}).runDirectory;
|
|
6943
|
+
if (existsSync3(unboundChildDirectory)) {
|
|
6944
|
+
input.authority.seal(childTarget);
|
|
6945
|
+
await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
|
|
6946
|
+
await rehomeUnboundTicketProvenance(
|
|
6947
|
+
unboundChildDirectory,
|
|
6948
|
+
input.ticketNumber,
|
|
6949
|
+
input.projectRoot,
|
|
6950
|
+
homeFromRunDirectory(input.parentRunDirectory)
|
|
6951
|
+
);
|
|
6952
|
+
ensureRoleRunDirectory(input.ledgerHome, dirname9(childTarget.runDirectory));
|
|
6953
|
+
await rename(unboundChildDirectory, childTarget.runDirectory);
|
|
6954
|
+
relocateTicketProgressForLeg({
|
|
6955
|
+
runDirectory: childTarget.runDirectory
|
|
6697
6956
|
});
|
|
6698
|
-
authority.seal(childTarget);
|
|
6699
|
-
await bindTicketNumberOnRunDirectory(childDirectory, admitted.ticketNumber);
|
|
6700
|
-
await rehomeUnboundTicketProvenance(childDirectory, admitted.ticketNumber, admitted.projectRoot, homeFromRunDirectory(oldRunDirectory));
|
|
6701
|
-
ensureRoleRunDirectory(ledgerHome, dirname8(childTarget.runDirectory));
|
|
6702
|
-
await rename(childDirectory, childTarget.runDirectory);
|
|
6703
6957
|
try {
|
|
6704
6958
|
renderCurrentSync(childTarget.runDirectory);
|
|
6705
6959
|
} catch (error) {
|
|
@@ -6708,18 +6962,71 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
6708
6962
|
`
|
|
6709
6963
|
);
|
|
6710
6964
|
}
|
|
6965
|
+
continue;
|
|
6711
6966
|
}
|
|
6967
|
+
if (existsSync3(childTarget.runDirectory)) {
|
|
6968
|
+
relocateTicketProgressForLeg({
|
|
6969
|
+
runDirectory: childTarget.runDirectory
|
|
6970
|
+
});
|
|
6971
|
+
}
|
|
6972
|
+
}
|
|
6973
|
+
}
|
|
6974
|
+
async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
6975
|
+
if (admitted.ticketNumber === void 0) return void 0;
|
|
6976
|
+
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(admitted.runDirectory));
|
|
6977
|
+
if (!isUnboundRunDirectory(admitted.runDirectory)) {
|
|
6978
|
+
relocateTicketProgressForLeg({
|
|
6979
|
+
runDirectory: admitted.runDirectory
|
|
6980
|
+
});
|
|
6981
|
+
if (admitted.role !== "diarist") {
|
|
6982
|
+
await relocateRegisteredChildDiarists({
|
|
6983
|
+
parentRunDirectory: admitted.runDirectory,
|
|
6984
|
+
bookKey: admitted.bookKey,
|
|
6985
|
+
ticketNumber: admitted.ticketNumber,
|
|
6986
|
+
projectRoot: admitted.projectRoot,
|
|
6987
|
+
ledgerHome,
|
|
6988
|
+
authority
|
|
6989
|
+
});
|
|
6990
|
+
}
|
|
6991
|
+
return void 0;
|
|
6992
|
+
}
|
|
6993
|
+
const oldRunDirectory = admitted.runDirectory;
|
|
6994
|
+
const target = roleRunPlacement(ledgerHome, {
|
|
6995
|
+
bookKey: admitted.bookKey,
|
|
6996
|
+
subject: { ticketNumber: admitted.ticketNumber },
|
|
6997
|
+
runId: admitted.runId,
|
|
6998
|
+
role: admitted.role
|
|
6999
|
+
});
|
|
7000
|
+
ensureRoleRunDirectory(ledgerHome, dirname9(target.runDirectory));
|
|
7001
|
+
authority.seal(target);
|
|
7002
|
+
if (admitted.role !== "diarist") {
|
|
7003
|
+
await relocateRegisteredChildDiarists({
|
|
7004
|
+
parentRunDirectory: oldRunDirectory,
|
|
7005
|
+
bookKey: admitted.bookKey,
|
|
7006
|
+
ticketNumber: admitted.ticketNumber,
|
|
7007
|
+
projectRoot: admitted.projectRoot,
|
|
7008
|
+
ledgerHome,
|
|
7009
|
+
authority
|
|
7010
|
+
});
|
|
6712
7011
|
}
|
|
6713
7012
|
if (admitted.role === "diarist") {
|
|
6714
7013
|
await rehomeUnboundTicketProvenance(oldRunDirectory, admitted.ticketNumber, admitted.projectRoot, homeFromRunDirectory(oldRunDirectory));
|
|
6715
7014
|
}
|
|
6716
7015
|
await rename(oldRunDirectory, target.runDirectory);
|
|
6717
7016
|
heldLease?.relocate(target.runDirectory);
|
|
7017
|
+
const actualSessionDirectory = sessionDirectoryOf(target.runDirectory);
|
|
7018
|
+
const principal = authority.seal({
|
|
7019
|
+
sessionDirectory: actualSessionDirectory,
|
|
7020
|
+
sessionFile: sessionFileIn(actualSessionDirectory)
|
|
7021
|
+
});
|
|
6718
7022
|
rewriteAdmittedRoleRunPage(
|
|
6719
7023
|
admitted,
|
|
6720
7024
|
[{ oldRunDirectory, newRunDirectory: target.runDirectory }]
|
|
6721
7025
|
);
|
|
6722
7026
|
admitted.principal = principal;
|
|
7027
|
+
relocateTicketProgressForLeg({
|
|
7028
|
+
runDirectory: target.runDirectory
|
|
7029
|
+
});
|
|
6723
7030
|
renderCurrentSync(target.runDirectory);
|
|
6724
7031
|
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
6725
7032
|
}
|
|
@@ -6755,7 +7062,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
6755
7062
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
6756
7063
|
const rolePackageRoot = packageRoot;
|
|
6757
7064
|
const raw = JSON.parse(
|
|
6758
|
-
await readFile7(
|
|
7065
|
+
await readFile7(join11(rolePackageRoot, "package.json"), "utf8")
|
|
6759
7066
|
);
|
|
6760
7067
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
6761
7068
|
throw new Error(
|
|
@@ -7313,7 +7620,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7313
7620
|
resolutionScope: [...derived.resolutionScope],
|
|
7314
7621
|
authorizedChecks: []
|
|
7315
7622
|
});
|
|
7316
|
-
const mergerInputPath =
|
|
7623
|
+
const mergerInputPath = join11(placed.runDirectory, "merger-input.json");
|
|
7317
7624
|
await writeFile(
|
|
7318
7625
|
mergerInputPath,
|
|
7319
7626
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -7460,9 +7767,6 @@ function appendCallerFileFlagPaths(body, attachments, requestManifestPath, prere
|
|
|
7460
7767
|
}
|
|
7461
7768
|
function buildInstructionTransportPrompt(admitted) {
|
|
7462
7769
|
const kind = admittedTransportPromptKind(admitted);
|
|
7463
|
-
if (kind === "fixed-kickoff") {
|
|
7464
|
-
return "";
|
|
7465
|
-
}
|
|
7466
7770
|
if (kind === "baseline") {
|
|
7467
7771
|
if (admitted.baseRevision === void 0) {
|
|
7468
7772
|
throw new Error("baseline transport prompt is missing the bound revision");
|
|
@@ -7598,7 +7902,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
7598
7902
|
}
|
|
7599
7903
|
async function resolveDoctorCaseRunsPath(options) {
|
|
7600
7904
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
7601
|
-
const defaultRuns =
|
|
7905
|
+
const defaultRuns = join11(
|
|
7602
7906
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
7603
7907
|
String(options.issueNumber),
|
|
7604
7908
|
"runs"
|
|
@@ -7671,11 +7975,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
7671
7975
|
`${flag} requires a comma-separated list of N or book:N`
|
|
7672
7976
|
);
|
|
7673
7977
|
}
|
|
7674
|
-
const
|
|
7675
|
-
if (
|
|
7676
|
-
const rhs = trimmed.slice(
|
|
7978
|
+
const sep6 = trimmed.lastIndexOf(":");
|
|
7979
|
+
if (sep6 > 0) {
|
|
7980
|
+
const rhs = trimmed.slice(sep6 + 1);
|
|
7677
7981
|
if (parseTicketNumber(rhs) !== void 0) {
|
|
7678
|
-
const bookKey = trimmed.slice(0,
|
|
7982
|
+
const bookKey = trimmed.slice(0, sep6);
|
|
7679
7983
|
if (bookKey.trim() === "") {
|
|
7680
7984
|
throw new CliUsageError(
|
|
7681
7985
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -7872,6 +8176,7 @@ var init_invocation = __esm({
|
|
|
7872
8176
|
init_activation_ledger_topology();
|
|
7873
8177
|
init_activation_ledger_git();
|
|
7874
8178
|
init_role_run_placement();
|
|
8179
|
+
init_ticket_progress();
|
|
7875
8180
|
init_packaged_role_registry();
|
|
7876
8181
|
init_run_ticket_number();
|
|
7877
8182
|
init_role_run_relocation();
|
|
@@ -7894,7 +8199,7 @@ var init_invocation = __esm({
|
|
|
7894
8199
|
|
|
7895
8200
|
// src/report-ticket-tool.ts
|
|
7896
8201
|
import { Type as Type15 } from "typebox";
|
|
7897
|
-
import { existsSync as
|
|
8202
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
7898
8203
|
function pageString(page, key) {
|
|
7899
8204
|
const value = page?.[key];
|
|
7900
8205
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
@@ -7936,7 +8241,7 @@ async function reportTicketFromHostContext(context, rawTicketNumber, authority =
|
|
|
7936
8241
|
if (runDirectory === void 0) {
|
|
7937
8242
|
throw new Error("ak_report_ticket requires a per-turn run directory");
|
|
7938
8243
|
}
|
|
7939
|
-
if (!
|
|
8244
|
+
if (!existsSync4(runDirectory)) {
|
|
7940
8245
|
throw new Error(`ak_report_ticket run directory missing: ${runDirectory}`);
|
|
7941
8246
|
}
|
|
7942
8247
|
const admitted = admittedForLiveTicketReport(runDirectory, authority);
|
|
@@ -7955,7 +8260,11 @@ async function reportTicketFromHostContext(context, rawTicketNumber, authority =
|
|
|
7955
8260
|
context.sessionManager.setSessionFile?.(projectedSessionFile);
|
|
7956
8261
|
}
|
|
7957
8262
|
};
|
|
7958
|
-
const relocation =
|
|
8263
|
+
const relocation = await relocateAdmittedRunToTicket(
|
|
8264
|
+
admitted,
|
|
8265
|
+
authority,
|
|
8266
|
+
alreadyPlaced ? void 0 : { relocate: applyLiveHandles }
|
|
8267
|
+
);
|
|
7959
8268
|
const nextDirectory = relocation?.newRunDirectory ?? admitted.runDirectory;
|
|
7960
8269
|
if (relocation === void 0) applyLiveHandles(nextDirectory);
|
|
7961
8270
|
return {
|
|
@@ -8212,6 +8521,7 @@ async function sealAcceptedSubmission(options) {
|
|
|
8212
8521
|
const attemptId = attemptIdentity(options.context, runId);
|
|
8213
8522
|
const sessionParent = sessionParentFromHostContext(options.context);
|
|
8214
8523
|
const home = homeFromHostContext(options.context, options.home);
|
|
8524
|
+
const sealHead = captureWorktreeHead(options.context.cwd);
|
|
8215
8525
|
sitianReport({
|
|
8216
8526
|
level: "event",
|
|
8217
8527
|
kind: "sealed",
|
|
@@ -8228,6 +8538,12 @@ async function sealAcceptedSubmission(options) {
|
|
|
8228
8538
|
...home !== void 0 ? { home } : {},
|
|
8229
8539
|
...sessionParent === void 0 ? {} : { sessionParent }
|
|
8230
8540
|
});
|
|
8541
|
+
landTicketProgressForSealedSubmission({
|
|
8542
|
+
context: options.context,
|
|
8543
|
+
role: options.role,
|
|
8544
|
+
accepted: options.accepted,
|
|
8545
|
+
sealHead
|
|
8546
|
+
});
|
|
8231
8547
|
}
|
|
8232
8548
|
function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (error) => {
|
|
8233
8549
|
throw error;
|
|
@@ -8352,6 +8668,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
8352
8668
|
kind: "accepted",
|
|
8353
8669
|
accepted: params
|
|
8354
8670
|
};
|
|
8671
|
+
const sealHead = captureWorktreeHead(context.cwd);
|
|
8355
8672
|
append({
|
|
8356
8673
|
type: "sealed",
|
|
8357
8674
|
attemptId,
|
|
@@ -8359,6 +8676,14 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
8359
8676
|
role,
|
|
8360
8677
|
accepted: params
|
|
8361
8678
|
});
|
|
8679
|
+
const rawLens = typeof host.getFlag === "function" ? host.getFlag("ak-review-lens") : void 0;
|
|
8680
|
+
landTicketProgressForSealedSubmission({
|
|
8681
|
+
context,
|
|
8682
|
+
role,
|
|
8683
|
+
accepted: params,
|
|
8684
|
+
sealHead,
|
|
8685
|
+
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
|
|
8686
|
+
});
|
|
8362
8687
|
await projectClosure(closed, context);
|
|
8363
8688
|
return result;
|
|
8364
8689
|
}
|
|
@@ -8380,6 +8705,7 @@ var init_submission_ledger = __esm({
|
|
|
8380
8705
|
init_report_ticket_tool();
|
|
8381
8706
|
init_review_submission();
|
|
8382
8707
|
init_run_ticket_number();
|
|
8708
|
+
init_ticket_progress();
|
|
8383
8709
|
init_unknown_value();
|
|
8384
8710
|
}
|
|
8385
8711
|
});
|
|
@@ -8566,7 +8892,7 @@ var init_engine_detour_usage = __esm({
|
|
|
8566
8892
|
});
|
|
8567
8893
|
|
|
8568
8894
|
// src/dossier-resolution.ts
|
|
8569
|
-
import { existsSync as
|
|
8895
|
+
import { existsSync as existsSync5, statSync as statSync4 } from "node:fs";
|
|
8570
8896
|
import { resolve as resolve9 } from "node:path";
|
|
8571
8897
|
function isHostContext(value) {
|
|
8572
8898
|
return "sessionManager" in value;
|
|
@@ -8586,7 +8912,7 @@ function resolveAuditDossier(source) {
|
|
|
8586
8912
|
}
|
|
8587
8913
|
const runDirectory = resolve9(raw);
|
|
8588
8914
|
try {
|
|
8589
|
-
if (!
|
|
8915
|
+
if (!existsSync5(runDirectory) || !statSync4(runDirectory).isDirectory()) {
|
|
8590
8916
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
8591
8917
|
}
|
|
8592
8918
|
} catch {
|
|
@@ -9904,12 +10230,12 @@ var init_settlement = __esm({
|
|
|
9904
10230
|
});
|
|
9905
10231
|
|
|
9906
10232
|
// src/external-host-turn-loop.ts
|
|
9907
|
-
import { existsSync as
|
|
9908
|
-
import { basename as
|
|
10233
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
10234
|
+
import { basename as basename9 } from "node:path";
|
|
9909
10235
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
9910
10236
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
9911
10237
|
if (live === void 0) {
|
|
9912
|
-
const parsed = parseRunLeaf(
|
|
10238
|
+
const parsed = parseRunLeaf(basename9(request.runDirectory));
|
|
9913
10239
|
throw new Error(
|
|
9914
10240
|
`admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
|
|
9915
10241
|
);
|
|
@@ -9928,7 +10254,7 @@ async function trySyncTurnRequestLivePlacement(request, authority) {
|
|
|
9928
10254
|
}
|
|
9929
10255
|
async function retainPackageFaultBesideLivePlacement(request, input) {
|
|
9930
10256
|
let runDirectory = request.runDirectory;
|
|
9931
|
-
if (!
|
|
10257
|
+
if (!existsSync6(runDirectory)) {
|
|
9932
10258
|
try {
|
|
9933
10259
|
const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
9934
10260
|
if (found === void 0) {
|
|
@@ -10099,6 +10425,7 @@ async function driveExternalRoleTurnRounds(prepared, request, driver) {
|
|
|
10099
10425
|
}
|
|
10100
10426
|
}
|
|
10101
10427
|
prompt = closure.retry.message;
|
|
10428
|
+
prepared.recordSentInstruction?.(prompt);
|
|
10102
10429
|
driver.afterRetry?.();
|
|
10103
10430
|
}
|
|
10104
10431
|
}
|
|
@@ -10141,9 +10468,9 @@ var init_external_host_turn_loop = __esm({
|
|
|
10141
10468
|
});
|
|
10142
10469
|
|
|
10143
10470
|
// src/session-identity.ts
|
|
10144
|
-
import {
|
|
10471
|
+
import { join as join12 } from "node:path";
|
|
10145
10472
|
function createSessionIdentityAuthority(authority, hostName) {
|
|
10146
|
-
const runDirectoryOf = (principal) =>
|
|
10473
|
+
const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
|
|
10147
10474
|
return {
|
|
10148
10475
|
principalAuthority: authority,
|
|
10149
10476
|
resolveSessionFile(principal) {
|
|
@@ -10151,7 +10478,7 @@ function createSessionIdentityAuthority(authority, hostName) {
|
|
|
10151
10478
|
},
|
|
10152
10479
|
async load(principal) {
|
|
10153
10480
|
const runDirectory = runDirectoryOf(principal);
|
|
10154
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
10481
|
+
const { records, diagnostics } = await readSitianRecords(join12(runDirectory, RUN_STATE_FILE));
|
|
10155
10482
|
if (diagnostics.length > 0) {
|
|
10156
10483
|
throw new Error(
|
|
10157
10484
|
`${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
|
|
@@ -10198,6 +10525,7 @@ var init_session_identity = __esm({
|
|
|
10198
10525
|
"src/session-identity.ts"() {
|
|
10199
10526
|
"use strict";
|
|
10200
10527
|
init_host_descriptions();
|
|
10528
|
+
init_role_run_placement();
|
|
10201
10529
|
init_run_dossier();
|
|
10202
10530
|
init_sitian_facade();
|
|
10203
10531
|
init_unknown_value();
|
|
@@ -10220,14 +10548,14 @@ __export(role_turn_host_exports, {
|
|
|
10220
10548
|
});
|
|
10221
10549
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
10222
10550
|
import { constants } from "node:fs";
|
|
10223
|
-
import { existsSync as
|
|
10551
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
10224
10552
|
import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
|
|
10225
|
-
import { delimiter, dirname as dirname10, isAbsolute as isAbsolute6, join as
|
|
10553
|
+
import { delimiter, dirname as dirname10, isAbsolute as isAbsolute6, join as join13, resolve as resolve11 } from "node:path";
|
|
10226
10554
|
import { platform } from "node:process";
|
|
10227
10555
|
import { promisify as promisify2 } from "node:util";
|
|
10228
10556
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
10229
10557
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
10230
|
-
return
|
|
10558
|
+
return join13(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
10231
10559
|
}
|
|
10232
10560
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
10233
10561
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -10417,7 +10745,7 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
10417
10745
|
homeFromRunDirectory(spawnDir)
|
|
10418
10746
|
);
|
|
10419
10747
|
} catch (resolveError) {
|
|
10420
|
-
runDirectory =
|
|
10748
|
+
runDirectory = existsSync7(spawnDir) ? spawnDir : void 0;
|
|
10421
10749
|
const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
|
|
10422
10750
|
if (runDirectory !== void 0) {
|
|
10423
10751
|
await retainPackageFault({
|
|
@@ -10470,7 +10798,8 @@ function createPiRoleTurnHost(config) {
|
|
|
10470
10798
|
config.extraPiArgs ?? []
|
|
10471
10799
|
);
|
|
10472
10800
|
const args = buildExplicitInternalActivationArgs(roleEntry, extraArgs);
|
|
10473
|
-
const
|
|
10801
|
+
const transportBody = piUserDialogueBody(turnRequest);
|
|
10802
|
+
const stdin = encodeUserDialogueStdin(transportBody);
|
|
10474
10803
|
const env = {
|
|
10475
10804
|
...process.env,
|
|
10476
10805
|
HOME: request.home,
|
|
@@ -10486,6 +10815,7 @@ function createPiRoleTurnHost(config) {
|
|
|
10486
10815
|
else env.AK_ROLE_INVOCATION_SCOPE = request.invocationScopeId;
|
|
10487
10816
|
if (request.host === void 0 || request.host.trim() === "") delete env.AK_ROLE_HOST;
|
|
10488
10817
|
else env.AK_ROLE_HOST = request.host.trim();
|
|
10818
|
+
delete env.AK_ROLE_SUMMONS_INSTRUCTION;
|
|
10489
10819
|
if (request.deliveryRequestLimit === void 0) delete env[RECEIPT_DELIVERY_LIMIT_ENV];
|
|
10490
10820
|
else env[RECEIPT_DELIVERY_LIMIT_ENV] = String(request.deliveryRequestLimit);
|
|
10491
10821
|
applyEngineChildEnv(env, request.engine);
|
|
@@ -10618,8 +10948,8 @@ var init_role_turn_host = __esm({
|
|
|
10618
10948
|
});
|
|
10619
10949
|
|
|
10620
10950
|
// src/package-resources/engine-material.ts
|
|
10621
|
-
import { existsSync as
|
|
10622
|
-
import { join as
|
|
10951
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
10952
|
+
import { join as join14 } from "node:path";
|
|
10623
10953
|
function pickEngineAxis(source) {
|
|
10624
10954
|
return {
|
|
10625
10955
|
...source.engine === void 0 ? {} : { engine: source.engine },
|
|
@@ -10640,14 +10970,14 @@ function isEngineNameSyntax(name) {
|
|
|
10640
10970
|
return true;
|
|
10641
10971
|
}
|
|
10642
10972
|
function resolveEngineMaterialDirectory(packageRoot) {
|
|
10643
|
-
return
|
|
10973
|
+
return join14(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
10644
10974
|
}
|
|
10645
10975
|
function resolveEngineDispatchMaterialPath(packageRoot) {
|
|
10646
|
-
return
|
|
10976
|
+
return join14(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
|
|
10647
10977
|
}
|
|
10648
10978
|
function resolveEngineMaterialPath(packageRoot, name) {
|
|
10649
10979
|
const legal = assertLegalEngineName(name);
|
|
10650
|
-
return
|
|
10980
|
+
return join14(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
|
|
10651
10981
|
}
|
|
10652
10982
|
function assertLegalEngineName(name) {
|
|
10653
10983
|
if (!isEngineNameSyntax(name)) {
|
|
@@ -10664,12 +10994,12 @@ function engineSessionMaterialFromOptions(options) {
|
|
|
10664
10994
|
const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
|
|
10665
10995
|
const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
|
|
10666
10996
|
const modelField = model === void 0 ? {} : { model };
|
|
10667
|
-
if (!
|
|
10997
|
+
if (!existsSync8(materialPath)) {
|
|
10668
10998
|
return Object.freeze({ name, ...modelField });
|
|
10669
10999
|
}
|
|
10670
|
-
const handbook =
|
|
11000
|
+
const handbook = readFileSync3(materialPath, "utf8");
|
|
10671
11001
|
const dispatchPath = resolveEngineDispatchMaterialPath(options.packageRoot);
|
|
10672
|
-
const dispatchField =
|
|
11002
|
+
const dispatchField = existsSync8(dispatchPath) ? { dispatchHandbook: readFileSync3(dispatchPath, "utf8") } : {};
|
|
10673
11003
|
return Object.freeze({ name, handbook, ...dispatchField, ...modelField });
|
|
10674
11004
|
}
|
|
10675
11005
|
function engineSessionReadingMaterial(engineMaterial) {
|
|
@@ -10746,7 +11076,7 @@ __export(config_exports, {
|
|
|
10746
11076
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
10747
11077
|
});
|
|
10748
11078
|
import { mkdir, readFile as readFile8, writeFile as writeFile2 } from "node:fs/promises";
|
|
10749
|
-
import { dirname as dirname11, join as
|
|
11079
|
+
import { dirname as dirname11, join as join15 } from "node:path";
|
|
10750
11080
|
function isGateOfficerSeat(value) {
|
|
10751
11081
|
return packagedProvinceConfig(value);
|
|
10752
11082
|
}
|
|
@@ -10754,7 +11084,7 @@ function publicCliConfigPath(home) {
|
|
|
10754
11084
|
if (typeof home !== "string" || home.trim() === "") {
|
|
10755
11085
|
throw new Error("home must be explicitly provided");
|
|
10756
11086
|
}
|
|
10757
|
-
return
|
|
11087
|
+
return join15(home, ".ak-roles", "public-cli.json");
|
|
10758
11088
|
}
|
|
10759
11089
|
async function loadPublicCliConfig(home) {
|
|
10760
11090
|
const path = publicCliConfigPath(home);
|
|
@@ -11214,11 +11544,11 @@ function credentialProvidersFromAuthData(data) {
|
|
|
11214
11544
|
};
|
|
11215
11545
|
}
|
|
11216
11546
|
function resolvePublicAgentDir(explicit, home) {
|
|
11217
|
-
return explicit ?? process.env.PI_CODING_AGENT_DIR ??
|
|
11547
|
+
return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join15(home, ".pi", "agent");
|
|
11218
11548
|
}
|
|
11219
11549
|
async function loadCredentialProviders(agentDir) {
|
|
11220
11550
|
try {
|
|
11221
|
-
const raw = await readFile8(
|
|
11551
|
+
const raw = await readFile8(join15(agentDir, "auth.json"), "utf8");
|
|
11222
11552
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
11223
11553
|
} catch (error) {
|
|
11224
11554
|
if (isEnoent(error)) return { "openai-codex": false, xai: false };
|
|
@@ -11242,16 +11572,16 @@ var init_config = __esm({
|
|
|
11242
11572
|
});
|
|
11243
11573
|
|
|
11244
11574
|
// src/public-cli/host-providers.ts
|
|
11245
|
-
import { readFileSync as
|
|
11246
|
-
import { join as
|
|
11575
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
11576
|
+
import { join as join16 } from "node:path";
|
|
11247
11577
|
function hostProvidersPath(home) {
|
|
11248
11578
|
if (typeof home !== "string" || home.trim() === "") {
|
|
11249
11579
|
throw new Error("home must be explicitly provided");
|
|
11250
11580
|
}
|
|
11251
|
-
return
|
|
11581
|
+
return join16(home, ".ak-roles", "host-providers.json");
|
|
11252
11582
|
}
|
|
11253
11583
|
function hermesProviderModelsCachePath(home) {
|
|
11254
|
-
return
|
|
11584
|
+
return join16(home, ".hermes", "provider_models_cache.json");
|
|
11255
11585
|
}
|
|
11256
11586
|
function parseHostProvidersTable(value) {
|
|
11257
11587
|
if (!isRecord(value)) {
|
|
@@ -11288,7 +11618,7 @@ function parseHostProvidersTable(value) {
|
|
|
11288
11618
|
function loadHostProvidersTable(home) {
|
|
11289
11619
|
const path = hostProvidersPath(home);
|
|
11290
11620
|
try {
|
|
11291
|
-
const raw =
|
|
11621
|
+
const raw = readFileSync4(path, "utf8");
|
|
11292
11622
|
return parseHostProvidersTable(JSON.parse(raw));
|
|
11293
11623
|
} catch (error) {
|
|
11294
11624
|
if (isEnoent(error)) return {};
|
|
@@ -11304,7 +11634,7 @@ function listHermesProvidersForModel(home, seatModel) {
|
|
|
11304
11634
|
const path = hermesProviderModelsCachePath(home);
|
|
11305
11635
|
let text;
|
|
11306
11636
|
try {
|
|
11307
|
-
text =
|
|
11637
|
+
text = readFileSync4(path, "utf8");
|
|
11308
11638
|
} catch (error) {
|
|
11309
11639
|
if (isEnoent(error)) return [];
|
|
11310
11640
|
throw error;
|
|
@@ -11401,17 +11731,17 @@ var init_host_providers = __esm({
|
|
|
11401
11731
|
});
|
|
11402
11732
|
|
|
11403
11733
|
// src/public-cli/load-production-acp-host.ts
|
|
11404
|
-
import { existsSync as
|
|
11405
|
-
import { join as
|
|
11734
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
11735
|
+
import { join as join17 } from "node:path";
|
|
11406
11736
|
import { pathToFileURL } from "node:url";
|
|
11407
11737
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
11408
11738
|
const description = lookupHostDescription(host);
|
|
11409
11739
|
if (description === void 0) {
|
|
11410
11740
|
throw new Error(`unregistered host: ${host}`);
|
|
11411
11741
|
}
|
|
11412
|
-
const built =
|
|
11413
|
-
const source =
|
|
11414
|
-
const target =
|
|
11742
|
+
const built = join17(packageRoot, "dist/acp-host/production-host.js");
|
|
11743
|
+
const source = join17(packageRoot, "src/acp-host/production-host.ts");
|
|
11744
|
+
const target = existsSync9(built) ? built : source;
|
|
11415
11745
|
const href = pathToFileURL(target).href;
|
|
11416
11746
|
const mod = await import(href);
|
|
11417
11747
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -11425,17 +11755,17 @@ var init_load_production_acp_host = __esm({
|
|
|
11425
11755
|
});
|
|
11426
11756
|
|
|
11427
11757
|
// src/public-cli/load-production-headless-host.ts
|
|
11428
|
-
import { existsSync as
|
|
11429
|
-
import { join as
|
|
11758
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
11759
|
+
import { join as join18 } from "node:path";
|
|
11430
11760
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
11431
11761
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
11432
11762
|
const description = lookupHeadlessHostDescription(host);
|
|
11433
11763
|
if (description === void 0) {
|
|
11434
11764
|
throw new Error(`unregistered headless host: ${host}`);
|
|
11435
11765
|
}
|
|
11436
|
-
const built =
|
|
11437
|
-
const source =
|
|
11438
|
-
const target =
|
|
11766
|
+
const built = join18(packageRoot, "dist/headless-host/production-host.js");
|
|
11767
|
+
const source = join18(packageRoot, "src/headless-host/production-host.ts");
|
|
11768
|
+
const target = existsSync10(built) ? built : source;
|
|
11439
11769
|
const href = pathToFileURL2(target).href;
|
|
11440
11770
|
const mod = await import(href);
|
|
11441
11771
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -11602,14 +11932,14 @@ var init_role_seat_runtime = __esm({
|
|
|
11602
11932
|
});
|
|
11603
11933
|
|
|
11604
11934
|
// src/session-opening-materials.ts
|
|
11605
|
-
import { existsSync as
|
|
11935
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
11606
11936
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
11607
|
-
import { dirname as dirname12, join as
|
|
11937
|
+
import { dirname as dirname12, join as join19 } from "node:path";
|
|
11608
11938
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11609
11939
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
11610
11940
|
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
11611
11941
|
for (let i = 0; i < 8; i += 1) {
|
|
11612
|
-
if (
|
|
11942
|
+
if (existsSync11(join19(dir, "package.json")) && existsSync11(join19(dir, "souls"))) {
|
|
11613
11943
|
return dir;
|
|
11614
11944
|
}
|
|
11615
11945
|
const parent = dirname12(dir);
|
|
@@ -11969,7 +12299,7 @@ __export(auditor_soul_exports, {
|
|
|
11969
12299
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
11970
12300
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
11971
12301
|
});
|
|
11972
|
-
import { basename as
|
|
12302
|
+
import { basename as basename10 } from "node:path";
|
|
11973
12303
|
function auditorSoulRelativePath(role) {
|
|
11974
12304
|
return `souls/${role}-auditor.md`;
|
|
11975
12305
|
}
|
|
@@ -12005,7 +12335,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
12005
12335
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
12006
12336
|
}
|
|
12007
12337
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
12008
|
-
const role = parseRunLeaf(
|
|
12338
|
+
const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
|
|
12009
12339
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
12010
12340
|
}
|
|
12011
12341
|
async function readAuditorResumeBinding(admitted) {
|
|
@@ -12048,16 +12378,16 @@ var init_auditor_soul = __esm({
|
|
|
12048
12378
|
// src/public-cli/machine-method-skills.ts
|
|
12049
12379
|
import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
|
|
12050
12380
|
import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
12051
|
-
import { join as
|
|
12052
|
-
import { spawnSync as
|
|
12381
|
+
import { join as join21 } from "node:path";
|
|
12382
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
12053
12383
|
function skillRoot(home) {
|
|
12054
|
-
return
|
|
12384
|
+
return join21(home, ".agents/skills");
|
|
12055
12385
|
}
|
|
12056
12386
|
function installedMethodSkillPath(home, name) {
|
|
12057
12387
|
return installedSkillPath(skillRoot(home), name);
|
|
12058
12388
|
}
|
|
12059
12389
|
function installedSkillPath(root, name) {
|
|
12060
|
-
const path =
|
|
12390
|
+
const path = join21(root, name, "SKILL.md");
|
|
12061
12391
|
try {
|
|
12062
12392
|
if (!statSync5(path).isFile()) return void 0;
|
|
12063
12393
|
accessSync(path, constants2.R_OK);
|
|
@@ -12070,9 +12400,9 @@ function installedSkillPath(root, name) {
|
|
|
12070
12400
|
}
|
|
12071
12401
|
function linkedSkillRoot(home, host) {
|
|
12072
12402
|
if (host === "claude" || host === "claude-code") {
|
|
12073
|
-
return
|
|
12403
|
+
return join21(process.env.CLAUDE_CONFIG_DIR?.trim() || join21(home, ".claude"), "skills");
|
|
12074
12404
|
}
|
|
12075
|
-
if (host === "hermes") return
|
|
12405
|
+
if (host === "hermes") return join21(home, ".hermes/skills");
|
|
12076
12406
|
return void 0;
|
|
12077
12407
|
}
|
|
12078
12408
|
async function occupied(path) {
|
|
@@ -12100,7 +12430,7 @@ async function warnMissingMethodSkills(home, host, role, skills, stdout) {
|
|
|
12100
12430
|
}
|
|
12101
12431
|
}
|
|
12102
12432
|
function runSkillsCli(args, home) {
|
|
12103
|
-
const result =
|
|
12433
|
+
const result = spawnSync3("npx", ["--yes", "skills", ...args], {
|
|
12104
12434
|
stdio: "inherit",
|
|
12105
12435
|
env: { ...process.env, HOME: home }
|
|
12106
12436
|
});
|
|
@@ -12129,7 +12459,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12129
12459
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
12130
12460
|
let unsourced = false;
|
|
12131
12461
|
for (const name of packagedMethodSkillNames()) {
|
|
12132
|
-
const path =
|
|
12462
|
+
const path = join21(canonical, name);
|
|
12133
12463
|
if (await occupied(path)) {
|
|
12134
12464
|
warnOccupied(path, stdout);
|
|
12135
12465
|
continue;
|
|
@@ -12159,9 +12489,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12159
12489
|
throw error;
|
|
12160
12490
|
}
|
|
12161
12491
|
for (const name of packagedMethodSkillNames()) {
|
|
12162
|
-
const target =
|
|
12492
|
+
const target = join21(canonical, name);
|
|
12163
12493
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
12164
|
-
const link =
|
|
12494
|
+
const link = join21(root, name);
|
|
12165
12495
|
if (await occupied(link)) {
|
|
12166
12496
|
warnOccupied(link, stdout);
|
|
12167
12497
|
continue;
|
|
@@ -12221,7 +12551,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
|
12221
12551
|
...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
|
|
12222
12552
|
...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
|
|
12223
12553
|
...options.navigatorByStatusPrepare === void 0 ? {} : { navigatorByStatusPrepare: options.navigatorByStatusPrepare },
|
|
12224
|
-
...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
|
|
12554
|
+
...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit },
|
|
12555
|
+
...options.host === void 0 || options.host.trim() === "" ? {} : { host: options.host.trim() }
|
|
12225
12556
|
};
|
|
12226
12557
|
}
|
|
12227
12558
|
function packagedSettleSkill(admitted) {
|
|
@@ -12861,10 +13192,7 @@ function buildReceiptDeliveryRequest(input) {
|
|
|
12861
13192
|
...request,
|
|
12862
13193
|
continuation: {
|
|
12863
13194
|
kind: "resume",
|
|
12864
|
-
prompt:
|
|
12865
|
-
...receiptDelivery.deliveryState(),
|
|
12866
|
-
deliveryTurns: receiptDelivery.issuedDeliveryRequests() + 1
|
|
12867
|
-
})
|
|
13195
|
+
prompt: request.continuation.prompt
|
|
12868
13196
|
},
|
|
12869
13197
|
deliveryRequestLimit: receiptDelivery.limit
|
|
12870
13198
|
};
|
|
@@ -13627,7 +13955,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
13627
13955
|
...firstTurn,
|
|
13628
13956
|
continuation: {
|
|
13629
13957
|
kind: "resume",
|
|
13630
|
-
prompt:
|
|
13958
|
+
prompt: firstTurn.continuation.prompt
|
|
13631
13959
|
}
|
|
13632
13960
|
};
|
|
13633
13961
|
}
|
|
@@ -13746,7 +14074,7 @@ async function runPostAdmissionOneShot(input) {
|
|
|
13746
14074
|
...input.request,
|
|
13747
14075
|
continuation: {
|
|
13748
14076
|
kind: "resume",
|
|
13749
|
-
prompt:
|
|
14077
|
+
prompt: input.request.continuation.prompt
|
|
13750
14078
|
}
|
|
13751
14079
|
}),
|
|
13752
14080
|
adapters: input.adapters,
|
|
@@ -13967,6 +14295,7 @@ __export(instruction_seat_run_exports, {
|
|
|
13967
14295
|
NOTARY_FIXED_DISPATCH: () => NOTARY_FIXED_DISPATCH,
|
|
13968
14296
|
buildInstructionSeatTurnRequest: () => buildInstructionSeatTurnRequest,
|
|
13969
14297
|
continueParentAfterChild: () => continueParentAfterChild,
|
|
14298
|
+
resolveReviewSeatDialogueBody: () => resolveReviewSeatDialogueBody,
|
|
13970
14299
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
13971
14300
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
13972
14301
|
});
|
|
@@ -14037,7 +14366,8 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io,
|
|
|
14037
14366
|
{
|
|
14038
14367
|
runId: admitted.runId,
|
|
14039
14368
|
runDirectory: admitted.runDirectory,
|
|
14040
|
-
|
|
14369
|
+
message,
|
|
14370
|
+
summons: { instructionEmpty: true }
|
|
14041
14371
|
},
|
|
14042
14372
|
next,
|
|
14043
14373
|
io
|
|
@@ -14064,7 +14394,8 @@ async function reaskMissingTicketOnce(admitted, terminal, env, io) {
|
|
|
14064
14394
|
{
|
|
14065
14395
|
runId: admitted.runId,
|
|
14066
14396
|
runDirectory: admitted.runDirectory,
|
|
14067
|
-
|
|
14397
|
+
message: instruction,
|
|
14398
|
+
summons: { instructionEmpty: true }
|
|
14068
14399
|
},
|
|
14069
14400
|
softReaskEnv,
|
|
14070
14401
|
io
|
|
@@ -14177,26 +14508,26 @@ async function loadLedgerPeerBody(sourceRunDirectory, projectRoot, home) {
|
|
|
14177
14508
|
return readableGateItem(latest.accepted);
|
|
14178
14509
|
}
|
|
14179
14510
|
async function resolveReviewSeatDialogueBody(input) {
|
|
14180
|
-
|
|
14181
|
-
|
|
14511
|
+
if (input.role === "notary") {
|
|
14512
|
+
if (input.reviewReask !== void 0) return input.reviewReask;
|
|
14513
|
+
return NOTARY_FIXED_DISPATCH;
|
|
14514
|
+
}
|
|
14515
|
+
const preferred = input.reviewReask ?? input.gateReviewInstruction;
|
|
14516
|
+
if (preferred !== void 0 && preferred.length > 0) return preferred;
|
|
14182
14517
|
const caller = input.callerInstruction ?? "";
|
|
14183
14518
|
if (caller.length > 0) return caller;
|
|
14184
14519
|
const sourceRunPath = admittedSourceRunPath(input)?.trim();
|
|
14185
14520
|
if (sourceRunPath === void 0) return void 0;
|
|
14186
|
-
if (input.role === "notary") {
|
|
14187
|
-
const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
14188
|
-
if (isTicketCourtCountersignSource2(sourceRunPath)) return NOTARY_FIXED_DISPATCH;
|
|
14189
|
-
}
|
|
14190
14521
|
return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
|
|
14191
14522
|
}
|
|
14192
|
-
async function
|
|
14523
|
+
async function resolveInitialTurnPrompt(admitted, env) {
|
|
14193
14524
|
const record = roleRecord(admitted.role);
|
|
14194
14525
|
if ("reaskPrompt" in record && record.reaskPrompt === true) {
|
|
14195
14526
|
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
14196
|
-
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
14197
14527
|
const body = await resolveReviewSeatDialogueBody({
|
|
14198
14528
|
role: admitted.role,
|
|
14199
|
-
...
|
|
14529
|
+
...env.reviewReask === void 0 ? {} : { reviewReask: env.reviewReask },
|
|
14530
|
+
...env.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: env.gateReviewInstruction },
|
|
14200
14531
|
callerInstruction: admitted.instruction,
|
|
14201
14532
|
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
14202
14533
|
projectRoot: admitted.projectRoot,
|
|
@@ -14286,7 +14617,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
14286
14617
|
if (activeEnv.correlationId !== void 0 && activeEnv.correlationId.trim() !== "") {
|
|
14287
14618
|
await recordAdmittedCorrelation(admitted, activeEnv.correlationId);
|
|
14288
14619
|
}
|
|
14289
|
-
const
|
|
14620
|
+
const initialPrompt = await resolveInitialTurnPrompt(admitted, activeEnv);
|
|
14290
14621
|
const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
|
|
14291
14622
|
if (auto) {
|
|
14292
14623
|
return await runPostAdmissionResumable({
|
|
@@ -14297,14 +14628,14 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
14297
14628
|
admitted,
|
|
14298
14629
|
roleTurnOptions(activeEnv, admitted, {
|
|
14299
14630
|
kind: "initial",
|
|
14300
|
-
prompt:
|
|
14631
|
+
prompt: initialPrompt
|
|
14301
14632
|
})
|
|
14302
14633
|
),
|
|
14303
14634
|
buildResumeRequest: () => buildInstructionSeatTurnRequest(
|
|
14304
14635
|
admitted,
|
|
14305
14636
|
roleTurnOptions(activeEnv, admitted, {
|
|
14306
14637
|
kind: "resume",
|
|
14307
|
-
prompt:
|
|
14638
|
+
prompt: initialPrompt
|
|
14308
14639
|
})
|
|
14309
14640
|
),
|
|
14310
14641
|
adapters,
|
|
@@ -14319,7 +14650,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
14319
14650
|
admitted,
|
|
14320
14651
|
roleTurnOptions(activeEnv, admitted, {
|
|
14321
14652
|
kind: "initial",
|
|
14322
|
-
prompt:
|
|
14653
|
+
prompt: initialPrompt
|
|
14323
14654
|
})
|
|
14324
14655
|
),
|
|
14325
14656
|
adapters,
|
|
@@ -14404,22 +14735,26 @@ function resumeSameParentInstructionSeat(input) {
|
|
|
14404
14735
|
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
|
|
14405
14736
|
freshSummons: input.env.freshSummons,
|
|
14406
14737
|
summons: input.summons,
|
|
14407
|
-
resume: (runId, materials, runDirectory) =>
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14738
|
+
resume: (runId, materials, runDirectory) => {
|
|
14739
|
+
const reask = input.env.reviewReask;
|
|
14740
|
+
return runPublicInstructionSeatResume(
|
|
14741
|
+
{
|
|
14742
|
+
runId,
|
|
14743
|
+
runDirectory,
|
|
14744
|
+
...reask === void 0 ? {} : { message: reask },
|
|
14745
|
+
...materials === void 0 ? {} : { summons: materials }
|
|
14746
|
+
},
|
|
14747
|
+
input.env,
|
|
14748
|
+
input.io
|
|
14749
|
+
);
|
|
14750
|
+
}
|
|
14416
14751
|
});
|
|
14417
14752
|
}
|
|
14418
14753
|
async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, role) {
|
|
14419
|
-
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
14420
14754
|
const body = await resolveReviewSeatDialogueBody({
|
|
14421
14755
|
role,
|
|
14422
|
-
...
|
|
14756
|
+
...env.reviewReask === void 0 ? {} : { reviewReask: env.reviewReask },
|
|
14757
|
+
...env.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: env.gateReviewInstruction },
|
|
14423
14758
|
callerInstruction: fallback.instruction,
|
|
14424
14759
|
sourceRunPath,
|
|
14425
14760
|
projectRoot,
|
|
@@ -14431,20 +14766,30 @@ async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, rol
|
|
|
14431
14766
|
return fallback;
|
|
14432
14767
|
}
|
|
14433
14768
|
async function runCountersignBody(parsed, env, io) {
|
|
14769
|
+
const projectRoot = resolve12(parsed.project ?? env.cwd);
|
|
14434
14770
|
const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
|
|
14435
14771
|
if (gateParentRunPath !== void 0) {
|
|
14436
|
-
const
|
|
14772
|
+
const dialogue = await sameParentDialogue(
|
|
14773
|
+
env,
|
|
14774
|
+
{
|
|
14775
|
+
instruction: parsed.instruction ?? "",
|
|
14776
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14777
|
+
},
|
|
14778
|
+
gateParentRunPath,
|
|
14779
|
+
projectRoot,
|
|
14780
|
+
"countersign"
|
|
14781
|
+
);
|
|
14437
14782
|
const resumed = await resumeSameParentInstructionSeat({
|
|
14438
14783
|
env,
|
|
14439
14784
|
io,
|
|
14440
|
-
projectRoot
|
|
14785
|
+
projectRoot,
|
|
14441
14786
|
role: "countersign",
|
|
14442
14787
|
parentRunPath: gateParentRunPath,
|
|
14443
14788
|
...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
|
|
14444
14789
|
summons: {
|
|
14445
14790
|
sourceRunPath: gateParentRunPath,
|
|
14446
|
-
instruction:
|
|
14447
|
-
instructionEmpty:
|
|
14791
|
+
instruction: dialogue.instruction,
|
|
14792
|
+
instructionEmpty: dialogue.instructionEmpty,
|
|
14448
14793
|
// #1166 J11: same-parent resume delivers this call's file-flag paths
|
|
14449
14794
|
// through the shared summons → appendCallerFileFlagPaths rule.
|
|
14450
14795
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
@@ -14479,10 +14824,9 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14479
14824
|
await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
|
|
14480
14825
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
14481
14826
|
}
|
|
14482
|
-
const reviewBody = env.reviewReask ?? env.gateReviewInstruction;
|
|
14483
14827
|
const turnProjection = roleTurnOptions(env, admitted, {
|
|
14484
14828
|
kind: "initial",
|
|
14485
|
-
prompt:
|
|
14829
|
+
prompt: await resolveInitialTurnPrompt(admitted, env)
|
|
14486
14830
|
});
|
|
14487
14831
|
const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
|
|
14488
14832
|
const result = await runPostAdmissionOneShot({
|
|
@@ -14693,6 +15037,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14693
15037
|
await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
|
|
14694
15038
|
admitted = { ...admitted, sourceRunPath: auditorSource };
|
|
14695
15039
|
}
|
|
15040
|
+
admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
|
|
14696
15041
|
const runAdmitted = async () => {
|
|
14697
15042
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
14698
15043
|
if (role === "secretariat") {
|
|
@@ -14755,6 +15100,16 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14755
15100
|
}
|
|
14756
15101
|
return runAdmitted();
|
|
14757
15102
|
}
|
|
15103
|
+
async function inheritKnownTicketFromSource(admitted, authority) {
|
|
15104
|
+
if (admitted.ticketNumber !== void 0) return admitted;
|
|
15105
|
+
const sourcePath = admittedSourceRunPath(admitted);
|
|
15106
|
+
if (sourcePath === void 0) return admitted;
|
|
15107
|
+
const sourceTicket = await readBoardTicketNumber(sourcePath);
|
|
15108
|
+
if (sourceTicket === void 0) return admitted;
|
|
15109
|
+
await bindAdmittedTicketNumber(admitted, sourceTicket);
|
|
15110
|
+
await relocateAdmittedRunToTicket(admitted, authority);
|
|
15111
|
+
return admitted;
|
|
15112
|
+
}
|
|
14758
15113
|
async function runPublicInstructionSeatResume(request, env, io) {
|
|
14759
15114
|
let selectedRequest = request;
|
|
14760
15115
|
const resume = async () => {
|
|
@@ -14774,26 +15129,45 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
14774
15129
|
env.principalAuthority,
|
|
14775
15130
|
effective.runDirectory === void 0 ? void 0 : { runDirectory: effective.runDirectory }
|
|
14776
15131
|
);
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
admitted
|
|
14781
|
-
|
|
14782
|
-
|
|
14783
|
-
sourceRun: effective.summons.sourceRun
|
|
14784
|
-
}
|
|
15132
|
+
let admitted = loaded.admitted;
|
|
15133
|
+
if (packagedRebindSourceOnResume(admitted.role) && effective.summons?.sourceRunPath !== void 0 && effective.summons.sourceRun !== void 0) {
|
|
15134
|
+
admitted = {
|
|
15135
|
+
...admitted,
|
|
15136
|
+
sourceRunPath: effective.summons.sourceRunPath,
|
|
15137
|
+
sourceRun: effective.summons.sourceRun
|
|
14785
15138
|
};
|
|
14786
15139
|
}
|
|
14787
|
-
|
|
15140
|
+
admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
|
|
15141
|
+
return { ...loaded, admitted };
|
|
14788
15142
|
},
|
|
14789
15143
|
buildTurnRequest: async (admitted, effective) => {
|
|
14790
15144
|
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
14791
|
-
|
|
15145
|
+
const projection = resumeTurnRequestProjectionOptions(
|
|
14792
15146
|
admitted,
|
|
14793
|
-
|
|
14794
|
-
|
|
14795
|
-
|
|
15147
|
+
effective,
|
|
15148
|
+
env,
|
|
15149
|
+
summonsPrepared
|
|
14796
15150
|
);
|
|
15151
|
+
if (effective.summons === void 0 || effective.message !== void 0) {
|
|
15152
|
+
return buildInstructionSeatTurnRequest(admitted, { ...projection });
|
|
15153
|
+
}
|
|
15154
|
+
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
15155
|
+
const body = await resolveReviewSeatDialogueBody({
|
|
15156
|
+
role: admitted.role,
|
|
15157
|
+
callerInstruction: summonsPrepared?.instruction ?? "",
|
|
15158
|
+
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
15159
|
+
projectRoot: admitted.projectRoot,
|
|
15160
|
+
home: env.home
|
|
15161
|
+
});
|
|
15162
|
+
if (body === void 0) {
|
|
15163
|
+
return buildInstructionSeatTurnRequest(admitted, { ...projection });
|
|
15164
|
+
}
|
|
15165
|
+
const fileFlags = summonsPrepared?.attachments ?? [];
|
|
15166
|
+
const prompt = fileFlags.length === 0 ? body : appendCallerFileFlagPaths(body, fileFlags);
|
|
15167
|
+
return buildInstructionSeatTurnRequest(admitted, {
|
|
15168
|
+
...projection,
|
|
15169
|
+
continuation: { kind: "resume", prompt }
|
|
15170
|
+
});
|
|
14797
15171
|
},
|
|
14798
15172
|
adapters: {
|
|
14799
15173
|
trySettle: async () => void 0
|
|
@@ -14988,7 +15362,8 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
14988
15362
|
return runPublicInstructionSeatResume({
|
|
14989
15363
|
runId: admitted.runId,
|
|
14990
15364
|
runDirectory: admitted.runDirectory,
|
|
14991
|
-
|
|
15365
|
+
message: SECRETARIAT_STATUS_REASK,
|
|
15366
|
+
summons: { instructionEmpty: true }
|
|
14992
15367
|
}, next, io);
|
|
14993
15368
|
}
|
|
14994
15369
|
if (admitted.role === "countersign" && (typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status))) {
|
|
@@ -15002,7 +15377,8 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15002
15377
|
return runPublicInstructionSeatResume({
|
|
15003
15378
|
runId: admitted.runId,
|
|
15004
15379
|
runDirectory: admitted.runDirectory,
|
|
15005
|
-
|
|
15380
|
+
message: officerConclusionReask(status),
|
|
15381
|
+
summons: { instructionEmpty: true }
|
|
15006
15382
|
}, next, io);
|
|
15007
15383
|
}
|
|
15008
15384
|
const selfEscalationSkipsAudit = status === "escalate" && (admitted.role === "judge" || admitted.role === "secretariat" || admitted.role === "countersign");
|
|
@@ -15257,6 +15633,20 @@ var init_instruction_seat_run = __esm({
|
|
|
15257
15633
|
judge: {
|
|
15258
15634
|
statuses: REVIEW_QUEUE_STATUSES
|
|
15259
15635
|
},
|
|
15636
|
+
// #1208 C1 / ADR 0055: every review-queue seat uses the shared
|
|
15637
|
+
// unreadable-status seam (officerConclusionReask). Independent public
|
|
15638
|
+
// entry for notary/auditor/inspector was the same miss — route here, do
|
|
15639
|
+
// not invent a parallel loop. Gate summons still own the outer budget
|
|
15640
|
+
// via nestedIncomplete when this seat exhausts unsettled.
|
|
15641
|
+
notary: {
|
|
15642
|
+
statuses: REVIEW_QUEUE_STATUSES
|
|
15643
|
+
},
|
|
15644
|
+
auditor: {
|
|
15645
|
+
statuses: REVIEW_QUEUE_STATUSES
|
|
15646
|
+
},
|
|
15647
|
+
inspector: {
|
|
15648
|
+
statuses: REVIEW_QUEUE_STATUSES
|
|
15649
|
+
},
|
|
15260
15650
|
coder: {
|
|
15261
15651
|
statuses: WORKER_ROUTING_STATUSES,
|
|
15262
15652
|
reask: WORKER_STATUS_REASK
|
|
@@ -15319,10 +15709,10 @@ var init_analyst_book_key = __esm({
|
|
|
15319
15709
|
// src/atomic-write.ts
|
|
15320
15710
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
15321
15711
|
import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
|
|
15322
|
-
import { dirname as dirname14, join as
|
|
15712
|
+
import { dirname as dirname14, join as join22 } from "node:path";
|
|
15323
15713
|
async function writeFileAtomically(destination, contents, options) {
|
|
15324
15714
|
const parent = dirname14(destination);
|
|
15325
|
-
const temporary =
|
|
15715
|
+
const temporary = join22(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
15326
15716
|
try {
|
|
15327
15717
|
await writeFile3(temporary, contents, options);
|
|
15328
15718
|
await rename2(temporary, destination);
|
|
@@ -15339,12 +15729,12 @@ var init_atomic_write = __esm({
|
|
|
15339
15729
|
|
|
15340
15730
|
// src/analyst-index.ts
|
|
15341
15731
|
import { open, readFile as readFile10, unlink } from "node:fs/promises";
|
|
15342
|
-
import { dirname as dirname15, join as
|
|
15732
|
+
import { dirname as dirname15, join as join23 } from "node:path";
|
|
15343
15733
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
15344
15734
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
15345
15735
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
15346
15736
|
ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
|
|
15347
|
-
const lockPath =
|
|
15737
|
+
const lockPath = join23(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
15348
15738
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
15349
15739
|
const startedAt = Date.now();
|
|
15350
15740
|
while (true) {
|
|
@@ -15371,7 +15761,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
15371
15761
|
}
|
|
15372
15762
|
}
|
|
15373
15763
|
function analystLibraryIndexPath(ledgerHome) {
|
|
15374
|
-
return
|
|
15764
|
+
return join23(ledgerHome, "analyst", "library-index.json");
|
|
15375
15765
|
}
|
|
15376
15766
|
function rowFromIssueMetricsPage(page) {
|
|
15377
15767
|
return {
|
|
@@ -15665,7 +16055,7 @@ var init_analyst_cohort = __esm({
|
|
|
15665
16055
|
});
|
|
15666
16056
|
|
|
15667
16057
|
// src/archivist-record-pointer.ts
|
|
15668
|
-
import { basename as
|
|
16058
|
+
import { basename as basename11, join as join24 } from "node:path";
|
|
15669
16059
|
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
15670
16060
|
const where = `${parentRunDirectory} officers`;
|
|
15671
16061
|
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
@@ -15678,7 +16068,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
15678
16068
|
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
15679
16069
|
let sessionFile = raw.sessionFile;
|
|
15680
16070
|
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
15681
|
-
const leaf = parseRunLeaf(
|
|
16071
|
+
const leaf = parseRunLeaf(basename11(recordedRunDirectory));
|
|
15682
16072
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
15683
16073
|
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
15684
16074
|
const currentRunDirectory = await resolveLiveRunDirectoryPath(
|
|
@@ -15698,7 +16088,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
15698
16088
|
};
|
|
15699
16089
|
}
|
|
15700
16090
|
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
15701
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
16091
|
+
const { records, diagnostics } = await readSitianRecords(join24(parentRunDirectory, RUN_HISTORY_FILE));
|
|
15702
16092
|
if (diagnostics.length > 0) {
|
|
15703
16093
|
throw new Error(
|
|
15704
16094
|
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
@@ -15981,7 +16371,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
15981
16371
|
|
|
15982
16372
|
// src/analyst-ledger.ts
|
|
15983
16373
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
15984
|
-
import { basename as
|
|
16374
|
+
import { basename as basename12, join as join25 } from "node:path";
|
|
15985
16375
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
15986
16376
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
15987
16377
|
}
|
|
@@ -16001,7 +16391,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
16001
16391
|
}
|
|
16002
16392
|
}
|
|
16003
16393
|
async function classifyGhostCandidate(input) {
|
|
16004
|
-
const autopsy = await autopsyWriterLock(
|
|
16394
|
+
const autopsy = await autopsyWriterLock(join25(input.runDirectory, "writer.lock"));
|
|
16005
16395
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
16006
16396
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
16007
16397
|
return {
|
|
@@ -16291,7 +16681,7 @@ async function classifyScopedRun(input) {
|
|
|
16291
16681
|
async function scanAnalystIssueRuns(input) {
|
|
16292
16682
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
16293
16683
|
const scopeTicketNumber = input.ticketNumber;
|
|
16294
|
-
const booksRoot =
|
|
16684
|
+
const booksRoot = join25(ledgerHome, "books");
|
|
16295
16685
|
let wholeBook = false;
|
|
16296
16686
|
let scopeRootIdentity;
|
|
16297
16687
|
let bookNames;
|
|
@@ -16324,7 +16714,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
16324
16714
|
const ghostLegs = [];
|
|
16325
16715
|
const scopeConflicts = [];
|
|
16326
16716
|
for (const book of bookNames) {
|
|
16327
|
-
const bookDir =
|
|
16717
|
+
const bookDir = join25(booksRoot, book);
|
|
16328
16718
|
let runDirectories;
|
|
16329
16719
|
try {
|
|
16330
16720
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -16333,7 +16723,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
16333
16723
|
throw error;
|
|
16334
16724
|
}
|
|
16335
16725
|
for (const runDirectory of runDirectories) {
|
|
16336
|
-
const runName =
|
|
16726
|
+
const runName = basename12(runDirectory);
|
|
16337
16727
|
const parsed = parseRunLeaf(runName);
|
|
16338
16728
|
if (parsed === void 0) continue;
|
|
16339
16729
|
let scopeFields;
|
|
@@ -17070,7 +17460,7 @@ var init_analyst_metric_family = __esm({
|
|
|
17070
17460
|
});
|
|
17071
17461
|
|
|
17072
17462
|
// src/analyst-page.ts
|
|
17073
|
-
import { dirname as dirname16, join as
|
|
17463
|
+
import { dirname as dirname16, join as join26 } from "node:path";
|
|
17074
17464
|
function analystIssuePageKey(address) {
|
|
17075
17465
|
const parts = ["book", address.bookKey];
|
|
17076
17466
|
if (address.issueNumber !== void 0) {
|
|
@@ -17081,7 +17471,7 @@ function analystIssuePageKey(address) {
|
|
|
17081
17471
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
17082
17472
|
}
|
|
17083
17473
|
function analystIssuePagePath(ledgerHome, address) {
|
|
17084
|
-
return
|
|
17474
|
+
return join26(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
17085
17475
|
}
|
|
17086
17476
|
function analystIssuePageAddressFromPage(page) {
|
|
17087
17477
|
return {
|
|
@@ -18637,9 +19027,9 @@ __export(public_role_summons_exports, {
|
|
|
18637
19027
|
summonPublicRole: () => summonPublicRole
|
|
18638
19028
|
});
|
|
18639
19029
|
import { execFile as execFile3 } from "node:child_process";
|
|
18640
|
-
import { existsSync as
|
|
19030
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
18641
19031
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18642
|
-
import { join as
|
|
19032
|
+
import { join as join27 } from "node:path";
|
|
18643
19033
|
import { promisify as promisify3 } from "node:util";
|
|
18644
19034
|
function createCapturingIo() {
|
|
18645
19035
|
const chunks = [];
|
|
@@ -18663,7 +19053,7 @@ function parentDir(path) {
|
|
|
18663
19053
|
function walkPackageRoot(start) {
|
|
18664
19054
|
let dir = start;
|
|
18665
19055
|
for (let i = 0; i < 12; i += 1) {
|
|
18666
|
-
if (
|
|
19056
|
+
if (existsSync12(join27(dir, "package.json")) && existsSync12(join27(dir, "souls"))) {
|
|
18667
19057
|
return dir;
|
|
18668
19058
|
}
|
|
18669
19059
|
const parent = parentDir(dir);
|
|
@@ -18985,13 +19375,9 @@ async function summonGateOfficer(options) {
|
|
|
18985
19375
|
home = homeFromRunDirectory2(options.sourceRunDirectory);
|
|
18986
19376
|
}
|
|
18987
19377
|
let gateReviewInstruction;
|
|
18988
|
-
if (options.reask === void 0 && options.submission !== void 0) {
|
|
18989
|
-
const {
|
|
18990
|
-
|
|
18991
|
-
if (!blindTicketCourt) {
|
|
18992
|
-
const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
|
|
18993
|
-
gateReviewInstruction = readableGateItem2(options.submission);
|
|
18994
|
-
}
|
|
19378
|
+
if (options.reask === void 0 && options.submission !== void 0 && options.officer !== "notary") {
|
|
19379
|
+
const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
|
|
19380
|
+
gateReviewInstruction = readableGateItem2(options.submission);
|
|
18995
19381
|
}
|
|
18996
19382
|
const { runIdFromRunDirectory: runIdFromRunDirectory2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
18997
19383
|
const parentRunId = runIdFromRunDirectory2(options.sourceRunDirectory);
|
|
@@ -19042,7 +19428,14 @@ async function summonGateOfficer(options) {
|
|
|
19042
19428
|
const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
|
|
19043
19429
|
const submittedTicket = isRecord(options.submission) ? options.submission.ticketNumber : void 0;
|
|
19044
19430
|
const courtTicket = isSafePositiveTicketNumber3(submittedTicket) ? submittedTicket : parentTicket;
|
|
19045
|
-
const
|
|
19431
|
+
const { resolveReviewSeatDialogueBody: resolveReviewSeatDialogueBody2 } = await Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports));
|
|
19432
|
+
const instruction = await resolveReviewSeatDialogueBody2({
|
|
19433
|
+
role: options.officer,
|
|
19434
|
+
...options.reask === void 0 ? {} : { reviewReask: options.reask },
|
|
19435
|
+
...gateReviewInstruction === void 0 ? {} : { gateReviewInstruction },
|
|
19436
|
+
projectRoot: options.cwd,
|
|
19437
|
+
home
|
|
19438
|
+
}) ?? "";
|
|
19046
19439
|
return summonPublicRole({
|
|
19047
19440
|
role: options.officer,
|
|
19048
19441
|
argv: ["--project", options.cwd, "--", instruction],
|
|
@@ -19208,7 +19601,7 @@ var init_compliance_transport = __esm({
|
|
|
19208
19601
|
});
|
|
19209
19602
|
|
|
19210
19603
|
// src/role-run-relocation.ts
|
|
19211
|
-
import { dirname as dirname17, join as
|
|
19604
|
+
import { dirname as dirname17, join as join28 } from "node:path";
|
|
19212
19605
|
async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirectory) {
|
|
19213
19606
|
if (recordedPath === currentPath) return true;
|
|
19214
19607
|
if (typeof recordedPath !== "string") return false;
|
|
@@ -19253,11 +19646,9 @@ var init_role_run_relocation = __esm({
|
|
|
19253
19646
|
var run_lifecycle_exports = {};
|
|
19254
19647
|
__export(run_lifecycle_exports, {
|
|
19255
19648
|
AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
|
|
19256
|
-
RESUME_TRANSPORT_ENVELOPE: () => RESUME_TRANSPORT_ENVELOPE,
|
|
19257
19649
|
RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
|
|
19258
19650
|
acquireRunWriterLease: () => acquireRunWriterLease,
|
|
19259
19651
|
autopsyWriterLock: () => autopsyWriterLock,
|
|
19260
|
-
buildAutoResumeContinuationPrompt: () => buildAutoResumeContinuationPrompt,
|
|
19261
19652
|
clearCurrentCourt: () => clearCurrentCourt,
|
|
19262
19653
|
describeErrorIdentity: () => describeErrorIdentity,
|
|
19263
19654
|
findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
|
|
@@ -19276,12 +19667,9 @@ __export(run_lifecycle_exports, {
|
|
|
19276
19667
|
resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
|
|
19277
19668
|
writeRoleRunState: () => writeRoleRunState
|
|
19278
19669
|
});
|
|
19279
|
-
import { existsSync as
|
|
19670
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
19280
19671
|
import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
|
|
19281
|
-
import { basename as
|
|
19282
|
-
function buildAutoResumeContinuationPrompt() {
|
|
19283
|
-
return RESUME_TRANSPORT_ENVELOPE;
|
|
19284
|
-
}
|
|
19672
|
+
import { basename as basename13, join as join29 } from "node:path";
|
|
19285
19673
|
async function writeRoleRunState(runDirectory, record) {
|
|
19286
19674
|
const payload = { ...record, runDirectory };
|
|
19287
19675
|
writeSectionSync(runDirectory, "runState", { ...payload });
|
|
@@ -19363,13 +19751,14 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
19363
19751
|
if (typeof record.sessionDirectory !== "string") throw new TypeError("Invalid state.jsonl run-state");
|
|
19364
19752
|
const storedRunDirectory = typeof record.runDirectory === "string" && record.runDirectory.trim() !== "" ? record.runDirectory : runDirectory;
|
|
19365
19753
|
const runDir = runDirectory;
|
|
19754
|
+
const principalCoords = {
|
|
19755
|
+
sessionDirectory: record.sessionDirectory,
|
|
19756
|
+
...typeof record.sessionFile === "string" ? { sessionFile: record.sessionFile } : {}
|
|
19757
|
+
};
|
|
19758
|
+
rewritePrincipalSessionPaths(principalCoords, storedRunDirectory, runDirectory);
|
|
19366
19759
|
const principalWire = {
|
|
19367
|
-
sessionDirectory:
|
|
19368
|
-
|
|
19369
|
-
storedRunDirectory,
|
|
19370
|
-
runDirectory
|
|
19371
|
-
),
|
|
19372
|
-
...typeof record.sessionFile === "string" ? { sessionFile: rewriteRunDirectoryPathValue(record.sessionFile, storedRunDirectory, runDirectory) } : {}
|
|
19760
|
+
sessionDirectory: principalCoords.sessionDirectory,
|
|
19761
|
+
...typeof principalCoords.sessionFile === "string" ? { sessionFile: principalCoords.sessionFile } : {}
|
|
19373
19762
|
};
|
|
19374
19763
|
const phase = record.phase === "plan" || record.phase === "apply" ? record.phase : void 0;
|
|
19375
19764
|
const currentCourt = parseCurrentCourtState(record.currentCourt);
|
|
@@ -19575,7 +19964,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19575
19964
|
},
|
|
19576
19965
|
relocate(nextRunDirectory) {
|
|
19577
19966
|
currentRunDirectory = nextRunDirectory;
|
|
19578
|
-
currentLockPath =
|
|
19967
|
+
currentLockPath = join29(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19579
19968
|
},
|
|
19580
19969
|
async release() {
|
|
19581
19970
|
if (released) return;
|
|
@@ -19614,10 +20003,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19614
20003
|
};
|
|
19615
20004
|
const reportReadFailure = (error) => {
|
|
19616
20005
|
reportDiagnostic(
|
|
19617
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
20006
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join29(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19618
20007
|
);
|
|
19619
20008
|
};
|
|
19620
|
-
const lockPath =
|
|
20009
|
+
const lockPath = join29(runDirectory, WRITER_LOCK_FILE);
|
|
19621
20010
|
let lastAutopsy = { verdict: "absent" };
|
|
19622
20011
|
let lastReclaimFailure;
|
|
19623
20012
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19673,7 +20062,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19673
20062
|
}
|
|
19674
20063
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
|
|
19675
20064
|
if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
|
|
19676
|
-
const parsed = parseRunLeaf(
|
|
20065
|
+
const parsed = parseRunLeaf(basename13(knownRunDirectory));
|
|
19677
20066
|
if (parsed === void 0 || parsed.runId !== runId) {
|
|
19678
20067
|
throw new CliUsageError(
|
|
19679
20068
|
`run directory does not match run id ${runId}: ${knownRunDirectory}`
|
|
@@ -19683,7 +20072,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
|
|
|
19683
20072
|
}
|
|
19684
20073
|
if (runId.trim() === "") return void 0;
|
|
19685
20074
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19686
|
-
const booksRoot =
|
|
20075
|
+
const booksRoot = join29(ledgerHome, "books");
|
|
19687
20076
|
let bookKeys;
|
|
19688
20077
|
try {
|
|
19689
20078
|
bookKeys = await readdir4(booksRoot);
|
|
@@ -19698,8 +20087,8 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
|
|
|
19698
20087
|
);
|
|
19699
20088
|
}
|
|
19700
20089
|
async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
|
|
19701
|
-
if (
|
|
19702
|
-
const parsed = parseRunLeaf(
|
|
20090
|
+
if (existsSync13(recordedPath)) return recordedPath;
|
|
20091
|
+
const parsed = parseRunLeaf(basename13(recordedPath));
|
|
19703
20092
|
const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
|
|
19704
20093
|
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
19705
20094
|
return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
|
|
@@ -19733,7 +20122,7 @@ async function findLatestRunForSeatTicket(input) {
|
|
|
19733
20122
|
let runDirectories;
|
|
19734
20123
|
try {
|
|
19735
20124
|
runDirectories = await listBookRunDirectories(
|
|
19736
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
20125
|
+
input.ticketNumber === void 0 ? bookDir : join29(bookDir, String(input.ticketNumber))
|
|
19737
20126
|
);
|
|
19738
20127
|
} catch (error) {
|
|
19739
20128
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19741,7 +20130,7 @@ async function findLatestRunForSeatTicket(input) {
|
|
|
19741
20130
|
}
|
|
19742
20131
|
let best;
|
|
19743
20132
|
for (const runDirectory of runDirectories) {
|
|
19744
|
-
const parsed = parseRunLeaf(
|
|
20133
|
+
const parsed = parseRunLeaf(basename13(runDirectory));
|
|
19745
20134
|
if (parsed === void 0 || parsed.role !== input.role) continue;
|
|
19746
20135
|
const runId = parsed.runId;
|
|
19747
20136
|
const parentPath = await readRunParentPath(runDirectory);
|
|
@@ -20212,7 +20601,7 @@ function resumedWorkerPhase(phase, phases, role, runId) {
|
|
|
20212
20601
|
}
|
|
20213
20602
|
throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
|
|
20214
20603
|
}
|
|
20215
|
-
var AUTO_RESUME_LIMIT,
|
|
20604
|
+
var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
|
|
20216
20605
|
var init_run_lifecycle = __esm({
|
|
20217
20606
|
"src/public-cli/run-lifecycle.ts"() {
|
|
20218
20607
|
"use strict";
|
|
@@ -20227,7 +20616,6 @@ var init_run_lifecycle = __esm({
|
|
|
20227
20616
|
init_run_dossier();
|
|
20228
20617
|
init_unknown_value();
|
|
20229
20618
|
AUTO_RESUME_LIMIT = 2;
|
|
20230
|
-
RESUME_TRANSPORT_ENVELOPE = "\u7EE7\u7EED\u3002";
|
|
20231
20619
|
WRITER_LOCK_FILE = "writer.lock";
|
|
20232
20620
|
RunWriterLeaseHeldError = class extends Error {
|
|
20233
20621
|
code = "AK_RUN_WRITER_LEASE_HELD";
|
|
@@ -20497,7 +20885,7 @@ init_filed_submission();
|
|
|
20497
20885
|
init_report_ticket_tool();
|
|
20498
20886
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
20499
20887
|
import { writeSync as writeSync2 } from "node:fs";
|
|
20500
|
-
import { join as
|
|
20888
|
+
import { join as join31 } from "node:path";
|
|
20501
20889
|
import { Value as Value3 } from "typebox/value";
|
|
20502
20890
|
|
|
20503
20891
|
// src/activation-trace.ts
|
|
@@ -20547,7 +20935,7 @@ import {
|
|
|
20547
20935
|
lstatSync as lstatSync2,
|
|
20548
20936
|
realpathSync as realpathSync2,
|
|
20549
20937
|
statSync as statSync7,
|
|
20550
|
-
writeFileSync as
|
|
20938
|
+
writeFileSync as writeFileSync3
|
|
20551
20939
|
} from "node:fs";
|
|
20552
20940
|
import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
|
|
20553
20941
|
var ActivationSessionFileMissingError = class extends Error {
|
|
@@ -20568,7 +20956,7 @@ function materializeDeferredSessionFile(sessionManager, resolvedFile) {
|
|
|
20568
20956
|
throw new ActivationSessionFileMissingError(resolvedFile);
|
|
20569
20957
|
}
|
|
20570
20958
|
try {
|
|
20571
|
-
|
|
20959
|
+
writeFileSync3(resolvedFile, `${JSON.stringify(header)}
|
|
20572
20960
|
`, { flag: "wx" });
|
|
20573
20961
|
} catch (error) {
|
|
20574
20962
|
if (errnoCode(error) !== "EEXIST") {
|
|
@@ -21004,10 +21392,10 @@ init_run_ticket_number();
|
|
|
21004
21392
|
|
|
21005
21393
|
// src/audited-run-identity.ts
|
|
21006
21394
|
init_role_run_placement();
|
|
21007
|
-
import { basename as
|
|
21395
|
+
import { basename as basename14 } from "node:path";
|
|
21008
21396
|
var AUDITED_RUN_IDENTITY_KIND = "audited-run-identity";
|
|
21009
21397
|
function auditedRunIdentityFromDirectory(runDirectory) {
|
|
21010
|
-
const parsed = parseRunLeaf(
|
|
21398
|
+
const parsed = parseRunLeaf(basename14(runDirectory));
|
|
21011
21399
|
if (parsed === void 0) return void 0;
|
|
21012
21400
|
return formatRunLeaf(parsed.runId, parsed.role);
|
|
21013
21401
|
}
|
|
@@ -21186,7 +21574,7 @@ import "typebox";
|
|
|
21186
21574
|
|
|
21187
21575
|
// src/navigator-public-session.ts
|
|
21188
21576
|
init_host_session_record();
|
|
21189
|
-
import { basename as
|
|
21577
|
+
import { basename as basename15 } from "node:path";
|
|
21190
21578
|
|
|
21191
21579
|
// src/navigator-session-contracts.ts
|
|
21192
21580
|
init_unknown_value();
|
|
@@ -21390,7 +21778,7 @@ async function resolveNavigatorLedgerHome(context) {
|
|
|
21390
21778
|
return void 0;
|
|
21391
21779
|
}
|
|
21392
21780
|
function runIdFromNavigatorDirectory(runDirectory) {
|
|
21393
|
-
const parsed = parseRunLeaf(
|
|
21781
|
+
const parsed = parseRunLeaf(basename15(runDirectory));
|
|
21394
21782
|
if (parsed === void 0 || parsed.role !== "navigator") return void 0;
|
|
21395
21783
|
return parsed.runId;
|
|
21396
21784
|
}
|
|
@@ -21794,7 +22182,7 @@ function createNavigatorAttendance(options) {
|
|
|
21794
22182
|
await promptAllowingRejectedPrepare(request);
|
|
21795
22183
|
while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
|
|
21796
22184
|
delivery.recordDeliveryRequest();
|
|
21797
|
-
await promptAllowingRejectedPrepare(
|
|
22185
|
+
await promptAllowingRejectedPrepare(request);
|
|
21798
22186
|
}
|
|
21799
22187
|
if (output === void 0 && delivery.nextAction() === "request-delivery") {
|
|
21800
22188
|
delivery.closeBudget();
|
|
@@ -22021,7 +22409,7 @@ init_unknown_value();
|
|
|
22021
22409
|
init_submission_errors();
|
|
22022
22410
|
init_worker_submission_contracts();
|
|
22023
22411
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
22024
|
-
import { existsSync as
|
|
22412
|
+
import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync4 } from "node:fs";
|
|
22025
22413
|
import { resolve as resolve16 } from "node:path";
|
|
22026
22414
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
22027
22415
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -22051,7 +22439,7 @@ function statusOf(error) {
|
|
|
22051
22439
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
22052
22440
|
}
|
|
22053
22441
|
function tryGetAll(file, key) {
|
|
22054
|
-
if (!
|
|
22442
|
+
if (!existsSync14(file)) return [];
|
|
22055
22443
|
try {
|
|
22056
22444
|
const out = gitFile(file, ["--get-all", key]);
|
|
22057
22445
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -22061,8 +22449,8 @@ function tryGetAll(file, key) {
|
|
|
22061
22449
|
}
|
|
22062
22450
|
}
|
|
22063
22451
|
function ownedHook(path) {
|
|
22064
|
-
if (!
|
|
22065
|
-
return
|
|
22452
|
+
if (!existsSync14(path)) return false;
|
|
22453
|
+
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
22066
22454
|
}
|
|
22067
22455
|
function escapeGitConfigValueRegex(value) {
|
|
22068
22456
|
return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
@@ -22087,13 +22475,13 @@ function unsetOwnedHooksPath(file) {
|
|
|
22087
22475
|
function rmOwnedDir(dir) {
|
|
22088
22476
|
const hookPath = resolve16(dir, HOOK_FILE);
|
|
22089
22477
|
if (!ownedHook(hookPath)) return;
|
|
22090
|
-
|
|
22091
|
-
if (
|
|
22478
|
+
rmSync4(hookPath, { force: true });
|
|
22479
|
+
if (existsSync14(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
22092
22480
|
}
|
|
22093
22481
|
function linkedGitDirs(commonDir) {
|
|
22094
22482
|
const root = resolve16(commonDir, "worktrees");
|
|
22095
|
-
if (!
|
|
22096
|
-
return
|
|
22483
|
+
if (!existsSync14(root)) return [];
|
|
22484
|
+
return readdirSync4(root).map((name) => resolve16(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
22097
22485
|
}
|
|
22098
22486
|
function uninstallPackageWorkerHooks(cwd) {
|
|
22099
22487
|
let inside;
|
|
@@ -22111,7 +22499,7 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
22111
22499
|
clear(resolve16(commonDir, "config.worktree"));
|
|
22112
22500
|
rmOwnedDir(resolve16(commonDir, HOOKS_DIR));
|
|
22113
22501
|
const legacy = resolve16(commonDir, "hooks", HOOK_FILE);
|
|
22114
|
-
if (ownedHook(legacy))
|
|
22502
|
+
if (ownedHook(legacy)) rmSync4(legacy, { force: true });
|
|
22115
22503
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
22116
22504
|
clear(resolve16(gitDir, "config.worktree"));
|
|
22117
22505
|
rmOwnedDir(resolve16(gitDir, HOOKS_DIR));
|
|
@@ -22189,11 +22577,11 @@ function reliableWindow(cwd, baseline, head) {
|
|
|
22189
22577
|
const raw = git2(cwd, ["log", "--format=%P%x1e%s", range]);
|
|
22190
22578
|
if (raw.length === 0) return [];
|
|
22191
22579
|
return raw.split("\n").flatMap((line2) => {
|
|
22192
|
-
const
|
|
22193
|
-
if (
|
|
22580
|
+
const sep6 = line2.indexOf("");
|
|
22581
|
+
if (sep6 < 0) return [];
|
|
22194
22582
|
return [{
|
|
22195
|
-
subject: line2.slice(
|
|
22196
|
-
merge: line2.slice(0,
|
|
22583
|
+
subject: line2.slice(sep6 + 1),
|
|
22584
|
+
merge: line2.slice(0, sep6).trim().includes(" ")
|
|
22197
22585
|
}];
|
|
22198
22586
|
});
|
|
22199
22587
|
}
|
|
@@ -22931,7 +23319,7 @@ function readRoleRunCoordinates(ctx, label) {
|
|
|
22931
23319
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
22932
23320
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
22933
23321
|
if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
22934
|
-
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${
|
|
23322
|
+
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join31(runDirectory, RUN_STATE_FILE)})`);
|
|
22935
23323
|
}
|
|
22936
23324
|
return {
|
|
22937
23325
|
runDirectory,
|
|
@@ -23119,6 +23507,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23119
23507
|
let engineDetourRegistered = false;
|
|
23120
23508
|
let receiptDelivery = createReceiptDeliveryPolicy(deliveryLimit);
|
|
23121
23509
|
let noReceiptRecorded = false;
|
|
23510
|
+
let turnDialoguePrompt;
|
|
23122
23511
|
const disposeNavigatorAttendanceNonBlocking = (attendance) => {
|
|
23123
23512
|
if (attendance === void 0) return;
|
|
23124
23513
|
const recordDisposeFailure = (error) => {
|
|
@@ -23196,7 +23585,10 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23196
23585
|
settleNavigatorProjection
|
|
23197
23586
|
);
|
|
23198
23587
|
};
|
|
23199
|
-
roleHost.on("input", (
|
|
23588
|
+
roleHost.on("input", (event, ctx) => {
|
|
23589
|
+
if (typeof event.text === "string" && ctx.summonsInstruction === void 0) {
|
|
23590
|
+
ctx.summonsInstruction = event.text;
|
|
23591
|
+
}
|
|
23200
23592
|
const role = roleHost.getFlag(ROLE_FLAG.name);
|
|
23201
23593
|
if (role !== void 0 && !admitted) return { action: "handled" };
|
|
23202
23594
|
return { action: "continue" };
|
|
@@ -23205,6 +23597,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23205
23597
|
roleHost.on("before_agent_start", async (event, ctx) => {
|
|
23206
23598
|
const role = roleHost.getFlag(ROLE_FLAG.name);
|
|
23207
23599
|
const prompt = event.prompt;
|
|
23600
|
+
if (typeof prompt === "string") turnDialoguePrompt = prompt;
|
|
23208
23601
|
if (role === void 0) return;
|
|
23209
23602
|
if (!admitted || selectedRole !== role) {
|
|
23210
23603
|
failInfrastructure(new ActivationBarrierError(role), ctx);
|
|
@@ -23350,6 +23743,8 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23350
23743
|
}
|
|
23351
23744
|
if (receiptDelivery.nextAction() === "request-delivery") {
|
|
23352
23745
|
receiptDelivery.recordDeliveryRequest();
|
|
23746
|
+
const deliveryContent = turnDialoguePrompt ?? "";
|
|
23747
|
+
ctx.summonsInstruction = deliveryContent;
|
|
23353
23748
|
const scopeId = ctx.invocationScopeId?.trim() ?? "";
|
|
23354
23749
|
envelopeHost.appendEntry(
|
|
23355
23750
|
RECEIPT_DELIVERY_REQUEST_ENTRY,
|
|
@@ -23365,7 +23760,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23365
23760
|
});
|
|
23366
23761
|
envelopeHost.sendMessage({
|
|
23367
23762
|
customType: "ak-receipt-delivery-prompt",
|
|
23368
|
-
content:
|
|
23763
|
+
content: deliveryContent,
|
|
23369
23764
|
display: false
|
|
23370
23765
|
}, { triggerTurn: true, deliverAs: "followUp" });
|
|
23371
23766
|
} else if (receiptDelivery.nextAction() === "no-receipt" && !noReceiptRecorded) {
|
|
@@ -23605,6 +24000,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23605
24000
|
activeCollector = void 0;
|
|
23606
24001
|
receiptDelivery = createReceiptDeliveryPolicy(deliveryLimit);
|
|
23607
24002
|
noReceiptRecorded = false;
|
|
24003
|
+
turnDialoguePrompt = void 0;
|
|
23608
24004
|
pendingNavigatorPresentation = void 0;
|
|
23609
24005
|
navigatorActivation += 1;
|
|
23610
24006
|
navigatorDeliveryClosed = false;
|
|
@@ -24296,6 +24692,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
24296
24692
|
const record = value;
|
|
24297
24693
|
if (record.action === "transform" && typeof record.text === "string") prompt = record.text;
|
|
24298
24694
|
}
|
|
24695
|
+
context.summonsInstruction = prompt;
|
|
24299
24696
|
if (typeof prompt === "string" && prompt.trim() !== "") {
|
|
24300
24697
|
sessionEntries.push({
|
|
24301
24698
|
type: "message",
|
|
@@ -24337,6 +24734,9 @@ async function prepareRoleEnvelope(options) {
|
|
|
24337
24734
|
}],
|
|
24338
24735
|
systemPrompt: { body: systemPromptBody, materials: readingMaterials },
|
|
24339
24736
|
prompt,
|
|
24737
|
+
recordSentInstruction(text) {
|
|
24738
|
+
context.summonsInstruction = text;
|
|
24739
|
+
},
|
|
24340
24740
|
abortSignal: hostAbort.signal,
|
|
24341
24741
|
closeRound,
|
|
24342
24742
|
dispose,
|
|
@@ -24917,12 +25317,12 @@ function createAcpRoleTurnHost(config) {
|
|
|
24917
25317
|
// src/acp-host/seat-profile-soul.ts
|
|
24918
25318
|
import { constants as constants3 } from "node:fs";
|
|
24919
25319
|
import { access as access3, copyFile, lstat as lstat4, mkdir as mkdir4, readlink, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
|
|
24920
|
-
import { dirname as dirname20, join as
|
|
25320
|
+
import { dirname as dirname20, join as join32, relative as relative4, resolve as resolve18 } from "node:path";
|
|
24921
25321
|
function seatProfileName(spec, role) {
|
|
24922
25322
|
return `${spec.namePrefix}${role}`;
|
|
24923
25323
|
}
|
|
24924
25324
|
function packageRoleSoulPath(packageRoot, role) {
|
|
24925
|
-
return
|
|
25325
|
+
return join32(packageRoot, "souls", `${role}.md`);
|
|
24926
25326
|
}
|
|
24927
25327
|
async function pathExists2(path) {
|
|
24928
25328
|
try {
|
|
@@ -24939,21 +25339,21 @@ async function ensureSeatProfileSoul(options) {
|
|
|
24939
25339
|
if (!await pathExists2(soulTarget)) {
|
|
24940
25340
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
24941
25341
|
}
|
|
24942
|
-
const profilesRoot =
|
|
24943
|
-
const profileDir =
|
|
25342
|
+
const profilesRoot = join32(operatorHome, ...spec.profilesRootFromHome);
|
|
25343
|
+
const profileDir = join32(profilesRoot, profileName);
|
|
24944
25344
|
const hostRoot = dirname20(profilesRoot);
|
|
24945
|
-
const soulPath =
|
|
25345
|
+
const soulPath = join32(profileDir, spec.soulFileName);
|
|
24946
25346
|
if (!await pathExists2(profileDir)) {
|
|
24947
25347
|
await mkdir4(profileDir, { recursive: true });
|
|
24948
25348
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
24949
|
-
const source =
|
|
25349
|
+
const source = join32(hostRoot, name);
|
|
24950
25350
|
if (!await pathExists2(source)) continue;
|
|
24951
|
-
await copyFile(source,
|
|
25351
|
+
await copyFile(source, join32(profileDir, name));
|
|
24952
25352
|
}
|
|
24953
25353
|
} else {
|
|
24954
25354
|
await mkdir4(profileDir, { recursive: true });
|
|
24955
25355
|
}
|
|
24956
|
-
const desiredLink =
|
|
25356
|
+
const desiredLink = relative4(profileDir, soulTarget);
|
|
24957
25357
|
let current;
|
|
24958
25358
|
try {
|
|
24959
25359
|
const st = await lstat4(soulPath);
|