@akagilnc/pi-workflow-roles 0.1.4321 → 0.1.4387

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 (71) hide show
  1. package/README.md +4 -1
  2. package/README.zh-CN.md +5 -1
  3. package/dist/acp-host/production-host.js +1308 -587
  4. package/dist/doctor-contracts.js +2 -2
  5. package/dist/engine-detour-tool.js +2 -8
  6. package/dist/gatekeeper-role.js +4 -19
  7. package/dist/headless-host/production-host.js +2613 -1892
  8. package/dist/merger-contracts.js +2 -2
  9. package/dist/migrate-book-topology.js +34 -9
  10. package/dist/notary-contracts.js +2 -2
  11. package/dist/package-contracts/auditor-output.js +2 -2
  12. package/dist/package-contracts/fixer-output.js +2 -2
  13. package/dist/package-contracts/gatekeeper-output.js +2 -2
  14. package/dist/package-contracts/navigator-output.js +2 -2
  15. package/dist/package-contracts/terminating-infrastructure.js +7 -2
  16. package/dist/package-contracts/terminating-tools.js +6 -0
  17. package/dist/packaged-role-registry.js +20 -1
  18. package/dist/public-cli/case-dossier-delivery.js +45 -28
  19. package/dist/public-cli/countersign-run.js +439 -0
  20. package/dist/public-cli/invocation.js +10 -0
  21. package/dist/public-cli/main.js +388 -101
  22. package/dist/public-cli/option-definitions.js +14 -0
  23. package/dist/public-cli/post-admission.js +44 -49
  24. package/dist/public-cli/run-lifecycle.js +13 -1
  25. package/dist/public-cli/settlement.js +14 -53
  26. package/dist/public-role-summons.js +14 -0
  27. package/dist/secretariat-contracts.js +8 -0
  28. package/dist/sitian-appender.js +21 -4
  29. package/extensions/role-runtime.ts +1 -0
  30. package/package.json +1 -1
  31. package/scripts/build-package.mjs +1 -0
  32. package/souls/secretariat.md +26 -0
  33. package/souls/ticket-law.md +9 -0
  34. package/src/collector-tool-schemas.ts +2 -2
  35. package/src/countersign-role.ts +2 -2
  36. package/src/diarist-role.ts +2 -2
  37. package/src/doctor-contracts.ts +2 -2
  38. package/src/engine-detour-tool.ts +3 -9
  39. package/src/gatekeeper-pass-envelope.ts +35 -2
  40. package/src/gatekeeper-role.ts +8 -31
  41. package/src/gleaner-left-role.ts +2 -2
  42. package/src/host-contracts.ts +2 -1
  43. package/src/inspector-role.ts +2 -2
  44. package/src/judge-role.ts +2 -2
  45. package/src/merger-contracts.ts +2 -2
  46. package/src/notary-contracts.ts +2 -2
  47. package/src/package-contracts/auditor-output.ts +2 -2
  48. package/src/package-contracts/fixer-output.ts +2 -2
  49. package/src/package-contracts/gatekeeper-output.ts +2 -2
  50. package/src/package-contracts/navigator-output.ts +2 -2
  51. package/src/package-contracts/terminating-infrastructure.ts +13 -3
  52. package/src/package-contracts/terminating-tools.ts +9 -1
  53. package/src/packaged-role-registry.ts +20 -1
  54. package/src/public-cli/case-dossier-delivery.ts +48 -29
  55. package/src/public-cli/cli.ts +10 -0
  56. package/src/public-cli/countersign-run.ts +29 -5
  57. package/src/public-cli/invocation.ts +28 -2
  58. package/src/public-cli/option-definitions.ts +17 -0
  59. package/src/public-cli/post-admission.ts +45 -58
  60. package/src/public-cli/run-lifecycle.ts +29 -2
  61. package/src/public-cli/secretariat-run.ts +266 -0
  62. package/src/public-cli/settlement.ts +31 -55
  63. package/src/public-cli/terminal.ts +2 -1
  64. package/src/public-role-summons.ts +23 -1
  65. package/src/reviewer-role.ts +2 -2
  66. package/src/role-runtime-dependencies.ts +1 -0
  67. package/src/role-runtime.ts +203 -18
  68. package/src/secretariat-contracts.ts +27 -0
  69. package/src/secretariat-role.ts +210 -0
  70. package/src/sitian-appender.ts +36 -3
  71. package/src/worker-role.ts +2 -2
@@ -1,7 +1,7 @@
1
1
  import { Type } from "typebox";
2
2
  import { canonicalJson } from "./canonical-json.js";
3
3
  import { openToolObjectFromUnion } from "./open-tool-schema.js";
4
- import { withInfrastructureFailureDeclaration } from "./package-contracts/terminating-infrastructure.js";
4
+ import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.js";
5
5
  const DOCTOR_EVIDENCE_TOOL_NAME = "ak_doctor_evidence";
6
6
  const DOCTOR_OUTPUT_TOOL_NAME = "ak_doctor_output";
7
7
  const DOCTOR_ACCEPTED_TEXT = "\u592A\u533B\u7F72\u56DE\u6267\u5DF2\u63A5\u53D7";
