bitfab 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-WWE3W6HF.js → chunk-CRBJE655.js} +3 -3
- package/dist/{chunk-5FRFNRFA.js → chunk-GGMFD2ZE.js} +11 -2
- package/dist/{chunk-5FRFNRFA.js.map → chunk-GGMFD2ZE.js.map} +1 -1
- package/dist/{chunk-FCJHKGEE.js → chunk-MFMTLYDW.js} +53 -20
- package/dist/chunk-MFMTLYDW.js.map +1 -0
- package/dist/{chunk-EBDVWYCV.js → chunk-ONMN7WXS.js} +2 -2
- package/dist/{chunk-IKNIY7JV.js → chunk-VDQAIWLX.js} +11 -2
- package/dist/{chunk-IKNIY7JV.js.map → chunk-VDQAIWLX.js.map} +1 -1
- package/dist/{http-EMAHQQ4A.js → http-DYGY3K7H.js} +2 -2
- package/dist/{http-DRPXLTJS.js → http-NIVPIUA2.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-XG6LNUN4.js → replay-22RLT3Z4.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-FCJHKGEE.js.map +0 -1
- /package/dist/{chunk-WWE3W6HF.js.map → chunk-CRBJE655.js.map} +0 -0
- /package/dist/{chunk-EBDVWYCV.js.map → chunk-ONMN7WXS.js.map} +0 -0
- /package/dist/{http-DRPXLTJS.js.map → http-DYGY3K7H.js.map} +0 -0
- /package/dist/{http-EMAHQQ4A.js.map → http-NIVPIUA2.js.map} +0 -0
- /package/dist/{replay-XG6LNUN4.js.map → replay-22RLT3Z4.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GGMFD2ZE.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-DYGY3K7H.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VDQAIWLX.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-NIVPIUA2.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ var __version__, __packageName__;
|
|
|
51
51
|
var init_version_generated = __esm({
|
|
52
52
|
"src/version.generated.ts"() {
|
|
53
53
|
"use strict";
|
|
54
|
-
__version__ = "0.54.
|
|
54
|
+
__version__ = "0.54.7";
|
|
55
55
|
__packageName__ = "bitfab";
|
|
56
56
|
}
|
|
57
57
|
});
|
|
@@ -2322,6 +2322,15 @@ var init_http = __esm({
|
|
|
2322
2322
|
resolveApiKey() {
|
|
2323
2323
|
return typeof this.apiKey === "function" ? this.apiKey() : this.apiKey;
|
|
2324
2324
|
}
|
|
2325
|
+
/** @internal Whether this client currently has credentials for trace delivery. */
|
|
2326
|
+
hasApiKey() {
|
|
2327
|
+
try {
|
|
2328
|
+
const apiKey = this.resolveApiKey();
|
|
2329
|
+
return apiKey !== void 0 && apiKey.trim() !== "";
|
|
2330
|
+
} catch {
|
|
2331
|
+
return false;
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2325
2334
|
/**
|
|
2326
2335
|
* This client's span transport, built on first use.
|
|
2327
2336
|
*
|
|
@@ -4499,6 +4508,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4499
4508
|
});
|
|
4500
4509
|
this.traceFunctionKey = config.traceFunctionKey;
|
|
4501
4510
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
4511
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
4502
4512
|
this.preToolUseHook = this.preToolUseHook.bind(this);
|
|
4503
4513
|
this.postToolUseHook = this.postToolUseHook.bind(this);
|
|
4504
4514
|
this.postToolUseFailureHook = this.postToolUseFailureHook.bind(this);
|
|
@@ -4603,6 +4613,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4603
4613
|
this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
|
|
4604
4614
|
}
|
|
4605
4615
|
sendSpan(spanInfo) {
|
|
4616
|
+
if (!this.shouldRecord()) {
|
|
4617
|
+
return;
|
|
4618
|
+
}
|
|
4606
4619
|
const spanData = {
|
|
4607
4620
|
name: spanInfo.name,
|
|
4608
4621
|
type: spanInfo.type
|
|
@@ -4646,6 +4659,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4646
4659
|
}
|
|
4647
4660
|
}
|
|
4648
4661
|
sendTraceCompletion(endedAt, metadata) {
|
|
4662
|
+
if (!this.shouldRecord()) {
|
|
4663
|
+
return;
|
|
4664
|
+
}
|
|
4649
4665
|
if (this.traceId === null) {
|
|
4650
4666
|
return;
|
|
4651
4667
|
}
|
|
@@ -6187,6 +6203,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6187
6203
|
});
|
|
6188
6204
|
this.traceFunctionKey = config.traceFunctionKey;
|
|
6189
6205
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
6206
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
6190
6207
|
this.captureTools = config.captureTools ?? true;
|
|
6191
6208
|
}
|
|
6192
6209
|
/**
|
|
@@ -6295,6 +6312,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6295
6312
|
this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
|
|
6296
6313
|
}
|
|
6297
6314
|
sendSpan(spanInfo) {
|
|
6315
|
+
if (!this.shouldRecord()) {
|
|
6316
|
+
return;
|
|
6317
|
+
}
|
|
6298
6318
|
const spanData = {
|
|
6299
6319
|
name: spanInfo.name,
|
|
6300
6320
|
type: spanInfo.type
|
|
@@ -6338,6 +6358,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6338
6358
|
}
|
|
6339
6359
|
}
|
|
6340
6360
|
sendTraceCompletion(rootSpan, activeContext) {
|
|
6361
|
+
if (!this.shouldRecord()) {
|
|
6362
|
+
return;
|
|
6363
|
+
}
|
|
6341
6364
|
const completed = activeContext === null;
|
|
6342
6365
|
const traceData = {
|
|
6343
6366
|
id: rootSpan.traceId,
|
|
@@ -6358,6 +6381,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6358
6381
|
}
|
|
6359
6382
|
}
|
|
6360
6383
|
sendTraceStart(rootSpan) {
|
|
6384
|
+
if (!this.shouldRecord()) {
|
|
6385
|
+
return;
|
|
6386
|
+
}
|
|
6361
6387
|
const traceData = {
|
|
6362
6388
|
id: rootSpan.traceId,
|
|
6363
6389
|
type: "sdk-function",
|
|
@@ -7066,6 +7092,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7066
7092
|
timeout: config.timeout ?? 1e4
|
|
7067
7093
|
});
|
|
7068
7094
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
7095
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
7069
7096
|
}
|
|
7070
7097
|
getCanonicalTraceId(sourceTraceId) {
|
|
7071
7098
|
const existing = this.canonicalTraceIds[sourceTraceId];
|
|
@@ -7186,6 +7213,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7186
7213
|
* the OpenAI trace into an outer withSpan trace.
|
|
7187
7214
|
*/
|
|
7188
7215
|
sendTrace(trace, options = {}) {
|
|
7216
|
+
if (!this.shouldRecord()) {
|
|
7217
|
+
return;
|
|
7218
|
+
}
|
|
7189
7219
|
try {
|
|
7190
7220
|
const traceData = trace.toJSON();
|
|
7191
7221
|
if (options.sourceTraceId) {
|
|
@@ -7300,6 +7330,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7300
7330
|
* and parent_id are rewritten to link the span into the withSpan tree.
|
|
7301
7331
|
*/
|
|
7302
7332
|
sendSpan(span) {
|
|
7333
|
+
if (!this.shouldRecord()) {
|
|
7334
|
+
return;
|
|
7335
|
+
}
|
|
7303
7336
|
const errors = [];
|
|
7304
7337
|
const [serializedSpan, exportErrors] = this.exportSpan(span);
|
|
7305
7338
|
errors.push(...exportErrors);
|
|
@@ -8397,6 +8430,11 @@ var Bitfab = class {
|
|
|
8397
8430
|
}
|
|
8398
8431
|
return this.resolveApiKey() !== void 0;
|
|
8399
8432
|
}
|
|
8433
|
+
prepareFrameworkIntegration() {
|
|
8434
|
+
if (this.captureConfigured && this.strict) {
|
|
8435
|
+
this.resolveApiKey();
|
|
8436
|
+
}
|
|
8437
|
+
}
|
|
8400
8438
|
get captureEnabled() {
|
|
8401
8439
|
return this.isCaptureEnabled();
|
|
8402
8440
|
}
|
|
@@ -8454,14 +8492,16 @@ var Bitfab = class {
|
|
|
8454
8492
|
resultStr = String(executionResult.result);
|
|
8455
8493
|
}
|
|
8456
8494
|
}
|
|
8457
|
-
this.
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8495
|
+
if (this.shouldRecord()) {
|
|
8496
|
+
this.httpClient.sendInternalTrace(functionVersion.id, {
|
|
8497
|
+
result: resultStr,
|
|
8498
|
+
source: "typescript-sdk",
|
|
8499
|
+
...Object.keys(inputs).length > 0 && { inputs },
|
|
8500
|
+
...executionResult.rawCollector != null && {
|
|
8501
|
+
rawCollector: executionResult.rawCollector
|
|
8502
|
+
}
|
|
8503
|
+
});
|
|
8504
|
+
}
|
|
8465
8505
|
return executionResult.result;
|
|
8466
8506
|
} catch (error) {
|
|
8467
8507
|
if (error instanceof BitfabError) {
|
|
@@ -8491,11 +8531,10 @@ var Bitfab = class {
|
|
|
8491
8531
|
* @returns A BitfabOpenAITracingProcessor instance configured for this client
|
|
8492
8532
|
*/
|
|
8493
8533
|
getOpenAiTracingProcessor() {
|
|
8534
|
+
this.prepareFrameworkIntegration();
|
|
8494
8535
|
return new BitfabOpenAITracingProcessor({
|
|
8495
|
-
// Resolved at getter-call time (framework handlers are set up after env
|
|
8496
|
-
// loads); the withSpan path stays lazy via the constructor HttpClient thunk.
|
|
8497
|
-
apiKey: this.resolveApiKey(),
|
|
8498
8536
|
serviceUrl: this.serviceUrl,
|
|
8537
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8499
8538
|
getActiveSpanContext: () => {
|
|
8500
8539
|
const stack = getSpanStack();
|
|
8501
8540
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8553,10 +8592,11 @@ var Bitfab = class {
|
|
|
8553
8592
|
* @returns A BitfabLangGraphCallbackHandler configured for this client
|
|
8554
8593
|
*/
|
|
8555
8594
|
getLangGraphCallbackHandler(traceFunctionKey) {
|
|
8595
|
+
this.prepareFrameworkIntegration();
|
|
8556
8596
|
return new BitfabLangGraphCallbackHandler({
|
|
8557
|
-
apiKey: this.resolveApiKey(),
|
|
8558
8597
|
traceFunctionKey,
|
|
8559
8598
|
serviceUrl: this.serviceUrl,
|
|
8599
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8560
8600
|
getActiveSpanContext: () => {
|
|
8561
8601
|
const stack = getSpanStack();
|
|
8562
8602
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8595,10 +8635,11 @@ var Bitfab = class {
|
|
|
8595
8635
|
* @experimental This API may change before it is stable.
|
|
8596
8636
|
*/
|
|
8597
8637
|
getLangGraphIntegration(traceFunctionKey, options) {
|
|
8638
|
+
this.prepareFrameworkIntegration();
|
|
8598
8639
|
const callbackHandler = new BitfabLangGraphCallbackHandler({
|
|
8599
|
-
apiKey: this.resolveApiKey(),
|
|
8600
8640
|
traceFunctionKey,
|
|
8601
8641
|
serviceUrl: this.serviceUrl,
|
|
8642
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8602
8643
|
getActiveSpanContext: () => {
|
|
8603
8644
|
const stack = getSpanStack();
|
|
8604
8645
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8637,10 +8678,11 @@ var Bitfab = class {
|
|
|
8637
8678
|
* @returns A BitfabClaudeAgentHandler configured for this client
|
|
8638
8679
|
*/
|
|
8639
8680
|
getClaudeAgentHandler(traceFunctionKey) {
|
|
8681
|
+
this.prepareFrameworkIntegration();
|
|
8640
8682
|
return new BitfabClaudeAgentHandler({
|
|
8641
|
-
apiKey: this.resolveApiKey(),
|
|
8642
8683
|
traceFunctionKey,
|
|
8643
8684
|
serviceUrl: this.serviceUrl,
|
|
8685
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8644
8686
|
getActiveSpanContext: () => {
|
|
8645
8687
|
const stack = getSpanStack();
|
|
8646
8688
|
return stack[stack.length - 1] ?? null;
|