@akagilnc/pi-workflow-roles 0.1.4035 → 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 +476 -250
- 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 +503 -264
- package/dist/host-contracts.js +16 -0
- package/dist/inspector-contracts.js +8 -0
- package/dist/packaged-role-registry.js +1 -1
- package/dist/pi/role-turn-host.js +43 -13
- package/dist/public-cli/case-dossier-delivery.js +60 -1
- package/dist/public-cli/inspector-run.js +17 -3
- package/dist/public-cli/instruction-seat-run.js +9 -6
- package/dist/public-cli/main.js +239 -112
- 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 +24 -7
- package/dist/public-role-summons.js +8 -0
- package/dist/submission-ledger.js +30 -8
- 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 +22 -3
- package/src/inspector-contracts.ts +7 -0
- package/src/judge-role.ts +4 -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/role-turn-host.ts +48 -14
- package/src/public-cli/case-dossier-delivery.ts +86 -1
- package/src/public-cli/inspector-run.ts +26 -2
- package/src/public-cli/instruction-seat-run.ts +17 -9
- package/src/public-cli/invocation.ts +2 -0
- package/src/public-cli/notary-run.ts +13 -4
- package/src/public-cli/post-admission.ts +74 -65
- package/src/public-cli/run-lifecycle.ts +3 -0
- package/src/public-cli/settlement.ts +32 -6
- 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 +48 -13
- package/src/user-dialogue-stdin.ts +37 -0
- package/src/worker-role.ts +4 -0
|
@@ -790,9 +790,17 @@ var init_auditor_dossier_tool = __esm({
|
|
|
790
790
|
});
|
|
791
791
|
|
|
792
792
|
// src/readable-gate-item.ts
|
|
793
|
+
var readable_gate_item_exports = {};
|
|
794
|
+
__export(readable_gate_item_exports, {
|
|
795
|
+
joinReadableGateItems: () => joinReadableGateItems,
|
|
796
|
+
readableGateItem: () => readableGateItem
|
|
797
|
+
});
|
|
793
798
|
function readableGateItem(value) {
|
|
794
799
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
795
800
|
}
|
|
801
|
+
function joinReadableGateItems(items, separator = "; ") {
|
|
802
|
+
return items.map(readableGateItem).join(separator);
|
|
803
|
+
}
|
|
796
804
|
var init_readable_gate_item = __esm({
|
|
797
805
|
"src/readable-gate-item.ts"() {
|
|
798
806
|
"use strict";
|
|
@@ -859,12 +867,19 @@ var init_submission_errors = __esm({
|
|
|
859
867
|
});
|
|
860
868
|
|
|
861
869
|
// src/inspector-contracts.ts
|
|
862
|
-
var INSPECTOR_OUTPUT_TOOL_NAME, INSPECTOR_ACCEPTED_TEXT;
|
|
870
|
+
var INSPECTOR_OUTPUT_TOOL_NAME, INSPECTOR_ACCEPTED_TEXT, INSPECTOR_SOURCE_RUN_FLAG;
|
|
863
871
|
var init_inspector_contracts = __esm({
|
|
864
872
|
"src/inspector-contracts.ts"() {
|
|
865
873
|
"use strict";
|
|
866
874
|
INSPECTOR_OUTPUT_TOOL_NAME = "ak_inspector_output";
|
|
867
875
|
INSPECTOR_ACCEPTED_TEXT = "\u5BDF\u9662\u56DE\u6267\u5DF2\u63A5\u53D7";
|
|
876
|
+
INSPECTOR_SOURCE_RUN_FLAG = {
|
|
877
|
+
name: "ak-inspector-source-run",
|
|
878
|
+
definition: {
|
|
879
|
+
description: "\u5BDF\u9662\u521D\u94F8\u7ED1\u5B9A\u7684\u7236 run \u7EDD\u5BF9\u8DEF\u5F84",
|
|
880
|
+
type: "string"
|
|
881
|
+
}
|
|
882
|
+
};
|
|
868
883
|
}
|
|
869
884
|
});
|
|
870
885
|
|
|
@@ -1169,6 +1184,15 @@ var init_durable_principal = __esm({
|
|
|
1169
1184
|
});
|
|
1170
1185
|
|
|
1171
1186
|
// src/host-contracts.ts
|
|
1187
|
+
function isOfficerReviewSeat(role) {
|
|
1188
|
+
return role === "notary" || role === "inspector" || role === "auditor";
|
|
1189
|
+
}
|
|
1190
|
+
function runDirectoryFromHostContext(context) {
|
|
1191
|
+
return typeof context.runDirectory === "string" && context.runDirectory.trim() !== "" ? context.runDirectory : void 0;
|
|
1192
|
+
}
|
|
1193
|
+
function courtAttemptIdFromHostContext(context) {
|
|
1194
|
+
return typeof context.courtAttemptId === "string" && context.courtAttemptId.trim() !== "" ? context.courtAttemptId : void 0;
|
|
1195
|
+
}
|
|
1172
1196
|
var ExplicitInternalActivationError;
|
|
1173
1197
|
var init_host_contracts = __esm({
|
|
1174
1198
|
"src/host-contracts.ts"() {
|
|
@@ -1901,7 +1925,7 @@ var init_packaged_role_registry = __esm({
|
|
|
1901
1925
|
role: "inspector",
|
|
1902
1926
|
phases: [null],
|
|
1903
1927
|
outputTool: INSPECTOR_OUTPUT_TOOL_NAME,
|
|
1904
|
-
inputFlag:
|
|
1928
|
+
inputFlag: "ak-inspector-source-run",
|
|
1905
1929
|
phaseFlag: void 0,
|
|
1906
1930
|
activationStage: "load-and-install",
|
|
1907
1931
|
sessionMaterials: INSPECTOR_SESSION_MATERIALS
|
|
@@ -2005,6 +2029,18 @@ var init_role_activation_flags = __esm({
|
|
|
2005
2029
|
}
|
|
2006
2030
|
});
|
|
2007
2031
|
|
|
2032
|
+
// src/user-dialogue-stdin.ts
|
|
2033
|
+
function encodeUserDialogueStdin(body) {
|
|
2034
|
+
return JSON.stringify({ kind: USER_DIALOGUE_STDIN_KIND, body });
|
|
2035
|
+
}
|
|
2036
|
+
var USER_DIALOGUE_STDIN_KIND;
|
|
2037
|
+
var init_user_dialogue_stdin = __esm({
|
|
2038
|
+
"src/user-dialogue-stdin.ts"() {
|
|
2039
|
+
"use strict";
|
|
2040
|
+
USER_DIALOGUE_STDIN_KIND = "ak-user-dialogue";
|
|
2041
|
+
}
|
|
2042
|
+
});
|
|
2043
|
+
|
|
2008
2044
|
// src/sitian-contracts.ts
|
|
2009
2045
|
function attachDirectErrnoCode(error, cause) {
|
|
2010
2046
|
if (cause === null || typeof cause !== "object" || !("code" in cause)) return;
|
|
@@ -2378,11 +2414,6 @@ function applyPiNativeSkillInvocation(methods, prompt) {
|
|
|
2378
2414
|
}
|
|
2379
2415
|
function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
2380
2416
|
const { sessionFile, sessionDirectory } = authority.decode(request.principal);
|
|
2381
|
-
const rawPrompt = request.continuation.kind === "initial" || request.continuation.kind === "resume" ? request.continuation.prompt : (() => {
|
|
2382
|
-
const _exhaustive = request.continuation;
|
|
2383
|
-
return _exhaustive;
|
|
2384
|
-
})();
|
|
2385
|
-
const prompt = applyPiNativeSkillInvocation(request.methods, rawPrompt);
|
|
2386
2417
|
return [
|
|
2387
2418
|
"--no-skills",
|
|
2388
2419
|
...buildMethodArgs(request.methods),
|
|
@@ -2396,12 +2427,24 @@ function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
|
2396
2427
|
...extraPiArgs,
|
|
2397
2428
|
// Envelope assembly = projectActivationFlags; pi only renders argv pairs.
|
|
2398
2429
|
...activationFlagsToPiArgv(projectActivationFlags(request)),
|
|
2430
|
+
...piEngineModelArgs(request),
|
|
2399
2431
|
"--mode",
|
|
2400
2432
|
"json",
|
|
2401
|
-
...buildSeatModelCliArgs(request.model)
|
|
2402
|
-
prompt
|
|
2433
|
+
...buildSeatModelCliArgs(request.model)
|
|
2403
2434
|
];
|
|
2404
2435
|
}
|
|
2436
|
+
function piEngineModelArgs(request) {
|
|
2437
|
+
const model = normalizeEngineName(request.engineModel);
|
|
2438
|
+
if (model === void 0) return [];
|
|
2439
|
+
return [`--${ENGINE_MODEL_FLAG_NAME}`, model];
|
|
2440
|
+
}
|
|
2441
|
+
function piUserDialogueBody(request) {
|
|
2442
|
+
const rawPrompt = request.continuation.kind === "initial" || request.continuation.kind === "resume" ? request.continuation.prompt : (() => {
|
|
2443
|
+
const _exhaustive = request.continuation;
|
|
2444
|
+
return _exhaustive;
|
|
2445
|
+
})();
|
|
2446
|
+
return applyPiNativeSkillInvocation(request.methods, rawPrompt);
|
|
2447
|
+
}
|
|
2405
2448
|
async function resolveSelectedPi(command, cwd, env) {
|
|
2406
2449
|
const searchPath = env.PATH ?? (platform === "win32" ? process.env.PATH ?? "" : "/usr/bin:/bin");
|
|
2407
2450
|
const candidates = isAbsolute3(command) || command.includes("/") ? [resolve6(cwd, command)] : searchPath.split(delimiter).map((dir) => resolve6(cwd, dir, command));
|
|
@@ -2441,11 +2484,22 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
2441
2484
|
const child = spawn2(piIdentity.executable, [...args], {
|
|
2442
2485
|
cwd: spawnOptions.cwd,
|
|
2443
2486
|
env: spawnOptions.env,
|
|
2444
|
-
stdio: ["
|
|
2487
|
+
stdio: ["pipe", "ignore", "pipe"]
|
|
2445
2488
|
});
|
|
2489
|
+
if (child.stdin === null) {
|
|
2490
|
+
throw new Error("Pi child stdin pipe was not created");
|
|
2491
|
+
}
|
|
2446
2492
|
if (child.stderr === null) {
|
|
2447
2493
|
throw new Error("Pi child stderr pipe was not created");
|
|
2448
2494
|
}
|
|
2495
|
+
let stdinDeliveryError;
|
|
2496
|
+
child.stdin.on("error", (error) => {
|
|
2497
|
+
stdinDeliveryError ??= error;
|
|
2498
|
+
});
|
|
2499
|
+
if (spawnOptions.stdin !== void 0) {
|
|
2500
|
+
child.stdin.write(spawnOptions.stdin);
|
|
2501
|
+
}
|
|
2502
|
+
child.stdin.end();
|
|
2449
2503
|
let stderr = "";
|
|
2450
2504
|
let timedOut = false;
|
|
2451
2505
|
let timer;
|
|
@@ -2498,6 +2552,10 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
2498
2552
|
reject(executionError);
|
|
2499
2553
|
return;
|
|
2500
2554
|
}
|
|
2555
|
+
if (stdinDeliveryError !== void 0) {
|
|
2556
|
+
reject(stdinDeliveryError);
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2501
2559
|
resolveResult({
|
|
2502
2560
|
code,
|
|
2503
2561
|
stderr,
|
|
@@ -2521,7 +2579,8 @@ function createPiRoleTurnHost(config) {
|
|
|
2521
2579
|
return {
|
|
2522
2580
|
async executeTurn(request) {
|
|
2523
2581
|
let turnRequest = request;
|
|
2524
|
-
const
|
|
2582
|
+
const officerStationChild = request.stationChild === true && isOfficerReviewSeat(request.activation.role);
|
|
2583
|
+
const paths = !officerStationChild && request.hostTransition?.priorNativeKind === "sitian" ? request.hostTransition.priorNativePaths : void 0;
|
|
2525
2584
|
if (request.continuation.kind === "resume" && paths !== void 0 && paths.length > 0) {
|
|
2526
2585
|
turnRequest = {
|
|
2527
2586
|
...request,
|
|
@@ -2539,6 +2598,7 @@ ${paths.join("\n")}`
|
|
|
2539
2598
|
config.extraPiArgs ?? []
|
|
2540
2599
|
);
|
|
2541
2600
|
const args = buildExplicitInternalActivationArgs(roleEntry, extraArgs);
|
|
2601
|
+
const stdin = encodeUserDialogueStdin(piUserDialogueBody(turnRequest));
|
|
2542
2602
|
const env = {
|
|
2543
2603
|
...process.env,
|
|
2544
2604
|
HOME: request.home,
|
|
@@ -2570,6 +2630,7 @@ ${paths.join("\n")}`
|
|
|
2570
2630
|
return await spawnRunner(args, {
|
|
2571
2631
|
cwd: request.cwd,
|
|
2572
2632
|
env,
|
|
2633
|
+
stdin,
|
|
2573
2634
|
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
2574
2635
|
...request.signal === void 0 ? {} : { signal: request.signal }
|
|
2575
2636
|
});
|
|
@@ -2613,6 +2674,7 @@ var init_role_turn_host = __esm({
|
|
|
2613
2674
|
init_host_contracts();
|
|
2614
2675
|
init_engine_detour();
|
|
2615
2676
|
init_role_activation_flags();
|
|
2677
|
+
init_user_dialogue_stdin();
|
|
2616
2678
|
init_sitian_facade();
|
|
2617
2679
|
INTERNAL_ROLE_ENTRYPOINT_RELATIVE = "extensions/role-runtime.ts";
|
|
2618
2680
|
EXPLICIT_INTERNAL_LOAD_PROBE_ARGS = [
|
|
@@ -4993,7 +5055,8 @@ async function loadResumableInspectorRun(home, runId, authority) {
|
|
|
4993
5055
|
}
|
|
4994
5056
|
const admitted = {
|
|
4995
5057
|
role: "inspector",
|
|
4996
|
-
...resumedBaseAdmitted(loaded)
|
|
5058
|
+
...resumedBaseAdmitted(loaded),
|
|
5059
|
+
...loaded.admittedFields.sourceRunPath === void 0 ? {} : { sourceRunPath: loaded.admittedFields.sourceRunPath }
|
|
4997
5060
|
};
|
|
4998
5061
|
return seatLoadedResult(loaded, admitted);
|
|
4999
5062
|
}
|
|
@@ -9720,6 +9783,15 @@ var init_ticket_provenance = __esm({
|
|
|
9720
9783
|
});
|
|
9721
9784
|
|
|
9722
9785
|
// src/public-cli/case-dossier-delivery.ts
|
|
9786
|
+
var case_dossier_delivery_exports = {};
|
|
9787
|
+
__export(case_dossier_delivery_exports, {
|
|
9788
|
+
deliverCaseDossierAsAttachment: () => deliverCaseDossierAsAttachment,
|
|
9789
|
+
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
9790
|
+
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
9791
|
+
});
|
|
9792
|
+
import { mkdtemp as mkdtemp2, readFile as readFile12, rm as rm2, writeFile as writeFile7 } from "node:fs/promises";
|
|
9793
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
9794
|
+
import { join as join21 } from "node:path";
|
|
9723
9795
|
function describeDossierFile(path) {
|
|
9724
9796
|
return path;
|
|
9725
9797
|
}
|
|
@@ -9738,18 +9810,59 @@ async function projectCaseDossierPointerSection(input) {
|
|
|
9738
9810
|
`\u8BB0\u5F55\u5377\u5B97\uFF1A${describeDossierFile(volume.recordFile)}`
|
|
9739
9811
|
].join("\n");
|
|
9740
9812
|
}
|
|
9741
|
-
|
|
9813
|
+
async function deliverCaseDossierAsAttachment(input) {
|
|
9814
|
+
const section = await projectCaseDossierPointerSection({
|
|
9815
|
+
ticketNumber: input.ticketNumber,
|
|
9816
|
+
projectRoot: input.projectRoot,
|
|
9817
|
+
home: input.home
|
|
9818
|
+
});
|
|
9819
|
+
if (section === void 0) return void 0;
|
|
9820
|
+
const stagingDir = await mkdtemp2(join21(tmpdir2(), "ak-case-dossier-"));
|
|
9821
|
+
try {
|
|
9822
|
+
const stagingPath = join21(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
9823
|
+
await writeFile7(stagingPath, `${section}
|
|
9824
|
+
`, "utf8");
|
|
9825
|
+
return await freezeAttachmentsIntoRun(
|
|
9826
|
+
[stagingPath],
|
|
9827
|
+
input.runDirectory,
|
|
9828
|
+
CASE_DOSSIER_ATTACH_KEY
|
|
9829
|
+
);
|
|
9830
|
+
} finally {
|
|
9831
|
+
await rm2(stagingDir, { recursive: true, force: true });
|
|
9832
|
+
}
|
|
9833
|
+
}
|
|
9834
|
+
async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
9835
|
+
const frozenPath = join21(
|
|
9836
|
+
runDirectory,
|
|
9837
|
+
"attachments",
|
|
9838
|
+
CASE_DOSSIER_ATTACH_KEY,
|
|
9839
|
+
`00-${CASE_DOSSIER_ATTACH_FILE}`
|
|
9840
|
+
);
|
|
9841
|
+
let section;
|
|
9842
|
+
try {
|
|
9843
|
+
section = await readFile12(frozenPath, "utf8");
|
|
9844
|
+
} catch (error) {
|
|
9845
|
+
if (error.code === "ENOENT") return void 0;
|
|
9846
|
+
throw error;
|
|
9847
|
+
}
|
|
9848
|
+
if (section.trim() === "") return void 0;
|
|
9849
|
+
return { kind: "case-dossier-pointer", frozenPath, section };
|
|
9850
|
+
}
|
|
9851
|
+
var CASE_DOSSIER_SECTION_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
|
|
9742
9852
|
var init_case_dossier_delivery = __esm({
|
|
9743
9853
|
"src/public-cli/case-dossier-delivery.ts"() {
|
|
9744
9854
|
"use strict";
|
|
9745
9855
|
init_ticket_provenance();
|
|
9856
|
+
init_invocation();
|
|
9746
9857
|
CASE_DOSSIER_SECTION_HEADING = "## \u672C\u7968\u8D77\u5C45\u5F55\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
9858
|
+
CASE_DOSSIER_ATTACH_KEY = "case-dossier";
|
|
9859
|
+
CASE_DOSSIER_ATTACH_FILE = "case-dossier-pointer.md";
|
|
9747
9860
|
}
|
|
9748
9861
|
});
|
|
9749
9862
|
|
|
9750
9863
|
// src/host-transition-prior-native.ts
|
|
9751
9864
|
import { access as access3, readdir as readdir3 } from "node:fs/promises";
|
|
9752
|
-
import { dirname as dirname11, join as
|
|
9865
|
+
import { dirname as dirname11, join as join22 } from "node:path";
|
|
9753
9866
|
function isEnoent2(error) {
|
|
9754
9867
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
9755
9868
|
}
|
|
@@ -9774,7 +9887,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
9774
9887
|
const recordPaths = [];
|
|
9775
9888
|
for (const entry of entries) {
|
|
9776
9889
|
if (!entry.isDirectory()) continue;
|
|
9777
|
-
const recordFile =
|
|
9890
|
+
const recordFile = join22(sessionRoot, entry.name, "records.jsonl");
|
|
9778
9891
|
try {
|
|
9779
9892
|
await access3(recordFile);
|
|
9780
9893
|
recordPaths.push(recordFile);
|
|
@@ -10165,13 +10278,13 @@ var init_reviewer_dispatch = __esm({
|
|
|
10165
10278
|
});
|
|
10166
10279
|
|
|
10167
10280
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
10168
|
-
import { readFile as
|
|
10169
|
-
import { join as
|
|
10281
|
+
import { readFile as readFile13, unlink as unlink3 } from "node:fs/promises";
|
|
10282
|
+
import { join as join23 } from "node:path";
|
|
10170
10283
|
function isReviewerPreflightViolation(value) {
|
|
10171
10284
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
10172
10285
|
}
|
|
10173
10286
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
10174
|
-
return
|
|
10287
|
+
return join23(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
10175
10288
|
}
|
|
10176
10289
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
10177
10290
|
try {
|
|
@@ -10186,7 +10299,7 @@ async function clearReviewerDispatchRejection(runDirectory) {
|
|
|
10186
10299
|
async function readReviewerDispatchRejection(runDirectory) {
|
|
10187
10300
|
let raw;
|
|
10188
10301
|
try {
|
|
10189
|
-
raw = await
|
|
10302
|
+
raw = await readFile13(reviewerDispatchRejectionPath(runDirectory), "utf8");
|
|
10190
10303
|
} catch (error) {
|
|
10191
10304
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
10192
10305
|
return void 0;
|
|
@@ -10228,12 +10341,12 @@ __export(session_assistant_usage_exports, {
|
|
|
10228
10341
|
sessionFileFromPublicSummon: () => sessionFileFromPublicSummon,
|
|
10229
10342
|
usageFromPublicSummon: () => usageFromPublicSummon
|
|
10230
10343
|
});
|
|
10231
|
-
import { join as
|
|
10344
|
+
import { join as join24 } from "node:path";
|
|
10232
10345
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
10233
|
-
const { readFile:
|
|
10346
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
10234
10347
|
let text;
|
|
10235
10348
|
try {
|
|
10236
|
-
text = await
|
|
10349
|
+
text = await readFile24(sessionFile, "utf8");
|
|
10237
10350
|
} catch (error) {
|
|
10238
10351
|
if (error?.code === "ENOENT") return void 0;
|
|
10239
10352
|
throw error;
|
|
@@ -10298,7 +10411,7 @@ async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
|
10298
10411
|
}
|
|
10299
10412
|
function sessionFileFromPublicSummon(summoned) {
|
|
10300
10413
|
if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
|
|
10301
|
-
return
|
|
10414
|
+
return join24(summoned.runDirectory, "session", "session.jsonl");
|
|
10302
10415
|
}
|
|
10303
10416
|
const fromArtifacts = summoned.terminal?.artifacts?.map((a) => a.path).find((p) => typeof p === "string" && p.endsWith("session.jsonl"));
|
|
10304
10417
|
if (fromArtifacts !== void 0) return fromArtifacts;
|
|
@@ -10307,7 +10420,7 @@ function sessionFileFromPublicSummon(summoned) {
|
|
|
10307
10420
|
const facts = outcome.decisiveFacts;
|
|
10308
10421
|
const pointer = facts?.runPointer;
|
|
10309
10422
|
if (typeof pointer === "string" && pointer.trim() !== "") {
|
|
10310
|
-
return
|
|
10423
|
+
return join24(pointer, "session", "session.jsonl");
|
|
10311
10424
|
}
|
|
10312
10425
|
return void 0;
|
|
10313
10426
|
}
|
|
@@ -10461,12 +10574,12 @@ var init_compliance_transport = __esm({
|
|
|
10461
10574
|
});
|
|
10462
10575
|
|
|
10463
10576
|
// src/ledger-session-read.ts
|
|
10464
|
-
import { readFile as
|
|
10577
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
10465
10578
|
function isRecord5(value) {
|
|
10466
10579
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10467
10580
|
}
|
|
10468
10581
|
async function readLedgerSessionJsonl(path) {
|
|
10469
|
-
const text = await
|
|
10582
|
+
const text = await readFile14(path, "utf8");
|
|
10470
10583
|
const lines = text.split("\n");
|
|
10471
10584
|
const rows = [];
|
|
10472
10585
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -10548,7 +10661,7 @@ var init_ledger_session_read = __esm({
|
|
|
10548
10661
|
|
|
10549
10662
|
// src/analyst-gate-cycles-read.ts
|
|
10550
10663
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
10551
|
-
import { join as
|
|
10664
|
+
import { join as join25 } from "node:path";
|
|
10552
10665
|
function isRecord6(value) {
|
|
10553
10666
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10554
10667
|
}
|
|
@@ -10763,10 +10876,10 @@ function pairGateRounds(volumes) {
|
|
|
10763
10876
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
10764
10877
|
}
|
|
10765
10878
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
10766
|
-
const { readFile:
|
|
10879
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
10767
10880
|
let raw;
|
|
10768
10881
|
try {
|
|
10769
|
-
raw = JSON.parse(await
|
|
10882
|
+
raw = JSON.parse(await readFile24(pointerPath, "utf8"));
|
|
10770
10883
|
} catch (error) {
|
|
10771
10884
|
throw new Error(
|
|
10772
10885
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -10798,7 +10911,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
10798
10911
|
throw error;
|
|
10799
10912
|
}
|
|
10800
10913
|
for (const name of names) {
|
|
10801
|
-
const path =
|
|
10914
|
+
const path = join25(directory, name);
|
|
10802
10915
|
const fromPointer = name.endsWith(".pointer.json");
|
|
10803
10916
|
const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
|
|
10804
10917
|
if (sessionPath === void 0) continue;
|
|
@@ -10937,7 +11050,7 @@ var init_audit_escalation = __esm({
|
|
|
10937
11050
|
});
|
|
10938
11051
|
|
|
10939
11052
|
// src/run-terminal-artifacts.ts
|
|
10940
|
-
import { basename as basename7, dirname as dirname12, join as
|
|
11053
|
+
import { basename as basename7, dirname as dirname12, join as join26 } from "node:path";
|
|
10941
11054
|
function runIdFromRunDirectory(runDirectory) {
|
|
10942
11055
|
const name = basename7(runDirectory);
|
|
10943
11056
|
const at = name.lastIndexOf("@");
|
|
@@ -10952,8 +11065,8 @@ var init_run_terminal_artifacts = __esm({
|
|
|
10952
11065
|
|
|
10953
11066
|
// src/submission-ledger.ts
|
|
10954
11067
|
function runIdentity(context) {
|
|
10955
|
-
const directory =
|
|
10956
|
-
if (
|
|
11068
|
+
const directory = runDirectoryFromHostContext(context);
|
|
11069
|
+
if (directory !== void 0) {
|
|
10957
11070
|
const fromDir = runIdFromRunDirectory(directory);
|
|
10958
11071
|
if (fromDir !== void 0) return fromDir;
|
|
10959
11072
|
}
|
|
@@ -10962,8 +11075,8 @@ function runIdentity(context) {
|
|
|
10962
11075
|
throw new Error("\u63D0\u4EA4\u8D26\u9700\u8981\u5DF2\u53D7\u7406\u7684 run \u8EAB\u4EFD");
|
|
10963
11076
|
}
|
|
10964
11077
|
function attemptIdentity(context, runId) {
|
|
10965
|
-
const courtAttempt =
|
|
10966
|
-
if (
|
|
11078
|
+
const courtAttempt = courtAttemptIdFromHostContext(context);
|
|
11079
|
+
if (courtAttempt !== void 0) return courtAttempt;
|
|
10967
11080
|
return context.sessionManager.getHeader?.()?.id ?? context.sessionManager.getLeafId?.() ?? `${runId}:initial`;
|
|
10968
11081
|
}
|
|
10969
11082
|
function submissionRecordFile(cwd, runId, home) {
|
|
@@ -11048,10 +11161,8 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
|
11048
11161
|
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
11049
11162
|
};
|
|
11050
11163
|
}
|
|
11051
|
-
|
|
11052
|
-
const
|
|
11053
|
-
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
|
|
11054
|
-
const scoped = recordsForAttempt(owned, scope.attemptId);
|
|
11164
|
+
function mapOwnedToSubmissionRows(owned) {
|
|
11165
|
+
const scoped = owned;
|
|
11055
11166
|
const out = [];
|
|
11056
11167
|
const indexByCall = /* @__PURE__ */ new Map();
|
|
11057
11168
|
const roleByCall = /* @__PURE__ */ new Map();
|
|
@@ -11115,6 +11226,17 @@ async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
|
|
|
11115
11226
|
}
|
|
11116
11227
|
return out;
|
|
11117
11228
|
}
|
|
11229
|
+
async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
|
|
11230
|
+
const scope = resolveReadScope(homeOrScope);
|
|
11231
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
|
|
11232
|
+
const scoped = recordsForAttempt(owned, scope.attemptId);
|
|
11233
|
+
return mapOwnedToSubmissionRows(scoped);
|
|
11234
|
+
}
|
|
11235
|
+
async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, home) {
|
|
11236
|
+
if (attemptId.length === 0) return [];
|
|
11237
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, home);
|
|
11238
|
+
return mapOwnedToSubmissionRows(owned.filter((record4) => recordAttemptId(record4) === attemptId));
|
|
11239
|
+
}
|
|
11118
11240
|
async function readRecordedSubmissions(cwd, runId, homeOrScope) {
|
|
11119
11241
|
return (await readRecordedSubmissionRows(cwd, runId, homeOrScope)).map((row) => row.accepted);
|
|
11120
11242
|
}
|
|
@@ -11269,29 +11391,28 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
11269
11391
|
}
|
|
11270
11392
|
};
|
|
11271
11393
|
}
|
|
11272
|
-
var COURT_ATTEMPT_ENV;
|
|
11273
11394
|
var init_submission_ledger = __esm({
|
|
11274
11395
|
"src/submission-ledger.ts"() {
|
|
11275
11396
|
"use strict";
|
|
11276
11397
|
init_activation_ledger_topology();
|
|
11398
|
+
init_host_contracts();
|
|
11277
11399
|
init_audit_escalation();
|
|
11278
11400
|
init_run_terminal_artifacts();
|
|
11279
11401
|
init_sitian_facade();
|
|
11280
11402
|
init_submission_correctable_error();
|
|
11281
11403
|
init_terminating_infrastructure();
|
|
11282
|
-
COURT_ATTEMPT_ENV = "AK_ROLE_COURT_ATTEMPT";
|
|
11283
11404
|
}
|
|
11284
11405
|
});
|
|
11285
11406
|
|
|
11286
11407
|
// src/session-opening-materials.ts
|
|
11287
11408
|
import { existsSync as existsSync8 } from "node:fs";
|
|
11288
|
-
import { readFile as
|
|
11289
|
-
import { dirname as dirname13, join as
|
|
11409
|
+
import { readFile as readFile15 } from "node:fs/promises";
|
|
11410
|
+
import { dirname as dirname13, join as join27 } from "node:path";
|
|
11290
11411
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11291
11412
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
11292
11413
|
let dir = dirname13(fileURLToPath(moduleUrl));
|
|
11293
11414
|
for (let i = 0; i < 8; i += 1) {
|
|
11294
|
-
if (existsSync8(
|
|
11415
|
+
if (existsSync8(join27(dir, "package.json")) && existsSync8(join27(dir, "souls"))) {
|
|
11295
11416
|
return dir;
|
|
11296
11417
|
}
|
|
11297
11418
|
const parent = dirname13(dir);
|
|
@@ -11301,7 +11422,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
|
11301
11422
|
return fileURLToPath(new URL("..", moduleUrl));
|
|
11302
11423
|
}
|
|
11303
11424
|
async function readPackageMaterial(relativePath) {
|
|
11304
|
-
return
|
|
11425
|
+
return readFile15(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
11305
11426
|
}
|
|
11306
11427
|
async function joinPackageMaterials(relativePaths) {
|
|
11307
11428
|
const chunks = [];
|
|
@@ -11401,9 +11522,20 @@ var init_auditor_soul = __esm({
|
|
|
11401
11522
|
// src/dossier-resolution.ts
|
|
11402
11523
|
import { existsSync as existsSync9, statSync as statSync2 } from "node:fs";
|
|
11403
11524
|
import { resolve as resolve11 } from "node:path";
|
|
11404
|
-
function
|
|
11525
|
+
function isHostContext(value) {
|
|
11526
|
+
return "sessionManager" in value;
|
|
11527
|
+
}
|
|
11528
|
+
function dossierPointerFrom(source) {
|
|
11529
|
+
if (source !== void 0 && isHostContext(source)) {
|
|
11530
|
+
return runDirectoryFromHostContext(source);
|
|
11531
|
+
}
|
|
11532
|
+
const env = source ?? process.env;
|
|
11405
11533
|
const raw = env[AUDIT_RUN_DIR_ENV];
|
|
11406
|
-
|
|
11534
|
+
return typeof raw === "string" && raw.trim() !== "" ? raw : void 0;
|
|
11535
|
+
}
|
|
11536
|
+
function resolveAuditDossier(source) {
|
|
11537
|
+
const raw = dossierPointerFrom(source);
|
|
11538
|
+
if (raw === void 0) {
|
|
11407
11539
|
return { status: "ok" };
|
|
11408
11540
|
}
|
|
11409
11541
|
const runDirectory = resolve11(raw);
|
|
@@ -11437,6 +11569,7 @@ var AUDIT_RUN_DIR_ENV, DOCTOR_CANDIDATE_ENTRY_TYPE, AuditMaterialsUnavailableErr
|
|
|
11437
11569
|
var init_dossier_resolution = __esm({
|
|
11438
11570
|
"src/dossier-resolution.ts"() {
|
|
11439
11571
|
"use strict";
|
|
11572
|
+
init_host_contracts();
|
|
11440
11573
|
AUDIT_RUN_DIR_ENV = "AK_ROLE_RUN_DIR";
|
|
11441
11574
|
DOCTOR_CANDIDATE_ENTRY_TYPE = "ak_doctor_audit_candidate";
|
|
11442
11575
|
AuditMaterialsUnavailableError = class extends Error {
|
|
@@ -11456,7 +11589,7 @@ var init_dossier_resolution = __esm({
|
|
|
11456
11589
|
// src/doctor-auditor.ts
|
|
11457
11590
|
function createPiDoctorAuditor() {
|
|
11458
11591
|
return async (options) => {
|
|
11459
|
-
const dossier = resolveAuditDossier();
|
|
11592
|
+
const dossier = resolveAuditDossier(options.context);
|
|
11460
11593
|
requireAuditMaterials(dossier);
|
|
11461
11594
|
const subjects = readDoctorAuditSubjects(options.context);
|
|
11462
11595
|
requireAuditMaterials(subjects);
|
|
@@ -12708,8 +12841,8 @@ var init_collector_ledger = __esm({
|
|
|
12708
12841
|
|
|
12709
12842
|
// src/package-resources/method-skill.ts
|
|
12710
12843
|
import { createHash as createHash8 } from "node:crypto";
|
|
12711
|
-
import { readFile as
|
|
12712
|
-
import { join as
|
|
12844
|
+
import { readFile as readFile16, realpath as realpath6 } from "node:fs/promises";
|
|
12845
|
+
import { join as join28 } from "node:path";
|
|
12713
12846
|
function gitBlobOid(bytes) {
|
|
12714
12847
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
12715
12848
|
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
@@ -12726,10 +12859,10 @@ function packagedMethodSkillRelativeDirectory(name) {
|
|
|
12726
12859
|
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
12727
12860
|
}
|
|
12728
12861
|
function resolvePackagedMethodSkillRoot(packageRoot, name) {
|
|
12729
|
-
return
|
|
12862
|
+
return join28(packageRoot, packagedMethodSkillRelativeDirectory(name));
|
|
12730
12863
|
}
|
|
12731
12864
|
function resolvePackagedMethodSkillPath(packageRoot, name) {
|
|
12732
|
-
return
|
|
12865
|
+
return join28(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
|
|
12733
12866
|
}
|
|
12734
12867
|
function isRecord8(value) {
|
|
12735
12868
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -12823,11 +12956,11 @@ function parseProvenance(raw, expectedName) {
|
|
|
12823
12956
|
}
|
|
12824
12957
|
async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
12825
12958
|
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot, name);
|
|
12826
|
-
const skillPathConfigured =
|
|
12827
|
-
const provenancePath =
|
|
12959
|
+
const skillPathConfigured = join28(rootDirectory, "SKILL.md");
|
|
12960
|
+
const provenancePath = join28(rootDirectory, "provenance.json");
|
|
12828
12961
|
let provenanceRaw;
|
|
12829
12962
|
try {
|
|
12830
|
-
provenanceRaw = await
|
|
12963
|
+
provenanceRaw = await readFile16(provenancePath, "utf8");
|
|
12831
12964
|
} catch (error) {
|
|
12832
12965
|
throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
|
|
12833
12966
|
}
|
|
@@ -12841,10 +12974,10 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
|
12841
12974
|
}
|
|
12842
12975
|
const provenance = parseProvenance(provenanceJson, name);
|
|
12843
12976
|
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
12844
|
-
const absolute =
|
|
12977
|
+
const absolute = join28(rootDirectory, rel);
|
|
12845
12978
|
let bytes;
|
|
12846
12979
|
try {
|
|
12847
|
-
bytes = await
|
|
12980
|
+
bytes = await readFile16(absolute);
|
|
12848
12981
|
} catch (error) {
|
|
12849
12982
|
throw new PackagedMethodSkillUnavailableError(name, absolute, error);
|
|
12850
12983
|
}
|
|
@@ -12860,7 +12993,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
|
12860
12993
|
let raw;
|
|
12861
12994
|
try {
|
|
12862
12995
|
skillPath = await realpath6(skillPathConfigured);
|
|
12863
|
-
raw = await
|
|
12996
|
+
raw = await readFile16(skillPath, "utf8");
|
|
12864
12997
|
} catch (error) {
|
|
12865
12998
|
throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
|
|
12866
12999
|
}
|
|
@@ -13347,8 +13480,8 @@ var init_terminal = __esm({
|
|
|
13347
13480
|
|
|
13348
13481
|
// src/public-cli/settlement.ts
|
|
13349
13482
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
13350
|
-
import { appendFile as appendFile2, readFile as
|
|
13351
|
-
import { dirname as dirname14, join as
|
|
13483
|
+
import { appendFile as appendFile2, readFile as readFile17, readdir as readdir5, writeFile as writeFile8 } from "node:fs/promises";
|
|
13484
|
+
import { dirname as dirname14, join as join29 } from "node:path";
|
|
13352
13485
|
function sealedLedgerHome(admitted) {
|
|
13353
13486
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
13354
13487
|
}
|
|
@@ -13371,6 +13504,16 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
13371
13504
|
return { kind: "accepted", role, payloads };
|
|
13372
13505
|
}
|
|
13373
13506
|
async function sealedLedgerOutcome(admitted, role, scope) {
|
|
13507
|
+
const home = sealedLedgerHome(admitted);
|
|
13508
|
+
if (scope?.courtAttemptId !== void 0 && scope.courtAttemptId.length > 0) {
|
|
13509
|
+
const thisCourt = await readAttemptScopedSubmissionRows(
|
|
13510
|
+
admitted.projectRoot,
|
|
13511
|
+
admitted.runId,
|
|
13512
|
+
scope.courtAttemptId,
|
|
13513
|
+
home
|
|
13514
|
+
);
|
|
13515
|
+
return roleOutcomeFromRows(role, thisCourt);
|
|
13516
|
+
}
|
|
13374
13517
|
const rows = await readRecordedSubmissionRows(
|
|
13375
13518
|
admitted.projectRoot,
|
|
13376
13519
|
admitted.runId,
|
|
@@ -13397,11 +13540,15 @@ async function recordedSubmissionPayloads(admitted, scope) {
|
|
|
13397
13540
|
function withSubmissions(terminal, submissions) {
|
|
13398
13541
|
if (submissions.length === 0) return terminal;
|
|
13399
13542
|
const roleOutcome = terminal.roleOutcome;
|
|
13400
|
-
const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation"
|
|
13543
|
+
const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" ? { ...roleOutcome, payloads: (roleOutcome.payloads ?? []).length > 0 ? roleOutcome.payloads : submissions } : roleOutcome.kind === "failure" ? { ...roleOutcome, payloads: roleOutcome.payloads ?? submissions } : roleOutcome;
|
|
13401
13544
|
return { ...terminal, roleOutcome: withPayloads, submissions };
|
|
13402
13545
|
}
|
|
13403
13546
|
async function attachRecordedSubmissions(admitted, terminal, scope) {
|
|
13404
|
-
|
|
13547
|
+
void scope;
|
|
13548
|
+
return withSubmissions(
|
|
13549
|
+
terminal,
|
|
13550
|
+
await recordedSubmissionPayloads(admitted, void 0)
|
|
13551
|
+
);
|
|
13405
13552
|
}
|
|
13406
13553
|
async function settleHostEndedNoReceipt(admitted, authority) {
|
|
13407
13554
|
const facts = noReceiptLifecycleFacts({
|
|
@@ -13470,7 +13617,7 @@ function presentStructuralRejection(error, io) {
|
|
|
13470
13617
|
}
|
|
13471
13618
|
async function inspectJudgeSession(sessionFile) {
|
|
13472
13619
|
try {
|
|
13473
|
-
await
|
|
13620
|
+
await readFile17(sessionFile, "utf8");
|
|
13474
13621
|
return { state: "present" };
|
|
13475
13622
|
} catch (error) {
|
|
13476
13623
|
if (isMissingPathError2(error)) return { state: "missing" };
|
|
@@ -13702,7 +13849,7 @@ function sessionReadFailure(error, fallbackMessage) {
|
|
|
13702
13849
|
return failed;
|
|
13703
13850
|
}
|
|
13704
13851
|
async function readBoundSessionEntries(sessionFile) {
|
|
13705
|
-
const text = await
|
|
13852
|
+
const text = await readFile17(sessionFile, "utf8");
|
|
13706
13853
|
const entries = [];
|
|
13707
13854
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
13708
13855
|
try {
|
|
@@ -13789,7 +13936,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
13789
13936
|
}
|
|
13790
13937
|
}
|
|
13791
13938
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
13792
|
-
const childDirectory =
|
|
13939
|
+
const childDirectory = join29(dirname14(sessionFile), "evidence-children");
|
|
13793
13940
|
let names;
|
|
13794
13941
|
try {
|
|
13795
13942
|
names = await readdir5(childDirectory);
|
|
@@ -13800,7 +13947,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
13800
13947
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
13801
13948
|
let entries;
|
|
13802
13949
|
try {
|
|
13803
|
-
entries = await readBoundSessionEntries(
|
|
13950
|
+
entries = await readBoundSessionEntries(join29(childDirectory, file));
|
|
13804
13951
|
} catch (error) {
|
|
13805
13952
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
13806
13953
|
}
|
|
@@ -13855,7 +14002,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
13855
14002
|
latestParentUserIndex = i;
|
|
13856
14003
|
break;
|
|
13857
14004
|
}
|
|
13858
|
-
const childDirectories = [
|
|
14005
|
+
const childDirectories = [join29(dirname14(sessionFile), "auditor-roles")];
|
|
13859
14006
|
const valid = [];
|
|
13860
14007
|
let sawAnyDirectory = false;
|
|
13861
14008
|
for (const childDirectory of childDirectories) {
|
|
@@ -13870,7 +14017,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
13870
14017
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
13871
14018
|
let entries;
|
|
13872
14019
|
try {
|
|
13873
|
-
entries = await readBoundSessionEntries(
|
|
14020
|
+
entries = await readBoundSessionEntries(join29(childDirectory, file));
|
|
13874
14021
|
} catch (error) {
|
|
13875
14022
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
13876
14023
|
}
|
|
@@ -14366,8 +14513,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
14366
14513
|
};
|
|
14367
14514
|
}
|
|
14368
14515
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
14369
|
-
const directories = [
|
|
14370
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
14516
|
+
const directories = [join29(sessionDirectory, "auditor-roles")];
|
|
14517
|
+
const parentSessionFile = options.parentSessionFile ?? join29(sessionDirectory, "session.jsonl");
|
|
14371
14518
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
14372
14519
|
parentSessionFile
|
|
14373
14520
|
});
|
|
@@ -14465,9 +14612,9 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
14465
14612
|
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
14466
14613
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
14467
14614
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
14468
|
-
const reportPath =
|
|
14469
|
-
const evidencePath =
|
|
14470
|
-
await
|
|
14615
|
+
const reportPath = join29(artifactsDir, "report.json");
|
|
14616
|
+
const evidencePath = join29(artifactsDir, "evidence.json");
|
|
14617
|
+
await writeFile8(
|
|
14471
14618
|
reportPath,
|
|
14472
14619
|
`${JSON.stringify(
|
|
14473
14620
|
{
|
|
@@ -14481,7 +14628,7 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
14481
14628
|
`,
|
|
14482
14629
|
"utf8"
|
|
14483
14630
|
);
|
|
14484
|
-
await
|
|
14631
|
+
await writeFile8(
|
|
14485
14632
|
evidencePath,
|
|
14486
14633
|
`${JSON.stringify(
|
|
14487
14634
|
{
|
|
@@ -14567,9 +14714,9 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
|
|
|
14567
14714
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
14568
14715
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
14569
14716
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
14570
|
-
const reportPath =
|
|
14571
|
-
const evidencePath =
|
|
14572
|
-
await
|
|
14717
|
+
const reportPath = join29(artifactsDir, "report.json");
|
|
14718
|
+
const evidencePath = join29(artifactsDir, "evidence.json");
|
|
14719
|
+
await writeFile8(
|
|
14573
14720
|
reportPath,
|
|
14574
14721
|
`${JSON.stringify(
|
|
14575
14722
|
{
|
|
@@ -14585,7 +14732,7 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
|
|
|
14585
14732
|
`,
|
|
14586
14733
|
"utf8"
|
|
14587
14734
|
);
|
|
14588
|
-
await
|
|
14735
|
+
await writeFile8(
|
|
14589
14736
|
evidencePath,
|
|
14590
14737
|
`${JSON.stringify(
|
|
14591
14738
|
{
|
|
@@ -14805,7 +14952,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
|
14805
14952
|
return dirs;
|
|
14806
14953
|
}
|
|
14807
14954
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
14808
|
-
const artifactsDir =
|
|
14955
|
+
const artifactsDir = join29(runDirectory, "artifacts");
|
|
14809
14956
|
try {
|
|
14810
14957
|
await ensureRunArtifactsDir(runDirectory);
|
|
14811
14958
|
return { baseDir: artifactsDir };
|
|
@@ -14821,13 +14968,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
14821
14968
|
const candidates = [
|
|
14822
14969
|
...preferredCandidates,
|
|
14823
14970
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
14824
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
14971
|
+
...uniqueFallbackDirs.map((dir) => join29(dir, `${stem}.${randomUUID3()}.json`))
|
|
14825
14972
|
];
|
|
14826
14973
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
14827
14974
|
const path = candidates[i];
|
|
14828
14975
|
const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
|
|
14829
14976
|
try {
|
|
14830
|
-
await
|
|
14977
|
+
await writeFile8(
|
|
14831
14978
|
path,
|
|
14832
14979
|
`${JSON.stringify(payload, null, 2)}
|
|
14833
14980
|
`,
|
|
@@ -14866,26 +15013,26 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
|
|
|
14866
15013
|
} catch (error) {
|
|
14867
15014
|
priorIssues.push(publicationAttemptFromError(sessionFile, error));
|
|
14868
15015
|
}
|
|
14869
|
-
const underArtifacts = baseDir ===
|
|
15016
|
+
const underArtifacts = baseDir === join29(admitted.runDirectory, "artifacts");
|
|
14870
15017
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
14871
15018
|
admitted.runDirectory,
|
|
14872
15019
|
baseDir
|
|
14873
15020
|
);
|
|
14874
15021
|
const errorCandidates = underArtifacts ? [
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
15022
|
+
join29(baseDir, "error.json"),
|
|
15023
|
+
join29(baseDir, "error.settlement.json"),
|
|
15024
|
+
join29(admitted.runDirectory, "error.settlement.json")
|
|
14878
15025
|
] : [
|
|
14879
|
-
|
|
14880
|
-
|
|
15026
|
+
join29(baseDir, "error.settlement.json"),
|
|
15027
|
+
join29(baseDir, "error.json")
|
|
14881
15028
|
];
|
|
14882
15029
|
const evidenceCandidates = underArtifacts ? [
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
15030
|
+
join29(baseDir, "evidence.json"),
|
|
15031
|
+
join29(baseDir, "evidence.settlement.json"),
|
|
15032
|
+
join29(admitted.runDirectory, "evidence.settlement.json")
|
|
14886
15033
|
] : [
|
|
14887
|
-
|
|
14888
|
-
|
|
15034
|
+
join29(baseDir, "evidence.settlement.json"),
|
|
15035
|
+
join29(baseDir, "evidence.json")
|
|
14889
15036
|
];
|
|
14890
15037
|
const errorPayloadBase = {
|
|
14891
15038
|
kind: "error",
|
|
@@ -15130,7 +15277,7 @@ var init_settlement = __esm({
|
|
|
15130
15277
|
import { constants as fsConstants2 } from "node:fs";
|
|
15131
15278
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
15132
15279
|
import { lstat as lstat5, mkdir as mkdir5, open as open2 } from "node:fs/promises";
|
|
15133
|
-
import { join as
|
|
15280
|
+
import { join as join30 } from "node:path";
|
|
15134
15281
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
15135
15282
|
if (options?.lawful === true) {
|
|
15136
15283
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -15166,7 +15313,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
|
|
|
15166
15313
|
}
|
|
15167
15314
|
}
|
|
15168
15315
|
function runArtifactsDirectory(runDirectory) {
|
|
15169
|
-
return
|
|
15316
|
+
return join30(runDirectory, "artifacts");
|
|
15170
15317
|
}
|
|
15171
15318
|
async function ensureRealArtifactsDirectory(runDirectory) {
|
|
15172
15319
|
const runStat = await lstat5(runDirectory);
|
|
@@ -15248,7 +15395,7 @@ function jsonSafeReplacer() {
|
|
|
15248
15395
|
};
|
|
15249
15396
|
}
|
|
15250
15397
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
15251
|
-
const filePath =
|
|
15398
|
+
const filePath = join30(artifactsDir, `${namePrefix}-${randomUUID4()}.json`);
|
|
15252
15399
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
15253
15400
|
`;
|
|
15254
15401
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -15519,8 +15666,8 @@ var init_auto_resume = __esm({
|
|
|
15519
15666
|
|
|
15520
15667
|
// src/public-cli/post-admission.ts
|
|
15521
15668
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
15522
|
-
import { readFile as
|
|
15523
|
-
import { isAbsolute as isAbsolute8, join as
|
|
15669
|
+
import { readFile as readFile18, writeFile as writeFile9 } from "node:fs/promises";
|
|
15670
|
+
import { isAbsolute as isAbsolute8, join as join31, resolve as resolve13 } from "node:path";
|
|
15524
15671
|
function describeCaughtError(error) {
|
|
15525
15672
|
if (error instanceof Error) {
|
|
15526
15673
|
const code = error.code;
|
|
@@ -15534,6 +15681,9 @@ function appendContinuationSection(continuation, section) {
|
|
|
15534
15681
|
${section}`;
|
|
15535
15682
|
return continuation.kind === "initial" ? { kind: "initial", prompt } : { kind: "resume", prompt };
|
|
15536
15683
|
}
|
|
15684
|
+
function isStationChildOfficerDialogue(role, env) {
|
|
15685
|
+
return env.stationChild === true && isOfficerReviewSeat(role);
|
|
15686
|
+
}
|
|
15537
15687
|
function withOnceSuccessfulBeforeDispatch(adapters) {
|
|
15538
15688
|
const hook = adapters.beforeDispatch;
|
|
15539
15689
|
if (hook === void 0) return adapters;
|
|
@@ -15561,8 +15711,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
15561
15711
|
} catch (appendError) {
|
|
15562
15712
|
try {
|
|
15563
15713
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
15564
|
-
await
|
|
15565
|
-
|
|
15714
|
+
await writeFile9(
|
|
15715
|
+
join31(artifactsDir, `post-admission-diagnostic-${randomUUID5()}.json`),
|
|
15566
15716
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
15567
15717
|
`,
|
|
15568
15718
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -15578,7 +15728,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
15578
15728
|
}
|
|
15579
15729
|
async function readInvocationHost(runDirectory) {
|
|
15580
15730
|
try {
|
|
15581
|
-
const raw = JSON.parse(await
|
|
15731
|
+
const raw = JSON.parse(await readFile18(join31(runDirectory, "invocation.json"), "utf8"));
|
|
15582
15732
|
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
|
|
15583
15733
|
} catch (error) {
|
|
15584
15734
|
if (error.code === "ENOENT") return void 0;
|
|
@@ -15751,19 +15901,28 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15751
15901
|
if (hostTransition !== void 0) {
|
|
15752
15902
|
turnRequest = { ...turnRequest, hostTransition };
|
|
15753
15903
|
}
|
|
15754
|
-
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15762
|
-
|
|
15763
|
-
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
};
|
|
15904
|
+
if (isStationChildOfficerDialogue(admitted.role, env)) {
|
|
15905
|
+
await deliverCaseDossierAsAttachment({
|
|
15906
|
+
ticketNumber: admitted.ticketNumber,
|
|
15907
|
+
projectRoot: admitted.projectRoot,
|
|
15908
|
+
home: env.home,
|
|
15909
|
+
runDirectory: admitted.runDirectory
|
|
15910
|
+
});
|
|
15911
|
+
} else {
|
|
15912
|
+
const dossierSection = await projectCaseDossierPointerSection({
|
|
15913
|
+
ticketNumber: admitted.ticketNumber,
|
|
15914
|
+
projectRoot: admitted.projectRoot,
|
|
15915
|
+
home: env.home
|
|
15916
|
+
});
|
|
15917
|
+
if (dossierSection !== void 0) {
|
|
15918
|
+
turnRequest = {
|
|
15919
|
+
...turnRequest,
|
|
15920
|
+
continuation: appendContinuationSection(
|
|
15921
|
+
turnRequest.continuation,
|
|
15922
|
+
dossierSection
|
|
15923
|
+
)
|
|
15924
|
+
};
|
|
15925
|
+
}
|
|
15767
15926
|
}
|
|
15768
15927
|
await markRunRunning(
|
|
15769
15928
|
admitted.runDirectory,
|
|
@@ -15793,8 +15952,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15793
15952
|
}
|
|
15794
15953
|
let stderrLogWriteFailure;
|
|
15795
15954
|
try {
|
|
15796
|
-
await
|
|
15797
|
-
|
|
15955
|
+
await writeFile9(
|
|
15956
|
+
join31(admitted.runDirectory, "stderr.log"),
|
|
15798
15957
|
result.stderr,
|
|
15799
15958
|
"utf8"
|
|
15800
15959
|
);
|
|
@@ -15983,25 +16142,17 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15983
16142
|
}
|
|
15984
16143
|
}
|
|
15985
16144
|
function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
|
|
15986
|
-
const
|
|
15987
|
-
const withReread = (body) => {
|
|
15988
|
-
if (officerSourcePath === void 0 || admitted.role !== "notary" && admitted.role !== "inspector" && admitted.role !== "auditor") {
|
|
15989
|
-
return body;
|
|
15990
|
-
}
|
|
15991
|
-
if (body.startsWith("\u8BF7\u91CD\u8BFB")) return body;
|
|
15992
|
-
return `\u8BF7\u91CD\u8BFB
|
|
15993
|
-
${body}`;
|
|
15994
|
-
};
|
|
16145
|
+
const officerDialogue = isStationChildOfficerDialogue(admitted.role, env);
|
|
15995
16146
|
let prompt;
|
|
15996
16147
|
if (request.message !== void 0) {
|
|
15997
16148
|
if (summonsPrepared !== void 0) {
|
|
15998
|
-
prompt =
|
|
16149
|
+
prompt = officerDialogue ? request.message : buildInstructionTransportPrompt({
|
|
15999
16150
|
instruction: request.message,
|
|
16000
16151
|
instructionEmpty: false,
|
|
16001
16152
|
attachments: summonsPrepared.attachments
|
|
16002
|
-
})
|
|
16153
|
+
});
|
|
16003
16154
|
} else if (request.summons !== void 0) {
|
|
16004
|
-
prompt =
|
|
16155
|
+
prompt = request.message;
|
|
16005
16156
|
} else {
|
|
16006
16157
|
prompt = buildResumeContinuationPrompt({
|
|
16007
16158
|
packageRoot: env.packageRoot,
|
|
@@ -16010,17 +16161,9 @@ ${body}`;
|
|
|
16010
16161
|
});
|
|
16011
16162
|
}
|
|
16012
16163
|
} else if (summonsPrepared !== void 0) {
|
|
16013
|
-
prompt =
|
|
16164
|
+
prompt = officerDialogue ? summonsPrepared.instructionEmpty ? "" : summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
|
|
16014
16165
|
} else if (request.summons !== void 0) {
|
|
16015
|
-
|
|
16016
|
-
if (path !== void 0 && (admitted.role === "notary" || admitted.role === "inspector" || admitted.role === "auditor")) {
|
|
16017
|
-
prompt = `\u8BF7\u91CD\u8BFB
|
|
16018
|
-
${GATE_DOSSIER_POINTER_PREFIX}${path}`;
|
|
16019
|
-
} else if (admitted.role === "notary" || admitted.role === "inspector" || admitted.role === "auditor") {
|
|
16020
|
-
prompt = "\u8BF7\u91CD\u8BFB";
|
|
16021
|
-
} else {
|
|
16022
|
-
prompt = "";
|
|
16023
|
-
}
|
|
16166
|
+
prompt = "";
|
|
16024
16167
|
} else {
|
|
16025
16168
|
prompt = buildResumeContinuationPrompt({
|
|
16026
16169
|
packageRoot: env.packageRoot,
|
|
@@ -16057,7 +16200,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
16057
16200
|
}
|
|
16058
16201
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
16059
16202
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
|
|
16060
|
-
return pathContainedIn(
|
|
16203
|
+
return pathContainedIn(join31(runDirectory, "attachments"), absolute);
|
|
16061
16204
|
}
|
|
16062
16205
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
16063
16206
|
if (summons === void 0) return void 0;
|
|
@@ -16353,6 +16496,7 @@ var init_post_admission = __esm({
|
|
|
16353
16496
|
init_activation_ledger_topology();
|
|
16354
16497
|
init_engine_material();
|
|
16355
16498
|
init_session_identity();
|
|
16499
|
+
init_host_contracts();
|
|
16356
16500
|
init_case_dossier_delivery();
|
|
16357
16501
|
init_host_transition_prior_native();
|
|
16358
16502
|
init_public_run_credentials();
|
|
@@ -16446,7 +16590,7 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
16446
16590
|
throw error;
|
|
16447
16591
|
}
|
|
16448
16592
|
{
|
|
16449
|
-
const resumeInstruction = env.reviewReask;
|
|
16593
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
16450
16594
|
const summons = {
|
|
16451
16595
|
sourceRunPath: source.runDirectory,
|
|
16452
16596
|
sourceRun: source,
|
|
@@ -16501,7 +16645,9 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
16501
16645
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
16502
16646
|
continuation: {
|
|
16503
16647
|
kind: "initial",
|
|
16504
|
-
|
|
16648
|
+
// #879: gate path first mint carries parent payload as dialogue content;
|
|
16649
|
+
// external zero-prompt kickoff unchanged when no body/reask.
|
|
16650
|
+
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildNotaryTransportPrompt(admitted, engineMaterial)
|
|
16505
16651
|
}
|
|
16506
16652
|
});
|
|
16507
16653
|
return await runPostAdmissionOneShot({
|
|
@@ -16589,12 +16735,20 @@ __export(inspector_run_exports, {
|
|
|
16589
16735
|
runPublicInspector: () => runPublicInspector,
|
|
16590
16736
|
runPublicInspectorResume: () => runPublicInspectorResume
|
|
16591
16737
|
});
|
|
16738
|
+
function inspectorParentRunPath(admitted) {
|
|
16739
|
+
if (typeof admitted.sourceRunPath === "string" && admitted.sourceRunPath.trim() !== "") {
|
|
16740
|
+
return admitted.sourceRunPath;
|
|
16741
|
+
}
|
|
16742
|
+
return parentRunPathFromGatePointerInstruction(admitted.instruction);
|
|
16743
|
+
}
|
|
16592
16744
|
function buildInspectorTurnRequest(admitted, options) {
|
|
16745
|
+
const sourceRun = inspectorParentRunPath(admitted);
|
|
16593
16746
|
return projectRoleTurnRequest(
|
|
16594
16747
|
admitted,
|
|
16595
16748
|
{
|
|
16596
16749
|
activation: {
|
|
16597
|
-
role: "inspector"
|
|
16750
|
+
role: "inspector",
|
|
16751
|
+
...sourceRun === void 0 ? {} : { sourceRun }
|
|
16598
16752
|
}
|
|
16599
16753
|
},
|
|
16600
16754
|
options
|
|
@@ -16614,7 +16768,7 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
16614
16768
|
const projectRoot = parsed.project ?? env.cwd;
|
|
16615
16769
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction);
|
|
16616
16770
|
if (parentRunPath !== void 0) {
|
|
16617
|
-
const resumeInstruction = env.reviewReask;
|
|
16771
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
16618
16772
|
const summons = {
|
|
16619
16773
|
sourceRunPath: parentRunPath,
|
|
16620
16774
|
...resumeInstruction === void 0 ? {
|
|
@@ -16659,6 +16813,10 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
16659
16813
|
throw error;
|
|
16660
16814
|
}
|
|
16661
16815
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
16816
|
+
if (parentRunPath !== void 0) {
|
|
16817
|
+
await persistAdmittedSourceRunPath(admitted, parentRunPath);
|
|
16818
|
+
admitted = { ...admitted, sourceRunPath: parentRunPath };
|
|
16819
|
+
}
|
|
16662
16820
|
const engineMaterial = engineSessionMaterialFromOptions({
|
|
16663
16821
|
...pickEngineAxis(env),
|
|
16664
16822
|
packageRoot: env.packageRoot
|
|
@@ -16673,7 +16831,8 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
16673
16831
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
16674
16832
|
continuation: {
|
|
16675
16833
|
kind: "initial",
|
|
16676
|
-
|
|
16834
|
+
// #879: gate first mint uses parent payload as content; binding stays typed activation.
|
|
16835
|
+
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInspectorTransportPrompt(admitted, engineMaterial)
|
|
16677
16836
|
}
|
|
16678
16837
|
});
|
|
16679
16838
|
return await runPostAdmissionOneShot({
|
|
@@ -16897,7 +17056,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
|
|
|
16897
17056
|
return { exitCode: 2 };
|
|
16898
17057
|
}
|
|
16899
17058
|
}
|
|
16900
|
-
const resumeInstruction = env.reviewReask;
|
|
17059
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
16901
17060
|
const summons = {
|
|
16902
17061
|
...resumeInstruction === void 0 ? {
|
|
16903
17062
|
instruction: parsed.instruction,
|
|
@@ -16963,7 +17122,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
|
|
|
16963
17122
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
16964
17123
|
continuation: {
|
|
16965
17124
|
kind: "initial",
|
|
16966
|
-
|
|
17125
|
+
// #879: gate first mint uses parent payload as content when present.
|
|
17126
|
+
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(
|
|
16967
17127
|
admitted,
|
|
16968
17128
|
engineSessionMaterialFromOptions({
|
|
16969
17129
|
...pickEngineAxis(env),
|
|
@@ -17392,7 +17552,7 @@ __export(public_role_summons_exports, {
|
|
|
17392
17552
|
summonPublicRole: () => summonPublicRole
|
|
17393
17553
|
});
|
|
17394
17554
|
import { existsSync as existsSync10 } from "node:fs";
|
|
17395
|
-
import { join as
|
|
17555
|
+
import { join as join32 } from "node:path";
|
|
17396
17556
|
function createCapturingIo() {
|
|
17397
17557
|
const chunks = [];
|
|
17398
17558
|
return {
|
|
@@ -17415,7 +17575,7 @@ function parentDir(path) {
|
|
|
17415
17575
|
function walkPackageRoot(start) {
|
|
17416
17576
|
let dir = start;
|
|
17417
17577
|
for (let i = 0; i < 12; i += 1) {
|
|
17418
|
-
if (existsSync10(
|
|
17578
|
+
if (existsSync10(join32(dir, "package.json")) && existsSync10(join32(dir, "souls"))) {
|
|
17419
17579
|
return dir;
|
|
17420
17580
|
}
|
|
17421
17581
|
const parent = parentDir(dir);
|
|
@@ -17509,7 +17669,7 @@ async function createSummonEnv(options) {
|
|
|
17509
17669
|
async function summonPublicRole(options) {
|
|
17510
17670
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
17511
17671
|
const home = await resolveSummonHome(options);
|
|
17512
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
17672
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join32(home, ".pi", "agent");
|
|
17513
17673
|
const {
|
|
17514
17674
|
loadCredentialProviders: loadCredentialProviders2,
|
|
17515
17675
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -17550,6 +17710,8 @@ async function summonPublicRole(options) {
|
|
|
17550
17710
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
17551
17711
|
// #753: reask rides the existing notary same-ticket resume summons.instruction.
|
|
17552
17712
|
...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
|
|
17713
|
+
// #879: verbatim submission body on officer dialogue content channel.
|
|
17714
|
+
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
|
|
17553
17715
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
17554
17716
|
// createRunId is the only remaining env overlay — host is seat-selected above.
|
|
17555
17717
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
@@ -17657,6 +17819,11 @@ async function summonGateOfficer(options) {
|
|
|
17657
17819
|
const { homeFromRunDirectory: homeFromRunDirectory3 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
|
|
17658
17820
|
home = homeFromRunDirectory3(options.sourceRunDirectory);
|
|
17659
17821
|
}
|
|
17822
|
+
let gateReviewInstruction;
|
|
17823
|
+
if (options.reask === void 0 && options.submission !== void 0) {
|
|
17824
|
+
const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
|
|
17825
|
+
gateReviewInstruction = readableGateItem2(options.submission);
|
|
17826
|
+
}
|
|
17660
17827
|
const common = {
|
|
17661
17828
|
cwd: options.cwd,
|
|
17662
17829
|
...home === void 0 ? {} : { home },
|
|
@@ -17664,6 +17831,7 @@ async function summonGateOfficer(options) {
|
|
|
17664
17831
|
...options.io === void 0 ? {} : { io: options.io },
|
|
17665
17832
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
17666
17833
|
...options.reask === void 0 ? {} : { reviewReask: options.reask },
|
|
17834
|
+
...gateReviewInstruction === void 0 ? {} : { gateReviewInstruction },
|
|
17667
17835
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
17668
17836
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
17669
17837
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
@@ -17737,11 +17905,18 @@ function projectOfficerDecision(officer, decision, fallbackStatus) {
|
|
|
17737
17905
|
}
|
|
17738
17906
|
return { status: "needs_reask", officer, receipt };
|
|
17739
17907
|
}
|
|
17740
|
-
function
|
|
17908
|
+
function thisCourtOfficerPayloads(terminal) {
|
|
17741
17909
|
const outcome = terminal?.roleOutcome;
|
|
17742
17910
|
if (outcome !== void 0 && (outcome.kind === "accepted" || outcome.kind === "audit_escalation")) {
|
|
17743
|
-
|
|
17911
|
+
if (outcome.payloads !== void 0 && outcome.payloads.length > 0) return outcome.payloads;
|
|
17744
17912
|
}
|
|
17913
|
+
if (outcome?.kind === "failure" && outcome.payloads !== void 0 && outcome.payloads.length > 0) {
|
|
17914
|
+
return outcome.payloads;
|
|
17915
|
+
}
|
|
17916
|
+
return [];
|
|
17917
|
+
}
|
|
17918
|
+
function officerFailurePayloads(terminal) {
|
|
17919
|
+
const outcome = terminal?.roleOutcome;
|
|
17745
17920
|
if (outcome?.kind === "failure") return outcome.payloads ?? terminal?.submissions ?? [];
|
|
17746
17921
|
return terminal?.submissions ?? [];
|
|
17747
17922
|
}
|
|
@@ -17749,24 +17924,20 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
|
|
|
17749
17924
|
if (payloads.length === 0) {
|
|
17750
17925
|
return projectOfficerDecision(officer, void 0, fallbackStatus);
|
|
17751
17926
|
}
|
|
17752
|
-
|
|
17753
|
-
if (payloads.length === 1) return queued;
|
|
17754
|
-
if (queued.status === "pass" || queued.status === "bounce" || queued.status === "escalate" || queued.status === "needs_reask") {
|
|
17755
|
-
return { ...queued, receipt: payloads };
|
|
17756
|
-
}
|
|
17757
|
-
return queued;
|
|
17927
|
+
return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
|
|
17758
17928
|
}
|
|
17759
17929
|
function projectOfficerTerminal(officer, summoned) {
|
|
17760
17930
|
const terminal = summoned.terminal;
|
|
17761
17931
|
const outcome = terminal?.roleOutcome;
|
|
17762
|
-
const
|
|
17932
|
+
const thisCourt = thisCourtOfficerPayloads(terminal);
|
|
17763
17933
|
if (outcome === void 0) {
|
|
17764
17934
|
const detail = summoned.stderr ?? "";
|
|
17935
|
+
const failurePayloads = officerFailurePayloads(terminal);
|
|
17765
17936
|
return {
|
|
17766
17937
|
status: "transport_failure",
|
|
17767
17938
|
stage: officer,
|
|
17768
17939
|
reason: detail.length > 0 ? `${gateSeatLabel(officer)} public summon exit ${summoned.exitCode}: ${detail}` : `${gateSeatLabel(officer)} public summon produced no terminal (exit ${summoned.exitCode})`,
|
|
17769
|
-
submission:
|
|
17940
|
+
submission: failurePayloads.length > 0 ? failurePayloads : summoned
|
|
17770
17941
|
};
|
|
17771
17942
|
}
|
|
17772
17943
|
if (outcome.kind === "no_receipt") {
|
|
@@ -17778,27 +17949,30 @@ function projectOfficerTerminal(officer, summoned) {
|
|
|
17778
17949
|
};
|
|
17779
17950
|
}
|
|
17780
17951
|
if (outcome.kind === "failure") {
|
|
17952
|
+
const failurePayloads = officerFailurePayloads(terminal);
|
|
17781
17953
|
return {
|
|
17782
17954
|
status: "transport_failure",
|
|
17783
17955
|
stage: officer,
|
|
17784
17956
|
reason: outcome.diagnostic,
|
|
17785
|
-
submission:
|
|
17957
|
+
submission: failurePayloads.length > 0 ? failurePayloads : outcome.decisiveFacts
|
|
17786
17958
|
};
|
|
17787
17959
|
}
|
|
17788
17960
|
if (outcome.kind === "audit_escalation") {
|
|
17789
17961
|
return {
|
|
17790
17962
|
status: "escalate",
|
|
17791
17963
|
officer,
|
|
17792
|
-
receipt
|
|
17964
|
+
// This-court receipt only (#879) — historical rows remain on terminal.submissions.
|
|
17965
|
+
receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
|
|
17793
17966
|
};
|
|
17794
17967
|
}
|
|
17795
17968
|
if (outcome.kind === "accepted") {
|
|
17796
|
-
return projectOfficerPayloads(officer,
|
|
17969
|
+
return projectOfficerPayloads(officer, thisCourt, outcome.status);
|
|
17797
17970
|
}
|
|
17798
17971
|
return {
|
|
17799
17972
|
status: "needs_reask",
|
|
17800
17973
|
officer,
|
|
17801
|
-
|
|
17974
|
+
// This-court receipt only (#879).
|
|
17975
|
+
receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
|
|
17802
17976
|
};
|
|
17803
17977
|
}
|
|
17804
17978
|
async function projectGatekeeperRun(options) {
|
|
@@ -17816,7 +17990,7 @@ async function projectGatekeeperRun(options) {
|
|
|
17816
17990
|
}
|
|
17817
17991
|
let summoned;
|
|
17818
17992
|
try {
|
|
17819
|
-
const summon = options.summonOfficer ?? (async (nextOfficer, sourceRunDirectory, officerSignal, reask) => {
|
|
17993
|
+
const summon = options.summonOfficer ?? (async (nextOfficer, sourceRunDirectory, officerSignal, reask, nextSubmission) => {
|
|
17820
17994
|
const { summonGateOfficer: summonGateOfficer2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
17821
17995
|
return summonGateOfficer2({
|
|
17822
17996
|
officer: nextOfficer,
|
|
@@ -17824,6 +17998,7 @@ async function projectGatekeeperRun(options) {
|
|
|
17824
17998
|
cwd: options.context.cwd ?? process.cwd(),
|
|
17825
17999
|
...officerSignal === void 0 ? {} : { signal: officerSignal },
|
|
17826
18000
|
...reask === void 0 ? {} : { reask },
|
|
18001
|
+
...nextSubmission === void 0 ? {} : { submission: nextSubmission },
|
|
17827
18002
|
...options.home === void 0 ? {} : { home: options.home },
|
|
17828
18003
|
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
17829
18004
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
@@ -17834,7 +18009,8 @@ async function projectGatekeeperRun(options) {
|
|
|
17834
18009
|
officer,
|
|
17835
18010
|
runDirectory,
|
|
17836
18011
|
options.signal,
|
|
17837
|
-
options.reask
|
|
18012
|
+
options.reask,
|
|
18013
|
+
options.submission
|
|
17838
18014
|
);
|
|
17839
18015
|
} catch (error) {
|
|
17840
18016
|
return {
|
|
@@ -17874,9 +18050,9 @@ import { randomUUID as randomUUID8 } from "node:crypto";
|
|
|
17874
18050
|
// src/role-envelope.ts
|
|
17875
18051
|
init_engine_detour();
|
|
17876
18052
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
17877
|
-
import { mkdir as mkdir6, readFile as
|
|
18053
|
+
import { mkdir as mkdir6, readFile as readFile20, writeFile as writeFile11 } from "node:fs/promises";
|
|
17878
18054
|
import { createServer } from "node:net";
|
|
17879
|
-
import { basename as basename8, dirname as dirname18, join as
|
|
18055
|
+
import { basename as basename8, dirname as dirname18, join as join37 } from "node:path";
|
|
17880
18056
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
17881
18057
|
|
|
17882
18058
|
// src/gatekeeper-pass-envelope.ts
|
|
@@ -17908,6 +18084,7 @@ async function requireGatekeeperPass(options) {
|
|
|
17908
18084
|
subject: options.subject,
|
|
17909
18085
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
17910
18086
|
...options.summonOfficer === void 0 ? {} : { summonOfficer: options.summonOfficer },
|
|
18087
|
+
...options.submission === void 0 ? {} : { submission: options.submission },
|
|
17911
18088
|
...reask === void 0 ? {} : { reask }
|
|
17912
18089
|
});
|
|
17913
18090
|
const gatekeeper = projected.result;
|
|
@@ -17950,7 +18127,7 @@ init_sitian_facade();
|
|
|
17950
18127
|
init_submission_ledger();
|
|
17951
18128
|
init_collector_ledger();
|
|
17952
18129
|
import { readFileSync as readFileSync5, writeSync as writeSync4 } from "node:fs";
|
|
17953
|
-
import { join as
|
|
18130
|
+
import { join as join36 } from "node:path";
|
|
17954
18131
|
import { Value as Value4 } from "typebox/value";
|
|
17955
18132
|
|
|
17956
18133
|
// src/activation-trace.ts
|
|
@@ -18359,6 +18536,7 @@ function createToolExecutionObservationFace(options) {
|
|
|
18359
18536
|
|
|
18360
18537
|
// src/role-runtime.ts
|
|
18361
18538
|
init_engine_detour();
|
|
18539
|
+
init_engine_material();
|
|
18362
18540
|
|
|
18363
18541
|
// src/engine-detour-tool.ts
|
|
18364
18542
|
init_engine_detour();
|
|
@@ -18456,21 +18634,21 @@ init_collector_evidence();
|
|
|
18456
18634
|
init_collector_github();
|
|
18457
18635
|
|
|
18458
18636
|
// src/collector-handbook.ts
|
|
18459
|
-
import { readFile as
|
|
18460
|
-
import { join as
|
|
18637
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
18638
|
+
import { join as join34, sep as sep4 } from "node:path";
|
|
18461
18639
|
|
|
18462
18640
|
// src/atomic-write.ts
|
|
18463
18641
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
18464
|
-
import { rename as rename2, rm as
|
|
18465
|
-
import { dirname as dirname16, join as
|
|
18642
|
+
import { rename as rename2, rm as rm3, writeFile as writeFile10 } from "node:fs/promises";
|
|
18643
|
+
import { dirname as dirname16, join as join33 } from "node:path";
|
|
18466
18644
|
async function writeFileAtomically(destination, contents) {
|
|
18467
18645
|
const parent = dirname16(destination);
|
|
18468
|
-
const temporary =
|
|
18646
|
+
const temporary = join33(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
18469
18647
|
try {
|
|
18470
|
-
await
|
|
18648
|
+
await writeFile10(temporary, contents);
|
|
18471
18649
|
await rename2(temporary, destination);
|
|
18472
18650
|
} catch (error) {
|
|
18473
|
-
await
|
|
18651
|
+
await rm3(temporary, { force: true }).catch(() => void 0);
|
|
18474
18652
|
throw error;
|
|
18475
18653
|
}
|
|
18476
18654
|
}
|
|
@@ -18591,7 +18769,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
|
|
|
18591
18769
|
throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
|
|
18592
18770
|
}
|
|
18593
18771
|
const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
|
|
18594
|
-
const root =
|
|
18772
|
+
const root = join34(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
|
|
18595
18773
|
return { ledgerHome, bookKey, root };
|
|
18596
18774
|
}
|
|
18597
18775
|
function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
@@ -18603,9 +18781,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
|
18603
18781
|
return `${repositoryCanonical.replaceAll("/", "__")}.md`;
|
|
18604
18782
|
}
|
|
18605
18783
|
function createCollectorHandbookStore(input) {
|
|
18606
|
-
const generalPath =
|
|
18607
|
-
const repoDir =
|
|
18608
|
-
const repoPath =
|
|
18784
|
+
const generalPath = join34(input.handbookRoot, "general.md");
|
|
18785
|
+
const repoDir = join34(input.handbookRoot, "repos");
|
|
18786
|
+
const repoPath = join34(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
|
|
18609
18787
|
const assertHandbookBudget = (body, label) => {
|
|
18610
18788
|
const byteLength = Buffer.byteLength(body, "utf8");
|
|
18611
18789
|
if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
|
|
@@ -18619,7 +18797,7 @@ function createCollectorHandbookStore(input) {
|
|
|
18619
18797
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
18620
18798
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
18621
18799
|
try {
|
|
18622
|
-
const body = await
|
|
18800
|
+
const body = await readFile19(path, "utf8");
|
|
18623
18801
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
18624
18802
|
return body;
|
|
18625
18803
|
} catch (error) {
|
|
@@ -20707,14 +20885,18 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
|
|
|
20707
20885
|
subject: { kind: "judge_draft" },
|
|
20708
20886
|
...signal === void 0 ? {} : { signal },
|
|
20709
20887
|
hostActions,
|
|
20710
|
-
toolCallId
|
|
20888
|
+
toolCallId,
|
|
20889
|
+
// #879: this-turn typed payload — identity-bound at submit site.
|
|
20890
|
+
submission: parameters
|
|
20711
20891
|
});
|
|
20712
20892
|
await pi.requireGatekeeperPass({
|
|
20713
20893
|
context: ctx,
|
|
20714
20894
|
subject: { kind: "judge_compliance" },
|
|
20715
20895
|
...signal === void 0 ? {} : { signal },
|
|
20716
20896
|
hostActions,
|
|
20717
|
-
toolCallId
|
|
20897
|
+
toolCallId,
|
|
20898
|
+
// #879: same parent payload for 审刑院; not recovered from session latest.
|
|
20899
|
+
submission: parameters
|
|
20718
20900
|
});
|
|
20719
20901
|
return {
|
|
20720
20902
|
content: [{ type: "text", text: JUDGE_ACCEPTED_TEXT }],
|
|
@@ -21225,7 +21407,9 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
21225
21407
|
subject: { kind: "worker_completion" },
|
|
21226
21408
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
21227
21409
|
hostActions,
|
|
21228
|
-
toolCallId
|
|
21410
|
+
toolCallId,
|
|
21411
|
+
// #879: this-turn typed payload — identity-bound at submit site.
|
|
21412
|
+
submission: output
|
|
21229
21413
|
});
|
|
21230
21414
|
}
|
|
21231
21415
|
const acceptedDetails = output;
|
|
@@ -21361,7 +21545,9 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
21361
21545
|
subject: { kind: "worker_completion" },
|
|
21362
21546
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
21363
21547
|
hostActions,
|
|
21364
|
-
toolCallId
|
|
21548
|
+
toolCallId,
|
|
21549
|
+
// #879: this-turn typed payload — identity-bound at submit site.
|
|
21550
|
+
submission: output
|
|
21365
21551
|
});
|
|
21366
21552
|
}
|
|
21367
21553
|
const acceptedDetails = output;
|
|
@@ -21896,12 +22082,12 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
21896
22082
|
}
|
|
21897
22083
|
return { kind: "invalid" };
|
|
21898
22084
|
}
|
|
21899
|
-
function readDiaristRunCoordinates() {
|
|
21900
|
-
const runDirectory =
|
|
21901
|
-
if (
|
|
22085
|
+
function readDiaristRunCoordinates(ctx) {
|
|
22086
|
+
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
22087
|
+
if (runDirectory === void 0) {
|
|
21902
22088
|
throw new Error("diarist accept requires AK_ROLE_RUN_DIR");
|
|
21903
22089
|
}
|
|
21904
|
-
const admittedPath =
|
|
22090
|
+
const admittedPath = join36(runDirectory, "admitted-request.json");
|
|
21905
22091
|
const admitted = JSON.parse(readFileSync5(admittedPath, "utf8"));
|
|
21906
22092
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
21907
22093
|
throw new Error(`diarist admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -21922,10 +22108,10 @@ function createDiaristRoleRuntime(roleHost, dependencies) {
|
|
|
21922
22108
|
tool: DIARIST_TOOL_SPEC,
|
|
21923
22109
|
acceptedText: DIARIST_ACCEPTED_TEXT,
|
|
21924
22110
|
soulTag: "diarist",
|
|
21925
|
-
beforeAccept: async ({ parameters }) => {
|
|
22111
|
+
beforeAccept: async ({ parameters, ctx }) => {
|
|
21926
22112
|
const submitted = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters : void 0;
|
|
21927
22113
|
const assertion = readDiaristTicketAssertion(submitted);
|
|
21928
|
-
const coords = readDiaristRunCoordinates();
|
|
22114
|
+
const coords = readDiaristRunCoordinates(ctx);
|
|
21929
22115
|
const ticketNumber = assertion.kind === "ticket" ? assertion.ticketNumber : void 0;
|
|
21930
22116
|
if (ticketNumber !== void 0) {
|
|
21931
22117
|
if (coords.boundTicketNumber === void 0) {
|
|
@@ -21961,7 +22147,9 @@ function createCountersignRoleRuntime(roleHost, dependencies, hostActions) {
|
|
|
21961
22147
|
subject: { kind: "countersign_verdict" },
|
|
21962
22148
|
...signal === void 0 ? {} : { signal },
|
|
21963
22149
|
hostActions,
|
|
21964
|
-
toolCallId
|
|
22150
|
+
toolCallId,
|
|
22151
|
+
// #879: this-turn typed payload — identity-bound at submit site.
|
|
22152
|
+
submission: parameters
|
|
21965
22153
|
});
|
|
21966
22154
|
} : void 0;
|
|
21967
22155
|
return createFiledOfficerRuntime(
|
|
@@ -21994,6 +22182,10 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
21994
22182
|
for (const flag of NOTARY_TRANSPORT_FLAGS) {
|
|
21995
22183
|
roleHost.registerFlag(flag.name, flag.definition);
|
|
21996
22184
|
}
|
|
22185
|
+
roleHost.registerFlag(
|
|
22186
|
+
INSPECTOR_SOURCE_RUN_FLAG.name,
|
|
22187
|
+
INSPECTOR_SOURCE_RUN_FLAG.definition
|
|
22188
|
+
);
|
|
21997
22189
|
for (const flag of GLEANER_LEFT_TRANSPORT_FLAGS) {
|
|
21998
22190
|
roleHost.registerFlag(flag.name, flag.definition);
|
|
21999
22191
|
}
|
|
@@ -22001,6 +22193,11 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22001
22193
|
roleHost.registerFlag(flag.name, flag.definition);
|
|
22002
22194
|
}
|
|
22003
22195
|
roleHost.registerFlag(STATION_CHILD_FLAG.name, STATION_CHILD_FLAG.definition);
|
|
22196
|
+
roleHost.registerFlag(ENGINE_MODEL_FLAG_NAME, {
|
|
22197
|
+
description: "\u672C\u6B21\u52B3\u52A1\u5F15\u64CE\u6A21\u578B",
|
|
22198
|
+
type: "string",
|
|
22199
|
+
default: ""
|
|
22200
|
+
});
|
|
22004
22201
|
let admitted = false;
|
|
22005
22202
|
let selectedRole;
|
|
22006
22203
|
let activeReviewerParent;
|
|
@@ -22085,19 +22282,21 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22085
22282
|
settleNavigatorProjection
|
|
22086
22283
|
);
|
|
22087
22284
|
roleHost.on("input", (event) => {
|
|
22285
|
+
const text = event.text;
|
|
22088
22286
|
const role = roleHost.getFlag(ROLE_FLAG.name);
|
|
22089
22287
|
if (role !== void 0 && !admitted) return { action: "handled" };
|
|
22090
22288
|
if (role === "reviewer" && admitted && activeReviewerParent !== void 0 && reviewerOriginalRequest === void 0) {
|
|
22091
22289
|
reviewerOriginalRequest = roleHost.capabilities?.skillOriginalRequest?.(
|
|
22092
22290
|
activeReviewerParent.skillBinding.name,
|
|
22093
|
-
|
|
22094
|
-
) ??
|
|
22095
|
-
return { action: "continue" };
|
|
22291
|
+
text
|
|
22292
|
+
) ?? text;
|
|
22293
|
+
return text === event.text ? { action: "continue" } : { action: "transform", text };
|
|
22096
22294
|
}
|
|
22097
|
-
return { action: "continue" };
|
|
22295
|
+
return text === event.text ? { action: "continue" } : { action: "transform", text };
|
|
22098
22296
|
});
|
|
22099
22297
|
roleHost.on("before_agent_start", async (event, ctx) => {
|
|
22100
22298
|
const role = roleHost.getFlag(ROLE_FLAG.name);
|
|
22299
|
+
const prompt = event.prompt;
|
|
22101
22300
|
if (role === void 0) return;
|
|
22102
22301
|
if (!admitted || selectedRole !== role) {
|
|
22103
22302
|
failInfrastructure(new ActivationBarrierError(role), ctx);
|
|
@@ -22110,7 +22309,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22110
22309
|
}
|
|
22111
22310
|
if (navigatorAttendance !== void 0 && navigatorWorkContext !== void 0 && navigatorWorkContext.contextError === void 0) {
|
|
22112
22311
|
if (navigatorWorkContext.subjectProvenance === "placeholder") {
|
|
22113
|
-
const subject =
|
|
22312
|
+
const subject = prompt.trim();
|
|
22114
22313
|
if (subject !== "") {
|
|
22115
22314
|
const root = subjectPath(ctx.sessionManager.getSessionDir(), ctx.cwd);
|
|
22116
22315
|
const subjectProvenance = "user_prompt";
|
|
@@ -22131,7 +22330,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22131
22330
|
if (!reviewerExpansionCaptured) {
|
|
22132
22331
|
if (reviewerOriginalRequest !== void 0) {
|
|
22133
22332
|
activeReviewerParent.skillBinding.captureExpansion(
|
|
22134
|
-
roleHost.capabilities?.skillExpansion(
|
|
22333
|
+
roleHost.capabilities?.skillExpansion(prompt),
|
|
22135
22334
|
reviewerOriginalRequest
|
|
22136
22335
|
);
|
|
22137
22336
|
}
|
|
@@ -22154,6 +22353,46 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22154
22353
|
};
|
|
22155
22354
|
}
|
|
22156
22355
|
});
|
|
22356
|
+
roleHost.on("before_agent_start", () => {
|
|
22357
|
+
const role = selectedRole ?? roleHost.getFlag(ROLE_FLAG.name);
|
|
22358
|
+
if (typeof role !== "string" || !isOfficerReviewSeat(role)) return;
|
|
22359
|
+
if (roleHost.getFlag(STATION_CHILD_FLAG.name) !== true) return;
|
|
22360
|
+
const engine = resolveEngineName((name) => roleHost.getFlag(name));
|
|
22361
|
+
if (engine === void 0 || dependencies.packageRoot === void 0) return;
|
|
22362
|
+
const engineModel = resolveEngineModel((name) => roleHost.getFlag(name));
|
|
22363
|
+
const material = engineSessionMaterialFromOptions({
|
|
22364
|
+
engine,
|
|
22365
|
+
...engineModel === void 0 ? {} : { engineModel },
|
|
22366
|
+
packageRoot: dependencies.packageRoot
|
|
22367
|
+
});
|
|
22368
|
+
if (material === void 0) return;
|
|
22369
|
+
return {
|
|
22370
|
+
readingMaterial: {
|
|
22371
|
+
kind: "engine-session-material",
|
|
22372
|
+
name: material.name,
|
|
22373
|
+
...material.model === void 0 ? {} : { model: material.model },
|
|
22374
|
+
...material.materialPath === void 0 ? {} : { materialPath: material.materialPath }
|
|
22375
|
+
}
|
|
22376
|
+
};
|
|
22377
|
+
});
|
|
22378
|
+
roleHost.on("before_agent_start", () => {
|
|
22379
|
+
const path = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
|
|
22380
|
+
if (typeof path !== "string" || path.trim() === "") return;
|
|
22381
|
+
return {
|
|
22382
|
+
readingMaterial: {
|
|
22383
|
+
kind: "inspector-parent-binding",
|
|
22384
|
+
sourceRunPath: path
|
|
22385
|
+
}
|
|
22386
|
+
};
|
|
22387
|
+
});
|
|
22388
|
+
roleHost.on("before_agent_start", async (_event, ctx) => {
|
|
22389
|
+
const runDir = runDirectoryFromHostContext(ctx);
|
|
22390
|
+
if (runDir === void 0) return;
|
|
22391
|
+
const { loadCaseDossierReadingMaterial: loadCaseDossierReadingMaterial2 } = await Promise.resolve().then(() => (init_case_dossier_delivery(), case_dossier_delivery_exports));
|
|
22392
|
+
const caseDossier = await loadCaseDossierReadingMaterial2(runDir);
|
|
22393
|
+
if (caseDossier === void 0) return;
|
|
22394
|
+
return { readingMaterial: caseDossier };
|
|
22395
|
+
});
|
|
22157
22396
|
roleHost.on("tool_result", async (event) => {
|
|
22158
22397
|
const role = selectedRole;
|
|
22159
22398
|
if (role === void 0) return;
|
|
@@ -22214,7 +22453,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22214
22453
|
display: false
|
|
22215
22454
|
}, { triggerTurn: true, deliverAs: "followUp" });
|
|
22216
22455
|
} else if (receiptDelivery.nextAction() === "no-receipt" && !noReceiptRecorded) {
|
|
22217
|
-
const runPointer =
|
|
22456
|
+
const runPointer = runDirectoryFromHostContext(ctx);
|
|
22218
22457
|
if (runPointer !== void 0) {
|
|
22219
22458
|
noReceiptRecorded = true;
|
|
22220
22459
|
const facts = receiptDelivery.facts({ runPointer, attemptPointer: `current:${runPointer}` });
|
|
@@ -22576,8 +22815,8 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22576
22815
|
await observe(() => observationFace.onEnd(event), ctx);
|
|
22577
22816
|
});
|
|
22578
22817
|
const recordHttpObservation = async (status, provider, ctx) => {
|
|
22579
|
-
const runDir =
|
|
22580
|
-
if (
|
|
22818
|
+
const runDir = runDirectoryFromHostContext(ctx);
|
|
22819
|
+
if (runDir === void 0) return;
|
|
22581
22820
|
try {
|
|
22582
22821
|
await recordTypedProviderHttpStatus(runDir, { httpStatus: status, provider });
|
|
22583
22822
|
} catch (error) {
|
|
@@ -22600,8 +22839,8 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22600
22839
|
const underlying = priorFetch;
|
|
22601
22840
|
globalThis.fetch = (async (input, init) => {
|
|
22602
22841
|
const response = await underlying(input, init);
|
|
22603
|
-
const runDir =
|
|
22604
|
-
if (
|
|
22842
|
+
const runDir = runDirectoryFromHostContext(ctx);
|
|
22843
|
+
if (runDir !== void 0 && typeof response?.status === "number" && (response.status < 200 || response.status >= 300)) {
|
|
22605
22844
|
const provider = typeof ctx.model?.provider === "string" && ctx.model.provider.trim() !== "" ? ctx.model.provider : "unknown";
|
|
22606
22845
|
try {
|
|
22607
22846
|
await recordTypedProviderHttpStatus(runDir, {
|
|
@@ -22834,14 +23073,14 @@ async function prepareRoleEnvelope(options) {
|
|
|
22834
23073
|
for (const method of request.methods) {
|
|
22835
23074
|
if (method.kind !== "skill") continue;
|
|
22836
23075
|
const name = basename8(dirname18(method.path));
|
|
22837
|
-
const raw = await
|
|
23076
|
+
const raw = await readFile20(method.path, "utf8");
|
|
22838
23077
|
methodSkills.set(name, { path: method.path, body: stripSkillFrontmatter(raw).trim() });
|
|
22839
23078
|
}
|
|
22840
|
-
let sessionFile = options.sessionFile ??
|
|
23079
|
+
let sessionFile = options.sessionFile ?? join37(request.runDirectory, "session", "session.jsonl");
|
|
22841
23080
|
await mkdir6(dirname18(sessionFile), { recursive: true });
|
|
22842
23081
|
if (request.continuation.kind !== "resume") {
|
|
22843
23082
|
try {
|
|
22844
|
-
await
|
|
23083
|
+
await writeFile11(
|
|
22845
23084
|
sessionFile,
|
|
22846
23085
|
`${JSON.stringify({
|
|
22847
23086
|
type: "session",
|
|
@@ -22861,6 +23100,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
22861
23100
|
cwd: request.cwd,
|
|
22862
23101
|
mode: "print",
|
|
22863
23102
|
model: request.model === void 0 ? void 0 : { provider: request.model.provider },
|
|
23103
|
+
runDirectory: request.runDirectory,
|
|
23104
|
+
...request.courtAttemptId === void 0 ? {} : { courtAttemptId: request.courtAttemptId },
|
|
22864
23105
|
sessionManager: {
|
|
22865
23106
|
getLeafEntry: () => sessionEntries.at(-1),
|
|
22866
23107
|
getLeafId: () => runId,
|
|
@@ -22935,7 +23176,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
22935
23176
|
failInfrastructure: (error, _context, toolCallId) => options2.hostActions.failInfrastructure(error, options2.context, toolCallId),
|
|
22936
23177
|
bindSubmissionNonPass: options2.hostActions.bindSubmissionNonPass
|
|
22937
23178
|
},
|
|
22938
|
-
toolCallId: options2.toolCallId
|
|
23179
|
+
toolCallId: options2.toolCallId,
|
|
23180
|
+
...options2.submission === void 0 ? {} : { submission: options2.submission }
|
|
22939
23181
|
});
|
|
22940
23182
|
},
|
|
22941
23183
|
on(...registration) {
|
|
@@ -23162,17 +23404,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
23162
23404
|
const relay = fileURLToPath2(new URL("./mcp-relay.mjs", import.meta.url));
|
|
23163
23405
|
await listen(server, options.socketPath);
|
|
23164
23406
|
let disposed = false;
|
|
23165
|
-
let priorAkRoleRunDir;
|
|
23166
|
-
let priorAkRoleCourtAttempt;
|
|
23167
|
-
let runDirInjected = false;
|
|
23168
|
-
const restoreAkRoleRunEnv = () => {
|
|
23169
|
-
if (!runDirInjected) return;
|
|
23170
|
-
runDirInjected = false;
|
|
23171
|
-
if (priorAkRoleRunDir === void 0) delete process.env.AK_ROLE_RUN_DIR;
|
|
23172
|
-
else process.env.AK_ROLE_RUN_DIR = priorAkRoleRunDir;
|
|
23173
|
-
if (priorAkRoleCourtAttempt === void 0) delete process.env.AK_ROLE_COURT_ATTEMPT;
|
|
23174
|
-
else process.env.AK_ROLE_COURT_ATTEMPT = priorAkRoleCourtAttempt;
|
|
23175
|
-
};
|
|
23176
23407
|
const dispose = async () => {
|
|
23177
23408
|
if (disposed) return;
|
|
23178
23409
|
disposed = true;
|
|
@@ -23182,11 +23413,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
23182
23413
|
} catch (error) {
|
|
23183
23414
|
cleanupFailures.push(error);
|
|
23184
23415
|
}
|
|
23185
|
-
try {
|
|
23186
|
-
restoreAkRoleRunEnv();
|
|
23187
|
-
} catch (error) {
|
|
23188
|
-
cleanupFailures.push(error);
|
|
23189
|
-
}
|
|
23190
23416
|
try {
|
|
23191
23417
|
const closeAll = server.closeAllConnections;
|
|
23192
23418
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
@@ -23255,7 +23481,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
23255
23481
|
message: { role: "user", content: prompt }
|
|
23256
23482
|
});
|
|
23257
23483
|
}
|
|
23258
|
-
const methodPrompt = (await Promise.all(request.methods.map(({ path }) =>
|
|
23484
|
+
const methodPrompt = (await Promise.all(request.methods.map(({ path }) => readFile20(path, "utf8")))).join("\n\n");
|
|
23259
23485
|
const promptResults = await emit("before_agent_start", {
|
|
23260
23486
|
prompt,
|
|
23261
23487
|
systemPrompt: methodPrompt,
|
|
@@ -23274,12 +23500,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
23274
23500
|
const material = value.readingMaterial;
|
|
23275
23501
|
if (material !== void 0) readingMaterials.push(material);
|
|
23276
23502
|
}
|
|
23277
|
-
priorAkRoleRunDir = process.env.AK_ROLE_RUN_DIR;
|
|
23278
|
-
priorAkRoleCourtAttempt = process.env.AK_ROLE_COURT_ATTEMPT;
|
|
23279
|
-
process.env.AK_ROLE_RUN_DIR = request.runDirectory;
|
|
23280
|
-
if (request.courtAttemptId === void 0) delete process.env.AK_ROLE_COURT_ATTEMPT;
|
|
23281
|
-
else process.env.AK_ROLE_COURT_ATTEMPT = request.courtAttemptId;
|
|
23282
|
-
runDirInjected = true;
|
|
23283
23503
|
const terminating = tools.get(terminatingToolName);
|
|
23284
23504
|
if (terminating === void 0) {
|
|
23285
23505
|
throw new Error(`terminating tool not registered after activation: ${terminatingToolName}`);
|
|
@@ -23319,11 +23539,11 @@ async function prepareRoleEnvelope(options) {
|
|
|
23319
23539
|
}
|
|
23320
23540
|
|
|
23321
23541
|
// src/role-runtime-dependencies.ts
|
|
23322
|
-
import { readFile as
|
|
23542
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
23323
23543
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
23324
23544
|
|
|
23325
23545
|
// src/canonical-skill-binding.ts
|
|
23326
|
-
import { readFile as
|
|
23546
|
+
import { readFile as readFile21, realpath as realpath7 } from "node:fs/promises";
|
|
23327
23547
|
import { homedir } from "node:os";
|
|
23328
23548
|
import { dirname as dirname19, resolve as resolve18 } from "node:path";
|
|
23329
23549
|
import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
@@ -23356,7 +23576,7 @@ async function loadCanonicalSkillBinding(name) {
|
|
|
23356
23576
|
let raw;
|
|
23357
23577
|
try {
|
|
23358
23578
|
path = await realpath7(configuredPath);
|
|
23359
|
-
raw = await
|
|
23579
|
+
raw = await readFile21(path, "utf8");
|
|
23360
23580
|
} catch (error) {
|
|
23361
23581
|
throw new CanonicalSkillUnavailableError(name, configuredPath, error);
|
|
23362
23582
|
}
|
|
@@ -23394,7 +23614,8 @@ init_doctor_evidence();
|
|
|
23394
23614
|
|
|
23395
23615
|
// src/navigator-work-context.ts
|
|
23396
23616
|
init_doctor_evidence();
|
|
23397
|
-
|
|
23617
|
+
init_host_contracts();
|
|
23618
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
23398
23619
|
import { resolve as resolve19 } from "node:path";
|
|
23399
23620
|
init_notary_source_run();
|
|
23400
23621
|
init_packaged_role_registry();
|
|
@@ -23407,7 +23628,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
23407
23628
|
}
|
|
23408
23629
|
async function loadNavigatorWorkContext(options) {
|
|
23409
23630
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
23410
|
-
const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await
|
|
23631
|
+
const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile22(reference, "utf8");
|
|
23411
23632
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
23412
23633
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
23413
23634
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -23422,9 +23643,9 @@ async function loadNavigatorWorkContext(options) {
|
|
|
23422
23643
|
subject = JSON.stringify({ sourceRun: locator });
|
|
23423
23644
|
subjectProvenance = "role_input";
|
|
23424
23645
|
}
|
|
23425
|
-
const publicRunDir =
|
|
23646
|
+
const publicRunDir = runDirectoryFromHostContext(options.context);
|
|
23426
23647
|
const currentSessionDir = options.context.sessionManager.getSessionDir();
|
|
23427
|
-
const isBoundPublicRun =
|
|
23648
|
+
const isBoundPublicRun = publicRunDir !== void 0 && resolve19(currentSessionDir) === resolve19(publicRunDir, "session");
|
|
23428
23649
|
if (options.role === "judge" && isBoundPublicRun) {
|
|
23429
23650
|
let admitted;
|
|
23430
23651
|
try {
|
|
@@ -23464,7 +23685,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
23464
23685
|
let authorityMaterial;
|
|
23465
23686
|
for (const path of authorityFiles) {
|
|
23466
23687
|
try {
|
|
23467
|
-
const content = await
|
|
23688
|
+
const content = await readFile22(path, "utf8");
|
|
23468
23689
|
if (content.trim() !== "") {
|
|
23469
23690
|
authorityMaterial = content;
|
|
23470
23691
|
break;
|
|
@@ -23531,15 +23752,16 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
23531
23752
|
const doctorAuditor = createPiDoctorAuditor();
|
|
23532
23753
|
const navigatorSessionFactory = createNativeNavigatorSessionFactory();
|
|
23533
23754
|
return {
|
|
23755
|
+
packageRoot,
|
|
23534
23756
|
loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
|
|
23535
23757
|
loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
|
|
23536
|
-
loadFixPacket: (path) =>
|
|
23758
|
+
loadFixPacket: (path) => readFile23(path, "utf8"),
|
|
23537
23759
|
loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
|
|
23538
|
-
loadCoderTask: (path) =>
|
|
23760
|
+
loadCoderTask: (path) => readFile23(path, "utf8"),
|
|
23539
23761
|
loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
|
|
23540
23762
|
createReviewerPinnedGitReader: () => createReviewerPinnedGitReader(),
|
|
23541
23763
|
loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
|
|
23542
|
-
loadCollectorHandbookSeed: () =>
|
|
23764
|
+
loadCollectorHandbookSeed: () => readFile23(collectorHandbookSeedPath, "utf8"),
|
|
23543
23765
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
23544
23766
|
loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
|
|
23545
23767
|
loadDoctorCase,
|
|
@@ -23553,7 +23775,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
23553
23775
|
loadDiaristSoul: () => loadMainRoleSessionMaterials("diarist"),
|
|
23554
23776
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
23555
23777
|
loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
|
|
23556
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
23778
|
+
loadMergerInput: async (path) => JSON.parse(await readFile23(path, "utf8")),
|
|
23557
23779
|
async loadCanonicalSkillBinding(name) {
|
|
23558
23780
|
if (name === "tdd") {
|
|
23559
23781
|
return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
|
|
@@ -23579,7 +23801,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
23579
23801
|
authority: options.authority,
|
|
23580
23802
|
invocationId: options.invocationId,
|
|
23581
23803
|
loadSoul: () => loadMainRoleSessionMaterials("navigator"),
|
|
23582
|
-
loadRoutePlaybook: () =>
|
|
23804
|
+
loadRoutePlaybook: () => readFile23(navigatorRoutePlaybookPath, "utf8"),
|
|
23583
23805
|
loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
|
|
23584
23806
|
createSession: navigatorSessionFactory,
|
|
23585
23807
|
...options.contextError === void 0 ? {} : { contextError: options.contextError },
|
|
@@ -23592,9 +23814,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
23592
23814
|
init_session_identity();
|
|
23593
23815
|
|
|
23594
23816
|
// src/acp-host/description.ts
|
|
23595
|
-
import { join as
|
|
23817
|
+
import { join as join38 } from "node:path";
|
|
23596
23818
|
function resolveAcpBinary(description, operatorHome) {
|
|
23597
|
-
return
|
|
23819
|
+
return join38(operatorHome, ...description.binaryFromHome);
|
|
23598
23820
|
}
|
|
23599
23821
|
function acpStdioArgs(description, model, seat) {
|
|
23600
23822
|
const { prefix, suffix, modelFlag, thinkingFlag } = description.argv;
|
|
@@ -23617,6 +23839,7 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
23617
23839
|
import { createInterface } from "node:readline";
|
|
23618
23840
|
|
|
23619
23841
|
// src/external-host-turn-loop.ts
|
|
23842
|
+
init_host_contracts();
|
|
23620
23843
|
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
23621
23844
|
function mergeRoleTurnAbortSignals(prepared, request) {
|
|
23622
23845
|
if (request === void 0) return prepared;
|
|
@@ -23625,6 +23848,9 @@ function mergeRoleTurnAbortSignals(prepared, request) {
|
|
|
23625
23848
|
}
|
|
23626
23849
|
function promptWithPriorNativePaths(basePrompt, request) {
|
|
23627
23850
|
if (request.continuation.kind !== "resume") return basePrompt;
|
|
23851
|
+
if (request.stationChild === true && isOfficerReviewSeat(request.activation.role)) {
|
|
23852
|
+
return basePrompt;
|
|
23853
|
+
}
|
|
23628
23854
|
const paths = request.hostTransition?.priorNativePaths;
|
|
23629
23855
|
if (paths === void 0 || paths.length === 0) return basePrompt;
|
|
23630
23856
|
return `${basePrompt}
|
|
@@ -24037,12 +24263,12 @@ function createAcpRoleTurnHost(config) {
|
|
|
24037
24263
|
// src/acp-host/seat-profile-soul.ts
|
|
24038
24264
|
import { constants as constants3 } from "node:fs";
|
|
24039
24265
|
import { access as access5, copyFile, lstat as lstat6, mkdir as mkdir7, readlink, symlink, unlink as unlink4 } from "node:fs/promises";
|
|
24040
|
-
import { dirname as dirname21, join as
|
|
24266
|
+
import { dirname as dirname21, join as join39, relative as relative3, resolve as resolve20 } from "node:path";
|
|
24041
24267
|
function seatProfileName(spec, role) {
|
|
24042
24268
|
return `${spec.namePrefix}${role}`;
|
|
24043
24269
|
}
|
|
24044
24270
|
function packageRoleSoulPath(packageRoot, role) {
|
|
24045
|
-
return
|
|
24271
|
+
return join39(packageRoot, "souls", `${role}.md`);
|
|
24046
24272
|
}
|
|
24047
24273
|
async function pathExists2(path) {
|
|
24048
24274
|
try {
|
|
@@ -24059,16 +24285,16 @@ async function ensureSeatProfileSoul(options) {
|
|
|
24059
24285
|
if (!await pathExists2(soulTarget)) {
|
|
24060
24286
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
24061
24287
|
}
|
|
24062
|
-
const profilesRoot =
|
|
24063
|
-
const profileDir =
|
|
24288
|
+
const profilesRoot = join39(operatorHome, ...spec.profilesRootFromHome);
|
|
24289
|
+
const profileDir = join39(profilesRoot, profileName);
|
|
24064
24290
|
const hostRoot = dirname21(profilesRoot);
|
|
24065
|
-
const soulPath =
|
|
24291
|
+
const soulPath = join39(profileDir, spec.soulFileName);
|
|
24066
24292
|
if (!await pathExists2(profileDir)) {
|
|
24067
24293
|
await mkdir7(profileDir, { recursive: true });
|
|
24068
24294
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
24069
|
-
const source =
|
|
24295
|
+
const source = join39(hostRoot, name);
|
|
24070
24296
|
if (!await pathExists2(source)) continue;
|
|
24071
|
-
await copyFile(source,
|
|
24297
|
+
await copyFile(source, join39(profileDir, name));
|
|
24072
24298
|
}
|
|
24073
24299
|
} else {
|
|
24074
24300
|
await mkdir7(profileDir, { recursive: true });
|