@tangle-network/agent-eval 0.125.0 → 0.126.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +62 -35
  2. package/README.md +270 -189
  3. package/dist/analyst/index.d.ts +15 -145
  4. package/dist/analyst/index.js +33 -47
  5. package/dist/analyst/index.js.map +1 -1
  6. package/dist/benchmarks/index.d.ts +45 -162
  7. package/dist/benchmarks/index.js +8 -9
  8. package/dist/campaign/index.d.ts +3674 -5393
  9. package/dist/campaign/index.js +21 -95
  10. package/dist/{chunk-R226UZOI.js → chunk-474LBSOX.js} +2 -2
  11. package/dist/{chunk-HM6V7F3M.js → chunk-FO7HEH76.js} +3 -3
  12. package/dist/chunk-IILEIWGW.js +635 -0
  13. package/dist/chunk-IILEIWGW.js.map +1 -0
  14. package/dist/{chunk-EQUK3RFS.js → chunk-J5SQWP6Y.js} +8 -5
  15. package/dist/chunk-J5SQWP6Y.js.map +1 -0
  16. package/dist/{chunk-W5B3ZGP3.js → chunk-KE2VWPZX.js} +8 -6
  17. package/dist/{chunk-W5B3ZGP3.js.map → chunk-KE2VWPZX.js.map} +1 -1
  18. package/dist/{chunk-DT7OXY3C.js → chunk-LUNF2SEL.js} +538 -851
  19. package/dist/chunk-LUNF2SEL.js.map +1 -0
  20. package/dist/chunk-NGUYT5CI.js +4637 -0
  21. package/dist/chunk-NGUYT5CI.js.map +1 -0
  22. package/dist/{chunk-QFQZ3U3X.js → chunk-OCFJACJU.js} +2 -2
  23. package/dist/{chunk-GID26AN4.js → chunk-P22LJ3Y2.js} +4 -6
  24. package/dist/{chunk-GID26AN4.js.map → chunk-P22LJ3Y2.js.map} +1 -1
  25. package/dist/{chunk-SJT4OBVL.js → chunk-SDPM6554.js} +3 -3
  26. package/dist/{chunk-D5JZ7UDZ.js → chunk-UCLVDLCH.js} +136 -50
  27. package/dist/chunk-UCLVDLCH.js.map +1 -0
  28. package/dist/chunk-VMUENW6F.js +7274 -0
  29. package/dist/chunk-VMUENW6F.js.map +1 -0
  30. package/dist/{chunk-JKDNAOF5.js → chunk-W4L6C2XT.js} +2 -2
  31. package/dist/chunk-WGXIEX7P.js +116 -0
  32. package/dist/chunk-WGXIEX7P.js.map +1 -0
  33. package/dist/{chunk-GRCDRKII.js → chunk-WS3NZZQQ.js} +58 -20
  34. package/dist/chunk-WS3NZZQQ.js.map +1 -0
  35. package/dist/cli.js +3 -3
  36. package/dist/contract/index.d.ts +3220 -3094
  37. package/dist/contract/index.js +173 -42
  38. package/dist/contract/index.js.map +1 -1
  39. package/dist/control.js +2 -3
  40. package/dist/fuzz.d.ts +14 -1
  41. package/dist/fuzz.js +1 -1
  42. package/dist/hosted/index.d.ts +8 -1
  43. package/dist/index.d.ts +71 -687
  44. package/dist/index.js +178 -497
  45. package/dist/index.js.map +1 -1
  46. package/dist/openapi.json +1 -1
  47. package/dist/rl.d.ts +5 -100
  48. package/dist/rl.js +4 -5
  49. package/dist/rl.js.map +1 -1
  50. package/dist/{run-campaign-I3JXKVAK.js → run-campaign-LVFKZCEU.js} +3 -3
  51. package/dist/traces.js +2 -3
  52. package/dist/wire/index.d.ts +14 -1
  53. package/dist/wire/index.js +3 -3
  54. package/docs/campaign-proposers.md +363 -168
  55. package/docs/design/loop-taxonomy.md +142 -190
  56. package/docs/design.md +1 -1
  57. package/docs/distributed-driver.md +8 -11
  58. package/docs/feature-guide.md +20 -19
  59. package/docs/knowledge-readiness.md +2 -5
  60. package/docs/multi-shot-optimization.md +35 -27
  61. package/docs/rollout.md +5 -5
  62. package/package.json +4 -4
  63. package/dist/chunk-A62YMFWA.js +0 -9269
  64. package/dist/chunk-A62YMFWA.js.map +0 -1
  65. package/dist/chunk-A6GT67HT.js +0 -550
  66. package/dist/chunk-A6GT67HT.js.map +0 -1
  67. package/dist/chunk-D5JZ7UDZ.js.map +0 -1
  68. package/dist/chunk-DT7OXY3C.js.map +0 -1
  69. package/dist/chunk-EQUK3RFS.js.map +0 -1
  70. package/dist/chunk-GC4ATIKK.js +0 -317
  71. package/dist/chunk-GC4ATIKK.js.map +0 -1
  72. package/dist/chunk-GRCDRKII.js.map +0 -1
  73. package/dist/chunk-LOW3U7JZ.js +0 -328
  74. package/dist/chunk-LOW3U7JZ.js.map +0 -1
  75. package/dist/chunk-PMITBABE.js +0 -3841
  76. package/dist/chunk-PMITBABE.js.map +0 -1
  77. /package/dist/{chunk-R226UZOI.js.map → chunk-474LBSOX.js.map} +0 -0
  78. /package/dist/{chunk-HM6V7F3M.js.map → chunk-FO7HEH76.js.map} +0 -0
  79. /package/dist/{chunk-QFQZ3U3X.js.map → chunk-OCFJACJU.js.map} +0 -0
  80. /package/dist/{chunk-SJT4OBVL.js.map → chunk-SDPM6554.js.map} +0 -0
  81. /package/dist/{chunk-JKDNAOF5.js.map → chunk-W4L6C2XT.js.map} +0 -0
  82. /package/dist/{run-campaign-I3JXKVAK.js.map → run-campaign-LVFKZCEU.js.map} +0 -0
