@bitfab/sdk 0.42.0 → 0.43.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/{chunk-BC5OYWAM.js → chunk-5BBJ5BQD.js} +173 -67
- package/dist/chunk-5BBJ5BQD.js.map +1 -0
- package/dist/{chunk-UGFTBSGS.js → chunk-6EM2S5H5.js} +6 -3
- package/dist/{chunk-UGFTBSGS.js.map → chunk-6EM2S5H5.js.map} +1 -1
- package/dist/{chunk-QJ6IFPGU.js → chunk-BBJSKBVJ.js} +6 -3
- package/dist/{chunk-QJ6IFPGU.js.map → chunk-BBJSKBVJ.js.map} +1 -1
- package/dist/{chunk-BG3A5HNC.js → chunk-BXBRVWWW.js} +10 -4
- package/dist/chunk-BXBRVWWW.js.map +1 -0
- package/dist/{http-F5L466DI.js → http-IO3Y7ROJ.js} +2 -2
- package/dist/{http-NZHGC5YF.js → http-R553H2H2.js} +2 -2
- package/dist/index.cjs +184 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -53
- package/dist/index.d.ts +37 -53
- package/dist/index.js +3 -3
- package/dist/node.cjs +184 -66
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-PLACY77M.js → replay-LM4GIDVD.js} +3 -3
- package/dist/replayCli.js +31 -10
- package/dist/replayCli.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-BC5OYWAM.js.map +0 -1
- package/dist/chunk-BG3A5HNC.js.map +0 -1
- /package/dist/{http-F5L466DI.js.map → http-IO3Y7ROJ.js.map} +0 -0
- /package/dist/{http-NZHGC5YF.js.map → http-R553H2H2.js.map} +0 -0
- /package/dist/{replay-PLACY77M.js.map → replay-LM4GIDVD.js.map} +0 -0
package/dist/node.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ActiveSpanContext, AdaptContext, AdaptInputsFn, AddDatasetGradersResult, AddDatasetTracesResult, AllowedEnvVars, BITFAB_PROGRESS_PREFIX, BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, BitfabConfig, BitfabError, BitfabFunction, BitfabLangChainCallbackHandler, BitfabLangChainCallbackHandler as BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, CaptureWhen, CapturedSpan, CodeChangeFile, CurrentSpan, CurrentTrace, DEFAULT_SERVICE_URL, Dataset, DatasetGraderRef, DatasetTraceIds, DatasetsClient, DbBranchOptions, DbBranchReplayError, DbBranchTimings, DbSnapshotConfig, DbSnapshotProvider, DbSnapshotRef, DetachedTrace, GraderRerun, GraderRerunProgress, GraderRerunResult, GraderRerunStatus, HttpClient, LangGraphIntegrationOptions, ListDatasetsParams, MockOverride, MockOverrideCtx, MockOverrideInput, MockOverrideResolver, MockStrategy, MockValue, NO_MOCK_OVERRIDE, NodeMatcher, NodeMethodDecorator, NodeOptions, ProviderDefinition, RemoveDatasetGradersResult, RemoveDatasetTracesResult, ReplayBranch, ReplayError, ReplayItem, ReplayItemFinishProgress, ReplayItemStartProgress, ReplayOptions, ReplayOptionsFactory, ReplayProgress, ReplayProgressItem, ReplayRegistration, ReplayRegistry, ReplayRegistryContext, ReplayRegistryOptions, ReplayResult, RerunGradersOptions, RerunGradersResult, SUPPORTED_PROVIDERS, SaveDatasetParams, SaveDatasetResult, SeedCase, SeedResult, SpanLookup, SpanMethodDecorator, SpanMethodDecoratorContext, SpanNodeMeta, SpanOccurrence, SpanOptions, SpanType, TokenUsage, TraceIngestionType, TraceResponse, TracingProcessor, VercelCallParams, VercelGenerateResult, VercelStreamResult, WrapBAMLOptions, WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult } from './index.cjs';
|
|
1
|
+
export { ActiveSpanContext, AdaptContext, AdaptInputsFn, AddDatasetGradersResult, AddDatasetTracesResult, AllowedEnvVars, BITFAB_PROGRESS_PREFIX, BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, BitfabConfig, BitfabError, BitfabFunction, BitfabLangChainCallbackHandler, BitfabLangChainCallbackHandler as BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, CaptureSurface, CaptureWhen, CapturedSpan, CodeChangeFile, CurrentSpan, CurrentTrace, DEFAULT_SERVICE_URL, Dataset, DatasetGraderRef, DatasetTraceIds, DatasetsClient, DbBranchOptions, DbBranchReplayError, DbBranchTimings, DbSnapshotConfig, DbSnapshotProvider, DbSnapshotRef, DetachedTrace, GraderRerun, GraderRerunProgress, GraderRerunResult, GraderRerunStatus, HttpClient, LangGraphIntegrationOptions, ListDatasetsParams, MockOverride, MockOverrideCtx, MockOverrideInput, MockOverrideResolver, MockStrategy, MockValue, NO_MOCK_OVERRIDE, NodeMatcher, NodeMethodDecorator, NodeOptions, ProviderDefinition, RemoveDatasetGradersResult, RemoveDatasetTracesResult, ReplayBranch, ReplayError, ReplayItem, ReplayItemFinishProgress, ReplayItemStartProgress, ReplayOptions, ReplayOptionsFactory, ReplayProgress, ReplayProgressItem, ReplayRegistration, ReplayRegistry, ReplayRegistryContext, ReplayRegistryOptions, ReplayResult, RerunGradersOptions, RerunGradersResult, SUPPORTED_PROVIDERS, SaveDatasetParams, SaveDatasetResult, SeedCase, SeedCaseOptions, SeedResult, SeedRunOptions, SpanLookup, SpanMethodDecorator, SpanMethodDecoratorContext, SpanNodeMeta, SpanOccurrence, SpanOptions, SpanType, TokenUsage, TraceIngestionType, TraceResponse, TracingProcessor, VercelCallParams, VercelGenerateResult, VercelStreamResult, WrapBAMLOptions, WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult } from './index.cjs';
|
package/dist/node.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ActiveSpanContext, AdaptContext, AdaptInputsFn, AddDatasetGradersResult, AddDatasetTracesResult, AllowedEnvVars, BITFAB_PROGRESS_PREFIX, BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, BitfabConfig, BitfabError, BitfabFunction, BitfabLangChainCallbackHandler, BitfabLangChainCallbackHandler as BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, CaptureWhen, CapturedSpan, CodeChangeFile, CurrentSpan, CurrentTrace, DEFAULT_SERVICE_URL, Dataset, DatasetGraderRef, DatasetTraceIds, DatasetsClient, DbBranchOptions, DbBranchReplayError, DbBranchTimings, DbSnapshotConfig, DbSnapshotProvider, DbSnapshotRef, DetachedTrace, GraderRerun, GraderRerunProgress, GraderRerunResult, GraderRerunStatus, HttpClient, LangGraphIntegrationOptions, ListDatasetsParams, MockOverride, MockOverrideCtx, MockOverrideInput, MockOverrideResolver, MockStrategy, MockValue, NO_MOCK_OVERRIDE, NodeMatcher, NodeMethodDecorator, NodeOptions, ProviderDefinition, RemoveDatasetGradersResult, RemoveDatasetTracesResult, ReplayBranch, ReplayError, ReplayItem, ReplayItemFinishProgress, ReplayItemStartProgress, ReplayOptions, ReplayOptionsFactory, ReplayProgress, ReplayProgressItem, ReplayRegistration, ReplayRegistry, ReplayRegistryContext, ReplayRegistryOptions, ReplayResult, RerunGradersOptions, RerunGradersResult, SUPPORTED_PROVIDERS, SaveDatasetParams, SaveDatasetResult, SeedCase, SeedResult, SpanLookup, SpanMethodDecorator, SpanMethodDecoratorContext, SpanNodeMeta, SpanOccurrence, SpanOptions, SpanType, TokenUsage, TraceIngestionType, TraceResponse, TracingProcessor, VercelCallParams, VercelGenerateResult, VercelStreamResult, WrapBAMLOptions, WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult } from './index.js';
|
|
1
|
+
export { ActiveSpanContext, AdaptContext, AdaptInputsFn, AddDatasetGradersResult, AddDatasetTracesResult, AllowedEnvVars, BITFAB_PROGRESS_PREFIX, BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, BitfabConfig, BitfabError, BitfabFunction, BitfabLangChainCallbackHandler, BitfabLangChainCallbackHandler as BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, CaptureSurface, CaptureWhen, CapturedSpan, CodeChangeFile, CurrentSpan, CurrentTrace, DEFAULT_SERVICE_URL, Dataset, DatasetGraderRef, DatasetTraceIds, DatasetsClient, DbBranchOptions, DbBranchReplayError, DbBranchTimings, DbSnapshotConfig, DbSnapshotProvider, DbSnapshotRef, DetachedTrace, GraderRerun, GraderRerunProgress, GraderRerunResult, GraderRerunStatus, HttpClient, LangGraphIntegrationOptions, ListDatasetsParams, MockOverride, MockOverrideCtx, MockOverrideInput, MockOverrideResolver, MockStrategy, MockValue, NO_MOCK_OVERRIDE, NodeMatcher, NodeMethodDecorator, NodeOptions, ProviderDefinition, RemoveDatasetGradersResult, RemoveDatasetTracesResult, ReplayBranch, ReplayError, ReplayItem, ReplayItemFinishProgress, ReplayItemStartProgress, ReplayOptions, ReplayOptionsFactory, ReplayProgress, ReplayProgressItem, ReplayRegistration, ReplayRegistry, ReplayRegistryContext, ReplayRegistryOptions, ReplayResult, RerunGradersOptions, RerunGradersResult, SUPPORTED_PROVIDERS, SaveDatasetParams, SaveDatasetResult, SeedCase, SeedCaseOptions, SeedResult, SeedRunOptions, SpanLookup, SpanMethodDecorator, SpanMethodDecoratorContext, SpanNodeMeta, SpanOccurrence, SpanOptions, SpanType, TokenUsage, TraceIngestionType, TraceResponse, TracingProcessor, VercelCallParams, VercelGenerateResult, VercelStreamResult, WrapBAMLOptions, WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult } from './index.js';
|
package/dist/node.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
getCurrentSpan,
|
|
16
16
|
getCurrentTrace,
|
|
17
17
|
seedFromRegistry
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5BBJ5BQD.js";
|
|
19
19
|
import "./chunk-ZUD7OFYB.js";
|
|
20
20
|
import {
|
|
21
21
|
BITFAB_PROGRESS_PREFIX,
|
|
@@ -24,14 +24,14 @@ import {
|
|
|
24
24
|
ReplayError,
|
|
25
25
|
reportReplayProgress,
|
|
26
26
|
serializeReplayResult
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-BXBRVWWW.js";
|
|
28
28
|
import {
|
|
29
29
|
BitfabError,
|
|
30
30
|
DEFAULT_SERVICE_URL,
|
|
31
31
|
HttpClient,
|
|
32
32
|
__version__,
|
|
33
33
|
flushTraces
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-6EM2S5H5.js";
|
|
35
35
|
import {
|
|
36
36
|
assertAsyncStorageRegistered,
|
|
37
37
|
registerAsyncLocalStorageClass
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
serializeReplayResult,
|
|
8
8
|
sleepForReplayPersistence,
|
|
9
9
|
waitForReplayPersistence
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-BXBRVWWW.js";
|
|
11
|
+
import "./chunk-6EM2S5H5.js";
|
|
12
12
|
import "./chunk-H6LZRFMN.js";
|
|
13
13
|
export {
|
|
14
14
|
BITFAB_PROGRESS_PREFIX,
|
|
@@ -20,4 +20,4 @@ export {
|
|
|
20
20
|
sleepForReplayPersistence,
|
|
21
21
|
waitForReplayPersistence
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=replay-
|
|
23
|
+
//# sourceMappingURL=replay-LM4GIDVD.js.map
|
package/dist/replayCli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
BitfabError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BBJSKBVJ.js";
|
|
5
5
|
|
|
6
6
|
// src/replayCli.ts
|
|
7
7
|
import { tsImport } from "tsx/esm/api";
|
|
@@ -114,7 +114,7 @@ Options:
|
|
|
114
114
|
}
|
|
115
115
|
var ReplayCliHelp = class extends Error {
|
|
116
116
|
};
|
|
117
|
-
function parseSeedCases(raw, path) {
|
|
117
|
+
function parseSeedCases(raw, path, run) {
|
|
118
118
|
const trimmed = raw.trim();
|
|
119
119
|
if (trimmed.length === 0) {
|
|
120
120
|
throw new BitfabError(`Seed file '${path}' is empty.`);
|
|
@@ -132,10 +132,15 @@ function parseSeedCases(raw, path) {
|
|
|
132
132
|
`Seed case ${index} in '${path}' is missing an "input" array. Wrap a single argument as [arg].`
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
|
+
if (run && "expected" in value) {
|
|
136
|
+
throw new BitfabError(
|
|
137
|
+
`Seed case ${index} in '${path}' carries "expected", which --run does not record: the case is run once and its output is what the run produced. Remove the field, or drop --run to record the case without running it.`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
135
140
|
return value;
|
|
136
141
|
});
|
|
137
142
|
}
|
|
138
|
-
async function seedFromRegistry(registry, pipeline, cases) {
|
|
143
|
+
async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
139
144
|
const registration = registry[pipeline];
|
|
140
145
|
if (registration === void 0) {
|
|
141
146
|
throw new BitfabError(
|
|
@@ -143,6 +148,19 @@ async function seedFromRegistry(registry, pipeline, cases) {
|
|
|
143
148
|
);
|
|
144
149
|
}
|
|
145
150
|
const traceFunctionKey = resolveTraceFunctionKey(registration);
|
|
151
|
+
if (options.run === true) {
|
|
152
|
+
const traceIds2 = [];
|
|
153
|
+
for (const seedCase of cases) {
|
|
154
|
+
traceIds2.push(
|
|
155
|
+
await registration.client.seedTrace(traceFunctionKey, registration.fn, {
|
|
156
|
+
args: seedCase.input,
|
|
157
|
+
metadata: seedCase.metadata,
|
|
158
|
+
sessionId: seedCase.sessionId
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
return { pipeline, traceFunctionKey, traceIds: traceIds2 };
|
|
163
|
+
}
|
|
146
164
|
const traceIds = cases.map(
|
|
147
165
|
(seedCase) => registration.client.seedTrace(traceFunctionKey, {
|
|
148
166
|
input: seedCase.input,
|
|
@@ -152,11 +170,11 @@ async function seedFromRegistry(registry, pipeline, cases) {
|
|
|
152
170
|
sessionId: seedCase.sessionId
|
|
153
171
|
})
|
|
154
172
|
);
|
|
155
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
173
|
+
const { flushTraces: flushTraces2 } = await import("./http-R553H2H2.js");
|
|
156
174
|
await flushTraces2(3e4);
|
|
157
175
|
return { pipeline, traceFunctionKey, traceIds };
|
|
158
176
|
}
|
|
159
|
-
var SEED_USAGE = 'Usage: bitfab-replay --registry <path> <pipeline> --seed <cases.jsonl
|
|
177
|
+
var SEED_USAGE = 'Usage: bitfab-replay --registry <path> <pipeline> --seed <cases.jsonl> [--run]\n\nEach case is a JSON object with an "input" array, plus optional "expected", "metadata", and "sessionId". A JSON array of those objects works too.\n\nWithout --run, each case is written as a trace directly: "input" becomes the root span input and "expected" its output, and nothing executes.\n\nWith --run, each case is run once through the registered function with capture off and the execution is recorded, so the output is what the run produced. Cases carrying "expected" are rejected.';
|
|
160
178
|
async function runSeedCli(registry, argv, io = {}) {
|
|
161
179
|
const stdout = io.stdout ?? console.log;
|
|
162
180
|
const stderr = io.stderr ?? console.error;
|
|
@@ -172,12 +190,15 @@ async function runSeedCli(registry, argv, io = {}) {
|
|
|
172
190
|
if (casesPath === void 0 || casesPath.startsWith("--")) {
|
|
173
191
|
throw new BitfabError("--seed requires a path to a cases file.");
|
|
174
192
|
}
|
|
193
|
+
const run = argv.includes("--run");
|
|
175
194
|
const readFile = io.readFile ?? defaultReadFile;
|
|
176
|
-
const cases = parseSeedCases(await readFile(casesPath), casesPath);
|
|
177
|
-
stderr(
|
|
178
|
-
|
|
195
|
+
const cases = parseSeedCases(await readFile(casesPath), casesPath, run);
|
|
196
|
+
stderr(
|
|
197
|
+
run ? `[seed] Running ${cases.length} case(s) through "${pipeline}"...` : `[seed] Seeding ${cases.length} case(s) into "${pipeline}"...`
|
|
198
|
+
);
|
|
199
|
+
const result = await seedFromRegistry(registry, pipeline, cases, { run });
|
|
179
200
|
stderr(
|
|
180
|
-
`[seed] Wrote ${result.traceIds.length} trace(s) for "${result.traceFunctionKey}". Replay them with --trace-ids ${result.traceIds.slice(0, 3).join(",")}${result.traceIds.length > 3 ? ",..." : ""}`
|
|
201
|
+
`[seed] ${run ? "Recorded" : "Wrote"} ${result.traceIds.length} trace(s) for "${result.traceFunctionKey}". Replay them with --trace-ids ${result.traceIds.slice(0, 3).join(",")}${result.traceIds.length > 3 ? ",..." : ""}`
|
|
181
202
|
);
|
|
182
203
|
stdout(JSON.stringify(result, null, 2));
|
|
183
204
|
return result;
|
|
@@ -534,7 +555,7 @@ async function runReplayCli(registry, argv = typeof process === "undefined" ? []
|
|
|
534
555
|
}
|
|
535
556
|
|
|
536
557
|
// src/replayCli.ts
|
|
537
|
-
var USAGE = "Usage: bitfab-replay --registry <path> <pipeline> [options]\n bitfab-replay --registry <path> <pipeline> --seed <cases.jsonl
|
|
558
|
+
var USAGE = "Usage: bitfab-replay --registry <path> <pipeline> [options]\n bitfab-replay --registry <path> <pipeline> --seed <cases.jsonl> [--run]\nRun bitfab-replay --registry <path> --help to list replay options.";
|
|
538
559
|
async function parseCommandArgs(argv) {
|
|
539
560
|
if (argv.some((value) => value === "--help" || value === "-h") && !argv.includes("--registry")) {
|
|
540
561
|
throw new ReplayCliHelp(USAGE);
|