braintrust 3.23.1 → 3.25.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 (51) hide show
  1. package/dev/dist/index.d.mts +11 -0
  2. package/dev/dist/index.d.ts +11 -0
  3. package/dev/dist/index.js +2881 -1518
  4. package/dev/dist/index.mjs +2298 -935
  5. package/dist/apply-auto-instrumentation.js +218 -195
  6. package/dist/apply-auto-instrumentation.mjs +30 -7
  7. package/dist/auto-instrumentations/bundler/esbuild.cjs +618 -444
  8. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/next.cjs +618 -444
  10. package/dist/auto-instrumentations/bundler/next.mjs +3 -3
  11. package/dist/auto-instrumentations/bundler/rollup.cjs +618 -444
  12. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  13. package/dist/auto-instrumentations/bundler/vite.cjs +618 -444
  14. package/dist/auto-instrumentations/bundler/vite.d.mts +1 -1
  15. package/dist/auto-instrumentations/bundler/vite.d.ts +1 -1
  16. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  17. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +618 -444
  18. package/dist/auto-instrumentations/bundler/webpack.cjs +618 -444
  19. package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
  20. package/dist/auto-instrumentations/{chunk-KIMLYPRW.mjs → chunk-7P6563SW.mjs} +1 -1
  21. package/dist/auto-instrumentations/{chunk-YXLNSAMJ.mjs → chunk-CZ24KNHT.mjs} +591 -424
  22. package/dist/auto-instrumentations/{chunk-EXY7QCJD.mjs → chunk-JPVCUKTY.mjs} +30 -21
  23. package/dist/auto-instrumentations/hook.mjs +778 -457
  24. package/dist/auto-instrumentations/index.cjs +590 -424
  25. package/dist/auto-instrumentations/index.mjs +1 -1
  26. package/dist/browser.d.mts +138 -9
  27. package/dist/browser.d.ts +138 -9
  28. package/dist/browser.js +2700 -1011
  29. package/dist/browser.mjs +2700 -1011
  30. package/dist/{chunk-RBXD2KYN.mjs → chunk-2SANLSWX.mjs} +1577 -513
  31. package/dist/{chunk-36IPYKMG.mjs → chunk-ABR2QWDP.mjs} +704 -438
  32. package/dist/{chunk-B6ZQIAK3.js → chunk-GSIDVFE6.js} +2361 -1297
  33. package/dist/{chunk-CDIKAHDZ.js → chunk-P25IOOU4.js} +706 -440
  34. package/dist/cli.js +2307 -940
  35. package/dist/edge-light.js +2700 -1011
  36. package/dist/edge-light.mjs +2700 -1011
  37. package/dist/index.d.mts +138 -9
  38. package/dist/index.d.ts +138 -9
  39. package/dist/index.js +955 -551
  40. package/dist/index.mjs +493 -89
  41. package/dist/instrumentation/index.d.mts +135 -9
  42. package/dist/instrumentation/index.d.ts +135 -9
  43. package/dist/instrumentation/index.js +2554 -1009
  44. package/dist/instrumentation/index.mjs +2554 -1009
  45. package/dist/vitest-evals-reporter.js +17 -16
  46. package/dist/vitest-evals-reporter.mjs +3 -2
  47. package/dist/workerd.js +2700 -1011
  48. package/dist/workerd.mjs +2700 -1011
  49. package/package.json +4 -4
  50. package/util/dist/index.js +4 -0
  51. package/util/dist/index.mjs +4 -0
