@akagilnc/pi-workflow-roles 0.1.3412 → 0.1.3439

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 (67) hide show
  1. package/dist/archivist-record-entry.js +21 -12
  2. package/dist/archivist-record-topology.js +20 -0
  3. package/dist/auditor-dossier-tool.js +67 -76
  4. package/dist/canonical-json.js +66 -69
  5. package/dist/compliance-transport.js +99 -86
  6. package/dist/countersign-contracts.js +23 -25
  7. package/dist/doctor-contracts.js +169 -145
  8. package/dist/engine-detour-tool.js +83 -87
  9. package/dist/engine-detour.js +148 -183
  10. package/dist/evidence-child-executor.js +10 -1
  11. package/dist/exact-utf8.js +11 -10
  12. package/dist/git-object-id.js +10 -5
  13. package/dist/gleaner-left-contracts.js +33 -35
  14. package/dist/grok/production-host.js +229 -118
  15. package/dist/inspector-contracts.js +28 -31
  16. package/dist/institutional-resolution.js +101 -104
  17. package/dist/ledger-session-read.js +241 -0
  18. package/dist/merger-contracts.js +66 -56
  19. package/dist/notary-contracts.js +91 -100
  20. package/dist/open-tool-schema.js +32 -31
  21. package/dist/package-contracts/collector-output.js +56 -43
  22. package/dist/package-contracts/fixer-output.js +52 -50
  23. package/dist/package-contracts/fixer-packet.js +67 -64
  24. package/dist/package-contracts/gatekeeper-output.js +48 -56
  25. package/dist/package-contracts/judge-output.js +23 -20
  26. package/dist/package-contracts/navigator-output.js +35 -40
  27. package/dist/package-contracts/reviewer-output.js +94 -110
  28. package/dist/package-contracts/terminating-infrastructure.js +62 -90
  29. package/dist/package-contracts/worker-output.js +30 -11
  30. package/dist/package-resources/engine-material.js +58 -94
  31. package/dist/public-cli/config.js +420 -484
  32. package/dist/public-cli/main.js +1219 -524
  33. package/dist/public-cli/registry.js +107 -114
  34. package/dist/receipt-delivery-policy.js +74 -76
  35. package/dist/session-opening-materials.js +44 -47
  36. package/dist/sha256.js +5 -3
  37. package/dist/sitian-appender.js +204 -210
  38. package/dist/sitian-contracts.js +15 -19
  39. package/dist/sitian-facade.js +5 -10
  40. package/dist/sitian-reader.js +37 -46
  41. package/dist/stream-idle-guard.js +63 -71
  42. package/dist/ticket-seat-memory.js +244 -0
  43. package/package.json +1 -1
  44. package/scripts/build-package.mjs +41 -0
  45. package/souls/audit-law.md +4 -0
  46. package/souls/countersign.md +1 -1
  47. package/souls/gleaner-left.md +1 -1
  48. package/souls/inspector.md +1 -1
  49. package/souls/notary.md +1 -1
  50. package/souls/reviewer.md +1 -1
  51. package/src/analyst-gate-cycles-read.ts +152 -83
  52. package/src/analyst-ledger.ts +170 -43
  53. package/src/archivist-record-entry.ts +32 -11
  54. package/src/archivist-record-topology.ts +39 -0
  55. package/src/evidence-child-executor.ts +14 -1
  56. package/src/grok/production-host.ts +44 -9
  57. package/src/host-contracts.ts +18 -0
  58. package/src/host-transition-prior-native.ts +8 -1
  59. package/src/ledger-session-read.ts +56 -0
  60. package/src/pi/durable-principal.ts +6 -0
  61. package/src/public-cli/inspector-run.ts +21 -10
  62. package/src/public-cli/invocation.ts +4 -20
  63. package/src/public-cli/notary-run.ts +21 -4
  64. package/src/public-cli/post-admission.ts +333 -42
  65. package/src/public-cli/settlement.ts +266 -81
  66. package/src/session-opening-materials.ts +4 -2
  67. package/src/ticket-seat-memory.ts +454 -0
@@ -7,72 +7,82 @@ import { withInfrastructureFailureDeclaration } from "./package-contracts/termin
7
7
  const oidPattern = "^(?:[0-9a-f]{40}|[0-9a-f]{64})$";
