evalution 2.0.2 → 2.0.4
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/dist/cli/index.js +90 -10
- package/dist/client/assets/{DatasetView-DZ2uLHKV.js → DatasetView-B1KoSX7p.js} +4 -4
- package/dist/client/assets/{EvalRunView-T610dLVw.js → EvalRunView-By5RN8fo.js} +1 -1
- package/dist/client/assets/{EvalView-Cae68vPB.js → EvalView-BW2qyhFj.js} +1 -1
- package/dist/client/assets/{data-grid-overlay-editor-PtH7A6E4.js → data-grid-overlay-editor-CQsCX66k.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-CPtwvSJb.js → highlighted-body-KPVGNVTW-D7b_g0Y9.js} +1 -1
- package/dist/client/assets/{index-BFH07Ynk.js → index-BDqLFfPf.js} +128 -128
- package/dist/client/assets/{number-overlay-editor-BbQhagHP.js → number-overlay-editor-lGaIg9Iu.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/{cost-fetching-trace-sink-Dz8gniQ6.js → cost-fetching-trace-sink-BEqbMdt1.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/ingest.js +2 -2
- package/dist/{local-database-trace-provider-87-WGqfS.js → local-database-trace-provider-BHe2hLFA.js} +20 -1
- package/dist/{trace-event-ingestor-B1DYEg2H.js → trace-event-ingestor-fjlL_FYB.js} +50 -9
- package/package.json +5 -5
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as InputResolutionError, A as isPathColumn, B as emptyCounts, Ct as registerFreshImportHook, D as DEFAULT_QUERY_TIMEOUT_MS, F as DatasetNotFoundError, G as parseBinding, H as evalProblems, I as DatasetValidationError, J as primitiveBase, K as parseCell, M as parseColumnSpecs, N as pathField, O as SqlQueryError, P as pathInstance, Q as portableDef, R as EvalRunRefusedError, S as VariationConflictError, T as EvalNotFoundError, U as InvalidCellError, V as CheckScopeTraceSink, W as fitsPrimitiveBase, X as fieldsForPrompt, Y as PRIMITIVE_FIELD_TYPES, Z as isPrimitiveFieldType, a as CloudTraceProvider, b as rollupSpans, c as LocalEvalProvider, ct as instanceNames, et as runPrompt, f as LocalDirectoryDatasetProvider, j as parseColumnPath, k as InvalidColumnPathError, o as WorkspaceSync, q as parseResources, t as LocalDatabaseTraceProvider, wt as registerBundlerResolutionFallback, x as datasetQueryColumns, xt as registerVariationLoaderHook, y as mkdirSelfIgnoring, yt as LocalFileProvider, z as EvalRunner } from "../local-database-trace-provider-
|
|
1
|
+
import { $ as InputResolutionError, A as isPathColumn, B as emptyCounts, Ct as registerFreshImportHook, D as DEFAULT_QUERY_TIMEOUT_MS, F as DatasetNotFoundError, G as parseBinding, H as evalProblems, I as DatasetValidationError, J as primitiveBase, K as parseCell, M as parseColumnSpecs, N as pathField, O as SqlQueryError, P as pathInstance, Q as portableDef, R as EvalRunRefusedError, S as VariationConflictError, T as EvalNotFoundError, U as InvalidCellError, V as CheckScopeTraceSink, W as fitsPrimitiveBase, X as fieldsForPrompt, Y as PRIMITIVE_FIELD_TYPES, Z as isPrimitiveFieldType, a as CloudTraceProvider, b as rollupSpans, c as LocalEvalProvider, ct as instanceNames, et as runPrompt, f as LocalDirectoryDatasetProvider, j as parseColumnPath, k as InvalidColumnPathError, o as WorkspaceSync, q as parseResources, t as LocalDatabaseTraceProvider, wt as registerBundlerResolutionFallback, x as datasetQueryColumns, xt as registerVariationLoaderHook, y as mkdirSelfIgnoring, yt as LocalFileProvider, z as EvalRunner } from "../local-database-trace-provider-BHe2hLFA.js";
|
|
2
2
|
import { r as builtinCheckInfos } from "../checks-Cq97JU-h.js";
|
|
3
|
-
import { d as isPromptStyle, n as OtlpTraceIngestor, t as TraceEventIngestor, u as isNonEmptyStringArray } from "../trace-event-ingestor-
|
|
4
|
-
import { n as handleTraceEvents, r as handleOtlpTraces, t as CostFetchingTraceSink } from "../cost-fetching-trace-sink-
|
|
3
|
+
import { d as isPromptStyle, n as OtlpTraceIngestor, t as TraceEventIngestor, u as isNonEmptyStringArray } from "../trace-event-ingestor-fjlL_FYB.js";
|
|
4
|
+
import { n as handleTraceEvents, r as handleOtlpTraces, t as CostFetchingTraceSink } from "../cost-fetching-trace-sink-BEqbMdt1.js";
|
|
5
5
|
import module, { builtinModules } from "node:module";
|
|
6
6
|
import path, { join, resolve } from "node:path";
|
|
7
7
|
import net from "node:net";
|
|
@@ -29,7 +29,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
|
29
29
|
import { execFile, spawn } from "node:child_process";
|
|
30
30
|
import { promisify } from "node:util";
|
|
31
31
|
//#region package.json
|
|
32
|
-
var version = "2.0.
|
|
32
|
+
var version = "2.0.4";
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/shared/links.ts
|
|
35
35
|
/**
|
|
@@ -5245,6 +5245,21 @@ function linkedCloudClient(config, { env = process.env } = {}) {
|
|
|
5245
5245
|
hasPersonalApiKey: true
|
|
5246
5246
|
};
|
|
5247
5247
|
}
|
|
5248
|
+
/**
|
|
5249
|
+
* What to tell someone whose project is linked but who has no personal key in
|
|
5250
|
+
* `EVALUTION_API_KEY` to sync it with; `undefined` otherwise.
|
|
5251
|
+
*/
|
|
5252
|
+
function apiKeyNotice(config, { env = process.env } = {}) {
|
|
5253
|
+
const project = config.cloud?.project;
|
|
5254
|
+
const apiKey = env.EVALUTION_API_KEY;
|
|
5255
|
+
if (!project) return void 0;
|
|
5256
|
+
const howToFix = `To sync it with Evalution Cloud, create a personal API key at ${API_KEYS_URL} and set it as EVALUTION_API_KEY, in your shell or the project's .env.`;
|
|
5257
|
+
const linked = `This project is linked to Evalution Cloud (${project}) in .evalution/config.ts`;
|
|
5258
|
+
if (!apiKey) return `💡 ${linked}, but EVALUTION_API_KEY isn't set. ${howToFix}`;
|
|
5259
|
+
const kind = apiKeyKind(apiKey);
|
|
5260
|
+
if (kind === "personal") return void 0;
|
|
5261
|
+
return `💡 ${linked}, but EVALUTION_API_KEY ${kind === "ingest" ? "is an ingest key, which can only send traces" : "isn't an Evalution API key"}. ${howToFix}`;
|
|
5262
|
+
}
|
|
5248
5263
|
/** Whether `url` is on this machine, which is all the cloud will send a browser to. */
|
|
5249
5264
|
function isLoopbackUrl(url) {
|
|
5250
5265
|
if (!URL.canParse(url)) return false;
|
|
@@ -5269,9 +5284,20 @@ function instanceRegistration({ rootDir, localUrl, portkit, hostname = os.hostna
|
|
|
5269
5284
|
};
|
|
5270
5285
|
}
|
|
5271
5286
|
/**
|
|
5287
|
+
* Whether portkit starts this instance on demand, so its portkit URL works
|
|
5288
|
+
* after this process exits: the next visit starts it again.
|
|
5289
|
+
*/
|
|
5290
|
+
function restartedByPortkit(registration) {
|
|
5291
|
+
return !!registration.portkitUrl && registration.portkitMode === "on_demand";
|
|
5292
|
+
}
|
|
5293
|
+
/**
|
|
5272
5294
|
* Registers this instance and keeps it registered, with a heartbeat. Nothing
|
|
5273
5295
|
* here can stop the playground starting: a failure is reported, and retried
|
|
5274
5296
|
* on the next beat unless retrying can't help.
|
|
5297
|
+
*
|
|
5298
|
+
* An instance portkit starts on demand is registered once and then left be:
|
|
5299
|
+
* its portkit URL stays good after it exits, so there's nothing for a
|
|
5300
|
+
* heartbeat to say, and its session isn't ended on exit.
|
|
5275
5301
|
*/
|
|
5276
5302
|
function connectInstance(client, registration, { project, intervalMs = HEARTBEAT_INTERVAL_MS, log = console }) {
|
|
5277
5303
|
let id;
|
|
@@ -5294,10 +5320,12 @@ function connectInstance(client, registration, { project, intervalMs = HEARTBEAT
|
|
|
5294
5320
|
projectUrl = registered.projectUrl;
|
|
5295
5321
|
openUrl = registered.openUrl;
|
|
5296
5322
|
};
|
|
5323
|
+
const persistent = restartedByPortkit(registration);
|
|
5297
5324
|
const tick = async () => {
|
|
5298
5325
|
try {
|
|
5299
5326
|
await beat();
|
|
5300
5327
|
warned = false;
|
|
5328
|
+
if (persistent) stopped = true;
|
|
5301
5329
|
} catch (err) {
|
|
5302
5330
|
const status = err instanceof EvalutionApiError ? err.status : void 0;
|
|
5303
5331
|
if (status === 404) {
|
|
@@ -5333,7 +5361,7 @@ function connectInstance(client, registration, { project, intervalMs = HEARTBEAT
|
|
|
5333
5361
|
clearTimeout(timer);
|
|
5334
5362
|
const ending = (async () => {
|
|
5335
5363
|
await current;
|
|
5336
|
-
if (id) await client.endInstanceSession(id);
|
|
5364
|
+
if (id && !persistent) await client.endInstanceSession(id);
|
|
5337
5365
|
})().catch(() => {});
|
|
5338
5366
|
await Promise.race([ending, new Promise((resolve) => setTimeout(resolve, END_SESSION_TIMEOUT_MS).unref())]);
|
|
5339
5367
|
}
|
|
@@ -6226,6 +6254,10 @@ function startedOnDemand(adoption, env = process.env) {
|
|
|
6226
6254
|
* Registers the server with portkit if it's there, and resolves to where a
|
|
6227
6255
|
* proxy serves it: the one that started this process, or else the one that
|
|
6228
6256
|
* just adopted it. `undefined` when no proxy does.
|
|
6257
|
+
*
|
|
6258
|
+
* When portkit started this process, call it only once the server is
|
|
6259
|
+
* listening: until then portkit refuses to merge into its own record, and the
|
|
6260
|
+
* mode is lost. {@link preparePortkit} sees to that.
|
|
6229
6261
|
*/
|
|
6230
6262
|
async function resolvePublicUrl(rootDir, port, options = {}) {
|
|
6231
6263
|
const { env = process.env } = options;
|
|
@@ -6236,6 +6268,51 @@ async function resolvePublicUrl(rootDir, port, options = {}) {
|
|
|
6236
6268
|
mode: adoption?.mode
|
|
6237
6269
|
} : void 0;
|
|
6238
6270
|
}
|
|
6271
|
+
/**
|
|
6272
|
+
* How long a server portkit started keeps asking it to merge the adoption:
|
|
6273
|
+
* portkit notices the server listening a moment after it does.
|
|
6274
|
+
*/
|
|
6275
|
+
const MERGE_RETRY_MS = 3e3;
|
|
6276
|
+
const MERGE_RETRY_INTERVAL_MS = 200;
|
|
6277
|
+
/**
|
|
6278
|
+
* Works out where a proxy will serve the server about to start on `port`.
|
|
6279
|
+
*
|
|
6280
|
+
* A proxy that started this process already said where in its environment,
|
|
6281
|
+
* so registering waits for {@link PortkitPlan.adoption}: portkit merges into
|
|
6282
|
+
* the record it started this process from only once it has seen the server
|
|
6283
|
+
* listening, so a refusal is retried for a moment. Otherwise portkit is asked
|
|
6284
|
+
* now, as only it knows the URL.
|
|
6285
|
+
*/
|
|
6286
|
+
async function preparePortkit(rootDir, port, options = {}) {
|
|
6287
|
+
const { env = process.env, sleep = (ms) => new Promise((r) => setTimeout(r, ms)) } = options;
|
|
6288
|
+
const proxied = env.PORTKIT_URL ?? env.PORTLESS_URL;
|
|
6289
|
+
if (!proxied) {
|
|
6290
|
+
const adoption = await resolvePublicUrl(rootDir, port, options);
|
|
6291
|
+
return {
|
|
6292
|
+
publicUrl: adoption?.url,
|
|
6293
|
+
adoption: async () => adoption
|
|
6294
|
+
};
|
|
6295
|
+
}
|
|
6296
|
+
const adoptOnceSeen = async () => {
|
|
6297
|
+
const attempts = env.PORTKIT_URL ? MERGE_RETRY_MS / MERGE_RETRY_INTERVAL_MS : 1;
|
|
6298
|
+
for (let i = 1;; i++) {
|
|
6299
|
+
const adoption = await adoptIntoPortkit(rootDir, port, options);
|
|
6300
|
+
if (adoption || i >= attempts) return {
|
|
6301
|
+
url: proxied,
|
|
6302
|
+
mode: adoption?.mode
|
|
6303
|
+
};
|
|
6304
|
+
await sleep(MERGE_RETRY_INTERVAL_MS);
|
|
6305
|
+
}
|
|
6306
|
+
};
|
|
6307
|
+
let adoption;
|
|
6308
|
+
return {
|
|
6309
|
+
publicUrl: proxied,
|
|
6310
|
+
adoption: () => {
|
|
6311
|
+
adoption ??= adoptOnceSeen();
|
|
6312
|
+
return adoption;
|
|
6313
|
+
}
|
|
6314
|
+
};
|
|
6315
|
+
}
|
|
6239
6316
|
//#endregion
|
|
6240
6317
|
//#region src/cli/project.ts
|
|
6241
6318
|
/**
|
|
@@ -6463,6 +6540,8 @@ const CLOUD_WAIT_MS = 2e3;
|
|
|
6463
6540
|
async function connectToCloud(rootDir, config, localUrl, portkit) {
|
|
6464
6541
|
const { client, hasPersonalApiKey } = linkedCloudClient(config);
|
|
6465
6542
|
if (!client && hasPersonalApiKey) console.log("💡 Run `evalution link` to link this project to Evalution Cloud.");
|
|
6543
|
+
const notice = apiKeyNotice(config);
|
|
6544
|
+
if (notice) console.log(notice);
|
|
6466
6545
|
const project = config.cloud?.project;
|
|
6467
6546
|
if (!client || !project) return void 0;
|
|
6468
6547
|
const registration = instanceRegistration({
|
|
@@ -6540,10 +6619,10 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
|
|
|
6540
6619
|
let port;
|
|
6541
6620
|
if (process.env.PORT) port = parseInt(process.env.PORT, 10);
|
|
6542
6621
|
else port = await findAvailablePort(3e3, host);
|
|
6543
|
-
const portkit = await
|
|
6544
|
-
const publicUrl = portkit
|
|
6622
|
+
const portkit = await preparePortkit(rootDir, port);
|
|
6623
|
+
const { publicUrl } = portkit;
|
|
6545
6624
|
const maybeOpen = async (url) => {
|
|
6546
|
-
if (process.env.EVALUTION_NO_OPEN || startedOnDemand(portkit)) return;
|
|
6625
|
+
if (process.env.EVALUTION_NO_OPEN || startedOnDemand(await portkit.adoption())) return;
|
|
6547
6626
|
await new Promise((r) => setTimeout(r, 250));
|
|
6548
6627
|
openBrowser(url);
|
|
6549
6628
|
};
|
|
@@ -6560,12 +6639,13 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
|
|
|
6560
6639
|
const config = await loadConfig(rootDir);
|
|
6561
6640
|
const handle = await startConfiguredServer(rootDir, config, true, serverOptions);
|
|
6562
6641
|
await writeServerInfo(rootDir, handle.url, "ui");
|
|
6563
|
-
cloud = await connectToCloud(rootDir, config, handle.url, portkit);
|
|
6642
|
+
cloud = await connectToCloud(rootDir, config, handle.url, await portkit.adoption());
|
|
6564
6643
|
await maybeOpen(cloud?.openUrl ?? handle.publicUrl);
|
|
6565
6644
|
return;
|
|
6566
6645
|
}
|
|
6567
6646
|
let server = await startConfiguredServer(rootDir, {}, false, serverOptions);
|
|
6568
6647
|
await writeServerInfo(rootDir, server.url, "ui");
|
|
6648
|
+
await portkit.adoption();
|
|
6569
6649
|
await maybeOpen(server.publicUrl);
|
|
6570
6650
|
console.log(`👀 No config found; watching ${path.join(rootDir, ".evalution", "config.ts")} for creation...`);
|
|
6571
6651
|
const stopWatching = watchForConfigCreation(rootDir, async () => {
|
|
@@ -6574,7 +6654,7 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
|
|
|
6574
6654
|
stopWatching();
|
|
6575
6655
|
await server.close();
|
|
6576
6656
|
server = await startConfiguredServer(rootDir, config, true, serverOptions);
|
|
6577
|
-
cloud = await connectToCloud(rootDir, config, server.url, portkit);
|
|
6657
|
+
cloud = await connectToCloud(rootDir, config, server.url, await portkit.adoption());
|
|
6578
6658
|
});
|
|
6579
6659
|
}
|
|
6580
6660
|
main().catch((error) => {
|