@akagilnc/pi-workflow-roles 0.1.4956 → 0.1.4977
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-CN.md +4 -4
- package/dist/acp-host/production-host.js +140 -265
- package/dist/audit-escalation.js +4 -3
- package/dist/compliance-transport.js +6 -11
- package/dist/doctor-contracts.js +0 -2
- package/dist/gatekeeper-role.js +3 -1
- package/dist/headless-host/production-host.js +140 -265
- package/dist/migrate-book-topology.js +1 -16
- package/dist/packaged-role-registry.js +0 -24
- package/dist/public-cli/main.js +12 -28
- package/dist/public-cli/settlement.js +5 -1
- package/dist/public-cli/terminal.js +2 -2
- package/dist/secretariat-contracts.js +1 -3
- package/dist/submission-ledger.js +9 -0
- package/package.json +1 -1
- package/src/audit-escalation.ts +5 -4
- package/src/collector-role.ts +1 -5
- package/src/compliance-transport.ts +10 -12
- package/src/doctor-auditor.ts +2 -0
- package/src/doctor-contracts.ts +0 -1
- package/src/doctor-role.ts +4 -4
- package/src/gatekeeper-pass-envelope.ts +7 -10
- package/src/gatekeeper-role.ts +3 -1
- package/src/judge-role.ts +45 -31
- package/src/merger-role.ts +1 -2
- package/src/notary-role.ts +1 -2
- package/src/packaged-role-registry.ts +0 -25
- package/src/public-cli/settlement.ts +6 -1
- package/src/public-cli/terminal.ts +2 -2
- package/src/reviewer-role.ts +1 -2
- package/src/role-runtime.ts +59 -156
- package/src/secretariat-contracts.ts +0 -2
- package/src/secretariat-role.ts +3 -162
- package/src/submission-ledger.ts +13 -0
- package/src/worker-role.ts +42 -24
|
@@ -2856,7 +2856,7 @@ function validateDoctorSubmissionShape(value) {
|
|
|
2856
2856
|
function validateDoctorOutput(value, _patient, _store) {
|
|
2857
2857
|
return validateDoctorSubmissionShape(value);
|
|
2858
2858
|
}
|
|
2859
|
-
var DOCTOR_EVIDENCE_TOOL_NAME, DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_AUDIT_TOOL_NAME,
|
|
2859
|
+
var DOCTOR_EVIDENCE_TOOL_NAME, DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_AUDIT_TOOL_NAME, DOCTOR_OUTPUT_TOOL_DESCRIPTION, DOCTOR_TARGET_KINDS, nonblank, evidenceIds, guardrail, lastRealBite, assetKinds, findingBody, finding, caseIdentity, DOCTOR_STATUS_DESCRIPTION, doctorSubmissionVariants, doctorSubmissionSchema, doctorEvidenceReadSchema, DoctorEvidenceStore;
|
|
2860
2860
|
var init_doctor_contracts = __esm({
|
|
2861
2861
|
"src/doctor-contracts.ts"() {
|
|
2862
2862
|
"use strict";
|
|
@@ -2866,7 +2866,6 @@ var init_doctor_contracts = __esm({
|
|
|
2866
2866
|
DOCTOR_EVIDENCE_TOOL_NAME = "ak_doctor_evidence";
|
|
2867
2867
|
DOCTOR_OUTPUT_TOOL_NAME = "ak_doctor_output";
|
|
2868
2868
|
DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
|
|
2869
|
-
DOCTOR_ACCEPTED_AUDIT_NO_RECEIPT_TEXT = "\u592A\u533B\u7F72\u56DE\u6267\u5DF2\u63A5\u53D7\uFF1B\u5BA1\u8BA1\u65E0\u56DE\u6267";
|
|
2870
2869
|
DOCTOR_OUTPUT_TOOL_DESCRIPTION = "\u63D0\u4EA4\u552F\u4E00\u7EC8\u5C40\u5355\u6848\u8BC1\u8BCD\uFF1Bcompleted \u5141\u8BB8\u7A7A findings\u3002";
|
|
2871
2870
|
DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
|
|
2872
2871
|
nonblank = Type8.Optional(Type8.String());
|
|
@@ -3337,15 +3336,13 @@ var secretariat_contracts_exports = {};
|
|
|
3337
3336
|
__export(secretariat_contracts_exports, {
|
|
3338
3337
|
SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY: () => SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY,
|
|
3339
3338
|
SECRETARIAT_GATE_OFFICER_ENTRY_TYPE: () => SECRETARIAT_GATE_OFFICER_ENTRY_TYPE,
|
|
3340
|
-
SECRETARIAT_OUTPUT_TOOL_NAME: () => SECRETARIAT_OUTPUT_TOOL_NAME
|
|
3341
|
-
SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME: () => SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME
|
|
3339
|
+
SECRETARIAT_OUTPUT_TOOL_NAME: () => SECRETARIAT_OUTPUT_TOOL_NAME
|
|
3342
3340
|
});
|
|
3343
|
-
var SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
3341
|
+
var SECRETARIAT_OUTPUT_TOOL_NAME, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY;
|
|
3344
3342
|
var init_secretariat_contracts = __esm({
|
|
3345
3343
|
"src/secretariat-contracts.ts"() {
|
|
3346
3344
|
"use strict";
|
|
3347
3345
|
SECRETARIAT_OUTPUT_TOOL_NAME = "ak_secretariat_output";
|
|
3348
|
-
SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME = "ak_secretariat_summon_countersign";
|
|
3349
3346
|
SECRETARIAT_GATE_OFFICER_ENTRY_TYPE = "ak-secretariat-gate-officer";
|
|
3350
3347
|
SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY = "countersignTerminal";
|
|
3351
3348
|
}
|
|
@@ -3393,7 +3390,6 @@ __export(packaged_role_registry_exports, {
|
|
|
3393
3390
|
packagedRebindSourceOnResume: () => packagedRebindSourceOnResume,
|
|
3394
3391
|
packagedResumeSourcePath: () => packagedResumeSourcePath,
|
|
3395
3392
|
packagedRoleAcceptedOutputTool: () => packagedRoleAcceptedOutputTool,
|
|
3396
|
-
packagedRoleAcceptedText: () => packagedRoleAcceptedText,
|
|
3397
3393
|
packagedRoleActivationFlags: () => packagedRoleActivationFlags,
|
|
3398
3394
|
packagedRoleInputFlag: () => packagedRoleInputFlag,
|
|
3399
3395
|
packagedRoleMetadata: () => packagedRoleMetadata,
|
|
@@ -3441,13 +3437,6 @@ function packagedRolePhaseFlag(role) {
|
|
|
3441
3437
|
function packagedRoleOutputTool(role) {
|
|
3442
3438
|
return packagedRoleMetadata(role)?.outputTool;
|
|
3443
3439
|
}
|
|
3444
|
-
function packagedRoleAcceptedText(role) {
|
|
3445
|
-
const record4 = packagedRoleMetadata(role);
|
|
3446
|
-
if (record4 === void 0) {
|
|
3447
|
-
throw new Error(`Unsupported workflow role: ${String(role)}`);
|
|
3448
|
-
}
|
|
3449
|
-
return record4.acceptedText;
|
|
3450
|
-
}
|
|
3451
3440
|
function packagedMethodLoadFailureCause(role) {
|
|
3452
3441
|
const record4 = packagedRoleMetadata(role);
|
|
3453
3442
|
if (record4 === void 0 || !("methodLoadFailureCause" in record4)) return void 0;
|
|
@@ -3620,7 +3609,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3620
3609
|
auditTool: JUDGE_AUDIT_TOOL_NAME,
|
|
3621
3610
|
settlement: "sealed",
|
|
3622
3611
|
runnerFailure: "engine-detour-known-first",
|
|
3623
|
-
acceptedText: "\u5927\u7406\u5BFA\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3624
3612
|
/** Factory board: court until another station has started, then marshal. */
|
|
3625
3613
|
boardPlacement: "judge-history",
|
|
3626
3614
|
/** Navigator subject is the public admitted instruction when the run is bound. */
|
|
@@ -3659,7 +3647,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3659
3647
|
],
|
|
3660
3648
|
method: "observed"
|
|
3661
3649
|
},
|
|
3662
|
-
acceptedText: "\u4FEE\u5185\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3663
3650
|
boardPlacement: "marshal",
|
|
3664
3651
|
activationFlags: [
|
|
3665
3652
|
{ field: "packetPath", flag: "ak-fix-packet", binds: "input" },
|
|
@@ -3698,7 +3685,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3698
3685
|
],
|
|
3699
3686
|
method: "optional"
|
|
3700
3687
|
},
|
|
3701
|
-
acceptedText: "\u5C06\u4F5C\u76D1\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3702
3688
|
activationFlags: [
|
|
3703
3689
|
{ field: "taskPath", flag: "ak-coder-task", binds: "input" },
|
|
3704
3690
|
{ field: "phase", flag: "ak-coder-phase", binds: "phase" }
|
|
@@ -3744,7 +3730,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3744
3730
|
/** Frozen base/lens/authority become the initial prompt; instruction follows. */
|
|
3745
3731
|
transportPrompt: "skill-args",
|
|
3746
3732
|
runnerFailure: "engine-detour-record-first",
|
|
3747
|
-
acceptedText: "\u5FA1\u53F2\u53F0\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3748
3733
|
boardPlacement: "marshal",
|
|
3749
3734
|
activationFlags: [
|
|
3750
3735
|
{ field: "baseRevision", flag: "ak-review-base" },
|
|
@@ -3786,7 +3771,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3786
3771
|
{ key: "manifestDigest" }
|
|
3787
3772
|
]
|
|
3788
3773
|
},
|
|
3789
|
-
acceptedText: "\u901A\u8FDB\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3790
3774
|
boardPlacement: "collector",
|
|
3791
3775
|
/** Taishi acceptance is a typed groups array, not a status leaf. */
|
|
3792
3776
|
analystTerminal: "groups",
|
|
@@ -3820,7 +3804,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3820
3804
|
],
|
|
3821
3805
|
doctorReportFacts: true
|
|
3822
3806
|
},
|
|
3823
|
-
acceptedText: "\u592A\u533B\u7F72\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3824
3807
|
/** Navigator subject is the doctor case, not the case-path file bytes. */
|
|
3825
3808
|
navigatorSubject: "case",
|
|
3826
3809
|
activationFlags: [
|
|
@@ -3856,7 +3839,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3856
3839
|
],
|
|
3857
3840
|
method: "observed"
|
|
3858
3841
|
},
|
|
3859
|
-
acceptedText: "\u5408\u5E76\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3860
3842
|
activationFlags: [
|
|
3861
3843
|
{ field: "inputPath", from: "mergerInputPath", flag: "ak-merger-input", binds: "input" }
|
|
3862
3844
|
],
|
|
@@ -3889,7 +3871,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3889
3871
|
/** Court reask replaces the initial prompt. Otherwise the fixed kickoff. */
|
|
3890
3872
|
reaskPrompt: true,
|
|
3891
3873
|
transportPrompt: "fixed-kickoff",
|
|
3892
|
-
acceptedText: "\u7B26\u5B9D\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3893
3874
|
gateStageLabel: "\u7B26\u5B9D\u90CE",
|
|
3894
3875
|
/** Gate summon binds --source-run and keeps dialogue off the argv. */
|
|
3895
3876
|
gateSummon: "source-run",
|
|
@@ -3914,7 +3895,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3914
3895
|
phases: [null],
|
|
3915
3896
|
outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
|
|
3916
3897
|
settlement: "accepted",
|
|
3917
|
-
acceptedText: "\u7ED9\u4E8B\u4E2D\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3918
3898
|
gateStageLabel: "\u7ED9\u4E8B\u4E2D",
|
|
3919
3899
|
/** Gate queue reads countersignStatus, not the shared three-state status. */
|
|
3920
3900
|
gateDecision: "countersign-status",
|
|
@@ -3940,7 +3920,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3940
3920
|
settlement: "accepted",
|
|
3941
3921
|
/** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
|
|
3942
3922
|
projectCountersignTerminal: true,
|
|
3943
|
-
acceptedText: "\u4E2D\u4E66\u7701\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3944
3923
|
activationFlags: [
|
|
3945
3924
|
{ field: "ticketNumber" }
|
|
3946
3925
|
],
|
|
@@ -3970,7 +3949,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3970
3949
|
settlement: "accepted",
|
|
3971
3950
|
/** Bound comparison base is the initial prompt; instruction follows. */
|
|
3972
3951
|
transportPrompt: "baseline",
|
|
3973
|
-
acceptedText: "\u5DE6\u62FE\u9057\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
3974
3952
|
activationFlags: [
|
|
3975
3953
|
{ field: "baseRevision", flag: "ak-gleaner-left-base" }
|
|
3976
3954
|
],
|
|
@@ -4001,7 +3979,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4001
3979
|
settlement: "accepted",
|
|
4002
3980
|
/** Court reask replaces the initial prompt. */
|
|
4003
3981
|
reaskPrompt: true,
|
|
4004
|
-
acceptedText: "\u53F0\u9662\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4005
3982
|
gateStageLabel: "\u53F0\u9662",
|
|
4006
3983
|
activationFlags: [
|
|
4007
3984
|
{
|
|
@@ -4033,7 +4010,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4033
4010
|
outputTool: GATEKEEPER_OUTPUT_TOOL_NAME,
|
|
4034
4011
|
settlement: "accepted",
|
|
4035
4012
|
runnerFailure: "engine-detour-record-first",
|
|
4036
|
-
acceptedText: "\u95E8\u4E0B\u7701\u51B3\u8BAE\u5DF2\u53D7\u7406",
|
|
4037
4013
|
activationStage: "load-and-install",
|
|
4038
4014
|
// Province materials; officers reuse their own public records below.
|
|
4039
4015
|
sessionMaterials: ["CLAUDE.md", "souls/gatekeeper.md", "souls/quality-law.md", "souls/gate-output-guide.md"]
|
|
@@ -4049,7 +4025,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4049
4025
|
outputTool: NAVIGATOR_OUTPUT_TOOL_NAME,
|
|
4050
4026
|
settlement: "accepted",
|
|
4051
4027
|
runnerFailure: "engine-detour-record-first",
|
|
4052
|
-
acceptedText: "\u6E38\u5955\u4F7F\u5EFA\u8BAE\u5DF2\u53D7\u7406",
|
|
4053
4028
|
activationStage: "load-and-install",
|
|
4054
4029
|
sessionMaterials: ["CLAUDE.md", "souls/navigator.md"]
|
|
4055
4030
|
},
|
|
@@ -4073,7 +4048,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4073
4048
|
/** Court reask replaces the initial prompt. */
|
|
4074
4049
|
reaskPrompt: true,
|
|
4075
4050
|
runnerFailure: "engine-detour-record-first",
|
|
4076
|
-
acceptedText: "\u5BA1\u5211\u9662\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4077
4051
|
gateStageLabel: "\u5BA1\u5211\u9662",
|
|
4078
4052
|
/** Gate summon binds --subject judge and --source-run. */
|
|
4079
4053
|
gateSummon: "subject-source",
|
|
@@ -4092,7 +4066,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4092
4066
|
phases: [null],
|
|
4093
4067
|
outputTool: DIARIST_OUTPUT_TOOL_NAME,
|
|
4094
4068
|
settlement: "accepted",
|
|
4095
|
-
acceptedText: "\u8D77\u5C45\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4096
4069
|
activationStage: "load-and-install",
|
|
4097
4070
|
sessionMaterials: [
|
|
4098
4071
|
"CLAUDE.md",
|
|
@@ -4399,7 +4372,7 @@ function projectOfficerTerminal(officer, summoned) {
|
|
|
4399
4372
|
status: "escalate",
|
|
4400
4373
|
officer,
|
|
4401
4374
|
// This-court receipt only (#879) — historical rows remain on terminal.submissions.
|
|
4402
|
-
receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
|
|
4375
|
+
receipt: outcome.decisiveFacts !== void 0 && Object.hasOwn(outcome.decisiveFacts, "auditEscalationReceipt") ? outcome.decisiveFacts.auditEscalationReceipt : thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
|
|
4403
4376
|
},
|
|
4404
4377
|
summoned
|
|
4405
4378
|
);
|
|
@@ -4521,8 +4494,8 @@ function formatTerminalResult(result) {
|
|
|
4521
4494
|
`diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
|
|
4522
4495
|
);
|
|
4523
4496
|
}
|
|
4524
|
-
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
|
|
4525
|
-
const facts = result.roleOutcome.decisiveFacts;
|
|
4497
|
+
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt" || result.roleOutcome.kind === "audit_escalation") {
|
|
4498
|
+
const facts = result.roleOutcome.decisiveFacts ?? {};
|
|
4526
4499
|
for (const [key, value] of Object.entries(facts)) {
|
|
4527
4500
|
if (value === void 0) continue;
|
|
4528
4501
|
const rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
@@ -12988,6 +12961,9 @@ function buildAuditEscalationResult(decision, deliveredOutput) {
|
|
|
12988
12961
|
const auditOwned = {
|
|
12989
12962
|
kind: AUDIT_ESCALATION_KIND
|
|
12990
12963
|
};
|
|
12964
|
+
if (Object.hasOwn(decision, "receipt")) {
|
|
12965
|
+
auditOwned.receipt = decision.receipt;
|
|
12966
|
+
}
|
|
12991
12967
|
if (Object.hasOwn(decision, "conflicts")) {
|
|
12992
12968
|
auditOwned.conflicts = decision.conflicts;
|
|
12993
12969
|
}
|
|
@@ -13017,9 +12993,8 @@ function isAuditEscalationProjection(value) {
|
|
|
13017
12993
|
}
|
|
13018
12994
|
function projectAuditEscalation(decision, deliveredOutput) {
|
|
13019
12995
|
const details = buildAuditEscalationResult(decision, deliveredOutput);
|
|
13020
|
-
const original = deliveredOutput !== void 0 ? deliveredOutput : decision;
|
|
13021
12996
|
return {
|
|
13022
|
-
content: [
|
|
12997
|
+
content: [],
|
|
13023
12998
|
details,
|
|
13024
12999
|
terminate: true,
|
|
13025
13000
|
...decision.usage === void 0 ? {} : { usage: decision.usage }
|
|
@@ -13073,7 +13048,6 @@ var AUDIT_ESCALATION_KIND, AUDIT_ESCALATION_LIVE_REGISTRY;
|
|
|
13073
13048
|
var init_audit_escalation = __esm({
|
|
13074
13049
|
"src/audit-escalation.ts"() {
|
|
13075
13050
|
"use strict";
|
|
13076
|
-
init_readable_gate_item();
|
|
13077
13051
|
init_submission_errors();
|
|
13078
13052
|
AUDIT_ESCALATION_KIND = "audit_escalation";
|
|
13079
13053
|
AUDIT_ESCALATION_LIVE_REGISTRY = /* @__PURE__ */ new WeakSet();
|
|
@@ -13188,6 +13162,7 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
|
13188
13162
|
...role === void 0 ? {} : { role },
|
|
13189
13163
|
kind,
|
|
13190
13164
|
accepted,
|
|
13165
|
+
...Object.hasOwn(payload, "auditReceipt") ? { auditReceipt: payload.auditReceipt } : {},
|
|
13191
13166
|
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
13192
13167
|
};
|
|
13193
13168
|
}
|
|
@@ -13452,6 +13427,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
13452
13427
|
}
|
|
13453
13428
|
}
|
|
13454
13429
|
if (isAuditEscalationProjection(result.details) || isAuditEscalationProjection(params)) {
|
|
13430
|
+
const audit = isAuditEscalationProjection(result.details) && typeof result.details.audit === "object" && result.details.audit !== null ? result.details.audit : void 0;
|
|
13455
13431
|
const closed2 = {
|
|
13456
13432
|
role,
|
|
13457
13433
|
kind: "audit_escalation",
|
|
@@ -13463,7 +13439,8 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
13463
13439
|
toolCallId,
|
|
13464
13440
|
outcome: "audit-escalation",
|
|
13465
13441
|
role,
|
|
13466
|
-
accepted: params
|
|
13442
|
+
accepted: params,
|
|
13443
|
+
...audit !== void 0 && (Object.hasOwn(audit, "receipt") || Object.hasOwn(audit, "conflicts")) ? { auditReceipt: Object.hasOwn(audit, "receipt") ? audit.receipt : audit.conflicts } : {}
|
|
13467
13444
|
});
|
|
13468
13445
|
await projectClosure(closed2, context);
|
|
13469
13446
|
return result;
|
|
@@ -14579,7 +14556,14 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
14579
14556
|
if (terminal.length === 0) return void 0;
|
|
14580
14557
|
const payloads = mine.map((row) => row.accepted);
|
|
14581
14558
|
if (terminal.some((row) => row.kind === "audit-escalation")) {
|
|
14582
|
-
|
|
14559
|
+
const audited = terminal.slice().reverse().find((row) => row.kind === "audit-escalation" && Object.hasOwn(row, "auditReceipt"));
|
|
14560
|
+
return {
|
|
14561
|
+
kind: "audit_escalation",
|
|
14562
|
+
role,
|
|
14563
|
+
status: "audit_escalation",
|
|
14564
|
+
payloads,
|
|
14565
|
+
...audited === void 0 ? {} : { decisiveFacts: { auditEscalationReceipt: audited.auditReceipt } }
|
|
14566
|
+
};
|
|
14583
14567
|
}
|
|
14584
14568
|
return { kind: "accepted", role, payloads };
|
|
14585
14569
|
}
|
|
@@ -22715,15 +22699,7 @@ async function projectAuditorTerminal(summoned) {
|
|
|
22715
22699
|
if (rows.length === 0) {
|
|
22716
22700
|
return readComplianceCandidate({}, usage);
|
|
22717
22701
|
}
|
|
22718
|
-
|
|
22719
|
-
if (rows.length === 1) return decision;
|
|
22720
|
-
if (decision.status === "pass" || decision.status === "bounce" || decision.status === "escalate") {
|
|
22721
|
-
return { ...decision, receipt: rows };
|
|
22722
|
-
}
|
|
22723
|
-
if (decision.status === "received") {
|
|
22724
|
-
return { ...decision, reply: rows };
|
|
22725
|
-
}
|
|
22726
|
-
return decision;
|
|
22702
|
+
return readComplianceCandidate(rows[rows.length - 1], usage);
|
|
22727
22703
|
}
|
|
22728
22704
|
return {
|
|
22729
22705
|
status: "received",
|
|
@@ -22737,6 +22713,7 @@ async function runComplianceAudit(options) {
|
|
|
22737
22713
|
throw new Error("Compliance audit requires a parent run directory pointer");
|
|
22738
22714
|
}
|
|
22739
22715
|
const subject = options.subject;
|
|
22716
|
+
const submission = options.submission === void 0 ? void 0 : readableGateItem(options.submission);
|
|
22740
22717
|
const summon = options.summonAuditor ?? (async (auditSubject, sourceRunDirectory, auditSignal, reask2) => {
|
|
22741
22718
|
const { summonPublicRole: summonPublicRole2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
22742
22719
|
const { homeFromRunDirectory: homeFromRunDirectory2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
|
|
@@ -22753,12 +22730,13 @@ async function runComplianceAudit(options) {
|
|
|
22753
22730
|
cwd: options.context.cwd ?? process.cwd(),
|
|
22754
22731
|
home,
|
|
22755
22732
|
...auditSignal === void 0 ? {} : { signal: auditSignal },
|
|
22756
|
-
...reask2 === void 0 ? {} : { reviewReask: reask2 }
|
|
22733
|
+
...reask2 === void 0 ? {} : { reviewReask: reask2 },
|
|
22734
|
+
...submission === void 0 ? {} : { gateReviewInstruction: submission }
|
|
22757
22735
|
});
|
|
22758
22736
|
});
|
|
22759
22737
|
let reask;
|
|
22760
22738
|
for (; ; ) {
|
|
22761
|
-
const summoned = await summon(subject, runDirectory, options.signal, reask);
|
|
22739
|
+
const summoned = await summon(subject, runDirectory, options.signal, reask, submission);
|
|
22762
22740
|
const decision = await projectAuditorTerminal(summoned);
|
|
22763
22741
|
if (decision.status === "received") {
|
|
22764
22742
|
reask = OFFICER_CONCLUSION_REASK;
|
|
@@ -22774,6 +22752,7 @@ var init_compliance_transport = __esm({
|
|
|
22774
22752
|
init_auditor_dossier_tool();
|
|
22775
22753
|
init_gatekeeper_role();
|
|
22776
22754
|
init_terminal();
|
|
22755
|
+
init_readable_gate_item();
|
|
22777
22756
|
AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
|
|
22778
22757
|
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
22779
22758
|
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
@@ -23209,6 +23188,7 @@ function createPiDoctorAuditor() {
|
|
|
23209
23188
|
return runComplianceAudit({
|
|
23210
23189
|
subject: "doctor",
|
|
23211
23190
|
context: options.context,
|
|
23191
|
+
submission: options.submission,
|
|
23212
23192
|
...auditorRunDirectory(options.context) === void 0 ? {} : { runDirectory: auditorRunDirectory(options.context) },
|
|
23213
23193
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
23214
23194
|
...options.summonAuditor === void 0 ? {} : { summonAuditor: options.summonAuditor }
|
|
@@ -24326,6 +24306,7 @@ async function loadPackagedCanonicalSkillBinding(packageRoot, name) {
|
|
|
24326
24306
|
}
|
|
24327
24307
|
|
|
24328
24308
|
// src/role-runtime.ts
|
|
24309
|
+
init_readable_gate_item();
|
|
24329
24310
|
init_host_contracts();
|
|
24330
24311
|
init_sitian_facade();
|
|
24331
24312
|
init_submission_ledger();
|
|
@@ -24754,8 +24735,6 @@ function registerEngineDetourTool(roleHost, hostActions) {
|
|
|
24754
24735
|
}
|
|
24755
24736
|
|
|
24756
24737
|
// src/role-runtime.ts
|
|
24757
|
-
init_readable_gate_item();
|
|
24758
|
-
init_run_terminal_artifacts();
|
|
24759
24738
|
init_receipt_delivery_policy();
|
|
24760
24739
|
|
|
24761
24740
|
// src/collector-role.ts
|
|
@@ -24978,7 +24957,6 @@ function isNotFound(error) {
|
|
|
24978
24957
|
|
|
24979
24958
|
// src/collector-role.ts
|
|
24980
24959
|
init_collector_ledger();
|
|
24981
|
-
init_packaged_role_registry();
|
|
24982
24960
|
init_submission_correctable_error();
|
|
24983
24961
|
init_collector_identity();
|
|
24984
24962
|
init_collector_identity();
|
|
@@ -25458,10 +25436,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
|
25458
25436
|
activation.ledger.beginOperational(COLLECTOR_OUTPUT_TOOL, toolCallId);
|
|
25459
25437
|
activation.ledger.recordOutputCandidate();
|
|
25460
25438
|
return {
|
|
25461
|
-
content: [
|
|
25462
|
-
type: "text",
|
|
25463
|
-
text: packagedRoleAcceptedText("collector")
|
|
25464
|
-
}],
|
|
25439
|
+
content: [],
|
|
25465
25440
|
details: params,
|
|
25466
25441
|
terminate: true
|
|
25467
25442
|
};
|
|
@@ -25484,7 +25459,7 @@ init_audit_escalation();
|
|
|
25484
25459
|
init_compliance_transport();
|
|
25485
25460
|
init_submission_errors();
|
|
25486
25461
|
init_dossier_resolution();
|
|
25487
|
-
|
|
25462
|
+
init_readable_gate_item();
|
|
25488
25463
|
init_doctor_contracts();
|
|
25489
25464
|
init_sitian_facade();
|
|
25490
25465
|
var DOCTOR_CASE_FLAG = { name: "ak-doctor-case", definition: { description: "Retained .ak-roles/books/<book>/<n>/runs directory", type: "string" } };
|
|
@@ -25539,22 +25514,22 @@ function createDoctorRoleRuntime(pi, dependencies, host) {
|
|
|
25539
25514
|
}
|
|
25540
25515
|
let audit;
|
|
25541
25516
|
try {
|
|
25542
|
-
audit = await dependencies.auditCompliance(signal === void 0 ? { context: ctx } : { context: ctx, signal });
|
|
25517
|
+
audit = await dependencies.auditCompliance(signal === void 0 ? { context: ctx, submission: testimony } : { context: ctx, signal, submission: testimony });
|
|
25543
25518
|
} catch (error) {
|
|
25544
25519
|
host.failInfrastructure(error, ctx, id);
|
|
25545
25520
|
}
|
|
25546
25521
|
const acceptedDetails = testimony;
|
|
25547
|
-
return disposeComplianceDecision(audit, { pass: (usage) => ({ content: [{ type: "text", text:
|
|
25522
|
+
return disposeComplianceDecision(audit, { pass: (usage) => ({ content: audit.status === "pass" && audit.receipt !== void 0 ? [{ type: "text", text: readableGateItem(audit.receipt) }] : [], details: acceptedDetails, terminate: true, ...usage === void 0 ? {} : { usage } }), noReceipt: (auditNoReceipt, usageProjection) => {
|
|
25548
25523
|
try {
|
|
25549
25524
|
appendCandidate(ctx, { version: 1, testimony, cost: active2.patient.cost, auditNoReceipt, readRecord: active2.store.readRecord(), patientIdentity: active2.patient.identity });
|
|
25550
25525
|
} catch (error) {
|
|
25551
25526
|
host.failInfrastructure(error, ctx, id);
|
|
25552
25527
|
}
|
|
25553
|
-
return { content: [
|
|
25528
|
+
return { content: [], details: acceptedDetails, terminate: true, ...usageProjection };
|
|
25554
25529
|
}, received: () => {
|
|
25555
25530
|
throw new Error("\u5BA1\u5211\u9662\u975E\u4E09\u6001\u5E94\u4EA4 runComplianceAudit \u91CD\u95EE\u8BF4\u8BDD\u8005");
|
|
25556
25531
|
}, bounce: (violations) => {
|
|
25557
|
-
throw new GatekeeperDecisionError({ status: "bounce", officer: "auditor", receipt: violations });
|
|
25532
|
+
throw new GatekeeperDecisionError({ status: "bounce", officer: "auditor", receipt: audit.status === "bounce" ? audit.receipt ?? violations : violations });
|
|
25558
25533
|
}, escalate: (result) => result, transportFailure: (facts) => {
|
|
25559
25534
|
host.failInfrastructure(Object.assign(new Error(facts.diagnostic), { name: "ComplianceTransportFailure", ...facts.submissions === void 0 && facts.terminal === void 0 ? {} : { submission: facts.submissions ?? facts.terminal } }), ctx, id);
|
|
25560
25535
|
} }, acceptedDetails);
|
|
@@ -25583,7 +25558,6 @@ ${JSON.stringify(catalog)}
|
|
|
25583
25558
|
}
|
|
25584
25559
|
|
|
25585
25560
|
// src/notary-role.ts
|
|
25586
|
-
init_packaged_role_registry();
|
|
25587
25561
|
init_notary_contracts();
|
|
25588
25562
|
function readNotaryTicketFlag(flag) {
|
|
25589
25563
|
if (flag === void 0) return void 0;
|
|
@@ -25662,7 +25636,7 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
|
|
|
25662
25636
|
throw new Error("\u7B26\u5B9D\u90CE\u672A\u6FC0\u6D3B");
|
|
25663
25637
|
}
|
|
25664
25638
|
return {
|
|
25665
|
-
content: [
|
|
25639
|
+
content: [],
|
|
25666
25640
|
details: parameters,
|
|
25667
25641
|
terminate: true
|
|
25668
25642
|
};
|
|
@@ -25893,7 +25867,6 @@ var DIARIST_TOOL_SPEC = {
|
|
|
25893
25867
|
// src/secretariat-role.ts
|
|
25894
25868
|
init_terminating_infrastructure();
|
|
25895
25869
|
init_secretariat_contracts();
|
|
25896
|
-
init_run_terminal_artifacts();
|
|
25897
25870
|
init_secretariat_contracts();
|
|
25898
25871
|
import { Type as Type23 } from "typebox";
|
|
25899
25872
|
var secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
@@ -25921,17 +25894,6 @@ var secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
|
25921
25894
|
)
|
|
25922
25895
|
);
|
|
25923
25896
|
secretariatVerdictSchema.required = [];
|
|
25924
|
-
var secretariatSummonCountersignSchema = Type23.Object(
|
|
25925
|
-
{
|
|
25926
|
-
instruction: Type23.Optional(
|
|
25927
|
-
Type23.String({
|
|
25928
|
-
description: "\u4F20\u53EC\u6563\u6587\uFF1B\u7968\u53F7\u5199\u5728\u5176\u4E2D\u3002\u7A7A\u5219\u6CBF\u7528\u672C\u5C40\u6307\u4EE4\u3002"
|
|
25929
|
-
})
|
|
25930
|
-
)
|
|
25931
|
-
},
|
|
25932
|
-
{ additionalProperties: true }
|
|
25933
|
-
);
|
|
25934
|
-
secretariatSummonCountersignSchema.required = [];
|
|
25935
25897
|
var SECRETARIAT_OUTPUT_TOOL_SPEC = {
|
|
25936
25898
|
name: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
25937
25899
|
label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
|
|
@@ -25939,68 +25901,6 @@ var SECRETARIAT_OUTPUT_TOOL_SPEC = {
|
|
|
25939
25901
|
promptSnippet: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267",
|
|
25940
25902
|
parameters: secretariatVerdictSchema
|
|
25941
25903
|
};
|
|
25942
|
-
var SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC = {
|
|
25943
|
-
name: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME,
|
|
25944
|
-
label: "\u4F20\u53EC\u7ED9\u4E8B\u4E2D",
|
|
25945
|
-
description: "\u7ECF\u5171\u4EAB\u6267\u884C\u63A5\u7F1D\u4F20\u53EC\u7ED9\u4E8B\u4E2D\u5BA1\u7968\uFF1B\u5C01\u9A73\u540E\u7EED\u540C\u4E00 run \u518D\u9001\u3002",
|
|
25946
|
-
promptSnippet: "\u4F20\u53EC\u7ED9\u4E8B\u4E2D",
|
|
25947
|
-
parameters: secretariatSummonCountersignSchema
|
|
25948
|
-
};
|
|
25949
|
-
function latestObjectPayload(payloads) {
|
|
25950
|
-
if (payloads === void 0 || payloads.length === 0) return void 0;
|
|
25951
|
-
const latest = payloads[payloads.length - 1];
|
|
25952
|
-
if (latest === null || typeof latest !== "object" || Array.isArray(latest)) {
|
|
25953
|
-
return void 0;
|
|
25954
|
-
}
|
|
25955
|
-
return latest;
|
|
25956
|
-
}
|
|
25957
|
-
function projectSecretariatSummonResult(summoned) {
|
|
25958
|
-
const terminal = summoned.terminal;
|
|
25959
|
-
const roleOutcome = terminal?.roleOutcome;
|
|
25960
|
-
const runDirectory = summoned.runDirectory;
|
|
25961
|
-
const runId = typeof runDirectory === "string" && runDirectory.trim() !== "" ? runIdFromRunDirectory(runDirectory) : void 0;
|
|
25962
|
-
const base = {
|
|
25963
|
-
exitCode: summoned.exitCode,
|
|
25964
|
-
...runId === void 0 ? {} : { runId },
|
|
25965
|
-
...runDirectory === void 0 ? {} : { runDirectory },
|
|
25966
|
-
...summoned.stderr === void 0 || summoned.stderr === "" ? {} : { stderr: summoned.stderr }
|
|
25967
|
-
};
|
|
25968
|
-
if (roleOutcome === void 0) {
|
|
25969
|
-
return { ...base, outcomeKind: "no_terminal" };
|
|
25970
|
-
}
|
|
25971
|
-
if (roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation") {
|
|
25972
|
-
const payloads = Array.isArray(roleOutcome.payloads) ? roleOutcome.payloads : void 0;
|
|
25973
|
-
const latest = latestObjectPayload(payloads);
|
|
25974
|
-
const countersignStatus = latest !== void 0 && typeof latest.countersignStatus === "string" ? latest.countersignStatus : void 0;
|
|
25975
|
-
return {
|
|
25976
|
-
...base,
|
|
25977
|
-
outcomeKind: roleOutcome.kind,
|
|
25978
|
-
// audit_escalation carries typed status; accepted may carry fixture/compat status.
|
|
25979
|
-
..."status" in roleOutcome && typeof roleOutcome.status === "string" && roleOutcome.status.length > 0 ? { status: roleOutcome.status } : {},
|
|
25980
|
-
...countersignStatus === void 0 ? {} : { countersignStatus },
|
|
25981
|
-
...latest === void 0 ? {} : { receipt: latest },
|
|
25982
|
-
...payloads === void 0 ? {} : { payloads },
|
|
25983
|
-
...roleOutcome.decisiveFacts === void 0 ? {} : { decisiveFacts: roleOutcome.decisiveFacts }
|
|
25984
|
-
};
|
|
25985
|
-
}
|
|
25986
|
-
if (roleOutcome.kind === "failure") {
|
|
25987
|
-
const submissions = Array.isArray(terminal?.submissions) ? terminal.submissions : void 0;
|
|
25988
|
-
return {
|
|
25989
|
-
...base,
|
|
25990
|
-
outcomeKind: "failure",
|
|
25991
|
-
diagnostic: roleOutcome.diagnostic,
|
|
25992
|
-
...roleOutcome.cause === void 0 ? {} : { cause: roleOutcome.cause },
|
|
25993
|
-
...roleOutcome.decisiveFacts === void 0 ? {} : { decisiveFacts: roleOutcome.decisiveFacts },
|
|
25994
|
-
...submissions === void 0 || submissions.length === 0 ? {} : { submissions }
|
|
25995
|
-
};
|
|
25996
|
-
}
|
|
25997
|
-
return {
|
|
25998
|
-
...base,
|
|
25999
|
-
outcomeKind: roleOutcome.kind,
|
|
26000
|
-
..."status" in roleOutcome && typeof roleOutcome.status === "string" && roleOutcome.status.length > 0 ? { status: roleOutcome.status } : {},
|
|
26001
|
-
..."decisiveFacts" in roleOutcome && roleOutcome.decisiveFacts !== void 0 ? { decisiveFacts: roleOutcome.decisiveFacts } : {}
|
|
26002
|
-
};
|
|
26003
|
-
}
|
|
26004
25904
|
|
|
26005
25905
|
// src/role-runtime.ts
|
|
26006
25906
|
init_secretariat_contracts();
|
|
@@ -26058,7 +25958,8 @@ init_audit_escalation();
|
|
|
26058
25958
|
// src/judge-role.ts
|
|
26059
25959
|
init_terminating_infrastructure();
|
|
26060
25960
|
init_submission_errors();
|
|
26061
|
-
|
|
25961
|
+
init_audit_escalation();
|
|
25962
|
+
init_readable_gate_item();
|
|
26062
25963
|
init_judge_output();
|
|
26063
25964
|
import { Type as Type24 } from "typebox";
|
|
26064
25965
|
var JUDGE_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
|
|
@@ -26122,35 +26023,45 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26122
26023
|
if (rawStatus === "escalate") {
|
|
26123
26024
|
const verdict2 = validateVerdict(parameters);
|
|
26124
26025
|
return {
|
|
26125
|
-
content: [
|
|
26026
|
+
content: [],
|
|
26126
26027
|
details: verdict2,
|
|
26127
26028
|
terminate: true
|
|
26128
26029
|
};
|
|
26129
26030
|
}
|
|
26130
26031
|
const verdict = validateVerdict(parameters);
|
|
26131
|
-
|
|
26132
|
-
|
|
26133
|
-
|
|
26134
|
-
|
|
26135
|
-
|
|
26136
|
-
|
|
26137
|
-
|
|
26138
|
-
|
|
26139
|
-
|
|
26140
|
-
|
|
26141
|
-
|
|
26142
|
-
|
|
26143
|
-
|
|
26144
|
-
|
|
26145
|
-
|
|
26146
|
-
|
|
26147
|
-
|
|
26148
|
-
|
|
26149
|
-
|
|
26150
|
-
|
|
26151
|
-
|
|
26152
|
-
|
|
26153
|
-
|
|
26032
|
+
let draftPass;
|
|
26033
|
+
try {
|
|
26034
|
+
const obtainedDraftPass = await pi.requireGatekeeperPass({
|
|
26035
|
+
context: ctx,
|
|
26036
|
+
subject: { kind: "judge_draft" },
|
|
26037
|
+
...signal === void 0 ? {} : { signal },
|
|
26038
|
+
hostActions,
|
|
26039
|
+
toolCallId,
|
|
26040
|
+
// #879: this-turn typed payload — identity-bound at submit site.
|
|
26041
|
+
submission: parameters
|
|
26042
|
+
});
|
|
26043
|
+
draftPass = obtainedDraftPass || void 0;
|
|
26044
|
+
if (draftPass !== void 0) hostActions.bindPriorGatePass(toolCallId, draftPass.receipt);
|
|
26045
|
+
const compliancePass = await pi.requireGatekeeperPass({
|
|
26046
|
+
context: ctx,
|
|
26047
|
+
subject: { kind: "judge_compliance" },
|
|
26048
|
+
...signal === void 0 ? {} : { signal },
|
|
26049
|
+
hostActions,
|
|
26050
|
+
toolCallId,
|
|
26051
|
+
// #879: same parent payload for 审刑院; not recovered from session latest.
|
|
26052
|
+
submission: parameters
|
|
26053
|
+
});
|
|
26054
|
+
return {
|
|
26055
|
+
content: [draftPass, compliancePass].filter((pass) => pass !== void 0).map((pass) => ({ type: "text", text: readableGateItem(pass.receipt) })),
|
|
26056
|
+
details: verdict,
|
|
26057
|
+
terminate: true
|
|
26058
|
+
};
|
|
26059
|
+
} catch (error) {
|
|
26060
|
+
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
26061
|
+
return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, verdict);
|
|
26062
|
+
}
|
|
26063
|
+
throw error;
|
|
26064
|
+
}
|
|
26154
26065
|
}
|
|
26155
26066
|
});
|
|
26156
26067
|
pi.on("before_agent_start", (event) => {
|
|
@@ -26171,7 +26082,6 @@ ${soul}
|
|
|
26171
26082
|
// src/reviewer-role.ts
|
|
26172
26083
|
init_open_tool_schema();
|
|
26173
26084
|
init_terminating_infrastructure();
|
|
26174
|
-
init_packaged_role_registry();
|
|
26175
26085
|
init_reviewer_output();
|
|
26176
26086
|
import { Type as Type25 } from "typebox";
|
|
26177
26087
|
var reviewerAmendmentsSchema = Type25.Object({
|
|
@@ -26224,7 +26134,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26224
26134
|
async execute(_id, parameters) {
|
|
26225
26135
|
if (!soul || !binding) throw new Error("\u5FA1\u53F2\u53F0\u8F93\u5165\u672A\u88C5\u8F7D");
|
|
26226
26136
|
return {
|
|
26227
|
-
content: [
|
|
26137
|
+
content: [],
|
|
26228
26138
|
details: parameters,
|
|
26229
26139
|
terminate: true
|
|
26230
26140
|
};
|
|
@@ -26247,7 +26157,9 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26247
26157
|
init_open_tool_schema();
|
|
26248
26158
|
init_terminating_infrastructure();
|
|
26249
26159
|
init_submission_correctable_error();
|
|
26250
|
-
|
|
26160
|
+
init_readable_gate_item();
|
|
26161
|
+
init_audit_escalation();
|
|
26162
|
+
init_submission_errors();
|
|
26251
26163
|
init_worker_output();
|
|
26252
26164
|
init_fixer_output();
|
|
26253
26165
|
init_fixer_packet();
|
|
@@ -26657,8 +26569,9 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26657
26569
|
ctx,
|
|
26658
26570
|
toolCallId
|
|
26659
26571
|
);
|
|
26660
|
-
|
|
26661
|
-
|
|
26572
|
+
let pass;
|
|
26573
|
+
try {
|
|
26574
|
+
pass = WORKER_DONE_STATUSES.has(workerStatusOf(output)) ? await pi.requireGatekeeperPass({
|
|
26662
26575
|
context: ctx,
|
|
26663
26576
|
subject: { kind: "worker_completion" },
|
|
26664
26577
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
@@ -26666,11 +26579,16 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26666
26579
|
toolCallId,
|
|
26667
26580
|
// #879: this-turn typed payload — identity-bound at submit site.
|
|
26668
26581
|
submission: output
|
|
26669
|
-
});
|
|
26582
|
+
}) : void 0;
|
|
26583
|
+
} catch (error) {
|
|
26584
|
+
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
26585
|
+
return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, output);
|
|
26586
|
+
}
|
|
26587
|
+
throw error;
|
|
26670
26588
|
}
|
|
26671
26589
|
const acceptedDetails = output;
|
|
26672
26590
|
return {
|
|
26673
|
-
content: [{ type: "text", text:
|
|
26591
|
+
content: pass === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
|
|
26674
26592
|
details: acceptedDetails,
|
|
26675
26593
|
terminate: true
|
|
26676
26594
|
};
|
|
@@ -26795,8 +26713,9 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26795
26713
|
ctx2,
|
|
26796
26714
|
toolCallId
|
|
26797
26715
|
);
|
|
26798
|
-
|
|
26799
|
-
|
|
26716
|
+
let pass;
|
|
26717
|
+
try {
|
|
26718
|
+
pass = WORKER_DONE_STATUSES.has(workerStatusOf(output)) ? await pi.requireGatekeeperPass({
|
|
26800
26719
|
context: ctx2,
|
|
26801
26720
|
subject: { kind: "worker_completion" },
|
|
26802
26721
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
@@ -26804,11 +26723,16 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26804
26723
|
toolCallId,
|
|
26805
26724
|
// #879: this-turn typed payload — identity-bound at submit site.
|
|
26806
26725
|
submission: output
|
|
26807
|
-
});
|
|
26726
|
+
}) : void 0;
|
|
26727
|
+
} catch (error) {
|
|
26728
|
+
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
26729
|
+
return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, output);
|
|
26730
|
+
}
|
|
26731
|
+
throw error;
|
|
26808
26732
|
}
|
|
26809
26733
|
const acceptedDetails = output;
|
|
26810
26734
|
return {
|
|
26811
|
-
content: [{ type: "text", text:
|
|
26735
|
+
content: pass === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
|
|
26812
26736
|
details: acceptedDetails,
|
|
26813
26737
|
terminate: true
|
|
26814
26738
|
};
|
|
@@ -26867,7 +26791,6 @@ init_doctor_contracts();
|
|
|
26867
26791
|
init_merger_contracts();
|
|
26868
26792
|
|
|
26869
26793
|
// src/merger-role.ts
|
|
26870
|
-
init_packaged_role_registry();
|
|
26871
26794
|
init_merger_contracts();
|
|
26872
26795
|
init_exact_utf8();
|
|
26873
26796
|
var MERGER_INPUT_FLAG = { name: "ak-merger-input", definition: { description: "Path to Merger assignment materials JSON", type: "string" } };
|
|
@@ -26896,7 +26819,7 @@ function createMergerRoleRuntime(pi, dependencies) {
|
|
|
26896
26819
|
parameters: mergerOutputSchema,
|
|
26897
26820
|
async execute(_id, params, _signal, _update, _ctx) {
|
|
26898
26821
|
if (!activation) throw new Error("\u6821\u4E66\u90CE\u672A\u6FC0\u6D3B");
|
|
26899
|
-
return { content: [
|
|
26822
|
+
return { content: [], details: params, terminate: true };
|
|
26900
26823
|
}
|
|
26901
26824
|
});
|
|
26902
26825
|
pi.on("before_agent_start", (event) => {
|
|
@@ -27187,9 +27110,13 @@ function createFiledOfficerRuntime(roleHost, spec, dependencies) {
|
|
|
27187
27110
|
async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
|
|
27188
27111
|
if (soul === void 0) throw new Error(`${spec.role} \u804C\u5206\u672A\u88C5\u8F7D`);
|
|
27189
27112
|
const projected = spec.beforeAccept === void 0 ? void 0 : await spec.beforeAccept({ toolCallId, parameters, signal, ctx });
|
|
27113
|
+
if (isAuditEscalationProjection(projected)) {
|
|
27114
|
+
return { content: [], details: projected, terminate: true };
|
|
27115
|
+
}
|
|
27116
|
+
const pass = spec.relayGatePass === true && projected !== null && typeof projected === "object" && "officer" in projected && "receipt" in projected ? projected : void 0;
|
|
27190
27117
|
return {
|
|
27191
|
-
content: [{ type: "text", text:
|
|
27192
|
-
details: projected === void 0 ? parameters : projected,
|
|
27118
|
+
content: pass === void 0 || pass.receipt === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
|
|
27119
|
+
details: pass === void 0 ? projected === void 0 ? parameters : projected : parameters,
|
|
27193
27120
|
terminate: true
|
|
27194
27121
|
};
|
|
27195
27122
|
}
|
|
@@ -27379,18 +27306,12 @@ ${error.message}`
|
|
|
27379
27306
|
}
|
|
27380
27307
|
var COUNTERSIGN_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
|
|
27381
27308
|
var 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";
|
|
27382
|
-
var SECRETARIAT_SUBMISSION_GATE_HOSTS = /* @__PURE__ */ new Set(["codex", "claude", "grok-build"]);
|
|
27383
27309
|
var SECRETARIAT_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "escalate"]);
|
|
27384
27310
|
var SECRETARIAT_STATUS_REASK = "secretariatStatus \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
|
27385
27311
|
function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
|
|
27386
|
-
let parentInstruction = "";
|
|
27387
27312
|
const beforeAccept = hostActions !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
|
|
27388
|
-
const host = typeof ctx.host === "string" && ctx.host.trim() !== "" ? ctx.host.trim() : void 0;
|
|
27389
|
-
if (host === void 0 || !SECRETARIAT_SUBMISSION_GATE_HOSTS.has(host)) {
|
|
27390
|
-
return void 0;
|
|
27391
|
-
}
|
|
27392
27313
|
if (roleHost.requireGatekeeperPass === void 0) {
|
|
27393
|
-
const error = new Error(
|
|
27314
|
+
const error = new Error("host cannot mount the secretariat submission gate");
|
|
27394
27315
|
error.name = "InfrastructureFailure";
|
|
27395
27316
|
return hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
27396
27317
|
}
|
|
@@ -27423,7 +27344,7 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
|
|
|
27423
27344
|
...runId === void 0 ? {} : { runId }
|
|
27424
27345
|
});
|
|
27425
27346
|
}
|
|
27426
|
-
return
|
|
27347
|
+
return pass;
|
|
27427
27348
|
} catch (error) {
|
|
27428
27349
|
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
27429
27350
|
const receipt = error.result.receipt;
|
|
@@ -27454,80 +27375,17 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
|
|
|
27454
27375
|
roleHost,
|
|
27455
27376
|
{
|
|
27456
27377
|
role: "secretariat",
|
|
27378
|
+
relayGatePass: true,
|
|
27457
27379
|
tool: SECRETARIAT_OUTPUT_TOOL_SPEC,
|
|
27458
27380
|
soulTag: "secretariat",
|
|
27459
27381
|
...beforeAccept === void 0 ? {} : { beforeAccept }
|
|
27460
27382
|
},
|
|
27461
27383
|
dependencies
|
|
27462
27384
|
);
|
|
27463
|
-
let summonRegistered = false;
|
|
27464
27385
|
return {
|
|
27465
27386
|
async activate() {
|
|
27466
27387
|
await base.activate();
|
|
27467
|
-
|
|
27468
|
-
summonRegistered = true;
|
|
27469
|
-
roleHost.on("before_agent_start", (event) => {
|
|
27470
|
-
if (typeof event.prompt === "string" && event.prompt.trim() !== "") {
|
|
27471
|
-
parentInstruction = event.prompt;
|
|
27472
|
-
}
|
|
27473
|
-
});
|
|
27474
|
-
roleHost.registerTool({
|
|
27475
|
-
name: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME,
|
|
27476
|
-
label: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC.label,
|
|
27477
|
-
description: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC.description,
|
|
27478
|
-
promptSnippet: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC.promptSnippet,
|
|
27479
|
-
parameters: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC.parameters,
|
|
27480
|
-
async execute(_toolCallId, parameters, signal, _onUpdate, ctx) {
|
|
27481
|
-
const fromArgs = typeof parameters?.instruction === "string" ? parameters.instruction.trim() : "";
|
|
27482
|
-
const instruction = fromArgs !== "" ? fromArgs : parentInstruction.trim();
|
|
27483
|
-
const correlationId = (() => {
|
|
27484
|
-
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
27485
|
-
if (runDirectory === void 0) return void 0;
|
|
27486
|
-
return runIdFromRunDirectory(runDirectory);
|
|
27487
|
-
})();
|
|
27488
|
-
const summon = dependencies.summonCountersign;
|
|
27489
|
-
const summoned = summon === void 0 ? await (async () => {
|
|
27490
|
-
const coordinates = readRoleRunCoordinates(ctx, "secretariat summons");
|
|
27491
|
-
const { summonPublicRole: summonPublicRole2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
27492
|
-
const { readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
|
|
27493
|
-
const parentTicket = await readBoardTicketNumber2(coordinates.runDirectory);
|
|
27494
|
-
return summonPublicRole2({
|
|
27495
|
-
role: "countersign",
|
|
27496
|
-
argv: ["--project", coordinates.projectRoot, "--", instruction],
|
|
27497
|
-
cwd: coordinates.projectRoot,
|
|
27498
|
-
home: coordinates.home,
|
|
27499
|
-
parentRunPath: coordinates.runDirectory,
|
|
27500
|
-
...parentTicket === void 0 ? {} : { boundTicketNumber: parentTicket },
|
|
27501
|
-
...signal === void 0 ? {} : { signal },
|
|
27502
|
-
...correlationId === void 0 ? {} : { correlationId },
|
|
27503
|
-
...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot },
|
|
27504
|
-
...dependencies.hostAdapters === void 0 ? {} : { hostAdapters: dependencies.hostAdapters }
|
|
27505
|
-
});
|
|
27506
|
-
})() : await summon({
|
|
27507
|
-
instruction,
|
|
27508
|
-
cwd: ctx.cwd,
|
|
27509
|
-
...signal === void 0 ? {} : { signal },
|
|
27510
|
-
...correlationId === void 0 ? {} : { correlationId },
|
|
27511
|
-
...dependencies.home === void 0 ? {} : { home: dependencies.home },
|
|
27512
|
-
...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot }
|
|
27513
|
-
});
|
|
27514
|
-
const details = projectSecretariatSummonResult(summoned);
|
|
27515
|
-
return {
|
|
27516
|
-
content: [
|
|
27517
|
-
{
|
|
27518
|
-
type: "text",
|
|
27519
|
-
text: readableGateItem(details)
|
|
27520
|
-
}
|
|
27521
|
-
],
|
|
27522
|
-
details
|
|
27523
|
-
};
|
|
27524
|
-
}
|
|
27525
|
-
});
|
|
27526
|
-
}
|
|
27527
|
-
const packageRequired = [
|
|
27528
|
-
SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
27529
|
-
SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME
|
|
27530
|
-
];
|
|
27388
|
+
const packageRequired = [SECRETARIAT_OUTPUT_TOOL_NAME];
|
|
27531
27389
|
const all = roleHost.getAllTools().map((tool) => tool.name);
|
|
27532
27390
|
for (const name of packageRequired) {
|
|
27533
27391
|
if (all.filter((item) => item === name).length !== 1) {
|
|
@@ -27565,20 +27423,29 @@ function createCountersignRoleRuntime(roleHost, dependencies, hostActions) {
|
|
|
27565
27423
|
error.name = "InfrastructureFailure";
|
|
27566
27424
|
return hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
27567
27425
|
}
|
|
27568
|
-
|
|
27569
|
-
|
|
27570
|
-
|
|
27571
|
-
|
|
27572
|
-
|
|
27573
|
-
|
|
27574
|
-
|
|
27575
|
-
|
|
27576
|
-
|
|
27426
|
+
try {
|
|
27427
|
+
return await roleHost.requireGatekeeperPass({
|
|
27428
|
+
context: ctx,
|
|
27429
|
+
subject: { kind: "countersign_verdict" },
|
|
27430
|
+
...signal === void 0 ? {} : { signal },
|
|
27431
|
+
hostActions,
|
|
27432
|
+
toolCallId,
|
|
27433
|
+
// #879: this-turn typed payload — identity-bound at submit site.
|
|
27434
|
+
submission: parameters
|
|
27435
|
+
});
|
|
27436
|
+
} catch (error) {
|
|
27437
|
+
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
27438
|
+
const { buildAuditEscalationResult: buildAuditEscalationResult2 } = await Promise.resolve().then(() => (init_audit_escalation(), audit_escalation_exports));
|
|
27439
|
+
return buildAuditEscalationResult2({ status: "escalate", officer: "notary", conflicts: error.result.receipt }, parameters);
|
|
27440
|
+
}
|
|
27441
|
+
throw error;
|
|
27442
|
+
}
|
|
27577
27443
|
} : void 0;
|
|
27578
27444
|
return createFiledOfficerRuntime(
|
|
27579
27445
|
roleHost,
|
|
27580
27446
|
{
|
|
27581
27447
|
role: "countersign",
|
|
27448
|
+
relayGatePass: true,
|
|
27582
27449
|
tool: COUNTERSIGN_TOOL_SPEC,
|
|
27583
27450
|
soulTag: "countersign",
|
|
27584
27451
|
...beforeAccept === void 0 ? {} : { beforeAccept }
|
|
@@ -27649,6 +27516,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27649
27516
|
let navigatorCwd;
|
|
27650
27517
|
const pendingInfrastructureFailures = /* @__PURE__ */ new Map();
|
|
27651
27518
|
const pendingSubmissionNonPassByToolCallId = /* @__PURE__ */ new Map();
|
|
27519
|
+
const pendingPriorGatePassByToolCallId = /* @__PURE__ */ new Map();
|
|
27652
27520
|
let engineDetourRegistered = false;
|
|
27653
27521
|
let receiptDelivery = createReceiptDeliveryPolicy();
|
|
27654
27522
|
let noReceiptRecorded = false;
|
|
@@ -27843,6 +27711,9 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27843
27711
|
return { readingMaterial: caseDossier };
|
|
27844
27712
|
});
|
|
27845
27713
|
roleHost.on("tool_result", async (event) => {
|
|
27714
|
+
const priorGatePass = pendingPriorGatePassByToolCallId.get(event.toolCallId);
|
|
27715
|
+
pendingPriorGatePassByToolCallId.delete(event.toolCallId);
|
|
27716
|
+
const priorPassContent = priorGatePass !== void 0 && event.isError ? [{ type: "text", text: readableGateItem(priorGatePass) }, ...event.content ?? []] : void 0;
|
|
27846
27717
|
const role = selectedRole;
|
|
27847
27718
|
if (role === void 0) return;
|
|
27848
27719
|
if (activeCollector !== void 0 && selectedRole === roleHost.getFlag(ROLE_FLAG.name)) {
|
|
@@ -27864,13 +27735,14 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27864
27735
|
const settlement = isRoleInfrastructureFailure || outputClassification?.kind === "infrastructure" ? publicNavigatorSettlement(role, navigatorPhase(roleHost, role), classified) : void 0;
|
|
27865
27736
|
await settleNavigatorProjection(settlement);
|
|
27866
27737
|
if (infrastructureDetails !== void 0) {
|
|
27867
|
-
return { isError: true };
|
|
27738
|
+
return { isError: true, ...priorPassContent === void 0 ? {} : { content: priorPassContent } };
|
|
27868
27739
|
}
|
|
27869
27740
|
const submissionNonPass = pendingSubmissionNonPassByToolCallId.get(event.toolCallId);
|
|
27870
27741
|
if (submissionNonPass !== void 0) {
|
|
27871
27742
|
pendingSubmissionNonPassByToolCallId.delete(event.toolCallId);
|
|
27872
|
-
return { details: submissionNonPass, isError: true };
|
|
27743
|
+
return { details: submissionNonPass, isError: true, ...priorPassContent === void 0 ? {} : { content: priorPassContent } };
|
|
27873
27744
|
}
|
|
27745
|
+
if (priorPassContent !== void 0) return { content: priorPassContent, isError: true };
|
|
27874
27746
|
});
|
|
27875
27747
|
roleHost.on("agent_end", async (event, ctx) => {
|
|
27876
27748
|
const lastMessage = event.messages.at(-1);
|
|
@@ -28006,6 +27878,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28006
27878
|
disposeNavigatorAttendanceNonBlocking(attendanceToDispose);
|
|
28007
27879
|
pendingInfrastructureFailures.clear();
|
|
28008
27880
|
pendingSubmissionNonPassByToolCallId.clear();
|
|
27881
|
+
pendingPriorGatePassByToolCallId.clear();
|
|
28009
27882
|
observationFace.reset();
|
|
28010
27883
|
});
|
|
28011
27884
|
const hostActions = {
|
|
@@ -28017,6 +27890,9 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28017
27890
|
},
|
|
28018
27891
|
bindSubmissionNonPass(toolCallId, result) {
|
|
28019
27892
|
pendingSubmissionNonPassByToolCallId.set(toolCallId, result);
|
|
27893
|
+
},
|
|
27894
|
+
bindPriorGatePass(toolCallId, receipt) {
|
|
27895
|
+
pendingPriorGatePassByToolCallId.set(toolCallId, receipt);
|
|
28020
27896
|
}
|
|
28021
27897
|
};
|
|
28022
27898
|
const requireRoleSoul = (role) => dependencies.loadRoleSoul(role);
|
|
@@ -28118,9 +27994,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28118
27994
|
}
|
|
28119
27995
|
);
|
|
28120
27996
|
const secretariat = createSecretariatRoleRuntime(roleHost, {
|
|
28121
|
-
loadSoul: () => requireRoleSoul("secretariat")
|
|
28122
|
-
...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot },
|
|
28123
|
-
...dependencies.hostAdapters === void 0 ? {} : { hostAdapters: dependencies.hostAdapters }
|
|
27997
|
+
loadSoul: () => requireRoleSoul("secretariat")
|
|
28124
27998
|
}, hostActions);
|
|
28125
27999
|
const merger = createMergerRoleRuntime(roleHost, {
|
|
28126
28000
|
loadSoul: () => requireRoleSoul("merger"),
|
|
@@ -28311,6 +28185,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28311
28185
|
pendingNavigatorSettlement = void 0;
|
|
28312
28186
|
pendingInfrastructureFailures.clear();
|
|
28313
28187
|
pendingSubmissionNonPassByToolCallId.clear();
|
|
28188
|
+
pendingPriorGatePassByToolCallId.clear();
|
|
28314
28189
|
navigatorWorkContext = void 0;
|
|
28315
28190
|
envelopeHost.startKeepalive(ctx);
|
|
28316
28191
|
const rawRole = roleHost.getFlag(ROLE_FLAG.name);
|
|
@@ -28602,7 +28477,7 @@ async function requireGatekeeperPass(options) {
|
|
|
28602
28477
|
});
|
|
28603
28478
|
options.hostActions.failInfrastructure(failure2, options.context, options.toolCallId);
|
|
28604
28479
|
}
|
|
28605
|
-
if (gatekeeper.status === "escalate"
|
|
28480
|
+
if (gatekeeper.status === "escalate") {
|
|
28606
28481
|
throw new GatekeeperDecisionError(gatekeeper);
|
|
28607
28482
|
}
|
|
28608
28483
|
options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
|