@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
@@ -1,120 +1,104 @@
1
- /** Package-owned Reviewer intent and runtime-receipt leaves — no role registration surface. */
2
- export const REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
3
- export const REVIEWER_ACCEPTED_TEXT = "御史台回执已接受";
1
+ const REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
2
+ const REVIEWER_ACCEPTED_TEXT = "\u5FA1\u53F2\u53F0\u56DE\u6267\u5DF2\u63A5\u53D7";
4
3
  function isRecord(value) {
5
- return typeof value === "object" && value !== null && !Array.isArray(value);
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6
5
  }
7
6
  function read(value, key) {
8
- if (!isRecord(value))
9
- return undefined;
10
- try {
11
- return value[key];
12
- }
13
- catch {
14
- return undefined;
15
- }
7
+ if (!isRecord(value)) return void 0;
8
+ try {
9
+ return value[key];
10
+ } catch {
11
+ return void 0;
12
+ }
16
13
  }
17
- /** Canonical per-axis string slots only — no shape reject, no prose parse (ADR 0057). */
18
14
  function readAmendments(output) {
19
- const amendments = read(output, "amendments");
20
- if (!isRecord(amendments))
21
- return undefined;
22
- const slots = {};
23
- for (const axis of ["standards", "spec"]) {
24
- const value = read(amendments, axis);
25
- if (typeof value === "string")
26
- slots[axis] = value;
27
- }
28
- if (slots.standards === undefined && slots.spec === undefined)
29
- return undefined;
30
- return Object.freeze(slots);
15
+ const amendments = read(output, "amendments");
16
+ if (!isRecord(amendments)) return void 0;
17
+ const slots = {};
18
+ for (const axis of ["standards", "spec"]) {
19
+ const value = read(amendments, axis);
20
+ if (typeof value === "string") slots[axis] = value;
21
+ }
22
+ if (slots.standards === void 0 && slots.spec === void 0) return void 0;
23
+ return Object.freeze(slots);
31
24
  }
