@akagilnc/pi-workflow-roles 0.1.5216 → 0.1.5235
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/acp-host/production-host.js +556 -617
- package/dist/engine-detour-usage.js +4 -16
- package/dist/headless-host/production-host.js +673 -648
- package/dist/host-session-record.js +303 -0
- package/dist/pi/role-turn-host.js +1 -21
- package/dist/public-cli/main.js +153 -361
- package/dist/public-cli/post-admission.js +7 -43
- package/dist/sitian-appender.js +10 -146
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +36 -108
- package/src/engine-detour-usage.ts +4 -16
- package/src/external-host-turn-loop.ts +2 -18
- package/src/headless-host/role-turn-host.ts +67 -31
- package/src/host-contracts.ts +0 -15
- package/src/host-session-record.ts +325 -25
- package/src/pi/role-turn-host.ts +1 -25
- package/src/public-cli/post-admission.ts +6 -51
- package/src/public-role-summons.ts +1 -2
- package/src/sitian-appender.ts +16 -191
- package/dist/host-transition-prior-native.js +0 -78
- package/src/host-transition-prior-native.ts +0 -80
- package/src/pi/pi-normalization.ts +0 -291
package/dist/public-cli/main.js
CHANGED
|
@@ -17879,57 +17879,15 @@ var init_sitian_contracts = __esm({
|
|
|
17879
17879
|
});
|
|
17880
17880
|
|
|
17881
17881
|
// src/sitian-appender.ts
|
|
17882
|
-
import {
|
|
17883
|
-
import {
|
|
17884
|
-
appendFileSync,
|
|
17885
|
-
existsSync as existsSync3,
|
|
17886
|
-
readFileSync as readFileSync2,
|
|
17887
|
-
unlinkSync,
|
|
17888
|
-
writeFileSync
|
|
17889
|
-
} from "node:fs";
|
|
17882
|
+
import { randomUUID } from "node:crypto";
|
|
17883
|
+
import { appendFileSync } from "node:fs";
|
|
17890
17884
|
import { dirname as dirname7, join as join14 } from "node:path";
|
|
17891
|
-
function isRecord3(value) {
|
|
17892
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17893
|
-
}
|
|
17894
|
-
function errorCodeOf(error) {
|
|
17895
|
-
return error.code;
|
|
17896
|
-
}
|
|
17897
|
-
function identityClaimPath(recordFile, identity) {
|
|
17898
|
-
const digest = createHash2("sha256").update(identity, "utf8").digest("hex");
|
|
17899
|
-
return `${recordFile}.id-${digest}`;
|
|
17900
|
-
}
|
|
17901
|
-
function createExclusiveFile(path, contents) {
|
|
17902
|
-
writeFileSync(path, contents, { encoding: "utf8", flag: "wx" });
|
|
17903
|
-
}
|
|
17904
|
-
function sealTornTail(recordFile) {
|
|
17905
|
-
if (!existsSync3(recordFile)) return;
|
|
17906
|
-
const buffer = readFileSync2(recordFile);
|
|
17907
|
-
if (buffer.length > 0 && buffer[buffer.length - 1] !== 10) {
|
|
17908
|
-
appendFileSync(recordFile, "\n", "utf8");
|
|
17909
|
-
}
|
|
17910
|
-
}
|
|
17911
17885
|
function appendSitianRecordBlock(input, block) {
|
|
17912
17886
|
if (block === "") return;
|
|
17913
17887
|
try {
|
|
17914
17888
|
const { sessionDir, recordFile, ledgerHome } = resolveSitianRecordPath(input);
|
|
17915
17889
|
ensureRealDirectoryTree(ledgerHome, sessionDir);
|
|
17916
|
-
appendFileSync(recordFile,
|
|
17917
|
-
sealTornTail(recordFile);
|
|
17918
|
-
const identityOf = (line2) => {
|
|
17919
|
-
try {
|
|
17920
|
-
const row = JSON.parse(line2);
|
|
17921
|
-
return isRecord3(row) && typeof row.identity === "string" ? row.identity : void 0;
|
|
17922
|
-
} catch {
|
|
17923
|
-
return void 0;
|
|
17924
|
-
}
|
|
17925
|
-
};
|
|
17926
|
-
const identities = new Set(readFileSync2(recordFile, "utf8").split("\n").map(identityOf).filter((id) => id !== void 0));
|
|
17927
|
-
for (const line2 of block.match(/[^\n]*\n|[^\n]+$/g) ?? []) {
|
|
17928
|
-
const identity = identityOf(line2);
|
|
17929
|
-
if (identity !== void 0 && identities.has(identity)) continue;
|
|
17930
|
-
appendFileSync(recordFile, line2, "utf8");
|
|
17931
|
-
if (identity !== void 0) identities.add(identity);
|
|
17932
|
-
}
|
|
17890
|
+
appendFileSync(recordFile, block, "utf8");
|
|
17933
17891
|
} catch (error) {
|
|
17934
17892
|
if (error instanceof SitianInfrastructureError) throw error;
|
|
17935
17893
|
throw new SitianInfrastructureError(
|
|
@@ -17938,106 +17896,6 @@ function appendSitianRecordBlock(input, block) {
|
|
|
17938
17896
|
);
|
|
17939
17897
|
}
|
|
17940
17898
|
}
|
|
17941
|
-
function findIdentityPointer(recordFile, identity, kind, level) {
|
|
17942
|
-
if (!existsSync3(recordFile)) return void 0;
|
|
17943
|
-
const text = readFileSync2(recordFile, "utf8");
|
|
17944
|
-
for (const line2 of text.split("\n")) {
|
|
17945
|
-
const trimmed = line2.trim();
|
|
17946
|
-
if (!trimmed) continue;
|
|
17947
|
-
try {
|
|
17948
|
-
const parsed = JSON.parse(trimmed);
|
|
17949
|
-
if (isRecord3(parsed) && parsed.identity === identity) {
|
|
17950
|
-
return { identity, recordFile, kind, level };
|
|
17951
|
-
}
|
|
17952
|
-
} catch {
|
|
17953
|
-
}
|
|
17954
|
-
}
|
|
17955
|
-
return void 0;
|
|
17956
|
-
}
|
|
17957
|
-
function unlinkAbsentOk(path) {
|
|
17958
|
-
try {
|
|
17959
|
-
unlinkSync(path);
|
|
17960
|
-
return void 0;
|
|
17961
|
-
} catch (error) {
|
|
17962
|
-
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
17963
|
-
return error instanceof Error ? error : new Error(errorText(error));
|
|
17964
|
-
}
|
|
17965
|
-
}
|
|
17966
|
-
function appendWithIdentityClaim(recordFile, record4, row) {
|
|
17967
|
-
sealTornTail(recordFile);
|
|
17968
|
-
const claimPath = identityClaimPath(recordFile, record4.identity);
|
|
17969
|
-
const existing = findIdentityPointer(
|
|
17970
|
-
recordFile,
|
|
17971
|
-
record4.identity,
|
|
17972
|
-
record4.kind,
|
|
17973
|
-
record4.level
|
|
17974
|
-
);
|
|
17975
|
-
if (existing !== void 0) {
|
|
17976
|
-
unlinkAbsentOk(claimPath);
|
|
17977
|
-
return existing;
|
|
17978
|
-
}
|
|
17979
|
-
try {
|
|
17980
|
-
createExclusiveFile(claimPath, "");
|
|
17981
|
-
} catch (error) {
|
|
17982
|
-
if (errorCodeOf(error) !== "EEXIST") throw error;
|
|
17983
|
-
sealTornTail(recordFile);
|
|
17984
|
-
const published = findIdentityPointer(
|
|
17985
|
-
recordFile,
|
|
17986
|
-
record4.identity,
|
|
17987
|
-
record4.kind,
|
|
17988
|
-
record4.level
|
|
17989
|
-
);
|
|
17990
|
-
if (published !== void 0) {
|
|
17991
|
-
unlinkAbsentOk(claimPath);
|
|
17992
|
-
return published;
|
|
17993
|
-
}
|
|
17994
|
-
throw new SitianInfrastructureError(
|
|
17995
|
-
`Sitian identity claim at ${claimPath} already exists for identity ${record4.identity}`,
|
|
17996
|
-
{ cause: error }
|
|
17997
|
-
);
|
|
17998
|
-
}
|
|
17999
|
-
let primaryFailure;
|
|
18000
|
-
let result;
|
|
18001
|
-
let cleanupFailure;
|
|
18002
|
-
try {
|
|
18003
|
-
sealTornTail(recordFile);
|
|
18004
|
-
const raced = findIdentityPointer(
|
|
18005
|
-
recordFile,
|
|
18006
|
-
record4.identity,
|
|
18007
|
-
record4.kind,
|
|
18008
|
-
record4.level
|
|
18009
|
-
);
|
|
18010
|
-
if (raced !== void 0) {
|
|
18011
|
-
result = raced;
|
|
18012
|
-
} else {
|
|
18013
|
-
appendFileSync(recordFile, row, "utf8");
|
|
18014
|
-
result = {
|
|
18015
|
-
identity: record4.identity,
|
|
18016
|
-
recordFile,
|
|
18017
|
-
kind: record4.kind,
|
|
18018
|
-
level: record4.level
|
|
18019
|
-
};
|
|
18020
|
-
}
|
|
18021
|
-
} catch (error) {
|
|
18022
|
-
primaryFailure = error;
|
|
18023
|
-
} finally {
|
|
18024
|
-
cleanupFailure = unlinkAbsentOk(claimPath);
|
|
18025
|
-
}
|
|
18026
|
-
if (primaryFailure !== void 0) {
|
|
18027
|
-
if (primaryFailure instanceof SitianInfrastructureError) throw primaryFailure;
|
|
18028
|
-
throw new SitianInfrastructureError(
|
|
18029
|
-
`Sitian appender persistence failure: ${errorText(primaryFailure)}`,
|
|
18030
|
-
{ cause: primaryFailure }
|
|
18031
|
-
);
|
|
18032
|
-
}
|
|
18033
|
-
if (cleanupFailure !== void 0) {
|
|
18034
|
-
throw new SitianInfrastructureError(
|
|
18035
|
-
`Sitian identity claim at ${claimPath} could not be released after append for identity ${record4.identity}: ${errorText(cleanupFailure)}`,
|
|
18036
|
-
{ cause: cleanupFailure }
|
|
18037
|
-
);
|
|
18038
|
-
}
|
|
18039
|
-
return result;
|
|
18040
|
-
}
|
|
18041
17899
|
function resolveSitianVolumeCategory(kind) {
|
|
18042
17900
|
if (S4_SUBMISSION_LEDGER_KINDS.has(kind)) {
|
|
18043
17901
|
return "submission-ledger";
|
|
@@ -18110,7 +17968,13 @@ function appendSitianRecord(input) {
|
|
|
18110
17968
|
};
|
|
18111
17969
|
const row = `${JSON.stringify(record4)}
|
|
18112
17970
|
`;
|
|
18113
|
-
|
|
17971
|
+
appendFileSync(recordFile, row, "utf8");
|
|
17972
|
+
return {
|
|
17973
|
+
identity: record4.identity,
|
|
17974
|
+
recordFile,
|
|
17975
|
+
kind: record4.kind,
|
|
17976
|
+
level: record4.level
|
|
17977
|
+
};
|
|
18114
17978
|
} catch (error) {
|
|
18115
17979
|
if (error instanceof SitianInfrastructureError) throw error;
|
|
18116
17980
|
throw new SitianInfrastructureError(
|
|
@@ -18138,13 +18002,13 @@ var init_sitian_appender = __esm({
|
|
|
18138
18002
|
});
|
|
18139
18003
|
|
|
18140
18004
|
// src/sitian-reader.ts
|
|
18141
|
-
import { existsSync as
|
|
18005
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
18142
18006
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
18143
|
-
function
|
|
18007
|
+
function isRecord3(value) {
|
|
18144
18008
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18145
18009
|
}
|
|
18146
18010
|
async function readSitianRecords(recordFile) {
|
|
18147
|
-
if (!
|
|
18011
|
+
if (!existsSync3(recordFile)) {
|
|
18148
18012
|
return { records: [], diagnostics: [] };
|
|
18149
18013
|
}
|
|
18150
18014
|
const text = await readFile6(recordFile, "utf8");
|
|
@@ -18156,7 +18020,7 @@ async function readSitianRecords(recordFile) {
|
|
|
18156
18020
|
if (!line2.trim()) continue;
|
|
18157
18021
|
try {
|
|
18158
18022
|
const parsed = JSON.parse(line2);
|
|
18159
|
-
if (
|
|
18023
|
+
if (isRecord3(parsed)) {
|
|
18160
18024
|
records.push(parsed);
|
|
18161
18025
|
} else {
|
|
18162
18026
|
const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
|
|
@@ -18416,19 +18280,7 @@ function createPiRoleTurnHost(config) {
|
|
|
18416
18280
|
});
|
|
18417
18281
|
return {
|
|
18418
18282
|
async executeTurn(request) {
|
|
18419
|
-
|
|
18420
|
-
const officerStationChild = request.stationChild === true && isOfficerReviewSeat(request.activation.role);
|
|
18421
|
-
const paths = !officerStationChild && request.hostTransition?.priorNativeKind === "sitian" ? request.hostTransition.priorNativePaths : void 0;
|
|
18422
|
-
if (request.continuation.kind === "resume" && paths !== void 0 && paths.length > 0) {
|
|
18423
|
-
turnRequest = {
|
|
18424
|
-
...request,
|
|
18425
|
-
continuation: {
|
|
18426
|
-
...request.continuation,
|
|
18427
|
-
prompt: `${request.continuation.prompt}
|
|
18428
|
-
${paths.join("\n")}`
|
|
18429
|
-
}
|
|
18430
|
-
};
|
|
18431
|
-
}
|
|
18283
|
+
const turnRequest = request;
|
|
18432
18284
|
const roleEntry = await realpath(resolveInternalRoleEntrypoint(config.packageRoot));
|
|
18433
18285
|
const extraArgs = buildPiTurnExtraArgs(
|
|
18434
18286
|
turnRequest,
|
|
@@ -18508,7 +18360,6 @@ var init_role_turn_host = __esm({
|
|
|
18508
18360
|
"src/pi/role-turn-host.ts"() {
|
|
18509
18361
|
"use strict";
|
|
18510
18362
|
init_host_contracts();
|
|
18511
|
-
init_packaged_role_registry();
|
|
18512
18363
|
init_engine_detour();
|
|
18513
18364
|
init_role_activation_flags();
|
|
18514
18365
|
init_user_dialogue_stdin();
|
|
@@ -18527,9 +18378,9 @@ var init_role_turn_host = __esm({
|
|
|
18527
18378
|
});
|
|
18528
18379
|
|
|
18529
18380
|
// src/sha256.ts
|
|
18530
|
-
import { createHash as
|
|
18381
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
18531
18382
|
function sha256Hex(bytes) {
|
|
18532
|
-
return
|
|
18383
|
+
return createHash2("sha256").update(bytes).digest("hex");
|
|
18533
18384
|
}
|
|
18534
18385
|
var init_sha256 = __esm({
|
|
18535
18386
|
"src/sha256.ts"() {
|
|
@@ -19029,7 +18880,7 @@ var init_merger_git_state = __esm({
|
|
|
19029
18880
|
|
|
19030
18881
|
// src/ledger-session-read.ts
|
|
19031
18882
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
19032
|
-
function
|
|
18883
|
+
function isRecord4(value) {
|
|
19033
18884
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19034
18885
|
}
|
|
19035
18886
|
async function readLedgerSessionJsonlLines(path) {
|
|
@@ -19054,7 +18905,7 @@ async function readLedgerSessionJsonlLines(path) {
|
|
|
19054
18905
|
});
|
|
19055
18906
|
continue;
|
|
19056
18907
|
}
|
|
19057
|
-
if (!
|
|
18908
|
+
if (!isRecord4(row)) {
|
|
19058
18909
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
19059
18910
|
out.push({
|
|
19060
18911
|
line: lineNumber,
|
|
@@ -19107,7 +18958,7 @@ function extractSessionModelSequence(rows) {
|
|
|
19107
18958
|
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
19108
18959
|
push(row.modelId);
|
|
19109
18960
|
}
|
|
19110
|
-
const message =
|
|
18961
|
+
const message = isRecord4(row.message) ? row.message : void 0;
|
|
19111
18962
|
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
19112
18963
|
push(message.model);
|
|
19113
18964
|
}
|
|
@@ -19123,11 +18974,11 @@ function extractSessionToolIntervals(rows) {
|
|
|
19123
18974
|
const openById = /* @__PURE__ */ new Map();
|
|
19124
18975
|
for (const row of rows) {
|
|
19125
18976
|
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
19126
|
-
const message =
|
|
18977
|
+
const message = isRecord4(row.message) ? row.message : void 0;
|
|
19127
18978
|
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
19128
18979
|
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
19129
18980
|
for (const part of message.content) {
|
|
19130
|
-
if (!
|
|
18981
|
+
if (!isRecord4(part) || part.type !== "toolCall") continue;
|
|
19131
18982
|
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
19132
18983
|
throw new Error("toolCall frame missing string id");
|
|
19133
18984
|
}
|
|
@@ -19140,7 +18991,7 @@ function extractSessionToolIntervals(rows) {
|
|
|
19140
18991
|
if (openById.has(part.id)) {
|
|
19141
18992
|
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
19142
18993
|
}
|
|
19143
|
-
const args =
|
|
18994
|
+
const args = isRecord4(part.arguments) ? part.arguments : void 0;
|
|
19144
18995
|
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
19145
18996
|
const interval = {
|
|
19146
18997
|
toolCallId: part.id,
|
|
@@ -20488,7 +20339,7 @@ var init_option_definitions = __esm({
|
|
|
20488
20339
|
|
|
20489
20340
|
// src/public-cli/invocation.ts
|
|
20490
20341
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
20491
|
-
import { existsSync as
|
|
20342
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
20492
20343
|
import {
|
|
20493
20344
|
lstat as lstat4,
|
|
20494
20345
|
mkdtemp,
|
|
@@ -20714,7 +20565,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
20714
20565
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
20715
20566
|
if (typeof childRunId !== "string") continue;
|
|
20716
20567
|
const childDirectory = join18(dirname12(oldRunDirectory), `${childRunId}@diarist`);
|
|
20717
|
-
if (!
|
|
20568
|
+
if (!existsSync4(childDirectory)) continue;
|
|
20718
20569
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
20719
20570
|
bookKey: admitted.bookKey,
|
|
20720
20571
|
subject: { ticketNumber: admitted.ticketNumber },
|
|
@@ -22176,7 +22027,7 @@ var init_invocation = __esm({
|
|
|
22176
22027
|
});
|
|
22177
22028
|
|
|
22178
22029
|
// src/public-cli/load-production-acp-host.ts
|
|
22179
|
-
import { existsSync as
|
|
22030
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
22180
22031
|
import { join as join19 } from "node:path";
|
|
22181
22032
|
import { pathToFileURL } from "node:url";
|
|
22182
22033
|
async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
@@ -22186,7 +22037,7 @@ async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
|
22186
22037
|
}
|
|
22187
22038
|
const built = join19(packageRoot2, "dist/acp-host/production-host.js");
|
|
22188
22039
|
const source = join19(packageRoot2, "src/acp-host/production-host.ts");
|
|
22189
|
-
const target =
|
|
22040
|
+
const target = existsSync5(built) ? built : source;
|
|
22190
22041
|
const href = pathToFileURL(target).href;
|
|
22191
22042
|
const mod = await import(href);
|
|
22192
22043
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -22200,7 +22051,7 @@ var init_load_production_acp_host = __esm({
|
|
|
22200
22051
|
});
|
|
22201
22052
|
|
|
22202
22053
|
// src/public-cli/load-production-headless-host.ts
|
|
22203
|
-
import { existsSync as
|
|
22054
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
22204
22055
|
import { join as join20 } from "node:path";
|
|
22205
22056
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
22206
22057
|
async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
@@ -22210,7 +22061,7 @@ async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
|
22210
22061
|
}
|
|
22211
22062
|
const built = join20(packageRoot2, "dist/headless-host/production-host.js");
|
|
22212
22063
|
const source = join20(packageRoot2, "src/headless-host/production-host.ts");
|
|
22213
|
-
const target =
|
|
22064
|
+
const target = existsSync6(built) ? built : source;
|
|
22214
22065
|
const href = pathToFileURL2(target).href;
|
|
22215
22066
|
const mod = await import(href);
|
|
22216
22067
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -22337,7 +22188,7 @@ var init_role_turn_host_resolution = __esm({
|
|
|
22337
22188
|
// src/analyst-gate-cycles-read.ts
|
|
22338
22189
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
22339
22190
|
import { join as join21 } from "node:path";
|
|
22340
|
-
function
|
|
22191
|
+
function isRecord5(value) {
|
|
22341
22192
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22342
22193
|
}
|
|
22343
22194
|
function isParentAttemptBindingRow(row) {
|
|
@@ -22367,7 +22218,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
22367
22218
|
function acceptedGateReceiptIds(rows) {
|
|
22368
22219
|
const accepted = /* @__PURE__ */ new Set();
|
|
22369
22220
|
for (const row of rows) {
|
|
22370
|
-
const message =
|
|
22221
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
22371
22222
|
if (message?.role !== "toolResult") continue;
|
|
22372
22223
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
22373
22224
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -22402,7 +22253,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
22402
22253
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
22403
22254
|
const row = rows[i];
|
|
22404
22255
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
22405
|
-
if (!
|
|
22256
|
+
if (!isRecord5(row.data) || !isRecord5(row.data.parent)) continue;
|
|
22406
22257
|
const id = row.data.parent.attemptEntryId;
|
|
22407
22258
|
const sessionFile = row.data.parent.sessionFile;
|
|
22408
22259
|
return {
|
|
@@ -22417,10 +22268,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22417
22268
|
const out = [];
|
|
22418
22269
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
22419
22270
|
const row = rows[rowIndex];
|
|
22420
|
-
const message =
|
|
22271
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
22421
22272
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
22422
22273
|
for (const part of message.content) {
|
|
22423
|
-
if (!
|
|
22274
|
+
if (!isRecord5(part) || part.type !== "toolCall") continue;
|
|
22424
22275
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
22425
22276
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
22426
22277
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -22428,7 +22279,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22428
22279
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
22429
22280
|
out.push({
|
|
22430
22281
|
toolName: part.name,
|
|
22431
|
-
args:
|
|
22282
|
+
args: isRecord5(part.arguments) ? part.arguments : void 0,
|
|
22432
22283
|
accepted: true,
|
|
22433
22284
|
rowIndex,
|
|
22434
22285
|
...binding
|
|
@@ -22561,7 +22412,7 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
22561
22412
|
{ cause: error }
|
|
22562
22413
|
);
|
|
22563
22414
|
}
|
|
22564
|
-
if (!
|
|
22415
|
+
if (!isRecord5(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
22565
22416
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
22566
22417
|
}
|
|
22567
22418
|
const sessionFile = raw.sessionFile;
|
|
@@ -22831,14 +22682,14 @@ var init_audit_escalation = __esm({
|
|
|
22831
22682
|
});
|
|
22832
22683
|
|
|
22833
22684
|
// src/session-opening-materials.ts
|
|
22834
|
-
import { existsSync as
|
|
22685
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
22835
22686
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
22836
22687
|
import { dirname as dirname13, join as join23 } from "node:path";
|
|
22837
22688
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
22838
22689
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
22839
22690
|
let dir = dirname13(fileURLToPath(moduleUrl));
|
|
22840
22691
|
for (let i = 0; i < 8; i += 1) {
|
|
22841
|
-
if (
|
|
22692
|
+
if (existsSync7(join23(dir, "package.json")) && existsSync7(join23(dir, "souls"))) {
|
|
22842
22693
|
return dir;
|
|
22843
22694
|
}
|
|
22844
22695
|
const parent = dirname13(dir);
|
|
@@ -23045,13 +22896,13 @@ var init_serialize_thrown_value = __esm({
|
|
|
23045
22896
|
|
|
23046
22897
|
// src/engine-detour-usage.ts
|
|
23047
22898
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
23048
|
-
import { readFileSync as
|
|
22899
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
23049
22900
|
import { dirname as dirname14, join as join25 } from "node:path";
|
|
23050
|
-
function
|
|
22901
|
+
function isRecord6(value) {
|
|
23051
22902
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23052
22903
|
}
|
|
23053
22904
|
function callFactFromSitianPayload(payload, pointer) {
|
|
23054
|
-
if (!
|
|
22905
|
+
if (!isRecord6(payload)) return void 0;
|
|
23055
22906
|
if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
|
|
23056
22907
|
if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
|
|
23057
22908
|
return void 0;
|
|
@@ -23068,11 +22919,11 @@ function callFactFromSitianPayload(payload, pointer) {
|
|
|
23068
22919
|
};
|
|
23069
22920
|
}
|
|
23070
22921
|
function invocationScopeIdOfRecord(record4) {
|
|
23071
|
-
if (
|
|
22922
|
+
if (isRecord6(record4.subject)) {
|
|
23072
22923
|
const fromSubject = record4.subject.invocationScopeId;
|
|
23073
22924
|
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
23074
22925
|
}
|
|
23075
|
-
if (
|
|
22926
|
+
if (isRecord6(record4.payload)) {
|
|
23076
22927
|
const fromPayload = record4.payload.invocationScopeId;
|
|
23077
22928
|
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
23078
22929
|
}
|
|
@@ -23088,7 +22939,7 @@ async function readEngineDetourToolUsage(input) {
|
|
|
23088
22939
|
...input.cwd === void 0 ? {} : { cwd: input.cwd }
|
|
23089
22940
|
});
|
|
23090
22941
|
const { records } = await readSitianRecords(recordFile);
|
|
23091
|
-
const
|
|
22942
|
+
const callsByToolCallId = /* @__PURE__ */ new Map();
|
|
23092
22943
|
for (const record4 of records) {
|
|
23093
22944
|
if (record4.kind !== ENGINE_DETOUR_CALL_KIND) continue;
|
|
23094
22945
|
const boundScope = invocationScopeIdOfRecord(record4);
|
|
@@ -23105,8 +22956,9 @@ async function readEngineDetourToolUsage(input) {
|
|
|
23105
22956
|
};
|
|
23106
22957
|
const fact = callFactFromSitianPayload(record4.payload, pointer);
|
|
23107
22958
|
if (fact === void 0) continue;
|
|
23108
|
-
|
|
22959
|
+
callsByToolCallId.set(fact.toolCallId, fact);
|
|
23109
22960
|
}
|
|
22961
|
+
const calls = Array.from(callsByToolCallId.values());
|
|
23110
22962
|
return { callCount: calls.length, calls };
|
|
23111
22963
|
}
|
|
23112
22964
|
function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
@@ -23130,9 +22982,9 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
23130
22982
|
function readInvocationRecord(runDirectory) {
|
|
23131
22983
|
try {
|
|
23132
22984
|
const raw = JSON.parse(
|
|
23133
|
-
|
|
22985
|
+
readFileSync2(join25(runDirectory, "invocation.json"), "utf8")
|
|
23134
22986
|
);
|
|
23135
|
-
return
|
|
22987
|
+
return isRecord6(raw) ? raw : void 0;
|
|
23136
22988
|
} catch (error) {
|
|
23137
22989
|
if (error?.code === "ENOENT") return void 0;
|
|
23138
22990
|
throw error;
|
|
@@ -23143,14 +22995,9 @@ async function readInvocationEngineMounted(runDirectory) {
|
|
|
23143
22995
|
if (raw === void 0) return false;
|
|
23144
22996
|
return typeof raw.engine === "string" && raw.engine.trim() !== "";
|
|
23145
22997
|
}
|
|
23146
|
-
function readInvocationSelectedHost(runDirectory) {
|
|
23147
|
-
const raw = readInvocationRecord(runDirectory);
|
|
23148
|
-
if (raw === void 0) return void 0;
|
|
23149
|
-
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host.trim() : void 0;
|
|
23150
|
-
}
|
|
23151
22998
|
function withEngineDetourToolUsageFact(outcome, usage) {
|
|
23152
22999
|
if (usage === void 0) return outcome;
|
|
23153
|
-
const prior =
|
|
23000
|
+
const prior = isRecord6(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
|
|
23154
23001
|
return {
|
|
23155
23002
|
...outcome,
|
|
23156
23003
|
decisiveFacts: {
|
|
@@ -23192,7 +23039,7 @@ var init_engine_detour_usage = __esm({
|
|
|
23192
23039
|
});
|
|
23193
23040
|
|
|
23194
23041
|
// src/dossier-resolution.ts
|
|
23195
|
-
import { existsSync as
|
|
23042
|
+
import { existsSync as existsSync8, statSync as statSync3 } from "node:fs";
|
|
23196
23043
|
import { resolve as resolve10 } from "node:path";
|
|
23197
23044
|
function isHostContext(value) {
|
|
23198
23045
|
return "sessionManager" in value;
|
|
@@ -23212,7 +23059,7 @@ function resolveAuditDossier(source) {
|
|
|
23212
23059
|
}
|
|
23213
23060
|
const runDirectory = resolve10(raw);
|
|
23214
23061
|
try {
|
|
23215
|
-
if (!
|
|
23062
|
+
if (!existsSync8(runDirectory) || !statSync3(runDirectory).isDirectory()) {
|
|
23216
23063
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
23217
23064
|
}
|
|
23218
23065
|
} catch {
|
|
@@ -23220,13 +23067,13 @@ function resolveAuditDossier(source) {
|
|
|
23220
23067
|
}
|
|
23221
23068
|
return { status: "ok", runDirectory };
|
|
23222
23069
|
}
|
|
23223
|
-
function
|
|
23070
|
+
function isRecord7(value) {
|
|
23224
23071
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23225
23072
|
}
|
|
23226
23073
|
function readDoctorAuditSubjects(context) {
|
|
23227
23074
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
23228
23075
|
for (const entry of entries) {
|
|
23229
|
-
if (
|
|
23076
|
+
if (isRecord7(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
23230
23077
|
return { status: "ok" };
|
|
23231
23078
|
}
|
|
23232
23079
|
}
|
|
@@ -23371,11 +23218,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
23371
23218
|
});
|
|
23372
23219
|
|
|
23373
23220
|
// src/receipt-delivery-policy.ts
|
|
23374
|
-
function
|
|
23221
|
+
function isRecord8(value) {
|
|
23375
23222
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23376
23223
|
}
|
|
23377
23224
|
function parseNoReceiptLifecycleFacts(input) {
|
|
23378
|
-
if (!
|
|
23225
|
+
if (!isRecord8(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord8(item) && typeof item.reason === "string")) {
|
|
23379
23226
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
23380
23227
|
}
|
|
23381
23228
|
return {
|
|
@@ -23950,7 +23797,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
23950
23797
|
const { records } = await readSitianRecords(recordFile);
|
|
23951
23798
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
23952
23799
|
const payload = records[i]?.payload;
|
|
23953
|
-
if (!
|
|
23800
|
+
if (!isRecord9(payload) || !isRecord9(payload.response)) continue;
|
|
23954
23801
|
if (typeof payload.type === "string") continue;
|
|
23955
23802
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
23956
23803
|
if (stop !== void 0) return stop;
|
|
@@ -24000,7 +23847,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24000
23847
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
24001
23848
|
}
|
|
24002
23849
|
const header = entries.find((entry) => entry.type === "session");
|
|
24003
|
-
if (!
|
|
23850
|
+
if (!isRecord9(header)) continue;
|
|
24004
23851
|
const bindingIndexes = [];
|
|
24005
23852
|
for (let i = 0; i < entries.length; i += 1) {
|
|
24006
23853
|
const entry = entries[i];
|
|
@@ -24014,7 +23861,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24014
23861
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
24015
23862
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
24016
23863
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
24017
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
23864
|
+
const bindingParent = bindingEntry !== void 0 && isRecord9(bindingEntry.data) && isRecord9(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
24018
23865
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
24019
23866
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
24020
23867
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -24038,12 +23885,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
24038
23885
|
if (stop === void 0) continue;
|
|
24039
23886
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
24040
23887
|
const entry = entries[i];
|
|
24041
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
24042
|
-
const parent =
|
|
24043
|
-
const failure =
|
|
23888
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord9(entry.data)) continue;
|
|
23889
|
+
const parent = isRecord9(entry.data.parent) ? entry.data.parent : void 0;
|
|
23890
|
+
const failure = isRecord9(entry.data.failure) ? entry.data.failure : void 0;
|
|
24044
23891
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
24045
23892
|
if (failure === void 0) continue;
|
|
24046
|
-
const identity =
|
|
23893
|
+
const identity = isRecord9(failure.identity) ? failure.identity : void 0;
|
|
24047
23894
|
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
24048
23895
|
return {
|
|
24049
23896
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -24052,7 +23899,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
24052
23899
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
24053
23900
|
} },
|
|
24054
23901
|
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
24055
|
-
...
|
|
23902
|
+
...isRecord9(failure.details) ? { details: failure.details } : {}
|
|
24056
23903
|
};
|
|
24057
23904
|
}
|
|
24058
23905
|
}
|
|
@@ -24099,9 +23946,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
24099
23946
|
if (classification.kind !== "infrastructure") continue;
|
|
24100
23947
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
24101
23948
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
24102
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
24103
|
-
const diagnostic =
|
|
24104
|
-
const details =
|
|
23949
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord9(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
23950
|
+
const diagnostic = isRecord9(textPart) ? textPart.text : void 0;
|
|
23951
|
+
const details = isRecord9(message.details) ? message.details : classification.fact;
|
|
24105
23952
|
return {
|
|
24106
23953
|
cause: "activation",
|
|
24107
23954
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -24238,7 +24085,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
24238
24085
|
} : {}
|
|
24239
24086
|
};
|
|
24240
24087
|
}
|
|
24241
|
-
function
|
|
24088
|
+
function isRecord9(value) {
|
|
24242
24089
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24243
24090
|
}
|
|
24244
24091
|
function toolResultText(message) {
|
|
@@ -24263,7 +24110,7 @@ function extractCollectorTargetBindRejection(entries) {
|
|
|
24263
24110
|
const diagnostic = toolResultText(message);
|
|
24264
24111
|
if (diagnostic.length === 0) return void 0;
|
|
24265
24112
|
const details = message.details;
|
|
24266
|
-
const code =
|
|
24113
|
+
const code = isRecord9(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
24267
24114
|
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
24268
24115
|
}
|
|
24269
24116
|
return void 0;
|
|
@@ -24364,7 +24211,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
24364
24211
|
const candidateMessage = entries[index]?.message;
|
|
24365
24212
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
24366
24213
|
for (const part of candidateMessage.content) {
|
|
24367
|
-
if (!
|
|
24214
|
+
if (!isRecord9(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
24368
24215
|
continue;
|
|
24369
24216
|
}
|
|
24370
24217
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -24435,7 +24282,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
24435
24282
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
24436
24283
|
prose = details.prose;
|
|
24437
24284
|
} else {
|
|
24438
|
-
const next =
|
|
24285
|
+
const next = isRecord9(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
24439
24286
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
24440
24287
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
24441
24288
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -24544,7 +24391,7 @@ function detourGateContext(admitted, scope) {
|
|
|
24544
24391
|
}
|
|
24545
24392
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
24546
24393
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
24547
|
-
const skipGate =
|
|
24394
|
+
const skipGate = isRecord9(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
24548
24395
|
let next = base;
|
|
24549
24396
|
if (!skipGate) {
|
|
24550
24397
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -24557,7 +24404,7 @@ function routePlaybookFailureMessage(entries) {
|
|
|
24557
24404
|
const entry = entries[i];
|
|
24558
24405
|
if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
|
|
24559
24406
|
const data = entry.data;
|
|
24560
|
-
if (!
|
|
24407
|
+
if (!isRecord9(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
|
|
24561
24408
|
return data.message;
|
|
24562
24409
|
}
|
|
24563
24410
|
return void 0;
|
|
@@ -24604,7 +24451,7 @@ function extractNavigatorAttendanceFact(entries) {
|
|
|
24604
24451
|
const entry = entries[i];
|
|
24605
24452
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
24606
24453
|
const details = entry.message?.details ?? entry.details;
|
|
24607
|
-
if (!
|
|
24454
|
+
if (!isRecord9(details)) {
|
|
24608
24455
|
return {
|
|
24609
24456
|
disposition: "unavailable",
|
|
24610
24457
|
source: "unknown",
|
|
@@ -24755,7 +24602,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
24755
24602
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
24756
24603
|
if (residual === void 0) continue;
|
|
24757
24604
|
const candidate = residual.candidate;
|
|
24758
|
-
const details =
|
|
24605
|
+
const details = isRecord9(candidate) ? candidate : { candidate };
|
|
24759
24606
|
const failed = await settleFailureTerminalResult(
|
|
24760
24607
|
admitted,
|
|
24761
24608
|
{
|
|
@@ -24830,7 +24677,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
24830
24677
|
continue;
|
|
24831
24678
|
}
|
|
24832
24679
|
const data = entry.data;
|
|
24833
|
-
if (!
|
|
24680
|
+
if (!isRecord9(data)) return {};
|
|
24834
24681
|
return {
|
|
24835
24682
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
24836
24683
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -24915,7 +24762,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
24915
24762
|
let residual;
|
|
24916
24763
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
24917
24764
|
const entry = entries[index];
|
|
24918
|
-
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" &&
|
|
24765
|
+
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord9(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
|
|
24919
24766
|
thisAttemptHasSeatSuccess = true;
|
|
24920
24767
|
}
|
|
24921
24768
|
const message = entries[index]?.message;
|
|
@@ -24955,7 +24802,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
24955
24802
|
);
|
|
24956
24803
|
}
|
|
24957
24804
|
if (residual !== void 0) {
|
|
24958
|
-
const details =
|
|
24805
|
+
const details = isRecord9(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
24959
24806
|
const failed = await settleFailureTerminalResult(
|
|
24960
24807
|
admitted,
|
|
24961
24808
|
{
|
|
@@ -25005,7 +24852,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
25005
24852
|
return void 0;
|
|
25006
24853
|
}
|
|
25007
24854
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
25008
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
24855
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord9(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
25009
24856
|
return {
|
|
25010
24857
|
...roleOutcome,
|
|
25011
24858
|
decisiveFacts: {
|
|
@@ -25018,7 +24865,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
25018
24865
|
const payloads = roleOutcome.payloads ?? [];
|
|
25019
24866
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
25020
24867
|
const payload = payloads[index];
|
|
25021
|
-
if (!
|
|
24868
|
+
if (!isRecord9(payload)) continue;
|
|
25022
24869
|
const status = payload.secretariatStatus;
|
|
25023
24870
|
if (typeof status !== "string") continue;
|
|
25024
24871
|
return status === "converged";
|
|
@@ -25463,7 +25310,7 @@ var init_settlement = __esm({
|
|
|
25463
25310
|
});
|
|
25464
25311
|
|
|
25465
25312
|
// src/archivist-record-pointer.ts
|
|
25466
|
-
import { mkdirSync as mkdirSync3, writeFileSync
|
|
25313
|
+
import { mkdirSync as mkdirSync3, writeFileSync } from "node:fs";
|
|
25467
25314
|
import { dirname as dirname16, join as join27 } from "node:path";
|
|
25468
25315
|
function bookDirectOfficerRunPointer(options) {
|
|
25469
25316
|
const nest = join27(dirname16(options.parentSessionFile), "auditor-roles");
|
|
@@ -25475,7 +25322,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
25475
25322
|
sessionFile: options.sessionFile,
|
|
25476
25323
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
25477
25324
|
};
|
|
25478
|
-
|
|
25325
|
+
writeFileSync(
|
|
25479
25326
|
join27(nest, `${options.officer}.pointer.json`),
|
|
25480
25327
|
`${JSON.stringify(pointer)}
|
|
25481
25328
|
`,
|
|
@@ -25818,11 +25665,11 @@ var init_turn_request = __esm({
|
|
|
25818
25665
|
});
|
|
25819
25666
|
|
|
25820
25667
|
// src/public-cli/countersign-run.ts
|
|
25821
|
-
function
|
|
25668
|
+
function isRecord10(value) {
|
|
25822
25669
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25823
25670
|
}
|
|
25824
25671
|
function isEscalatePayload(payload) {
|
|
25825
|
-
if (!
|
|
25672
|
+
if (!isRecord10(payload)) return false;
|
|
25826
25673
|
return payload.status === "escalate";
|
|
25827
25674
|
}
|
|
25828
25675
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -27046,7 +26893,7 @@ __export(public_role_summons_exports, {
|
|
|
27046
26893
|
summonPublicRole: () => summonPublicRole
|
|
27047
26894
|
});
|
|
27048
26895
|
import { execFile as execFile3 } from "node:child_process";
|
|
27049
|
-
import { existsSync as
|
|
26896
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
27050
26897
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
27051
26898
|
import { join as join28 } from "node:path";
|
|
27052
26899
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -27072,7 +26919,7 @@ function parentDir(path) {
|
|
|
27072
26919
|
function walkPackageRoot(start) {
|
|
27073
26920
|
let dir = start;
|
|
27074
26921
|
for (let i = 0; i < 12; i += 1) {
|
|
27075
|
-
if (
|
|
26922
|
+
if (existsSync9(join28(dir, "package.json")) && existsSync9(join28(dir, "souls"))) {
|
|
27076
26923
|
return dir;
|
|
27077
26924
|
}
|
|
27078
26925
|
const parent = parentDir(dir);
|
|
@@ -27897,7 +27744,7 @@ async function readRoleRunStateRaw(runDirectory) {
|
|
|
27897
27744
|
try {
|
|
27898
27745
|
raw = JSON.parse(await readFile16(join30(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
27899
27746
|
} catch (error) {
|
|
27900
|
-
if (
|
|
27747
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
27901
27748
|
throw error;
|
|
27902
27749
|
}
|
|
27903
27750
|
return raw;
|
|
@@ -28142,7 +27989,7 @@ function describeErrorIdentity(error) {
|
|
|
28142
27989
|
const message = typeof candidate?.message === "string" && candidate.message !== "" ? `: ${candidate.message}` : "";
|
|
28143
27990
|
return `${name}${code}${message}`;
|
|
28144
27991
|
}
|
|
28145
|
-
function
|
|
27992
|
+
function errorCodeOf(error) {
|
|
28146
27993
|
return error.code;
|
|
28147
27994
|
}
|
|
28148
27995
|
function isProcessAlive(pid) {
|
|
@@ -28150,7 +27997,7 @@ function isProcessAlive(pid) {
|
|
|
28150
27997
|
process.kill(pid, 0);
|
|
28151
27998
|
return true;
|
|
28152
27999
|
} catch (error) {
|
|
28153
|
-
return
|
|
28000
|
+
return errorCodeOf(error) !== "ESRCH";
|
|
28154
28001
|
}
|
|
28155
28002
|
}
|
|
28156
28003
|
async function autopsyWriterLock(lockPath) {
|
|
@@ -28158,7 +28005,7 @@ async function autopsyWriterLock(lockPath) {
|
|
|
28158
28005
|
try {
|
|
28159
28006
|
content = await readFile16(lockPath, "utf8");
|
|
28160
28007
|
} catch (error) {
|
|
28161
|
-
if (
|
|
28008
|
+
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
28162
28009
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
28163
28010
|
}
|
|
28164
28011
|
const normalized = content.trim();
|
|
@@ -28190,8 +28037,8 @@ async function reclaimStaleWriterLock(lockPath, runDirectory) {
|
|
|
28190
28037
|
await unlink4(lockPath);
|
|
28191
28038
|
return { reclaimed: true };
|
|
28192
28039
|
} catch (error) {
|
|
28193
|
-
if (
|
|
28194
|
-
if (
|
|
28040
|
+
if (errorCodeOf(error) === "ENOENT") return { reclaimed: false };
|
|
28041
|
+
if (errorCodeOf(error) !== "EACCES") throw error;
|
|
28195
28042
|
await chmod(runDirectory, 493);
|
|
28196
28043
|
return { reclaimed: false, eaccesFailure: error };
|
|
28197
28044
|
}
|
|
@@ -28224,7 +28071,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
28224
28071
|
try {
|
|
28225
28072
|
await unlink4(currentLockPath);
|
|
28226
28073
|
} catch (error) {
|
|
28227
|
-
if (
|
|
28074
|
+
if (errorCodeOf(error) === "EACCES") {
|
|
28228
28075
|
try {
|
|
28229
28076
|
await chmod(currentRunDirectory, 493);
|
|
28230
28077
|
await unlink4(currentLockPath);
|
|
@@ -28264,7 +28111,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
28264
28111
|
try {
|
|
28265
28112
|
return await createWriterLease(lockPath, runDirectory, reportCleanupFailure);
|
|
28266
28113
|
} catch (error) {
|
|
28267
|
-
if (
|
|
28114
|
+
if (errorCodeOf(error) !== "EEXIST") throw error;
|
|
28268
28115
|
}
|
|
28269
28116
|
lastAutopsy = await autopsyWriterLock(lockPath);
|
|
28270
28117
|
if (lastAutopsy.verdict === "unknown" && lastAutopsy.reason === "unreadable") {
|
|
@@ -28317,7 +28164,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
28317
28164
|
try {
|
|
28318
28165
|
bookKeys = await readdir6(booksRoot);
|
|
28319
28166
|
} catch (error) {
|
|
28320
|
-
if (
|
|
28167
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
28321
28168
|
throw error;
|
|
28322
28169
|
}
|
|
28323
28170
|
const matches = [];
|
|
@@ -28328,7 +28175,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
28328
28175
|
try {
|
|
28329
28176
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
28330
28177
|
} catch (error) {
|
|
28331
|
-
if (
|
|
28178
|
+
if (errorCodeOf(error) === "ENOENT") continue;
|
|
28332
28179
|
throw error;
|
|
28333
28180
|
}
|
|
28334
28181
|
for (const runDirectory of runDirectories) {
|
|
@@ -28356,7 +28203,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
28356
28203
|
await readFile16(join30(runDirectory, "admitted-request.json"), "utf8")
|
|
28357
28204
|
);
|
|
28358
28205
|
} catch (error) {
|
|
28359
|
-
if (
|
|
28206
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
28360
28207
|
throw error;
|
|
28361
28208
|
}
|
|
28362
28209
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
@@ -28379,7 +28226,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
28379
28226
|
const stat2 = await lstat6(sessionFile);
|
|
28380
28227
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
28381
28228
|
} catch (error) {
|
|
28382
|
-
if (
|
|
28229
|
+
if (errorCodeOf(error) === "ENOENT") return false;
|
|
28383
28230
|
throw error;
|
|
28384
28231
|
}
|
|
28385
28232
|
}
|
|
@@ -28395,7 +28242,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
28395
28242
|
input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
|
|
28396
28243
|
);
|
|
28397
28244
|
} catch (error) {
|
|
28398
|
-
if (
|
|
28245
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
28399
28246
|
throw error;
|
|
28400
28247
|
}
|
|
28401
28248
|
const suffix = `@${input.role}`;
|
|
@@ -29138,63 +28985,6 @@ var init_case_dossier_delivery = __esm({
|
|
|
29138
28985
|
}
|
|
29139
28986
|
});
|
|
29140
28987
|
|
|
29141
|
-
// src/host-transition-prior-native.ts
|
|
29142
|
-
import { access as access3, readdir as readdir7 } from "node:fs/promises";
|
|
29143
|
-
import { dirname as dirname19, join as join33 } from "node:path";
|
|
29144
|
-
function isEnoent2(error) {
|
|
29145
|
-
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
29146
|
-
}
|
|
29147
|
-
async function listPiNativeRecordPaths(sessionFile) {
|
|
29148
|
-
try {
|
|
29149
|
-
await access3(sessionFile);
|
|
29150
|
-
return [sessionFile];
|
|
29151
|
-
} catch (error) {
|
|
29152
|
-
if (isEnoent2(error)) return [];
|
|
29153
|
-
throw error;
|
|
29154
|
-
}
|
|
29155
|
-
}
|
|
29156
|
-
async function listSitianRecordPaths(sessionParent) {
|
|
29157
|
-
const sessionRoot = dirname19(sessionParent);
|
|
29158
|
-
let entries;
|
|
29159
|
-
try {
|
|
29160
|
-
entries = await readdir7(sessionRoot, { withFileTypes: true });
|
|
29161
|
-
} catch (error) {
|
|
29162
|
-
if (isEnoent2(error)) return [];
|
|
29163
|
-
throw error;
|
|
29164
|
-
}
|
|
29165
|
-
const recordPaths = [];
|
|
29166
|
-
for (const entry of entries) {
|
|
29167
|
-
if (!entry.isDirectory()) continue;
|
|
29168
|
-
const recordFile = join33(sessionRoot, entry.name, "records.jsonl");
|
|
29169
|
-
try {
|
|
29170
|
-
await access3(recordFile);
|
|
29171
|
-
recordPaths.push(recordFile);
|
|
29172
|
-
} catch (error) {
|
|
29173
|
-
if (!isEnoent2(error)) throw error;
|
|
29174
|
-
}
|
|
29175
|
-
}
|
|
29176
|
-
recordPaths.sort();
|
|
29177
|
-
return recordPaths;
|
|
29178
|
-
}
|
|
29179
|
-
async function projectHostTransitionPriorNative(input) {
|
|
29180
|
-
if (input.previousHost === input.liveHost) return void 0;
|
|
29181
|
-
if (input.previousHost === "pi") {
|
|
29182
|
-
return {
|
|
29183
|
-
priorNativeKind: "pi-native",
|
|
29184
|
-
priorNativePaths: await listPiNativeRecordPaths(input.piSessionFile)
|
|
29185
|
-
};
|
|
29186
|
-
}
|
|
29187
|
-
return {
|
|
29188
|
-
priorNativeKind: "sitian",
|
|
29189
|
-
priorNativePaths: await listSitianRecordPaths(input.piSessionFile)
|
|
29190
|
-
};
|
|
29191
|
-
}
|
|
29192
|
-
var init_host_transition_prior_native = __esm({
|
|
29193
|
-
"src/host-transition-prior-native.ts"() {
|
|
29194
|
-
"use strict";
|
|
29195
|
-
}
|
|
29196
|
-
});
|
|
29197
|
-
|
|
29198
28988
|
// src/public-cli/process-cancel.ts
|
|
29199
28989
|
var process_cancel_exports = {};
|
|
29200
28990
|
__export(process_cancel_exports, {
|
|
@@ -29248,6 +29038,39 @@ var init_process_cancel = __esm({
|
|
|
29248
29038
|
}
|
|
29249
29039
|
});
|
|
29250
29040
|
|
|
29041
|
+
// src/host-session-record.ts
|
|
29042
|
+
import {
|
|
29043
|
+
appendFileSync as appendFileSync2,
|
|
29044
|
+
copyFileSync,
|
|
29045
|
+
closeSync,
|
|
29046
|
+
existsSync as existsSync10,
|
|
29047
|
+
openSync,
|
|
29048
|
+
readFileSync as readFileSync3,
|
|
29049
|
+
mkdirSync as mkdirSync4,
|
|
29050
|
+
readdirSync as readdirSync2,
|
|
29051
|
+
rmSync as rmSync2,
|
|
29052
|
+
statSync as statSync4
|
|
29053
|
+
} from "node:fs";
|
|
29054
|
+
import { dirname as dirname19, join as join33 } from "node:path";
|
|
29055
|
+
function declareHostSessionFailure(error) {
|
|
29056
|
+
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
29057
|
+
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
29058
|
+
`);
|
|
29059
|
+
}
|
|
29060
|
+
function recordRunStart(runDirectory) {
|
|
29061
|
+
try {
|
|
29062
|
+
appendFileSync2(join33(runDirectory, ".run-starts"), "\n");
|
|
29063
|
+
} catch (error) {
|
|
29064
|
+
declareHostSessionFailure(error);
|
|
29065
|
+
}
|
|
29066
|
+
}
|
|
29067
|
+
var init_host_session_record = __esm({
|
|
29068
|
+
"src/host-session-record.ts"() {
|
|
29069
|
+
"use strict";
|
|
29070
|
+
init_sitian_facade();
|
|
29071
|
+
}
|
|
29072
|
+
});
|
|
29073
|
+
|
|
29251
29074
|
// src/public-cli/auto-resume.ts
|
|
29252
29075
|
import { constants as fsConstants2 } from "node:fs";
|
|
29253
29076
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
@@ -29910,35 +29733,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29910
29733
|
}
|
|
29911
29734
|
};
|
|
29912
29735
|
try {
|
|
29913
|
-
let previousHost;
|
|
29914
|
-
const liveHost = env.host;
|
|
29915
|
-
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
29916
|
-
let hostTransition;
|
|
29917
|
-
try {
|
|
29918
|
-
previousHost = readInvocationSelectedHost(admitted.runDirectory);
|
|
29919
|
-
hostTransition = previousHost !== void 0 && liveHost !== void 0 && principalCoordinates !== void 0 ? await projectHostTransitionPriorNative({
|
|
29920
|
-
previousHost,
|
|
29921
|
-
liveHost,
|
|
29922
|
-
piSessionFile: principalCoordinates.sessionFile
|
|
29923
|
-
}) : void 0;
|
|
29924
|
-
} catch (error) {
|
|
29925
|
-
return {
|
|
29926
|
-
...await presentControlledFailure2(
|
|
29927
|
-
admitted,
|
|
29928
|
-
withEngineDetourInvocationScope({
|
|
29929
|
-
timedOut: false,
|
|
29930
|
-
code: null,
|
|
29931
|
-
stderr: "",
|
|
29932
|
-
thrown: error
|
|
29933
|
-
}, request.invocationScopeId),
|
|
29934
|
-
adapters,
|
|
29935
|
-
env.principalAuthority,
|
|
29936
|
-
io,
|
|
29937
|
-
persistRunState
|
|
29938
|
-
),
|
|
29939
|
-
...deferredPersist
|
|
29940
|
-
};
|
|
29941
|
-
}
|
|
29942
29736
|
await clearTypedProviderHttpObservation(admitted.runDirectory);
|
|
29943
29737
|
if (adapters.beforeDispatch !== void 0) {
|
|
29944
29738
|
try {
|
|
@@ -29974,11 +29768,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29974
29768
|
if (env.stationChild !== void 0) {
|
|
29975
29769
|
turnRequest = { ...turnRequest, stationChild: env.stationChild };
|
|
29976
29770
|
}
|
|
29977
|
-
if (
|
|
29978
|
-
turnRequest = { ...turnRequest,
|
|
29979
|
-
}
|
|
29980
|
-
if (typeof liveHost === "string" && liveHost.trim() !== "") {
|
|
29981
|
-
turnRequest = { ...turnRequest, host: liveHost.trim() };
|
|
29771
|
+
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
29772
|
+
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
29982
29773
|
}
|
|
29983
29774
|
await deliverCaseDossierAsAttachment({
|
|
29984
29775
|
ticketNumber: admitted.ticketNumber,
|
|
@@ -29995,6 +29786,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29995
29786
|
);
|
|
29996
29787
|
let result;
|
|
29997
29788
|
try {
|
|
29789
|
+
recordRunStart(admitted.runDirectory);
|
|
29998
29790
|
result = await env.roleTurnHost.executeTurn(turnRequest);
|
|
29999
29791
|
} catch (error) {
|
|
30000
29792
|
const processCancelName = processCancelSignalName(env.signal);
|
|
@@ -30694,10 +30486,10 @@ var init_post_admission = __esm({
|
|
|
30694
30486
|
init_packaged_role_registry();
|
|
30695
30487
|
init_case_dossier_delivery();
|
|
30696
30488
|
init_engine_detour_usage();
|
|
30697
|
-
init_host_transition_prior_native();
|
|
30698
30489
|
init_run_lifecycle();
|
|
30699
30490
|
init_process_cancel();
|
|
30700
30491
|
init_activation_ledger_topology();
|
|
30492
|
+
init_host_session_record();
|
|
30701
30493
|
init_settlement();
|
|
30702
30494
|
init_terminal();
|
|
30703
30495
|
init_auto_resume();
|
|
@@ -30709,13 +30501,13 @@ var init_post_admission = __esm({
|
|
|
30709
30501
|
});
|
|
30710
30502
|
|
|
30711
30503
|
// src/analyst-book-key.ts
|
|
30712
|
-
import { statSync as
|
|
30504
|
+
import { statSync as statSync5 } from "node:fs";
|
|
30713
30505
|
import { isAbsolute as isAbsolute9 } from "node:path";
|
|
30714
30506
|
function resolveAnalystBookKey(projectRoot) {
|
|
30715
30507
|
const identity = physicalPathIdentity(projectRoot);
|
|
30716
30508
|
let stats;
|
|
30717
30509
|
try {
|
|
30718
|
-
stats =
|
|
30510
|
+
stats = statSync5(identity);
|
|
30719
30511
|
} catch (error) {
|
|
30720
30512
|
const code = errnoCode(error);
|
|
30721
30513
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -31096,7 +30888,7 @@ var init_analyst_cohort = __esm({
|
|
|
31096
30888
|
});
|
|
31097
30889
|
|
|
31098
30890
|
// src/analyst-ledger.ts
|
|
31099
|
-
import { readdir as
|
|
30891
|
+
import { readdir as readdir7, readFile as readFile20 } from "node:fs/promises";
|
|
31100
30892
|
import { basename as basename9, join as join38 } from "node:path";
|
|
31101
30893
|
function isMissingPathError6(error) {
|
|
31102
30894
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -31104,7 +30896,7 @@ function isMissingPathError6(error) {
|
|
|
31104
30896
|
function errorText3(error) {
|
|
31105
30897
|
return error instanceof Error ? error.message : String(error);
|
|
31106
30898
|
}
|
|
31107
|
-
function
|
|
30899
|
+
function isRecord11(value) {
|
|
31108
30900
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31109
30901
|
}
|
|
31110
30902
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -31145,7 +30937,7 @@ function parseRunDirectoryName2(name) {
|
|
|
31145
30937
|
}
|
|
31146
30938
|
async function listLedgerBookNames(booksRoot) {
|
|
31147
30939
|
try {
|
|
31148
|
-
const entries = await
|
|
30940
|
+
const entries = await readdir7(booksRoot, { withFileTypes: true });
|
|
31149
30941
|
return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
31150
30942
|
} catch (error) {
|
|
31151
30943
|
if (isMissingPathError6(error)) return [];
|
|
@@ -31161,7 +30953,7 @@ async function readInvocationScopeFields(runDirectory) {
|
|
|
31161
30953
|
throw error;
|
|
31162
30954
|
}
|
|
31163
30955
|
const parsed = JSON.parse(raw);
|
|
31164
|
-
if (!
|
|
30956
|
+
if (!isRecord11(parsed)) return void 0;
|
|
31165
30957
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
31166
30958
|
return void 0;
|
|
31167
30959
|
}
|
|
@@ -31190,7 +30982,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
31190
30982
|
try {
|
|
31191
30983
|
const raw = await readFile20(join38(runDirectory, "invocation.json"), "utf8");
|
|
31192
30984
|
const parsed = JSON.parse(raw);
|
|
31193
|
-
if (
|
|
30985
|
+
if (isRecord11(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
31194
30986
|
return parsed.sessionFile;
|
|
31195
30987
|
}
|
|
31196
30988
|
} catch (error) {
|
|
@@ -31528,7 +31320,7 @@ var init_analyst_ledger = __esm({
|
|
|
31528
31320
|
});
|
|
31529
31321
|
|
|
31530
31322
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
31531
|
-
function
|
|
31323
|
+
function isRecord12(value) {
|
|
31532
31324
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31533
31325
|
}
|
|
31534
31326
|
function wallMsFromSpan(span) {
|
|
@@ -31537,21 +31329,21 @@ function wallMsFromSpan(span) {
|
|
|
31537
31329
|
function findCollectorGroups(body) {
|
|
31538
31330
|
if (Array.isArray(body.groups)) return body.groups;
|
|
31539
31331
|
const receipt = body.receipt;
|
|
31540
|
-
if (
|
|
31332
|
+
if (isRecord12(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
31541
31333
|
const outcome = body.outcome;
|
|
31542
|
-
if (
|
|
31334
|
+
if (isRecord12(outcome)) {
|
|
31543
31335
|
const facts = outcome.decisiveFacts;
|
|
31544
|
-
if (
|
|
31336
|
+
if (isRecord12(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
31545
31337
|
}
|
|
31546
31338
|
return void 0;
|
|
31547
31339
|
}
|
|
31548
31340
|
function extractStatus(body) {
|
|
31549
31341
|
const outcome = body.outcome;
|
|
31550
|
-
if (
|
|
31342
|
+
if (isRecord12(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
31551
31343
|
return outcome.status;
|
|
31552
31344
|
}
|
|
31553
31345
|
const receipt = body.receipt;
|
|
31554
|
-
if (
|
|
31346
|
+
if (isRecord12(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
31555
31347
|
return receipt.status;
|
|
31556
31348
|
}
|
|
31557
31349
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -32177,15 +31969,15 @@ var init_leg_wall_clock = __esm({
|
|
|
32177
31969
|
});
|
|
32178
31970
|
|
|
32179
31971
|
// src/analyst-metric-families/round-timeline.ts
|
|
32180
|
-
function
|
|
31972
|
+
function isRecord13(value) {
|
|
32181
31973
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32182
31974
|
}
|
|
32183
31975
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
32184
31976
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
32185
31977
|
}
|
|
32186
31978
|
function readClassCount(body) {
|
|
32187
|
-
if (!
|
|
32188
|
-
if (!
|
|
31979
|
+
if (!isRecord13(body.outcome)) return void 0;
|
|
31980
|
+
if (!isRecord13(body.outcome.decisiveFacts)) return void 0;
|
|
32189
31981
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
32190
31982
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
32191
31983
|
return void 0;
|
|
@@ -32329,7 +32121,7 @@ var init_analyst_metric_family = __esm({
|
|
|
32329
32121
|
});
|
|
32330
32122
|
|
|
32331
32123
|
// src/analyst-page.ts
|
|
32332
|
-
import { createHash as
|
|
32124
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
32333
32125
|
import { dirname as dirname22, join as join39 } from "node:path";
|
|
32334
32126
|
function analystIssuePageKey(address) {
|
|
32335
32127
|
const parts = ["book", address.bookKey];
|
|
@@ -32338,7 +32130,7 @@ function analystIssuePageKey(address) {
|
|
|
32338
32130
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
32339
32131
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
32340
32132
|
}
|
|
32341
|
-
return
|
|
32133
|
+
return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
32342
32134
|
}
|
|
32343
32135
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32344
32136
|
return join39(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|