braintrust
Advanced tools
| import { | ||
| unplugin | ||
| } from "./chunk-GSZHTAQW.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
| import { | ||
| aiSDKConfigs, | ||
| anthropicConfigs, | ||
| bedrockRuntimeConfigs, | ||
| channel, | ||
| claudeAgentSDKConfigs, | ||
| cohereConfigs, | ||
| cursorSDKConfigs, | ||
| defineChannels, | ||
| genkitConfigs, | ||
| gitHubCopilotConfigs, | ||
| googleADKConfigs, | ||
| googleGenAIConfigs, | ||
| groqConfigs, | ||
| huggingFaceConfigs, | ||
| langSmithConfigs, | ||
| langchainConfigs, | ||
| mistralConfigs, | ||
| openAIAgentsCoreConfigs, | ||
| openAICodexConfigs, | ||
| openRouterAgentConfigs, | ||
| openRouterConfigs, | ||
| openaiConfigs, | ||
| piCodingAgentConfigs | ||
| } from "./chunk-F43DNLPD.mjs"; | ||
| import { | ||
| applySpecialCasePatch, | ||
| create | ||
| } from "./chunk-M6DLIJ2Z.mjs"; | ||
| // src/auto-instrumentations/bundler/plugin.ts | ||
| import { createUnplugin } from "unplugin"; | ||
| 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", | ||
| langsmith: "langsmith" | ||
| }; | ||
| 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: ["langsmith"], configs: langSmithConfigs }, | ||
| { 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 | ||
| }; |
| "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" | ||
| }), | ||
| workflowAgentStream: channel({ | ||
| channelName: "WorkflowAgent.stream", | ||
| kind: "async" | ||
| }), | ||
| v7CreateTelemetryDispatcher: channel({ | ||
| channelName: "createTelemetryDispatcher", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| var harnessAgentChannels = defineChannels("@ai-sdk/harness", { | ||
| generate: channel({ | ||
| channelName: "HarnessAgent.generate", | ||
| kind: "async" | ||
| }), | ||
| stream: channel({ | ||
| channelName: "HarnessAgent.stream", | ||
| kind: "async" | ||
| }), | ||
| continueGenerate: channel({ | ||
| channelName: "HarnessAgent.continueGenerate", | ||
| kind: "async" | ||
| }), | ||
| continueStream: channel({ | ||
| channelName: "HarnessAgent.continueStream", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // 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/langsmith-channels.ts | ||
| var langSmithChannels = defineChannels("langsmith", { | ||
| createRun: channel({ | ||
| channelName: "Client.createRun", | ||
| kind: "async" | ||
| }), | ||
| updateRun: channel({ | ||
| channelName: "Client.updateRun", | ||
| kind: "async" | ||
| }), | ||
| batchIngestRuns: channel({ | ||
| channelName: "Client.batchIngestRuns", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // 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", | ||
| langsmith: "langsmith" | ||
| }; | ||
| 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, | ||
| langsmith: 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.harnessAgentChannels = harnessAgentChannels; 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.langSmithChannels = langSmithChannels; exports.piCodingAgentChannels = piCodingAgentChannels; exports.strandsAgentSDKChannels = strandsAgentSDKChannels; 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; | ||
| } | ||
| 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" | ||
| }), | ||
| workflowAgentStream: channel({ | ||
| channelName: "WorkflowAgent.stream", | ||
| kind: "async" | ||
| }), | ||
| v7CreateTelemetryDispatcher: channel({ | ||
| channelName: "createTelemetryDispatcher", | ||
| kind: "sync-stream" | ||
| }) | ||
| }); | ||
| var harnessAgentChannels = defineChannels("@ai-sdk/harness", { | ||
| generate: channel({ | ||
| channelName: "HarnessAgent.generate", | ||
| kind: "async" | ||
| }), | ||
| stream: channel({ | ||
| channelName: "HarnessAgent.stream", | ||
| kind: "async" | ||
| }), | ||
| continueGenerate: channel({ | ||
| channelName: "HarnessAgent.continueGenerate", | ||
| kind: "async" | ||
| }), | ||
| continueStream: channel({ | ||
| channelName: "HarnessAgent.continueStream", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // 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/langsmith-channels.ts | ||
| var langSmithChannels = defineChannels("langsmith", { | ||
| createRun: channel({ | ||
| channelName: "Client.createRun", | ||
| kind: "async" | ||
| }), | ||
| updateRun: channel({ | ||
| channelName: "Client.updateRun", | ||
| kind: "async" | ||
| }), | ||
| batchIngestRuns: channel({ | ||
| channelName: "Client.batchIngestRuns", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // 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", | ||
| langsmith: "langsmith" | ||
| }; | ||
| 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, | ||
| langsmith: 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, | ||
| harnessAgentChannels, | ||
| claudeAgentSDKChannels, | ||
| cursorSDKChannels, | ||
| openAIAgentsCoreChannels, | ||
| googleGenAIChannels, | ||
| huggingFaceChannels, | ||
| openRouterAgentChannels, | ||
| openRouterChannels, | ||
| mistralChannels, | ||
| googleADKChannels, | ||
| cohereChannels, | ||
| groqChannels, | ||
| bedrockRuntimeChannels, | ||
| smithyCoreChannels, | ||
| smithyClientChannels, | ||
| genkitChannels, | ||
| genkitCoreChannels, | ||
| gitHubCopilotChannels, | ||
| flueChannels, | ||
| langChainChannels, | ||
| langSmithChannels, | ||
| piCodingAgentChannels, | ||
| strandsAgentSDKChannels, | ||
| 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
| import { | ||
| unplugin | ||
| } from "../chunk-EXY7QCJD.mjs"; | ||
| import "../chunk-YXLNSAMJ.mjs"; | ||
| } from "../chunk-GSZHTAQW.mjs"; | ||
| import "../chunk-F43DNLPD.mjs"; | ||
| import "../chunk-M6DLIJ2Z.mjs"; | ||
@@ -6,0 +6,0 @@ |
| import { | ||
| webpackPlugin | ||
| } from "../chunk-KIMLYPRW.mjs"; | ||
| import "../chunk-EXY7QCJD.mjs"; | ||
| import "../chunk-YXLNSAMJ.mjs"; | ||
| } from "../chunk-BURMPO7L.mjs"; | ||
| import "../chunk-GSZHTAQW.mjs"; | ||
| import "../chunk-F43DNLPD.mjs"; | ||
| import "../chunk-M6DLIJ2Z.mjs"; | ||
@@ -7,0 +7,0 @@ |
| import { | ||
| unplugin | ||
| } from "../chunk-EXY7QCJD.mjs"; | ||
| import "../chunk-YXLNSAMJ.mjs"; | ||
| } from "../chunk-GSZHTAQW.mjs"; | ||
| import "../chunk-F43DNLPD.mjs"; | ||
| import "../chunk-M6DLIJ2Z.mjs"; | ||
@@ -6,0 +6,0 @@ |
@@ -10,4 +10,4 @@ import { VitePlugin } from 'unplugin'; | ||
| */ | ||
| declare const vitePlugin: (options: LegacyBundlerPluginOptions) => VitePlugin<any> | VitePlugin<any>[]; | ||
| declare const vitePlugin: (options: LegacyBundlerPluginOptions) => any; | ||
| export { type VitePluginOptions, braintrustVitePlugin, vitePlugin }; |
@@ -10,4 +10,4 @@ import { VitePlugin } from 'unplugin'; | ||
| */ | ||
| declare const vitePlugin: (options: LegacyBundlerPluginOptions) => VitePlugin<any> | VitePlugin<any>[]; | ||
| declare const vitePlugin: (options: LegacyBundlerPluginOptions) => any; | ||
| export { type VitePluginOptions, braintrustVitePlugin, vitePlugin }; |
| import { | ||
| unplugin | ||
| } from "../chunk-EXY7QCJD.mjs"; | ||
| import "../chunk-YXLNSAMJ.mjs"; | ||
| } from "../chunk-GSZHTAQW.mjs"; | ||
| import "../chunk-F43DNLPD.mjs"; | ||
| import "../chunk-M6DLIJ2Z.mjs"; | ||
@@ -6,0 +6,0 @@ |
| import { | ||
| braintrustWebpackPlugin, | ||
| webpackPlugin | ||
| } from "../chunk-KIMLYPRW.mjs"; | ||
| import "../chunk-EXY7QCJD.mjs"; | ||
| import "../chunk-YXLNSAMJ.mjs"; | ||
| } from "../chunk-BURMPO7L.mjs"; | ||
| import "../chunk-GSZHTAQW.mjs"; | ||
| import "../chunk-F43DNLPD.mjs"; | ||
| import "../chunk-M6DLIJ2Z.mjs"; | ||
@@ -8,0 +8,0 @@ export { |
@@ -23,3 +23,3 @@ import { | ||
| piCodingAgentConfigs | ||
| } from "./chunk-YXLNSAMJ.mjs"; | ||
| } from "./chunk-F43DNLPD.mjs"; | ||
| export { | ||
@@ -26,0 +26,0 @@ aiSDKConfigs, |
@@ -7,7 +7,7 @@ "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 _chunkB6ZQIAK3js = require('./chunk-B6ZQIAK3.js'); | ||
| require('./chunk-CDIKAHDZ.js'); | ||
| var _chunkSU6EHKJVjs = require('./chunk-SU6EHKJV.js'); | ||
| require('./chunk-7AUY2XWX.js'); | ||
| // src/wrappers/vitest-evals/reporter.ts | ||
| _chunkB6ZQIAK3js.configureNode.call(void 0, ); | ||
| _chunkSU6EHKJVjs.configureNode.call(void 0, ); | ||
| var RESERVED_NORMALIZED_SPAN_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([ | ||
@@ -27,2 +27,3 @@ "name", | ||
| onInit(_vitest) { | ||
@@ -47,3 +48,3 @@ } | ||
| } | ||
| await _chunkB6ZQIAK3js.summarizeAndFlush.call(void 0, experiment, { | ||
| await _chunkSU6EHKJVjs.summarizeAndFlush.call(void 0, experiment, { | ||
| displaySummary: this.options.displaySummary | ||
@@ -64,3 +65,3 @@ }); | ||
| const experimentName = _nullishCoalesce(this.options.experimentName, () => ( `vitest-evals-${(/* @__PURE__ */ new Date()).toISOString()}`)); | ||
| this.experiment = _chunkB6ZQIAK3js.initExperiment.call(void 0, { | ||
| this.experiment = _chunkSU6EHKJVjs.initExperiment.call(void 0, { | ||
| ...projectId ? { projectId } : { project: projectName }, | ||
@@ -279,3 +280,3 @@ experiment: experimentName, | ||
| function readEvalTaskMeta(input) { | ||
| if (!_chunkB6ZQIAK3js.isObject.call(void 0, input)) return void 0; | ||
| if (!_chunkSU6EHKJVjs.isObject.call(void 0, input)) return void 0; | ||
| const evalMeta = readEvalMeta(input.eval); | ||
@@ -290,3 +291,3 @@ const harnessMeta = readHarnessMeta(input.harness); | ||
| function readEvalMeta(input) { | ||
| if (!_chunkB6ZQIAK3js.isObject.call(void 0, input)) return void 0; | ||
| if (!_chunkSU6EHKJVjs.isObject.call(void 0, input)) return void 0; | ||
| const avgScore = readFiniteOrNull(input.avgScore); | ||
@@ -304,3 +305,3 @@ const scores = Array.isArray(input.scores) ? input.scores.map(readEvalScore).filter(isDefined) : void 0; | ||
| function readEvalScore(input) { | ||
| if (!_chunkB6ZQIAK3js.isObject.call(void 0, input)) return void 0; | ||
| if (!_chunkSU6EHKJVjs.isObject.call(void 0, input)) return void 0; | ||
| const score = readFiniteOrNull(input.score); | ||
@@ -310,14 +311,14 @@ return { | ||
| ...score !== void 0 ? { score } : {}, | ||
| ..._chunkB6ZQIAK3js.isObject.call(void 0, input.metadata) ? { metadata: input.metadata } : {} | ||
| ..._chunkSU6EHKJVjs.isObject.call(void 0, input.metadata) ? { metadata: input.metadata } : {} | ||
| }; | ||
| } | ||
| function readHarnessMeta(input) { | ||
| if (!_chunkB6ZQIAK3js.isObject.call(void 0, input)) return void 0; | ||
| if (!_chunkSU6EHKJVjs.isObject.call(void 0, input)) return void 0; | ||
| return { | ||
| ...typeof input.name === "string" ? { name: input.name } : {}, | ||
| ..._chunkB6ZQIAK3js.isObject.call(void 0, input.run) ? { run: input.run } : {} | ||
| ..._chunkSU6EHKJVjs.isObject.call(void 0, input.run) ? { run: input.run } : {} | ||
| }; | ||
| } | ||
| function readToolCall(input) { | ||
| if (!_chunkB6ZQIAK3js.isObject.call(void 0, input)) return void 0; | ||
| if (!_chunkSU6EHKJVjs.isObject.call(void 0, input)) return void 0; | ||
| return input; | ||
@@ -382,6 +383,6 @@ } | ||
| if (error instanceof Error) { | ||
| _chunkB6ZQIAK3js.logError.call(void 0, span, error); | ||
| _chunkSU6EHKJVjs.logError.call(void 0, span, error); | ||
| return; | ||
| } | ||
| if (_chunkB6ZQIAK3js.isObject.call(void 0, error)) { | ||
| if (_chunkSU6EHKJVjs.isObject.call(void 0, error)) { | ||
| const message = typeof error.message === "string" ? error.message : void 0; | ||
@@ -398,6 +399,6 @@ const stack = typeof error.stack === "string" ? error.stack : void 0; | ||
| } | ||
| _chunkB6ZQIAK3js.logError.call(void 0, span, error); | ||
| _chunkSU6EHKJVjs.logError.call(void 0, span, error); | ||
| } | ||
| function formatErrorMessage(error) { | ||
| if (_chunkB6ZQIAK3js.isObject.call(void 0, error)) { | ||
| if (_chunkSU6EHKJVjs.isObject.call(void 0, error)) { | ||
| if (typeof error.message === "string") return error.message; | ||
@@ -404,0 +405,0 @@ if (typeof error.stack === "string") return error.stack; |
@@ -7,4 +7,4 @@ import { | ||
| summarizeAndFlush | ||
| } from "./chunk-RBXD2KYN.mjs"; | ||
| import "./chunk-36IPYKMG.mjs"; | ||
| } from "./chunk-XE5FS7QY.mjs"; | ||
| import "./chunk-7F6GCRHH.mjs"; | ||
@@ -26,2 +26,3 @@ // src/wrappers/vitest-evals/reporter.ts | ||
| } | ||
| options; | ||
| experiment; | ||
@@ -28,0 +29,0 @@ onInit(_vitest) { |
+3
-3
| { | ||
| "name": "braintrust", | ||
| "version": "3.23.1", | ||
| "version": "3.24.0", | ||
| "description": "SDK for integrating Braintrust", | ||
@@ -209,3 +209,3 @@ "repository": { | ||
| "typescript": "5.4.4", | ||
| "vite": "^6.4.3", | ||
| "vite": "^8.1.5", | ||
| "vite-tsconfig-paths": "^4.3.2", | ||
@@ -230,3 +230,3 @@ "vitest": "4.1.5", | ||
| "dotenv": "^16.4.5", | ||
| "esbuild": "0.28.0", | ||
| "esbuild": "0.28.1", | ||
| "esquery": "^1.7.0", | ||
@@ -233,0 +233,0 @@ "eventsource-parser": "^1.1.2", |
@@ -513,2 +513,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; }// util/db_fields.ts | ||
| } | ||
| toStr() { | ||
@@ -1071,2 +1072,3 @@ const jsonObj = { | ||
| } | ||
| toStr() { | ||
@@ -1308,2 +1310,4 @@ const jsonObj = { | ||
| } | ||
| }; | ||
@@ -1310,0 +1314,0 @@ function parseNoStrip(schema, input) { |
@@ -513,2 +513,3 @@ // util/db_fields.ts | ||
| } | ||
| data; | ||
| toStr() { | ||
@@ -1071,2 +1072,3 @@ const jsonObj = { | ||
| } | ||
| data; | ||
| toStr() { | ||
@@ -1308,2 +1310,4 @@ const jsonObj = { | ||
| } | ||
| key; | ||
| path; | ||
| }; | ||
@@ -1310,0 +1314,0 @@ function parseNoStrip(schema, input) { |
| import { | ||
| aiSDKConfigs, | ||
| anthropicConfigs, | ||
| bedrockRuntimeConfigs, | ||
| channel, | ||
| claudeAgentSDKConfigs, | ||
| cohereConfigs, | ||
| cursorSDKConfigs, | ||
| defineChannels, | ||
| genkitConfigs, | ||
| gitHubCopilotConfigs, | ||
| googleADKConfigs, | ||
| googleGenAIConfigs, | ||
| groqConfigs, | ||
| huggingFaceConfigs, | ||
| langSmithConfigs, | ||
| langchainConfigs, | ||
| mistralConfigs, | ||
| openAIAgentsCoreConfigs, | ||
| openAICodexConfigs, | ||
| openRouterAgentConfigs, | ||
| openRouterConfigs, | ||
| openaiConfigs, | ||
| piCodingAgentConfigs | ||
| } from "./chunk-YXLNSAMJ.mjs"; | ||
| import { | ||
| applySpecialCasePatch, | ||
| create | ||
| } from "./chunk-M6DLIJ2Z.mjs"; | ||
| // src/auto-instrumentations/bundler/plugin.ts | ||
| import { createUnplugin } from "unplugin"; | ||
| 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", | ||
| langsmith: "langsmith" | ||
| }; | ||
| 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: ["langsmith"], configs: langSmithConfigs }, | ||
| { 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 | ||
| }; |
| import { | ||
| unplugin | ||
| } from "./chunk-EXY7QCJD.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
| 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" | ||
| }), | ||
| workflowAgentStream: channel({ | ||
| channelName: "WorkflowAgent.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/langsmith-channels.ts | ||
| var langSmithChannels = defineChannels("langsmith", { | ||
| createRun: channel({ | ||
| channelName: "Client.createRun", | ||
| kind: "async" | ||
| }), | ||
| updateRun: channel({ | ||
| channelName: "Client.updateRun", | ||
| kind: "async" | ||
| }), | ||
| batchIngestRuns: channel({ | ||
| channelName: "Client.batchIngestRuns", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // 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", | ||
| langsmith: "langsmith" | ||
| }; | ||
| 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, | ||
| langsmith: 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, | ||
| langSmithChannels, | ||
| piCodingAgentChannels, | ||
| strandsAgentSDKChannels, | ||
| getDefaultInstrumentationIntegrations, | ||
| readDisabledInstrumentationEnvConfig, | ||
| isInstrumentationIntegrationDisabled, | ||
| installMastraExporterFactory, | ||
| classifyMastraTarget, | ||
| patchMastraSource | ||
| }; |
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" | ||
| }), | ||
| workflowAgentStream: channel({ | ||
| channelName: "WorkflowAgent.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/langsmith-channels.ts | ||
| var langSmithChannels = defineChannels("langsmith", { | ||
| createRun: channel({ | ||
| channelName: "Client.createRun", | ||
| kind: "async" | ||
| }), | ||
| updateRun: channel({ | ||
| channelName: "Client.updateRun", | ||
| kind: "async" | ||
| }), | ||
| batchIngestRuns: channel({ | ||
| channelName: "Client.batchIngestRuns", | ||
| kind: "async" | ||
| }) | ||
| }); | ||
| // 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", | ||
| langsmith: "langsmith" | ||
| }; | ||
| 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, | ||
| langsmith: 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.langSmithChannels = langSmithChannels; 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
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
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 8 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 7 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
28628605
0.94%693670
1.16%65
1.56%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated