braintrust 3.24.0 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/NOTICE +6 -0
  2. package/dev/dist/index.d.mts +135 -2
  3. package/dev/dist/index.d.ts +135 -2
  4. package/dev/dist/index.js +4426 -2040
  5. package/dev/dist/index.mjs +3594 -1208
  6. package/dist/apply-auto-instrumentation.js +445 -403
  7. package/dist/apply-auto-instrumentation.mjs +249 -207
  8. package/dist/auto-instrumentations/bundler/esbuild.cjs +1449 -799
  9. package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
  10. package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
  11. package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -8
  12. package/dist/auto-instrumentations/bundler/next.cjs +1448 -818
  13. package/dist/auto-instrumentations/bundler/next.mjs +6 -29
  14. package/dist/auto-instrumentations/bundler/rollup.cjs +1449 -799
  15. package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
  16. package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
  17. package/dist/auto-instrumentations/bundler/rollup.mjs +5 -8
  18. package/dist/auto-instrumentations/bundler/vite.cjs +1449 -799
  19. package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
  20. package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
  21. package/dist/auto-instrumentations/bundler/vite.mjs +5 -8
  22. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1602 -728
  23. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
  24. package/dist/auto-instrumentations/bundler/webpack.cjs +1449 -799
  25. package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
  26. package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
  27. package/dist/auto-instrumentations/bundler/webpack.mjs +5 -4
  28. package/dist/auto-instrumentations/{chunk-GSZHTAQW.mjs → chunk-6E22MYSW.mjs} +194 -93
  29. package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
  30. package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
  31. package/dist/auto-instrumentations/{chunk-BURMPO7L.mjs → chunk-V5LEODRX.mjs} +2 -6
  32. package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
  33. package/dist/auto-instrumentations/{chunk-F43DNLPD.mjs → chunk-XZHHE4Y3.mjs} +646 -510
  34. package/dist/auto-instrumentations/hook.mjs +894 -657
  35. package/dist/auto-instrumentations/index.cjs +1125 -490
  36. package/dist/auto-instrumentations/index.d.mts +6 -2
  37. package/dist/auto-instrumentations/index.d.ts +6 -2
  38. package/dist/auto-instrumentations/index.mjs +6 -1
  39. package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
  40. package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
  41. package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
  42. package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
  43. package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
  44. package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
  45. package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
  46. package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
  47. package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
  48. package/dist/browser.d.mts +824 -197
  49. package/dist/browser.d.ts +824 -197
  50. package/dist/browser.js +3897 -1228
  51. package/dist/browser.mjs +3897 -1228
  52. package/dist/chunk-PN7EWK66.mjs +1784 -0
  53. package/dist/{chunk-SU6EHKJV.js → chunk-VRZZQPAA.js} +3289 -1577
  54. package/dist/chunk-VYNNEKSA.js +1784 -0
  55. package/dist/{chunk-XE5FS7QY.mjs → chunk-XIZOM2HO.mjs} +2470 -758
  56. package/dist/cli.js +3596 -1211
  57. package/dist/edge-light.d.mts +1 -1
  58. package/dist/edge-light.d.ts +1 -1
  59. package/dist/edge-light.js +3897 -1231
  60. package/dist/edge-light.mjs +3897 -1231
  61. package/dist/index.d.mts +824 -197
  62. package/dist/index.d.ts +824 -197
  63. package/dist/index.js +750 -445
  64. package/dist/index.mjs +334 -29
  65. package/dist/instrumentation/index.d.mts +135 -6
  66. package/dist/instrumentation/index.d.ts +135 -6
  67. package/dist/instrumentation/index.js +3696 -1257
  68. package/dist/instrumentation/index.mjs +3696 -1257
  69. package/dist/vitest-evals-reporter.js +16 -16
  70. package/dist/vitest-evals-reporter.mjs +2 -2
  71. package/dist/workerd.d.mts +1 -1
  72. package/dist/workerd.d.ts +1 -1
  73. package/dist/workerd.js +3897 -1231
  74. package/dist/workerd.mjs +3897 -1231
  75. package/licenses/node-diagnostics-channel/LICENSE +19 -0
  76. package/package.json +34 -35
  77. package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
  78. package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
  79. package/dist/chunk-7AUY2XWX.js +0 -1090
  80. package/dist/chunk-7F6GCRHH.mjs +0 -1090
