@akagilnc/pi-workflow-roles 0.1.5212 → 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 +580 -1031
- package/dist/engine-detour-usage.js +4 -16
- package/dist/headless-host/production-host.js +701 -1066
- package/dist/host-session-record.js +303 -0
- package/dist/migrate-book-topology.js +0 -1
- package/dist/pi/role-turn-host.js +1 -21
- package/dist/public-cli/main.js +153 -362
- package/dist/public-cli/post-admission.js +7 -43
- package/dist/sitian-appender.js +10 -146
- package/dist/ticket-provenance-contracts.js +4 -42
- package/dist/ticket-provenance.js +27 -456
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +36 -108
- package/src/diarist.ts +5 -5
- 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/src/ticket-provenance-contracts.ts +10 -48
- package/src/ticket-provenance.ts +33 -499
- 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,
|
|
@@ -19272,7 +19123,6 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
|
|
|
19272
19123
|
var init_ticket_provenance = __esm({
|
|
19273
19124
|
"src/ticket-provenance.ts"() {
|
|
19274
19125
|
"use strict";
|
|
19275
|
-
init_activation_ledger_git();
|
|
19276
19126
|
init_activation_ledger_topology();
|
|
19277
19127
|
init_ledger_session_read();
|
|
19278
19128
|
init_run_ticket_number();
|
|
@@ -20489,7 +20339,7 @@ var init_option_definitions = __esm({
|
|
|
20489
20339
|
|
|
20490
20340
|
// src/public-cli/invocation.ts
|
|
20491
20341
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
20492
|
-
import { existsSync as
|
|
20342
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
20493
20343
|
import {
|
|
20494
20344
|
lstat as lstat4,
|
|
20495
20345
|
mkdtemp,
|
|
@@ -20715,7 +20565,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
20715
20565
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
20716
20566
|
if (typeof childRunId !== "string") continue;
|
|
20717
20567
|
const childDirectory = join18(dirname12(oldRunDirectory), `${childRunId}@diarist`);
|
|
20718
|
-
if (!
|
|
20568
|
+
if (!existsSync4(childDirectory)) continue;
|
|
20719
20569
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
20720
20570
|
bookKey: admitted.bookKey,
|
|
20721
20571
|
subject: { ticketNumber: admitted.ticketNumber },
|
|
@@ -22177,7 +22027,7 @@ var init_invocation = __esm({
|
|
|
22177
22027
|
});
|
|
22178
22028
|
|
|
22179
22029
|
// src/public-cli/load-production-acp-host.ts
|
|
22180
|
-
import { existsSync as
|
|
22030
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
22181
22031
|
import { join as join19 } from "node:path";
|
|
22182
22032
|
import { pathToFileURL } from "node:url";
|
|
22183
22033
|
async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
@@ -22187,7 +22037,7 @@ async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
|
22187
22037
|
}
|
|
22188
22038
|
const built = join19(packageRoot2, "dist/acp-host/production-host.js");
|
|
22189
22039
|
const source = join19(packageRoot2, "src/acp-host/production-host.ts");
|
|
22190
|
-
const target =
|
|
22040
|
+
const target = existsSync5(built) ? built : source;
|
|
22191
22041
|
const href = pathToFileURL(target).href;
|
|
22192
22042
|
const mod = await import(href);
|
|
22193
22043
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -22201,7 +22051,7 @@ var init_load_production_acp_host = __esm({
|
|
|
22201
22051
|
});
|
|
22202
22052
|
|
|
22203
22053
|
// src/public-cli/load-production-headless-host.ts
|
|
22204
|
-
import { existsSync as
|
|
22054
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
22205
22055
|
import { join as join20 } from "node:path";
|
|
22206
22056
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
22207
22057
|
async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
@@ -22211,7 +22061,7 @@ async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
|
22211
22061
|
}
|
|
22212
22062
|
const built = join20(packageRoot2, "dist/headless-host/production-host.js");
|
|
22213
22063
|
const source = join20(packageRoot2, "src/headless-host/production-host.ts");
|
|
22214
|
-
const target =
|
|
22064
|
+
const target = existsSync6(built) ? built : source;
|
|
22215
22065
|
const href = pathToFileURL2(target).href;
|
|
22216
22066
|
const mod = await import(href);
|
|
22217
22067
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -22338,7 +22188,7 @@ var init_role_turn_host_resolution = __esm({
|
|
|
22338
22188
|
// src/analyst-gate-cycles-read.ts
|
|
22339
22189
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
22340
22190
|
import { join as join21 } from "node:path";
|
|
22341
|
-
function
|
|
22191
|
+
function isRecord5(value) {
|
|
22342
22192
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22343
22193
|
}
|
|
22344
22194
|
function isParentAttemptBindingRow(row) {
|
|
@@ -22368,7 +22218,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
22368
22218
|
function acceptedGateReceiptIds(rows) {
|
|
22369
22219
|
const accepted = /* @__PURE__ */ new Set();
|
|
22370
22220
|
for (const row of rows) {
|
|
22371
|
-
const message =
|
|
22221
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
22372
22222
|
if (message?.role !== "toolResult") continue;
|
|
22373
22223
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
22374
22224
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -22403,7 +22253,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
22403
22253
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
22404
22254
|
const row = rows[i];
|
|
22405
22255
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
22406
|
-
if (!
|
|
22256
|
+
if (!isRecord5(row.data) || !isRecord5(row.data.parent)) continue;
|
|
22407
22257
|
const id = row.data.parent.attemptEntryId;
|
|
22408
22258
|
const sessionFile = row.data.parent.sessionFile;
|
|
22409
22259
|
return {
|
|
@@ -22418,10 +22268,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22418
22268
|
const out = [];
|
|
22419
22269
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
22420
22270
|
const row = rows[rowIndex];
|
|
22421
|
-
const message =
|
|
22271
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
22422
22272
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
22423
22273
|
for (const part of message.content) {
|
|
22424
|
-
if (!
|
|
22274
|
+
if (!isRecord5(part) || part.type !== "toolCall") continue;
|
|
22425
22275
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
22426
22276
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
22427
22277
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -22429,7 +22279,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22429
22279
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
22430
22280
|
out.push({
|
|
22431
22281
|
toolName: part.name,
|
|
22432
|
-
args:
|
|
22282
|
+
args: isRecord5(part.arguments) ? part.arguments : void 0,
|
|
22433
22283
|
accepted: true,
|
|
22434
22284
|
rowIndex,
|
|
22435
22285
|
...binding
|
|
@@ -22562,7 +22412,7 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
22562
22412
|
{ cause: error }
|
|
22563
22413
|
);
|
|
22564
22414
|
}
|
|
22565
|
-
if (!
|
|
22415
|
+
if (!isRecord5(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
22566
22416
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
22567
22417
|
}
|
|
22568
22418
|
const sessionFile = raw.sessionFile;
|
|
@@ -22832,14 +22682,14 @@ var init_audit_escalation = __esm({
|
|
|
22832
22682
|
});
|
|
22833
22683
|
|
|
22834
22684
|
// src/session-opening-materials.ts
|
|
22835
|
-
import { existsSync as
|
|
22685
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
22836
22686
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
22837
22687
|
import { dirname as dirname13, join as join23 } from "node:path";
|
|
22838
22688
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
22839
22689
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
22840
22690
|
let dir = dirname13(fileURLToPath(moduleUrl));
|
|
22841
22691
|
for (let i = 0; i < 8; i += 1) {
|
|
22842
|
-
if (
|
|
22692
|
+
if (existsSync7(join23(dir, "package.json")) && existsSync7(join23(dir, "souls"))) {
|
|
22843
22693
|
return dir;
|
|
22844
22694
|
}
|
|
22845
22695
|
const parent = dirname13(dir);
|
|
@@ -23046,13 +22896,13 @@ var init_serialize_thrown_value = __esm({
|
|
|
23046
22896
|
|
|
23047
22897
|
// src/engine-detour-usage.ts
|
|
23048
22898
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
23049
|
-
import { readFileSync as
|
|
22899
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
23050
22900
|
import { dirname as dirname14, join as join25 } from "node:path";
|
|
23051
|
-
function
|
|
22901
|
+
function isRecord6(value) {
|
|
23052
22902
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23053
22903
|
}
|
|
23054
22904
|
function callFactFromSitianPayload(payload, pointer) {
|
|
23055
|
-
if (!
|
|
22905
|
+
if (!isRecord6(payload)) return void 0;
|
|
23056
22906
|
if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
|
|
23057
22907
|
if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
|
|
23058
22908
|
return void 0;
|
|
@@ -23069,11 +22919,11 @@ function callFactFromSitianPayload(payload, pointer) {
|
|
|
23069
22919
|
};
|
|
23070
22920
|
}
|
|
23071
22921
|
function invocationScopeIdOfRecord(record4) {
|
|
23072
|
-
if (
|
|
22922
|
+
if (isRecord6(record4.subject)) {
|
|
23073
22923
|
const fromSubject = record4.subject.invocationScopeId;
|
|
23074
22924
|
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
23075
22925
|
}
|
|
23076
|
-
if (
|
|
22926
|
+
if (isRecord6(record4.payload)) {
|
|
23077
22927
|
const fromPayload = record4.payload.invocationScopeId;
|
|
23078
22928
|
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
23079
22929
|
}
|
|
@@ -23089,7 +22939,7 @@ async function readEngineDetourToolUsage(input) {
|
|
|
23089
22939
|
...input.cwd === void 0 ? {} : { cwd: input.cwd }
|
|
23090
22940
|
});
|
|
23091
22941
|
const { records } = await readSitianRecords(recordFile);
|
|
23092
|
-
const
|
|
22942
|
+
const callsByToolCallId = /* @__PURE__ */ new Map();
|
|
23093
22943
|
for (const record4 of records) {
|
|
23094
22944
|
if (record4.kind !== ENGINE_DETOUR_CALL_KIND) continue;
|
|
23095
22945
|
const boundScope = invocationScopeIdOfRecord(record4);
|
|
@@ -23106,8 +22956,9 @@ async function readEngineDetourToolUsage(input) {
|
|
|
23106
22956
|
};
|
|
23107
22957
|
const fact = callFactFromSitianPayload(record4.payload, pointer);
|
|
23108
22958
|
if (fact === void 0) continue;
|
|
23109
|
-
|
|
22959
|
+
callsByToolCallId.set(fact.toolCallId, fact);
|
|
23110
22960
|
}
|
|
22961
|
+
const calls = Array.from(callsByToolCallId.values());
|
|
23111
22962
|
return { callCount: calls.length, calls };
|
|
23112
22963
|
}
|
|
23113
22964
|
function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
@@ -23131,9 +22982,9 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
23131
22982
|
function readInvocationRecord(runDirectory) {
|
|
23132
22983
|
try {
|
|
23133
22984
|
const raw = JSON.parse(
|
|
23134
|
-
|
|
22985
|
+
readFileSync2(join25(runDirectory, "invocation.json"), "utf8")
|
|
23135
22986
|
);
|
|
23136
|
-
return
|
|
22987
|
+
return isRecord6(raw) ? raw : void 0;
|
|
23137
22988
|
} catch (error) {
|
|
23138
22989
|
if (error?.code === "ENOENT") return void 0;
|
|
23139
22990
|
throw error;
|
|
@@ -23144,14 +22995,9 @@ async function readInvocationEngineMounted(runDirectory) {
|
|
|
23144
22995
|
if (raw === void 0) return false;
|
|
23145
22996
|
return typeof raw.engine === "string" && raw.engine.trim() !== "";
|
|
23146
22997
|
}
|
|
23147
|
-
function readInvocationSelectedHost(runDirectory) {
|
|
23148
|
-
const raw = readInvocationRecord(runDirectory);
|
|
23149
|
-
if (raw === void 0) return void 0;
|
|
23150
|
-
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host.trim() : void 0;
|
|
23151
|
-
}
|
|
23152
22998
|
function withEngineDetourToolUsageFact(outcome, usage) {
|
|
23153
22999
|
if (usage === void 0) return outcome;
|
|
23154
|
-
const prior =
|
|
23000
|
+
const prior = isRecord6(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
|
|
23155
23001
|
return {
|
|
23156
23002
|
...outcome,
|
|
23157
23003
|
decisiveFacts: {
|
|
@@ -23193,7 +23039,7 @@ var init_engine_detour_usage = __esm({
|
|
|
23193
23039
|
});
|
|
23194
23040
|
|
|
23195
23041
|
// src/dossier-resolution.ts
|
|
23196
|
-
import { existsSync as
|
|
23042
|
+
import { existsSync as existsSync8, statSync as statSync3 } from "node:fs";
|
|
23197
23043
|
import { resolve as resolve10 } from "node:path";
|
|
23198
23044
|
function isHostContext(value) {
|
|
23199
23045
|
return "sessionManager" in value;
|
|
@@ -23213,7 +23059,7 @@ function resolveAuditDossier(source) {
|
|
|
23213
23059
|
}
|
|
23214
23060
|
const runDirectory = resolve10(raw);
|
|
23215
23061
|
try {
|
|
23216
|
-
if (!
|
|
23062
|
+
if (!existsSync8(runDirectory) || !statSync3(runDirectory).isDirectory()) {
|
|
23217
23063
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
23218
23064
|
}
|
|
23219
23065
|
} catch {
|
|
@@ -23221,13 +23067,13 @@ function resolveAuditDossier(source) {
|
|
|
23221
23067
|
}
|
|
23222
23068
|
return { status: "ok", runDirectory };
|
|
23223
23069
|
}
|
|
23224
|
-
function
|
|
23070
|
+
function isRecord7(value) {
|
|
23225
23071
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23226
23072
|
}
|
|
23227
23073
|
function readDoctorAuditSubjects(context) {
|
|
23228
23074
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
23229
23075
|
for (const entry of entries) {
|
|
23230
|
-
if (
|
|
23076
|
+
if (isRecord7(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
23231
23077
|
return { status: "ok" };
|
|
23232
23078
|
}
|
|
23233
23079
|
}
|
|
@@ -23372,11 +23218,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
23372
23218
|
});
|
|
23373
23219
|
|
|
23374
23220
|
// src/receipt-delivery-policy.ts
|
|
23375
|
-
function
|
|
23221
|
+
function isRecord8(value) {
|
|
23376
23222
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23377
23223
|
}
|
|
23378
23224
|
function parseNoReceiptLifecycleFacts(input) {
|
|
23379
|
-
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")) {
|
|
23380
23226
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
23381
23227
|
}
|
|
23382
23228
|
return {
|
|
@@ -23951,7 +23797,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
23951
23797
|
const { records } = await readSitianRecords(recordFile);
|
|
23952
23798
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
23953
23799
|
const payload = records[i]?.payload;
|
|
23954
|
-
if (!
|
|
23800
|
+
if (!isRecord9(payload) || !isRecord9(payload.response)) continue;
|
|
23955
23801
|
if (typeof payload.type === "string") continue;
|
|
23956
23802
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
23957
23803
|
if (stop !== void 0) return stop;
|
|
@@ -24001,7 +23847,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24001
23847
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
24002
23848
|
}
|
|
24003
23849
|
const header = entries.find((entry) => entry.type === "session");
|
|
24004
|
-
if (!
|
|
23850
|
+
if (!isRecord9(header)) continue;
|
|
24005
23851
|
const bindingIndexes = [];
|
|
24006
23852
|
for (let i = 0; i < entries.length; i += 1) {
|
|
24007
23853
|
const entry = entries[i];
|
|
@@ -24015,7 +23861,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24015
23861
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
24016
23862
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
24017
23863
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
24018
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
23864
|
+
const bindingParent = bindingEntry !== void 0 && isRecord9(bindingEntry.data) && isRecord9(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
24019
23865
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
24020
23866
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
24021
23867
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -24039,12 +23885,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
24039
23885
|
if (stop === void 0) continue;
|
|
24040
23886
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
24041
23887
|
const entry = entries[i];
|
|
24042
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
24043
|
-
const parent =
|
|
24044
|
-
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;
|
|
24045
23891
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
24046
23892
|
if (failure === void 0) continue;
|
|
24047
|
-
const identity =
|
|
23893
|
+
const identity = isRecord9(failure.identity) ? failure.identity : void 0;
|
|
24048
23894
|
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
24049
23895
|
return {
|
|
24050
23896
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -24053,7 +23899,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
24053
23899
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
24054
23900
|
} },
|
|
24055
23901
|
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
24056
|
-
...
|
|
23902
|
+
...isRecord9(failure.details) ? { details: failure.details } : {}
|
|
24057
23903
|
};
|
|
24058
23904
|
}
|
|
24059
23905
|
}
|
|
@@ -24100,9 +23946,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
24100
23946
|
if (classification.kind !== "infrastructure") continue;
|
|
24101
23947
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
24102
23948
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
24103
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
24104
|
-
const diagnostic =
|
|
24105
|
-
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;
|
|
24106
23952
|
return {
|
|
24107
23953
|
cause: "activation",
|
|
24108
23954
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -24239,7 +24085,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
24239
24085
|
} : {}
|
|
24240
24086
|
};
|
|
24241
24087
|
}
|
|
24242
|
-
function
|
|
24088
|
+
function isRecord9(value) {
|
|
24243
24089
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24244
24090
|
}
|
|
24245
24091
|
function toolResultText(message) {
|
|
@@ -24264,7 +24110,7 @@ function extractCollectorTargetBindRejection(entries) {
|
|
|
24264
24110
|
const diagnostic = toolResultText(message);
|
|
24265
24111
|
if (diagnostic.length === 0) return void 0;
|
|
24266
24112
|
const details = message.details;
|
|
24267
|
-
const code =
|
|
24113
|
+
const code = isRecord9(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
24268
24114
|
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
24269
24115
|
}
|
|
24270
24116
|
return void 0;
|
|
@@ -24365,7 +24211,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
24365
24211
|
const candidateMessage = entries[index]?.message;
|
|
24366
24212
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
24367
24213
|
for (const part of candidateMessage.content) {
|
|
24368
|
-
if (!
|
|
24214
|
+
if (!isRecord9(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
24369
24215
|
continue;
|
|
24370
24216
|
}
|
|
24371
24217
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -24436,7 +24282,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
24436
24282
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
24437
24283
|
prose = details.prose;
|
|
24438
24284
|
} else {
|
|
24439
|
-
const next =
|
|
24285
|
+
const next = isRecord9(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
24440
24286
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
24441
24287
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
24442
24288
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -24545,7 +24391,7 @@ function detourGateContext(admitted, scope) {
|
|
|
24545
24391
|
}
|
|
24546
24392
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
24547
24393
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
24548
|
-
const skipGate =
|
|
24394
|
+
const skipGate = isRecord9(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
24549
24395
|
let next = base;
|
|
24550
24396
|
if (!skipGate) {
|
|
24551
24397
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -24558,7 +24404,7 @@ function routePlaybookFailureMessage(entries) {
|
|
|
24558
24404
|
const entry = entries[i];
|
|
24559
24405
|
if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
|
|
24560
24406
|
const data = entry.data;
|
|
24561
|
-
if (!
|
|
24407
|
+
if (!isRecord9(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
|
|
24562
24408
|
return data.message;
|
|
24563
24409
|
}
|
|
24564
24410
|
return void 0;
|
|
@@ -24605,7 +24451,7 @@ function extractNavigatorAttendanceFact(entries) {
|
|
|
24605
24451
|
const entry = entries[i];
|
|
24606
24452
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
24607
24453
|
const details = entry.message?.details ?? entry.details;
|
|
24608
|
-
if (!
|
|
24454
|
+
if (!isRecord9(details)) {
|
|
24609
24455
|
return {
|
|
24610
24456
|
disposition: "unavailable",
|
|
24611
24457
|
source: "unknown",
|
|
@@ -24756,7 +24602,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
24756
24602
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
24757
24603
|
if (residual === void 0) continue;
|
|
24758
24604
|
const candidate = residual.candidate;
|
|
24759
|
-
const details =
|
|
24605
|
+
const details = isRecord9(candidate) ? candidate : { candidate };
|
|
24760
24606
|
const failed = await settleFailureTerminalResult(
|
|
24761
24607
|
admitted,
|
|
24762
24608
|
{
|
|
@@ -24831,7 +24677,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
24831
24677
|
continue;
|
|
24832
24678
|
}
|
|
24833
24679
|
const data = entry.data;
|
|
24834
|
-
if (!
|
|
24680
|
+
if (!isRecord9(data)) return {};
|
|
24835
24681
|
return {
|
|
24836
24682
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
24837
24683
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -24916,7 +24762,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
24916
24762
|
let residual;
|
|
24917
24763
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
24918
24764
|
const entry = entries[index];
|
|
24919
|
-
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") {
|
|
24920
24766
|
thisAttemptHasSeatSuccess = true;
|
|
24921
24767
|
}
|
|
24922
24768
|
const message = entries[index]?.message;
|
|
@@ -24956,7 +24802,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
24956
24802
|
);
|
|
24957
24803
|
}
|
|
24958
24804
|
if (residual !== void 0) {
|
|
24959
|
-
const details =
|
|
24805
|
+
const details = isRecord9(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
24960
24806
|
const failed = await settleFailureTerminalResult(
|
|
24961
24807
|
admitted,
|
|
24962
24808
|
{
|
|
@@ -25006,7 +24852,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
25006
24852
|
return void 0;
|
|
25007
24853
|
}
|
|
25008
24854
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
25009
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
24855
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord9(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
25010
24856
|
return {
|
|
25011
24857
|
...roleOutcome,
|
|
25012
24858
|
decisiveFacts: {
|
|
@@ -25019,7 +24865,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
25019
24865
|
const payloads = roleOutcome.payloads ?? [];
|
|
25020
24866
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
25021
24867
|
const payload = payloads[index];
|
|
25022
|
-
if (!
|
|
24868
|
+
if (!isRecord9(payload)) continue;
|
|
25023
24869
|
const status = payload.secretariatStatus;
|
|
25024
24870
|
if (typeof status !== "string") continue;
|
|
25025
24871
|
return status === "converged";
|
|
@@ -25464,7 +25310,7 @@ var init_settlement = __esm({
|
|
|
25464
25310
|
});
|
|
25465
25311
|
|
|
25466
25312
|
// src/archivist-record-pointer.ts
|
|
25467
|
-
import { mkdirSync as mkdirSync3, writeFileSync
|
|
25313
|
+
import { mkdirSync as mkdirSync3, writeFileSync } from "node:fs";
|
|
25468
25314
|
import { dirname as dirname16, join as join27 } from "node:path";
|
|
25469
25315
|
function bookDirectOfficerRunPointer(options) {
|
|
25470
25316
|
const nest = join27(dirname16(options.parentSessionFile), "auditor-roles");
|
|
@@ -25476,7 +25322,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
25476
25322
|
sessionFile: options.sessionFile,
|
|
25477
25323
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
25478
25324
|
};
|
|
25479
|
-
|
|
25325
|
+
writeFileSync(
|
|
25480
25326
|
join27(nest, `${options.officer}.pointer.json`),
|
|
25481
25327
|
`${JSON.stringify(pointer)}
|
|
25482
25328
|
`,
|
|
@@ -25819,11 +25665,11 @@ var init_turn_request = __esm({
|
|
|
25819
25665
|
});
|
|
25820
25666
|
|
|
25821
25667
|
// src/public-cli/countersign-run.ts
|
|
25822
|
-
function
|
|
25668
|
+
function isRecord10(value) {
|
|
25823
25669
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25824
25670
|
}
|
|
25825
25671
|
function isEscalatePayload(payload) {
|
|
25826
|
-
if (!
|
|
25672
|
+
if (!isRecord10(payload)) return false;
|
|
25827
25673
|
return payload.status === "escalate";
|
|
25828
25674
|
}
|
|
25829
25675
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -27047,7 +26893,7 @@ __export(public_role_summons_exports, {
|
|
|
27047
26893
|
summonPublicRole: () => summonPublicRole
|
|
27048
26894
|
});
|
|
27049
26895
|
import { execFile as execFile3 } from "node:child_process";
|
|
27050
|
-
import { existsSync as
|
|
26896
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
27051
26897
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
27052
26898
|
import { join as join28 } from "node:path";
|
|
27053
26899
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -27073,7 +26919,7 @@ function parentDir(path) {
|
|
|
27073
26919
|
function walkPackageRoot(start) {
|
|
27074
26920
|
let dir = start;
|
|
27075
26921
|
for (let i = 0; i < 12; i += 1) {
|
|
27076
|
-
if (
|
|
26922
|
+
if (existsSync9(join28(dir, "package.json")) && existsSync9(join28(dir, "souls"))) {
|
|
27077
26923
|
return dir;
|
|
27078
26924
|
}
|
|
27079
26925
|
const parent = parentDir(dir);
|
|
@@ -27898,7 +27744,7 @@ async function readRoleRunStateRaw(runDirectory) {
|
|
|
27898
27744
|
try {
|
|
27899
27745
|
raw = JSON.parse(await readFile16(join30(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
27900
27746
|
} catch (error) {
|
|
27901
|
-
if (
|
|
27747
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
27902
27748
|
throw error;
|
|
27903
27749
|
}
|
|
27904
27750
|
return raw;
|
|
@@ -28143,7 +27989,7 @@ function describeErrorIdentity(error) {
|
|
|
28143
27989
|
const message = typeof candidate?.message === "string" && candidate.message !== "" ? `: ${candidate.message}` : "";
|
|
28144
27990
|
return `${name}${code}${message}`;
|
|
28145
27991
|
}
|
|
28146
|
-
function
|
|
27992
|
+
function errorCodeOf(error) {
|
|
28147
27993
|
return error.code;
|
|
28148
27994
|
}
|
|
28149
27995
|
function isProcessAlive(pid) {
|
|
@@ -28151,7 +27997,7 @@ function isProcessAlive(pid) {
|
|
|
28151
27997
|
process.kill(pid, 0);
|
|
28152
27998
|
return true;
|
|
28153
27999
|
} catch (error) {
|
|
28154
|
-
return
|
|
28000
|
+
return errorCodeOf(error) !== "ESRCH";
|
|
28155
28001
|
}
|
|
28156
28002
|
}
|
|
28157
28003
|
async function autopsyWriterLock(lockPath) {
|
|
@@ -28159,7 +28005,7 @@ async function autopsyWriterLock(lockPath) {
|
|
|
28159
28005
|
try {
|
|
28160
28006
|
content = await readFile16(lockPath, "utf8");
|
|
28161
28007
|
} catch (error) {
|
|
28162
|
-
if (
|
|
28008
|
+
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
28163
28009
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
28164
28010
|
}
|
|
28165
28011
|
const normalized = content.trim();
|
|
@@ -28191,8 +28037,8 @@ async function reclaimStaleWriterLock(lockPath, runDirectory) {
|
|
|
28191
28037
|
await unlink4(lockPath);
|
|
28192
28038
|
return { reclaimed: true };
|
|
28193
28039
|
} catch (error) {
|
|
28194
|
-
if (
|
|
28195
|
-
if (
|
|
28040
|
+
if (errorCodeOf(error) === "ENOENT") return { reclaimed: false };
|
|
28041
|
+
if (errorCodeOf(error) !== "EACCES") throw error;
|
|
28196
28042
|
await chmod(runDirectory, 493);
|
|
28197
28043
|
return { reclaimed: false, eaccesFailure: error };
|
|
28198
28044
|
}
|
|
@@ -28225,7 +28071,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
28225
28071
|
try {
|
|
28226
28072
|
await unlink4(currentLockPath);
|
|
28227
28073
|
} catch (error) {
|
|
28228
|
-
if (
|
|
28074
|
+
if (errorCodeOf(error) === "EACCES") {
|
|
28229
28075
|
try {
|
|
28230
28076
|
await chmod(currentRunDirectory, 493);
|
|
28231
28077
|
await unlink4(currentLockPath);
|
|
@@ -28265,7 +28111,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
28265
28111
|
try {
|
|
28266
28112
|
return await createWriterLease(lockPath, runDirectory, reportCleanupFailure);
|
|
28267
28113
|
} catch (error) {
|
|
28268
|
-
if (
|
|
28114
|
+
if (errorCodeOf(error) !== "EEXIST") throw error;
|
|
28269
28115
|
}
|
|
28270
28116
|
lastAutopsy = await autopsyWriterLock(lockPath);
|
|
28271
28117
|
if (lastAutopsy.verdict === "unknown" && lastAutopsy.reason === "unreadable") {
|
|
@@ -28318,7 +28164,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
28318
28164
|
try {
|
|
28319
28165
|
bookKeys = await readdir6(booksRoot);
|
|
28320
28166
|
} catch (error) {
|
|
28321
|
-
if (
|
|
28167
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
28322
28168
|
throw error;
|
|
28323
28169
|
}
|
|
28324
28170
|
const matches = [];
|
|
@@ -28329,7 +28175,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
28329
28175
|
try {
|
|
28330
28176
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
28331
28177
|
} catch (error) {
|
|
28332
|
-
if (
|
|
28178
|
+
if (errorCodeOf(error) === "ENOENT") continue;
|
|
28333
28179
|
throw error;
|
|
28334
28180
|
}
|
|
28335
28181
|
for (const runDirectory of runDirectories) {
|
|
@@ -28357,7 +28203,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
28357
28203
|
await readFile16(join30(runDirectory, "admitted-request.json"), "utf8")
|
|
28358
28204
|
);
|
|
28359
28205
|
} catch (error) {
|
|
28360
|
-
if (
|
|
28206
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
28361
28207
|
throw error;
|
|
28362
28208
|
}
|
|
28363
28209
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
@@ -28380,7 +28226,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
28380
28226
|
const stat2 = await lstat6(sessionFile);
|
|
28381
28227
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
28382
28228
|
} catch (error) {
|
|
28383
|
-
if (
|
|
28229
|
+
if (errorCodeOf(error) === "ENOENT") return false;
|
|
28384
28230
|
throw error;
|
|
28385
28231
|
}
|
|
28386
28232
|
}
|
|
@@ -28396,7 +28242,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
28396
28242
|
input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
|
|
28397
28243
|
);
|
|
28398
28244
|
} catch (error) {
|
|
28399
|
-
if (
|
|
28245
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
28400
28246
|
throw error;
|
|
28401
28247
|
}
|
|
28402
28248
|
const suffix = `@${input.role}`;
|
|
@@ -29139,63 +28985,6 @@ var init_case_dossier_delivery = __esm({
|
|
|
29139
28985
|
}
|
|
29140
28986
|
});
|
|
29141
28987
|
|
|
29142
|
-
// src/host-transition-prior-native.ts
|
|
29143
|
-
import { access as access3, readdir as readdir7 } from "node:fs/promises";
|
|
29144
|
-
import { dirname as dirname19, join as join33 } from "node:path";
|
|
29145
|
-
function isEnoent2(error) {
|
|
29146
|
-
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
29147
|
-
}
|
|
29148
|
-
async function listPiNativeRecordPaths(sessionFile) {
|
|
29149
|
-
try {
|
|
29150
|
-
await access3(sessionFile);
|
|
29151
|
-
return [sessionFile];
|
|
29152
|
-
} catch (error) {
|
|
29153
|
-
if (isEnoent2(error)) return [];
|
|
29154
|
-
throw error;
|
|
29155
|
-
}
|
|
29156
|
-
}
|
|
29157
|
-
async function listSitianRecordPaths(sessionParent) {
|
|
29158
|
-
const sessionRoot = dirname19(sessionParent);
|
|
29159
|
-
let entries;
|
|
29160
|
-
try {
|
|
29161
|
-
entries = await readdir7(sessionRoot, { withFileTypes: true });
|
|
29162
|
-
} catch (error) {
|
|
29163
|
-
if (isEnoent2(error)) return [];
|
|
29164
|
-
throw error;
|
|
29165
|
-
}
|
|
29166
|
-
const recordPaths = [];
|
|
29167
|
-
for (const entry of entries) {
|
|
29168
|
-
if (!entry.isDirectory()) continue;
|
|
29169
|
-
const recordFile = join33(sessionRoot, entry.name, "records.jsonl");
|
|
29170
|
-
try {
|
|
29171
|
-
await access3(recordFile);
|
|
29172
|
-
recordPaths.push(recordFile);
|
|
29173
|
-
} catch (error) {
|
|
29174
|
-
if (!isEnoent2(error)) throw error;
|
|
29175
|
-
}
|
|
29176
|
-
}
|
|
29177
|
-
recordPaths.sort();
|
|
29178
|
-
return recordPaths;
|
|
29179
|
-
}
|
|
29180
|
-
async function projectHostTransitionPriorNative(input) {
|
|
29181
|
-
if (input.previousHost === input.liveHost) return void 0;
|
|
29182
|
-
if (input.previousHost === "pi") {
|
|
29183
|
-
return {
|
|
29184
|
-
priorNativeKind: "pi-native",
|
|
29185
|
-
priorNativePaths: await listPiNativeRecordPaths(input.piSessionFile)
|
|
29186
|
-
};
|
|
29187
|
-
}
|
|
29188
|
-
return {
|
|
29189
|
-
priorNativeKind: "sitian",
|
|
29190
|
-
priorNativePaths: await listSitianRecordPaths(input.piSessionFile)
|
|
29191
|
-
};
|
|
29192
|
-
}
|
|
29193
|
-
var init_host_transition_prior_native = __esm({
|
|
29194
|
-
"src/host-transition-prior-native.ts"() {
|
|
29195
|
-
"use strict";
|
|
29196
|
-
}
|
|
29197
|
-
});
|
|
29198
|
-
|
|
29199
28988
|
// src/public-cli/process-cancel.ts
|
|
29200
28989
|
var process_cancel_exports = {};
|
|
29201
28990
|
__export(process_cancel_exports, {
|
|
@@ -29249,6 +29038,39 @@ var init_process_cancel = __esm({
|
|
|
29249
29038
|
}
|
|
29250
29039
|
});
|
|
29251
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
|
+
|
|
29252
29074
|
// src/public-cli/auto-resume.ts
|
|
29253
29075
|
import { constants as fsConstants2 } from "node:fs";
|
|
29254
29076
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
@@ -29911,35 +29733,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29911
29733
|
}
|
|
29912
29734
|
};
|
|
29913
29735
|
try {
|
|
29914
|
-
let previousHost;
|
|
29915
|
-
const liveHost = env.host;
|
|
29916
|
-
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
29917
|
-
let hostTransition;
|
|
29918
|
-
try {
|
|
29919
|
-
previousHost = readInvocationSelectedHost(admitted.runDirectory);
|
|
29920
|
-
hostTransition = previousHost !== void 0 && liveHost !== void 0 && principalCoordinates !== void 0 ? await projectHostTransitionPriorNative({
|
|
29921
|
-
previousHost,
|
|
29922
|
-
liveHost,
|
|
29923
|
-
piSessionFile: principalCoordinates.sessionFile
|
|
29924
|
-
}) : void 0;
|
|
29925
|
-
} catch (error) {
|
|
29926
|
-
return {
|
|
29927
|
-
...await presentControlledFailure2(
|
|
29928
|
-
admitted,
|
|
29929
|
-
withEngineDetourInvocationScope({
|
|
29930
|
-
timedOut: false,
|
|
29931
|
-
code: null,
|
|
29932
|
-
stderr: "",
|
|
29933
|
-
thrown: error
|
|
29934
|
-
}, request.invocationScopeId),
|
|
29935
|
-
adapters,
|
|
29936
|
-
env.principalAuthority,
|
|
29937
|
-
io,
|
|
29938
|
-
persistRunState
|
|
29939
|
-
),
|
|
29940
|
-
...deferredPersist
|
|
29941
|
-
};
|
|
29942
|
-
}
|
|
29943
29736
|
await clearTypedProviderHttpObservation(admitted.runDirectory);
|
|
29944
29737
|
if (adapters.beforeDispatch !== void 0) {
|
|
29945
29738
|
try {
|
|
@@ -29975,11 +29768,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29975
29768
|
if (env.stationChild !== void 0) {
|
|
29976
29769
|
turnRequest = { ...turnRequest, stationChild: env.stationChild };
|
|
29977
29770
|
}
|
|
29978
|
-
if (
|
|
29979
|
-
turnRequest = { ...turnRequest,
|
|
29980
|
-
}
|
|
29981
|
-
if (typeof liveHost === "string" && liveHost.trim() !== "") {
|
|
29982
|
-
turnRequest = { ...turnRequest, host: liveHost.trim() };
|
|
29771
|
+
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
29772
|
+
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
29983
29773
|
}
|
|
29984
29774
|
await deliverCaseDossierAsAttachment({
|
|
29985
29775
|
ticketNumber: admitted.ticketNumber,
|
|
@@ -29996,6 +29786,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29996
29786
|
);
|
|
29997
29787
|
let result;
|
|
29998
29788
|
try {
|
|
29789
|
+
recordRunStart(admitted.runDirectory);
|
|
29999
29790
|
result = await env.roleTurnHost.executeTurn(turnRequest);
|
|
30000
29791
|
} catch (error) {
|
|
30001
29792
|
const processCancelName = processCancelSignalName(env.signal);
|
|
@@ -30695,10 +30486,10 @@ var init_post_admission = __esm({
|
|
|
30695
30486
|
init_packaged_role_registry();
|
|
30696
30487
|
init_case_dossier_delivery();
|
|
30697
30488
|
init_engine_detour_usage();
|
|
30698
|
-
init_host_transition_prior_native();
|
|
30699
30489
|
init_run_lifecycle();
|
|
30700
30490
|
init_process_cancel();
|
|
30701
30491
|
init_activation_ledger_topology();
|
|
30492
|
+
init_host_session_record();
|
|
30702
30493
|
init_settlement();
|
|
30703
30494
|
init_terminal();
|
|
30704
30495
|
init_auto_resume();
|
|
@@ -30710,13 +30501,13 @@ var init_post_admission = __esm({
|
|
|
30710
30501
|
});
|
|
30711
30502
|
|
|
30712
30503
|
// src/analyst-book-key.ts
|
|
30713
|
-
import { statSync as
|
|
30504
|
+
import { statSync as statSync5 } from "node:fs";
|
|
30714
30505
|
import { isAbsolute as isAbsolute9 } from "node:path";
|
|
30715
30506
|
function resolveAnalystBookKey(projectRoot) {
|
|
30716
30507
|
const identity = physicalPathIdentity(projectRoot);
|
|
30717
30508
|
let stats;
|
|
30718
30509
|
try {
|
|
30719
|
-
stats =
|
|
30510
|
+
stats = statSync5(identity);
|
|
30720
30511
|
} catch (error) {
|
|
30721
30512
|
const code = errnoCode(error);
|
|
30722
30513
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -31097,7 +30888,7 @@ var init_analyst_cohort = __esm({
|
|
|
31097
30888
|
});
|
|
31098
30889
|
|
|
31099
30890
|
// src/analyst-ledger.ts
|
|
31100
|
-
import { readdir as
|
|
30891
|
+
import { readdir as readdir7, readFile as readFile20 } from "node:fs/promises";
|
|
31101
30892
|
import { basename as basename9, join as join38 } from "node:path";
|
|
31102
30893
|
function isMissingPathError6(error) {
|
|
31103
30894
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -31105,7 +30896,7 @@ function isMissingPathError6(error) {
|
|
|
31105
30896
|
function errorText3(error) {
|
|
31106
30897
|
return error instanceof Error ? error.message : String(error);
|
|
31107
30898
|
}
|
|
31108
|
-
function
|
|
30899
|
+
function isRecord11(value) {
|
|
31109
30900
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31110
30901
|
}
|
|
31111
30902
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -31146,7 +30937,7 @@ function parseRunDirectoryName2(name) {
|
|
|
31146
30937
|
}
|
|
31147
30938
|
async function listLedgerBookNames(booksRoot) {
|
|
31148
30939
|
try {
|
|
31149
|
-
const entries = await
|
|
30940
|
+
const entries = await readdir7(booksRoot, { withFileTypes: true });
|
|
31150
30941
|
return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
31151
30942
|
} catch (error) {
|
|
31152
30943
|
if (isMissingPathError6(error)) return [];
|
|
@@ -31162,7 +30953,7 @@ async function readInvocationScopeFields(runDirectory) {
|
|
|
31162
30953
|
throw error;
|
|
31163
30954
|
}
|
|
31164
30955
|
const parsed = JSON.parse(raw);
|
|
31165
|
-
if (!
|
|
30956
|
+
if (!isRecord11(parsed)) return void 0;
|
|
31166
30957
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
31167
30958
|
return void 0;
|
|
31168
30959
|
}
|
|
@@ -31191,7 +30982,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
31191
30982
|
try {
|
|
31192
30983
|
const raw = await readFile20(join38(runDirectory, "invocation.json"), "utf8");
|
|
31193
30984
|
const parsed = JSON.parse(raw);
|
|
31194
|
-
if (
|
|
30985
|
+
if (isRecord11(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
31195
30986
|
return parsed.sessionFile;
|
|
31196
30987
|
}
|
|
31197
30988
|
} catch (error) {
|
|
@@ -31529,7 +31320,7 @@ var init_analyst_ledger = __esm({
|
|
|
31529
31320
|
});
|
|
31530
31321
|
|
|
31531
31322
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
31532
|
-
function
|
|
31323
|
+
function isRecord12(value) {
|
|
31533
31324
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31534
31325
|
}
|
|
31535
31326
|
function wallMsFromSpan(span) {
|
|
@@ -31538,21 +31329,21 @@ function wallMsFromSpan(span) {
|
|
|
31538
31329
|
function findCollectorGroups(body) {
|
|
31539
31330
|
if (Array.isArray(body.groups)) return body.groups;
|
|
31540
31331
|
const receipt = body.receipt;
|
|
31541
|
-
if (
|
|
31332
|
+
if (isRecord12(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
31542
31333
|
const outcome = body.outcome;
|
|
31543
|
-
if (
|
|
31334
|
+
if (isRecord12(outcome)) {
|
|
31544
31335
|
const facts = outcome.decisiveFacts;
|
|
31545
|
-
if (
|
|
31336
|
+
if (isRecord12(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
31546
31337
|
}
|
|
31547
31338
|
return void 0;
|
|
31548
31339
|
}
|
|
31549
31340
|
function extractStatus(body) {
|
|
31550
31341
|
const outcome = body.outcome;
|
|
31551
|
-
if (
|
|
31342
|
+
if (isRecord12(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
31552
31343
|
return outcome.status;
|
|
31553
31344
|
}
|
|
31554
31345
|
const receipt = body.receipt;
|
|
31555
|
-
if (
|
|
31346
|
+
if (isRecord12(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
31556
31347
|
return receipt.status;
|
|
31557
31348
|
}
|
|
31558
31349
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -32178,15 +31969,15 @@ var init_leg_wall_clock = __esm({
|
|
|
32178
31969
|
});
|
|
32179
31970
|
|
|
32180
31971
|
// src/analyst-metric-families/round-timeline.ts
|
|
32181
|
-
function
|
|
31972
|
+
function isRecord13(value) {
|
|
32182
31973
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32183
31974
|
}
|
|
32184
31975
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
32185
31976
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
32186
31977
|
}
|
|
32187
31978
|
function readClassCount(body) {
|
|
32188
|
-
if (!
|
|
32189
|
-
if (!
|
|
31979
|
+
if (!isRecord13(body.outcome)) return void 0;
|
|
31980
|
+
if (!isRecord13(body.outcome.decisiveFacts)) return void 0;
|
|
32190
31981
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
32191
31982
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
32192
31983
|
return void 0;
|
|
@@ -32330,7 +32121,7 @@ var init_analyst_metric_family = __esm({
|
|
|
32330
32121
|
});
|
|
32331
32122
|
|
|
32332
32123
|
// src/analyst-page.ts
|
|
32333
|
-
import { createHash as
|
|
32124
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
32334
32125
|
import { dirname as dirname22, join as join39 } from "node:path";
|
|
32335
32126
|
function analystIssuePageKey(address) {
|
|
32336
32127
|
const parts = ["book", address.bookKey];
|
|
@@ -32339,7 +32130,7 @@ function analystIssuePageKey(address) {
|
|
|
32339
32130
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
32340
32131
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
32341
32132
|
}
|
|
32342
|
-
return
|
|
32133
|
+
return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
32343
32134
|
}
|
|
32344
32135
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32345
32136
|
return join39(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|