@@ -1,31 +1,3 @@
1
- type AgentProfileCellSchemaVersion = 'agent-profile-cell/v1';
2
- type AgentProfileJsonObject = {
3
- [key: string]: AgentProfileJson;
4
- };
5
- type AgentProfileJson = string | number | boolean | null | AgentProfileJson[] | AgentProfileJsonObject;
6
- type AgentProfileDimensionValue = string | number | boolean | null;
7
- interface AgentProfileSource {
8
- /** Runtime/profile contract being fingerprinted, e.g. `agent-interface-profile`. */
9
- kind: string;
10
- /** sha256 over the canonical source profile object. */
11
- hash: string;
12
- }
13
- interface AgentProfileHarness {
14
- id: string;
15
- version?: string;
16
- hash?: string;
17
- }
18
- interface AgentProfileCell {
19
- schemaVersion: AgentProfileCellSchemaVersion;
20
- cellId: string;
21
- profileId: string;
22
- sourceProfile: AgentProfileSource;
23
- harness?: AgentProfileHarness;
24
- model?: string;
25
- promptHash?: string;
26
- dimensions?: Record<string, AgentProfileDimensionValue>;
27
- }
28
-
29
1
  type CostChannel = 'agent' | 'judge' | 'verifier' | 'analyst' | 'driver' | (string & {});
