@tangle-network/agent-interface 0.27.2 → 0.29.0
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/agent-candidate-artifact-schema.d.ts +0 -3
- package/dist/agent-candidate-artifact-schema.js +0 -2
- package/dist/agent-candidate-code-schema.d.ts +0 -10
- package/dist/agent-candidate-code-schema.js +0 -1
- package/dist/agent-candidate-execution-plan-schema.d.ts +173 -382
- package/dist/agent-candidate-execution-plan-schema.js +100 -138
- package/dist/agent-candidate-lineage-schema.d.ts +1 -31
- package/dist/agent-candidate-lineage-schema.js +3 -34
- package/dist/agent-candidate-outcome-schema.d.ts +48 -36
- package/dist/agent-candidate-outcome-schema.js +23 -32
- package/dist/agent-candidate-promotion-schema.d.ts +11021 -2411
- package/dist/agent-candidate-promotion-schema.js +495 -109
- package/dist/agent-candidate-receipt-schema.d.ts +260 -344
- package/dist/agent-candidate-receipt-schema.js +82 -11
- package/dist/agent-candidate-schema-common.d.ts +8 -0
- package/dist/agent-candidate-schema-common.js +35 -1
- package/dist/agent-candidate-schema.d.ts +2 -44
- package/dist/agent-candidate-schema.js +3 -29
- package/dist/agent-candidate-task-schema.d.ts +643 -0
- package/dist/agent-candidate-task-schema.js +191 -0
- package/dist/agent-candidate.d.ts +173 -94
- package/dist/agent-candidate.test-fixture.d.ts +0 -32
- package/dist/agent-candidate.test-fixture.js +0 -32
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/profile-diff.d.ts +0 -1
- package/dist/profile-schema.d.ts +9 -0
- package/dist/profile-schema.js +14 -6
- package/package.json +2 -2
- package/dist/agent-candidate-compat.d.ts +0 -1918
- package/dist/agent-candidate-compat.js +0 -340
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { agentCandidateArtifactRefSchema, agentCandidateCapturedArtifactSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, } from "./agent-candidate-artifact-schema.js";
|
|
3
|
-
import { agentCandidateExecutionPlanEvidenceSchema,
|
|
3
|
+
import { agentCandidateExecutionPlanEvidenceSchema, agentCandidateProfileActivationSchema, agentCandidateResolvedModelSchema, } from "./agent-candidate-execution-plan-schema.js";
|
|
4
4
|
import { agentCandidateBenchmarkResultEvidenceSchema, agentCandidateModelSettlementEvidenceSchema, agentCandidateTaskOutcomeEvidenceSchema, } from "./agent-candidate-outcome-schema.js";
|
|
5
5
|
import { gitObjectSchema, isCanonicalJsonValue, isSafeRelativePath, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
6
6
|
import { harnessTypeSchema } from "./harness.js";
|
|
@@ -20,9 +20,36 @@ const ociPlatformSchema = z
|
|
|
20
20
|
variant: z.string().min(1).optional(),
|
|
21
21
|
})
|
|
22
22
|
.strict();
|
|
23
|
+
const benchmarkMaterialEvidenceSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
digest: sha256DigestSchema,
|
|
26
|
+
material: agentCandidateCapturedArtifactSchema,
|
|
27
|
+
})
|
|
28
|
+
.strict()
|
|
29
|
+
.superRefine((evidence, ctx) => {
|
|
30
|
+
if (evidence.material.sha256 !== evidence.digest) {
|
|
31
|
+
ctx.addIssue({
|
|
32
|
+
code: "custom",
|
|
33
|
+
path: ["material", "sha256"],
|
|
34
|
+
message: "benchmark material artifact must match its canonical digest",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (evidence.material.byteLength === 0) {
|
|
38
|
+
ctx.addIssue({
|
|
39
|
+
code: "custom",
|
|
40
|
+
path: ["material", "byteLength"],
|
|
41
|
+
message: "benchmark material artifact must contain canonical bytes",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export const agentCandidateBenchmarkInputEvidenceSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
suite: benchmarkMaterialEvidenceSchema,
|
|
48
|
+
task: benchmarkMaterialEvidenceSchema,
|
|
49
|
+
})
|
|
50
|
+
.strict();
|
|
23
51
|
export const agentCandidateTraceEvidenceSchema = z
|
|
24
52
|
.object({
|
|
25
|
-
schemaVersion: z.literal(1),
|
|
26
53
|
artifact: agentCandidateCapturedArtifactSchema,
|
|
27
54
|
eventCount: z.number().int().positive(),
|
|
28
55
|
modelCallCount: z.number().int().nonnegative(),
|
|
@@ -75,11 +102,11 @@ export const agentCandidateTerminationSchema = z.discriminatedUnion("kind", [
|
|
|
75
102
|
]);
|
|
76
103
|
export const agentCandidateMaterializationReceiptSchema = z
|
|
77
104
|
.object({
|
|
78
|
-
schemaVersion: z.literal(2),
|
|
79
105
|
kind: z.literal("agent-candidate-materialization"),
|
|
80
106
|
digestAlgorithm: z.literal("rfc8785-sha256"),
|
|
81
107
|
bundleDigest: sha256DigestSchema,
|
|
82
|
-
|
|
108
|
+
benchmark: agentCandidateBenchmarkInputEvidenceSchema,
|
|
109
|
+
profileActivation: agentCandidateProfileActivationSchema,
|
|
83
110
|
executionPlan: agentCandidateExecutionPlanEvidenceSchema,
|
|
84
111
|
candidateWorkspace: agentCandidateWorkspaceSnapshotEvidenceSchema.optional(),
|
|
85
112
|
codeKind: z.enum(["disabled", "no-op", "git-patch"]),
|
|
@@ -135,18 +162,28 @@ export const agentCandidateMaterializationReceiptSchema = z
|
|
|
135
162
|
}
|
|
136
163
|
const checks = [
|
|
137
164
|
[
|
|
138
|
-
receipt.bundleDigest === plan.bundleDigest,
|
|
139
|
-
["executionPlan", "material", "bundleDigest"],
|
|
165
|
+
receipt.bundleDigest === plan.runCell.bundleDigest,
|
|
166
|
+
["executionPlan", "material", "runCell", "bundleDigest"],
|
|
140
167
|
"execution plan must bind the receipt bundle",
|
|
141
168
|
],
|
|
142
169
|
[
|
|
143
|
-
receipt.
|
|
170
|
+
receipt.benchmark.suite.digest === plan.runCell.suiteDigest,
|
|
171
|
+
["benchmark", "suite", "digest"],
|
|
172
|
+
"execution plan must bind the captured benchmark suite",
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
receipt.benchmark.task.digest === plan.runCell.taskDigest,
|
|
176
|
+
["benchmark", "task", "digest"],
|
|
177
|
+
"execution plan must bind the captured benchmark task",
|
|
178
|
+
],
|
|
179
|
+
[
|
|
180
|
+
receipt.profileActivation.profilePlan.digest === plan.profile.planDigest,
|
|
144
181
|
["executionPlan", "material", "profile", "planDigest"],
|
|
145
182
|
"execution plan must bind the exact profile plan",
|
|
146
183
|
],
|
|
147
184
|
[
|
|
148
185
|
JSON.stringify(plan.profile.mountPaths) ===
|
|
149
|
-
JSON.stringify(receipt.profilePlan.material.files.map((file) => file.relPath)),
|
|
186
|
+
JSON.stringify(receipt.profileActivation.profilePlan.material.files.map((file) => file.relPath)),
|
|
150
187
|
["executionPlan", "material", "profile", "mountPaths"],
|
|
151
188
|
"execution plan must bind every profile mount path",
|
|
152
189
|
],
|
|
@@ -191,8 +228,8 @@ export const agentCandidateMaterializationReceiptSchema = z
|
|
|
191
228
|
"execution plan must bind the exact uploaded candidate workspace",
|
|
192
229
|
],
|
|
193
230
|
[
|
|
194
|
-
receipt.profilePlan.material.harness === receipt.harness,
|
|
195
|
-
["profilePlan", "material", "harness"],
|
|
231
|
+
receipt.profileActivation.profilePlan.material.harness === receipt.harness,
|
|
232
|
+
["profileActivation", "profilePlan", "material", "harness"],
|
|
196
233
|
"profile plan harness must match materialization",
|
|
197
234
|
],
|
|
198
235
|
];
|
|
@@ -209,12 +246,19 @@ export const agentCandidateMaterializationReceiptSchema = z
|
|
|
209
246
|
});
|
|
210
247
|
export const agentCandidateRunReceiptSchema = z
|
|
211
248
|
.object({
|
|
212
|
-
schemaVersion: z.literal(3),
|
|
213
249
|
kind: z.literal("agent-candidate-run"),
|
|
214
250
|
digestAlgorithm: z.literal("rfc8785-sha256"),
|
|
215
251
|
bundleDigest: sha256DigestSchema,
|
|
252
|
+
runCellDigest: sha256DigestSchema,
|
|
216
253
|
materializationReceiptDigest: sha256DigestSchema,
|
|
217
254
|
executionPlanDigest: sha256DigestSchema,
|
|
255
|
+
timing: z
|
|
256
|
+
.object({
|
|
257
|
+
startedAtMs: z.number().int().nonnegative().safe(),
|
|
258
|
+
endedAtMs: z.number().int().nonnegative().safe(),
|
|
259
|
+
durationMs: z.number().int().nonnegative().safe(),
|
|
260
|
+
})
|
|
261
|
+
.strict(),
|
|
218
262
|
memory: agentCandidateMemoryReceiptSchema,
|
|
219
263
|
trace: agentCandidateTraceEvidenceSchema,
|
|
220
264
|
termination: agentCandidateTerminationSchema,
|
|
@@ -226,6 +270,15 @@ export const agentCandidateRunReceiptSchema = z
|
|
|
226
270
|
})
|
|
227
271
|
.strict()
|
|
228
272
|
.superRefine((receipt, ctx) => {
|
|
273
|
+
if (receipt.timing.endedAtMs < receipt.timing.startedAtMs ||
|
|
274
|
+
receipt.timing.durationMs !==
|
|
275
|
+
receipt.timing.endedAtMs - receipt.timing.startedAtMs) {
|
|
276
|
+
ctx.addIssue({
|
|
277
|
+
code: "custom",
|
|
278
|
+
path: ["timing"],
|
|
279
|
+
message: "run timing must be ordered and internally consistent",
|
|
280
|
+
});
|
|
281
|
+
}
|
|
229
282
|
if (receipt.modelSettlement.material.executionPlanDigest !==
|
|
230
283
|
receipt.executionPlanDigest) {
|
|
231
284
|
ctx.addIssue({
|
|
@@ -234,6 +287,24 @@ export const agentCandidateRunReceiptSchema = z
|
|
|
234
287
|
message: "model settlement must bind the executed plan",
|
|
235
288
|
});
|
|
236
289
|
}
|
|
290
|
+
for (const [index, call] of receipt.modelSettlement.material.calls.entries()) {
|
|
291
|
+
if (call.startedAtMs < receipt.timing.startedAtMs ||
|
|
292
|
+
call.endedAtMs > receipt.timing.endedAtMs) {
|
|
293
|
+
ctx.addIssue({
|
|
294
|
+
code: "custom",
|
|
295
|
+
path: ["modelSettlement", "material", "calls", index],
|
|
296
|
+
message: "model calls must occur within the recorded run",
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (receipt.benchmarkResult.material.grading.timing.startedAtMs <
|
|
301
|
+
receipt.timing.endedAtMs) {
|
|
302
|
+
ctx.addIssue({
|
|
303
|
+
code: "custom",
|
|
304
|
+
path: ["benchmarkResult", "material", "grading", "timing", "startedAtMs"],
|
|
305
|
+
message: "grading must start after candidate execution ends",
|
|
306
|
+
});
|
|
307
|
+
}
|
|
237
308
|
if (receipt.trace.modelCallCount !==
|
|
238
309
|
receipt.modelSettlement.material.usage.modelCalls) {
|
|
239
310
|
ctx.addIssue({
|
|
@@ -6,6 +6,14 @@ export declare const environmentNameSchema: z.ZodString;
|
|
|
6
6
|
export declare const headerNameSchema: z.ZodString;
|
|
7
7
|
export declare const agentCandidateMediaTypeSchema: z.ZodString;
|
|
8
8
|
export declare function sha256Utf8(value: string): Sha256Digest;
|
|
9
|
+
export declare function sha256Bytes(value: Uint8Array): Sha256Digest;
|
|
10
|
+
/** RFC 8785 serialization used by every candidate-producing package. */
|
|
11
|
+
export declare function canonicalCandidateJson(value: unknown): string;
|
|
12
|
+
export declare function canonicalCandidateBytes(value: unknown): Uint8Array;
|
|
13
|
+
export declare function canonicalCandidateDigest(value: unknown): Sha256Digest;
|
|
14
|
+
export declare function omitTopLevelDigest<T extends {
|
|
15
|
+
digest: Sha256Digest;
|
|
16
|
+
}>(value: T): Omit<T, "digest">;
|
|
9
17
|
export declare function isWellFormedUnicode(value: string): boolean;
|
|
10
18
|
export declare function isSafeRelativePath(value: string, allowDot: boolean): boolean;
|
|
11
19
|
export declare function isSafeExecutable(value: string): boolean;
|
|
@@ -33,10 +33,44 @@ export const environmentNameSchema = z.string().regex(environmentNamePattern);
|
|
|
33
33
|
export const headerNameSchema = z.string().regex(headerNamePattern);
|
|
34
34
|
export const agentCandidateMediaTypeSchema = z.string().regex(mediaTypePattern);
|
|
35
35
|
export function sha256Utf8(value) {
|
|
36
|
-
|
|
36
|
+
return sha256Bytes(new TextEncoder().encode(value));
|
|
37
|
+
}
|
|
38
|
+
export function sha256Bytes(value) {
|
|
39
|
+
const bytes = sha256(value);
|
|
37
40
|
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
38
41
|
return `sha256:${hex}`;
|
|
39
42
|
}
|
|
43
|
+
/** RFC 8785 serialization used by every candidate-producing package. */
|
|
44
|
+
export function canonicalCandidateJson(value) {
|
|
45
|
+
if (!isCanonicalJsonValue(value)) {
|
|
46
|
+
throw new Error("candidate document must be finite, acyclic RFC 8785 JSON");
|
|
47
|
+
}
|
|
48
|
+
return serializeCanonicalCandidate(value);
|
|
49
|
+
}
|
|
50
|
+
export function canonicalCandidateBytes(value) {
|
|
51
|
+
return new TextEncoder().encode(canonicalCandidateJson(value));
|
|
52
|
+
}
|
|
53
|
+
export function canonicalCandidateDigest(value) {
|
|
54
|
+
return sha256Bytes(canonicalCandidateBytes(value));
|
|
55
|
+
}
|
|
56
|
+
export function omitTopLevelDigest(value) {
|
|
57
|
+
const { digest: _digest, ...material } = value;
|
|
58
|
+
return material;
|
|
59
|
+
}
|
|
60
|
+
function serializeCanonicalCandidate(value) {
|
|
61
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") {
|
|
62
|
+
return JSON.stringify(value);
|
|
63
|
+
}
|
|
64
|
+
if (typeof value === "string")
|
|
65
|
+
return JSON.stringify(value);
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
return `[${value.map(serializeCanonicalCandidate).join(",")}]`;
|
|
68
|
+
}
|
|
69
|
+
return `{${Object.keys(value)
|
|
70
|
+
.sort()
|
|
71
|
+
.map((key) => `${JSON.stringify(key)}:${serializeCanonicalCandidate(value[key])}`)
|
|
72
|
+
.join(",")}}`;
|
|
73
|
+
}
|
|
40
74
|
export function isWellFormedUnicode(value) {
|
|
41
75
|
for (let index = 0; index < value.length; index++) {
|
|
42
76
|
const code = value.charCodeAt(index);
|
|
@@ -8,7 +8,6 @@ import { z } from "zod";
|
|
|
8
8
|
* compares lowercase `sha256:<hex>` identities before materialization.
|
|
9
9
|
*/
|
|
10
10
|
export declare const agentCandidateBundleSchema: z.ZodObject<{
|
|
11
|
-
schemaVersion: z.ZodLiteral<2>;
|
|
12
11
|
kind: z.ZodLiteral<"agent-candidate-bundle">;
|
|
13
12
|
digestAlgorithm: z.ZodLiteral<"rfc8785-sha256">;
|
|
14
13
|
profile: z.ZodObject<{
|
|
@@ -251,10 +250,6 @@ export declare const agentCandidateBundleSchema: z.ZodObject<{
|
|
|
251
250
|
}, z.core.$strict>;
|
|
252
251
|
code: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
253
252
|
kind: z.ZodLiteral<"disabled">;
|
|
254
|
-
reason: z.ZodEnum<{
|
|
255
|
-
control: "control";
|
|
256
|
-
"not-applicable": "not-applicable";
|
|
257
|
-
}>;
|
|
258
253
|
}, z.core.$strict>, z.ZodObject<{
|
|
259
254
|
kind: z.ZodLiteral<"no-op">;
|
|
260
255
|
reason: z.ZodLiteral<"proposer-no-change">;
|
|
@@ -359,11 +354,9 @@ export declare const agentCandidateBundleSchema: z.ZodObject<{
|
|
|
359
354
|
kind: z.ZodLiteral<"evaluator-task-container">;
|
|
360
355
|
}, z.core.$strict>], "kind">;
|
|
361
356
|
workspace: z.ZodOptional<z.ZodObject<{
|
|
362
|
-
schemaVersion: z.ZodLiteral<2>;
|
|
363
357
|
kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
|
|
364
358
|
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
365
359
|
material: z.ZodObject<{
|
|
366
|
-
schemaVersion: z.ZodLiteral<2>;
|
|
367
360
|
kind: z.ZodLiteral<"agent-candidate-workspace-manifest">;
|
|
368
361
|
files: z.ZodArray<z.ZodObject<{
|
|
369
362
|
path: z.ZodString;
|
|
@@ -419,7 +412,6 @@ export declare const agentCandidateBundleSchema: z.ZodObject<{
|
|
|
419
412
|
}, z.core.$strict>;
|
|
420
413
|
knowledge: z.ZodOptional<z.ZodObject<{
|
|
421
414
|
candidate: z.ZodObject<{
|
|
422
|
-
schemaVersion: z.ZodLiteral<1>;
|
|
423
415
|
kind: z.ZodLiteral<"knowledge-improvement-candidate">;
|
|
424
416
|
runId: z.ZodString;
|
|
425
417
|
candidateId: z.ZodString;
|
|
@@ -430,11 +422,9 @@ export declare const agentCandidateBundleSchema: z.ZodObject<{
|
|
|
430
422
|
promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
431
423
|
}, z.core.$strict>;
|
|
432
424
|
snapshot: z.ZodObject<{
|
|
433
|
-
schemaVersion: z.ZodLiteral<2>;
|
|
434
425
|
kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
|
|
435
426
|
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
436
427
|
material: z.ZodObject<{
|
|
437
|
-
schemaVersion: z.ZodLiteral<2>;
|
|
438
428
|
kind: z.ZodLiteral<"agent-candidate-workspace-manifest">;
|
|
439
429
|
files: z.ZodArray<z.ZodObject<{
|
|
440
430
|
path: z.ZodString;
|
|
@@ -541,39 +531,6 @@ export declare const agentCandidateBundleSchema: z.ZodObject<{
|
|
|
541
531
|
byteLength: z.ZodNumber;
|
|
542
532
|
}, z.core.$strict>>;
|
|
543
533
|
}, z.core.$strict>], "mode">;
|
|
544
|
-
lineage: z.ZodObject<{
|
|
545
|
-
source: z.ZodEnum<{
|
|
546
|
-
optimizer: "optimizer";
|
|
547
|
-
human: "human";
|
|
548
|
-
import: "import";
|
|
549
|
-
compound: "compound";
|
|
550
|
-
}>;
|
|
551
|
-
parentDigests: z.ZodOptional<z.ZodArray<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>>;
|
|
552
|
-
runIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
553
|
-
profileDiffIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
554
|
-
modelSnapshots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
555
|
-
benchmark: z.ZodOptional<z.ZodObject<{
|
|
556
|
-
name: z.ZodString;
|
|
557
|
-
version: z.ZodString;
|
|
558
|
-
splitDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
559
|
-
}, z.core.$strict>>;
|
|
560
|
-
spend: z.ZodOptional<z.ZodObject<{
|
|
561
|
-
proposal: z.ZodObject<{
|
|
562
|
-
costUsd: z.ZodNumber;
|
|
563
|
-
inputTokens: z.ZodNumber;
|
|
564
|
-
outputTokens: z.ZodNumber;
|
|
565
|
-
cachedInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
566
|
-
modelCalls: z.ZodNumber;
|
|
567
|
-
}, z.core.$strict>;
|
|
568
|
-
evaluation: z.ZodObject<{
|
|
569
|
-
costUsd: z.ZodNumber;
|
|
570
|
-
inputTokens: z.ZodNumber;
|
|
571
|
-
outputTokens: z.ZodNumber;
|
|
572
|
-
cachedInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
573
|
-
modelCalls: z.ZodNumber;
|
|
574
|
-
}, z.core.$strict>;
|
|
575
|
-
}, z.core.$strict>>;
|
|
576
|
-
}, z.core.$strict>;
|
|
577
534
|
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
578
535
|
}, z.core.$strict>;
|
|
579
536
|
export * from "./agent-candidate-artifact-schema.js";
|
|
@@ -583,4 +540,5 @@ export * from "./agent-candidate-lineage-schema.js";
|
|
|
583
540
|
export * from "./agent-candidate-outcome-schema.js";
|
|
584
541
|
export * from "./agent-candidate-profile-schema.js";
|
|
585
542
|
export * from "./agent-candidate-receipt-schema.js";
|
|
586
|
-
export
|
|
543
|
+
export * from "./agent-candidate-task-schema.js";
|
|
544
|
+
export { canonicalCandidateBytes, canonicalCandidateDigest, canonicalCandidateJson, omitTopLevelDigest, sha256Bytes, sha256DigestSchema, sha256Utf8, } from "./agent-candidate-schema-common.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { agentCandidateCodeSchema, agentCandidateExecutionSchema } from "./agent-candidate-code-schema.js";
|
|
3
3
|
import { agentCandidateProfileSchema } from "./agent-candidate-profile-schema.js";
|
|
4
|
-
import { agentCandidateKnowledgeSchema,
|
|
4
|
+
import { agentCandidateKnowledgeSchema, agentCandidateMemoryPolicySchema, } from "./agent-candidate-lineage-schema.js";
|
|
5
5
|
import { isCanonicalJsonValue, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
6
6
|
import { canonicalizeHarness } from "./harness.js";
|
|
7
7
|
/**
|
|
@@ -14,7 +14,6 @@ import { canonicalizeHarness } from "./harness.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export const agentCandidateBundleSchema = z
|
|
16
16
|
.object({
|
|
17
|
-
schemaVersion: z.literal(2),
|
|
18
17
|
kind: z.literal("agent-candidate-bundle"),
|
|
19
18
|
digestAlgorithm: z.literal("rfc8785-sha256"),
|
|
20
19
|
profile: agentCandidateProfileSchema,
|
|
@@ -22,7 +21,6 @@ export const agentCandidateBundleSchema = z
|
|
|
22
21
|
execution: agentCandidateExecutionSchema,
|
|
23
22
|
knowledge: agentCandidateKnowledgeSchema.optional(),
|
|
24
23
|
memory: agentCandidateMemoryPolicySchema,
|
|
25
|
-
lineage: agentCandidateLineageSchema,
|
|
26
24
|
digest: sha256DigestSchema,
|
|
27
25
|
})
|
|
28
26
|
.strict()
|
|
@@ -42,13 +40,6 @@ export const agentCandidateBundleSchema = z
|
|
|
42
40
|
message: "execution harness must match the candidate profile preference",
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
|
-
if (bundle.lineage.parentDigests?.includes(bundle.digest)) {
|
|
46
|
-
ctx.addIssue({
|
|
47
|
-
code: "custom",
|
|
48
|
-
path: ["lineage", "parentDigests"],
|
|
49
|
-
message: "a candidate cannot name itself as a parent",
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
43
|
if (bundle.code.kind === "disabled") {
|
|
53
44
|
if (bundle.execution.cwd.workspace !== "task") {
|
|
54
45
|
ctx.addIssue({
|
|
@@ -71,15 +62,6 @@ export const agentCandidateBundleSchema = z
|
|
|
71
62
|
message: "disabled code cannot carry a candidate workspace",
|
|
72
63
|
});
|
|
73
64
|
}
|
|
74
|
-
if (bundle.code.reason === "control" &&
|
|
75
|
-
(bundle.lineage.source === "optimizer" ||
|
|
76
|
-
bundle.lineage.source === "compound")) {
|
|
77
|
-
ctx.addIssue({
|
|
78
|
-
code: "custom",
|
|
79
|
-
path: ["lineage", "source"],
|
|
80
|
-
message: "fixed controls cannot claim proposer lineage",
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
65
|
}
|
|
84
66
|
else {
|
|
85
67
|
const launch = bundle.execution.launch;
|
|
@@ -122,15 +104,6 @@ export const agentCandidateBundleSchema = z
|
|
|
122
104
|
});
|
|
123
105
|
}
|
|
124
106
|
}
|
|
125
|
-
if (bundle.code.kind === "no-op" &&
|
|
126
|
-
bundle.lineage.source !== "optimizer" &&
|
|
127
|
-
bundle.lineage.source !== "compound") {
|
|
128
|
-
ctx.addIssue({
|
|
129
|
-
code: "custom",
|
|
130
|
-
path: ["lineage", "source"],
|
|
131
|
-
message: "proposer no-op candidates require optimizer or compound lineage",
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
107
|
}
|
|
135
108
|
});
|
|
136
109
|
const _bundleSchemaMatchesType = true;
|
|
@@ -142,4 +115,5 @@ export * from "./agent-candidate-lineage-schema.js";
|
|
|
142
115
|
export * from "./agent-candidate-outcome-schema.js";
|
|
143
116
|
export * from "./agent-candidate-profile-schema.js";
|
|
144
117
|
export * from "./agent-candidate-receipt-schema.js";
|
|
145
|
-
export
|
|
118
|
+
export * from "./agent-candidate-task-schema.js";
|
|
119
|
+
export { canonicalCandidateBytes, canonicalCandidateDigest, canonicalCandidateJson, omitTopLevelDigest, sha256Bytes, sha256DigestSchema, sha256Utf8, } from "./agent-candidate-schema-common.js";
|