braintrust
Advanced tools
| import { | ||
| unplugin | ||
| } from "./chunk-S4374IP6.mjs"; | ||
| // src/auto-instrumentations/bundler/webpack.ts | ||
| function braintrustWebpackPlugin(options = {}) { | ||
| const { useDiagnosticChannelCompatShim = false, ...pluginOptions } = options; | ||
| return unplugin.webpack({ | ||
| ...pluginOptions, | ||
| browser: useDiagnosticChannelCompatShim | ||
| }); | ||
| } | ||
| var webpackPlugin = unplugin.webpack; | ||
| export { | ||
| braintrustWebpackPlugin, | ||
| webpackPlugin | ||
| }; |
| import { | ||
| aiSDKConfigs, | ||
| anthropicConfigs, | ||
| bedrockRuntimeConfigs, | ||
| channel, | ||
| claudeAgentSDKConfigs, | ||
| cohereConfigs, | ||
| cursorSDKConfigs, | ||
| defineChannels, | ||
| genkitConfigs, | ||
| gitHubCopilotConfigs, | ||
| googleADKConfigs, | ||
| googleGenAIConfigs, | ||
| groqConfigs, | ||
| huggingFaceConfigs, | ||
| langchainConfigs, | ||
| mistralConfigs, | ||
| openAIAgentsCoreConfigs, | ||
| openAICodexConfigs, | ||
| openRouterAgentConfigs, | ||
| openRouterConfigs, | ||
| openaiConfigs, | ||
| piCodingAgentConfigs | ||
| } from "./chunk-W4E36GIW.mjs"; | ||
| import { | ||
| applySpecialCasePatch | ||
| } from "./chunk-J57YF7WS.mjs"; | ||
| // src/auto-instrumentations/bundler/plugin.ts | ||
| import { createUnplugin } from "unplugin"; | ||
| import { | ||
| create | ||
| } from "@apm-js-collab/code-transformer"; | ||
| import { extname, join, sep } from "path"; | ||
| import { readFileSync } from "fs"; | ||
| import { fileURLToPath } from "url"; | ||
| import moduleDetailsFromPath from "module-details-from-path"; | ||
| // src/instrumentation/config.ts | ||
| var envIntegrationAliases = { | ||
| openai: "openai", | ||
| "openai-codex": "openaiCodexSDK", | ||
| "openai-codex-sdk": "openaiCodexSDK", | ||
| openaicodexsdk: "openaiCodexSDK", | ||
| codex: "openaiCodexSDK", | ||
| "codex-sdk": "openaiCodexSDK", | ||
| "pi-coding-agent": "piCodingAgent", | ||
| "pi-coding-agent-sdk": "piCodingAgent", | ||
| picodingagent: "piCodingAgent", | ||
| picodingagentsdk: "piCodingAgent", | ||
| "@earendil-works/pi-coding-agent": "piCodingAgent", | ||
| strandsAgentSDK: "strandsAgentSDK", | ||
| strandsagentsdk: "strandsAgentSDK", | ||
| "strands-agent-sdk": "strandsAgentSDK", | ||
| "@strands-agents/sdk": "strandsAgentSDK", | ||
| anthropic: "anthropic", | ||
| aisdk: "aisdk", | ||
| "ai-sdk": "aisdk", | ||
| "vercel-ai": "aisdk", | ||
| vercel: "vercel", | ||
| claudeagentsdk: "claudeAgentSDK", | ||
| "claude-agent-sdk": "claudeAgentSDK", | ||
| cursor: "cursor", | ||
| "cursor-sdk": "cursorSDK", | ||
| cursorsdk: "cursorSDK", | ||
| flue: "flue", | ||
| "flue-runtime": "flue", | ||
| mastra: "mastra", | ||
| "openai-agents": "openAIAgents", | ||
| openaiagents: "openAIAgents", | ||
| "openai-agents-core": "openAIAgents", | ||
| openaiagentscore: "openAIAgents", | ||
| google: "google", | ||
| "google-genai": "googleGenAI", | ||
| googlegenai: "googleGenAI", | ||
| huggingface: "huggingface", | ||
| openrouter: "openrouter", | ||
| openrouteragent: "openrouterAgent", | ||
| "openrouter-agent": "openrouterAgent", | ||
| mistral: "mistral", | ||
| googleadk: "googleADK", | ||
| "google-adk": "googleADK", | ||
| cohere: "cohere", | ||
| groq: "groq", | ||
| "groq-sdk": "groq", | ||
| bedrock: "bedrock", | ||
| "aws-bedrock": "awsBedrock", | ||
| awsbedrock: "awsBedrock", | ||
| "aws-bedrock-runtime": "awsBedrockRuntime", | ||
| awsbedrockruntime: "awsBedrockRuntime", | ||
| "@aws-sdk/client-bedrock-runtime": "awsBedrockRuntime", | ||
| genkit: "genkit", | ||
| "firebase-genkit": "genkit", | ||
| githubcopilot: "gitHubCopilot", | ||
| "github-copilot": "gitHubCopilot", | ||
| "copilot-sdk": "gitHubCopilot", | ||
| langchain: "langchain", | ||
| "langchain-js": "langchain", | ||
| "@langchain": "langchain", | ||
| langgraph: "langgraph" | ||
| }; | ||
| function readDisabledInstrumentationEnvConfig(disabledList) { | ||
| const integrations = {}; | ||
| if (disabledList) { | ||
| for (const value of disabledList.split(",")) { | ||
| const rawSdk = value.trim(); | ||
| const sdk = rawSdk.toLowerCase(); | ||
| if (sdk.length > 0) { | ||
| integrations[envIntegrationAliases[rawSdk] ?? envIntegrationAliases[sdk] ?? sdk] = false; | ||
| } | ||
| } | ||
| } | ||
| return { integrations }; | ||
| } | ||
| function isInstrumentationIntegrationDisabled(integrations, ...names) { | ||
| return names.some((name) => integrations?.[name] === false); | ||
| } | ||
| // src/instrumentation/plugins/flue-channels.ts | ||
| var flueChannels = defineChannels("@flue/runtime", { | ||
| createContext: channel({ | ||
| channelName: "createFlueContext", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/auto-instrumentations/configs/flue.ts | ||
| var flueVersionRange = ">=0.8.0 <1.0.0"; | ||
| var flueConfigs = [ | ||
| { | ||
| channelName: flueChannels.createContext.channelName, | ||
| module: { | ||
| name: "@flue/runtime", | ||
| versionRange: flueVersionRange, | ||
| filePath: "dist/internal.mjs" | ||
| }, | ||
| functionQuery: { | ||
| functionName: "createFlueContext", | ||
| kind: "Sync" | ||
| } | ||
| } | ||
| ]; | ||
| // src/instrumentation/plugins/strands-agent-sdk-channels.ts | ||
| var strandsAgentSDKChannels = defineChannels("@strands-agents/sdk", { | ||
| agentStream: channel({ | ||
| channelName: "Agent.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| graphStream: channel({ | ||
| channelName: "Graph.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| swarmStream: channel({ | ||
| channelName: "Swarm.stream", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/auto-instrumentations/configs/strands-agent-sdk.ts | ||
| var strandsAgentSDKVersionRange = ">=1.0.0 <2.0.0"; | ||
| var strandsAgentSDKConfigs = [ | ||
| { | ||
| channelName: strandsAgentSDKChannels.agentStream.channelName, | ||
| module: { | ||
| name: "@strands-agents/sdk", | ||
| versionRange: strandsAgentSDKVersionRange, | ||
| filePath: "dist/src/agent/agent.js" | ||
| }, | ||
| functionQuery: { | ||
| className: "Agent", | ||
| methodName: "stream", | ||
| kind: "Sync" | ||
| } | ||
| }, | ||
| { | ||
| channelName: strandsAgentSDKChannels.graphStream.channelName, | ||
| module: { | ||
| name: "@strands-agents/sdk", | ||
| versionRange: strandsAgentSDKVersionRange, | ||
| filePath: "dist/src/multiagent/graph.js" | ||
| }, | ||
| functionQuery: { | ||
| className: "Graph", | ||
| methodName: "stream", | ||
| kind: "Sync" | ||
| } | ||
| }, | ||
| { | ||
| channelName: strandsAgentSDKChannels.swarmStream.channelName, | ||
| module: { | ||
| name: "@strands-agents/sdk", | ||
| versionRange: strandsAgentSDKVersionRange, | ||
| filePath: "dist/src/multiagent/swarm.js" | ||
| }, | ||
| functionQuery: { | ||
| className: "Swarm", | ||
| methodName: "stream", | ||
| kind: "Sync" | ||
| } | ||
| } | ||
| ]; | ||
| // src/auto-instrumentations/configs/all.ts | ||
| var defaultInstrumentationConfigGroups = [ | ||
| { integrations: ["openai"], configs: openaiConfigs }, | ||
| { | ||
| integrations: ["openaiCodexSDK"], | ||
| configs: openAICodexConfigs | ||
| }, | ||
| { integrations: ["anthropic"], configs: anthropicConfigs }, | ||
| { | ||
| integrations: ["bedrock", "awsBedrock", "awsBedrockRuntime"], | ||
| configs: bedrockRuntimeConfigs | ||
| }, | ||
| { | ||
| integrations: ["aisdk", "vercel"], | ||
| configs: aiSDKConfigs | ||
| }, | ||
| { | ||
| integrations: ["claudeAgentSDK"], | ||
| configs: claudeAgentSDKConfigs | ||
| }, | ||
| { integrations: ["cursor", "cursorSDK"], configs: cursorSDKConfigs }, | ||
| { | ||
| integrations: ["openAIAgents"], | ||
| configs: openAIAgentsCoreConfigs | ||
| }, | ||
| { | ||
| integrations: ["google", "googleGenAI"], | ||
| configs: googleGenAIConfigs | ||
| }, | ||
| { integrations: ["huggingface"], configs: huggingFaceConfigs }, | ||
| { | ||
| integrations: ["langchain", "langgraph"], | ||
| configs: langchainConfigs | ||
| }, | ||
| { integrations: ["openrouter"], configs: openRouterConfigs }, | ||
| { | ||
| integrations: ["openrouterAgent"], | ||
| configs: openRouterAgentConfigs | ||
| }, | ||
| { integrations: ["mistral"], configs: mistralConfigs }, | ||
| { integrations: ["googleADK"], configs: googleADKConfigs }, | ||
| { integrations: ["cohere"], configs: cohereConfigs }, | ||
| { integrations: ["groq"], configs: groqConfigs }, | ||
| { | ||
| integrations: ["genkit"], | ||
| configs: genkitConfigs | ||
| }, | ||
| { | ||
| integrations: ["gitHubCopilot"], | ||
| configs: gitHubCopilotConfigs | ||
| }, | ||
| { | ||
| integrations: ["piCodingAgent"], | ||
| configs: piCodingAgentConfigs | ||
| }, | ||
| { | ||
| integrations: ["strandsAgentSDK"], | ||
| configs: strandsAgentSDKConfigs | ||
| }, | ||
| { | ||
| integrations: ["flue"], | ||
| configs: flueConfigs | ||
| } | ||
| // Note: `@mastra/core` is not listed here because its instrumentation | ||
| // doesn't go through the AST `code-transformer` matcher — Mastra's | ||
| // content-hashed chunks make `filePath`-based matching too brittle. | ||
| // Instead it's handled by the source-replacement entry in | ||
| // `loader/special-case-patches.ts`, which both the runtime loader | ||
| // (`hook.mjs` → `cjs-patch.ts`/`esm-hook.mts`) and the bundler plugin | ||
| // (`bundler/plugin.ts`) call. The `mastra` env-var disable still works. | ||
| ]; | ||
| function getDefaultInstrumentationConfigs({ | ||
| additionalInstrumentations, | ||
| disabledIntegrationConfig, | ||
| disabledIntegrations | ||
| } = {}) { | ||
| const disabledConfig = disabledIntegrationConfig ?? (disabledIntegrations ? readDisabledInstrumentationEnvConfig( | ||
| [...disabledIntegrations].join(",") | ||
| ).integrations : void 0); | ||
| return [ | ||
| ...defaultInstrumentationConfigGroups.flatMap( | ||
| ({ configs, integrations }) => isInstrumentationIntegrationDisabled(disabledConfig, ...integrations) ? [] : configs | ||
| ), | ||
| ...additionalInstrumentations ?? [] | ||
| ]; | ||
| } | ||
| // src/auto-instrumentations/bundler/plugin.ts | ||
| function getModuleVersion(basedir) { | ||
| try { | ||
| const packageJsonPath = join(basedir, "package.json"); | ||
| const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")); | ||
| if (packageJson.version) { | ||
| return packageJson.version; | ||
| } | ||
| } catch (error) { | ||
| } | ||
| return void 0; | ||
| } | ||
| var unplugin = createUnplugin( | ||
| (options = {}) => { | ||
| const allInstrumentations = getDefaultInstrumentationConfigs({ | ||
| additionalInstrumentations: options.instrumentations | ||
| }); | ||
| const dcModule = options.browser === false ? void 0 : "dc-browser"; | ||
| const instrumentationMatcher = create(allInstrumentations, dcModule); | ||
| return { | ||
| name: "code-transformer", | ||
| enforce: "pre", | ||
| transform(code, id) { | ||
| if (!id) { | ||
| return null; | ||
| } | ||
| const filePath = id.startsWith("file:") ? fileURLToPath(id) : id; | ||
| const ext = extname(filePath); | ||
| let isModule = ext === ".mjs" || ext === ".ts" || ext === ".tsx"; | ||
| if (ext === ".js") { | ||
| isModule = code.includes("export ") || code.includes("import "); | ||
| } | ||
| const normalizedForPlatform = filePath.split("/").join(sep); | ||
| const moduleDetails = moduleDetailsFromPath(normalizedForPlatform); | ||
| if (!moduleDetails) { | ||
| return null; | ||
| } | ||
| const moduleName = moduleDetails.name; | ||
| const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/"); | ||
| const moduleVersion = getModuleVersion(moduleDetails.basedir); | ||
| if (options.browser !== true) { | ||
| const patched = applySpecialCasePatch({ | ||
| packageName: moduleName, | ||
| modulePath: normalizedModulePath, | ||
| source: code, | ||
| format: isModule ? "esm" : "cjs" | ||
| }); | ||
| if (patched !== null) { | ||
| return { code: patched, map: null }; | ||
| } | ||
| } | ||
| if (!moduleVersion) { | ||
| console.warn( | ||
| `No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.` | ||
| ); | ||
| return null; | ||
| } | ||
| const transformer = instrumentationMatcher.getTransformer( | ||
| moduleName, | ||
| moduleVersion, | ||
| normalizedModulePath | ||
| ); | ||
| if (!transformer) { | ||
| return null; | ||
| } | ||
| try { | ||
| const moduleType = isModule ? "esm" : "cjs"; | ||
| const result = transformer.transform(code, moduleType); | ||
| const transformedCode = result.code.replace( | ||
| /const \{tracingChannel: ([A-Za-z_$][\w$]*)\} = ([A-Za-z_$][\w$]*);/g, | ||
| "const $1 = $2.tracingChannel;" | ||
| ); | ||
| return { | ||
| code: transformedCode, | ||
| map: result.map | ||
| }; | ||
| } catch (error) { | ||
| console.warn(`Code transformation failed for ${id}: ${error}`); | ||
| return null; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| ); | ||
| export { | ||
| unplugin | ||
| }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| // src/auto-instrumentations/patch-tracing-channel.ts | ||
| function patchTracingChannel(tracingChannelFn) { | ||
| const dummyChannel = tracingChannelFn("__braintrust_probe__"); | ||
| const TracingChannel = _optionalChain([dummyChannel, 'optionalAccess', _2 => _2.constructor]); | ||
| if (!_optionalChain([TracingChannel, 'optionalAccess', _3 => _3.prototype])) { | ||
| return; | ||
| } | ||
| if (!Object.getOwnPropertyDescriptor(TracingChannel.prototype, "hasSubscribers")) { | ||
| Object.defineProperty(TracingChannel.prototype, "hasSubscribers", { | ||
| configurable: true, | ||
| enumerable: false, | ||
| get() { | ||
| return Boolean( | ||
| _optionalChain([this, 'access', _4 => _4.start, 'optionalAccess', _5 => _5.hasSubscribers]) || _optionalChain([this, 'access', _6 => _6.end, 'optionalAccess', _7 => _7.hasSubscribers]) || _optionalChain([this, 'access', _8 => _8.asyncStart, 'optionalAccess', _9 => _9.hasSubscribers]) || _optionalChain([this, 'access', _10 => _10.asyncEnd, 'optionalAccess', _11 => _11.hasSubscribers]) || _optionalChain([this, 'access', _12 => _12.error, 'optionalAccess', _13 => _13.hasSubscribers]) | ||
| ); | ||
| } | ||
| }); | ||
| } | ||
| if (TracingChannel.prototype.tracePromise) { | ||
| TracingChannel.prototype.tracePromise = function(fn, context = {}, thisArg, ...args) { | ||
| const start = this.start; | ||
| const end = this.end; | ||
| const asyncStart = this.asyncStart; | ||
| const asyncEnd = this.asyncEnd; | ||
| const error = this.error; | ||
| function publishRejected(err) { | ||
| context.error = err; | ||
| _optionalChain([error, 'optionalAccess', _14 => _14.publish, 'call', _15 => _15(context)]); | ||
| _optionalChain([asyncStart, 'optionalAccess', _16 => _16.publish, 'call', _17 => _17(context)]); | ||
| _optionalChain([asyncEnd, 'optionalAccess', _18 => _18.publish, 'call', _19 => _19(context)]); | ||
| } | ||
| function publishResolved(result) { | ||
| context.result = result; | ||
| _optionalChain([asyncStart, 'optionalAccess', _20 => _20.publish, 'call', _21 => _21(context)]); | ||
| _optionalChain([asyncEnd, 'optionalAccess', _22 => _22.publish, 'call', _23 => _23(context)]); | ||
| } | ||
| return start.runStores(context, () => { | ||
| try { | ||
| const result = Reflect.apply(fn, thisArg, args); | ||
| _optionalChain([end, 'optionalAccess', _24 => _24.publish, 'call', _25 => _25(context)]); | ||
| if (result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function") { | ||
| if (result.constructor === Promise) { | ||
| return result.then( | ||
| (res) => { | ||
| publishResolved(res); | ||
| return res; | ||
| }, | ||
| (err) => { | ||
| publishRejected(err); | ||
| return Promise.reject(err); | ||
| } | ||
| ); | ||
| } | ||
| void result.then( | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (resolved) => { | ||
| try { | ||
| publishResolved(resolved); | ||
| } catch (e) { | ||
| } | ||
| }, | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (err) => { | ||
| try { | ||
| publishRejected(err); | ||
| } catch (e2) { | ||
| } | ||
| } | ||
| ); | ||
| return result; | ||
| } | ||
| context.result = result; | ||
| _optionalChain([asyncStart, 'optionalAccess', _26 => _26.publish, 'call', _27 => _27(context)]); | ||
| _optionalChain([asyncEnd, 'optionalAccess', _28 => _28.publish, 'call', _29 => _29(context)]); | ||
| return result; | ||
| } catch (err) { | ||
| context.error = err; | ||
| _optionalChain([error, 'optionalAccess', _30 => _30.publish, 'call', _31 => _31(context)]); | ||
| _optionalChain([end, 'optionalAccess', _32 => _32.publish, 'call', _33 => _33(context)]); | ||
| throw err; | ||
| } | ||
| }); | ||
| }; | ||
| } | ||
| } | ||
| // src/isomorph.ts | ||
| var DefaultAsyncLocalStorage = class { | ||
| constructor() { | ||
| } | ||
| enterWith(_) { | ||
| } | ||
| run(_, callback) { | ||
| return callback(); | ||
| } | ||
| getStore() { | ||
| return void 0; | ||
| } | ||
| }; | ||
| var DefaultChannel = (_class = class { | ||
| constructor(name) {;_class.prototype.__init.call(this); | ||
| this.name = name; | ||
| } | ||
| __init() {this.hasSubscribers = false} | ||
| subscribe(_subscription) { | ||
| } | ||
| unsubscribe(_subscription) { | ||
| return false; | ||
| } | ||
| bindStore(_store, _transform) { | ||
| } | ||
| unbindStore(_store) { | ||
| return false; | ||
| } | ||
| publish(_message) { | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| runStores(_message, fn, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| }, _class); | ||
| var DefaultTracingChannel = class { | ||
| constructor(nameOrChannels) { | ||
| if (typeof nameOrChannels === "string") { | ||
| this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`); | ||
| this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`); | ||
| this.asyncStart = new DefaultChannel( | ||
| `tracing:${nameOrChannels}:asyncStart` | ||
| ); | ||
| this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`); | ||
| this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`); | ||
| return; | ||
| } | ||
| this.start = _nullishCoalesce(nameOrChannels.start, () => ( new DefaultChannel("tracing:start"))); | ||
| this.end = _nullishCoalesce(nameOrChannels.end, () => ( new DefaultChannel("tracing:end"))); | ||
| this.asyncStart = _nullishCoalesce(nameOrChannels.asyncStart, () => ( new DefaultChannel("tracing:asyncStart"))); | ||
| this.asyncEnd = _nullishCoalesce(nameOrChannels.asyncEnd, () => ( new DefaultChannel("tracing:asyncEnd"))); | ||
| this.error = _nullishCoalesce(nameOrChannels.error, () => ( new DefaultChannel("tracing:error"))); | ||
| } | ||
| get hasSubscribers() { | ||
| return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers; | ||
| } | ||
| subscribe(_handlers) { | ||
| } | ||
| unsubscribe(_handlers) { | ||
| return false; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| traceSync(fn, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| tracePromise(fn, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| traceCallback(fn, _position, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| }; | ||
| var iso = { | ||
| buildType: "unknown", | ||
| // Will be set by configureBrowser() or configureNode() | ||
| getRepoInfo: async (_settings) => void 0, | ||
| getPastNAncestors: async () => [], | ||
| getEnv: (_name) => void 0, | ||
| getBraintrustApiKey: async () => void 0, | ||
| getCallerLocation: () => void 0, | ||
| newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(), | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels), | ||
| processOn: (_0, _1) => { | ||
| }, | ||
| basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath, | ||
| // eslint-disable-next-line no-restricted-properties -- preserving intentional console usage. | ||
| writeln: (text) => console.log(text) | ||
| }; | ||
| var isomorph_default = iso; | ||
| // src/instrumentation/core/channel-definitions.ts | ||
| function channel(spec) { | ||
| return spec; | ||
| } | ||
| function defineChannels(pkg, channels) { | ||
| return Object.fromEntries( | ||
| Object.entries(channels).map(([key, spec]) => { | ||
| const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`; | ||
| if (spec.kind === "async") { | ||
| const asyncSpec = spec; | ||
| const tracingChannel2 = () => isomorph_default.newTracingChannel( | ||
| fullChannelName | ||
| ); | ||
| return [ | ||
| key, | ||
| { | ||
| ...asyncSpec, | ||
| tracingChannel: tracingChannel2, | ||
| tracePromise: (fn, context) => tracingChannel2().tracePromise( | ||
| fn, | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| context | ||
| ) | ||
| } | ||
| ]; | ||
| } | ||
| const syncSpec = spec; | ||
| const tracingChannel = () => isomorph_default.newTracingChannel( | ||
| fullChannelName | ||
| ); | ||
| return [ | ||
| key, | ||
| { | ||
| ...syncSpec, | ||
| tracingChannel, | ||
| traceSync: (fn, context) => tracingChannel().traceSync( | ||
| fn, | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| context | ||
| ) | ||
| } | ||
| ]; | ||
| }) | ||
| ); | ||
| } | ||
| // src/instrumentation/plugins/openai-channels.ts | ||
| var openAIChannels = defineChannels("openai", { | ||
| chatCompletionsCreate: channel({ | ||
| channelName: "chat.completions.create", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel({ | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| }), | ||
| betaChatCompletionsParse: channel({ | ||
| channelName: "beta.chat.completions.parse", | ||
| kind: "async" | ||
| }), | ||
| betaChatCompletionsStream: channel({ | ||
| channelName: "beta.chat.completions.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| moderationsCreate: channel({ | ||
| channelName: "moderations.create", | ||
| kind: "async" | ||
| }), | ||
| responsesCreate: channel({ | ||
| channelName: "responses.create", | ||
| kind: "async" | ||
| }), | ||
| responsesStream: channel({ | ||
| channelName: "responses.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| responsesParse: channel({ | ||
| channelName: "responses.parse", | ||
| kind: "async" | ||
| }), | ||
| responsesCompact: channel({ | ||
| channelName: "responses.compact", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openai-codex-channels.ts | ||
| var openAICodexChannels = defineChannels("@openai/codex-sdk", { | ||
| run: channel({ | ||
| channelName: "Thread.run", | ||
| kind: "async" | ||
| }), | ||
| runStreamed: channel({ | ||
| channelName: "Thread.runStreamed", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/anthropic-channels.ts | ||
| var anthropicChannels = defineChannels("@anthropic-ai/sdk", { | ||
| messagesCreate: channel({ | ||
| channelName: "messages.create", | ||
| kind: "async" | ||
| }), | ||
| betaMessagesCreate: channel({ | ||
| channelName: "beta.messages.create", | ||
| kind: "async" | ||
| }), | ||
| betaMessagesToolRunner: channel({ | ||
| channelName: "beta.messages.toolRunner", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/ai-sdk-channels.ts | ||
| var aiSDKChannels = defineChannels("ai", { | ||
| generateText: channel({ | ||
| channelName: "generateText", | ||
| kind: "async" | ||
| }), | ||
| streamText: channel({ | ||
| channelName: "streamText", | ||
| kind: "async" | ||
| }), | ||
| streamTextSync: channel({ | ||
| channelName: "streamText.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| generateObject: channel({ | ||
| channelName: "generateObject", | ||
| kind: "async" | ||
| }), | ||
| streamObject: channel({ | ||
| channelName: "streamObject", | ||
| kind: "async" | ||
| }), | ||
| streamObjectSync: channel({ | ||
| channelName: "streamObject.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| embed: channel( | ||
| { | ||
| channelName: "embed", | ||
| kind: "async" | ||
| } | ||
| ), | ||
| embedMany: channel({ | ||
| channelName: "embedMany", | ||
| kind: "async" | ||
| }), | ||
| rerank: channel({ | ||
| channelName: "rerank", | ||
| kind: "async" | ||
| }), | ||
| agentGenerate: channel({ | ||
| channelName: "Agent.generate", | ||
| kind: "async" | ||
| }), | ||
| agentStream: channel({ | ||
| channelName: "Agent.stream", | ||
| kind: "async" | ||
| }), | ||
| agentStreamSync: channel({ | ||
| channelName: "Agent.stream.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| toolLoopAgentGenerate: channel({ | ||
| channelName: "ToolLoopAgent.generate", | ||
| kind: "async" | ||
| }), | ||
| toolLoopAgentStream: channel({ | ||
| channelName: "ToolLoopAgent.stream", | ||
| kind: "async" | ||
| }), | ||
| v7CreateTelemetryDispatcher: channel({ | ||
| channelName: "createTelemetryDispatcher", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/claude-agent-sdk-channels.ts | ||
| var claudeAgentSDKChannels = defineChannels( | ||
| "@anthropic-ai/claude-agent-sdk", | ||
| { | ||
| query: channel({ | ||
| channelName: "query", | ||
| kind: "sync-stream" | ||
| }) | ||
| } | ||
| ); | ||
| // src/instrumentation/plugins/cursor-sdk-channels.ts | ||
| var cursorSDKChannels = defineChannels("@cursor/sdk", { | ||
| create: channel({ | ||
| channelName: "Agent.create", | ||
| kind: "async" | ||
| }), | ||
| resume: channel({ | ||
| channelName: "Agent.resume", | ||
| kind: "async" | ||
| }), | ||
| prompt: channel({ | ||
| channelName: "Agent.prompt", | ||
| kind: "async" | ||
| }), | ||
| send: channel({ | ||
| channelName: "agent.send", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/google-genai-channels.ts | ||
| var googleGenAIChannels = defineChannels("@google/genai", { | ||
| generateContent: channel({ | ||
| channelName: "models.generateContent", | ||
| kind: "async" | ||
| }), | ||
| generateContentStream: channel({ | ||
| channelName: "models.generateContentStream", | ||
| kind: "async" | ||
| }), | ||
| embedContent: channel({ | ||
| channelName: "models.embedContent", | ||
| kind: "async" | ||
| }), | ||
| interactionsCreate: channel({ | ||
| channelName: "interactions.create", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/huggingface-channels.ts | ||
| var huggingFaceChannels = defineChannels("@huggingface/inference", { | ||
| chatCompletion: channel({ | ||
| channelName: "chatCompletion", | ||
| kind: "async" | ||
| }), | ||
| chatCompletionStream: channel({ | ||
| channelName: "chatCompletionStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| textGeneration: channel({ | ||
| channelName: "textGeneration", | ||
| kind: "async" | ||
| }), | ||
| textGenerationStream: channel({ | ||
| channelName: "textGenerationStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| featureExtraction: channel({ | ||
| channelName: "featureExtraction", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openrouter-agent-channels.ts | ||
| var openRouterAgentChannels = defineChannels("@openrouter/agent", { | ||
| callModel: channel({ | ||
| channelName: "callModel", | ||
| kind: "sync-stream" | ||
| }), | ||
| callModelTurn: channel({ | ||
| channelName: "callModel.turn", | ||
| kind: "async" | ||
| }), | ||
| toolExecute: channel({ | ||
| channelName: "tool.execute", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openrouter-channels.ts | ||
| var openRouterChannels = defineChannels("@openrouter/sdk", { | ||
| chatSend: channel({ | ||
| channelName: "chat.send", | ||
| kind: "async" | ||
| }), | ||
| embeddingsGenerate: channel({ | ||
| channelName: "embeddings.generate", | ||
| kind: "async" | ||
| }), | ||
| rerankRerank: channel( | ||
| { | ||
| channelName: "rerank.rerank", | ||
| kind: "async" | ||
| } | ||
| ), | ||
| betaResponsesSend: channel({ | ||
| channelName: "beta.responses.send", | ||
| kind: "async" | ||
| }), | ||
| callModel: channel({ | ||
| channelName: "callModel", | ||
| kind: "sync-stream" | ||
| }), | ||
| callModelTurn: channel({ | ||
| channelName: "callModel.turn", | ||
| kind: "async" | ||
| }), | ||
| toolExecute: channel({ | ||
| channelName: "tool.execute", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/mistral-channels.ts | ||
| var mistralChannels = defineChannels("@mistralai/mistralai", { | ||
| chatComplete: channel({ | ||
| channelName: "chat.complete", | ||
| kind: "async" | ||
| }), | ||
| chatStream: channel({ | ||
| channelName: "chat.stream", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel({ | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| }), | ||
| classifiersModerate: channel({ | ||
| channelName: "classifiers.moderate", | ||
| kind: "async" | ||
| }), | ||
| classifiersModerateChat: channel({ | ||
| channelName: "classifiers.moderateChat", | ||
| kind: "async" | ||
| }), | ||
| classifiersClassify: channel({ | ||
| channelName: "classifiers.classify", | ||
| kind: "async" | ||
| }), | ||
| classifiersClassifyChat: channel({ | ||
| channelName: "classifiers.classifyChat", | ||
| kind: "async" | ||
| }), | ||
| fimComplete: channel({ | ||
| channelName: "fim.complete", | ||
| kind: "async" | ||
| }), | ||
| fimStream: channel({ | ||
| channelName: "fim.stream", | ||
| kind: "async" | ||
| }), | ||
| agentsComplete: channel({ | ||
| channelName: "agents.complete", | ||
| kind: "async" | ||
| }), | ||
| agentsStream: channel({ | ||
| channelName: "agents.stream", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/google-adk-channels.ts | ||
| var googleADKChannels = defineChannels("@google/adk", { | ||
| runnerRunAsync: channel({ | ||
| channelName: "runner.runAsync", | ||
| kind: "sync-stream" | ||
| }), | ||
| agentRunAsync: channel({ | ||
| channelName: "agent.runAsync", | ||
| kind: "sync-stream" | ||
| }), | ||
| toolRunAsync: channel({ | ||
| channelName: "tool.runAsync", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/cohere-channels.ts | ||
| var cohereChannels = defineChannels("cohere-ai", { | ||
| chat: channel({ | ||
| channelName: "chat", | ||
| kind: "async" | ||
| }), | ||
| chatStream: channel({ | ||
| channelName: "chatStream", | ||
| kind: "async" | ||
| }), | ||
| embed: channel({ | ||
| channelName: "embed", | ||
| kind: "async" | ||
| }), | ||
| rerank: channel({ | ||
| channelName: "rerank", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/groq-channels.ts | ||
| var groqChannels = defineChannels("groq-sdk", { | ||
| chatCompletionsCreate: channel({ | ||
| channelName: "chat.completions.create", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel( | ||
| { | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| } | ||
| ) | ||
| }); | ||
| // src/instrumentation/plugins/bedrock-runtime-channels.ts | ||
| var clientSendChannel = channel({ | ||
| channelName: "client.send", | ||
| kind: "async" | ||
| }); | ||
| var bedrockRuntimeChannels = defineChannels("aws-bedrock-runtime", { | ||
| clientSend: clientSendChannel | ||
| }); | ||
| var smithyCoreChannels = defineChannels("@smithy/core", { | ||
| clientSend: clientSendChannel | ||
| }); | ||
| var smithyClientChannels = defineChannels("@smithy/smithy-client", { | ||
| clientSend: clientSendChannel | ||
| }); | ||
| // src/instrumentation/plugins/genkit-channels.ts | ||
| var genkitChannels = defineChannels("@genkit-ai/ai", { | ||
| generate: channel({ | ||
| channelName: "generate", | ||
| kind: "async" | ||
| }), | ||
| generateStream: channel({ | ||
| channelName: "generateStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| embed: channel({ | ||
| channelName: "embed", | ||
| kind: "async" | ||
| }), | ||
| embedMany: channel({ | ||
| channelName: "embedMany", | ||
| kind: "async" | ||
| }), | ||
| actionRun: channel({ | ||
| channelName: "action.run", | ||
| kind: "async" | ||
| }), | ||
| actionStream: channel({ | ||
| channelName: "action.stream", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| var genkitCoreChannels = defineChannels("@genkit-ai/core", { | ||
| actionSpan: channel({ | ||
| channelName: "action.span", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/github-copilot-channels.ts | ||
| var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", { | ||
| createSession: channel({ | ||
| channelName: "client.createSession", | ||
| kind: "async" | ||
| }), | ||
| resumeSession: channel({ | ||
| channelName: "client.resumeSession", | ||
| kind: "async" | ||
| }), | ||
| sendAndWait: channel({ | ||
| channelName: "session.sendAndWait", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/flue-channels.ts | ||
| var flueChannels = defineChannels("@flue/runtime", { | ||
| createContext: channel({ | ||
| channelName: "createFlueContext", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/pi-coding-agent-channels.ts | ||
| var piCodingAgentChannels = defineChannels( | ||
| "@earendil-works/pi-coding-agent", | ||
| { | ||
| prompt: channel({ | ||
| channelName: "AgentSession.prompt", | ||
| kind: "async" | ||
| }) | ||
| } | ||
| ); | ||
| // src/instrumentation/plugins/strands-agent-sdk-channels.ts | ||
| var strandsAgentSDKChannels = defineChannels("@strands-agents/sdk", { | ||
| agentStream: channel({ | ||
| channelName: "Agent.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| graphStream: channel({ | ||
| channelName: "Graph.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| swarmStream: channel({ | ||
| channelName: "Swarm.stream", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/config.ts | ||
| var envIntegrationAliases = { | ||
| openai: "openai", | ||
| "openai-codex": "openaiCodexSDK", | ||
| "openai-codex-sdk": "openaiCodexSDK", | ||
| openaicodexsdk: "openaiCodexSDK", | ||
| codex: "openaiCodexSDK", | ||
| "codex-sdk": "openaiCodexSDK", | ||
| "pi-coding-agent": "piCodingAgent", | ||
| "pi-coding-agent-sdk": "piCodingAgent", | ||
| picodingagent: "piCodingAgent", | ||
| picodingagentsdk: "piCodingAgent", | ||
| "@earendil-works/pi-coding-agent": "piCodingAgent", | ||
| strandsAgentSDK: "strandsAgentSDK", | ||
| strandsagentsdk: "strandsAgentSDK", | ||
| "strands-agent-sdk": "strandsAgentSDK", | ||
| "@strands-agents/sdk": "strandsAgentSDK", | ||
| anthropic: "anthropic", | ||
| aisdk: "aisdk", | ||
| "ai-sdk": "aisdk", | ||
| "vercel-ai": "aisdk", | ||
| vercel: "vercel", | ||
| claudeagentsdk: "claudeAgentSDK", | ||
| "claude-agent-sdk": "claudeAgentSDK", | ||
| cursor: "cursor", | ||
| "cursor-sdk": "cursorSDK", | ||
| cursorsdk: "cursorSDK", | ||
| flue: "flue", | ||
| "flue-runtime": "flue", | ||
| mastra: "mastra", | ||
| "openai-agents": "openAIAgents", | ||
| openaiagents: "openAIAgents", | ||
| "openai-agents-core": "openAIAgents", | ||
| openaiagentscore: "openAIAgents", | ||
| google: "google", | ||
| "google-genai": "googleGenAI", | ||
| googlegenai: "googleGenAI", | ||
| huggingface: "huggingface", | ||
| openrouter: "openrouter", | ||
| openrouteragent: "openrouterAgent", | ||
| "openrouter-agent": "openrouterAgent", | ||
| mistral: "mistral", | ||
| googleadk: "googleADK", | ||
| "google-adk": "googleADK", | ||
| cohere: "cohere", | ||
| groq: "groq", | ||
| "groq-sdk": "groq", | ||
| bedrock: "bedrock", | ||
| "aws-bedrock": "awsBedrock", | ||
| awsbedrock: "awsBedrock", | ||
| "aws-bedrock-runtime": "awsBedrockRuntime", | ||
| awsbedrockruntime: "awsBedrockRuntime", | ||
| "@aws-sdk/client-bedrock-runtime": "awsBedrockRuntime", | ||
| genkit: "genkit", | ||
| "firebase-genkit": "genkit", | ||
| githubcopilot: "gitHubCopilot", | ||
| "github-copilot": "gitHubCopilot", | ||
| "copilot-sdk": "gitHubCopilot", | ||
| langchain: "langchain", | ||
| "langchain-js": "langchain", | ||
| "@langchain": "langchain", | ||
| langgraph: "langgraph" | ||
| }; | ||
| function getDefaultInstrumentationIntegrations() { | ||
| return { | ||
| openai: true, | ||
| openaiCodexSDK: true, | ||
| anthropic: true, | ||
| vercel: true, | ||
| aisdk: true, | ||
| google: true, | ||
| googleGenAI: true, | ||
| googleADK: true, | ||
| huggingface: true, | ||
| claudeAgentSDK: true, | ||
| cursor: true, | ||
| cursorSDK: true, | ||
| flue: true, | ||
| mastra: true, | ||
| openAIAgents: true, | ||
| openrouter: true, | ||
| openrouterAgent: true, | ||
| mistral: true, | ||
| cohere: true, | ||
| groq: true, | ||
| bedrock: true, | ||
| awsBedrock: true, | ||
| awsBedrockRuntime: true, | ||
| genkit: true, | ||
| gitHubCopilot: true, | ||
| langchain: true, | ||
| langgraph: true, | ||
| piCodingAgent: true, | ||
| strandsAgentSDK: true | ||
| }; | ||
| } | ||
| function readDisabledInstrumentationEnvConfig(disabledList) { | ||
| const integrations = {}; | ||
| if (disabledList) { | ||
| for (const value of disabledList.split(",")) { | ||
| const rawSdk = value.trim(); | ||
| const sdk = rawSdk.toLowerCase(); | ||
| if (sdk.length > 0) { | ||
| integrations[_nullishCoalesce(_nullishCoalesce(envIntegrationAliases[rawSdk], () => ( envIntegrationAliases[sdk])), () => ( sdk))] = false; | ||
| } | ||
| } | ||
| } | ||
| return { integrations }; | ||
| } | ||
| function isInstrumentationIntegrationDisabled(integrations, ...names) { | ||
| return names.some((name) => _optionalChain([integrations, 'optionalAccess', _34 => _34[name]]) === false); | ||
| } | ||
| // src/auto-instrumentations/loader/mastra-observability-patch.ts | ||
| var MASTRA_EXPORTER_FACTORY_GLOBAL = "__braintrustMastraExporterFactory"; | ||
| function installMastraExporterFactory(factory) { | ||
| const globals = globalThis; | ||
| globals[MASTRA_EXPORTER_FACTORY_GLOBAL] ??= factory; | ||
| } | ||
| var MASTRA_CORE_PACKAGE = "@mastra/core"; | ||
| var MASTRA_OBSERVABILITY_PACKAGE = "@mastra/observability"; | ||
| var MASTRA_CORE_ENTRY_PATHS = /* @__PURE__ */ new Set([ | ||
| "dist/index.js", | ||
| "dist/index.cjs", | ||
| "dist/mastra/index.js", | ||
| "dist/mastra/index.cjs" | ||
| ]); | ||
| var MASTRA_OBSERVABILITY_ENTRY_PATHS = /* @__PURE__ */ new Set([ | ||
| "dist/index.js", | ||
| "dist/index.cjs" | ||
| ]); | ||
| function classifyMastraTarget(packageName, modulePath) { | ||
| if (packageName === MASTRA_CORE_PACKAGE && MASTRA_CORE_ENTRY_PATHS.has(modulePath)) { | ||
| return "core"; | ||
| } | ||
| if (packageName === MASTRA_OBSERVABILITY_PACKAGE && MASTRA_OBSERVABILITY_ENTRY_PATHS.has(modulePath)) { | ||
| return "observability"; | ||
| } | ||
| return null; | ||
| } | ||
| function extractChunkPath(source) { | ||
| const esmMatch = source.match( | ||
| /export\s*\{\s*Mastra(?:\s+as\s+\w+)?\s*\}\s*from\s*['"]([^'"]+)['"]/ | ||
| ); | ||
| if (esmMatch) return esmMatch[1]; | ||
| const cjsMatch = source.match( | ||
| /require\s*\(\s*['"]([^'"]+chunk-[^'"]+)['"]\s*\)/ | ||
| ); | ||
| if (cjsMatch) return cjsMatch[1]; | ||
| return null; | ||
| } | ||
| var EXPORTER_FACTORY_KEY = JSON.stringify(MASTRA_EXPORTER_FACTORY_GLOBAL); | ||
| var MASTRA_PROXY_HANDLER_BODY = ` | ||
| { | ||
| construct(target, args, newTarget) { | ||
| var firstArg = args[0]; | ||
| if ( | ||
| (!firstArg || typeof firstArg !== "object" || !firstArg.observability) && | ||
| __braintrustObservabilityClass | ||
| ) { | ||
| try { | ||
| // serviceName is required by Mastra's Observability validator; pass | ||
| // something sensible by default. Users who want a different name | ||
| // should construct Observability themselves. | ||
| var observability = new __braintrustObservabilityClass({ | ||
| configs: { default: { serviceName: "mastra" } }, | ||
| }); | ||
| args = args.slice(); | ||
| args[0] = Object.assign({}, firstArg, { observability: observability }); | ||
| } catch (e) { | ||
| // Fall through. Mastra will use its own NoOp; user code still works, | ||
| // just without auto-instrumentation. | ||
| } | ||
| } | ||
| return Reflect.construct(target, args, newTarget); | ||
| }, | ||
| }`; | ||
| function buildMastraEsmWrapper(chunkPath) { | ||
| const chunk = JSON.stringify(chunkPath); | ||
| return `import { Mastra as __braintrustOrigMastra } from ${chunk}; | ||
| import { createRequire as __braintrustCreateRequire } from "node:module"; | ||
| let __braintrustObservabilityClass = null; | ||
| try { | ||
| // Resolve @mastra/observability relative to this module (the Mastra entry), | ||
| // so it's looked up from the user's node_modules tree. | ||
| const __braintrustRequire = __braintrustCreateRequire(import.meta.url); | ||
| __braintrustObservabilityClass = | ||
| __braintrustRequire("@mastra/observability").Observability; | ||
| } catch (e) { | ||
| // @mastra/observability isn't installed; the construct trap will skip the | ||
| // auto-construct branch and Mastra falls back to its own NoOp. | ||
| } | ||
| const Mastra = new Proxy(__braintrustOrigMastra, ${MASTRA_PROXY_HANDLER_BODY}); | ||
| export { Mastra }; | ||
| `; | ||
| } | ||
| function buildMastraCjsWrapper(chunkPath) { | ||
| const chunk = JSON.stringify(chunkPath); | ||
| return `'use strict'; | ||
| const __braintrustChunk = require(${chunk}); | ||
| let __braintrustObservabilityClass = null; | ||
| try { | ||
| __braintrustObservabilityClass = require("@mastra/observability").Observability; | ||
| } catch (e) { | ||
| // @mastra/observability isn't installed; same fallback as the ESM wrapper. | ||
| } | ||
| const __braintrustWrappedMastra = new Proxy( | ||
| __braintrustChunk.Mastra, | ||
| ${MASTRA_PROXY_HANDLER_BODY}, | ||
| ); | ||
| Object.defineProperty(exports, "Mastra", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| get: function () { return __braintrustWrappedMastra; } | ||
| }); | ||
| `; | ||
| } | ||
| var OBSERVABILITY_APPEND_BODY = ` | ||
| ;(function __braintrustWrapObservability() { | ||
| // Top-level so we can both read and reassign the var binding the original | ||
| // entry declared. | ||
| if (typeof Observability === "undefined") return; | ||
| if (Observability.__braintrustWrapped) return; | ||
| function __braintrustEnsureExporter(rawConfig) { | ||
| try { | ||
| var factory = globalThis[${EXPORTER_FACTORY_KEY}]; | ||
| if (typeof factory !== "function") return rawConfig; | ||
| var config = rawConfig && typeof rawConfig === "object" ? rawConfig : {}; | ||
| var configsIn = config.configs && typeof config.configs === "object" ? config.configs : null; | ||
| var configsOut = {}; | ||
| var hadEntries = false; | ||
| if (configsIn) { | ||
| for (var name in configsIn) { | ||
| if (!Object.prototype.hasOwnProperty.call(configsIn, name)) continue; | ||
| hadEntries = true; | ||
| var inst = configsIn[name] || {}; | ||
| var existing = Array.isArray(inst.exporters) ? inst.exporters : []; | ||
| var hasOurs = existing.some(function (e) { return e && e.name === "braintrust"; }); | ||
| configsOut[name] = Object.assign({}, inst, { | ||
| exporters: hasOurs ? existing : existing.concat([factory()]), | ||
| }); | ||
| } | ||
| } | ||
| if (!hadEntries) { | ||
| configsOut.default = { | ||
| serviceName: "mastra", | ||
| exporters: [factory()], | ||
| }; | ||
| } | ||
| return Object.assign({}, config, { configs: configsOut }); | ||
| } catch (e) { | ||
| return rawConfig; | ||
| } | ||
| } | ||
| var __OriginalObservability = Observability; | ||
| Observability = new Proxy(__OriginalObservability, { | ||
| construct: function (target, args, newTarget) { | ||
| var nextArgs = args.slice(); | ||
| nextArgs[0] = __braintrustEnsureExporter(nextArgs[0]); | ||
| return Reflect.construct(target, nextArgs, newTarget); | ||
| }, | ||
| }); | ||
| Observability.__braintrustWrapped = true; | ||
| if (typeof exports !== "undefined" && exports && typeof exports === "object") { | ||
| try { | ||
| Object.defineProperty(exports, "Observability", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| get: function () { return Observability; }, | ||
| }); | ||
| } catch (e) {} | ||
| } | ||
| })(); | ||
| `; | ||
| function patchMastraSource(source, target, format) { | ||
| if (target === "core") { | ||
| const chunkPath = extractChunkPath(source); | ||
| if (!chunkPath) return source; | ||
| return format === "esm" ? buildMastraEsmWrapper(chunkPath) : buildMastraCjsWrapper(chunkPath); | ||
| } | ||
| return source + OBSERVABILITY_APPEND_BODY; | ||
| } | ||
| // src/instrumentation/plugins/openai-agents-channels.ts | ||
| var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", { | ||
| onTraceStart: channel({ | ||
| channelName: "tracing.processor.onTraceStart", | ||
| kind: "async" | ||
| }), | ||
| onTraceEnd: channel({ | ||
| channelName: "tracing.processor.onTraceEnd", | ||
| kind: "async" | ||
| }), | ||
| onSpanStart: channel({ | ||
| channelName: "tracing.processor.onSpanStart", | ||
| kind: "async" | ||
| }), | ||
| onSpanEnd: channel({ | ||
| channelName: "tracing.processor.onSpanEnd", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/langchain-channels.ts | ||
| var langChainChannels = defineChannels("@langchain/core", { | ||
| configure: channel({ | ||
| channelName: "CallbackManager.configure", | ||
| kind: "sync-stream" | ||
| }), | ||
| configureSync: channel({ | ||
| channelName: "CallbackManager._configureSync", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| exports.__export = __export; exports.patchTracingChannel = patchTracingChannel; exports.isomorph_default = isomorph_default; exports.openAIChannels = openAIChannels; exports.openAICodexChannels = openAICodexChannels; exports.anthropicChannels = anthropicChannels; exports.aiSDKChannels = aiSDKChannels; exports.claudeAgentSDKChannels = claudeAgentSDKChannels; exports.cursorSDKChannels = cursorSDKChannels; exports.openAIAgentsCoreChannels = openAIAgentsCoreChannels; exports.googleGenAIChannels = googleGenAIChannels; exports.huggingFaceChannels = huggingFaceChannels; exports.openRouterAgentChannels = openRouterAgentChannels; exports.openRouterChannels = openRouterChannels; exports.mistralChannels = mistralChannels; exports.googleADKChannels = googleADKChannels; exports.cohereChannels = cohereChannels; exports.groqChannels = groqChannels; exports.bedrockRuntimeChannels = bedrockRuntimeChannels; exports.smithyCoreChannels = smithyCoreChannels; exports.smithyClientChannels = smithyClientChannels; exports.genkitChannels = genkitChannels; exports.genkitCoreChannels = genkitCoreChannels; exports.gitHubCopilotChannels = gitHubCopilotChannels; exports.flueChannels = flueChannels; exports.langChainChannels = langChainChannels; exports.piCodingAgentChannels = piCodingAgentChannels; exports.strandsAgentSDKChannels = strandsAgentSDKChannels; exports.getDefaultInstrumentationIntegrations = getDefaultInstrumentationIntegrations; exports.readDisabledInstrumentationEnvConfig = readDisabledInstrumentationEnvConfig; exports.isInstrumentationIntegrationDisabled = isInstrumentationIntegrationDisabled; exports.installMastraExporterFactory = installMastraExporterFactory; exports.classifyMastraTarget = classifyMastraTarget; exports.patchMastraSource = patchMastraSource; |
Sorry, the diff of this file is too big to display
| var __defProp = Object.defineProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| // src/auto-instrumentations/patch-tracing-channel.ts | ||
| function patchTracingChannel(tracingChannelFn) { | ||
| const dummyChannel = tracingChannelFn("__braintrust_probe__"); | ||
| const TracingChannel = dummyChannel?.constructor; | ||
| if (!TracingChannel?.prototype) { | ||
| return; | ||
| } | ||
| if (!Object.getOwnPropertyDescriptor(TracingChannel.prototype, "hasSubscribers")) { | ||
| Object.defineProperty(TracingChannel.prototype, "hasSubscribers", { | ||
| configurable: true, | ||
| enumerable: false, | ||
| get() { | ||
| return Boolean( | ||
| this.start?.hasSubscribers || this.end?.hasSubscribers || this.asyncStart?.hasSubscribers || this.asyncEnd?.hasSubscribers || this.error?.hasSubscribers | ||
| ); | ||
| } | ||
| }); | ||
| } | ||
| if (TracingChannel.prototype.tracePromise) { | ||
| TracingChannel.prototype.tracePromise = function(fn, context = {}, thisArg, ...args) { | ||
| const start = this.start; | ||
| const end = this.end; | ||
| const asyncStart = this.asyncStart; | ||
| const asyncEnd = this.asyncEnd; | ||
| const error = this.error; | ||
| function publishRejected(err) { | ||
| context.error = err; | ||
| error?.publish(context); | ||
| asyncStart?.publish(context); | ||
| asyncEnd?.publish(context); | ||
| } | ||
| function publishResolved(result) { | ||
| context.result = result; | ||
| asyncStart?.publish(context); | ||
| asyncEnd?.publish(context); | ||
| } | ||
| return start.runStores(context, () => { | ||
| try { | ||
| const result = Reflect.apply(fn, thisArg, args); | ||
| end?.publish(context); | ||
| if (result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function") { | ||
| if (result.constructor === Promise) { | ||
| return result.then( | ||
| (res) => { | ||
| publishResolved(res); | ||
| return res; | ||
| }, | ||
| (err) => { | ||
| publishRejected(err); | ||
| return Promise.reject(err); | ||
| } | ||
| ); | ||
| } | ||
| void result.then( | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (resolved) => { | ||
| try { | ||
| publishResolved(resolved); | ||
| } catch { | ||
| } | ||
| }, | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (err) => { | ||
| try { | ||
| publishRejected(err); | ||
| } catch { | ||
| } | ||
| } | ||
| ); | ||
| return result; | ||
| } | ||
| context.result = result; | ||
| asyncStart?.publish(context); | ||
| asyncEnd?.publish(context); | ||
| return result; | ||
| } catch (err) { | ||
| context.error = err; | ||
| error?.publish(context); | ||
| end?.publish(context); | ||
| throw err; | ||
| } | ||
| }); | ||
| }; | ||
| } | ||
| } | ||
| // src/isomorph.ts | ||
| var DefaultAsyncLocalStorage = class { | ||
| constructor() { | ||
| } | ||
| enterWith(_) { | ||
| } | ||
| run(_, callback) { | ||
| return callback(); | ||
| } | ||
| getStore() { | ||
| return void 0; | ||
| } | ||
| }; | ||
| var DefaultChannel = class { | ||
| constructor(name) { | ||
| this.name = name; | ||
| } | ||
| hasSubscribers = false; | ||
| subscribe(_subscription) { | ||
| } | ||
| unsubscribe(_subscription) { | ||
| return false; | ||
| } | ||
| bindStore(_store, _transform) { | ||
| } | ||
| unbindStore(_store) { | ||
| return false; | ||
| } | ||
| publish(_message) { | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| runStores(_message, fn, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| }; | ||
| var DefaultTracingChannel = class { | ||
| start; | ||
| end; | ||
| asyncStart; | ||
| asyncEnd; | ||
| error; | ||
| constructor(nameOrChannels) { | ||
| if (typeof nameOrChannels === "string") { | ||
| this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`); | ||
| this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`); | ||
| this.asyncStart = new DefaultChannel( | ||
| `tracing:${nameOrChannels}:asyncStart` | ||
| ); | ||
| this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`); | ||
| this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`); | ||
| return; | ||
| } | ||
| this.start = nameOrChannels.start ?? new DefaultChannel("tracing:start"); | ||
| this.end = nameOrChannels.end ?? new DefaultChannel("tracing:end"); | ||
| this.asyncStart = nameOrChannels.asyncStart ?? new DefaultChannel("tracing:asyncStart"); | ||
| this.asyncEnd = nameOrChannels.asyncEnd ?? new DefaultChannel("tracing:asyncEnd"); | ||
| this.error = nameOrChannels.error ?? new DefaultChannel("tracing:error"); | ||
| } | ||
| get hasSubscribers() { | ||
| return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers; | ||
| } | ||
| subscribe(_handlers) { | ||
| } | ||
| unsubscribe(_handlers) { | ||
| return false; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| traceSync(fn, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| tracePromise(fn, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| traceCallback(fn, _position, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| }; | ||
| var iso = { | ||
| buildType: "unknown", | ||
| // Will be set by configureBrowser() or configureNode() | ||
| getRepoInfo: async (_settings) => void 0, | ||
| getPastNAncestors: async () => [], | ||
| getEnv: (_name) => void 0, | ||
| getBraintrustApiKey: async () => void 0, | ||
| getCallerLocation: () => void 0, | ||
| newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(), | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels), | ||
| processOn: (_0, _1) => { | ||
| }, | ||
| basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath, | ||
| // eslint-disable-next-line no-restricted-properties -- preserving intentional console usage. | ||
| writeln: (text) => console.log(text) | ||
| }; | ||
| var isomorph_default = iso; | ||
| // src/instrumentation/core/channel-definitions.ts | ||
| function channel(spec) { | ||
| return spec; | ||
| } | ||
| function defineChannels(pkg, channels) { | ||
| return Object.fromEntries( | ||
| Object.entries(channels).map(([key, spec]) => { | ||
| const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`; | ||
| if (spec.kind === "async") { | ||
| const asyncSpec = spec; | ||
| const tracingChannel2 = () => isomorph_default.newTracingChannel( | ||
| fullChannelName | ||
| ); | ||
| return [ | ||
| key, | ||
| { | ||
| ...asyncSpec, | ||
| tracingChannel: tracingChannel2, | ||
| tracePromise: (fn, context) => tracingChannel2().tracePromise( | ||
| fn, | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| context | ||
| ) | ||
| } | ||
| ]; | ||
| } | ||
| const syncSpec = spec; | ||
| const tracingChannel = () => isomorph_default.newTracingChannel( | ||
| fullChannelName | ||
| ); | ||
| return [ | ||
| key, | ||
| { | ||
| ...syncSpec, | ||
| tracingChannel, | ||
| traceSync: (fn, context) => tracingChannel().traceSync( | ||
| fn, | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| context | ||
| ) | ||
| } | ||
| ]; | ||
| }) | ||
| ); | ||
| } | ||
| // src/instrumentation/plugins/openai-channels.ts | ||
| var openAIChannels = defineChannels("openai", { | ||
| chatCompletionsCreate: channel({ | ||
| channelName: "chat.completions.create", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel({ | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| }), | ||
| betaChatCompletionsParse: channel({ | ||
| channelName: "beta.chat.completions.parse", | ||
| kind: "async" | ||
| }), | ||
| betaChatCompletionsStream: channel({ | ||
| channelName: "beta.chat.completions.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| moderationsCreate: channel({ | ||
| channelName: "moderations.create", | ||
| kind: "async" | ||
| }), | ||
| responsesCreate: channel({ | ||
| channelName: "responses.create", | ||
| kind: "async" | ||
| }), | ||
| responsesStream: channel({ | ||
| channelName: "responses.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| responsesParse: channel({ | ||
| channelName: "responses.parse", | ||
| kind: "async" | ||
| }), | ||
| responsesCompact: channel({ | ||
| channelName: "responses.compact", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openai-codex-channels.ts | ||
| var openAICodexChannels = defineChannels("@openai/codex-sdk", { | ||
| run: channel({ | ||
| channelName: "Thread.run", | ||
| kind: "async" | ||
| }), | ||
| runStreamed: channel({ | ||
| channelName: "Thread.runStreamed", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/anthropic-channels.ts | ||
| var anthropicChannels = defineChannels("@anthropic-ai/sdk", { | ||
| messagesCreate: channel({ | ||
| channelName: "messages.create", | ||
| kind: "async" | ||
| }), | ||
| betaMessagesCreate: channel({ | ||
| channelName: "beta.messages.create", | ||
| kind: "async" | ||
| }), | ||
| betaMessagesToolRunner: channel({ | ||
| channelName: "beta.messages.toolRunner", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/ai-sdk-channels.ts | ||
| var aiSDKChannels = defineChannels("ai", { | ||
| generateText: channel({ | ||
| channelName: "generateText", | ||
| kind: "async" | ||
| }), | ||
| streamText: channel({ | ||
| channelName: "streamText", | ||
| kind: "async" | ||
| }), | ||
| streamTextSync: channel({ | ||
| channelName: "streamText.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| generateObject: channel({ | ||
| channelName: "generateObject", | ||
| kind: "async" | ||
| }), | ||
| streamObject: channel({ | ||
| channelName: "streamObject", | ||
| kind: "async" | ||
| }), | ||
| streamObjectSync: channel({ | ||
| channelName: "streamObject.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| embed: channel( | ||
| { | ||
| channelName: "embed", | ||
| kind: "async" | ||
| } | ||
| ), | ||
| embedMany: channel({ | ||
| channelName: "embedMany", | ||
| kind: "async" | ||
| }), | ||
| rerank: channel({ | ||
| channelName: "rerank", | ||
| kind: "async" | ||
| }), | ||
| agentGenerate: channel({ | ||
| channelName: "Agent.generate", | ||
| kind: "async" | ||
| }), | ||
| agentStream: channel({ | ||
| channelName: "Agent.stream", | ||
| kind: "async" | ||
| }), | ||
| agentStreamSync: channel({ | ||
| channelName: "Agent.stream.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| toolLoopAgentGenerate: channel({ | ||
| channelName: "ToolLoopAgent.generate", | ||
| kind: "async" | ||
| }), | ||
| toolLoopAgentStream: channel({ | ||
| channelName: "ToolLoopAgent.stream", | ||
| kind: "async" | ||
| }), | ||
| v7CreateTelemetryDispatcher: channel({ | ||
| channelName: "createTelemetryDispatcher", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/claude-agent-sdk-channels.ts | ||
| var claudeAgentSDKChannels = defineChannels( | ||
| "@anthropic-ai/claude-agent-sdk", | ||
| { | ||
| query: channel({ | ||
| channelName: "query", | ||
| kind: "sync-stream" | ||
| }) | ||
| } | ||
| ); | ||
| // src/instrumentation/plugins/cursor-sdk-channels.ts | ||
| var cursorSDKChannels = defineChannels("@cursor/sdk", { | ||
| create: channel({ | ||
| channelName: "Agent.create", | ||
| kind: "async" | ||
| }), | ||
| resume: channel({ | ||
| channelName: "Agent.resume", | ||
| kind: "async" | ||
| }), | ||
| prompt: channel({ | ||
| channelName: "Agent.prompt", | ||
| kind: "async" | ||
| }), | ||
| send: channel({ | ||
| channelName: "agent.send", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/google-genai-channels.ts | ||
| var googleGenAIChannels = defineChannels("@google/genai", { | ||
| generateContent: channel({ | ||
| channelName: "models.generateContent", | ||
| kind: "async" | ||
| }), | ||
| generateContentStream: channel({ | ||
| channelName: "models.generateContentStream", | ||
| kind: "async" | ||
| }), | ||
| embedContent: channel({ | ||
| channelName: "models.embedContent", | ||
| kind: "async" | ||
| }), | ||
| interactionsCreate: channel({ | ||
| channelName: "interactions.create", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/huggingface-channels.ts | ||
| var huggingFaceChannels = defineChannels("@huggingface/inference", { | ||
| chatCompletion: channel({ | ||
| channelName: "chatCompletion", | ||
| kind: "async" | ||
| }), | ||
| chatCompletionStream: channel({ | ||
| channelName: "chatCompletionStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| textGeneration: channel({ | ||
| channelName: "textGeneration", | ||
| kind: "async" | ||
| }), | ||
| textGenerationStream: channel({ | ||
| channelName: "textGenerationStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| featureExtraction: channel({ | ||
| channelName: "featureExtraction", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openrouter-agent-channels.ts | ||
| var openRouterAgentChannels = defineChannels("@openrouter/agent", { | ||
| callModel: channel({ | ||
| channelName: "callModel", | ||
| kind: "sync-stream" | ||
| }), | ||
| callModelTurn: channel({ | ||
| channelName: "callModel.turn", | ||
| kind: "async" | ||
| }), | ||
| toolExecute: channel({ | ||
| channelName: "tool.execute", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openrouter-channels.ts | ||
| var openRouterChannels = defineChannels("@openrouter/sdk", { | ||
| chatSend: channel({ | ||
| channelName: "chat.send", | ||
| kind: "async" | ||
| }), | ||
| embeddingsGenerate: channel({ | ||
| channelName: "embeddings.generate", | ||
| kind: "async" | ||
| }), | ||
| rerankRerank: channel( | ||
| { | ||
| channelName: "rerank.rerank", | ||
| kind: "async" | ||
| } | ||
| ), | ||
| betaResponsesSend: channel({ | ||
| channelName: "beta.responses.send", | ||
| kind: "async" | ||
| }), | ||
| callModel: channel({ | ||
| channelName: "callModel", | ||
| kind: "sync-stream" | ||
| }), | ||
| callModelTurn: channel({ | ||
| channelName: "callModel.turn", | ||
| kind: "async" | ||
| }), | ||
| toolExecute: channel({ | ||
| channelName: "tool.execute", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/mistral-channels.ts | ||
| var mistralChannels = defineChannels("@mistralai/mistralai", { | ||
| chatComplete: channel({ | ||
| channelName: "chat.complete", | ||
| kind: "async" | ||
| }), | ||
| chatStream: channel({ | ||
| channelName: "chat.stream", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel({ | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| }), | ||
| classifiersModerate: channel({ | ||
| channelName: "classifiers.moderate", | ||
| kind: "async" | ||
| }), | ||
| classifiersModerateChat: channel({ | ||
| channelName: "classifiers.moderateChat", | ||
| kind: "async" | ||
| }), | ||
| classifiersClassify: channel({ | ||
| channelName: "classifiers.classify", | ||
| kind: "async" | ||
| }), | ||
| classifiersClassifyChat: channel({ | ||
| channelName: "classifiers.classifyChat", | ||
| kind: "async" | ||
| }), | ||
| fimComplete: channel({ | ||
| channelName: "fim.complete", | ||
| kind: "async" | ||
| }), | ||
| fimStream: channel({ | ||
| channelName: "fim.stream", | ||
| kind: "async" | ||
| }), | ||
| agentsComplete: channel({ | ||
| channelName: "agents.complete", | ||
| kind: "async" | ||
| }), | ||
| agentsStream: channel({ | ||
| channelName: "agents.stream", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/google-adk-channels.ts | ||
| var googleADKChannels = defineChannels("@google/adk", { | ||
| runnerRunAsync: channel({ | ||
| channelName: "runner.runAsync", | ||
| kind: "sync-stream" | ||
| }), | ||
| agentRunAsync: channel({ | ||
| channelName: "agent.runAsync", | ||
| kind: "sync-stream" | ||
| }), | ||
| toolRunAsync: channel({ | ||
| channelName: "tool.runAsync", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/cohere-channels.ts | ||
| var cohereChannels = defineChannels("cohere-ai", { | ||
| chat: channel({ | ||
| channelName: "chat", | ||
| kind: "async" | ||
| }), | ||
| chatStream: channel({ | ||
| channelName: "chatStream", | ||
| kind: "async" | ||
| }), | ||
| embed: channel({ | ||
| channelName: "embed", | ||
| kind: "async" | ||
| }), | ||
| rerank: channel({ | ||
| channelName: "rerank", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/groq-channels.ts | ||
| var groqChannels = defineChannels("groq-sdk", { | ||
| chatCompletionsCreate: channel({ | ||
| channelName: "chat.completions.create", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel( | ||
| { | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| } | ||
| ) | ||
| }); | ||
| // src/instrumentation/plugins/bedrock-runtime-channels.ts | ||
| var clientSendChannel = channel({ | ||
| channelName: "client.send", | ||
| kind: "async" | ||
| }); | ||
| var bedrockRuntimeChannels = defineChannels("aws-bedrock-runtime", { | ||
| clientSend: clientSendChannel | ||
| }); | ||
| var smithyCoreChannels = defineChannels("@smithy/core", { | ||
| clientSend: clientSendChannel | ||
| }); | ||
| var smithyClientChannels = defineChannels("@smithy/smithy-client", { | ||
| clientSend: clientSendChannel | ||
| }); | ||
| // src/instrumentation/plugins/genkit-channels.ts | ||
| var genkitChannels = defineChannels("@genkit-ai/ai", { | ||
| generate: channel({ | ||
| channelName: "generate", | ||
| kind: "async" | ||
| }), | ||
| generateStream: channel({ | ||
| channelName: "generateStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| embed: channel({ | ||
| channelName: "embed", | ||
| kind: "async" | ||
| }), | ||
| embedMany: channel({ | ||
| channelName: "embedMany", | ||
| kind: "async" | ||
| }), | ||
| actionRun: channel({ | ||
| channelName: "action.run", | ||
| kind: "async" | ||
| }), | ||
| actionStream: channel({ | ||
| channelName: "action.stream", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| var genkitCoreChannels = defineChannels("@genkit-ai/core", { | ||
| actionSpan: channel({ | ||
| channelName: "action.span", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/github-copilot-channels.ts | ||
| var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", { | ||
| createSession: channel({ | ||
| channelName: "client.createSession", | ||
| kind: "async" | ||
| }), | ||
| resumeSession: channel({ | ||
| channelName: "client.resumeSession", | ||
| kind: "async" | ||
| }), | ||
| sendAndWait: channel({ | ||
| channelName: "session.sendAndWait", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/flue-channels.ts | ||
| var flueChannels = defineChannels("@flue/runtime", { | ||
| createContext: channel({ | ||
| channelName: "createFlueContext", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/pi-coding-agent-channels.ts | ||
| var piCodingAgentChannels = defineChannels( | ||
| "@earendil-works/pi-coding-agent", | ||
| { | ||
| prompt: channel({ | ||
| channelName: "AgentSession.prompt", | ||
| kind: "async" | ||
| }) | ||
| } | ||
| ); | ||
| // src/instrumentation/plugins/strands-agent-sdk-channels.ts | ||
| var strandsAgentSDKChannels = defineChannels("@strands-agents/sdk", { | ||
| agentStream: channel({ | ||
| channelName: "Agent.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| graphStream: channel({ | ||
| channelName: "Graph.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| swarmStream: channel({ | ||
| channelName: "Swarm.stream", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/config.ts | ||
| var envIntegrationAliases = { | ||
| openai: "openai", | ||
| "openai-codex": "openaiCodexSDK", | ||
| "openai-codex-sdk": "openaiCodexSDK", | ||
| openaicodexsdk: "openaiCodexSDK", | ||
| codex: "openaiCodexSDK", | ||
| "codex-sdk": "openaiCodexSDK", | ||
| "pi-coding-agent": "piCodingAgent", | ||
| "pi-coding-agent-sdk": "piCodingAgent", | ||
| picodingagent: "piCodingAgent", | ||
| picodingagentsdk: "piCodingAgent", | ||
| "@earendil-works/pi-coding-agent": "piCodingAgent", | ||
| strandsAgentSDK: "strandsAgentSDK", | ||
| strandsagentsdk: "strandsAgentSDK", | ||
| "strands-agent-sdk": "strandsAgentSDK", | ||
| "@strands-agents/sdk": "strandsAgentSDK", | ||
| anthropic: "anthropic", | ||
| aisdk: "aisdk", | ||
| "ai-sdk": "aisdk", | ||
| "vercel-ai": "aisdk", | ||
| vercel: "vercel", | ||
| claudeagentsdk: "claudeAgentSDK", | ||
| "claude-agent-sdk": "claudeAgentSDK", | ||
| cursor: "cursor", | ||
| "cursor-sdk": "cursorSDK", | ||
| cursorsdk: "cursorSDK", | ||
| flue: "flue", | ||
| "flue-runtime": "flue", | ||
| mastra: "mastra", | ||
| "openai-agents": "openAIAgents", | ||
| openaiagents: "openAIAgents", | ||
| "openai-agents-core": "openAIAgents", | ||
| openaiagentscore: "openAIAgents", | ||
| google: "google", | ||
| "google-genai": "googleGenAI", | ||
| googlegenai: "googleGenAI", | ||
| huggingface: "huggingface", | ||
| openrouter: "openrouter", | ||
| openrouteragent: "openrouterAgent", | ||
| "openrouter-agent": "openrouterAgent", | ||
| mistral: "mistral", | ||
| googleadk: "googleADK", | ||
| "google-adk": "googleADK", | ||
| cohere: "cohere", | ||
| groq: "groq", | ||
| "groq-sdk": "groq", | ||
| bedrock: "bedrock", | ||
| "aws-bedrock": "awsBedrock", | ||
| awsbedrock: "awsBedrock", | ||
| "aws-bedrock-runtime": "awsBedrockRuntime", | ||
| awsbedrockruntime: "awsBedrockRuntime", | ||
| "@aws-sdk/client-bedrock-runtime": "awsBedrockRuntime", | ||
| genkit: "genkit", | ||
| "firebase-genkit": "genkit", | ||
| githubcopilot: "gitHubCopilot", | ||
| "github-copilot": "gitHubCopilot", | ||
| "copilot-sdk": "gitHubCopilot", | ||
| langchain: "langchain", | ||
| "langchain-js": "langchain", | ||
| "@langchain": "langchain", | ||
| langgraph: "langgraph" | ||
| }; | ||
| function getDefaultInstrumentationIntegrations() { | ||
| return { | ||
| openai: true, | ||
| openaiCodexSDK: true, | ||
| anthropic: true, | ||
| vercel: true, | ||
| aisdk: true, | ||
| google: true, | ||
| googleGenAI: true, | ||
| googleADK: true, | ||
| huggingface: true, | ||
| claudeAgentSDK: true, | ||
| cursor: true, | ||
| cursorSDK: true, | ||
| flue: true, | ||
| mastra: true, | ||
| openAIAgents: true, | ||
| openrouter: true, | ||
| openrouterAgent: true, | ||
| mistral: true, | ||
| cohere: true, | ||
| groq: true, | ||
| bedrock: true, | ||
| awsBedrock: true, | ||
| awsBedrockRuntime: true, | ||
| genkit: true, | ||
| gitHubCopilot: true, | ||
| langchain: true, | ||
| langgraph: true, | ||
| piCodingAgent: true, | ||
| strandsAgentSDK: true | ||
| }; | ||
| } | ||
| function readDisabledInstrumentationEnvConfig(disabledList) { | ||
| const integrations = {}; | ||
| if (disabledList) { | ||
| for (const value of disabledList.split(",")) { | ||
| const rawSdk = value.trim(); | ||
| const sdk = rawSdk.toLowerCase(); | ||
| if (sdk.length > 0) { | ||
| integrations[envIntegrationAliases[rawSdk] ?? envIntegrationAliases[sdk] ?? sdk] = false; | ||
| } | ||
| } | ||
| } | ||
| return { integrations }; | ||
| } | ||
| function isInstrumentationIntegrationDisabled(integrations, ...names) { | ||
| return names.some((name) => integrations?.[name] === false); | ||
| } | ||
| // src/auto-instrumentations/loader/mastra-observability-patch.ts | ||
| var MASTRA_EXPORTER_FACTORY_GLOBAL = "__braintrustMastraExporterFactory"; | ||
| function installMastraExporterFactory(factory) { | ||
| const globals = globalThis; | ||
| globals[MASTRA_EXPORTER_FACTORY_GLOBAL] ??= factory; | ||
| } | ||
| var MASTRA_CORE_PACKAGE = "@mastra/core"; | ||
| var MASTRA_OBSERVABILITY_PACKAGE = "@mastra/observability"; | ||
| var MASTRA_CORE_ENTRY_PATHS = /* @__PURE__ */ new Set([ | ||
| "dist/index.js", | ||
| "dist/index.cjs", | ||
| "dist/mastra/index.js", | ||
| "dist/mastra/index.cjs" | ||
| ]); | ||
| var MASTRA_OBSERVABILITY_ENTRY_PATHS = /* @__PURE__ */ new Set([ | ||
| "dist/index.js", | ||
| "dist/index.cjs" | ||
| ]); | ||
| function classifyMastraTarget(packageName, modulePath) { | ||
| if (packageName === MASTRA_CORE_PACKAGE && MASTRA_CORE_ENTRY_PATHS.has(modulePath)) { | ||
| return "core"; | ||
| } | ||
| if (packageName === MASTRA_OBSERVABILITY_PACKAGE && MASTRA_OBSERVABILITY_ENTRY_PATHS.has(modulePath)) { | ||
| return "observability"; | ||
| } | ||
| return null; | ||
| } | ||
| function extractChunkPath(source) { | ||
| const esmMatch = source.match( | ||
| /export\s*\{\s*Mastra(?:\s+as\s+\w+)?\s*\}\s*from\s*['"]([^'"]+)['"]/ | ||
| ); | ||
| if (esmMatch) return esmMatch[1]; | ||
| const cjsMatch = source.match( | ||
| /require\s*\(\s*['"]([^'"]+chunk-[^'"]+)['"]\s*\)/ | ||
| ); | ||
| if (cjsMatch) return cjsMatch[1]; | ||
| return null; | ||
| } | ||
| var EXPORTER_FACTORY_KEY = JSON.stringify(MASTRA_EXPORTER_FACTORY_GLOBAL); | ||
| var MASTRA_PROXY_HANDLER_BODY = ` | ||
| { | ||
| construct(target, args, newTarget) { | ||
| var firstArg = args[0]; | ||
| if ( | ||
| (!firstArg || typeof firstArg !== "object" || !firstArg.observability) && | ||
| __braintrustObservabilityClass | ||
| ) { | ||
| try { | ||
| // serviceName is required by Mastra's Observability validator; pass | ||
| // something sensible by default. Users who want a different name | ||
| // should construct Observability themselves. | ||
| var observability = new __braintrustObservabilityClass({ | ||
| configs: { default: { serviceName: "mastra" } }, | ||
| }); | ||
| args = args.slice(); | ||
| args[0] = Object.assign({}, firstArg, { observability: observability }); | ||
| } catch (e) { | ||
| // Fall through. Mastra will use its own NoOp; user code still works, | ||
| // just without auto-instrumentation. | ||
| } | ||
| } | ||
| return Reflect.construct(target, args, newTarget); | ||
| }, | ||
| }`; | ||
| function buildMastraEsmWrapper(chunkPath) { | ||
| const chunk = JSON.stringify(chunkPath); | ||
| return `import { Mastra as __braintrustOrigMastra } from ${chunk}; | ||
| import { createRequire as __braintrustCreateRequire } from "node:module"; | ||
| let __braintrustObservabilityClass = null; | ||
| try { | ||
| // Resolve @mastra/observability relative to this module (the Mastra entry), | ||
| // so it's looked up from the user's node_modules tree. | ||
| const __braintrustRequire = __braintrustCreateRequire(import.meta.url); | ||
| __braintrustObservabilityClass = | ||
| __braintrustRequire("@mastra/observability").Observability; | ||
| } catch (e) { | ||
| // @mastra/observability isn't installed; the construct trap will skip the | ||
| // auto-construct branch and Mastra falls back to its own NoOp. | ||
| } | ||
| const Mastra = new Proxy(__braintrustOrigMastra, ${MASTRA_PROXY_HANDLER_BODY}); | ||
| export { Mastra }; | ||
| `; | ||
| } | ||
| function buildMastraCjsWrapper(chunkPath) { | ||
| const chunk = JSON.stringify(chunkPath); | ||
| return `'use strict'; | ||
| const __braintrustChunk = require(${chunk}); | ||
| let __braintrustObservabilityClass = null; | ||
| try { | ||
| __braintrustObservabilityClass = require("@mastra/observability").Observability; | ||
| } catch (e) { | ||
| // @mastra/observability isn't installed; same fallback as the ESM wrapper. | ||
| } | ||
| const __braintrustWrappedMastra = new Proxy( | ||
| __braintrustChunk.Mastra, | ||
| ${MASTRA_PROXY_HANDLER_BODY}, | ||
| ); | ||
| Object.defineProperty(exports, "Mastra", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| get: function () { return __braintrustWrappedMastra; } | ||
| }); | ||
| `; | ||
| } | ||
| var OBSERVABILITY_APPEND_BODY = ` | ||
| ;(function __braintrustWrapObservability() { | ||
| // Top-level so we can both read and reassign the var binding the original | ||
| // entry declared. | ||
| if (typeof Observability === "undefined") return; | ||
| if (Observability.__braintrustWrapped) return; | ||
| function __braintrustEnsureExporter(rawConfig) { | ||
| try { | ||
| var factory = globalThis[${EXPORTER_FACTORY_KEY}]; | ||
| if (typeof factory !== "function") return rawConfig; | ||
| var config = rawConfig && typeof rawConfig === "object" ? rawConfig : {}; | ||
| var configsIn = config.configs && typeof config.configs === "object" ? config.configs : null; | ||
| var configsOut = {}; | ||
| var hadEntries = false; | ||
| if (configsIn) { | ||
| for (var name in configsIn) { | ||
| if (!Object.prototype.hasOwnProperty.call(configsIn, name)) continue; | ||
| hadEntries = true; | ||
| var inst = configsIn[name] || {}; | ||
| var existing = Array.isArray(inst.exporters) ? inst.exporters : []; | ||
| var hasOurs = existing.some(function (e) { return e && e.name === "braintrust"; }); | ||
| configsOut[name] = Object.assign({}, inst, { | ||
| exporters: hasOurs ? existing : existing.concat([factory()]), | ||
| }); | ||
| } | ||
| } | ||
| if (!hadEntries) { | ||
| configsOut.default = { | ||
| serviceName: "mastra", | ||
| exporters: [factory()], | ||
| }; | ||
| } | ||
| return Object.assign({}, config, { configs: configsOut }); | ||
| } catch (e) { | ||
| return rawConfig; | ||
| } | ||
| } | ||
| var __OriginalObservability = Observability; | ||
| Observability = new Proxy(__OriginalObservability, { | ||
| construct: function (target, args, newTarget) { | ||
| var nextArgs = args.slice(); | ||
| nextArgs[0] = __braintrustEnsureExporter(nextArgs[0]); | ||
| return Reflect.construct(target, nextArgs, newTarget); | ||
| }, | ||
| }); | ||
| Observability.__braintrustWrapped = true; | ||
| if (typeof exports !== "undefined" && exports && typeof exports === "object") { | ||
| try { | ||
| Object.defineProperty(exports, "Observability", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| get: function () { return Observability; }, | ||
| }); | ||
| } catch (e) {} | ||
| } | ||
| })(); | ||
| `; | ||
| function patchMastraSource(source, target, format) { | ||
| if (target === "core") { | ||
| const chunkPath = extractChunkPath(source); | ||
| if (!chunkPath) return source; | ||
| return format === "esm" ? buildMastraEsmWrapper(chunkPath) : buildMastraCjsWrapper(chunkPath); | ||
| } | ||
| return source + OBSERVABILITY_APPEND_BODY; | ||
| } | ||
| // src/instrumentation/plugins/openai-agents-channels.ts | ||
| var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", { | ||
| onTraceStart: channel({ | ||
| channelName: "tracing.processor.onTraceStart", | ||
| kind: "async" | ||
| }), | ||
| onTraceEnd: channel({ | ||
| channelName: "tracing.processor.onTraceEnd", | ||
| kind: "async" | ||
| }), | ||
| onSpanStart: channel({ | ||
| channelName: "tracing.processor.onSpanStart", | ||
| kind: "async" | ||
| }), | ||
| onSpanEnd: channel({ | ||
| channelName: "tracing.processor.onSpanEnd", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/langchain-channels.ts | ||
| var langChainChannels = defineChannels("@langchain/core", { | ||
| configure: channel({ | ||
| channelName: "CallbackManager.configure", | ||
| kind: "sync-stream" | ||
| }), | ||
| configureSync: channel({ | ||
| channelName: "CallbackManager._configureSync", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| export { | ||
| __export, | ||
| patchTracingChannel, | ||
| isomorph_default, | ||
| openAIChannels, | ||
| openAICodexChannels, | ||
| anthropicChannels, | ||
| aiSDKChannels, | ||
| claudeAgentSDKChannels, | ||
| cursorSDKChannels, | ||
| openAIAgentsCoreChannels, | ||
| googleGenAIChannels, | ||
| huggingFaceChannels, | ||
| openRouterAgentChannels, | ||
| openRouterChannels, | ||
| mistralChannels, | ||
| googleADKChannels, | ||
| cohereChannels, | ||
| groqChannels, | ||
| bedrockRuntimeChannels, | ||
| smithyCoreChannels, | ||
| smithyClientChannels, | ||
| genkitChannels, | ||
| genkitCoreChannels, | ||
| gitHubCopilotChannels, | ||
| flueChannels, | ||
| langChainChannels, | ||
| piCodingAgentChannels, | ||
| strandsAgentSDKChannels, | ||
| getDefaultInstrumentationIntegrations, | ||
| readDisabledInstrumentationEnvConfig, | ||
| isInstrumentationIntegrationDisabled, | ||
| installMastraExporterFactory, | ||
| classifyMastraTarget, | ||
| patchMastraSource | ||
| }; |
| import { Reporter, Vitest, TestModule } from 'vitest/node'; | ||
| interface BraintrustVitestEvalsReporterOptions { | ||
| projectName?: string; | ||
| projectId?: string; | ||
| experimentName?: string; | ||
| displaySummary?: boolean; | ||
| metadata?: Record<string, unknown>; | ||
| tags?: string[]; | ||
| baseExperiment?: string; | ||
| baseExperimentId?: string; | ||
| } | ||
| declare class BraintrustVitestEvalsReporter implements Reporter { | ||
| private readonly options; | ||
| private experiment?; | ||
| constructor(options?: BraintrustVitestEvalsReporterOptions); | ||
| onInit(_vitest: Vitest): void; | ||
| onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>; | ||
| private getOrCreateExperiment; | ||
| } | ||
| export { BraintrustVitestEvalsReporter as default }; |
| import { Reporter, Vitest, TestModule } from 'vitest/node'; | ||
| interface BraintrustVitestEvalsReporterOptions { | ||
| projectName?: string; | ||
| projectId?: string; | ||
| experimentName?: string; | ||
| displaySummary?: boolean; | ||
| metadata?: Record<string, unknown>; | ||
| tags?: string[]; | ||
| baseExperiment?: string; | ||
| baseExperimentId?: string; | ||
| } | ||
| declare class BraintrustVitestEvalsReporter implements Reporter { | ||
| private readonly options; | ||
| private experiment?; | ||
| constructor(options?: BraintrustVitestEvalsReporterOptions); | ||
| onInit(_vitest: Vitest): void; | ||
| onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>; | ||
| private getOrCreateExperiment; | ||
| } | ||
| export { BraintrustVitestEvalsReporter as default }; |
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } | ||
| var _chunk37RLJF2Ujs = require('./chunk-37RLJF2U.js'); | ||
| require('./chunk-LPC4W2WX.js'); | ||
| // src/wrappers/vitest-evals/reporter.ts | ||
| _chunk37RLJF2Ujs.configureNode.call(void 0, ); | ||
| var RESERVED_NORMALIZED_SPAN_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([ | ||
| "name", | ||
| "type", | ||
| "vitest_evals_kind", | ||
| "trace_id", | ||
| "external_span_id", | ||
| "external_parent_id", | ||
| "status" | ||
| ]); | ||
| var BraintrustVitestEvalsReporter = class { | ||
| constructor(options = {}) { | ||
| this.options = options; | ||
| } | ||
| onInit(_vitest) { | ||
| } | ||
| async onTestRunEnd(testModules) { | ||
| const evalTests = []; | ||
| for (const testModule of testModules) { | ||
| for (const test of testModule.children.allTests()) { | ||
| const candidate = { test, meta: readEvalTaskMeta(test.meta()) }; | ||
| if (isRunnableEvalTest(candidate)) { | ||
| evalTests.push(candidate); | ||
| } | ||
| } | ||
| } | ||
| if (evalTests.length === 0) { | ||
| return; | ||
| } | ||
| const experiment = this.getOrCreateExperiment(); | ||
| for (const { test, meta } of evalTests) { | ||
| logEvalTest(experiment, test, meta); | ||
| } | ||
| await _chunk37RLJF2Ujs.summarizeAndFlush.call(void 0, experiment, { | ||
| displaySummary: this.options.displaySummary | ||
| }); | ||
| this.experiment = void 0; | ||
| } | ||
| getOrCreateExperiment() { | ||
| if (this.experiment) { | ||
| return this.experiment; | ||
| } | ||
| const { projectId, projectName } = this.options; | ||
| if (!projectId && !projectName) { | ||
| throw new Error( | ||
| "Braintrust vitest-evals reporter requires projectName or projectId when eval cases are reported." | ||
| ); | ||
| } | ||
| const experimentName = _nullishCoalesce(this.options.experimentName, () => ( `vitest-evals-${(/* @__PURE__ */ new Date()).toISOString()}`)); | ||
| this.experiment = _chunk37RLJF2Ujs.initExperiment.call(void 0, { | ||
| ...projectId ? { projectId } : { project: projectName }, | ||
| experiment: experimentName, | ||
| metadata: this.options.metadata, | ||
| tags: this.options.tags, | ||
| baseExperiment: this.options.baseExperiment, | ||
| baseExperimentId: this.options.baseExperimentId | ||
| }); | ||
| return this.experiment; | ||
| } | ||
| }; | ||
| function isRunnableEvalTest(candidate) { | ||
| if (!candidate.meta) return false; | ||
| const state = candidate.test.result().state; | ||
| return state !== "skipped" && state !== "pending"; | ||
| } | ||
| function logEvalTest(experiment, test, meta) { | ||
| const result = test.result(); | ||
| const diagnostic = test.diagnostic(); | ||
| const run = _optionalChain([meta, 'access', _ => _.harness, 'optionalAccess', _2 => _2.run]); | ||
| const output = _nullishCoalesce(_optionalChain([meta, 'access', _3 => _3.eval, 'optionalAccess', _4 => _4.output]), () => ( _optionalChain([run, 'optionalAccess', _5 => _5.output]))); | ||
| const scores = buildScores(result.state, meta.eval); | ||
| const metrics = buildMetrics(_optionalChain([diagnostic, 'optionalAccess', _6 => _6.duration]), run); | ||
| const metadata = buildMetadata(test, meta, run); | ||
| const rootSpan = experiment.startSpan({ | ||
| name: test.fullName || test.name, | ||
| spanAttributes: { | ||
| type: "eval" /* EVAL */, | ||
| framework: "vitest", | ||
| reporter: "vitest-evals" | ||
| }, | ||
| startTime: startTimeSeconds(diagnostic), | ||
| event: { | ||
| input: { | ||
| test: test.fullName || test.name, | ||
| input: firstUserMessageContent(run) | ||
| }, | ||
| ...output !== void 0 ? { output } : {}, | ||
| scores, | ||
| metrics, | ||
| metadata, | ||
| ...test.tags.length > 0 ? { tags: test.tags } : {} | ||
| } | ||
| }); | ||
| if (result.state === "failed") { | ||
| for (const error of _nullishCoalesce(result.errors, () => ( []))) { | ||
| logReporterError(rootSpan, error); | ||
| } | ||
| } | ||
| if (_optionalChain([run, 'optionalAccess', _7 => _7.traces, 'optionalAccess', _8 => _8.length])) { | ||
| logNormalizedTraces(rootSpan, run.traces); | ||
| } else { | ||
| logToolCallSpans(rootSpan, toolCallsFromMeta(meta.eval, run)); | ||
| } | ||
| rootSpan.end({ | ||
| endTime: startTimeSeconds(diagnostic) !== void 0 && _optionalChain([diagnostic, 'optionalAccess', _9 => _9.duration]) !== void 0 ? startTimeSeconds(diagnostic) + diagnostic.duration / 1e3 : void 0 | ||
| }); | ||
| } | ||
| function buildScores(state, evalMeta) { | ||
| const scores = { | ||
| pass: state === "passed" ? 1 : 0 | ||
| }; | ||
| if (typeof _optionalChain([evalMeta, 'optionalAccess', _10 => _10.avgScore]) === "number" || _optionalChain([evalMeta, 'optionalAccess', _11 => _11.avgScore]) === null) { | ||
| scores.avg_score = evalMeta.avgScore; | ||
| } | ||
| for (const score of _nullishCoalesce(_optionalChain([evalMeta, 'optionalAccess', _12 => _12.scores]), () => ( []))) { | ||
| if (!score.name) continue; | ||
| if (typeof score.score === "number" || score.score === null) { | ||
| scores[score.name] = score.score; | ||
| } | ||
| } | ||
| return scores; | ||
| } | ||
| function buildMetrics(durationMs, run) { | ||
| const usage = _optionalChain([run, 'optionalAccess', _13 => _13.usage]); | ||
| const metrics = {}; | ||
| if (durationMs !== void 0) { | ||
| metrics.duration_ms = durationMs; | ||
| } | ||
| if (typeof _optionalChain([usage, 'optionalAccess', _14 => _14.inputTokens]) === "number") { | ||
| metrics.input_tokens = usage.inputTokens; | ||
| } | ||
| if (typeof _optionalChain([usage, 'optionalAccess', _15 => _15.outputTokens]) === "number") { | ||
| metrics.output_tokens = usage.outputTokens; | ||
| } | ||
| if (typeof _optionalChain([usage, 'optionalAccess', _16 => _16.reasoningTokens]) === "number") { | ||
| metrics.reasoning_tokens = usage.reasoningTokens; | ||
| } | ||
| if (typeof _optionalChain([usage, 'optionalAccess', _17 => _17.totalTokens]) === "number") { | ||
| metrics.total_tokens = usage.totalTokens; | ||
| } | ||
| if (typeof _optionalChain([usage, 'optionalAccess', _18 => _18.toolCalls]) === "number") { | ||
| metrics.tool_calls = usage.toolCalls; | ||
| } | ||
| if (typeof _optionalChain([usage, 'optionalAccess', _19 => _19.retries]) === "number") { | ||
| metrics.retries = usage.retries; | ||
| } | ||
| return metrics; | ||
| } | ||
| function buildMetadata(test, meta, run) { | ||
| const result = test.result(); | ||
| const metadata = { | ||
| file: _optionalChain([test, 'access', _20 => _20.module, 'optionalAccess', _21 => _21.moduleId]), | ||
| relativeFile: _optionalChain([test, 'access', _22 => _22.module, 'optionalAccess', _23 => _23.relativeModuleId]), | ||
| fullName: test.fullName, | ||
| testId: test.id, | ||
| location: test.location, | ||
| status: result.state, | ||
| failureMessages: (_nullishCoalesce(result.errors, () => ( []))).map(formatErrorMessage), | ||
| harnessName: _optionalChain([meta, 'access', _24 => _24.harness, 'optionalAccess', _25 => _25.name]), | ||
| thresholdFailed: _optionalChain([meta, 'access', _26 => _26.eval, 'optionalAccess', _27 => _27.thresholdFailed]), | ||
| session: _optionalChain([run, 'optionalAccess', _28 => _28.session]), | ||
| artifacts: _optionalChain([run, 'optionalAccess', _29 => _29.artifacts]), | ||
| timings: _optionalChain([run, 'optionalAccess', _30 => _30.timings]), | ||
| errors: _optionalChain([run, 'optionalAccess', _31 => _31.errors]), | ||
| scoreMetadata: Object.fromEntries( | ||
| (_nullishCoalesce(_optionalChain([meta, 'access', _32 => _32.eval, 'optionalAccess', _33 => _33.scores]), () => ( []))).filter((score) => score.name && score.metadata).map((score) => [score.name, score.metadata]) | ||
| ) | ||
| }; | ||
| return Object.fromEntries( | ||
| Object.entries(metadata).filter(([, value]) => value !== void 0) | ||
| ); | ||
| } | ||
| function logNormalizedTraces(rootSpan, traces) { | ||
| for (const trace of traces) { | ||
| const spans = _nullishCoalesce(trace.spans, () => ( [])); | ||
| const spanMap = /* @__PURE__ */ new Map(); | ||
| const pending = [...spans]; | ||
| while (pending.length > 0) { | ||
| const before = pending.length; | ||
| for (let index = pending.length - 1; index >= 0; index--) { | ||
| const normalized = pending[index]; | ||
| const parent = normalized.parentId === void 0 ? rootSpan : spanMap.get(normalized.parentId); | ||
| if (!parent) continue; | ||
| const span = logNormalizedSpan(parent, normalized, trace); | ||
| if (normalized.id) { | ||
| spanMap.set(normalized.id, span); | ||
| } | ||
| pending.splice(index, 1); | ||
| } | ||
| if (pending.length === before) { | ||
| for (const normalized of pending.splice(0)) { | ||
| const span = logNormalizedSpan(rootSpan, normalized, trace); | ||
| if (normalized.id) { | ||
| spanMap.set(normalized.id, span); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| function logNormalizedSpan(parent, normalized, trace) { | ||
| const durationMs = typeof normalized.durationMs === "number" && Number.isFinite(normalized.durationMs) ? normalized.durationMs : void 0; | ||
| const startTime = epochSeconds(normalized.startedAt); | ||
| const endTime = _nullishCoalesce(epochSeconds(normalized.finishedAt), () => ( (startTime !== void 0 && durationMs !== void 0 ? startTime + durationMs / 1e3 : void 0))); | ||
| const span = parent.startSpan({ | ||
| name: _nullishCoalesce(_nullishCoalesce(normalized.name, () => ( normalized.kind)), () => ( "harness span")), | ||
| spanAttributes: { | ||
| ...filteredNormalizedSpanAttributes(normalized.attributes), | ||
| type: spanTypeForNormalizedKind(normalized.kind), | ||
| vitest_evals_kind: normalized.kind, | ||
| trace_id: _nullishCoalesce(normalized.traceId, () => ( trace.id)), | ||
| external_span_id: normalized.id, | ||
| external_parent_id: normalized.parentId, | ||
| status: normalized.status | ||
| }, | ||
| startTime, | ||
| ...durationMs !== void 0 ? { event: { metrics: { duration_ms: durationMs } } } : {} | ||
| }); | ||
| const metadata = { | ||
| traceName: trace.name, | ||
| traceMetadata: trace.metadata, | ||
| events: normalized.events | ||
| }; | ||
| if (Object.values(metadata).some((value) => value !== void 0)) { | ||
| span.log({ | ||
| metadata: Object.fromEntries( | ||
| Object.entries(metadata).filter(([, value]) => value !== void 0) | ||
| ) | ||
| }); | ||
| } | ||
| if (normalized.error !== void 0) { | ||
| logReporterError(span, normalized.error); | ||
| } | ||
| span.end({ endTime }); | ||
| return span; | ||
| } | ||
| function logToolCallSpans(rootSpan, calls) { | ||
| for (const call of calls) { | ||
| if (!call.name) continue; | ||
| const durationMs = typeof call.durationMs === "number" && Number.isFinite(call.durationMs) ? call.durationMs : void 0; | ||
| const startTime = epochSeconds(call.startedAt); | ||
| const endTime = _nullishCoalesce(epochSeconds(call.finishedAt), () => ( (startTime !== void 0 && durationMs !== void 0 ? startTime + durationMs / 1e3 : void 0))); | ||
| const span = rootSpan.startSpan({ | ||
| name: call.name, | ||
| spanAttributes: { | ||
| type: "tool" /* TOOL */, | ||
| tool_call_id: call.id | ||
| }, | ||
| startTime, | ||
| event: { | ||
| input: call.arguments, | ||
| ...call.result !== void 0 ? { output: call.result } : {}, | ||
| metadata: call.metadata, | ||
| metrics: durationMs !== void 0 ? { duration_ms: durationMs } : void 0 | ||
| } | ||
| }); | ||
| if (call.error !== void 0) { | ||
| logReporterError(span, call.error); | ||
| } | ||
| span.end({ endTime }); | ||
| } | ||
| } | ||
| function readEvalTaskMeta(input) { | ||
| if (!_chunk37RLJF2Ujs.isObject.call(void 0, input)) return void 0; | ||
| const evalMeta = readEvalMeta(input.eval); | ||
| const harnessMeta = readHarnessMeta(input.harness); | ||
| if (!evalMeta && !harnessMeta) return void 0; | ||
| return { | ||
| ...evalMeta ? { eval: evalMeta } : {}, | ||
| ...harnessMeta ? { harness: harnessMeta } : {} | ||
| }; | ||
| } | ||
| function readEvalMeta(input) { | ||
| if (!_chunk37RLJF2Ujs.isObject.call(void 0, input)) return void 0; | ||
| const avgScore = readFiniteOrNull(input.avgScore); | ||
| const scores = Array.isArray(input.scores) ? input.scores.map(readEvalScore).filter(isDefined) : void 0; | ||
| const toolCalls = Array.isArray(input.toolCalls) ? input.toolCalls.map(readToolCall).filter(isDefined) : void 0; | ||
| return { | ||
| ...scores ? { scores } : {}, | ||
| ...avgScore !== void 0 ? { avgScore } : {}, | ||
| ...input.output !== void 0 ? { output: input.output } : {}, | ||
| ...typeof input.thresholdFailed === "boolean" ? { thresholdFailed: input.thresholdFailed } : {}, | ||
| ...toolCalls ? { toolCalls } : {} | ||
| }; | ||
| } | ||
| function readEvalScore(input) { | ||
| if (!_chunk37RLJF2Ujs.isObject.call(void 0, input)) return void 0; | ||
| const score = readFiniteOrNull(input.score); | ||
| return { | ||
| ...typeof input.name === "string" ? { name: input.name } : {}, | ||
| ...score !== void 0 ? { score } : {}, | ||
| ..._chunk37RLJF2Ujs.isObject.call(void 0, input.metadata) ? { metadata: input.metadata } : {} | ||
| }; | ||
| } | ||
| function readHarnessMeta(input) { | ||
| if (!_chunk37RLJF2Ujs.isObject.call(void 0, input)) return void 0; | ||
| return { | ||
| ...typeof input.name === "string" ? { name: input.name } : {}, | ||
| ..._chunk37RLJF2Ujs.isObject.call(void 0, input.run) ? { run: input.run } : {} | ||
| }; | ||
| } | ||
| function readToolCall(input) { | ||
| if (!_chunk37RLJF2Ujs.isObject.call(void 0, input)) return void 0; | ||
| return input; | ||
| } | ||
| function filteredNormalizedSpanAttributes(attributes) { | ||
| if (!attributes) return {}; | ||
| return Object.fromEntries( | ||
| Object.entries(attributes).filter( | ||
| ([key]) => !RESERVED_NORMALIZED_SPAN_ATTRIBUTE_KEYS.has(key) | ||
| ) | ||
| ); | ||
| } | ||
| function readFiniteOrNull(value) { | ||
| if (value === null) return null; | ||
| if (typeof value === "number" && Number.isFinite(value)) { | ||
| return value; | ||
| } | ||
| return void 0; | ||
| } | ||
| function isDefined(value) { | ||
| return value !== void 0; | ||
| } | ||
| function firstUserMessageContent(run) { | ||
| return _optionalChain([run, 'optionalAccess', _34 => _34.session, 'optionalAccess', _35 => _35.messages, 'optionalAccess', _36 => _36.find, 'call', _37 => _37((message) => message.role === "user"), 'optionalAccess', _38 => _38.content]); | ||
| } | ||
| function toolCallsFromRun(run) { | ||
| const calls = []; | ||
| for (const message of _nullishCoalesce(_optionalChain([run, 'optionalAccess', _39 => _39.session, 'optionalAccess', _40 => _40.messages]), () => ( []))) { | ||
| if (Array.isArray(message.toolCalls)) { | ||
| calls.push(...message.toolCalls); | ||
| } | ||
| } | ||
| return calls; | ||
| } | ||
| function toolCallsFromMeta(evalMeta, run) { | ||
| const runCalls = toolCallsFromRun(run); | ||
| return runCalls.length > 0 ? runCalls : _nullishCoalesce(_optionalChain([evalMeta, 'optionalAccess', _41 => _41.toolCalls]), () => ( [])); | ||
| } | ||
| function spanTypeForNormalizedKind(kind) { | ||
| switch (kind) { | ||
| case "model": | ||
| return "llm" /* LLM */; | ||
| case "tool": | ||
| return "tool" /* TOOL */; | ||
| case "agent": | ||
| case "run": | ||
| return "task" /* TASK */; | ||
| default: | ||
| return "function" /* FUNCTION */; | ||
| } | ||
| } | ||
| function startTimeSeconds(diagnostic) { | ||
| return _optionalChain([diagnostic, 'optionalAccess', _42 => _42.startTime]) === void 0 ? void 0 : diagnostic.startTime / 1e3; | ||
| } | ||
| function epochSeconds(value) { | ||
| if (value === void 0) return void 0; | ||
| const ms = Date.parse(value); | ||
| return Number.isFinite(ms) ? ms / 1e3 : void 0; | ||
| } | ||
| function logReporterError(span, error) { | ||
| if (error instanceof Error) { | ||
| _chunk37RLJF2Ujs.logError.call(void 0, span, error); | ||
| return; | ||
| } | ||
| if (_chunk37RLJF2Ujs.isObject.call(void 0, error)) { | ||
| const message = typeof error.message === "string" ? error.message : void 0; | ||
| const stack = typeof error.stack === "string" ? error.stack : void 0; | ||
| if (message !== void 0 || stack !== void 0) { | ||
| span.log({ | ||
| error: stack ? `${_nullishCoalesce(message, () => ( "<error>"))} | ||
| ${stack}` : message | ||
| }); | ||
| return; | ||
| } | ||
| } | ||
| _chunk37RLJF2Ujs.logError.call(void 0, span, error); | ||
| } | ||
| function formatErrorMessage(error) { | ||
| if (_chunk37RLJF2Ujs.isObject.call(void 0, error)) { | ||
| if (typeof error.message === "string") return error.message; | ||
| if (typeof error.stack === "string") return error.stack; | ||
| } | ||
| if (error instanceof Error) return error.message; | ||
| return String(error); | ||
| } | ||
| exports.default = BraintrustVitestEvalsReporter; |
| import { | ||
| configureNode, | ||
| initExperiment, | ||
| isObject, | ||
| logError, | ||
| summarizeAndFlush | ||
| } from "./chunk-VEQ2PCMC.mjs"; | ||
| import "./chunk-Y7W7WP6H.mjs"; | ||
| // src/wrappers/vitest-evals/reporter.ts | ||
| configureNode(); | ||
| var RESERVED_NORMALIZED_SPAN_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([ | ||
| "name", | ||
| "type", | ||
| "vitest_evals_kind", | ||
| "trace_id", | ||
| "external_span_id", | ||
| "external_parent_id", | ||
| "status" | ||
| ]); | ||
| var BraintrustVitestEvalsReporter = class { | ||
| constructor(options = {}) { | ||
| this.options = options; | ||
| } | ||
| experiment; | ||
| onInit(_vitest) { | ||
| } | ||
| async onTestRunEnd(testModules) { | ||
| const evalTests = []; | ||
| for (const testModule of testModules) { | ||
| for (const test of testModule.children.allTests()) { | ||
| const candidate = { test, meta: readEvalTaskMeta(test.meta()) }; | ||
| if (isRunnableEvalTest(candidate)) { | ||
| evalTests.push(candidate); | ||
| } | ||
| } | ||
| } | ||
| if (evalTests.length === 0) { | ||
| return; | ||
| } | ||
| const experiment = this.getOrCreateExperiment(); | ||
| for (const { test, meta } of evalTests) { | ||
| logEvalTest(experiment, test, meta); | ||
| } | ||
| await summarizeAndFlush(experiment, { | ||
| displaySummary: this.options.displaySummary | ||
| }); | ||
| this.experiment = void 0; | ||
| } | ||
| getOrCreateExperiment() { | ||
| if (this.experiment) { | ||
| return this.experiment; | ||
| } | ||
| const { projectId, projectName } = this.options; | ||
| if (!projectId && !projectName) { | ||
| throw new Error( | ||
| "Braintrust vitest-evals reporter requires projectName or projectId when eval cases are reported." | ||
| ); | ||
| } | ||
| const experimentName = this.options.experimentName ?? `vitest-evals-${(/* @__PURE__ */ new Date()).toISOString()}`; | ||
| this.experiment = initExperiment({ | ||
| ...projectId ? { projectId } : { project: projectName }, | ||
| experiment: experimentName, | ||
| metadata: this.options.metadata, | ||
| tags: this.options.tags, | ||
| baseExperiment: this.options.baseExperiment, | ||
| baseExperimentId: this.options.baseExperimentId | ||
| }); | ||
| return this.experiment; | ||
| } | ||
| }; | ||
| function isRunnableEvalTest(candidate) { | ||
| if (!candidate.meta) return false; | ||
| const state = candidate.test.result().state; | ||
| return state !== "skipped" && state !== "pending"; | ||
| } | ||
| function logEvalTest(experiment, test, meta) { | ||
| const result = test.result(); | ||
| const diagnostic = test.diagnostic(); | ||
| const run = meta.harness?.run; | ||
| const output = meta.eval?.output ?? run?.output; | ||
| const scores = buildScores(result.state, meta.eval); | ||
| const metrics = buildMetrics(diagnostic?.duration, run); | ||
| const metadata = buildMetadata(test, meta, run); | ||
| const rootSpan = experiment.startSpan({ | ||
| name: test.fullName || test.name, | ||
| spanAttributes: { | ||
| type: "eval" /* EVAL */, | ||
| framework: "vitest", | ||
| reporter: "vitest-evals" | ||
| }, | ||
| startTime: startTimeSeconds(diagnostic), | ||
| event: { | ||
| input: { | ||
| test: test.fullName || test.name, | ||
| input: firstUserMessageContent(run) | ||
| }, | ||
| ...output !== void 0 ? { output } : {}, | ||
| scores, | ||
| metrics, | ||
| metadata, | ||
| ...test.tags.length > 0 ? { tags: test.tags } : {} | ||
| } | ||
| }); | ||
| if (result.state === "failed") { | ||
| for (const error of result.errors ?? []) { | ||
| logReporterError(rootSpan, error); | ||
| } | ||
| } | ||
| if (run?.traces?.length) { | ||
| logNormalizedTraces(rootSpan, run.traces); | ||
| } else { | ||
| logToolCallSpans(rootSpan, toolCallsFromMeta(meta.eval, run)); | ||
| } | ||
| rootSpan.end({ | ||
| endTime: startTimeSeconds(diagnostic) !== void 0 && diagnostic?.duration !== void 0 ? startTimeSeconds(diagnostic) + diagnostic.duration / 1e3 : void 0 | ||
| }); | ||
| } | ||
| function buildScores(state, evalMeta) { | ||
| const scores = { | ||
| pass: state === "passed" ? 1 : 0 | ||
| }; | ||
| if (typeof evalMeta?.avgScore === "number" || evalMeta?.avgScore === null) { | ||
| scores.avg_score = evalMeta.avgScore; | ||
| } | ||
| for (const score of evalMeta?.scores ?? []) { | ||
| if (!score.name) continue; | ||
| if (typeof score.score === "number" || score.score === null) { | ||
| scores[score.name] = score.score; | ||
| } | ||
| } | ||
| return scores; | ||
| } | ||
| function buildMetrics(durationMs, run) { | ||
| const usage = run?.usage; | ||
| const metrics = {}; | ||
| if (durationMs !== void 0) { | ||
| metrics.duration_ms = durationMs; | ||
| } | ||
| if (typeof usage?.inputTokens === "number") { | ||
| metrics.input_tokens = usage.inputTokens; | ||
| } | ||
| if (typeof usage?.outputTokens === "number") { | ||
| metrics.output_tokens = usage.outputTokens; | ||
| } | ||
| if (typeof usage?.reasoningTokens === "number") { | ||
| metrics.reasoning_tokens = usage.reasoningTokens; | ||
| } | ||
| if (typeof usage?.totalTokens === "number") { | ||
| metrics.total_tokens = usage.totalTokens; | ||
| } | ||
| if (typeof usage?.toolCalls === "number") { | ||
| metrics.tool_calls = usage.toolCalls; | ||
| } | ||
| if (typeof usage?.retries === "number") { | ||
| metrics.retries = usage.retries; | ||
| } | ||
| return metrics; | ||
| } | ||
| function buildMetadata(test, meta, run) { | ||
| const result = test.result(); | ||
| const metadata = { | ||
| file: test.module?.moduleId, | ||
| relativeFile: test.module?.relativeModuleId, | ||
| fullName: test.fullName, | ||
| testId: test.id, | ||
| location: test.location, | ||
| status: result.state, | ||
| failureMessages: (result.errors ?? []).map(formatErrorMessage), | ||
| harnessName: meta.harness?.name, | ||
| thresholdFailed: meta.eval?.thresholdFailed, | ||
| session: run?.session, | ||
| artifacts: run?.artifacts, | ||
| timings: run?.timings, | ||
| errors: run?.errors, | ||
| scoreMetadata: Object.fromEntries( | ||
| (meta.eval?.scores ?? []).filter((score) => score.name && score.metadata).map((score) => [score.name, score.metadata]) | ||
| ) | ||
| }; | ||
| return Object.fromEntries( | ||
| Object.entries(metadata).filter(([, value]) => value !== void 0) | ||
| ); | ||
| } | ||
| function logNormalizedTraces(rootSpan, traces) { | ||
| for (const trace of traces) { | ||
| const spans = trace.spans ?? []; | ||
| const spanMap = /* @__PURE__ */ new Map(); | ||
| const pending = [...spans]; | ||
| while (pending.length > 0) { | ||
| const before = pending.length; | ||
| for (let index = pending.length - 1; index >= 0; index--) { | ||
| const normalized = pending[index]; | ||
| const parent = normalized.parentId === void 0 ? rootSpan : spanMap.get(normalized.parentId); | ||
| if (!parent) continue; | ||
| const span = logNormalizedSpan(parent, normalized, trace); | ||
| if (normalized.id) { | ||
| spanMap.set(normalized.id, span); | ||
| } | ||
| pending.splice(index, 1); | ||
| } | ||
| if (pending.length === before) { | ||
| for (const normalized of pending.splice(0)) { | ||
| const span = logNormalizedSpan(rootSpan, normalized, trace); | ||
| if (normalized.id) { | ||
| spanMap.set(normalized.id, span); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| function logNormalizedSpan(parent, normalized, trace) { | ||
| const durationMs = typeof normalized.durationMs === "number" && Number.isFinite(normalized.durationMs) ? normalized.durationMs : void 0; | ||
| const startTime = epochSeconds(normalized.startedAt); | ||
| const endTime = epochSeconds(normalized.finishedAt) ?? (startTime !== void 0 && durationMs !== void 0 ? startTime + durationMs / 1e3 : void 0); | ||
| const span = parent.startSpan({ | ||
| name: normalized.name ?? normalized.kind ?? "harness span", | ||
| spanAttributes: { | ||
| ...filteredNormalizedSpanAttributes(normalized.attributes), | ||
| type: spanTypeForNormalizedKind(normalized.kind), | ||
| vitest_evals_kind: normalized.kind, | ||
| trace_id: normalized.traceId ?? trace.id, | ||
| external_span_id: normalized.id, | ||
| external_parent_id: normalized.parentId, | ||
| status: normalized.status | ||
| }, | ||
| startTime, | ||
| ...durationMs !== void 0 ? { event: { metrics: { duration_ms: durationMs } } } : {} | ||
| }); | ||
| const metadata = { | ||
| traceName: trace.name, | ||
| traceMetadata: trace.metadata, | ||
| events: normalized.events | ||
| }; | ||
| if (Object.values(metadata).some((value) => value !== void 0)) { | ||
| span.log({ | ||
| metadata: Object.fromEntries( | ||
| Object.entries(metadata).filter(([, value]) => value !== void 0) | ||
| ) | ||
| }); | ||
| } | ||
| if (normalized.error !== void 0) { | ||
| logReporterError(span, normalized.error); | ||
| } | ||
| span.end({ endTime }); | ||
| return span; | ||
| } | ||
| function logToolCallSpans(rootSpan, calls) { | ||
| for (const call of calls) { | ||
| if (!call.name) continue; | ||
| const durationMs = typeof call.durationMs === "number" && Number.isFinite(call.durationMs) ? call.durationMs : void 0; | ||
| const startTime = epochSeconds(call.startedAt); | ||
| const endTime = epochSeconds(call.finishedAt) ?? (startTime !== void 0 && durationMs !== void 0 ? startTime + durationMs / 1e3 : void 0); | ||
| const span = rootSpan.startSpan({ | ||
| name: call.name, | ||
| spanAttributes: { | ||
| type: "tool" /* TOOL */, | ||
| tool_call_id: call.id | ||
| }, | ||
| startTime, | ||
| event: { | ||
| input: call.arguments, | ||
| ...call.result !== void 0 ? { output: call.result } : {}, | ||
| metadata: call.metadata, | ||
| metrics: durationMs !== void 0 ? { duration_ms: durationMs } : void 0 | ||
| } | ||
| }); | ||
| if (call.error !== void 0) { | ||
| logReporterError(span, call.error); | ||
| } | ||
| span.end({ endTime }); | ||
| } | ||
| } | ||
| function readEvalTaskMeta(input) { | ||
| if (!isObject(input)) return void 0; | ||
| const evalMeta = readEvalMeta(input.eval); | ||
| const harnessMeta = readHarnessMeta(input.harness); | ||
| if (!evalMeta && !harnessMeta) return void 0; | ||
| return { | ||
| ...evalMeta ? { eval: evalMeta } : {}, | ||
| ...harnessMeta ? { harness: harnessMeta } : {} | ||
| }; | ||
| } | ||
| function readEvalMeta(input) { | ||
| if (!isObject(input)) return void 0; | ||
| const avgScore = readFiniteOrNull(input.avgScore); | ||
| const scores = Array.isArray(input.scores) ? input.scores.map(readEvalScore).filter(isDefined) : void 0; | ||
| const toolCalls = Array.isArray(input.toolCalls) ? input.toolCalls.map(readToolCall).filter(isDefined) : void 0; | ||
| return { | ||
| ...scores ? { scores } : {}, | ||
| ...avgScore !== void 0 ? { avgScore } : {}, | ||
| ...input.output !== void 0 ? { output: input.output } : {}, | ||
| ...typeof input.thresholdFailed === "boolean" ? { thresholdFailed: input.thresholdFailed } : {}, | ||
| ...toolCalls ? { toolCalls } : {} | ||
| }; | ||
| } | ||
| function readEvalScore(input) { | ||
| if (!isObject(input)) return void 0; | ||
| const score = readFiniteOrNull(input.score); | ||
| return { | ||
| ...typeof input.name === "string" ? { name: input.name } : {}, | ||
| ...score !== void 0 ? { score } : {}, | ||
| ...isObject(input.metadata) ? { metadata: input.metadata } : {} | ||
| }; | ||
| } | ||
| function readHarnessMeta(input) { | ||
| if (!isObject(input)) return void 0; | ||
| return { | ||
| ...typeof input.name === "string" ? { name: input.name } : {}, | ||
| ...isObject(input.run) ? { run: input.run } : {} | ||
| }; | ||
| } | ||
| function readToolCall(input) { | ||
| if (!isObject(input)) return void 0; | ||
| return input; | ||
| } | ||
| function filteredNormalizedSpanAttributes(attributes) { | ||
| if (!attributes) return {}; | ||
| return Object.fromEntries( | ||
| Object.entries(attributes).filter( | ||
| ([key]) => !RESERVED_NORMALIZED_SPAN_ATTRIBUTE_KEYS.has(key) | ||
| ) | ||
| ); | ||
| } | ||
| function readFiniteOrNull(value) { | ||
| if (value === null) return null; | ||
| if (typeof value === "number" && Number.isFinite(value)) { | ||
| return value; | ||
| } | ||
| return void 0; | ||
| } | ||
| function isDefined(value) { | ||
| return value !== void 0; | ||
| } | ||
| function firstUserMessageContent(run) { | ||
| return run?.session?.messages?.find((message) => message.role === "user")?.content; | ||
| } | ||
| function toolCallsFromRun(run) { | ||
| const calls = []; | ||
| for (const message of run?.session?.messages ?? []) { | ||
| if (Array.isArray(message.toolCalls)) { | ||
| calls.push(...message.toolCalls); | ||
| } | ||
| } | ||
| return calls; | ||
| } | ||
| function toolCallsFromMeta(evalMeta, run) { | ||
| const runCalls = toolCallsFromRun(run); | ||
| return runCalls.length > 0 ? runCalls : evalMeta?.toolCalls ?? []; | ||
| } | ||
| function spanTypeForNormalizedKind(kind) { | ||
| switch (kind) { | ||
| case "model": | ||
| return "llm" /* LLM */; | ||
| case "tool": | ||
| return "tool" /* TOOL */; | ||
| case "agent": | ||
| case "run": | ||
| return "task" /* TASK */; | ||
| default: | ||
| return "function" /* FUNCTION */; | ||
| } | ||
| } | ||
| function startTimeSeconds(diagnostic) { | ||
| return diagnostic?.startTime === void 0 ? void 0 : diagnostic.startTime / 1e3; | ||
| } | ||
| function epochSeconds(value) { | ||
| if (value === void 0) return void 0; | ||
| const ms = Date.parse(value); | ||
| return Number.isFinite(ms) ? ms / 1e3 : void 0; | ||
| } | ||
| function logReporterError(span, error) { | ||
| if (error instanceof Error) { | ||
| logError(span, error); | ||
| return; | ||
| } | ||
| if (isObject(error)) { | ||
| const message = typeof error.message === "string" ? error.message : void 0; | ||
| const stack = typeof error.stack === "string" ? error.stack : void 0; | ||
| if (message !== void 0 || stack !== void 0) { | ||
| span.log({ | ||
| error: stack ? `${message ?? "<error>"} | ||
| ${stack}` : message | ||
| }); | ||
| return; | ||
| } | ||
| } | ||
| logError(span, error); | ||
| } | ||
| function formatErrorMessage(error) { | ||
| if (isObject(error)) { | ||
| if (typeof error.message === "string") return error.message; | ||
| if (typeof error.stack === "string") return error.stack; | ||
| } | ||
| if (error instanceof Error) return error.message; | ||
| return String(error); | ||
| } | ||
| export { | ||
| BraintrustVitestEvalsReporter as default | ||
| }; |
| import { | ||
| unplugin | ||
| } from "../chunk-GNUEZ2PE.mjs"; | ||
| import "../chunk-ZYKZEMRT.mjs"; | ||
| } from "../chunk-S4374IP6.mjs"; | ||
| import "../chunk-W4E36GIW.mjs"; | ||
| import "../chunk-J57YF7WS.mjs"; | ||
@@ -6,0 +6,0 @@ |
| import { | ||
| webpackPlugin | ||
| } from "../chunk-MYCHHXOE.mjs"; | ||
| import "../chunk-GNUEZ2PE.mjs"; | ||
| import "../chunk-ZYKZEMRT.mjs"; | ||
| } from "../chunk-K74TZGGM.mjs"; | ||
| import "../chunk-S4374IP6.mjs"; | ||
| import "../chunk-W4E36GIW.mjs"; | ||
| import "../chunk-J57YF7WS.mjs"; | ||
@@ -7,0 +7,0 @@ |
| import { | ||
| unplugin | ||
| } from "../chunk-GNUEZ2PE.mjs"; | ||
| import "../chunk-ZYKZEMRT.mjs"; | ||
| } from "../chunk-S4374IP6.mjs"; | ||
| import "../chunk-W4E36GIW.mjs"; | ||
| import "../chunk-J57YF7WS.mjs"; | ||
@@ -6,0 +6,0 @@ |
| import { | ||
| unplugin | ||
| } from "../chunk-GNUEZ2PE.mjs"; | ||
| import "../chunk-ZYKZEMRT.mjs"; | ||
| } from "../chunk-S4374IP6.mjs"; | ||
| import "../chunk-W4E36GIW.mjs"; | ||
| import "../chunk-J57YF7WS.mjs"; | ||
@@ -6,0 +6,0 @@ |
| import { | ||
| braintrustWebpackPlugin, | ||
| webpackPlugin | ||
| } from "../chunk-MYCHHXOE.mjs"; | ||
| import "../chunk-GNUEZ2PE.mjs"; | ||
| import "../chunk-ZYKZEMRT.mjs"; | ||
| } from "../chunk-K74TZGGM.mjs"; | ||
| import "../chunk-S4374IP6.mjs"; | ||
| import "../chunk-W4E36GIW.mjs"; | ||
| import "../chunk-J57YF7WS.mjs"; | ||
@@ -8,0 +8,0 @@ export { |
@@ -32,2 +32,4 @@ import { InstrumentationConfig } from '@apm-js-collab/code-transformer'; | ||
| declare const bedrockRuntimeConfigs: InstrumentationConfig[]; | ||
| /** | ||
@@ -116,2 +118,2 @@ * Instrumentation configurations for the Vercel AI SDK. | ||
| export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, langchainConfigs, mistralConfigs, openAIAgentsCoreConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs, piCodingAgentConfigs }; | ||
| export { aiSDKConfigs, anthropicConfigs, bedrockRuntimeConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, langchainConfigs, mistralConfigs, openAIAgentsCoreConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs, piCodingAgentConfigs }; |
@@ -32,2 +32,4 @@ import { InstrumentationConfig } from '@apm-js-collab/code-transformer'; | ||
| declare const bedrockRuntimeConfigs: InstrumentationConfig[]; | ||
| /** | ||
@@ -116,2 +118,2 @@ * Instrumentation configurations for the Vercel AI SDK. | ||
| export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, langchainConfigs, mistralConfigs, openAIAgentsCoreConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs, piCodingAgentConfigs }; | ||
| export { aiSDKConfigs, anthropicConfigs, bedrockRuntimeConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, langchainConfigs, mistralConfigs, openAIAgentsCoreConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs, piCodingAgentConfigs }; |
| import { | ||
| aiSDKConfigs, | ||
| anthropicConfigs, | ||
| bedrockRuntimeConfigs, | ||
| claudeAgentSDKConfigs, | ||
@@ -21,6 +22,7 @@ cohereConfigs, | ||
| piCodingAgentConfigs | ||
| } from "./chunk-ZYKZEMRT.mjs"; | ||
| } from "./chunk-W4E36GIW.mjs"; | ||
| export { | ||
| aiSDKConfigs, | ||
| anthropicConfigs, | ||
| bedrockRuntimeConfigs, | ||
| claudeAgentSDKConfigs, | ||
@@ -27,0 +29,0 @@ cohereConfigs, |
@@ -1,2 +0,2 @@ | ||
| export { AnyDataset, Attachment, AttachmentParams, AttachmentReference, BRAINTRUST_CURRENT_SPAN_STORE, BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME, BackgroundLoggerOpts, BaseAttachment, BaseExperiment, BaseMetadata, BraintrustLangChainCallbackHandler, BraintrustMiddleware, BraintrustObservabilityExporter, BraintrustState, BraintrustStream, BraintrustStreamChunk, CachedSpanFetcher, ChatPrompt, CodeFunction, CodeOpts, CodePrompt, CommentEvent, CompiledPrompt, CompiledPromptParams, CompletionPrompt, ContextManager, ContextParentSpanIds, CreateProjectOpts, CurrentSpanStore, DEFAULT_FETCH_BATCH_SIZE, DEFAULT_MAX_REQUEST_SIZE, DataSummary, Dataset, DatasetPipeline, DatasetRecord, DatasetRestorePreviewResult, DatasetRestoreResult, DatasetSnapshot, DatasetSummary, DefaultMetadataType, DefaultPromptArgs, ERR_PERMALINK, EndSpanArgs, Eval, EvalCase, EvalClassifier, EvalHooks, EvalParameterSerializedSchema, EvalParameters, EvalResult, EvalResultWithSummary, EvalScorer, EvalScorerArgs, EvalTask, Evaluator, EvaluatorDef, EvaluatorDefinition, EvaluatorDefinitions, EvaluatorFile, EvaluatorManifest, Experiment, ExperimentLogFullArgs, ExperimentLogPartialArgs, ExperimentSummary, Exportable, ExternalAttachment, ExternalAttachmentParams, FailedHTTPResponse, FullInitDatasetOptions, FullInitOptions, FullLoginOptions, FunctionEvent, GetThreadOptions, IDGenerator, IdField, InitDatasetOptions, InitLoggerOptions, InitOptions, InputField, InstrumentationConfig, InvokeFunctionArgs, InvokeReturn, JSONAttachment, LEGACY_CACHED_HEADER, LOGS3_OVERFLOW_REFERENCE_TYPE, LangChainCallbackHandlerOptions, LazyValue, LoadPromptOptions, LocalTrace, LogCommentFullArgs, LogFeedbackFullArgs, LogOptions, Logger, LoginInvalidOrgError, LoginOptions, Logs3OverflowInputRow, Logs3OverflowUpload, MastraObservabilityExporter, MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, ObjectFetcher, ObjectMetadata, OtherExperimentLogFields, ParametersSource, ParentExperimentIds, ParentProjectLogIds, Project, ProjectNameIdMap, PromiseUnless, Prompt, PromptBuilder, PromptContents, PromptDefinition, PromptDefinitionWithTools, PromptOpts, PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, RegisterSandboxOptions, RegisterSandboxResult, Reporter, ReporterBody, SandboxConfig, ScoreSummary, ScorerBuilder, ScorerOpts, SerializedBraintrustState, SetCurrentArg, Span, SpanContext, SpanData, SpanFetcher, SpanImpl, StartSpanArgs, TemplateFormat, TemplateRenderer, TemplateRendererPlugin, TestBackgroundLogger, ToolBuilder, Trace, UUIDGenerator, WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalIso, _internalSetInitialState, addAzureBlobHeaders, braintrustAISDKTelemetry, braintrustFlueObserver, braintrustStreamChunkSchema, buildLocalSummary, configureInstrumentation, constructLogs3OverflowRequest, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, deepCopyEvent, default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getContextManager, getIdGenerator, getPromptVersions, getSpanParentObject, getTemplateRenderer, graph, init, initDataset, initExperiment, initFunction, initLogger, initNodeTestSuite, invoke, isTemplateFormat, loadParameters, loadPrompt, log, logError, login, loginToState, logs3OverflowUploadSchema, newId, parseCachedHeader, parseTemplateFormat, permalink, pickLogs3OverflowObjectIds, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, registerOtelFlush, registerSandbox, registerTemplatePlugin, renderMessage, renderPromptParams, renderTemplateContent, reportFailures, runEvaluator, setFetch, setMaskingFunction, spanComponentsToObjectId, startSpan, summarize, templateRegistry, toolFunctionDefinitionSchema, traceable, traced, updateSpan, uploadLogs3OverflowPayload, utf8ByteLength, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDK, wrapAISDKModel, wrapAgentClass, wrapAnthropic, wrapClaudeAgentSDK, wrapCohere, wrapCopilotClient, wrapCursorSDK, wrapGenkit, wrapGoogleADK, wrapGoogleGenAI, wrapGroq, wrapHuggingFace, wrapMastraAgent, wrapMistral, wrapOpenAI, wrapOpenAICodexSDK, wrapOpenAIv4, wrapOpenRouter, wrapOpenRouterAgent, wrapPiCodingAgentSDK, wrapTraced, wrapVitest } from './browser.mjs'; | ||
| export { AnyDataset, Attachment, AttachmentParams, AttachmentReference, BRAINTRUST_CURRENT_SPAN_STORE, BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME, BackgroundLoggerOpts, BaseAttachment, BaseExperiment, BaseMetadata, BraintrustLangChainCallbackHandler, BraintrustMiddleware, BraintrustObservabilityExporter, BraintrustState, BraintrustStream, BraintrustStreamChunk, CachedSpanFetcher, ChatPrompt, CodeFunction, CodeOpts, CodePrompt, CommentEvent, CompiledPrompt, CompiledPromptParams, CompletionPrompt, ContextManager, ContextParentSpanIds, CreateProjectOpts, CurrentSpanStore, DEFAULT_FETCH_BATCH_SIZE, DEFAULT_MAX_REQUEST_SIZE, DataSummary, Dataset, DatasetPipeline, DatasetRecord, DatasetRestorePreviewResult, DatasetRestoreResult, DatasetSnapshot, DatasetSummary, DefaultMetadataType, DefaultPromptArgs, ERR_PERMALINK, EndSpanArgs, Eval, EvalCase, EvalClassifier, EvalHooks, EvalParameterSerializedSchema, EvalParameters, EvalResult, EvalResultWithSummary, EvalScorer, EvalScorerArgs, EvalTask, Evaluator, EvaluatorDef, EvaluatorDefinition, EvaluatorDefinitions, EvaluatorFile, EvaluatorManifest, Experiment, ExperimentLogFullArgs, ExperimentLogPartialArgs, ExperimentSummary, Exportable, ExternalAttachment, ExternalAttachmentParams, FailedHTTPResponse, FullInitDatasetOptions, FullInitOptions, FullLoginOptions, FunctionEvent, GetThreadOptions, IDGenerator, IdField, InitDatasetOptions, InitLoggerOptions, InitOptions, InputField, InstrumentationConfig, InvokeFunctionArgs, InvokeReturn, JSONAttachment, LEGACY_CACHED_HEADER, LOGS3_OVERFLOW_REFERENCE_TYPE, LangChainCallbackHandlerOptions, LazyValue, LoadPromptOptions, LocalTrace, LogCommentFullArgs, LogFeedbackFullArgs, LogOptions, Logger, LoginInvalidOrgError, LoginOptions, Logs3OverflowInputRow, Logs3OverflowUpload, MastraObservabilityExporter, MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, ObjectFetcher, ObjectMetadata, OtherExperimentLogFields, ParametersSource, ParentExperimentIds, ParentProjectLogIds, Project, ProjectNameIdMap, PromiseUnless, Prompt, PromptBuilder, PromptContents, PromptDefinition, PromptDefinitionWithTools, PromptOpts, PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, RegisterSandboxOptions, RegisterSandboxResult, Reporter, ReporterBody, SandboxConfig, ScoreSummary, ScorerBuilder, ScorerOpts, SerializedBraintrustState, SetCurrentArg, Span, SpanContext, SpanData, SpanFetcher, SpanImpl, StartSpanArgs, TemplateFormat, TemplateRenderer, TemplateRendererPlugin, TestBackgroundLogger, ToolBuilder, Trace, UUIDGenerator, WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalIso, _internalSetInitialState, addAzureBlobHeaders, braintrustAISDKTelemetry, braintrustFlueObserver, braintrustStreamChunkSchema, buildLocalSummary, configureInstrumentation, constructLogs3OverflowRequest, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, deepCopyEvent, default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getContextManager, getIdGenerator, getPromptVersions, getSpanParentObject, getTemplateRenderer, graph, init, initDataset, initExperiment, initFunction, initLogger, initNodeTestSuite, invoke, isTemplateFormat, loadParameters, loadPrompt, log, logError, login, loginToState, logs3OverflowUploadSchema, newId, parseCachedHeader, parseTemplateFormat, permalink, pickLogs3OverflowObjectIds, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, registerOtelFlush, registerSandbox, registerTemplatePlugin, renderMessage, renderPromptParams, renderTemplateContent, reportFailures, runEvaluator, setFetch, setMaskingFunction, spanComponentsToObjectId, startSpan, summarize, templateRegistry, toolFunctionDefinitionSchema, traceable, traced, updateSpan, uploadLogs3OverflowPayload, utf8ByteLength, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDK, wrapAISDKModel, wrapAgentClass, wrapAnthropic, wrapBedrockRuntime, wrapClaudeAgentSDK, wrapCohere, wrapCopilotClient, wrapCursorSDK, wrapGenkit, wrapGoogleADK, wrapGoogleGenAI, wrapGroq, wrapHuggingFace, wrapMastraAgent, wrapMistral, wrapOpenAI, wrapOpenAICodexSDK, wrapOpenAIv4, wrapOpenRouter, wrapOpenRouterAgent, wrapPiCodingAgentSDK, wrapStrandsAgentSDK, wrapTraced, wrapVitest } from './browser.mjs'; | ||
| import 'zod/v3'; |
@@ -1,2 +0,2 @@ | ||
| export { AnyDataset, Attachment, AttachmentParams, AttachmentReference, BRAINTRUST_CURRENT_SPAN_STORE, BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME, BackgroundLoggerOpts, BaseAttachment, BaseExperiment, BaseMetadata, BraintrustLangChainCallbackHandler, BraintrustMiddleware, BraintrustObservabilityExporter, BraintrustState, BraintrustStream, BraintrustStreamChunk, CachedSpanFetcher, ChatPrompt, CodeFunction, CodeOpts, CodePrompt, CommentEvent, CompiledPrompt, CompiledPromptParams, CompletionPrompt, ContextManager, ContextParentSpanIds, CreateProjectOpts, CurrentSpanStore, DEFAULT_FETCH_BATCH_SIZE, DEFAULT_MAX_REQUEST_SIZE, DataSummary, Dataset, DatasetPipeline, DatasetRecord, DatasetRestorePreviewResult, DatasetRestoreResult, DatasetSnapshot, DatasetSummary, DefaultMetadataType, DefaultPromptArgs, ERR_PERMALINK, EndSpanArgs, Eval, EvalCase, EvalClassifier, EvalHooks, EvalParameterSerializedSchema, EvalParameters, EvalResult, EvalResultWithSummary, EvalScorer, EvalScorerArgs, EvalTask, Evaluator, EvaluatorDef, EvaluatorDefinition, EvaluatorDefinitions, EvaluatorFile, EvaluatorManifest, Experiment, ExperimentLogFullArgs, ExperimentLogPartialArgs, ExperimentSummary, Exportable, ExternalAttachment, ExternalAttachmentParams, FailedHTTPResponse, FullInitDatasetOptions, FullInitOptions, FullLoginOptions, FunctionEvent, GetThreadOptions, IDGenerator, IdField, InitDatasetOptions, InitLoggerOptions, InitOptions, InputField, InstrumentationConfig, InvokeFunctionArgs, InvokeReturn, JSONAttachment, LEGACY_CACHED_HEADER, LOGS3_OVERFLOW_REFERENCE_TYPE, LangChainCallbackHandlerOptions, LazyValue, LoadPromptOptions, LocalTrace, LogCommentFullArgs, LogFeedbackFullArgs, LogOptions, Logger, LoginInvalidOrgError, LoginOptions, Logs3OverflowInputRow, Logs3OverflowUpload, MastraObservabilityExporter, MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, ObjectFetcher, ObjectMetadata, OtherExperimentLogFields, ParametersSource, ParentExperimentIds, ParentProjectLogIds, Project, ProjectNameIdMap, PromiseUnless, Prompt, PromptBuilder, PromptContents, PromptDefinition, PromptDefinitionWithTools, PromptOpts, PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, RegisterSandboxOptions, RegisterSandboxResult, Reporter, ReporterBody, SandboxConfig, ScoreSummary, ScorerBuilder, ScorerOpts, SerializedBraintrustState, SetCurrentArg, Span, SpanContext, SpanData, SpanFetcher, SpanImpl, StartSpanArgs, TemplateFormat, TemplateRenderer, TemplateRendererPlugin, TestBackgroundLogger, ToolBuilder, Trace, UUIDGenerator, WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalIso, _internalSetInitialState, addAzureBlobHeaders, braintrustAISDKTelemetry, braintrustFlueObserver, braintrustStreamChunkSchema, buildLocalSummary, configureInstrumentation, constructLogs3OverflowRequest, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, deepCopyEvent, default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getContextManager, getIdGenerator, getPromptVersions, getSpanParentObject, getTemplateRenderer, graph, init, initDataset, initExperiment, initFunction, initLogger, initNodeTestSuite, invoke, isTemplateFormat, loadParameters, loadPrompt, log, logError, login, loginToState, logs3OverflowUploadSchema, newId, parseCachedHeader, parseTemplateFormat, permalink, pickLogs3OverflowObjectIds, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, registerOtelFlush, registerSandbox, registerTemplatePlugin, renderMessage, renderPromptParams, renderTemplateContent, reportFailures, runEvaluator, setFetch, setMaskingFunction, spanComponentsToObjectId, startSpan, summarize, templateRegistry, toolFunctionDefinitionSchema, traceable, traced, updateSpan, uploadLogs3OverflowPayload, utf8ByteLength, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDK, wrapAISDKModel, wrapAgentClass, wrapAnthropic, wrapClaudeAgentSDK, wrapCohere, wrapCopilotClient, wrapCursorSDK, wrapGenkit, wrapGoogleADK, wrapGoogleGenAI, wrapGroq, wrapHuggingFace, wrapMastraAgent, wrapMistral, wrapOpenAI, wrapOpenAICodexSDK, wrapOpenAIv4, wrapOpenRouter, wrapOpenRouterAgent, wrapPiCodingAgentSDK, wrapTraced, wrapVitest } from './browser.js'; | ||
| export { AnyDataset, Attachment, AttachmentParams, AttachmentReference, BRAINTRUST_CURRENT_SPAN_STORE, BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME, BackgroundLoggerOpts, BaseAttachment, BaseExperiment, BaseMetadata, BraintrustLangChainCallbackHandler, BraintrustMiddleware, BraintrustObservabilityExporter, BraintrustState, BraintrustStream, BraintrustStreamChunk, CachedSpanFetcher, ChatPrompt, CodeFunction, CodeOpts, CodePrompt, CommentEvent, CompiledPrompt, CompiledPromptParams, CompletionPrompt, ContextManager, ContextParentSpanIds, CreateProjectOpts, CurrentSpanStore, DEFAULT_FETCH_BATCH_SIZE, DEFAULT_MAX_REQUEST_SIZE, DataSummary, Dataset, DatasetPipeline, DatasetRecord, DatasetRestorePreviewResult, DatasetRestoreResult, DatasetSnapshot, DatasetSummary, DefaultMetadataType, DefaultPromptArgs, ERR_PERMALINK, EndSpanArgs, Eval, EvalCase, EvalClassifier, EvalHooks, EvalParameterSerializedSchema, EvalParameters, EvalResult, EvalResultWithSummary, EvalScorer, EvalScorerArgs, EvalTask, Evaluator, EvaluatorDef, EvaluatorDefinition, EvaluatorDefinitions, EvaluatorFile, EvaluatorManifest, Experiment, ExperimentLogFullArgs, ExperimentLogPartialArgs, ExperimentSummary, Exportable, ExternalAttachment, ExternalAttachmentParams, FailedHTTPResponse, FullInitDatasetOptions, FullInitOptions, FullLoginOptions, FunctionEvent, GetThreadOptions, IDGenerator, IdField, InitDatasetOptions, InitLoggerOptions, InitOptions, InputField, InstrumentationConfig, InvokeFunctionArgs, InvokeReturn, JSONAttachment, LEGACY_CACHED_HEADER, LOGS3_OVERFLOW_REFERENCE_TYPE, LangChainCallbackHandlerOptions, LazyValue, LoadPromptOptions, LocalTrace, LogCommentFullArgs, LogFeedbackFullArgs, LogOptions, Logger, LoginInvalidOrgError, LoginOptions, Logs3OverflowInputRow, Logs3OverflowUpload, MastraObservabilityExporter, MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, ObjectFetcher, ObjectMetadata, OtherExperimentLogFields, ParametersSource, ParentExperimentIds, ParentProjectLogIds, Project, ProjectNameIdMap, PromiseUnless, Prompt, PromptBuilder, PromptContents, PromptDefinition, PromptDefinitionWithTools, PromptOpts, PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, RegisterSandboxOptions, RegisterSandboxResult, Reporter, ReporterBody, SandboxConfig, ScoreSummary, ScorerBuilder, ScorerOpts, SerializedBraintrustState, SetCurrentArg, Span, SpanContext, SpanData, SpanFetcher, SpanImpl, StartSpanArgs, TemplateFormat, TemplateRenderer, TemplateRendererPlugin, TestBackgroundLogger, ToolBuilder, Trace, UUIDGenerator, WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalIso, _internalSetInitialState, addAzureBlobHeaders, braintrustAISDKTelemetry, braintrustFlueObserver, braintrustStreamChunkSchema, buildLocalSummary, configureInstrumentation, constructLogs3OverflowRequest, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, deepCopyEvent, default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getContextManager, getIdGenerator, getPromptVersions, getSpanParentObject, getTemplateRenderer, graph, init, initDataset, initExperiment, initFunction, initLogger, initNodeTestSuite, invoke, isTemplateFormat, loadParameters, loadPrompt, log, logError, login, loginToState, logs3OverflowUploadSchema, newId, parseCachedHeader, parseTemplateFormat, permalink, pickLogs3OverflowObjectIds, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, registerOtelFlush, registerSandbox, registerTemplatePlugin, renderMessage, renderPromptParams, renderTemplateContent, reportFailures, runEvaluator, setFetch, setMaskingFunction, spanComponentsToObjectId, startSpan, summarize, templateRegistry, toolFunctionDefinitionSchema, traceable, traced, updateSpan, uploadLogs3OverflowPayload, utf8ByteLength, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDK, wrapAISDKModel, wrapAgentClass, wrapAnthropic, wrapBedrockRuntime, wrapClaudeAgentSDK, wrapCohere, wrapCopilotClient, wrapCursorSDK, wrapGenkit, wrapGoogleADK, wrapGoogleGenAI, wrapGroq, wrapHuggingFace, wrapMastraAgent, wrapMistral, wrapOpenAI, wrapOpenAICodexSDK, wrapOpenAIv4, wrapOpenRouter, wrapOpenRouterAgent, wrapPiCodingAgentSDK, wrapStrandsAgentSDK, wrapTraced, wrapVitest } from './browser.js'; | ||
| import 'zod/v3'; |
@@ -1,2 +0,2 @@ | ||
| export { AnyDataset, Attachment, AttachmentParams, AttachmentReference, BRAINTRUST_CURRENT_SPAN_STORE, BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME, BackgroundLoggerOpts, BaseAttachment, BaseExperiment, BaseMetadata, BraintrustLangChainCallbackHandler, BraintrustMiddleware, BraintrustObservabilityExporter, BraintrustState, BraintrustStream, BraintrustStreamChunk, CachedSpanFetcher, ChatPrompt, CodeFunction, CodeOpts, CodePrompt, CommentEvent, CompiledPrompt, CompiledPromptParams, CompletionPrompt, ContextManager, ContextParentSpanIds, CreateProjectOpts, CurrentSpanStore, DEFAULT_FETCH_BATCH_SIZE, DEFAULT_MAX_REQUEST_SIZE, DataSummary, Dataset, DatasetPipeline, DatasetRecord, DatasetRestorePreviewResult, DatasetRestoreResult, DatasetSnapshot, DatasetSummary, DefaultMetadataType, DefaultPromptArgs, ERR_PERMALINK, EndSpanArgs, Eval, EvalCase, EvalClassifier, EvalHooks, EvalParameterSerializedSchema, EvalParameters, EvalResult, EvalResultWithSummary, EvalScorer, EvalScorerArgs, EvalTask, Evaluator, EvaluatorDef, EvaluatorDefinition, EvaluatorDefinitions, EvaluatorFile, EvaluatorManifest, Experiment, ExperimentLogFullArgs, ExperimentLogPartialArgs, ExperimentSummary, Exportable, ExternalAttachment, ExternalAttachmentParams, FailedHTTPResponse, FullInitDatasetOptions, FullInitOptions, FullLoginOptions, FunctionEvent, GetThreadOptions, IDGenerator, IdField, InitDatasetOptions, InitLoggerOptions, InitOptions, InputField, InstrumentationConfig, InvokeFunctionArgs, InvokeReturn, JSONAttachment, LEGACY_CACHED_HEADER, LOGS3_OVERFLOW_REFERENCE_TYPE, LangChainCallbackHandlerOptions, LazyValue, LoadPromptOptions, LocalTrace, LogCommentFullArgs, LogFeedbackFullArgs, LogOptions, Logger, LoginInvalidOrgError, LoginOptions, Logs3OverflowInputRow, Logs3OverflowUpload, MastraObservabilityExporter, MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, ObjectFetcher, ObjectMetadata, OtherExperimentLogFields, ParametersSource, ParentExperimentIds, ParentProjectLogIds, Project, ProjectNameIdMap, PromiseUnless, Prompt, PromptBuilder, PromptContents, PromptDefinition, PromptDefinitionWithTools, PromptOpts, PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, RegisterSandboxOptions, RegisterSandboxResult, Reporter, ReporterBody, SandboxConfig, ScoreSummary, ScorerBuilder, ScorerOpts, SerializedBraintrustState, SetCurrentArg, Span, SpanContext, SpanData, SpanFetcher, SpanImpl, StartSpanArgs, TemplateFormat, TemplateRenderer, TemplateRendererPlugin, TestBackgroundLogger, ToolBuilder, Trace, UUIDGenerator, WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalIso, _internalSetInitialState, addAzureBlobHeaders, braintrustAISDKTelemetry, braintrustFlueObserver, braintrustStreamChunkSchema, buildLocalSummary, configureInstrumentation, constructLogs3OverflowRequest, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, deepCopyEvent, default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getContextManager, getIdGenerator, getPromptVersions, getSpanParentObject, getTemplateRenderer, graph, init, initDataset, initExperiment, initFunction, initLogger, initNodeTestSuite, invoke, isTemplateFormat, loadParameters, loadPrompt, log, logError, login, loginToState, logs3OverflowUploadSchema, newId, parseCachedHeader, parseTemplateFormat, permalink, pickLogs3OverflowObjectIds, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, registerOtelFlush, registerSandbox, registerTemplatePlugin, renderMessage, renderPromptParams, renderTemplateContent, reportFailures, runEvaluator, setFetch, setMaskingFunction, spanComponentsToObjectId, startSpan, summarize, templateRegistry, toolFunctionDefinitionSchema, traceable, traced, updateSpan, uploadLogs3OverflowPayload, utf8ByteLength, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDK, wrapAISDKModel, wrapAgentClass, wrapAnthropic, wrapClaudeAgentSDK, wrapCohere, wrapCopilotClient, wrapCursorSDK, wrapGenkit, wrapGoogleADK, wrapGoogleGenAI, wrapGroq, wrapHuggingFace, wrapMastraAgent, wrapMistral, wrapOpenAI, wrapOpenAICodexSDK, wrapOpenAIv4, wrapOpenRouter, wrapOpenRouterAgent, wrapPiCodingAgentSDK, wrapTraced, wrapVitest } from './browser.mjs'; | ||
| export { AnyDataset, Attachment, AttachmentParams, AttachmentReference, BRAINTRUST_CURRENT_SPAN_STORE, BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME, BackgroundLoggerOpts, BaseAttachment, BaseExperiment, BaseMetadata, BraintrustLangChainCallbackHandler, BraintrustMiddleware, BraintrustObservabilityExporter, BraintrustState, BraintrustStream, BraintrustStreamChunk, CachedSpanFetcher, ChatPrompt, CodeFunction, CodeOpts, CodePrompt, CommentEvent, CompiledPrompt, CompiledPromptParams, CompletionPrompt, ContextManager, ContextParentSpanIds, CreateProjectOpts, CurrentSpanStore, DEFAULT_FETCH_BATCH_SIZE, DEFAULT_MAX_REQUEST_SIZE, DataSummary, Dataset, DatasetPipeline, DatasetRecord, DatasetRestorePreviewResult, DatasetRestoreResult, DatasetSnapshot, DatasetSummary, DefaultMetadataType, DefaultPromptArgs, ERR_PERMALINK, EndSpanArgs, Eval, EvalCase, EvalClassifier, EvalHooks, EvalParameterSerializedSchema, EvalParameters, EvalResult, EvalResultWithSummary, EvalScorer, EvalScorerArgs, EvalTask, Evaluator, EvaluatorDef, EvaluatorDefinition, EvaluatorDefinitions, EvaluatorFile, EvaluatorManifest, Experiment, ExperimentLogFullArgs, ExperimentLogPartialArgs, ExperimentSummary, Exportable, ExternalAttachment, ExternalAttachmentParams, FailedHTTPResponse, FullInitDatasetOptions, FullInitOptions, FullLoginOptions, FunctionEvent, GetThreadOptions, IDGenerator, IdField, InitDatasetOptions, InitLoggerOptions, InitOptions, InputField, InstrumentationConfig, InvokeFunctionArgs, InvokeReturn, JSONAttachment, LEGACY_CACHED_HEADER, LOGS3_OVERFLOW_REFERENCE_TYPE, LangChainCallbackHandlerOptions, LazyValue, LoadPromptOptions, LocalTrace, LogCommentFullArgs, LogFeedbackFullArgs, LogOptions, Logger, LoginInvalidOrgError, LoginOptions, Logs3OverflowInputRow, Logs3OverflowUpload, MastraObservabilityExporter, MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, ObjectFetcher, ObjectMetadata, OtherExperimentLogFields, ParametersSource, ParentExperimentIds, ParentProjectLogIds, Project, ProjectNameIdMap, PromiseUnless, Prompt, PromptBuilder, PromptContents, PromptDefinition, PromptDefinitionWithTools, PromptOpts, PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, RegisterSandboxOptions, RegisterSandboxResult, Reporter, ReporterBody, SandboxConfig, ScoreSummary, ScorerBuilder, ScorerOpts, SerializedBraintrustState, SetCurrentArg, Span, SpanContext, SpanData, SpanFetcher, SpanImpl, StartSpanArgs, TemplateFormat, TemplateRenderer, TemplateRendererPlugin, TestBackgroundLogger, ToolBuilder, Trace, UUIDGenerator, WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalIso, _internalSetInitialState, addAzureBlobHeaders, braintrustAISDKTelemetry, braintrustFlueObserver, braintrustStreamChunkSchema, buildLocalSummary, configureInstrumentation, constructLogs3OverflowRequest, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, deepCopyEvent, default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getContextManager, getIdGenerator, getPromptVersions, getSpanParentObject, getTemplateRenderer, graph, init, initDataset, initExperiment, initFunction, initLogger, initNodeTestSuite, invoke, isTemplateFormat, loadParameters, loadPrompt, log, logError, login, loginToState, logs3OverflowUploadSchema, newId, parseCachedHeader, parseTemplateFormat, permalink, pickLogs3OverflowObjectIds, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, registerOtelFlush, registerSandbox, registerTemplatePlugin, renderMessage, renderPromptParams, renderTemplateContent, reportFailures, runEvaluator, setFetch, setMaskingFunction, spanComponentsToObjectId, startSpan, summarize, templateRegistry, toolFunctionDefinitionSchema, traceable, traced, updateSpan, uploadLogs3OverflowPayload, utf8ByteLength, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDK, wrapAISDKModel, wrapAgentClass, wrapAnthropic, wrapBedrockRuntime, wrapClaudeAgentSDK, wrapCohere, wrapCopilotClient, wrapCursorSDK, wrapGenkit, wrapGoogleADK, wrapGoogleGenAI, wrapGroq, wrapHuggingFace, wrapMastraAgent, wrapMistral, wrapOpenAI, wrapOpenAICodexSDK, wrapOpenAIv4, wrapOpenRouter, wrapOpenRouterAgent, wrapPiCodingAgentSDK, wrapStrandsAgentSDK, wrapTraced, wrapVitest } from './browser.mjs'; | ||
| import 'zod/v3'; |
@@ -1,2 +0,2 @@ | ||
| export { AnyDataset, Attachment, AttachmentParams, AttachmentReference, BRAINTRUST_CURRENT_SPAN_STORE, BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME, BackgroundLoggerOpts, BaseAttachment, BaseExperiment, BaseMetadata, BraintrustLangChainCallbackHandler, BraintrustMiddleware, BraintrustObservabilityExporter, BraintrustState, BraintrustStream, BraintrustStreamChunk, CachedSpanFetcher, ChatPrompt, CodeFunction, CodeOpts, CodePrompt, CommentEvent, CompiledPrompt, CompiledPromptParams, CompletionPrompt, ContextManager, ContextParentSpanIds, CreateProjectOpts, CurrentSpanStore, DEFAULT_FETCH_BATCH_SIZE, DEFAULT_MAX_REQUEST_SIZE, DataSummary, Dataset, DatasetPipeline, DatasetRecord, DatasetRestorePreviewResult, DatasetRestoreResult, DatasetSnapshot, DatasetSummary, DefaultMetadataType, DefaultPromptArgs, ERR_PERMALINK, EndSpanArgs, Eval, EvalCase, EvalClassifier, EvalHooks, EvalParameterSerializedSchema, EvalParameters, EvalResult, EvalResultWithSummary, EvalScorer, EvalScorerArgs, EvalTask, Evaluator, EvaluatorDef, EvaluatorDefinition, EvaluatorDefinitions, EvaluatorFile, EvaluatorManifest, Experiment, ExperimentLogFullArgs, ExperimentLogPartialArgs, ExperimentSummary, Exportable, ExternalAttachment, ExternalAttachmentParams, FailedHTTPResponse, FullInitDatasetOptions, FullInitOptions, FullLoginOptions, FunctionEvent, GetThreadOptions, IDGenerator, IdField, InitDatasetOptions, InitLoggerOptions, InitOptions, InputField, InstrumentationConfig, InvokeFunctionArgs, InvokeReturn, JSONAttachment, LEGACY_CACHED_HEADER, LOGS3_OVERFLOW_REFERENCE_TYPE, LangChainCallbackHandlerOptions, LazyValue, LoadPromptOptions, LocalTrace, LogCommentFullArgs, LogFeedbackFullArgs, LogOptions, Logger, LoginInvalidOrgError, LoginOptions, Logs3OverflowInputRow, Logs3OverflowUpload, MastraObservabilityExporter, MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, ObjectFetcher, ObjectMetadata, OtherExperimentLogFields, ParametersSource, ParentExperimentIds, ParentProjectLogIds, Project, ProjectNameIdMap, PromiseUnless, Prompt, PromptBuilder, PromptContents, PromptDefinition, PromptDefinitionWithTools, PromptOpts, PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, RegisterSandboxOptions, RegisterSandboxResult, Reporter, ReporterBody, SandboxConfig, ScoreSummary, ScorerBuilder, ScorerOpts, SerializedBraintrustState, SetCurrentArg, Span, SpanContext, SpanData, SpanFetcher, SpanImpl, StartSpanArgs, TemplateFormat, TemplateRenderer, TemplateRendererPlugin, TestBackgroundLogger, ToolBuilder, Trace, UUIDGenerator, WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalIso, _internalSetInitialState, addAzureBlobHeaders, braintrustAISDKTelemetry, braintrustFlueObserver, braintrustStreamChunkSchema, buildLocalSummary, configureInstrumentation, constructLogs3OverflowRequest, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, deepCopyEvent, default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getContextManager, getIdGenerator, getPromptVersions, getSpanParentObject, getTemplateRenderer, graph, init, initDataset, initExperiment, initFunction, initLogger, initNodeTestSuite, invoke, isTemplateFormat, loadParameters, loadPrompt, log, logError, login, loginToState, logs3OverflowUploadSchema, newId, parseCachedHeader, parseTemplateFormat, permalink, pickLogs3OverflowObjectIds, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, registerOtelFlush, registerSandbox, registerTemplatePlugin, renderMessage, renderPromptParams, renderTemplateContent, reportFailures, runEvaluator, setFetch, setMaskingFunction, spanComponentsToObjectId, startSpan, summarize, templateRegistry, toolFunctionDefinitionSchema, traceable, traced, updateSpan, uploadLogs3OverflowPayload, utf8ByteLength, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDK, wrapAISDKModel, wrapAgentClass, wrapAnthropic, wrapClaudeAgentSDK, wrapCohere, wrapCopilotClient, wrapCursorSDK, wrapGenkit, wrapGoogleADK, wrapGoogleGenAI, wrapGroq, wrapHuggingFace, wrapMastraAgent, wrapMistral, wrapOpenAI, wrapOpenAICodexSDK, wrapOpenAIv4, wrapOpenRouter, wrapOpenRouterAgent, wrapPiCodingAgentSDK, wrapTraced, wrapVitest } from './browser.js'; | ||
| export { AnyDataset, Attachment, AttachmentParams, AttachmentReference, BRAINTRUST_CURRENT_SPAN_STORE, BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME, BackgroundLoggerOpts, BaseAttachment, BaseExperiment, BaseMetadata, BraintrustLangChainCallbackHandler, BraintrustMiddleware, BraintrustObservabilityExporter, BraintrustState, BraintrustStream, BraintrustStreamChunk, CachedSpanFetcher, ChatPrompt, CodeFunction, CodeOpts, CodePrompt, CommentEvent, CompiledPrompt, CompiledPromptParams, CompletionPrompt, ContextManager, ContextParentSpanIds, CreateProjectOpts, CurrentSpanStore, DEFAULT_FETCH_BATCH_SIZE, DEFAULT_MAX_REQUEST_SIZE, DataSummary, Dataset, DatasetPipeline, DatasetRecord, DatasetRestorePreviewResult, DatasetRestoreResult, DatasetSnapshot, DatasetSummary, DefaultMetadataType, DefaultPromptArgs, ERR_PERMALINK, EndSpanArgs, Eval, EvalCase, EvalClassifier, EvalHooks, EvalParameterSerializedSchema, EvalParameters, EvalResult, EvalResultWithSummary, EvalScorer, EvalScorerArgs, EvalTask, Evaluator, EvaluatorDef, EvaluatorDefinition, EvaluatorDefinitions, EvaluatorFile, EvaluatorManifest, Experiment, ExperimentLogFullArgs, ExperimentLogPartialArgs, ExperimentSummary, Exportable, ExternalAttachment, ExternalAttachmentParams, FailedHTTPResponse, FullInitDatasetOptions, FullInitOptions, FullLoginOptions, FunctionEvent, GetThreadOptions, IDGenerator, IdField, InitDatasetOptions, InitLoggerOptions, InitOptions, InputField, InstrumentationConfig, InvokeFunctionArgs, InvokeReturn, JSONAttachment, LEGACY_CACHED_HEADER, LOGS3_OVERFLOW_REFERENCE_TYPE, LangChainCallbackHandlerOptions, LazyValue, LoadPromptOptions, LocalTrace, LogCommentFullArgs, LogFeedbackFullArgs, LogOptions, Logger, LoginInvalidOrgError, LoginOptions, Logs3OverflowInputRow, Logs3OverflowUpload, MastraObservabilityExporter, MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, ObjectFetcher, ObjectMetadata, OtherExperimentLogFields, ParametersSource, ParentExperimentIds, ParentProjectLogIds, Project, ProjectNameIdMap, PromiseUnless, Prompt, PromptBuilder, PromptContents, PromptDefinition, PromptDefinitionWithTools, PromptOpts, PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, RegisterSandboxOptions, RegisterSandboxResult, Reporter, ReporterBody, SandboxConfig, ScoreSummary, ScorerBuilder, ScorerOpts, SerializedBraintrustState, SetCurrentArg, Span, SpanContext, SpanData, SpanFetcher, SpanImpl, StartSpanArgs, TemplateFormat, TemplateRenderer, TemplateRendererPlugin, TestBackgroundLogger, ToolBuilder, Trace, UUIDGenerator, WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalIso, _internalSetInitialState, addAzureBlobHeaders, braintrustAISDKTelemetry, braintrustFlueObserver, braintrustStreamChunkSchema, buildLocalSummary, configureInstrumentation, constructLogs3OverflowRequest, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, deepCopyEvent, default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getContextManager, getIdGenerator, getPromptVersions, getSpanParentObject, getTemplateRenderer, graph, init, initDataset, initExperiment, initFunction, initLogger, initNodeTestSuite, invoke, isTemplateFormat, loadParameters, loadPrompt, log, logError, login, loginToState, logs3OverflowUploadSchema, newId, parseCachedHeader, parseTemplateFormat, permalink, pickLogs3OverflowObjectIds, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, registerOtelFlush, registerSandbox, registerTemplatePlugin, renderMessage, renderPromptParams, renderTemplateContent, reportFailures, runEvaluator, setFetch, setMaskingFunction, spanComponentsToObjectId, startSpan, summarize, templateRegistry, toolFunctionDefinitionSchema, traceable, traced, updateSpan, uploadLogs3OverflowPayload, utf8ByteLength, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDK, wrapAISDKModel, wrapAgentClass, wrapAnthropic, wrapBedrockRuntime, wrapClaudeAgentSDK, wrapCohere, wrapCopilotClient, wrapCursorSDK, wrapGenkit, wrapGoogleADK, wrapGoogleGenAI, wrapGroq, wrapHuggingFace, wrapMastraAgent, wrapMistral, wrapOpenAI, wrapOpenAICodexSDK, wrapOpenAIv4, wrapOpenRouter, wrapOpenRouterAgent, wrapPiCodingAgentSDK, wrapStrandsAgentSDK, wrapTraced, wrapVitest } from './browser.js'; | ||
| import 'zod/v3'; |
+7
-1
| { | ||
| "name": "braintrust", | ||
| "version": "3.18.0", | ||
| "version": "3.19.0", | ||
| "description": "SDK for integrating Braintrust", | ||
@@ -68,2 +68,8 @@ "repository": { | ||
| }, | ||
| "./vitest-evals-reporter": { | ||
| "types": "./dist/vitest-evals-reporter.d.ts", | ||
| "import": "./dist/vitest-evals-reporter.mjs", | ||
| "module": "./dist/vitest-evals-reporter.mjs", | ||
| "require": "./dist/vitest-evals-reporter.js" | ||
| }, | ||
| "./node": { | ||
@@ -70,0 +76,0 @@ "types": "./dist/index.d.ts", |
+0
-10
@@ -105,12 +105,2 @@ # Braintrust JavaScript SDK | ||
| ## Browser Support | ||
| For browser-only applications, use the dedicated browser package: | ||
| ```bash | ||
| npm install @braintrust/browser braintrust | ||
| ``` | ||
| See the [`@braintrust/browser` README](../integrations/browser-js/README.md) for details and current limitations. | ||
| ## Migration Guides | ||
@@ -117,0 +107,0 @@ |
| import { | ||
| aiSDKConfigs, | ||
| anthropicConfigs, | ||
| channel, | ||
| claudeAgentSDKConfigs, | ||
| cohereConfigs, | ||
| cursorSDKConfigs, | ||
| defineChannels, | ||
| genkitConfigs, | ||
| gitHubCopilotConfigs, | ||
| googleADKConfigs, | ||
| googleGenAIConfigs, | ||
| groqConfigs, | ||
| huggingFaceConfigs, | ||
| langchainConfigs, | ||
| mistralConfigs, | ||
| openAIAgentsCoreConfigs, | ||
| openAICodexConfigs, | ||
| openRouterAgentConfigs, | ||
| openRouterConfigs, | ||
| openaiConfigs, | ||
| piCodingAgentConfigs | ||
| } from "./chunk-ZYKZEMRT.mjs"; | ||
| import { | ||
| applySpecialCasePatch | ||
| } from "./chunk-J57YF7WS.mjs"; | ||
| // src/auto-instrumentations/bundler/plugin.ts | ||
| import { createUnplugin } from "unplugin"; | ||
| import { | ||
| create | ||
| } from "@apm-js-collab/code-transformer"; | ||
| import { extname, join, sep } from "path"; | ||
| import { readFileSync } from "fs"; | ||
| import { fileURLToPath } from "url"; | ||
| import moduleDetailsFromPath from "module-details-from-path"; | ||
| // src/instrumentation/config.ts | ||
| var envIntegrationAliases = { | ||
| openai: "openai", | ||
| "openai-codex": "openaiCodexSDK", | ||
| "openai-codex-sdk": "openaiCodexSDK", | ||
| openaicodexsdk: "openaiCodexSDK", | ||
| codex: "openaiCodexSDK", | ||
| "codex-sdk": "openaiCodexSDK", | ||
| "pi-coding-agent": "piCodingAgent", | ||
| "pi-coding-agent-sdk": "piCodingAgent", | ||
| picodingagent: "piCodingAgent", | ||
| picodingagentsdk: "piCodingAgent", | ||
| "@earendil-works/pi-coding-agent": "piCodingAgent", | ||
| anthropic: "anthropic", | ||
| aisdk: "aisdk", | ||
| "ai-sdk": "aisdk", | ||
| "vercel-ai": "aisdk", | ||
| vercel: "vercel", | ||
| claudeagentsdk: "claudeAgentSDK", | ||
| "claude-agent-sdk": "claudeAgentSDK", | ||
| cursor: "cursor", | ||
| "cursor-sdk": "cursorSDK", | ||
| cursorsdk: "cursorSDK", | ||
| flue: "flue", | ||
| "flue-runtime": "flue", | ||
| mastra: "mastra", | ||
| "openai-agents": "openAIAgents", | ||
| openaiagents: "openAIAgents", | ||
| "openai-agents-core": "openAIAgents", | ||
| openaiagentscore: "openAIAgents", | ||
| google: "google", | ||
| "google-genai": "googleGenAI", | ||
| googlegenai: "googleGenAI", | ||
| huggingface: "huggingface", | ||
| openrouter: "openrouter", | ||
| openrouteragent: "openrouterAgent", | ||
| "openrouter-agent": "openrouterAgent", | ||
| mistral: "mistral", | ||
| googleadk: "googleADK", | ||
| "google-adk": "googleADK", | ||
| cohere: "cohere", | ||
| groq: "groq", | ||
| "groq-sdk": "groq", | ||
| genkit: "genkit", | ||
| "firebase-genkit": "genkit", | ||
| githubcopilot: "gitHubCopilot", | ||
| "github-copilot": "gitHubCopilot", | ||
| "copilot-sdk": "gitHubCopilot", | ||
| langchain: "langchain", | ||
| "langchain-js": "langchain", | ||
| "@langchain": "langchain", | ||
| langgraph: "langgraph" | ||
| }; | ||
| function readDisabledInstrumentationEnvConfig(disabledList) { | ||
| const integrations = {}; | ||
| if (disabledList) { | ||
| for (const value of disabledList.split(",")) { | ||
| const sdk = value.trim().toLowerCase(); | ||
| if (sdk.length > 0) { | ||
| integrations[envIntegrationAliases[sdk] ?? sdk] = false; | ||
| } | ||
| } | ||
| } | ||
| return { integrations }; | ||
| } | ||
| function isInstrumentationIntegrationDisabled(integrations, ...names) { | ||
| return names.some((name) => integrations?.[name] === false); | ||
| } | ||
| // src/instrumentation/plugins/flue-channels.ts | ||
| var flueChannels = defineChannels("@flue/runtime", { | ||
| createContext: channel({ | ||
| channelName: "createFlueContext", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/auto-instrumentations/configs/flue.ts | ||
| var flueVersionRange = ">=0.8.0"; | ||
| var flueConfigs = [ | ||
| { | ||
| channelName: flueChannels.createContext.channelName, | ||
| module: { | ||
| name: "@flue/runtime", | ||
| versionRange: flueVersionRange, | ||
| filePath: "dist/internal.mjs" | ||
| }, | ||
| functionQuery: { | ||
| functionName: "createFlueContext", | ||
| kind: "Sync" | ||
| } | ||
| } | ||
| ]; | ||
| // src/auto-instrumentations/configs/all.ts | ||
| var defaultInstrumentationConfigGroups = [ | ||
| { integrations: ["openai"], configs: openaiConfigs }, | ||
| { | ||
| integrations: ["openaiCodexSDK"], | ||
| configs: openAICodexConfigs | ||
| }, | ||
| { integrations: ["anthropic"], configs: anthropicConfigs }, | ||
| { | ||
| integrations: ["aisdk", "vercel"], | ||
| configs: aiSDKConfigs | ||
| }, | ||
| { | ||
| integrations: ["claudeAgentSDK"], | ||
| configs: claudeAgentSDKConfigs | ||
| }, | ||
| { integrations: ["cursor", "cursorSDK"], configs: cursorSDKConfigs }, | ||
| { | ||
| integrations: ["openAIAgents"], | ||
| configs: openAIAgentsCoreConfigs | ||
| }, | ||
| { | ||
| integrations: ["google", "googleGenAI"], | ||
| configs: googleGenAIConfigs | ||
| }, | ||
| { integrations: ["huggingface"], configs: huggingFaceConfigs }, | ||
| { | ||
| integrations: ["langchain", "langgraph"], | ||
| configs: langchainConfigs | ||
| }, | ||
| { integrations: ["openrouter"], configs: openRouterConfigs }, | ||
| { | ||
| integrations: ["openrouterAgent"], | ||
| configs: openRouterAgentConfigs | ||
| }, | ||
| { integrations: ["mistral"], configs: mistralConfigs }, | ||
| { integrations: ["googleADK"], configs: googleADKConfigs }, | ||
| { integrations: ["cohere"], configs: cohereConfigs }, | ||
| { integrations: ["groq"], configs: groqConfigs }, | ||
| { | ||
| integrations: ["genkit"], | ||
| configs: genkitConfigs | ||
| }, | ||
| { | ||
| integrations: ["gitHubCopilot"], | ||
| configs: gitHubCopilotConfigs | ||
| }, | ||
| { | ||
| integrations: ["piCodingAgent"], | ||
| configs: piCodingAgentConfigs | ||
| }, | ||
| { | ||
| integrations: ["flue"], | ||
| configs: flueConfigs | ||
| } | ||
| // Note: `@mastra/core` is not listed here because its instrumentation | ||
| // doesn't go through the AST `code-transformer` matcher — Mastra's | ||
| // content-hashed chunks make `filePath`-based matching too brittle. | ||
| // Instead it's handled by the source-replacement entry in | ||
| // `loader/special-case-patches.ts`, which both the runtime loader | ||
| // (`hook.mjs` → `cjs-patch.ts`/`esm-hook.mts`) and the bundler plugin | ||
| // (`bundler/plugin.ts`) call. The `mastra` env-var disable still works. | ||
| ]; | ||
| function getDefaultInstrumentationConfigs({ | ||
| additionalInstrumentations, | ||
| disabledIntegrationConfig, | ||
| disabledIntegrations | ||
| } = {}) { | ||
| const disabledConfig = disabledIntegrationConfig ?? (disabledIntegrations ? readDisabledInstrumentationEnvConfig( | ||
| [...disabledIntegrations].join(",") | ||
| ).integrations : void 0); | ||
| return [ | ||
| ...defaultInstrumentationConfigGroups.flatMap( | ||
| ({ configs, integrations }) => isInstrumentationIntegrationDisabled(disabledConfig, ...integrations) ? [] : configs | ||
| ), | ||
| ...additionalInstrumentations ?? [] | ||
| ]; | ||
| } | ||
| // src/auto-instrumentations/bundler/plugin.ts | ||
| function getModuleVersion(basedir) { | ||
| try { | ||
| const packageJsonPath = join(basedir, "package.json"); | ||
| const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")); | ||
| if (packageJson.version) { | ||
| return packageJson.version; | ||
| } | ||
| } catch (error) { | ||
| } | ||
| return void 0; | ||
| } | ||
| var unplugin = createUnplugin( | ||
| (options = {}) => { | ||
| const allInstrumentations = getDefaultInstrumentationConfigs({ | ||
| additionalInstrumentations: options.instrumentations | ||
| }); | ||
| const dcModule = options.browser === false ? void 0 : "dc-browser"; | ||
| const instrumentationMatcher = create(allInstrumentations, dcModule); | ||
| return { | ||
| name: "code-transformer", | ||
| enforce: "pre", | ||
| transform(code, id) { | ||
| if (!id) { | ||
| return null; | ||
| } | ||
| const filePath = id.startsWith("file:") ? fileURLToPath(id) : id; | ||
| const ext = extname(filePath); | ||
| let isModule = ext === ".mjs" || ext === ".ts" || ext === ".tsx"; | ||
| if (ext === ".js") { | ||
| isModule = code.includes("export ") || code.includes("import "); | ||
| } | ||
| const normalizedForPlatform = filePath.split("/").join(sep); | ||
| const moduleDetails = moduleDetailsFromPath(normalizedForPlatform); | ||
| if (!moduleDetails) { | ||
| return null; | ||
| } | ||
| const moduleName = moduleDetails.name; | ||
| const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/"); | ||
| const moduleVersion = getModuleVersion(moduleDetails.basedir); | ||
| if (options.browser !== true) { | ||
| const patched = applySpecialCasePatch({ | ||
| packageName: moduleName, | ||
| modulePath: normalizedModulePath, | ||
| source: code, | ||
| format: isModule ? "esm" : "cjs" | ||
| }); | ||
| if (patched !== null) { | ||
| return { code: patched, map: null }; | ||
| } | ||
| } | ||
| if (!moduleVersion) { | ||
| console.warn( | ||
| `No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.` | ||
| ); | ||
| return null; | ||
| } | ||
| const transformer = instrumentationMatcher.getTransformer( | ||
| moduleName, | ||
| moduleVersion, | ||
| normalizedModulePath | ||
| ); | ||
| if (!transformer) { | ||
| return null; | ||
| } | ||
| try { | ||
| const moduleType = isModule ? "esm" : "cjs"; | ||
| const result = transformer.transform(code, moduleType); | ||
| const transformedCode = result.code.replace( | ||
| /const \{tracingChannel: ([A-Za-z_$][\w$]*)\} = ([A-Za-z_$][\w$]*);/g, | ||
| "const $1 = $2.tracingChannel;" | ||
| ); | ||
| return { | ||
| code: transformedCode, | ||
| map: result.map | ||
| }; | ||
| } catch (error) { | ||
| console.warn(`Code transformation failed for ${id}: ${error}`); | ||
| return null; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| ); | ||
| export { | ||
| unplugin | ||
| }; |
| import { | ||
| unplugin | ||
| } from "./chunk-GNUEZ2PE.mjs"; | ||
| // src/auto-instrumentations/bundler/webpack.ts | ||
| function braintrustWebpackPlugin(options = {}) { | ||
| const { useDiagnosticChannelCompatShim = false, ...pluginOptions } = options; | ||
| return unplugin.webpack({ | ||
| ...pluginOptions, | ||
| browser: useDiagnosticChannelCompatShim | ||
| }); | ||
| } | ||
| var webpackPlugin = unplugin.webpack; | ||
| export { | ||
| braintrustWebpackPlugin, | ||
| webpackPlugin | ||
| }; |
Sorry, the diff of this file is too big to display
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| // src/auto-instrumentations/patch-tracing-channel.ts | ||
| function patchTracingChannel(tracingChannelFn) { | ||
| const dummyChannel = tracingChannelFn("__braintrust_probe__"); | ||
| const TracingChannel = _optionalChain([dummyChannel, 'optionalAccess', _2 => _2.constructor]); | ||
| if (!_optionalChain([TracingChannel, 'optionalAccess', _3 => _3.prototype])) { | ||
| return; | ||
| } | ||
| if (!Object.getOwnPropertyDescriptor(TracingChannel.prototype, "hasSubscribers")) { | ||
| Object.defineProperty(TracingChannel.prototype, "hasSubscribers", { | ||
| configurable: true, | ||
| enumerable: false, | ||
| get() { | ||
| return Boolean( | ||
| _optionalChain([this, 'access', _4 => _4.start, 'optionalAccess', _5 => _5.hasSubscribers]) || _optionalChain([this, 'access', _6 => _6.end, 'optionalAccess', _7 => _7.hasSubscribers]) || _optionalChain([this, 'access', _8 => _8.asyncStart, 'optionalAccess', _9 => _9.hasSubscribers]) || _optionalChain([this, 'access', _10 => _10.asyncEnd, 'optionalAccess', _11 => _11.hasSubscribers]) || _optionalChain([this, 'access', _12 => _12.error, 'optionalAccess', _13 => _13.hasSubscribers]) | ||
| ); | ||
| } | ||
| }); | ||
| } | ||
| if (TracingChannel.prototype.tracePromise) { | ||
| TracingChannel.prototype.tracePromise = function(fn, context = {}, thisArg, ...args) { | ||
| const start = this.start; | ||
| const end = this.end; | ||
| const asyncStart = this.asyncStart; | ||
| const asyncEnd = this.asyncEnd; | ||
| const error = this.error; | ||
| function publishRejected(err) { | ||
| context.error = err; | ||
| _optionalChain([error, 'optionalAccess', _14 => _14.publish, 'call', _15 => _15(context)]); | ||
| _optionalChain([asyncStart, 'optionalAccess', _16 => _16.publish, 'call', _17 => _17(context)]); | ||
| _optionalChain([asyncEnd, 'optionalAccess', _18 => _18.publish, 'call', _19 => _19(context)]); | ||
| } | ||
| function publishResolved(result) { | ||
| context.result = result; | ||
| _optionalChain([asyncStart, 'optionalAccess', _20 => _20.publish, 'call', _21 => _21(context)]); | ||
| _optionalChain([asyncEnd, 'optionalAccess', _22 => _22.publish, 'call', _23 => _23(context)]); | ||
| } | ||
| return start.runStores(context, () => { | ||
| try { | ||
| const result = Reflect.apply(fn, thisArg, args); | ||
| _optionalChain([end, 'optionalAccess', _24 => _24.publish, 'call', _25 => _25(context)]); | ||
| if (result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function") { | ||
| if (result.constructor === Promise) { | ||
| return result.then( | ||
| (res) => { | ||
| publishResolved(res); | ||
| return res; | ||
| }, | ||
| (err) => { | ||
| publishRejected(err); | ||
| return Promise.reject(err); | ||
| } | ||
| ); | ||
| } | ||
| void result.then( | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (resolved) => { | ||
| try { | ||
| publishResolved(resolved); | ||
| } catch (e) { | ||
| } | ||
| }, | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (err) => { | ||
| try { | ||
| publishRejected(err); | ||
| } catch (e2) { | ||
| } | ||
| } | ||
| ); | ||
| return result; | ||
| } | ||
| context.result = result; | ||
| _optionalChain([asyncStart, 'optionalAccess', _26 => _26.publish, 'call', _27 => _27(context)]); | ||
| _optionalChain([asyncEnd, 'optionalAccess', _28 => _28.publish, 'call', _29 => _29(context)]); | ||
| return result; | ||
| } catch (err) { | ||
| context.error = err; | ||
| _optionalChain([error, 'optionalAccess', _30 => _30.publish, 'call', _31 => _31(context)]); | ||
| _optionalChain([end, 'optionalAccess', _32 => _32.publish, 'call', _33 => _33(context)]); | ||
| throw err; | ||
| } | ||
| }); | ||
| }; | ||
| } | ||
| } | ||
| // src/isomorph.ts | ||
| var DefaultAsyncLocalStorage = class { | ||
| constructor() { | ||
| } | ||
| enterWith(_) { | ||
| } | ||
| run(_, callback) { | ||
| return callback(); | ||
| } | ||
| getStore() { | ||
| return void 0; | ||
| } | ||
| }; | ||
| var DefaultChannel = (_class = class { | ||
| constructor(name) {;_class.prototype.__init.call(this); | ||
| this.name = name; | ||
| } | ||
| __init() {this.hasSubscribers = false} | ||
| subscribe(_subscription) { | ||
| } | ||
| unsubscribe(_subscription) { | ||
| return false; | ||
| } | ||
| bindStore(_store, _transform) { | ||
| } | ||
| unbindStore(_store) { | ||
| return false; | ||
| } | ||
| publish(_message) { | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| runStores(_message, fn, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| }, _class); | ||
| var DefaultTracingChannel = class { | ||
| constructor(nameOrChannels) { | ||
| if (typeof nameOrChannels === "string") { | ||
| this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`); | ||
| this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`); | ||
| this.asyncStart = new DefaultChannel( | ||
| `tracing:${nameOrChannels}:asyncStart` | ||
| ); | ||
| this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`); | ||
| this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`); | ||
| return; | ||
| } | ||
| this.start = _nullishCoalesce(nameOrChannels.start, () => ( new DefaultChannel("tracing:start"))); | ||
| this.end = _nullishCoalesce(nameOrChannels.end, () => ( new DefaultChannel("tracing:end"))); | ||
| this.asyncStart = _nullishCoalesce(nameOrChannels.asyncStart, () => ( new DefaultChannel("tracing:asyncStart"))); | ||
| this.asyncEnd = _nullishCoalesce(nameOrChannels.asyncEnd, () => ( new DefaultChannel("tracing:asyncEnd"))); | ||
| this.error = _nullishCoalesce(nameOrChannels.error, () => ( new DefaultChannel("tracing:error"))); | ||
| } | ||
| get hasSubscribers() { | ||
| return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers; | ||
| } | ||
| subscribe(_handlers) { | ||
| } | ||
| unsubscribe(_handlers) { | ||
| return false; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| traceSync(fn, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| tracePromise(fn, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| traceCallback(fn, _position, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| }; | ||
| var iso = { | ||
| buildType: "unknown", | ||
| // Will be set by configureBrowser() or configureNode() | ||
| getRepoInfo: async (_settings) => void 0, | ||
| getPastNAncestors: async () => [], | ||
| getEnv: (_name) => void 0, | ||
| getBraintrustApiKey: async () => void 0, | ||
| getCallerLocation: () => void 0, | ||
| newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(), | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels), | ||
| processOn: (_0, _1) => { | ||
| }, | ||
| basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath, | ||
| // eslint-disable-next-line no-restricted-properties -- preserving intentional console usage. | ||
| writeln: (text) => console.log(text) | ||
| }; | ||
| var isomorph_default = iso; | ||
| // src/instrumentation/core/channel-definitions.ts | ||
| function channel(spec) { | ||
| return spec; | ||
| } | ||
| function defineChannels(pkg, channels) { | ||
| return Object.fromEntries( | ||
| Object.entries(channels).map(([key, spec]) => { | ||
| const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`; | ||
| if (spec.kind === "async") { | ||
| const asyncSpec = spec; | ||
| const tracingChannel2 = () => isomorph_default.newTracingChannel( | ||
| fullChannelName | ||
| ); | ||
| return [ | ||
| key, | ||
| { | ||
| ...asyncSpec, | ||
| tracingChannel: tracingChannel2, | ||
| tracePromise: (fn, context) => tracingChannel2().tracePromise( | ||
| fn, | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| context | ||
| ) | ||
| } | ||
| ]; | ||
| } | ||
| const syncSpec = spec; | ||
| const tracingChannel = () => isomorph_default.newTracingChannel( | ||
| fullChannelName | ||
| ); | ||
| return [ | ||
| key, | ||
| { | ||
| ...syncSpec, | ||
| tracingChannel, | ||
| traceSync: (fn, context) => tracingChannel().traceSync( | ||
| fn, | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| context | ||
| ) | ||
| } | ||
| ]; | ||
| }) | ||
| ); | ||
| } | ||
| // src/instrumentation/plugins/openai-channels.ts | ||
| var openAIChannels = defineChannels("openai", { | ||
| chatCompletionsCreate: channel({ | ||
| channelName: "chat.completions.create", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel({ | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| }), | ||
| betaChatCompletionsParse: channel({ | ||
| channelName: "beta.chat.completions.parse", | ||
| kind: "async" | ||
| }), | ||
| betaChatCompletionsStream: channel({ | ||
| channelName: "beta.chat.completions.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| moderationsCreate: channel({ | ||
| channelName: "moderations.create", | ||
| kind: "async" | ||
| }), | ||
| responsesCreate: channel({ | ||
| channelName: "responses.create", | ||
| kind: "async" | ||
| }), | ||
| responsesStream: channel({ | ||
| channelName: "responses.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| responsesParse: channel({ | ||
| channelName: "responses.parse", | ||
| kind: "async" | ||
| }), | ||
| responsesCompact: channel({ | ||
| channelName: "responses.compact", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openai-codex-channels.ts | ||
| var openAICodexChannels = defineChannels("@openai/codex-sdk", { | ||
| run: channel({ | ||
| channelName: "Thread.run", | ||
| kind: "async" | ||
| }), | ||
| runStreamed: channel({ | ||
| channelName: "Thread.runStreamed", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/anthropic-channels.ts | ||
| var anthropicChannels = defineChannels("@anthropic-ai/sdk", { | ||
| messagesCreate: channel({ | ||
| channelName: "messages.create", | ||
| kind: "async" | ||
| }), | ||
| betaMessagesCreate: channel({ | ||
| channelName: "beta.messages.create", | ||
| kind: "async" | ||
| }), | ||
| betaMessagesToolRunner: channel({ | ||
| channelName: "beta.messages.toolRunner", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/ai-sdk-channels.ts | ||
| var aiSDKChannels = defineChannels("ai", { | ||
| generateText: channel({ | ||
| channelName: "generateText", | ||
| kind: "async" | ||
| }), | ||
| streamText: channel({ | ||
| channelName: "streamText", | ||
| kind: "async" | ||
| }), | ||
| streamTextSync: channel({ | ||
| channelName: "streamText.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| generateObject: channel({ | ||
| channelName: "generateObject", | ||
| kind: "async" | ||
| }), | ||
| streamObject: channel({ | ||
| channelName: "streamObject", | ||
| kind: "async" | ||
| }), | ||
| streamObjectSync: channel({ | ||
| channelName: "streamObject.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| embed: channel( | ||
| { | ||
| channelName: "embed", | ||
| kind: "async" | ||
| } | ||
| ), | ||
| embedMany: channel({ | ||
| channelName: "embedMany", | ||
| kind: "async" | ||
| }), | ||
| rerank: channel({ | ||
| channelName: "rerank", | ||
| kind: "async" | ||
| }), | ||
| agentGenerate: channel({ | ||
| channelName: "Agent.generate", | ||
| kind: "async" | ||
| }), | ||
| agentStream: channel({ | ||
| channelName: "Agent.stream", | ||
| kind: "async" | ||
| }), | ||
| agentStreamSync: channel({ | ||
| channelName: "Agent.stream.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| toolLoopAgentGenerate: channel({ | ||
| channelName: "ToolLoopAgent.generate", | ||
| kind: "async" | ||
| }), | ||
| toolLoopAgentStream: channel({ | ||
| channelName: "ToolLoopAgent.stream", | ||
| kind: "async" | ||
| }), | ||
| v7CreateTelemetryDispatcher: channel({ | ||
| channelName: "createTelemetryDispatcher", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/claude-agent-sdk-channels.ts | ||
| var claudeAgentSDKChannels = defineChannels( | ||
| "@anthropic-ai/claude-agent-sdk", | ||
| { | ||
| query: channel({ | ||
| channelName: "query", | ||
| kind: "sync-stream" | ||
| }) | ||
| } | ||
| ); | ||
| // src/instrumentation/plugins/cursor-sdk-channels.ts | ||
| var cursorSDKChannels = defineChannels("@cursor/sdk", { | ||
| create: channel({ | ||
| channelName: "Agent.create", | ||
| kind: "async" | ||
| }), | ||
| resume: channel({ | ||
| channelName: "Agent.resume", | ||
| kind: "async" | ||
| }), | ||
| prompt: channel({ | ||
| channelName: "Agent.prompt", | ||
| kind: "async" | ||
| }), | ||
| send: channel({ | ||
| channelName: "agent.send", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/google-genai-channels.ts | ||
| var googleGenAIChannels = defineChannels("@google/genai", { | ||
| generateContent: channel({ | ||
| channelName: "models.generateContent", | ||
| kind: "async" | ||
| }), | ||
| generateContentStream: channel({ | ||
| channelName: "models.generateContentStream", | ||
| kind: "async" | ||
| }), | ||
| embedContent: channel({ | ||
| channelName: "models.embedContent", | ||
| kind: "async" | ||
| }), | ||
| interactionsCreate: channel({ | ||
| channelName: "interactions.create", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/huggingface-channels.ts | ||
| var huggingFaceChannels = defineChannels("@huggingface/inference", { | ||
| chatCompletion: channel({ | ||
| channelName: "chatCompletion", | ||
| kind: "async" | ||
| }), | ||
| chatCompletionStream: channel({ | ||
| channelName: "chatCompletionStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| textGeneration: channel({ | ||
| channelName: "textGeneration", | ||
| kind: "async" | ||
| }), | ||
| textGenerationStream: channel({ | ||
| channelName: "textGenerationStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| featureExtraction: channel({ | ||
| channelName: "featureExtraction", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openrouter-agent-channels.ts | ||
| var openRouterAgentChannels = defineChannels("@openrouter/agent", { | ||
| callModel: channel({ | ||
| channelName: "callModel", | ||
| kind: "sync-stream" | ||
| }), | ||
| callModelTurn: channel({ | ||
| channelName: "callModel.turn", | ||
| kind: "async" | ||
| }), | ||
| toolExecute: channel({ | ||
| channelName: "tool.execute", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openrouter-channels.ts | ||
| var openRouterChannels = defineChannels("@openrouter/sdk", { | ||
| chatSend: channel({ | ||
| channelName: "chat.send", | ||
| kind: "async" | ||
| }), | ||
| embeddingsGenerate: channel({ | ||
| channelName: "embeddings.generate", | ||
| kind: "async" | ||
| }), | ||
| rerankRerank: channel( | ||
| { | ||
| channelName: "rerank.rerank", | ||
| kind: "async" | ||
| } | ||
| ), | ||
| betaResponsesSend: channel({ | ||
| channelName: "beta.responses.send", | ||
| kind: "async" | ||
| }), | ||
| callModel: channel({ | ||
| channelName: "callModel", | ||
| kind: "sync-stream" | ||
| }), | ||
| callModelTurn: channel({ | ||
| channelName: "callModel.turn", | ||
| kind: "async" | ||
| }), | ||
| toolExecute: channel({ | ||
| channelName: "tool.execute", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/mistral-channels.ts | ||
| var mistralChannels = defineChannels("@mistralai/mistralai", { | ||
| chatComplete: channel({ | ||
| channelName: "chat.complete", | ||
| kind: "async" | ||
| }), | ||
| chatStream: channel({ | ||
| channelName: "chat.stream", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel({ | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| }), | ||
| classifiersModerate: channel({ | ||
| channelName: "classifiers.moderate", | ||
| kind: "async" | ||
| }), | ||
| classifiersModerateChat: channel({ | ||
| channelName: "classifiers.moderateChat", | ||
| kind: "async" | ||
| }), | ||
| classifiersClassify: channel({ | ||
| channelName: "classifiers.classify", | ||
| kind: "async" | ||
| }), | ||
| classifiersClassifyChat: channel({ | ||
| channelName: "classifiers.classifyChat", | ||
| kind: "async" | ||
| }), | ||
| fimComplete: channel({ | ||
| channelName: "fim.complete", | ||
| kind: "async" | ||
| }), | ||
| fimStream: channel({ | ||
| channelName: "fim.stream", | ||
| kind: "async" | ||
| }), | ||
| agentsComplete: channel({ | ||
| channelName: "agents.complete", | ||
| kind: "async" | ||
| }), | ||
| agentsStream: channel({ | ||
| channelName: "agents.stream", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/google-adk-channels.ts | ||
| var googleADKChannels = defineChannels("@google/adk", { | ||
| runnerRunAsync: channel({ | ||
| channelName: "runner.runAsync", | ||
| kind: "sync-stream" | ||
| }), | ||
| agentRunAsync: channel({ | ||
| channelName: "agent.runAsync", | ||
| kind: "sync-stream" | ||
| }), | ||
| toolRunAsync: channel({ | ||
| channelName: "tool.runAsync", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/cohere-channels.ts | ||
| var cohereChannels = defineChannels("cohere-ai", { | ||
| chat: channel({ | ||
| channelName: "chat", | ||
| kind: "async" | ||
| }), | ||
| chatStream: channel({ | ||
| channelName: "chatStream", | ||
| kind: "async" | ||
| }), | ||
| embed: channel({ | ||
| channelName: "embed", | ||
| kind: "async" | ||
| }), | ||
| rerank: channel({ | ||
| channelName: "rerank", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/groq-channels.ts | ||
| var groqChannels = defineChannels("groq-sdk", { | ||
| chatCompletionsCreate: channel({ | ||
| channelName: "chat.completions.create", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel( | ||
| { | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| } | ||
| ) | ||
| }); | ||
| // src/instrumentation/plugins/genkit-channels.ts | ||
| var genkitChannels = defineChannels("@genkit-ai/ai", { | ||
| generate: channel({ | ||
| channelName: "generate", | ||
| kind: "async" | ||
| }), | ||
| generateStream: channel({ | ||
| channelName: "generateStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| embed: channel({ | ||
| channelName: "embed", | ||
| kind: "async" | ||
| }), | ||
| embedMany: channel({ | ||
| channelName: "embedMany", | ||
| kind: "async" | ||
| }), | ||
| actionRun: channel({ | ||
| channelName: "action.run", | ||
| kind: "async" | ||
| }), | ||
| actionStream: channel({ | ||
| channelName: "action.stream", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| var genkitCoreChannels = defineChannels("@genkit-ai/core", { | ||
| actionSpan: channel({ | ||
| channelName: "action.span", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/github-copilot-channels.ts | ||
| var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", { | ||
| createSession: channel({ | ||
| channelName: "client.createSession", | ||
| kind: "async" | ||
| }), | ||
| resumeSession: channel({ | ||
| channelName: "client.resumeSession", | ||
| kind: "async" | ||
| }), | ||
| sendAndWait: channel({ | ||
| channelName: "session.sendAndWait", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/flue-channels.ts | ||
| var flueChannels = defineChannels("@flue/runtime", { | ||
| createContext: channel({ | ||
| channelName: "createFlueContext", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/pi-coding-agent-channels.ts | ||
| var piCodingAgentChannels = defineChannels( | ||
| "@earendil-works/pi-coding-agent", | ||
| { | ||
| prompt: channel({ | ||
| channelName: "AgentSession.prompt", | ||
| kind: "async" | ||
| }) | ||
| } | ||
| ); | ||
| // src/instrumentation/config.ts | ||
| var envIntegrationAliases = { | ||
| openai: "openai", | ||
| "openai-codex": "openaiCodexSDK", | ||
| "openai-codex-sdk": "openaiCodexSDK", | ||
| openaicodexsdk: "openaiCodexSDK", | ||
| codex: "openaiCodexSDK", | ||
| "codex-sdk": "openaiCodexSDK", | ||
| "pi-coding-agent": "piCodingAgent", | ||
| "pi-coding-agent-sdk": "piCodingAgent", | ||
| picodingagent: "piCodingAgent", | ||
| picodingagentsdk: "piCodingAgent", | ||
| "@earendil-works/pi-coding-agent": "piCodingAgent", | ||
| anthropic: "anthropic", | ||
| aisdk: "aisdk", | ||
| "ai-sdk": "aisdk", | ||
| "vercel-ai": "aisdk", | ||
| vercel: "vercel", | ||
| claudeagentsdk: "claudeAgentSDK", | ||
| "claude-agent-sdk": "claudeAgentSDK", | ||
| cursor: "cursor", | ||
| "cursor-sdk": "cursorSDK", | ||
| cursorsdk: "cursorSDK", | ||
| flue: "flue", | ||
| "flue-runtime": "flue", | ||
| mastra: "mastra", | ||
| "openai-agents": "openAIAgents", | ||
| openaiagents: "openAIAgents", | ||
| "openai-agents-core": "openAIAgents", | ||
| openaiagentscore: "openAIAgents", | ||
| google: "google", | ||
| "google-genai": "googleGenAI", | ||
| googlegenai: "googleGenAI", | ||
| huggingface: "huggingface", | ||
| openrouter: "openrouter", | ||
| openrouteragent: "openrouterAgent", | ||
| "openrouter-agent": "openrouterAgent", | ||
| mistral: "mistral", | ||
| googleadk: "googleADK", | ||
| "google-adk": "googleADK", | ||
| cohere: "cohere", | ||
| groq: "groq", | ||
| "groq-sdk": "groq", | ||
| genkit: "genkit", | ||
| "firebase-genkit": "genkit", | ||
| githubcopilot: "gitHubCopilot", | ||
| "github-copilot": "gitHubCopilot", | ||
| "copilot-sdk": "gitHubCopilot", | ||
| langchain: "langchain", | ||
| "langchain-js": "langchain", | ||
| "@langchain": "langchain", | ||
| langgraph: "langgraph" | ||
| }; | ||
| function getDefaultInstrumentationIntegrations() { | ||
| return { | ||
| openai: true, | ||
| openaiCodexSDK: true, | ||
| anthropic: true, | ||
| vercel: true, | ||
| aisdk: true, | ||
| google: true, | ||
| googleGenAI: true, | ||
| googleADK: true, | ||
| huggingface: true, | ||
| claudeAgentSDK: true, | ||
| cursor: true, | ||
| cursorSDK: true, | ||
| flue: true, | ||
| mastra: true, | ||
| openAIAgents: true, | ||
| openrouter: true, | ||
| openrouterAgent: true, | ||
| mistral: true, | ||
| cohere: true, | ||
| groq: true, | ||
| genkit: true, | ||
| gitHubCopilot: true, | ||
| langchain: true, | ||
| langgraph: true, | ||
| piCodingAgent: true | ||
| }; | ||
| } | ||
| function readDisabledInstrumentationEnvConfig(disabledList) { | ||
| const integrations = {}; | ||
| if (disabledList) { | ||
| for (const value of disabledList.split(",")) { | ||
| const sdk = value.trim().toLowerCase(); | ||
| if (sdk.length > 0) { | ||
| integrations[_nullishCoalesce(envIntegrationAliases[sdk], () => ( sdk))] = false; | ||
| } | ||
| } | ||
| } | ||
| return { integrations }; | ||
| } | ||
| function isInstrumentationIntegrationDisabled(integrations, ...names) { | ||
| return names.some((name) => _optionalChain([integrations, 'optionalAccess', _34 => _34[name]]) === false); | ||
| } | ||
| // src/auto-instrumentations/loader/mastra-observability-patch.ts | ||
| var MASTRA_EXPORTER_FACTORY_GLOBAL = "__braintrustMastraExporterFactory"; | ||
| function installMastraExporterFactory(factory) { | ||
| const globals = globalThis; | ||
| globals[MASTRA_EXPORTER_FACTORY_GLOBAL] ??= factory; | ||
| } | ||
| var MASTRA_CORE_PACKAGE = "@mastra/core"; | ||
| var MASTRA_OBSERVABILITY_PACKAGE = "@mastra/observability"; | ||
| var MASTRA_CORE_ENTRY_PATHS = /* @__PURE__ */ new Set([ | ||
| "dist/index.js", | ||
| "dist/index.cjs", | ||
| "dist/mastra/index.js", | ||
| "dist/mastra/index.cjs" | ||
| ]); | ||
| var MASTRA_OBSERVABILITY_ENTRY_PATHS = /* @__PURE__ */ new Set([ | ||
| "dist/index.js", | ||
| "dist/index.cjs" | ||
| ]); | ||
| function classifyMastraTarget(packageName, modulePath) { | ||
| if (packageName === MASTRA_CORE_PACKAGE && MASTRA_CORE_ENTRY_PATHS.has(modulePath)) { | ||
| return "core"; | ||
| } | ||
| if (packageName === MASTRA_OBSERVABILITY_PACKAGE && MASTRA_OBSERVABILITY_ENTRY_PATHS.has(modulePath)) { | ||
| return "observability"; | ||
| } | ||
| return null; | ||
| } | ||
| function extractChunkPath(source) { | ||
| const esmMatch = source.match( | ||
| /export\s*\{\s*Mastra(?:\s+as\s+\w+)?\s*\}\s*from\s*['"]([^'"]+)['"]/ | ||
| ); | ||
| if (esmMatch) return esmMatch[1]; | ||
| const cjsMatch = source.match( | ||
| /require\s*\(\s*['"]([^'"]+chunk-[^'"]+)['"]\s*\)/ | ||
| ); | ||
| if (cjsMatch) return cjsMatch[1]; | ||
| return null; | ||
| } | ||
| var EXPORTER_FACTORY_KEY = JSON.stringify(MASTRA_EXPORTER_FACTORY_GLOBAL); | ||
| var MASTRA_PROXY_HANDLER_BODY = ` | ||
| { | ||
| construct(target, args, newTarget) { | ||
| var firstArg = args[0]; | ||
| if ( | ||
| (!firstArg || typeof firstArg !== "object" || !firstArg.observability) && | ||
| __braintrustObservabilityClass | ||
| ) { | ||
| try { | ||
| // serviceName is required by Mastra's Observability validator; pass | ||
| // something sensible by default. Users who want a different name | ||
| // should construct Observability themselves. | ||
| var observability = new __braintrustObservabilityClass({ | ||
| configs: { default: { serviceName: "mastra" } }, | ||
| }); | ||
| args = args.slice(); | ||
| args[0] = Object.assign({}, firstArg, { observability: observability }); | ||
| } catch (e) { | ||
| // Fall through. Mastra will use its own NoOp; user code still works, | ||
| // just without auto-instrumentation. | ||
| } | ||
| } | ||
| return Reflect.construct(target, args, newTarget); | ||
| }, | ||
| }`; | ||
| function buildMastraEsmWrapper(chunkPath) { | ||
| const chunk = JSON.stringify(chunkPath); | ||
| return `import { Mastra as __braintrustOrigMastra } from ${chunk}; | ||
| import { createRequire as __braintrustCreateRequire } from "node:module"; | ||
| let __braintrustObservabilityClass = null; | ||
| try { | ||
| // Resolve @mastra/observability relative to this module (the Mastra entry), | ||
| // so it's looked up from the user's node_modules tree. | ||
| const __braintrustRequire = __braintrustCreateRequire(import.meta.url); | ||
| __braintrustObservabilityClass = | ||
| __braintrustRequire("@mastra/observability").Observability; | ||
| } catch (e) { | ||
| // @mastra/observability isn't installed; the construct trap will skip the | ||
| // auto-construct branch and Mastra falls back to its own NoOp. | ||
| } | ||
| const Mastra = new Proxy(__braintrustOrigMastra, ${MASTRA_PROXY_HANDLER_BODY}); | ||
| export { Mastra }; | ||
| `; | ||
| } | ||
| function buildMastraCjsWrapper(chunkPath) { | ||
| const chunk = JSON.stringify(chunkPath); | ||
| return `'use strict'; | ||
| const __braintrustChunk = require(${chunk}); | ||
| let __braintrustObservabilityClass = null; | ||
| try { | ||
| __braintrustObservabilityClass = require("@mastra/observability").Observability; | ||
| } catch (e) { | ||
| // @mastra/observability isn't installed; same fallback as the ESM wrapper. | ||
| } | ||
| const __braintrustWrappedMastra = new Proxy( | ||
| __braintrustChunk.Mastra, | ||
| ${MASTRA_PROXY_HANDLER_BODY}, | ||
| ); | ||
| Object.defineProperty(exports, "Mastra", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| get: function () { return __braintrustWrappedMastra; } | ||
| }); | ||
| `; | ||
| } | ||
| var OBSERVABILITY_APPEND_BODY = ` | ||
| ;(function __braintrustWrapObservability() { | ||
| // Top-level so we can both read and reassign the var binding the original | ||
| // entry declared. | ||
| if (typeof Observability === "undefined") return; | ||
| if (Observability.__braintrustWrapped) return; | ||
| function __braintrustEnsureExporter(rawConfig) { | ||
| try { | ||
| var factory = globalThis[${EXPORTER_FACTORY_KEY}]; | ||
| if (typeof factory !== "function") return rawConfig; | ||
| var config = rawConfig && typeof rawConfig === "object" ? rawConfig : {}; | ||
| var configsIn = config.configs && typeof config.configs === "object" ? config.configs : null; | ||
| var configsOut = {}; | ||
| var hadEntries = false; | ||
| if (configsIn) { | ||
| for (var name in configsIn) { | ||
| if (!Object.prototype.hasOwnProperty.call(configsIn, name)) continue; | ||
| hadEntries = true; | ||
| var inst = configsIn[name] || {}; | ||
| var existing = Array.isArray(inst.exporters) ? inst.exporters : []; | ||
| var hasOurs = existing.some(function (e) { return e && e.name === "braintrust"; }); | ||
| configsOut[name] = Object.assign({}, inst, { | ||
| exporters: hasOurs ? existing : existing.concat([factory()]), | ||
| }); | ||
| } | ||
| } | ||
| if (!hadEntries) { | ||
| configsOut.default = { | ||
| serviceName: "mastra", | ||
| exporters: [factory()], | ||
| }; | ||
| } | ||
| return Object.assign({}, config, { configs: configsOut }); | ||
| } catch (e) { | ||
| return rawConfig; | ||
| } | ||
| } | ||
| var __OriginalObservability = Observability; | ||
| Observability = new Proxy(__OriginalObservability, { | ||
| construct: function (target, args, newTarget) { | ||
| var nextArgs = args.slice(); | ||
| nextArgs[0] = __braintrustEnsureExporter(nextArgs[0]); | ||
| return Reflect.construct(target, nextArgs, newTarget); | ||
| }, | ||
| }); | ||
| Observability.__braintrustWrapped = true; | ||
| if (typeof exports !== "undefined" && exports && typeof exports === "object") { | ||
| try { | ||
| Object.defineProperty(exports, "Observability", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| get: function () { return Observability; }, | ||
| }); | ||
| } catch (e) {} | ||
| } | ||
| })(); | ||
| `; | ||
| function patchMastraSource(source, target, format) { | ||
| if (target === "core") { | ||
| const chunkPath = extractChunkPath(source); | ||
| if (!chunkPath) return source; | ||
| return format === "esm" ? buildMastraEsmWrapper(chunkPath) : buildMastraCjsWrapper(chunkPath); | ||
| } | ||
| return source + OBSERVABILITY_APPEND_BODY; | ||
| } | ||
| // src/instrumentation/plugins/openai-agents-channels.ts | ||
| var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", { | ||
| onTraceStart: channel({ | ||
| channelName: "tracing.processor.onTraceStart", | ||
| kind: "async" | ||
| }), | ||
| onTraceEnd: channel({ | ||
| channelName: "tracing.processor.onTraceEnd", | ||
| kind: "async" | ||
| }), | ||
| onSpanStart: channel({ | ||
| channelName: "tracing.processor.onSpanStart", | ||
| kind: "async" | ||
| }), | ||
| onSpanEnd: channel({ | ||
| channelName: "tracing.processor.onSpanEnd", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/langchain-channels.ts | ||
| var langChainChannels = defineChannels("@langchain/core", { | ||
| configure: channel({ | ||
| channelName: "CallbackManager.configure", | ||
| kind: "sync-stream" | ||
| }), | ||
| configureSync: channel({ | ||
| channelName: "CallbackManager._configureSync", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| exports.__export = __export; exports.patchTracingChannel = patchTracingChannel; exports.isomorph_default = isomorph_default; exports.openAIChannels = openAIChannels; exports.openAICodexChannels = openAICodexChannels; exports.anthropicChannels = anthropicChannels; exports.aiSDKChannels = aiSDKChannels; exports.claudeAgentSDKChannels = claudeAgentSDKChannels; exports.cursorSDKChannels = cursorSDKChannels; exports.openAIAgentsCoreChannels = openAIAgentsCoreChannels; exports.googleGenAIChannels = googleGenAIChannels; exports.huggingFaceChannels = huggingFaceChannels; exports.openRouterAgentChannels = openRouterAgentChannels; exports.openRouterChannels = openRouterChannels; exports.mistralChannels = mistralChannels; exports.googleADKChannels = googleADKChannels; exports.cohereChannels = cohereChannels; exports.groqChannels = groqChannels; exports.genkitChannels = genkitChannels; exports.genkitCoreChannels = genkitCoreChannels; exports.gitHubCopilotChannels = gitHubCopilotChannels; exports.flueChannels = flueChannels; exports.langChainChannels = langChainChannels; exports.piCodingAgentChannels = piCodingAgentChannels; exports.getDefaultInstrumentationIntegrations = getDefaultInstrumentationIntegrations; exports.readDisabledInstrumentationEnvConfig = readDisabledInstrumentationEnvConfig; exports.isInstrumentationIntegrationDisabled = isInstrumentationIntegrationDisabled; exports.installMastraExporterFactory = installMastraExporterFactory; exports.classifyMastraTarget = classifyMastraTarget; exports.patchMastraSource = patchMastraSource; |
| var __defProp = Object.defineProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| // src/auto-instrumentations/patch-tracing-channel.ts | ||
| function patchTracingChannel(tracingChannelFn) { | ||
| const dummyChannel = tracingChannelFn("__braintrust_probe__"); | ||
| const TracingChannel = dummyChannel?.constructor; | ||
| if (!TracingChannel?.prototype) { | ||
| return; | ||
| } | ||
| if (!Object.getOwnPropertyDescriptor(TracingChannel.prototype, "hasSubscribers")) { | ||
| Object.defineProperty(TracingChannel.prototype, "hasSubscribers", { | ||
| configurable: true, | ||
| enumerable: false, | ||
| get() { | ||
| return Boolean( | ||
| this.start?.hasSubscribers || this.end?.hasSubscribers || this.asyncStart?.hasSubscribers || this.asyncEnd?.hasSubscribers || this.error?.hasSubscribers | ||
| ); | ||
| } | ||
| }); | ||
| } | ||
| if (TracingChannel.prototype.tracePromise) { | ||
| TracingChannel.prototype.tracePromise = function(fn, context = {}, thisArg, ...args) { | ||
| const start = this.start; | ||
| const end = this.end; | ||
| const asyncStart = this.asyncStart; | ||
| const asyncEnd = this.asyncEnd; | ||
| const error = this.error; | ||
| function publishRejected(err) { | ||
| context.error = err; | ||
| error?.publish(context); | ||
| asyncStart?.publish(context); | ||
| asyncEnd?.publish(context); | ||
| } | ||
| function publishResolved(result) { | ||
| context.result = result; | ||
| asyncStart?.publish(context); | ||
| asyncEnd?.publish(context); | ||
| } | ||
| return start.runStores(context, () => { | ||
| try { | ||
| const result = Reflect.apply(fn, thisArg, args); | ||
| end?.publish(context); | ||
| if (result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function") { | ||
| if (result.constructor === Promise) { | ||
| return result.then( | ||
| (res) => { | ||
| publishResolved(res); | ||
| return res; | ||
| }, | ||
| (err) => { | ||
| publishRejected(err); | ||
| return Promise.reject(err); | ||
| } | ||
| ); | ||
| } | ||
| void result.then( | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (resolved) => { | ||
| try { | ||
| publishResolved(resolved); | ||
| } catch { | ||
| } | ||
| }, | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| (err) => { | ||
| try { | ||
| publishRejected(err); | ||
| } catch { | ||
| } | ||
| } | ||
| ); | ||
| return result; | ||
| } | ||
| context.result = result; | ||
| asyncStart?.publish(context); | ||
| asyncEnd?.publish(context); | ||
| return result; | ||
| } catch (err) { | ||
| context.error = err; | ||
| error?.publish(context); | ||
| end?.publish(context); | ||
| throw err; | ||
| } | ||
| }); | ||
| }; | ||
| } | ||
| } | ||
| // src/isomorph.ts | ||
| var DefaultAsyncLocalStorage = class { | ||
| constructor() { | ||
| } | ||
| enterWith(_) { | ||
| } | ||
| run(_, callback) { | ||
| return callback(); | ||
| } | ||
| getStore() { | ||
| return void 0; | ||
| } | ||
| }; | ||
| var DefaultChannel = class { | ||
| constructor(name) { | ||
| this.name = name; | ||
| } | ||
| hasSubscribers = false; | ||
| subscribe(_subscription) { | ||
| } | ||
| unsubscribe(_subscription) { | ||
| return false; | ||
| } | ||
| bindStore(_store, _transform) { | ||
| } | ||
| unbindStore(_store) { | ||
| return false; | ||
| } | ||
| publish(_message) { | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| runStores(_message, fn, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| }; | ||
| var DefaultTracingChannel = class { | ||
| start; | ||
| end; | ||
| asyncStart; | ||
| asyncEnd; | ||
| error; | ||
| constructor(nameOrChannels) { | ||
| if (typeof nameOrChannels === "string") { | ||
| this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`); | ||
| this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`); | ||
| this.asyncStart = new DefaultChannel( | ||
| `tracing:${nameOrChannels}:asyncStart` | ||
| ); | ||
| this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`); | ||
| this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`); | ||
| return; | ||
| } | ||
| this.start = nameOrChannels.start ?? new DefaultChannel("tracing:start"); | ||
| this.end = nameOrChannels.end ?? new DefaultChannel("tracing:end"); | ||
| this.asyncStart = nameOrChannels.asyncStart ?? new DefaultChannel("tracing:asyncStart"); | ||
| this.asyncEnd = nameOrChannels.asyncEnd ?? new DefaultChannel("tracing:asyncEnd"); | ||
| this.error = nameOrChannels.error ?? new DefaultChannel("tracing:error"); | ||
| } | ||
| get hasSubscribers() { | ||
| return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers; | ||
| } | ||
| subscribe(_handlers) { | ||
| } | ||
| unsubscribe(_handlers) { | ||
| return false; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| traceSync(fn, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| tracePromise(fn, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| traceCallback(fn, _position, _message, thisArg, ...args) { | ||
| return fn.apply(thisArg, args); | ||
| } | ||
| }; | ||
| var iso = { | ||
| buildType: "unknown", | ||
| // Will be set by configureBrowser() or configureNode() | ||
| getRepoInfo: async (_settings) => void 0, | ||
| getPastNAncestors: async () => [], | ||
| getEnv: (_name) => void 0, | ||
| getBraintrustApiKey: async () => void 0, | ||
| getCallerLocation: () => void 0, | ||
| newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(), | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels), | ||
| processOn: (_0, _1) => { | ||
| }, | ||
| basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath, | ||
| // eslint-disable-next-line no-restricted-properties -- preserving intentional console usage. | ||
| writeln: (text) => console.log(text) | ||
| }; | ||
| var isomorph_default = iso; | ||
| // src/instrumentation/core/channel-definitions.ts | ||
| function channel(spec) { | ||
| return spec; | ||
| } | ||
| function defineChannels(pkg, channels) { | ||
| return Object.fromEntries( | ||
| Object.entries(channels).map(([key, spec]) => { | ||
| const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`; | ||
| if (spec.kind === "async") { | ||
| const asyncSpec = spec; | ||
| const tracingChannel2 = () => isomorph_default.newTracingChannel( | ||
| fullChannelName | ||
| ); | ||
| return [ | ||
| key, | ||
| { | ||
| ...asyncSpec, | ||
| tracingChannel: tracingChannel2, | ||
| tracePromise: (fn, context) => tracingChannel2().tracePromise( | ||
| fn, | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| context | ||
| ) | ||
| } | ||
| ]; | ||
| } | ||
| const syncSpec = spec; | ||
| const tracingChannel = () => isomorph_default.newTracingChannel( | ||
| fullChannelName | ||
| ); | ||
| return [ | ||
| key, | ||
| { | ||
| ...syncSpec, | ||
| tracingChannel, | ||
| traceSync: (fn, context) => tracingChannel().traceSync( | ||
| fn, | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| context | ||
| ) | ||
| } | ||
| ]; | ||
| }) | ||
| ); | ||
| } | ||
| // src/instrumentation/plugins/openai-channels.ts | ||
| var openAIChannels = defineChannels("openai", { | ||
| chatCompletionsCreate: channel({ | ||
| channelName: "chat.completions.create", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel({ | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| }), | ||
| betaChatCompletionsParse: channel({ | ||
| channelName: "beta.chat.completions.parse", | ||
| kind: "async" | ||
| }), | ||
| betaChatCompletionsStream: channel({ | ||
| channelName: "beta.chat.completions.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| moderationsCreate: channel({ | ||
| channelName: "moderations.create", | ||
| kind: "async" | ||
| }), | ||
| responsesCreate: channel({ | ||
| channelName: "responses.create", | ||
| kind: "async" | ||
| }), | ||
| responsesStream: channel({ | ||
| channelName: "responses.stream", | ||
| kind: "sync-stream" | ||
| }), | ||
| responsesParse: channel({ | ||
| channelName: "responses.parse", | ||
| kind: "async" | ||
| }), | ||
| responsesCompact: channel({ | ||
| channelName: "responses.compact", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openai-codex-channels.ts | ||
| var openAICodexChannels = defineChannels("@openai/codex-sdk", { | ||
| run: channel({ | ||
| channelName: "Thread.run", | ||
| kind: "async" | ||
| }), | ||
| runStreamed: channel({ | ||
| channelName: "Thread.runStreamed", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/anthropic-channels.ts | ||
| var anthropicChannels = defineChannels("@anthropic-ai/sdk", { | ||
| messagesCreate: channel({ | ||
| channelName: "messages.create", | ||
| kind: "async" | ||
| }), | ||
| betaMessagesCreate: channel({ | ||
| channelName: "beta.messages.create", | ||
| kind: "async" | ||
| }), | ||
| betaMessagesToolRunner: channel({ | ||
| channelName: "beta.messages.toolRunner", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/ai-sdk-channels.ts | ||
| var aiSDKChannels = defineChannels("ai", { | ||
| generateText: channel({ | ||
| channelName: "generateText", | ||
| kind: "async" | ||
| }), | ||
| streamText: channel({ | ||
| channelName: "streamText", | ||
| kind: "async" | ||
| }), | ||
| streamTextSync: channel({ | ||
| channelName: "streamText.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| generateObject: channel({ | ||
| channelName: "generateObject", | ||
| kind: "async" | ||
| }), | ||
| streamObject: channel({ | ||
| channelName: "streamObject", | ||
| kind: "async" | ||
| }), | ||
| streamObjectSync: channel({ | ||
| channelName: "streamObject.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| embed: channel( | ||
| { | ||
| channelName: "embed", | ||
| kind: "async" | ||
| } | ||
| ), | ||
| embedMany: channel({ | ||
| channelName: "embedMany", | ||
| kind: "async" | ||
| }), | ||
| rerank: channel({ | ||
| channelName: "rerank", | ||
| kind: "async" | ||
| }), | ||
| agentGenerate: channel({ | ||
| channelName: "Agent.generate", | ||
| kind: "async" | ||
| }), | ||
| agentStream: channel({ | ||
| channelName: "Agent.stream", | ||
| kind: "async" | ||
| }), | ||
| agentStreamSync: channel({ | ||
| channelName: "Agent.stream.sync", | ||
| kind: "sync-stream" | ||
| }), | ||
| toolLoopAgentGenerate: channel({ | ||
| channelName: "ToolLoopAgent.generate", | ||
| kind: "async" | ||
| }), | ||
| toolLoopAgentStream: channel({ | ||
| channelName: "ToolLoopAgent.stream", | ||
| kind: "async" | ||
| }), | ||
| v7CreateTelemetryDispatcher: channel({ | ||
| channelName: "createTelemetryDispatcher", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/claude-agent-sdk-channels.ts | ||
| var claudeAgentSDKChannels = defineChannels( | ||
| "@anthropic-ai/claude-agent-sdk", | ||
| { | ||
| query: channel({ | ||
| channelName: "query", | ||
| kind: "sync-stream" | ||
| }) | ||
| } | ||
| ); | ||
| // src/instrumentation/plugins/cursor-sdk-channels.ts | ||
| var cursorSDKChannels = defineChannels("@cursor/sdk", { | ||
| create: channel({ | ||
| channelName: "Agent.create", | ||
| kind: "async" | ||
| }), | ||
| resume: channel({ | ||
| channelName: "Agent.resume", | ||
| kind: "async" | ||
| }), | ||
| prompt: channel({ | ||
| channelName: "Agent.prompt", | ||
| kind: "async" | ||
| }), | ||
| send: channel({ | ||
| channelName: "agent.send", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/google-genai-channels.ts | ||
| var googleGenAIChannels = defineChannels("@google/genai", { | ||
| generateContent: channel({ | ||
| channelName: "models.generateContent", | ||
| kind: "async" | ||
| }), | ||
| generateContentStream: channel({ | ||
| channelName: "models.generateContentStream", | ||
| kind: "async" | ||
| }), | ||
| embedContent: channel({ | ||
| channelName: "models.embedContent", | ||
| kind: "async" | ||
| }), | ||
| interactionsCreate: channel({ | ||
| channelName: "interactions.create", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/huggingface-channels.ts | ||
| var huggingFaceChannels = defineChannels("@huggingface/inference", { | ||
| chatCompletion: channel({ | ||
| channelName: "chatCompletion", | ||
| kind: "async" | ||
| }), | ||
| chatCompletionStream: channel({ | ||
| channelName: "chatCompletionStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| textGeneration: channel({ | ||
| channelName: "textGeneration", | ||
| kind: "async" | ||
| }), | ||
| textGenerationStream: channel({ | ||
| channelName: "textGenerationStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| featureExtraction: channel({ | ||
| channelName: "featureExtraction", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openrouter-agent-channels.ts | ||
| var openRouterAgentChannels = defineChannels("@openrouter/agent", { | ||
| callModel: channel({ | ||
| channelName: "callModel", | ||
| kind: "sync-stream" | ||
| }), | ||
| callModelTurn: channel({ | ||
| channelName: "callModel.turn", | ||
| kind: "async" | ||
| }), | ||
| toolExecute: channel({ | ||
| channelName: "tool.execute", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/openrouter-channels.ts | ||
| var openRouterChannels = defineChannels("@openrouter/sdk", { | ||
| chatSend: channel({ | ||
| channelName: "chat.send", | ||
| kind: "async" | ||
| }), | ||
| embeddingsGenerate: channel({ | ||
| channelName: "embeddings.generate", | ||
| kind: "async" | ||
| }), | ||
| rerankRerank: channel( | ||
| { | ||
| channelName: "rerank.rerank", | ||
| kind: "async" | ||
| } | ||
| ), | ||
| betaResponsesSend: channel({ | ||
| channelName: "beta.responses.send", | ||
| kind: "async" | ||
| }), | ||
| callModel: channel({ | ||
| channelName: "callModel", | ||
| kind: "sync-stream" | ||
| }), | ||
| callModelTurn: channel({ | ||
| channelName: "callModel.turn", | ||
| kind: "async" | ||
| }), | ||
| toolExecute: channel({ | ||
| channelName: "tool.execute", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/mistral-channels.ts | ||
| var mistralChannels = defineChannels("@mistralai/mistralai", { | ||
| chatComplete: channel({ | ||
| channelName: "chat.complete", | ||
| kind: "async" | ||
| }), | ||
| chatStream: channel({ | ||
| channelName: "chat.stream", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel({ | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| }), | ||
| classifiersModerate: channel({ | ||
| channelName: "classifiers.moderate", | ||
| kind: "async" | ||
| }), | ||
| classifiersModerateChat: channel({ | ||
| channelName: "classifiers.moderateChat", | ||
| kind: "async" | ||
| }), | ||
| classifiersClassify: channel({ | ||
| channelName: "classifiers.classify", | ||
| kind: "async" | ||
| }), | ||
| classifiersClassifyChat: channel({ | ||
| channelName: "classifiers.classifyChat", | ||
| kind: "async" | ||
| }), | ||
| fimComplete: channel({ | ||
| channelName: "fim.complete", | ||
| kind: "async" | ||
| }), | ||
| fimStream: channel({ | ||
| channelName: "fim.stream", | ||
| kind: "async" | ||
| }), | ||
| agentsComplete: channel({ | ||
| channelName: "agents.complete", | ||
| kind: "async" | ||
| }), | ||
| agentsStream: channel({ | ||
| channelName: "agents.stream", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/google-adk-channels.ts | ||
| var googleADKChannels = defineChannels("@google/adk", { | ||
| runnerRunAsync: channel({ | ||
| channelName: "runner.runAsync", | ||
| kind: "sync-stream" | ||
| }), | ||
| agentRunAsync: channel({ | ||
| channelName: "agent.runAsync", | ||
| kind: "sync-stream" | ||
| }), | ||
| toolRunAsync: channel({ | ||
| channelName: "tool.runAsync", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/cohere-channels.ts | ||
| var cohereChannels = defineChannels("cohere-ai", { | ||
| chat: channel({ | ||
| channelName: "chat", | ||
| kind: "async" | ||
| }), | ||
| chatStream: channel({ | ||
| channelName: "chatStream", | ||
| kind: "async" | ||
| }), | ||
| embed: channel({ | ||
| channelName: "embed", | ||
| kind: "async" | ||
| }), | ||
| rerank: channel({ | ||
| channelName: "rerank", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/groq-channels.ts | ||
| var groqChannels = defineChannels("groq-sdk", { | ||
| chatCompletionsCreate: channel({ | ||
| channelName: "chat.completions.create", | ||
| kind: "async" | ||
| }), | ||
| embeddingsCreate: channel( | ||
| { | ||
| channelName: "embeddings.create", | ||
| kind: "async" | ||
| } | ||
| ) | ||
| }); | ||
| // src/instrumentation/plugins/genkit-channels.ts | ||
| var genkitChannels = defineChannels("@genkit-ai/ai", { | ||
| generate: channel({ | ||
| channelName: "generate", | ||
| kind: "async" | ||
| }), | ||
| generateStream: channel({ | ||
| channelName: "generateStream", | ||
| kind: "sync-stream" | ||
| }), | ||
| embed: channel({ | ||
| channelName: "embed", | ||
| kind: "async" | ||
| }), | ||
| embedMany: channel({ | ||
| channelName: "embedMany", | ||
| kind: "async" | ||
| }), | ||
| actionRun: channel({ | ||
| channelName: "action.run", | ||
| kind: "async" | ||
| }), | ||
| actionStream: channel({ | ||
| channelName: "action.stream", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| var genkitCoreChannels = defineChannels("@genkit-ai/core", { | ||
| actionSpan: channel({ | ||
| channelName: "action.span", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/github-copilot-channels.ts | ||
| var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", { | ||
| createSession: channel({ | ||
| channelName: "client.createSession", | ||
| kind: "async" | ||
| }), | ||
| resumeSession: channel({ | ||
| channelName: "client.resumeSession", | ||
| kind: "async" | ||
| }), | ||
| sendAndWait: channel({ | ||
| channelName: "session.sendAndWait", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/flue-channels.ts | ||
| var flueChannels = defineChannels("@flue/runtime", { | ||
| createContext: channel({ | ||
| channelName: "createFlueContext", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/pi-coding-agent-channels.ts | ||
| var piCodingAgentChannels = defineChannels( | ||
| "@earendil-works/pi-coding-agent", | ||
| { | ||
| prompt: channel({ | ||
| channelName: "AgentSession.prompt", | ||
| kind: "async" | ||
| }) | ||
| } | ||
| ); | ||
| // src/instrumentation/config.ts | ||
| var envIntegrationAliases = { | ||
| openai: "openai", | ||
| "openai-codex": "openaiCodexSDK", | ||
| "openai-codex-sdk": "openaiCodexSDK", | ||
| openaicodexsdk: "openaiCodexSDK", | ||
| codex: "openaiCodexSDK", | ||
| "codex-sdk": "openaiCodexSDK", | ||
| "pi-coding-agent": "piCodingAgent", | ||
| "pi-coding-agent-sdk": "piCodingAgent", | ||
| picodingagent: "piCodingAgent", | ||
| picodingagentsdk: "piCodingAgent", | ||
| "@earendil-works/pi-coding-agent": "piCodingAgent", | ||
| anthropic: "anthropic", | ||
| aisdk: "aisdk", | ||
| "ai-sdk": "aisdk", | ||
| "vercel-ai": "aisdk", | ||
| vercel: "vercel", | ||
| claudeagentsdk: "claudeAgentSDK", | ||
| "claude-agent-sdk": "claudeAgentSDK", | ||
| cursor: "cursor", | ||
| "cursor-sdk": "cursorSDK", | ||
| cursorsdk: "cursorSDK", | ||
| flue: "flue", | ||
| "flue-runtime": "flue", | ||
| mastra: "mastra", | ||
| "openai-agents": "openAIAgents", | ||
| openaiagents: "openAIAgents", | ||
| "openai-agents-core": "openAIAgents", | ||
| openaiagentscore: "openAIAgents", | ||
| google: "google", | ||
| "google-genai": "googleGenAI", | ||
| googlegenai: "googleGenAI", | ||
| huggingface: "huggingface", | ||
| openrouter: "openrouter", | ||
| openrouteragent: "openrouterAgent", | ||
| "openrouter-agent": "openrouterAgent", | ||
| mistral: "mistral", | ||
| googleadk: "googleADK", | ||
| "google-adk": "googleADK", | ||
| cohere: "cohere", | ||
| groq: "groq", | ||
| "groq-sdk": "groq", | ||
| genkit: "genkit", | ||
| "firebase-genkit": "genkit", | ||
| githubcopilot: "gitHubCopilot", | ||
| "github-copilot": "gitHubCopilot", | ||
| "copilot-sdk": "gitHubCopilot", | ||
| langchain: "langchain", | ||
| "langchain-js": "langchain", | ||
| "@langchain": "langchain", | ||
| langgraph: "langgraph" | ||
| }; | ||
| function getDefaultInstrumentationIntegrations() { | ||
| return { | ||
| openai: true, | ||
| openaiCodexSDK: true, | ||
| anthropic: true, | ||
| vercel: true, | ||
| aisdk: true, | ||
| google: true, | ||
| googleGenAI: true, | ||
| googleADK: true, | ||
| huggingface: true, | ||
| claudeAgentSDK: true, | ||
| cursor: true, | ||
| cursorSDK: true, | ||
| flue: true, | ||
| mastra: true, | ||
| openAIAgents: true, | ||
| openrouter: true, | ||
| openrouterAgent: true, | ||
| mistral: true, | ||
| cohere: true, | ||
| groq: true, | ||
| genkit: true, | ||
| gitHubCopilot: true, | ||
| langchain: true, | ||
| langgraph: true, | ||
| piCodingAgent: true | ||
| }; | ||
| } | ||
| function readDisabledInstrumentationEnvConfig(disabledList) { | ||
| const integrations = {}; | ||
| if (disabledList) { | ||
| for (const value of disabledList.split(",")) { | ||
| const sdk = value.trim().toLowerCase(); | ||
| if (sdk.length > 0) { | ||
| integrations[envIntegrationAliases[sdk] ?? sdk] = false; | ||
| } | ||
| } | ||
| } | ||
| return { integrations }; | ||
| } | ||
| function isInstrumentationIntegrationDisabled(integrations, ...names) { | ||
| return names.some((name) => integrations?.[name] === false); | ||
| } | ||
| // src/auto-instrumentations/loader/mastra-observability-patch.ts | ||
| var MASTRA_EXPORTER_FACTORY_GLOBAL = "__braintrustMastraExporterFactory"; | ||
| function installMastraExporterFactory(factory) { | ||
| const globals = globalThis; | ||
| globals[MASTRA_EXPORTER_FACTORY_GLOBAL] ??= factory; | ||
| } | ||
| var MASTRA_CORE_PACKAGE = "@mastra/core"; | ||
| var MASTRA_OBSERVABILITY_PACKAGE = "@mastra/observability"; | ||
| var MASTRA_CORE_ENTRY_PATHS = /* @__PURE__ */ new Set([ | ||
| "dist/index.js", | ||
| "dist/index.cjs", | ||
| "dist/mastra/index.js", | ||
| "dist/mastra/index.cjs" | ||
| ]); | ||
| var MASTRA_OBSERVABILITY_ENTRY_PATHS = /* @__PURE__ */ new Set([ | ||
| "dist/index.js", | ||
| "dist/index.cjs" | ||
| ]); | ||
| function classifyMastraTarget(packageName, modulePath) { | ||
| if (packageName === MASTRA_CORE_PACKAGE && MASTRA_CORE_ENTRY_PATHS.has(modulePath)) { | ||
| return "core"; | ||
| } | ||
| if (packageName === MASTRA_OBSERVABILITY_PACKAGE && MASTRA_OBSERVABILITY_ENTRY_PATHS.has(modulePath)) { | ||
| return "observability"; | ||
| } | ||
| return null; | ||
| } | ||
| function extractChunkPath(source) { | ||
| const esmMatch = source.match( | ||
| /export\s*\{\s*Mastra(?:\s+as\s+\w+)?\s*\}\s*from\s*['"]([^'"]+)['"]/ | ||
| ); | ||
| if (esmMatch) return esmMatch[1]; | ||
| const cjsMatch = source.match( | ||
| /require\s*\(\s*['"]([^'"]+chunk-[^'"]+)['"]\s*\)/ | ||
| ); | ||
| if (cjsMatch) return cjsMatch[1]; | ||
| return null; | ||
| } | ||
| var EXPORTER_FACTORY_KEY = JSON.stringify(MASTRA_EXPORTER_FACTORY_GLOBAL); | ||
| var MASTRA_PROXY_HANDLER_BODY = ` | ||
| { | ||
| construct(target, args, newTarget) { | ||
| var firstArg = args[0]; | ||
| if ( | ||
| (!firstArg || typeof firstArg !== "object" || !firstArg.observability) && | ||
| __braintrustObservabilityClass | ||
| ) { | ||
| try { | ||
| // serviceName is required by Mastra's Observability validator; pass | ||
| // something sensible by default. Users who want a different name | ||
| // should construct Observability themselves. | ||
| var observability = new __braintrustObservabilityClass({ | ||
| configs: { default: { serviceName: "mastra" } }, | ||
| }); | ||
| args = args.slice(); | ||
| args[0] = Object.assign({}, firstArg, { observability: observability }); | ||
| } catch (e) { | ||
| // Fall through. Mastra will use its own NoOp; user code still works, | ||
| // just without auto-instrumentation. | ||
| } | ||
| } | ||
| return Reflect.construct(target, args, newTarget); | ||
| }, | ||
| }`; | ||
| function buildMastraEsmWrapper(chunkPath) { | ||
| const chunk = JSON.stringify(chunkPath); | ||
| return `import { Mastra as __braintrustOrigMastra } from ${chunk}; | ||
| import { createRequire as __braintrustCreateRequire } from "node:module"; | ||
| let __braintrustObservabilityClass = null; | ||
| try { | ||
| // Resolve @mastra/observability relative to this module (the Mastra entry), | ||
| // so it's looked up from the user's node_modules tree. | ||
| const __braintrustRequire = __braintrustCreateRequire(import.meta.url); | ||
| __braintrustObservabilityClass = | ||
| __braintrustRequire("@mastra/observability").Observability; | ||
| } catch (e) { | ||
| // @mastra/observability isn't installed; the construct trap will skip the | ||
| // auto-construct branch and Mastra falls back to its own NoOp. | ||
| } | ||
| const Mastra = new Proxy(__braintrustOrigMastra, ${MASTRA_PROXY_HANDLER_BODY}); | ||
| export { Mastra }; | ||
| `; | ||
| } | ||
| function buildMastraCjsWrapper(chunkPath) { | ||
| const chunk = JSON.stringify(chunkPath); | ||
| return `'use strict'; | ||
| const __braintrustChunk = require(${chunk}); | ||
| let __braintrustObservabilityClass = null; | ||
| try { | ||
| __braintrustObservabilityClass = require("@mastra/observability").Observability; | ||
| } catch (e) { | ||
| // @mastra/observability isn't installed; same fallback as the ESM wrapper. | ||
| } | ||
| const __braintrustWrappedMastra = new Proxy( | ||
| __braintrustChunk.Mastra, | ||
| ${MASTRA_PROXY_HANDLER_BODY}, | ||
| ); | ||
| Object.defineProperty(exports, "Mastra", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| get: function () { return __braintrustWrappedMastra; } | ||
| }); | ||
| `; | ||
| } | ||
| var OBSERVABILITY_APPEND_BODY = ` | ||
| ;(function __braintrustWrapObservability() { | ||
| // Top-level so we can both read and reassign the var binding the original | ||
| // entry declared. | ||
| if (typeof Observability === "undefined") return; | ||
| if (Observability.__braintrustWrapped) return; | ||
| function __braintrustEnsureExporter(rawConfig) { | ||
| try { | ||
| var factory = globalThis[${EXPORTER_FACTORY_KEY}]; | ||
| if (typeof factory !== "function") return rawConfig; | ||
| var config = rawConfig && typeof rawConfig === "object" ? rawConfig : {}; | ||
| var configsIn = config.configs && typeof config.configs === "object" ? config.configs : null; | ||
| var configsOut = {}; | ||
| var hadEntries = false; | ||
| if (configsIn) { | ||
| for (var name in configsIn) { | ||
| if (!Object.prototype.hasOwnProperty.call(configsIn, name)) continue; | ||
| hadEntries = true; | ||
| var inst = configsIn[name] || {}; | ||
| var existing = Array.isArray(inst.exporters) ? inst.exporters : []; | ||
| var hasOurs = existing.some(function (e) { return e && e.name === "braintrust"; }); | ||
| configsOut[name] = Object.assign({}, inst, { | ||
| exporters: hasOurs ? existing : existing.concat([factory()]), | ||
| }); | ||
| } | ||
| } | ||
| if (!hadEntries) { | ||
| configsOut.default = { | ||
| serviceName: "mastra", | ||
| exporters: [factory()], | ||
| }; | ||
| } | ||
| return Object.assign({}, config, { configs: configsOut }); | ||
| } catch (e) { | ||
| return rawConfig; | ||
| } | ||
| } | ||
| var __OriginalObservability = Observability; | ||
| Observability = new Proxy(__OriginalObservability, { | ||
| construct: function (target, args, newTarget) { | ||
| var nextArgs = args.slice(); | ||
| nextArgs[0] = __braintrustEnsureExporter(nextArgs[0]); | ||
| return Reflect.construct(target, nextArgs, newTarget); | ||
| }, | ||
| }); | ||
| Observability.__braintrustWrapped = true; | ||
| if (typeof exports !== "undefined" && exports && typeof exports === "object") { | ||
| try { | ||
| Object.defineProperty(exports, "Observability", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| get: function () { return Observability; }, | ||
| }); | ||
| } catch (e) {} | ||
| } | ||
| })(); | ||
| `; | ||
| function patchMastraSource(source, target, format) { | ||
| if (target === "core") { | ||
| const chunkPath = extractChunkPath(source); | ||
| if (!chunkPath) return source; | ||
| return format === "esm" ? buildMastraEsmWrapper(chunkPath) : buildMastraCjsWrapper(chunkPath); | ||
| } | ||
| return source + OBSERVABILITY_APPEND_BODY; | ||
| } | ||
| // src/instrumentation/plugins/openai-agents-channels.ts | ||
| var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", { | ||
| onTraceStart: channel({ | ||
| channelName: "tracing.processor.onTraceStart", | ||
| kind: "async" | ||
| }), | ||
| onTraceEnd: channel({ | ||
| channelName: "tracing.processor.onTraceEnd", | ||
| kind: "async" | ||
| }), | ||
| onSpanStart: channel({ | ||
| channelName: "tracing.processor.onSpanStart", | ||
| kind: "async" | ||
| }), | ||
| onSpanEnd: channel({ | ||
| channelName: "tracing.processor.onSpanEnd", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // src/instrumentation/plugins/langchain-channels.ts | ||
| var langChainChannels = defineChannels("@langchain/core", { | ||
| configure: channel({ | ||
| channelName: "CallbackManager.configure", | ||
| kind: "sync-stream" | ||
| }), | ||
| configureSync: channel({ | ||
| channelName: "CallbackManager._configureSync", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| export { | ||
| __export, | ||
| patchTracingChannel, | ||
| isomorph_default, | ||
| openAIChannels, | ||
| openAICodexChannels, | ||
| anthropicChannels, | ||
| aiSDKChannels, | ||
| claudeAgentSDKChannels, | ||
| cursorSDKChannels, | ||
| openAIAgentsCoreChannels, | ||
| googleGenAIChannels, | ||
| huggingFaceChannels, | ||
| openRouterAgentChannels, | ||
| openRouterChannels, | ||
| mistralChannels, | ||
| googleADKChannels, | ||
| cohereChannels, | ||
| groqChannels, | ||
| genkitChannels, | ||
| genkitCoreChannels, | ||
| gitHubCopilotChannels, | ||
| flueChannels, | ||
| langChainChannels, | ||
| piCodingAgentChannels, | ||
| getDefaultInstrumentationIntegrations, | ||
| readDisabledInstrumentationEnvConfig, | ||
| isInstrumentationIntegrationDisabled, | ||
| installMastraExporterFactory, | ||
| classifyMastraTarget, | ||
| patchMastraSource | ||
| }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 5 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 3 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
25473386
3.52%94
6.82%615026
4.53%120
-7.69%79
3.95%235
21.13%