@bitfab/sdk 0.38.10 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -540,7 +540,11 @@ declare class HttpClient {
540
540
  lookupFunction<T>(name: string): Promise<T>;
541
541
  getAutoTracePolicy<T>(traceFunctionKey: string, protocol: string): Promise<T>;
542
542
  getTraceSpan(traceId: string, lookup: SpanLookup): Promise<CapturedSpan | null>;
543
- private get;
543
+ /**
544
+ * GET a JSON endpoint on the service with the client's API key. Throws a
545
+ * `BitfabError` carrying the status text for any non-2xx response.
546
+ */
547
+ get<T>(endpoint: string): Promise<T>;
544
548
  /**
545
549
  * Queue an internal trace (from local BAML execution via `call()`) onto this
546
550
  * client's batching transport. `functionId` moves into the payload because
@@ -1034,6 +1038,141 @@ declare class BitfabVercelAiHandler {
1034
1038
  get middleware(): BitfabLanguageModelMiddleware;
1035
1039
  }
1036
1040
 
1041
+ interface DatasetGraderRef {
1042
+ id: string;
1043
+ name: string | null;
1044
+ }
1045
+ interface Dataset {
1046
+ id: string;
1047
+ traceFunctionKey: string;
1048
+ name: string;
1049
+ description: string | null;
1050
+ traceCount: number;
1051
+ graders: DatasetGraderRef[];
1052
+ createdAt: string;
1053
+ updatedAt: string;
1054
+ }
1055
+ interface SaveDatasetParams {
1056
+ traceFunctionKey: string;
1057
+ name: string;
1058
+ description?: string;
1059
+ }
1060
+ interface SaveDatasetResult {
1061
+ dataset: Dataset;
1062
+ created: boolean;
1063
+ }
1064
+ interface ListDatasetsParams {
1065
+ traceFunctionKey?: string;
1066
+ }
1067
+ interface DatasetTraceIds {
1068
+ datasetId: string;
1069
+ traceIds: string[];
1070
+ }
1071
+ interface AddDatasetTracesResult {
1072
+ dataset: Dataset;
1073
+ addedTraceIds: string[];
1074
+ alreadyPresentTraceIds: string[];
1075
+ skippedTraceIds: string[];
1076
+ }
1077
+ interface RemoveDatasetTracesResult {
1078
+ dataset: Dataset;
1079
+ removedTraceIds: string[];
1080
+ notPresentTraceIds: string[];
1081
+ }
1082
+ interface AddDatasetGradersResult {
1083
+ dataset: Dataset;
1084
+ addedGraderIds: string[];
1085
+ alreadyAssignedGraderIds: string[];
1086
+ skippedGraderIds: string[];
1087
+ }
1088
+ interface RemoveDatasetGradersResult {
1089
+ dataset: Dataset;
1090
+ removedGraderIds: string[];
1091
+ notAssignedGraderIds: string[];
1092
+ }
1093
+ type GraderRerunStatus = "pending" | "running" | "completed" | "errored";
1094
+ interface GraderRerunProgress {
1095
+ completedTraces: number;
1096
+ totalTraces: number;
1097
+ graderCount: number;
1098
+ }
1099
+ interface GraderRerunResult {
1100
+ tracesGraded: number;
1101
+ gradersRun: number;
1102
+ }
1103
+ interface GraderRerun {
1104
+ id: string;
1105
+ status: GraderRerunStatus;
1106
+ graderIds: string[];
1107
+ progress: GraderRerunProgress | null;
1108
+ result: GraderRerunResult | null;
1109
+ error: string | null;
1110
+ createdAt: string;
1111
+ updatedAt: string;
1112
+ }
1113
+ interface RerunGradersOptions {
1114
+ graderIds?: string[];
1115
+ wait?: boolean;
1116
+ timeoutMs?: number;
1117
+ pollIntervalMs?: number;
1118
+ }
1119
+ interface RerunGradersResult {
1120
+ run: GraderRerun;
1121
+ joinedExisting: boolean;
1122
+ }
1123
+ /**
1124
+ * Dataset operations for the authenticated organization, reached as
1125
+ * `client.datasets`. A dataset is a named bucket of traces scoped to one trace
1126
+ * function. Experiments replay against it and its graders score its members.
1127
+ */
1128
+ declare class DatasetsClient {
1129
+ private readonly httpClient;
1130
+ constructor(httpClient: HttpClient);
1131
+ /**
1132
+ * Create a dataset, or update the one already named this way under the same
1133
+ * trace function. `created` reports which happened. An omitted description
1134
+ * leaves an existing one untouched.
1135
+ */
1136
+ save(params: SaveDatasetParams): Promise<SaveDatasetResult>;
1137
+ /**
1138
+ * List datasets, scoped to one trace function when `traceFunctionKey` is
1139
+ * given and organization-wide otherwise.
1140
+ */
1141
+ list(params?: ListDatasetsParams): Promise<Dataset[]>;
1142
+ /** Fetch one dataset by id. Rejects with a 404 `BitfabError` when it is not in this organization. */
1143
+ get(datasetId: string): Promise<Dataset>;
1144
+ /** The ids of every trace in the dataset, the same membership a replay with `datasetId` selects. */
1145
+ listTraces(datasetId: string): Promise<DatasetTraceIds>;
1146
+ /**
1147
+ * Add traces to the dataset (1 to 100 ids per call). Traces outside the
1148
+ * organization or under another trace function are reported in
1149
+ * `skippedTraceIds` rather than failing the call.
1150
+ */
1151
+ addTraces(datasetId: string, traceIds: string[]): Promise<AddDatasetTracesResult>;
1152
+ /** Remove traces from the dataset. The traces themselves are never deleted. */
1153
+ removeTraces(datasetId: string, traceIds: string[]): Promise<RemoveDatasetTracesResult>;
1154
+ /**
1155
+ * Assign graders to the dataset (1 to 100 ids per call). Graders outside the
1156
+ * organization or under another trace function are reported in
1157
+ * `skippedGraderIds` rather than failing the call.
1158
+ */
1159
+ addGraders(datasetId: string, graderIds: string[]): Promise<AddDatasetGradersResult>;
1160
+ /** Unassign graders from the dataset. */
1161
+ removeGraders(datasetId: string, graderIds: string[]): Promise<RemoveDatasetGradersResult>;
1162
+ /**
1163
+ * Re-run graders over every trace in the dataset. Defaults to every assigned
1164
+ * grader; an unassigned id is rejected. Waits for the run to finish (up to
1165
+ * `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
1166
+ * run state seen either way. A request matching an in-flight run joins it.
1167
+ */
1168
+ rerunGraders(datasetId: string, options?: RerunGradersOptions): Promise<RerunGradersResult>;
1169
+ /**
1170
+ * The dataset's active grader re-run, or the run named by `runId`. Returns
1171
+ * `null` when nothing is active or the run does not belong to this dataset.
1172
+ */
1173
+ getGraderRerun(datasetId: string, runId?: string): Promise<GraderRerun | null>;
1174
+ }
1175
+
1037
1176
  /**
1038
1177
  * LangGraph/LangChain callback handler for Bitfab tracing.
1039
1178
  *
@@ -1288,6 +1427,13 @@ declare class BitfabOpenAIAgentHandler {
1288
1427
  */
1289
1428
 
1290
1429
  type MockStrategy = "none" | "all" | "marked";
1430
+ /**
1431
+ * How a source trace came to exist. A `seeded` trace was written from a case
1432
+ * with {@link Bitfab.seedTrace} rather than executed, so it has no recorded
1433
+ * child spans to mock from and no database state to restore, and its recorded
1434
+ * output is the value the case expected rather than a previous run's result.
1435
+ */
1436
+ type TraceIngestionType = "captured" | "seeded";
1291
1437
  /**
1292
1438
  * How the DB-snapshot branch each replay item runs against is sized and warmed.
1293
1439
  *
@@ -1418,6 +1564,15 @@ interface ReplayOptions {
1418
1564
  * Omit it to spread the recorded inputs unchanged.
1419
1565
  */
1420
1566
  adaptInputs?: (inputs: unknown[], ctx: AdaptContext) => unknown[];
1567
+ /**
1568
+ * Resolve every item's inputs and stop, without calling the function.
1569
+ *
1570
+ * Selection, span fetch, deserialization, and `adaptInputs` all run, so each
1571
+ * item reports the exact arguments the function would have received. Nothing
1572
+ * executes and no replay traces are produced, which is the cheap way to check
1573
+ * that recorded inputs still fit the current signature.
1574
+ */
1575
+ dryRun?: boolean;
1421
1576
  /**
1422
1577
  * Called once per item as it finishes, in completion order (not input
1423
1578
  * order), with running totals for the whole run. Use it to render replay
@@ -1620,8 +1775,17 @@ interface ReplayItem<T> {
1620
1775
  input: unknown[];
1621
1776
  /** The result returned by the function during replay, or undefined on error. */
1622
1777
  result: T | undefined;
1623
- /** The original output from the historical trace. */
1778
+ /**
1779
+ * The original output from the historical trace. For a `seeded` source this
1780
+ * is the value the case expected, not a previous run's result, so a
1781
+ * difference means the code missed the expectation rather than drifted.
1782
+ */
1624
1783
  originalOutput: unknown;
1784
+ /**
1785
+ * How the source trace came to exist. Absent on servers that predate the
1786
+ * field, which only ever served captured traces.
1787
+ */
1788
+ ingestionType?: TraceIngestionType;
1625
1789
  /**
1626
1790
  * Backward-compatible message for either error kind. Prefer `traceError` and
1627
1791
  * `replayError` when callers need the original exception and its source.
@@ -2247,6 +2411,8 @@ declare class Bitfab {
2247
2411
  private readonly explicitlyEnabled;
2248
2412
  private readonly strict;
2249
2413
  private readonly httpClient;
2414
+ /** Dataset operations for the authenticated organization. */
2415
+ readonly datasets: DatasetsClient;
2250
2416
  private readonly bamlClient;
2251
2417
  private readonly dbSnapshot;
2252
2418
  private readonly autoTracePolicyRefreshes;
@@ -2716,6 +2882,45 @@ declare class Bitfab {
2716
2882
  registerMockOverride(traceFunctionKey: string, override: MockOverride | MockOverrideResolver): void;
2717
2883
  /** Remove all overrides registered via {@link registerMockOverride}. */
2718
2884
  clearMockOverrides(): void;
2885
+ /**
2886
+ * Write a replayable trace from a case, without running anything.
2887
+ *
2888
+ * Use this to turn a corpus you already hold (a Braintrust dataset, a
2889
+ * spreadsheet, hand-written cases) into traces that {@link replay} can
2890
+ * select. The recorded root span carries `input` as its input and `expected`
2891
+ * as its output, so replay reports each item against the value you expected
2892
+ * rather than against a previous run.
2893
+ *
2894
+ * A seeded trace has no child spans and no database pin, so replay mocking
2895
+ * has nothing recorded to substitute and `dbBranch` refuses it. Pass
2896
+ * `mockOverride` at replay time for calls that must not run.
2897
+ *
2898
+ * @returns The trace ID, usable with `replay({ traceIds: [...] })`.
2899
+ */
2900
+ seedTrace(traceFunctionKey: string, options: {
2901
+ /** Arguments spread into the function at replay, as `fn(...input)`. */
2902
+ input: unknown[];
2903
+ /**
2904
+ * The output this case should produce. Optional, but without it the
2905
+ * replay has nothing to be judged against.
2906
+ */
2907
+ expected?: unknown;
2908
+ /**
2909
+ * The function these inputs will replay through. When given, the call is
2910
+ * checked against its arity here, so a case that cannot supply the
2911
+ * function's required arguments fails now instead of at replay. Omit it
2912
+ * when the seeding script cannot import the function.
2913
+ */
2914
+ fn?: (...args: any[]) => unknown;
2915
+ /**
2916
+ * Recorded on the trace. Put the source row's id here so a seeded trace
2917
+ * can be traced back to the case it came from.
2918
+ */
2919
+ metadata?: Record<string, unknown>;
2920
+ sessionId?: string;
2921
+ spanName?: string;
2922
+ spanType?: SpanType;
2923
+ }): string;
2719
2924
  replay<TReturn>(traceFunctionKey: string, fn: (...args: any[]) => TReturn | Promise<TReturn>, options?: ReplayOptions): Promise<ReplayResult<TReturn>>;
2720
2925
  }
2721
2926
  /**
@@ -2891,7 +3096,7 @@ declare class BitfabFunction {
2891
3096
  /**
2892
3097
  * SDK version from package.json (injected at build time)
2893
3098
  */
2894
- declare const __version__ = "0.38.10";
3099
+ declare const __version__ = "0.40.0";
2895
3100
 
2896
3101
  /**
2897
3102
  * Constants for the Bitfab SDK.
@@ -2993,5 +3198,30 @@ type ReplayRegistry = Record<string, ReplayRegistration>;
2993
3198
  * SDK upgrade can add replay features without regenerating the project file.
2994
3199
  */
2995
3200
  declare function defineReplayRegistry<TRegistry extends ReplayRegistry>(registry: TRegistry): TRegistry;
3201
+ /** One case to seed, in the shape `--seed` reads from JSON or JSONL. */
3202
+ interface SeedCase {
3203
+ /** Arguments spread into the registered function at replay. */
3204
+ input: unknown[];
3205
+ /** The output this case should produce. */
3206
+ expected?: unknown;
3207
+ /** Recorded on the trace, for tracing a seeded case back to its source row. */
3208
+ metadata?: Record<string, unknown>;
3209
+ sessionId?: string;
3210
+ }
3211
+ interface SeedResult {
3212
+ pipeline: string;
3213
+ traceFunctionKey: string;
3214
+ traceIds: string[];
3215
+ }
3216
+ /**
3217
+ * Seed cases through an already-registered pipeline.
3218
+ *
3219
+ * The registration is the whole point: it already holds the client, the exact
3220
+ * function production calls, and the trace function key replay selects by, so
3221
+ * a seeded case is guaranteed to line up with the replay that will read it.
3222
+ * Passing the registered function to `seedTrace` also means a case that cannot
3223
+ * supply its required arguments is rejected here rather than at replay.
3224
+ */
3225
+ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, cases: readonly SeedCase[]): Promise<SeedResult>;
2996
3226
 
