@bitfab/sdk 0.53.1 → 0.53.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.
- package/dist/{chunk-LIHAOYN5.js → chunk-6J5LDOLY.js} +2 -2
- package/dist/{chunk-I5IJASRB.js → chunk-DZVMVRI2.js} +2 -2
- package/dist/{chunk-I5IJASRB.js.map → chunk-DZVMVRI2.js.map} +1 -1
- package/dist/{chunk-OT3EG36L.js → chunk-T5MTBF4Q.js} +3 -3
- package/dist/{chunk-UWXRK2KJ.js → chunk-VRGVD6LA.js} +116 -41
- package/dist/chunk-VRGVD6LA.js.map +1 -0
- package/dist/{chunk-XPIB2WYS.js → chunk-W76KGDVL.js} +2 -2
- package/dist/{chunk-XPIB2WYS.js.map → chunk-W76KGDVL.js.map} +1 -1
- package/dist/{http-4ZQB3KK4.js → http-MXEESNBT.js} +2 -2
- package/dist/{http-IWUYUIPY.js → http-OG5FURDU.js} +2 -2
- package/dist/index.cjs +113 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -3
- package/dist/node.cjs +113 -36
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-2TY7F3UC.js → replay-USQSY73Q.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +2 -1
- package/dist/chunk-UWXRK2KJ.js.map +0 -1
- /package/dist/{chunk-LIHAOYN5.js.map → chunk-6J5LDOLY.js.map} +0 -0
- /package/dist/{chunk-OT3EG36L.js.map → chunk-T5MTBF4Q.js.map} +0 -0
- /package/dist/{http-4ZQB3KK4.js.map → http-MXEESNBT.js.map} +0 -0
- /package/dist/{http-IWUYUIPY.js.map → http-OG5FURDU.js.map} +0 -0
- /package/dist/{replay-2TY7F3UC.js.map → replay-USQSY73Q.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1069,9 +1069,9 @@ declare class BitfabClaudeAgentHandler {
|
|
|
1069
1069
|
* The span records the call parameters (the prompt/messages) as its input and a
|
|
1070
1070
|
* serializable summary (`{ text, toolCalls, usage, finishReason }`) as its
|
|
1071
1071
|
* output. Streaming is handled by passing the model's stream through a
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1072
|
+
* reader that accumulates text and usage as the caller consumes it. Parts,
|
|
1073
|
+
* upstream errors, and cancellation propagate to the caller unchanged; the
|
|
1074
|
+
* span finalizes on completion, error, or cancellation with partial output.
|
|
1075
1075
|
*
|
|
1076
1076
|
* The middleware is fully duck-typed (no static or dynamic `ai` import), so it
|
|
1077
1077
|
* adds no dependency and is browser-safe. It works with `ai` v5 and v6.
|
|
@@ -1112,6 +1112,7 @@ interface VercelGenerateResult {
|
|
|
1112
1112
|
/** Duck-typed subset of a single streaming part from `doStream`. */
|
|
1113
1113
|
interface VercelStreamPart {
|
|
1114
1114
|
type: string;
|
|
1115
|
+
error?: unknown;
|
|
1115
1116
|
delta?: string;
|
|
1116
1117
|
textDelta?: string;
|
|
1117
1118
|
toolCallId?: string;
|
|
@@ -3343,7 +3344,7 @@ interface CommitRef {
|
|
|
3343
3344
|
/**
|
|
3344
3345
|
* SDK version from package.json (injected at build time)
|
|
3345
3346
|
*/
|
|
3346
|
-
declare const __version__ = "0.53.
|
|
3347
|
+
declare const __version__ = "0.53.2";
|
|
3347
3348
|
|
|
3348
3349
|
/**
|
|
3349
3350
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -1069,9 +1069,9 @@ declare class BitfabClaudeAgentHandler {
|
|
|
1069
1069
|
* The span records the call parameters (the prompt/messages) as its input and a
|
|
1070
1070
|
* serializable summary (`{ text, toolCalls, usage, finishReason }`) as its
|
|
1071
1071
|
* output. Streaming is handled by passing the model's stream through a
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1072
|
+
* reader that accumulates text and usage as the caller consumes it. Parts,
|
|
1073
|
+
* upstream errors, and cancellation propagate to the caller unchanged; the
|
|
1074
|
+
* span finalizes on completion, error, or cancellation with partial output.
|
|
1075
1075
|
*
|
|
1076
1076
|
* The middleware is fully duck-typed (no static or dynamic `ai` import), so it
|
|
1077
1077
|
* adds no dependency and is browser-safe. It works with `ai` v5 and v6.
|
|
@@ -1112,6 +1112,7 @@ interface VercelGenerateResult {
|
|
|
1112
1112
|
/** Duck-typed subset of a single streaming part from `doStream`. */
|
|
1113
1113
|
interface VercelStreamPart {
|
|
1114
1114
|
type: string;
|
|
1115
|
+
error?: unknown;
|
|
1115
1116
|
delta?: string;
|
|
1116
1117
|
textDelta?: string;
|
|
1117
1118
|
toolCallId?: string;
|
|
@@ -3343,7 +3344,7 @@ interface CommitRef {
|
|
|
3343
3344
|
/**
|
|
3344
3345
|
* SDK version from package.json (injected at build time)
|
|
3345
3346
|
*/
|
|
3346
|
-
declare const __version__ = "0.53.
|
|
3347
|
+
declare const __version__ = "0.53.2";
|
|
3347
3348
|
|
|
3348
3349
|
/**
|
|
3349
3350
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
getCurrentTrace,
|
|
20
20
|
reseedFromRegistry,
|
|
21
21
|
seedFromRegistry
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-VRGVD6LA.js";
|
|
23
23
|
import "./chunk-E5BLYL5X.js";
|
|
24
24
|
import {
|
|
25
25
|
BITFAB_PROGRESS_PREFIX,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
ReplayError,
|
|
29
29
|
reportReplayProgress,
|
|
30
30
|
serializeReplayResult
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-6J5LDOLY.js";
|
|
32
32
|
import {
|
|
33
33
|
BitfabError,
|
|
34
34
|
DEFAULT_SERVICE_URL,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
MixedTracingError,
|
|
37
37
|
__version__,
|
|
38
38
|
flushTraces
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-W76KGDVL.js";
|
|
40
40
|
import "./chunk-H6LZRFMN.js";
|
|
41
41
|
export {
|
|
42
42
|
BITFAB_PROGRESS_PREFIX,
|
package/dist/node.cjs
CHANGED
|
@@ -88,7 +88,7 @@ var __version__, __packageName__;
|
|
|
88
88
|
var init_version_generated = __esm({
|
|
89
89
|
"src/version.generated.ts"() {
|
|
90
90
|
"use strict";
|
|
91
|
-
__version__ = "0.53.
|
|
91
|
+
__version__ = "0.53.2";
|
|
92
92
|
__packageName__ = "@bitfab/sdk";
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -6724,6 +6724,17 @@ function runWithSeedContext(ctx, fn) {
|
|
|
6724
6724
|
init_serialize();
|
|
6725
6725
|
init_simulationPlan();
|
|
6726
6726
|
init_spanOrigin();
|
|
6727
|
+
|
|
6728
|
+
// src/streamFinalizationError.ts
|
|
6729
|
+
var StreamFinalizationError = class extends Error {
|
|
6730
|
+
constructor(message, output) {
|
|
6731
|
+
super(message);
|
|
6732
|
+
this.output = output;
|
|
6733
|
+
this.name = "StreamFinalizationError";
|
|
6734
|
+
}
|
|
6735
|
+
};
|
|
6736
|
+
|
|
6737
|
+
// src/client.ts
|
|
6727
6738
|
init_traceMetadata();
|
|
6728
6739
|
|
|
6729
6740
|
// src/tracing.ts
|
|
@@ -6997,52 +7008,110 @@ function summarizeGenerate(result, model) {
|
|
|
6997
7008
|
}
|
|
6998
7009
|
return summary;
|
|
6999
7010
|
}
|
|
7000
|
-
function accumulateStream(onComplete, model) {
|
|
7011
|
+
function accumulateStream(source, onComplete, model) {
|
|
7012
|
+
const reader = source.getReader();
|
|
7001
7013
|
let text = "";
|
|
7002
7014
|
const toolCalls = [];
|
|
7003
7015
|
let usage;
|
|
7004
7016
|
let finishReason;
|
|
7005
7017
|
let completed = false;
|
|
7006
|
-
|
|
7018
|
+
let streamFailure;
|
|
7019
|
+
const complete = (failure = streamFailure) => {
|
|
7007
7020
|
if (completed) {
|
|
7008
7021
|
return;
|
|
7009
7022
|
}
|
|
7010
7023
|
completed = true;
|
|
7011
|
-
|
|
7024
|
+
let error;
|
|
7025
|
+
if (failure !== void 0) {
|
|
7026
|
+
try {
|
|
7027
|
+
error = failure.error instanceof Error ? failure.error.message : String(
|
|
7028
|
+
failure.error ?? (failure.cancelled === true ? "Stream cancelled" : "Stream failed")
|
|
7029
|
+
);
|
|
7030
|
+
} catch {
|
|
7031
|
+
error = "Stream failed";
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
7034
|
+
onComplete({
|
|
7012
7035
|
text,
|
|
7013
7036
|
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
7014
7037
|
usage,
|
|
7015
|
-
finishReason
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
}
|
|
7020
|
-
onComplete(summary);
|
|
7038
|
+
finishReason,
|
|
7039
|
+
...model !== void 0 && { model },
|
|
7040
|
+
...failure !== void 0 && { error },
|
|
7041
|
+
...failure?.cancelled === true && { cancelled: true }
|
|
7042
|
+
});
|
|
7021
7043
|
};
|
|
7022
|
-
return new
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7044
|
+
return new ReadableStream(
|
|
7045
|
+
{
|
|
7046
|
+
start(controller) {
|
|
7047
|
+
void reader.closed.then(
|
|
7048
|
+
() => {
|
|
7049
|
+
queueMicrotask(() => {
|
|
7050
|
+
if (!completed) {
|
|
7051
|
+
complete();
|
|
7052
|
+
reader.releaseLock();
|
|
7053
|
+
controller.close();
|
|
7054
|
+
}
|
|
7055
|
+
});
|
|
7056
|
+
},
|
|
7057
|
+
(error) => {
|
|
7058
|
+
if (!completed) {
|
|
7059
|
+
complete({ error });
|
|
7060
|
+
controller.error(error);
|
|
7061
|
+
reader.releaseLock();
|
|
7062
|
+
}
|
|
7063
|
+
}
|
|
7064
|
+
);
|
|
7065
|
+
},
|
|
7066
|
+
async pull(controller) {
|
|
7067
|
+
try {
|
|
7068
|
+
const { done, value: part } = await reader.read();
|
|
7069
|
+
if (completed) {
|
|
7070
|
+
return;
|
|
7071
|
+
}
|
|
7072
|
+
if (done) {
|
|
7073
|
+
complete();
|
|
7074
|
+
reader.releaseLock();
|
|
7075
|
+
controller.close();
|
|
7076
|
+
return;
|
|
7077
|
+
}
|
|
7078
|
+
try {
|
|
7079
|
+
if (part?.type === "text-delta") {
|
|
7080
|
+
text += part.delta ?? part.textDelta ?? "";
|
|
7081
|
+
} else if (part?.type === "tool-call") {
|
|
7082
|
+
toolCalls.push({
|
|
7083
|
+
toolCallId: part.toolCallId,
|
|
7084
|
+
toolName: part.toolName,
|
|
7085
|
+
input: part.input ?? part.args
|
|
7086
|
+
});
|
|
7087
|
+
} else if (part?.type === "error") {
|
|
7088
|
+
streamFailure = { error: part.error };
|
|
7089
|
+
} else if (part?.type === "finish") {
|
|
7090
|
+
usage = part.usage;
|
|
7091
|
+
finishReason = part.finishReason;
|
|
7092
|
+
}
|
|
7093
|
+
} catch {
|
|
7094
|
+
}
|
|
7095
|
+
controller.enqueue(part);
|
|
7096
|
+
} catch (error) {
|
|
7097
|
+
if (!completed) {
|
|
7098
|
+
complete({ error });
|
|
7099
|
+
reader.releaseLock();
|
|
7100
|
+
controller.error(error);
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
},
|
|
7104
|
+
async cancel(reason) {
|
|
7105
|
+
complete({ error: reason, cancelled: true });
|
|
7106
|
+
try {
|
|
7107
|
+
await reader.cancel(reason);
|
|
7108
|
+
} finally {
|
|
7109
|
+
reader.releaseLock();
|
|
7037
7110
|
}
|
|
7038
|
-
} catch {
|
|
7039
7111
|
}
|
|
7040
|
-
controller.enqueue(part);
|
|
7041
7112
|
},
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
}
|
|
7045
|
-
});
|
|
7113
|
+
{ highWaterMark: 0 }
|
|
7114
|
+
);
|
|
7046
7115
|
}
|
|
7047
7116
|
var BitfabVercelAiHandler = class {
|
|
7048
7117
|
constructor(config) {
|
|
@@ -7083,14 +7152,22 @@ var BitfabVercelAiHandler = class {
|
|
|
7083
7152
|
// awaits the summary the accumulator resolves once the stream drains.
|
|
7084
7153
|
{
|
|
7085
7154
|
type: "llm",
|
|
7086
|
-
finalize: () =>
|
|
7155
|
+
finalize: async () => {
|
|
7156
|
+
const output = await summary;
|
|
7157
|
+
if (output.error !== void 0) {
|
|
7158
|
+
throw new StreamFinalizationError(output.error, output);
|
|
7159
|
+
}
|
|
7160
|
+
return output;
|
|
7161
|
+
},
|
|
7087
7162
|
surface: "inherit",
|
|
7088
7163
|
instrumentation: "vercel-ai"
|
|
7089
7164
|
},
|
|
7090
7165
|
async () => {
|
|
7091
7166
|
const result = await doStream();
|
|
7092
|
-
const stream =
|
|
7093
|
-
|
|
7167
|
+
const stream = accumulateStream(
|
|
7168
|
+
result.stream,
|
|
7169
|
+
resolveSummary,
|
|
7170
|
+
label
|
|
7094
7171
|
);
|
|
7095
7172
|
return { ...result, stream };
|
|
7096
7173
|
}
|
|
@@ -8585,8 +8662,8 @@ var Bitfab = class {
|
|
|
8585
8662
|
void self.httpClient.trackDeferred(
|
|
8586
8663
|
Promise.resolve().then(() => options.finalize(result)).then((output) => sendSpan({ result: output })).catch(
|
|
8587
8664
|
(error) => sendSpan({
|
|
8588
|
-
result: void 0,
|
|
8589
|
-
error: error instanceof Error ? `finalize failed: ${error.message}` : `finalize failed: ${String(error)}`
|
|
8665
|
+
result: error instanceof StreamFinalizationError ? error.output : void 0,
|
|
8666
|
+
error: error instanceof StreamFinalizationError ? error.message : error instanceof Error ? `finalize failed: ${error.message}` : `finalize failed: ${String(error)}`
|
|
8590
8667
|
})
|
|
8591
8668
|
)
|
|
8592
8669
|
);
|