@akagilnc/pi-workflow-roles 0.1.6111 → 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 +442 -279
- package/dist/engine-detour-usage.js +2 -1
- package/dist/gatekeeper-role.js +3 -15
- package/dist/headless-host/production-host.js +427 -264
- package/dist/migrate-book-topology.js +42 -22
- package/dist/notary-source-run.js +8 -8
- package/dist/package-contracts/fixer-output.js +3 -0
- 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 +52 -13
- package/dist/public-cli/invocation.js +22 -12
- package/dist/public-cli/main.js +398 -237
- 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 +90 -14
- 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/package-contracts/fixer-output.ts +4 -0
- 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 +55 -11
- package/src/public-cli/invocation.ts +31 -16
- 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 +113 -15
|
@@ -1047,6 +1047,9 @@ var init_fixer_output = __esm({
|
|
|
1047
1047
|
classResults: Type8.Unknown({
|
|
1048
1048
|
description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u6BCF\u7C7B\u5199 name\u3001shape\uFF08\u9519\u8BEF\u5F62\u72B6\u4E00\u53E5\uFF09\u3002\u6309\u4EE3\u7801\u5F62\u72B6\u8BA4\u7684\u7C7B\u5199 search\uFF08\u5B9E\u9645\u8DD1\u7684\u641C\u7D22\u547D\u4EE4\uFF0C\u539F\u6837\uFF09\u3001hits\uFF08\u547D\u4EE4\u8F93\u51FA\u7684\u6BCF\u4E2A\u547D\u4E2D\u4E00\u884C { where: path:line, outcome: \u5DF2\u4FEE | \u4E0D\u540C\u7C7B\uFF1A\u7406\u7531 }\uFF09\uFF1B\u6309\u60C5\u5F62\u8BA4\u7684\u7C7B\u5199 cases\uFF08\u6BCF\u79CD\u524D\u5E8F\u7ECF\u5386\u4E00\u884C { case: \u5BF9\u8C61\u5148\u7ECF\u5386\u4E86\u4EC0\u4E48, entry: \u4ECE\u771F\u5B9E\u5165\u53E3\u600E\u4E48\u8D70\u5230\u5B83, before: \u4FEE\u524D\u7ED3\u679C, after: \u4FEE\u540E\u7ED3\u679C }\uFF09\u3002\u5220\u5E76\u7C7B\u5199 files\uFF08\u672C\u7968\u8D77\u70B9\u5230 HEAD \u7684 git diff --name-status \u91CC\u6BCF\u4E2A\u6587\u4EF6\u4E00\u884C { file, hits: \u8BE5\u7C7B\u5728\u6B64\u6587\u4EF6\u7684\u547D\u4E2D path:line \u5217\u8868\uFF0C\u6CA1\u6709\u4E3A\u7A7A, outcome: \u5DF2\u4FEE | \u65E0\uFF1A\u6BD4\u5BF9\u4E86\u54EA\u51E0\u5904\u3001\u4E3A\u4EC0\u4E48\u4E0D\u7B97 | \u672A\u4FEE\uFF1A\u7406\u7531 }\uFF09\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 remainingScope\u3001blocker\u3002"
|
|
1049
1049
|
}),
|
|
1050
|
+
for: Type8.Unknown({
|
|
1051
|
+
description: "\u4FEE\u7684\u662F\u54EA\u4EFD\u5224\u8BCD\uFF1A<\u5E2D>#<\u8F6E>\uFF0C\u5982 judge#5\uFF0C\u539F\u6837\u843D\u5230\u8FDB\u5EA6\u884C\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002"
|
|
1052
|
+
}),
|
|
1050
1053
|
diffItems: diffItemsField,
|
|
1051
1054
|
testEvidence: Type8.Unknown({
|
|
1052
1055
|
description: "\u4EC5 diff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u586B\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
|
|
@@ -1452,7 +1455,7 @@ async function findRoleRunDirectory(bookDirectories, runId, onlyRole) {
|
|
|
1452
1455
|
}
|
|
1453
1456
|
if (matches.length === 0) return void 0;
|
|
1454
1457
|
if (matches.length === 1) return matches[0];
|
|
1455
|
-
throw new Error(`ambiguous role run
|
|
1458
|
+
throw new Error(`ambiguous role run: ${matches.join(", ")}`);
|
|
1456
1459
|
}
|
|
1457
1460
|
function roleRunPlacement(ledgerHome, input) {
|
|
1458
1461
|
const subjectDirectory = "ticketNumber" in input.subject ? String(requireSafePositiveTicketNumber(
|
|
@@ -1623,7 +1626,7 @@ var init_role_run_path_rewrite = __esm({
|
|
|
1623
1626
|
});
|
|
1624
1627
|
|
|
1625
1628
|
// src/run-dossier-files.ts
|
|
1626
|
-
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;
|
|
1627
1630
|
var init_run_dossier_files = __esm({
|
|
1628
1631
|
"src/run-dossier-files.ts"() {
|
|
1629
1632
|
"use strict";
|
|
@@ -1639,8 +1642,10 @@ var init_run_dossier_files = __esm({
|
|
|
1639
1642
|
"post-seal-anomaly",
|
|
1640
1643
|
"attempt-history",
|
|
1641
1644
|
"turn-delivery",
|
|
1642
|
-
"officer-pointer"
|
|
1645
|
+
"officer-pointer",
|
|
1646
|
+
"progress"
|
|
1643
1647
|
]);
|
|
1648
|
+
PROGRESS_RECORD_KIND = "progress";
|
|
1644
1649
|
OFFICER_POINTER_RECORD_KIND = "officer-pointer";
|
|
1645
1650
|
RUN_STATE_KINDS = /* @__PURE__ */ new Set([
|
|
1646
1651
|
"invocation",
|
|
@@ -4862,6 +4867,13 @@ function currentReplyRows(terminal) {
|
|
|
4862
4867
|
function adviceNavigatorFact(input) {
|
|
4863
4868
|
return { disposition: "advice", prose: input.prose };
|
|
4864
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
|
+
}
|
|
4865
4877
|
function formatTerminalResult(result) {
|
|
4866
4878
|
const lines = [];
|
|
4867
4879
|
lines.push("role outcome status");
|
|
@@ -4907,11 +4919,11 @@ function formatTerminalResult(result) {
|
|
|
4907
4919
|
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
4908
4920
|
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
4909
4921
|
}
|
|
4922
|
+
const lens = result.reviewerChildren?.[axis];
|
|
4923
|
+
if (lens !== void 0) lines.push(...identityRows(lens));
|
|
4910
4924
|
}
|
|
4911
4925
|
}
|
|
4912
|
-
|
|
4913
|
-
lines.push(`run ${encodeTerminalField(result.runId)}`);
|
|
4914
|
-
}
|
|
4926
|
+
lines.push(...identityRows(result));
|
|
4915
4927
|
if (result.autoResumeCount !== void 0) {
|
|
4916
4928
|
lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
4917
4929
|
}
|
|
@@ -4972,15 +4984,7 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
|
|
|
4972
4984
|
return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
|
|
4973
4985
|
}
|
|
4974
4986
|
function officerRunIdFromSummoned(summoned) {
|
|
4975
|
-
|
|
4976
|
-
const fromDir = runIdFromRunDirectory(summoned.runDirectory);
|
|
4977
|
-
if (fromDir !== void 0) return fromDir;
|
|
4978
|
-
}
|
|
4979
|
-
const terminal = summoned.terminal;
|
|
4980
|
-
if (terminal !== void 0 && typeof terminal.runId === "string" && terminal.runId.trim() !== "") {
|
|
4981
|
-
return terminal.runId;
|
|
4982
|
-
}
|
|
4983
|
-
return void 0;
|
|
4987
|
+
return summoned.runDirectory === void 0 ? void 0 : runIdFromRunDirectory(summoned.runDirectory);
|
|
4984
4988
|
}
|
|
4985
4989
|
function withOfficerRunId(result, summoned) {
|
|
4986
4990
|
if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask") {
|
|
@@ -6297,15 +6301,11 @@ import {
|
|
|
6297
6301
|
writeFileSync as writeFileSync2
|
|
6298
6302
|
} from "node:fs";
|
|
6299
6303
|
import { basename as basename7, dirname as dirname10, join as join12, relative as relative3, sep as sep4 } from "node:path";
|
|
6300
|
-
function
|
|
6301
|
-
if (
|
|
6304
|
+
function decodeProgressFile(path) {
|
|
6305
|
+
if (!existsSync4(path)) return { lines: [], malformed: [] };
|
|
6306
|
+
const text = readFileSync3(path, "utf8");
|
|
6307
|
+
if (text.trim() === "") return { lines: [], malformed: [] };
|
|
6302
6308
|
const { records, diagnostics } = parseSitianRecordText(text);
|
|
6303
|
-
for (const diagnostic of diagnostics) {
|
|
6304
|
-
process.stderr.write(
|
|
6305
|
-
`[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
|
|
6306
|
-
`
|
|
6307
|
-
);
|
|
6308
|
-
}
|
|
6309
6309
|
const lines = [];
|
|
6310
6310
|
for (const record of records) {
|
|
6311
6311
|
const parsed = record;
|
|
@@ -6313,11 +6313,20 @@ function parseProgressText(text, pathForDiagnostic) {
|
|
|
6313
6313
|
if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
|
|
6314
6314
|
lines.push(parsed);
|
|
6315
6315
|
}
|
|
6316
|
-
return
|
|
6316
|
+
return {
|
|
6317
|
+
lines,
|
|
6318
|
+
malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`)
|
|
6319
|
+
};
|
|
6317
6320
|
}
|
|
6318
6321
|
function readProgressFile(path) {
|
|
6319
|
-
|
|
6320
|
-
|
|
6322
|
+
const { lines, malformed } = decodeProgressFile(path);
|
|
6323
|
+
for (const diagnostic of malformed) {
|
|
6324
|
+
process.stderr.write(
|
|
6325
|
+
`[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}
|
|
6326
|
+
`
|
|
6327
|
+
);
|
|
6328
|
+
}
|
|
6329
|
+
return lines;
|
|
6321
6330
|
}
|
|
6322
6331
|
function readTicketProgressLines(subjectDirectory) {
|
|
6323
6332
|
if (basename7(subjectDirectory) === "unbound") {
|
|
@@ -6373,6 +6382,26 @@ function statusAndSummaryFromPayload(payload) {
|
|
|
6373
6382
|
...summary === void 0 ? {} : { summary }
|
|
6374
6383
|
};
|
|
6375
6384
|
}
|
|
6385
|
+
function readAuditedRound(auditedRunDirectory) {
|
|
6386
|
+
try {
|
|
6387
|
+
const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
|
|
6388
|
+
if (subjectDirectory === void 0) return {};
|
|
6389
|
+
const path = join12(subjectDirectory, CURRENT_FILENAME);
|
|
6390
|
+
const { lines, malformed } = decodeProgressFile(path);
|
|
6391
|
+
if (malformed.length > 0) {
|
|
6392
|
+
throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
|
|
6393
|
+
}
|
|
6394
|
+
const receipts = `runs/${basename7(auditedRunDirectory)}/`;
|
|
6395
|
+
const latest = lines.filter((line2) => line2.receipt.startsWith(receipts)).at(-1);
|
|
6396
|
+
return latest === void 0 ? {} : { for: `${latest.seat}#${latest.round}` };
|
|
6397
|
+
} catch (error) {
|
|
6398
|
+
return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
function forOfSealedRow(runDirectory, seat, payload) {
|
|
6402
|
+
const reported = packagedGateStageLabel(seat) !== void 0 ? readPageSync(runDirectory, "admitted")?.for : seat === "fixer" && isRecord(payload) ? payload.for : void 0;
|
|
6403
|
+
return typeof reported === "string" ? reported : void 0;
|
|
6404
|
+
}
|
|
6376
6405
|
function captureWorktreeHead(projectRoot) {
|
|
6377
6406
|
try {
|
|
6378
6407
|
const result = spawnSync2("git", ["rev-parse", "HEAD"], {
|
|
@@ -6400,6 +6429,23 @@ function captureWorktreeHead(projectRoot) {
|
|
|
6400
6429
|
return { head: "", fault: `git rev-parse HEAD threw cwd=${projectRoot}: ${message}` };
|
|
6401
6430
|
}
|
|
6402
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
|
+
}
|
|
6403
6449
|
function progressSessionAbsolute(runDirectory, context) {
|
|
6404
6450
|
const host = typeof context.host === "string" ? context.host.trim() : "";
|
|
6405
6451
|
const sessionDirectory = sessionDirectoryOf(runDirectory);
|
|
@@ -6425,6 +6471,7 @@ function landTicketProgressForSealedSubmission(input) {
|
|
|
6425
6471
|
role: input.role,
|
|
6426
6472
|
accepted: input.accepted,
|
|
6427
6473
|
sealHead: input.sealHead,
|
|
6474
|
+
call: input.call,
|
|
6428
6475
|
...input.lens === void 0 ? {} : { lens: input.lens },
|
|
6429
6476
|
sessionFile: progressSessionAbsolute(runDirectory, input.context),
|
|
6430
6477
|
instruction: typeof input.context.summonsInstruction === "string" ? input.context.summonsInstruction : ""
|
|
@@ -6451,11 +6498,13 @@ function landTicketProgress(input) {
|
|
|
6451
6498
|
const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
|
|
6452
6499
|
const sessionRelative = input.sessionFile === void 0 ? "" : relative3(subjectDirectory, input.sessionFile).split(sep4).join("/");
|
|
6453
6500
|
const { status, summary } = statusAndSummaryFromPayload(input.accepted);
|
|
6501
|
+
const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
|
|
6454
6502
|
const instruction = input.instruction;
|
|
6455
6503
|
const line2 = {
|
|
6456
6504
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6457
6505
|
seat: input.role,
|
|
6458
6506
|
round,
|
|
6507
|
+
...reviewed === void 0 ? {} : { for: reviewed },
|
|
6459
6508
|
instruction,
|
|
6460
6509
|
head: input.sealHead.head,
|
|
6461
6510
|
...status === void 0 ? {} : { status },
|
|
@@ -6466,6 +6515,7 @@ function landTicketProgress(input) {
|
|
|
6466
6515
|
mkdirSync3(dirname10(progressPath), { recursive: true });
|
|
6467
6516
|
appendFileSync2(progressPath, `${JSON.stringify(line2)}
|
|
6468
6517
|
`, "utf8");
|
|
6518
|
+
carryProgressRow(runDirectory, line2, input.call);
|
|
6469
6519
|
if (input.sealHead.fault !== void 0) {
|
|
6470
6520
|
process.stderr.write(`${input.sealHead.fault}
|
|
6471
6521
|
`);
|
|
@@ -6513,6 +6563,7 @@ function relocateTicketProgressForLeg(input) {
|
|
|
6513
6563
|
"utf8"
|
|
6514
6564
|
);
|
|
6515
6565
|
rmSync3(stagedPath, { force: true });
|
|
6566
|
+
for (const moved of movedLines) carryProgressRow(input.runDirectory, moved);
|
|
6516
6567
|
}
|
|
6517
6568
|
var CURRENT_FILENAME, RECEIPTS_DIRNAME, LEG_PROGRESS_FILENAME;
|
|
6518
6569
|
var init_ticket_progress = __esm({
|
|
@@ -6523,6 +6574,9 @@ var init_ticket_progress = __esm({
|
|
|
6523
6574
|
init_packaged_role_registry();
|
|
6524
6575
|
init_role_run_placement();
|
|
6525
6576
|
init_run_dossier();
|
|
6577
|
+
init_run_dossier_files();
|
|
6578
|
+
init_run_terminal_artifacts();
|
|
6579
|
+
init_sitian_facade();
|
|
6526
6580
|
init_sitian_reader();
|
|
6527
6581
|
init_unknown_value();
|
|
6528
6582
|
CURRENT_FILENAME = "current.jsonl";
|
|
@@ -7031,8 +7085,66 @@ var init_ticket_provenance = __esm({
|
|
|
7031
7085
|
}
|
|
7032
7086
|
});
|
|
7033
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
|
+
|
|
7034
7146
|
// src/notary-source-run.ts
|
|
7035
|
-
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";
|
|
7036
7148
|
import { lstat, realpath as realpath2 } from "node:fs/promises";
|
|
7037
7149
|
async function readRetainedIdentity(runDirectory) {
|
|
7038
7150
|
try {
|
|
@@ -7084,11 +7196,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
7084
7196
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
7085
7197
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
7086
7198
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
7087
|
-
const bookRunsRoot =
|
|
7199
|
+
const bookRunsRoot = join15(bookDirectory, "runs");
|
|
7088
7200
|
let candidate;
|
|
7089
|
-
const
|
|
7090
|
-
if (
|
|
7091
|
-
candidate =
|
|
7201
|
+
const address = parseTicketLegLocator(raw);
|
|
7202
|
+
if (address !== void 0) {
|
|
7203
|
+
candidate = locateTicketLeg(bookDirectory, address);
|
|
7092
7204
|
} else {
|
|
7093
7205
|
candidate = isAbsolute4(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
7094
7206
|
const identity2 = parseRunLeaf(basename8(candidate));
|
|
@@ -7168,6 +7280,7 @@ var init_notary_source_run = __esm({
|
|
|
7168
7280
|
init_activation_ledger_topology();
|
|
7169
7281
|
init_run_lifecycle();
|
|
7170
7282
|
init_role_run_placement();
|
|
7283
|
+
init_ticket_address();
|
|
7171
7284
|
NotarySourceRunError = class extends Error {
|
|
7172
7285
|
constructor(message, options) {
|
|
7173
7286
|
super(message, options);
|
|
@@ -7637,7 +7750,7 @@ var init_option_definitions = __esm({
|
|
|
7637
7750
|
owner: "auditor",
|
|
7638
7751
|
canonical: "--source-run",
|
|
7639
7752
|
aliases: [],
|
|
7640
|
-
valueMetavar: "
|
|
7753
|
+
valueMetavar: "ticket:seat#round|path",
|
|
7641
7754
|
required: true,
|
|
7642
7755
|
repeatable: false,
|
|
7643
7756
|
form: "option",
|
|
@@ -7815,13 +7928,13 @@ var init_option_definitions = __esm({
|
|
|
7815
7928
|
owner: "notary",
|
|
7816
7929
|
canonical: "--source-run",
|
|
7817
7930
|
aliases: [],
|
|
7818
|
-
valueMetavar: "
|
|
7931
|
+
valueMetavar: "ticket:seat#round|path",
|
|
7819
7932
|
required: true,
|
|
7820
7933
|
repeatable: false,
|
|
7821
7934
|
form: "option",
|
|
7822
7935
|
description: {
|
|
7823
|
-
en: "Required source run locator (
|
|
7824
|
-
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"
|
|
7825
7938
|
}
|
|
7826
7939
|
}
|
|
7827
7940
|
];
|
|
@@ -7832,13 +7945,13 @@ var init_option_definitions = __esm({
|
|
|
7832
7945
|
owner: "inspector",
|
|
7833
7946
|
canonical: "--source-run",
|
|
7834
7947
|
aliases: [],
|
|
7835
|
-
valueMetavar: "
|
|
7948
|
+
valueMetavar: "ticket:seat#round|path",
|
|
7836
7949
|
required: false,
|
|
7837
7950
|
repeatable: false,
|
|
7838
7951
|
form: "option",
|
|
7839
7952
|
description: {
|
|
7840
|
-
en: "Optional audited source-run locator (
|
|
7841
|
-
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"
|
|
7842
7955
|
}
|
|
7843
7956
|
}
|
|
7844
7957
|
];
|
|
@@ -8133,10 +8246,10 @@ var init_option_definitions = __esm({
|
|
|
8133
8246
|
auditor: {
|
|
8134
8247
|
command: "auditor",
|
|
8135
8248
|
summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: converged, continue, or escalate.",
|
|
8136
|
-
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]"],
|
|
8137
8250
|
examples: [
|
|
8138
|
-
'ak-role auditor --subject judge --source-run
|
|
8139
|
-
'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"'
|
|
8140
8253
|
]
|
|
8141
8254
|
},
|
|
8142
8255
|
diarist: {
|
|
@@ -8159,10 +8272,10 @@ var init_option_definitions = __esm({
|
|
|
8159
8272
|
notary: {
|
|
8160
8273
|
command: "notary",
|
|
8161
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.",
|
|
8162
|
-
usage: ["ak-role notary --source-run <
|
|
8275
|
+
usage: ["ak-role notary --source-run <ticket:seat#round|path> [options]"],
|
|
8163
8276
|
examples: [
|
|
8164
|
-
"ak-role notary --source-run
|
|
8165
|
-
"ak-role notary --source-run
|
|
8277
|
+
"ak-role notary --source-run 1201:judge#2",
|
|
8278
|
+
"ak-role notary --source-run 1201:countersign#1"
|
|
8166
8279
|
]
|
|
8167
8280
|
},
|
|
8168
8281
|
analyst: {
|
|
@@ -8219,14 +8332,15 @@ var init_option_definitions = __esm({
|
|
|
8219
8332
|
},
|
|
8220
8333
|
resume: {
|
|
8221
8334
|
command: "resume",
|
|
8222
|
-
summary: "Resume a
|
|
8223
|
-
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]"],
|
|
8224
8337
|
examples: [
|
|
8225
|
-
"ak-role resume
|
|
8226
|
-
'ak-role resume
|
|
8227
|
-
"ak-role
|
|
8228
|
-
"ak-role --
|
|
8229
|
-
|
|
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"'
|
|
8230
8344
|
]
|
|
8231
8345
|
},
|
|
8232
8346
|
new: {
|
|
@@ -8235,7 +8349,7 @@ var init_option_definitions = __esm({
|
|
|
8235
8349
|
usage: ["ak-role new <role> [options] \u2026"],
|
|
8236
8350
|
examples: [
|
|
8237
8351
|
'ak-role new countersign --attach ./ticket.md "\u88C1\uFF1A\u672C\u7968 #708 \u662F\u5426\u8DB3\u4EE5\u5F00\u5DE5\u3002"',
|
|
8238
|
-
"ak-role new notary --source-run
|
|
8352
|
+
"ak-role new notary --source-run 1201:countersign#1",
|
|
8239
8353
|
"ak-role --host grok-build new inspector --attach ./change.patch"
|
|
8240
8354
|
]
|
|
8241
8355
|
},
|
|
@@ -8258,14 +8372,14 @@ var init_option_definitions = __esm({
|
|
|
8258
8372
|
|
|
8259
8373
|
// src/public-cli/invocation.ts
|
|
8260
8374
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
8261
|
-
import { existsSync as
|
|
8375
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
8262
8376
|
import {
|
|
8263
8377
|
readFile as readFile9,
|
|
8264
8378
|
realpath as realpath3,
|
|
8265
8379
|
rename,
|
|
8266
8380
|
writeFile as writeFile2
|
|
8267
8381
|
} from "node:fs/promises";
|
|
8268
|
-
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";
|
|
8269
8383
|
function admittedSourceRunPath(admitted) {
|
|
8270
8384
|
if (!isRecord(admitted)) return void 0;
|
|
8271
8385
|
const path = admitted.sourceRunPath;
|
|
@@ -8363,22 +8477,25 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
|
8363
8477
|
...fields
|
|
8364
8478
|
}));
|
|
8365
8479
|
}
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8480
|
+
function persistAdmittedAuditedLeg(runDirectory, audited) {
|
|
8481
|
+
const { sourceRunPath, auditorSubject } = audited;
|
|
8482
|
+
if (sourceRunPath !== void 0 && sourceRunPath.trim() === "") {
|
|
8483
|
+
throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
|
|
8369
8484
|
}
|
|
8370
|
-
updateSectionSync(
|
|
8371
|
-
if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
8485
|
+
updateSectionSync(runDirectory, "admitted", (current) => {
|
|
8486
|
+
if (sourceRunPath !== void 0 && typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
8372
8487
|
throw new Error(
|
|
8373
|
-
`
|
|
8488
|
+
`persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
8374
8489
|
);
|
|
8375
8490
|
}
|
|
8376
|
-
const
|
|
8377
|
-
if (
|
|
8491
|
+
const unchanged = current.for === audited.for && (sourceRunPath === void 0 || current.sourceRunPath === sourceRunPath) && (auditorSubject === void 0 || current.auditorSubject === auditorSubject);
|
|
8492
|
+
if (unchanged) return void 0;
|
|
8493
|
+
const { for: _replaced, ...rest } = current;
|
|
8378
8494
|
return {
|
|
8379
|
-
...
|
|
8380
|
-
sourceRunPath,
|
|
8381
|
-
...auditorSubject === void 0 ? {} : { auditorSubject }
|
|
8495
|
+
...rest,
|
|
8496
|
+
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
8497
|
+
...auditorSubject === void 0 ? {} : { auditorSubject },
|
|
8498
|
+
...audited.for === void 0 ? {} : { for: audited.for }
|
|
8382
8499
|
};
|
|
8383
8500
|
});
|
|
8384
8501
|
}
|
|
@@ -8440,7 +8557,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
8440
8557
|
runId: childRunId,
|
|
8441
8558
|
role: "diarist"
|
|
8442
8559
|
}).runDirectory;
|
|
8443
|
-
if (
|
|
8560
|
+
if (existsSync6(unboundChildDirectory)) {
|
|
8444
8561
|
input.authority.seal(childTarget);
|
|
8445
8562
|
await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
|
|
8446
8563
|
await rehomeUnboundTicketProvenance(
|
|
@@ -8464,7 +8581,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
8464
8581
|
}
|
|
8465
8582
|
continue;
|
|
8466
8583
|
}
|
|
8467
|
-
if (
|
|
8584
|
+
if (existsSync6(childTarget.runDirectory)) {
|
|
8468
8585
|
relocateTicketProgressForLeg({
|
|
8469
8586
|
runDirectory: childTarget.runDirectory
|
|
8470
8587
|
});
|
|
@@ -8562,7 +8679,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
8562
8679
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
8563
8680
|
const rolePackageRoot = packageRoot;
|
|
8564
8681
|
const raw = JSON.parse(
|
|
8565
|
-
await readFile9(
|
|
8682
|
+
await readFile9(join16(rolePackageRoot, "package.json"), "utf8")
|
|
8566
8683
|
);
|
|
8567
8684
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
8568
8685
|
throw new Error(
|
|
@@ -9133,7 +9250,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
9133
9250
|
resolutionScope: [...derived.resolutionScope],
|
|
9134
9251
|
authorizedChecks: []
|
|
9135
9252
|
});
|
|
9136
|
-
const mergerInputPath =
|
|
9253
|
+
const mergerInputPath = join16(placed.runDirectory, "merger-input.json");
|
|
9137
9254
|
await writeFile2(
|
|
9138
9255
|
mergerInputPath,
|
|
9139
9256
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -9401,7 +9518,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
9401
9518
|
}
|
|
9402
9519
|
async function resolveDoctorCaseRunsPath(options) {
|
|
9403
9520
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
9404
|
-
const defaultRuns =
|
|
9521
|
+
const defaultRuns = join16(
|
|
9405
9522
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
9406
9523
|
String(options.issueNumber),
|
|
9407
9524
|
"runs"
|
|
@@ -9698,34 +9815,9 @@ var init_invocation = __esm({
|
|
|
9698
9815
|
});
|
|
9699
9816
|
|
|
9700
9817
|
// src/public-cli/run-lifecycle.ts
|
|
9701
|
-
|
|
9702
|
-
__export(run_lifecycle_exports, {
|
|
9703
|
-
AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
|
|
9704
|
-
RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
|
|
9705
|
-
WRITER_LOCK_FILE: () => WRITER_LOCK_FILE,
|
|
9706
|
-
acquireRunWriterLease: () => acquireRunWriterLease,
|
|
9707
|
-
autopsyWriterLock: () => autopsyWriterLock,
|
|
9708
|
-
clearCurrentCourt: () => clearCurrentCourt,
|
|
9709
|
-
describeErrorIdentity: () => describeErrorIdentity,
|
|
9710
|
-
findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
|
|
9711
|
-
findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
|
|
9712
|
-
findRunDirectoryById: () => findRunDirectoryById,
|
|
9713
|
-
loadResumablePublicRole: () => loadResumablePublicRole,
|
|
9714
|
-
markRunAdmitted: () => markRunAdmitted,
|
|
9715
|
-
markRunRunning: () => markRunRunning,
|
|
9716
|
-
markRunTerminal: () => markRunTerminal,
|
|
9717
|
-
peekRoleRunRole: () => peekRoleRunRole,
|
|
9718
|
-
readCurrentCourt: () => readCurrentCourt,
|
|
9719
|
-
readRoleRunIdentity: () => readRoleRunIdentity,
|
|
9720
|
-
readRoleRunState: () => readRoleRunState,
|
|
9721
|
-
readRunParentPath: () => readRunParentPath,
|
|
9722
|
-
recordCurrentCourt: () => recordCurrentCourt,
|
|
9723
|
-
resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
|
|
9724
|
-
writeRoleRunState: () => writeRoleRunState
|
|
9725
|
-
});
|
|
9726
|
-
import { existsSync as existsSync6 } from "node:fs";
|
|
9818
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
9727
9819
|
import { chmod, lstat as lstat2, open, readdir as readdir3, readFile as readFile10, unlink } from "node:fs/promises";
|
|
9728
|
-
import { basename as basename9, join as
|
|
9820
|
+
import { basename as basename9, join as join17 } from "node:path";
|
|
9729
9821
|
async function writeRoleRunState(runDirectory, record) {
|
|
9730
9822
|
const payload = { ...record, runDirectory };
|
|
9731
9823
|
writeSectionSync(runDirectory, "runState", { ...payload });
|
|
@@ -10020,7 +10112,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
10020
10112
|
},
|
|
10021
10113
|
relocate(nextRunDirectory) {
|
|
10022
10114
|
currentRunDirectory = nextRunDirectory;
|
|
10023
|
-
currentLockPath =
|
|
10115
|
+
currentLockPath = join17(nextRunDirectory, WRITER_LOCK_FILE);
|
|
10024
10116
|
},
|
|
10025
10117
|
async release() {
|
|
10026
10118
|
if (released) return;
|
|
@@ -10059,10 +10151,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
10059
10151
|
};
|
|
10060
10152
|
const reportReadFailure = (error) => {
|
|
10061
10153
|
reportDiagnostic(
|
|
10062
|
-
`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)}`
|
|
10063
10155
|
);
|
|
10064
10156
|
};
|
|
10065
|
-
const lockPath =
|
|
10157
|
+
const lockPath = join17(runDirectory, WRITER_LOCK_FILE);
|
|
10066
10158
|
let lastAutopsy = { verdict: "absent" };
|
|
10067
10159
|
let lastReclaimFailure;
|
|
10068
10160
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -10121,14 +10213,14 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
|
|
|
10121
10213
|
const parsed = parseRunLeaf(basename9(knownRunDirectory));
|
|
10122
10214
|
if (parsed === void 0 || parsed.runId !== runId) {
|
|
10123
10215
|
throw new CliUsageError(
|
|
10124
|
-
`run directory
|
|
10216
|
+
`run directory is not the expected role run: ${knownRunDirectory}`
|
|
10125
10217
|
);
|
|
10126
10218
|
}
|
|
10127
10219
|
return knownRunDirectory;
|
|
10128
10220
|
}
|
|
10129
10221
|
if (runId.trim() === "") return void 0;
|
|
10130
10222
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
10131
|
-
const booksRoot =
|
|
10223
|
+
const booksRoot = join17(ledgerHome, "books");
|
|
10132
10224
|
let bookKeys;
|
|
10133
10225
|
try {
|
|
10134
10226
|
bookKeys = await readdir3(booksRoot);
|
|
@@ -10143,7 +10235,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
|
|
|
10143
10235
|
);
|
|
10144
10236
|
}
|
|
10145
10237
|
async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
|
|
10146
|
-
if (
|
|
10238
|
+
if (existsSync7(recordedPath)) return recordedPath;
|
|
10147
10239
|
const parsed = parseRunLeaf(basename9(recordedPath));
|
|
10148
10240
|
const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
|
|
10149
10241
|
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
@@ -10165,10 +10257,6 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
10165
10257
|
throw error;
|
|
10166
10258
|
}
|
|
10167
10259
|
}
|
|
10168
|
-
async function findLatestRunIdForSeatTicket(input) {
|
|
10169
|
-
const found = await findLatestRunForSeatTicket(input);
|
|
10170
|
-
return found?.runId;
|
|
10171
|
-
}
|
|
10172
10260
|
async function findLatestRunForSeatTicket(input) {
|
|
10173
10261
|
if (input.parentRunPath.trim() === "") {
|
|
10174
10262
|
return void 0;
|
|
@@ -10178,7 +10266,7 @@ async function findLatestRunForSeatTicket(input) {
|
|
|
10178
10266
|
let runDirectories;
|
|
10179
10267
|
try {
|
|
10180
10268
|
runDirectories = await listBookRunDirectories(
|
|
10181
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
10269
|
+
input.ticketNumber === void 0 ? bookDir : join17(bookDir, String(input.ticketNumber))
|
|
10182
10270
|
);
|
|
10183
10271
|
} catch (error) {
|
|
10184
10272
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -10213,15 +10301,15 @@ function restoredTicketFields(fields) {
|
|
|
10213
10301
|
async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
|
|
10214
10302
|
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
10215
10303
|
if (runDirectory === void 0) {
|
|
10216
|
-
throw new CliUsageError(`unknown role run
|
|
10304
|
+
throw new CliUsageError(`unknown role run: no run directory found under ${home}`);
|
|
10217
10305
|
}
|
|
10218
10306
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
10219
10307
|
if (disk === void 0) {
|
|
10220
|
-
throw new CliUsageError(`
|
|
10308
|
+
throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
|
|
10221
10309
|
}
|
|
10222
10310
|
const materialized = materializeRoleRunFromDisk(disk, authority);
|
|
10223
10311
|
if (materialized === void 0) {
|
|
10224
|
-
throw new CliUsageError(`
|
|
10312
|
+
throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
|
|
10225
10313
|
}
|
|
10226
10314
|
const { run, principal } = materialized;
|
|
10227
10315
|
let instruction = "";
|
|
@@ -10347,7 +10435,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
|
|
|
10347
10435
|
} catch (error) {
|
|
10348
10436
|
if (error instanceof CliUsageError) throw error;
|
|
10349
10437
|
throw new CliUsageError(
|
|
10350
|
-
`role run admitted request is unreadable: ${
|
|
10438
|
+
`role run admitted request is unreadable: ${run.runDirectory}`,
|
|
10351
10439
|
{ cause: error }
|
|
10352
10440
|
);
|
|
10353
10441
|
}
|
|
@@ -10374,7 +10462,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
|
|
|
10374
10462
|
}
|
|
10375
10463
|
if (!isEnoent(error)) {
|
|
10376
10464
|
throw new CliUsageError(
|
|
10377
|
-
`role run invocation identity is unreadable: ${
|
|
10465
|
+
`role run invocation identity is unreadable: ${run.runDirectory}`,
|
|
10378
10466
|
{ cause: error }
|
|
10379
10467
|
);
|
|
10380
10468
|
}
|
|
@@ -10456,7 +10544,7 @@ async function loadResumablePublicRole(home, runId, authority, options) {
|
|
|
10456
10544
|
}
|
|
10457
10545
|
function admitResumedRole(loaded) {
|
|
10458
10546
|
const role = loaded.run.role;
|
|
10459
|
-
const
|
|
10547
|
+
const leg = loaded.run.runDirectory;
|
|
10460
10548
|
const record = packagedRoleMetadata(role);
|
|
10461
10549
|
if (record === void 0) {
|
|
10462
10550
|
throw new CliUsageError(`unknown role: ${role}`);
|
|
@@ -10487,10 +10575,10 @@ function admitResumedRole(loaded) {
|
|
|
10487
10575
|
return admitted;
|
|
10488
10576
|
}
|
|
10489
10577
|
case "worker-task": {
|
|
10490
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role,
|
|
10578
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
|
|
10491
10579
|
if (fields.instruction.trim() === "") {
|
|
10492
10580
|
throw new CliUsageError(
|
|
10493
|
-
`role run admitted coder task is blank: ${
|
|
10581
|
+
`role run admitted coder task is blank: ${leg}`
|
|
10494
10582
|
);
|
|
10495
10583
|
}
|
|
10496
10584
|
const admitted = {
|
|
@@ -10502,10 +10590,10 @@ function admitResumedRole(loaded) {
|
|
|
10502
10590
|
return admitted;
|
|
10503
10591
|
}
|
|
10504
10592
|
case "worker-packet": {
|
|
10505
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role,
|
|
10593
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
|
|
10506
10594
|
if (fields.instruction.trim() === "") {
|
|
10507
10595
|
throw new CliUsageError(
|
|
10508
|
-
`role run admitted fixer instruction is blank: ${
|
|
10596
|
+
`role run admitted fixer instruction is blank: ${leg}`
|
|
10509
10597
|
);
|
|
10510
10598
|
}
|
|
10511
10599
|
const admitted = {
|
|
@@ -10522,19 +10610,19 @@ function admitResumedRole(loaded) {
|
|
|
10522
10610
|
const baseFault = admittedReviewerBaseFault(rawBase);
|
|
10523
10611
|
if (baseFault !== void 0 || rawBase === void 0) {
|
|
10524
10612
|
throw new CliUsageError(
|
|
10525
|
-
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}`
|
|
10526
10614
|
);
|
|
10527
10615
|
}
|
|
10528
10616
|
const lens = fields.lens;
|
|
10529
10617
|
if (!isReviewerLens(lens)) {
|
|
10530
10618
|
throw new CliUsageError(
|
|
10531
|
-
`role run admitted reviewer lens is missing: ${
|
|
10619
|
+
`role run admitted reviewer lens is missing: ${leg}`
|
|
10532
10620
|
);
|
|
10533
10621
|
}
|
|
10534
10622
|
const authorityRefs = Object.freeze([...fields.authorityRefs ?? []]);
|
|
10535
10623
|
if (authorityRefs.length === 0) {
|
|
10536
10624
|
throw new CliUsageError(
|
|
10537
|
-
`role run admitted reviewer authority refs are missing: ${
|
|
10625
|
+
`role run admitted reviewer authority refs are missing: ${leg}`
|
|
10538
10626
|
);
|
|
10539
10627
|
}
|
|
10540
10628
|
const admitted = {
|
|
@@ -10550,7 +10638,7 @@ function admitResumedRole(loaded) {
|
|
|
10550
10638
|
const baseRevision = fields.baseRevision;
|
|
10551
10639
|
if (baseRevision === void 0 || baseRevision.trim() === "") {
|
|
10552
10640
|
throw new CliUsageError(
|
|
10553
|
-
`role run admitted gleaner-left base revision is missing: ${
|
|
10641
|
+
`role run admitted gleaner-left base revision is missing: ${leg}`
|
|
10554
10642
|
);
|
|
10555
10643
|
}
|
|
10556
10644
|
const admitted = {
|
|
@@ -10564,18 +10652,18 @@ function admitResumedRole(loaded) {
|
|
|
10564
10652
|
const mergerInputPath = fields.mergerInputPath;
|
|
10565
10653
|
if (mergerInputPath === void 0) {
|
|
10566
10654
|
throw new CliUsageError(
|
|
10567
|
-
`role run admitted merger input path is missing: ${
|
|
10655
|
+
`role run admitted merger input path is missing: ${leg}`
|
|
10568
10656
|
);
|
|
10569
10657
|
}
|
|
10570
10658
|
const derived = fields.derived;
|
|
10571
10659
|
if (derived === void 0) {
|
|
10572
10660
|
throw new CliUsageError(
|
|
10573
|
-
`role run admitted merger envelope is missing: ${
|
|
10661
|
+
`role run admitted merger envelope is missing: ${leg}`
|
|
10574
10662
|
);
|
|
10575
10663
|
}
|
|
10576
10664
|
if (fields.instruction.trim() === "") {
|
|
10577
10665
|
throw new CliUsageError(
|
|
10578
|
-
`role run admitted merger task is blank: ${
|
|
10666
|
+
`role run admitted merger task is blank: ${leg}`
|
|
10579
10667
|
);
|
|
10580
10668
|
}
|
|
10581
10669
|
const admitted = {
|
|
@@ -10591,7 +10679,7 @@ function admitResumedRole(loaded) {
|
|
|
10591
10679
|
const { prNumber, repository, repositoryDisplay } = fields;
|
|
10592
10680
|
if (repository === void 0 || repositoryDisplay === void 0) {
|
|
10593
10681
|
throw new CliUsageError(
|
|
10594
|
-
`role run admitted collector repository identity is missing: ${
|
|
10682
|
+
`role run admitted collector repository identity is missing: ${leg}`
|
|
10595
10683
|
);
|
|
10596
10684
|
}
|
|
10597
10685
|
let parsedRepository;
|
|
@@ -10603,7 +10691,7 @@ function admitResumedRole(loaded) {
|
|
|
10603
10691
|
}
|
|
10604
10692
|
if (parsedRepository.canonical !== repository) {
|
|
10605
10693
|
throw new CliUsageError(
|
|
10606
|
-
`role run admitted collector repository does not match its canonical form: ${
|
|
10694
|
+
`role run admitted collector repository does not match its canonical form: ${leg}`
|
|
10607
10695
|
);
|
|
10608
10696
|
}
|
|
10609
10697
|
const admitted = {
|
|
@@ -10620,7 +10708,7 @@ function admitResumedRole(loaded) {
|
|
|
10620
10708
|
const { issueNumber, caseRunsPath, caseIdentity } = fields;
|
|
10621
10709
|
if (issueNumber === void 0 || caseRunsPath === void 0 || caseIdentity === void 0) {
|
|
10622
10710
|
throw new CliUsageError(
|
|
10623
|
-
`role run admitted doctor case identity is missing: ${
|
|
10711
|
+
`role run admitted doctor case identity is missing: ${leg}`
|
|
10624
10712
|
);
|
|
10625
10713
|
}
|
|
10626
10714
|
const admitted = {
|
|
@@ -10636,7 +10724,7 @@ function admitResumedRole(loaded) {
|
|
|
10636
10724
|
const { sourceRunPath, sourceRun } = fields;
|
|
10637
10725
|
if (sourceRunPath === void 0 || sourceRun === void 0) {
|
|
10638
10726
|
throw new CliUsageError(
|
|
10639
|
-
`role run admitted notary source-run locator is missing: ${
|
|
10727
|
+
`role run admitted notary source-run locator is missing: ${leg}`
|
|
10640
10728
|
);
|
|
10641
10729
|
}
|
|
10642
10730
|
const admitted = {
|
|
@@ -10649,13 +10737,13 @@ function admitResumedRole(loaded) {
|
|
|
10649
10737
|
}
|
|
10650
10738
|
}
|
|
10651
10739
|
}
|
|
10652
|
-
function resumedWorkerPhase(phase, phases, role,
|
|
10740
|
+
function resumedWorkerPhase(phase, phases, role, leg) {
|
|
10653
10741
|
if (phase === "plan" || phase === "apply") {
|
|
10654
10742
|
if (phases.some((item) => item === phase)) {
|
|
10655
10743
|
return phase;
|
|
10656
10744
|
}
|
|
10657
10745
|
}
|
|
10658
|
-
throw new CliUsageError(`role run admitted ${role} phase is missing: ${
|
|
10746
|
+
throw new CliUsageError(`role run admitted ${role} phase is missing: ${leg}`);
|
|
10659
10747
|
}
|
|
10660
10748
|
var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
|
|
10661
10749
|
var init_run_lifecycle = __esm({
|
|
@@ -10694,7 +10782,7 @@ var init_run_lifecycle = __esm({
|
|
|
10694
10782
|
|
|
10695
10783
|
// src/report-ticket-tool.ts
|
|
10696
10784
|
import { Type as Type16 } from "typebox";
|
|
10697
|
-
import { existsSync as
|
|
10785
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
10698
10786
|
function pageString(page, key) {
|
|
10699
10787
|
const value = page?.[key];
|
|
10700
10788
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
@@ -10732,7 +10820,7 @@ async function reportTicketFromHostContext(context, ticketNumber, authority = pi
|
|
|
10732
10820
|
if (runDirectory === void 0) {
|
|
10733
10821
|
throw new Error("ak_report_ticket requires a per-turn run directory");
|
|
10734
10822
|
}
|
|
10735
|
-
if (!
|
|
10823
|
+
if (!existsSync8(runDirectory)) {
|
|
10736
10824
|
throw new Error(`ak_report_ticket run directory missing: ${runDirectory}`);
|
|
10737
10825
|
}
|
|
10738
10826
|
const admitted = admittedForLiveTicketReport(runDirectory, authority);
|
|
@@ -10910,8 +10998,21 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
|
10910
10998
|
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
10911
10999
|
};
|
|
10912
11000
|
}
|
|
10913
|
-
function mapOwnedToSubmissionRows(owned) {
|
|
11001
|
+
function mapOwnedToSubmissionRows(owned, leg = owned) {
|
|
10914
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
|
+
}
|
|
10915
11016
|
const out = [];
|
|
10916
11017
|
const indexByCall = /* @__PURE__ */ new Map();
|
|
10917
11018
|
const roleByCall = /* @__PURE__ */ new Map();
|
|
@@ -10962,7 +11063,13 @@ function mapOwnedToSubmissionRows(owned) {
|
|
|
10962
11063
|
if (kind === void 0 || original === void 0 || payload === void 0) continue;
|
|
10963
11064
|
const callKey = typeof payload.toolCallId === "string" ? submissionCallKey(recordAttemptId(record), payload.toolCallId) : void 0;
|
|
10964
11065
|
const fallback = callKey === void 0 ? void 0 : roleByCall.get(callKey);
|
|
10965
|
-
|
|
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);
|
|
10966
11073
|
}
|
|
10967
11074
|
return out;
|
|
10968
11075
|
}
|
|
@@ -10975,7 +11082,7 @@ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScop
|
|
|
10975
11082
|
if (attemptId.length === 0) return [];
|
|
10976
11083
|
const scope = resolveReadScope(homeOrScope);
|
|
10977
11084
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
10978
|
-
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
11085
|
+
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId), owned);
|
|
10979
11086
|
}
|
|
10980
11087
|
async function readSubmissionAttemptId(cwd, runId, toolCallId, homeOrScope) {
|
|
10981
11088
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
|
|
@@ -11051,7 +11158,8 @@ function sealAcceptedSubmission(options) {
|
|
|
11051
11158
|
accepted: options.accepted,
|
|
11052
11159
|
sealHead,
|
|
11053
11160
|
sessionFile: void 0,
|
|
11054
|
-
instruction: options.instruction ?? ""
|
|
11161
|
+
instruction: options.instruction ?? "",
|
|
11162
|
+
call: { attemptId, toolCallId: options.toolCallId }
|
|
11055
11163
|
});
|
|
11056
11164
|
}
|
|
11057
11165
|
function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (error) => {
|
|
@@ -11173,7 +11281,8 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
11173
11281
|
role,
|
|
11174
11282
|
accepted: params,
|
|
11175
11283
|
sealHead,
|
|
11176
|
-
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
|
|
11284
|
+
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {},
|
|
11285
|
+
call: { attemptId, toolCallId }
|
|
11177
11286
|
});
|
|
11178
11287
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
11179
11288
|
if (context.host !== "claude" && context.host !== "codex" && runDirectory !== void 0 && isUnboundRunDirectory(runDirectory)) {
|
|
@@ -11206,6 +11315,7 @@ var init_submission_ledger = __esm({
|
|
|
11206
11315
|
init_host_contracts();
|
|
11207
11316
|
init_run_terminal_artifacts();
|
|
11208
11317
|
init_sitian_facade();
|
|
11318
|
+
init_run_dossier_files();
|
|
11209
11319
|
init_run_lifecycle();
|
|
11210
11320
|
init_submission_correctable_error();
|
|
11211
11321
|
init_report_ticket_tool();
|
|
@@ -11397,7 +11507,7 @@ var init_engine_detour_usage = __esm({
|
|
|
11397
11507
|
});
|
|
11398
11508
|
|
|
11399
11509
|
// src/dossier-resolution.ts
|
|
11400
|
-
import { existsSync as
|
|
11510
|
+
import { existsSync as existsSync9, statSync as statSync5 } from "node:fs";
|
|
11401
11511
|
import { resolve as resolve10 } from "node:path";
|
|
11402
11512
|
function isHostContext(value) {
|
|
11403
11513
|
return "sessionManager" in value;
|
|
@@ -11417,7 +11527,7 @@ function resolveAuditDossier(source) {
|
|
|
11417
11527
|
}
|
|
11418
11528
|
const runDirectory = resolve10(raw);
|
|
11419
11529
|
try {
|
|
11420
|
-
if (!
|
|
11530
|
+
if (!existsSync9(runDirectory) || !statSync5(runDirectory).isDirectory()) {
|
|
11421
11531
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
11422
11532
|
}
|
|
11423
11533
|
} catch {
|
|
@@ -11474,6 +11584,7 @@ __export(settlement_exports, {
|
|
|
11474
11584
|
exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
|
|
11475
11585
|
explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
|
|
11476
11586
|
extractNavigatorFact: () => extractNavigatorFact,
|
|
11587
|
+
filedIdentity: () => filedIdentity,
|
|
11477
11588
|
formatCliDiagnostic: () => formatCliDiagnostic,
|
|
11478
11589
|
formatErrorCauseDetail: () => formatErrorCauseDetail,
|
|
11479
11590
|
formatFailureStderrDiagnostic: () => formatFailureStderrDiagnostic,
|
|
@@ -11495,6 +11606,7 @@ __export(settlement_exports, {
|
|
|
11495
11606
|
trySettlePublicSeat: () => trySettlePublicSeat,
|
|
11496
11607
|
withSubmissions: () => withSubmissions
|
|
11497
11608
|
});
|
|
11609
|
+
import { basename as basename10, join as join18 } from "node:path";
|
|
11498
11610
|
function sealedLedgerHome(admitted) {
|
|
11499
11611
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
11500
11612
|
}
|
|
@@ -11553,6 +11665,17 @@ function ledgerReadScope(admitted, scope) {
|
|
|
11553
11665
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
11554
11666
|
};
|
|
11555
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
|
+
}
|
|
11556
11679
|
function roleOutcomeFromRows(role, rows) {
|
|
11557
11680
|
const mine = rows.filter((row) => row.role === role);
|
|
11558
11681
|
const terminal = mine.filter(
|
|
@@ -11562,7 +11685,11 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
11562
11685
|
const payloads = mine.map((row) => row.accepted);
|
|
11563
11686
|
const latest = terminal[terminal.length - 1];
|
|
11564
11687
|
const submissionToolCallId = typeof latest.toolCallId === "string" && latest.toolCallId.length > 0 ? latest.toolCallId : void 0;
|
|
11565
|
-
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
|
+
};
|
|
11566
11693
|
if (latest.kind === "audit-escalation") {
|
|
11567
11694
|
return {
|
|
11568
11695
|
outcome: {
|
|
@@ -11729,7 +11856,7 @@ async function settleNoReceiptTerminal(admitted, authority, scope, facts) {
|
|
|
11729
11856
|
scope
|
|
11730
11857
|
),
|
|
11731
11858
|
artifacts: [],
|
|
11732
|
-
|
|
11859
|
+
...filedIdentity(admitted.runDirectory)
|
|
11733
11860
|
}, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
|
|
11734
11861
|
}
|
|
11735
11862
|
function coordinatesFromAdmitted(authority, admitted) {
|
|
@@ -12203,16 +12330,17 @@ async function settleSealedSeat(admitted, authority, scope, options) {
|
|
|
12203
12330
|
entriesOf(read),
|
|
12204
12331
|
settled.outcome,
|
|
12205
12332
|
scope,
|
|
12206
|
-
settled.submissionToolCallId
|
|
12333
|
+
settled.submissionToolCallId,
|
|
12334
|
+
settled.filed
|
|
12207
12335
|
);
|
|
12208
12336
|
}
|
|
12209
|
-
async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId) {
|
|
12337
|
+
async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId, filed) {
|
|
12210
12338
|
const artifacts = scope?.previewOnly === true ? [] : await publishDeclaredSeatTerminal(admitted, roleOutcome, coordinates, entries, scope);
|
|
12211
12339
|
const terminal = await attachEngineDetourToolUsage({
|
|
12212
12340
|
roleOutcome,
|
|
12213
12341
|
navigator: isNavigatorSeat(admitted.role) ? NAVIGATOR_SEAT_OWN_FACT : extractNavigatorFact(entries),
|
|
12214
12342
|
artifacts,
|
|
12215
|
-
|
|
12343
|
+
...filedIdentity(admitted.runDirectory, filed),
|
|
12216
12344
|
...submissionToolCallId === void 0 || submissionToolCallId.length === 0 ? {} : { submissionToolCallId }
|
|
12217
12345
|
}, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
|
|
12218
12346
|
return attachRecordedSubmissions(admitted, terminal, scope);
|
|
@@ -12378,7 +12506,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
12378
12506
|
decisiveFacts
|
|
12379
12507
|
};
|
|
12380
12508
|
return attachEngineDetourToolUsage(
|
|
12381
|
-
{ roleOutcome, navigator, artifacts,
|
|
12509
|
+
{ roleOutcome, navigator, artifacts, ...filedIdentity(admitted.runDirectory) },
|
|
12382
12510
|
sessionDirectory,
|
|
12383
12511
|
detourUsageContext(admitted, options)
|
|
12384
12512
|
);
|
|
@@ -12445,6 +12573,7 @@ var init_settlement = __esm({
|
|
|
12445
12573
|
"src/public-cli/settlement.ts"() {
|
|
12446
12574
|
"use strict";
|
|
12447
12575
|
init_role_run_placement();
|
|
12576
|
+
init_run_ticket_number();
|
|
12448
12577
|
init_sitian_facade();
|
|
12449
12578
|
init_run_terminal_artifacts();
|
|
12450
12579
|
init_submission_ledger();
|
|
@@ -12480,12 +12609,12 @@ var init_settlement = __esm({
|
|
|
12480
12609
|
});
|
|
12481
12610
|
|
|
12482
12611
|
// src/external-host-turn-loop.ts
|
|
12483
|
-
import { existsSync as
|
|
12484
|
-
import { basename as
|
|
12612
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
12613
|
+
import { basename as basename11 } from "node:path";
|
|
12485
12614
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
12486
12615
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
12487
12616
|
if (live === void 0) {
|
|
12488
|
-
const parsed = parseRunLeaf(
|
|
12617
|
+
const parsed = parseRunLeaf(basename11(request.runDirectory));
|
|
12489
12618
|
throw new Error(
|
|
12490
12619
|
`admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
|
|
12491
12620
|
);
|
|
@@ -12504,7 +12633,7 @@ async function trySyncTurnRequestLivePlacement(request, authority) {
|
|
|
12504
12633
|
}
|
|
12505
12634
|
async function retainPackageFaultBesideLivePlacement(request, input) {
|
|
12506
12635
|
let runDirectory = request.runDirectory;
|
|
12507
|
-
if (!
|
|
12636
|
+
if (!existsSync10(runDirectory)) {
|
|
12508
12637
|
try {
|
|
12509
12638
|
const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
12510
12639
|
if (found === void 0) {
|
|
@@ -12689,7 +12818,7 @@ var init_external_host_turn_loop = __esm({
|
|
|
12689
12818
|
});
|
|
12690
12819
|
|
|
12691
12820
|
// src/session-identity.ts
|
|
12692
|
-
import { join as
|
|
12821
|
+
import { join as join19 } from "node:path";
|
|
12693
12822
|
function createSessionIdentityAuthority(authority, hostName) {
|
|
12694
12823
|
const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
|
|
12695
12824
|
return {
|
|
@@ -12699,7 +12828,7 @@ function createSessionIdentityAuthority(authority, hostName) {
|
|
|
12699
12828
|
},
|
|
12700
12829
|
async load(principal) {
|
|
12701
12830
|
const runDirectory = runDirectoryOf(principal);
|
|
12702
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
12831
|
+
const { records, diagnostics } = await readSitianRecords(join19(runDirectory, RUN_STATE_FILE));
|
|
12703
12832
|
if (diagnostics.length > 0) {
|
|
12704
12833
|
throw new Error(
|
|
12705
12834
|
`${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
|
|
@@ -12769,14 +12898,14 @@ __export(role_turn_host_exports, {
|
|
|
12769
12898
|
});
|
|
12770
12899
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
12771
12900
|
import { constants } from "node:fs";
|
|
12772
|
-
import { existsSync as
|
|
12901
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
12773
12902
|
import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
|
|
12774
|
-
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";
|
|
12775
12904
|
import { platform } from "node:process";
|
|
12776
12905
|
import { promisify as promisify2 } from "node:util";
|
|
12777
12906
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
12778
12907
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
12779
|
-
return
|
|
12908
|
+
return join20(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
12780
12909
|
}
|
|
12781
12910
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
12782
12911
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -12966,7 +13095,7 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
12966
13095
|
homeFromRunDirectory(spawnDir)
|
|
12967
13096
|
);
|
|
12968
13097
|
} catch (resolveError) {
|
|
12969
|
-
runDirectory =
|
|
13098
|
+
runDirectory = existsSync11(spawnDir) ? spawnDir : void 0;
|
|
12970
13099
|
const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
|
|
12971
13100
|
if (runDirectory !== void 0) {
|
|
12972
13101
|
await retainPackageFault({
|
|
@@ -13256,15 +13385,15 @@ var init_navigator_lookup_host = __esm({
|
|
|
13256
13385
|
|
|
13257
13386
|
// src/public-cli/host-providers.ts
|
|
13258
13387
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
13259
|
-
import { join as
|
|
13388
|
+
import { join as join21 } from "node:path";
|
|
13260
13389
|
function hostProvidersPath(home) {
|
|
13261
13390
|
if (typeof home !== "string" || home.trim() === "") {
|
|
13262
13391
|
throw new Error("home must be explicitly provided");
|
|
13263
13392
|
}
|
|
13264
|
-
return
|
|
13393
|
+
return join21(home, ".ak-roles", "host-providers.json");
|
|
13265
13394
|
}
|
|
13266
13395
|
function hermesProviderModelsCachePath(home) {
|
|
13267
|
-
return
|
|
13396
|
+
return join21(home, ".hermes", "provider_models_cache.json");
|
|
13268
13397
|
}
|
|
13269
13398
|
function parseHostProvidersTable(value) {
|
|
13270
13399
|
if (!isRecord(value)) {
|
|
@@ -13414,17 +13543,17 @@ var init_host_providers = __esm({
|
|
|
13414
13543
|
});
|
|
13415
13544
|
|
|
13416
13545
|
// src/public-cli/load-production-acp-host.ts
|
|
13417
|
-
import { existsSync as
|
|
13418
|
-
import { join as
|
|
13546
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
13547
|
+
import { join as join22 } from "node:path";
|
|
13419
13548
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
13420
13549
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
13421
13550
|
const description = lookupHostDescription(host);
|
|
13422
13551
|
if (description === void 0) {
|
|
13423
13552
|
throw new Error(`unregistered host: ${host}`);
|
|
13424
13553
|
}
|
|
13425
|
-
const built =
|
|
13426
|
-
const source =
|
|
13427
|
-
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;
|
|
13428
13557
|
const href = pathToFileURL2(target).href;
|
|
13429
13558
|
const mod = await import(href);
|
|
13430
13559
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -13438,17 +13567,17 @@ var init_load_production_acp_host = __esm({
|
|
|
13438
13567
|
});
|
|
13439
13568
|
|
|
13440
13569
|
// src/public-cli/load-production-headless-host.ts
|
|
13441
|
-
import { existsSync as
|
|
13442
|
-
import { join as
|
|
13570
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
13571
|
+
import { join as join23 } from "node:path";
|
|
13443
13572
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
13444
13573
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
13445
13574
|
const description = lookupHeadlessHostDescription(host);
|
|
13446
13575
|
if (description === void 0) {
|
|
13447
13576
|
throw new Error(`unregistered headless host: ${host}`);
|
|
13448
13577
|
}
|
|
13449
|
-
const built =
|
|
13450
|
-
const source =
|
|
13451
|
-
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;
|
|
13452
13581
|
const href = pathToFileURL3(target).href;
|
|
13453
13582
|
const mod = await import(href);
|
|
13454
13583
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -13907,7 +14036,7 @@ async function requireSubmissionGate(options) {
|
|
|
13907
14036
|
officer: projected.officer,
|
|
13908
14037
|
receipt: gatekeeper.submission ?? { reason: gatekeeper.reason },
|
|
13909
14038
|
reason: gatekeeper.reason,
|
|
13910
|
-
runId: projected.summoned
|
|
14039
|
+
runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
|
|
13911
14040
|
runDirectory: projected.summoned?.runDirectory,
|
|
13912
14041
|
terminal: projected.summoned?.terminal
|
|
13913
14042
|
});
|
|
@@ -13927,7 +14056,7 @@ async function requireSubmissionGate(options) {
|
|
|
13927
14056
|
officer: projected.officer,
|
|
13928
14057
|
receipt: gatekeeper.facts ?? { reason: gatekeeper.reason },
|
|
13929
14058
|
reason: gatekeeper.reason,
|
|
13930
|
-
runId: projected.summoned
|
|
14059
|
+
runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
|
|
13931
14060
|
runDirectory: projected.summoned?.runDirectory,
|
|
13932
14061
|
terminal: projected.summoned?.terminal
|
|
13933
14062
|
});
|
|
@@ -13959,7 +14088,7 @@ __export(auditor_soul_exports, {
|
|
|
13959
14088
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
13960
14089
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
13961
14090
|
});
|
|
13962
|
-
import { basename as
|
|
14091
|
+
import { basename as basename12 } from "node:path";
|
|
13963
14092
|
function auditorSoulRelativePath(role) {
|
|
13964
14093
|
return `souls/${role}-auditor.md`;
|
|
13965
14094
|
}
|
|
@@ -13995,7 +14124,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
13995
14124
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
13996
14125
|
}
|
|
13997
14126
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
13998
|
-
const role = parseRunLeaf(
|
|
14127
|
+
const role = parseRunLeaf(basename12(sourceRunDirectory))?.role;
|
|
13999
14128
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
14000
14129
|
}
|
|
14001
14130
|
async function readAuditorResumeBinding(admitted) {
|
|
@@ -14037,20 +14166,20 @@ var init_auditor_soul = __esm({
|
|
|
14037
14166
|
});
|
|
14038
14167
|
|
|
14039
14168
|
// src/public-cli/machine-method-skills.ts
|
|
14040
|
-
import { accessSync, constants as constants2, statSync as
|
|
14169
|
+
import { accessSync, constants as constants2, statSync as statSync6 } from "node:fs";
|
|
14041
14170
|
import { lstat as lstat3, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
14042
|
-
import { join as
|
|
14171
|
+
import { join as join25 } from "node:path";
|
|
14043
14172
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
14044
14173
|
function skillRoot(home) {
|
|
14045
|
-
return
|
|
14174
|
+
return join25(home, ".agents/skills");
|
|
14046
14175
|
}
|
|
14047
14176
|
function installedMethodSkillPath(home, name) {
|
|
14048
14177
|
return installedSkillPath(skillRoot(home), name);
|
|
14049
14178
|
}
|
|
14050
14179
|
function installedSkillPath(root, name) {
|
|
14051
|
-
const path =
|
|
14180
|
+
const path = join25(root, name, "SKILL.md");
|
|
14052
14181
|
try {
|
|
14053
|
-
if (!
|
|
14182
|
+
if (!statSync6(path).isFile()) return void 0;
|
|
14054
14183
|
accessSync(path, constants2.R_OK);
|
|
14055
14184
|
return path;
|
|
14056
14185
|
} catch (error) {
|
|
@@ -14061,9 +14190,9 @@ function installedSkillPath(root, name) {
|
|
|
14061
14190
|
}
|
|
14062
14191
|
function linkedSkillRoot(home, host) {
|
|
14063
14192
|
if (host === "claude" || host === "claude-code") {
|
|
14064
|
-
return
|
|
14193
|
+
return join25(process.env.CLAUDE_CONFIG_DIR?.trim() || join25(home, ".claude"), "skills");
|
|
14065
14194
|
}
|
|
14066
|
-
if (host === "hermes") return
|
|
14195
|
+
if (host === "hermes") return join25(home, ".hermes/skills");
|
|
14067
14196
|
return void 0;
|
|
14068
14197
|
}
|
|
14069
14198
|
async function occupied(path) {
|
|
@@ -14120,7 +14249,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
14120
14249
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
14121
14250
|
let unsourced = false;
|
|
14122
14251
|
for (const name of packagedMethodSkillNames()) {
|
|
14123
|
-
const path =
|
|
14252
|
+
const path = join25(canonical, name);
|
|
14124
14253
|
if (await occupied(path)) {
|
|
14125
14254
|
warnOccupied(path, stdout);
|
|
14126
14255
|
continue;
|
|
@@ -14150,9 +14279,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
14150
14279
|
throw error;
|
|
14151
14280
|
}
|
|
14152
14281
|
for (const name of packagedMethodSkillNames()) {
|
|
14153
|
-
const target =
|
|
14282
|
+
const target = join25(canonical, name);
|
|
14154
14283
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
14155
|
-
const link =
|
|
14284
|
+
const link = join25(root, name);
|
|
14156
14285
|
if (await occupied(link)) {
|
|
14157
14286
|
warnOccupied(link, stdout);
|
|
14158
14287
|
continue;
|
|
@@ -14411,7 +14540,7 @@ function dispatchExceptionFailureTerminal(input) {
|
|
|
14411
14540
|
},
|
|
14412
14541
|
navigator: { disposition: "no-advice" },
|
|
14413
14542
|
artifacts,
|
|
14414
|
-
|
|
14543
|
+
...filedIdentity(input.runDirectory),
|
|
14415
14544
|
autoResumeCount: input.autoResumeAttempts
|
|
14416
14545
|
};
|
|
14417
14546
|
}
|
|
@@ -14509,7 +14638,7 @@ async function runWithAutoResumeLoop(options) {
|
|
|
14509
14638
|
options.admitted,
|
|
14510
14639
|
dispatchExceptionFailureTerminal({
|
|
14511
14640
|
role: options.admitted.role,
|
|
14512
|
-
|
|
14641
|
+
runDirectory: options.admitted.runDirectory,
|
|
14513
14642
|
causeError: lastThrownError,
|
|
14514
14643
|
errorFiles: retainedErrorFiles,
|
|
14515
14644
|
autoResumeAttempts,
|
|
@@ -15823,12 +15952,12 @@ var init_post_admission = __esm({
|
|
|
15823
15952
|
});
|
|
15824
15953
|
|
|
15825
15954
|
// src/public-cli/seat-ticket-binding.ts
|
|
15826
|
-
import { join as
|
|
15955
|
+
import { join as join26 } from "node:path";
|
|
15827
15956
|
function resumedSessionIdMissing(result, runId) {
|
|
15828
15957
|
if (typeof result !== "object" || result === null) return false;
|
|
15829
15958
|
const terminal = result.terminal;
|
|
15830
15959
|
if (typeof terminal !== "object" || terminal === null) return false;
|
|
15831
|
-
if (
|
|
15960
|
+
if (result.admitted?.runId !== runId) return false;
|
|
15832
15961
|
const outcome = terminal.roleOutcome;
|
|
15833
15962
|
if (typeof outcome !== "object" || outcome === null) return false;
|
|
15834
15963
|
if (outcome.kind !== "failure") return false;
|
|
@@ -15837,7 +15966,7 @@ function resumedSessionIdMissing(result, runId) {
|
|
|
15837
15966
|
return facts.errorCode === SESSION_ID_MISSING;
|
|
15838
15967
|
}
|
|
15839
15968
|
async function writerLockBlocksFreshSummons(runDirectory) {
|
|
15840
|
-
const autopsy = await autopsyWriterLock(
|
|
15969
|
+
const autopsy = await autopsyWriterLock(join26(runDirectory, WRITER_LOCK_FILE));
|
|
15841
15970
|
return autopsy.verdict === "alive" || autopsy.verdict === "unknown";
|
|
15842
15971
|
}
|
|
15843
15972
|
async function tryResumeSameTicketSeatRun(input) {
|
|
@@ -16376,6 +16505,16 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
|
|
|
16376
16505
|
else io.stdout(formatTerminalResult(terminal));
|
|
16377
16506
|
return { exitCode: failed ? 1 : 0, terminal };
|
|
16378
16507
|
}
|
|
16508
|
+
async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
|
|
16509
|
+
const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
|
|
16510
|
+
persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
|
|
16511
|
+
if (fault === void 0) return;
|
|
16512
|
+
await retainPackageFault({
|
|
16513
|
+
runDirectory: officerRunDirectory,
|
|
16514
|
+
diagnostic: fault,
|
|
16515
|
+
stderr: (text) => io.stderr(text)
|
|
16516
|
+
});
|
|
16517
|
+
}
|
|
16379
16518
|
function resumeSameParentInstructionSeat(input) {
|
|
16380
16519
|
return tryResumeSameTicketSeatRun({
|
|
16381
16520
|
home: input.env.home,
|
|
@@ -16395,7 +16534,8 @@ function resumeSameParentInstructionSeat(input) {
|
|
|
16395
16534
|
...materials === void 0 ? {} : { summons: materials }
|
|
16396
16535
|
},
|
|
16397
16536
|
input.env,
|
|
16398
|
-
input.io
|
|
16537
|
+
input.io,
|
|
16538
|
+
input.parentRunPath
|
|
16399
16539
|
);
|
|
16400
16540
|
}
|
|
16401
16541
|
});
|
|
@@ -16471,7 +16611,9 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
16471
16611
|
);
|
|
16472
16612
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
16473
16613
|
if (gateParentRunPath !== void 0) {
|
|
16474
|
-
await
|
|
16614
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
|
|
16615
|
+
sourceRunPath: gateParentRunPath
|
|
16616
|
+
});
|
|
16475
16617
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
16476
16618
|
}
|
|
16477
16619
|
const turnProjection = roleTurnOptions(env, admitted, {
|
|
@@ -16680,12 +16822,21 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
16680
16822
|
throw error;
|
|
16681
16823
|
}
|
|
16682
16824
|
if (instructionSourceRunPath !== void 0) {
|
|
16683
|
-
await
|
|
16825
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
|
|
16826
|
+
sourceRunPath: instructionSourceRunPath
|
|
16827
|
+
});
|
|
16684
16828
|
admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
|
|
16685
|
-
}
|
|
16686
|
-
|
|
16687
|
-
|
|
16829
|
+
} else if (record.sameParent === "subject-source" && auditorSource !== void 0) {
|
|
16830
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
|
|
16831
|
+
sourceRunPath: auditorSource,
|
|
16832
|
+
auditorSubject
|
|
16833
|
+
});
|
|
16688
16834
|
admitted = { ...admitted, sourceRunPath: auditorSource };
|
|
16835
|
+
} else {
|
|
16836
|
+
const auditedRunDirectory = admittedSourceRunPath(admitted);
|
|
16837
|
+
if (auditedRunDirectory !== void 0) {
|
|
16838
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
|
|
16839
|
+
}
|
|
16689
16840
|
}
|
|
16690
16841
|
admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
|
|
16691
16842
|
const runAdmitted = async () => {
|
|
@@ -16760,7 +16911,7 @@ async function inheritKnownTicketFromSource(admitted, authority) {
|
|
|
16760
16911
|
await relocateAdmittedRunToTicket(admitted, authority);
|
|
16761
16912
|
return admitted;
|
|
16762
16913
|
}
|
|
16763
|
-
async function runPublicInstructionSeatResume(request, env, io) {
|
|
16914
|
+
async function runPublicInstructionSeatResume(request, env, io, resummonedFor) {
|
|
16764
16915
|
let selectedRequest = request;
|
|
16765
16916
|
const resume = async () => {
|
|
16766
16917
|
const held = [];
|
|
@@ -16791,6 +16942,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
16791
16942
|
return { ...loaded, admitted };
|
|
16792
16943
|
},
|
|
16793
16944
|
buildTurnRequest: async (admitted, effective) => {
|
|
16945
|
+
if (resummonedFor !== void 0) {
|
|
16946
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
|
|
16947
|
+
}
|
|
16794
16948
|
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
16795
16949
|
const projection = resumeTurnRequestProjectionOptions(
|
|
16796
16950
|
admitted,
|
|
@@ -17192,7 +17346,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
17192
17346
|
const pass = chain.passes.at(-1);
|
|
17193
17347
|
const officerTerminal = pass?.terminal;
|
|
17194
17348
|
const officerRunDirectory = pass?.runDirectory;
|
|
17195
|
-
const officerRunId = pass?.runId
|
|
17349
|
+
const officerRunId = pass?.runId;
|
|
17196
17350
|
if (officerTerminal !== void 0 && officerRunId !== void 0) {
|
|
17197
17351
|
await presentAuditedOriginalVolume(turn, io);
|
|
17198
17352
|
const officer = await loadResumablePublicRole(
|
|
@@ -17231,7 +17385,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
17231
17385
|
if (chain.status === "escalate") {
|
|
17232
17386
|
const escalation = chain.passes.at(-1);
|
|
17233
17387
|
const escalatedRunDirectory = escalation?.runDirectory;
|
|
17234
|
-
const escalatedRunId = escalation?.runId
|
|
17388
|
+
const escalatedRunId = escalation?.runId;
|
|
17235
17389
|
if (escalatedRunId === void 0) {
|
|
17236
17390
|
return incompleteAuditWithoutOfficerVolume(
|
|
17237
17391
|
turn,
|
|
@@ -17309,6 +17463,7 @@ var init_instruction_seat_run = __esm({
|
|
|
17309
17463
|
init_terminal();
|
|
17310
17464
|
init_turn_request();
|
|
17311
17465
|
init_countersign_run();
|
|
17466
|
+
init_ticket_progress();
|
|
17312
17467
|
init_unknown_value();
|
|
17313
17468
|
AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
|
|
17314
17469
|
SECRETARIAT_STATUS_REASK = "status \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
|
@@ -17404,13 +17559,13 @@ var init_dialogue_command = __esm({
|
|
|
17404
17559
|
});
|
|
17405
17560
|
|
|
17406
17561
|
// src/analyst-book-key.ts
|
|
17407
|
-
import { statSync as
|
|
17562
|
+
import { statSync as statSync7 } from "node:fs";
|
|
17408
17563
|
import { isAbsolute as isAbsolute8 } from "node:path";
|
|
17409
17564
|
function resolveAnalystBookKey(projectRoot) {
|
|
17410
17565
|
const identity = physicalPathIdentity(projectRoot);
|
|
17411
17566
|
let stats;
|
|
17412
17567
|
try {
|
|
17413
|
-
stats =
|
|
17568
|
+
stats = statSync7(identity);
|
|
17414
17569
|
} catch (error) {
|
|
17415
17570
|
const code = errnoCode(error);
|
|
17416
17571
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -17440,10 +17595,10 @@ var init_analyst_book_key = __esm({
|
|
|
17440
17595
|
// src/atomic-write.ts
|
|
17441
17596
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
17442
17597
|
import { rename as rename2, rm, writeFile as writeFile4 } from "node:fs/promises";
|
|
17443
|
-
import { dirname as dirname15, join as
|
|
17598
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
17444
17599
|
async function writeFileAtomically(destination, contents, options) {
|
|
17445
17600
|
const parent = dirname15(destination);
|
|
17446
|
-
const temporary =
|
|
17601
|
+
const temporary = join27(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
17447
17602
|
try {
|
|
17448
17603
|
await writeFile4(temporary, contents, options);
|
|
17449
17604
|
await rename2(temporary, destination);
|
|
@@ -17460,12 +17615,12 @@ var init_atomic_write = __esm({
|
|
|
17460
17615
|
|
|
17461
17616
|
// src/analyst-index.ts
|
|
17462
17617
|
import { open as open2, readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
|
|
17463
|
-
import { dirname as dirname16, join as
|
|
17618
|
+
import { dirname as dirname16, join as join28 } from "node:path";
|
|
17464
17619
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
17465
17620
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
17466
17621
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
17467
17622
|
ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
|
|
17468
|
-
const lockPath =
|
|
17623
|
+
const lockPath = join28(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
17469
17624
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
17470
17625
|
const startedAt = Date.now();
|
|
17471
17626
|
while (true) {
|
|
@@ -17492,7 +17647,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
17492
17647
|
}
|
|
17493
17648
|
}
|
|
17494
17649
|
function analystLibraryIndexPath(ledgerHome) {
|
|
17495
|
-
return
|
|
17650
|
+
return join28(ledgerHome, "analyst", "library-index.json");
|
|
17496
17651
|
}
|
|
17497
17652
|
function rowFromIssueMetricsPage(page) {
|
|
17498
17653
|
return {
|
|
@@ -17786,7 +17941,7 @@ var init_analyst_cohort = __esm({
|
|
|
17786
17941
|
});
|
|
17787
17942
|
|
|
17788
17943
|
// src/archivist-record-pointer.ts
|
|
17789
|
-
import { basename as
|
|
17944
|
+
import { basename as basename13, join as join29 } from "node:path";
|
|
17790
17945
|
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
17791
17946
|
const where = `${parentRunDirectory} officers`;
|
|
17792
17947
|
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
@@ -17799,7 +17954,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
17799
17954
|
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
17800
17955
|
let sessionFile = raw.sessionFile;
|
|
17801
17956
|
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
17802
|
-
const leaf = parseRunLeaf(
|
|
17957
|
+
const leaf = parseRunLeaf(basename13(recordedRunDirectory));
|
|
17803
17958
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
17804
17959
|
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
17805
17960
|
const currentRunDirectory = await resolveLiveRunDirectoryPath(
|
|
@@ -17819,7 +17974,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
17819
17974
|
};
|
|
17820
17975
|
}
|
|
17821
17976
|
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
17822
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
17977
|
+
const { records, diagnostics } = await readSitianRecords(join29(parentRunDirectory, RUN_HISTORY_FILE));
|
|
17823
17978
|
if (diagnostics.length > 0) {
|
|
17824
17979
|
throw new Error(
|
|
17825
17980
|
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
@@ -18102,7 +18257,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
18102
18257
|
|
|
18103
18258
|
// src/analyst-ledger.ts
|
|
18104
18259
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
18105
|
-
import { basename as
|
|
18260
|
+
import { basename as basename14, join as join30 } from "node:path";
|
|
18106
18261
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
18107
18262
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
18108
18263
|
}
|
|
@@ -18122,7 +18277,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
18122
18277
|
}
|
|
18123
18278
|
}
|
|
18124
18279
|
async function classifyGhostCandidate(input) {
|
|
18125
|
-
const autopsy = await autopsyWriterLock(
|
|
18280
|
+
const autopsy = await autopsyWriterLock(join30(input.runDirectory, "writer.lock"));
|
|
18126
18281
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
18127
18282
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
18128
18283
|
return {
|
|
@@ -18412,7 +18567,7 @@ async function classifyScopedRun(input) {
|
|
|
18412
18567
|
async function scanAnalystIssueRuns(input) {
|
|
18413
18568
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
18414
18569
|
const scopeTicketNumber = input.ticketNumber;
|
|
18415
|
-
const booksRoot =
|
|
18570
|
+
const booksRoot = join30(ledgerHome, "books");
|
|
18416
18571
|
let wholeBook = false;
|
|
18417
18572
|
let scopeRootIdentity;
|
|
18418
18573
|
let bookNames;
|
|
@@ -18445,7 +18600,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
18445
18600
|
const ghostLegs = [];
|
|
18446
18601
|
const scopeConflicts = [];
|
|
18447
18602
|
for (const book of bookNames) {
|
|
18448
|
-
const bookDir =
|
|
18603
|
+
const bookDir = join30(booksRoot, book);
|
|
18449
18604
|
let runDirectories;
|
|
18450
18605
|
try {
|
|
18451
18606
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -18454,7 +18609,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
18454
18609
|
throw error;
|
|
18455
18610
|
}
|
|
18456
18611
|
for (const runDirectory of runDirectories) {
|
|
18457
|
-
const runName =
|
|
18612
|
+
const runName = basename14(runDirectory);
|
|
18458
18613
|
const parsed = parseRunLeaf(runName);
|
|
18459
18614
|
if (parsed === void 0) continue;
|
|
18460
18615
|
let scopeFields;
|
|
@@ -19191,7 +19346,7 @@ var init_analyst_metric_family = __esm({
|
|
|
19191
19346
|
});
|
|
19192
19347
|
|
|
19193
19348
|
// src/analyst-page.ts
|
|
19194
|
-
import { dirname as dirname17, join as
|
|
19349
|
+
import { dirname as dirname17, join as join31 } from "node:path";
|
|
19195
19350
|
function analystIssuePageKey(address) {
|
|
19196
19351
|
const parts = ["book", address.bookKey];
|
|
19197
19352
|
if (address.issueNumber !== void 0) {
|
|
@@ -19202,7 +19357,7 @@ function analystIssuePageKey(address) {
|
|
|
19202
19357
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
19203
19358
|
}
|
|
19204
19359
|
function analystIssuePagePath(ledgerHome, address) {
|
|
19205
|
-
return
|
|
19360
|
+
return join31(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
19206
19361
|
}
|
|
19207
19362
|
function analystIssuePageAddressFromPage(page) {
|
|
19208
19363
|
return {
|
|
@@ -20048,18 +20203,22 @@ function parseArgv(argv) {
|
|
|
20048
20203
|
help
|
|
20049
20204
|
};
|
|
20050
20205
|
}
|
|
20051
|
-
function
|
|
20052
|
-
const
|
|
20053
|
-
|
|
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) {
|
|
20054
20210
|
throw new CliUsageError(RESUME_USAGE_ERROR);
|
|
20055
20211
|
}
|
|
20056
|
-
|
|
20057
|
-
|
|
20212
|
+
const { seat, round } = parseSeatRound(seatToken);
|
|
20213
|
+
if (!isPublicCallableRole(seat) || round === "") {
|
|
20214
|
+
throw new CliUsageError(`${RESUME_USAGE_ERROR}; not a callable seat: ${seatToken}`);
|
|
20058
20215
|
}
|
|
20059
|
-
|
|
20060
|
-
|
|
20061
|
-
|
|
20062
|
-
|
|
20216
|
+
return {
|
|
20217
|
+
ticketNumber,
|
|
20218
|
+
seat,
|
|
20219
|
+
...round === void 0 ? {} : { round },
|
|
20220
|
+
...rest.length === 0 ? {} : { message: rest[0] }
|
|
20221
|
+
};
|
|
20063
20222
|
}
|
|
20064
20223
|
function invocationFromParsed(parsed) {
|
|
20065
20224
|
if (parsed.model === void 0 && parsed.thinking === void 0 && parsed.engine === void 0 && parsed.host === void 0) {
|
|
@@ -20168,7 +20327,7 @@ function renderHelp() {
|
|
|
20168
20327
|
"Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
|
|
20169
20328
|
"Model resolution: --model \u2192 persistent seat \u2192 officer inherit (#620); still none \u2192 error (#178)",
|
|
20170
20329
|
"Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
|
|
20171
|
-
"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)",
|
|
20172
20331
|
"Effective seats: ak-role roles"
|
|
20173
20332
|
);
|
|
20174
20333
|
return `${lines.join("\n")}
|
|
@@ -20560,28 +20719,34 @@ async function runAkRole(argv, env) {
|
|
|
20560
20719
|
env = { ...env, freshSummons: true };
|
|
20561
20720
|
}
|
|
20562
20721
|
if (parsed.command === "resume") {
|
|
20563
|
-
|
|
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
|
+
};
|
|
20564
20735
|
resumeFailureContext = {
|
|
20565
20736
|
home,
|
|
20566
20737
|
runId: resumeRequest.runId,
|
|
20738
|
+
runDirectory,
|
|
20567
20739
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
20568
20740
|
};
|
|
20569
|
-
const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
|
|
20570
|
-
if (runDirectory !== void 0) {
|
|
20571
|
-
resumeRequest = { ...resumeRequest, runDirectory };
|
|
20572
|
-
resumeFailureContext = { ...resumeFailureContext, runDirectory };
|
|
20573
|
-
}
|
|
20574
20741
|
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
20575
|
-
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
|
|
20576
|
-
const seatRole = resumeRole ?? "judge";
|
|
20577
20742
|
const seat = resolveEffectiveSeat(
|
|
20578
20743
|
parts.config,
|
|
20579
|
-
|
|
20744
|
+
address.seat,
|
|
20580
20745
|
parts.credentials,
|
|
20581
20746
|
invocationFromParsed(parsed)
|
|
20582
20747
|
);
|
|
20583
20748
|
const resumeEnv = createRoleEnvironment(env, {
|
|
20584
|
-
role:
|
|
20749
|
+
role: address.seat,
|
|
20585
20750
|
home,
|
|
20586
20751
|
agentDir: parts.agentDir,
|
|
20587
20752
|
cwd: parts.cwd,
|
|
@@ -20715,6 +20880,10 @@ var init_cli = __esm({
|
|
|
20715
20880
|
init_instruction_seat_run();
|
|
20716
20881
|
init_countersign_run();
|
|
20717
20882
|
init_analyst_run();
|
|
20883
|
+
init_activation_ledger_git();
|
|
20884
|
+
init_activation_ledger_topology();
|
|
20885
|
+
init_run_terminal_artifacts();
|
|
20886
|
+
init_ticket_address();
|
|
20718
20887
|
init_run_lifecycle();
|
|
20719
20888
|
init_registry();
|
|
20720
20889
|
init_settlement();
|
|
@@ -20728,7 +20897,7 @@ var init_cli = __esm({
|
|
|
20728
20897
|
])
|
|
20729
20898
|
);
|
|
20730
20899
|
PUBLIC_GLOBAL_OPTIONS = optionsForOwner("global");
|
|
20731
|
-
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)";
|
|
20732
20901
|
}
|
|
20733
20902
|
});
|
|
20734
20903
|
|
|
@@ -20742,9 +20911,9 @@ __export(public_role_summons_exports, {
|
|
|
20742
20911
|
summonPublicRole: () => summonPublicRole
|
|
20743
20912
|
});
|
|
20744
20913
|
import { execFile as execFile3 } from "node:child_process";
|
|
20745
|
-
import { existsSync as
|
|
20914
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
20746
20915
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
20747
|
-
import { join as
|
|
20916
|
+
import { join as join32 } from "node:path";
|
|
20748
20917
|
import { promisify as promisify3 } from "node:util";
|
|
20749
20918
|
function createCapturingIo() {
|
|
20750
20919
|
const chunks = [];
|
|
@@ -20768,7 +20937,7 @@ function parentDir(path) {
|
|
|
20768
20937
|
function walkPackageRoot(start) {
|
|
20769
20938
|
let dir = start;
|
|
20770
20939
|
for (let i = 0; i < 12; i += 1) {
|
|
20771
|
-
if (
|
|
20940
|
+
if (existsSync14(join32(dir, "package.json")) && existsSync14(join32(dir, "souls"))) {
|
|
20772
20941
|
return dir;
|
|
20773
20942
|
}
|
|
20774
20943
|
const parent = parentDir(dir);
|
|
@@ -21003,13 +21172,7 @@ async function summonPublicRole(options) {
|
|
|
21003
21172
|
result = stepped.ok;
|
|
21004
21173
|
}
|
|
21005
21174
|
const stderr = captured?.stderrText();
|
|
21006
|
-
|
|
21007
|
-
if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
|
|
21008
|
-
runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
21009
|
-
home,
|
|
21010
|
-
result.terminal.runId
|
|
21011
|
-
) ?? runDirectory;
|
|
21012
|
-
}
|
|
21175
|
+
const runDirectory = result.admitted?.runDirectory;
|
|
21013
21176
|
return {
|
|
21014
21177
|
exitCode: result.exitCode,
|
|
21015
21178
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -21376,7 +21539,7 @@ init_submission_ledger();
|
|
|
21376
21539
|
init_filed_submission();
|
|
21377
21540
|
init_report_ticket_tool();
|
|
21378
21541
|
import { writeSync as writeSync2 } from "node:fs";
|
|
21379
|
-
import { join as
|
|
21542
|
+
import { join as join33 } from "node:path";
|
|
21380
21543
|
import { Value as Value2 } from "typebox/value";
|
|
21381
21544
|
|
|
21382
21545
|
// src/activation-trace.ts
|
|
@@ -21425,7 +21588,7 @@ init_activation_ledger_topology();
|
|
|
21425
21588
|
import {
|
|
21426
21589
|
lstatSync as lstatSync2,
|
|
21427
21590
|
realpathSync as realpathSync2,
|
|
21428
|
-
statSync as
|
|
21591
|
+
statSync as statSync8,
|
|
21429
21592
|
writeFileSync as writeFileSync3
|
|
21430
21593
|
} from "node:fs";
|
|
21431
21594
|
import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
|
|
@@ -21500,7 +21663,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
21500
21663
|
}
|
|
21501
21664
|
let info;
|
|
21502
21665
|
try {
|
|
21503
|
-
info =
|
|
21666
|
+
info = statSync8(realFile);
|
|
21504
21667
|
} catch (error) {
|
|
21505
21668
|
throw new Error(
|
|
21506
21669
|
`Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
|
|
@@ -21894,10 +22057,10 @@ init_run_ticket_number();
|
|
|
21894
22057
|
|
|
21895
22058
|
// src/audited-run-identity.ts
|
|
21896
22059
|
init_role_run_placement();
|
|
21897
|
-
import { basename as
|
|
22060
|
+
import { basename as basename15 } from "node:path";
|
|
21898
22061
|
var AUDITED_RUN_IDENTITY_KIND = "audited-run";
|
|
21899
22062
|
function auditedRunIdentityFromDirectory(runDirectory) {
|
|
21900
|
-
const parsed = parseRunLeaf(
|
|
22063
|
+
const parsed = parseRunLeaf(basename15(runDirectory));
|
|
21901
22064
|
if (parsed === void 0) return void 0;
|
|
21902
22065
|
return formatRunLeaf(parsed.runId, parsed.role);
|
|
21903
22066
|
}
|
|
@@ -22122,7 +22285,7 @@ init_unknown_value();
|
|
|
22122
22285
|
init_submission_errors();
|
|
22123
22286
|
init_worker_submission_contracts();
|
|
22124
22287
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
22125
|
-
import { existsSync as
|
|
22288
|
+
import { existsSync as existsSync15, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync4 } from "node:fs";
|
|
22126
22289
|
import { resolve as resolve15 } from "node:path";
|
|
22127
22290
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
22128
22291
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -22152,7 +22315,7 @@ function statusOf(error) {
|
|
|
22152
22315
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
22153
22316
|
}
|
|
22154
22317
|
function tryGetAll(file, key) {
|
|
22155
|
-
if (!
|
|
22318
|
+
if (!existsSync15(file)) return [];
|
|
22156
22319
|
try {
|
|
22157
22320
|
const out = gitFile(file, ["--get-all", key]);
|
|
22158
22321
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -22162,7 +22325,7 @@ function tryGetAll(file, key) {
|
|
|
22162
22325
|
}
|
|
22163
22326
|
}
|
|
22164
22327
|
function ownedHook(path) {
|
|
22165
|
-
if (!
|
|
22328
|
+
if (!existsSync15(path)) return false;
|
|
22166
22329
|
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
22167
22330
|
}
|
|
22168
22331
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -22189,12 +22352,12 @@ function rmOwnedDir(dir) {
|
|
|
22189
22352
|
const hookPath = resolve15(dir, HOOK_FILE);
|
|
22190
22353
|
if (!ownedHook(hookPath)) return;
|
|
22191
22354
|
rmSync4(hookPath, { force: true });
|
|
22192
|
-
if (
|
|
22355
|
+
if (existsSync15(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
22193
22356
|
}
|
|
22194
22357
|
function linkedGitDirs(commonDir) {
|
|
22195
22358
|
const root = resolve15(commonDir, "worktrees");
|
|
22196
|
-
if (!
|
|
22197
|
-
return
|
|
22359
|
+
if (!existsSync15(root)) return [];
|
|
22360
|
+
return readdirSync4(root).map((name) => resolve15(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
22198
22361
|
}
|
|
22199
22362
|
function uninstallPackageWorkerHooks(cwd) {
|
|
22200
22363
|
let inside;
|
|
@@ -22985,7 +23148,7 @@ function readRoleRunCoordinates(ctx, label) {
|
|
|
22985
23148
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
22986
23149
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
22987
23150
|
if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
22988
|
-
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)})`);
|
|
22989
23152
|
}
|
|
22990
23153
|
return {
|
|
22991
23154
|
runDirectory,
|
|
@@ -24374,10 +24537,10 @@ init_run_lifecycle();
|
|
|
24374
24537
|
init_settlement();
|
|
24375
24538
|
import { spawn as spawn3, spawnSync as spawnSync4 } from "node:child_process";
|
|
24376
24539
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
24377
|
-
import { existsSync as
|
|
24540
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
24378
24541
|
import { mkdtemp, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
|
|
24379
24542
|
import { tmpdir } from "node:os";
|
|
24380
|
-
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";
|
|
24381
24544
|
|
|
24382
24545
|
// src/agent-start-materials.ts
|
|
24383
24546
|
function renderAgentStartMaterials(body, materials) {
|
|
@@ -24763,7 +24926,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
24763
24926
|
function cwdIsGitWorkTree(cwd) {
|
|
24764
24927
|
let dir = cwd;
|
|
24765
24928
|
for (; ; ) {
|
|
24766
|
-
if (
|
|
24929
|
+
if (existsSync16(join34(dir, ".git"))) return true;
|
|
24767
24930
|
const parent = dirname19(dir);
|
|
24768
24931
|
if (parent === dir) return false;
|
|
24769
24932
|
dir = parent;
|
|
@@ -24980,8 +25143,8 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
24980
25143
|
}
|
|
24981
25144
|
const env = { ...process.env, ...config.env ?? {} };
|
|
24982
25145
|
const liveSessionParent = () => config.sessionIdentity.resolveSessionFile(request.principal);
|
|
24983
|
-
const inputsDirectory = await mkdtemp(
|
|
24984
|
-
const systemPromptPath =
|
|
25146
|
+
const inputsDirectory = await mkdtemp(join34(tmpdir(), "ak-role-headless-"));
|
|
25147
|
+
const systemPromptPath = join34(inputsDirectory, "system-prompt.txt");
|
|
24985
25148
|
let mcpConfigPath;
|
|
24986
25149
|
let outputSchemaPath;
|
|
24987
25150
|
let startedWithSchema;
|
|
@@ -24989,12 +25152,12 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
24989
25152
|
await writeFile6(systemPromptPath, systemPrompt, "utf8");
|
|
24990
25153
|
let deliveredSchema;
|
|
24991
25154
|
if (codex) {
|
|
24992
|
-
outputSchemaPath =
|
|
25155
|
+
outputSchemaPath = join34(inputsDirectory, "output-schema.json");
|
|
24993
25156
|
deliveredSchema = closeJsonSchemaForCodex(prepared.jsonSchema);
|
|
24994
25157
|
await writeFile6(outputSchemaPath, `${JSON.stringify(deliveredSchema, null, 2)}
|
|
24995
25158
|
`, "utf8");
|
|
24996
25159
|
} else {
|
|
24997
|
-
mcpConfigPath =
|
|
25160
|
+
mcpConfigPath = join34(inputsDirectory, "mcp-config.json");
|
|
24998
25161
|
await writeFile6(
|
|
24999
25162
|
mcpConfigPath,
|
|
25000
25163
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|