@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.
Files changed (43) hide show
  1. package/dist/acp-host/production-host.js +479 -425
  2. package/dist/collector-tool-schemas.js +18 -0
  3. package/dist/diarist-contracts.js +26 -0
  4. package/dist/filed-submission.js +28 -0
  5. package/dist/gatekeeper-role.js +6 -10
  6. package/dist/gleaner-left-contracts.js +16 -0
  7. package/dist/headless-host/production-host.js +495 -441
  8. package/dist/judge-role.js +8 -16
  9. package/dist/migrate-book-topology.js +262 -7
  10. package/dist/package-contracts/reviewer-output.js +16 -0
  11. package/dist/package-contracts/worker-output.js +18 -2
  12. package/dist/public-cli/instruction-seat-run.js +9 -12
  13. package/dist/public-cli/main.js +283 -26
  14. package/dist/role-submission-declarations.js +131 -0
  15. package/dist/secretariat-contracts.js +23 -1
  16. package/dist/submission-gate.js +5 -8
  17. package/package.json +1 -1
  18. package/src/auditor-role.ts +2 -8
  19. package/src/collector-role.ts +5 -28
  20. package/src/countersign-role.ts +2 -7
  21. package/src/diarist-contracts.ts +37 -0
  22. package/src/diarist-role.ts +4 -44
  23. package/src/doctor-role.ts +16 -11
  24. package/src/filed-submission.ts +44 -0
  25. package/src/gatekeeper-role.ts +6 -14
  26. package/src/gleaner-left-contracts.ts +26 -1
  27. package/src/gleaner-left-role.ts +4 -32
  28. package/src/inspector-role.ts +2 -7
  29. package/src/judge-role.ts +12 -24
  30. package/src/merger-role.ts +5 -8
  31. package/src/navigator-role.ts +2 -8
  32. package/src/notary-role.ts +5 -20
  33. package/src/package-contracts/reviewer-output.ts +25 -0
  34. package/src/package-contracts/worker-output.ts +43 -5
  35. package/src/public-cli/instruction-seat-run.ts +10 -13
  36. package/src/reviewer-role.ts +7 -35
  37. package/src/role-runtime.ts +7 -35
  38. package/src/role-submission-declarations.ts +143 -0
  39. package/src/secretariat-contracts.ts +35 -0
  40. package/src/secretariat-role.ts +4 -40
  41. package/src/submission-gate.ts +8 -9
  42. package/src/worker-role.ts +62 -79
  43. package/src/worker-submission-gates.ts +3 -0
@@ -0,0 +1,18 @@
1
+ import { Type } from "typebox";
2
+ import { openToolObject } from "./open-tool-schema.js";
3
+ import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.js";
4
+ /**
5
+ * #1088: LLM gathers evidence via host CLI and submits the receipt.
6
+ * Field declarations guide the model — host must not pure-shape-reject (第 0 条 / ADR 0057).
7
+ * Presence of `groups` remains the Collector terminal discriminator for settlement/analyst.
8
+ */
9
+ export const collectorOutputBaseSchema = openToolObject(Type.Object({
10
+ groups: Type.Unsafe({
11
+ description: "按机器身份归组的出席、材料与逐条 findings(LLM 自行从宿主 CLI 取证整理;代码不代收不归并)。",
12
+ }),
13
+ unfinishedReasons: Type.Unknown({
14
+ description: "未完成原因;取证受限时如实报告。",
15
+ }),
16
+ }));
17
+ /** Runtime does not enrich findings; the model submits the receipt and signals sole-final. */
18
+ export const collectorOutputArgsSchema = withTerminatingOutputDeclarations(collectorOutputBaseSchema);
@@ -6,6 +6,9 @@
6
6
  *
7
7
  * #901: LLM submits bounds; the mechanical layer projects source bytes.
8
8
  */
9
+ import { Type } from "typebox";
10
+ import { openToolObject } from "./open-tool-schema.js";
11
+ import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.js";
9
12
  import { projectTicketProvenanceSessions, } from "./ticket-provenance-contracts.js";
