evalution 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +11 -11
  2. package/dist/{check-ci7RhMcB.d.ts → check-BKU5_IhU.d.ts} +7 -2
  3. package/dist/checks/index.d.ts +1 -1
  4. package/dist/cli/index.js +622 -336
  5. package/dist/client/assets/{DatasetView-BqSWI_pm.js → DatasetView-DZ2uLHKV.js} +12 -10
  6. package/dist/client/assets/{EvalRunView-CR6ZksSu.js → EvalRunView-T610dLVw.js} +1 -1
  7. package/dist/client/assets/{EvalView-JPEM5IY8.js → EvalView-Cae68vPB.js} +1 -1
  8. package/dist/client/assets/{data-grid-overlay-editor-B_nPhXKR.js → data-grid-overlay-editor-PtH7A6E4.js} +1 -1
  9. package/dist/client/assets/{highlighted-body-KPVGNVTW-dPpneB8R.js → highlighted-body-KPVGNVTW-CPtwvSJb.js} +1 -1
  10. package/dist/client/assets/{index-CwjMcK6S.js → index-BFH07Ynk.js} +147 -147
  11. package/dist/client/assets/index-KCv8AeiY.css +32 -0
  12. package/dist/client/assets/{number-overlay-editor-CRWFlaQs.js → number-overlay-editor-BbQhagHP.js} +1 -1
  13. package/dist/client/index.html +2 -2
  14. package/dist/cost-fetching-trace-sink-Dz8gniQ6.js +262 -0
  15. package/dist/{dataset-types-8cDpOFYi.d.ts → dataset-types-D-Fsbg8B.d.ts} +5 -0
  16. package/dist/index.d.ts +517 -121
  17. package/dist/index.js +29 -10
  18. package/dist/ingest.d.ts +119 -0
  19. package/dist/ingest.js +3 -0
  20. package/dist/{trace-event-ingestor-DwI1hxGX.js → local-database-trace-provider-87-WGqfS.js} +1795 -1086
  21. package/dist/{trace-BlnjMp7o.d.ts → trace-BLjFYF9G.d.ts} +1 -1
  22. package/dist/trace-event-ingestor-B1DYEg2H.js +798 -0
  23. package/dist/trace-event-ingestor-JNpe-OrX.d.ts +109 -0
  24. package/dist/views/datasets/index.d.ts +1 -1
  25. package/dist/views/index.d.ts +2 -2
  26. package/dist/views/react/index.d.ts +1 -1
  27. package/package.json +38 -41
  28. package/dist/client/assets/index-BGcZZetP.css +0 -32
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { $ as FieldValues, $t as VariationConflict, A as DatasetRowsOverview, At as SpanImagePart, B as AnnotationEvent, Bt as TraceChangeEvent, C as DatasetFieldShape, Cn as EvalSummary, Ct as ResourceInfo, D as DatasetRow, Dn as TraceCheckResult, Dt as SourceSpan, E as DatasetProviderInfo, En as NewEvalRun, Et as RunResources, F as KnownColumnSpec, Ft as SpanTextPart, G as ChangeEventType, Gt as TraceStreamEvent, H as AnnotationKind, Ht as TraceEvalRun, I as AddPromptContext, It as SpanToolCallPart, J as ConflictChoices, Jt as UpdatePromptResponse, K as ChatPromptUpdates, Kt as TraceSummary, L as AddPromptField, Lt as SpanToolResultPart, M as ColumnPath, Mt as SpanMessage, N as DatasetColumnSpec, Nt as SpanMessageRole, O as DatasetRowSource, Ot as Span, P as ForeignColumnSpec, Pt as SpanReasoningPart, Q as ExtractedProps, Qt as ValueFactory, R as Annotation, Rt as ToolSpanDetails, S as DatasetField, Sn as EvalRunSummary, St as RebaseResult, T as DatasetPathChild, Tn as NewEvalDefinition, Tt as ResourceScope, U as AnnotationSource, Ut as TraceLiveEvent, V as AnnotationEventOp, Vt as TraceChangeType, W as CalleeBinding, Wt as TraceProviderInfo, X as ExecuteResponse, Xt as ValueCatalogGroup, Y as ExecuteRequest, Yt as ValueCatalog, Z as ExecutionInput, Zt as ValueCatalogPreset, _ as isStandardSchema, _n as EvalRowResult, _t as PromptStyle, a as check, an as EvalArmSpec, at as NormalizedPrompt, b as DatasetChangeEvent, bn as EvalRunProgress, bt as PropValue, c as ResolvedResourceInputs, cn as EvalCheck, ct as NormalizedQuestionsPrompt, d as ResourceInput, dn as EvalCounts, dt as PendingConflicts, en as VariationId, et as InputLayout, f as ResourceInputs, fn as EvalDefinition, ft as PromptChangeEvent, g as isResource, gn as EvalResults, gt as PromptRef, h as StaticResourceDefinition, hn as EvalProviderInfo, ht as PromptProviderInfo, i as CheckRun, in as EvalArm, it as NormalizedParameter, j as DatasetSummary, jt as SpanKind, k as DatasetRowUpdate, kt as SpanContentPart, l as Resource, ln as EvalCheckOutcome, lt as NormalizedToolCall, m as ResourceOutputDefinition, mn as EvalInputs, mt as PromptInputSources, n as CheckDefinition, nn as VersionId, nt as NormalizedChatPrompt, o as isCheck, on as EvalChangeEvent, ot as NormalizedPromptBase, p as ResourceInstance, pn as EvalDefinitionPatch, pt as PromptID, q as CheckInfo, qt as TraceWithSpans, r as CheckOutcome, rn as VersionInfo, rt as NormalizedMessage, s as DynamicResourceDefinition, sn as EvalChangeType, st as NormalizedPromptUpdates, t as Check, tn as VariationInfo, tt as LLMSpanDetails, u as ResourceDefinition, un as EvalCheckResult, ut as ParsedPrompt, v as resource, vn as EvalRowStatus, vt as PropDefinition, w as DatasetInstanceShape, wn as EvalTraceRun, wt as ResourceInstanceInput, x as DatasetChangeType, xn as EvalRunStatus, xt as QuestionsPromptUpdates, y as Dataset, yn as EvalRun, yt as PropType, z as AnnotationChanges, zt as Trace } from "./check-ci7RhMcB.js";
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";
2
3
  import { Tracer } from "@opentelemetry/api";
