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.
Files changed (30) hide show
  1. package/LICENSING.md +26 -44
  2. package/README.md +11 -11
  3. package/dist/{check-CR4fU1S5.d.ts → check-BKU5_IhU.d.ts} +18 -868
  4. package/dist/checks/index.d.ts +2 -1
  5. package/dist/cli/index.js +809 -372
  6. package/dist/client/assets/{DatasetView-BqSWI_pm.js → DatasetView-DZ2uLHKV.js} +12 -10
  7. package/dist/client/assets/{EvalRunView-CR6ZksSu.js → EvalRunView-T610dLVw.js} +1 -1
  8. package/dist/client/assets/{EvalView-JPEM5IY8.js → EvalView-Cae68vPB.js} +1 -1
  9. package/dist/client/assets/{data-grid-overlay-editor-B_nPhXKR.js → data-grid-overlay-editor-PtH7A6E4.js} +1 -1
  10. package/dist/client/assets/{highlighted-body-KPVGNVTW-dPpneB8R.js → highlighted-body-KPVGNVTW-CPtwvSJb.js} +1 -1
  11. package/dist/client/assets/{index-CwjMcK6S.js → index-BFH07Ynk.js} +147 -147
  12. package/dist/client/assets/index-KCv8AeiY.css +32 -0
  13. package/dist/client/assets/{number-overlay-editor-CRWFlaQs.js → number-overlay-editor-BbQhagHP.js} +1 -1
  14. package/dist/client/index.html +2 -2
  15. package/dist/cost-fetching-trace-sink-Dz8gniQ6.js +262 -0
  16. package/dist/{dataset-types-Dqi5vVg-.d.ts → dataset-types-D-Fsbg8B.d.ts} +7 -247
  17. package/dist/index.d.ts +844 -1426
  18. package/dist/index.js +151 -480
  19. package/dist/ingest.d.ts +119 -0
  20. package/dist/ingest.js +3 -0
  21. package/dist/{trace-event-ingestor-BghQcCHe.js → local-database-trace-provider-87-WGqfS.js} +1976 -7362
  22. package/dist/{trace-DGj5oW7z.d.ts → trace-BLjFYF9G.d.ts} +2 -1
  23. package/dist/trace-event-ingestor-B1DYEg2H.js +798 -0
  24. package/dist/trace-event-ingestor-JNpe-OrX.d.ts +109 -0
  25. package/dist/views/datasets/index.d.ts +1 -1
  26. package/dist/views/index.d.ts +3 -2
  27. package/dist/views/index.js +0 -4
  28. package/dist/views/react/index.d.ts +1 -1
  29. package/package.json +32 -30
  30. package/dist/client/assets/index-BGcZZetP.css +0 -32
package/dist/index.js CHANGED
@@ -1,17 +1,20 @@
1
- import { $t as SPAN_KIND_ATTRIBUTE, A as DEFAULT_QUERY_TIMEOUT_MS, B as DEFAULT_EVAL_CONCURRENCY, Bt as SERVICE_NAME_ATTRIBUTE, C as VariationConflictError, Ct as VercelAISDKTelemetry, D as normalizeOtlpRequest, Dt as OTelTraceIngestor, E as decodeOtlpProtobuf, Et as setupGlobalOTelPipeline, Ft as BaseTraceIngestor, Gt as isMissingPackage, H as EvalRunner, Ht as spanMessages, It as PLAYGROUND_RESOURCE, Jt as PROMPT_INPUTS_ATTRIBUTE, Kt as missingPackageMessage, Lt as CHECK_ATTRIBUTE, Mt as TypeSafeSDK, Nt as PROMPT_IDENTITY, O as EvalNotFoundError, Ot as isEditable, Pt as TypeSafeTelemetry, Qt as PROMPT_VERSION_ATTRIBUTE, R as DatasetNotFoundError, Rt as DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, St as resource, T as toPromptRef, Tt as TRACE_EVENTS_PATH, Ut as assertUpdateStyle, V as EvalRunRefusedError, Vt as isCheckSpan, Wt as findPackageDts, Xt as PROMPT_PROVIDER_ID_ATTRIBUTE, Yt as PROMPT_NAME_ATTRIBUTE, Zt as PROMPT_VARIATION_ATTRIBUTE, _ as runMigrations, _t as resourceParameterNames, a as mergeSpans, an as LocalFileProvider, at as resolveExecutionInput, b as mkdirSelfIgnoring, bt as isResource, c as TRACE_QUERY_SCHEMA, cn as isFreshImportHookRegistered, ct as collectInputSlots, d as TursoEvalProvider, en as createTracerForPrompt, f as runEvalMigrations, ft as namedBindings, g as MIGRATIONS_TABLE, gt as parameterDetails, h as runDatasetMigrations, ht as ResourceRegistry, i as TursoTraceProvider, it as matchSourcesToSlots, j as SqlQueryError, jt as shortId, k as DEFAULT_MAX_QUERY_ROWS, l as LocalEvalProvider, ln as registerFreshImportHook, lt as findInputCycle, m as TursoDatasetProvider, mt as DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, n as OtlpTraceIngestor, nn as mergePromptIdentity, o as BaseTraceProvider, on as isVariationLoaderHookRegistered, ot as resolveExecutionInputs, p as LocalDirectoryDatasetProvider, pt as DEFAULT_PLAYGROUND_IGNORE_PATTERNS, qt as PROMPT_ID_ATTRIBUTE, r as LocalDatabaseTraceProvider, sn as registerVariationLoaderHook, st as stampReceipts, t as TraceEventIngestor, tn as getPromptSpanAttributes, u as openLocalEvalProvider, ut as inputReferenceProblems, v as assertSqliteFile, vt as isValidInstanceName, w as promptIdOf, wt as HttpTraceSink, x as rollupSpans, xt as isStandardSchema, y as createLocalTursoClient, yt as VercelAISDK, z as DatasetValidationError, zt as PLAYGROUND_ENVIRONMENT } from "./trace-event-ingestor-BghQcCHe.js";
1
+ import { C as promptIdOf, Ct as registerFreshImportHook, D as DEFAULT_QUERY_TIMEOUT_MS, E as DEFAULT_MAX_QUERY_ROWS, F as DatasetNotFoundError, I as DatasetValidationError, L as DEFAULT_EVAL_CONCURRENCY, O as SqlQueryError, R as EvalRunRefusedError, S as VariationConflictError, St as isFreshImportHookRegistered, T as EvalNotFoundError, _ as assertSqliteFile, _t as isStandardSchema, a as CloudTraceProvider, at as collectInputSlots, b as rollupSpans, bt as isVariationLoaderHookRegistered, c as LocalEvalProvider, d as runEvalMigrations, dt as DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, f as LocalDirectoryDatasetProvider, ft as ResourceRegistry, g as runMigrations, gt as isResource, h as MIGRATIONS_TABLE, ht as isValidInstanceName, i as BaseTraceProvider, it as stampReceipts, l as openLocalEvalProvider, lt as namedBindings, m as runDatasetMigrations, mt as resourceParameterNames, n as TursoTraceProvider, nt as resolveExecutionInput, o as WorkspaceSync, ot as findInputCycle, p as TursoDatasetProvider, pt as parameterDetails, r as TRACE_QUERY_SCHEMA, rt as resolveExecutionInputs, s as DatabaseSync, st as inputReferenceProblems, t as LocalDatabaseTraceProvider, tt as matchSourcesToSlots, u as TursoEvalProvider, ut as DEFAULT_PLAYGROUND_IGNORE_PATTERNS, v as createLocalTursoClient, vt as resource, w as toPromptRef, xt as registerVariationLoaderHook, y as mkdirSelfIgnoring, yt as LocalFileProvider, z as EvalRunner } from "./local-database-trace-provider-87-WGqfS.js";
2
2
  import { _ as isCheck, g as check, n as builtinCheck, r as builtinCheckInfos } from "./checks-Cq97JU-h.js";
