@tangle-network/agent-interface 0.19.0 → 0.21.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/README.md +24 -0
- package/dist/agent-candidate-artifact-schema.d.ts +311 -0
- package/dist/agent-candidate-artifact-schema.js +192 -0
- package/dist/agent-candidate-code-schema.d.ts +295 -0
- package/dist/agent-candidate-code-schema.js +185 -0
- package/dist/agent-candidate-execution-plan-schema.d.ts +1193 -0
- package/dist/agent-candidate-execution-plan-schema.js +418 -0
- package/dist/agent-candidate-lineage-schema.d.ts +78 -0
- package/dist/agent-candidate-lineage-schema.js +96 -0
- package/dist/agent-candidate-profile-schema.d.ts +267 -0
- package/dist/agent-candidate-profile-schema.js +125 -0
- package/dist/agent-candidate-receipt-schema.d.ts +1081 -0
- package/dist/agent-candidate-receipt-schema.js +263 -0
- package/dist/agent-candidate-schema-common.d.ts +32 -0
- package/dist/agent-candidate-schema-common.js +251 -0
- package/dist/agent-candidate-schema.d.ts +498 -0
- package/dist/agent-candidate-schema.js +144 -0
- package/dist/agent-candidate.d.ts +518 -0
- package/dist/agent-candidate.js +6 -0
- package/dist/agent-candidate.test-fixture.d.ts +160 -0
- package/dist/agent-candidate.test-fixture.js +151 -0
- package/dist/agent-profile.d.ts +14 -0
- package/dist/harness.d.ts +7 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/interaction.d.ts +4 -4
- package/dist/profile-diff.d.ts +4 -1
- package/dist/profile-diff.js +64 -64
- package/dist/profile-schema.d.ts +19 -0
- package/dist/profile-schema.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { agentCandidateCapturedArtifactSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, } from "./agent-candidate-artifact-schema.js";
|
|
3
|
+
import { agentCandidateContainerSchema, agentCandidateInstructionDeliverySchema, agentCandidateWorkingDirectorySchema, } from "./agent-candidate-code-schema.js";
|
|
4
|
+
import { addDuplicateIssues, agentCandidateConfigValueSchema, environmentConfigSchema, gitObjectSchema, isCanonicalJsonValue, isSafeExecutable, isSafeRelativePath, sameGitObjectFormat, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
5
|
+
import { harnessTypeSchema } from "./harness.js";
|
|
6
|
+
const reasoningEffortSchema = z.enum([
|
|
7
|
+
"none",
|
|
8
|
+
"minimal",
|
|
9
|
+
"low",
|
|
10
|
+
"medium",
|
|
11
|
+
"high",
|
|
12
|
+
"xhigh",
|
|
13
|
+
"ultracode",
|
|
14
|
+
]);
|
|
15
|
+
function isCanonicalAbsolutePath(value) {
|
|
16
|
+
return (value.startsWith("/") &&
|
|
17
|
+
value !== "/" &&
|
|
18
|
+
!value.includes("//") &&
|
|
19
|
+
isSafeRelativePath(value.slice(1), false));
|
|
20
|
+
}
|
|
21
|
+
function pathsOverlap(left, right) {
|
|
22
|
+
return left === right || left.startsWith(`${right}/`) || right.startsWith(`${left}/`);
|
|
23
|
+
}
|
|
24
|
+
export const agentCandidateResolvedModelSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
requested: z.string().min(1),
|
|
27
|
+
provider: z.string().min(1),
|
|
28
|
+
model: z.string().min(1),
|
|
29
|
+
snapshot: z.string().min(1),
|
|
30
|
+
reasoningEffort: reasoningEffortSchema,
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
export const agentCandidateProfilePlanMaterialSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
version: z.literal(1),
|
|
36
|
+
harness: harnessTypeSchema,
|
|
37
|
+
files: z.array(z
|
|
38
|
+
.object({
|
|
39
|
+
relPath: z
|
|
40
|
+
.string()
|
|
41
|
+
.refine((value) => isSafeRelativePath(value, false), "profile-plan file must use a canonical relative path"),
|
|
42
|
+
mode: z.number().int().min(0).max(0o777),
|
|
43
|
+
contentSha256: sha256DigestSchema,
|
|
44
|
+
})
|
|
45
|
+
.strict()),
|
|
46
|
+
env: environmentConfigSchema,
|
|
47
|
+
flags: z.array(agentCandidateConfigValueSchema),
|
|
48
|
+
unsupported: z
|
|
49
|
+
.array(z
|
|
50
|
+
.object({
|
|
51
|
+
dimension: z.string().min(1),
|
|
52
|
+
reason: z.string().min(1),
|
|
53
|
+
})
|
|
54
|
+
.strict())
|
|
55
|
+
.length(0, "sealed candidate materialization cannot omit profile behavior"),
|
|
56
|
+
})
|
|
57
|
+
.strict()
|
|
58
|
+
.superRefine((material, ctx) => {
|
|
59
|
+
addDuplicateIssues(material.files.map((file) => file.relPath), ["files"], ctx);
|
|
60
|
+
for (let index = 1; index < material.files.length; index++) {
|
|
61
|
+
if ((material.files[index - 1]?.relPath ?? "") >=
|
|
62
|
+
(material.files[index]?.relPath ?? "")) {
|
|
63
|
+
ctx.addIssue({
|
|
64
|
+
code: "custom",
|
|
65
|
+
path: ["files", index, "relPath"],
|
|
66
|
+
message: "profile-plan files must be lexicographically sorted",
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!isCanonicalJsonValue(material)) {
|
|
71
|
+
ctx.addIssue({
|
|
72
|
+
code: "custom",
|
|
73
|
+
message: "profile-plan material must contain only RFC 8785 JSON values",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
export const agentCandidateEffectiveMemorySchema = z.discriminatedUnion("mode", [
|
|
78
|
+
z.object({ mode: z.literal("disabled") }).strict(),
|
|
79
|
+
z
|
|
80
|
+
.object({
|
|
81
|
+
mode: z.literal("isolated"),
|
|
82
|
+
scope: z.literal("task"),
|
|
83
|
+
effectiveNamespace: z.string().min(1),
|
|
84
|
+
reset: z
|
|
85
|
+
.object({
|
|
86
|
+
kind: z.literal("fresh"),
|
|
87
|
+
evidence: agentCandidateCapturedArtifactSchema,
|
|
88
|
+
emptyStateDigest: sha256DigestSchema,
|
|
89
|
+
})
|
|
90
|
+
.strict(),
|
|
91
|
+
beforeState: agentCandidateWorkspaceSnapshotEvidenceSchema,
|
|
92
|
+
seedDigest: sha256DigestSchema.optional(),
|
|
93
|
+
})
|
|
94
|
+
.strict()
|
|
95
|
+
.superRefine((memory, ctx) => {
|
|
96
|
+
if (memory.reset.evidence.byteLength === 0) {
|
|
97
|
+
ctx.addIssue({
|
|
98
|
+
code: "custom",
|
|
99
|
+
path: ["reset", "evidence", "byteLength"],
|
|
100
|
+
message: "task-scoped memory requires non-empty fresh-reset evidence",
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
]);
|
|
105
|
+
export const agentCandidateExecutionLimitsSchema = z
|
|
106
|
+
.object({
|
|
107
|
+
timeoutMs: z.number().int().positive(),
|
|
108
|
+
maxSteps: z.number().int().positive(),
|
|
109
|
+
maxModelCalls: z.number().int().nonnegative(),
|
|
110
|
+
maxInputTokens: z.number().int().nonnegative(),
|
|
111
|
+
maxOutputTokens: z.number().int().nonnegative(),
|
|
112
|
+
maxCostUsd: z.number().finite().nonnegative(),
|
|
113
|
+
})
|
|
114
|
+
.strict();
|
|
115
|
+
export const agentCandidateExecutionPlanMaterialSchema = z
|
|
116
|
+
.object({
|
|
117
|
+
schemaVersion: z.literal(1),
|
|
118
|
+
kind: z.literal("agent-candidate-execution-plan-material"),
|
|
119
|
+
bundleDigest: sha256DigestSchema,
|
|
120
|
+
executionId: z.string().min(1),
|
|
121
|
+
attempt: z
|
|
122
|
+
.object({
|
|
123
|
+
number: z.number().int().min(1),
|
|
124
|
+
maxAttempts: z.number().int().min(1),
|
|
125
|
+
retryPolicy: z.enum(["pre-model-infrastructure-only", "none"]),
|
|
126
|
+
})
|
|
127
|
+
.strict(),
|
|
128
|
+
task: z
|
|
129
|
+
.object({
|
|
130
|
+
benchmark: z.string().min(1),
|
|
131
|
+
benchmarkVersion: z.string().min(1),
|
|
132
|
+
taskId: z.string().min(1),
|
|
133
|
+
splitDigest: sha256DigestSchema,
|
|
134
|
+
instruction: z
|
|
135
|
+
.object({
|
|
136
|
+
encoding: z.literal("utf8"),
|
|
137
|
+
sha256: sha256DigestSchema,
|
|
138
|
+
byteLength: z.number().int().positive(),
|
|
139
|
+
delivery: agentCandidateInstructionDeliverySchema,
|
|
140
|
+
})
|
|
141
|
+
.strict(),
|
|
142
|
+
repository: z
|
|
143
|
+
.object({
|
|
144
|
+
identity: z.string().min(1),
|
|
145
|
+
rootIdentity: z.string().min(1),
|
|
146
|
+
baseCommit: gitObjectSchema,
|
|
147
|
+
baseTree: gitObjectSchema,
|
|
148
|
+
})
|
|
149
|
+
.strict(),
|
|
150
|
+
workspace: agentCandidateWorkspaceSnapshotEvidenceSchema,
|
|
151
|
+
})
|
|
152
|
+
.strict(),
|
|
153
|
+
workspaces: z
|
|
154
|
+
.object({
|
|
155
|
+
taskRoot: z
|
|
156
|
+
.string()
|
|
157
|
+
.refine(isCanonicalAbsolutePath, "task root must be a canonical absolute path"),
|
|
158
|
+
candidateRoot: z
|
|
159
|
+
.string()
|
|
160
|
+
.refine(isCanonicalAbsolutePath, "candidate root must be a canonical absolute path")
|
|
161
|
+
.optional(),
|
|
162
|
+
})
|
|
163
|
+
.strict(),
|
|
164
|
+
codeKind: z.enum(["disabled", "no-op", "git-patch"]),
|
|
165
|
+
candidateWorkspace: agentCandidateWorkspaceSnapshotEvidenceSchema.optional(),
|
|
166
|
+
profile: z
|
|
167
|
+
.object({
|
|
168
|
+
planDigest: sha256DigestSchema,
|
|
169
|
+
targetWorkspace: z.enum(["task", "candidate"]),
|
|
170
|
+
mountPaths: z.array(z
|
|
171
|
+
.string()
|
|
172
|
+
.refine((value) => isSafeRelativePath(value, false), "profile mount paths must be canonical and relative")),
|
|
173
|
+
})
|
|
174
|
+
.strict(),
|
|
175
|
+
harness: harnessTypeSchema,
|
|
176
|
+
harnessVersion: z.string().min(1),
|
|
177
|
+
container: agentCandidateContainerSchema
|
|
178
|
+
.extend({
|
|
179
|
+
source: z.enum(["pinned-container", "evaluator-task-container"]),
|
|
180
|
+
manifestDigest: sha256DigestSchema,
|
|
181
|
+
platform: z
|
|
182
|
+
.object({
|
|
183
|
+
os: z.string().min(1),
|
|
184
|
+
architecture: z.string().min(1),
|
|
185
|
+
variant: z.string().min(1).optional(),
|
|
186
|
+
})
|
|
187
|
+
.strict(),
|
|
188
|
+
})
|
|
189
|
+
.strict(),
|
|
190
|
+
model: z
|
|
191
|
+
.object({
|
|
192
|
+
policy: z.literal("single"),
|
|
193
|
+
resolved: agentCandidateResolvedModelSchema,
|
|
194
|
+
access: z
|
|
195
|
+
.object({
|
|
196
|
+
kind: z.literal("evaluator-mediated"),
|
|
197
|
+
grantDigest: sha256DigestSchema,
|
|
198
|
+
})
|
|
199
|
+
.strict(),
|
|
200
|
+
routes: z
|
|
201
|
+
.array(z.discriminatedUnion("kind", [
|
|
202
|
+
z
|
|
203
|
+
.object({
|
|
204
|
+
kind: z.literal("primary"),
|
|
205
|
+
requested: z.string().min(1).optional(),
|
|
206
|
+
})
|
|
207
|
+
.strict(),
|
|
208
|
+
z
|
|
209
|
+
.object({
|
|
210
|
+
kind: z.literal("small"),
|
|
211
|
+
requested: z.string().min(1),
|
|
212
|
+
})
|
|
213
|
+
.strict(),
|
|
214
|
+
z
|
|
215
|
+
.object({
|
|
216
|
+
kind: z.literal("mode"),
|
|
217
|
+
name: z.string().min(1),
|
|
218
|
+
requested: z.string().min(1),
|
|
219
|
+
})
|
|
220
|
+
.strict(),
|
|
221
|
+
z
|
|
222
|
+
.object({
|
|
223
|
+
kind: z.literal("subagent"),
|
|
224
|
+
name: z.string().min(1),
|
|
225
|
+
requested: z.string().min(1),
|
|
226
|
+
})
|
|
227
|
+
.strict(),
|
|
228
|
+
]))
|
|
229
|
+
.min(1),
|
|
230
|
+
})
|
|
231
|
+
.strict(),
|
|
232
|
+
launch: z
|
|
233
|
+
.object({
|
|
234
|
+
executable: z
|
|
235
|
+
.string()
|
|
236
|
+
.refine(isSafeExecutable, "execution plan requires a non-shell executable"),
|
|
237
|
+
args: z.array(agentCandidateConfigValueSchema),
|
|
238
|
+
env: environmentConfigSchema,
|
|
239
|
+
cwd: agentCandidateWorkingDirectorySchema,
|
|
240
|
+
})
|
|
241
|
+
.strict(),
|
|
242
|
+
knowledgeManifestDigest: sha256DigestSchema.optional(),
|
|
243
|
+
memory: agentCandidateEffectiveMemorySchema,
|
|
244
|
+
limits: agentCandidateExecutionLimitsSchema,
|
|
245
|
+
network: z.object({ mode: z.literal("disabled") }).strict(),
|
|
246
|
+
})
|
|
247
|
+
.strict()
|
|
248
|
+
.superRefine((material, ctx) => {
|
|
249
|
+
if (!sameGitObjectFormat(material.task.repository.baseCommit, material.task.repository.baseTree)) {
|
|
250
|
+
ctx.addIssue({
|
|
251
|
+
code: "custom",
|
|
252
|
+
path: ["task", "repository"],
|
|
253
|
+
message: "task Git object ids must use one object format",
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
if (material.attempt.number > material.attempt.maxAttempts) {
|
|
257
|
+
ctx.addIssue({
|
|
258
|
+
code: "custom",
|
|
259
|
+
path: ["attempt", "number"],
|
|
260
|
+
message: "attempt number cannot exceed the frozen maximum",
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
if (material.attempt.retryPolicy === "none" &&
|
|
264
|
+
material.attempt.maxAttempts !== 1) {
|
|
265
|
+
ctx.addIssue({
|
|
266
|
+
code: "custom",
|
|
267
|
+
path: ["attempt", "maxAttempts"],
|
|
268
|
+
message: "a no-retry plan must allow exactly one attempt",
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
const routeIds = material.model.routes.map((route) => route.kind === "mode" || route.kind === "subagent"
|
|
272
|
+
? `${route.kind}:${route.name}`
|
|
273
|
+
: route.kind);
|
|
274
|
+
addDuplicateIssues(routeIds, ["model", "routes"], ctx);
|
|
275
|
+
addDuplicateIssues(material.profile.mountPaths, ["profile", "mountPaths"], ctx);
|
|
276
|
+
for (let index = 1; index < material.profile.mountPaths.length; index++) {
|
|
277
|
+
if ((material.profile.mountPaths[index - 1] ?? "") >=
|
|
278
|
+
(material.profile.mountPaths[index] ?? "")) {
|
|
279
|
+
ctx.addIssue({
|
|
280
|
+
code: "custom",
|
|
281
|
+
path: ["profile", "mountPaths", index],
|
|
282
|
+
message: "profile mount paths must be lexicographically sorted",
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (!material.model.routes.some((route) => route.kind === "primary")) {
|
|
287
|
+
ctx.addIssue({
|
|
288
|
+
code: "custom",
|
|
289
|
+
path: ["model", "routes"],
|
|
290
|
+
message: "single-model plans must include the primary route",
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
for (const [index, route] of material.model.routes.entries()) {
|
|
294
|
+
if (route.requested !== undefined &&
|
|
295
|
+
route.requested !== material.model.resolved.requested) {
|
|
296
|
+
ctx.addIssue({
|
|
297
|
+
code: "custom",
|
|
298
|
+
path: ["model", "routes", index, "requested"],
|
|
299
|
+
message: "every route must request the one resolved model literal",
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const activeCode = material.codeKind !== "disabled";
|
|
304
|
+
if (activeCode !== (material.candidateWorkspace !== undefined)) {
|
|
305
|
+
ctx.addIssue({
|
|
306
|
+
code: "custom",
|
|
307
|
+
path: ["candidateWorkspace"],
|
|
308
|
+
message: "active code requires a complete candidate-workspace snapshot",
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (activeCode !== (material.workspaces.candidateRoot !== undefined)) {
|
|
312
|
+
ctx.addIssue({
|
|
313
|
+
code: "custom",
|
|
314
|
+
path: ["workspaces", "candidateRoot"],
|
|
315
|
+
message: "active code requires a fixed candidate workspace root",
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
if (material.workspaces.candidateRoot !== undefined &&
|
|
319
|
+
pathsOverlap(material.workspaces.taskRoot, material.workspaces.candidateRoot)) {
|
|
320
|
+
ctx.addIssue({
|
|
321
|
+
code: "custom",
|
|
322
|
+
path: ["workspaces"],
|
|
323
|
+
message: "task and candidate workspace roots must be disjoint",
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
if (material.launch.cwd.workspace === "candidate" &&
|
|
327
|
+
material.workspaces.candidateRoot === undefined) {
|
|
328
|
+
ctx.addIssue({
|
|
329
|
+
code: "custom",
|
|
330
|
+
path: ["launch", "cwd", "workspace"],
|
|
331
|
+
message: "candidate cwd requires a pinned candidate workspace root",
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (material.profile.targetWorkspace === "candidate" &&
|
|
335
|
+
material.workspaces.candidateRoot === undefined) {
|
|
336
|
+
ctx.addIssue({
|
|
337
|
+
code: "custom",
|
|
338
|
+
path: ["profile", "targetWorkspace"],
|
|
339
|
+
message: "candidate-targeted profile files require a candidate workspace root",
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
const delivery = material.task.instruction.delivery;
|
|
343
|
+
const taskPath = material.launch.env.TANGLE_CANDIDATE_TASK_PATH;
|
|
344
|
+
if (delivery.kind === "utf8-file") {
|
|
345
|
+
if (taskPath?.value !== delivery.path) {
|
|
346
|
+
ctx.addIssue({
|
|
347
|
+
code: "custom",
|
|
348
|
+
path: ["launch", "env", "TANGLE_CANDIDATE_TASK_PATH"],
|
|
349
|
+
message: "file delivery requires the signed fixed task path",
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
if (pathsOverlap(material.workspaces.taskRoot, delivery.path) ||
|
|
353
|
+
(material.workspaces.candidateRoot !== undefined &&
|
|
354
|
+
pathsOverlap(material.workspaces.candidateRoot, delivery.path))) {
|
|
355
|
+
ctx.addIssue({
|
|
356
|
+
code: "custom",
|
|
357
|
+
path: ["workspaces"],
|
|
358
|
+
message: "the task instruction file must be outside both workspaces",
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
else if (taskPath !== undefined) {
|
|
363
|
+
ctx.addIssue({
|
|
364
|
+
code: "custom",
|
|
365
|
+
path: ["launch", "env", "TANGLE_CANDIDATE_TASK_PATH"],
|
|
366
|
+
message: "non-file delivery cannot expose an instruction path",
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
if (activeCode && material.candidateWorkspace?.material.files.length === 0) {
|
|
370
|
+
ctx.addIssue({
|
|
371
|
+
code: "custom",
|
|
372
|
+
path: ["candidateWorkspace", "material", "files"],
|
|
373
|
+
message: "active candidate workspaces cannot be empty",
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
if (material.task.workspace.material.files.length === 0) {
|
|
377
|
+
ctx.addIssue({
|
|
378
|
+
code: "custom",
|
|
379
|
+
path: ["task", "workspace", "material", "files"],
|
|
380
|
+
message: "task workspace snapshots cannot be empty",
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
if (!isCanonicalJsonValue(material)) {
|
|
384
|
+
ctx.addIssue({
|
|
385
|
+
code: "custom",
|
|
386
|
+
message: "execution-plan material must contain only RFC 8785 JSON values",
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
function planEvidenceSchema(kind, material) {
|
|
391
|
+
return z
|
|
392
|
+
.object({
|
|
393
|
+
schemaVersion: z.literal(1),
|
|
394
|
+
kind: z.literal(kind),
|
|
395
|
+
digest: sha256DigestSchema,
|
|
396
|
+
material,
|
|
397
|
+
artifact: agentCandidateCapturedArtifactSchema,
|
|
398
|
+
})
|
|
399
|
+
.strict()
|
|
400
|
+
.superRefine((evidence, ctx) => {
|
|
401
|
+
if (evidence.artifact.sha256 !== evidence.digest) {
|
|
402
|
+
ctx.addIssue({
|
|
403
|
+
code: "custom",
|
|
404
|
+
path: ["artifact", "sha256"],
|
|
405
|
+
message: "plan artifact hash must equal its canonical material digest",
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
if (evidence.artifact.byteLength === 0) {
|
|
409
|
+
ctx.addIssue({
|
|
410
|
+
code: "custom",
|
|
411
|
+
path: ["artifact", "byteLength"],
|
|
412
|
+
message: "plan artifact must contain canonical material bytes",
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
export const agentCandidateProfilePlanEvidenceSchema = planEvidenceSchema("agent-profile-workspace-plan", agentCandidateProfilePlanMaterialSchema);
|
|
418
|
+
export const agentCandidateExecutionPlanEvidenceSchema = planEvidenceSchema("agent-candidate-execution-plan", agentCandidateExecutionPlanMaterialSchema);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const agentCandidateKnowledgeSchema: z.ZodObject<{
|
|
3
|
+
snapshotId: z.ZodString;
|
|
4
|
+
manifest: z.ZodObject<{
|
|
5
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
6
|
+
kind: z.ZodLiteral<"s3">;
|
|
7
|
+
bucket: z.ZodString;
|
|
8
|
+
key: z.ZodString;
|
|
9
|
+
region: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
12
|
+
cid: z.ZodString;
|
|
13
|
+
path: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strict>], "kind">;
|
|
15
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
16
|
+
byteLength: z.ZodNumber;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
export declare const agentCandidateMemoryPolicySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
20
|
+
mode: z.ZodLiteral<"disabled">;
|
|
21
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
22
|
+
mode: z.ZodLiteral<"isolated">;
|
|
23
|
+
scope: z.ZodLiteral<"task">;
|
|
24
|
+
seed: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
26
|
+
kind: z.ZodLiteral<"s3">;
|
|
27
|
+
bucket: z.ZodString;
|
|
28
|
+
key: z.ZodString;
|
|
29
|
+
region: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
31
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
32
|
+
cid: z.ZodString;
|
|
33
|
+
path: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strict>], "kind">;
|
|
35
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
36
|
+
byteLength: z.ZodNumber;
|
|
37
|
+
}, z.core.$strict>>;
|
|
38
|
+
}, z.core.$strict>], "mode">;
|
|
39
|
+
export declare const agentCandidateSpendSchema: z.ZodObject<{
|
|
40
|
+
costUsd: z.ZodNumber;
|
|
41
|
+
inputTokens: z.ZodNumber;
|
|
42
|
+
outputTokens: z.ZodNumber;
|
|
43
|
+
cachedInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
modelCalls: z.ZodNumber;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
export declare const agentCandidateLineageSchema: z.ZodObject<{
|
|
47
|
+
source: z.ZodEnum<{
|
|
48
|
+
optimizer: "optimizer";
|
|
49
|
+
human: "human";
|
|
50
|
+
import: "import";
|
|
51
|
+
compound: "compound";
|
|
52
|
+
}>;
|
|
53
|
+
parentDigests: z.ZodOptional<z.ZodArray<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>>;
|
|
54
|
+
runIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
+
profileDiffIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
56
|
+
modelSnapshots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
|
+
benchmark: z.ZodOptional<z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
version: z.ZodString;
|
|
60
|
+
splitDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
61
|
+
}, z.core.$strict>>;
|
|
62
|
+
spend: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
proposal: z.ZodObject<{
|
|
64
|
+
costUsd: z.ZodNumber;
|
|
65
|
+
inputTokens: z.ZodNumber;
|
|
66
|
+
outputTokens: z.ZodNumber;
|
|
67
|
+
cachedInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
modelCalls: z.ZodNumber;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
evaluation: z.ZodObject<{
|
|
71
|
+
costUsd: z.ZodNumber;
|
|
72
|
+
inputTokens: z.ZodNumber;
|
|
73
|
+
outputTokens: z.ZodNumber;
|
|
74
|
+
cachedInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
modelCalls: z.ZodNumber;
|
|
76
|
+
}, z.core.$strict>;
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { agentCandidateArtifactRefSchema } from "./agent-candidate-artifact-schema.js";
|
|
3
|
+
import { addDuplicateIssues, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
4
|
+
export const agentCandidateKnowledgeSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
snapshotId: z.string().min(1),
|
|
7
|
+
manifest: agentCandidateArtifactRefSchema,
|
|
8
|
+
})
|
|
9
|
+
.strict();
|
|
10
|
+
export const agentCandidateMemoryPolicySchema = z.discriminatedUnion("mode", [
|
|
11
|
+
z.object({ mode: z.literal("disabled") }).strict(),
|
|
12
|
+
z
|
|
13
|
+
.object({
|
|
14
|
+
mode: z.literal("isolated"),
|
|
15
|
+
scope: z.literal("task"),
|
|
16
|
+
seed: agentCandidateArtifactRefSchema.optional(),
|
|
17
|
+
})
|
|
18
|
+
.strict(),
|
|
19
|
+
]);
|
|
20
|
+
export const agentCandidateSpendSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
costUsd: z.number().finite().nonnegative(),
|
|
23
|
+
inputTokens: z.number().int().nonnegative(),
|
|
24
|
+
outputTokens: z.number().int().nonnegative(),
|
|
25
|
+
cachedInputTokens: z.number().int().nonnegative().optional(),
|
|
26
|
+
modelCalls: z.number().int().nonnegative(),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
export const agentCandidateLineageSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
source: z.enum(["optimizer", "human", "import", "compound"]),
|
|
32
|
+
parentDigests: z.array(sha256DigestSchema).optional(),
|
|
33
|
+
runIds: z.array(z.string().min(1)).optional(),
|
|
34
|
+
profileDiffIds: z.array(z.string().min(1)).optional(),
|
|
35
|
+
modelSnapshots: z.array(z.string().min(1)).optional(),
|
|
36
|
+
benchmark: z
|
|
37
|
+
.object({
|
|
38
|
+
name: z.string().min(1),
|
|
39
|
+
version: z.string().min(1),
|
|
40
|
+
splitDigest: sha256DigestSchema,
|
|
41
|
+
})
|
|
42
|
+
.strict()
|
|
43
|
+
.optional(),
|
|
44
|
+
spend: z
|
|
45
|
+
.object({
|
|
46
|
+
proposal: agentCandidateSpendSchema,
|
|
47
|
+
evaluation: agentCandidateSpendSchema,
|
|
48
|
+
})
|
|
49
|
+
.strict()
|
|
50
|
+
.optional(),
|
|
51
|
+
})
|
|
52
|
+
.strict()
|
|
53
|
+
.superRefine((lineage, ctx) => {
|
|
54
|
+
addDuplicateIssues(lineage.parentDigests, ["parentDigests"], ctx);
|
|
55
|
+
addDuplicateIssues(lineage.runIds, ["runIds"], ctx);
|
|
56
|
+
addDuplicateIssues(lineage.profileDiffIds, ["profileDiffIds"], ctx);
|
|
57
|
+
addDuplicateIssues(lineage.modelSnapshots, ["modelSnapshots"], ctx);
|
|
58
|
+
if (lineage.source === "compound" &&
|
|
59
|
+
(lineage.parentDigests?.length ?? 0) < 2) {
|
|
60
|
+
ctx.addIssue({
|
|
61
|
+
code: "custom",
|
|
62
|
+
path: ["parentDigests"],
|
|
63
|
+
message: "compound candidates must name at least two distinct parents",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (lineage.source === "optimizer" || lineage.source === "compound") {
|
|
67
|
+
if ((lineage.parentDigests?.length ?? 0) === 0) {
|
|
68
|
+
ctx.addIssue({
|
|
69
|
+
code: "custom",
|
|
70
|
+
path: ["parentDigests"],
|
|
71
|
+
message: "generated candidates must name at least one parent",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if ((lineage.runIds?.length ?? 0) === 0) {
|
|
75
|
+
ctx.addIssue({
|
|
76
|
+
code: "custom",
|
|
77
|
+
path: ["runIds"],
|
|
78
|
+
message: "generated candidates must name their producing run",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (lineage.benchmark === undefined) {
|
|
82
|
+
ctx.addIssue({
|
|
83
|
+
code: "custom",
|
|
84
|
+
path: ["benchmark"],
|
|
85
|
+
message: "generated candidates must pin their development split",
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (lineage.spend === undefined) {
|
|
89
|
+
ctx.addIssue({
|
|
90
|
+
code: "custom",
|
|
91
|
+
path: ["spend"],
|
|
92
|
+
message: "generated candidates must record proposal and evaluation spend",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|