@bitfab/sdk 0.43.1 → 0.44.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-TNGKCPBP.js → chunk-3WIN3VU3.js} +2 -2
- package/dist/{chunk-5LY4XOUY.js → chunk-6JTVCM2L.js} +9 -2
- package/dist/chunk-6JTVCM2L.js.map +1 -0
- package/dist/{chunk-RBKGO5ZC.js → chunk-AX6EZPGH.js} +2 -2
- package/dist/chunk-AX6EZPGH.js.map +1 -0
- package/dist/{chunk-V4MRFSWK.js → chunk-XYMG2FH7.js} +81 -34
- package/dist/chunk-XYMG2FH7.js.map +1 -0
- package/dist/{http-FKD4GT55.js → http-Q4TSO32V.js} +2 -2
- package/dist/{http-TPVUGXYJ.js → http-QWUWDTFN.js} +2 -2
- package/dist/index.cjs +86 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +5 -3
- package/dist/node.cjs +86 -30
- 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 +5 -3
- package/dist/node.js.map +1 -1
- package/dist/{replay-PICGOZVG.js → replay-RPB6CT6M.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-5LY4XOUY.js.map +0 -1
- package/dist/chunk-RBKGO5ZC.js.map +0 -1
- package/dist/chunk-V4MRFSWK.js.map +0 -1
- /package/dist/{chunk-TNGKCPBP.js.map → chunk-3WIN3VU3.js.map} +0 -0
- /package/dist/{http-FKD4GT55.js.map → http-Q4TSO32V.js.map} +0 -0
- /package/dist/{http-TPVUGXYJ.js.map → http-QWUWDTFN.js.map} +0 -0
- /package/dist/{replay-PICGOZVG.js.map → replay-RPB6CT6M.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AX6EZPGH.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-Q4TSO32V.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6JTVCM2L.js";
|
|
10
10
|
import "./chunk-H6LZRFMN.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-QWUWDTFN.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.
|
|
45
|
+
__version__ = "0.44.0";
|
|
46
46
|
__packageName__ = "@bitfab/sdk";
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -164,7 +164,7 @@ var init_compress = __esm({
|
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
// src/errors.ts
|
|
167
|
-
var BitfabError;
|
|
167
|
+
var BitfabError, MixedTracingError;
|
|
168
168
|
var init_errors = __esm({
|
|
169
169
|
"src/errors.ts"() {
|
|
170
170
|
"use strict";
|
|
@@ -177,6 +177,12 @@ var init_errors = __esm({
|
|
|
177
177
|
this.name = "BitfabError";
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
+
MixedTracingError = class extends Error {
|
|
181
|
+
constructor(message) {
|
|
182
|
+
super(message);
|
|
183
|
+
this.name = "MixedTracingError";
|
|
184
|
+
}
|
|
185
|
+
};
|
|
180
186
|
}
|
|
181
187
|
});
|
|
182
188
|
|
|
@@ -3255,6 +3261,7 @@ __export(index_exports, {
|
|
|
3255
3261
|
DatasetsClient: () => DatasetsClient,
|
|
3256
3262
|
DbBranchReplayError: () => DbBranchReplayError,
|
|
3257
3263
|
HttpClient: () => HttpClient,
|
|
3264
|
+
MixedTracingError: () => MixedTracingError,
|
|
3258
3265
|
NO_MOCK_OVERRIDE: () => NO_MOCK_OVERRIDE,
|
|
3259
3266
|
ReplayError: () => ReplayError,
|
|
3260
3267
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
@@ -4328,6 +4335,50 @@ async function runFunctionWithBaml(bamlSource, inputs, providers, envVars) {
|
|
|
4328
4335
|
};
|
|
4329
4336
|
}
|
|
4330
4337
|
|
|
4338
|
+
// src/captureSurface.ts
|
|
4339
|
+
init_errors();
|
|
4340
|
+
var DEFAULT_SURFACE = "opt-in";
|
|
4341
|
+
var SURFACE_API = {
|
|
4342
|
+
"opt-in": "withSpan()",
|
|
4343
|
+
"opt-out": "withTrace()"
|
|
4344
|
+
};
|
|
4345
|
+
var MIXED_SURFACE_REMEDY = {
|
|
4346
|
+
"opt-in": "Inside a withTrace/trace subtree, configure a discovered call with node()/withNode() instead, or trace this workflow with withSpan() only.",
|
|
4347
|
+
"opt-out": "Wrap the caller with withTrace()/trace() as well, or wrap this function with withSpan()."
|
|
4348
|
+
};
|
|
4349
|
+
function resolveSurface(requested, parentSurface) {
|
|
4350
|
+
if (requested === "neutral") {
|
|
4351
|
+
return void 0;
|
|
4352
|
+
}
|
|
4353
|
+
if (requested === "inherit") {
|
|
4354
|
+
return parentSurface ?? DEFAULT_SURFACE;
|
|
4355
|
+
}
|
|
4356
|
+
return requested;
|
|
4357
|
+
}
|
|
4358
|
+
function mixedTracingError(enteredApi, entered, enclosing, traceFunctionKey) {
|
|
4359
|
+
const subject = traceFunctionKey === void 0 ? "" : ` for "${traceFunctionKey}"`;
|
|
4360
|
+
return new MixedTracingError(
|
|
4361
|
+
`opt-in and opt-out tracing can't be mixed in one call stack: ${enteredApi} (${entered})${subject} was entered inside a ${SURFACE_API[enclosing]} call (${enclosing}). ${MIXED_SURFACE_REMEDY[entered]}`
|
|
4362
|
+
);
|
|
4363
|
+
}
|
|
4364
|
+
function assertSurfacesCompatible(requested, resolved, parentSurface, traceFunctionKey) {
|
|
4365
|
+
if (requested === "inherit" || requested === "neutral") {
|
|
4366
|
+
return;
|
|
4367
|
+
}
|
|
4368
|
+
if (resolved === void 0 || parentSurface === void 0) {
|
|
4369
|
+
return;
|
|
4370
|
+
}
|
|
4371
|
+
if (parentSurface === resolved) {
|
|
4372
|
+
return;
|
|
4373
|
+
}
|
|
4374
|
+
throw mixedTracingError(
|
|
4375
|
+
SURFACE_API[resolved],
|
|
4376
|
+
resolved,
|
|
4377
|
+
parentSurface,
|
|
4378
|
+
traceFunctionKey
|
|
4379
|
+
);
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4331
4382
|
// src/client.ts
|
|
4332
4383
|
init_constants();
|
|
4333
4384
|
|
|
@@ -4474,6 +4525,7 @@ function buildSnapshotRef(config, sdkWallClockBeforeFn) {
|
|
|
4474
4525
|
}
|
|
4475
4526
|
|
|
4476
4527
|
// src/client.ts
|
|
4528
|
+
init_errors();
|
|
4477
4529
|
init_http();
|
|
4478
4530
|
|
|
4479
4531
|
// src/langgraph.ts
|
|
@@ -5863,18 +5915,6 @@ var BitfabVercelAiHandler = class {
|
|
|
5863
5915
|
|
|
5864
5916
|
// src/client.ts
|
|
5865
5917
|
init_warnOnce();
|
|
5866
|
-
var MIXED_SURFACE_REMEDY = {
|
|
5867
|
-
"opt-in": "Inside a withTrace/trace subtree, configure a discovered call with node()/withNode() instead, or trace this workflow with withSpan() only.",
|
|
5868
|
-
"opt-out": "Wrap the caller with withTrace()/trace() as well, or wrap this function with withSpan()."
|
|
5869
|
-
};
|
|
5870
|
-
function warnMixedTracingSurfaces(traceFunctionKey, entered, enclosing) {
|
|
5871
|
-
const enteredApi = entered === "opt-in" ? "withSpan()" : "withTrace()";
|
|
5872
|
-
const enclosingApi = enclosing === "opt-in" ? "withSpan()" : "withTrace()";
|
|
5873
|
-
warnOnce(
|
|
5874
|
-
`mixed-tracing-surface:${traceFunctionKey}:${entered}`,
|
|
5875
|
-
`opt-in and opt-out tracing are mixed in one call stack: ${enteredApi} (${entered}) for "${traceFunctionKey}" was entered inside a ${enclosingApi} call (${enclosing}). Both are recorded, and the spans nest as written. ${MIXED_SURFACE_REMEDY[entered]}`
|
|
5876
|
-
);
|
|
5877
|
-
}
|
|
5878
5918
|
var activeTraceStates = /* @__PURE__ */ new Map();
|
|
5879
5919
|
var asyncLocalStorage = null;
|
|
5880
5920
|
var SPAN_CONTEXT_STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.spanContextStorage");
|
|
@@ -5904,6 +5944,10 @@ function getSpanStack() {
|
|
|
5904
5944
|
}
|
|
5905
5945
|
return browserSpanStack;
|
|
5906
5946
|
}
|
|
5947
|
+
function enclosingSurface() {
|
|
5948
|
+
const stack = getSpanStack();
|
|
5949
|
+
return stack[stack.length - 1]?.surface;
|
|
5950
|
+
}
|
|
5907
5951
|
function runWithSpanStack(stack, fn) {
|
|
5908
5952
|
if (asyncLocalStorage) {
|
|
5909
5953
|
return asyncLocalStorage.run(stack, fn);
|
|
@@ -6390,6 +6434,9 @@ var Bitfab = class {
|
|
|
6390
6434
|
const nodeConfiguration = { ...configuration, functionName };
|
|
6391
6435
|
return function(...args) {
|
|
6392
6436
|
if (!__bitfabAutoTraceActive()) {
|
|
6437
|
+
if (enclosingSurface() === "opt-in") {
|
|
6438
|
+
throw mixedTracingError("node()", "opt-out", "opt-in");
|
|
6439
|
+
}
|
|
6393
6440
|
return fn.apply(this, args);
|
|
6394
6441
|
}
|
|
6395
6442
|
return runWithAutoTraceNodeConfiguration(
|
|
@@ -7091,20 +7138,19 @@ var Bitfab = class {
|
|
|
7091
7138
|
const spanId = randomUuid();
|
|
7092
7139
|
const parentSpanId = parentContext?.spanId ?? null;
|
|
7093
7140
|
const isRootSpan = parentSpanId === null;
|
|
7094
|
-
const requestedSurface = options.surface ??
|
|
7095
|
-
const surface = requestedSurface
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
}
|
|
7141
|
+
const requestedSurface = options.surface ?? DEFAULT_SURFACE;
|
|
7142
|
+
const surface = resolveSurface(requestedSurface, parentContext?.surface);
|
|
7143
|
+
assertSurfacesCompatible(
|
|
7144
|
+
requestedSurface,
|
|
7145
|
+
surface,
|
|
7146
|
+
parentContext?.surface,
|
|
7147
|
+
traceFunctionKey
|
|
7148
|
+
);
|
|
7103
7149
|
const newContext = {
|
|
7104
7150
|
traceId,
|
|
7105
7151
|
spanId,
|
|
7106
7152
|
contexts: [],
|
|
7107
|
-
surface
|
|
7153
|
+
...surface !== void 0 && { surface }
|
|
7108
7154
|
};
|
|
7109
7155
|
newStack = [...currentStack, newContext];
|
|
7110
7156
|
const inputs = args;
|
|
@@ -7387,6 +7433,9 @@ var Bitfab = class {
|
|
|
7387
7433
|
if (registeredTraceId) {
|
|
7388
7434
|
activeTraceStates.delete(registeredTraceId);
|
|
7389
7435
|
}
|
|
7436
|
+
if (setupError instanceof MixedTracingError) {
|
|
7437
|
+
throw setupError;
|
|
7438
|
+
}
|
|
7390
7439
|
if (getReplayContext() || inSeedScope()) {
|
|
7391
7440
|
throw setupError;
|
|
7392
7441
|
}
|
|
@@ -7786,9 +7835,14 @@ var Bitfab = class {
|
|
|
7786
7835
|
const wrappedKey = fn._bitfabTraceFunctionKey;
|
|
7787
7836
|
let target = fn;
|
|
7788
7837
|
if (wrappedKey === void 0) {
|
|
7838
|
+
const seedRootOptions = {
|
|
7839
|
+
name: traceFunctionKey,
|
|
7840
|
+
type: "agent",
|
|
7841
|
+
surface: "neutral"
|
|
7842
|
+
};
|
|
7789
7843
|
target = this.withSpan(
|
|
7790
7844
|
traceFunctionKey,
|
|
7791
|
-
|
|
7845
|
+
seedRootOptions,
|
|
7792
7846
|
fn
|
|
7793
7847
|
);
|
|
7794
7848
|
} else if (wrappedKey !== traceFunctionKey) {
|
|
@@ -7830,11 +7884,12 @@ var Bitfab = class {
|
|
|
7830
7884
|
const wrappedKey = fn._bitfabTraceFunctionKey;
|
|
7831
7885
|
let replayFn = fn;
|
|
7832
7886
|
if (wrappedKey === void 0) {
|
|
7833
|
-
|
|
7834
|
-
traceFunctionKey,
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7887
|
+
const replayRootOptions = {
|
|
7888
|
+
name: traceFunctionKey,
|
|
7889
|
+
type: "agent",
|
|
7890
|
+
surface: "neutral"
|
|
7891
|
+
};
|
|
7892
|
+
replayFn = this.withSpan(traceFunctionKey, replayRootOptions, fn);
|
|
7838
7893
|
} else if (wrappedKey !== traceFunctionKey) {
|
|
7839
7894
|
throw new BitfabError(
|
|
7840
7895
|
`Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
|
|
@@ -8147,6 +8202,7 @@ function resolveTraceFunctionKey(registration) {
|
|
|
8147
8202
|
DatasetsClient,
|
|
8148
8203
|
DbBranchReplayError,
|
|
8149
8204
|
HttpClient,
|
|
8205
|
+
MixedTracingError,
|
|
8150
8206
|
NO_MOCK_OVERRIDE,
|
|
8151
8207
|
ReplayError,
|
|
8152
8208
|
SUPPORTED_PROVIDERS,
|