package/dist/index.mjs CHANGED
@@ -91,6 +91,7 @@ import {
91
91
  initExperiment,
92
92
  initLogger,
93
93
  injectTraceContext,
94
+ instrumentCloudflareAIChatAgent,
94
95
  isEmpty,
95
96
  isObject,
96
97
  isTemplateFormat,
@@ -139,13 +140,15 @@ import {
139
140
  wrapMastraAgent,
140
141
  wrapTraced,
141
142
  zodToJsonSchema
142
- } from "./chunk-XE5FS7QY.mjs";
143
+ } from "./chunk-XIZOM2HO.mjs";
143
144
  import {
145
+ INSTRUMENTATION_NAMES,
144
146
  __export,
145
147
  aiSDKChannels,
146
148
  anthropicChannels,
147
149
  bedrockRuntimeChannels,
148
150
  claudeAgentSDKChannels,
151
+ cloudflareAgentsChannels,
149
152
  cohereChannels,
150
153
  cursorSDKChannels,
151
154
  genkitChannels,
@@ -155,6 +158,8 @@ import {
155
158
  groqChannels,
156
159
  harnessAgentChannels,
157
160
  huggingFaceChannels,
161
+ huggingFaceTransformersChannels,
162
+ isSupportedHuggingFaceTransformersTask,
158
163
  isomorph_default,
159
164
  langSmithChannels,
160
165
  mistralChannels,
@@ -163,8 +168,9 @@ import {
163
168
  openRouterAgentChannels,
164
169
  openRouterChannels,
165
170
  piCodingAgentChannels,
166
- strandsAgentSDKChannels
167
- } from "./chunk-7F6GCRHH.mjs";
171
+ strandsAgentSDKChannels,
172
+ withSpanInstrumentationName
173
+ } from "./chunk-PN7EWK66.mjs";
168
174
 
169
175
  // src/exports.ts
170
176
  var exports_exports = {};
@@ -315,6 +321,8 @@ __export(exports_exports, {
315
321
  wrapAnthropic: () => wrapAnthropic,
316
322
  wrapBedrockRuntime: () => wrapBedrockRuntime,
317
323
  wrapClaudeAgentSDK: () => wrapClaudeAgentSDK,
324
+ wrapCloudflareAIChat: () => wrapCloudflareAIChat,
325
+ wrapCloudflareAgent: () => wrapCloudflareAgent,
318
326
  wrapCohere: () => wrapCohere,
319
327
  wrapCopilotClient: () => wrapCopilotClient,
320
328
  wrapCursorSDK: () => wrapCursorSDK,
@@ -323,6 +331,7 @@ __export(exports_exports, {
323
331
  wrapGoogleGenAI: () => wrapGoogleGenAI,
324
332
  wrapGroq: () => wrapGroq,
325
333
  wrapHuggingFace: () => wrapHuggingFace,
334
+ wrapHuggingFaceTransformers: () => wrapHuggingFaceTransformers,
326
335
  wrapLangSmithClient: () => wrapLangSmithClient,
327
336
  wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
328
337
  wrapLangSmithTraceable: () => wrapLangSmithTraceable,
@@ -941,6 +950,12 @@ var wrapAgentClass = (AgentClass, options = {}) => {
941
950
  const original = Reflect.get(instanceTarget, prop, instanceTarget);
942
951
  if (harnessAgent && typeof original === "function") {
943
952
  switch (prop) {
953
+ case "createSession":
954
+ return wrapHarnessAgentCreateSession(
955
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
956
+ original,
957
+ harnessAgent
958
+ );
944
959
  case "generate":
945
960
  return wrapHarnessAgentGenerate(
946
961
  original,
@@ -990,6 +1005,19 @@ var wrapAgentClass = (AgentClass, options = {}) => {
990
1005
  }
991
1006
  });
992
1007
  };
1008
+ var wrapHarnessAgentCreateSession = (createSession, instance) => {
1009
+ const wrapper = function(params) {
1010
+ return harnessAgentChannels.createSession.tracePromise(
1011
+ () => params === void 0 ? createSession.call(instance) : createSession.call(instance, params),
1012
+ createAISDKChannelContext(params ?? {}, { self: instance })
1013
+ );
1014
+ };
1015
+ Object.defineProperty(wrapper, "name", {
1016
+ value: "HarnessAgent.createSession",
1017
+ writable: false
1018
+ });
1019
+ return wrapper;
1020
+ };
993
1021
  var wrapHarnessAgentGenerate = (generate, instance, channel, name, options) => makeGenerateTextWrapper(
994
1022
  channel,
995
1023
  name,
@@ -1259,12 +1287,17 @@ var BraintrustLanguageModelWrapper = class {
1259
1287
  // For the first cut, do not support custom span_info arguments. We can
1260
1288
  // propagate those via async local storage
1261
1289
  async doGenerate(options) {
1262
- const span = startSpan({
1263
- name: "Chat Completion",
1264
- spanAttributes: {
1265
- type: "llm"
1266
- }
1267
- });
1290
+ const span = startSpan(
1291
+ withSpanInstrumentationName(
1292
+ {
1293
+ name: "Chat Completion",
1294
+ spanAttributes: {
1295
+ type: "llm"
1296
+ }
1297
+ },
1298
+ INSTRUMENTATION_NAMES.AI_SDK
1299
+ )
1300
+ );
1268
1301
  const { prompt, mode, ...rest } = options;
1269
1302
  const startTime = getCurrentUnixTimestamp();
1270
1303
  try {
@@ -1295,12 +1328,17 @@ var BraintrustLanguageModelWrapper = class {
1295
1328
  async doStream(options) {
1296
1329
  const { prompt, mode, ...rest } = options;
1297
1330
  const startTime = getCurrentUnixTimestamp();
1298
- const span = startSpan({
1299
- name: "Chat Completion",
1300
- spanAttributes: {
1301
- type: "llm"
1302
- }
1303
- });
1331
+ const span = startSpan(
1332
+ withSpanInstrumentationName(
1333
+ {
1334
+ name: "Chat Completion",
1335
+ spanAttributes: {
1336
+ type: "llm"
1337
+ }
1338
+ },
1339
+ INSTRUMENTATION_NAMES.AI_SDK
1340
+ )
1341
+ );
1304
1342
  span.log({
1305
1343
  input: postProcessPrompt(prompt),
1306
1344
  metadata: {
@@ -1655,7 +1693,9 @@ function BraintrustMiddleware(config = {}) {
1655
1693
  }
1656
1694
  }
1657
1695
  };
1658
- const span = startSpan(spanArgs);
1696
+ const span = startSpan(
1697
+ withSpanInstrumentationName(spanArgs, INSTRUMENTATION_NAMES.AI_SDK)
1698
+ );
1659
1699
  try {
1660
1700
  const result = await doGenerate();
1661
1701
  const metadata = {};
@@ -1717,7 +1757,9 @@ function BraintrustMiddleware(config = {}) {
1717
1757
  }
1718
1758
  }
1719
1759
  };
1720
- const span = startSpan(spanArgs);
1760
+ const span = startSpan(
1761
+ withSpanInstrumentationName(spanArgs, INSTRUMENTATION_NAMES.AI_SDK)
1762
+ );
1721
1763
  try {
1722
1764
  const { stream, ...rest } = await doStream();
1723
1765
  const textChunks = [];
@@ -1924,7 +1966,12 @@ var EveBridge = class {
1924
1966
  };
1925
1967
  const span = withCurrent(
1926
1968
  NOOP_SPAN,
1927
- () => _internalStartSpanWithInitialMerge({ ...args, startTime })
1969
+ () => _internalStartSpanWithInitialMerge(
1970
+ withSpanInstrumentationName(
1971
+ { ...args, startTime },
1972
+ INSTRUMENTATION_NAMES.EVE
1973
+ )
1974
+ )
1928
1975
  );
1929
1976
  if (typeof rowId !== "string") {
1930
1977
  return span;
@@ -3996,6 +4043,67 @@ function patchAgentSessionClass(AgentSession) {
3996
4043
  });
3997
4044
  }
3998
4045
 
4046
+ // src/wrappers/cloudflare-agent.ts
4047
+ var WRAPPED_RUN_AGENT_TOOL = /* @__PURE__ */ Symbol.for(
4048
+ "braintrust.cloudflare-agents.wrapped-run-agent-tool"
4049
+ );
4050
+ function wrapCloudflareAgent(Agent) {
4051
+ if (typeof Agent !== "function") {
4052
+ warnUnsupportedAgent();
4053
+ return Agent;
4054
+ }
4055
+ const prototypeDescriptor = Object.getOwnPropertyDescriptor(
4056
+ Agent,
4057
+ "prototype"
4058
+ );
4059
+ const prototype = prototypeDescriptor && "value" in prototypeDescriptor ? prototypeDescriptor.value : void 0;
4060
+ if (!isObjectLike(prototype)) {
4061
+ warnUnsupportedAgent();
4062
+ return Agent;
4063
+ }
4064
+ if (ownValue(prototype, WRAPPED_RUN_AGENT_TOOL) === true) {
4065
+ return Agent;
4066
+ }
4067
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, "runAgentTool");
4068
+ if (!descriptor || typeof descriptor.value !== "function") {
4069
+ warnUnsupportedAgent();
4070
+ return Agent;
4071
+ }
4072
+ const originalRunAgentTool = descriptor.value;
4073
+ Object.defineProperty(prototype, "runAgentTool", {
4074
+ ...descriptor,
4075
+ value: function wrappedRunAgentTool(...args) {
4076
+ const options = args[1];
4077
+ if (ownValue(options, "detached")) {
4078
+ return Reflect.apply(originalRunAgentTool, this, args);
4079
+ }
4080
+ return cloudflareAgentsChannels.runAgentTool.tracePromise(
4081
+ () => Reflect.apply(originalRunAgentTool, this, args),
4082
+ { arguments: args, self: this }
4083
+ );
4084
+ }
4085
+ });
4086
+ Object.defineProperty(prototype, WRAPPED_RUN_AGENT_TOOL, {
4087
+ configurable: false,
4088
+ enumerable: false,
4089
+ value: true
4090
+ });
4091
+ return Agent;
4092
+ }
4093
+ function ownValue(value, key) {
4094
+ if (!isObjectLike(value)) {
4095
+ return void 0;
4096
+ }
4097
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
4098
+ return descriptor && "value" in descriptor ? descriptor.value : void 0;
4099
+ }
4100
+ function isObjectLike(value) {
4101
+ return typeof value === "object" && value !== null || typeof value === "function";
4102
+ }
4103
+ function warnUnsupportedAgent() {
4104
+ debugLogger.warn("Unsupported Cloudflare Agents Agent class. Not wrapping.");
4105
+ }
4106
+
3999
4107
  // src/wrappers/strands-agent-sdk.ts
4000
4108
  var WRAPPED_CLASS = /* @__PURE__ */ Symbol.for("braintrust.strands-agent-sdk.wrapped-class");
4001
4109
  var WRAPPED_INSTANCE = /* @__PURE__ */ Symbol.for(
@@ -4164,6 +4272,81 @@ async function consumeAsyncGenerator(generator) {
4164
4272
  return result.value;
4165
4273
  }
4166
4274
 
4275
+ // src/wrappers/cloudflare-ai-chat.ts
4276
+ var wrappedClasses = /* @__PURE__ */ new WeakMap();
4277
+ function wrapCloudflareAIChat(module) {
4278
+ if (!module || typeof module !== "object") {
4279
+ return module;
4280
+ }
4281
+ const candidate = module;
4282
+ let AIChatAgent;
4283
+ try {
4284
+ AIChatAgent = Reflect.get(candidate, "AIChatAgent");
4285
+ } catch (error) {
4286
+ debugLogger.debug("Failed to inspect @cloudflare/ai-chat module:", error);
4287
+ return module;
4288
+ }
4289
+ if (typeof AIChatAgent !== "function") {
4290
+ debugLogger.warn(
4291
+ "Unsupported @cloudflare/ai-chat module. AIChatAgent was not found; not wrapping."
4292
+ );
4293
+ return module;
4294
+ }
4295
+ const target = isModuleNamespace5(module) ? Object.setPrototypeOf({}, module) : candidate;
4296
+ return new Proxy(target, {
4297
+ get(target2, property, receiver) {
4298
+ const value = Reflect.get(target2, property, receiver);
4299
+ if (property === "AIChatAgent" && typeof value === "function") {
4300
+ return wrapAIChatAgentClass(
4301
+ value
4302
+ );
4303
+ }
4304
+ return value;
4305
+ }
4306
+ });
4307
+ }
4308
+ function wrapAIChatAgentClass(AgentClass) {
4309
+ const cached = wrappedClasses.get(AgentClass);
4310
+ if (cached) {
4311
+ return cached;
4312
+ }
4313
+ const wrapped = new Proxy(AgentClass, {
4314
+ get(target, property) {
4315
+ const value = Reflect.get(target, property, target);
4316
+ return typeof value === "function" ? value.bind(target) : value;
4317
+ },
4318
+ construct(target, args, newTarget) {
4319
+ const instance = Reflect.construct(
4320
+ target,
4321
+ args,
4322
+ newTarget
4323
+ );
4324
+ return instrumentCloudflareAIChatAgent(instance);
4325
+ }
4326
+ });
4327
+ wrappedClasses.set(AgentClass, wrapped);
4328
+ wrappedClasses.set(wrapped, wrapped);
4329
+ return wrapped;
4330
+ }
4331
+ function isModuleNamespace5(value) {
4332
+ if (!value || typeof value !== "object") {
4333
+ return false;
4334
+ }
4335
+ try {
4336
+ if (Reflect.get(value, Symbol.toStringTag) === "Module") {
4337
+ return true;
4338
+ }
4339
+ const keys = Object.keys(value);
4340
+ if (keys.length === 0) {
4341
+ return false;
4342
+ }
4343
+ const descriptor = Object.getOwnPropertyDescriptor(value, keys[0]);
4344
+ return descriptor ? !descriptor.configurable && !descriptor.writable : false;
4345
+ } catch {
4346
+ return false;
4347
+ }
4348
+ }
4349
+
4167
4350
  // src/wrappers/google-genai.ts
4168
4351
  function wrapGoogleGenAI(googleGenAI) {
4169
4352
  if (!googleGenAI || typeof googleGenAI !== "object") {
@@ -4816,6 +4999,120 @@ function wrapFeatureExtraction(original, endpointUrl) {
4816
4999
  };
4817
5000
  }
4818
5001
 
5002
+ // src/wrappers/huggingface-transformers.ts
5003
+ var PIPELINE_CONSTRUCTOR_KEYS = /* @__PURE__ */ new Set([
5004
+ "TextGenerationPipeline",
5005
+ "Text2TextGenerationPipeline",
5006
+ "SummarizationPipeline",
5007
+ "FeatureExtractionPipeline",
5008
+ "QuestionAnsweringPipeline"
5009
+ ]);
5010
+ var wrappedValues = /* @__PURE__ */ new WeakMap();
5011
+ function wrapHuggingFaceTransformers(transformers) {
5012
+ const pipelineTask = transformers?.task;
5013
+ if (typeof transformers === "function" && isSupportedHuggingFaceTransformersTask(pipelineTask)) {
5014
+ return wrapPipeline(transformers);
5015
+ }
5016
+ if (!isSupportedModule(transformers)) {
5017
+ return transformers;
5018
+ }
5019
+ const existing = wrappedValues.get(transformers);
5020
+ if (existing) {
5021
+ return existing;
5022
+ }
5023
+ const proxy = new Proxy(Object.create(transformers), {
5024
+ get(_target, property, receiver) {
5025
+ const value = Reflect.get(transformers, property, receiver);
5026
+ if (property === "pipeline" && typeof value === "function") {
5027
+ return wrapPipelineFactory(value);
5028
+ }
5029
+ if (typeof property === "string" && PIPELINE_CONSTRUCTOR_KEYS.has(property) && typeof value === "function") {
5030
+ return wrapPipelineConstructor(
5031
+ value
5032
+ );
5033
+ }
5034
+ return value;
5035
+ }
5036
+ });
5037
+ wrappedValues.set(transformers, proxy);
5038
+ wrappedValues.set(proxy, proxy);
5039
+ return proxy;
5040
+ }
5041
+ function isSupportedModule(value) {
5042
+ if (value === null || typeof value !== "object" && typeof value !== "function") {
5043
+ return false;
5044
+ }
5045
+ if (typeof Reflect.get(value, "pipeline") === "function") {
5046
+ return true;
5047
+ }
5048
+ for (const key of PIPELINE_CONSTRUCTOR_KEYS) {
5049
+ if (typeof Reflect.get(value, key) === "function") {
5050
+ return true;
5051
+ }
5052
+ }
5053
+ return false;
5054
+ }
5055
+ function wrapPipelineFactory(factory) {
5056
+ const existing = wrappedValues.get(factory);
5057
+ if (existing) {
5058
+ return existing;
5059
+ }
5060
+ const wrapped = function(...args) {
5061
+ const [task] = args;
5062
+ const context = {
5063
+ arguments: args
5064
+ };
5065
+ return huggingFaceTransformersChannels.pipeline.tracePromise(() => Reflect.apply(factory, this, args), context).then((pipeline) => {
5066
+ if (isSupportedHuggingFaceTransformersTask(pipeline.task ?? task)) {
5067
+ return wrapPipeline(pipeline);
5068
+ }
5069
+ return pipeline;
5070
+ });
5071
+ };
5072
+ wrappedValues.set(factory, wrapped);
5073
+ wrappedValues.set(wrapped, wrapped);
5074
+ return wrapped;
5075
+ }
5076
+ function wrapPipelineConstructor(constructor) {
5077
+ const existing = wrappedValues.get(constructor);
5078
+ if (existing) {
5079
+ return existing;
5080
+ }
5081
+ const proxy = new Proxy(constructor, {
5082
+ construct(target, args, newTarget) {
5083
+ const pipeline = Reflect.construct(target, args, newTarget);
5084
+ if (isSupportedHuggingFaceTransformersTask(pipeline.task)) {
5085
+ return wrapPipeline(pipeline);
5086
+ }
5087
+ return pipeline;
5088
+ }
5089
+ });
5090
+ wrappedValues.set(constructor, proxy);
5091
+ wrappedValues.set(proxy, proxy);
5092
+ return proxy;
5093
+ }
5094
+ function wrapPipeline(pipeline) {
5095
+ const existing = wrappedValues.get(pipeline);
5096
+ if (existing) {
5097
+ return existing;
5098
+ }
5099
+ const proxy = new Proxy(pipeline, {
5100
+ apply(target, thisArg, args) {
5101
+ const context = {
5102
+ arguments: args,
5103
+ self: target
5104
+ };
5105
+ return huggingFaceTransformersChannels.pipelineCall.tracePromise(
5106
+ () => Reflect.apply(target, thisArg, args),
5107
+ context
5108
+ );
5109
+ }
5110
+ });
5111
+ wrappedValues.set(pipeline, proxy);
5112
+ wrappedValues.set(proxy, proxy);
5113
+ return proxy;
5114
+ }
5115
+
4819
5116
  // src/wrappers/openrouter-agent.ts
4820
5117
  function wrapOpenRouterAgent(agent) {
4821
5118
  const candidate = agent;
@@ -5532,7 +5829,7 @@ function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
5532
5829
  );
5533
5830
  return namespace;
5534
5831
  }
5535
- const target = isModuleNamespace5(namespace) ? Object.setPrototypeOf({}, namespace) : candidate;
5832
+ const target = isModuleNamespace6(namespace) ? Object.setPrototypeOf({}, namespace) : candidate;
5536
5833
  const moduleNamespace = target !== candidate;
5537
5834
  let wrappedExport;
5538
5835
  return new Proxy(target, {
@@ -5566,7 +5863,7 @@ function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
5566
5863
  }
5567
5864
  });
5568
5865
  }
5569
- function isModuleNamespace5(value) {
5866
+ function isModuleNamespace6(value) {
5570
5867
  if (!value || typeof value !== "object") {
5571
5868
  return false;
5572
5869
  }
@@ -8836,26 +9133,30 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8836
9133
  }
8837
9134
  }
8838
9135
  })();
9136
+ let timeoutId;
9137
+ let abortHandler;
9138
+ const cleanupCancellation = () => {
9139
+ if (timeoutId !== void 0) {
9140
+ clearTimeout(timeoutId);
9141
+ timeoutId = void 0;
9142
+ }
9143
+ if (abortHandler && evaluator.signal) {
9144
+ evaluator.signal.removeEventListener("abort", abortHandler);
9145
+ abortHandler = void 0;
9146
+ }
9147
+ };
8839
9148
  const cancel = async () => {
8840
9149
  await new Promise((_, reject2) => {
8841
9150
  if (cancelled) {
8842
9151
  reject2(new InternalAbortError("Evaluator already cancelled"));
8843
9152
  return;
8844
9153
  }
8845
- let timeoutId;
8846
- let abortHandler;
8847
9154
  const rejectOnce = (error) => {
8848
9155
  if (cancelled) {
8849
9156
  return;
8850
9157
  }
8851
9158
  cancelled = true;
8852
- if (timeoutId) {
8853
- clearTimeout(timeoutId);
8854
- timeoutId = void 0;
8855
- }
8856
- if (abortHandler && evaluator.signal) {
8857
- evaluator.signal.removeEventListener("abort", abortHandler);
8858
- }
9159
+ cleanupCancellation();
8859
9160
  reject2(error);
8860
9161
  };
8861
9162
  if (evaluator.timeout) {
@@ -8895,6 +9196,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8895
9196
  }
8896
9197
  throw e;
8897
9198
  } finally {
9199
+ cleanupCancellation();
8898
9200
  if (!collectResults) {
8899
9201
  collectedResults.length = 0;
8900
9202
  }
@@ -10158,6 +10460,8 @@ export {
10158
10460
  wrapAnthropic,
10159
10461
  wrapBedrockRuntime,
10160
10462
  wrapClaudeAgentSDK,
10463
+ wrapCloudflareAIChat,
10464
+ wrapCloudflareAgent,
10161
10465
  wrapCohere,
10162
10466
  wrapCopilotClient,
10163
10467
  wrapCursorSDK,
@@ -10166,6 +10470,7 @@ export {
10166
10470
  wrapGoogleGenAI,
10167
10471
  wrapGroq,
10168
10472
  wrapHuggingFace,
10473
+ wrapHuggingFaceTransformers,
10169
10474
  wrapLangSmithClient,
10170
10475
  wrapLangSmithRunTrees,
10171
10476
  wrapLangSmithTraceable,