@akagilnc/pi-workflow-roles 0.1.4951 → 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
|
@@ -3522,7 +3522,7 @@ function validateDoctorSubmissionShape(value) {
|
|
|
3522
3522
|
function validateDoctorOutput(value, _patient, _store) {
|
|
3523
3523
|
return validateDoctorSubmissionShape(value);
|
|
3524
3524
|
}
|
|
3525
|
-
var DOCTOR_EVIDENCE_TOOL_NAME, DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_AUDIT_TOOL_NAME,
|
|
3525
|
+
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;
|
|
3526
3526
|
var init_doctor_contracts = __esm({
|
|
3527
3527
|
"src/doctor-contracts.ts"() {
|
|
3528
3528
|
"use strict";
|
|
@@ -3532,7 +3532,6 @@ var init_doctor_contracts = __esm({
|
|
|
3532
3532
|
DOCTOR_EVIDENCE_TOOL_NAME = "ak_doctor_evidence";
|
|
3533
3533
|
DOCTOR_OUTPUT_TOOL_NAME = "ak_doctor_output";
|
|
3534
3534
|
DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
|
|
3535
|
-
DOCTOR_ACCEPTED_AUDIT_NO_RECEIPT_TEXT = "\u592A\u533B\u7F72\u56DE\u6267\u5DF2\u63A5\u53D7\uFF1B\u5BA1\u8BA1\u65E0\u56DE\u6267";
|
|
3536
3535
|
DOCTOR_OUTPUT_TOOL_DESCRIPTION = "\u63D0\u4EA4\u552F\u4E00\u7EC8\u5C40\u5355\u6848\u8BC1\u8BCD\uFF1Bcompleted \u5141\u8BB8\u7A7A findings\u3002";
|
|
3537
3536
|
DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
|
|
3538
3537
|
nonblank = Type8.Optional(Type8.String());
|
|
@@ -4003,15 +4002,13 @@ var secretariat_contracts_exports = {};
|
|
|
4003
4002
|
__export(secretariat_contracts_exports, {
|
|
4004
4003
|
SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY: () => SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY,
|
|
4005
4004
|
SECRETARIAT_GATE_OFFICER_ENTRY_TYPE: () => SECRETARIAT_GATE_OFFICER_ENTRY_TYPE,
|
|
4006
|
-
SECRETARIAT_OUTPUT_TOOL_NAME: () => SECRETARIAT_OUTPUT_TOOL_NAME
|
|
4007
|
-
SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME: () => SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME
|
|
4005
|
+
SECRETARIAT_OUTPUT_TOOL_NAME: () => SECRETARIAT_OUTPUT_TOOL_NAME
|
|
4008
4006
|
});
|
|
4009
|
-
var SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
4007
|
+
var SECRETARIAT_OUTPUT_TOOL_NAME, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY;
|
|
4010
4008
|
var init_secretariat_contracts = __esm({
|
|
4011
4009
|
"src/secretariat-contracts.ts"() {
|
|
4012
4010
|
"use strict";
|
|
4013
4011
|
SECRETARIAT_OUTPUT_TOOL_NAME = "ak_secretariat_output";
|
|
4014
|
-
SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME = "ak_secretariat_summon_countersign";
|
|
4015
4012
|
SECRETARIAT_GATE_OFFICER_ENTRY_TYPE = "ak-secretariat-gate-officer";
|
|
4016
4013
|
SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY = "countersignTerminal";
|
|
4017
4014
|
}
|
|
@@ -4059,7 +4056,6 @@ __export(packaged_role_registry_exports, {
|
|
|
4059
4056
|
packagedRebindSourceOnResume: () => packagedRebindSourceOnResume,
|
|
4060
4057
|
packagedResumeSourcePath: () => packagedResumeSourcePath,
|
|
4061
4058
|
packagedRoleAcceptedOutputTool: () => packagedRoleAcceptedOutputTool,
|
|
4062
|
-
packagedRoleAcceptedText: () => packagedRoleAcceptedText,
|
|
4063
4059
|
packagedRoleActivationFlags: () => packagedRoleActivationFlags,
|
|
4064
4060
|
packagedRoleInputFlag: () => packagedRoleInputFlag,
|
|
4065
4061
|
packagedRoleMetadata: () => packagedRoleMetadata,
|
|
@@ -4107,13 +4103,6 @@ function packagedRolePhaseFlag(role) {
|
|
|
4107
4103
|
function packagedRoleOutputTool(role) {
|
|
4108
4104
|
return packagedRoleMetadata(role)?.outputTool;
|
|
4109
4105
|
}
|
|
4110
|
-
function packagedRoleAcceptedText(role) {
|
|
4111
|
-
const record4 = packagedRoleMetadata(role);
|
|
4112
|
-
if (record4 === void 0) {
|
|
4113
|
-
throw new Error(`Unsupported workflow role: ${String(role)}`);
|
|
4114
|
-
}
|
|
4115
|
-
return record4.acceptedText;
|
|
4116
|
-
}
|
|
4117
4106
|
function packagedMethodLoadFailureCause(role) {
|
|
4118
4107
|
const record4 = packagedRoleMetadata(role);
|
|
4119
4108
|
if (record4 === void 0 || !("methodLoadFailureCause" in record4)) return void 0;
|
|
@@ -4286,7 +4275,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4286
4275
|
auditTool: JUDGE_AUDIT_TOOL_NAME,
|
|
4287
4276
|
settlement: "sealed",
|
|
4288
4277
|
runnerFailure: "engine-detour-known-first",
|
|
4289
|
-
acceptedText: "\u5927\u7406\u5BFA\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4290
4278
|
/** Factory board: court until another station has started, then marshal. */
|
|
4291
4279
|
boardPlacement: "judge-history",
|
|
4292
4280
|
/** Navigator subject is the public admitted instruction when the run is bound. */
|
|
@@ -4325,7 +4313,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4325
4313
|
],
|
|
4326
4314
|
method: "observed"
|
|
4327
4315
|
},
|
|
4328
|
-
acceptedText: "\u4FEE\u5185\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4329
4316
|
boardPlacement: "marshal",
|
|
4330
4317
|
activationFlags: [
|
|
4331
4318
|
{ field: "packetPath", flag: "ak-fix-packet", binds: "input" },
|
|
@@ -4364,7 +4351,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4364
4351
|
],
|
|
4365
4352
|
method: "optional"
|
|
4366
4353
|
},
|
|
4367
|
-
acceptedText: "\u5C06\u4F5C\u76D1\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4368
4354
|
activationFlags: [
|
|
4369
4355
|
{ field: "taskPath", flag: "ak-coder-task", binds: "input" },
|
|
4370
4356
|
{ field: "phase", flag: "ak-coder-phase", binds: "phase" }
|
|
@@ -4410,7 +4396,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4410
4396
|
/** Frozen base/lens/authority become the initial prompt; instruction follows. */
|
|
4411
4397
|
transportPrompt: "skill-args",
|
|
4412
4398
|
runnerFailure: "engine-detour-record-first",
|
|
4413
|
-
acceptedText: "\u5FA1\u53F2\u53F0\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4414
4399
|
boardPlacement: "marshal",
|
|
4415
4400
|
activationFlags: [
|
|
4416
4401
|
{ field: "baseRevision", flag: "ak-review-base" },
|
|
@@ -4452,7 +4437,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4452
4437
|
{ key: "manifestDigest" }
|
|
4453
4438
|
]
|
|
4454
4439
|
},
|
|
4455
|
-
acceptedText: "\u901A\u8FDB\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4456
4440
|
boardPlacement: "collector",
|
|
4457
4441
|
/** Taishi acceptance is a typed groups array, not a status leaf. */
|
|
4458
4442
|
analystTerminal: "groups",
|
|
@@ -4486,7 +4470,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4486
4470
|
],
|
|
4487
4471
|
doctorReportFacts: true
|
|
4488
4472
|
},
|
|
4489
|
-
acceptedText: "\u592A\u533B\u7F72\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4490
4473
|
/** Navigator subject is the doctor case, not the case-path file bytes. */
|
|
4491
4474
|
navigatorSubject: "case",
|
|
4492
4475
|
activationFlags: [
|
|
@@ -4522,7 +4505,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4522
4505
|
],
|
|
4523
4506
|
method: "observed"
|
|
4524
4507
|
},
|
|
4525
|
-
acceptedText: "\u5408\u5E76\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4526
4508
|
activationFlags: [
|
|
4527
4509
|
{ field: "inputPath", from: "mergerInputPath", flag: "ak-merger-input", binds: "input" }
|
|
4528
4510
|
],
|
|
@@ -4555,7 +4537,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4555
4537
|
/** Court reask replaces the initial prompt. Otherwise the fixed kickoff. */
|
|
4556
4538
|
reaskPrompt: true,
|
|
4557
4539
|
transportPrompt: "fixed-kickoff",
|
|
4558
|
-
acceptedText: "\u7B26\u5B9D\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4559
4540
|
gateStageLabel: "\u7B26\u5B9D\u90CE",
|
|
4560
4541
|
/** Gate summon binds --source-run and keeps dialogue off the argv. */
|
|
4561
4542
|
gateSummon: "source-run",
|
|
@@ -4580,7 +4561,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4580
4561
|
phases: [null],
|
|
4581
4562
|
outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
|
|
4582
4563
|
settlement: "accepted",
|
|
4583
|
-
acceptedText: "\u7ED9\u4E8B\u4E2D\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4584
4564
|
gateStageLabel: "\u7ED9\u4E8B\u4E2D",
|
|
4585
4565
|
/** Gate queue reads countersignStatus, not the shared three-state status. */
|
|
4586
4566
|
gateDecision: "countersign-status",
|
|
@@ -4606,7 +4586,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4606
4586
|
settlement: "accepted",
|
|
4607
4587
|
/** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
|
|
4608
4588
|
projectCountersignTerminal: true,
|
|
4609
|
-
acceptedText: "\u4E2D\u4E66\u7701\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4610
4589
|
activationFlags: [
|
|
4611
4590
|
{ field: "ticketNumber" }
|
|
4612
4591
|
],
|
|
@@ -4636,7 +4615,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4636
4615
|
settlement: "accepted",
|
|
4637
4616
|
/** Bound comparison base is the initial prompt; instruction follows. */
|
|
4638
4617
|
transportPrompt: "baseline",
|
|
4639
|
-
acceptedText: "\u5DE6\u62FE\u9057\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4640
4618
|
activationFlags: [
|
|
4641
4619
|
{ field: "baseRevision", flag: "ak-gleaner-left-base" }
|
|
4642
4620
|
],
|
|
@@ -4667,7 +4645,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4667
4645
|
settlement: "accepted",
|
|
4668
4646
|
/** Court reask replaces the initial prompt. */
|
|
4669
4647
|
reaskPrompt: true,
|
|
4670
|
-
acceptedText: "\u53F0\u9662\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4671
4648
|
gateStageLabel: "\u53F0\u9662",
|
|
4672
4649
|
activationFlags: [
|
|
4673
4650
|
{
|
|
@@ -4699,7 +4676,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4699
4676
|
outputTool: GATEKEEPER_OUTPUT_TOOL_NAME,
|
|
4700
4677
|
settlement: "accepted",
|
|
4701
4678
|
runnerFailure: "engine-detour-record-first",
|
|
4702
|
-
acceptedText: "\u95E8\u4E0B\u7701\u51B3\u8BAE\u5DF2\u53D7\u7406",
|
|
4703
4679
|
activationStage: "load-and-install",
|
|
4704
4680
|
// Province materials; officers reuse their own public records below.
|
|
4705
4681
|
sessionMaterials: ["CLAUDE.md", "souls/gatekeeper.md", "souls/quality-law.md", "souls/gate-output-guide.md"]
|
|
@@ -4715,7 +4691,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4715
4691
|
outputTool: NAVIGATOR_OUTPUT_TOOL_NAME,
|
|
4716
4692
|
settlement: "accepted",
|
|
4717
4693
|
runnerFailure: "engine-detour-record-first",
|
|
4718
|
-
acceptedText: "\u6E38\u5955\u4F7F\u5EFA\u8BAE\u5DF2\u53D7\u7406",
|
|
4719
4694
|
activationStage: "load-and-install",
|
|
4720
4695
|
sessionMaterials: ["CLAUDE.md", "souls/navigator.md"]
|
|
4721
4696
|
},
|
|
@@ -4739,7 +4714,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4739
4714
|
/** Court reask replaces the initial prompt. */
|
|
4740
4715
|
reaskPrompt: true,
|
|
4741
4716
|
runnerFailure: "engine-detour-record-first",
|
|
4742
|
-
acceptedText: "\u5BA1\u5211\u9662\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4743
4717
|
gateStageLabel: "\u5BA1\u5211\u9662",
|
|
4744
4718
|
/** Gate summon binds --subject judge and --source-run. */
|
|
4745
4719
|
gateSummon: "subject-source",
|
|
@@ -4758,7 +4732,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4758
4732
|
phases: [null],
|
|
4759
4733
|
outputTool: DIARIST_OUTPUT_TOOL_NAME,
|
|
4760
4734
|
settlement: "accepted",
|
|
4761
|
-
acceptedText: "\u8D77\u5C45\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7",
|
|
4762
4735
|
activationStage: "load-and-install",
|
|
4763
4736
|
sessionMaterials: [
|
|
4764
4737
|
"CLAUDE.md",
|
|
@@ -5065,7 +5038,7 @@ function projectOfficerTerminal(officer, summoned) {
|
|
|
5065
5038
|
status: "escalate",
|
|
5066
5039
|
officer,
|
|
5067
5040
|
// This-court receipt only (#879) — historical rows remain on terminal.submissions.
|
|
5068
|
-
receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
|
|
5041
|
+
receipt: outcome.decisiveFacts !== void 0 && Object.hasOwn(outcome.decisiveFacts, "auditEscalationReceipt") ? outcome.decisiveFacts.auditEscalationReceipt : thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
|
|
5069
5042
|
},
|
|
5070
5043
|
summoned
|
|
5071
5044
|
);
|
|
@@ -6298,8 +6271,8 @@ function formatTerminalResult(result) {
|
|
|
6298
6271
|
`diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
|
|
6299
6272
|
);
|
|
6300
6273
|
}
|
|
6301
|
-
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
|
|
6302
|
-
const facts = result.roleOutcome.decisiveFacts;
|
|
6274
|
+
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt" || result.roleOutcome.kind === "audit_escalation") {
|
|
6275
|
+
const facts = result.roleOutcome.decisiveFacts ?? {};
|
|
6303
6276
|
for (const [key, value] of Object.entries(facts)) {
|
|
6304
6277
|
if (value === void 0) continue;
|
|
6305
6278
|
const rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
@@ -6443,15 +6416,7 @@ async function projectAuditorTerminal(summoned) {
|
|
|
6443
6416
|
if (rows.length === 0) {
|
|
6444
6417
|
return readComplianceCandidate({}, usage);
|
|
6445
6418
|
}
|
|
6446
|
-
|
|
6447
|
-
if (rows.length === 1) return decision;
|
|
6448
|
-
if (decision.status === "pass" || decision.status === "bounce" || decision.status === "escalate") {
|
|
6449
|
-
return { ...decision, receipt: rows };
|
|
6450
|
-
}
|
|
6451
|
-
if (decision.status === "received") {
|
|
6452
|
-
return { ...decision, reply: rows };
|
|
6453
|
-
}
|
|
6454
|
-
return decision;
|
|
6419
|
+
return readComplianceCandidate(rows[rows.length - 1], usage);
|
|
6455
6420
|
}
|
|
6456
6421
|
return {
|
|
6457
6422
|
status: "received",
|
|
@@ -6465,6 +6430,7 @@ async function runComplianceAudit(options) {
|
|
|
6465
6430
|
throw new Error("Compliance audit requires a parent run directory pointer");
|
|
6466
6431
|
}
|
|
6467
6432
|
const subject = options.subject;
|
|
6433
|
+
const submission = options.submission === void 0 ? void 0 : readableGateItem(options.submission);
|
|
6468
6434
|
const summon = options.summonAuditor ?? (async (auditSubject, sourceRunDirectory, auditSignal, reask2) => {
|
|
6469
6435
|
const { summonPublicRole: summonPublicRole2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
6470
6436
|
const { homeFromRunDirectory: homeFromRunDirectory2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
|
|
@@ -6481,12 +6447,13 @@ async function runComplianceAudit(options) {
|
|
|
6481
6447
|
cwd: options.context.cwd ?? process.cwd(),
|
|
6482
6448
|
home,
|
|
6483
6449
|
...auditSignal === void 0 ? {} : { signal: auditSignal },
|
|
6484
|
-
...reask2 === void 0 ? {} : { reviewReask: reask2 }
|
|
6450
|
+
...reask2 === void 0 ? {} : { reviewReask: reask2 },
|
|
6451
|
+
...submission === void 0 ? {} : { gateReviewInstruction: submission }
|
|
6485
6452
|
});
|
|
6486
6453
|
});
|
|
6487
6454
|
let reask;
|
|
6488
6455
|
for (; ; ) {
|
|
6489
|
-
const summoned = await summon(subject, runDirectory, options.signal, reask);
|
|
6456
|
+
const summoned = await summon(subject, runDirectory, options.signal, reask, submission);
|
|
6490
6457
|
const decision = await projectAuditorTerminal(summoned);
|
|
6491
6458
|
if (decision.status === "received") {
|
|
6492
6459
|
reask = OFFICER_CONCLUSION_REASK;
|
|
@@ -6502,6 +6469,7 @@ var init_compliance_transport = __esm({
|
|
|
6502
6469
|
init_auditor_dossier_tool();
|
|
6503
6470
|
init_gatekeeper_role();
|
|
6504
6471
|
init_terminal();
|
|
6472
|
+
init_readable_gate_item();
|
|
6505
6473
|
AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
|
|
6506
6474
|
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
6507
6475
|
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
@@ -13531,6 +13499,9 @@ function buildAuditEscalationResult(decision, deliveredOutput) {
|
|
|
13531
13499
|
const auditOwned = {
|
|
13532
13500
|
kind: AUDIT_ESCALATION_KIND
|
|
13533
13501
|
};
|
|
13502
|
+
if (Object.hasOwn(decision, "receipt")) {
|
|
13503
|
+
auditOwned.receipt = decision.receipt;
|
|
13504
|
+
}
|
|
13534
13505
|
if (Object.hasOwn(decision, "conflicts")) {
|
|
13535
13506
|
auditOwned.conflicts = decision.conflicts;
|
|
13536
13507
|
}
|
|
@@ -13560,9 +13531,8 @@ function isAuditEscalationProjection(value) {
|
|
|
13560
13531
|
}
|
|
13561
13532
|
function projectAuditEscalation(decision, deliveredOutput) {
|
|
13562
13533
|
const details = buildAuditEscalationResult(decision, deliveredOutput);
|
|
13563
|
-
const original = deliveredOutput !== void 0 ? deliveredOutput : decision;
|
|
13564
13534
|
return {
|
|
13565
|
-
content: [
|
|
13535
|
+
content: [],
|
|
13566
13536
|
details,
|
|
13567
13537
|
terminate: true,
|
|
13568
13538
|
...decision.usage === void 0 ? {} : { usage: decision.usage }
|
|
@@ -13616,7 +13586,6 @@ var AUDIT_ESCALATION_KIND, AUDIT_ESCALATION_LIVE_REGISTRY;
|
|
|
13616
13586
|
var init_audit_escalation = __esm({
|
|
13617
13587
|
"src/audit-escalation.ts"() {
|
|
13618
13588
|
"use strict";
|
|
13619
|
-
init_readable_gate_item();
|
|
13620
13589
|
init_submission_errors();
|
|
13621
13590
|
AUDIT_ESCALATION_KIND = "audit_escalation";
|
|
13622
13591
|
AUDIT_ESCALATION_LIVE_REGISTRY = /* @__PURE__ */ new WeakSet();
|
|
@@ -13731,6 +13700,7 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
|
13731
13700
|
...role === void 0 ? {} : { role },
|
|
13732
13701
|
kind,
|
|
13733
13702
|
accepted,
|
|
13703
|
+
...Object.hasOwn(payload, "auditReceipt") ? { auditReceipt: payload.auditReceipt } : {},
|
|
13734
13704
|
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
13735
13705
|
};
|
|
13736
13706
|
}
|
|
@@ -13995,6 +13965,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
13995
13965
|
}
|
|
13996
13966
|
}
|
|
13997
13967
|
if (isAuditEscalationProjection(result.details) || isAuditEscalationProjection(params)) {
|
|
13968
|
+
const audit = isAuditEscalationProjection(result.details) && typeof result.details.audit === "object" && result.details.audit !== null ? result.details.audit : void 0;
|
|
13998
13969
|
const closed2 = {
|
|
13999
13970
|
role,
|
|
14000
13971
|
kind: "audit_escalation",
|
|
@@ -14006,7 +13977,8 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
14006
13977
|
toolCallId,
|
|
14007
13978
|
outcome: "audit-escalation",
|
|
14008
13979
|
role,
|
|
14009
|
-
accepted: params
|
|
13980
|
+
accepted: params,
|
|
13981
|
+
...audit !== void 0 && (Object.hasOwn(audit, "receipt") || Object.hasOwn(audit, "conflicts")) ? { auditReceipt: Object.hasOwn(audit, "receipt") ? audit.receipt : audit.conflicts } : {}
|
|
14010
13982
|
});
|
|
14011
13983
|
await projectClosure(closed2, context);
|
|
14012
13984
|
return result;
|
|
@@ -15122,7 +15094,14 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
15122
15094
|
if (terminal.length === 0) return void 0;
|
|
15123
15095
|
const payloads = mine.map((row) => row.accepted);
|
|
15124
15096
|
if (terminal.some((row) => row.kind === "audit-escalation")) {
|
|
15125
|
-
|
|
15097
|
+
const audited = terminal.slice().reverse().find((row) => row.kind === "audit-escalation" && Object.hasOwn(row, "auditReceipt"));
|
|
15098
|
+
return {
|
|
15099
|
+
kind: "audit_escalation",
|
|
15100
|
+
role,
|
|
15101
|
+
status: "audit_escalation",
|
|
15102
|
+
payloads,
|
|
15103
|
+
...audited === void 0 ? {} : { decisiveFacts: { auditEscalationReceipt: audited.auditReceipt } }
|
|
15104
|
+
};
|
|
15126
15105
|
}
|
|
15127
15106
|
return { kind: "accepted", role, payloads };
|
|
15128
15107
|
}
|
|
@@ -23282,7 +23261,7 @@ async function requireGatekeeperPass(options) {
|
|
|
23282
23261
|
});
|
|
23283
23262
|
options.hostActions.failInfrastructure(failure2, options.context, options.toolCallId);
|
|
23284
23263
|
}
|
|
23285
|
-
if (gatekeeper.status === "escalate"
|
|
23264
|
+
if (gatekeeper.status === "escalate") {
|
|
23286
23265
|
throw new GatekeeperDecisionError(gatekeeper);
|
|
23287
23266
|
}
|
|
23288
23267
|
options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
|
|
@@ -23407,6 +23386,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
23407
23386
|
init_packaged_role_registry();
|
|
23408
23387
|
|
|
23409
23388
|
// src/role-runtime.ts
|
|
23389
|
+
init_readable_gate_item();
|
|
23410
23390
|
init_host_contracts();
|
|
23411
23391
|
init_sitian_facade();
|
|
23412
23392
|
init_submission_ledger();
|
|
@@ -23835,8 +23815,6 @@ function registerEngineDetourTool(roleHost, hostActions) {
|
|
|
23835
23815
|
}
|
|
23836
23816
|
|
|
23837
23817
|
// src/role-runtime.ts
|
|
23838
|
-
init_readable_gate_item();
|
|
23839
|
-
init_run_terminal_artifacts();
|
|
23840
23818
|
init_receipt_delivery_policy();
|
|
23841
23819
|
|
|
23842
23820
|
// src/collector-role.ts
|
|
@@ -24059,7 +24037,6 @@ function isNotFound(error) {
|
|
|
24059
24037
|
|
|
24060
24038
|
// src/collector-role.ts
|
|
24061
24039
|
init_collector_ledger();
|
|
24062
|
-
init_packaged_role_registry();
|
|
24063
24040
|
init_submission_correctable_error();
|
|
24064
24041
|
init_collector_identity();
|
|
24065
24042
|
init_collector_identity();
|
|
@@ -24539,10 +24516,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
|
24539
24516
|
activation.ledger.beginOperational(COLLECTOR_OUTPUT_TOOL, toolCallId);
|
|
24540
24517
|
activation.ledger.recordOutputCandidate();
|
|
24541
24518
|
return {
|
|
24542
|
-
content: [
|
|
24543
|
-
type: "text",
|
|
24544
|
-
text: packagedRoleAcceptedText("collector")
|
|
24545
|
-
}],
|
|
24519
|
+
content: [],
|
|
24546
24520
|
details: params,
|
|
24547
24521
|
terminate: true
|
|
24548
24522
|
};
|
|
@@ -24565,7 +24539,7 @@ init_audit_escalation();
|
|
|
24565
24539
|
init_compliance_transport();
|
|
24566
24540
|
init_submission_errors();
|
|
24567
24541
|
init_dossier_resolution();
|
|
24568
|
-
|
|
24542
|
+
init_readable_gate_item();
|
|
24569
24543
|
init_doctor_contracts();
|
|
24570
24544
|
init_sitian_facade();
|
|
24571
24545
|
var DOCTOR_CASE_FLAG = { name: "ak-doctor-case", definition: { description: "Retained .ak-roles/books/<book>/<n>/runs directory", type: "string" } };
|
|
@@ -24620,22 +24594,22 @@ function createDoctorRoleRuntime(pi, dependencies, host) {
|
|
|
24620
24594
|
}
|
|
24621
24595
|
let audit;
|
|
24622
24596
|
try {
|
|
24623
|
-
audit = await dependencies.auditCompliance(signal === void 0 ? { context: ctx } : { context: ctx, signal });
|
|
24597
|
+
audit = await dependencies.auditCompliance(signal === void 0 ? { context: ctx, submission: testimony } : { context: ctx, signal, submission: testimony });
|
|
24624
24598
|
} catch (error) {
|
|
24625
24599
|
host.failInfrastructure(error, ctx, id);
|
|
24626
24600
|
}
|
|
24627
24601
|
const acceptedDetails = testimony;
|
|
24628
|
-
return disposeComplianceDecision(audit, { pass: (usage) => ({ content: [{ type: "text", text:
|
|
24602
|
+
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) => {
|
|
24629
24603
|
try {
|
|
24630
24604
|
appendCandidate(ctx, { version: 1, testimony, cost: active2.patient.cost, auditNoReceipt, readRecord: active2.store.readRecord(), patientIdentity: active2.patient.identity });
|
|
24631
24605
|
} catch (error) {
|
|
24632
24606
|
host.failInfrastructure(error, ctx, id);
|
|
24633
24607
|
}
|
|
24634
|
-
return { content: [
|
|
24608
|
+
return { content: [], details: acceptedDetails, terminate: true, ...usageProjection };
|
|
24635
24609
|
}, received: () => {
|
|
24636
24610
|
throw new Error("\u5BA1\u5211\u9662\u975E\u4E09\u6001\u5E94\u4EA4 runComplianceAudit \u91CD\u95EE\u8BF4\u8BDD\u8005");
|
|
24637
24611
|
}, bounce: (violations) => {
|
|
24638
|
-
throw new GatekeeperDecisionError({ status: "bounce", officer: "auditor", receipt: violations });
|
|
24612
|
+
throw new GatekeeperDecisionError({ status: "bounce", officer: "auditor", receipt: audit.status === "bounce" ? audit.receipt ?? violations : violations });
|
|
24639
24613
|
}, escalate: (result) => result, transportFailure: (facts) => {
|
|
24640
24614
|
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);
|
|
24641
24615
|
} }, acceptedDetails);
|
|
@@ -24664,7 +24638,6 @@ ${JSON.stringify(catalog)}
|
|
|
24664
24638
|
}
|
|
24665
24639
|
|
|
24666
24640
|
// src/notary-role.ts
|
|
24667
|
-
init_packaged_role_registry();
|
|
24668
24641
|
init_notary_contracts();
|
|
24669
24642
|
function readNotaryTicketFlag(flag) {
|
|
24670
24643
|
if (flag === void 0) return void 0;
|
|
@@ -24743,7 +24716,7 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
|
|
|
24743
24716
|
throw new Error("\u7B26\u5B9D\u90CE\u672A\u6FC0\u6D3B");
|
|
24744
24717
|
}
|
|
24745
24718
|
return {
|
|
24746
|
-
content: [
|
|
24719
|
+
content: [],
|
|
24747
24720
|
details: parameters,
|
|
24748
24721
|
terminate: true
|
|
24749
24722
|
};
|
|
@@ -24974,7 +24947,6 @@ var DIARIST_TOOL_SPEC = {
|
|
|
24974
24947
|
// src/secretariat-role.ts
|
|
24975
24948
|
init_terminating_infrastructure();
|
|
24976
24949
|
init_secretariat_contracts();
|
|
24977
|
-
init_run_terminal_artifacts();
|
|
24978
24950
|
init_secretariat_contracts();
|
|
24979
24951
|
import { Type as Type21 } from "typebox";
|
|
24980
24952
|
var secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
@@ -25002,17 +24974,6 @@ var secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
|
25002
24974
|
)
|
|
25003
24975
|
);
|
|
25004
24976
|
secretariatVerdictSchema.required = [];
|
|
25005
|
-
var secretariatSummonCountersignSchema = Type21.Object(
|
|
25006
|
-
{
|
|
25007
|
-
instruction: Type21.Optional(
|
|
25008
|
-
Type21.String({
|
|
25009
|
-
description: "\u4F20\u53EC\u6563\u6587\uFF1B\u7968\u53F7\u5199\u5728\u5176\u4E2D\u3002\u7A7A\u5219\u6CBF\u7528\u672C\u5C40\u6307\u4EE4\u3002"
|
|
25010
|
-
})
|
|
25011
|
-
)
|
|
25012
|
-
},
|
|
25013
|
-
{ additionalProperties: true }
|
|
25014
|
-
);
|
|
25015
|
-
secretariatSummonCountersignSchema.required = [];
|
|
25016
24977
|
var SECRETARIAT_OUTPUT_TOOL_SPEC = {
|
|
25017
24978
|
name: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
25018
24979
|
label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
|
|
@@ -25020,68 +24981,6 @@ var SECRETARIAT_OUTPUT_TOOL_SPEC = {
|
|
|
25020
24981
|
promptSnippet: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267",
|
|
25021
24982
|
parameters: secretariatVerdictSchema
|
|
25022
24983
|
};
|
|
25023
|
-
var SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC = {
|
|
25024
|
-
name: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME,
|
|
25025
|
-
label: "\u4F20\u53EC\u7ED9\u4E8B\u4E2D",
|
|
25026
|
-
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",
|
|
25027
|
-
promptSnippet: "\u4F20\u53EC\u7ED9\u4E8B\u4E2D",
|
|
25028
|
-
parameters: secretariatSummonCountersignSchema
|
|
25029
|
-
};
|
|
25030
|
-
function latestObjectPayload(payloads) {
|
|
25031
|
-
if (payloads === void 0 || payloads.length === 0) return void 0;
|
|
25032
|
-
const latest = payloads[payloads.length - 1];
|
|
25033
|
-
if (latest === null || typeof latest !== "object" || Array.isArray(latest)) {
|
|
25034
|
-
return void 0;
|
|
25035
|
-
}
|
|
25036
|
-
return latest;
|
|
25037
|
-
}
|
|
25038
|
-
function projectSecretariatSummonResult(summoned) {
|
|
25039
|
-
const terminal = summoned.terminal;
|
|
25040
|
-
const roleOutcome = terminal?.roleOutcome;
|
|
25041
|
-
const runDirectory = summoned.runDirectory;
|
|
25042
|
-
const runId = typeof runDirectory === "string" && runDirectory.trim() !== "" ? runIdFromRunDirectory(runDirectory) : void 0;
|
|
25043
|
-
const base = {
|
|
25044
|
-
exitCode: summoned.exitCode,
|
|
25045
|
-
...runId === void 0 ? {} : { runId },
|
|
25046
|
-
...runDirectory === void 0 ? {} : { runDirectory },
|
|
25047
|
-
...summoned.stderr === void 0 || summoned.stderr === "" ? {} : { stderr: summoned.stderr }
|
|
25048
|
-
};
|
|
25049
|
-
if (roleOutcome === void 0) {
|
|
25050
|
-
return { ...base, outcomeKind: "no_terminal" };
|
|
25051
|
-
}
|
|
25052
|
-
if (roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation") {
|
|
25053
|
-
const payloads = Array.isArray(roleOutcome.payloads) ? roleOutcome.payloads : void 0;
|
|
25054
|
-
const latest = latestObjectPayload(payloads);
|
|
25055
|
-
const countersignStatus = latest !== void 0 && typeof latest.countersignStatus === "string" ? latest.countersignStatus : void 0;
|
|
25056
|
-
return {
|
|
25057
|
-
...base,
|
|
25058
|
-
outcomeKind: roleOutcome.kind,
|
|
25059
|
-
// audit_escalation carries typed status; accepted may carry fixture/compat status.
|
|
25060
|
-
..."status" in roleOutcome && typeof roleOutcome.status === "string" && roleOutcome.status.length > 0 ? { status: roleOutcome.status } : {},
|
|
25061
|
-
...countersignStatus === void 0 ? {} : { countersignStatus },
|
|
25062
|
-
...latest === void 0 ? {} : { receipt: latest },
|
|
25063
|
-
...payloads === void 0 ? {} : { payloads },
|
|
25064
|
-
...roleOutcome.decisiveFacts === void 0 ? {} : { decisiveFacts: roleOutcome.decisiveFacts }
|
|
25065
|
-
};
|
|
25066
|
-
}
|
|
25067
|
-
if (roleOutcome.kind === "failure") {
|
|
25068
|
-
const submissions = Array.isArray(terminal?.submissions) ? terminal.submissions : void 0;
|
|
25069
|
-
return {
|
|
25070
|
-
...base,
|
|
25071
|
-
outcomeKind: "failure",
|
|
25072
|
-
diagnostic: roleOutcome.diagnostic,
|
|
25073
|
-
...roleOutcome.cause === void 0 ? {} : { cause: roleOutcome.cause },
|
|
25074
|
-
...roleOutcome.decisiveFacts === void 0 ? {} : { decisiveFacts: roleOutcome.decisiveFacts },
|
|
25075
|
-
...submissions === void 0 || submissions.length === 0 ? {} : { submissions }
|
|
25076
|
-
};
|
|
25077
|
-
}
|
|
25078
|
-
return {
|
|
25079
|
-
...base,
|
|
25080
|
-
outcomeKind: roleOutcome.kind,
|
|
25081
|
-
..."status" in roleOutcome && typeof roleOutcome.status === "string" && roleOutcome.status.length > 0 ? { status: roleOutcome.status } : {},
|
|
25082
|
-
..."decisiveFacts" in roleOutcome && roleOutcome.decisiveFacts !== void 0 ? { decisiveFacts: roleOutcome.decisiveFacts } : {}
|
|
25083
|
-
};
|
|
25084
|
-
}
|
|
25085
24984
|
|
|
25086
24985
|
// src/role-runtime.ts
|
|
25087
24986
|
init_secretariat_contracts();
|
|
@@ -26101,7 +26000,8 @@ init_audit_escalation();
|
|
|
26101
26000
|
// src/judge-role.ts
|
|
26102
26001
|
init_terminating_infrastructure();
|
|
26103
26002
|
init_submission_errors();
|
|
26104
|
-
|
|
26003
|
+
init_audit_escalation();
|
|
26004
|
+
init_readable_gate_item();
|
|
26105
26005
|
init_judge_output();
|
|
26106
26006
|
import { Type as Type24 } from "typebox";
|
|
26107
26007
|
var JUDGE_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
|
|
@@ -26165,35 +26065,45 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26165
26065
|
if (rawStatus === "escalate") {
|
|
26166
26066
|
const verdict2 = validateVerdict(parameters);
|
|
26167
26067
|
return {
|
|
26168
|
-
content: [
|
|
26068
|
+
content: [],
|
|
26169
26069
|
details: verdict2,
|
|
26170
26070
|
terminate: true
|
|
26171
26071
|
};
|
|
26172
26072
|
}
|
|
26173
26073
|
const verdict = validateVerdict(parameters);
|
|
26174
|
-
|
|
26175
|
-
|
|
26176
|
-
|
|
26177
|
-
|
|
26178
|
-
|
|
26179
|
-
|
|
26180
|
-
|
|
26181
|
-
|
|
26182
|
-
|
|
26183
|
-
|
|
26184
|
-
|
|
26185
|
-
|
|
26186
|
-
|
|
26187
|
-
|
|
26188
|
-
|
|
26189
|
-
|
|
26190
|
-
|
|
26191
|
-
|
|
26192
|
-
|
|
26193
|
-
|
|
26194
|
-
|
|
26195
|
-
|
|
26196
|
-
|
|
26074
|
+
let draftPass;
|
|
26075
|
+
try {
|
|
26076
|
+
const obtainedDraftPass = await pi.requireGatekeeperPass({
|
|
26077
|
+
context: ctx,
|
|
26078
|
+
subject: { kind: "judge_draft" },
|
|
26079
|
+
...signal === void 0 ? {} : { signal },
|
|
26080
|
+
hostActions,
|
|
26081
|
+
toolCallId,
|
|
26082
|
+
// #879: this-turn typed payload — identity-bound at submit site.
|
|
26083
|
+
submission: parameters
|
|
26084
|
+
});
|
|
26085
|
+
draftPass = obtainedDraftPass || void 0;
|
|
26086
|
+
if (draftPass !== void 0) hostActions.bindPriorGatePass(toolCallId, draftPass.receipt);
|
|
26087
|
+
const compliancePass = await pi.requireGatekeeperPass({
|
|
26088
|
+
context: ctx,
|
|
26089
|
+
subject: { kind: "judge_compliance" },
|
|
26090
|
+
...signal === void 0 ? {} : { signal },
|
|
26091
|
+
hostActions,
|
|
26092
|
+
toolCallId,
|
|
26093
|
+
// #879: same parent payload for 审刑院; not recovered from session latest.
|
|
26094
|
+
submission: parameters
|
|
26095
|
+
});
|
|
26096
|
+
return {
|
|
26097
|
+
content: [draftPass, compliancePass].filter((pass) => pass !== void 0).map((pass) => ({ type: "text", text: readableGateItem(pass.receipt) })),
|
|
26098
|
+
details: verdict,
|
|
26099
|
+
terminate: true
|
|
26100
|
+
};
|
|
26101
|
+
} catch (error) {
|
|
26102
|
+
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
26103
|
+
return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, verdict);
|
|
26104
|
+
}
|
|
26105
|
+
throw error;
|
|
26106
|
+
}
|
|
26197
26107
|
}
|
|
26198
26108
|
});
|
|
26199
26109
|
pi.on("before_agent_start", (event) => {
|
|
@@ -26214,7 +26124,6 @@ ${soul}
|
|
|
26214
26124
|
// src/reviewer-role.ts
|
|
26215
26125
|
init_open_tool_schema();
|
|
26216
26126
|
init_terminating_infrastructure();
|
|
26217
|
-
init_packaged_role_registry();
|
|
26218
26127
|
init_reviewer_output();
|
|
26219
26128
|
import { Type as Type25 } from "typebox";
|
|
26220
26129
|
var reviewerAmendmentsSchema = Type25.Object({
|
|
@@ -26267,7 +26176,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26267
26176
|
async execute(_id, parameters) {
|
|
26268
26177
|
if (!soul || !binding) throw new Error("\u5FA1\u53F2\u53F0\u8F93\u5165\u672A\u88C5\u8F7D");
|
|
26269
26178
|
return {
|
|
26270
|
-
content: [
|
|
26179
|
+
content: [],
|
|
26271
26180
|
details: parameters,
|
|
26272
26181
|
terminate: true
|
|
26273
26182
|
};
|
|
@@ -26290,7 +26199,9 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26290
26199
|
init_open_tool_schema();
|
|
26291
26200
|
init_terminating_infrastructure();
|
|
26292
26201
|
init_submission_correctable_error();
|
|
26293
|
-
|
|
26202
|
+
init_readable_gate_item();
|
|
26203
|
+
init_audit_escalation();
|
|
26204
|
+
init_submission_errors();
|
|
26294
26205
|
init_worker_output();
|
|
26295
26206
|
init_fixer_output();
|
|
26296
26207
|
init_fixer_packet();
|
|
@@ -26700,8 +26611,9 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26700
26611
|
ctx,
|
|
26701
26612
|
toolCallId
|
|
26702
26613
|
);
|
|
26703
|
-
|
|
26704
|
-
|
|
26614
|
+
let pass;
|
|
26615
|
+
try {
|
|
26616
|
+
pass = WORKER_DONE_STATUSES.has(workerStatusOf(output)) ? await pi.requireGatekeeperPass({
|
|
26705
26617
|
context: ctx,
|
|
26706
26618
|
subject: { kind: "worker_completion" },
|
|
26707
26619
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
@@ -26709,11 +26621,16 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26709
26621
|
toolCallId,
|
|
26710
26622
|
// #879: this-turn typed payload — identity-bound at submit site.
|
|
26711
26623
|
submission: output
|
|
26712
|
-
});
|
|
26624
|
+
}) : void 0;
|
|
26625
|
+
} catch (error) {
|
|
26626
|
+
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
26627
|
+
return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, output);
|
|
26628
|
+
}
|
|
26629
|
+
throw error;
|
|
26713
26630
|
}
|
|
26714
26631
|
const acceptedDetails = output;
|
|
26715
26632
|
return {
|
|
26716
|
-
content: [{ type: "text", text:
|
|
26633
|
+
content: pass === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
|
|
26717
26634
|
details: acceptedDetails,
|
|
26718
26635
|
terminate: true
|
|
26719
26636
|
};
|
|
@@ -26838,8 +26755,9 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26838
26755
|
ctx2,
|
|
26839
26756
|
toolCallId
|
|
26840
26757
|
);
|
|
26841
|
-
|
|
26842
|
-
|
|
26758
|
+
let pass;
|
|
26759
|
+
try {
|
|
26760
|
+
pass = WORKER_DONE_STATUSES.has(workerStatusOf(output)) ? await pi.requireGatekeeperPass({
|
|
26843
26761
|
context: ctx2,
|
|
26844
26762
|
subject: { kind: "worker_completion" },
|
|
26845
26763
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
@@ -26847,11 +26765,16 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26847
26765
|
toolCallId,
|
|
26848
26766
|
// #879: this-turn typed payload — identity-bound at submit site.
|
|
26849
26767
|
submission: output
|
|
26850
|
-
});
|
|
26768
|
+
}) : void 0;
|
|
26769
|
+
} catch (error) {
|
|
26770
|
+
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
26771
|
+
return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, output);
|
|
26772
|
+
}
|
|
26773
|
+
throw error;
|
|
26851
26774
|
}
|
|
26852
26775
|
const acceptedDetails = output;
|
|
26853
26776
|
return {
|
|
26854
|
-
content: [{ type: "text", text:
|
|
26777
|
+
content: pass === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
|
|
26855
26778
|
details: acceptedDetails,
|
|
26856
26779
|
terminate: true
|
|
26857
26780
|
};
|
|
@@ -26910,7 +26833,6 @@ init_doctor_contracts();
|
|
|
26910
26833
|
init_merger_contracts();
|
|
26911
26834
|
|
|
26912
26835
|
// src/merger-role.ts
|
|
26913
|
-
init_packaged_role_registry();
|
|
26914
26836
|
init_merger_contracts();
|
|
26915
26837
|
init_exact_utf8();
|
|
26916
26838
|
var MERGER_INPUT_FLAG = { name: "ak-merger-input", definition: { description: "Path to Merger assignment materials JSON", type: "string" } };
|
|
@@ -26939,7 +26861,7 @@ function createMergerRoleRuntime(pi, dependencies) {
|
|
|
26939
26861
|
parameters: mergerOutputSchema,
|
|
26940
26862
|
async execute(_id, params, _signal, _update, _ctx) {
|
|
26941
26863
|
if (!activation) throw new Error("\u6821\u4E66\u90CE\u672A\u6FC0\u6D3B");
|
|
26942
|
-
return { content: [
|
|
26864
|
+
return { content: [], details: params, terminate: true };
|
|
26943
26865
|
}
|
|
26944
26866
|
});
|
|
26945
26867
|
pi.on("before_agent_start", (event) => {
|
|
@@ -26991,6 +26913,7 @@ function createPiDoctorAuditor() {
|
|
|
26991
26913
|
return runComplianceAudit({
|
|
26992
26914
|
subject: "doctor",
|
|
26993
26915
|
context: options.context,
|
|
26916
|
+
submission: options.submission,
|
|
26994
26917
|
...auditorRunDirectory(options.context) === void 0 ? {} : { runDirectory: auditorRunDirectory(options.context) },
|
|
26995
26918
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
26996
26919
|
...options.summonAuditor === void 0 ? {} : { summonAuditor: options.summonAuditor }
|
|
@@ -27253,9 +27176,13 @@ function createFiledOfficerRuntime(roleHost, spec, dependencies) {
|
|
|
27253
27176
|
async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
|
|
27254
27177
|
if (soul === void 0) throw new Error(`${spec.role} \u804C\u5206\u672A\u88C5\u8F7D`);
|
|
27255
27178
|
const projected = spec.beforeAccept === void 0 ? void 0 : await spec.beforeAccept({ toolCallId, parameters, signal, ctx });
|
|
27179
|
+
if (isAuditEscalationProjection(projected)) {
|
|
27180
|
+
return { content: [], details: projected, terminate: true };
|
|
27181
|
+
}
|
|
27182
|
+
const pass = spec.relayGatePass === true && projected !== null && typeof projected === "object" && "officer" in projected && "receipt" in projected ? projected : void 0;
|
|
27256
27183
|
return {
|
|
27257
|
-
content: [{ type: "text", text:
|
|
27258
|
-
details: projected === void 0 ? parameters : projected,
|
|
27184
|
+
content: pass === void 0 || pass.receipt === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
|
|
27185
|
+
details: pass === void 0 ? projected === void 0 ? parameters : projected : parameters,
|
|
27259
27186
|
terminate: true
|
|
27260
27187
|
};
|
|
27261
27188
|
}
|
|
@@ -27445,18 +27372,12 @@ ${error.message}`
|
|
|
27445
27372
|
}
|
|
27446
27373
|
var COUNTERSIGN_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
|
|
27447
27374
|
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";
|
|
27448
|
-
var SECRETARIAT_SUBMISSION_GATE_HOSTS = /* @__PURE__ */ new Set(["codex", "claude", "grok-build"]);
|
|
27449
27375
|
var SECRETARIAT_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "escalate"]);
|
|
27450
27376
|
var SECRETARIAT_STATUS_REASK = "secretariatStatus \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
|
27451
27377
|
function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
|
|
27452
|
-
let parentInstruction = "";
|
|
27453
27378
|
const beforeAccept = hostActions !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
|
|
27454
|
-
const host = typeof ctx.host === "string" && ctx.host.trim() !== "" ? ctx.host.trim() : void 0;
|
|
27455
|
-
if (host === void 0 || !SECRETARIAT_SUBMISSION_GATE_HOSTS.has(host)) {
|
|
27456
|
-
return void 0;
|
|
27457
|
-
}
|
|
27458
27379
|
if (roleHost.requireGatekeeperPass === void 0) {
|
|
27459
|
-
const error = new Error(
|
|
27380
|
+
const error = new Error("host cannot mount the secretariat submission gate");
|
|
27460
27381
|
error.name = "InfrastructureFailure";
|
|
27461
27382
|
return hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
27462
27383
|
}
|
|
@@ -27489,7 +27410,7 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
|
|
|
27489
27410
|
...runId === void 0 ? {} : { runId }
|
|
27490
27411
|
});
|
|
27491
27412
|
}
|
|
27492
|
-
return
|
|
27413
|
+
return pass;
|
|
27493
27414
|
} catch (error) {
|
|
27494
27415
|
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
27495
27416
|
const receipt = error.result.receipt;
|
|
@@ -27520,80 +27441,17 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
|
|
|
27520
27441
|
roleHost,
|
|
27521
27442
|
{
|
|
27522
27443
|
role: "secretariat",
|
|
27444
|
+
relayGatePass: true,
|
|
27523
27445
|
tool: SECRETARIAT_OUTPUT_TOOL_SPEC,
|
|
27524
27446
|
soulTag: "secretariat",
|
|
27525
27447
|
...beforeAccept === void 0 ? {} : { beforeAccept }
|
|
27526
27448
|
},
|
|
27527
27449
|
dependencies
|
|
27528
27450
|
);
|
|
27529
|
-
let summonRegistered = false;
|
|
27530
27451
|
return {
|
|
27531
27452
|
async activate() {
|
|
27532
27453
|
await base.activate();
|
|
27533
|
-
|
|
27534
|
-
summonRegistered = true;
|
|
27535
|
-
roleHost.on("before_agent_start", (event) => {
|
|
27536
|
-
if (typeof event.prompt === "string" && event.prompt.trim() !== "") {
|
|
27537
|
-
parentInstruction = event.prompt;
|
|
27538
|
-
}
|
|
27539
|
-
});
|
|
27540
|
-
roleHost.registerTool({
|
|
27541
|
-
name: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME,
|
|
27542
|
-
label: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC.label,
|
|
27543
|
-
description: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC.description,
|
|
27544
|
-
promptSnippet: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC.promptSnippet,
|
|
27545
|
-
parameters: SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_SPEC.parameters,
|
|
27546
|
-
async execute(_toolCallId, parameters, signal, _onUpdate, ctx) {
|
|
27547
|
-
const fromArgs = typeof parameters?.instruction === "string" ? parameters.instruction.trim() : "";
|
|
27548
|
-
const instruction = fromArgs !== "" ? fromArgs : parentInstruction.trim();
|
|
27549
|
-
const correlationId = (() => {
|
|
27550
|
-
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
27551
|
-
if (runDirectory === void 0) return void 0;
|
|
27552
|
-
return runIdFromRunDirectory(runDirectory);
|
|
27553
|
-
})();
|
|
27554
|
-
const summon = dependencies.summonCountersign;
|
|
27555
|
-
const summoned = summon === void 0 ? await (async () => {
|
|
27556
|
-
const coordinates = readRoleRunCoordinates(ctx, "secretariat summons");
|
|
27557
|
-
const { summonPublicRole: summonPublicRole2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
27558
|
-
const { readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
|
|
27559
|
-
const parentTicket = await readBoardTicketNumber2(coordinates.runDirectory);
|
|
27560
|
-
return summonPublicRole2({
|
|
27561
|
-
role: "countersign",
|
|
27562
|
-
argv: ["--project", coordinates.projectRoot, "--", instruction],
|
|
27563
|
-
cwd: coordinates.projectRoot,
|
|
27564
|
-
home: coordinates.home,
|
|
27565
|
-
parentRunPath: coordinates.runDirectory,
|
|
27566
|
-
...parentTicket === void 0 ? {} : { boundTicketNumber: parentTicket },
|
|
27567
|
-
...signal === void 0 ? {} : { signal },
|
|
27568
|
-
...correlationId === void 0 ? {} : { correlationId },
|
|
27569
|
-
...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot },
|
|
27570
|
-
...dependencies.hostAdapters === void 0 ? {} : { hostAdapters: dependencies.hostAdapters }
|
|
27571
|
-
});
|
|
27572
|
-
})() : await summon({
|
|
27573
|
-
instruction,
|
|
27574
|
-
cwd: ctx.cwd,
|
|
27575
|
-
...signal === void 0 ? {} : { signal },
|
|
27576
|
-
...correlationId === void 0 ? {} : { correlationId },
|
|
27577
|
-
...dependencies.home === void 0 ? {} : { home: dependencies.home },
|
|
27578
|
-
...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot }
|
|
27579
|
-
});
|
|
27580
|
-
const details = projectSecretariatSummonResult(summoned);
|
|
27581
|
-
return {
|
|
27582
|
-
content: [
|
|
27583
|
-
{
|
|
27584
|
-
type: "text",
|
|
27585
|
-
text: readableGateItem(details)
|
|
27586
|
-
}
|
|
27587
|
-
],
|
|
27588
|
-
details
|
|
27589
|
-
};
|
|
27590
|
-
}
|
|
27591
|
-
});
|
|
27592
|
-
}
|
|
27593
|
-
const packageRequired = [
|
|
27594
|
-
SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
27595
|
-
SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME
|
|
27596
|
-
];
|
|
27454
|
+
const packageRequired = [SECRETARIAT_OUTPUT_TOOL_NAME];
|
|
27597
27455
|
const all = roleHost.getAllTools().map((tool) => tool.name);
|
|
27598
27456
|
for (const name of packageRequired) {
|
|
27599
27457
|
if (all.filter((item) => item === name).length !== 1) {
|
|
@@ -27631,20 +27489,29 @@ function createCountersignRoleRuntime(roleHost, dependencies, hostActions) {
|
|
|
27631
27489
|
error.name = "InfrastructureFailure";
|
|
27632
27490
|
return hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
27633
27491
|
}
|
|
27634
|
-
|
|
27635
|
-
|
|
27636
|
-
|
|
27637
|
-
|
|
27638
|
-
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
|
|
27642
|
-
|
|
27492
|
+
try {
|
|
27493
|
+
return await roleHost.requireGatekeeperPass({
|
|
27494
|
+
context: ctx,
|
|
27495
|
+
subject: { kind: "countersign_verdict" },
|
|
27496
|
+
...signal === void 0 ? {} : { signal },
|
|
27497
|
+
hostActions,
|
|
27498
|
+
toolCallId,
|
|
27499
|
+
// #879: this-turn typed payload — identity-bound at submit site.
|
|
27500
|
+
submission: parameters
|
|
27501
|
+
});
|
|
27502
|
+
} catch (error) {
|
|
27503
|
+
if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
|
|
27504
|
+
const { buildAuditEscalationResult: buildAuditEscalationResult2 } = await Promise.resolve().then(() => (init_audit_escalation(), audit_escalation_exports));
|
|
27505
|
+
return buildAuditEscalationResult2({ status: "escalate", officer: "notary", conflicts: error.result.receipt }, parameters);
|
|
27506
|
+
}
|
|
27507
|
+
throw error;
|
|
27508
|
+
}
|
|
27643
27509
|
} : void 0;
|
|
27644
27510
|
return createFiledOfficerRuntime(
|
|
27645
27511
|
roleHost,
|
|
27646
27512
|
{
|
|
27647
27513
|
role: "countersign",
|
|
27514
|
+
relayGatePass: true,
|
|
27648
27515
|
tool: COUNTERSIGN_TOOL_SPEC,
|
|
27649
27516
|
soulTag: "countersign",
|
|
27650
27517
|
...beforeAccept === void 0 ? {} : { beforeAccept }
|
|
@@ -27715,6 +27582,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27715
27582
|
let navigatorCwd;
|
|
27716
27583
|
const pendingInfrastructureFailures = /* @__PURE__ */ new Map();
|
|
27717
27584
|
const pendingSubmissionNonPassByToolCallId = /* @__PURE__ */ new Map();
|
|
27585
|
+
const pendingPriorGatePassByToolCallId = /* @__PURE__ */ new Map();
|
|
27718
27586
|
let engineDetourRegistered = false;
|
|
27719
27587
|
let receiptDelivery = createReceiptDeliveryPolicy();
|
|
27720
27588
|
let noReceiptRecorded = false;
|
|
@@ -27909,6 +27777,9 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27909
27777
|
return { readingMaterial: caseDossier };
|
|
27910
27778
|
});
|
|
27911
27779
|
roleHost.on("tool_result", async (event) => {
|
|
27780
|
+
const priorGatePass = pendingPriorGatePassByToolCallId.get(event.toolCallId);
|
|
27781
|
+
pendingPriorGatePassByToolCallId.delete(event.toolCallId);
|
|
27782
|
+
const priorPassContent = priorGatePass !== void 0 && event.isError ? [{ type: "text", text: readableGateItem(priorGatePass) }, ...event.content ?? []] : void 0;
|
|
27912
27783
|
const role = selectedRole;
|
|
27913
27784
|
if (role === void 0) return;
|
|
27914
27785
|
if (activeCollector !== void 0 && selectedRole === roleHost.getFlag(ROLE_FLAG.name)) {
|
|
@@ -27930,13 +27801,14 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27930
27801
|
const settlement = isRoleInfrastructureFailure || outputClassification?.kind === "infrastructure" ? publicNavigatorSettlement(role, navigatorPhase(roleHost, role), classified) : void 0;
|
|
27931
27802
|
await settleNavigatorProjection(settlement);
|
|
27932
27803
|
if (infrastructureDetails !== void 0) {
|
|
27933
|
-
return { isError: true };
|
|
27804
|
+
return { isError: true, ...priorPassContent === void 0 ? {} : { content: priorPassContent } };
|
|
27934
27805
|
}
|
|
27935
27806
|
const submissionNonPass = pendingSubmissionNonPassByToolCallId.get(event.toolCallId);
|
|
27936
27807
|
if (submissionNonPass !== void 0) {
|
|
27937
27808
|
pendingSubmissionNonPassByToolCallId.delete(event.toolCallId);
|
|
27938
|
-
return { details: submissionNonPass, isError: true };
|
|
27809
|
+
return { details: submissionNonPass, isError: true, ...priorPassContent === void 0 ? {} : { content: priorPassContent } };
|
|
27939
27810
|
}
|
|
27811
|
+
if (priorPassContent !== void 0) return { content: priorPassContent, isError: true };
|
|
27940
27812
|
});
|
|
27941
27813
|
roleHost.on("agent_end", async (event, ctx) => {
|
|
27942
27814
|
const lastMessage = event.messages.at(-1);
|
|
@@ -28072,6 +27944,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28072
27944
|
disposeNavigatorAttendanceNonBlocking(attendanceToDispose);
|
|
28073
27945
|
pendingInfrastructureFailures.clear();
|
|
28074
27946
|
pendingSubmissionNonPassByToolCallId.clear();
|
|
27947
|
+
pendingPriorGatePassByToolCallId.clear();
|
|
28075
27948
|
observationFace.reset();
|
|
28076
27949
|
});
|
|
28077
27950
|
const hostActions = {
|
|
@@ -28083,6 +27956,9 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28083
27956
|
},
|
|
28084
27957
|
bindSubmissionNonPass(toolCallId, result) {
|
|
28085
27958
|
pendingSubmissionNonPassByToolCallId.set(toolCallId, result);
|
|
27959
|
+
},
|
|
27960
|
+
bindPriorGatePass(toolCallId, receipt) {
|
|
27961
|
+
pendingPriorGatePassByToolCallId.set(toolCallId, receipt);
|
|
28086
27962
|
}
|
|
28087
27963
|
};
|
|
28088
27964
|
const requireRoleSoul = (role) => dependencies.loadRoleSoul(role);
|
|
@@ -28184,9 +28060,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28184
28060
|
}
|
|
28185
28061
|
);
|
|
28186
28062
|
const secretariat = createSecretariatRoleRuntime(roleHost, {
|
|
28187
|
-
loadSoul: () => requireRoleSoul("secretariat")
|
|
28188
|
-
...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot },
|
|
28189
|
-
...dependencies.hostAdapters === void 0 ? {} : { hostAdapters: dependencies.hostAdapters }
|
|
28063
|
+
loadSoul: () => requireRoleSoul("secretariat")
|
|
28190
28064
|
}, hostActions);
|
|
28191
28065
|
const merger = createMergerRoleRuntime(roleHost, {
|
|
28192
28066
|
loadSoul: () => requireRoleSoul("merger"),
|
|
@@ -28377,6 +28251,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28377
28251
|
pendingNavigatorSettlement = void 0;
|
|
28378
28252
|
pendingInfrastructureFailures.clear();
|
|
28379
28253
|
pendingSubmissionNonPassByToolCallId.clear();
|
|
28254
|
+
pendingPriorGatePassByToolCallId.clear();
|
|
28380
28255
|
navigatorWorkContext = void 0;
|
|
28381
28256
|
envelopeHost.startKeepalive(ctx);
|
|
28382
28257
|
const rawRole = roleHost.getFlag(ROLE_FLAG.name);
|