braintrust 0.4.4 → 0.4.6
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/dev/dist/index.js +20 -7
- package/dev/dist/index.mjs +20 -7
- package/dist/browser.d.mts +64 -1
- package/dist/browser.d.ts +64 -1
- package/dist/browser.js +12 -7
- package/dist/browser.mjs +12 -7
- package/dist/cli.js +24 -9
- package/dist/index.d.mts +88 -3
- package/dist/index.d.ts +88 -3
- package/dist/index.js +679 -75
- package/dist/index.mjs +632 -28
- package/package.json +4 -2
- package/util/dist/index.js +3 -1
- package/util/dist/index.mjs +3 -1
package/dev/dist/index.js
CHANGED
|
@@ -848,7 +848,9 @@ function mergeDictsWithPathsHelper({
|
|
|
848
848
|
mergePaths
|
|
849
849
|
});
|
|
850
850
|
} else {
|
|
851
|
-
|
|
851
|
+
if (mergeFromV !== void 0) {
|
|
852
|
+
mergeInto[k] = mergeFromV;
|
|
853
|
+
}
|
|
852
854
|
}
|
|
853
855
|
});
|
|
854
856
|
return mergeInto;
|
|
@@ -5447,7 +5449,7 @@ async function permalink(slug, opts) {
|
|
|
5447
5449
|
return state.appUrl;
|
|
5448
5450
|
};
|
|
5449
5451
|
try {
|
|
5450
|
-
const components =
|
|
5452
|
+
const components = getSpanComponentsClass().fromStr(slug);
|
|
5451
5453
|
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
5452
5454
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
5453
5455
|
getOrgName(),
|
|
@@ -5475,7 +5477,7 @@ function startSpanParentArgs(args) {
|
|
|
5475
5477
|
if (args.parentSpanIds) {
|
|
5476
5478
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
5477
5479
|
}
|
|
5478
|
-
const parentComponents =
|
|
5480
|
+
const parentComponents = getSpanComponentsClass().fromStr(args.parent);
|
|
5479
5481
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
5480
5482
|
throw new Error(
|
|
5481
5483
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
@@ -5919,7 +5921,7 @@ function getSpanParentObject(options) {
|
|
|
5919
5921
|
return parentSpan;
|
|
5920
5922
|
}
|
|
5921
5923
|
const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.parent]), () => ( state.currentParent.getStore()));
|
|
5922
|
-
if (parentStr) return
|
|
5924
|
+
if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
|
|
5923
5925
|
const experiment = currentExperiment();
|
|
5924
5926
|
if (experiment) {
|
|
5925
5927
|
return experiment;
|
|
@@ -5985,7 +5987,7 @@ function startSpanAndIsLogger(args) {
|
|
|
5985
5987
|
parent: _optionalChain([args, 'optionalAccess', _47 => _47.parent]),
|
|
5986
5988
|
state
|
|
5987
5989
|
});
|
|
5988
|
-
if (parentObject instanceof SpanComponentsV3) {
|
|
5990
|
+
if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
|
|
5989
5991
|
const parentSpanIds = parentObject.data.row_id ? {
|
|
5990
5992
|
spanId: parentObject.data.span_id,
|
|
5991
5993
|
rootSpanId: parentObject.data.root_span_id
|
|
@@ -7828,7 +7830,10 @@ Error: ${errorText}`;
|
|
|
7828
7830
|
limit: INTERNAL_BTQL_LIMIT
|
|
7829
7831
|
},
|
|
7830
7832
|
use_columnstore: false,
|
|
7831
|
-
brainstore_realtime: true
|
|
7833
|
+
brainstore_realtime: true,
|
|
7834
|
+
...this.pinnedVersion !== void 0 ? {
|
|
7835
|
+
version: this.pinnedVersion
|
|
7836
|
+
} : {}
|
|
7832
7837
|
},
|
|
7833
7838
|
{ headers: { "Accept-Encoding": "gzip" } }
|
|
7834
7839
|
);
|
|
@@ -11392,9 +11397,17 @@ function makeCheckAuthorized(allowedOrgName) {
|
|
|
11392
11397
|
return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
|
|
11393
11398
|
}
|
|
11394
11399
|
try {
|
|
11400
|
+
const orgName = parseHeader(req.headers, "x-bt-org-name");
|
|
11401
|
+
if (!orgName) {
|
|
11402
|
+
return next(_httperrors2.default.call(void 0, 400, "Missing x-bt-org-name header"));
|
|
11403
|
+
}
|
|
11404
|
+
if (allowedOrgName && allowedOrgName !== orgName) {
|
|
11405
|
+
const errorMessage = `Org '${orgName}' is not allowed. Only org '${allowedOrgName}' is allowed.`;
|
|
11406
|
+
return next(_httperrors2.default.call(void 0, 403, errorMessage));
|
|
11407
|
+
}
|
|
11395
11408
|
const state = await cachedLogin({
|
|
11396
11409
|
apiKey: _optionalChain([req, 'access', _124 => _124.ctx, 'optionalAccess', _125 => _125.token]),
|
|
11397
|
-
orgName
|
|
11410
|
+
orgName
|
|
11398
11411
|
});
|
|
11399
11412
|
req.ctx.state = state;
|
|
11400
11413
|
next();
|
package/dev/dist/index.mjs
CHANGED
|
@@ -848,7 +848,9 @@ function mergeDictsWithPathsHelper({
|
|
|
848
848
|
mergePaths
|
|
849
849
|
});
|
|
850
850
|
} else {
|
|
851
|
-
|
|
851
|
+
if (mergeFromV !== void 0) {
|
|
852
|
+
mergeInto[k] = mergeFromV;
|
|
853
|
+
}
|
|
852
854
|
}
|
|
853
855
|
});
|
|
854
856
|
return mergeInto;
|
|
@@ -5447,7 +5449,7 @@ async function permalink(slug, opts) {
|
|
|
5447
5449
|
return state.appUrl;
|
|
5448
5450
|
};
|
|
5449
5451
|
try {
|
|
5450
|
-
const components =
|
|
5452
|
+
const components = getSpanComponentsClass().fromStr(slug);
|
|
5451
5453
|
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
5452
5454
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
5453
5455
|
getOrgName(),
|
|
@@ -5475,7 +5477,7 @@ function startSpanParentArgs(args) {
|
|
|
5475
5477
|
if (args.parentSpanIds) {
|
|
5476
5478
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
5477
5479
|
}
|
|
5478
|
-
const parentComponents =
|
|
5480
|
+
const parentComponents = getSpanComponentsClass().fromStr(args.parent);
|
|
5479
5481
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
5480
5482
|
throw new Error(
|
|
5481
5483
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
@@ -5919,7 +5921,7 @@ function getSpanParentObject(options) {
|
|
|
5919
5921
|
return parentSpan;
|
|
5920
5922
|
}
|
|
5921
5923
|
const parentStr = options?.parent ?? state.currentParent.getStore();
|
|
5922
|
-
if (parentStr) return
|
|
5924
|
+
if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
|
|
5923
5925
|
const experiment = currentExperiment();
|
|
5924
5926
|
if (experiment) {
|
|
5925
5927
|
return experiment;
|
|
@@ -5985,7 +5987,7 @@ function startSpanAndIsLogger(args) {
|
|
|
5985
5987
|
parent: args?.parent,
|
|
5986
5988
|
state
|
|
5987
5989
|
});
|
|
5988
|
-
if (parentObject instanceof SpanComponentsV3) {
|
|
5990
|
+
if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
|
|
5989
5991
|
const parentSpanIds = parentObject.data.row_id ? {
|
|
5990
5992
|
spanId: parentObject.data.span_id,
|
|
5991
5993
|
rootSpanId: parentObject.data.root_span_id
|
|
@@ -7828,7 +7830,10 @@ Error: ${errorText}`;
|
|
|
7828
7830
|
limit: INTERNAL_BTQL_LIMIT
|
|
7829
7831
|
},
|
|
7830
7832
|
use_columnstore: false,
|
|
7831
|
-
brainstore_realtime: true
|
|
7833
|
+
brainstore_realtime: true,
|
|
7834
|
+
...this.pinnedVersion !== void 0 ? {
|
|
7835
|
+
version: this.pinnedVersion
|
|
7836
|
+
} : {}
|
|
7832
7837
|
},
|
|
7833
7838
|
{ headers: { "Accept-Encoding": "gzip" } }
|
|
7834
7839
|
);
|
|
@@ -11392,9 +11397,17 @@ function makeCheckAuthorized(allowedOrgName) {
|
|
|
11392
11397
|
return next(createError(401, "Unauthorized"));
|
|
11393
11398
|
}
|
|
11394
11399
|
try {
|
|
11400
|
+
const orgName = parseHeader(req.headers, "x-bt-org-name");
|
|
11401
|
+
if (!orgName) {
|
|
11402
|
+
return next(createError(400, "Missing x-bt-org-name header"));
|
|
11403
|
+
}
|
|
11404
|
+
if (allowedOrgName && allowedOrgName !== orgName) {
|
|
11405
|
+
const errorMessage = `Org '${orgName}' is not allowed. Only org '${allowedOrgName}' is allowed.`;
|
|
11406
|
+
return next(createError(403, errorMessage));
|
|
11407
|
+
}
|
|
11395
11408
|
const state = await cachedLogin({
|
|
11396
11409
|
apiKey: req.ctx?.token,
|
|
11397
|
-
orgName
|
|
11410
|
+
orgName
|
|
11398
11411
|
});
|
|
11399
11412
|
req.ctx.state = state;
|
|
11400
11413
|
next();
|
package/dist/browser.d.mts
CHANGED
|
@@ -318,6 +318,69 @@ interface Score {
|
|
|
318
318
|
error?: unknown;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
+
declare const spanComponentsV4Schema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
|
|
322
|
+
object_type: z.ZodNativeEnum<typeof SpanObjectTypeV3>;
|
|
323
|
+
propagated_event: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
324
|
+
}, "strip", z.ZodTypeAny, {
|
|
325
|
+
object_type: SpanObjectTypeV3;
|
|
326
|
+
propagated_event?: Record<string, unknown> | null | undefined;
|
|
327
|
+
}, {
|
|
328
|
+
object_type: SpanObjectTypeV3;
|
|
329
|
+
propagated_event?: Record<string, unknown> | null | undefined;
|
|
330
|
+
}>, z.ZodUnion<[z.ZodObject<{
|
|
331
|
+
object_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
332
|
+
compute_object_metadata_args: z.ZodOptional<z.ZodNull>;
|
|
333
|
+
}, "strip", z.ZodTypeAny, {
|
|
334
|
+
object_id?: string | null | undefined;
|
|
335
|
+
compute_object_metadata_args?: null | undefined;
|
|
336
|
+
}, {
|
|
337
|
+
object_id?: string | null | undefined;
|
|
338
|
+
compute_object_metadata_args?: null | undefined;
|
|
339
|
+
}>, z.ZodObject<{
|
|
340
|
+
object_id: z.ZodOptional<z.ZodNull>;
|
|
341
|
+
compute_object_metadata_args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
342
|
+
}, "strip", z.ZodTypeAny, {
|
|
343
|
+
compute_object_metadata_args: Record<string, unknown>;
|
|
344
|
+
object_id?: null | undefined;
|
|
345
|
+
}, {
|
|
346
|
+
compute_object_metadata_args: Record<string, unknown>;
|
|
347
|
+
object_id?: null | undefined;
|
|
348
|
+
}>]>>, z.ZodUnion<[z.ZodObject<{
|
|
349
|
+
row_id: z.ZodString;
|
|
350
|
+
span_id: z.ZodString;
|
|
351
|
+
root_span_id: z.ZodString;
|
|
352
|
+
}, "strip", z.ZodTypeAny, {
|
|
353
|
+
span_id: string;
|
|
354
|
+
root_span_id: string;
|
|
355
|
+
row_id: string;
|
|
356
|
+
}, {
|
|
357
|
+
span_id: string;
|
|
358
|
+
root_span_id: string;
|
|
359
|
+
row_id: string;
|
|
360
|
+
}>, z.ZodObject<{
|
|
361
|
+
row_id: z.ZodOptional<z.ZodNull>;
|
|
362
|
+
span_id: z.ZodOptional<z.ZodNull>;
|
|
363
|
+
root_span_id: z.ZodOptional<z.ZodNull>;
|
|
364
|
+
}, "strip", z.ZodTypeAny, {
|
|
365
|
+
span_id?: null | undefined;
|
|
366
|
+
root_span_id?: null | undefined;
|
|
367
|
+
row_id?: null | undefined;
|
|
368
|
+
}, {
|
|
369
|
+
span_id?: null | undefined;
|
|
370
|
+
root_span_id?: null | undefined;
|
|
371
|
+
row_id?: null | undefined;
|
|
372
|
+
}>]>>;
|
|
373
|
+
type SpanComponentsV4Data = z.infer<typeof spanComponentsV4Schema>;
|
|
374
|
+
declare class SpanComponentsV4 {
|
|
375
|
+
data: SpanComponentsV4Data;
|
|
376
|
+
constructor(data: SpanComponentsV4Data);
|
|
377
|
+
toStr(): string;
|
|
378
|
+
static fromStr(s: string): SpanComponentsV4;
|
|
379
|
+
objectIdFields(): ParentExperimentIds | ParentProjectLogIds | ParentPlaygroundLogIds;
|
|
380
|
+
export(): Promise<string>;
|
|
381
|
+
private static fromJsonObj;
|
|
382
|
+
}
|
|
383
|
+
|
|
321
384
|
declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool"];
|
|
322
385
|
type SpanType = (typeof spanTypeAttributeValues)[number];
|
|
323
386
|
|
|
@@ -8919,7 +8982,7 @@ declare function currentSpan(options?: OptionalStateArg): Span;
|
|
|
8919
8982
|
*/
|
|
8920
8983
|
declare function getSpanParentObject<IsAsyncFlush extends boolean>(options?: AsyncFlushArg<IsAsyncFlush> & OptionalStateArg & {
|
|
8921
8984
|
parent?: string;
|
|
8922
|
-
}): SpanComponentsV3 | Span | Experiment | Logger<IsAsyncFlush>;
|
|
8985
|
+
}): SpanComponentsV3 | SpanComponentsV4 | Span | Experiment | Logger<IsAsyncFlush>;
|
|
8923
8986
|
declare function logError(span: Span, error: unknown): void;
|
|
8924
8987
|
/**
|
|
8925
8988
|
* Toplevel function for starting a span. It checks the following (in precedence order):
|
package/dist/browser.d.ts
CHANGED
|
@@ -318,6 +318,69 @@ interface Score {
|
|
|
318
318
|
error?: unknown;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
+
declare const spanComponentsV4Schema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
|
|
322
|
+
object_type: z.ZodNativeEnum<typeof SpanObjectTypeV3>;
|
|
323
|
+
propagated_event: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
324
|
+
}, "strip", z.ZodTypeAny, {
|
|
325
|
+
object_type: SpanObjectTypeV3;
|
|
326
|
+
propagated_event?: Record<string, unknown> | null | undefined;
|
|
327
|
+
}, {
|
|
328
|
+
object_type: SpanObjectTypeV3;
|
|
329
|
+
propagated_event?: Record<string, unknown> | null | undefined;
|
|
330
|
+
}>, z.ZodUnion<[z.ZodObject<{
|
|
331
|
+
object_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
332
|
+
compute_object_metadata_args: z.ZodOptional<z.ZodNull>;
|
|
333
|
+
}, "strip", z.ZodTypeAny, {
|
|
334
|
+
object_id?: string | null | undefined;
|
|
335
|
+
compute_object_metadata_args?: null | undefined;
|
|
336
|
+
}, {
|
|
337
|
+
object_id?: string | null | undefined;
|
|
338
|
+
compute_object_metadata_args?: null | undefined;
|
|
339
|
+
}>, z.ZodObject<{
|
|
340
|
+
object_id: z.ZodOptional<z.ZodNull>;
|
|
341
|
+
compute_object_metadata_args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
342
|
+
}, "strip", z.ZodTypeAny, {
|
|
343
|
+
compute_object_metadata_args: Record<string, unknown>;
|
|
344
|
+
object_id?: null | undefined;
|
|
345
|
+
}, {
|
|
346
|
+
compute_object_metadata_args: Record<string, unknown>;
|
|
347
|
+
object_id?: null | undefined;
|
|
348
|
+
}>]>>, z.ZodUnion<[z.ZodObject<{
|
|
349
|
+
row_id: z.ZodString;
|
|
350
|
+
span_id: z.ZodString;
|
|
351
|
+
root_span_id: z.ZodString;
|
|
352
|
+
}, "strip", z.ZodTypeAny, {
|
|
353
|
+
span_id: string;
|
|
354
|
+
root_span_id: string;
|
|
355
|
+
row_id: string;
|
|
356
|
+
}, {
|
|
357
|
+
span_id: string;
|
|
358
|
+
root_span_id: string;
|
|
359
|
+
row_id: string;
|
|
360
|
+
}>, z.ZodObject<{
|
|
361
|
+
row_id: z.ZodOptional<z.ZodNull>;
|
|
362
|
+
span_id: z.ZodOptional<z.ZodNull>;
|
|
363
|
+
root_span_id: z.ZodOptional<z.ZodNull>;
|
|
364
|
+
}, "strip", z.ZodTypeAny, {
|
|
365
|
+
span_id?: null | undefined;
|
|
366
|
+
root_span_id?: null | undefined;
|
|
367
|
+
row_id?: null | undefined;
|
|
368
|
+
}, {
|
|
369
|
+
span_id?: null | undefined;
|
|
370
|
+
root_span_id?: null | undefined;
|
|
371
|
+
row_id?: null | undefined;
|
|
372
|
+
}>]>>;
|
|
373
|
+
type SpanComponentsV4Data = z.infer<typeof spanComponentsV4Schema>;
|
|
374
|
+
declare class SpanComponentsV4 {
|
|
375
|
+
data: SpanComponentsV4Data;
|
|
376
|
+
constructor(data: SpanComponentsV4Data);
|
|
377
|
+
toStr(): string;
|
|
378
|
+
static fromStr(s: string): SpanComponentsV4;
|
|
379
|
+
objectIdFields(): ParentExperimentIds | ParentProjectLogIds | ParentPlaygroundLogIds;
|
|
380
|
+
export(): Promise<string>;
|
|
381
|
+
private static fromJsonObj;
|
|
382
|
+
}
|
|
383
|
+
|
|
321
384
|
declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool"];
|
|
322
385
|
type SpanType = (typeof spanTypeAttributeValues)[number];
|
|
323
386
|
|
|
@@ -8919,7 +8982,7 @@ declare function currentSpan(options?: OptionalStateArg): Span;
|
|
|
8919
8982
|
*/
|
|
8920
8983
|
declare function getSpanParentObject<IsAsyncFlush extends boolean>(options?: AsyncFlushArg<IsAsyncFlush> & OptionalStateArg & {
|
|
8921
8984
|
parent?: string;
|
|
8922
|
-
}): SpanComponentsV3 | Span | Experiment | Logger<IsAsyncFlush>;
|
|
8985
|
+
}): SpanComponentsV3 | SpanComponentsV4 | Span | Experiment | Logger<IsAsyncFlush>;
|
|
8923
8986
|
declare function logError(span: Span, error: unknown): void;
|
|
8924
8987
|
/**
|
|
8925
8988
|
* Toplevel function for starting a span. It checks the following (in precedence order):
|
package/dist/browser.js
CHANGED
|
@@ -845,7 +845,9 @@ function mergeDictsWithPathsHelper({
|
|
|
845
845
|
mergePaths
|
|
846
846
|
});
|
|
847
847
|
} else {
|
|
848
|
-
|
|
848
|
+
if (mergeFromV !== void 0) {
|
|
849
|
+
mergeInto[k] = mergeFromV;
|
|
850
|
+
}
|
|
849
851
|
}
|
|
850
852
|
});
|
|
851
853
|
return mergeInto;
|
|
@@ -5391,7 +5393,7 @@ function updateSpan({
|
|
|
5391
5393
|
...event
|
|
5392
5394
|
}) {
|
|
5393
5395
|
const resolvedState = _nullishCoalesce(state, () => ( _globalState));
|
|
5394
|
-
const components =
|
|
5396
|
+
const components = getSpanComponentsClass().fromStr(exported);
|
|
5395
5397
|
if (!components.data.row_id) {
|
|
5396
5398
|
throw new Error("Exported span must have a row id");
|
|
5397
5399
|
}
|
|
@@ -5474,7 +5476,7 @@ async function permalink(slug, opts) {
|
|
|
5474
5476
|
return state.appUrl;
|
|
5475
5477
|
};
|
|
5476
5478
|
try {
|
|
5477
|
-
const components =
|
|
5479
|
+
const components = getSpanComponentsClass().fromStr(slug);
|
|
5478
5480
|
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
5479
5481
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
5480
5482
|
getOrgName(),
|
|
@@ -5502,7 +5504,7 @@ function startSpanParentArgs(args) {
|
|
|
5502
5504
|
if (args.parentSpanIds) {
|
|
5503
5505
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
5504
5506
|
}
|
|
5505
|
-
const parentComponents =
|
|
5507
|
+
const parentComponents = getSpanComponentsClass().fromStr(args.parent);
|
|
5506
5508
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
5507
5509
|
throw new Error(
|
|
5508
5510
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
@@ -6164,7 +6166,7 @@ function getSpanParentObject(options) {
|
|
|
6164
6166
|
return parentSpan;
|
|
6165
6167
|
}
|
|
6166
6168
|
const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _43 => _43.parent]), () => ( state.currentParent.getStore()));
|
|
6167
|
-
if (parentStr) return
|
|
6169
|
+
if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
|
|
6168
6170
|
const experiment = currentExperiment();
|
|
6169
6171
|
if (experiment) {
|
|
6170
6172
|
return experiment;
|
|
@@ -6385,7 +6387,7 @@ function startSpanAndIsLogger(args) {
|
|
|
6385
6387
|
parent: _optionalChain([args, 'optionalAccess', _52 => _52.parent]),
|
|
6386
6388
|
state
|
|
6387
6389
|
});
|
|
6388
|
-
if (parentObject instanceof SpanComponentsV3) {
|
|
6390
|
+
if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
|
|
6389
6391
|
const parentSpanIds = parentObject.data.row_id ? {
|
|
6390
6392
|
spanId: parentObject.data.span_id,
|
|
6391
6393
|
rootSpanId: parentObject.data.root_span_id
|
|
@@ -8505,7 +8507,10 @@ Error: ${errorText}`;
|
|
|
8505
8507
|
limit: INTERNAL_BTQL_LIMIT
|
|
8506
8508
|
},
|
|
8507
8509
|
use_columnstore: false,
|
|
8508
|
-
brainstore_realtime: true
|
|
8510
|
+
brainstore_realtime: true,
|
|
8511
|
+
...this.pinnedVersion !== void 0 ? {
|
|
8512
|
+
version: this.pinnedVersion
|
|
8513
|
+
} : {}
|
|
8509
8514
|
},
|
|
8510
8515
|
{ headers: { "Accept-Encoding": "gzip" } }
|
|
8511
8516
|
);
|
package/dist/browser.mjs
CHANGED
|
@@ -845,7 +845,9 @@ function mergeDictsWithPathsHelper({
|
|
|
845
845
|
mergePaths
|
|
846
846
|
});
|
|
847
847
|
} else {
|
|
848
|
-
|
|
848
|
+
if (mergeFromV !== void 0) {
|
|
849
|
+
mergeInto[k] = mergeFromV;
|
|
850
|
+
}
|
|
849
851
|
}
|
|
850
852
|
});
|
|
851
853
|
return mergeInto;
|
|
@@ -5391,7 +5393,7 @@ function updateSpan({
|
|
|
5391
5393
|
...event
|
|
5392
5394
|
}) {
|
|
5393
5395
|
const resolvedState = state ?? _globalState;
|
|
5394
|
-
const components =
|
|
5396
|
+
const components = getSpanComponentsClass().fromStr(exported);
|
|
5395
5397
|
if (!components.data.row_id) {
|
|
5396
5398
|
throw new Error("Exported span must have a row id");
|
|
5397
5399
|
}
|
|
@@ -5474,7 +5476,7 @@ async function permalink(slug, opts) {
|
|
|
5474
5476
|
return state.appUrl;
|
|
5475
5477
|
};
|
|
5476
5478
|
try {
|
|
5477
|
-
const components =
|
|
5479
|
+
const components = getSpanComponentsClass().fromStr(slug);
|
|
5478
5480
|
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
5479
5481
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
5480
5482
|
getOrgName(),
|
|
@@ -5502,7 +5504,7 @@ function startSpanParentArgs(args) {
|
|
|
5502
5504
|
if (args.parentSpanIds) {
|
|
5503
5505
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
5504
5506
|
}
|
|
5505
|
-
const parentComponents =
|
|
5507
|
+
const parentComponents = getSpanComponentsClass().fromStr(args.parent);
|
|
5506
5508
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
5507
5509
|
throw new Error(
|
|
5508
5510
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
@@ -6164,7 +6166,7 @@ function getSpanParentObject(options) {
|
|
|
6164
6166
|
return parentSpan;
|
|
6165
6167
|
}
|
|
6166
6168
|
const parentStr = options?.parent ?? state.currentParent.getStore();
|
|
6167
|
-
if (parentStr) return
|
|
6169
|
+
if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
|
|
6168
6170
|
const experiment = currentExperiment();
|
|
6169
6171
|
if (experiment) {
|
|
6170
6172
|
return experiment;
|
|
@@ -6385,7 +6387,7 @@ function startSpanAndIsLogger(args) {
|
|
|
6385
6387
|
parent: args?.parent,
|
|
6386
6388
|
state
|
|
6387
6389
|
});
|
|
6388
|
-
if (parentObject instanceof SpanComponentsV3) {
|
|
6390
|
+
if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
|
|
6389
6391
|
const parentSpanIds = parentObject.data.row_id ? {
|
|
6390
6392
|
spanId: parentObject.data.span_id,
|
|
6391
6393
|
rootSpanId: parentObject.data.root_span_id
|
|
@@ -8505,7 +8507,10 @@ Error: ${errorText}`;
|
|
|
8505
8507
|
limit: INTERNAL_BTQL_LIMIT
|
|
8506
8508
|
},
|
|
8507
8509
|
use_columnstore: false,
|
|
8508
|
-
brainstore_realtime: true
|
|
8510
|
+
brainstore_realtime: true,
|
|
8511
|
+
...this.pinnedVersion !== void 0 ? {
|
|
8512
|
+
version: this.pinnedVersion
|
|
8513
|
+
} : {}
|
|
8509
8514
|
},
|
|
8510
8515
|
{ headers: { "Accept-Encoding": "gzip" } }
|
|
8511
8516
|
);
|
package/dist/cli.js
CHANGED
|
@@ -2052,7 +2052,9 @@ function mergeDictsWithPathsHelper({
|
|
|
2052
2052
|
mergePaths
|
|
2053
2053
|
});
|
|
2054
2054
|
} else {
|
|
2055
|
-
|
|
2055
|
+
if (mergeFromV !== void 0) {
|
|
2056
|
+
mergeInto[k] = mergeFromV;
|
|
2057
|
+
}
|
|
2056
2058
|
}
|
|
2057
2059
|
});
|
|
2058
2060
|
return mergeInto;
|
|
@@ -6686,7 +6688,7 @@ async function permalink(slug, opts) {
|
|
|
6686
6688
|
return state.appUrl;
|
|
6687
6689
|
};
|
|
6688
6690
|
try {
|
|
6689
|
-
const components =
|
|
6691
|
+
const components = getSpanComponentsClass().fromStr(slug);
|
|
6690
6692
|
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
6691
6693
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
6692
6694
|
getOrgName(),
|
|
@@ -6714,7 +6716,7 @@ function startSpanParentArgs(args) {
|
|
|
6714
6716
|
if (args.parentSpanIds) {
|
|
6715
6717
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
6716
6718
|
}
|
|
6717
|
-
const parentComponents =
|
|
6719
|
+
const parentComponents = getSpanComponentsClass().fromStr(args.parent);
|
|
6718
6720
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
6719
6721
|
throw new Error(
|
|
6720
6722
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
@@ -7158,7 +7160,7 @@ function getSpanParentObject(options) {
|
|
|
7158
7160
|
return parentSpan;
|
|
7159
7161
|
}
|
|
7160
7162
|
const parentStr = options?.parent ?? state.currentParent.getStore();
|
|
7161
|
-
if (parentStr) return
|
|
7163
|
+
if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
|
|
7162
7164
|
const experiment = currentExperiment();
|
|
7163
7165
|
if (experiment) {
|
|
7164
7166
|
return experiment;
|
|
@@ -7224,7 +7226,7 @@ function startSpanAndIsLogger(args) {
|
|
|
7224
7226
|
parent: args?.parent,
|
|
7225
7227
|
state
|
|
7226
7228
|
});
|
|
7227
|
-
if (parentObject instanceof SpanComponentsV3) {
|
|
7229
|
+
if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
|
|
7228
7230
|
const parentSpanIds = parentObject.data.row_id ? {
|
|
7229
7231
|
spanId: parentObject.data.span_id,
|
|
7230
7232
|
rootSpanId: parentObject.data.root_span_id
|
|
@@ -9071,7 +9073,10 @@ Error: ${errorText}`;
|
|
|
9071
9073
|
limit: INTERNAL_BTQL_LIMIT
|
|
9072
9074
|
},
|
|
9073
9075
|
use_columnstore: false,
|
|
9074
|
-
brainstore_realtime: true
|
|
9076
|
+
brainstore_realtime: true,
|
|
9077
|
+
...this.pinnedVersion !== void 0 ? {
|
|
9078
|
+
version: this.pinnedVersion
|
|
9079
|
+
} : {}
|
|
9075
9080
|
},
|
|
9076
9081
|
{ headers: { "Accept-Encoding": "gzip" } }
|
|
9077
9082
|
);
|
|
@@ -10228,7 +10233,7 @@ var require_package = __commonJS({
|
|
|
10228
10233
|
"package.json"(exports2, module2) {
|
|
10229
10234
|
module2.exports = {
|
|
10230
10235
|
name: "braintrust",
|
|
10231
|
-
version: "0.4.
|
|
10236
|
+
version: "0.4.6",
|
|
10232
10237
|
description: "SDK for integrating Braintrust",
|
|
10233
10238
|
repository: {
|
|
10234
10239
|
type: "git",
|
|
@@ -10284,10 +10289,11 @@ var require_package = __commonJS({
|
|
|
10284
10289
|
watch: "tsup --watch",
|
|
10285
10290
|
clean: "rm -r dist/* && rm -r dev/dist/*",
|
|
10286
10291
|
docs: "npx typedoc --options typedoc.json src/index.ts",
|
|
10287
|
-
test: "vitest run --exclude src/wrappers/anthropic.test.ts --exclude src/wrappers/oai.test.ts --exclude src/otel.test.ts --exclude src/otel-no-deps.test.ts --exclude src/wrappers/ai-sdk-v1.test.ts --exclude src/wrappers/ai-sdk-v2.test.ts --exclude src/wrappers/ai-sdk-v3.test.ts --exclude src/wrappers/mastra.test.ts --exclude src/wrappers/claude-agent-sdk.test.ts",
|
|
10292
|
+
test: "vitest run --exclude src/wrappers/anthropic.test.ts --exclude src/wrappers/oai.test.ts --exclude src/otel.test.ts --exclude src/otel-no-deps.test.ts --exclude src/wrappers/ai-sdk-v1.test.ts --exclude src/wrappers/ai-sdk-v2.test.ts --exclude src/wrappers/ai-sdk-v3.test.ts --exclude src/wrappers/mastra.test.ts --exclude src/wrappers/claude-agent-sdk.test.ts --exclude src/wrappers/google-genai.test.ts",
|
|
10288
10293
|
"test:anthropic": "vitest run src/wrappers/anthropic.test.ts",
|
|
10289
10294
|
"test:openai": "vitest run src/wrappers/oai.test.ts",
|
|
10290
10295
|
"test:otel": "vitest run src/otel.test.ts",
|
|
10296
|
+
"test:google-genai": "vitest run src/wrappers/google-genai.test.ts",
|
|
10291
10297
|
"test:otel-no-deps": "vitest run src/otel-no-deps.test.ts --reporter=verbose",
|
|
10292
10298
|
"test:ai-sdk-v1": "vitest run src/wrappers/ai-sdk-v1.test.ts",
|
|
10293
10299
|
"test:ai-sdk-v2": "vitest run src/wrappers/ai-sdk-v2.test.ts src/wrappers/ai-sdk-v1.test.ts",
|
|
@@ -10300,6 +10306,7 @@ var require_package = __commonJS({
|
|
|
10300
10306
|
devDependencies: {
|
|
10301
10307
|
"@ai-sdk/anthropic": "^1.0.5",
|
|
10302
10308
|
"@anthropic-ai/sdk": "^0.60.0",
|
|
10309
|
+
"@google/genai": "^1.25.0",
|
|
10303
10310
|
"@jest/globals": "^29.7.0",
|
|
10304
10311
|
"@nodelib/fs.walk": "^1.2.8",
|
|
10305
10312
|
"@openai/agents": "^0.0.14",
|
|
@@ -13731,9 +13738,17 @@ function makeCheckAuthorized(allowedOrgName) {
|
|
|
13731
13738
|
return next((0, import_http_errors.default)(401, "Unauthorized"));
|
|
13732
13739
|
}
|
|
13733
13740
|
try {
|
|
13741
|
+
const orgName = parseHeader(req.headers, "x-bt-org-name");
|
|
13742
|
+
if (!orgName) {
|
|
13743
|
+
return next((0, import_http_errors.default)(400, "Missing x-bt-org-name header"));
|
|
13744
|
+
}
|
|
13745
|
+
if (allowedOrgName && allowedOrgName !== orgName) {
|
|
13746
|
+
const errorMessage = `Org '${orgName}' is not allowed. Only org '${allowedOrgName}' is allowed.`;
|
|
13747
|
+
return next((0, import_http_errors.default)(403, errorMessage));
|
|
13748
|
+
}
|
|
13734
13749
|
const state = await cachedLogin({
|
|
13735
13750
|
apiKey: req.ctx?.token,
|
|
13736
|
-
orgName
|
|
13751
|
+
orgName
|
|
13737
13752
|
});
|
|
13738
13753
|
req.ctx.state = state;
|
|
13739
13754
|
next();
|