@akagilnc/pi-workflow-roles 0.1.6115 → 0.1.6123
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/production-host.js +339 -235
- 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/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
|
@@ -1455,7 +1455,7 @@ async function findRoleRunDirectory(bookDirectories, runId, onlyRole) {
|
|
|
1455
1455
|
}
|
|
1456
1456
|
if (matches.length === 0) return void 0;
|
|
1457
1457
|
if (matches.length === 1) return matches[0];
|
|
1458
|
-
throw new Error(`ambiguous role run
|
|
1458
|
+
throw new Error(`ambiguous role run: ${matches.join(", ")}`);
|
|
1459
1459
|
}
|
|
1460
1460
|
function roleRunPlacement(ledgerHome, input) {
|
|
1461
1461
|
const subjectDirectory = "ticketNumber" in input.subject ? String(requireSafePositiveTicketNumber(
|
|
@@ -1626,7 +1626,7 @@ var init_role_run_path_rewrite = __esm({
|
|
|
1626
1626
|
});
|
|
1627
1627
|
|
|
1628
1628
|
// src/run-dossier-files.ts
|
|
1629
|
-
var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, OFFICER_POINTER_RECORD_KIND, RUN_STATE_KINDS;
|
|
1629
|
+
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;
|
|
1630
1630
|
var init_run_dossier_files = __esm({
|
|
1631
1631
|
"src/run-dossier-files.ts"() {
|
|
1632
1632
|
"use strict";
|
|
@@ -1642,8 +1642,10 @@ var init_run_dossier_files = __esm({
|
|
|
1642
1642
|
"post-seal-anomaly",
|
|
1643
1643
|
"attempt-history",
|
|
1644
1644
|
"turn-delivery",
|
|
1645
|
-
"officer-pointer"
|
|
1645
|
+
"officer-pointer",
|
|
1646
|
+
"progress"
|
|
1646
1647
|
]);
|
|
1648
|
+
PROGRESS_RECORD_KIND = "progress";
|
|
1647
1649
|
OFFICER_POINTER_RECORD_KIND = "officer-pointer";
|
|
1648
1650
|
RUN_STATE_KINDS = /* @__PURE__ */ new Set([
|
|
1649
1651
|
"invocation",
|
|
@@ -4865,6 +4867,13 @@ function currentReplyRows(terminal) {
|
|
|
4865
4867
|
function adviceNavigatorFact(input) {
|
|
4866
4868
|
return { disposition: "advice", prose: input.prose };
|
|
4867
4869
|
}
|
|
4870
|
+
function identityRows(leg) {
|
|
4871
|
+
const seat = leg.roleOutcome.role;
|
|
4872
|
+
return [
|
|
4873
|
+
...leg.ticket === void 0 ? [] : [`ticket ${leg.ticket}`],
|
|
4874
|
+
...[...leg.receipts ?? []].reverse().map((filed) => `receipt ${encodeTerminalField(filed.round === void 0 ? seat : `${seat}#${filed.round}`)} ${encodeTerminalField(filed.receipt)}`)
|
|
4875
|
+
];
|
|
4876
|
+
}
|
|
4868
4877
|
function formatTerminalResult(result) {
|
|
4869
4878
|
const lines = [];
|
|
4870
4879
|
lines.push("role outcome status");
|
|
@@ -4910,11 +4919,11 @@ function formatTerminalResult(result) {
|
|
|
4910
4919
|
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
4911
4920
|
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
4912
4921
|
}
|
|
4922
|
+
const lens = result.reviewerChildren?.[axis];
|
|
4923
|
+
if (lens !== void 0) lines.push(...identityRows(lens));
|
|
4913
4924
|
}
|
|
4914
4925
|
}
|
|
4915
|
-
|
|
4916
|
-
lines.push(`run ${encodeTerminalField(result.runId)}`);
|
|
4917
|
-
}
|
|
4926
|
+
lines.push(...identityRows(result));
|
|
4918
4927
|
if (result.autoResumeCount !== void 0) {
|
|
4919
4928
|
lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
4920
4929
|
}
|
|
@@ -4975,15 +4984,7 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
|
|
|
4975
4984
|
return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
|
|
4976
4985
|
}
|
|
4977
4986
|
function officerRunIdFromSummoned(summoned) {
|
|
4978
|
-
|
|
4979
|
-
const fromDir = runIdFromRunDirectory(summoned.runDirectory);
|
|
4980
|
-
if (fromDir !== void 0) return fromDir;
|
|
4981
|
-
}
|
|
4982
|
-
const terminal = summoned.terminal;
|
|
4983
|
-
if (terminal !== void 0 && typeof terminal.runId === "string" && terminal.runId.trim() !== "") {
|
|
4984
|
-
return terminal.runId;
|
|
4985
|
-
}
|
|
4986
|
-
return void 0;
|
|
4987
|
+
return summoned.runDirectory === void 0 ? void 0 : runIdFromRunDirectory(summoned.runDirectory);
|
|
4987
4988
|
}
|
|
4988
4989
|
function withOfficerRunId(result, summoned) {
|
|
4989
4990
|
if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask") {
|
|
@@ -6428,6 +6429,23 @@ function captureWorktreeHead(projectRoot) {
|
|
|
6428
6429
|
return { head: "", fault: `git rev-parse HEAD threw cwd=${projectRoot}: ${message}` };
|
|
6429
6430
|
}
|
|
6430
6431
|
}
|
|
6432
|
+
function carryProgressRow(runDirectory, line2, call) {
|
|
6433
|
+
const runId = runIdFromRunDirectory(runDirectory);
|
|
6434
|
+
if (runId === void 0) return;
|
|
6435
|
+
sitianReport({
|
|
6436
|
+
level: "event",
|
|
6437
|
+
kind: PROGRESS_RECORD_KIND,
|
|
6438
|
+
subject: { runId, ...call === void 0 ? {} : { attemptId: call.attemptId } },
|
|
6439
|
+
payload: {
|
|
6440
|
+
type: PROGRESS_RECORD_KIND,
|
|
6441
|
+
...call === void 0 ? {} : { toolCallId: call.toolCallId },
|
|
6442
|
+
receipt: line2.receipt,
|
|
6443
|
+
round: line2.round
|
|
6444
|
+
},
|
|
6445
|
+
source: "ticket-progress",
|
|
6446
|
+
sessionParent: sessionFileOf(runDirectory)
|
|
6447
|
+
});
|
|
6448
|
+
}
|
|
6431
6449
|
function progressSessionAbsolute(runDirectory, context) {
|
|
6432
6450
|
const host = typeof context.host === "string" ? context.host.trim() : "";
|
|
6433
6451
|
const sessionDirectory = sessionDirectoryOf(runDirectory);
|
|
@@ -6453,6 +6471,7 @@ function landTicketProgressForSealedSubmission(input) {
|
|
|
6453
6471
|
role: input.role,
|
|
6454
6472
|
accepted: input.accepted,
|
|
6455
6473
|
sealHead: input.sealHead,
|
|
6474
|
+
call: input.call,
|
|
6456
6475
|
...input.lens === void 0 ? {} : { lens: input.lens },
|
|
6457
6476
|
sessionFile: progressSessionAbsolute(runDirectory, input.context),
|
|
6458
6477
|
instruction: typeof input.context.summonsInstruction === "string" ? input.context.summonsInstruction : ""
|
|
@@ -6496,6 +6515,7 @@ function landTicketProgress(input) {
|
|
|
6496
6515
|
mkdirSync3(dirname10(progressPath), { recursive: true });
|
|
6497
6516
|
appendFileSync2(progressPath, `${JSON.stringify(line2)}
|
|
6498
6517
|
`, "utf8");
|
|
6518
|
+
carryProgressRow(runDirectory, line2, input.call);
|
|
6499
6519
|
if (input.sealHead.fault !== void 0) {
|
|
6500
6520
|
process.stderr.write(`${input.sealHead.fault}
|
|
6501
6521
|
`);
|
|
@@ -6543,6 +6563,7 @@ function relocateTicketProgressForLeg(input) {
|
|
|
6543
6563
|
"utf8"
|
|
6544
6564
|
);
|
|
6545
6565
|
rmSync3(stagedPath, { force: true });
|
|
6566
|
+
for (const moved of movedLines) carryProgressRow(input.runDirectory, moved);
|
|
6546
6567
|
}
|
|
6547
6568
|
var CURRENT_FILENAME, RECEIPTS_DIRNAME, LEG_PROGRESS_FILENAME;
|
|
6548
6569
|
var init_ticket_progress = __esm({
|
|
@@ -6553,6 +6574,9 @@ var init_ticket_progress = __esm({
|
|
|
6553
6574
|
init_packaged_role_registry();
|
|
6554
6575
|
init_role_run_placement();
|
|
6555
6576
|
init_run_dossier();
|
|
6577
|
+
init_run_dossier_files();
|
|
6578
|
+
init_run_terminal_artifacts();
|
|
6579
|
+
init_sitian_facade();
|
|
6556
6580
|
init_sitian_reader();
|
|
6557
6581
|
init_unknown_value();
|
|
6558
6582
|
CURRENT_FILENAME = "current.jsonl";
|
|
@@ -7061,8 +7085,66 @@ var init_ticket_provenance = __esm({
|
|
|
7061
7085
|
}
|
|
7062
7086
|
});
|
|
7063
7087
|
|
|
7088
|
+
// src/ticket-address.ts
|
|
7089
|
+
import { existsSync as existsSync5, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
7090
|
+
import { join as join14 } from "node:path";
|
|
7091
|
+
function parseAddressTicket(token) {
|
|
7092
|
+
return parseTicketNumber(token.startsWith("#") ? token.slice(1) : token);
|
|
7093
|
+
}
|
|
7094
|
+
function parseSeatRound(token) {
|
|
7095
|
+
const hash = token.indexOf("#");
|
|
7096
|
+
return hash === -1 ? { seat: token } : { seat: token.slice(0, hash), round: token.slice(hash + 1) };
|
|
7097
|
+
}
|
|
7098
|
+
function parseTicketLegLocator(token) {
|
|
7099
|
+
const colon = token.indexOf(":");
|
|
7100
|
+
if (colon === -1) return void 0;
|
|
7101
|
+
const ticketNumber = parseAddressTicket(token.slice(0, colon));
|
|
7102
|
+
const { seat, round } = parseSeatRound(token.slice(colon + 1));
|
|
7103
|
+
if (ticketNumber === void 0 || seat === "" || round === void 0 || round === "") {
|
|
7104
|
+
return void 0;
|
|
7105
|
+
}
|
|
7106
|
+
return { ticketNumber, seat, round };
|
|
7107
|
+
}
|
|
7108
|
+
function locateTicketLeg(bookDirectory, input) {
|
|
7109
|
+
const ticketDirectory = join14(bookDirectory, String(input.ticketNumber));
|
|
7110
|
+
if (!existsSync5(ticketDirectory)) {
|
|
7111
|
+
throw new CliUsageError(`ticket ${input.ticketNumber} has no records in this project's book: ${ticketDirectory}`);
|
|
7112
|
+
}
|
|
7113
|
+
if (input.round !== void 0) {
|
|
7114
|
+
const row = readTicketProgressLines(ticketDirectory).find((line2) => line2.seat === input.seat && line2.round === input.round);
|
|
7115
|
+
if (row === void 0) {
|
|
7116
|
+
throw new CliUsageError(
|
|
7117
|
+
`ticket ${input.ticketNumber} has no progress row ${input.seat}#${input.round}`
|
|
7118
|
+
);
|
|
7119
|
+
}
|
|
7120
|
+
return join14(ticketDirectory, ...row.receipt.split("/").slice(0, 2));
|
|
7121
|
+
}
|
|
7122
|
+
const runsDirectory = join14(ticketDirectory, "runs");
|
|
7123
|
+
let latest;
|
|
7124
|
+
for (const entry of existsSync5(runsDirectory) ? readdirSync3(runsDirectory, { withFileTypes: true }) : []) {
|
|
7125
|
+
if (!entry.isDirectory() || parseRunLeaf(entry.name)?.role !== input.seat) continue;
|
|
7126
|
+
const { mtimeMs } = statSync4(join14(runsDirectory, entry.name));
|
|
7127
|
+
if (latest === void 0 || mtimeMs > latest.mtimeMs || mtimeMs === latest.mtimeMs && entry.name > latest.leaf) {
|
|
7128
|
+
latest = { leaf: entry.name, mtimeMs };
|
|
7129
|
+
}
|
|
7130
|
+
}
|
|
7131
|
+
if (latest === void 0) {
|
|
7132
|
+
throw new CliUsageError(`ticket ${input.ticketNumber} has no ${input.seat} leg`);
|
|
7133
|
+
}
|
|
7134
|
+
return join14(runsDirectory, latest.leaf);
|
|
7135
|
+
}
|
|
7136
|
+
var init_ticket_address = __esm({
|
|
7137
|
+
"src/ticket-address.ts"() {
|
|
7138
|
+
"use strict";
|
|
7139
|
+
init_cli_errors();
|
|
7140
|
+
init_role_run_placement();
|
|
7141
|
+
init_run_ticket_number();
|
|
7142
|
+
init_ticket_progress();
|
|
7143
|
+
}
|
|
7144
|
+
});
|
|
7145
|
+
|
|
7064
7146
|
// src/notary-source-run.ts
|
|
7065
|
-
import { dirname as dirname11, isAbsolute as isAbsolute4, join as
|
|
7147
|
+
import { dirname as dirname11, isAbsolute as isAbsolute4, join as join15, resolve as resolve8, basename as basename8 } from "node:path";
|
|
7066
7148
|
import { lstat, realpath as realpath2 } from "node:fs/promises";
|
|
7067
7149
|
async function readRetainedIdentity(runDirectory) {
|
|
7068
7150
|
try {
|
|
@@ -7114,11 +7196,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
7114
7196
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
7115
7197
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
7116
7198
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
7117
|
-
const bookRunsRoot =
|
|
7199
|
+
const bookRunsRoot = join15(bookDirectory, "runs");
|
|
7118
7200
|
let candidate;
|
|
7119
|
-
const
|
|
7120
|
-
if (
|
|
7121
|
-
candidate =
|
|
7201
|
+
const address = parseTicketLegLocator(raw);
|
|
7202
|
+
if (address !== void 0) {
|
|
7203
|
+
candidate = locateTicketLeg(bookDirectory, address);
|
|
7122
7204
|
} else {
|
|
7123
7205
|
candidate = isAbsolute4(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
7124
7206
|
const identity2 = parseRunLeaf(basename8(candidate));
|
|
@@ -7198,6 +7280,7 @@ var init_notary_source_run = __esm({
|
|
|
7198
7280
|
init_activation_ledger_topology();
|
|
7199
7281
|
init_run_lifecycle();
|
|
7200
7282
|
init_role_run_placement();
|
|
7283
|
+
init_ticket_address();
|
|
7201
7284
|
NotarySourceRunError = class extends Error {
|
|
7202
7285
|
constructor(message, options) {
|
|
7203
7286
|
super(message, options);
|
|
@@ -7667,7 +7750,7 @@ var init_option_definitions = __esm({
|
|
|
7667
7750
|
owner: "auditor",
|
|
7668
7751
|
canonical: "--source-run",
|
|
7669
7752
|
aliases: [],
|
|
7670
|
-
valueMetavar: "
|
|
7753
|
+
valueMetavar: "ticket:seat#round|path",
|
|
7671
7754
|
required: true,
|
|
7672
7755
|
repeatable: false,
|
|
7673
7756
|
form: "option",
|
|
@@ -7845,13 +7928,13 @@ var init_option_definitions = __esm({
|
|
|
7845
7928
|
owner: "notary",
|
|
7846
7929
|
canonical: "--source-run",
|
|
7847
7930
|
aliases: [],
|
|
7848
|
-
valueMetavar: "
|
|
7931
|
+
valueMetavar: "ticket:seat#round|path",
|
|
7849
7932
|
required: true,
|
|
7850
7933
|
repeatable: false,
|
|
7851
7934
|
form: "option",
|
|
7852
7935
|
description: {
|
|
7853
|
-
en: "Required source run locator (
|
|
7854
|
-
zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\
|
|
7936
|
+
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.",
|
|
7937
|
+
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"
|
|
7855
7938
|
}
|
|
7856
7939
|
}
|
|
7857
7940
|
];
|
|
@@ -7862,13 +7945,13 @@ var init_option_definitions = __esm({
|
|
|
7862
7945
|
owner: "inspector",
|
|
7863
7946
|
canonical: "--source-run",
|
|
7864
7947
|
aliases: [],
|
|
7865
|
-
valueMetavar: "
|
|
7948
|
+
valueMetavar: "ticket:seat#round|path",
|
|
7866
7949
|
required: false,
|
|
7867
7950
|
repeatable: false,
|
|
7868
7951
|
form: "option",
|
|
7869
7952
|
description: {
|
|
7870
|
-
en: "Optional audited source-run locator (
|
|
7871
|
-
zh: "\u53EF\u9009\u88AB\u5BA1\u817F\u5B9A\u4F4D\u7B26\
|
|
7953
|
+
en: "Optional audited source-run locator (<ticket>:<seat>#<round> or path). Gate summons always supply it; identity rides startup materials.",
|
|
7954
|
+
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"
|
|
7872
7955
|
}
|
|
7873
7956
|
}
|
|
7874
7957
|
];
|
|
@@ -8163,10 +8246,10 @@ var init_option_definitions = __esm({
|
|
|
8163
8246
|
auditor: {
|
|
8164
8247
|
command: "auditor",
|
|
8165
8248
|
summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: converged, continue, or escalate.",
|
|
8166
|
-
usage: ["ak-role auditor --subject <judge|doctor> --source-run <
|
|
8249
|
+
usage: ["ak-role auditor --subject <judge|doctor> --source-run <ticket:seat#round|path> [options] [instruction]"],
|
|
8167
8250
|
examples: [
|
|
8168
|
-
'ak-role auditor --subject judge --source-run
|
|
8169
|
-
'ak-role auditor --subject doctor --source-run
|
|
8251
|
+
'ak-role auditor --subject judge --source-run 1201:judge#2 --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
|
|
8252
|
+
'ak-role auditor --subject doctor --source-run 1201:doctor#1 "\u5BA1\uFF1A\u592A\u533B\u5019\u9009\u662F\u5426\u5408\u89C4\u3002"'
|
|
8170
8253
|
]
|
|
8171
8254
|
},
|
|
8172
8255
|
diarist: {
|
|
@@ -8189,10 +8272,10 @@ var init_option_definitions = __esm({
|
|
|
8189
8272
|
notary: {
|
|
8190
8273
|
command: "notary",
|
|
8191
8274
|
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.",
|
|
8192
|
-
usage: ["ak-role notary --source-run <
|
|
8275
|
+
usage: ["ak-role notary --source-run <ticket:seat#round|path> [options]"],
|
|
8193
8276
|
examples: [
|
|
8194
|
-
"ak-role notary --source-run
|
|
8195
|
-
"ak-role notary --source-run
|
|
8277
|
+
"ak-role notary --source-run 1201:judge#2",
|
|
8278
|
+
"ak-role notary --source-run 1201:countersign#1"
|
|
8196
8279
|
]
|
|
8197
8280
|
},
|
|
8198
8281
|
analyst: {
|
|
@@ -8249,14 +8332,15 @@ var init_option_definitions = __esm({
|
|
|
8249
8332
|
},
|
|
8250
8333
|
resume: {
|
|
8251
8334
|
command: "resume",
|
|
8252
|
-
summary: "Resume a
|
|
8253
|
-
usage: ["ak-role resume <
|
|
8335
|
+
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).",
|
|
8336
|
+
usage: ["ak-role resume <ticket> <seat>[#<round>] [message]"],
|
|
8254
8337
|
examples: [
|
|
8255
|
-
"ak-role resume
|
|
8256
|
-
'ak-role resume
|
|
8257
|
-
"ak-role
|
|
8258
|
-
"ak-role --
|
|
8259
|
-
|
|
8338
|
+
"ak-role resume 1201 judge",
|
|
8339
|
+
'ak-role resume 1201 judge "owner ruling"',
|
|
8340
|
+
"ak-role resume 1201 'reviewer#2.correctness'",
|
|
8341
|
+
"ak-role --host grok-build resume 1201 fixer",
|
|
8342
|
+
"ak-role --engine agy resume 1201 fixer",
|
|
8343
|
+
'ak-role resume --model xai/grok-4.5 1201 notary "owner ruling"'
|
|
8260
8344
|
]
|
|
8261
8345
|
},
|
|
8262
8346
|
new: {
|
|
@@ -8265,7 +8349,7 @@ var init_option_definitions = __esm({
|
|
|
8265
8349
|
usage: ["ak-role new <role> [options] \u2026"],
|
|
8266
8350
|
examples: [
|
|
8267
8351
|
'ak-role new countersign --attach ./ticket.md "\u88C1\uFF1A\u672C\u7968 #708 \u662F\u5426\u8DB3\u4EE5\u5F00\u5DE5\u3002"',
|
|
8268
|
-
"ak-role new notary --source-run
|
|
8352
|
+
"ak-role new notary --source-run 1201:countersign#1",
|
|
8269
8353
|
"ak-role --host grok-build new inspector --attach ./change.patch"
|
|
8270
8354
|
]
|
|
8271
8355
|
},
|
|
@@ -8288,14 +8372,14 @@ var init_option_definitions = __esm({
|
|
|
8288
8372
|
|
|
8289
8373
|
// src/public-cli/invocation.ts
|
|
8290
8374
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
8291
|
-
import { existsSync as
|
|
8375
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
8292
8376
|
import {
|
|
8293
8377
|
readFile as readFile9,
|
|
8294
8378
|
realpath as realpath3,
|
|
8295
8379
|
rename,
|
|
8296
8380
|
writeFile as writeFile2
|
|
8297
8381
|
} from "node:fs/promises";
|
|
8298
|
-
import { dirname as dirname12, isAbsolute as isAbsolute5, join as
|
|
8382
|
+
import { dirname as dirname12, isAbsolute as isAbsolute5, join as join16, resolve as resolve9 } from "node:path";
|
|
8299
8383
|
function admittedSourceRunPath(admitted) {
|
|
8300
8384
|
if (!isRecord(admitted)) return void 0;
|
|
8301
8385
|
const path = admitted.sourceRunPath;
|
|
@@ -8473,7 +8557,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
8473
8557
|
runId: childRunId,
|
|
8474
8558
|
role: "diarist"
|
|
8475
8559
|
}).runDirectory;
|
|
8476
|
-
if (
|
|
8560
|
+
if (existsSync6(unboundChildDirectory)) {
|
|
8477
8561
|
input.authority.seal(childTarget);
|
|
8478
8562
|
await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
|
|
8479
8563
|
await rehomeUnboundTicketProvenance(
|
|
@@ -8497,7 +8581,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
8497
8581
|
}
|
|
8498
8582
|
continue;
|
|
8499
8583
|
}
|
|
8500
|
-
if (
|
|
8584
|
+
if (existsSync6(childTarget.runDirectory)) {
|
|
8501
8585
|
relocateTicketProgressForLeg({
|
|
8502
8586
|
runDirectory: childTarget.runDirectory
|
|
8503
8587
|
});
|
|
@@ -8595,7 +8679,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
8595
8679
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
8596
8680
|
const rolePackageRoot = packageRoot;
|
|
8597
8681
|
const raw = JSON.parse(
|
|
8598
|
-
await readFile9(
|
|
8682
|
+
await readFile9(join16(rolePackageRoot, "package.json"), "utf8")
|
|
8599
8683
|
);
|
|
8600
8684
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
8601
8685
|
throw new Error(
|
|
@@ -9166,7 +9250,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
9166
9250
|
resolutionScope: [...derived.resolutionScope],
|
|
9167
9251
|
authorizedChecks: []
|
|
9168
9252
|
});
|
|
9169
|
-
const mergerInputPath =
|
|
9253
|
+
const mergerInputPath = join16(placed.runDirectory, "merger-input.json");
|
|
9170
9254
|
await writeFile2(
|
|
9171
9255
|
mergerInputPath,
|
|
9172
9256
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -9434,7 +9518,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
9434
9518
|
}
|
|
9435
9519
|
async function resolveDoctorCaseRunsPath(options) {
|
|
9436
9520
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
9437
|
-
const defaultRuns =
|
|
9521
|
+
const defaultRuns = join16(
|
|
9438
9522
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
9439
9523
|
String(options.issueNumber),
|
|
9440
9524
|
"runs"
|
|
@@ -9731,34 +9815,9 @@ var init_invocation = __esm({
|
|
|
9731
9815
|
});
|
|
9732
9816
|
|
|
9733
9817
|
// src/public-cli/run-lifecycle.ts
|
|
9734
|
-
|
|
9735
|
-
__export(run_lifecycle_exports, {
|
|
9736
|
-
AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
|
|
9737
|
-
RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
|
|
9738
|
-
WRITER_LOCK_FILE: () => WRITER_LOCK_FILE,
|
|
9739
|
-
acquireRunWriterLease: () => acquireRunWriterLease,
|
|
9740
|
-
autopsyWriterLock: () => autopsyWriterLock,
|
|
9741
|
-
clearCurrentCourt: () => clearCurrentCourt,
|
|
9742
|
-
describeErrorIdentity: () => describeErrorIdentity,
|
|
9743
|
-
findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
|
|
9744
|
-
findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
|
|
9745
|
-
findRunDirectoryById: () => findRunDirectoryById,
|
|
9746
|
-
loadResumablePublicRole: () => loadResumablePublicRole,
|
|
9747
|
-
markRunAdmitted: () => markRunAdmitted,
|
|
9748
|
-
markRunRunning: () => markRunRunning,
|
|
9749
|
-
markRunTerminal: () => markRunTerminal,
|
|
9750
|
-
peekRoleRunRole: () => peekRoleRunRole,
|
|
9751
|
-
readCurrentCourt: () => readCurrentCourt,
|
|
9752
|
-
readRoleRunIdentity: () => readRoleRunIdentity,
|
|
9753
|
-
readRoleRunState: () => readRoleRunState,
|
|
9754
|
-
readRunParentPath: () => readRunParentPath,
|
|
9755
|
-
recordCurrentCourt: () => recordCurrentCourt,
|
|
9756
|
-
resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
|
|
9757
|
-
writeRoleRunState: () => writeRoleRunState
|
|
9758
|
-
});
|
|
9759
|
-
import { existsSync as existsSync6 } from "node:fs";
|
|
9818
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
9760
9819
|
import { chmod, lstat as lstat2, open, readdir as readdir3, readFile as readFile10, unlink } from "node:fs/promises";
|
|
9761
|
-
import { basename as basename9, join as
|
|
9820
|
+
import { basename as basename9, join as join17 } from "node:path";
|
|
9762
9821
|
async function writeRoleRunState(runDirectory, record) {
|
|
9763
9822
|
const payload = { ...record, runDirectory };
|
|
9764
9823
|
writeSectionSync(runDirectory, "runState", { ...payload });
|
|
@@ -10053,7 +10112,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
10053
10112
|
},
|
|
10054
10113
|
relocate(nextRunDirectory) {
|
|
10055
10114
|
currentRunDirectory = nextRunDirectory;
|
|
10056
|
-
currentLockPath =
|
|
10115
|
+
currentLockPath = join17(nextRunDirectory, WRITER_LOCK_FILE);
|
|
10057
10116
|
},
|
|
10058
10117
|
async release() {
|
|
10059
10118
|
if (released) return;
|
|
@@ -10092,10 +10151,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
10092
10151
|
};
|
|
10093
10152
|
const reportReadFailure = (error) => {
|
|
10094
10153
|
reportDiagnostic(
|
|
10095
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
10154
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join17(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
10096
10155
|
);
|
|
10097
10156
|
};
|
|
10098
|
-
const lockPath =
|
|
10157
|
+
const lockPath = join17(runDirectory, WRITER_LOCK_FILE);
|
|
10099
10158
|
let lastAutopsy = { verdict: "absent" };
|
|
10100
10159
|
let lastReclaimFailure;
|
|
10101
10160
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -10154,14 +10213,14 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
|
|
|
10154
10213
|
const parsed = parseRunLeaf(basename9(knownRunDirectory));
|
|
10155
10214
|
if (parsed === void 0 || parsed.runId !== runId) {
|
|
10156
10215
|
throw new CliUsageError(
|
|
10157
|
-
`run directory
|
|
10216
|
+
`run directory is not the expected role run: ${knownRunDirectory}`
|
|
10158
10217
|
);
|
|
10159
10218
|
}
|
|
10160
10219
|
return knownRunDirectory;
|
|
10161
10220
|
}
|
|
10162
10221
|
if (runId.trim() === "") return void 0;
|
|
10163
10222
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
10164
|
-
const booksRoot =
|
|
10223
|
+
const booksRoot = join17(ledgerHome, "books");
|
|
10165
10224
|
let bookKeys;
|
|
10166
10225
|
try {
|
|
10167
10226
|
bookKeys = await readdir3(booksRoot);
|
|
@@ -10176,7 +10235,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
|
|
|
10176
10235
|
);
|
|
10177
10236
|
}
|
|
10178
10237
|
async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
|
|
10179
|
-
if (
|
|
10238
|
+
if (existsSync7(recordedPath)) return recordedPath;
|
|
10180
10239
|
const parsed = parseRunLeaf(basename9(recordedPath));
|
|
10181
10240
|
const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
|
|
10182
10241
|
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
@@ -10198,10 +10257,6 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
10198
10257
|
throw error;
|
|
10199
10258
|
}
|
|
10200
10259
|
}
|
|
10201
|
-
async function findLatestRunIdForSeatTicket(input) {
|
|
10202
|
-
const found = await findLatestRunForSeatTicket(input);
|
|
10203
|
-
return found?.runId;
|
|
10204
|
-
}
|
|
10205
10260
|
async function findLatestRunForSeatTicket(input) {
|
|
10206
10261
|
if (input.parentRunPath.trim() === "") {
|
|
10207
10262
|
return void 0;
|
|
@@ -10211,7 +10266,7 @@ async function findLatestRunForSeatTicket(input) {
|
|
|
10211
10266
|
let runDirectories;
|
|
10212
10267
|
try {
|
|
10213
10268
|
runDirectories = await listBookRunDirectories(
|
|
10214
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
10269
|
+
input.ticketNumber === void 0 ? bookDir : join17(bookDir, String(input.ticketNumber))
|
|
10215
10270
|
);
|
|
10216
10271
|
} catch (error) {
|
|
10217
10272
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -10246,15 +10301,15 @@ function restoredTicketFields(fields) {
|
|
|
10246
10301
|
async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
|
|
10247
10302
|
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
10248
10303
|
if (runDirectory === void 0) {
|
|
10249
|
-
throw new CliUsageError(`unknown role run
|
|
10304
|
+
throw new CliUsageError(`unknown role run: no run directory found under ${home}`);
|
|
10250
10305
|
}
|
|
10251
10306
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
10252
10307
|
if (disk === void 0) {
|
|
10253
|
-
throw new CliUsageError(`
|
|
10308
|
+
throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
|
|
10254
10309
|
}
|
|
10255
10310
|
const materialized = materializeRoleRunFromDisk(disk, authority);
|
|
10256
10311
|
if (materialized === void 0) {
|
|
10257
|
-
throw new CliUsageError(`
|
|
10312
|
+
throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
|
|
10258
10313
|
}
|
|
10259
10314
|
const { run, principal } = materialized;
|
|
10260
10315
|
let instruction = "";
|
|
@@ -10380,7 +10435,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
|
|
|
10380
10435
|
} catch (error) {
|
|
10381
10436
|
if (error instanceof CliUsageError) throw error;
|
|
10382
10437
|
throw new CliUsageError(
|
|
10383
|
-
`role run admitted request is unreadable: ${
|
|
10438
|
+
`role run admitted request is unreadable: ${run.runDirectory}`,
|
|
10384
10439
|
{ cause: error }
|
|
10385
10440
|
);
|
|
10386
10441
|
}
|
|
@@ -10407,7 +10462,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
|
|
|
10407
10462
|
}
|
|
10408
10463
|
if (!isEnoent(error)) {
|
|
10409
10464
|
throw new CliUsageError(
|
|
10410
|
-
`role run invocation identity is unreadable: ${
|
|
10465
|
+
`role run invocation identity is unreadable: ${run.runDirectory}`,
|
|
10411
10466
|
{ cause: error }
|
|
10412
10467
|
);
|
|
10413
10468
|
}
|
|
@@ -10489,7 +10544,7 @@ async function loadResumablePublicRole(home, runId, authority, options) {
|
|
|
10489
10544
|
}
|
|
10490
10545
|
function admitResumedRole(loaded) {
|
|
10491
10546
|
const role = loaded.run.role;
|
|
10492
|
-
const
|
|
10547
|
+
const leg = loaded.run.runDirectory;
|
|
10493
10548
|
const record = packagedRoleMetadata(role);
|
|
10494
10549
|
if (record === void 0) {
|
|
10495
10550
|
throw new CliUsageError(`unknown role: ${role}`);
|
|
@@ -10520,10 +10575,10 @@ function admitResumedRole(loaded) {
|
|
|
10520
10575
|
return admitted;
|
|
10521
10576
|
}
|
|
10522
10577
|
case "worker-task": {
|
|
10523
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role,
|
|
10578
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
|
|
10524
10579
|
if (fields.instruction.trim() === "") {
|
|
10525
10580
|
throw new CliUsageError(
|
|
10526
|
-
`role run admitted coder task is blank: ${
|
|
10581
|
+
`role run admitted coder task is blank: ${leg}`
|
|
10527
10582
|
);
|
|
10528
10583
|
}
|
|
10529
10584
|
const admitted = {
|
|
@@ -10535,10 +10590,10 @@ function admitResumedRole(loaded) {
|
|
|
10535
10590
|
return admitted;
|
|
10536
10591
|
}
|
|
10537
10592
|
case "worker-packet": {
|
|
10538
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role,
|
|
10593
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
|
|
10539
10594
|
if (fields.instruction.trim() === "") {
|
|
10540
10595
|
throw new CliUsageError(
|
|
10541
|
-
`role run admitted fixer instruction is blank: ${
|
|
10596
|
+
`role run admitted fixer instruction is blank: ${leg}`
|
|
10542
10597
|
);
|
|
10543
10598
|
}
|
|
10544
10599
|
const admitted = {
|
|
@@ -10555,19 +10610,19 @@ function admitResumedRole(loaded) {
|
|
|
10555
10610
|
const baseFault = admittedReviewerBaseFault(rawBase);
|
|
10556
10611
|
if (baseFault !== void 0 || rawBase === void 0) {
|
|
10557
10612
|
throw new CliUsageError(
|
|
10558
|
-
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${
|
|
10613
|
+
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${leg}` : `role run admitted reviewer base revision is missing: ${leg}`
|
|
10559
10614
|
);
|
|
10560
10615
|
}
|
|
10561
10616
|
const lens = fields.lens;
|
|
10562
10617
|
if (!isReviewerLens(lens)) {
|
|
10563
10618
|
throw new CliUsageError(
|
|
10564
|
-
`role run admitted reviewer lens is missing: ${
|
|
10619
|
+
`role run admitted reviewer lens is missing: ${leg}`
|
|
10565
10620
|
);
|
|
10566
10621
|
}
|
|
10567
10622
|
const authorityRefs = Object.freeze([...fields.authorityRefs ?? []]);
|
|
10568
10623
|
if (authorityRefs.length === 0) {
|
|
10569
10624
|
throw new CliUsageError(
|
|
10570
|
-
`role run admitted reviewer authority refs are missing: ${
|
|
10625
|
+
`role run admitted reviewer authority refs are missing: ${leg}`
|
|
10571
10626
|
);
|
|
10572
10627
|
}
|
|
10573
10628
|
const admitted = {
|
|
@@ -10583,7 +10638,7 @@ function admitResumedRole(loaded) {
|
|
|
10583
10638
|
const baseRevision = fields.baseRevision;
|
|
10584
10639
|
if (baseRevision === void 0 || baseRevision.trim() === "") {
|
|
10585
10640
|
throw new CliUsageError(
|
|
10586
|
-
`role run admitted gleaner-left base revision is missing: ${
|
|
10641
|
+
`role run admitted gleaner-left base revision is missing: ${leg}`
|
|
10587
10642
|
);
|
|
10588
10643
|
}
|
|
10589
10644
|
const admitted = {
|
|
@@ -10597,18 +10652,18 @@ function admitResumedRole(loaded) {
|
|
|
10597
10652
|
const mergerInputPath = fields.mergerInputPath;
|
|
10598
10653
|
if (mergerInputPath === void 0) {
|
|
10599
10654
|
throw new CliUsageError(
|
|
10600
|
-
`role run admitted merger input path is missing: ${
|
|
10655
|
+
`role run admitted merger input path is missing: ${leg}`
|
|
10601
10656
|
);
|
|
10602
10657
|
}
|
|
10603
10658
|
const derived = fields.derived;
|
|
10604
10659
|
if (derived === void 0) {
|
|
10605
10660
|
throw new CliUsageError(
|
|
10606
|
-
`role run admitted merger envelope is missing: ${
|
|
10661
|
+
`role run admitted merger envelope is missing: ${leg}`
|
|
10607
10662
|
);
|
|
10608
10663
|
}
|
|
10609
10664
|
if (fields.instruction.trim() === "") {
|
|
10610
10665
|
throw new CliUsageError(
|
|
10611
|
-
`role run admitted merger task is blank: ${
|
|
10666
|
+
`role run admitted merger task is blank: ${leg}`
|
|
10612
10667
|
);
|
|
10613
10668
|
}
|
|
10614
10669
|
const admitted = {
|
|
@@ -10624,7 +10679,7 @@ function admitResumedRole(loaded) {
|
|
|
10624
10679
|
const { prNumber, repository, repositoryDisplay } = fields;
|
|
10625
10680
|
if (repository === void 0 || repositoryDisplay === void 0) {
|
|
10626
10681
|
throw new CliUsageError(
|
|
10627
|
-
`role run admitted collector repository identity is missing: ${
|
|
10682
|
+
`role run admitted collector repository identity is missing: ${leg}`
|
|
10628
10683
|
);
|
|
10629
10684
|
}
|
|
10630
10685
|
let parsedRepository;
|
|
@@ -10636,7 +10691,7 @@ function admitResumedRole(loaded) {
|
|
|
10636
10691
|
}
|
|
10637
10692
|
if (parsedRepository.canonical !== repository) {
|
|
10638
10693
|
throw new CliUsageError(
|
|
10639
|
-
`role run admitted collector repository does not match its canonical form: ${
|
|
10694
|
+
`role run admitted collector repository does not match its canonical form: ${leg}`
|
|
10640
10695
|
);
|
|
10641
10696
|
}
|
|
10642
10697
|
const admitted = {
|
|
@@ -10653,7 +10708,7 @@ function admitResumedRole(loaded) {
|
|
|
10653
10708
|
const { issueNumber, caseRunsPath, caseIdentity } = fields;
|
|
10654
10709
|
if (issueNumber === void 0 || caseRunsPath === void 0 || caseIdentity === void 0) {
|
|
10655
10710
|
throw new CliUsageError(
|
|
10656
|
-
`role run admitted doctor case identity is missing: ${
|
|
10711
|
+
`role run admitted doctor case identity is missing: ${leg}`
|
|
10657
10712
|
);
|
|
10658
10713
|
}
|
|
10659
10714
|
const admitted = {
|
|
@@ -10669,7 +10724,7 @@ function admitResumedRole(loaded) {
|
|
|
10669
10724
|
const { sourceRunPath, sourceRun } = fields;
|
|
10670
10725
|
if (sourceRunPath === void 0 || sourceRun === void 0) {
|
|
10671
10726
|
throw new CliUsageError(
|
|
10672
|
-
`role run admitted notary source-run locator is missing: ${
|
|
10727
|
+
`role run admitted notary source-run locator is missing: ${leg}`
|
|
10673
10728
|
);
|
|
10674
10729
|
}
|
|
10675
10730
|
const admitted = {
|
|
@@ -10682,13 +10737,13 @@ function admitResumedRole(loaded) {
|
|
|
10682
10737
|
}
|
|
10683
10738
|
}
|
|
10684
10739
|
}
|
|
10685
|
-
function resumedWorkerPhase(phase, phases, role,
|
|
10740
|
+
function resumedWorkerPhase(phase, phases, role, leg) {
|
|
10686
10741
|
if (phase === "plan" || phase === "apply") {
|
|
10687
10742
|
if (phases.some((item) => item === phase)) {
|
|
10688
10743
|
return phase;
|
|
10689
10744
|
}
|
|
10690
10745
|
}
|
|
10691
|
-
throw new CliUsageError(`role run admitted ${role} phase is missing: ${
|
|
10746
|
+
throw new CliUsageError(`role run admitted ${role} phase is missing: ${leg}`);
|
|
10692
10747
|
}
|
|
10693
10748
|
var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
|
|
10694
10749
|
var init_run_lifecycle = __esm({
|
|
@@ -10727,7 +10782,7 @@ var init_run_lifecycle = __esm({
|
|
|
10727
10782
|
|
|
10728
10783
|
// src/report-ticket-tool.ts
|
|
10729
10784
|
import { Type as Type16 } from "typebox";
|
|
10730
|
-
import { existsSync as
|
|
10785
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
10731
10786
|
function pageString(page, key) {
|
|
10732
10787
|
const value = page?.[key];
|
|
10733
10788
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
@@ -10765,7 +10820,7 @@ async function reportTicketFromHostContext(context, ticketNumber, authority = pi
|
|
|
10765
10820
|
if (runDirectory === void 0) {
|
|
10766
10821
|
throw new Error("ak_report_ticket requires a per-turn run directory");
|
|
10767
10822
|
}
|
|
10768
|
-
if (!
|
|
10823
|
+
if (!existsSync8(runDirectory)) {
|
|
10769
10824
|
throw new Error(`ak_report_ticket run directory missing: ${runDirectory}`);
|
|
10770
10825
|
}
|
|
10771
10826
|
const admitted = admittedForLiveTicketReport(runDirectory, authority);
|
|
@@ -10943,8 +10998,21 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
|
10943
10998
|
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
10944
10999
|
};
|
|
10945
11000
|
}
|
|
10946
|
-
function mapOwnedToSubmissionRows(owned) {
|
|
11001
|
+
function mapOwnedToSubmissionRows(owned, leg = owned) {
|
|
10947
11002
|
const scoped = owned;
|
|
11003
|
+
const receiptByCall = /* @__PURE__ */ new Map();
|
|
11004
|
+
const roundByReceipt = /* @__PURE__ */ new Map();
|
|
11005
|
+
for (const record of leg) {
|
|
11006
|
+
if (record.kind !== PROGRESS_RECORD_KIND) continue;
|
|
11007
|
+
const payload = record.payload;
|
|
11008
|
+
if (typeof payload?.receipt !== "string") continue;
|
|
11009
|
+
if (typeof payload.toolCallId === "string") {
|
|
11010
|
+
receiptByCall.set(submissionCallKey(recordAttemptId(record), payload.toolCallId), payload.receipt);
|
|
11011
|
+
}
|
|
11012
|
+
if (typeof payload.round === "string" && payload.round !== "") {
|
|
11013
|
+
roundByReceipt.set(payload.receipt, payload.round);
|
|
11014
|
+
}
|
|
11015
|
+
}
|
|
10948
11016
|
const out = [];
|
|
10949
11017
|
const indexByCall = /* @__PURE__ */ new Map();
|
|
10950
11018
|
const roleByCall = /* @__PURE__ */ new Map();
|
|
@@ -10995,7 +11063,13 @@ function mapOwnedToSubmissionRows(owned) {
|
|
|
10995
11063
|
if (kind === void 0 || original === void 0 || payload === void 0) continue;
|
|
10996
11064
|
const callKey = typeof payload.toolCallId === "string" ? submissionCallKey(recordAttemptId(record), payload.toolCallId) : void 0;
|
|
10997
11065
|
const fallback = callKey === void 0 ? void 0 : roleByCall.get(callKey);
|
|
10998
|
-
|
|
11066
|
+
const receipt = kind === "accepted" && callKey !== void 0 ? receiptByCall.get(callKey) : void 0;
|
|
11067
|
+
const round = receipt === void 0 ? void 0 : roundByReceipt.get(receipt);
|
|
11068
|
+
take({
|
|
11069
|
+
...rowFromPayload(kind, payload, original, fallback),
|
|
11070
|
+
...receipt === void 0 ? {} : { receipt },
|
|
11071
|
+
...round === void 0 ? {} : { round }
|
|
11072
|
+
}, callKey);
|
|
10999
11073
|
}
|
|
11000
11074
|
return out;
|
|
11001
11075
|
}
|
|
@@ -11008,7 +11082,7 @@ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScop
|
|
|
11008
11082
|
if (attemptId.length === 0) return [];
|
|
11009
11083
|
const scope = resolveReadScope(homeOrScope);
|
|
11010
11084
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
11011
|
-
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
11085
|
+
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId), owned);
|
|
11012
11086
|
}
|
|
11013
11087
|
async function readSubmissionAttemptId(cwd, runId, toolCallId, homeOrScope) {
|
|
11014
11088
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
|
|
@@ -11084,7 +11158,8 @@ function sealAcceptedSubmission(options) {
|
|
|
11084
11158
|
accepted: options.accepted,
|
|
11085
11159
|
sealHead,
|
|
11086
11160
|
sessionFile: void 0,
|
|
11087
|
-
instruction: options.instruction ?? ""
|
|
11161
|
+
instruction: options.instruction ?? "",
|
|
11162
|
+
call: { attemptId, toolCallId: options.toolCallId }
|
|
11088
11163
|
});
|
|
11089
11164
|
}
|
|
11090
11165
|
function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (error) => {
|
|
@@ -11206,7 +11281,8 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
11206
11281
|
role,
|
|
11207
11282
|
accepted: params,
|
|
11208
11283
|
sealHead,
|
|
11209
|
-
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
|
|
11284
|
+
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {},
|
|
11285
|
+
call: { attemptId, toolCallId }
|
|
11210
11286
|
});
|
|
11211
11287
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
11212
11288
|
if (context.host !== "claude" && context.host !== "codex" && runDirectory !== void 0 && isUnboundRunDirectory(runDirectory)) {
|
|
@@ -11239,6 +11315,7 @@ var init_submission_ledger = __esm({
|
|
|
11239
11315
|
init_host_contracts();
|
|
11240
11316
|
init_run_terminal_artifacts();
|
|
11241
11317
|
init_sitian_facade();
|
|
11318
|
+
init_run_dossier_files();
|
|
11242
11319
|
init_run_lifecycle();
|
|
11243
11320
|
init_submission_correctable_error();
|
|
11244
11321
|
init_report_ticket_tool();
|
|
@@ -11430,7 +11507,7 @@ var init_engine_detour_usage = __esm({
|
|
|
11430
11507
|
});
|
|
11431
11508
|
|
|
11432
11509
|
// src/dossier-resolution.ts
|
|
11433
|
-
import { existsSync as
|
|
11510
|
+
import { existsSync as existsSync9, statSync as statSync5 } from "node:fs";
|
|
11434
11511
|
import { resolve as resolve10 } from "node:path";
|
|
11435
11512
|
function isHostContext(value) {
|
|
11436
11513
|
return "sessionManager" in value;
|
|
@@ -11450,7 +11527,7 @@ function resolveAuditDossier(source) {
|
|
|
11450
11527
|
}
|
|
11451
11528
|
const runDirectory = resolve10(raw);
|
|
11452
11529
|
try {
|
|
11453
|
-
if (!
|
|
11530
|
+
if (!existsSync9(runDirectory) || !statSync5(runDirectory).isDirectory()) {
|
|
11454
11531
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
11455
11532
|
}
|
|
11456
11533
|
} catch {
|
|
@@ -11507,6 +11584,7 @@ __export(settlement_exports, {
|
|
|
11507
11584
|
exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
|
|
11508
11585
|
explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
|
|
11509
11586
|
extractNavigatorFact: () => extractNavigatorFact,
|
|
11587
|
+
filedIdentity: () => filedIdentity,
|
|
11510
11588
|
formatCliDiagnostic: () => formatCliDiagnostic,
|
|
11511
11589
|
formatErrorCauseDetail: () => formatErrorCauseDetail,
|
|
11512
11590
|
formatFailureStderrDiagnostic: () => formatFailureStderrDiagnostic,
|
|
@@ -11528,6 +11606,7 @@ __export(settlement_exports, {
|
|
|
11528
11606
|
trySettlePublicSeat: () => trySettlePublicSeat,
|
|
11529
11607
|
withSubmissions: () => withSubmissions
|
|
11530
11608
|
});
|
|
11609
|
+
import { basename as basename10, join as join18 } from "node:path";
|
|
11531
11610
|
function sealedLedgerHome(admitted) {
|
|
11532
11611
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
11533
11612
|
}
|
|
@@ -11586,6 +11665,17 @@ function ledgerReadScope(admitted, scope) {
|
|
|
11586
11665
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
11587
11666
|
};
|
|
11588
11667
|
}
|
|
11668
|
+
function filedIdentity(runDirectory, filed = []) {
|
|
11669
|
+
const subjectDirectory = subjectDirectoryOfRun(runDirectory);
|
|
11670
|
+
if (subjectDirectory === void 0) return {};
|
|
11671
|
+
const ticket = parseTicketNumber(basename10(subjectDirectory));
|
|
11672
|
+
return {
|
|
11673
|
+
...ticket === void 0 ? {} : { ticket },
|
|
11674
|
+
...filed.length === 0 ? {} : {
|
|
11675
|
+
receipts: filed.map((row) => ({ ...row, receipt: join18(subjectDirectory, row.receipt) }))
|
|
11676
|
+
}
|
|
11677
|
+
};
|
|
11678
|
+
}
|
|
11589
11679
|
function roleOutcomeFromRows(role, rows) {
|
|
11590
11680
|
const mine = rows.filter((row) => row.role === role);
|
|
11591
11681
|
const terminal = mine.filter(
|
|
@@ -11595,7 +11685,11 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
11595
11685
|
const payloads = mine.map((row) => row.accepted);
|
|
11596
11686
|
const latest = terminal[terminal.length - 1];
|
|
11597
11687
|
const submissionToolCallId = typeof latest.toolCallId === "string" && latest.toolCallId.length > 0 ? latest.toolCallId : void 0;
|
|
11598
|
-
const
|
|
11688
|
+
const filed = mine.flatMap((row) => row.receipt === void 0 ? [] : [{ receipt: row.receipt, ...row.round === void 0 ? {} : { round: row.round } }]);
|
|
11689
|
+
const belonging = {
|
|
11690
|
+
...submissionToolCallId === void 0 ? {} : { submissionToolCallId },
|
|
11691
|
+
filed
|
|
11692
|
+
};
|
|
11599
11693
|
if (latest.kind === "audit-escalation") {
|
|
11600
11694
|
return {
|
|
11601
11695
|
outcome: {
|
|
@@ -11762,7 +11856,7 @@ async function settleNoReceiptTerminal(admitted, authority, scope, facts) {
|
|
|
11762
11856
|
scope
|
|
11763
11857
|
),
|
|
11764
11858
|
artifacts: [],
|
|
11765
|
-
|
|
11859
|
+
...filedIdentity(admitted.runDirectory)
|
|
11766
11860
|
}, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
|
|
11767
11861
|
}
|
|
11768
11862
|
function coordinatesFromAdmitted(authority, admitted) {
|
|
@@ -12236,16 +12330,17 @@ async function settleSealedSeat(admitted, authority, scope, options) {
|
|
|
12236
12330
|
entriesOf(read),
|
|
12237
12331
|
settled.outcome,
|
|
12238
12332
|
scope,
|
|
12239
|
-
settled.submissionToolCallId
|
|
12333
|
+
settled.submissionToolCallId,
|
|
12334
|
+
settled.filed
|
|
12240
12335
|
);
|
|
12241
12336
|
}
|
|
12242
|
-
async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId) {
|
|
12337
|
+
async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId, filed) {
|
|
12243
12338
|
const artifacts = scope?.previewOnly === true ? [] : await publishDeclaredSeatTerminal(admitted, roleOutcome, coordinates, entries, scope);
|
|
12244
12339
|
const terminal = await attachEngineDetourToolUsage({
|
|
12245
12340
|
roleOutcome,
|
|
12246
12341
|
navigator: isNavigatorSeat(admitted.role) ? NAVIGATOR_SEAT_OWN_FACT : extractNavigatorFact(entries),
|
|
12247
12342
|
artifacts,
|
|
12248
|
-
|
|
12343
|
+
...filedIdentity(admitted.runDirectory, filed),
|
|
12249
12344
|
...submissionToolCallId === void 0 || submissionToolCallId.length === 0 ? {} : { submissionToolCallId }
|
|
12250
12345
|
}, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
|
|
12251
12346
|
return attachRecordedSubmissions(admitted, terminal, scope);
|
|
@@ -12411,7 +12506,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
12411
12506
|
decisiveFacts
|
|
12412
12507
|
};
|
|
12413
12508
|
return attachEngineDetourToolUsage(
|
|
12414
|
-
{ roleOutcome, navigator, artifacts,
|
|
12509
|
+
{ roleOutcome, navigator, artifacts, ...filedIdentity(admitted.runDirectory) },
|
|
12415
12510
|
sessionDirectory,
|
|
12416
12511
|
detourUsageContext(admitted, options)
|
|
12417
12512
|
);
|
|
@@ -12478,6 +12573,7 @@ var init_settlement = __esm({
|
|
|
12478
12573
|
"src/public-cli/settlement.ts"() {
|
|
12479
12574
|
"use strict";
|
|
12480
12575
|
init_role_run_placement();
|
|
12576
|
+
init_run_ticket_number();
|
|
12481
12577
|
init_sitian_facade();
|
|
12482
12578
|
init_run_terminal_artifacts();
|
|
12483
12579
|
init_submission_ledger();
|
|
@@ -12513,12 +12609,12 @@ var init_settlement = __esm({
|
|
|
12513
12609
|
});
|
|
12514
12610
|
|
|
12515
12611
|
// src/external-host-turn-loop.ts
|
|
12516
|
-
import { existsSync as
|
|
12517
|
-
import { basename as
|
|
12612
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
12613
|
+
import { basename as basename11 } from "node:path";
|
|
12518
12614
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
12519
12615
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
12520
12616
|
if (live === void 0) {
|
|
12521
|
-
const parsed = parseRunLeaf(
|
|
12617
|
+
const parsed = parseRunLeaf(basename11(request.runDirectory));
|
|
12522
12618
|
throw new Error(
|
|
12523
12619
|
`admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
|
|
12524
12620
|
);
|
|
@@ -12537,7 +12633,7 @@ async function trySyncTurnRequestLivePlacement(request, authority) {
|
|
|
12537
12633
|
}
|
|
12538
12634
|
async function retainPackageFaultBesideLivePlacement(request, input) {
|
|
12539
12635
|
let runDirectory = request.runDirectory;
|
|
12540
|
-
if (!
|
|
12636
|
+
if (!existsSync10(runDirectory)) {
|
|
12541
12637
|
try {
|
|
12542
12638
|
const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
12543
12639
|
if (found === void 0) {
|
|
@@ -12722,7 +12818,7 @@ var init_external_host_turn_loop = __esm({
|
|
|
12722
12818
|
});
|
|
12723
12819
|
|
|
12724
12820
|
// src/session-identity.ts
|
|
12725
|
-
import { join as
|
|
12821
|
+
import { join as join19 } from "node:path";
|
|
12726
12822
|
function createSessionIdentityAuthority(authority, hostName) {
|
|
12727
12823
|
const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
|
|
12728
12824
|
return {
|
|
@@ -12732,7 +12828,7 @@ function createSessionIdentityAuthority(authority, hostName) {
|
|
|
12732
12828
|
},
|
|
12733
12829
|
async load(principal) {
|
|
12734
12830
|
const runDirectory = runDirectoryOf(principal);
|
|
12735
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
12831
|
+
const { records, diagnostics } = await readSitianRecords(join19(runDirectory, RUN_STATE_FILE));
|
|
12736
12832
|
if (diagnostics.length > 0) {
|
|
12737
12833
|
throw new Error(
|
|
12738
12834
|
`${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
|
|
@@ -12802,14 +12898,14 @@ __export(role_turn_host_exports, {
|
|
|
12802
12898
|
});
|
|
12803
12899
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
12804
12900
|
import { constants } from "node:fs";
|
|
12805
|
-
import { existsSync as
|
|
12901
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
12806
12902
|
import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
|
|
12807
|
-
import { delimiter, dirname as dirname13, isAbsolute as isAbsolute7, join as
|
|
12903
|
+
import { delimiter, dirname as dirname13, isAbsolute as isAbsolute7, join as join20, resolve as resolve11 } from "node:path";
|
|
12808
12904
|
import { platform } from "node:process";
|
|
12809
12905
|
import { promisify as promisify2 } from "node:util";
|
|
12810
12906
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
12811
12907
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
12812
|
-
return
|
|
12908
|
+
return join20(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
12813
12909
|
}
|
|
12814
12910
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
12815
12911
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -12999,7 +13095,7 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
12999
13095
|
homeFromRunDirectory(spawnDir)
|
|
13000
13096
|
);
|
|
13001
13097
|
} catch (resolveError) {
|
|
13002
|
-
runDirectory =
|
|
13098
|
+
runDirectory = existsSync11(spawnDir) ? spawnDir : void 0;
|
|
13003
13099
|
const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
|
|
13004
13100
|
if (runDirectory !== void 0) {
|
|
13005
13101
|
await retainPackageFault({
|
|
@@ -13289,15 +13385,15 @@ var init_navigator_lookup_host = __esm({
|
|
|
13289
13385
|
|
|
13290
13386
|
// src/public-cli/host-providers.ts
|
|
13291
13387
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
13292
|
-
import { join as
|
|
13388
|
+
import { join as join21 } from "node:path";
|
|
13293
13389
|
function hostProvidersPath(home) {
|
|
13294
13390
|
if (typeof home !== "string" || home.trim() === "") {
|
|
13295
13391
|
throw new Error("home must be explicitly provided");
|
|
13296
13392
|
}
|
|
13297
|
-
return
|
|
13393
|
+
return join21(home, ".ak-roles", "host-providers.json");
|
|
13298
13394
|
}
|
|
13299
13395
|
function hermesProviderModelsCachePath(home) {
|
|
13300
|
-
return
|
|
13396
|
+
return join21(home, ".hermes", "provider_models_cache.json");
|
|
13301
13397
|
}
|
|
13302
13398
|
function parseHostProvidersTable(value) {
|
|
13303
13399
|
if (!isRecord(value)) {
|
|
@@ -13447,17 +13543,17 @@ var init_host_providers = __esm({
|
|
|
13447
13543
|
});
|
|
13448
13544
|
|
|
13449
13545
|
// src/public-cli/load-production-acp-host.ts
|
|
13450
|
-
import { existsSync as
|
|
13451
|
-
import { join as
|
|
13546
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
13547
|
+
import { join as join22 } from "node:path";
|
|
13452
13548
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
13453
13549
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
13454
13550
|
const description = lookupHostDescription(host);
|
|
13455
13551
|
if (description === void 0) {
|
|
13456
13552
|
throw new Error(`unregistered host: ${host}`);
|
|
13457
13553
|
}
|
|
13458
|
-
const built =
|
|
13459
|
-
const source =
|
|
13460
|
-
const target =
|
|
13554
|
+
const built = join22(packageRoot, "dist/acp-host/production-host.js");
|
|
13555
|
+
const source = join22(packageRoot, "src/acp-host/production-host.ts");
|
|
13556
|
+
const target = existsSync12(built) ? built : source;
|
|
13461
13557
|
const href = pathToFileURL2(target).href;
|
|
13462
13558
|
const mod = await import(href);
|
|
13463
13559
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -13471,17 +13567,17 @@ var init_load_production_acp_host = __esm({
|
|
|
13471
13567
|
});
|
|
13472
13568
|
|
|
13473
13569
|
// src/public-cli/load-production-headless-host.ts
|
|
13474
|
-
import { existsSync as
|
|
13475
|
-
import { join as
|
|
13570
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
13571
|
+
import { join as join23 } from "node:path";
|
|
13476
13572
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
13477
13573
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
13478
13574
|
const description = lookupHeadlessHostDescription(host);
|
|
13479
13575
|
if (description === void 0) {
|
|
13480
13576
|
throw new Error(`unregistered headless host: ${host}`);
|
|
13481
13577
|
}
|
|
13482
|
-
const built =
|
|
13483
|
-
const source =
|
|
13484
|
-
const target =
|
|
13578
|
+
const built = join23(packageRoot, "dist/headless-host/production-host.js");
|
|
13579
|
+
const source = join23(packageRoot, "src/headless-host/production-host.ts");
|
|
13580
|
+
const target = existsSync13(built) ? built : source;
|
|
13485
13581
|
const href = pathToFileURL3(target).href;
|
|
13486
13582
|
const mod = await import(href);
|
|
13487
13583
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -13940,7 +14036,7 @@ async function requireSubmissionGate(options) {
|
|
|
13940
14036
|
officer: projected.officer,
|
|
13941
14037
|
receipt: gatekeeper.submission ?? { reason: gatekeeper.reason },
|
|
13942
14038
|
reason: gatekeeper.reason,
|
|
13943
|
-
runId: projected.summoned
|
|
14039
|
+
runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
|
|
13944
14040
|
runDirectory: projected.summoned?.runDirectory,
|
|
13945
14041
|
terminal: projected.summoned?.terminal
|
|
13946
14042
|
});
|
|
@@ -13960,7 +14056,7 @@ async function requireSubmissionGate(options) {
|
|
|
13960
14056
|
officer: projected.officer,
|
|
13961
14057
|
receipt: gatekeeper.facts ?? { reason: gatekeeper.reason },
|
|
13962
14058
|
reason: gatekeeper.reason,
|
|
13963
|
-
runId: projected.summoned
|
|
14059
|
+
runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
|
|
13964
14060
|
runDirectory: projected.summoned?.runDirectory,
|
|
13965
14061
|
terminal: projected.summoned?.terminal
|
|
13966
14062
|
});
|
|
@@ -13992,7 +14088,7 @@ __export(auditor_soul_exports, {
|
|
|
13992
14088
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
13993
14089
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
13994
14090
|
});
|
|
13995
|
-
import { basename as
|
|
14091
|
+
import { basename as basename12 } from "node:path";
|
|
13996
14092
|
function auditorSoulRelativePath(role) {
|
|
13997
14093
|
return `souls/${role}-auditor.md`;
|
|
13998
14094
|
}
|
|
@@ -14028,7 +14124,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
14028
14124
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
14029
14125
|
}
|
|
14030
14126
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
14031
|
-
const role = parseRunLeaf(
|
|
14127
|
+
const role = parseRunLeaf(basename12(sourceRunDirectory))?.role;
|
|
14032
14128
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
14033
14129
|
}
|
|
14034
14130
|
async function readAuditorResumeBinding(admitted) {
|
|
@@ -14070,20 +14166,20 @@ var init_auditor_soul = __esm({
|
|
|
14070
14166
|
});
|
|
14071
14167
|
|
|
14072
14168
|
// src/public-cli/machine-method-skills.ts
|
|
14073
|
-
import { accessSync, constants as constants2, statSync as
|
|
14169
|
+
import { accessSync, constants as constants2, statSync as statSync6 } from "node:fs";
|
|
14074
14170
|
import { lstat as lstat3, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
14075
|
-
import { join as
|
|
14171
|
+
import { join as join25 } from "node:path";
|
|
14076
14172
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
14077
14173
|
function skillRoot(home) {
|
|
14078
|
-
return
|
|
14174
|
+
return join25(home, ".agents/skills");
|
|
14079
14175
|
}
|
|
14080
14176
|
function installedMethodSkillPath(home, name) {
|
|
14081
14177
|
return installedSkillPath(skillRoot(home), name);
|
|
14082
14178
|
}
|
|
14083
14179
|
function installedSkillPath(root, name) {
|
|
14084
|
-
const path =
|
|
14180
|
+
const path = join25(root, name, "SKILL.md");
|
|
14085
14181
|
try {
|
|
14086
|
-
if (!
|
|
14182
|
+
if (!statSync6(path).isFile()) return void 0;
|
|
14087
14183
|
accessSync(path, constants2.R_OK);
|
|
14088
14184
|
return path;
|
|
14089
14185
|
} catch (error) {
|
|
@@ -14094,9 +14190,9 @@ function installedSkillPath(root, name) {
|
|
|
14094
14190
|
}
|
|
14095
14191
|
function linkedSkillRoot(home, host) {
|
|
14096
14192
|
if (host === "claude" || host === "claude-code") {
|
|
14097
|
-
return
|
|
14193
|
+
return join25(process.env.CLAUDE_CONFIG_DIR?.trim() || join25(home, ".claude"), "skills");
|
|
14098
14194
|
}
|
|
14099
|
-
if (host === "hermes") return
|
|
14195
|
+
if (host === "hermes") return join25(home, ".hermes/skills");
|
|
14100
14196
|
return void 0;
|
|
14101
14197
|
}
|
|
14102
14198
|
async function occupied(path) {
|
|
@@ -14153,7 +14249,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
14153
14249
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
14154
14250
|
let unsourced = false;
|
|
14155
14251
|
for (const name of packagedMethodSkillNames()) {
|
|
14156
|
-
const path =
|
|
14252
|
+
const path = join25(canonical, name);
|
|
14157
14253
|
if (await occupied(path)) {
|
|
14158
14254
|
warnOccupied(path, stdout);
|
|
14159
14255
|
continue;
|
|
@@ -14183,9 +14279,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
14183
14279
|
throw error;
|
|
14184
14280
|
}
|
|
14185
14281
|
for (const name of packagedMethodSkillNames()) {
|
|
14186
|
-
const target =
|
|
14282
|
+
const target = join25(canonical, name);
|
|
14187
14283
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
14188
|
-
const link =
|
|
14284
|
+
const link = join25(root, name);
|
|
14189
14285
|
if (await occupied(link)) {
|
|
14190
14286
|
warnOccupied(link, stdout);
|
|
14191
14287
|
continue;
|
|
@@ -14444,7 +14540,7 @@ function dispatchExceptionFailureTerminal(input) {
|
|
|
14444
14540
|
},
|
|
14445
14541
|
navigator: { disposition: "no-advice" },
|
|
14446
14542
|
artifacts,
|
|
14447
|
-
|
|
14543
|
+
...filedIdentity(input.runDirectory),
|
|
14448
14544
|
autoResumeCount: input.autoResumeAttempts
|
|
14449
14545
|
};
|
|
14450
14546
|
}
|
|
@@ -14542,7 +14638,7 @@ async function runWithAutoResumeLoop(options) {
|
|
|
14542
14638
|
options.admitted,
|
|
14543
14639
|
dispatchExceptionFailureTerminal({
|
|
14544
14640
|
role: options.admitted.role,
|
|
14545
|
-
|
|
14641
|
+
runDirectory: options.admitted.runDirectory,
|
|
14546
14642
|
causeError: lastThrownError,
|
|
14547
14643
|
errorFiles: retainedErrorFiles,
|
|
14548
14644
|
autoResumeAttempts,
|
|
@@ -15856,12 +15952,12 @@ var init_post_admission = __esm({
|
|
|
15856
15952
|
});
|
|
15857
15953
|
|
|
15858
15954
|
// src/public-cli/seat-ticket-binding.ts
|
|
15859
|
-
import { join as
|
|
15955
|
+
import { join as join26 } from "node:path";
|
|
15860
15956
|
function resumedSessionIdMissing(result, runId) {
|
|
15861
15957
|
if (typeof result !== "object" || result === null) return false;
|
|
15862
15958
|
const terminal = result.terminal;
|
|
15863
15959
|
if (typeof terminal !== "object" || terminal === null) return false;
|
|
15864
|
-
if (
|
|
15960
|
+
if (result.admitted?.runId !== runId) return false;
|
|
15865
15961
|
const outcome = terminal.roleOutcome;
|
|
15866
15962
|
if (typeof outcome !== "object" || outcome === null) return false;
|
|
15867
15963
|
if (outcome.kind !== "failure") return false;
|
|
@@ -15870,7 +15966,7 @@ function resumedSessionIdMissing(result, runId) {
|
|
|
15870
15966
|
return facts.errorCode === SESSION_ID_MISSING;
|
|
15871
15967
|
}
|
|
15872
15968
|
async function writerLockBlocksFreshSummons(runDirectory) {
|
|
15873
|
-
const autopsy = await autopsyWriterLock(
|
|
15969
|
+
const autopsy = await autopsyWriterLock(join26(runDirectory, WRITER_LOCK_FILE));
|
|
15874
15970
|
return autopsy.verdict === "alive" || autopsy.verdict === "unknown";
|
|
15875
15971
|
}
|
|
15876
15972
|
async function tryResumeSameTicketSeatRun(input) {
|
|
@@ -17250,7 +17346,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
17250
17346
|
const pass = chain.passes.at(-1);
|
|
17251
17347
|
const officerTerminal = pass?.terminal;
|
|
17252
17348
|
const officerRunDirectory = pass?.runDirectory;
|
|
17253
|
-
const officerRunId = pass?.runId
|
|
17349
|
+
const officerRunId = pass?.runId;
|
|
17254
17350
|
if (officerTerminal !== void 0 && officerRunId !== void 0) {
|
|
17255
17351
|
await presentAuditedOriginalVolume(turn, io);
|
|
17256
17352
|
const officer = await loadResumablePublicRole(
|
|
@@ -17289,7 +17385,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
17289
17385
|
if (chain.status === "escalate") {
|
|
17290
17386
|
const escalation = chain.passes.at(-1);
|
|
17291
17387
|
const escalatedRunDirectory = escalation?.runDirectory;
|
|
17292
|
-
const escalatedRunId = escalation?.runId
|
|
17388
|
+
const escalatedRunId = escalation?.runId;
|
|
17293
17389
|
if (escalatedRunId === void 0) {
|
|
17294
17390
|
return incompleteAuditWithoutOfficerVolume(
|
|
17295
17391
|
turn,
|
|
@@ -17463,13 +17559,13 @@ var init_dialogue_command = __esm({
|
|
|
17463
17559
|
});
|
|
17464
17560
|
|
|
17465
17561
|
// src/analyst-book-key.ts
|
|
17466
|
-
import { statSync as
|
|
17562
|
+
import { statSync as statSync7 } from "node:fs";
|
|
17467
17563
|
import { isAbsolute as isAbsolute8 } from "node:path";
|
|
17468
17564
|
function resolveAnalystBookKey(projectRoot) {
|
|
17469
17565
|
const identity = physicalPathIdentity(projectRoot);
|
|
17470
17566
|
let stats;
|
|
17471
17567
|
try {
|
|
17472
|
-
stats =
|
|
17568
|
+
stats = statSync7(identity);
|
|
17473
17569
|
} catch (error) {
|
|
17474
17570
|
const code = errnoCode(error);
|
|
17475
17571
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -17499,10 +17595,10 @@ var init_analyst_book_key = __esm({
|
|
|
17499
17595
|
// src/atomic-write.ts
|
|
17500
17596
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
17501
17597
|
import { rename as rename2, rm, writeFile as writeFile4 } from "node:fs/promises";
|
|
17502
|
-
import { dirname as dirname15, join as
|
|
17598
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
17503
17599
|
async function writeFileAtomically(destination, contents, options) {
|
|
17504
17600
|
const parent = dirname15(destination);
|
|
17505
|
-
const temporary =
|
|
17601
|
+
const temporary = join27(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
17506
17602
|
try {
|
|
17507
17603
|
await writeFile4(temporary, contents, options);
|
|
17508
17604
|
await rename2(temporary, destination);
|
|
@@ -17519,12 +17615,12 @@ var init_atomic_write = __esm({
|
|
|
17519
17615
|
|
|
17520
17616
|
// src/analyst-index.ts
|
|
17521
17617
|
import { open as open2, readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
|
|
17522
|
-
import { dirname as dirname16, join as
|
|
17618
|
+
import { dirname as dirname16, join as join28 } from "node:path";
|
|
17523
17619
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
17524
17620
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
17525
17621
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
17526
17622
|
ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
|
|
17527
|
-
const lockPath =
|
|
17623
|
+
const lockPath = join28(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
17528
17624
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
17529
17625
|
const startedAt = Date.now();
|
|
17530
17626
|
while (true) {
|
|
@@ -17551,7 +17647,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
17551
17647
|
}
|
|
17552
17648
|
}
|
|
17553
17649
|
function analystLibraryIndexPath(ledgerHome) {
|
|
17554
|
-
return
|
|
17650
|
+
return join28(ledgerHome, "analyst", "library-index.json");
|
|
17555
17651
|
}
|
|
17556
17652
|
function rowFromIssueMetricsPage(page) {
|
|
17557
17653
|
return {
|
|
@@ -17845,7 +17941,7 @@ var init_analyst_cohort = __esm({
|
|
|
17845
17941
|
});
|
|
17846
17942
|
|
|
17847
17943
|
// src/archivist-record-pointer.ts
|
|
17848
|
-
import { basename as
|
|
17944
|
+
import { basename as basename13, join as join29 } from "node:path";
|
|
17849
17945
|
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
17850
17946
|
const where = `${parentRunDirectory} officers`;
|
|
17851
17947
|
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
@@ -17858,7 +17954,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
17858
17954
|
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
17859
17955
|
let sessionFile = raw.sessionFile;
|
|
17860
17956
|
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
17861
|
-
const leaf = parseRunLeaf(
|
|
17957
|
+
const leaf = parseRunLeaf(basename13(recordedRunDirectory));
|
|
17862
17958
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
17863
17959
|
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
17864
17960
|
const currentRunDirectory = await resolveLiveRunDirectoryPath(
|
|
@@ -17878,7 +17974,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
17878
17974
|
};
|
|
17879
17975
|
}
|
|
17880
17976
|
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
17881
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
17977
|
+
const { records, diagnostics } = await readSitianRecords(join29(parentRunDirectory, RUN_HISTORY_FILE));
|
|
17882
17978
|
if (diagnostics.length > 0) {
|
|
17883
17979
|
throw new Error(
|
|
17884
17980
|
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
@@ -18161,7 +18257,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
18161
18257
|
|
|
18162
18258
|
// src/analyst-ledger.ts
|
|
18163
18259
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
18164
|
-
import { basename as
|
|
18260
|
+
import { basename as basename14, join as join30 } from "node:path";
|
|
18165
18261
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
18166
18262
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
18167
18263
|
}
|
|
@@ -18181,7 +18277,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
18181
18277
|
}
|
|
18182
18278
|
}
|
|
18183
18279
|
async function classifyGhostCandidate(input) {
|
|
18184
|
-
const autopsy = await autopsyWriterLock(
|
|
18280
|
+
const autopsy = await autopsyWriterLock(join30(input.runDirectory, "writer.lock"));
|
|
18185
18281
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
18186
18282
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
18187
18283
|
return {
|
|
@@ -18471,7 +18567,7 @@ async function classifyScopedRun(input) {
|
|
|
18471
18567
|
async function scanAnalystIssueRuns(input) {
|
|
18472
18568
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
18473
18569
|
const scopeTicketNumber = input.ticketNumber;
|
|
18474
|
-
const booksRoot =
|
|
18570
|
+
const booksRoot = join30(ledgerHome, "books");
|
|
18475
18571
|
let wholeBook = false;
|
|
18476
18572
|
let scopeRootIdentity;
|
|
18477
18573
|
let bookNames;
|
|
@@ -18504,7 +18600,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
18504
18600
|
const ghostLegs = [];
|
|
18505
18601
|
const scopeConflicts = [];
|
|
18506
18602
|
for (const book of bookNames) {
|
|
18507
|
-
const bookDir =
|
|
18603
|
+
const bookDir = join30(booksRoot, book);
|
|
18508
18604
|
let runDirectories;
|
|
18509
18605
|
try {
|
|
18510
18606
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -18513,7 +18609,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
18513
18609
|
throw error;
|
|
18514
18610
|
}
|
|
18515
18611
|
for (const runDirectory of runDirectories) {
|
|
18516
|
-
const runName =
|
|
18612
|
+
const runName = basename14(runDirectory);
|
|
18517
18613
|
const parsed = parseRunLeaf(runName);
|
|
18518
18614
|
if (parsed === void 0) continue;
|
|
18519
18615
|
let scopeFields;
|
|
@@ -19250,7 +19346,7 @@ var init_analyst_metric_family = __esm({
|
|
|
19250
19346
|
});
|
|
19251
19347
|
|
|
19252
19348
|
// src/analyst-page.ts
|
|
19253
|
-
import { dirname as dirname17, join as
|
|
19349
|
+
import { dirname as dirname17, join as join31 } from "node:path";
|
|
19254
19350
|
function analystIssuePageKey(address) {
|
|
19255
19351
|
const parts = ["book", address.bookKey];
|
|
19256
19352
|
if (address.issueNumber !== void 0) {
|
|
@@ -19261,7 +19357,7 @@ function analystIssuePageKey(address) {
|
|
|
19261
19357
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
19262
19358
|
}
|
|
19263
19359
|
function analystIssuePagePath(ledgerHome, address) {
|
|
19264
|
-
return
|
|
19360
|
+
return join31(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
19265
19361
|
}
|
|
19266
19362
|
function analystIssuePageAddressFromPage(page) {
|
|
19267
19363
|
return {
|
|
@@ -20107,18 +20203,22 @@ function parseArgv(argv) {
|
|
|
20107
20203
|
help
|
|
20108
20204
|
};
|
|
20109
20205
|
}
|
|
20110
|
-
function
|
|
20111
|
-
const
|
|
20112
|
-
|
|
20113
|
-
|
|
20114
|
-
}
|
|
20115
|
-
if (args.length > 2) {
|
|
20206
|
+
function parseResumeAddress(args) {
|
|
20207
|
+
const [ticketToken, seatToken, ...rest] = args;
|
|
20208
|
+
const ticketNumber = ticketToken === void 0 ? void 0 : parseAddressTicket(ticketToken);
|
|
20209
|
+
if (ticketNumber === void 0 || seatToken === void 0 || rest.length > 1) {
|
|
20116
20210
|
throw new CliUsageError(RESUME_USAGE_ERROR);
|
|
20117
20211
|
}
|
|
20118
|
-
|
|
20119
|
-
|
|
20212
|
+
const { seat, round } = parseSeatRound(seatToken);
|
|
20213
|
+
if (!isPublicCallableRole(seat) || round === "") {
|
|
20214
|
+
throw new CliUsageError(`${RESUME_USAGE_ERROR}; not a callable seat: ${seatToken}`);
|
|
20120
20215
|
}
|
|
20121
|
-
return {
|
|
20216
|
+
return {
|
|
20217
|
+
ticketNumber,
|
|
20218
|
+
seat,
|
|
20219
|
+
...round === void 0 ? {} : { round },
|
|
20220
|
+
...rest.length === 0 ? {} : { message: rest[0] }
|
|
20221
|
+
};
|
|
20122
20222
|
}
|
|
20123
20223
|
function invocationFromParsed(parsed) {
|
|
20124
20224
|
if (parsed.model === void 0 && parsed.thinking === void 0 && parsed.engine === void 0 && parsed.host === void 0) {
|
|
@@ -20227,7 +20327,7 @@ function renderHelp() {
|
|
|
20227
20327
|
"Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
|
|
20228
20328
|
"Model resolution: --model \u2192 persistent seat \u2192 officer inherit (#620); still none \u2192 error (#178)",
|
|
20229
20329
|
"Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
|
|
20230
|
-
"Resume
|
|
20330
|
+
"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)",
|
|
20231
20331
|
"Effective seats: ak-role roles"
|
|
20232
20332
|
);
|
|
20233
20333
|
return `${lines.join("\n")}
|
|
@@ -20619,28 +20719,34 @@ async function runAkRole(argv, env) {
|
|
|
20619
20719
|
env = { ...env, freshSummons: true };
|
|
20620
20720
|
}
|
|
20621
20721
|
if (parsed.command === "resume") {
|
|
20622
|
-
|
|
20722
|
+
const address = parseResumeAddress(parsed.args);
|
|
20723
|
+
const runDirectory = locateTicketLeg(
|
|
20724
|
+
activationBookDirectory(
|
|
20725
|
+
resolveActivationLedgerHome(home),
|
|
20726
|
+
resolveBookKeyFromGit(env.cwd ?? process.cwd())
|
|
20727
|
+
),
|
|
20728
|
+
address
|
|
20729
|
+
);
|
|
20730
|
+
const resumeRequest = {
|
|
20731
|
+
runId: runIdFromRunDirectory(runDirectory),
|
|
20732
|
+
runDirectory,
|
|
20733
|
+
...address.message === void 0 ? {} : { message: address.message }
|
|
20734
|
+
};
|
|
20623
20735
|
resumeFailureContext = {
|
|
20624
20736
|
home,
|
|
20625
20737
|
runId: resumeRequest.runId,
|
|
20738
|
+
runDirectory,
|
|
20626
20739
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
20627
20740
|
};
|
|
20628
|
-
const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
|
|
20629
|
-
if (runDirectory !== void 0) {
|
|
20630
|
-
resumeRequest = { ...resumeRequest, runDirectory };
|
|
20631
|
-
resumeFailureContext = { ...resumeFailureContext, runDirectory };
|
|
20632
|
-
}
|
|
20633
20741
|
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
20634
|
-
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
|
|
20635
|
-
const seatRole = resumeRole ?? "judge";
|
|
20636
20742
|
const seat = resolveEffectiveSeat(
|
|
20637
20743
|
parts.config,
|
|
20638
|
-
|
|
20744
|
+
address.seat,
|
|
20639
20745
|
parts.credentials,
|
|
20640
20746
|
invocationFromParsed(parsed)
|
|
20641
20747
|
);
|
|
20642
20748
|
const resumeEnv = createRoleEnvironment(env, {
|
|
20643
|
-
role:
|
|
20749
|
+
role: address.seat,
|
|
20644
20750
|
home,
|
|
20645
20751
|
agentDir: parts.agentDir,
|
|
20646
20752
|
cwd: parts.cwd,
|
|
@@ -20774,6 +20880,10 @@ var init_cli = __esm({
|
|
|
20774
20880
|
init_instruction_seat_run();
|
|
20775
20881
|
init_countersign_run();
|
|
20776
20882
|
init_analyst_run();
|
|
20883
|
+
init_activation_ledger_git();
|
|
20884
|
+
init_activation_ledger_topology();
|
|
20885
|
+
init_run_terminal_artifacts();
|
|
20886
|
+
init_ticket_address();
|
|
20777
20887
|
init_run_lifecycle();
|
|
20778
20888
|
init_registry();
|
|
20779
20889
|
init_settlement();
|
|
@@ -20787,7 +20897,7 @@ var init_cli = __esm({
|
|
|
20787
20897
|
])
|
|
20788
20898
|
);
|
|
20789
20899
|
PUBLIC_GLOBAL_OPTIONS = optionsForOwner("global");
|
|
20790
|
-
RESUME_USAGE_ERROR = "usage: ak-role resume <
|
|
20900
|
+
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)";
|
|
20791
20901
|
}
|
|
20792
20902
|
});
|
|
20793
20903
|
|
|
@@ -20801,9 +20911,9 @@ __export(public_role_summons_exports, {
|
|
|
20801
20911
|
summonPublicRole: () => summonPublicRole
|
|
20802
20912
|
});
|
|
20803
20913
|
import { execFile as execFile3 } from "node:child_process";
|
|
20804
|
-
import { existsSync as
|
|
20914
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
20805
20915
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
20806
|
-
import { join as
|
|
20916
|
+
import { join as join32 } from "node:path";
|
|
20807
20917
|
import { promisify as promisify3 } from "node:util";
|
|
20808
20918
|
function createCapturingIo() {
|
|
20809
20919
|
const chunks = [];
|
|
@@ -20827,7 +20937,7 @@ function parentDir(path) {
|
|
|
20827
20937
|
function walkPackageRoot(start) {
|
|
20828
20938
|
let dir = start;
|
|
20829
20939
|
for (let i = 0; i < 12; i += 1) {
|
|
20830
|
-
if (
|
|
20940
|
+
if (existsSync14(join32(dir, "package.json")) && existsSync14(join32(dir, "souls"))) {
|
|
20831
20941
|
return dir;
|
|
20832
20942
|
}
|
|
20833
20943
|
const parent = parentDir(dir);
|
|
@@ -21062,13 +21172,7 @@ async function summonPublicRole(options) {
|
|
|
21062
21172
|
result = stepped.ok;
|
|
21063
21173
|
}
|
|
21064
21174
|
const stderr = captured?.stderrText();
|
|
21065
|
-
|
|
21066
|
-
if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
|
|
21067
|
-
runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
21068
|
-
home,
|
|
21069
|
-
result.terminal.runId
|
|
21070
|
-
) ?? runDirectory;
|
|
21071
|
-
}
|
|
21175
|
+
const runDirectory = result.admitted?.runDirectory;
|
|
21072
21176
|
return {
|
|
21073
21177
|
exitCode: result.exitCode,
|
|
21074
21178
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -21435,7 +21539,7 @@ init_submission_ledger();
|
|
|
21435
21539
|
init_filed_submission();
|
|
21436
21540
|
init_report_ticket_tool();
|
|
21437
21541
|
import { writeSync as writeSync2 } from "node:fs";
|
|
21438
|
-
import { join as
|
|
21542
|
+
import { join as join33 } from "node:path";
|
|
21439
21543
|
import { Value as Value2 } from "typebox/value";
|
|
21440
21544
|
|
|
21441
21545
|
// src/activation-trace.ts
|
|
@@ -21484,7 +21588,7 @@ init_activation_ledger_topology();
|
|
|
21484
21588
|
import {
|
|
21485
21589
|
lstatSync as lstatSync2,
|
|
21486
21590
|
realpathSync as realpathSync2,
|
|
21487
|
-
statSync as
|
|
21591
|
+
statSync as statSync8,
|
|
21488
21592
|
writeFileSync as writeFileSync3
|
|
21489
21593
|
} from "node:fs";
|
|
21490
21594
|
import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
|
|
@@ -21559,7 +21663,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
21559
21663
|
}
|
|
21560
21664
|
let info;
|
|
21561
21665
|
try {
|
|
21562
|
-
info =
|
|
21666
|
+
info = statSync8(realFile);
|
|
21563
21667
|
} catch (error) {
|
|
21564
21668
|
throw new Error(
|
|
21565
21669
|
`Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
|
|
@@ -21953,10 +22057,10 @@ init_run_ticket_number();
|
|
|
21953
22057
|
|
|
21954
22058
|
// src/audited-run-identity.ts
|
|
21955
22059
|
init_role_run_placement();
|
|
21956
|
-
import { basename as
|
|
22060
|
+
import { basename as basename15 } from "node:path";
|
|
21957
22061
|
var AUDITED_RUN_IDENTITY_KIND = "audited-run";
|
|
21958
22062
|
function auditedRunIdentityFromDirectory(runDirectory) {
|
|
21959
|
-
const parsed = parseRunLeaf(
|
|
22063
|
+
const parsed = parseRunLeaf(basename15(runDirectory));
|
|
21960
22064
|
if (parsed === void 0) return void 0;
|
|
21961
22065
|
return formatRunLeaf(parsed.runId, parsed.role);
|
|
21962
22066
|
}
|
|
@@ -22181,7 +22285,7 @@ init_unknown_value();
|
|
|
22181
22285
|
init_submission_errors();
|
|
22182
22286
|
init_worker_submission_contracts();
|
|
22183
22287
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
22184
|
-
import { existsSync as
|
|
22288
|
+
import { existsSync as existsSync15, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync4 } from "node:fs";
|
|
22185
22289
|
import { resolve as resolve15 } from "node:path";
|
|
22186
22290
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
22187
22291
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -22211,7 +22315,7 @@ function statusOf(error) {
|
|
|
22211
22315
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
22212
22316
|
}
|
|
22213
22317
|
function tryGetAll(file, key) {
|
|
22214
|
-
if (!
|
|
22318
|
+
if (!existsSync15(file)) return [];
|
|
22215
22319
|
try {
|
|
22216
22320
|
const out = gitFile(file, ["--get-all", key]);
|
|
22217
22321
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -22221,7 +22325,7 @@ function tryGetAll(file, key) {
|
|
|
22221
22325
|
}
|
|
22222
22326
|
}
|
|
22223
22327
|
function ownedHook(path) {
|
|
22224
|
-
if (!
|
|
22328
|
+
if (!existsSync15(path)) return false;
|
|
22225
22329
|
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
22226
22330
|
}
|
|
22227
22331
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -22248,12 +22352,12 @@ function rmOwnedDir(dir) {
|
|
|
22248
22352
|
const hookPath = resolve15(dir, HOOK_FILE);
|
|
22249
22353
|
if (!ownedHook(hookPath)) return;
|
|
22250
22354
|
rmSync4(hookPath, { force: true });
|
|
22251
|
-
if (
|
|
22355
|
+
if (existsSync15(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
22252
22356
|
}
|
|
22253
22357
|
function linkedGitDirs(commonDir) {
|
|
22254
22358
|
const root = resolve15(commonDir, "worktrees");
|
|
22255
|
-
if (!
|
|
22256
|
-
return
|
|
22359
|
+
if (!existsSync15(root)) return [];
|
|
22360
|
+
return readdirSync4(root).map((name) => resolve15(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
22257
22361
|
}
|
|
22258
22362
|
function uninstallPackageWorkerHooks(cwd) {
|
|
22259
22363
|
let inside;
|
|
@@ -23044,7 +23148,7 @@ function readRoleRunCoordinates(ctx, label) {
|
|
|
23044
23148
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23045
23149
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
23046
23150
|
if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23047
|
-
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${
|
|
23151
|
+
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join33(runDirectory, RUN_STATE_FILE)})`);
|
|
23048
23152
|
}
|
|
23049
23153
|
return {
|
|
23050
23154
|
runDirectory,
|
|
@@ -24433,10 +24537,10 @@ init_run_lifecycle();
|
|
|
24433
24537
|
init_settlement();
|
|
24434
24538
|
import { spawn as spawn3, spawnSync as spawnSync4 } from "node:child_process";
|
|
24435
24539
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
24436
|
-
import { existsSync as
|
|
24540
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
24437
24541
|
import { mkdtemp, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
|
|
24438
24542
|
import { tmpdir } from "node:os";
|
|
24439
|
-
import { dirname as dirname19, isAbsolute as isAbsolute11, join as
|
|
24543
|
+
import { dirname as dirname19, isAbsolute as isAbsolute11, join as join34, resolve as resolve16 } from "node:path";
|
|
24440
24544
|
|
|
24441
24545
|
// src/agent-start-materials.ts
|
|
24442
24546
|
function renderAgentStartMaterials(body, materials) {
|
|
@@ -24822,7 +24926,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
24822
24926
|
function cwdIsGitWorkTree(cwd) {
|
|
24823
24927
|
let dir = cwd;
|
|
24824
24928
|
for (; ; ) {
|
|
24825
|
-
if (
|
|
24929
|
+
if (existsSync16(join34(dir, ".git"))) return true;
|
|
24826
24930
|
const parent = dirname19(dir);
|
|
24827
24931
|
if (parent === dir) return false;
|
|
24828
24932
|
dir = parent;
|
|
@@ -25039,8 +25143,8 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25039
25143
|
}
|
|
25040
25144
|
const env = { ...process.env, ...config.env ?? {} };
|
|
25041
25145
|
const liveSessionParent = () => config.sessionIdentity.resolveSessionFile(request.principal);
|
|
25042
|
-
const inputsDirectory = await mkdtemp(
|
|
25043
|
-
const systemPromptPath =
|
|
25146
|
+
const inputsDirectory = await mkdtemp(join34(tmpdir(), "ak-role-headless-"));
|
|
25147
|
+
const systemPromptPath = join34(inputsDirectory, "system-prompt.txt");
|
|
25044
25148
|
let mcpConfigPath;
|
|
25045
25149
|
let outputSchemaPath;
|
|
25046
25150
|
let startedWithSchema;
|
|
@@ -25048,12 +25152,12 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25048
25152
|
await writeFile6(systemPromptPath, systemPrompt, "utf8");
|
|
25049
25153
|
let deliveredSchema;
|
|
25050
25154
|
if (codex) {
|
|
25051
|
-
outputSchemaPath =
|
|
25155
|
+
outputSchemaPath = join34(inputsDirectory, "output-schema.json");
|
|
25052
25156
|
deliveredSchema = closeJsonSchemaForCodex(prepared.jsonSchema);
|
|
25053
25157
|
await writeFile6(outputSchemaPath, `${JSON.stringify(deliveredSchema, null, 2)}
|
|
25054
25158
|
`, "utf8");
|
|
25055
25159
|
} else {
|
|
25056
|
-
mcpConfigPath =
|
|
25160
|
+
mcpConfigPath = join34(inputsDirectory, "mcp-config.json");
|
|
25057
25161
|
await writeFile6(
|
|
25058
25162
|
mcpConfigPath,
|
|
25059
25163
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|