@akagilnc/pi-workflow-roles 0.1.3637 → 0.1.3644
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +45 -69
- package/dist/audit-escalation.js +2 -2
- package/dist/compliance-transport.js +2 -2
- package/dist/package-contracts/auditor-output.js +7 -7
- package/dist/package-contracts/terminating-tools.js +1 -1
- package/dist/public-cli/main.js +133 -163
- package/dist/public-cli/notary-run.js +5 -20
- package/dist/public-cli/option-definitions.js +1 -1
- package/dist/public-cli/post-admission.js +30 -23
- package/dist/public-cli/run-lifecycle.js +6 -14
- package/dist/public-cli/settlement.js +3 -3
- package/package.json +1 -1
- package/souls/doctor-auditor.md +1 -1
- package/souls/fixer-auditor.md +3 -3
- package/souls/judge-auditor.md +1 -1
- package/src/audit-escalation.ts +3 -3
- package/src/auditor-role.ts +1 -1
- package/src/compliance-transport.ts +4 -4
- package/src/doctor-role.ts +1 -1
- package/src/judge-role.ts +1 -1
- package/src/package-contracts/auditor-output.ts +8 -8
- package/src/package-contracts/terminating-tools.ts +1 -1
- package/src/public-cli/notary-run.ts +6 -18
- package/src/public-cli/option-definitions.ts +1 -1
- package/src/public-cli/post-admission.ts +31 -37
- package/src/public-cli/run-lifecycle.ts +6 -17
- package/src/public-cli/settlement.ts +4 -4
package/dist/public-cli/main.js
CHANGED
|
@@ -15031,9 +15031,9 @@ function isRecord6(value) {
|
|
|
15031
15031
|
function projectLawfulAuditorOutput(value) {
|
|
15032
15032
|
if (!isRecord6(value)) return void 0;
|
|
15033
15033
|
if (value.status === "pass") return { status: "pass" };
|
|
15034
|
-
if (value.status === "
|
|
15034
|
+
if (value.status === "bounce") {
|
|
15035
15035
|
return {
|
|
15036
|
-
status: "
|
|
15036
|
+
status: "bounce",
|
|
15037
15037
|
...Object.hasOwn(value, "violations") ? { violations: value.violations } : {}
|
|
15038
15038
|
};
|
|
15039
15039
|
}
|
|
@@ -15055,7 +15055,7 @@ function validateRecordedAuditorOutput(value) {
|
|
|
15055
15055
|
}
|
|
15056
15056
|
function auditorDecisiveFacts(output) {
|
|
15057
15057
|
const facts = { status: output.status };
|
|
15058
|
-
if (output.status === "
|
|
15058
|
+
if (output.status === "bounce" && output.violations !== void 0) {
|
|
15059
15059
|
facts.violations = output.violations;
|
|
15060
15060
|
}
|
|
15061
15061
|
if (output.status === "escalate") {
|
|
@@ -15076,10 +15076,10 @@ var init_auditor_output = __esm({
|
|
|
15076
15076
|
openToolObject(
|
|
15077
15077
|
typebox_exports.Object({
|
|
15078
15078
|
status: typebox_exports.Unknown({
|
|
15079
|
-
description: "pass |
|
|
15079
|
+
description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
|
|
15080
15080
|
}),
|
|
15081
15081
|
violations: typebox_exports.Optional(typebox_exports.Unknown({
|
|
15082
|
-
description: "status \u4E3A
|
|
15082
|
+
description: "status \u4E3A bounce \u65F6\u7684\u8FDD\u89C4\u6761\u76EE"
|
|
15083
15083
|
})),
|
|
15084
15084
|
conflicts: typebox_exports.Optional(typebox_exports.Unknown({
|
|
15085
15085
|
description: "status \u4E3A escalate \u65F6\u7684\u51B2\u7A81"
|
|
@@ -16129,7 +16129,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
16129
16129
|
}
|
|
16130
16130
|
const command = input.argv[0];
|
|
16131
16131
|
const args = input.argv.slice(1);
|
|
16132
|
-
return await new Promise((
|
|
16132
|
+
return await new Promise((resolve12, reject) => {
|
|
16133
16133
|
let settled = false;
|
|
16134
16134
|
const signal = input.signal;
|
|
16135
16135
|
const child = spawn(command, args, {
|
|
@@ -16159,7 +16159,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
16159
16159
|
if (signal !== void 0) {
|
|
16160
16160
|
signal.removeEventListener("abort", onAbort);
|
|
16161
16161
|
}
|
|
16162
|
-
|
|
16162
|
+
resolve12(result2);
|
|
16163
16163
|
};
|
|
16164
16164
|
const onAbort = () => {
|
|
16165
16165
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -16998,7 +16998,7 @@ function validateAcceptedDetails(toolName, details) {
|
|
|
16998
16998
|
[INSPECTOR_OUTPUT_TOOL_NAME]: ["pass", "bounce"],
|
|
16999
16999
|
[GATEKEEPER_OUTPUT_TOOL_NAME]: ["dispatch", "pass"],
|
|
17000
17000
|
[NAVIGATOR_OUTPUT_TOOL_NAME]: ["advice"],
|
|
17001
|
-
[AUDITOR_OUTPUT_TOOL_NAME]: ["pass", "
|
|
17001
|
+
[AUDITOR_OUTPUT_TOOL_NAME]: ["pass", "bounce", "escalate"],
|
|
17002
17002
|
[EVIDENCE_CHILD_OUTPUT_TOOL_NAME]: [],
|
|
17003
17003
|
[DIARIST_OUTPUT_TOOL_NAME]: ["completed"]
|
|
17004
17004
|
};
|
|
@@ -17520,13 +17520,6 @@ function instructResumeHandbookRead(prompt, engineMaterial) {
|
|
|
17520
17520
|
return line2;
|
|
17521
17521
|
}).join("\n");
|
|
17522
17522
|
}
|
|
17523
|
-
function appendResumeMaterialReread(prompt, materialPath) {
|
|
17524
|
-
const instruction = resumeRereadInstruction(materialPath, false);
|
|
17525
|
-
const lines = prompt.split("\n");
|
|
17526
|
-
if (lines.includes(instruction)) return prompt;
|
|
17527
|
-
return prompt.length === 0 ? instruction : `${prompt}
|
|
17528
|
-
${instruction}`;
|
|
17529
|
-
}
|
|
17530
17523
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
17531
17524
|
const base = message !== void 0 ? message : RESUME_TRANSPORT_ENVELOPE;
|
|
17532
17525
|
return instructResumeHandbookRead(
|
|
@@ -19716,7 +19709,7 @@ var init_option_definitions = __esm({
|
|
|
19716
19709
|
},
|
|
19717
19710
|
auditor: {
|
|
19718
19711
|
command: "auditor",
|
|
19719
|
-
summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: pass,
|
|
19712
|
+
summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: pass, bounce, or escalate.",
|
|
19720
19713
|
usage: ["ak-role auditor --subject <judge|doctor> --source-run <runId@role|path> [options] [instruction]"],
|
|
19721
19714
|
examples: [
|
|
19722
19715
|
'ak-role auditor --subject judge --source-run 01abc\u2026@judge --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
|
|
@@ -22338,7 +22331,7 @@ function normalizeReviewComment(raw) {
|
|
|
22338
22331
|
function createGhApiRunner(options = {}) {
|
|
22339
22332
|
const spawnImpl = options.spawnImpl ?? spawn3;
|
|
22340
22333
|
return async (args, runOptions = {}) => {
|
|
22341
|
-
return await new Promise((
|
|
22334
|
+
return await new Promise((resolve12, reject) => {
|
|
22342
22335
|
const signal = runOptions.signal;
|
|
22343
22336
|
if (signal?.aborted) {
|
|
22344
22337
|
reject(signal.reason ?? new Error("aborted"));
|
|
@@ -22411,11 +22404,11 @@ function createGhApiRunner(options = {}) {
|
|
|
22411
22404
|
const value = line2.slice(idx + 1).trim();
|
|
22412
22405
|
headers[name] = value;
|
|
22413
22406
|
}
|
|
22414
|
-
|
|
22407
|
+
resolve12({ status, headers, bodyText });
|
|
22415
22408
|
return;
|
|
22416
22409
|
}
|
|
22417
22410
|
if (code === 0) {
|
|
22418
|
-
|
|
22411
|
+
resolve12({ status: 200, headers: {}, bodyText: stdout });
|
|
22419
22412
|
return;
|
|
22420
22413
|
}
|
|
22421
22414
|
const failure = new Error(
|
|
@@ -23863,16 +23856,10 @@ var init_seat_ticket_binding = __esm({
|
|
|
23863
23856
|
});
|
|
23864
23857
|
|
|
23865
23858
|
// src/auditor-dossier-tool.ts
|
|
23866
|
-
import { dirname as dirname8, join as join19, resolve as resolve9 } from "node:path";
|
|
23867
|
-
function gateSubmissionCandidatePath(runDirectory) {
|
|
23868
|
-
return join19(runDirectory, "artifacts", GATE_SUBMISSION_CANDIDATE_FILE);
|
|
23869
|
-
}
|
|
23870
|
-
var GATE_SUBMISSION_CANDIDATE_FILE;
|
|
23871
23859
|
var init_auditor_dossier_tool = __esm({
|
|
23872
23860
|
"src/auditor-dossier-tool.ts"() {
|
|
23873
23861
|
"use strict";
|
|
23874
23862
|
init_build();
|
|
23875
|
-
GATE_SUBMISSION_CANDIDATE_FILE = "gate-submission-candidate.json";
|
|
23876
23863
|
}
|
|
23877
23864
|
});
|
|
23878
23865
|
|
|
@@ -23902,7 +23889,7 @@ var init_compliance_transport = __esm({
|
|
|
23902
23889
|
init_shape_unreadable_failure();
|
|
23903
23890
|
nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
|
|
23904
23891
|
decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
|
|
23905
|
-
complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "pass |
|
|
23892
|
+
complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), violations: typebox_exports.Array(nonblank2, { description: "\u89C2\u5BDF\u5230\u7684\u5408\u89C4\u8FDD\u89C4" }), conflicts: typebox_exports.Array(nonblank2, { description: "\u672A\u51B3\u6743\u5A01\u6216\u6267\u884C\u51B2\u7A81" }), decisionGate: typebox_exports.Union([decisionGateSchema, typebox_exports.Null()], { description: "\u5347\u7EA7\u95EE\u9898\u4E0E\u53EF\u9009\u9009\u9879" }) }, { additionalProperties: true, required: [] });
|
|
23906
23893
|
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
23907
23894
|
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
23908
23895
|
}
|
|
@@ -24089,7 +24076,7 @@ var init_ledger_session_read = __esm({
|
|
|
24089
24076
|
|
|
24090
24077
|
// src/analyst-gate-cycles-read.ts
|
|
24091
24078
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
24092
|
-
import { join as
|
|
24079
|
+
import { join as join19 } from "node:path";
|
|
24093
24080
|
function isRecord15(value) {
|
|
24094
24081
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24095
24082
|
}
|
|
@@ -24350,7 +24337,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
24350
24337
|
throw error;
|
|
24351
24338
|
}
|
|
24352
24339
|
for (const name of names) {
|
|
24353
|
-
const path =
|
|
24340
|
+
const path = join19(directory, name);
|
|
24354
24341
|
const sessionPath = name.endsWith(".pointer.json") ? await resolveOfficerSessionFromPointerFile(path) : path;
|
|
24355
24342
|
if (sessionPath === void 0) continue;
|
|
24356
24343
|
const classified = await classifyAuditorVolume(sessionPath);
|
|
@@ -24403,7 +24390,7 @@ var init_gatekeeper_role = __esm({
|
|
|
24403
24390
|
|
|
24404
24391
|
// src/run-terminal-artifacts.ts
|
|
24405
24392
|
import { readdir as readdir4, readFile as readFile12 } from "node:fs/promises";
|
|
24406
|
-
import { basename as basename7, dirname as
|
|
24393
|
+
import { basename as basename7, dirname as dirname8, join as join20 } from "node:path";
|
|
24407
24394
|
function isMissingPathError2(error) {
|
|
24408
24395
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
24409
24396
|
}
|
|
@@ -24478,7 +24465,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
24478
24465
|
}
|
|
24479
24466
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
24480
24467
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
24481
|
-
found.push(
|
|
24468
|
+
found.push(join20(dir, name));
|
|
24482
24469
|
}
|
|
24483
24470
|
}
|
|
24484
24471
|
return found;
|
|
@@ -24494,14 +24481,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
24494
24481
|
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
24495
24482
|
}
|
|
24496
24483
|
async function readRunTerminalArtifact(runDirectory) {
|
|
24497
|
-
const artifactsDir =
|
|
24484
|
+
const artifactsDir = join20(runDirectory, "artifacts");
|
|
24498
24485
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
24499
|
-
const path =
|
|
24486
|
+
const path = join20(artifactsDir, file);
|
|
24500
24487
|
const read3 = await readTerminalArtifactAtPath(path, file);
|
|
24501
24488
|
if (read3 !== void 0) return read3;
|
|
24502
24489
|
}
|
|
24503
24490
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
24504
|
-
const path =
|
|
24491
|
+
const path = join20(runDirectory, relative3);
|
|
24505
24492
|
const read3 = await readTerminalArtifactAtPath(path, "error.json");
|
|
24506
24493
|
if (read3 !== void 0) return read3;
|
|
24507
24494
|
}
|
|
@@ -24510,7 +24497,7 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
24510
24497
|
if (read3 !== void 0) return read3;
|
|
24511
24498
|
}
|
|
24512
24499
|
const expectedRunId = runIdFromRunDirectory(runDirectory);
|
|
24513
|
-
for (const path of await listUniqueErrorFallbackPaths([
|
|
24500
|
+
for (const path of await listUniqueErrorFallbackPaths([dirname8(runDirectory)])) {
|
|
24514
24501
|
const read3 = await readTerminalArtifactAtPath(path, "error.json");
|
|
24515
24502
|
if (read3 === void 0) continue;
|
|
24516
24503
|
if (read3.status === "present") {
|
|
@@ -24642,15 +24629,15 @@ var init_submission_ledger = __esm({
|
|
|
24642
24629
|
// src/session-opening-materials.ts
|
|
24643
24630
|
import { existsSync as existsSync9 } from "node:fs";
|
|
24644
24631
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
24645
|
-
import { dirname as
|
|
24632
|
+
import { dirname as dirname9, join as join21 } from "node:path";
|
|
24646
24633
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
24647
24634
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
24648
|
-
let dir =
|
|
24635
|
+
let dir = dirname9(fileURLToPath2(moduleUrl));
|
|
24649
24636
|
for (let i = 0; i < 8; i += 1) {
|
|
24650
|
-
if (existsSync9(
|
|
24637
|
+
if (existsSync9(join21(dir, "package.json")) && existsSync9(join21(dir, "souls"))) {
|
|
24651
24638
|
return dir;
|
|
24652
24639
|
}
|
|
24653
|
-
const parent =
|
|
24640
|
+
const parent = dirname9(dir);
|
|
24654
24641
|
if (parent === dir) break;
|
|
24655
24642
|
dir = parent;
|
|
24656
24643
|
}
|
|
@@ -24896,12 +24883,12 @@ var init_reviewer_dispatch = __esm({
|
|
|
24896
24883
|
|
|
24897
24884
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
24898
24885
|
import { readFile as readFile14, unlink as unlink3 } from "node:fs/promises";
|
|
24899
|
-
import { join as
|
|
24886
|
+
import { join as join22 } from "node:path";
|
|
24900
24887
|
function isReviewerPreflightViolation(value) {
|
|
24901
24888
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
24902
24889
|
}
|
|
24903
24890
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
24904
|
-
return
|
|
24891
|
+
return join22(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
24905
24892
|
}
|
|
24906
24893
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
24907
24894
|
try {
|
|
@@ -25313,7 +25300,7 @@ var init_terminal = __esm({
|
|
|
25313
25300
|
// src/public-cli/settlement.ts
|
|
25314
25301
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
25315
25302
|
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile6 } from "node:fs/promises";
|
|
25316
|
-
import { dirname as
|
|
25303
|
+
import { dirname as dirname10, join as join23 } from "node:path";
|
|
25317
25304
|
function sealedLedgerHome(admitted) {
|
|
25318
25305
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
25319
25306
|
}
|
|
@@ -25688,7 +25675,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
25688
25675
|
kind: "auditor",
|
|
25689
25676
|
sessionParent: sessionFile,
|
|
25690
25677
|
// Path is driven by sessionParent when under ledger home; cwd is a fallback only.
|
|
25691
|
-
cwd:
|
|
25678
|
+
cwd: dirname10(sessionFile)
|
|
25692
25679
|
});
|
|
25693
25680
|
const { records: records2 } = await readSitianRecords(recordFile);
|
|
25694
25681
|
for (let i = records2.length - 1; i >= 0; i -= 1) {
|
|
@@ -25714,7 +25701,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
25714
25701
|
}
|
|
25715
25702
|
}
|
|
25716
25703
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
25717
|
-
const childDirectory =
|
|
25704
|
+
const childDirectory = join23(dirname10(sessionFile), "evidence-children");
|
|
25718
25705
|
let names;
|
|
25719
25706
|
try {
|
|
25720
25707
|
names = await readdir5(childDirectory);
|
|
@@ -25725,7 +25712,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
25725
25712
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
25726
25713
|
let entries;
|
|
25727
25714
|
try {
|
|
25728
|
-
entries = await readBoundSessionEntries(
|
|
25715
|
+
entries = await readBoundSessionEntries(join23(childDirectory, file));
|
|
25729
25716
|
} catch (error) {
|
|
25730
25717
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
25731
25718
|
}
|
|
@@ -25779,7 +25766,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25779
25766
|
latestParentUserIndex = i;
|
|
25780
25767
|
break;
|
|
25781
25768
|
}
|
|
25782
|
-
const childDirectories = [
|
|
25769
|
+
const childDirectories = [join23(dirname10(sessionFile), "auditor-roles")];
|
|
25783
25770
|
const valid = [];
|
|
25784
25771
|
let sawAnyDirectory = false;
|
|
25785
25772
|
for (const childDirectory of childDirectories) {
|
|
@@ -25794,7 +25781,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25794
25781
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
25795
25782
|
let entries;
|
|
25796
25783
|
try {
|
|
25797
|
-
entries = await readBoundSessionEntries(
|
|
25784
|
+
entries = await readBoundSessionEntries(join23(childDirectory, file));
|
|
25798
25785
|
} catch (error) {
|
|
25799
25786
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
25800
25787
|
}
|
|
@@ -26572,8 +26559,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
26572
26559
|
};
|
|
26573
26560
|
}
|
|
26574
26561
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
26575
|
-
const directories = [
|
|
26576
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
26562
|
+
const directories = [join23(sessionDirectory, "auditor-roles")];
|
|
26563
|
+
const parentSessionFile = options.parentSessionFile ?? join23(sessionDirectory, "session.jsonl");
|
|
26577
26564
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
26578
26565
|
parentSessionFile
|
|
26579
26566
|
});
|
|
@@ -26671,8 +26658,8 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
26671
26658
|
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
26672
26659
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26673
26660
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26674
|
-
const reportPath =
|
|
26675
|
-
const evidencePath =
|
|
26661
|
+
const reportPath = join23(artifactsDir, "report.json");
|
|
26662
|
+
const evidencePath = join23(artifactsDir, "evidence.json");
|
|
26676
26663
|
await writeFile6(
|
|
26677
26664
|
reportPath,
|
|
26678
26665
|
`${JSON.stringify(
|
|
@@ -26716,8 +26703,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
26716
26703
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26717
26704
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26718
26705
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26719
|
-
const reportPath =
|
|
26720
|
-
const evidencePath =
|
|
26706
|
+
const reportPath = join23(artifactsDir, "report.json");
|
|
26707
|
+
const evidencePath = join23(artifactsDir, "evidence.json");
|
|
26721
26708
|
await writeFile6(
|
|
26722
26709
|
reportPath,
|
|
26723
26710
|
`${JSON.stringify(
|
|
@@ -26876,8 +26863,8 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
26876
26863
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26877
26864
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26878
26865
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26879
|
-
const reportPath =
|
|
26880
|
-
const evidencePath =
|
|
26866
|
+
const reportPath = join23(artifactsDir, "report.json");
|
|
26867
|
+
const evidencePath = join23(artifactsDir, "evidence.json");
|
|
26881
26868
|
await writeFile6(
|
|
26882
26869
|
reportPath,
|
|
26883
26870
|
`${JSON.stringify(
|
|
@@ -26976,8 +26963,8 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options) {
|
|
|
26976
26963
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26977
26964
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26978
26965
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26979
|
-
const reportPath =
|
|
26980
|
-
const evidencePath =
|
|
26966
|
+
const reportPath = join23(artifactsDir, "report.json");
|
|
26967
|
+
const evidencePath = join23(artifactsDir, "evidence.json");
|
|
26981
26968
|
await writeFile6(
|
|
26982
26969
|
reportPath,
|
|
26983
26970
|
`${JSON.stringify(
|
|
@@ -27084,8 +27071,8 @@ async function trySettleCollectorTerminalResult(admitted, authority) {
|
|
|
27084
27071
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
27085
27072
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
27086
27073
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
27087
|
-
const reportPath =
|
|
27088
|
-
const evidencePath =
|
|
27074
|
+
const reportPath = join23(artifactsDir, "report.json");
|
|
27075
|
+
const evidencePath = join23(artifactsDir, "evidence.json");
|
|
27089
27076
|
await writeFile6(
|
|
27090
27077
|
reportPath,
|
|
27091
27078
|
`${JSON.stringify(
|
|
@@ -27432,14 +27419,14 @@ async function settleLawfulAuditorTerminalResult(admitted, authority, scope) {
|
|
|
27432
27419
|
return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
|
|
27433
27420
|
role: "auditor",
|
|
27434
27421
|
toolName: AUDITOR_OUTPUT_TOOL_NAME,
|
|
27435
|
-
nonUsableDiagnostic: "\u5BA1\u5211\u9662\u56DE\u6267\u65E0\u663E\u5F0F pass/
|
|
27436
|
-
// Only pass/
|
|
27422
|
+
nonUsableDiagnostic: "\u5BA1\u5211\u9662\u56DE\u6267\u65E0\u663E\u5F0F pass/bounce/escalate",
|
|
27423
|
+
// Only pass/bounce/escalate are lawful releases. Unreadable mystery status
|
|
27437
27424
|
// fails closed with candidate retained for parent ComplianceCandidateUnreadableError.
|
|
27438
27425
|
tryAcceptDetails: (details) => projectLawfulAuditorOutput(details) !== void 0,
|
|
27439
27426
|
projectAccepted: (sealed) => {
|
|
27440
27427
|
const lawful = projectLawfulAuditorOutput(sealed.decisiveFacts);
|
|
27441
27428
|
if (lawful === void 0) {
|
|
27442
|
-
throw new Error("auditor projectAccepted requires lawful pass/
|
|
27429
|
+
throw new Error("auditor projectAccepted requires lawful pass/bounce/escalate");
|
|
27443
27430
|
}
|
|
27444
27431
|
const accepted = {
|
|
27445
27432
|
kind: "accepted",
|
|
@@ -27500,8 +27487,8 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
27500
27487
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
27501
27488
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
27502
27489
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
27503
|
-
const reportPath =
|
|
27504
|
-
const evidencePath =
|
|
27490
|
+
const reportPath = join23(artifactsDir, "report.json");
|
|
27491
|
+
const evidencePath = join23(artifactsDir, "evidence.json");
|
|
27505
27492
|
await writeFile6(
|
|
27506
27493
|
reportPath,
|
|
27507
27494
|
`${JSON.stringify(
|
|
@@ -27628,8 +27615,8 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
27628
27615
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
27629
27616
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
27630
27617
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
27631
|
-
const reportPath =
|
|
27632
|
-
const evidencePath =
|
|
27618
|
+
const reportPath = join23(artifactsDir, "report.json");
|
|
27619
|
+
const evidencePath = join23(artifactsDir, "evidence.json");
|
|
27633
27620
|
await writeFile6(
|
|
27634
27621
|
reportPath,
|
|
27635
27622
|
`${JSON.stringify(
|
|
@@ -27772,13 +27759,13 @@ function publicationAttemptFromError(path, error) {
|
|
|
27772
27759
|
}
|
|
27773
27760
|
function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
27774
27761
|
const dirs = [];
|
|
27775
|
-
for (const dir of [baseDir, runDirectory,
|
|
27762
|
+
for (const dir of [baseDir, runDirectory, dirname10(runDirectory)]) {
|
|
27776
27763
|
if (!dirs.includes(dir)) dirs.push(dir);
|
|
27777
27764
|
}
|
|
27778
27765
|
return dirs;
|
|
27779
27766
|
}
|
|
27780
27767
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
27781
|
-
const artifactsDir =
|
|
27768
|
+
const artifactsDir = join23(runDirectory, "artifacts");
|
|
27782
27769
|
try {
|
|
27783
27770
|
await ensureRunArtifactsDir(runDirectory);
|
|
27784
27771
|
return { baseDir: artifactsDir };
|
|
@@ -27794,7 +27781,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
27794
27781
|
const candidates = [
|
|
27795
27782
|
...preferredCandidates,
|
|
27796
27783
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
27797
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
27784
|
+
...uniqueFallbackDirs.map((dir) => join23(dir, `${stem}.${randomUUID3()}.json`))
|
|
27798
27785
|
];
|
|
27799
27786
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
27800
27787
|
const path = candidates[i];
|
|
@@ -27839,26 +27826,26 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
27839
27826
|
} catch (error) {
|
|
27840
27827
|
priorIssues.push(publicationAttemptFromError(sessionFile, error));
|
|
27841
27828
|
}
|
|
27842
|
-
const underArtifacts = baseDir ===
|
|
27829
|
+
const underArtifacts = baseDir === join23(admitted.runDirectory, "artifacts");
|
|
27843
27830
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
27844
27831
|
admitted.runDirectory,
|
|
27845
27832
|
baseDir
|
|
27846
27833
|
);
|
|
27847
27834
|
const errorCandidates = underArtifacts ? [
|
|
27848
|
-
|
|
27849
|
-
|
|
27850
|
-
|
|
27835
|
+
join23(baseDir, "error.json"),
|
|
27836
|
+
join23(baseDir, "error.settlement.json"),
|
|
27837
|
+
join23(admitted.runDirectory, "error.settlement.json")
|
|
27851
27838
|
] : [
|
|
27852
|
-
|
|
27853
|
-
|
|
27839
|
+
join23(baseDir, "error.settlement.json"),
|
|
27840
|
+
join23(baseDir, "error.json")
|
|
27854
27841
|
];
|
|
27855
27842
|
const evidenceCandidates = underArtifacts ? [
|
|
27856
|
-
|
|
27857
|
-
|
|
27858
|
-
|
|
27843
|
+
join23(baseDir, "evidence.json"),
|
|
27844
|
+
join23(baseDir, "evidence.settlement.json"),
|
|
27845
|
+
join23(admitted.runDirectory, "evidence.settlement.json")
|
|
27859
27846
|
] : [
|
|
27860
|
-
|
|
27861
|
-
|
|
27847
|
+
join23(baseDir, "evidence.settlement.json"),
|
|
27848
|
+
join23(baseDir, "evidence.json")
|
|
27862
27849
|
];
|
|
27863
27850
|
const errorPayloadBase = {
|
|
27864
27851
|
kind: "error",
|
|
@@ -28134,7 +28121,7 @@ var init_turn_request = __esm({
|
|
|
28134
28121
|
|
|
28135
28122
|
// src/host-transition-prior-native.ts
|
|
28136
28123
|
import { access as access2, readdir as readdir6 } from "node:fs/promises";
|
|
28137
|
-
import { dirname as
|
|
28124
|
+
import { dirname as dirname11, join as join24 } from "node:path";
|
|
28138
28125
|
function isEnoent2(error) {
|
|
28139
28126
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
28140
28127
|
}
|
|
@@ -28148,7 +28135,7 @@ async function listPiNativeRecordPaths(sessionFile) {
|
|
|
28148
28135
|
}
|
|
28149
28136
|
}
|
|
28150
28137
|
async function listSitianRecordPaths(sessionParent) {
|
|
28151
|
-
const sessionRoot =
|
|
28138
|
+
const sessionRoot = dirname11(sessionParent);
|
|
28152
28139
|
let entries;
|
|
28153
28140
|
try {
|
|
28154
28141
|
entries = await readdir6(sessionRoot, { withFileTypes: true });
|
|
@@ -28159,7 +28146,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
28159
28146
|
const recordPaths = [];
|
|
28160
28147
|
for (const entry of entries) {
|
|
28161
28148
|
if (!entry.isDirectory()) continue;
|
|
28162
|
-
const recordFile =
|
|
28149
|
+
const recordFile = join24(sessionRoot, entry.name, "records.jsonl");
|
|
28163
28150
|
try {
|
|
28164
28151
|
await access2(recordFile);
|
|
28165
28152
|
recordPaths.push(recordFile);
|
|
@@ -28229,7 +28216,7 @@ var init_public_run_credentials = __esm({
|
|
|
28229
28216
|
import { constants as fsConstants } from "node:fs";
|
|
28230
28217
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
28231
28218
|
import { lstat as lstat5, mkdir as mkdir4, open as open2 } from "node:fs/promises";
|
|
28232
|
-
import { join as
|
|
28219
|
+
import { join as join25 } from "node:path";
|
|
28233
28220
|
function presentTerminal(terminal, io) {
|
|
28234
28221
|
if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
|
|
28235
28222
|
presentFailureTerminal(terminal, io);
|
|
@@ -28248,7 +28235,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
|
|
|
28248
28235
|
}
|
|
28249
28236
|
}
|
|
28250
28237
|
function runArtifactsDirectory(runDirectory) {
|
|
28251
|
-
return
|
|
28238
|
+
return join25(runDirectory, "artifacts");
|
|
28252
28239
|
}
|
|
28253
28240
|
async function ensureRealArtifactsDirectory(runDirectory) {
|
|
28254
28241
|
const runStat = await lstat5(runDirectory);
|
|
@@ -28331,7 +28318,7 @@ function jsonSafeReplacer() {
|
|
|
28331
28318
|
}
|
|
28332
28319
|
async function retainDispatchError(admitted, principalAuthority, sessionAppender, attempt, error) {
|
|
28333
28320
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
28334
|
-
const filePath =
|
|
28321
|
+
const filePath = join25(
|
|
28335
28322
|
artifactsDir,
|
|
28336
28323
|
`dispatch-error-attempt-${attempt}-${randomUUID4()}.json`
|
|
28337
28324
|
);
|
|
@@ -28580,10 +28567,10 @@ var init_auto_resume = __esm({
|
|
|
28580
28567
|
// src/public-cli/post-admission.ts
|
|
28581
28568
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
28582
28569
|
import { readFile as readFile16, writeFile as writeFile7 } from "node:fs/promises";
|
|
28583
|
-
import { isAbsolute as isAbsolute7, join as
|
|
28570
|
+
import { isAbsolute as isAbsolute7, join as join26, resolve as resolve9 } from "node:path";
|
|
28584
28571
|
async function readInvocationHost(runDirectory) {
|
|
28585
28572
|
try {
|
|
28586
|
-
const raw = JSON.parse(await readFile16(
|
|
28573
|
+
const raw = JSON.parse(await readFile16(join26(runDirectory, "invocation.json"), "utf8"));
|
|
28587
28574
|
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
|
|
28588
28575
|
} catch (error) {
|
|
28589
28576
|
if (error.code === "ENOENT") return void 0;
|
|
@@ -28723,7 +28710,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28723
28710
|
}
|
|
28724
28711
|
try {
|
|
28725
28712
|
await writeFile7(
|
|
28726
|
-
|
|
28713
|
+
join26(admitted.runDirectory, "stderr.log"),
|
|
28727
28714
|
result2.stderr,
|
|
28728
28715
|
"utf8"
|
|
28729
28716
|
);
|
|
@@ -28789,24 +28776,16 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28789
28776
|
}
|
|
28790
28777
|
}
|
|
28791
28778
|
function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
|
|
28792
|
-
const engineMaterial = engineSessionMaterialFromOptions({
|
|
28793
|
-
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
28794
|
-
packageRoot: env.packageRoot
|
|
28795
|
-
});
|
|
28796
28779
|
let prompt;
|
|
28797
28780
|
if (request.message !== void 0) {
|
|
28798
|
-
if (summonsPrepared !== void 0
|
|
28799
|
-
prompt =
|
|
28800
|
-
|
|
28801
|
-
|
|
28802
|
-
|
|
28803
|
-
|
|
28804
|
-
|
|
28805
|
-
|
|
28806
|
-
engineMaterial
|
|
28807
|
-
),
|
|
28808
|
-
engineMaterial
|
|
28809
|
-
);
|
|
28781
|
+
if (summonsPrepared !== void 0) {
|
|
28782
|
+
prompt = buildInstructionTransportPrompt({
|
|
28783
|
+
instruction: request.message,
|
|
28784
|
+
instructionEmpty: false,
|
|
28785
|
+
attachments: summonsPrepared.attachments
|
|
28786
|
+
});
|
|
28787
|
+
} else if (request.summons !== void 0) {
|
|
28788
|
+
prompt = request.message;
|
|
28810
28789
|
} else {
|
|
28811
28790
|
prompt = buildResumeContinuationPrompt({
|
|
28812
28791
|
packageRoot: env.packageRoot,
|
|
@@ -28815,10 +28794,9 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
28815
28794
|
});
|
|
28816
28795
|
}
|
|
28817
28796
|
} else if (summonsPrepared !== void 0) {
|
|
28818
|
-
prompt =
|
|
28819
|
-
|
|
28820
|
-
|
|
28821
|
-
);
|
|
28797
|
+
prompt = buildInstructionTransportPrompt(summonsPrepared);
|
|
28798
|
+
} else if (request.summons !== void 0) {
|
|
28799
|
+
prompt = RESUME_TRANSPORT_ENVELOPE;
|
|
28822
28800
|
} else {
|
|
28823
28801
|
prompt = buildResumeContinuationPrompt({
|
|
28824
28802
|
packageRoot: env.packageRoot,
|
|
@@ -28840,8 +28818,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
28840
28818
|
};
|
|
28841
28819
|
}
|
|
28842
28820
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
28843
|
-
const absolute = isAbsolute7(attachmentPath) ? attachmentPath :
|
|
28844
|
-
return pathContainedIn(
|
|
28821
|
+
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve9(attachmentPath);
|
|
28822
|
+
return pathContainedIn(join26(runDirectory, "attachments"), absolute);
|
|
28845
28823
|
}
|
|
28846
28824
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
28847
28825
|
if (summons === void 0) return void 0;
|
|
@@ -29133,7 +29111,6 @@ var init_post_admission = __esm({
|
|
|
29133
29111
|
init_cli_errors();
|
|
29134
29112
|
init_invocation();
|
|
29135
29113
|
init_activation_ledger_topology();
|
|
29136
|
-
init_engine_material();
|
|
29137
29114
|
init_host_transition_prior_native();
|
|
29138
29115
|
init_public_run_credentials();
|
|
29139
29116
|
init_run_lifecycle();
|
|
@@ -29892,7 +29869,7 @@ var init_countersign_run = __esm({
|
|
|
29892
29869
|
// src/public-cli/diarist-run.ts
|
|
29893
29870
|
import { existsSync as existsSync10 } from "node:fs";
|
|
29894
29871
|
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
29895
|
-
import { join as
|
|
29872
|
+
import { join as join27 } from "node:path";
|
|
29896
29873
|
function withDiaristCatalogPath(prompt, sourcesPath) {
|
|
29897
29874
|
if (sourcesPath === void 0 || sourcesPath.trim() === "") return prompt;
|
|
29898
29875
|
return `${prompt}
|
|
@@ -29918,7 +29895,7 @@ function buildDiaristTurnRequest(admitted, options, sourcesPath) {
|
|
|
29918
29895
|
}
|
|
29919
29896
|
async function freezeDiaristSourceCatalog(admitted, env) {
|
|
29920
29897
|
if (admitted.ticketNumber === void 0) return void 0;
|
|
29921
|
-
const path =
|
|
29898
|
+
const path = join27(admitted.runDirectory, DIARIST_SOURCE_CATALOG_FILE);
|
|
29922
29899
|
if (existsSync10(path)) {
|
|
29923
29900
|
const identity = await readRoleRunIdentity(admitted.runDirectory);
|
|
29924
29901
|
if (identity !== void 0 && identity.state !== "terminal") return path;
|
|
@@ -30466,7 +30443,6 @@ var init_fixer_run = __esm({
|
|
|
30466
30443
|
});
|
|
30467
30444
|
|
|
30468
30445
|
// src/public-cli/notary-run.ts
|
|
30469
|
-
import { existsSync as existsSync11 } from "node:fs";
|
|
30470
30446
|
function buildNotaryTurnRequest(admitted, options) {
|
|
30471
30447
|
return projectRoleTurnRequest(
|
|
30472
30448
|
admitted,
|
|
@@ -30608,19 +30584,14 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
30608
30584
|
}
|
|
30609
30585
|
return loaded;
|
|
30610
30586
|
},
|
|
30611
|
-
buildTurnRequest: (admitted, effective) =>
|
|
30612
|
-
|
|
30587
|
+
buildTurnRequest: (admitted, effective) => (
|
|
30588
|
+
// #755: review continuation is plain dialogue / resume envelope — no
|
|
30589
|
+
//「重新读」candidate line, no engine handbook packaging.
|
|
30590
|
+
buildNotaryTurnRequest(
|
|
30613
30591
|
admitted,
|
|
30614
|
-
effective,
|
|
30615
|
-
|
|
30616
|
-
|
|
30617
|
-
const candidatePath = gateSubmissionCandidatePath(admitted.sourceRunPath);
|
|
30618
|
-
const prompt = existsSync11(candidatePath) ? appendResumeMaterialReread(projection.continuation.prompt, candidatePath) : projection.continuation.prompt;
|
|
30619
|
-
return buildNotaryTurnRequest(admitted, {
|
|
30620
|
-
...projection,
|
|
30621
|
-
continuation: { kind: "resume", prompt }
|
|
30622
|
-
});
|
|
30623
|
-
},
|
|
30592
|
+
resumeTurnRequestProjectionOptions(admitted, effective, env)
|
|
30593
|
+
)
|
|
30594
|
+
),
|
|
30624
30595
|
adapters: notaryAdapters(),
|
|
30625
30596
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
30626
30597
|
});
|
|
@@ -30628,7 +30599,6 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
30628
30599
|
var init_notary_run = __esm({
|
|
30629
30600
|
"src/public-cli/notary-run.ts"() {
|
|
30630
30601
|
"use strict";
|
|
30631
|
-
init_auditor_dossier_tool();
|
|
30632
30602
|
init_notary_source_run();
|
|
30633
30603
|
init_engine_material();
|
|
30634
30604
|
init_cli_errors();
|
|
@@ -30910,7 +30880,7 @@ var init_judge_run = __esm({
|
|
|
30910
30880
|
|
|
30911
30881
|
// src/public-cli/merger-run.ts
|
|
30912
30882
|
import { mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
|
|
30913
|
-
import { join as
|
|
30883
|
+
import { join as join28, resolve as resolve10 } from "node:path";
|
|
30914
30884
|
function mergerMethods(packageRoot2) {
|
|
30915
30885
|
return [
|
|
30916
30886
|
{
|
|
@@ -30952,7 +30922,7 @@ async function loadMergerMethodMaterial(packageRoot2) {
|
|
|
30952
30922
|
);
|
|
30953
30923
|
}
|
|
30954
30924
|
async function admitMergerShellForActivationFailure(options) {
|
|
30955
|
-
const projectRoot =
|
|
30925
|
+
const projectRoot = resolve10(options.project ?? options.cwd);
|
|
30956
30926
|
const runId = (options.createRunId ?? uuidv7)();
|
|
30957
30927
|
const {
|
|
30958
30928
|
principal,
|
|
@@ -30976,8 +30946,8 @@ async function admitMergerShellForActivationFailure(options) {
|
|
|
30976
30946
|
expectedConflictPaths: [],
|
|
30977
30947
|
resolutionScope: []
|
|
30978
30948
|
};
|
|
30979
|
-
const admittedRequestPath =
|
|
30980
|
-
const mergerInputPath =
|
|
30949
|
+
const admittedRequestPath = join28(runDirectory, "admitted-request.json");
|
|
30950
|
+
const mergerInputPath = join28(runDirectory, "merger-input.json");
|
|
30981
30951
|
await writeFile9(
|
|
30982
30952
|
admittedRequestPath,
|
|
30983
30953
|
`${JSON.stringify(
|
|
@@ -31417,10 +31387,10 @@ var init_analyst_book_key = __esm({
|
|
|
31417
31387
|
// src/atomic-write.ts
|
|
31418
31388
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
31419
31389
|
import { rename, rm as rm2, writeFile as writeFile10 } from "node:fs/promises";
|
|
31420
|
-
import { dirname as
|
|
31390
|
+
import { dirname as dirname12, join as join29 } from "node:path";
|
|
31421
31391
|
async function writeFileAtomically(destination, contents) {
|
|
31422
|
-
const parent =
|
|
31423
|
-
const temporary =
|
|
31392
|
+
const parent = dirname12(destination);
|
|
31393
|
+
const temporary = join29(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
31424
31394
|
try {
|
|
31425
31395
|
await writeFile10(temporary, contents);
|
|
31426
31396
|
await rename(temporary, destination);
|
|
@@ -31437,16 +31407,16 @@ var init_atomic_write = __esm({
|
|
|
31437
31407
|
|
|
31438
31408
|
// src/analyst-index.ts
|
|
31439
31409
|
import { open as open3, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
31440
|
-
import { dirname as
|
|
31410
|
+
import { dirname as dirname13, join as join30 } from "node:path";
|
|
31441
31411
|
function sleep(ms) {
|
|
31442
|
-
return new Promise((
|
|
31443
|
-
setTimeout(
|
|
31412
|
+
return new Promise((resolve12) => {
|
|
31413
|
+
setTimeout(resolve12, ms);
|
|
31444
31414
|
});
|
|
31445
31415
|
}
|
|
31446
31416
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
31447
31417
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
31448
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
31449
|
-
const lockPath =
|
|
31418
|
+
ensureRealDirectoryTree(ledgerHome, dirname13(indexPath));
|
|
31419
|
+
const lockPath = join30(dirname13(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
31450
31420
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
31451
31421
|
const startedAt = Date.now();
|
|
31452
31422
|
while (true) {
|
|
@@ -31473,7 +31443,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
31473
31443
|
}
|
|
31474
31444
|
}
|
|
31475
31445
|
function analystLibraryIndexPath(ledgerHome) {
|
|
31476
|
-
return
|
|
31446
|
+
return join30(ledgerHome, "analyst", "library-index.json");
|
|
31477
31447
|
}
|
|
31478
31448
|
function rowFromIssueMetricsPage(page) {
|
|
31479
31449
|
return {
|
|
@@ -31582,7 +31552,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
31582
31552
|
}
|
|
31583
31553
|
async function writeAnalystLibraryIndexPage(ledgerHome, page) {
|
|
31584
31554
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
31585
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
31555
|
+
ensureRealDirectoryTree(ledgerHome, dirname13(path));
|
|
31586
31556
|
assertLedgerFileInsideHome(path, ledgerHome);
|
|
31587
31557
|
await writeFileAtomically(path, `${JSON.stringify(page, null, 2)}
|
|
31588
31558
|
`);
|
|
@@ -31769,7 +31739,7 @@ var init_analyst_cohort = __esm({
|
|
|
31769
31739
|
|
|
31770
31740
|
// src/analyst-ledger.ts
|
|
31771
31741
|
import { readdir as readdir7, readFile as readFile18 } from "node:fs/promises";
|
|
31772
|
-
import { join as
|
|
31742
|
+
import { join as join31 } from "node:path";
|
|
31773
31743
|
function isMissingPathError5(error) {
|
|
31774
31744
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
31775
31745
|
}
|
|
@@ -31782,7 +31752,7 @@ function isRecord19(value) {
|
|
|
31782
31752
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
31783
31753
|
try {
|
|
31784
31754
|
const raw = JSON.parse(
|
|
31785
|
-
await readFile18(
|
|
31755
|
+
await readFile18(join31(runDirectory, "run-state.json"), "utf8")
|
|
31786
31756
|
);
|
|
31787
31757
|
if (!isRecord19(raw) || typeof raw.state !== "string") return void 0;
|
|
31788
31758
|
return raw.state;
|
|
@@ -31814,7 +31784,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
31814
31784
|
async function readInvocationScopeFields(runDirectory) {
|
|
31815
31785
|
let raw;
|
|
31816
31786
|
try {
|
|
31817
|
-
raw = await readFile18(
|
|
31787
|
+
raw = await readFile18(join31(runDirectory, "invocation.json"), "utf8");
|
|
31818
31788
|
} catch (error) {
|
|
31819
31789
|
if (isMissingPathError5(error)) return void 0;
|
|
31820
31790
|
throw error;
|
|
@@ -31846,7 +31816,7 @@ function decideIssueScope(input) {
|
|
|
31846
31816
|
}
|
|
31847
31817
|
async function resolveSessionFile(runDirectory) {
|
|
31848
31818
|
try {
|
|
31849
|
-
const raw = await readFile18(
|
|
31819
|
+
const raw = await readFile18(join31(runDirectory, "invocation.json"), "utf8");
|
|
31850
31820
|
const parsed = JSON.parse(raw);
|
|
31851
31821
|
if (isRecord19(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
31852
31822
|
return parsed.sessionFile;
|
|
@@ -31854,7 +31824,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
31854
31824
|
} catch (error) {
|
|
31855
31825
|
if (!isMissingPathError5(error)) throw error;
|
|
31856
31826
|
}
|
|
31857
|
-
return
|
|
31827
|
+
return join31(runDirectory, "session", "session.jsonl");
|
|
31858
31828
|
}
|
|
31859
31829
|
function attributeSessionRowsForRun(input) {
|
|
31860
31830
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -32026,9 +31996,9 @@ async function classifyScopedRun(input) {
|
|
|
32026
31996
|
}
|
|
32027
31997
|
let gateCycles;
|
|
32028
31998
|
try {
|
|
32029
|
-
const parentSessionFile =
|
|
31999
|
+
const parentSessionFile = join31(input.runDirectory, "session", "session.jsonl");
|
|
32030
32000
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
32031
|
-
|
|
32001
|
+
join31(input.runDirectory, "session", "auditor-roles"),
|
|
32032
32002
|
{ parentSessionFile }
|
|
32033
32003
|
);
|
|
32034
32004
|
} catch (error) {
|
|
@@ -32061,7 +32031,7 @@ async function classifyScopedRun(input) {
|
|
|
32061
32031
|
async function scanAnalystIssueRuns(input) {
|
|
32062
32032
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
32063
32033
|
const scopeTicketNumber = input.ticketNumber;
|
|
32064
|
-
const booksRoot =
|
|
32034
|
+
const booksRoot = join31(ledgerHome, "books");
|
|
32065
32035
|
let wholeBook = false;
|
|
32066
32036
|
let scopeRootIdentity;
|
|
32067
32037
|
let bookNames;
|
|
@@ -32093,7 +32063,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
32093
32063
|
const unreadable = [];
|
|
32094
32064
|
const scopeConflicts = [];
|
|
32095
32065
|
for (const book of bookNames) {
|
|
32096
|
-
const runsDir =
|
|
32066
|
+
const runsDir = join31(booksRoot, book, "runs");
|
|
32097
32067
|
let runNames;
|
|
32098
32068
|
try {
|
|
32099
32069
|
const entries = await readdir7(runsDir, { withFileTypes: true });
|
|
@@ -32105,7 +32075,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
32105
32075
|
for (const runName of runNames) {
|
|
32106
32076
|
const parsed = parseRunDirectoryName2(runName);
|
|
32107
32077
|
if (parsed === void 0) continue;
|
|
32108
|
-
const runDirectory =
|
|
32078
|
+
const runDirectory = join31(runsDir, runName);
|
|
32109
32079
|
let scopeFields;
|
|
32110
32080
|
try {
|
|
32111
32081
|
scopeFields = await readInvocationScopeFields(runDirectory);
|
|
@@ -32959,7 +32929,7 @@ var init_analyst_metric_family = __esm({
|
|
|
32959
32929
|
|
|
32960
32930
|
// src/analyst-page.ts
|
|
32961
32931
|
import { createHash as createHash7 } from "node:crypto";
|
|
32962
|
-
import { dirname as
|
|
32932
|
+
import { dirname as dirname14, join as join32 } from "node:path";
|
|
32963
32933
|
function analystIssuePageKey(address) {
|
|
32964
32934
|
const parts = ["book", address.bookKey];
|
|
32965
32935
|
if (address.issueNumber !== void 0) {
|
|
@@ -32970,7 +32940,7 @@ function analystIssuePageKey(address) {
|
|
|
32970
32940
|
return createHash7("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
32971
32941
|
}
|
|
32972
32942
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32973
|
-
return
|
|
32943
|
+
return join32(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
32974
32944
|
}
|
|
32975
32945
|
function analystIssuePageAddressFromPage(page) {
|
|
32976
32946
|
return {
|
|
@@ -33089,7 +33059,7 @@ async function buildAnalystIssueMetricsPage(input) {
|
|
|
33089
33059
|
}
|
|
33090
33060
|
async function writeAnalystIssueMetricsPage(ledgerHome, page) {
|
|
33091
33061
|
const path = analystIssuePagePath(ledgerHome, analystIssuePageAddressFromPage(page));
|
|
33092
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
33062
|
+
ensureRealDirectoryTree(ledgerHome, dirname14(path));
|
|
33093
33063
|
assertLedgerFileInsideHome(path, ledgerHome);
|
|
33094
33064
|
await writeFileAtomically(path, `${JSON.stringify(page, null, 2)}
|
|
33095
33065
|
`);
|
|
@@ -33331,7 +33301,7 @@ var init_analyst_entry = __esm({
|
|
|
33331
33301
|
|
|
33332
33302
|
// src/public-cli/analyst-run.ts
|
|
33333
33303
|
import { readFile as readFile20 } from "node:fs/promises";
|
|
33334
|
-
import { isAbsolute as isAbsolute9, resolve as
|
|
33304
|
+
import { isAbsolute as isAbsolute9, resolve as resolve11 } from "node:path";
|
|
33335
33305
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
33336
33306
|
try {
|
|
33337
33307
|
return resolveBookKeyFromGit(cwd);
|
|
@@ -33380,7 +33350,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
33380
33350
|
);
|
|
33381
33351
|
}
|
|
33382
33352
|
const sourcePath = attachmentPaths[0];
|
|
33383
|
-
const absolute = isAbsolute9(sourcePath) ? sourcePath :
|
|
33353
|
+
const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve11(sourcePath);
|
|
33384
33354
|
let bytes;
|
|
33385
33355
|
try {
|
|
33386
33356
|
bytes = await readFile20(absolute);
|
|
@@ -33503,7 +33473,7 @@ __export(cli_exports, {
|
|
|
33503
33473
|
runAkRole: () => runAkRole
|
|
33504
33474
|
});
|
|
33505
33475
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
33506
|
-
import { join as
|
|
33476
|
+
import { join as join33 } from "node:path";
|
|
33507
33477
|
function takePublicGlobalFlag(argv, index, options) {
|
|
33508
33478
|
const tokens = argv.slice(index);
|
|
33509
33479
|
const taken = options.takeDashed(tokens);
|
|
@@ -33635,7 +33605,7 @@ function resolveHome(env) {
|
|
|
33635
33605
|
return env.home ?? packageMachineHome();
|
|
33636
33606
|
}
|
|
33637
33607
|
function resolveAgentDir(env, home) {
|
|
33638
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
33608
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join33(home, ".pi", "agent");
|
|
33639
33609
|
}
|
|
33640
33610
|
function parseThinking(value) {
|
|
33641
33611
|
return value;
|
|
@@ -34592,8 +34562,8 @@ var init_cli = __esm({
|
|
|
34592
34562
|
});
|
|
34593
34563
|
|
|
34594
34564
|
// src/public-cli/main.ts
|
|
34595
|
-
import { existsSync as
|
|
34596
|
-
import { dirname as
|
|
34565
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
34566
|
+
import { dirname as dirname15, join as join34 } from "node:path";
|
|
34597
34567
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
34598
34568
|
|
|
34599
34569
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -34680,10 +34650,10 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
34680
34650
|
}
|
|
34681
34651
|
|
|
34682
34652
|
// src/public-cli/main.ts
|
|
34683
|
-
var here =
|
|
34653
|
+
var here = dirname15(fileURLToPath3(import.meta.url));
|
|
34684
34654
|
function resolvePackageRoot(binDir) {
|
|
34685
|
-
const canonical =
|
|
34686
|
-
if (
|
|
34655
|
+
const canonical = join34(binDir, "..", "..");
|
|
34656
|
+
if (existsSync11(join34(canonical, "package.json"))) {
|
|
34687
34657
|
return canonical;
|
|
34688
34658
|
}
|
|
34689
34659
|
return binDir;
|