evalution 2.0.3 → 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 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-87-WGqfS.js";
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-B1DYEg2H.js";
4
- import { n as handleTraceEvents, r as handleOtlpTraces, t as CostFetchingTraceSink } from "../cost-fetching-trace-sink-Dz8gniQ6.js";
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.3";
32
+ var version = "2.0.4";
33
33
  //#endregion
34
34
  //#region src/shared/links.ts
35
35
  /**
@@ -6254,6 +6254,10 @@ function startedOnDemand(adoption, env = process.env) {
6254
6254
  * Registers the server with portkit if it's there, and resolves to where a
6255
6255
  * proxy serves it: the one that started this process, or else the one that
6256
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.
6257
6261
  */
6258
6262
  async function resolvePublicUrl(rootDir, port, options = {}) {
6259
6263
  const { env = process.env } = options;
@@ -6264,6 +6268,51 @@ async function resolvePublicUrl(rootDir, port, options = {}) {
6264
6268
  mode: adoption?.mode
6265
6269
  } : void 0;
6266
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
+ }
6267
6316
  //#endregion
6268
6317
  //#region src/cli/project.ts
6269
6318
  /**
@@ -6570,10 +6619,10 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
6570
6619
  let port;
6571
6620
  if (process.env.PORT) port = parseInt(process.env.PORT, 10);
6572
6621
  else port = await findAvailablePort(3e3, host);
6573
- const portkit = await resolvePublicUrl(rootDir, port);
6574
- const publicUrl = portkit?.url;
6622
+ const portkit = await preparePortkit(rootDir, port);
6623
+ const { publicUrl } = portkit;
6575
6624
  const maybeOpen = async (url) => {
6576
- if (process.env.EVALUTION_NO_OPEN || startedOnDemand(portkit)) return;
6625
+ if (process.env.EVALUTION_NO_OPEN || startedOnDemand(await portkit.adoption())) return;
6577
6626
  await new Promise((r) => setTimeout(r, 250));
6578
6627
  openBrowser(url);
6579
6628
  };
@@ -6590,12 +6639,13 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
6590
6639
  const config = await loadConfig(rootDir);
6591
6640
  const handle = await startConfiguredServer(rootDir, config, true, serverOptions);
6592
6641
  await writeServerInfo(rootDir, handle.url, "ui");
6593
- cloud = await connectToCloud(rootDir, config, handle.url, portkit);
6642
+ cloud = await connectToCloud(rootDir, config, handle.url, await portkit.adoption());
6594
6643
  await maybeOpen(cloud?.openUrl ?? handle.publicUrl);
6595
6644
  return;
6596
6645
  }
6597
6646
  let server = await startConfiguredServer(rootDir, {}, false, serverOptions);
6598
6647
  await writeServerInfo(rootDir, server.url, "ui");
6648
+ await portkit.adoption();
6599
6649
  await maybeOpen(server.publicUrl);
6600
6650
  console.log(`👀 No config found; watching ${path.join(rootDir, ".evalution", "config.ts")} for creation...`);
6601
6651
  const stopWatching = watchForConfigCreation(rootDir, async () => {
@@ -6604,7 +6654,7 @@ async function ui(rootDir, hasConfig, host, attempt = 0) {
6604
6654
  stopWatching();
6605
6655
  await server.close();
6606
6656
  server = await startConfiguredServer(rootDir, config, true, serverOptions);
6607
- cloud = await connectToCloud(rootDir, config, server.url, portkit);
6657
+ cloud = await connectToCloud(rootDir, config, server.url, await portkit.adoption());
6608
6658
  });
6609
6659
  }
6610
6660
  main().catch((error) => {