@@ -107,6 +107,7 @@ var DefaultChannel = class {
107
107
  constructor(name) {
108
108
  this.name = name;
109
109
  }
110
+ name;
110
111
  hasSubscribers = false;
111
112
  subscribe(_subscription) {
112
113
  }
@@ -188,11 +189,150 @@ var iso = {
188
189
  };
189
190
  var isomorph_default = iso;
190
191
 
192
+ // src/span-origin.ts
193
+ var INSTRUMENTATION_NAMES = {
194
+ AI_SDK: "ai-sdk",
195
+ ANTHROPIC: "anthropic",
196
+ BEDROCK_RUNTIME: "bedrock-runtime",
197
+ BRAINTRUST_JS_LOGGER: "braintrust-js-logger",
198
+ CLAUDE_AGENT_SDK: "claude-agent-sdk",
199
+ COHERE: "cohere",
200
+ CURSOR_SDK: "cursor-sdk",
201
+ EVE: "eve",
202
+ FLUE: "flue",
203
+ GENKIT: "genkit",
204
+ GITHUB_COPILOT: "github-copilot",
205
+ GOOGLE_ADK: "google-adk",
206
+ GOOGLE_GENAI: "google-genai",
207
+ GROQ: "groq",
208
+ HUGGINGFACE: "huggingface",
209
+ LANGCHAIN: "langchain",
210
+ LANGSMITH: "langsmith",
211
+ MASTRA: "mastra",
212
+ MISTRAL: "mistral",
213
+ OPENAI: "openai",
214
+ OPENAI_AGENTS: "openai-agents",
215
+ OPENAI_CODEX: "openai-codex",
216
+ OPENROUTER: "openrouter",
217
+ OPENROUTER_AGENT: "openrouter-agent",
218
+ PI_CODING_AGENT: "pi-coding-agent",
219
+ STRANDS_AGENT_SDK: "strands-agent-sdk"
220
+ };
221
+ var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
222
+ "braintrust.spanInstrumentationName"
223
+ );
224
+ var SDK_VERSION = true ? "3.25.0" : "0.0.0";
225
+ function withSpanInstrumentationName(args, instrumentationName) {
226
+ return {
227
+ ...args,
228
+ [INTERNAL_SPAN_INSTRUMENTATION_NAME]: instrumentationName
229
+ };
230
+ }
231
+ function getSpanInstrumentationName(args) {
232
+ if (typeof args !== "object" || args === null) {
233
+ return void 0;
234
+ }
235
+ const value = args[INTERNAL_SPAN_INSTRUMENTATION_NAME];
236
+ return isSpanInstrumentationName(value) ? value : void 0;
237
+ }
238
+ function detectSpanOriginEnvironment(explicit) {
239
+ if (explicit) return explicit;
240
+ const envType = isomorph_default.getEnv("BRAINTRUST_ENVIRONMENT_TYPE");
241
+ const envName = isomorph_default.getEnv("BRAINTRUST_ENVIRONMENT_NAME");
242
+ if (envType || envName) {
243
+ return {
244
+ ...envType ? { type: envType } : {},
245
+ ...envName ? { name: envName } : {}
246
+ };
247
+ }
248
+ const ci = firstPresent([
249
+ ["GITHUB_ACTIONS", "github_actions"],
250
+ ["GITLAB_CI", "gitlab_ci"],
251
+ ["CIRCLECI", "circleci"],
252
+ ["BUILDKITE", "buildkite"],
253
+ ["JENKINS_URL", "jenkins"],
254
+ ["JENKINS_HOME", "jenkins"],
255
+ ["TF_BUILD", "azure_pipelines"],
256
+ ["TEAMCITY_VERSION", "teamcity"],
257
+ ["TRAVIS", "travis"],
258
+ ["BITBUCKET_BUILD_NUMBER", "bitbucket"]
259
+ ]);
260
+ if (ci) return { type: "ci", name: ci };
261
+ if (isomorph_default.getEnv("CI")) return { type: "ci", name: "ci" };
262
+ const earlyServer = firstPresent([
263
+ ["VERCEL", "vercel"],
264
+ ["NETLIFY", "netlify"]
265
+ ]);
266
+ if (earlyServer) return { type: "server", name: earlyServer };
267
+ if (isomorph_default.getEnv("ECS_CONTAINER_METADATA_URI") || isomorph_default.getEnv("ECS_CONTAINER_METADATA_URI_V4")) {
268
+ return { type: "server", name: "ecs" };
269
+ }
270
+ const awsExecutionEnv = isomorph_default.getEnv("AWS_EXECUTION_ENV");
271
+ if (awsExecutionEnv?.startsWith("AWS_ECS_")) {
272
+ return { type: "server", name: "ecs" };
273
+ }
274
+ if (awsExecutionEnv?.startsWith("AWS_Lambda_")) {
275
+ return { type: "server", name: "aws_lambda" };
276
+ }
277
+ if (isomorph_default.getEnv("AWS_LAMBDA_FUNCTION_NAME")) {
278
+ return { type: "server", name: "aws_lambda" };
279
+ }
280
+ const server = firstPresent([
281
+ ["K_SERVICE", "cloud_run"],
282
+ ["FUNCTION_TARGET", "gcp_functions"],
283
+ ["KUBERNETES_SERVICE_HOST", "kubernetes"],
284
+ ["DYNO", "heroku"],
285
+ ["FLY_APP_NAME", "fly"],
286
+ ["RAILWAY_ENVIRONMENT", "railway"],
287
+ ["RENDER_SERVICE_NAME", "render"]
288
+ ]);
289
+ if (server) return { type: "server", name: server };
290
+ return deploymentModeEnvironment("NODE_ENV", isomorph_default.getEnv("NODE_ENV"));
291
+ }
292
+ function makeSpanOrigin(instrumentationName, environment) {
293
+ return {
294
+ name: "braintrust.sdk.javascript",
295
+ version: SDK_VERSION,
296
+ instrumentation: { name: instrumentationName },
297
+ ...environment ? { environment } : {}
298
+ };
299
+ }
300
+ function mergeSpanOriginContext(context, instrumentationName, environment) {
301
+ const next = { ...context ?? {} };
302
+ const current = isObject(next.span_origin) ? { ...next.span_origin } : {};
303
+ next.span_origin = {
304
+ ...makeSpanOrigin(instrumentationName, environment),
305
+ ...current
306
+ };
307
+ return next;
308
+ }
309
+ function isSpanInstrumentationName(value) {
310
+ return Object.values(INSTRUMENTATION_NAMES).some((name) => name === value);
311
+ }
312
+ function firstPresent(entries) {
313
+ return entries.find(([key]) => Boolean(isomorph_default.getEnv(key)))?.[1];
314
+ }
315
+ function deploymentModeEnvironment(_key, value) {
316
+ if (!value) return void 0;
317
+ const normalized = value.toLowerCase();
318
+ if (normalized === "production" || normalized === "staging") {
319
+ return { type: "server", name: normalized };
320
+ }
321
+ if (normalized === "development" || normalized === "local") {
322
+ return { type: "local", name: normalized };
323
+ }
324
+ return { name: value };
325
+ }
326
+ function isObject(value) {
327
+ return typeof value === "object" && value !== null && !Array.isArray(value);
328
+ }
329
+
191
330
  // src/instrumentation/core/channel-definitions.ts
192
331
  function channel(spec) {
193
332
  return spec;
194
333
  }