10
13
  import { isSafePositiveTicketNumber } from "./run-ticket-number.js";
11
14
  import { isRecord } from "./unknown-value.js";
@@ -55,3 +58,26 @@ export function projectDiaristTicketSessions(value) {
55
58
  }
56
59
  return Array.from(perTicket, ([ticketNumber, sessions]) => ({ ticketNumber, sessions }));
57
60
  }
61
+ /**
62
+ * 起居郎交卷形状。
63
+ * #901:交边界(sessions);正文与不可解析原字节由机械投影。
64
+ * status 的合法词(completed | escalate)写在 description,结算认这些词。
65
+ * sessions / ticketSessions 是投影所读的边界:卷路径或端点读不出时走既有 reask,不中止本轮。
66
+ * 声明只留字段名和语义说明,不留类型、嵌套、长度、必填。
67
+ */
68
+ const DIARIST_SESSIONS_DESCRIPTION = "对话边界。每卷含 path(会话卷绝对或可读路径)与 ranges(本卷本轮各区间)。每段区间含 from / to;起点与终点各写 id(原生 id)或 line(本轮行号),二选一。空列表=本轮无对话可划。端点无法指名时走 reask,不中止。";
69
+ export const diaristOutputSchema = withTerminatingOutputDeclarations(openToolObject(Type.Object({
70
+ status: Type.Unknown({
71
+ description: "completed | escalate",
72
+ }),
73
+ ticketNumber: Type.Optional(Type.Unknown({
74
+ description: "本庭对象票号(正整数)或 null/省略=真无票;下游走 typed 键;认不出用 status=escalate,不洗成无录。机械层不重判。",
75
+ })),
76
+ reason: Type.Unknown({
77
+ description: "status 为 escalate 时:认不出本庭对象的原因",
78
+ }),
79
+ sessions: Type.Optional(Type.Unknown({ description: DIARIST_SESSIONS_DESCRIPTION })),
80
+ ticketSessions: Type.Unknown({
81
+ description: `多票庭逐票对话边界;每票含 ticketNumber(本条边界所归票号,正整数)与 sessions(${DIARIST_SESSIONS_DESCRIPTION})。一次交卷各票各自分录。与单票 sessions 二选一。`,
82
+ }),
83
+ })));
@@ -0,0 +1,28 @@
1
+ /**
2
+ * One host-neutral submission execute for every public seat.
3
+ * Records nothing itself — the ledger seam already appends the original payload.
4
+ * Ends this tool call. Does not summon an auditor and does not end the role run.
5
+ * Shape is not an admission gate (ADR 0055). Seat reminders stay on beforeAccept.
6
+ */
7
+ export function registerFiledSubmissionTool(roleHost, tool, options) {
8
+ roleHost.registerTool({
9
+ name: tool.name,
10
+ label: tool.label,
11
+ description: tool.description,
12
+ ...(tool.promptSnippet === undefined ? {} : { promptSnippet: tool.promptSnippet }),
13
+ parameters: tool.parameters,
14
+ async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
15
+ const blocked = options.readyError();
16
+ if (blocked !== undefined)
17
+ throw new Error(blocked);
18
+ const projected = options.beforeAccept === undefined
19
+ ? undefined
20
+ : await options.beforeAccept({ toolCallId, parameters, signal, ctx });
21
+ return {
22
+ content: [],
23
+ details: projected === undefined ? parameters : projected,
24
+ terminate: true,
25
+ };
26
+ },
27
+ });
28
+ }
@@ -3,7 +3,8 @@ import { packagedGateStageLabel } from "./packaged-role-registry.js";
3
3
  import { GatekeeperDecisionError, receivedDiscriminator, unreadableDiscriminatorNotice } from "./submission-errors.js";
4
4
  import { INSPECTOR_OUTPUT_TOOL_NAME } from "./inspector-contracts.js";
5
5
  import { REVIEW_QUEUE_STATUSES, REVIEW_SUBMISSION_OUTPUT_TOOL_NAME } from "./review-submission.js";
