@akagilnc/pi-workflow-roles 0.1.4021 → 0.1.4062
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +682 -355
- package/dist/doctor-auditor.js +1 -1
- package/dist/dossier-resolution.js +21 -8
- package/dist/gatekeeper-role.js +34 -27
- package/dist/headless-host/description.js +7 -8
- package/dist/headless-host/production-host.js +709 -369
- package/dist/host-contracts.js +16 -0
- package/dist/inspector-contracts.js +8 -0
- package/dist/navigator-attendance.js +2 -0
- package/dist/navigator-public-session.js +18 -34
- package/dist/navigator-session-contracts.js +19 -0
- package/dist/packaged-role-registry.js +1 -1
- package/dist/pi/known-failure.js +3 -4
- package/dist/pi/role-turn-host.js +43 -13
- package/dist/public-cli/auto-resume.js +20 -7
- package/dist/public-cli/case-dossier-delivery.js +60 -1
- package/dist/public-cli/diarist-run.js +9 -23
- package/dist/public-cli/inspector-run.js +17 -3
- package/dist/public-cli/instruction-seat-run.js +12 -7
- package/dist/public-cli/judge-run.js +3 -1
- package/dist/public-cli/main.js +440 -222
- package/dist/public-cli/notary-run.js +7 -4
- package/dist/public-cli/post-admission.js +66 -59
- package/dist/public-cli/run-lifecycle.js +3 -0
- package/dist/public-cli/settlement.js +78 -58
- package/dist/public-cli/terminal.js +1 -11
- package/dist/public-role-summons.js +8 -0
- package/dist/submission-ledger.js +139 -19
- package/dist/user-dialogue-stdin.js +33 -0
- package/extensions/role-runtime.ts +1 -0
- package/package.json +1 -1
- package/resources/836-deleted-machine-instruction-inventory.md +1 -1
- package/src/doctor-auditor.ts +1 -1
- package/src/dossier-resolution.ts +26 -8
- package/src/external-host-turn-loop.ts +9 -0
- package/src/gatekeeper-pass-envelope.ts +6 -0
- package/src/gatekeeper-role.ts +47 -28
- package/src/headless-host/description.ts +8 -11
- package/src/headless-host/role-turn-host.ts +20 -5
- package/src/host-contracts.ts +30 -7
- package/src/inspector-contracts.ts +7 -0
- package/src/judge-role.ts +4 -0
- package/src/navigator-attendance.ts +2 -0
- package/src/navigator-public-session.ts +19 -55
- package/src/navigator-session-contracts.ts +39 -0
- package/src/navigator-work-context.ts +3 -4
- package/src/notary-role.ts +1 -0
- package/src/packaged-role-registry.ts +1 -1
- package/src/pi/adapter.ts +19 -4
- package/src/pi/known-failure.ts +3 -4
- package/src/pi/role-turn-host.ts +48 -14
- package/src/public-cli/auto-resume.ts +57 -20
- package/src/public-cli/case-dossier-delivery.ts +86 -1
- package/src/public-cli/cli.ts +2 -2
- package/src/public-cli/collector-run.ts +3 -1
- package/src/public-cli/countersign-run.ts +34 -27
- package/src/public-cli/diarist-run.ts +10 -27
- package/src/public-cli/inspector-run.ts +26 -2
- package/src/public-cli/instruction-seat-run.ts +20 -10
- package/src/public-cli/invocation.ts +2 -0
- package/src/public-cli/judge-run.ts +3 -1
- package/src/public-cli/notary-run.ts +13 -4
- package/src/public-cli/post-admission.ts +74 -65
- package/src/public-cli/reviewer-run.ts +3 -1
- package/src/public-cli/run-lifecycle.ts +3 -0
- package/src/public-cli/settlement.ts +105 -80
- package/src/public-cli/terminal.ts +7 -16
- package/src/public-role-summons.ts +31 -7
- package/src/role-envelope.ts +9 -30
- package/src/role-runtime-dependencies.ts +1 -0
- package/src/role-runtime.ts +95 -19
- package/src/submission-ledger.ts +195 -26
- package/src/user-dialogue-stdin.ts +37 -0
- package/src/worker-role.ts +4 -0
package/dist/public-cli/main.js
CHANGED
|
@@ -14892,7 +14892,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14892
14892
|
role: "inspector",
|
|
14893
14893
|
phases: [null],
|
|
14894
14894
|
outputTool: INSPECTOR_OUTPUT_TOOL_NAME,
|
|
14895
|
-
inputFlag:
|
|
14895
|
+
inputFlag: "ak-inspector-source-run",
|
|
14896
14896
|
phaseFlag: void 0,
|
|
14897
14897
|
activationStage: "load-and-install",
|
|
14898
14898
|
sessionMaterials: INSPECTOR_SESSION_MATERIALS
|
|
@@ -15926,6 +15926,9 @@ var init_cli_errors = __esm({
|
|
|
15926
15926
|
});
|
|
15927
15927
|
|
|
15928
15928
|
// src/host-contracts.ts
|
|
15929
|
+
function isOfficerReviewSeat(role) {
|
|
15930
|
+
return role === "notary" || role === "inspector" || role === "auditor";
|
|
15931
|
+
}
|
|
15929
15932
|
var ExplicitInternalActivationError;
|
|
15930
15933
|
var init_host_contracts = __esm({
|
|
15931
15934
|
"src/host-contracts.ts"() {
|
|
@@ -15963,12 +15966,13 @@ function applyEngineChildEnv(childEnv, engine) {
|
|
|
15963
15966
|
childEnv[AK_ROLE_ENGINE_ENV] = void 0;
|
|
15964
15967
|
}
|
|
15965
15968
|
}
|
|
15966
|
-
var ENGINE_DETOUR_TOOL_NAME, AK_ROLE_ENGINE_ENV;
|
|
15969
|
+
var ENGINE_DETOUR_TOOL_NAME, AK_ROLE_ENGINE_ENV, ENGINE_MODEL_FLAG_NAME;
|
|
15967
15970
|
var init_engine_detour = __esm({
|
|
15968
15971
|
"src/engine-detour.ts"() {
|
|
15969
15972
|
"use strict";
|
|
15970
15973
|
ENGINE_DETOUR_TOOL_NAME = "ak_engine_detour";
|
|
15971
15974
|
AK_ROLE_ENGINE_ENV = "AK_ROLE_ENGINE";
|
|
15975
|
+
ENGINE_MODEL_FLAG_NAME = "ak-engine-model";
|
|
15972
15976
|
}
|
|
15973
15977
|
});
|
|
15974
15978
|
|
|
@@ -16019,6 +16023,18 @@ var init_role_activation_flags = __esm({
|
|
|
16019
16023
|
}
|
|
16020
16024
|
});
|
|
16021
16025
|
|
|
16026
|
+
// src/user-dialogue-stdin.ts
|
|
16027
|
+
function encodeUserDialogueStdin(body) {
|
|
16028
|
+
return JSON.stringify({ kind: USER_DIALOGUE_STDIN_KIND, body });
|
|
16029
|
+
}
|
|
16030
|
+
var USER_DIALOGUE_STDIN_KIND;
|
|
16031
|
+
var init_user_dialogue_stdin = __esm({
|
|
16032
|
+
"src/user-dialogue-stdin.ts"() {
|
|
16033
|
+
"use strict";
|
|
16034
|
+
USER_DIALOGUE_STDIN_KIND = "ak-user-dialogue";
|
|
16035
|
+
}
|
|
16036
|
+
});
|
|
16037
|
+
|
|
16022
16038
|
// src/sitian-contracts.ts
|
|
16023
16039
|
function attachDirectErrnoCode(error, cause) {
|
|
16024
16040
|
if (cause === null || typeof cause !== "object" || !("code" in cause)) return;
|
|
@@ -16392,11 +16408,6 @@ function applyPiNativeSkillInvocation(methods, prompt) {
|
|
|
16392
16408
|
}
|
|
16393
16409
|
function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
16394
16410
|
const { sessionFile, sessionDirectory } = authority.decode(request.principal);
|
|
16395
|
-
const rawPrompt = request.continuation.kind === "initial" || request.continuation.kind === "resume" ? request.continuation.prompt : (() => {
|
|
16396
|
-
const _exhaustive = request.continuation;
|
|
16397
|
-
return _exhaustive;
|
|
16398
|
-
})();
|
|
16399
|
-
const prompt = applyPiNativeSkillInvocation(request.methods, rawPrompt);
|
|
16400
16411
|
return [
|
|
16401
16412
|
"--no-skills",
|
|
16402
16413
|
...buildMethodArgs(request.methods),
|
|
@@ -16410,12 +16421,24 @@ function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
|
16410
16421
|
...extraPiArgs,
|
|
16411
16422
|
// Envelope assembly = projectActivationFlags; pi only renders argv pairs.
|
|
16412
16423
|
...activationFlagsToPiArgv(projectActivationFlags(request)),
|
|
16424
|
+
...piEngineModelArgs(request),
|
|
16413
16425
|
"--mode",
|
|
16414
16426
|
"json",
|
|
16415
|
-
...buildSeatModelCliArgs2(request.model)
|
|
16416
|
-
prompt
|
|
16427
|
+
...buildSeatModelCliArgs2(request.model)
|
|
16417
16428
|
];
|
|
16418
16429
|
}
|
|
16430
|
+
function piEngineModelArgs(request) {
|
|
16431
|
+
const model = normalizeEngineName(request.engineModel);
|
|
16432
|
+
if (model === void 0) return [];
|
|
16433
|
+
return [`--${ENGINE_MODEL_FLAG_NAME}`, model];
|
|
16434
|
+
}
|
|
16435
|
+
function piUserDialogueBody(request) {
|
|
16436
|
+
const rawPrompt = request.continuation.kind === "initial" || request.continuation.kind === "resume" ? request.continuation.prompt : (() => {
|
|
16437
|
+
const _exhaustive = request.continuation;
|
|
16438
|
+
return _exhaustive;
|
|
16439
|
+
})();
|
|
16440
|
+
return applyPiNativeSkillInvocation(request.methods, rawPrompt);
|
|
16441
|
+
}
|
|
16419
16442
|
async function resolveSelectedPi(command, cwd, env) {
|
|
16420
16443
|
const searchPath = env.PATH ?? (platform === "win32" ? process.env.PATH ?? "" : "/usr/bin:/bin");
|
|
16421
16444
|
const candidates = isAbsolute3(command) || command.includes("/") ? [resolve4(cwd, command)] : searchPath.split(delimiter2).map((dir) => resolve4(cwd, dir, command));
|
|
@@ -16455,11 +16478,22 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
16455
16478
|
const child = spawn(piIdentity.executable, [...args], {
|
|
16456
16479
|
cwd: spawnOptions.cwd,
|
|
16457
16480
|
env: spawnOptions.env,
|
|
16458
|
-
stdio: ["
|
|
16481
|
+
stdio: ["pipe", "ignore", "pipe"]
|
|
16459
16482
|
});
|
|
16483
|
+
if (child.stdin === null) {
|
|
16484
|
+
throw new Error("Pi child stdin pipe was not created");
|
|
16485
|
+
}
|
|
16460
16486
|
if (child.stderr === null) {
|
|
16461
16487
|
throw new Error("Pi child stderr pipe was not created");
|
|
16462
16488
|
}
|
|
16489
|
+
let stdinDeliveryError;
|
|
16490
|
+
child.stdin.on("error", (error) => {
|
|
16491
|
+
stdinDeliveryError ??= error;
|
|
16492
|
+
});
|
|
16493
|
+
if (spawnOptions.stdin !== void 0) {
|
|
16494
|
+
child.stdin.write(spawnOptions.stdin);
|
|
16495
|
+
}
|
|
16496
|
+
child.stdin.end();
|
|
16463
16497
|
let stderr = "";
|
|
16464
16498
|
let timedOut = false;
|
|
16465
16499
|
let timer;
|
|
@@ -16512,6 +16546,10 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
16512
16546
|
reject(executionError);
|
|
16513
16547
|
return;
|
|
16514
16548
|
}
|
|
16549
|
+
if (stdinDeliveryError !== void 0) {
|
|
16550
|
+
reject(stdinDeliveryError);
|
|
16551
|
+
return;
|
|
16552
|
+
}
|
|
16515
16553
|
resolveResult({
|
|
16516
16554
|
code,
|
|
16517
16555
|
stderr,
|
|
@@ -16535,7 +16573,8 @@ function createPiRoleTurnHost(config) {
|
|
|
16535
16573
|
return {
|
|
16536
16574
|
async executeTurn(request) {
|
|
16537
16575
|
let turnRequest = request;
|
|
16538
|
-
const
|
|
16576
|
+
const officerStationChild = request.stationChild === true && isOfficerReviewSeat(request.activation.role);
|
|
16577
|
+
const paths = !officerStationChild && request.hostTransition?.priorNativeKind === "sitian" ? request.hostTransition.priorNativePaths : void 0;
|
|
16539
16578
|
if (request.continuation.kind === "resume" && paths !== void 0 && paths.length > 0) {
|
|
16540
16579
|
turnRequest = {
|
|
16541
16580
|
...request,
|
|
@@ -16553,6 +16592,7 @@ ${paths.join("\n")}`
|
|
|
16553
16592
|
config.extraPiArgs ?? []
|
|
16554
16593
|
);
|
|
16555
16594
|
const args = buildExplicitInternalActivationArgs(roleEntry, extraArgs);
|
|
16595
|
+
const stdin = encodeUserDialogueStdin(piUserDialogueBody(turnRequest));
|
|
16556
16596
|
const env = {
|
|
16557
16597
|
...process.env,
|
|
16558
16598
|
HOME: request.home,
|
|
@@ -16584,6 +16624,7 @@ ${paths.join("\n")}`
|
|
|
16584
16624
|
return await spawnRunner(args, {
|
|
16585
16625
|
cwd: request.cwd,
|
|
16586
16626
|
env,
|
|
16627
|
+
stdin,
|
|
16587
16628
|
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
16588
16629
|
...request.signal === void 0 ? {} : { signal: request.signal }
|
|
16589
16630
|
});
|
|
@@ -16627,6 +16668,7 @@ var init_role_turn_host = __esm({
|
|
|
16627
16668
|
init_host_contracts();
|
|
16628
16669
|
init_engine_detour();
|
|
16629
16670
|
init_role_activation_flags();
|
|
16671
|
+
init_user_dialogue_stdin();
|
|
16630
16672
|
init_sitian_facade();
|
|
16631
16673
|
INTERNAL_ROLE_ENTRYPOINT_RELATIVE2 = "extensions/role-runtime.ts";
|
|
16632
16674
|
EXPLICIT_INTERNAL_LOAD_PROBE_ARGS = [
|
|
@@ -16687,6 +16729,17 @@ var init_sha256 = __esm({
|
|
|
16687
16729
|
});
|
|
16688
16730
|
|
|
16689
16731
|
// src/readable-gate-item.ts
|
|
16732
|
+
var readable_gate_item_exports = {};
|
|
16733
|
+
__export(readable_gate_item_exports, {
|
|
16734
|
+
joinReadableGateItems: () => joinReadableGateItems,
|
|
16735
|
+
readableGateItem: () => readableGateItem
|
|
16736
|
+
});
|
|
16737
|
+
function readableGateItem(value) {
|
|
16738
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
16739
|
+
}
|
|
16740
|
+
function joinReadableGateItems(items, separator = "; ") {
|
|
16741
|
+
return items.map(readableGateItem).join(separator);
|
|
16742
|
+
}
|
|
16690
16743
|
var init_readable_gate_item = __esm({
|
|
16691
16744
|
"src/readable-gate-item.ts"() {
|
|
16692
16745
|
"use strict";
|
|
@@ -18614,7 +18667,8 @@ async function loadResumableInspectorRun(home, runId, authority) {
|
|
|
18614
18667
|
}
|
|
18615
18668
|
const admitted = {
|
|
18616
18669
|
role: "inspector",
|
|
18617
|
-
...resumedBaseAdmitted(loaded)
|
|
18670
|
+
...resumedBaseAdmitted(loaded),
|
|
18671
|
+
...loaded.admittedFields.sourceRunPath === void 0 ? {} : { sourceRunPath: loaded.admittedFields.sourceRunPath }
|
|
18618
18672
|
};
|
|
18619
18673
|
return seatLoadedResult(loaded, admitted);
|
|
18620
18674
|
}
|
|
@@ -22887,10 +22941,10 @@ function pairGateRounds(volumes) {
|
|
|
22887
22941
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
22888
22942
|
}
|
|
22889
22943
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
22890
|
-
const { readFile:
|
|
22944
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
22891
22945
|
let raw;
|
|
22892
22946
|
try {
|
|
22893
|
-
raw = JSON.parse(await
|
|
22947
|
+
raw = JSON.parse(await readFile24(pointerPath, "utf8"));
|
|
22894
22948
|
} catch (error) {
|
|
22895
22949
|
throw new Error(
|
|
22896
22950
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -23166,31 +23220,107 @@ function recordedRole(payload) {
|
|
|
23166
23220
|
if (isTerminalRoleName(payload.projection?.role)) return payload.projection.role;
|
|
23167
23221
|
return void 0;
|
|
23168
23222
|
}
|
|
23169
|
-
|
|
23170
|
-
|
|
23171
|
-
|
|
23172
|
-
|
|
23223
|
+
function rowRank(kind) {
|
|
23224
|
+
switch (kind) {
|
|
23225
|
+
case "accepted":
|
|
23226
|
+
return 4;
|
|
23227
|
+
case "audit-escalation":
|
|
23228
|
+
return 3;
|
|
23229
|
+
case "correctable-rejection":
|
|
23230
|
+
case "infrastructure":
|
|
23231
|
+
return 2;
|
|
23232
|
+
case "candidate":
|
|
23233
|
+
return 1;
|
|
23234
|
+
}
|
|
23235
|
+
}
|
|
23236
|
+
function submissionCallKey(attemptId, toolCallId) {
|
|
23237
|
+
return `${attemptId ?? ""}\0${toolCallId}`;
|
|
23238
|
+
}
|
|
23239
|
+
function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
23240
|
+
const role = recordedRole(payload) ?? roleFallback;
|
|
23241
|
+
return {
|
|
23242
|
+
...role === void 0 ? {} : { role },
|
|
23243
|
+
kind,
|
|
23244
|
+
accepted,
|
|
23245
|
+
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
23246
|
+
};
|
|
23247
|
+
}
|
|
23248
|
+
function mapOwnedToSubmissionRows(owned) {
|
|
23249
|
+
const scoped = owned;
|
|
23173
23250
|
const out = [];
|
|
23251
|
+
const indexByCall = /* @__PURE__ */ new Map();
|
|
23252
|
+
const roleByCall = /* @__PURE__ */ new Map();
|
|
23253
|
+
for (const record4 of scoped) {
|
|
23254
|
+
const payload = record4.payload;
|
|
23255
|
+
if (typeof payload?.toolCallId !== "string" || payload.toolCallId.length === 0) continue;
|
|
23256
|
+
const role = recordedRole(payload);
|
|
23257
|
+
if (role !== void 0) {
|
|
23258
|
+
roleByCall.set(submissionCallKey(recordAttemptId(record4), payload.toolCallId), role);
|
|
23259
|
+
}
|
|
23260
|
+
}
|
|
23261
|
+
const take = (row, callKey) => {
|
|
23262
|
+
const toolCallId = row.toolCallId;
|
|
23263
|
+
if (toolCallId !== void 0 && callKey !== void 0) {
|
|
23264
|
+
const existingIndex = indexByCall.get(callKey);
|
|
23265
|
+
if (existingIndex !== void 0) {
|
|
23266
|
+
const existing = out[existingIndex];
|
|
23267
|
+
if (rowRank(row.kind) >= rowRank(existing.kind)) {
|
|
23268
|
+
out[existingIndex] = {
|
|
23269
|
+
...row,
|
|
23270
|
+
toolCallId,
|
|
23271
|
+
// Keep a previously recovered role when the upgraded row still omits it.
|
|
23272
|
+
...row.role === void 0 && existing.role !== void 0 ? { role: existing.role } : {}
|
|
23273
|
+
};
|
|
23274
|
+
} else if (existing.role === void 0 && row.role !== void 0) {
|
|
23275
|
+
out[existingIndex] = { ...existing, role: row.role };
|
|
23276
|
+
}
|
|
23277
|
+
return;
|
|
23278
|
+
}
|
|
23279
|
+
indexByCall.set(callKey, out.length);
|
|
23280
|
+
}
|
|
23281
|
+
out.push(row);
|
|
23282
|
+
};
|
|
23174
23283
|
for (const record4 of scoped) {
|
|
23284
|
+
const attemptId = recordAttemptId(record4);
|
|
23285
|
+
if (record4.kind === "candidate") {
|
|
23286
|
+
const payload2 = record4.payload;
|
|
23287
|
+
if (payload2?.type !== "candidate" || payload2.params === void 0) continue;
|
|
23288
|
+
const callKey2 = typeof payload2.toolCallId === "string" ? submissionCallKey(attemptId, payload2.toolCallId) : void 0;
|
|
23289
|
+
const fallback2 = callKey2 !== void 0 ? roleByCall.get(callKey2) : void 0;
|
|
23290
|
+
take(rowFromPayload("candidate", payload2, payload2.params, fallback2), callKey2);
|
|
23291
|
+
continue;
|
|
23292
|
+
}
|
|
23175
23293
|
if (record4.kind === "sealed") {
|
|
23176
23294
|
const payload2 = record4.payload;
|
|
23177
23295
|
if (payload2?.type !== "sealed" || payload2.accepted === void 0) continue;
|
|
23178
|
-
const
|
|
23179
|
-
|
|
23180
|
-
|
|
23296
|
+
const callKey2 = typeof payload2.toolCallId === "string" ? submissionCallKey(attemptId, payload2.toolCallId) : void 0;
|
|
23297
|
+
const fallback2 = callKey2 !== void 0 ? roleByCall.get(callKey2) : void 0;
|
|
23298
|
+
take(rowFromPayload("accepted", payload2, payload2.accepted, fallback2), callKey2);
|
|
23181
23299
|
continue;
|
|
23182
23300
|
}
|
|
23183
23301
|
if (record4.kind !== "outcome") continue;
|
|
23184
23302
|
const payload = record4.payload;
|
|
23185
|
-
if (payload?.type !== "outcome" || payload.
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23189
|
-
|
|
23190
|
-
|
|
23303
|
+
if (payload?.type !== "outcome" || payload.accepted === void 0) continue;
|
|
23304
|
+
const outcome = payload.outcome;
|
|
23305
|
+
const kind = outcome === "audit-escalation" ? "audit-escalation" : outcome === "correctable-rejection" ? "correctable-rejection" : outcome === "infrastructure" ? "infrastructure" : void 0;
|
|
23306
|
+
if (kind === void 0) continue;
|
|
23307
|
+
const callKey = typeof payload.toolCallId === "string" ? submissionCallKey(attemptId, payload.toolCallId) : void 0;
|
|
23308
|
+
const fallback = callKey !== void 0 ? roleByCall.get(callKey) : void 0;
|
|
23309
|
+
take(rowFromPayload(kind, payload, payload.accepted, fallback), callKey);
|
|
23191
23310
|
}
|
|
23192
23311
|
return out;
|
|
23193
23312
|
}
|
|
23313
|
+
async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
|
|
23314
|
+
const scope = resolveReadScope(homeOrScope);
|
|
23315
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
|
|
23316
|
+
const scoped = recordsForAttempt(owned, scope.attemptId);
|
|
23317
|
+
return mapOwnedToSubmissionRows(scoped);
|
|
23318
|
+
}
|
|
23319
|
+
async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, home) {
|
|
23320
|
+
if (attemptId.length === 0) return [];
|
|
23321
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, home);
|
|
23322
|
+
return mapOwnedToSubmissionRows(owned.filter((record4) => recordAttemptId(record4) === attemptId));
|
|
23323
|
+
}
|
|
23194
23324
|
async function readRecordedSubmissions(cwd, runId, homeOrScope) {
|
|
23195
23325
|
return (await readRecordedSubmissionRows(cwd, runId, homeOrScope)).map((row) => row.accepted);
|
|
23196
23326
|
}
|
|
@@ -23198,6 +23328,7 @@ var init_submission_ledger = __esm({
|
|
|
23198
23328
|
"src/submission-ledger.ts"() {
|
|
23199
23329
|
"use strict";
|
|
23200
23330
|
init_activation_ledger_topology();
|
|
23331
|
+
init_host_contracts();
|
|
23201
23332
|
init_audit_escalation();
|
|
23202
23333
|
init_run_terminal_artifacts();
|
|
23203
23334
|
init_sitian_facade();
|
|
@@ -23320,6 +23451,7 @@ var DOCTOR_CANDIDATE_ENTRY_TYPE;
|
|
|
23320
23451
|
var init_dossier_resolution = __esm({
|
|
23321
23452
|
"src/dossier-resolution.ts"() {
|
|
23322
23453
|
"use strict";
|
|
23454
|
+
init_host_contracts();
|
|
23323
23455
|
DOCTOR_CANDIDATE_ENTRY_TYPE = "ak_doctor_audit_candidate";
|
|
23324
23456
|
}
|
|
23325
23457
|
});
|
|
@@ -23391,7 +23523,7 @@ function knownFailureFromProviderStop(input) {
|
|
|
23391
23523
|
const diagnostic = nonEmptyString(input.errorMessage);
|
|
23392
23524
|
const details = sessionStopDetails(input);
|
|
23393
23525
|
return {
|
|
23394
|
-
|
|
23526
|
+
...hasUpstreamErrorTestimony(input) ? { cause: "provider" } : {},
|
|
23395
23527
|
...diagnostic === void 0 ? {} : { diagnostic },
|
|
23396
23528
|
...Object.keys(details).length === 0 ? {} : { details }
|
|
23397
23529
|
};
|
|
@@ -23756,15 +23888,6 @@ function isLawfulTypedTerminalOutcome(outcome) {
|
|
|
23756
23888
|
function exitCodeForTerminalOutcome(outcome) {
|
|
23757
23889
|
return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
|
|
23758
23890
|
}
|
|
23759
|
-
function lastRolePayloadRecord(payloads) {
|
|
23760
|
-
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
23761
|
-
const payload = payloads[index];
|
|
23762
|
-
if (typeof payload === "object" && payload !== null && !Array.isArray(payload)) {
|
|
23763
|
-
return payload;
|
|
23764
|
-
}
|
|
23765
|
-
}
|
|
23766
|
-
return void 0;
|
|
23767
|
-
}
|
|
23768
23891
|
function recommendationNavigatorFact(input) {
|
|
23769
23892
|
const command = typeof input.modelCommand === "string" && input.modelCommand.trim() !== "" ? input.modelCommand : isPublicCallableRole2(input.next.role) ? renderPublicAkRoleCommand(input.next) : void 0;
|
|
23770
23893
|
return {
|
|
@@ -23779,7 +23902,7 @@ function recommendationNavigatorFact(input) {
|
|
|
23779
23902
|
function formatTerminalResult(result2) {
|
|
23780
23903
|
const lines = [];
|
|
23781
23904
|
lines.push("role outcome status");
|
|
23782
|
-
const outcomeStatus = result2.roleOutcome.kind === "failure" ? result2.roleOutcome.cause : result2.roleOutcome.kind === "accepted" ? "accepted" : result2.roleOutcome.status;
|
|
23905
|
+
const outcomeStatus = result2.roleOutcome.kind === "failure" ? result2.roleOutcome.cause ?? "" : result2.roleOutcome.kind === "accepted" ? "accepted" : result2.roleOutcome.status;
|
|
23783
23906
|
lines.push(
|
|
23784
23907
|
`${result2.roleOutcome.role} ${result2.roleOutcome.kind} ${encodeTerminalField(outcomeStatus)}`
|
|
23785
23908
|
);
|
|
@@ -23865,14 +23988,27 @@ function ledgerReadScope(admitted, scope) {
|
|
|
23865
23988
|
}
|
|
23866
23989
|
function roleOutcomeFromRows(role, rows) {
|
|
23867
23990
|
const mine = rows.filter((row) => row.role === role);
|
|
23868
|
-
|
|
23991
|
+
const terminal = mine.filter(
|
|
23992
|
+
(row) => row.kind === "accepted" || row.kind === "audit-escalation"
|
|
23993
|
+
);
|
|
23994
|
+
if (terminal.length === 0) return void 0;
|
|
23869
23995
|
const payloads = mine.map((row) => row.accepted);
|
|
23870
|
-
if (
|
|
23996
|
+
if (terminal.some((row) => row.kind === "audit-escalation")) {
|
|
23871
23997
|
return { kind: "audit_escalation", role, status: "audit_escalation", payloads };
|
|
23872
23998
|
}
|
|
23873
23999
|
return { kind: "accepted", role, payloads };
|
|
23874
24000
|
}
|
|
23875
24001
|
async function sealedLedgerOutcome(admitted, role, scope) {
|
|
24002
|
+
const home = sealedLedgerHome(admitted);
|
|
24003
|
+
if (scope?.courtAttemptId !== void 0 && scope.courtAttemptId.length > 0) {
|
|
24004
|
+
const thisCourt = await readAttemptScopedSubmissionRows(
|
|
24005
|
+
admitted.projectRoot,
|
|
24006
|
+
admitted.runId,
|
|
24007
|
+
scope.courtAttemptId,
|
|
24008
|
+
home
|
|
24009
|
+
);
|
|
24010
|
+
return roleOutcomeFromRows(role, thisCourt);
|
|
24011
|
+
}
|
|
23876
24012
|
const rows = await readRecordedSubmissionRows(
|
|
23877
24013
|
admitted.projectRoot,
|
|
23878
24014
|
admitted.runId,
|
|
@@ -23903,7 +24039,11 @@ function withSubmissions(terminal, submissions) {
|
|
|
23903
24039
|
return { ...terminal, roleOutcome: withPayloads, submissions };
|
|
23904
24040
|
}
|
|
23905
24041
|
async function attachRecordedSubmissions(admitted, terminal, scope) {
|
|
23906
|
-
|
|
24042
|
+
void scope;
|
|
24043
|
+
return withSubmissions(
|
|
24044
|
+
terminal,
|
|
24045
|
+
await recordedSubmissionPayloads(admitted, void 0)
|
|
24046
|
+
);
|
|
23907
24047
|
}
|
|
23908
24048
|
async function settleHostEndedNoReceipt(admitted, authority) {
|
|
23909
24049
|
const facts = noReceiptLifecycleFacts({
|
|
@@ -24000,7 +24140,7 @@ function thrownIdentity(error) {
|
|
|
24000
24140
|
function isTypedActivationError(error) {
|
|
24001
24141
|
if (!(error instanceof Error)) return false;
|
|
24002
24142
|
const cause = error.knownCause;
|
|
24003
|
-
return cause === "provider" || cause === "activation" || cause === "session" || cause === "output" || cause === "timeout"
|
|
24143
|
+
return cause === "provider" || cause === "activation" || cause === "session" || cause === "output" || cause === "timeout";
|
|
24004
24144
|
}
|
|
24005
24145
|
function flattenThrownFailureLeaves(error) {
|
|
24006
24146
|
if (!(error instanceof AggregateError)) {
|
|
@@ -24020,7 +24160,7 @@ function projectThrownFailureLeaf(error) {
|
|
|
24020
24160
|
}
|
|
24021
24161
|
return {
|
|
24022
24162
|
cause: error.knownCause,
|
|
24023
|
-
diagnostic: error.message || error.name || "
|
|
24163
|
+
diagnostic: error.message || error.name || "exception",
|
|
24024
24164
|
identity,
|
|
24025
24165
|
...error.details === void 0 ? {} : { details: error.details }
|
|
24026
24166
|
};
|
|
@@ -24028,13 +24168,11 @@ function projectThrownFailureLeaf(error) {
|
|
|
24028
24168
|
if (error instanceof Error) {
|
|
24029
24169
|
const identity = thrownIdentity(error);
|
|
24030
24170
|
return {
|
|
24031
|
-
|
|
24032
|
-
diagnostic: error.message || error.name || "unrecognized exception",
|
|
24171
|
+
diagnostic: error.message || error.name || "exception",
|
|
24033
24172
|
identity
|
|
24034
24173
|
};
|
|
24035
24174
|
}
|
|
24036
24175
|
return {
|
|
24037
|
-
cause: "unrecognized",
|
|
24038
24176
|
diagnostic: String(error)
|
|
24039
24177
|
};
|
|
24040
24178
|
}
|
|
@@ -24056,7 +24194,7 @@ function classifyThrownFailure(error) {
|
|
|
24056
24194
|
...leaves.slice(1).map((leaf) => {
|
|
24057
24195
|
const secondary = projectThrownFailureLeaf(leaf);
|
|
24058
24196
|
return {
|
|
24059
|
-
cause: secondary.cause,
|
|
24197
|
+
...secondary.cause === void 0 ? {} : { cause: secondary.cause },
|
|
24060
24198
|
diagnostic: secondary.diagnostic,
|
|
24061
24199
|
...secondary.identity === void 0 ? {} : { identity: secondary.identity },
|
|
24062
24200
|
...secondary.details === void 0 ? {} : { details: secondary.details }
|
|
@@ -24064,7 +24202,7 @@ function classifyThrownFailure(error) {
|
|
|
24064
24202
|
})
|
|
24065
24203
|
];
|
|
24066
24204
|
return {
|
|
24067
|
-
cause: primary.cause,
|
|
24205
|
+
...primary.cause === void 0 ? {} : { cause: primary.cause },
|
|
24068
24206
|
diagnostic: primary.diagnostic,
|
|
24069
24207
|
...primary.identity === void 0 ? {} : { identity: primary.identity },
|
|
24070
24208
|
details: {
|
|
@@ -24105,6 +24243,24 @@ function classifyPostAdmissionFailure(input) {
|
|
|
24105
24243
|
...input.knownIdentity === void 0 ? {} : { identity: input.knownIdentity }
|
|
24106
24244
|
};
|
|
24107
24245
|
}
|
|
24246
|
+
if (input.knownDiagnostic !== void 0 && input.knownDiagnostic.trim() !== "" || input.knownIdentity !== void 0) {
|
|
24247
|
+
const diagnostic = input.knownDiagnostic !== void 0 && input.knownDiagnostic.trim() !== "" ? input.knownDiagnostic : conciseChildDiagnostic(input.stderr, "role run failed");
|
|
24248
|
+
const { timedOut: _knownTimedOut, ...knownDetails } = input.knownDetails ?? {};
|
|
24249
|
+
const remoteCode = knownDetails.code;
|
|
24250
|
+
return withKnownDetails(
|
|
24251
|
+
{
|
|
24252
|
+
diagnostic,
|
|
24253
|
+
details: {
|
|
24254
|
+
...knownDetails,
|
|
24255
|
+
...remoteCode === void 0 ? {} : { code: remoteCode },
|
|
24256
|
+
exitCode: input.code,
|
|
24257
|
+
...input.timedOut ? { timedOut: true } : {}
|
|
24258
|
+
},
|
|
24259
|
+
...input.knownIdentity === void 0 ? {} : { identity: input.knownIdentity }
|
|
24260
|
+
},
|
|
24261
|
+
void 0
|
|
24262
|
+
);
|
|
24263
|
+
}
|
|
24108
24264
|
if (input.timedOut) {
|
|
24109
24265
|
return withKnownDetails(
|
|
24110
24266
|
{
|
|
@@ -24158,7 +24314,7 @@ function classifyPostAdmissionFailure(input) {
|
|
|
24158
24314
|
function explicitInternalKnownFailureClassificationInput(failure) {
|
|
24159
24315
|
if (failure === void 0) return {};
|
|
24160
24316
|
return {
|
|
24161
|
-
knownCause: failure.cause,
|
|
24317
|
+
...failure.cause === void 0 ? {} : { knownCause: failure.cause },
|
|
24162
24318
|
...failure.identity === void 0 ? {} : { knownIdentity: failure.identity },
|
|
24163
24319
|
...failure.diagnostic === void 0 ? {} : { knownDiagnostic: failure.diagnostic },
|
|
24164
24320
|
...failure.details === void 0 ? {} : { knownDetails: failure.details }
|
|
@@ -24410,10 +24566,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
24410
24566
|
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord9(entry.data)) continue;
|
|
24411
24567
|
const parent = isRecord9(entry.data.parent) ? entry.data.parent : void 0;
|
|
24412
24568
|
const failure = isRecord9(entry.data.failure) ? entry.data.failure : void 0;
|
|
24413
|
-
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId
|
|
24569
|
+
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
24570
|
+
if (failure === void 0) continue;
|
|
24414
24571
|
const identity = isRecord9(failure.identity) ? failure.identity : void 0;
|
|
24572
|
+
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
24415
24573
|
return {
|
|
24416
|
-
|
|
24574
|
+
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
24417
24575
|
...identity === void 0 ? {} : { identity: {
|
|
24418
24576
|
...typeof identity.name === "string" ? { name: identity.name } : {},
|
|
24419
24577
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
@@ -25017,8 +25175,7 @@ async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options
|
|
|
25017
25175
|
role: "coder",
|
|
25018
25176
|
runId: admitted.runId,
|
|
25019
25177
|
phase: admitted.phase,
|
|
25020
|
-
outcome: roleOutcome
|
|
25021
|
-
...options.coderOutput === void 0 ? {} : { receipt: options.coderOutput }
|
|
25178
|
+
outcome: roleOutcome
|
|
25022
25179
|
},
|
|
25023
25180
|
null,
|
|
25024
25181
|
2
|
|
@@ -25095,7 +25252,6 @@ async function settleLawfulCoderTerminalResult(admitted, authority, options = {}
|
|
|
25095
25252
|
const ledgerOutcome = await closedLedgerOutcome(admitted, "coder", scope);
|
|
25096
25253
|
if (ledgerOutcome === void 0) return void 0;
|
|
25097
25254
|
const roleOutcome = ledgerOutcome;
|
|
25098
|
-
const output = ledgerOutcome.kind === "accepted" ? lastRolePayloadRecord(ledgerOutcome.payloads ?? []) : void 0;
|
|
25099
25255
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
25100
25256
|
const entries = await readLawfulSettlementEntries(coordinates.sessionFile) ?? [];
|
|
25101
25257
|
const navigator = extractNavigatorFact(entries);
|
|
@@ -25104,7 +25260,6 @@ async function settleLawfulCoderTerminalResult(admitted, authority, options = {}
|
|
|
25104
25260
|
roleOutcome,
|
|
25105
25261
|
coordinates,
|
|
25106
25262
|
{
|
|
25107
|
-
...output === void 0 ? {} : { coderOutput: output },
|
|
25108
25263
|
...options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance }
|
|
25109
25264
|
}
|
|
25110
25265
|
);
|
|
@@ -25158,8 +25313,7 @@ async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options
|
|
|
25158
25313
|
role: "fixer",
|
|
25159
25314
|
runId: admitted.runId,
|
|
25160
25315
|
phase: admitted.phase,
|
|
25161
|
-
outcome: roleOutcome
|
|
25162
|
-
...options.fixerOutput === void 0 ? {} : { receipt: options.fixerOutput }
|
|
25316
|
+
outcome: roleOutcome
|
|
25163
25317
|
},
|
|
25164
25318
|
null,
|
|
25165
25319
|
2
|
|
@@ -25206,7 +25360,6 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options, sco
|
|
|
25206
25360
|
const ledgerOutcome = await closedLedgerOutcome(admitted, "fixer", scope);
|
|
25207
25361
|
if (ledgerOutcome === void 0) return void 0;
|
|
25208
25362
|
const roleOutcome = ledgerOutcome;
|
|
25209
|
-
const output = ledgerOutcome.kind === "accepted" ? lastRolePayloadRecord(ledgerOutcome.payloads ?? []) : void 0;
|
|
25210
25363
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
25211
25364
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
25212
25365
|
const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
|
|
@@ -25222,7 +25375,6 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options, sco
|
|
|
25222
25375
|
roleOutcome,
|
|
25223
25376
|
coordinates,
|
|
25224
25377
|
{
|
|
25225
|
-
...output === void 0 ? {} : { fixerOutput: output },
|
|
25226
25378
|
methodProvenance: options.methodProvenance,
|
|
25227
25379
|
methodInvocations
|
|
25228
25380
|
}
|
|
@@ -25237,7 +25389,7 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options, sco
|
|
|
25237
25389
|
sessionDirectory
|
|
25238
25390
|
);
|
|
25239
25391
|
}
|
|
25240
|
-
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates
|
|
25392
|
+
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
|
|
25241
25393
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25242
25394
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25243
25395
|
const reportPath = join21(artifactsDir, "report.json");
|
|
@@ -25248,8 +25400,7 @@ async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, opt
|
|
|
25248
25400
|
{
|
|
25249
25401
|
role: "collector",
|
|
25250
25402
|
runId: admitted.runId,
|
|
25251
|
-
outcome: roleOutcome
|
|
25252
|
-
...options.collectorReceipt === void 0 ? {} : { receipt: options.collectorReceipt }
|
|
25403
|
+
outcome: roleOutcome
|
|
25253
25404
|
},
|
|
25254
25405
|
null,
|
|
25255
25406
|
2
|
|
@@ -25310,14 +25461,12 @@ async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
|
|
|
25310
25461
|
}
|
|
25311
25462
|
return void 0;
|
|
25312
25463
|
}
|
|
25313
|
-
const receipt = lastRolePayloadRecord(roleOutcome.payloads ?? []) ?? {};
|
|
25314
25464
|
const accepted = roleOutcome;
|
|
25315
25465
|
const navigator = extractNavigatorFact(entries);
|
|
25316
25466
|
const artifacts = await publishCollectorArtifacts(
|
|
25317
25467
|
admitted,
|
|
25318
25468
|
accepted,
|
|
25319
|
-
coordinates
|
|
25320
|
-
{ collectorReceipt: receipt }
|
|
25469
|
+
coordinates
|
|
25321
25470
|
);
|
|
25322
25471
|
return attachRecordedSubmissions(
|
|
25323
25472
|
admitted,
|
|
@@ -25370,8 +25519,6 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
|
|
|
25370
25519
|
role: "doctor",
|
|
25371
25520
|
runId: admitted.runId,
|
|
25372
25521
|
outcome: roleOutcome,
|
|
25373
|
-
...options.doctorOutput === void 0 ? {} : { receipt: options.doctorOutput },
|
|
25374
|
-
// Independent machine fields beside the receipt — not merged into it.
|
|
25375
25522
|
...options.cost === void 0 ? {} : { cost: options.cost },
|
|
25376
25523
|
...options.auditNoReceipt === void 0 ? {} : { auditNoReceipt: options.auditNoReceipt }
|
|
25377
25524
|
},
|
|
@@ -25429,7 +25576,6 @@ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
|
|
|
25429
25576
|
sessionDirectory
|
|
25430
25577
|
);
|
|
25431
25578
|
}
|
|
25432
|
-
const output = lastRolePayloadRecord(sealed.payloads ?? []) ?? {};
|
|
25433
25579
|
const roleOutcome = sealed;
|
|
25434
25580
|
const navigator = extractNavigatorFact(entries);
|
|
25435
25581
|
const cost = extractDoctorCandidateCostFact(entries);
|
|
@@ -25439,7 +25585,6 @@ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
|
|
|
25439
25585
|
roleOutcome,
|
|
25440
25586
|
coordinates,
|
|
25441
25587
|
{
|
|
25442
|
-
doctorOutput: output,
|
|
25443
25588
|
...cost === void 0 ? {} : { cost },
|
|
25444
25589
|
...auditNoReceipt === void 0 ? {} : { auditNoReceipt }
|
|
25445
25590
|
}
|
|
@@ -25629,8 +25774,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, opti
|
|
|
25629
25774
|
{
|
|
25630
25775
|
role: "reviewer",
|
|
25631
25776
|
runId: admitted.runId,
|
|
25632
|
-
outcome: roleOutcome
|
|
25633
|
-
...options.reviewerReceipt === void 0 ? {} : { receipt: options.reviewerReceipt }
|
|
25777
|
+
outcome: roleOutcome
|
|
25634
25778
|
},
|
|
25635
25779
|
null,
|
|
25636
25780
|
2
|
|
@@ -25678,7 +25822,6 @@ async function settleLawfulReviewerTerminalResult(admitted, authority, options,
|
|
|
25678
25822
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
25679
25823
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
25680
25824
|
const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
|
|
25681
|
-
const receipt = lastRolePayloadRecord(sealed.payloads ?? []);
|
|
25682
25825
|
const roleOutcome = sealed;
|
|
25683
25826
|
const navigator = extractNavigatorFact(entries);
|
|
25684
25827
|
const methodInvocations = extractReviewerMethodInvocations(entries, {
|
|
@@ -25692,7 +25835,6 @@ async function settleLawfulReviewerTerminalResult(admitted, authority, options,
|
|
|
25692
25835
|
roleOutcome,
|
|
25693
25836
|
coordinates,
|
|
25694
25837
|
{
|
|
25695
|
-
...receipt === void 0 ? {} : { reviewerReceipt: receipt },
|
|
25696
25838
|
methodProvenance: options.methodProvenance,
|
|
25697
25839
|
methodInvocations
|
|
25698
25840
|
}
|
|
@@ -25737,8 +25879,7 @@ async function publishMergerArtifacts(admitted, roleOutcome, coordinates, option
|
|
|
25737
25879
|
{
|
|
25738
25880
|
role: "merger",
|
|
25739
25881
|
runId: admitted.runId,
|
|
25740
|
-
outcome: roleOutcome
|
|
25741
|
-
...options.mergerOutput === void 0 ? {} : { receipt: options.mergerOutput }
|
|
25882
|
+
outcome: roleOutcome
|
|
25742
25883
|
},
|
|
25743
25884
|
null,
|
|
25744
25885
|
2
|
|
@@ -25810,7 +25951,6 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options, sc
|
|
|
25810
25951
|
accepted,
|
|
25811
25952
|
coordinates,
|
|
25812
25953
|
{
|
|
25813
|
-
mergerOutput: lastRolePayloadRecord(accepted.payloads ?? []) ?? {},
|
|
25814
25954
|
methodProvenance: options.methodProvenance,
|
|
25815
25955
|
methodInvocations
|
|
25816
25956
|
}
|
|
@@ -25943,7 +26083,7 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
25943
26083
|
kind: "error",
|
|
25944
26084
|
role: admitted.role,
|
|
25945
26085
|
runId: admitted.runId,
|
|
25946
|
-
cause: failure.cause,
|
|
26086
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
25947
26087
|
diagnostic: failure.diagnostic,
|
|
25948
26088
|
...failure.identity === void 0 ? {} : { identity: failure.identity },
|
|
25949
26089
|
...failure.details === void 0 ? {} : { details: failure.details }
|
|
@@ -25966,7 +26106,7 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
25966
26106
|
sha256: a.sha256,
|
|
25967
26107
|
byteLength: a.byteLength
|
|
25968
26108
|
})),
|
|
25969
|
-
failureCause: failure.cause
|
|
26109
|
+
...failure.cause === void 0 ? {} : { failureCause: failure.cause }
|
|
25970
26110
|
};
|
|
25971
26111
|
const evidenceWrite = await writeFailureJsonRetainingCause(
|
|
25972
26112
|
evidenceCandidates,
|
|
@@ -26030,7 +26170,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
26030
26170
|
const navigator = await extractNavigatorFactFromAdmittedSession(sessionFile);
|
|
26031
26171
|
const artifacts = await publishFailureArtifacts(admitted, failure, authority);
|
|
26032
26172
|
const decisiveFacts = {
|
|
26033
|
-
cause: failure.cause,
|
|
26173
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
26034
26174
|
diagnostic: failure.diagnostic
|
|
26035
26175
|
};
|
|
26036
26176
|
if (failure.identity?.name !== void 0) {
|
|
@@ -26046,7 +26186,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
26046
26186
|
const roleOutcome2 = {
|
|
26047
26187
|
kind: "failure",
|
|
26048
26188
|
role: admitted.role,
|
|
26049
|
-
cause: failure.cause,
|
|
26189
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
26050
26190
|
diagnostic: failure.diagnostic,
|
|
26051
26191
|
decisiveFacts
|
|
26052
26192
|
};
|
|
@@ -26063,7 +26203,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
26063
26203
|
const roleOutcome = {
|
|
26064
26204
|
kind: "failure",
|
|
26065
26205
|
role: admitted.role,
|
|
26066
|
-
cause: failure.cause,
|
|
26206
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
26067
26207
|
diagnostic: failure.diagnostic,
|
|
26068
26208
|
decisiveFacts
|
|
26069
26209
|
};
|
|
@@ -26084,7 +26224,7 @@ function presentFailureTerminal(terminal, io) {
|
|
|
26084
26224
|
io.stdout(formatTerminalResult(terminal));
|
|
26085
26225
|
if (terminal.roleOutcome.kind === "failure") {
|
|
26086
26226
|
io.stderr(formatFailureStderrDiagnostic({
|
|
26087
|
-
cause: terminal.roleOutcome.cause,
|
|
26227
|
+
...terminal.roleOutcome.cause === void 0 ? {} : { cause: terminal.roleOutcome.cause },
|
|
26088
26228
|
diagnostic: terminal.roleOutcome.diagnostic
|
|
26089
26229
|
}));
|
|
26090
26230
|
return;
|
|
@@ -26276,6 +26416,9 @@ var init_ticket_provenance = __esm({
|
|
|
26276
26416
|
});
|
|
26277
26417
|
|
|
26278
26418
|
// src/public-cli/case-dossier-delivery.ts
|
|
26419
|
+
import { mkdtemp, readFile as readFile18, rm, writeFile as writeFile7 } from "node:fs/promises";
|
|
26420
|
+
import { tmpdir } from "node:os";
|
|
26421
|
+
import { join as join24 } from "node:path";
|
|
26279
26422
|
function describeDossierFile(path) {
|
|
26280
26423
|
return path;
|
|
26281
26424
|
}
|
|
@@ -26294,18 +26437,42 @@ async function projectCaseDossierPointerSection(input) {
|
|
|
26294
26437
|
`\u8BB0\u5F55\u5377\u5B97\uFF1A${describeDossierFile(volume.recordFile)}`
|
|
26295
26438
|
].join("\n");
|
|
26296
26439
|
}
|
|
26297
|
-
|
|
26440
|
+
async function deliverCaseDossierAsAttachment(input) {
|
|
26441
|
+
const section = await projectCaseDossierPointerSection({
|
|
26442
|
+
ticketNumber: input.ticketNumber,
|
|
26443
|
+
projectRoot: input.projectRoot,
|
|
26444
|
+
home: input.home
|
|
26445
|
+
});
|
|
26446
|
+
if (section === void 0) return void 0;
|
|
26447
|
+
const stagingDir = await mkdtemp(join24(tmpdir(), "ak-case-dossier-"));
|
|
26448
|
+
try {
|
|
26449
|
+
const stagingPath = join24(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
26450
|
+
await writeFile7(stagingPath, `${section}
|
|
26451
|
+
`, "utf8");
|
|
26452
|
+
return await freezeAttachmentsIntoRun(
|
|
26453
|
+
[stagingPath],
|
|
26454
|
+
input.runDirectory,
|
|
26455
|
+
CASE_DOSSIER_ATTACH_KEY
|
|
26456
|
+
);
|
|
26457
|
+
} finally {
|
|
26458
|
+
await rm(stagingDir, { recursive: true, force: true });
|
|
26459
|
+
}
|
|
26460
|
+
}
|
|
26461
|
+
var CASE_DOSSIER_SECTION_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
|
|
26298
26462
|
var init_case_dossier_delivery = __esm({
|
|
26299
26463
|
"src/public-cli/case-dossier-delivery.ts"() {
|
|
26300
26464
|
"use strict";
|
|
26301
26465
|
init_ticket_provenance();
|
|
26466
|
+
init_invocation();
|
|
26302
26467
|
CASE_DOSSIER_SECTION_HEADING = "## \u672C\u7968\u8D77\u5C45\u5F55\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
26468
|
+
CASE_DOSSIER_ATTACH_KEY = "case-dossier";
|
|
26469
|
+
CASE_DOSSIER_ATTACH_FILE = "case-dossier-pointer.md";
|
|
26303
26470
|
}
|
|
26304
26471
|
});
|
|
26305
26472
|
|
|
26306
26473
|
// src/host-transition-prior-native.ts
|
|
26307
26474
|
import { access as access3, readdir as readdir6 } from "node:fs/promises";
|
|
26308
|
-
import { dirname as dirname13, join as
|
|
26475
|
+
import { dirname as dirname13, join as join25 } from "node:path";
|
|
26309
26476
|
function isEnoent2(error) {
|
|
26310
26477
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
26311
26478
|
}
|
|
@@ -26330,7 +26497,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
26330
26497
|
const recordPaths = [];
|
|
26331
26498
|
for (const entry of entries) {
|
|
26332
26499
|
if (!entry.isDirectory()) continue;
|
|
26333
|
-
const recordFile =
|
|
26500
|
+
const recordFile = join25(sessionRoot, entry.name, "records.jsonl");
|
|
26334
26501
|
try {
|
|
26335
26502
|
await access3(recordFile);
|
|
26336
26503
|
recordPaths.push(recordFile);
|
|
@@ -26400,7 +26567,7 @@ var init_public_run_credentials = __esm({
|
|
|
26400
26567
|
import { constants as fsConstants2 } from "node:fs";
|
|
26401
26568
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
26402
26569
|
import { lstat as lstat5, mkdir as mkdir5, open as open2 } from "node:fs/promises";
|
|
26403
|
-
import { join as
|
|
26570
|
+
import { join as join26 } from "node:path";
|
|
26404
26571
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
26405
26572
|
if (options?.lawful === true) {
|
|
26406
26573
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -26436,7 +26603,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
|
|
|
26436
26603
|
}
|
|
26437
26604
|
}
|
|
26438
26605
|
function runArtifactsDirectory(runDirectory) {
|
|
26439
|
-
return
|
|
26606
|
+
return join26(runDirectory, "artifacts");
|
|
26440
26607
|
}
|
|
26441
26608
|
async function ensureRealArtifactsDirectory(runDirectory) {
|
|
26442
26609
|
const runStat = await lstat5(runDirectory);
|
|
@@ -26518,7 +26685,7 @@ function jsonSafeReplacer() {
|
|
|
26518
26685
|
};
|
|
26519
26686
|
}
|
|
26520
26687
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
26521
|
-
const filePath =
|
|
26688
|
+
const filePath = join26(artifactsDir, `${namePrefix}-${randomUUID4()}.json`);
|
|
26522
26689
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
26523
26690
|
`;
|
|
26524
26691
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -26572,12 +26739,29 @@ function unwrapTurnDispatchedFailure(error) {
|
|
|
26572
26739
|
}
|
|
26573
26740
|
return current;
|
|
26574
26741
|
}
|
|
26742
|
+
async function attachDispatchExceptionTerminal(admitted, terminal, io) {
|
|
26743
|
+
try {
|
|
26744
|
+
return await attachRecordedSubmissions(
|
|
26745
|
+
{
|
|
26746
|
+
projectRoot: admitted.projectRoot,
|
|
26747
|
+
runId: admitted.runId,
|
|
26748
|
+
runDirectory: admitted.runDirectory
|
|
26749
|
+
},
|
|
26750
|
+
terminal
|
|
26751
|
+
);
|
|
26752
|
+
} catch (error) {
|
|
26753
|
+
io.stderr(
|
|
26754
|
+
`dispatch exception ledger attach failed (best-effort continue): ${describeErrorIdentity(error)}
|
|
26755
|
+
`
|
|
26756
|
+
);
|
|
26757
|
+
return terminal;
|
|
26758
|
+
}
|
|
26759
|
+
}
|
|
26575
26760
|
function dispatchExceptionFailureTerminal(input) {
|
|
26576
26761
|
const causeError = unwrapTurnDispatchedFailure(input.causeError);
|
|
26577
26762
|
const history = input.everyAttemptThrew ? "dispatch threw an exception on every attempt" : "the final dispatch threw an exception";
|
|
26578
26763
|
const diagnostic = `${history} (${input.endReason}; resumes used ${input.autoResumeAttempts}); last cause: ${describeErrorIdentity(causeError)}`;
|
|
26579
26764
|
const decisiveFacts = {
|
|
26580
|
-
cause: "unrecognized",
|
|
26581
26765
|
diagnostic,
|
|
26582
26766
|
resumesUsed: input.autoResumeAttempts,
|
|
26583
26767
|
dispatchErrorFiles: [...input.errorFiles]
|
|
@@ -26598,7 +26782,6 @@ function dispatchExceptionFailureTerminal(input) {
|
|
|
26598
26782
|
roleOutcome: {
|
|
26599
26783
|
kind: "failure",
|
|
26600
26784
|
role: input.role,
|
|
26601
|
-
cause: "unrecognized",
|
|
26602
26785
|
diagnostic,
|
|
26603
26786
|
decisiveFacts
|
|
26604
26787
|
},
|
|
@@ -26698,15 +26881,19 @@ async function runWithAutoResumeLoop(options) {
|
|
|
26698
26881
|
}
|
|
26699
26882
|
} else {
|
|
26700
26883
|
if (autoResumeAttempts >= limit) {
|
|
26701
|
-
const terminal =
|
|
26702
|
-
|
|
26703
|
-
|
|
26704
|
-
|
|
26705
|
-
|
|
26706
|
-
|
|
26707
|
-
|
|
26708
|
-
|
|
26709
|
-
|
|
26884
|
+
const terminal = await attachDispatchExceptionTerminal(
|
|
26885
|
+
options.admitted,
|
|
26886
|
+
dispatchExceptionFailureTerminal({
|
|
26887
|
+
role: options.admitted.role,
|
|
26888
|
+
runId: options.admitted.runId,
|
|
26889
|
+
causeError: lastThrownError,
|
|
26890
|
+
errorFiles: retainedErrorFiles,
|
|
26891
|
+
autoResumeAttempts,
|
|
26892
|
+
endReason: "auto-resume budget exhausted",
|
|
26893
|
+
everyAttemptThrew
|
|
26894
|
+
}),
|
|
26895
|
+
options.io
|
|
26896
|
+
);
|
|
26710
26897
|
await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
|
|
26711
26898
|
presentTerminal(terminal, options.io);
|
|
26712
26899
|
return {
|
|
@@ -26715,15 +26902,19 @@ async function runWithAutoResumeLoop(options) {
|
|
|
26715
26902
|
};
|
|
26716
26903
|
}
|
|
26717
26904
|
if (!await isPrincipalAvailable(options.admitted.principal)) {
|
|
26718
|
-
const terminal =
|
|
26719
|
-
|
|
26720
|
-
|
|
26721
|
-
|
|
26722
|
-
|
|
26723
|
-
|
|
26724
|
-
|
|
26725
|
-
|
|
26726
|
-
|
|
26905
|
+
const terminal = await attachDispatchExceptionTerminal(
|
|
26906
|
+
options.admitted,
|
|
26907
|
+
dispatchExceptionFailureTerminal({
|
|
26908
|
+
role: options.admitted.role,
|
|
26909
|
+
runId: options.admitted.runId,
|
|
26910
|
+
causeError: lastThrownError,
|
|
26911
|
+
errorFiles: retainedErrorFiles,
|
|
26912
|
+
autoResumeAttempts,
|
|
26913
|
+
endReason: "session principal unavailable before further resume",
|
|
26914
|
+
everyAttemptThrew
|
|
26915
|
+
}),
|
|
26916
|
+
options.io
|
|
26917
|
+
);
|
|
26727
26918
|
await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
|
|
26728
26919
|
presentTerminal(terminal, options.io);
|
|
26729
26920
|
return {
|
|
@@ -26765,8 +26956,8 @@ var init_auto_resume = __esm({
|
|
|
26765
26956
|
|
|
26766
26957
|
// src/public-cli/post-admission.ts
|
|
26767
26958
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
26768
|
-
import { readFile as
|
|
26769
|
-
import { isAbsolute as isAbsolute8, join as
|
|
26959
|
+
import { readFile as readFile19, writeFile as writeFile8 } from "node:fs/promises";
|
|
26960
|
+
import { isAbsolute as isAbsolute8, join as join27, resolve as resolve9 } from "node:path";
|
|
26770
26961
|
function describeCaughtError(error) {
|
|
26771
26962
|
if (error instanceof Error) {
|
|
26772
26963
|
const code = error.code;
|
|
@@ -26780,6 +26971,9 @@ function appendContinuationSection(continuation, section) {
|
|
|
26780
26971
|
${section}`;
|
|
26781
26972
|
return continuation.kind === "initial" ? { kind: "initial", prompt } : { kind: "resume", prompt };
|
|
26782
26973
|
}
|
|
26974
|
+
function isStationChildOfficerDialogue(role, env) {
|
|
26975
|
+
return env.stationChild === true && isOfficerReviewSeat(role);
|
|
26976
|
+
}
|
|
26783
26977
|
function withOnceSuccessfulBeforeDispatch(adapters) {
|
|
26784
26978
|
const hook = adapters.beforeDispatch;
|
|
26785
26979
|
if (hook === void 0) return adapters;
|
|
@@ -26807,8 +27001,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
26807
27001
|
} catch (appendError) {
|
|
26808
27002
|
try {
|
|
26809
27003
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
26810
|
-
await
|
|
26811
|
-
|
|
27004
|
+
await writeFile8(
|
|
27005
|
+
join27(artifactsDir, `post-admission-diagnostic-${randomUUID5()}.json`),
|
|
26812
27006
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
26813
27007
|
`,
|
|
26814
27008
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -26824,7 +27018,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
26824
27018
|
}
|
|
26825
27019
|
async function readInvocationHost(runDirectory) {
|
|
26826
27020
|
try {
|
|
26827
|
-
const raw = JSON.parse(await
|
|
27021
|
+
const raw = JSON.parse(await readFile19(join27(runDirectory, "invocation.json"), "utf8"));
|
|
26828
27022
|
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
|
|
26829
27023
|
} catch (error) {
|
|
26830
27024
|
if (error.code === "ENOENT") return void 0;
|
|
@@ -27021,19 +27215,28 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
27021
27215
|
if (hostTransition !== void 0) {
|
|
27022
27216
|
turnRequest = { ...turnRequest, hostTransition };
|
|
27023
27217
|
}
|
|
27024
|
-
|
|
27025
|
-
|
|
27026
|
-
|
|
27027
|
-
|
|
27028
|
-
|
|
27029
|
-
|
|
27030
|
-
|
|
27031
|
-
|
|
27032
|
-
|
|
27033
|
-
|
|
27034
|
-
|
|
27035
|
-
|
|
27036
|
-
};
|
|
27218
|
+
if (isStationChildOfficerDialogue(admitted.role, env)) {
|
|
27219
|
+
await deliverCaseDossierAsAttachment({
|
|
27220
|
+
ticketNumber: admitted.ticketNumber,
|
|
27221
|
+
projectRoot: admitted.projectRoot,
|
|
27222
|
+
home: env.home,
|
|
27223
|
+
runDirectory: admitted.runDirectory
|
|
27224
|
+
});
|
|
27225
|
+
} else {
|
|
27226
|
+
const dossierSection = await projectCaseDossierPointerSection({
|
|
27227
|
+
ticketNumber: admitted.ticketNumber,
|
|
27228
|
+
projectRoot: admitted.projectRoot,
|
|
27229
|
+
home: env.home
|
|
27230
|
+
});
|
|
27231
|
+
if (dossierSection !== void 0) {
|
|
27232
|
+
turnRequest = {
|
|
27233
|
+
...turnRequest,
|
|
27234
|
+
continuation: appendContinuationSection(
|
|
27235
|
+
turnRequest.continuation,
|
|
27236
|
+
dossierSection
|
|
27237
|
+
)
|
|
27238
|
+
};
|
|
27239
|
+
}
|
|
27037
27240
|
}
|
|
27038
27241
|
await markRunRunning(
|
|
27039
27242
|
admitted.runDirectory,
|
|
@@ -27063,8 +27266,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
27063
27266
|
}
|
|
27064
27267
|
let stderrLogWriteFailure;
|
|
27065
27268
|
try {
|
|
27066
|
-
await
|
|
27067
|
-
|
|
27269
|
+
await writeFile8(
|
|
27270
|
+
join27(admitted.runDirectory, "stderr.log"),
|
|
27068
27271
|
result2.stderr,
|
|
27069
27272
|
"utf8"
|
|
27070
27273
|
);
|
|
@@ -27253,25 +27456,17 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
27253
27456
|
}
|
|
27254
27457
|
}
|
|
27255
27458
|
function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
|
|
27256
|
-
const
|
|
27257
|
-
const withReread = (body) => {
|
|
27258
|
-
if (officerSourcePath === void 0 || admitted.role !== "notary" && admitted.role !== "inspector" && admitted.role !== "auditor") {
|
|
27259
|
-
return body;
|
|
27260
|
-
}
|
|
27261
|
-
if (body.startsWith("\u8BF7\u91CD\u8BFB")) return body;
|
|
27262
|
-
return `\u8BF7\u91CD\u8BFB
|
|
27263
|
-
${body}`;
|
|
27264
|
-
};
|
|
27459
|
+
const officerDialogue = isStationChildOfficerDialogue(admitted.role, env);
|
|
27265
27460
|
let prompt;
|
|
27266
27461
|
if (request.message !== void 0) {
|
|
27267
27462
|
if (summonsPrepared !== void 0) {
|
|
27268
|
-
prompt =
|
|
27463
|
+
prompt = officerDialogue ? request.message : buildInstructionTransportPrompt({
|
|
27269
27464
|
instruction: request.message,
|
|
27270
27465
|
instructionEmpty: false,
|
|
27271
27466
|
attachments: summonsPrepared.attachments
|
|
27272
|
-
})
|
|
27467
|
+
});
|
|
27273
27468
|
} else if (request.summons !== void 0) {
|
|
27274
|
-
prompt =
|
|
27469
|
+
prompt = request.message;
|
|
27275
27470
|
} else {
|
|
27276
27471
|
prompt = buildResumeContinuationPrompt({
|
|
27277
27472
|
packageRoot: env.packageRoot,
|
|
@@ -27280,17 +27475,9 @@ ${body}`;
|
|
|
27280
27475
|
});
|
|
27281
27476
|
}
|
|
27282
27477
|
} else if (summonsPrepared !== void 0) {
|
|
27283
|
-
prompt =
|
|
27478
|
+
prompt = officerDialogue ? summonsPrepared.instructionEmpty ? "" : summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
|
|
27284
27479
|
} else if (request.summons !== void 0) {
|
|
27285
|
-
|
|
27286
|
-
if (path !== void 0 && (admitted.role === "notary" || admitted.role === "inspector" || admitted.role === "auditor")) {
|
|
27287
|
-
prompt = `\u8BF7\u91CD\u8BFB
|
|
27288
|
-
${GATE_DOSSIER_POINTER_PREFIX}${path}`;
|
|
27289
|
-
} else if (admitted.role === "notary" || admitted.role === "inspector" || admitted.role === "auditor") {
|
|
27290
|
-
prompt = "\u8BF7\u91CD\u8BFB";
|
|
27291
|
-
} else {
|
|
27292
|
-
prompt = "";
|
|
27293
|
-
}
|
|
27480
|
+
prompt = "";
|
|
27294
27481
|
} else {
|
|
27295
27482
|
prompt = buildResumeContinuationPrompt({
|
|
27296
27483
|
packageRoot: env.packageRoot,
|
|
@@ -27327,7 +27514,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
27327
27514
|
}
|
|
27328
27515
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
27329
27516
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve9(attachmentPath);
|
|
27330
|
-
return pathContainedIn(
|
|
27517
|
+
return pathContainedIn(join27(runDirectory, "attachments"), absolute);
|
|
27331
27518
|
}
|
|
27332
27519
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
27333
27520
|
if (summons === void 0) return void 0;
|
|
@@ -27623,6 +27810,7 @@ var init_post_admission = __esm({
|
|
|
27623
27810
|
init_activation_ledger_topology();
|
|
27624
27811
|
init_engine_material();
|
|
27625
27812
|
init_session_identity();
|
|
27813
|
+
init_host_contracts();
|
|
27626
27814
|
init_case_dossier_delivery();
|
|
27627
27815
|
init_host_transition_prior_native();
|
|
27628
27816
|
init_public_run_credentials();
|
|
@@ -27862,7 +28050,7 @@ function instructionSeatAdapters(options) {
|
|
|
27862
28050
|
}) => {
|
|
27863
28051
|
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
27864
28052
|
return infrastructureFailure === void 0 ? result2.knownFailure : {
|
|
27865
|
-
cause: infrastructureFailure.cause,
|
|
28053
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
27866
28054
|
diagnostic: infrastructureFailure.diagnostic,
|
|
27867
28055
|
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
27868
28056
|
};
|
|
@@ -27984,7 +28172,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
27984
28172
|
return { exitCode: 2 };
|
|
27985
28173
|
}
|
|
27986
28174
|
}
|
|
27987
|
-
const resumeInstruction = env.reviewReask;
|
|
28175
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
27988
28176
|
const summons = {
|
|
27989
28177
|
...resumeInstruction === void 0 ? {
|
|
27990
28178
|
instruction: parsed.instruction,
|
|
@@ -28050,7 +28238,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
28050
28238
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
28051
28239
|
continuation: {
|
|
28052
28240
|
kind: "initial",
|
|
28053
|
-
|
|
28241
|
+
// #879: gate first mint uses parent payload as content when present.
|
|
28242
|
+
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(
|
|
28054
28243
|
admitted,
|
|
28055
28244
|
engineSessionMaterialFromOptions({
|
|
28056
28245
|
...pickEngineAxis(env),
|
|
@@ -28169,7 +28358,7 @@ function collectorAdapters() {
|
|
|
28169
28358
|
resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
|
|
28170
28359
|
const infrastructureFailure = await readCollectorInfrastructureFailure(sessionFile);
|
|
28171
28360
|
return result2.knownFailure ?? (infrastructureFailure === void 0 ? void 0 : {
|
|
28172
|
-
cause: infrastructureFailure.cause,
|
|
28361
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
28173
28362
|
diagnostic: infrastructureFailure.diagnostic,
|
|
28174
28363
|
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
28175
28364
|
});
|
|
@@ -28255,7 +28444,7 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
28255
28444
|
throw error;
|
|
28256
28445
|
}
|
|
28257
28446
|
{
|
|
28258
|
-
const resumeInstruction = env.reviewReask;
|
|
28447
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
28259
28448
|
const summons = {
|
|
28260
28449
|
sourceRunPath: source.runDirectory,
|
|
28261
28450
|
sourceRun: source,
|
|
@@ -28310,7 +28499,9 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
28310
28499
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
28311
28500
|
continuation: {
|
|
28312
28501
|
kind: "initial",
|
|
28313
|
-
|
|
28502
|
+
// #879: gate path first mint carries parent payload as dialogue content;
|
|
28503
|
+
// external zero-prompt kickoff unchanged when no body/reask.
|
|
28504
|
+
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildNotaryTransportPrompt(admitted, engineMaterial)
|
|
28314
28505
|
}
|
|
28315
28506
|
});
|
|
28316
28507
|
return await runPostAdmissionOneShot({
|
|
@@ -28398,12 +28589,20 @@ __export(inspector_run_exports, {
|
|
|
28398
28589
|
runPublicInspector: () => runPublicInspector,
|
|
28399
28590
|
runPublicInspectorResume: () => runPublicInspectorResume
|
|
28400
28591
|
});
|
|
28592
|
+
function inspectorParentRunPath(admitted) {
|
|
28593
|
+
if (typeof admitted.sourceRunPath === "string" && admitted.sourceRunPath.trim() !== "") {
|
|
28594
|
+
return admitted.sourceRunPath;
|
|
28595
|
+
}
|
|
28596
|
+
return parentRunPathFromGatePointerInstruction(admitted.instruction);
|
|
28597
|
+
}
|
|
28401
28598
|
function buildInspectorTurnRequest(admitted, options) {
|
|
28599
|
+
const sourceRun = inspectorParentRunPath(admitted);
|
|
28402
28600
|
return projectRoleTurnRequest(
|
|
28403
28601
|
admitted,
|
|
28404
28602
|
{
|
|
28405
28603
|
activation: {
|
|
28406
|
-
role: "inspector"
|
|
28604
|
+
role: "inspector",
|
|
28605
|
+
...sourceRun === void 0 ? {} : { sourceRun }
|
|
28407
28606
|
}
|
|
28408
28607
|
},
|
|
28409
28608
|
options
|
|
@@ -28423,7 +28622,7 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
28423
28622
|
const projectRoot = parsed.project ?? env.cwd;
|
|
28424
28623
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction);
|
|
28425
28624
|
if (parentRunPath !== void 0) {
|
|
28426
|
-
const resumeInstruction = env.reviewReask;
|
|
28625
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
28427
28626
|
const summons = {
|
|
28428
28627
|
sourceRunPath: parentRunPath,
|
|
28429
28628
|
...resumeInstruction === void 0 ? {
|
|
@@ -28468,6 +28667,10 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
28468
28667
|
throw error;
|
|
28469
28668
|
}
|
|
28470
28669
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
28670
|
+
if (parentRunPath !== void 0) {
|
|
28671
|
+
await persistAdmittedSourceRunPath(admitted, parentRunPath);
|
|
28672
|
+
admitted = { ...admitted, sourceRunPath: parentRunPath };
|
|
28673
|
+
}
|
|
28471
28674
|
const engineMaterial = engineSessionMaterialFromOptions({
|
|
28472
28675
|
...pickEngineAxis(env),
|
|
28473
28676
|
packageRoot: env.packageRoot
|
|
@@ -28482,7 +28685,8 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
28482
28685
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
28483
28686
|
continuation: {
|
|
28484
28687
|
kind: "initial",
|
|
28485
|
-
|
|
28688
|
+
// #879: gate first mint uses parent payload as content; binding stays typed activation.
|
|
28689
|
+
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInspectorTransportPrompt(admitted, engineMaterial)
|
|
28486
28690
|
}
|
|
28487
28691
|
});
|
|
28488
28692
|
return await runPostAdmissionOneShot({
|
|
@@ -28560,7 +28764,7 @@ function judgeAdapters() {
|
|
|
28560
28764
|
resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
|
|
28561
28765
|
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
28562
28766
|
return result2.knownFailure ?? (infrastructureFailure === void 0 ? void 0 : {
|
|
28563
|
-
cause: infrastructureFailure.cause,
|
|
28767
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
28564
28768
|
diagnostic: infrastructureFailure.diagnostic,
|
|
28565
28769
|
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
28566
28770
|
});
|
|
@@ -28872,15 +29076,11 @@ async function runPublicDiarist(argv, env, io, parseDiaristArgv2) {
|
|
|
28872
29076
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
28873
29077
|
}).then(async (result2) => {
|
|
28874
29078
|
if (admitted.ticketNumber === void 0 && result2.admitted !== void 0) {
|
|
28875
|
-
const
|
|
28876
|
-
|
|
28877
|
-
|
|
28878
|
-
|
|
28879
|
-
|
|
28880
|
-
admitted.ticketNumber = raw;
|
|
28881
|
-
if (result2.admitted.ticketNumber === void 0) {
|
|
28882
|
-
result2.admitted.ticketNumber = raw;
|
|
28883
|
-
}
|
|
29079
|
+
const fromPages = await readRunTicketNumber(admitted.runDirectory);
|
|
29080
|
+
if (fromPages !== void 0) {
|
|
29081
|
+
await bindAdmittedTicketNumber(admitted, fromPages);
|
|
29082
|
+
if (result2.admitted.ticketNumber === void 0) {
|
|
29083
|
+
result2.admitted.ticketNumber = fromPages;
|
|
28884
29084
|
}
|
|
28885
29085
|
}
|
|
28886
29086
|
}
|
|
@@ -28922,8 +29122,8 @@ var init_diarist_run = __esm({
|
|
|
28922
29122
|
init_run_lifecycle();
|
|
28923
29123
|
init_seat_ticket_binding();
|
|
28924
29124
|
init_settlement();
|
|
28925
|
-
init_terminal();
|
|
28926
29125
|
init_turn_request();
|
|
29126
|
+
init_run_ticket_number();
|
|
28927
29127
|
}
|
|
28928
29128
|
});
|
|
28929
29129
|
|
|
@@ -28936,7 +29136,7 @@ __export(public_role_summons_exports, {
|
|
|
28936
29136
|
summonPublicRole: () => summonPublicRole
|
|
28937
29137
|
});
|
|
28938
29138
|
import { existsSync as existsSync9 } from "node:fs";
|
|
28939
|
-
import { join as
|
|
29139
|
+
import { join as join28 } from "node:path";
|
|
28940
29140
|
function createCapturingIo() {
|
|
28941
29141
|
const chunks = [];
|
|
28942
29142
|
return {
|
|
@@ -28959,7 +29159,7 @@ function parentDir(path) {
|
|
|
28959
29159
|
function walkPackageRoot(start) {
|
|
28960
29160
|
let dir = start;
|
|
28961
29161
|
for (let i = 0; i < 12; i += 1) {
|
|
28962
|
-
if (existsSync9(
|
|
29162
|
+
if (existsSync9(join28(dir, "package.json")) && existsSync9(join28(dir, "souls"))) {
|
|
28963
29163
|
return dir;
|
|
28964
29164
|
}
|
|
28965
29165
|
const parent = parentDir(dir);
|
|
@@ -29053,7 +29253,7 @@ async function createSummonEnv(options) {
|
|
|
29053
29253
|
async function summonPublicRole(options) {
|
|
29054
29254
|
const packageRoot2 = resolveSummonsPackageRoot(options.packageRoot);
|
|
29055
29255
|
const home = await resolveSummonHome(options);
|
|
29056
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
29256
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join28(home, ".pi", "agent");
|
|
29057
29257
|
const {
|
|
29058
29258
|
loadCredentialProviders: loadCredentialProviders2,
|
|
29059
29259
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -29094,6 +29294,8 @@ async function summonPublicRole(options) {
|
|
|
29094
29294
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
29095
29295
|
// #753: reask rides the existing notary same-ticket resume summons.instruction.
|
|
29096
29296
|
...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
|
|
29297
|
+
// #879: verbatim submission body on officer dialogue content channel.
|
|
29298
|
+
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
|
|
29097
29299
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
29098
29300
|
// createRunId is the only remaining env overlay — host is seat-selected above.
|
|
29099
29301
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
@@ -29201,6 +29403,11 @@ async function summonGateOfficer(options) {
|
|
|
29201
29403
|
const { homeFromRunDirectory: homeFromRunDirectory3 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
|
|
29202
29404
|
home = homeFromRunDirectory3(options.sourceRunDirectory);
|
|
29203
29405
|
}
|
|
29406
|
+
let gateReviewInstruction;
|
|
29407
|
+
if (options.reask === void 0 && options.submission !== void 0) {
|
|
29408
|
+
const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
|
|
29409
|
+
gateReviewInstruction = readableGateItem2(options.submission);
|
|
29410
|
+
}
|
|
29204
29411
|
const common = {
|
|
29205
29412
|
cwd: options.cwd,
|
|
29206
29413
|
...home === void 0 ? {} : { home },
|
|
@@ -29208,6 +29415,7 @@ async function summonGateOfficer(options) {
|
|
|
29208
29415
|
...options.io === void 0 ? {} : { io: options.io },
|
|
29209
29416
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
29210
29417
|
...options.reask === void 0 ? {} : { reviewReask: options.reask },
|
|
29418
|
+
...gateReviewInstruction === void 0 ? {} : { gateReviewInstruction },
|
|
29211
29419
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
29212
29420
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
29213
29421
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
@@ -29261,6 +29469,16 @@ function buildCountersignTurnRequest(admitted, options) {
|
|
|
29261
29469
|
options
|
|
29262
29470
|
);
|
|
29263
29471
|
}
|
|
29472
|
+
function courtDiaristEscalated(roleOutcome) {
|
|
29473
|
+
if (roleOutcome === void 0) return false;
|
|
29474
|
+
if (roleOutcome.kind === "audit_escalation") return true;
|
|
29475
|
+
if (roleOutcome.kind !== "accepted") return false;
|
|
29476
|
+
return (roleOutcome.payloads ?? []).some((payload) => {
|
|
29477
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return false;
|
|
29478
|
+
const record4 = payload;
|
|
29479
|
+
return record4.status === "escalate" || record4.countersignStatus === "escalate";
|
|
29480
|
+
});
|
|
29481
|
+
}
|
|
29264
29482
|
async function invokeCourtDiarist(input, env, io) {
|
|
29265
29483
|
const quietIo = {
|
|
29266
29484
|
stdout() {
|
|
@@ -29286,13 +29504,10 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
29286
29504
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters }
|
|
29287
29505
|
});
|
|
29288
29506
|
const roleOutcome = result2.terminal?.roleOutcome;
|
|
29289
|
-
if (
|
|
29290
|
-
|
|
29291
|
-
|
|
29292
|
-
|
|
29293
|
-
const reason = typeof facts?.reason === "string" ? facts.reason : "diarist escalated without reason";
|
|
29294
|
-
return { identity: { kind: "escalate", reason } };
|
|
29295
|
-
}
|
|
29507
|
+
if (courtDiaristEscalated(roleOutcome)) {
|
|
29508
|
+
return {
|
|
29509
|
+
identity: { kind: "escalate" }
|
|
29510
|
+
};
|
|
29296
29511
|
}
|
|
29297
29512
|
if (result2.exitCode !== 0) {
|
|
29298
29513
|
const diagnostic = roleOutcome?.kind === "failure" ? roleOutcome.diagnostic : result2.stderr?.trim() || `exit ${result2.exitCode}`;
|
|
@@ -29305,9 +29520,13 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
29305
29520
|
}
|
|
29306
29521
|
const asserted = result2.admitted?.ticketNumber;
|
|
29307
29522
|
if (typeof asserted === "number" && Number.isSafeInteger(asserted) && asserted >= 1) {
|
|
29308
|
-
return {
|
|
29523
|
+
return {
|
|
29524
|
+
identity: { kind: "ticket", ticketNumber: asserted }
|
|
29525
|
+
};
|
|
29309
29526
|
}
|
|
29310
|
-
return {
|
|
29527
|
+
return {
|
|
29528
|
+
identity: { kind: "unbound" }
|
|
29529
|
+
};
|
|
29311
29530
|
}
|
|
29312
29531
|
async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
29313
29532
|
if (env.runCourtDiaristStation !== void 0) {
|
|
@@ -29328,7 +29547,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
29328
29547
|
);
|
|
29329
29548
|
if (outcome.identity.kind === "escalate") {
|
|
29330
29549
|
throw new StationChildExhaustedError(
|
|
29331
|
-
|
|
29550
|
+
"court diarist station escalated (cannot identify court target)"
|
|
29332
29551
|
);
|
|
29333
29552
|
}
|
|
29334
29553
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
@@ -29388,7 +29607,7 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
29388
29607
|
code: null,
|
|
29389
29608
|
stderr: "",
|
|
29390
29609
|
thrown: new Error(
|
|
29391
|
-
|
|
29610
|
+
"court diarist station escalated (cannot identify court target)"
|
|
29392
29611
|
)
|
|
29393
29612
|
},
|
|
29394
29613
|
countersignAdapters(),
|
|
@@ -29534,7 +29753,6 @@ var init_countersign_run = __esm({
|
|
|
29534
29753
|
init_run_lifecycle();
|
|
29535
29754
|
init_seat_ticket_binding();
|
|
29536
29755
|
init_settlement();
|
|
29537
|
-
init_terminal();
|
|
29538
29756
|
init_turn_request();
|
|
29539
29757
|
}
|
|
29540
29758
|
});
|
|
@@ -30019,7 +30237,7 @@ function reviewerAdapters(packageRoot2, methodMaterial) {
|
|
|
30019
30237
|
resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
|
|
30020
30238
|
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
30021
30239
|
return infrastructureFailure === void 0 ? result2.knownFailure : {
|
|
30022
|
-
cause: infrastructureFailure.cause,
|
|
30240
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
30023
30241
|
diagnostic: infrastructureFailure.diagnostic,
|
|
30024
30242
|
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
30025
30243
|
};
|
|
@@ -30185,16 +30403,16 @@ var init_analyst_book_key = __esm({
|
|
|
30185
30403
|
|
|
30186
30404
|
// src/atomic-write.ts
|
|
30187
30405
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
30188
|
-
import { rename as rename2, rm, writeFile as
|
|
30189
|
-
import { dirname as dirname14, join as
|
|
30406
|
+
import { rename as rename2, rm as rm2, writeFile as writeFile9 } from "node:fs/promises";
|
|
30407
|
+
import { dirname as dirname14, join as join29 } from "node:path";
|
|
30190
30408
|
async function writeFileAtomically(destination, contents) {
|
|
30191
30409
|
const parent = dirname14(destination);
|
|
30192
|
-
const temporary =
|
|
30410
|
+
const temporary = join29(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
30193
30411
|
try {
|
|
30194
|
-
await
|
|
30412
|
+
await writeFile9(temporary, contents);
|
|
30195
30413
|
await rename2(temporary, destination);
|
|
30196
30414
|
} catch (error) {
|
|
30197
|
-
await
|
|
30415
|
+
await rm2(temporary, { force: true }).catch(() => void 0);
|
|
30198
30416
|
throw error;
|
|
30199
30417
|
}
|
|
30200
30418
|
}
|
|
@@ -30205,8 +30423,8 @@ var init_atomic_write = __esm({
|
|
|
30205
30423
|
});
|
|
30206
30424
|
|
|
30207
30425
|
// src/analyst-index.ts
|
|
30208
|
-
import { open as open3, readFile as
|
|
30209
|
-
import { dirname as dirname15, join as
|
|
30426
|
+
import { open as open3, readFile as readFile20, unlink as unlink4 } from "node:fs/promises";
|
|
30427
|
+
import { dirname as dirname15, join as join30 } from "node:path";
|
|
30210
30428
|
function sleep(ms) {
|
|
30211
30429
|
return new Promise((resolve11) => {
|
|
30212
30430
|
setTimeout(resolve11, ms);
|
|
@@ -30215,7 +30433,7 @@ function sleep(ms) {
|
|
|
30215
30433
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
30216
30434
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
30217
30435
|
ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
|
|
30218
|
-
const lockPath =
|
|
30436
|
+
const lockPath = join30(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
30219
30437
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
30220
30438
|
const startedAt = Date.now();
|
|
30221
30439
|
while (true) {
|
|
@@ -30242,7 +30460,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
30242
30460
|
}
|
|
30243
30461
|
}
|
|
30244
30462
|
function analystLibraryIndexPath(ledgerHome) {
|
|
30245
|
-
return
|
|
30463
|
+
return join30(ledgerHome, "analyst", "library-index.json");
|
|
30246
30464
|
}
|
|
30247
30465
|
function rowFromIssueMetricsPage(page) {
|
|
30248
30466
|
return {
|
|
@@ -30333,7 +30551,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
30333
30551
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
30334
30552
|
let raw;
|
|
30335
30553
|
try {
|
|
30336
|
-
raw = await
|
|
30554
|
+
raw = await readFile20(path, "utf8");
|
|
30337
30555
|
} catch (error) {
|
|
30338
30556
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
30339
30557
|
return void 0;
|
|
@@ -30537,8 +30755,8 @@ var init_analyst_cohort = __esm({
|
|
|
30537
30755
|
});
|
|
30538
30756
|
|
|
30539
30757
|
// src/analyst-ledger.ts
|
|
30540
|
-
import { readdir as readdir7, readFile as
|
|
30541
|
-
import { join as
|
|
30758
|
+
import { readdir as readdir7, readFile as readFile21 } from "node:fs/promises";
|
|
30759
|
+
import { join as join31 } from "node:path";
|
|
30542
30760
|
function isMissingPathError5(error) {
|
|
30543
30761
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
30544
30762
|
}
|
|
@@ -30551,7 +30769,7 @@ function isRecord10(value) {
|
|
|
30551
30769
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
30552
30770
|
try {
|
|
30553
30771
|
const raw = JSON.parse(
|
|
30554
|
-
await
|
|
30772
|
+
await readFile21(join31(runDirectory, "run-state.json"), "utf8")
|
|
30555
30773
|
);
|
|
30556
30774
|
if (!isRecord10(raw) || typeof raw.state !== "string") return void 0;
|
|
30557
30775
|
return raw.state;
|
|
@@ -30583,7 +30801,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
30583
30801
|
async function readInvocationScopeFields(runDirectory) {
|
|
30584
30802
|
let raw;
|
|
30585
30803
|
try {
|
|
30586
|
-
raw = await
|
|
30804
|
+
raw = await readFile21(join31(runDirectory, "invocation.json"), "utf8");
|
|
30587
30805
|
} catch (error) {
|
|
30588
30806
|
if (isMissingPathError5(error)) return void 0;
|
|
30589
30807
|
throw error;
|
|
@@ -30615,7 +30833,7 @@ function decideIssueScope(input) {
|
|
|
30615
30833
|
}
|
|
30616
30834
|
async function resolveSessionFile(runDirectory) {
|
|
30617
30835
|
try {
|
|
30618
|
-
const raw = await
|
|
30836
|
+
const raw = await readFile21(join31(runDirectory, "invocation.json"), "utf8");
|
|
30619
30837
|
const parsed = JSON.parse(raw);
|
|
30620
30838
|
if (isRecord10(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
30621
30839
|
return parsed.sessionFile;
|
|
@@ -30623,7 +30841,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
30623
30841
|
} catch (error) {
|
|
30624
30842
|
if (!isMissingPathError5(error)) throw error;
|
|
30625
30843
|
}
|
|
30626
|
-
return
|
|
30844
|
+
return join31(runDirectory, "session", "session.jsonl");
|
|
30627
30845
|
}
|
|
30628
30846
|
function attributeSessionRowsForRun(input) {
|
|
30629
30847
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -30795,9 +31013,9 @@ async function classifyScopedRun(input) {
|
|
|
30795
31013
|
}
|
|
30796
31014
|
let gateCycles;
|
|
30797
31015
|
try {
|
|
30798
|
-
const parentSessionFile =
|
|
31016
|
+
const parentSessionFile = join31(input.runDirectory, "session", "session.jsonl");
|
|
30799
31017
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
30800
|
-
|
|
31018
|
+
join31(input.runDirectory, "session", "auditor-roles"),
|
|
30801
31019
|
{ parentSessionFile }
|
|
30802
31020
|
);
|
|
30803
31021
|
} catch (error) {
|
|
@@ -30830,7 +31048,7 @@ async function classifyScopedRun(input) {
|
|
|
30830
31048
|
async function scanAnalystIssueRuns(input) {
|
|
30831
31049
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
30832
31050
|
const scopeTicketNumber = input.ticketNumber;
|
|
30833
|
-
const booksRoot =
|
|
31051
|
+
const booksRoot = join31(ledgerHome, "books");
|
|
30834
31052
|
let wholeBook = false;
|
|
30835
31053
|
let scopeRootIdentity;
|
|
30836
31054
|
let bookNames;
|
|
@@ -30862,7 +31080,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
30862
31080
|
const unreadable = [];
|
|
30863
31081
|
const scopeConflicts = [];
|
|
30864
31082
|
for (const book of bookNames) {
|
|
30865
|
-
const runsDir =
|
|
31083
|
+
const runsDir = join31(booksRoot, book, "runs");
|
|
30866
31084
|
let runNames;
|
|
30867
31085
|
try {
|
|
30868
31086
|
const entries = await readdir7(runsDir, { withFileTypes: true });
|
|
@@ -30874,7 +31092,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
30874
31092
|
for (const runName of runNames) {
|
|
30875
31093
|
const parsed = parseRunDirectoryName2(runName);
|
|
30876
31094
|
if (parsed === void 0) continue;
|
|
30877
|
-
const runDirectory =
|
|
31095
|
+
const runDirectory = join31(runsDir, runName);
|
|
30878
31096
|
let scopeFields;
|
|
30879
31097
|
try {
|
|
30880
31098
|
scopeFields = await readInvocationScopeFields(runDirectory);
|
|
@@ -31728,7 +31946,7 @@ var init_analyst_metric_family = __esm({
|
|
|
31728
31946
|
|
|
31729
31947
|
// src/analyst-page.ts
|
|
31730
31948
|
import { createHash as createHash5 } from "node:crypto";
|
|
31731
|
-
import { dirname as dirname16, join as
|
|
31949
|
+
import { dirname as dirname16, join as join32 } from "node:path";
|
|
31732
31950
|
function analystIssuePageKey(address) {
|
|
31733
31951
|
const parts = ["book", address.bookKey];
|
|
31734
31952
|
if (address.issueNumber !== void 0) {
|
|
@@ -31739,7 +31957,7 @@ function analystIssuePageKey(address) {
|
|
|
31739
31957
|
return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
31740
31958
|
}
|
|
31741
31959
|
function analystIssuePagePath(ledgerHome, address) {
|
|
31742
|
-
return
|
|
31960
|
+
return join32(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
31743
31961
|
}
|
|
31744
31962
|
function analystIssuePageAddressFromPage(page) {
|
|
31745
31963
|
return {
|
|
@@ -31875,7 +32093,7 @@ var init_analyst_page = __esm({
|
|
|
31875
32093
|
});
|
|
31876
32094
|
|
|
31877
32095
|
// src/analyst-entry.ts
|
|
31878
|
-
import { readFile as
|
|
32096
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
31879
32097
|
function isMissingPathError6(error) {
|
|
31880
32098
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
31881
32099
|
}
|
|
@@ -31905,7 +32123,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
31905
32123
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
31906
32124
|
});
|
|
31907
32125
|
try {
|
|
31908
|
-
const raw = await
|
|
32126
|
+
const raw = await readFile22(pagePath, "utf8");
|
|
31909
32127
|
const page = JSON.parse(raw);
|
|
31910
32128
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
31911
32129
|
return { mode: "issue", page, pagePath };
|
|
@@ -32000,7 +32218,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
32000
32218
|
scopeRootIdentity: projectRoot
|
|
32001
32219
|
});
|
|
32002
32220
|
try {
|
|
32003
|
-
const raw = await
|
|
32221
|
+
const raw = await readFile22(pagePath, "utf8");
|
|
32004
32222
|
JSON.parse(raw);
|
|
32005
32223
|
} catch (error) {
|
|
32006
32224
|
if (!isMissingPathError6(error)) {
|
|
@@ -32099,7 +32317,7 @@ var init_analyst_entry = __esm({
|
|
|
32099
32317
|
});
|
|
32100
32318
|
|
|
32101
32319
|
// src/public-cli/analyst-run.ts
|
|
32102
|
-
import { readFile as
|
|
32320
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
32103
32321
|
import { isAbsolute as isAbsolute10, resolve as resolve10 } from "node:path";
|
|
32104
32322
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
32105
32323
|
try {
|
|
@@ -32152,7 +32370,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
32152
32370
|
const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve10(sourcePath);
|
|
32153
32371
|
let bytes;
|
|
32154
32372
|
try {
|
|
32155
|
-
bytes = await
|
|
32373
|
+
bytes = await readFile23(absolute);
|
|
32156
32374
|
} catch (error) {
|
|
32157
32375
|
throw new CliUsageError(
|
|
32158
32376
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -32272,7 +32490,7 @@ __export(cli_exports, {
|
|
|
32272
32490
|
runAkRole: () => runAkRole
|
|
32273
32491
|
});
|
|
32274
32492
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
32275
|
-
import { join as
|
|
32493
|
+
import { join as join33 } from "node:path";
|
|
32276
32494
|
function takePublicGlobalFlag(argv, index, options) {
|
|
32277
32495
|
const tokens = argv.slice(index);
|
|
32278
32496
|
const taken = options.takeDashed(tokens);
|
|
@@ -32369,7 +32587,7 @@ function resolveHome(env) {
|
|
|
32369
32587
|
return env.home ?? packageMachineHome();
|
|
32370
32588
|
}
|
|
32371
32589
|
function resolveAgentDir(env, home) {
|
|
32372
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
32590
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join33(home, ".pi", "agent");
|
|
32373
32591
|
}
|
|
32374
32592
|
function parseThinking(value) {
|
|
32375
32593
|
return value;
|
|
@@ -33296,10 +33514,10 @@ async function runAkRole(argv, env) {
|
|
|
33296
33514
|
if (error.cause !== void 0) {
|
|
33297
33515
|
const detail = formatErrorCauseDetail(error.cause);
|
|
33298
33516
|
if (detail.trim().length > 0) {
|
|
33299
|
-
label = `${label || error.name || "
|
|
33517
|
+
label = `${label || error.name || "exception"}; cause: ${detail}`;
|
|
33300
33518
|
}
|
|
33301
33519
|
}
|
|
33302
|
-
io.stderr(formatCliDiagnostic(label || error.name || "
|
|
33520
|
+
io.stderr(formatCliDiagnostic(label || error.name || "exception"));
|
|
33303
33521
|
return { exitCode: 1 };
|
|
33304
33522
|
}
|
|
33305
33523
|
io.stderr(formatCliDiagnostic(String(error)));
|
|
@@ -33384,7 +33602,7 @@ var init_cli = __esm({
|
|
|
33384
33602
|
|
|
33385
33603
|
// src/public-cli/main.ts
|
|
33386
33604
|
import { existsSync as existsSync10 } from "node:fs";
|
|
33387
|
-
import { dirname as dirname17, join as
|
|
33605
|
+
import { dirname as dirname17, join as join34 } from "node:path";
|
|
33388
33606
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33389
33607
|
|
|
33390
33608
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -33473,8 +33691,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
33473
33691
|
// src/public-cli/main.ts
|
|
33474
33692
|
var here = dirname17(fileURLToPath2(import.meta.url));
|
|
33475
33693
|
function resolvePackageRoot(binDir) {
|
|
33476
|
-
const canonical =
|
|
33477
|
-
if (existsSync10(
|
|
33694
|
+
const canonical = join34(binDir, "..", "..");
|
|
33695
|
+
if (existsSync10(join34(canonical, "package.json"))) {
|
|
33478
33696
|
return canonical;
|
|
33479
33697
|
}
|
|
33480
33698
|
return binDir;
|