@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 { exactUtf8 } from "./exact-utf8.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 materialSchema = Type.Object({ bytesBase64: Type.String(), sha256: Type.String() }, { additionalProperties: false });
6
6
  const checkSchema = Type.Object({ name: Type.String({ minLength: 1 }), argv: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }) }, { additionalProperties: false });
7
7
  const mergerInputSchema = Type.Object({
@@ -18,7 +18,7 @@ const mergerOutputVariants = Type.Union([
18
18
  Type.Object({ status: Type.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
19
19
  Type.Object({ status: Type.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type.String({ description: "\u5408\u5E76\u65E0\u6CD5\u6216\u4E0D\u5E94\u7531\u672C\u5E2D\u5B8C\u6210\u7684\u539F\u56E0\uFF08\u542B\u65E0\u8FDB\u884C\u4E2D\u5408\u5E76\u3001\u65E0\u6D3B\u53EF\u5E72\u3001\u9700\u65B0\u7684\u4EA7\u54C1/\u6743\u529B\u51B3\u5B9A\uFF09" }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
20
20
  ]);
21
- const mergerOutputSchema = withInfrastructureFailureDeclaration(openToolObjectFromUnion(mergerOutputVariants));
21
+ const mergerOutputSchema = withTerminatingOutputDeclarations(openToolObjectFromUnion(mergerOutputVariants));
22
22
  const MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
23
23
  const MERGER_ACCEPTED_TEXT = "\u5408\u5E76\u56DE\u6267\u5DF2\u63A5\u53D7";
24
24
  const record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -8112,10 +8112,15 @@ var init_open_tool_schema = __esm({
8112
8112
  });
8113
8113
 
8114
8114
  // src/package-contracts/terminating-infrastructure.ts
8115
- function withInfrastructureFailureDeclaration(schema) {
8115
+ function withTerminatingOutputDeclarations(schema) {
8116
8116
  const baseProperties = schema.properties;
8117
8117
  const properties = {
8118
8118
  ...baseProperties ?? {},
8119
+ ...baseProperties?.ticketNumber === void 0 ? {
8120
+ ticketNumber: typebox_exports.Unknown({
8121
+ description: "\u53EF\u9009\u672C\u7968\u53F7\uFF1A\u5C1A\u672A\u7ED1\u5B9A\u65F6\u7531\u89D2\u8272\u5728\u65E2\u6709\u56DE\u6267\u4E2D\u7533\u62A5\uFF1B\u673A\u68B0\u5C42\u53EA\u8BB0\u5F55\u5408\u6CD5\u6B63\u6574\u6570\uFF0C\u4E0D\u4ECE\u6563\u6587\u63A8\u5BFC\u3001\u4E0D\u9A8C\u771F\u3002\u7F3A\u5931\u6216\u9519\u5F62\u4E0D\u62D2\u6536\u3002"
8122
+ })
8123
+ } : {},
8119
8124
  [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
8120
8125
  };
8121
8126
  const object2 = typebox_exports.Object(properties, { additionalProperties: true });
@@ -8171,7 +8176,7 @@ var init_gatekeeper_output = __esm({
8171
8176
  })
8172
8177
  })
8173
8178
  );
8174
- gatekeeperOutputSchema = withInfrastructureFailureDeclaration(
8179
+ gatekeeperOutputSchema = withTerminatingOutputDeclarations(
8175
8180
  gatekeeperDecisionSchema
8176
8181
  );
8177
8182
  }
@@ -8647,7 +8652,7 @@ var init_doctor_contracts = __esm({
8647
8652
  missingEvidence: typebox_exports.Array(typebox_exports.Object({ need: nonblank, targetKeys: evidenceIds }, { additionalProperties: true }), { description: "\u5982\u5B9E\u8BC1\u8BCD\u6240\u9700\u800C\u5C1A\u7F3A\u7684\u8BC1\u636E" })
8648
8653
  }, { additionalProperties: false, description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD" })
8649
8654
  ]);
8650
- doctorSubmissionSchema = withInfrastructureFailureDeclaration(
8655
+ doctorSubmissionSchema = withTerminatingOutputDeclarations(
8651
8656
  openToolObjectFromUnion(doctorSubmissionVariants)
8652
8657
  );
8653
8658
  doctorEvidenceReadSchema = typebox_exports.Object({ evidenceId: typebox_exports.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: typebox_exports.Optional(typebox_exports.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "\u8FD4\u56DE\u5B57\u8282\u6570\uFF08\u65E0\u4E0A\u9650\uFF09" })) }, { additionalProperties: true });
@@ -8662,7 +8667,7 @@ var init_navigator_output = __esm({
8662
8667
  init_build();
8663
8668
  init_open_tool_schema();
8664
8669
  init_terminating_infrastructure();
8665
- navigatorOutputSchema = withInfrastructureFailureDeclaration(
8670
+ navigatorOutputSchema = withTerminatingOutputDeclarations(
8666
8671
  openToolObject(
8667
8672
  typebox_exports.Object({
8668
8673
  status: typebox_exports.Unknown({
@@ -8685,7 +8690,7 @@ var init_auditor_output = __esm({
8685
8690
  init_build();
8686
8691
  init_open_tool_schema();
8687
8692
  init_terminating_infrastructure();
8688
- auditorOutputSchema = withInfrastructureFailureDeclaration(
8693
+ auditorOutputSchema = withTerminatingOutputDeclarations(
8689
8694
  openToolObject(
8690
8695
  typebox_exports.Object({
8691
8696
  status: typebox_exports.Unknown({
@@ -8740,7 +8745,7 @@ var init_merger_contracts = __esm({
8740
8745
  typebox_exports.Object({ status: typebox_exports.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: typebox_exports.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: typebox_exports.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: typebox_exports.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
8741
8746
  typebox_exports.Object({ status: typebox_exports.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: typebox_exports.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: typebox_exports.String({ description: "\u5408\u5E76\u65E0\u6CD5\u6216\u4E0D\u5E94\u7531\u672C\u5E2D\u5B8C\u6210\u7684\u539F\u56E0\uFF08\u542B\u65E0\u8FDB\u884C\u4E2D\u5408\u5E76\u3001\u65E0\u6D3B\u53EF\u5E72\u3001\u9700\u65B0\u7684\u4EA7\u54C1/\u6743\u529B\u51B3\u5B9A\uFF09" }), report: typebox_exports.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
8742
8747
  ]);
8743
- mergerOutputSchema = withInfrastructureFailureDeclaration(openToolObjectFromUnion(mergerOutputVariants));
8748
+ mergerOutputSchema = withTerminatingOutputDeclarations(openToolObjectFromUnion(mergerOutputVariants));
8744
8749
  }
8745
8750
  });
8746
8751
 
@@ -8752,7 +8757,7 @@ var init_notary_contracts = __esm({
8752
8757
  init_build();
8753
8758
  init_open_tool_schema();
8754
8759
  init_terminating_infrastructure();
8755
- notaryOutputSchema = withInfrastructureFailureDeclaration(
8760
+ notaryOutputSchema = withTerminatingOutputDeclarations(
8756
8761
  openToolObject(
8757
8762
  typebox_exports.Object({
8758
8763
  status: typebox_exports.Unknown({
@@ -8784,6 +8789,13 @@ var init_gleaner_left_contracts = __esm({
8784
8789
  }
8785
8790
  });
8786
8791
 
8792
+ // src/secretariat-contracts.ts
8793
+ var init_secretariat_contracts = __esm({
8794
+ "src/secretariat-contracts.ts"() {
8795
+ "use strict";
8796
+ }
8797
+ });
8798
+
8787
8799
  // src/package-contracts/fixer-output.ts
8788
8800
  var transportString, authorityBlockerSchema, prerequisiteBlockerSchema, blockerSchema, exceptionSchema, testEvidenceSchema, completedClassResultSchema, refusedClassResultSchema, classResultSchema, completedClassResultsSchema, FIXER_STATUS_DESCRIPTION, fixerOutputVariants, fixerOutputSchema;
8789
8801
  var init_fixer_output = __esm({
@@ -8826,7 +8838,7 @@ var init_fixer_output = __esm({
8826
8838
  typebox_exports.Object({ status: typebox_exports.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: typebox_exports.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: typebox_exports.Array(classResultSchema, { description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
8827
8839
  typebox_exports.Object({ status: typebox_exports.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: typebox_exports.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: typebox_exports.Array(classResultSchema, { description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: typebox_exports.Optional(testEvidenceSchema) })
8828
8840
  ]);
8829
- fixerOutputSchema = withInfrastructureFailureDeclaration(
8841
+ fixerOutputSchema = withTerminatingOutputDeclarations(
8830
8842
  openToolObjectFromUnion(fixerOutputVariants)
8831
8843
  );
8832
8844
  }
@@ -14254,6 +14266,7 @@ var init_terminating_tools = __esm({
14254
14266
  init_gleaner_left_contracts();
14255
14267
  init_inspector_contracts();
14256
14268
  init_diarist_contracts();
14269
+ init_secretariat_contracts();
14257
14270
  init_worker_output();
14258
14271
  }
14259
14272
  });
@@ -14333,7 +14346,7 @@ var init_notary_source_run = __esm({
14333
14346
  function bindOwner(owner, semantics) {
14334
14347
  return { ...semantics, owner };
14335
14348
  }
14336
- var SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, JUDGE_OPTIONS, GLEANER_LEFT_OPTIONS, INSPECTOR_OPTIONS, GATEKEEPER_OPTIONS, NAVIGATOR_OPTIONS, AUDITOR_OPTIONS, COUNTERSIGN_OPTIONS, DIARIST_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
14349
+ var SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, JUDGE_OPTIONS, GLEANER_LEFT_OPTIONS, INSPECTOR_OPTIONS, GATEKEEPER_OPTIONS, NAVIGATOR_OPTIONS, AUDITOR_OPTIONS, COUNTERSIGN_OPTIONS, DIARIST_OPTIONS, SECRETARIAT_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
14337
14350
  var init_option_definitions = __esm({
14338
14351
  "src/public-cli/option-definitions.ts"() {
14339
14352
  "use strict";
@@ -14438,6 +14451,10 @@ var init_option_definitions = __esm({
14438
14451
  bindOwner("diarist", SHARED_PROJECT_SEMANTICS),
14439
14452
  bindOwner("diarist", SHARED_ATTACH_SEMANTICS)
14440
14453
  ];
14454
+ SECRETARIAT_OPTIONS = [
14455
+ bindOwner("secretariat", SHARED_PROJECT_SEMANTICS),
14456
+ bindOwner("secretariat", SHARED_ATTACH_SEMANTICS)
14457
+ ];
14441
14458
  CODER_OPTIONS = [
14442
14459
  {
14443
14460
  id: "phase",
@@ -14786,6 +14803,14 @@ var init_option_definitions = __esm({
14786
14803
  'ak-role diarist --attach ./design.md "\u8865\u5F55\u672C\u8F6E\u8BBE\u8BA1\u4FEE\u8BA2\u3002"'
14787
14804
  ]
14788
14805
  },
14806
+ secretariat: {
14807
+ command: "secretariat",
14808
+ summary: "Secretariat (\u4E2D\u4E66\u7701): rewrite ticket per \u7968\u9762\u6CD5 and drive countersign to converged or escalate.",
14809
+ usage: ["ak-role secretariat [options] [instruction]"],
14810
+ examples: [
14811
+ 'ak-role secretariat "\u6574\u7406 #924 \u7968\u9762\u5E76\u9001\u5EAD\u3002"'
14812
+ ]
14813
+ },
14789
14814
  notary: {
14790
14815
  command: "notary",
14791
14816
  summary: "Direct Notary document check (quote fidelity + ticket alignment); zero prompt/attachment.",
@@ -1,6 +1,6 @@
1
1
  import { Type } from "typebox";
2
2
  import { openToolObject } from "./open-tool-schema.js";
3
- import { withInfrastructureFailureDeclaration } from "./package-contracts/terminating-infrastructure.js";
3
+ import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.js";
4
4
  const NOTARY_OUTPUT_TOOL_NAME = "ak_notary_output";
5
5
  const NOTARY_ACCEPTED_TEXT = "\u7B26\u5B9D\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7";
6
6
  const NOTARY_SOURCE_RUN_FLAG = {
@@ -18,7 +18,7 @@ const NOTARY_TICKET_FLAG = {
18
18
  }
19
19
  };
20
20
  const NOTARY_FIXED_KICKOFF = "\u7B26\u5B9D\u90CE\u6848\u5377\u5DF2\u53D7\u7406\uFF1B\u6765\u6E90 run \u5B9A\u4F4D\u89C1\u4F1A\u8BDD\u6750\u6599\u3002";
21
- const notaryOutputSchema = withInfrastructureFailureDeclaration(
21
+ const notaryOutputSchema = withTerminatingOutputDeclarations(
22
22
  openToolObject(
23
23
  Type.Object({
24
24
  status: Type.Unknown({
@@ -4,10 +4,10 @@
4
4
  */
5
5
  import { Type } from "typebox";
6
6
  import { openToolObject } from "../open-tool-schema.js";
7
- import { withInfrastructureFailureDeclaration } from "./terminating-infrastructure.js";
7
+ import { withTerminatingOutputDeclarations } from "./terminating-infrastructure.js";
8
8
  export const AUDITOR_OUTPUT_TOOL_NAME = "ak_auditor_output";
9
9
  export const AUDITOR_ACCEPTED_TEXT = "审刑院回执已接受";
10
- export const auditorOutputSchema = withInfrastructureFailureDeclaration(openToolObject(Type.Object({
10
+ export const auditorOutputSchema = withTerminatingOutputDeclarations(openToolObject(Type.Object({
11
11
  status: Type.Unknown({
12
12
  description: "pass | bounce | escalate — 形状指引,非 schema 闸",
13
13
  }),
@@ -1,6 +1,6 @@
1
1
  import { Type } from "typebox";
2
2
  import { openToolObjectFromUnion } from "../open-tool-schema.js";
3
- import { withInfrastructureFailureDeclaration } from "./terminating-infrastructure.js";
3
+ import { withTerminatingOutputDeclarations } from "./terminating-infrastructure.js";
4
4
  const FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
5
5
  const FIXER_ACCEPTED_TEXT = "\u4FEE\u5185\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7";
6
6
  const transportString = Type.String();
@@ -37,7 +37,7 @@ const fixerOutputVariants = Type.Union([
37
37
  Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
38
38
  Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: Type.Optional(testEvidenceSchema) })
39
39
  ]);
40
- const fixerOutputSchema = withInfrastructureFailureDeclaration(
40
+ const fixerOutputSchema = withTerminatingOutputDeclarations(
41
41
  openToolObjectFromUnion(fixerOutputVariants)
42
42
  );
43
43
  function validateFixerOutput(value, _phase) {
@@ -1,6 +1,6 @@
1
1
  import { Type } from "typebox";
2
2
  import { openToolObject } from "../open-tool-schema.js";
3
- import { withInfrastructureFailureDeclaration } from "./terminating-infrastructure.js";
3
+ import { withTerminatingOutputDeclarations } from "./terminating-infrastructure.js";
4
4
  const GATEKEEPER_OUTPUT_TOOL_NAME = "ak_gatekeeper_output";
5
5
  const GATEKEEPER_ACCEPTED_TEXT = "\u95E8\u4E0B\u7701\u51B3\u8BAE\u5DF2\u53D7\u7406";
6
6
  const gatekeeperDecisionSchema = openToolObject(
@@ -16,7 +16,7 @@ const gatekeeperDecisionSchema = openToolObject(
16
16
  })
17
17
  })
18
18
  );
19
- const gatekeeperOutputSchema = withInfrastructureFailureDeclaration(
19
+ const gatekeeperOutputSchema = withTerminatingOutputDeclarations(
20
20
  gatekeeperDecisionSchema
21
21
  );
22
22
  function isRecord(value) {
@@ -1,9 +1,9 @@
1
1
  import { Type } from "typebox";
2
2
  import { openToolObject } from "../open-tool-schema.js";
3
- import { withInfrastructureFailureDeclaration } from "./terminating-infrastructure.js";
3
+ import { withTerminatingOutputDeclarations } from "./terminating-infrastructure.js";
4
4
  const NAVIGATOR_OUTPUT_TOOL_NAME = "ak_navigator_output";
5
5
  const NAVIGATOR_ACCEPTED_TEXT = "\u6E38\u5955\u4F7F\u5EFA\u8BAE\u5DF2\u53D7\u7406";
6
- const navigatorOutputSchema = withInfrastructureFailureDeclaration(
6
+ const navigatorOutputSchema = withTerminatingOutputDeclarations(
7
7
  openToolObject(
8
8
  Type.Object({
9
9
  status: Type.Unknown({
@@ -19,10 +19,15 @@ const infrastructureFailureDeclarationSchema = Type.Object(
19
19
  },
20
20
  { additionalProperties: true }
21
21
  );
22
- function withInfrastructureFailureDeclaration(schema) {
22
+ function withTerminatingOutputDeclarations(schema) {
23
23
  const baseProperties = schema.properties;
24
24
  const properties = {
25
25
  ...baseProperties ?? {},
26
+ ...baseProperties?.ticketNumber === void 0 ? {
27
+ ticketNumber: Type.Unknown({
28
+ description: "\u53EF\u9009\u672C\u7968\u53F7\uFF1A\u5C1A\u672A\u7ED1\u5B9A\u65F6\u7531\u89D2\u8272\u5728\u65E2\u6709\u56DE\u6267\u4E2D\u7533\u62A5\uFF1B\u673A\u68B0\u5C42\u53EA\u8BB0\u5F55\u5408\u6CD5\u6B63\u6574\u6570\uFF0C\u4E0D\u4ECE\u6563\u6587\u63A8\u5BFC\u3001\u4E0D\u9A8C\u771F\u3002\u7F3A\u5931\u6216\u9519\u5F62\u4E0D\u62D2\u6536\u3002"
29
+ })
30
+ } : {},
26
31
  [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
27
32
  };
28
33
  const object = Type.Object(properties, { additionalProperties: true });
@@ -70,5 +75,5 @@ export {
70
75
  INFRASTRUCTURE_FAILURE_DECLARATION_KEY,
71
76
  INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY,
72
77
  failOnInfrastructureFailureDeclaration,
73
- withInfrastructureFailureDeclaration
78
+ withTerminatingOutputDeclarations
74
79
  };
@@ -16,6 +16,7 @@ import { COUNTERSIGN_ACCEPTED_TEXT, COUNTERSIGN_OUTPUT_TOOL_NAME, validateRecord
16
16
  import { GLEANER_LEFT_ACCEPTED_TEXT, GLEANER_LEFT_OUTPUT_TOOL_NAME, validateRecordedGleanerLeftOutput } from "../gleaner-left-contracts.js";
17
17
  import { INSPECTOR_ACCEPTED_TEXT, INSPECTOR_OUTPUT_TOOL_NAME, validateRecordedInspectorOutput } from "../inspector-contracts.js";
18
18
  import { DIARIST_ACCEPTED_TEXT, DIARIST_OUTPUT_TOOL_NAME, validateRecordedDiaristOutput } from "../diarist-contracts.js";
19
+ import { SECRETARIAT_ACCEPTED_TEXT, SECRETARIAT_OUTPUT_TOOL_NAME } from "../secretariat-contracts.js";
19
20
  import { CODER_ACCEPTED_TEXT, CODER_OUTPUT_TOOL_NAME, FIXER_ACCEPTED_TEXT, FIXER_OUTPUT_TOOL_NAME, validateAcceptedWorkerDetails, } from "./worker-output.js";
20
21
  export { CODER_ACCEPTED_TEXT, CODER_OUTPUT_TOOL_NAME, COLLECTOR_ACCEPTED_TEXT, COLLECTOR_OUTPUT_TOOL, FIXER_ACCEPTED_TEXT, FIXER_OUTPUT_TOOL_NAME, JUDGE_ACCEPTED_TEXT, JUDGE_OUTPUT_TOOL_NAME, REVIEWER_ACCEPTED_TEXT, REVIEWER_OUTPUT_TOOL_NAME, MERGER_ACCEPTED_TEXT, MERGER_OUTPUT_TOOL_NAME, validateAcceptedCollectorReceipt, validateAcceptedJudgeDetails, validateReviewerIntent, validateAcceptedWorkerDetails, validateDoctorSubmissionShape, validateRecordedDoctorOutput, validateMergerOutput, validateRecordedNotaryOutput, validateRecordedCountersignOutput, validateRecordedGleanerLeftOutput, validateRecordedInspectorOutput, validateRecordedGatekeeperOutput, validateRecordedNavigatorOutput, validateRecordedAuditorOutput, validateRecordedDiaristOutput, };
21
22
  export const TERMINATING_TOOL_NAMES = [
@@ -34,6 +35,7 @@ export const TERMINATING_TOOL_NAMES = [
34
35
  NAVIGATOR_OUTPUT_TOOL_NAME,
35
36
  AUDITOR_OUTPUT_TOOL_NAME,
36
37
  DIARIST_OUTPUT_TOOL_NAME,
38
+ SECRETARIAT_OUTPUT_TOOL_NAME,
37
39
  ];
38
40
  export function isTerminatingToolName(name) {
39
41
  return TERMINATING_TOOL_NAMES.includes(name);
@@ -70,6 +72,8 @@ export function acceptedTextFor(toolName) {
70
72
  return AUDITOR_ACCEPTED_TEXT;
71
73
  case DIARIST_OUTPUT_TOOL_NAME:
72
74
  return DIARIST_ACCEPTED_TEXT;
75
+ case SECRETARIAT_OUTPUT_TOOL_NAME:
76
+ return SECRETARIAT_ACCEPTED_TEXT;
73
77
  }
74
78
  }
75
79
  export class AcceptedDetailsContractError extends CorrectableSubmissionError {
@@ -104,6 +108,8 @@ export function acceptedFacts(toolName, details) {
104
108
  return typeof record.judgeStatus === "string" ? { status: record.judgeStatus } : {};
105
109
  case COUNTERSIGN_OUTPUT_TOOL_NAME:
106
110
  return typeof record.countersignStatus === "string" ? { status: record.countersignStatus } : {};
111
+ case SECRETARIAT_OUTPUT_TOOL_NAME:
112
+ return typeof record.secretariatStatus === "string" ? { status: record.secretariatStatus } : {};
107
113
  case MERGER_OUTPUT_TOOL_NAME: {
108
114
  const status = typeof record.status === "string" ? record.status : undefined;
109
115
  return {
@@ -12,10 +12,12 @@ import { GLEANER_LEFT_OUTPUT_TOOL_NAME } from "./gleaner-left-contracts.js";
12
12
  import { INSPECTOR_OUTPUT_TOOL_NAME } from "./inspector-contracts.js";
13
13
  import { AUDITOR_OUTPUT_TOOL_NAME } from "./package-contracts/auditor-output.js";
14
14
  import { DIARIST_OUTPUT_TOOL_NAME } from "./diarist-contracts.js";
15
+ import { SECRETARIAT_OUTPUT_TOOL_NAME } from "./secretariat-contracts.js";
15
16
  const NOTARY_SESSION_MATERIALS = [
16
17
  "CLAUDE.md",
17
18
  "souls/notary.md",
18
19
  "souls/audit-law.md",
20
+ "souls/ticket-law.md",
19
21
  "souls/gate-output-guide.md"
20
22
  ];
21
23
  const INSPECTOR_SESSION_MATERIALS = [
@@ -138,7 +140,24 @@ const PUBLIC_ROLE_RECORDS = [
138
140
  inputFlag: void 0,
139
141
  phaseFlag: void 0,
140
142
  activationStage: "load-and-install",
141
- sessionMaterials: ["CLAUDE.md", "souls/countersign.md"]
143
+ // #924: 公用《票面法》三席同装
144
+ sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md"]
145
+ },
146
+ {
147
+ role: "secretariat",
148
+ phases: [null],
149
+ outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
150
+ inputFlag: void 0,
151
+ phaseFlag: void 0,
152
+ activationStage: "load-and-install",
153
+ // #924: owner-finalized Soul + 票面法 + 给事中/符宝郎行为指南
154
+ sessionMaterials: [
155
+ "CLAUDE.md",
156
+ "souls/secretariat.md",
157
+ "souls/ticket-law.md",
158
+ "souls/countersign.md",
159
+ "souls/notary.md"
160
+ ]
142
161
  },
143
162
  {
144
163
  role: "gleaner-left",
@@ -1,55 +1,69 @@
1
1
  /**
2
- * 系统随案递送本票起居录的中立指针段(ADR 0081:公共入口直接挂案卷,Soul 只说明用途不负责派送;
3
- * #709 公共入口通用递送与 #742 给事中受理链路同源;
4
- * 指针输入沿 ADR 0079(指针是绑定材料由代码精准递送),不把卷宗正文塞进提示词)。
5
- * 只读已有案卷:不刷新、不生成、不校验内容、不新增拒收或停工条件。
2
+ * 系统随案递送起居录路径的中立指针段(ADR 0081:公共入口直接挂案卷,Soul 只说明用途不负责派送;
3
+ * #709 公共入口通用递送与 #742 给事中受理链路同源;#858 告诉 LLM 路径,不另建取号/lookup)。
4
+ * 指针输入沿 ADR 0079(指针是绑定材料由代码精准递送),不把卷宗正文塞进提示词。
5
+ * 只告诉路径:不刷新、不生成、不校验内容、不新增拒收或停工条件、不从 instruction 抽票号。
6
6
  * 机器文本仅中立标识材料(ADR 0073),用途说明归角色材料所有。
7
7
  *
8
8
  * 递送挂载点唯一:`post-admission` 在 beforeDispatch 之后为每个公共入口挂载。
9
- * 普通入口把本段追加进 continuation;station-child 审核轮次走 attachments
10
- * 冻结 + role-runtime `loadCaseDossierReadingMaterial` → readingMaterial →
11
- * systemPrompt.materials fold(#879:对话 instruction 保持父腿 payload 原文;
12
- * 起居录作独立附件面,不新造 RoleTurnRequest.materials)。
9
+ * 全部公共入口(ordinary 已绑定/未绑定与 station-child)统一走 attachments 冻结 +
10
+ * role-runtime `loadCaseDossierReadingMaterial` → readingMaterial →
11
+ * systemPrompt.materials fold(#879 / #858:对话 instruction、空请求、resume
12
+ * message 保持调用者原文;起居录作独立附件面,不新造 RoleTurnRequest.materials,
13
+ * 不拼进 user-dialogue continuation)。
14
+ *
15
+ * #858: deliver returns typed FrozenAttachment[]; load currently re-derives the
16
+ * freeze leaf under runDirectory because agent-start only has HostContext.runDirectory.
17
+ * Consuming the typed frozenPath across that process boundary needs a design
18
+ * revision of the existing envelope/persistence seam — not a local replica of
19
+ * freezeAttachments' `00-` naming, not a drift throw, not readdir guessing.
13
20
  */
14
21
  import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
15
22
  import { tmpdir } from "node:os";
16
23
  import { join } from "node:path";
24
+ import { projectTicketRecordsPathShape } from "../sitian-facade.js";
17
25
  import { resolveTicketProvenanceVolume } from "../ticket-provenance.js";
18
26
  import { freezeAttachmentsIntoRun, } from "./invocation.js";
19
- /** Section heading of the system-delivered dossier pointer (presentation only). */
27
+ /** Bound-ticket section heading (presentation only). */
20
28
  const CASE_DOSSIER_SECTION_HEADING = "## 本票起居录(系统随案提供)";
29
+ /** Unbound path-only heading — no 本票 claim when no typed ticket is on the run. */
30
+ const UNBOUND_DOSSIER_PATH_HEADING = "## 起居录路径(系统随案提供)";
21
31
  /** Stable freeze key under run/attachments/ for station-child 0081 delivery. */
22
32
  const CASE_DOSSIER_ATTACH_KEY = "case-dossier";
23
33
  /** Leaf name of the frozen pointer section (content = purpose + paths). */
24
34
  const CASE_DOSSIER_ATTACH_FILE = "case-dossier-pointer.md";
25
- /** Pointer only — presence/absence is for the role to observe at the path. */
26
- function describeDossierFile(path) {
27
- return path;
28
- }
29
35
  /**
30
- * Pointer section for a bound ticket's existing 起居录, or undefined when the
31
- * run carries no ticket identity (unbound calls stay legal and get no dossier).
32
- * A bound ticket whose volume is missing or unreadable is stated as such —
33
- * the section never claims a dossier that is not there.
36
+ * Neutral 起居录 path pointer for every public entry (ADR 0081 delivery seam).
37
+ * Always tells the canonical path shape so the seat LLM can read the diary
38
+ * itself (陛下 2026-09-15: 只需要告诉llm这个路径). When a typed ticket identity is
39
+ * already on the run, also project the concrete resolved file. Never claims a
40
+ * volume or「本票」exists when unbound; never extracts a ticket from instruction.
41
+ * Under-book shape comes only from sitian writer joins — no local replica.
34
42
  */
35
43
  export async function projectCaseDossierPointerSection(input) {
36
- if (input.ticketNumber === undefined)
37
- return undefined;
44
+ if (input.ticketNumber === undefined) {
45
+ return [
46
+ UNBOUND_DOSSIER_PATH_HEADING,
47
+ "",
48
+ `记录卷宗:${projectTicketRecordsPathShape()}`,
49
+ ].join("\n");
50
+ }
38
51
  const volume = resolveTicketProvenanceVolume(input.ticketNumber, input.projectRoot, input.home);
39
52
  return [
40
53
  CASE_DOSSIER_SECTION_HEADING,
41
54
  "",
42
55
  `票号:#${input.ticketNumber}`,
43
- `记录卷宗:${describeDossierFile(volume.recordFile)}`,
56
+ `记录卷宗:${volume.recordFile}`,
44
57
  ].join("\n");
45
58
  }
46
59
  /**
47
- * ADR 0081 delivery for station-child officer turns (#879): freeze the same
48
- * pointer section through the existing attachments seam. Role-runtime loads
49
- * that freeze via loadCaseDossierReadingMaterial onto readingMaterial; the
50
- * envelope then folds it into systemPrompt.materials. Peer dialogue instruction
51
- * stays the parent payload; never RoleTurnRequest.materials.
52
- * Returns frozen attachments, or undefined when unbound (no dossier).
60
+ * ADR 0081 delivery for every public entry (#879 / #858): freeze the pointer
61
+ * section through the existing attachments seam. Role-runtime loads that freeze
62
+ * via loadCaseDossierReadingMaterial onto readingMaterial; the envelope then
63
+ * folds it into systemPrompt.materials. Caller / peer dialogue instruction stays
64
+ * opaque; never RoleTurnRequest.materials, never user-dialogue continuation.
65
+ * Always freezes the path pointer (canonical shape, or concrete file when a
66
+ * typed ticket is already bound).
53
67
  */
54
68
  export async function deliverCaseDossierAsAttachment(input) {
55
69
  const section = await projectCaseDossierPointerSection({
@@ -57,8 +71,6 @@ export async function deliverCaseDossierAsAttachment(input) {
57
71
  projectRoot: input.projectRoot,
58
72
  home: input.home,
59
73
  });
60
- if (section === undefined)
61
- return undefined;
62
74
  // Stage in OS temp only — never leave a run-local .case-dossier-stage copy.
63
75
  const stagingDir = await mkdtemp(join(tmpdir(), "ak-case-dossier-"));
64
76
  try {
@@ -74,6 +86,11 @@ export async function deliverCaseDossierAsAttachment(input) {
74
86
  * Load a previously frozen case-dossier attachment as reading material
75
87
  * (existing agent-start / systemPrompt.materials fold — not dialogue prompt,
76
88
  * not RoleTurnRequest.materials). Undefined when the run has no such freeze.
89
+ *
90
+ * #858: this join re-derives freezeAttachments' leaf naming because the
91
+ * agent-start handler only receives runDirectory. Replacing it requires
92
+ * threading deliver's typed frozenPath across the existing envelope seam
93
+ * (design revision) — do not copy freeze's `00-` algorithm here again.
77
94
  */
78
95
  export async function loadCaseDossierReadingMaterial(runDirectory) {
79
96
  const frozenPath = join(runDirectory, "attachments", CASE_DOSSIER_ATTACH_KEY, `00-${CASE_DOSSIER_ATTACH_FILE}`);