@akagilnc/pi-workflow-roles 0.1.5375 → 0.1.5406
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 +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/acp-host/production-host.js +6381 -5684
- package/dist/archivist-record-pointer.js +38 -0
- package/dist/collector-tool-schemas.js +18 -0
- package/dist/compliance-transport.js +5 -0
- package/dist/diarist-contracts.js +26 -0
- package/dist/doctor-auditor.js +1 -0
- package/dist/engine-detour-usage.js +6 -6
- package/dist/filed-submission.js +28 -0
- package/dist/gatekeeper-role.js +6 -10
- package/dist/gleaner-left-contracts.js +16 -0
- package/dist/headless-host/production-host.js +1644 -947
- package/dist/judge-role.js +21 -16
- package/dist/migrate-book-topology.js +452 -81
- package/dist/navigator-attendance.js +10 -9
- package/dist/navigator-invocation-identity.js +18 -0
- package/dist/package-contracts/reviewer-output.js +16 -0
- package/dist/package-contracts/worker-output.js +18 -2
- package/dist/pi/role-turn-host.js +9 -0
- package/dist/public-cli/cli.js +1 -0
- package/dist/public-cli/instruction-seat-run.js +258 -55
- package/dist/public-cli/main.js +1209 -346
- package/dist/public-cli/post-admission.js +427 -244
- package/dist/public-cli/settlement.js +111 -48
- package/dist/public-cli/terminal.js +12 -1
- package/dist/public-cli/turn-request.js +3 -0
- package/dist/receipt-delivery-policy.js +152 -17
- package/dist/role-submission-declarations.js +131 -0
- package/dist/secretariat-contracts.js +23 -1
- package/dist/submission-errors.js +11 -1
- package/dist/submission-gate.js +32 -12
- package/package.json +1 -1
- package/src/archivist-record-pointer.ts +48 -0
- package/src/auditor-role.ts +2 -8
- package/src/collector-role.ts +5 -28
- package/src/compliance-transport.ts +10 -2
- package/src/countersign-role.ts +2 -7
- package/src/diarist-contracts.ts +37 -0
- package/src/diarist-role.ts +4 -44
- package/src/doctor-auditor.ts +3 -0
- package/src/doctor-role.ts +16 -11
- package/src/engine-detour-usage.ts +7 -6
- package/src/external-host-turn-loop.ts +24 -12
- package/src/filed-submission.ts +44 -0
- package/src/gatekeeper-role.ts +8 -16
- package/src/gleaner-left-contracts.ts +26 -1
- package/src/gleaner-left-role.ts +4 -32
- package/src/host-contracts.ts +7 -0
- package/src/inspector-role.ts +2 -7
- package/src/judge-role.ts +31 -24
- package/src/merger-role.ts +5 -8
- package/src/navigator-attendance.ts +17 -12
- package/src/navigator-invocation-identity.ts +31 -0
- package/src/navigator-role.ts +2 -8
- package/src/notary-role.ts +5 -20
- package/src/package-contracts/reviewer-output.ts +25 -0
- package/src/package-contracts/worker-output.ts +43 -5
- package/src/pi/adapter.ts +33 -8
- package/src/pi/role-turn-host.ts +7 -0
- package/src/public-cli/cli.ts +1 -0
- package/src/public-cli/instruction-seat-run.ts +292 -61
- package/src/public-cli/post-admission.ts +556 -324
- package/src/public-cli/settlement.ts +112 -50
- package/src/public-cli/terminal.ts +16 -4
- package/src/public-cli/turn-request.ts +10 -1
- package/src/receipt-delivery-policy.ts +209 -17
- package/src/reviewer-role.ts +7 -35
- package/src/role-envelope.ts +5 -1
- package/src/role-runtime-dependencies.ts +1 -0
- package/src/role-runtime.ts +72 -56
- package/src/role-submission-declarations.ts +143 -0
- package/src/secretariat-contracts.ts +35 -0
- package/src/secretariat-role.ts +4 -40
- package/src/submission-correctable-error.ts +5 -2
- package/src/submission-errors.ts +12 -1
- package/src/submission-gate.ts +41 -12
- package/src/worker-role.ts +81 -86
- package/src/worker-submission-gates.ts +32 -7
|
@@ -31,7 +31,10 @@ import {
|
|
|
31
31
|
} from "./navigator-session-contracts.js";
|
|
32
32
|
import { sitianReport } from "./sitian-facade.js";
|
|
33
33
|
import { issueRoot, subjectPath } from "./work-subject-identity.js";
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
createReceiptDeliveryPolicy,
|
|
36
|
+
NO_RECEIPT_LIFECYCLE_ENTRY_TYPE
|
|
37
|
+
} from "./receipt-delivery-policy.js";
|
|
35
38
|
import { navigatorProseFromUnknown } from "./package-contracts/navigator-output.js";
|
|
36
39
|
import { persistNavigatorWorkBase } from "./navigator-work-base.js";
|
|
37
40
|
import { sha256Hex } from "./sha256.js";
|
|
@@ -250,8 +253,8 @@ function createNavigatorAttendance(options) {
|
|
|
250
253
|
try {
|
|
251
254
|
try {
|
|
252
255
|
if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
|
|
253
|
-
const delivery = createReceiptDeliveryPolicy();
|
|
254
|
-
const promptAllowingRejectedPrepare = async (text
|
|
256
|
+
const delivery = createReceiptDeliveryPolicy(options.deliveryRequestLimit);
|
|
257
|
+
const promptAllowingRejectedPrepare = async (text) => {
|
|
255
258
|
await persistNavigatorWorkBase(activeSession.recordPointer(), { subject, authority });
|
|
256
259
|
const entryStart = activeSession.entries().length;
|
|
257
260
|
prepareBatchRejected = false;
|
|
@@ -278,17 +281,15 @@ function createNavigatorAttendance(options) {
|
|
|
278
281
|
delivery.recordNestedNoReceipt(sessionNoReceipt);
|
|
279
282
|
return;
|
|
280
283
|
}
|
|
281
|
-
if (deliveryRequest && output === void 0) delivery.recordDeliveryRequest();
|
|
282
284
|
};
|
|
283
|
-
await promptAllowingRejectedPrepare(request
|
|
285
|
+
await promptAllowingRejectedPrepare(request);
|
|
284
286
|
if (boundSettlement !== void 0) {
|
|
285
287
|
while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
|
|
286
|
-
|
|
288
|
+
delivery.recordDeliveryRequest();
|
|
289
|
+
await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()));
|
|
287
290
|
}
|
|
288
291
|
if (output === void 0 && delivery.nextAction() === "request-delivery") {
|
|
289
|
-
|
|
290
|
-
delivery.recordDeliveryRequest();
|
|
291
|
-
}
|
|
292
|
+
delivery.closeBudget();
|
|
292
293
|
}
|
|
293
294
|
if (output === void 0 && delivery.nextAction() === "no-receipt" && activeSession.providerFailure?.() === void 0) {
|
|
294
295
|
const facts = delivery.facts({ runPointer: activeSession.recordPointer(), attemptPointer: invocationId });
|
|
@@ -86,6 +86,23 @@ function markerMatchesExpectedIdentity(marker, expected) {
|
|
|
86
86
|
}
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
89
|
+
function packagedRoleOutputRejectionReason(message) {
|
|
90
|
+
if (typeof message.toolName !== "string") return void 0;
|
|
91
|
+
if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName) && message.toolName !== "ak_submission_output") {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
if (message.isError !== true) return void 0;
|
|
95
|
+
if (classifyPackagedRoleTerminalResult(message).kind !== "nonterminal") return void 0;
|
|
96
|
+
const content = message.content;
|
|
97
|
+
if (typeof content === "string") return content.trim();
|
|
98
|
+
if (!Array.isArray(content)) return "";
|
|
99
|
+
return content.map((part) => {
|
|
100
|
+
if (isRecord(part) && part.type === "text" && typeof part.text === "string") {
|
|
101
|
+
return part.text;
|
|
102
|
+
}
|
|
103
|
+
return "";
|
|
104
|
+
}).join("").trim();
|
|
105
|
+
}
|
|
89
106
|
function classifyPackagedRoleTerminalResult(message) {
|
|
90
107
|
if (typeof message.toolName !== "string") return { kind: "nonterminal" };
|
|
91
108
|
if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName) && message.toolName !== "ak_submission_output") return { kind: "nonterminal" };
|
|
@@ -181,6 +198,7 @@ export {
|
|
|
181
198
|
isNavigatorInfrastructureFailureFact,
|
|
182
199
|
markerMatchesExpectedIdentity,
|
|
183
200
|
mintNavigatorInvocationId,
|
|
201
|
+
packagedRoleOutputRejectionReason,
|
|
184
202
|
parseInvocationMarkerIdentity,
|
|
185
203
|
resolveLifecycleInvocationPrincipal
|
|
186
204
|
};
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { openToolObject } from "../open-tool-schema.js";
|
|
3
|
+
import { withTerminatingOutputDeclarations } from "./terminating-infrastructure.js";
|
|
1
4
|
const REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
|
|
5
|
+
const REVIEWER_AMENDMENTS_DESCRIPTION = "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\uFF08completeness / correctness\uFF09\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002";
|
|
6
|
+
const REVIEWER_STATUS_DESCRIPTION = "completed | refused\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
|
|
7
|
+
const reviewerOutputObject = Type.Object({
|
|
8
|
+
status: Type.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
|
|
9
|
+
amendments: Type.Unknown({ description: REVIEWER_AMENDMENTS_DESCRIPTION }),
|
|
10
|
+
diagnostic: Type.Unknown({
|
|
11
|
+
description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E\uFF1Bhard-stop\uFF0Fusage error \u539F\u56E0\u8FDB\u6B64\u5B57\u6BB5\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u53E6\u7167\u5F55 amendments"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
const reviewerOutputSchema = withTerminatingOutputDeclarations(
|
|
15
|
+
openToolObject(reviewerOutputObject)
|
|
16
|
+
);
|
|
2
17
|
function validateReviewerIntent(output) {
|
|
3
18
|
return output;
|
|
4
19
|
}
|
|
5
20
|
export {
|
|
6
21
|
REVIEWER_OUTPUT_TOOL_NAME,
|
|
22
|
+
reviewerOutputSchema,
|
|
7
23
|
validateReviewerIntent
|
|
8
24
|
};
|
|
@@ -1,20 +1,36 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { openToolObject } from "../open-tool-schema.js";
|
|
1
3
|
import {
|
|
2
4
|
FIXER_OUTPUT_TOOL_NAME,
|
|
3
5
|
fixerOutputSchema,
|
|
6
|
+
PARTIALLY_COMPLETED_DEFINITION,
|
|
4
7
|
validateFixerOutput
|
|
5
8
|
} from "./fixer-output.js";
|
|
6
9
|
import { fixerPrerequisiteSchema, fixerPrerequisitesSchema, parseFixerPrerequisites, validateFixerPrerequisites } from "./fixer-packet.js";
|
|
7
|
-
import {
|
|
10
|
+
import { withTerminatingOutputDeclarations } from "./terminating-infrastructure.js";
|
|
8
11
|
const CODER_OUTPUT_TOOL_NAME = "ak_coder_output";
|
|
9
12
|
function validateAcceptedCoderDetails(output) {
|
|
10
13
|
return output;
|
|
11
14
|
}
|
|
12
15
|
function validateAcceptedWorkerDetails(output, roleLabel = "Coder") {
|
|
13
|
-
return roleLabel === "Fixer" ?
|
|
16
|
+
return roleLabel === "Fixer" ? validateFixerOutput(output) : validateAcceptedCoderDetails(output);
|
|
14
17
|
}
|
|
18
|
+
const CODER_STATUS_DESCRIPTION = `planned | completed | refused | partially_completed | unfinished\u3002unfinished\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u3002${PARTIALLY_COMPLETED_DEFINITION}`;
|
|
19
|
+
const coderOutputObject = Type.Object({
|
|
20
|
+
status: Type.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
21
|
+
report: Type.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
22
|
+
remainingScope: Type.Unknown({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
|
|
23
|
+
reason: Type.Unknown({
|
|
24
|
+
description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002"
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
const coderOutputSchema = withTerminatingOutputDeclarations(
|
|
28
|
+
openToolObject(coderOutputObject)
|
|
29
|
+
);
|
|
15
30
|
export {
|
|
16
31
|
CODER_OUTPUT_TOOL_NAME,
|
|
17
32
|
FIXER_OUTPUT_TOOL_NAME,
|
|
33
|
+
coderOutputSchema,
|
|
18
34
|
fixerOutputSchema,
|
|
19
35
|
fixerPrerequisiteSchema,
|
|
20
36
|
fixerPrerequisitesSchema,
|
|
@@ -14,6 +14,7 @@ import { ExplicitInternalActivationError } from "../host-contracts.js";
|
|
|
14
14
|
import { applyEngineChildEnv, ENGINE_MODEL_FLAG_NAME, normalizeEngineName } from "../engine-detour.js";
|
|
15
15
|
import { projectActivationFlags } from "../role-activation-flags.js";
|
|
16
16
|
import { encodeUserDialogueStdin } from "../user-dialogue-stdin.js";
|
|
17
|
+
import { RECEIPT_DELIVERY_LIMIT_ENV } from "../receipt-delivery-policy.js";
|
|
17
18
|
/** Package-relative Internal role entrypoint (ADR 0052; same path as public-cli registry). */
|
|
18
19
|
const INTERNAL_ROLE_ENTRYPOINT_RELATIVE = "extensions/role-runtime.ts";
|
|
19
20
|
export function resolveInternalRoleEntrypoint(packageRoot) {
|
|
@@ -307,6 +308,14 @@ export function createPiRoleTurnHost(config) {
|
|
|
307
308
|
delete env.AK_ROLE_HOST;
|
|
308
309
|
else
|
|
309
310
|
env.AK_ROLE_HOST = request.host.trim();
|
|
311
|
+
// #1132: the one effective delivery-request ceiling travels to the child
|
|
312
|
+
// on its own env so the in-child role runtime and the worker submission
|
|
313
|
+
// gate count with the same configured number the AK seam resolved. Omit
|
|
314
|
+
// must not inherit a parent value (same rule as the other AK_ROLE_ axes).
|
|
315
|
+
if (request.deliveryRequestLimit === undefined)
|
|
316
|
+
delete env[RECEIPT_DELIVERY_LIMIT_ENV];
|
|
317
|
+
else
|
|
318
|
+
env[RECEIPT_DELIVERY_LIMIT_ENV] = String(request.deliveryRequestLimit);
|
|
310
319
|
applyEngineChildEnv(env, request.engine);
|
|
311
320
|
// Nested auditor dossier tool binds the parent run pointer when published.
|
|
312
321
|
if (typeof process.env.AK_ROLE_AUDITOR_SOURCE_RUN === "string"
|
package/dist/public-cli/cli.js
CHANGED
|
@@ -846,6 +846,7 @@ export async function runAkRole(argv, env) {
|
|
|
846
846
|
let current = result;
|
|
847
847
|
while (current.exitCode === 0 && current.admitted?.correlationId !== undefined
|
|
848
848
|
&& current.terminal?.roleOutcome.kind === "accepted"
|
|
849
|
+
&& current.terminal.roleOutcome.decisiveFacts?.directionUnsettled !== true
|
|
849
850
|
&& !latestPayloadEscalated(current.terminal.roleOutcome)) {
|
|
850
851
|
const parentRunId = current.admitted.correlationId;
|
|
851
852
|
resumeFailureContext = {
|