32
- export function validateReviewerIntent(output) {
33
- const status = read(output, "status");
34
- const amendments = readAmendments(output);
35
- if (status === "completed") {
36
- return amendments === undefined ? { status } : { status, amendments };
37
- }
38
- if (status === "refused") {
39
- return amendments === undefined
40
- ? { status, diagnostic: read(output, "diagnostic") }
41
- : { status, diagnostic: read(output, "diagnostic"), amendments };
42
- }
43
- throw new Error("Reviewer output has no recognized execution intent");
25
+ function validateReviewerIntent(output) {
26
+ const status = read(output, "status");
27
+ const amendments = readAmendments(output);
28
+ if (status === "completed") {
29
+ return amendments === void 0 ? { status } : { status, amendments };
30
+ }
31
+ if (status === "refused") {
32
+ return amendments === void 0 ? { status, diagnostic: read(output, "diagnostic") } : { status, diagnostic: read(output, "diagnostic"), amendments };
33
+ }
34
+ throw new Error("Reviewer output has no recognized execution intent");
44
35
  }
45
- /** Validate runtime-owned facts at their real identity seams (target pins + plain text). */
46
- export function validateRuntimeReviewerReceipt(output) {
47
- const status = read(output, "status");
48
- const acceptedBatch = read(output, "acceptedBatch");
49
- const identities = read(output, "identities");
50
- const construction = read(identities, "construction");
51
- const target = read(identities, "target");
52
- const reports = read(output, "reports");
53
- const outcomes = read(output, "outcomes");
54
- const legs = read(acceptedBatch, "legs");
55
- // A recognizable accepted batch must remain bound to its exact target pin.
56
- if (acceptedBatch !== undefined || construction !== undefined || target !== undefined) {
57
- if (!isRecord(acceptedBatch) || !isRecord(construction) || !isRecord(target) || !Array.isArray(legs))
58
- throw new Error("Incomplete Reviewer accepted-batch identity");
59
- const objectFormat = read(target, "objectFormat");
60
- const objectId = (value) => typeof value === "string" && new RegExp(objectFormat === "sha1" ? "^[0-9a-f]{40}$" : "^[0-9a-f]{64}$").test(value);
61
- const refs = read(target, "refs");
62
- const skillText = read(read(identities, "canonicalSkill"), "text");
63
- if (typeof skillText !== "string" ||
64
- read(construction, "recipe") !== "reviewer-common-bundle-v1" ||
65
- (objectFormat !== "sha1" && objectFormat !== "sha256") || !objectId(read(target, "targetHead")) || !isRecord(refs) ||
66
- Object.values(refs).some((ref) => !isRecord(ref) || !objectId(read(ref, "objectId")) || (read(ref, "peeledCommitId") !== null && !objectId(read(ref, "peeledCommitId")))))
67
- throw new Error("Invalid Reviewer construction or target identity");
68
- const expectedAxes = legs.map((leg) => read(leg, "axis"));
69
- if (expectedAxes[0] !== "standards" || (expectedAxes.length === 2 && expectedAxes[1] !== "spec") || expectedAxes.length < 1 || expectedAxes.length > 2)
70
- throw new Error("Invalid Reviewer accepted-leg projection");
71
- if (!isRecord(outcomes) || !isRecord(reports))
72
- throw new Error("Accepted Reviewer batch lacks outcomes or reports");
73
- const outcomeAxes = Object.keys(outcomes).filter(axis => axis === "standards" || axis === "spec");
74
- if (outcomeAxes.length !== expectedAxes.length || outcomeAxes.some((axis, index) => axis !== expectedAxes[index]))
75
- throw new Error("Reviewer outcomes must exactly cover accepted legs in canonical order");
76
- for (const [index, axisValue] of expectedAxes.entries()) {
77
- const axis = axisValue;
78
- const outcome = read(outcomes, axis);
79
- if (!isRecord(outcome))
80
- throw new Error("Reviewer accepted leg lacks outcome");
81
- const expectedPrompt = read(read(legs[index], "prompt"), "text");
82
- const actualPrompt = read(read(outcome, "prompt"), "text");
83
- if (expectedPrompt !== actualPrompt)
84
- throw new Error("Reviewer outcome prompt disagrees with accepted leg");
85
- const status = read(outcome, "status");
86
- const report = read(reports, axis);
87
- if (status === "successful" && report === undefined)
88
- throw new Error("Successful Reviewer outcome lacks report");
89
- if (status === "failed" && report !== undefined)
90
- throw new Error("Failed Reviewer outcome cannot bind a report");
91
- }
92
- // One read inside the existing accepted-leg consistency cycle — not a second validator.
93
- // launched ⇔ Standards+Spec; skipped-missing ⇔ Standards only.
94
- const specDisposition = read(output, "specDisposition");
95
- if (specDisposition === "launched") {
96
- if (expectedAxes.length !== 2 || expectedAxes[0] !== "standards" || expectedAxes[1] !== "spec") {
97
- throw new Error("Reviewer specDisposition launched requires Standards+Spec accepted legs");
98
- }
99
- }
100
- else if (specDisposition === "skipped-missing") {
101
- if (expectedAxes.length !== 1 || expectedAxes[0] !== "standards") {
102
- throw new Error("Reviewer specDisposition skipped-missing requires Standards-only accepted legs");
103
- }
104
- }
105
- else if (specDisposition !== undefined) {
106
- throw new Error("Invalid Reviewer specDisposition");
107
- }
36
+ function validateRuntimeReviewerReceipt(output) {
37
+ const status = read(output, "status");
38
+ const acceptedBatch = read(output, "acceptedBatch");
39
+ const identities = read(output, "identities");
40
+ const construction = read(identities, "construction");
41
+ const target = read(identities, "target");
42
+ const reports = read(output, "reports");
43
+ const outcomes = read(output, "outcomes");
44
+ const legs = read(acceptedBatch, "legs");
45
+ if (acceptedBatch !== void 0 || construction !== void 0 || target !== void 0) {
46
+ if (!isRecord(acceptedBatch) || !isRecord(construction) || !isRecord(target) || !Array.isArray(legs))
47
+ throw new Error("Incomplete Reviewer accepted-batch identity");
48
+ const objectFormat = read(target, "objectFormat");
49
+ const objectId = (value) => typeof value === "string" && new RegExp(objectFormat === "sha1" ? "^[0-9a-f]{40}$" : "^[0-9a-f]{64}$").test(value);
50
+ const refs = read(target, "refs");
51
+ const skillText = read(read(identities, "canonicalSkill"), "text");
52
+ if (typeof skillText !== "string" || read(construction, "recipe") !== "reviewer-common-bundle-v1" || objectFormat !== "sha1" && objectFormat !== "sha256" || !objectId(read(target, "targetHead")) || !isRecord(refs) || Object.values(refs).some((ref) => !isRecord(ref) || !objectId(read(ref, "objectId")) || read(ref, "peeledCommitId") !== null && !objectId(read(ref, "peeledCommitId"))))
53
+ throw new Error("Invalid Reviewer construction or target identity");
54
+ const expectedAxes = legs.map((leg) => read(leg, "axis"));
55
+ if (expectedAxes[0] !== "standards" || expectedAxes.length === 2 && expectedAxes[1] !== "spec" || expectedAxes.length < 1 || expectedAxes.length > 2)
56
+ throw new Error("Invalid Reviewer accepted-leg projection");
57
+ if (!isRecord(outcomes) || !isRecord(reports)) throw new Error("Accepted Reviewer batch lacks outcomes or reports");
58
+ const outcomeAxes = Object.keys(outcomes).filter((axis) => axis === "standards" || axis === "spec");
59
+ if (outcomeAxes.length !== expectedAxes.length || outcomeAxes.some((axis, index) => axis !== expectedAxes[index]))
60
+ throw new Error("Reviewer outcomes must exactly cover accepted legs in canonical order");
61
+ for (const [index, axisValue] of expectedAxes.entries()) {
62
+ const axis = axisValue;
63
+ const outcome = read(outcomes, axis);
64
+ if (!isRecord(outcome)) throw new Error("Reviewer accepted leg lacks outcome");
65
+ const expectedPrompt = read(read(legs[index], "prompt"), "text");
66
+ const actualPrompt = read(read(outcome, "prompt"), "text");
67
+ if (expectedPrompt !== actualPrompt) throw new Error("Reviewer outcome prompt disagrees with accepted leg");
68
+ const status2 = read(outcome, "status");
69
+ const report = read(reports, axis);
70
+ if (status2 === "successful" && report === void 0)
71
+ throw new Error("Successful Reviewer outcome lacks report");
72
+ if (status2 === "failed" && report !== void 0) throw new Error("Failed Reviewer outcome cannot bind a report");
108
73
  }
109
- return output;
110
- }
111
- /** Project thin submitted intent onto runtime enrichment without comparing runtime-owned fields. */
112
- export function projectReviewerIntentToReceipt(intentValue, receiptValue) {
113
- const intent = validateReviewerIntent(intentValue);
114
- const receipt = validateRuntimeReviewerReceipt(receiptValue);
115
- const receiptStatus = String(receipt.status);
116
- if (receiptStatus !== intent.status || (intent.status === "completed" ? receipt.diagnostic !== undefined : receipt.diagnostic !== intent.diagnostic)) {
117
- throw new Error("Reviewer intent and runtime receipt disagree");
74
+ const specDisposition = read(output, "specDisposition");
75
+ if (specDisposition === "launched") {
76
+ if (expectedAxes.length !== 2 || expectedAxes[0] !== "standards" || expectedAxes[1] !== "spec") {
77
+ throw new Error("Reviewer specDisposition launched requires Standards+Spec accepted legs");
78
+ }
79
+ } else if (specDisposition === "skipped-missing") {
80
+ if (expectedAxes.length !== 1 || expectedAxes[0] !== "standards") {
81
+ throw new Error("Reviewer specDisposition skipped-missing requires Standards-only accepted legs");
82
+ }
83
+ } else if (specDisposition !== void 0) {
84
+ throw new Error("Invalid Reviewer specDisposition");
118
85
  }
119
- return receipt;
86
+ }
87
+ return output;
88
+ }
89
+ function projectReviewerIntentToReceipt(intentValue, receiptValue) {
90
+ const intent = validateReviewerIntent(intentValue);
91
+ const receipt = validateRuntimeReviewerReceipt(receiptValue);
92
+ const receiptStatus = String(receipt.status);
93
+ if (receiptStatus !== intent.status || (intent.status === "completed" ? receipt.diagnostic !== void 0 : receipt.diagnostic !== intent.diagnostic)) {
94
+ throw new Error("Reviewer intent and runtime receipt disagree");
95
+ }
96
+ return receipt;
120
97
  }
98
+ export {
99
+ REVIEWER_ACCEPTED_TEXT,
100
+ REVIEWER_OUTPUT_TOOL_NAME,
101
+ projectReviewerIntentToReceipt,
102
+ validateReviewerIntent,
103
+ validateRuntimeReviewerReceipt
104
+ };
@@ -1,101 +1,73 @@
1
- /**
2
- * Package-owned shared infrastructure-failure declaration for every primary
3
- * packaged-role output tool (#541).
4
- *
5
- * One module owns what the judge mandates be shared (not reimplemented per
6
- * seat): the typed `infrastructureFailure.diagnostic` declaration composed into
7
- * each output tool's schema, and the single early host `failInfrastructure`
8
- * call each output `execute` makes before any role business validation / gate /
9
- * audit / ledger / Git work. The accepted status sets are intentionally NOT
10
- * extended: an infra declaration fails BEFORE accepted validation, never
11
- * becomes an accepted receipt. The diagnostic is carried verbatim on the thrown
12
- * Error so settlement keeps the original cause (kind=failure, exit 1).
13
- */
14
1
  import { Type } from "typebox";
15
- export const INFRASTRUCTURE_FAILURE_DECLARATION_KEY = "infrastructureFailure";
16
- export const INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY = "diagnostic";
17
- /** Shared typed declaration fragment: `infrastructureFailure.diagnostic` = non-empty string. */
18
- const infrastructureFailureDeclarationSchema = Type.Object({
19
- [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: Type.Object({
2
+ const INFRASTRUCTURE_FAILURE_DECLARATION_KEY = "infrastructureFailure";
3
+ const INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY = "diagnostic";
4
+ const infrastructureFailureDeclarationSchema = Type.Object(
5
+ {
6
+ [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: Type.Object(
7
+ {
20
8
  [INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY]: Type.String({
21
- minLength: 1,
22
- description: "非空基础设施失败诊断",
23
- }),
24
- }, {
9
+ minLength: 1,
10
+ description: "\u975E\u7A7A\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8BCA\u65AD"
11
+ })
12
+ },
13
+ {
25
14
  additionalProperties: true,
26
- description: "基础设施失败声明",
27
- }),
28
- }, { additionalProperties: true });
29
- /**
30
- * Compose the shared infrastructure-failure declaration into an open output
31
- * tool-object schema. Returns an open object (additionalProperties: true,
32
- * required: []) with the base schema's properties plus the shared declaration.
33
- * Static typing is preserved on the base (`as S`), so existing
34
- * `Static<typeof ...>` derived parameter types are unchanged.
35
- */
36
- export function withInfrastructureFailureDeclaration(schema) {
37
- const baseProperties = schema
38
- .properties;
39
- const properties = {
40
- ...(baseProperties ?? {}),
41
- [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY],
42
- };
43
- const object = Type.Object(properties, { additionalProperties: true });
44
- object.required = [];
45
- return object;
15
+ description: "\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u58F0\u660E"
16
+ }
17
+ )
18
+ },
19
+ { additionalProperties: true }
20
+ );
21
+ function withInfrastructureFailureDeclaration(schema) {
22
+ const baseProperties = schema.properties;
23
+ const properties = {
24
+ ...baseProperties ?? {},
25
+ [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
26
+ };
27
+ const object = Type.Object(properties, { additionalProperties: true });
28
+ object.required = [];
29
+ return object;
46
30
  }
47
- /** Safe recognition of the typed declaration; non-shapes / hostile input fail closed. */
48
31
  function isInfrastructureFailureDeclaration(parameters) {
49
- if (parameters === null ||
50
- typeof parameters !== "object" ||
51
- Array.isArray(parameters)) {
52
- return false;
53
- }
54
- const record = parameters;
55
- if (!Object.hasOwn(record, INFRASTRUCTURE_FAILURE_DECLARATION_KEY))
56
- return false;
57
- const declaration = record[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
58
- if (declaration === null ||
59
- typeof declaration !== "object" ||
60
- Array.isArray(declaration)) {
61
- return false;
62
- }
63
- const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
64
- return typeof diagnostic === "string" && diagnostic.trim().length > 0;
32
+ if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
33
+ return false;
34
+ }
35
+ const record = parameters;
36
+ if (!Object.hasOwn(record, INFRASTRUCTURE_FAILURE_DECLARATION_KEY)) return false;
37
+ const declaration = record[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
38
+ if (declaration === null || typeof declaration !== "object" || Array.isArray(declaration)) {
39
+ return false;
40
+ }
41
+ const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
42
+ return typeof diagnostic === "string" && diagnostic.trim().length > 0;
65
43
  }
66
- /** Non-empty trimmed diagnostic from the declaration, else undefined. */
67
44
  function infrastructureFailureDiagnostic(parameters) {
68
- if (!isInfrastructureFailureDeclaration(parameters))
69
- return undefined;
70
- const declaration = parameters[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
71
- const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
72
- return typeof diagnostic === "string" ? diagnostic.trim() : undefined;
45
+ if (!isInfrastructureFailureDeclaration(parameters)) return void 0;
46
+ const declaration = parameters[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
47
+ const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
48
+ return typeof diagnostic === "string" ? diagnostic.trim() : void 0;
73
49
  }
74
- /** diagnostic → Error, name stamped so the host error identity is observable. */
75
50
  function infrastructureFailureError(diagnostic) {
76
- const error = new Error(diagnostic);
77
- error.name = "InfrastructureFailure";
78
- return error;
51
+ const error = new Error(diagnostic);
52
+ error.name = "InfrastructureFailure";
53
+ return error;
79
54
  }
80
- /**
81
- * The one early call for every terminating output `execute`: if the parameters
82
- * carry the infra declaration, hand the diagnostic error to the shared host
83
- * `failInfrastructure` seam (which aborts the run). No-op otherwise.
84
- *
85
- * #641 chain②: an optional seat-owned bounce hook may intercept the
86
- * declaration first — when the seat can machine-verify a lawful normal
87
- * completion, it returns a correctable error and the declaration is treated as
88
- * model misuse (交件契约封驳) instead of a host failure. Returning undefined
89
- * keeps the shared failure path.
90
- */
91
- export function failOnInfrastructureFailureDeclaration(parameters, hostActions, ctx, toolCallId, bounceInfrastructureDeclaration) {
92
- const diagnostic = infrastructureFailureDiagnostic(parameters);
93
- if (diagnostic === undefined)
94
- return;
95
- if (bounceInfrastructureDeclaration !== undefined) {
96
- const bounce = bounceInfrastructureDeclaration(parameters, toolCallId, ctx);
97
- if (bounce !== undefined)
98
- throw bounce;
99
- }
100
- hostActions.failInfrastructure(infrastructureFailureError(diagnostic), ctx, toolCallId);
55
+ function failOnInfrastructureFailureDeclaration(parameters, hostActions, ctx, toolCallId, bounceInfrastructureDeclaration) {
56
+ const diagnostic = infrastructureFailureDiagnostic(parameters);
57
+ if (diagnostic === void 0) return;
58
+ if (bounceInfrastructureDeclaration !== void 0) {
59
+ const bounce = bounceInfrastructureDeclaration(parameters, toolCallId, ctx);
60
+ if (bounce !== void 0) throw bounce;
61
+ }
62
+ hostActions.failInfrastructure(
63
+ infrastructureFailureError(diagnostic),
64
+ ctx,
65
+ toolCallId
66
+ );
101
67
  }
68
+ export {
69
+ INFRASTRUCTURE_FAILURE_DECLARATION_KEY,
70
+ INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY,
71
+ failOnInfrastructureFailureDeclaration,
72
+ withInfrastructureFailureDeclaration
73
+ };
@@ -1,13 +1,32 @@
1
- /** Package-owned independent Coder and Fixer output leaves. */
2
- export { FIXER_ACCEPTED_TEXT, FIXER_OUTPUT_TOOL_NAME, fixerOutputSchema, validateFixerOutput, validateFixerOutputForPacket, } from "./fixer-output.js";
3
- export { fixerPrerequisiteSchema, fixerPrerequisitesSchema, parseFixerPrerequisites, validateFixerPrerequisites } from "./fixer-packet.js";
4
- import { validateFixerOutput } from "./fixer-output.js";
5
- export const CODER_OUTPUT_TOOL_NAME = "ak_coder_output";
6
- export const CODER_ACCEPTED_TEXT = "将作监回执已接受";
7
- export function validateAcceptedCoderDetails(output) {
8
- return output;
1
+ import {
2
+ FIXER_ACCEPTED_TEXT,
3
+ FIXER_OUTPUT_TOOL_NAME,
4
+ fixerOutputSchema,
5
+ validateFixerOutput,
6
+ validateFixerOutputForPacket
7
+ } from "./fixer-output.js";
8
+ import { fixerPrerequisiteSchema, fixerPrerequisitesSchema, parseFixerPrerequisites, validateFixerPrerequisites } from "./fixer-packet.js";
9
+ import { validateFixerOutput as validateFixerOutput2 } from "./fixer-output.js";
10
+ const CODER_OUTPUT_TOOL_NAME = "ak_coder_output";
11
+ const CODER_ACCEPTED_TEXT = "\u5C06\u4F5C\u76D1\u56DE\u6267\u5DF2\u63A5\u53D7";
12
+ function validateAcceptedCoderDetails(output) {
13
+ return output;
9
14
  }
10
- /** Structural production validator for an accepted current leaf. */
11
- export function validateAcceptedWorkerDetails(output, roleLabel = "Coder") {
12
- return roleLabel === "Fixer" ? validateFixerOutput(output) : validateAcceptedCoderDetails(output);
15
+ function validateAcceptedWorkerDetails(output, roleLabel = "Coder") {
16
+ return roleLabel === "Fixer" ? validateFixerOutput2(output) : validateAcceptedCoderDetails(output);
13
17
  }
18
+ export {
19
+ CODER_ACCEPTED_TEXT,
20
+ CODER_OUTPUT_TOOL_NAME,
21
+ FIXER_ACCEPTED_TEXT,
22
+ FIXER_OUTPUT_TOOL_NAME,
23
+ fixerOutputSchema,
24
+ fixerPrerequisiteSchema,
25
+ fixerPrerequisitesSchema,
26
+ parseFixerPrerequisites,
27
+ validateAcceptedCoderDetails,
28
+ validateAcceptedWorkerDetails,
29
+ validateFixerOutput,
30
+ validateFixerOutputForPacket,
31
+ validateFixerPrerequisites
32
+ };
@@ -1,105 +1,69 @@
1
- /**
2
- * Packaged engine method-material seam (#356 T1 / ADR 0069 / #376).
3
- * Engine names are owner pool-directive labels — not a closed material catalog.
4
- * Material body is optional data for the LLM, not a code contract.
5
- * Only path-safety syntax is checked at real I/O seams.
6
- */
7
1
  import { existsSync, readdirSync } from "node:fs";
8
2
  import { join } from "node:path";
9
3
  const ENGINE_MATERIAL_RELATIVE_ROOT = "resources/engines";
10
- /** Non-empty, trimmed; reject only real path hazards at the I/O seam. */
11
- export function isEngineNameSyntax(name) {
12
- if (typeof name !== "string")
13
- return false;
14
- if (name.length === 0 || name.trim() !== name)
15
- return false;
16
- // Exact "." / ".." are directory aliases; consecutive dots inside a label are not.
17
- if (name === "." || name === "..")
18
- return false;
19
- if (name.includes("/") || name.includes("\\") || name.includes("\0"))
20
- return false;
21
- return true;
4
+ function isEngineNameSyntax(name) {
5
+ if (typeof name !== "string") return false;
6
+ if (name.length === 0 || name.trim() !== name) return false;
7
+ if (name === "." || name === "..") return false;
8
+ if (name.includes("/") || name.includes("\\") || name.includes("\0")) return false;
9
+ return true;
22
10
  }
23
- export function engineMaterialRelativeDirectory() {
24
- return ENGINE_MATERIAL_RELATIVE_ROOT;
11
+ function engineMaterialRelativeDirectory() {
12
+ return ENGINE_MATERIAL_RELATIVE_ROOT;
25
13
  }
26
- export function resolveEngineMaterialDirectory(packageRoot) {
27
- return join(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
14
+ function resolveEngineMaterialDirectory(packageRoot) {
15
+ return join(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
28
16
  }
29
- /**
30
- * Enumerate packaged engine notes stems (discovery only — not a legal-name gate).
31
- * Only `*.md` stems that pass name syntax are listed.
32
- */
33
- export function listEngineMaterialNames(packageRoot) {
34
- const dir = resolveEngineMaterialDirectory(packageRoot);
35
- if (!existsSync(dir))
36
- return Object.freeze([]);
37
- const names = readdirSync(dir)
38
- .filter((entry) => entry.endsWith(".md"))
39
- .map((entry) => entry.slice(0, -".md".length))
40
- .filter((stem) => isEngineNameSyntax(stem))
41
- .sort();
42
- return Object.freeze([...names]);
17
+ function listEngineMaterialNames(packageRoot) {
18
+ const dir = resolveEngineMaterialDirectory(packageRoot);
19
+ if (!existsSync(dir)) return Object.freeze([]);
20
+ const names = readdirSync(dir).filter((entry) => entry.endsWith(".md")).map((entry) => entry.slice(0, -".md".length)).filter((stem) => isEngineNameSyntax(stem)).sort();
21
+ return Object.freeze([...names]);
43
22
  }
44
- /**
45
- * Build the packaged notes path for a syntax-legal engine name.
46
- * Does not require the file to exist (material is optional data).
47
- */
48
- export function resolveEngineMaterialPath(packageRoot, name) {
49
- const legal = assertLegalEngineName(name);
50
- return join(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
23
+ function resolveEngineMaterialPath(packageRoot, name) {
24
+ const legal = assertLegalEngineName(name);
25
+ return join(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
51
26
  }
52
- /**
53
- * Path-safety syntax gate for engine labels at real I/O seams.
54
- * Returns the canonical name on success; throws Error on illegal syntax.
55
- * Does not consult any material catalog (ADR 0069 pool-directive axis).
56
- */
57
- export function assertLegalEngineName(name) {
58
- if (!isEngineNameSyntax(name)) {
59
- throw new Error(`illegal engine name: ${name}`);
60
- }
61
- return name;
27
+ function assertLegalEngineName(name) {
28
+ if (!isEngineNameSyntax(name)) {
29
+ throw new Error(`illegal engine name: ${name}`);
30
+ }
31
+ return name;
62
32
  }
63
- /**
64
- * Resolve optional engine options into session material coordinates.
65
- * No engine → undefined (caller keeps default prompt bytes).
66
- * Engine with packaged notes → name + absolute material path.
67
- * Engine without notes → name only (pass-through; no warning).
68
- */
69
- export function engineSessionMaterialFromOptions(options) {
70
- if (options.engine === undefined)
71
- return undefined;
72
- if (options.packageRoot === undefined || options.packageRoot.trim() === "") {
73
- throw new Error("packageRoot is required when engine is configured");
74
- }
75
- const name = assertLegalEngineName(options.engine);
76
- const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
77
- if (existsSync(materialPath)) {
78
- return Object.freeze({ name, materialPath });
79
- }
80
- return Object.freeze({ name });
33
+ function engineSessionMaterialFromOptions(options) {
34
+ if (options.engine === void 0) return void 0;
35
+ if (options.packageRoot === void 0 || options.packageRoot.trim() === "") {
36
+ throw new Error("packageRoot is required when engine is configured");
37
+ }
38
+ const name = assertLegalEngineName(options.engine);
39
+ const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
40
+ if (existsSync(materialPath)) {
41
+ return Object.freeze({ name, materialPath });
42
+ }
43
+ return Object.freeze({ name });
81
44
  }
82
- /**
83
- * Append engine method-material delivery to session initial material lines.
84
- * No engine → identity copy (byte-stable when joined the same way).
85
- * With notes → Chinese neutral handbook header + engine name + absolute material path.
86
- * Name only → engine name coordinate only (no handbook header, no path, no warning).
87
- * Never delivers material body.
88
- */
89
- export function appendEngineSessionMaterial(lines, engineMaterial) {
90
- if (engineMaterial === undefined) {
91
- return [...lines];
92
- }
93
- const out = [...lines];
94
- out.push("");
95
- if (engineMaterial.materialPath !== undefined) {
96
- out.push("本次配置的劳务引擎及其手册:");
97
- out.push(`- engine: ${engineMaterial.name}`);
98
- out.push(`- ${engineMaterial.materialPath}`);
99
- }
100
- else {
101
- // Name-only pass-through: no packaged bytes to claim as handbook.
102
- out.push(`- engine: ${engineMaterial.name}`);
103
- }
104
- return out;
45
+ function appendEngineSessionMaterial(lines, engineMaterial) {
46
+ if (engineMaterial === void 0) {
47
+ return [...lines];
48
+ }
49
+ const out = [...lines];
50
+ out.push("");
51
+ if (engineMaterial.materialPath !== void 0) {
52
+ out.push("\u672C\u6B21\u914D\u7F6E\u7684\u52B3\u52A1\u5F15\u64CE\u53CA\u5176\u624B\u518C\uFF1A");
53
+ out.push(`- engine: ${engineMaterial.name}`);
54
+ out.push(`- ${engineMaterial.materialPath}`);
55
+ } else {
56
+ out.push(`- engine: ${engineMaterial.name}`);
57
+ }
58
+ return out;
105
59
  }
60
+ export {
61
+ appendEngineSessionMaterial,
62
+ assertLegalEngineName,
63
+ engineMaterialRelativeDirectory,
64
+ engineSessionMaterialFromOptions,
65
+ isEngineNameSyntax,
66
+ listEngineMaterialNames,
67
+ resolveEngineMaterialDirectory,
68
+ resolveEngineMaterialPath
69
+ };