2997
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type LangGraphIntegrationOptions, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
3227
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedResult, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
package/dist/index.d.ts CHANGED
@@ -540,7 +540,11 @@ declare class HttpClient {
540
540
  lookupFunction<T>(name: string): Promise<T>;
541
541
  getAutoTracePolicy<T>(traceFunctionKey: string, protocol: string): Promise<T>;
542
542
  getTraceSpan(traceId: string, lookup: SpanLookup): Promise<CapturedSpan | null>;
543
- private get;
543
+ /**
544
+ * GET a JSON endpoint on the service with the client's API key. Throws a
545
+ * `BitfabError` carrying the status text for any non-2xx response.
546
+ */
547
+ get<T>(endpoint: string): Promise<T>;
544
548
  /**
545
549
  * Queue an internal trace (from local BAML execution via `call()`) onto this
546
550
  * client's batching transport. `functionId` moves into the payload because
@@ -1034,6 +1038,141 @@ declare class BitfabVercelAiHandler {
1034
1038
  get middleware(): BitfabLanguageModelMiddleware;
1035
1039
  }
1036
1040
 
1041
+ interface DatasetGraderRef {
1042
+ id: string;
1043
+ name: string | null;
1044
+ }
1045
+ interface Dataset {
1046
+ id: string;
1047
+ traceFunctionKey: string;
1048
+ name: string;
1049
+ description: string | null;
1050
+ traceCount: number;
1051
+ graders: DatasetGraderRef[];
1052
+ createdAt: string;
1053
+ updatedAt: string;
1054
+ }
1055
+ interface SaveDatasetParams {
1056
+ traceFunctionKey: string;
1057
+ name: string;
1058
+ description?: string;
1059
+ }
1060
+ interface SaveDatasetResult {
1061
+ dataset: Dataset;
1062
+ created: boolean;
1063
+ }
1064
+ interface ListDatasetsParams {
1065
+ traceFunctionKey?: string;
1066
+ }
1067
+ interface DatasetTraceIds {
1068
+ datasetId: string;
1069
+ traceIds: string[];
1070
+ }
1071
+ interface AddDatasetTracesResult {
1072
+ dataset: Dataset;
1073
+ addedTraceIds: string[];
1074
+ alreadyPresentTraceIds: string[];
1075
+ skippedTraceIds: string[];
1076
+ }
1077
+ interface RemoveDatasetTracesResult {
1078
+ dataset: Dataset;
1079
+ removedTraceIds: string[];
1080
+ notPresentTraceIds: string[];
1081
+ }
1082
+ interface AddDatasetGradersResult {
1083
+ dataset: Dataset;
1084
+ addedGraderIds: string[];
1085
+ alreadyAssignedGraderIds: string[];
1086
+ skippedGraderIds: string[];
1087
+ }
1088
+ interface RemoveDatasetGradersResult {
1089
+ dataset: Dataset;
1090
+ removedGraderIds: string[];
1091
+ notAssignedGraderIds: string[];
1092
+ }
1093
+ type GraderRerunStatus = "pending" | "running" | "completed" | "errored";
1094
+ interface GraderRerunProgress {
1095
+ completedTraces: number;
1096
+ totalTraces: number;
1097
+ graderCount: number;
1098
+ }
1099
+ interface GraderRerunResult {
1100
+ tracesGraded: number;
1101
+ gradersRun: number;
1102
+ }
1103
+ interface GraderRerun {
1104
+ id: string;
1105
+ status: GraderRerunStatus;
1106
+ graderIds: string[];
1107
+ progress: GraderRerunProgress | null;
1108
+ result: GraderRerunResult | null;
1109
+ error: string | null;
1110
+ createdAt: string;
1111
+ updatedAt: string;
1112
+ }
1113
+ interface RerunGradersOptions {
1114
+ graderIds?: string[];
1115
+ wait?: boolean;
1116
+ timeoutMs?: number;
1117
+ pollIntervalMs?: number;
1118
+ }
1119
+ interface RerunGradersResult {
1120
+ run: GraderRerun;
1121
+ joinedExisting: boolean;
1122
+ }
1123
+ /**
1124
+ * Dataset operations for the authenticated organization, reached as
1125
+ * `client.datasets`. A dataset is a named bucket of traces scoped to one trace
1126
+ * function. Experiments replay against it and its graders score its members.
1127
+ */
1128
+ declare class DatasetsClient {
1129
+ private readonly httpClient;
1130
+ constructor(httpClient: HttpClient);
1131
+ /**
1132
+ * Create a dataset, or update the one already named this way under the same
1133
+ * trace function. `created` reports which happened. An omitted description
1134
+ * leaves an existing one untouched.
1135
+ */
1136
+ save(params: SaveDatasetParams): Promise<SaveDatasetResult>;
1137
+ /**
1138
+ * List datasets, scoped to one trace function when `traceFunctionKey` is
1139
+ * given and organization-wide otherwise.
1140
+ */
1141
+ list(params?: ListDatasetsParams): Promise<Dataset[]>;
1142
+ /** Fetch one dataset by id. Rejects with a 404 `BitfabError` when it is not in this organization. */
1143
+ get(datasetId: string): Promise<Dataset>;
1144
+ /** The ids of every trace in the dataset, the same membership a replay with `datasetId` selects. */
1145
+ listTraces(datasetId: string): Promise<DatasetTraceIds>;
1146
+ /**
1147
+ * Add traces to the dataset (1 to 100 ids per call). Traces outside the
1148
+ * organization or under another trace function are reported in
1149
+ * `skippedTraceIds` rather than failing the call.
1150
+ */
1151
+ addTraces(datasetId: string, traceIds: string[]): Promise<AddDatasetTracesResult>;
1152
+ /** Remove traces from the dataset. The traces themselves are never deleted. */
1153
+ removeTraces(datasetId: string, traceIds: string[]): Promise<RemoveDatasetTracesResult>;
1154
+ /**
1155
+ * Assign graders to the dataset (1 to 100 ids per call). Graders outside the
1156
+ * organization or under another trace function are reported in
1157
+ * `skippedGraderIds` rather than failing the call.
1158
+ */
1159
+ addGraders(datasetId: string, graderIds: string[]): Promise<AddDatasetGradersResult>;
1160
+ /** Unassign graders from the dataset. */
1161
+ removeGraders(datasetId: string, graderIds: string[]): Promise<RemoveDatasetGradersResult>;
1162
+ /**
1163
+ * Re-run graders over every trace in the dataset. Defaults to every assigned
1164
+ * grader; an unassigned id is rejected. Waits for the run to finish (up to
1165
+ * `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
1166
+ * run state seen either way. A request matching an in-flight run joins it.
1167
+ */
1168
+ rerunGraders(datasetId: string, options?: RerunGradersOptions): Promise<RerunGradersResult>;
1169
+ /**
1170
+ * The dataset's active grader re-run, or the run named by `runId`. Returns
1171
+ * `null` when nothing is active or the run does not belong to this dataset.
1172
+ */
1173
+ getGraderRerun(datasetId: string, runId?: string): Promise<GraderRerun | null>;
1174
+ }
1175
+
1037
1176
  /**
1038
1177
  * LangGraph/LangChain callback handler for Bitfab tracing.
1039
1178
  *
@@ -1288,6 +1427,13 @@ declare class BitfabOpenAIAgentHandler {
1288
1427
  */
1289
1428
 
1290
1429
  type MockStrategy = "none" | "all" | "marked";
1430
+ /**
1431
+ * How a source trace came to exist. A `seeded` trace was written from a case
1432
+ * with {@link Bitfab.seedTrace} rather than executed, so it has no recorded
1433
+ * child spans to mock from and no database state to restore, and its recorded
1434
+ * output is the value the case expected rather than a previous run's result.
1435
+ */
1436
+ type TraceIngestionType = "captured" | "seeded";
1291
1437
  /**
1292
1438
  * How the DB-snapshot branch each replay item runs against is sized and warmed.
1293
1439
  *
@@ -1418,6 +1564,15 @@ interface ReplayOptions {
1418
1564
  * Omit it to spread the recorded inputs unchanged.
1419
1565
  */
1420
1566
  adaptInputs?: (inputs: unknown[], ctx: AdaptContext) => unknown[];
1567
+ /**
1568
+ * Resolve every item's inputs and stop, without calling the function.
1569
+ *
1570
+ * Selection, span fetch, deserialization, and `adaptInputs` all run, so each
1571
+ * item reports the exact arguments the function would have received. Nothing
1572
+ * executes and no replay traces are produced, which is the cheap way to check
1573
+ * that recorded inputs still fit the current signature.
1574
+ */
1575
+ dryRun?: boolean;
1421
1576
  /**
1422
1577
  * Called once per item as it finishes, in completion order (not input
1423
1578
  * order), with running totals for the whole run. Use it to render replay
@@ -1620,8 +1775,17 @@ interface ReplayItem<T> {
1620
1775
  input: unknown[];
1621
1776
  /** The result returned by the function during replay, or undefined on error. */
1622
1777
  result: T | undefined;
1623
- /** The original output from the historical trace. */
1778
+ /**
1779
+ * The original output from the historical trace. For a `seeded` source this
1780
+ * is the value the case expected, not a previous run's result, so a
1781
+ * difference means the code missed the expectation rather than drifted.
1782
+ */
1624
1783
  originalOutput: unknown;
1784
+ /**
1785
+ * How the source trace came to exist. Absent on servers that predate the
1786
+ * field, which only ever served captured traces.
1787
+ */
1788
+ ingestionType?: TraceIngestionType;
1625
1789
  /**
1626
1790
  * Backward-compatible message for either error kind. Prefer `traceError` and
1627
1791
  * `replayError` when callers need the original exception and its source.
@@ -2247,6 +2411,8 @@ declare class Bitfab {
2247
2411
  private readonly explicitlyEnabled;
2248
2412
  private readonly strict;
2249
2413
  private readonly httpClient;
2414
+ /** Dataset operations for the authenticated organization. */
2415
+ readonly datasets: DatasetsClient;
2250
2416
  private readonly bamlClient;
2251
2417
  private readonly dbSnapshot;
2252
2418
  private readonly autoTracePolicyRefreshes;
@@ -2716,6 +2882,45 @@ declare class Bitfab {
2716
2882
  registerMockOverride(traceFunctionKey: string, override: MockOverride | MockOverrideResolver): void;
2717
2883
  /** Remove all overrides registered via {@link registerMockOverride}. */
2718
2884
  clearMockOverrides(): void;
2885
+ /**
2886
+ * Write a replayable trace from a case, without running anything.
2887
+ *
2888
+ * Use this to turn a corpus you already hold (a Braintrust dataset, a
2889
+ * spreadsheet, hand-written cases) into traces that {@link replay} can
2890
+ * select. The recorded root span carries `input` as its input and `expected`
2891
+ * as its output, so replay reports each item against the value you expected
2892
+ * rather than against a previous run.
2893
+ *
2894
+ * A seeded trace has no child spans and no database pin, so replay mocking
2895
+ * has nothing recorded to substitute and `dbBranch` refuses it. Pass
2896
+ * `mockOverride` at replay time for calls that must not run.
2897
+ *
2898
+ * @returns The trace ID, usable with `replay({ traceIds: [...] })`.
2899
+ */
2900
+ seedTrace(traceFunctionKey: string, options: {
2901
+ /** Arguments spread into the function at replay, as `fn(...input)`. */
2902
+ input: unknown[];
2903
+ /**
2904
+ * The output this case should produce. Optional, but without it the
2905
+ * replay has nothing to be judged against.
2906
+ */
2907
+ expected?: unknown;
2908
+ /**
2909
+ * The function these inputs will replay through. When given, the call is
2910
+ * checked against its arity here, so a case that cannot supply the
2911
+ * function's required arguments fails now instead of at replay. Omit it
2912
+ * when the seeding script cannot import the function.
2913
+ */
2914
+ fn?: (...args: any[]) => unknown;
2915
+ /**
2916
+ * Recorded on the trace. Put the source row's id here so a seeded trace
2917
+ * can be traced back to the case it came from.
2918
+ */
2919
+ metadata?: Record<string, unknown>;
2920
+ sessionId?: string;
2921
+ spanName?: string;
2922
+ spanType?: SpanType;
2923
+ }): string;
2719
2924
  replay<TReturn>(traceFunctionKey: string, fn: (...args: any[]) => TReturn | Promise<TReturn>, options?: ReplayOptions): Promise<ReplayResult<TReturn>>;
2720
2925
  }
2721
2926
  /**
@@ -2891,7 +3096,7 @@ declare class BitfabFunction {
2891
3096
  /**
2892
3097
  * SDK version from package.json (injected at build time)
2893
3098
  */
2894
- declare const __version__ = "0.38.10";
3099
+ declare const __version__ = "0.40.0";
2895
3100
 
2896
3101
  /**
2897
3102
  * Constants for the Bitfab SDK.
@@ -2993,5 +3198,30 @@ type ReplayRegistry = Record<string, ReplayRegistration>;
2993
3198
  * SDK upgrade can add replay features without regenerating the project file.
2994
3199
  */
2995
3200
  declare function defineReplayRegistry<TRegistry extends ReplayRegistry>(registry: TRegistry): TRegistry;
3201
+ /** One case to seed, in the shape `--seed` reads from JSON or JSONL. */
3202
+ interface SeedCase {
3203
+ /** Arguments spread into the registered function at replay. */
3204
+ input: unknown[];
3205
+ /** The output this case should produce. */
3206
+ expected?: unknown;
3207
+ /** Recorded on the trace, for tracing a seeded case back to its source row. */
3208
+ metadata?: Record<string, unknown>;
3209
+ sessionId?: string;
3210
+ }
3211
+ interface SeedResult {
3212
+ pipeline: string;
3213
+ traceFunctionKey: string;
3214
+ traceIds: string[];
3215
+ }
3216
+ /**
3217
+ * Seed cases through an already-registered pipeline.
3218
+ *
3219
+ * The registration is the whole point: it already holds the client, the exact
3220
+ * function production calls, and the trace function key replay selects by, so
3221
+ * a seeded case is guaranteed to line up with the replay that will read it.
3222
+ * Passing the registered function to `seedTrace` also means a case that cannot
3223
+ * supply its required arguments is rejected here rather than at replay.
3224
+ */
3225
+ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, cases: readonly SeedCase[]): Promise<SeedResult>;
2996
3226
 
