evalution 1.0.7 → 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-BTg6THHB.d.ts → check-ci7RhMcB.d.ts} +21 -848
- package/dist/checks/index.d.ts +2 -1
- package/dist/cli/index.js +257 -77
- package/dist/client/assets/DatasetView-BqSWI_pm.js +15 -0
- package/dist/client/assets/EvalRunView-CR6ZksSu.js +2 -0
- package/dist/client/assets/EvalView-JPEM5IY8.js +1 -0
- package/dist/client/assets/{data-grid-overlay-editor-CBVV2omk.js → data-grid-overlay-editor-B_nPhXKR.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-BqsjUFPI.js → highlighted-body-KPVGNVTW-dPpneB8R.js} +1 -1
- package/dist/client/assets/{index-B7OFMd2c.css → index-BGcZZetP.css} +1 -1
- package/dist/client/assets/{index-DOmAST6D.js → index-CwjMcK6S.js} +137 -137
- package/dist/client/assets/{number-overlay-editor-DhCVhD05.js → number-overlay-editor-CRWFlaQs.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/{dataset-types-CSjbM_Vz.d.ts → dataset-types-8cDpOFYi.d.ts} +6 -236
- package/dist/index.d.ts +302 -1279
- package/dist/index.js +148 -485
- package/dist/{trace-Dn6Pfcc5.d.ts → trace-BlnjMp7o.d.ts} +2 -1
- package/dist/{trace-event-ingestor-DI-HkA4Q.js → trace-event-ingestor-DwI1hxGX.js} +2471 -8458
- 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 +19 -16
- package/dist/client/assets/DatasetView-CWw3B_XI.js +0 -15
- package/dist/client/assets/EvalRunView-DJNSAydj.js +0 -2
- package/dist/client/assets/EvalView-R0Nkikzs.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as EvalNotFoundError, At as registerVariationLoaderHook, B as DatasetNotFoundError, C as rollupSpans, Ct as resourceParameterNames, D as toPromptRef, Dt as resource, E as promptIdOf, Et as isStandardSchema, G as shortId, H as isEditable, J as EvalRunner, K as DEFAULT_EVAL_CONCURRENCY, M as DEFAULT_QUERY_TIMEOUT_MS, Mt as registerFreshImportHook, N as SqlQueryError, O as decodeOtlpProtobuf, Ot as LocalFileProvider, S as mkdirSelfIgnoring, St as parameterDetails, T as VariationConflictError, Tt as isResource, V as DatasetValidationError, _ as runDatasetMigrations, a as readKind, b as assertSqliteFile, bt as DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, c as mergeSpans, d as LocalEvalProvider, dt as resolveExecutionInput, f as openLocalEvalProvider, ft as resolveExecutionInputs, g as TursoDatasetProvider, gt as inputReferenceProblems, h as LocalDirectoryDatasetProvider, ht as findInputCycle, i as mapStatus, j as DEFAULT_MAX_QUERY_ROWS, jt as isFreshImportHookRegistered, k as normalizeOtlpRequest, kt as isVariationLoaderHookRegistered, l as TRACE_QUERY_SCHEMA, m as runEvalMigrations, mt as collectInputSlots, n as OtlpTraceIngestor, o as LocalDatabaseTraceProvider, p as TursoEvalProvider, pt as stampReceipts, q as EvalRunRefusedError, r as llmAndPrompt, s as TursoTraceProvider, t as TraceEventIngestor, u as BaseTraceProvider, ut as matchSourcesToSlots, v as MIGRATIONS_TABLE, vt as namedBindings, wt as isValidInstanceName, x as createLocalTursoClient, xt as ResourceRegistry, y as runMigrations, yt as DEFAULT_PLAYGROUND_IGNORE_PATTERNS } from "./trace-event-ingestor-DwI1hxGX.js";
|
|
2
2
|
import { _ as isCheck, g as check, n as builtinCheck, r as builtinCheckInfos } from "./checks-Cq97JU-h.js";
|
|
3
3
|
import "node:module";
|
|
4
4
|
import path, { dirname } from "node:path";
|
|
5
5
|
import { access, realpath } from "node:fs/promises";
|
|
6
6
|
import { minimatch } from "minimatch";
|
|
7
|
-
import fs$1 from "node:fs";
|
|
8
7
|
import { createHash } from "node:crypto";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
8
|
+
import { SpanStatusCode } from "@opentelemetry/api";
|
|
9
|
+
import { addProperty, buildPropTypeFromType, extractPropertiesFromObjectLiteral, extractPropertiesFromParameters, isOpaqueType, removeProperty, resolveBindings, updateProperty } from "ts-proppy";
|
|
10
|
+
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, getPromptSpanAttributes, isCheckSpan, mergePromptIdentity, spanMessages } from "@evalution/sdk";
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
12
|
import { drizzle } from "drizzle-orm/tursodatabase-sync";
|
|
13
13
|
import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
|
|
14
14
|
import { integer, primaryKey, real, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
15
|
+
import ts from "typescript";
|
|
16
|
+
import { assertUpdateStyle } from "@evalution/sdk/adapter";
|
|
15
17
|
//#region \0rolldown/runtime.js
|
|
16
18
|
var __defProp = Object.defineProperty;
|
|
17
19
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -168,6 +170,125 @@ var OverlayFileProvider = class {
|
|
|
168
170
|
}
|
|
169
171
|
};
|
|
170
172
|
//#endregion
|
|
173
|
+
//#region src/trace/otel-trace-ingestor.ts
|
|
174
|
+
function hrTimeToMs(time) {
|
|
175
|
+
return time[0] * 1e3 + time[1] / 1e6;
|
|
176
|
+
}
|
|
177
|
+
/** `span`'s resource attributes as a {@link Span.resource}, if it has any. */
|
|
178
|
+
function resourceOf(span) {
|
|
179
|
+
const attributes = span.resource?.attributes;
|
|
180
|
+
return attributes && Object.keys(attributes).length > 0 ? { resource: { ...attributes } } : {};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* {@link TraceIngestor} populated by OpenTelemetry spans. Register the
|
|
184
|
+
* processor returned by {@link getSpanProcessor} on a `BasicTracerProvider`
|
|
185
|
+
* (from `@opentelemetry/sdk-trace-base`).
|
|
186
|
+
*
|
|
187
|
+
* Because OpenTelemetry is a single process-global pipeline, at most one
|
|
188
|
+
* `OTelTraceIngestor` should be active per server — {@link isRedundant}
|
|
189
|
+
* reports any other instance redundant so server wiring can consolidate.
|
|
190
|
+
*/
|
|
191
|
+
var OTelTraceIngestor = class OTelTraceIngestor extends BaseTraceIngestor$1 {
|
|
192
|
+
spanPromises = /* @__PURE__ */ new Map();
|
|
193
|
+
isRedundant(other) {
|
|
194
|
+
return other instanceof OTelTraceIngestor;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Returns a `SpanProcessor` that funnels every OpenTelemetry span the
|
|
198
|
+
* caller's tracer produces into this ingestor's sinks.
|
|
199
|
+
*/
|
|
200
|
+
getSpanProcessor() {
|
|
201
|
+
return {
|
|
202
|
+
onStart: (span) => {
|
|
203
|
+
const spanId = span.spanContext().spanId;
|
|
204
|
+
const p = this.handleStart(span).catch(console.error);
|
|
205
|
+
this.spanPromises.set(spanId, p);
|
|
206
|
+
p.finally(() => this.spanPromises.delete(spanId));
|
|
207
|
+
},
|
|
208
|
+
onEnd: (span) => {
|
|
209
|
+
const spanId = span.spanContext().spanId;
|
|
210
|
+
const p = (this.spanPromises.get(spanId) ?? Promise.resolve()).then(() => this.handleEnd(span)).catch(console.error);
|
|
211
|
+
this.spanPromises.set(spanId, p);
|
|
212
|
+
p.finally(() => this.spanPromises.delete(spanId));
|
|
213
|
+
},
|
|
214
|
+
forceFlush: async () => {},
|
|
215
|
+
shutdown: async () => {}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
async handleStart(span) {
|
|
219
|
+
const ctx = span.spanContext();
|
|
220
|
+
const traceId = ctx.traceId;
|
|
221
|
+
const spanId = ctx.spanId;
|
|
222
|
+
const parentCtx = span.parentSpanContext;
|
|
223
|
+
const ourSpan = {
|
|
224
|
+
id: spanId,
|
|
225
|
+
traceId,
|
|
226
|
+
parentId: parentCtx && parentCtx.traceId === traceId ? parentCtx.spanId : void 0,
|
|
227
|
+
name: span.name,
|
|
228
|
+
kind: readKind(span.attributes),
|
|
229
|
+
startTime: hrTimeToMs(span.startTime),
|
|
230
|
+
attributes: { ...span.attributes },
|
|
231
|
+
...resourceOf(span),
|
|
232
|
+
...llmAndPrompt(span.attributes)
|
|
233
|
+
};
|
|
234
|
+
await this.recordSpanStart(ourSpan);
|
|
235
|
+
}
|
|
236
|
+
async handleEnd(span) {
|
|
237
|
+
const ctx = span.spanContext();
|
|
238
|
+
const traceId = ctx.traceId;
|
|
239
|
+
const ended = {
|
|
240
|
+
id: ctx.spanId,
|
|
241
|
+
traceId,
|
|
242
|
+
parentId: span.parentSpanContext && span.parentSpanContext.traceId === traceId ? span.parentSpanContext.spanId : void 0,
|
|
243
|
+
name: span.name,
|
|
244
|
+
kind: readKind(span.attributes),
|
|
245
|
+
startTime: hrTimeToMs(span.startTime),
|
|
246
|
+
endTime: hrTimeToMs(span.endTime),
|
|
247
|
+
status: mapStatus(span.status),
|
|
248
|
+
errorMessage: span.status.code === SpanStatusCode.ERROR ? span.status.message : void 0,
|
|
249
|
+
attributes: { ...span.attributes },
|
|
250
|
+
...resourceOf(span),
|
|
251
|
+
...llmAndPrompt(span.attributes)
|
|
252
|
+
};
|
|
253
|
+
await this.recordSpanEnd(ended);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Waits for every in-flight `onStart`/`onEnd` handler to settle. Used by
|
|
257
|
+
* tests to deterministically assert on the resulting trace store.
|
|
258
|
+
*/
|
|
259
|
+
async drainPendingHandlers() {
|
|
260
|
+
while (this.spanPromises.size > 0) await Promise.all([...this.spanPromises.values()]);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/trace/otel-global-pipeline.ts
|
|
265
|
+
let globalOTelPipeline;
|
|
266
|
+
/**
|
|
267
|
+
* Stands up the process-global OpenTelemetry tracer provider and
|
|
268
|
+
* `AsyncLocalStorageContextManager`, if not already done, and returns the
|
|
269
|
+
* {@link OTelTraceIngestor} feeding it.
|
|
270
|
+
*
|
|
271
|
+
* Safe to call from multiple SDK adapters: the underlying setup runs at most
|
|
272
|
+
* once per process, and every caller is resolved with the same ingestor
|
|
273
|
+
* instance.
|
|
274
|
+
*/
|
|
275
|
+
function setupGlobalOTelPipeline() {
|
|
276
|
+
globalOTelPipeline ??= doSetup();
|
|
277
|
+
return globalOTelPipeline;
|
|
278
|
+
}
|
|
279
|
+
async function doSetup() {
|
|
280
|
+
const { context, trace } = await import("@opentelemetry/api");
|
|
281
|
+
const { AsyncLocalStorageContextManager } = await import("@opentelemetry/context-async-hooks");
|
|
282
|
+
const { BasicTracerProvider } = await import("@opentelemetry/sdk-trace-base");
|
|
283
|
+
const ingestor = new OTelTraceIngestor();
|
|
284
|
+
const tracerProvider = new BasicTracerProvider({ spanProcessors: [ingestor.getSpanProcessor()] });
|
|
285
|
+
trace.setGlobalTracerProvider(tracerProvider);
|
|
286
|
+
const contextManager = new AsyncLocalStorageContextManager();
|
|
287
|
+
contextManager.enable();
|
|
288
|
+
context.setGlobalContextManager(contextManager);
|
|
289
|
+
return ingestor;
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
171
292
|
//#region src/prompt/variations/canonical-updates.ts
|
|
172
293
|
/** Prefix of a per-parameter field name, e.g. `modelParameters.temperature`. */
|
|
173
294
|
const MODEL_PARAMETER_PREFIX = "modelParameters.";
|
|
@@ -2383,6 +2504,20 @@ function isDefinition(result) {
|
|
|
2383
2504
|
return !!result && !Array.isArray(result);
|
|
2384
2505
|
}
|
|
2385
2506
|
/**
|
|
2507
|
+
* A declared argument's definition: its probe's answer, or the unresolved
|
|
2508
|
+
* fallback, with what its schema says added — the probe sees an output type
|
|
2509
|
+
* alone, which can't say whether it can be left out, or what it's for.
|
|
2510
|
+
*/
|
|
2511
|
+
function parameterDefinition(name, result, details) {
|
|
2512
|
+
const definition = isDefinition(result) ? result : unresolvedParameter(name);
|
|
2513
|
+
const { optional = false, description } = details.get(name) ?? {};
|
|
2514
|
+
return {
|
|
2515
|
+
...definition,
|
|
2516
|
+
optional,
|
|
2517
|
+
...description && { description }
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
/**
|
|
2386
2521
|
* A file type's slot-match answer (slot path → source uris) turned around into
|
|
2387
2522
|
* source uri → the slot paths it fits, or `undefined` when there is none.
|
|
2388
2523
|
*/
|
|
@@ -2749,9 +2884,11 @@ var FilePromptProvider = class {
|
|
|
2749
2884
|
const names = resourceParameterNames(resource.resource);
|
|
2750
2885
|
if (names.length === 0) continue;
|
|
2751
2886
|
const candidates = (await this.resources.inScopeFor(resource.modulePath)).filter((s) => !dependsOn(s.resource, resource, byResource));
|
|
2887
|
+
const details = await parameterDetails(resource.resource);
|
|
2752
2888
|
withParams.push({
|
|
2753
2889
|
resource,
|
|
2754
2890
|
names,
|
|
2891
|
+
details,
|
|
2755
2892
|
candidates
|
|
2756
2893
|
});
|
|
2757
2894
|
}
|
|
@@ -2833,13 +2970,10 @@ var FilePromptProvider = class {
|
|
|
2833
2970
|
*/
|
|
2834
2971
|
assembleResourceParameters(withParams, resolved) {
|
|
2835
2972
|
let cursor = 0;
|
|
2836
|
-
return new Map(withParams.map(({ resource, names }) => {
|
|
2973
|
+
return new Map(withParams.map(({ resource, names, details }) => {
|
|
2837
2974
|
const start = cursor;
|
|
2838
2975
|
cursor += names.length;
|
|
2839
|
-
return [resource.uri, names.map((name, j) =>
|
|
2840
|
-
const result = resolved?.[start + j];
|
|
2841
|
-
return isDefinition(result) ? result : unresolvedParameter(name);
|
|
2842
|
-
})];
|
|
2976
|
+
return [resource.uri, names.map((name, j) => parameterDefinition(name, resolved?.[start + j], details))];
|
|
2843
2977
|
}));
|
|
2844
2978
|
}
|
|
2845
2979
|
/**
|
|
@@ -3040,8 +3174,9 @@ var FilePromptProvider = class {
|
|
|
3040
3174
|
promptName: c.key
|
|
3041
3175
|
})));
|
|
3042
3176
|
const resolved = requests.length > 0 ? await this.resolveTypes(requests, []) : {};
|
|
3177
|
+
const details = await Promise.all(withNames.map(({ registered: c }) => parameterDetails(c.check)));
|
|
3043
3178
|
let cursor = 0;
|
|
3044
|
-
const user = withNames.map(({ registered: c, names }) => {
|
|
3179
|
+
const user = withNames.map(({ registered: c, names }, i) => {
|
|
3045
3180
|
const start = cursor;
|
|
3046
3181
|
cursor += names.length;
|
|
3047
3182
|
return {
|
|
@@ -3050,10 +3185,7 @@ var FilePromptProvider = class {
|
|
|
3050
3185
|
...c.check.group && { group: c.check.group },
|
|
3051
3186
|
...c.check.description && { description: c.check.description },
|
|
3052
3187
|
...c.check.runsOnError && { runsOnError: true },
|
|
3053
|
-
parameters: names.map((name, j) =>
|
|
3054
|
-
const result = resolved.probes?.[start + j];
|
|
3055
|
-
return isDefinition(result) ? result : unresolvedParameter(name);
|
|
3056
|
-
})
|
|
3188
|
+
parameters: names.map((name, j) => parameterDefinition(name, resolved.probes?.[start + j], details[i]))
|
|
3057
3189
|
};
|
|
3058
3190
|
});
|
|
3059
3191
|
return [
|
|
@@ -3134,7 +3266,7 @@ var FilePromptProvider = class {
|
|
|
3134
3266
|
}
|
|
3135
3267
|
}
|
|
3136
3268
|
async setupTraceIngestion() {
|
|
3137
|
-
return this.sdkAdapter.setupTraceIngestion?.();
|
|
3269
|
+
return this.sdkAdapter.setupTraceIngestion?.({ setupGlobalOTelPipeline });
|
|
3138
3270
|
}
|
|
3139
3271
|
async renamePrompt(promptId, newName) {
|
|
3140
3272
|
const [filePath, oldName] = this.parsePromptId(promptId);
|
|
@@ -3824,475 +3956,6 @@ var GitVersioning = class GitVersioning {
|
|
|
3824
3956
|
}
|
|
3825
3957
|
};
|
|
3826
3958
|
//#endregion
|
|
3827
|
-
//#region src/sdk/gemini-interactions-sdk.ts
|
|
3828
|
-
const MODEL_KEY = "model";
|
|
3829
|
-
const AGENT_KEY = "agent";
|
|
3830
|
-
const SYSTEM_KEY = "system_instruction";
|
|
3831
|
-
const INPUT_KEY = "input";
|
|
3832
|
-
const GENERATION_CONFIG_KEY = "generation_config";
|
|
3833
|
-
const AGENT_CONFIG_KEY = "agent_config";
|
|
3834
|
-
const FALLBACK_GENERATION_CONFIG_PARAMS = [
|
|
3835
|
-
{
|
|
3836
|
-
name: "temperature",
|
|
3837
|
-
description: "Controls the randomness of the output.",
|
|
3838
|
-
type: {
|
|
3839
|
-
kind: "primitive",
|
|
3840
|
-
syntax: "number"
|
|
3841
|
-
},
|
|
3842
|
-
optional: true
|
|
3843
|
-
},
|
|
3844
|
-
{
|
|
3845
|
-
name: "top_p",
|
|
3846
|
-
description: "The maximum cumulative probability of tokens to consider when sampling.",
|
|
3847
|
-
type: {
|
|
3848
|
-
kind: "primitive",
|
|
3849
|
-
syntax: "number"
|
|
3850
|
-
},
|
|
3851
|
-
optional: true
|
|
3852
|
-
},
|
|
3853
|
-
{
|
|
3854
|
-
name: "max_output_tokens",
|
|
3855
|
-
description: "The maximum number of tokens to include in the response.",
|
|
3856
|
-
type: {
|
|
3857
|
-
kind: "primitive",
|
|
3858
|
-
syntax: "number"
|
|
3859
|
-
},
|
|
3860
|
-
optional: true
|
|
3861
|
-
},
|
|
3862
|
-
{
|
|
3863
|
-
name: "seed",
|
|
3864
|
-
description: "Seed used in decoding for reproducibility.",
|
|
3865
|
-
type: {
|
|
3866
|
-
kind: "primitive",
|
|
3867
|
-
syntax: "number"
|
|
3868
|
-
},
|
|
3869
|
-
optional: true
|
|
3870
|
-
},
|
|
3871
|
-
{
|
|
3872
|
-
name: "stop_sequences",
|
|
3873
|
-
description: "A list of character sequences that will stop output interaction.",
|
|
3874
|
-
type: {
|
|
3875
|
-
kind: "array",
|
|
3876
|
-
syntax: "string[]",
|
|
3877
|
-
element: {
|
|
3878
|
-
name: "",
|
|
3879
|
-
type: {
|
|
3880
|
-
kind: "primitive",
|
|
3881
|
-
syntax: "string"
|
|
3882
|
-
},
|
|
3883
|
-
optional: false
|
|
3884
|
-
}
|
|
3885
|
-
},
|
|
3886
|
-
optional: true
|
|
3887
|
-
},
|
|
3888
|
-
{
|
|
3889
|
-
name: "thinking_level",
|
|
3890
|
-
description: "The level of thought tokens that the model should generate.",
|
|
3891
|
-
type: {
|
|
3892
|
-
kind: "union",
|
|
3893
|
-
syntax: "'minimal' | 'low' | 'medium' | 'high'",
|
|
3894
|
-
types: [
|
|
3895
|
-
{
|
|
3896
|
-
kind: "constant",
|
|
3897
|
-
syntax: "'minimal'",
|
|
3898
|
-
value: "minimal"
|
|
3899
|
-
},
|
|
3900
|
-
{
|
|
3901
|
-
kind: "constant",
|
|
3902
|
-
syntax: "'low'",
|
|
3903
|
-
value: "low"
|
|
3904
|
-
},
|
|
3905
|
-
{
|
|
3906
|
-
kind: "constant",
|
|
3907
|
-
syntax: "'medium'",
|
|
3908
|
-
value: "medium"
|
|
3909
|
-
},
|
|
3910
|
-
{
|
|
3911
|
-
kind: "constant",
|
|
3912
|
-
syntax: "'high'",
|
|
3913
|
-
value: "high"
|
|
3914
|
-
}
|
|
3915
|
-
]
|
|
3916
|
-
},
|
|
3917
|
-
optional: true
|
|
3918
|
-
},
|
|
3919
|
-
{
|
|
3920
|
-
name: "thinking_summaries",
|
|
3921
|
-
description: "Whether to include thought summaries in the response.",
|
|
3922
|
-
type: {
|
|
3923
|
-
kind: "union",
|
|
3924
|
-
syntax: "'auto' | 'none'",
|
|
3925
|
-
types: [{
|
|
3926
|
-
kind: "constant",
|
|
3927
|
-
syntax: "'auto'",
|
|
3928
|
-
value: "auto"
|
|
3929
|
-
}, {
|
|
3930
|
-
kind: "constant",
|
|
3931
|
-
syntax: "'none'",
|
|
3932
|
-
value: "none"
|
|
3933
|
-
}]
|
|
3934
|
-
},
|
|
3935
|
-
optional: true
|
|
3936
|
-
}
|
|
3937
|
-
];
|
|
3938
|
-
/**
|
|
3939
|
-
* The models `interactions.create` accepts — a subset of the full Gemini
|
|
3940
|
-
* lineup. See https://ai.google.dev/gemini-api/docs/interactions
|
|
3941
|
-
*/
|
|
3942
|
-
const CURATED_MODELS = [
|
|
3943
|
-
{
|
|
3944
|
-
label: "Gemini 3.8 Flash",
|
|
3945
|
-
id: "gemini-3.8-flash"
|
|
3946
|
-
},
|
|
3947
|
-
{
|
|
3948
|
-
label: "Gemini 3.7 Flash",
|
|
3949
|
-
id: "gemini-3.7-flash"
|
|
3950
|
-
},
|
|
3951
|
-
{
|
|
3952
|
-
label: "Gemini 3.6 Flash",
|
|
3953
|
-
id: "gemini-3.6-flash"
|
|
3954
|
-
},
|
|
3955
|
-
{
|
|
3956
|
-
label: "Gemini 3.5 Flash",
|
|
3957
|
-
id: "gemini-3.5-flash"
|
|
3958
|
-
},
|
|
3959
|
-
{
|
|
3960
|
-
label: "Gemini 3.5 Flash-Lite",
|
|
3961
|
-
id: "gemini-3.5-flash-lite"
|
|
3962
|
-
},
|
|
3963
|
-
{
|
|
3964
|
-
label: "Gemini 3.1 Pro Preview",
|
|
3965
|
-
id: "gemini-3.1-pro-preview"
|
|
3966
|
-
},
|
|
3967
|
-
{
|
|
3968
|
-
label: "Gemini 3.1 Flash-Lite",
|
|
3969
|
-
id: "gemini-3.1-flash-lite"
|
|
3970
|
-
},
|
|
3971
|
-
{
|
|
3972
|
-
label: "Gemini 3 Flash Preview",
|
|
3973
|
-
id: "gemini-3-flash-preview"
|
|
3974
|
-
},
|
|
3975
|
-
{
|
|
3976
|
-
label: "Gemini 2.5 Pro",
|
|
3977
|
-
id: "gemini-2.5-pro"
|
|
3978
|
-
},
|
|
3979
|
-
{
|
|
3980
|
-
label: "Gemini 2.5 Flash",
|
|
3981
|
-
id: "gemini-2.5-flash"
|
|
3982
|
-
},
|
|
3983
|
-
{
|
|
3984
|
-
label: "Gemini 2.5 Flash-Lite",
|
|
3985
|
-
id: "gemini-2.5-flash-lite"
|
|
3986
|
-
}
|
|
3987
|
-
];
|
|
3988
|
-
/** The agents `interactions.create` accepts. */
|
|
3989
|
-
const CURATED_AGENTS = [
|
|
3990
|
-
{
|
|
3991
|
-
label: "Deep Research Preview",
|
|
3992
|
-
id: "deep-research-preview-04-2026"
|
|
3993
|
-
},
|
|
3994
|
-
{
|
|
3995
|
-
label: "Deep Research Max Preview",
|
|
3996
|
-
id: "deep-research-max-preview-04-2026"
|
|
3997
|
-
},
|
|
3998
|
-
{
|
|
3999
|
-
label: "Antigravity Preview",
|
|
4000
|
-
id: "antigravity-preview-09-2026"
|
|
4001
|
-
}
|
|
4002
|
-
];
|
|
4003
|
-
/** Each variant's own settings, which are invalid under the other. */
|
|
4004
|
-
const VARIANT_CONFIG_KEY = {
|
|
4005
|
-
model: GENERATION_CONFIG_KEY,
|
|
4006
|
-
agent: AGENT_CONFIG_KEY
|
|
4007
|
-
};
|
|
4008
|
-
const STRING = {
|
|
4009
|
-
kind: "primitive",
|
|
4010
|
-
syntax: "string",
|
|
4011
|
-
base: "string"
|
|
4012
|
-
};
|
|
4013
|
-
/** One variant's fragment of the config, `{ model: … }` or `{ agent: … }`. */
|
|
4014
|
-
function variantType(key, idType = STRING) {
|
|
4015
|
-
return {
|
|
4016
|
-
kind: "object",
|
|
4017
|
-
syntax: `{ ${key}: ${key === MODEL_KEY ? "Model" : "AgentOption"} }`,
|
|
4018
|
-
properties: [{
|
|
4019
|
-
name: key,
|
|
4020
|
-
type: idType,
|
|
4021
|
-
optional: false
|
|
4022
|
-
}]
|
|
4023
|
-
};
|
|
4024
|
-
}
|
|
4025
|
-
/** The model slot's type when it couldn't be resolved. */
|
|
4026
|
-
const FALLBACK_MODEL_TYPE = {
|
|
4027
|
-
kind: "union",
|
|
4028
|
-
syntax: "{ model: Model } | { agent: AgentOption }",
|
|
4029
|
-
types: [variantType(MODEL_KEY), variantType(AGENT_KEY)]
|
|
4030
|
-
};
|
|
4031
|
-
/** Probe name for the model slot's type, as reported in project results. */
|
|
4032
|
-
const MODEL_PROBE = "model";
|
|
4033
|
-
/**
|
|
4034
|
-
* The model slot as a union of two config fragments: each variant's own ID
|
|
4035
|
-
* key, read off the SDK's own request types.
|
|
4036
|
-
*/
|
|
4037
|
-
const MODEL_PROJECT_PROBES = [{
|
|
4038
|
-
kind: "type",
|
|
4039
|
-
name: MODEL_PROBE,
|
|
4040
|
-
expression: "Pick<import(\"@google/genai\").Interactions.CreateModelInteraction, \"model\"> | Pick<import(\"@google/genai\").Interactions.CreateAgentInteraction, \"agent\">",
|
|
4041
|
-
syntax: "{ model: Model } | { agent: AgentOption }"
|
|
4042
|
-
}];
|
|
4043
|
-
/** The variant member of a resolved model type, by the key it carries. */
|
|
4044
|
-
function memberFor(type, key) {
|
|
4045
|
-
return (type.kind === "union" ? type.types : [type]).find((m) => m.kind === "object" && m.properties.some((p) => p.name === key)) ?? variantType(key);
|
|
4046
|
-
}
|
|
4047
|
-
function fragment(key, id) {
|
|
4048
|
-
return {
|
|
4049
|
-
kind: "object",
|
|
4050
|
-
properties: { [key]: {
|
|
4051
|
-
kind: "primitive",
|
|
4052
|
-
value: id
|
|
4053
|
-
} },
|
|
4054
|
-
displayValue: id
|
|
4055
|
-
};
|
|
4056
|
-
}
|
|
4057
|
-
/** Which variant a model fragment is, if it is one. */
|
|
4058
|
-
function variantOf(value) {
|
|
4059
|
-
if (value?.kind !== "object") return void 0;
|
|
4060
|
-
if (MODEL_KEY in value.properties) return MODEL_KEY;
|
|
4061
|
-
if (AGENT_KEY in value.properties) return AGENT_KEY;
|
|
4062
|
-
}
|
|
4063
|
-
/**
|
|
4064
|
-
* {@link SDKAdapter} implementation for the Google GenAI
|
|
4065
|
-
* [Interactions API](https://ai.google.dev/gemini-api/docs/interactions)
|
|
4066
|
-
* (`@google/genai` package). Currently experimental and untested.
|
|
4067
|
-
*/
|
|
4068
|
-
var GeminiInteractionsSDK = class {
|
|
4069
|
-
promptsHelperImport = "FIXME";
|
|
4070
|
-
getProjectProbes(language) {
|
|
4071
|
-
return language === "typescript" ? MODEL_PROJECT_PROBES : [];
|
|
4072
|
-
}
|
|
4073
|
-
/**
|
|
4074
|
-
* One model row whose value is an honest config fragment —
|
|
4075
|
-
* `{ model: "gemini-3.5-flash" }` or `{ agent: "deep-research-…" }` —
|
|
4076
|
-
* because `interactions.create` takes one or the other, never both. The
|
|
4077
|
-
* **Models** and **Agents** catalogs each narrow their free-form entry to
|
|
4078
|
-
* their own variant.
|
|
4079
|
-
*/
|
|
4080
|
-
async getModelDefinition(project) {
|
|
4081
|
-
const resolved = project[MODEL_PROBE];
|
|
4082
|
-
const type = resolved && !Array.isArray(resolved) ? resolved.type : FALLBACK_MODEL_TYPE;
|
|
4083
|
-
const catalog = (key, label, ids) => ({
|
|
4084
|
-
label,
|
|
4085
|
-
groups: [{
|
|
4086
|
-
label: "Google",
|
|
4087
|
-
icon: "Google",
|
|
4088
|
-
presets: ids.map(({ label, id }) => ({
|
|
4089
|
-
label,
|
|
4090
|
-
value: fragment(key, id)
|
|
4091
|
-
}))
|
|
4092
|
-
}],
|
|
4093
|
-
literal: {
|
|
4094
|
-
name: "model",
|
|
4095
|
-
type: memberFor(type, key),
|
|
4096
|
-
optional: false
|
|
4097
|
-
}
|
|
4098
|
-
});
|
|
4099
|
-
return {
|
|
4100
|
-
name: "model",
|
|
4101
|
-
type,
|
|
4102
|
-
optional: false,
|
|
4103
|
-
catalogs: [catalog(MODEL_KEY, "Models", CURATED_MODELS), catalog(AGENT_KEY, "Agents", CURATED_AGENTS)]
|
|
4104
|
-
};
|
|
4105
|
-
}
|
|
4106
|
-
getModelParameters(rootDir) {
|
|
4107
|
-
try {
|
|
4108
|
-
const dtsPath = findPackageDts("@google/genai", "dist/genai.d.ts", rootDir);
|
|
4109
|
-
if (dtsPath) {
|
|
4110
|
-
const sourceText = fs$1.readFileSync(dtsPath, "utf-8");
|
|
4111
|
-
const sourceFile = ts.createSourceFile(dtsPath, sourceText, ts.ScriptTarget.Latest, true);
|
|
4112
|
-
const decl = findTypeDeclaration(sourceFile, "GenerationConfig_2");
|
|
4113
|
-
if (decl) return extractPropertiesFromDeclaration(decl, sourceFile).definitions;
|
|
4114
|
-
}
|
|
4115
|
-
} catch {}
|
|
4116
|
-
return FALLBACK_GENERATION_CONFIG_PARAMS;
|
|
4117
|
-
}
|
|
4118
|
-
async executeConfig(config) {
|
|
4119
|
-
let GoogleGenAI;
|
|
4120
|
-
try {
|
|
4121
|
-
({GoogleGenAI} = await import("@google/genai"));
|
|
4122
|
-
} catch (err) {
|
|
4123
|
-
if (!isMissingPackage(err, "@google/genai")) throw err;
|
|
4124
|
-
throw new Error(missingPackageMessage("@google/genai"), { cause: err });
|
|
4125
|
-
}
|
|
4126
|
-
await new GoogleGenAI({}).interactions.create({
|
|
4127
|
-
...config,
|
|
4128
|
-
store: false
|
|
4129
|
-
});
|
|
4130
|
-
}
|
|
4131
|
-
normalizePrompt(prompt) {
|
|
4132
|
-
const { definitions, values } = prompt.extractedProps;
|
|
4133
|
-
const systemValue = values?.[SYSTEM_KEY];
|
|
4134
|
-
const inputValue = values?.[INPUT_KEY];
|
|
4135
|
-
const modelValue = values?.[MODEL_KEY];
|
|
4136
|
-
const agentValue = values?.[AGENT_KEY];
|
|
4137
|
-
const variant = !modelValue && agentValue ? AGENT_KEY : MODEL_KEY;
|
|
4138
|
-
const idValue = variant === MODEL_KEY ? modelValue : agentValue;
|
|
4139
|
-
const model = idValue && {
|
|
4140
|
-
kind: "object",
|
|
4141
|
-
properties: { [variant]: idValue },
|
|
4142
|
-
displayValue: idValue.kind === "primitive" ? String(idValue.value) : valueToSourceText(idValue)
|
|
4143
|
-
};
|
|
4144
|
-
const configKey = VARIANT_CONFIG_KEY[variant];
|
|
4145
|
-
const configDef = definitions.find((d) => d.name === configKey);
|
|
4146
|
-
const configValue = values?.[configKey];
|
|
4147
|
-
const configProps = configValue?.kind === "object" ? configValue.properties : {};
|
|
4148
|
-
const modelParameters = (configDef?.type.kind === "object" ? configDef.type.properties : []).map((def) => ({
|
|
4149
|
-
def,
|
|
4150
|
-
value: configProps[def.name]
|
|
4151
|
-
}));
|
|
4152
|
-
return {
|
|
4153
|
-
style: "chat",
|
|
4154
|
-
id: prompt.id,
|
|
4155
|
-
providerId: prompt.providerId,
|
|
4156
|
-
name: prompt.name,
|
|
4157
|
-
functionParameters: prompt.functionParameters,
|
|
4158
|
-
metadata: prompt.metadata,
|
|
4159
|
-
treePath: prompt.treePath,
|
|
4160
|
-
model,
|
|
4161
|
-
modelEditable: true,
|
|
4162
|
-
system: systemValue,
|
|
4163
|
-
systemEditable: true,
|
|
4164
|
-
messages: extractMessages(inputValue),
|
|
4165
|
-
messagesEditable: true,
|
|
4166
|
-
modelParameters
|
|
4167
|
-
};
|
|
4168
|
-
}
|
|
4169
|
-
denormalizeUpdates(updates, currentValues) {
|
|
4170
|
-
assertUpdateStyle(updates, "chat");
|
|
4171
|
-
const out = {};
|
|
4172
|
-
const remove = (key) => {
|
|
4173
|
-
if (currentValues && key in currentValues) out[key] = null;
|
|
4174
|
-
};
|
|
4175
|
-
const currentVariant = currentValues && MODEL_KEY in currentValues ? MODEL_KEY : currentValues && AGENT_KEY in currentValues ? AGENT_KEY : void 0;
|
|
4176
|
-
let variant = currentVariant ?? MODEL_KEY;
|
|
4177
|
-
if ("model" in updates) {
|
|
4178
|
-
const next = variantOf(updates.model);
|
|
4179
|
-
if (!next) {
|
|
4180
|
-
remove(MODEL_KEY);
|
|
4181
|
-
remove(AGENT_KEY);
|
|
4182
|
-
} else if (updates.model?.kind === "object") {
|
|
4183
|
-
const other = next === MODEL_KEY ? AGENT_KEY : MODEL_KEY;
|
|
4184
|
-
out[next] = updates.model.properties[next];
|
|
4185
|
-
remove(other);
|
|
4186
|
-
if (currentVariant && currentVariant !== next) remove(VARIANT_CONFIG_KEY[other]);
|
|
4187
|
-
variant = next;
|
|
4188
|
-
}
|
|
4189
|
-
}
|
|
4190
|
-
if ("system" in updates) out[SYSTEM_KEY] = updates.system ?? null;
|
|
4191
|
-
if ("messages" in updates) out[INPUT_KEY] = updates.messages == null ? null : messagesToValue(updates.messages);
|
|
4192
|
-
if (updates.modelParameters) {
|
|
4193
|
-
const configKey = VARIANT_CONFIG_KEY[variant];
|
|
4194
|
-
const current = variant === currentVariant ? currentValues?.[configKey] : void 0;
|
|
4195
|
-
const merged = current?.kind === "object" ? { ...current.properties } : {};
|
|
4196
|
-
for (const [name, value] of Object.entries(updates.modelParameters)) if (value === null) delete merged[name];
|
|
4197
|
-
else merged[name] = value;
|
|
4198
|
-
if (Object.keys(merged).length > 0) out[configKey] = {
|
|
4199
|
-
kind: "object",
|
|
4200
|
-
properties: merged
|
|
4201
|
-
};
|
|
4202
|
-
else remove(configKey);
|
|
4203
|
-
}
|
|
4204
|
-
return out;
|
|
4205
|
-
}
|
|
4206
|
-
};
|
|
4207
|
-
/**
|
|
4208
|
-
* Convert a {@link NormalizedMessage} array into a PropValue representing the
|
|
4209
|
-
* `input` property: an array of [Step](https://ai.google.dev/api/interactions-api#Resource:Step)
|
|
4210
|
-
* objects (`{type: 'user_input' | 'model_output', content: [...]}`), each
|
|
4211
|
-
* carrying a single text [Content](https://ai.google.dev/api/interactions-api#schema-example-Content-text).
|
|
4212
|
-
*/
|
|
4213
|
-
function messagesToValue(msgs) {
|
|
4214
|
-
return {
|
|
4215
|
-
kind: "array",
|
|
4216
|
-
elements: msgs.map((msg) => ({
|
|
4217
|
-
kind: "object",
|
|
4218
|
-
properties: {
|
|
4219
|
-
type: {
|
|
4220
|
-
kind: "primitive",
|
|
4221
|
-
value: msg.role === "assistant" ? "model_output" : "user_input"
|
|
4222
|
-
},
|
|
4223
|
-
content: {
|
|
4224
|
-
kind: "array",
|
|
4225
|
-
elements: [{
|
|
4226
|
-
kind: "object",
|
|
4227
|
-
properties: {
|
|
4228
|
-
type: {
|
|
4229
|
-
kind: "primitive",
|
|
4230
|
-
value: "text"
|
|
4231
|
-
},
|
|
4232
|
-
text: msg.content
|
|
4233
|
-
}
|
|
4234
|
-
}]
|
|
4235
|
-
}
|
|
4236
|
-
}
|
|
4237
|
-
}))
|
|
4238
|
-
};
|
|
4239
|
-
}
|
|
4240
|
-
const EMPTY_CONTENT = {
|
|
4241
|
-
kind: "primitive",
|
|
4242
|
-
value: ""
|
|
4243
|
-
};
|
|
4244
|
-
function extractContent(el) {
|
|
4245
|
-
if (el?.kind !== "object" || el.properties.type?.kind !== "primitive") return;
|
|
4246
|
-
switch (el.properties.type.value) {
|
|
4247
|
-
case "text": return {
|
|
4248
|
-
role: "user",
|
|
4249
|
-
content: el.properties.text ?? EMPTY_CONTENT
|
|
4250
|
-
};
|
|
4251
|
-
}
|
|
4252
|
-
}
|
|
4253
|
-
/**
|
|
4254
|
-
* Extract a {@link NormalizedMessage} array from the `input` PropValue.
|
|
4255
|
-
*
|
|
4256
|
-
* The `input` field can be:
|
|
4257
|
-
* - A primitive string (single user message)
|
|
4258
|
-
* - A single content object (e.g. `{type: 'text', text: '...'}`)
|
|
4259
|
-
* - An array of Step objects (https://ai.google.dev/api/interactions-api#Resource:Step)
|
|
4260
|
-
* - An array of Content objects (https://ai.google.dev/api/interactions-api#schema-example-Content-text)
|
|
4261
|
-
*
|
|
4262
|
-
* The Interactions API uses `"model"` for assistant messages; we translate
|
|
4263
|
-
* `"model"` → `"assistant"` on the way in.
|
|
4264
|
-
*/
|
|
4265
|
-
function extractMessages(value) {
|
|
4266
|
-
if (!value) return [];
|
|
4267
|
-
const content = extractContent(value);
|
|
4268
|
-
if (content) return [content];
|
|
4269
|
-
if (value.kind !== "array") return [{
|
|
4270
|
-
role: "user",
|
|
4271
|
-
content: value
|
|
4272
|
-
}];
|
|
4273
|
-
const results = [];
|
|
4274
|
-
for (const el of value.elements) {
|
|
4275
|
-
const content = extractContent(el);
|
|
4276
|
-
if (content) {
|
|
4277
|
-
results.push(content);
|
|
4278
|
-
continue;
|
|
4279
|
-
}
|
|
4280
|
-
if (el.kind !== "object" || el.properties.type?.kind !== "primitive") continue;
|
|
4281
|
-
switch (el.properties.type.value) {
|
|
4282
|
-
case "user_input":
|
|
4283
|
-
results.push(...extractMessages(el.properties.content));
|
|
4284
|
-
break;
|
|
4285
|
-
case "model_output":
|
|
4286
|
-
for (const msg of extractMessages(el.properties.content)) results.push({
|
|
4287
|
-
...msg,
|
|
4288
|
-
role: "assistant"
|
|
4289
|
-
});
|
|
4290
|
-
break;
|
|
4291
|
-
}
|
|
4292
|
-
}
|
|
4293
|
-
return results;
|
|
4294
|
-
}
|
|
4295
|
-
//#endregion
|
|
4296
3959
|
//#region src/trace/memory-trace-provider.ts
|
|
4297
3960
|
/**
|
|
4298
3961
|
* In-memory {@link TraceProvider}, populated by one or more
|
|
@@ -4363,4 +4026,4 @@ var MemoryTraceProvider = class extends BaseTraceProvider {
|
|
|
4363
4026
|
}
|
|
4364
4027
|
};
|
|
4365
4028
|
//#endregion
|
|
4366
|
-
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,
|
|
4029
|
+
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, 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, 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 };
|