evalution 1.0.8 → 2.0.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/LICENSING.md +26 -44
- package/dist/{check-CR4fU1S5.d.ts → check-ci7RhMcB.d.ts} +13 -868
- package/dist/checks/index.d.ts +2 -1
- package/dist/cli/index.js +209 -58
- package/dist/{dataset-types-Dqi5vVg-.d.ts → dataset-types-8cDpOFYi.d.ts} +2 -247
- package/dist/index.d.ts +325 -1303
- package/dist/index.js +127 -475
- package/dist/{trace-DGj5oW7z.d.ts → trace-BlnjMp7o.d.ts} +2 -1
- package/dist/{trace-event-ingestor-BghQcCHe.js → trace-event-ingestor-DwI1hxGX.js} +2143 -8238
- 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 +18 -15
package/dist/checks/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as CheckRun, q as CheckInfo, t as Check } from "../check-ci7RhMcB.js";
|
|
2
|
+
import { TraceWithSpans } from "@evalution/sdk";
|
|
2
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
4
|
|
|
4
5
|
//#region src/checks/index.d.ts
|
package/dist/cli/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as fitsPrimitiveBase, A as EvalNotFoundError, At as registerVariationLoaderHook, B as DatasetNotFoundError, C as rollupSpans, F as isPathColumn, I as parseColumnPath, J as EvalRunner, L as parseColumnSpecs, M as DEFAULT_QUERY_TIMEOUT_MS, Mt as registerFreshImportHook, N as SqlQueryError, Nt as registerBundlerResolutionFallback, O as decodeOtlpProtobuf, Ot as LocalFileProvider, P as InvalidColumnPathError, Q as InvalidCellError, R as pathField, S as mkdirSelfIgnoring, T as VariationConflictError, U as isNonEmptyStringArray, V as DatasetValidationError, W as isPromptStyle, X as CheckScopeTraceSink, Y as emptyCounts, Z as evalProblems, _t as instanceNames, at as fieldsForPrompt, ct as InputResolutionError, d as LocalEvalProvider, et as parseBinding, h as LocalDirectoryDatasetProvider, it as PRIMITIVE_FIELD_TYPES, k as normalizeOtlpRequest, lt as runPrompt, n as OtlpTraceIngestor, nt as parseResources, o as LocalDatabaseTraceProvider, ot as isPrimitiveFieldType, q as EvalRunRefusedError, rt as primitiveBase, st as portableDef, t as TraceEventIngestor, tt as parseCell, w as datasetQueryColumns, z as pathInstance } from "../trace-event-ingestor-DwI1hxGX.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";
|
|
@@ -14,16 +14,18 @@ import fs$1, { readFileSync, unlinkSync } from "node:fs";
|
|
|
14
14
|
import { createHash } from "node:crypto";
|
|
15
15
|
import { trace } from "@opentelemetry/api";
|
|
16
16
|
import { valueToSourceText } from "ts-proppy";
|
|
17
|
-
import
|
|
17
|
+
import { PLAYGROUND_RESOURCE, TRACE_EVENTS_PATH, isTraceSink } from "@evalution/sdk";
|
|
18
18
|
import { streamSSE } from "hono/streaming";
|
|
19
19
|
import { McpServer, createMcpHandler, isJSONRPCRequest } from "@modelcontextprotocol/server";
|
|
20
20
|
import * as z from "zod";
|
|
21
21
|
import * as pty from "@lydell/node-pty";
|
|
22
22
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
23
23
|
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
24
|
-
import { spawn } from "node:child_process";
|
|
24
|
+
import { execFile, spawn } from "node:child_process";
|
|
25
|
+
import { promisify } from "node:util";
|
|
26
|
+
import ts from "typescript";
|
|
25
27
|
//#region package.json
|
|
26
|
-
var version = "
|
|
28
|
+
var version = "2.0.0";
|
|
27
29
|
//#endregion
|
|
28
30
|
//#region src/agent/command-builder.ts
|
|
29
31
|
/** Characters an argument may consist of to be left unquoted. */
|
|
@@ -168,7 +170,7 @@ function findAgent(agentId) {
|
|
|
168
170
|
* order — each is a {@link SetupTask} whose lone {@link SetupStep} runs the
|
|
169
171
|
* agent's CLI with the setup prompt queued up in an interactive terminal.
|
|
170
172
|
*
|
|
171
|
-
* Mirrors {@link
|
|
173
|
+
* Mirrors {@link AI_SDK_SETUP_TASKS} in `../sdk/registry.ts`, but agents have no
|
|
172
174
|
* adapter class, so they're derived here from {@link CODING_AGENTS}.
|
|
173
175
|
*/
|
|
174
176
|
const AGENT_REGISTRY = CODING_AGENTS.map((agent) => ({
|
|
@@ -194,17 +196,101 @@ function findSetupStep$2(taskId, stepId) {
|
|
|
194
196
|
return findSetupTask$1(taskId)?.steps.find((s) => s.id === stepId);
|
|
195
197
|
}
|
|
196
198
|
//#endregion
|
|
197
|
-
//#region src/
|
|
199
|
+
//#region src/shared/setup-task.ts
|
|
200
|
+
/**
|
|
201
|
+
* Shared, dependency-free types describing the onboarding "setup tasks" a user
|
|
202
|
+
* can run to wire up an AI SDK.
|
|
203
|
+
*
|
|
204
|
+
* This module is imported by both the browser client (to render the
|
|
205
|
+
* manual-setup picker) and the server (to define and execute the tasks), so it
|
|
206
|
+
* must stay free of any Node- or DOM-specific imports.
|
|
207
|
+
*/
|
|
208
|
+
/** Path, relative to the project root, where evalution looks for its config. */
|
|
209
|
+
const CONFIG_FILE_RELATIVE_PATH = ".evalution/config.ts";
|
|
210
|
+
/**
|
|
211
|
+
* The shell command a run-style step executes. `install_package` steps map to
|
|
212
|
+
* `npm i <package>`; `run_command` steps carry their command verbatim.
|
|
213
|
+
*/
|
|
214
|
+
function setupStepCommand(step) {
|
|
215
|
+
return step.kind === "install_package" ? `npm i ${step.package}` : step.command;
|
|
216
|
+
}
|
|
198
217
|
/**
|
|
199
|
-
* Every AI SDK offered in manual onboarding, in display order
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* here.
|
|
218
|
+
* Every AI SDK offered in manual onboarding, in display order, and the single
|
|
219
|
+
* source of truth for their task ids. Plain data rather than something the
|
|
220
|
+
* adapters carry: onboarding runs before an adapter package is installed.
|
|
203
221
|
*/
|
|
204
|
-
const
|
|
222
|
+
const AI_SDK_SETUP_TASKS = [{
|
|
223
|
+
id: "vercel-ai-sdk",
|
|
224
|
+
label: "AI SDK",
|
|
225
|
+
icon: "vercel",
|
|
226
|
+
steps: [
|
|
227
|
+
{
|
|
228
|
+
kind: "install_package",
|
|
229
|
+
id: "install-ai",
|
|
230
|
+
package: "ai"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
kind: "install_package",
|
|
234
|
+
id: "install-evalution-vercel-ai-sdk",
|
|
235
|
+
package: "@evalution/vercel-ai-sdk"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
kind: "create_config",
|
|
239
|
+
id: "create-config",
|
|
240
|
+
path: CONFIG_FILE_RELATIVE_PATH,
|
|
241
|
+
contents: `import type { EvalutionConfig } from 'evalution';
|
|
242
|
+
import { FilePromptProvider } from 'evalution';
|
|
243
|
+
import { VercelAISDK } from '@evalution/vercel-ai-sdk/config';
|
|
244
|
+
|
|
245
|
+
export default {
|
|
246
|
+
promptProviders: [
|
|
247
|
+
new FilePromptProvider({
|
|
248
|
+
sdk: new VercelAISDK(),
|
|
249
|
+
}),
|
|
250
|
+
],
|
|
251
|
+
} satisfies EvalutionConfig;
|
|
252
|
+
`
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
}, {
|
|
256
|
+
id: "typesafe-sdk",
|
|
257
|
+
label: "TypeSafe",
|
|
258
|
+
icon: "TypeSafe",
|
|
259
|
+
steps: [
|
|
260
|
+
{
|
|
261
|
+
kind: "install_package",
|
|
262
|
+
id: "install-typesafe-sdk",
|
|
263
|
+
package: "@typesafe-ai/sdk"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
kind: "install_package",
|
|
267
|
+
id: "install-evalution-typesafe-sdk",
|
|
268
|
+
package: "@evalution/typesafe-sdk"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
kind: "create_config",
|
|
272
|
+
id: "create-config",
|
|
273
|
+
path: CONFIG_FILE_RELATIVE_PATH,
|
|
274
|
+
contents: `import type { EvalutionConfig } from 'evalution';
|
|
275
|
+
import { FilePromptProvider } from 'evalution';
|
|
276
|
+
import { TypeSafeSDK } from '@evalution/typesafe-sdk/config';
|
|
277
|
+
|
|
278
|
+
// Running prompts needs a TypeSafe API key: set TYPESAFE_API_KEY in the
|
|
279
|
+
// environment you start evalution from.
|
|
280
|
+
export default {
|
|
281
|
+
promptProviders: [
|
|
282
|
+
new FilePromptProvider({
|
|
283
|
+
sdk: new TypeSafeSDK(),
|
|
284
|
+
}),
|
|
285
|
+
],
|
|
286
|
+
} satisfies EvalutionConfig;
|
|
287
|
+
`
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
}];
|
|
205
291
|
/** Look up a {@link SetupTask} by its id, or `undefined` if none matches. */
|
|
206
292
|
function findSetupTask(taskId) {
|
|
207
|
-
|
|
293
|
+
return AI_SDK_SETUP_TASKS.find((task) => task.id === taskId);
|
|
208
294
|
}
|
|
209
295
|
/**
|
|
210
296
|
* Look up a step within a task by both ids, or `undefined` if either is
|
|
@@ -237,7 +323,7 @@ var SetupStepNotFoundError = class extends Error {
|
|
|
237
323
|
* `taskId`/`stepId`.
|
|
238
324
|
*
|
|
239
325
|
* The client only sends ids; the step definition (file contents, command, ...)
|
|
240
|
-
* comes entirely from {@link
|
|
326
|
+
* comes entirely from {@link AI_SDK_SETUP_TASKS}, so a request can never write
|
|
241
327
|
* arbitrary files or run arbitrary commands.
|
|
242
328
|
*
|
|
243
329
|
* @param rootPath - Absolute path to the project root.
|
|
@@ -271,7 +357,7 @@ function resolveSetupTasks(rootPath) {
|
|
|
271
357
|
});
|
|
272
358
|
return {
|
|
273
359
|
agent: AGENT_REGISTRY.map(resolve),
|
|
274
|
-
sdk:
|
|
360
|
+
sdk: AI_SDK_SETUP_TASKS.map(resolve)
|
|
275
361
|
};
|
|
276
362
|
}
|
|
277
363
|
/** Adds the runtime `completed` flag to a single step where determinable. */
|
|
@@ -5062,7 +5148,8 @@ function parseCliArgs(argv) {
|
|
|
5062
5148
|
* and isn't installed locally. This hook redirects the `evalution` specifier
|
|
5063
5149
|
* (and its subpaths) to resolve from the running CLI instead, so the config
|
|
5064
5150
|
* always binds to the same evalution the CLI is executing — no local install
|
|
5065
|
-
* required.
|
|
5151
|
+
* required. The same goes for `@evalution/sdk`, and for the packages an adapter
|
|
5152
|
+
* expects its host to provide (see {@link ADAPTER_PEERS}).
|
|
5066
5153
|
*
|
|
5067
5154
|
* Uses {@link https://nodejs.org/api/module.html#moduleregisterhooksoptions | `module.registerHooks`}
|
|
5068
5155
|
* (synchronous, same-thread) rather than `module.register`, so it needs no
|
|
@@ -5074,45 +5161,11 @@ function parseCliArgs(argv) {
|
|
|
5074
5161
|
*/
|
|
5075
5162
|
function registerEvalutionResolver(parentURL) {
|
|
5076
5163
|
module.registerHooks({ resolve(specifier, context, nextResolve) {
|
|
5077
|
-
if (specifier
|
|
5164
|
+
if (isCliOwned(specifier)) return nextResolve(specifier, {
|
|
5078
5165
|
...context,
|
|
5079
5166
|
parentURL
|
|
5080
5167
|
});
|
|
5081
|
-
return nextResolve(specifier, context);
|
|
5082
|
-
} });
|
|
5083
|
-
}
|
|
5084
|
-
/**
|
|
5085
|
-
* Packages evalution imports lazily but does not own: they are optional peer
|
|
5086
|
-
* dependencies belonging to the consumer's project, and execution must run
|
|
5087
|
-
* against the consumer's own copy (the same instance their provider/model
|
|
5088
|
-
* objects were built with).
|
|
5089
|
-
*/
|
|
5090
|
-
const PEER_DEPENDENCIES = ["ai", "@google/genai"];
|
|
5091
|
-
function isPeerDependency(specifier) {
|
|
5092
|
-
return PEER_DEPENDENCIES.some((name) => specifier === name || specifier.startsWith(`${name}/`));
|
|
5093
|
-
}
|
|
5094
|
-
/**
|
|
5095
|
-
* Registers an in-thread module-resolution hook that lets evalution's lazy
|
|
5096
|
-
* `import('ai')` / `import('@google/genai')` find those packages in the user's
|
|
5097
|
-
* project when they are not resolvable from evalution itself.
|
|
5098
|
-
*
|
|
5099
|
-
* This is the mirror image of {@link registerEvalutionResolver}. Both packages
|
|
5100
|
-
* are *optional* peer dependencies, which npm deliberately does not install —
|
|
5101
|
-
* so under `npx evalution` they are absent from the CLI's own `node_modules`
|
|
5102
|
-
* and a bare `import('ai')` from the bundle fails with `ERR_MODULE_NOT_FOUND`
|
|
5103
|
-
* even though the project it was pointed at has `ai` installed.
|
|
5104
|
-
*
|
|
5105
|
-
* The retry only runs after normal resolution has already failed, so a project
|
|
5106
|
-
* that resolves these packages on its own (the common case, including a
|
|
5107
|
-
* workspace that pins its own copy) keeps the exact resolution it has today.
|
|
5108
|
-
*
|
|
5109
|
-
* @param projectDir - Directory to retry resolution from; pass the root dir the
|
|
5110
|
-
* CLI is serving (the one holding `.evalution/config.ts`).
|
|
5111
|
-
*/
|
|
5112
|
-
function registerPeerDependencyResolver(projectDir) {
|
|
5113
|
-
const parentURL = pathToFileURL(path.join(projectDir, "[evalution-peer-resolver]")).href;
|
|
5114
|
-
module.registerHooks({ resolve(specifier, context, nextResolve) {
|
|
5115
|
-
if (!isPeerDependency(specifier)) return nextResolve(specifier, context);
|
|
5168
|
+
if (!ADAPTER_PEERS.has(specifier)) return nextResolve(specifier, context);
|
|
5116
5169
|
try {
|
|
5117
5170
|
return nextResolve(specifier, context);
|
|
5118
5171
|
} catch (err) {
|
|
@@ -5127,6 +5180,20 @@ function registerPeerDependencyResolver(projectDir) {
|
|
|
5127
5180
|
}
|
|
5128
5181
|
} });
|
|
5129
5182
|
}
|
|
5183
|
+
/**
|
|
5184
|
+
* Packages always bound to the running CLI's copy. An adapter package installed
|
|
5185
|
+
* in the project depends on `@evalution/sdk` too, and under `npx` that would
|
|
5186
|
+
* otherwise be a second copy of it.
|
|
5187
|
+
*/
|
|
5188
|
+
function isCliOwned(specifier) {
|
|
5189
|
+
return ["evalution", "@evalution/sdk"].some((name) => specifier === name || specifier.startsWith(`${name}/`));
|
|
5190
|
+
}
|
|
5191
|
+
/**
|
|
5192
|
+
* Optional peers of the adapter packages' `/config` entries. They stay optional
|
|
5193
|
+
* so a production install of an adapter doesn't pull in the TypeScript
|
|
5194
|
+
* compiler, so a project may not have them; the CLI always does.
|
|
5195
|
+
*/
|
|
5196
|
+
const ADAPTER_PEERS = /* @__PURE__ */ new Set(["typescript", "ts-proppy"]);
|
|
5130
5197
|
//#endregion
|
|
5131
5198
|
//#region src/cli/config-watcher.ts
|
|
5132
5199
|
/**
|
|
@@ -5719,6 +5786,66 @@ function openBrowser(url) {
|
|
|
5719
5786
|
} catch {}
|
|
5720
5787
|
}
|
|
5721
5788
|
//#endregion
|
|
5789
|
+
//#region src/cli/portkit.ts
|
|
5790
|
+
/** How long `portkit adopt` gets before startup carries on without it. */
|
|
5791
|
+
const ADOPT_TIMEOUT_MS = 3e3;
|
|
5792
|
+
const runCommand = promisify(execFile);
|
|
5793
|
+
/**
|
|
5794
|
+
* The portkit name for a project: `<dir>.evalution`, or just `evalution` when
|
|
5795
|
+
* nothing of the directory's name is usable in a DNS label.
|
|
5796
|
+
*/
|
|
5797
|
+
function portkitServiceName(rootDir) {
|
|
5798
|
+
const label = path.basename(rootDir).toLowerCase().replace(/[^a-z0-9-]+/g, "-").slice(0, 63).replace(/^-+|-+$/g, "");
|
|
5799
|
+
return label ? `${label}.evalution` : "evalution";
|
|
5800
|
+
}
|
|
5801
|
+
/**
|
|
5802
|
+
* Names this server to portkit and labels it, so an app's SDK can find it and
|
|
5803
|
+
* it has an HTTPS URL for as long as this process lives. Portkit merges this
|
|
5804
|
+
* into the record when it already routes to `port`, as it does for a server
|
|
5805
|
+
* it started itself.
|
|
5806
|
+
*
|
|
5807
|
+
* Resolves to `undefined` if portkit isn't installed or refuses: nothing
|
|
5808
|
+
* depends on it.
|
|
5809
|
+
*/
|
|
5810
|
+
async function adoptIntoPortkit(rootDir, port, { env = process.env, run = runCommand } = {}) {
|
|
5811
|
+
const args = [
|
|
5812
|
+
"adopt",
|
|
5813
|
+
portkitServiceName(rootDir),
|
|
5814
|
+
String(port),
|
|
5815
|
+
"--label",
|
|
5816
|
+
"kind=evalution",
|
|
5817
|
+
"--json"
|
|
5818
|
+
];
|
|
5819
|
+
const [file, ...fullArgs] = env.PORTKIT_HOME ? [
|
|
5820
|
+
path.join(env.PORTKIT_HOME, "bin", "caddy"),
|
|
5821
|
+
"portkit",
|
|
5822
|
+
...args
|
|
5823
|
+
] : ["portkit", ...args];
|
|
5824
|
+
try {
|
|
5825
|
+
const { stdout } = await run(file, fullArgs, {
|
|
5826
|
+
cwd: rootDir,
|
|
5827
|
+
timeout: ADOPT_TIMEOUT_MS
|
|
5828
|
+
});
|
|
5829
|
+
const { url, record } = JSON.parse(stdout);
|
|
5830
|
+
return typeof url === "string" ? {
|
|
5831
|
+
url,
|
|
5832
|
+
mode: record?.mode
|
|
5833
|
+
} : void 0;
|
|
5834
|
+
} catch {
|
|
5835
|
+
return;
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
/**
|
|
5839
|
+
* Registers the server with portkit if it's there, and resolves to the URL to
|
|
5840
|
+
* open the playground at when a proxy serves it: the one that started this
|
|
5841
|
+
* process, or else the one that just adopted it.
|
|
5842
|
+
*/
|
|
5843
|
+
async function resolvePublicUrl(rootDir, port, options = {}) {
|
|
5844
|
+
const { env = process.env } = options;
|
|
5845
|
+
const adoption = await adoptIntoPortkit(rootDir, port, options);
|
|
5846
|
+
return env.PORTKIT_URL ?? env.PORTLESS_URL ?? adoption?.url;
|
|
5847
|
+
}
|
|
5848
|
+
//#endregion
|
|
5722
5849
|
//#region src/trace/cost-fetching-trace-sink.ts
|
|
5723
5850
|
/** The catalogs to fetch prices from, in order — each only if the last fails. */
|
|
5724
5851
|
const CATALOGS = [{
|
|
@@ -5913,10 +6040,34 @@ async function findRootDir(startDir) {
|
|
|
5913
6040
|
}
|
|
5914
6041
|
async function loadConfig(rootDir) {
|
|
5915
6042
|
const configPath = path.join(rootDir, ".evalution", "config.ts");
|
|
5916
|
-
|
|
6043
|
+
let mod;
|
|
6044
|
+
try {
|
|
6045
|
+
mod = await import(pathToFileURL(configPath).href);
|
|
6046
|
+
} catch (err) {
|
|
6047
|
+
throw movedExportError(err) ?? err;
|
|
6048
|
+
}
|
|
5917
6049
|
console.log(`⚙️ Loaded config from ${configPath}`);
|
|
5918
6050
|
return mod.default ?? {};
|
|
5919
6051
|
}
|
|
6052
|
+
/** Exports that left `evalution` in 2.0, and the package each is now in. */
|
|
6053
|
+
const MOVED_EXPORTS = {
|
|
6054
|
+
VercelAISDK: "@evalution/vercel-ai-sdk/config",
|
|
6055
|
+
VercelAISDKTelemetry: "@evalution/vercel-ai-sdk",
|
|
6056
|
+
TypeSafeSDK: "@evalution/typesafe-sdk/config",
|
|
6057
|
+
TypeSafeTelemetry: "@evalution/typesafe-sdk",
|
|
6058
|
+
GeminiInteractionsSDK: "@evalution/gemini-interactions-sdk/config"
|
|
6059
|
+
};
|
|
6060
|
+
/**
|
|
6061
|
+
* If `err` is a config importing something that has moved out of `evalution`,
|
|
6062
|
+
* the error telling the user where it went.
|
|
6063
|
+
*/
|
|
6064
|
+
function movedExportError(err) {
|
|
6065
|
+
if (!(err instanceof SyntaxError)) return void 0;
|
|
6066
|
+
const name = /module 'evalution' does not provide an export named '(\w+)'/.exec(err.message)?.[1];
|
|
6067
|
+
const target = name && MOVED_EXPORTS[name];
|
|
6068
|
+
if (!target) return void 0;
|
|
6069
|
+
return new Error(`\`${name}\` is no longer exported from 'evalution'. In .evalution/config.ts, import it from '${target}' instead, and install that package.`, { cause: err });
|
|
6070
|
+
}
|
|
5920
6071
|
function applyDotenv(rootDir) {
|
|
5921
6072
|
const envPath = path.join(rootDir, ".env");
|
|
5922
6073
|
try {
|
|
@@ -6045,12 +6196,12 @@ registerBundlerResolutionFallback();
|
|
|
6045
6196
|
registerFreshImportHook();
|
|
6046
6197
|
registerVariationLoaderHook();
|
|
6047
6198
|
registerTypeScriptTransformFallback();
|
|
6048
|
-
async function startConfiguredServer(rootDir, config, hasConfig, port, host, terminalSessions) {
|
|
6199
|
+
async function startConfiguredServer(rootDir, config, hasConfig, port, host, publicUrl, terminalSessions) {
|
|
6049
6200
|
return startServer({
|
|
6050
6201
|
...await setUpProject(rootDir, config),
|
|
6051
6202
|
port,
|
|
6052
6203
|
hostname: host,
|
|
6053
|
-
publicUrl
|
|
6204
|
+
publicUrl,
|
|
6054
6205
|
rootPath: rootDir,
|
|
6055
6206
|
hasConfig,
|
|
6056
6207
|
terminalSessions,
|
|
@@ -6069,7 +6220,6 @@ async function main() {
|
|
|
6069
6220
|
const { command, path: pathArg, host } = args;
|
|
6070
6221
|
if (command === "mcp") keepStdoutForProtocol();
|
|
6071
6222
|
const { rootDir, hasConfig } = await findRootDir(pathArg ? path.resolve(pathArg) : process.cwd());
|
|
6072
|
-
registerPeerDependencyResolver(rootDir);
|
|
6073
6223
|
process.chdir(rootDir);
|
|
6074
6224
|
if (command === "mcp") {
|
|
6075
6225
|
await mcp(rootDir, hasConfig);
|
|
@@ -6116,6 +6266,7 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
|
|
|
6116
6266
|
let port;
|
|
6117
6267
|
if (process.env.PORT) port = parseInt(process.env.PORT, 10);
|
|
6118
6268
|
else port = await findAvailablePort(3e3, host);
|
|
6269
|
+
const publicUrl = await resolvePublicUrl(rootDir, port);
|
|
6119
6270
|
const maybeOpen = async (url) => {
|
|
6120
6271
|
if (process.env.EVALUTION_NO_OPEN) return;
|
|
6121
6272
|
await new Promise((r) => setTimeout(r, 250));
|
|
@@ -6123,12 +6274,12 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
|
|
|
6123
6274
|
};
|
|
6124
6275
|
const terminalSessions = new TerminalSessionRegistry();
|
|
6125
6276
|
if (hasConfig) {
|
|
6126
|
-
const handle = await startConfiguredServer(rootDir, await loadConfig(rootDir), true, port, host, terminalSessions);
|
|
6277
|
+
const handle = await startConfiguredServer(rootDir, await loadConfig(rootDir), true, port, host, publicUrl, terminalSessions);
|
|
6127
6278
|
await writeServerInfo(rootDir, handle.url, "ui");
|
|
6128
6279
|
await maybeOpen(handle.publicUrl);
|
|
6129
6280
|
return;
|
|
6130
6281
|
}
|
|
6131
|
-
let server = await startConfiguredServer(rootDir, {}, false, port, host, terminalSessions);
|
|
6282
|
+
let server = await startConfiguredServer(rootDir, {}, false, port, host, publicUrl, terminalSessions);
|
|
6132
6283
|
await writeServerInfo(rootDir, server.url, "ui");
|
|
6133
6284
|
await maybeOpen(server.publicUrl);
|
|
6134
6285
|
console.log(`👀 No config found; watching ${path.join(rootDir, ".evalution", "config.ts")} for creation...`);
|
|
@@ -6137,7 +6288,7 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
|
|
|
6137
6288
|
console.log("⚙️ Config loaded; restarting server...");
|
|
6138
6289
|
stopWatching();
|
|
6139
6290
|
await server.close();
|
|
6140
|
-
server = await startConfiguredServer(rootDir, config, true, port, host, terminalSessions);
|
|
6291
|
+
server = await startConfiguredServer(rootDir, config, true, port, host, publicUrl, terminalSessions);
|
|
6141
6292
|
});
|
|
6142
6293
|
}
|
|
6143
6294
|
main().catch((error) => {
|
|
@@ -1,251 +1,6 @@
|
|
|
1
|
+
import { PromptID } from "@evalution/sdk";
|
|
1
2
|
import { PropDefinition, PropValue } from "ts-proppy";
|
|
2
3
|
|
|
3
|
-
//#region src/trace/trace-types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* A reference to a prompt.
|
|
6
|
-
*
|
|
7
|
-
* `id` is interpreted as a globally-unique prompt ID unless `providerId` is
|
|
8
|
-
* present, in which case `id` is scoped to that specific prompt provider. This
|
|
9
|
-
* mirrors the OpenTelemetry attributes `evalution.prompt.id` (always present)
|
|
10
|
-
* and `evalution.prompt.provider.id` (optional, scoping).
|
|
11
|
-
*/
|
|
12
|
-
interface PromptID {
|
|
13
|
-
/** The prompt ID — global unless {@link providerId} scopes it. */
|
|
14
|
-
id: string;
|
|
15
|
-
/** When set, {@link id} is scoped to this prompt provider. */
|
|
16
|
-
providerId?: string;
|
|
17
|
-
/** Positional arguments the prompt function was called with. */
|
|
18
|
-
functionParameters?: unknown[];
|
|
19
|
-
/**
|
|
20
|
-
* The unresolved inputs the run was launched with — the recipe, not the
|
|
21
|
-
* resolution.
|
|
22
|
-
*
|
|
23
|
-
* Replaying them is only exactly faithful for the `value` kind. A `resource`
|
|
24
|
-
* re-runs its `create()`, producing an *equivalent* value rather than the
|
|
25
|
-
* same one — a fresh handle, a newly seeded row — so a UI must present it as
|
|
26
|
-
* something that will be re-created, never as a restored value.
|
|
27
|
-
*/
|
|
28
|
-
functionInputs?: unknown[];
|
|
29
|
-
/** The unresolved execute-parameter inputs, keyed by parameter name. */
|
|
30
|
-
executeInputs?: Record<string, unknown>;
|
|
31
|
-
/**
|
|
32
|
-
* The run's named resource instances, by name, with the receipt each
|
|
33
|
-
* `create()` produced. See `specs/resource-instances.md` §F.
|
|
34
|
-
*/
|
|
35
|
-
resources?: Record<string, unknown>;
|
|
36
|
-
/**
|
|
37
|
-
* The prompt's parameter definitions as they stood when the run was
|
|
38
|
-
* launched, so a replay can diff them against today's signature rather than
|
|
39
|
-
* guess whether the recorded inputs still fit.
|
|
40
|
-
*/
|
|
41
|
-
parameterDefinitions?: unknown[];
|
|
42
|
-
/**
|
|
43
|
-
* The prompt's execute-parameter definitions as they stood when the run was
|
|
44
|
-
* launched — the types of {@link executeInputs}, as
|
|
45
|
-
* {@link parameterDefinitions} is for {@link functionInputs}.
|
|
46
|
-
*/
|
|
47
|
-
executeParameterDefinitions?: unknown[];
|
|
48
|
-
/** The version the run executed against. */
|
|
49
|
-
version?: string;
|
|
50
|
-
/** The variation applied on top of {@link version}, if any. */
|
|
51
|
-
variation?: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Classification of a {@link Span}. See also:
|
|
55
|
-
* - `lmnr.span.type` from https://laminar.sh/docs/tracing/otel
|
|
56
|
-
* - `mlflow.spanType` from https://mlflow.org/docs/latest/genai/tracing/opentelemetry/attribute-mapping/#translated-span-attributes
|
|
57
|
-
*
|
|
58
|
-
* Mapped from `gen_ai.operation.name`. `CHECK` is evalution's own: an eval
|
|
59
|
-
* check that traced something while judging the run — see
|
|
60
|
-
* {@link CHECK_ATTRIBUTE}.
|
|
61
|
-
*/
|
|
62
|
-
type SpanKind = "LLM" | "TOOL" | "AGENT" | "EMBEDDING" | "CHECK" | "DEFAULT";
|
|
63
|
-
/** A text segment within a multi-part {@link SpanMessage} content. */
|
|
64
|
-
interface SpanTextPart {
|
|
65
|
-
type: "text";
|
|
66
|
-
text: string;
|
|
67
|
-
}
|
|
68
|
-
/** An image segment within a multi-part {@link SpanMessage} content. */
|
|
69
|
-
interface SpanImagePart {
|
|
70
|
-
type: "image";
|
|
71
|
-
/** A URL, or base64/data-URI image data. */
|
|
72
|
-
image: string;
|
|
73
|
-
/** MIME type (e.g. `image/png`), when known. */
|
|
74
|
-
mediaType?: string;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* A tool call the assistant made, within a multi-part {@link SpanMessage}
|
|
78
|
-
* content. Matched to its {@link SpanToolResultPart} by `toolCallId`.
|
|
79
|
-
*/
|
|
80
|
-
interface SpanToolCallPart {
|
|
81
|
-
type: "tool-call";
|
|
82
|
-
toolCallId: string;
|
|
83
|
-
toolName: string;
|
|
84
|
-
/** The arguments the model passed, as JSON. */
|
|
85
|
-
input: unknown;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* A tool's result fed back to the model, within a multi-part
|
|
89
|
-
* {@link SpanMessage} content (usually a `tool` message).
|
|
90
|
-
*/
|
|
91
|
-
interface SpanToolResultPart {
|
|
92
|
-
type: "tool-result";
|
|
93
|
-
toolCallId: string;
|
|
94
|
-
toolName: string;
|
|
95
|
-
/** What the tool returned, unwrapped from the SDK's output envelope. */
|
|
96
|
-
output: unknown;
|
|
97
|
-
/** Whether the result reports a failure (an error, or a denied call). */
|
|
98
|
-
isError?: boolean;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* The reasoning (thinking) a model produced ahead of its answer, within a
|
|
102
|
-
* multi-part {@link SpanMessage} content — how a conversation's earlier
|
|
103
|
-
* assistant turns carry theirs. The turn a span records keeps its own in
|
|
104
|
-
* {@link LLMSpanDetails.reasoning}.
|
|
105
|
-
*/
|
|
106
|
-
interface SpanReasoningPart {
|
|
107
|
-
type: "reasoning";
|
|
108
|
-
text: string;
|
|
109
|
-
}
|
|
110
|
-
type SpanMessageRole = "user" | "assistant" | "system" | "tool" | (string & {});
|
|
111
|
-
/** One segment of a multi-part {@link SpanMessage} content. */
|
|
112
|
-
type SpanContentPart = SpanTextPart | SpanImagePart | SpanToolCallPart | SpanToolResultPart | SpanReasoningPart;
|
|
113
|
-
/**
|
|
114
|
-
* A single message within an LLM span's input/output.
|
|
115
|
-
*
|
|
116
|
-
* `content` is a plain string for the common text-only case. It is an array
|
|
117
|
-
* of {@link SpanContentPart} when the message carries non-text content (e.g.
|
|
118
|
-
* an image, or a tool call or result) — the `string` form stays in the union so existing consumers and
|
|
119
|
-
* already-stored rows keep working unchanged.
|
|
120
|
-
*/
|
|
121
|
-
interface SpanMessage {
|
|
122
|
-
role: SpanMessageRole;
|
|
123
|
-
content: string | SpanContentPart[];
|
|
124
|
-
}
|
|
125
|
-
/** LLM-specific attributes attached to `LLM` spans. */
|
|
126
|
-
interface LLMSpanDetails {
|
|
127
|
-
provider?: string;
|
|
128
|
-
model?: string;
|
|
129
|
-
/** Model parameters (temperature, max_tokens, …). */
|
|
130
|
-
modelParameters?: Record<string, unknown>;
|
|
131
|
-
/**
|
|
132
|
-
* Why the model stopped generating, as the provider or SDK reports it
|
|
133
|
-
* (`stop`, `length`, `tool-calls`, …). Not normalized across providers.
|
|
134
|
-
*/
|
|
135
|
-
finishReason?: string;
|
|
136
|
-
/**
|
|
137
|
-
* What the model was given: a message list for a chat model, or any JSON
|
|
138
|
-
* for a model that takes something else (a System One call records
|
|
139
|
-
* `{ state, questions }`). Array-ness is the discriminant — see
|
|
140
|
-
* {@link spanMessages}.
|
|
141
|
-
*/
|
|
142
|
-
input?: SpanMessage[] | {
|
|
143
|
-
[key: string]: unknown;
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* What it returned: text for a chat model, the assistant message of a turn
|
|
147
|
-
* that called tools (see `toolCallingOutput`), or JSON for structured
|
|
148
|
-
* output and for any model whose answer is data rather than prose.
|
|
149
|
-
*/
|
|
150
|
-
output?: unknown;
|
|
151
|
-
/**
|
|
152
|
-
* The reasoning the model produced on the way to {@link output}, kept apart
|
|
153
|
-
* from it so an output stays the answer that checks and agents read.
|
|
154
|
-
*/
|
|
155
|
-
reasoning?: string;
|
|
156
|
-
/** Input tokens, counting any read from or written to a prompt cache. */
|
|
157
|
-
promptTokens?: number;
|
|
158
|
-
completionTokens?: number;
|
|
159
|
-
totalTokens?: number;
|
|
160
|
-
/** How many of {@link promptTokens} were read from a prompt cache. */
|
|
161
|
-
cacheReadTokens?: number;
|
|
162
|
-
/** How many of {@link promptTokens} were written to a prompt cache. */
|
|
163
|
-
cacheWriteTokens?: number;
|
|
164
|
-
/**
|
|
165
|
-
* Dollar cost of the call, broken down by token type, if known. The total
|
|
166
|
-
* cost is `cost.prompt + cost.completion`; `cost.prompt` includes cache
|
|
167
|
-
* reads and writes, each at its own price.
|
|
168
|
-
*/
|
|
169
|
-
cost?: {
|
|
170
|
-
prompt: number;
|
|
171
|
-
completion: number; /** The part of `prompt` spent on {@link cacheReadTokens}. */
|
|
172
|
-
cacheRead?: number; /** The part of `prompt` spent on {@link cacheWriteTokens}. */
|
|
173
|
-
cacheWrite?: number;
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
interface ToolSpanDetails {
|
|
177
|
-
toolName: string;
|
|
178
|
-
/**
|
|
179
|
-
* The id the model gave this call, when the integration reports it — the
|
|
180
|
-
* same id as the {@link SpanToolCallPart} that requested it.
|
|
181
|
-
*/
|
|
182
|
-
toolCallId?: string;
|
|
183
|
-
input: unknown;
|
|
184
|
-
output?: unknown;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* A span in a {@link Trace}. Spans form a tree via {@link parentId}.
|
|
188
|
-
* Durations are derived from `startTime` and `endTime`; an in-progress span has
|
|
189
|
-
* no `endTime` yet.
|
|
190
|
-
*/
|
|
191
|
-
interface Span {
|
|
192
|
-
id: string;
|
|
193
|
-
traceId: string;
|
|
194
|
-
/** `undefined` for the root span of the trace. */
|
|
195
|
-
parentId?: string;
|
|
196
|
-
name: string;
|
|
197
|
-
kind: SpanKind;
|
|
198
|
-
/** Start timestamp in milliseconds since epoch. */
|
|
199
|
-
startTime: number;
|
|
200
|
-
/** End timestamp in milliseconds since epoch, or `undefined` while running. */
|
|
201
|
-
endTime?: number;
|
|
202
|
-
status?: "ok" | "error";
|
|
203
|
-
/** Error message if `status` is `'error'`. */
|
|
204
|
-
errorMessage?: string;
|
|
205
|
-
/** Free-form attributes to show in the span's details pane. */
|
|
206
|
-
attributes?: Record<string, unknown>;
|
|
207
|
-
/**
|
|
208
|
-
* The OpenTelemetry resource that produced the span: attributes describing
|
|
209
|
-
* the process or service it ran in rather than the span itself
|
|
210
|
-
* (`service.name`, `deployment.environment.name`, …).
|
|
211
|
-
*/
|
|
212
|
-
resource?: Record<string, unknown>;
|
|
213
|
-
/** LLM-specific details (present for `chat`/`completion`/`embedding` spans). */
|
|
214
|
-
llm?: LLMSpanDetails;
|
|
215
|
-
/**
|
|
216
|
-
* The prompt this span is attributed to, if any.
|
|
217
|
-
*
|
|
218
|
-
* Stored as emitted (`evalution.prompt.id` plus optional
|
|
219
|
-
* `evalution.prompt.provider.id`): a {@link PromptID} whose `id` is global
|
|
220
|
-
* unless `providerId` is set. The server resolves it against the prompt
|
|
221
|
-
* registry to a provider-scoped reference when a trace is served.
|
|
222
|
-
*/
|
|
223
|
-
prompt?: PromptID;
|
|
224
|
-
tool?: ToolSpanDetails;
|
|
225
|
-
}
|
|
226
|
-
interface TraceBase {
|
|
227
|
-
id: string;
|
|
228
|
-
providerId?: string;
|
|
229
|
-
name: string;
|
|
230
|
-
/** Start timestamp (ms). */
|
|
231
|
-
startTime: number;
|
|
232
|
-
/** End timestamp (ms), or `undefined` while the trace is still running. */
|
|
233
|
-
endTime?: number;
|
|
234
|
-
status: "running" | "ok" | "error";
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Top-level trace for a single invocation (e.g. one prompt execution).
|
|
238
|
-
*/
|
|
239
|
-
interface Trace extends TraceBase {
|
|
240
|
-
/** Free-form attributes (e.g. prompt ID, function params). */
|
|
241
|
-
attributes?: Record<string, unknown>;
|
|
242
|
-
}
|
|
243
|
-
/** A trace together with all of its spans. */
|
|
244
|
-
interface TraceWithSpans {
|
|
245
|
-
trace: Trace;
|
|
246
|
-
spans: Span[];
|
|
247
|
-
}
|
|
248
|
-
//#endregion
|
|
249
4
|
//#region src/shared/types.d.ts
|
|
250
5
|
/**
|
|
251
6
|
* One prompt input, *before* resolution — the recipe rather than the value.
|
|
@@ -576,4 +331,4 @@ interface DatasetRowsOverview {
|
|
|
576
331
|
instances: Record<string, DatasetInstanceShape>;
|
|
577
332
|
}
|
|
578
333
|
//#endregion
|
|
579
|
-
export { ResourceInstanceInput as _, ColumnPath as a,
|
|
334
|
+
export { ResourceInstanceInput as _, ColumnPath as a, PathRow as c, childInputs as d, fieldPath as f, ExecutionInput as g, resolveColumnPath as h, DatasetRowsOverview as i, PathValue as l, readColumnPath as m, DatasetRow as n, InstanceArgument as o, instancePath as p, DatasetRowUpdate as r, MAX_REFERENCE_HOPS as s, Dataset as t, ResolvedPath as u, RunResources as v };
|