2997
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type LangGraphIntegrationOptions, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
3227
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedResult, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
package/dist/index.js CHANGED
@@ -7,27 +7,31 @@ import {
7
7
  BitfabOpenAIAgentHandler,
8
8
  BitfabOpenAITracingProcessor,
9
9
  BitfabVercelAiHandler,
10
+ DatasetsClient,
10
11
  SUPPORTED_PROVIDERS,
11
12
  defineReplayRegistry,
12
13
  finalizers,
13
14
  getCurrentReplayBranch,
14
15
  getCurrentSpan,
15
- getCurrentTrace
16
- } from "./chunk-UE4GGPM6.js";
16
+ getCurrentTrace,
17
+ seedFromRegistry
18
+ } from "./chunk-5NT4YDCQ.js";
17
19
  import "./chunk-ZUD7OFYB.js";
18
20
  import {
19
21
  BITFAB_PROGRESS_PREFIX,
20
- BitfabError,
21
- DEFAULT_SERVICE_URL,
22
22
  DbBranchReplayError,
23
- HttpClient,
24
23
  NO_MOCK_OVERRIDE,
25
24
  ReplayError,
26
- __version__,
27
- flushTraces,
28
25
  reportReplayProgress,
29
26
  serializeReplayResult
30
- } from "./chunk-BNOVHUQB.js";
27
+ } from "./chunk-EXT5FK54.js";
28
+ import {
29
+ BitfabError,
30
+ DEFAULT_SERVICE_URL,
31
+ HttpClient,
32
+ __version__,
33
+ flushTraces
34
+ } from "./chunk-A22EYRSY.js";
31
35
  import "./chunk-H6LZRFMN.js";
32
36
  export {
33
37
  BITFAB_PROGRESS_PREFIX,
@@ -42,6 +46,7 @@ export {
42
46
  BitfabOpenAITracingProcessor,
43
47
  BitfabVercelAiHandler,
44
48
  DEFAULT_SERVICE_URL,
49
+ DatasetsClient,
45
50
  DbBranchReplayError,
46
51
  HttpClient,
47
52
  NO_MOCK_OVERRIDE,
@@ -55,6 +60,7 @@ export {
55
60
  getCurrentSpan,
56
61
  getCurrentTrace,
57
62
  reportReplayProgress,
63
+ seedFromRegistry,
58
64
  serializeReplayResult
59
65
  };
60
66
  //# sourceMappingURL=index.js.map