braintrust 3.24.0 → 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 (47) hide show
  1. package/dev/dist/index.d.mts +5 -0
  2. package/dev/dist/index.d.ts +5 -0
  3. package/dev/dist/index.js +2614 -1567
  4. package/dev/dist/index.mjs +2037 -990
  5. package/dist/apply-auto-instrumentation.js +200 -199
  6. package/dist/apply-auto-instrumentation.mjs +8 -7
  7. package/dist/auto-instrumentations/bundler/esbuild.cjs +596 -462
  8. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/next.cjs +596 -462
  10. package/dist/auto-instrumentations/bundler/next.mjs +3 -3
  11. package/dist/auto-instrumentations/bundler/rollup.cjs +596 -462
  12. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  13. package/dist/auto-instrumentations/bundler/vite.cjs +596 -462
  14. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  15. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +596 -462
  16. package/dist/auto-instrumentations/bundler/webpack.cjs +596 -462
  17. package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
  18. package/dist/auto-instrumentations/{chunk-BURMPO7L.mjs → chunk-7P6563SW.mjs} +1 -1
  19. package/dist/auto-instrumentations/{chunk-F43DNLPD.mjs → chunk-CZ24KNHT.mjs} +569 -442
  20. package/dist/auto-instrumentations/{chunk-GSZHTAQW.mjs → chunk-JPVCUKTY.mjs} +30 -21
  21. package/dist/auto-instrumentations/hook.mjs +648 -476
  22. package/dist/auto-instrumentations/index.cjs +568 -442
  23. package/dist/auto-instrumentations/index.mjs +1 -1
  24. package/dist/browser.d.mts +7 -0
  25. package/dist/browser.d.ts +7 -0
  26. package/dist/browser.js +2022 -971
  27. package/dist/browser.mjs +2022 -971
  28. package/dist/{chunk-XE5FS7QY.mjs → chunk-2SANLSWX.mjs} +1375 -597
  29. package/dist/{chunk-7F6GCRHH.mjs → chunk-ABR2QWDP.mjs} +702 -456
  30. package/dist/{chunk-SU6EHKJV.js → chunk-GSIDVFE6.js} +2176 -1398
  31. package/dist/{chunk-7AUY2XWX.js → chunk-P25IOOU4.js} +704 -458
  32. package/dist/cli.js +2005 -958
  33. package/dist/edge-light.js +2022 -971
  34. package/dist/edge-light.mjs +2022 -971
  35. package/dist/index.d.mts +7 -0
  36. package/dist/index.d.ts +7 -0
  37. package/dist/index.js +447 -402
  38. package/dist/index.mjs +72 -27
  39. package/dist/instrumentation/index.d.mts +5 -0
  40. package/dist/instrumentation/index.d.ts +5 -0
  41. package/dist/instrumentation/index.js +1990 -981
  42. package/dist/instrumentation/index.mjs +1990 -981
  43. package/dist/vitest-evals-reporter.js +16 -16
  44. package/dist/vitest-evals-reporter.mjs +2 -2
  45. package/dist/workerd.js +2022 -971
  46. package/dist/workerd.mjs +2022 -971
  47. package/package.json +2 -2
@@ -189,11 +189,150 @@ var iso = {
189
189
  };
190
190
  var isomorph_default = iso;
191
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
+
192
330
  // src/instrumentation/core/channel-definitions.ts
193
331
  function channel(spec) {
194
332
  return spec;
195
333
  }
