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.
Files changed (32) hide show
  1. package/dev/dist/index.js +1859 -1338
  2. package/dev/dist/index.mjs +1774 -1253
  3. package/dist/auto-instrumentations/bundler/esbuild.cjs +12 -15
  4. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  5. package/dist/auto-instrumentations/bundler/rollup.cjs +12 -15
  6. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  7. package/dist/auto-instrumentations/bundler/vite.cjs +12 -15
  8. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +12 -15
  10. package/dist/auto-instrumentations/bundler/webpack.cjs +12 -15
  11. package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
  12. package/dist/auto-instrumentations/{chunk-ZK2IYER2.mjs → chunk-NY4CGTN6.mjs} +1 -1
  13. package/dist/auto-instrumentations/{chunk-AKEXR4AL.mjs → chunk-YCKND42U.mjs} +12 -15
  14. package/dist/auto-instrumentations/hook.mjs +12 -15
  15. package/dist/auto-instrumentations/index.cjs +12 -15
  16. package/dist/auto-instrumentations/index.mjs +1 -1
  17. package/dist/browser.d.mts +8 -30
  18. package/dist/browser.d.ts +8 -30
  19. package/dist/browser.js +4836 -6828
  20. package/dist/browser.mjs +4836 -6828
  21. package/dist/cli.js +1507 -986
  22. package/dist/edge-light.js +9173 -11163
  23. package/dist/edge-light.mjs +9173 -11163
  24. package/dist/index.d.mts +8 -30
  25. package/dist/index.d.ts +8 -30
  26. package/dist/index.js +4747 -6739
  27. package/dist/index.mjs +4748 -6740
  28. package/dist/instrumentation/index.js +1735 -1236
  29. package/dist/instrumentation/index.mjs +1735 -1236
  30. package/dist/workerd.js +9173 -11163
  31. package/dist/workerd.mjs +9173 -11163
  32. package/package.json +2 -2
package/dist/index.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>(fn: F, message?: M, thisArg?: ThisParameterType<F>, ...args: Parameters<F>): Promise<Awaited<ReturnType<F>>>;
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. Returns wrapped versions
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 Object with AI SDK methods with Braintrust tracing
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(...)`) to add tracing. If Braintrust is
21078
- * not configured, nothing will be traced. If this is not an `Anthropic` object, this function is
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. This returns wrapped versions
21098
- * of query and tool that automatically trace all agent interactions.
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/index.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>(fn: F, message?: M, thisArg?: ThisParameterType<F>, ...args: Parameters<F>): Promise<Awaited<ReturnType<F>>>;
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. Returns wrapped versions
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 Object with AI SDK methods with Braintrust tracing
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(...)`) to add tracing. If Braintrust is
21078
- * not configured, nothing will be traced. If this is not an `Anthropic` object, this function is
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. This returns wrapped versions
21098
- * of query and tool that automatically trace all agent interactions.
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