3
+ import { a as readKind, c as normalizeOtlpRequest, f as shortId, i as mapStatus, l as isEditable, n as OtlpTraceIngestor, o as mergeSpans, r as llmAndPrompt, s as decodeOtlpProtobuf, t as TraceEventIngestor } from "./trace-event-ingestor-B1DYEg2H.js";
3
4
  import "node:module";
4
5
  import path, { dirname } from "node:path";
5
6
  import { access, realpath } from "node:fs/promises";
6
7
  import { minimatch } from "minimatch";
7
- import fs$1 from "node:fs";
8
8
  import { createHash } from "node:crypto";
9
- import { addProperty, buildPropTypeFromType, extractPropertiesFromDeclaration, extractPropertiesFromObjectLiteral, extractPropertiesFromParameters, findTypeDeclaration, isOpaqueType, removeProperty, resolveBindings, updateProperty, valueToSourceText } from "ts-proppy";
9
+ import { SpanStatusCode } from "@opentelemetry/api";
10
+ import { addProperty, buildPropTypeFromType, extractPropertiesFromObjectLiteral, extractPropertiesFromParameters, isOpaqueType, removeProperty, resolveBindings, updateProperty } from "ts-proppy";
11
+ import { BaseTraceIngestor, BaseTraceIngestor as BaseTraceIngestor$1, CHECK_ATTRIBUTE, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, Evalution, HttpTraceSink, PLAYGROUND_ENVIRONMENT, PLAYGROUND_RESOURCE, PROMPT_ID_ATTRIBUTE, PROMPT_INPUTS_ATTRIBUTE, PROMPT_NAME_ATTRIBUTE, PROMPT_PROVIDER_ID_ATTRIBUTE, PROMPT_VARIATION_ATTRIBUTE, PROMPT_VERSION_ATTRIBUTE, SERVICE_NAME_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, TRACE_EVENTS_PATH, createTracerForPrompt, filterTraces, getPromptSpanAttributes, isCheckSpan, mergePromptIdentity, spanMessages } from "@evalution/sdk";
10
12
  import ts from "typescript";
11
13
  import { spawn } from "node:child_process";
12
14
  import { drizzle } from "drizzle-orm/tursodatabase-sync";
13
15
  import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
