@akagilnc/pi-workflow-roles 0.1.5303 → 0.1.5312
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/description.js +0 -11
- package/dist/acp-host/production-host.js +577 -604
- package/dist/analyst-ledger.js +16 -1
- package/dist/analyst-metric-families/acceptance-success-rework.js +16 -15
- package/dist/analyst-metric-families/b2-frame-buckets-actions.js +3 -8
- package/dist/analyst-metric-families/gate-cycles.js +2 -8
- package/dist/analyst-metric-families/leg-wall-clock.js +4 -13
- package/dist/analyst-metric-families/round-timeline.js +1 -4
- package/dist/analyst-model-groups.js +1 -7
- package/dist/analyst-page.js +4 -13
- package/dist/headless-host/description.js +0 -11
- package/dist/headless-host/production-host.js +679 -718
- package/dist/host-descriptions.js +13 -0
- package/dist/prepared-role-turn.js +4 -0
- package/dist/public-cli/machine-method-skills.js +5 -5
- package/dist/public-cli/main.js +291 -313
- package/package.json +1 -1
- package/src/acp-host/description.ts +2 -12
- package/src/acp-host/production-host.ts +3 -2
- package/src/acp-host/role-turn-host.ts +7 -42
- package/src/analyst-ledger.ts +20 -1
- package/src/analyst-metric-families/acceptance-success-rework.ts +5 -15
- package/src/analyst-metric-families/b2-frame-buckets-actions.ts +3 -7
- package/src/analyst-metric-families/gate-cycles.ts +2 -8
- package/src/analyst-metric-families/leg-wall-clock.ts +4 -16
- package/src/analyst-metric-families/round-timeline.ts +1 -5
- package/src/analyst-model-groups.ts +1 -10
- package/src/analyst-page.ts +4 -16
- package/src/external-host-turn-loop.ts +36 -16
- package/src/headless-host/description.ts +3 -18
- package/src/headless-host/production-host.ts +3 -2
- package/src/headless-host/role-turn-host.ts +10 -68
- package/src/host-descriptions.ts +18 -0
- package/src/prepared-role-turn.ts +8 -0
- package/src/public-cli/machine-method-skills.ts +5 -5
package/dist/public-cli/main.js
CHANGED
|
@@ -15711,6 +15711,10 @@ var init_institutional_resolution = __esm({
|
|
|
15711
15711
|
});
|
|
15712
15712
|
|
|
15713
15713
|
// src/host-descriptions.ts
|
|
15714
|
+
import { join as join7 } from "node:path";
|
|
15715
|
+
function resolveHostBinary(description, operatorHome) {
|
|
15716
|
+
return join7(operatorHome, ...description.binaryFromHome);
|
|
15717
|
+
}
|
|
15714
15718
|
function lookupHostDescription(host) {
|
|
15715
15719
|
return Object.hasOwn(HOST_DESCRIPTIONS, host) ? HOST_DESCRIPTIONS[host] : void 0;
|
|
15716
15720
|
}
|
|
@@ -15839,7 +15843,7 @@ __export(config_exports, {
|
|
|
15839
15843
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
15840
15844
|
});
|
|
15841
15845
|
import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
15842
|
-
import { dirname as dirname4, join as
|
|
15846
|
+
import { dirname as dirname4, join as join8 } from "node:path";
|
|
15843
15847
|
function isGateOfficerSeat(value) {
|
|
15844
15848
|
return packagedProvinceConfig(value);
|
|
15845
15849
|
}
|
|
@@ -15847,7 +15851,7 @@ function publicCliConfigPath(home) {
|
|
|
15847
15851
|
if (typeof home !== "string" || home.trim() === "") {
|
|
15848
15852
|
throw new Error("home must be explicitly provided");
|
|
15849
15853
|
}
|
|
15850
|
-
return
|
|
15854
|
+
return join8(home, ".ak-roles", "public-cli.json");
|
|
15851
15855
|
}
|
|
15852
15856
|
async function loadPublicCliConfig(home) {
|
|
15853
15857
|
const path = publicCliConfigPath(home);
|
|
@@ -16310,7 +16314,7 @@ function credentialProvidersFromAuthData(data) {
|
|
|
16310
16314
|
}
|
|
16311
16315
|
async function loadCredentialProviders(agentDir) {
|
|
16312
16316
|
try {
|
|
16313
|
-
const raw = await readFile2(
|
|
16317
|
+
const raw = await readFile2(join8(agentDir, "auth.json"), "utf8");
|
|
16314
16318
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
16315
16319
|
} catch (error) {
|
|
16316
16320
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -16348,15 +16352,15 @@ __export(host_providers_exports, {
|
|
|
16348
16352
|
renderHostProvidersTable: () => renderHostProvidersTable
|
|
16349
16353
|
});
|
|
16350
16354
|
import { readFileSync } from "node:fs";
|
|
16351
|
-
import { join as
|
|
16355
|
+
import { join as join9 } from "node:path";
|
|
16352
16356
|
function hostProvidersPath(home) {
|
|
16353
16357
|
if (typeof home !== "string" || home.trim() === "") {
|
|
16354
16358
|
throw new Error("home must be explicitly provided");
|
|
16355
16359
|
}
|
|
16356
|
-
return
|
|
16360
|
+
return join9(home, ".ak-roles", "host-providers.json");
|
|
16357
16361
|
}
|
|
16358
16362
|
function hermesProviderModelsCachePath(home) {
|
|
16359
|
-
return
|
|
16363
|
+
return join9(home, ".hermes", "provider_models_cache.json");
|
|
16360
16364
|
}
|
|
16361
16365
|
function parseHostProvidersTable(value) {
|
|
16362
16366
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -16535,16 +16539,16 @@ var init_cli_errors = __esm({
|
|
|
16535
16539
|
// src/public-cli/machine-method-skills.ts
|
|
16536
16540
|
import { accessSync, constants, statSync as statSync2 } from "node:fs";
|
|
16537
16541
|
import { lstat, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
16538
|
-
import { join as
|
|
16542
|
+
import { join as join10 } from "node:path";
|
|
16539
16543
|
import { spawnSync } from "node:child_process";
|
|
16540
16544
|
function skillRoot(home) {
|
|
16541
|
-
return
|
|
16545
|
+
return join10(home, ".agents/skills");
|
|
16542
16546
|
}
|
|
16543
16547
|
function installedMethodSkillPath(home, name) {
|
|
16544
16548
|
return installedSkillPath(skillRoot(home), name);
|
|
16545
16549
|
}
|
|
16546
16550
|
function installedSkillPath(root, name) {
|
|
16547
|
-
const path =
|
|
16551
|
+
const path = join10(root, name, "SKILL.md");
|
|
16548
16552
|
try {
|
|
16549
16553
|
if (!statSync2(path).isFile()) return void 0;
|
|
16550
16554
|
accessSync(path, constants.R_OK);
|
|
@@ -16557,9 +16561,9 @@ function installedSkillPath(root, name) {
|
|
|
16557
16561
|
}
|
|
16558
16562
|
function linkedSkillRoot(home, host) {
|
|
16559
16563
|
if (host === "claude" || host === "claude-code") {
|
|
16560
|
-
return
|
|
16564
|
+
return join10(process.env.CLAUDE_CONFIG_DIR?.trim() || join10(home, ".claude"), "skills");
|
|
16561
16565
|
}
|
|
16562
|
-
if (host === "hermes") return
|
|
16566
|
+
if (host === "hermes") return join10(home, ".hermes/skills");
|
|
16563
16567
|
return void 0;
|
|
16564
16568
|
}
|
|
16565
16569
|
async function occupied(path) {
|
|
@@ -16616,7 +16620,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
16616
16620
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
16617
16621
|
let unsourced = false;
|
|
16618
16622
|
for (const name of packagedMethodSkillNames()) {
|
|
16619
|
-
const path =
|
|
16623
|
+
const path = join10(canonical, name);
|
|
16620
16624
|
if (await occupied(path)) {
|
|
16621
16625
|
warnOccupied(path, stdout);
|
|
16622
16626
|
continue;
|
|
@@ -16638,17 +16642,17 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
16638
16642
|
if (unsourced) return 1;
|
|
16639
16643
|
for (const host of ["claude-code", "hermes"]) {
|
|
16640
16644
|
const root = linkedSkillRoot(home, host);
|
|
16641
|
-
const
|
|
16645
|
+
const description = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude : HOST_DESCRIPTIONS.hermes;
|
|
16642
16646
|
try {
|
|
16643
|
-
accessSync(
|
|
16647
|
+
accessSync(resolveHostBinary(description, home), constants.X_OK);
|
|
16644
16648
|
} catch (error) {
|
|
16645
16649
|
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
16646
16650
|
throw error;
|
|
16647
16651
|
}
|
|
16648
16652
|
for (const name of packagedMethodSkillNames()) {
|
|
16649
|
-
const target =
|
|
16653
|
+
const target = join10(canonical, name);
|
|
16650
16654
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
16651
|
-
const link =
|
|
16655
|
+
const link = join10(root, name);
|
|
16652
16656
|
if (await occupied(link)) {
|
|
16653
16657
|
warnOccupied(link, stdout);
|
|
16654
16658
|
continue;
|
|
@@ -16678,9 +16682,9 @@ var init_machine_method_skills = __esm({
|
|
|
16678
16682
|
|
|
16679
16683
|
// src/typed-provider-http.ts
|
|
16680
16684
|
import { readFile as readFile3, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
16681
|
-
import { join as
|
|
16685
|
+
import { join as join11 } from "node:path";
|
|
16682
16686
|
function typedProviderHttpPath(runDirectory) {
|
|
16683
|
-
return
|
|
16687
|
+
return join11(runDirectory, TYPED_HTTP_FILE);
|
|
16684
16688
|
}
|
|
16685
16689
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
16686
16690
|
try {
|
|
@@ -16818,7 +16822,7 @@ var init_collector_config = __esm({
|
|
|
16818
16822
|
});
|
|
16819
16823
|
|
|
16820
16824
|
// src/auditor-dossier-tool.ts
|
|
16821
|
-
import { dirname as dirname5, join as
|
|
16825
|
+
import { dirname as dirname5, join as join12, resolve as resolve3 } from "node:path";
|
|
16822
16826
|
function auditorRunDirectory(context) {
|
|
16823
16827
|
const sessionFile = context.sessionManager?.getSessionFile?.();
|
|
16824
16828
|
if (sessionFile === void 0) return void 0;
|
|
@@ -16901,7 +16905,7 @@ __export(run_terminal_artifacts_exports, {
|
|
|
16901
16905
|
runIdFromRunDirectory: () => runIdFromRunDirectory
|
|
16902
16906
|
});
|
|
16903
16907
|
import { readdir as readdir2, readFile as readFile5 } from "node:fs/promises";
|
|
16904
|
-
import { basename as basename3, dirname as dirname6, join as
|
|
16908
|
+
import { basename as basename3, dirname as dirname6, join as join13 } from "node:path";
|
|
16905
16909
|
function isMissingPathError2(error) {
|
|
16906
16910
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
16907
16911
|
}
|
|
@@ -16976,7 +16980,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
16976
16980
|
}
|
|
16977
16981
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
16978
16982
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
16979
|
-
found.push(
|
|
16983
|
+
found.push(join13(dir, name));
|
|
16980
16984
|
}
|
|
16981
16985
|
}
|
|
16982
16986
|
return found;
|
|
@@ -17022,11 +17026,11 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
17022
17026
|
unreadable.push(read);
|
|
17023
17027
|
};
|
|
17024
17028
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
17025
|
-
consider(await readTerminalArtifactAtPath(
|
|
17029
|
+
consider(await readTerminalArtifactAtPath(join13(artifactsDir, file), file));
|
|
17026
17030
|
}
|
|
17027
17031
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
17028
17032
|
consider(
|
|
17029
|
-
await readTerminalArtifactAtPath(
|
|
17033
|
+
await readTerminalArtifactAtPath(join13(runDirectory, relative3), "error.json")
|
|
17030
17034
|
);
|
|
17031
17035
|
}
|
|
17032
17036
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
@@ -17368,7 +17372,7 @@ __export(session_assistant_usage_exports, {
|
|
|
17368
17372
|
sessionFileFromPublicSummon: () => sessionFileFromPublicSummon,
|
|
17369
17373
|
usageFromPublicSummon: () => usageFromPublicSummon
|
|
17370
17374
|
});
|
|
17371
|
-
import { join as
|
|
17375
|
+
import { join as join14 } from "node:path";
|
|
17372
17376
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
17373
17377
|
const { readFile: readFile22 } = await import("node:fs/promises");
|
|
17374
17378
|
let text;
|
|
@@ -17438,7 +17442,7 @@ async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
|
17438
17442
|
}
|
|
17439
17443
|
function sessionFileFromPublicSummon(summoned) {
|
|
17440
17444
|
if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
|
|
17441
|
-
return
|
|
17445
|
+
return join14(summoned.runDirectory, "session", "session.jsonl");
|
|
17442
17446
|
}
|
|
17443
17447
|
const fromArtifacts = summoned.terminal?.artifacts?.map((a) => a.path).find((p) => typeof p === "string" && p.endsWith("session.jsonl"));
|
|
17444
17448
|
if (fromArtifacts !== void 0) return fromArtifacts;
|
|
@@ -17447,7 +17451,7 @@ function sessionFileFromPublicSummon(summoned) {
|
|
|
17447
17451
|
const facts = outcome.decisiveFacts;
|
|
17448
17452
|
const pointer = facts?.runPointer;
|
|
17449
17453
|
if (typeof pointer === "string" && pointer.trim() !== "") {
|
|
17450
|
-
return
|
|
17454
|
+
return join14(pointer, "session", "session.jsonl");
|
|
17451
17455
|
}
|
|
17452
17456
|
return void 0;
|
|
17453
17457
|
}
|
|
@@ -17579,7 +17583,7 @@ var init_sitian_contracts = __esm({
|
|
|
17579
17583
|
// src/sitian-appender.ts
|
|
17580
17584
|
import { randomUUID } from "node:crypto";
|
|
17581
17585
|
import { appendFileSync } from "node:fs";
|
|
17582
|
-
import { dirname as dirname7, join as
|
|
17586
|
+
import { dirname as dirname7, join as join15 } from "node:path";
|
|
17583
17587
|
function appendSitianRecordBlock(input, block) {
|
|
17584
17588
|
if (block === "") return;
|
|
17585
17589
|
try {
|
|
@@ -17601,8 +17605,8 @@ function resolveSitianVolumeCategory(kind) {
|
|
|
17601
17605
|
return kind;
|
|
17602
17606
|
}
|
|
17603
17607
|
function ticketProvenanceUnderBookPaths(ledgerHome, bookKey, ticketId) {
|
|
17604
|
-
const sessionDir =
|
|
17605
|
-
return { sessionDir, recordFile:
|
|
17608
|
+
const sessionDir = join15(activationBookDirectory(ledgerHome, bookKey), ticketId);
|
|
17609
|
+
return { sessionDir, recordFile: join15(sessionDir, SITIAN_RECORDS_LEAF) };
|
|
17606
17610
|
}
|
|
17607
17611
|
function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
17608
17612
|
const category = resolveSitianVolumeCategory(input.kind);
|
|
@@ -17619,13 +17623,13 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
17619
17623
|
recordFile = paths.recordFile;
|
|
17620
17624
|
} else if (category === "ticket-provenance" && input.runDirectory !== void 0) {
|
|
17621
17625
|
sessionDir = input.runDirectory;
|
|
17622
|
-
recordFile =
|
|
17626
|
+
recordFile = join15(sessionDir, SITIAN_RECORDS_LEAF);
|
|
17623
17627
|
} else {
|
|
17624
17628
|
if (input.sessionParent === void 0 || input.sessionParent.length === 0 || !physicallyContainedIn(ledgerHome, input.sessionParent)) {
|
|
17625
17629
|
throw new Error("Sitian record ownership requires a parent session inside the ledger home");
|
|
17626
17630
|
}
|
|
17627
|
-
sessionDir =
|
|
17628
|
-
recordFile =
|
|
17631
|
+
sessionDir = join15(dirname7(input.sessionParent), category);
|
|
17632
|
+
recordFile = join15(sessionDir, SITIAN_RECORDS_LEAF);
|
|
17629
17633
|
}
|
|
17630
17634
|
if (!physicallyContainedIn(ledgerHome, sessionDir)) {
|
|
17631
17635
|
throw new Error("Sitian record ownership requires a directory inside the ledger home");
|
|
@@ -17766,12 +17770,12 @@ __export(role_turn_host_exports, {
|
|
|
17766
17770
|
import { execFile, spawn } from "node:child_process";
|
|
17767
17771
|
import { constants as constants2 } from "node:fs";
|
|
17768
17772
|
import { access, appendFile, readFile as readFile7, realpath } from "node:fs/promises";
|
|
17769
|
-
import { delimiter as delimiter2, dirname as dirname8, isAbsolute as isAbsolute3, join as
|
|
17773
|
+
import { delimiter as delimiter2, dirname as dirname8, isAbsolute as isAbsolute3, join as join16, resolve as resolve4 } from "node:path";
|
|
17770
17774
|
import { platform } from "node:process";
|
|
17771
17775
|
import { promisify } from "node:util";
|
|
17772
17776
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
17773
17777
|
function resolveInternalRoleEntrypoint(packageRoot2) {
|
|
17774
|
-
return
|
|
17778
|
+
return join16(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
17775
17779
|
}
|
|
17776
17780
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
17777
17781
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -18644,7 +18648,7 @@ var init_session_dialogue = __esm({
|
|
|
18644
18648
|
|
|
18645
18649
|
// src/ticket-provenance.ts
|
|
18646
18650
|
import { readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
|
|
18647
|
-
import { basename as basename4, dirname as dirname10, join as
|
|
18651
|
+
import { basename as basename4, dirname as dirname10, join as join17, resolve as resolve7 } from "node:path";
|
|
18648
18652
|
function ticketProvenanceSubject(ticketNumber) {
|
|
18649
18653
|
if (!isSafePositiveTicketNumber(ticketNumber)) {
|
|
18650
18654
|
throw new Error(
|
|
@@ -18664,7 +18668,7 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
18664
18668
|
};
|
|
18665
18669
|
}
|
|
18666
18670
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
18667
|
-
const source =
|
|
18671
|
+
const source = join17(runDirectory, "records.jsonl");
|
|
18668
18672
|
let content;
|
|
18669
18673
|
try {
|
|
18670
18674
|
content = await readFile11(source, "utf8");
|
|
@@ -18713,7 +18717,7 @@ var init_uuidv7 = __esm({
|
|
|
18713
18717
|
});
|
|
18714
18718
|
|
|
18715
18719
|
// src/notary-source-run.ts
|
|
18716
|
-
import { dirname as dirname11, isAbsolute as isAbsolute5, join as
|
|
18720
|
+
import { dirname as dirname11, isAbsolute as isAbsolute5, join as join18, resolve as resolve8, basename as basename5 } from "node:path";
|
|
18717
18721
|
import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
|
|
18718
18722
|
async function readRetainedIdentity(runDirectory) {
|
|
18719
18723
|
try {
|
|
@@ -18770,11 +18774,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
18770
18774
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
18771
18775
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
18772
18776
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
18773
|
-
const bookRunsRoot =
|
|
18777
|
+
const bookRunsRoot = join18(bookDirectory, "runs");
|
|
18774
18778
|
let candidate;
|
|
18775
18779
|
const bare = parseRunDirectoryName(raw);
|
|
18776
18780
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
18777
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
18781
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join18(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
18778
18782
|
} else {
|
|
18779
18783
|
candidate = isAbsolute5(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
18780
18784
|
const identity2 = parseRunDirectoryName(basename5(candidate));
|
|
@@ -19890,7 +19894,7 @@ import {
|
|
|
19890
19894
|
writeFile as writeFile3
|
|
19891
19895
|
} from "node:fs/promises";
|
|
19892
19896
|
import { tmpdir } from "node:os";
|
|
19893
|
-
import { basename as basename6, dirname as dirname12, isAbsolute as isAbsolute6, join as
|
|
19897
|
+
import { basename as basename6, dirname as dirname12, isAbsolute as isAbsolute6, join as join19, resolve as resolve9, sep as sep3 } from "node:path";
|
|
19894
19898
|
function issueAdmissionPlacement(authority, request) {
|
|
19895
19899
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
19896
19900
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -19944,14 +19948,14 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
19944
19948
|
...effectiveModelLedgerFields(effectiveModel)
|
|
19945
19949
|
};
|
|
19946
19950
|
await writeFile3(
|
|
19947
|
-
|
|
19951
|
+
join19(source.runDirectory, "invocation.json"),
|
|
19948
19952
|
`${JSON.stringify(identity, null, 2)}
|
|
19949
19953
|
`,
|
|
19950
19954
|
"utf8"
|
|
19951
19955
|
);
|
|
19952
19956
|
}
|
|
19953
19957
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
19954
|
-
const ledgerPath =
|
|
19958
|
+
const ledgerPath = join19(runDirectory, "invocation.json");
|
|
19955
19959
|
const current = JSON.parse(await readFile12(ledgerPath, "utf8"));
|
|
19956
19960
|
const next = { ...current };
|
|
19957
19961
|
if (model !== void 0) {
|
|
@@ -19984,7 +19988,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
19984
19988
|
);
|
|
19985
19989
|
}
|
|
19986
19990
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
19987
|
-
const ledgerPath =
|
|
19991
|
+
const ledgerPath = join19(runDirectory, "invocation.json");
|
|
19988
19992
|
const current = JSON.parse(await readFile12(ledgerPath, "utf8"));
|
|
19989
19993
|
await writeFile3(
|
|
19990
19994
|
ledgerPath,
|
|
@@ -20067,7 +20071,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
20067
20071
|
const childRunIds = parentPage.childDiaristRunIds;
|
|
20068
20072
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
20069
20073
|
if (typeof childRunId !== "string") continue;
|
|
20070
|
-
const childDirectory =
|
|
20074
|
+
const childDirectory = join19(dirname12(oldRunDirectory), `${childRunId}@diarist`);
|
|
20071
20075
|
if (!existsSync4(childDirectory)) continue;
|
|
20072
20076
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
20073
20077
|
bookKey: admitted.bookKey,
|
|
@@ -20124,7 +20128,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
20124
20128
|
ticketNumber,
|
|
20125
20129
|
"bindTicketNumberOnRunDirectory"
|
|
20126
20130
|
);
|
|
20127
|
-
const admittedPath =
|
|
20131
|
+
const admittedPath = join19(runDirectory, "admitted-request.json");
|
|
20128
20132
|
const admitted = JSON.parse(await readFile12(admittedPath, "utf8"));
|
|
20129
20133
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
20130
20134
|
await writeFile3(
|
|
@@ -20144,7 +20148,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
20144
20148
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
20145
20149
|
const rolePackageRoot = packageRoot2;
|
|
20146
20150
|
const raw = JSON.parse(
|
|
20147
|
-
await readFile12(
|
|
20151
|
+
await readFile12(join19(rolePackageRoot, "package.json"), "utf8")
|
|
20148
20152
|
);
|
|
20149
20153
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
20150
20154
|
throw new Error(
|
|
@@ -20432,13 +20436,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
|
20432
20436
|
}
|
|
20433
20437
|
async function withPreparedAttachments(attachmentPaths, use) {
|
|
20434
20438
|
if (attachmentPaths.length === 0) return await use([]);
|
|
20435
|
-
const stagingDirectory = await mkdtemp(
|
|
20439
|
+
const stagingDirectory = await mkdtemp(join19(tmpdir(), "ak-role-attachments-"));
|
|
20436
20440
|
const prepared = [];
|
|
20437
20441
|
let result;
|
|
20438
20442
|
try {
|
|
20439
20443
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
20440
20444
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
20441
|
-
const snapshotPath =
|
|
20445
|
+
const snapshotPath = join19(stagingDirectory, String(index).padStart(6, "0"));
|
|
20442
20446
|
await writeFile3(snapshotPath, bytes);
|
|
20443
20447
|
prepared.push({ absolute, snapshotPath });
|
|
20444
20448
|
}
|
|
@@ -20459,7 +20463,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
20459
20463
|
return result;
|
|
20460
20464
|
}
|
|
20461
20465
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
20462
|
-
const frozenPath =
|
|
20466
|
+
const frozenPath = join19(
|
|
20463
20467
|
destinationDir,
|
|
20464
20468
|
`${String(index).padStart(2, "0")}-${basename6(provenancePath)}`
|
|
20465
20469
|
);
|
|
@@ -20502,14 +20506,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
20502
20506
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
20503
20507
|
if (attachmentPaths.length === 0) return [];
|
|
20504
20508
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
20505
|
-
const attachmentsDirectory =
|
|
20509
|
+
const attachmentsDirectory = join19(runDirectory, "attachments", summonsKey);
|
|
20506
20510
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20507
20511
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
20508
20512
|
}
|
|
20509
20513
|
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
20510
20514
|
if (prepared.length === 0) return [];
|
|
20511
20515
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
20512
|
-
const attachmentsDirectory = summonsKey === void 0 ?
|
|
20516
|
+
const attachmentsDirectory = summonsKey === void 0 ? join19(runDirectory, "attachments") : join19(runDirectory, "attachments", summonsKey);
|
|
20513
20517
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20514
20518
|
const attachments = [];
|
|
20515
20519
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
@@ -20586,7 +20590,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20586
20590
|
attachmentPaths,
|
|
20587
20591
|
...project,
|
|
20588
20592
|
placedFields: async (placed) => {
|
|
20589
|
-
const taskPath =
|
|
20593
|
+
const taskPath = join19(placed.runDirectory, "task.md");
|
|
20590
20594
|
await writeFile3(taskPath, instruction, "utf8");
|
|
20591
20595
|
return { phase, taskPath };
|
|
20592
20596
|
}
|
|
@@ -20632,7 +20636,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20632
20636
|
placedFields: async (placed) => {
|
|
20633
20637
|
let prerequisitesPath;
|
|
20634
20638
|
if (prerequisitesSource !== void 0) {
|
|
20635
|
-
prerequisitesPath =
|
|
20639
|
+
prerequisitesPath = join19(placed.runDirectory, "prerequisites.json");
|
|
20636
20640
|
await writeFile3(
|
|
20637
20641
|
prerequisitesPath,
|
|
20638
20642
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -20640,7 +20644,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20640
20644
|
"utf8"
|
|
20641
20645
|
);
|
|
20642
20646
|
}
|
|
20643
|
-
const packetPath =
|
|
20647
|
+
const packetPath = join19(placed.runDirectory, "fix-packet.md");
|
|
20644
20648
|
await writeFile3(packetPath, instruction, "utf8");
|
|
20645
20649
|
return {
|
|
20646
20650
|
phase,
|
|
@@ -20698,7 +20702,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20698
20702
|
placedFields: async (placed) => {
|
|
20699
20703
|
let requestManifestPath;
|
|
20700
20704
|
if (manifestCanonicalJson !== void 0) {
|
|
20701
|
-
requestManifestPath =
|
|
20705
|
+
requestManifestPath = join19(placed.runDirectory, "request-manifest.json");
|
|
20702
20706
|
await writeFile3(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
20703
20707
|
}
|
|
20704
20708
|
return {
|
|
@@ -20888,7 +20892,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20888
20892
|
resolutionScope: [...derived.resolutionScope],
|
|
20889
20893
|
authorizedChecks: []
|
|
20890
20894
|
});
|
|
20891
|
-
const mergerInputPath =
|
|
20895
|
+
const mergerInputPath = join19(placed.runDirectory, "merger-input.json");
|
|
20892
20896
|
await writeFile3(
|
|
20893
20897
|
mergerInputPath,
|
|
20894
20898
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -20962,7 +20966,7 @@ function persistedAttachmentRefs(attachments) {
|
|
|
20962
20966
|
}));
|
|
20963
20967
|
}
|
|
20964
20968
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
20965
|
-
const admittedRequestPath =
|
|
20969
|
+
const admittedRequestPath = join19(placed.runDirectory, "admitted-request.json");
|
|
20966
20970
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20967
20971
|
sessionDirectory: placed.sessionDirectory,
|
|
20968
20972
|
sessionFile: placed.sessionFile
|
|
@@ -21015,7 +21019,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
21015
21019
|
attachments: persistedAttachmentRefs(placed.attachments),
|
|
21016
21020
|
...placed.ticketFields
|
|
21017
21021
|
};
|
|
21018
|
-
const admittedRequestPath = defer ?
|
|
21022
|
+
const admittedRequestPath = defer ? join19(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
|
|
21019
21023
|
return {
|
|
21020
21024
|
role,
|
|
21021
21025
|
runId: placed.runId,
|
|
@@ -21093,7 +21097,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
21093
21097
|
});
|
|
21094
21098
|
const placement = placed;
|
|
21095
21099
|
admitted.runDirectory = placement.runDirectory;
|
|
21096
|
-
admitted.admittedRequestPath =
|
|
21100
|
+
admitted.admittedRequestPath = join19(
|
|
21097
21101
|
placement.runDirectory,
|
|
21098
21102
|
"admitted-request.json"
|
|
21099
21103
|
);
|
|
@@ -21189,7 +21193,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
21189
21193
|
}
|
|
21190
21194
|
async function resolveDoctorCaseRunsPath(options) {
|
|
21191
21195
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
21192
|
-
const defaultRuns =
|
|
21196
|
+
const defaultRuns = join19(
|
|
21193
21197
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
21194
21198
|
String(options.issueNumber),
|
|
21195
21199
|
"runs"
|
|
@@ -21510,15 +21514,15 @@ var init_invocation = __esm({
|
|
|
21510
21514
|
|
|
21511
21515
|
// src/public-cli/load-production-acp-host.ts
|
|
21512
21516
|
import { existsSync as existsSync5 } from "node:fs";
|
|
21513
|
-
import { join as
|
|
21517
|
+
import { join as join20 } from "node:path";
|
|
21514
21518
|
import { pathToFileURL } from "node:url";
|
|
21515
21519
|
async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
21516
21520
|
const description = lookupHostDescription(host);
|
|
21517
21521
|
if (description === void 0) {
|
|
21518
21522
|
throw new Error(`unregistered host: ${host}`);
|
|
21519
21523
|
}
|
|
21520
|
-
const built =
|
|
21521
|
-
const source =
|
|
21524
|
+
const built = join20(packageRoot2, "dist/acp-host/production-host.js");
|
|
21525
|
+
const source = join20(packageRoot2, "src/acp-host/production-host.ts");
|
|
21522
21526
|
const target = existsSync5(built) ? built : source;
|
|
21523
21527
|
const href = pathToFileURL(target).href;
|
|
21524
21528
|
const mod = await import(href);
|
|
@@ -21534,15 +21538,15 @@ var init_load_production_acp_host = __esm({
|
|
|
21534
21538
|
|
|
21535
21539
|
// src/public-cli/load-production-headless-host.ts
|
|
21536
21540
|
import { existsSync as existsSync6 } from "node:fs";
|
|
21537
|
-
import { join as
|
|
21541
|
+
import { join as join21 } from "node:path";
|
|
21538
21542
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
21539
21543
|
async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
21540
21544
|
const description = lookupHeadlessHostDescription(host);
|
|
21541
21545
|
if (description === void 0) {
|
|
21542
21546
|
throw new Error(`unregistered headless host: ${host}`);
|
|
21543
21547
|
}
|
|
21544
|
-
const built =
|
|
21545
|
-
const source =
|
|
21548
|
+
const built = join21(packageRoot2, "dist/headless-host/production-host.js");
|
|
21549
|
+
const source = join21(packageRoot2, "src/headless-host/production-host.ts");
|
|
21546
21550
|
const target = existsSync6(built) ? built : source;
|
|
21547
21551
|
const href = pathToFileURL2(target).href;
|
|
21548
21552
|
const mod = await import(href);
|
|
@@ -21669,7 +21673,7 @@ var init_role_turn_host_resolution = __esm({
|
|
|
21669
21673
|
|
|
21670
21674
|
// src/analyst-gate-cycles-read.ts
|
|
21671
21675
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
21672
|
-
import { join as
|
|
21676
|
+
import { join as join22 } from "node:path";
|
|
21673
21677
|
function isRecord4(value) {
|
|
21674
21678
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21675
21679
|
}
|
|
@@ -21920,7 +21924,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
21920
21924
|
throw error;
|
|
21921
21925
|
}
|
|
21922
21926
|
for (const name of names) {
|
|
21923
|
-
const path =
|
|
21927
|
+
const path = join22(directory, name);
|
|
21924
21928
|
const fromPointer = name.endsWith(".pointer.json");
|
|
21925
21929
|
const pointer = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : void 0;
|
|
21926
21930
|
const sessionPath = pointer?.sessionFile ?? path;
|
|
@@ -21962,14 +21966,14 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
21962
21966
|
});
|
|
21963
21967
|
|
|
21964
21968
|
// src/submission-ledger.ts
|
|
21965
|
-
import { join as
|
|
21969
|
+
import { join as join23 } from "node:path";
|
|
21966
21970
|
async function submissionRecordFile(cwd, runId, scope) {
|
|
21967
21971
|
const ledgerHome = resolveActivationLedgerHome(scope.home);
|
|
21968
21972
|
let sessionParent = scope.sessionParent;
|
|
21969
21973
|
if (sessionParent === void 0) {
|
|
21970
21974
|
const discoveredRun = await findRunDirectoryById(scope.home, runId);
|
|
21971
21975
|
if (discoveredRun === void 0) return void 0;
|
|
21972
|
-
sessionParent =
|
|
21976
|
+
sessionParent = join23(discoveredRun, "session", "session.jsonl");
|
|
21973
21977
|
}
|
|
21974
21978
|
return resolveSitianRecordPathInLedger({
|
|
21975
21979
|
level: "event",
|
|
@@ -22166,12 +22170,12 @@ var init_audit_escalation = __esm({
|
|
|
22166
22170
|
// src/session-opening-materials.ts
|
|
22167
22171
|
import { existsSync as existsSync7 } from "node:fs";
|
|
22168
22172
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
22169
|
-
import { dirname as dirname13, join as
|
|
22173
|
+
import { dirname as dirname13, join as join24 } from "node:path";
|
|
22170
22174
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
22171
22175
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
22172
22176
|
let dir = dirname13(fileURLToPath(moduleUrl));
|
|
22173
22177
|
for (let i = 0; i < 8; i += 1) {
|
|
22174
|
-
if (existsSync7(
|
|
22178
|
+
if (existsSync7(join24(dir, "package.json")) && existsSync7(join24(dir, "souls"))) {
|
|
22175
22179
|
return dir;
|
|
22176
22180
|
}
|
|
22177
22181
|
const parent = dirname13(dir);
|
|
@@ -22224,7 +22228,7 @@ __export(auditor_soul_exports, {
|
|
|
22224
22228
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
22225
22229
|
});
|
|
22226
22230
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
22227
|
-
import { basename as basename7, join as
|
|
22231
|
+
import { basename as basename7, join as join25 } from "node:path";
|
|
22228
22232
|
function auditorSoulRelativePath(role) {
|
|
22229
22233
|
return `souls/${role}-auditor.md`;
|
|
22230
22234
|
}
|
|
@@ -22266,7 +22270,7 @@ function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
|
22266
22270
|
async function readAuditorResumeBinding(runDirectory) {
|
|
22267
22271
|
let raw;
|
|
22268
22272
|
try {
|
|
22269
|
-
raw = JSON.parse(await readFile14(
|
|
22273
|
+
raw = JSON.parse(await readFile14(join25(runDirectory, "admitted-request.json"), "utf8"));
|
|
22270
22274
|
} catch (error) {
|
|
22271
22275
|
if (error.code === "ENOENT") return void 0;
|
|
22272
22276
|
throw error;
|
|
@@ -22379,7 +22383,7 @@ var init_serialize_thrown_value = __esm({
|
|
|
22379
22383
|
// src/engine-detour-usage.ts
|
|
22380
22384
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
22381
22385
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
22382
|
-
import { dirname as dirname14, join as
|
|
22386
|
+
import { dirname as dirname14, join as join26 } from "node:path";
|
|
22383
22387
|
function isRecord5(value) {
|
|
22384
22388
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22385
22389
|
}
|
|
@@ -22464,7 +22468,7 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
22464
22468
|
function readInvocationRecord(runDirectory) {
|
|
22465
22469
|
try {
|
|
22466
22470
|
const raw = JSON.parse(
|
|
22467
|
-
readFileSync2(
|
|
22471
|
+
readFileSync2(join26(runDirectory, "invocation.json"), "utf8")
|
|
22468
22472
|
);
|
|
22469
22473
|
return isRecord5(raw) ? raw : void 0;
|
|
22470
22474
|
} catch (error) {
|
|
@@ -22492,7 +22496,7 @@ function runDirectoryFromSessionDirectory(sessionDirectory) {
|
|
|
22492
22496
|
return dirname14(sessionDirectory);
|
|
22493
22497
|
}
|
|
22494
22498
|
function sessionFileFromSessionDirectory(sessionDirectory) {
|
|
22495
|
-
return
|
|
22499
|
+
return join26(sessionDirectory, "session.jsonl");
|
|
22496
22500
|
}
|
|
22497
22501
|
function mintEngineDetourInvocationScope(input) {
|
|
22498
22502
|
const engine = input.effectiveEngine?.trim();
|
|
@@ -22799,14 +22803,14 @@ __export(settlement_exports, {
|
|
|
22799
22803
|
});
|
|
22800
22804
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
22801
22805
|
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
|
|
22802
|
-
import { dirname as dirname15, join as
|
|
22806
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
22803
22807
|
function sealedLedgerHome(admitted) {
|
|
22804
22808
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
22805
22809
|
}
|
|
22806
22810
|
function ledgerReadScope(admitted, scope) {
|
|
22807
22811
|
return {
|
|
22808
22812
|
home: sealedLedgerHome(admitted),
|
|
22809
|
-
sessionParent:
|
|
22813
|
+
sessionParent: join27(admitted.runDirectory, "session", "session.jsonl"),
|
|
22810
22814
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
22811
22815
|
};
|
|
22812
22816
|
}
|
|
@@ -23307,7 +23311,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
23307
23311
|
}
|
|
23308
23312
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
23309
23313
|
if (parentId === void 0) return void 0;
|
|
23310
|
-
const childDirectories = [
|
|
23314
|
+
const childDirectories = [join27(dirname15(sessionFile), "auditor-roles")];
|
|
23311
23315
|
const valid = [];
|
|
23312
23316
|
let sawAnyDirectory = false;
|
|
23313
23317
|
for (const childDirectory of childDirectories) {
|
|
@@ -23322,7 +23326,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
23322
23326
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
23323
23327
|
let entries;
|
|
23324
23328
|
try {
|
|
23325
|
-
entries = await readBoundSessionEntries(
|
|
23329
|
+
entries = await readBoundSessionEntries(join27(childDirectory, file));
|
|
23326
23330
|
} catch (error) {
|
|
23327
23331
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
23328
23332
|
}
|
|
@@ -23798,8 +23802,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
23798
23802
|
};
|
|
23799
23803
|
}
|
|
23800
23804
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
23801
|
-
const directories = [
|
|
23802
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
23805
|
+
const directories = [join27(sessionDirectory, "auditor-roles")];
|
|
23806
|
+
const parentSessionFile = options.parentSessionFile ?? join27(sessionDirectory, "session.jsonl");
|
|
23803
23807
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
23804
23808
|
parentSessionFile
|
|
23805
23809
|
});
|
|
@@ -23911,10 +23915,10 @@ async function removeFaceIfPresent(path) {
|
|
|
23911
23915
|
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
23912
23916
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
23913
23917
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
23914
|
-
await removeFaceIfPresent(
|
|
23918
|
+
await removeFaceIfPresent(join27(artifactsDir, file));
|
|
23915
23919
|
}
|
|
23916
23920
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
23917
|
-
await removeFaceIfPresent(
|
|
23921
|
+
await removeFaceIfPresent(join27(runDirectory, relative3));
|
|
23918
23922
|
}
|
|
23919
23923
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
23920
23924
|
await removeFaceIfPresent(path);
|
|
@@ -23943,8 +23947,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
23943
23947
|
roleOutcome
|
|
23944
23948
|
);
|
|
23945
23949
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
23946
|
-
const reportPath =
|
|
23947
|
-
const evidencePath =
|
|
23950
|
+
const reportPath = join27(artifactsDir, "report.json");
|
|
23951
|
+
const evidencePath = join27(artifactsDir, "evidence.json");
|
|
23948
23952
|
await writeFile4(
|
|
23949
23953
|
reportPath,
|
|
23950
23954
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
@@ -24353,7 +24357,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
24353
24357
|
const candidates = [
|
|
24354
24358
|
...preferredCandidates,
|
|
24355
24359
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
24356
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
24360
|
+
...uniqueFallbackDirs.map((dir) => join27(dir, `${stem}.${randomUUID4()}.json`))
|
|
24357
24361
|
];
|
|
24358
24362
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
24359
24363
|
const path = candidates[i];
|
|
@@ -24414,20 +24418,20 @@ async function publishFailureArtifacts(admitted, failure, authority, onErrorPubl
|
|
|
24414
24418
|
baseDir
|
|
24415
24419
|
);
|
|
24416
24420
|
const errorCandidates = underArtifacts ? [
|
|
24417
|
-
|
|
24418
|
-
|
|
24419
|
-
|
|
24421
|
+
join27(baseDir, "error.json"),
|
|
24422
|
+
join27(baseDir, "error.settlement.json"),
|
|
24423
|
+
join27(admitted.runDirectory, "error.settlement.json")
|
|
24420
24424
|
] : [
|
|
24421
|
-
|
|
24422
|
-
|
|
24425
|
+
join27(baseDir, "error.settlement.json"),
|
|
24426
|
+
join27(baseDir, "error.json")
|
|
24423
24427
|
];
|
|
24424
24428
|
const evidenceCandidates = underArtifacts ? [
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
|
|
24429
|
+
join27(baseDir, "evidence.json"),
|
|
24430
|
+
join27(baseDir, "evidence.settlement.json"),
|
|
24431
|
+
join27(admitted.runDirectory, "evidence.settlement.json")
|
|
24428
24432
|
] : [
|
|
24429
|
-
|
|
24430
|
-
|
|
24433
|
+
join27(baseDir, "evidence.settlement.json"),
|
|
24434
|
+
join27(baseDir, "evidence.json")
|
|
24431
24435
|
];
|
|
24432
24436
|
const errorPayloadBase = {
|
|
24433
24437
|
kind: "error",
|
|
@@ -24682,9 +24686,9 @@ var init_settlement = __esm({
|
|
|
24682
24686
|
|
|
24683
24687
|
// src/archivist-record-pointer.ts
|
|
24684
24688
|
import { mkdirSync as mkdirSync3, writeFileSync } from "node:fs";
|
|
24685
|
-
import { dirname as dirname16, join as
|
|
24689
|
+
import { dirname as dirname16, join as join28 } from "node:path";
|
|
24686
24690
|
function bookDirectOfficerRunPointer(options) {
|
|
24687
|
-
const nest =
|
|
24691
|
+
const nest = join28(dirname16(options.parentSessionFile), "auditor-roles");
|
|
24688
24692
|
mkdirSync3(nest, { recursive: true });
|
|
24689
24693
|
const pointer = {
|
|
24690
24694
|
version: 1,
|
|
@@ -24694,7 +24698,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
24694
24698
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
24695
24699
|
};
|
|
24696
24700
|
writeFileSync(
|
|
24697
|
-
|
|
24701
|
+
join28(nest, `${options.officer}.pointer.json`),
|
|
24698
24702
|
`${JSON.stringify(pointer)}
|
|
24699
24703
|
`,
|
|
24700
24704
|
"utf8"
|
|
@@ -26094,7 +26098,7 @@ __export(public_role_summons_exports, {
|
|
|
26094
26098
|
import { execFile as execFile3 } from "node:child_process";
|
|
26095
26099
|
import { existsSync as existsSync9 } from "node:fs";
|
|
26096
26100
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
26097
|
-
import { join as
|
|
26101
|
+
import { join as join29 } from "node:path";
|
|
26098
26102
|
import { promisify as promisify3 } from "node:util";
|
|
26099
26103
|
function createCapturingIo() {
|
|
26100
26104
|
const chunks = [];
|
|
@@ -26118,7 +26122,7 @@ function parentDir(path) {
|
|
|
26118
26122
|
function walkPackageRoot(start) {
|
|
26119
26123
|
let dir = start;
|
|
26120
26124
|
for (let i = 0; i < 12; i += 1) {
|
|
26121
|
-
if (existsSync9(
|
|
26125
|
+
if (existsSync9(join29(dir, "package.json")) && existsSync9(join29(dir, "souls"))) {
|
|
26122
26126
|
return dir;
|
|
26123
26127
|
}
|
|
26124
26128
|
const parent = parentDir(dir);
|
|
@@ -26234,7 +26238,7 @@ async function createSummonEnv(options, afterHost) {
|
|
|
26234
26238
|
async function summonPublicRole(options) {
|
|
26235
26239
|
const packageRoot2 = resolveSummonsPackageRoot(options.packageRoot);
|
|
26236
26240
|
const home = await resolveSummonHome(options);
|
|
26237
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
26241
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join29(home, ".pi", "agent");
|
|
26238
26242
|
const {
|
|
26239
26243
|
loadCredentialProviders: loadCredentialProviders2,
|
|
26240
26244
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -26736,7 +26740,7 @@ var init_compliance_transport = __esm({
|
|
|
26736
26740
|
});
|
|
26737
26741
|
|
|
26738
26742
|
// src/role-run-relocation.ts
|
|
26739
|
-
import { join as
|
|
26743
|
+
import { join as join30, sep as sep5 } from "node:path";
|
|
26740
26744
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
26741
26745
|
if (typeof value !== "string") return value;
|
|
26742
26746
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -26864,7 +26868,7 @@ __export(run_lifecycle_exports, {
|
|
|
26864
26868
|
writeRoleRunState: () => writeRoleRunState
|
|
26865
26869
|
});
|
|
26866
26870
|
import { chmod, lstat as lstat5, open, readdir as readdir6, readFile as readFile16, unlink as unlink4, writeFile as writeFile5 } from "node:fs/promises";
|
|
26867
|
-
import { basename as basename8, join as
|
|
26871
|
+
import { basename as basename8, join as join31 } from "node:path";
|
|
26868
26872
|
function buildAutoResumeContinuationPrompt(options) {
|
|
26869
26873
|
return appendEngineSessionMaterial(
|
|
26870
26874
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -26890,7 +26894,7 @@ function renderResumeCommand(runId) {
|
|
|
26890
26894
|
async function writeRoleRunState(runDirectory, record4) {
|
|
26891
26895
|
const payload = { ...record4, runDirectory };
|
|
26892
26896
|
await writeFile5(
|
|
26893
|
-
|
|
26897
|
+
join31(runDirectory, RUN_STATE_FILE),
|
|
26894
26898
|
`${JSON.stringify(payload, null, 2)}
|
|
26895
26899
|
`,
|
|
26896
26900
|
"utf8"
|
|
@@ -26940,7 +26944,7 @@ function parseCurrentCourtState(raw) {
|
|
|
26940
26944
|
async function readRoleRunStateRaw(runDirectory) {
|
|
26941
26945
|
let raw;
|
|
26942
26946
|
try {
|
|
26943
|
-
raw = JSON.parse(await readFile16(
|
|
26947
|
+
raw = JSON.parse(await readFile16(join31(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
26944
26948
|
} catch (error) {
|
|
26945
26949
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
26946
26950
|
throw error;
|
|
@@ -27034,7 +27038,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
27034
27038
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
27035
27039
|
};
|
|
27036
27040
|
await writeFile5(
|
|
27037
|
-
|
|
27041
|
+
join31(runDirectory, RUN_STATE_FILE),
|
|
27038
27042
|
`${JSON.stringify(payload, null, 2)}
|
|
27039
27043
|
`,
|
|
27040
27044
|
"utf8"
|
|
@@ -27257,7 +27261,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
27257
27261
|
},
|
|
27258
27262
|
relocate(nextRunDirectory) {
|
|
27259
27263
|
currentRunDirectory = nextRunDirectory;
|
|
27260
|
-
currentLockPath =
|
|
27264
|
+
currentLockPath = join31(nextRunDirectory, WRITER_LOCK_FILE);
|
|
27261
27265
|
},
|
|
27262
27266
|
async release() {
|
|
27263
27267
|
if (released) return;
|
|
@@ -27296,10 +27300,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
27296
27300
|
};
|
|
27297
27301
|
const reportReadFailure = (error) => {
|
|
27298
27302
|
reportDiagnostic(
|
|
27299
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
27303
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join31(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
27300
27304
|
);
|
|
27301
27305
|
};
|
|
27302
|
-
const lockPath =
|
|
27306
|
+
const lockPath = join31(runDirectory, WRITER_LOCK_FILE);
|
|
27303
27307
|
let lastAutopsy = { verdict: "absent" };
|
|
27304
27308
|
let lastReclaimFailure;
|
|
27305
27309
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -27354,7 +27358,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
27354
27358
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
27355
27359
|
if (runId.trim() === "") return void 0;
|
|
27356
27360
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
27357
|
-
const booksRoot =
|
|
27361
|
+
const booksRoot = join31(ledgerHome, "books");
|
|
27358
27362
|
let bookKeys;
|
|
27359
27363
|
try {
|
|
27360
27364
|
bookKeys = await readdir6(booksRoot);
|
|
@@ -27395,7 +27399,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
27395
27399
|
let raw;
|
|
27396
27400
|
try {
|
|
27397
27401
|
raw = JSON.parse(
|
|
27398
|
-
await readFile16(
|
|
27402
|
+
await readFile16(join31(runDirectory, "admitted-request.json"), "utf8")
|
|
27399
27403
|
);
|
|
27400
27404
|
} catch (error) {
|
|
27401
27405
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -27416,7 +27420,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
27416
27420
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
27417
27421
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
27418
27422
|
if (disk === void 0) return false;
|
|
27419
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
27423
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join31(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
27420
27424
|
try {
|
|
27421
27425
|
const stat2 = await lstat5(sessionFile);
|
|
27422
27426
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -27434,7 +27438,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
27434
27438
|
let runDirectories;
|
|
27435
27439
|
try {
|
|
27436
27440
|
runDirectories = await listBookRunDirectories(
|
|
27437
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
27441
|
+
input.ticketNumber === void 0 ? bookDir : join31(bookDir, String(input.ticketNumber))
|
|
27438
27442
|
);
|
|
27439
27443
|
} catch (error) {
|
|
27440
27444
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -27632,7 +27636,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27632
27636
|
let model;
|
|
27633
27637
|
try {
|
|
27634
27638
|
const invocationRaw = JSON.parse(
|
|
27635
|
-
await readFile16(
|
|
27639
|
+
await readFile16(join31(run.runDirectory, "invocation.json"), "utf8")
|
|
27636
27640
|
);
|
|
27637
27641
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
27638
27642
|
const rec = invocationRaw;
|
|
@@ -28001,9 +28005,9 @@ var init_run_lifecycle = __esm({
|
|
|
28001
28005
|
|
|
28002
28006
|
// src/session-identity.ts
|
|
28003
28007
|
import { mkdir as mkdir3, readFile as readFile17, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
|
|
28004
|
-
import { dirname as dirname18, join as
|
|
28008
|
+
import { dirname as dirname18, join as join32 } from "node:path";
|
|
28005
28009
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
28006
|
-
const bindingPath = (principal) =>
|
|
28010
|
+
const bindingPath = (principal) => join32(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
28007
28011
|
return {
|
|
28008
28012
|
resolveSessionFile(principal) {
|
|
28009
28013
|
return authority.decode(principal).sessionFile;
|
|
@@ -28114,7 +28118,7 @@ import {
|
|
|
28114
28118
|
rmSync as rmSync2,
|
|
28115
28119
|
statSync as statSync4
|
|
28116
28120
|
} from "node:fs";
|
|
28117
|
-
import { dirname as dirname19, join as
|
|
28121
|
+
import { dirname as dirname19, join as join33 } from "node:path";
|
|
28118
28122
|
function declareHostSessionFailure(error) {
|
|
28119
28123
|
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
28120
28124
|
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
@@ -28122,7 +28126,7 @@ function declareHostSessionFailure(error) {
|
|
|
28122
28126
|
}
|
|
28123
28127
|
function recordRunStart(runDirectory) {
|
|
28124
28128
|
try {
|
|
28125
|
-
appendFileSync2(
|
|
28129
|
+
appendFileSync2(join33(runDirectory, ".run-starts"), "\n");
|
|
28126
28130
|
} catch (error) {
|
|
28127
28131
|
declareHostSessionFailure(error);
|
|
28128
28132
|
}
|
|
@@ -28138,7 +28142,7 @@ var init_host_session_record = __esm({
|
|
|
28138
28142
|
import { constants as fsConstants2 } from "node:fs";
|
|
28139
28143
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
28140
28144
|
import { lstat as lstat6, mkdir as mkdir4, open as open2 } from "node:fs/promises";
|
|
28141
|
-
import { join as
|
|
28145
|
+
import { join as join34 } from "node:path";
|
|
28142
28146
|
async function persistReturnedRunState(admitted, options) {
|
|
28143
28147
|
if (options?.lawful === true) {
|
|
28144
28148
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -28207,7 +28211,7 @@ function jsonSafeReplacer() {
|
|
|
28207
28211
|
};
|
|
28208
28212
|
}
|
|
28209
28213
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
28210
|
-
const filePath =
|
|
28214
|
+
const filePath = join34(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
28211
28215
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
28212
28216
|
`;
|
|
28213
28217
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -28462,7 +28466,7 @@ var init_auto_resume = __esm({
|
|
|
28462
28466
|
// src/public-cli/post-admission.ts
|
|
28463
28467
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
28464
28468
|
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
28465
|
-
import { isAbsolute as isAbsolute8, join as
|
|
28469
|
+
import { isAbsolute as isAbsolute8, join as join35, resolve as resolve12 } from "node:path";
|
|
28466
28470
|
function describeCaughtError(error) {
|
|
28467
28471
|
if (error instanceof Error) {
|
|
28468
28472
|
const code = error.code;
|
|
@@ -28558,7 +28562,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
28558
28562
|
try {
|
|
28559
28563
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
28560
28564
|
await writeFile7(
|
|
28561
|
-
|
|
28565
|
+
join35(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
28562
28566
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
28563
28567
|
`,
|
|
28564
28568
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -28699,7 +28703,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28699
28703
|
const rows = await readRecordedSubmissionRows(
|
|
28700
28704
|
admitted.projectRoot,
|
|
28701
28705
|
admitted.runId,
|
|
28702
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
28706
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join35(admitted.runDirectory, "session", "session.jsonl") }
|
|
28703
28707
|
);
|
|
28704
28708
|
let ticketNumber;
|
|
28705
28709
|
for (const row of rows) {
|
|
@@ -28826,7 +28830,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28826
28830
|
let stderrLogWriteFailure;
|
|
28827
28831
|
try {
|
|
28828
28832
|
await writeFile7(
|
|
28829
|
-
|
|
28833
|
+
join35(admitted.runDirectory, "stderr.log"),
|
|
28830
28834
|
result.stderr,
|
|
28831
28835
|
"utf8"
|
|
28832
28836
|
);
|
|
@@ -29105,7 +29109,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
29105
29109
|
}
|
|
29106
29110
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
29107
29111
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
29108
|
-
return pathContainedIn(
|
|
29112
|
+
return pathContainedIn(join35(runDirectory, "attachments"), absolute);
|
|
29109
29113
|
}
|
|
29110
29114
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
29111
29115
|
if (summons === void 0) return void 0;
|
|
@@ -29360,7 +29364,7 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
29360
29364
|
}
|
|
29361
29365
|
async function writeResumeDiagnosticFile(runDirectory, runId, failure, role) {
|
|
29362
29366
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
29363
|
-
const path =
|
|
29367
|
+
const path = join35(dir, `resume-diagnostic-${randomUUID6()}.json`);
|
|
29364
29368
|
await writeFile7(
|
|
29365
29369
|
path,
|
|
29366
29370
|
`${JSON.stringify({
|
|
@@ -29541,10 +29545,10 @@ var init_analyst_book_key = __esm({
|
|
|
29541
29545
|
// src/atomic-write.ts
|
|
29542
29546
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
29543
29547
|
import { rename as rename3, rm as rm3, writeFile as writeFile8 } from "node:fs/promises";
|
|
29544
|
-
import { dirname as dirname20, join as
|
|
29548
|
+
import { dirname as dirname20, join as join36 } from "node:path";
|
|
29545
29549
|
async function writeFileAtomically(destination, contents) {
|
|
29546
29550
|
const parent = dirname20(destination);
|
|
29547
|
-
const temporary =
|
|
29551
|
+
const temporary = join36(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
29548
29552
|
try {
|
|
29549
29553
|
await writeFile8(temporary, contents);
|
|
29550
29554
|
await rename3(temporary, destination);
|
|
@@ -29561,7 +29565,7 @@ var init_atomic_write = __esm({
|
|
|
29561
29565
|
|
|
29562
29566
|
// src/analyst-index.ts
|
|
29563
29567
|
import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
|
|
29564
|
-
import { dirname as dirname21, join as
|
|
29568
|
+
import { dirname as dirname21, join as join37 } from "node:path";
|
|
29565
29569
|
function sleep(ms) {
|
|
29566
29570
|
return new Promise((resolve14) => {
|
|
29567
29571
|
setTimeout(resolve14, ms);
|
|
@@ -29570,7 +29574,7 @@ function sleep(ms) {
|
|
|
29570
29574
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
29571
29575
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
29572
29576
|
ensureRealDirectoryTree(ledgerHome, dirname21(indexPath));
|
|
29573
|
-
const lockPath =
|
|
29577
|
+
const lockPath = join37(dirname21(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
29574
29578
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
29575
29579
|
const startedAt = Date.now();
|
|
29576
29580
|
while (true) {
|
|
@@ -29597,7 +29601,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
29597
29601
|
}
|
|
29598
29602
|
}
|
|
29599
29603
|
function analystLibraryIndexPath(ledgerHome) {
|
|
29600
|
-
return
|
|
29604
|
+
return join37(ledgerHome, "analyst", "library-index.json");
|
|
29601
29605
|
}
|
|
29602
29606
|
function rowFromIssueMetricsPage(page) {
|
|
29603
29607
|
return {
|
|
@@ -29893,7 +29897,7 @@ var init_analyst_cohort = __esm({
|
|
|
29893
29897
|
|
|
29894
29898
|
// src/analyst-ledger.ts
|
|
29895
29899
|
import { readdir as readdir7, readFile as readFile19 } from "node:fs/promises";
|
|
29896
|
-
import { basename as basename9, join as
|
|
29900
|
+
import { basename as basename9, join as join38 } from "node:path";
|
|
29897
29901
|
function isMissingPathError6(error) {
|
|
29898
29902
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
29899
29903
|
}
|
|
@@ -29922,7 +29926,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
29922
29926
|
}
|
|
29923
29927
|
}
|
|
29924
29928
|
async function classifyGhostCandidate(input) {
|
|
29925
|
-
const autopsy = await autopsyWriterLock(
|
|
29929
|
+
const autopsy = await autopsyWriterLock(join38(input.runDirectory, "writer.lock"));
|
|
29926
29930
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
29927
29931
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
29928
29932
|
return {
|
|
@@ -29951,7 +29955,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
29951
29955
|
async function readInvocationScopeFields(runDirectory) {
|
|
29952
29956
|
let raw;
|
|
29953
29957
|
try {
|
|
29954
|
-
raw = await readFile19(
|
|
29958
|
+
raw = await readFile19(join38(runDirectory, "invocation.json"), "utf8");
|
|
29955
29959
|
} catch (error) {
|
|
29956
29960
|
if (isMissingPathError6(error)) return void 0;
|
|
29957
29961
|
throw error;
|
|
@@ -29984,7 +29988,7 @@ function decideIssueScope(input) {
|
|
|
29984
29988
|
}
|
|
29985
29989
|
async function resolveSessionFile(runDirectory) {
|
|
29986
29990
|
try {
|
|
29987
|
-
const raw = await readFile19(
|
|
29991
|
+
const raw = await readFile19(join38(runDirectory, "invocation.json"), "utf8");
|
|
29988
29992
|
const parsed = JSON.parse(raw);
|
|
29989
29993
|
if (isRecord10(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
29990
29994
|
return parsed.sessionFile;
|
|
@@ -29992,7 +29996,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
29992
29996
|
} catch (error) {
|
|
29993
29997
|
if (!isMissingPathError6(error)) throw error;
|
|
29994
29998
|
}
|
|
29995
|
-
return
|
|
29999
|
+
return join38(runDirectory, "session", "session.jsonl");
|
|
29996
30000
|
}
|
|
29997
30001
|
function attributeSessionRowsForRun(input) {
|
|
29998
30002
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -30042,11 +30046,21 @@ function admitFrameSpanFromRows(rows) {
|
|
|
30042
30046
|
}
|
|
30043
30047
|
return {
|
|
30044
30048
|
models,
|
|
30045
|
-
frameSpan: { startedAt: span.startedAt, endedAt: span.endedAt },
|
|
30049
|
+
frameSpan: { startedAt: span.startedAt, endedAt: span.endedAt, wallMs: endedMs - startedMs },
|
|
30046
30050
|
partialFirstFrameAt: { status: "present", at: span.startedAt },
|
|
30047
30051
|
partialLastFrameAt: { status: "present", at: span.endedAt }
|
|
30048
30052
|
};
|
|
30049
30053
|
}
|
|
30054
|
+
function sumAnalystRunWallMs(runs) {
|
|
30055
|
+
let total = 0;
|
|
30056
|
+
for (const run of runs) total += run.frameSpan.wallMs;
|
|
30057
|
+
return total;
|
|
30058
|
+
}
|
|
30059
|
+
function compareAnalystLegs(a, b) {
|
|
30060
|
+
if (a.book !== b.book) return a.book.localeCompare(b.book);
|
|
30061
|
+
if (a.role !== b.role) return a.role.localeCompare(b.role);
|
|
30062
|
+
return a.runId.localeCompare(b.runId);
|
|
30063
|
+
}
|
|
30050
30064
|
async function classifyScopedRun(input) {
|
|
30051
30065
|
const missingSources = [];
|
|
30052
30066
|
const reasons = [];
|
|
@@ -30184,9 +30198,9 @@ async function classifyScopedRun(input) {
|
|
|
30184
30198
|
}
|
|
30185
30199
|
let gateCycles;
|
|
30186
30200
|
try {
|
|
30187
|
-
const parentSessionFile =
|
|
30201
|
+
const parentSessionFile = join38(input.runDirectory, "session", "session.jsonl");
|
|
30188
30202
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
30189
|
-
|
|
30203
|
+
join38(input.runDirectory, "session", "auditor-roles"),
|
|
30190
30204
|
{ parentSessionFile }
|
|
30191
30205
|
);
|
|
30192
30206
|
} catch (error) {
|
|
@@ -30221,7 +30235,7 @@ async function classifyScopedRun(input) {
|
|
|
30221
30235
|
async function scanAnalystIssueRuns(input) {
|
|
30222
30236
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
30223
30237
|
const scopeTicketNumber = input.ticketNumber;
|
|
30224
|
-
const booksRoot =
|
|
30238
|
+
const booksRoot = join38(ledgerHome, "books");
|
|
30225
30239
|
let wholeBook = false;
|
|
30226
30240
|
let scopeRootIdentity;
|
|
30227
30241
|
let bookNames;
|
|
@@ -30254,7 +30268,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
30254
30268
|
const ghostLegs = [];
|
|
30255
30269
|
const scopeConflicts = [];
|
|
30256
30270
|
for (const book of bookNames) {
|
|
30257
|
-
const bookDir =
|
|
30271
|
+
const bookDir = join38(booksRoot, book);
|
|
30258
30272
|
let runDirectories;
|
|
30259
30273
|
try {
|
|
30260
30274
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -30327,9 +30341,6 @@ var init_analyst_ledger = __esm({
|
|
|
30327
30341
|
function isRecord11(value) {
|
|
30328
30342
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30329
30343
|
}
|
|
30330
|
-
function wallMsFromSpan(span) {
|
|
30331
|
-
return Date.parse(span.endedAt) - Date.parse(span.startedAt);
|
|
30332
|
-
}
|
|
30333
30344
|
function findCollectorGroups(body) {
|
|
30334
30345
|
if (Array.isArray(body.groups)) return body.groups;
|
|
30335
30346
|
const receipt = body.receipt;
|
|
@@ -30438,7 +30449,7 @@ function projectLegs(runs) {
|
|
|
30438
30449
|
book: run.book,
|
|
30439
30450
|
role: run.role,
|
|
30440
30451
|
startedAt: run.frameSpan.startedAt,
|
|
30441
|
-
wallMs:
|
|
30452
|
+
wallMs: run.frameSpan.wallMs,
|
|
30442
30453
|
terminalLabel: mapped.terminalLabel,
|
|
30443
30454
|
accepted: mapped.accepted,
|
|
30444
30455
|
success: mapped.success,
|
|
@@ -30448,11 +30459,7 @@ function projectLegs(runs) {
|
|
|
30448
30459
|
rework: ordinal >= 2
|
|
30449
30460
|
});
|
|
30450
30461
|
}
|
|
30451
|
-
return legs.sort(
|
|
30452
|
-
if (a.book !== b.book) return a.book.localeCompare(b.book);
|
|
30453
|
-
if (a.role !== b.role) return a.role.localeCompare(b.role);
|
|
30454
|
-
return a.runId.localeCompare(b.runId);
|
|
30455
|
-
});
|
|
30462
|
+
return legs.sort(compareAnalystLegs);
|
|
30456
30463
|
}
|
|
30457
30464
|
function aggregateByRole(legs) {
|
|
30458
30465
|
const roles = [...new Set(legs.map((leg) => leg.role))].sort((a, b) => a.localeCompare(b));
|
|
@@ -30496,12 +30503,10 @@ function aggregateByRole(legs) {
|
|
|
30496
30503
|
};
|
|
30497
30504
|
});
|
|
30498
30505
|
}
|
|
30499
|
-
function reworkLens(legs) {
|
|
30506
|
+
function reworkLens(legs, totalWallMs) {
|
|
30500
30507
|
let reworkWallMs = 0;
|
|
30501
|
-
let totalWallMs = 0;
|
|
30502
30508
|
let reworkLegCount = 0;
|
|
30503
30509
|
for (const leg of legs) {
|
|
30504
|
-
totalWallMs += leg.wallMs;
|
|
30505
30510
|
if (leg.rework) {
|
|
30506
30511
|
reworkWallMs += leg.wallMs;
|
|
30507
30512
|
reworkLegCount += 1;
|
|
@@ -30522,13 +30527,14 @@ function buildAcceptanceSuccessReworkSection(runs) {
|
|
|
30522
30527
|
kind: "analyst-acceptance-success-rework",
|
|
30523
30528
|
legs,
|
|
30524
30529
|
byRole: aggregateByRole(legs),
|
|
30525
|
-
rework: reworkLens(legs)
|
|
30530
|
+
rework: reworkLens(legs, sumAnalystRunWallMs(runs))
|
|
30526
30531
|
};
|
|
30527
30532
|
}
|
|
30528
30533
|
var WORKER_ROLES, ACCEPTED_STATUS, SUCCESS_STATUS, acceptanceSuccessReworkFamily, acceptance_success_rework_default;
|
|
30529
30534
|
var init_acceptance_success_rework = __esm({
|
|
30530
30535
|
"src/analyst-metric-families/acceptance-success-rework.ts"() {
|
|
30531
30536
|
"use strict";
|
|
30537
|
+
init_analyst_ledger();
|
|
30532
30538
|
init_analyst_median();
|
|
30533
30539
|
init_packaged_role_registry();
|
|
30534
30540
|
WORKER_ROLES = /* @__PURE__ */ new Set(["coder", "fixer"]);
|
|
@@ -30561,117 +30567,6 @@ var init_acceptance_success_rework = __esm({
|
|
|
30561
30567
|
}
|
|
30562
30568
|
});
|
|
30563
30569
|
|
|
30564
|
-
// src/analyst-model-groups.ts
|
|
30565
|
-
function analystModelGroupKey(models) {
|
|
30566
|
-
if (models.length === 0) return void 0;
|
|
30567
|
-
if (models.length === 1) return models[0];
|
|
30568
|
-
return `mixed:${models.join("+")}`;
|
|
30569
|
-
}
|
|
30570
|
-
function rate(numerator, denominator) {
|
|
30571
|
-
if (denominator === 0) return void 0;
|
|
30572
|
-
return numerator / denominator;
|
|
30573
|
-
}
|
|
30574
|
-
function displayNameFor(rawGroupKey, combinationMapping) {
|
|
30575
|
-
if (combinationMapping === void 0) return rawGroupKey;
|
|
30576
|
-
const aliased = combinationMapping[rawGroupKey];
|
|
30577
|
-
return aliased === void 0 ? rawGroupKey : aliased;
|
|
30578
|
-
}
|
|
30579
|
-
function sortUnreadable(unreadable) {
|
|
30580
|
-
return [...unreadable].sort((a, b) => {
|
|
30581
|
-
if (a.book !== b.book) return a.book.localeCompare(b.book);
|
|
30582
|
-
return a.runId.localeCompare(b.runId);
|
|
30583
|
-
});
|
|
30584
|
-
}
|
|
30585
|
-
function modelIdentityAbsentEntry(run) {
|
|
30586
|
-
return {
|
|
30587
|
-
runId: run.runId,
|
|
30588
|
-
book: run.book,
|
|
30589
|
-
missingSources: ["session-model"],
|
|
30590
|
-
reason: "session has no usable model identity",
|
|
30591
|
-
firstFrameAt: { status: "present", at: run.frameSpan.startedAt },
|
|
30592
|
-
// Readable legs already admitted a full span — retain end edge for lastActivityAt.
|
|
30593
|
-
lastFrameAt: { status: "present", at: run.frameSpan.endedAt }
|
|
30594
|
-
};
|
|
30595
|
-
}
|
|
30596
|
-
function buildAnalystModelGroupsPage(input) {
|
|
30597
|
-
const groupedRuns = [];
|
|
30598
|
-
const modelAbsent = [];
|
|
30599
|
-
for (const run of input.runs) {
|
|
30600
|
-
const rawGroupKey = analystModelGroupKey(run.models);
|
|
30601
|
-
if (rawGroupKey === void 0) {
|
|
30602
|
-
modelAbsent.push(modelIdentityAbsentEntry(run));
|
|
30603
|
-
} else {
|
|
30604
|
-
groupedRuns.push({ run, rawGroupKey });
|
|
30605
|
-
}
|
|
30606
|
-
}
|
|
30607
|
-
const acceptance = buildAcceptanceSuccessReworkSection(
|
|
30608
|
-
groupedRuns.map(({ run }) => run)
|
|
30609
|
-
);
|
|
30610
|
-
const legByRunId = new Map(
|
|
30611
|
-
(acceptance?.legs ?? []).map((leg) => [leg.runId, leg])
|
|
30612
|
-
);
|
|
30613
|
-
const byRaw = /* @__PURE__ */ new Map();
|
|
30614
|
-
for (const { run, rawGroupKey } of groupedRuns) {
|
|
30615
|
-
const leg = legByRunId.get(run.runId);
|
|
30616
|
-
if (leg === void 0) {
|
|
30617
|
-
throw new Error(
|
|
30618
|
-
`analyst model-groups: missing acceptance projection for run ${run.runId}`
|
|
30619
|
-
);
|
|
30620
|
-
}
|
|
30621
|
-
let acc = byRaw.get(rawGroupKey);
|
|
30622
|
-
if (acc === void 0) {
|
|
30623
|
-
acc = {
|
|
30624
|
-
acceptedCount: 0,
|
|
30625
|
-
successCount: 0,
|
|
30626
|
-
successEligibleCount: 0,
|
|
30627
|
-
noReceiptCount: 0,
|
|
30628
|
-
walls: []
|
|
30629
|
-
};
|
|
30630
|
-
byRaw.set(rawGroupKey, acc);
|
|
30631
|
-
}
|
|
30632
|
-
if (leg.accepted) acc.acceptedCount += 1;
|
|
30633
|
-
if (leg.success) acc.successCount += 1;
|
|
30634
|
-
if (leg.successEligible) acc.successEligibleCount += 1;
|
|
30635
|
-
if (leg.noReceipt) acc.noReceiptCount += 1;
|
|
30636
|
-
acc.walls.push(leg.wallMs);
|
|
30637
|
-
}
|
|
30638
|
-
const rawKeys = [...byRaw.keys()].sort((a, b) => a.localeCompare(b));
|
|
30639
|
-
const groups = rawKeys.map((rawGroupKey) => {
|
|
30640
|
-
const acc = byRaw.get(rawGroupKey);
|
|
30641
|
-
const legCount = acc.walls.length;
|
|
30642
|
-
return {
|
|
30643
|
-
rawGroupKey,
|
|
30644
|
-
displayName: displayNameFor(rawGroupKey, input.combinationMapping),
|
|
30645
|
-
legCount,
|
|
30646
|
-
acceptedCount: acc.acceptedCount,
|
|
30647
|
-
acceptanceRate: rate(acc.acceptedCount, legCount),
|
|
30648
|
-
successCount: acc.successCount,
|
|
30649
|
-
successEligibleCount: acc.successEligibleCount,
|
|
30650
|
-
successRate: rate(acc.successCount, acc.successEligibleCount),
|
|
30651
|
-
noReceiptCount: acc.noReceiptCount,
|
|
30652
|
-
noReceiptRate: rate(acc.noReceiptCount, legCount),
|
|
30653
|
-
wallClockMedianMs: medianNumber(acc.walls)
|
|
30654
|
-
};
|
|
30655
|
-
});
|
|
30656
|
-
const unreadable = sortUnreadable([...input.unreadable, ...modelAbsent]);
|
|
30657
|
-
return {
|
|
30658
|
-
kind: "analyst-model-groups",
|
|
30659
|
-
mode: "model-groups",
|
|
30660
|
-
projectRoots: [...input.projectRoots].sort((a, b) => a.localeCompare(b)),
|
|
30661
|
-
groups,
|
|
30662
|
-
legCount: groupedRuns.length,
|
|
30663
|
-
unreadableCount: unreadable.length,
|
|
30664
|
-
unreadable
|
|
30665
|
-
};
|
|
30666
|
-
}
|
|
30667
|
-
var init_analyst_model_groups = __esm({
|
|
30668
|
-
"src/analyst-model-groups.ts"() {
|
|
30669
|
-
"use strict";
|
|
30670
|
-
init_acceptance_success_rework();
|
|
30671
|
-
init_analyst_median();
|
|
30672
|
-
}
|
|
30673
|
-
});
|
|
30674
|
-
|
|
30675
30570
|
// src/analyst-metric-families/b2-frame-buckets-actions.ts
|
|
30676
30571
|
function timestampMs(iso) {
|
|
30677
30572
|
const ms = Date.parse(iso);
|
|
@@ -30794,7 +30689,7 @@ function sortActionsDescending(actions) {
|
|
|
30794
30689
|
function computeAnalystB2RunMetrics(facts) {
|
|
30795
30690
|
const frameStartMs = timestampMs(facts.frameSpan.startedAt);
|
|
30796
30691
|
const frameEndMs = timestampMs(facts.frameSpan.endedAt);
|
|
30797
|
-
const wallMs =
|
|
30692
|
+
const wallMs = facts.frameSpan.wallMs;
|
|
30798
30693
|
const tools = clipToolsToFrame(closedTools(facts.toolIntervals), frameStartMs, frameEndMs);
|
|
30799
30694
|
const toolUnion = mergeUnion(tools);
|
|
30800
30695
|
const toolBucketMs = toolUnion.reduce(
|
|
@@ -30824,15 +30719,12 @@ var init_b2_frame_buckets_actions = __esm({
|
|
|
30824
30719
|
"src/analyst-metric-families/b2-frame-buckets-actions.ts"() {
|
|
30825
30720
|
"use strict";
|
|
30826
30721
|
init_analyst_median();
|
|
30722
|
+
init_analyst_ledger();
|
|
30827
30723
|
b2FrameBucketsActionsFamily = {
|
|
30828
30724
|
id: "b2-frame-buckets-actions",
|
|
30829
30725
|
contribute(input) {
|
|
30830
30726
|
if (input.runs.length === 0) return void 0;
|
|
30831
|
-
const runs = [...input.runs].map(computeAnalystB2RunMetrics).sort(
|
|
30832
|
-
if (a.book !== b.book) return a.book.localeCompare(b.book);
|
|
30833
|
-
if (a.role !== b.role) return a.role.localeCompare(b.role);
|
|
30834
|
-
return a.runId.localeCompare(b.runId);
|
|
30835
|
-
});
|
|
30727
|
+
const runs = [...input.runs].map(computeAnalystB2RunMetrics).sort(compareAnalystLegs);
|
|
30836
30728
|
const section = {
|
|
30837
30729
|
kind: "analyst-b2-frame-buckets-actions",
|
|
30838
30730
|
runs
|
|
@@ -30865,11 +30757,6 @@ function projectLeg(facts) {
|
|
|
30865
30757
|
rounds
|
|
30866
30758
|
};
|
|
30867
30759
|
}
|
|
30868
|
-
function compareLegs(a, b) {
|
|
30869
|
-
if (a.book !== b.book) return a.book.localeCompare(b.book);
|
|
30870
|
-
if (a.role !== b.role) return a.role.localeCompare(b.role);
|
|
30871
|
-
return a.runId.localeCompare(b.runId);
|
|
30872
|
-
}
|
|
30873
30760
|
function emptyAccum() {
|
|
30874
30761
|
return { rounds: 0, bounceCount: 0, passCount: 0, wallSum: 0 };
|
|
30875
30762
|
}
|
|
@@ -30905,11 +30792,12 @@ var gateCyclesFamily, gate_cycles_default;
|
|
|
30905
30792
|
var init_gate_cycles = __esm({
|
|
30906
30793
|
"src/analyst-metric-families/gate-cycles.ts"() {
|
|
30907
30794
|
"use strict";
|
|
30795
|
+
init_analyst_ledger();
|
|
30908
30796
|
gateCyclesFamily = {
|
|
30909
30797
|
id: "gate-cycles",
|
|
30910
30798
|
contribute(input) {
|
|
30911
30799
|
if (input.runs.length === 0) return void 0;
|
|
30912
|
-
const legs = input.runs.map(projectLeg).sort(
|
|
30800
|
+
const legs = input.runs.map(projectLeg).sort(compareAnalystLegs);
|
|
30913
30801
|
const section = {
|
|
30914
30802
|
kind: "analyst-gate-cycles",
|
|
30915
30803
|
legs,
|
|
@@ -30923,28 +30811,24 @@ var init_gate_cycles = __esm({
|
|
|
30923
30811
|
});
|
|
30924
30812
|
|
|
30925
30813
|
// src/analyst-metric-families/leg-wall-clock.ts
|
|
30926
|
-
function frameSpanWallMs(span) {
|
|
30927
|
-
return Date.parse(span.endedAt) - Date.parse(span.startedAt);
|
|
30928
|
-
}
|
|
30929
30814
|
function projectEntry(facts) {
|
|
30930
30815
|
return {
|
|
30931
30816
|
runId: facts.runId,
|
|
30932
30817
|
book: facts.book,
|
|
30933
30818
|
role: facts.role,
|
|
30934
|
-
wallMs:
|
|
30819
|
+
wallMs: facts.frameSpan.wallMs
|
|
30935
30820
|
};
|
|
30936
30821
|
}
|
|
30937
30822
|
function compareRankingDesc(a, b) {
|
|
30938
30823
|
if (b.wallMs !== a.wallMs) return b.wallMs - a.wallMs;
|
|
30939
|
-
|
|
30940
|
-
if (a.role !== b.role) return a.role.localeCompare(b.role);
|
|
30941
|
-
return a.runId.localeCompare(b.runId);
|
|
30824
|
+
return compareAnalystLegs(a, b);
|
|
30942
30825
|
}
|
|
30943
30826
|
var legWallClockFamily, leg_wall_clock_default;
|
|
30944
30827
|
var init_leg_wall_clock = __esm({
|
|
30945
30828
|
"src/analyst-metric-families/leg-wall-clock.ts"() {
|
|
30946
30829
|
"use strict";
|
|
30947
30830
|
init_analyst_median();
|
|
30831
|
+
init_analyst_ledger();
|
|
30948
30832
|
legWallClockFamily = {
|
|
30949
30833
|
id: "leg-wall-clock",
|
|
30950
30834
|
contribute(input) {
|
|
@@ -30957,13 +30841,11 @@ var init_leg_wall_clock = __esm({
|
|
|
30957
30841
|
if (medianWallMs === void 0) {
|
|
30958
30842
|
return void 0;
|
|
30959
30843
|
}
|
|
30960
|
-
let totalElapsedMs = 0;
|
|
30961
|
-
for (const wallMs of walls) totalElapsedMs += wallMs;
|
|
30962
30844
|
const section = {
|
|
30963
30845
|
kind: "analyst-leg-wall-clock",
|
|
30964
30846
|
ranking,
|
|
30965
30847
|
medianWallMs,
|
|
30966
|
-
totalElapsedMs
|
|
30848
|
+
totalElapsedMs: sumAnalystRunWallMs(input.runs)
|
|
30967
30849
|
};
|
|
30968
30850
|
return { legWallClock: section };
|
|
30969
30851
|
}
|
|
@@ -30976,9 +30858,6 @@ var init_leg_wall_clock = __esm({
|
|
|
30976
30858
|
function isRecord12(value) {
|
|
30977
30859
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30978
30860
|
}
|
|
30979
|
-
function wallMsFromSpan2(startedAt, endedAt) {
|
|
30980
|
-
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
30981
|
-
}
|
|
30982
30861
|
function readClassCount(body) {
|
|
30983
30862
|
if (!isRecord12(body.outcome)) return void 0;
|
|
30984
30863
|
if (!isRecord12(body.outcome.decisiveFacts)) return void 0;
|
|
@@ -31015,7 +30894,7 @@ function projectRunRow(facts) {
|
|
|
31015
30894
|
role: facts.role,
|
|
31016
30895
|
startedAt,
|
|
31017
30896
|
endedAt,
|
|
31018
|
-
wallMs:
|
|
30897
|
+
wallMs: facts.frameSpan.wallMs,
|
|
31019
30898
|
terminal: projectTerminal(facts)
|
|
31020
30899
|
};
|
|
31021
30900
|
}
|
|
@@ -31126,7 +31005,7 @@ var init_analyst_metric_family = __esm({
|
|
|
31126
31005
|
|
|
31127
31006
|
// src/analyst-page.ts
|
|
31128
31007
|
import { createHash as createHash3 } from "node:crypto";
|
|
31129
|
-
import { dirname as dirname22, join as
|
|
31008
|
+
import { dirname as dirname22, join as join39 } from "node:path";
|
|
31130
31009
|
function analystIssuePageKey(address) {
|
|
31131
31010
|
const parts = ["book", address.bookKey];
|
|
31132
31011
|
if (address.issueNumber !== void 0) {
|
|
@@ -31137,7 +31016,7 @@ function analystIssuePageKey(address) {
|
|
|
31137
31016
|
return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
31138
31017
|
}
|
|
31139
31018
|
function analystIssuePagePath(ledgerHome, address) {
|
|
31140
|
-
return
|
|
31019
|
+
return join39(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
31141
31020
|
}
|
|
31142
31021
|
function analystIssuePageAddressFromPage(page) {
|
|
31143
31022
|
return {
|
|
@@ -31147,13 +31026,9 @@ function analystIssuePageAddressFromPage(page) {
|
|
|
31147
31026
|
};
|
|
31148
31027
|
}
|
|
31149
31028
|
function sortLegs(legs) {
|
|
31150
|
-
return [...legs].sort(
|
|
31151
|
-
if (a.book !== b.book) return a.book.localeCompare(b.book);
|
|
31152
|
-
if (a.role !== b.role) return a.role.localeCompare(b.role);
|
|
31153
|
-
return a.runId.localeCompare(b.runId);
|
|
31154
|
-
});
|
|
31029
|
+
return [...legs].sort(compareAnalystLegs);
|
|
31155
31030
|
}
|
|
31156
|
-
function
|
|
31031
|
+
function sortUnreadable(unreadable) {
|
|
31157
31032
|
return [...unreadable].sort((a, b) => {
|
|
31158
31033
|
if (a.book !== b.book) return a.book.localeCompare(b.book);
|
|
31159
31034
|
return a.runId.localeCompare(b.runId);
|
|
@@ -31189,14 +31064,10 @@ function computeAnalystMsPerKLines(totalElapsedMs, changedLines) {
|
|
|
31189
31064
|
value: totalElapsedMs / (changedLines.value / 1e3)
|
|
31190
31065
|
};
|
|
31191
31066
|
}
|
|
31192
|
-
function frameSpanWallMs2(span) {
|
|
31193
|
-
return Date.parse(span.endedAt) - Date.parse(span.startedAt);
|
|
31194
|
-
}
|
|
31195
31067
|
function summarizeAnalystRunEfficiency(runs, unreadable = []) {
|
|
31196
|
-
|
|
31068
|
+
const totalElapsedMs = sumAnalystRunWallMs(runs);
|
|
31197
31069
|
let latestEndedAt;
|
|
31198
31070
|
for (const run of runs) {
|
|
31199
|
-
totalElapsedMs += frameSpanWallMs2(run.frameSpan);
|
|
31200
31071
|
const endedAt = run.frameSpan.endedAt;
|
|
31201
31072
|
if (latestEndedAt === void 0 || endedAt > latestEndedAt) {
|
|
31202
31073
|
latestEndedAt = endedAt;
|
|
@@ -31221,7 +31092,7 @@ async function buildAnalystIssueMetricsPage(input) {
|
|
|
31221
31092
|
role: run.role
|
|
31222
31093
|
}))
|
|
31223
31094
|
);
|
|
31224
|
-
const unreadable =
|
|
31095
|
+
const unreadable = sortUnreadable(input.unreadable);
|
|
31225
31096
|
const scopeConflicts = sortScopeConflicts(input.scopeConflicts ?? []);
|
|
31226
31097
|
const projectRoot = physicalPathIdentity(input.projectRoot);
|
|
31227
31098
|
const { totalElapsedMs, lastActivityAt } = summarizeAnalystRunEfficiency(
|
|
@@ -31267,11 +31138,118 @@ var init_analyst_page = __esm({
|
|
|
31267
31138
|
"use strict";
|
|
31268
31139
|
init_atomic_write();
|
|
31269
31140
|
init_activation_ledger_topology();
|
|
31141
|
+
init_analyst_ledger();
|
|
31270
31142
|
init_analyst_metric_families();
|
|
31271
31143
|
init_analyst_metric_family();
|
|
31272
31144
|
}
|
|
31273
31145
|
});
|
|
31274
31146
|
|
|
31147
|
+
// src/analyst-model-groups.ts
|
|
31148
|
+
function analystModelGroupKey(models) {
|
|
31149
|
+
if (models.length === 0) return void 0;
|
|
31150
|
+
if (models.length === 1) return models[0];
|
|
31151
|
+
return `mixed:${models.join("+")}`;
|
|
31152
|
+
}
|
|
31153
|
+
function rate(numerator, denominator) {
|
|
31154
|
+
if (denominator === 0) return void 0;
|
|
31155
|
+
return numerator / denominator;
|
|
31156
|
+
}
|
|
31157
|
+
function displayNameFor(rawGroupKey, combinationMapping) {
|
|
31158
|
+
if (combinationMapping === void 0) return rawGroupKey;
|
|
31159
|
+
const aliased = combinationMapping[rawGroupKey];
|
|
31160
|
+
return aliased === void 0 ? rawGroupKey : aliased;
|
|
31161
|
+
}
|
|
31162
|
+
function modelIdentityAbsentEntry(run) {
|
|
31163
|
+
return {
|
|
31164
|
+
runId: run.runId,
|
|
31165
|
+
book: run.book,
|
|
31166
|
+
missingSources: ["session-model"],
|
|
31167
|
+
reason: "session has no usable model identity",
|
|
31168
|
+
firstFrameAt: { status: "present", at: run.frameSpan.startedAt },
|
|
31169
|
+
// Readable legs already admitted a full span — retain end edge for lastActivityAt.
|
|
31170
|
+
lastFrameAt: { status: "present", at: run.frameSpan.endedAt }
|
|
31171
|
+
};
|
|
31172
|
+
}
|
|
31173
|
+
function buildAnalystModelGroupsPage(input) {
|
|
31174
|
+
const groupedRuns = [];
|
|
31175
|
+
const modelAbsent = [];
|
|
31176
|
+
for (const run of input.runs) {
|
|
31177
|
+
const rawGroupKey = analystModelGroupKey(run.models);
|
|
31178
|
+
if (rawGroupKey === void 0) {
|
|
31179
|
+
modelAbsent.push(modelIdentityAbsentEntry(run));
|
|
31180
|
+
} else {
|
|
31181
|
+
groupedRuns.push({ run, rawGroupKey });
|
|
31182
|
+
}
|
|
31183
|
+
}
|
|
31184
|
+
const acceptance = buildAcceptanceSuccessReworkSection(
|
|
31185
|
+
groupedRuns.map(({ run }) => run)
|
|
31186
|
+
);
|
|
31187
|
+
const legByRunId = new Map(
|
|
31188
|
+
(acceptance?.legs ?? []).map((leg) => [leg.runId, leg])
|
|
31189
|
+
);
|
|
31190
|
+
const byRaw = /* @__PURE__ */ new Map();
|
|
31191
|
+
for (const { run, rawGroupKey } of groupedRuns) {
|
|
31192
|
+
const leg = legByRunId.get(run.runId);
|
|
31193
|
+
if (leg === void 0) {
|
|
31194
|
+
throw new Error(
|
|
31195
|
+
`analyst model-groups: missing acceptance projection for run ${run.runId}`
|
|
31196
|
+
);
|
|
31197
|
+
}
|
|
31198
|
+
let acc = byRaw.get(rawGroupKey);
|
|
31199
|
+
if (acc === void 0) {
|
|
31200
|
+
acc = {
|
|
31201
|
+
acceptedCount: 0,
|
|
31202
|
+
successCount: 0,
|
|
31203
|
+
successEligibleCount: 0,
|
|
31204
|
+
noReceiptCount: 0,
|
|
31205
|
+
walls: []
|
|
31206
|
+
};
|
|
31207
|
+
byRaw.set(rawGroupKey, acc);
|
|
31208
|
+
}
|
|
31209
|
+
if (leg.accepted) acc.acceptedCount += 1;
|
|
31210
|
+
if (leg.success) acc.successCount += 1;
|
|
31211
|
+
if (leg.successEligible) acc.successEligibleCount += 1;
|
|
31212
|
+
if (leg.noReceipt) acc.noReceiptCount += 1;
|
|
31213
|
+
acc.walls.push(leg.wallMs);
|
|
31214
|
+
}
|
|
31215
|
+
const rawKeys = [...byRaw.keys()].sort((a, b) => a.localeCompare(b));
|
|
31216
|
+
const groups = rawKeys.map((rawGroupKey) => {
|
|
31217
|
+
const acc = byRaw.get(rawGroupKey);
|
|
31218
|
+
const legCount = acc.walls.length;
|
|
31219
|
+
return {
|
|
31220
|
+
rawGroupKey,
|
|
31221
|
+
displayName: displayNameFor(rawGroupKey, input.combinationMapping),
|
|
31222
|
+
legCount,
|
|
31223
|
+
acceptedCount: acc.acceptedCount,
|
|
31224
|
+
acceptanceRate: rate(acc.acceptedCount, legCount),
|
|
31225
|
+
successCount: acc.successCount,
|
|
31226
|
+
successEligibleCount: acc.successEligibleCount,
|
|
31227
|
+
successRate: rate(acc.successCount, acc.successEligibleCount),
|
|
31228
|
+
noReceiptCount: acc.noReceiptCount,
|
|
31229
|
+
noReceiptRate: rate(acc.noReceiptCount, legCount),
|
|
31230
|
+
wallClockMedianMs: medianNumber(acc.walls)
|
|
31231
|
+
};
|
|
31232
|
+
});
|
|
31233
|
+
const unreadable = sortUnreadable([...input.unreadable, ...modelAbsent]);
|
|
31234
|
+
return {
|
|
31235
|
+
kind: "analyst-model-groups",
|
|
31236
|
+
mode: "model-groups",
|
|
31237
|
+
projectRoots: [...input.projectRoots].sort((a, b) => a.localeCompare(b)),
|
|
31238
|
+
groups,
|
|
31239
|
+
legCount: groupedRuns.length,
|
|
31240
|
+
unreadableCount: unreadable.length,
|
|
31241
|
+
unreadable
|
|
31242
|
+
};
|
|
31243
|
+
}
|
|
31244
|
+
var init_analyst_model_groups = __esm({
|
|
31245
|
+
"src/analyst-model-groups.ts"() {
|
|
31246
|
+
"use strict";
|
|
31247
|
+
init_acceptance_success_rework();
|
|
31248
|
+
init_analyst_median();
|
|
31249
|
+
init_analyst_page();
|
|
31250
|
+
}
|
|
31251
|
+
});
|
|
31252
|
+
|
|
31275
31253
|
// src/analyst-entry.ts
|
|
31276
31254
|
import { readFile as readFile20 } from "node:fs/promises";
|
|
31277
31255
|
function isMissingPathError7(error) {
|
|
@@ -31677,7 +31655,7 @@ __export(cli_exports, {
|
|
|
31677
31655
|
runAkRole: () => runAkRole
|
|
31678
31656
|
});
|
|
31679
31657
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
31680
|
-
import { join as
|
|
31658
|
+
import { join as join40 } from "node:path";
|
|
31681
31659
|
function publicSeatArgv(owner) {
|
|
31682
31660
|
return {
|
|
31683
31661
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -31816,7 +31794,7 @@ function resolveHome(env) {
|
|
|
31816
31794
|
return env.home ?? packageMachineHome();
|
|
31817
31795
|
}
|
|
31818
31796
|
function resolveAgentDir(env, home) {
|
|
31819
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
31797
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join40(home, ".pi", "agent");
|
|
31820
31798
|
}
|
|
31821
31799
|
function parseThinking(value) {
|
|
31822
31800
|
return value;
|
|
@@ -32578,7 +32556,7 @@ var init_cli = __esm({
|
|
|
32578
32556
|
|
|
32579
32557
|
// src/public-cli/main.ts
|
|
32580
32558
|
import { existsSync as existsSync11 } from "node:fs";
|
|
32581
|
-
import { dirname as dirname23, join as
|
|
32559
|
+
import { dirname as dirname23, join as join41 } from "node:path";
|
|
32582
32560
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32583
32561
|
|
|
32584
32562
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -32667,8 +32645,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
32667
32645
|
// src/public-cli/main.ts
|
|
32668
32646
|
var here = dirname23(fileURLToPath2(import.meta.url));
|
|
32669
32647
|
function resolvePackageRoot(binDir) {
|
|
32670
|
-
const canonical =
|
|
32671
|
-
if (existsSync11(
|
|
32648
|
+
const canonical = join41(binDir, "..", "..");
|
|
32649
|
+
if (existsSync11(join41(canonical, "package.json"))) {
|
|
32672
32650
|
return canonical;
|
|
32673
32651
|
}
|
|
32674
32652
|
return binDir;
|