evalution 1.0.8 → 2.0.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/LICENSING.md +26 -44
- package/README.md +11 -11
- package/dist/{check-CR4fU1S5.d.ts → check-BKU5_IhU.d.ts} +18 -868
- package/dist/checks/index.d.ts +2 -1
- package/dist/cli/index.js +809 -372
- package/dist/client/assets/{DatasetView-BqSWI_pm.js → DatasetView-DZ2uLHKV.js} +12 -10
- package/dist/client/assets/{EvalRunView-CR6ZksSu.js → EvalRunView-T610dLVw.js} +1 -1
- package/dist/client/assets/{EvalView-JPEM5IY8.js → EvalView-Cae68vPB.js} +1 -1
- package/dist/client/assets/{data-grid-overlay-editor-B_nPhXKR.js → data-grid-overlay-editor-PtH7A6E4.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-dPpneB8R.js → highlighted-body-KPVGNVTW-CPtwvSJb.js} +1 -1
- package/dist/client/assets/{index-CwjMcK6S.js → index-BFH07Ynk.js} +147 -147
- package/dist/client/assets/index-KCv8AeiY.css +32 -0
- package/dist/client/assets/{number-overlay-editor-CRWFlaQs.js → number-overlay-editor-BbQhagHP.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/cost-fetching-trace-sink-Dz8gniQ6.js +262 -0
- package/dist/{dataset-types-Dqi5vVg-.d.ts → dataset-types-D-Fsbg8B.d.ts} +7 -247
- package/dist/index.d.ts +844 -1426
- package/dist/index.js +151 -480
- package/dist/ingest.d.ts +119 -0
- package/dist/ingest.js +3 -0
- package/dist/{trace-event-ingestor-BghQcCHe.js → local-database-trace-provider-87-WGqfS.js} +1976 -7362
- package/dist/{trace-DGj5oW7z.d.ts → trace-BLjFYF9G.d.ts} +2 -1
- package/dist/trace-event-ingestor-B1DYEg2H.js +798 -0
- package/dist/trace-event-ingestor-JNpe-OrX.d.ts +109 -0
- package/dist/views/datasets/index.d.ts +1 -1
- package/dist/views/index.d.ts +3 -2
- package/dist/views/index.js +0 -4
- package/dist/views/react/index.d.ts +1 -1
- package/package.json +32 -30
- package/dist/client/assets/index-BGcZZetP.css +0 -32
package/dist/ingest.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { a as NormalizedOtlpEvent, i as decodeOtlpProtobuf, n as mergeSpans, o as NormalizedOtlpSpan, r as OtlpTraceIngestor, s as normalizeOtlpRequest, t as TraceEventIngestor } from "./trace-event-ingestor-JNpe-OrX.js";
|
|
2
|
+
import { Span, TraceSink } from "@evalution/sdk";
|
|
3
|
+
|
|
4
|
+
//#region src/server/handlers/otlp-ingest.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Placeholder for cloud auth context. OSS has none; a cloud host's
|
|
7
|
+
* `resolveIngestor` narrows this to whatever it derives from the request's
|
|
8
|
+
* API key (project + environment). Kept as an extension point so
|
|
9
|
+
* {@link OtlpIngestDeps} doesn't need to change shape when cloud adds it.
|
|
10
|
+
*/
|
|
11
|
+
type AuthCtx = Record<string, unknown>;
|
|
12
|
+
/** What {@link handleOtlpTraces} needs from its host. */
|
|
13
|
+
interface OtlpIngestDeps {
|
|
14
|
+
/**
|
|
15
|
+
* Picks which {@link OtlpTraceIngestor} a batch should be recorded through.
|
|
16
|
+
* OSS resolves this to "the process's single ingestor" (optionally keying
|
|
17
|
+
* off an `x-evalution-provider` header when more than one trace provider is
|
|
18
|
+
* configured); a cloud host keys off `ctx.auth` instead. Returns `undefined`
|
|
19
|
+
* when nothing matches, in which case the request is rejected — this
|
|
20
|
+
* handler never guesses a target.
|
|
21
|
+
*/
|
|
22
|
+
resolveIngestor(ctx: {
|
|
23
|
+
headers: Record<string, string>;
|
|
24
|
+
auth?: AuthCtx;
|
|
25
|
+
}): OtlpTraceIngestor | undefined;
|
|
26
|
+
}
|
|
27
|
+
/** One OTLP export request, as {@link handleOtlpTraces} takes it. */
|
|
28
|
+
interface OtlpIngestRequest {
|
|
29
|
+
/** The request's `content-type` header, e.g. `application/x-protobuf`. */
|
|
30
|
+
contentType: string;
|
|
31
|
+
/** The request body, decompressed. */
|
|
32
|
+
body: ArrayBuffer;
|
|
33
|
+
/** The request's headers, with lowercase names. */
|
|
34
|
+
headers: Record<string, string>;
|
|
35
|
+
/** What the host authenticated the request as, if it did. */
|
|
36
|
+
auth?: AuthCtx;
|
|
37
|
+
}
|
|
38
|
+
/** What {@link handleOtlpTraces} answers: an HTTP status and a JSON body. */
|
|
39
|
+
interface OtlpIngestResult {
|
|
40
|
+
status: number;
|
|
41
|
+
body: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Host-neutral handler for an OTLP trace export request (`POST /v1/traces`).
|
|
45
|
+
* Decodes protobuf or JSON, normalizes to `NormalizedOtlpSpan[]`, and hands
|
|
46
|
+
* the batch to whichever {@link OtlpTraceIngestor} {@link OtlpIngestDeps.resolveIngestor}
|
|
47
|
+
* picks. Takes and returns plain data (`ArrayBuffer` + headers, `{status,
|
|
48
|
+
* body}`) rather than a framework `Request`/`Response` so it stays usable
|
|
49
|
+
* from Hono, a Worker, or a test — no `Buffer`, no `fs`, no `process`.
|
|
50
|
+
*/
|
|
51
|
+
declare function handleOtlpTraces(req: OtlpIngestRequest, deps: OtlpIngestDeps): Promise<OtlpIngestResult>;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/server/handlers/trace-events-ingest.d.ts
|
|
54
|
+
/** What {@link handleTraceEvents} answers: an HTTP status and a JSON body. */
|
|
55
|
+
interface TraceEventsIngestResult {
|
|
56
|
+
status: number;
|
|
57
|
+
body: unknown;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Host-neutral handler for a batch of trace events an app's `HttpTraceSink`
|
|
61
|
+
* sends (`POST /api/traces`). Takes the request body as text and
|
|
62
|
+
* returns plain `{status, body}`, like `handleOtlpTraces`, so it stays usable
|
|
63
|
+
* from Hono, a Worker, or a test.
|
|
64
|
+
*/
|
|
65
|
+
declare function handleTraceEvents(body: string, ingestor: TraceEventIngestor | undefined): Promise<TraceEventsIngestResult>;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/trace/cost-fetching-trace-sink.d.ts
|
|
68
|
+
/** Options for {@link CostFetchingTraceSink}. */
|
|
69
|
+
interface CostFetchingTraceSinkOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Override for the global `fetch`, so tests can inject a mock instead of
|
|
72
|
+
* hitting the network. Defaults to the global `fetch`.
|
|
73
|
+
*/
|
|
74
|
+
fetch?: typeof fetch;
|
|
75
|
+
/**
|
|
76
|
+
* Whether to fetch pricing (and so stamp costs) at all. When `false`, spans
|
|
77
|
+
* pass through untouched and no request is ever made. Defaults to `true`
|
|
78
|
+
* unless the `EVALUTION_NO_COST_ESTIMATES` environment variable is set.
|
|
79
|
+
*/
|
|
80
|
+
fetchPricing?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A {@link TraceSink} that stamps `llm.cost` onto LLM spans with known token
|
|
84
|
+
* usage, then fans the span out to its own registered downstream sinks.
|
|
85
|
+
*
|
|
86
|
+
* Pricing is fetched once, lazily on the first relevant span, from Vercel AI
|
|
87
|
+
* Gateway's public model catalog — or, if that request fails, from
|
|
88
|
+
* OpenRouter's — and cached in memory for the life of the instance. Cache
|
|
89
|
+
* reads and writes are billed at the catalog's cache prices where it lists
|
|
90
|
+
* them. A fetch failure (or an offline environment) is logged to the console
|
|
91
|
+
* but never thrown at the caller; costs just don't get stamped.
|
|
92
|
+
*/
|
|
93
|
+
declare class CostFetchingTraceSink implements TraceSink {
|
|
94
|
+
private readonly fetchImpl;
|
|
95
|
+
private readonly fetchPricing;
|
|
96
|
+
private readonly sinks;
|
|
97
|
+
private prices;
|
|
98
|
+
constructor(options?: CostFetchingTraceSinkOptions);
|
|
99
|
+
/** Add a downstream sink. May be called multiple times. */
|
|
100
|
+
addSink(sink: TraceSink): void;
|
|
101
|
+
/**
|
|
102
|
+
* Remove a previously-added sink. Returns `true` if the given sink was
|
|
103
|
+
* found and removed, otherwise `false`.
|
|
104
|
+
*/
|
|
105
|
+
removeSink(sink: TraceSink): boolean;
|
|
106
|
+
recordSpanStart(span: Span): Promise<Span>;
|
|
107
|
+
recordSpanEnd(span: Span): Promise<Span>;
|
|
108
|
+
failTrace(traceId: string, errorMessage: string): Promise<void>;
|
|
109
|
+
private withCost;
|
|
110
|
+
private fetchPrices;
|
|
111
|
+
/**
|
|
112
|
+
* Fetches and parses one model catalog. Returns `undefined` if the request
|
|
113
|
+
* fails, so the caller can fall back to another — never throws for the
|
|
114
|
+
* caller over this.
|
|
115
|
+
*/
|
|
116
|
+
private fetchCatalog;
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { type AuthCtx, CostFetchingTraceSink, type CostFetchingTraceSinkOptions, type NormalizedOtlpEvent, type NormalizedOtlpSpan, type OtlpIngestDeps, type OtlpIngestRequest, type OtlpIngestResult, OtlpTraceIngestor, TraceEventIngestor, type TraceEventsIngestResult, decodeOtlpProtobuf, handleOtlpTraces, handleTraceEvents, mergeSpans, normalizeOtlpRequest };
|
package/dist/ingest.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { c as normalizeOtlpRequest, n as OtlpTraceIngestor, o as mergeSpans, s as decodeOtlpProtobuf, t as TraceEventIngestor } from "./trace-event-ingestor-B1DYEg2H.js";
|
|
2
|
+
import { n as handleTraceEvents, r as handleOtlpTraces, t as CostFetchingTraceSink } from "./cost-fetching-trace-sink-Dz8gniQ6.js";
|
|
3
|
+
export { CostFetchingTraceSink, OtlpTraceIngestor, TraceEventIngestor, decodeOtlpProtobuf, handleOtlpTraces, handleTraceEvents, mergeSpans, normalizeOtlpRequest };
|