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.
- package/LICENSING.md +26 -44
- package/README.md +11 -11
- package/dist/{check-CR4fU1S5.d.ts → check-BKU5_IhU.d.ts} +18 -868
- package/dist/checks/index.d.ts +2 -1
- package/dist/cli/index.js +809 -372
- package/dist/client/assets/{DatasetView-BqSWI_pm.js → DatasetView-DZ2uLHKV.js} +12 -10
- package/dist/client/assets/{EvalRunView-CR6ZksSu.js → EvalRunView-T610dLVw.js} +1 -1
- package/dist/client/assets/{EvalView-JPEM5IY8.js → EvalView-Cae68vPB.js} +1 -1
- package/dist/client/assets/{data-grid-overlay-editor-B_nPhXKR.js → data-grid-overlay-editor-PtH7A6E4.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-dPpneB8R.js → highlighted-body-KPVGNVTW-CPtwvSJb.js} +1 -1
- package/dist/client/assets/{index-CwjMcK6S.js → index-BFH07Ynk.js} +147 -147
- package/dist/client/assets/index-KCv8AeiY.css +32 -0
- package/dist/client/assets/{number-overlay-editor-CRWFlaQs.js → number-overlay-editor-BbQhagHP.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/cost-fetching-trace-sink-Dz8gniQ6.js +262 -0
- package/dist/{dataset-types-Dqi5vVg-.d.ts → dataset-types-D-Fsbg8B.d.ts} +7 -247
- package/dist/index.d.ts +844 -1426
- package/dist/index.js +151 -480
- package/dist/ingest.d.ts +119 -0
- package/dist/ingest.js +3 -0
- package/dist/{trace-event-ingestor-BghQcCHe.js → local-database-trace-provider-87-WGqfS.js} +1976 -7362
- package/dist/{trace-DGj5oW7z.d.ts → trace-BLjFYF9G.d.ts} +2 -1
- package/dist/trace-event-ingestor-B1DYEg2H.js +798 -0
- package/dist/trace-event-ingestor-JNpe-OrX.d.ts +109 -0
- 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 +32 -30
- package/dist/client/assets/index-BGcZZetP.css +0 -32
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { $ as FieldValues, $t as ValueCatalogGroup, A as DatasetRowsOverview, An as TraceCheckResult, At as SpanImagePart, B as AnnotationEvent, Bt as TraceChangeEvent, C as DatasetFieldShape, Cn as EvalRunProgress, Ct as ResourceInfo, D as DatasetRow, Dn as EvalTraceRun, Dt as SourceSpan, E as DatasetProviderInfo, En as EvalSummary, Et as RunResources, F as KnownColumnSpec, Ft as SpanTextPart, G as ChangeEventType, Gt as TraceLiveEvent, H as AnnotationKind, Ht as TraceEvalRun, I as AddPromptContext, It as SpanToolCallPart, J as ConflictChoices, Jt as TraceStreamEvent, K as ChatPromptUpdates, Kt as TraceProviderInfo, L as AddPromptField, Lt as SpanToolResultPart, M as ColumnPath, Mt as SpanMessage, N as DatasetColumnSpec, Nt as SpanMessageRole, O as DatasetRowSource, On as NewEvalDefinition, Ot as Span, P as ForeignColumnSpec, Pt as SpanReasoningPart, Q as ExtractedProps, Qt as ValueCatalog, R as Annotation, Rt as ToolSpanDetails, S as DatasetField, Sn as EvalRun, St as RebaseResult, T as DatasetPathChild, Tn as EvalRunSummary, Tt as ResourceScope, U as AnnotationSource, Ut as TraceGroup$1, V as AnnotationEventOp, Vt as TraceChangeType, W as CalleeBinding, Wt as TraceGroupQuery$1, X as ExecuteResponse, Xt as TraceWithSpans, Y as ExecuteRequest, Yt as TraceSummary, Z as ExecutionInput, Zt as UpdatePromptResponse, _ as isStandardSchema, _n as EvalInputs, _t as PromptStyle, a as check, an as VersionId, at as NormalizedPrompt, b as DatasetChangeEvent, bn as EvalRowResult, bt as PropValue, c as ResolvedResourceInputs, cn as EvalArmSpec, ct as NormalizedQuestionsPrompt, d as ResourceInput, dn as EvalCheck, dt as PendingConflicts, en as ValueCatalogPreset, et as InputLayout, f as ResourceInputs, fn as EvalCheckOutcome, ft as PromptChangeEvent, g as isResource, gn as EvalDefinitionPatch, gt as PromptRef, h as StaticResourceDefinition, hn as EvalDefinition, ht as PromptProviderInfo, i as CheckRun, in as VariationInfo, it as NormalizedParameter, j as DatasetSummary, jt as SpanKind, k as DatasetRowUpdate, kn as NewEvalRun, kt as SpanContentPart, l as Resource, ln as EvalChangeEvent, lt as NormalizedToolCall, m as ResourceOutputDefinition, mn as EvalCounts, mt as PromptInputSources, n as CheckDefinition, nn as VariationConflict, nt as NormalizedChatPrompt, o as isCheck, on as VersionInfo, ot as NormalizedPromptBase, p as ResourceInstance, pn as EvalCheckResult, pt as PromptID, q as CheckInfo, qt as TraceQuery$1, r as CheckOutcome, rn as VariationId, rt as NormalizedMessage, s as DynamicResourceDefinition, sn as EvalArm, st as NormalizedPromptUpdates, t as Check, tn as ValueFactory, tt as LLMSpanDetails, u as ResourceDefinition, un as EvalChangeType, ut as ParsedPrompt, v as resource, vn as EvalProviderInfo, vt as PropDefinition, w as DatasetInstanceShape, wn as EvalRunStatus, wt as ResourceInstanceInput, x as DatasetChangeType, xn as EvalRowStatus, xt as QuestionsPromptUpdates, y as Dataset, yn as EvalResults, yt as PropType, z as AnnotationChanges, zt as Trace } from "./check-BKU5_IhU.js";
|
|
2
|
+
import { a as NormalizedOtlpEvent, i as decodeOtlpProtobuf, n as mergeSpans, o as NormalizedOtlpSpan, r as OtlpTraceIngestor, s as normalizeOtlpRequest, t as TraceEventIngestor } from "./trace-event-ingestor-JNpe-OrX.js";
|
|
3
|
+
import { Tracer } from "@opentelemetry/api";
|
|
4
|
+
import { PropDefinition as PropDefinition$1, PropValue as PropValue$1 } from "ts-proppy";
|
|
5
|
+
import { Annotation as Annotation$1, AnnotationChanges as AnnotationChanges$1, AnnotationEvent as AnnotationEvent$1, AnnotationEventOp as AnnotationEventOp$1, BaseTraceIngestor, BaseTraceIngestor as BaseTraceIngestor$1, CHECK_ATTRIBUTE, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, Evalution, Evalution as Evalution$1, EvalutionOptions, HttpTraceSink, HttpTraceSinkOptions, HttpTraceTarget, PLAYGROUND_ENVIRONMENT, PLAYGROUND_RESOURCE, PROMPT_ID_ATTRIBUTE, PROMPT_INPUTS_ATTRIBUTE, PROMPT_NAME_ATTRIBUTE, PROMPT_PROVIDER_ID_ATTRIBUTE, PROMPT_VARIATION_ATTRIBUTE, PROMPT_VERSION_ATTRIBUTE, PromptID as PromptID$1, PromptSpanInfo, PromptsFactory, PromptsHelper, PromptsHelperOptions, SERVICE_NAME_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, Span as Span$1, SyncDatabaseCredentials, SyncDatabaseKey, TRACE_EVENTS_PATH, Trace as Trace$1, TraceChangeEvent as TraceChangeEvent$1, TraceEventsRequest, TraceGroup, TraceGroupQuery, TraceIngestor, TraceIngestor as TraceIngestor$1, TraceQuery, TraceSink, TraceSink as TraceSink$1, TraceSinkEvent, TraceStreamEvent as TraceStreamEvent$1, TraceSummary as TraceSummary$1, TraceWithSpans as TraceWithSpans$1, createTracerForPrompt, getPromptSpanAttributes, isCheckSpan, mergePromptIdentity, spanMessages } from "@evalution/sdk";
|
|
4
6
|
import { Database } from "@tursodatabase/sync";
|
|
5
7
|
import { migrateAsync } from "drizzle-orm/sqlite-core/async/session";
|
|
8
|
+
import { ExecuteConfigOptions, ExecutionHandle, FactoriesProbe, ProbeResult, ProbeResult as ProbeResult$1, ProbeResults, ProbeResults as ProbeResults$1, SDKAdapter, SDKAdapter as SDKAdapter$1, TypeExpressionProbe, TypeProbe, TypeProbe as TypeProbe$1, assertUpdateStyle } from "@evalution/sdk/adapter";
|
|
6
9
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
10
|
import { MigrationMeta } from "drizzle-orm/migrator";
|
|
8
|
-
import { Questions, SystemOneRequest, SystemOneResult } from "@typesafe-ai/sdk";
|
|
9
|
-
import { Telemetry } from "ai";
|
|
10
11
|
import { SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
11
12
|
|
|
12
13
|
//#region src/cli/fresh-import-hook.d.ts
|
|
@@ -96,7 +97,7 @@ interface CreateDatasetInput {
|
|
|
96
97
|
/** The schema. Ids are minted by the provider. */
|
|
97
98
|
fields: Omit<DatasetField, "id">[];
|
|
98
99
|
/** The prompt this dataset is created from, if any. */
|
|
99
|
-
prompt?: PromptID;
|
|
100
|
+
prompt?: PromptID$1;
|
|
100
101
|
}
|
|
101
102
|
/**
|
|
102
103
|
* Which rows {@link DatasetProvider.listRows} returns: a window onto the
|
|
@@ -312,417 +313,6 @@ interface EvalProvider {
|
|
|
312
313
|
watch?(callback: (event: EvalChangeEvent) => void): () => void;
|
|
313
314
|
}
|
|
314
315
|
//#endregion
|
|
315
|
-
//#region src/trace/prompt-tracer.d.ts
|
|
316
|
-
interface PromptsHelperOptions {
|
|
317
|
-
/**
|
|
318
|
-
* Globally-unique stable identifier for this group of prompts.
|
|
319
|
-
*/
|
|
320
|
-
readonly id: string;
|
|
321
|
-
}
|
|
322
|
-
type PromptsFactory<Args extends any[] = never[], Prompt = unknown> = (...args: Args) => Record<string, (...args: any[]) => Prompt>;
|
|
323
|
-
/**
|
|
324
|
-
* Intended to be used in the `satisfies` clause of a `prompts` export from an
|
|
325
|
-
* SDK adapter package.
|
|
326
|
-
*/
|
|
327
|
-
type PromptsHelper = (opts: PromptsHelperOptions, factory: PromptsFactory<any[], any>) => PromptsFactory<any[], any>;
|
|
328
|
-
/**
|
|
329
|
-
* Attribute name a span can set to pick one of evalution's span-kind values
|
|
330
|
-
* (`'LLM'`, `'TOOL'`, `'AGENT'`, `'EMBEDDING'`, `'DEFAULT'`). Falls back to
|
|
331
|
-
* `'DEFAULT'` when absent or unrecognised.
|
|
332
|
-
*/
|
|
333
|
-
declare const SPAN_KIND_ATTRIBUTE = "evalution.span.type";
|
|
334
|
-
/**
|
|
335
|
-
* Attribute name a span can set to give a human-readable name to the prompt.
|
|
336
|
-
*/
|
|
337
|
-
declare const PROMPT_NAME_ATTRIBUTE = "gen_ai.prompt.name";
|
|
338
|
-
/**
|
|
339
|
-
* Attribute name a span can set to link itself to a specific prompt. The value
|
|
340
|
-
* is a globally-unique prompt ID unless {@link PROMPT_PROVIDER_ID_ATTRIBUTE} is
|
|
341
|
-
* also set, in which case it is scoped to that provider.
|
|
342
|
-
*/
|
|
343
|
-
declare const PROMPT_ID_ATTRIBUTE = "evalution.prompt.id";
|
|
344
|
-
/**
|
|
345
|
-
* Attribute name a span can set to scope its {@link PROMPT_ID_ATTRIBUTE} to a
|
|
346
|
-
* specific prompt provider. When absent, the prompt ID is treated as global.
|
|
347
|
-
*/
|
|
348
|
-
declare const PROMPT_PROVIDER_ID_ATTRIBUTE = "evalution.prompt.provider.id";
|
|
349
|
-
/**
|
|
350
|
-
* Attribute name a span can set to include an array of input parameters used
|
|
351
|
-
* to construct the final prompt.
|
|
352
|
-
*/
|
|
353
|
-
declare const PROMPT_INPUTS_ATTRIBUTE = "evalution.prompt.inputs";
|
|
354
|
-
/**
|
|
355
|
-
* Attribute name a span can set to record which version of its prompt ran —
|
|
356
|
-
* for a file-based prompt, the commit checked out, when nothing was
|
|
357
|
-
* uncommitted.
|
|
358
|
-
*/
|
|
359
|
-
declare const PROMPT_VERSION_ATTRIBUTE = "evalution.prompt.version";
|
|
360
|
-
/**
|
|
361
|
-
* Attribute name a span can set to record which variation of its prompt ran,
|
|
362
|
-
* on top of its {@link PROMPT_VERSION_ATTRIBUTE}.
|
|
363
|
-
*/
|
|
364
|
-
declare const PROMPT_VARIATION_ATTRIBUTE = "evalution.prompt.variation";
|
|
365
|
-
interface PromptSpanInfo {
|
|
366
|
-
/** Globally-unique prompt id (e.g. `${groupId}#${name}`). */
|
|
367
|
-
id?: string;
|
|
368
|
-
/** Human-readable prompt name. */
|
|
369
|
-
name: string;
|
|
370
|
-
/**
|
|
371
|
-
* Positional arguments the prompt function was called with.
|
|
372
|
-
*
|
|
373
|
-
* Only the `prompts()` helper records these, because it is the only caller
|
|
374
|
-
* that sees the arguments and nothing else. A playground run records
|
|
375
|
-
* {@link functionInputs} instead: its arguments may include a live database
|
|
376
|
-
* handle, which is neither serializable nor the thing a replay needs.
|
|
377
|
-
*/
|
|
378
|
-
functionParameters?: unknown[];
|
|
379
|
-
/**
|
|
380
|
-
* The unresolved inputs this run was launched with — the *recipe* rather
|
|
381
|
-
* than the resolution.
|
|
382
|
-
*
|
|
383
|
-
* This is what makes a past run replayable. A resolved value cannot be
|
|
384
|
-
* recorded faithfully (a live handle does not serialize) and would not be
|
|
385
|
-
* the right thing to record anyway: replaying a resource means running its
|
|
386
|
-
* `create()` again, which is the recipe, not the value it produced last
|
|
387
|
-
* time. Each entry is JSON-safe by construction.
|
|
388
|
-
*/
|
|
389
|
-
functionInputs?: unknown[];
|
|
390
|
-
/** The unresolved execute-parameter inputs, keyed by parameter name. */
|
|
391
|
-
executeInputs?: Record<string, unknown>;
|
|
392
|
-
/**
|
|
393
|
-
* The run's named resource instances, by name, each with the receipt its
|
|
394
|
-
* `create()` produced. See `specs/resource-instances.md` §F.
|
|
395
|
-
*/
|
|
396
|
-
resources?: Record<string, unknown>;
|
|
397
|
-
/**
|
|
398
|
-
* The prompt's parameter definitions as they stood when the run was
|
|
399
|
-
* launched, recorded beside the inputs.
|
|
400
|
-
*
|
|
401
|
-
* For a file-based prompt git is the version, and the playground has no
|
|
402
|
-
* business checking out old commits to replay one — so writing the shape
|
|
403
|
-
* down at run time is the cheap equivalent. A later replay diffs two known
|
|
404
|
-
* signatures instead of guessing whether the recorded inputs still fit.
|
|
405
|
-
*/
|
|
406
|
-
parameterDefinitions?: unknown[];
|
|
407
|
-
/**
|
|
408
|
-
* The prompt's execute-parameter definitions, recorded for the same reason
|
|
409
|
-
* as {@link parameterDefinitions}: without them an entry of
|
|
410
|
-
* {@link executeInputs} has a name but no type.
|
|
411
|
-
*/
|
|
412
|
-
executeParameterDefinitions?: unknown[];
|
|
413
|
-
/** The version the run executed against. See {@link PROMPT_VERSION_ATTRIBUTE}. */
|
|
414
|
-
version?: string;
|
|
415
|
-
/** The variation the run applied. See {@link PROMPT_VARIATION_ATTRIBUTE}. */
|
|
416
|
-
variation?: string;
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* `identity` with any field it leaves unset filled from `fallback`.
|
|
420
|
-
*
|
|
421
|
-
* A config built by the `prompts()` helper carries an identity of its own —
|
|
422
|
-
* the one to keep, since its id is the global one — but only the playground
|
|
423
|
-
* knows what the run was launched with and against which version.
|
|
424
|
-
*/
|
|
425
|
-
declare function mergePromptIdentity(identity: PromptSpanInfo | undefined, fallback: PromptSpanInfo | undefined): PromptSpanInfo | undefined;
|
|
426
|
-
/**
|
|
427
|
-
* Build the attributes that associate a span with a prompt.
|
|
428
|
-
*
|
|
429
|
-
* @param prompt - The prompt to attribute the span to.
|
|
430
|
-
* @param attributes - Attributes to merge in; these take precedence.
|
|
431
|
-
* @param includeInputs - Whether to stamp the run's inputs. Inputs belong on
|
|
432
|
-
* the **root span only**: they are identical on every span of a trace, so
|
|
433
|
-
* repeating them is invisible when the input is `["Ada"]` and wasteful when
|
|
434
|
-
* it is a fifty-message thread — multiplied by span count, then persisted.
|
|
435
|
-
*/
|
|
436
|
-
declare function getPromptSpanAttributes(prompt: PromptSpanInfo, attributes?: Attributes, includeInputs?: boolean): Record<string, AttributeValue>;
|
|
437
|
-
/**
|
|
438
|
-
* Wraps a {@link Tracer} so that every span it produces is tagged with the
|
|
439
|
-
* attributes that associate it with a prompt — the prompt's name
|
|
440
|
-
* ({@link PROMPT_NAME_ATTRIBUTE}), an optional global prompt ID
|
|
441
|
-
* ({@link PROMPT_ID_ATTRIBUTE}), and an `'LLM'` span kind
|
|
442
|
-
* ({@link SPAN_KIND_ATTRIBUTE}). Attributes set explicitly on an individual
|
|
443
|
-
* span take precedence over these defaults.
|
|
444
|
-
*
|
|
445
|
-
* This depends only on `@opentelemetry/api`, so it can be re-used by SDK
|
|
446
|
-
* adapter packages (e.g. `@evalution/vercel-ai-sdk`) without pulling in the
|
|
447
|
-
* rest of evalution.
|
|
448
|
-
*
|
|
449
|
-
* @param prompt - The prompt to attribute spans to. `name` is a human-readable
|
|
450
|
-
* name; the optional `id` is a globally-unique prompt ID used to resolve
|
|
451
|
-
* runtime traces back to the prompt.
|
|
452
|
-
* @param tracer - Tracer to wrap. Defaults to a tracer from the globally
|
|
453
|
-
* registered tracer provider.
|
|
454
|
-
* @returns A tracer that forwards to `tracer` while attaching the prompt
|
|
455
|
-
* attributes to each span it creates.
|
|
456
|
-
*/
|
|
457
|
-
declare function createTracerForPrompt(prompt: PromptSpanInfo, tracer?: Tracer): Tracer;
|
|
458
|
-
//#endregion
|
|
459
|
-
//#region src/trace/trace-provider.d.ts
|
|
460
|
-
/**
|
|
461
|
-
* A read-only store of execution traces that the playground can display and
|
|
462
|
-
* subscribe to in real time. Implement this interface to integrate a tracing
|
|
463
|
-
* backend.
|
|
464
|
-
*
|
|
465
|
-
* `TraceProvider` is a pure read interface — populating the store is the job
|
|
466
|
-
* of a `TraceIngestor`, which feeds normalized spans into the provider's
|
|
467
|
-
* write side (`TraceSink`, implemented by `BaseTraceProvider`).
|
|
468
|
-
*/
|
|
469
|
-
interface TraceProvider {
|
|
470
|
-
/**
|
|
471
|
-
* Uniquely identifies this instance, even when multiple providers of the
|
|
472
|
-
* same type are used.
|
|
473
|
-
*/
|
|
474
|
-
readonly id: string;
|
|
475
|
-
/** Human-readable name shown when choosing between providers. */
|
|
476
|
-
readonly displayName?: string;
|
|
477
|
-
/** Short description of what this provider offers. */
|
|
478
|
-
readonly description?: string;
|
|
479
|
-
/**
|
|
480
|
-
* Returns compact summaries for every trace known to this provider, newest
|
|
481
|
-
* first. Used to populate the Traces sidebar.
|
|
482
|
-
*/
|
|
483
|
-
getAllTraces(): Promise<TraceSummary[]>;
|
|
484
|
-
/**
|
|
485
|
-
* Returns the trace with the given ID together with all of its spans, or
|
|
486
|
-
* `undefined` when the trace is unknown.
|
|
487
|
-
*/
|
|
488
|
-
getTrace(traceId: string): Promise<TraceWithSpans | undefined>;
|
|
489
|
-
/**
|
|
490
|
-
* Subscribes to real-time updates for a specific trace. The callback is
|
|
491
|
-
* invoked for every {@link Span} change on this trace, for as long as the
|
|
492
|
-
* returned cleanup function has not been called.
|
|
493
|
-
*
|
|
494
|
-
* Optional — providers that cannot track live changes may omit it.
|
|
495
|
-
*
|
|
496
|
-
* @returns A no-argument function that cancels the subscription.
|
|
497
|
-
*/
|
|
498
|
-
subscribeTrace?(traceId: string, callback: (event: TraceStreamEvent) => void): () => void;
|
|
499
|
-
/**
|
|
500
|
-
* Registers a callback invoked whenever a trace is added, updated, or
|
|
501
|
-
* removed. Used by the sidebar to stay in sync without polling.
|
|
502
|
-
*
|
|
503
|
-
* Optional — providers that cannot detect live changes may omit it.
|
|
504
|
-
*
|
|
505
|
-
* @returns A no-argument function that unregisters the watcher.
|
|
506
|
-
*/
|
|
507
|
-
watch?(callback: (event: TraceChangeEvent) => void): () => void;
|
|
508
|
-
/**
|
|
509
|
-
* Permanently deletes a trace along with its spans and annotations, and
|
|
510
|
-
* notifies {@link watch}ers with a `remove` event. Returns `false` if the trace
|
|
511
|
-
* doesn't exist.
|
|
512
|
-
*
|
|
513
|
-
* Optional — a provider backed by a read-only source omits it, and the REST
|
|
514
|
-
* route in `src/server/api-routes.ts` treats its absence as "not
|
|
515
|
-
* supported" (405).
|
|
516
|
-
*/
|
|
517
|
-
deleteTrace?(traceId: string): Promise<boolean>;
|
|
518
|
-
/**
|
|
519
|
-
* Runs one read-only SQL query (a `SELECT`) against this provider's
|
|
520
|
-
* store and returns the rows — the ad-hoc counterpart to
|
|
521
|
-
* {@link getAllTraces}, for questions a summary can't answer. The schema the
|
|
522
|
-
* query is written against is {@link getQuerySchema}'s. Writes are refused.
|
|
523
|
-
*
|
|
524
|
-
* Optional — a provider not backed by SQL omits it, and the REST and MCP
|
|
525
|
-
* handlers report "not supported".
|
|
526
|
-
*/
|
|
527
|
-
query?(sql: string, options?: SqlQueryOptions): Promise<SqlQueryResult>;
|
|
528
|
-
/**
|
|
529
|
-
* Describes the tables {@link query} runs against, as annotated SQL DDL.
|
|
530
|
-
* Present exactly when {@link query} is.
|
|
531
|
-
*/
|
|
532
|
-
getQuerySchema?(): string;
|
|
533
|
-
/** Lists every annotation on a trace, oldest first. */
|
|
534
|
-
listAnnotations?(traceId: string): Promise<Annotation[]>;
|
|
535
|
-
/** Creates a new annotation, minting its `id`/`createdAt`. */
|
|
536
|
-
createAnnotation?(input: Omit<Annotation, "id" | "createdAt">): Promise<Annotation>;
|
|
537
|
-
/**
|
|
538
|
-
* Changes an annotation's `kind` and/or `note`, returning it as updated, or
|
|
539
|
-
* `undefined` if it doesn't exist.
|
|
540
|
-
*/
|
|
541
|
-
updateAnnotation?(id: string, changes: AnnotationChanges): Promise<Annotation | undefined>;
|
|
542
|
-
/** Deletes an annotation by id. A no-op if it doesn't exist. */
|
|
543
|
-
deleteAnnotation?(id: string): Promise<void>;
|
|
544
|
-
/**
|
|
545
|
-
* Subscribes to annotation changes on a specific trace — the counterpart
|
|
546
|
-
* to {@link subscribeTrace} that a client's per-trace SSE connection also
|
|
547
|
-
* opens, so both ride the same stream. Callers (the annotation REST
|
|
548
|
-
* handlers) invoke {@link emitAnnotation} after a successful
|
|
549
|
-
* create/update/delete; this only delivers what's explicitly emitted.
|
|
550
|
-
*
|
|
551
|
-
* @returns A no-argument function that cancels the subscription.
|
|
552
|
-
*/
|
|
553
|
-
subscribeAnnotations?(traceId: string, callback: (event: AnnotationEvent) => void): () => void;
|
|
554
|
-
/**
|
|
555
|
-
* Notifies this trace's {@link subscribeAnnotations} subscribers of an
|
|
556
|
-
* annotation change, and {@link watch}ers with an `update` event, since a
|
|
557
|
-
* trace's summary carries its annotation counts. Called by the annotation
|
|
558
|
-
* REST handlers immediately after
|
|
559
|
-
* {@link createAnnotation}/{@link updateAnnotation}/{@link deleteAnnotation}
|
|
560
|
-
* succeeds — the provider itself never calls this on its own.
|
|
561
|
-
*/
|
|
562
|
-
emitAnnotation?(traceId: string, op: AnnotationEventOp, annotation: Annotation): void;
|
|
563
|
-
}
|
|
564
|
-
//#endregion
|
|
565
|
-
//#region src/trace/trace-sink.d.ts
|
|
566
|
-
/**
|
|
567
|
-
* The write side of a {@link TraceProvider}. A {@link TraceIngestor} feeds
|
|
568
|
-
* normalized spans in; the sink owns root detection, trace creation, and
|
|
569
|
-
* event emission.
|
|
570
|
-
*/
|
|
571
|
-
interface TraceSink {
|
|
572
|
-
/**
|
|
573
|
-
* Records a span start. Creates a `running` trace for a new root. Returns
|
|
574
|
-
* the stored (merged) span. Emits `span-start` (+ watch `add` for a new
|
|
575
|
-
* trace).
|
|
576
|
-
*/
|
|
577
|
-
recordSpanStart(span: Span): Promise<Span>;
|
|
578
|
-
/**
|
|
579
|
-
* Records a span end. For a root span, finalizes the trace and emits
|
|
580
|
-
* `trace-end` (+ watch `update`). Returns the stored (merged) span.
|
|
581
|
-
*/
|
|
582
|
-
recordSpanEnd(span: Span): Promise<Span>;
|
|
583
|
-
/**
|
|
584
|
-
* Finalizes a trace as `error` when execution fails before any span is
|
|
585
|
-
* produced (e.g. a bad model id throws before `onStart`).
|
|
586
|
-
*/
|
|
587
|
-
failTrace(traceId: string, errorMessage: string): Promise<void>;
|
|
588
|
-
/**
|
|
589
|
-
* Optional: resolves once everything recorded so far has been delivered,
|
|
590
|
-
* for a sink that records in the background (e.g. `HttpTraceSink`).
|
|
591
|
-
*/
|
|
592
|
-
flush?(): Promise<void>;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Source-agnostic base class for a {@link TraceProvider}. Owns storage
|
|
596
|
-
* delegation, subscriptions, watchers, and the generic trace lifecycle that
|
|
597
|
-
* every concrete provider shares, regardless of how spans are produced.
|
|
598
|
-
*
|
|
599
|
-
* Subclasses implement the abstract storage hooks; ingestion is handled by
|
|
600
|
-
* one or more {@link TraceIngestor}s that call {@link recordSpanStart} /
|
|
601
|
-
* {@link recordSpanEnd} / {@link failTrace} on this instance (via
|
|
602
|
-
* {@link TraceSink}).
|
|
603
|
-
*/
|
|
604
|
-
declare abstract class BaseTraceProvider implements TraceProvider, TraceSink {
|
|
605
|
-
readonly id: string;
|
|
606
|
-
readonly displayName?: string;
|
|
607
|
-
readonly description?: string;
|
|
608
|
-
protected subscribers: Map<string, Set<(event: TraceStreamEvent) => void>>;
|
|
609
|
-
private watchers;
|
|
610
|
-
private annotationSubscribers;
|
|
611
|
-
constructor(options: {
|
|
612
|
-
id: string;
|
|
613
|
-
displayName: string;
|
|
614
|
-
description: string;
|
|
615
|
-
});
|
|
616
|
-
abstract getAllTraces(): Promise<TraceSummary[]>;
|
|
617
|
-
abstract hasTrace(traceId: string): Promise<boolean>;
|
|
618
|
-
protected abstract getTraceWithoutSpans(traceId: string): Promise<Trace | undefined>;
|
|
619
|
-
protected abstract getTraceSpans(traceId: string): Promise<Span[]>;
|
|
620
|
-
protected abstract addOrUpdateTrace(trace: Trace): Promise<void>;
|
|
621
|
-
/**
|
|
622
|
-
* Removes a trace together with its spans and annotations. Only called for
|
|
623
|
-
* a trace that {@link hasTrace} confirmed exists.
|
|
624
|
-
*/
|
|
625
|
-
protected abstract removeTrace(traceId: string): Promise<void>;
|
|
626
|
-
/**
|
|
627
|
-
* Stores a span, merging it into any existing span with the same ID (via
|
|
628
|
-
* the `mergeSpans` helper). Returns the resulting stored span so callers
|
|
629
|
-
* can stream the merged view rather than the partial snapshot they passed
|
|
630
|
-
* in.
|
|
631
|
-
*/
|
|
632
|
-
protected abstract addOrUpdateSpan(span: Span): Promise<Span>;
|
|
633
|
-
getTrace(traceId: string): Promise<TraceWithSpans | undefined>;
|
|
634
|
-
deleteTrace(traceId: string): Promise<boolean>;
|
|
635
|
-
subscribeTrace(traceId: string, callback: (event: TraceStreamEvent) => void): () => void;
|
|
636
|
-
watch(callback: (event: TraceChangeEvent) => void): () => void;
|
|
637
|
-
/**
|
|
638
|
-
* Generic pub-sub for annotation changes — every subclass gets a working
|
|
639
|
-
* implementation "for free", even one with no annotation store of its own
|
|
640
|
-
* (e.g. `MemoryTraceProvider`): nothing is ever delivered unless a caller
|
|
641
|
-
* (the annotation REST handlers) explicitly calls {@link emitAnnotation}.
|
|
642
|
-
*/
|
|
643
|
-
subscribeAnnotations(traceId: string, callback: (event: AnnotationEvent) => void): () => void;
|
|
644
|
-
emitAnnotation(traceId: string, op: AnnotationEventOp, annotation: Annotation): void;
|
|
645
|
-
recordSpanStart(span: Span): Promise<Span>;
|
|
646
|
-
recordSpanEnd(span: Span): Promise<Span>;
|
|
647
|
-
/**
|
|
648
|
-
* Marks a trace that already ended as running again: its root span has just
|
|
649
|
-
* been started anew (a failed run being retried), so the failure it recorded
|
|
650
|
-
* is no longer its state.
|
|
651
|
-
*/
|
|
652
|
-
private reopenTrace;
|
|
653
|
-
failTrace(traceId: string, errorMessage: string): Promise<void>;
|
|
654
|
-
protected emitStream(traceId: string, event: TraceStreamEvent): void;
|
|
655
|
-
protected emitChange(event: TraceChangeEvent): void;
|
|
656
|
-
}
|
|
657
|
-
//#endregion
|
|
658
|
-
//#region src/trace/trace-ingestor.d.ts
|
|
659
|
-
/**
|
|
660
|
-
* A source of trace data. Translates some upstream signal (OTel spans, native
|
|
661
|
-
* AI SDK telemetry, an external collector) into normalized {@link Span}s and
|
|
662
|
-
* feeds the {@link TraceSink}(s) it is connected to.
|
|
663
|
-
*/
|
|
664
|
-
interface TraceIngestor {
|
|
665
|
-
/**
|
|
666
|
-
* Add a sink. May be called multiple times; the ingestor writes to every
|
|
667
|
-
* added sink.
|
|
668
|
-
*/
|
|
669
|
-
addSink(sink: TraceSink): void;
|
|
670
|
-
/**
|
|
671
|
-
* Remove a previously-added sink. Returns `true` if the given sink was found
|
|
672
|
-
* and removed, otherwise `false`.
|
|
673
|
-
*/
|
|
674
|
-
removeSink(sink: TraceSink): boolean;
|
|
675
|
-
/**
|
|
676
|
-
* Optional: returns true if `other` is made redundant by this ingestor and
|
|
677
|
-
* should be excluded from the collected set. The decision may depend on
|
|
678
|
-
* this ingestor's own configuration. Used by the server to consolidate
|
|
679
|
-
* overlapping ingestors — e.g. `OTelTraceIngestor` reports any other
|
|
680
|
-
* `OTelTraceIngestor` redundant because OTel is a single process-global
|
|
681
|
-
* pipeline.
|
|
682
|
-
*/
|
|
683
|
-
isRedundant?(other: TraceIngestor): boolean;
|
|
684
|
-
/**
|
|
685
|
-
* Optional: sets the resource attributes merged into every span this
|
|
686
|
-
* ingestor records from now on, over whatever resource the source itself
|
|
687
|
-
* reported. The server stamps {@link PLAYGROUND_RESOURCE} on the ingestors
|
|
688
|
-
* that record its own runs.
|
|
689
|
-
*/
|
|
690
|
-
setResource?(resource: Record<string, unknown>): void;
|
|
691
|
-
}
|
|
692
|
-
/**
|
|
693
|
-
* The resource of every run evalution itself makes — from the playground, an
|
|
694
|
-
* eval, or an MCP client — as opposed to one an app exported to it.
|
|
695
|
-
*/
|
|
696
|
-
declare const PLAYGROUND_RESOURCE: Readonly<Record<string, string>>;
|
|
697
|
-
/**
|
|
698
|
-
* Base class that holds the added sinks and fans each normalized record out
|
|
699
|
-
* to all of them. Concrete ingestors translate their source into
|
|
700
|
-
* {@link Span}/{@link Trace} records and call these protected helpers.
|
|
701
|
-
*/
|
|
702
|
-
declare abstract class BaseTraceIngestor implements TraceIngestor {
|
|
703
|
-
protected sinks: TraceSink[];
|
|
704
|
-
private resource?;
|
|
705
|
-
/** Recordings still under way, which {@link flush} waits out. */
|
|
706
|
-
private pending;
|
|
707
|
-
setResource(resource: Record<string, unknown>): void;
|
|
708
|
-
/** `span` with this ingestor's resource, if it has one, merged into its own. */
|
|
709
|
-
private withResource;
|
|
710
|
-
addSink(sink: TraceSink): void;
|
|
711
|
-
removeSink(sink: TraceSink): boolean;
|
|
712
|
-
/**
|
|
713
|
-
* Resolves once everything recorded so far has reached every sink and been
|
|
714
|
-
* delivered by those that deliver in the background. Await it before a
|
|
715
|
-
* short-lived process (a script, a serverless function) exits, so no trace
|
|
716
|
-
* data is lost.
|
|
717
|
-
*/
|
|
718
|
-
flush(): Promise<void>;
|
|
719
|
-
/** Registers `recording` for {@link flush} to wait out, and returns it. */
|
|
720
|
-
private track;
|
|
721
|
-
protected recordSpanStart(span: Span): Promise<void>;
|
|
722
|
-
protected recordSpanEnd(span: Span): Promise<void>;
|
|
723
|
-
protected failTrace(traceId: string, msg: string): Promise<void>;
|
|
724
|
-
}
|
|
725
|
-
//#endregion
|
|
726
316
|
//#region src/shared/input-references.d.ts
|
|
727
317
|
/**
|
|
728
318
|
* One place an input can be plugged in: a prompt's parameter, or any slot
|
|
@@ -1677,7 +1267,7 @@ interface PromptProvider<TPrompt extends NormalizedPrompt = NormalizedPrompt> {
|
|
|
1677
1267
|
*
|
|
1678
1268
|
* Optional — providers with no tracing support may omit it.
|
|
1679
1269
|
*/
|
|
1680
|
-
setupTraceIngestion?(): Promise<TraceIngestor | undefined>;
|
|
1270
|
+
setupTraceIngestion?(): Promise<TraceIngestor$1 | undefined>;
|
|
1681
1271
|
/**
|
|
1682
1272
|
* Returns the definition of the model slot for this provider's underlying
|
|
1683
1273
|
* SDK, catalogs included, for prompts of the given style. See
|
|
@@ -1732,33 +1322,166 @@ interface PromptProvider<TPrompt extends NormalizedPrompt = NormalizedPrompt> {
|
|
|
1732
1322
|
readonly variations?: PromptVariations;
|
|
1733
1323
|
}
|
|
1734
1324
|
//#endregion
|
|
1735
|
-
//#region src/
|
|
1325
|
+
//#region src/trace/trace-provider.d.ts
|
|
1736
1326
|
/**
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
1739
|
-
*
|
|
1740
|
-
* of your project to customise how Evalution discovers and serves prompts
|
|
1741
|
-
* and traces.
|
|
1742
|
-
*
|
|
1743
|
-
* If no config file is found, Evalution will show an onboarding wizard
|
|
1744
|
-
* to help you create one.
|
|
1745
|
-
*
|
|
1746
|
-
* @example
|
|
1747
|
-
* ```ts
|
|
1748
|
-
* // .evalution/config.ts
|
|
1749
|
-
* import type { EvalutionConfig } from 'evalution';
|
|
1750
|
-
* import { FilePromptProvider, VercelAISDK } from 'evalution';
|
|
1327
|
+
* A read-only store of execution traces that the playground can display and
|
|
1328
|
+
* subscribe to in real time. Implement this interface to integrate a tracing
|
|
1329
|
+
* backend.
|
|
1751
1330
|
*
|
|
1752
|
-
*
|
|
1753
|
-
*
|
|
1754
|
-
*
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1331
|
+
* `TraceProvider` is a pure read interface — populating the store is the job
|
|
1332
|
+
* of a `TraceIngestor`, which feeds normalized spans into the provider's
|
|
1333
|
+
* write side (`TraceSink`, implemented by `BaseTraceProvider`).
|
|
1334
|
+
*/
|
|
1335
|
+
interface TraceProvider {
|
|
1336
|
+
/**
|
|
1337
|
+
* Uniquely identifies this instance, even when multiple providers of the
|
|
1338
|
+
* same type are used.
|
|
1339
|
+
*/
|
|
1340
|
+
readonly id: string;
|
|
1341
|
+
/** Human-readable name shown when choosing between providers. */
|
|
1342
|
+
readonly displayName?: string;
|
|
1343
|
+
/** Short description of what this provider offers. */
|
|
1344
|
+
readonly description?: string;
|
|
1345
|
+
/**
|
|
1346
|
+
* Returns compact summaries for every trace known to this provider, newest
|
|
1347
|
+
* first. Used to populate the Traces sidebar.
|
|
1348
|
+
*
|
|
1349
|
+
* With a `query`, only the traces it matches: `filterTraces` is the
|
|
1350
|
+
* reference for what that means. A provider with a store that can search
|
|
1351
|
+
* runs the query there; any other filters its summaries in memory. Filters
|
|
1352
|
+
* on `checks` never reach a provider, which doesn't know a trace's checks:
|
|
1353
|
+
* the server applies those itself.
|
|
1354
|
+
*/
|
|
1355
|
+
getAllTraces(query?: TraceQuery$1): Promise<TraceSummary[]>;
|
|
1356
|
+
/**
|
|
1357
|
+
* Returns the traces `query` matches as groups, one per value or bucket of
|
|
1358
|
+
* the column it groups by: `groupTraceSummaries` is the reference. Each
|
|
1359
|
+
* group's `filter`, added to the query's and passed to
|
|
1360
|
+
* {@link getAllTraces}, lists its traces.
|
|
1361
|
+
*
|
|
1362
|
+
* Optional. The server groups what {@link getAllTraces} returns for a
|
|
1363
|
+
* provider without it, which a provider that lists only its most recent
|
|
1364
|
+
* traces should improve on by counting every trace in its store.
|
|
1365
|
+
*/
|
|
1366
|
+
groupTraces?(query: TraceGroupQuery$1): Promise<TraceGroup$1[]>;
|
|
1367
|
+
/**
|
|
1368
|
+
* Returns the trace with the given ID together with all of its spans, or
|
|
1369
|
+
* `undefined` when the trace is unknown.
|
|
1370
|
+
*/
|
|
1371
|
+
getTrace(traceId: string): Promise<TraceWithSpans | undefined>;
|
|
1372
|
+
/**
|
|
1373
|
+
* Subscribes to real-time updates for a specific trace. The callback is
|
|
1374
|
+
* invoked for every {@link Span} change on this trace, for as long as the
|
|
1375
|
+
* returned cleanup function has not been called.
|
|
1376
|
+
*
|
|
1377
|
+
* Optional — providers that cannot track live changes may omit it.
|
|
1378
|
+
*
|
|
1379
|
+
* @returns A no-argument function that cancels the subscription.
|
|
1380
|
+
*/
|
|
1381
|
+
subscribeTrace?(traceId: string, callback: (event: TraceStreamEvent) => void): () => void;
|
|
1382
|
+
/**
|
|
1383
|
+
* Registers a callback invoked whenever a trace is added, updated, or
|
|
1384
|
+
* removed. Used by the sidebar to stay in sync without polling.
|
|
1385
|
+
*
|
|
1386
|
+
* Optional — providers that cannot detect live changes may omit it.
|
|
1387
|
+
*
|
|
1388
|
+
* @returns A no-argument function that unregisters the watcher.
|
|
1389
|
+
*/
|
|
1390
|
+
watch?(callback: (event: TraceChangeEvent) => void): () => void;
|
|
1391
|
+
/**
|
|
1392
|
+
* Permanently deletes a trace along with its spans and annotations, and
|
|
1393
|
+
* notifies {@link watch}ers with a `remove` event. Returns `false` if the trace
|
|
1394
|
+
* doesn't exist.
|
|
1395
|
+
*
|
|
1396
|
+
* Optional — a provider backed by a read-only source omits it, and the REST
|
|
1397
|
+
* route in `src/server/api-routes.ts` treats its absence as "not
|
|
1398
|
+
* supported" (405).
|
|
1399
|
+
*/
|
|
1400
|
+
deleteTrace?(traceId: string): Promise<boolean>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Runs one read-only SQL query (a `SELECT`) against this provider's
|
|
1403
|
+
* store and returns the rows — the ad-hoc counterpart to
|
|
1404
|
+
* {@link getAllTraces}, for questions a summary can't answer. The schema the
|
|
1405
|
+
* query is written against is {@link getQuerySchema}'s. Writes are refused.
|
|
1406
|
+
*
|
|
1407
|
+
* Optional — a provider not backed by SQL omits it, and the REST and MCP
|
|
1408
|
+
* handlers report "not supported".
|
|
1409
|
+
*/
|
|
1410
|
+
query?(sql: string, options?: SqlQueryOptions): Promise<SqlQueryResult>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Describes the tables {@link query} runs against, as annotated SQL DDL.
|
|
1413
|
+
* Present exactly when {@link query} is.
|
|
1414
|
+
*/
|
|
1415
|
+
getQuerySchema?(): string;
|
|
1416
|
+
/** Lists every annotation on a trace, oldest first. */
|
|
1417
|
+
listAnnotations?(traceId: string): Promise<Annotation[]>;
|
|
1418
|
+
/** Creates a new annotation, minting its `id`/`createdAt`. */
|
|
1419
|
+
createAnnotation?(input: Omit<Annotation, "id" | "createdAt">): Promise<Annotation>;
|
|
1420
|
+
/**
|
|
1421
|
+
* Changes an annotation's `kind` and/or `note`, returning it as updated, or
|
|
1422
|
+
* `undefined` if it doesn't exist.
|
|
1423
|
+
*/
|
|
1424
|
+
updateAnnotation?(id: string, changes: AnnotationChanges): Promise<Annotation | undefined>;
|
|
1425
|
+
/** Deletes an annotation by id. A no-op if it doesn't exist. */
|
|
1426
|
+
deleteAnnotation?(id: string): Promise<void>;
|
|
1427
|
+
/**
|
|
1428
|
+
* Subscribes to annotation changes on a specific trace — the counterpart
|
|
1429
|
+
* to {@link subscribeTrace} that a client's per-trace SSE connection also
|
|
1430
|
+
* opens, so both ride the same stream. Callers (the annotation REST
|
|
1431
|
+
* handlers) invoke {@link emitAnnotation} after a successful
|
|
1432
|
+
* create/update/delete; this only delivers what's explicitly emitted.
|
|
1433
|
+
*
|
|
1434
|
+
* @returns A no-argument function that cancels the subscription.
|
|
1435
|
+
*/
|
|
1436
|
+
subscribeAnnotations?(traceId: string, callback: (event: AnnotationEvent) => void): () => void;
|
|
1437
|
+
/**
|
|
1438
|
+
* Notifies this trace's {@link subscribeAnnotations} subscribers of an
|
|
1439
|
+
* annotation change, and {@link watch}ers with an `update` event, since a
|
|
1440
|
+
* trace's summary carries its annotation counts. Called by the annotation
|
|
1441
|
+
* REST handlers immediately after
|
|
1442
|
+
* {@link createAnnotation}/{@link updateAnnotation}/{@link deleteAnnotation}
|
|
1443
|
+
* succeeds — the provider itself never calls this on its own.
|
|
1444
|
+
*/
|
|
1445
|
+
emitAnnotation?(traceId: string, op: AnnotationEventOp, annotation: Annotation): void;
|
|
1446
|
+
}
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region src/config.d.ts
|
|
1449
|
+
/**
|
|
1450
|
+
* Top-level configuration for an Evalution instance.
|
|
1451
|
+
*
|
|
1452
|
+
* Place a default export of this type in `.evalution/config.ts` at the root
|
|
1453
|
+
* of your project to customise how Evalution discovers and serves prompts
|
|
1454
|
+
* and traces.
|
|
1455
|
+
*
|
|
1456
|
+
* If no config file is found, Evalution will show an onboarding wizard
|
|
1457
|
+
* to help you create one.
|
|
1458
|
+
*
|
|
1459
|
+
* @example
|
|
1460
|
+
* ```ts
|
|
1461
|
+
* // .evalution/config.ts
|
|
1462
|
+
* import type { EvalutionConfig } from 'evalution';
|
|
1463
|
+
* import { FilePromptProvider } from 'evalution';
|
|
1464
|
+
* import { VercelAISDK } from '@evalution/vercel-ai-sdk/config';
|
|
1465
|
+
*
|
|
1466
|
+
* export default {
|
|
1467
|
+
* promptProviders: [
|
|
1468
|
+
* new FilePromptProvider({
|
|
1469
|
+
* sdk: new VercelAISDK(),
|
|
1470
|
+
* }),
|
|
1471
|
+
* ],
|
|
1472
|
+
* } satisfies EvalutionConfig;
|
|
1473
|
+
* ```
|
|
1760
1474
|
*/
|
|
1761
1475
|
interface EvalutionConfig {
|
|
1476
|
+
/**
|
|
1477
|
+
* Links the project to Evalution Cloud. `evalution link` writes this.
|
|
1478
|
+
*
|
|
1479
|
+
* With a personal API key in `EVALUTION_API_KEY`, each running playground
|
|
1480
|
+
* registers with the cloud, so the project's URL
|
|
1481
|
+
* (`https://l.evalut.io/<org>/<project>`) opens it, and links to it
|
|
1482
|
+
* can be shared with the project's members.
|
|
1483
|
+
*/
|
|
1484
|
+
cloud?: CloudConfig;
|
|
1762
1485
|
/**
|
|
1763
1486
|
* Whether to load a `.env` file from the directory Evalution is launched
|
|
1764
1487
|
* from before starting the server.
|
|
@@ -1804,6 +1527,14 @@ interface EvalutionConfig {
|
|
|
1804
1527
|
*/
|
|
1805
1528
|
evalProviders?: EvalProvider[];
|
|
1806
1529
|
}
|
|
1530
|
+
/** Where a project lives in Evalution Cloud. See {@link EvalutionConfig.cloud}. */
|
|
1531
|
+
interface CloudConfig {
|
|
1532
|
+
/**
|
|
1533
|
+
* The project's id (`prj_…`). It isn't a secret: only the project's members
|
|
1534
|
+
* can use it.
|
|
1535
|
+
*/
|
|
1536
|
+
project: string;
|
|
1537
|
+
}
|
|
1807
1538
|
//#endregion
|
|
1808
1539
|
//#region src/trace/db/migrate.d.ts
|
|
1809
1540
|
/** The ledger table `runMigrations` records applied migrations in. */
|
|
@@ -1825,6 +1556,259 @@ declare function runMigrations(db: Parameters<typeof migrateAsync>[1], migration
|
|
|
1825
1556
|
*/
|
|
1826
1557
|
declare function runDatasetMigrations(db: Parameters<typeof runMigrations>[0]): Promise<void>;
|
|
1827
1558
|
//#endregion
|
|
1559
|
+
//#region src/sync/database-sync.d.ts
|
|
1560
|
+
/** The cloud call a {@link DatabaseSync} makes. */
|
|
1561
|
+
type SyncCloud = Pick<Evalution$1, "getSyncDatabase">;
|
|
1562
|
+
/** The sync operations of a `@tursodatabase/sync` database. */
|
|
1563
|
+
interface SyncedDatabase {
|
|
1564
|
+
push(): Promise<unknown>;
|
|
1565
|
+
pull(): Promise<boolean>;
|
|
1566
|
+
checkpoint(): Promise<unknown>;
|
|
1567
|
+
}
|
|
1568
|
+
/** Options for {@link DatabaseSync}. */
|
|
1569
|
+
interface DatabaseSyncOptions {
|
|
1570
|
+
cloud: SyncCloud;
|
|
1571
|
+
/** Which of the project's synced databases this is. */
|
|
1572
|
+
key: SyncDatabaseKey;
|
|
1573
|
+
/** The local schema's version: see `TRACE_SCHEMA_VERSION`. */
|
|
1574
|
+
schemaVersion: number;
|
|
1575
|
+
/** How long after the last write to push, in ms. */
|
|
1576
|
+
pushDelayMs?: number;
|
|
1577
|
+
/** How long opening the database waits on the cloud, in ms. */
|
|
1578
|
+
prepareTimeoutMs?: number;
|
|
1579
|
+
/** Runs when {@link DatabaseSync.isAdopting} changes. */
|
|
1580
|
+
onStatusChange?: () => void;
|
|
1581
|
+
log?: Pick<Console, "warn">;
|
|
1582
|
+
}
|
|
1583
|
+
/** What {@link DatabaseSync.attach} needs to know about the open file. */
|
|
1584
|
+
interface AttachOptions {
|
|
1585
|
+
/** The sync ids of the cloud databases the file has synced with. */
|
|
1586
|
+
links: readonly string[];
|
|
1587
|
+
/** Runs whenever a pull brings changes. */
|
|
1588
|
+
onPulled: () => void;
|
|
1589
|
+
/**
|
|
1590
|
+
* Makes the file a copy of the cloud's database that holds its rows too,
|
|
1591
|
+
* then attaches that. Called when the cloud names a database the file has
|
|
1592
|
+
* no link to.
|
|
1593
|
+
*/
|
|
1594
|
+
adopt: () => Promise<void>;
|
|
1595
|
+
/**
|
|
1596
|
+
* Removes the file. Called when the cloud says the database it synced
|
|
1597
|
+
* with was deleted from the project — on another machine, say. A file that
|
|
1598
|
+
* never synced with it is kept, local-only.
|
|
1599
|
+
*/
|
|
1600
|
+
onDeleted?: () => void;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* One local database's link to its cloud copy. Hand {@link getCloudUrl} and
|
|
1604
|
+
* {@link getAuthToken} to `createLocalTursoClient`, after {@link prepare} so
|
|
1605
|
+
* a database that isn't on this machine yet can start from the copy
|
|
1606
|
+
* {@link currentCredentials} names. Then {@link attach} the open database.
|
|
1607
|
+
* `openLocalDatabase` does all this.
|
|
1608
|
+
*/
|
|
1609
|
+
declare class DatabaseSync {
|
|
1610
|
+
private readonly cloud;
|
|
1611
|
+
private readonly schemaVersion;
|
|
1612
|
+
private readonly pushDelayMs;
|
|
1613
|
+
private readonly prepareTimeoutMs;
|
|
1614
|
+
private readonly onStatusChange;
|
|
1615
|
+
private readonly log;
|
|
1616
|
+
/** What this database is, in messages. */
|
|
1617
|
+
readonly label: string;
|
|
1618
|
+
/** Which of the project's synced databases this is. */
|
|
1619
|
+
readonly key: SyncDatabaseKey;
|
|
1620
|
+
private credentials;
|
|
1621
|
+
private requesting;
|
|
1622
|
+
private stopped;
|
|
1623
|
+
private closed;
|
|
1624
|
+
private create;
|
|
1625
|
+
private db;
|
|
1626
|
+
private onPulled;
|
|
1627
|
+
/** The open file's links: see {@link AttachOptions.links}. */
|
|
1628
|
+
private links;
|
|
1629
|
+
private adoptFile;
|
|
1630
|
+
private adopting;
|
|
1631
|
+
/** Local writes may not have been pushed. */
|
|
1632
|
+
private owesPush;
|
|
1633
|
+
private pushTimer;
|
|
1634
|
+
/** The operation in flight: the engine runs one at a time. */
|
|
1635
|
+
private chain;
|
|
1636
|
+
private warned;
|
|
1637
|
+
/** The cloud said the database was deleted: settled once a file is attached. */
|
|
1638
|
+
private deletion;
|
|
1639
|
+
private onDeleted;
|
|
1640
|
+
constructor(options: DatabaseSyncOptions);
|
|
1641
|
+
/** Whether the cloud has answered, and not said no. */
|
|
1642
|
+
get isAvailable(): boolean;
|
|
1643
|
+
/** The cloud's answer, while it stands. */
|
|
1644
|
+
get currentCredentials(): SyncDatabaseCredentials | undefined;
|
|
1645
|
+
/** Whether the open file holds the rows of the database the cloud names. */
|
|
1646
|
+
get isLinked(): boolean;
|
|
1647
|
+
/**
|
|
1648
|
+
* Whether the file is being adopted. Its provider's operations wait while
|
|
1649
|
+
* the copy takes its place, so this is shown.
|
|
1650
|
+
*/
|
|
1651
|
+
get isAdopting(): boolean;
|
|
1652
|
+
/** Whether the cloud has said this database can't sync, so it never will this session. */
|
|
1653
|
+
get isStopped(): boolean;
|
|
1654
|
+
/**
|
|
1655
|
+
* Asks the cloud where the database is, waiting a little for the answer.
|
|
1656
|
+
* Never rejects: without an answer the database opens local-only and
|
|
1657
|
+
* switches sync on once one comes. `create` is for a dataset being made
|
|
1658
|
+
* now, whose id may be a deleted one's.
|
|
1659
|
+
*/
|
|
1660
|
+
prepare({
|
|
1661
|
+
create
|
|
1662
|
+
}?: {
|
|
1663
|
+
create?: boolean;
|
|
1664
|
+
}): Promise<void>;
|
|
1665
|
+
/**
|
|
1666
|
+
* The cloud copy's URL once the file holds its rows; `null` keeps the
|
|
1667
|
+
* database local. Pulling into a file that doesn't would drop its rows.
|
|
1668
|
+
*/
|
|
1669
|
+
readonly getCloudUrl: () => string | null;
|
|
1670
|
+
/** A current token for the cloud copy. Only called by the engine once {@link getCloudUrl} has a URL. */
|
|
1671
|
+
readonly getAuthToken: () => Promise<string>;
|
|
1672
|
+
/**
|
|
1673
|
+
* For `createLocalTursoClient`'s `onBootstrapFailure`: the file is made
|
|
1674
|
+
* empty instead, and adopted once the cloud answers.
|
|
1675
|
+
*/
|
|
1676
|
+
readonly reportBootstrapFailure: (err: unknown) => void;
|
|
1677
|
+
/** Asks the cloud for credentials, sharing a request already in flight. */
|
|
1678
|
+
private requestCredentials;
|
|
1679
|
+
private reportCredentialsFailure;
|
|
1680
|
+
/**
|
|
1681
|
+
* Removes the attached file if it synced with the deleted database, and
|
|
1682
|
+
* keeps it local-only if not: then it holds rows the cloud never had.
|
|
1683
|
+
*/
|
|
1684
|
+
private settleDeletion;
|
|
1685
|
+
private warnOnce;
|
|
1686
|
+
/**
|
|
1687
|
+
* Starts syncing the open database: pulls what the cloud has, then pushes
|
|
1688
|
+
* what this machine has. A file with no link to the cloud's database is
|
|
1689
|
+
* adopted instead, once the cloud answers. Attaching the database that's
|
|
1690
|
+
* attached already does nothing.
|
|
1691
|
+
*/
|
|
1692
|
+
attach(db: SyncedDatabase, {
|
|
1693
|
+
links,
|
|
1694
|
+
onPulled,
|
|
1695
|
+
adopt,
|
|
1696
|
+
onDeleted
|
|
1697
|
+
}: AttachOptions): void;
|
|
1698
|
+
/** Settles once no adoption is under way. */
|
|
1699
|
+
adopted(): Promise<void>;
|
|
1700
|
+
/** Adopts the file if the cloud names a database it has no link to. Never rejects. */
|
|
1701
|
+
private adoptIfUnlinked;
|
|
1702
|
+
/**
|
|
1703
|
+
* Asks the cloud again for the database, as if for a new token: how a
|
|
1704
|
+
* dataset gone from the project's list is found to be deleted. Never
|
|
1705
|
+
* rejects.
|
|
1706
|
+
*/
|
|
1707
|
+
recheck(): Promise<void>;
|
|
1708
|
+
/** Says the database was written to: it's pushed once writes settle. */
|
|
1709
|
+
noteWrite(): void;
|
|
1710
|
+
/**
|
|
1711
|
+
* Pulls the cloud's changes, and pushes this machine's if it has any.
|
|
1712
|
+
* `true` if the pull brought changes. Never rejects.
|
|
1713
|
+
*/
|
|
1714
|
+
pull(): Promise<boolean>;
|
|
1715
|
+
/** Folds the database's write-ahead log into it. Never rejects. */
|
|
1716
|
+
checkpoint(): Promise<void>;
|
|
1717
|
+
private pushIfOwed;
|
|
1718
|
+
/** Runs `op` after whatever is in flight, reporting a failure rather than rejecting. */
|
|
1719
|
+
private run;
|
|
1720
|
+
/** Settles once no operation is in flight. */
|
|
1721
|
+
idle(): Promise<void>;
|
|
1722
|
+
/** Pushes what hasn't been, then stops syncing. */
|
|
1723
|
+
close(): Promise<void>;
|
|
1724
|
+
}
|
|
1725
|
+
//#endregion
|
|
1726
|
+
//#region src/sync/workspace-sync.d.ts
|
|
1727
|
+
/** The cloud calls a {@link WorkspaceSync} makes. */
|
|
1728
|
+
type WorkspaceCloud = Pick<Evalution$1, "getSyncDatabase" | "listSyncDatabases" | "deleteSyncDatabase">;
|
|
1729
|
+
/** Options for {@link WorkspaceSync}. */
|
|
1730
|
+
interface WorkspaceSyncOptions {
|
|
1731
|
+
cloud: WorkspaceCloud;
|
|
1732
|
+
/** How often to pull while running, in ms. */
|
|
1733
|
+
pullIntervalMs?: number;
|
|
1734
|
+
/** Checkpoint every this many pulls. */
|
|
1735
|
+
checkpointEvery?: number;
|
|
1736
|
+
/** How long closing may take to push what's left, in ms. */
|
|
1737
|
+
closeTimeoutMs?: number;
|
|
1738
|
+
log?: Pick<Console, "warn">;
|
|
1739
|
+
}
|
|
1740
|
+
/** A project's providers, by kind, for {@link WorkspaceSync.syncProviders}. */
|
|
1741
|
+
interface ProvidersToSync {
|
|
1742
|
+
traces: readonly unknown[];
|
|
1743
|
+
datasets: readonly unknown[];
|
|
1744
|
+
evals: readonly unknown[];
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* The project's synced databases. Each local provider, given this by
|
|
1748
|
+
* `syncProviders`, asks it for the {@link DatabaseSync} of each of its
|
|
1749
|
+
* databases; this pulls them all on an interval and when the playground asks
|
|
1750
|
+
* ({@link pullAll}, when its window regains focus).
|
|
1751
|
+
*/
|
|
1752
|
+
declare class WorkspaceSync {
|
|
1753
|
+
private readonly cloud;
|
|
1754
|
+
private readonly pullIntervalMs;
|
|
1755
|
+
private readonly checkpointEvery;
|
|
1756
|
+
private readonly closeTimeoutMs;
|
|
1757
|
+
private readonly log;
|
|
1758
|
+
private readonly databases;
|
|
1759
|
+
private readonly hooks;
|
|
1760
|
+
private readonly statusListeners;
|
|
1761
|
+
private pulling;
|
|
1762
|
+
private timer;
|
|
1763
|
+
private ticks;
|
|
1764
|
+
constructor(options: WorkspaceSyncOptions);
|
|
1765
|
+
/**
|
|
1766
|
+
* Gives each provider that can sync this, whether the config made it or
|
|
1767
|
+
* the defaults did: it syncs its own databases, named by its id. Of a
|
|
1768
|
+
* kind's providers that share an id, only the first syncs, since they'd
|
|
1769
|
+
* share databases.
|
|
1770
|
+
*
|
|
1771
|
+
* @internal Not public API yet, like `_ecSetSync`.
|
|
1772
|
+
*/
|
|
1773
|
+
syncProviders(providers: ProvidersToSync): void;
|
|
1774
|
+
/** The sync for one database, made on first ask. */
|
|
1775
|
+
database(key: SyncDatabaseKey, schemaVersion: number): DatabaseSync;
|
|
1776
|
+
/**
|
|
1777
|
+
* The databases being adopted (see `local-database.ts`): their providers'
|
|
1778
|
+
* operations wait while each copy takes its file's place.
|
|
1779
|
+
*/
|
|
1780
|
+
adopting(): SyncDatabaseKey[];
|
|
1781
|
+
/** Runs `listener` whenever {@link adopting} changes. */
|
|
1782
|
+
onStatusChange(listener: () => void): () => void;
|
|
1783
|
+
/** Runs `hook` after each {@link pullAll}: how new datasets are found. */
|
|
1784
|
+
onPull(hook: () => Promise<void>): () => void;
|
|
1785
|
+
/** Starts pulling on an interval. */
|
|
1786
|
+
start(): void;
|
|
1787
|
+
/**
|
|
1788
|
+
* Pulls every database now, sharing a pull that's already under way. A
|
|
1789
|
+
* database being adopted is pulled (and so pushed) once it's adopted.
|
|
1790
|
+
* Never rejects.
|
|
1791
|
+
*/
|
|
1792
|
+
pullAll(): Promise<void>;
|
|
1793
|
+
/**
|
|
1794
|
+
* The ids of a dataset provider's datasets in the cloud, or `undefined` if
|
|
1795
|
+
* it can't be asked.
|
|
1796
|
+
*/
|
|
1797
|
+
remoteDatasetIds(provider: string): Promise<string[] | undefined>;
|
|
1798
|
+
/**
|
|
1799
|
+
* Stops syncing a provider's dataset, and forgets its sync, so a dataset
|
|
1800
|
+
* made again with its id starts afresh. For one deleted on another machine.
|
|
1801
|
+
*/
|
|
1802
|
+
forgetDataset(provider: string, datasetId: string): Promise<void>;
|
|
1803
|
+
/**
|
|
1804
|
+
* Deletes a provider's dataset from the cloud. Every other machine whose
|
|
1805
|
+
* copy synced with it removes it on its next pull. Never rejects.
|
|
1806
|
+
*/
|
|
1807
|
+
deleteDataset(provider: string, datasetId: string): Promise<void>;
|
|
1808
|
+
/** Stops pulling, and pushes what's left, waiting a few seconds at most. */
|
|
1809
|
+
close(): Promise<void>;
|
|
1810
|
+
}
|
|
1811
|
+
//#endregion
|
|
1828
1812
|
//#region src/dataset/local-directory-dataset-provider.d.ts
|
|
1829
1813
|
/** Options for {@link LocalDirectoryDatasetProvider}. */
|
|
1830
1814
|
interface LocalDirectoryDatasetProviderOptions {
|
|
@@ -1836,6 +1820,10 @@ interface LocalDirectoryDatasetProviderOptions {
|
|
|
1836
1820
|
* @default "./.evalution/datasets"
|
|
1837
1821
|
*/
|
|
1838
1822
|
dir?: string;
|
|
1823
|
+
/**
|
|
1824
|
+
* Also names the datasets in Evalution Cloud when the project is linked:
|
|
1825
|
+
* changing it starts new cloud copies.
|
|
1826
|
+
*/
|
|
1839
1827
|
id?: string;
|
|
1840
1828
|
displayName?: string;
|
|
1841
1829
|
description?: string;
|
|
@@ -1869,7 +1857,44 @@ declare class LocalDirectoryDatasetProvider implements DatasetProvider {
|
|
|
1869
1857
|
private readonly reported;
|
|
1870
1858
|
/** Tail of the create chain: id choice and file creation are one step. */
|
|
1871
1859
|
private creates;
|
|
1860
|
+
private sync;
|
|
1861
|
+
/** Per file: holds operations while sync swaps it. */
|
|
1862
|
+
private readonly gates;
|
|
1863
|
+
/** Datasets being removed because they were deleted on another machine. */
|
|
1864
|
+
private readonly removals;
|
|
1872
1865
|
constructor(options?: LocalDirectoryDatasetProviderOptions);
|
|
1866
|
+
/**
|
|
1867
|
+
* Syncs each dataset with the linked project's copy (named by this
|
|
1868
|
+
* provider's id and the dataset's), once `setUpProject` hands this the
|
|
1869
|
+
* project's sync. A dataset the project has in the cloud but this machine
|
|
1870
|
+
* doesn't is fetched whenever the sync pulls, and deleting a dataset
|
|
1871
|
+
* deletes it from the cloud. Datasets already open start syncing as they
|
|
1872
|
+
* are.
|
|
1873
|
+
*
|
|
1874
|
+
* @internal Not public API yet.
|
|
1875
|
+
*/
|
|
1876
|
+
_ecSetSync(workspace: WorkspaceSync): void;
|
|
1877
|
+
/** What syncing `datasetId`'s file needs, once there's a sync. */
|
|
1878
|
+
private syncHooksFor;
|
|
1879
|
+
private gateFor;
|
|
1880
|
+
/** Runs `op` on `datasetId`'s file, after any swap of it. */
|
|
1881
|
+
private on;
|
|
1882
|
+
private datasetSync;
|
|
1883
|
+
/**
|
|
1884
|
+
* Removes a dataset deleted on another machine, once its sync has found
|
|
1885
|
+
* this file synced with the deleted cloud copy.
|
|
1886
|
+
*/
|
|
1887
|
+
private removeDeleted;
|
|
1888
|
+
/**
|
|
1889
|
+
* Opens this machine's datasets, so each syncs — one made before the
|
|
1890
|
+
* project was linked is brought into it — and fetches the datasets the
|
|
1891
|
+
* project has in the cloud that this machine doesn't, announcing each as
|
|
1892
|
+
* added. One gone from the cloud's list is checked on, so if it was
|
|
1893
|
+
* deleted on another machine it's removed here too. Chained with creates,
|
|
1894
|
+
* so it can't open a file a create is making.
|
|
1895
|
+
*/
|
|
1896
|
+
private fetchRemoteDatasets;
|
|
1897
|
+
private fetchRemoteDatasetsNow;
|
|
1873
1898
|
private pathFor;
|
|
1874
1899
|
private emit;
|
|
1875
1900
|
watch(callback: (event: DatasetChangeEvent) => void): () => void;
|
|
@@ -1881,14 +1906,20 @@ declare class LocalDirectoryDatasetProvider implements DatasetProvider {
|
|
|
1881
1906
|
* one).
|
|
1882
1907
|
*/
|
|
1883
1908
|
private entryFor;
|
|
1884
|
-
/**
|
|
1909
|
+
/**
|
|
1910
|
+
* Opens (and migrates) `datasetId`'s file, caching the result. `create`
|
|
1911
|
+
* says the dataset is being made now, which may reuse a deleted one's id.
|
|
1912
|
+
*/
|
|
1885
1913
|
private openEntry;
|
|
1886
1914
|
private openUncached;
|
|
1915
|
+
/** Opens `datasetId`'s file again, after sync swapped it (and closed the old one). */
|
|
1916
|
+
private reopenEntry;
|
|
1887
1917
|
/** The open entry for `datasetId`, or a {@link DatasetNotFoundError}. */
|
|
1888
1918
|
private requireEntry;
|
|
1889
|
-
/** `dataset` with its id rewritten to the file's. */
|
|
1919
|
+
/** `dataset` with its id rewritten to the file's, marked if the cloud has it. */
|
|
1890
1920
|
private withFileId;
|
|
1891
1921
|
listDatasets(): Promise<DatasetSummary[]>;
|
|
1922
|
+
private summarize;
|
|
1892
1923
|
getDataset(datasetId: string): Promise<Dataset | undefined>;
|
|
1893
1924
|
listRows(datasetId: string, options?: ListRowsOptions): Promise<DatasetRow[]>;
|
|
1894
1925
|
describeRows(datasetId: string): Promise<DatasetRowsOverview>;
|
|
@@ -1900,9 +1931,16 @@ declare class LocalDirectoryDatasetProvider implements DatasetProvider {
|
|
|
1900
1931
|
*/
|
|
1901
1932
|
createDataset(input: CreateDatasetInput): Promise<Dataset>;
|
|
1902
1933
|
private createNow;
|
|
1934
|
+
/** Runs `op` on `datasetId`'s open entry, or throws if there's none. */
|
|
1935
|
+
private withEntry;
|
|
1903
1936
|
renameDataset(datasetId: string, name: string): Promise<Dataset>;
|
|
1904
|
-
/**
|
|
1937
|
+
/**
|
|
1938
|
+
* Closes the file's client, then removes it and its sidecars. When
|
|
1939
|
+
* syncing, it's deleted from the cloud too, and so from every machine.
|
|
1940
|
+
*/
|
|
1905
1941
|
deleteDataset(datasetId: string): Promise<void>;
|
|
1942
|
+
/** Closes the file's client, then removes it and its sidecars. */
|
|
1943
|
+
private removeLocal;
|
|
1906
1944
|
addRows(datasetId: string, rows: NewDatasetRow[]): Promise<DatasetRow[]>;
|
|
1907
1945
|
updateRows(datasetId: string, updates: DatasetRowUpdate[]): Promise<void>;
|
|
1908
1946
|
deleteRows(datasetId: string, rowIds: readonly string[]): Promise<number>;
|
|
@@ -2044,7 +2082,7 @@ interface EvalRunnerOptions {
|
|
|
2044
2082
|
traceProviderId: string;
|
|
2045
2083
|
tracer: Tracer;
|
|
2046
2084
|
/** Resolves an eval's (possibly global) prompt id to a provider and prompt. */
|
|
2047
|
-
resolvePrompt(prompt: PromptID): {
|
|
2085
|
+
resolvePrompt(prompt: PromptID$1): {
|
|
2048
2086
|
providerId: string;
|
|
2049
2087
|
promptId: string;
|
|
2050
2088
|
} | undefined;
|
|
@@ -2211,6 +2249,10 @@ interface LocalEvalProviderOptions {
|
|
|
2211
2249
|
* @default "./.evalution/evals/evals.db"
|
|
2212
2250
|
*/
|
|
2213
2251
|
path?: string;
|
|
2252
|
+
/**
|
|
2253
|
+
* Also names the database in Evalution Cloud when the project is linked:
|
|
2254
|
+
* changing it starts a new cloud copy.
|
|
2255
|
+
*/
|
|
2214
2256
|
id?: string;
|
|
2215
2257
|
displayName?: string;
|
|
2216
2258
|
}
|
|
@@ -2226,9 +2268,36 @@ declare class LocalEvalProvider implements EvalProvider {
|
|
|
2226
2268
|
readonly path: string;
|
|
2227
2269
|
private opened?;
|
|
2228
2270
|
private readonly watchers;
|
|
2271
|
+
private sync;
|
|
2272
|
+
/** The open file, for sync. */
|
|
2273
|
+
private client;
|
|
2274
|
+
/** Holds operations while sync swaps the database file. */
|
|
2275
|
+
private readonly gate;
|
|
2229
2276
|
constructor(options?: LocalEvalProviderOptions);
|
|
2277
|
+
/**
|
|
2278
|
+
* Syncs the database with the linked project's copy (named by this
|
|
2279
|
+
* provider's id), once `setUpProject` hands this the project's sync. Opens
|
|
2280
|
+
* (and creates) the database at once, since the project may already have
|
|
2281
|
+
* evals from another machine; a database already open starts syncing as
|
|
2282
|
+
* it is.
|
|
2283
|
+
*
|
|
2284
|
+
* @internal Not public API yet.
|
|
2285
|
+
*/
|
|
2286
|
+
_ecSetSync(workspace: WorkspaceSync): void;
|
|
2287
|
+
/** What syncing the file needs, once there's a sync. */
|
|
2288
|
+
private syncHooks;
|
|
2289
|
+
/** Starts syncing the open file. */
|
|
2290
|
+
private startSyncing;
|
|
2230
2291
|
/** The store, creating it if needed. Set synchronously, so concurrent first writes share one open. */
|
|
2231
2292
|
private open;
|
|
2293
|
+
private openStore;
|
|
2294
|
+
private emit;
|
|
2295
|
+
/** Runs `op` on the store, creating it if needed. */
|
|
2296
|
+
private withStore;
|
|
2297
|
+
/** Runs `op` on the store if it exists yet, without creating it. */
|
|
2298
|
+
private ifOpen;
|
|
2299
|
+
/** `op`'s result, after telling the sync the database was written to. */
|
|
2300
|
+
private wrote;
|
|
2232
2301
|
/** The store if it exists yet, without creating it. */
|
|
2233
2302
|
private existing;
|
|
2234
2303
|
watch(callback: (event: EvalChangeEvent) => void): () => void;
|
|
@@ -2236,7 +2305,7 @@ declare class LocalEvalProvider implements EvalProvider {
|
|
|
2236
2305
|
getEval(id: string): Promise<EvalDefinition | undefined>;
|
|
2237
2306
|
createEval(input: NewEvalDefinition): Promise<EvalDefinition>;
|
|
2238
2307
|
updateEval(id: string, patch: EvalDefinitionPatch): Promise<EvalDefinition>;
|
|
2239
|
-
deleteEval(id: string): Promise<void>;
|
|
2308
|
+
deleteEval(id: string): Promise<void | undefined>;
|
|
2240
2309
|
createRun(evalId: string, run: NewEvalRun): Promise<EvalRun>;
|
|
2241
2310
|
finishRun(runId: string, status: EvalRunStatus, options?: {
|
|
2242
2311
|
drifted?: boolean;
|
|
@@ -2244,7 +2313,7 @@ declare class LocalEvalProvider implements EvalProvider {
|
|
|
2244
2313
|
interruptRuns(): Promise<number>;
|
|
2245
2314
|
listRuns(evalId: string): Promise<EvalRunSummary[]>;
|
|
2246
2315
|
getRun(runId: string): Promise<EvalRun | undefined>;
|
|
2247
|
-
deleteRun(runId: string): Promise<void>;
|
|
2316
|
+
deleteRun(runId: string): Promise<void | undefined>;
|
|
2248
2317
|
recordRowResult(result: EvalRowResult): Promise<void>;
|
|
2249
2318
|
recordCheckResults(results: EvalCheckResult[]): Promise<void>;
|
|
2250
2319
|
listResults(runId: string): Promise<EvalResults>;
|
|
@@ -2359,6 +2428,87 @@ declare class OverlayFileProvider implements FileProvider {
|
|
|
2359
2428
|
watch(patterns: readonly string[], options: FileWatchOptions, callback: FileWatchCallback): () => void;
|
|
2360
2429
|
}
|
|
2361
2430
|
//#endregion
|
|
2431
|
+
//#region src/prompt/variations/variation-store.d.ts
|
|
2432
|
+
/** A variation as stored: {@link VariationInfo} plus what only the store needs. */
|
|
2433
|
+
interface StoredVariation extends VariationInfo {
|
|
2434
|
+
/**
|
|
2435
|
+
* The prompt's `prompts()` id when it has one, so a rebase can find the
|
|
2436
|
+
* prompt at head after a file move or an export rename.
|
|
2437
|
+
*/
|
|
2438
|
+
globalId?: string;
|
|
2439
|
+
/**
|
|
2440
|
+
* The prompt's values for the fields {@link updates} sets, as they were
|
|
2441
|
+
* when it was made — the base of the three-way merge that carries it onto
|
|
2442
|
+
* a changed working tree. See `fieldValuesOf`.
|
|
2443
|
+
*/
|
|
2444
|
+
baseValues: FieldValues;
|
|
2445
|
+
}
|
|
2446
|
+
/** What identifies a variation's content. */
|
|
2447
|
+
interface VariationContent {
|
|
2448
|
+
promptId: string;
|
|
2449
|
+
globalId?: string;
|
|
2450
|
+
base?: VersionId;
|
|
2451
|
+
/** Canonical updates — see `canonicalizeUpdates`. */
|
|
2452
|
+
updates: NormalizedPromptUpdates;
|
|
2453
|
+
baseValues: FieldValues;
|
|
2454
|
+
}
|
|
2455
|
+
/** A new WIP variation. */
|
|
2456
|
+
interface NewWip extends VariationContent {
|
|
2457
|
+
/** Whether this WIP holds the unsaved edits to head. At most one per prompt. */
|
|
2458
|
+
onHead: boolean;
|
|
2459
|
+
/** The name of the variation it was opened from, if any. */
|
|
2460
|
+
originName?: string;
|
|
2461
|
+
}
|
|
2462
|
+
/** Changes to a WIP. Omitted fields are left alone; `null` clears. */
|
|
2463
|
+
interface WipChanges {
|
|
2464
|
+
updates?: NormalizedPromptUpdates;
|
|
2465
|
+
baseValues?: FieldValues;
|
|
2466
|
+
pending?: PendingConflicts | null;
|
|
2467
|
+
originName?: string | null;
|
|
2468
|
+
}
|
|
2469
|
+
/**
|
|
2470
|
+
* Where a {@link FilePromptProvider} keeps variations: immutable ("frozen")
|
|
2471
|
+
* ones, deduplicated by content, the one mutable WIP of unsaved edits to
|
|
2472
|
+
* head per prompt, and one per (prompt, old version).
|
|
2473
|
+
*
|
|
2474
|
+
* Nothing is garbage-collected: frozen rows are minted only when something
|
|
2475
|
+
* runs or gets a name, and they dedupe. See
|
|
2476
|
+
* `specs/prompt-versions-and-variations.md` §E.
|
|
2477
|
+
*/
|
|
2478
|
+
interface VariationStore {
|
|
2479
|
+
/** The variation with this id, frozen or WIP. */
|
|
2480
|
+
get(id: VariationId): Promise<StoredVariation | undefined>;
|
|
2481
|
+
/**
|
|
2482
|
+
* Inserts a frozen variation, or returns the existing one with the same
|
|
2483
|
+
* content.
|
|
2484
|
+
*/
|
|
2485
|
+
intern(v: VariationContent): Promise<StoredVariation>;
|
|
2486
|
+
/** The WIP of unsaved edits to an old version of a prompt, if any. */
|
|
2487
|
+
getWip(promptId: string, base: VersionId): Promise<StoredVariation | undefined>;
|
|
2488
|
+
/** The WIP holding a prompt's unsaved edits to head, if any. */
|
|
2489
|
+
getHeadWip(promptId: string): Promise<StoredVariation | undefined>;
|
|
2490
|
+
/** Every head WIP, of every prompt — what the dirty indicators come from. */
|
|
2491
|
+
listHeadWips(): Promise<StoredVariation[]>;
|
|
2492
|
+
/** Creates a WIP, replacing any that holds the same slot. */
|
|
2493
|
+
putWip(v: NewWip): Promise<StoredVariation>;
|
|
2494
|
+
/** Changes a WIP in place — to edit it, rebase it, or record conflicts. */
|
|
2495
|
+
updateWip(id: VariationId, changes: WipChanges): Promise<StoredVariation>;
|
|
2496
|
+
/** Deletes a WIP. A frozen variation is never deleted. */
|
|
2497
|
+
deleteWip(id: VariationId): Promise<void>;
|
|
2498
|
+
/** A prompt's named variations and its WIPs. */
|
|
2499
|
+
list(promptId: string): Promise<StoredVariation[]>;
|
|
2500
|
+
/** Names a frozen variation. A name is unique per prompt; naming again moves it. */
|
|
2501
|
+
name(id: VariationId, promptId: string, name: string): Promise<void>;
|
|
2502
|
+
/** Removes a name. */
|
|
2503
|
+
unname(promptId: string, name: string): Promise<void>;
|
|
2504
|
+
/**
|
|
2505
|
+
* Renames `from` to `to`, keeping the variation it points at, and returns
|
|
2506
|
+
* that variation's id. Throws if `from` doesn't exist, or `to` is already
|
|
2507
|
+
* taken.
|
|
2508
|
+
*/
|
|
2509
|
+
rename(promptId: string, from: string, to: string): Promise<VariationId>;
|
|
2510
|
+
}
|
|
2511
|
+
//#endregion
|
|
2362
2512
|
//#region src/prompt/file/prompt-file-type.d.ts
|
|
2363
2513
|
/** Metadata attached to prompts that originate from a file on disk. */
|
|
2364
2514
|
interface FilePromptMetadata {
|
|
@@ -2397,96 +2547,6 @@ interface ParsePromptsOptions {
|
|
|
2397
2547
|
*/
|
|
2398
2548
|
companionFiles?: readonly string[];
|
|
2399
2549
|
}
|
|
2400
|
-
/**
|
|
2401
|
-
* A type question for a {@link PromptFileType} to answer on an
|
|
2402
|
-
* {@link SDKAdapter}'s behalf.
|
|
2403
|
-
*
|
|
2404
|
-
* Neither side can answer alone. Knowing that a Vercel AI SDK config's tools
|
|
2405
|
-
* imply a `toolsContext` is SDK semantics; *evaluating* that mapping is a
|
|
2406
|
-
* TypeScript capability. So the adapter says what to look for and the file
|
|
2407
|
-
* type contributes the checker.
|
|
2408
|
-
*/
|
|
2409
|
-
type TypeProbe = TypeExpressionProbe | FactoriesProbe;
|
|
2410
|
-
/** A probe that resolves a type expression to a {@link PropDefinition}. */
|
|
2411
|
-
interface TypeExpressionProbe {
|
|
2412
|
-
kind: "type";
|
|
2413
|
-
/**
|
|
2414
|
-
* The name the result is reported under — for an execute parameter, its
|
|
2415
|
-
* name, and the name of the resolved {@link PropDefinition}.
|
|
2416
|
-
*/
|
|
2417
|
-
name: string;
|
|
2418
|
-
/**
|
|
2419
|
-
* Source text of a type expression, in the file type's
|
|
2420
|
-
* {@link PromptFileType.language}, that resolves to the type.
|
|
2421
|
-
*
|
|
2422
|
-
* In a prompt probe, the token `$config` stands for the type of whatever the
|
|
2423
|
-
* prompt returns, and the file type substitutes a way to name it — which
|
|
2424
|
-
* shape a prompt file uses is the file type's knowledge, not the adapter's.
|
|
2425
|
-
* A project probe has no prompt, so `$config` resolves to `never` there.
|
|
2426
|
-
*
|
|
2427
|
-
* Write it defensively: a probe that cannot find what it is looking for
|
|
2428
|
-
* should resolve to `never` (which means "there is no such thing"), never
|
|
2429
|
-
* fail to compile. That is what lets an adapter emit a probe without first
|
|
2430
|
-
* inspecting the parse result.
|
|
2431
|
-
*
|
|
2432
|
-
* For instance, the Vercel AI SDK derives its `toolsContext` from whichever
|
|
2433
|
-
* of a config's tools declare a `contextSchema`, with the `never` branch
|
|
2434
|
-
* covering a config that has no tools at all:
|
|
2435
|
-
*
|
|
2436
|
-
* ```ts
|
|
2437
|
-
* "$config extends { tools: infer T extends ToolSet } ? InferToolSetContext<T> : never"
|
|
2438
|
-
* ```
|
|
2439
|
-
*/
|
|
2440
|
-
expression: string;
|
|
2441
|
-
/**
|
|
2442
|
-
* How to label the resolved type in the UI, when the checker's own spelling
|
|
2443
|
-
* would be unreadable — a deeply-instantiated mapped type is accurate and
|
|
2444
|
-
* useless as a label. The resolved *shape* is unaffected.
|
|
2445
|
-
*/
|
|
2446
|
-
syntax?: string;
|
|
2447
|
-
/** Documentation shown beside the resolved definition in the UI. */
|
|
2448
|
-
description?: string;
|
|
2449
|
-
}
|
|
2450
|
-
/**
|
|
2451
|
-
* A probe that resolves to the {@link ValueFactory}s among some modules'
|
|
2452
|
-
* exports: every export that can be called to produce a value assignable to
|
|
2453
|
-
* {@link produces}.
|
|
2454
|
-
*
|
|
2455
|
-
* The adapter says *what* to look for; the file type knows *how* to ask in its
|
|
2456
|
-
* language. A module that isn't installed contributes nothing rather than
|
|
2457
|
-
* failing the probe.
|
|
2458
|
-
*/
|
|
2459
|
-
interface FactoriesProbe {
|
|
2460
|
-
kind: "factories";
|
|
2461
|
-
/** The name the result is reported under. */
|
|
2462
|
-
name: string;
|
|
2463
|
-
/** Module specifiers whose exports to consider, e.g. `"@ai-sdk/openai"`. */
|
|
2464
|
-
modules: string[];
|
|
2465
|
-
/**
|
|
2466
|
-
* A type expression, in the file type's language, naming what a factory's
|
|
2467
|
-
* call must produce, e.g. `import("ai").LanguageModel`.
|
|
2468
|
-
*/
|
|
2469
|
-
produces: string;
|
|
2470
|
-
/**
|
|
2471
|
-
* Consider a method of each export rather than the export itself: with
|
|
2472
|
-
* `"evaluationModel"`, an exported provider object `typeSafeAi` whose
|
|
2473
|
-
* `evaluationModel(…)` produces the type is found as the factory
|
|
2474
|
-
* `typeSafeAi.evaluationModel`, still bound to the import of `typeSafeAi`.
|
|
2475
|
-
*/
|
|
2476
|
-
member?: string;
|
|
2477
|
-
}
|
|
2478
|
-
/**
|
|
2479
|
-
* What one probe resolved to: a {@link PropDefinition} for a `type` probe or
|
|
2480
|
-
* the {@link ValueFactory}s found by a `factories` probe; `null` for a definite
|
|
2481
|
-
* "no such thing" (the expression evaluated to `never`); or `undefined` for
|
|
2482
|
-
* "could not be evaluated".
|
|
2483
|
-
*/
|
|
2484
|
-
type ProbeResult = PropDefinition$1 | ValueFactory$1[] | null | undefined;
|
|
2485
|
-
/**
|
|
2486
|
-
* Project probe results, keyed by probe name. See
|
|
2487
|
-
* {@link SDKAdapter.getProjectProbes}.
|
|
2488
|
-
*/
|
|
2489
|
-
type ProbeResults = Record<string, ProbeResult>;
|
|
2490
2550
|
/** The project-scoped half of a {@link TypeResolutionRequest}. */
|
|
2491
2551
|
interface ProjectProbeRequest {
|
|
2492
2552
|
/**
|
|
@@ -2495,12 +2555,12 @@ interface ProjectProbeRequest {
|
|
|
2495
2555
|
*/
|
|
2496
2556
|
rootDir: string;
|
|
2497
2557
|
/** The probes to evaluate. */
|
|
2498
|
-
probes: readonly TypeProbe[];
|
|
2558
|
+
probes: readonly TypeProbe$1[];
|
|
2499
2559
|
}
|
|
2500
2560
|
/** A {@link TypeProbe} together with the prompt it is being asked about. */
|
|
2501
2561
|
interface TypeProbeRequest {
|
|
2502
2562
|
/** The probe to evaluate. */
|
|
2503
|
-
probe: TypeProbe;
|
|
2563
|
+
probe: TypeProbe$1;
|
|
2504
2564
|
/** Absolute path of the prompt's source file. */
|
|
2505
2565
|
filePath: string;
|
|
2506
2566
|
/** Name of the prompt within that file. */
|
|
@@ -2554,12 +2614,12 @@ interface TypeResolutionRequest {
|
|
|
2554
2614
|
/** Answers to a {@link TypeResolutionRequest}, positional within each list. */
|
|
2555
2615
|
interface TypeResolutionResult {
|
|
2556
2616
|
/** One per probe request, with the same meaning as {@link PromptFileType.resolveTypeProbes}. */
|
|
2557
|
-
probes: ProbeResult[];
|
|
2617
|
+
probes: ProbeResult$1[];
|
|
2558
2618
|
/**
|
|
2559
2619
|
* The project probes' results, by probe name. Every requested probe has an
|
|
2560
2620
|
* entry, `undefined` when it could not be evaluated.
|
|
2561
2621
|
*/
|
|
2562
|
-
project?: ProbeResults;
|
|
2622
|
+
project?: ProbeResults$1;
|
|
2563
2623
|
/** One per slot match request, with the same meaning as {@link PromptFileType.resolveSlotMatches}. */
|
|
2564
2624
|
slotMatches: Record<string, string[]>[];
|
|
2565
2625
|
}
|
|
@@ -2670,325 +2730,52 @@ interface PromptFileType {
|
|
|
2670
2730
|
* @param requests - The expressions to evaluate, each paired with the
|
|
2671
2731
|
* prompt it concerns. See {@link TypeProbeRequest}.
|
|
2672
2732
|
*/
|
|
2673
|
-
resolveTypeProbes?(requests: readonly TypeProbeRequest[]): Promise<ProbeResult[]>;
|
|
2733
|
+
resolveTypeProbes?(requests: readonly TypeProbeRequest[]): Promise<ProbeResult$1[]>;
|
|
2674
2734
|
/**
|
|
2675
2735
|
* Decides, for each request, which of its sources can supply which of the
|
|
2676
2736
|
* prompt's input slots — the type-based half of source matching.
|
|
2677
2737
|
*
|
|
2678
2738
|
* A slot is a parameter or any object property nested inside one, addressed
|
|
2679
|
-
* by a dotted path (`taskId`, `ctx.db`, `toolsContext.list_tasks.db`). Fit is
|
|
2680
|
-
* **assignability**, not name or spelling equality: `TaskId` and
|
|
2681
|
-
* `` `tsk_${string}` `` are one type written two ways, and a source that
|
|
2682
|
-
* produces either must be offered on a slot declared as the other.
|
|
2683
|
-
*
|
|
2684
|
-
* A match never implies a slot has no editor of its own — that is decided
|
|
2685
|
-
* from the slot's type alone. A `TaskId` slot keeps its text field and gains
|
|
2686
|
-
* the source beside it.
|
|
2687
|
-
*
|
|
2688
|
-
* Optional. Without it, callers fall back to matching on names, which is
|
|
2689
|
-
* what happens whenever no checker is available anyway.
|
|
2690
|
-
*
|
|
2691
|
-
* @param requests - One entry per prompt. See {@link SlotMatchRequest}.
|
|
2692
|
-
* @returns Positional, one per request: slot path → the `key`s of the
|
|
2693
|
-
* sources that fit it.
|
|
2694
|
-
*/
|
|
2695
|
-
resolveSlotMatches?(requests: readonly SlotMatchRequest[]): Promise<Record<string, string[]>[]>;
|
|
2696
|
-
/**
|
|
2697
|
-
* Answers probes and slot matches together: the same questions, with the
|
|
2698
|
-
* same answers, as {@link resolveTypeProbes} and {@link resolveSlotMatches},
|
|
2699
|
-
* but sharing whatever it costs to answer them. For a checker-backed file
|
|
2700
|
-
* type that is a whole program build, so a caller with both kinds of
|
|
2701
|
-
* question should prefer this.
|
|
2702
|
-
*
|
|
2703
|
-
* Optional. When omitted, callers ask the two separately.
|
|
2704
|
-
*
|
|
2705
|
-
* @param requests - See {@link TypeResolutionRequest}.
|
|
2706
|
-
*/
|
|
2707
|
-
resolveTypes?(requests: TypeResolutionRequest): Promise<TypeResolutionResult>;
|
|
2708
|
-
/**
|
|
2709
|
-
* A file type like this one that does all its file I/O — reading, writing
|
|
2710
|
-
* and importing prompt files — through `fileProvider` instead.
|
|
2711
|
-
*
|
|
2712
|
-
* How a prompt variation is materialized: the provider hands the copy an
|
|
2713
|
-
* {@link OverlayFileProvider} holding the variation's source at the
|
|
2714
|
-
* prompt's real path, and parses, edits and runs it through that.
|
|
2715
|
-
*
|
|
2716
|
-
* Optional. A file type without it can't show or run variations.
|
|
2717
|
-
*/
|
|
2718
|
-
withFileProvider?(fileProvider: FileProvider): PromptFileType;
|
|
2719
|
-
}
|
|
2720
|
-
//#endregion
|
|
2721
|
-
//#region src/sdk/sdk-adapter.d.ts
|
|
2722
|
-
/** Options for {@link SDKAdapter.executeConfig}. */
|
|
2723
|
-
interface ExecuteConfigOptions {
|
|
2724
|
-
/** The ID to use for the trace created by this execution, if any. */
|
|
2725
|
-
traceId?: string;
|
|
2726
|
-
/**
|
|
2727
|
-
* The ID the route gave this execution's root span, if any. An adapter that
|
|
2728
|
-
* records its own spans names the root span with this, so the span the
|
|
2729
|
-
* client selects when a run starts is the one that actually arrives.
|
|
2730
|
-
*/
|
|
2731
|
-
rootSpanId?: string;
|
|
2732
|
-
/**
|
|
2733
|
-
* The prompt's identity (id, name, inputs). Used to name and link the
|
|
2734
|
-
* trace when the config wasn't built by the `prompts()` helper (which would
|
|
2735
|
-
* otherwise carry that identity itself).
|
|
2736
|
-
*/
|
|
2737
|
-
identity?: PromptSpanInfo;
|
|
2738
|
-
/**
|
|
2739
|
-
* Named values the SDK needs to execute this config, resolved from the
|
|
2740
|
-
* prompt's `executeParameters` — the Vercel AI SDK's `toolsContext`, say.
|
|
2741
|
-
*
|
|
2742
|
-
* How they reach the underlying call is the adapter's business: merging
|
|
2743
|
-
* them generically would assume an execute parameter's name is always a
|
|
2744
|
-
* config key, which is true for `toolsContext` but is the adapter's fact to
|
|
2745
|
-
* know rather than the caller's.
|
|
2746
|
-
*/
|
|
2747
|
-
executeValues?: Record<string, any>;
|
|
2748
|
-
}
|
|
2749
|
-
/**
|
|
2750
|
-
* Handle on an execution that has been dispatched.
|
|
2751
|
-
*
|
|
2752
|
-
* `executeConfig` deliberately resolves as soon as the call is in flight — the
|
|
2753
|
-
* route answers with a trace id and the generation continues in the background
|
|
2754
|
-
* — so this is how a caller learns when the run is actually over, which is
|
|
2755
|
-
* what run-scoped resource teardown hangs off.
|
|
2756
|
-
*/
|
|
2757
|
-
interface ExecutionHandle {
|
|
2758
|
-
/**
|
|
2759
|
-
* Settles when the run is over, successfully or not. Never rejects: a
|
|
2760
|
-
* failure is already reported through the trace, and a caller awaiting this
|
|
2761
|
-
* only wants to know that it is safe to tear down.
|
|
2762
|
-
*/
|
|
2763
|
-
done: Promise<void>;
|
|
2764
|
-
}
|
|
2765
|
-
/**
|
|
2766
|
-
* Adapter that provides values and execution for a particular AI SDK.
|
|
2767
|
-
*
|
|
2768
|
-
* Pass an instance of this to {@link FilePromptProvider} via the
|
|
2769
|
-
* `sdk` option.
|
|
2770
|
-
*
|
|
2771
|
-
* Each `SDKAdapter` implementation should be paired with a companion package
|
|
2772
|
-
* (named by {@link SDKAdapter.promptsHelperImport}) that exports a `prompts`
|
|
2773
|
-
* function satisfying the {@link PromptsHelper} type. That function is the user-facing entry
|
|
2774
|
-
* point for defining prompts that work with Evalution. It accepts a {@link PromptsHelperOptions}
|
|
2775
|
-
* and a factory that can optionally receive SDK-specific parameters. The factory should return a
|
|
2776
|
-
* record of prompt functions. Prompt functions should return a configuration that enables OpenTelemetry
|
|
2777
|
-
* reporting, if possible, with the attributes returned by {@link getPromptSpanAttributes}.
|
|
2778
|
-
*/
|
|
2779
|
-
interface SDKAdapter {
|
|
2780
|
-
/**
|
|
2781
|
-
* The package that exports the `prompts()` helper used in new prompt files
|
|
2782
|
-
* (e.g. `'@evalution/vercel-ai-sdk'`). Used by {@link PromptFileType.newPromptSkeleton}.
|
|
2783
|
-
*/
|
|
2784
|
-
promptsHelperImport: string;
|
|
2785
|
-
/**
|
|
2786
|
-
* Returns the definition of this SDK's model slot: its type, and the
|
|
2787
|
-
* catalogs (providers, presets, free-form entries) the playground's model
|
|
2788
|
-
* picker offers.
|
|
2789
|
-
*
|
|
2790
|
-
* A per-SDK call rather than something copied onto every prompt, since the
|
|
2791
|
-
* suggestions a checker derives can run to hundreds of model IDs. It is
|
|
2792
|
-
* asked per {@link PromptStyle}, since one SDK may drive different kinds of
|
|
2793
|
-
* model — the Vercel AI SDK's chat prompts take a language model, and its
|
|
2794
|
-
* evaluation prompts an evaluation model. An adapter that only produces one
|
|
2795
|
-
* style may ignore it.
|
|
2796
|
-
*
|
|
2797
|
-
* @param project - What {@link getProjectProbes} resolved to, by probe name.
|
|
2798
|
-
* Substitute a fallback for any `undefined` result.
|
|
2799
|
-
* @param style - The style of the prompts the slot belongs to.
|
|
2800
|
-
*/
|
|
2801
|
-
getModelDefinition(project: ProbeResults, style: PromptStyle): Promise<PropDefinition$1>;
|
|
2802
|
-
/**
|
|
2803
|
-
* Returns the list of model parameters that can be edited in the playground
|
|
2804
|
-
* UI for projects rooted at `rootDir`. Typically extracted from the SDK's
|
|
2805
|
-
* published TypeScript type definitions.
|
|
2806
|
-
*
|
|
2807
|
-
* @param rootDir - Absolute path to the project root.
|
|
2808
|
-
*/
|
|
2809
|
-
getModelParameters(rootDir: string): PropDefinition$1[];
|
|
2810
|
-
/**
|
|
2811
|
-
* Executes a prompt config object.
|
|
2812
|
-
*
|
|
2813
|
-
* Resolves once the call has been dispatched, not once it has finished. Use
|
|
2814
|
-
* the returned {@link ExecutionHandle} to await completion.
|
|
2815
|
-
*
|
|
2816
|
-
* @param config - The config object returned by the prompt function.
|
|
2817
|
-
* @param options - Optional execution options (trace id, prompt identity,
|
|
2818
|
-
* resolved execute values).
|
|
2819
|
-
*/
|
|
2820
|
-
executeConfig(config: any, options?: ExecuteConfigOptions): Promise<ExecutionHandle | undefined>;
|
|
2821
|
-
/**
|
|
2822
|
-
* Called once, during server startup, before any prompt config is built,
|
|
2823
|
-
* to perform whatever setup this SDK's tracing mechanism needs
|
|
2824
|
-
* (e.g. registering a native telemetry integration, or standing up an
|
|
2825
|
-
* OpenTelemetry pipeline).
|
|
2826
|
-
*
|
|
2827
|
-
* If this SDK's tracing is built on OpenTelemetry, its implementation of
|
|
2828
|
-
* this method should call {@link setupGlobalOTelPipeline}, which
|
|
2829
|
-
* ensures the global pipeline is only set up once, even if other SDK adapters
|
|
2830
|
-
* also call it.
|
|
2831
|
-
*
|
|
2832
|
-
* Optional — adapters with no tracing support may omit it.
|
|
2833
|
-
*
|
|
2834
|
-
* @returns An ingestor to which {@link TraceSink}s should be added, or
|
|
2835
|
-
* `undefined` if tracing cannot be set up.
|
|
2836
|
-
*/
|
|
2837
|
-
setupTraceIngestion?(): Promise<TraceIngestor | undefined>;
|
|
2838
|
-
/**
|
|
2839
|
-
* Convert a low-level {@link ParsedPrompt} produced by a
|
|
2840
|
-
* {@link PromptFileType} into a {@link NormalizedPrompt} that the UI can
|
|
2841
|
-
* consume without knowing the SDK's specific property names or message shape.
|
|
2842
|
-
*
|
|
2843
|
-
* Stays synchronous: the expensive, asynchronous work of resolving probes
|
|
2844
|
-
* happens in the provider, which passes the results back in.
|
|
2845
|
-
*
|
|
2846
|
-
* The adapter also chooses the prompt's {@link PromptStyle},
|
|
2847
|
-
* which decides the editor the playground renders it in.
|
|
2848
|
-
*
|
|
2849
|
-
* @param prompt - The raw parsed prompt.
|
|
2850
|
-
* @param promptProbes - What this prompt's {@link getPromptProbes} resolved
|
|
2851
|
-
* to, in the order the probes were returned — see {@link ProbeResult}.
|
|
2852
|
-
* Absent when the file type cannot evaluate probes at all, which an
|
|
2853
|
-
* adapter should treat the same as `undefined`: declaring a parameter with
|
|
2854
|
-
* an unresolved type rather than omitting it.
|
|
2855
|
-
* @param project - What {@link getProjectProbes} resolved to, by probe name.
|
|
2856
|
-
* An adapter substitutes its own fallback for any `undefined` result.
|
|
2857
|
-
*/
|
|
2858
|
-
normalizePrompt(prompt: ParsedPrompt, promptProbes?: readonly ProbeResult[], project?: ProbeResults): NormalizedPrompt;
|
|
2859
|
-
/**
|
|
2860
|
-
* Returns the type expressions to evaluate for one prompt — chiefly to
|
|
2861
|
-
* discover its **execute parameters**, the named values this SDK needs at
|
|
2862
|
-
* run time that the prompt function's signature cannot express. Resolved
|
|
2863
|
-
* per prompt, so an expression may reference `$config`.
|
|
2864
|
-
*
|
|
2865
|
-
* The file type declares the language and this method is asked *in* it, so
|
|
2866
|
-
* the decision of whether the expression can be written at all belongs here,
|
|
2867
|
-
* where the SDK knowledge is. Return `[]` for a language this adapter does
|
|
2868
|
-
* not speak, rather than emitting every variant and hoping.
|
|
2869
|
-
*
|
|
2870
|
-
* Optional — an SDK whose configs are self-contained omits it.
|
|
2871
|
-
*
|
|
2872
|
-
* @param prompt - The parsed prompt to probe.
|
|
2873
|
-
* @param language - The file type's {@link PromptFileType.language}.
|
|
2874
|
-
*/
|
|
2875
|
-
getPromptProbes?(prompt: ParsedPrompt, language: string): TypeProbe[];
|
|
2876
|
-
/**
|
|
2877
|
-
* Returns the probes to evaluate about the project as a whole — the SDK's
|
|
2878
|
-
* own types, as installed — rather than about any one prompt. They are
|
|
2879
|
-
* resolved once per program build, in a virtual module at the project root
|
|
2880
|
-
* (so they see the project's module resolution), and cached; `$config` has
|
|
2881
|
-
* no meaning here.
|
|
2882
|
-
*
|
|
2883
|
-
* Optional, and like {@link getPromptProbes}, return `[]` for a language
|
|
2884
|
-
* this adapter does not speak.
|
|
2885
|
-
*
|
|
2886
|
-
* @param language - The file type's {@link PromptFileType.language}.
|
|
2887
|
-
*/
|
|
2888
|
-
getProjectProbes?(language: string): TypeProbe[];
|
|
2889
|
-
/**
|
|
2890
|
-
* Convert {@link NormalizedPromptUpdates} (what the UI sends back) into the
|
|
2891
|
-
* raw property-name-keyed updates that {@link PromptFileType.updateProperty}
|
|
2892
|
-
* and friends operate on.
|
|
2893
|
-
*
|
|
2894
|
-
* Throws on updates of a {@link PromptStyle} this adapter never
|
|
2895
|
-
* produces: they were written against a different editor, and guessing at
|
|
2896
|
-
* property names for them would corrupt the file.
|
|
2897
|
-
*
|
|
2898
|
-
* @param updates - Updates expressed in the normalized vocabulary.
|
|
2899
|
-
* @returns A `Record` keyed by the SDK's actual property names. Values may
|
|
2900
|
-
* be `null` (to remove) or a `PropValue`.
|
|
2901
|
-
*/
|
|
2902
|
-
denormalizeUpdates(updates: NormalizedPromptUpdates, currentValues?: Record<string, PropValue$1>): Record<string, PropValue$1 | null>;
|
|
2903
|
-
}
|
|
2904
|
-
/**
|
|
2905
|
-
* Throws unless `updates` are in the style the adapter produces. For use at
|
|
2906
|
-
* the top of {@link SDKAdapter.denormalizeUpdates}; narrows `updates` to that
|
|
2907
|
-
* style's update type.
|
|
2908
|
-
*/
|
|
2909
|
-
declare function assertUpdateStyle<S extends NormalizedPromptUpdates["style"]>(updates: NormalizedPromptUpdates, style: S): asserts updates is Extract<NormalizedPromptUpdates, {
|
|
2910
|
-
style: S;
|
|
2911
|
-
}>;
|
|
2912
|
-
//#endregion
|
|
2913
|
-
//#region src/prompt/variations/variation-store.d.ts
|
|
2914
|
-
/** A variation as stored: {@link VariationInfo} plus what only the store needs. */
|
|
2915
|
-
interface StoredVariation extends VariationInfo {
|
|
2916
|
-
/**
|
|
2917
|
-
* The prompt's `prompts()` id when it has one, so a rebase can find the
|
|
2918
|
-
* prompt at head after a file move or an export rename.
|
|
2919
|
-
*/
|
|
2920
|
-
globalId?: string;
|
|
2921
|
-
/**
|
|
2922
|
-
* The prompt's values for the fields {@link updates} sets, as they were
|
|
2923
|
-
* when it was made — the base of the three-way merge that carries it onto
|
|
2924
|
-
* a changed working tree. See `fieldValuesOf`.
|
|
2925
|
-
*/
|
|
2926
|
-
baseValues: FieldValues;
|
|
2927
|
-
}
|
|
2928
|
-
/** What identifies a variation's content. */
|
|
2929
|
-
interface VariationContent {
|
|
2930
|
-
promptId: string;
|
|
2931
|
-
globalId?: string;
|
|
2932
|
-
base?: VersionId;
|
|
2933
|
-
/** Canonical updates — see `canonicalizeUpdates`. */
|
|
2934
|
-
updates: NormalizedPromptUpdates;
|
|
2935
|
-
baseValues: FieldValues;
|
|
2936
|
-
}
|
|
2937
|
-
/** A new WIP variation. */
|
|
2938
|
-
interface NewWip extends VariationContent {
|
|
2939
|
-
/** Whether this WIP holds the unsaved edits to head. At most one per prompt. */
|
|
2940
|
-
onHead: boolean;
|
|
2941
|
-
/** The name of the variation it was opened from, if any. */
|
|
2942
|
-
originName?: string;
|
|
2943
|
-
}
|
|
2944
|
-
/** Changes to a WIP. Omitted fields are left alone; `null` clears. */
|
|
2945
|
-
interface WipChanges {
|
|
2946
|
-
updates?: NormalizedPromptUpdates;
|
|
2947
|
-
baseValues?: FieldValues;
|
|
2948
|
-
pending?: PendingConflicts | null;
|
|
2949
|
-
originName?: string | null;
|
|
2950
|
-
}
|
|
2951
|
-
/**
|
|
2952
|
-
* Where a {@link FilePromptProvider} keeps variations: immutable ("frozen")
|
|
2953
|
-
* ones, deduplicated by content, the one mutable WIP of unsaved edits to
|
|
2954
|
-
* head per prompt, and one per (prompt, old version).
|
|
2955
|
-
*
|
|
2956
|
-
* Nothing is garbage-collected: frozen rows are minted only when something
|
|
2957
|
-
* runs or gets a name, and they dedupe. See
|
|
2958
|
-
* `specs/prompt-versions-and-variations.md` §E.
|
|
2959
|
-
*/
|
|
2960
|
-
interface VariationStore {
|
|
2961
|
-
/** The variation with this id, frozen or WIP. */
|
|
2962
|
-
get(id: VariationId): Promise<StoredVariation | undefined>;
|
|
2739
|
+
* by a dotted path (`taskId`, `ctx.db`, `toolsContext.list_tasks.db`). Fit is
|
|
2740
|
+
* **assignability**, not name or spelling equality: `TaskId` and
|
|
2741
|
+
* `` `tsk_${string}` `` are one type written two ways, and a source that
|
|
2742
|
+
* produces either must be offered on a slot declared as the other.
|
|
2743
|
+
*
|
|
2744
|
+
* A match never implies a slot has no editor of its own — that is decided
|
|
2745
|
+
* from the slot's type alone. A `TaskId` slot keeps its text field and gains
|
|
2746
|
+
* the source beside it.
|
|
2747
|
+
*
|
|
2748
|
+
* Optional. Without it, callers fall back to matching on names, which is
|
|
2749
|
+
* what happens whenever no checker is available anyway.
|
|
2750
|
+
*
|
|
2751
|
+
* @param requests - One entry per prompt. See {@link SlotMatchRequest}.
|
|
2752
|
+
* @returns Positional, one per request: slot path → the `key`s of the
|
|
2753
|
+
* sources that fit it.
|
|
2754
|
+
*/
|
|
2755
|
+
resolveSlotMatches?(requests: readonly SlotMatchRequest[]): Promise<Record<string, string[]>[]>;
|
|
2963
2756
|
/**
|
|
2964
|
-
*
|
|
2965
|
-
*
|
|
2757
|
+
* Answers probes and slot matches together: the same questions, with the
|
|
2758
|
+
* same answers, as {@link resolveTypeProbes} and {@link resolveSlotMatches},
|
|
2759
|
+
* but sharing whatever it costs to answer them. For a checker-backed file
|
|
2760
|
+
* type that is a whole program build, so a caller with both kinds of
|
|
2761
|
+
* question should prefer this.
|
|
2762
|
+
*
|
|
2763
|
+
* Optional. When omitted, callers ask the two separately.
|
|
2764
|
+
*
|
|
2765
|
+
* @param requests - See {@link TypeResolutionRequest}.
|
|
2966
2766
|
*/
|
|
2967
|
-
|
|
2968
|
-
/** The WIP of unsaved edits to an old version of a prompt, if any. */
|
|
2969
|
-
getWip(promptId: string, base: VersionId): Promise<StoredVariation | undefined>;
|
|
2970
|
-
/** The WIP holding a prompt's unsaved edits to head, if any. */
|
|
2971
|
-
getHeadWip(promptId: string): Promise<StoredVariation | undefined>;
|
|
2972
|
-
/** Every head WIP, of every prompt — what the dirty indicators come from. */
|
|
2973
|
-
listHeadWips(): Promise<StoredVariation[]>;
|
|
2974
|
-
/** Creates a WIP, replacing any that holds the same slot. */
|
|
2975
|
-
putWip(v: NewWip): Promise<StoredVariation>;
|
|
2976
|
-
/** Changes a WIP in place — to edit it, rebase it, or record conflicts. */
|
|
2977
|
-
updateWip(id: VariationId, changes: WipChanges): Promise<StoredVariation>;
|
|
2978
|
-
/** Deletes a WIP. A frozen variation is never deleted. */
|
|
2979
|
-
deleteWip(id: VariationId): Promise<void>;
|
|
2980
|
-
/** A prompt's named variations and its WIPs. */
|
|
2981
|
-
list(promptId: string): Promise<StoredVariation[]>;
|
|
2982
|
-
/** Names a frozen variation. A name is unique per prompt; naming again moves it. */
|
|
2983
|
-
name(id: VariationId, promptId: string, name: string): Promise<void>;
|
|
2984
|
-
/** Removes a name. */
|
|
2985
|
-
unname(promptId: string, name: string): Promise<void>;
|
|
2767
|
+
resolveTypes?(requests: TypeResolutionRequest): Promise<TypeResolutionResult>;
|
|
2986
2768
|
/**
|
|
2987
|
-
*
|
|
2988
|
-
*
|
|
2989
|
-
*
|
|
2769
|
+
* A file type like this one that does all its file I/O — reading, writing
|
|
2770
|
+
* and importing prompt files — through `fileProvider` instead.
|
|
2771
|
+
*
|
|
2772
|
+
* How a prompt variation is materialized: the provider hands the copy an
|
|
2773
|
+
* {@link OverlayFileProvider} holding the variation's source at the
|
|
2774
|
+
* prompt's real path, and parses, edits and runs it through that.
|
|
2775
|
+
*
|
|
2776
|
+
* Optional. A file type without it can't show or run variations.
|
|
2990
2777
|
*/
|
|
2991
|
-
|
|
2778
|
+
withFileProvider?(fileProvider: FileProvider): PromptFileType;
|
|
2992
2779
|
}
|
|
2993
2780
|
//#endregion
|
|
2994
2781
|
//#region src/prompt/file/file-prompt-provider.d.ts
|
|
@@ -3038,7 +2825,7 @@ interface FilePromptProviderOptions {
|
|
|
3038
2825
|
/**
|
|
3039
2826
|
* SDK adapter that governs prompt structure and execution.
|
|
3040
2827
|
*/
|
|
3041
|
-
sdk: SDKAdapter;
|
|
2828
|
+
sdk: SDKAdapter$1;
|
|
3042
2829
|
/**
|
|
3043
2830
|
* How states of the world are named, so a trace records which content of a
|
|
3044
2831
|
* prompt it ran and an old one can be reopened. See
|
|
@@ -3309,7 +3096,7 @@ declare class FilePromptProvider implements PromptProvider<NormalizedFilePrompt>
|
|
|
3309
3096
|
*/
|
|
3310
3097
|
private applyUpdates;
|
|
3311
3098
|
getModelDefinition(style: PromptStyle): Promise<PropDefinition>;
|
|
3312
|
-
getModelParameters(): PropDefinition[];
|
|
3099
|
+
getModelParameters(): import("ts-proppy").PropDefinition[];
|
|
3313
3100
|
resolveInputs(_ref: PromptRefLike, inputs: {
|
|
3314
3101
|
functionInputs?: readonly ExecutionInput[];
|
|
3315
3102
|
executeInputs?: Record<string, ExecutionInput>;
|
|
@@ -3349,7 +3136,7 @@ declare class FilePromptProvider implements PromptProvider<NormalizedFilePrompt>
|
|
|
3349
3136
|
* trace's `executeInputs` would have names but no types.
|
|
3350
3137
|
*/
|
|
3351
3138
|
private parameterSnapshot;
|
|
3352
|
-
setupTraceIngestion(): Promise<TraceIngestor | undefined>;
|
|
3139
|
+
setupTraceIngestion(): Promise<import("@evalution/sdk").TraceIngestor | undefined>;
|
|
3353
3140
|
renamePrompt(promptId: string, newName: string): Promise<NormalizedFilePrompt>;
|
|
3354
3141
|
addPrompt(partial: Partial<NormalizedFilePrompt>): Promise<NormalizedFilePrompt | AddPromptContext>;
|
|
3355
3142
|
watch(callback: (event: PromptChangeEvent) => void): () => void;
|
|
@@ -3667,409 +3454,168 @@ declare class GitVersioning implements VersioningAdapter {
|
|
|
3667
3454
|
private git;
|
|
3668
3455
|
}
|
|
3669
3456
|
//#endregion
|
|
3670
|
-
//#region src/
|
|
3671
|
-
type BaseCreateInteractionParams = Parameters<typeof import("@google/genai").GoogleGenAI.prototype.interactions.create>[0];
|
|
3672
|
-
/**
|
|
3673
|
-
* {@link SDKAdapter} implementation for the Google GenAI
|
|
3674
|
-
* [Interactions API](https://ai.google.dev/gemini-api/docs/interactions)
|
|
3675
|
-
* (`@google/genai` package). Currently experimental and untested.
|
|
3676
|
-
*/
|
|
3677
|
-
declare class GeminiInteractionsSDK implements SDKAdapter {
|
|
3678
|
-
readonly promptsHelperImport = "FIXME";
|
|
3679
|
-
getProjectProbes(language: string): TypeProbe[];
|
|
3680
|
-
/**
|
|
3681
|
-
* One model row whose value is an honest config fragment —
|
|
3682
|
-
* `{ model: "gemini-3.5-flash" }` or `{ agent: "deep-research-…" }` —
|
|
3683
|
-
* because `interactions.create` takes one or the other, never both. The
|
|
3684
|
-
* **Models** and **Agents** catalogs each narrow their free-form entry to
|
|
3685
|
-
* their own variant.
|
|
3686
|
-
*/
|
|
3687
|
-
getModelDefinition(project: ProbeResults): Promise<PropDefinition$1>;
|
|
3688
|
-
getModelParameters(rootDir: string): PropDefinition$1[];
|
|
3689
|
-
executeConfig(config: BaseCreateInteractionParams): Promise<undefined>;
|
|
3690
|
-
normalizePrompt(prompt: ParsedPrompt): NormalizedChatPrompt;
|
|
3691
|
-
denormalizeUpdates(updates: NormalizedPromptUpdates, currentValues?: Record<string, PropValue$1>): Record<string, PropValue$1 | null>;
|
|
3692
|
-
}
|
|
3693
|
-
//#endregion
|
|
3694
|
-
//#region src/shared/setup-task.d.ts
|
|
3695
|
-
/** Fields shared by every {@link SetupStep} kind. */
|
|
3696
|
-
interface SetupStepBase {
|
|
3697
|
-
/** Stable identifier, unique within the owning {@link SetupTask}. */
|
|
3698
|
-
id: string;
|
|
3699
|
-
/**
|
|
3700
|
-
* Runtime completion status, populated by the server when listing tasks
|
|
3701
|
-
* (e.g. the config file already exists, or the package is installed). Absent
|
|
3702
|
-
* in the static step definitions held by the registry.
|
|
3703
|
-
*/
|
|
3704
|
-
completed?: boolean;
|
|
3705
|
-
}
|
|
3706
|
-
/** Writes evalution's starter config file. */
|
|
3707
|
-
interface SetupCreateConfigStep extends SetupStepBase {
|
|
3708
|
-
/** Discriminant: this step creates the project config file. */
|
|
3709
|
-
kind: "create_config";
|
|
3710
|
-
/** Project-relative path the file will be written to. */
|
|
3711
|
-
path: string;
|
|
3712
|
-
/**
|
|
3713
|
-
* Full contents of the file. Shown to the user as a copyable snippet and
|
|
3714
|
-
* written verbatim by the server. This is display data: the server reads it
|
|
3715
|
-
* from its own registry, never from a client request.
|
|
3716
|
-
*/
|
|
3717
|
-
contents: string;
|
|
3718
|
-
}
|
|
3719
|
-
/**
|
|
3720
|
-
* Runs a shell command in the project root, streamed to an interactive
|
|
3721
|
-
* terminal so the user can watch it and respond to prompts.
|
|
3722
|
-
*/
|
|
3723
|
-
interface SetupRunCommandStep extends SetupStepBase {
|
|
3724
|
-
/** Discriminant: this step runs a shell command. */
|
|
3725
|
-
kind: "run_command";
|
|
3726
|
-
/** The command line to run, e.g. `npm run build`. */
|
|
3727
|
-
command: string;
|
|
3728
|
-
/** Optional human-friendly label shown alongside the command. */
|
|
3729
|
-
label?: string;
|
|
3730
|
-
}
|
|
3731
|
-
/**
|
|
3732
|
-
* Installs an npm package — a specialization of {@link SetupRunCommandStep}
|
|
3733
|
-
* that runs `npm i <package>`. The server reports it as already
|
|
3734
|
-
* {@link SetupStepBase.completed | completed} when the package is present in
|
|
3735
|
-
* the project, so the user can skip it.
|
|
3736
|
-
*/
|
|
3737
|
-
interface SetupInstallPackageStep extends SetupStepBase {
|
|
3738
|
-
/** Discriminant: this step installs an npm package. */
|
|
3739
|
-
kind: "install_package";
|
|
3740
|
-
/** The npm package to install, e.g. `@evalution/vercel-ai-sdk`. */
|
|
3741
|
-
package: string;
|
|
3742
|
-
}
|
|
3743
|
-
/**
|
|
3744
|
-
* A single executable step within a {@link SetupTask}.
|
|
3745
|
-
*
|
|
3746
|
-
* Steps are defined server-side and addressed by {@link SetupTask.id} plus the
|
|
3747
|
-
* step's `id`; the client references a step only by those ids when asking the
|
|
3748
|
-
* server to run it.
|
|
3749
|
-
*/
|
|
3750
|
-
type SetupStep = {
|
|
3751
|
-
disabledReason?: string;
|
|
3752
|
-
} & (SetupCreateConfigStep | SetupRunCommandStep | SetupInstallPackageStep);
|
|
3753
|
-
/**
|
|
3754
|
-
* A named onboarding task for a single AI SDK: what to show in the manual-setup
|
|
3755
|
-
* picker, plus the ordered steps that wire the SDK up.
|
|
3756
|
-
*/
|
|
3757
|
-
interface SetupTask {
|
|
3758
|
-
/** Stable identifier, also used as the wire id for this SDK choice. */
|
|
3759
|
-
id: string;
|
|
3760
|
-
/** Display label for the picker (typically the SDK's product name). */
|
|
3761
|
-
label: string;
|
|
3762
|
-
/** Icon identifier, mapped to a bundled asset on the client. */
|
|
3763
|
-
icon: string;
|
|
3764
|
-
/** Ordered steps to run, in display order. */
|
|
3765
|
-
steps: SetupStep[];
|
|
3766
|
-
}
|
|
3767
|
-
//#endregion
|
|
3768
|
-
//#region src/sdk/typesafe-sdk/telemetry.d.ts
|
|
3769
|
-
/**
|
|
3770
|
-
* The key under which the `prompts()` helper attaches a config's prompt
|
|
3771
|
-
* identity. A symbol, because a System One request object is sent to the API
|
|
3772
|
-
* as-is: a string key would be sent along and fail validation, while a symbol
|
|
3773
|
-
* survives a spread and is dropped by `JSON.stringify`.
|
|
3774
|
-
*/
|
|
3775
|
-
declare const PROMPT_IDENTITY: unique symbol;
|
|
3776
|
-
/** One System One call being recorded. See {@link TypeSafeTelemetry.startCall}. */
|
|
3777
|
-
interface SystemOneCallRecord {
|
|
3778
|
-
/** Records the call's result and ends its span. */
|
|
3779
|
-
end(result: SystemOneResult<Questions>): Promise<void>;
|
|
3780
|
-
/** Records the call's failure and ends its span as an error. */
|
|
3781
|
-
fail(err: unknown): Promise<void>;
|
|
3782
|
-
}
|
|
3783
|
-
/** Options for {@link TypeSafeTelemetry.startCall}. */
|
|
3784
|
-
interface SystemOneCallOptions {
|
|
3785
|
-
/** The trace to record into. */
|
|
3786
|
-
traceId: string;
|
|
3787
|
-
/** The span's ID; defaults to the trace's conventional root span ID. */
|
|
3788
|
-
spanId?: string;
|
|
3789
|
-
/** The prompt the call was made for, if known. */
|
|
3790
|
-
identity?: PromptSpanInfo;
|
|
3791
|
-
/** The request, recorded as the span's input. */
|
|
3792
|
-
request: SystemOneRequest<Questions>;
|
|
3793
|
-
/** The model the request will be answered by, if the request doesn't say. */
|
|
3794
|
-
defaultModel?: string;
|
|
3795
|
-
}
|
|
3457
|
+
//#region src/shared/instance-names.d.ts
|
|
3796
3458
|
/**
|
|
3797
|
-
*
|
|
3798
|
-
*
|
|
3799
|
-
*
|
|
3459
|
+
* What a run's resource instance may be named — shared by the server, which
|
|
3460
|
+
* refuses anything else, and the client, which says so before sending. See
|
|
3461
|
+
* `specs/resource-instances.md` §A.2.
|
|
3800
3462
|
*/
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
startCall({
|
|
3804
|
-
traceId,
|
|
3805
|
-
spanId,
|
|
3806
|
-
identity,
|
|
3807
|
-
request,
|
|
3808
|
-
defaultModel
|
|
3809
|
-
}: SystemOneCallOptions): Promise<SystemOneCallRecord>;
|
|
3810
|
-
}
|
|
3463
|
+
/** Whether `name` is a valid instance name: `[A-Za-z_][A-Za-z0-9_-]*`. */
|
|
3464
|
+
declare function isValidInstanceName(name: string): boolean;
|
|
3811
3465
|
//#endregion
|
|
3812
|
-
//#region src/
|
|
3813
|
-
type TypeSafeClientConfig = import("@typesafe-ai/sdk").TypeSafeClientConfig;
|
|
3814
|
-
type SystemOneRequest$1 = import("@typesafe-ai/sdk").SystemOneRequest;
|
|
3815
|
-
/** Options for {@link TypeSafeSDK}. */
|
|
3816
|
-
interface TypeSafeSDKOptions {
|
|
3817
|
-
/**
|
|
3818
|
-
* Configuration for the `TypeSafeClient` this adapter builds to list models
|
|
3819
|
-
* and execute prompts. Defaults to the SDK's own (API key and base URL from
|
|
3820
|
-
* the environment).
|
|
3821
|
-
*/
|
|
3822
|
-
client?: TypeSafeClientConfig;
|
|
3823
|
-
}
|
|
3466
|
+
//#region src/trace/base-trace-provider.d.ts
|
|
3824
3467
|
/**
|
|
3825
|
-
* {@link
|
|
3826
|
-
*
|
|
3827
|
-
*
|
|
3828
|
-
* A System One request isn't a chat: it asks a set of named, typed questions
|
|
3829
|
-
* about a `state`. So its prompts are normalized to the `questions` style,
|
|
3830
|
-
* whose editor is built around the questions rather than a message list.
|
|
3468
|
+
* Source-agnostic base class for a {@link TraceProvider}. Owns storage
|
|
3469
|
+
* delegation, subscriptions, watchers, and the generic trace lifecycle that
|
|
3470
|
+
* every concrete provider shares, regardless of how spans are produced.
|
|
3831
3471
|
*
|
|
3832
|
-
*
|
|
3833
|
-
*
|
|
3834
|
-
*
|
|
3835
|
-
*
|
|
3472
|
+
* Subclasses implement the abstract storage hooks; ingestion is handled by
|
|
3473
|
+
* one or more {@link TraceIngestor}s that call {@link recordSpanStart} /
|
|
3474
|
+
* {@link recordSpanEnd} / {@link failTrace} on this instance (via
|
|
3475
|
+
* {@link TraceSink}).
|
|
3836
3476
|
*/
|
|
3837
|
-
declare class
|
|
3838
|
-
readonly
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
}
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
* presets. Listing needs an API key and the network, so it falls back to the
|
|
3857
|
-
* default model alone.
|
|
3858
|
-
*/
|
|
3859
|
-
getModelDefinition(project: ProbeResults): Promise<PropDefinition$1>;
|
|
3860
|
-
/** Model names from the API, listed once per adapter. */
|
|
3861
|
-
private listModels;
|
|
3862
|
-
/** Per-call options are transport settings, not prompt content. */
|
|
3863
|
-
getModelParameters(): PropDefinition$1[];
|
|
3864
|
-
normalizePrompt(prompt: ParsedPrompt, _promptProbes?: readonly ProbeResult[], project?: ProbeResults): NormalizedQuestionsPrompt;
|
|
3477
|
+
declare abstract class BaseTraceProvider implements TraceProvider, TraceSink$1 {
|
|
3478
|
+
readonly id: string;
|
|
3479
|
+
readonly displayName?: string;
|
|
3480
|
+
readonly description?: string;
|
|
3481
|
+
protected subscribers: Map<string, Set<(event: TraceStreamEvent$1) => void>>;
|
|
3482
|
+
private watchers;
|
|
3483
|
+
private annotationSubscribers;
|
|
3484
|
+
constructor(options: {
|
|
3485
|
+
id: string;
|
|
3486
|
+
displayName: string;
|
|
3487
|
+
description: string;
|
|
3488
|
+
});
|
|
3489
|
+
abstract getAllTraces(query?: TraceQuery): Promise<TraceSummary$1[]>;
|
|
3490
|
+
/** Groups what {@link getAllTraces} lists for the query, in memory. */
|
|
3491
|
+
groupTraces(query: TraceGroupQuery): Promise<TraceGroup[]>;
|
|
3492
|
+
abstract hasTrace(traceId: string): Promise<boolean>;
|
|
3493
|
+
protected abstract getTraceWithoutSpans(traceId: string): Promise<Trace$1 | undefined>;
|
|
3494
|
+
protected abstract getTraceSpans(traceId: string): Promise<Span$1[]>;
|
|
3495
|
+
protected abstract addOrUpdateTrace(trace: Trace$1): Promise<void>;
|
|
3865
3496
|
/**
|
|
3866
|
-
*
|
|
3867
|
-
*
|
|
3497
|
+
* Removes a trace together with its spans and annotations. Only called for
|
|
3498
|
+
* a trace that {@link hasTrace} confirmed exists.
|
|
3868
3499
|
*/
|
|
3869
|
-
|
|
3500
|
+
protected abstract removeTrace(traceId: string): Promise<void>;
|
|
3870
3501
|
/**
|
|
3871
|
-
*
|
|
3872
|
-
*
|
|
3873
|
-
*
|
|
3874
|
-
*
|
|
3502
|
+
* Stores a span, merging it into any existing span with the same ID (via
|
|
3503
|
+
* the `mergeSpans` helper). Returns the resulting stored span so callers
|
|
3504
|
+
* can stream the merged view rather than the partial snapshot they passed
|
|
3505
|
+
* in.
|
|
3875
3506
|
*/
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
/** The client executions use, built once. */
|
|
3882
|
-
private client;
|
|
3883
|
-
setupTraceIngestion(): Promise<TypeSafeTelemetry>;
|
|
3884
|
-
}
|
|
3885
|
-
//#endregion
|
|
3886
|
-
//#region src/sdk/vercel-ai-sdk/index.d.ts
|
|
3887
|
-
/**
|
|
3888
|
-
* {@link SDKAdapter} implementation for the
|
|
3889
|
-
* [Vercel AI SDK](https://sdk.vercel.ai/).
|
|
3890
|
-
*
|
|
3891
|
-
* - `getModelParameters` reads `CallSettings` from the SDK's `.d.ts` bundle
|
|
3892
|
-
* and surfaces parameters with simple types that can be edited in the UI.
|
|
3893
|
-
* - `executeConfig` delegates to `generateText`.
|
|
3894
|
-
*
|
|
3895
|
-
* A prompt whose config asks `questions` is an `experimental_evaluate` call
|
|
3896
|
-
* instead: it is edited in the `questions` style and executed with
|
|
3897
|
-
* `experimental_evaluate`. Both are traced through the same native telemetry.
|
|
3898
|
-
*/
|
|
3899
|
-
declare class VercelAISDK implements SDKAdapter {
|
|
3900
|
-
readonly promptsHelperImport: "@evalution/vercel-ai-sdk";
|
|
3507
|
+
protected abstract addOrUpdateSpan(span: Span$1): Promise<Span$1>;
|
|
3508
|
+
getTrace(traceId: string): Promise<TraceWithSpans$1 | undefined>;
|
|
3509
|
+
deleteTrace(traceId: string): Promise<boolean>;
|
|
3510
|
+
subscribeTrace(traceId: string, callback: (event: TraceStreamEvent$1) => void): () => void;
|
|
3511
|
+
watch(callback: (event: TraceChangeEvent$1) => void): () => void;
|
|
3901
3512
|
/**
|
|
3902
|
-
*
|
|
3903
|
-
*
|
|
3513
|
+
* Generic pub-sub for annotation changes — every subclass gets a working
|
|
3514
|
+
* implementation "for free", even one with no annotation store of its own
|
|
3515
|
+
* (e.g. `MemoryTraceProvider`): nothing is ever delivered unless a caller
|
|
3516
|
+
* (the annotation REST handlers) explicitly calls {@link emitAnnotation}.
|
|
3904
3517
|
*/
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
getModelParameters(rootDir: string): PropDefinition$1[];
|
|
3518
|
+
subscribeAnnotations(traceId: string, callback: (event: AnnotationEvent$1) => void): () => void;
|
|
3519
|
+
emitAnnotation(traceId: string, op: AnnotationEventOp$1, annotation: Annotation$1): void;
|
|
3520
|
+
recordSpanStart(span: Span$1): Promise<Span$1>;
|
|
3521
|
+
recordSpanEnd(span: Span$1): Promise<Span$1>;
|
|
3910
3522
|
/**
|
|
3911
|
-
*
|
|
3912
|
-
*
|
|
3913
|
-
|
|
3914
|
-
private static readonly TOOLS_CONTEXT_PROBE;
|
|
3915
|
-
getPromptProbes(prompt: ParsedPrompt, language: string): TypeProbe[];
|
|
3916
|
-
executeConfig(config: any, {
|
|
3917
|
-
traceId,
|
|
3918
|
-
identity,
|
|
3919
|
-
executeValues
|
|
3920
|
-
}?: ExecuteConfigOptions): Promise<ExecutionHandle>;
|
|
3921
|
-
setupTraceIngestion(): Promise<TraceIngestor | undefined>;
|
|
3922
|
-
private doSetupTraceIngestion;
|
|
3923
|
-
normalizePrompt(prompt: ParsedPrompt, resolvedProbes?: readonly ProbeResult[], project?: ProbeResults): NormalizedPrompt;
|
|
3924
|
-
private normalizeChatPrompt;
|
|
3925
|
-
/**
|
|
3926
|
-
* Assemble the prompt's execute parameters from what the probes resolved to.
|
|
3927
|
-
*
|
|
3928
|
-
* The interesting case is the third one. When no probe could run — a file
|
|
3929
|
-
* type with no checker, an in-memory provider, a resolution failure — the
|
|
3930
|
-
* parameter is still declared, with an unresolved type. "This prompt needs
|
|
3931
|
-
* `toolsContext` and I cannot tell you its shape" is a usable state; staying
|
|
3932
|
-
* silent reproduces exactly the failure this machinery exists to prevent,
|
|
3933
|
-
* where the first tool call dies at run time with nothing having warned you.
|
|
3934
|
-
*
|
|
3935
|
-
* That degradation is scoped by a cheap syntactic check — does the config
|
|
3936
|
-
* even have a `tools` property? — so a prompt that plainly has no tools does
|
|
3937
|
-
* not sprout a mystery parameter.
|
|
3523
|
+
* Marks a trace that already ended as running again: its root span has just
|
|
3524
|
+
* been started anew (a failed run being retried), so the failure it recorded
|
|
3525
|
+
* is no longer its state.
|
|
3938
3526
|
*/
|
|
3939
|
-
private
|
|
3940
|
-
|
|
3527
|
+
private reopenTrace;
|
|
3528
|
+
failTrace(traceId: string, errorMessage: string): Promise<void>;
|
|
3529
|
+
protected emitStream(traceId: string, event: TraceStreamEvent$1): void;
|
|
3530
|
+
protected emitChange(event: TraceChangeEvent$1): void;
|
|
3941
3531
|
}
|
|
3942
3532
|
//#endregion
|
|
3943
|
-
//#region src/
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
*
|
|
3950
|
-
*
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
/**
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
* defers to it by default (see {@link VercelAISDKTelemetryOptions.nativeTelemetry}) rather
|
|
4005
|
-
* than emitting a duplicate, parallel trace.
|
|
4006
|
-
*/
|
|
4007
|
-
declare class VercelAISDKTelemetry extends BaseTraceIngestor implements Telemetry {
|
|
4008
|
-
/**
|
|
4009
|
-
* This instance's configured {@link VercelAISDKTelemetryOptions.nativeTelemetry}.
|
|
4010
|
-
* Read by the `prompts()` helper to decide whether to defer to a sibling
|
|
4011
|
-
* OpenTelemetry integration for a given call.
|
|
4012
|
-
*/
|
|
4013
|
-
readonly nativeTelemetry: "auto" | "always" | "never";
|
|
4014
|
-
private readonly runs;
|
|
4015
|
-
constructor(options?: VercelAISDKTelemetryOptions);
|
|
4016
|
-
private shouldDeferGlobally;
|
|
4017
|
-
onStart: Callbacks["onStart"];
|
|
4018
|
-
onStepStart: Callbacks["onStepStart"];
|
|
4019
|
-
onToolExecutionStart: Callbacks["onToolExecutionStart"];
|
|
4020
|
-
onToolExecutionEnd: Callbacks["onToolExecutionEnd"];
|
|
4021
|
-
onStepEnd: Callbacks["onStepEnd"];
|
|
4022
|
-
onEnd: Callbacks["onEnd"];
|
|
4023
|
-
onAbort: Callbacks["onAbort"];
|
|
4024
|
-
onError: Callbacks["onError"];
|
|
4025
|
-
experimental_onEvaluateStart: Callbacks["experimental_onEvaluateStart"];
|
|
4026
|
-
experimental_onEvaluateEnd: Callbacks["experimental_onEvaluateEnd"];
|
|
4027
|
-
/**
|
|
4028
|
-
* Mints a `PerPromptTelemetry` integration bound to the given prompt identity.
|
|
4029
|
-
* Used by the `prompts()` helper so a helper-defined prompt is recorded with
|
|
4030
|
-
* full identity. Called with no `identity` (e.g. by the playground for a raw,
|
|
4031
|
-
* non-helper config) it still binds a trace id but records without prompt
|
|
4032
|
-
* identity — the same data the global fallback would, just under a known id.
|
|
4033
|
-
*/
|
|
4034
|
-
createTelemetryForPrompt(identity?: PromptSpanInfo): PerPromptTelemetry;
|
|
4035
|
-
private handleStart;
|
|
3533
|
+
//#region src/trace/cloud-trace-provider.d.ts
|
|
3534
|
+
/** The calls {@link CloudTraceProvider} makes of the cloud. */
|
|
3535
|
+
type CloudTraceClient = Pick<Evalution$1, "listTraces" | "getTrace" | "listTraceGroups">;
|
|
3536
|
+
/** Options for {@link CloudTraceProvider}. */
|
|
3537
|
+
interface CloudTraceProviderOptions {
|
|
3538
|
+
/**
|
|
3539
|
+
* The cloud client, with a personal key and the project to read: what
|
|
3540
|
+
* `evalution` builds from `EVALUTION_API_KEY` and the config's
|
|
3541
|
+
* `cloud.project`.
|
|
3542
|
+
*/
|
|
3543
|
+
client: CloudTraceClient;
|
|
3544
|
+
/** Defaults to `"cloud"`. */
|
|
3545
|
+
id?: string;
|
|
3546
|
+
displayName?: string;
|
|
3547
|
+
description?: string;
|
|
3548
|
+
/** Only traces from this deployment environment. Defaults to all of them. */
|
|
3549
|
+
environment?: string;
|
|
3550
|
+
/** How many of the most recent traces to list. Defaults to 200. */
|
|
3551
|
+
limit?: number;
|
|
3552
|
+
/** How far back to list traces, in ms. Defaults to a week. */
|
|
3553
|
+
windowMs?: number;
|
|
3554
|
+
/** How often to check for new and changed traces while watched, in ms. */
|
|
3555
|
+
pollIntervalMs?: number;
|
|
3556
|
+
/** Where to report a cloud that can't be reached. Defaults to `console`. */
|
|
3557
|
+
log?: Pick<Console, "warn">;
|
|
3558
|
+
}
|
|
3559
|
+
/**
|
|
3560
|
+
* The project's production traces, read from Evalution Cloud: what the apps
|
|
3561
|
+
* you deployed sent with an ingest key. Read-only. There's no live stream of
|
|
3562
|
+
* a trace's spans, and no annotations or SQL; {@link watch} polls the cloud
|
|
3563
|
+
* for new and changed traces instead.
|
|
3564
|
+
*
|
|
3565
|
+
* `evalution` adds one of these next to the configured trace providers when
|
|
3566
|
+
* `EVALUTION_API_KEY` is a personal key and `.evalution/config.ts` links a
|
|
3567
|
+
* project.
|
|
3568
|
+
*
|
|
3569
|
+
* It lists the most recent traces within a window (see
|
|
3570
|
+
* {@link CloudTraceProviderOptions}), since {@link TraceProvider.getAllTraces}
|
|
3571
|
+
* doesn't page. A search, filters and grouping run in the cloud, so they
|
|
3572
|
+
* reach every trace in the window, not only the most recent ones. A cloud
|
|
3573
|
+
* that can't be reached never fails the listing: the last traces it returned
|
|
3574
|
+
* are shown instead, and the failure is reported once.
|
|
3575
|
+
*/
|
|
3576
|
+
declare class CloudTraceProvider implements TraceProvider {
|
|
3577
|
+
readonly id: string;
|
|
3578
|
+
readonly displayName: string;
|
|
3579
|
+
readonly description: string;
|
|
3580
|
+
private readonly client;
|
|
3581
|
+
private readonly environment?;
|
|
3582
|
+
private readonly limit;
|
|
3583
|
+
private readonly windowMs;
|
|
3584
|
+
private readonly pollIntervalMs;
|
|
3585
|
+
private readonly log;
|
|
3586
|
+
private watchers;
|
|
3587
|
+
private timer;
|
|
3588
|
+
/** What the last listing returned, by id, as {@link fingerprint}s. */
|
|
3589
|
+
private known;
|
|
3590
|
+
private lastListed;
|
|
3591
|
+
private failing;
|
|
3592
|
+
constructor(options: CloudTraceProviderOptions);
|
|
3593
|
+
getAllTraces(query?: TraceQuery): Promise<TraceSummary$1[]>;
|
|
4036
3594
|
/**
|
|
4037
|
-
*
|
|
4038
|
-
*
|
|
4039
|
-
*
|
|
3595
|
+
* The groups of every trace in the window that `query` matches, counted in
|
|
3596
|
+
* the cloud. When it can't be reached, the last traces it listed are
|
|
3597
|
+
* grouped instead.
|
|
4040
3598
|
*/
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
private handleStepStart;
|
|
4044
|
-
private handleToolExecutionStart;
|
|
4045
|
-
private handleToolExecutionEnd;
|
|
4046
|
-
private handleStepEnd;
|
|
4047
|
-
private handleEnd;
|
|
4048
|
-
private handleAbort;
|
|
3599
|
+
groupTraces(query: TraceGroupQuery): Promise<TraceGroup[]>;
|
|
3600
|
+
getTrace(traceId: string): Promise<TraceWithSpans$1 | undefined>;
|
|
4049
3601
|
/**
|
|
4050
|
-
*
|
|
4051
|
-
*
|
|
4052
|
-
* the `fail()` path so a mid-flight rejection doesn't leave spans hanging in
|
|
4053
|
-
* `running`.
|
|
3602
|
+
* Polls the cloud while anyone is watching. Each new trace is an `add`,
|
|
3603
|
+
* each changed one an `update`, and one that's left the window a `remove`.
|
|
4054
3604
|
*/
|
|
4055
|
-
|
|
3605
|
+
watch(callback: (event: TraceChangeEvent$1) => void): () => void;
|
|
3606
|
+
/** The traces every listing is of: the environment's, in the window. */
|
|
3607
|
+
private window;
|
|
3608
|
+
private reportFailure;
|
|
4056
3609
|
/**
|
|
4057
|
-
*
|
|
4058
|
-
*
|
|
3610
|
+
* Lists the traces `query` matches. A listing of them all also notes what
|
|
3611
|
+
* changed since the last one.
|
|
4059
3612
|
*/
|
|
4060
|
-
private
|
|
4061
|
-
private
|
|
3613
|
+
private list;
|
|
3614
|
+
private noteChanges;
|
|
3615
|
+
private schedule;
|
|
3616
|
+
private emit;
|
|
4062
3617
|
}
|
|
4063
3618
|
//#endregion
|
|
4064
|
-
//#region src/shared/instance-names.d.ts
|
|
4065
|
-
/**
|
|
4066
|
-
* What a run's resource instance may be named — shared by the server, which
|
|
4067
|
-
* refuses anything else, and the client, which says so before sending. See
|
|
4068
|
-
* `specs/resource-instances.md` §A.2.
|
|
4069
|
-
*/
|
|
4070
|
-
/** Whether `name` is a valid instance name: `[A-Za-z_][A-Za-z0-9_-]*`. */
|
|
4071
|
-
declare function isValidInstanceName(name: string): boolean;
|
|
4072
|
-
//#endregion
|
|
4073
3619
|
//#region src/trace/db/local-turso-client.d.ts
|
|
4074
3620
|
interface LocalTursoClientOptions {
|
|
4075
3621
|
/** Path to the local SQLite file (e.g. `<rootDir>/.evalution/trace.db`). */
|
|
@@ -4093,6 +3639,12 @@ interface LocalTursoClientOptions {
|
|
|
4093
3639
|
getAuthToken?: () => Promise<string>;
|
|
4094
3640
|
/** Identifies this client to the sync engine (shown in Turso's dashboard). */
|
|
4095
3641
|
clientName?: string;
|
|
3642
|
+
/**
|
|
3643
|
+
* Called when a database new to this machine couldn't be started from the
|
|
3644
|
+
* cloud's copy (the cloud was unreachable), so it was opened empty instead.
|
|
3645
|
+
* Sync stays on: the next pull brings the cloud's rows.
|
|
3646
|
+
*/
|
|
3647
|
+
onBootstrapFailure?: (err: unknown) => void;
|
|
4096
3648
|
}
|
|
4097
3649
|
/**
|
|
4098
3650
|
* Connects to a local SQLite database that starts purely local and, once
|
|
@@ -4112,7 +3664,8 @@ declare function createLocalTursoClient({
|
|
|
4112
3664
|
path,
|
|
4113
3665
|
getCloudUrl,
|
|
4114
3666
|
getAuthToken,
|
|
4115
|
-
clientName
|
|
3667
|
+
clientName,
|
|
3668
|
+
onBootstrapFailure
|
|
4116
3669
|
}: LocalTursoClientOptions): Promise<Database>;
|
|
4117
3670
|
//#endregion
|
|
4118
3671
|
//#region src/trace/db/query-schema.d.ts
|
|
@@ -4125,69 +3678,6 @@ declare function createLocalTursoClient({
|
|
|
4125
3678
|
/** The trace database's tables, described for someone writing SQL against them. */
|
|
4126
3679
|
declare const TRACE_QUERY_SCHEMA = "-- Trace database (SQLite). Timestamps are milliseconds since the Unix epoch.\n-- Columns marked JSON hold JSON text; read into them with json_extract(),\n-- e.g. json_extract(llm_parameters, '$.temperature').\n\n-- One row per trace: a single run, e.g. one prompt execution.\nCREATE TABLE traces (\n id TEXT PRIMARY KEY,\n provider_id TEXT, -- the trace provider that recorded it\n name TEXT NOT NULL, -- usually the prompt's name\n start_time REAL NOT NULL, -- ms since epoch\n end_time REAL, -- ms since epoch; NULL while running\n status TEXT NOT NULL, -- 'running' | 'ok' | 'error'\n attributes TEXT -- JSON object of free-form attributes\n);\n\n-- One row per span. Spans form a tree per trace via parent_id.\nCREATE TABLE spans (\n id TEXT PRIMARY KEY,\n trace_id TEXT NOT NULL, -- traces.id\n parent_id TEXT, -- spans.id; NULL for the root span\n name TEXT NOT NULL,\n kind TEXT NOT NULL, -- 'LLM' | 'TOOL' | 'AGENT' | 'EMBEDDING' | 'CHECK' | 'DEFAULT'\n start_time REAL NOT NULL, -- ms since epoch\n end_time REAL, -- ms since epoch; NULL while running\n status TEXT, -- 'ok' | 'error'; NULL while running\n error_message TEXT,\n llm_provider TEXT, -- e.g. 'openai', 'anthropic'\n llm_model TEXT, -- e.g. 'gpt-4o'\n llm_finish_reason TEXT, -- e.g. 'stop', 'length', 'tool-calls'\n llm_prompt_tokens INTEGER, -- includes cache reads and writes\n llm_completion_tokens INTEGER,\n llm_total_tokens INTEGER,\n llm_cache_read_tokens INTEGER, -- of llm_prompt_tokens, read from a prompt cache\n llm_cache_write_tokens INTEGER, -- of llm_prompt_tokens, written to a prompt cache\n llm_cost_prompt REAL, -- USD, cache reads and writes included\n llm_cost_completion REAL, -- USD\n llm_cost_cache_read REAL, -- USD, the part of llm_cost_prompt spent on cache reads\n llm_cost_cache_write REAL, -- USD, the part of llm_cost_prompt spent on cache writes\n llm_input TEXT, -- JSON: an array of messages {role, content}, or any JSON object\n llm_output TEXT, -- JSON: always encoded, so a text output is a JSON string\n llm_reasoning TEXT, -- the model's reasoning for this turn, as plain text\n llm_parameters TEXT, -- JSON object of model parameters (temperature, ...)\n attributes TEXT, -- JSON object of free-form attributes; \"evalution.check\" is set on spans an eval check recorded while judging the trace (its CHECK span and everything under it), which aren't part of the run\n resource TEXT, -- JSON object: the OTel resource that produced the span (\"service.name\", \"deployment.environment.name\" = 'playground' for runs evalution made, ...)\n prompt TEXT, -- JSON {id, providerId?, version?, variation?, functionInputs?, executeInputs?, ...}: the prompt this span ran\n tool TEXT -- JSON {toolName, input, output?} for TOOL spans\n);\n\n-- Notes left on a trace, or on one span of it.\nCREATE TABLE annotations (\n id TEXT PRIMARY KEY,\n trace_id TEXT NOT NULL, -- traces.id\n span_id TEXT, -- spans.id; NULL for a note on the whole trace\n kind TEXT NOT NULL, -- 'issue' | 'good' | 'note'\n note TEXT NOT NULL,\n source TEXT NOT NULL, -- 'user' | 'claude-code' | 'codex' | 'agent'\n created_at REAL NOT NULL -- ms since epoch\n);\n";
|
|
4127
3680
|
//#endregion
|
|
4128
|
-
//#region src/trace/http-trace-sink.d.ts
|
|
4129
|
-
/**
|
|
4130
|
-
* Where an evalution server accepts {@link TraceSinkEvent}s, relative to its
|
|
4131
|
-
* base URL.
|
|
4132
|
-
*/
|
|
4133
|
-
declare const TRACE_EVENTS_PATH = "/api/traces";
|
|
4134
|
-
/** One {@link TraceSink} call, as {@link HttpTraceSink} sends it. */
|
|
4135
|
-
type TraceSinkEvent = {
|
|
4136
|
-
type: "span-start";
|
|
4137
|
-
span: Span;
|
|
4138
|
-
} | {
|
|
4139
|
-
type: "span-end";
|
|
4140
|
-
span: Span;
|
|
4141
|
-
} | {
|
|
4142
|
-
type: "trace-fail";
|
|
4143
|
-
traceId: string;
|
|
4144
|
-
errorMessage: string;
|
|
4145
|
-
};
|
|
4146
|
-
/** The body of a `POST` to {@link TRACE_EVENTS_PATH}. */
|
|
4147
|
-
interface TraceEventsRequest {
|
|
4148
|
-
/** The events to record, in the order they happened. */
|
|
4149
|
-
events: TraceSinkEvent[];
|
|
4150
|
-
}
|
|
4151
|
-
/** Options for {@link HttpTraceSink}. */
|
|
4152
|
-
interface HttpTraceSinkOptions {
|
|
4153
|
-
/**
|
|
4154
|
-
* The evalution server's base URL, e.g. `http://localhost:3000`. Events are
|
|
4155
|
-
* posted to {@link TRACE_EVENTS_PATH} under it.
|
|
4156
|
-
*/
|
|
4157
|
-
endpoint: string;
|
|
4158
|
-
/** The `fetch` to send with. Defaults to the global one. */
|
|
4159
|
-
fetch?: typeof fetch;
|
|
4160
|
-
}
|
|
4161
|
-
/**
|
|
4162
|
-
* A {@link TraceSink} that sends what it's given to an evalution server,
|
|
4163
|
-
* which records it through its own trace providers — so an app's traces show
|
|
4164
|
-
* up in the playground without the app writing to a trace store itself.
|
|
4165
|
-
*
|
|
4166
|
-
* Calls return as soon as the event is queued, never waiting on the network,
|
|
4167
|
-
* so tracing doesn't slow the app down. Queued events go out in order, batched
|
|
4168
|
-
* into one request at a time, so a span's end never overtakes its start. A
|
|
4169
|
-
* request that fails is logged and its events dropped: tracing never breaks
|
|
4170
|
-
* the app. Await {@link flush} before a short-lived process exits to be sure
|
|
4171
|
-
* everything was sent.
|
|
4172
|
-
*/
|
|
4173
|
-
declare class HttpTraceSink implements TraceSink {
|
|
4174
|
-
private readonly url;
|
|
4175
|
-
private readonly fetch;
|
|
4176
|
-
private queue;
|
|
4177
|
-
private sending?;
|
|
4178
|
-
/** Whether the last request failed, so a down server is reported once. */
|
|
4179
|
-
private failing;
|
|
4180
|
-
constructor(options: HttpTraceSinkOptions);
|
|
4181
|
-
recordSpanStart(span: Span): Promise<Span>;
|
|
4182
|
-
recordSpanEnd(span: Span): Promise<Span>;
|
|
4183
|
-
failTrace(traceId: string, errorMessage: string): Promise<void>;
|
|
4184
|
-
/** Resolves once every event recorded so far has been sent (or dropped). */
|
|
4185
|
-
flush(): Promise<void>;
|
|
4186
|
-
private enqueue;
|
|
4187
|
-
private drain;
|
|
4188
|
-
private send;
|
|
4189
|
-
}
|
|
4190
|
-
//#endregion
|
|
4191
3681
|
//#region src/trace/local-database-trace-provider.d.ts
|
|
4192
3682
|
interface LocalDatabaseTraceProviderOptions {
|
|
4193
3683
|
/**
|
|
@@ -4196,6 +3686,10 @@ interface LocalDatabaseTraceProviderOptions {
|
|
|
4196
3686
|
* @default "./.evalution/traces/local.db"
|
|
4197
3687
|
*/
|
|
4198
3688
|
path?: string;
|
|
3689
|
+
/**
|
|
3690
|
+
* Also names the database in Evalution Cloud when the project is linked:
|
|
3691
|
+
* changing it starts a new cloud copy.
|
|
3692
|
+
*/
|
|
4199
3693
|
id?: string;
|
|
4200
3694
|
displayName?: string;
|
|
4201
3695
|
description?: string;
|
|
@@ -4217,6 +3711,12 @@ declare class LocalDatabaseTraceProvider extends BaseTraceProvider {
|
|
|
4217
3711
|
* migrations — and re-logging the same stack — once per span.
|
|
4218
3712
|
*/
|
|
4219
3713
|
private openFailure;
|
|
3714
|
+
private sync;
|
|
3715
|
+
/** The open file, for sync. */
|
|
3716
|
+
private client;
|
|
3717
|
+
/** Holds operations while sync swaps the database file. */
|
|
3718
|
+
private readonly gate;
|
|
3719
|
+
private unwatchReal;
|
|
4220
3720
|
constructor(options?: LocalDatabaseTraceProviderOptions);
|
|
4221
3721
|
/**
|
|
4222
3722
|
* Reports — once — that the database could not be opened, and leaves this
|
|
@@ -4226,6 +3726,20 @@ declare class LocalDatabaseTraceProvider extends BaseTraceProvider {
|
|
|
4226
3726
|
* Explicit user actions still fail loudly (see {@link createAnnotation}).
|
|
4227
3727
|
*/
|
|
4228
3728
|
private reportOpenFailure;
|
|
3729
|
+
/**
|
|
3730
|
+
* Syncs the database with the linked project's copy (named by this
|
|
3731
|
+
* provider's id), once `setUpProject` hands this the project's sync. Opens
|
|
3732
|
+
* (and creates) the database at once, since the project may already have
|
|
3733
|
+
* traces from another machine; a database already open starts syncing as
|
|
3734
|
+
* it is.
|
|
3735
|
+
*
|
|
3736
|
+
* @internal Not public API yet.
|
|
3737
|
+
*/
|
|
3738
|
+
_ecSetSync(workspace: WorkspaceSync): void;
|
|
3739
|
+
/** What syncing the file needs, once there's a sync. */
|
|
3740
|
+
private syncHooks;
|
|
3741
|
+
/** Starts syncing the open file. */
|
|
3742
|
+
private startSyncing;
|
|
4229
3743
|
/** The live provider if one exists, awaiting an already-in-flight open — but never starting one. */
|
|
4230
3744
|
private currentReal;
|
|
4231
3745
|
/**
|
|
@@ -4237,13 +3751,17 @@ declare class LocalDatabaseTraceProvider extends BaseTraceProvider {
|
|
|
4237
3751
|
*/
|
|
4238
3752
|
private ensureReal;
|
|
4239
3753
|
private open;
|
|
3754
|
+
/** Opens the database again, after sync swapped its file (and closed the old one). */
|
|
3755
|
+
private reopen;
|
|
3756
|
+
/** `result`, after telling the sync the database was written to. */
|
|
3757
|
+
private wrote;
|
|
4240
3758
|
private bridgeTrace;
|
|
4241
|
-
getAllTraces(): Promise<TraceSummary[]>;
|
|
3759
|
+
getAllTraces(query?: TraceQuery): Promise<TraceSummary$1[]>;
|
|
4242
3760
|
hasTrace(traceId: string): Promise<boolean>;
|
|
4243
|
-
protected getTraceWithoutSpans(): Promise<Trace | undefined>;
|
|
4244
|
-
protected getTraceSpans(): Promise<Span[]>;
|
|
3761
|
+
protected getTraceWithoutSpans(): Promise<Trace$1 | undefined>;
|
|
3762
|
+
protected getTraceSpans(): Promise<Span$1[]>;
|
|
4245
3763
|
protected addOrUpdateTrace(): Promise<void>;
|
|
4246
|
-
protected addOrUpdateSpan(): Promise<Span>;
|
|
3764
|
+
protected addOrUpdateSpan(): Promise<Span$1>;
|
|
4247
3765
|
protected removeTrace(): Promise<void>;
|
|
4248
3766
|
/**
|
|
4249
3767
|
* Deletes a trace, its spans and its annotations. Returns `false` if the database
|
|
@@ -4257,27 +3775,33 @@ declare class LocalDatabaseTraceProvider extends BaseTraceProvider {
|
|
|
4257
3775
|
* would create the file, so this says so instead.
|
|
4258
3776
|
*/
|
|
4259
3777
|
query(sql: string, options?: SqlQueryOptions): Promise<SqlQueryResult>;
|
|
3778
|
+
private queryNow;
|
|
4260
3779
|
/** The tables {@link query} runs against. */
|
|
4261
3780
|
getQuerySchema(): string;
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
3781
|
+
/**
|
|
3782
|
+
* The trace with its spans. When syncing, a trace that isn't here is
|
|
3783
|
+
* pulled for once before it's reported missing: it may be a shared link to
|
|
3784
|
+
* one recorded on another machine.
|
|
3785
|
+
*/
|
|
3786
|
+
getTrace(traceId: string): Promise<TraceWithSpans$1 | undefined>;
|
|
3787
|
+
subscribeTrace(traceId: string, callback: (event: TraceStreamEvent$1) => void): () => void;
|
|
3788
|
+
recordSpanStart(span: Span$1): Promise<Span$1>;
|
|
3789
|
+
recordSpanEnd(span: Span$1): Promise<Span$1>;
|
|
4266
3790
|
failTrace(traceId: string, errorMessage: string): Promise<void>;
|
|
4267
3791
|
/** Lists every annotation on a trace, oldest first. Empty if nothing has been saved yet. */
|
|
4268
|
-
listAnnotations(traceId: string): Promise<Annotation[]>;
|
|
3792
|
+
listAnnotations(traceId: string): Promise<Annotation$1[]>;
|
|
4269
3793
|
/**
|
|
4270
3794
|
* Creates a new annotation, minting its `id`/`createdAt`. Unlike span
|
|
4271
3795
|
* recording, this throws when the database can't be opened — someone asked
|
|
4272
3796
|
* for this note to be saved, so dropping it silently would be worse than
|
|
4273
3797
|
* the error.
|
|
4274
3798
|
*/
|
|
4275
|
-
createAnnotation(input: Omit<Annotation, "id" | "createdAt">): Promise<Annotation>;
|
|
3799
|
+
createAnnotation(input: Omit<Annotation$1, "id" | "createdAt">): Promise<Annotation$1>;
|
|
4276
3800
|
/**
|
|
4277
3801
|
* Changes an annotation's `kind` and/or `note`. `undefined` if it doesn't
|
|
4278
3802
|
* exist — including when the database was never created.
|
|
4279
3803
|
*/
|
|
4280
|
-
updateAnnotation(id: string, changes: AnnotationChanges): Promise<Annotation | undefined>;
|
|
3804
|
+
updateAnnotation(id: string, changes: AnnotationChanges$1): Promise<Annotation$1 | undefined>;
|
|
4281
3805
|
/** Deletes an annotation by id. A no-op if the database was never created. */
|
|
4282
3806
|
deleteAnnotation(id: string): Promise<void>;
|
|
4283
3807
|
}
|
|
@@ -4299,7 +3823,7 @@ declare class MemoryTraceProvider extends BaseTraceProvider {
|
|
|
4299
3823
|
displayName?: string;
|
|
4300
3824
|
description?: string;
|
|
4301
3825
|
});
|
|
4302
|
-
getAllTraces(): Promise<TraceSummary[]>;
|
|
3826
|
+
getAllTraces(query?: TraceQuery$1): Promise<TraceSummary[]>;
|
|
4303
3827
|
hasTrace(traceId: string): Promise<boolean>;
|
|
4304
3828
|
protected getTraceWithoutSpans(traceId: string): Promise<Trace | undefined>;
|
|
4305
3829
|
protected getTraceSpans(traceId: string): Promise<Span[]>;
|
|
@@ -4318,9 +3842,9 @@ declare class MemoryTraceProvider extends BaseTraceProvider {
|
|
|
4318
3842
|
* `OTelTraceIngestor` should be active per server — {@link isRedundant}
|
|
4319
3843
|
* reports any other instance redundant so server wiring can consolidate.
|
|
4320
3844
|
*/
|
|
4321
|
-
declare class OTelTraceIngestor extends BaseTraceIngestor {
|
|
3845
|
+
declare class OTelTraceIngestor extends BaseTraceIngestor$1 {
|
|
4322
3846
|
private spanPromises;
|
|
4323
|
-
isRedundant(other: TraceIngestor): boolean;
|
|
3847
|
+
isRedundant(other: TraceIngestor$1): boolean;
|
|
4324
3848
|
/**
|
|
4325
3849
|
* Returns a `SpanProcessor` that funnels every OpenTelemetry span the
|
|
4326
3850
|
* caller's tracer produces into this ingestor's sinks.
|
|
@@ -4347,112 +3871,6 @@ declare class OTelTraceIngestor extends BaseTraceIngestor {
|
|
|
4347
3871
|
*/
|
|
4348
3872
|
declare function setupGlobalOTelPipeline(): Promise<OTelTraceIngestor>;
|
|
4349
3873
|
//#endregion
|
|
4350
|
-
//#region src/trace/otlp/normalize.d.ts
|
|
4351
|
-
/** A single event attached to a span (e.g. an exception record). */
|
|
4352
|
-
interface NormalizedOtlpEvent {
|
|
4353
|
-
name: string;
|
|
4354
|
-
timeMs: number;
|
|
4355
|
-
attributes: Record<string, unknown>;
|
|
4356
|
-
}
|
|
4357
|
-
/**
|
|
4358
|
-
* One span from an OTLP export batch, decoded and normalized enough that both
|
|
4359
|
-
* the protobuf and JSON encodings produce identical output: hex trace/span
|
|
4360
|
-
* ids, millisecond timestamps, a readable `statusCode`, and a plain
|
|
4361
|
-
* `attributes` bag (nested `kvlist`/`array` values converted to plain
|
|
4362
|
-
* objects/arrays).
|
|
4363
|
-
*/
|
|
4364
|
-
interface NormalizedOtlpSpan {
|
|
4365
|
-
traceId: string;
|
|
4366
|
-
spanId: string;
|
|
4367
|
-
/** `undefined` for a root span. */
|
|
4368
|
-
parentSpanId?: string;
|
|
4369
|
-
name: string;
|
|
4370
|
-
startTimeMs: number;
|
|
4371
|
-
/** `undefined` for a span OTLP exported without an end time. */
|
|
4372
|
-
endTimeMs?: number;
|
|
4373
|
-
statusCode: "unset" | "ok" | "error";
|
|
4374
|
-
statusMessage?: string;
|
|
4375
|
-
attributes: Record<string, unknown>;
|
|
4376
|
-
events?: NormalizedOtlpEvent[];
|
|
4377
|
-
/** The attributes of the resource the span was exported under, if any. */
|
|
4378
|
-
resource?: Record<string, unknown>;
|
|
4379
|
-
}
|
|
4380
|
-
type Raw = any;
|
|
4381
|
-
/**
|
|
4382
|
-
* Flattens an OTLP `ExportTraceServiceRequest` (as decoded by
|
|
4383
|
-
* `decodeOtlpProtobuf`, or `JSON.parse`d directly) into a flat list of
|
|
4384
|
-
* {@link NormalizedOtlpSpan}s, in document order.
|
|
4385
|
-
*/
|
|
4386
|
-
declare function normalizeOtlpRequest(body: Raw): NormalizedOtlpSpan[];
|
|
4387
|
-
//#endregion
|
|
4388
|
-
//#region src/trace/otlp/otlp-protobuf.d.ts
|
|
4389
|
-
/**
|
|
4390
|
-
* Decodes an OTLP/protobuf `ExportTraceServiceRequest` payload into the same
|
|
4391
|
-
* plain-object shape as the OTLP/JSON encoding (camelCase keys, hex trace/span
|
|
4392
|
-
* ids, stringified 64-bit values) — so `../otlp/normalize.ts` can walk either
|
|
4393
|
-
* with one function.
|
|
4394
|
-
*/
|
|
4395
|
-
declare function decodeOtlpProtobuf(buf: Uint8Array): {
|
|
4396
|
-
resourceSpans: any[];
|
|
4397
|
-
};
|
|
4398
|
-
//#endregion
|
|
4399
|
-
//#region src/trace/otlp-trace-ingestor.d.ts
|
|
4400
|
-
/**
|
|
4401
|
-
* {@link TraceIngestor} populated by spans received over OTLP (protobuf or
|
|
4402
|
-
* JSON) from an external app or collector — see `specs/trace-workshopping.md`
|
|
4403
|
-
* §A. Unlike {@link OTelTraceIngestor}, OTLP arrives as a batch of already
|
|
4404
|
-
* -finished (or explicitly in-flight) spans with no separate start/end
|
|
4405
|
-
* lifecycle of its own.
|
|
4406
|
-
*
|
|
4407
|
-
* `BaseTraceProvider.recordSpanEnd` only *finalizes* a trace that
|
|
4408
|
-
* `recordSpanStart` already created (root detection happens there), so
|
|
4409
|
-
* {@link ingest} always calls `recordSpanStart` first — for an
|
|
4410
|
-
* already-ended span this immediately followed by `recordSpanEnd` — mirroring
|
|
4411
|
-
* the start-then-end pair {@link OTelTraceIngestor} fires for every real OTel
|
|
4412
|
-
* span. A span OTLP exported with no end time gets only the start.
|
|
4413
|
-
*
|
|
4414
|
-
* Storage-agnostic like every ingestor: works against `MemoryTraceProvider`
|
|
4415
|
-
* in tests and any other `TraceSink` in production with no code change.
|
|
4416
|
-
*/
|
|
4417
|
-
declare class OtlpTraceIngestor extends BaseTraceIngestor {
|
|
4418
|
-
/** Ingests one OTLP export batch, already normalized by `./otlp/normalize.ts`. */
|
|
4419
|
-
ingest(spans: NormalizedOtlpSpan[]): Promise<void>;
|
|
4420
|
-
}
|
|
4421
|
-
//#endregion
|
|
4422
|
-
//#region src/trace/span-merge.d.ts
|
|
4423
|
-
/**
|
|
4424
|
-
* Merges a later snapshot of a span into an earlier one.
|
|
4425
|
-
*
|
|
4426
|
-
* OpenTelemetry reports each span twice — at `onStart` (creation-time
|
|
4427
|
-
* attributes only) and at `onEnd` (the full set) — and the two snapshots can
|
|
4428
|
-
* carry complementary data. This unions their `attributes` and `resource`,
|
|
4429
|
-
* and lets any *defined* field on `incoming` update `existing`, so nothing
|
|
4430
|
-
* recorded at start is lost when the span ends, and end-only fields (status,
|
|
4431
|
-
* timings, token usage, …) are filled in.
|
|
4432
|
-
*
|
|
4433
|
-
* An ended span is final: a snapshot of it after its end is a re-report of
|
|
4434
|
-
* what already happened (a durable workflow replaying a finished step from
|
|
4435
|
-
* its record, say), whose timings are the replay's, not the work's.
|
|
4436
|
-
*
|
|
4437
|
-
* The exception is a span that ended in error. A later report of it is the
|
|
4438
|
-
* work being retried, so it replaces the failed attempt outright: carrying
|
|
4439
|
-
* over the old `errorMessage`, status or attributes would describe a failure
|
|
4440
|
-
* the retry may not have had.
|
|
4441
|
-
*/
|
|
4442
|
-
declare function mergeSpans(existing: Span, incoming: Span): Span;
|
|
4443
|
-
//#endregion
|
|
4444
|
-
//#region src/trace/trace-event-ingestor.d.ts
|
|
4445
|
-
/**
|
|
4446
|
-
* {@link TraceIngestor} populated by the {@link TraceSinkEvent}s an app's
|
|
4447
|
-
* `HttpTraceSink` sends to this server. The events are already normalized
|
|
4448
|
-
* {@link TraceSink} calls, so this just replays them, in order, on its own
|
|
4449
|
-
* sinks.
|
|
4450
|
-
*/
|
|
4451
|
-
declare class TraceEventIngestor extends BaseTraceIngestor {
|
|
4452
|
-
/** Records one batch of events, in order. */
|
|
4453
|
-
ingest(events: TraceSinkEvent[]): Promise<void>;
|
|
4454
|
-
}
|
|
4455
|
-
//#endregion
|
|
4456
3874
|
//#region src/trace/turso-trace-provider.d.ts
|
|
4457
3875
|
/**
|
|
4458
3876
|
* `TraceProvider` backed by a Turso/libSQL database via
|
|
@@ -4499,7 +3917,7 @@ declare class TursoTraceProvider extends BaseTraceProvider {
|
|
|
4499
3917
|
* start or end in the same tick land here concurrently.
|
|
4500
3918
|
*/
|
|
4501
3919
|
private serializeWrite;
|
|
4502
|
-
getAllTraces(): Promise<TraceSummary[]>;
|
|
3920
|
+
getAllTraces(query?: TraceQuery): Promise<TraceSummary$1[]>;
|
|
4503
3921
|
/**
|
|
4504
3922
|
* Runs one read-only query against the `traces`, `spans`, and
|
|
4505
3923
|
* `annotations` tables.
|
|
@@ -4508,9 +3926,9 @@ declare class TursoTraceProvider extends BaseTraceProvider {
|
|
|
4508
3926
|
/** The tables {@link query} runs against — see `./db/query-schema.ts`. */
|
|
4509
3927
|
getQuerySchema(): string;
|
|
4510
3928
|
hasTrace(traceId: string): Promise<boolean>;
|
|
4511
|
-
protected getTraceWithoutSpans(traceId: string): Promise<Trace | undefined>;
|
|
4512
|
-
protected getTraceSpans(traceId: string): Promise<Span[]>;
|
|
4513
|
-
protected addOrUpdateTrace(trace: Trace): Promise<void>;
|
|
3929
|
+
protected getTraceWithoutSpans(traceId: string): Promise<Trace$1 | undefined>;
|
|
3930
|
+
protected getTraceSpans(traceId: string): Promise<Span$1[]>;
|
|
3931
|
+
protected addOrUpdateTrace(trace: Trace$1): Promise<void>;
|
|
4514
3932
|
/**
|
|
4515
3933
|
* Deletes just the `traces` row — its spans go via the
|
|
4516
3934
|
* `trg_spans_cascade_delete_trace` trigger, and its annotations via their
|
|
@@ -4525,18 +3943,18 @@ declare class TursoTraceProvider extends BaseTraceProvider {
|
|
|
4525
3943
|
* `serializeWrite` slot), so a concurrent write can't interleave
|
|
4526
3944
|
* between the read and the write.
|
|
4527
3945
|
*/
|
|
4528
|
-
protected addOrUpdateSpan(span: Span): Promise<Span>;
|
|
3946
|
+
protected addOrUpdateSpan(span: Span$1): Promise<Span$1>;
|
|
4529
3947
|
/** Lists every annotation on a trace, oldest first. */
|
|
4530
|
-
listAnnotations(traceId: string): Promise<Annotation[]>;
|
|
3948
|
+
listAnnotations(traceId: string): Promise<Annotation$1[]>;
|
|
4531
3949
|
/** Creates a new annotation, minting its `id`/`createdAt`. */
|
|
4532
|
-
createAnnotation(input: Omit<Annotation, "id" | "createdAt">): Promise<Annotation>;
|
|
3950
|
+
createAnnotation(input: Omit<Annotation$1, "id" | "createdAt">): Promise<Annotation$1>;
|
|
4533
3951
|
/**
|
|
4534
3952
|
* Changes an annotation's `kind` and/or `note`. Returns it as updated, or
|
|
4535
3953
|
* `undefined` if it doesn't exist.
|
|
4536
3954
|
*/
|
|
4537
|
-
updateAnnotation(id: string, changes: AnnotationChanges): Promise<Annotation | undefined>;
|
|
3955
|
+
updateAnnotation(id: string, changes: AnnotationChanges$1): Promise<Annotation$1 | undefined>;
|
|
4538
3956
|
/** Deletes an annotation by id. A no-op if it doesn't exist. */
|
|
4539
3957
|
deleteAnnotation(id: string): Promise<void>;
|
|
4540
3958
|
}
|
|
4541
3959
|
//#endregion
|
|
4542
|
-
export { type AddPromptContext, type AddPromptField, type Annotation, type AnnotationChanges, type AnnotationEvent, type AnnotationEventOp, type AnnotationKind, type AnnotationSource, BaseTraceIngestor, BaseTraceProvider, CHECK_ATTRIBUTE, type CalleeBinding, type ChangeEventType, type ChatPromptUpdates, type Check, type CheckDefinition, type CheckInfo, type CheckOutcome, type CheckRun, type ColumnPath, type ConflictChoices, type CreateDatasetInput, DEFAULT_EVAL_CONCURRENCY, DEFAULT_MAX_QUERY_ROWS, DEFAULT_PLAYGROUND_IGNORE_PATTERNS, DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, DEFAULT_QUERY_TIMEOUT_MS, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, type Dataset, type DatasetChangeEvent, type DatasetChangeType, type DatasetColumnSpec, type DatasetField, type DatasetFieldShape, type DatasetInstanceShape, DatasetNotFoundError, type DatasetPathChild, type DatasetProvider, type DatasetProviderInfo, type DatasetRow, type DatasetRowSource, type DatasetRowUpdate, type DatasetRowsOverview, type DatasetSummary, DatasetValidationError, type DeclaredInstance, type DynamicResourceDefinition, type EvalArm, type EvalArmSpec, type EvalChangeEvent, type EvalChangeType, type EvalCheck, type EvalCheckOutcome, type EvalCheckResult, type EvalCounts, type EvalDefinition, type EvalDefinitionPatch, type EvalInputs, EvalNotFoundError, type EvalProvider, type EvalProviderInfo, type EvalResults, type EvalRowResult, type EvalRowStatus, type EvalRun, type EvalRunProgress, EvalRunRefusedError, type EvalRunStatus, type EvalRunSummary, EvalRunner, type EvalRunnerOptions, type EvalSummary, type EvalTraceRun, type EvalutionConfig, type ExecuteConfigOptions, type ExecuteOptions, type ExecuteRequest, type ExecuteResponse, type ExecuteResult, type ExecutionHandle, type ExecutionInput, type ExtractedProps, type FactoriesProbe, type FieldValues, type FilePromptMetadata, FilePromptProvider, type FilePromptProviderOptions, type FileProvider, type FileWatchCallback, type FileWatchOptions, type ForeignColumnSpec,
|
|
3960
|
+
export { type AddPromptContext, type AddPromptField, type Annotation, type AnnotationChanges, type AnnotationEvent, type AnnotationEventOp, type AnnotationKind, type AnnotationSource, type AttachOptions, BaseTraceIngestor, BaseTraceProvider, CHECK_ATTRIBUTE, type CalleeBinding, type ChangeEventType, type ChatPromptUpdates, type Check, type CheckDefinition, type CheckInfo, type CheckOutcome, type CheckRun, type CloudConfig, type CloudTraceClient, CloudTraceProvider, type CloudTraceProviderOptions, type ColumnPath, type ConflictChoices, type CreateDatasetInput, DEFAULT_EVAL_CONCURRENCY, DEFAULT_MAX_QUERY_ROWS, DEFAULT_PLAYGROUND_IGNORE_PATTERNS, DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, DEFAULT_QUERY_TIMEOUT_MS, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, DatabaseSync, type DatabaseSyncOptions, type Dataset, type DatasetChangeEvent, type DatasetChangeType, type DatasetColumnSpec, type DatasetField, type DatasetFieldShape, type DatasetInstanceShape, DatasetNotFoundError, type DatasetPathChild, type DatasetProvider, type DatasetProviderInfo, type DatasetRow, type DatasetRowSource, type DatasetRowUpdate, type DatasetRowsOverview, type DatasetSummary, DatasetValidationError, type DeclaredInstance, type DynamicResourceDefinition, type EvalArm, type EvalArmSpec, type EvalChangeEvent, type EvalChangeType, type EvalCheck, type EvalCheckOutcome, type EvalCheckResult, type EvalCounts, type EvalDefinition, type EvalDefinitionPatch, type EvalInputs, EvalNotFoundError, type EvalProvider, type EvalProviderInfo, type EvalResults, type EvalRowResult, type EvalRowStatus, type EvalRun, type EvalRunProgress, EvalRunRefusedError, type EvalRunStatus, type EvalRunSummary, EvalRunner, type EvalRunnerOptions, type EvalSummary, type EvalTraceRun, Evalution, type EvalutionConfig, type EvalutionOptions, type ExecuteConfigOptions, type ExecuteOptions, type ExecuteRequest, type ExecuteResponse, type ExecuteResult, type ExecutionHandle, type ExecutionInput, type ExtractedProps, type FactoriesProbe, type FieldValues, type FilePromptMetadata, FilePromptProvider, type FilePromptProviderOptions, type FileProvider, type FileWatchCallback, type FileWatchOptions, type ForeignColumnSpec, GitVersioning, type GitVersioningOptions, type GlobOptions, type HeadState, HttpTraceSink, type HttpTraceSinkOptions, type HttpTraceTarget, type ImportOptions, type InputBindings, type InputLayout, type InputSignature, type InputSlot, type InputSource, type InstanceResolver, type KnownColumnSpec, type LLMSpanDetails, type ListRowsOptions, LocalDatabaseTraceProvider, type LocalDatabaseTraceProviderOptions, LocalDirectoryDatasetProvider, type LocalDirectoryDatasetProviderOptions, LocalEvalProvider, type LocalEvalProviderOptions, LocalFileProvider, type LocalTursoClientOptions, LocalVariationStore, MIGRATIONS_TABLE, MemoryFileProvider, MemoryTraceProvider, type MergeOutcome, type NewDatasetRow, type NewEvalDefinition, type NewEvalRun, type NewWip, type NormalizedChatPrompt, type NormalizedFilePrompt, type NormalizedMessage, type NormalizedOtlpEvent, type NormalizedOtlpSpan, type NormalizedParameter, type NormalizedPrompt, type NormalizedPromptBase, type NormalizedPromptUpdates, type NormalizedQuestionsPrompt, type NormalizedToolCall, OTelTraceIngestor, type OpenOnHeadOptions, 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, type ParsePromptsOptions, type ParsedFilePrompt, type ParsedPrompt, type PendingConflicts, type PlaygroundModuleError, type PreparedCheck, type ProbeResult, type ProbeResults, type ProjectProbeRequest, type PromptChangeEvent, type PromptFileType, type PromptID, type PromptInputSources, type PromptProvider, type PromptProviderInfo, type PromptRef, type PromptRefLike, type PromptSpanInfo, type PromptStyle, type PromptVariations, type PromptVersions, type PromptsFactory, type PromptsHelper, type PromptsHelperOptions, type PropDefinition, type PropType, type PropValue, type QuestionsPromptUpdates, type ReadOnlyQueryRunner, type RebaseResult, type RegisteredCheck, type RegisteredResource, type RegisteredSource, type ResolutionContext, type ResolvedPromptInputs, type ResolvedResourceInputs, type Resource, type ResourceBinding, type ResourceDefinition, type ResourceInfo, type ResourceInput, type ResourceInputs, type ResourceInstance, type ResourceInstanceInput, type ResourceLease, type ResourceOutputDefinition, ResourceRegistry, type ResourceScope, type RunResources, type SDKAdapter, SERVICE_NAME_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, type SlotMatchRequest, type SlotMatchSource, type SourceSpan, type Span, type SpanContentPart, type SpanImagePart, type SpanKind, type SpanMessage, type SpanMessageRole, type SpanReasoningPart, type SpanTextPart, type SpanToolCallPart, type SpanToolResultPart, SqlQueryError, type SqlQueryOptions, type SqlQueryResult, type StartEvalRunOptions, type StaticResourceDefinition, type StoredVariation, type SyncCloud, type SyncedDatabase, TRACE_EVENTS_PATH, TRACE_QUERY_SCHEMA, TSPromptFileType, type ToolSpanDetails, type Trace, type TraceChangeEvent, type TraceChangeType, type TraceCheckResult, type TraceEvalRun, TraceEventIngestor, type TraceEventsRequest, type TraceIngestor, type TraceLiveEvent, type TraceProvider, type TraceProviderInfo, type TraceSink, type TraceSinkEvent, type TraceStreamEvent, type TraceSummary, type TraceWithSpans, type TursoCreateDatasetOptions, TursoDatasetProvider, TursoEvalProvider, TursoTraceProvider, TursoVariationStore, type TypeExpressionProbe, type TypeProbe, type TypeProbeRequest, type TypeResolutionRequest, type TypeResolutionResult, type UpdatePromptResponse, type UpdatePromptResult, type ValueCatalog, type ValueCatalogGroup, type ValueCatalogPreset, type ValueFactory, type VariationConflict, VariationConflictError, type VariationContent, type VariationId, type VariationInfo, type VariationStore, type VersionHistoryOptions, type VersionId, type VersionInfo, type VersioningAdapter, type WipChanges, type WorkspaceCloud, WorkspaceSync, type WorkspaceSyncOptions, 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 };
|