bitfab 0.54.6 → 0.54.8
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/README.md +2 -1
- package/dist/{chunk-5FRFNRFA.js → chunk-5H3D7J4K.js} +11 -2
- package/dist/{chunk-5FRFNRFA.js.map → chunk-5H3D7J4K.js.map} +1 -1
- package/dist/{chunk-WWE3W6HF.js → chunk-5LXZGUKW.js} +3 -3
- package/dist/{chunk-IKNIY7JV.js → chunk-RC3HOMLJ.js} +11 -2
- package/dist/{chunk-IKNIY7JV.js.map → chunk-RC3HOMLJ.js.map} +1 -1
- package/dist/{chunk-EBDVWYCV.js → chunk-RUCVJQBI.js} +2 -2
- package/dist/{chunk-FCJHKGEE.js → chunk-XPCVDQDS.js} +90 -24
- package/dist/chunk-XPCVDQDS.js.map +1 -0
- package/dist/{http-DRPXLTJS.js → http-4JG3XW5X.js} +2 -2
- package/dist/{http-EMAHQQ4A.js → http-7PL32JLX.js} +2 -2
- package/dist/index.cjs +94 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +3 -3
- package/dist/node.cjs +94 -19
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-XG6LNUN4.js → replay-KWBZ2JQV.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-5LXZGUKW.js.map} +0 -0
- /package/dist/{chunk-EBDVWYCV.js.map → chunk-RUCVJQBI.js.map} +0 -0
- /package/dist/{http-DRPXLTJS.js.map → http-4JG3XW5X.js.map} +0 -0
- /package/dist/{http-EMAHQQ4A.js.map → http-7PL32JLX.js.map} +0 -0
- /package/dist/{replay-XG6LNUN4.js.map → replay-KWBZ2JQV.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -426,6 +426,8 @@ declare class HttpClient {
|
|
|
426
426
|
* the function form if one was supplied. Never read at construction.
|
|
427
427
|
*/
|
|
428
428
|
private resolveApiKey;
|
|
429
|
+
/** @internal Whether this client currently has credentials for trace delivery. */
|
|
430
|
+
hasApiKey(): boolean;
|
|
429
431
|
/**
|
|
430
432
|
* This client's span transport, built on first use.
|
|
431
433
|
*
|
|
@@ -917,6 +919,7 @@ declare class BitfabClaudeAgentHandler {
|
|
|
917
919
|
private readonly ownsHttpClient;
|
|
918
920
|
private readonly traceFunctionKey;
|
|
919
921
|
private readonly getActiveSpanContext;
|
|
922
|
+
private readonly shouldRecord;
|
|
920
923
|
private runToSpan;
|
|
921
924
|
private traceId;
|
|
922
925
|
private rootSpanId;
|
|
@@ -941,6 +944,7 @@ declare class BitfabClaudeAgentHandler {
|
|
|
941
944
|
serviceUrl?: string;
|
|
942
945
|
timeout?: number;
|
|
943
946
|
getActiveSpanContext?: () => ActiveSpanContext$2 | null;
|
|
947
|
+
shouldRecord?: () => boolean;
|
|
944
948
|
/**
|
|
945
949
|
* The owning `Bitfab` client's HTTP client. Supplied by
|
|
946
950
|
* `getClaudeAgentHandler()` so this handler shares that client's single
|
|
@@ -1412,6 +1416,7 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
1412
1416
|
private readonly ownsHttpClient;
|
|
1413
1417
|
private readonly traceFunctionKey;
|
|
1414
1418
|
private readonly getActiveSpanContext;
|
|
1419
|
+
private readonly shouldRecord;
|
|
1415
1420
|
private readonly captureTools;
|
|
1416
1421
|
private runToSpan;
|
|
1417
1422
|
private invocations;
|
|
@@ -1421,6 +1426,7 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
1421
1426
|
serviceUrl?: string;
|
|
1422
1427
|
timeout?: number;
|
|
1423
1428
|
getActiveSpanContext?: () => ActiveSpanContext$1 | null;
|
|
1429
|
+
shouldRecord?: () => boolean;
|
|
1424
1430
|
/** Whether callback tool events should emit spans. Defaults to true. */
|
|
1425
1431
|
captureTools?: boolean;
|
|
1426
1432
|
/**
|
|
@@ -2322,6 +2328,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
|
|
|
2322
2328
|
private readonly ownsHttpClient;
|
|
2323
2329
|
private activeTraces;
|
|
2324
2330
|
private readonly getActiveSpanContext;
|
|
2331
|
+
private readonly shouldRecord;
|
|
2325
2332
|
private activeSpanMappings;
|
|
2326
2333
|
private canonicalTraceIds;
|
|
2327
2334
|
private getCanonicalTraceId;
|
|
@@ -2335,6 +2342,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
|
|
|
2335
2342
|
serviceUrl?: string;
|
|
2336
2343
|
timeout?: number;
|
|
2337
2344
|
getActiveSpanContext?: () => ActiveSpanContext | null;
|
|
2345
|
+
shouldRecord?: () => boolean;
|
|
2338
2346
|
/**
|
|
2339
2347
|
* The owning `Bitfab` client's HTTP client. Supplied by
|
|
2340
2348
|
* `getOpenAiTracingProcessor()` so this processor shares that client's
|
|
@@ -2755,7 +2763,8 @@ declare class Bitfab {
|
|
|
2755
2763
|
private readonly serviceUrl;
|
|
2756
2764
|
private readonly timeout;
|
|
2757
2765
|
private readonly envVars;
|
|
2758
|
-
private readonly
|
|
2766
|
+
private readonly captureConfiguredInCode;
|
|
2767
|
+
private captureConfiguredFromEnv;
|
|
2759
2768
|
private readonly strict;
|
|
2760
2769
|
private readonly httpClient;
|
|
2761
2770
|
/** Dataset operations for the authenticated organization. */
|
|
@@ -2876,8 +2885,10 @@ declare class Bitfab {
|
|
|
2876
2885
|
* early resolve that found nothing never poisons a later one.
|
|
2877
2886
|
*/
|
|
2878
2887
|
private resolveApiKey;
|
|
2888
|
+
private isCaptureConfigured;
|
|
2879
2889
|
private isCaptureEnabled;
|
|
2880
2890
|
private shouldRecord;
|
|
2891
|
+
private prepareFrameworkIntegration;
|
|
2881
2892
|
get captureEnabled(): boolean;
|
|
2882
2893
|
/**
|
|
2883
2894
|
* Fetch the function with its current version and BAML prompt from the server.
|
|
@@ -3420,7 +3431,7 @@ interface CommitRef {
|
|
|
3420
3431
|
/**
|
|
3421
3432
|
* SDK version from package.json (injected at build time)
|
|
3422
3433
|
*/
|
|
3423
|
-
declare const __version__ = "0.54.
|
|
3434
|
+
declare const __version__ = "0.54.8";
|
|
3424
3435
|
|
|
3425
3436
|
/**
|
|
3426
3437
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -426,6 +426,8 @@ declare class HttpClient {
|
|
|
426
426
|
* the function form if one was supplied. Never read at construction.
|
|
427
427
|
*/
|
|
428
428
|
private resolveApiKey;
|
|
429
|
+
/** @internal Whether this client currently has credentials for trace delivery. */
|
|
430
|
+
hasApiKey(): boolean;
|
|
429
431
|
/**
|
|
430
432
|
* This client's span transport, built on first use.
|
|
431
433
|
*
|
|
@@ -917,6 +919,7 @@ declare class BitfabClaudeAgentHandler {
|
|
|
917
919
|
private readonly ownsHttpClient;
|
|
918
920
|
private readonly traceFunctionKey;
|
|
919
921
|
private readonly getActiveSpanContext;
|
|
922
|
+
private readonly shouldRecord;
|
|
920
923
|
private runToSpan;
|
|
921
924
|
private traceId;
|
|
922
925
|
private rootSpanId;
|
|
@@ -941,6 +944,7 @@ declare class BitfabClaudeAgentHandler {
|
|
|
941
944
|
serviceUrl?: string;
|
|
942
945
|
timeout?: number;
|
|
943
946
|
getActiveSpanContext?: () => ActiveSpanContext$2 | null;
|
|
947
|
+
shouldRecord?: () => boolean;
|
|
944
948
|
/**
|
|
945
949
|
* The owning `Bitfab` client's HTTP client. Supplied by
|
|
946
950
|
* `getClaudeAgentHandler()` so this handler shares that client's single
|
|
@@ -1412,6 +1416,7 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
1412
1416
|
private readonly ownsHttpClient;
|
|
1413
1417
|
private readonly traceFunctionKey;
|
|
1414
1418
|
private readonly getActiveSpanContext;
|
|
1419
|
+
private readonly shouldRecord;
|
|
1415
1420
|
private readonly captureTools;
|
|
1416
1421
|
private runToSpan;
|
|
1417
1422
|
private invocations;
|
|
@@ -1421,6 +1426,7 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
1421
1426
|
serviceUrl?: string;
|
|
1422
1427
|
timeout?: number;
|
|
1423
1428
|
getActiveSpanContext?: () => ActiveSpanContext$1 | null;
|
|
1429
|
+
shouldRecord?: () => boolean;
|
|
1424
1430
|
/** Whether callback tool events should emit spans. Defaults to true. */
|
|
1425
1431
|
captureTools?: boolean;
|
|
1426
1432
|
/**
|
|
@@ -2322,6 +2328,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
|
|
|
2322
2328
|
private readonly ownsHttpClient;
|
|
2323
2329
|
private activeTraces;
|
|
2324
2330
|
private readonly getActiveSpanContext;
|
|
2331
|
+
private readonly shouldRecord;
|
|
2325
2332
|
private activeSpanMappings;
|
|
2326
2333
|
private canonicalTraceIds;
|
|
2327
2334
|
private getCanonicalTraceId;
|
|
@@ -2335,6 +2342,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
|
|
|
2335
2342
|
serviceUrl?: string;
|
|
2336
2343
|
timeout?: number;
|
|
2337
2344
|
getActiveSpanContext?: () => ActiveSpanContext | null;
|
|
2345
|
+
shouldRecord?: () => boolean;
|
|
2338
2346
|
/**
|
|
2339
2347
|
* The owning `Bitfab` client's HTTP client. Supplied by
|
|
2340
2348
|
* `getOpenAiTracingProcessor()` so this processor shares that client's
|
|
@@ -2755,7 +2763,8 @@ declare class Bitfab {
|
|
|
2755
2763
|
private readonly serviceUrl;
|
|
2756
2764
|
private readonly timeout;
|
|
2757
2765
|
private readonly envVars;
|
|
2758
|
-
private readonly
|
|
2766
|
+
private readonly captureConfiguredInCode;
|
|
2767
|
+
private captureConfiguredFromEnv;
|
|
2759
2768
|
private readonly strict;
|
|
2760
2769
|
private readonly httpClient;
|
|
2761
2770
|
/** Dataset operations for the authenticated organization. */
|
|
@@ -2876,8 +2885,10 @@ declare class Bitfab {
|
|
|
2876
2885
|
* early resolve that found nothing never poisons a later one.
|
|
2877
2886
|
*/
|
|
2878
2887
|
private resolveApiKey;
|
|
2888
|
+
private isCaptureConfigured;
|
|
2879
2889
|
private isCaptureEnabled;
|
|
2880
2890
|
private shouldRecord;
|
|
2891
|
+
private prepareFrameworkIntegration;
|
|
2881
2892
|
get captureEnabled(): boolean;
|
|
2882
2893
|
/**
|
|
2883
2894
|
* Fetch the function with its current version and BAML prompt from the server.
|
|
@@ -3420,7 +3431,7 @@ interface CommitRef {
|
|
|
3420
3431
|
/**
|
|
3421
3432
|
* SDK version from package.json (injected at build time)
|
|
3422
3433
|
*/
|
|
3423
|
-
declare const __version__ = "0.54.
|
|
3434
|
+
declare const __version__ = "0.54.8";
|
|
3424
3435
|
|
|
3425
3436
|
/**
|
|
3426
3437
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
getCurrentTrace,
|
|
30
30
|
reseedFromRegistry,
|
|
31
31
|
seedFromRegistry
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-XPCVDQDS.js";
|
|
33
33
|
import "./chunk-EGWJYCNT.js";
|
|
34
34
|
import {
|
|
35
35
|
BITFAB_PROGRESS_PREFIX,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
ReplayError,
|
|
39
39
|
reportReplayProgress,
|
|
40
40
|
serializeReplayResult
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-RUCVJQBI.js";
|
|
42
42
|
import {
|
|
43
43
|
BitfabError,
|
|
44
44
|
DEFAULT_SERVICE_URL,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
MixedTracingError,
|
|
47
47
|
__version__,
|
|
48
48
|
flushTraces
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-5H3D7J4K.js";
|
|
50
50
|
import "./chunk-VCRFFCLY.js";
|
|
51
51
|
export {
|
|
52
52
|
AssertionCategoriesClient,
|
package/dist/node.cjs
CHANGED
|
@@ -97,7 +97,7 @@ var __version__, __packageName__;
|
|
|
97
97
|
var init_version_generated = __esm({
|
|
98
98
|
"src/version.generated.ts"() {
|
|
99
99
|
"use strict";
|
|
100
|
-
__version__ = "0.54.
|
|
100
|
+
__version__ = "0.54.8";
|
|
101
101
|
__packageName__ = "bitfab";
|
|
102
102
|
}
|
|
103
103
|
});
|
|
@@ -2329,6 +2329,15 @@ var init_http = __esm({
|
|
|
2329
2329
|
resolveApiKey() {
|
|
2330
2330
|
return typeof this.apiKey === "function" ? this.apiKey() : this.apiKey;
|
|
2331
2331
|
}
|
|
2332
|
+
/** @internal Whether this client currently has credentials for trace delivery. */
|
|
2333
|
+
hasApiKey() {
|
|
2334
|
+
try {
|
|
2335
|
+
const apiKey = this.resolveApiKey();
|
|
2336
|
+
return apiKey !== void 0 && apiKey.trim() !== "";
|
|
2337
|
+
} catch {
|
|
2338
|
+
return false;
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2332
2341
|
/**
|
|
2333
2342
|
* This client's span transport, built on first use.
|
|
2334
2343
|
*
|
|
@@ -4513,6 +4522,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4513
4522
|
});
|
|
4514
4523
|
this.traceFunctionKey = config.traceFunctionKey;
|
|
4515
4524
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
4525
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
4516
4526
|
this.preToolUseHook = this.preToolUseHook.bind(this);
|
|
4517
4527
|
this.postToolUseHook = this.postToolUseHook.bind(this);
|
|
4518
4528
|
this.postToolUseFailureHook = this.postToolUseFailureHook.bind(this);
|
|
@@ -4617,6 +4627,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4617
4627
|
this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
|
|
4618
4628
|
}
|
|
4619
4629
|
sendSpan(spanInfo) {
|
|
4630
|
+
if (!this.shouldRecord()) {
|
|
4631
|
+
return;
|
|
4632
|
+
}
|
|
4620
4633
|
const spanData = {
|
|
4621
4634
|
name: spanInfo.name,
|
|
4622
4635
|
type: spanInfo.type
|
|
@@ -4660,6 +4673,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4660
4673
|
}
|
|
4661
4674
|
}
|
|
4662
4675
|
sendTraceCompletion(endedAt, metadata) {
|
|
4676
|
+
if (!this.shouldRecord()) {
|
|
4677
|
+
return;
|
|
4678
|
+
}
|
|
4663
4679
|
if (this.traceId === null) {
|
|
4664
4680
|
return;
|
|
4665
4681
|
}
|
|
@@ -6201,6 +6217,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6201
6217
|
});
|
|
6202
6218
|
this.traceFunctionKey = config.traceFunctionKey;
|
|
6203
6219
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
6220
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
6204
6221
|
this.captureTools = config.captureTools ?? true;
|
|
6205
6222
|
}
|
|
6206
6223
|
/**
|
|
@@ -6309,6 +6326,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6309
6326
|
this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
|
|
6310
6327
|
}
|
|
6311
6328
|
sendSpan(spanInfo) {
|
|
6329
|
+
if (!this.shouldRecord()) {
|
|
6330
|
+
return;
|
|
6331
|
+
}
|
|
6312
6332
|
const spanData = {
|
|
6313
6333
|
name: spanInfo.name,
|
|
6314
6334
|
type: spanInfo.type
|
|
@@ -6352,6 +6372,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6352
6372
|
}
|
|
6353
6373
|
}
|
|
6354
6374
|
sendTraceCompletion(rootSpan, activeContext) {
|
|
6375
|
+
if (!this.shouldRecord()) {
|
|
6376
|
+
return;
|
|
6377
|
+
}
|
|
6355
6378
|
const completed = activeContext === null;
|
|
6356
6379
|
const traceData = {
|
|
6357
6380
|
id: rootSpan.traceId,
|
|
@@ -6372,6 +6395,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6372
6395
|
}
|
|
6373
6396
|
}
|
|
6374
6397
|
sendTraceStart(rootSpan) {
|
|
6398
|
+
if (!this.shouldRecord()) {
|
|
6399
|
+
return;
|
|
6400
|
+
}
|
|
6375
6401
|
const traceData = {
|
|
6376
6402
|
id: rootSpan.traceId,
|
|
6377
6403
|
type: "sdk-function",
|
|
@@ -7080,6 +7106,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7080
7106
|
timeout: config.timeout ?? 1e4
|
|
7081
7107
|
});
|
|
7082
7108
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
7109
|
+
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
7083
7110
|
}
|
|
7084
7111
|
getCanonicalTraceId(sourceTraceId) {
|
|
7085
7112
|
const existing = this.canonicalTraceIds[sourceTraceId];
|
|
@@ -7200,6 +7227,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7200
7227
|
* the OpenAI trace into an outer withSpan trace.
|
|
7201
7228
|
*/
|
|
7202
7229
|
sendTrace(trace, options = {}) {
|
|
7230
|
+
if (!this.shouldRecord()) {
|
|
7231
|
+
return;
|
|
7232
|
+
}
|
|
7203
7233
|
try {
|
|
7204
7234
|
const traceData = trace.toJSON();
|
|
7205
7235
|
if (options.sourceTraceId) {
|
|
@@ -7314,6 +7344,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7314
7344
|
* and parent_id are rewritten to link the span into the withSpan tree.
|
|
7315
7345
|
*/
|
|
7316
7346
|
sendSpan(span) {
|
|
7347
|
+
if (!this.shouldRecord()) {
|
|
7348
|
+
return;
|
|
7349
|
+
}
|
|
7317
7350
|
const errors = [];
|
|
7318
7351
|
const [serializedSpan, exportErrors] = this.exportSpan(span);
|
|
7319
7352
|
errors.push(...exportErrors);
|
|
@@ -7883,6 +7916,30 @@ function readEnv2(name) {
|
|
|
7883
7916
|
}
|
|
7884
7917
|
return void 0;
|
|
7885
7918
|
}
|
|
7919
|
+
var CAPTURE_ENABLED_ENV = "BITFAB_CAPTURE_ENABLED";
|
|
7920
|
+
var TRUE_ENV_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes"]);
|
|
7921
|
+
var FALSE_ENV_VALUES = /* @__PURE__ */ new Set(["0", "false", "no"]);
|
|
7922
|
+
function readBooleanEnv(name) {
|
|
7923
|
+
const raw = readEnv2(name);
|
|
7924
|
+
if (raw === void 0) {
|
|
7925
|
+
return void 0;
|
|
7926
|
+
}
|
|
7927
|
+
const value = raw.trim().toLowerCase();
|
|
7928
|
+
if (value === "") {
|
|
7929
|
+
return void 0;
|
|
7930
|
+
}
|
|
7931
|
+
if (TRUE_ENV_VALUES.has(value)) {
|
|
7932
|
+
return true;
|
|
7933
|
+
}
|
|
7934
|
+
if (FALSE_ENV_VALUES.has(value)) {
|
|
7935
|
+
return false;
|
|
7936
|
+
}
|
|
7937
|
+
warnOnce(
|
|
7938
|
+
`unrecognized-boolean-env:${name}`,
|
|
7939
|
+
`${name}="${raw}" is not 0 or 1; ignoring it.`
|
|
7940
|
+
);
|
|
7941
|
+
return void 0;
|
|
7942
|
+
}
|
|
7886
7943
|
var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
|
|
7887
7944
|
var DEFAULT_AUTO_TRACE_MAX_SPANS = 500;
|
|
7888
7945
|
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
@@ -7937,7 +7994,7 @@ var Bitfab = class {
|
|
|
7937
7994
|
"Bitfab({ enabled }) is deprecated; pass captureEnabled instead."
|
|
7938
7995
|
);
|
|
7939
7996
|
}
|
|
7940
|
-
this.
|
|
7997
|
+
this.captureConfiguredInCode = config.captureEnabled === void 0 && config.enabled === void 0 ? void 0 : (config.captureEnabled ?? true) && (config.enabled ?? true);
|
|
7941
7998
|
this.strict = config.strict ?? false;
|
|
7942
7999
|
this.bamlClient = config.bamlClient ?? null;
|
|
7943
8000
|
if (config.dbSnapshot) {
|
|
@@ -8391,7 +8448,7 @@ var Bitfab = class {
|
|
|
8391
8448
|
"Bitfab: no API key resolved. Set BITFAB_API_KEY or pass apiKey to new Bitfab(). If a script loads env with dotenv, load it before the module that constructs the client is imported (e.g. `node --env-file=.env script.ts`), or pass `apiKey: () => process.env.BITFAB_API_KEY`."
|
|
8392
8449
|
);
|
|
8393
8450
|
}
|
|
8394
|
-
if (this.
|
|
8451
|
+
if (this.isCaptureConfigured() && !this.apiKeyWarned) {
|
|
8395
8452
|
this.apiKeyWarned = true;
|
|
8396
8453
|
console.warn(
|
|
8397
8454
|
"Bitfab: apiKey is empty - tracing is disabled. Provide a valid API key to enable tracing."
|
|
@@ -8399,18 +8456,32 @@ var Bitfab = class {
|
|
|
8399
8456
|
}
|
|
8400
8457
|
return void 0;
|
|
8401
8458
|
}
|
|
8459
|
+
isCaptureConfigured() {
|
|
8460
|
+
if (this.captureConfiguredInCode !== void 0) {
|
|
8461
|
+
return this.captureConfiguredInCode;
|
|
8462
|
+
}
|
|
8463
|
+
if (this.captureConfiguredFromEnv === void 0) {
|
|
8464
|
+
this.captureConfiguredFromEnv = readBooleanEnv(CAPTURE_ENABLED_ENV) ?? true;
|
|
8465
|
+
}
|
|
8466
|
+
return this.captureConfiguredFromEnv;
|
|
8467
|
+
}
|
|
8402
8468
|
isCaptureEnabled() {
|
|
8403
|
-
if (!this.
|
|
8469
|
+
if (!this.isCaptureConfigured()) {
|
|
8404
8470
|
return false;
|
|
8405
8471
|
}
|
|
8406
8472
|
return this.resolveApiKey() !== void 0;
|
|
8407
8473
|
}
|
|
8408
8474
|
shouldRecord() {
|
|
8409
|
-
if (!this.
|
|
8475
|
+
if (!this.isCaptureConfigured() && !getReplayContext() && !inSeedScope()) {
|
|
8410
8476
|
return false;
|
|
8411
8477
|
}
|
|
8412
8478
|
return this.resolveApiKey() !== void 0;
|
|
8413
8479
|
}
|
|
8480
|
+
prepareFrameworkIntegration() {
|
|
8481
|
+
if (this.isCaptureConfigured() && this.strict) {
|
|
8482
|
+
this.resolveApiKey();
|
|
8483
|
+
}
|
|
8484
|
+
}
|
|
8414
8485
|
get captureEnabled() {
|
|
8415
8486
|
return this.isCaptureEnabled();
|
|
8416
8487
|
}
|
|
@@ -8468,14 +8539,16 @@ var Bitfab = class {
|
|
|
8468
8539
|
resultStr = String(executionResult.result);
|
|
8469
8540
|
}
|
|
8470
8541
|
}
|
|
8471
|
-
this.
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8542
|
+
if (this.shouldRecord()) {
|
|
8543
|
+
this.httpClient.sendInternalTrace(functionVersion.id, {
|
|
8544
|
+
result: resultStr,
|
|
8545
|
+
source: "typescript-sdk",
|
|
8546
|
+
...Object.keys(inputs).length > 0 && { inputs },
|
|
8547
|
+
...executionResult.rawCollector != null && {
|
|
8548
|
+
rawCollector: executionResult.rawCollector
|
|
8549
|
+
}
|
|
8550
|
+
});
|
|
8551
|
+
}
|
|
8479
8552
|
return executionResult.result;
|
|
8480
8553
|
} catch (error) {
|
|
8481
8554
|
if (error instanceof BitfabError) {
|
|
@@ -8505,11 +8578,10 @@ var Bitfab = class {
|
|
|
8505
8578
|
* @returns A BitfabOpenAITracingProcessor instance configured for this client
|
|
8506
8579
|
*/
|
|
8507
8580
|
getOpenAiTracingProcessor() {
|
|
8581
|
+
this.prepareFrameworkIntegration();
|
|
8508
8582
|
return new BitfabOpenAITracingProcessor({
|
|
8509
|
-
// Resolved at getter-call time (framework handlers are set up after env
|
|
8510
|
-
// loads); the withSpan path stays lazy via the constructor HttpClient thunk.
|
|
8511
|
-
apiKey: this.resolveApiKey(),
|
|
8512
8583
|
serviceUrl: this.serviceUrl,
|
|
8584
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8513
8585
|
getActiveSpanContext: () => {
|
|
8514
8586
|
const stack = getSpanStack();
|
|
8515
8587
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8567,10 +8639,11 @@ var Bitfab = class {
|
|
|
8567
8639
|
* @returns A BitfabLangGraphCallbackHandler configured for this client
|
|
8568
8640
|
*/
|
|
8569
8641
|
getLangGraphCallbackHandler(traceFunctionKey) {
|
|
8642
|
+
this.prepareFrameworkIntegration();
|
|
8570
8643
|
return new BitfabLangGraphCallbackHandler({
|
|
8571
|
-
apiKey: this.resolveApiKey(),
|
|
8572
8644
|
traceFunctionKey,
|
|
8573
8645
|
serviceUrl: this.serviceUrl,
|
|
8646
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8574
8647
|
getActiveSpanContext: () => {
|
|
8575
8648
|
const stack = getSpanStack();
|
|
8576
8649
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8609,10 +8682,11 @@ var Bitfab = class {
|
|
|
8609
8682
|
* @experimental This API may change before it is stable.
|
|
8610
8683
|
*/
|
|
8611
8684
|
getLangGraphIntegration(traceFunctionKey, options) {
|
|
8685
|
+
this.prepareFrameworkIntegration();
|
|
8612
8686
|
const callbackHandler = new BitfabLangGraphCallbackHandler({
|
|
8613
|
-
apiKey: this.resolveApiKey(),
|
|
8614
8687
|
traceFunctionKey,
|
|
8615
8688
|
serviceUrl: this.serviceUrl,
|
|
8689
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8616
8690
|
getActiveSpanContext: () => {
|
|
8617
8691
|
const stack = getSpanStack();
|
|
8618
8692
|
return stack[stack.length - 1] ?? null;
|
|
@@ -8651,10 +8725,11 @@ var Bitfab = class {
|
|
|
8651
8725
|
* @returns A BitfabClaudeAgentHandler configured for this client
|
|
8652
8726
|
*/
|
|
8653
8727
|
getClaudeAgentHandler(traceFunctionKey) {
|
|
8728
|
+
this.prepareFrameworkIntegration();
|
|
8654
8729
|
return new BitfabClaudeAgentHandler({
|
|
8655
|
-
apiKey: this.resolveApiKey(),
|
|
8656
8730
|
traceFunctionKey,
|
|
8657
8731
|
serviceUrl: this.serviceUrl,
|
|
8732
|
+
shouldRecord: () => this.shouldRecord(),
|
|
8658
8733
|
getActiveSpanContext: () => {
|
|
8659
8734
|
const stack = getSpanStack();
|
|
8660
8735
|
return stack[stack.length - 1] ?? null;
|