@tangle-network/agent-interface 0.25.0 → 0.26.1
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 +2 -2
- package/dist/agent-candidate-artifact-schema.d.ts +5 -5
- package/dist/agent-candidate-artifact-schema.js +30 -5
- package/dist/agent-candidate-code-schema.d.ts +3 -3
- package/dist/agent-candidate-execution-plan-schema.d.ts +149 -46
- package/dist/agent-candidate-execution-plan-schema.js +81 -9
- package/dist/agent-candidate-lineage-schema.d.ts +90 -3
- package/dist/agent-candidate-lineage-schema.js +17 -3
- package/dist/agent-candidate-outcome-schema.d.ts +259 -395
- package/dist/agent-candidate-outcome-schema.js +75 -64
- package/dist/agent-candidate-promotion-schema.d.ts +2708 -0
- package/dist/agent-candidate-promotion-schema.js +409 -0
- package/dist/agent-candidate-receipt-schema.d.ts +238 -1333
- package/dist/agent-candidate-receipt-schema.js +7 -116
- package/dist/agent-candidate-schema-common.d.ts +2 -0
- package/dist/agent-candidate-schema-common.js +8 -0
- package/dist/agent-candidate-schema.d.ts +94 -7
- package/dist/agent-candidate-schema.js +1 -1
- package/dist/agent-candidate.d.ts +251 -87
- package/dist/agent-candidate.test-fixture.d.ts +45 -11
- package/dist/agent-candidate.test-fixture.js +46 -12
- package/dist/agent-profile.js +5 -20
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { agentCandidateArtifactRefSchema, agentCandidateCapturedArtifactSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, } from "./agent-candidate-artifact-schema.js";
|
|
3
3
|
import { agentCandidateResolvedModelSchema } from "./agent-candidate-execution-plan-schema.js";
|
|
4
|
-
import { gitObjectSchema, isCanonicalJsonValue, sameGitObjectFormat, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
4
|
+
import { agentCandidateMediaTypeSchema, gitObjectSchema, isCanonicalJsonValue, sameGitObjectFormat, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
5
5
|
const safeCountSchema = z
|
|
6
6
|
.number()
|
|
7
7
|
.int()
|
|
@@ -24,18 +24,6 @@ export const agentCandidateFixedSpendSchema = z
|
|
|
24
24
|
})
|
|
25
25
|
.strict();
|
|
26
26
|
export const agentCandidateModelSettlementCallSchema = z
|
|
27
|
-
.object({
|
|
28
|
-
callId: boundedIdentifierSchema,
|
|
29
|
-
traceSpanId: boundedIdentifierSchema,
|
|
30
|
-
model: boundedIdentifierSchema,
|
|
31
|
-
inputTokens: safeCountSchema,
|
|
32
|
-
outputTokens: safeCountSchema,
|
|
33
|
-
cachedInputTokens: safeCountSchema,
|
|
34
|
-
reasoningTokens: safeCountSchema,
|
|
35
|
-
costUsdNanos: safeCountSchema,
|
|
36
|
-
})
|
|
37
|
-
.strict();
|
|
38
|
-
export const agentCandidateModelSettlementCallV2Schema = z
|
|
39
27
|
.object({
|
|
40
28
|
callId: boundedIdentifierSchema,
|
|
41
29
|
generationId: boundedIdentifierSchema,
|
|
@@ -76,26 +64,14 @@ const modelSettlementMaterialShape = {
|
|
|
76
64
|
resolved: agentCandidateResolvedModelSchema,
|
|
77
65
|
usage: agentCandidateFixedSpendSchema,
|
|
78
66
|
};
|
|
79
|
-
export const
|
|
80
|
-
.object({
|
|
81
|
-
schemaVersion: z.literal(1),
|
|
82
|
-
...modelSettlementMaterialShape,
|
|
83
|
-
calls: z.array(agentCandidateModelSettlementCallSchema),
|
|
84
|
-
})
|
|
85
|
-
.strict()
|
|
86
|
-
.superRefine(refineModelSettlementMaterial);
|
|
87
|
-
export const agentCandidateModelSettlementMaterialV2Schema = z
|
|
67
|
+
export const agentCandidateModelSettlementMaterialSchema = z
|
|
88
68
|
.object({
|
|
89
69
|
schemaVersion: z.literal(2),
|
|
90
70
|
...modelSettlementMaterialShape,
|
|
91
|
-
calls: z.array(
|
|
71
|
+
calls: z.array(agentCandidateModelSettlementCallSchema),
|
|
92
72
|
})
|
|
93
73
|
.strict()
|
|
94
74
|
.superRefine(refineModelSettlementMaterial);
|
|
95
|
-
export const agentCandidateModelSettlementMaterialSchema = z.union([
|
|
96
|
-
agentCandidateModelSettlementMaterialV1Schema,
|
|
97
|
-
agentCandidateModelSettlementMaterialV2Schema,
|
|
98
|
-
]);
|
|
99
75
|
function refineModelSettlementMaterial(material, ctx) {
|
|
100
76
|
const callIds = new Set();
|
|
101
77
|
const traceSpanIds = new Set();
|
|
@@ -125,19 +101,14 @@ function refineModelSettlementMaterial(material, ctx) {
|
|
|
125
101
|
});
|
|
126
102
|
}
|
|
127
103
|
traceSpanIds.add(call.traceSpanId);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
code: "custom",
|
|
135
|
-
path: ["calls", index, "generationId"],
|
|
136
|
-
message: "model settlement generation ids must be unique",
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
generationIds.add(generationId);
|
|
104
|
+
if (generationIds.has(call.generationId)) {
|
|
105
|
+
ctx.addIssue({
|
|
106
|
+
code: "custom",
|
|
107
|
+
path: ["calls", index, "generationId"],
|
|
108
|
+
message: "model settlement generation ids must be unique",
|
|
109
|
+
});
|
|
140
110
|
}
|
|
111
|
+
generationIds.add(call.generationId);
|
|
141
112
|
if (call.model !== material.resolved.model) {
|
|
142
113
|
ctx.addIssue({
|
|
143
114
|
code: "custom",
|
|
@@ -179,7 +150,7 @@ function refineModelSettlementMaterial(material, ctx) {
|
|
|
179
150
|
});
|
|
180
151
|
}
|
|
181
152
|
}
|
|
182
|
-
export const agentCandidateModelSettlementEvidenceSchema = evidenceSchema("agent-candidate-model-settlement", agentCandidateModelSettlementMaterialSchema, "model settlement");
|
|
153
|
+
export const agentCandidateModelSettlementEvidenceSchema = evidenceSchema(2, "agent-candidate-model-settlement", agentCandidateModelSettlementMaterialSchema, "model settlement");
|
|
183
154
|
export const agentCandidateRepositoryStateSchema = z
|
|
184
155
|
.object({
|
|
185
156
|
identity: z.string().min(1),
|
|
@@ -199,42 +170,82 @@ export const agentCandidateRepositoryStateSchema = z
|
|
|
199
170
|
});
|
|
200
171
|
export const agentCandidateTaskOutcomeMaterialSchema = z
|
|
201
172
|
.object({
|
|
202
|
-
schemaVersion: z.literal(
|
|
173
|
+
schemaVersion: z.literal(2),
|
|
203
174
|
kind: z.literal("agent-candidate-task-outcome-material"),
|
|
204
175
|
executionPlanDigest: sha256DigestSchema,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
176
|
+
outcome: z.discriminatedUnion("kind", [
|
|
177
|
+
z
|
|
178
|
+
.object({
|
|
179
|
+
kind: z.literal("workspace"),
|
|
180
|
+
baseRepository: agentCandidateRepositoryStateSchema,
|
|
181
|
+
resultRepository: agentCandidateRepositoryStateSchema,
|
|
182
|
+
afterState: agentCandidateWorkspaceSnapshotEvidenceSchema,
|
|
183
|
+
gitDiff: z
|
|
184
|
+
.object({
|
|
185
|
+
format: z.literal("git-diff-binary"),
|
|
186
|
+
artifact: agentCandidateArtifactRefSchema,
|
|
187
|
+
})
|
|
188
|
+
.strict(),
|
|
189
|
+
})
|
|
190
|
+
.strict(),
|
|
191
|
+
z
|
|
192
|
+
.object({
|
|
193
|
+
kind: z.literal("output"),
|
|
194
|
+
spec: z
|
|
195
|
+
.object({
|
|
196
|
+
mediaType: agentCandidateMediaTypeSchema,
|
|
197
|
+
maxBytes: z.number().int().positive().max(64 * 1024 * 1024),
|
|
198
|
+
})
|
|
199
|
+
.strict(),
|
|
200
|
+
artifact: agentCandidateArtifactRefSchema,
|
|
201
|
+
})
|
|
202
|
+
.strict(),
|
|
203
|
+
]),
|
|
214
204
|
})
|
|
215
205
|
.strict()
|
|
216
206
|
.superRefine((material, ctx) => {
|
|
217
|
-
if (material.
|
|
207
|
+
if (material.outcome.kind === "workspace" &&
|
|
208
|
+
material.outcome.baseRepository.identity !==
|
|
209
|
+
material.outcome.resultRepository.identity) {
|
|
218
210
|
ctx.addIssue({
|
|
219
211
|
code: "custom",
|
|
220
|
-
path: ["resultRepository", "identity"],
|
|
212
|
+
path: ["outcome", "resultRepository", "identity"],
|
|
221
213
|
message: "base and result repository identities must match",
|
|
222
214
|
});
|
|
223
215
|
}
|
|
224
|
-
if (material.
|
|
225
|
-
material.
|
|
216
|
+
if (material.outcome.kind === "workspace" &&
|
|
217
|
+
material.outcome.baseRepository.rootIdentity !==
|
|
218
|
+
material.outcome.resultRepository.rootIdentity) {
|
|
226
219
|
ctx.addIssue({
|
|
227
220
|
code: "custom",
|
|
228
|
-
path: ["resultRepository", "rootIdentity"],
|
|
221
|
+
path: ["outcome", "resultRepository", "rootIdentity"],
|
|
229
222
|
message: "base and result repository roots must match",
|
|
230
223
|
});
|
|
231
224
|
}
|
|
232
|
-
if (
|
|
233
|
-
!sameGitObjectFormat(material.baseRepository.
|
|
225
|
+
if (material.outcome.kind === "workspace") {
|
|
226
|
+
if (!sameGitObjectFormat(material.outcome.baseRepository.commit, material.outcome.resultRepository.commit) ||
|
|
227
|
+
!sameGitObjectFormat(material.outcome.baseRepository.tree, material.outcome.resultRepository.tree)) {
|
|
228
|
+
ctx.addIssue({
|
|
229
|
+
code: "custom",
|
|
230
|
+
path: ["outcome", "resultRepository"],
|
|
231
|
+
message: "base and result repositories must use one Git object format",
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (material.outcome.kind === "output" &&
|
|
236
|
+
material.outcome.artifact.byteLength === 0) {
|
|
237
|
+
ctx.addIssue({
|
|
238
|
+
code: "custom",
|
|
239
|
+
path: ["outcome", "artifact"],
|
|
240
|
+
message: "task outcome artifact cannot be empty",
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (material.outcome.kind === "output" &&
|
|
244
|
+
material.outcome.artifact.byteLength > material.outcome.spec.maxBytes) {
|
|
234
245
|
ctx.addIssue({
|
|
235
246
|
code: "custom",
|
|
236
|
-
path: ["
|
|
237
|
-
message: "
|
|
247
|
+
path: ["outcome", "artifact", "byteLength"],
|
|
248
|
+
message: "task outcome artifact exceeds its signed byte limit",
|
|
238
249
|
});
|
|
239
250
|
}
|
|
240
251
|
if (!isCanonicalJsonValue(material)) {
|
|
@@ -244,7 +255,7 @@ export const agentCandidateTaskOutcomeMaterialSchema = z
|
|
|
244
255
|
});
|
|
245
256
|
}
|
|
246
257
|
});
|
|
247
|
-
export const agentCandidateTaskOutcomeEvidenceSchema = evidenceSchema("agent-candidate-task-outcome", agentCandidateTaskOutcomeMaterialSchema, "task outcome");
|
|
258
|
+
export const agentCandidateTaskOutcomeEvidenceSchema = evidenceSchema(2, "agent-candidate-task-outcome", agentCandidateTaskOutcomeMaterialSchema, "task outcome");
|
|
248
259
|
export const agentCandidateBenchmarkDimensionSchema = z
|
|
249
260
|
.object({
|
|
250
261
|
name: normalizedDimensionNameSchema,
|
|
@@ -318,8 +329,8 @@ export const agentCandidateBenchmarkResultMaterialSchema = z
|
|
|
318
329
|
});
|
|
319
330
|
}
|
|
320
331
|
});
|
|
321
|
-
export const agentCandidateBenchmarkResultEvidenceSchema = evidenceSchema("agent-candidate-benchmark-result", agentCandidateBenchmarkResultMaterialSchema, "benchmark result");
|
|
322
|
-
|
|
332
|
+
export const agentCandidateBenchmarkResultEvidenceSchema = evidenceSchema(1, "agent-candidate-benchmark-result", agentCandidateBenchmarkResultMaterialSchema, "benchmark result");
|
|
333
|
+
function sameFixedSpend(left, right) {
|
|
323
334
|
return (left.inputTokens === right.inputTokens &&
|
|
324
335
|
left.outputTokens === right.outputTokens &&
|
|
325
336
|
left.cachedInputTokens === right.cachedInputTokens &&
|
|
@@ -327,10 +338,10 @@ export function sameFixedSpend(left, right) {
|
|
|
327
338
|
left.modelCalls === right.modelCalls &&
|
|
328
339
|
left.costUsdNanos === right.costUsdNanos);
|
|
329
340
|
}
|
|
330
|
-
function evidenceSchema(kind, material, label) {
|
|
341
|
+
function evidenceSchema(schemaVersion, kind, material, label) {
|
|
331
342
|
return z
|
|
332
343
|
.object({
|
|
333
|
-
schemaVersion: z.literal(
|
|
344
|
+
schemaVersion: z.literal(schemaVersion),
|
|
334
345
|
kind: z.literal(kind),
|
|
335
346
|
digest: sha256DigestSchema,
|
|
336
347
|
material,
|