braintrust 3.25.0 → 3.27.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 +4133 -1421
- package/dev/dist/index.mjs +3242 -530
- package/dist/apply-auto-instrumentation.js +526 -426
- package/dist/apply-auto-instrumentation.mjs +329 -229
- package/dist/auto-instrumentations/bundler/esbuild.cjs +1198 -364
- 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 +6 -8
- package/dist/auto-instrumentations/bundler/next.cjs +1227 -413
- package/dist/auto-instrumentations/bundler/next.mjs +7 -29
- package/dist/auto-instrumentations/bundler/rollup.cjs +1198 -364
- 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 +6 -8
- package/dist/auto-instrumentations/bundler/vite.cjs +1249 -387
- 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 +34 -8
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1368 -324
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
- package/dist/auto-instrumentations/bundler/webpack.cjs +1198 -364
- 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 +6 -4
- package/dist/auto-instrumentations/chunk-2AMDGD65.mjs +1396 -0
- package/dist/auto-instrumentations/{chunk-7P6563SW.mjs → chunk-BW33ULMW.mjs} +2 -6
- package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-I55G56ZL.mjs} +114 -221
- package/dist/auto-instrumentations/chunk-JPUFNW7X.mjs +649 -0
- package/dist/auto-instrumentations/{chunk-JPVCUKTY.mjs → chunk-XEYKUBLY.mjs} +191 -73
- package/dist/auto-instrumentations/{chunk-CZ24KNHT.mjs → chunk-ZNHTSSGI.mjs} +231 -69
- package/dist/auto-instrumentations/hook.mjs +406 -183
- package/dist/auto-instrumentations/index.cjs +853 -49
- package/dist/auto-instrumentations/index.d.mts +10 -2
- package/dist/auto-instrumentations/index.d.ts +10 -2
- package/dist/auto-instrumentations/index.mjs +10 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +566 -221
- 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 +871 -199
- package/dist/browser.d.ts +871 -199
- package/dist/browser.js +3737 -549
- package/dist/browser.mjs +3737 -549
- package/dist/{chunk-ABR2QWDP.mjs → chunk-CZM5JIQL.mjs} +788 -132
- package/dist/{chunk-P25IOOU4.js → chunk-MF7NU6BT.js} +795 -139
- package/dist/{chunk-GSIDVFE6.js → chunk-QRHGVBKU.js} +3580 -1463
- package/dist/{chunk-2SANLSWX.mjs → chunk-YKD22IMR.mjs} +2505 -388
- package/dist/cli.js +3244 -533
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +3737 -552
- package/dist/edge-light.mjs +3737 -552
- package/dist/index.d.mts +871 -199
- package/dist/index.d.ts +871 -199
- package/dist/index.js +893 -446
- package/dist/index.mjs +463 -16
- package/dist/instrumentation/index.d.mts +138 -6
- package/dist/instrumentation/index.d.ts +138 -6
- package/dist/instrumentation/index.js +3362 -559
- package/dist/instrumentation/index.mjs +3362 -559
- package/dist/vitest-evals-reporter.js +45 -43
- package/dist/vitest-evals-reporter.mjs +5 -3
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +3737 -552
- package/dist/workerd.mjs +3737 -552
- package/licenses/node-diagnostics-channel/LICENSE +19 -0
- package/package.json +34 -35
- package/dist/auto-instrumentations/chunk-VT6DDNKM.mjs +0 -856
- package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
- package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
|
@@ -24,6 +24,9 @@ __export(index_exports, {
|
|
|
24
24
|
anthropicConfigs: () => anthropicConfigs,
|
|
25
25
|
bedrockRuntimeConfigs: () => bedrockRuntimeConfigs,
|
|
26
26
|
claudeAgentSDKConfigs: () => claudeAgentSDKConfigs,
|
|
27
|
+
cloudflareAIChatConfigs: () => cloudflareAIChatConfigs,
|
|
28
|
+
cloudflareAgentsConfigs: () => cloudflareAgentsConfigs,
|
|
29
|
+
cloudflareThinkConfigs: () => cloudflareThinkConfigs,
|
|
27
30
|
cohereConfigs: () => cohereConfigs,
|
|
28
31
|
cursorSDKConfigs: () => cursorSDKConfigs,
|
|
29
32
|
genkitConfigs: () => genkitConfigs,
|
|
@@ -35,6 +38,7 @@ __export(index_exports, {
|
|
|
35
38
|
langSmithConfigs: () => langSmithConfigs,
|
|
36
39
|
langchainConfigs: () => langchainConfigs,
|
|
37
40
|
mistralConfigs: () => mistralConfigs,
|
|
41
|
+
ollamaConfigs: () => ollamaConfigs,
|
|
38
42
|
openAIAgentsCoreConfigs: () => openAIAgentsCoreConfigs,
|
|
39
43
|
openAICodexConfigs: () => openAICodexConfigs,
|
|
40
44
|
openRouterAgentConfigs: () => openRouterAgentConfigs,
|
|
@@ -44,84 +48,659 @@ __export(index_exports, {
|
|
|
44
48
|
});
|
|
45
49
|
module.exports = __toCommonJS(index_exports);
|
|
46
50
|
|
|
47
|
-
// src/
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
// src/global-instrumentation-hooks.ts
|
|
52
|
+
var GLOBAL_INSTRUMENTATION_HOOKS_KEY = "__braintrust_instrumentation_hooks";
|
|
53
|
+
var GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION = 1;
|
|
54
|
+
var GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND = "braintrust.global-instrumentation-hooks.registry";
|
|
55
|
+
var GLOBAL_INSTRUMENTATION_HOOK_BRAND = "braintrust.global-instrumentation-hooks.hook";
|
|
56
|
+
var GLOBAL_INVOCATION_HOOK_BRAND = "braintrust.global-instrumentation-hooks.invocation-hook";
|
|
57
|
+
var registryBrand = Symbol.for(GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND);
|
|
58
|
+
var hookBrand = Symbol.for(GLOBAL_INSTRUMENTATION_HOOK_BRAND);
|
|
59
|
+
var invocationHookBrand = Symbol.for(GLOBAL_INVOCATION_HOOK_BRAND);
|
|
60
|
+
var errorReporter;
|
|
61
|
+
function reportError(error) {
|
|
62
|
+
try {
|
|
63
|
+
errorReporter?.(error);
|
|
64
|
+
} catch {
|
|
55
65
|
}
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
}
|
|
67
|
+
function setContextValue(context, key, value) {
|
|
68
|
+
try {
|
|
69
|
+
context[key] = value;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
reportError(error);
|
|
58
72
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
73
|
+
}
|
|
74
|
+
function wrapStoreRun(store, message, next, transform) {
|
|
75
|
+
return () => {
|
|
76
|
+
let context;
|
|
77
|
+
try {
|
|
78
|
+
context = transform ? transform(message) : message;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
reportError(error);
|
|
81
|
+
return next();
|
|
82
|
+
}
|
|
83
|
+
let called = false;
|
|
84
|
+
let result;
|
|
85
|
+
let providerError;
|
|
86
|
+
let providerThrew = false;
|
|
87
|
+
const runNext = () => {
|
|
88
|
+
if (called) {
|
|
89
|
+
reportError(
|
|
90
|
+
new Error(
|
|
91
|
+
"Instrumentation store invoked its callback more than once"
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
if (providerThrew) {
|
|
95
|
+
throw providerError;
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
called = true;
|
|
100
|
+
try {
|
|
101
|
+
result = next();
|
|
102
|
+
return result;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
providerThrew = true;
|
|
105
|
+
providerError = error;
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
try {
|
|
110
|
+
store.run(context, runNext);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (!providerThrew || error !== providerError) {
|
|
113
|
+
reportError(error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!called) {
|
|
117
|
+
reportError(
|
|
118
|
+
new Error("Instrumentation store did not invoke its callback")
|
|
119
|
+
);
|
|
120
|
+
return runNext();
|
|
121
|
+
}
|
|
122
|
+
if (providerThrew) {
|
|
123
|
+
throw providerError;
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
var HookChannel = class {
|
|
61
129
|
constructor(name) {
|
|
62
130
|
this.name = name;
|
|
63
131
|
}
|
|
64
132
|
name;
|
|
65
|
-
|
|
66
|
-
|
|
133
|
+
subscribers = [];
|
|
134
|
+
stores = /* @__PURE__ */ new Map();
|
|
135
|
+
get hasSubscribers() {
|
|
136
|
+
return this.subscribers.length > 0 || this.stores.size > 0;
|
|
67
137
|
}
|
|
68
|
-
|
|
69
|
-
|
|
138
|
+
subscribe(subscription) {
|
|
139
|
+
if (typeof subscription !== "function") {
|
|
140
|
+
throw new TypeError("subscription must be a function");
|
|
141
|
+
}
|
|
142
|
+
this.subscribers = [...this.subscribers, subscription];
|
|
70
143
|
}
|
|
71
|
-
|
|
144
|
+
unsubscribe(subscription) {
|
|
145
|
+
const index = this.subscribers.indexOf(subscription);
|
|
146
|
+
if (index === -1) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
this.subscribers = [
|
|
150
|
+
...this.subscribers.slice(0, index),
|
|
151
|
+
...this.subscribers.slice(index + 1)
|
|
152
|
+
];
|
|
153
|
+
return true;
|
|
72
154
|
}
|
|
73
|
-
|
|
74
|
-
|
|
155
|
+
bindStore(store, transform) {
|
|
156
|
+
if (!store || typeof store.run !== "function") {
|
|
157
|
+
throw new TypeError("store must have a run method");
|
|
158
|
+
}
|
|
159
|
+
this.stores.set(
|
|
160
|
+
store,
|
|
161
|
+
transform
|
|
162
|
+
);
|
|
75
163
|
}
|
|
76
|
-
|
|
164
|
+
unbindStore(store) {
|
|
165
|
+
return this.stores.delete(store);
|
|
77
166
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
167
|
+
publish(message) {
|
|
168
|
+
const subscribers = this.subscribers;
|
|
169
|
+
for (const subscriber of subscribers) {
|
|
170
|
+
try {
|
|
171
|
+
subscriber(message, this.name);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
reportError(error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
runStores(message, fn, thisArg, ...args) {
|
|
178
|
+
let run = () => {
|
|
179
|
+
this.publish(message);
|
|
180
|
+
return Reflect.apply(fn, thisArg, args);
|
|
181
|
+
};
|
|
182
|
+
for (const [store, transform] of this.stores.entries()) {
|
|
183
|
+
run = wrapStoreRun(store, message, run, transform);
|
|
184
|
+
}
|
|
185
|
+
return run();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var traceEvents = [
|
|
189
|
+
"start",
|
|
190
|
+
"end",
|
|
191
|
+
"asyncStart",
|
|
192
|
+
"asyncEnd",
|
|
193
|
+
"error"
|
|
194
|
+
];
|
|
195
|
+
function traceInvocation(hook, operator, target, thisArg, args, additional, callbackIndex = -1) {
|
|
196
|
+
const context = {
|
|
197
|
+
...additional,
|
|
198
|
+
arguments: args,
|
|
199
|
+
self: thisArg
|
|
200
|
+
};
|
|
201
|
+
const invoke = () => hook.invoke(target, thisArg, args, additional);
|
|
202
|
+
if (operator === "traceCallback") {
|
|
203
|
+
return hook.traceCallback(invoke, callbackIndex, context);
|
|
204
|
+
}
|
|
205
|
+
if (operator === "tracePromise") {
|
|
206
|
+
return hook.tracePromise(invoke, context);
|
|
207
|
+
}
|
|
208
|
+
return hook.traceSync(invoke, context);
|
|
209
|
+
}
|
|
210
|
+
var InvocationHook = class {
|
|
211
|
+
interceptors = [];
|
|
212
|
+
get hasInterceptors() {
|
|
213
|
+
return this.interceptors.length > 0;
|
|
214
|
+
}
|
|
215
|
+
intercept(interceptor) {
|
|
216
|
+
if (typeof interceptor !== "function") {
|
|
217
|
+
throw new TypeError("interceptor must be a function");
|
|
218
|
+
}
|
|
219
|
+
this.interceptors = [...this.interceptors, interceptor];
|
|
220
|
+
let active = true;
|
|
221
|
+
return () => {
|
|
222
|
+
if (!active) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
active = false;
|
|
226
|
+
const index = this.interceptors.indexOf(interceptor);
|
|
227
|
+
if (index !== -1) {
|
|
228
|
+
this.interceptors = [
|
|
229
|
+
...this.interceptors.slice(0, index),
|
|
230
|
+
...this.interceptors.slice(index + 1)
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
invoke(target, thisArg, args, additional) {
|
|
236
|
+
const interceptors = this.interceptors;
|
|
237
|
+
if (interceptors.length === 0) {
|
|
238
|
+
return Reflect.apply(target, thisArg, args);
|
|
239
|
+
}
|
|
240
|
+
let next = target;
|
|
241
|
+
for (let index = interceptors.length - 1; index >= 0; index -= 1) {
|
|
242
|
+
const interceptor = interceptors[index];
|
|
243
|
+
const downstream = next;
|
|
244
|
+
next = function(...nextArgs) {
|
|
245
|
+
return interceptor(downstream, this, nextArgs, additional);
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return Reflect.apply(next, thisArg, args);
|
|
81
249
|
}
|
|
82
250
|
};
|
|
83
|
-
var
|
|
251
|
+
var TracingHook = class {
|
|
84
252
|
start;
|
|
85
253
|
end;
|
|
86
254
|
asyncStart;
|
|
87
255
|
asyncEnd;
|
|
88
256
|
error;
|
|
257
|
+
invocationHook = new InvocationHook();
|
|
89
258
|
constructor(nameOrChannels) {
|
|
259
|
+
Object.defineProperty(this, hookBrand, {
|
|
260
|
+
configurable: false,
|
|
261
|
+
enumerable: false,
|
|
262
|
+
value: GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
|
|
263
|
+
writable: false
|
|
264
|
+
});
|
|
265
|
+
Object.defineProperty(this, invocationHookBrand, {
|
|
266
|
+
configurable: false,
|
|
267
|
+
enumerable: false,
|
|
268
|
+
value: GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
|
|
269
|
+
writable: false
|
|
270
|
+
});
|
|
90
271
|
if (typeof nameOrChannels === "string") {
|
|
91
|
-
this.start = new
|
|
92
|
-
this.end = new
|
|
93
|
-
this.asyncStart = new
|
|
94
|
-
|
|
95
|
-
);
|
|
96
|
-
this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`);
|
|
97
|
-
this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`);
|
|
272
|
+
this.start = new HookChannel(`tracing:${nameOrChannels}:start`);
|
|
273
|
+
this.end = new HookChannel(`tracing:${nameOrChannels}:end`);
|
|
274
|
+
this.asyncStart = new HookChannel(`tracing:${nameOrChannels}:asyncStart`);
|
|
275
|
+
this.asyncEnd = new HookChannel(`tracing:${nameOrChannels}:asyncEnd`);
|
|
276
|
+
this.error = new HookChannel(`tracing:${nameOrChannels}:error`);
|
|
98
277
|
return;
|
|
99
278
|
}
|
|
100
|
-
this.start = nameOrChannels.start ?? new
|
|
101
|
-
this.end = nameOrChannels.end ?? new
|
|
102
|
-
this.asyncStart = nameOrChannels.asyncStart ?? new
|
|
103
|
-
this.asyncEnd = nameOrChannels.asyncEnd ?? new
|
|
104
|
-
this.error = nameOrChannels.error ?? new
|
|
279
|
+
this.start = nameOrChannels.start ?? new HookChannel("tracing:start");
|
|
280
|
+
this.end = nameOrChannels.end ?? new HookChannel("tracing:end");
|
|
281
|
+
this.asyncStart = nameOrChannels.asyncStart ?? new HookChannel("tracing:asyncStart");
|
|
282
|
+
this.asyncEnd = nameOrChannels.asyncEnd ?? new HookChannel("tracing:asyncEnd");
|
|
283
|
+
this.error = nameOrChannels.error ?? new HookChannel("tracing:error");
|
|
105
284
|
}
|
|
106
285
|
get hasSubscribers() {
|
|
107
286
|
return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
|
|
108
287
|
}
|
|
109
|
-
|
|
288
|
+
get hasInterceptors() {
|
|
289
|
+
return this.invocationHook.hasInterceptors;
|
|
290
|
+
}
|
|
291
|
+
intercept(interceptor) {
|
|
292
|
+
return this.invocationHook.intercept(interceptor);
|
|
293
|
+
}
|
|
294
|
+
invoke(target, thisArg, args, additional) {
|
|
295
|
+
return this.invocationHook.invoke(target, thisArg, args, additional);
|
|
110
296
|
}
|
|
111
|
-
|
|
297
|
+
traceInvocation(operator, target, thisArg, args, additional, callbackIndex = -1) {
|
|
298
|
+
return traceInvocation(
|
|
299
|
+
this,
|
|
300
|
+
operator,
|
|
301
|
+
target,
|
|
302
|
+
thisArg,
|
|
303
|
+
args,
|
|
304
|
+
additional,
|
|
305
|
+
callbackIndex
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
subscribe(handlers) {
|
|
309
|
+
for (const eventName of traceEvents) {
|
|
310
|
+
const handler = handlers[eventName];
|
|
311
|
+
if (handler) {
|
|
312
|
+
this[eventName].subscribe(handler);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
unsubscribe(handlers) {
|
|
317
|
+
let done = true;
|
|
318
|
+
for (const eventName of traceEvents) {
|
|
319
|
+
const handler = handlers[eventName];
|
|
320
|
+
if (handler && !this[eventName].unsubscribe(handler)) {
|
|
321
|
+
done = false;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return done;
|
|
325
|
+
}
|
|
326
|
+
traceSync(fn, message = {}, thisArg, ...args) {
|
|
327
|
+
if (!this.hasSubscribers) {
|
|
328
|
+
return Reflect.apply(fn, thisArg, args);
|
|
329
|
+
}
|
|
330
|
+
const context = message;
|
|
331
|
+
return this.start.runStores(message, () => {
|
|
332
|
+
try {
|
|
333
|
+
const result = Reflect.apply(fn, thisArg, args);
|
|
334
|
+
setContextValue(context, "result", result);
|
|
335
|
+
return result;
|
|
336
|
+
} catch (error) {
|
|
337
|
+
setContextValue(context, "error", error);
|
|
338
|
+
this.error.publish(message);
|
|
339
|
+
throw error;
|
|
340
|
+
} finally {
|
|
341
|
+
this.end.publish(message);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
tracePromise(fn, message = {}, thisArg, ...args) {
|
|
346
|
+
if (!this.hasSubscribers) {
|
|
347
|
+
return Reflect.apply(fn, thisArg, args);
|
|
348
|
+
}
|
|
349
|
+
const context = message;
|
|
350
|
+
return this.start.runStores(message, () => {
|
|
351
|
+
let result;
|
|
352
|
+
try {
|
|
353
|
+
result = Reflect.apply(fn, thisArg, args);
|
|
354
|
+
} catch (error) {
|
|
355
|
+
setContextValue(context, "error", error);
|
|
356
|
+
this.error.publish(message);
|
|
357
|
+
this.end.publish(message);
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
360
|
+
this.end.publish(message);
|
|
361
|
+
if (!result || typeof result !== "object" && typeof result !== "function") {
|
|
362
|
+
setContextValue(context, "result", result);
|
|
363
|
+
this.asyncStart.publish(message);
|
|
364
|
+
this.asyncEnd.publish(message);
|
|
365
|
+
return result;
|
|
366
|
+
}
|
|
367
|
+
let terminalPublished = false;
|
|
368
|
+
const finishUnobservedResult = (error) => {
|
|
369
|
+
reportError(error);
|
|
370
|
+
if (!terminalPublished) {
|
|
371
|
+
terminalPublished = true;
|
|
372
|
+
setContextValue(context, "result", result);
|
|
373
|
+
this.asyncStart.publish(message);
|
|
374
|
+
this.asyncEnd.publish(message);
|
|
375
|
+
}
|
|
376
|
+
return result;
|
|
377
|
+
};
|
|
378
|
+
let then;
|
|
379
|
+
try {
|
|
380
|
+
then = result.then;
|
|
381
|
+
} catch (error) {
|
|
382
|
+
return finishUnobservedResult(error);
|
|
383
|
+
}
|
|
384
|
+
if (typeof then !== "function") {
|
|
385
|
+
setContextValue(context, "result", result);
|
|
386
|
+
this.asyncStart.publish(message);
|
|
387
|
+
this.asyncEnd.publish(message);
|
|
388
|
+
return result;
|
|
389
|
+
}
|
|
390
|
+
const resolve = (resolved) => {
|
|
391
|
+
if (!terminalPublished) {
|
|
392
|
+
terminalPublished = true;
|
|
393
|
+
setContextValue(context, "result", resolved);
|
|
394
|
+
this.asyncStart.publish(message);
|
|
395
|
+
this.asyncEnd.publish(message);
|
|
396
|
+
}
|
|
397
|
+
return resolved;
|
|
398
|
+
};
|
|
399
|
+
let rejectionThrown = false;
|
|
400
|
+
let rejectionError;
|
|
401
|
+
const reject = (error) => {
|
|
402
|
+
if (!terminalPublished) {
|
|
403
|
+
terminalPublished = true;
|
|
404
|
+
setContextValue(context, "error", error);
|
|
405
|
+
this.error.publish(message);
|
|
406
|
+
this.asyncStart.publish(message);
|
|
407
|
+
this.asyncEnd.publish(message);
|
|
408
|
+
}
|
|
409
|
+
rejectionThrown = true;
|
|
410
|
+
rejectionError = error;
|
|
411
|
+
throw error;
|
|
412
|
+
};
|
|
413
|
+
let isPlainPromise;
|
|
414
|
+
try {
|
|
415
|
+
isPlainPromise = result instanceof Promise && result.constructor === Promise;
|
|
416
|
+
} catch (error) {
|
|
417
|
+
return finishUnobservedResult(error);
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
if (isPlainPromise) {
|
|
421
|
+
return Reflect.apply(then, result, [resolve, reject]);
|
|
422
|
+
}
|
|
423
|
+
Reflect.apply(then, result, [
|
|
424
|
+
resolve,
|
|
425
|
+
(error) => {
|
|
426
|
+
try {
|
|
427
|
+
reject(error);
|
|
428
|
+
} catch {
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
]);
|
|
432
|
+
} catch (error) {
|
|
433
|
+
if (rejectionThrown && error === rejectionError) {
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
return finishUnobservedResult(error);
|
|
437
|
+
}
|
|
438
|
+
return result;
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
traceCallback(fn, position = -1, message = {}, thisArg, ...args) {
|
|
442
|
+
if (!this.hasSubscribers) {
|
|
443
|
+
return Reflect.apply(fn, thisArg, args);
|
|
444
|
+
}
|
|
445
|
+
const context = message;
|
|
446
|
+
const callArgs = args.length > 0 ? args : context.arguments ?? args;
|
|
447
|
+
const callback = Array.prototype.at.call(callArgs, position);
|
|
448
|
+
if (typeof callback !== "function") {
|
|
449
|
+
return Reflect.apply(fn, thisArg, args);
|
|
450
|
+
}
|
|
451
|
+
const { asyncStart, asyncEnd, error: errorChannel } = this;
|
|
452
|
+
function wrappedCallback(error, result) {
|
|
453
|
+
if (error) {
|
|
454
|
+
setContextValue(context, "error", error);
|
|
455
|
+
errorChannel.publish(message);
|
|
456
|
+
} else {
|
|
457
|
+
setContextValue(context, "result", result);
|
|
458
|
+
}
|
|
459
|
+
return asyncStart.runStores(message, () => {
|
|
460
|
+
try {
|
|
461
|
+
return Reflect.apply(callback, this, arguments);
|
|
462
|
+
} finally {
|
|
463
|
+
asyncEnd.publish(message);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
Array.prototype.splice.call(callArgs, position, 1, wrappedCallback);
|
|
468
|
+
return this.start.runStores(message, () => {
|
|
469
|
+
try {
|
|
470
|
+
return Reflect.apply(fn, thisArg, args);
|
|
471
|
+
} catch (error) {
|
|
472
|
+
setContextValue(context, "error", error);
|
|
473
|
+
this.error.publish(message);
|
|
474
|
+
throw error;
|
|
475
|
+
} finally {
|
|
476
|
+
this.end.publish(message);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
var inertChannel = Object.freeze({
|
|
482
|
+
name: "braintrust:inert",
|
|
483
|
+
hasSubscribers: false,
|
|
484
|
+
subscribe() {
|
|
485
|
+
},
|
|
486
|
+
unsubscribe() {
|
|
487
|
+
return false;
|
|
488
|
+
},
|
|
489
|
+
bindStore() {
|
|
490
|
+
},
|
|
491
|
+
unbindStore() {
|
|
112
492
|
return false;
|
|
493
|
+
},
|
|
494
|
+
publish() {
|
|
495
|
+
},
|
|
496
|
+
runStores(_message, fn, thisArg, ...args) {
|
|
497
|
+
return Reflect.apply(fn, thisArg, args);
|
|
113
498
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
499
|
+
});
|
|
500
|
+
var inertTracingHook = new TracingHook({
|
|
501
|
+
start: inertChannel,
|
|
502
|
+
end: inertChannel,
|
|
503
|
+
asyncStart: inertChannel,
|
|
504
|
+
asyncEnd: inertChannel,
|
|
505
|
+
error: inertChannel
|
|
506
|
+
});
|
|
507
|
+
function isHookChannel(value) {
|
|
508
|
+
if (typeof value !== "object" && typeof value !== "function" || value === null) {
|
|
509
|
+
return false;
|
|
117
510
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return
|
|
511
|
+
try {
|
|
512
|
+
const channel2 = value;
|
|
513
|
+
return typeof channel2.hasSubscribers === "boolean" && typeof channel2.subscribe === "function" && typeof channel2.unsubscribe === "function" && typeof channel2.bindStore === "function" && typeof channel2.unbindStore === "function" && typeof channel2.publish === "function" && typeof channel2.runStores === "function";
|
|
514
|
+
} catch {
|
|
515
|
+
return false;
|
|
121
516
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
517
|
+
}
|
|
518
|
+
function hasTracingHookShape(value) {
|
|
519
|
+
if (typeof value !== "object" && typeof value !== "function" || value === null) {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
const hook = value;
|
|
524
|
+
return typeof hook.hasSubscribers === "boolean" && typeof hook.subscribe === "function" && typeof hook.unsubscribe === "function" && typeof hook.traceSync === "function" && typeof hook.tracePromise === "function" && typeof hook.traceCallback === "function" && isHookChannel(hook.start) && isHookChannel(hook.end) && isHookChannel(hook.asyncStart) && isHookChannel(hook.asyncEnd) && isHookChannel(hook.error);
|
|
525
|
+
} catch {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function hasInvocationHookShape(value) {
|
|
530
|
+
if (typeof value !== "object" && typeof value !== "function" || value === null) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
try {
|
|
534
|
+
const hook = value;
|
|
535
|
+
return value[invocationHookBrand] === GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION && typeof hook.hasInterceptors === "boolean" && typeof hook.intercept === "function" && typeof hook.invoke === "function";
|
|
536
|
+
} catch {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function installInvocationHook(value) {
|
|
541
|
+
const hasInvocationHook = hasInvocationHookShape(value);
|
|
542
|
+
const invocationHook = new InvocationHook();
|
|
543
|
+
try {
|
|
544
|
+
if (!hasInvocationHook) {
|
|
545
|
+
Object.defineProperties(value, {
|
|
546
|
+
[invocationHookBrand]: {
|
|
547
|
+
configurable: false,
|
|
548
|
+
enumerable: false,
|
|
549
|
+
value: GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
|
|
550
|
+
writable: false
|
|
551
|
+
},
|
|
552
|
+
hasInterceptors: {
|
|
553
|
+
configurable: false,
|
|
554
|
+
enumerable: false,
|
|
555
|
+
get: () => invocationHook.hasInterceptors
|
|
556
|
+
},
|
|
557
|
+
intercept: {
|
|
558
|
+
configurable: false,
|
|
559
|
+
enumerable: false,
|
|
560
|
+
value: invocationHook.intercept.bind(invocationHook),
|
|
561
|
+
writable: false
|
|
562
|
+
},
|
|
563
|
+
invoke: {
|
|
564
|
+
configurable: false,
|
|
565
|
+
enumerable: false,
|
|
566
|
+
value: invocationHook.invoke.bind(invocationHook),
|
|
567
|
+
writable: false
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
if (typeof value.traceInvocation !== "function") {
|
|
572
|
+
Object.defineProperty(value, "traceInvocation", {
|
|
573
|
+
configurable: false,
|
|
574
|
+
enumerable: false,
|
|
575
|
+
value: traceInvocation.bind(void 0, value),
|
|
576
|
+
writable: false
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
} catch (error) {
|
|
580
|
+
reportError(error);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
function isCompatibleTracingHook(value) {
|
|
584
|
+
try {
|
|
585
|
+
return value[hookBrand] === GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION && hasTracingHookShape(value);
|
|
586
|
+
} catch {
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
function isCompatibleHookRegistry(value) {
|
|
591
|
+
try {
|
|
592
|
+
return value instanceof Map && value[registryBrand] === GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION;
|
|
593
|
+
} catch {
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function getHookRegistry() {
|
|
598
|
+
let descriptor;
|
|
599
|
+
try {
|
|
600
|
+
descriptor = Object.getOwnPropertyDescriptor(
|
|
601
|
+
globalThis,
|
|
602
|
+
GLOBAL_INSTRUMENTATION_HOOKS_KEY
|
|
603
|
+
);
|
|
604
|
+
} catch (error) {
|
|
605
|
+
reportError(error);
|
|
606
|
+
return void 0;
|
|
607
|
+
}
|
|
608
|
+
if (descriptor && "value" in descriptor && isCompatibleHookRegistry(descriptor.value) && (descriptor.configurable || descriptor.enumerable === false)) {
|
|
609
|
+
if (descriptor.configurable || descriptor.writable) {
|
|
610
|
+
try {
|
|
611
|
+
Object.defineProperty(globalThis, GLOBAL_INSTRUMENTATION_HOOKS_KEY, {
|
|
612
|
+
configurable: false,
|
|
613
|
+
enumerable: false,
|
|
614
|
+
value: descriptor.value,
|
|
615
|
+
writable: false
|
|
616
|
+
});
|
|
617
|
+
} catch (error) {
|
|
618
|
+
reportError(error);
|
|
619
|
+
return void 0;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return descriptor.value;
|
|
623
|
+
}
|
|
624
|
+
if (descriptor && !descriptor.configurable) {
|
|
625
|
+
reportError(new Error("Incompatible global instrumentation hook registry"));
|
|
626
|
+
return void 0;
|
|
627
|
+
}
|
|
628
|
+
const registry = /* @__PURE__ */ new Map();
|
|
629
|
+
try {
|
|
630
|
+
Object.defineProperty(registry, registryBrand, {
|
|
631
|
+
configurable: false,
|
|
632
|
+
enumerable: false,
|
|
633
|
+
value: GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
|
|
634
|
+
writable: false
|
|
635
|
+
});
|
|
636
|
+
} catch (error) {
|
|
637
|
+
reportError(error);
|
|
638
|
+
return void 0;
|
|
639
|
+
}
|
|
640
|
+
try {
|
|
641
|
+
Object.defineProperty(globalThis, GLOBAL_INSTRUMENTATION_HOOKS_KEY, {
|
|
642
|
+
configurable: false,
|
|
643
|
+
enumerable: false,
|
|
644
|
+
value: registry,
|
|
645
|
+
writable: false
|
|
646
|
+
});
|
|
647
|
+
return registry;
|
|
648
|
+
} catch (error) {
|
|
649
|
+
reportError(error);
|
|
650
|
+
return void 0;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function newGlobalTracingChannel(nameOrChannels) {
|
|
654
|
+
if (typeof nameOrChannels !== "string") {
|
|
655
|
+
return new TracingHook(nameOrChannels);
|
|
656
|
+
}
|
|
657
|
+
const registry = getHookRegistry();
|
|
658
|
+
if (!registry) {
|
|
659
|
+
return inertTracingHook;
|
|
660
|
+
}
|
|
661
|
+
let existing;
|
|
662
|
+
try {
|
|
663
|
+
existing = Map.prototype.get.call(registry, nameOrChannels);
|
|
664
|
+
} catch (error) {
|
|
665
|
+
reportError(error);
|
|
666
|
+
return inertTracingHook;
|
|
667
|
+
}
|
|
668
|
+
if (isCompatibleTracingHook(existing)) {
|
|
669
|
+
installInvocationHook(existing);
|
|
670
|
+
return existing;
|
|
671
|
+
}
|
|
672
|
+
if (existing !== void 0) {
|
|
673
|
+
reportError(
|
|
674
|
+
new Error(`Invalid global instrumentation hook: ${nameOrChannels}`)
|
|
675
|
+
);
|
|
676
|
+
try {
|
|
677
|
+
Map.prototype.delete.call(registry, nameOrChannels);
|
|
678
|
+
} catch (error) {
|
|
679
|
+
reportError(error);
|
|
680
|
+
return inertTracingHook;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
const hook = new TracingHook(nameOrChannels);
|
|
684
|
+
try {
|
|
685
|
+
Map.prototype.set.call(registry, nameOrChannels, hook);
|
|
686
|
+
} catch (error) {
|
|
687
|
+
reportError(error);
|
|
688
|
+
return inertTracingHook;
|
|
689
|
+
}
|
|
690
|
+
return hook;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// src/isomorph.ts
|
|
694
|
+
var DefaultAsyncLocalStorage = class {
|
|
695
|
+
constructor() {
|
|
696
|
+
}
|
|
697
|
+
enterWith(_) {
|
|
698
|
+
}
|
|
699
|
+
run(_, callback) {
|
|
700
|
+
return callback();
|
|
701
|
+
}
|
|
702
|
+
getStore() {
|
|
703
|
+
return void 0;
|
|
125
704
|
}
|
|
126
705
|
};
|
|
127
706
|
var iso = {
|
|
@@ -134,7 +713,7 @@ var iso = {
|
|
|
134
713
|
getCallerLocation: () => void 0,
|
|
135
714
|
newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(),
|
|
136
715
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
-
newTracingChannel: (nameOrChannels) =>
|
|
716
|
+
newTracingChannel: (nameOrChannels) => newGlobalTracingChannel(nameOrChannels),
|
|
138
717
|
processOn: (_0, _1) => {
|
|
139
718
|
},
|
|
140
719
|
basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
|
|
@@ -157,11 +736,21 @@ function defineChannels(pkg, channels, options) {
|
|
|
157
736
|
const tracingChannel2 = () => isomorph_default.newTracingChannel(
|
|
158
737
|
fullChannelName
|
|
159
738
|
);
|
|
739
|
+
const intercept2 = (interceptor) => {
|
|
740
|
+
const hook = tracingChannel2();
|
|
741
|
+
return typeof hook.intercept === "function" ? hook.intercept(interceptor) : () => {
|
|
742
|
+
};
|
|
743
|
+
};
|
|
160
744
|
return [
|
|
161
745
|
key,
|
|
162
746
|
{
|
|
163
747
|
...asyncSpec,
|
|
164
748
|
instrumentationName,
|
|
749
|
+
intercept: intercept2,
|
|
750
|
+
invoke: (target, thisArg, args, additional) => {
|
|
751
|
+
const hook = tracingChannel2();
|
|
752
|
+
return typeof hook.invoke === "function" ? hook.invoke(target, thisArg, args, additional) : Reflect.apply(target, thisArg, args);
|
|
753
|
+
},
|
|
165
754
|
tracingChannel: tracingChannel2,
|
|
166
755
|
tracePromise: (fn, context) => tracingChannel2().tracePromise(
|
|
167
756
|
fn,
|
|
@@ -175,11 +764,21 @@ function defineChannels(pkg, channels, options) {
|
|
|
175
764
|
const tracingChannel = () => isomorph_default.newTracingChannel(
|
|
176
765
|
fullChannelName
|
|
177
766
|
);
|
|
767
|
+
const intercept = (interceptor) => {
|
|
768
|
+
const hook = tracingChannel();
|
|
769
|
+
return typeof hook.intercept === "function" ? hook.intercept(interceptor) : () => {
|
|
770
|
+
};
|
|
771
|
+
};
|
|
178
772
|
return [
|
|
179
773
|
key,
|
|
180
774
|
{
|
|
181
775
|
...syncSpec,
|
|
182
776
|
instrumentationName,
|
|
777
|
+
intercept,
|
|
778
|
+
invoke: (target, thisArg, args, additional) => {
|
|
779
|
+
const hook = tracingChannel();
|
|
780
|
+
return typeof hook.invoke === "function" ? hook.invoke(target, thisArg, args, additional) : Reflect.apply(target, thisArg, args);
|
|
781
|
+
},
|
|
183
782
|
tracingChannel,
|
|
184
783
|
traceSync: (fn, context) => tracingChannel().traceSync(
|
|
185
784
|
fn,
|
|
@@ -199,6 +798,9 @@ var INSTRUMENTATION_NAMES = {
|
|
|
199
798
|
BEDROCK_RUNTIME: "bedrock-runtime",
|
|
200
799
|
BRAINTRUST_JS_LOGGER: "braintrust-js-logger",
|
|
201
800
|
CLAUDE_AGENT_SDK: "claude-agent-sdk",
|
|
801
|
+
CLOUDFLARE_AI_CHAT: "cloudflare-ai-chat",
|
|
802
|
+
CLOUDFLARE_AGENTS: "cloudflare-agents",
|
|
803
|
+
CLOUDFLARE_THINK: "cloudflare-think",
|
|
202
804
|
COHERE: "cohere",
|
|
203
805
|
CURSOR_SDK: "cursor-sdk",
|
|
204
806
|
EVE: "eve",
|
|
@@ -213,6 +815,7 @@ var INSTRUMENTATION_NAMES = {
|
|
|
213
815
|
LANGSMITH: "langsmith",
|
|
214
816
|
MASTRA: "mastra",
|
|
215
817
|
MISTRAL: "mistral",
|
|
818
|
+
OLLAMA: "ollama",
|
|
216
819
|
OPENAI: "openai",
|
|
217
820
|
OPENAI_AGENTS: "openai-agents",
|
|
218
821
|
OPENAI_CODEX: "openai-codex",
|
|
@@ -507,6 +1110,14 @@ var anthropicChannels = defineChannels(
|
|
|
507
1110
|
betaMessagesToolRunner: channel({
|
|
508
1111
|
channelName: "beta.messages.toolRunner",
|
|
509
1112
|
kind: "sync-stream"
|
|
1113
|
+
}),
|
|
1114
|
+
betaSessionsEventsStream: channel({
|
|
1115
|
+
channelName: "beta.sessions.events.stream",
|
|
1116
|
+
kind: "async"
|
|
1117
|
+
}),
|
|
1118
|
+
betaSessionsThreadsEventsStream: channel({
|
|
1119
|
+
channelName: "beta.sessions.threads.events.stream",
|
|
1120
|
+
kind: "async"
|
|
510
1121
|
})
|
|
511
1122
|
},
|
|
512
1123
|
{ instrumentationName: INSTRUMENTATION_NAMES.ANTHROPIC }
|
|
@@ -625,7 +1236,40 @@ var anthropicConfigs = [
|
|
|
625
1236
|
methodName: "toolRunner",
|
|
626
1237
|
kind: "Sync"
|
|
627
1238
|
}
|
|
628
|
-
}
|
|
1239
|
+
},
|
|
1240
|
+
// Managed Agents Sessions event streams are discovered automatically, but
|
|
1241
|
+
// remain passive until the user calls collectAnthropicSession() on the
|
|
1242
|
+
// returned stream.
|
|
1243
|
+
...["mjs", "js"].map(
|
|
1244
|
+
(extension) => ({
|
|
1245
|
+
channelName: anthropicChannels.betaSessionsEventsStream.channelName,
|
|
1246
|
+
module: {
|
|
1247
|
+
name: "@anthropic-ai/sdk",
|
|
1248
|
+
versionRange: ">=0.86.0",
|
|
1249
|
+
filePath: `resources/beta/sessions/events.${extension}`
|
|
1250
|
+
},
|
|
1251
|
+
functionQuery: {
|
|
1252
|
+
className: "Events",
|
|
1253
|
+
methodName: "stream",
|
|
1254
|
+
kind: "Async"
|
|
1255
|
+
}
|
|
1256
|
+
})
|
|
1257
|
+
),
|
|
1258
|
+
...["mjs", "js"].map(
|
|
1259
|
+
(extension) => ({
|
|
1260
|
+
channelName: anthropicChannels.betaSessionsThreadsEventsStream.channelName,
|
|
1261
|
+
module: {
|
|
1262
|
+
name: "@anthropic-ai/sdk",
|
|
1263
|
+
versionRange: ">=0.86.0",
|
|
1264
|
+
filePath: `resources/beta/sessions/threads/events.${extension}`
|
|
1265
|
+
},
|
|
1266
|
+
functionQuery: {
|
|
1267
|
+
className: "Events",
|
|
1268
|
+
methodName: "stream",
|
|
1269
|
+
kind: "Async"
|
|
1270
|
+
}
|
|
1271
|
+
})
|
|
1272
|
+
)
|
|
629
1273
|
];
|
|
630
1274
|
|
|
631
1275
|
// src/instrumentation/plugins/bedrock-runtime-channels.ts
|
|
@@ -1246,6 +1890,66 @@ var claudeAgentSDKConfigs = [
|
|
|
1246
1890
|
}
|
|
1247
1891
|
];
|
|
1248
1892
|
|
|
1893
|
+
// src/instrumentation/plugins/cloudflare-agents-channels.ts
|
|
1894
|
+
var cloudflareAgentsChannels = defineChannels(
|
|
1895
|
+
"agents",
|
|
1896
|
+
{
|
|
1897
|
+
runAgentTool: channel({
|
|
1898
|
+
channelName: "Agent.runAgentTool",
|
|
1899
|
+
kind: "async"
|
|
1900
|
+
})
|
|
1901
|
+
},
|
|
1902
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AGENTS }
|
|
1903
|
+
);
|
|
1904
|
+
|
|
1905
|
+
// src/auto-instrumentations/configs/cloudflare-agents.ts
|
|
1906
|
+
var cloudflareAgentsVersionRange = ">=0.17.0 <0.18.0";
|
|
1907
|
+
var cloudflareAgentsConfigs = [
|
|
1908
|
+
{
|
|
1909
|
+
channelName: cloudflareAgentsChannels.runAgentTool.channelName,
|
|
1910
|
+
module: {
|
|
1911
|
+
name: "agents",
|
|
1912
|
+
versionRange: cloudflareAgentsVersionRange,
|
|
1913
|
+
filePath: "dist/index.js"
|
|
1914
|
+
},
|
|
1915
|
+
functionQuery: {
|
|
1916
|
+
className: "Agent",
|
|
1917
|
+
methodName: "runAgentTool",
|
|
1918
|
+
kind: "Async"
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
];
|
|
1922
|
+
|
|
1923
|
+
// src/instrumentation/plugins/cloudflare-think-channels.ts
|
|
1924
|
+
var cloudflareThinkChannels = defineChannels(
|
|
1925
|
+
"@cloudflare/think",
|
|
1926
|
+
{
|
|
1927
|
+
runInferenceLoop: channel({
|
|
1928
|
+
channelName: "Think.runInferenceLoop",
|
|
1929
|
+
kind: "async"
|
|
1930
|
+
})
|
|
1931
|
+
},
|
|
1932
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_THINK }
|
|
1933
|
+
);
|
|
1934
|
+
|
|
1935
|
+
// src/auto-instrumentations/configs/cloudflare-think.ts
|
|
1936
|
+
var cloudflareThinkVersionRange = ">=0.13.0 <0.14.0";
|
|
1937
|
+
var cloudflareThinkConfigs = [
|
|
1938
|
+
{
|
|
1939
|
+
channelName: cloudflareThinkChannels.runInferenceLoop.channelName,
|
|
1940
|
+
module: {
|
|
1941
|
+
name: "@cloudflare/think",
|
|
1942
|
+
versionRange: cloudflareThinkVersionRange,
|
|
1943
|
+
filePath: "dist/think.js"
|
|
1944
|
+
},
|
|
1945
|
+
functionQuery: {
|
|
1946
|
+
className: "Think",
|
|
1947
|
+
methodName: "_runInferenceLoop",
|
|
1948
|
+
kind: "Async"
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
];
|
|
1952
|
+
|
|
1249
1953
|
// src/instrumentation/plugins/cursor-sdk-channels.ts
|
|
1250
1954
|
var cursorSDKChannels = defineChannels(
|
|
1251
1955
|
"@cursor/sdk",
|
|
@@ -1863,6 +2567,19 @@ var openRouterConfigs = [
|
|
|
1863
2567
|
kind: "Async"
|
|
1864
2568
|
}
|
|
1865
2569
|
},
|
|
2570
|
+
{
|
|
2571
|
+
channelName: openRouterChannels.betaResponsesSend.channelName,
|
|
2572
|
+
module: {
|
|
2573
|
+
name: "@openrouter/sdk",
|
|
2574
|
+
versionRange: ">=1.1.2 <2.0.0",
|
|
2575
|
+
filePath: "esm/sdk/betaresponses.js"
|
|
2576
|
+
},
|
|
2577
|
+
functionQuery: {
|
|
2578
|
+
className: "BetaResponses",
|
|
2579
|
+
methodName: "send",
|
|
2580
|
+
kind: "Async"
|
|
2581
|
+
}
|
|
2582
|
+
},
|
|
1866
2583
|
{
|
|
1867
2584
|
channelName: openRouterChannels.callModel.channelName,
|
|
1868
2585
|
module: {
|
|
@@ -2220,6 +2937,51 @@ var mistralConfigs = [
|
|
|
2220
2937
|
}
|
|
2221
2938
|
];
|
|
2222
2939
|
|
|
2940
|
+
// src/instrumentation/plugins/ollama-channels.ts
|
|
2941
|
+
var ollamaChannels = defineChannels(
|
|
2942
|
+
"ollama",
|
|
2943
|
+
{
|
|
2944
|
+
chat: channel({
|
|
2945
|
+
channelName: "chat",
|
|
2946
|
+
kind: "async"
|
|
2947
|
+
}),
|
|
2948
|
+
generate: channel({
|
|
2949
|
+
channelName: "generate",
|
|
2950
|
+
kind: "async"
|
|
2951
|
+
}),
|
|
2952
|
+
embed: channel({
|
|
2953
|
+
channelName: "embed",
|
|
2954
|
+
kind: "async"
|
|
2955
|
+
})
|
|
2956
|
+
},
|
|
2957
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.OLLAMA }
|
|
2958
|
+
);
|
|
2959
|
+
|
|
2960
|
+
// src/auto-instrumentations/configs/ollama.ts
|
|
2961
|
+
var methods = [
|
|
2962
|
+
["chat", ollamaChannels.chat.channelName],
|
|
2963
|
+
["generate", ollamaChannels.generate.channelName],
|
|
2964
|
+
["embed", ollamaChannels.embed.channelName]
|
|
2965
|
+
];
|
|
2966
|
+
var implementationFiles = ["dist/browser.mjs", "dist/browser.cjs"];
|
|
2967
|
+
var ollamaConfigs = [
|
|
2968
|
+
...implementationFiles.flatMap(
|
|
2969
|
+
(filePath) => methods.map(([methodName, channelName]) => ({
|
|
2970
|
+
channelName,
|
|
2971
|
+
module: {
|
|
2972
|
+
name: "ollama",
|
|
2973
|
+
versionRange: ">=0.6.0 <0.7.0",
|
|
2974
|
+
filePath
|
|
2975
|
+
},
|
|
2976
|
+
functionQuery: {
|
|
2977
|
+
className: "Ollama",
|
|
2978
|
+
methodName,
|
|
2979
|
+
kind: "Async"
|
|
2980
|
+
}
|
|
2981
|
+
}))
|
|
2982
|
+
)
|
|
2983
|
+
];
|
|
2984
|
+
|
|
2223
2985
|
// src/instrumentation/plugins/google-adk-channels.ts
|
|
2224
2986
|
var googleADKChannels = defineChannels(
|
|
2225
2987
|
"@google/adk",
|
|
@@ -2468,6 +3230,44 @@ var googleADKConfigs = [
|
|
|
2468
3230
|
}
|
|
2469
3231
|
];
|
|
2470
3232
|
|
|
3233
|
+
// src/instrumentation/plugins/cloudflare-ai-chat-channels.ts
|
|
3234
|
+
var cloudflareAIChatChannels = defineChannels(
|
|
3235
|
+
"@cloudflare/ai-chat",
|
|
3236
|
+
{
|
|
3237
|
+
runExclusiveChatTurn: channel({
|
|
3238
|
+
channelName: "AIChatAgent._runExclusiveChatTurn",
|
|
3239
|
+
kind: "async"
|
|
3240
|
+
}),
|
|
3241
|
+
onChatResponse: channel({
|
|
3242
|
+
channelName: "AIChatAgent.onChatResponse",
|
|
3243
|
+
kind: "sync-stream"
|
|
3244
|
+
})
|
|
3245
|
+
},
|
|
3246
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AI_CHAT }
|
|
3247
|
+
);
|
|
3248
|
+
|
|
3249
|
+
// src/auto-instrumentations/configs/cloudflare-ai-chat.ts
|
|
3250
|
+
var cloudflareAIChatVersionRange = ">=0.9.0 <0.10.0";
|
|
3251
|
+
var cloudflareAIChatConfigs = [
|
|
3252
|
+
{
|
|
3253
|
+
// AIChatAgent subclasses replace onChatMessage, so there is no stable
|
|
3254
|
+
// public implementation for the transformer to target. This runner is
|
|
3255
|
+
// the narrowest shared boundary around every chat turn; keep the version
|
|
3256
|
+
// range tight because it is an internal method.
|
|
3257
|
+
channelName: cloudflareAIChatChannels.runExclusiveChatTurn.channelName,
|
|
3258
|
+
module: {
|
|
3259
|
+
name: "@cloudflare/ai-chat",
|
|
3260
|
+
versionRange: cloudflareAIChatVersionRange,
|
|
3261
|
+
filePath: "dist/index.js"
|
|
3262
|
+
},
|
|
3263
|
+
functionQuery: {
|
|
3264
|
+
className: "AIChatAgent",
|
|
3265
|
+
methodName: "_runExclusiveChatTurn",
|
|
3266
|
+
kind: "Async"
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
];
|
|
3270
|
+
|
|
2471
3271
|
// src/instrumentation/plugins/cohere-channels.ts
|
|
2472
3272
|
var cohereChannels = defineChannels(
|
|
2473
3273
|
"cohere-ai",
|
|
@@ -3248,6 +4048,9 @@ var piCodingAgentConfigs = [
|
|
|
3248
4048
|
anthropicConfigs,
|
|
3249
4049
|
bedrockRuntimeConfigs,
|
|
3250
4050
|
claudeAgentSDKConfigs,
|
|
4051
|
+
cloudflareAIChatConfigs,
|
|
4052
|
+
cloudflareAgentsConfigs,
|
|
4053
|
+
cloudflareThinkConfigs,
|
|
3251
4054
|
cohereConfigs,
|
|
3252
4055
|
cursorSDKConfigs,
|
|
3253
4056
|
genkitConfigs,
|
|
@@ -3259,6 +4062,7 @@ var piCodingAgentConfigs = [
|
|
|
3259
4062
|
langSmithConfigs,
|
|
3260
4063
|
langchainConfigs,
|
|
3261
4064
|
mistralConfigs,
|
|
4065
|
+
ollamaConfigs,
|
|
3262
4066
|
openAIAgentsCoreConfigs,
|
|
3263
4067
|
openAICodexConfigs,
|
|
3264
4068
|
openRouterAgentConfigs,
|