Skip to content

Commit 51bef8c

Browse files
authored
ref!: Reduce API to a minimum that makes sense (#2429)
ref [#1841](#1841) - Replaced the root `braintrust` export surface with an explicit allowlist, removing roughly 140 named exports—primarily internal helpers, implementation classes, schemas, constants, and low-level types. - Stopped named-exporting most SDK-owned request/result types. Retained types are primarily user extension points, including `StartSpanArgs`, `Span`, tracing context types, eval callbacks, reporters, template plugins, and durable-eval stores. - Removed package subpaths `braintrust/browser`, `braintrust/util`, and `braintrust/webpack-loader`; the util bundle is no longer built or published. - Kept the webpack loader private: `braintrust/next` now resolves its built loader directly instead of exposing it as a package entrypoint. - Removed public implementation/testing exports such as `_exportsForTestingOnly`, `_internalIso`, `_internalGetGlobalState`, `_internalSetInitialState`, `SpanImpl`, `NoopSpan`, `TestBackgroundLogger`, `ObjectFetcher`, and ID-generator classes. - Removed public runtime schemas and serialization internals, including prompt, stream-chunk, attachment-reference, logs-overflow, and propagation schemas/constants. - Removed lower-level project/building APIs such as `graph`, `Project`, `CodeFunction`, `CodePrompt`, `PromptBuilder`, `ScorerBuilder`, and `ToolBuilder`; the `projects` facade remains. - Removed miscellaneous convenience and implementation exports including `log`, `summarize`, `traceable`, `newId`, `permalink`, `deepCopyEvent`, template-registry internals, span fetchers, and logs-overflow helpers. - Removed deprecated APIs: - `BraintrustMiddleware` and `wrapAISDKModel` - `wrapMastraAgent` - `withExperiment` and `withDataset` - `toAIStreamResponse` - deprecated bundler aliases `esbuildPlugin`, `rollupPlugin`, `vitePlugin`, and `webpackPlugin` - deprecated `useDiagnosticChannelCompatShim` - `Experiment.close()`, `Dataset.close()`, and `Span.close()` - `EvalHooks.meta`, `EvalResultWithSummary.toString()`, and `Score.error` - Removed legacy aliases and call shapes: - `initExperiment` - string-first `init()` and `initDataset()` overloads - dataset `useOutput` mode and the `output` record alias - deprecated event `inputs` and `datasetRecordId` fields - `wrapOpenAIv4` - Changed `EvalResultWithSummary` from an exported runtime class to a plain `{ summary, results }` result shape. - Restricted public span parenting to opaque `PropagationContext`; serialized span-slug strings remain internal plumbing. The public type is still named `StartSpanArgs`. - Added `configureContextManager()` and `ContextManager.getCurrentSpanStore()` as the supported context integration mechanism, replacing global symbols and direct state mutation. - Moved instrumentation-only APIs off the root: - `configureInstrumentation`, `InstrumentationConfig`, and Eve/Flue instrumentation remain under `braintrust/instrumentation`. - `registerOtelFlush` now lives there as the narrow OTEL hook. - Simplified OTEL integration: - Uses `configureContextManager()` instead of internal globals. - No longer overrides ID generation or V4 span serialization. - Replaced `contextFromSpanExport(string)` with `contextFromSpan(span)`. - `parentFromHeaders()` now returns opaque W3C propagation context. - Environment and `.env.braintrust` handling is self-contained and Edge-safe. - Removed the OTEL-specific exported ID generator. - Migrated Temporal propagation from private serialized span headers to standard `traceparent`, `tracestate`, and `baggage`, covering client→workflow, child workflow, and same-/cross-worker activity parenting. - Reworked `@braintrust/browser` to install a browser `ContextManager` through the public configuration API instead of mutating core isomorph internals. - Updated OpenAI Agents and the Vercel adapter to avoid `braintrust/util` and the exported `BraintrustStreamChunk`; the adapter now derives its stream chunk type from `BraintrustStream`. - Canonicalized instrumentation config keys by removing typed aliases such as `vercel`, `google`, `cursor`, `bedrock`, and `awsBedrock`; environment spellings still map to canonical keys. - Updated smoke tests, integration tests, Deno/browser coverage, and e2e scenarios to use only the curated public surface; added explicit tests for the allowed root types and published package entrypoints.
1 parent 34bff9d commit 51bef8c

149 files changed

Lines changed: 1406 additions & 3917 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"braintrust": major
3+
"@braintrust/otel": major
4+
"@braintrust/vercel-ai-sdk": major
5+
"@braintrust/browser": patch
6+
"@braintrust/openai-agents": patch
7+
"@braintrust/temporal": patch
8+
---
9+
10+
ref!: Reduce API to a minimum that makes sense

‎e2e/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"test:e2e:record": "node ./scripts/run-record-tests.mjs"
99
},
1010
"devDependencies": {
11+
"@braintrust/browser": "workspace:^",
1112
"@braintrust/langchain-js": "workspace:^",
1213
"@braintrust/otel": "workspace:^",
1314
"@braintrust/seinfeld": "workspace:^",

‎e2e/scenarios/cloudflare-agents-instrumentation/vite.config.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ const agentsPackageName =
77
const instrumentationMode =
88
process.env.CLOUDFLARE_AGENTS_INSTRUMENTATION_MODE ?? "auto";
99
const braintrustPlugins =
10-
instrumentationMode === "auto"
11-
? braintrustVitePlugin({ useDiagnosticChannelCompatShim: true })
12-
: [];
10+
instrumentationMode === "auto" ? braintrustVitePlugin({ browser: true }) : [];
1311

1412
export default defineConfig({
1513
define: {

‎e2e/scenarios/cloudflare-ai-chat-instrumentation/vite.config.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ export default defineConfig({
2525
__OPENAI_BASE_URL__: JSON.stringify(process.env.OPENAI_BASE_URL),
2626
},
2727
plugins: [
28-
...(mode === "auto"
29-
? [braintrustVitePlugin({ useDiagnosticChannelCompatShim: true })]
30-
: []),
28+
...(mode === "auto" ? [braintrustVitePlugin({ browser: true })] : []),
3129
cloudflare({ configPath: "./wrangler.toml", inspectorPort: 0 }),
3230
],
3331
resolve: {

‎e2e/scenarios/cloudflare-think-instrumentation/vite.config.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ export default defineConfig({
1313
),
1414
},
1515
plugins: [
16-
...(manual
17-
? []
18-
: [braintrustVitePlugin({ useDiagnosticChannelCompatShim: true })]),
16+
...(manual ? [] : [braintrustVitePlugin({ browser: true })]),
1917
cloudflare({ inspectorPort: 0 }),
2018
],
2119
resolve: {

0 commit comments

Comments
 (0)