@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.
- package/dist/archivist-record-entry.js +21 -12
- package/dist/archivist-record-topology.js +20 -0
- package/dist/auditor-dossier-tool.js +67 -76
- package/dist/canonical-json.js +66 -69
- package/dist/compliance-transport.js +99 -86
- package/dist/countersign-contracts.js +23 -25
- package/dist/doctor-contracts.js +169 -145
- package/dist/engine-detour-tool.js +83 -87
- package/dist/engine-detour.js +148 -183
- package/dist/evidence-child-executor.js +10 -1
- package/dist/exact-utf8.js +11 -10
- package/dist/git-object-id.js +10 -5
- package/dist/gleaner-left-contracts.js +33 -35
- package/dist/grok/production-host.js +229 -118
- package/dist/inspector-contracts.js +28 -31
- package/dist/institutional-resolution.js +101 -104
- package/dist/ledger-session-read.js +241 -0
- package/dist/merger-contracts.js +66 -56
- package/dist/notary-contracts.js +91 -100
- package/dist/open-tool-schema.js +32 -31
- package/dist/package-contracts/collector-output.js +56 -43
- package/dist/package-contracts/fixer-output.js +52 -50
- package/dist/package-contracts/fixer-packet.js +67 -64
- package/dist/package-contracts/gatekeeper-output.js +48 -56
- package/dist/package-contracts/judge-output.js +23 -20
- package/dist/package-contracts/navigator-output.js +35 -40
- package/dist/package-contracts/reviewer-output.js +94 -110
- package/dist/package-contracts/terminating-infrastructure.js +62 -90
- package/dist/package-contracts/worker-output.js +30 -11
- package/dist/package-resources/engine-material.js +58 -94
- package/dist/public-cli/config.js +420 -484
- package/dist/public-cli/main.js +1219 -524
- package/dist/public-cli/registry.js +107 -114
- package/dist/receipt-delivery-policy.js +74 -76
- package/dist/session-opening-materials.js +44 -47
- package/dist/sha256.js +5 -3
- package/dist/sitian-appender.js +204 -210
- package/dist/sitian-contracts.js +15 -19
- package/dist/sitian-facade.js +5 -10
- package/dist/sitian-reader.js +37 -46
- package/dist/stream-idle-guard.js +63 -71
- package/dist/ticket-seat-memory.js +244 -0
- package/package.json +1 -1
- package/scripts/build-package.mjs +41 -0
- package/souls/audit-law.md +4 -0
- package/souls/countersign.md +1 -1
- package/souls/gleaner-left.md +1 -1
- package/souls/inspector.md +1 -1
- package/souls/notary.md +1 -1
- package/souls/reviewer.md +1 -1
- package/src/analyst-gate-cycles-read.ts +152 -83
- package/src/analyst-ledger.ts +170 -43
- package/src/archivist-record-entry.ts +32 -11
- package/src/archivist-record-topology.ts +39 -0
- package/src/evidence-child-executor.ts +14 -1
- package/src/grok/production-host.ts +44 -9
- package/src/host-contracts.ts +18 -0
- package/src/host-transition-prior-native.ts +8 -1
- package/src/ledger-session-read.ts +56 -0
- package/src/pi/durable-principal.ts +6 -0
- package/src/public-cli/inspector-run.ts +21 -10
- package/src/public-cli/invocation.ts +4 -20
- package/src/public-cli/notary-run.ts +21 -4
- package/src/public-cli/post-admission.ts +333 -42
- package/src/public-cli/settlement.ts +266 -81
- package/src/session-opening-materials.ts +4 -2
- package/src/ticket-seat-memory.ts +454 -0
|
@@ -1,120 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
5
|
}
|
|
7
6
|
function read(value, key) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
51
|
+
const error = new Error(diagnostic);
|
|
52
|
+
error.name = "InfrastructureFailure";
|
|
53
|
+
return error;
|
|
79
54
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
24
|
-
|
|
11
|
+
function engineMaterialRelativeDirectory() {
|
|
12
|
+
return ENGINE_MATERIAL_RELATIVE_ROOT;
|
|
25
13
|
}
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
function resolveEngineMaterialDirectory(packageRoot) {
|
|
15
|
+
return join(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
28
16
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
+
};
|