braintrust 3.6.0 → 3.7.1
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/dev/dist/index.js +2692 -1472
- package/dev/dist/index.mjs +2616 -1396
- package/dist/auto-instrumentations/bundler/esbuild.cjs +46 -21
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/rollup.cjs +46 -21
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +46 -21
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +952 -0
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +53 -0
- package/dist/auto-instrumentations/bundler/webpack.cjs +46 -21
- package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
- package/dist/auto-instrumentations/{chunk-WOUC73KB.mjs → chunk-NY4CGTN6.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-F7WAXFNM.mjs → chunk-YCKND42U.mjs} +46 -21
- package/dist/auto-instrumentations/hook.mjs +77 -26
- package/dist/auto-instrumentations/index.cjs +46 -21
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/browser.d.mts +8 -30
- package/dist/browser.d.ts +8 -30
- package/dist/browser.js +5051 -6344
- package/dist/browser.mjs +5051 -6344
- package/dist/cli.js +2622 -1398
- package/dist/edge-light.js +9456 -10773
- package/dist/edge-light.mjs +9456 -10773
- package/dist/index.d.mts +8 -30
- package/dist/index.d.ts +8 -30
- package/dist/index.js +5078 -6371
- package/dist/index.mjs +4870 -6163
- package/dist/instrumentation/index.js +2491 -1319
- package/dist/instrumentation/index.mjs +2491 -1319
- package/dist/workerd.js +9456 -10773
- package/dist/workerd.mjs +9456 -10773
- package/package.json +6 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { InstrumentationConfig } from '@apm-js-collab/code-transformer';
|
|
2
|
+
|
|
3
|
+
interface BundlerPluginOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Enable debug logging
|
|
6
|
+
*/
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Additional instrumentation configs to apply
|
|
10
|
+
*/
|
|
11
|
+
instrumentations?: InstrumentationConfig[];
|
|
12
|
+
/**
|
|
13
|
+
* Whether to bundle for browser environments.
|
|
14
|
+
*
|
|
15
|
+
* When true, uses 'dc-browser' for browser-compatible diagnostics_channel polyfill.
|
|
16
|
+
* When false, uses Node.js built-in 'diagnostics_channel' and 'async_hooks'.
|
|
17
|
+
* Defaults to true (assumes browser build).
|
|
18
|
+
*/
|
|
19
|
+
browser?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Webpack loader for auto-instrumentation.
|
|
24
|
+
*
|
|
25
|
+
* This is a webpack loader (not a plugin) for compatibility with tools that only support loaders,
|
|
26
|
+
* such as Next.js Turbopack. Unlike the other exports in this package, this does not use unplugin.
|
|
27
|
+
*
|
|
28
|
+
* Usage in next.config.js / next.config.ts:
|
|
29
|
+
* ```javascript
|
|
30
|
+
* export default {
|
|
31
|
+
* webpack(config) {
|
|
32
|
+
* config.module.rules.unshift({
|
|
33
|
+
* use: [{ loader: 'braintrust/webpack-loader' }],
|
|
34
|
+
* });
|
|
35
|
+
* return config;
|
|
36
|
+
* },
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* For browser builds, the loader automatically uses 'dc-browser' for diagnostics_channel polyfill.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Webpack loader that instruments JavaScript code using code-transformer.
|
|
45
|
+
*
|
|
46
|
+
* Accepts the same options as the webpack plugin (BundlerPluginOptions).
|
|
47
|
+
*/
|
|
48
|
+
declare function codeTransformerLoader(this: any, code: string, inputSourceMap?: any): void;
|
|
49
|
+
declare namespace codeTransformerLoader {
|
|
50
|
+
type Options = BundlerPluginOptions;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { codeTransformerLoader as default };
|
|
@@ -114,7 +114,7 @@ var DefaultTracingChannel = class {
|
|
|
114
114
|
}
|
|
115
115
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
116
|
tracePromise(fn, _message, thisArg, ...args) {
|
|
117
|
-
return
|
|
117
|
+
return fn.apply(thisArg, args);
|
|
118
118
|
}
|
|
119
119
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
120
|
traceCallback(fn, _position, _message, thisArg, ...args) {
|
|
@@ -134,6 +134,7 @@ var iso = {
|
|
|
134
134
|
processOn: (_0, _1) => {
|
|
135
135
|
},
|
|
136
136
|
basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
|
|
137
|
+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
|
|
137
138
|
writeln: (text) => console.log(text)
|
|
138
139
|
};
|
|
139
140
|
var isomorph_default = iso;
|
|
@@ -400,12 +401,26 @@ var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
|
|
|
400
401
|
|
|
401
402
|
// src/auto-instrumentations/configs/anthropic.ts
|
|
402
403
|
var anthropicConfigs = [
|
|
404
|
+
// Messages API - create in older SDK layouts (supports streaming via stream=true parameter)
|
|
405
|
+
{
|
|
406
|
+
channelName: anthropicChannels.messagesCreate.channelName,
|
|
407
|
+
module: {
|
|
408
|
+
name: "@anthropic-ai/sdk",
|
|
409
|
+
versionRange: ">=0.27.0 <0.39.0",
|
|
410
|
+
filePath: "resources/messages.mjs"
|
|
411
|
+
},
|
|
412
|
+
functionQuery: {
|
|
413
|
+
className: "Messages",
|
|
414
|
+
methodName: "create",
|
|
415
|
+
kind: "Async"
|
|
416
|
+
}
|
|
417
|
+
},
|
|
403
418
|
// Messages API - create (supports streaming via stream=true parameter)
|
|
404
419
|
{
|
|
405
420
|
channelName: anthropicChannels.messagesCreate.channelName,
|
|
406
421
|
module: {
|
|
407
422
|
name: "@anthropic-ai/sdk",
|
|
408
|
-
versionRange: ">=0.
|
|
423
|
+
versionRange: ">=0.39.0",
|
|
409
424
|
filePath: "resources/messages/messages.mjs"
|
|
410
425
|
},
|
|
411
426
|
functionQuery: {
|
|
@@ -419,7 +434,7 @@ var anthropicConfigs = [
|
|
|
419
434
|
channelName: anthropicChannels.betaMessagesCreate.channelName,
|
|
420
435
|
module: {
|
|
421
436
|
name: "@anthropic-ai/sdk",
|
|
422
|
-
versionRange: ">=0.
|
|
437
|
+
versionRange: ">=0.39.0",
|
|
423
438
|
filePath: "resources/beta/messages/messages.mjs"
|
|
424
439
|
},
|
|
425
440
|
functionQuery: {
|
|
@@ -440,10 +455,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
440
455
|
channelName: "streamText",
|
|
441
456
|
kind: "async"
|
|
442
457
|
}),
|
|
443
|
-
streamTextSync: channel({
|
|
444
|
-
channelName: "streamText.sync",
|
|
445
|
-
kind: "sync-stream"
|
|
446
|
-
}),
|
|
447
458
|
generateObject: channel({
|
|
448
459
|
channelName: "generateObject",
|
|
449
460
|
kind: "async"
|
|
@@ -452,10 +463,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
452
463
|
channelName: "streamObject",
|
|
453
464
|
kind: "async"
|
|
454
465
|
}),
|
|
455
|
-
streamObjectSync: channel({
|
|
456
|
-
channelName: "streamObject.sync",
|
|
457
|
-
kind: "sync-stream"
|
|
458
|
-
}),
|
|
459
466
|
agentGenerate: channel({
|
|
460
467
|
channelName: "Agent.generate",
|
|
461
468
|
kind: "async"
|
|
@@ -501,7 +508,7 @@ var aiSDKConfigs = [
|
|
|
501
508
|
kind: "Async"
|
|
502
509
|
}
|
|
503
510
|
},
|
|
504
|
-
// streamText -
|
|
511
|
+
// streamText - function returning stream
|
|
505
512
|
{
|
|
506
513
|
channelName: aiSDKChannels.streamText.channelName,
|
|
507
514
|
module: {
|
|
@@ -515,7 +522,7 @@ var aiSDKConfigs = [
|
|
|
515
522
|
}
|
|
516
523
|
},
|
|
517
524
|
{
|
|
518
|
-
channelName: aiSDKChannels.
|
|
525
|
+
channelName: aiSDKChannels.streamText.channelName,
|
|
519
526
|
module: {
|
|
520
527
|
name: "ai",
|
|
521
528
|
versionRange: ">=3.0.0",
|
|
@@ -523,7 +530,7 @@ var aiSDKConfigs = [
|
|
|
523
530
|
},
|
|
524
531
|
functionQuery: {
|
|
525
532
|
functionName: "streamText",
|
|
526
|
-
kind: "
|
|
533
|
+
kind: "Async"
|
|
527
534
|
}
|
|
528
535
|
},
|
|
529
536
|
// generateObject - async function
|
|
@@ -551,7 +558,7 @@ var aiSDKConfigs = [
|
|
|
551
558
|
kind: "Async"
|
|
552
559
|
}
|
|
553
560
|
},
|
|
554
|
-
// streamObject -
|
|
561
|
+
// streamObject - function returning stream
|
|
555
562
|
{
|
|
556
563
|
channelName: aiSDKChannels.streamObject.channelName,
|
|
557
564
|
module: {
|
|
@@ -565,7 +572,7 @@ var aiSDKConfigs = [
|
|
|
565
572
|
}
|
|
566
573
|
},
|
|
567
574
|
{
|
|
568
|
-
channelName: aiSDKChannels.
|
|
575
|
+
channelName: aiSDKChannels.streamObject.channelName,
|
|
569
576
|
module: {
|
|
570
577
|
name: "ai",
|
|
571
578
|
versionRange: ">=3.0.0",
|
|
@@ -573,7 +580,7 @@ var aiSDKConfigs = [
|
|
|
573
580
|
},
|
|
574
581
|
functionQuery: {
|
|
575
582
|
functionName: "streamObject",
|
|
576
|
-
kind: "
|
|
583
|
+
kind: "Async"
|
|
577
584
|
}
|
|
578
585
|
},
|
|
579
586
|
// Agent.generate - async method (v5 only)
|
|
@@ -700,24 +707,38 @@ var claudeAgentSDKChannels = defineChannels(
|
|
|
700
707
|
{
|
|
701
708
|
query: channel({
|
|
702
709
|
channelName: "query",
|
|
703
|
-
kind: "
|
|
710
|
+
kind: "sync-stream"
|
|
704
711
|
})
|
|
705
712
|
}
|
|
706
713
|
);
|
|
707
714
|
|
|
708
715
|
// src/auto-instrumentations/configs/claude-agent-sdk.ts
|
|
709
716
|
var claudeAgentSDKConfigs = [
|
|
710
|
-
// query - Main entry point for agent interactions
|
|
717
|
+
// query - Main entry point for agent interactions. The SDK returns an async
|
|
718
|
+
// iterable, but the exported query function itself is synchronous.
|
|
711
719
|
{
|
|
712
720
|
channelName: claudeAgentSDKChannels.query.channelName,
|
|
713
721
|
module: {
|
|
714
722
|
name: "@anthropic-ai/claude-agent-sdk",
|
|
715
|
-
versionRange: ">=0.1.0",
|
|
723
|
+
versionRange: ">=0.1.0 <0.2.0",
|
|
716
724
|
filePath: "sdk.mjs"
|
|
717
725
|
},
|
|
718
726
|
functionQuery: {
|
|
719
727
|
functionName: "query",
|
|
720
|
-
kind: "
|
|
728
|
+
kind: "Sync"
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
channelName: claudeAgentSDKChannels.query.channelName,
|
|
733
|
+
module: {
|
|
734
|
+
name: "@anthropic-ai/claude-agent-sdk",
|
|
735
|
+
versionRange: ">=0.2.0",
|
|
736
|
+
filePath: "sdk.mjs"
|
|
737
|
+
},
|
|
738
|
+
functionQuery: {
|
|
739
|
+
functionName: "query",
|
|
740
|
+
kind: "Sync",
|
|
741
|
+
isExportAlias: true
|
|
721
742
|
}
|
|
722
743
|
}
|
|
723
744
|
];
|
|
@@ -786,6 +807,10 @@ var openRouterChannels = defineChannels("@openrouter/sdk", {
|
|
|
786
807
|
channelName: "callModel",
|
|
787
808
|
kind: "sync-stream"
|
|
788
809
|
}),
|
|
810
|
+
callModelTurn: channel({
|
|
811
|
+
channelName: "callModel.turn",
|
|
812
|
+
kind: "async"
|
|
813
|
+
}),
|
|
789
814
|
toolExecute: channel({
|
|
790
815
|
channelName: "tool.execute",
|
|
791
816
|
kind: "async"
|
|
@@ -70,7 +70,7 @@ var DefaultTracingChannel = class {
|
|
|
70
70
|
}
|
|
71
71
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
72
|
tracePromise(fn, _message, thisArg, ...args) {
|
|
73
|
-
return
|
|
73
|
+
return fn.apply(thisArg, args);
|
|
74
74
|
}
|
|
75
75
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
76
|
traceCallback(fn, _position, _message, thisArg, ...args) {
|
|
@@ -90,6 +90,7 @@ var iso = {
|
|
|
90
90
|
processOn: (_0, _1) => {
|
|
91
91
|
},
|
|
92
92
|
basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
|
|
93
|
+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
|
|
93
94
|
writeln: (text) => console.log(text)
|
|
94
95
|
};
|
|
95
96
|
var isomorph_default = iso;
|
|
@@ -356,12 +357,26 @@ var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
|
|
|
356
357
|
|
|
357
358
|
// src/auto-instrumentations/configs/anthropic.ts
|
|
358
359
|
var anthropicConfigs = [
|
|
360
|
+
// Messages API - create in older SDK layouts (supports streaming via stream=true parameter)
|
|
361
|
+
{
|
|
362
|
+
channelName: anthropicChannels.messagesCreate.channelName,
|
|
363
|
+
module: {
|
|
364
|
+
name: "@anthropic-ai/sdk",
|
|
365
|
+
versionRange: ">=0.27.0 <0.39.0",
|
|
366
|
+
filePath: "resources/messages.mjs"
|
|
367
|
+
},
|
|
368
|
+
functionQuery: {
|
|
369
|
+
className: "Messages",
|
|
370
|
+
methodName: "create",
|
|
371
|
+
kind: "Async"
|
|
372
|
+
}
|
|
373
|
+
},
|
|
359
374
|
// Messages API - create (supports streaming via stream=true parameter)
|
|
360
375
|
{
|
|
361
376
|
channelName: anthropicChannels.messagesCreate.channelName,
|
|
362
377
|
module: {
|
|
363
378
|
name: "@anthropic-ai/sdk",
|
|
364
|
-
versionRange: ">=0.
|
|
379
|
+
versionRange: ">=0.39.0",
|
|
365
380
|
filePath: "resources/messages/messages.mjs"
|
|
366
381
|
},
|
|
367
382
|
functionQuery: {
|
|
@@ -375,7 +390,7 @@ var anthropicConfigs = [
|
|
|
375
390
|
channelName: anthropicChannels.betaMessagesCreate.channelName,
|
|
376
391
|
module: {
|
|
377
392
|
name: "@anthropic-ai/sdk",
|
|
378
|
-
versionRange: ">=0.
|
|
393
|
+
versionRange: ">=0.39.0",
|
|
379
394
|
filePath: "resources/beta/messages/messages.mjs"
|
|
380
395
|
},
|
|
381
396
|
functionQuery: {
|
|
@@ -396,10 +411,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
396
411
|
channelName: "streamText",
|
|
397
412
|
kind: "async"
|
|
398
413
|
}),
|
|
399
|
-
streamTextSync: channel({
|
|
400
|
-
channelName: "streamText.sync",
|
|
401
|
-
kind: "sync-stream"
|
|
402
|
-
}),
|
|
403
414
|
generateObject: channel({
|
|
404
415
|
channelName: "generateObject",
|
|
405
416
|
kind: "async"
|
|
@@ -408,10 +419,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
408
419
|
channelName: "streamObject",
|
|
409
420
|
kind: "async"
|
|
410
421
|
}),
|
|
411
|
-
streamObjectSync: channel({
|
|
412
|
-
channelName: "streamObject.sync",
|
|
413
|
-
kind: "sync-stream"
|
|
414
|
-
}),
|
|
415
422
|
agentGenerate: channel({
|
|
416
423
|
channelName: "Agent.generate",
|
|
417
424
|
kind: "async"
|
|
@@ -457,7 +464,7 @@ var aiSDKConfigs = [
|
|
|
457
464
|
kind: "Async"
|
|
458
465
|
}
|
|
459
466
|
},
|
|
460
|
-
// streamText -
|
|
467
|
+
// streamText - function returning stream
|
|
461
468
|
{
|
|
462
469
|
channelName: aiSDKChannels.streamText.channelName,
|
|
463
470
|
module: {
|
|
@@ -471,7 +478,7 @@ var aiSDKConfigs = [
|
|
|
471
478
|
}
|
|
472
479
|
},
|
|
473
480
|
{
|
|
474
|
-
channelName: aiSDKChannels.
|
|
481
|
+
channelName: aiSDKChannels.streamText.channelName,
|
|
475
482
|
module: {
|
|
476
483
|
name: "ai",
|
|
477
484
|
versionRange: ">=3.0.0",
|
|
@@ -479,7 +486,7 @@ var aiSDKConfigs = [
|
|
|
479
486
|
},
|
|
480
487
|
functionQuery: {
|
|
481
488
|
functionName: "streamText",
|
|
482
|
-
kind: "
|
|
489
|
+
kind: "Async"
|
|
483
490
|
}
|
|
484
491
|
},
|
|
485
492
|
// generateObject - async function
|
|
@@ -507,7 +514,7 @@ var aiSDKConfigs = [
|
|
|
507
514
|
kind: "Async"
|
|
508
515
|
}
|
|
509
516
|
},
|
|
510
|
-
// streamObject -
|
|
517
|
+
// streamObject - function returning stream
|
|
511
518
|
{
|
|
512
519
|
channelName: aiSDKChannels.streamObject.channelName,
|
|
513
520
|
module: {
|
|
@@ -521,7 +528,7 @@ var aiSDKConfigs = [
|
|
|
521
528
|
}
|
|
522
529
|
},
|
|
523
530
|
{
|
|
524
|
-
channelName: aiSDKChannels.
|
|
531
|
+
channelName: aiSDKChannels.streamObject.channelName,
|
|
525
532
|
module: {
|
|
526
533
|
name: "ai",
|
|
527
534
|
versionRange: ">=3.0.0",
|
|
@@ -529,7 +536,7 @@ var aiSDKConfigs = [
|
|
|
529
536
|
},
|
|
530
537
|
functionQuery: {
|
|
531
538
|
functionName: "streamObject",
|
|
532
|
-
kind: "
|
|
539
|
+
kind: "Async"
|
|
533
540
|
}
|
|
534
541
|
},
|
|
535
542
|
// Agent.generate - async method (v5 only)
|
|
@@ -656,24 +663,38 @@ var claudeAgentSDKChannels = defineChannels(
|
|
|
656
663
|
{
|
|
657
664
|
query: channel({
|
|
658
665
|
channelName: "query",
|
|
659
|
-
kind: "
|
|
666
|
+
kind: "sync-stream"
|
|
660
667
|
})
|
|
661
668
|
}
|
|
662
669
|
);
|
|
663
670
|
|
|
664
671
|
// src/auto-instrumentations/configs/claude-agent-sdk.ts
|
|
665
672
|
var claudeAgentSDKConfigs = [
|
|
666
|
-
// query - Main entry point for agent interactions
|
|
673
|
+
// query - Main entry point for agent interactions. The SDK returns an async
|
|
674
|
+
// iterable, but the exported query function itself is synchronous.
|
|
667
675
|
{
|
|
668
676
|
channelName: claudeAgentSDKChannels.query.channelName,
|
|
669
677
|
module: {
|
|
670
678
|
name: "@anthropic-ai/claude-agent-sdk",
|
|
671
|
-
versionRange: ">=0.1.0",
|
|
679
|
+
versionRange: ">=0.1.0 <0.2.0",
|
|
672
680
|
filePath: "sdk.mjs"
|
|
673
681
|
},
|
|
674
682
|
functionQuery: {
|
|
675
683
|
functionName: "query",
|
|
676
|
-
kind: "
|
|
684
|
+
kind: "Sync"
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
channelName: claudeAgentSDKChannels.query.channelName,
|
|
689
|
+
module: {
|
|
690
|
+
name: "@anthropic-ai/claude-agent-sdk",
|
|
691
|
+
versionRange: ">=0.2.0",
|
|
692
|
+
filePath: "sdk.mjs"
|
|
693
|
+
},
|
|
694
|
+
functionQuery: {
|
|
695
|
+
functionName: "query",
|
|
696
|
+
kind: "Sync",
|
|
697
|
+
isExportAlias: true
|
|
677
698
|
}
|
|
678
699
|
}
|
|
679
700
|
];
|
|
@@ -742,6 +763,10 @@ var openRouterChannels = defineChannels("@openrouter/sdk", {
|
|
|
742
763
|
channelName: "callModel",
|
|
743
764
|
kind: "sync-stream"
|
|
744
765
|
}),
|
|
766
|
+
callModelTurn: channel({
|
|
767
|
+
channelName: "callModel.turn",
|
|
768
|
+
kind: "async"
|
|
769
|
+
}),
|
|
745
770
|
toolExecute: channel({
|
|
746
771
|
channelName: "tool.execute",
|
|
747
772
|
kind: "async"
|
|
@@ -78,7 +78,7 @@ var DefaultTracingChannel = class {
|
|
|
78
78
|
}
|
|
79
79
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
80
|
tracePromise(fn, _message, thisArg, ...args) {
|
|
81
|
-
return
|
|
81
|
+
return fn.apply(thisArg, args);
|
|
82
82
|
}
|
|
83
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
84
|
traceCallback(fn, _position, _message, thisArg, ...args) {
|
|
@@ -98,6 +98,7 @@ var iso = {
|
|
|
98
98
|
processOn: (_0, _1) => {
|
|
99
99
|
},
|
|
100
100
|
basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
|
|
101
|
+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
|
|
101
102
|
writeln: (text) => console.log(text)
|
|
102
103
|
};
|
|
103
104
|
var isomorph_default = iso;
|
|
@@ -364,12 +365,26 @@ var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
|
|
|
364
365
|
|
|
365
366
|
// src/auto-instrumentations/configs/anthropic.ts
|
|
366
367
|
var anthropicConfigs = [
|
|
368
|
+
// Messages API - create in older SDK layouts (supports streaming via stream=true parameter)
|
|
369
|
+
{
|
|
370
|
+
channelName: anthropicChannels.messagesCreate.channelName,
|
|
371
|
+
module: {
|
|
372
|
+
name: "@anthropic-ai/sdk",
|
|
373
|
+
versionRange: ">=0.27.0 <0.39.0",
|
|
374
|
+
filePath: "resources/messages.mjs"
|
|
375
|
+
},
|
|
376
|
+
functionQuery: {
|
|
377
|
+
className: "Messages",
|
|
378
|
+
methodName: "create",
|
|
379
|
+
kind: "Async"
|
|
380
|
+
}
|
|
381
|
+
},
|
|
367
382
|
// Messages API - create (supports streaming via stream=true parameter)
|
|
368
383
|
{
|
|
369
384
|
channelName: anthropicChannels.messagesCreate.channelName,
|
|
370
385
|
module: {
|
|
371
386
|
name: "@anthropic-ai/sdk",
|
|
372
|
-
versionRange: ">=0.
|
|
387
|
+
versionRange: ">=0.39.0",
|
|
373
388
|
filePath: "resources/messages/messages.mjs"
|
|
374
389
|
},
|
|
375
390
|
functionQuery: {
|
|
@@ -383,7 +398,7 @@ var anthropicConfigs = [
|
|
|
383
398
|
channelName: anthropicChannels.betaMessagesCreate.channelName,
|
|
384
399
|
module: {
|
|
385
400
|
name: "@anthropic-ai/sdk",
|
|
386
|
-
versionRange: ">=0.
|
|
401
|
+
versionRange: ">=0.39.0",
|
|
387
402
|
filePath: "resources/beta/messages/messages.mjs"
|
|
388
403
|
},
|
|
389
404
|
functionQuery: {
|
|
@@ -404,10 +419,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
404
419
|
channelName: "streamText",
|
|
405
420
|
kind: "async"
|
|
406
421
|
}),
|
|
407
|
-
streamTextSync: channel({
|
|
408
|
-
channelName: "streamText.sync",
|
|
409
|
-
kind: "sync-stream"
|
|
410
|
-
}),
|
|
411
422
|
generateObject: channel({
|
|
412
423
|
channelName: "generateObject",
|
|
413
424
|
kind: "async"
|
|
@@ -416,10 +427,6 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
416
427
|
channelName: "streamObject",
|
|
417
428
|
kind: "async"
|
|
418
429
|
}),
|
|
419
|
-
streamObjectSync: channel({
|
|
420
|
-
channelName: "streamObject.sync",
|
|
421
|
-
kind: "sync-stream"
|
|
422
|
-
}),
|
|
423
430
|
agentGenerate: channel({
|
|
424
431
|
channelName: "Agent.generate",
|
|
425
432
|
kind: "async"
|
|
@@ -465,7 +472,7 @@ var aiSDKConfigs = [
|
|
|
465
472
|
kind: "Async"
|
|
466
473
|
}
|
|
467
474
|
},
|
|
468
|
-
// streamText -
|
|
475
|
+
// streamText - function returning stream
|
|
469
476
|
{
|
|
470
477
|
channelName: aiSDKChannels.streamText.channelName,
|
|
471
478
|
module: {
|
|
@@ -479,7 +486,7 @@ var aiSDKConfigs = [
|
|
|
479
486
|
}
|
|
480
487
|
},
|
|
481
488
|
{
|
|
482
|
-
channelName: aiSDKChannels.
|
|
489
|
+
channelName: aiSDKChannels.streamText.channelName,
|
|
483
490
|
module: {
|
|
484
491
|
name: "ai",
|
|
485
492
|
versionRange: ">=3.0.0",
|
|
@@ -487,7 +494,7 @@ var aiSDKConfigs = [
|
|
|
487
494
|
},
|
|
488
495
|
functionQuery: {
|
|
489
496
|
functionName: "streamText",
|
|
490
|
-
kind: "
|
|
497
|
+
kind: "Async"
|
|
491
498
|
}
|
|
492
499
|
},
|
|
493
500
|
// generateObject - async function
|
|
@@ -515,7 +522,7 @@ var aiSDKConfigs = [
|
|
|
515
522
|
kind: "Async"
|
|
516
523
|
}
|
|
517
524
|
},
|
|
518
|
-
// streamObject -
|
|
525
|
+
// streamObject - function returning stream
|
|
519
526
|
{
|
|
520
527
|
channelName: aiSDKChannels.streamObject.channelName,
|
|
521
528
|
module: {
|
|
@@ -529,7 +536,7 @@ var aiSDKConfigs = [
|
|
|
529
536
|
}
|
|
530
537
|
},
|
|
531
538
|
{
|
|
532
|
-
channelName: aiSDKChannels.
|
|
539
|
+
channelName: aiSDKChannels.streamObject.channelName,
|
|
533
540
|
module: {
|
|
534
541
|
name: "ai",
|
|
535
542
|
versionRange: ">=3.0.0",
|
|
@@ -537,7 +544,7 @@ var aiSDKConfigs = [
|
|
|
537
544
|
},
|
|
538
545
|
functionQuery: {
|
|
539
546
|
functionName: "streamObject",
|
|
540
|
-
kind: "
|
|
547
|
+
kind: "Async"
|
|
541
548
|
}
|
|
542
549
|
},
|
|
543
550
|
// Agent.generate - async method (v5 only)
|
|
@@ -664,24 +671,38 @@ var claudeAgentSDKChannels = defineChannels(
|
|
|
664
671
|
{
|
|
665
672
|
query: channel({
|
|
666
673
|
channelName: "query",
|
|
667
|
-
kind: "
|
|
674
|
+
kind: "sync-stream"
|
|
668
675
|
})
|
|
669
676
|
}
|
|
670
677
|
);
|
|
671
678
|
|
|
672
679
|
// src/auto-instrumentations/configs/claude-agent-sdk.ts
|
|
673
680
|
var claudeAgentSDKConfigs = [
|
|
674
|
-
// query - Main entry point for agent interactions
|
|
681
|
+
// query - Main entry point for agent interactions. The SDK returns an async
|
|
682
|
+
// iterable, but the exported query function itself is synchronous.
|
|
675
683
|
{
|
|
676
684
|
channelName: claudeAgentSDKChannels.query.channelName,
|
|
677
685
|
module: {
|
|
678
686
|
name: "@anthropic-ai/claude-agent-sdk",
|
|
679
|
-
versionRange: ">=0.1.0",
|
|
687
|
+
versionRange: ">=0.1.0 <0.2.0",
|
|
680
688
|
filePath: "sdk.mjs"
|
|
681
689
|
},
|
|
682
690
|
functionQuery: {
|
|
683
691
|
functionName: "query",
|
|
684
|
-
kind: "
|
|
692
|
+
kind: "Sync"
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
channelName: claudeAgentSDKChannels.query.channelName,
|
|
697
|
+
module: {
|
|
698
|
+
name: "@anthropic-ai/claude-agent-sdk",
|
|
699
|
+
versionRange: ">=0.2.0",
|
|
700
|
+
filePath: "sdk.mjs"
|
|
701
|
+
},
|
|
702
|
+
functionQuery: {
|
|
703
|
+
functionName: "query",
|
|
704
|
+
kind: "Sync",
|
|
705
|
+
isExportAlias: true
|
|
685
706
|
}
|
|
686
707
|
}
|
|
687
708
|
];
|
|
@@ -750,6 +771,10 @@ var openRouterChannels = defineChannels("@openrouter/sdk", {
|
|
|
750
771
|
channelName: "callModel",
|
|
751
772
|
kind: "sync-stream"
|
|
752
773
|
}),
|
|
774
|
+
callModelTurn: channel({
|
|
775
|
+
channelName: "callModel.turn",
|
|
776
|
+
kind: "async"
|
|
777
|
+
}),
|
|
753
778
|
toolExecute: channel({
|
|
754
779
|
channelName: "tool.execute",
|
|
755
780
|
kind: "async"
|
|
@@ -897,25 +922,51 @@ function patchTracingChannel(tracingChannelFn) {
|
|
|
897
922
|
if (TracingChannel.prototype.tracePromise) {
|
|
898
923
|
TracingChannel.prototype.tracePromise = function(fn, context = {}, thisArg, ...args) {
|
|
899
924
|
const { start, end, asyncStart, asyncEnd, error } = this;
|
|
900
|
-
function
|
|
925
|
+
function publishRejected(err) {
|
|
901
926
|
context.error = err;
|
|
902
927
|
error?.publish(context);
|
|
903
928
|
asyncStart?.publish(context);
|
|
904
929
|
asyncEnd?.publish(context);
|
|
905
|
-
return Promise.reject(err);
|
|
906
930
|
}
|
|
907
|
-
function
|
|
931
|
+
function publishResolved(result) {
|
|
908
932
|
context.result = result;
|
|
909
933
|
asyncStart?.publish(context);
|
|
910
934
|
asyncEnd?.publish(context);
|
|
911
|
-
return result;
|
|
912
935
|
}
|
|
913
936
|
return start.runStores(context, () => {
|
|
914
937
|
try {
|
|
915
938
|
const result = Reflect.apply(fn, thisArg, args);
|
|
916
939
|
end?.publish(context);
|
|
917
940
|
if (result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function") {
|
|
918
|
-
|
|
941
|
+
if (result.constructor === Promise) {
|
|
942
|
+
return result.then(
|
|
943
|
+
(res) => {
|
|
944
|
+
publishResolved(res);
|
|
945
|
+
return res;
|
|
946
|
+
},
|
|
947
|
+
(err) => {
|
|
948
|
+
publishRejected(err);
|
|
949
|
+
return Promise.reject(err);
|
|
950
|
+
}
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
void result.then(
|
|
954
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
955
|
+
(resolved) => {
|
|
956
|
+
try {
|
|
957
|
+
publishResolved(resolved);
|
|
958
|
+
} catch {
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
962
|
+
(err) => {
|
|
963
|
+
try {
|
|
964
|
+
publishRejected(err);
|
|
965
|
+
} catch {
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
);
|
|
969
|
+
return result;
|
|
919
970
|
}
|
|
920
971
|
context.result = result;
|
|
921
972
|
asyncStart?.publish(context);
|