bitfab 0.26.2 → 0.27.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-DW7VTEO2.js → chunk-PFV4MPNS.js} +4 -4
- package/dist/{chunk-DW7VTEO2.js.map → chunk-PFV4MPNS.js.map} +1 -1
- package/dist/{replay-CORDD7TR.js → chunk-RNTDM6WM.js} +286 -10
- package/dist/chunk-RNTDM6WM.js.map +1 -0
- package/dist/index.cjs +41 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -6
- package/dist/index.d.ts +43 -6
- package/dist/index.js +8 -4
- package/dist/node.cjs +41 -6
- 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 +8 -4
- package/dist/node.js.map +1 -1
- package/dist/replay-66KNEAMO.js +11 -0
- package/dist/replay-66KNEAMO.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-IDGR2OIX.js +0 -263
- package/dist/chunk-IDGR2OIX.js.map +0 -1
- package/dist/replay-CORDD7TR.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -579,9 +579,9 @@ declare class ReplayEnvironment {
|
|
|
579
579
|
* Replay historical traces through a function and create a test run.
|
|
580
580
|
*
|
|
581
581
|
* The replay flow has three phases:
|
|
582
|
-
* 1. Start
|
|
583
|
-
* 2. Execute
|
|
584
|
-
* 3. Complete
|
|
582
|
+
* 1. Start: fetches historical traces from the server and creates a test run
|
|
583
|
+
* 2. Execute: re-runs each trace's inputs through the provided function locally
|
|
584
|
+
* 3. Complete: marks the test run as completed on the server
|
|
585
585
|
*/
|
|
586
586
|
|
|
587
587
|
type MockStrategy = "none" | "all" | "marked";
|
|
@@ -603,7 +603,7 @@ interface ReplayOptions {
|
|
|
603
603
|
codeChangeDescription?: string;
|
|
604
604
|
/**
|
|
605
605
|
* Files edited as part of this code change. Each entry holds the file path
|
|
606
|
-
* and the full `before`/`after` contents
|
|
606
|
+
* and the full `before`/`after` contents. The agent reads each file before
|
|
607
607
|
* and after editing and passes the two strings. Use `""` for newly created
|
|
608
608
|
* files (`before`) or deleted files (`after`).
|
|
609
609
|
*/
|
|
@@ -675,7 +675,44 @@ interface ReplayProgress {
|
|
|
675
675
|
succeeded: number;
|
|
676
676
|
/** Of the completed items, how many threw (their `item.error` is set). */
|
|
677
677
|
errored: number;
|
|
678
|
+
/**
|
|
679
|
+
* The single item that just settled to produce this event. `traceId` is the
|
|
680
|
+
* source (historical) trace that was replayed (so a UI can identify or link
|
|
681
|
+
* it); `error` is its replay error, or null when it ran ok; `durationMs` is how
|
|
682
|
+
* long this one trace took to replay. Lets a progress UI show per-trace
|
|
683
|
+
* pass/fail and timing as the run streams, without waiting for the full
|
|
684
|
+
* {@link ReplayResult}.
|
|
685
|
+
*/
|
|
686
|
+
item?: {
|
|
687
|
+
traceId: string | null;
|
|
688
|
+
error: string | null;
|
|
689
|
+
durationMs: number | null;
|
|
690
|
+
};
|
|
678
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* Wire prefix the Bitfab plugin scans for. Each line {@link reportReplayProgress}
|
|
694
|
+
* writes is this prefix followed by the JSON of the running totals (plus the
|
|
695
|
+
* settled `item`). The plugin polls these lines to report live progress while a
|
|
696
|
+
* replay runs in the background; keep the SDK emitter and the plugin parser in
|
|
697
|
+
* sync.
|
|
698
|
+
*/
|
|
699
|
+
declare const BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
|
|
700
|
+
/**
|
|
701
|
+
* A ready-made {@link ReplayOptions.onProgress} callback for replay scripts.
|
|
702
|
+
* Pass it straight in:
|
|
703
|
+
*
|
|
704
|
+
* ```ts
|
|
705
|
+
* await bitfab.replay("my-fn", fn, { limit, onProgress: reportReplayProgress })
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
708
|
+
* It writes one `@@bitfab:progress` line per trace to stderr, which the Bitfab
|
|
709
|
+
* plugin polls to report live progress while the replay runs in the background,
|
|
710
|
+
* so scripts never hand-format the wire protocol.
|
|
711
|
+
* stdout is left untouched for the ReplayResult JSON. Outside Node (no
|
|
712
|
+
* `process.stderr`, e.g. a browser) it is a no-op, and a write failure is
|
|
713
|
+
* swallowed so progress can never crash a run.
|
|
714
|
+
*/
|
|
715
|
+
declare function reportReplayProgress(progress: ReplayProgress): void;
|
|
679
716
|
/** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
|
|
680
717
|
interface AdaptContext {
|
|
681
718
|
/** Bitfab trace ID of the historical trace being replayed. */
|
|
@@ -1491,7 +1528,7 @@ declare class BitfabFunction {
|
|
|
1491
1528
|
/**
|
|
1492
1529
|
* SDK version from package.json (injected at build time)
|
|
1493
1530
|
*/
|
|
1494
|
-
declare const __version__ = "0.
|
|
1531
|
+
declare const __version__ = "0.27.0";
|
|
1495
1532
|
|
|
1496
1533
|
/**
|
|
1497
1534
|
* Constants for the Bitfab SDK.
|
|
@@ -1559,4 +1596,4 @@ declare const finalizers: {
|
|
|
1559
1596
|
readableStream: typeof readableStream;
|
|
1560
1597
|
};
|
|
1561
1598
|
|
|
1562
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace };
|
|
1599
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
package/dist/index.d.ts
CHANGED
|
@@ -579,9 +579,9 @@ declare class ReplayEnvironment {
|
|
|
579
579
|
* Replay historical traces through a function and create a test run.
|
|
580
580
|
*
|
|
581
581
|
* The replay flow has three phases:
|
|
582
|
-
* 1. Start
|
|
583
|
-
* 2. Execute
|
|
584
|
-
* 3. Complete
|
|
582
|
+
* 1. Start: fetches historical traces from the server and creates a test run
|
|
583
|
+
* 2. Execute: re-runs each trace's inputs through the provided function locally
|
|
584
|
+
* 3. Complete: marks the test run as completed on the server
|
|
585
585
|
*/
|
|
586
586
|
|
|
587
587
|
type MockStrategy = "none" | "all" | "marked";
|
|
@@ -603,7 +603,7 @@ interface ReplayOptions {
|
|
|
603
603
|
codeChangeDescription?: string;
|
|
604
604
|
/**
|
|
605
605
|
* Files edited as part of this code change. Each entry holds the file path
|
|
606
|
-
* and the full `before`/`after` contents
|
|
606
|
+
* and the full `before`/`after` contents. The agent reads each file before
|
|
607
607
|
* and after editing and passes the two strings. Use `""` for newly created
|
|
608
608
|
* files (`before`) or deleted files (`after`).
|
|
609
609
|
*/
|
|
@@ -675,7 +675,44 @@ interface ReplayProgress {
|
|
|
675
675
|
succeeded: number;
|
|
676
676
|
/** Of the completed items, how many threw (their `item.error` is set). */
|
|
677
677
|
errored: number;
|
|
678
|
+
/**
|
|
679
|
+
* The single item that just settled to produce this event. `traceId` is the
|
|
680
|
+
* source (historical) trace that was replayed (so a UI can identify or link
|
|
681
|
+
* it); `error` is its replay error, or null when it ran ok; `durationMs` is how
|
|
682
|
+
* long this one trace took to replay. Lets a progress UI show per-trace
|
|
683
|
+
* pass/fail and timing as the run streams, without waiting for the full
|
|
684
|
+
* {@link ReplayResult}.
|
|
685
|
+
*/
|
|
686
|
+
item?: {
|
|
687
|
+
traceId: string | null;
|
|
688
|
+
error: string | null;
|
|
689
|
+
durationMs: number | null;
|
|
690
|
+
};
|
|
678
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* Wire prefix the Bitfab plugin scans for. Each line {@link reportReplayProgress}
|
|
694
|
+
* writes is this prefix followed by the JSON of the running totals (plus the
|
|
695
|
+
* settled `item`). The plugin polls these lines to report live progress while a
|
|
696
|
+
* replay runs in the background; keep the SDK emitter and the plugin parser in
|
|
697
|
+
* sync.
|
|
698
|
+
*/
|
|
699
|
+
declare const BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
|
|
700
|
+
/**
|
|
701
|
+
* A ready-made {@link ReplayOptions.onProgress} callback for replay scripts.
|
|
702
|
+
* Pass it straight in:
|
|
703
|
+
*
|
|
704
|
+
* ```ts
|
|
705
|
+
* await bitfab.replay("my-fn", fn, { limit, onProgress: reportReplayProgress })
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
708
|
+
* It writes one `@@bitfab:progress` line per trace to stderr, which the Bitfab
|
|
709
|
+
* plugin polls to report live progress while the replay runs in the background,
|
|
710
|
+
* so scripts never hand-format the wire protocol.
|
|
711
|
+
* stdout is left untouched for the ReplayResult JSON. Outside Node (no
|
|
712
|
+
* `process.stderr`, e.g. a browser) it is a no-op, and a write failure is
|
|
713
|
+
* swallowed so progress can never crash a run.
|
|
714
|
+
*/
|
|
715
|
+
declare function reportReplayProgress(progress: ReplayProgress): void;
|
|
679
716
|
/** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
|
|
680
717
|
interface AdaptContext {
|
|
681
718
|
/** Bitfab trace ID of the historical trace being replayed. */
|
|
@@ -1491,7 +1528,7 @@ declare class BitfabFunction {
|
|
|
1491
1528
|
/**
|
|
1492
1529
|
* SDK version from package.json (injected at build time)
|
|
1493
1530
|
*/
|
|
1494
|
-
declare const __version__ = "0.
|
|
1531
|
+
declare const __version__ = "0.27.0";
|
|
1495
1532
|
|
|
1496
1533
|
/**
|
|
1497
1534
|
* Constants for the Bitfab SDK.
|
|
@@ -1559,4 +1596,4 @@ declare const finalizers: {
|
|
|
1559
1596
|
readableStream: typeof readableStream;
|
|
1560
1597
|
};
|
|
1561
1598
|
|
|
1562
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace };
|
|
1599
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
package/dist/index.js
CHANGED
|
@@ -23,11 +23,14 @@ import {
|
|
|
23
23
|
flushTraces,
|
|
24
24
|
getCurrentSpan,
|
|
25
25
|
getCurrentTrace
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-PFV4MPNS.js";
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
BITFAB_PROGRESS_PREFIX,
|
|
29
|
+
BitfabError,
|
|
30
|
+
reportReplayProgress
|
|
31
|
+
} from "./chunk-RNTDM6WM.js";
|
|
30
32
|
export {
|
|
33
|
+
BITFAB_PROGRESS_PREFIX,
|
|
31
34
|
Bitfab,
|
|
32
35
|
BitfabClaudeAgentHandler,
|
|
33
36
|
BitfabError,
|
|
@@ -44,6 +47,7 @@ export {
|
|
|
44
47
|
finalizers,
|
|
45
48
|
flushTraces,
|
|
46
49
|
getCurrentSpan,
|
|
47
|
-
getCurrentTrace
|
|
50
|
+
getCurrentTrace,
|
|
51
|
+
reportReplayProgress
|
|
48
52
|
};
|
|
49
53
|
//# sourceMappingURL=index.js.map
|
package/dist/node.cjs
CHANGED
|
@@ -323,8 +323,21 @@ var init_replayContext = __esm({
|
|
|
323
323
|
// src/replay.ts
|
|
324
324
|
var replay_exports = {};
|
|
325
325
|
__export(replay_exports, {
|
|
326
|
-
|
|
326
|
+
BITFAB_PROGRESS_PREFIX: () => BITFAB_PROGRESS_PREFIX,
|
|
327
|
+
replay: () => replay,
|
|
328
|
+
reportReplayProgress: () => reportReplayProgress
|
|
327
329
|
});
|
|
330
|
+
function reportReplayProgress(progress) {
|
|
331
|
+
const stderr = typeof process !== "undefined" ? process.stderr : void 0;
|
|
332
|
+
if (!stderr) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
try {
|
|
336
|
+
stderr.write(`${BITFAB_PROGRESS_PREFIX}${JSON.stringify(progress)}
|
|
337
|
+
`);
|
|
338
|
+
} catch {
|
|
339
|
+
}
|
|
340
|
+
}
|
|
328
341
|
function deserializeInputs(spanData) {
|
|
329
342
|
const inputMeta = spanData.input_meta;
|
|
330
343
|
const rawInput = spanData.input;
|
|
@@ -522,7 +535,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
522
535
|
const resultItems = await mapWithConcurrency(
|
|
523
536
|
tasks,
|
|
524
537
|
maxConcurrency,
|
|
525
|
-
options?.onProgress ? (item) => {
|
|
538
|
+
options?.onProgress ? (item, index) => {
|
|
526
539
|
completed += 1;
|
|
527
540
|
if (item.error === null) {
|
|
528
541
|
succeeded += 1;
|
|
@@ -530,7 +543,20 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
530
543
|
errored += 1;
|
|
531
544
|
}
|
|
532
545
|
try {
|
|
533
|
-
options?.onProgress?.({
|
|
546
|
+
options?.onProgress?.({
|
|
547
|
+
completed,
|
|
548
|
+
total,
|
|
549
|
+
succeeded,
|
|
550
|
+
errored,
|
|
551
|
+
item: {
|
|
552
|
+
// Source (historical) trace id, so a UI can identify the trace
|
|
553
|
+
// that just settled. The item's own traceId is the new replay
|
|
554
|
+
// trace and is assigned later (below), so use the server item.
|
|
555
|
+
traceId: serverItems[index]?.traceId ?? null,
|
|
556
|
+
error: item.error,
|
|
557
|
+
durationMs: item.durationMs
|
|
558
|
+
}
|
|
559
|
+
});
|
|
534
560
|
} catch {
|
|
535
561
|
}
|
|
536
562
|
} : void 0
|
|
@@ -587,6 +613,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
587
613
|
testRunUrl: `${serviceUrl}${testRunUrl}`
|
|
588
614
|
};
|
|
589
615
|
}
|
|
616
|
+
var BITFAB_PROGRESS_PREFIX;
|
|
590
617
|
var init_replay = __esm({
|
|
591
618
|
"src/replay.ts"() {
|
|
592
619
|
"use strict";
|
|
@@ -594,12 +621,14 @@ var init_replay = __esm({
|
|
|
594
621
|
init_randomUuid();
|
|
595
622
|
init_replayContext();
|
|
596
623
|
init_serialize();
|
|
624
|
+
BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
|
|
597
625
|
}
|
|
598
626
|
});
|
|
599
627
|
|
|
600
628
|
// src/node.ts
|
|
601
629
|
var node_exports = {};
|
|
602
630
|
__export(node_exports, {
|
|
631
|
+
BITFAB_PROGRESS_PREFIX: () => BITFAB_PROGRESS_PREFIX,
|
|
603
632
|
Bitfab: () => Bitfab,
|
|
604
633
|
BitfabClaudeAgentHandler: () => BitfabClaudeAgentHandler,
|
|
605
634
|
BitfabError: () => BitfabError,
|
|
@@ -616,7 +645,8 @@ __export(node_exports, {
|
|
|
616
645
|
finalizers: () => finalizers,
|
|
617
646
|
flushTraces: () => flushTraces,
|
|
618
647
|
getCurrentSpan: () => getCurrentSpan,
|
|
619
|
-
getCurrentTrace: () => getCurrentTrace
|
|
648
|
+
getCurrentTrace: () => getCurrentTrace,
|
|
649
|
+
reportReplayProgress: () => reportReplayProgress
|
|
620
650
|
});
|
|
621
651
|
module.exports = __toCommonJS(node_exports);
|
|
622
652
|
|
|
@@ -628,7 +658,7 @@ registerAsyncLocalStorageClass(
|
|
|
628
658
|
);
|
|
629
659
|
|
|
630
660
|
// src/version.generated.ts
|
|
631
|
-
var __version__ = "0.
|
|
661
|
+
var __version__ = "0.27.0";
|
|
632
662
|
|
|
633
663
|
// src/constants.ts
|
|
634
664
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -4370,11 +4400,15 @@ var finalizers = {
|
|
|
4370
4400
|
readableStream
|
|
4371
4401
|
};
|
|
4372
4402
|
|
|
4403
|
+
// src/index.ts
|
|
4404
|
+
init_replay();
|
|
4405
|
+
|
|
4373
4406
|
// src/node.ts
|
|
4374
4407
|
init_asyncStorage();
|
|
4375
4408
|
assertAsyncStorageRegistered();
|
|
4376
4409
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4377
4410
|
0 && (module.exports = {
|
|
4411
|
+
BITFAB_PROGRESS_PREFIX,
|
|
4378
4412
|
Bitfab,
|
|
4379
4413
|
BitfabClaudeAgentHandler,
|
|
4380
4414
|
BitfabError,
|
|
@@ -4391,6 +4425,7 @@ assertAsyncStorageRegistered();
|
|
|
4391
4425
|
finalizers,
|
|
4392
4426
|
flushTraces,
|
|
4393
4427
|
getCurrentSpan,
|
|
4394
|
-
getCurrentTrace
|
|
4428
|
+
getCurrentTrace,
|
|
4429
|
+
reportReplayProgress
|
|
4395
4430
|
});
|
|
4396
4431
|
//# sourceMappingURL=node.cjs.map
|