8
8
  const materialSchema = Type.Object({ bytesBase64: Type.String(), sha256: Type.String() }, { additionalProperties: false });
9
9
  const checkSchema = Type.Object({ name: Type.String({ minLength: 1 }), argv: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }) }, { additionalProperties: false });
10
- export const mergerInputSchema = Type.Object({
11
- version: Type.Literal(1), attemptId: Type.String({ minLength: 1 }),
12
- targetObjectId: Type.String({ pattern: oidPattern }), sourceObjectId: Type.String({ pattern: oidPattern }),
13
- materials: Type.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }, { additionalProperties: false }),
14
- expectedConflictPaths: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
15
- resolutionScope: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
16
- authorizedChecks: Type.Array(checkSchema),
10
+ const mergerInputSchema = Type.Object({
11
+ version: Type.Literal(1),
12
+ attemptId: Type.String({ minLength: 1 }),
13
+ targetObjectId: Type.String({ pattern: oidPattern }),
14
+ sourceObjectId: Type.String({ pattern: oidPattern }),
15
+ materials: Type.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }, { additionalProperties: false }),
16
+ expectedConflictPaths: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
17
+ resolutionScope: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
18
+ authorizedChecks: Type.Array(checkSchema)
17
19
  }, { additionalProperties: false });
18
20
  const mergerOutputVariants = Type.Union([
19
- Type.Object({ status: Type.Literal("completed", { description: "completed — 形状指引,非 schema 闸" }), attemptId: Type.String({ minLength: 1, description: "已受理合并 attempt 身份" }), report: Type.String({ minLength: 1, description: "如实结果报告" }), mergeCommitId: Type.String({ pattern: oidPattern, description: "已核验的完成合并 commit object ID" }) }, { additionalProperties: false }),
20
- Type.Object({ status: Type.Literal("escalate", { description: "escalate — 形状指引,非 schema 闸" }), attemptId: Type.String({ minLength: 1, description: "已受理合并 attempt 身份" }), diagnosis: Type.String({ minLength: 1, description: "合并完成需升级的原因" }), report: Type.String({ minLength: 1, description: "如实结果报告" }) }, { additionalProperties: false }),
21
+ Type.Object({ status: Type.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), attemptId: Type.String({ minLength: 1, description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type.String({ pattern: oidPattern, description: "\u5DF2\u6838\u9A8C\u7684\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
22
+ Type.Object({ status: Type.Literal("escalate", { description: "escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), attemptId: Type.String({ minLength: 1, description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type.String({ minLength: 1, description: "\u5408\u5E76\u5B8C\u6210\u9700\u5347\u7EA7\u7684\u539F\u56E0" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
21
23
  ]);
22
- export const mergerOutputSchema = withInfrastructureFailureDeclaration(openToolObjectFromUnion(mergerOutputVariants));
23
- export const MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
24
- export const MERGER_ACCEPTED_TEXT = "合并回执已接受";
24
+ const mergerOutputSchema = withInfrastructureFailureDeclaration(
25
+ openToolObjectFromUnion(mergerOutputVariants)
26
+ );
27
+ const MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
28
+ const MERGER_ACCEPTED_TEXT = "\u5408\u5E76\u56DE\u6267\u5DF2\u63A5\u53D7";
25
29
  const record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
26
30
  const blank = (v) => typeof v !== "string" || v.trim().length === 0;
27
- export class MergerInputContractError extends Error {
28
- constructor(message = "Merger input violates its exact contract") { super(message); this.name = "MergerInputContractError"; }
31
+ class MergerInputContractError extends Error {
32
+ constructor(message = "Merger input violates its exact contract") {
33
+ super(message);
34
+ this.name = "MergerInputContractError";
35
+ }
36
+ }
37
+ function fail(message = "Merger input violates its exact contract") {
38
+ throw new MergerInputContractError(message);
39
+ }
40
+ function canonicalPath(path) {
41
+ return typeof path === "string" && path.length > 0 && !path.startsWith("/") && !path.includes("\0") && path.split("/").every((part) => part !== "" && part !== "." && part !== "..");
29
42
  }
30
- function fail(message = "Merger input violates its exact contract") { throw new MergerInputContractError(message); }
31
- function canonicalPath(path) { return typeof path === "string" && path.length > 0 && !path.startsWith("/") && !path.includes("\0") && path.split("/").every(part => part !== "" && part !== "." && part !== ".."); }
32
43
  function validatePathSet(value, label) {
33
- if (!Array.isArray(value) || value.length === 0 || !value.every(canonicalPath))
34
- fail(`Merger ${label} must be a non-empty canonical path set`);
35
- return value;
44
+ if (!Array.isArray(value) || value.length === 0 || !value.every(canonicalPath)) fail(`Merger ${label} must be a non-empty canonical path set`);
45
+ return value;
36
46
  }
37
47
  function validateMaterial(value, label) {
38
- if (!record(value) || typeof value.bytesBase64 !== "string" || typeof value.sha256 !== "string")
39
- fail(`Merger ${label} material is malformed`);
40
- const bytes = Buffer.from(value.bytesBase64, "base64");
41
- exactUtf8(bytes, `Merger ${label} material`);
42
- if (sha256Hex(bytes) !== value.sha256)
43
- fail(`Merger ${label} material digest mismatch`);
48
+ if (!record(value) || typeof value.bytesBase64 !== "string" || typeof value.sha256 !== "string") fail(`Merger ${label} material is malformed`);
49
+ const bytes = Buffer.from(value.bytesBase64, "base64");
50
+ exactUtf8(bytes, `Merger ${label} material`);
51
+ if (sha256Hex(bytes) !== value.sha256) fail(`Merger ${label} material digest mismatch`);
44
52
  }
45
- function deepFreeze(value) { if (value && typeof value === "object") {
46
- for (const child of Object.values(value))
47
- deepFreeze(child);
53
+ function deepFreeze(value) {
54
+ if (value && typeof value === "object") {
55
+ for (const child of Object.values(value)) deepFreeze(child);
48
56
  Object.freeze(value);
49
- } return value; }
50
- export function validateMergerInput(value) {
51
- if (!record(value) || blank(value.attemptId) || !isFullGitObjectId(value.targetObjectId) || !isFullGitObjectId(value.sourceObjectId) || value.targetObjectId.length !== value.sourceObjectId.length)
52
- fail("Merger input has invalid identity or object ID");
53
- if (!record(value.materials))
54
- fail();
55
- for (const key of ["task", "authority", "targetIntent", "sourceIntent"])
56
- validateMaterial(value.materials[key], key);
57
- const conflicts = validatePathSet(value.expectedConflictPaths, "expected conflict paths");
58
- const scope = validatePathSet(value.resolutionScope, "resolution scope");
59
- if (!conflicts.every(path => scope.includes(path)))
60
- fail("Merger resolution scope must contain the complete conflict set");
61
- if (!Array.isArray(value.authorizedChecks))
62
- fail("Merger authorized checks are malformed");
63
- for (const check of value.authorizedChecks) {
64
- if (!record(check) || !Array.isArray(check.argv) || check.argv.length === 0 || check.argv.some(blank))
65
- fail("Merger authorized check is malformed");
66
- }
67
- return deepFreeze(structuredClone(value));
57
+ }
58
+ return value;
59
+ }
60
+ function validateMergerInput(value) {
61
+ if (!record(value) || blank(value.attemptId) || !isFullGitObjectId(value.targetObjectId) || !isFullGitObjectId(value.sourceObjectId) || value.targetObjectId.length !== value.sourceObjectId.length) fail("Merger input has invalid identity or object ID");
62
+ if (!record(value.materials)) fail();
63
+ for (const key of ["task", "authority", "targetIntent", "sourceIntent"]) validateMaterial(value.materials[key], key);
64
+ const conflicts = validatePathSet(value.expectedConflictPaths, "expected conflict paths");
65
+ const scope = validatePathSet(value.resolutionScope, "resolution scope");
66
+ if (!conflicts.every((path) => scope.includes(path))) fail("Merger resolution scope must contain the complete conflict set");
67
+ if (!Array.isArray(value.authorizedChecks)) fail("Merger authorized checks are malformed");
68
+ for (const check of value.authorizedChecks) {
69
+ if (!record(check) || !Array.isArray(check.argv) || check.argv.length === 0 || check.argv.some(blank)) fail("Merger authorized check is malformed");
70
+ }
71
+ return deepFreeze(structuredClone(value));
68
72
  }
69
- export function validateMergerOutput(value, expectedAttemptId) {
70
- if (!record(value) || (expectedAttemptId !== undefined && value.attemptId !== expectedAttemptId))
71
- throw new Error("合并回执 attempt 不匹配");
72
- const status = typeof value.status === "string" ? value.status : undefined;
73
- if (status === "completed" && isFullGitObjectId(value.mergeCommitId))
74
- return structuredClone(value);
75
- if (status === "escalate")
76
- return structuredClone(value);
77
- throw new Error("合并回执无已识别的执行判别");
73
+ function validateMergerOutput(value, expectedAttemptId) {
74
+ if (!record(value) || expectedAttemptId !== void 0 && value.attemptId !== expectedAttemptId) throw new Error("\u5408\u5E76\u56DE\u6267 attempt \u4E0D\u5339\u914D");
75
+ const status = typeof value.status === "string" ? value.status : void 0;
76
+ if (status === "completed" && isFullGitObjectId(value.mergeCommitId)) return structuredClone(value);
77
+ if (status === "escalate") return structuredClone(value);
78
+ throw new Error("\u5408\u5E76\u56DE\u6267\u65E0\u5DF2\u8BC6\u522B\u7684\u6267\u884C\u5224\u522B");
78
79
  }
80
+ export {
81
+ MERGER_ACCEPTED_TEXT,
82
+ MERGER_OUTPUT_TOOL_NAME,
83
+ MergerInputContractError,
84
+ mergerInputSchema,
85
+ mergerOutputSchema,
86
+ validateMergerInput,
87
+ validateMergerOutput
88
+ };
@@ -1,113 +1,104 @@
1
- /**
2
- * Public Notary (符宝郎) terminating receipt contracts.
3
- * Lawful explicit releases: pass | bounce | escalate.
4
- * No usable result is infrastructure failure via public settlement, not a judgment status (#475).
5
- */
6
1
  import { Type } from "typebox";
7
2
  import { openToolObject } from "./open-tool-schema.js";
8
3
  import { withInfrastructureFailureDeclaration } from "./package-contracts/terminating-infrastructure.js";
9
- export const NOTARY_OUTPUT_TOOL_NAME = "ak_notary_output";
10
- export const NOTARY_ACCEPTED_TEXT = "符宝郎回执已接受";
11
- export const NOTARY_SOURCE_RUN_FLAG = {
12
- name: "ak-notary-source-run",
13
- definition: {
14
- description: "Absolute source run directory bound for Notary self-fetch",
15
- type: "string",
16
- },
4
+ const NOTARY_OUTPUT_TOOL_NAME = "ak_notary_output";
5
+ const NOTARY_ACCEPTED_TEXT = "\u7B26\u5B9D\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7";
6
+ const NOTARY_SOURCE_RUN_FLAG = {
7
+ name: "ak-notary-source-run",
8
+ definition: {
9
+ description: "Absolute source run directory bound for Notary self-fetch",
10
+ type: "string"
11
+ }
17
12
  };
18
- /** Optional ticket binding for court-diary (起居录) lookup — ADR 0075. */
19
- export const NOTARY_TICKET_FLAG = {
20
- name: "ak-notary-ticket-number",
21
- definition: {
22
- description: "Optional ticket number for Notary court-diary lookup",
23
- type: "string",
24
- },
13
+ const NOTARY_TICKET_FLAG = {
14
+ name: "ak-notary-ticket-number",
15
+ definition: {
16
+ description: "Optional ticket number for Notary court-diary lookup",
17
+ type: "string"
18
+ }
25
19
  };
26
- /** Package-owned kickoff only — callers supply zero prompt bytes (ADR 0067 / #448). */
27
- export const NOTARY_FIXED_KICKOFF = "符宝郎案卷已受理;来源 run 定位见会话材料。";
28
- export const notaryOutputSchema = withInfrastructureFailureDeclaration(openToolObject(Type.Object({
29
- status: Type.Unknown({
30
- description: "pass | bounce | escalate — 形状指引,非 schema 闸",
31
- }),
32
- findings: Type.Unknown({
33
- description: "string[] findings,随 pass、bounce 或 escalate 留存",
34
- }),
35
- reason: Type.Optional(Type.Unknown({
36
- description: "status 为 escalate 时的上呈理由",
37
- })),
38
- })));
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(
22
+ openToolObject(
23
+ Type.Object({
24
+ status: Type.Unknown({
25
+ description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
26
+ }),
27
+ findings: Type.Unknown({
28
+ description: "string[] findings\uFF0C\u968F pass\u3001bounce \u6216 escalate \u7559\u5B58"
29
+ }),
30
+ reason: Type.Optional(Type.Unknown({
31
+ description: "status \u4E3A escalate \u65F6\u7684\u4E0A\u5448\u7406\u7531"
32
+ }))
33
+ })
34
+ )
35
+ );
39
36
  function isRecord(value) {
40
- return typeof value === "object" && value !== null && !Array.isArray(value);
37
+ return typeof value === "object" && value !== null && !Array.isArray(value);
41
38
  }
42
39
  function asStringArray(value) {
43
- if (!Array.isArray(value))
44
- return [];
45
- return value.filter((item) => typeof item === "string");
40
+ if (!Array.isArray(value)) return [];
41
+ return value.filter((item) => typeof item === "string");
46
42
  }
47
- /**
48
- * Project one lawful explicit Notary release (pass | bounce | escalate).
49
- * No throw on shape — ADR 0055 / 第 0 条: already-submitted params are retained as-is;
50
- * public-terminal projects non-usable releases via typed failure cause.
51
- */
52
- export function projectLawfulNotaryOutput(value) {
53
- if (!isRecord(value))
54
- return undefined;
55
- const status = typeof value.status === "string" ? value.status : undefined;
56
- if (status === "bounce") {
57
- const clone = structuredClone(value);
58
- if (clone.disposition === undefined)
59
- clone.disposition = "rewrite";
60
- if (!Array.isArray(clone.findings))
61
- clone.findings = asStringArray(clone.findings);
62
- return clone;
63
- }
64
- if (status === "pass") {
65
- const clone = structuredClone(value);
66
- if (!Array.isArray(clone.findings))
67
- clone.findings = asStringArray(clone.findings);
68
- return clone;
69
- }
70
- if (status === "escalate") {
71
- return structuredClone(value);
72
- }
73
- return undefined;
43
+ function projectLawfulNotaryOutput(value) {
44
+ if (!isRecord(value)) return void 0;
45
+ const status = typeof value.status === "string" ? value.status : void 0;
46
+ if (status === "bounce") {
47
+ const clone = structuredClone(value);
48
+ if (clone.disposition === void 0) clone.disposition = "rewrite";
49
+ if (!Array.isArray(clone.findings)) clone.findings = asStringArray(clone.findings);
50
+ return clone;
51
+ }
52
+ if (status === "pass") {
53
+ const clone = structuredClone(value);
54
+ if (!Array.isArray(clone.findings)) clone.findings = asStringArray(clone.findings);
55
+ return clone;
56
+ }
57
+ if (status === "escalate") {
58
+ return structuredClone(value);
59
+ }
60
+ return void 0;
74
61
  }
75
- /** Retain submitted Notary params as-is for the failure channel (no shape rewrite). */
76
- export function retainNotarySubmission(value) {
77
- if (value === undefined)
78
- return { missing: "arguments" };
79
- try {
80
- return structuredClone(value);
81
- }
82
- catch {
83
- return value;
84
- }
62
+ function retainNotarySubmission(value) {
63
+ if (value === void 0) return { missing: "arguments" };
64
+ try {
65
+ return structuredClone(value);
66
+ } catch {
67
+ return value;
68
+ }
85
69
  }
86
- /**
87
- * Settlement/recording path: only lawful recorded pass/bounce/escalate.
88
- * Does not gate role admission — callers must not use this to reject a submission.
89
- */
90
- export function validateRecordedNotaryOutput(value) {
91
- const projected = projectLawfulNotaryOutput(value);
92
- if (projected === undefined) {
93
- throw new Error("Notary output has no recognized execution discriminator");
94
- }
95
- return projected;
70
+ function validateRecordedNotaryOutput(value) {
71
+ const projected = projectLawfulNotaryOutput(value);
72
+ if (projected === void 0) {
73
+ throw new Error("Notary output has no recognized execution discriminator");
74
+ }
75
+ return projected;
96
76
  }
97
- export function notaryDecisiveFacts(output) {
98
- const status = String(output.status);
99
- const facts = { status, officer: "notary" };
100
- if (status === "pass" || status === "bounce") {
101
- const findings = output.findings;
102
- facts.findingsCount = Array.isArray(findings) ? findings.length : 0;
103
- }
104
- if (status === "bounce") {
105
- facts.disposition = "rewrite";
106
- }
107
- if (status === "escalate") {
108
- const reason = output.reason;
109
- if (reason !== undefined)
110
- facts.reason = reason;
111
- }
112
- return facts;
77
+ function notaryDecisiveFacts(output) {
78
+ const status = String(output.status);
79
+ const facts = { status, officer: "notary" };
80
+ if (status === "pass" || status === "bounce") {
81
+ const findings = output.findings;
82
+ facts.findingsCount = Array.isArray(findings) ? findings.length : 0;
83
+ }
84
+ if (status === "bounce") {
85
+ facts.disposition = "rewrite";
86
+ }
87
+ if (status === "escalate") {
88
+ const reason = output.reason;
89
+ if (reason !== void 0) facts.reason = reason;
90
+ }
91
+ return facts;
113
92
  }
93
+ export {
94
+ NOTARY_ACCEPTED_TEXT,
95
+ NOTARY_FIXED_KICKOFF,
96
+ NOTARY_OUTPUT_TOOL_NAME,
97
+ NOTARY_SOURCE_RUN_FLAG,
98
+ NOTARY_TICKET_FLAG,
99
+ notaryDecisiveFacts,
100
+ notaryOutputSchema,
101
+ projectLawfulNotaryOutput,
102
+ retainNotarySubmission,
103
+ validateRecordedNotaryOutput
104
+ };
@@ -1,39 +1,40 @@
1
1
  import { Type } from "typebox";
2
2
  function described(name, schema) {
3
- if (typeof schema.description === "string")
4
- return schema;
5
- throw new Error(`Tool field ${name} has no semantic description at its schema owner`);
3
+ if (typeof schema.description === "string") return schema;
4
+ throw new Error(`Tool field ${name} has no semantic description at its schema owner`);
6
5
  }
7
6
  function declarationIdentity(schema) {
8
- const { description: _description, ...semantic } = schema;
9
- return JSON.stringify(semantic);
7
+ const { description: _description, ...semantic } = schema;
8
+ return JSON.stringify(semantic);
10
9
  }
11
- /** Collapse transport variants into one provider-compatible, zero-required open object. */
12
- export function openToolObjectFromUnion(schema) {
13
- const declarations = new Map();
14
- for (const variant of schema.anyOf) {
15
- for (const [name, declaration] of Object.entries(variant.properties ?? {})) {
16
- const entries = declarations.get(name) ?? [];
17
- const identity = declarationIdentity(declaration);
18
- if (!entries.some((entry) => declarationIdentity(entry) === identity))
19
- entries.push(declaration);
20
- declarations.set(name, entries);
21
- }
10
+ function openToolObjectFromUnion(schema) {
11
+ const declarations = /* @__PURE__ */ new Map();
12
+ for (const variant of schema.anyOf) {
13
+ for (const [name, declaration] of Object.entries(variant.properties ?? {})) {
14
+ const entries = declarations.get(name) ?? [];
15
+ const identity = declarationIdentity(declaration);
16
+ if (!entries.some((entry) => declarationIdentity(entry) === identity)) entries.push(declaration);
17
+ declarations.set(name, entries);
22
18
  }
23
- const properties = Object.fromEntries([...declarations].map(([name, entries]) => {
24
- const descriptions = [...new Set(entries.map((entry) => entry.description).filter((value) => typeof value === "string"))].join(" ");
25
- const declaration = entries.length === 1
26
- ? entries[0]
27
- : Type.Union(entries, descriptions === "" ? {} : { description: descriptions });
28
- return [name, Type.Optional(described(name, declaration))];
29
- }));
30
- const object = Type.Object(properties, { additionalProperties: true });
31
- object.required = [];
32
- return object;
19
+ }
20
+ const properties = Object.fromEntries([...declarations].map(([name, entries]) => {
21
+ const descriptions = [...new Set(entries.map((entry) => entry.description).filter((value) => typeof value === "string"))].join(" ");
22
+ const declaration = entries.length === 1 ? entries[0] : Type.Union(entries, descriptions === "" ? {} : { description: descriptions });
23
+ return [name, Type.Optional(described(name, declaration))];
24
+ }));
25
+ const object = Type.Object(properties, { additionalProperties: true });
26
+ object.required = [];
27
+ return object;
33
28
  }
34
- /** Open a pre-existing object transport schema without changing declarations. */
35
- export function openToolObject(schema) {
36
- const object = Type.Object(Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [name, Type.Optional(described(name, declaration))])), { additionalProperties: true });
37
- object.required = [];
38
- return object;
29
+ function openToolObject(schema) {
30
+ const object = Type.Object(
31
+ Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [name, Type.Optional(described(name, declaration))])),
32
+ { additionalProperties: true }
33
+ );
34
+ object.required = [];
35
+ return object;
39
36
  }
37
+ export {
38
+ openToolObject,
39
+ openToolObjectFromUnion
40
+ };
@@ -1,50 +1,63 @@
1
- /** Package-owned Collector receipt leaf — no role registration surface. */
2
- export const COLLECTOR_OUTPUT_TOOL = "ak_collector_output";
3
- export const COLLECTOR_ACCEPTED_TEXT = "通进司回执已接受";
4
- export const COLLECTOR_HOST = "github.com";
1
+ const COLLECTOR_OUTPUT_TOOL = "ak_collector_output";
2
+ const COLLECTOR_ACCEPTED_TEXT = "\u901A\u8FDB\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7";
3
+ const COLLECTOR_HOST = "github.com";
5
4
  function safeGet(value, key) {
6
- if ((typeof value !== "object" && typeof value !== "function") || value === null)
7
- return undefined;
8
- try {
9
- return value[key];
10
- }
11
- catch {
12
- return undefined;
13
- }
5
+ if (typeof value !== "object" && typeof value !== "function" || value === null) return void 0;
6
+ try {
7
+ return value[key];
8
+ } catch {
9
+ return void 0;
10
+ }
14
11
  }
15
12
  function records(value) {
16
- return Array.isArray(value) ? value.filter((item) => item !== null && typeof item === "object") : [];
13
+ return Array.isArray(value) ? value.filter((item) => item !== null && typeof item === "object") : [];
17
14
  }
18
15
  function strings(value) {
19
- return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
16
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
20
17
  }
21
- /** Settlement projection. Presence of the canonical groups array is the one Collector terminal discriminator. */
22
- export function validateAcceptedCollectorReceipt(value) {
23
- const rawGroups = safeGet(value, "groups");
24
- if (!Array.isArray(rawGroups))
25
- throw new Error("Collector receipt has no typed groups terminal discriminator");
26
- const groups = records(rawGroups).map((group) => ({
27
- identity: (safeGet(group, "identity") ?? null),
28
- ...(typeof safeGet(group, "displayLogin") === "string" ? { displayLogin: safeGet(group, "displayLogin") } : {}),
29
- attendance: true,
30
- materials: records(safeGet(group, "materials")),
31
- findings: records(safeGet(group, "findings")),
32
- }));
33
- return {
34
- host: safeGet(value, "host"),
35
- repository: safeGet(value, "repository"),
36
- prNumber: safeGet(value, "prNumber"),
37
- manifestDigest: safeGet(value, "manifestDigest"),
38
- activationTime: safeGet(value, "activationTime"),
39
- deadlineTime: safeGet(value, "deadlineTime"),
40
- finalObservationTime: safeGet(value, "finalObservationTime"),
41
- finalSnapshotId: safeGet(value, "finalSnapshotId"),
42
- targetHead: safeGet(value, "targetHead"),
43
- groups,
44
- requestAttempts: records(safeGet(value, "requestAttempts")),
45
- snapshots: records(safeGet(value, "snapshots")).map((snapshot) => ({
46
- snapshotId: safeGet(snapshot, "snapshotId"), observedAt: safeGet(snapshot, "observedAt"), completedAt: safeGet(snapshot, "completedAt"), completedMono: safeGet(snapshot, "completedMono"), host: safeGet(snapshot, "host"), repository: safeGet(snapshot, "repository"), prNumber: safeGet(snapshot, "prNumber"), prState: safeGet(snapshot, "prState"), headOid: safeGet(snapshot, "headOid"), complete: safeGet(snapshot, "complete"), evidenceIds: strings(safeGet(snapshot, "evidenceIds")), pageDiagnostics: records(safeGet(snapshot, "pageDiagnostics")), normalizedByteLength: safeGet(snapshot, "normalizedByteLength"),
47
- })),
48
- evidenceRecords: records(safeGet(value, "evidenceRecords")).map((record) => ({ evidenceId: safeGet(record, "evidenceId"), kind: safeGet(record, "kind"), versionId: safeGet(record, "versionId"), contentDigest: safeGet(record, "contentDigest"), firstObservedAt: safeGet(record, "firstObservedAt"), githubId: safeGet(record, "githubId"), authorLogin: safeGet(record, "authorLogin"), htmlUrl: safeGet(record, "htmlUrl"), authoritativeTime: safeGet(record, "authoritativeTime") })),
49
- };
18
+ function validateAcceptedCollectorReceipt(value) {
19
+ const rawGroups = safeGet(value, "groups");
20
+ if (!Array.isArray(rawGroups)) throw new Error("Collector receipt has no typed groups terminal discriminator");
21
+ const groups = records(rawGroups).map((group) => ({
22
+ identity: safeGet(group, "identity") ?? null,
23
+ ...typeof safeGet(group, "displayLogin") === "string" ? { displayLogin: safeGet(group, "displayLogin") } : {},
24
+ attendance: true,
25
+ materials: records(safeGet(group, "materials")),
26
+ findings: records(safeGet(group, "findings"))
27
+ }));
28
+ return {
29
+ host: safeGet(value, "host"),
30
+ repository: safeGet(value, "repository"),
31
+ prNumber: safeGet(value, "prNumber"),
32
+ manifestDigest: safeGet(value, "manifestDigest"),
33
+ activationTime: safeGet(value, "activationTime"),
34
+ deadlineTime: safeGet(value, "deadlineTime"),
35
+ finalObservationTime: safeGet(value, "finalObservationTime"),
36
+ finalSnapshotId: safeGet(value, "finalSnapshotId"),
37
+ targetHead: safeGet(value, "targetHead"),
38
+ groups,
39
+ requestAttempts: records(safeGet(value, "requestAttempts")),
40
+ snapshots: records(safeGet(value, "snapshots")).map((snapshot) => ({
41
+ snapshotId: safeGet(snapshot, "snapshotId"),
42
+ observedAt: safeGet(snapshot, "observedAt"),
43
+ completedAt: safeGet(snapshot, "completedAt"),
44
+ completedMono: safeGet(snapshot, "completedMono"),
45
+ host: safeGet(snapshot, "host"),
46
+ repository: safeGet(snapshot, "repository"),
47
+ prNumber: safeGet(snapshot, "prNumber"),
48
+ prState: safeGet(snapshot, "prState"),
49
+ headOid: safeGet(snapshot, "headOid"),
50
+ complete: safeGet(snapshot, "complete"),
51
+ evidenceIds: strings(safeGet(snapshot, "evidenceIds")),
52
+ pageDiagnostics: records(safeGet(snapshot, "pageDiagnostics")),
53
+ normalizedByteLength: safeGet(snapshot, "normalizedByteLength")
54
+ })),
55
+ evidenceRecords: records(safeGet(value, "evidenceRecords")).map((record) => ({ evidenceId: safeGet(record, "evidenceId"), kind: safeGet(record, "kind"), versionId: safeGet(record, "versionId"), contentDigest: safeGet(record, "contentDigest"), firstObservedAt: safeGet(record, "firstObservedAt"), githubId: safeGet(record, "githubId"), authorLogin: safeGet(record, "authorLogin"), htmlUrl: safeGet(record, "htmlUrl"), authoritativeTime: safeGet(record, "authoritativeTime") }))
56
+ };
50
57
  }
58
+ export {
59
+ COLLECTOR_ACCEPTED_TEXT,
60
+ COLLECTOR_HOST,
61
+ COLLECTOR_OUTPUT_TOOL,
62
+ validateAcceptedCollectorReceipt
63
+ };