@akagilnc/pi-workflow-roles 0.1.5375 → 0.1.5382
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +479 -425
- package/dist/collector-tool-schemas.js +18 -0
- package/dist/diarist-contracts.js +26 -0
- 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 +495 -441
- package/dist/judge-role.js +8 -16
- package/dist/migrate-book-topology.js +262 -7
- package/dist/package-contracts/reviewer-output.js +16 -0
- package/dist/package-contracts/worker-output.js +18 -2
- package/dist/public-cli/instruction-seat-run.js +9 -12
- package/dist/public-cli/main.js +283 -26
- package/dist/role-submission-declarations.js +131 -0
- package/dist/secretariat-contracts.js +23 -1
- package/dist/submission-gate.js +5 -8
- package/package.json +1 -1
- package/src/auditor-role.ts +2 -8
- package/src/collector-role.ts +5 -28
- package/src/countersign-role.ts +2 -7
- package/src/diarist-contracts.ts +37 -0
- package/src/diarist-role.ts +4 -44
- package/src/doctor-role.ts +16 -11
- package/src/filed-submission.ts +44 -0
- package/src/gatekeeper-role.ts +6 -14
- package/src/gleaner-left-contracts.ts +26 -1
- package/src/gleaner-left-role.ts +4 -32
- package/src/inspector-role.ts +2 -7
- package/src/judge-role.ts +12 -24
- package/src/merger-role.ts +5 -8
- 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/public-cli/instruction-seat-run.ts +10 -13
- package/src/reviewer-role.ts +7 -35
- package/src/role-runtime.ts +7 -35
- 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-gate.ts +8 -9
- package/src/worker-role.ts +62 -79
- package/src/worker-submission-gates.ts +3 -0
package/src/worker-role.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import type { RoleHost, HostContext,
|
|
2
|
-
import { Type, type Static } from "typebox";
|
|
3
|
-
import { openToolObject } from "./open-tool-schema.ts";
|
|
4
|
-
import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.ts";
|
|
1
|
+
import type { RoleHost, HostContext, HostGatekeeperActions } from "./host-contracts.ts";
|
|
5
2
|
|
|
6
3
|
import {
|
|
7
|
-
CODER_OUTPUT_TOOL_NAME,
|
|
8
|
-
FIXER_OUTPUT_TOOL_NAME,
|
|
9
4
|
validateAcceptedWorkerDetails,
|
|
10
5
|
type CoderOutput,
|
|
11
6
|
type FixerOutput,
|
|
12
7
|
type WorkerOutput,
|
|
13
8
|
type WorkerRoleLabel,
|
|
14
9
|
} from "./package-contracts/worker-output.ts";
|
|
15
|
-
import {
|
|
10
|
+
import { validateFixerOutput, type FixerPhase } from "./package-contracts/fixer-output.ts";
|
|
11
|
+
import { registerFiledSubmissionTool } from "./filed-submission.ts";
|
|
12
|
+
import { roleSubmissionDeclaration } from "./role-submission-declarations.ts";
|
|
16
13
|
import {
|
|
17
14
|
FixerPacketValidationError,
|
|
18
15
|
parseFixerPrerequisites,
|
|
@@ -23,6 +20,7 @@ import {
|
|
|
23
20
|
WorkerCommitReminderError,
|
|
24
21
|
WorkerPrefixReminderError,
|
|
25
22
|
WorkerUnfinishedReasonReminderError,
|
|
23
|
+
type WorkerSubmissionGate,
|
|
26
24
|
} from "./worker-submission-gates.ts";
|
|
27
25
|
import {
|
|
28
26
|
fixerBashSeatbeltDenyReason,
|
|
@@ -34,28 +32,10 @@ import { isRecord } from "./unknown-value.ts";
|
|
|
34
32
|
export {
|
|
35
33
|
CODER_OUTPUT_TOOL_NAME,
|
|
36
34
|
FIXER_OUTPUT_TOOL_NAME,
|
|
35
|
+
coderOutputSchema,
|
|
37
36
|
validateAcceptedWorkerDetails,
|
|
38
|
-
};
|
|
39
|
-
export type { WorkerOutput };
|
|
40
|
-
|
|
41
|
-
// status 的合法词写在 description。WORKER_DONE_STATUSES 只让 completed /
|
|
42
|
-
// partially_completed 进入提交闸。unfinished 且未见理由说明时,运行时同 run 催全
|
|
43
|
-
// (ADR 0050);理由在不在不按 JSON 类型判,也不在派发前用长度拒收。
|
|
44
|
-
// report / remainingScope / reason 的声明只留字段名和语义。
|
|
45
|
-
const CODER_STATUS_DESCRIPTION =
|
|
46
|
-
`planned | completed | refused | partially_completed | unfinished。unfinished:缺前置或违宪约束致本局未完成。${PARTIALLY_COMPLETED_DEFINITION}` as const;
|
|
47
|
-
const coderOutputObject = Type.Object({
|
|
48
|
-
status: Type.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
49
|
-
report: Type.Unknown({ description: "如实结果报告" }),
|
|
50
|
-
remainingScope: Type.Unknown({ description: "本局后剩余工作" }),
|
|
51
|
-
reason: Type.Unknown({
|
|
52
|
-
description: "阻断原因:缺前置或违宪约束。缺待决 owner 决定或答复属缺前置。",
|
|
53
|
-
}),
|
|
54
|
-
});
|
|
55
|
-
export const coderOutputSchema = withTerminatingOutputDeclarations(
|
|
56
|
-
openToolObject(coderOutputObject),
|
|
57
|
-
);
|
|
58
|
-
export type { FixerOutput, CoderOutput };
|
|
37
|
+
} from "./package-contracts/worker-output.ts";
|
|
38
|
+
export type { WorkerOutput, FixerOutput, CoderOutput };
|
|
59
39
|
export const FIXER_FLAG_DEFINITIONS = {
|
|
60
40
|
packet: {
|
|
61
41
|
name: "ak-fix-packet",
|
|
@@ -128,9 +108,48 @@ export function validateWorkerOutput(
|
|
|
128
108
|
return validateAcceptedWorkerDetails(output, "Coder") as CoderOutput;
|
|
129
109
|
}
|
|
130
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Coder and fixer share one submission sequence: record via the shared tool,
|
|
113
|
+
* then read status and bounce through the same reminder gate.
|
|
114
|
+
* Seat differences stay in the ready check and the projection.
|
|
115
|
+
*/
|
|
116
|
+
function registerWorkerSubmission(
|
|
117
|
+
pi: RoleHost,
|
|
118
|
+
role: "coder" | "fixer",
|
|
119
|
+
options: {
|
|
120
|
+
readonly notReady: string;
|
|
121
|
+
readonly ready: () => boolean;
|
|
122
|
+
readonly phase: () => WorkerPhase | undefined;
|
|
123
|
+
readonly project: (parameters: unknown, phase: WorkerPhase) => WorkerOutput;
|
|
124
|
+
readonly submissionGate: WorkerSubmissionGate;
|
|
125
|
+
readonly hostActions: WorkerRoleHostActions;
|
|
126
|
+
},
|
|
127
|
+
): void {
|
|
128
|
+
registerFiledSubmissionTool(pi, roleSubmissionDeclaration(role), {
|
|
129
|
+
readyError: () => (options.ready() ? undefined : options.notReady),
|
|
130
|
+
beforeAccept: async ({ toolCallId, parameters, ctx }) => {
|
|
131
|
+
const phase = options.phase();
|
|
132
|
+
if (phase === undefined) throw new Error(options.notReady);
|
|
133
|
+
const output = options.project(parameters, phase);
|
|
134
|
+
const status = workerStatusOf(output);
|
|
135
|
+
if (status !== undefined) {
|
|
136
|
+
assertAcceptableThroughHost(
|
|
137
|
+
options.submissionGate,
|
|
138
|
+
status,
|
|
139
|
+
output,
|
|
140
|
+
options.hostActions,
|
|
141
|
+
ctx,
|
|
142
|
+
toolCallId,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
return output;
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
131
150
|
/** Reminder bounces stay typed rejects; IO/infrastructure keep identity via host failInfrastructure. */
|
|
132
151
|
function assertAcceptableThroughHost(
|
|
133
|
-
submissionGate:
|
|
152
|
+
submissionGate: WorkerSubmissionGate,
|
|
134
153
|
status: string,
|
|
135
154
|
details: unknown,
|
|
136
155
|
hostActions: WorkerRoleHostActions,
|
|
@@ -212,30 +231,13 @@ export function createFixerRoleRuntime(
|
|
|
212
231
|
|
|
213
232
|
if (!lifecycleRegistered) {
|
|
214
233
|
lifecycleRegistered = true;
|
|
215
|
-
pi
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (packet === undefined || phase === undefined) {
|
|
223
|
-
throw new Error("修内司修理包与阶段未装载");
|
|
224
|
-
}
|
|
225
|
-
const output = deepFreeze(validateFixerOutput(parameters, phase));
|
|
226
|
-
const status = workerStatusOf(output);
|
|
227
|
-
if (status !== undefined) {
|
|
228
|
-
assertAcceptableThroughHost(
|
|
229
|
-
submissionGate,
|
|
230
|
-
status,
|
|
231
|
-
output,
|
|
232
|
-
hostActions,
|
|
233
|
-
ctx,
|
|
234
|
-
toolCallId,
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
return { content: [], details: output, terminate: true as const };
|
|
238
|
-
},
|
|
234
|
+
registerWorkerSubmission(pi, "fixer", {
|
|
235
|
+
notReady: "修内司修理包与阶段未装载",
|
|
236
|
+
ready: () => packet !== undefined && phase !== undefined,
|
|
237
|
+
phase: () => phase,
|
|
238
|
+
project: (parameters, current) => deepFreeze(validateFixerOutput(parameters, current)),
|
|
239
|
+
submissionGate,
|
|
240
|
+
hostActions,
|
|
239
241
|
});
|
|
240
242
|
pi.on("tool_call", (event) => {
|
|
241
243
|
if (event.toolName !== "bash") return;
|
|
@@ -310,32 +312,13 @@ export function createCoderRoleRuntime(
|
|
|
310
312
|
|
|
311
313
|
if (!lifecycleRegistered) {
|
|
312
314
|
lifecycleRegistered = true;
|
|
313
|
-
pi
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (task === undefined || phase === undefined) {
|
|
321
|
-
throw new Error("将作监任务与阶段未装载");
|
|
322
|
-
}
|
|
323
|
-
const output = validateWorkerOutput(parameters, phase, "Coder");
|
|
324
|
-
const status = workerStatusOf(output);
|
|
325
|
-
// #836: skill-expansion evidence rejection deleted (陛下「2.4/5 删」).
|
|
326
|
-
// Skill still ships with the package (ADR 0052); code no longer refuses on it.
|
|
327
|
-
if (status !== undefined) {
|
|
328
|
-
assertAcceptableThroughHost(
|
|
329
|
-
submissionGate,
|
|
330
|
-
status,
|
|
331
|
-
output,
|
|
332
|
-
hostActions,
|
|
333
|
-
ctx,
|
|
334
|
-
toolCallId,
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
return { content: [], details: output, terminate: true as const };
|
|
338
|
-
},
|
|
315
|
+
registerWorkerSubmission(pi, "coder", {
|
|
316
|
+
notReady: "将作监任务与阶段未装载",
|
|
317
|
+
ready: () => task !== undefined && phase !== undefined,
|
|
318
|
+
phase: () => phase,
|
|
319
|
+
project: (parameters, current) => validateWorkerOutput(parameters, current, "Coder"),
|
|
320
|
+
submissionGate,
|
|
321
|
+
hostActions,
|
|
339
322
|
});
|
|
340
323
|
pi.on("before_agent_start", (event, ctx) => {
|
|
341
324
|
if (soul === undefined) throw new Error("将作监职分未装载");
|