@tangle-network/agent-interface 0.27.1 → 0.28.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 -2
- package/dist/agent-candidate-execution-plan-schema.d.ts +0 -32
- package/dist/agent-candidate-execution-plan-schema.js +3 -7
- package/dist/agent-candidate-lineage-schema.d.ts +0 -3
- package/dist/agent-candidate-lineage-schema.js +0 -1
- package/dist/agent-candidate-outcome-schema.d.ts +0 -18
- package/dist/agent-candidate-outcome-schema.js +4 -8
- package/dist/agent-candidate-promotion-schema.d.ts +0 -53
- package/dist/agent-candidate-promotion-schema.js +0 -4
- package/dist/agent-candidate-receipt-schema.d.ts +0 -41
- package/dist/agent-candidate-receipt-schema.js +0 -3
- package/dist/agent-candidate-schema.d.ts +0 -6
- package/dist/agent-candidate-schema.js +0 -1
- package/dist/agent-candidate.d.ts +0 -22
- package/dist/agent-candidate.test-fixture.d.ts +0 -6
- package/dist/agent-candidate.test-fixture.js +0 -6
- 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.js +4 -3
- package/package.json +2 -1
- package/dist/agent-candidate-compat.d.ts +0 -1918
- package/dist/agent-candidate-compat.js +0 -340
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backward-compatibility surface for the candidate outcome and receipt exports
|
|
3
|
-
* that were renamed or collapsed when the candidate contract was unified.
|
|
4
|
-
*
|
|
5
|
-
* Every symbol here is deprecated and exists only so published consumers that
|
|
6
|
-
* still import the pre-unification names keep resolving at ESM import time.
|
|
7
|
-
* Prefer the current names; these will be removed in a future major.
|
|
8
|
-
*
|
|
9
|
-
* Two shapes of compat live in this module:
|
|
10
|
-
* - Pure renames (shape-identical to a current export) are re-exported as
|
|
11
|
-
* deprecated aliases and remain reference-equal to their new counterpart.
|
|
12
|
-
* - Symbols whose shape changed (a different `schemaVersion` literal, a
|
|
13
|
-
* restructured field, or a union that no longer exists) are re-declared here
|
|
14
|
-
* verbatim from the last release that published them, so old data still
|
|
15
|
-
* parses against the old name instead of silently binding to a newer shape.
|
|
16
|
-
*/
|
|
17
|
-
import { z } from "zod";
|
|
18
|
-
import { agentCandidateModelSettlementCallSchema, agentCandidateModelSettlementEvidenceSchema, agentCandidateModelSettlementMaterialSchema, agentCandidateBenchmarkResultEvidenceSchema, agentCandidateFixedSpendSchema, agentCandidateTaskOutcomeEvidenceSchema, } from "./agent-candidate-outcome-schema.js";
|
|
19
|
-
import { agentCandidateResolvedModelSchema } from "./agent-candidate-execution-plan-schema.js";
|
|
20
|
-
import { agentCandidateSpendSchema } from "./agent-candidate-lineage-schema.js";
|
|
21
|
-
import { agentCandidateMemoryReceiptSchema, agentCandidateTerminationSchema, agentCandidateTraceEvidenceSchema, } from "./agent-candidate-receipt-schema.js";
|
|
22
|
-
import { isCanonicalJsonValue, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Renamed to {@link agentCandidateModelSettlementCallSchema}.
|
|
25
|
-
* Reference-equal to the current export.
|
|
26
|
-
*/
|
|
27
|
-
export const agentCandidateModelSettlementCallV2Schema = agentCandidateModelSettlementCallSchema;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Renamed to {@link agentCandidateModelSettlementMaterialSchema}.
|
|
30
|
-
* Reference-equal to the current export.
|
|
31
|
-
*/
|
|
32
|
-
export const agentCandidateModelSettlementMaterialV2Schema = agentCandidateModelSettlementMaterialSchema;
|
|
33
|
-
// -----------------------------------------------------------------------------
|
|
34
|
-
// Re-added schemas.
|
|
35
|
-
// -----------------------------------------------------------------------------
|
|
36
|
-
const safeCountSchema = z
|
|
37
|
-
.number()
|
|
38
|
-
.int()
|
|
39
|
-
.nonnegative()
|
|
40
|
-
.refine(Number.isSafeInteger, "value must be a nonnegative safe integer");
|
|
41
|
-
const boundedIdentifierSchema = z.string().min(1).max(256);
|
|
42
|
-
/**
|
|
43
|
-
* @deprecated The run receipt no longer carries a standalone model-usage block.
|
|
44
|
-
* Restored `resolved`/`usage` schema for consumers of the V1/V2 run receipt.
|
|
45
|
-
*/
|
|
46
|
-
export const agentCandidateModelUsageSchema = z
|
|
47
|
-
.object({
|
|
48
|
-
resolved: agentCandidateResolvedModelSchema,
|
|
49
|
-
usage: agentCandidateSpendSchema,
|
|
50
|
-
})
|
|
51
|
-
.strict();
|
|
52
|
-
/**
|
|
53
|
-
* Restored per-call aggregate and canonical-value checks shared by the V1
|
|
54
|
-
* settlement material. Mirrors the current internal refinement but tolerates
|
|
55
|
-
* the pre-router call shape that omits `generationId`.
|
|
56
|
-
*/
|
|
57
|
-
function refineLegacyModelSettlementMaterial(material, ctx) {
|
|
58
|
-
const callIds = new Set();
|
|
59
|
-
const traceSpanIds = new Set();
|
|
60
|
-
const totals = {
|
|
61
|
-
inputTokens: 0,
|
|
62
|
-
outputTokens: 0,
|
|
63
|
-
cachedInputTokens: 0,
|
|
64
|
-
reasoningTokens: 0,
|
|
65
|
-
modelCalls: material.calls.length,
|
|
66
|
-
costUsdNanos: 0,
|
|
67
|
-
};
|
|
68
|
-
for (const [index, call] of material.calls.entries()) {
|
|
69
|
-
if (callIds.has(call.callId)) {
|
|
70
|
-
ctx.addIssue({
|
|
71
|
-
code: "custom",
|
|
72
|
-
path: ["calls", index, "callId"],
|
|
73
|
-
message: "model settlement call ids must be unique",
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
callIds.add(call.callId);
|
|
77
|
-
if (traceSpanIds.has(call.traceSpanId)) {
|
|
78
|
-
ctx.addIssue({
|
|
79
|
-
code: "custom",
|
|
80
|
-
path: ["calls", index, "traceSpanId"],
|
|
81
|
-
message: "model settlement trace span ids must be unique",
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
traceSpanIds.add(call.traceSpanId);
|
|
85
|
-
if (call.model !== material.resolved.model) {
|
|
86
|
-
ctx.addIssue({
|
|
87
|
-
code: "custom",
|
|
88
|
-
path: ["calls", index, "model"],
|
|
89
|
-
message: "settled call model must match the resolved single model",
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
for (const field of [
|
|
93
|
-
"inputTokens",
|
|
94
|
-
"outputTokens",
|
|
95
|
-
"cachedInputTokens",
|
|
96
|
-
"reasoningTokens",
|
|
97
|
-
"costUsdNanos",
|
|
98
|
-
]) {
|
|
99
|
-
const sum = totals[field] + call[field];
|
|
100
|
-
if (!Number.isSafeInteger(sum)) {
|
|
101
|
-
ctx.addIssue({
|
|
102
|
-
code: "custom",
|
|
103
|
-
path: ["calls", index, field],
|
|
104
|
-
message: `model settlement ${field} total exceeds safe integer range`,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
totals[field] = sum;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (!sameFixedSpend(totals, material.usage)) {
|
|
113
|
-
ctx.addIssue({
|
|
114
|
-
code: "custom",
|
|
115
|
-
path: ["usage"],
|
|
116
|
-
message: "model settlement usage must equal the exact per-call aggregate",
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
if (!isCanonicalJsonValue(material)) {
|
|
120
|
-
ctx.addIssue({
|
|
121
|
-
code: "custom",
|
|
122
|
-
message: "model settlement material must contain only RFC 8785 JSON values",
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const legacyModelSettlementCallV1Schema = z
|
|
127
|
-
.object({
|
|
128
|
-
callId: boundedIdentifierSchema,
|
|
129
|
-
traceSpanId: boundedIdentifierSchema,
|
|
130
|
-
model: boundedIdentifierSchema,
|
|
131
|
-
inputTokens: safeCountSchema,
|
|
132
|
-
outputTokens: safeCountSchema,
|
|
133
|
-
cachedInputTokens: safeCountSchema,
|
|
134
|
-
reasoningTokens: safeCountSchema,
|
|
135
|
-
costUsdNanos: safeCountSchema,
|
|
136
|
-
})
|
|
137
|
-
.strict();
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated The settlement material collapsed to
|
|
140
|
-
* {@link agentCandidateModelSettlementMaterialSchema} (`schemaVersion: 2`).
|
|
141
|
-
* Restored `schemaVersion: 1` parser for the pre-router base call shape.
|
|
142
|
-
*/
|
|
143
|
-
export const agentCandidateModelSettlementMaterialV1Schema = z
|
|
144
|
-
.object({
|
|
145
|
-
schemaVersion: z.literal(1),
|
|
146
|
-
kind: z.literal("agent-candidate-model-settlement-material"),
|
|
147
|
-
executionPlanDigest: sha256DigestSchema,
|
|
148
|
-
preparationId: boundedIdentifierSchema,
|
|
149
|
-
grantDigest: sha256DigestSchema,
|
|
150
|
-
closed: z.literal(true),
|
|
151
|
-
resolved: agentCandidateResolvedModelSchema,
|
|
152
|
-
usage: agentCandidateFixedSpendSchema,
|
|
153
|
-
calls: z.array(legacyModelSettlementCallV1Schema),
|
|
154
|
-
})
|
|
155
|
-
.strict()
|
|
156
|
-
.superRefine(refineLegacyModelSettlementMaterial);
|
|
157
|
-
/**
|
|
158
|
-
* @deprecated The run receipt collapsed to
|
|
159
|
-
* {@link agentCandidateRunReceiptSchema} (`schemaVersion: 3`). Restored
|
|
160
|
-
* `schemaVersion: 1` parser with aggregate usage accounting.
|
|
161
|
-
*/
|
|
162
|
-
export const agentCandidateRunReceiptV1Schema = z
|
|
163
|
-
.object({
|
|
164
|
-
schemaVersion: z.literal(1),
|
|
165
|
-
kind: z.literal("agent-candidate-run"),
|
|
166
|
-
digestAlgorithm: z.literal("rfc8785-sha256"),
|
|
167
|
-
bundleDigest: sha256DigestSchema,
|
|
168
|
-
materializationReceiptDigest: sha256DigestSchema,
|
|
169
|
-
executionPlanDigest: sha256DigestSchema,
|
|
170
|
-
memory: agentCandidateMemoryReceiptSchema,
|
|
171
|
-
usage: agentCandidateSpendSchema,
|
|
172
|
-
modelUsage: agentCandidateModelUsageSchema,
|
|
173
|
-
trace: agentCandidateTraceEvidenceSchema,
|
|
174
|
-
termination: agentCandidateTerminationSchema,
|
|
175
|
-
digest: sha256DigestSchema,
|
|
176
|
-
})
|
|
177
|
-
.strict()
|
|
178
|
-
.superRefine((receipt, ctx) => {
|
|
179
|
-
const usageMatchesModel = receipt.usage.costUsd === receipt.modelUsage.usage.costUsd &&
|
|
180
|
-
receipt.usage.inputTokens === receipt.modelUsage.usage.inputTokens &&
|
|
181
|
-
receipt.usage.outputTokens === receipt.modelUsage.usage.outputTokens &&
|
|
182
|
-
receipt.usage.cachedInputTokens ===
|
|
183
|
-
receipt.modelUsage.usage.cachedInputTokens &&
|
|
184
|
-
receipt.usage.modelCalls === receipt.modelUsage.usage.modelCalls;
|
|
185
|
-
if (!usageMatchesModel) {
|
|
186
|
-
ctx.addIssue({
|
|
187
|
-
code: "custom",
|
|
188
|
-
path: ["modelUsage", "usage"],
|
|
189
|
-
message: "single-model usage must equal aggregate protected usage",
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
if (receipt.trace.modelCallCount !== receipt.modelUsage.usage.modelCalls) {
|
|
193
|
-
ctx.addIssue({
|
|
194
|
-
code: "custom",
|
|
195
|
-
path: ["trace", "modelCallCount"],
|
|
196
|
-
message: "trace model-call count must match protected single-model usage",
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
if (!isCanonicalJsonValue(receipt)) {
|
|
200
|
-
ctx.addIssue({
|
|
201
|
-
code: "custom",
|
|
202
|
-
message: "run receipt must contain only RFC 8785 JSON values",
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
function legacyUsageMatchesFixed(legacy, fixed) {
|
|
207
|
-
return (legacy.costUsd === fixed.costUsdNanos / 1_000_000_000 &&
|
|
208
|
-
legacy.inputTokens === fixed.inputTokens &&
|
|
209
|
-
legacy.outputTokens === fixed.outputTokens &&
|
|
210
|
-
(legacy.cachedInputTokens ?? 0) === fixed.cachedInputTokens &&
|
|
211
|
-
legacy.modelCalls === fixed.modelCalls);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* @deprecated The run receipt collapsed to
|
|
215
|
-
* {@link agentCandidateRunReceiptSchema} (`schemaVersion: 3`). Restored
|
|
216
|
-
* `schemaVersion: 2` parser. Its evidence members bind the current settlement,
|
|
217
|
-
* task-outcome, and benchmark-result schemas.
|
|
218
|
-
*/
|
|
219
|
-
export const agentCandidateRunReceiptV2Schema = z
|
|
220
|
-
.object({
|
|
221
|
-
schemaVersion: z.literal(2),
|
|
222
|
-
kind: z.literal("agent-candidate-run"),
|
|
223
|
-
digestAlgorithm: z.literal("rfc8785-sha256"),
|
|
224
|
-
bundleDigest: sha256DigestSchema,
|
|
225
|
-
materializationReceiptDigest: sha256DigestSchema,
|
|
226
|
-
executionPlanDigest: sha256DigestSchema,
|
|
227
|
-
memory: agentCandidateMemoryReceiptSchema,
|
|
228
|
-
usage: agentCandidateSpendSchema,
|
|
229
|
-
modelUsage: agentCandidateModelUsageSchema,
|
|
230
|
-
trace: agentCandidateTraceEvidenceSchema,
|
|
231
|
-
termination: agentCandidateTerminationSchema,
|
|
232
|
-
fixedUsage: agentCandidateFixedSpendSchema,
|
|
233
|
-
modelSettlement: agentCandidateModelSettlementEvidenceSchema,
|
|
234
|
-
taskOutcome: agentCandidateTaskOutcomeEvidenceSchema,
|
|
235
|
-
benchmarkResult: agentCandidateBenchmarkResultEvidenceSchema,
|
|
236
|
-
digest: sha256DigestSchema,
|
|
237
|
-
})
|
|
238
|
-
.strict()
|
|
239
|
-
.superRefine((receipt, ctx) => {
|
|
240
|
-
const legacyUsageMatchesModel = receipt.usage.costUsd === receipt.modelUsage.usage.costUsd &&
|
|
241
|
-
receipt.usage.inputTokens === receipt.modelUsage.usage.inputTokens &&
|
|
242
|
-
receipt.usage.outputTokens === receipt.modelUsage.usage.outputTokens &&
|
|
243
|
-
receipt.usage.cachedInputTokens ===
|
|
244
|
-
receipt.modelUsage.usage.cachedInputTokens &&
|
|
245
|
-
receipt.usage.modelCalls === receipt.modelUsage.usage.modelCalls;
|
|
246
|
-
if (!legacyUsageMatchesModel) {
|
|
247
|
-
ctx.addIssue({
|
|
248
|
-
code: "custom",
|
|
249
|
-
path: ["modelUsage", "usage"],
|
|
250
|
-
message: "single-model usage must equal aggregate protected usage",
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
if (!legacyUsageMatchesFixed(receipt.usage, receipt.fixedUsage)) {
|
|
254
|
-
ctx.addIssue({
|
|
255
|
-
code: "custom",
|
|
256
|
-
path: ["fixedUsage"],
|
|
257
|
-
message: "fixed usage must exactly preserve the legacy usage totals",
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
if (!sameFixedSpend(receipt.fixedUsage, receipt.modelSettlement.material.usage)) {
|
|
261
|
-
ctx.addIssue({
|
|
262
|
-
code: "custom",
|
|
263
|
-
path: ["modelSettlement", "material", "usage"],
|
|
264
|
-
message: "model settlement aggregate must equal fixed run usage",
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
if (JSON.stringify(receipt.modelUsage.resolved) !==
|
|
268
|
-
JSON.stringify(receipt.modelSettlement.material.resolved)) {
|
|
269
|
-
ctx.addIssue({
|
|
270
|
-
code: "custom",
|
|
271
|
-
path: ["modelSettlement", "material", "resolved"],
|
|
272
|
-
message: "model settlement must bind the run's resolved model",
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
if (receipt.modelSettlement.material.executionPlanDigest !==
|
|
276
|
-
receipt.executionPlanDigest) {
|
|
277
|
-
ctx.addIssue({
|
|
278
|
-
code: "custom",
|
|
279
|
-
path: ["modelSettlement", "material", "executionPlanDigest"],
|
|
280
|
-
message: "model settlement must bind the executed plan",
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
if (receipt.trace.modelCallCount !== receipt.fixedUsage.modelCalls) {
|
|
284
|
-
ctx.addIssue({
|
|
285
|
-
code: "custom",
|
|
286
|
-
path: ["trace", "modelCallCount"],
|
|
287
|
-
message: "trace model-call count must match fixed run usage",
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
if (receipt.taskOutcome.material.executionPlanDigest !==
|
|
291
|
-
receipt.executionPlanDigest) {
|
|
292
|
-
ctx.addIssue({
|
|
293
|
-
code: "custom",
|
|
294
|
-
path: ["taskOutcome", "material", "executionPlanDigest"],
|
|
295
|
-
message: "task outcome must bind the executed plan",
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
if (receipt.benchmarkResult.material.executionPlanDigest !==
|
|
299
|
-
receipt.executionPlanDigest) {
|
|
300
|
-
ctx.addIssue({
|
|
301
|
-
code: "custom",
|
|
302
|
-
path: ["benchmarkResult", "material", "executionPlanDigest"],
|
|
303
|
-
message: "benchmark result must bind the executed plan",
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
if (receipt.benchmarkResult.material.taskOutcomeDigest !==
|
|
307
|
-
receipt.taskOutcome.digest) {
|
|
308
|
-
ctx.addIssue({
|
|
309
|
-
code: "custom",
|
|
310
|
-
path: ["benchmarkResult", "material", "taskOutcomeDigest"],
|
|
311
|
-
message: "benchmark result must bind the exact task outcome",
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
if (!isCanonicalJsonValue(receipt)) {
|
|
315
|
-
ctx.addIssue({
|
|
316
|
-
code: "custom",
|
|
317
|
-
message: "run receipt must contain only RFC 8785 JSON values",
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
/**
|
|
322
|
-
* @deprecated The run receipt generations collapsed into a single current
|
|
323
|
-
* schema. Restored union parser for consumers that accepted both generations.
|
|
324
|
-
*/
|
|
325
|
-
export const agentCandidateRunReceiptAnyVersionSchema = z.union([
|
|
326
|
-
agentCandidateRunReceiptV1Schema,
|
|
327
|
-
agentCandidateRunReceiptV2Schema,
|
|
328
|
-
]);
|
|
329
|
-
/**
|
|
330
|
-
* @deprecated No longer exported from the outcome module. Restored spend-equality
|
|
331
|
-
* helper for consumers that compared fixed-point usage totals.
|
|
332
|
-
*/
|
|
333
|
-
export function sameFixedSpend(left, right) {
|
|
334
|
-
return (left.inputTokens === right.inputTokens &&
|
|
335
|
-
left.outputTokens === right.outputTokens &&
|
|
336
|
-
left.cachedInputTokens === right.cachedInputTokens &&
|
|
337
|
-
left.reasoningTokens === right.reasoningTokens &&
|
|
338
|
-
left.modelCalls === right.modelCalls &&
|
|
339
|
-
left.costUsdNanos === right.costUsdNanos);
|
|
340
|
-
}
|