@tangle-network/agent-interface 0.20.0 → 0.22.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-outcome-schema.d.ts +618 -0
- package/dist/agent-candidate-outcome-schema.js +293 -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 +2468 -0
- package/dist/agent-candidate-receipt-schema.js +388 -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 +499 -0
- package/dist/agent-candidate-schema.js +145 -0
- package/dist/agent-candidate.d.ts +634 -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/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 +1 -0
- package/dist/profile-schema.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { agentCandidateArtifactRefSchema, agentCandidateCapturedArtifactSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, } from "./agent-candidate-artifact-schema.js";
|
|
3
|
+
import { agentCandidateResolvedModelSchema } from "./agent-candidate-execution-plan-schema.js";
|
|
4
|
+
import { gitObjectSchema, isCanonicalJsonValue, sameGitObjectFormat, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
5
|
+
const safeCountSchema = z
|
|
6
|
+
.number()
|
|
7
|
+
.int()
|
|
8
|
+
.nonnegative()
|
|
9
|
+
.refine(Number.isSafeInteger, "value must be a nonnegative safe integer");
|
|
10
|
+
const boundedIdentifierSchema = z.string().min(1).max(256);
|
|
11
|
+
const normalizedDimensionNameSchema = z
|
|
12
|
+
.string()
|
|
13
|
+
.regex(/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/, "dimension names must be normalized lowercase identifiers");
|
|
14
|
+
const normalizedScoreSchema = z.number().finite().min(0).max(1);
|
|
15
|
+
export const agentCandidateFixedSpendSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
inputTokens: safeCountSchema,
|
|
18
|
+
outputTokens: safeCountSchema,
|
|
19
|
+
cachedInputTokens: safeCountSchema,
|
|
20
|
+
reasoningTokens: safeCountSchema,
|
|
21
|
+
modelCalls: safeCountSchema,
|
|
22
|
+
costUsdNanos: safeCountSchema,
|
|
23
|
+
})
|
|
24
|
+
.strict();
|
|
25
|
+
export const agentCandidateModelSettlementCallSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
callId: boundedIdentifierSchema,
|
|
28
|
+
traceSpanId: boundedIdentifierSchema,
|
|
29
|
+
model: boundedIdentifierSchema,
|
|
30
|
+
inputTokens: safeCountSchema,
|
|
31
|
+
outputTokens: safeCountSchema,
|
|
32
|
+
cachedInputTokens: safeCountSchema,
|
|
33
|
+
reasoningTokens: safeCountSchema,
|
|
34
|
+
costUsdNanos: safeCountSchema,
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
export const agentCandidateModelSettlementMaterialSchema = z
|
|
38
|
+
.object({
|
|
39
|
+
schemaVersion: z.literal(1),
|
|
40
|
+
kind: z.literal("agent-candidate-model-settlement-material"),
|
|
41
|
+
executionPlanDigest: sha256DigestSchema,
|
|
42
|
+
preparationId: boundedIdentifierSchema,
|
|
43
|
+
grantDigest: sha256DigestSchema,
|
|
44
|
+
closed: z.literal(true),
|
|
45
|
+
resolved: agentCandidateResolvedModelSchema,
|
|
46
|
+
calls: z.array(agentCandidateModelSettlementCallSchema),
|
|
47
|
+
usage: agentCandidateFixedSpendSchema,
|
|
48
|
+
})
|
|
49
|
+
.strict()
|
|
50
|
+
.superRefine((material, ctx) => {
|
|
51
|
+
const callIds = new Set();
|
|
52
|
+
const traceSpanIds = new Set();
|
|
53
|
+
const totals = {
|
|
54
|
+
inputTokens: 0,
|
|
55
|
+
outputTokens: 0,
|
|
56
|
+
cachedInputTokens: 0,
|
|
57
|
+
reasoningTokens: 0,
|
|
58
|
+
modelCalls: material.calls.length,
|
|
59
|
+
costUsdNanos: 0,
|
|
60
|
+
};
|
|
61
|
+
for (const [index, call] of material.calls.entries()) {
|
|
62
|
+
if (callIds.has(call.callId)) {
|
|
63
|
+
ctx.addIssue({
|
|
64
|
+
code: "custom",
|
|
65
|
+
path: ["calls", index, "callId"],
|
|
66
|
+
message: "model settlement call ids must be unique",
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
callIds.add(call.callId);
|
|
70
|
+
if (traceSpanIds.has(call.traceSpanId)) {
|
|
71
|
+
ctx.addIssue({
|
|
72
|
+
code: "custom",
|
|
73
|
+
path: ["calls", index, "traceSpanId"],
|
|
74
|
+
message: "model settlement trace span ids must be unique",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
traceSpanIds.add(call.traceSpanId);
|
|
78
|
+
if (call.model !== material.resolved.model) {
|
|
79
|
+
ctx.addIssue({
|
|
80
|
+
code: "custom",
|
|
81
|
+
path: ["calls", index, "model"],
|
|
82
|
+
message: "settled call model must match the resolved single model",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
for (const field of [
|
|
86
|
+
"inputTokens",
|
|
87
|
+
"outputTokens",
|
|
88
|
+
"cachedInputTokens",
|
|
89
|
+
"reasoningTokens",
|
|
90
|
+
"costUsdNanos",
|
|
91
|
+
]) {
|
|
92
|
+
const sum = totals[field] + call[field];
|
|
93
|
+
if (!Number.isSafeInteger(sum)) {
|
|
94
|
+
ctx.addIssue({
|
|
95
|
+
code: "custom",
|
|
96
|
+
path: ["calls", index, field],
|
|
97
|
+
message: `model settlement ${field} total exceeds safe integer range`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
totals[field] = sum;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (!sameFixedSpend(totals, material.usage)) {
|
|
106
|
+
ctx.addIssue({
|
|
107
|
+
code: "custom",
|
|
108
|
+
path: ["usage"],
|
|
109
|
+
message: "model settlement usage must equal the exact per-call aggregate",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (!isCanonicalJsonValue(material)) {
|
|
113
|
+
ctx.addIssue({
|
|
114
|
+
code: "custom",
|
|
115
|
+
message: "model settlement material must contain only RFC 8785 JSON values",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
export const agentCandidateModelSettlementEvidenceSchema = evidenceSchema("agent-candidate-model-settlement", agentCandidateModelSettlementMaterialSchema, "model settlement");
|
|
120
|
+
export const agentCandidateRepositoryStateSchema = z
|
|
121
|
+
.object({
|
|
122
|
+
identity: z.string().min(1),
|
|
123
|
+
rootIdentity: z.string().min(1),
|
|
124
|
+
commit: gitObjectSchema,
|
|
125
|
+
tree: gitObjectSchema,
|
|
126
|
+
})
|
|
127
|
+
.strict()
|
|
128
|
+
.superRefine((state, ctx) => {
|
|
129
|
+
if (!sameGitObjectFormat(state.commit, state.tree)) {
|
|
130
|
+
ctx.addIssue({
|
|
131
|
+
code: "custom",
|
|
132
|
+
path: ["tree"],
|
|
133
|
+
message: "repository commit and tree must use the same Git object format",
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
export const agentCandidateTaskOutcomeMaterialSchema = z
|
|
138
|
+
.object({
|
|
139
|
+
schemaVersion: z.literal(1),
|
|
140
|
+
kind: z.literal("agent-candidate-task-outcome-material"),
|
|
141
|
+
executionPlanDigest: sha256DigestSchema,
|
|
142
|
+
baseRepository: agentCandidateRepositoryStateSchema,
|
|
143
|
+
resultRepository: agentCandidateRepositoryStateSchema,
|
|
144
|
+
afterState: agentCandidateWorkspaceSnapshotEvidenceSchema,
|
|
145
|
+
gitDiff: z
|
|
146
|
+
.object({
|
|
147
|
+
format: z.literal("git-diff-binary"),
|
|
148
|
+
artifact: agentCandidateArtifactRefSchema,
|
|
149
|
+
})
|
|
150
|
+
.strict(),
|
|
151
|
+
})
|
|
152
|
+
.strict()
|
|
153
|
+
.superRefine((material, ctx) => {
|
|
154
|
+
if (material.baseRepository.identity !== material.resultRepository.identity) {
|
|
155
|
+
ctx.addIssue({
|
|
156
|
+
code: "custom",
|
|
157
|
+
path: ["resultRepository", "identity"],
|
|
158
|
+
message: "base and result repository identities must match",
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (material.baseRepository.rootIdentity !==
|
|
162
|
+
material.resultRepository.rootIdentity) {
|
|
163
|
+
ctx.addIssue({
|
|
164
|
+
code: "custom",
|
|
165
|
+
path: ["resultRepository", "rootIdentity"],
|
|
166
|
+
message: "base and result repository roots must match",
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (!sameGitObjectFormat(material.baseRepository.commit, material.resultRepository.commit) ||
|
|
170
|
+
!sameGitObjectFormat(material.baseRepository.tree, material.resultRepository.tree)) {
|
|
171
|
+
ctx.addIssue({
|
|
172
|
+
code: "custom",
|
|
173
|
+
path: ["resultRepository"],
|
|
174
|
+
message: "base and result repositories must use one Git object format",
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (!isCanonicalJsonValue(material)) {
|
|
178
|
+
ctx.addIssue({
|
|
179
|
+
code: "custom",
|
|
180
|
+
message: "task outcome material must contain only RFC 8785 JSON values",
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
export const agentCandidateTaskOutcomeEvidenceSchema = evidenceSchema("agent-candidate-task-outcome", agentCandidateTaskOutcomeMaterialSchema, "task outcome");
|
|
185
|
+
export const agentCandidateBenchmarkDimensionSchema = z
|
|
186
|
+
.object({
|
|
187
|
+
name: normalizedDimensionNameSchema,
|
|
188
|
+
score: normalizedScoreSchema,
|
|
189
|
+
})
|
|
190
|
+
.strict();
|
|
191
|
+
export const agentCandidateBenchmarkResultMaterialSchema = z
|
|
192
|
+
.object({
|
|
193
|
+
schemaVersion: z.literal(1),
|
|
194
|
+
kind: z.literal("agent-candidate-benchmark-result-material"),
|
|
195
|
+
executionPlanDigest: sha256DigestSchema,
|
|
196
|
+
taskOutcomeDigest: sha256DigestSchema,
|
|
197
|
+
benchmark: z
|
|
198
|
+
.object({
|
|
199
|
+
name: z.string().min(1),
|
|
200
|
+
version: z.string().min(1),
|
|
201
|
+
taskId: z.string().min(1),
|
|
202
|
+
splitDigest: sha256DigestSchema,
|
|
203
|
+
})
|
|
204
|
+
.strict(),
|
|
205
|
+
grader: z
|
|
206
|
+
.object({
|
|
207
|
+
name: z.string().min(1),
|
|
208
|
+
version: z.string().min(1),
|
|
209
|
+
artifact: agentCandidateArtifactRefSchema,
|
|
210
|
+
})
|
|
211
|
+
.strict(),
|
|
212
|
+
evidence: agentCandidateArtifactRefSchema,
|
|
213
|
+
score: normalizedScoreSchema,
|
|
214
|
+
passed: z.boolean(),
|
|
215
|
+
dimensions: z.array(agentCandidateBenchmarkDimensionSchema),
|
|
216
|
+
})
|
|
217
|
+
.strict()
|
|
218
|
+
.superRefine((material, ctx) => {
|
|
219
|
+
if (material.grader.artifact.byteLength === 0) {
|
|
220
|
+
ctx.addIssue({
|
|
221
|
+
code: "custom",
|
|
222
|
+
path: ["grader", "artifact", "byteLength"],
|
|
223
|
+
message: "pinned grader artifact must contain executable grader bytes",
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (material.evidence.byteLength === 0) {
|
|
227
|
+
ctx.addIssue({
|
|
228
|
+
code: "custom",
|
|
229
|
+
path: ["evidence", "byteLength"],
|
|
230
|
+
message: "benchmark result must contain non-empty durable grading evidence",
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (material.evidence.sha256 === material.grader.artifact.sha256) {
|
|
234
|
+
ctx.addIssue({
|
|
235
|
+
code: "custom",
|
|
236
|
+
path: ["evidence", "sha256"],
|
|
237
|
+
message: "grading evidence must be distinct from the grader implementation",
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
for (let index = 1; index < material.dimensions.length; index++) {
|
|
241
|
+
const previous = material.dimensions[index - 1]?.name ?? "";
|
|
242
|
+
const current = material.dimensions[index]?.name ?? "";
|
|
243
|
+
if (previous >= current) {
|
|
244
|
+
ctx.addIssue({
|
|
245
|
+
code: "custom",
|
|
246
|
+
path: ["dimensions", index, "name"],
|
|
247
|
+
message: "benchmark dimensions must be unique and lexicographically sorted",
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (!isCanonicalJsonValue(material)) {
|
|
252
|
+
ctx.addIssue({
|
|
253
|
+
code: "custom",
|
|
254
|
+
message: "benchmark result material must contain only RFC 8785 JSON values",
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
export const agentCandidateBenchmarkResultEvidenceSchema = evidenceSchema("agent-candidate-benchmark-result", agentCandidateBenchmarkResultMaterialSchema, "benchmark result");
|
|
259
|
+
export function sameFixedSpend(left, right) {
|
|
260
|
+
return (left.inputTokens === right.inputTokens &&
|
|
261
|
+
left.outputTokens === right.outputTokens &&
|
|
262
|
+
left.cachedInputTokens === right.cachedInputTokens &&
|
|
263
|
+
left.reasoningTokens === right.reasoningTokens &&
|
|
264
|
+
left.modelCalls === right.modelCalls &&
|
|
265
|
+
left.costUsdNanos === right.costUsdNanos);
|
|
266
|
+
}
|
|
267
|
+
function evidenceSchema(kind, material, label) {
|
|
268
|
+
return z
|
|
269
|
+
.object({
|
|
270
|
+
schemaVersion: z.literal(1),
|
|
271
|
+
kind: z.literal(kind),
|
|
272
|
+
digest: sha256DigestSchema,
|
|
273
|
+
material,
|
|
274
|
+
artifact: agentCandidateCapturedArtifactSchema,
|
|
275
|
+
})
|
|
276
|
+
.strict()
|
|
277
|
+
.superRefine((evidence, ctx) => {
|
|
278
|
+
if (evidence.artifact.sha256 !== evidence.digest) {
|
|
279
|
+
ctx.addIssue({
|
|
280
|
+
code: "custom",
|
|
281
|
+
path: ["artifact", "sha256"],
|
|
282
|
+
message: `${label} artifact hash must equal its canonical material digest`,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
if (evidence.artifact.byteLength === 0) {
|
|
286
|
+
ctx.addIssue({
|
|
287
|
+
code: "custom",
|
|
288
|
+
path: ["artifact", "byteLength"],
|
|
289
|
+
message: `${label} artifact must contain canonical material bytes`,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const agentCandidateMcpServerSchema: z.ZodObject<{
|
|
3
|
+
transport: z.ZodOptional<z.ZodLiteral<"stdio">>;
|
|
4
|
+
command: z.ZodOptional<z.ZodString>;
|
|
5
|
+
args: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
6
|
+
kind: z.ZodLiteral<"public">;
|
|
7
|
+
value: z.ZodString;
|
|
8
|
+
}, z.core.$strict>>>;
|
|
9
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
10
|
+
kind: z.ZodLiteral<"public">;
|
|
11
|
+
value: z.ZodString;
|
|
12
|
+
}, z.core.$strict>>>;
|
|
13
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
14
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export declare const agentCandidateHookCommandSchema: z.ZodObject<{
|
|
17
|
+
executable: z.ZodString;
|
|
18
|
+
args: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
19
|
+
kind: z.ZodLiteral<"public">;
|
|
20
|
+
value: z.ZodString;
|
|
21
|
+
}, z.core.$strict>>>;
|
|
22
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
blocking: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
matcher: z.ZodOptional<z.ZodString>;
|
|
25
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
26
|
+
kind: z.ZodLiteral<"public">;
|
|
27
|
+
value: z.ZodString;
|
|
28
|
+
}, z.core.$strict>>>;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
export declare const agentCandidateProfileSchema: z.ZodObject<{
|
|
31
|
+
name: z.ZodOptional<z.ZodString>;
|
|
32
|
+
description: z.ZodOptional<z.ZodString>;
|
|
33
|
+
version: z.ZodOptional<z.ZodString>;
|
|
34
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
+
prompt: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
37
|
+
instructions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
41
|
+
none: "none";
|
|
42
|
+
minimal: "minimal";
|
|
43
|
+
low: "low";
|
|
44
|
+
medium: "medium";
|
|
45
|
+
high: "high";
|
|
46
|
+
xhigh: "xhigh";
|
|
47
|
+
ultracode: "ultracode";
|
|
48
|
+
}>>;
|
|
49
|
+
default: z.ZodOptional<z.ZodString>;
|
|
50
|
+
small: z.ZodOptional<z.ZodString>;
|
|
51
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strict>>;
|
|
53
|
+
harness: z.ZodOptional<z.ZodEnum<{
|
|
54
|
+
"claude-code": "claude-code";
|
|
55
|
+
claude: "claude";
|
|
56
|
+
claudish: "claudish";
|
|
57
|
+
nanoclaw: "nanoclaw";
|
|
58
|
+
codex: "codex";
|
|
59
|
+
opencode: "opencode";
|
|
60
|
+
"kimi-code": "kimi-code";
|
|
61
|
+
kimi: "kimi";
|
|
62
|
+
pi: "pi";
|
|
63
|
+
gemini: "gemini";
|
|
64
|
+
hermes: "hermes";
|
|
65
|
+
openclaw: "openclaw";
|
|
66
|
+
amp: "amp";
|
|
67
|
+
"factory-droids": "factory-droids";
|
|
68
|
+
acp: "acp";
|
|
69
|
+
"cli-base": "cli-base";
|
|
70
|
+
}>>;
|
|
71
|
+
permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
|
|
72
|
+
allow: "allow";
|
|
73
|
+
ask: "ask";
|
|
74
|
+
deny: "deny";
|
|
75
|
+
}>, z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
76
|
+
allow: "allow";
|
|
77
|
+
ask: "ask";
|
|
78
|
+
deny: "deny";
|
|
79
|
+
}>>]>>>;
|
|
80
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
81
|
+
mcp: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
82
|
+
transport: z.ZodOptional<z.ZodLiteral<"stdio">>;
|
|
83
|
+
command: z.ZodOptional<z.ZodString>;
|
|
84
|
+
args: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
85
|
+
kind: z.ZodLiteral<"public">;
|
|
86
|
+
value: z.ZodString;
|
|
87
|
+
}, z.core.$strict>>>;
|
|
88
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
89
|
+
kind: z.ZodLiteral<"public">;
|
|
90
|
+
value: z.ZodString;
|
|
91
|
+
}, z.core.$strict>>>;
|
|
92
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
93
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
}, z.core.$strict>>>;
|
|
95
|
+
subagents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
96
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
97
|
+
permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
|
|
98
|
+
allow: "allow";
|
|
99
|
+
ask: "ask";
|
|
100
|
+
deny: "deny";
|
|
101
|
+
}>, z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
102
|
+
allow: "allow";
|
|
103
|
+
ask: "ask";
|
|
104
|
+
deny: "deny";
|
|
105
|
+
}>>]>>>;
|
|
106
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
107
|
+
description: z.ZodOptional<z.ZodString>;
|
|
108
|
+
model: z.ZodOptional<z.ZodString>;
|
|
109
|
+
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
}, z.core.$strict>>>;
|
|
111
|
+
resources: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
113
|
+
path: z.ZodString;
|
|
114
|
+
resource: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
115
|
+
kind: z.ZodLiteral<"inline">;
|
|
116
|
+
name: z.ZodString;
|
|
117
|
+
content: z.ZodString;
|
|
118
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
119
|
+
byteLength: z.ZodNumber;
|
|
120
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
121
|
+
kind: z.ZodLiteral<"github">;
|
|
122
|
+
repository: z.ZodObject<{
|
|
123
|
+
kind: z.ZodLiteral<"github">;
|
|
124
|
+
owner: z.ZodString;
|
|
125
|
+
repo: z.ZodString;
|
|
126
|
+
}, z.core.$strict>;
|
|
127
|
+
path: z.ZodString;
|
|
128
|
+
commit: z.ZodString;
|
|
129
|
+
name: z.ZodOptional<z.ZodString>;
|
|
130
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
131
|
+
byteLength: z.ZodNumber;
|
|
132
|
+
}, z.core.$strict>], "kind">;
|
|
133
|
+
executable: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
+
}, z.core.$strict>>>;
|
|
135
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
136
|
+
kind: z.ZodLiteral<"inline">;
|
|
137
|
+
name: z.ZodString;
|
|
138
|
+
content: z.ZodString;
|
|
139
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
140
|
+
byteLength: z.ZodNumber;
|
|
141
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
142
|
+
kind: z.ZodLiteral<"github">;
|
|
143
|
+
repository: z.ZodObject<{
|
|
144
|
+
kind: z.ZodLiteral<"github">;
|
|
145
|
+
owner: z.ZodString;
|
|
146
|
+
repo: z.ZodString;
|
|
147
|
+
}, z.core.$strict>;
|
|
148
|
+
path: z.ZodString;
|
|
149
|
+
commit: z.ZodString;
|
|
150
|
+
name: z.ZodOptional<z.ZodString>;
|
|
151
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
152
|
+
byteLength: z.ZodNumber;
|
|
153
|
+
}, z.core.$strict>], "kind">>>;
|
|
154
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
155
|
+
kind: z.ZodLiteral<"inline">;
|
|
156
|
+
name: z.ZodString;
|
|
157
|
+
content: z.ZodString;
|
|
158
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
159
|
+
byteLength: z.ZodNumber;
|
|
160
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
161
|
+
kind: z.ZodLiteral<"github">;
|
|
162
|
+
repository: z.ZodObject<{
|
|
163
|
+
kind: z.ZodLiteral<"github">;
|
|
164
|
+
owner: z.ZodString;
|
|
165
|
+
repo: z.ZodString;
|
|
166
|
+
}, z.core.$strict>;
|
|
167
|
+
path: z.ZodString;
|
|
168
|
+
commit: z.ZodString;
|
|
169
|
+
name: z.ZodOptional<z.ZodString>;
|
|
170
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
171
|
+
byteLength: z.ZodNumber;
|
|
172
|
+
}, z.core.$strict>], "kind">>>;
|
|
173
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
174
|
+
kind: z.ZodLiteral<"inline">;
|
|
175
|
+
name: z.ZodString;
|
|
176
|
+
content: z.ZodString;
|
|
177
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
178
|
+
byteLength: z.ZodNumber;
|
|
179
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
180
|
+
kind: z.ZodLiteral<"github">;
|
|
181
|
+
repository: z.ZodObject<{
|
|
182
|
+
kind: z.ZodLiteral<"github">;
|
|
183
|
+
owner: z.ZodString;
|
|
184
|
+
repo: z.ZodString;
|
|
185
|
+
}, z.core.$strict>;
|
|
186
|
+
path: z.ZodString;
|
|
187
|
+
commit: z.ZodString;
|
|
188
|
+
name: z.ZodOptional<z.ZodString>;
|
|
189
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
190
|
+
byteLength: z.ZodNumber;
|
|
191
|
+
}, z.core.$strict>], "kind">>>;
|
|
192
|
+
commands: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
193
|
+
kind: z.ZodLiteral<"inline">;
|
|
194
|
+
name: z.ZodString;
|
|
195
|
+
content: z.ZodString;
|
|
196
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
197
|
+
byteLength: z.ZodNumber;
|
|
198
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
199
|
+
kind: z.ZodLiteral<"github">;
|
|
200
|
+
repository: z.ZodObject<{
|
|
201
|
+
kind: z.ZodLiteral<"github">;
|
|
202
|
+
owner: z.ZodString;
|
|
203
|
+
repo: z.ZodString;
|
|
204
|
+
}, z.core.$strict>;
|
|
205
|
+
path: z.ZodString;
|
|
206
|
+
commit: z.ZodString;
|
|
207
|
+
name: z.ZodOptional<z.ZodString>;
|
|
208
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
209
|
+
byteLength: z.ZodNumber;
|
|
210
|
+
}, z.core.$strict>], "kind">>>;
|
|
211
|
+
instructions: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
212
|
+
kind: z.ZodLiteral<"inline">;
|
|
213
|
+
name: z.ZodString;
|
|
214
|
+
content: z.ZodString;
|
|
215
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
216
|
+
byteLength: z.ZodNumber;
|
|
217
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
218
|
+
kind: z.ZodLiteral<"github">;
|
|
219
|
+
repository: z.ZodObject<{
|
|
220
|
+
kind: z.ZodLiteral<"github">;
|
|
221
|
+
owner: z.ZodString;
|
|
222
|
+
repo: z.ZodString;
|
|
223
|
+
}, z.core.$strict>;
|
|
224
|
+
path: z.ZodString;
|
|
225
|
+
commit: z.ZodString;
|
|
226
|
+
name: z.ZodOptional<z.ZodString>;
|
|
227
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
228
|
+
byteLength: z.ZodNumber;
|
|
229
|
+
}, z.core.$strict>], "kind">]>>;
|
|
230
|
+
failOnError: z.ZodLiteral<true>;
|
|
231
|
+
}, z.core.$strict>>;
|
|
232
|
+
hooks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
233
|
+
executable: z.ZodString;
|
|
234
|
+
args: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
235
|
+
kind: z.ZodLiteral<"public">;
|
|
236
|
+
value: z.ZodString;
|
|
237
|
+
}, z.core.$strict>>>;
|
|
238
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
239
|
+
blocking: z.ZodOptional<z.ZodBoolean>;
|
|
240
|
+
matcher: z.ZodOptional<z.ZodString>;
|
|
241
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
242
|
+
kind: z.ZodLiteral<"public">;
|
|
243
|
+
value: z.ZodString;
|
|
244
|
+
}, z.core.$strict>>>;
|
|
245
|
+
}, z.core.$strict>>>>;
|
|
246
|
+
modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
247
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
248
|
+
permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
|
|
249
|
+
allow: "allow";
|
|
250
|
+
ask: "ask";
|
|
251
|
+
deny: "deny";
|
|
252
|
+
}>, z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
253
|
+
allow: "allow";
|
|
254
|
+
ask: "ask";
|
|
255
|
+
deny: "deny";
|
|
256
|
+
}>>]>>>;
|
|
257
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
258
|
+
description: z.ZodOptional<z.ZodString>;
|
|
259
|
+
model: z.ZodOptional<z.ZodString>;
|
|
260
|
+
}, z.core.$strict>>>;
|
|
261
|
+
confidential: z.ZodOptional<z.ZodObject<{
|
|
262
|
+
tee: z.ZodOptional<z.ZodString>;
|
|
263
|
+
attestationNonce: z.ZodOptional<z.ZodString>;
|
|
264
|
+
sealed: z.ZodOptional<z.ZodBoolean>;
|
|
265
|
+
attestationRefresh: z.ZodOptional<z.ZodBoolean>;
|
|
266
|
+
}, z.core.$strict>>;
|
|
267
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { agentCandidateResourcesSchema } from "./agent-candidate-artifact-schema.js";
|
|
3
|
+
import { agentCandidateConfigValueSchema, environmentConfigSchema, isCanonicalJsonValue, isSafeExecutable, isSafeRelativePath, isWellFormedUnicode, } from "./agent-candidate-schema-common.js";
|
|
4
|
+
import { harnessTypeSchema } from "./harness.js";
|
|
5
|
+
import { agentProfileConfidentialSchema, agentProfileModeSchema, agentProfileModelHintsSchema, agentProfilePermissionSchema, agentProfilePromptSchema, agentSubagentProfileSchema, } from "./profile-schema.js";
|
|
6
|
+
const executableSchema = z
|
|
7
|
+
.string()
|
|
8
|
+
.refine(isSafeExecutable, "executable must be a canonical non-shell command");
|
|
9
|
+
export const agentCandidateMcpServerSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
transport: z.literal("stdio").optional(),
|
|
12
|
+
command: executableSchema.optional(),
|
|
13
|
+
args: z.array(agentCandidateConfigValueSchema).optional(),
|
|
14
|
+
env: environmentConfigSchema.optional(),
|
|
15
|
+
cwd: z
|
|
16
|
+
.string()
|
|
17
|
+
.refine((value) => isSafeRelativePath(value, true), "MCP cwd must be a canonical workspace-relative path")
|
|
18
|
+
.optional(),
|
|
19
|
+
enabled: z.boolean().optional(),
|
|
20
|
+
})
|
|
21
|
+
.strict()
|
|
22
|
+
.superRefine((server, ctx) => {
|
|
23
|
+
if (server.enabled === false) {
|
|
24
|
+
if (server.transport !== undefined ||
|
|
25
|
+
server.command !== undefined ||
|
|
26
|
+
server.args !== undefined ||
|
|
27
|
+
server.env !== undefined ||
|
|
28
|
+
server.cwd !== undefined) {
|
|
29
|
+
ctx.addIssue({
|
|
30
|
+
code: "custom",
|
|
31
|
+
message: "disabled MCP servers cannot carry process fields",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (server.command === undefined) {
|
|
37
|
+
ctx.addIssue({
|
|
38
|
+
code: "custom",
|
|
39
|
+
path: ["command"],
|
|
40
|
+
message: "enabled stdio MCP servers require a command",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export const agentCandidateHookCommandSchema = z
|
|
45
|
+
.object({
|
|
46
|
+
executable: executableSchema,
|
|
47
|
+
args: z.array(agentCandidateConfigValueSchema).optional(),
|
|
48
|
+
timeoutMs: z.number().positive().optional(),
|
|
49
|
+
blocking: z.boolean().optional(),
|
|
50
|
+
matcher: z.string().refine(isWellFormedUnicode).optional(),
|
|
51
|
+
env: environmentConfigSchema.optional(),
|
|
52
|
+
})
|
|
53
|
+
.strict();
|
|
54
|
+
const candidateModelHintsSchema = agentProfileModelHintsSchema
|
|
55
|
+
.omit({ metadata: true })
|
|
56
|
+
.extend({
|
|
57
|
+
default: z.string().min(1).optional(),
|
|
58
|
+
small: z.string().min(1).optional(),
|
|
59
|
+
provider: z.string().min(1).optional(),
|
|
60
|
+
})
|
|
61
|
+
.strict();
|
|
62
|
+
const candidateSubagentSchema = agentSubagentProfileSchema
|
|
63
|
+
.omit({ metadata: true })
|
|
64
|
+
.extend({
|
|
65
|
+
model: z.string().min(1).optional(),
|
|
66
|
+
maxSteps: z.number().int().positive().optional(),
|
|
67
|
+
})
|
|
68
|
+
.strict();
|
|
69
|
+
const candidateModeSchema = agentProfileModeSchema
|
|
70
|
+
.omit({ metadata: true })
|
|
71
|
+
.extend({ model: z.string().min(1).optional() })
|
|
72
|
+
.strict();
|
|
73
|
+
export const agentCandidateProfileSchema = z
|
|
74
|
+
.object({
|
|
75
|
+
name: z.string().refine(isWellFormedUnicode).optional(),
|
|
76
|
+
description: z.string().refine(isWellFormedUnicode).optional(),
|
|
77
|
+
version: z.string().refine(isWellFormedUnicode).optional(),
|
|
78
|
+
tags: z.array(z.string().refine(isWellFormedUnicode)).optional(),
|
|
79
|
+
prompt: agentProfilePromptSchema.strict().optional(),
|
|
80
|
+
model: candidateModelHintsSchema.optional(),
|
|
81
|
+
harness: harnessTypeSchema.optional(),
|
|
82
|
+
permissions: z
|
|
83
|
+
.record(z.string(), agentProfilePermissionSchema)
|
|
84
|
+
.optional(),
|
|
85
|
+
tools: z.record(z.string(), z.boolean()).optional(),
|
|
86
|
+
mcp: z.record(z.string(), agentCandidateMcpServerSchema).optional(),
|
|
87
|
+
subagents: z.record(z.string(), candidateSubagentSchema).optional(),
|
|
88
|
+
resources: agentCandidateResourcesSchema.optional(),
|
|
89
|
+
hooks: z
|
|
90
|
+
.record(z.string(), z.array(agentCandidateHookCommandSchema))
|
|
91
|
+
.optional(),
|
|
92
|
+
modes: z.record(z.string(), candidateModeSchema).optional(),
|
|
93
|
+
confidential: agentProfileConfidentialSchema.strict().optional(),
|
|
94
|
+
})
|
|
95
|
+
.strict()
|
|
96
|
+
.superRefine((profile, ctx) => {
|
|
97
|
+
if (!isCanonicalJsonValue(profile)) {
|
|
98
|
+
ctx.addIssue({
|
|
99
|
+
code: "custom",
|
|
100
|
+
message: "candidate profile must contain only RFC 8785 JSON values",
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const primaryModel = profile.model?.default;
|
|
104
|
+
const alternateRoutes = [
|
|
105
|
+
...(profile.model?.small === undefined
|
|
106
|
+
? []
|
|
107
|
+
: [["model", "small", profile.model.small]]),
|
|
108
|
+
...Object.entries(profile.subagents ?? {}).flatMap(([name, subagent]) => subagent.model === undefined
|
|
109
|
+
? []
|
|
110
|
+
: [["subagents", name, "model", subagent.model]]),
|
|
111
|
+
...Object.entries(profile.modes ?? {}).flatMap(([name, mode]) => mode.model === undefined
|
|
112
|
+
? []
|
|
113
|
+
: [["modes", name, "model", mode.model]]),
|
|
114
|
+
];
|
|
115
|
+
for (const route of alternateRoutes) {
|
|
116
|
+
const routeModel = route.at(-1);
|
|
117
|
+
if (primaryModel === undefined || routeModel !== primaryModel) {
|
|
118
|
+
ctx.addIssue({
|
|
119
|
+
code: "custom",
|
|
120
|
+
path: route.slice(0, -1),
|
|
121
|
+
message: "sealed candidates require every model route to use the exact primary model",
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|