@akagilnc/pi-workflow-roles 0.1.6115 → 0.1.6126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/dist/acp-host/production-host.js +354 -250
- package/dist/engine-detour-usage.js +2 -1
- package/dist/gatekeeper-role.js +3 -15
- package/dist/headless-host/description.js +4 -1
- package/dist/headless-host/production-host.js +340 -236
- package/dist/migrate-book-topology.js +39 -22
- package/dist/notary-source-run.js +8 -8
- package/dist/public-cli/auto-resume.js +3 -3
- package/dist/public-cli/cli.js +38 -32
- package/dist/public-cli/instruction-seat-run.js +2 -5
- package/dist/public-cli/main.js +310 -208
- package/dist/public-cli/option-definitions.js +22 -21
- package/dist/public-cli/run-lifecycle.js +27 -26
- package/dist/public-cli/seat-ticket-binding.js +2 -1
- package/dist/public-cli/settlement.js +33 -8
- package/dist/public-cli/terminal.js +13 -3
- package/dist/public-role-summons.js +1 -7
- package/dist/role-run-placement.js +1 -1
- package/dist/run-dossier-files.js +4 -2
- package/dist/submission-gate.js +3 -3
- package/dist/submission-ledger.js +29 -3
- package/dist/ticket-address.js +77 -0
- package/dist/ticket-progress.js +31 -0
- package/package.json +1 -1
- package/src/engine-detour-usage.ts +2 -1
- package/src/gatekeeper-role.ts +5 -18
- package/src/headless-host/description.ts +4 -1
- package/src/notary-source-run.ts +8 -8
- package/src/public-cli/auto-resume.ts +4 -3
- package/src/public-cli/cli.ts +53 -32
- package/src/public-cli/instruction-seat-run.ts +2 -5
- package/src/public-cli/option-definitions.ts +22 -21
- package/src/public-cli/run-lifecycle.ts +31 -31
- package/src/public-cli/seat-ticket-binding.ts +2 -1
- package/src/public-cli/settlement.ts +43 -7
- package/src/public-cli/terminal.ts +33 -14
- package/src/public-role-summons.ts +3 -15
- package/src/role-run-placement.ts +1 -1
- package/src/run-dossier-files.ts +5 -2
- package/src/submission-gate.ts +3 -2
- package/src/submission-ledger.ts +32 -2
- package/src/ticket-address.ts +91 -0
- package/src/ticket-progress.ts +42 -0
|
@@ -554,7 +554,7 @@ var init_role_run_path_rewrite = __esm({
|
|
|
554
554
|
});
|
|
555
555
|
|
|
556
556
|
// src/run-dossier-files.ts
|
|
557
|
-
var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, OFFICER_POINTER_RECORD_KIND, RUN_STATE_KINDS;
|
|
557
|
+
var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, PROGRESS_RECORD_KIND, OFFICER_POINTER_RECORD_KIND, RUN_STATE_KINDS;
|
|
558
558
|
var init_run_dossier_files = __esm({
|
|
559
559
|
"src/run-dossier-files.ts"() {
|
|
560
560
|
"use strict";
|
|
@@ -570,8 +570,10 @@ var init_run_dossier_files = __esm({
|
|
|
570
570
|
"post-seal-anomaly",
|
|
571
571
|
"attempt-history",
|
|
572
572
|
"turn-delivery",
|
|
573
|
-
"officer-pointer"
|
|
573
|
+
"officer-pointer",
|
|
574
|
+
"progress"
|
|
574
575
|
]);
|
|
576
|
+
PROGRESS_RECORD_KIND = "progress";
|
|
575
577
|
OFFICER_POINTER_RECORD_KIND = "officer-pointer";
|
|
576
578
|
RUN_STATE_KINDS = /* @__PURE__ */ new Set([
|
|
577
579
|
"invocation",
|
|
@@ -1297,7 +1299,7 @@ async function findRoleRunDirectory(bookDirectories, runId, onlyRole) {
|
|
|
1297
1299
|
}
|
|
1298
1300
|
if (matches.length === 0) return void 0;
|
|
1299
1301
|
if (matches.length === 1) return matches[0];
|
|
1300
|
-
throw new Error(`ambiguous role run
|
|
1302
|
+
throw new Error(`ambiguous role run: ${matches.join(", ")}`);
|
|
1301
1303
|
}
|
|
1302
1304
|
function roleRunPlacement(ledgerHome, input) {
|
|
1303
1305
|
const subjectDirectory = "ticketNumber" in input.subject ? String(requireSafePositiveTicketNumber(
|
|
@@ -3569,6 +3571,13 @@ function currentReplyRows(terminal) {
|
|
|
3569
3571
|
function adviceNavigatorFact(input) {
|
|
3570
3572
|
return { disposition: "advice", prose: input.prose };
|
|
3571
3573
|
}
|
|
3574
|
+
function identityRows(leg) {
|
|
3575
|
+
const seat = leg.roleOutcome.role;
|
|
3576
|
+
return [
|
|
3577
|
+
...leg.ticket === void 0 ? [] : [`ticket ${leg.ticket}`],
|
|
3578
|
+
...[...leg.receipts ?? []].reverse().map((filed) => `receipt ${encodeTerminalField(filed.round === void 0 ? seat : `${seat}#${filed.round}`)} ${encodeTerminalField(filed.receipt)}`)
|
|
3579
|
+
];
|
|
3580
|
+
}
|
|
3572
3581
|
function formatTerminalResult(result) {
|
|
3573
3582
|
const lines = [];
|
|
3574
3583
|
lines.push("role outcome status");
|
|
@@ -3614,11 +3623,11 @@ function formatTerminalResult(result) {
|
|
|
3614
3623
|
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
3615
3624
|
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
3616
3625
|
}
|
|
3626
|
+
const lens = result.reviewerChildren?.[axis];
|
|
3627
|
+
if (lens !== void 0) lines.push(...identityRows(lens));
|
|
3617
3628
|
}
|
|
3618
3629
|
}
|
|
3619
|
-
|
|
3620
|
-
lines.push(`run ${encodeTerminalField(result.runId)}`);
|
|
3621
|
-
}
|
|
3630
|
+
lines.push(...identityRows(result));
|
|
3622
3631
|
if (result.autoResumeCount !== void 0) {
|
|
3623
3632
|
lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
3624
3633
|
}
|
|
@@ -3756,15 +3765,7 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
|
|
|
3756
3765
|
return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
|
|
3757
3766
|
}
|
|
3758
3767
|
function officerRunIdFromSummoned(summoned) {
|
|
3759
|
-
|
|
3760
|
-
const fromDir = runIdFromRunDirectory(summoned.runDirectory);
|
|
3761
|
-
if (fromDir !== void 0) return fromDir;
|
|
3762
|
-
}
|
|
3763
|
-
const terminal = summoned.terminal;
|
|
3764
|
-
if (terminal !== void 0 && typeof terminal.runId === "string" && terminal.runId.trim() !== "") {
|
|
3765
|
-
return terminal.runId;
|
|
3766
|
-
}
|
|
3767
|
-
return void 0;
|
|
3768
|
+
return summoned.runDirectory === void 0 ? void 0 : runIdFromRunDirectory(summoned.runDirectory);
|
|
3768
3769
|
}
|
|
3769
3770
|
function withOfficerRunId(result, summoned) {
|
|
3770
3771
|
if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask") {
|
|
@@ -4908,6 +4909,23 @@ function captureWorktreeHead(projectRoot) {
|
|
|
4908
4909
|
return { head: "", fault: `git rev-parse HEAD threw cwd=${projectRoot}: ${message}` };
|
|
4909
4910
|
}
|
|
4910
4911
|
}
|
|
4912
|
+
function carryProgressRow(runDirectory, line2, call) {
|
|
4913
|
+
const runId = runIdFromRunDirectory(runDirectory);
|
|
4914
|
+
if (runId === void 0) return;
|
|
4915
|
+
sitianReport({
|
|
4916
|
+
level: "event",
|
|
4917
|
+
kind: PROGRESS_RECORD_KIND,
|
|
4918
|
+
subject: { runId, ...call === void 0 ? {} : { attemptId: call.attemptId } },
|
|
4919
|
+
payload: {
|
|
4920
|
+
type: PROGRESS_RECORD_KIND,
|
|
4921
|
+
...call === void 0 ? {} : { toolCallId: call.toolCallId },
|
|
4922
|
+
receipt: line2.receipt,
|
|
4923
|
+
round: line2.round
|
|
4924
|
+
},
|
|
4925
|
+
source: "ticket-progress",
|
|
4926
|
+
sessionParent: sessionFileOf(runDirectory)
|
|
4927
|
+
});
|
|
4928
|
+
}
|
|
4911
4929
|
function progressSessionAbsolute(runDirectory, context) {
|
|
4912
4930
|
const host = typeof context.host === "string" ? context.host.trim() : "";
|
|
4913
4931
|
const sessionDirectory = sessionDirectoryOf(runDirectory);
|
|
@@ -4933,6 +4951,7 @@ function landTicketProgressForSealedSubmission(input) {
|
|
|
4933
4951
|
role: input.role,
|
|
4934
4952
|
accepted: input.accepted,
|
|
4935
4953
|
sealHead: input.sealHead,
|
|
4954
|
+
call: input.call,
|
|
4936
4955
|
...input.lens === void 0 ? {} : { lens: input.lens },
|
|
4937
4956
|
sessionFile: progressSessionAbsolute(runDirectory, input.context),
|
|
4938
4957
|
instruction: typeof input.context.summonsInstruction === "string" ? input.context.summonsInstruction : ""
|
|
@@ -4976,6 +4995,7 @@ function landTicketProgress(input) {
|
|
|
4976
4995
|
mkdirSync3(dirname7(progressPath), { recursive: true });
|
|
4977
4996
|
appendFileSync2(progressPath, `${JSON.stringify(line2)}
|
|
4978
4997
|
`, "utf8");
|
|
4998
|
+
carryProgressRow(runDirectory, line2, input.call);
|
|
4979
4999
|
if (input.sealHead.fault !== void 0) {
|
|
4980
5000
|
process.stderr.write(`${input.sealHead.fault}
|
|
4981
5001
|
`);
|
|
@@ -5023,6 +5043,7 @@ function relocateTicketProgressForLeg(input) {
|
|
|
5023
5043
|
"utf8"
|
|
5024
5044
|
);
|
|
5025
5045
|
rmSync3(stagedPath, { force: true });
|
|
5046
|
+
for (const moved of movedLines) carryProgressRow(input.runDirectory, moved);
|
|
5026
5047
|
}
|
|
5027
5048
|
var CURRENT_FILENAME, RECEIPTS_DIRNAME, LEG_PROGRESS_FILENAME;
|
|
5028
5049
|
var init_ticket_progress = __esm({
|
|
@@ -5033,6 +5054,9 @@ var init_ticket_progress = __esm({
|
|
|
5033
5054
|
init_packaged_role_registry();
|
|
5034
5055
|
init_role_run_placement();
|
|
5035
5056
|
init_run_dossier();
|
|
5057
|
+
init_run_dossier_files();
|
|
5058
|
+
init_run_terminal_artifacts();
|
|
5059
|
+
init_sitian_facade();
|
|
5036
5060
|
init_sitian_reader();
|
|
5037
5061
|
init_unknown_value();
|
|
5038
5062
|
CURRENT_FILENAME = "current.jsonl";
|
|
@@ -5772,8 +5796,66 @@ var init_uuidv7 = __esm({
|
|
|
5772
5796
|
}
|
|
5773
5797
|
});
|
|
5774
5798
|
|
|
5799
|
+
// src/ticket-address.ts
|
|
5800
|
+
import { existsSync as existsSync4, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
5801
|
+
import { join as join11 } from "node:path";
|
|
5802
|
+
function parseAddressTicket(token) {
|
|
5803
|
+
return parseTicketNumber(token.startsWith("#") ? token.slice(1) : token);
|
|
5804
|
+
}
|
|
5805
|
+
function parseSeatRound(token) {
|
|
5806
|
+
const hash = token.indexOf("#");
|
|
5807
|
+
return hash === -1 ? { seat: token } : { seat: token.slice(0, hash), round: token.slice(hash + 1) };
|
|
5808
|
+
}
|
|
5809
|
+
function parseTicketLegLocator(token) {
|
|
5810
|
+
const colon = token.indexOf(":");
|
|
5811
|
+
if (colon === -1) return void 0;
|
|
5812
|
+
const ticketNumber = parseAddressTicket(token.slice(0, colon));
|
|
5813
|
+
const { seat, round } = parseSeatRound(token.slice(colon + 1));
|
|
5814
|
+
if (ticketNumber === void 0 || seat === "" || round === void 0 || round === "") {
|
|
5815
|
+
return void 0;
|
|
5816
|
+
}
|
|
5817
|
+
return { ticketNumber, seat, round };
|
|
5818
|
+
}
|
|
5819
|
+
function locateTicketLeg(bookDirectory, input) {
|
|
5820
|
+
const ticketDirectory = join11(bookDirectory, String(input.ticketNumber));
|
|
5821
|
+
if (!existsSync4(ticketDirectory)) {
|
|
5822
|
+
throw new CliUsageError(`ticket ${input.ticketNumber} has no records in this project's book: ${ticketDirectory}`);
|
|
5823
|
+
}
|
|
5824
|
+
if (input.round !== void 0) {
|
|
5825
|
+
const row = readTicketProgressLines(ticketDirectory).find((line2) => line2.seat === input.seat && line2.round === input.round);
|
|
5826
|
+
if (row === void 0) {
|
|
5827
|
+
throw new CliUsageError(
|
|
5828
|
+
`ticket ${input.ticketNumber} has no progress row ${input.seat}#${input.round}`
|
|
5829
|
+
);
|
|
5830
|
+
}
|
|
5831
|
+
return join11(ticketDirectory, ...row.receipt.split("/").slice(0, 2));
|
|
5832
|
+
}
|
|
5833
|
+
const runsDirectory = join11(ticketDirectory, "runs");
|
|
5834
|
+
let latest;
|
|
5835
|
+
for (const entry of existsSync4(runsDirectory) ? readdirSync3(runsDirectory, { withFileTypes: true }) : []) {
|
|
5836
|
+
if (!entry.isDirectory() || parseRunLeaf(entry.name)?.role !== input.seat) continue;
|
|
5837
|
+
const { mtimeMs } = statSync4(join11(runsDirectory, entry.name));
|
|
5838
|
+
if (latest === void 0 || mtimeMs > latest.mtimeMs || mtimeMs === latest.mtimeMs && entry.name > latest.leaf) {
|
|
5839
|
+
latest = { leaf: entry.name, mtimeMs };
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
if (latest === void 0) {
|
|
5843
|
+
throw new CliUsageError(`ticket ${input.ticketNumber} has no ${input.seat} leg`);
|
|
5844
|
+
}
|
|
5845
|
+
return join11(runsDirectory, latest.leaf);
|
|
5846
|
+
}
|
|
5847
|
+
var init_ticket_address = __esm({
|
|
5848
|
+
"src/ticket-address.ts"() {
|
|
5849
|
+
"use strict";
|
|
5850
|
+
init_cli_errors();
|
|
5851
|
+
init_role_run_placement();
|
|
5852
|
+
init_run_ticket_number();
|
|
5853
|
+
init_ticket_progress();
|
|
5854
|
+
}
|
|
5855
|
+
});
|
|
5856
|
+
|
|
5775
5857
|
// src/notary-source-run.ts
|
|
5776
|
-
import { dirname as dirname9, isAbsolute as isAbsolute4, join as
|
|
5858
|
+
import { dirname as dirname9, isAbsolute as isAbsolute4, join as join12, resolve as resolve7, basename as basename8 } from "node:path";
|
|
5777
5859
|
import { lstat, realpath as realpath2 } from "node:fs/promises";
|
|
5778
5860
|
async function readRetainedIdentity(runDirectory) {
|
|
5779
5861
|
try {
|
|
@@ -5825,11 +5907,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5825
5907
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
5826
5908
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
5827
5909
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
5828
|
-
const bookRunsRoot =
|
|
5910
|
+
const bookRunsRoot = join12(bookDirectory, "runs");
|
|
5829
5911
|
let candidate;
|
|
5830
|
-
const
|
|
5831
|
-
if (
|
|
5832
|
-
candidate =
|
|
5912
|
+
const address = parseTicketLegLocator(raw);
|
|
5913
|
+
if (address !== void 0) {
|
|
5914
|
+
candidate = locateTicketLeg(bookDirectory, address);
|
|
5833
5915
|
} else {
|
|
5834
5916
|
candidate = isAbsolute4(raw) ? raw : resolve7(options.projectRoot, raw);
|
|
5835
5917
|
const identity2 = parseRunLeaf(basename8(candidate));
|
|
@@ -5909,6 +5991,7 @@ var init_notary_source_run = __esm({
|
|
|
5909
5991
|
init_activation_ledger_topology();
|
|
5910
5992
|
init_run_lifecycle();
|
|
5911
5993
|
init_role_run_placement();
|
|
5994
|
+
init_ticket_address();
|
|
5912
5995
|
NotarySourceRunError = class extends Error {
|
|
5913
5996
|
constructor(message, options) {
|
|
5914
5997
|
super(message, options);
|
|
@@ -6440,7 +6523,7 @@ var init_option_definitions = __esm({
|
|
|
6440
6523
|
owner: "auditor",
|
|
6441
6524
|
canonical: "--source-run",
|
|
6442
6525
|
aliases: [],
|
|
6443
|
-
valueMetavar: "
|
|
6526
|
+
valueMetavar: "ticket:seat#round|path",
|
|
6444
6527
|
required: true,
|
|
6445
6528
|
repeatable: false,
|
|
6446
6529
|
form: "option",
|
|
@@ -6618,13 +6701,13 @@ var init_option_definitions = __esm({
|
|
|
6618
6701
|
owner: "notary",
|
|
6619
6702
|
canonical: "--source-run",
|
|
6620
6703
|
aliases: [],
|
|
6621
|
-
valueMetavar: "
|
|
6704
|
+
valueMetavar: "ticket:seat#round|path",
|
|
6622
6705
|
required: true,
|
|
6623
6706
|
repeatable: false,
|
|
6624
6707
|
form: "option",
|
|
6625
6708
|
description: {
|
|
6626
|
-
en: "Required source run locator (
|
|
6627
|
-
zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\
|
|
6709
|
+
en: "Required source run locator (<ticket>:<seat>#<round> as written on the ticket's progress row, 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.",
|
|
6710
|
+
zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08<\u7968\u53F7>:<\u5E2D>#<\u8F6E>\uFF0C\u8F6E\u7167\u8FDB\u5EA6\u884C\u4E0A\u7684\u5199\u6CD5\uFF1B\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"
|
|
6628
6711
|
}
|
|
6629
6712
|
}
|
|
6630
6713
|
];
|
|
@@ -6635,13 +6718,13 @@ var init_option_definitions = __esm({
|
|
|
6635
6718
|
owner: "inspector",
|
|
6636
6719
|
canonical: "--source-run",
|
|
6637
6720
|
aliases: [],
|
|
6638
|
-
valueMetavar: "
|
|
6721
|
+
valueMetavar: "ticket:seat#round|path",
|
|
6639
6722
|
required: false,
|
|
6640
6723
|
repeatable: false,
|
|
6641
6724
|
form: "option",
|
|
6642
6725
|
description: {
|
|
6643
|
-
en: "Optional audited source-run locator (
|
|
6644
|
-
zh: "\u53EF\u9009\u88AB\u5BA1\u817F\u5B9A\u4F4D\u7B26\
|
|
6726
|
+
en: "Optional audited source-run locator (<ticket>:<seat>#<round> or path). Gate summons always supply it; identity rides startup materials.",
|
|
6727
|
+
zh: "\u53EF\u9009\u88AB\u5BA1\u817F\u5B9A\u4F4D\u7B26\uFF08<\u7968\u53F7>:<\u5E2D>#<\u8F6E> \u6216\u8DEF\u5F84\uFF09\u3002\u95F8\u4F20\u53EC\u5FC5\u5E26\uFF1B\u8EAB\u4EFD\u5728\u542F\u52A8\u6750\u6599\u91CC\u3002"
|
|
6645
6728
|
}
|
|
6646
6729
|
}
|
|
6647
6730
|
];
|
|
@@ -6936,10 +7019,10 @@ var init_option_definitions = __esm({
|
|
|
6936
7019
|
auditor: {
|
|
6937
7020
|
command: "auditor",
|
|
6938
7021
|
summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: converged, continue, or escalate.",
|
|
6939
|
-
usage: ["ak-role auditor --subject <judge|doctor> --source-run <
|
|
7022
|
+
usage: ["ak-role auditor --subject <judge|doctor> --source-run <ticket:seat#round|path> [options] [instruction]"],
|
|
6940
7023
|
examples: [
|
|
6941
|
-
'ak-role auditor --subject judge --source-run
|
|
6942
|
-
'ak-role auditor --subject doctor --source-run
|
|
7024
|
+
'ak-role auditor --subject judge --source-run 1201:judge#2 --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
|
|
7025
|
+
'ak-role auditor --subject doctor --source-run 1201:doctor#1 "\u5BA1\uFF1A\u592A\u533B\u5019\u9009\u662F\u5426\u5408\u89C4\u3002"'
|
|
6943
7026
|
]
|
|
6944
7027
|
},
|
|
6945
7028
|
diarist: {
|
|
@@ -6962,10 +7045,10 @@ var init_option_definitions = __esm({
|
|
|
6962
7045
|
notary: {
|
|
6963
7046
|
command: "notary",
|
|
6964
7047
|
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.",
|
|
6965
|
-
usage: ["ak-role notary --source-run <
|
|
7048
|
+
usage: ["ak-role notary --source-run <ticket:seat#round|path> [options]"],
|
|
6966
7049
|
examples: [
|
|
6967
|
-
"ak-role notary --source-run
|
|
6968
|
-
"ak-role notary --source-run
|
|
7050
|
+
"ak-role notary --source-run 1201:judge#2",
|
|
7051
|
+
"ak-role notary --source-run 1201:countersign#1"
|
|
6969
7052
|
]
|
|
6970
7053
|
},
|
|
6971
7054
|
analyst: {
|
|
@@ -7022,14 +7105,15 @@ var init_option_definitions = __esm({
|
|
|
7022
7105
|
},
|
|
7023
7106
|
resume: {
|
|
7024
7107
|
command: "resume",
|
|
7025
|
-
summary: "Resume a
|
|
7026
|
-
usage: ["ak-role resume <
|
|
7108
|
+
summary: "Resume one leg of a ticket under the live seat table (model/host/engine); session principal must still exist. The address is the ticket number and the seat: by default the seat's most recently active leg under that ticket; <seat>#<round> (round as written on the ticket's progress row, reviewer rounds carry the lens suffix) names the leg that filed that round. A leg that has reported no ticket is not in this address. 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 <ticket> (either before `resume` or between `resume` and <ticket>); the one argv after <seat> is the opaque message, not a flag position (#471).",
|
|
7109
|
+
usage: ["ak-role resume <ticket> <seat>[#<round>] [message]"],
|
|
7027
7110
|
examples: [
|
|
7028
|
-
"ak-role resume
|
|
7029
|
-
'ak-role resume
|
|
7030
|
-
"ak-role
|
|
7031
|
-
"ak-role --
|
|
7032
|
-
|
|
7111
|
+
"ak-role resume 1201 judge",
|
|
7112
|
+
'ak-role resume 1201 judge "owner ruling"',
|
|
7113
|
+
"ak-role resume 1201 'reviewer#2.correctness'",
|
|
7114
|
+
"ak-role --host grok-build resume 1201 fixer",
|
|
7115
|
+
"ak-role --engine agy resume 1201 fixer",
|
|
7116
|
+
'ak-role resume --model xai/grok-4.5 1201 notary "owner ruling"'
|
|
7033
7117
|
]
|
|
7034
7118
|
},
|
|
7035
7119
|
new: {
|
|
@@ -7038,7 +7122,7 @@ var init_option_definitions = __esm({
|
|
|
7038
7122
|
usage: ["ak-role new <role> [options] \u2026"],
|
|
7039
7123
|
examples: [
|
|
7040
7124
|
'ak-role new countersign --attach ./ticket.md "\u88C1\uFF1A\u672C\u7968 #708 \u662F\u5426\u8DB3\u4EE5\u5F00\u5DE5\u3002"',
|
|
7041
|
-
"ak-role new notary --source-run
|
|
7125
|
+
"ak-role new notary --source-run 1201:countersign#1",
|
|
7042
7126
|
"ak-role --host grok-build new inspector --attach ./change.patch"
|
|
7043
7127
|
]
|
|
7044
7128
|
},
|
|
@@ -7061,14 +7145,14 @@ var init_option_definitions = __esm({
|
|
|
7061
7145
|
|
|
7062
7146
|
// src/public-cli/invocation.ts
|
|
7063
7147
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
7064
|
-
import { existsSync as
|
|
7148
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
7065
7149
|
import {
|
|
7066
7150
|
readFile as readFile8,
|
|
7067
7151
|
realpath as realpath3,
|
|
7068
7152
|
rename,
|
|
7069
7153
|
writeFile
|
|
7070
7154
|
} from "node:fs/promises";
|
|
7071
|
-
import { dirname as dirname10, isAbsolute as isAbsolute5, join as
|
|
7155
|
+
import { dirname as dirname10, isAbsolute as isAbsolute5, join as join13, resolve as resolve8 } from "node:path";
|
|
7072
7156
|
function admittedSourceRunPath(admitted) {
|
|
7073
7157
|
if (!isRecord(admitted)) return void 0;
|
|
7074
7158
|
const path = admitted.sourceRunPath;
|
|
@@ -7246,7 +7330,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
7246
7330
|
runId: childRunId,
|
|
7247
7331
|
role: "diarist"
|
|
7248
7332
|
}).runDirectory;
|
|
7249
|
-
if (
|
|
7333
|
+
if (existsSync5(unboundChildDirectory)) {
|
|
7250
7334
|
input.authority.seal(childTarget);
|
|
7251
7335
|
await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
|
|
7252
7336
|
await rehomeUnboundTicketProvenance(
|
|
@@ -7270,7 +7354,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
7270
7354
|
}
|
|
7271
7355
|
continue;
|
|
7272
7356
|
}
|
|
7273
|
-
if (
|
|
7357
|
+
if (existsSync5(childTarget.runDirectory)) {
|
|
7274
7358
|
relocateTicketProgressForLeg({
|
|
7275
7359
|
runDirectory: childTarget.runDirectory
|
|
7276
7360
|
});
|
|
@@ -7368,7 +7452,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
7368
7452
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
7369
7453
|
const rolePackageRoot = packageRoot;
|
|
7370
7454
|
const raw = JSON.parse(
|
|
7371
|
-
await readFile8(
|
|
7455
|
+
await readFile8(join13(rolePackageRoot, "package.json"), "utf8")
|
|
7372
7456
|
);
|
|
7373
7457
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
7374
7458
|
throw new Error(
|
|
@@ -7939,7 +8023,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7939
8023
|
resolutionScope: [...derived.resolutionScope],
|
|
7940
8024
|
authorizedChecks: []
|
|
7941
8025
|
});
|
|
7942
|
-
const mergerInputPath =
|
|
8026
|
+
const mergerInputPath = join13(placed.runDirectory, "merger-input.json");
|
|
7943
8027
|
await writeFile(
|
|
7944
8028
|
mergerInputPath,
|
|
7945
8029
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -8207,7 +8291,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
8207
8291
|
}
|
|
8208
8292
|
async function resolveDoctorCaseRunsPath(options) {
|
|
8209
8293
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
8210
|
-
const defaultRuns =
|
|
8294
|
+
const defaultRuns = join13(
|
|
8211
8295
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
8212
8296
|
String(options.issueNumber),
|
|
8213
8297
|
"runs"
|
|
@@ -8505,7 +8589,7 @@ var init_invocation = __esm({
|
|
|
8505
8589
|
|
|
8506
8590
|
// src/report-ticket-tool.ts
|
|
8507
8591
|
import { Type as Type16 } from "typebox";
|
|
8508
|
-
import { existsSync as
|
|
8592
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
8509
8593
|
function pageString(page, key) {
|
|
8510
8594
|
const value = page?.[key];
|
|
8511
8595
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
@@ -8543,7 +8627,7 @@ async function reportTicketFromHostContext(context, ticketNumber, authority = pi
|
|
|
8543
8627
|
if (runDirectory === void 0) {
|
|
8544
8628
|
throw new Error("ak_report_ticket requires a per-turn run directory");
|
|
8545
8629
|
}
|
|
8546
|
-
if (!
|
|
8630
|
+
if (!existsSync6(runDirectory)) {
|
|
8547
8631
|
throw new Error(`ak_report_ticket run directory missing: ${runDirectory}`);
|
|
8548
8632
|
}
|
|
8549
8633
|
const admitted = admittedForLiveTicketReport(runDirectory, authority);
|
|
@@ -8721,8 +8805,21 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
|
8721
8805
|
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
8722
8806
|
};
|
|
8723
8807
|
}
|
|
8724
|
-
function mapOwnedToSubmissionRows(owned) {
|
|
8808
|
+
function mapOwnedToSubmissionRows(owned, leg = owned) {
|
|
8725
8809
|
const scoped = owned;
|
|
8810
|
+
const receiptByCall = /* @__PURE__ */ new Map();
|
|
8811
|
+
const roundByReceipt = /* @__PURE__ */ new Map();
|
|
8812
|
+
for (const record of leg) {
|
|
8813
|
+
if (record.kind !== PROGRESS_RECORD_KIND) continue;
|
|
8814
|
+
const payload = record.payload;
|
|
8815
|
+
if (typeof payload?.receipt !== "string") continue;
|
|
8816
|
+
if (typeof payload.toolCallId === "string") {
|
|
8817
|
+
receiptByCall.set(submissionCallKey(recordAttemptId(record), payload.toolCallId), payload.receipt);
|
|
8818
|
+
}
|
|
8819
|
+
if (typeof payload.round === "string" && payload.round !== "") {
|
|
8820
|
+
roundByReceipt.set(payload.receipt, payload.round);
|
|
8821
|
+
}
|
|
8822
|
+
}
|
|
8726
8823
|
const out = [];
|
|
8727
8824
|
const indexByCall = /* @__PURE__ */ new Map();
|
|
8728
8825
|
const roleByCall = /* @__PURE__ */ new Map();
|
|
@@ -8773,7 +8870,13 @@ function mapOwnedToSubmissionRows(owned) {
|
|
|
8773
8870
|
if (kind === void 0 || original === void 0 || payload === void 0) continue;
|
|
8774
8871
|
const callKey = typeof payload.toolCallId === "string" ? submissionCallKey(recordAttemptId(record), payload.toolCallId) : void 0;
|
|
8775
8872
|
const fallback = callKey === void 0 ? void 0 : roleByCall.get(callKey);
|
|
8776
|
-
|
|
8873
|
+
const receipt = kind === "accepted" && callKey !== void 0 ? receiptByCall.get(callKey) : void 0;
|
|
8874
|
+
const round = receipt === void 0 ? void 0 : roundByReceipt.get(receipt);
|
|
8875
|
+
take({
|
|
8876
|
+
...rowFromPayload(kind, payload, original, fallback),
|
|
8877
|
+
...receipt === void 0 ? {} : { receipt },
|
|
8878
|
+
...round === void 0 ? {} : { round }
|
|
8879
|
+
}, callKey);
|
|
8777
8880
|
}
|
|
8778
8881
|
return out;
|
|
8779
8882
|
}
|
|
@@ -8786,7 +8889,7 @@ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScop
|
|
|
8786
8889
|
if (attemptId.length === 0) return [];
|
|
8787
8890
|
const scope = resolveReadScope(homeOrScope);
|
|
8788
8891
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
8789
|
-
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
8892
|
+
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId), owned);
|
|
8790
8893
|
}
|
|
8791
8894
|
async function readSubmissionAttemptId(cwd, runId, toolCallId, homeOrScope) {
|
|
8792
8895
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
|
|
@@ -8862,7 +8965,8 @@ function sealAcceptedSubmission(options) {
|
|
|
8862
8965
|
accepted: options.accepted,
|
|
8863
8966
|
sealHead,
|
|
8864
8967
|
sessionFile: void 0,
|
|
8865
|
-
instruction: options.instruction ?? ""
|
|
8968
|
+
instruction: options.instruction ?? "",
|
|
8969
|
+
call: { attemptId, toolCallId: options.toolCallId }
|
|
8866
8970
|
});
|
|
8867
8971
|
}
|
|
8868
8972
|
function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (error) => {
|
|
@@ -8984,7 +9088,8 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
8984
9088
|
role,
|
|
8985
9089
|
accepted: params,
|
|
8986
9090
|
sealHead,
|
|
8987
|
-
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
|
|
9091
|
+
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {},
|
|
9092
|
+
call: { attemptId, toolCallId }
|
|
8988
9093
|
});
|
|
8989
9094
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
8990
9095
|
if (context.host !== "claude" && context.host !== "codex" && runDirectory !== void 0 && isUnboundRunDirectory(runDirectory)) {
|
|
@@ -9017,6 +9122,7 @@ var init_submission_ledger = __esm({
|
|
|
9017
9122
|
init_host_contracts();
|
|
9018
9123
|
init_run_terminal_artifacts();
|
|
9019
9124
|
init_sitian_facade();
|
|
9125
|
+
init_run_dossier_files();
|
|
9020
9126
|
init_run_lifecycle();
|
|
9021
9127
|
init_submission_correctable_error();
|
|
9022
9128
|
init_report_ticket_tool();
|
|
@@ -9208,7 +9314,7 @@ var init_engine_detour_usage = __esm({
|
|
|
9208
9314
|
});
|
|
9209
9315
|
|
|
9210
9316
|
// src/dossier-resolution.ts
|
|
9211
|
-
import { existsSync as
|
|
9317
|
+
import { existsSync as existsSync7, statSync as statSync5 } from "node:fs";
|
|
9212
9318
|
import { resolve as resolve9 } from "node:path";
|
|
9213
9319
|
function isHostContext(value) {
|
|
9214
9320
|
return "sessionManager" in value;
|
|
@@ -9228,7 +9334,7 @@ function resolveAuditDossier(source) {
|
|
|
9228
9334
|
}
|
|
9229
9335
|
const runDirectory = resolve9(raw);
|
|
9230
9336
|
try {
|
|
9231
|
-
if (!
|
|
9337
|
+
if (!existsSync7(runDirectory) || !statSync5(runDirectory).isDirectory()) {
|
|
9232
9338
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
9233
9339
|
}
|
|
9234
9340
|
} catch {
|
|
@@ -9511,6 +9617,7 @@ __export(settlement_exports, {
|
|
|
9511
9617
|
exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
|
|
9512
9618
|
explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
|
|
9513
9619
|
extractNavigatorFact: () => extractNavigatorFact,
|
|
9620
|
+
filedIdentity: () => filedIdentity,
|
|
9514
9621
|
formatCliDiagnostic: () => formatCliDiagnostic,
|
|
9515
9622
|
formatErrorCauseDetail: () => formatErrorCauseDetail,
|
|
9516
9623
|
formatFailureStderrDiagnostic: () => formatFailureStderrDiagnostic,
|
|
@@ -9532,6 +9639,7 @@ __export(settlement_exports, {
|
|
|
9532
9639
|
trySettlePublicSeat: () => trySettlePublicSeat,
|
|
9533
9640
|
withSubmissions: () => withSubmissions
|
|
9534
9641
|
});
|
|
9642
|
+
import { basename as basename9, join as join14 } from "node:path";
|
|
9535
9643
|
function sealedLedgerHome(admitted) {
|
|
9536
9644
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
9537
9645
|
}
|
|
@@ -9590,6 +9698,17 @@ function ledgerReadScope(admitted, scope) {
|
|
|
9590
9698
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
9591
9699
|
};
|
|
9592
9700
|
}
|
|
9701
|
+
function filedIdentity(runDirectory, filed = []) {
|
|
9702
|
+
const subjectDirectory = subjectDirectoryOfRun(runDirectory);
|
|
9703
|
+
if (subjectDirectory === void 0) return {};
|
|
9704
|
+
const ticket = parseTicketNumber(basename9(subjectDirectory));
|
|
9705
|
+
return {
|
|
9706
|
+
...ticket === void 0 ? {} : { ticket },
|
|
9707
|
+
...filed.length === 0 ? {} : {
|
|
9708
|
+
receipts: filed.map((row) => ({ ...row, receipt: join14(subjectDirectory, row.receipt) }))
|
|
9709
|
+
}
|
|
9710
|
+
};
|
|
9711
|
+
}
|
|
9593
9712
|
function roleOutcomeFromRows(role, rows) {
|
|
9594
9713
|
const mine = rows.filter((row) => row.role === role);
|
|
9595
9714
|
const terminal = mine.filter(
|
|
@@ -9599,7 +9718,11 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
9599
9718
|
const payloads = mine.map((row) => row.accepted);
|
|
9600
9719
|
const latest = terminal[terminal.length - 1];
|
|
9601
9720
|
const submissionToolCallId = typeof latest.toolCallId === "string" && latest.toolCallId.length > 0 ? latest.toolCallId : void 0;
|
|
9602
|
-
const
|
|
9721
|
+
const filed = mine.flatMap((row) => row.receipt === void 0 ? [] : [{ receipt: row.receipt, ...row.round === void 0 ? {} : { round: row.round } }]);
|
|
9722
|
+
const belonging = {
|
|
9723
|
+
...submissionToolCallId === void 0 ? {} : { submissionToolCallId },
|
|
9724
|
+
filed
|
|
9725
|
+
};
|
|
9603
9726
|
if (latest.kind === "audit-escalation") {
|
|
9604
9727
|
return {
|
|
9605
9728
|
outcome: {
|
|
@@ -9766,7 +9889,7 @@ async function settleNoReceiptTerminal(admitted, authority, scope, facts) {
|
|
|
9766
9889
|
scope
|
|
9767
9890
|
),
|
|
9768
9891
|
artifacts: [],
|
|
9769
|
-
|
|
9892
|
+
...filedIdentity(admitted.runDirectory)
|
|
9770
9893
|
}, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
|
|
9771
9894
|
}
|
|
9772
9895
|
function coordinatesFromAdmitted(authority, admitted) {
|
|
@@ -10240,16 +10363,17 @@ async function settleSealedSeat(admitted, authority, scope, options) {
|
|
|
10240
10363
|
entriesOf(read),
|
|
10241
10364
|
settled.outcome,
|
|
10242
10365
|
scope,
|
|
10243
|
-
settled.submissionToolCallId
|
|
10366
|
+
settled.submissionToolCallId,
|
|
10367
|
+
settled.filed
|
|
10244
10368
|
);
|
|
10245
10369
|
}
|
|
10246
|
-
async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId) {
|
|
10370
|
+
async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId, filed) {
|
|
10247
10371
|
const artifacts = scope?.previewOnly === true ? [] : await publishDeclaredSeatTerminal(admitted, roleOutcome, coordinates, entries, scope);
|
|
10248
10372
|
const terminal = await attachEngineDetourToolUsage({
|
|
10249
10373
|
roleOutcome,
|
|
10250
10374
|
navigator: isNavigatorSeat(admitted.role) ? NAVIGATOR_SEAT_OWN_FACT : extractNavigatorFact(entries),
|
|
10251
10375
|
artifacts,
|
|
10252
|
-
|
|
10376
|
+
...filedIdentity(admitted.runDirectory, filed),
|
|
10253
10377
|
...submissionToolCallId === void 0 || submissionToolCallId.length === 0 ? {} : { submissionToolCallId }
|
|
10254
10378
|
}, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
|
|
10255
10379
|
return attachRecordedSubmissions(admitted, terminal, scope);
|
|
@@ -10415,7 +10539,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
10415
10539
|
decisiveFacts
|
|
10416
10540
|
};
|
|
10417
10541
|
return attachEngineDetourToolUsage(
|
|
10418
|
-
{ roleOutcome, navigator, artifacts,
|
|
10542
|
+
{ roleOutcome, navigator, artifacts, ...filedIdentity(admitted.runDirectory) },
|
|
10419
10543
|
sessionDirectory,
|
|
10420
10544
|
detourUsageContext(admitted, options)
|
|
10421
10545
|
);
|
|
@@ -10482,6 +10606,7 @@ var init_settlement = __esm({
|
|
|
10482
10606
|
"src/public-cli/settlement.ts"() {
|
|
10483
10607
|
"use strict";
|
|
10484
10608
|
init_role_run_placement();
|
|
10609
|
+
init_run_ticket_number();
|
|
10485
10610
|
init_sitian_facade();
|
|
10486
10611
|
init_run_terminal_artifacts();
|
|
10487
10612
|
init_submission_ledger();
|
|
@@ -10517,12 +10642,12 @@ var init_settlement = __esm({
|
|
|
10517
10642
|
});
|
|
10518
10643
|
|
|
10519
10644
|
// src/external-host-turn-loop.ts
|
|
10520
|
-
import { existsSync as
|
|
10521
|
-
import { basename as
|
|
10645
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
10646
|
+
import { basename as basename10 } from "node:path";
|
|
10522
10647
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
10523
10648
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
10524
10649
|
if (live === void 0) {
|
|
10525
|
-
const parsed = parseRunLeaf(
|
|
10650
|
+
const parsed = parseRunLeaf(basename10(request.runDirectory));
|
|
10526
10651
|
throw new Error(
|
|
10527
10652
|
`admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
|
|
10528
10653
|
);
|
|
@@ -10541,7 +10666,7 @@ async function trySyncTurnRequestLivePlacement(request, authority) {
|
|
|
10541
10666
|
}
|
|
10542
10667
|
async function retainPackageFaultBesideLivePlacement(request, input) {
|
|
10543
10668
|
let runDirectory = request.runDirectory;
|
|
10544
|
-
if (!
|
|
10669
|
+
if (!existsSync8(runDirectory)) {
|
|
10545
10670
|
try {
|
|
10546
10671
|
const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
10547
10672
|
if (found === void 0) {
|
|
@@ -10755,7 +10880,7 @@ var init_external_host_turn_loop = __esm({
|
|
|
10755
10880
|
});
|
|
10756
10881
|
|
|
10757
10882
|
// src/session-identity.ts
|
|
10758
|
-
import { join as
|
|
10883
|
+
import { join as join15 } from "node:path";
|
|
10759
10884
|
function createSessionIdentityAuthority(authority, hostName) {
|
|
10760
10885
|
const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
|
|
10761
10886
|
return {
|
|
@@ -10765,7 +10890,7 @@ function createSessionIdentityAuthority(authority, hostName) {
|
|
|
10765
10890
|
},
|
|
10766
10891
|
async load(principal) {
|
|
10767
10892
|
const runDirectory = runDirectoryOf(principal);
|
|
10768
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
10893
|
+
const { records, diagnostics } = await readSitianRecords(join15(runDirectory, RUN_STATE_FILE));
|
|
10769
10894
|
if (diagnostics.length > 0) {
|
|
10770
10895
|
throw new Error(
|
|
10771
10896
|
`${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
|
|
@@ -10835,14 +10960,14 @@ __export(role_turn_host_exports, {
|
|
|
10835
10960
|
});
|
|
10836
10961
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
10837
10962
|
import { constants } from "node:fs";
|
|
10838
|
-
import { existsSync as
|
|
10963
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
10839
10964
|
import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
|
|
10840
|
-
import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as
|
|
10965
|
+
import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join16, resolve as resolve11 } from "node:path";
|
|
10841
10966
|
import { platform } from "node:process";
|
|
10842
10967
|
import { promisify as promisify2 } from "node:util";
|
|
10843
10968
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
10844
10969
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
10845
|
-
return
|
|
10970
|
+
return join16(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
10846
10971
|
}
|
|
10847
10972
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
10848
10973
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -11032,7 +11157,7 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
11032
11157
|
homeFromRunDirectory(spawnDir)
|
|
11033
11158
|
);
|
|
11034
11159
|
} catch (resolveError) {
|
|
11035
|
-
runDirectory =
|
|
11160
|
+
runDirectory = existsSync9(spawnDir) ? spawnDir : void 0;
|
|
11036
11161
|
const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
|
|
11037
11162
|
if (runDirectory !== void 0) {
|
|
11038
11163
|
await retainPackageFault({
|
|
@@ -11234,8 +11359,8 @@ var init_role_turn_host = __esm({
|
|
|
11234
11359
|
});
|
|
11235
11360
|
|
|
11236
11361
|
// src/package-resources/engine-material.ts
|
|
11237
|
-
import { existsSync as
|
|
11238
|
-
import { join as
|
|
11362
|
+
import { existsSync as existsSync10, readFileSync as readFileSync3 } from "node:fs";
|
|
11363
|
+
import { join as join17 } from "node:path";
|
|
11239
11364
|
function pickEngineAxis(source) {
|
|
11240
11365
|
return {
|
|
11241
11366
|
...source.engine === void 0 ? {} : { engine: source.engine },
|
|
@@ -11256,14 +11381,14 @@ function isEngineNameSyntax(name) {
|
|
|
11256
11381
|
return true;
|
|
11257
11382
|
}
|
|
11258
11383
|
function resolveEngineMaterialDirectory(packageRoot) {
|
|
11259
|
-
return
|
|
11384
|
+
return join17(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
11260
11385
|
}
|
|
11261
11386
|
function resolveEngineDispatchMaterialPath(packageRoot) {
|
|
11262
|
-
return
|
|
11387
|
+
return join17(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
|
|
11263
11388
|
}
|
|
11264
11389
|
function resolveEngineMaterialPath(packageRoot, name) {
|
|
11265
11390
|
const legal = assertLegalEngineName(name);
|
|
11266
|
-
return
|
|
11391
|
+
return join17(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
|
|
11267
11392
|
}
|
|
11268
11393
|
function assertLegalEngineName(name) {
|
|
11269
11394
|
if (!isEngineNameSyntax(name)) {
|
|
@@ -11280,12 +11405,12 @@ function engineSessionMaterialFromOptions(options) {
|
|
|
11280
11405
|
const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
|
|
11281
11406
|
const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
|
|
11282
11407
|
const modelField = model === void 0 ? {} : { model };
|
|
11283
|
-
if (!
|
|
11408
|
+
if (!existsSync10(materialPath)) {
|
|
11284
11409
|
return Object.freeze({ name, ...modelField });
|
|
11285
11410
|
}
|
|
11286
11411
|
const handbook = readFileSync3(materialPath, "utf8");
|
|
11287
11412
|
const dispatchPath = resolveEngineDispatchMaterialPath(options.packageRoot);
|
|
11288
|
-
const dispatchField =
|
|
11413
|
+
const dispatchField = existsSync10(dispatchPath) ? { dispatchHandbook: readFileSync3(dispatchPath, "utf8") } : {};
|
|
11289
11414
|
return Object.freeze({ name, handbook, ...dispatchField, ...modelField });
|
|
11290
11415
|
}
|
|
11291
11416
|
function engineSessionReadingMaterial(engineMaterial) {
|
|
@@ -11448,7 +11573,7 @@ __export(config_exports, {
|
|
|
11448
11573
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
11449
11574
|
});
|
|
11450
11575
|
import { mkdir, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
|
|
11451
|
-
import { dirname as dirname12, join as
|
|
11576
|
+
import { dirname as dirname12, join as join18 } from "node:path";
|
|
11452
11577
|
function isGateOfficerSeat(value) {
|
|
11453
11578
|
return packagedProvinceConfig(value);
|
|
11454
11579
|
}
|
|
@@ -11456,7 +11581,7 @@ function publicCliConfigPath(home) {
|
|
|
11456
11581
|
if (typeof home !== "string" || home.trim() === "") {
|
|
11457
11582
|
throw new Error("home must be explicitly provided");
|
|
11458
11583
|
}
|
|
11459
|
-
return
|
|
11584
|
+
return join18(home, ".ak-roles", "public-cli.json");
|
|
11460
11585
|
}
|
|
11461
11586
|
async function loadPublicCliConfig(home) {
|
|
11462
11587
|
const path = publicCliConfigPath(home);
|
|
@@ -11916,11 +12041,11 @@ function credentialProvidersFromAuthData(data) {
|
|
|
11916
12041
|
};
|
|
11917
12042
|
}
|
|
11918
12043
|
function resolvePublicAgentDir(explicit, home) {
|
|
11919
|
-
return explicit ?? process.env.PI_CODING_AGENT_DIR ??
|
|
12044
|
+
return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join18(home, ".pi", "agent");
|
|
11920
12045
|
}
|
|
11921
12046
|
async function loadCredentialProviders(agentDir) {
|
|
11922
12047
|
try {
|
|
11923
|
-
const raw = await readFile9(
|
|
12048
|
+
const raw = await readFile9(join18(agentDir, "auth.json"), "utf8");
|
|
11924
12049
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
11925
12050
|
} catch (error) {
|
|
11926
12051
|
if (isEnoent(error)) return { "openai-codex": false, xai: false };
|
|
@@ -11941,15 +12066,15 @@ var init_config = __esm({
|
|
|
11941
12066
|
|
|
11942
12067
|
// src/public-cli/host-providers.ts
|
|
11943
12068
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
11944
|
-
import { join as
|
|
12069
|
+
import { join as join19 } from "node:path";
|
|
11945
12070
|
function hostProvidersPath(home) {
|
|
11946
12071
|
if (typeof home !== "string" || home.trim() === "") {
|
|
11947
12072
|
throw new Error("home must be explicitly provided");
|
|
11948
12073
|
}
|
|
11949
|
-
return
|
|
12074
|
+
return join19(home, ".ak-roles", "host-providers.json");
|
|
11950
12075
|
}
|
|
11951
12076
|
function hermesProviderModelsCachePath(home) {
|
|
11952
|
-
return
|
|
12077
|
+
return join19(home, ".hermes", "provider_models_cache.json");
|
|
11953
12078
|
}
|
|
11954
12079
|
function parseHostProvidersTable(value) {
|
|
11955
12080
|
if (!isRecord(value)) {
|
|
@@ -12099,17 +12224,17 @@ var init_host_providers = __esm({
|
|
|
12099
12224
|
});
|
|
12100
12225
|
|
|
12101
12226
|
// src/public-cli/load-production-acp-host.ts
|
|
12102
|
-
import { existsSync as
|
|
12103
|
-
import { join as
|
|
12227
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
12228
|
+
import { join as join20 } from "node:path";
|
|
12104
12229
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
12105
12230
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
12106
12231
|
const description = lookupHostDescription(host);
|
|
12107
12232
|
if (description === void 0) {
|
|
12108
12233
|
throw new Error(`unregistered host: ${host}`);
|
|
12109
12234
|
}
|
|
12110
|
-
const built =
|
|
12111
|
-
const source =
|
|
12112
|
-
const target =
|
|
12235
|
+
const built = join20(packageRoot, "dist/acp-host/production-host.js");
|
|
12236
|
+
const source = join20(packageRoot, "src/acp-host/production-host.ts");
|
|
12237
|
+
const target = existsSync11(built) ? built : source;
|
|
12113
12238
|
const href = pathToFileURL2(target).href;
|
|
12114
12239
|
const mod = await import(href);
|
|
12115
12240
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -12123,17 +12248,17 @@ var init_load_production_acp_host = __esm({
|
|
|
12123
12248
|
});
|
|
12124
12249
|
|
|
12125
12250
|
// src/public-cli/load-production-headless-host.ts
|
|
12126
|
-
import { existsSync as
|
|
12127
|
-
import { join as
|
|
12251
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
12252
|
+
import { join as join21 } from "node:path";
|
|
12128
12253
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
12129
12254
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
12130
12255
|
const description = lookupHeadlessHostDescription(host);
|
|
12131
12256
|
if (description === void 0) {
|
|
12132
12257
|
throw new Error(`unregistered headless host: ${host}`);
|
|
12133
12258
|
}
|
|
12134
|
-
const built =
|
|
12135
|
-
const source =
|
|
12136
|
-
const target =
|
|
12259
|
+
const built = join21(packageRoot, "dist/headless-host/production-host.js");
|
|
12260
|
+
const source = join21(packageRoot, "src/headless-host/production-host.ts");
|
|
12261
|
+
const target = existsSync12(built) ? built : source;
|
|
12137
12262
|
const href = pathToFileURL3(target).href;
|
|
12138
12263
|
const mod = await import(href);
|
|
12139
12264
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -12592,7 +12717,7 @@ async function requireSubmissionGate(options) {
|
|
|
12592
12717
|
officer: projected.officer,
|
|
12593
12718
|
receipt: gatekeeper.submission ?? { reason: gatekeeper.reason },
|
|
12594
12719
|
reason: gatekeeper.reason,
|
|
12595
|
-
runId: projected.summoned
|
|
12720
|
+
runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
|
|
12596
12721
|
runDirectory: projected.summoned?.runDirectory,
|
|
12597
12722
|
terminal: projected.summoned?.terminal
|
|
12598
12723
|
});
|
|
@@ -12612,7 +12737,7 @@ async function requireSubmissionGate(options) {
|
|
|
12612
12737
|
officer: projected.officer,
|
|
12613
12738
|
receipt: gatekeeper.facts ?? { reason: gatekeeper.reason },
|
|
12614
12739
|
reason: gatekeeper.reason,
|
|
12615
|
-
runId: projected.summoned
|
|
12740
|
+
runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
|
|
12616
12741
|
runDirectory: projected.summoned?.runDirectory,
|
|
12617
12742
|
terminal: projected.summoned?.terminal
|
|
12618
12743
|
});
|
|
@@ -12644,7 +12769,7 @@ __export(auditor_soul_exports, {
|
|
|
12644
12769
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
12645
12770
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
12646
12771
|
});
|
|
12647
|
-
import { basename as
|
|
12772
|
+
import { basename as basename11 } from "node:path";
|
|
12648
12773
|
function auditorSoulRelativePath(role) {
|
|
12649
12774
|
return `souls/${role}-auditor.md`;
|
|
12650
12775
|
}
|
|
@@ -12680,7 +12805,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
12680
12805
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
12681
12806
|
}
|
|
12682
12807
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
12683
|
-
const role = parseRunLeaf(
|
|
12808
|
+
const role = parseRunLeaf(basename11(sourceRunDirectory))?.role;
|
|
12684
12809
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
12685
12810
|
}
|
|
12686
12811
|
async function readAuditorResumeBinding(admitted) {
|
|
@@ -12722,20 +12847,20 @@ var init_auditor_soul = __esm({
|
|
|
12722
12847
|
});
|
|
12723
12848
|
|
|
12724
12849
|
// src/public-cli/machine-method-skills.ts
|
|
12725
|
-
import { accessSync, constants as constants2, statSync as
|
|
12850
|
+
import { accessSync, constants as constants2, statSync as statSync6 } from "node:fs";
|
|
12726
12851
|
import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
12727
|
-
import { join as
|
|
12852
|
+
import { join as join23 } from "node:path";
|
|
12728
12853
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
12729
12854
|
function skillRoot(home) {
|
|
12730
|
-
return
|
|
12855
|
+
return join23(home, ".agents/skills");
|
|
12731
12856
|
}
|
|
12732
12857
|
function installedMethodSkillPath(home, name) {
|
|
12733
12858
|
return installedSkillPath(skillRoot(home), name);
|
|
12734
12859
|
}
|
|
12735
12860
|
function installedSkillPath(root, name) {
|
|
12736
|
-
const path =
|
|
12861
|
+
const path = join23(root, name, "SKILL.md");
|
|
12737
12862
|
try {
|
|
12738
|
-
if (!
|
|
12863
|
+
if (!statSync6(path).isFile()) return void 0;
|
|
12739
12864
|
accessSync(path, constants2.R_OK);
|
|
12740
12865
|
return path;
|
|
12741
12866
|
} catch (error) {
|
|
@@ -12746,9 +12871,9 @@ function installedSkillPath(root, name) {
|
|
|
12746
12871
|
}
|
|
12747
12872
|
function linkedSkillRoot(home, host) {
|
|
12748
12873
|
if (host === "claude" || host === "claude-code") {
|
|
12749
|
-
return
|
|
12874
|
+
return join23(process.env.CLAUDE_CONFIG_DIR?.trim() || join23(home, ".claude"), "skills");
|
|
12750
12875
|
}
|
|
12751
|
-
if (host === "hermes") return
|
|
12876
|
+
if (host === "hermes") return join23(home, ".hermes/skills");
|
|
12752
12877
|
return void 0;
|
|
12753
12878
|
}
|
|
12754
12879
|
async function occupied(path) {
|
|
@@ -12805,7 +12930,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12805
12930
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
12806
12931
|
let unsourced = false;
|
|
12807
12932
|
for (const name of packagedMethodSkillNames()) {
|
|
12808
|
-
const path =
|
|
12933
|
+
const path = join23(canonical, name);
|
|
12809
12934
|
if (await occupied(path)) {
|
|
12810
12935
|
warnOccupied(path, stdout);
|
|
12811
12936
|
continue;
|
|
@@ -12835,9 +12960,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12835
12960
|
throw error;
|
|
12836
12961
|
}
|
|
12837
12962
|
for (const name of packagedMethodSkillNames()) {
|
|
12838
|
-
const target =
|
|
12963
|
+
const target = join23(canonical, name);
|
|
12839
12964
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
12840
|
-
const link =
|
|
12965
|
+
const link = join23(root, name);
|
|
12841
12966
|
if (await occupied(link)) {
|
|
12842
12967
|
warnOccupied(link, stdout);
|
|
12843
12968
|
continue;
|
|
@@ -13096,7 +13221,7 @@ function dispatchExceptionFailureTerminal(input) {
|
|
|
13096
13221
|
},
|
|
13097
13222
|
navigator: { disposition: "no-advice" },
|
|
13098
13223
|
artifacts,
|
|
13099
|
-
|
|
13224
|
+
...filedIdentity(input.runDirectory),
|
|
13100
13225
|
autoResumeCount: input.autoResumeAttempts
|
|
13101
13226
|
};
|
|
13102
13227
|
}
|
|
@@ -13194,7 +13319,7 @@ async function runWithAutoResumeLoop(options) {
|
|
|
13194
13319
|
options.admitted,
|
|
13195
13320
|
dispatchExceptionFailureTerminal({
|
|
13196
13321
|
role: options.admitted.role,
|
|
13197
|
-
|
|
13322
|
+
runDirectory: options.admitted.runDirectory,
|
|
13198
13323
|
causeError: lastThrownError,
|
|
13199
13324
|
errorFiles: retainedErrorFiles,
|
|
13200
13325
|
autoResumeAttempts,
|
|
@@ -14508,12 +14633,12 @@ var init_post_admission = __esm({
|
|
|
14508
14633
|
});
|
|
14509
14634
|
|
|
14510
14635
|
// src/public-cli/seat-ticket-binding.ts
|
|
14511
|
-
import { join as
|
|
14636
|
+
import { join as join24 } from "node:path";
|
|
14512
14637
|
function resumedSessionIdMissing(result, runId) {
|
|
14513
14638
|
if (typeof result !== "object" || result === null) return false;
|
|
14514
14639
|
const terminal = result.terminal;
|
|
14515
14640
|
if (typeof terminal !== "object" || terminal === null) return false;
|
|
14516
|
-
if (
|
|
14641
|
+
if (result.admitted?.runId !== runId) return false;
|
|
14517
14642
|
const outcome = terminal.roleOutcome;
|
|
14518
14643
|
if (typeof outcome !== "object" || outcome === null) return false;
|
|
14519
14644
|
if (outcome.kind !== "failure") return false;
|
|
@@ -14522,7 +14647,7 @@ function resumedSessionIdMissing(result, runId) {
|
|
|
14522
14647
|
return facts.errorCode === SESSION_ID_MISSING;
|
|
14523
14648
|
}
|
|
14524
14649
|
async function writerLockBlocksFreshSummons(runDirectory) {
|
|
14525
|
-
const autopsy = await autopsyWriterLock(
|
|
14650
|
+
const autopsy = await autopsyWriterLock(join24(runDirectory, WRITER_LOCK_FILE));
|
|
14526
14651
|
return autopsy.verdict === "alive" || autopsy.verdict === "unknown";
|
|
14527
14652
|
}
|
|
14528
14653
|
async function tryResumeSameTicketSeatRun(input) {
|
|
@@ -15902,7 +16027,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15902
16027
|
const pass = chain.passes.at(-1);
|
|
15903
16028
|
const officerTerminal = pass?.terminal;
|
|
15904
16029
|
const officerRunDirectory = pass?.runDirectory;
|
|
15905
|
-
const officerRunId = pass?.runId
|
|
16030
|
+
const officerRunId = pass?.runId;
|
|
15906
16031
|
if (officerTerminal !== void 0 && officerRunId !== void 0) {
|
|
15907
16032
|
await presentAuditedOriginalVolume(turn, io);
|
|
15908
16033
|
const officer = await loadResumablePublicRole(
|
|
@@ -15941,7 +16066,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15941
16066
|
if (chain.status === "escalate") {
|
|
15942
16067
|
const escalation = chain.passes.at(-1);
|
|
15943
16068
|
const escalatedRunDirectory = escalation?.runDirectory;
|
|
15944
|
-
const escalatedRunId = escalation?.runId
|
|
16069
|
+
const escalatedRunId = escalation?.runId;
|
|
15945
16070
|
if (escalatedRunId === void 0) {
|
|
15946
16071
|
return incompleteAuditWithoutOfficerVolume(
|
|
15947
16072
|
turn,
|
|
@@ -16115,13 +16240,13 @@ var init_dialogue_command = __esm({
|
|
|
16115
16240
|
});
|
|
16116
16241
|
|
|
16117
16242
|
// src/analyst-book-key.ts
|
|
16118
|
-
import { statSync as
|
|
16243
|
+
import { statSync as statSync7 } from "node:fs";
|
|
16119
16244
|
import { isAbsolute as isAbsolute7 } from "node:path";
|
|
16120
16245
|
function resolveAnalystBookKey(projectRoot) {
|
|
16121
16246
|
const identity = physicalPathIdentity(projectRoot);
|
|
16122
16247
|
let stats;
|
|
16123
16248
|
try {
|
|
16124
|
-
stats =
|
|
16249
|
+
stats = statSync7(identity);
|
|
16125
16250
|
} catch (error) {
|
|
16126
16251
|
const code = errnoCode(error);
|
|
16127
16252
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -16151,10 +16276,10 @@ var init_analyst_book_key = __esm({
|
|
|
16151
16276
|
// src/atomic-write.ts
|
|
16152
16277
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
16153
16278
|
import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
|
|
16154
|
-
import { dirname as dirname14, join as
|
|
16279
|
+
import { dirname as dirname14, join as join25 } from "node:path";
|
|
16155
16280
|
async function writeFileAtomically(destination, contents, options) {
|
|
16156
16281
|
const parent = dirname14(destination);
|
|
16157
|
-
const temporary =
|
|
16282
|
+
const temporary = join25(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
16158
16283
|
try {
|
|
16159
16284
|
await writeFile3(temporary, contents, options);
|
|
16160
16285
|
await rename2(temporary, destination);
|
|
@@ -16171,12 +16296,12 @@ var init_atomic_write = __esm({
|
|
|
16171
16296
|
|
|
16172
16297
|
// src/analyst-index.ts
|
|
16173
16298
|
import { open, readFile as readFile10, unlink } from "node:fs/promises";
|
|
16174
|
-
import { dirname as dirname15, join as
|
|
16299
|
+
import { dirname as dirname15, join as join26 } from "node:path";
|
|
16175
16300
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
16176
16301
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
16177
16302
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
16178
16303
|
ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
|
|
16179
|
-
const lockPath =
|
|
16304
|
+
const lockPath = join26(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
16180
16305
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
16181
16306
|
const startedAt = Date.now();
|
|
16182
16307
|
while (true) {
|
|
@@ -16203,7 +16328,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
16203
16328
|
}
|
|
16204
16329
|
}
|
|
16205
16330
|
function analystLibraryIndexPath(ledgerHome) {
|
|
16206
|
-
return
|
|
16331
|
+
return join26(ledgerHome, "analyst", "library-index.json");
|
|
16207
16332
|
}
|
|
16208
16333
|
function rowFromIssueMetricsPage(page) {
|
|
16209
16334
|
return {
|
|
@@ -16497,7 +16622,7 @@ var init_analyst_cohort = __esm({
|
|
|
16497
16622
|
});
|
|
16498
16623
|
|
|
16499
16624
|
// src/archivist-record-pointer.ts
|
|
16500
|
-
import { basename as
|
|
16625
|
+
import { basename as basename12, join as join27 } from "node:path";
|
|
16501
16626
|
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
16502
16627
|
const where = `${parentRunDirectory} officers`;
|
|
16503
16628
|
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
@@ -16510,7 +16635,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
16510
16635
|
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
16511
16636
|
let sessionFile = raw.sessionFile;
|
|
16512
16637
|
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
16513
|
-
const leaf = parseRunLeaf(
|
|
16638
|
+
const leaf = parseRunLeaf(basename12(recordedRunDirectory));
|
|
16514
16639
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
16515
16640
|
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
16516
16641
|
const currentRunDirectory = await resolveLiveRunDirectoryPath(
|
|
@@ -16530,7 +16655,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
16530
16655
|
};
|
|
16531
16656
|
}
|
|
16532
16657
|
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
16533
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
16658
|
+
const { records, diagnostics } = await readSitianRecords(join27(parentRunDirectory, RUN_HISTORY_FILE));
|
|
16534
16659
|
if (diagnostics.length > 0) {
|
|
16535
16660
|
throw new Error(
|
|
16536
16661
|
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
@@ -16813,7 +16938,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
16813
16938
|
|
|
16814
16939
|
// src/analyst-ledger.ts
|
|
16815
16940
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
16816
|
-
import { basename as
|
|
16941
|
+
import { basename as basename13, join as join28 } from "node:path";
|
|
16817
16942
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
16818
16943
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
16819
16944
|
}
|
|
@@ -16833,7 +16958,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
16833
16958
|
}
|
|
16834
16959
|
}
|
|
16835
16960
|
async function classifyGhostCandidate(input) {
|
|
16836
|
-
const autopsy = await autopsyWriterLock(
|
|
16961
|
+
const autopsy = await autopsyWriterLock(join28(input.runDirectory, "writer.lock"));
|
|
16837
16962
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
16838
16963
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
16839
16964
|
return {
|
|
@@ -17123,7 +17248,7 @@ async function classifyScopedRun(input) {
|
|
|
17123
17248
|
async function scanAnalystIssueRuns(input) {
|
|
17124
17249
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
17125
17250
|
const scopeTicketNumber = input.ticketNumber;
|
|
17126
|
-
const booksRoot =
|
|
17251
|
+
const booksRoot = join28(ledgerHome, "books");
|
|
17127
17252
|
let wholeBook = false;
|
|
17128
17253
|
let scopeRootIdentity;
|
|
17129
17254
|
let bookNames;
|
|
@@ -17156,7 +17281,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
17156
17281
|
const ghostLegs = [];
|
|
17157
17282
|
const scopeConflicts = [];
|
|
17158
17283
|
for (const book of bookNames) {
|
|
17159
|
-
const bookDir =
|
|
17284
|
+
const bookDir = join28(booksRoot, book);
|
|
17160
17285
|
let runDirectories;
|
|
17161
17286
|
try {
|
|
17162
17287
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -17165,7 +17290,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
17165
17290
|
throw error;
|
|
17166
17291
|
}
|
|
17167
17292
|
for (const runDirectory of runDirectories) {
|
|
17168
|
-
const runName =
|
|
17293
|
+
const runName = basename13(runDirectory);
|
|
17169
17294
|
const parsed = parseRunLeaf(runName);
|
|
17170
17295
|
if (parsed === void 0) continue;
|
|
17171
17296
|
let scopeFields;
|
|
@@ -17902,7 +18027,7 @@ var init_analyst_metric_family = __esm({
|
|
|
17902
18027
|
});
|
|
17903
18028
|
|
|
17904
18029
|
// src/analyst-page.ts
|
|
17905
|
-
import { dirname as dirname16, join as
|
|
18030
|
+
import { dirname as dirname16, join as join29 } from "node:path";
|
|
17906
18031
|
function analystIssuePageKey(address) {
|
|
17907
18032
|
const parts = ["book", address.bookKey];
|
|
17908
18033
|
if (address.issueNumber !== void 0) {
|
|
@@ -17913,7 +18038,7 @@ function analystIssuePageKey(address) {
|
|
|
17913
18038
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
17914
18039
|
}
|
|
17915
18040
|
function analystIssuePagePath(ledgerHome, address) {
|
|
17916
|
-
return
|
|
18041
|
+
return join29(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
17917
18042
|
}
|
|
17918
18043
|
function analystIssuePageAddressFromPage(page) {
|
|
17919
18044
|
return {
|
|
@@ -18759,18 +18884,22 @@ function parseArgv(argv) {
|
|
|
18759
18884
|
help
|
|
18760
18885
|
};
|
|
18761
18886
|
}
|
|
18762
|
-
function
|
|
18763
|
-
const
|
|
18764
|
-
|
|
18887
|
+
function parseResumeAddress(args) {
|
|
18888
|
+
const [ticketToken, seatToken, ...rest] = args;
|
|
18889
|
+
const ticketNumber = ticketToken === void 0 ? void 0 : parseAddressTicket(ticketToken);
|
|
18890
|
+
if (ticketNumber === void 0 || seatToken === void 0 || rest.length > 1) {
|
|
18765
18891
|
throw new CliUsageError(RESUME_USAGE_ERROR);
|
|
18766
18892
|
}
|
|
18767
|
-
|
|
18768
|
-
|
|
18769
|
-
|
|
18770
|
-
if (args.length === 2) {
|
|
18771
|
-
return { runId, message: args[1] };
|
|
18893
|
+
const { seat, round } = parseSeatRound(seatToken);
|
|
18894
|
+
if (!isPublicCallableRole(seat) || round === "") {
|
|
18895
|
+
throw new CliUsageError(`${RESUME_USAGE_ERROR}; not a callable seat: ${seatToken}`);
|
|
18772
18896
|
}
|
|
18773
|
-
return {
|
|
18897
|
+
return {
|
|
18898
|
+
ticketNumber,
|
|
18899
|
+
seat,
|
|
18900
|
+
...round === void 0 ? {} : { round },
|
|
18901
|
+
...rest.length === 0 ? {} : { message: rest[0] }
|
|
18902
|
+
};
|
|
18774
18903
|
}
|
|
18775
18904
|
function invocationFromParsed(parsed) {
|
|
18776
18905
|
if (parsed.model === void 0 && parsed.thinking === void 0 && parsed.engine === void 0 && parsed.host === void 0) {
|
|
@@ -18879,7 +19008,7 @@ function renderHelp() {
|
|
|
18879
19008
|
"Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
|
|
18880
19009
|
"Model resolution: --model \u2192 persistent seat \u2192 officer inherit (#620); still none \u2192 error (#178)",
|
|
18881
19010
|
"Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
|
|
18882
|
-
"Resume
|
|
19011
|
+
"Resume address: ak-role resume <ticket> <seat>[#<round>] [message]; --model/--thinking/--host/--engine go before <ticket> (before `resume` or between `resume` and <ticket>); the one argv after <seat> is always the opaque message, never a flag (#471)",
|
|
18883
19012
|
"Effective seats: ak-role roles"
|
|
18884
19013
|
);
|
|
18885
19014
|
return `${lines.join("\n")}
|
|
@@ -19271,28 +19400,34 @@ async function runAkRole(argv, env) {
|
|
|
19271
19400
|
env = { ...env, freshSummons: true };
|
|
19272
19401
|
}
|
|
19273
19402
|
if (parsed.command === "resume") {
|
|
19274
|
-
|
|
19403
|
+
const address = parseResumeAddress(parsed.args);
|
|
19404
|
+
const runDirectory = locateTicketLeg(
|
|
19405
|
+
activationBookDirectory(
|
|
19406
|
+
resolveActivationLedgerHome(home),
|
|
19407
|
+
resolveBookKeyFromGit(env.cwd ?? process.cwd())
|
|
19408
|
+
),
|
|
19409
|
+
address
|
|
19410
|
+
);
|
|
19411
|
+
const resumeRequest = {
|
|
19412
|
+
runId: runIdFromRunDirectory(runDirectory),
|
|
19413
|
+
runDirectory,
|
|
19414
|
+
...address.message === void 0 ? {} : { message: address.message }
|
|
19415
|
+
};
|
|
19275
19416
|
resumeFailureContext = {
|
|
19276
19417
|
home,
|
|
19277
19418
|
runId: resumeRequest.runId,
|
|
19419
|
+
runDirectory,
|
|
19278
19420
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
19279
19421
|
};
|
|
19280
|
-
const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
|
|
19281
|
-
if (runDirectory !== void 0) {
|
|
19282
|
-
resumeRequest = { ...resumeRequest, runDirectory };
|
|
19283
|
-
resumeFailureContext = { ...resumeFailureContext, runDirectory };
|
|
19284
|
-
}
|
|
19285
19422
|
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
19286
|
-
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
|
|
19287
|
-
const seatRole = resumeRole ?? "judge";
|
|
19288
19423
|
const seat = resolveEffectiveSeat(
|
|
19289
19424
|
parts.config,
|
|
19290
|
-
|
|
19425
|
+
address.seat,
|
|
19291
19426
|
parts.credentials,
|
|
19292
19427
|
invocationFromParsed(parsed)
|
|
19293
19428
|
);
|
|
19294
19429
|
const resumeEnv = createRoleEnvironment(env, {
|
|
19295
|
-
role:
|
|
19430
|
+
role: address.seat,
|
|
19296
19431
|
home,
|
|
19297
19432
|
agentDir: parts.agentDir,
|
|
19298
19433
|
cwd: parts.cwd,
|
|
@@ -19426,6 +19561,10 @@ var init_cli = __esm({
|
|
|
19426
19561
|
init_instruction_seat_run();
|
|
19427
19562
|
init_countersign_run();
|
|
19428
19563
|
init_analyst_run();
|
|
19564
|
+
init_activation_ledger_git();
|
|
19565
|
+
init_activation_ledger_topology();
|
|
19566
|
+
init_run_terminal_artifacts();
|
|
19567
|
+
init_ticket_address();
|
|
19429
19568
|
init_run_lifecycle();
|
|
19430
19569
|
init_registry();
|
|
19431
19570
|
init_settlement();
|
|
@@ -19439,7 +19578,7 @@ var init_cli = __esm({
|
|
|
19439
19578
|
])
|
|
19440
19579
|
);
|
|
19441
19580
|
PUBLIC_GLOBAL_OPTIONS = optionsForOwner("global");
|
|
19442
|
-
RESUME_USAGE_ERROR = "usage: ak-role resume <
|
|
19581
|
+
RESUME_USAGE_ERROR = "usage: ak-role resume <ticket> <seat>[#<round>] [message] (ticket is the bare number; put --model/--thinking/--host/--engine before <ticket>; the one argv after <seat> is the opaque message)";
|
|
19443
19582
|
}
|
|
19444
19583
|
});
|
|
19445
19584
|
|
|
@@ -19453,9 +19592,9 @@ __export(public_role_summons_exports, {
|
|
|
19453
19592
|
summonPublicRole: () => summonPublicRole
|
|
19454
19593
|
});
|
|
19455
19594
|
import { execFile as execFile3 } from "node:child_process";
|
|
19456
|
-
import { existsSync as
|
|
19595
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
19457
19596
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
19458
|
-
import { join as
|
|
19597
|
+
import { join as join30 } from "node:path";
|
|
19459
19598
|
import { promisify as promisify3 } from "node:util";
|
|
19460
19599
|
function createCapturingIo() {
|
|
19461
19600
|
const chunks = [];
|
|
@@ -19479,7 +19618,7 @@ function parentDir(path) {
|
|
|
19479
19618
|
function walkPackageRoot(start) {
|
|
19480
19619
|
let dir = start;
|
|
19481
19620
|
for (let i = 0; i < 12; i += 1) {
|
|
19482
|
-
if (
|
|
19621
|
+
if (existsSync13(join30(dir, "package.json")) && existsSync13(join30(dir, "souls"))) {
|
|
19483
19622
|
return dir;
|
|
19484
19623
|
}
|
|
19485
19624
|
const parent = parentDir(dir);
|
|
@@ -19714,13 +19853,7 @@ async function summonPublicRole(options) {
|
|
|
19714
19853
|
result = stepped.ok;
|
|
19715
19854
|
}
|
|
19716
19855
|
const stderr = captured?.stderrText();
|
|
19717
|
-
|
|
19718
|
-
if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
|
|
19719
|
-
runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
19720
|
-
home,
|
|
19721
|
-
result.terminal.runId
|
|
19722
|
-
) ?? runDirectory;
|
|
19723
|
-
}
|
|
19856
|
+
const runDirectory = result.admitted?.runDirectory;
|
|
19724
19857
|
return {
|
|
19725
19858
|
exitCode: result.exitCode,
|
|
19726
19859
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -20028,7 +20161,7 @@ var init_compliance_transport = __esm({
|
|
|
20028
20161
|
});
|
|
20029
20162
|
|
|
20030
20163
|
// src/role-run-relocation.ts
|
|
20031
|
-
import { dirname as dirname17, join as
|
|
20164
|
+
import { dirname as dirname17, join as join31 } from "node:path";
|
|
20032
20165
|
async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirectory) {
|
|
20033
20166
|
if (recordedPath === currentPath) return true;
|
|
20034
20167
|
if (typeof recordedPath !== "string") return false;
|
|
@@ -20070,34 +20203,9 @@ var init_role_run_relocation = __esm({
|
|
|
20070
20203
|
});
|
|
20071
20204
|
|
|
20072
20205
|
// src/public-cli/run-lifecycle.ts
|
|
20073
|
-
|
|
20074
|
-
__export(run_lifecycle_exports, {
|
|
20075
|
-
AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
|
|
20076
|
-
RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
|
|
20077
|
-
WRITER_LOCK_FILE: () => WRITER_LOCK_FILE,
|
|
20078
|
-
acquireRunWriterLease: () => acquireRunWriterLease,
|
|
20079
|
-
autopsyWriterLock: () => autopsyWriterLock,
|
|
20080
|
-
clearCurrentCourt: () => clearCurrentCourt,
|
|
20081
|
-
describeErrorIdentity: () => describeErrorIdentity,
|
|
20082
|
-
findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
|
|
20083
|
-
findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
|
|
20084
|
-
findRunDirectoryById: () => findRunDirectoryById,
|
|
20085
|
-
loadResumablePublicRole: () => loadResumablePublicRole,
|
|
20086
|
-
markRunAdmitted: () => markRunAdmitted,
|
|
20087
|
-
markRunRunning: () => markRunRunning,
|
|
20088
|
-
markRunTerminal: () => markRunTerminal,
|
|
20089
|
-
peekRoleRunRole: () => peekRoleRunRole,
|
|
20090
|
-
readCurrentCourt: () => readCurrentCourt,
|
|
20091
|
-
readRoleRunIdentity: () => readRoleRunIdentity,
|
|
20092
|
-
readRoleRunState: () => readRoleRunState,
|
|
20093
|
-
readRunParentPath: () => readRunParentPath,
|
|
20094
|
-
recordCurrentCourt: () => recordCurrentCourt,
|
|
20095
|
-
resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
|
|
20096
|
-
writeRoleRunState: () => writeRoleRunState
|
|
20097
|
-
});
|
|
20098
|
-
import { existsSync as existsSync13 } from "node:fs";
|
|
20206
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
20099
20207
|
import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
|
|
20100
|
-
import { basename as
|
|
20208
|
+
import { basename as basename14, join as join32 } from "node:path";
|
|
20101
20209
|
async function writeRoleRunState(runDirectory, record) {
|
|
20102
20210
|
const payload = { ...record, runDirectory };
|
|
20103
20211
|
writeSectionSync(runDirectory, "runState", { ...payload });
|
|
@@ -20392,7 +20500,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
20392
20500
|
},
|
|
20393
20501
|
relocate(nextRunDirectory) {
|
|
20394
20502
|
currentRunDirectory = nextRunDirectory;
|
|
20395
|
-
currentLockPath =
|
|
20503
|
+
currentLockPath = join32(nextRunDirectory, WRITER_LOCK_FILE);
|
|
20396
20504
|
},
|
|
20397
20505
|
async release() {
|
|
20398
20506
|
if (released) return;
|
|
@@ -20431,10 +20539,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
20431
20539
|
};
|
|
20432
20540
|
const reportReadFailure = (error) => {
|
|
20433
20541
|
reportDiagnostic(
|
|
20434
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
20542
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join32(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
20435
20543
|
);
|
|
20436
20544
|
};
|
|
20437
|
-
const lockPath =
|
|
20545
|
+
const lockPath = join32(runDirectory, WRITER_LOCK_FILE);
|
|
20438
20546
|
let lastAutopsy = { verdict: "absent" };
|
|
20439
20547
|
let lastReclaimFailure;
|
|
20440
20548
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -20490,17 +20598,17 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
20490
20598
|
}
|
|
20491
20599
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
|
|
20492
20600
|
if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
|
|
20493
|
-
const parsed = parseRunLeaf(
|
|
20601
|
+
const parsed = parseRunLeaf(basename14(knownRunDirectory));
|
|
20494
20602
|
if (parsed === void 0 || parsed.runId !== runId) {
|
|
20495
20603
|
throw new CliUsageError(
|
|
20496
|
-
`run directory
|
|
20604
|
+
`run directory is not the expected role run: ${knownRunDirectory}`
|
|
20497
20605
|
);
|
|
20498
20606
|
}
|
|
20499
20607
|
return knownRunDirectory;
|
|
20500
20608
|
}
|
|
20501
20609
|
if (runId.trim() === "") return void 0;
|
|
20502
20610
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
20503
|
-
const booksRoot =
|
|
20611
|
+
const booksRoot = join32(ledgerHome, "books");
|
|
20504
20612
|
let bookKeys;
|
|
20505
20613
|
try {
|
|
20506
20614
|
bookKeys = await readdir4(booksRoot);
|
|
@@ -20515,8 +20623,8 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
|
|
|
20515
20623
|
);
|
|
20516
20624
|
}
|
|
20517
20625
|
async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
|
|
20518
|
-
if (
|
|
20519
|
-
const parsed = parseRunLeaf(
|
|
20626
|
+
if (existsSync14(recordedPath)) return recordedPath;
|
|
20627
|
+
const parsed = parseRunLeaf(basename14(recordedPath));
|
|
20520
20628
|
const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
|
|
20521
20629
|
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
20522
20630
|
return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
|
|
@@ -20537,10 +20645,6 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
20537
20645
|
throw error;
|
|
20538
20646
|
}
|
|
20539
20647
|
}
|
|
20540
|
-
async function findLatestRunIdForSeatTicket(input) {
|
|
20541
|
-
const found = await findLatestRunForSeatTicket(input);
|
|
20542
|
-
return found?.runId;
|
|
20543
|
-
}
|
|
20544
20648
|
async function findLatestRunForSeatTicket(input) {
|
|
20545
20649
|
if (input.parentRunPath.trim() === "") {
|
|
20546
20650
|
return void 0;
|
|
@@ -20550,7 +20654,7 @@ async function findLatestRunForSeatTicket(input) {
|
|
|
20550
20654
|
let runDirectories;
|
|
20551
20655
|
try {
|
|
20552
20656
|
runDirectories = await listBookRunDirectories(
|
|
20553
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
20657
|
+
input.ticketNumber === void 0 ? bookDir : join32(bookDir, String(input.ticketNumber))
|
|
20554
20658
|
);
|
|
20555
20659
|
} catch (error) {
|
|
20556
20660
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -20558,7 +20662,7 @@ async function findLatestRunForSeatTicket(input) {
|
|
|
20558
20662
|
}
|
|
20559
20663
|
let best;
|
|
20560
20664
|
for (const runDirectory of runDirectories) {
|
|
20561
|
-
const parsed = parseRunLeaf(
|
|
20665
|
+
const parsed = parseRunLeaf(basename14(runDirectory));
|
|
20562
20666
|
if (parsed === void 0 || parsed.role !== input.role) continue;
|
|
20563
20667
|
const runId = parsed.runId;
|
|
20564
20668
|
const parentPath = await readRunParentPath(runDirectory);
|
|
@@ -20585,15 +20689,15 @@ function restoredTicketFields(fields) {
|
|
|
20585
20689
|
async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
|
|
20586
20690
|
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
20587
20691
|
if (runDirectory === void 0) {
|
|
20588
|
-
throw new CliUsageError(`unknown role run
|
|
20692
|
+
throw new CliUsageError(`unknown role run: no run directory found under ${home}`);
|
|
20589
20693
|
}
|
|
20590
20694
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
20591
20695
|
if (disk === void 0) {
|
|
20592
|
-
throw new CliUsageError(`
|
|
20696
|
+
throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
|
|
20593
20697
|
}
|
|
20594
20698
|
const materialized = materializeRoleRunFromDisk(disk, authority);
|
|
20595
20699
|
if (materialized === void 0) {
|
|
20596
|
-
throw new CliUsageError(`
|
|
20700
|
+
throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
|
|
20597
20701
|
}
|
|
20598
20702
|
const { run, principal } = materialized;
|
|
20599
20703
|
let instruction = "";
|
|
@@ -20719,7 +20823,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
|
|
|
20719
20823
|
} catch (error) {
|
|
20720
20824
|
if (error instanceof CliUsageError) throw error;
|
|
20721
20825
|
throw new CliUsageError(
|
|
20722
|
-
`role run admitted request is unreadable: ${
|
|
20826
|
+
`role run admitted request is unreadable: ${run.runDirectory}`,
|
|
20723
20827
|
{ cause: error }
|
|
20724
20828
|
);
|
|
20725
20829
|
}
|
|
@@ -20746,7 +20850,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
|
|
|
20746
20850
|
}
|
|
20747
20851
|
if (!isEnoent(error)) {
|
|
20748
20852
|
throw new CliUsageError(
|
|
20749
|
-
`role run invocation identity is unreadable: ${
|
|
20853
|
+
`role run invocation identity is unreadable: ${run.runDirectory}`,
|
|
20750
20854
|
{ cause: error }
|
|
20751
20855
|
);
|
|
20752
20856
|
}
|
|
@@ -20828,7 +20932,7 @@ async function loadResumablePublicRole(home, runId, authority, options) {
|
|
|
20828
20932
|
}
|
|
20829
20933
|
function admitResumedRole(loaded) {
|
|
20830
20934
|
const role = loaded.run.role;
|
|
20831
|
-
const
|
|
20935
|
+
const leg = loaded.run.runDirectory;
|
|
20832
20936
|
const record = packagedRoleMetadata(role);
|
|
20833
20937
|
if (record === void 0) {
|
|
20834
20938
|
throw new CliUsageError(`unknown role: ${role}`);
|
|
@@ -20859,10 +20963,10 @@ function admitResumedRole(loaded) {
|
|
|
20859
20963
|
return admitted;
|
|
20860
20964
|
}
|
|
20861
20965
|
case "worker-task": {
|
|
20862
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role,
|
|
20966
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
|
|
20863
20967
|
if (fields.instruction.trim() === "") {
|
|
20864
20968
|
throw new CliUsageError(
|
|
20865
|
-
`role run admitted coder task is blank: ${
|
|
20969
|
+
`role run admitted coder task is blank: ${leg}`
|
|
20866
20970
|
);
|
|
20867
20971
|
}
|
|
20868
20972
|
const admitted = {
|
|
@@ -20874,10 +20978,10 @@ function admitResumedRole(loaded) {
|
|
|
20874
20978
|
return admitted;
|
|
20875
20979
|
}
|
|
20876
20980
|
case "worker-packet": {
|
|
20877
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role,
|
|
20981
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
|
|
20878
20982
|
if (fields.instruction.trim() === "") {
|
|
20879
20983
|
throw new CliUsageError(
|
|
20880
|
-
`role run admitted fixer instruction is blank: ${
|
|
20984
|
+
`role run admitted fixer instruction is blank: ${leg}`
|
|
20881
20985
|
);
|
|
20882
20986
|
}
|
|
20883
20987
|
const admitted = {
|
|
@@ -20894,19 +20998,19 @@ function admitResumedRole(loaded) {
|
|
|
20894
20998
|
const baseFault = admittedReviewerBaseFault(rawBase);
|
|
20895
20999
|
if (baseFault !== void 0 || rawBase === void 0) {
|
|
20896
21000
|
throw new CliUsageError(
|
|
20897
|
-
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${
|
|
21001
|
+
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${leg}` : `role run admitted reviewer base revision is missing: ${leg}`
|
|
20898
21002
|
);
|
|
20899
21003
|
}
|
|
20900
21004
|
const lens = fields.lens;
|
|
20901
21005
|
if (!isReviewerLens(lens)) {
|
|
20902
21006
|
throw new CliUsageError(
|
|
20903
|
-
`role run admitted reviewer lens is missing: ${
|
|
21007
|
+
`role run admitted reviewer lens is missing: ${leg}`
|
|
20904
21008
|
);
|
|
20905
21009
|
}
|
|
20906
21010
|
const authorityRefs = Object.freeze([...fields.authorityRefs ?? []]);
|
|
20907
21011
|
if (authorityRefs.length === 0) {
|
|
20908
21012
|
throw new CliUsageError(
|
|
20909
|
-
`role run admitted reviewer authority refs are missing: ${
|
|
21013
|
+
`role run admitted reviewer authority refs are missing: ${leg}`
|
|
20910
21014
|
);
|
|
20911
21015
|
}
|
|
20912
21016
|
const admitted = {
|
|
@@ -20922,7 +21026,7 @@ function admitResumedRole(loaded) {
|
|
|
20922
21026
|
const baseRevision = fields.baseRevision;
|
|
20923
21027
|
if (baseRevision === void 0 || baseRevision.trim() === "") {
|
|
20924
21028
|
throw new CliUsageError(
|
|
20925
|
-
`role run admitted gleaner-left base revision is missing: ${
|
|
21029
|
+
`role run admitted gleaner-left base revision is missing: ${leg}`
|
|
20926
21030
|
);
|
|
20927
21031
|
}
|
|
20928
21032
|
const admitted = {
|
|
@@ -20936,18 +21040,18 @@ function admitResumedRole(loaded) {
|
|
|
20936
21040
|
const mergerInputPath = fields.mergerInputPath;
|
|
20937
21041
|
if (mergerInputPath === void 0) {
|
|
20938
21042
|
throw new CliUsageError(
|
|
20939
|
-
`role run admitted merger input path is missing: ${
|
|
21043
|
+
`role run admitted merger input path is missing: ${leg}`
|
|
20940
21044
|
);
|
|
20941
21045
|
}
|
|
20942
21046
|
const derived = fields.derived;
|
|
20943
21047
|
if (derived === void 0) {
|
|
20944
21048
|
throw new CliUsageError(
|
|
20945
|
-
`role run admitted merger envelope is missing: ${
|
|
21049
|
+
`role run admitted merger envelope is missing: ${leg}`
|
|
20946
21050
|
);
|
|
20947
21051
|
}
|
|
20948
21052
|
if (fields.instruction.trim() === "") {
|
|
20949
21053
|
throw new CliUsageError(
|
|
20950
|
-
`role run admitted merger task is blank: ${
|
|
21054
|
+
`role run admitted merger task is blank: ${leg}`
|
|
20951
21055
|
);
|
|
20952
21056
|
}
|
|
20953
21057
|
const admitted = {
|
|
@@ -20963,7 +21067,7 @@ function admitResumedRole(loaded) {
|
|
|
20963
21067
|
const { prNumber, repository, repositoryDisplay } = fields;
|
|
20964
21068
|
if (repository === void 0 || repositoryDisplay === void 0) {
|
|
20965
21069
|
throw new CliUsageError(
|
|
20966
|
-
`role run admitted collector repository identity is missing: ${
|
|
21070
|
+
`role run admitted collector repository identity is missing: ${leg}`
|
|
20967
21071
|
);
|
|
20968
21072
|
}
|
|
20969
21073
|
let parsedRepository;
|
|
@@ -20975,7 +21079,7 @@ function admitResumedRole(loaded) {
|
|
|
20975
21079
|
}
|
|
20976
21080
|
if (parsedRepository.canonical !== repository) {
|
|
20977
21081
|
throw new CliUsageError(
|
|
20978
|
-
`role run admitted collector repository does not match its canonical form: ${
|
|
21082
|
+
`role run admitted collector repository does not match its canonical form: ${leg}`
|
|
20979
21083
|
);
|
|
20980
21084
|
}
|
|
20981
21085
|
const admitted = {
|
|
@@ -20992,7 +21096,7 @@ function admitResumedRole(loaded) {
|
|
|
20992
21096
|
const { issueNumber, caseRunsPath, caseIdentity } = fields;
|
|
20993
21097
|
if (issueNumber === void 0 || caseRunsPath === void 0 || caseIdentity === void 0) {
|
|
20994
21098
|
throw new CliUsageError(
|
|
20995
|
-
`role run admitted doctor case identity is missing: ${
|
|
21099
|
+
`role run admitted doctor case identity is missing: ${leg}`
|
|
20996
21100
|
);
|
|
20997
21101
|
}
|
|
20998
21102
|
const admitted = {
|
|
@@ -21008,7 +21112,7 @@ function admitResumedRole(loaded) {
|
|
|
21008
21112
|
const { sourceRunPath, sourceRun } = fields;
|
|
21009
21113
|
if (sourceRunPath === void 0 || sourceRun === void 0) {
|
|
21010
21114
|
throw new CliUsageError(
|
|
21011
|
-
`role run admitted notary source-run locator is missing: ${
|
|
21115
|
+
`role run admitted notary source-run locator is missing: ${leg}`
|
|
21012
21116
|
);
|
|
21013
21117
|
}
|
|
21014
21118
|
const admitted = {
|
|
@@ -21021,13 +21125,13 @@ function admitResumedRole(loaded) {
|
|
|
21021
21125
|
}
|
|
21022
21126
|
}
|
|
21023
21127
|
}
|
|
21024
|
-
function resumedWorkerPhase(phase, phases, role,
|
|
21128
|
+
function resumedWorkerPhase(phase, phases, role, leg) {
|
|
21025
21129
|
if (phase === "plan" || phase === "apply") {
|
|
21026
21130
|
if (phases.some((item) => item === phase)) {
|
|
21027
21131
|
return phase;
|
|
21028
21132
|
}
|
|
21029
21133
|
}
|
|
21030
|
-
throw new CliUsageError(`role run admitted ${role} phase is missing: ${
|
|
21134
|
+
throw new CliUsageError(`role run admitted ${role} phase is missing: ${leg}`);
|
|
21031
21135
|
}
|
|
21032
21136
|
var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
|
|
21033
21137
|
var init_run_lifecycle = __esm({
|
|
@@ -21289,7 +21393,7 @@ init_submission_ledger();
|
|
|
21289
21393
|
init_filed_submission();
|
|
21290
21394
|
init_report_ticket_tool();
|
|
21291
21395
|
import { writeSync as writeSync2 } from "node:fs";
|
|
21292
|
-
import { join as
|
|
21396
|
+
import { join as join33 } from "node:path";
|
|
21293
21397
|
import { Value as Value2 } from "typebox/value";
|
|
21294
21398
|
|
|
21295
21399
|
// src/activation-trace.ts
|
|
@@ -21338,7 +21442,7 @@ init_activation_ledger_topology();
|
|
|
21338
21442
|
import {
|
|
21339
21443
|
lstatSync as lstatSync2,
|
|
21340
21444
|
realpathSync as realpathSync2,
|
|
21341
|
-
statSync as
|
|
21445
|
+
statSync as statSync8,
|
|
21342
21446
|
writeFileSync as writeFileSync3
|
|
21343
21447
|
} from "node:fs";
|
|
21344
21448
|
import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
|
|
@@ -21413,7 +21517,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
21413
21517
|
}
|
|
21414
21518
|
let info;
|
|
21415
21519
|
try {
|
|
21416
|
-
info =
|
|
21520
|
+
info = statSync8(realFile);
|
|
21417
21521
|
} catch (error) {
|
|
21418
21522
|
throw new Error(
|
|
21419
21523
|
`Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
|
|
@@ -21807,10 +21911,10 @@ init_run_ticket_number();
|
|
|
21807
21911
|
|
|
21808
21912
|
// src/audited-run-identity.ts
|
|
21809
21913
|
init_role_run_placement();
|
|
21810
|
-
import { basename as
|
|
21914
|
+
import { basename as basename15 } from "node:path";
|
|
21811
21915
|
var AUDITED_RUN_IDENTITY_KIND = "audited-run";
|
|
21812
21916
|
function auditedRunIdentityFromDirectory(runDirectory) {
|
|
21813
|
-
const parsed = parseRunLeaf(
|
|
21917
|
+
const parsed = parseRunLeaf(basename15(runDirectory));
|
|
21814
21918
|
if (parsed === void 0) return void 0;
|
|
21815
21919
|
return formatRunLeaf(parsed.runId, parsed.role);
|
|
21816
21920
|
}
|
|
@@ -22214,7 +22318,7 @@ init_unknown_value();
|
|
|
22214
22318
|
init_submission_errors();
|
|
22215
22319
|
init_worker_submission_contracts();
|
|
22216
22320
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
22217
|
-
import { existsSync as
|
|
22321
|
+
import { existsSync as existsSync15, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync4 } from "node:fs";
|
|
22218
22322
|
import { resolve as resolve15 } from "node:path";
|
|
22219
22323
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
22220
22324
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -22244,7 +22348,7 @@ function statusOf(error) {
|
|
|
22244
22348
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
22245
22349
|
}
|
|
22246
22350
|
function tryGetAll(file, key) {
|
|
22247
|
-
if (!
|
|
22351
|
+
if (!existsSync15(file)) return [];
|
|
22248
22352
|
try {
|
|
22249
22353
|
const out = gitFile(file, ["--get-all", key]);
|
|
22250
22354
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -22254,7 +22358,7 @@ function tryGetAll(file, key) {
|
|
|
22254
22358
|
}
|
|
22255
22359
|
}
|
|
22256
22360
|
function ownedHook(path) {
|
|
22257
|
-
if (!
|
|
22361
|
+
if (!existsSync15(path)) return false;
|
|
22258
22362
|
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
22259
22363
|
}
|
|
22260
22364
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -22281,12 +22385,12 @@ function rmOwnedDir(dir) {
|
|
|
22281
22385
|
const hookPath = resolve15(dir, HOOK_FILE);
|
|
22282
22386
|
if (!ownedHook(hookPath)) return;
|
|
22283
22387
|
rmSync4(hookPath, { force: true });
|
|
22284
|
-
if (
|
|
22388
|
+
if (existsSync15(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
22285
22389
|
}
|
|
22286
22390
|
function linkedGitDirs(commonDir) {
|
|
22287
22391
|
const root = resolve15(commonDir, "worktrees");
|
|
22288
|
-
if (!
|
|
22289
|
-
return
|
|
22392
|
+
if (!existsSync15(root)) return [];
|
|
22393
|
+
return readdirSync4(root).map((name) => resolve15(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
22290
22394
|
}
|
|
22291
22395
|
function uninstallPackageWorkerHooks(cwd) {
|
|
22292
22396
|
let inside;
|
|
@@ -23077,7 +23181,7 @@ function readRoleRunCoordinates(ctx, label) {
|
|
|
23077
23181
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23078
23182
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
23079
23183
|
if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23080
|
-
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${
|
|
23184
|
+
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join33(runDirectory, RUN_STATE_FILE)})`);
|
|
23081
23185
|
}
|
|
23082
23186
|
return {
|
|
23083
23187
|
runDirectory,
|
|
@@ -24843,12 +24947,12 @@ function createAcpRoleTurnHost(config) {
|
|
|
24843
24947
|
// src/acp-host/seat-profile-soul.ts
|
|
24844
24948
|
import { constants as constants3 } from "node:fs";
|
|
24845
24949
|
import { access as access3, copyFile, lstat as lstat4, mkdir as mkdir4, readlink, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
|
|
24846
|
-
import { dirname as dirname19, join as
|
|
24950
|
+
import { dirname as dirname19, join as join34, relative as relative4, resolve as resolve16 } from "node:path";
|
|
24847
24951
|
function seatProfileName(spec, role) {
|
|
24848
24952
|
return `${spec.namePrefix}${role}`;
|
|
24849
24953
|
}
|
|
24850
24954
|
function packageRoleSoulPath(packageRoot, role) {
|
|
24851
|
-
return
|
|
24955
|
+
return join34(packageRoot, "souls", `${role}.md`);
|
|
24852
24956
|
}
|
|
24853
24957
|
async function pathExists2(path) {
|
|
24854
24958
|
try {
|
|
@@ -24865,16 +24969,16 @@ async function ensureSeatProfileSoul(options) {
|
|
|
24865
24969
|
if (!await pathExists2(soulTarget)) {
|
|
24866
24970
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
24867
24971
|
}
|
|
24868
|
-
const profilesRoot =
|
|
24869
|
-
const profileDir =
|
|
24972
|
+
const profilesRoot = join34(operatorHome, ...spec.profilesRootFromHome);
|
|
24973
|
+
const profileDir = join34(profilesRoot, profileName);
|
|
24870
24974
|
const hostRoot = dirname19(profilesRoot);
|
|
24871
|
-
const soulPath =
|
|
24975
|
+
const soulPath = join34(profileDir, spec.soulFileName);
|
|
24872
24976
|
if (!await pathExists2(profileDir)) {
|
|
24873
24977
|
await mkdir4(profileDir, { recursive: true });
|
|
24874
24978
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
24875
|
-
const source =
|
|
24979
|
+
const source = join34(hostRoot, name);
|
|
24876
24980
|
if (!await pathExists2(source)) continue;
|
|
24877
|
-
await copyFile(source,
|
|
24981
|
+
await copyFile(source, join34(profileDir, name));
|
|
24878
24982
|
}
|
|
24879
24983
|
} else {
|
|
24880
24984
|
await mkdir4(profileDir, { recursive: true });
|