196
- function defineChannels(pkg, channels) {
334
+ function defineChannels(pkg, channels, options) {
335
+ const { instrumentationName } = options;
197
336
  return Object.fromEntries(
198
337
  Object.entries(channels).map(([key, spec]) => {
199
338
  const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`;
@@ -206,6 +345,7 @@ function defineChannels(pkg, channels) {
206
345
  key,
207
346
  {
208
347
  ...asyncSpec,
348
+ instrumentationName,
209
349
  tracingChannel: tracingChannel2,
210
350
  tracePromise: (fn, context) => tracingChannel2().tracePromise(
211
351
  fn,
@@ -223,6 +363,7 @@ function defineChannels(pkg, channels) {
223
363
  key,
224
364
  {
225
365
  ...syncSpec,
366
+ instrumentationName,
226
367
  tracingChannel,
227
368
  traceSync: (fn, context) => tracingChannel().traceSync(
228
369
  fn,
@@ -236,160 +377,182 @@ function defineChannels(pkg, channels) {
236
377
  }
237
378
 
238
379
  // src/instrumentation/plugins/openai-channels.ts
239
- var openAIChannels = defineChannels("openai", {
240
- chatCompletionsCreate: channel({
241
- channelName: "chat.completions.create",
242
- kind: "async"
243
- }),
244
- embeddingsCreate: channel({
245
- channelName: "embeddings.create",
246
- kind: "async"
247
- }),
248
- betaChatCompletionsParse: channel({
249
- channelName: "beta.chat.completions.parse",
250
- kind: "async"
251
- }),
252
- betaChatCompletionsStream: channel({
253
- channelName: "beta.chat.completions.stream",
254
- kind: "sync-stream"
255
- }),
256
- moderationsCreate: channel({
257
- channelName: "moderations.create",
258
- kind: "async"
259
- }),
260
- responsesCreate: channel({
261
- channelName: "responses.create",
262
- kind: "async"
263
- }),
264
- responsesStream: channel({
265
- channelName: "responses.stream",
266
- kind: "sync-stream"
267
- }),
268
- responsesParse: channel({
269
- channelName: "responses.parse",
270
- kind: "async"
271
- }),
272
- responsesCompact: channel({
273
- channelName: "responses.compact",
274
- kind: "async"
275
- })
276
- });
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
+ );
277
422
 
278
423
  // src/instrumentation/plugins/openai-codex-channels.ts
279
- var openAICodexChannels = defineChannels("@openai/codex-sdk", {
280
- run: channel({
281
- channelName: "Thread.run",
282
- kind: "async"
283
- }),
284
- runStreamed: channel({
285
- channelName: "Thread.runStreamed",
286
- kind: "async"
287
- })
288
- });
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
+ );
289
438
 
290
439
  // src/instrumentation/plugins/anthropic-channels.ts
291
- var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
292
- messagesCreate: channel({
293
- channelName: "messages.create",
294
- kind: "async"
295
- }),
296
- betaMessagesCreate: channel({
297
- channelName: "beta.messages.create",
298
- kind: "async"
299
- }),
300
- betaMessagesToolRunner: channel({
301
- channelName: "beta.messages.toolRunner",
302
- kind: "sync-stream"
303
- })
304
- });
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
+ );
305
458
 
306
459
  // src/instrumentation/plugins/ai-sdk-channels.ts
307
- var aiSDKChannels = defineChannels("ai", {
308
- generateText: channel({
309
- channelName: "generateText",
310
- kind: "async"
311
- }),
312
- streamText: channel({
313
- channelName: "streamText",
314
- kind: "async"
315
- }),
316
- streamTextSync: channel({
317
- channelName: "streamText.sync",
318
- kind: "sync-stream"
319
- }),
320
- generateObject: channel({
321
- channelName: "generateObject",
322
- kind: "async"
323
- }),
324
- streamObject: channel({
325
- channelName: "streamObject",
326
- kind: "async"
327
- }),
328
- streamObjectSync: channel({
329
- channelName: "streamObject.sync",
330
- kind: "sync-stream"
331
- }),
332
- embed: channel(
333
- {
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({
334
488
  channelName: "embed",
335
489
  kind: "async"
336
- }
337
- ),
338
- embedMany: channel({
339
- channelName: "embedMany",
340
- kind: "async"
341
- }),
342
- rerank: channel({
343
- channelName: "rerank",
344
- kind: "async"
345
- }),
346
- agentGenerate: channel({
347
- channelName: "Agent.generate",
348
- kind: "async"
349
- }),
350
- agentStream: channel({
351
- channelName: "Agent.stream",
352
- kind: "async"
353
- }),
354
- agentStreamSync: channel({
355
- channelName: "Agent.stream.sync",
356
- kind: "sync-stream"
357
- }),
358
- toolLoopAgentGenerate: channel({
359
- channelName: "ToolLoopAgent.generate",
360
- kind: "async"
361
- }),
362
- toolLoopAgentStream: channel({
363
- channelName: "ToolLoopAgent.stream",
364
- kind: "async"
365
- }),
366
- workflowAgentStream: channel({
367
- channelName: "WorkflowAgent.stream",
368
- kind: "async"
369
- }),
370
- v7CreateTelemetryDispatcher: channel({
371
- channelName: "createTelemetryDispatcher",
372
- kind: "sync-stream"
373
- })
374
- });
375
- var harnessAgentChannels = defineChannels("@ai-sdk/harness", {
376
- generate: channel({
377
- channelName: "HarnessAgent.generate",
378
- kind: "async"
379
- }),
380
- stream: channel({
381
- channelName: "HarnessAgent.stream",
382
- kind: "async"
383
- }),
384
- continueGenerate: channel({
385
- channelName: "HarnessAgent.continueGenerate",
386
- kind: "async"
387
- }),
388
- continueStream: channel({
389
- channelName: "HarnessAgent.continueStream",
390
- kind: "async"
391
- })
392
- });
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
+ );
393
556
 
394
557
  // src/instrumentation/plugins/claude-agent-sdk-channels.ts
395
558
  var claudeAgentSDKChannels = defineChannels(
@@ -399,309 +562,374 @@ var claudeAgentSDKChannels = defineChannels(
399
562
  channelName: "query",
400
563
  kind: "sync-stream"
401
564
  })
402
- }
565
+ },
566
+ { instrumentationName: INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK }
403
567
  );
404
568
 
405
569
  // src/instrumentation/plugins/cursor-sdk-channels.ts
406
- var cursorSDKChannels = defineChannels("@cursor/sdk", {
407
- create: channel({
408
- channelName: "Agent.create",
409
- kind: "async"
410
- }),
411
- resume: channel({
412
- channelName: "Agent.resume",
413
- kind: "async"
414
- }),
415
- prompt: channel({
416
- channelName: "Agent.prompt",
417
- kind: "async"
418
- }),
419
- send: channel({
420
- channelName: "agent.send",
421
- kind: "async"
422
- })
423
- });
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
+ );
424
592
 
425
593
  // src/instrumentation/plugins/google-genai-channels.ts
426
- var googleGenAIChannels = defineChannels("@google/genai", {
427
- generateContent: channel({
428
- channelName: "models.generateContent",
429
- kind: "async"
430
- }),
431
- generateContentStream: channel({
432
- channelName: "models.generateContentStream",
433
- kind: "async"
434
- }),
435
- embedContent: channel({
436
- channelName: "models.embedContent",
437
- kind: "async"
438
- }),
439
- interactionsCreate: channel({
440
- channelName: "interactions.create",
441
- kind: "async"
442
- })
443
- });
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
+ );
444
616
 
445
617
  // src/instrumentation/plugins/huggingface-channels.ts
446
- var huggingFaceChannels = defineChannels("@huggingface/inference", {
447
- chatCompletion: channel({
448
- channelName: "chatCompletion",
449
- kind: "async"
450
- }),
451
- chatCompletionStream: channel({
452
- channelName: "chatCompletionStream",
453
- kind: "sync-stream"
454
- }),
455
- textGeneration: channel({
456
- channelName: "textGeneration",
457
- kind: "async"
458
- }),
459
- textGenerationStream: channel({
460
- channelName: "textGenerationStream",
461
- kind: "sync-stream"
462
- }),
463
- featureExtraction: channel({
464
- channelName: "featureExtraction",
465
- kind: "async"
466
- })
467
- });
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
+ );
468
644
 
469
645
  // src/instrumentation/plugins/openrouter-agent-channels.ts
470
- var openRouterAgentChannels = defineChannels("@openrouter/agent", {
471
- callModel: channel({
472
- channelName: "callModel",
473
- kind: "sync-stream"
474
- }),
475
- callModelTurn: channel({
476
- channelName: "callModel.turn",
477
- kind: "async"
478
- }),
479
- toolExecute: channel({
480
- channelName: "tool.execute",
481
- kind: "async"
482
- })
483
- });
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
+ );
484
664
 
485
665
  // src/instrumentation/plugins/openrouter-channels.ts
486
- var openRouterChannels = defineChannels("@openrouter/sdk", {
487
- chatSend: channel({
488
- channelName: "chat.send",
489
- kind: "async"
490
- }),
491
- embeddingsGenerate: channel({
492
- channelName: "embeddings.generate",
493
- kind: "async"
494
- }),
495
- rerankRerank: channel(
496
- {
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({
497
678
  channelName: "rerank.rerank",
498
679
  kind: "async"
499
- }
500
- ),
501
- betaResponsesSend: channel({
502
- channelName: "beta.responses.send",
503
- kind: "async"
504
- }),
505
- callModel: channel({
506
- channelName: "callModel",
507
- kind: "sync-stream"
508
- }),
509
- callModelTurn: channel({
510
- channelName: "callModel.turn",
511
- kind: "async"
512
- }),
513
- toolExecute: channel({
514
- channelName: "tool.execute",
515
- kind: "async"
516
- })
517
- });
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
+ );
518
700
 
519
701
  // src/instrumentation/plugins/mistral-channels.ts
520
- var mistralChannels = defineChannels("@mistralai/mistralai", {
521
- chatComplete: channel({
522
- channelName: "chat.complete",
523
- kind: "async"
524
- }),
525
- chatStream: channel({
526
- channelName: "chat.stream",
527
- kind: "async"
528
- }),
529
- embeddingsCreate: channel({
530
- channelName: "embeddings.create",
531
- kind: "async"
532
- }),
533
- classifiersModerate: channel({
534
- channelName: "classifiers.moderate",
535
- kind: "async"
536
- }),
537
- classifiersModerateChat: channel({
538
- channelName: "classifiers.moderateChat",
539
- kind: "async"
540
- }),
541
- classifiersClassify: channel({
542
- channelName: "classifiers.classify",
543
- kind: "async"
544
- }),
545
- classifiersClassifyChat: channel({
546
- channelName: "classifiers.classifyChat",
547
- kind: "async"
548
- }),
549
- fimComplete: channel({
550
- channelName: "fim.complete",
551
- kind: "async"
552
- }),
553
- fimStream: channel({
554
- channelName: "fim.stream",
555
- kind: "async"
556
- }),
557
- agentsComplete: channel({
558
- channelName: "agents.complete",
559
- kind: "async"
560
- }),
561
- agentsStream: channel({
562
- channelName: "agents.stream",
563
- kind: "async"
564
- })
565
- });
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
+ );
566
752
 
567
753
  // src/instrumentation/plugins/google-adk-channels.ts
568
- var googleADKChannels = defineChannels("@google/adk", {
569
- runnerRunAsync: channel({
570
- channelName: "runner.runAsync",
571
- kind: "sync-stream"
572
- }),
573
- agentRunAsync: channel({
574
- channelName: "agent.runAsync",
575
- kind: "sync-stream"
576
- }),
577
- toolRunAsync: channel({
578
- channelName: "tool.runAsync",
579
- kind: "async"
580
- })
581
- });
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
+ );
582
772
 
583
773
  // src/instrumentation/plugins/cohere-channels.ts
584
- var cohereChannels = defineChannels("cohere-ai", {
585
- chat: channel({
586
- channelName: "chat",
587
- kind: "async"
588
- }),
589
- chatStream: channel({
590
- channelName: "chatStream",
591
- kind: "async"
592
- }),
593
- embed: channel({
594
- channelName: "embed",
595
- kind: "async"
596
- }),
597
- rerank: channel({
598
- channelName: "rerank",
599
- kind: "async"
600
- })
601
- });
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
+ );
602
796
 
603
797
  // src/instrumentation/plugins/groq-channels.ts
604
- var groqChannels = defineChannels("groq-sdk", {
605
- chatCompletionsCreate: channel({
606
- channelName: "chat.completions.create",
607
- kind: "async"
608
- }),
609
- embeddingsCreate: channel(
610
- {
798
+ var groqChannels = defineChannels(
799
+ "groq-sdk",
800
+ {
801
+ chatCompletionsCreate: channel({
802
+ channelName: "chat.completions.create",
803
+ kind: "async"
804
+ }),
805
+ embeddingsCreate: channel({
611
806
  channelName: "embeddings.create",
612
807
  kind: "async"
613
- }
614
- )
615
- });
808
+ })
809
+ },
810
+ { instrumentationName: INSTRUMENTATION_NAMES.GROQ }
811
+ );
616
812
 
617
813
  // src/instrumentation/plugins/bedrock-runtime-channels.ts
618
814
  var clientSendChannel = channel({
619
815
  channelName: "client.send",
620
816
  kind: "async"
621
817
  });
622
- var bedrockRuntimeChannels = defineChannels("aws-bedrock-runtime", {
623
- clientSend: clientSendChannel
624
- });
625
- var smithyCoreChannels = defineChannels("@smithy/core", {
626
- clientSend: clientSendChannel
627
- });
628
- var smithyClientChannels = defineChannels("@smithy/smithy-client", {
629
- clientSend: clientSendChannel
630
- });
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
+ );
631
839
 
632
840
  // src/instrumentation/plugins/genkit-channels.ts
633
- var genkitChannels = defineChannels("@genkit-ai/ai", {
634
- generate: channel({
635
- channelName: "generate",
636
- kind: "async"
637
- }),
638
- generateStream: channel({
639
- channelName: "generateStream",
640
- kind: "sync-stream"
641
- }),
642
- embed: channel({
643
- channelName: "embed",
644
- kind: "async"
645
- }),
646
- embedMany: channel({
647
- channelName: "embedMany",
648
- kind: "async"
649
- }),
650
- actionRun: channel({
651
- channelName: "action.run",
652
- kind: "async"
653
- }),
654
- actionStream: channel({
655
- channelName: "action.stream",
656
- kind: "sync-stream"
657
- })
658
- });
659
- var genkitCoreChannels = defineChannels("@genkit-ai/core", {
660
- actionSpan: channel({
661
- channelName: "action.span",
662
- kind: "async"
663
- })
664
- });
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
+ );
665
881
 
666
882
  // src/instrumentation/plugins/github-copilot-channels.ts
667
- var gitHubCopilotChannels = defineChannels("@github/copilot-sdk", {
668
- createSession: channel({
669
- channelName: "client.createSession",
670
- kind: "async"
671
- }),
672
- resumeSession: channel({
673
- channelName: "client.resumeSession",
674
- kind: "async"
675
- }),
676
- sendAndWait: channel({
677
- channelName: "session.sendAndWait",
678
- kind: "async"
679
- })
680
- });
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
+ );
681
901
 
682
902
  // src/instrumentation/plugins/flue-channels.ts
683
- var flueChannels = defineChannels("@flue/runtime", {
684
- createContext: channel({
685
- channelName: "createFlueContext",
686
- kind: "sync-stream"
687
- })
688
- });
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
+ );
689
913
 
690
914
  // src/instrumentation/plugins/langsmith-channels.ts
691
- var langSmithChannels = defineChannels("langsmith", {
692
- createRun: channel({
693
- channelName: "Client.createRun",
694
- kind: "async"
695
- }),
696
- updateRun: channel({
697
- channelName: "Client.updateRun",
698
- kind: "async"
699
- }),
700
- batchIngestRuns: channel({
701
- channelName: "Client.batchIngestRuns",
702
- kind: "async"
703
- })
704
- });
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
+ );
705
933
 
706
934
  // src/instrumentation/plugins/pi-coding-agent-channels.ts
707
935
  var piCodingAgentChannels = defineChannels(
@@ -711,24 +939,29 @@ var piCodingAgentChannels = defineChannels(
711
939
  channelName: "AgentSession.prompt",
712
940
  kind: "async"
713
941
  })
714
- }
942
+ },
943
+ { instrumentationName: INSTRUMENTATION_NAMES.PI_CODING_AGENT }
715
944
  );
716
945
 
717
946
  // src/instrumentation/plugins/strands-agent-sdk-channels.ts
718
- var strandsAgentSDKChannels = defineChannels("@strands-agents/sdk", {
719
- agentStream: channel({
720
- channelName: "Agent.stream",
721
- kind: "sync-stream"
722
- }),
723
- graphStream: channel({
724
- channelName: "Graph.stream",
725
- kind: "sync-stream"
726
- }),
727
- swarmStream: channel({
728
- channelName: "Swarm.stream",
729
- kind: "sync-stream"
730
- })
731
- });
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
+ );
732
965
 
733
966
  // src/instrumentation/config.ts
734
967
  var envIntegrationAliases = {
@@ -1019,41 +1252,54 @@ function patchMastraSource(source, target, format) {
1019
1252
  }
1020
1253
 
1021
1254
  // src/instrumentation/plugins/openai-agents-channels.ts
1022
- var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", {
1023
- onTraceStart: channel({
1024
- channelName: "tracing.processor.onTraceStart",
1025
- kind: "async"
1026
- }),
1027
- onTraceEnd: channel({
1028
- channelName: "tracing.processor.onTraceEnd",
1029
- kind: "async"
1030
- }),
1031
- onSpanStart: channel({
1032
- channelName: "tracing.processor.onSpanStart",
1033
- kind: "async"
1034
- }),
1035
- onSpanEnd: channel({
1036
- channelName: "tracing.processor.onSpanEnd",
1037
- kind: "async"
1038
- })
1039
- });
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
+ );
1040
1277
 
1041
1278
  // src/instrumentation/plugins/langchain-channels.ts
1042
- var langChainChannels = defineChannels("@langchain/core", {
1043
- configure: channel({
1044
- channelName: "CallbackManager.configure",
1045
- kind: "sync-stream"
1046
- }),
1047
- configureSync: channel({
1048
- channelName: "CallbackManager._configureSync",
1049
- kind: "sync-stream"
1050
- })
1051
- });
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
+ );
1052
1293
 
1053
1294
  export {
1054
1295
  __export,
1055
1296
  patchTracingChannel,
1056
1297
  isomorph_default,
1298
+ INSTRUMENTATION_NAMES,
1299
+ withSpanInstrumentationName,
1300
+ getSpanInstrumentationName,
1301
+ detectSpanOriginEnvironment,
1302
+ mergeSpanOriginContext,
1057
1303
  openAIChannels,
1058
1304
  openAICodexChannels,
1059
1305
  anthropicChannels,