braintrust 3.25.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.
- package/NOTICE +6 -0
- package/dev/dist/index.d.mts +130 -2
- package/dev/dist/index.d.ts +130 -2
- package/dev/dist/index.js +2455 -1116
- package/dev/dist/index.mjs +1599 -260
- package/dist/apply-auto-instrumentation.js +439 -398
- package/dist/apply-auto-instrumentation.mjs +242 -201
- package/dist/auto-instrumentations/bundler/esbuild.cjs +853 -337
- package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -8
- package/dist/auto-instrumentations/bundler/next.cjs +852 -356
- package/dist/auto-instrumentations/bundler/next.mjs +6 -29
- package/dist/auto-instrumentations/bundler/rollup.cjs +853 -337
- package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.mjs +5 -8
- package/dist/auto-instrumentations/bundler/vite.cjs +853 -337
- package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/vite.mjs +5 -8
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1006 -266
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
- package/dist/auto-instrumentations/bundler/webpack.cjs +853 -337
- package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.mjs +5 -4
- package/dist/auto-instrumentations/{chunk-JPVCUKTY.mjs → chunk-6E22MYSW.mjs} +165 -73
- package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
- package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
- package/dist/auto-instrumentations/{chunk-7P6563SW.mjs → chunk-V5LEODRX.mjs} +2 -6
- package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
- package/dist/auto-instrumentations/{chunk-CZ24KNHT.mjs → chunk-XZHHE4Y3.mjs} +77 -68
- package/dist/auto-instrumentations/hook.mjs +247 -182
- package/dist/auto-instrumentations/index.cjs +557 -48
- package/dist/auto-instrumentations/index.d.mts +6 -2
- package/dist/auto-instrumentations/index.d.ts +6 -2
- package/dist/auto-instrumentations/index.mjs +6 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
- package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
- package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
- package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
- package/dist/browser.d.mts +817 -197
- package/dist/browser.d.ts +817 -197
- package/dist/browser.js +1883 -265
- package/dist/browser.mjs +1883 -265
- package/dist/{chunk-ABR2QWDP.mjs → chunk-PN7EWK66.mjs} +581 -133
- package/dist/{chunk-GSIDVFE6.js → chunk-VRZZQPAA.js} +1670 -736
- package/dist/{chunk-P25IOOU4.js → chunk-VYNNEKSA.js} +586 -138
- package/dist/{chunk-2SANLSWX.mjs → chunk-XIZOM2HO.mjs} +1052 -118
- package/dist/cli.js +1601 -263
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +1883 -268
- package/dist/edge-light.mjs +1883 -268
- package/dist/index.d.mts +817 -197
- package/dist/index.d.ts +817 -197
- package/dist/index.js +695 -435
- package/dist/index.mjs +264 -4
- package/dist/instrumentation/index.d.mts +130 -6
- package/dist/instrumentation/index.d.ts +130 -6
- package/dist/instrumentation/index.js +1510 -80
- package/dist/instrumentation/index.mjs +1510 -80
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +1883 -268
- package/dist/workerd.mjs +1883 -268
- package/licenses/node-diagnostics-channel/LICENSE +19 -0
- package/package.json +34 -35
- package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
- package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
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,7 +140,7 @@ import {
|
|
|
139
140
|
wrapMastraAgent,
|
|
140
141
|
wrapTraced,
|
|
141
142
|
zodToJsonSchema
|
|
142
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-XIZOM2HO.mjs";
|
|
143
144
|
import {
|
|
144
145
|
INSTRUMENTATION_NAMES,
|
|
145
146
|
__export,
|
|
@@ -147,6 +148,7 @@ import {
|
|
|
147
148
|
anthropicChannels,
|
|
148
149
|
bedrockRuntimeChannels,
|
|
149
150
|
claudeAgentSDKChannels,
|
|
151
|
+
cloudflareAgentsChannels,
|
|
150
152
|
cohereChannels,
|
|
151
153
|
cursorSDKChannels,
|
|
152
154
|
genkitChannels,
|
|
@@ -156,6 +158,8 @@ import {
|
|
|
156
158
|
groqChannels,
|
|
157
159
|
harnessAgentChannels,
|
|
158
160
|
huggingFaceChannels,
|
|
161
|
+
huggingFaceTransformersChannels,
|
|
162
|
+
isSupportedHuggingFaceTransformersTask,
|
|
159
163
|
isomorph_default,
|
|
160
164
|
langSmithChannels,
|
|
161
165
|
mistralChannels,
|
|
@@ -166,7 +170,7 @@ import {
|
|
|
166
170
|
piCodingAgentChannels,
|
|
167
171
|
strandsAgentSDKChannels,
|
|
168
172
|
withSpanInstrumentationName
|
|
169
|
-
} from "./chunk-
|
|
173
|
+
} from "./chunk-PN7EWK66.mjs";
|
|
170
174
|
|
|
171
175
|
// src/exports.ts
|
|
172
176
|
var exports_exports = {};
|
|
@@ -317,6 +321,8 @@ __export(exports_exports, {
|
|
|
317
321
|
wrapAnthropic: () => wrapAnthropic,
|
|
318
322
|
wrapBedrockRuntime: () => wrapBedrockRuntime,
|
|
319
323
|
wrapClaudeAgentSDK: () => wrapClaudeAgentSDK,
|
|
324
|
+
wrapCloudflareAIChat: () => wrapCloudflareAIChat,
|
|
325
|
+
wrapCloudflareAgent: () => wrapCloudflareAgent,
|
|
320
326
|
wrapCohere: () => wrapCohere,
|
|
321
327
|
wrapCopilotClient: () => wrapCopilotClient,
|
|
322
328
|
wrapCursorSDK: () => wrapCursorSDK,
|
|
@@ -325,6 +331,7 @@ __export(exports_exports, {
|
|
|
325
331
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
326
332
|
wrapGroq: () => wrapGroq,
|
|
327
333
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
334
|
+
wrapHuggingFaceTransformers: () => wrapHuggingFaceTransformers,
|
|
328
335
|
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
329
336
|
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
330
337
|
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
@@ -4036,6 +4043,67 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
4036
4043
|
});
|
|
4037
4044
|
}
|
|
4038
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
|
+
|
|
4039
4107
|
// src/wrappers/strands-agent-sdk.ts
|
|
4040
4108
|
var WRAPPED_CLASS = /* @__PURE__ */ Symbol.for("braintrust.strands-agent-sdk.wrapped-class");
|
|
4041
4109
|
var WRAPPED_INSTANCE = /* @__PURE__ */ Symbol.for(
|
|
@@ -4204,6 +4272,81 @@ async function consumeAsyncGenerator(generator) {
|
|
|
4204
4272
|
return result.value;
|
|
4205
4273
|
}
|
|
4206
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
|
+
|
|
4207
4350
|
// src/wrappers/google-genai.ts
|
|
4208
4351
|
function wrapGoogleGenAI(googleGenAI) {
|
|
4209
4352
|
if (!googleGenAI || typeof googleGenAI !== "object") {
|
|
@@ -4856,6 +4999,120 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
4856
4999
|
};
|
|
4857
5000
|
}
|
|
4858
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
|
+
|
|
4859
5116
|
// src/wrappers/openrouter-agent.ts
|
|
4860
5117
|
function wrapOpenRouterAgent(agent) {
|
|
4861
5118
|
const candidate = agent;
|
|
@@ -5572,7 +5829,7 @@ function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
|
|
|
5572
5829
|
);
|
|
5573
5830
|
return namespace;
|
|
5574
5831
|
}
|
|
5575
|
-
const target =
|
|
5832
|
+
const target = isModuleNamespace6(namespace) ? Object.setPrototypeOf({}, namespace) : candidate;
|
|
5576
5833
|
const moduleNamespace = target !== candidate;
|
|
5577
5834
|
let wrappedExport;
|
|
5578
5835
|
return new Proxy(target, {
|
|
@@ -5606,7 +5863,7 @@ function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
|
|
|
5606
5863
|
}
|
|
5607
5864
|
});
|
|
5608
5865
|
}
|
|
5609
|
-
function
|
|
5866
|
+
function isModuleNamespace6(value) {
|
|
5610
5867
|
if (!value || typeof value !== "object") {
|
|
5611
5868
|
return false;
|
|
5612
5869
|
}
|
|
@@ -10203,6 +10460,8 @@ export {
|
|
|
10203
10460
|
wrapAnthropic,
|
|
10204
10461
|
wrapBedrockRuntime,
|
|
10205
10462
|
wrapClaudeAgentSDK,
|
|
10463
|
+
wrapCloudflareAIChat,
|
|
10464
|
+
wrapCloudflareAgent,
|
|
10206
10465
|
wrapCohere,
|
|
10207
10466
|
wrapCopilotClient,
|
|
10208
10467
|
wrapCursorSDK,
|
|
@@ -10211,6 +10470,7 @@ export {
|
|
|
10211
10470
|
wrapGoogleGenAI,
|
|
10212
10471
|
wrapGroq,
|
|
10213
10472
|
wrapHuggingFace,
|
|
10473
|
+
wrapHuggingFaceTransformers,
|
|
10214
10474
|
wrapLangSmithClient,
|
|
10215
10475
|
wrapLangSmithRunTrees,
|
|
10216
10476
|
wrapLangSmithTraceable,
|
|
@@ -3044,6 +3044,7 @@ declare const PromptData: z.ZodObject<{
|
|
|
3044
3044
|
reasoning_budget: z.ZodOptional<z.ZodNumber>;
|
|
3045
3045
|
}, z.ZodTypeAny, "passthrough">>]>>;
|
|
3046
3046
|
position: z.ZodOptional<z.ZodString>;
|
|
3047
|
+
endpoint_name: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
3047
3048
|
}, "strip", z.ZodTypeAny, {
|
|
3048
3049
|
params?: z.objectOutputType<{
|
|
3049
3050
|
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -3164,6 +3165,7 @@ declare const PromptData: z.ZodObject<{
|
|
|
3164
3165
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
3165
3166
|
model?: string | undefined;
|
|
3166
3167
|
position?: string | undefined;
|
|
3168
|
+
endpoint_name?: string | null | undefined;
|
|
3167
3169
|
}, {
|
|
3168
3170
|
params?: z.objectInputType<{
|
|
3169
3171
|
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -3284,6 +3286,7 @@ declare const PromptData: z.ZodObject<{
|
|
|
3284
3286
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
3285
3287
|
model?: string | undefined;
|
|
3286
3288
|
position?: string | undefined;
|
|
3289
|
+
endpoint_name?: string | null | undefined;
|
|
3287
3290
|
}>, z.ZodNull]>>;
|
|
3288
3291
|
parser: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
3289
3292
|
type: z.ZodLiteral<"llm_classifier">;
|
|
@@ -3307,6 +3310,31 @@ declare const PromptData: z.ZodObject<{
|
|
|
3307
3310
|
allow_no_match?: boolean | undefined;
|
|
3308
3311
|
allow_skip?: boolean | undefined;
|
|
3309
3312
|
}>, z.ZodNull]>>;
|
|
3313
|
+
preprocessor: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
3314
|
+
type: z.ZodLiteral<"function">;
|
|
3315
|
+
id: z.ZodString;
|
|
3316
|
+
version: z.ZodOptional<z.ZodString>;
|
|
3317
|
+
}, "strip", z.ZodTypeAny, {
|
|
3318
|
+
type: "function";
|
|
3319
|
+
id: string;
|
|
3320
|
+
version?: string | undefined;
|
|
3321
|
+
}, {
|
|
3322
|
+
type: "function";
|
|
3323
|
+
id: string;
|
|
3324
|
+
version?: string | undefined;
|
|
3325
|
+
}>, z.ZodObject<{
|
|
3326
|
+
type: z.ZodLiteral<"global">;
|
|
3327
|
+
name: z.ZodString;
|
|
3328
|
+
function_type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"preprocessor">>>;
|
|
3329
|
+
}, "strip", z.ZodTypeAny, {
|
|
3330
|
+
type: "global";
|
|
3331
|
+
name: string;
|
|
3332
|
+
function_type: "preprocessor";
|
|
3333
|
+
}, {
|
|
3334
|
+
type: "global";
|
|
3335
|
+
name: string;
|
|
3336
|
+
function_type?: "preprocessor" | undefined;
|
|
3337
|
+
}>, z.ZodNull]>>;
|
|
3310
3338
|
tool_functions: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
3311
3339
|
type: z.ZodLiteral<"function">;
|
|
3312
3340
|
id: z.ZodString;
|
|
@@ -3498,6 +3526,7 @@ declare const PromptData: z.ZodObject<{
|
|
|
3498
3526
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
3499
3527
|
model?: string | undefined;
|
|
3500
3528
|
position?: string | undefined;
|
|
3529
|
+
endpoint_name?: string | null | undefined;
|
|
3501
3530
|
} | null | undefined;
|
|
3502
3531
|
prompt?: {
|
|
3503
3532
|
type: "chat";
|
|
@@ -3607,6 +3636,15 @@ declare const PromptData: z.ZodObject<{
|
|
|
3607
3636
|
type: "completion";
|
|
3608
3637
|
content: string;
|
|
3609
3638
|
} | null | undefined;
|
|
3639
|
+
preprocessor?: {
|
|
3640
|
+
type: "function";
|
|
3641
|
+
id: string;
|
|
3642
|
+
version?: string | undefined;
|
|
3643
|
+
} | {
|
|
3644
|
+
type: "global";
|
|
3645
|
+
name: string;
|
|
3646
|
+
function_type: "preprocessor";
|
|
3647
|
+
} | null | undefined;
|
|
3610
3648
|
origin?: {
|
|
3611
3649
|
project_id?: string | undefined;
|
|
3612
3650
|
prompt_id?: string | undefined;
|
|
@@ -3762,6 +3800,7 @@ declare const PromptData: z.ZodObject<{
|
|
|
3762
3800
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
3763
3801
|
model?: string | undefined;
|
|
3764
3802
|
position?: string | undefined;
|
|
3803
|
+
endpoint_name?: string | null | undefined;
|
|
3765
3804
|
} | null | undefined;
|
|
3766
3805
|
prompt?: {
|
|
3767
3806
|
type: "chat";
|
|
@@ -3871,6 +3910,15 @@ declare const PromptData: z.ZodObject<{
|
|
|
3871
3910
|
type: "completion";
|
|
3872
3911
|
content: string;
|
|
3873
3912
|
} | null | undefined;
|
|
3913
|
+
preprocessor?: {
|
|
3914
|
+
type: "function";
|
|
3915
|
+
id: string;
|
|
3916
|
+
version?: string | undefined;
|
|
3917
|
+
} | {
|
|
3918
|
+
type: "global";
|
|
3919
|
+
name: string;
|
|
3920
|
+
function_type?: "preprocessor" | undefined;
|
|
3921
|
+
} | null | undefined;
|
|
3874
3922
|
origin?: {
|
|
3875
3923
|
project_id?: string | undefined;
|
|
3876
3924
|
prompt_id?: string | undefined;
|
|
@@ -5023,6 +5071,7 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
5023
5071
|
reasoning_budget: z.ZodOptional<z.ZodNumber>;
|
|
5024
5072
|
}, z.ZodTypeAny, "passthrough">>]>>;
|
|
5025
5073
|
position: z.ZodOptional<z.ZodString>;
|
|
5074
|
+
endpoint_name: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
5026
5075
|
}, "strip", z.ZodTypeAny, {
|
|
5027
5076
|
params?: z.objectOutputType<{
|
|
5028
5077
|
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -5143,6 +5192,7 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
5143
5192
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
5144
5193
|
model?: string | undefined;
|
|
5145
5194
|
position?: string | undefined;
|
|
5195
|
+
endpoint_name?: string | null | undefined;
|
|
5146
5196
|
}, {
|
|
5147
5197
|
params?: z.objectInputType<{
|
|
5148
5198
|
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -5263,6 +5313,7 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
5263
5313
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
5264
5314
|
model?: string | undefined;
|
|
5265
5315
|
position?: string | undefined;
|
|
5316
|
+
endpoint_name?: string | null | undefined;
|
|
5266
5317
|
}>, z.ZodNull]>>;
|
|
5267
5318
|
parser: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
5268
5319
|
type: z.ZodLiteral<"llm_classifier">;
|
|
@@ -5286,6 +5337,31 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
5286
5337
|
allow_no_match?: boolean | undefined;
|
|
5287
5338
|
allow_skip?: boolean | undefined;
|
|
5288
5339
|
}>, z.ZodNull]>>;
|
|
5340
|
+
preprocessor: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
5341
|
+
type: z.ZodLiteral<"function">;
|
|
5342
|
+
id: z.ZodString;
|
|
5343
|
+
version: z.ZodOptional<z.ZodString>;
|
|
5344
|
+
}, "strip", z.ZodTypeAny, {
|
|
5345
|
+
type: "function";
|
|
5346
|
+
id: string;
|
|
5347
|
+
version?: string | undefined;
|
|
5348
|
+
}, {
|
|
5349
|
+
type: "function";
|
|
5350
|
+
id: string;
|
|
5351
|
+
version?: string | undefined;
|
|
5352
|
+
}>, z.ZodObject<{
|
|
5353
|
+
type: z.ZodLiteral<"global">;
|
|
5354
|
+
name: z.ZodString;
|
|
5355
|
+
function_type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"preprocessor">>>;
|
|
5356
|
+
}, "strip", z.ZodTypeAny, {
|
|
5357
|
+
type: "global";
|
|
5358
|
+
name: string;
|
|
5359
|
+
function_type: "preprocessor";
|
|
5360
|
+
}, {
|
|
5361
|
+
type: "global";
|
|
5362
|
+
name: string;
|
|
5363
|
+
function_type?: "preprocessor" | undefined;
|
|
5364
|
+
}>, z.ZodNull]>>;
|
|
5289
5365
|
tool_functions: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
5290
5366
|
type: z.ZodLiteral<"function">;
|
|
5291
5367
|
id: z.ZodString;
|
|
@@ -5477,6 +5553,7 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
5477
5553
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
5478
5554
|
model?: string | undefined;
|
|
5479
5555
|
position?: string | undefined;
|
|
5556
|
+
endpoint_name?: string | null | undefined;
|
|
5480
5557
|
} | null | undefined;
|
|
5481
5558
|
prompt?: {
|
|
5482
5559
|
type: "chat";
|
|
@@ -5586,6 +5663,15 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
5586
5663
|
type: "completion";
|
|
5587
5664
|
content: string;
|
|
5588
5665
|
} | null | undefined;
|
|
5666
|
+
preprocessor?: {
|
|
5667
|
+
type: "function";
|
|
5668
|
+
id: string;
|
|
5669
|
+
version?: string | undefined;
|
|
5670
|
+
} | {
|
|
5671
|
+
type: "global";
|
|
5672
|
+
name: string;
|
|
5673
|
+
function_type: "preprocessor";
|
|
5674
|
+
} | null | undefined;
|
|
5589
5675
|
origin?: {
|
|
5590
5676
|
project_id?: string | undefined;
|
|
5591
5677
|
prompt_id?: string | undefined;
|
|
@@ -5741,6 +5827,7 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
5741
5827
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
5742
5828
|
model?: string | undefined;
|
|
5743
5829
|
position?: string | undefined;
|
|
5830
|
+
endpoint_name?: string | null | undefined;
|
|
5744
5831
|
} | null | undefined;
|
|
5745
5832
|
prompt?: {
|
|
5746
5833
|
type: "chat";
|
|
@@ -5850,6 +5937,15 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
5850
5937
|
type: "completion";
|
|
5851
5938
|
content: string;
|
|
5852
5939
|
} | null | undefined;
|
|
5940
|
+
preprocessor?: {
|
|
5941
|
+
type: "function";
|
|
5942
|
+
id: string;
|
|
5943
|
+
version?: string | undefined;
|
|
5944
|
+
} | {
|
|
5945
|
+
type: "global";
|
|
5946
|
+
name: string;
|
|
5947
|
+
function_type?: "preprocessor" | undefined;
|
|
5948
|
+
} | null | undefined;
|
|
5853
5949
|
origin?: {
|
|
5854
5950
|
project_id?: string | undefined;
|
|
5855
5951
|
prompt_id?: string | undefined;
|
|
@@ -6022,6 +6118,7 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
6022
6118
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
6023
6119
|
model?: string | undefined;
|
|
6024
6120
|
position?: string | undefined;
|
|
6121
|
+
endpoint_name?: string | null | undefined;
|
|
6025
6122
|
} | null | undefined;
|
|
6026
6123
|
prompt?: {
|
|
6027
6124
|
type: "chat";
|
|
@@ -6131,6 +6228,15 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
6131
6228
|
type: "completion";
|
|
6132
6229
|
content: string;
|
|
6133
6230
|
} | null | undefined;
|
|
6231
|
+
preprocessor?: {
|
|
6232
|
+
type: "function";
|
|
6233
|
+
id: string;
|
|
6234
|
+
version?: string | undefined;
|
|
6235
|
+
} | {
|
|
6236
|
+
type: "global";
|
|
6237
|
+
name: string;
|
|
6238
|
+
function_type: "preprocessor";
|
|
6239
|
+
} | null | undefined;
|
|
6134
6240
|
origin?: {
|
|
6135
6241
|
project_id?: string | undefined;
|
|
6136
6242
|
prompt_id?: string | undefined;
|
|
@@ -6300,6 +6406,7 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
6300
6406
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
6301
6407
|
model?: string | undefined;
|
|
6302
6408
|
position?: string | undefined;
|
|
6409
|
+
endpoint_name?: string | null | undefined;
|
|
6303
6410
|
} | null | undefined;
|
|
6304
6411
|
prompt?: {
|
|
6305
6412
|
type: "chat";
|
|
@@ -6409,6 +6516,15 @@ declare const Prompt$1: z.ZodObject<{
|
|
|
6409
6516
|
type: "completion";
|
|
6410
6517
|
content: string;
|
|
6411
6518
|
} | null | undefined;
|
|
6519
|
+
preprocessor?: {
|
|
6520
|
+
type: "function";
|
|
6521
|
+
id: string;
|
|
6522
|
+
version?: string | undefined;
|
|
6523
|
+
} | {
|
|
6524
|
+
type: "global";
|
|
6525
|
+
name: string;
|
|
6526
|
+
function_type?: "preprocessor" | undefined;
|
|
6527
|
+
} | null | undefined;
|
|
6412
6528
|
origin?: {
|
|
6413
6529
|
project_id?: string | undefined;
|
|
6414
6530
|
prompt_id?: string | undefined;
|
|
@@ -6491,12 +6607,12 @@ declare const PromptSessionEvent: z.ZodObject<{
|
|
|
6491
6607
|
}>;
|
|
6492
6608
|
type PromptSessionEventType = z.infer<typeof PromptSessionEvent>;
|
|
6493
6609
|
|
|
6494
|
-
interface
|
|
6610
|
+
interface GlobalHookAsyncLocalStorage<T> {
|
|
6495
6611
|
enterWith(store: T): void;
|
|
6496
6612
|
run<R>(store: T | undefined, callback: () => R): R;
|
|
6497
6613
|
getStore(): T | undefined;
|
|
6498
6614
|
}
|
|
6499
|
-
interface
|
|
6615
|
+
interface GlobalHookHandlers<M = any> {
|
|
6500
6616
|
start?: (context: M, name: string) => void;
|
|
6501
6617
|
end?: (context: M, name: string) => void;
|
|
6502
6618
|
asyncStart?: (context: M, name: string) => void;
|
|
@@ -6504,10 +6620,13 @@ interface IsoChannelHandlers<M = any> {
|
|
|
6504
6620
|
error?: (context: M, name: string) => void;
|
|
6505
6621
|
}
|
|
6506
6622
|
|
|
6623
|
+
type IsoAsyncLocalStorage<T> = GlobalHookAsyncLocalStorage<T>;
|
|
6624
|
+
type IsoChannelHandlers<M = any> = GlobalHookHandlers<M>;
|
|
6625
|
+
|
|
6507
6626
|
/**
|
|
6508
6627
|
* Base class for creating instrumentation plugins.
|
|
6509
6628
|
*
|
|
6510
|
-
* Plugins subscribe to
|
|
6629
|
+
* Plugins subscribe to global instrumentation hook events and convert them
|
|
6511
6630
|
* into spans, logs, or other observability data.
|
|
6512
6631
|
*/
|
|
6513
6632
|
declare abstract class BasePlugin {
|
|
@@ -6593,7 +6712,7 @@ declare abstract class BasePlugin {
|
|
|
6593
6712
|
}
|
|
6594
6713
|
|
|
6595
6714
|
/**
|
|
6596
|
-
* Utilities for
|
|
6715
|
+
* Utilities for instrumentation hook naming and management.
|
|
6597
6716
|
*/
|
|
6598
6717
|
/**
|
|
6599
6718
|
* Channel naming convention: braintrust:{component}:{operation}
|
|
@@ -6692,7 +6811,7 @@ interface AsyncStartEvent<TInput = unknown> extends StartEvent<TInput> {
|
|
|
6692
6811
|
interface AsyncEndEvent<TResult = unknown> extends EndEvent<TResult> {
|
|
6693
6812
|
}
|
|
6694
6813
|
/**
|
|
6695
|
-
* Subscription handlers for a
|
|
6814
|
+
* Subscription handlers for a tracing-compatible global hook.
|
|
6696
6815
|
*
|
|
6697
6816
|
* Common usage pattern:
|
|
6698
6817
|
* - Use start to create spans and extract input
|
|
@@ -6737,6 +6856,7 @@ interface InstrumentationIntegrationsConfig {
|
|
|
6737
6856
|
googleADK?: boolean;
|
|
6738
6857
|
huggingface?: boolean;
|
|
6739
6858
|
claudeAgentSDK?: boolean;
|
|
6859
|
+
cloudflareAIChat?: boolean;
|
|
6740
6860
|
cursor?: boolean;
|
|
6741
6861
|
cursorSDK?: boolean;
|
|
6742
6862
|
flue?: boolean;
|
|
@@ -6755,6 +6875,7 @@ interface InstrumentationIntegrationsConfig {
|
|
|
6755
6875
|
openaiCodexSDK?: boolean;
|
|
6756
6876
|
piCodingAgent?: boolean;
|
|
6757
6877
|
strandsAgentSDK?: boolean;
|
|
6878
|
+
cloudflareAgents?: boolean;
|
|
6758
6879
|
langchain?: boolean;
|
|
6759
6880
|
langgraph?: boolean;
|
|
6760
6881
|
langsmith?: boolean;
|
|
@@ -6798,6 +6919,7 @@ declare class BraintrustPlugin extends BasePlugin {
|
|
|
6798
6919
|
private openAIAgentsPlugin;
|
|
6799
6920
|
private googleGenAIPlugin;
|
|
6800
6921
|
private huggingFacePlugin;
|
|
6922
|
+
private huggingFaceTransformersPlugin;
|
|
6801
6923
|
private openRouterPlugin;
|
|
6802
6924
|
private openRouterAgentPlugin;
|
|
6803
6925
|
private mistralPlugin;
|
|
@@ -6812,6 +6934,8 @@ declare class BraintrustPlugin extends BasePlugin {
|
|
|
6812
6934
|
private langSmithPlugin;
|
|
6813
6935
|
private piCodingAgentPlugin;
|
|
6814
6936
|
private strandsAgentSDKPlugin;
|
|
6937
|
+
private cloudflareAIChatPlugin;
|
|
6938
|
+
private cloudflareAgentsPlugin;
|
|
6815
6939
|
constructor(config?: BraintrustPluginConfig);
|
|
6816
6940
|
protected onEnable(): void;
|
|
6817
6941
|
protected onDisable(): void;
|
|
@@ -7844,7 +7968,7 @@ declare abstract class ContextManager {
|
|
|
7844
7968
|
abstract runInContext<R>(span: Span, callback: () => R): R;
|
|
7845
7969
|
abstract getCurrentSpan(): Span | undefined;
|
|
7846
7970
|
/**
|
|
7847
|
-
* Returns the value to store in the ALS bound to a
|
|
7971
|
+
* Returns the value to store in the ALS bound to a global hook's start event.
|
|
7848
7972
|
* In default mode this is the Span itself; in OTEL mode it is the OTEL Context
|
|
7849
7973
|
* containing the span so that OTEL's own ALS stores a proper Context object.
|
|
7850
7974
|
*/
|