@bitfab/sdk 0.24.1 → 0.25.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-J4D6PRM4.js → chunk-GQLNEYSU.js} +3 -3
- package/dist/{chunk-J4D6PRM4.js.map → chunk-GQLNEYSU.js.map} +1 -1
- package/dist/index.cjs +25 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +1 -1
- package/dist/node.cjs +25 -4
- 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 +1 -1
- package/dist/{replay-NMQA7XY6.js → replay-KYGI6LJY.js} +25 -4
- package/dist/replay-KYGI6LJY.js.map +1 -0
- package/package.json +1 -1
- package/dist/replay-NMQA7XY6.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -651,6 +651,30 @@ interface ReplayOptions {
|
|
|
651
651
|
* Omit it to spread the recorded inputs unchanged.
|
|
652
652
|
*/
|
|
653
653
|
adaptInputs?: (inputs: unknown[], ctx: AdaptContext) => unknown[];
|
|
654
|
+
/**
|
|
655
|
+
* Called once per item as it finishes, in completion order (not input
|
|
656
|
+
* order), with running totals for the whole run. Use it to render replay
|
|
657
|
+
* progress, for example a terminal progress bar. Replay does not know
|
|
658
|
+
* pass/fail at this point (verdicts are assigned later), so the totals only
|
|
659
|
+
* distinguish items whose function ran (`succeeded`) from items that threw
|
|
660
|
+
* (`errored`).
|
|
661
|
+
*
|
|
662
|
+
* Invoked synchronously right after each item settles, so keep it cheap. A
|
|
663
|
+
* throwing callback never crashes the run: the error is swallowed so progress
|
|
664
|
+
* UI can't break replay.
|
|
665
|
+
*/
|
|
666
|
+
onProgress?: (progress: ReplayProgress) => void;
|
|
667
|
+
}
|
|
668
|
+
/** Running totals reported to {@link ReplayOptions.onProgress} as replay proceeds. */
|
|
669
|
+
interface ReplayProgress {
|
|
670
|
+
/** Items that have finished so far, whether they succeeded or errored. */
|
|
671
|
+
completed: number;
|
|
672
|
+
/** Total number of items in this replay run. */
|
|
673
|
+
total: number;
|
|
674
|
+
/** Of the completed items, how many ran the function without throwing. */
|
|
675
|
+
succeeded: number;
|
|
676
|
+
/** Of the completed items, how many threw (their `item.error` is set). */
|
|
677
|
+
errored: number;
|
|
654
678
|
}
|
|
655
679
|
/** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
|
|
656
680
|
interface AdaptContext {
|
|
@@ -1380,7 +1404,7 @@ declare class BitfabFunction {
|
|
|
1380
1404
|
/**
|
|
1381
1405
|
* SDK version from package.json (injected at build time)
|
|
1382
1406
|
*/
|
|
1383
|
-
declare const __version__ = "0.
|
|
1407
|
+
declare const __version__ = "0.25.0";
|
|
1384
1408
|
|
|
1385
1409
|
/**
|
|
1386
1410
|
* Constants for the Bitfab SDK.
|
|
@@ -1448,4 +1472,4 @@ declare const finalizers: {
|
|
|
1448
1472
|
readableStream: typeof readableStream;
|
|
1449
1473
|
};
|
|
1450
1474
|
|
|
1451
|
-
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 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 };
|
|
1475
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -651,6 +651,30 @@ interface ReplayOptions {
|
|
|
651
651
|
* Omit it to spread the recorded inputs unchanged.
|
|
652
652
|
*/
|
|
653
653
|
adaptInputs?: (inputs: unknown[], ctx: AdaptContext) => unknown[];
|
|
654
|
+
/**
|
|
655
|
+
* Called once per item as it finishes, in completion order (not input
|
|
656
|
+
* order), with running totals for the whole run. Use it to render replay
|
|
657
|
+
* progress, for example a terminal progress bar. Replay does not know
|
|
658
|
+
* pass/fail at this point (verdicts are assigned later), so the totals only
|
|
659
|
+
* distinguish items whose function ran (`succeeded`) from items that threw
|
|
660
|
+
* (`errored`).
|
|
661
|
+
*
|
|
662
|
+
* Invoked synchronously right after each item settles, so keep it cheap. A
|
|
663
|
+
* throwing callback never crashes the run: the error is swallowed so progress
|
|
664
|
+
* UI can't break replay.
|
|
665
|
+
*/
|
|
666
|
+
onProgress?: (progress: ReplayProgress) => void;
|
|
667
|
+
}
|
|
668
|
+
/** Running totals reported to {@link ReplayOptions.onProgress} as replay proceeds. */
|
|
669
|
+
interface ReplayProgress {
|
|
670
|
+
/** Items that have finished so far, whether they succeeded or errored. */
|
|
671
|
+
completed: number;
|
|
672
|
+
/** Total number of items in this replay run. */
|
|
673
|
+
total: number;
|
|
674
|
+
/** Of the completed items, how many ran the function without throwing. */
|
|
675
|
+
succeeded: number;
|
|
676
|
+
/** Of the completed items, how many threw (their `item.error` is set). */
|
|
677
|
+
errored: number;
|
|
654
678
|
}
|
|
655
679
|
/** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
|
|
656
680
|
interface AdaptContext {
|
|
@@ -1380,7 +1404,7 @@ declare class BitfabFunction {
|
|
|
1380
1404
|
/**
|
|
1381
1405
|
* SDK version from package.json (injected at build time)
|
|
1382
1406
|
*/
|
|
1383
|
-
declare const __version__ = "0.
|
|
1407
|
+
declare const __version__ = "0.25.0";
|
|
1384
1408
|
|
|
1385
1409
|
/**
|
|
1386
1410
|
* Constants for the Bitfab SDK.
|
|
@@ -1448,4 +1472,4 @@ declare const finalizers: {
|
|
|
1448
1472
|
readableStream: typeof readableStream;
|
|
1449
1473
|
};
|
|
1450
1474
|
|
|
1451
|
-
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 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 };
|
|
1475
|
+
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 };
|
package/dist/index.js
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -420,13 +420,15 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
420
420
|
dbSnapshotRef: serverItem.dbSnapshotRef ?? null
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
|
-
async function mapWithConcurrency(tasks, maxConcurrency) {
|
|
423
|
+
async function mapWithConcurrency(tasks, maxConcurrency, onSettled) {
|
|
424
424
|
const results = new Array(tasks.length);
|
|
425
425
|
let nextIndex = 0;
|
|
426
426
|
async function worker() {
|
|
427
427
|
while (nextIndex < tasks.length) {
|
|
428
428
|
const index = nextIndex++;
|
|
429
|
-
|
|
429
|
+
const result = await tasks[index]();
|
|
430
|
+
results[index] = result;
|
|
431
|
+
onSettled?.(result, index);
|
|
430
432
|
}
|
|
431
433
|
}
|
|
432
434
|
const workers = Array.from(
|
|
@@ -486,7 +488,26 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
486
488
|
options?.adaptInputs
|
|
487
489
|
)
|
|
488
490
|
);
|
|
489
|
-
const
|
|
491
|
+
const total = tasks.length;
|
|
492
|
+
let completed = 0;
|
|
493
|
+
let succeeded = 0;
|
|
494
|
+
let errored = 0;
|
|
495
|
+
const resultItems = await mapWithConcurrency(
|
|
496
|
+
tasks,
|
|
497
|
+
maxConcurrency,
|
|
498
|
+
options?.onProgress ? (item) => {
|
|
499
|
+
completed += 1;
|
|
500
|
+
if (item.error === null) {
|
|
501
|
+
succeeded += 1;
|
|
502
|
+
} else {
|
|
503
|
+
errored += 1;
|
|
504
|
+
}
|
|
505
|
+
try {
|
|
506
|
+
options?.onProgress?.({ completed, total, succeeded, errored });
|
|
507
|
+
} catch {
|
|
508
|
+
}
|
|
509
|
+
} : void 0
|
|
510
|
+
);
|
|
490
511
|
const completeResult = await httpClient.completeReplay(testRunId);
|
|
491
512
|
const serverTraceIds = completeResult.traceIds;
|
|
492
513
|
const replayTokens = completeResult.tokens;
|
|
@@ -580,7 +601,7 @@ registerAsyncLocalStorageClass(
|
|
|
580
601
|
);
|
|
581
602
|
|
|
582
603
|
// src/version.generated.ts
|
|
583
|
-
var __version__ = "0.
|
|
604
|
+
var __version__ = "0.25.0";
|
|
584
605
|
|
|
585
606
|
// src/constants.ts
|
|
586
607
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|