3
4
  import { PropDefinition as PropDefinition$1, PropValue as PropValue$1 } from "ts-proppy";
4
- 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, 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, TRACE_EVENTS_PATH, Trace as Trace$1, TraceChangeEvent as TraceChangeEvent$1, TraceEventsRequest, TraceIngestor, TraceIngestor as TraceIngestor$1, TraceSink, TraceSink as TraceSink$1, TraceSinkEvent, TraceSinkEvent as TraceSinkEvent$1, TraceStreamEvent as TraceStreamEvent$1, TraceSummary as TraceSummary$1, TraceWithSpans as TraceWithSpans$1, createTracerForPrompt, getPromptSpanAttributes, isCheckSpan, mergePromptIdentity, spanMessages } from "@evalution/sdk";
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";
5
6
  import { Database } from "@tursodatabase/sync";
6
7
  import { migrateAsync } from "drizzle-orm/sqlite-core/async/session";
7
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";
@@ -1344,8 +1345,25 @@ interface TraceProvider {
1344
1345
  /**
1345
1346
  * Returns compact summaries for every trace known to this provider, newest
1346
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.
1347
1365
  */
1348
- getAllTraces(): Promise<TraceSummary[]>;
1366
+ groupTraces?(query: TraceGroupQuery$1): Promise<TraceGroup$1[]>;
1349
1367
  /**
1350
1368
  * Returns the trace with the given ID together with all of its spans, or
1351
1369
  * `undefined` when the trace is unknown.
@@ -1455,6 +1473,15 @@ interface TraceProvider {
1455
1473
  * ```
1456
1474
  */
1457
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;
1458
1485
  /**
1459
1486
  * Whether to load a `.env` file from the directory Evalution is launched
1460
1487
  * from before starting the server.
@@ -1500,6 +1527,14 @@ interface EvalutionConfig {
1500
1527
  */
1501
1528
  evalProviders?: EvalProvider[];
1502
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
+ }
1503
1538
  //#endregion
