@akagilnc/pi-workflow-roles 0.1.3414 → 0.1.3445
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 +12 -9
- 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 +239 -154
- 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/navigator-attendance.js +0 -6
- package/dist/navigator-session-contracts.js +6 -10
- 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/pi/in-process-session.js +2 -12
- package/dist/public-cli/config.js +403 -485
- package/dist/public-cli/main.js +1226 -561
- 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/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 +18 -10
- 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/navigator-attendance.ts +0 -6
- package/src/navigator-session-contracts.ts +15 -14
- package/src/pi/durable-principal.ts +6 -0
- package/src/pi/in-process-session.ts +10 -17
- package/src/public-cli/cli.ts +2 -14
- package/src/public-cli/config.ts +6 -28
- package/src/public-cli/inspector-run.ts +21 -10
- package/src/public-cli/invocation.ts +8 -25
- package/src/public-cli/notary-run.ts +21 -4
- package/src/public-cli/option-definitions.ts +2 -2
- package/src/public-cli/post-admission.ts +333 -42
- package/src/public-cli/registry.ts +2 -8
- package/src/public-cli/run-lifecycle.ts +1 -3
- package/src/public-cli/settlement.ts +266 -81
- package/src/session-opening-materials.ts +4 -2
- package/src/ticket-seat-memory.ts +454 -0
package/dist/merger-contracts.js
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
20
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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) {
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!Array.isArray(
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
};
|
|
@@ -396,9 +396,6 @@ ${text}
|
|
|
396
396
|
try {
|
|
397
397
|
await created.setModel?.(modelSetting, model.thinkingLevel);
|
|
398
398
|
if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
|
|
399
|
-
if (created.getThinkingLevel?.() !== void 0 && created.getThinkingLevel() !== model.thinkingLevel) {
|
|
400
|
-
throw new NavigatorUnavailableError("thinking", `Navigator thinking level ${model.thinkingLevel} is unavailable for ${modelSetting}`);
|
|
401
|
-
}
|
|
402
399
|
created.appendEntry(INVOCATION_ENTRY, { invocationId, role: options.role, phase: options.phase, subjectKey });
|
|
403
400
|
if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
|
|
404
401
|
session = created;
|
|
@@ -413,9 +410,6 @@ ${text}
|
|
|
413
410
|
} else {
|
|
414
411
|
try {
|
|
415
412
|
await session.setModel?.(modelSetting, model.thinkingLevel);
|
|
416
|
-
if (session.getThinkingLevel?.() !== void 0 && session.getThinkingLevel() !== model.thinkingLevel) {
|
|
417
|
-
throw new NavigatorUnavailableError("thinking", `Navigator thinking level ${model.thinkingLevel} is unavailable for ${modelSetting}`);
|
|
418
|
-
}
|
|
419
413
|
} catch (error) {
|
|
420
414
|
throw error instanceof NavigatorUnavailableError ? error : navigatorUnavailableError("session", error);
|
|
421
415
|
}
|
|
@@ -151,33 +151,29 @@ async function writeNavigatorModelSetting(model, path = navigatorModelSettingPat
|
|
|
151
151
|
function parseNavigatorModelSetting(value) {
|
|
152
152
|
const slash = value.indexOf("/");
|
|
153
153
|
if (slash <= 0 || slash === value.length - 1) {
|
|
154
|
-
throw new Error("Navigator model setting must be provider/model[:
|
|
154
|
+
throw new Error("Navigator model setting must be provider/model[:thinking]");
|
|
155
155
|
}
|
|
156
156
|
const provider = value.slice(0, slash);
|
|
157
157
|
const modelWithThinking = value.slice(slash + 1);
|
|
158
158
|
const colon = modelWithThinking.lastIndexOf(":");
|
|
159
159
|
const suffix = colon < 0 ? void 0 : modelWithThinking.slice(colon + 1);
|
|
160
|
-
if (suffix !== void 0 && suffix !== "max") {
|
|
161
|
-
throw new Error("Navigator model setting must use :max or omit the thinking suffix");
|
|
162
|
-
}
|
|
163
160
|
const model = colon < 0 ? modelWithThinking : modelWithThinking.slice(0, colon);
|
|
164
161
|
if (model === "") throw new Error("Navigator model setting must include a model");
|
|
165
|
-
return { provider, model
|
|
162
|
+
return suffix === void 0 ? { provider, model } : { provider, model, thinkingLevel: suffix };
|
|
166
163
|
}
|
|
167
164
|
async function resolveNavigatorSeatSelection(context, modelSettingPath, defaultModelSettingPath) {
|
|
168
165
|
const runDirectory = auditorRunDirectory(context);
|
|
169
166
|
if (runDirectory !== void 0) {
|
|
170
167
|
try {
|
|
171
168
|
const selection = await readInstitutionalSeatSelection(runDirectory, "navigator");
|
|
172
|
-
const thinkingLevel = selection.thinking === "max" ? "max" : "off";
|
|
173
169
|
return {
|
|
174
170
|
selection: {
|
|
175
171
|
provider: selection.provider,
|
|
176
172
|
model: selection.model,
|
|
177
173
|
...selection.thinking === void 0 ? {} : { thinking: selection.thinking }
|
|
178
174
|
},
|
|
179
|
-
configuredLabel: `${selection.provider}/${selection.model}
|
|
180
|
-
thinkingLevel
|
|
175
|
+
configuredLabel: selection.thinking === void 0 ? `${selection.provider}/${selection.model}` : `${selection.provider}/${selection.model}:${selection.thinking}`,
|
|
176
|
+
...selection.thinking === void 0 ? {} : { thinkingLevel: selection.thinking }
|
|
181
177
|
};
|
|
182
178
|
} catch (error) {
|
|
183
179
|
if (error instanceof InstitutionalResolutionError && (error.reason === "missing-page" || error.reason === "missing-seat")) {
|
|
@@ -202,10 +198,10 @@ async function resolveNavigatorSeatSelection(context, modelSettingPath, defaultM
|
|
|
202
198
|
selection: {
|
|
203
199
|
provider: parsed.provider,
|
|
204
200
|
model: parsed.model,
|
|
205
|
-
thinking: parsed.thinkingLevel
|
|
201
|
+
...parsed.thinkingLevel === void 0 ? {} : { thinking: parsed.thinkingLevel }
|
|
206
202
|
},
|
|
207
203
|
configuredLabel: configured,
|
|
208
|
-
thinkingLevel: parsed.thinkingLevel
|
|
204
|
+
...parsed.thinkingLevel === void 0 ? {} : { thinkingLevel: parsed.thinkingLevel }
|
|
209
205
|
};
|
|
210
206
|
}
|
|
211
207
|
export {
|
package/dist/notary-contracts.js
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
37
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
38
|
}
|
|
42
39
|
function asStringArray(value) {
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
+
};
|
package/dist/open-tool-schema.js
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
function described(name, schema) {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
9
|
-
|
|
7
|
+
const { description: _description, ...semantic } = schema;
|
|
8
|
+
return JSON.stringify(semantic);
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
13
|
+
return Array.isArray(value) ? value.filter((item) => item !== null && typeof item === "object") : [];
|
|
17
14
|
}
|
|
18
15
|
function strings(value) {
|
|
19
|
-
|
|
16
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
};
|