14
16
  import { integer, primaryKey, real, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
17
+ import { assertUpdateStyle } from "@evalution/sdk/adapter";
15
18
  //#region \0rolldown/runtime.js
16
19
  var __defProp = Object.defineProperty;
17
20
  var __exportAll = (all, no_symbols) => {
@@ -168,6 +171,125 @@ var OverlayFileProvider = class {
168
171
  }
169
172
  };
170
173
  //#endregion
174
+ //#region src/trace/otel-trace-ingestor.ts
175
+ function hrTimeToMs(time) {
176
+ return time[0] * 1e3 + time[1] / 1e6;
177
+ }
178
+ /** `span`'s resource attributes as a {@link Span.resource}, if it has any. */
179
+ function resourceOf(span) {
180
+ const attributes = span.resource?.attributes;
181
+ return attributes && Object.keys(attributes).length > 0 ? { resource: { ...attributes } } : {};
182
+ }
183
+ /**
184
+ * {@link TraceIngestor} populated by OpenTelemetry spans. Register the
185
+ * processor returned by {@link getSpanProcessor} on a `BasicTracerProvider`
186
+ * (from `@opentelemetry/sdk-trace-base`).
187
+ *
188
+ * Because OpenTelemetry is a single process-global pipeline, at most one
189
+ * `OTelTraceIngestor` should be active per server — {@link isRedundant}
190
+ * reports any other instance redundant so server wiring can consolidate.
191
+ */
192
+ var OTelTraceIngestor = class OTelTraceIngestor extends BaseTraceIngestor$1 {
193
+ spanPromises = /* @__PURE__ */ new Map();
194
+ isRedundant(other) {
195
+ return other instanceof OTelTraceIngestor;
196
+ }
197
+ /**
198
+ * Returns a `SpanProcessor` that funnels every OpenTelemetry span the
199
+ * caller's tracer produces into this ingestor's sinks.
200
+ */
201
+ getSpanProcessor() {
202
+ return {
203
+ onStart: (span) => {
204
+ const spanId = span.spanContext().spanId;
205
+ const p = this.handleStart(span).catch(console.error);
206
+ this.spanPromises.set(spanId, p);
207
+ p.finally(() => this.spanPromises.delete(spanId));
208
+ },
209
+ onEnd: (span) => {
210
+ const spanId = span.spanContext().spanId;
211
+ const p = (this.spanPromises.get(spanId) ?? Promise.resolve()).then(() => this.handleEnd(span)).catch(console.error);
212
+ this.spanPromises.set(spanId, p);
213
+ p.finally(() => this.spanPromises.delete(spanId));
214
+ },
215
+ forceFlush: async () => {},
216
+ shutdown: async () => {}
217
+ };
218
+ }
219
+ async handleStart(span) {
220
+ const ctx = span.spanContext();
221
+ const traceId = ctx.traceId;
222
+ const spanId = ctx.spanId;
223
+ const parentCtx = span.parentSpanContext;
224
+ const ourSpan = {
225
+ id: spanId,
226
+ traceId,
227
+ parentId: parentCtx && parentCtx.traceId === traceId ? parentCtx.spanId : void 0,
228
+ name: span.name,
229
+ kind: readKind(span.attributes),
230
+ startTime: hrTimeToMs(span.startTime),
231
+ attributes: { ...span.attributes },
232
+ ...resourceOf(span),
233
+ ...llmAndPrompt(span.attributes)
234
+ };
235
+ await this.recordSpanStart(ourSpan);
236
+ }
237
+ async handleEnd(span) {
238
+ const ctx = span.spanContext();
239
+ const traceId = ctx.traceId;
240
+ const ended = {
241
+ id: ctx.spanId,
242
+ traceId,
243
+ parentId: span.parentSpanContext && span.parentSpanContext.traceId === traceId ? span.parentSpanContext.spanId : void 0,
244
+ name: span.name,
245
+ kind: readKind(span.attributes),
246
+ startTime: hrTimeToMs(span.startTime),
247
+ endTime: hrTimeToMs(span.endTime),
248
+ status: mapStatus(span.status),
249
+ errorMessage: span.status.code === SpanStatusCode.ERROR ? span.status.message : void 0,
250
+ attributes: { ...span.attributes },
251
+ ...resourceOf(span),
252
+ ...llmAndPrompt(span.attributes)
253
+ };
254
+ await this.recordSpanEnd(ended);
255
+ }
256
+ /**
257
+ * Waits for every in-flight `onStart`/`onEnd` handler to settle. Used by
258
+ * tests to deterministically assert on the resulting trace store.
259
+ */
260
+ async drainPendingHandlers() {
261
+ while (this.spanPromises.size > 0) await Promise.all([...this.spanPromises.values()]);
262
+ }
263
+ };
264
+ //#endregion
265
+ //#region src/trace/otel-global-pipeline.ts
266
+ let globalOTelPipeline;
267
+ /**
268
+ * Stands up the process-global OpenTelemetry tracer provider and
269
+ * `AsyncLocalStorageContextManager`, if not already done, and returns the
270
+ * {@link OTelTraceIngestor} feeding it.
271
+ *
272
+ * Safe to call from multiple SDK adapters: the underlying setup runs at most
273
+ * once per process, and every caller is resolved with the same ingestor
274
+ * instance.
275
+ */
276
+ function setupGlobalOTelPipeline() {
277
+ globalOTelPipeline ??= doSetup();
278
+ return globalOTelPipeline;
279
+ }
280
+ async function doSetup() {
281
+ const { context, trace } = await import("@opentelemetry/api");
282
+ const { AsyncLocalStorageContextManager } = await import("@opentelemetry/context-async-hooks");
283
+ const { BasicTracerProvider } = await import("@opentelemetry/sdk-trace-base");
284
+ const ingestor = new OTelTraceIngestor();
285
+ const tracerProvider = new BasicTracerProvider({ spanProcessors: [ingestor.getSpanProcessor()] });
286
+ trace.setGlobalTracerProvider(tracerProvider);
287
+ const contextManager = new AsyncLocalStorageContextManager();
288
+ contextManager.enable();
289
+ context.setGlobalContextManager(contextManager);
290
+ return ingestor;
291
+ }
292
+ //#endregion
171
293
  //#region src/prompt/variations/canonical-updates.ts
172
294
  /** Prefix of a per-parameter field name, e.g. `modelParameters.temperature`. */
173
295
  const MODEL_PARAMETER_PREFIX = "modelParameters.";
@@ -1454,10 +1576,25 @@ const FALLBACK_OPTIONS = {
1454
1576
  };
1455
1577
  /** Parsed declaration files that are stable for the lifetime of the process. */
1456
1578
  const immutableSourceFiles = /* @__PURE__ */ new Map();
1457
- const TS_LIB_DIR = path.dirname(ts.getDefaultLibFilePath({}));
1579
+ /**
1580
+ * Where TypeScript's own `lib.*.d.ts` files are, once asked for, or `null`
1581
+ * where TypeScript can't say. It can't outside Node, where it throws: this
1582
+ * module also runs in the marketing site's in-browser demo, so it isn't asked
1583
+ * at module scope.
1584
+ */
1585
+ let tsLibDir;
1586
+ function libDir() {
1587
+ if (tsLibDir === void 0) try {
1588
+ tsLibDir = path.dirname(ts.getDefaultLibFilePath({}));
1589
+ } catch {
1590
+ tsLibDir = null;
1591
+ }
1592
+ return tsLibDir;
1593
+ }
1458
1594
  /** Whether `fileName` names a file that will not change while we run. */
1459
1595
  function isImmutable(fileName) {
1460
- return fileName.startsWith(TS_LIB_DIR) || fileName.includes("/node_modules/");
1596
+ const lib = libDir();
1597
+ return lib !== null && fileName.startsWith(lib) || fileName.includes("/node_modules/");
1461
1598
  }
1462
1599
  /**
1463
1600
  * Load the compiler options from the nearest `tsconfig.json` at or above
@@ -1465,6 +1602,7 @@ function isImmutable(fileName) {
1465
1602
  * `moduleResolution` settings resolve the way they do for the user's own build.
1466
1603
  */
1467
1604
  function compilerOptionsFor(fromPath) {
1605
+ if (!ts.sys) return FALLBACK_OPTIONS;
1468
1606
  const configPath = ts.findConfigFile(path.dirname(fromPath), ts.sys.fileExists);
1469
1607
  if (!configPath) return FALLBACK_OPTIONS;
1470
1608
  const { config, error } = ts.readConfigFile(configPath, ts.sys.readFile);
@@ -2084,6 +2222,8 @@ function moduleFingerprint(rootDir, probes) {
2084
2222
  for (const module of probe.modules) specifiers.add(module);
2085
2223
  addImports(probe.produces);
2086
2224
  }
2225
+ const { sys } = ts;
2226
+ if (!sys) return "";
2087
2227
  const parts = [];
2088
2228
  for (const specifier of [...specifiers].sort()) {
2089
2229
  if (specifier.startsWith(".")) continue;
@@ -2092,8 +2232,8 @@ function moduleFingerprint(rootDir, probes) {
2092
2232
  let found = "missing";
2093
2233
  for (let dir = rootDir;; dir = path.dirname(dir)) {
2094
2234
  const manifest = path.join(dir, "node_modules", pkg, "package.json");
2095
- if (ts.sys.fileExists(manifest)) {
2096
- found = `${manifest}@${ts.sys.getModifiedTime?.(manifest)?.getTime() ?? 0}`;
2235
+ if (sys.fileExists(manifest)) {
2236
+ found = `${manifest}@${sys.getModifiedTime?.(manifest)?.getTime() ?? 0}`;
2097
2237
  break;
2098
2238
  }
2099
2239
  if (path.dirname(dir) === dir) break;
@@ -3145,7 +3285,7 @@ var FilePromptProvider = class {
3145
3285
  }
3146
3286
  }
3147
3287
  async setupTraceIngestion() {
3148
- return this.sdkAdapter.setupTraceIngestion?.();
3288
+ return this.sdkAdapter.setupTraceIngestion?.({ setupGlobalOTelPipeline });
3149
3289
  }
3150
3290
  async renamePrompt(promptId, newName) {
3151
3291
  const [filePath, oldName] = this.parsePromptId(promptId);
@@ -3835,475 +3975,6 @@ var GitVersioning = class GitVersioning {
3835
3975
  }
3836
3976
  };
3837
3977
  //#endregion
3838
- //#region src/sdk/gemini-interactions-sdk.ts
3839
- const MODEL_KEY = "model";
3840
- const AGENT_KEY = "agent";
3841
- const SYSTEM_KEY = "system_instruction";
3842
- const INPUT_KEY = "input";
3843
- const GENERATION_CONFIG_KEY = "generation_config";
3844
- const AGENT_CONFIG_KEY = "agent_config";
3845
- const FALLBACK_GENERATION_CONFIG_PARAMS = [
3846
- {
3847
- name: "temperature",
3848
- description: "Controls the randomness of the output.",
3849
- type: {
3850
- kind: "primitive",
3851
- syntax: "number"
3852
- },
3853
- optional: true
3854
- },
3855
- {
3856
- name: "top_p",
3857
- description: "The maximum cumulative probability of tokens to consider when sampling.",
3858
- type: {
3859
- kind: "primitive",
3860
- syntax: "number"
3861
- },
3862
- optional: true
3863
- },
3864
- {
3865
- name: "max_output_tokens",
3866
- description: "The maximum number of tokens to include in the response.",
3867
- type: {
3868
- kind: "primitive",
3869
- syntax: "number"
3870
- },
3871
- optional: true
3872
- },
3873
- {
3874
- name: "seed",
3875
- description: "Seed used in decoding for reproducibility.",
3876
- type: {
3877
- kind: "primitive",
3878
- syntax: "number"
3879
- },
3880
- optional: true
3881
- },
3882
- {
3883
- name: "stop_sequences",
3884
- description: "A list of character sequences that will stop output interaction.",
3885
- type: {
3886
- kind: "array",
3887
- syntax: "string[]",
3888
- element: {
3889
- name: "",
3890
- type: {
3891
- kind: "primitive",
3892
- syntax: "string"
3893
- },
3894
- optional: false
3895
- }
3896
- },
3897
- optional: true
3898
- },
3899
- {
3900
- name: "thinking_level",
3901
- description: "The level of thought tokens that the model should generate.",
3902
- type: {
3903
- kind: "union",
3904
- syntax: "'minimal' | 'low' | 'medium' | 'high'",
3905
- types: [
3906
- {
3907
- kind: "constant",
3908
- syntax: "'minimal'",
3909
- value: "minimal"
3910
- },
3911
- {
3912
- kind: "constant",
3913
- syntax: "'low'",
3914
- value: "low"
3915
- },
3916
- {
3917
- kind: "constant",
3918
- syntax: "'medium'",
3919
- value: "medium"
3920
- },
3921
- {
3922
- kind: "constant",
3923
- syntax: "'high'",
3924
- value: "high"
3925
- }
3926
- ]
3927
- },
3928
- optional: true
3929
- },
3930
- {
3931
- name: "thinking_summaries",
3932
- description: "Whether to include thought summaries in the response.",
3933
- type: {
3934
- kind: "union",
3935
- syntax: "'auto' | 'none'",
3936
- types: [{
3937
- kind: "constant",
3938
- syntax: "'auto'",
3939
- value: "auto"
3940
- }, {
3941
- kind: "constant",
3942
- syntax: "'none'",
3943
- value: "none"
3944
- }]
3945
- },
3946
- optional: true
3947
- }
3948
- ];
3949
- /**
3950
- * The models `interactions.create` accepts — a subset of the full Gemini
3951
- * lineup. See https://ai.google.dev/gemini-api/docs/interactions
3952
- */
3953
- const CURATED_MODELS = [
3954
- {
3955
- label: "Gemini 3.8 Flash",
3956
- id: "gemini-3.8-flash"
3957
- },
3958
- {
3959
- label: "Gemini 3.7 Flash",
3960
- id: "gemini-3.7-flash"
3961
- },
3962
- {
3963
- label: "Gemini 3.6 Flash",
3964
- id: "gemini-3.6-flash"
3965
- },
3966
- {
3967
- label: "Gemini 3.5 Flash",
3968
- id: "gemini-3.5-flash"
3969
- },
3970
- {
3971
- label: "Gemini 3.5 Flash-Lite",
3972
- id: "gemini-3.5-flash-lite"
3973
- },
3974
- {
3975
- label: "Gemini 3.1 Pro Preview",
3976
- id: "gemini-3.1-pro-preview"
3977
- },
3978
- {
3979
- label: "Gemini 3.1 Flash-Lite",
3980
- id: "gemini-3.1-flash-lite"
3981
- },
3982
- {
3983
- label: "Gemini 3 Flash Preview",
3984
- id: "gemini-3-flash-preview"
3985
- },
3986
- {
3987
- label: "Gemini 2.5 Pro",
3988
- id: "gemini-2.5-pro"
3989
- },
3990
- {
3991
- label: "Gemini 2.5 Flash",
3992
- id: "gemini-2.5-flash"
3993
- },
3994
- {
3995
- label: "Gemini 2.5 Flash-Lite",
3996
- id: "gemini-2.5-flash-lite"
3997
- }
3998
- ];
3999
- /** The agents `interactions.create` accepts. */
4000
- const CURATED_AGENTS = [
4001
- {
4002
- label: "Deep Research Preview",
4003
- id: "deep-research-preview-04-2026"
4004
- },
4005
- {
4006
- label: "Deep Research Max Preview",
4007
- id: "deep-research-max-preview-04-2026"
4008
- },
4009
- {
4010
- label: "Antigravity Preview",
4011
- id: "antigravity-preview-09-2026"
4012
- }
4013
- ];
4014
- /** Each variant's own settings, which are invalid under the other. */
4015
- const VARIANT_CONFIG_KEY = {
4016
- model: GENERATION_CONFIG_KEY,
4017
- agent: AGENT_CONFIG_KEY
4018
- };
4019
- const STRING = {
4020
- kind: "primitive",
4021
- syntax: "string",
4022
- base: "string"
4023
- };
4024
- /** One variant's fragment of the config, `{ model: … }` or `{ agent: … }`. */
4025
- function variantType(key, idType = STRING) {
4026
- return {
4027
- kind: "object",
4028
- syntax: `{ ${key}: ${key === MODEL_KEY ? "Model" : "AgentOption"} }`,
4029
- properties: [{
4030
- name: key,
4031
- type: idType,
4032
- optional: false
4033
- }]
4034
- };
4035
- }
4036
- /** The model slot's type when it couldn't be resolved. */
4037
- const FALLBACK_MODEL_TYPE = {
4038
- kind: "union",
4039
- syntax: "{ model: Model } | { agent: AgentOption }",
4040
- types: [variantType(MODEL_KEY), variantType(AGENT_KEY)]
4041
- };
4042
- /** Probe name for the model slot's type, as reported in project results. */
4043
- const MODEL_PROBE = "model";
4044
- /**
4045
- * The model slot as a union of two config fragments: each variant's own ID
4046
- * key, read off the SDK's own request types.
4047
- */
4048
- const MODEL_PROJECT_PROBES = [{
4049
- kind: "type",
4050
- name: MODEL_PROBE,
4051
- expression: "Pick<import(\"@google/genai\").Interactions.CreateModelInteraction, \"model\"> | Pick<import(\"@google/genai\").Interactions.CreateAgentInteraction, \"agent\">",
4052
- syntax: "{ model: Model } | { agent: AgentOption }"
4053
- }];
4054
- /** The variant member of a resolved model type, by the key it carries. */
4055
- function memberFor(type, key) {
4056
- return (type.kind === "union" ? type.types : [type]).find((m) => m.kind === "object" && m.properties.some((p) => p.name === key)) ?? variantType(key);
4057
- }
4058
- function fragment(key, id) {
4059
- return {
4060
- kind: "object",
4061
- properties: { [key]: {
4062
- kind: "primitive",
4063
- value: id
4064
- } },
4065
- displayValue: id
4066
- };
4067
- }
4068
- /** Which variant a model fragment is, if it is one. */
4069
- function variantOf(value) {
4070
- if (value?.kind !== "object") return void 0;
4071
- if (MODEL_KEY in value.properties) return MODEL_KEY;
4072
- if (AGENT_KEY in value.properties) return AGENT_KEY;
4073
- }
4074
- /**
4075
- * {@link SDKAdapter} implementation for the Google GenAI
4076
- * [Interactions API](https://ai.google.dev/gemini-api/docs/interactions)
4077
- * (`@google/genai` package). Currently experimental and untested.
4078
- */
4079
- var GeminiInteractionsSDK = class {
4080
- promptsHelperImport = "FIXME";
4081
- getProjectProbes(language) {
4082
- return language === "typescript" ? MODEL_PROJECT_PROBES : [];
4083
- }
4084
- /**
4085
- * One model row whose value is an honest config fragment —
4086
- * `{ model: "gemini-3.5-flash" }` or `{ agent: "deep-research-…" }` —
4087
- * because `interactions.create` takes one or the other, never both. The
4088
- * **Models** and **Agents** catalogs each narrow their free-form entry to
4089
- * their own variant.
4090
- */
4091
- async getModelDefinition(project) {
4092
- const resolved = project[MODEL_PROBE];
4093
- const type = resolved && !Array.isArray(resolved) ? resolved.type : FALLBACK_MODEL_TYPE;
4094
- const catalog = (key, label, ids) => ({
4095
- label,
4096
- groups: [{
4097
- label: "Google",
4098
- icon: "Google",
4099
- presets: ids.map(({ label, id }) => ({
4100
- label,
4101
- value: fragment(key, id)
4102
- }))
4103
- }],
4104
- literal: {
4105
- name: "model",
4106
- type: memberFor(type, key),
4107
- optional: false
4108
- }
4109
- });
4110
- return {
4111
- name: "model",
4112
- type,
4113
- optional: false,
4114
- catalogs: [catalog(MODEL_KEY, "Models", CURATED_MODELS), catalog(AGENT_KEY, "Agents", CURATED_AGENTS)]
4115
- };
4116
- }
4117
- getModelParameters(rootDir) {
4118
- try {
4119
- const dtsPath = findPackageDts("@google/genai", "dist/genai.d.ts", rootDir);
4120
- if (dtsPath) {
4121
- const sourceText = fs$1.readFileSync(dtsPath, "utf-8");
4122
- const sourceFile = ts.createSourceFile(dtsPath, sourceText, ts.ScriptTarget.Latest, true);
4123
- const decl = findTypeDeclaration(sourceFile, "GenerationConfig_2");
4124
- if (decl) return extractPropertiesFromDeclaration(decl, sourceFile).definitions;
4125
- }
4126
- } catch {}
4127
- return FALLBACK_GENERATION_CONFIG_PARAMS;
4128
- }
4129
- async executeConfig(config) {
4130
- let GoogleGenAI;
4131
- try {
4132
- ({GoogleGenAI} = await import("@google/genai"));
4133
- } catch (err) {
4134
- if (!isMissingPackage(err, "@google/genai")) throw err;
4135
- throw new Error(missingPackageMessage("@google/genai"), { cause: err });
4136
- }
4137
- await new GoogleGenAI({}).interactions.create({
4138
- ...config,
4139
- store: false
4140
- });
4141
- }
4142
- normalizePrompt(prompt) {
4143
- const { definitions, values } = prompt.extractedProps;
4144
- const systemValue = values?.[SYSTEM_KEY];
4145
- const inputValue = values?.[INPUT_KEY];
4146
- const modelValue = values?.[MODEL_KEY];
4147
- const agentValue = values?.[AGENT_KEY];
4148
- const variant = !modelValue && agentValue ? AGENT_KEY : MODEL_KEY;
4149
- const idValue = variant === MODEL_KEY ? modelValue : agentValue;
4150
- const model = idValue && {
4151
- kind: "object",
4152
- properties: { [variant]: idValue },
4153
- displayValue: idValue.kind === "primitive" ? String(idValue.value) : valueToSourceText(idValue)
4154
- };
4155
- const configKey = VARIANT_CONFIG_KEY[variant];
4156
- const configDef = definitions.find((d) => d.name === configKey);
4157
- const configValue = values?.[configKey];
4158
- const configProps = configValue?.kind === "object" ? configValue.properties : {};
4159
- const modelParameters = (configDef?.type.kind === "object" ? configDef.type.properties : []).map((def) => ({
4160
- def,
4161
- value: configProps[def.name]
4162
- }));
4163
- return {
4164
- style: "chat",
4165
- id: prompt.id,
4166
- providerId: prompt.providerId,
4167
- name: prompt.name,
4168
- functionParameters: prompt.functionParameters,
4169
- metadata: prompt.metadata,
4170
- treePath: prompt.treePath,
4171
- model,
4172
- modelEditable: true,
4173
- system: systemValue,
4174
- systemEditable: true,
4175
- messages: extractMessages(inputValue),
4176
- messagesEditable: true,
4177
- modelParameters
4178
- };
4179
- }
4180
- denormalizeUpdates(updates, currentValues) {
4181
- assertUpdateStyle(updates, "chat");
4182
- const out = {};
4183
- const remove = (key) => {
4184
- if (currentValues && key in currentValues) out[key] = null;
4185
- };
4186
- const currentVariant = currentValues && MODEL_KEY in currentValues ? MODEL_KEY : currentValues && AGENT_KEY in currentValues ? AGENT_KEY : void 0;
4187
- let variant = currentVariant ?? MODEL_KEY;
4188
- if ("model" in updates) {
4189
- const next = variantOf(updates.model);
4190
- if (!next) {
4191
- remove(MODEL_KEY);
4192
- remove(AGENT_KEY);
4193
- } else if (updates.model?.kind === "object") {
4194
- const other = next === MODEL_KEY ? AGENT_KEY : MODEL_KEY;
4195
- out[next] = updates.model.properties[next];
4196
- remove(other);
4197
- if (currentVariant && currentVariant !== next) remove(VARIANT_CONFIG_KEY[other]);
4198
- variant = next;
4199
- }
4200
- }
4201
- if ("system" in updates) out[SYSTEM_KEY] = updates.system ?? null;
4202
- if ("messages" in updates) out[INPUT_KEY] = updates.messages == null ? null : messagesToValue(updates.messages);
4203
- if (updates.modelParameters) {
4204
- const configKey = VARIANT_CONFIG_KEY[variant];
4205
- const current = variant === currentVariant ? currentValues?.[configKey] : void 0;
4206
- const merged = current?.kind === "object" ? { ...current.properties } : {};
4207
- for (const [name, value] of Object.entries(updates.modelParameters)) if (value === null) delete merged[name];
4208
- else merged[name] = value;
4209
- if (Object.keys(merged).length > 0) out[configKey] = {
4210
- kind: "object",
4211
- properties: merged
4212
- };
4213
- else remove(configKey);
4214
- }
4215
- return out;
4216
- }
4217
- };
4218
- /**
4219
- * Convert a {@link NormalizedMessage} array into a PropValue representing the
4220
- * `input` property: an array of [Step](https://ai.google.dev/api/interactions-api#Resource:Step)
4221
- * objects (`{type: 'user_input' | 'model_output', content: [...]}`), each
4222
- * carrying a single text [Content](https://ai.google.dev/api/interactions-api#schema-example-Content-text).
4223
- */
4224
- function messagesToValue(msgs) {
4225
- return {
4226
- kind: "array",
4227
- elements: msgs.map((msg) => ({
4228
- kind: "object",
4229
- properties: {
4230
- type: {
4231
- kind: "primitive",
4232
- value: msg.role === "assistant" ? "model_output" : "user_input"
4233
- },
4234
- content: {
4235
- kind: "array",
4236
- elements: [{
4237
- kind: "object",
4238
- properties: {
4239
- type: {
4240
- kind: "primitive",
4241
- value: "text"
4242
- },
4243
- text: msg.content
4244
- }
4245
- }]
4246
- }
4247
- }
4248
- }))
4249
- };
4250
- }
4251
- const EMPTY_CONTENT = {
4252
- kind: "primitive",
4253
- value: ""
4254
- };
4255
- function extractContent(el) {
4256
- if (el?.kind !== "object" || el.properties.type?.kind !== "primitive") return;
4257
- switch (el.properties.type.value) {
4258
- case "text": return {
4259
- role: "user",
4260
- content: el.properties.text ?? EMPTY_CONTENT
4261
- };
4262
- }
4263
- }
4264
- /**
4265
- * Extract a {@link NormalizedMessage} array from the `input` PropValue.
4266
- *
4267
- * The `input` field can be:
4268
- * - A primitive string (single user message)
4269
- * - A single content object (e.g. `{type: 'text', text: '...'}`)
4270
- * - An array of Step objects (https://ai.google.dev/api/interactions-api#Resource:Step)
4271
- * - An array of Content objects (https://ai.google.dev/api/interactions-api#schema-example-Content-text)
4272
- *
4273
- * The Interactions API uses `"model"` for assistant messages; we translate
4274
- * `"model"` → `"assistant"` on the way in.
4275
- */
4276
- function extractMessages(value) {
4277
- if (!value) return [];
4278
- const content = extractContent(value);
4279
- if (content) return [content];
4280
- if (value.kind !== "array") return [{
4281
- role: "user",
4282
- content: value
4283
- }];
4284
- const results = [];
4285
- for (const el of value.elements) {
4286
- const content = extractContent(el);
4287
- if (content) {
4288
- results.push(content);
4289
- continue;
4290
- }
4291
- if (el.kind !== "object" || el.properties.type?.kind !== "primitive") continue;
4292
- switch (el.properties.type.value) {
4293
- case "user_input":
4294
- results.push(...extractMessages(el.properties.content));
4295
- break;
4296
- case "model_output":
4297
- for (const msg of extractMessages(el.properties.content)) results.push({
4298
- ...msg,
4299
- role: "assistant"
4300
- });
4301
- break;
4302
- }
4303
- }
4304
- return results;
4305
- }
4306
- //#endregion
4307
3978
  //#region src/trace/memory-trace-provider.ts
4308
3979
  /**
4309
3980
  * In-memory {@link TraceProvider}, populated by one or more
@@ -4319,7 +3990,7 @@ var MemoryTraceProvider = class extends BaseTraceProvider {
4319
3990
  description
4320
3991
  });
4321
3992
  }
4322
- async getAllTraces() {
3993
+ async getAllTraces(query) {
4323
3994
  const summaries = Array.from(this.traces.values()).map((t) => {
4324
3995
  const spans = this.spansByTrace.get(t.id) ?? [];
4325
3996
  return {
@@ -4339,7 +4010,7 @@ var MemoryTraceProvider = class extends BaseTraceProvider {
4339
4010
  };
4340
4011
  });
4341
4012
  summaries.sort((a, b) => b.startTime - a.startTime);
4342
- return summaries;
4013
+ return filterTraces(summaries, query);
4343
4014
  }
4344
4015
  async hasTrace(traceId) {
4345
4016
  return this.traces.has(traceId);
@@ -4374,4 +4045,4 @@ var MemoryTraceProvider = class extends BaseTraceProvider {
4374
4045
  }
4375
4046
  };
4376
4047
  //#endregion
4377
- export { BaseTraceIngestor, BaseTraceProvider, CHECK_ATTRIBUTE, DEFAULT_EVAL_CONCURRENCY, DEFAULT_MAX_QUERY_ROWS, DEFAULT_PLAYGROUND_IGNORE_PATTERNS, DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, DEFAULT_QUERY_TIMEOUT_MS, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, DatasetNotFoundError, DatasetValidationError, EvalNotFoundError, EvalRunRefusedError, EvalRunner, FilePromptProvider, GeminiInteractionsSDK, GitVersioning, HttpTraceSink, LocalDatabaseTraceProvider, LocalDirectoryDatasetProvider, LocalEvalProvider, LocalFileProvider, LocalVariationStore, MIGRATIONS_TABLE, MemoryFileProvider, MemoryTraceProvider, OTelTraceIngestor, OtlpTraceIngestor, OverlayFileProvider, PLAYGROUND_ENVIRONMENT, PLAYGROUND_RESOURCE, PROMPT_FIELD, PROMPT_IDENTITY, PROMPT_ID_ATTRIBUTE, PROMPT_INPUTS_ATTRIBUTE, PROMPT_NAME_ATTRIBUTE, PROMPT_PROVIDER_ID_ATTRIBUTE, PROMPT_VARIATION_ATTRIBUTE, PROMPT_VERSION_ATTRIBUTE, ResourceRegistry, SERVICE_NAME_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, SqlQueryError, TRACE_EVENTS_PATH, TRACE_QUERY_SCHEMA, TSPromptFileType, TraceEventIngestor, TursoDatasetProvider, TursoEvalProvider, TursoTraceProvider, TursoVariationStore, TypeSafeSDK, TypeSafeTelemetry, VariationConflictError, VercelAISDK, VercelAISDKTelemetry, assertUpdateStyle, canonicalizeUpdates, check, collectInputSlots, createLocalTursoClient, createTracerForPrompt, decodeOtlpProtobuf, fieldValuesOf, findInputCycle, getPromptSpanAttributes, inputReferenceProblems, isCheck, isCheckSpan, isFreshImportHookRegistered, isResource, isStandardSchema, isValidInstanceName, isVariationLoaderHookRegistered, matchSourcesToSlots, mergeIntoWip, mergePromptIdentity, mergeSpans, mergeUpdates, namedBindings, normalizeOtlpRequest, openLocalEvalProvider, openLocalVariationStore, promptIdOf, rebaseUpdates, registerFreshImportHook, registerVariationLoaderHook, resolveConflicts, resolveExecutionInput, resolveExecutionInputs, resource, resourceParameterNames, runDatasetMigrations, runEvalMigrations, runMigrations, runVariationMigrations, serializeUpdates, setupGlobalOTelPipeline, spanMessages, stampReceipts, toPromptRef };
4048
+ export { BaseTraceIngestor, BaseTraceProvider, CHECK_ATTRIBUTE, CloudTraceProvider, DEFAULT_EVAL_CONCURRENCY, DEFAULT_MAX_QUERY_ROWS, DEFAULT_PLAYGROUND_IGNORE_PATTERNS, DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, DEFAULT_QUERY_TIMEOUT_MS, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, DatabaseSync, DatasetNotFoundError, DatasetValidationError, EvalNotFoundError, EvalRunRefusedError, EvalRunner, Evalution, FilePromptProvider, GitVersioning, HttpTraceSink, LocalDatabaseTraceProvider, LocalDirectoryDatasetProvider, LocalEvalProvider, LocalFileProvider, LocalVariationStore, MIGRATIONS_TABLE, MemoryFileProvider, MemoryTraceProvider, OTelTraceIngestor, OtlpTraceIngestor, OverlayFileProvider, PLAYGROUND_ENVIRONMENT, PLAYGROUND_RESOURCE, PROMPT_FIELD, PROMPT_ID_ATTRIBUTE, PROMPT_INPUTS_ATTRIBUTE, PROMPT_NAME_ATTRIBUTE, PROMPT_PROVIDER_ID_ATTRIBUTE, PROMPT_VARIATION_ATTRIBUTE, PROMPT_VERSION_ATTRIBUTE, ResourceRegistry, SERVICE_NAME_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, SqlQueryError, TRACE_EVENTS_PATH, TRACE_QUERY_SCHEMA, TSPromptFileType, TraceEventIngestor, TursoDatasetProvider, TursoEvalProvider, TursoTraceProvider, TursoVariationStore, VariationConflictError, WorkspaceSync, assertUpdateStyle, canonicalizeUpdates, check, collectInputSlots, createLocalTursoClient, createTracerForPrompt, decodeOtlpProtobuf, fieldValuesOf, findInputCycle, getPromptSpanAttributes, inputReferenceProblems, isCheck, isCheckSpan, isFreshImportHookRegistered, isResource, isStandardSchema, isValidInstanceName, isVariationLoaderHookRegistered, matchSourcesToSlots, mergeIntoWip, mergePromptIdentity, mergeSpans, mergeUpdates, namedBindings, normalizeOtlpRequest, openLocalEvalProvider, openLocalVariationStore, promptIdOf, rebaseUpdates, registerFreshImportHook, registerVariationLoaderHook, resolveConflicts, resolveExecutionInput, resolveExecutionInputs, resource, resourceParameterNames, runDatasetMigrations, runEvalMigrations, runMigrations, runVariationMigrations, serializeUpdates, setupGlobalOTelPipeline, spanMessages, stampReceipts, toPromptRef };