@bitfab/sdk 0.54.6 → 0.54.7
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-2J7QZHRC.js → chunk-27WMHYUI.js} +2 -2
- package/dist/{chunk-QEQXIG5A.js → chunk-JF56DBPP.js} +11 -2
- package/dist/{chunk-QEQXIG5A.js.map → chunk-JF56DBPP.js.map} +1 -1
- package/dist/{chunk-BXLEJW7C.js → chunk-O3XSV52U.js} +3 -3
- package/dist/{chunk-P3FTTOAG.js → chunk-OIIMVPTH.js} +11 -2
- package/dist/{chunk-P3FTTOAG.js.map → chunk-OIIMVPTH.js.map} +1 -1
- package/dist/{chunk-2ZUDLA5T.js → chunk-X6AIRJJX.js} +53 -20
- package/dist/chunk-X6AIRJJX.js.map +1 -0
- package/dist/{http-PJEFWDKR.js → http-I5VDJLSJ.js} +2 -2
- package/dist/{http-KLQ5KEUQ.js → http-RGNLMMZQ.js} +2 -2
- package/dist/index.cjs +57 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +3 -3
- package/dist/node.cjs +57 -15
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-YQQHMR5K.js → replay-KILXEBEG.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-2ZUDLA5T.js.map +0 -1
- /package/dist/{chunk-2J7QZHRC.js.map → chunk-27WMHYUI.js.map} +0 -0
- /package/dist/{chunk-BXLEJW7C.js.map → chunk-O3XSV52U.js.map} +0 -0
- /package/dist/{http-KLQ5KEUQ.js.map → http-I5VDJLSJ.js.map} +0 -0
- /package/dist/{http-PJEFWDKR.js.map → http-RGNLMMZQ.js.map} +0 -0
- /package/dist/{replay-YQQHMR5K.js.map → replay-KILXEBEG.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OIIMVPTH.js";
|
|
10
10
|
export {
|
|
11
11
|
BitfabError,
|
|
12
12
|
HttpClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
parseRetryAfterMs,
|
|
17
17
|
serializePayloadBody
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=http-
|
|
19
|
+
//# sourceMappingURL=http-I5VDJLSJ.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JF56DBPP.js";
|
|
10
10
|
import "./chunk-VCRFFCLY.js";
|
|
11
11
|
export {
|
|
12
12
|
BitfabError,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
parseRetryAfterMs,
|
|
18
18
|
serializePayloadBody
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=http-
|
|
20
|
+
//# sourceMappingURL=http-RGNLMMZQ.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var __version__, __packageName__;
|
|
|
42
42
|
var init_version_generated = __esm({
|
|
43
43
|
"src/version.generated.ts"() {
|
|
44
44
|
"use strict";
|
|
45
|
-
__version__ = "0.54.
|
|
45
|
+
__version__ = "0.54.7";
|
|
46
46
|
__packageName__ = "@bitfab/sdk";
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -2313,6 +2313,15 @@ var init_http = __esm({
|
|
|
2313
2313
|
resolveApiKey() {
|
|
2314
2314
|
return typeof this.apiKey === "function" ? this.apiKey() : this.apiKey;
|
|
2315
2315
|
}
|
|
2316
|
+
/** @internal Whether this client currently has credentials for trace delivery. */
|
|
2317
|
+
hasApiKey() {
|
|
2318
|
+
try {
|
|
2319
|
+
const apiKey = this.resolveApiKey();
|
|
2320
|
+
return apiKey !== void 0 && apiKey.trim() !== "";
|
|
2321
|
+
} catch {
|
|
2322
|
+
return false;
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2316
2325
|
/**
|
|
2317
2326
|
* This client's span transport, built on first use.
|
|
2318
2327
|
*
|
|
@@ -4490,6 +4499,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4490
4499
|
});
|
|
4491
4500
|
this.traceFunctionKey = config.traceFunctionKey;
|
|
4492
4501
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
4502
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
4493
4503
|
this.preToolUseHook = this.preToolUseHook.bind(this);
|
|
4494
4504
|
this.postToolUseHook = this.postToolUseHook.bind(this);
|
|
4495
4505
|
this.postToolUseFailureHook = this.postToolUseFailureHook.bind(this);
|
|
@@ -4594,6 +4604,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4594
4604
|
this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
|
|
4595
4605
|
}
|
|
4596
4606
|
sendSpan(spanInfo) {
|
|
4607
|
+
if (!this.shouldRecord()) {
|
|
4608
|
+
return;
|
|
4609
|
+
}
|
|
4597
4610
|
const spanData = {
|
|
4598
4611
|
name: spanInfo.name,
|
|
4599
4612
|
type: spanInfo.type
|
|
@@ -4637,6 +4650,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4637
4650
|
}
|
|
4638
4651
|
}
|
|
4639
4652
|
sendTraceCompletion(endedAt, metadata) {
|
|
4653
|
+
if (!this.shouldRecord()) {
|
|
4654
|
+
return;
|
|
4655
|
+
}
|
|
4640
4656
|
if (this.traceId === null) {
|
|
4641
4657
|
return;
|
|
4642
4658
|
}
|
|
@@ -6178,6 +6194,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6178
6194
|
});
|
|
6179
6195
|
this.traceFunctionKey = config.traceFunctionKey;
|
|
6180
6196
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
6197
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
6181
6198
|
this.captureTools = config.captureTools ?? true;
|
|
6182
6199
|
}
|
|
6183
6200
|
/**
|
|
@@ -6286,6 +6303,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6286
6303
|
this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
|
|
6287
6304
|
}
|
|
6288
6305
|
sendSpan(spanInfo) {
|
|
6306
|
+
if (!this.shouldRecord()) {
|
|
6307
|
+
return;
|
|
6308
|
+
}
|
|
6289
6309
|
const spanData = {
|
|
6290
6310
|
name: spanInfo.name,
|
|
6291
6311
|
type: spanInfo.type
|
|
@@ -6329,6 +6349,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6329
6349
|
}
|
|
6330
6350
|
}
|
|
6331
6351
|
sendTraceCompletion(rootSpan, activeContext) {
|
|
6352
|
+
if (!this.shouldRecord()) {
|
|
6353
|
+
return;
|
|
6354
|
+
}
|
|
6332
6355
|
const completed = activeContext === null;
|
|
6333
6356
|
const traceData = {
|
|
6334
6357
|
id: rootSpan.traceId,
|
|
@@ -6349,6 +6372,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6349
6372
|
}
|
|
6350
6373
|
}
|
|
6351
6374
|
sendTraceStart(rootSpan) {
|
|
6375
|
+
if (!this.shouldRecord()) {
|
|
6376
|
+
return;
|
|
6377
|
+
}
|
|
6352
6378
|
const traceData = {
|
|
6353
6379
|
id: rootSpan.traceId,
|
|
6354
6380
|
type: "sdk-function",
|
|
@@ -7057,6 +7083,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7057
7083
|
timeout: config.timeout ?? 1e4
|
|
7058
7084
|
});
|
|
7059
7085
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
7086
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
7060
7087
|
}
|
|
7061
7088
|
getCanonicalTraceId(sourceTraceId) {
|
|
7062
7089
|
const existing = this.canonicalTraceIds[sourceTraceId];
|
|
@@ -7177,6 +7204,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7177
7204
|
* the OpenAI trace into an outer withSpan trace.
|
|
7178
7205
|
*/
|
|
7179
7206
|
sendTrace(trace, options = {}) {
|
|
7207
|
+
if (!this.shouldRecord()) {
|
|
7208
|
+
return;
|
|
7209
|
+
}
|
|
7180
7210
|
try {
|
|
7181
7211
|
const traceData = trace.toJSON();
|
|
7182
7212
|
if (options.sourceTraceId) {
|
|
@@ -7291,6 +7321,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7291
7321
|
* and parent_id are rewritten to link the span into the withSpan tree.
|
|
7292
7322
|
*/
|
|
7293
7323
|
sendSpan(span) {
|
|
7324
|
+
if (!this.shouldRecord()) {
|
|
7325
|
+
return;
|
|
7326
|
+
}
|
|
7294
7327
|
const errors = [];
|
|
7295
7328
|
const [serializedSpan, exportErrors] = this.exportSpan(span);
|
|
7296
7329
|
errors.push(...exportErrors);
|
|
@@ -8388,6 +8421,11 @@ var Bitfab = class {
|
|
|
8388
8421
|
}
|
|
8389
8422
|
return this.resolveApiKey() !== void 0;
|
|
8390
8423
|
}
|
|
8424
|
+
prepareFrameworkIntegration() {
|
|
8425
|
+
if (this.captureConfigured && this.strict) {
|
|
8426
|
+
this.resolveApiKey();
|
|
8427
|
+
}
|
|
8428
|
+
}
|
|
8391
8429
|
get captureEnabled() {
|
|
8392
8430
|
return this.isCaptureEnabled();
|
|
8393
8431
|
}
|
|
@@ -8445,14 +8483,16 @@ var Bitfab = class {
|
|
|
8445
8483
|
resultStr = String(executionResult.result);
|
|
8446
8484
|
}
|
|
8447
8485
|
}
|
|
8448
|
-
this.
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8486
|
+
if (this.shouldRecord()) {
|
|
8487
|
+
this.httpClient.sendInternalTrace(functionVersion.id, {
|
|
8488
|
+
result: resultStr,
|
|
8489
|
+
source: "typescript-sdk",
|
|
8490
|
+
...Object.keys(inputs).length > 0 && { inputs },
|
|
8491
|
+
...executionResult.rawCollector != null && {
|
|
8492
|
+
rawCollector: executionResult.rawCollector
|
|
8493
|
+
}
|
|
8494
|
+
});
|
|
8495
|
+
}
|
|
8456
8496
|
return executionResult.result;
|
|
8457
8497
|
} catch (error) {
|
|
8458
8498
|
if (error instanceof BitfabError) {
|
|
@@ -8482,11 +8522,10 @@ var Bitfab = class {
|
|
|
8482
8522
|
* @returns A BitfabOpenAITracingProcessor instance configured for this client
|
|
8483
8523
|
*/
|
|
8484
8524
|
getOpenAiTracingProcessor() {
|
|
8525
|
+
this.prepareFrameworkIntegration();
|
|
8485
8526
|
return new BitfabOpenAITracingProcessor({
|
|
8486
|
-
// Resolved at getter-call time (framework handlers are set up after env
|
|
8487
|
-
// loads); the withSpan path stays lazy via the constructor HttpClient thunk.
|
|
8488
|
-
apiKey: this.resolveApiKey(),
|
|
8489
8527
|
serviceUrl: this.serviceUrl,
|
|
8528
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8490
8529
|
getActiveSpanContext: () => {
|
|
8491
8530
|
const stack = getSpanStack();
|
|
8492
8531
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8544,10 +8583,11 @@ var Bitfab = class {
|
|
|
8544
8583
|
* @returns A BitfabLangGraphCallbackHandler configured for this client
|
|
8545
8584
|
*/
|
|
8546
8585
|
getLangGraphCallbackHandler(traceFunctionKey) {
|
|
8586
|
+
this.prepareFrameworkIntegration();
|
|
8547
8587
|
return new BitfabLangGraphCallbackHandler({
|
|
8548
|
-
apiKey: this.resolveApiKey(),
|
|
8549
8588
|
traceFunctionKey,
|
|
8550
8589
|
serviceUrl: this.serviceUrl,
|
|
8590
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8551
8591
|
getActiveSpanContext: () => {
|
|
8552
8592
|
const stack = getSpanStack();
|
|
8553
8593
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8586,10 +8626,11 @@ var Bitfab = class {
|
|
|
8586
8626
|
* @experimental This API may change before it is stable.
|
|
8587
8627
|
*/
|
|
8588
8628
|
getLangGraphIntegration(traceFunctionKey, options) {
|
|
8629
|
+
this.prepareFrameworkIntegration();
|
|
8589
8630
|
const callbackHandler = new BitfabLangGraphCallbackHandler({
|
|
8590
|
-
apiKey: this.resolveApiKey(),
|
|
8591
8631
|
traceFunctionKey,
|
|
8592
8632
|
serviceUrl: this.serviceUrl,
|
|
8633
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8593
8634
|
getActiveSpanContext: () => {
|
|
8594
8635
|
const stack = getSpanStack();
|
|
8595
8636
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8628,10 +8669,11 @@ var Bitfab = class {
|
|
|
8628
8669
|
* @returns A BitfabClaudeAgentHandler configured for this client
|
|
8629
8670
|
*/
|
|
8630
8671
|
getClaudeAgentHandler(traceFunctionKey) {
|
|
8672
|
+
this.prepareFrameworkIntegration();
|
|
8631
8673
|
return new BitfabClaudeAgentHandler({
|
|
8632
|
-
apiKey: this.resolveApiKey(),
|
|
8633
8674
|
traceFunctionKey,
|
|
8634
8675
|
serviceUrl: this.serviceUrl,
|
|
8676
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8635
8677
|
getActiveSpanContext: () => {
|
|
8636
8678
|
const stack = getSpanStack();
|
|
8637
8679
|
return stack[stack.length - 1] ?? null;
|