@@ -41,7 +41,7 @@ const doctorSubmissionVariants = Type.Union([
41
41
  missingEvidence: Type.Array(Type.Object({ need: nonblank, targetKeys: evidenceIds }, { additionalProperties: true }), { description: "\u5982\u5B9E\u8BC1\u8BCD\u6240\u9700\u800C\u5C1A\u7F3A\u7684\u8BC1\u636E" })
42
42
  }, { additionalProperties: false, description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD" })
43
43
  ]);
44
- const doctorSubmissionSchema = withInfrastructureFailureDeclaration(
44
+ const doctorSubmissionSchema = withTerminatingOutputDeclarations(
45
45
  openToolObjectFromUnion(doctorSubmissionVariants)
46
46
  );
47
47
  const doctorEvidenceReadSchema = Type.Object({ evidenceId: Type.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: Type.Optional(Type.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: Type.Optional(Type.Integer({ minimum: 1, description: "\u8FD4\u56DE\u5B57\u8282\u6570\uFF08\u65E0\u4E0A\u9650\uFF09" })) }, { additionalProperties: true });
@@ -1,4 +1,3 @@
1
- import { basename } from "node:path";
2
1
  import { Type } from "typebox";
3
2
  import {
4
3
  ENGINE_DETOUR_TOOL_NAME,
@@ -12,12 +11,7 @@ import {
12
11
  engineDetourStdoutByteLength,
13
12
  reportEngineDetourCall
14
13
  } from "./engine-detour-usage.js";
15
- function basenameRunId(runDirectory) {
16
- const leaf = basename(runDirectory);
17
- const at = leaf.indexOf("@");
18
- if (at <= 0) return void 0;
19
- return leaf.slice(0, at);
20
- }
14
+ import { runIdFromRunDirectory } from "./run-terminal-artifacts.js";
21
15
  const engineDetourArgsSchema = Type.Object(
22
16
  {
23
17
  argv: Type.Array(Type.String({ minLength: 1 }), {
@@ -60,7 +54,7 @@ function createEngineDetourToolDefinition(input) {
60
54
  const sessionParent = ctx.sessionManager?.getSessionFile?.();
61
55
  const startedAt = Date.now();
62
56
  const runDirectory = typeof ctx.runDirectory === "string" && ctx.runDirectory.length > 0 ? ctx.runDirectory : void 0;
63
- const runId = runDirectory === void 0 ? void 0 : basenameRunId(runDirectory);
57
+ const runId = runDirectory === void 0 ? void 0 : runIdFromRunDirectory(runDirectory);
64
58
  const invocationScopeId = typeof ctx.invocationScopeId === "string" && ctx.invocationScopeId.trim() !== "" ? ctx.invocationScopeId.trim() : void 0;
65
59
  const host = typeof ctx.host === "string" && ctx.host.trim() !== "" ? ctx.host.trim() : void 0;
66
60
  const recordCall = (observed2) => {
@@ -178,8 +178,9 @@ function projectOfficerTerminal(officer, summoned) {
178
178
  */
179
179
  export const OFFICER_CONCLUSION_REASK = "上次交卷的结论不是 pass、bounce、escalate 三态之一。请重新输出,结论字段写明其一;打回或上呈的话就是给对方看的原文。";
180
180
  /**
181
- * Summon + project only. Lifecycle book and host abort face live on the shared
182
- * submit envelope (`gatekeeper-pass-envelope.ts`, ADR 0018 / #675).
181
+ * Summon (via injected seam) + project. Default summonGateOfficer drive lives
182
+ * on the shared envelope (`gatekeeper-pass-envelope.ts`, ADR 0018 / #675) —
183
+ * role module keeps projection only.
183
184
  */
184
185
  export async function projectGatekeeperRun(options) {
185
186
  const officer = gateOfficerForSubject(options.subject);
@@ -198,23 +199,7 @@ export async function projectGatekeeperRun(options) {
198
199
  // typed payload passed explicitly (never latest-toolCall recovery, A7.1–A7.3).
199
200
  let summoned;
200
201
  try {
201
- const summon = options.summonOfficer
202
- ?? (async (nextOfficer, sourceRunDirectory, officerSignal, reask, nextSubmission) => {
203
- const { summonGateOfficer } = await import("./public-role-summons.js");
204
- return summonGateOfficer({
205
- officer: nextOfficer,
206
- sourceRunDirectory,
207
- cwd: options.context.cwd ?? process.cwd(),
208
- ...(officerSignal === undefined ? {} : { signal: officerSignal }),
209
- ...(reask === undefined ? {} : { reask }),
210
- ...(nextSubmission === undefined ? {} : { submission: nextSubmission }),
211
- ...(options.home === undefined ? {} : { home: options.home }),
212
- ...(options.packageRoot === undefined ? {} : { packageRoot: options.packageRoot }),
213
- ...(options.roleTurnHost === undefined ? {} : { roleTurnHost: options.roleTurnHost }),
214
- ...(options.createRunId === undefined ? {} : { createRunId: options.createRunId }),
215
- });
216
- });
217
- summoned = await summon(officer, runDirectory, options.signal, options.reask, options.submission);
202
+ summoned = await options.summonOfficer(officer, runDirectory, options.signal, options.reask, options.submission);
218
203
  }
219
204
  catch (error) {
220
205
  return {