1504
1539
  //#region src/trace/db/migrate.d.ts
1505
1540
  /** The ledger table `runMigrations` records applied migrations in. */
@@ -1521,6 +1556,259 @@ declare function runMigrations(db: Parameters<typeof migrateAsync>[1], migration
1521
1556
  */
1522
1557
  declare function runDatasetMigrations(db: Parameters<typeof runMigrations>[0]): Promise<void>;
1523
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
1524
1812
  //#region src/dataset/local-directory-dataset-provider.d.ts
1525
1813
  /** Options for {@link LocalDirectoryDatasetProvider}. */
1526
1814
  interface LocalDirectoryDatasetProviderOptions {
@@ -1532,6 +1820,10 @@ interface LocalDirectoryDatasetProviderOptions {
1532
1820
  * @default "./.evalution/datasets"
1533
1821
  */
1534
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
+ */
1535
1827
  id?: string;
1536
1828
  displayName?: string;
1537
1829
  description?: string;
@@ -1565,7 +1857,44 @@ declare class LocalDirectoryDatasetProvider implements DatasetProvider {
1565
1857
  private readonly reported;
1566
1858
  /** Tail of the create chain: id choice and file creation are one step. */
1567
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;
1568
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;
1569
1898
  private pathFor;
1570
1899
  private emit;
1571
1900
  watch(callback: (event: DatasetChangeEvent) => void): () => void;
@@ -1577,14 +1906,20 @@ declare class LocalDirectoryDatasetProvider implements DatasetProvider {
1577
1906
  * one).
1578
1907
  */
1579
1908
  private entryFor;
1580
- /** Opens (and migrates) `datasetId`'s file, caching the result. */
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
+ */
1581
1913
  private openEntry;
1582
1914
  private openUncached;
1915
+ /** Opens `datasetId`'s file again, after sync swapped it (and closed the old one). */
1916
+ private reopenEntry;
1583
1917
  /** The open entry for `datasetId`, or a {@link DatasetNotFoundError}. */
1584
1918
  private requireEntry;
1585
- /** `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. */
1586
1920
  private withFileId;
1587
1921
  listDatasets(): Promise<DatasetSummary[]>;
1922
+ private summarize;
1588
1923
  getDataset(datasetId: string): Promise<Dataset | undefined>;
1589
1924
  listRows(datasetId: string, options?: ListRowsOptions): Promise<DatasetRow[]>;
1590
1925
  describeRows(datasetId: string): Promise<DatasetRowsOverview>;
@@ -1596,9 +1931,16 @@ declare class LocalDirectoryDatasetProvider implements DatasetProvider {
1596
1931
  */
1597
1932
  createDataset(input: CreateDatasetInput): Promise<Dataset>;
1598
1933
  private createNow;
1934
+ /** Runs `op` on `datasetId`'s open entry, or throws if there's none. */
1935
+ private withEntry;
1599
1936
  renameDataset(datasetId: string, name: string): Promise<Dataset>;
1600
- /** Closes the file's client, then removes it and its sidecars. */
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
+ */
1601
1941
  deleteDataset(datasetId: string): Promise<void>;
1942
+ /** Closes the file's client, then removes it and its sidecars. */
1943
+ private removeLocal;
1602
1944
  addRows(datasetId: string, rows: NewDatasetRow[]): Promise<DatasetRow[]>;
1603
1945
  updateRows(datasetId: string, updates: DatasetRowUpdate[]): Promise<void>;
1604
1946
  deleteRows(datasetId: string, rowIds: readonly string[]): Promise<number>;
@@ -1907,6 +2249,10 @@ interface LocalEvalProviderOptions {
1907
2249
  * @default "./.evalution/evals/evals.db"
1908
2250
  */
1909
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
+ */
1910
2256
  id?: string;
1911
2257
  displayName?: string;
1912
2258
  }
@@ -1922,9 +2268,36 @@ declare class LocalEvalProvider implements EvalProvider {
1922
2268
  readonly path: string;
1923
2269
  private opened?;
1924
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;
1925
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;
1926
2291
  /** The store, creating it if needed. Set synchronously, so concurrent first writes share one open. */
1927
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;
1928
2301
  /** The store if it exists yet, without creating it. */
1929
2302
  private existing;
1930
2303
  watch(callback: (event: EvalChangeEvent) => void): () => void;
@@ -1932,7 +2305,7 @@ declare class LocalEvalProvider implements EvalProvider {
1932
2305
  getEval(id: string): Promise<EvalDefinition | undefined>;
1933
2306
  createEval(input: NewEvalDefinition): Promise<EvalDefinition>;
1934
2307
  updateEval(id: string, patch: EvalDefinitionPatch): Promise<EvalDefinition>;
1935
- deleteEval(id: string): Promise<void>;
2308
+ deleteEval(id: string): Promise<void | undefined>;
1936
2309
  createRun(evalId: string, run: NewEvalRun): Promise<EvalRun>;
1937
2310
  finishRun(runId: string, status: EvalRunStatus, options?: {
1938
2311
  drifted?: boolean;
@@ -1940,7 +2313,7 @@ declare class LocalEvalProvider implements EvalProvider {
1940
2313
  interruptRuns(): Promise<number>;
1941
2314
  listRuns(evalId: string): Promise<EvalRunSummary[]>;
1942
2315
  getRun(runId: string): Promise<EvalRun | undefined>;
1943
- deleteRun(runId: string): Promise<void>;
2316
+ deleteRun(runId: string): Promise<void | undefined>;
1944
2317
  recordRowResult(result: EvalRowResult): Promise<void>;
1945
2318
  recordCheckResults(results: EvalCheckResult[]): Promise<void>;
1946
2319
  listResults(runId: string): Promise<EvalResults>;
@@ -2723,7 +3096,7 @@ declare class FilePromptProvider implements PromptProvider<NormalizedFilePrompt>
2723
3096
  */
2724
3097
  private applyUpdates;
2725
3098
  getModelDefinition(style: PromptStyle): Promise<PropDefinition>;
2726
- getModelParameters(): PropDefinition[];
3099
+ getModelParameters(): import("ts-proppy").PropDefinition[];
2727
3100
  resolveInputs(_ref: PromptRefLike, inputs: {
2728
3101
  functionInputs?: readonly ExecutionInput[];
2729
3102
  executeInputs?: Record<string, ExecutionInput>;
@@ -3113,7 +3486,9 @@ declare abstract class BaseTraceProvider implements TraceProvider, TraceSink$1 {
3113
3486
  displayName: string;
3114
3487
  description: string;
3115
3488
  });
3116
- abstract getAllTraces(): Promise<TraceSummary$1[]>;
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[]>;
3117
3492
  abstract hasTrace(traceId: string): Promise<boolean>;
3118
3493
  protected abstract getTraceWithoutSpans(traceId: string): Promise<Trace$1 | undefined>;
3119
3494
  protected abstract getTraceSpans(traceId: string): Promise<Span$1[]>;
@@ -3155,6 +3530,92 @@ declare abstract class BaseTraceProvider implements TraceProvider, TraceSink$1 {
3155
3530
  protected emitChange(event: TraceChangeEvent$1): void;
3156
3531
  }
3157
3532
  //#endregion
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[]>;
3594
+ /**
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.
3598
+ */
3599
+ groupTraces(query: TraceGroupQuery): Promise<TraceGroup[]>;
3600
+ getTrace(traceId: string): Promise<TraceWithSpans$1 | undefined>;
3601
+ /**
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`.
3604
+ */
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;
3609
+ /**
3610
+ * Lists the traces `query` matches. A listing of them all also notes what
3611
+ * changed since the last one.
3612
+ */
3613
+ private list;
3614
+ private noteChanges;
3615
+ private schedule;
3616
+ private emit;
3617
+ }
3618
+ //#endregion
3158
3619
  //#region src/trace/db/local-turso-client.d.ts
3159
3620
  interface LocalTursoClientOptions {
3160
3621
  /** Path to the local SQLite file (e.g. `<rootDir>/.evalution/trace.db`). */
@@ -3178,6 +3639,12 @@ interface LocalTursoClientOptions {
3178
3639
  getAuthToken?: () => Promise<string>;
3179
3640
  /** Identifies this client to the sync engine (shown in Turso's dashboard). */
3180
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;
3181
3648
  }
3182
3649
  /**
3183
3650
  * Connects to a local SQLite database that starts purely local and, once
@@ -3197,7 +3664,8 @@ declare function createLocalTursoClient({
3197
3664
  path,
3198
3665
  getCloudUrl,
3199
3666
  getAuthToken,
3200
- clientName
3667
+ clientName,
3668
+ onBootstrapFailure
3201
3669
  }: LocalTursoClientOptions): Promise<Database>;
3202
3670
  //#endregion
3203
3671
  //#region src/trace/db/query-schema.d.ts
@@ -3218,6 +3686,10 @@ interface LocalDatabaseTraceProviderOptions {
3218
3686
  * @default "./.evalution/traces/local.db"
3219
3687
  */
3220
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
+ */
3221
3693
  id?: string;
3222
3694
  displayName?: string;
3223
3695
  description?: string;
@@ -3239,6 +3711,12 @@ declare class LocalDatabaseTraceProvider extends BaseTraceProvider {
3239
3711
  * migrations — and re-logging the same stack — once per span.
3240
3712
  */
3241
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;
3242
3720
  constructor(options?: LocalDatabaseTraceProviderOptions);
3243
3721
  /**
3244
3722
  * Reports — once — that the database could not be opened, and leaves this
@@ -3248,6 +3726,20 @@ declare class LocalDatabaseTraceProvider extends BaseTraceProvider {
3248
3726
  * Explicit user actions still fail loudly (see {@link createAnnotation}).
3249
3727
  */
3250
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;
3251
3743
  /** The live provider if one exists, awaiting an already-in-flight open — but never starting one. */
3252
3744
  private currentReal;
3253
3745
  /**
@@ -3259,8 +3751,12 @@ declare class LocalDatabaseTraceProvider extends BaseTraceProvider {
3259
3751
  */
3260
3752
  private ensureReal;
3261
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;
3262
3758
  private bridgeTrace;
3263
- getAllTraces(): Promise<TraceSummary$1[]>;
3759
+ getAllTraces(query?: TraceQuery): Promise<TraceSummary$1[]>;
3264
3760
  hasTrace(traceId: string): Promise<boolean>;
3265
3761
  protected getTraceWithoutSpans(): Promise<Trace$1 | undefined>;
3266
3762
  protected getTraceSpans(): Promise<Span$1[]>;
@@ -3279,8 +3775,14 @@ declare class LocalDatabaseTraceProvider extends BaseTraceProvider {
3279
3775
  * would create the file, so this says so instead.
3280
3776
  */
3281
3777
  query(sql: string, options?: SqlQueryOptions): Promise<SqlQueryResult>;
3778
+ private queryNow;
3282
3779
  /** The tables {@link query} runs against. */
3283
3780
  getQuerySchema(): string;
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
+ */
3284
3786
  getTrace(traceId: string): Promise<TraceWithSpans$1 | undefined>;
3285
3787
  subscribeTrace(traceId: string, callback: (event: TraceStreamEvent$1) => void): () => void;
3286
3788
  recordSpanStart(span: Span$1): Promise<Span$1>;
@@ -3321,7 +3823,7 @@ declare class MemoryTraceProvider extends BaseTraceProvider {
3321
3823
  displayName?: string;
3322
3824
  description?: string;
3323
3825
  });
3324
- getAllTraces(): Promise<TraceSummary[]>;
3826
+ getAllTraces(query?: TraceQuery$1): Promise<TraceSummary[]>;
3325
3827
  hasTrace(traceId: string): Promise<boolean>;
3326
3828
  protected getTraceWithoutSpans(traceId: string): Promise<Trace | undefined>;
3327
3829
  protected getTraceSpans(traceId: string): Promise<Span[]>;
@@ -3369,112 +3871,6 @@ declare class OTelTraceIngestor extends BaseTraceIngestor$1 {
3369
3871
  */
3370
3872
  declare function setupGlobalOTelPipeline(): Promise<OTelTraceIngestor>;
3371
3873
  //#endregion
3372
- //#region src/trace/otlp/normalize.d.ts
3373
- /** A single event attached to a span (e.g. an exception record). */
3374
- interface NormalizedOtlpEvent {
3375
- name: string;
3376
- timeMs: number;
3377
- attributes: Record<string, unknown>;
3378
- }
3379
- /**
3380
- * One span from an OTLP export batch, decoded and normalized enough that both
3381
- * the protobuf and JSON encodings produce identical output: hex trace/span
3382
- * ids, millisecond timestamps, a readable `statusCode`, and a plain
3383
- * `attributes` bag (nested `kvlist`/`array` values converted to plain
3384
- * objects/arrays).
3385
- */
3386
- interface NormalizedOtlpSpan {
3387
- traceId: string;
3388
- spanId: string;
3389
- /** `undefined` for a root span. */
3390
- parentSpanId?: string;
3391
- name: string;
3392
- startTimeMs: number;
3393
- /** `undefined` for a span OTLP exported without an end time. */
3394
- endTimeMs?: number;
3395
- statusCode: "unset" | "ok" | "error";
3396
- statusMessage?: string;
3397
- attributes: Record<string, unknown>;
3398
- events?: NormalizedOtlpEvent[];
3399
- /** The attributes of the resource the span was exported under, if any. */
3400
- resource?: Record<string, unknown>;
3401
- }
3402
- type Raw = any;
3403
- /**
3404
- * Flattens an OTLP `ExportTraceServiceRequest` (as decoded by
3405
- * `decodeOtlpProtobuf`, or `JSON.parse`d directly) into a flat list of
3406
- * {@link NormalizedOtlpSpan}s, in document order.
3407
- */
3408
- declare function normalizeOtlpRequest(body: Raw): NormalizedOtlpSpan[];
3409
- //#endregion
3410
- //#region src/trace/otlp/otlp-protobuf.d.ts
3411
- /**
3412
- * Decodes an OTLP/protobuf `ExportTraceServiceRequest` payload into the same
3413
- * plain-object shape as the OTLP/JSON encoding (camelCase keys, hex trace/span
3414
- * ids, stringified 64-bit values) — so `../otlp/normalize.ts` can walk either
3415
- * with one function.
3416
- */
3417
- declare function decodeOtlpProtobuf(buf: Uint8Array): {
3418
- resourceSpans: any[];
3419
- };
3420
- //#endregion
3421
- //#region src/trace/otlp-trace-ingestor.d.ts
3422
- /**
3423
- * {@link TraceIngestor} populated by spans received over OTLP (protobuf or
3424
- * JSON) from an external app or collector — see `specs/trace-workshopping.md`
3425
- * §A. Unlike {@link OTelTraceIngestor}, OTLP arrives as a batch of already
3426
- * -finished (or explicitly in-flight) spans with no separate start/end
3427
- * lifecycle of its own.
3428
- *
3429
- * `BaseTraceProvider.recordSpanEnd` only *finalizes* a trace that
3430
- * `recordSpanStart` already created (root detection happens there), so
3431
- * {@link ingest} always calls `recordSpanStart` first — for an
3432
- * already-ended span this immediately followed by `recordSpanEnd` — mirroring
3433
- * the start-then-end pair {@link OTelTraceIngestor} fires for every real OTel
3434
- * span. A span OTLP exported with no end time gets only the start.
3435
- *
3436
- * Storage-agnostic like every ingestor: works against `MemoryTraceProvider`
3437
- * in tests and any other `TraceSink` in production with no code change.
3438
- */
3439
- declare class OtlpTraceIngestor extends BaseTraceIngestor$1 {
3440
- /** Ingests one OTLP export batch, already normalized by `./otlp/normalize.ts`. */
3441
- ingest(spans: NormalizedOtlpSpan[]): Promise<void>;
3442
- }
3443
- //#endregion
3444
- //#region src/trace/span-merge.d.ts
3445
- /**
3446
- * Merges a later snapshot of a span into an earlier one.
3447
- *
3448
- * OpenTelemetry reports each span twice — at `onStart` (creation-time
3449
- * attributes only) and at `onEnd` (the full set) — and the two snapshots can
3450
- * carry complementary data. This unions their `attributes` and `resource`,
3451
- * and lets any *defined* field on `incoming` update `existing`, so nothing
3452
- * recorded at start is lost when the span ends, and end-only fields (status,
3453
- * timings, token usage, …) are filled in.
3454
- *
3455
- * An ended span is final: a snapshot of it after its end is a re-report of
3456
- * what already happened (a durable workflow replaying a finished step from
3457
- * its record, say), whose timings are the replay's, not the work's.
3458
- *
3459
- * The exception is a span that ended in error. A later report of it is the
3460
- * work being retried, so it replaces the failed attempt outright: carrying
3461
- * over the old `errorMessage`, status or attributes would describe a failure
3462
- * the retry may not have had.
3463
- */
3464
- declare function mergeSpans(existing: Span$1, incoming: Span$1): Span$1;
3465
- //#endregion
3466
- //#region src/trace/trace-event-ingestor.d.ts
3467
- /**
3468
- * {@link TraceIngestor} populated by the {@link TraceSinkEvent}s an app's
3469
- * `HttpTraceSink` sends to this server. The events are already normalized
3470
- * {@link TraceSink} calls, so this just replays them, in order, on its own
3471
- * sinks.
3472
- */
3473
- declare class TraceEventIngestor extends BaseTraceIngestor$1 {
3474
- /** Records one batch of events, in order. */
3475
- ingest(events: TraceSinkEvent$1[]): Promise<void>;
3476
- }
3477
- //#endregion
3478
3874
  //#region src/trace/turso-trace-provider.d.ts
3479
3875
  /**
3480
3876
  * `TraceProvider` backed by a Turso/libSQL database via
@@ -3521,7 +3917,7 @@ declare class TursoTraceProvider extends BaseTraceProvider {
3521
3917
  * start or end in the same tick land here concurrently.
3522
3918
  */
3523
3919
  private serializeWrite;
3524
- getAllTraces(): Promise<TraceSummary$1[]>;
3920
+ getAllTraces(query?: TraceQuery): Promise<TraceSummary$1[]>;
3525
3921
  /**
3526
3922
  * Runs one read-only query against the `traces`, `spans`, and
3527
3923
  * `annotations` tables.
@@ -3561,4 +3957,4 @@ declare class TursoTraceProvider extends BaseTraceProvider {
3561
3957
  deleteAnnotation(id: string): Promise<void>;
3562
3958
  }
3563
3959
  //#endregion
3564
- 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, 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, 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, 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 };
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 };