@akagilnc/pi-workflow-roles 0.1.3661 → 0.1.3669
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 +52 -28
- package/dist/public-cli/case-dossier-delivery.js +5 -2
- package/dist/public-cli/main.js +378 -291
- package/dist/public-cli/notary-run.js +20 -5
- package/dist/public-cli/post-admission.js +28 -35
- package/dist/public-cli/run-lifecycle.js +14 -6
- package/package.json +1 -1
- package/src/public-cli/case-dossier-delivery.ts +5 -2
- package/src/public-cli/countersign-run.ts +105 -12
- package/src/public-cli/notary-run.ts +18 -6
- package/src/public-cli/post-admission.ts +42 -36
- package/src/public-cli/run-lifecycle.ts +17 -6
package/dist/public-cli/main.js
CHANGED
|
@@ -17275,6 +17275,13 @@ function instructResumeHandbookRead(prompt, engineMaterial) {
|
|
|
17275
17275
|
return line2;
|
|
17276
17276
|
}).join("\n");
|
|
17277
17277
|
}
|
|
17278
|
+
function appendResumeMaterialReread(prompt, materialPath) {
|
|
17279
|
+
const instruction = resumeRereadInstruction(materialPath, false);
|
|
17280
|
+
const lines = prompt.split("\n");
|
|
17281
|
+
if (lines.includes(instruction)) return prompt;
|
|
17282
|
+
return prompt.length === 0 ? instruction : `${prompt}
|
|
17283
|
+
${instruction}`;
|
|
17284
|
+
}
|
|
17278
17285
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
17279
17286
|
const base = message !== void 0 ? message : RESUME_TRANSPORT_ENVELOPE;
|
|
17280
17287
|
return instructResumeHandbookRead(
|
|
@@ -22322,10 +22329,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
22322
22329
|
});
|
|
22323
22330
|
|
|
22324
22331
|
// src/auditor-dossier-tool.ts
|
|
22332
|
+
import { dirname as dirname8, join as join16, resolve as resolve8 } from "node:path";
|
|
22333
|
+
function gateSubmissionCandidatePath(runDirectory) {
|
|
22334
|
+
return join16(runDirectory, "artifacts", GATE_SUBMISSION_CANDIDATE_FILE);
|
|
22335
|
+
}
|
|
22336
|
+
var GATE_SUBMISSION_CANDIDATE_FILE;
|
|
22325
22337
|
var init_auditor_dossier_tool = __esm({
|
|
22326
22338
|
"src/auditor-dossier-tool.ts"() {
|
|
22327
22339
|
"use strict";
|
|
22328
22340
|
init_build();
|
|
22341
|
+
GATE_SUBMISSION_CANDIDATE_FILE = "gate-submission-candidate.json";
|
|
22329
22342
|
}
|
|
22330
22343
|
});
|
|
22331
22344
|
|
|
@@ -22525,7 +22538,7 @@ var init_ledger_session_read = __esm({
|
|
|
22525
22538
|
|
|
22526
22539
|
// src/analyst-gate-cycles-read.ts
|
|
22527
22540
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
22528
|
-
import { join as
|
|
22541
|
+
import { join as join17 } from "node:path";
|
|
22529
22542
|
function isRecord12(value) {
|
|
22530
22543
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22531
22544
|
}
|
|
@@ -22786,7 +22799,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
22786
22799
|
throw error;
|
|
22787
22800
|
}
|
|
22788
22801
|
for (const name of names) {
|
|
22789
|
-
const path =
|
|
22802
|
+
const path = join17(directory, name);
|
|
22790
22803
|
const sessionPath = name.endsWith(".pointer.json") ? await resolveOfficerSessionFromPointerFile(path) : path;
|
|
22791
22804
|
if (sessionPath === void 0) continue;
|
|
22792
22805
|
const classified = await classifyAuditorVolume(sessionPath);
|
|
@@ -22846,7 +22859,7 @@ var init_gatekeeper_role = __esm({
|
|
|
22846
22859
|
|
|
22847
22860
|
// src/run-terminal-artifacts.ts
|
|
22848
22861
|
import { readdir as readdir4, readFile as readFile12 } from "node:fs/promises";
|
|
22849
|
-
import { basename as basename6, dirname as
|
|
22862
|
+
import { basename as basename6, dirname as dirname9, join as join18 } from "node:path";
|
|
22850
22863
|
function isMissingPathError2(error) {
|
|
22851
22864
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
22852
22865
|
}
|
|
@@ -22921,7 +22934,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
22921
22934
|
}
|
|
22922
22935
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
22923
22936
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
22924
|
-
found.push(
|
|
22937
|
+
found.push(join18(dir, name));
|
|
22925
22938
|
}
|
|
22926
22939
|
}
|
|
22927
22940
|
return found;
|
|
@@ -22937,14 +22950,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
22937
22950
|
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
22938
22951
|
}
|
|
22939
22952
|
async function readRunTerminalArtifact(runDirectory) {
|
|
22940
|
-
const artifactsDir =
|
|
22953
|
+
const artifactsDir = join18(runDirectory, "artifacts");
|
|
22941
22954
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
22942
|
-
const path =
|
|
22955
|
+
const path = join18(artifactsDir, file);
|
|
22943
22956
|
const read3 = await readTerminalArtifactAtPath(path, file);
|
|
22944
22957
|
if (read3 !== void 0) return read3;
|
|
22945
22958
|
}
|
|
22946
22959
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
22947
|
-
const path =
|
|
22960
|
+
const path = join18(runDirectory, relative3);
|
|
22948
22961
|
const read3 = await readTerminalArtifactAtPath(path, "error.json");
|
|
22949
22962
|
if (read3 !== void 0) return read3;
|
|
22950
22963
|
}
|
|
@@ -22953,7 +22966,7 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
22953
22966
|
if (read3 !== void 0) return read3;
|
|
22954
22967
|
}
|
|
22955
22968
|
const expectedRunId = runIdFromRunDirectory(runDirectory);
|
|
22956
|
-
for (const path of await listUniqueErrorFallbackPaths([
|
|
22969
|
+
for (const path of await listUniqueErrorFallbackPaths([dirname9(runDirectory)])) {
|
|
22957
22970
|
const read3 = await readTerminalArtifactAtPath(path, "error.json");
|
|
22958
22971
|
if (read3 === void 0) continue;
|
|
22959
22972
|
if (read3.status === "present") {
|
|
@@ -23085,15 +23098,15 @@ var init_submission_ledger = __esm({
|
|
|
23085
23098
|
// src/session-opening-materials.ts
|
|
23086
23099
|
import { existsSync as existsSync8 } from "node:fs";
|
|
23087
23100
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
23088
|
-
import { dirname as
|
|
23101
|
+
import { dirname as dirname10, join as join19 } from "node:path";
|
|
23089
23102
|
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
23090
23103
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
23091
|
-
let dir =
|
|
23104
|
+
let dir = dirname10(fileURLToPath(moduleUrl));
|
|
23092
23105
|
for (let i = 0; i < 8; i += 1) {
|
|
23093
|
-
if (existsSync8(
|
|
23106
|
+
if (existsSync8(join19(dir, "package.json")) && existsSync8(join19(dir, "souls"))) {
|
|
23094
23107
|
return dir;
|
|
23095
23108
|
}
|
|
23096
|
-
const parent =
|
|
23109
|
+
const parent = dirname10(dir);
|
|
23097
23110
|
if (parent === dir) break;
|
|
23098
23111
|
dir = parent;
|
|
23099
23112
|
}
|
|
@@ -23416,12 +23429,12 @@ var init_reviewer_dispatch = __esm({
|
|
|
23416
23429
|
|
|
23417
23430
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
23418
23431
|
import { readFile as readFile14, unlink as unlink3 } from "node:fs/promises";
|
|
23419
|
-
import { join as
|
|
23432
|
+
import { join as join20 } from "node:path";
|
|
23420
23433
|
function isReviewerPreflightViolation(value) {
|
|
23421
23434
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
23422
23435
|
}
|
|
23423
23436
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
23424
|
-
return
|
|
23437
|
+
return join20(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
23425
23438
|
}
|
|
23426
23439
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
23427
23440
|
try {
|
|
@@ -23630,7 +23643,7 @@ function normalizeReviewComment(raw) {
|
|
|
23630
23643
|
function createGhApiRunner(options = {}) {
|
|
23631
23644
|
const spawnImpl = options.spawnImpl ?? spawn2;
|
|
23632
23645
|
return async (args, runOptions = {}) => {
|
|
23633
|
-
return await new Promise((
|
|
23646
|
+
return await new Promise((resolve13, reject) => {
|
|
23634
23647
|
const signal = runOptions.signal;
|
|
23635
23648
|
if (signal?.aborted) {
|
|
23636
23649
|
reject(signal.reason ?? new Error("aborted"));
|
|
@@ -23703,11 +23716,11 @@ function createGhApiRunner(options = {}) {
|
|
|
23703
23716
|
const value = line2.slice(idx + 1).trim();
|
|
23704
23717
|
headers[name] = value;
|
|
23705
23718
|
}
|
|
23706
|
-
|
|
23719
|
+
resolve13({ status, headers, bodyText });
|
|
23707
23720
|
return;
|
|
23708
23721
|
}
|
|
23709
23722
|
if (code === 0) {
|
|
23710
|
-
|
|
23723
|
+
resolve13({ status: 200, headers: {}, bodyText: stdout });
|
|
23711
23724
|
return;
|
|
23712
23725
|
}
|
|
23713
23726
|
const failure = new Error(
|
|
@@ -24285,7 +24298,7 @@ var init_terminal = __esm({
|
|
|
24285
24298
|
// src/public-cli/settlement.ts
|
|
24286
24299
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
24287
24300
|
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile5 } from "node:fs/promises";
|
|
24288
|
-
import { dirname as
|
|
24301
|
+
import { dirname as dirname11, join as join21 } from "node:path";
|
|
24289
24302
|
function sealedLedgerHome(admitted) {
|
|
24290
24303
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
24291
24304
|
}
|
|
@@ -24660,7 +24673,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
24660
24673
|
kind: "auditor",
|
|
24661
24674
|
sessionParent: sessionFile,
|
|
24662
24675
|
// Path is driven by sessionParent when under ledger home; cwd is a fallback only.
|
|
24663
|
-
cwd:
|
|
24676
|
+
cwd: dirname11(sessionFile)
|
|
24664
24677
|
});
|
|
24665
24678
|
const { records: records2 } = await readSitianRecords(recordFile);
|
|
24666
24679
|
for (let i = records2.length - 1; i >= 0; i -= 1) {
|
|
@@ -24686,7 +24699,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
24686
24699
|
}
|
|
24687
24700
|
}
|
|
24688
24701
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
24689
|
-
const childDirectory =
|
|
24702
|
+
const childDirectory = join21(dirname11(sessionFile), "evidence-children");
|
|
24690
24703
|
let names;
|
|
24691
24704
|
try {
|
|
24692
24705
|
names = await readdir5(childDirectory);
|
|
@@ -24697,7 +24710,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
24697
24710
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
24698
24711
|
let entries;
|
|
24699
24712
|
try {
|
|
24700
|
-
entries = await readBoundSessionEntries(
|
|
24713
|
+
entries = await readBoundSessionEntries(join21(childDirectory, file));
|
|
24701
24714
|
} catch (error) {
|
|
24702
24715
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
24703
24716
|
}
|
|
@@ -24751,7 +24764,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24751
24764
|
latestParentUserIndex = i;
|
|
24752
24765
|
break;
|
|
24753
24766
|
}
|
|
24754
|
-
const childDirectories = [
|
|
24767
|
+
const childDirectories = [join21(dirname11(sessionFile), "auditor-roles")];
|
|
24755
24768
|
const valid = [];
|
|
24756
24769
|
let sawAnyDirectory = false;
|
|
24757
24770
|
for (const childDirectory of childDirectories) {
|
|
@@ -24766,7 +24779,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24766
24779
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
24767
24780
|
let entries;
|
|
24768
24781
|
try {
|
|
24769
|
-
entries = await readBoundSessionEntries(
|
|
24782
|
+
entries = await readBoundSessionEntries(join21(childDirectory, file));
|
|
24770
24783
|
} catch (error) {
|
|
24771
24784
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
24772
24785
|
}
|
|
@@ -25298,8 +25311,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
25298
25311
|
};
|
|
25299
25312
|
}
|
|
25300
25313
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
25301
|
-
const directories = [
|
|
25302
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
25314
|
+
const directories = [join21(sessionDirectory, "auditor-roles")];
|
|
25315
|
+
const parentSessionFile = options.parentSessionFile ?? join21(sessionDirectory, "session.jsonl");
|
|
25303
25316
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
25304
25317
|
parentSessionFile
|
|
25305
25318
|
});
|
|
@@ -25397,8 +25410,8 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
25397
25410
|
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
25398
25411
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25399
25412
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25400
|
-
const reportPath =
|
|
25401
|
-
const evidencePath =
|
|
25413
|
+
const reportPath = join21(artifactsDir, "report.json");
|
|
25414
|
+
const evidencePath = join21(artifactsDir, "evidence.json");
|
|
25402
25415
|
await writeFile5(
|
|
25403
25416
|
reportPath,
|
|
25404
25417
|
`${JSON.stringify(
|
|
@@ -25442,8 +25455,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
25442
25455
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
25443
25456
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25444
25457
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25445
|
-
const reportPath =
|
|
25446
|
-
const evidencePath =
|
|
25458
|
+
const reportPath = join21(artifactsDir, "report.json");
|
|
25459
|
+
const evidencePath = join21(artifactsDir, "evidence.json");
|
|
25447
25460
|
await writeFile5(
|
|
25448
25461
|
reportPath,
|
|
25449
25462
|
`${JSON.stringify(
|
|
@@ -25594,8 +25607,8 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
25594
25607
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
25595
25608
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25596
25609
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25597
|
-
const reportPath =
|
|
25598
|
-
const evidencePath =
|
|
25610
|
+
const reportPath = join21(artifactsDir, "report.json");
|
|
25611
|
+
const evidencePath = join21(artifactsDir, "evidence.json");
|
|
25599
25612
|
await writeFile5(
|
|
25600
25613
|
reportPath,
|
|
25601
25614
|
`${JSON.stringify(
|
|
@@ -25685,8 +25698,8 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options) {
|
|
|
25685
25698
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
25686
25699
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25687
25700
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25688
|
-
const reportPath =
|
|
25689
|
-
const evidencePath =
|
|
25701
|
+
const reportPath = join21(artifactsDir, "report.json");
|
|
25702
|
+
const evidencePath = join21(artifactsDir, "evidence.json");
|
|
25690
25703
|
await writeFile5(
|
|
25691
25704
|
reportPath,
|
|
25692
25705
|
`${JSON.stringify(
|
|
@@ -25793,8 +25806,8 @@ async function trySettleCollectorTerminalResult(admitted, authority) {
|
|
|
25793
25806
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
25794
25807
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25795
25808
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25796
|
-
const reportPath =
|
|
25797
|
-
const evidencePath =
|
|
25809
|
+
const reportPath = join21(artifactsDir, "report.json");
|
|
25810
|
+
const evidencePath = join21(artifactsDir, "evidence.json");
|
|
25798
25811
|
await writeFile5(
|
|
25799
25812
|
reportPath,
|
|
25800
25813
|
`${JSON.stringify(
|
|
@@ -26054,8 +26067,8 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
26054
26067
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26055
26068
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26056
26069
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26057
|
-
const reportPath =
|
|
26058
|
-
const evidencePath =
|
|
26070
|
+
const reportPath = join21(artifactsDir, "report.json");
|
|
26071
|
+
const evidencePath = join21(artifactsDir, "evidence.json");
|
|
26059
26072
|
await writeFile5(
|
|
26060
26073
|
reportPath,
|
|
26061
26074
|
`${JSON.stringify(
|
|
@@ -26169,8 +26182,8 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
26169
26182
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26170
26183
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26171
26184
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26172
|
-
const reportPath =
|
|
26173
|
-
const evidencePath =
|
|
26185
|
+
const reportPath = join21(artifactsDir, "report.json");
|
|
26186
|
+
const evidencePath = join21(artifactsDir, "evidence.json");
|
|
26174
26187
|
await writeFile5(
|
|
26175
26188
|
reportPath,
|
|
26176
26189
|
`${JSON.stringify(
|
|
@@ -26309,13 +26322,13 @@ function publicationAttemptFromError(path, error) {
|
|
|
26309
26322
|
}
|
|
26310
26323
|
function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
26311
26324
|
const dirs = [];
|
|
26312
|
-
for (const dir of [baseDir, runDirectory,
|
|
26325
|
+
for (const dir of [baseDir, runDirectory, dirname11(runDirectory)]) {
|
|
26313
26326
|
if (!dirs.includes(dir)) dirs.push(dir);
|
|
26314
26327
|
}
|
|
26315
26328
|
return dirs;
|
|
26316
26329
|
}
|
|
26317
26330
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
26318
|
-
const artifactsDir =
|
|
26331
|
+
const artifactsDir = join21(runDirectory, "artifacts");
|
|
26319
26332
|
try {
|
|
26320
26333
|
await ensureRunArtifactsDir(runDirectory);
|
|
26321
26334
|
return { baseDir: artifactsDir };
|
|
@@ -26331,7 +26344,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
26331
26344
|
const candidates = [
|
|
26332
26345
|
...preferredCandidates,
|
|
26333
26346
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
26334
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
26347
|
+
...uniqueFallbackDirs.map((dir) => join21(dir, `${stem}.${randomUUID3()}.json`))
|
|
26335
26348
|
];
|
|
26336
26349
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
26337
26350
|
const path = candidates[i];
|
|
@@ -26376,26 +26389,26 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
26376
26389
|
} catch (error) {
|
|
26377
26390
|
priorIssues.push(publicationAttemptFromError(sessionFile, error));
|
|
26378
26391
|
}
|
|
26379
|
-
const underArtifacts = baseDir ===
|
|
26392
|
+
const underArtifacts = baseDir === join21(admitted.runDirectory, "artifacts");
|
|
26380
26393
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
26381
26394
|
admitted.runDirectory,
|
|
26382
26395
|
baseDir
|
|
26383
26396
|
);
|
|
26384
26397
|
const errorCandidates = underArtifacts ? [
|
|
26385
|
-
|
|
26386
|
-
|
|
26387
|
-
|
|
26398
|
+
join21(baseDir, "error.json"),
|
|
26399
|
+
join21(baseDir, "error.settlement.json"),
|
|
26400
|
+
join21(admitted.runDirectory, "error.settlement.json")
|
|
26388
26401
|
] : [
|
|
26389
|
-
|
|
26390
|
-
|
|
26402
|
+
join21(baseDir, "error.settlement.json"),
|
|
26403
|
+
join21(baseDir, "error.json")
|
|
26391
26404
|
];
|
|
26392
26405
|
const evidenceCandidates = underArtifacts ? [
|
|
26393
|
-
|
|
26394
|
-
|
|
26395
|
-
|
|
26406
|
+
join21(baseDir, "evidence.json"),
|
|
26407
|
+
join21(baseDir, "evidence.settlement.json"),
|
|
26408
|
+
join21(admitted.runDirectory, "evidence.settlement.json")
|
|
26396
26409
|
] : [
|
|
26397
|
-
|
|
26398
|
-
|
|
26410
|
+
join21(baseDir, "evidence.settlement.json"),
|
|
26411
|
+
join21(baseDir, "evidence.json")
|
|
26399
26412
|
];
|
|
26400
26413
|
const errorPayloadBase = {
|
|
26401
26414
|
kind: "error",
|
|
@@ -26706,7 +26719,7 @@ var init_case_dossier_delivery = __esm({
|
|
|
26706
26719
|
|
|
26707
26720
|
// src/host-transition-prior-native.ts
|
|
26708
26721
|
import { access as access2, readdir as readdir6 } from "node:fs/promises";
|
|
26709
|
-
import { dirname as
|
|
26722
|
+
import { dirname as dirname12, join as join22 } from "node:path";
|
|
26710
26723
|
function isEnoent2(error) {
|
|
26711
26724
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
26712
26725
|
}
|
|
@@ -26720,7 +26733,7 @@ async function listPiNativeRecordPaths(sessionFile) {
|
|
|
26720
26733
|
}
|
|
26721
26734
|
}
|
|
26722
26735
|
async function listSitianRecordPaths(sessionParent) {
|
|
26723
|
-
const sessionRoot =
|
|
26736
|
+
const sessionRoot = dirname12(sessionParent);
|
|
26724
26737
|
let entries;
|
|
26725
26738
|
try {
|
|
26726
26739
|
entries = await readdir6(sessionRoot, { withFileTypes: true });
|
|
@@ -26731,7 +26744,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
26731
26744
|
const recordPaths = [];
|
|
26732
26745
|
for (const entry of entries) {
|
|
26733
26746
|
if (!entry.isDirectory()) continue;
|
|
26734
|
-
const recordFile =
|
|
26747
|
+
const recordFile = join22(sessionRoot, entry.name, "records.jsonl");
|
|
26735
26748
|
try {
|
|
26736
26749
|
await access2(recordFile);
|
|
26737
26750
|
recordPaths.push(recordFile);
|
|
@@ -26801,7 +26814,7 @@ var init_public_run_credentials = __esm({
|
|
|
26801
26814
|
import { constants as fsConstants } from "node:fs";
|
|
26802
26815
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
26803
26816
|
import { lstat as lstat5, mkdir as mkdir4, open as open2 } from "node:fs/promises";
|
|
26804
|
-
import { join as
|
|
26817
|
+
import { join as join23 } from "node:path";
|
|
26805
26818
|
function presentTerminal(terminal, io) {
|
|
26806
26819
|
if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
|
|
26807
26820
|
presentFailureTerminal(terminal, io);
|
|
@@ -26820,7 +26833,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
|
|
|
26820
26833
|
}
|
|
26821
26834
|
}
|
|
26822
26835
|
function runArtifactsDirectory(runDirectory) {
|
|
26823
|
-
return
|
|
26836
|
+
return join23(runDirectory, "artifacts");
|
|
26824
26837
|
}
|
|
26825
26838
|
async function ensureRealArtifactsDirectory(runDirectory) {
|
|
26826
26839
|
const runStat = await lstat5(runDirectory);
|
|
@@ -26903,7 +26916,7 @@ function jsonSafeReplacer() {
|
|
|
26903
26916
|
}
|
|
26904
26917
|
async function retainDispatchError(admitted, principalAuthority, sessionAppender, attempt, error) {
|
|
26905
26918
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
26906
|
-
const filePath =
|
|
26919
|
+
const filePath = join23(
|
|
26907
26920
|
artifactsDir,
|
|
26908
26921
|
`dispatch-error-attempt-${attempt}-${randomUUID4()}.json`
|
|
26909
26922
|
);
|
|
@@ -27152,7 +27165,7 @@ var init_auto_resume = __esm({
|
|
|
27152
27165
|
// src/public-cli/post-admission.ts
|
|
27153
27166
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
27154
27167
|
import { readFile as readFile16, writeFile as writeFile6 } from "node:fs/promises";
|
|
27155
|
-
import { isAbsolute as isAbsolute7, join as
|
|
27168
|
+
import { isAbsolute as isAbsolute7, join as join24, resolve as resolve9 } from "node:path";
|
|
27156
27169
|
function appendContinuationSection(continuation, section) {
|
|
27157
27170
|
const prompt = `${continuation.prompt}
|
|
27158
27171
|
|
|
@@ -27161,7 +27174,7 @@ ${section}`;
|
|
|
27161
27174
|
}
|
|
27162
27175
|
async function readInvocationHost(runDirectory) {
|
|
27163
27176
|
try {
|
|
27164
|
-
const raw = JSON.parse(await readFile16(
|
|
27177
|
+
const raw = JSON.parse(await readFile16(join24(runDirectory, "invocation.json"), "utf8"));
|
|
27165
27178
|
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
|
|
27166
27179
|
} catch (error) {
|
|
27167
27180
|
if (error.code === "ENOENT") return void 0;
|
|
@@ -27315,7 +27328,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
27315
27328
|
}
|
|
27316
27329
|
try {
|
|
27317
27330
|
await writeFile6(
|
|
27318
|
-
|
|
27331
|
+
join24(admitted.runDirectory, "stderr.log"),
|
|
27319
27332
|
result2.stderr,
|
|
27320
27333
|
"utf8"
|
|
27321
27334
|
);
|
|
@@ -27381,16 +27394,24 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
27381
27394
|
}
|
|
27382
27395
|
}
|
|
27383
27396
|
function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
|
|
27397
|
+
const engineMaterial = engineSessionMaterialFromOptions({
|
|
27398
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
27399
|
+
packageRoot: env.packageRoot
|
|
27400
|
+
});
|
|
27384
27401
|
let prompt;
|
|
27385
27402
|
if (request.message !== void 0) {
|
|
27386
|
-
if (summonsPrepared !== void 0) {
|
|
27387
|
-
prompt =
|
|
27388
|
-
|
|
27389
|
-
|
|
27390
|
-
|
|
27391
|
-
|
|
27392
|
-
|
|
27393
|
-
|
|
27403
|
+
if (summonsPrepared !== void 0 && summonsPrepared.attachments.length > 0) {
|
|
27404
|
+
prompt = instructResumeHandbookRead(
|
|
27405
|
+
buildInstructionTransportPrompt(
|
|
27406
|
+
{
|
|
27407
|
+
instruction: request.message,
|
|
27408
|
+
instructionEmpty: false,
|
|
27409
|
+
attachments: summonsPrepared.attachments
|
|
27410
|
+
},
|
|
27411
|
+
engineMaterial
|
|
27412
|
+
),
|
|
27413
|
+
engineMaterial
|
|
27414
|
+
);
|
|
27394
27415
|
} else {
|
|
27395
27416
|
prompt = buildResumeContinuationPrompt({
|
|
27396
27417
|
packageRoot: env.packageRoot,
|
|
@@ -27399,9 +27420,10 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
27399
27420
|
});
|
|
27400
27421
|
}
|
|
27401
27422
|
} else if (summonsPrepared !== void 0) {
|
|
27402
|
-
prompt =
|
|
27403
|
-
|
|
27404
|
-
|
|
27423
|
+
prompt = instructResumeHandbookRead(
|
|
27424
|
+
buildInstructionTransportPrompt(summonsPrepared, engineMaterial),
|
|
27425
|
+
engineMaterial
|
|
27426
|
+
);
|
|
27405
27427
|
} else {
|
|
27406
27428
|
prompt = buildResumeContinuationPrompt({
|
|
27407
27429
|
packageRoot: env.packageRoot,
|
|
@@ -27423,8 +27445,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
27423
27445
|
};
|
|
27424
27446
|
}
|
|
27425
27447
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
27426
|
-
const absolute = isAbsolute7(attachmentPath) ? attachmentPath :
|
|
27427
|
-
return pathContainedIn(
|
|
27448
|
+
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve9(attachmentPath);
|
|
27449
|
+
return pathContainedIn(join24(runDirectory, "attachments"), absolute);
|
|
27428
27450
|
}
|
|
27429
27451
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
27430
27452
|
if (summons === void 0) return void 0;
|
|
@@ -27716,6 +27738,7 @@ var init_post_admission = __esm({
|
|
|
27716
27738
|
init_cli_errors();
|
|
27717
27739
|
init_invocation();
|
|
27718
27740
|
init_activation_ledger_topology();
|
|
27741
|
+
init_engine_material();
|
|
27719
27742
|
init_case_dossier_delivery();
|
|
27720
27743
|
init_host_transition_prior_native();
|
|
27721
27744
|
init_public_run_credentials();
|
|
@@ -28303,171 +28326,10 @@ var init_collector_run = __esm({
|
|
|
28303
28326
|
}
|
|
28304
28327
|
});
|
|
28305
28328
|
|
|
28306
|
-
// src/public-cli/countersign-run.ts
|
|
28307
|
-
function buildCountersignTurnRequest(admitted, options) {
|
|
28308
|
-
return projectRoleTurnRequest(
|
|
28309
|
-
admitted,
|
|
28310
|
-
{
|
|
28311
|
-
activation: {
|
|
28312
|
-
role: "countersign",
|
|
28313
|
-
// Admitted typed binding rides the turn activation seam to the Notary gate.
|
|
28314
|
-
...admitted.ticketNumber === void 0 ? {} : { ticketNumber: admitted.ticketNumber }
|
|
28315
|
-
}
|
|
28316
|
-
},
|
|
28317
|
-
options
|
|
28318
|
-
);
|
|
28319
|
-
}
|
|
28320
|
-
async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
28321
|
-
let parsed;
|
|
28322
|
-
try {
|
|
28323
|
-
parsed = parseCountersignArgv2(argv);
|
|
28324
|
-
} catch (error) {
|
|
28325
|
-
if (error instanceof CliUsageError) {
|
|
28326
|
-
presentStructuralRejection(error, io);
|
|
28327
|
-
return { exitCode: 2 };
|
|
28328
|
-
}
|
|
28329
|
-
throw error;
|
|
28330
|
-
}
|
|
28331
|
-
const projectRoot = parsed.project ?? env.cwd;
|
|
28332
|
-
const reusedTicketNumber = await resolveKnownTicketNumber({
|
|
28333
|
-
instruction: parsed.instruction,
|
|
28334
|
-
projectRoot,
|
|
28335
|
-
home: env.home
|
|
28336
|
-
});
|
|
28337
|
-
if (reusedTicketNumber !== void 0) {
|
|
28338
|
-
const summons = {
|
|
28339
|
-
instruction: parsed.instruction,
|
|
28340
|
-
instructionEmpty: parsed.instruction.trim() === "",
|
|
28341
|
-
attachmentPaths: parsed.attachmentPaths
|
|
28342
|
-
};
|
|
28343
|
-
const resumed = await tryResumeSameTicketSeatRun({
|
|
28344
|
-
home: env.home,
|
|
28345
|
-
projectRoot,
|
|
28346
|
-
role: "countersign",
|
|
28347
|
-
ticketNumber: reusedTicketNumber,
|
|
28348
|
-
freshSummons: env.freshSummons,
|
|
28349
|
-
summons,
|
|
28350
|
-
resume: (runId, materials) => runPublicCountersignResume(
|
|
28351
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
28352
|
-
env,
|
|
28353
|
-
io
|
|
28354
|
-
)
|
|
28355
|
-
});
|
|
28356
|
-
if (resumed !== void 0) return resumed;
|
|
28357
|
-
}
|
|
28358
|
-
let admitted;
|
|
28359
|
-
try {
|
|
28360
|
-
admitted = await admitCountersignInvocation({
|
|
28361
|
-
home: env.home,
|
|
28362
|
-
principalAuthority: env.principalAuthority,
|
|
28363
|
-
cwd: env.cwd,
|
|
28364
|
-
instruction: parsed.instruction,
|
|
28365
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
28366
|
-
...parsed.project === void 0 ? {} : { project: parsed.project },
|
|
28367
|
-
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
28368
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
28369
|
-
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId }
|
|
28370
|
-
});
|
|
28371
|
-
} catch (error) {
|
|
28372
|
-
if (error instanceof CliUsageError) {
|
|
28373
|
-
presentStructuralRejection(error, io);
|
|
28374
|
-
return { exitCode: 2 };
|
|
28375
|
-
}
|
|
28376
|
-
throw error;
|
|
28377
|
-
}
|
|
28378
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
28379
|
-
const turnProjection = {
|
|
28380
|
-
packageRoot: env.packageRoot,
|
|
28381
|
-
home: env.home,
|
|
28382
|
-
agentDir: env.agentDir,
|
|
28383
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
28384
|
-
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
28385
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
28386
|
-
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
28387
|
-
continuation: {
|
|
28388
|
-
kind: "initial",
|
|
28389
|
-
prompt: buildCountersignTransportPrompt(
|
|
28390
|
-
admitted,
|
|
28391
|
-
engineSessionMaterialFromOptions({
|
|
28392
|
-
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
28393
|
-
packageRoot: env.packageRoot
|
|
28394
|
-
})
|
|
28395
|
-
)
|
|
28396
|
-
}
|
|
28397
|
-
};
|
|
28398
|
-
const turnRequest = buildCountersignTurnRequest(admitted, turnProjection);
|
|
28399
|
-
return await runPostAdmissionOneShot({
|
|
28400
|
-
admitted,
|
|
28401
|
-
env,
|
|
28402
|
-
io,
|
|
28403
|
-
request: turnRequest,
|
|
28404
|
-
adapters: countersignAdapters({
|
|
28405
|
-
beforeDispatch: async (admitted2) => {
|
|
28406
|
-
await bindReusedTicketNumber(admitted2, reusedTicketNumber);
|
|
28407
|
-
Object.assign(
|
|
28408
|
-
turnRequest,
|
|
28409
|
-
buildCountersignTurnRequest(admitted2, turnProjection)
|
|
28410
|
-
);
|
|
28411
|
-
}
|
|
28412
|
-
}),
|
|
28413
|
-
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
28414
|
-
});
|
|
28415
|
-
}
|
|
28416
|
-
function countersignAdapters(options) {
|
|
28417
|
-
return {
|
|
28418
|
-
trySettle: (admitted, authority, scope) => trySettleCountersignTerminalResult(admitted, authority, scope),
|
|
28419
|
-
// Accepted receipts and failure terminals both present via shared path.
|
|
28420
|
-
shouldPresentSettled: () => true,
|
|
28421
|
-
...options?.beforeDispatch === void 0 ? {} : { beforeDispatch: options.beforeDispatch }
|
|
28422
|
-
};
|
|
28423
|
-
}
|
|
28424
|
-
async function runPublicCountersignResume(request, env, io) {
|
|
28425
|
-
return await runPostAdmissionSeatResume({
|
|
28426
|
-
request,
|
|
28427
|
-
env,
|
|
28428
|
-
io,
|
|
28429
|
-
load: (effective) => loadResumableCountersignRun(
|
|
28430
|
-
env.home,
|
|
28431
|
-
effective.runId,
|
|
28432
|
-
env.principalAuthority
|
|
28433
|
-
),
|
|
28434
|
-
buildTurnRequest: async (admitted, effective) => {
|
|
28435
|
-
const summonsPrepared = await prepareSummonsResumeMaterials(
|
|
28436
|
-
admitted.runDirectory,
|
|
28437
|
-
effective.summons
|
|
28438
|
-
);
|
|
28439
|
-
return buildCountersignTurnRequest(
|
|
28440
|
-
admitted,
|
|
28441
|
-
resumeTurnRequestProjectionOptions(
|
|
28442
|
-
admitted,
|
|
28443
|
-
effective,
|
|
28444
|
-
env,
|
|
28445
|
-
summonsPrepared
|
|
28446
|
-
)
|
|
28447
|
-
);
|
|
28448
|
-
},
|
|
28449
|
-
adapters: countersignAdapters(),
|
|
28450
|
-
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
28451
|
-
});
|
|
28452
|
-
}
|
|
28453
|
-
var init_countersign_run = __esm({
|
|
28454
|
-
"src/public-cli/countersign-run.ts"() {
|
|
28455
|
-
"use strict";
|
|
28456
|
-
init_engine_material();
|
|
28457
|
-
init_cli_errors();
|
|
28458
|
-
init_invocation();
|
|
28459
|
-
init_seat_ticket_binding();
|
|
28460
|
-
init_post_admission();
|
|
28461
|
-
init_run_lifecycle();
|
|
28462
|
-
init_settlement();
|
|
28463
|
-
init_turn_request();
|
|
28464
|
-
}
|
|
28465
|
-
});
|
|
28466
|
-
|
|
28467
28329
|
// src/diarist-mechanical.ts
|
|
28468
28330
|
import { createHash as createHash6 } from "node:crypto";
|
|
28469
28331
|
import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as statSync2 } from "node:fs";
|
|
28470
|
-
import { basename as basename7, join as
|
|
28332
|
+
import { basename as basename7, join as join25, resolve as resolve10 } from "node:path";
|
|
28471
28333
|
import { homedir } from "node:os";
|
|
28472
28334
|
function extractCornerQuotes(text, minLength = DEFAULT_QUOTE_MIN) {
|
|
28473
28335
|
const out = [];
|
|
@@ -28547,16 +28409,16 @@ function isNotificationRow(type, text) {
|
|
|
28547
28409
|
return false;
|
|
28548
28410
|
}
|
|
28549
28411
|
function readCcSessionBlocks(options) {
|
|
28550
|
-
const root = options.projectsRoot ??
|
|
28412
|
+
const root = options.projectsRoot ?? join25(homedir(), ".claude", "projects");
|
|
28551
28413
|
if (!existsSync9(root)) return [];
|
|
28552
28414
|
const blocks = [];
|
|
28553
28415
|
const dirs = /* @__PURE__ */ new Set();
|
|
28554
28416
|
for (const cwd of options.cwds) {
|
|
28555
|
-
dirs.add(
|
|
28417
|
+
dirs.add(join25(root, encodeClaudeProjectDir(cwd)));
|
|
28556
28418
|
}
|
|
28557
28419
|
for (const cwd of options.cwds) {
|
|
28558
28420
|
if (cwd.includes("projects")) continue;
|
|
28559
|
-
const direct =
|
|
28421
|
+
const direct = join25(root, cwd);
|
|
28560
28422
|
if (existsSync9(direct)) dirs.add(direct);
|
|
28561
28423
|
}
|
|
28562
28424
|
for (const dir of dirs) {
|
|
@@ -28585,7 +28447,7 @@ function readCcSessionBlocks(options) {
|
|
|
28585
28447
|
);
|
|
28586
28448
|
}
|
|
28587
28449
|
for (const name of files) {
|
|
28588
|
-
const sessionFile =
|
|
28450
|
+
const sessionFile = join25(dir, name);
|
|
28589
28451
|
let text;
|
|
28590
28452
|
try {
|
|
28591
28453
|
text = readFileSync3(sessionFile, "utf8");
|
|
@@ -28681,11 +28543,11 @@ function readIssueFaceBlocks(input) {
|
|
|
28681
28543
|
function readAdrDecisionKeyBlocks(input) {
|
|
28682
28544
|
const timestamp2 = input.timestamp ?? (/* @__PURE__ */ new Date(0)).toISOString();
|
|
28683
28545
|
const blocks = [];
|
|
28684
|
-
const cwdAbs =
|
|
28685
|
-
const adrRootAbs =
|
|
28546
|
+
const cwdAbs = resolve10(input.cwd);
|
|
28547
|
+
const adrRootAbs = resolve10(cwdAbs, DIARIST_ADR_ROOT_REL);
|
|
28686
28548
|
let adrRootReal;
|
|
28687
28549
|
try {
|
|
28688
|
-
adrRootReal = existsSync9(adrRootAbs) ? realpathSync3(adrRootAbs) :
|
|
28550
|
+
adrRootReal = existsSync9(adrRootAbs) ? realpathSync3(adrRootAbs) : resolve10(realpathSync3(cwdAbs), DIARIST_ADR_ROOT_REL);
|
|
28689
28551
|
} catch (error) {
|
|
28690
28552
|
throw new DiaristSourceReadError(
|
|
28691
28553
|
"adr-unreadable",
|
|
@@ -28699,11 +28561,11 @@ function readAdrDecisionKeyBlocks(input) {
|
|
|
28699
28561
|
if (segments[0] !== "docs" || segments[1] !== "adr" || segments.length < 3 || segments.some((part) => part === "" || part === "." || part === "..")) {
|
|
28700
28562
|
throw new DiaristSourceReadError(
|
|
28701
28563
|
"adr-escape",
|
|
28702
|
-
|
|
28564
|
+
resolve10(cwdAbs, rel),
|
|
28703
28565
|
`diarist referenced ADR escapes docs/adr (${rel})`
|
|
28704
28566
|
);
|
|
28705
28567
|
}
|
|
28706
|
-
const abs =
|
|
28568
|
+
const abs = resolve10(cwdAbs, rel);
|
|
28707
28569
|
if (abs !== adrRootAbs && !pathContainedIn(adrRootAbs, abs)) {
|
|
28708
28570
|
throw new DiaristSourceReadError(
|
|
28709
28571
|
"adr-escape",
|
|
@@ -28990,9 +28852,15 @@ var init_diarist = __esm({
|
|
|
28990
28852
|
});
|
|
28991
28853
|
|
|
28992
28854
|
// src/public-cli/diarist-run.ts
|
|
28855
|
+
var diarist_run_exports = {};
|
|
28856
|
+
__export(diarist_run_exports, {
|
|
28857
|
+
buildDiaristTurnRequest: () => buildDiaristTurnRequest,
|
|
28858
|
+
runPublicDiarist: () => runPublicDiarist,
|
|
28859
|
+
runPublicDiaristResume: () => runPublicDiaristResume
|
|
28860
|
+
});
|
|
28993
28861
|
import { existsSync as existsSync10 } from "node:fs";
|
|
28994
28862
|
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
28995
|
-
import { join as
|
|
28863
|
+
import { join as join26 } from "node:path";
|
|
28996
28864
|
function withDiaristCatalogPath(prompt, sourcesPath) {
|
|
28997
28865
|
if (sourcesPath === void 0 || sourcesPath.trim() === "") return prompt;
|
|
28998
28866
|
return `${prompt}
|
|
@@ -29018,7 +28886,7 @@ function buildDiaristTurnRequest(admitted, options, sourcesPath) {
|
|
|
29018
28886
|
}
|
|
29019
28887
|
async function freezeDiaristSourceCatalog(admitted, env) {
|
|
29020
28888
|
if (admitted.ticketNumber === void 0) return void 0;
|
|
29021
|
-
const path =
|
|
28889
|
+
const path = join26(admitted.runDirectory, DIARIST_SOURCE_CATALOG_FILE);
|
|
29022
28890
|
if (existsSync10(path)) {
|
|
29023
28891
|
const identity = await readRoleRunIdentity(admitted.runDirectory);
|
|
29024
28892
|
if (identity !== void 0 && identity.state !== "terminal") return path;
|
|
@@ -29186,6 +29054,218 @@ var init_diarist_run = __esm({
|
|
|
29186
29054
|
}
|
|
29187
29055
|
});
|
|
29188
29056
|
|
|
29057
|
+
// src/public-cli/countersign-run.ts
|
|
29058
|
+
function buildCountersignTurnRequest(admitted, options) {
|
|
29059
|
+
return projectRoleTurnRequest(
|
|
29060
|
+
admitted,
|
|
29061
|
+
{
|
|
29062
|
+
activation: {
|
|
29063
|
+
role: "countersign",
|
|
29064
|
+
// Admitted typed binding rides the turn activation seam to the Notary gate.
|
|
29065
|
+
...admitted.ticketNumber === void 0 ? {} : { ticketNumber: admitted.ticketNumber }
|
|
29066
|
+
}
|
|
29067
|
+
},
|
|
29068
|
+
options
|
|
29069
|
+
);
|
|
29070
|
+
}
|
|
29071
|
+
async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
29072
|
+
if (admitted.ticketNumber === void 0) return;
|
|
29073
|
+
if (env.runCourtDiaristStation !== void 0) {
|
|
29074
|
+
await env.runCourtDiaristStation(admitted);
|
|
29075
|
+
return;
|
|
29076
|
+
}
|
|
29077
|
+
const quietIo = {
|
|
29078
|
+
stdout() {
|
|
29079
|
+
},
|
|
29080
|
+
stderr(text) {
|
|
29081
|
+
if (text.trim() !== "") io.stderr(text);
|
|
29082
|
+
}
|
|
29083
|
+
};
|
|
29084
|
+
const { runPublicDiarist: runPublicDiarist2 } = await Promise.resolve().then(() => (init_diarist_run(), diarist_run_exports));
|
|
29085
|
+
const result2 = await runPublicDiarist2(
|
|
29086
|
+
[
|
|
29087
|
+
"--project",
|
|
29088
|
+
admitted.projectRoot,
|
|
29089
|
+
`\u6574\u7406 #${admitted.ticketNumber} \u7684\u672C\u6848\u4F9D\u636E\u3002`
|
|
29090
|
+
],
|
|
29091
|
+
{
|
|
29092
|
+
home: env.home,
|
|
29093
|
+
agentDir: env.agentDir,
|
|
29094
|
+
packageRoot: env.packageRoot,
|
|
29095
|
+
cwd: env.cwd,
|
|
29096
|
+
principalAuthority: env.principalAuthority,
|
|
29097
|
+
roleTurnHost: env.roleTurnHost,
|
|
29098
|
+
sessionAppender: env.sessionAppender,
|
|
29099
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
29100
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
29101
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
29102
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
29103
|
+
...env.credentials === void 0 ? {} : { credentials: env.credentials },
|
|
29104
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
29105
|
+
...env.signal === void 0 ? {} : { signal: env.signal }
|
|
29106
|
+
},
|
|
29107
|
+
quietIo,
|
|
29108
|
+
parseDiaristArgv
|
|
29109
|
+
);
|
|
29110
|
+
if (result2.exitCode !== 0) {
|
|
29111
|
+
const detail = result2.terminal?.roleOutcome.kind === "failure" ? ` (roleOutcome=failure)` : "";
|
|
29112
|
+
throw new Error(
|
|
29113
|
+
`court diarist station failed for ticket #${admitted.ticketNumber}: exit ${result2.exitCode}${detail}`
|
|
29114
|
+
);
|
|
29115
|
+
}
|
|
29116
|
+
}
|
|
29117
|
+
async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
29118
|
+
let parsed;
|
|
29119
|
+
try {
|
|
29120
|
+
parsed = parseCountersignArgv2(argv);
|
|
29121
|
+
} catch (error) {
|
|
29122
|
+
if (error instanceof CliUsageError) {
|
|
29123
|
+
presentStructuralRejection(error, io);
|
|
29124
|
+
return { exitCode: 2 };
|
|
29125
|
+
}
|
|
29126
|
+
throw error;
|
|
29127
|
+
}
|
|
29128
|
+
const projectRoot = parsed.project ?? env.cwd;
|
|
29129
|
+
const reusedTicketNumber = await resolveKnownTicketNumber({
|
|
29130
|
+
instruction: parsed.instruction,
|
|
29131
|
+
projectRoot,
|
|
29132
|
+
home: env.home
|
|
29133
|
+
});
|
|
29134
|
+
if (reusedTicketNumber !== void 0) {
|
|
29135
|
+
const summons = {
|
|
29136
|
+
instruction: parsed.instruction,
|
|
29137
|
+
instructionEmpty: parsed.instruction.trim() === "",
|
|
29138
|
+
attachmentPaths: parsed.attachmentPaths
|
|
29139
|
+
};
|
|
29140
|
+
const resumed = await tryResumeSameTicketSeatRun({
|
|
29141
|
+
home: env.home,
|
|
29142
|
+
projectRoot,
|
|
29143
|
+
role: "countersign",
|
|
29144
|
+
ticketNumber: reusedTicketNumber,
|
|
29145
|
+
freshSummons: env.freshSummons,
|
|
29146
|
+
summons,
|
|
29147
|
+
resume: (runId, materials) => runPublicCountersignResume(
|
|
29148
|
+
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
29149
|
+
env,
|
|
29150
|
+
io
|
|
29151
|
+
)
|
|
29152
|
+
});
|
|
29153
|
+
if (resumed !== void 0) return resumed;
|
|
29154
|
+
}
|
|
29155
|
+
let admitted;
|
|
29156
|
+
try {
|
|
29157
|
+
admitted = await admitCountersignInvocation({
|
|
29158
|
+
home: env.home,
|
|
29159
|
+
principalAuthority: env.principalAuthority,
|
|
29160
|
+
cwd: env.cwd,
|
|
29161
|
+
instruction: parsed.instruction,
|
|
29162
|
+
attachmentPaths: parsed.attachmentPaths,
|
|
29163
|
+
...parsed.project === void 0 ? {} : { project: parsed.project },
|
|
29164
|
+
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
29165
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
29166
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId }
|
|
29167
|
+
});
|
|
29168
|
+
} catch (error) {
|
|
29169
|
+
if (error instanceof CliUsageError) {
|
|
29170
|
+
presentStructuralRejection(error, io);
|
|
29171
|
+
return { exitCode: 2 };
|
|
29172
|
+
}
|
|
29173
|
+
throw error;
|
|
29174
|
+
}
|
|
29175
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
29176
|
+
const turnProjection = {
|
|
29177
|
+
packageRoot: env.packageRoot,
|
|
29178
|
+
home: env.home,
|
|
29179
|
+
agentDir: env.agentDir,
|
|
29180
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
29181
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
29182
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
29183
|
+
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
29184
|
+
continuation: {
|
|
29185
|
+
kind: "initial",
|
|
29186
|
+
prompt: buildCountersignTransportPrompt(
|
|
29187
|
+
admitted,
|
|
29188
|
+
engineSessionMaterialFromOptions({
|
|
29189
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
29190
|
+
packageRoot: env.packageRoot
|
|
29191
|
+
})
|
|
29192
|
+
)
|
|
29193
|
+
}
|
|
29194
|
+
};
|
|
29195
|
+
const turnRequest = buildCountersignTurnRequest(admitted, turnProjection);
|
|
29196
|
+
return await runPostAdmissionOneShot({
|
|
29197
|
+
admitted,
|
|
29198
|
+
env,
|
|
29199
|
+
io,
|
|
29200
|
+
request: turnRequest,
|
|
29201
|
+
adapters: countersignAdapters({
|
|
29202
|
+
beforeDispatch: async (admittedSeat) => {
|
|
29203
|
+
await bindReusedTicketNumber(admittedSeat, reusedTicketNumber);
|
|
29204
|
+
Object.assign(
|
|
29205
|
+
turnRequest,
|
|
29206
|
+
buildCountersignTurnRequest(admittedSeat, turnProjection)
|
|
29207
|
+
);
|
|
29208
|
+
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
29209
|
+
}
|
|
29210
|
+
}),
|
|
29211
|
+
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
29212
|
+
});
|
|
29213
|
+
}
|
|
29214
|
+
function countersignAdapters(options) {
|
|
29215
|
+
return {
|
|
29216
|
+
trySettle: (admitted, authority, scope) => trySettleCountersignTerminalResult(admitted, authority, scope),
|
|
29217
|
+
// Accepted receipts and failure terminals both present via shared path.
|
|
29218
|
+
shouldPresentSettled: () => true,
|
|
29219
|
+
...options?.beforeDispatch === void 0 ? {} : { beforeDispatch: options.beforeDispatch }
|
|
29220
|
+
};
|
|
29221
|
+
}
|
|
29222
|
+
async function runPublicCountersignResume(request, env, io) {
|
|
29223
|
+
return await runPostAdmissionSeatResume({
|
|
29224
|
+
request,
|
|
29225
|
+
env,
|
|
29226
|
+
io,
|
|
29227
|
+
load: (effective) => loadResumableCountersignRun(
|
|
29228
|
+
env.home,
|
|
29229
|
+
effective.runId,
|
|
29230
|
+
env.principalAuthority
|
|
29231
|
+
),
|
|
29232
|
+
buildTurnRequest: async (admitted, effective) => {
|
|
29233
|
+
const summonsPrepared = await prepareSummonsResumeMaterials(
|
|
29234
|
+
admitted.runDirectory,
|
|
29235
|
+
effective.summons
|
|
29236
|
+
);
|
|
29237
|
+
return buildCountersignTurnRequest(
|
|
29238
|
+
admitted,
|
|
29239
|
+
resumeTurnRequestProjectionOptions(
|
|
29240
|
+
admitted,
|
|
29241
|
+
effective,
|
|
29242
|
+
env,
|
|
29243
|
+
summonsPrepared
|
|
29244
|
+
)
|
|
29245
|
+
);
|
|
29246
|
+
},
|
|
29247
|
+
adapters: countersignAdapters({
|
|
29248
|
+
beforeDispatch: async (admitted) => {
|
|
29249
|
+
await runCountersignCourtDiaristStation(admitted, env, io);
|
|
29250
|
+
}
|
|
29251
|
+
}),
|
|
29252
|
+
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
29253
|
+
});
|
|
29254
|
+
}
|
|
29255
|
+
var init_countersign_run = __esm({
|
|
29256
|
+
"src/public-cli/countersign-run.ts"() {
|
|
29257
|
+
"use strict";
|
|
29258
|
+
init_engine_material();
|
|
29259
|
+
init_cli_errors();
|
|
29260
|
+
init_invocation();
|
|
29261
|
+
init_seat_ticket_binding();
|
|
29262
|
+
init_post_admission();
|
|
29263
|
+
init_run_lifecycle();
|
|
29264
|
+
init_settlement();
|
|
29265
|
+
init_turn_request();
|
|
29266
|
+
}
|
|
29267
|
+
});
|
|
29268
|
+
|
|
29189
29269
|
// src/public-cli/gleaner-left-run.ts
|
|
29190
29270
|
function buildGleanerLeftTurnRequest(admitted, options) {
|
|
29191
29271
|
return projectRoleTurnRequest(
|
|
@@ -29565,6 +29645,7 @@ var init_fixer_run = __esm({
|
|
|
29565
29645
|
});
|
|
29566
29646
|
|
|
29567
29647
|
// src/public-cli/notary-run.ts
|
|
29648
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
29568
29649
|
function buildNotaryTurnRequest(admitted, options) {
|
|
29569
29650
|
return projectRoleTurnRequest(
|
|
29570
29651
|
admitted,
|
|
@@ -29706,14 +29787,19 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
29706
29787
|
}
|
|
29707
29788
|
return loaded;
|
|
29708
29789
|
},
|
|
29709
|
-
buildTurnRequest: (admitted, effective) =>
|
|
29710
|
-
|
|
29711
|
-
//「重新读」candidate line, no engine handbook packaging.
|
|
29712
|
-
buildNotaryTurnRequest(
|
|
29790
|
+
buildTurnRequest: (admitted, effective) => {
|
|
29791
|
+
const projection = resumeTurnRequestProjectionOptions(
|
|
29713
29792
|
admitted,
|
|
29714
|
-
|
|
29715
|
-
|
|
29716
|
-
|
|
29793
|
+
effective,
|
|
29794
|
+
env
|
|
29795
|
+
);
|
|
29796
|
+
const candidatePath = gateSubmissionCandidatePath(admitted.sourceRunPath);
|
|
29797
|
+
const prompt = existsSync11(candidatePath) ? appendResumeMaterialReread(projection.continuation.prompt, candidatePath) : projection.continuation.prompt;
|
|
29798
|
+
return buildNotaryTurnRequest(admitted, {
|
|
29799
|
+
...projection,
|
|
29800
|
+
continuation: { kind: "resume", prompt }
|
|
29801
|
+
});
|
|
29802
|
+
},
|
|
29717
29803
|
adapters: notaryAdapters(),
|
|
29718
29804
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
29719
29805
|
});
|
|
@@ -29721,6 +29807,7 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
29721
29807
|
var init_notary_run = __esm({
|
|
29722
29808
|
"src/public-cli/notary-run.ts"() {
|
|
29723
29809
|
"use strict";
|
|
29810
|
+
init_auditor_dossier_tool();
|
|
29724
29811
|
init_notary_source_run();
|
|
29725
29812
|
init_engine_material();
|
|
29726
29813
|
init_cli_errors();
|
|
@@ -30002,7 +30089,7 @@ var init_judge_run = __esm({
|
|
|
30002
30089
|
|
|
30003
30090
|
// src/public-cli/merger-run.ts
|
|
30004
30091
|
import { mkdir as mkdir5, writeFile as writeFile8 } from "node:fs/promises";
|
|
30005
|
-
import { join as
|
|
30092
|
+
import { join as join27, resolve as resolve11 } from "node:path";
|
|
30006
30093
|
function mergerMethods(packageRoot2) {
|
|
30007
30094
|
return [
|
|
30008
30095
|
{
|
|
@@ -30044,7 +30131,7 @@ async function loadMergerMethodMaterial(packageRoot2) {
|
|
|
30044
30131
|
);
|
|
30045
30132
|
}
|
|
30046
30133
|
async function admitMergerShellForActivationFailure(options) {
|
|
30047
|
-
const projectRoot =
|
|
30134
|
+
const projectRoot = resolve11(options.project ?? options.cwd);
|
|
30048
30135
|
const runId = (options.createRunId ?? uuidv7)();
|
|
30049
30136
|
const {
|
|
30050
30137
|
principal,
|
|
@@ -30068,8 +30155,8 @@ async function admitMergerShellForActivationFailure(options) {
|
|
|
30068
30155
|
expectedConflictPaths: [],
|
|
30069
30156
|
resolutionScope: []
|
|
30070
30157
|
};
|
|
30071
|
-
const admittedRequestPath =
|
|
30072
|
-
const mergerInputPath =
|
|
30158
|
+
const admittedRequestPath = join27(runDirectory, "admitted-request.json");
|
|
30159
|
+
const mergerInputPath = join27(runDirectory, "merger-input.json");
|
|
30073
30160
|
await writeFile8(
|
|
30074
30161
|
admittedRequestPath,
|
|
30075
30162
|
`${JSON.stringify(
|
|
@@ -30509,10 +30596,10 @@ var init_analyst_book_key = __esm({
|
|
|
30509
30596
|
// src/atomic-write.ts
|
|
30510
30597
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
30511
30598
|
import { rename, rm, writeFile as writeFile9 } from "node:fs/promises";
|
|
30512
|
-
import { dirname as
|
|
30599
|
+
import { dirname as dirname13, join as join28 } from "node:path";
|
|
30513
30600
|
async function writeFileAtomically(destination, contents) {
|
|
30514
|
-
const parent =
|
|
30515
|
-
const temporary =
|
|
30601
|
+
const parent = dirname13(destination);
|
|
30602
|
+
const temporary = join28(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
30516
30603
|
try {
|
|
30517
30604
|
await writeFile9(temporary, contents);
|
|
30518
30605
|
await rename(temporary, destination);
|
|
@@ -30529,16 +30616,16 @@ var init_atomic_write = __esm({
|
|
|
30529
30616
|
|
|
30530
30617
|
// src/analyst-index.ts
|
|
30531
30618
|
import { open as open3, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
30532
|
-
import { dirname as
|
|
30619
|
+
import { dirname as dirname14, join as join29 } from "node:path";
|
|
30533
30620
|
function sleep(ms) {
|
|
30534
|
-
return new Promise((
|
|
30535
|
-
setTimeout(
|
|
30621
|
+
return new Promise((resolve13) => {
|
|
30622
|
+
setTimeout(resolve13, ms);
|
|
30536
30623
|
});
|
|
30537
30624
|
}
|
|
30538
30625
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
30539
30626
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
30540
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
30541
|
-
const lockPath =
|
|
30627
|
+
ensureRealDirectoryTree(ledgerHome, dirname14(indexPath));
|
|
30628
|
+
const lockPath = join29(dirname14(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
30542
30629
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
30543
30630
|
const startedAt = Date.now();
|
|
30544
30631
|
while (true) {
|
|
@@ -30565,7 +30652,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
30565
30652
|
}
|
|
30566
30653
|
}
|
|
30567
30654
|
function analystLibraryIndexPath(ledgerHome) {
|
|
30568
|
-
return
|
|
30655
|
+
return join29(ledgerHome, "analyst", "library-index.json");
|
|
30569
30656
|
}
|
|
30570
30657
|
function rowFromIssueMetricsPage(page) {
|
|
30571
30658
|
return {
|
|
@@ -30674,7 +30761,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
30674
30761
|
}
|
|
30675
30762
|
async function writeAnalystLibraryIndexPage(ledgerHome, page) {
|
|
30676
30763
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
30677
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
30764
|
+
ensureRealDirectoryTree(ledgerHome, dirname14(path));
|
|
30678
30765
|
assertLedgerFileInsideHome(path, ledgerHome);
|
|
30679
30766
|
await writeFileAtomically(path, `${JSON.stringify(page, null, 2)}
|
|
30680
30767
|
`);
|
|
@@ -30861,7 +30948,7 @@ var init_analyst_cohort = __esm({
|
|
|
30861
30948
|
|
|
30862
30949
|
// src/analyst-ledger.ts
|
|
30863
30950
|
import { readdir as readdir7, readFile as readFile18 } from "node:fs/promises";
|
|
30864
|
-
import { join as
|
|
30951
|
+
import { join as join30 } from "node:path";
|
|
30865
30952
|
function isMissingPathError5(error) {
|
|
30866
30953
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
30867
30954
|
}
|
|
@@ -30874,7 +30961,7 @@ function isRecord18(value) {
|
|
|
30874
30961
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
30875
30962
|
try {
|
|
30876
30963
|
const raw = JSON.parse(
|
|
30877
|
-
await readFile18(
|
|
30964
|
+
await readFile18(join30(runDirectory, "run-state.json"), "utf8")
|
|
30878
30965
|
);
|
|
30879
30966
|
if (!isRecord18(raw) || typeof raw.state !== "string") return void 0;
|
|
30880
30967
|
return raw.state;
|
|
@@ -30906,7 +30993,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
30906
30993
|
async function readInvocationScopeFields(runDirectory) {
|
|
30907
30994
|
let raw;
|
|
30908
30995
|
try {
|
|
30909
|
-
raw = await readFile18(
|
|
30996
|
+
raw = await readFile18(join30(runDirectory, "invocation.json"), "utf8");
|
|
30910
30997
|
} catch (error) {
|
|
30911
30998
|
if (isMissingPathError5(error)) return void 0;
|
|
30912
30999
|
throw error;
|
|
@@ -30938,7 +31025,7 @@ function decideIssueScope(input) {
|
|
|
30938
31025
|
}
|
|
30939
31026
|
async function resolveSessionFile(runDirectory) {
|
|
30940
31027
|
try {
|
|
30941
|
-
const raw = await readFile18(
|
|
31028
|
+
const raw = await readFile18(join30(runDirectory, "invocation.json"), "utf8");
|
|
30942
31029
|
const parsed = JSON.parse(raw);
|
|
30943
31030
|
if (isRecord18(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
30944
31031
|
return parsed.sessionFile;
|
|
@@ -30946,7 +31033,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
30946
31033
|
} catch (error) {
|
|
30947
31034
|
if (!isMissingPathError5(error)) throw error;
|
|
30948
31035
|
}
|
|
30949
|
-
return
|
|
31036
|
+
return join30(runDirectory, "session", "session.jsonl");
|
|
30950
31037
|
}
|
|
30951
31038
|
function attributeSessionRowsForRun(input) {
|
|
30952
31039
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -31118,9 +31205,9 @@ async function classifyScopedRun(input) {
|
|
|
31118
31205
|
}
|
|
31119
31206
|
let gateCycles;
|
|
31120
31207
|
try {
|
|
31121
|
-
const parentSessionFile =
|
|
31208
|
+
const parentSessionFile = join30(input.runDirectory, "session", "session.jsonl");
|
|
31122
31209
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
31123
|
-
|
|
31210
|
+
join30(input.runDirectory, "session", "auditor-roles"),
|
|
31124
31211
|
{ parentSessionFile }
|
|
31125
31212
|
);
|
|
31126
31213
|
} catch (error) {
|
|
@@ -31153,7 +31240,7 @@ async function classifyScopedRun(input) {
|
|
|
31153
31240
|
async function scanAnalystIssueRuns(input) {
|
|
31154
31241
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
31155
31242
|
const scopeTicketNumber = input.ticketNumber;
|
|
31156
|
-
const booksRoot =
|
|
31243
|
+
const booksRoot = join30(ledgerHome, "books");
|
|
31157
31244
|
let wholeBook = false;
|
|
31158
31245
|
let scopeRootIdentity;
|
|
31159
31246
|
let bookNames;
|
|
@@ -31185,7 +31272,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31185
31272
|
const unreadable = [];
|
|
31186
31273
|
const scopeConflicts = [];
|
|
31187
31274
|
for (const book of bookNames) {
|
|
31188
|
-
const runsDir =
|
|
31275
|
+
const runsDir = join30(booksRoot, book, "runs");
|
|
31189
31276
|
let runNames;
|
|
31190
31277
|
try {
|
|
31191
31278
|
const entries = await readdir7(runsDir, { withFileTypes: true });
|
|
@@ -31197,7 +31284,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31197
31284
|
for (const runName of runNames) {
|
|
31198
31285
|
const parsed = parseRunDirectoryName2(runName);
|
|
31199
31286
|
if (parsed === void 0) continue;
|
|
31200
|
-
const runDirectory =
|
|
31287
|
+
const runDirectory = join30(runsDir, runName);
|
|
31201
31288
|
let scopeFields;
|
|
31202
31289
|
try {
|
|
31203
31290
|
scopeFields = await readInvocationScopeFields(runDirectory);
|
|
@@ -32051,7 +32138,7 @@ var init_analyst_metric_family = __esm({
|
|
|
32051
32138
|
|
|
32052
32139
|
// src/analyst-page.ts
|
|
32053
32140
|
import { createHash as createHash7 } from "node:crypto";
|
|
32054
|
-
import { dirname as
|
|
32141
|
+
import { dirname as dirname15, join as join31 } from "node:path";
|
|
32055
32142
|
function analystIssuePageKey(address) {
|
|
32056
32143
|
const parts = ["book", address.bookKey];
|
|
32057
32144
|
if (address.issueNumber !== void 0) {
|
|
@@ -32062,7 +32149,7 @@ function analystIssuePageKey(address) {
|
|
|
32062
32149
|
return createHash7("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
32063
32150
|
}
|
|
32064
32151
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32065
|
-
return
|
|
32152
|
+
return join31(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
32066
32153
|
}
|
|
32067
32154
|
function analystIssuePageAddressFromPage(page) {
|
|
32068
32155
|
return {
|
|
@@ -32181,7 +32268,7 @@ async function buildAnalystIssueMetricsPage(input) {
|
|
|
32181
32268
|
}
|
|
32182
32269
|
async function writeAnalystIssueMetricsPage(ledgerHome, page) {
|
|
32183
32270
|
const path = analystIssuePagePath(ledgerHome, analystIssuePageAddressFromPage(page));
|
|
32184
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
32271
|
+
ensureRealDirectoryTree(ledgerHome, dirname15(path));
|
|
32185
32272
|
assertLedgerFileInsideHome(path, ledgerHome);
|
|
32186
32273
|
await writeFileAtomically(path, `${JSON.stringify(page, null, 2)}
|
|
32187
32274
|
`);
|
|
@@ -32423,7 +32510,7 @@ var init_analyst_entry = __esm({
|
|
|
32423
32510
|
|
|
32424
32511
|
// src/public-cli/analyst-run.ts
|
|
32425
32512
|
import { readFile as readFile20 } from "node:fs/promises";
|
|
32426
|
-
import { isAbsolute as isAbsolute9, resolve as
|
|
32513
|
+
import { isAbsolute as isAbsolute9, resolve as resolve12 } from "node:path";
|
|
32427
32514
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
32428
32515
|
try {
|
|
32429
32516
|
return resolveBookKeyFromGit(cwd);
|
|
@@ -32472,7 +32559,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
32472
32559
|
);
|
|
32473
32560
|
}
|
|
32474
32561
|
const sourcePath = attachmentPaths[0];
|
|
32475
|
-
const absolute = isAbsolute9(sourcePath) ? sourcePath :
|
|
32562
|
+
const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve12(sourcePath);
|
|
32476
32563
|
let bytes;
|
|
32477
32564
|
try {
|
|
32478
32565
|
bytes = await readFile20(absolute);
|
|
@@ -32595,7 +32682,7 @@ __export(cli_exports, {
|
|
|
32595
32682
|
runAkRole: () => runAkRole
|
|
32596
32683
|
});
|
|
32597
32684
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
32598
|
-
import { join as
|
|
32685
|
+
import { join as join32 } from "node:path";
|
|
32599
32686
|
function takePublicGlobalFlag(argv, index, options) {
|
|
32600
32687
|
const tokens = argv.slice(index);
|
|
32601
32688
|
const taken = options.takeDashed(tokens);
|
|
@@ -32727,7 +32814,7 @@ function resolveHome(env) {
|
|
|
32727
32814
|
return env.home ?? packageMachineHome();
|
|
32728
32815
|
}
|
|
32729
32816
|
function resolveAgentDir(env, home) {
|
|
32730
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
32817
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join32(home, ".pi", "agent");
|
|
32731
32818
|
}
|
|
32732
32819
|
function parseThinking(value) {
|
|
32733
32820
|
return value;
|
|
@@ -33682,8 +33769,8 @@ var init_cli = __esm({
|
|
|
33682
33769
|
});
|
|
33683
33770
|
|
|
33684
33771
|
// src/public-cli/main.ts
|
|
33685
|
-
import { existsSync as
|
|
33686
|
-
import { dirname as
|
|
33772
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
33773
|
+
import { dirname as dirname16, join as join33 } from "node:path";
|
|
33687
33774
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33688
33775
|
|
|
33689
33776
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -33770,10 +33857,10 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
33770
33857
|
}
|
|
33771
33858
|
|
|
33772
33859
|
// src/public-cli/main.ts
|
|
33773
|
-
var here =
|
|
33860
|
+
var here = dirname16(fileURLToPath2(import.meta.url));
|
|
33774
33861
|
function resolvePackageRoot(binDir) {
|
|
33775
|
-
const canonical =
|
|
33776
|
-
if (
|
|
33862
|
+
const canonical = join33(binDir, "..", "..");
|
|
33863
|
+
if (existsSync12(join33(canonical, "package.json"))) {
|
|
33777
33864
|
return canonical;
|
|
33778
33865
|
}
|
|
33779
33866
|
return binDir;
|