30
2
  interface CostUsage {
31
3
  inputTokens: number;
@@ -53,29 +25,40 @@ interface CostReceipt extends CostCallBase, CostUsage {
53
25
  costUsd: number;
54
26
  costUnknown: boolean;
55
27
  usageUnknown?: boolean;
28
+ /** Rates used to estimate cost locally. Absent when cost is provider-reported or unknown. */
56
29
  pricing?: {
57
30
  inputUsdPerThousand: number;
31
+ cachedInputUsdPerThousand?: number;
32
+ cacheWriteUsdPerThousand?: number;
58
33
  outputUsdPerThousand: number;
59
34
  };
35
+ /** Cost reported by the provider, not a local token-price calculation. */
60
36
  actualCostUsd?: number;
61
37
  error?: string;
62
38
  }
63
39
  interface CostReceiptInput extends CostUsage {
64
40
  model: string;
41
+ /** Caller-supplied rates for a local estimate when the provider does not report billed cost. */
42
+ customTokenPricing?: CustomTokenPricing;
65
43
  actualCostUsd?: number;
66
44
  costUnknown?: boolean;
67
45
  usageUnknown?: boolean;
68
46
  }
69
47
  /** Per-million token rates for a model or endpoint not covered by package pricing. */
70
48
  interface CustomTokenPricing {
49
+ /** Non-cached input tokens. */
71
50
  inputUsdPerMillion: number;
51
+ /** Cache-read tokens. Falls back to the normal input rate when omitted. */
52
+ cachedInputUsdPerMillion?: number;
53
+ /** Cache-creation or cache-write tokens. Falls back to the normal input rate when omitted. */
54
+ cacheWriteUsdPerMillion?: number;
72
55
  outputUsdPerMillion: number;
73
56
  }
74
57
  type MaximumCharge = {
75
58
  externallyEnforcedMaximumUsd: number;
76
59
  } | ({
77
60
  customTokenPricing: CustomTokenPricing;
78
- } & Pick<CostUsage, 'inputTokens' | 'outputTokens'>) | ({
61
+ } & Pick<CostUsage, 'inputTokens' | 'outputTokens' | 'cachedTokens' | 'cacheWriteTokens'>) | ({
79
62
  model: string;
80
63
  } & CostUsage);
81
64
  interface RunPaidCallInput<T> {
@@ -136,46 +119,6 @@ interface CostLedgerSummary {
136
119
  incompleteReasons: string[];
137
120
  }
138
121
 
139
- /**
140
- * Paper-grade RunRecord schema + runtime validator.
141
- *
142
- * Every run that participates in a promotion gate, paper table, or
143
- * researcher loop SHOULD be recorded as a `RunRecord`. The mandatory
144
- * fields are exactly those the paper "Two Loops, Three Roles" requires
145
- * for reproducibility: who/what/when/cost/seed/hash, plus the search vs
146
- * holdout split tag and either a `searchScore` or a `holdoutScore`.
147
- *
148
- * This is intentionally NOT a replacement for the rich `Run` /
149
- * `ProposeReviewReport` / `ScenarioResult` types already in the
150
- * package. Those are runtime structures with full provenance. A
151
- * `RunRecord` is the analysis-time projection — the JSON-friendly
152
- * row you'd put in a parquet file or paste into a notebook.
153
- *
154
- * Validate at the boundary:
155
- *
156
- * const rec = validateRunRecord(rawJson) // throws on missing
157
- * const ok = isRunRecord(rawJson) // boolean check
158
- * const rec = parseRunRecordSafe(rawJson) // { ok, value | error }
159
- *
160
- * The validator runs in pure TS — zod is intentionally NOT a
161
- * dependency. Round-trip tested in `tests/run-record.test.ts`.
162
- */
163
-
164
- /** Search/dev/holdout split tag. 'search' is the paper-grade alias for the
165
- * combined train+test pool that the optimizer is allowed to read. */
166
- type RunSplitTag = 'search' | 'dev' | 'holdout';
167
- interface RunTokenUsage {
168
- input: number;
169
- /** All generated tokens charged as output, including reasoning tokens. */
170
- output: number;
171
- /** Reasoning-token subset of `output`, when the provider reports it. */
172
- reasoning?: number;
173
- /** Prompt tokens served from a provider cache. */
174
- cached?: number;
175
- /** Prompt tokens written into a provider cache. */
176
- cacheWrite?: number;
177
- }
178
-
179
122
  /**
180
123
  * LLM client with graceful degrade.
181
124
  *
@@ -244,101 +187,43 @@ interface LlmCallResult {
244
187
  type LlmCallMetadata = Pick<LlmCallResult, 'usage' | 'costUsd' | 'model' | 'durationMs'>;
245
188
 
246
189
  /**
247
- * Analyst contract the missing orchestration layer over agent-eval's
248
- * existing analyzers (analyzeTraces, MultiLayerVerifier, RunCritic,
249
- * SemanticConceptJudge, JudgeFn, ...).
190
+ * Paper-grade RunRecord schema + runtime validator.
191
+ *
192
+ * Every run that participates in a promotion gate, paper table, or
193
+ * researcher loop SHOULD be recorded as a `RunRecord`. The mandatory
194
+ * fields are exactly those the paper "Two Loops, Three Roles" requires
195
+ * for reproducibility: who/what/when/cost/seed/hash, plus the search vs
196
+ * holdout split tag and either a `searchScore` or a `holdoutScore`.
197
+ *
198
+ * This is intentionally NOT a replacement for the rich `Run` /
199
+ * `ProposeReviewReport` / `ScenarioResult` types already in the
200
+ * package. Those are runtime structures with full provenance. A
201
+ * `RunRecord` is the analysis-time projection — the JSON-friendly
202
+ * row you'd put in a parquet file or paste into a notebook.
250
203
  *
251
- * Each existing primitive returns its own output shape. The Analyst
252
- * contract is the single envelope every primitive lifts into, so a
253
- * registry can run N analysts against a run and a single renderer can
254
- * compose findings without knowing which analyzer produced them.
204
+ * Validate at the boundary:
205
+ *
206
+ * const rec = validateRunRecord(rawJson) // throws on missing
207
+ * const ok = isRunRecord(rawJson) // boolean check
208
+ * const rec = parseRunRecordSafe(rawJson) // { ok, value | error }
255
209
  *
256
- * The contract is intentionally domain-agnostic: nothing here knows
257
- * about code, voice, RAG, or any particular agent stack. Analysts
258
- * declare what INPUT KIND they need (a trace store, an artifact dir,
259
- * a RunRecord, a JudgeInput, or `custom`), and the registry routes
260
- * the matching input from `AnalystRunInputs`.
210
+ * The validator runs in pure TS — zod is intentionally NOT a
211
+ * dependency. Round-trip tested in `tests/run-record.test.ts`.
261
212
  */
262
213
 
263
- interface EvidenceRef {
264
- /**
265
- * Where the evidence lives. `span` and `event` refer to OTLP trace
266
- * elements; `artifact` to a file inside the run's artifact tree;
267
- * `finding` to another AnalystFinding (cross-analyst chaining);
268
- * `metric` to a named scalar reading the renderer knows how to read.
269
- */
270
- kind: 'span' | 'event' | 'artifact' | 'finding' | 'metric';
271
- uri: string;
272
- excerpt?: string;
273
- }
274
-
275
- type PolicyEditSchemaVersion = 'policy-edit/v1';
276
- declare const POLICY_EDIT_AXES: readonly ["carrier", "representation", "budget", "sampling", "output_contract", "tool_contract", "routing", "memory", "agent_profile", "deployment_target"];
277
- type PolicyEditAxis = (typeof POLICY_EDIT_AXES)[number];
278
- declare const POLICY_EDIT_TARGET_SURFACES: readonly ["prompt", "tool-contract", "runtime-config", "memory", "agent-profile", "code", "deployment"];
279
- type PolicyEditTargetSurface = (typeof POLICY_EDIT_TARGET_SURFACES)[number];
280
- type PolicyEditRisk = 'low' | 'medium' | 'high' | 'unknown';
281
- type PolicyEditGainDirection = 'increase' | 'decrease';
282
- type PolicyEditGainUnit = 'absolute' | 'relative' | 'percent' | 'score';
283
- interface PolicyEditTarget {
284
- surface: PolicyEditTargetSurface;
285
- /** Stable path inside the target surface, for example `system-prompt:tools`
286
- * or `budget.maxTurns`. */
287
- path?: string;
288
- /** Optional canonical deployment identity. Store the existing cell, not a
289
- * local profile shape. */
290
- agentProfileCell?: AgentProfileCell;
291
- /** Human label when the path is not enough for a readable audit trail. */
292
- label?: string;
293
- }
294
- type PolicyEditChange = {
295
- kind: 'text';
296
- mode: 'append' | 'prepend' | 'replace';
297
- value: string;
298
- /** Required when `mode === 'replace'`; exact match only. */
299
- find?: string;
300
- } | {
301
- kind: 'json';
302
- mode: 'set' | 'merge' | 'remove';
303
- path: string;
304
- value?: AgentProfileJson;
305
- };
306
- interface PolicyEditExpectedGain {
307
- /** Metric this edit is expected to move, e.g. `holdout.composite`. */
308
- metric: string;
309
- direction: PolicyEditGainDirection;
310
- /** Positive magnitude in the metric's native units. */
311
- amount: number;
312
- unit?: PolicyEditGainUnit;
313
- rationale?: string;
314
- }
315
- interface PolicyEditSource {
316
- findingIds: string[];
317
- analystIds: string[];
318
- evidenceRefs: EvidenceRef[];
319
- /** Mirrors `AnalystFinding.derived_from_judge`; admission rejects it. */
320
- derivedFromJudge?: boolean;
321
- }
322
- interface PolicyEdit {
323
- schemaVersion: PolicyEditSchemaVersion;
324
- editId: string;
325
- axis: PolicyEditAxis;
326
- target: PolicyEditTarget;
327
- change: PolicyEditChange;
328
- claim: string;
329
- expectedGain: PolicyEditExpectedGain;
330
- confidence: number;
331
- risk: PolicyEditRisk;
332
- source: PolicyEditSource;
333
- rationale?: string;
334
- validationPlan?: string;
335
- metadata?: Record<string, unknown>;
336
- }
337
- declare const POLICY_EDIT_CANDIDATE_RECORD_SCHEMA: "tangle.policy-edit-candidate.v1";
338
- /** JSON-safe attribution carried with a measured candidate and its scores. */
339
- interface PolicyEditCandidateRecord {
340
- schema: typeof POLICY_EDIT_CANDIDATE_RECORD_SCHEMA;
341
- policyEdit: PolicyEdit;
214
+ /** Search/dev/holdout split tag. 'search' is the paper-grade alias for the
215
+ * combined train+test pool that the optimizer is allowed to read. */
216
+ type RunSplitTag = 'search' | 'dev' | 'holdout';
217
+ interface RunTokenUsage {
218
+ input: number;
219
+ /** All generated tokens charged as output, including reasoning tokens. */
220
+ output: number;
221
+ /** Reasoning-token subset of `output`, when the provider reports it. */
222
+ reasoning?: number;
223
+ /** Prompt tokens served from a provider cache. */
224
+ cached?: number;
225
+ /** Prompt tokens written into a provider cache. */
226
+ cacheWrite?: number;
342
227
  }
343
228
 
344
229
  /**
@@ -569,8 +454,6 @@ interface GenerationCandidate {
569
454
  * "because rationale Z" the audit requires to survive to the result.
570
455
  * Present when the proposer returned a `ProposedCandidate`. */
571
456
  rationale?: string;
572
- /** Exact structured cause threaded from the proposer, when available. */
573
- candidateRecord?: PolicyEditCandidateRecord;
574
457
  }
575
458
  interface CampaignAggregates {
576
459
  byJudge: Record<string, JudgeAggregate>;
@@ -16,23 +16,22 @@ import {
16
16
  routing_exports,
17
17
  runBenchmarkAdapter,
18
18
  summarizeBenchmarkCampaign
19
- } from "../chunk-JKDNAOF5.js";
20
- import "../chunk-A62YMFWA.js";
21
- import "../chunk-PMITBABE.js";
22
- import "../chunk-D5JZ7UDZ.js";
23
- import "../chunk-DT7OXY3C.js";
19
+ } from "../chunk-W4L6C2XT.js";
20
+ import "../chunk-NGUYT5CI.js";
21
+ import "../chunk-VMUENW6F.js";
22
+ import "../chunk-UCLVDLCH.js";
23
+ import "../chunk-WGXIEX7P.js";
24
24
  import "../chunk-ARU2PZFM.js";
25
- import "../chunk-EQUK3RFS.js";
25
+ import "../chunk-J5SQWP6Y.js";
26
26
  import "../chunk-PJQFMIOX.js";
27
- import "../chunk-GRCDRKII.js";
27
+ import "../chunk-WS3NZZQQ.js";
28
28
  import "../chunk-VI2UW6B6.js";
29
29
  import "../chunk-NUKSVU3W.js";
30
30
  import "../chunk-GGE4NNQT.js";
31
31
  import "../chunk-IR3KBHOY.js";
32
32
  import "../chunk-PC4UYEBM.js";
33
- import "../chunk-LOW3U7JZ.js";
33
+ import "../chunk-IILEIWGW.js";
34
34
  import "../chunk-MA6HLL3S.js";
35
- import "../chunk-GC4ATIKK.js";
36
35
  import "../chunk-VSMTAMNK.js";
37
36
  import "../chunk-ONWEPEDO.js";
38
37
  import "../chunk-K4DBDHLK.js";