6
- import { GATEKEEPER_OUTPUT_TOOL_NAME, gatekeeperOutputSchema, } from "./package-contracts/gatekeeper-output.js";
6
+ import { GATEKEEPER_OUTPUT_TOOL_NAME } from "./package-contracts/gatekeeper-output.js";
7
+ import { roleSubmissionDeclaration } from "./role-submission-declarations.js";
7
8
  import { runIdFromRunDirectory } from "./run-terminal-artifacts.js";
8
9
  import { isRecord } from "./unknown-value.js";
9
10
  export const INSPECTOR_OUTPUT_TOOL = INSPECTOR_OUTPUT_TOOL_NAME;
@@ -29,13 +30,7 @@ export { GatekeeperDecisionError } from "./submission-errors.js";
29
30
  * registration envelope — src/role-runtime.ts (ADR 0018). Schema authority is
30
31
  * the shared contract module (with infrastructure-failure declaration).
31
32
  */
32
- export const GATEKEEPER_TOOL_SPEC = {
33
- name: GATEKEEPER_OUTPUT_TOOL_NAME,
34
- label: "门下省决议",
35
- description: "门下省终局决议。status 为 dispatch 或 pass。",
36
- promptSnippet: "门下省决议",
37
- parameters: gatekeeperOutputSchema,
38
- };
33
+ export const GATEKEEPER_TOOL_SPEC = roleSubmissionDeclaration("gatekeeper");
39
34
  function failureReason(error) {
40
35
  if (error instanceof AggregateError)
41
36
  return error.errors.map(failureReason).join("; ");
@@ -59,8 +54,9 @@ function reviewQueueStatus(status) {
59
54
  function projectOfficerDecision(officer, decision, fallbackStatus) {
60
55
  const receipt = retainedReceipt(decision);
61
56
  const record = isRecord(decision) ? decision : undefined;
62
- const status = (record !== undefined && typeof record.status === "string" ? record.status : undefined)
63
- ?? fallbackStatus;
57
+ const status = record !== undefined && Object.hasOwn(record, "status")
58
+ ? receivedDiscriminator(record, "status")
59
+ : fallbackStatus;
64
60
  const queueStatus = typeof status === "string" ? reviewQueueStatus(status) : undefined;
65
61
  if (queueStatus === "converged") {
66
62
  return { status: "converged", officer, receipt };
@@ -1,5 +1,20 @@
1
+ import { Type } from "typebox";
2
+ import { openToolObject } from "./open-tool-schema.js";
3
+ import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.js";
1
4
  import { isRecord } from "./unknown-value.js";
2
5
  const GLEANER_LEFT_OUTPUT_TOOL_NAME = "ak_gleaner_left_output";
6
+ const gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
7
+ openToolObject(
8
+ Type.Object({
9
+ status: Type.Unknown({
10
+ description: "completed"
11
+ }),
12
+ findings: Type.Unknown({
13
+ description: "\u5F39\u7AE0\u5217\u8868\uFF1B\u6BCF\u6761\u53EF\u542B pointer\uFF08\u6587\u4EF6/\u884C\u6307\u9488\uFF09\u4E0E statement\uFF08\u7591\u70B9\u9648\u8FF0\uFF09\uFF0C\u539F\u6837\u7559\u5B58\u3002\u7A7A\u5217\u8868\u5408\u6CD5\u5B8C\u5C40\uFF1B\u673A\u5668\u4E0D\u5224\u5F39\u7AE0\u662F\u5426\u6210\u7ACB\u3002"
14
+ })
15
+ })
16
+ )
17
+ );
3
18
  const GLEANER_LEFT_BASE_FLAG = {
4
19
  name: "ak-gleaner-left-base",
5
20
  definition: {
@@ -25,5 +40,6 @@ function validateRecordedGleanerLeftOutput(value) {
25
40
  export {
26
41
  GLEANER_LEFT_BASE_FLAG,
27
42
  GLEANER_LEFT_OUTPUT_TOOL_NAME,
43
+ gleanerLeftOutputSchema,
28
44
  validateRecordedGleanerLeftOutput
29
45
  };