braintrust 3.7.0 → 3.7.1
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 +1859 -1338
- package/dev/dist/index.mjs +1774 -1253
- package/dist/auto-instrumentations/bundler/esbuild.cjs +12 -15
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/rollup.cjs +12 -15
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +12 -15
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +12 -15
- package/dist/auto-instrumentations/bundler/webpack.cjs +12 -15
- package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
- package/dist/auto-instrumentations/{chunk-ZK2IYER2.mjs → chunk-NY4CGTN6.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-AKEXR4AL.mjs → chunk-YCKND42U.mjs} +12 -15
- package/dist/auto-instrumentations/hook.mjs +12 -15
- package/dist/auto-instrumentations/index.cjs +12 -15
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/browser.d.mts +8 -30
- package/dist/browser.d.ts +8 -30
- package/dist/browser.js +4836 -6828
- package/dist/browser.mjs +4836 -6828
- package/dist/cli.js +1507 -986
- package/dist/edge-light.js +9173 -11163
- package/dist/edge-light.mjs +9173 -11163
- package/dist/index.d.mts +8 -30
- package/dist/index.d.ts +8 -30
- package/dist/index.js +4747 -6739
- package/dist/index.mjs +4748 -6740
- package/dist/instrumentation/index.js +1735 -1236
- package/dist/instrumentation/index.mjs +1735 -1236
- package/dist/workerd.js +9173 -11163
- package/dist/workerd.mjs +9173 -11163
- package/package.json +2 -2
|
@@ -78,7 +78,7 @@ var DefaultTracingChannel = class {
|
|
|
78
78
|
}
|
|
79
79
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
80
|
tracePromise(fn, _message, thisArg, ...args) {
|
|
81
|
-
return
|
|
81
|
+
return fn.apply(thisArg, args);
|
|
82
82
|
}
|
|
83
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
84
|
traceCallback(fn, _position, _message, thisArg, ...args) {
|
|
@@ -98,6 +98,7 @@ var iso = {
|
|
|
98
98
|
processOn: (_0, _1) => {
|
|
99
99
|
},
|
|
100
100
|
basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
|
|
101
|
+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
|
|
101
102
|
writeln: (text) => console.log(text)
|
|
102
103
|
};
|
|
103
104
|
var isomorph_default = iso;
|
|
@@ -418,10 +419,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
418
419
|
channelName: "streamText",
|
|
419
420
|
kind: "async"
|
|
420
421
|
}),
|
|
421
|
-
streamTextSync: channel({
|
|
422
|
-
channelName: "streamText.sync",
|
|
423
|
-
kind: "sync-stream"
|
|
424
|
-
}),
|
|
425
422
|
generateObject: channel({
|
|
426
423
|
channelName: "generateObject",
|
|
427
424
|
kind: "async"
|
|
@@ -430,10 +427,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
430
427
|
channelName: "streamObject",
|
|
431
428
|
kind: "async"
|
|
432
429
|
}),
|
|
433
|
-
streamObjectSync: channel({
|
|
434
|
-
channelName: "streamObject.sync",
|
|
435
|
-
kind: "sync-stream"
|
|
436
|
-
}),
|
|
437
430
|
agentGenerate: channel({
|
|
438
431
|
channelName: "Agent.generate",
|
|
439
432
|
kind: "async"
|
|
@@ -479,7 +472,7 @@ var aiSDKConfigs = [
|
|
|
479
472
|
kind: "Async"
|
|
480
473
|
}
|
|
481
474
|
},
|
|
482
|
-
// streamText -
|
|
475
|
+
// streamText - function returning stream
|
|
483
476
|
{
|
|
484
477
|
channelName: aiSDKChannels.streamText.channelName,
|
|
485
478
|
module: {
|
|
@@ -493,7 +486,7 @@ var aiSDKConfigs = [
|
|
|
493
486
|
}
|
|
494
487
|
},
|
|
495
488
|
{
|
|
496
|
-
channelName: aiSDKChannels.
|
|
489
|
+
channelName: aiSDKChannels.streamText.channelName,
|
|
497
490
|
module: {
|
|
498
491
|
name: "ai",
|
|
499
492
|
versionRange: ">=3.0.0",
|
|
@@ -501,7 +494,7 @@ var aiSDKConfigs = [
|
|
|
501
494
|
},
|
|
502
495
|
functionQuery: {
|
|
503
496
|
functionName: "streamText",
|
|
504
|
-
kind: "
|
|
497
|
+
kind: "Async"
|
|
505
498
|
}
|
|
506
499
|
},
|
|
507
500
|
// generateObject - async function
|
|
@@ -529,7 +522,7 @@ var aiSDKConfigs = [
|
|
|
529
522
|
kind: "Async"
|
|
530
523
|
}
|
|
531
524
|
},
|
|
532
|
-
// streamObject -
|
|
525
|
+
// streamObject - function returning stream
|
|
533
526
|
{
|
|
534
527
|
channelName: aiSDKChannels.streamObject.channelName,
|
|
535
528
|
module: {
|
|
@@ -543,7 +536,7 @@ var aiSDKConfigs = [
|
|
|
543
536
|
}
|
|
544
537
|
},
|
|
545
538
|
{
|
|
546
|
-
channelName: aiSDKChannels.
|
|
539
|
+
channelName: aiSDKChannels.streamObject.channelName,
|
|
547
540
|
module: {
|
|
548
541
|
name: "ai",
|
|
549
542
|
versionRange: ">=3.0.0",
|
|
@@ -551,7 +544,7 @@ var aiSDKConfigs = [
|
|
|
551
544
|
},
|
|
552
545
|
functionQuery: {
|
|
553
546
|
functionName: "streamObject",
|
|
554
|
-
kind: "
|
|
547
|
+
kind: "Async"
|
|
555
548
|
}
|
|
556
549
|
},
|
|
557
550
|
// Agent.generate - async method (v5 only)
|
|
@@ -778,6 +771,10 @@ var openRouterChannels = defineChannels("@openrouter/sdk", {
|
|
|
778
771
|
channelName: "callModel",
|
|
779
772
|
kind: "sync-stream"
|
|
780
773
|
}),
|
|
774
|
+
callModelTurn: channel({
|
|
775
|
+
channelName: "callModel.turn",
|
|
776
|
+
kind: "async"
|
|
777
|
+
}),
|
|
781
778
|
toolExecute: channel({
|
|
782
779
|
channelName: "tool.execute",
|
|
783
780
|
kind: "async"
|
|
@@ -101,7 +101,7 @@ var DefaultTracingChannel = class {
|
|
|
101
101
|
}
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
103
|
tracePromise(fn, _message, thisArg, ...args) {
|
|
104
|
-
return
|
|
104
|
+
return fn.apply(thisArg, args);
|
|
105
105
|
}
|
|
106
106
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
107
|
traceCallback(fn, _position, _message, thisArg, ...args) {
|
|
@@ -121,6 +121,7 @@ var iso = {
|
|
|
121
121
|
processOn: (_0, _1) => {
|
|
122
122
|
},
|
|
123
123
|
basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
|
|
124
|
+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
|
|
124
125
|
writeln: (text) => console.log(text)
|
|
125
126
|
};
|
|
126
127
|
var isomorph_default = iso;
|
|
@@ -441,10 +442,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
441
442
|
channelName: "streamText",
|
|
442
443
|
kind: "async"
|
|
443
444
|
}),
|
|
444
|
-
streamTextSync: channel({
|
|
445
|
-
channelName: "streamText.sync",
|
|
446
|
-
kind: "sync-stream"
|
|
447
|
-
}),
|
|
448
445
|
generateObject: channel({
|
|
449
446
|
channelName: "generateObject",
|
|
450
447
|
kind: "async"
|
|
@@ -453,10 +450,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
453
450
|
channelName: "streamObject",
|
|
454
451
|
kind: "async"
|
|
455
452
|
}),
|
|
456
|
-
streamObjectSync: channel({
|
|
457
|
-
channelName: "streamObject.sync",
|
|
458
|
-
kind: "sync-stream"
|
|
459
|
-
}),
|
|
460
453
|
agentGenerate: channel({
|
|
461
454
|
channelName: "Agent.generate",
|
|
462
455
|
kind: "async"
|
|
@@ -502,7 +495,7 @@ var aiSDKConfigs = [
|
|
|
502
495
|
kind: "Async"
|
|
503
496
|
}
|
|
504
497
|
},
|
|
505
|
-
// streamText -
|
|
498
|
+
// streamText - function returning stream
|
|
506
499
|
{
|
|
507
500
|
channelName: aiSDKChannels.streamText.channelName,
|
|
508
501
|
module: {
|
|
@@ -516,7 +509,7 @@ var aiSDKConfigs = [
|
|
|
516
509
|
}
|
|
517
510
|
},
|
|
518
511
|
{
|
|
519
|
-
channelName: aiSDKChannels.
|
|
512
|
+
channelName: aiSDKChannels.streamText.channelName,
|
|
520
513
|
module: {
|
|
521
514
|
name: "ai",
|
|
522
515
|
versionRange: ">=3.0.0",
|
|
@@ -524,7 +517,7 @@ var aiSDKConfigs = [
|
|
|
524
517
|
},
|
|
525
518
|
functionQuery: {
|
|
526
519
|
functionName: "streamText",
|
|
527
|
-
kind: "
|
|
520
|
+
kind: "Async"
|
|
528
521
|
}
|
|
529
522
|
},
|
|
530
523
|
// generateObject - async function
|
|
@@ -552,7 +545,7 @@ var aiSDKConfigs = [
|
|
|
552
545
|
kind: "Async"
|
|
553
546
|
}
|
|
554
547
|
},
|
|
555
|
-
// streamObject -
|
|
548
|
+
// streamObject - function returning stream
|
|
556
549
|
{
|
|
557
550
|
channelName: aiSDKChannels.streamObject.channelName,
|
|
558
551
|
module: {
|
|
@@ -566,7 +559,7 @@ var aiSDKConfigs = [
|
|
|
566
559
|
}
|
|
567
560
|
},
|
|
568
561
|
{
|
|
569
|
-
channelName: aiSDKChannels.
|
|
562
|
+
channelName: aiSDKChannels.streamObject.channelName,
|
|
570
563
|
module: {
|
|
571
564
|
name: "ai",
|
|
572
565
|
versionRange: ">=3.0.0",
|
|
@@ -574,7 +567,7 @@ var aiSDKConfigs = [
|
|
|
574
567
|
},
|
|
575
568
|
functionQuery: {
|
|
576
569
|
functionName: "streamObject",
|
|
577
|
-
kind: "
|
|
570
|
+
kind: "Async"
|
|
578
571
|
}
|
|
579
572
|
},
|
|
580
573
|
// Agent.generate - async method (v5 only)
|
|
@@ -801,6 +794,10 @@ var openRouterChannels = defineChannels("@openrouter/sdk", {
|
|
|
801
794
|
channelName: "callModel",
|
|
802
795
|
kind: "sync-stream"
|
|
803
796
|
}),
|
|
797
|
+
callModelTurn: channel({
|
|
798
|
+
channelName: "callModel.turn",
|
|
799
|
+
kind: "async"
|
|
800
|
+
}),
|
|
804
801
|
toolExecute: channel({
|
|
805
802
|
channelName: "tool.execute",
|
|
806
803
|
kind: "async"
|
package/dist/browser.d.mts
CHANGED
|
@@ -15756,7 +15756,7 @@ interface IsoTracingChannel<M = any> extends IsoTracingChannelCollection<M> {
|
|
|
15756
15756
|
subscribe(handlers: IsoChannelHandlers<M>): void;
|
|
15757
15757
|
unsubscribe(handlers: IsoChannelHandlers<M>): boolean;
|
|
15758
15758
|
traceSync<F extends (...args: any[]) => any>(fn: F, message?: M, thisArg?: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
15759
|
-
tracePromise<F extends (...args: any[]) => any
|
|
15759
|
+
tracePromise<F extends (...args: any[]) => PromiseLike<any>>(fn: F, message?: M, thisArg?: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
15760
15760
|
traceCallback<F extends (...args: any[]) => any>(fn: F, position?: number, message?: M, thisArg?: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
15761
15761
|
}
|
|
15762
15762
|
interface IsoChannelHandlers<M = any> {
|
|
@@ -20988,12 +20988,10 @@ interface WrapAISDKOptions {
|
|
|
20988
20988
|
denyOutputPaths?: string[];
|
|
20989
20989
|
}
|
|
20990
20990
|
/**
|
|
20991
|
-
* Wraps Vercel AI SDK methods with Braintrust tracing.
|
|
20992
|
-
* of generateText, streamText, generateObject, streamObject, Agent, experimental_Agent,
|
|
20993
|
-
* and ToolLoopAgent that automatically create spans and log inputs, outputs, and metrics.
|
|
20991
|
+
* Wraps Vercel AI SDK methods with Braintrust tracing.
|
|
20994
20992
|
*
|
|
20995
20993
|
* @param ai - The AI SDK namespace (e.g., import * as ai from "ai")
|
|
20996
|
-
* @returns
|
|
20994
|
+
* @returns AI SDK with Braintrust tracing.
|
|
20997
20995
|
*
|
|
20998
20996
|
* @example
|
|
20999
20997
|
* ```typescript
|
|
@@ -21074,9 +21072,8 @@ interface MiddlewareConfig {
|
|
|
21074
21072
|
declare function BraintrustMiddleware(config?: MiddlewareConfig): LanguageModelV2Middleware<any, any>;
|
|
21075
21073
|
|
|
21076
21074
|
/**
|
|
21077
|
-
* Wrap an `Anthropic` object (created with `new Anthropic(...)`)
|
|
21078
|
-
*
|
|
21079
|
-
* a no-op.
|
|
21075
|
+
* Wrap an `Anthropic` object (created with `new Anthropic(...)`) so calls emit
|
|
21076
|
+
* tracing-channel events that Braintrust plugins can consume.
|
|
21080
21077
|
*
|
|
21081
21078
|
* Currently, this only supports the `v4` API.
|
|
21082
21079
|
*
|
|
@@ -21094,31 +21091,12 @@ declare function wrapMastraAgent<T>(agent: T, _options?: {
|
|
|
21094
21091
|
}): T;
|
|
21095
21092
|
|
|
21096
21093
|
/**
|
|
21097
|
-
* Wraps the Claude Agent SDK with Braintrust tracing.
|
|
21098
|
-
*
|
|
21094
|
+
* Wraps the Claude Agent SDK with Braintrust tracing. Query calls only publish
|
|
21095
|
+
* tracing-channel events; the Claude Agent SDK plugin owns all span lifecycle
|
|
21096
|
+
* work, including root/task spans, LLM spans, tool spans, and sub-agent spans.
|
|
21099
21097
|
*
|
|
21100
21098
|
* @param sdk - The Claude Agent SDK module
|
|
21101
21099
|
* @returns Object with wrapped query, tool, and createSdkMcpServer functions
|
|
21102
|
-
*
|
|
21103
|
-
* @example
|
|
21104
|
-
* ```typescript
|
|
21105
|
-
* import * as claudeSDK from "@anthropic-ai/claude-agent-sdk";
|
|
21106
|
-
* import { wrapClaudeAgentSDK } from "braintrust";
|
|
21107
|
-
*
|
|
21108
|
-
* // Wrap once - returns { query, tool, createSdkMcpServer } with tracing built-in
|
|
21109
|
-
* const { query, tool, createSdkMcpServer } = wrapClaudeAgentSDK(claudeSDK);
|
|
21110
|
-
*
|
|
21111
|
-
* // Use normally - tracing is automatic
|
|
21112
|
-
* for await (const message of query({
|
|
21113
|
-
* prompt: "Hello, Claude!",
|
|
21114
|
-
* options: { model: "claude-haiku-4-5-20251001" }
|
|
21115
|
-
* })) {
|
|
21116
|
-
* console.log(message);
|
|
21117
|
-
* }
|
|
21118
|
-
*
|
|
21119
|
-
* // Tools created with wrapped tool() are automatically traced
|
|
21120
|
-
* const calculator = tool("calculator", "Does math", schema, handler);
|
|
21121
|
-
* ```
|
|
21122
21100
|
*/
|
|
21123
21101
|
declare function wrapClaudeAgentSDK<T extends object>(sdk: T): T;
|
|
21124
21102
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -15756,7 +15756,7 @@ interface IsoTracingChannel<M = any> extends IsoTracingChannelCollection<M> {
|
|
|
15756
15756
|
subscribe(handlers: IsoChannelHandlers<M>): void;
|
|
15757
15757
|
unsubscribe(handlers: IsoChannelHandlers<M>): boolean;
|
|
15758
15758
|
traceSync<F extends (...args: any[]) => any>(fn: F, message?: M, thisArg?: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
15759
|
-
tracePromise<F extends (...args: any[]) => any
|
|
15759
|
+
tracePromise<F extends (...args: any[]) => PromiseLike<any>>(fn: F, message?: M, thisArg?: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
15760
15760
|
traceCallback<F extends (...args: any[]) => any>(fn: F, position?: number, message?: M, thisArg?: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
15761
15761
|
}
|
|
15762
15762
|
interface IsoChannelHandlers<M = any> {
|
|
@@ -20988,12 +20988,10 @@ interface WrapAISDKOptions {
|
|
|
20988
20988
|
denyOutputPaths?: string[];
|
|
20989
20989
|
}
|
|
20990
20990
|
/**
|
|
20991
|
-
* Wraps Vercel AI SDK methods with Braintrust tracing.
|
|
20992
|
-
* of generateText, streamText, generateObject, streamObject, Agent, experimental_Agent,
|
|
20993
|
-
* and ToolLoopAgent that automatically create spans and log inputs, outputs, and metrics.
|
|
20991
|
+
* Wraps Vercel AI SDK methods with Braintrust tracing.
|
|
20994
20992
|
*
|
|
20995
20993
|
* @param ai - The AI SDK namespace (e.g., import * as ai from "ai")
|
|
20996
|
-
* @returns
|
|
20994
|
+
* @returns AI SDK with Braintrust tracing.
|
|
20997
20995
|
*
|
|
20998
20996
|
* @example
|
|
20999
20997
|
* ```typescript
|
|
@@ -21074,9 +21072,8 @@ interface MiddlewareConfig {
|
|
|
21074
21072
|
declare function BraintrustMiddleware(config?: MiddlewareConfig): LanguageModelV2Middleware<any, any>;
|
|
21075
21073
|
|
|
21076
21074
|
/**
|
|
21077
|
-
* Wrap an `Anthropic` object (created with `new Anthropic(...)`)
|
|
21078
|
-
*
|
|
21079
|
-
* a no-op.
|
|
21075
|
+
* Wrap an `Anthropic` object (created with `new Anthropic(...)`) so calls emit
|
|
21076
|
+
* tracing-channel events that Braintrust plugins can consume.
|
|
21080
21077
|
*
|
|
21081
21078
|
* Currently, this only supports the `v4` API.
|
|
21082
21079
|
*
|
|
@@ -21094,31 +21091,12 @@ declare function wrapMastraAgent<T>(agent: T, _options?: {
|
|
|
21094
21091
|
}): T;
|
|
21095
21092
|
|
|
21096
21093
|
/**
|
|
21097
|
-
* Wraps the Claude Agent SDK with Braintrust tracing.
|
|
21098
|
-
*
|
|
21094
|
+
* Wraps the Claude Agent SDK with Braintrust tracing. Query calls only publish
|
|
21095
|
+
* tracing-channel events; the Claude Agent SDK plugin owns all span lifecycle
|
|
21096
|
+
* work, including root/task spans, LLM spans, tool spans, and sub-agent spans.
|
|
21099
21097
|
*
|
|
21100
21098
|
* @param sdk - The Claude Agent SDK module
|
|
21101
21099
|
* @returns Object with wrapped query, tool, and createSdkMcpServer functions
|
|
21102
|
-
*
|
|
21103
|
-
* @example
|
|
21104
|
-
* ```typescript
|
|
21105
|
-
* import * as claudeSDK from "@anthropic-ai/claude-agent-sdk";
|
|
21106
|
-
* import { wrapClaudeAgentSDK } from "braintrust";
|
|
21107
|
-
*
|
|
21108
|
-
* // Wrap once - returns { query, tool, createSdkMcpServer } with tracing built-in
|
|
21109
|
-
* const { query, tool, createSdkMcpServer } = wrapClaudeAgentSDK(claudeSDK);
|
|
21110
|
-
*
|
|
21111
|
-
* // Use normally - tracing is automatic
|
|
21112
|
-
* for await (const message of query({
|
|
21113
|
-
* prompt: "Hello, Claude!",
|
|
21114
|
-
* options: { model: "claude-haiku-4-5-20251001" }
|
|
21115
|
-
* })) {
|
|
21116
|
-
* console.log(message);
|
|
21117
|
-
* }
|
|
21118
|
-
*
|
|
21119
|
-
* // Tools created with wrapped tool() are automatically traced
|
|
21120
|
-
* const calculator = tool("calculator", "Does math", schema, handler);
|
|
21121
|
-
* ```
|
|
21122
21100
|
*/
|
|
21123
21101
|
declare function wrapClaudeAgentSDK<T extends object>(sdk: T): T;
|
|
21124
21102
|
|