@akagilnc/pi-workflow-roles 0.1.3685 → 0.1.3702
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 +499 -559
- package/dist/analyst-gate-cycles-read.js +11 -1
- package/dist/archivist-record-entry.js +1 -1
- package/dist/auditor-dossier-tool.js +12 -0
- package/dist/dossier-resolution.js +0 -35
- package/dist/gatekeeper-pass-envelope.js +39 -34
- package/dist/gatekeeper-role.js +70 -77
- package/dist/judge-auditor.js +5 -24
- package/dist/judge-role.js +39 -42
- package/dist/notary-contracts.js +2 -17
- package/dist/notary-role.js +3 -6
- package/dist/package-contracts/judge-output.js +0 -2
- package/dist/package-contracts/terminating-tools.js +2 -2
- package/dist/public-cli/inspector-run.js +16 -2
- package/dist/public-cli/instruction-seat-run.js +14 -2
- package/dist/public-cli/main.js +189 -214
- package/dist/public-cli/notary-run.js +23 -20
- package/dist/public-cli/post-admission.js +30 -23
- package/dist/public-cli/run-lifecycle.js +6 -14
- package/dist/public-role-summons.js +38 -11
- package/dist/role-runtime.js +28 -3
- package/dist/submission-correctable-error.js +2 -1
- package/dist/submission-errors.js +26 -11
- package/dist/submission-ledger.js +7 -23
- package/extensions/role-runtime.ts +0 -2
- package/package.json +1 -1
- package/souls/countersign.md +12 -11
- package/souls/notary.md +5 -0
- package/src/acp-host/production-host.ts +1 -4
- package/src/acp-host/role-envelope.ts +1 -1
- package/src/analyst-gate-cycles-read.ts +10 -1
- package/src/archivist-record-entry.ts +7 -3
- package/src/auditor-dossier-tool.ts +21 -0
- package/src/dossier-resolution.ts +0 -39
- package/src/gatekeeper-pass-envelope.ts +59 -43
- package/src/gatekeeper-role.ts +114 -113
- package/src/host-contracts.ts +3 -3
- package/src/judge-auditor.ts +5 -43
- package/src/judge-role.ts +41 -54
- package/src/notary-contracts.ts +8 -27
- package/src/notary-role.ts +2 -7
- package/src/package-contracts/judge-output.ts +0 -1
- package/src/package-contracts/terminating-tools.ts +2 -2
- package/src/public-cli/inspector-run.ts +32 -2
- package/src/public-cli/instruction-seat-run.ts +30 -2
- package/src/public-cli/notary-run.ts +48 -16
- package/src/public-cli/post-admission.ts +31 -37
- package/src/public-cli/run-lifecycle.ts +6 -17
- package/src/public-role-summons.ts +76 -12
- package/src/role-runtime.ts +34 -9
- package/src/submission-correctable-error.ts +2 -0
- package/src/submission-errors.ts +28 -11
- package/src/submission-ledger.ts +8 -32
- package/dist/shape-unreadable-failure.js +0 -34
|
@@ -508,6 +508,7 @@ __export(auditor_dossier_tool_exports, {
|
|
|
508
508
|
AUDITOR_DOSSIER_TOOL_NAME: () => AUDITOR_DOSSIER_TOOL_NAME,
|
|
509
509
|
GATE_SUBMISSION_CANDIDATE_FILE: () => GATE_SUBMISSION_CANDIDATE_FILE,
|
|
510
510
|
auditorRunDirectory: () => auditorRunDirectory,
|
|
511
|
+
buildGateOfficerReviewInstruction: () => buildGateOfficerReviewInstruction,
|
|
511
512
|
createAuditorDossierTool: () => createAuditorDossierTool,
|
|
512
513
|
gateSubmissionCandidatePath: () => gateSubmissionCandidatePath,
|
|
513
514
|
persistGateSubmissionCandidate: () => persistGateSubmissionCandidate,
|
|
@@ -542,6 +543,17 @@ function readLatestToolCallLeaf(context) {
|
|
|
542
543
|
function gateSubmissionCandidatePath(runDirectory) {
|
|
543
544
|
return join(runDirectory, "artifacts", GATE_SUBMISSION_CANDIDATE_FILE);
|
|
544
545
|
}
|
|
546
|
+
function buildGateOfficerReviewInstruction(input) {
|
|
547
|
+
const lines = [
|
|
548
|
+
"\u672C\u8F6E\u7236\u5E2D\u4EA4\u5377\u5F85\u5BA1\u3002",
|
|
549
|
+
`\u6765\u6E90 run\uFF1A${input.sourceRunDirectory}`
|
|
550
|
+
];
|
|
551
|
+
const candidate = input.submissionCandidatePath?.trim();
|
|
552
|
+
if (candidate !== void 0 && candidate.length > 0) {
|
|
553
|
+
lines.push(`\u4EA4\u5377\u5019\u9009\uFF08\u51BB\u7ED3\u5FEB\u7167\uFF09\uFF1A${candidate}`);
|
|
554
|
+
}
|
|
555
|
+
return lines.join("\n");
|
|
556
|
+
}
|
|
545
557
|
function persistGateSubmissionCandidate(runDirectory, context) {
|
|
546
558
|
const leaf = readLatestToolCallLeaf(context);
|
|
547
559
|
if (leaf === void 0) return void 0;
|
|
@@ -2122,13 +2134,12 @@ function validateAcceptedJudgeDetails(verdict) {
|
|
|
2122
2134
|
}
|
|
2123
2135
|
throw new Error("Judge verdict has no execution discriminator");
|
|
2124
2136
|
}
|
|
2125
|
-
var JUDGE_OUTPUT_TOOL_NAME, JUDGE_ACCEPTED_TEXT
|
|
2137
|
+
var JUDGE_OUTPUT_TOOL_NAME, JUDGE_ACCEPTED_TEXT;
|
|
2126
2138
|
var init_judge_output = __esm({
|
|
2127
2139
|
"src/package-contracts/judge-output.ts"() {
|
|
2128
2140
|
"use strict";
|
|
2129
2141
|
JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
|
|
2130
2142
|
JUDGE_ACCEPTED_TEXT = "\u5927\u7406\u5BFA\u56DE\u6267\u5DF2\u63A5\u53D7";
|
|
2131
|
-
JUDGE_ACCEPTED_AUDIT_NO_RECEIPT_TEXT = "\u5927\u7406\u5BFA\u56DE\u6267\u5DF2\u63A5\u53D7\uFF1B\u5BA1\u8BA1\u65E0\u56DE\u6267";
|
|
2132
2143
|
}
|
|
2133
2144
|
});
|
|
2134
2145
|
|
|
@@ -2358,25 +2369,24 @@ var init_audit_escalation = __esm({
|
|
|
2358
2369
|
});
|
|
2359
2370
|
|
|
2360
2371
|
// src/submission-errors.ts
|
|
2372
|
+
function serializeReceipt(receipt) {
|
|
2373
|
+
return readableGateItem(receipt);
|
|
2374
|
+
}
|
|
2361
2375
|
function gatekeeperNonPassMessage(result) {
|
|
2362
|
-
if (result.status === "bounce") {
|
|
2363
|
-
|
|
2364
|
-
return `\u95E8\u4E0B\u7701\u6253\u56DE\u91CD\u5199\uFF0Cfindings\uFF1A${findings}`;
|
|
2365
|
-
}
|
|
2366
|
-
if (result.status === "unreadable") {
|
|
2367
|
-
return `\u95E8\u4E0B\u7701\u5B98\u56DE\u6267\u5F62\u72B6\u4E0D\u53EF\u8BFB\uFF08${result.officer}\uFF09\uFF1A${result.reason}`;
|
|
2376
|
+
if (result.status === "bounce" || result.status === "escalate") {
|
|
2377
|
+
return serializeReceipt(result.receipt);
|
|
2368
2378
|
}
|
|
2369
2379
|
return `\u95E8\u4E0B\u7701 ${result.status}\uFF08${result.stage}\uFF09\uFF1A${result.reason}`;
|
|
2370
2380
|
}
|
|
2371
|
-
var GatekeeperDecisionError, WorkerCommitReminderError, WorkerPrefixReminderError, WorkerUnfinishedReasonReminderError;
|
|
2381
|
+
var GatekeeperDecisionError, WorkerCommitReminderError, WorkerPrefixReminderError, WorkerUnfinishedReasonReminderError, ParentQueueReaskError;
|
|
2372
2382
|
var init_submission_errors = __esm({
|
|
2373
2383
|
"src/submission-errors.ts"() {
|
|
2374
2384
|
"use strict";
|
|
2375
2385
|
init_readable_gate_item();
|
|
2376
2386
|
GatekeeperDecisionError = class extends Error {
|
|
2377
2387
|
result;
|
|
2378
|
-
constructor(result) {
|
|
2379
|
-
super(gatekeeperNonPassMessage(result));
|
|
2388
|
+
constructor(result, message) {
|
|
2389
|
+
super(message ?? gatekeeperNonPassMessage(result));
|
|
2380
2390
|
this.name = "GatekeeperDecisionError";
|
|
2381
2391
|
this.result = result;
|
|
2382
2392
|
}
|
|
@@ -2402,6 +2412,13 @@ var init_submission_errors = __esm({
|
|
|
2402
2412
|
this.name = "WorkerUnfinishedReasonReminderError";
|
|
2403
2413
|
}
|
|
2404
2414
|
};
|
|
2415
|
+
ParentQueueReaskError = class extends Error {
|
|
2416
|
+
code = "parent_queue_reask";
|
|
2417
|
+
constructor(message) {
|
|
2418
|
+
super(message);
|
|
2419
|
+
this.name = "ParentQueueReaskError";
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2405
2422
|
}
|
|
2406
2423
|
});
|
|
2407
2424
|
|
|
@@ -2410,7 +2427,7 @@ function isCorrectableSubmissionError(error) {
|
|
|
2410
2427
|
return error instanceof CorrectableSubmissionError;
|
|
2411
2428
|
}
|
|
2412
2429
|
function isCorrectableExecuteError(error) {
|
|
2413
|
-
return isCorrectableSubmissionError(error) || error instanceof GatekeeperDecisionError || error instanceof WorkerCommitReminderError || error instanceof WorkerPrefixReminderError || error instanceof WorkerUnfinishedReasonReminderError;
|
|
2430
|
+
return isCorrectableSubmissionError(error) || error instanceof GatekeeperDecisionError || error instanceof ParentQueueReaskError || error instanceof WorkerCommitReminderError || error instanceof WorkerPrefixReminderError || error instanceof WorkerUnfinishedReasonReminderError;
|
|
2414
2431
|
}
|
|
2415
2432
|
var correctableSubmissionErrorBrand, CorrectableSubmissionError;
|
|
2416
2433
|
var init_submission_correctable_error = __esm({
|
|
@@ -3082,36 +3099,13 @@ import { Type as Type10 } from "typebox";
|
|
|
3082
3099
|
function isRecord10(value) {
|
|
3083
3100
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3084
3101
|
}
|
|
3085
|
-
function asStringArray2(value) {
|
|
3086
|
-
if (!Array.isArray(value)) return [];
|
|
3087
|
-
return value.filter((item) => typeof item === "string");
|
|
3088
|
-
}
|
|
3089
3102
|
function projectLawfulNotaryOutput(value) {
|
|
3090
3103
|
if (!isRecord10(value)) return void 0;
|
|
3091
3104
|
const status = typeof value.status === "string" ? value.status : void 0;
|
|
3092
|
-
if (status === "bounce") {
|
|
3093
|
-
const clone = structuredClone(value);
|
|
3094
|
-
if (clone.disposition === void 0) clone.disposition = "rewrite";
|
|
3095
|
-
if (!Array.isArray(clone.findings)) clone.findings = asStringArray2(clone.findings);
|
|
3096
|
-
return clone;
|
|
3097
|
-
}
|
|
3098
|
-
if (status === "pass") {
|
|
3099
|
-
const clone = structuredClone(value);
|
|
3100
|
-
if (!Array.isArray(clone.findings)) clone.findings = asStringArray2(clone.findings);
|
|
3101
|
-
return clone;
|
|
3102
|
-
}
|
|
3103
|
-
if (status === "escalate") {
|
|
3104
|
-
return structuredClone(value);
|
|
3105
|
-
}
|
|
3106
|
-
return void 0;
|
|
3107
|
-
}
|
|
3108
|
-
function retainNotarySubmission(value) {
|
|
3109
|
-
if (value === void 0) return { missing: "arguments" };
|
|
3110
|
-
try {
|
|
3111
|
-
return structuredClone(value);
|
|
3112
|
-
} catch {
|
|
3105
|
+
if (status === "bounce" || status === "pass" || status === "escalate") {
|
|
3113
3106
|
return value;
|
|
3114
3107
|
}
|
|
3108
|
+
return void 0;
|
|
3115
3109
|
}
|
|
3116
3110
|
function validateRecordedNotaryOutput(value) {
|
|
3117
3111
|
const projected = projectLawfulNotaryOutput(value);
|
|
@@ -3504,10 +3498,10 @@ function validateAcceptedDetails(toolName, details) {
|
|
|
3504
3498
|
[COLLECTOR_OUTPUT_TOOL]: [],
|
|
3505
3499
|
[DOCTOR_OUTPUT_TOOL_NAME]: ["completed", "refused"],
|
|
3506
3500
|
[MERGER_OUTPUT_TOOL_NAME]: ["completed", "escalate"],
|
|
3507
|
-
[NOTARY_OUTPUT_TOOL_NAME]: ["pass", "bounce"],
|
|
3501
|
+
[NOTARY_OUTPUT_TOOL_NAME]: ["pass", "bounce", "escalate"],
|
|
3508
3502
|
[COUNTERSIGN_OUTPUT_TOOL_NAME]: ["converged", "continue", "escalate"],
|
|
3509
3503
|
[GLEANER_LEFT_OUTPUT_TOOL_NAME]: ["completed"],
|
|
3510
|
-
[INSPECTOR_OUTPUT_TOOL_NAME]: ["pass", "bounce"],
|
|
3504
|
+
[INSPECTOR_OUTPUT_TOOL_NAME]: ["pass", "bounce", "escalate"],
|
|
3511
3505
|
[GATEKEEPER_OUTPUT_TOOL_NAME]: ["dispatch", "pass"],
|
|
3512
3506
|
[NAVIGATOR_OUTPUT_TOOL_NAME]: ["advice"],
|
|
3513
3507
|
[AUDITOR_OUTPUT_TOOL_NAME]: ["pass", "bounce", "escalate"],
|
|
@@ -4117,13 +4111,6 @@ function instructResumeHandbookRead(prompt, engineMaterial) {
|
|
|
4117
4111
|
return line2;
|
|
4118
4112
|
}).join("\n");
|
|
4119
4113
|
}
|
|
4120
|
-
function appendResumeMaterialReread(prompt, materialPath) {
|
|
4121
|
-
const instruction = resumeRereadInstruction(materialPath, false);
|
|
4122
|
-
const lines = prompt.split("\n");
|
|
4123
|
-
if (lines.includes(instruction)) return prompt;
|
|
4124
|
-
return prompt.length === 0 ? instruction : `${prompt}
|
|
4125
|
-
${instruction}`;
|
|
4126
|
-
}
|
|
4127
4114
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
4128
4115
|
const base = message !== void 0 ? message : RESUME_TRANSPORT_ENVELOPE;
|
|
4129
4116
|
return instructResumeHandbookRead(
|
|
@@ -9816,202 +9803,6 @@ var init_public_run_credentials = __esm({
|
|
|
9816
9803
|
}
|
|
9817
9804
|
});
|
|
9818
9805
|
|
|
9819
|
-
// src/shape-unreadable-failure.ts
|
|
9820
|
-
function isRecord12(value) {
|
|
9821
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9822
|
-
}
|
|
9823
|
-
function retainedShapeUnreadable(decisiveFacts) {
|
|
9824
|
-
if (!isRecord12(decisiveFacts)) return void 0;
|
|
9825
|
-
if (decisiveFacts[SHAPE_UNREADABLE_KEY] === true) {
|
|
9826
|
-
return { candidate: decisiveFacts.candidate };
|
|
9827
|
-
}
|
|
9828
|
-
const secondary = isRecord12(decisiveFacts.secondaryEvidence) ? decisiveFacts.secondaryEvidence : void 0;
|
|
9829
|
-
if (secondary !== void 0 && secondary[SHAPE_UNREADABLE_KEY] === true) {
|
|
9830
|
-
return { candidate: secondary.candidate };
|
|
9831
|
-
}
|
|
9832
|
-
return void 0;
|
|
9833
|
-
}
|
|
9834
|
-
var SHAPE_UNREADABLE_KEY;
|
|
9835
|
-
var init_shape_unreadable_failure = __esm({
|
|
9836
|
-
"src/shape-unreadable-failure.ts"() {
|
|
9837
|
-
"use strict";
|
|
9838
|
-
SHAPE_UNREADABLE_KEY = "shapeUnreadable";
|
|
9839
|
-
}
|
|
9840
|
-
});
|
|
9841
|
-
|
|
9842
|
-
// src/gatekeeper-role.ts
|
|
9843
|
-
function gateSeatLabel(stage) {
|
|
9844
|
-
return stage === "inspector" ? "\u5BDF\u9662" : "\u7B26\u5B9D\u90CE";
|
|
9845
|
-
}
|
|
9846
|
-
function failureReason(error) {
|
|
9847
|
-
if (error instanceof AggregateError) return error.errors.map(failureReason).join("; ");
|
|
9848
|
-
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
9849
|
-
}
|
|
9850
|
-
function asStringArray3(value) {
|
|
9851
|
-
if (!Array.isArray(value)) return [];
|
|
9852
|
-
return value.map(readableGateItem);
|
|
9853
|
-
}
|
|
9854
|
-
function isRecord13(value) {
|
|
9855
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9856
|
-
}
|
|
9857
|
-
function retainedSubmission(decision) {
|
|
9858
|
-
return decision === void 0 || isRecord13(decision) && Object.keys(decision).length === 0 ? MISSING_ARGUMENTS_SUBMISSION : decision;
|
|
9859
|
-
}
|
|
9860
|
-
function shapeUnreadable(officer, decision, reason = "decision \u65E0\u663E\u5F0F pass/bounce/escalate") {
|
|
9861
|
-
return {
|
|
9862
|
-
status: "unreadable",
|
|
9863
|
-
officer,
|
|
9864
|
-
reason,
|
|
9865
|
-
submission: retainedSubmission(decision)
|
|
9866
|
-
};
|
|
9867
|
-
}
|
|
9868
|
-
function readRecord(value) {
|
|
9869
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
9870
|
-
return value;
|
|
9871
|
-
}
|
|
9872
|
-
function projectOfficerDecision(officer, decision) {
|
|
9873
|
-
const record4 = readRecord(decision);
|
|
9874
|
-
if (record4 === void 0) return shapeUnreadable(officer, decision);
|
|
9875
|
-
if (record4.status === "bounce") {
|
|
9876
|
-
return {
|
|
9877
|
-
status: "bounce",
|
|
9878
|
-
officer,
|
|
9879
|
-
disposition: "rewrite",
|
|
9880
|
-
findings: asStringArray3(record4.findings),
|
|
9881
|
-
submission: retainedSubmission(decision)
|
|
9882
|
-
};
|
|
9883
|
-
}
|
|
9884
|
-
if (record4.status === "pass") {
|
|
9885
|
-
return {
|
|
9886
|
-
status: "pass",
|
|
9887
|
-
officer,
|
|
9888
|
-
findings: asStringArray3(record4.findings)
|
|
9889
|
-
};
|
|
9890
|
-
}
|
|
9891
|
-
if (record4.status === "escalate") {
|
|
9892
|
-
return {
|
|
9893
|
-
status: "escalate",
|
|
9894
|
-
officer,
|
|
9895
|
-
...Object.hasOwn(record4, "reason") ? { reason: record4.reason } : {},
|
|
9896
|
-
findings: record4.findings,
|
|
9897
|
-
submission: retainedSubmission(decision)
|
|
9898
|
-
};
|
|
9899
|
-
}
|
|
9900
|
-
return shapeUnreadable(officer, decision);
|
|
9901
|
-
}
|
|
9902
|
-
function projectOfficerTerminal(officer, summoned) {
|
|
9903
|
-
const terminal = summoned.terminal;
|
|
9904
|
-
const outcome = terminal?.roleOutcome;
|
|
9905
|
-
if (outcome === void 0) {
|
|
9906
|
-
const detail = summoned.stderr?.trim();
|
|
9907
|
-
return {
|
|
9908
|
-
status: "transport_failure",
|
|
9909
|
-
stage: officer,
|
|
9910
|
-
reason: detail && detail.length > 0 ? `${gateSeatLabel(officer)} public summon exit ${summoned.exitCode}: ${detail}` : `${gateSeatLabel(officer)} public summon produced no terminal (exit ${summoned.exitCode})`,
|
|
9911
|
-
submission: summoned
|
|
9912
|
-
};
|
|
9913
|
-
}
|
|
9914
|
-
if (outcome.kind === "no_receipt") {
|
|
9915
|
-
return {
|
|
9916
|
-
status: "no_receipt",
|
|
9917
|
-
stage: officer,
|
|
9918
|
-
reason: `${gateSeatLabel(officer)}\u672A\u4EA7\u751F\u5DF2\u63A5\u53D7\u56DE\u6267\u5373\u6563\u5C40`,
|
|
9919
|
-
facts: outcome
|
|
9920
|
-
};
|
|
9921
|
-
}
|
|
9922
|
-
if (outcome.kind === "failure") {
|
|
9923
|
-
const shape = retainedShapeUnreadable(outcome.decisiveFacts);
|
|
9924
|
-
if (shape !== void 0) {
|
|
9925
|
-
return shapeUnreadable(officer, shape.candidate, outcome.diagnostic);
|
|
9926
|
-
}
|
|
9927
|
-
return {
|
|
9928
|
-
status: "transport_failure",
|
|
9929
|
-
stage: officer,
|
|
9930
|
-
reason: outcome.diagnostic,
|
|
9931
|
-
submission: outcome.decisiveFacts
|
|
9932
|
-
};
|
|
9933
|
-
}
|
|
9934
|
-
if (outcome.kind === "accepted") {
|
|
9935
|
-
return projectOfficerDecision(officer, {
|
|
9936
|
-
status: outcome.status,
|
|
9937
|
-
...outcome.decisiveFacts
|
|
9938
|
-
});
|
|
9939
|
-
}
|
|
9940
|
-
return {
|
|
9941
|
-
status: "transport_failure",
|
|
9942
|
-
stage: officer,
|
|
9943
|
-
reason: `${gateSeatLabel(officer)} public summon returned unusable terminal kind`,
|
|
9944
|
-
submission: outcome
|
|
9945
|
-
};
|
|
9946
|
-
}
|
|
9947
|
-
async function projectGatekeeperRun(options) {
|
|
9948
|
-
const officer = options.subject.kind === "worker_completion" ? "inspector" : "notary";
|
|
9949
|
-
const runDirectory = options.runDirectory ?? auditorRunDirectory(options.context);
|
|
9950
|
-
if (runDirectory === void 0) {
|
|
9951
|
-
return {
|
|
9952
|
-
officer,
|
|
9953
|
-
result: {
|
|
9954
|
-
status: "transport_failure",
|
|
9955
|
-
stage: officer,
|
|
9956
|
-
reason: `${gateSeatLabel(officer)} requires a parent run directory pointer`
|
|
9957
|
-
}
|
|
9958
|
-
};
|
|
9959
|
-
}
|
|
9960
|
-
persistGateSubmissionCandidate(runDirectory, options.context);
|
|
9961
|
-
let summoned;
|
|
9962
|
-
try {
|
|
9963
|
-
const summon = options.summonOfficer ?? (async (nextOfficer, sourceRunDirectory, officerSignal) => {
|
|
9964
|
-
const { summonGateOfficer: summonGateOfficer2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
9965
|
-
return summonGateOfficer2({
|
|
9966
|
-
officer: nextOfficer,
|
|
9967
|
-
sourceRunDirectory,
|
|
9968
|
-
cwd: options.context.cwd ?? process.cwd(),
|
|
9969
|
-
...officerSignal === void 0 ? {} : { signal: officerSignal }
|
|
9970
|
-
});
|
|
9971
|
-
});
|
|
9972
|
-
summoned = await summon(officer, runDirectory, options.signal);
|
|
9973
|
-
} catch (error) {
|
|
9974
|
-
return {
|
|
9975
|
-
officer,
|
|
9976
|
-
result: { status: "transport_failure", stage: officer, reason: failureReason(error) }
|
|
9977
|
-
};
|
|
9978
|
-
}
|
|
9979
|
-
return {
|
|
9980
|
-
officer,
|
|
9981
|
-
result: projectOfficerTerminal(officer, summoned),
|
|
9982
|
-
summoned
|
|
9983
|
-
};
|
|
9984
|
-
}
|
|
9985
|
-
var GatekeeperEscalationError, GATEKEEPER_TOOL_SPEC, MISSING_ARGUMENTS_SUBMISSION;
|
|
9986
|
-
var init_gatekeeper_role = __esm({
|
|
9987
|
-
"src/gatekeeper-role.ts"() {
|
|
9988
|
-
"use strict";
|
|
9989
|
-
init_auditor_dossier_tool();
|
|
9990
|
-
init_submission_errors();
|
|
9991
|
-
init_readable_gate_item();
|
|
9992
|
-
init_inspector_contracts();
|
|
9993
|
-
init_gatekeeper_output();
|
|
9994
|
-
init_shape_unreadable_failure();
|
|
9995
|
-
init_submission_errors();
|
|
9996
|
-
GatekeeperEscalationError = class extends Error {
|
|
9997
|
-
gatekeeper;
|
|
9998
|
-
constructor(gatekeeper) {
|
|
9999
|
-
super(`\u95E8\u4E0B\u7701${gateSeatLabel(gatekeeper.officer)}\u4E0A\u5448`);
|
|
10000
|
-
this.name = "GatekeeperEscalationError";
|
|
10001
|
-
this.gatekeeper = gatekeeper;
|
|
10002
|
-
}
|
|
10003
|
-
};
|
|
10004
|
-
GATEKEEPER_TOOL_SPEC = {
|
|
10005
|
-
name: GATEKEEPER_OUTPUT_TOOL_NAME,
|
|
10006
|
-
label: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
|
|
10007
|
-
description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\uFF0C\u72B6\u6001\u4E3A dispatch \u6216 pass\u3002",
|
|
10008
|
-
promptSnippet: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
|
|
10009
|
-
parameters: gatekeeperOutputSchema
|
|
10010
|
-
};
|
|
10011
|
-
MISSING_ARGUMENTS_SUBMISSION = Object.freeze({ missing: "arguments" });
|
|
10012
|
-
}
|
|
10013
|
-
});
|
|
10014
|
-
|
|
10015
9806
|
// src/run-terminal-artifacts.ts
|
|
10016
9807
|
import { basename as basename6, dirname as dirname10, join as join18 } from "node:path";
|
|
10017
9808
|
function runIdFromRunDirectory(runDirectory) {
|
|
@@ -10237,12 +10028,6 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
10237
10028
|
const append = (event) => appendFor(state, context, runId, attemptId, event);
|
|
10238
10029
|
if (state.sealedAttemptIds.has(attemptId)) throw new Error("\u63D0\u4EA4\u8D26\u5DF2\u5C01\u8D26");
|
|
10239
10030
|
append({ type: "candidate", attemptId, toolCallId, toolName: tool.name, sequence: ++state.sequence });
|
|
10240
|
-
const projectOfficerEscalation = (officer, original, deliveredOutput = original) => projectAuditEscalation({
|
|
10241
|
-
...original,
|
|
10242
|
-
status: "escalate",
|
|
10243
|
-
officer,
|
|
10244
|
-
reason: original.reason === void 0 ? `\u95E8\u4E0B\u7701${officer}\u4E0A\u5448\uFF08\u539F\u5377\u672A\u9644 reason\uFF09` : original.reason
|
|
10245
|
-
}, deliveredOutput);
|
|
10246
10031
|
let result;
|
|
10247
10032
|
try {
|
|
10248
10033
|
failOnInfrastructureFailureDeclaration(
|
|
@@ -10258,14 +10043,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
10258
10043
|
);
|
|
10259
10044
|
result = await tool.execute(toolCallId, params, signal, update, context);
|
|
10260
10045
|
} catch (error) {
|
|
10261
|
-
if (error
|
|
10262
|
-
const decision = error.gatekeeper;
|
|
10263
|
-
result = projectOfficerEscalation(
|
|
10264
|
-
error.gatekeeper.officer,
|
|
10265
|
-
decision,
|
|
10266
|
-
params
|
|
10267
|
-
);
|
|
10268
|
-
} else if (isCorrectableExecuteError(error)) {
|
|
10046
|
+
if (isCorrectableExecuteError(error)) {
|
|
10269
10047
|
append({
|
|
10270
10048
|
type: "outcome",
|
|
10271
10049
|
attemptId,
|
|
@@ -10286,10 +10064,6 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
10286
10064
|
throw error;
|
|
10287
10065
|
}
|
|
10288
10066
|
}
|
|
10289
|
-
if ((role === "inspector" || role === "notary") && typeof result.details === "object" && result.details !== null && !Array.isArray(result.details) && result.details.status === "escalate") {
|
|
10290
|
-
const details = result.details;
|
|
10291
|
-
result = projectOfficerEscalation(role, details);
|
|
10292
|
-
}
|
|
10293
10067
|
if (isAuditEscalationProjection(result.details)) {
|
|
10294
10068
|
const candidates2 = rounds.get(attemptId) ?? [];
|
|
10295
10069
|
candidates2.push({
|
|
@@ -10337,7 +10111,6 @@ var init_submission_ledger = __esm({
|
|
|
10337
10111
|
"use strict";
|
|
10338
10112
|
init_activation_ledger_topology();
|
|
10339
10113
|
init_audit_escalation();
|
|
10340
|
-
init_gatekeeper_role();
|
|
10341
10114
|
init_terminating_tools();
|
|
10342
10115
|
init_run_terminal_artifacts();
|
|
10343
10116
|
init_sitian_facade();
|
|
@@ -10349,7 +10122,7 @@ var init_submission_ledger = __esm({
|
|
|
10349
10122
|
|
|
10350
10123
|
// src/ledger-session-read.ts
|
|
10351
10124
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
10352
|
-
function
|
|
10125
|
+
function isRecord12(value) {
|
|
10353
10126
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10354
10127
|
}
|
|
10355
10128
|
async function readLedgerSessionJsonl(path) {
|
|
@@ -10373,7 +10146,7 @@ async function readLedgerSessionJsonl(path) {
|
|
|
10373
10146
|
}
|
|
10374
10147
|
break;
|
|
10375
10148
|
}
|
|
10376
|
-
if (!
|
|
10149
|
+
if (!isRecord12(row)) {
|
|
10377
10150
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
10378
10151
|
throw new LedgerSessionJsonlError(
|
|
10379
10152
|
`complete non-object JSONL record in ${path} at line ${index + 1}: expected object, got ${kind}`,
|
|
@@ -10436,7 +10209,7 @@ var init_ledger_session_read = __esm({
|
|
|
10436
10209
|
// src/analyst-gate-cycles-read.ts
|
|
10437
10210
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
10438
10211
|
import { join as join19 } from "node:path";
|
|
10439
|
-
function
|
|
10212
|
+
function isRecord13(value) {
|
|
10440
10213
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10441
10214
|
}
|
|
10442
10215
|
function isParentAttemptBindingRow(row) {
|
|
@@ -10467,7 +10240,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
10467
10240
|
function acceptedGateReceiptIds(rows) {
|
|
10468
10241
|
const accepted = /* @__PURE__ */ new Set();
|
|
10469
10242
|
for (const row of rows) {
|
|
10470
|
-
const message =
|
|
10243
|
+
const message = isRecord13(row.message) ? row.message : void 0;
|
|
10471
10244
|
if (message?.role !== "toolResult") continue;
|
|
10472
10245
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
10473
10246
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -10506,7 +10279,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
10506
10279
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
10507
10280
|
const row = rows[i];
|
|
10508
10281
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
10509
|
-
if (!
|
|
10282
|
+
if (!isRecord13(row.data) || !isRecord13(row.data.parent)) continue;
|
|
10510
10283
|
const id = row.data.parent.attemptEntryId;
|
|
10511
10284
|
const sessionFile = row.data.parent.sessionFile;
|
|
10512
10285
|
return {
|
|
@@ -10521,10 +10294,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
10521
10294
|
const out = [];
|
|
10522
10295
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
10523
10296
|
const row = rows[rowIndex];
|
|
10524
|
-
const message =
|
|
10297
|
+
const message = isRecord13(row.message) ? row.message : void 0;
|
|
10525
10298
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
10526
10299
|
for (const part of message.content) {
|
|
10527
|
-
if (!
|
|
10300
|
+
if (!isRecord13(part) || part.type !== "toolCall") continue;
|
|
10528
10301
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
10529
10302
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
10530
10303
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -10532,7 +10305,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
10532
10305
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
10533
10306
|
out.push({
|
|
10534
10307
|
toolName: part.name,
|
|
10535
|
-
args:
|
|
10308
|
+
args: isRecord13(part.arguments) ? part.arguments : void 0,
|
|
10536
10309
|
accepted: true,
|
|
10537
10310
|
rowIndex,
|
|
10538
10311
|
...binding
|
|
@@ -10672,7 +10445,7 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
10672
10445
|
{ cause: error }
|
|
10673
10446
|
);
|
|
10674
10447
|
}
|
|
10675
|
-
if (!
|
|
10448
|
+
if (!isRecord13(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
10676
10449
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
10677
10450
|
}
|
|
10678
10451
|
const sessionFile = raw.sessionFile;
|
|
@@ -10684,6 +10457,7 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
10684
10457
|
async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, options = {}) {
|
|
10685
10458
|
const directories = typeof auditorRolesDirectory === "string" ? [auditorRolesDirectory] : auditorRolesDirectory;
|
|
10686
10459
|
const volumes = [];
|
|
10460
|
+
const classifiedOfficerSessions = /* @__PURE__ */ new Set();
|
|
10687
10461
|
for (const directory of directories) {
|
|
10688
10462
|
let names;
|
|
10689
10463
|
try {
|
|
@@ -10697,8 +10471,13 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
10697
10471
|
}
|
|
10698
10472
|
for (const name of names) {
|
|
10699
10473
|
const path = join19(directory, name);
|
|
10700
|
-
const
|
|
10474
|
+
const fromPointer = name.endsWith(".pointer.json");
|
|
10475
|
+
const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
|
|
10701
10476
|
if (sessionPath === void 0) continue;
|
|
10477
|
+
if (fromPointer) {
|
|
10478
|
+
if (classifiedOfficerSessions.has(sessionPath)) continue;
|
|
10479
|
+
classifiedOfficerSessions.add(sessionPath);
|
|
10480
|
+
}
|
|
10702
10481
|
const classified = await classifyAuditorVolume(sessionPath);
|
|
10703
10482
|
for (const volume of classified) {
|
|
10704
10483
|
if (options.parentSessionFile !== void 0 && volume.parentSessionFile !== void 0 && volume.parentSessionFile !== options.parentSessionFile) {
|
|
@@ -10847,112 +10626,10 @@ var init_auditor_soul = __esm({
|
|
|
10847
10626
|
}
|
|
10848
10627
|
});
|
|
10849
10628
|
|
|
10850
|
-
// src/dossier-resolution.ts
|
|
10851
|
-
import { existsSync as existsSync8, statSync as statSync2 } from "node:fs";
|
|
10852
|
-
import { resolve as resolve10 } from "node:path";
|
|
10853
|
-
function resolveAuditDossier(env = process.env) {
|
|
10854
|
-
const raw = env[AUDIT_RUN_DIR_ENV];
|
|
10855
|
-
if (typeof raw !== "string" || raw.trim() === "") {
|
|
10856
|
-
return { status: "ok" };
|
|
10857
|
-
}
|
|
10858
|
-
const runDirectory = resolve10(raw);
|
|
10859
|
-
try {
|
|
10860
|
-
if (!existsSync8(runDirectory) || !statSync2(runDirectory).isDirectory()) {
|
|
10861
|
-
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
10862
|
-
}
|
|
10863
|
-
} catch {
|
|
10864
|
-
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
10865
|
-
}
|
|
10866
|
-
return { status: "ok", runDirectory };
|
|
10867
|
-
}
|
|
10868
|
-
function isRecord16(value) {
|
|
10869
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10870
|
-
}
|
|
10871
|
-
function readJudgeAuditSubjects(context) {
|
|
10872
|
-
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
10873
|
-
let hasAssignment = false;
|
|
10874
|
-
let hasCandidate = false;
|
|
10875
|
-
for (const entry of entries) {
|
|
10876
|
-
if (!isRecord16(entry) || entry.type !== "message" || !isRecord16(entry.message)) continue;
|
|
10877
|
-
const message = entry.message;
|
|
10878
|
-
if (message.role === "user") {
|
|
10879
|
-
const text = typeof message.content === "string" ? message.content : Array.isArray(message.content) ? message.content.map((part) => isRecord16(part) && part.type === "text" && typeof part.text === "string" ? part.text : "").join("") : "";
|
|
10880
|
-
if (text.trim().length > 0) hasAssignment = true;
|
|
10881
|
-
}
|
|
10882
|
-
if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
10883
|
-
for (const part of message.content) {
|
|
10884
|
-
if (isRecord16(part) && part.type === "toolCall" && part.name === JUDGE_OUTPUT_TOOL_NAME2 && isRecord16(part.arguments)) {
|
|
10885
|
-
hasCandidate = true;
|
|
10886
|
-
}
|
|
10887
|
-
}
|
|
10888
|
-
}
|
|
10889
|
-
}
|
|
10890
|
-
if (!hasAssignment) {
|
|
10891
|
-
return { status: "incomplete", observation: { kind: "missing-subject", subject: "assignment" } };
|
|
10892
|
-
}
|
|
10893
|
-
if (!hasCandidate) {
|
|
10894
|
-
return { status: "incomplete", observation: { kind: "missing-subject", subject: "candidate-verdict" } };
|
|
10895
|
-
}
|
|
10896
|
-
return { status: "ok" };
|
|
10897
|
-
}
|
|
10898
|
-
function readDoctorAuditSubjects(context) {
|
|
10899
|
-
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
10900
|
-
for (const entry of entries) {
|
|
10901
|
-
if (isRecord16(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
10902
|
-
return { status: "ok" };
|
|
10903
|
-
}
|
|
10904
|
-
}
|
|
10905
|
-
return { status: "incomplete", observation: { kind: "missing-subject", subject: "candidate-testimony" } };
|
|
10906
|
-
}
|
|
10907
|
-
function requireAuditMaterials(resolution) {
|
|
10908
|
-
if (resolution.status === "incomplete") {
|
|
10909
|
-
throw new AuditMaterialsUnavailableError(resolution.observation);
|
|
10910
|
-
}
|
|
10911
|
-
}
|
|
10912
|
-
var JUDGE_OUTPUT_TOOL_NAME2, AUDIT_RUN_DIR_ENV, DOCTOR_CANDIDATE_ENTRY_TYPE, AuditMaterialsUnavailableError;
|
|
10913
|
-
var init_dossier_resolution = __esm({
|
|
10914
|
-
"src/dossier-resolution.ts"() {
|
|
10915
|
-
"use strict";
|
|
10916
|
-
init_judge_output();
|
|
10917
|
-
JUDGE_OUTPUT_TOOL_NAME2 = JUDGE_OUTPUT_TOOL_NAME;
|
|
10918
|
-
AUDIT_RUN_DIR_ENV = "AK_ROLE_RUN_DIR";
|
|
10919
|
-
DOCTOR_CANDIDATE_ENTRY_TYPE = "ak_doctor_audit_candidate";
|
|
10920
|
-
AuditMaterialsUnavailableError = class extends Error {
|
|
10921
|
-
observation;
|
|
10922
|
-
candidate;
|
|
10923
|
-
constructor(observation) {
|
|
10924
|
-
const detail = observation.kind === "missing-subject" ? `${observation.kind}:${observation.subject}` : observation.kind;
|
|
10925
|
-
super(`Audit materials unavailable: ${detail}`);
|
|
10926
|
-
this.name = "AuditMaterialsUnavailableError";
|
|
10927
|
-
this.observation = observation;
|
|
10928
|
-
this.candidate = void 0;
|
|
10929
|
-
}
|
|
10930
|
-
};
|
|
10931
|
-
}
|
|
10932
|
-
});
|
|
10933
|
-
|
|
10934
10629
|
// src/judge-auditor.ts
|
|
10935
|
-
function createPiJudgeAuditor() {
|
|
10936
|
-
return async (options) => {
|
|
10937
|
-
const dossier = resolveAuditDossier();
|
|
10938
|
-
requireAuditMaterials(dossier);
|
|
10939
|
-
const subjects = readJudgeAuditSubjects(options.context);
|
|
10940
|
-
requireAuditMaterials(subjects);
|
|
10941
|
-
return runComplianceAudit({
|
|
10942
|
-
subject: "judge",
|
|
10943
|
-
context: options.context,
|
|
10944
|
-
...auditorRunDirectory(options.context) === void 0 ? {} : { runDirectory: auditorRunDirectory(options.context) },
|
|
10945
|
-
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
10946
|
-
...options.summonAuditor === void 0 ? {} : { summonAuditor: options.summonAuditor }
|
|
10947
|
-
});
|
|
10948
|
-
};
|
|
10949
|
-
}
|
|
10950
10630
|
var init_judge_auditor = __esm({
|
|
10951
10631
|
"src/judge-auditor.ts"() {
|
|
10952
10632
|
"use strict";
|
|
10953
|
-
init_compliance_transport();
|
|
10954
|
-
init_auditor_dossier_tool();
|
|
10955
|
-
init_dossier_resolution();
|
|
10956
10633
|
}
|
|
10957
10634
|
});
|
|
10958
10635
|
|
|
@@ -12907,11 +12584,11 @@ function resolvePackagedMethodSkillRoot(packageRoot, name) {
|
|
|
12907
12584
|
function resolvePackagedMethodSkillPath(packageRoot, name) {
|
|
12908
12585
|
return join22(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
|
|
12909
12586
|
}
|
|
12910
|
-
function
|
|
12587
|
+
function isRecord14(value) {
|
|
12911
12588
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12912
12589
|
}
|
|
12913
12590
|
function parseProvenance(raw, expectedName) {
|
|
12914
|
-
if (!
|
|
12591
|
+
if (!isRecord14(raw)) {
|
|
12915
12592
|
throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
|
|
12916
12593
|
}
|
|
12917
12594
|
if (raw.name !== expectedName) {
|
|
@@ -12925,7 +12602,7 @@ function parseProvenance(raw, expectedName) {
|
|
|
12925
12602
|
if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
|
|
12926
12603
|
throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
|
|
12927
12604
|
}
|
|
12928
|
-
if (!
|
|
12605
|
+
if (!isRecord14(raw.upstream)) {
|
|
12929
12606
|
throw new Error(`Packaged method provenance upstream must be an object`);
|
|
12930
12607
|
}
|
|
12931
12608
|
const upstream = raw.upstream;
|
|
@@ -12952,12 +12629,12 @@ function parseProvenance(raw, expectedName) {
|
|
|
12952
12629
|
`Packaged method provenance upstream must include nonblank tag or version`
|
|
12953
12630
|
);
|
|
12954
12631
|
}
|
|
12955
|
-
if (!
|
|
12632
|
+
if (!isRecord14(raw.files)) {
|
|
12956
12633
|
throw new Error(`Packaged method provenance files must be an object`);
|
|
12957
12634
|
}
|
|
12958
12635
|
const files = {};
|
|
12959
12636
|
for (const [rel, entry] of Object.entries(raw.files)) {
|
|
12960
|
-
if (!
|
|
12637
|
+
if (!isRecord14(entry)) {
|
|
12961
12638
|
throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
|
|
12962
12639
|
}
|
|
12963
12640
|
if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
|
|
@@ -13092,7 +12769,7 @@ var init_method_skill = __esm({
|
|
|
13092
12769
|
});
|
|
13093
12770
|
|
|
13094
12771
|
// src/work-subject-identity.ts
|
|
13095
|
-
import { resolve as
|
|
12772
|
+
import { resolve as resolve10 } from "node:path";
|
|
13096
12773
|
function issueRoot(value) {
|
|
13097
12774
|
const normalized = value.replaceAll("\\", "/");
|
|
13098
12775
|
const marker = ".ak/work/issues/";
|
|
@@ -13102,7 +12779,7 @@ function issueRoot(value) {
|
|
|
13102
12779
|
return issue === void 0 || issue === "" ? void 0 : normalized.slice(0, index + marker.length) + issue;
|
|
13103
12780
|
}
|
|
13104
12781
|
function workIdentityFromCwd(cwd) {
|
|
13105
|
-
const resolvedCwd =
|
|
12782
|
+
const resolvedCwd = resolve10(cwd, ".");
|
|
13106
12783
|
const cwdIssue = issueRoot(resolvedCwd);
|
|
13107
12784
|
if (cwdIssue !== void 0) return cwdIssue;
|
|
13108
12785
|
if (resolvedCwd.includes("/.ak/work/")) return resolvedCwd;
|
|
@@ -13113,11 +12790,11 @@ function isMachineLedgerSessionPath(sessionPath) {
|
|
|
13113
12790
|
}
|
|
13114
12791
|
function subjectPath(sessionDir, cwd = process.cwd()) {
|
|
13115
12792
|
if (sessionDir === "") {
|
|
13116
|
-
return workIdentityFromCwd(cwd) ??
|
|
12793
|
+
return workIdentityFromCwd(cwd) ?? resolve10(cwd, ".ak/work");
|
|
13117
12794
|
}
|
|
13118
|
-
const resolvedSession =
|
|
12795
|
+
const resolvedSession = resolve10(cwd, sessionDir || ".ak/work");
|
|
13119
12796
|
if (isMachineLedgerSessionPath(resolvedSession)) {
|
|
13120
|
-
return workIdentityFromCwd(cwd) ??
|
|
12797
|
+
return workIdentityFromCwd(cwd) ?? resolve10(cwd, ".ak/work");
|
|
13121
12798
|
}
|
|
13122
12799
|
const issue = issueRoot(resolvedSession);
|
|
13123
12800
|
if (issue !== void 0) return issue;
|
|
@@ -13301,11 +12978,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
13301
12978
|
});
|
|
13302
12979
|
|
|
13303
12980
|
// src/receipt-delivery-policy.ts
|
|
13304
|
-
function
|
|
12981
|
+
function isRecord15(value) {
|
|
13305
12982
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13306
12983
|
}
|
|
13307
12984
|
function parseNoReceiptLifecycleFacts(input) {
|
|
13308
|
-
if (!
|
|
12985
|
+
if (!isRecord15(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord15(item) && typeof item.reason === "string")) {
|
|
13309
12986
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
13310
12987
|
}
|
|
13311
12988
|
return {
|
|
@@ -13908,7 +13585,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
13908
13585
|
const { records: records2 } = await readSitianRecords(recordFile);
|
|
13909
13586
|
for (let i = records2.length - 1; i >= 0; i -= 1) {
|
|
13910
13587
|
const payload = records2[i]?.payload;
|
|
13911
|
-
if (!
|
|
13588
|
+
if (!isRecord16(payload) || !isRecord16(payload.response)) continue;
|
|
13912
13589
|
if (typeof payload.type === "string") continue;
|
|
13913
13590
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
13914
13591
|
if (stop !== void 0) return stop;
|
|
@@ -13945,7 +13622,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
13945
13622
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
13946
13623
|
}
|
|
13947
13624
|
const header = entries.find((entry) => entry.type === "session");
|
|
13948
|
-
if (!
|
|
13625
|
+
if (!isRecord16(header) || header.parentSession !== sessionFile) continue;
|
|
13949
13626
|
const stop = extractSessionProviderStop(entries);
|
|
13950
13627
|
if (stop === void 0) continue;
|
|
13951
13628
|
const primary = knownFailureFromProviderStop(stop);
|
|
@@ -13977,12 +13654,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
13977
13654
|
return firstLine === RESUME_ENVELOPE;
|
|
13978
13655
|
};
|
|
13979
13656
|
const isResumeEnvelope = (msg) => {
|
|
13980
|
-
if (!
|
|
13657
|
+
if (!isRecord16(msg) || msg.role !== "user") return false;
|
|
13981
13658
|
const text = typeof msg.text === "string" ? msg.text : typeof msg.content === "string" ? msg.content : void 0;
|
|
13982
13659
|
if (isResumeEnvelopeBytes(text)) return true;
|
|
13983
13660
|
const content = msg.content;
|
|
13984
13661
|
if (Array.isArray(content)) {
|
|
13985
|
-
return content.some((p) =>
|
|
13662
|
+
return content.some((p) => isRecord16(p) && (isResumeEnvelopeBytes(p.text) || isResumeEnvelopeBytes(p.content)));
|
|
13986
13663
|
}
|
|
13987
13664
|
return false;
|
|
13988
13665
|
};
|
|
@@ -14014,7 +13691,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
14014
13691
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
14015
13692
|
}
|
|
14016
13693
|
const header = entries.find((entry) => entry.type === "session");
|
|
14017
|
-
if (!
|
|
13694
|
+
if (!isRecord16(header)) continue;
|
|
14018
13695
|
const bindingIndexes = [];
|
|
14019
13696
|
for (let i = 0; i < entries.length; i += 1) {
|
|
14020
13697
|
const entry = entries[i];
|
|
@@ -14028,7 +13705,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
14028
13705
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
14029
13706
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
14030
13707
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
14031
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
13708
|
+
const bindingParent = bindingEntry !== void 0 && isRecord16(bindingEntry.data) && isRecord16(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
14032
13709
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
14033
13710
|
const attemptEntryIndex = attemptEntryId === void 0 ? -1 : parentEntries.findIndex((entry) => entry.id === attemptEntryId);
|
|
14034
13711
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
@@ -14055,11 +13732,11 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
14055
13732
|
if (stop === void 0) continue;
|
|
14056
13733
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
14057
13734
|
const entry = entries[i];
|
|
14058
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
14059
|
-
const parent =
|
|
14060
|
-
const failure2 =
|
|
13735
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord16(entry.data)) continue;
|
|
13736
|
+
const parent = isRecord16(entry.data.parent) ? entry.data.parent : void 0;
|
|
13737
|
+
const failure2 = isRecord16(entry.data.failure) ? entry.data.failure : void 0;
|
|
14061
13738
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId || failure2?.cause !== "provider" && failure2?.cause !== "unrecognized") continue;
|
|
14062
|
-
const identity =
|
|
13739
|
+
const identity = isRecord16(failure2.identity) ? failure2.identity : void 0;
|
|
14063
13740
|
return {
|
|
14064
13741
|
cause: failure2.cause === "provider" ? "provider" : "unrecognized",
|
|
14065
13742
|
...identity === void 0 ? {} : { identity: {
|
|
@@ -14067,7 +13744,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
14067
13744
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
14068
13745
|
} },
|
|
14069
13746
|
...typeof failure2.diagnostic === "string" ? { diagnostic: failure2.diagnostic } : {},
|
|
14070
|
-
...
|
|
13747
|
+
...isRecord16(failure2.details) ? { details: failure2.details } : {}
|
|
14071
13748
|
};
|
|
14072
13749
|
}
|
|
14073
13750
|
}
|
|
@@ -14114,9 +13791,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
14114
13791
|
if (classification.kind !== "infrastructure") continue;
|
|
14115
13792
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
14116
13793
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
14117
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
14118
|
-
const diagnostic =
|
|
14119
|
-
const details =
|
|
13794
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord16(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
13795
|
+
const diagnostic = isRecord16(textPart) ? textPart.text : void 0;
|
|
13796
|
+
const details = isRecord16(message.details) ? message.details : classification.fact;
|
|
14120
13797
|
return {
|
|
14121
13798
|
cause: "activation",
|
|
14122
13799
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -14274,7 +13951,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
14274
13951
|
} : {}
|
|
14275
13952
|
};
|
|
14276
13953
|
}
|
|
14277
|
-
function
|
|
13954
|
+
function isRecord16(value) {
|
|
14278
13955
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14279
13956
|
}
|
|
14280
13957
|
function safelyRead(object, key) {
|
|
@@ -14366,7 +14043,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
14366
14043
|
const candidateMessage = entries[index]?.message;
|
|
14367
14044
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
14368
14045
|
for (const part of candidateMessage.content) {
|
|
14369
|
-
if (!
|
|
14046
|
+
if (!isRecord16(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
14370
14047
|
continue;
|
|
14371
14048
|
}
|
|
14372
14049
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -14438,7 +14115,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
14438
14115
|
const advisoryDiagnostic = typeof details.routePlaybookReadFailure === "string" ? { advisoryDiagnostic: details.routePlaybookReadFailure } : {};
|
|
14439
14116
|
if (disposition === "recommendation") {
|
|
14440
14117
|
const next = details.next;
|
|
14441
|
-
if (!
|
|
14118
|
+
if (!isRecord16(next) || typeof next.role !== "string") {
|
|
14442
14119
|
return {
|
|
14443
14120
|
disposition: "unavailable",
|
|
14444
14121
|
source: "unknown",
|
|
@@ -14446,7 +14123,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
14446
14123
|
};
|
|
14447
14124
|
}
|
|
14448
14125
|
const reason = typeof details.reason === "string" ? details.reason : "";
|
|
14449
|
-
const route = Array.isArray(details.route) ? details.route.filter(
|
|
14126
|
+
const route = Array.isArray(details.route) ? details.route.filter(isRecord16).map((target) => ({
|
|
14450
14127
|
role: String(target.role),
|
|
14451
14128
|
phase: navigatorPhaseValue(target.phase)
|
|
14452
14129
|
})) : void 0;
|
|
@@ -14518,7 +14195,7 @@ async function extractGateFactFromSessionDirectory(sessionDirectory, options = {
|
|
|
14518
14195
|
}
|
|
14519
14196
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
14520
14197
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
14521
|
-
if (
|
|
14198
|
+
if (isRecord16(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary")) return base;
|
|
14522
14199
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
14523
14200
|
return gate === void 0 ? base : { ...base, gate };
|
|
14524
14201
|
}
|
|
@@ -14558,7 +14235,7 @@ function extractNavigatorFact(entries) {
|
|
|
14558
14235
|
const entry = entries[i];
|
|
14559
14236
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
14560
14237
|
const details = entry.message?.details ?? entry.details;
|
|
14561
|
-
if (!
|
|
14238
|
+
if (!isRecord16(details)) {
|
|
14562
14239
|
return {
|
|
14563
14240
|
disposition: "unavailable",
|
|
14564
14241
|
source: "unknown",
|
|
@@ -14841,7 +14518,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
14841
14518
|
spec.toolName
|
|
14842
14519
|
);
|
|
14843
14520
|
if (residual !== void 0) {
|
|
14844
|
-
const details =
|
|
14521
|
+
const details = isRecord16(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
14845
14522
|
return settleFailureTerminalResult(admitted, {
|
|
14846
14523
|
cause: "output",
|
|
14847
14524
|
diagnostic: residual.diagnostic,
|
|
@@ -15635,7 +15312,7 @@ var init_auto_resume = __esm({
|
|
|
15635
15312
|
// src/public-cli/post-admission.ts
|
|
15636
15313
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
15637
15314
|
import { readFile as readFile16, writeFile as writeFile7 } from "node:fs/promises";
|
|
15638
|
-
import { isAbsolute as isAbsolute7, join as join25, resolve as
|
|
15315
|
+
import { isAbsolute as isAbsolute7, join as join25, resolve as resolve11 } from "node:path";
|
|
15639
15316
|
function appendContinuationSection(continuation, section) {
|
|
15640
15317
|
const prompt = `${continuation.prompt}
|
|
15641
15318
|
|
|
@@ -15864,24 +15541,16 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15864
15541
|
}
|
|
15865
15542
|
}
|
|
15866
15543
|
function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
|
|
15867
|
-
const engineMaterial = engineSessionMaterialFromOptions({
|
|
15868
|
-
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
15869
|
-
packageRoot: env.packageRoot
|
|
15870
|
-
});
|
|
15871
15544
|
let prompt;
|
|
15872
15545
|
if (request.message !== void 0) {
|
|
15873
|
-
if (summonsPrepared !== void 0
|
|
15874
|
-
prompt =
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
|
|
15880
|
-
|
|
15881
|
-
engineMaterial
|
|
15882
|
-
),
|
|
15883
|
-
engineMaterial
|
|
15884
|
-
);
|
|
15546
|
+
if (summonsPrepared !== void 0) {
|
|
15547
|
+
prompt = buildInstructionTransportPrompt({
|
|
15548
|
+
instruction: request.message,
|
|
15549
|
+
instructionEmpty: false,
|
|
15550
|
+
attachments: summonsPrepared.attachments
|
|
15551
|
+
});
|
|
15552
|
+
} else if (request.summons !== void 0) {
|
|
15553
|
+
prompt = request.message;
|
|
15885
15554
|
} else {
|
|
15886
15555
|
prompt = buildResumeContinuationPrompt({
|
|
15887
15556
|
packageRoot: env.packageRoot,
|
|
@@ -15890,10 +15559,9 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
15890
15559
|
});
|
|
15891
15560
|
}
|
|
15892
15561
|
} else if (summonsPrepared !== void 0) {
|
|
15893
|
-
prompt =
|
|
15894
|
-
|
|
15895
|
-
|
|
15896
|
-
);
|
|
15562
|
+
prompt = buildInstructionTransportPrompt(summonsPrepared);
|
|
15563
|
+
} else if (request.summons !== void 0) {
|
|
15564
|
+
prompt = RESUME_TRANSPORT_ENVELOPE;
|
|
15897
15565
|
} else {
|
|
15898
15566
|
prompt = buildResumeContinuationPrompt({
|
|
15899
15567
|
packageRoot: env.packageRoot,
|
|
@@ -15915,7 +15583,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
15915
15583
|
};
|
|
15916
15584
|
}
|
|
15917
15585
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
15918
|
-
const absolute = isAbsolute7(attachmentPath) ? attachmentPath :
|
|
15586
|
+
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve11(attachmentPath);
|
|
15919
15587
|
return pathContainedIn(join25(runDirectory, "attachments"), absolute);
|
|
15920
15588
|
}
|
|
15921
15589
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
@@ -16208,7 +15876,6 @@ var init_post_admission = __esm({
|
|
|
16208
15876
|
init_cli_errors();
|
|
16209
15877
|
init_invocation();
|
|
16210
15878
|
init_activation_ledger_topology();
|
|
16211
|
-
init_engine_material();
|
|
16212
15879
|
init_case_dossier_delivery();
|
|
16213
15880
|
init_host_transition_prior_native();
|
|
16214
15881
|
init_public_run_credentials();
|
|
@@ -16254,7 +15921,6 @@ __export(notary_run_exports, {
|
|
|
16254
15921
|
runPublicNotary: () => runPublicNotary,
|
|
16255
15922
|
runPublicNotaryResume: () => runPublicNotaryResume
|
|
16256
15923
|
});
|
|
16257
|
-
import { existsSync as existsSync9 } from "node:fs";
|
|
16258
15924
|
function buildNotaryTurnRequest(admitted, options) {
|
|
16259
15925
|
return projectRoleTurnRequest(
|
|
16260
15926
|
admitted,
|
|
@@ -16296,9 +15962,11 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
16296
15962
|
throw error;
|
|
16297
15963
|
}
|
|
16298
15964
|
{
|
|
15965
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
16299
15966
|
const summons = {
|
|
16300
15967
|
sourceRunPath: source.runDirectory,
|
|
16301
|
-
sourceRun: source
|
|
15968
|
+
sourceRun: source,
|
|
15969
|
+
...resumeInstruction === void 0 ? {} : { instruction: resumeInstruction, instructionEmpty: false }
|
|
16302
15970
|
};
|
|
16303
15971
|
const resumed = await tryResumeSameTicketSeatRun({
|
|
16304
15972
|
home: env.home,
|
|
@@ -16314,6 +15982,15 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
16314
15982
|
)
|
|
16315
15983
|
});
|
|
16316
15984
|
if (resumed !== void 0) return resumed;
|
|
15985
|
+
if (env.reviewReask !== void 0) {
|
|
15986
|
+
presentStructuralRejection(
|
|
15987
|
+
new CliUsageError(
|
|
15988
|
+
"notary review reask requires a prior same-parent run to resume"
|
|
15989
|
+
),
|
|
15990
|
+
io
|
|
15991
|
+
);
|
|
15992
|
+
return { exitCode: 2 };
|
|
15993
|
+
}
|
|
16317
15994
|
}
|
|
16318
15995
|
let admitted;
|
|
16319
15996
|
try {
|
|
@@ -16396,18 +16073,20 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
16396
16073
|
}
|
|
16397
16074
|
return loaded;
|
|
16398
16075
|
},
|
|
16399
|
-
buildTurnRequest: (admitted, effective) => {
|
|
16400
|
-
const
|
|
16076
|
+
buildTurnRequest: async (admitted, effective) => {
|
|
16077
|
+
const summonsPrepared = effective.summons === void 0 ? void 0 : await prepareSummonsResumeMaterials(
|
|
16078
|
+
admitted.runDirectory,
|
|
16079
|
+
effective.summons
|
|
16080
|
+
);
|
|
16081
|
+
return buildNotaryTurnRequest(
|
|
16401
16082
|
admitted,
|
|
16402
|
-
|
|
16403
|
-
|
|
16083
|
+
resumeTurnRequestProjectionOptions(
|
|
16084
|
+
admitted,
|
|
16085
|
+
effective,
|
|
16086
|
+
env,
|
|
16087
|
+
summonsPrepared
|
|
16088
|
+
)
|
|
16404
16089
|
);
|
|
16405
|
-
const candidatePath = gateSubmissionCandidatePath(admitted.sourceRunPath);
|
|
16406
|
-
const prompt = existsSync9(candidatePath) ? appendResumeMaterialReread(projection.continuation.prompt, candidatePath) : projection.continuation.prompt;
|
|
16407
|
-
return buildNotaryTurnRequest(admitted, {
|
|
16408
|
-
...projection,
|
|
16409
|
-
continuation: { kind: "resume", prompt }
|
|
16410
|
-
});
|
|
16411
16090
|
},
|
|
16412
16091
|
adapters: notaryAdapters(),
|
|
16413
16092
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -16416,7 +16095,6 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
16416
16095
|
var init_notary_run = __esm({
|
|
16417
16096
|
"src/public-cli/notary-run.ts"() {
|
|
16418
16097
|
"use strict";
|
|
16419
|
-
init_auditor_dossier_tool();
|
|
16420
16098
|
init_notary_source_run();
|
|
16421
16099
|
init_engine_material();
|
|
16422
16100
|
init_cli_errors();
|
|
@@ -16461,9 +16139,12 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
16461
16139
|
const projectRoot = parsed.project ?? env.cwd;
|
|
16462
16140
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction);
|
|
16463
16141
|
if (parentRunPath !== void 0) {
|
|
16142
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
16464
16143
|
const summons = {
|
|
16465
|
-
|
|
16466
|
-
|
|
16144
|
+
...resumeInstruction === void 0 ? {
|
|
16145
|
+
instruction: parsed.instruction,
|
|
16146
|
+
instructionEmpty: parsed.instruction.trim() === ""
|
|
16147
|
+
} : { instruction: resumeInstruction, instructionEmpty: false },
|
|
16467
16148
|
attachmentPaths: parsed.attachmentPaths
|
|
16468
16149
|
};
|
|
16469
16150
|
const resumed = await tryResumeSameTicketSeatRun({
|
|
@@ -16480,6 +16161,15 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
16480
16161
|
)
|
|
16481
16162
|
});
|
|
16482
16163
|
if (resumed !== void 0) return resumed;
|
|
16164
|
+
if (env.reviewReask !== void 0) {
|
|
16165
|
+
presentStructuralRejection(
|
|
16166
|
+
new CliUsageError(
|
|
16167
|
+
"inspector review reask requires a prior same-parent run to resume"
|
|
16168
|
+
),
|
|
16169
|
+
io
|
|
16170
|
+
);
|
|
16171
|
+
return { exitCode: 2 };
|
|
16172
|
+
}
|
|
16483
16173
|
}
|
|
16484
16174
|
let admitted;
|
|
16485
16175
|
try {
|
|
@@ -16740,9 +16430,12 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
|
|
|
16740
16430
|
return { exitCode: 2 };
|
|
16741
16431
|
}
|
|
16742
16432
|
}
|
|
16433
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
16743
16434
|
const summons = {
|
|
16744
|
-
|
|
16745
|
-
|
|
16435
|
+
...resumeInstruction === void 0 ? {
|
|
16436
|
+
instruction: parsed.instruction,
|
|
16437
|
+
instructionEmpty: parsed.instruction.trim() === ""
|
|
16438
|
+
} : { instruction: resumeInstruction, instructionEmpty: false },
|
|
16746
16439
|
attachmentPaths: parsed.attachmentPaths
|
|
16747
16440
|
};
|
|
16748
16441
|
if (role === "auditor" && auditorSourceRun !== void 0) {
|
|
@@ -16764,6 +16457,15 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
|
|
|
16764
16457
|
})
|
|
16765
16458
|
});
|
|
16766
16459
|
if (resumed !== void 0) return resumed;
|
|
16460
|
+
if (env.reviewReask !== void 0) {
|
|
16461
|
+
presentStructuralRejection(
|
|
16462
|
+
new CliUsageError(
|
|
16463
|
+
"auditor review reask requires a prior same-parent run to resume"
|
|
16464
|
+
),
|
|
16465
|
+
io
|
|
16466
|
+
);
|
|
16467
|
+
return { exitCode: 2 };
|
|
16468
|
+
}
|
|
16767
16469
|
}
|
|
16768
16470
|
let admitted;
|
|
16769
16471
|
try {
|
|
@@ -17067,7 +16769,7 @@ __export(public_role_summons_exports, {
|
|
|
17067
16769
|
summonGateOfficer: () => summonGateOfficer,
|
|
17068
16770
|
summonPublicRole: () => summonPublicRole
|
|
17069
16771
|
});
|
|
17070
|
-
import { existsSync as
|
|
16772
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
17071
16773
|
import { join as join26 } from "node:path";
|
|
17072
16774
|
function createCapturingIo() {
|
|
17073
16775
|
const chunks = [];
|
|
@@ -17091,7 +16793,7 @@ function parentDir(path) {
|
|
|
17091
16793
|
function walkPackageRoot(start) {
|
|
17092
16794
|
let dir = start;
|
|
17093
16795
|
for (let i = 0; i < 12; i += 1) {
|
|
17094
|
-
if (
|
|
16796
|
+
if (existsSync8(join26(dir, "package.json")) && existsSync8(join26(dir, "souls"))) {
|
|
17095
16797
|
return dir;
|
|
17096
16798
|
}
|
|
17097
16799
|
const parent = parentDir(dir);
|
|
@@ -17230,7 +16932,11 @@ async function summonPublicRole(options) {
|
|
|
17230
16932
|
// Host config passthrough only — same face as public CLI (#422 / #675).
|
|
17231
16933
|
...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit },
|
|
17232
16934
|
// Parent cancellation reaches the nested activation's own turn dispatch.
|
|
17233
|
-
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
16935
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
16936
|
+
// #753: reask rides the existing notary same-ticket resume summons.instruction.
|
|
16937
|
+
...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
|
|
16938
|
+
// #753/#750: new-submission pointers on same-parent resume (not conclusion re-ask).
|
|
16939
|
+
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction }
|
|
17234
16940
|
};
|
|
17235
16941
|
const captured = options.io === void 0 ? createCapturingIo() : void 0;
|
|
17236
16942
|
const io = options.io ?? captured.io;
|
|
@@ -17326,25 +17032,48 @@ async function summonGateOfficer(options) {
|
|
|
17326
17032
|
const { homeFromRunDirectory: homeFromRunDirectory2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
|
|
17327
17033
|
home = homeFromRunDirectory2(options.sourceRunDirectory);
|
|
17328
17034
|
}
|
|
17035
|
+
let gateReviewInstruction;
|
|
17036
|
+
if (options.reask === void 0) {
|
|
17037
|
+
const { buildGateOfficerReviewInstruction: buildGateOfficerReviewInstruction2 } = await Promise.resolve().then(() => (init_auditor_dossier_tool(), auditor_dossier_tool_exports));
|
|
17038
|
+
gateReviewInstruction = buildGateOfficerReviewInstruction2({
|
|
17039
|
+
sourceRunDirectory: options.sourceRunDirectory,
|
|
17040
|
+
...options.submissionCandidatePath === void 0 ? {} : { submissionCandidatePath: options.submissionCandidatePath }
|
|
17041
|
+
});
|
|
17042
|
+
}
|
|
17043
|
+
const common = {
|
|
17044
|
+
cwd: options.cwd,
|
|
17045
|
+
...home === void 0 ? {} : { home },
|
|
17046
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
17047
|
+
...options.io === void 0 ? {} : { io: options.io },
|
|
17048
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
17049
|
+
...options.reask === void 0 ? {} : { reviewReask: options.reask },
|
|
17050
|
+
...gateReviewInstruction === void 0 ? {} : { gateReviewInstruction }
|
|
17051
|
+
};
|
|
17329
17052
|
if (options.officer === "notary") {
|
|
17330
17053
|
return summonPublicRole({
|
|
17331
17054
|
role: "notary",
|
|
17332
17055
|
argv: ["--source-run", options.sourceRunDirectory, "--project", options.cwd],
|
|
17333
|
-
|
|
17334
|
-
|
|
17335
|
-
|
|
17336
|
-
|
|
17337
|
-
|
|
17056
|
+
...common
|
|
17057
|
+
});
|
|
17058
|
+
}
|
|
17059
|
+
if (options.officer === "auditor") {
|
|
17060
|
+
const { AUDITOR_DOSSIER_PROMPT: AUDITOR_DOSSIER_PROMPT2 } = await Promise.resolve().then(() => (init_compliance_transport(), compliance_transport_exports));
|
|
17061
|
+
return summonPublicRole({
|
|
17062
|
+
role: "auditor",
|
|
17063
|
+
argv: [
|
|
17064
|
+
"--subject",
|
|
17065
|
+
"judge",
|
|
17066
|
+
"--source-run",
|
|
17067
|
+
options.sourceRunDirectory,
|
|
17068
|
+
AUDITOR_DOSSIER_PROMPT2
|
|
17069
|
+
],
|
|
17070
|
+
...common
|
|
17338
17071
|
});
|
|
17339
17072
|
}
|
|
17340
17073
|
return summonPublicRole({
|
|
17341
17074
|
role: "inspector",
|
|
17342
17075
|
argv: [`\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`],
|
|
17343
|
-
|
|
17344
|
-
...home === void 0 ? {} : { home },
|
|
17345
|
-
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
17346
|
-
...options.io === void 0 ? {} : { io: options.io },
|
|
17347
|
-
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
17076
|
+
...common
|
|
17348
17077
|
});
|
|
17349
17078
|
}
|
|
17350
17079
|
var AK_ROLE_PACKAGE_ROOT_ENV;
|
|
@@ -17356,6 +17085,18 @@ var init_public_role_summons = __esm({
|
|
|
17356
17085
|
});
|
|
17357
17086
|
|
|
17358
17087
|
// src/compliance-transport.ts
|
|
17088
|
+
var compliance_transport_exports = {};
|
|
17089
|
+
__export(compliance_transport_exports, {
|
|
17090
|
+
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE: () => AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE,
|
|
17091
|
+
AUDITOR_DOSSIER_PROMPT: () => AUDITOR_DOSSIER_PROMPT,
|
|
17092
|
+
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE: () => AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE,
|
|
17093
|
+
COMPLIANCE_RESPONSE_ENTRY_TYPE: () => COMPLIANCE_RESPONSE_ENTRY_TYPE,
|
|
17094
|
+
ComplianceResponseRetentionError: () => ComplianceResponseRetentionError,
|
|
17095
|
+
complianceDecisionSchema: () => complianceDecisionSchema,
|
|
17096
|
+
readComplianceCandidate: () => readComplianceCandidate,
|
|
17097
|
+
runComplianceAudit: () => runComplianceAudit,
|
|
17098
|
+
tryReadComplianceCandidate: () => tryReadComplianceCandidate
|
|
17099
|
+
});
|
|
17359
17100
|
import { Type as Type14 } from "typebox";
|
|
17360
17101
|
function readListField(value) {
|
|
17361
17102
|
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
@@ -17448,7 +17189,7 @@ async function runComplianceAudit(options) {
|
|
|
17448
17189
|
const summoned = await summon(subject, runDirectory, options.signal);
|
|
17449
17190
|
return await projectAuditorTerminal(summoned);
|
|
17450
17191
|
}
|
|
17451
|
-
var AUDITOR_DOSSIER_PROMPT, nonblank2, decisionGateSchema, complianceDecisionSchema, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE, ComplianceResponseRetentionError;
|
|
17192
|
+
var AUDITOR_DOSSIER_PROMPT, nonblank2, decisionGateSchema, complianceDecisionSchema, COMPLIANCE_RESPONSE_ENTRY_TYPE, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE, ComplianceResponseRetentionError;
|
|
17452
17193
|
var init_compliance_transport = __esm({
|
|
17453
17194
|
"src/compliance-transport.ts"() {
|
|
17454
17195
|
"use strict";
|
|
@@ -17457,6 +17198,7 @@ var init_compliance_transport = __esm({
|
|
|
17457
17198
|
nonblank2 = Type14.String({ minLength: 1, pattern: "\\S" });
|
|
17458
17199
|
decisionGateSchema = Type14.Object({ question: nonblank2, options: Type14.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
|
|
17459
17200
|
complianceDecisionSchema = Type14.Object({ status: Type14.Unknown({ description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), violations: Type14.Array(nonblank2, { description: "\u89C2\u5BDF\u5230\u7684\u5408\u89C4\u8FDD\u89C4" }), conflicts: Type14.Array(nonblank2, { description: "\u672A\u51B3\u6743\u5A01\u6216\u6267\u884C\u51B2\u7A81" }), decisionGate: Type14.Union([decisionGateSchema, Type14.Null()], { description: "\u5347\u7EA7\u95EE\u9898\u4E0E\u53EF\u9009\u9009\u9879" }) }, { additionalProperties: true, required: [] });
|
|
17201
|
+
COMPLIANCE_RESPONSE_ENTRY_TYPE = "ak_compliance_response";
|
|
17460
17202
|
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
17461
17203
|
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
17462
17204
|
ComplianceResponseRetentionError = class extends Error {
|
|
@@ -17468,6 +17210,61 @@ var init_compliance_transport = __esm({
|
|
|
17468
17210
|
}
|
|
17469
17211
|
});
|
|
17470
17212
|
|
|
17213
|
+
// src/dossier-resolution.ts
|
|
17214
|
+
import { existsSync as existsSync9, statSync as statSync2 } from "node:fs";
|
|
17215
|
+
import { resolve as resolve12 } from "node:path";
|
|
17216
|
+
function resolveAuditDossier(env = process.env) {
|
|
17217
|
+
const raw = env[AUDIT_RUN_DIR_ENV];
|
|
17218
|
+
if (typeof raw !== "string" || raw.trim() === "") {
|
|
17219
|
+
return { status: "ok" };
|
|
17220
|
+
}
|
|
17221
|
+
const runDirectory = resolve12(raw);
|
|
17222
|
+
try {
|
|
17223
|
+
if (!existsSync9(runDirectory) || !statSync2(runDirectory).isDirectory()) {
|
|
17224
|
+
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
17225
|
+
}
|
|
17226
|
+
} catch {
|
|
17227
|
+
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
17228
|
+
}
|
|
17229
|
+
return { status: "ok", runDirectory };
|
|
17230
|
+
}
|
|
17231
|
+
function isRecord17(value) {
|
|
17232
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17233
|
+
}
|
|
17234
|
+
function readDoctorAuditSubjects(context) {
|
|
17235
|
+
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
17236
|
+
for (const entry of entries) {
|
|
17237
|
+
if (isRecord17(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
17238
|
+
return { status: "ok" };
|
|
17239
|
+
}
|
|
17240
|
+
}
|
|
17241
|
+
return { status: "incomplete", observation: { kind: "missing-subject", subject: "candidate-testimony" } };
|
|
17242
|
+
}
|
|
17243
|
+
function requireAuditMaterials(resolution) {
|
|
17244
|
+
if (resolution.status === "incomplete") {
|
|
17245
|
+
throw new AuditMaterialsUnavailableError(resolution.observation);
|
|
17246
|
+
}
|
|
17247
|
+
}
|
|
17248
|
+
var AUDIT_RUN_DIR_ENV, DOCTOR_CANDIDATE_ENTRY_TYPE, AuditMaterialsUnavailableError;
|
|
17249
|
+
var init_dossier_resolution = __esm({
|
|
17250
|
+
"src/dossier-resolution.ts"() {
|
|
17251
|
+
"use strict";
|
|
17252
|
+
AUDIT_RUN_DIR_ENV = "AK_ROLE_RUN_DIR";
|
|
17253
|
+
DOCTOR_CANDIDATE_ENTRY_TYPE = "ak_doctor_audit_candidate";
|
|
17254
|
+
AuditMaterialsUnavailableError = class extends Error {
|
|
17255
|
+
observation;
|
|
17256
|
+
candidate;
|
|
17257
|
+
constructor(observation) {
|
|
17258
|
+
const detail = observation.kind === "missing-subject" ? `${observation.kind}:${observation.subject}` : observation.kind;
|
|
17259
|
+
super(`Audit materials unavailable: ${detail}`);
|
|
17260
|
+
this.name = "AuditMaterialsUnavailableError";
|
|
17261
|
+
this.observation = observation;
|
|
17262
|
+
this.candidate = void 0;
|
|
17263
|
+
}
|
|
17264
|
+
};
|
|
17265
|
+
}
|
|
17266
|
+
});
|
|
17267
|
+
|
|
17471
17268
|
// src/doctor-auditor.ts
|
|
17472
17269
|
function createPiDoctorAuditor() {
|
|
17473
17270
|
return async (options) => {
|
|
@@ -17701,7 +17498,7 @@ __export(archivist_record_entry_exports, {
|
|
|
17701
17498
|
createRecordSessionOpen: () => createRecordSessionOpen,
|
|
17702
17499
|
subjectKeyedRecordDirectory: () => subjectKeyedRecordDirectory
|
|
17703
17500
|
});
|
|
17704
|
-
import { existsSync as
|
|
17501
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync4, readFileSync as readFileSync3, realpathSync as realpathSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
17705
17502
|
import { dirname as dirname13, resolve as resolve13, join as join28 } from "node:path";
|
|
17706
17503
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
17707
17504
|
function readCurrentSession(sessionDir) {
|
|
@@ -17784,7 +17581,7 @@ function createRecordSessionOpen(options) {
|
|
|
17784
17581
|
sessionDir = physicallyContainedIn(ledgerHome, parentResolved) ? join28(dirname13(parentResolved), options.kind) : join28(activationBookDirectory(ledgerHome, resolveBookKeyFromGit(cwd)), options.kind);
|
|
17785
17582
|
parentSession = parentFile;
|
|
17786
17583
|
}
|
|
17787
|
-
const nestAlreadyExists =
|
|
17584
|
+
const nestAlreadyExists = existsSync10(sessionDir);
|
|
17788
17585
|
ensureRealDirectoryTree(ledgerHome, sessionDir);
|
|
17789
17586
|
const mayResumeSameNest = options.subject !== void 0 || options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
17790
17587
|
if (mayResumeSameNest && nestAlreadyExists) {
|
|
@@ -17802,7 +17599,7 @@ function createRecordSessionOpen(options) {
|
|
|
17802
17599
|
);
|
|
17803
17600
|
if (session.isPersisted()) {
|
|
17804
17601
|
const file = session.getSessionFile();
|
|
17805
|
-
if (file !== void 0 && !
|
|
17602
|
+
if (file !== void 0 && !existsSync10(file)) {
|
|
17806
17603
|
const header = session.getHeader();
|
|
17807
17604
|
if (header !== null && header.type === "session") {
|
|
17808
17605
|
writeFileSync5(file, `${JSON.stringify(header)}
|
|
@@ -17830,7 +17627,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
17830
17627
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
17831
17628
|
};
|
|
17832
17629
|
writeFileSync5(
|
|
17833
|
-
join28(nest, `${options.officer}
|
|
17630
|
+
join28(nest, `${options.officer}.pointer.json`),
|
|
17834
17631
|
`${JSON.stringify(pointer)}
|
|
17835
17632
|
`,
|
|
17836
17633
|
"utf8"
|
|
@@ -18781,9 +18578,158 @@ var init_engine_detour_tool = __esm({
|
|
|
18781
18578
|
}
|
|
18782
18579
|
});
|
|
18783
18580
|
|
|
18581
|
+
// src/gatekeeper-role.ts
|
|
18582
|
+
function gateSeatLabel(stage) {
|
|
18583
|
+
if (stage === "inspector") return "\u5BDF\u9662";
|
|
18584
|
+
if (stage === "auditor") return "\u5BA1\u5211\u9662";
|
|
18585
|
+
return "\u7B26\u5B9D\u90CE";
|
|
18586
|
+
}
|
|
18587
|
+
function gateOfficerForSubject(subject) {
|
|
18588
|
+
if (subject.kind === "worker_completion") return "inspector";
|
|
18589
|
+
if (subject.kind === "judge_compliance") return "auditor";
|
|
18590
|
+
return "notary";
|
|
18591
|
+
}
|
|
18592
|
+
function failureReason(error) {
|
|
18593
|
+
if (error instanceof AggregateError) return error.errors.map(failureReason).join("; ");
|
|
18594
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
18595
|
+
}
|
|
18596
|
+
function isRecord18(value) {
|
|
18597
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18598
|
+
}
|
|
18599
|
+
function retainedReceipt(decision) {
|
|
18600
|
+
return decision === void 0 || isRecord18(decision) && Object.keys(decision).length === 0 ? MISSING_ARGUMENTS_SUBMISSION : decision;
|
|
18601
|
+
}
|
|
18602
|
+
function readRecord(value) {
|
|
18603
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
18604
|
+
return value;
|
|
18605
|
+
}
|
|
18606
|
+
function projectOfficerDecision(officer, decision, fallbackStatus) {
|
|
18607
|
+
const receipt = retainedReceipt(decision);
|
|
18608
|
+
const record4 = readRecord(decision);
|
|
18609
|
+
const status = (record4 !== void 0 && typeof record4.status === "string" ? record4.status : void 0) ?? fallbackStatus;
|
|
18610
|
+
if (status === "pass") {
|
|
18611
|
+
return { status: "pass", officer, receipt };
|
|
18612
|
+
}
|
|
18613
|
+
if (status === "bounce" || status === "escalate") {
|
|
18614
|
+
return { status, officer, receipt };
|
|
18615
|
+
}
|
|
18616
|
+
return { status: "needs_reask", officer, receipt };
|
|
18617
|
+
}
|
|
18618
|
+
function projectOfficerTerminal(officer, summoned) {
|
|
18619
|
+
const terminal = summoned.terminal;
|
|
18620
|
+
const outcome = terminal?.roleOutcome;
|
|
18621
|
+
if (outcome === void 0) {
|
|
18622
|
+
const detail = summoned.stderr?.trim();
|
|
18623
|
+
return {
|
|
18624
|
+
status: "transport_failure",
|
|
18625
|
+
stage: officer,
|
|
18626
|
+
reason: detail && detail.length > 0 ? `${gateSeatLabel(officer)} public summon exit ${summoned.exitCode}: ${detail}` : `${gateSeatLabel(officer)} public summon produced no terminal (exit ${summoned.exitCode})`,
|
|
18627
|
+
submission: summoned
|
|
18628
|
+
};
|
|
18629
|
+
}
|
|
18630
|
+
if (outcome.kind === "no_receipt") {
|
|
18631
|
+
return {
|
|
18632
|
+
status: "no_receipt",
|
|
18633
|
+
stage: officer,
|
|
18634
|
+
reason: `${gateSeatLabel(officer)}\u672A\u4EA7\u751F\u5DF2\u63A5\u53D7\u56DE\u6267\u5373\u6563\u5C40`,
|
|
18635
|
+
facts: outcome
|
|
18636
|
+
};
|
|
18637
|
+
}
|
|
18638
|
+
if (outcome.kind === "failure") {
|
|
18639
|
+
return {
|
|
18640
|
+
status: "transport_failure",
|
|
18641
|
+
stage: officer,
|
|
18642
|
+
reason: outcome.diagnostic,
|
|
18643
|
+
submission: outcome.decisiveFacts
|
|
18644
|
+
};
|
|
18645
|
+
}
|
|
18646
|
+
if (outcome.kind === "audit_escalation") {
|
|
18647
|
+
return {
|
|
18648
|
+
status: "escalate",
|
|
18649
|
+
officer,
|
|
18650
|
+
receipt: retainedReceipt(outcome.decisiveFacts)
|
|
18651
|
+
};
|
|
18652
|
+
}
|
|
18653
|
+
if (outcome.kind === "accepted") {
|
|
18654
|
+
const facts = outcome.decisiveFacts;
|
|
18655
|
+
if (isRecord18(facts) && Object.keys(facts).length > 0) {
|
|
18656
|
+
return projectOfficerDecision(officer, facts, outcome.status);
|
|
18657
|
+
}
|
|
18658
|
+
return projectOfficerDecision(officer, { status: outcome.status });
|
|
18659
|
+
}
|
|
18660
|
+
return {
|
|
18661
|
+
status: "needs_reask",
|
|
18662
|
+
officer,
|
|
18663
|
+
receipt: retainedReceipt(outcome)
|
|
18664
|
+
};
|
|
18665
|
+
}
|
|
18666
|
+
async function projectGatekeeperRun(options) {
|
|
18667
|
+
const officer = gateOfficerForSubject(options.subject);
|
|
18668
|
+
const runDirectory = options.runDirectory ?? auditorRunDirectory(options.context);
|
|
18669
|
+
if (runDirectory === void 0) {
|
|
18670
|
+
return {
|
|
18671
|
+
officer,
|
|
18672
|
+
result: {
|
|
18673
|
+
status: "transport_failure",
|
|
18674
|
+
stage: officer,
|
|
18675
|
+
reason: `${gateSeatLabel(officer)} requires a parent run directory pointer`
|
|
18676
|
+
}
|
|
18677
|
+
};
|
|
18678
|
+
}
|
|
18679
|
+
const submissionCandidatePath = persistGateSubmissionCandidate(
|
|
18680
|
+
runDirectory,
|
|
18681
|
+
options.context
|
|
18682
|
+
);
|
|
18683
|
+
let summoned;
|
|
18684
|
+
try {
|
|
18685
|
+
const summon = options.summonOfficer ?? (async (nextOfficer, sourceRunDirectory, officerSignal, reask) => {
|
|
18686
|
+
const { summonGateOfficer: summonGateOfficer2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
18687
|
+
return summonGateOfficer2({
|
|
18688
|
+
officer: nextOfficer,
|
|
18689
|
+
sourceRunDirectory,
|
|
18690
|
+
cwd: options.context.cwd ?? process.cwd(),
|
|
18691
|
+
...officerSignal === void 0 ? {} : { signal: officerSignal },
|
|
18692
|
+
...reask === void 0 ? {} : { reask },
|
|
18693
|
+
...submissionCandidatePath === void 0 ? {} : { submissionCandidatePath }
|
|
18694
|
+
});
|
|
18695
|
+
});
|
|
18696
|
+
summoned = await summon(officer, runDirectory, options.signal, options.reask);
|
|
18697
|
+
} catch (error) {
|
|
18698
|
+
return {
|
|
18699
|
+
officer,
|
|
18700
|
+
result: { status: "transport_failure", stage: officer, reason: failureReason(error) }
|
|
18701
|
+
};
|
|
18702
|
+
}
|
|
18703
|
+
return {
|
|
18704
|
+
officer,
|
|
18705
|
+
result: projectOfficerTerminal(officer, summoned),
|
|
18706
|
+
summoned
|
|
18707
|
+
};
|
|
18708
|
+
}
|
|
18709
|
+
var GATEKEEPER_TOOL_SPEC, MISSING_ARGUMENTS_SUBMISSION, OFFICER_CONCLUSION_REASK;
|
|
18710
|
+
var init_gatekeeper_role = __esm({
|
|
18711
|
+
"src/gatekeeper-role.ts"() {
|
|
18712
|
+
"use strict";
|
|
18713
|
+
init_auditor_dossier_tool();
|
|
18714
|
+
init_submission_errors();
|
|
18715
|
+
init_inspector_contracts();
|
|
18716
|
+
init_gatekeeper_output();
|
|
18717
|
+
init_submission_errors();
|
|
18718
|
+
GATEKEEPER_TOOL_SPEC = {
|
|
18719
|
+
name: GATEKEEPER_OUTPUT_TOOL_NAME,
|
|
18720
|
+
label: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
|
|
18721
|
+
description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\uFF0C\u72B6\u6001\u4E3A dispatch \u6216 pass\u3002",
|
|
18722
|
+
promptSnippet: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
|
|
18723
|
+
parameters: gatekeeperOutputSchema
|
|
18724
|
+
};
|
|
18725
|
+
MISSING_ARGUMENTS_SUBMISSION = Object.freeze({ missing: "arguments" });
|
|
18726
|
+
OFFICER_CONCLUSION_REASK = "\u4E0A\u6B21\u4EA4\u5377\u7684\u7ED3\u8BBA\u4E0D\u662F pass\u3001bounce\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u8F93\u51FA\uFF0C\u7ED3\u8BBA\u5B57\u6BB5\u5199\u660E\u5176\u4E00\uFF1B\u6253\u56DE\u6216\u4E0A\u5448\u7684\u8BDD\u5C31\u662F\u7ED9\u5BF9\u65B9\u770B\u7684\u539F\u6587\u3002";
|
|
18727
|
+
}
|
|
18728
|
+
});
|
|
18729
|
+
|
|
18784
18730
|
// src/gatekeeper-pass-envelope.ts
|
|
18785
18731
|
function bookDirectOfficerPointer(context, officer, result, summoned) {
|
|
18786
|
-
if (result.status !== "pass" && result.status !== "bounce" && result.status !== "escalate" && result.status !== "
|
|
18732
|
+
if (result.status !== "pass" && result.status !== "bounce" && result.status !== "escalate" && result.status !== "needs_reask") {
|
|
18787
18733
|
return;
|
|
18788
18734
|
}
|
|
18789
18735
|
const parentFile = context.sessionManager?.getSessionFile?.();
|
|
@@ -18800,39 +18746,43 @@ function bookDirectOfficerPointer(context, officer, result, summoned) {
|
|
|
18800
18746
|
});
|
|
18801
18747
|
}
|
|
18802
18748
|
async function requireGatekeeperPass(options) {
|
|
18803
|
-
|
|
18804
|
-
|
|
18805
|
-
|
|
18806
|
-
|
|
18807
|
-
|
|
18808
|
-
|
|
18809
|
-
|
|
18810
|
-
|
|
18811
|
-
|
|
18812
|
-
|
|
18813
|
-
|
|
18814
|
-
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
|
|
18818
|
-
|
|
18749
|
+
let reask;
|
|
18750
|
+
for (; ; ) {
|
|
18751
|
+
const projected = await projectGatekeeperRun({
|
|
18752
|
+
context: options.context,
|
|
18753
|
+
subject: options.subject,
|
|
18754
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
18755
|
+
...options.summonOfficer === void 0 ? {} : { summonOfficer: options.summonOfficer },
|
|
18756
|
+
...reask === void 0 ? {} : { reask }
|
|
18757
|
+
});
|
|
18758
|
+
const gatekeeper = projected.result;
|
|
18759
|
+
if (projected.summoned !== void 0) {
|
|
18760
|
+
try {
|
|
18761
|
+
bookDirectOfficerPointer(
|
|
18762
|
+
options.context,
|
|
18763
|
+
projected.officer,
|
|
18764
|
+
gatekeeper,
|
|
18765
|
+
projected.summoned
|
|
18766
|
+
);
|
|
18767
|
+
} catch (error) {
|
|
18768
|
+
options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
|
|
18769
|
+
}
|
|
18770
|
+
}
|
|
18771
|
+
if (gatekeeper.status === "pass") return;
|
|
18772
|
+
if (gatekeeper.status === "needs_reask") {
|
|
18773
|
+
reask = OFFICER_CONCLUSION_REASK;
|
|
18774
|
+
continue;
|
|
18775
|
+
}
|
|
18776
|
+
if (gatekeeper.status === "transport_failure") {
|
|
18777
|
+
const error = new Error(`\u4EA4\u5377\u95F8 transport_failure\uFF08${gatekeeper.stage}\uFF09\uFF1A${gatekeeper.reason}`);
|
|
18778
|
+
error.stage = gatekeeper.stage;
|
|
18779
|
+
error.reason = gatekeeper.reason;
|
|
18780
|
+
if (gatekeeper.submission !== void 0) error.submission = gatekeeper.submission;
|
|
18819
18781
|
options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
|
|
18820
18782
|
}
|
|
18783
|
+
options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
|
|
18784
|
+
throw new GatekeeperDecisionError(gatekeeper);
|
|
18821
18785
|
}
|
|
18822
|
-
if (gatekeeper.status === "pass") return;
|
|
18823
|
-
if (gatekeeper.status === "unreadable") return;
|
|
18824
|
-
if (gatekeeper.status === "transport_failure") {
|
|
18825
|
-
const error = new Error(`\u4EA4\u5377\u95F8 transport_failure\uFF08${gatekeeper.stage}\uFF09\uFF1A${gatekeeper.reason}`);
|
|
18826
|
-
error.stage = gatekeeper.stage;
|
|
18827
|
-
error.reason = gatekeeper.reason;
|
|
18828
|
-
if (gatekeeper.submission !== void 0) error.submission = gatekeeper.submission;
|
|
18829
|
-
options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
|
|
18830
|
-
}
|
|
18831
|
-
if (gatekeeper.status === "escalate") {
|
|
18832
|
-
throw new GatekeeperEscalationError(gatekeeper);
|
|
18833
|
-
}
|
|
18834
|
-
options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
|
|
18835
|
-
throw new GatekeeperDecisionError(gatekeeper);
|
|
18836
18786
|
}
|
|
18837
18787
|
var init_gatekeeper_pass_envelope = __esm({
|
|
18838
18788
|
"src/gatekeeper-pass-envelope.ts"() {
|
|
@@ -20202,11 +20152,9 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
|
|
|
20202
20152
|
if (activation === void 0) {
|
|
20203
20153
|
throw new Error("\u7B26\u5B9D\u90CE\u672A\u6FC0\u6D3B");
|
|
20204
20154
|
}
|
|
20205
|
-
const lawful = projectLawfulNotaryOutput(parameters);
|
|
20206
|
-
const details = lawful ?? retainNotarySubmission(parameters);
|
|
20207
20155
|
return {
|
|
20208
20156
|
content: [{ type: "text", text: NOTARY_ACCEPTED_TEXT }],
|
|
20209
|
-
details,
|
|
20157
|
+
details: parameters,
|
|
20210
20158
|
terminate: true
|
|
20211
20159
|
};
|
|
20212
20160
|
}
|
|
@@ -20751,11 +20699,23 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
|
|
|
20751
20699
|
pi.registerTool({
|
|
20752
20700
|
name: JUDGE_OUTPUT_TOOL_NAME,
|
|
20753
20701
|
label: "\u5927\u7406\u5BFA\u8F93\u51FA",
|
|
20754
|
-
description: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD\uFF1B\u53D7\u7406\u524D\u7ECF\u5BA1\u5211\u9662\u5BA1\
|
|
20702
|
+
description: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD\uFF1B\u53D7\u7406\u524D\u7ECF\u7B26\u5B9D\u90CE\u5185\u95F8\u4E0E\u5BA1\u5211\u9662\u5408\u89C4\u5BA1\u6838\u3002",
|
|
20755
20703
|
promptSnippet: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD",
|
|
20756
20704
|
parameters: judgeVerdictSchema,
|
|
20757
20705
|
async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
|
|
20758
20706
|
if (soul === void 0) throw new Error("\u5927\u7406\u5BFA\u804C\u5206\u672A\u88C5\u8F7D");
|
|
20707
|
+
const rawStatus = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) && typeof parameters.judgeStatus === "string" ? parameters.judgeStatus : void 0;
|
|
20708
|
+
if (rawStatus === void 0 || !JUDGE_QUEUE_STATUSES.has(rawStatus)) {
|
|
20709
|
+
throw new ParentQueueReaskError(JUDGE_STATUS_REASK);
|
|
20710
|
+
}
|
|
20711
|
+
if (rawStatus === "escalate") {
|
|
20712
|
+
const verdict2 = validateVerdict(parameters);
|
|
20713
|
+
return {
|
|
20714
|
+
content: [{ type: "text", text: JUDGE_ACCEPTED_TEXT }],
|
|
20715
|
+
details: verdict2,
|
|
20716
|
+
terminate: true
|
|
20717
|
+
};
|
|
20718
|
+
}
|
|
20759
20719
|
const verdict = validateVerdict(parameters);
|
|
20760
20720
|
await pi.requireGatekeeperPass({
|
|
20761
20721
|
context: ctx,
|
|
@@ -20764,47 +20724,18 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
|
|
|
20764
20724
|
hostActions,
|
|
20765
20725
|
toolCallId
|
|
20766
20726
|
});
|
|
20767
|
-
|
|
20768
|
-
|
|
20769
|
-
|
|
20770
|
-
|
|
20771
|
-
|
|
20772
|
-
|
|
20773
|
-
|
|
20774
|
-
|
|
20775
|
-
|
|
20776
|
-
|
|
20777
|
-
|
|
20778
|
-
|
|
20779
|
-
pass: (usage) => ({
|
|
20780
|
-
content: [{ type: "text", text: JUDGE_ACCEPTED_TEXT }],
|
|
20781
|
-
details: acceptedDetails,
|
|
20782
|
-
terminate: true,
|
|
20783
|
-
...usage === void 0 ? {} : { usage }
|
|
20784
|
-
}),
|
|
20785
|
-
noReceipt: (auditNoReceipt, usageProjection) => ({
|
|
20786
|
-
content: [{ type: "text", text: JUDGE_ACCEPTED_AUDIT_NO_RECEIPT_TEXT }],
|
|
20787
|
-
details: { ...acceptedDetails, auditNoReceipt },
|
|
20788
|
-
terminate: true,
|
|
20789
|
-
...usageProjection
|
|
20790
|
-
}),
|
|
20791
|
-
// #757: parent stands with auditor raw reply — no unreadable judgment.
|
|
20792
|
-
received: (auditReceived, usageProjection) => ({
|
|
20793
|
-
content: [{ type: "text", text: JUDGE_ACCEPTED_TEXT }],
|
|
20794
|
-
details: { ...acceptedDetails, audit: auditReceived.reply },
|
|
20795
|
-
terminate: true,
|
|
20796
|
-
...usageProjection
|
|
20797
|
-
}),
|
|
20798
|
-
bounce: (violations) => {
|
|
20799
|
-
throw new Error(
|
|
20800
|
-
`\u5927\u7406\u5BFA\u56DE\u6267\u8FDD soul\uFF1A${joinReadableGateItems(violations)}`
|
|
20801
|
-
);
|
|
20802
|
-
},
|
|
20803
|
-
escalate: (result) => result
|
|
20804
|
-
},
|
|
20805
|
-
// #380: escalate deliveredOutput must carry the same mechanical projection.
|
|
20806
|
-
acceptedDetails
|
|
20807
|
-
);
|
|
20727
|
+
await pi.requireGatekeeperPass({
|
|
20728
|
+
context: ctx,
|
|
20729
|
+
subject: { kind: "judge_compliance" },
|
|
20730
|
+
...signal === void 0 ? {} : { signal },
|
|
20731
|
+
hostActions,
|
|
20732
|
+
toolCallId
|
|
20733
|
+
});
|
|
20734
|
+
return {
|
|
20735
|
+
content: [{ type: "text", text: JUDGE_ACCEPTED_TEXT }],
|
|
20736
|
+
details: verdict,
|
|
20737
|
+
terminate: true
|
|
20738
|
+
};
|
|
20808
20739
|
}
|
|
20809
20740
|
});
|
|
20810
20741
|
pi.on("before_agent_start", (event) => {
|
|
@@ -20821,15 +20752,16 @@ ${soul}
|
|
|
20821
20752
|
}
|
|
20822
20753
|
};
|
|
20823
20754
|
}
|
|
20824
|
-
var judgeVerdictSchema;
|
|
20755
|
+
var JUDGE_QUEUE_STATUSES, JUDGE_STATUS_REASK, judgeVerdictSchema;
|
|
20825
20756
|
var init_judge_role = __esm({
|
|
20826
20757
|
"src/judge-role.ts"() {
|
|
20827
20758
|
"use strict";
|
|
20828
20759
|
init_host_contracts();
|
|
20829
|
-
init_audit_escalation();
|
|
20830
|
-
init_readable_gate_item();
|
|
20831
20760
|
init_terminating_infrastructure();
|
|
20761
|
+
init_submission_errors();
|
|
20832
20762
|
init_judge_output();
|
|
20763
|
+
JUDGE_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
|
|
20764
|
+
JUDGE_STATUS_REASK = "judgeStatus \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
|
20833
20765
|
judgeVerdictSchema = withInfrastructureFailureDeclaration(
|
|
20834
20766
|
Type24.Object(
|
|
20835
20767
|
{
|
|
@@ -21238,7 +21170,7 @@ var init_reviewer_role = __esm({
|
|
|
21238
21170
|
|
|
21239
21171
|
// src/worker-submission-gates.ts
|
|
21240
21172
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
21241
|
-
import { existsSync as
|
|
21173
|
+
import { existsSync as existsSync11, lstatSync as lstatSync3, readdirSync as readdirSync2, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
21242
21174
|
import { resolve as resolve18 } from "node:path";
|
|
21243
21175
|
function git2(cwd, args) {
|
|
21244
21176
|
return execFileSync4("git", args, {
|
|
@@ -21259,7 +21191,7 @@ function statusOf(error) {
|
|
|
21259
21191
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
21260
21192
|
}
|
|
21261
21193
|
function tryGetAll(file, key) {
|
|
21262
|
-
if (!
|
|
21194
|
+
if (!existsSync11(file)) return [];
|
|
21263
21195
|
try {
|
|
21264
21196
|
const out = gitFile(file, ["--get-all", key]);
|
|
21265
21197
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -21269,7 +21201,7 @@ function tryGetAll(file, key) {
|
|
|
21269
21201
|
}
|
|
21270
21202
|
}
|
|
21271
21203
|
function ownedHook(path) {
|
|
21272
|
-
if (!
|
|
21204
|
+
if (!existsSync11(path)) return false;
|
|
21273
21205
|
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
21274
21206
|
}
|
|
21275
21207
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -21296,11 +21228,11 @@ function rmOwnedDir(dir) {
|
|
|
21296
21228
|
const hookPath = resolve18(dir, HOOK_FILE);
|
|
21297
21229
|
if (!ownedHook(hookPath)) return;
|
|
21298
21230
|
rmSync(hookPath, { force: true });
|
|
21299
|
-
if (
|
|
21231
|
+
if (existsSync11(dir) && readdirSync2(dir).length === 0) rmdirSync(dir);
|
|
21300
21232
|
}
|
|
21301
21233
|
function linkedGitDirs(commonDir) {
|
|
21302
21234
|
const root = resolve18(commonDir, "worktrees");
|
|
21303
|
-
if (!
|
|
21235
|
+
if (!existsSync11(root)) return [];
|
|
21304
21236
|
return readdirSync2(root).map((name) => resolve18(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
21305
21237
|
}
|
|
21306
21238
|
function uninstallPackageWorkerHooks(cwd) {
|
|
@@ -21325,7 +21257,7 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
21325
21257
|
rmOwnedDir(resolve18(gitDir, HOOKS_DIR));
|
|
21326
21258
|
}
|
|
21327
21259
|
}
|
|
21328
|
-
function
|
|
21260
|
+
function isRecord19(value) {
|
|
21329
21261
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21330
21262
|
}
|
|
21331
21263
|
function unfinishedReasonPresent(details) {
|
|
@@ -21341,7 +21273,7 @@ function readGateState(session) {
|
|
|
21341
21273
|
if (entry.type !== "custom") continue;
|
|
21342
21274
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
21343
21275
|
const data = entry.data;
|
|
21344
|
-
if (
|
|
21276
|
+
if (isRecord19(data) && (data.head === null || typeof data.head === "string")) {
|
|
21345
21277
|
baseline = data.head;
|
|
21346
21278
|
}
|
|
21347
21279
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -22453,7 +22385,15 @@ function loadFrozenDiaristCatalog(getFlag) {
|
|
|
22453
22385
|
return loadDiaristSourceCatalog(raw);
|
|
22454
22386
|
}
|
|
22455
22387
|
function createCountersignRoleRuntime(roleHost, dependencies, hostActions) {
|
|
22456
|
-
const beforeAccept = hostActions !== void 0 && roleHost.requireGatekeeperPass !== void 0 ? async ({ toolCallId, signal, ctx }) => {
|
|
22388
|
+
const beforeAccept = hostActions !== void 0 && roleHost.requireGatekeeperPass !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
|
|
22389
|
+
const record4 = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters : void 0;
|
|
22390
|
+
const status = record4 !== void 0 && typeof record4.countersignStatus === "string" ? record4.countersignStatus : void 0;
|
|
22391
|
+
if (status === void 0 || !COUNTERSIGN_QUEUE_STATUSES.has(status)) {
|
|
22392
|
+
throw new ParentQueueReaskError(COUNTERSIGN_STATUS_REASK);
|
|
22393
|
+
}
|
|
22394
|
+
if (status === "escalate") {
|
|
22395
|
+
return void 0;
|
|
22396
|
+
}
|
|
22457
22397
|
await roleHost.requireGatekeeperPass({
|
|
22458
22398
|
context: ctx,
|
|
22459
22399
|
subject: { kind: "countersign_verdict" },
|
|
@@ -22763,8 +22703,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
22763
22703
|
const judge = createJudgeRoleRuntime(
|
|
22764
22704
|
roleHost,
|
|
22765
22705
|
{
|
|
22766
|
-
loadSoul: dependencies.loadJudgeSoul
|
|
22767
|
-
auditSoulCompliance: dependencies.auditSoulCompliance
|
|
22706
|
+
loadSoul: dependencies.loadJudgeSoul
|
|
22768
22707
|
},
|
|
22769
22708
|
hostActions
|
|
22770
22709
|
);
|
|
@@ -23193,7 +23132,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
23193
23132
|
});
|
|
23194
23133
|
};
|
|
23195
23134
|
}
|
|
23196
|
-
var REVIEWER_TRANSPORT_FLAGS, NOTARY_TRANSPORT_FLAGS, GLEANER_LEFT_TRANSPORT_FLAGS, DIARIST_TRANSPORT_FLAGS, ActivationBarrierError, WORKFLOW_ROLES, ROLE_FLAG;
|
|
23135
|
+
var REVIEWER_TRANSPORT_FLAGS, NOTARY_TRANSPORT_FLAGS, GLEANER_LEFT_TRANSPORT_FLAGS, DIARIST_TRANSPORT_FLAGS, ActivationBarrierError, WORKFLOW_ROLES, ROLE_FLAG, COUNTERSIGN_QUEUE_STATUSES, COUNTERSIGN_STATUS_REASK;
|
|
23197
23136
|
var init_role_runtime = __esm({
|
|
23198
23137
|
"src/role-runtime.ts"() {
|
|
23199
23138
|
"use strict";
|
|
@@ -23251,6 +23190,8 @@ var init_role_runtime = __esm({
|
|
|
23251
23190
|
init_activation_reconciliation();
|
|
23252
23191
|
init_tool_execution_observation();
|
|
23253
23192
|
init_gatekeeper_role();
|
|
23193
|
+
init_gatekeeper_role();
|
|
23194
|
+
init_submission_errors();
|
|
23254
23195
|
init_doctor_role();
|
|
23255
23196
|
init_doctor_contracts();
|
|
23256
23197
|
init_doctor_evidence();
|
|
@@ -23332,6 +23273,8 @@ var init_role_runtime = __esm({
|
|
|
23332
23273
|
type: "string"
|
|
23333
23274
|
}
|
|
23334
23275
|
};
|
|
23276
|
+
COUNTERSIGN_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
|
|
23277
|
+
COUNTERSIGN_STATUS_REASK = "countersignStatus \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
|
23335
23278
|
}
|
|
23336
23279
|
});
|
|
23337
23280
|
|
|
@@ -24790,7 +24733,6 @@ async function loadCanonicalSkillBinding(name) {
|
|
|
24790
24733
|
init_collector_github();
|
|
24791
24734
|
init_doctor_auditor();
|
|
24792
24735
|
init_doctor_evidence();
|
|
24793
|
-
init_judge_auditor();
|
|
24794
24736
|
init_merger_git_state();
|
|
24795
24737
|
init_navigator_attendance();
|
|
24796
24738
|
|
|
@@ -25457,7 +25399,7 @@ async function prepareAcpRoleEnvelope(options) {
|
|
|
25457
25399
|
const record4 = details;
|
|
25458
25400
|
if (record4.cause === "infrastructure") return;
|
|
25459
25401
|
if (record4.kind === "role_infrastructure_failure") return;
|
|
25460
|
-
const code = typeof record4.code === "string" && record4.code.length > 0 ? record4.code : record4.status === "bounce" || record4.status === "
|
|
25402
|
+
const code = typeof record4.code === "string" && record4.code.length > 0 ? record4.code : record4.status === "bounce" || record4.status === "escalate" || record4.status === "no_receipt" ? record4.status : void 0;
|
|
25461
25403
|
if (code === void 0) return;
|
|
25462
25404
|
rejection = { code, toolCallIds: [toolCallId] };
|
|
25463
25405
|
}
|
|
@@ -25821,7 +25763,6 @@ var navigatorRoutePlaybookPath = fileURLToPath3(
|
|
|
25821
25763
|
new URL("../../resources/navigator-route-playbook.md", import.meta.url)
|
|
25822
25764
|
);
|
|
25823
25765
|
function createAcpRoleRuntimeDependencies(packageRoot) {
|
|
25824
|
-
const judgeAuditor = createPiJudgeAuditor();
|
|
25825
25766
|
const doctorAuditor = createPiDoctorAuditor();
|
|
25826
25767
|
const reviewerAgent = createPerDispatchReviewerAgent({ packageRoot });
|
|
25827
25768
|
const navigatorSessionFactory = createNativeNavigatorSessionFactory();
|
|
@@ -25859,8 +25800,7 @@ function createAcpRoleRuntimeDependencies(packageRoot) {
|
|
|
25859
25800
|
}
|
|
25860
25801
|
return loadCanonicalSkillBinding(name);
|
|
25861
25802
|
},
|
|
25862
|
-
// #590:
|
|
25863
|
-
auditSoulCompliance: (options) => judgeAuditor(options),
|
|
25803
|
+
// #590: doctor compliance still on disposeCompliance path; judge→auditor is gate queue (#756).
|
|
25864
25804
|
auditDoctorCompliance: (options) => doctorAuditor(options),
|
|
25865
25805
|
runReviewerDispatch: (dispatch, options) => reviewerAgent.run(dispatch, options),
|
|
25866
25806
|
shutdownReviewerAgent: () => reviewerAgent.shutdown(),
|