@akagilnc/pi-workflow-roles 0.1.5357 → 0.1.5368
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 +5353 -5480
- package/dist/doctor-contracts.js +22 -34
- package/dist/headless-host/production-host.js +1215 -1342
- package/dist/merger-contracts.js +11 -6
- package/dist/migrate-book-topology.js +57 -101
- package/dist/open-tool-schema.js +1 -25
- package/dist/package-contracts/fixer-output.js +21 -35
- package/dist/public-cli/auto-resume.js +1 -1
- package/dist/public-cli/cli.js +57 -56
- package/dist/public-cli/config.js +4 -0
- package/dist/public-cli/instruction-seat-run.js +65 -40
- package/dist/public-cli/invocation.js +132 -128
- package/dist/public-cli/main.js +449 -506
- package/dist/public-cli/post-admission.js +85 -86
- package/dist/public-cli/role-seat-runtime.js +29 -0
- package/dist/public-cli/run-lifecycle.js +6 -6
- package/dist/public-cli/turn-request.js +14 -0
- package/dist/public-role-summons.js +20 -33
- package/dist/role-run-placement.js +4 -0
- package/package.json +1 -1
- package/src/book-topology-migration-placement.ts +3 -5
- package/src/diarist-role.ts +12 -49
- package/src/doctor-contracts.ts +38 -49
- package/src/gleaner-left-role.ts +10 -11
- package/src/merger-contracts.ts +19 -12
- package/src/open-tool-schema.ts +8 -32
- package/src/package-contracts/fixer-output.ts +49 -52
- package/src/public-cli/auto-resume.ts +1 -1
- package/src/public-cli/cli.ts +67 -73
- package/src/public-cli/config.ts +8 -0
- package/src/public-cli/instruction-seat-run.ts +82 -55
- package/src/public-cli/invocation.ts +148 -162
- package/src/public-cli/post-admission.ts +110 -100
- package/src/public-cli/role-seat-runtime.ts +72 -0
- package/src/public-cli/run-lifecycle.ts +7 -26
- package/src/public-cli/terminal.ts +2 -17
- package/src/public-cli/turn-request.ts +26 -0
- package/src/public-role-summons.ts +20 -45
- package/src/reviewer-role.ts +16 -35
- package/src/role-run-placement.ts +5 -0
- package/src/secretariat-role.ts +16 -12
- package/src/worker-role.ts +14 -29
- package/src/worker-submission-gates.ts +14 -3
package/src/reviewer-role.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RoleHost, HostContext, HostToolResult } from "./host-contracts.ts";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
-
import {
|
|
3
|
+
import { openToolObject } from "./open-tool-schema.ts";
|
|
4
4
|
import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.ts";
|
|
5
5
|
|
|
6
6
|
import { REVIEWER_OUTPUT_TOOL_NAME, type ReviewerIntent } from "./package-contracts/reviewer-output.ts";
|
|
@@ -17,43 +17,24 @@ export type ReviewerAdmittedInputs = Readonly<{
|
|
|
17
17
|
ticketNumber?: number;
|
|
18
18
|
}>;
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
completeness
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"correctness lens 完整报告:candidates、逐条处置与 verdict;非仅 verdict 一行。hard-stop/usage error 为 refused 时,若已产出报告仍照录于此",
|
|
28
|
-
})),
|
|
29
|
-
}, {
|
|
30
|
-
additionalProperties: true,
|
|
31
|
-
description:
|
|
32
|
-
"已运行 lens 的 amendments 承载 candidates、逐条处置与 verdict 的完整报告(非仅 verdict 行);显式单轴时另一轴可省略。hard-stop/usage error 为 refused 时,已产出报告仍照录对应 lens 字段。",
|
|
33
|
-
});
|
|
34
|
-
// #836 r16 class 1: diagnostic is LLM/human-read narrative content — no code
|
|
35
|
-
// branches on its length (src/reviewer-role.ts consumer: reviewer content is
|
|
36
|
-
// returned as submitted, ADR 0057).
|
|
37
|
-
// #836 (ADR 0003 Amendment): status kept open like countersignStatus
|
|
38
|
-
// (src/countersign-role.ts) — one shared description across both variants
|
|
39
|
-
// so openToolObjectFromUnion's identical-declaration collapse drops none of it.
|
|
40
|
-
// #917 §6: both normal lens verdicts → completed; hard-stop/usage error → refused
|
|
41
|
-
// (report already produced still lands in selected-lens amendments).
|
|
20
|
+
const REVIEWER_AMENDMENTS_DESCRIPTION =
|
|
21
|
+
"已运行 lens 的 amendments 承载 candidates、逐条处置与 verdict 的完整报告(非仅 verdict 行);显式单轴时另一轴可省略(completeness / correctness)。hard-stop/usage error 为 refused 时,已产出报告仍照录对应 lens 字段。" as const;
|
|
22
|
+
// #1134: `status` alone is the trajectory field (#917 §6 two normal lens verdicts →
|
|
23
|
+
// completed; hard-stop / usage error → refused); its words ride the description.
|
|
24
|
+
// amendments/diagnostic are LLM/human-read narrative content returned as
|
|
25
|
+
// submitted — declaration keeps name + semantic description only, no nested
|
|
26
|
+
// object shape, no string type, no required constraint.
|
|
42
27
|
const REVIEWER_STATUS_DESCRIPTION =
|
|
43
28
|
"completed | refused。两种正常 lens verdict(completeness / correctness)均 completed;hard-stop 与 usage error 为 refused(已产出报告仍照录进所选 lens amendments)。" as const;
|
|
44
|
-
const
|
|
45
|
-
Type.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
diagnostic: Type.String({ description: "拒绝诊断说明;hard-stop/usage error 原因进此字段,已产出报告另照录 amendments" }),
|
|
52
|
-
amendments: Type.Optional(reviewerAmendmentsSchema),
|
|
53
|
-
}, { additionalProperties: false }),
|
|
54
|
-
]);
|
|
29
|
+
const reviewerOutputObject = Type.Object({
|
|
30
|
+
status: Type.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
|
|
31
|
+
amendments: Type.Unknown({ description: REVIEWER_AMENDMENTS_DESCRIPTION }),
|
|
32
|
+
diagnostic: Type.Unknown({
|
|
33
|
+
description: "拒绝诊断说明;hard-stop/usage error 原因进此字段,已产出报告另照录 amendments",
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
55
36
|
export const reviewerOutputSchema = withTerminatingOutputDeclarations(
|
|
56
|
-
|
|
37
|
+
openToolObject(reviewerOutputObject),
|
|
57
38
|
);
|
|
58
39
|
export type ReviewerRoleDependencies = {
|
|
59
40
|
loadSoul(): Promise<string>;
|
|
@@ -107,6 +107,11 @@ export function roleRunArtifactsDirectory(runDirectory: string): string {
|
|
|
107
107
|
return join(runDirectory, "artifacts");
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/** Canonical unbound placement: a run directory under `<book>/unbound/runs/`. */
|
|
111
|
+
export function isUnboundRunDirectory(runDirectory: string): boolean {
|
|
112
|
+
return runDirectory.replaceAll("\\", "/").includes("/unbound/runs/");
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
/** The placement seam owns creation for both new runs and resumed legacy runs. */
|
|
111
116
|
export function ensureRoleRunDirectory(
|
|
112
117
|
ledgerHome: string,
|
package/src/secretariat-role.ts
CHANGED
|
@@ -12,7 +12,17 @@ import { SECRETARIAT_OUTPUT_TOOL_NAME, type SecretariatVerdict } from "./secreta
|
|
|
12
12
|
export { SECRETARIAT_OUTPUT_TOOL_NAME } from "./secretariat-contracts.ts";
|
|
13
13
|
export type { SecretariatVerdict };
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* 中书省终局回执形状。
|
|
17
|
+
* #1134: `secretariatStatus` alone is the trajectory field
|
|
18
|
+
* (src/packaged-role-registry.ts:406 receiptStatusKey; the public settlement reads
|
|
19
|
+
* converged | escalate to route); its words ride the description. note/evidence/
|
|
20
|
+
* decisionGate are declared name + semantic description only — the string type, the
|
|
21
|
+
* number type, the nested question/options object shape and the required constraint
|
|
22
|
+
* are deleted, because the package declaration IS the host's pre-dispatch validator.
|
|
23
|
+
* (ticketNumber keeps its own declaration: it is the declared seat identity the
|
|
24
|
+
* activation flag and settlement read, not narrative content.)
|
|
25
|
+
*/
|
|
16
26
|
export const secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
17
27
|
Type.Object(
|
|
18
28
|
{
|
|
@@ -20,19 +30,13 @@ export const secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
|
20
30
|
description: "converged | escalate",
|
|
21
31
|
}),
|
|
22
32
|
ticketNumber: Type.Optional(
|
|
23
|
-
Type.
|
|
33
|
+
Type.Unknown({ description: "本票号;署时指向最终正文所在票" }),
|
|
24
34
|
),
|
|
25
|
-
note: Type.
|
|
35
|
+
note: Type.Unknown({ description: "附注" }),
|
|
26
36
|
evidence: Type.Optional(Type.Unknown({ description: "留存证据" })),
|
|
27
|
-
decisionGate: Type.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
question: Type.Optional(Type.String()),
|
|
31
|
-
options: Type.Optional(Type.Array(Type.String())),
|
|
32
|
-
},
|
|
33
|
-
{ additionalProperties: true, description: "需陛下处置的问题与选项" },
|
|
34
|
-
),
|
|
35
|
-
),
|
|
37
|
+
decisionGate: Type.Unknown({
|
|
38
|
+
description: "需陛下处置的问题与选项;可写 question 与 options,原样留存。",
|
|
39
|
+
}),
|
|
36
40
|
},
|
|
37
41
|
{ additionalProperties: true },
|
|
38
42
|
),
|
package/src/worker-role.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RoleHost, HostContext, HostToolResult, HostGatekeeperActions } from "./host-contracts.ts";
|
|
2
2
|
import { Type, type Static } from "typebox";
|
|
3
|
-
import {
|
|
3
|
+
import { openToolObject } from "./open-tool-schema.ts";
|
|
4
4
|
import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.ts";
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -36,37 +36,22 @@ export {
|
|
|
36
36
|
};
|
|
37
37
|
export type { WorkerOutput };
|
|
38
38
|
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
// Worker status is not the review three-state field (#1055): schema stays open.
|
|
44
|
-
// One shared description across every variant
|
|
45
|
-
// so openToolObjectFromUnion's identical-declaration collapse drops none of it.
|
|
39
|
+
// status 的合法词写在 description。WORKER_DONE_STATUSES 只让 completed /
|
|
40
|
+
// partially_completed 进入提交闸。unfinished 且未见理由说明时,运行时同 run 催全
|
|
41
|
+
// (ADR 0050);理由在不在不按 JSON 类型判,也不在派发前用长度拒收。
|
|
42
|
+
// report / remainingScope / reason 的声明只留字段名和语义。
|
|
46
43
|
const CODER_STATUS_DESCRIPTION =
|
|
47
44
|
`planned | completed | refused | partially_completed | unfinished。unfinished:缺前置或违宪约束致本局未完成。${PARTIALLY_COMPLETED_DEFINITION}` as const;
|
|
48
|
-
const
|
|
49
|
-
Type.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, { additionalProperties: false }),
|
|
57
|
-
Type.Object({
|
|
58
|
-
status: Type.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
59
|
-
report: Type.String({ description: "如实结果报告" }),
|
|
60
|
-
remainingScope: Type.String({ description: "本局后剩余工作" }),
|
|
61
|
-
reason: Type.Optional(Type.String({
|
|
62
|
-
minLength: 1,
|
|
63
|
-
description:
|
|
64
|
-
"阻断原因:缺前置或违宪约束。缺待决 owner 决定或答复属缺前置。",
|
|
65
|
-
})),
|
|
66
|
-
}, { additionalProperties: false }),
|
|
67
|
-
]);
|
|
45
|
+
const coderOutputObject = Type.Object({
|
|
46
|
+
status: Type.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
47
|
+
report: Type.Unknown({ description: "如实结果报告" }),
|
|
48
|
+
remainingScope: Type.Unknown({ description: "本局后剩余工作" }),
|
|
49
|
+
reason: Type.Unknown({
|
|
50
|
+
description: "阻断原因:缺前置或违宪约束。缺待决 owner 决定或答复属缺前置。",
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
68
53
|
export const coderOutputSchema = withTerminatingOutputDeclarations(
|
|
69
|
-
|
|
54
|
+
openToolObject(coderOutputObject),
|
|
70
55
|
);
|
|
71
56
|
export type { FixerOutput, CoderOutput };
|
|
72
57
|
export const FIXER_FLAG_DEFINITIONS = {
|
|
@@ -156,10 +156,21 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
156
156
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/** ADR 0050: a written explanation, including text carried by an object key. */
|
|
160
|
+
function containsWrittenReason(value: unknown): boolean {
|
|
161
|
+
if (typeof value === "string") return value.trim().length > 0;
|
|
162
|
+
if (Array.isArray(value)) return value.some(containsWrittenReason);
|
|
163
|
+
if (typeof value === "object" && value !== null) {
|
|
164
|
+
return Object.entries(value).some(
|
|
165
|
+
([key, item]) => containsWrittenReason(key) || containsWrittenReason(item),
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
159
171
|
function unfinishedReasonPresent(details?: unknown): boolean {
|
|
160
|
-
if (typeof details !== "object" || details === null) return false;
|
|
161
|
-
|
|
162
|
-
return typeof reason === "string" && reason.trim().length > 0;
|
|
172
|
+
if (typeof details !== "object" || details === null || Array.isArray(details)) return false;
|
|
173
|
+
return containsWrittenReason((details as { reason?: unknown }).reason);
|
|
163
174
|
}
|
|
164
175
|
|
|
165
176
|
function readGateState(session: HostRecordSession): {
|