195
- function defineChannels(pkg, channels) {
334
+ function defineChannels(pkg, channels, options) {
335
+ const { instrumentationName } = options;
196
336
  return Object.fromEntries(
197
337
  Object.entries(channels).map(([key, spec]) => {
198
338
  const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`;
@@ -205,6 +345,7 @@ function defineChannels(pkg, channels) {
205
345
  key,
206
346
  {
207
347
  ...asyncSpec,
348
+ instrumentationName,
208
349
  tracingChannel: tracingChannel2,
209
350
  tracePromise: (fn, context) => tracingChannel2().tracePromise(
210
351
  fn,
@@ -222,6 +363,7 @@ function defineChannels(pkg, channels) {
222
363
  key,
223
364
  {
224
365
  ...syncSpec,
366
+ instrumentationName,
225
367
  tracingChannel,
226
368
  traceSync: (fn, context) => tracingChannel().traceSync(
227
369
  fn,
@@ -235,142 +377,182 @@ function defineChannels(pkg, channels) {
235
377
  }
236
378
 
237
379
  // src/instrumentation/plugins/openai-channels.ts
238
- var openAIChannels = defineChannels("openai", {
239
- chatCompletionsCreate: channel({
240
- channelName: "chat.completions.create",
241
- kind: "async"
242
- }),
243
- embeddingsCreate: channel({
244
- channelName: "embeddings.create",
245
- kind: "async"
246
- }),
247
- betaChatCompletionsParse: channel({
248
- channelName: "beta.chat.completions.parse",
249
- kind: "async"
250
- }),
251
- betaChatCompletionsStream: channel({
252
- channelName: "beta.chat.completions.stream",
253
- kind: "sync-stream"
254
- }),
255
- moderationsCreate: channel({
256
- channelName: "moderations.create",
257
- kind: "async"
258
- }),
259
- responsesCreate: channel({
260
- channelName: "responses.create",
261
- kind: "async"
262
- }),
263
- responsesStream: channel({
264
- channelName: "responses.stream",
265
- kind: "sync-stream"
266
- }),
267
- responsesParse: channel({
268
- channelName: "responses.parse",
269
- kind: "async"
270
- }),
271
- responsesCompact: channel({
272
- channelName: "responses.compact",
273
- kind: "async"
274
- })
275
- });
380
+ var openAIChannels = defineChannels(
381
+ "openai",
382
+ {
383
+ chatCompletionsCreate: channel({
384
+ channelName: "chat.completions.create",
385
+ kind: "async"
386
+ }),
387
+ embeddingsCreate: channel({
388
+ channelName: "embeddings.create",
389
+ kind: "async"
390
+ }),
391
+ betaChatCompletionsParse: channel({
392
+ channelName: "beta.chat.completions.parse",
393
+ kind: "async"
394
+ }),
395
+ betaChatCompletionsStream: channel({
396
+ channelName: "beta.chat.completions.stream",
397
+ kind: "sync-stream"
398
+ }),
399
+ moderationsCreate: channel({
400
+ channelName: "moderations.create",
401
+ kind: "async"
402
+ }),
403
+ responsesCreate: channel({
404
+ channelName: "responses.create",
405
+ kind: "async"
406
+ }),
407
+ responsesStream: channel({
408
+ channelName: "responses.stream",
409
+ kind: "sync-stream"
410
+ }),
411
+ responsesParse: channel({
412
+ channelName: "responses.parse",
413
+ kind: "async"
414
+ }),
415
+ responsesCompact: channel({
416
+ channelName: "responses.compact",
417
+ kind: "async"
418
+ })
419
+ },
420
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENAI }
421
+ );
276
422
 
277
423
  // src/instrumentation/plugins/openai-codex-channels.ts
278
- var openAICodexChannels = defineChannels("@openai/codex-sdk", {
279
- run: channel({
280
- channelName: "Thread.run",
281
- kind: "async"
282
- }),
283
- runStreamed: channel({
284
- channelName: "Thread.runStreamed",
285
- kind: "async"
286
- })
287
- });
424
+ var openAICodexChannels = defineChannels(
425
+ "@openai/codex-sdk",
426
+ {
427
+ run: channel({
428
+ channelName: "Thread.run",
429
+ kind: "async"
430
+ }),
431
+ runStreamed: channel({
432
+ channelName: "Thread.runStreamed",
433
+ kind: "async"
434
+ })
435
+ },
436
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENAI_CODEX }
437
+ );
288
438
 
289
439
  // src/instrumentation/plugins/anthropic-channels.ts
290
- var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
291
- messagesCreate: channel({
292
- channelName: "messages.create",
293
- kind: "async"
294
- }),
295
- betaMessagesCreate: channel({
296
- channelName: "beta.messages.create",
297
- kind: "async"
298
- }),
299
- betaMessagesToolRunner: channel({
300
- channelName: "beta.messages.toolRunner",
301
- kind: "sync-stream"
302
- })
303
- });
440
+ var anthropicChannels = defineChannels(
441
+ "@anthropic-ai/sdk",
442
+ {
443
+ messagesCreate: channel({
444
+ channelName: "messages.create",
445
+ kind: "async"
446
+ }),
447
+ betaMessagesCreate: channel({
448
+ channelName: "beta.messages.create",
449
+ kind: "async"
450
+ }),
451
+ betaMessagesToolRunner: channel({
452
+ channelName: "beta.messages.toolRunner",
453
+ kind: "sync-stream"
454
+ })
455
+ },
456
+ { instrumentationName: INSTRUMENTATION_NAMES.ANTHROPIC }
457
+ );
304
458
 
305
459
  // src/instrumentation/plugins/ai-sdk-channels.ts
306
- var aiSDKChannels = defineChannels("ai", {
307
- generateText: channel({
308
- channelName: "generateText",
309
- kind: "async"
310
- }),
311
- streamText: channel({
312
- channelName: "streamText",
313
- kind: "async"
314
- }),
315
- streamTextSync: channel({
316
- channelName: "streamText.sync",
317
- kind: "sync-stream"
318
- }),
319
- generateObject: channel({
320
- channelName: "generateObject",
321
- kind: "async"
322
- }),
323
- streamObject: channel({
324
- channelName: "streamObject",
325
- kind: "async"
326
- }),
327
- streamObjectSync: channel({
328
- channelName: "streamObject.sync",
329
- kind: "sync-stream"
330
- }),
331
- embed: channel(
332
- {
460
+ var aiSDKChannels = defineChannels(
461
+ "ai",
462
+ {
463
+ generateText: channel({
464
+ channelName: "generateText",
465
+ kind: "async"
466
+ }),
467
+ streamText: channel({
468
+ channelName: "streamText",
469
+ kind: "async"
470
+ }),
471
+ streamTextSync: channel({
472
+ channelName: "streamText.sync",
473
+ kind: "sync-stream"
474
+ }),
475
+ generateObject: channel({
476
+ channelName: "generateObject",
477
+ kind: "async"
478
+ }),
479
+ streamObject: channel({
480
+ channelName: "streamObject",
481
+ kind: "async"
482
+ }),
483
+ streamObjectSync: channel({
484
+ channelName: "streamObject.sync",
485
+ kind: "sync-stream"
486
+ }),
487
+ embed: channel({
333
488
  channelName: "embed",
334
489
  kind: "async"
335
- }
336
- ),
337
- embedMany: channel({
338
- channelName: "embedMany",
339
- kind: "async"
340
- }),
341
- rerank: channel({
342
- channelName: "rerank",
343
- kind: "async"
344
- }),
345
- agentGenerate: channel({
346
- channelName: "Agent.generate",
347
- kind: "async"
348
- }),
349
- agentStream: channel({
350
- channelName: "Agent.stream",
351
- kind: "async"
352
- }),
353
- agentStreamSync: channel({
354
- channelName: "Agent.stream.sync",
355
- kind: "sync-stream"
356
- }),
357
- toolLoopAgentGenerate: channel({
358
- channelName: "ToolLoopAgent.generate",
359
- kind: "async"
360
- }),
361
- toolLoopAgentStream: channel({
362
- channelName: "ToolLoopAgent.stream",
363
- kind: "async"
364
- }),
365
- workflowAgentStream: channel({
366
- channelName: "WorkflowAgent.stream",
367
- kind: "async"
368
- }),
369
- v7CreateTelemetryDispatcher: channel({
370
- channelName: "createTelemetryDispatcher",
371
- kind: "sync-stream"
372
- })
373
- });
490
+ }),
491
+ embedMany: channel({
492
+ channelName: "embedMany",
493
+ kind: "async"
494
+ }),
495
+ rerank: channel({
496
+ channelName: "rerank",
497
+ kind: "async"
498
+ }),
499
+ agentGenerate: channel({
500
+ channelName: "Agent.generate",
501
+ kind: "async"
502
+ }),
503
+ agentStream: channel({
504
+ channelName: "Agent.stream",
505
+ kind: "async"
506
+ }),
507
+ agentStreamSync: channel({
508
+ channelName: "Agent.stream.sync",
509
+ kind: "sync-stream"
510
+ }),
511
+ toolLoopAgentGenerate: channel({
512
+ channelName: "ToolLoopAgent.generate",
513
+ kind: "async"
514
+ }),
515
+ toolLoopAgentStream: channel({
516
+ channelName: "ToolLoopAgent.stream",
517
+ kind: "async"
518
+ }),
519
+ workflowAgentStream: channel({
520
+ channelName: "WorkflowAgent.stream",
521
+ kind: "async"
522
+ }),
523
+ v7CreateTelemetryDispatcher: channel({
524
+ channelName: "createTelemetryDispatcher",
525
+ kind: "sync-stream"
526
+ })
527
+ },
528
+ { instrumentationName: INSTRUMENTATION_NAMES.AI_SDK }
529
+ );
530
+ var harnessAgentChannels = defineChannels(
531
+ "@ai-sdk/harness",
532
+ {
533
+ createSession: channel({
534
+ channelName: "HarnessAgent.createSession",
535
+ kind: "async"
536
+ }),
537
+ generate: channel({
538
+ channelName: "HarnessAgent.generate",
539
+ kind: "async"
540
+ }),
541
+ stream: channel({
542
+ channelName: "HarnessAgent.stream",
543
+ kind: "async"
544
+ }),
545
+ continueGenerate: channel({
546
+ channelName: "HarnessAgent.continueGenerate",
547
+ kind: "async"
548
+ }),
549
+ continueStream: channel({
550
+ channelName: "HarnessAgent.continueStream",
551
+ kind: "async"
552
+ })
553
+ },
554
+ { instrumentationName: INSTRUMENTATION_NAMES.AI_SDK }
555
+ );
374
556
 
375
557
  // src/instrumentation/plugins/claude-agent-sdk-channels.ts
376
558
  var claudeAgentSDKChannels = defineChannels(
@@ -380,309 +562,374 @@ var claudeAgentSDKChannels = defineChannels(
380
562
  channelName: "query",
381
563
  kind: "sync-stream"
382
564
  })
383
- }
565
+ },
566
+ { instrumentationName: INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK }
384
567
  );
385
568
 
386
569
  // src/instrumentation/plugins/cursor-sdk-channels.ts
387
- var cursorSDKChannels = defineChannels("@cursor/sdk", {
388
- create: channel({
389
- channelName: "Agent.create",
390
- kind: "async"
391
- }),
392
- resume: channel({
393
- channelName: "Agent.resume",
394
- kind: "async"
395
- }),
396
- prompt: channel({
397
- channelName: "Agent.prompt",
398
- kind: "async"
399
- }),
400
- send: channel({
401
- channelName: "agent.send",
402
- kind: "async"
403
- })
404
- });
570
+ var cursorSDKChannels = defineChannels(
571
+ "@cursor/sdk",
572
+ {
573
+ create: channel({
574
+ channelName: "Agent.create",
575
+ kind: "async"
576
+ }),
577
+ resume: channel({
578
+ channelName: "Agent.resume",
579
+ kind: "async"
580
+ }),
581
+ prompt: channel({
582
+ channelName: "Agent.prompt",
583
+ kind: "async"
584
+ }),
585
+ send: channel({
586
+ channelName: "agent.send",
587
+ kind: "async"
588
+ })
589
+ },
590
+ { instrumentationName: INSTRUMENTATION_NAMES.CURSOR_SDK }
591
+ );
405
592
 
406
593
  // src/instrumentation/plugins/google-genai-channels.ts
407
- var googleGenAIChannels = defineChannels("@google/genai", {
408
- generateContent: channel({
409
- channelName: "models.generateContent",
410
- kind: "async"
411
- }),
412
- generateContentStream: channel({
413
- channelName: "models.generateContentStream",
414
- kind: "async"
415
- }),
416
- embedContent: channel({
417
- channelName: "models.embedContent",
418
- kind: "async"
419
- }),
420
- interactionsCreate: channel({
421
- channelName: "interactions.create",
422
- kind: "async"
423
- })
424
- });
594
+ var googleGenAIChannels = defineChannels(
595
+ "@google/genai",
596
+ {
597
+ generateContent: channel({
598
+ channelName: "models.generateContent",
599
+ kind: "async"
600
+ }),
601
+ generateContentStream: channel({
602
+ channelName: "models.generateContentStream",
603
+ kind: "async"
604
+ }),
605
+ embedContent: channel({
606
+ channelName: "models.embedContent",
607
+ kind: "async"
608
+ }),
609
+ interactionsCreate: channel({
610
+ channelName: "interactions.create",
611
+ kind: "async"
612
+ })
613
+ },
614
+ { instrumentationName: INSTRUMENTATION_NAMES.GOOGLE_GENAI }
615
+ );
425
616
 
426
617
  // src/instrumentation/plugins/huggingface-channels.ts
427
- var huggingFaceChannels = defineChannels("@huggingface/inference", {
428
- chatCompletion: channel({
429
- channelName: "chatCompletion",
430
- kind: "async"
431
- }),
432
- chatCompletionStream: channel({
433
- channelName: "chatCompletionStream",
434
- kind: "sync-stream"
435
- }),
436
- textGeneration: channel({
437
- channelName: "textGeneration",
438
- kind: "async"
439
- }),
440
- textGenerationStream: channel({
441
- channelName: "textGenerationStream",
442
- kind: "sync-stream"
443
- }),
444
- featureExtraction: channel({
445
- channelName: "featureExtraction",
446
- kind: "async"
447
- })
448
- });
618
+ var huggingFaceChannels = defineChannels(
619
+ "@huggingface/inference",
620
+ {
621
+ chatCompletion: channel({
622
+ channelName: "chatCompletion",
623
+ kind: "async"
624
+ }),
625
+ chatCompletionStream: channel({
626
+ channelName: "chatCompletionStream",
627
+ kind: "sync-stream"
628
+ }),
629
+ textGeneration: channel({
630
+ channelName: "textGeneration",
631
+ kind: "async"
632
+ }),
633
+ textGenerationStream: channel({
634
+ channelName: "textGenerationStream",
635
+ kind: "sync-stream"
636
+ }),
637
+ featureExtraction: channel({
638
+ channelName: "featureExtraction",
639
+ kind: "async"
640
+ })
641
+ },
642
+ { instrumentationName: INSTRUMENTATION_NAMES.HUGGINGFACE }
643
+ );
449
644
 
450
645
  // src/instrumentation/plugins/openrouter-agent-channels.ts
451
- var openRouterAgentChannels = defineChannels("@openrouter/agent", {
452
- callModel: channel({
453
- channelName: "callModel",
454
- kind: "sync-stream"
455
- }),
456
- callModelTurn: channel({
457
- channelName: "callModel.turn",
458
- kind: "async"
459
- }),
460
- toolExecute: channel({
461
- channelName: "tool.execute",
462
- kind: "async"
463
- })
464
- });
646
+ var openRouterAgentChannels = defineChannels(
647
+ "@openrouter/agent",
648
+ {
649
+ callModel: channel({
650
+ channelName: "callModel",
651
+ kind: "sync-stream"
652
+ }),
653
+ callModelTurn: channel({
654
+ channelName: "callModel.turn",
655
+ kind: "async"
656
+ }),
657
+ toolExecute: channel({
658
+ channelName: "tool.execute",
659
+ kind: "async"
660
+ })
661
+ },
662
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENROUTER_AGENT }
663
+ );
465
664
 
466
665
  // src/instrumentation/plugins/openrouter-channels.ts
467
- var openRouterChannels = defineChannels("@openrouter/sdk", {
468
- chatSend: channel({
469
- channelName: "chat.send",
470
- kind: "async"
471
- }),
472
- embeddingsGenerate: channel({
473
- channelName: "embeddings.generate",
474
- kind: "async"
475
- }),
476
- rerankRerank: channel(
477
- {
666
+ var openRouterChannels = defineChannels(
667
+ "@openrouter/sdk",
668
+ {
669
+ chatSend: channel({
670
+ channelName: "chat.send",
671
+ kind: "async"
672
+ }),
673
+ embeddingsGenerate: channel({
674
+ channelName: "embeddings.generate",
675
+ kind: "async"
676
+ }),
677
+ rerankRerank: channel({
478
678
  channelName: "rerank.rerank",
479
679
  kind: "async"
480
- }
481
- ),
482
- betaResponsesSend: channel({
483
- channelName: "beta.responses.send",
484
- kind: "async"
485
- }),
486
- callModel: channel({
487
- channelName: "callModel",
488
- kind: "sync-stream"
489
- }),
490
- callModelTurn: channel({
491
- channelName: "callModel.turn",
492
- kind: "async"
493
- }),
494
- toolExecute: channel({
495
- channelName: "tool.execute",
496
- kind: "async"
497
- })
498
- });
680
+ }),
681
+ betaResponsesSend: channel({
682
+ channelName: "beta.responses.send",
683
+ kind: "async"
684
+ }),
685
+ callModel: channel({
686
+ channelName: "callModel",
687
+ kind: "sync-stream"
688
+ }),
689
+ callModelTurn: channel({
690
+ channelName: "callModel.turn",
691
+ kind: "async"
692
+ }),
693
+ toolExecute: channel({
694
+ channelName: "tool.execute",
695
+ kind: "async"
696
+ })
697
+ },
698
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENROUTER }
699
+ );
499
700
 
500
701
  // src/instrumentation/plugins/mistral-channels.ts
501
- var mistralChannels = defineChannels("@mistralai/mistralai", {
502
- chatComplete: channel({
503
- channelName: "chat.complete",
504
- kind: "async"
505
- }),
506
- chatStream: channel({
507
- channelName: "chat.stream",
508
- kind: "async"
509
- }),
510
- embeddingsCreate: channel({
511
- channelName: "embeddings.create",
512
- kind: "async"
513
- }),
514
- classifiersModerate: channel({
515
- channelName: "classifiers.moderate",
516
- kind: "async"
517
- }),
518
- classifiersModerateChat: channel({
519
- channelName: "classifiers.moderateChat",
520
- kind: "async"
521
- }),
522
- classifiersClassify: channel({
523
- channelName: "classifiers.classify",
524
- kind: "async"
525
- }),
526
- classifiersClassifyChat: channel({
527
- channelName: "classifiers.classifyChat",
528
- kind: "async"
529
- }),
530
- fimComplete: channel({
531
- channelName: "fim.complete",
532
- kind: "async"
533
- }),
534
- fimStream: channel({
535
- channelName: "fim.stream",
536
- kind: "async"
537
- }),
538
- agentsComplete: channel({
539
- channelName: "agents.complete",
540
- kind: "async"
541
- }),
542
- agentsStream: channel({
543
- channelName: "agents.stream",
544
- kind: "async"
545
- })
546
- });
702
+ var mistralChannels = defineChannels(
703
+ "@mistralai/mistralai",
704
+ {
705
+ chatComplete: channel({
706
+ channelName: "chat.complete",
707
+ kind: "async"
708
+ }),
709
+ chatStream: channel({
710
+ channelName: "chat.stream",
711
+ kind: "async"
712
+ }),
713
+ embeddingsCreate: channel({
714
+ channelName: "embeddings.create",
715
+ kind: "async"
716
+ }),
717
+ classifiersModerate: channel({
718
+ channelName: "classifiers.moderate",
719
+ kind: "async"
720
+ }),
721
+ classifiersModerateChat: channel({
722
+ channelName: "classifiers.moderateChat",
723
+ kind: "async"
724
+ }),
725
+ classifiersClassify: channel({
726
+ channelName: "classifiers.classify",
727
+ kind: "async"
728
+ }),
729
+ classifiersClassifyChat: channel({
730
+ channelName: "classifiers.classifyChat",
731
+ kind: "async"
732
+ }),
733
+ fimComplete: channel({
734
+ channelName: "fim.complete",
735
+ kind: "async"
736
+ }),
737
+ fimStream: channel({
738
+ channelName: "fim.stream",
739
+ kind: "async"
740
+ }),
741
+ agentsComplete: channel({
742
+ channelName: "agents.complete",
743
+ kind: "async"
744
+ }),
745
+ agentsStream: channel({
746
+ channelName: "agents.stream",
747
+ kind: "async"
748
+ })
749
+ },
750
+ { instrumentationName: INSTRUMENTATION_NAMES.MISTRAL }
751
+ );
547
752
 
548
753
  // src/instrumentation/plugins/google-adk-channels.ts
549
- var googleADKChannels = defineChannels("@google/adk", {
550
- runnerRunAsync: channel({
551
- channelName: "runner.runAsync",
552
- kind: "sync-stream"
553
- }),
554
- agentRunAsync: channel({
555
- channelName: "agent.runAsync",
556
- kind: "sync-stream"
557
- }),
558
- toolRunAsync: channel({
559
- channelName: "tool.runAsync",
560
- kind: "async"
561
- })
562
- });
754
+ var googleADKChannels = defineChannels(
755
+ "@google/adk",
756
+ {
757
+ runnerRunAsync: channel({
758
+ channelName: "runner.runAsync",
759
+ kind: "sync-stream"
760
+ }),
761
+ agentRunAsync: channel({
762
+ channelName: "agent.runAsync",
763
+ kind: "sync-stream"
764
+ }),
765
+ toolRunAsync: channel({
766
+ channelName: "tool.runAsync",
767
+ kind: "async"
768
+ })
769
+ },
770
+ { instrumentationName: INSTRUMENTATION_NAMES.GOOGLE_ADK }
771
+ );
563
772
 
564
773
  // src/instrumentation/plugins/cohere-channels.ts
565
- var cohereChannels = defineChannels("cohere-ai", {
566
- chat: channel({
567
- channelName: "chat",
568
- kind: "async"
569
- }),
570
- chatStream: channel({
571
- channelName: "chatStream",
572
- kind: "async"
573
- }),
574
- embed: channel({
575
- channelName: "embed",
576
- kind: "async"
577
- }),
578
- rerank: channel({
579
- channelName: "rerank",
580
- kind: "async"
581
- })
582
- });
774
+ var cohereChannels = defineChannels(
775
+ "cohere-ai",
776
+ {
777
+ chat: channel({
778
+ channelName: "chat",
779
+ kind: "async"
780
+ }),
781
+ chatStream: channel({
782
+ channelName: "chatStream",
783
+ kind: "async"
784
+ }),
785
+ embed: channel({
786
+ channelName: "embed",
787
+ kind: "async"
788
+ }),
789
+ rerank: channel({
790
+ channelName: "rerank",
791
+ kind: "async"
792
+ })
793
+ },
794
+ { instrumentationName: INSTRUMENTATION_NAMES.COHERE }
795
+ );
583
796
 
584
797
  // src/instrumentation/plugins/groq-channels.ts
585
- var groqChannels = defineChannels("groq-sdk", {
586
- chatCompletionsCreate: channel({
587
- channelName: "chat.completions.create",
588
- kind: "async"
589
- }),
590
- embeddingsCreate: channel(
591
- {
798
+ var groqChannels = defineChannels(
799
+ "groq-sdk",
800
+ {
801
+ chatCompletionsCreate: channel({
802
+ channelName: "chat.completions.create",
803
+ kind: "async"
804
+ }),
805
+ embeddingsCreate: channel({
592
806
  channelName: "embeddings.create",
593
807
  kind: "async"
594
- }
595
- )
596
- });
808
+ })
809
+ },
810
+ { instrumentationName: INSTRUMENTATION_NAMES.GROQ }
811
+ );
597
812
 
598
813
  // src/instrumentation/plugins/bedrock-runtime-channels.ts
599
814
  var clientSendChannel = channel({
600
815
  channelName: "client.send",
601
816
  kind: "async"
602
817
  });
603
- var bedrockRuntimeChannels = defineChannels("aws-bedrock-runtime", {
604
- clientSend: clientSendChannel
605
- });
606
- var smithyCoreChannels = defineChannels("@smithy/core", {
607
- clientSend: clientSendChannel
608
- });
609
- var smithyClientChannels = defineChannels("@smithy/smithy-client", {
610
- clientSend: clientSendChannel
611
- });
818
+ var bedrockRuntimeChannels = defineChannels(
819
+ "aws-bedrock-runtime",
820
+ {
821
+ clientSend: clientSendChannel
822
+ },
823
+ { instrumentationName: INSTRUMENTATION_NAMES.BEDROCK_RUNTIME }
824
+ );
825
+ var smithyCoreChannels = defineChannels(
826
+ "@smithy/core",
827
+ {
828
+ clientSend: clientSendChannel
829
+ },
830
+ { instrumentationName: INSTRUMENTATION_NAMES.BEDROCK_RUNTIME }
831
+ );
832
+ var smithyClientChannels = defineChannels(
833
+ "@smithy/smithy-client",
834
+ {
835
+ clientSend: clientSendChannel
836
+ },
837
+ { instrumentationName: INSTRUMENTATION_NAMES.BEDROCK_RUNTIME }
838
+ );
612
839
 
613
840
  // src/instrumentation/plugins/genkit-channels.ts
614
- var genkitChannels = defineChannels("@genkit-ai/ai", {
615
- generate: channel({
616
- channelName: "generate",
617
- kind: "async"
618
- }),
619
- generateStream: channel({
620
- channelName: "generateStream",
621
- kind: "sync-stream"
622
- }),
623
- embed: channel({
624
- channelName: "embed",
625
- kind: "async"
626
- }),
627
- embedMany: channel({
628
- channelName: "embedMany",
629
- kind: "async"
630
- }),
631
- actionRun: channel({
632
- channelName: "action.run",
633
- kind: "async"
634
- }),
635
- actionStream: channel({
636
- channelName: "action.stream",
637
- kind: "sync-stream"
638
- })
639
- });
640
- var genkitCoreChannels = defineChannels("@genkit-ai/core", {
641
- actionSpan: channel({
642
- channelName: "action.span",
643
- kind: "async"
644
- })
645
- });
841
+ var genkitChannels = defineChannels(
842
+ "@genkit-ai/ai",
843
+ {
844
+ generate: channel({
845
+ channelName: "generate",
846
+ kind: "async"
847
+ }),
848
+ generateStream: channel({
849
+ channelName: "generateStream",
850
+ kind: "sync-stream"
851
+ }),
852
+ embed: channel({
853
+ channelName: "embed",
854
+ kind: "async"
855
+ }),
856
+ embedMany: channel({
857
+ channelName: "embedMany",
858
+ kind: "async"
859
+ }),
860
+ actionRun: channel({
861
+ channelName: "action.run",
862
+ kind: "async"
863
+ }),
864
+ actionStream: channel({
865
+ channelName: "action.stream",
866
+ kind: "sync-stream"
867
+ })
868
+ },
869
+ { instrumentationName: INSTRUMENTATION_NAMES.GENKIT }
870
+ );
871
+ var genkitCoreChannels = defineChannels(
872
+ "@genkit-ai/core",
873
+ {
874
+ actionSpan: channel({
875
+ channelName: "action.span",
876
+ kind: "async"
877
+ })
878
+ },
879
+ { instrumentationName: INSTRUMENTATION_NAMES.GENKIT }
880
+ );
646
881
 
647
882
  // src/instrumentation/plugins/github-copilot-channels.ts
648
- var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", {
649
- createSession: channel({
650
- channelName: "client.createSession",
651
- kind: "async"
652
- }),
653
- resumeSession: channel({
654
- channelName: "client.resumeSession",
655
- kind: "async"
656
- }),
657
- sendAndWait: channel({
658
- channelName: "session.sendAndWait",
659
- kind: "async"
660
- })
661
- });
883
+ var gitHubCopilotChannels = defineChannels(
884
+ "@github/copilot-sdk",
885
+ {
886
+ createSession: channel({
887
+ channelName: "client.createSession",
888
+ kind: "async"
889
+ }),
890
+ resumeSession: channel({
891
+ channelName: "client.resumeSession",
892
+ kind: "async"
893
+ }),
894
+ sendAndWait: channel({
895
+ channelName: "session.sendAndWait",
896
+ kind: "async"
897
+ })
898
+ },
899
+ { instrumentationName: INSTRUMENTATION_NAMES.GITHUB_COPILOT }
900
+ );
662
901
 
663
902
  // src/instrumentation/plugins/flue-channels.ts
664
- var flueChannels = defineChannels("@flue/runtime", {
665
- createContext: channel({
666
- channelName: "createFlueContext",
667
- kind: "sync-stream"
668
- })
669
- });
903
+ var flueChannels = defineChannels(
904
+ "@flue/runtime",
905
+ {
906
+ createContext: channel({
907
+ channelName: "createFlueContext",
908
+ kind: "sync-stream"
909
+ })
910
+ },
911
+ { instrumentationName: INSTRUMENTATION_NAMES.FLUE }
912
+ );
670
913
 
671
914
  // src/instrumentation/plugins/langsmith-channels.ts
672
- var langSmithChannels = defineChannels("langsmith", {
673
- createRun: channel({
674
- channelName: "Client.createRun",
675
- kind: "async"
676
- }),
677
- updateRun: channel({
678
- channelName: "Client.updateRun",
679
- kind: "async"
680
- }),
681
- batchIngestRuns: channel({
682
- channelName: "Client.batchIngestRuns",
683
- kind: "async"
684
- })
685
- });
915
+ var langSmithChannels = defineChannels(
916
+ "langsmith",
917
+ {
918
+ createRun: channel({
919
+ channelName: "Client.createRun",
920
+ kind: "async"
921
+ }),
922
+ updateRun: channel({
923
+ channelName: "Client.updateRun",
924
+ kind: "async"
925
+ }),
926
+ batchIngestRuns: channel({
927
+ channelName: "Client.batchIngestRuns",
928
+ kind: "async"
929
+ })
930
+ },
931
+ { instrumentationName: INSTRUMENTATION_NAMES.LANGSMITH }
932
+ );
686
933
 
687
934
  // src/instrumentation/plugins/pi-coding-agent-channels.ts
688
935
  var piCodingAgentChannels = defineChannels(
@@ -692,24 +939,29 @@ var piCodingAgentChannels = defineChannels(
692
939
  channelName: "AgentSession.prompt",
693
940
  kind: "async"
694
941
  })
695
- }
942
+ },
943
+ { instrumentationName: INSTRUMENTATION_NAMES.PI_CODING_AGENT }
696
944
  );
697
945
 
698
946
  // src/instrumentation/plugins/strands-agent-sdk-channels.ts
699
- var strandsAgentSDKChannels = defineChannels("@strands-agents/sdk", {
700
- agentStream: channel({
701
- channelName: "Agent.stream",
702
- kind: "sync-stream"
703
- }),
704
- graphStream: channel({
705
- channelName: "Graph.stream",
706
- kind: "sync-stream"
707
- }),
708
- swarmStream: channel({
709
- channelName: "Swarm.stream",
710
- kind: "sync-stream"
711
- })
712
- });
947
+ var strandsAgentSDKChannels = defineChannels(
948
+ "@strands-agents/sdk",
949
+ {
950
+ agentStream: channel({
951
+ channelName: "Agent.stream",
952
+ kind: "sync-stream"
953
+ }),
954
+ graphStream: channel({
955
+ channelName: "Graph.stream",
956
+ kind: "sync-stream"
957
+ }),
958
+ swarmStream: channel({
959
+ channelName: "Swarm.stream",
960
+ kind: "sync-stream"
961
+ })
962
+ },
963
+ { instrumentationName: INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK }
964
+ );
713
965
 
714
966
  // src/instrumentation/config.ts
715
967
  var envIntegrationAliases = {
@@ -1000,45 +1252,59 @@ function patchMastraSource(source, target, format) {
1000
1252
  }
1001
1253
 
1002
1254
  // src/instrumentation/plugins/openai-agents-channels.ts
1003
- var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", {
1004
- onTraceStart: channel({
1005
- channelName: "tracing.processor.onTraceStart",
1006
- kind: "async"
1007
- }),
1008
- onTraceEnd: channel({
1009
- channelName: "tracing.processor.onTraceEnd",
1010
- kind: "async"
1011
- }),
1012
- onSpanStart: channel({
1013
- channelName: "tracing.processor.onSpanStart",
1014
- kind: "async"
1015
- }),
1016
- onSpanEnd: channel({
1017
- channelName: "tracing.processor.onSpanEnd",
1018
- kind: "async"
1019
- })
1020
- });
1255
+ var openAIAgentsCoreChannels = defineChannels(
1256
+ "@openai/agents-core",
1257
+ {
1258
+ onTraceStart: channel({
1259
+ channelName: "tracing.processor.onTraceStart",
1260
+ kind: "async"
1261
+ }),
1262
+ onTraceEnd: channel({
1263
+ channelName: "tracing.processor.onTraceEnd",
1264
+ kind: "async"
1265
+ }),
1266
+ onSpanStart: channel({
1267
+ channelName: "tracing.processor.onSpanStart",
1268
+ kind: "async"
1269
+ }),
1270
+ onSpanEnd: channel({
1271
+ channelName: "tracing.processor.onSpanEnd",
1272
+ kind: "async"
1273
+ })
1274
+ },
1275
+ { instrumentationName: INSTRUMENTATION_NAMES.OPENAI_AGENTS }
1276
+ );
1021
1277
 
1022
1278
  // src/instrumentation/plugins/langchain-channels.ts
1023
- var langChainChannels = defineChannels("@langchain/core", {
1024
- configure: channel({
1025
- channelName: "CallbackManager.configure",
1026
- kind: "sync-stream"
1027
- }),
1028
- configureSync: channel({
1029
- channelName: "CallbackManager._configureSync",
1030
- kind: "sync-stream"
1031
- })
1032
- });
1279
+ var langChainChannels = defineChannels(
1280
+ "@langchain/core",
1281
+ {
1282
+ configure: channel({
1283
+ channelName: "CallbackManager.configure",
1284
+ kind: "sync-stream"
1285
+ }),
1286
+ configureSync: channel({
1287
+ channelName: "CallbackManager._configureSync",
1288
+ kind: "sync-stream"
1289
+ })
1290
+ },
1291
+ { instrumentationName: INSTRUMENTATION_NAMES.LANGCHAIN }
1292
+ );
1033
1293
 
1034
1294
  export {
1035
1295
  __export,
1036
1296
  patchTracingChannel,
1037
1297
  isomorph_default,
1298
+ INSTRUMENTATION_NAMES,
1299
+ withSpanInstrumentationName,
1300
+ getSpanInstrumentationName,
1301
+ detectSpanOriginEnvironment,
1302
+ mergeSpanOriginContext,
1038
1303
  openAIChannels,
1039
1304
  openAICodexChannels,
1040
1305
  anthropicChannels,
1041
1306
  aiSDKChannels,
1307
+ harnessAgentChannels,
1042
1308
  claudeAgentSDKChannels,
1043
1309
  cursorSDKChannels,
1044
1310
  openAIAgentsCoreChannels,