@tangle-network/agent-eval 0.20.12 → 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/CHANGELOG.md +177 -0
- package/README.md +43 -1
- package/dist/{chunk-KWUAAIHR.js → chunk-4W4NCYM2.js} +182 -1
- package/dist/chunk-4W4NCYM2.js.map +1 -0
- package/dist/{chunk-PKCVBYTQ.js → chunk-5IIQKMD5.js} +38 -2
- package/dist/chunk-5IIQKMD5.js.map +1 -0
- package/dist/{chunk-HNJLMAJ2.js → chunk-6KQG5HAH.js} +2 -2
- package/dist/chunk-6M774GY6.js +53 -0
- package/dist/chunk-6M774GY6.js.map +1 -0
- package/dist/{chunk-MCMV7DUL.js → chunk-ARZ6BEV6.js} +2 -2
- package/dist/chunk-IOXMGMHQ.js +1226 -0
- package/dist/chunk-IOXMGMHQ.js.map +1 -0
- package/dist/{chunk-75MCTH7P.js → chunk-KAO3Q65R.js} +198 -3
- package/dist/chunk-KAO3Q65R.js.map +1 -0
- package/dist/chunk-QUKKGHTZ.js +121 -0
- package/dist/chunk-QUKKGHTZ.js.map +1 -0
- package/dist/chunk-SQQLHODJ.js +163 -0
- package/dist/chunk-SQQLHODJ.js.map +1 -0
- package/dist/{chunk-IKFVX537.js → chunk-UAND2LOT.js} +232 -211
- package/dist/chunk-UAND2LOT.js.map +1 -0
- package/dist/{chunk-HKYRWNHV.js → chunk-USHQBPMH.js} +283 -7
- package/dist/chunk-USHQBPMH.js.map +1 -0
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/{control-C8NKbF3w.d.ts → control-cxwMOAsy.d.ts} +3 -2
- package/dist/control.d.ts +4 -3
- package/dist/control.js +2 -2
- package/dist/emitter-B2XqDKFU.d.ts +121 -0
- package/dist/{feedback-trajectory-BGQ_ANCN.d.ts → feedback-trajectory-CB0A32o3.d.ts} +2 -1
- package/dist/index.d.ts +16 -302
- package/dist/index.js +70 -62
- package/dist/index.js.map +1 -1
- package/dist/integrity-K2oVlF57.d.ts +210 -0
- package/dist/openapi.json +1 -1
- package/dist/optimization-UVDNKaO6.d.ts +574 -0
- package/dist/optimization.d.ts +7 -144
- package/dist/optimization.js +9 -2
- package/dist/reporting-B82RSv9C.d.ts +593 -0
- package/dist/reporting.d.ts +5 -426
- package/dist/reporting.js +17 -6
- package/dist/{emitter-BYO2nSDA.d.ts → store-u47QaJ9G.d.ts} +1 -91
- package/dist/{multi-shot-optimization-Bvtz294B.d.ts → summary-report-D4p7RlDu.d.ts} +381 -1
- package/dist/traces.d.ts +179 -3
- package/dist/traces.js +35 -4
- package/dist/wire/index.js +3 -2
- package/docs/research-report-methodology.md +170 -0
- package/docs/wire-protocol.md +1 -1
- package/package.json +11 -13
- package/dist/chunk-75MCTH7P.js.map +0 -1
- package/dist/chunk-HKYRWNHV.js.map +0 -1
- package/dist/chunk-IKFVX537.js.map +0 -1
- package/dist/chunk-KWUAAIHR.js.map +0 -1
- package/dist/chunk-ODFINDLQ.js +0 -413
- package/dist/chunk-ODFINDLQ.js.map +0 -1
- package/dist/chunk-PKCVBYTQ.js.map +0 -1
- /package/dist/{chunk-HNJLMAJ2.js.map → chunk-6KQG5HAH.js.map} +0 -0
- /package/dist/{chunk-MCMV7DUL.js.map → chunk-ARZ6BEV6.js.map} +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { T as TraceStore } from './store-u47QaJ9G.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* RawProviderSink — first-class persistence for the actual HTTP-level
|
|
5
|
+
* request/response bodies of every LLM provider call.
|
|
6
|
+
*
|
|
7
|
+
* Why this is a separate sink from the structured `LlmSpan`:
|
|
8
|
+
*
|
|
9
|
+
* - `LlmSpan` records the *intent* — model name, messages, output text,
|
|
10
|
+
* usage. It's what dashboards read; it's NOT enough for forensics.
|
|
11
|
+
* - When a downstream consumer reports "the verifier used the wrong route"
|
|
12
|
+
* or "tokens look right but reasoning was missing," the only way to
|
|
13
|
+
* answer is the raw HTTP body. Span fields can lie (a proxy can echo
|
|
14
|
+
* a different `model` value than what actually answered); the raw
|
|
15
|
+
* response is ground truth.
|
|
16
|
+
*
|
|
17
|
+
* Default behaviour: opt-in. Pass `rawSink` to `LlmClientOptions` (or the
|
|
18
|
+
* matrix runner / BuilderSession sets it up automatically) and every
|
|
19
|
+
* request, response, and error is recorded — including retries, with the
|
|
20
|
+
* attempt index attached so a flaky call's full event chain is recoverable.
|
|
21
|
+
*
|
|
22
|
+
* Redaction is enforced at sink time. The default redactor strips
|
|
23
|
+
* `Authorization`, `X-Api-Key`, `X-Auth-Token`, `Cookie` headers and any
|
|
24
|
+
* payload field whose key matches `apiKey | api_key | bearer | password |
|
|
25
|
+
* secret | token` (case-insensitive). Override via the sink constructor or
|
|
26
|
+
* the per-call `redactor`. The `redactedFields` array on the persisted
|
|
27
|
+
* event lets a reviewer see what was stripped without exposing the values.
|
|
28
|
+
*/
|
|
29
|
+
type RawProviderDirection = 'request' | 'response' | 'error';
|
|
30
|
+
interface RawProviderEvent {
|
|
31
|
+
/** Stable id. Generated by the sink if omitted. */
|
|
32
|
+
eventId: string;
|
|
33
|
+
/** Trace context populated by `LlmClient` when the call is wrapped in a span. */
|
|
34
|
+
runId?: string;
|
|
35
|
+
spanId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Logical provider name. Free-form so callers can use whatever id matches
|
|
38
|
+
* their topology (`'openai'`, `'anthropic'`, `'tangle-router'`, …). When
|
|
39
|
+
* omitted, derived from `baseUrl` in `LlmClientOptions`.
|
|
40
|
+
*/
|
|
41
|
+
provider: string;
|
|
42
|
+
model: string;
|
|
43
|
+
/** Endpoint path, e.g. `'/v1/chat/completions'`. */
|
|
44
|
+
endpoint: string;
|
|
45
|
+
/** Base URL used for the call (already-normalised — no trailing slash). */
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
/** 0-indexed retry attempt. The first attempt is 0; a retried call gets 1, 2, … */
|
|
48
|
+
attemptIndex: number;
|
|
49
|
+
direction: RawProviderDirection;
|
|
50
|
+
/** Unix ms. */
|
|
51
|
+
timestamp: number;
|
|
52
|
+
/** Wall-clock duration of the call leg. Set on `response` and `error` events; null on `request`. */
|
|
53
|
+
durationMs?: number;
|
|
54
|
+
statusCode?: number;
|
|
55
|
+
requestHeaders?: Record<string, string>;
|
|
56
|
+
requestBody?: unknown;
|
|
57
|
+
responseHeaders?: Record<string, string>;
|
|
58
|
+
responseBody?: unknown;
|
|
59
|
+
/** Set on `direction: 'error'` events. */
|
|
60
|
+
errorMessage?: string;
|
|
61
|
+
/** Field paths the redactor stripped from this event ('header:Authorization', 'body.apiKey', …). */
|
|
62
|
+
redactedFields: string[];
|
|
63
|
+
}
|
|
64
|
+
interface RawProviderSinkFilter {
|
|
65
|
+
runId?: string;
|
|
66
|
+
spanId?: string;
|
|
67
|
+
direction?: RawProviderDirection;
|
|
68
|
+
attemptIndex?: number;
|
|
69
|
+
}
|
|
70
|
+
interface RawProviderSink {
|
|
71
|
+
record(event: RawProviderEvent): Promise<void>;
|
|
72
|
+
/** Optional listing — implementations that durably persist (file, db) should support this. */
|
|
73
|
+
list?(filter?: RawProviderSinkFilter): Promise<RawProviderEvent[]>;
|
|
74
|
+
/** Optional teardown for backed implementations. */
|
|
75
|
+
close?(): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
type ProviderRedactor = (event: RawProviderEvent) => RawProviderEvent;
|
|
78
|
+
/**
|
|
79
|
+
* Default redactor — strips well-known auth headers and any body field whose
|
|
80
|
+
* key matches the credential pattern. Records every redacted path on
|
|
81
|
+
* `event.redactedFields` so a downstream reviewer can see what was removed.
|
|
82
|
+
*/
|
|
83
|
+
declare function defaultProviderRedactor(event: RawProviderEvent): RawProviderEvent;
|
|
84
|
+
interface InMemoryRawProviderSinkOptions {
|
|
85
|
+
redactor?: ProviderRedactor;
|
|
86
|
+
}
|
|
87
|
+
declare class InMemoryRawProviderSink implements RawProviderSink {
|
|
88
|
+
private events;
|
|
89
|
+
private redactor;
|
|
90
|
+
constructor(opts?: InMemoryRawProviderSinkOptions);
|
|
91
|
+
record(event: RawProviderEvent): Promise<void>;
|
|
92
|
+
list(filter?: RawProviderSinkFilter): Promise<RawProviderEvent[]>;
|
|
93
|
+
size(): number;
|
|
94
|
+
}
|
|
95
|
+
declare class NoopRawProviderSink implements RawProviderSink {
|
|
96
|
+
record(): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns an empty array. Implemented so `assertRunCaptured` does not
|
|
99
|
+
* trip the `no_raw_sink` issue when a caller explicitly opts out of
|
|
100
|
+
* capture by passing this sink — opt-out is a deliberate choice, not a
|
|
101
|
+
* misconfiguration.
|
|
102
|
+
*/
|
|
103
|
+
list(): Promise<RawProviderEvent[]>;
|
|
104
|
+
}
|
|
105
|
+
interface FileSystemRawProviderSinkOptions {
|
|
106
|
+
/** Directory the NDJSON file is written into. Created if missing. */
|
|
107
|
+
dir: string;
|
|
108
|
+
/** File name; default `'raw-provider-events.ndjson'`. */
|
|
109
|
+
fileName?: string;
|
|
110
|
+
/** Bytes after which the writer rolls over to a new file (default 32 MiB). */
|
|
111
|
+
rollAtBytes?: number;
|
|
112
|
+
redactor?: ProviderRedactor;
|
|
113
|
+
}
|
|
114
|
+
declare class FileSystemRawProviderSink implements RawProviderSink {
|
|
115
|
+
private dir;
|
|
116
|
+
private fileName;
|
|
117
|
+
private rollAtBytes;
|
|
118
|
+
private redactor;
|
|
119
|
+
private bytesWritten;
|
|
120
|
+
private rollIndex;
|
|
121
|
+
private initPromise;
|
|
122
|
+
constructor(opts: FileSystemRawProviderSinkOptions);
|
|
123
|
+
private ensureInit;
|
|
124
|
+
private currentPath;
|
|
125
|
+
record(event: RawProviderEvent): Promise<void>;
|
|
126
|
+
list(filter?: RawProviderSinkFilter): Promise<RawProviderEvent[]>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Best-effort provider id from a base URL. Falls back to the URL host when
|
|
130
|
+
* none of the well-known patterns match.
|
|
131
|
+
*/
|
|
132
|
+
declare function providerFromBaseUrl(baseUrl: string): string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Run-completion integrity check — at end of run, verify the expected event
|
|
136
|
+
* types were actually captured. The point is the launch-review failure mode:
|
|
137
|
+
* a run *appears* successful but the raw provider events were never written,
|
|
138
|
+
* so a downstream reviewer can't reconstruct what happened.
|
|
139
|
+
*
|
|
140
|
+
* Pattern:
|
|
141
|
+
*
|
|
142
|
+
* const report = await assertRunCaptured(store, runId, {
|
|
143
|
+
* llmSpansMin: 1,
|
|
144
|
+
* judgeSpansMin: 1,
|
|
145
|
+
* rawSink: providerSink, // must have ≥ 1 event for this run
|
|
146
|
+
* requireRawCoverageOfLlmSpans: true, // every llm span has matching raw events
|
|
147
|
+
* })
|
|
148
|
+
* if (!report.ok) throwIfRunIncomplete(report) // or mark run failed and continue
|
|
149
|
+
*
|
|
150
|
+
* The function is read-only on the store and returns a structured report;
|
|
151
|
+
* the caller chooses the failure mode (throw, mark run failed, log warning).
|
|
152
|
+
* `throwIfRunIncomplete` is the convenient strict mode.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
interface RunIntegrityExpectations {
|
|
156
|
+
/** Minimum LLM span count. Default 0 (no requirement). */
|
|
157
|
+
llmSpansMin?: number;
|
|
158
|
+
/** Minimum judge span count. Default 0. */
|
|
159
|
+
judgeSpansMin?: number;
|
|
160
|
+
/** Minimum tool span count. Default 0. */
|
|
161
|
+
toolSpansMin?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Raw provider sink to consult for capture verification. When present,
|
|
164
|
+
* the check requires at least one raw event for the run.
|
|
165
|
+
*/
|
|
166
|
+
rawSink?: RawProviderSink;
|
|
167
|
+
/** Minimum raw provider event count. Default 0; ignored when `rawSink` absent. */
|
|
168
|
+
rawProviderEventsMin?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Every LLM span must have at least one matching raw `request` event
|
|
171
|
+
* (matched by spanId). Catches the common bug where the structured span
|
|
172
|
+
* was emitted but the raw HTTP capture was wired to a different sink.
|
|
173
|
+
*/
|
|
174
|
+
requireRawCoverageOfLlmSpans?: boolean;
|
|
175
|
+
/** Run outcome must be set (not null/undefined). Default false. */
|
|
176
|
+
requireOutcome?: boolean;
|
|
177
|
+
}
|
|
178
|
+
type RunIntegrityIssueCode = 'no_run' | 'missing_llm_spans' | 'missing_judge_spans' | 'missing_tool_spans' | 'missing_raw_events' | 'no_raw_sink' | 'orphan_llm_span' | 'missing_outcome';
|
|
179
|
+
interface RunIntegrityIssue {
|
|
180
|
+
code: RunIntegrityIssueCode;
|
|
181
|
+
message: string;
|
|
182
|
+
detail?: Record<string, unknown>;
|
|
183
|
+
}
|
|
184
|
+
interface RunIntegrityReport {
|
|
185
|
+
ok: boolean;
|
|
186
|
+
runId: string;
|
|
187
|
+
llmSpanCount: number;
|
|
188
|
+
judgeSpanCount: number;
|
|
189
|
+
toolSpanCount: number;
|
|
190
|
+
rawProviderEventCount: number;
|
|
191
|
+
/**
|
|
192
|
+
* Coverage of LLM spans by raw provider events keyed on spanId.
|
|
193
|
+
* `total` is the number of LLM spans; `covered` is the count with at
|
|
194
|
+
* least one matching `request` raw event.
|
|
195
|
+
*/
|
|
196
|
+
rawSpanCoverage: {
|
|
197
|
+
covered: number;
|
|
198
|
+
total: number;
|
|
199
|
+
};
|
|
200
|
+
issues: RunIntegrityIssue[];
|
|
201
|
+
}
|
|
202
|
+
declare class RunIntegrityError extends Error {
|
|
203
|
+
readonly report: RunIntegrityReport;
|
|
204
|
+
constructor(report: RunIntegrityReport);
|
|
205
|
+
}
|
|
206
|
+
declare function assertRunCaptured(store: TraceStore, runId: string, expectations?: RunIntegrityExpectations): Promise<RunIntegrityReport>;
|
|
207
|
+
/** Strict mode: throws `RunIntegrityError` when the report isn't ok. */
|
|
208
|
+
declare function throwIfRunIncomplete(report: RunIntegrityReport): void;
|
|
209
|
+
|
|
210
|
+
export { FileSystemRawProviderSink as F, InMemoryRawProviderSink as I, NoopRawProviderSink as N, type ProviderRedactor as P, type RawProviderDirection as R, type FileSystemRawProviderSinkOptions as a, type InMemoryRawProviderSinkOptions as b, type RawProviderEvent as c, type RawProviderSink as d, type RawProviderSinkFilter as e, RunIntegrityError as f, type RunIntegrityExpectations as g, type RunIntegrityIssue as h, type RunIntegrityIssueCode as i, type RunIntegrityReport as j, assertRunCaptured as k, defaultProviderRedactor as l, providerFromBaseUrl as p, throwIfRunIncomplete as t };
|
package/dist/openapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.1.0",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "@tangle-network/agent-eval — wire protocol",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.22.0",
|
|
6
6
|
"description": "HTTP and stdio RPC interface to agent-eval. The TypeScript runtime is the source of truth; this spec is the contract that cross-language clients (Python, Rust, Go) generate from.\n\nWire-protocol version: 1.0.0. Bumps on breaking changes to request/response schemas.",
|
|
7
7
|
"contact": {
|
|
8
8
|
"name": "Tangle Network",
|