evalution 1.0.6 → 1.0.7
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 +1 -0
- package/dist/cli/index.js +68 -50
- package/dist/client/assets/DatasetView-CWw3B_XI.js +15 -0
- package/dist/client/assets/{EvalRunView-5IZp_6Ob.js → EvalRunView-DJNSAydj.js} +1 -1
- package/dist/client/assets/EvalView-R0Nkikzs.js +1 -0
- package/dist/client/assets/{data-grid-overlay-editor-CBtkQufd.js → data-grid-overlay-editor-CBVV2omk.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-DyudWmoO.js → highlighted-body-KPVGNVTW-BqsjUFPI.js} +1 -1
- package/dist/client/assets/{index-aypgoZcG.js → index-DOmAST6D.js} +145 -145
- package/dist/client/assets/{number-overlay-editor-CXHiTLsp.js → number-overlay-editor-DhCVhD05.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/index.d.ts +162 -3
- package/dist/index.js +3 -3
- package/dist/{otlp-trace-ingestor-V8_bbpUG.js → trace-event-ingestor-DI-HkA4Q.js} +443 -60
- package/package.json +1 -1
- package/dist/client/assets/DatasetView-CyX0mCj8.js +0 -15
- package/dist/client/assets/EvalView-DBTK6rCe.js +0 -1
package/LICENSING.md
CHANGED
|
@@ -58,6 +58,7 @@ permissively licensed code:
|
|
|
58
58
|
[`src/trace/trace-types.ts`](./src/trace/trace-types.ts),
|
|
59
59
|
[`src/trace/trace-sink.ts`](./src/trace/trace-sink.ts),
|
|
60
60
|
[`src/trace/trace-ingestor.ts`](./src/trace/trace-ingestor.ts),
|
|
61
|
+
[`src/trace/http-trace-sink.ts`](./src/trace/http-trace-sink.ts),
|
|
61
62
|
[`src/trace/evaluation-answers.ts`](./src/trace/evaluation-answers.ts), and
|
|
62
63
|
[`src/sdk/vercel-ai-sdk/telemetry.ts`](./src/sdk/vercel-ai-sdk/telemetry.ts).
|
|
63
64
|
Each is **dual-licensed `MIT OR AGPL-3.0-only`** (see its SPDX header),
|
package/dist/cli/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as fieldsForPrompt, A as DEFAULT_QUERY_TIMEOUT_MS, C as VariationConflictError, D as normalizeOtlpRequest, E as decodeOtlpProtobuf, F as parseColumnSpecs, Ft as PLAYGROUND_RESOURCE, G as evalProblems, H as EvalRunner, I as pathField, J as parseBinding, K as InvalidCellError, L as pathInstance, M as InvalidColumnPathError, N as isPathColumn, O as EvalNotFoundError, Ot as isNonEmptyStringArray, P as parseColumnPath, Q as PRIMITIVE_FIELD_TYPES, R as DatasetNotFoundError, S as datasetQueryColumns, U as emptyCounts, V as EvalRunRefusedError, W as CheckScopeTraceSink, X as parseResources, Y as parseCell, Z as primitiveBase, b as mkdirSelfIgnoring, cn as registerFreshImportHook, dt as instanceNames, et as isPrimitiveFieldType, in as LocalFileProvider, j as SqlQueryError, jt as TypeSafeSDK, kt as isPromptStyle, l as LocalEvalProvider, ln as registerBundlerResolutionFallback, n as OtlpTraceIngestor, nn as CONFIG_FILE_RELATIVE_PATH, nt as InputResolutionError, on as registerVariationLoaderHook, p as LocalDirectoryDatasetProvider, q as fitsPrimitiveBase, r as LocalDatabaseTraceProvider, rn as setupStepCommand, rt as runPrompt, s as isTraceSink, t as TraceEventIngestor, tt as portableDef, vt as VercelAISDK, wt as TRACE_EVENTS_PATH, x as rollupSpans, z as DatasetValidationError } from "../trace-event-ingestor-DI-HkA4Q.js";
|
|
2
2
|
import { r as builtinCheckInfos } from "../checks-Cq97JU-h.js";
|
|
3
3
|
import module, { builtinModules } from "node:module";
|
|
4
4
|
import path, { join, resolve } from "node:path";
|
|
@@ -10,8 +10,8 @@ import { Hono } from "hono";
|
|
|
10
10
|
import { WebSocketServer } from "ws";
|
|
11
11
|
import fs, { link, readFile, rename, stat, unlink, writeFile } from "node:fs/promises";
|
|
12
12
|
import chokidar from "chokidar";
|
|
13
|
-
import { createHash } from "node:crypto";
|
|
14
13
|
import fs$1, { readFileSync, unlinkSync } from "node:fs";
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
15
|
import { trace } from "@opentelemetry/api";
|
|
16
16
|
import { valueToSourceText } from "ts-proppy";
|
|
17
17
|
import ts from "typescript";
|
|
@@ -23,7 +23,7 @@ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
|
23
23
|
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
24
24
|
import { spawn } from "node:child_process";
|
|
25
25
|
//#region package.json
|
|
26
|
-
var version = "1.0.
|
|
26
|
+
var version = "1.0.7";
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/agent/command-builder.ts
|
|
29
29
|
/** Characters an argument may consist of to be left unquoted. */
|
|
@@ -1860,6 +1860,59 @@ function summarizePrompt(provider, prompt) {
|
|
|
1860
1860
|
};
|
|
1861
1861
|
}
|
|
1862
1862
|
//#endregion
|
|
1863
|
+
//#region src/server/handlers/trace-events-ingest.ts
|
|
1864
|
+
function isObject(value) {
|
|
1865
|
+
return typeof value === "object" && value !== null;
|
|
1866
|
+
}
|
|
1867
|
+
function isSpanLike(value) {
|
|
1868
|
+
return isObject(value) && typeof value.id === "string" && typeof value.traceId === "string" && typeof value.startTime === "number";
|
|
1869
|
+
}
|
|
1870
|
+
/** Whether `value` is a {@link TraceSinkEvent} the ingestor can replay. */
|
|
1871
|
+
function isTraceSinkEvent(value) {
|
|
1872
|
+
if (!isObject(value)) return false;
|
|
1873
|
+
switch (value.type) {
|
|
1874
|
+
case "span-start":
|
|
1875
|
+
case "span-end": return isSpanLike(value.span);
|
|
1876
|
+
case "trace-fail": return typeof value.traceId === "string" && typeof value.errorMessage === "string";
|
|
1877
|
+
default: return false;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Host-neutral handler for a batch of trace events an app's `HttpTraceSink`
|
|
1882
|
+
* sends (`POST /api/traces`). Takes the request body as text and
|
|
1883
|
+
* returns plain `{status, body}`, like `handleOtlpTraces`, so it stays usable
|
|
1884
|
+
* from Hono, a Worker, or a test.
|
|
1885
|
+
*/
|
|
1886
|
+
async function handleTraceEvents(body, ingestor) {
|
|
1887
|
+
let events;
|
|
1888
|
+
try {
|
|
1889
|
+
events = JSON.parse(body)?.events;
|
|
1890
|
+
} catch (err) {
|
|
1891
|
+
return {
|
|
1892
|
+
status: 400,
|
|
1893
|
+
body: { error: `Malformed JSON: ${err?.message ?? err}` }
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
if (!Array.isArray(events)) return {
|
|
1897
|
+
status: 400,
|
|
1898
|
+
body: { error: "Expected an `events` array" }
|
|
1899
|
+
};
|
|
1900
|
+
const invalid = events.findIndex((e) => !isTraceSinkEvent(e));
|
|
1901
|
+
if (invalid >= 0) return {
|
|
1902
|
+
status: 400,
|
|
1903
|
+
body: { error: `Malformed event at ${invalid}` }
|
|
1904
|
+
};
|
|
1905
|
+
if (!ingestor) return {
|
|
1906
|
+
status: 404,
|
|
1907
|
+
body: { error: "No trace ingestor available for this request" }
|
|
1908
|
+
};
|
|
1909
|
+
await ingestor.ingest(events);
|
|
1910
|
+
return {
|
|
1911
|
+
status: 200,
|
|
1912
|
+
body: {}
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
//#endregion
|
|
1863
1916
|
//#region src/server/handlers/trace-stream.ts
|
|
1864
1917
|
/**
|
|
1865
1918
|
* Streams live updates for one trace over SSE: replays its current state
|
|
@@ -2118,7 +2171,7 @@ function errorResponse(c, error, status) {
|
|
|
2118
2171
|
* Registers every REST route on `app`, answering through the neutral handlers
|
|
2119
2172
|
* in `./handlers/` from `context` — which a host can serve over MCP too.
|
|
2120
2173
|
*/
|
|
2121
|
-
function setupRoutes({ app, context, hotReloadSubscribers, hasConfig, setupTasks, agents, otlpIngestor, views }) {
|
|
2174
|
+
function setupRoutes({ app, context, hotReloadSubscribers, hasConfig, setupTasks, agents, otlpIngestor, traceEventIngestor, views }) {
|
|
2122
2175
|
const { promptProviders, traceProviders, datasetProviders, rootPath, resolveSpanPrompt, resolvePromptLink } = context;
|
|
2123
2176
|
mountConfigRoute(app, rootPath, hasConfig);
|
|
2124
2177
|
app.get("/api/setup-tasks", (c) => c.json(setupTasks ? setupTasks.resolve(rootPath) : {
|
|
@@ -2486,6 +2539,10 @@ function setupRoutes({ app, context, hotReloadSubscribers, hasConfig, setupTasks
|
|
|
2486
2539
|
};
|
|
2487
2540
|
app.post("/v1/traces", otlpRoute);
|
|
2488
2541
|
app.post("/otel/v1/traces", otlpRoute);
|
|
2542
|
+
app.post(TRACE_EVENTS_PATH, async (c) => {
|
|
2543
|
+
const result = await handleTraceEvents(await c.req.text(), traceEventIngestor);
|
|
2544
|
+
return c.json(result.body, result.status);
|
|
2545
|
+
});
|
|
2489
2546
|
app.get("/api/views", async (c) => c.json(views ? await views.list() : {
|
|
2490
2547
|
version: 0,
|
|
2491
2548
|
views: [],
|
|
@@ -4830,7 +4887,7 @@ var ViewRegistry = class {
|
|
|
4830
4887
|
//#endregion
|
|
4831
4888
|
//#region src/server/index.ts
|
|
4832
4889
|
async function startServer(options) {
|
|
4833
|
-
const { promptProviders, traceProviders, datasetProviders = [], evalProviders = [], port, hostname = DEFAULT_HOST, publicUrl: givenPublicUrl, rootPath, hasConfig, terminalSessions, otlpIngestor, version } = options;
|
|
4890
|
+
const { promptProviders, traceProviders, datasetProviders = [], evalProviders = [], port, hostname = DEFAULT_HOST, publicUrl: givenPublicUrl, rootPath, hasConfig, terminalSessions, otlpIngestor, traceEventIngestor, version } = options;
|
|
4834
4891
|
const views = options.views ?? new ViewRegistry({
|
|
4835
4892
|
fileProvider: new LocalFileProvider(),
|
|
4836
4893
|
rootDir: rootPath
|
|
@@ -4870,6 +4927,7 @@ async function startServer(options) {
|
|
|
4870
4927
|
},
|
|
4871
4928
|
agents,
|
|
4872
4929
|
otlpIngestor,
|
|
4930
|
+
traceEventIngestor,
|
|
4873
4931
|
views
|
|
4874
4932
|
});
|
|
4875
4933
|
const unwatchViews = views.watch((version) => broadcast({
|
|
@@ -4963,50 +5021,6 @@ function parseCliArgs(argv) {
|
|
|
4963
5021
|
};
|
|
4964
5022
|
}
|
|
4965
5023
|
//#endregion
|
|
4966
|
-
//#region src/cli/bundler-resolution-hook.ts
|
|
4967
|
-
const RESOLVABLE_EXTENSIONS = [
|
|
4968
|
-
".ts",
|
|
4969
|
-
".tsx",
|
|
4970
|
-
".mts",
|
|
4971
|
-
".js",
|
|
4972
|
-
".jsx",
|
|
4973
|
-
".mjs",
|
|
4974
|
-
".cjs"
|
|
4975
|
-
];
|
|
4976
|
-
function isFileSpecifier(specifier) {
|
|
4977
|
-
return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("file://");
|
|
4978
|
-
}
|
|
4979
|
-
function candidateSpecifiers(specifier) {
|
|
4980
|
-
return [...RESOLVABLE_EXTENSIONS.map((ext) => specifier + ext), ...RESOLVABLE_EXTENSIONS.map((ext) => `${specifier}/index${ext}`)];
|
|
4981
|
-
}
|
|
4982
|
-
/**
|
|
4983
|
-
* Registers an in-thread module-resolution hook that falls back to
|
|
4984
|
-
* bundler-style resolution — appending an extension (`./foo` → `./foo.ts`)
|
|
4985
|
-
* or a directory's index file (`./tools` → `./tools/index.ts`) — when
|
|
4986
|
-
* Node's strict ESM resolver rejects a relative or absolute specifier that
|
|
4987
|
-
* has neither.
|
|
4988
|
-
*
|
|
4989
|
-
* Prompt files (and whatever they import) run through Node's own loader,
|
|
4990
|
-
* but consumer projects are commonly authored for a bundler
|
|
4991
|
-
* (`moduleResolution: "bundler"`), which allows omitting both. Only retried
|
|
4992
|
-
* for specifiers Node itself couldn't resolve, and only for relative or
|
|
4993
|
-
* absolute ones — bare package specifiers are left to normal resolution.
|
|
4994
|
-
*/
|
|
4995
|
-
function registerBundlerResolutionFallback() {
|
|
4996
|
-
module.registerHooks({ resolve(specifier, context, nextResolve) {
|
|
4997
|
-
if (!isFileSpecifier(specifier)) return nextResolve(specifier, context);
|
|
4998
|
-
try {
|
|
4999
|
-
return nextResolve(specifier, context);
|
|
5000
|
-
} catch (err) {
|
|
5001
|
-
if (err?.code !== "ERR_MODULE_NOT_FOUND" && err?.code !== "ERR_UNSUPPORTED_DIR_IMPORT") throw err;
|
|
5002
|
-
for (const candidate of candidateSpecifiers(specifier)) try {
|
|
5003
|
-
return nextResolve(candidate, context);
|
|
5004
|
-
} catch {}
|
|
5005
|
-
throw err;
|
|
5006
|
-
}
|
|
5007
|
-
} });
|
|
5008
|
-
}
|
|
5009
|
-
//#endregion
|
|
5010
5024
|
//#region src/cli/config-loader-hooks.ts
|
|
5011
5025
|
/**
|
|
5012
5026
|
* Registers an in-thread module-resolution hook so a project's
|
|
@@ -5902,6 +5916,8 @@ async function setUpProject(rootDir, config) {
|
|
|
5902
5916
|
for (const ingestor of ingestors) ingestor.setResource?.(PLAYGROUND_RESOURCE);
|
|
5903
5917
|
const otlpIngestor = new OtlpTraceIngestor();
|
|
5904
5918
|
ingestors.push(otlpIngestor);
|
|
5919
|
+
const traceEventIngestor = new TraceEventIngestor();
|
|
5920
|
+
ingestors.push(traceEventIngestor);
|
|
5905
5921
|
const costSink = new CostFetchingTraceSink();
|
|
5906
5922
|
const traceSinks = traceProviders.filter((p) => isTraceSink(p));
|
|
5907
5923
|
for (const sink of traceSinks) costSink.addSink(sink);
|
|
@@ -5913,7 +5929,8 @@ async function setUpProject(rootDir, config) {
|
|
|
5913
5929
|
traceProviders,
|
|
5914
5930
|
datasetProviders,
|
|
5915
5931
|
evalProviders,
|
|
5916
|
-
otlpIngestor
|
|
5932
|
+
otlpIngestor,
|
|
5933
|
+
traceEventIngestor
|
|
5917
5934
|
};
|
|
5918
5935
|
}
|
|
5919
5936
|
//#endregion
|
|
@@ -5996,6 +6013,7 @@ function registerTypeScriptTransformFallback() {
|
|
|
5996
6013
|
const VERSION = version;
|
|
5997
6014
|
registerEvalutionResolver(import.meta.url);
|
|
5998
6015
|
registerBundlerResolutionFallback();
|
|
6016
|
+
registerFreshImportHook();
|
|
5999
6017
|
registerVariationLoaderHook();
|
|
6000
6018
|
registerTypeScriptTransformFallback();
|
|
6001
6019
|
async function startConfiguredServer(rootDir, config, hasConfig, port, host, terminalSessions) {
|