braintrust 3.14.0 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev/dist/index.js +655 -1059
- package/dev/dist/index.mjs +613 -1017
- package/dist/apply-auto-instrumentation.js +176 -186
- package/dist/apply-auto-instrumentation.mjs +6 -16
- package/dist/auto-instrumentations/bundler/esbuild.cjs +5 -39
- package/dist/auto-instrumentations/bundler/esbuild.mjs +1 -1
- package/dist/auto-instrumentations/bundler/next.cjs +5 -39
- package/dist/auto-instrumentations/bundler/next.mjs +2 -2
- package/dist/auto-instrumentations/bundler/rollup.cjs +5 -39
- package/dist/auto-instrumentations/bundler/rollup.mjs +1 -1
- package/dist/auto-instrumentations/bundler/vite.cjs +5 -39
- package/dist/auto-instrumentations/bundler/vite.mjs +1 -1
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +5 -39
- package/dist/auto-instrumentations/bundler/webpack.cjs +5 -39
- package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
- package/dist/auto-instrumentations/{chunk-OTUQ7KH5.mjs → chunk-CNQ7BUKN.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-XKAAVWT6.mjs → chunk-VXJONZVX.mjs} +5 -39
- package/dist/auto-instrumentations/hook.mjs +10 -40
- package/dist/browser.d.mts +75 -18
- package/dist/browser.d.ts +75 -18
- package/dist/browser.js +616 -1042
- package/dist/browser.mjs +616 -1042
- package/dist/{chunk-NU2GSPHX.mjs → chunk-O4ZIWXO3.mjs} +0 -24
- package/dist/{chunk-NKD77KGB.js → chunk-VMBQETG3.js} +0 -24
- package/dist/cli.js +614 -1018
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +616 -1042
- package/dist/edge-light.mjs +616 -1042
- package/dist/index.d.mts +75 -18
- package/dist/index.d.ts +75 -18
- package/dist/index.js +1007 -1409
- package/dist/index.mjs +620 -1022
- package/dist/instrumentation/index.d.mts +11 -1
- package/dist/instrumentation/index.d.ts +11 -1
- package/dist/instrumentation/index.js +616 -1016
- package/dist/instrumentation/index.mjs +615 -1016
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +616 -1042
- package/dist/workerd.mjs +616 -1042
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkVMBQETG3js = require('./chunk-VMBQETG3.js');
|
|
30
30
|
|
|
31
31
|
// src/node/config.ts
|
|
32
32
|
var _nodeasync_hooks = require('node:async_hooks');
|
|
@@ -83,7 +83,7 @@ function parseDebugLogLevelEnv(value) {
|
|
|
83
83
|
return void 0;
|
|
84
84
|
}
|
|
85
85
|
function getEnvDebugLogLevel() {
|
|
86
|
-
return parseDebugLogLevelEnv(
|
|
86
|
+
return parseDebugLogLevelEnv(_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_DEBUG_LOG_LEVEL"));
|
|
87
87
|
}
|
|
88
88
|
function setGlobalDebugLogLevel(level) {
|
|
89
89
|
globalThis[DEBUG_LOG_LEVEL_SYMBOL] = level;
|
|
@@ -350,9 +350,9 @@ function getCallerLocation() {
|
|
|
350
350
|
const entries = getStackTrace();
|
|
351
351
|
for (const frame of entries) {
|
|
352
352
|
if (thisDir === void 0) {
|
|
353
|
-
thisDir = _optionalChain([
|
|
353
|
+
thisDir = _optionalChain([_chunkVMBQETG3js.isomorph_default, 'access', _12 => _12.pathDirname, 'optionalCall', _13 => _13(frame.fileName)]);
|
|
354
354
|
}
|
|
355
|
-
if (_optionalChain([
|
|
355
|
+
if (_optionalChain([_chunkVMBQETG3js.isomorph_default, 'access', _14 => _14.pathDirname, 'optionalCall', _15 => _15(frame.fileName)]) !== thisDir) {
|
|
356
356
|
return {
|
|
357
357
|
caller_functionname: frame.functionName,
|
|
358
358
|
caller_filename: frame.fileName,
|
|
@@ -3854,7 +3854,7 @@ function btStreamParser() {
|
|
|
3854
3854
|
},
|
|
3855
3855
|
async transform(chunk, controller) {
|
|
3856
3856
|
if (chunk instanceof Uint8Array) {
|
|
3857
|
-
parser.feed(decoder.decode(chunk));
|
|
3857
|
+
parser.feed(decoder.decode(chunk, { stream: true }));
|
|
3858
3858
|
} else if (typeof chunk === "string") {
|
|
3859
3859
|
parser.feed(chunk);
|
|
3860
3860
|
} else {
|
|
@@ -3862,6 +3862,10 @@ function btStreamParser() {
|
|
|
3862
3862
|
}
|
|
3863
3863
|
},
|
|
3864
3864
|
async flush(controller) {
|
|
3865
|
+
const tail = decoder.decode();
|
|
3866
|
+
if (tail) {
|
|
3867
|
+
parser.feed(tail);
|
|
3868
|
+
}
|
|
3865
3869
|
controller.terminate();
|
|
3866
3870
|
}
|
|
3867
3871
|
});
|
|
@@ -3944,7 +3948,7 @@ function devNullWritableStream() {
|
|
|
3944
3948
|
|
|
3945
3949
|
// src/prompt-cache/disk-cache.ts
|
|
3946
3950
|
function canUseDiskCache() {
|
|
3947
|
-
return !!(
|
|
3951
|
+
return !!(_chunkVMBQETG3js.isomorph_default.hash && _chunkVMBQETG3js.isomorph_default.gunzip && _chunkVMBQETG3js.isomorph_default.gzip && _chunkVMBQETG3js.isomorph_default.stat && _chunkVMBQETG3js.isomorph_default.readFile && _chunkVMBQETG3js.isomorph_default.writeFile && _chunkVMBQETG3js.isomorph_default.utimes && _chunkVMBQETG3js.isomorph_default.readdir && _chunkVMBQETG3js.isomorph_default.mkdir && _chunkVMBQETG3js.isomorph_default.unlink && _chunkVMBQETG3js.isomorph_default.homedir);
|
|
3948
3952
|
}
|
|
3949
3953
|
var DiskCache = class {
|
|
3950
3954
|
|
|
@@ -3965,8 +3969,8 @@ var DiskCache = class {
|
|
|
3965
3969
|
this.mkdir = _nullishCoalesce(options.mkdir, () => ( true));
|
|
3966
3970
|
}
|
|
3967
3971
|
getEntryPath(key) {
|
|
3968
|
-
const hashed =
|
|
3969
|
-
return
|
|
3972
|
+
const hashed = _chunkVMBQETG3js.isomorph_default.hash(key);
|
|
3973
|
+
return _chunkVMBQETG3js.isomorph_default.pathJoin(this.dir, hashed);
|
|
3970
3974
|
}
|
|
3971
3975
|
/**
|
|
3972
3976
|
* Retrieves a value from the cache.
|
|
@@ -3978,8 +3982,8 @@ var DiskCache = class {
|
|
|
3978
3982
|
async get(key) {
|
|
3979
3983
|
try {
|
|
3980
3984
|
const filePath = this.getEntryPath(key);
|
|
3981
|
-
const data = await
|
|
3982
|
-
await
|
|
3985
|
+
const data = await _chunkVMBQETG3js.isomorph_default.gunzip(await _chunkVMBQETG3js.isomorph_default.readFile(filePath));
|
|
3986
|
+
await _chunkVMBQETG3js.isomorph_default.utimes(filePath, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date());
|
|
3983
3987
|
return JSON.parse(data.toString());
|
|
3984
3988
|
} catch (e) {
|
|
3985
3989
|
if (e.code === "ENOENT") {
|
|
@@ -4001,11 +4005,11 @@ var DiskCache = class {
|
|
|
4001
4005
|
async set(key, value) {
|
|
4002
4006
|
try {
|
|
4003
4007
|
if (this.mkdir) {
|
|
4004
|
-
await
|
|
4008
|
+
await _chunkVMBQETG3js.isomorph_default.mkdir(this.dir, { recursive: true });
|
|
4005
4009
|
}
|
|
4006
4010
|
const filePath = this.getEntryPath(key);
|
|
4007
|
-
const data = await
|
|
4008
|
-
await
|
|
4011
|
+
const data = await _chunkVMBQETG3js.isomorph_default.gzip(JSON.stringify(value));
|
|
4012
|
+
await _chunkVMBQETG3js.isomorph_default.writeFile(filePath, data);
|
|
4009
4013
|
await this.evictOldestIfFull();
|
|
4010
4014
|
} catch (e) {
|
|
4011
4015
|
if (this.logWarnings) {
|
|
@@ -4018,14 +4022,14 @@ var DiskCache = class {
|
|
|
4018
4022
|
if (!this.max) {
|
|
4019
4023
|
return;
|
|
4020
4024
|
}
|
|
4021
|
-
const files = await
|
|
4022
|
-
const paths = files.map((file) =>
|
|
4025
|
+
const files = await _chunkVMBQETG3js.isomorph_default.readdir(this.dir);
|
|
4026
|
+
const paths = files.map((file) => _chunkVMBQETG3js.isomorph_default.pathJoin(this.dir, file));
|
|
4023
4027
|
if (paths.length <= this.max) {
|
|
4024
4028
|
return;
|
|
4025
4029
|
}
|
|
4026
4030
|
const stats = await Promise.all(
|
|
4027
4031
|
paths.map(async (path2) => {
|
|
4028
|
-
const stat2 = await
|
|
4032
|
+
const stat2 = await _chunkVMBQETG3js.isomorph_default.stat(path2);
|
|
4029
4033
|
return {
|
|
4030
4034
|
path: path2,
|
|
4031
4035
|
mtime: stat2.mtime.getTime()
|
|
@@ -4034,7 +4038,7 @@ var DiskCache = class {
|
|
|
4034
4038
|
);
|
|
4035
4039
|
stats.sort((a, b) => a.mtime - b.mtime);
|
|
4036
4040
|
const toRemove = stats.slice(0, stats.length - this.max);
|
|
4037
|
-
await Promise.all(toRemove.map((stat2) =>
|
|
4041
|
+
await Promise.all(toRemove.map((stat2) => _chunkVMBQETG3js.isomorph_default.unlink(stat2.path)));
|
|
4038
4042
|
}
|
|
4039
4043
|
};
|
|
4040
4044
|
|
|
@@ -4112,7 +4116,7 @@ function warnUnavailableDiskCache() {
|
|
|
4112
4116
|
);
|
|
4113
4117
|
}
|
|
4114
4118
|
function parseCacheMode() {
|
|
4115
|
-
const value =
|
|
4119
|
+
const value = _chunkVMBQETG3js.isomorph_default.getEnv(CACHE_LOCATION_ENV_VAR);
|
|
4116
4120
|
const normalized = _optionalChain([value, 'optionalAccess', _31 => _31.trim, 'call', _32 => _32(), 'access', _33 => _33.toLowerCase, 'call', _34 => _34()]);
|
|
4117
4121
|
if (!normalized) {
|
|
4118
4122
|
return "mixed";
|
|
@@ -4124,7 +4128,7 @@ function parseCacheMode() {
|
|
|
4124
4128
|
return "mixed";
|
|
4125
4129
|
}
|
|
4126
4130
|
function parsePositiveIntegerEnv(envVar, defaultValue) {
|
|
4127
|
-
const value = Number(
|
|
4131
|
+
const value = Number(_chunkVMBQETG3js.isomorph_default.getEnv(envVar));
|
|
4128
4132
|
return Number.isInteger(value) && value > 0 ? value : defaultValue;
|
|
4129
4133
|
}
|
|
4130
4134
|
function createCacheLayers({
|
|
@@ -4144,7 +4148,7 @@ function createCacheLayers({
|
|
|
4144
4148
|
if (mode === "mixed" || mode === "disk") {
|
|
4145
4149
|
if (canUseDiskCache()) {
|
|
4146
4150
|
diskCache = new DiskCache({
|
|
4147
|
-
cacheDir: _nullishCoalesce(
|
|
4151
|
+
cacheDir: _nullishCoalesce(_chunkVMBQETG3js.isomorph_default.getEnv(diskCacheDirEnvVar), () => ( getDefaultDiskCacheDir())),
|
|
4148
4152
|
max: parsePositiveIntegerEnv(diskMaxEnvVar, DEFAULT_CACHE_DISK_MAX)
|
|
4149
4153
|
});
|
|
4150
4154
|
} else if (mode === "disk") {
|
|
@@ -4269,7 +4273,7 @@ var ParametersCache = class {
|
|
|
4269
4273
|
var activeCaches = /* @__PURE__ */ new Set();
|
|
4270
4274
|
var exitHandlersRegistered = false;
|
|
4271
4275
|
function canUseSpanCache() {
|
|
4272
|
-
return !!(
|
|
4276
|
+
return !!(_chunkVMBQETG3js.isomorph_default.pathJoin && _chunkVMBQETG3js.isomorph_default.tmpdir && _chunkVMBQETG3js.isomorph_default.writeFileSync && _chunkVMBQETG3js.isomorph_default.appendFileSync && _chunkVMBQETG3js.isomorph_default.readFileSync && _chunkVMBQETG3js.isomorph_default.unlinkSync && _chunkVMBQETG3js.isomorph_default.openFile);
|
|
4273
4277
|
}
|
|
4274
4278
|
var SpanCache = (_class5 = class {
|
|
4275
4279
|
__init7() {this.cacheFilePath = null}
|
|
@@ -4334,16 +4338,16 @@ var SpanCache = (_class5 = class {
|
|
|
4334
4338
|
return this.initPromise;
|
|
4335
4339
|
}
|
|
4336
4340
|
this.initPromise = (async () => {
|
|
4337
|
-
if (!
|
|
4341
|
+
if (!_chunkVMBQETG3js.isomorph_default.tmpdir || !_chunkVMBQETG3js.isomorph_default.pathJoin || !_chunkVMBQETG3js.isomorph_default.openFile) {
|
|
4338
4342
|
return;
|
|
4339
4343
|
}
|
|
4340
|
-
const tmpDir =
|
|
4344
|
+
const tmpDir = _chunkVMBQETG3js.isomorph_default.tmpdir();
|
|
4341
4345
|
const uniqueId = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
4342
|
-
this.cacheFilePath =
|
|
4346
|
+
this.cacheFilePath = _chunkVMBQETG3js.isomorph_default.pathJoin(
|
|
4343
4347
|
tmpDir,
|
|
4344
4348
|
`braintrust-span-cache-${uniqueId}.jsonl`
|
|
4345
4349
|
);
|
|
4346
|
-
this.fileHandle = await
|
|
4350
|
+
this.fileHandle = await _chunkVMBQETG3js.isomorph_default.openFile(this.cacheFilePath, "a+");
|
|
4347
4351
|
this.initialized = true;
|
|
4348
4352
|
this.registerExitHandler();
|
|
4349
4353
|
})();
|
|
@@ -4367,9 +4371,9 @@ var SpanCache = (_class5 = class {
|
|
|
4367
4371
|
} catch (e12) {
|
|
4368
4372
|
}
|
|
4369
4373
|
}
|
|
4370
|
-
if (cache.cacheFilePath && canUseSpanCache() &&
|
|
4374
|
+
if (cache.cacheFilePath && canUseSpanCache() && _chunkVMBQETG3js.isomorph_default.unlinkSync) {
|
|
4371
4375
|
try {
|
|
4372
|
-
|
|
4376
|
+
_chunkVMBQETG3js.isomorph_default.unlinkSync(cache.cacheFilePath);
|
|
4373
4377
|
} catch (e13) {
|
|
4374
4378
|
}
|
|
4375
4379
|
}
|
|
@@ -4448,9 +4452,9 @@ var SpanCache = (_class5 = class {
|
|
|
4448
4452
|
return void 0;
|
|
4449
4453
|
}
|
|
4450
4454
|
const spanMap = /* @__PURE__ */ new Map();
|
|
4451
|
-
if (this.initialized && this.cacheFilePath &&
|
|
4455
|
+
if (this.initialized && this.cacheFilePath && _chunkVMBQETG3js.isomorph_default.readFileSync) {
|
|
4452
4456
|
try {
|
|
4453
|
-
const content =
|
|
4457
|
+
const content = _chunkVMBQETG3js.isomorph_default.readFileSync(this.cacheFilePath, "utf8");
|
|
4454
4458
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
4455
4459
|
for (const line of lines) {
|
|
4456
4460
|
try {
|
|
@@ -4539,9 +4543,9 @@ var SpanCache = (_class5 = class {
|
|
|
4539
4543
|
});
|
|
4540
4544
|
this.fileHandle = null;
|
|
4541
4545
|
}
|
|
4542
|
-
if (this.cacheFilePath && canUseSpanCache() &&
|
|
4546
|
+
if (this.cacheFilePath && canUseSpanCache() && _chunkVMBQETG3js.isomorph_default.unlinkSync) {
|
|
4543
4547
|
try {
|
|
4544
|
-
|
|
4548
|
+
_chunkVMBQETG3js.isomorph_default.unlinkSync(this.cacheFilePath);
|
|
4545
4549
|
} catch (e16) {
|
|
4546
4550
|
}
|
|
4547
4551
|
this.cacheFilePath = null;
|
|
@@ -4654,7 +4658,7 @@ var BraintrustContextManager = class extends ContextManager {
|
|
|
4654
4658
|
|
|
4655
4659
|
constructor() {
|
|
4656
4660
|
super();
|
|
4657
|
-
this._currentSpan =
|
|
4661
|
+
this._currentSpan = _chunkVMBQETG3js.isomorph_default.newAsyncLocalStorage();
|
|
4658
4662
|
this[BRAINTRUST_CURRENT_SPAN_STORE] = this._currentSpan;
|
|
4659
4663
|
}
|
|
4660
4664
|
getParentSpanIds() {
|
|
@@ -4767,8 +4771,8 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
4767
4771
|
this.id = `${(/* @__PURE__ */ new Date()).toLocaleString()}-${stateNonce++}`;
|
|
4768
4772
|
this.currentExperiment = void 0;
|
|
4769
4773
|
this.currentLogger = void 0;
|
|
4770
|
-
this.currentParent =
|
|
4771
|
-
this.currentSpan =
|
|
4774
|
+
this.currentParent = _chunkVMBQETG3js.isomorph_default.newAsyncLocalStorage();
|
|
4775
|
+
this.currentSpan = _chunkVMBQETG3js.isomorph_default.newAsyncLocalStorage();
|
|
4772
4776
|
if (loginParams.fetch) {
|
|
4773
4777
|
this.fetch = loginParams.fetch;
|
|
4774
4778
|
}
|
|
@@ -4794,7 +4798,7 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
4794
4798
|
memoryMaxEnvVar: "BRAINTRUST_PROMPT_CACHE_MEMORY_MAX",
|
|
4795
4799
|
diskCacheDirEnvVar: "BRAINTRUST_PROMPT_CACHE_DIR",
|
|
4796
4800
|
diskMaxEnvVar: "BRAINTRUST_PROMPT_CACHE_DISK_MAX",
|
|
4797
|
-
getDefaultDiskCacheDir: () => `${_nullishCoalesce(
|
|
4801
|
+
getDefaultDiskCacheDir: () => `${_nullishCoalesce(_chunkVMBQETG3js.isomorph_default.getEnv("HOME"), () => ( _chunkVMBQETG3js.isomorph_default.homedir()))}/.braintrust/prompt_cache`
|
|
4798
4802
|
});
|
|
4799
4803
|
this.promptCache = new PromptCache({ memoryCache, diskCache });
|
|
4800
4804
|
const {
|
|
@@ -4804,7 +4808,7 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
4804
4808
|
memoryMaxEnvVar: "BRAINTRUST_PARAMETERS_CACHE_MEMORY_MAX",
|
|
4805
4809
|
diskCacheDirEnvVar: "BRAINTRUST_PARAMETERS_CACHE_DIR",
|
|
4806
4810
|
diskMaxEnvVar: "BRAINTRUST_PARAMETERS_CACHE_DISK_MAX",
|
|
4807
|
-
getDefaultDiskCacheDir: () => `${_nullishCoalesce(
|
|
4811
|
+
getDefaultDiskCacheDir: () => `${_nullishCoalesce(_chunkVMBQETG3js.isomorph_default.getEnv("HOME"), () => ( _chunkVMBQETG3js.isomorph_default.homedir()))}/.braintrust/parameters_cache`
|
|
4808
4812
|
});
|
|
4809
4813
|
this.parametersCache = new ParametersCache({
|
|
4810
4814
|
memoryCache: parametersMemoryCache,
|
|
@@ -5445,7 +5449,7 @@ var Attachment = class extends BaseAttachment {
|
|
|
5445
5449
|
initData(data) {
|
|
5446
5450
|
if (typeof data === "string") {
|
|
5447
5451
|
this.ensureFileReadable(data);
|
|
5448
|
-
const readFile2 =
|
|
5452
|
+
const readFile2 = _chunkVMBQETG3js.isomorph_default.readFile;
|
|
5449
5453
|
if (!readFile2) {
|
|
5450
5454
|
throw new Error(
|
|
5451
5455
|
`This platform does not support reading the filesystem. Construct the Attachment
|
|
@@ -5458,7 +5462,7 @@ with a Blob/ArrayBuffer, or run the program on Node.js.`
|
|
|
5458
5462
|
}
|
|
5459
5463
|
}
|
|
5460
5464
|
ensureFileReadable(data) {
|
|
5461
|
-
const statSync2 =
|
|
5465
|
+
const statSync2 = _chunkVMBQETG3js.isomorph_default.statSync;
|
|
5462
5466
|
if (!statSync2) {
|
|
5463
5467
|
throw new Error(
|
|
5464
5468
|
`This platform does not support reading the filesystem. Construct the Attachment
|
|
@@ -5846,10 +5850,10 @@ function getErrPermlink(msg) {
|
|
|
5846
5850
|
return `${ERR_PERMALINK}?msg=${encodeURIComponent(msg)}`;
|
|
5847
5851
|
}
|
|
5848
5852
|
function _getAppUrl(appUrl) {
|
|
5849
|
-
return appUrl ||
|
|
5853
|
+
return appUrl || _chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_APP_URL") || "https://www.braintrust.dev";
|
|
5850
5854
|
}
|
|
5851
5855
|
function _getOrgName(orgName) {
|
|
5852
|
-
return orgName ||
|
|
5856
|
+
return orgName || _chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_ORG_NAME") || void 0;
|
|
5853
5857
|
}
|
|
5854
5858
|
function _getLinkBaseUrl(state, linkArgs) {
|
|
5855
5859
|
const appUrl = _getAppUrl(state.appUrl || _optionalChain([linkArgs, 'optionalAccess', _69 => _69.app_url]));
|
|
@@ -6333,62 +6337,62 @@ var HTTPBackgroundLogger = (_class10 = class _HTTPBackgroundLogger {
|
|
|
6333
6337
|
constructor(apiConn, opts) {;_class10.prototype.__init38.call(this);_class10.prototype.__init39.call(this);_class10.prototype.__init40.call(this);_class10.prototype.__init41.call(this);_class10.prototype.__init42.call(this);_class10.prototype.__init43.call(this);_class10.prototype.__init44.call(this);_class10.prototype.__init45.call(this);_class10.prototype.__init46.call(this);_class10.prototype.__init47.call(this);_class10.prototype.__init48.call(this);_class10.prototype.__init49.call(this);_class10.prototype.__init50.call(this);_class10.prototype.__init51.call(this);_class10.prototype.__init52.call(this);_class10.prototype.__init53.call(this);_class10.prototype.__init54.call(this);
|
|
6334
6338
|
opts = _nullishCoalesce(opts, () => ( {}));
|
|
6335
6339
|
this.apiConn = apiConn;
|
|
6336
|
-
const syncFlushEnv = Number(
|
|
6340
|
+
const syncFlushEnv = Number(_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_SYNC_FLUSH"));
|
|
6337
6341
|
if (!isNaN(syncFlushEnv)) {
|
|
6338
6342
|
this.syncFlush = Boolean(syncFlushEnv);
|
|
6339
6343
|
}
|
|
6340
6344
|
const defaultBatchSizeEnv = Number(
|
|
6341
|
-
|
|
6345
|
+
_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_DEFAULT_BATCH_SIZE")
|
|
6342
6346
|
);
|
|
6343
6347
|
if (!isNaN(defaultBatchSizeEnv)) {
|
|
6344
6348
|
this.defaultBatchSize = defaultBatchSizeEnv;
|
|
6345
6349
|
}
|
|
6346
|
-
const maxRequestSizeEnv = Number(
|
|
6350
|
+
const maxRequestSizeEnv = Number(_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_MAX_REQUEST_SIZE"));
|
|
6347
6351
|
if (!isNaN(maxRequestSizeEnv)) {
|
|
6348
6352
|
this.maxRequestSizeOverride = maxRequestSizeEnv;
|
|
6349
6353
|
}
|
|
6350
|
-
const numTriesEnv = Number(
|
|
6354
|
+
const numTriesEnv = Number(_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_NUM_RETRIES"));
|
|
6351
6355
|
if (!isNaN(numTriesEnv)) {
|
|
6352
6356
|
this.numTries = numTriesEnv + 1;
|
|
6353
6357
|
}
|
|
6354
6358
|
const queueDropExceedingMaxsizeEnv = Number(
|
|
6355
|
-
|
|
6359
|
+
_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_QUEUE_DROP_EXCEEDING_MAXSIZE")
|
|
6356
6360
|
);
|
|
6357
6361
|
if (!isNaN(queueDropExceedingMaxsizeEnv)) {
|
|
6358
6362
|
this.queueDropExceedingMaxsize = queueDropExceedingMaxsizeEnv;
|
|
6359
6363
|
}
|
|
6360
6364
|
this.queue = new Queue(this.queueDropExceedingMaxsize);
|
|
6361
6365
|
const queueDropLoggingPeriodEnv = Number(
|
|
6362
|
-
|
|
6366
|
+
_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_QUEUE_DROP_LOGGING_PERIOD")
|
|
6363
6367
|
);
|
|
6364
6368
|
if (!isNaN(queueDropLoggingPeriodEnv)) {
|
|
6365
6369
|
this.queueDropLoggingPeriod = queueDropLoggingPeriodEnv;
|
|
6366
6370
|
}
|
|
6367
|
-
if (
|
|
6371
|
+
if (_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_LOG_FLUSH_CHUNK_SIZE")) {
|
|
6368
6372
|
debugLogger.warn(
|
|
6369
6373
|
"BRAINTRUST_LOG_FLUSH_CHUNK_SIZE is deprecated and no longer has any effect. Log flushing now sends all items at once and batches them automatically. This environment variable will be removed in a future major release."
|
|
6370
6374
|
);
|
|
6371
6375
|
}
|
|
6372
6376
|
const flushBackpressureBytesEnv = Number(
|
|
6373
|
-
|
|
6377
|
+
_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_FLUSH_BACKPRESSURE_BYTES")
|
|
6374
6378
|
);
|
|
6375
6379
|
if (!isNaN(flushBackpressureBytesEnv) && flushBackpressureBytesEnv > 0) {
|
|
6376
6380
|
this._flushBackpressureBytes = flushBackpressureBytesEnv;
|
|
6377
6381
|
}
|
|
6378
|
-
const failedPublishPayloadsDirEnv =
|
|
6382
|
+
const failedPublishPayloadsDirEnv = _chunkVMBQETG3js.isomorph_default.getEnv(
|
|
6379
6383
|
"BRAINTRUST_FAILED_PUBLISH_PAYLOADS_DIR"
|
|
6380
6384
|
);
|
|
6381
6385
|
if (failedPublishPayloadsDirEnv) {
|
|
6382
6386
|
this.failedPublishPayloadsDir = failedPublishPayloadsDirEnv;
|
|
6383
6387
|
}
|
|
6384
|
-
const allPublishPayloadsDirEnv =
|
|
6388
|
+
const allPublishPayloadsDirEnv = _chunkVMBQETG3js.isomorph_default.getEnv(
|
|
6385
6389
|
"BRAINTRUST_ALL_PUBLISH_PAYLOADS_DIR"
|
|
6386
6390
|
);
|
|
6387
6391
|
if (allPublishPayloadsDirEnv) {
|
|
6388
6392
|
this.allPublishPayloadsDir = allPublishPayloadsDirEnv;
|
|
6389
6393
|
}
|
|
6390
6394
|
if (!opts.noExitFlush) {
|
|
6391
|
-
|
|
6395
|
+
_chunkVMBQETG3js.isomorph_default.processOn("beforeExit", async () => {
|
|
6392
6396
|
await this.flush();
|
|
6393
6397
|
});
|
|
6394
6398
|
}
|
|
@@ -6746,19 +6750,19 @@ Error: ${errorText}`;
|
|
|
6746
6750
|
payloadDir,
|
|
6747
6751
|
payload
|
|
6748
6752
|
}) {
|
|
6749
|
-
if (!(
|
|
6753
|
+
if (!(_chunkVMBQETG3js.isomorph_default.pathJoin && _chunkVMBQETG3js.isomorph_default.mkdir && _chunkVMBQETG3js.isomorph_default.writeFile)) {
|
|
6750
6754
|
debugLogger.warn(
|
|
6751
6755
|
"Cannot dump payloads: filesystem-operations not supported on this platform"
|
|
6752
6756
|
);
|
|
6753
6757
|
return;
|
|
6754
6758
|
}
|
|
6755
|
-
const payloadFile =
|
|
6759
|
+
const payloadFile = _chunkVMBQETG3js.isomorph_default.pathJoin(
|
|
6756
6760
|
payloadDir,
|
|
6757
6761
|
`payload_${getCurrentUnixTimestamp()}_${_uuid.v4.call(void 0, ).slice(0, 8)}.json`
|
|
6758
6762
|
);
|
|
6759
6763
|
try {
|
|
6760
|
-
await
|
|
6761
|
-
await
|
|
6764
|
+
await _chunkVMBQETG3js.isomorph_default.mkdir(payloadDir, { recursive: true });
|
|
6765
|
+
await _chunkVMBQETG3js.isomorph_default.writeFile(payloadFile, payload);
|
|
6762
6766
|
} catch (e) {
|
|
6763
6767
|
debugLogger.error(
|
|
6764
6768
|
`Failed to write failed payload to output file ${payloadFile}:
|
|
@@ -6940,7 +6944,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
6940
6944
|
state.gitMetadataSettings,
|
|
6941
6945
|
_nullishCoalesce(gitMetadataSettings, () => ( { collect: "all" }))
|
|
6942
6946
|
);
|
|
6943
|
-
return await
|
|
6947
|
+
return await _chunkVMBQETG3js.isomorph_default.getRepoInfo(mergedGitMetadataSettings);
|
|
6944
6948
|
})();
|
|
6945
6949
|
if (repoInfoArg) {
|
|
6946
6950
|
args["repo_info"] = repoInfoArg;
|
|
@@ -6950,7 +6954,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
6950
6954
|
} else if (baseExperiment) {
|
|
6951
6955
|
args["base_experiment"] = baseExperiment;
|
|
6952
6956
|
} else {
|
|
6953
|
-
args["ancestor_commits"] = await
|
|
6957
|
+
args["ancestor_commits"] = await _chunkVMBQETG3js.isomorph_default.getPastNAncestors();
|
|
6954
6958
|
}
|
|
6955
6959
|
if (dataset !== void 0) {
|
|
6956
6960
|
const datasetSelection = await serializeDatasetForExperiment({
|
|
@@ -7662,13 +7666,13 @@ async function login(options = {}) {
|
|
|
7662
7666
|
}
|
|
7663
7667
|
async function loginToState(options = {}) {
|
|
7664
7668
|
const {
|
|
7665
|
-
appUrl =
|
|
7669
|
+
appUrl = _chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_APP_URL") || "https://www.braintrust.dev",
|
|
7666
7670
|
apiKey: apiKeyArg,
|
|
7667
|
-
orgName =
|
|
7671
|
+
orgName = _chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_ORG_NAME"),
|
|
7668
7672
|
fetch: fetch2 = globalThis.fetch
|
|
7669
7673
|
} = options || {};
|
|
7670
|
-
const apiKey = apiKeyArg !== void 0 ? apiKeyArg : await
|
|
7671
|
-
const appPublicUrl =
|
|
7674
|
+
const apiKey = apiKeyArg !== void 0 ? apiKeyArg : await _chunkVMBQETG3js.isomorph_default.getBraintrustApiKey();
|
|
7675
|
+
const appPublicUrl = _chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_APP_PUBLIC_URL") || appUrl;
|
|
7672
7676
|
const state = new BraintrustState(options);
|
|
7673
7677
|
state.resetLoginInfo();
|
|
7674
7678
|
state.appUrl = appUrl;
|
|
@@ -7833,7 +7837,7 @@ function wrapTracedSyncGenerator(fn, spanArgs, noTraceIO) {
|
|
|
7833
7837
|
if (!noTraceIO) {
|
|
7834
7838
|
span.log({ input: fnArgs });
|
|
7835
7839
|
}
|
|
7836
|
-
const envValue =
|
|
7840
|
+
const envValue = _chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_MAX_GENERATOR_ITEMS");
|
|
7837
7841
|
const maxItems = envValue !== void 0 ? Number(envValue) : 1e3;
|
|
7838
7842
|
if (!noTraceIO && maxItems !== 0) {
|
|
7839
7843
|
let collected = [];
|
|
@@ -7882,7 +7886,7 @@ function wrapTracedAsyncGenerator(fn, spanArgs, noTraceIO) {
|
|
|
7882
7886
|
if (!noTraceIO) {
|
|
7883
7887
|
span.log({ input: fnArgs });
|
|
7884
7888
|
}
|
|
7885
|
-
const envValue =
|
|
7889
|
+
const envValue = _chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_MAX_GENERATOR_ITEMS");
|
|
7886
7890
|
const maxItems = envValue !== void 0 ? Number(envValue) : 1e3;
|
|
7887
7891
|
if (!noTraceIO && maxItems !== 0) {
|
|
7888
7892
|
let collected = [];
|
|
@@ -8084,8 +8088,8 @@ function _saveOrgInfo(state, org_info, org_name) {
|
|
|
8084
8088
|
if (org_name === void 0 || org.name === org_name) {
|
|
8085
8089
|
state.orgId = org.id;
|
|
8086
8090
|
state.orgName = org.name;
|
|
8087
|
-
state.apiUrl = _nullishCoalesce(
|
|
8088
|
-
state.proxyUrl = _nullishCoalesce(
|
|
8091
|
+
state.apiUrl = _nullishCoalesce(_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_API_URL"), () => ( org.api_url));
|
|
8092
|
+
state.proxyUrl = _nullishCoalesce(_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_PROXY_URL"), () => ( org.proxy_url));
|
|
8089
8093
|
state.gitMetadataSettings = org.git_metadata || void 0;
|
|
8090
8094
|
break;
|
|
8091
8095
|
}
|
|
@@ -8813,7 +8817,7 @@ var SpanImpl = (_class13 = class _SpanImpl {
|
|
|
8813
8817
|
mergeDicts(rawEvent, this.propagatedEvent);
|
|
8814
8818
|
}
|
|
8815
8819
|
const { id: eventId, ...event } = rawEvent;
|
|
8816
|
-
const callerLocation =
|
|
8820
|
+
const callerLocation = _chunkVMBQETG3js.isomorph_default.getCallerLocation();
|
|
8817
8821
|
const name = (() => {
|
|
8818
8822
|
if (args.name) return args.name;
|
|
8819
8823
|
if (!args.parentSpanIds) return "root";
|
|
@@ -10049,7 +10053,7 @@ var _exportsForTestingOnly = {
|
|
|
10049
10053
|
isAsyncGeneratorFunction,
|
|
10050
10054
|
resetIdGenStateForTests,
|
|
10051
10055
|
validateTags,
|
|
10052
|
-
isomorph:
|
|
10056
|
+
isomorph: _chunkVMBQETG3js.isomorph_default
|
|
10053
10057
|
// Expose isomorph for build type detection
|
|
10054
10058
|
};
|
|
10055
10059
|
|
|
@@ -10342,7 +10346,7 @@ var BasePlugin = (_class17 = class {constructor() { _class17.prototype.__init63.
|
|
|
10342
10346
|
* @param handlers - Event handlers
|
|
10343
10347
|
*/
|
|
10344
10348
|
subscribe(channelName, handlers) {
|
|
10345
|
-
const channel =
|
|
10349
|
+
const channel = _chunkVMBQETG3js.isomorph_default.newTracingChannel(channelName);
|
|
10346
10350
|
channel.subscribe(handlers);
|
|
10347
10351
|
}
|
|
10348
10352
|
/**
|
|
@@ -10350,7 +10354,7 @@ var BasePlugin = (_class17 = class {constructor() { _class17.prototype.__init63.
|
|
|
10350
10354
|
* Creates a span and logs input/output/metrics.
|
|
10351
10355
|
*/
|
|
10352
10356
|
subscribeToChannel(channelName, config) {
|
|
10353
|
-
const channel =
|
|
10357
|
+
const channel = _chunkVMBQETG3js.isomorph_default.newTracingChannel(channelName);
|
|
10354
10358
|
const spans = /* @__PURE__ */ new WeakMap();
|
|
10355
10359
|
const handlers = {
|
|
10356
10360
|
start: (event) => {
|
|
@@ -10419,7 +10423,7 @@ var BasePlugin = (_class17 = class {constructor() { _class17.prototype.__init63.
|
|
|
10419
10423
|
* Handles both streaming and non-streaming responses.
|
|
10420
10424
|
*/
|
|
10421
10425
|
subscribeToStreamingChannel(channelName, config) {
|
|
10422
|
-
const channel =
|
|
10426
|
+
const channel = _chunkVMBQETG3js.isomorph_default.newTracingChannel(channelName);
|
|
10423
10427
|
const spans = /* @__PURE__ */ new WeakMap();
|
|
10424
10428
|
const handlers = {
|
|
10425
10429
|
start: (event) => {
|
|
@@ -10546,7 +10550,7 @@ var BasePlugin = (_class17 = class {constructor() { _class17.prototype.__init63.
|
|
|
10546
10550
|
* Used for methods like beta.chat.completions.stream() and responses.stream().
|
|
10547
10551
|
*/
|
|
10548
10552
|
subscribeToSyncStreamChannel(channelName, config) {
|
|
10549
|
-
const channel =
|
|
10553
|
+
const channel = _chunkVMBQETG3js.isomorph_default.newTracingChannel(channelName);
|
|
10550
10554
|
const spans = /* @__PURE__ */ new WeakMap();
|
|
10551
10555
|
const handlers = {
|
|
10552
10556
|
start: (event) => {
|
|
@@ -11320,7 +11324,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11320
11324
|
}
|
|
11321
11325
|
onEnable() {
|
|
11322
11326
|
this.unsubscribers.push(
|
|
11323
|
-
traceStreamingChannel(
|
|
11327
|
+
traceStreamingChannel(_chunkVMBQETG3js.openAIChannels.chatCompletionsCreate, {
|
|
11324
11328
|
name: "Chat Completion",
|
|
11325
11329
|
type: "llm" /* LLM */,
|
|
11326
11330
|
extractInput: ([params]) => {
|
|
@@ -11348,7 +11352,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11348
11352
|
})
|
|
11349
11353
|
);
|
|
11350
11354
|
this.unsubscribers.push(
|
|
11351
|
-
traceAsyncChannel(
|
|
11355
|
+
traceAsyncChannel(_chunkVMBQETG3js.openAIChannels.embeddingsCreate, {
|
|
11352
11356
|
name: "Embedding",
|
|
11353
11357
|
type: "llm" /* LLM */,
|
|
11354
11358
|
extractInput: ([params]) => {
|
|
@@ -11372,7 +11376,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11372
11376
|
})
|
|
11373
11377
|
);
|
|
11374
11378
|
this.unsubscribers.push(
|
|
11375
|
-
traceStreamingChannel(
|
|
11379
|
+
traceStreamingChannel(_chunkVMBQETG3js.openAIChannels.betaChatCompletionsParse, {
|
|
11376
11380
|
name: "Chat Completion",
|
|
11377
11381
|
type: "llm" /* LLM */,
|
|
11378
11382
|
extractInput: ([params]) => {
|
|
@@ -11400,7 +11404,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11400
11404
|
})
|
|
11401
11405
|
);
|
|
11402
11406
|
this.unsubscribers.push(
|
|
11403
|
-
traceSyncStreamChannel(
|
|
11407
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.openAIChannels.betaChatCompletionsStream, {
|
|
11404
11408
|
name: "Chat Completion",
|
|
11405
11409
|
type: "llm" /* LLM */,
|
|
11406
11410
|
extractInput: ([params]) => {
|
|
@@ -11413,7 +11417,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11413
11417
|
})
|
|
11414
11418
|
);
|
|
11415
11419
|
this.unsubscribers.push(
|
|
11416
|
-
traceAsyncChannel(
|
|
11420
|
+
traceAsyncChannel(_chunkVMBQETG3js.openAIChannels.moderationsCreate, {
|
|
11417
11421
|
name: "Moderation",
|
|
11418
11422
|
type: "llm" /* LLM */,
|
|
11419
11423
|
extractInput: ([params]) => {
|
|
@@ -11436,7 +11440,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11436
11440
|
})
|
|
11437
11441
|
);
|
|
11438
11442
|
this.unsubscribers.push(
|
|
11439
|
-
traceStreamingChannel(
|
|
11443
|
+
traceStreamingChannel(_chunkVMBQETG3js.openAIChannels.responsesCreate, {
|
|
11440
11444
|
name: "openai.responses.create",
|
|
11441
11445
|
type: "llm" /* LLM */,
|
|
11442
11446
|
extractInput: ([params]) => {
|
|
@@ -11471,7 +11475,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11471
11475
|
})
|
|
11472
11476
|
);
|
|
11473
11477
|
this.unsubscribers.push(
|
|
11474
|
-
traceSyncStreamChannel(
|
|
11478
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.openAIChannels.responsesStream, {
|
|
11475
11479
|
name: "openai.responses.create",
|
|
11476
11480
|
type: "llm" /* LLM */,
|
|
11477
11481
|
extractInput: ([params]) => {
|
|
@@ -11500,7 +11504,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11500
11504
|
})
|
|
11501
11505
|
);
|
|
11502
11506
|
this.unsubscribers.push(
|
|
11503
|
-
traceStreamingChannel(
|
|
11507
|
+
traceStreamingChannel(_chunkVMBQETG3js.openAIChannels.responsesParse, {
|
|
11504
11508
|
name: "openai.responses.parse",
|
|
11505
11509
|
type: "llm" /* LLM */,
|
|
11506
11510
|
extractInput: ([params]) => {
|
|
@@ -11535,7 +11539,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
11535
11539
|
})
|
|
11536
11540
|
);
|
|
11537
11541
|
this.unsubscribers.push(
|
|
11538
|
-
traceAsyncChannel(
|
|
11542
|
+
traceAsyncChannel(_chunkVMBQETG3js.openAIChannels.responsesCompact, {
|
|
11539
11543
|
name: "openai.responses.compact",
|
|
11540
11544
|
type: "llm" /* LLM */,
|
|
11541
11545
|
extractInput: ([params]) => {
|
|
@@ -11786,7 +11790,7 @@ var OpenAICodexPlugin = class extends BasePlugin {
|
|
|
11786
11790
|
this.unsubscribers = [];
|
|
11787
11791
|
}
|
|
11788
11792
|
subscribeToRun() {
|
|
11789
|
-
const channel =
|
|
11793
|
+
const channel = _chunkVMBQETG3js.openAICodexChannels.run.tracingChannel();
|
|
11790
11794
|
const states = /* @__PURE__ */ new WeakMap();
|
|
11791
11795
|
const handlers = {
|
|
11792
11796
|
start: (event) => {
|
|
@@ -11815,7 +11819,7 @@ var OpenAICodexPlugin = class extends BasePlugin {
|
|
|
11815
11819
|
});
|
|
11816
11820
|
}
|
|
11817
11821
|
subscribeToRunStreamed() {
|
|
11818
|
-
const channel =
|
|
11822
|
+
const channel = _chunkVMBQETG3js.openAICodexChannels.runStreamed.tracingChannel();
|
|
11819
11823
|
const states = /* @__PURE__ */ new WeakMap();
|
|
11820
11824
|
const handlers = {
|
|
11821
11825
|
start: (event) => {
|
|
@@ -12466,17 +12470,17 @@ var AnthropicPlugin = class extends BasePlugin {
|
|
|
12466
12470
|
aggregateChunks: (chunks) => aggregateAnthropicStreamChunks(chunks)
|
|
12467
12471
|
};
|
|
12468
12472
|
this.unsubscribers.push(
|
|
12469
|
-
traceStreamingChannel(
|
|
12473
|
+
traceStreamingChannel(_chunkVMBQETG3js.anthropicChannels.messagesCreate, anthropicConfig)
|
|
12470
12474
|
);
|
|
12471
12475
|
this.unsubscribers.push(
|
|
12472
|
-
traceStreamingChannel(
|
|
12476
|
+
traceStreamingChannel(_chunkVMBQETG3js.anthropicChannels.betaMessagesCreate, {
|
|
12473
12477
|
...anthropicConfig,
|
|
12474
12478
|
name: "anthropic.messages.create"
|
|
12475
12479
|
})
|
|
12476
12480
|
);
|
|
12477
12481
|
}
|
|
12478
12482
|
subscribeToAnthropicToolRunner() {
|
|
12479
|
-
const tracingChannel2 =
|
|
12483
|
+
const tracingChannel2 = _chunkVMBQETG3js.anthropicChannels.betaMessagesToolRunner.tracingChannel();
|
|
12480
12484
|
const states = /* @__PURE__ */ new WeakMap();
|
|
12481
12485
|
const handlers = {
|
|
12482
12486
|
start: (event) => {
|
|
@@ -13244,7 +13248,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13244
13248
|
subscribeToAISDK() {
|
|
13245
13249
|
const denyOutputPaths = this.config.denyOutputPaths || DEFAULT_DENY_OUTPUT_PATHS;
|
|
13246
13250
|
this.unsubscribers.push(
|
|
13247
|
-
traceStreamingChannel(
|
|
13251
|
+
traceStreamingChannel(_chunkVMBQETG3js.aiSDKChannels.generateText, {
|
|
13248
13252
|
name: "generateText",
|
|
13249
13253
|
type: "function" /* FUNCTION */,
|
|
13250
13254
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13260,7 +13264,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13260
13264
|
})
|
|
13261
13265
|
);
|
|
13262
13266
|
this.unsubscribers.push(
|
|
13263
|
-
traceStreamingChannel(
|
|
13267
|
+
traceStreamingChannel(_chunkVMBQETG3js.aiSDKChannels.streamText, {
|
|
13264
13268
|
name: "streamText",
|
|
13265
13269
|
type: "function" /* FUNCTION */,
|
|
13266
13270
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13280,7 +13284,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13280
13284
|
})
|
|
13281
13285
|
);
|
|
13282
13286
|
this.unsubscribers.push(
|
|
13283
|
-
traceSyncStreamChannel(
|
|
13287
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.aiSDKChannels.streamTextSync, {
|
|
13284
13288
|
name: "streamText",
|
|
13285
13289
|
type: "function" /* FUNCTION */,
|
|
13286
13290
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13294,7 +13298,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13294
13298
|
})
|
|
13295
13299
|
);
|
|
13296
13300
|
this.unsubscribers.push(
|
|
13297
|
-
traceStreamingChannel(
|
|
13301
|
+
traceStreamingChannel(_chunkVMBQETG3js.aiSDKChannels.generateObject, {
|
|
13298
13302
|
name: "generateObject",
|
|
13299
13303
|
type: "function" /* FUNCTION */,
|
|
13300
13304
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13310,7 +13314,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13310
13314
|
})
|
|
13311
13315
|
);
|
|
13312
13316
|
this.unsubscribers.push(
|
|
13313
|
-
traceStreamingChannel(
|
|
13317
|
+
traceStreamingChannel(_chunkVMBQETG3js.aiSDKChannels.streamObject, {
|
|
13314
13318
|
name: "streamObject",
|
|
13315
13319
|
type: "function" /* FUNCTION */,
|
|
13316
13320
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13330,7 +13334,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13330
13334
|
})
|
|
13331
13335
|
);
|
|
13332
13336
|
this.unsubscribers.push(
|
|
13333
|
-
traceSyncStreamChannel(
|
|
13337
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.aiSDKChannels.streamObjectSync, {
|
|
13334
13338
|
name: "streamObject",
|
|
13335
13339
|
type: "function" /* FUNCTION */,
|
|
13336
13340
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13344,7 +13348,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13344
13348
|
})
|
|
13345
13349
|
);
|
|
13346
13350
|
this.unsubscribers.push(
|
|
13347
|
-
traceAsyncChannel(
|
|
13351
|
+
traceAsyncChannel(_chunkVMBQETG3js.aiSDKChannels.embed, {
|
|
13348
13352
|
name: "embed",
|
|
13349
13353
|
type: "function" /* FUNCTION */,
|
|
13350
13354
|
extractInput: ([params], event) => prepareAISDKEmbedInput(params, event.self),
|
|
@@ -13356,7 +13360,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13356
13360
|
})
|
|
13357
13361
|
);
|
|
13358
13362
|
this.unsubscribers.push(
|
|
13359
|
-
traceAsyncChannel(
|
|
13363
|
+
traceAsyncChannel(_chunkVMBQETG3js.aiSDKChannels.embedMany, {
|
|
13360
13364
|
name: "embedMany",
|
|
13361
13365
|
type: "function" /* FUNCTION */,
|
|
13362
13366
|
extractInput: ([params], event) => prepareAISDKEmbedInput(params, event.self),
|
|
@@ -13368,7 +13372,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13368
13372
|
})
|
|
13369
13373
|
);
|
|
13370
13374
|
this.unsubscribers.push(
|
|
13371
|
-
traceAsyncChannel(
|
|
13375
|
+
traceAsyncChannel(_chunkVMBQETG3js.aiSDKChannels.rerank, {
|
|
13372
13376
|
name: "rerank",
|
|
13373
13377
|
type: "function" /* FUNCTION */,
|
|
13374
13378
|
extractInput: ([params], event) => prepareAISDKRerankInput(params, event.self),
|
|
@@ -13380,7 +13384,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13380
13384
|
})
|
|
13381
13385
|
);
|
|
13382
13386
|
this.unsubscribers.push(
|
|
13383
|
-
traceStreamingChannel(
|
|
13387
|
+
traceStreamingChannel(_chunkVMBQETG3js.aiSDKChannels.agentGenerate, {
|
|
13384
13388
|
name: "Agent.generate",
|
|
13385
13389
|
type: "function" /* FUNCTION */,
|
|
13386
13390
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13396,7 +13400,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13396
13400
|
})
|
|
13397
13401
|
);
|
|
13398
13402
|
this.unsubscribers.push(
|
|
13399
|
-
traceStreamingChannel(
|
|
13403
|
+
traceStreamingChannel(_chunkVMBQETG3js.aiSDKChannels.agentStream, {
|
|
13400
13404
|
name: "Agent.stream",
|
|
13401
13405
|
type: "function" /* FUNCTION */,
|
|
13402
13406
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13416,7 +13420,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13416
13420
|
})
|
|
13417
13421
|
);
|
|
13418
13422
|
this.unsubscribers.push(
|
|
13419
|
-
traceSyncStreamChannel(
|
|
13423
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.aiSDKChannels.agentStreamSync, {
|
|
13420
13424
|
name: "Agent.stream",
|
|
13421
13425
|
type: "function" /* FUNCTION */,
|
|
13422
13426
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13430,7 +13434,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13430
13434
|
})
|
|
13431
13435
|
);
|
|
13432
13436
|
this.unsubscribers.push(
|
|
13433
|
-
traceStreamingChannel(
|
|
13437
|
+
traceStreamingChannel(_chunkVMBQETG3js.aiSDKChannels.toolLoopAgentGenerate, {
|
|
13434
13438
|
name: "ToolLoopAgent.generate",
|
|
13435
13439
|
type: "function" /* FUNCTION */,
|
|
13436
13440
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13446,7 +13450,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13446
13450
|
})
|
|
13447
13451
|
);
|
|
13448
13452
|
this.unsubscribers.push(
|
|
13449
|
-
traceStreamingChannel(
|
|
13453
|
+
traceStreamingChannel(_chunkVMBQETG3js.aiSDKChannels.toolLoopAgentStream, {
|
|
13450
13454
|
name: "ToolLoopAgent.stream",
|
|
13451
13455
|
type: "function" /* FUNCTION */,
|
|
13452
13456
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -14854,7 +14858,7 @@ var LOCAL_TOOL_CONTEXT_ASYNC_ITERATOR_PATCHED = /* @__PURE__ */ Symbol.for(
|
|
|
14854
14858
|
"braintrust.claude_agent_sdk.local_tool_context_async_iterator_patched"
|
|
14855
14859
|
);
|
|
14856
14860
|
function createLocalToolContextStore() {
|
|
14857
|
-
const maybeIsoWithAsyncLocalStorage =
|
|
14861
|
+
const maybeIsoWithAsyncLocalStorage = _chunkVMBQETG3js.isomorph_default;
|
|
14858
14862
|
if (typeof maybeIsoWithAsyncLocalStorage.newAsyncLocalStorage === "function") {
|
|
14859
14863
|
return maybeIsoWithAsyncLocalStorage.newAsyncLocalStorage();
|
|
14860
14864
|
}
|
|
@@ -16031,7 +16035,7 @@ var ClaudeAgentSDKPlugin = class extends BasePlugin {
|
|
|
16031
16035
|
this.unsubscribers = [];
|
|
16032
16036
|
}
|
|
16033
16037
|
subscribeToQuery() {
|
|
16034
|
-
const channel =
|
|
16038
|
+
const channel = _chunkVMBQETG3js.claudeAgentSDKChannels.query.tracingChannel();
|
|
16035
16039
|
const spans = /* @__PURE__ */ new WeakMap();
|
|
16036
16040
|
const handlers = {
|
|
16037
16041
|
start: (event) => {
|
|
@@ -16264,8 +16268,8 @@ var CursorSDKPlugin = (_class18 = class extends BasePlugin {constructor(...args3
|
|
|
16264
16268
|
this.promptDepth = 0;
|
|
16265
16269
|
}
|
|
16266
16270
|
subscribeToAgentFactories() {
|
|
16267
|
-
this.subscribeToAgentFactory(
|
|
16268
|
-
this.subscribeToAgentFactory(
|
|
16271
|
+
this.subscribeToAgentFactory(_chunkVMBQETG3js.cursorSDKChannels.create);
|
|
16272
|
+
this.subscribeToAgentFactory(_chunkVMBQETG3js.cursorSDKChannels.resume);
|
|
16269
16273
|
}
|
|
16270
16274
|
subscribeToAgentFactory(channel) {
|
|
16271
16275
|
const tracingChannel2 = channel.tracingChannel();
|
|
@@ -16282,7 +16286,7 @@ var CursorSDKPlugin = (_class18 = class extends BasePlugin {constructor(...args3
|
|
|
16282
16286
|
});
|
|
16283
16287
|
}
|
|
16284
16288
|
subscribeToPrompt() {
|
|
16285
|
-
const channel =
|
|
16289
|
+
const channel = _chunkVMBQETG3js.cursorSDKChannels.prompt.tracingChannel();
|
|
16286
16290
|
const states = /* @__PURE__ */ new WeakMap();
|
|
16287
16291
|
const handlers = {
|
|
16288
16292
|
start: (event) => {
|
|
@@ -16343,7 +16347,7 @@ var CursorSDKPlugin = (_class18 = class extends BasePlugin {constructor(...args3
|
|
|
16343
16347
|
});
|
|
16344
16348
|
}
|
|
16345
16349
|
subscribeToSend() {
|
|
16346
|
-
const channel =
|
|
16350
|
+
const channel = _chunkVMBQETG3js.cursorSDKChannels.send.tracingChannel();
|
|
16347
16351
|
const states = /* @__PURE__ */ new WeakMap();
|
|
16348
16352
|
const handlers = {
|
|
16349
16353
|
start: (event) => {
|
|
@@ -16442,7 +16446,7 @@ function patchCursorAgentInPlace(agent) {
|
|
|
16442
16446
|
configurable: true,
|
|
16443
16447
|
value(message, options) {
|
|
16444
16448
|
const args = [message, options];
|
|
16445
|
-
return
|
|
16449
|
+
return _chunkVMBQETG3js.cursorSDKChannels.send.tracePromise(
|
|
16446
16450
|
() => originalSend(...args),
|
|
16447
16451
|
{
|
|
16448
16452
|
agent: agentRecord,
|
|
@@ -17491,7 +17495,7 @@ var OpenAIAgentsPlugin = (_class20 = class extends BasePlugin {constructor(...ar
|
|
|
17491
17495
|
void this.processor.shutdown();
|
|
17492
17496
|
}
|
|
17493
17497
|
subscribeToTraceLifecycle() {
|
|
17494
|
-
const traceStartChannel =
|
|
17498
|
+
const traceStartChannel = _chunkVMBQETG3js.openAIAgentsCoreChannels.onTraceStart.tracingChannel();
|
|
17495
17499
|
const traceStartHandlers = {
|
|
17496
17500
|
start: (event) => {
|
|
17497
17501
|
const trace = firstArgument(event.arguments);
|
|
@@ -17504,7 +17508,7 @@ var OpenAIAgentsPlugin = (_class20 = class extends BasePlugin {constructor(...ar
|
|
|
17504
17508
|
this.unsubscribers.push(
|
|
17505
17509
|
() => traceStartChannel.unsubscribe(traceStartHandlers)
|
|
17506
17510
|
);
|
|
17507
|
-
const traceEndChannel =
|
|
17511
|
+
const traceEndChannel = _chunkVMBQETG3js.openAIAgentsCoreChannels.onTraceEnd.tracingChannel();
|
|
17508
17512
|
const traceEndHandlers = {
|
|
17509
17513
|
start: (event) => {
|
|
17510
17514
|
const trace = firstArgument(event.arguments);
|
|
@@ -17517,7 +17521,7 @@ var OpenAIAgentsPlugin = (_class20 = class extends BasePlugin {constructor(...ar
|
|
|
17517
17521
|
this.unsubscribers.push(
|
|
17518
17522
|
() => traceEndChannel.unsubscribe(traceEndHandlers)
|
|
17519
17523
|
);
|
|
17520
|
-
const spanStartChannel =
|
|
17524
|
+
const spanStartChannel = _chunkVMBQETG3js.openAIAgentsCoreChannels.onSpanStart.tracingChannel();
|
|
17521
17525
|
const spanStartHandlers = {
|
|
17522
17526
|
start: (event) => {
|
|
17523
17527
|
const span = firstArgument(event.arguments);
|
|
@@ -17530,7 +17534,7 @@ var OpenAIAgentsPlugin = (_class20 = class extends BasePlugin {constructor(...ar
|
|
|
17530
17534
|
this.unsubscribers.push(
|
|
17531
17535
|
() => spanStartChannel.unsubscribe(spanStartHandlers)
|
|
17532
17536
|
);
|
|
17533
|
-
const spanEndChannel =
|
|
17537
|
+
const spanEndChannel = _chunkVMBQETG3js.openAIAgentsCoreChannels.onSpanEnd.tracingChannel();
|
|
17534
17538
|
const spanEndHandlers = {
|
|
17535
17539
|
start: (event) => {
|
|
17536
17540
|
const span = firstArgument(event.arguments);
|
|
@@ -17570,7 +17574,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
17570
17574
|
this.subscribeToEmbedContentChannel();
|
|
17571
17575
|
}
|
|
17572
17576
|
subscribeToGenerateContentChannel() {
|
|
17573
|
-
const tracingChannel2 =
|
|
17577
|
+
const tracingChannel2 = _chunkVMBQETG3js.googleGenAIChannels.generateContent.tracingChannel();
|
|
17574
17578
|
const states = /* @__PURE__ */ new WeakMap();
|
|
17575
17579
|
const unbindCurrentSpanStore = bindCurrentSpanStoreToStart2(
|
|
17576
17580
|
tracingChannel2,
|
|
@@ -17644,7 +17648,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
17644
17648
|
});
|
|
17645
17649
|
}
|
|
17646
17650
|
subscribeToGenerateContentStreamChannel() {
|
|
17647
|
-
const tracingChannel2 =
|
|
17651
|
+
const tracingChannel2 = _chunkVMBQETG3js.googleGenAIChannels.generateContentStream.tracingChannel();
|
|
17648
17652
|
const handlers = {
|
|
17649
17653
|
start: (event) => {
|
|
17650
17654
|
const streamEvent = event;
|
|
@@ -17671,7 +17675,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
17671
17675
|
});
|
|
17672
17676
|
}
|
|
17673
17677
|
subscribeToEmbedContentChannel() {
|
|
17674
|
-
const tracingChannel2 =
|
|
17678
|
+
const tracingChannel2 = _chunkVMBQETG3js.googleGenAIChannels.embedContent.tracingChannel();
|
|
17675
17679
|
const states = /* @__PURE__ */ new WeakMap();
|
|
17676
17680
|
const unbindCurrentSpanStore = bindCurrentSpanStoreToStart2(
|
|
17677
17681
|
tracingChannel2,
|
|
@@ -18316,7 +18320,7 @@ var RESPONSE_METADATA_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
|
18316
18320
|
var HuggingFacePlugin = class extends BasePlugin {
|
|
18317
18321
|
onEnable() {
|
|
18318
18322
|
this.unsubscribers.push(
|
|
18319
|
-
traceAsyncChannel(
|
|
18323
|
+
traceAsyncChannel(_chunkVMBQETG3js.huggingFaceChannels.chatCompletion, {
|
|
18320
18324
|
name: "huggingface.chat_completion",
|
|
18321
18325
|
type: "llm" /* LLM */,
|
|
18322
18326
|
extractInput: extractChatInputWithMetadata,
|
|
@@ -18324,7 +18328,7 @@ var HuggingFacePlugin = class extends BasePlugin {
|
|
|
18324
18328
|
extractMetadata: (result) => extractResponseMetadata2(result),
|
|
18325
18329
|
extractMetrics: (result) => parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _396 => _396.usage]))
|
|
18326
18330
|
}),
|
|
18327
|
-
traceSyncStreamChannel(
|
|
18331
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.huggingFaceChannels.chatCompletionStream, {
|
|
18328
18332
|
name: "huggingface.chat_completion_stream",
|
|
18329
18333
|
type: "llm" /* LLM */,
|
|
18330
18334
|
extractInput: extractChatInputWithMetadata,
|
|
@@ -18334,7 +18338,7 @@ var HuggingFacePlugin = class extends BasePlugin {
|
|
|
18334
18338
|
startTime
|
|
18335
18339
|
})
|
|
18336
18340
|
}),
|
|
18337
|
-
traceAsyncChannel(
|
|
18341
|
+
traceAsyncChannel(_chunkVMBQETG3js.huggingFaceChannels.textGeneration, {
|
|
18338
18342
|
name: "huggingface.text_generation",
|
|
18339
18343
|
type: "llm" /* LLM */,
|
|
18340
18344
|
extractInput: extractTextGenerationInputWithMetadata,
|
|
@@ -18342,7 +18346,7 @@ var HuggingFacePlugin = class extends BasePlugin {
|
|
|
18342
18346
|
extractMetadata: extractTextGenerationMetadata,
|
|
18343
18347
|
extractMetrics: (result) => extractTextGenerationMetrics(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _397 => _397.details]), () => ( null)))
|
|
18344
18348
|
}),
|
|
18345
|
-
traceSyncStreamChannel(
|
|
18349
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.huggingFaceChannels.textGenerationStream, {
|
|
18346
18350
|
name: "huggingface.text_generation_stream",
|
|
18347
18351
|
type: "llm" /* LLM */,
|
|
18348
18352
|
extractInput: extractTextGenerationInputWithMetadata,
|
|
@@ -18352,7 +18356,7 @@ var HuggingFacePlugin = class extends BasePlugin {
|
|
|
18352
18356
|
startTime
|
|
18353
18357
|
})
|
|
18354
18358
|
}),
|
|
18355
|
-
traceAsyncChannel(
|
|
18359
|
+
traceAsyncChannel(_chunkVMBQETG3js.huggingFaceChannels.featureExtraction, {
|
|
18356
18360
|
name: "huggingface.feature_extraction",
|
|
18357
18361
|
type: "llm" /* LLM */,
|
|
18358
18362
|
extractInput: extractFeatureExtractionInputWithMetadata,
|
|
@@ -18725,7 +18729,7 @@ var OpenRouterAgentPlugin = class extends BasePlugin {
|
|
|
18725
18729
|
}
|
|
18726
18730
|
subscribeToOpenRouterAgentChannels() {
|
|
18727
18731
|
this.unsubscribers.push(
|
|
18728
|
-
traceSyncStreamChannel(
|
|
18732
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.openRouterAgentChannels.callModel, {
|
|
18729
18733
|
name: "openrouter.callModel",
|
|
18730
18734
|
type: "task" /* TASK */,
|
|
18731
18735
|
extractInput: (args) => {
|
|
@@ -18745,7 +18749,7 @@ var OpenRouterAgentPlugin = class extends BasePlugin {
|
|
|
18745
18749
|
})
|
|
18746
18750
|
);
|
|
18747
18751
|
this.unsubscribers.push(
|
|
18748
|
-
traceAsyncChannel(
|
|
18752
|
+
traceAsyncChannel(_chunkVMBQETG3js.openRouterAgentChannels.callModelTurn, {
|
|
18749
18753
|
name: "openrouter.beta.responses.send",
|
|
18750
18754
|
type: "llm" /* LLM */,
|
|
18751
18755
|
extractInput: (args, event) => {
|
|
@@ -18781,7 +18785,7 @@ var OpenRouterAgentPlugin = class extends BasePlugin {
|
|
|
18781
18785
|
})
|
|
18782
18786
|
);
|
|
18783
18787
|
this.unsubscribers.push(
|
|
18784
|
-
traceStreamingChannel(
|
|
18788
|
+
traceStreamingChannel(_chunkVMBQETG3js.openRouterAgentChannels.toolExecute, {
|
|
18785
18789
|
name: "openrouter.tool",
|
|
18786
18790
|
type: "tool" /* TOOL */,
|
|
18787
18791
|
extractInput: (args, event) => ({
|
|
@@ -18800,7 +18804,7 @@ var OpenRouterAgentPlugin = class extends BasePlugin {
|
|
|
18800
18804
|
})
|
|
18801
18805
|
})
|
|
18802
18806
|
);
|
|
18803
|
-
const callModelChannel =
|
|
18807
|
+
const callModelChannel = _chunkVMBQETG3js.openRouterAgentChannels.callModel.tracingChannel();
|
|
18804
18808
|
const callModelHandlers = {
|
|
18805
18809
|
start: (event) => {
|
|
18806
18810
|
const request = getOpenRouterCallModelRequestArg(event.arguments);
|
|
@@ -19094,7 +19098,7 @@ function isWrappedTool(tool) {
|
|
|
19094
19098
|
return Boolean(tool[OPENROUTER_WRAPPED_TOOL]);
|
|
19095
19099
|
}
|
|
19096
19100
|
function traceToolExecution(args) {
|
|
19097
|
-
const tracingChannel2 =
|
|
19101
|
+
const tracingChannel2 = _chunkVMBQETG3js.openRouterAgentChannels.toolExecute.tracingChannel();
|
|
19098
19102
|
const input = args.args.length > 0 ? args.args[0] : void 0;
|
|
19099
19103
|
const event = {
|
|
19100
19104
|
arguments: [input],
|
|
@@ -19351,7 +19355,7 @@ async function traceOpenRouterCallModelTurn(args) {
|
|
|
19351
19355
|
};
|
|
19352
19356
|
return await withCurrent(
|
|
19353
19357
|
args.parentSpan,
|
|
19354
|
-
() =>
|
|
19358
|
+
() => _chunkVMBQETG3js.openRouterAgentChannels.callModelTurn.tracePromise(args.fn, context)
|
|
19355
19359
|
);
|
|
19356
19360
|
}
|
|
19357
19361
|
function isWrappedCallModelResult(value) {
|
|
@@ -19494,7 +19498,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
19494
19498
|
}
|
|
19495
19499
|
subscribeToOpenRouterChannels() {
|
|
19496
19500
|
this.unsubscribers.push(
|
|
19497
|
-
traceStreamingChannel(
|
|
19501
|
+
traceStreamingChannel(_chunkVMBQETG3js.openRouterChannels.chatSend, {
|
|
19498
19502
|
name: "openrouter.chat.send",
|
|
19499
19503
|
type: "llm" /* LLM */,
|
|
19500
19504
|
extractInput: (args) => {
|
|
@@ -19522,7 +19526,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
19522
19526
|
})
|
|
19523
19527
|
);
|
|
19524
19528
|
this.unsubscribers.push(
|
|
19525
|
-
traceAsyncChannel(
|
|
19529
|
+
traceAsyncChannel(_chunkVMBQETG3js.openRouterChannels.embeddingsGenerate, {
|
|
19526
19530
|
name: "openrouter.embeddings.generate",
|
|
19527
19531
|
type: "llm" /* LLM */,
|
|
19528
19532
|
extractInput: (args) => {
|
|
@@ -19559,7 +19563,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
19559
19563
|
})
|
|
19560
19564
|
);
|
|
19561
19565
|
this.unsubscribers.push(
|
|
19562
|
-
traceAsyncChannel(
|
|
19566
|
+
traceAsyncChannel(_chunkVMBQETG3js.openRouterChannels.rerankRerank, {
|
|
19563
19567
|
name: "openrouter.rerank.rerank",
|
|
19564
19568
|
type: "llm" /* LLM */,
|
|
19565
19569
|
extractInput: (args) => {
|
|
@@ -19587,7 +19591,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
19587
19591
|
})
|
|
19588
19592
|
);
|
|
19589
19593
|
this.unsubscribers.push(
|
|
19590
|
-
traceStreamingChannel(
|
|
19594
|
+
traceStreamingChannel(_chunkVMBQETG3js.openRouterChannels.betaResponsesSend, {
|
|
19591
19595
|
name: "openrouter.beta.responses.send",
|
|
19592
19596
|
type: "llm" /* LLM */,
|
|
19593
19597
|
extractInput: (args) => {
|
|
@@ -19614,7 +19618,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
19614
19618
|
})
|
|
19615
19619
|
);
|
|
19616
19620
|
this.unsubscribers.push(
|
|
19617
|
-
traceSyncStreamChannel(
|
|
19621
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.openRouterChannels.callModel, {
|
|
19618
19622
|
name: "openrouter.callModel",
|
|
19619
19623
|
type: "task" /* TASK */,
|
|
19620
19624
|
extractInput: (args) => {
|
|
@@ -19634,7 +19638,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
19634
19638
|
})
|
|
19635
19639
|
);
|
|
19636
19640
|
this.unsubscribers.push(
|
|
19637
|
-
traceAsyncChannel(
|
|
19641
|
+
traceAsyncChannel(_chunkVMBQETG3js.openRouterChannels.callModelTurn, {
|
|
19638
19642
|
name: "openrouter.beta.responses.send",
|
|
19639
19643
|
type: "llm" /* LLM */,
|
|
19640
19644
|
extractInput: (args, event) => {
|
|
@@ -19670,7 +19674,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
19670
19674
|
})
|
|
19671
19675
|
);
|
|
19672
19676
|
this.unsubscribers.push(
|
|
19673
|
-
traceStreamingChannel(
|
|
19677
|
+
traceStreamingChannel(_chunkVMBQETG3js.openRouterChannels.toolExecute, {
|
|
19674
19678
|
name: "openrouter.tool",
|
|
19675
19679
|
type: "tool" /* TOOL */,
|
|
19676
19680
|
extractInput: (args, event) => ({
|
|
@@ -19689,7 +19693,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
19689
19693
|
})
|
|
19690
19694
|
})
|
|
19691
19695
|
);
|
|
19692
|
-
const callModelChannel =
|
|
19696
|
+
const callModelChannel = _chunkVMBQETG3js.openRouterChannels.callModel.tracingChannel();
|
|
19693
19697
|
const callModelHandlers = {
|
|
19694
19698
|
start: (event) => {
|
|
19695
19699
|
const request = getOpenRouterCallModelRequestArg2(event.arguments);
|
|
@@ -20002,7 +20006,7 @@ function isWrappedTool2(tool) {
|
|
|
20002
20006
|
return Boolean(tool[OPENROUTER_WRAPPED_TOOL2]);
|
|
20003
20007
|
}
|
|
20004
20008
|
function traceToolExecution2(args) {
|
|
20005
|
-
const tracingChannel2 =
|
|
20009
|
+
const tracingChannel2 = _chunkVMBQETG3js.openRouterChannels.toolExecute.tracingChannel();
|
|
20006
20010
|
const input = args.args.length > 0 ? args.args[0] : void 0;
|
|
20007
20011
|
const event = {
|
|
20008
20012
|
arguments: [input],
|
|
@@ -20390,7 +20394,7 @@ async function traceOpenRouterCallModelTurn2(args) {
|
|
|
20390
20394
|
};
|
|
20391
20395
|
return await withCurrent(
|
|
20392
20396
|
args.parentSpan,
|
|
20393
|
-
() =>
|
|
20397
|
+
() => _chunkVMBQETG3js.openRouterChannels.callModelTurn.tracePromise(args.fn, context)
|
|
20394
20398
|
);
|
|
20395
20399
|
}
|
|
20396
20400
|
function isWrappedCallModelResult2(value) {
|
|
@@ -20533,7 +20537,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20533
20537
|
}
|
|
20534
20538
|
subscribeToMistralChannels() {
|
|
20535
20539
|
this.unsubscribers.push(
|
|
20536
|
-
traceStreamingChannel(
|
|
20540
|
+
traceStreamingChannel(_chunkVMBQETG3js.mistralChannels.chatComplete, {
|
|
20537
20541
|
name: "mistral.chat.complete",
|
|
20538
20542
|
type: "llm" /* LLM */,
|
|
20539
20543
|
extractInput: extractMessagesInputWithMetadata,
|
|
@@ -20545,7 +20549,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20545
20549
|
})
|
|
20546
20550
|
);
|
|
20547
20551
|
this.unsubscribers.push(
|
|
20548
|
-
traceStreamingChannel(
|
|
20552
|
+
traceStreamingChannel(_chunkVMBQETG3js.mistralChannels.chatStream, {
|
|
20549
20553
|
name: "mistral.chat.stream",
|
|
20550
20554
|
type: "llm" /* LLM */,
|
|
20551
20555
|
extractInput: extractMessagesInputWithMetadata,
|
|
@@ -20556,7 +20560,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20556
20560
|
})
|
|
20557
20561
|
);
|
|
20558
20562
|
this.unsubscribers.push(
|
|
20559
|
-
traceAsyncChannel(
|
|
20563
|
+
traceAsyncChannel(_chunkVMBQETG3js.mistralChannels.embeddingsCreate, {
|
|
20560
20564
|
name: "mistral.embeddings.create",
|
|
20561
20565
|
type: "llm" /* LLM */,
|
|
20562
20566
|
extractInput: extractEmbeddingInputWithMetadata,
|
|
@@ -20569,7 +20573,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20569
20573
|
})
|
|
20570
20574
|
);
|
|
20571
20575
|
this.unsubscribers.push(
|
|
20572
|
-
traceAsyncChannel(
|
|
20576
|
+
traceAsyncChannel(_chunkVMBQETG3js.mistralChannels.classifiersModerate, {
|
|
20573
20577
|
name: "mistral.classifiers.moderate",
|
|
20574
20578
|
type: "llm" /* LLM */,
|
|
20575
20579
|
extractInput: extractClassifierInputWithMetadata,
|
|
@@ -20579,7 +20583,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20579
20583
|
})
|
|
20580
20584
|
);
|
|
20581
20585
|
this.unsubscribers.push(
|
|
20582
|
-
traceAsyncChannel(
|
|
20586
|
+
traceAsyncChannel(_chunkVMBQETG3js.mistralChannels.classifiersModerateChat, {
|
|
20583
20587
|
name: "mistral.classifiers.moderateChat",
|
|
20584
20588
|
type: "llm" /* LLM */,
|
|
20585
20589
|
extractInput: extractClassifierInputWithMetadata,
|
|
@@ -20589,7 +20593,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20589
20593
|
})
|
|
20590
20594
|
);
|
|
20591
20595
|
this.unsubscribers.push(
|
|
20592
|
-
traceAsyncChannel(
|
|
20596
|
+
traceAsyncChannel(_chunkVMBQETG3js.mistralChannels.classifiersClassify, {
|
|
20593
20597
|
name: "mistral.classifiers.classify",
|
|
20594
20598
|
type: "llm" /* LLM */,
|
|
20595
20599
|
extractInput: extractClassifierInputWithMetadata,
|
|
@@ -20599,7 +20603,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20599
20603
|
})
|
|
20600
20604
|
);
|
|
20601
20605
|
this.unsubscribers.push(
|
|
20602
|
-
traceAsyncChannel(
|
|
20606
|
+
traceAsyncChannel(_chunkVMBQETG3js.mistralChannels.classifiersClassifyChat, {
|
|
20603
20607
|
name: "mistral.classifiers.classifyChat",
|
|
20604
20608
|
type: "llm" /* LLM */,
|
|
20605
20609
|
extractInput: extractClassifierInputWithMetadata,
|
|
@@ -20609,7 +20613,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20609
20613
|
})
|
|
20610
20614
|
);
|
|
20611
20615
|
this.unsubscribers.push(
|
|
20612
|
-
traceStreamingChannel(
|
|
20616
|
+
traceStreamingChannel(_chunkVMBQETG3js.mistralChannels.fimComplete, {
|
|
20613
20617
|
name: "mistral.fim.complete",
|
|
20614
20618
|
type: "llm" /* LLM */,
|
|
20615
20619
|
extractInput: extractPromptInputWithMetadata,
|
|
@@ -20621,7 +20625,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20621
20625
|
})
|
|
20622
20626
|
);
|
|
20623
20627
|
this.unsubscribers.push(
|
|
20624
|
-
traceStreamingChannel(
|
|
20628
|
+
traceStreamingChannel(_chunkVMBQETG3js.mistralChannels.fimStream, {
|
|
20625
20629
|
name: "mistral.fim.stream",
|
|
20626
20630
|
type: "llm" /* LLM */,
|
|
20627
20631
|
extractInput: extractPromptInputWithMetadata,
|
|
@@ -20632,7 +20636,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20632
20636
|
})
|
|
20633
20637
|
);
|
|
20634
20638
|
this.unsubscribers.push(
|
|
20635
|
-
traceStreamingChannel(
|
|
20639
|
+
traceStreamingChannel(_chunkVMBQETG3js.mistralChannels.agentsComplete, {
|
|
20636
20640
|
name: "mistral.agents.complete",
|
|
20637
20641
|
type: "llm" /* LLM */,
|
|
20638
20642
|
extractInput: extractMessagesInputWithMetadata,
|
|
@@ -20644,7 +20648,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
20644
20648
|
})
|
|
20645
20649
|
);
|
|
20646
20650
|
this.unsubscribers.push(
|
|
20647
|
-
traceStreamingChannel(
|
|
20651
|
+
traceStreamingChannel(_chunkVMBQETG3js.mistralChannels.agentsStream, {
|
|
20648
20652
|
name: "mistral.agents.stream",
|
|
20649
20653
|
type: "llm" /* LLM */,
|
|
20650
20654
|
extractInput: extractMessagesInputWithMetadata,
|
|
@@ -21158,7 +21162,7 @@ var GoogleADKPlugin = (_class21 = class extends BasePlugin {constructor(...args5
|
|
|
21158
21162
|
this.activeAgentSpans.clear();
|
|
21159
21163
|
}
|
|
21160
21164
|
subscribeToRunnerRunAsync() {
|
|
21161
|
-
const tracingChannel2 =
|
|
21165
|
+
const tracingChannel2 = _chunkVMBQETG3js.googleADKChannels.runnerRunAsync.tracingChannel();
|
|
21162
21166
|
const states = /* @__PURE__ */ new WeakMap();
|
|
21163
21167
|
const createState = (event) => {
|
|
21164
21168
|
const params = _nullishCoalesce(event.arguments[0], () => ( {}));
|
|
@@ -21243,7 +21247,7 @@ var GoogleADKPlugin = (_class21 = class extends BasePlugin {constructor(...args5
|
|
|
21243
21247
|
});
|
|
21244
21248
|
}
|
|
21245
21249
|
subscribeToAgentRunAsync() {
|
|
21246
|
-
const tracingChannel2 =
|
|
21250
|
+
const tracingChannel2 = _chunkVMBQETG3js.googleADKChannels.agentRunAsync.tracingChannel();
|
|
21247
21251
|
const states = /* @__PURE__ */ new WeakMap();
|
|
21248
21252
|
const createState = (event) => {
|
|
21249
21253
|
const parentContext = event.arguments[0];
|
|
@@ -21346,7 +21350,7 @@ var GoogleADKPlugin = (_class21 = class extends BasePlugin {constructor(...args5
|
|
|
21346
21350
|
});
|
|
21347
21351
|
}
|
|
21348
21352
|
subscribeToToolRunAsync() {
|
|
21349
|
-
const tracingChannel2 =
|
|
21353
|
+
const tracingChannel2 = _chunkVMBQETG3js.googleADKChannels.toolRunAsync.tracingChannel();
|
|
21350
21354
|
const states = /* @__PURE__ */ new WeakMap();
|
|
21351
21355
|
const handlers = {
|
|
21352
21356
|
start: (event) => {
|
|
@@ -21781,7 +21785,7 @@ var CoherePlugin = class extends BasePlugin {
|
|
|
21781
21785
|
}
|
|
21782
21786
|
subscribeToCohereChannels() {
|
|
21783
21787
|
this.unsubscribers.push(
|
|
21784
|
-
traceStreamingChannel(
|
|
21788
|
+
traceStreamingChannel(_chunkVMBQETG3js.cohereChannels.chat, {
|
|
21785
21789
|
name: "cohere.chat",
|
|
21786
21790
|
type: "llm" /* LLM */,
|
|
21787
21791
|
extractInput: extractChatInputWithMetadata2,
|
|
@@ -21797,7 +21801,7 @@ var CoherePlugin = class extends BasePlugin {
|
|
|
21797
21801
|
})
|
|
21798
21802
|
);
|
|
21799
21803
|
this.unsubscribers.push(
|
|
21800
|
-
traceStreamingChannel(
|
|
21804
|
+
traceStreamingChannel(_chunkVMBQETG3js.cohereChannels.chatStream, {
|
|
21801
21805
|
name: "cohere.chatStream",
|
|
21802
21806
|
type: "llm" /* LLM */,
|
|
21803
21807
|
extractInput: extractChatInputWithMetadata2,
|
|
@@ -21808,7 +21812,7 @@ var CoherePlugin = class extends BasePlugin {
|
|
|
21808
21812
|
})
|
|
21809
21813
|
);
|
|
21810
21814
|
this.unsubscribers.push(
|
|
21811
|
-
traceAsyncChannel(
|
|
21815
|
+
traceAsyncChannel(_chunkVMBQETG3js.cohereChannels.embed, {
|
|
21812
21816
|
name: "cohere.embed",
|
|
21813
21817
|
type: "llm" /* LLM */,
|
|
21814
21818
|
extractInput: extractEmbedInputWithMetadata,
|
|
@@ -21818,7 +21822,7 @@ var CoherePlugin = class extends BasePlugin {
|
|
|
21818
21822
|
})
|
|
21819
21823
|
);
|
|
21820
21824
|
this.unsubscribers.push(
|
|
21821
|
-
traceAsyncChannel(
|
|
21825
|
+
traceAsyncChannel(_chunkVMBQETG3js.cohereChannels.rerank, {
|
|
21822
21826
|
name: "cohere.rerank",
|
|
21823
21827
|
type: "llm" /* LLM */,
|
|
21824
21828
|
extractInput: extractRerankInputWithMetadata,
|
|
@@ -22441,7 +22445,7 @@ function aggregateCohereChatStreamChunks(chunks) {
|
|
|
22441
22445
|
var GroqPlugin = class extends BasePlugin {
|
|
22442
22446
|
onEnable() {
|
|
22443
22447
|
this.unsubscribers.push(
|
|
22444
|
-
traceStreamingChannel(
|
|
22448
|
+
traceStreamingChannel(_chunkVMBQETG3js.groqChannels.chatCompletionsCreate, {
|
|
22445
22449
|
name: "groq.chat.completions.create",
|
|
22446
22450
|
type: "llm" /* LLM */,
|
|
22447
22451
|
extractInput: ([params]) => {
|
|
@@ -22463,7 +22467,7 @@ var GroqPlugin = class extends BasePlugin {
|
|
|
22463
22467
|
})
|
|
22464
22468
|
);
|
|
22465
22469
|
this.unsubscribers.push(
|
|
22466
|
-
traceAsyncChannel(
|
|
22470
|
+
traceAsyncChannel(_chunkVMBQETG3js.groqChannels.embeddingsCreate, {
|
|
22467
22471
|
name: "groq.embeddings.create",
|
|
22468
22472
|
type: "llm" /* LLM */,
|
|
22469
22473
|
extractInput: ([params]) => {
|
|
@@ -22543,7 +22547,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
22543
22547
|
}
|
|
22544
22548
|
subscribeToGenkitChannels() {
|
|
22545
22549
|
this.unsubscribers.push(
|
|
22546
|
-
traceAsyncChannel(
|
|
22550
|
+
traceAsyncChannel(_chunkVMBQETG3js.genkitChannels.generate, {
|
|
22547
22551
|
name: "genkit.generate",
|
|
22548
22552
|
type: "llm" /* LLM */,
|
|
22549
22553
|
extractInput: ([input]) => extractGenerateInput(input),
|
|
@@ -22553,7 +22557,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
22553
22557
|
})
|
|
22554
22558
|
);
|
|
22555
22559
|
this.unsubscribers.push(
|
|
22556
|
-
traceSyncStreamChannel(
|
|
22560
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.genkitChannels.generateStream, {
|
|
22557
22561
|
name: "genkit.generateStream",
|
|
22558
22562
|
type: "llm" /* LLM */,
|
|
22559
22563
|
extractInput: ([input]) => extractGenerateInput(input),
|
|
@@ -22561,7 +22565,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
22561
22565
|
})
|
|
22562
22566
|
);
|
|
22563
22567
|
this.unsubscribers.push(
|
|
22564
|
-
traceAsyncChannel(
|
|
22568
|
+
traceAsyncChannel(_chunkVMBQETG3js.genkitChannels.embed, {
|
|
22565
22569
|
name: "genkit.embed",
|
|
22566
22570
|
type: "function" /* FUNCTION */,
|
|
22567
22571
|
extractInput: ([params]) => extractEmbedInput(params),
|
|
@@ -22571,7 +22575,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
22571
22575
|
})
|
|
22572
22576
|
);
|
|
22573
22577
|
this.unsubscribers.push(
|
|
22574
|
-
traceAsyncChannel(
|
|
22578
|
+
traceAsyncChannel(_chunkVMBQETG3js.genkitChannels.embedMany, {
|
|
22575
22579
|
name: "genkit.embedMany",
|
|
22576
22580
|
type: "function" /* FUNCTION */,
|
|
22577
22581
|
extractInput: ([params]) => extractEmbedManyInput(params),
|
|
@@ -22585,7 +22589,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
22585
22589
|
this.subscribeToActionStream();
|
|
22586
22590
|
}
|
|
22587
22591
|
subscribeToActionRun() {
|
|
22588
|
-
const tracingChannel2 =
|
|
22592
|
+
const tracingChannel2 = _chunkVMBQETG3js.genkitChannels.actionRun.tracingChannel();
|
|
22589
22593
|
const states = /* @__PURE__ */ new WeakMap();
|
|
22590
22594
|
const unbindCurrentSpanStore = bindActionCurrentSpanStoreToStart(
|
|
22591
22595
|
tracingChannel2,
|
|
@@ -22632,7 +22636,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
22632
22636
|
});
|
|
22633
22637
|
}
|
|
22634
22638
|
subscribeToActionSpan() {
|
|
22635
|
-
const tracingChannel2 =
|
|
22639
|
+
const tracingChannel2 = _chunkVMBQETG3js.genkitCoreChannels.actionSpan.tracingChannel();
|
|
22636
22640
|
const states = /* @__PURE__ */ new WeakMap();
|
|
22637
22641
|
const unbindCurrentSpanStore = bindActionCurrentSpanStoreToStart(
|
|
22638
22642
|
tracingChannel2,
|
|
@@ -22681,7 +22685,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
22681
22685
|
}
|
|
22682
22686
|
subscribeToActionStream() {
|
|
22683
22687
|
this.unsubscribers.push(
|
|
22684
|
-
traceSyncStreamChannel(
|
|
22688
|
+
traceSyncStreamChannel(_chunkVMBQETG3js.genkitChannels.actionStream, {
|
|
22685
22689
|
name: "genkit.action.stream",
|
|
22686
22690
|
type: "task" /* TASK */,
|
|
22687
22691
|
extractInput: ([input], event) => ({
|
|
@@ -23572,8 +23576,8 @@ var GitHubCopilotPlugin = class extends BasePlugin {
|
|
|
23572
23576
|
this.unsubscribers = [];
|
|
23573
23577
|
}
|
|
23574
23578
|
subscribeToSessionChannels() {
|
|
23575
|
-
const createChannel =
|
|
23576
|
-
const resumeChannel =
|
|
23579
|
+
const createChannel = _chunkVMBQETG3js.gitHubCopilotChannels.createSession.tracingChannel();
|
|
23580
|
+
const resumeChannel = _chunkVMBQETG3js.gitHubCopilotChannels.resumeSession.tracingChannel();
|
|
23577
23581
|
const sessionStates = /* @__PURE__ */ new WeakMap();
|
|
23578
23582
|
const createHandlers = makeSessionHandlers(
|
|
23579
23583
|
sessionStates,
|
|
@@ -23598,798 +23602,437 @@ var GitHubCopilotPlugin = class extends BasePlugin {
|
|
|
23598
23602
|
}
|
|
23599
23603
|
};
|
|
23600
23604
|
|
|
23601
|
-
// src/
|
|
23602
|
-
var
|
|
23603
|
-
var
|
|
23604
|
-
var
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23608
|
-
|
|
23609
|
-
|
|
23610
|
-
console.warn("Unsupported Flue context. Not wrapping.");
|
|
23611
|
-
return ctx;
|
|
23605
|
+
// src/instrumentation/plugins/flue-plugin.ts
|
|
23606
|
+
var FLUE_AUTO_STATE = /* @__PURE__ */ Symbol.for("braintrust.flue.auto-state");
|
|
23607
|
+
var FLUE_OBSERVE_BRIDGE = /* @__PURE__ */ Symbol.for("braintrust.flue.observe-bridge");
|
|
23608
|
+
var braintrustFlueObserver = (event, ctx) => {
|
|
23609
|
+
getObserveBridge().handle(event, ctx);
|
|
23610
|
+
};
|
|
23611
|
+
var FluePlugin = class extends BasePlugin {
|
|
23612
|
+
onEnable() {
|
|
23613
|
+
this.unsubscribers.push(enableFlueAutoInstrumentation());
|
|
23612
23614
|
}
|
|
23613
|
-
|
|
23614
|
-
|
|
23615
|
-
|
|
23616
|
-
}
|
|
23617
|
-
|
|
23618
|
-
const context = ctx;
|
|
23619
|
-
if (context[WRAPPED_FLUE_CONTEXT]) {
|
|
23620
|
-
return ctx;
|
|
23615
|
+
onDisable() {
|
|
23616
|
+
for (const unsubscribe of this.unsubscribers) {
|
|
23617
|
+
unsubscribe();
|
|
23618
|
+
}
|
|
23619
|
+
this.unsubscribers = [];
|
|
23621
23620
|
}
|
|
23622
|
-
|
|
23623
|
-
|
|
23624
|
-
|
|
23625
|
-
|
|
23626
|
-
|
|
23627
|
-
|
|
23628
|
-
|
|
23629
|
-
|
|
23630
|
-
|
|
23631
|
-
|
|
23632
|
-
|
|
23633
|
-
|
|
23634
|
-
|
|
23635
|
-
|
|
23636
|
-
});
|
|
23637
|
-
} catch (e48) {
|
|
23621
|
+
};
|
|
23622
|
+
function enableFlueAutoInstrumentation() {
|
|
23623
|
+
const state = getAutoState();
|
|
23624
|
+
state.refCount += 1;
|
|
23625
|
+
if (!state.handlers) {
|
|
23626
|
+
const channel = _chunkVMBQETG3js.flueChannels.createContext.tracingChannel();
|
|
23627
|
+
const handlers = {
|
|
23628
|
+
end: (event) => {
|
|
23629
|
+
subscribeToFlueContext(event.result, state);
|
|
23630
|
+
}
|
|
23631
|
+
};
|
|
23632
|
+
channel.subscribe(handlers);
|
|
23633
|
+
state.channel = channel;
|
|
23634
|
+
state.handlers = handlers;
|
|
23638
23635
|
}
|
|
23639
|
-
|
|
23636
|
+
let released = false;
|
|
23637
|
+
return () => {
|
|
23638
|
+
if (released) {
|
|
23639
|
+
return;
|
|
23640
|
+
}
|
|
23641
|
+
released = true;
|
|
23642
|
+
releaseAutoState(state);
|
|
23643
|
+
};
|
|
23640
23644
|
}
|
|
23641
|
-
function
|
|
23642
|
-
|
|
23643
|
-
|
|
23644
|
-
return
|
|
23645
|
+
function getAutoState() {
|
|
23646
|
+
const existing = Reflect.get(globalThis, FLUE_AUTO_STATE);
|
|
23647
|
+
if (isAutoState(existing)) {
|
|
23648
|
+
return existing;
|
|
23645
23649
|
}
|
|
23646
|
-
|
|
23650
|
+
const state = {
|
|
23651
|
+
contexts: /* @__PURE__ */ new WeakSet(),
|
|
23652
|
+
refCount: 0
|
|
23653
|
+
};
|
|
23654
|
+
Reflect.set(globalThis, FLUE_AUTO_STATE, state);
|
|
23655
|
+
return state;
|
|
23647
23656
|
}
|
|
23648
|
-
function
|
|
23649
|
-
|
|
23650
|
-
|
|
23651
|
-
|
|
23652
|
-
const context = ctx;
|
|
23653
|
-
const captureTurnSpans = _nullishCoalesce(options.captureTurnSpans, () => ( true));
|
|
23654
|
-
const existingSubscription = context[SUBSCRIBED_FLUE_CONTEXT_EVENTS];
|
|
23655
|
-
if (existingSubscription) {
|
|
23656
|
-
if (existingSubscription.captureTurnSpans || !captureTurnSpans) {
|
|
23657
|
-
return void 0;
|
|
23658
|
-
}
|
|
23659
|
-
try {
|
|
23660
|
-
existingSubscription.unsubscribe();
|
|
23661
|
-
} catch (e49) {
|
|
23662
|
-
}
|
|
23663
|
-
}
|
|
23664
|
-
try {
|
|
23665
|
-
const unsubscribe = ctx.subscribeEvent((event) => {
|
|
23666
|
-
_chunkNKD77KGBjs.flueChannels.contextEvent.traceSync(() => void 0, {
|
|
23667
|
-
arguments: [event],
|
|
23668
|
-
captureTurnSpans,
|
|
23669
|
-
context: ctx
|
|
23670
|
-
});
|
|
23671
|
-
});
|
|
23672
|
-
if (existingSubscription) {
|
|
23673
|
-
existingSubscription.captureTurnSpans = captureTurnSpans;
|
|
23674
|
-
existingSubscription.unsubscribe = unsubscribe;
|
|
23675
|
-
} else {
|
|
23676
|
-
Object.defineProperty(context, SUBSCRIBED_FLUE_CONTEXT_EVENTS, {
|
|
23677
|
-
configurable: false,
|
|
23678
|
-
enumerable: false,
|
|
23679
|
-
value: {
|
|
23680
|
-
captureTurnSpans,
|
|
23681
|
-
unsubscribe
|
|
23682
|
-
}
|
|
23683
|
-
});
|
|
23684
|
-
}
|
|
23685
|
-
return unsubscribe;
|
|
23686
|
-
} catch (e50) {
|
|
23687
|
-
return void 0;
|
|
23657
|
+
function getObserveBridge() {
|
|
23658
|
+
const existing = Reflect.get(globalThis, FLUE_OBSERVE_BRIDGE);
|
|
23659
|
+
if (isFlueObserveBridge(existing)) {
|
|
23660
|
+
return existing;
|
|
23688
23661
|
}
|
|
23662
|
+
const bridge = new FlueObserveBridge();
|
|
23663
|
+
Reflect.set(globalThis, FLUE_OBSERVE_BRIDGE, bridge);
|
|
23664
|
+
return bridge;
|
|
23689
23665
|
}
|
|
23690
|
-
function
|
|
23691
|
-
|
|
23692
|
-
return harness;
|
|
23693
|
-
}
|
|
23694
|
-
const target = harness;
|
|
23695
|
-
if (target[WRAPPED_FLUE_HARNESS]) {
|
|
23696
|
-
return harness;
|
|
23697
|
-
}
|
|
23698
|
-
const originalSession = target.session.bind(target);
|
|
23699
|
-
try {
|
|
23700
|
-
Object.defineProperty(target, WRAPPED_FLUE_HARNESS, {
|
|
23701
|
-
configurable: false,
|
|
23702
|
-
enumerable: false,
|
|
23703
|
-
value: true
|
|
23704
|
-
});
|
|
23705
|
-
Object.defineProperty(target, "session", {
|
|
23706
|
-
configurable: true,
|
|
23707
|
-
value: async function wrappedFlueHarnessSession(name, options) {
|
|
23708
|
-
const session = await originalSession(name, options);
|
|
23709
|
-
return patchFlueSessionInPlace(session);
|
|
23710
|
-
},
|
|
23711
|
-
writable: true
|
|
23712
|
-
});
|
|
23713
|
-
const sessions = target.sessions;
|
|
23714
|
-
if (sessions && typeof sessions === "object") {
|
|
23715
|
-
patchFlueSessionFactory(sessions, "get");
|
|
23716
|
-
patchFlueSessionFactory(sessions, "create");
|
|
23717
|
-
}
|
|
23718
|
-
} catch (e51) {
|
|
23719
|
-
}
|
|
23720
|
-
return harness;
|
|
23666
|
+
function isFlueObserveBridge(value) {
|
|
23667
|
+
return isObjectLike(value) && typeof Reflect.get(value, "handle") === "function" && typeof Reflect.get(value, "reset") === "function";
|
|
23721
23668
|
}
|
|
23722
|
-
function
|
|
23723
|
-
|
|
23724
|
-
return session;
|
|
23725
|
-
}
|
|
23726
|
-
try {
|
|
23727
|
-
Object.defineProperty(session, WRAPPED_FLUE_SESSION, {
|
|
23728
|
-
configurable: false,
|
|
23729
|
-
enumerable: false,
|
|
23730
|
-
value: true
|
|
23731
|
-
});
|
|
23732
|
-
patchCallHandleMethod(session, "prompt", _chunkNKD77KGBjs.flueChannels.prompt);
|
|
23733
|
-
patchCallHandleMethod(session, "skill", _chunkNKD77KGBjs.flueChannels.skill);
|
|
23734
|
-
patchCallHandleMethod(session, "task", _chunkNKD77KGBjs.flueChannels.task);
|
|
23735
|
-
patchCompact(session);
|
|
23736
|
-
} catch (e52) {
|
|
23737
|
-
}
|
|
23738
|
-
return session;
|
|
23669
|
+
function isAutoState(value) {
|
|
23670
|
+
return isObjectLike(value) && Reflect.get(value, "contexts") instanceof WeakSet && typeof Reflect.get(value, "refCount") === "number";
|
|
23739
23671
|
}
|
|
23740
|
-
function
|
|
23741
|
-
|
|
23742
|
-
if (
|
|
23672
|
+
function releaseAutoState(state) {
|
|
23673
|
+
state.refCount -= 1;
|
|
23674
|
+
if (state.refCount > 0) {
|
|
23743
23675
|
return;
|
|
23744
23676
|
}
|
|
23745
|
-
|
|
23746
|
-
|
|
23747
|
-
|
|
23748
|
-
|
|
23749
|
-
|
|
23750
|
-
|
|
23751
|
-
},
|
|
23752
|
-
writable: true
|
|
23753
|
-
});
|
|
23754
|
-
}
|
|
23755
|
-
function patchCallHandleMethod(session, method, channel) {
|
|
23756
|
-
const original = session[method];
|
|
23757
|
-
if (typeof original !== "function") {
|
|
23758
|
-
return;
|
|
23677
|
+
try {
|
|
23678
|
+
if (state.channel && state.handlers) {
|
|
23679
|
+
state.channel.unsubscribe(state.handlers);
|
|
23680
|
+
}
|
|
23681
|
+
} finally {
|
|
23682
|
+
Reflect.deleteProperty(globalThis, FLUE_AUTO_STATE);
|
|
23759
23683
|
}
|
|
23760
|
-
const bound = original.bind(session);
|
|
23761
|
-
Object.defineProperty(session, method, {
|
|
23762
|
-
configurable: true,
|
|
23763
|
-
value(input, options) {
|
|
23764
|
-
const args = [input, options];
|
|
23765
|
-
const { originalResult, traced: traced2 } = traceFlueOperation(channel, {
|
|
23766
|
-
context: {
|
|
23767
|
-
arguments: args,
|
|
23768
|
-
operation: method,
|
|
23769
|
-
session
|
|
23770
|
-
},
|
|
23771
|
-
run: () => bound(input, options)
|
|
23772
|
-
});
|
|
23773
|
-
return preserveCallHandle(originalResult, traced2);
|
|
23774
|
-
},
|
|
23775
|
-
writable: true
|
|
23776
|
-
});
|
|
23777
23684
|
}
|
|
23778
|
-
function
|
|
23779
|
-
|
|
23780
|
-
if (typeof original !== "function") {
|
|
23685
|
+
function subscribeToFlueContext(value, state) {
|
|
23686
|
+
if (!isObservableFlueContext(value) || state.contexts.has(value)) {
|
|
23781
23687
|
return;
|
|
23782
23688
|
}
|
|
23783
|
-
const
|
|
23784
|
-
|
|
23785
|
-
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
};
|
|
23792
|
-
return _chunkNKD77KGBjs.flueChannels.compact.tracePromise(() => bound(), context);
|
|
23793
|
-
},
|
|
23794
|
-
writable: true
|
|
23795
|
-
});
|
|
23796
|
-
}
|
|
23797
|
-
function traceFlueOperation(channel, args) {
|
|
23798
|
-
const tracingChannel2 = channel.tracingChannel();
|
|
23799
|
-
const context = args.context;
|
|
23800
|
-
let originalResult;
|
|
23801
|
-
let traced2;
|
|
23802
|
-
const run = () => {
|
|
23689
|
+
const ctx = flueContextFromUnknown(value);
|
|
23690
|
+
let released = false;
|
|
23691
|
+
let unsubscribe;
|
|
23692
|
+
const release = () => {
|
|
23693
|
+
if (released) {
|
|
23694
|
+
return;
|
|
23695
|
+
}
|
|
23696
|
+
released = true;
|
|
23803
23697
|
try {
|
|
23804
|
-
|
|
23805
|
-
_optionalChain([tracingChannel2, 'access', _564 => _564.end, 'optionalAccess', _565 => _565.publish, 'call', _566 => _566(context)]);
|
|
23698
|
+
_optionalChain([unsubscribe, 'optionalCall', _564 => _564()]);
|
|
23806
23699
|
} catch (error) {
|
|
23807
|
-
context
|
|
23808
|
-
_optionalChain([tracingChannel2, 'access', _567 => _567.error, 'optionalAccess', _568 => _568.publish, 'call', _569 => _569(context)]);
|
|
23809
|
-
_optionalChain([tracingChannel2, 'access', _570 => _570.end, 'optionalAccess', _571 => _571.publish, 'call', _572 => _572(context)]);
|
|
23810
|
-
throw error;
|
|
23700
|
+
logInstrumentationError3("Flue context unsubscribe", error);
|
|
23811
23701
|
}
|
|
23812
|
-
traced2 = Promise.resolve(originalResult).then(
|
|
23813
|
-
(result) => {
|
|
23814
|
-
context.result = result;
|
|
23815
|
-
_optionalChain([tracingChannel2, 'access', _573 => _573.asyncStart, 'optionalAccess', _574 => _574.publish, 'call', _575 => _575(context)]);
|
|
23816
|
-
_optionalChain([tracingChannel2, 'access', _576 => _576.asyncEnd, 'optionalAccess', _577 => _577.publish, 'call', _578 => _578(context)]);
|
|
23817
|
-
return result;
|
|
23818
|
-
},
|
|
23819
|
-
(error) => {
|
|
23820
|
-
context.error = normalizeError3(error);
|
|
23821
|
-
_optionalChain([tracingChannel2, 'access', _579 => _579.error, 'optionalAccess', _580 => _580.publish, 'call', _581 => _581(context)]);
|
|
23822
|
-
_optionalChain([tracingChannel2, 'access', _582 => _582.asyncStart, 'optionalAccess', _583 => _583.publish, 'call', _584 => _584(context)]);
|
|
23823
|
-
_optionalChain([tracingChannel2, 'access', _585 => _585.asyncEnd, 'optionalAccess', _586 => _586.publish, 'call', _587 => _587(context)]);
|
|
23824
|
-
throw error;
|
|
23825
|
-
}
|
|
23826
|
-
);
|
|
23827
23702
|
};
|
|
23828
|
-
|
|
23829
|
-
|
|
23830
|
-
|
|
23831
|
-
|
|
23832
|
-
|
|
23703
|
+
try {
|
|
23704
|
+
unsubscribe = value.subscribeEvent((event) => {
|
|
23705
|
+
if (state.refCount <= 0) {
|
|
23706
|
+
release();
|
|
23707
|
+
return;
|
|
23708
|
+
}
|
|
23709
|
+
braintrustFlueObserver(event, ctx);
|
|
23710
|
+
if (isAutoContextTerminalEvent(event, ctx)) {
|
|
23711
|
+
release();
|
|
23712
|
+
}
|
|
23713
|
+
});
|
|
23714
|
+
state.contexts.add(value);
|
|
23715
|
+
} catch (error) {
|
|
23716
|
+
logInstrumentationError3("Flue context subscription", error);
|
|
23833
23717
|
}
|
|
23834
|
-
return { originalResult, traced: traced2 };
|
|
23835
|
-
}
|
|
23836
|
-
function normalizeError3(error) {
|
|
23837
|
-
return error instanceof Error ? error : new Error(String(error));
|
|
23838
23718
|
}
|
|
23839
|
-
function
|
|
23840
|
-
if (!
|
|
23841
|
-
return
|
|
23719
|
+
function isAutoContextTerminalEvent(event, ctx) {
|
|
23720
|
+
if (!isObjectLike(event)) {
|
|
23721
|
+
return false;
|
|
23842
23722
|
}
|
|
23843
|
-
const
|
|
23844
|
-
|
|
23845
|
-
|
|
23846
|
-
|
|
23847
|
-
|
|
23848
|
-
|
|
23849
|
-
|
|
23850
|
-
|
|
23851
|
-
then(onfulfilled, onrejected) {
|
|
23852
|
-
return traced2.then(onfulfilled, onrejected);
|
|
23853
|
-
}
|
|
23854
|
-
};
|
|
23855
|
-
return wrapped;
|
|
23723
|
+
const type = Reflect.get(event, "type");
|
|
23724
|
+
if (type === "run_end") {
|
|
23725
|
+
return true;
|
|
23726
|
+
}
|
|
23727
|
+
if (type !== "operation") {
|
|
23728
|
+
return false;
|
|
23729
|
+
}
|
|
23730
|
+
return !_optionalChain([ctx, 'optionalAccess', _565 => _565.runId]) && typeof Reflect.get(event, "runId") !== "string";
|
|
23856
23731
|
}
|
|
23857
|
-
function
|
|
23858
|
-
return
|
|
23732
|
+
function isObservableFlueContext(value) {
|
|
23733
|
+
return isObjectLike(value) && typeof Reflect.get(value, "subscribeEvent") === "function";
|
|
23859
23734
|
}
|
|
23860
|
-
function
|
|
23861
|
-
|
|
23735
|
+
function isFlueEvent(event) {
|
|
23736
|
+
const type = Reflect.get(event, "type");
|
|
23737
|
+
return type === "run_start" || type === "run_end" || type === "operation_start" || type === "operation" || type === "turn_request" || type === "turn" || type === "tool_start" || type === "tool_call" || type === "task_start" || type === "task" || type === "compaction_start" || type === "compaction";
|
|
23862
23738
|
}
|
|
23863
|
-
function
|
|
23864
|
-
|
|
23739
|
+
function flueContextFromUnknown(ctx) {
|
|
23740
|
+
if (!isObjectLike(ctx)) {
|
|
23741
|
+
return void 0;
|
|
23742
|
+
}
|
|
23743
|
+
const id = Reflect.get(ctx, "id");
|
|
23744
|
+
const runId = Reflect.get(ctx, "runId");
|
|
23745
|
+
return {
|
|
23746
|
+
...typeof id === "string" ? { id } : {},
|
|
23747
|
+
...typeof runId === "string" ? { runId } : {}
|
|
23748
|
+
};
|
|
23865
23749
|
}
|
|
23866
|
-
function
|
|
23867
|
-
return
|
|
23750
|
+
function isObjectLike(value) {
|
|
23751
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23868
23752
|
}
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
|
|
23874
|
-
__init74() {this.compactionsByScope = /* @__PURE__ */ new Map()}
|
|
23875
|
-
__init75() {this.pendingOperationsByKey = /* @__PURE__ */ new Map()}
|
|
23753
|
+
var FlueObserveBridge = (_class22 = class {constructor() { _class22.prototype.__init72.call(this);_class22.prototype.__init73.call(this);_class22.prototype.__init74.call(this);_class22.prototype.__init75.call(this);_class22.prototype.__init76.call(this);_class22.prototype.__init77.call(this);_class22.prototype.__init78.call(this); }
|
|
23754
|
+
__init72() {this.compactionsByKey = /* @__PURE__ */ new Map()}
|
|
23755
|
+
__init73() {this.operationsById = /* @__PURE__ */ new Map()}
|
|
23756
|
+
__init74() {this.runsById = /* @__PURE__ */ new Map()}
|
|
23757
|
+
__init75() {this.seenEvents = /* @__PURE__ */ new WeakSet()}
|
|
23876
23758
|
__init76() {this.tasksById = /* @__PURE__ */ new Map()}
|
|
23877
|
-
__init77() {this.
|
|
23878
|
-
__init78() {this.
|
|
23879
|
-
|
|
23880
|
-
|
|
23881
|
-
|
|
23882
|
-
this.subscribeToContextEvents();
|
|
23883
|
-
this.subscribeToSessionOperations();
|
|
23884
|
-
}
|
|
23885
|
-
onDisable() {
|
|
23886
|
-
for (const unsubscribe of this.unsubscribers) {
|
|
23887
|
-
unsubscribe();
|
|
23759
|
+
__init77() {this.toolsByKey = /* @__PURE__ */ new Map()}
|
|
23760
|
+
__init78() {this.turnsByKey = /* @__PURE__ */ new Map()}
|
|
23761
|
+
handle(event, ctx) {
|
|
23762
|
+
if (!isObjectLike(event) || !isFlueEvent(event)) {
|
|
23763
|
+
return;
|
|
23888
23764
|
}
|
|
23889
|
-
this.
|
|
23890
|
-
|
|
23891
|
-
|
|
23892
|
-
this.
|
|
23893
|
-
|
|
23765
|
+
if (this.seenEvents.has(event)) {
|
|
23766
|
+
return;
|
|
23767
|
+
}
|
|
23768
|
+
this.seenEvents.add(event);
|
|
23769
|
+
try {
|
|
23770
|
+
this.handleEvent(event, flueContextFromUnknown(ctx));
|
|
23771
|
+
} catch (error) {
|
|
23772
|
+
logInstrumentationError3("Flue observe", error);
|
|
23773
|
+
}
|
|
23774
|
+
}
|
|
23775
|
+
reset() {
|
|
23776
|
+
this.compactionsByKey.clear();
|
|
23777
|
+
this.operationsById.clear();
|
|
23778
|
+
this.runsById.clear();
|
|
23779
|
+
this.seenEvents = /* @__PURE__ */ new WeakSet();
|
|
23894
23780
|
this.tasksById.clear();
|
|
23895
|
-
this.
|
|
23896
|
-
this.
|
|
23781
|
+
this.toolsByKey.clear();
|
|
23782
|
+
this.turnsByKey.clear();
|
|
23897
23783
|
}
|
|
23898
|
-
|
|
23899
|
-
|
|
23900
|
-
|
|
23901
|
-
|
|
23902
|
-
|
|
23903
|
-
|
|
23904
|
-
|
|
23905
|
-
|
|
23906
|
-
|
|
23907
|
-
|
|
23908
|
-
|
|
23909
|
-
|
|
23910
|
-
|
|
23911
|
-
|
|
23912
|
-
|
|
23913
|
-
|
|
23914
|
-
|
|
23915
|
-
|
|
23784
|
+
handleEvent(event, ctx) {
|
|
23785
|
+
switch (event.type) {
|
|
23786
|
+
case "run_start":
|
|
23787
|
+
this.handleRunStart(event, ctx);
|
|
23788
|
+
return;
|
|
23789
|
+
case "run_end":
|
|
23790
|
+
this.handleRunEnd(event);
|
|
23791
|
+
return;
|
|
23792
|
+
case "operation_start":
|
|
23793
|
+
this.handleOperationStart(event);
|
|
23794
|
+
return;
|
|
23795
|
+
case "operation":
|
|
23796
|
+
this.handleOperation(event);
|
|
23797
|
+
return;
|
|
23798
|
+
case "turn_request":
|
|
23799
|
+
this.handleTurnRequest(event);
|
|
23800
|
+
return;
|
|
23801
|
+
case "turn":
|
|
23802
|
+
this.handleTurn(event);
|
|
23803
|
+
return;
|
|
23804
|
+
case "tool_start":
|
|
23805
|
+
this.handleToolStart(event);
|
|
23806
|
+
return;
|
|
23807
|
+
case "tool_call":
|
|
23808
|
+
this.handleToolCall(event);
|
|
23809
|
+
return;
|
|
23810
|
+
case "task_start":
|
|
23811
|
+
this.handleTaskStart(event);
|
|
23812
|
+
return;
|
|
23813
|
+
case "task":
|
|
23814
|
+
this.handleTask(event);
|
|
23815
|
+
return;
|
|
23816
|
+
case "compaction_start":
|
|
23817
|
+
this.handleCompactionStart(event);
|
|
23818
|
+
return;
|
|
23819
|
+
case "compaction":
|
|
23820
|
+
this.handleCompaction(event);
|
|
23821
|
+
return;
|
|
23822
|
+
default:
|
|
23823
|
+
return;
|
|
23824
|
+
}
|
|
23916
23825
|
}
|
|
23917
|
-
|
|
23918
|
-
|
|
23919
|
-
|
|
23920
|
-
|
|
23921
|
-
|
|
23922
|
-
|
|
23923
|
-
|
|
23924
|
-
|
|
23925
|
-
|
|
23926
|
-
|
|
23927
|
-
wrapFlueHarness(event.harness);
|
|
23928
|
-
}
|
|
23929
|
-
},
|
|
23930
|
-
error: () => {
|
|
23931
|
-
}
|
|
23826
|
+
handleRunStart(event, ctx) {
|
|
23827
|
+
if (!event.runId) {
|
|
23828
|
+
return;
|
|
23829
|
+
}
|
|
23830
|
+
const workflowName = _nullishCoalesce(_nullishCoalesce(event.workflowName, () => ( _optionalChain([event, 'access', _566 => _566.owner, 'optionalAccess', _567 => _567.workflowName]))), () => ( (typeof _optionalChain([ctx, 'optionalAccess', _568 => _568.id]) === "string" ? ctx.id : "unknown")));
|
|
23831
|
+
const metadata = {
|
|
23832
|
+
...extractPayloadMetadata(event.payload),
|
|
23833
|
+
...extractEventMetadata(event, ctx),
|
|
23834
|
+
...workflowName ? { "flue.workflow_name": workflowName } : {},
|
|
23835
|
+
provider: "flue"
|
|
23932
23836
|
};
|
|
23933
|
-
|
|
23934
|
-
|
|
23935
|
-
|
|
23837
|
+
const span = startSpan({
|
|
23838
|
+
name: `workflow:${workflowName}`,
|
|
23839
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
23840
|
+
startTime: eventTime(_nullishCoalesce(event.startedAt, () => ( event.timestamp))),
|
|
23841
|
+
event: {
|
|
23842
|
+
input: event.payload,
|
|
23843
|
+
metadata
|
|
23844
|
+
}
|
|
23936
23845
|
});
|
|
23846
|
+
this.runsById.set(event.runId, { metadata, span });
|
|
23937
23847
|
}
|
|
23938
|
-
|
|
23939
|
-
this.
|
|
23940
|
-
this.
|
|
23941
|
-
|
|
23942
|
-
|
|
23943
|
-
|
|
23944
|
-
|
|
23945
|
-
|
|
23946
|
-
|
|
23947
|
-
|
|
23948
|
-
|
|
23949
|
-
|
|
23950
|
-
|
|
23951
|
-
}
|
|
23952
|
-
const state = this.startOperationState({
|
|
23953
|
-
args: event.arguments,
|
|
23954
|
-
moduleVersion: typeof event.moduleVersion === "string" ? event.moduleVersion : void 0,
|
|
23955
|
-
operation: event.operation,
|
|
23956
|
-
session: event.session
|
|
23848
|
+
handleRunEnd(event) {
|
|
23849
|
+
const state = this.runsById.get(event.runId);
|
|
23850
|
+
this.finishPendingSpansForRun(event);
|
|
23851
|
+
if (state) {
|
|
23852
|
+
safeLog3(state.span, {
|
|
23853
|
+
...event.isError ? { error: errorToString(event.error) } : {},
|
|
23854
|
+
metadata: {
|
|
23855
|
+
...state.metadata,
|
|
23856
|
+
...extractEventMetadata(event),
|
|
23857
|
+
...event.isError !== void 0 ? { "flue.is_error": event.isError } : {}
|
|
23858
|
+
},
|
|
23859
|
+
metrics: durationMetrics2(event.durationMs),
|
|
23860
|
+
output: event.result
|
|
23957
23861
|
});
|
|
23958
|
-
|
|
23959
|
-
|
|
23960
|
-
}
|
|
23961
|
-
|
|
23962
|
-
|
|
23963
|
-
|
|
23964
|
-
|
|
23965
|
-
|
|
23966
|
-
|
|
23967
|
-
|
|
23968
|
-
|
|
23969
|
-
|
|
23970
|
-
|
|
23971
|
-
|
|
23972
|
-
|
|
23973
|
-
error: (event) => {
|
|
23974
|
-
const state = states.get(event);
|
|
23975
|
-
if (state && event.error) {
|
|
23976
|
-
safeLog3(state.span, { error: errorToString(event.error) });
|
|
23977
|
-
this.finishOperationState(state);
|
|
23978
|
-
}
|
|
23979
|
-
states.delete(event);
|
|
23980
|
-
}
|
|
23862
|
+
safeEnd(state.span, eventTime(event.timestamp));
|
|
23863
|
+
this.runsById.delete(event.runId);
|
|
23864
|
+
}
|
|
23865
|
+
void flush().catch((error) => {
|
|
23866
|
+
logInstrumentationError3("Flue flush", error);
|
|
23867
|
+
});
|
|
23868
|
+
}
|
|
23869
|
+
handleOperationStart(event) {
|
|
23870
|
+
if (!event.operationId || !isInstrumentedOperation(event.operationKind)) {
|
|
23871
|
+
return;
|
|
23872
|
+
}
|
|
23873
|
+
const metadata = {
|
|
23874
|
+
...extractEventMetadata(event),
|
|
23875
|
+
"flue.operation": event.operationKind,
|
|
23876
|
+
provider: "flue"
|
|
23981
23877
|
};
|
|
23982
|
-
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
|
|
23878
|
+
const parent = this.parentSpanForEvent(event);
|
|
23879
|
+
const span = startFlueSpan(parent, {
|
|
23880
|
+
name: `flue.${event.operationKind}`,
|
|
23881
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
23882
|
+
startTime: eventTime(event.timestamp),
|
|
23883
|
+
event: { metadata }
|
|
23986
23884
|
});
|
|
23885
|
+
this.operationsById.set(event.operationId, { metadata, span });
|
|
23987
23886
|
}
|
|
23988
|
-
|
|
23989
|
-
|
|
23990
|
-
|
|
23991
|
-
|
|
23992
|
-
|
|
23993
|
-
|
|
23994
|
-
|
|
23995
|
-
|
|
23996
|
-
|
|
23997
|
-
|
|
23998
|
-
|
|
23999
|
-
operation: event.operation,
|
|
24000
|
-
session: event.session
|
|
24001
|
-
});
|
|
24002
|
-
states.set(event, state);
|
|
24003
|
-
return state;
|
|
24004
|
-
};
|
|
24005
|
-
const unbindCurrentSpanStore = this.bindCurrentSpanStoreToOperationStart(
|
|
24006
|
-
tracingChannel2,
|
|
24007
|
-
ensureState2
|
|
24008
|
-
);
|
|
24009
|
-
const handlers = {
|
|
24010
|
-
start: (event) => {
|
|
24011
|
-
ensureState2(event);
|
|
24012
|
-
},
|
|
24013
|
-
asyncEnd: (event) => {
|
|
24014
|
-
this.endOperationState(states.get(event), void 0);
|
|
24015
|
-
states.delete(event);
|
|
24016
|
-
},
|
|
24017
|
-
error: (event) => {
|
|
24018
|
-
const state = states.get(event);
|
|
24019
|
-
if (state && event.error) {
|
|
24020
|
-
safeLog3(state.span, { error: errorToString(event.error) });
|
|
24021
|
-
this.finishOperationState(state);
|
|
24022
|
-
}
|
|
24023
|
-
states.delete(event);
|
|
24024
|
-
}
|
|
24025
|
-
};
|
|
24026
|
-
tracingChannel2.subscribe(handlers);
|
|
24027
|
-
this.unsubscribers.push(() => {
|
|
24028
|
-
_optionalChain([unbindCurrentSpanStore, 'optionalCall', _594 => _594()]);
|
|
24029
|
-
tracingChannel2.unsubscribe(handlers);
|
|
24030
|
-
});
|
|
24031
|
-
}
|
|
24032
|
-
subscribeToContextEvents() {
|
|
24033
|
-
const channel = _chunkNKD77KGBjs.flueChannels.contextEvent.tracingChannel();
|
|
24034
|
-
const handlers = {
|
|
24035
|
-
start: (event) => {
|
|
24036
|
-
const flueEvent = event.arguments[0];
|
|
24037
|
-
if (!flueEvent) {
|
|
24038
|
-
return;
|
|
24039
|
-
}
|
|
24040
|
-
try {
|
|
24041
|
-
this.handleFlueEvent(flueEvent, {
|
|
24042
|
-
captureTurnSpans: event.captureTurnSpans !== false
|
|
24043
|
-
});
|
|
24044
|
-
} catch (error) {
|
|
24045
|
-
logInstrumentationError3("Flue event", error);
|
|
24046
|
-
}
|
|
24047
|
-
},
|
|
24048
|
-
error: () => {
|
|
24049
|
-
}
|
|
24050
|
-
};
|
|
24051
|
-
channel.subscribe(handlers);
|
|
24052
|
-
this.unsubscribers.push(() => {
|
|
24053
|
-
channel.unsubscribe(handlers);
|
|
24054
|
-
});
|
|
24055
|
-
}
|
|
24056
|
-
bindCurrentSpanStoreToOperationStart(tracingChannel2, ensureState2) {
|
|
24057
|
-
const state = _internalGetGlobalState();
|
|
24058
|
-
const startChannel = tracingChannel2.start;
|
|
24059
|
-
const contextManager = _optionalChain([state, 'optionalAccess', _595 => _595.contextManager]);
|
|
24060
|
-
const currentSpanStore = contextManager ? contextManager[BRAINTRUST_CURRENT_SPAN_STORE] : void 0;
|
|
24061
|
-
if (!currentSpanStore || !startChannel) {
|
|
24062
|
-
return void 0;
|
|
24063
|
-
}
|
|
24064
|
-
startChannel.bindStore(currentSpanStore, (event) => {
|
|
24065
|
-
const operationState = ensureState2(event);
|
|
24066
|
-
return contextManager.wrapSpanForStore(operationState.span);
|
|
24067
|
-
});
|
|
24068
|
-
return () => {
|
|
24069
|
-
startChannel.unbindStore(currentSpanStore);
|
|
24070
|
-
};
|
|
24071
|
-
}
|
|
24072
|
-
startOperationState(args) {
|
|
24073
|
-
const sessionName = getSessionName(args.session);
|
|
24074
|
-
const metadata = {
|
|
24075
|
-
...extractOperationInputMetadata(args.operation, args.args),
|
|
24076
|
-
...extractSessionMetadata(args.session),
|
|
24077
|
-
"flue.operation": args.operation,
|
|
24078
|
-
provider: "flue",
|
|
24079
|
-
...args.moduleVersion ? { "flue.version": args.moduleVersion } : {}
|
|
24080
|
-
};
|
|
24081
|
-
const span = startSpan({
|
|
24082
|
-
name: `flue.session.${args.operation}`,
|
|
24083
|
-
spanAttributes: { type: "task" /* TASK */ }
|
|
24084
|
-
});
|
|
24085
|
-
const state = {
|
|
24086
|
-
metadata,
|
|
24087
|
-
operation: args.operation,
|
|
24088
|
-
sessionName,
|
|
24089
|
-
span,
|
|
24090
|
-
startTime: getCurrentUnixTimestamp()
|
|
24091
|
-
};
|
|
24092
|
-
safeLog3(span, {
|
|
24093
|
-
input: extractOperationInput(args.operation, args.args),
|
|
24094
|
-
metadata
|
|
24095
|
-
});
|
|
24096
|
-
this.pendingOperationQueue(operationKey(sessionName, args.operation)).push(
|
|
24097
|
-
state
|
|
24098
|
-
);
|
|
24099
|
-
addOperationToScope(
|
|
24100
|
-
this.activeOperationsByScope,
|
|
24101
|
-
_nullishCoalesce(sessionName, () => ( "unknown")),
|
|
24102
|
-
state
|
|
24103
|
-
);
|
|
24104
|
-
return state;
|
|
24105
|
-
}
|
|
24106
|
-
endOperationState(state, result) {
|
|
24107
|
-
if (!state) {
|
|
24108
|
-
return;
|
|
24109
|
-
}
|
|
24110
|
-
const metadata = {
|
|
24111
|
-
...state.metadata,
|
|
24112
|
-
...extractPromptResponseMetadata(result)
|
|
24113
|
-
};
|
|
24114
|
-
const metrics = {
|
|
24115
|
-
...buildDurationMetrics3(state.startTime),
|
|
24116
|
-
...metricsFromUsage(_optionalChain([result, 'optionalAccess', _596 => _596.usage]))
|
|
23887
|
+
handleOperation(event) {
|
|
23888
|
+
if (!isInstrumentedOperation(event.operationKind)) {
|
|
23889
|
+
return;
|
|
23890
|
+
}
|
|
23891
|
+
const state = _nullishCoalesce(this.operationsById.get(event.operationId), () => ( this.startSyntheticOperation(event)));
|
|
23892
|
+
const output = operationOutput(event);
|
|
23893
|
+
const metadata = {
|
|
23894
|
+
...state.metadata,
|
|
23895
|
+
...extractEventMetadata(event),
|
|
23896
|
+
...event.isError !== void 0 ? { "flue.is_error": event.isError } : {},
|
|
23897
|
+
...event.usage ? { "flue.usage": event.usage } : {}
|
|
24117
23898
|
};
|
|
23899
|
+
this.finishPendingChildrenForOperation(event, output);
|
|
24118
23900
|
safeLog3(state.span, {
|
|
23901
|
+
...event.isError ? { error: errorToString(event.error) } : {},
|
|
24119
23902
|
metadata,
|
|
24120
|
-
metrics,
|
|
24121
|
-
output
|
|
23903
|
+
metrics: durationMetrics2(event.durationMs),
|
|
23904
|
+
output
|
|
24122
23905
|
});
|
|
24123
|
-
|
|
24124
|
-
this.
|
|
23906
|
+
safeEnd(state.span, eventTime(event.timestamp));
|
|
23907
|
+
this.operationsById.delete(event.operationId);
|
|
24125
23908
|
}
|
|
24126
|
-
|
|
24127
|
-
|
|
24128
|
-
if (
|
|
24129
|
-
this.activeOperationsById.delete(state.operationId);
|
|
24130
|
-
}
|
|
24131
|
-
removeScopedOperation(this.activeOperationsByScope, state);
|
|
24132
|
-
state.span.end();
|
|
24133
|
-
}
|
|
24134
|
-
handleFlueEvent(event, options) {
|
|
24135
|
-
switch (event.type) {
|
|
24136
|
-
case "operation_start":
|
|
24137
|
-
this.handleOperationStart(event);
|
|
24138
|
-
return;
|
|
24139
|
-
case "operation":
|
|
24140
|
-
this.handleOperation(event);
|
|
24141
|
-
return;
|
|
24142
|
-
case "text_delta":
|
|
24143
|
-
if (!options.captureTurnSpans) {
|
|
24144
|
-
return;
|
|
24145
|
-
}
|
|
24146
|
-
this.ensureTurnState(event).text.push(
|
|
24147
|
-
typeof event.text === "string" ? event.text : ""
|
|
24148
|
-
);
|
|
24149
|
-
return;
|
|
24150
|
-
case "thinking_start":
|
|
24151
|
-
if (!options.captureTurnSpans) {
|
|
24152
|
-
return;
|
|
24153
|
-
}
|
|
24154
|
-
this.handleThinkingStart(event);
|
|
24155
|
-
return;
|
|
24156
|
-
case "thinking_delta":
|
|
24157
|
-
if (!options.captureTurnSpans) {
|
|
24158
|
-
return;
|
|
24159
|
-
}
|
|
24160
|
-
this.handleThinkingDelta(event);
|
|
24161
|
-
return;
|
|
24162
|
-
case "thinking_end":
|
|
24163
|
-
if (!options.captureTurnSpans) {
|
|
24164
|
-
return;
|
|
24165
|
-
}
|
|
24166
|
-
this.handleThinkingEnd(event);
|
|
24167
|
-
return;
|
|
24168
|
-
case "turn":
|
|
24169
|
-
if (!options.captureTurnSpans) {
|
|
24170
|
-
return;
|
|
24171
|
-
}
|
|
24172
|
-
this.handleTurn(event);
|
|
24173
|
-
return;
|
|
24174
|
-
case "tool_start":
|
|
24175
|
-
this.handleToolStart(event, options);
|
|
24176
|
-
return;
|
|
24177
|
-
case "tool_call":
|
|
24178
|
-
this.handleToolCall(event);
|
|
24179
|
-
return;
|
|
24180
|
-
case "task_start":
|
|
24181
|
-
this.handleTaskStart(event);
|
|
24182
|
-
return;
|
|
24183
|
-
case "task":
|
|
24184
|
-
this.handleTask(event);
|
|
24185
|
-
return;
|
|
24186
|
-
case "compaction_start":
|
|
24187
|
-
this.handleCompactionStart(event);
|
|
24188
|
-
return;
|
|
24189
|
-
case "compaction":
|
|
24190
|
-
this.handleCompaction(event);
|
|
24191
|
-
return;
|
|
24192
|
-
default:
|
|
24193
|
-
return;
|
|
24194
|
-
}
|
|
24195
|
-
}
|
|
24196
|
-
handleOperationStart(event) {
|
|
24197
|
-
if (!isInstrumentedOperation(event.operationKind)) {
|
|
24198
|
-
return;
|
|
24199
|
-
}
|
|
24200
|
-
const state = this.takePendingOperationForEvent(event);
|
|
24201
|
-
if (!state) {
|
|
24202
|
-
return;
|
|
24203
|
-
}
|
|
24204
|
-
state.operationId = event.operationId;
|
|
24205
|
-
this.activeOperationsById.set(event.operationId, state);
|
|
24206
|
-
addScopedOperation(this.activeOperationsByScope, event, state);
|
|
24207
|
-
state.metadata = {
|
|
24208
|
-
...state.metadata,
|
|
24209
|
-
...extractEventMetadata(event),
|
|
24210
|
-
"flue.operation_id": event.operationId
|
|
24211
|
-
};
|
|
24212
|
-
safeLog3(state.span, { metadata: state.metadata });
|
|
24213
|
-
}
|
|
24214
|
-
handleOperation(event) {
|
|
24215
|
-
const state = event.operationId ? this.activeOperationsById.get(event.operationId) : void 0;
|
|
24216
|
-
if (!state) {
|
|
23909
|
+
handleTurnRequest(event) {
|
|
23910
|
+
const key = turnKey(event);
|
|
23911
|
+
if (!key) {
|
|
24217
23912
|
return;
|
|
24218
23913
|
}
|
|
24219
23914
|
const metadata = {
|
|
24220
|
-
...state.metadata,
|
|
24221
23915
|
...extractEventMetadata(event),
|
|
24222
|
-
...
|
|
24223
|
-
...event.
|
|
24224
|
-
|
|
24225
|
-
|
|
24226
|
-
|
|
24227
|
-
...event.
|
|
24228
|
-
|
|
24229
|
-
...
|
|
24230
|
-
});
|
|
24231
|
-
}
|
|
24232
|
-
ensureTurnState(event) {
|
|
24233
|
-
const scope = scopeKey(event);
|
|
24234
|
-
const existing = this.turnsByScope.get(scope);
|
|
24235
|
-
if (existing) {
|
|
24236
|
-
return existing;
|
|
24237
|
-
}
|
|
24238
|
-
const parent = this.parentSpanForEvent(event);
|
|
24239
|
-
const metadata = {
|
|
24240
|
-
...extractEventMetadata(event),
|
|
24241
|
-
provider: "flue"
|
|
23916
|
+
...event.api ? { "flue.api": event.api } : {},
|
|
23917
|
+
...event.model ? { model: event.model, "flue.model": event.model } : {},
|
|
23918
|
+
...event.provider ? { provider: event.provider } : { provider: "flue" },
|
|
23919
|
+
...event.provider ? { "flue.provider": event.provider } : {},
|
|
23920
|
+
...event.purpose ? { "flue.turn_purpose": event.purpose } : {},
|
|
23921
|
+
...event.reasoning ? { reasoning: event.reasoning } : {},
|
|
23922
|
+
..._optionalChain([event, 'access', _569 => _569.input, 'optionalAccess', _570 => _570.systemPrompt]) ? { "flue.system_prompt": event.input.systemPrompt } : {},
|
|
23923
|
+
..._optionalChain([event, 'access', _571 => _571.input, 'optionalAccess', _572 => _572.tools]) ? { tools: event.input.tools } : {}
|
|
24242
23924
|
};
|
|
23925
|
+
const parent = this.parentSpanForTurn(event);
|
|
24243
23926
|
const span = startFlueSpan(parent, {
|
|
24244
|
-
name:
|
|
24245
|
-
spanAttributes: { type: "llm" /* LLM */ }
|
|
23927
|
+
name: `llm:${_nullishCoalesce(_nullishCoalesce(event.model, () => ( event.purpose)), () => ( "unknown"))}`,
|
|
23928
|
+
spanAttributes: { type: "llm" /* LLM */ },
|
|
23929
|
+
startTime: eventTime(event.timestamp),
|
|
23930
|
+
event: {
|
|
23931
|
+
input: _optionalChain([event, 'access', _573 => _573.input, 'optionalAccess', _574 => _574.messages]),
|
|
23932
|
+
metadata
|
|
23933
|
+
}
|
|
24246
23934
|
});
|
|
24247
|
-
|
|
24248
|
-
|
|
24249
|
-
|
|
24250
|
-
|
|
24251
|
-
|
|
24252
|
-
text: [],
|
|
24253
|
-
thinking: [],
|
|
24254
|
-
toolCalls: []
|
|
24255
|
-
};
|
|
24256
|
-
safeLog3(span, { metadata });
|
|
24257
|
-
this.turnsByScope.set(scope, state);
|
|
24258
|
-
return state;
|
|
23935
|
+
this.logOperationInput(
|
|
23936
|
+
event.operationId,
|
|
23937
|
+
_nullishCoalesce(_optionalChain([event, 'access', _575 => _575.input, 'optionalAccess', _576 => _576.messages]), () => ( event.input))
|
|
23938
|
+
);
|
|
23939
|
+
this.turnsByKey.set(key, { metadata, span });
|
|
24259
23940
|
}
|
|
24260
23941
|
handleTurn(event) {
|
|
24261
|
-
const
|
|
24262
|
-
|
|
24263
|
-
|
|
24264
|
-
|
|
24265
|
-
const
|
|
23942
|
+
const key = turnKey(event);
|
|
23943
|
+
if (!key) {
|
|
23944
|
+
return;
|
|
23945
|
+
}
|
|
23946
|
+
const state = _nullishCoalesce(this.turnsByKey.get(key), () => ( this.startSyntheticTurn(event)));
|
|
24266
23947
|
const metadata = {
|
|
24267
23948
|
...state.metadata,
|
|
24268
23949
|
...extractEventMetadata(event),
|
|
23950
|
+
...event.api ? { "flue.api": event.api } : {},
|
|
24269
23951
|
...event.model ? { model: event.model, "flue.model": event.model } : {},
|
|
23952
|
+
...event.provider ? { provider: event.provider } : {},
|
|
23953
|
+
...event.provider ? { "flue.provider": event.provider } : {},
|
|
23954
|
+
...event.purpose ? { "flue.turn_purpose": event.purpose } : {},
|
|
24270
23955
|
...event.stopReason ? { "flue.stop_reason": event.stopReason } : {},
|
|
24271
|
-
...event.isError !== void 0 ? { "flue.is_error": event.isError } : {}
|
|
24272
|
-
provider: "flue"
|
|
23956
|
+
...event.isError !== void 0 ? { "flue.is_error": event.isError } : {}
|
|
24273
23957
|
};
|
|
24274
23958
|
safeLog3(state.span, {
|
|
24275
|
-
...event.
|
|
23959
|
+
...event.isError ? { error: errorToString(event.error) } : {},
|
|
24276
23960
|
metadata,
|
|
24277
23961
|
metrics: {
|
|
24278
|
-
...
|
|
23962
|
+
...durationMetrics2(event.durationMs),
|
|
24279
23963
|
...metricsFromUsage(event.usage)
|
|
24280
23964
|
},
|
|
24281
|
-
output:
|
|
24282
|
-
text,
|
|
24283
|
-
event.stopReason,
|
|
24284
|
-
outputReasoning,
|
|
24285
|
-
state.toolCalls
|
|
24286
|
-
)
|
|
23965
|
+
output: event.output
|
|
24287
23966
|
});
|
|
24288
|
-
state.span.
|
|
24289
|
-
this.
|
|
23967
|
+
safeEnd(state.span, eventTime(event.timestamp));
|
|
23968
|
+
this.turnsByKey.delete(key);
|
|
24290
23969
|
}
|
|
24291
|
-
|
|
24292
|
-
|
|
24293
|
-
if (typeof delta !== "string" || !delta) {
|
|
23970
|
+
handleToolStart(event) {
|
|
23971
|
+
if (!event.toolCallId) {
|
|
24294
23972
|
return;
|
|
24295
23973
|
}
|
|
24296
|
-
const state = this.ensureTurnState(event);
|
|
24297
|
-
state.hasThinking = true;
|
|
24298
|
-
state.metadata["flue.thinking"] = true;
|
|
24299
|
-
state.thinking.push(delta);
|
|
24300
|
-
}
|
|
24301
|
-
handleThinkingStart(event) {
|
|
24302
|
-
const state = this.ensureTurnState(event);
|
|
24303
|
-
state.hasThinking = true;
|
|
24304
|
-
state.metadata["flue.thinking"] = true;
|
|
24305
|
-
}
|
|
24306
|
-
handleThinkingEnd(event) {
|
|
24307
|
-
const state = this.ensureTurnState(event);
|
|
24308
|
-
state.hasThinking = true;
|
|
24309
|
-
state.metadata["flue.thinking"] = true;
|
|
24310
|
-
if (typeof event.content === "string" && event.content) {
|
|
24311
|
-
state.finalThinking = event.content;
|
|
24312
|
-
}
|
|
24313
|
-
}
|
|
24314
|
-
handleToolStart(event, options) {
|
|
24315
|
-
const toolCallId = event.toolCallId;
|
|
24316
|
-
if (!toolCallId) {
|
|
24317
|
-
return;
|
|
24318
|
-
}
|
|
24319
|
-
const parent = this.parentSpanForEvent(event);
|
|
24320
|
-
const scope = scopeKey(event);
|
|
24321
|
-
let turnState = this.turnsByScope.get(scope);
|
|
24322
|
-
if (!turnState && parent && options.captureTurnSpans) {
|
|
24323
|
-
turnState = this.ensureTurnState(event);
|
|
24324
|
-
}
|
|
24325
23974
|
const metadata = {
|
|
24326
23975
|
...extractEventMetadata(event),
|
|
24327
23976
|
...event.toolName ? { "flue.tool_name": event.toolName } : {},
|
|
24328
|
-
"flue.tool_call_id": toolCallId,
|
|
23977
|
+
"flue.tool_call_id": event.toolCallId,
|
|
24329
23978
|
provider: "flue"
|
|
24330
23979
|
};
|
|
23980
|
+
const parent = this.parentSpanForTool(event);
|
|
24331
23981
|
const span = startFlueSpan(parent, {
|
|
24332
|
-
name: `tool
|
|
24333
|
-
spanAttributes: { type: "tool" /* TOOL */ }
|
|
24334
|
-
|
|
24335
|
-
|
|
24336
|
-
|
|
24337
|
-
|
|
24338
|
-
|
|
24339
|
-
toolName: event.toolName
|
|
24340
|
-
});
|
|
24341
|
-
}
|
|
24342
|
-
safeLog3(span, {
|
|
24343
|
-
input: event.args,
|
|
24344
|
-
metadata
|
|
24345
|
-
});
|
|
24346
|
-
this.toolsById.set(toolKey(event), {
|
|
24347
|
-
metadata,
|
|
24348
|
-
span,
|
|
24349
|
-
startTime: getCurrentUnixTimestamp()
|
|
23982
|
+
name: `tool:${_nullishCoalesce(event.toolName, () => ( "unknown"))}`,
|
|
23983
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
23984
|
+
startTime: eventTime(event.timestamp),
|
|
23985
|
+
event: {
|
|
23986
|
+
input: event.args,
|
|
23987
|
+
metadata
|
|
23988
|
+
}
|
|
24350
23989
|
});
|
|
23990
|
+
this.toolsByKey.set(toolKey(event), { metadata, span });
|
|
24351
23991
|
}
|
|
24352
23992
|
handleToolCall(event) {
|
|
23993
|
+
if (!event.toolCallId) {
|
|
23994
|
+
return;
|
|
23995
|
+
}
|
|
24353
23996
|
const key = toolKey(event);
|
|
24354
|
-
const state = _nullishCoalesce(this.
|
|
23997
|
+
const state = _nullishCoalesce(this.toolsByKey.get(key), () => ( this.startSyntheticTool(event)));
|
|
24355
23998
|
const metadata = {
|
|
24356
23999
|
...state.metadata,
|
|
24357
24000
|
...extractEventMetadata(event),
|
|
24358
24001
|
...event.toolName ? { "flue.tool_name": event.toolName } : {},
|
|
24359
|
-
|
|
24002
|
+
"flue.tool_call_id": event.toolCallId,
|
|
24360
24003
|
...event.isError !== void 0 ? { "flue.is_error": event.isError } : {}
|
|
24361
24004
|
};
|
|
24362
24005
|
safeLog3(state.span, {
|
|
24363
24006
|
...event.isError ? { error: errorToString(event.result) } : {},
|
|
24364
24007
|
metadata,
|
|
24365
|
-
metrics:
|
|
24008
|
+
metrics: durationMetrics2(event.durationMs),
|
|
24366
24009
|
output: event.result
|
|
24367
24010
|
});
|
|
24368
|
-
state.span.
|
|
24369
|
-
this.
|
|
24011
|
+
safeEnd(state.span, eventTime(event.timestamp));
|
|
24012
|
+
this.toolsByKey.delete(key);
|
|
24370
24013
|
}
|
|
24371
24014
|
handleTaskStart(event) {
|
|
24372
|
-
|
|
24015
|
+
if (!event.taskId) {
|
|
24016
|
+
return;
|
|
24017
|
+
}
|
|
24373
24018
|
const metadata = {
|
|
24374
24019
|
...extractEventMetadata(event),
|
|
24375
|
-
...event.
|
|
24020
|
+
...event.agent ? { "flue.agent": event.agent } : {},
|
|
24376
24021
|
...event.cwd ? { "flue.cwd": event.cwd } : {},
|
|
24377
24022
|
"flue.task_id": event.taskId,
|
|
24378
24023
|
provider: "flue"
|
|
24379
24024
|
};
|
|
24025
|
+
const parent = this.parentSpanForEvent(event);
|
|
24380
24026
|
const span = startFlueSpan(parent, {
|
|
24381
|
-
name: "flue.task",
|
|
24382
|
-
spanAttributes: { type: "task" /* TASK */ }
|
|
24383
|
-
|
|
24384
|
-
|
|
24385
|
-
|
|
24386
|
-
|
|
24387
|
-
|
|
24388
|
-
this.tasksById.set(event.taskId, {
|
|
24389
|
-
metadata,
|
|
24390
|
-
span,
|
|
24391
|
-
startTime: getCurrentUnixTimestamp()
|
|
24027
|
+
name: event.agent ? `task:${event.agent}` : "flue.task",
|
|
24028
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
24029
|
+
startTime: eventTime(event.timestamp),
|
|
24030
|
+
event: {
|
|
24031
|
+
input: event.prompt,
|
|
24032
|
+
metadata
|
|
24033
|
+
}
|
|
24392
24034
|
});
|
|
24035
|
+
this.tasksById.set(event.taskId, { metadata, span });
|
|
24393
24036
|
}
|
|
24394
24037
|
handleTask(event) {
|
|
24395
24038
|
const state = this.tasksById.get(event.taskId);
|
|
@@ -24401,426 +24044,372 @@ var FluePlugin = (_class22 = class extends BasePlugin {constructor(...args6) { s
|
|
|
24401
24044
|
metadata: {
|
|
24402
24045
|
...state.metadata,
|
|
24403
24046
|
...extractEventMetadata(event),
|
|
24047
|
+
...event.agent ? { "flue.agent": event.agent } : {},
|
|
24404
24048
|
...event.isError !== void 0 ? { "flue.is_error": event.isError } : {}
|
|
24405
24049
|
},
|
|
24406
|
-
metrics:
|
|
24050
|
+
metrics: durationMetrics2(event.durationMs),
|
|
24407
24051
|
output: event.result
|
|
24408
24052
|
});
|
|
24409
|
-
state.span.
|
|
24053
|
+
safeEnd(state.span, eventTime(event.timestamp));
|
|
24410
24054
|
this.tasksById.delete(event.taskId);
|
|
24411
24055
|
}
|
|
24412
24056
|
handleCompactionStart(event) {
|
|
24413
|
-
const
|
|
24414
|
-
const
|
|
24057
|
+
const key = compactionKey(event);
|
|
24058
|
+
const input = {
|
|
24059
|
+
...event.estimatedTokens !== void 0 ? { estimatedTokens: event.estimatedTokens } : {},
|
|
24060
|
+
...event.reason ? { reason: event.reason } : {}
|
|
24061
|
+
};
|
|
24415
24062
|
const metadata = {
|
|
24416
24063
|
...extractEventMetadata(event),
|
|
24417
24064
|
...event.reason ? { "flue.compaction_reason": event.reason } : {},
|
|
24418
24065
|
provider: "flue"
|
|
24419
24066
|
};
|
|
24420
|
-
const
|
|
24421
|
-
...typeof event.estimatedTokens === "number" ? { estimatedTokens: event.estimatedTokens } : {},
|
|
24422
|
-
...event.reason ? { reason: event.reason } : {}
|
|
24423
|
-
};
|
|
24067
|
+
const parent = this.parentSpanForEvent(event);
|
|
24424
24068
|
const span = startFlueSpan(parent, {
|
|
24425
|
-
name:
|
|
24426
|
-
spanAttributes: { type: "task" /* TASK */ }
|
|
24427
|
-
|
|
24428
|
-
|
|
24429
|
-
|
|
24430
|
-
|
|
24431
|
-
|
|
24432
|
-
this.compactionsByScope.set(scopeKey(event), {
|
|
24433
|
-
input,
|
|
24434
|
-
metadata,
|
|
24435
|
-
operationState,
|
|
24436
|
-
span,
|
|
24437
|
-
startTime: getCurrentUnixTimestamp()
|
|
24069
|
+
name: `compaction:${_nullishCoalesce(event.reason, () => ( "unknown"))}`,
|
|
24070
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
24071
|
+
startTime: eventTime(event.timestamp),
|
|
24072
|
+
event: {
|
|
24073
|
+
input,
|
|
24074
|
+
metadata
|
|
24075
|
+
}
|
|
24438
24076
|
});
|
|
24077
|
+
this.logOperationInput(event.operationId, input);
|
|
24078
|
+
this.compactionsByKey.set(key, { metadata, span });
|
|
24439
24079
|
}
|
|
24440
24080
|
handleCompaction(event) {
|
|
24441
|
-
const key =
|
|
24442
|
-
const state = _nullishCoalesce(this.
|
|
24443
|
-
|
|
24444
|
-
|
|
24445
|
-
|
|
24081
|
+
const key = compactionKey(event);
|
|
24082
|
+
const state = _nullishCoalesce(this.compactionsByKey.get(key), () => ( this.startSyntheticCompaction(event)));
|
|
24083
|
+
const metadata = {
|
|
24084
|
+
...state.metadata,
|
|
24085
|
+
...extractEventMetadata(event),
|
|
24086
|
+
...event.usage ? { "flue.usage": event.usage } : {}
|
|
24087
|
+
};
|
|
24446
24088
|
safeLog3(state.span, {
|
|
24447
|
-
metadata
|
|
24448
|
-
...state.metadata,
|
|
24449
|
-
...extractEventMetadata(event),
|
|
24450
|
-
...typeof event.messagesBefore === "number" ? { "flue.messages_before": event.messagesBefore } : {},
|
|
24451
|
-
...typeof event.messagesAfter === "number" ? { "flue.messages_after": event.messagesAfter } : {}
|
|
24452
|
-
},
|
|
24089
|
+
metadata,
|
|
24453
24090
|
metrics: {
|
|
24454
|
-
...
|
|
24455
|
-
...
|
|
24091
|
+
...durationMetrics2(event.durationMs),
|
|
24092
|
+
...typeof event.messagesBefore === "number" ? { messages_before: event.messagesBefore } : {},
|
|
24093
|
+
...typeof event.messagesAfter === "number" ? { messages_after: event.messagesAfter } : {}
|
|
24456
24094
|
},
|
|
24457
24095
|
output: {
|
|
24458
24096
|
messagesAfter: event.messagesAfter,
|
|
24459
24097
|
messagesBefore: event.messagesBefore
|
|
24460
24098
|
}
|
|
24461
24099
|
});
|
|
24462
|
-
state.span.
|
|
24463
|
-
this.
|
|
24100
|
+
safeEnd(state.span, eventTime(event.timestamp));
|
|
24101
|
+
this.compactionsByKey.delete(key);
|
|
24464
24102
|
}
|
|
24465
|
-
|
|
24466
|
-
|
|
24467
|
-
|
|
24468
|
-
if (
|
|
24469
|
-
return
|
|
24103
|
+
parentSpanForTurn(event) {
|
|
24104
|
+
if (event.purpose === "compaction" || event.purpose === "compaction_prefix") {
|
|
24105
|
+
const compaction = this.compactionsByKey.get(compactionKey(event));
|
|
24106
|
+
if (compaction) {
|
|
24107
|
+
return compaction.span;
|
|
24470
24108
|
}
|
|
24471
24109
|
}
|
|
24472
|
-
return
|
|
24110
|
+
return this.parentSpanForEvent(event);
|
|
24473
24111
|
}
|
|
24474
|
-
|
|
24475
|
-
|
|
24476
|
-
|
|
24477
|
-
|
|
24112
|
+
parentSpanForEvent(event) {
|
|
24113
|
+
const turn = turnKey(event);
|
|
24114
|
+
if (turn) {
|
|
24115
|
+
const turnState = this.turnsByKey.get(turn);
|
|
24116
|
+
if (turnState) {
|
|
24117
|
+
return turnState.span;
|
|
24478
24118
|
}
|
|
24479
|
-
safeLog3(state.span, {
|
|
24480
|
-
input: state.input,
|
|
24481
|
-
metadata: state.metadata,
|
|
24482
|
-
metrics: {
|
|
24483
|
-
...buildDurationMetrics3(state.startTime)
|
|
24484
|
-
},
|
|
24485
|
-
output: { completed: true }
|
|
24486
|
-
});
|
|
24487
|
-
state.span.end();
|
|
24488
|
-
this.deleteCompactionState(state);
|
|
24489
24119
|
}
|
|
24490
|
-
|
|
24491
|
-
|
|
24492
|
-
|
|
24493
|
-
|
|
24494
|
-
continue;
|
|
24120
|
+
if (event.taskId) {
|
|
24121
|
+
const task = this.tasksById.get(event.taskId);
|
|
24122
|
+
if (task) {
|
|
24123
|
+
return task.span;
|
|
24495
24124
|
}
|
|
24496
|
-
this.compactionsByScope.delete(key);
|
|
24497
|
-
return;
|
|
24498
24125
|
}
|
|
24499
|
-
}
|
|
24500
|
-
startSyntheticToolState(event, toolName) {
|
|
24501
|
-
const parent = this.parentSpanForEvent(event);
|
|
24502
|
-
const metadata = {
|
|
24503
|
-
...extractEventMetadata(event),
|
|
24504
|
-
...event.toolCallId ? { "flue.tool_call_id": event.toolCallId } : {},
|
|
24505
|
-
"flue.tool_name": toolName,
|
|
24506
|
-
provider: "flue"
|
|
24507
|
-
};
|
|
24508
|
-
const span = startFlueSpan(parent, {
|
|
24509
|
-
name: `tool: ${toolName}`,
|
|
24510
|
-
spanAttributes: { type: "tool" /* TOOL */ }
|
|
24511
|
-
});
|
|
24512
|
-
safeLog3(span, { metadata });
|
|
24513
|
-
return { metadata, span, startTime: getCurrentUnixTimestamp() };
|
|
24514
|
-
}
|
|
24515
|
-
operationStateForEvent(event) {
|
|
24516
24126
|
if (event.operationId) {
|
|
24517
|
-
const operation =
|
|
24127
|
+
const operation = this.operationsById.get(event.operationId);
|
|
24518
24128
|
if (operation) {
|
|
24519
|
-
return operation;
|
|
24129
|
+
return operation.span;
|
|
24520
24130
|
}
|
|
24521
24131
|
}
|
|
24522
|
-
|
|
24132
|
+
if (event.runId) {
|
|
24133
|
+
return _optionalChain([this, 'access', _577 => _577.runsById, 'access', _578 => _578.get, 'call', _579 => _579(event.runId), 'optionalAccess', _580 => _580.span]);
|
|
24134
|
+
}
|
|
24135
|
+
return void 0;
|
|
24523
24136
|
}
|
|
24524
|
-
|
|
24137
|
+
parentSpanForTool(event) {
|
|
24138
|
+
if (event.taskId) {
|
|
24139
|
+
const task = this.tasksById.get(event.taskId);
|
|
24140
|
+
if (task) {
|
|
24141
|
+
return task.span;
|
|
24142
|
+
}
|
|
24143
|
+
}
|
|
24525
24144
|
if (event.operationId) {
|
|
24526
|
-
const operation = this.
|
|
24145
|
+
const operation = this.operationsById.get(event.operationId);
|
|
24527
24146
|
if (operation) {
|
|
24528
24147
|
return operation.span;
|
|
24529
24148
|
}
|
|
24530
24149
|
}
|
|
24531
|
-
if (event.
|
|
24532
|
-
return _optionalChain([this, 'access',
|
|
24150
|
+
if (event.runId) {
|
|
24151
|
+
return _optionalChain([this, 'access', _581 => _581.runsById, 'access', _582 => _582.get, 'call', _583 => _583(event.runId), 'optionalAccess', _584 => _584.span]);
|
|
24533
24152
|
}
|
|
24534
|
-
return
|
|
24153
|
+
return void 0;
|
|
24535
24154
|
}
|
|
24536
|
-
|
|
24537
|
-
if (!
|
|
24538
|
-
return
|
|
24155
|
+
logOperationInput(operationId, input) {
|
|
24156
|
+
if (!operationId || input === void 0) {
|
|
24157
|
+
return;
|
|
24158
|
+
}
|
|
24159
|
+
const operation = this.operationsById.get(operationId);
|
|
24160
|
+
if (!operation || operation.loggedInput) {
|
|
24161
|
+
return;
|
|
24539
24162
|
}
|
|
24540
|
-
|
|
24541
|
-
|
|
24542
|
-
|
|
24163
|
+
safeLog3(operation.span, { input });
|
|
24164
|
+
operation.loggedInput = true;
|
|
24165
|
+
}
|
|
24166
|
+
startSyntheticOperation(event) {
|
|
24167
|
+
const metadata = {
|
|
24168
|
+
...extractEventMetadata(event),
|
|
24169
|
+
"flue.operation": event.operationKind,
|
|
24170
|
+
provider: "flue"
|
|
24171
|
+
};
|
|
24172
|
+
const span = startFlueSpan(this.parentSpanForEvent(event), {
|
|
24173
|
+
name: `flue.${event.operationKind}`,
|
|
24174
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
24175
|
+
startTime: eventTime(event.timestamp),
|
|
24176
|
+
event: { metadata }
|
|
24177
|
+
});
|
|
24178
|
+
return { metadata, span };
|
|
24179
|
+
}
|
|
24180
|
+
startSyntheticTurn(event) {
|
|
24181
|
+
const metadata = {
|
|
24182
|
+
...extractEventMetadata(event),
|
|
24183
|
+
...event.api ? { "flue.api": event.api } : {},
|
|
24184
|
+
...event.model ? { model: event.model, "flue.model": event.model } : {},
|
|
24185
|
+
...event.provider ? { provider: event.provider } : { provider: "flue" },
|
|
24186
|
+
...event.provider ? { "flue.provider": event.provider } : {},
|
|
24187
|
+
...event.purpose ? { "flue.turn_purpose": event.purpose } : {}
|
|
24188
|
+
};
|
|
24189
|
+
const span = startFlueSpan(this.parentSpanForEvent(event), {
|
|
24190
|
+
name: `llm:${_nullishCoalesce(_nullishCoalesce(event.model, () => ( event.purpose)), () => ( "unknown"))}`,
|
|
24191
|
+
spanAttributes: { type: "llm" /* LLM */ },
|
|
24192
|
+
startTime: eventTime(event.timestamp),
|
|
24193
|
+
event: { metadata }
|
|
24194
|
+
});
|
|
24195
|
+
return { metadata, span };
|
|
24196
|
+
}
|
|
24197
|
+
startSyntheticTool(event) {
|
|
24198
|
+
const metadata = {
|
|
24199
|
+
...extractEventMetadata(event),
|
|
24200
|
+
...event.toolName ? { "flue.tool_name": event.toolName } : {},
|
|
24201
|
+
"flue.tool_call_id": event.toolCallId,
|
|
24202
|
+
provider: "flue"
|
|
24203
|
+
};
|
|
24204
|
+
const span = startFlueSpan(this.parentSpanForTool(event), {
|
|
24205
|
+
name: `tool:${_nullishCoalesce(event.toolName, () => ( "unknown"))}`,
|
|
24206
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
24207
|
+
startTime: eventTime(event.timestamp),
|
|
24208
|
+
event: { metadata }
|
|
24209
|
+
});
|
|
24210
|
+
return { metadata, span };
|
|
24211
|
+
}
|
|
24212
|
+
startSyntheticCompaction(event) {
|
|
24213
|
+
const metadata = {
|
|
24214
|
+
...extractEventMetadata(event),
|
|
24215
|
+
provider: "flue"
|
|
24216
|
+
};
|
|
24217
|
+
const span = startFlueSpan(this.parentSpanForEvent(event), {
|
|
24218
|
+
name: "compaction:unknown",
|
|
24219
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
24220
|
+
startTime: eventTime(event.timestamp),
|
|
24221
|
+
event: { metadata }
|
|
24222
|
+
});
|
|
24223
|
+
return { metadata, span };
|
|
24224
|
+
}
|
|
24225
|
+
finishPendingChildrenForOperation(event, operationOutput2) {
|
|
24226
|
+
const endTime = eventTime(event.timestamp);
|
|
24227
|
+
const usage = _nullishCoalesce(event.usage, () => ( usageFromOperationResult(event.result)));
|
|
24228
|
+
const turnEntries = [...this.turnsByKey].filter(
|
|
24229
|
+
([, state]) => stateMatchesOperation(state, event.operationId)
|
|
24230
|
+
);
|
|
24231
|
+
turnEntries.forEach(([key, state], index) => {
|
|
24232
|
+
const shouldLogOperationOutput = (event.operationKind === "prompt" || event.operationKind === "skill") && index === turnEntries.length - 1 && operationOutput2 !== void 0;
|
|
24233
|
+
safeLog3(state.span, {
|
|
24234
|
+
metadata: state.metadata,
|
|
24235
|
+
metrics: metricsFromUsage(usage),
|
|
24236
|
+
...shouldLogOperationOutput ? { output: operationOutput2 } : {}
|
|
24237
|
+
});
|
|
24238
|
+
safeEnd(state.span, endTime);
|
|
24239
|
+
this.turnsByKey.delete(key);
|
|
24240
|
+
});
|
|
24241
|
+
for (const [key, state] of this.toolsByKey) {
|
|
24242
|
+
if (!stateMatchesOperation(state, event.operationId)) {
|
|
24543
24243
|
continue;
|
|
24544
24244
|
}
|
|
24545
|
-
|
|
24546
|
-
|
|
24547
|
-
|
|
24245
|
+
safeEnd(state.span, endTime);
|
|
24246
|
+
this.toolsByKey.delete(key);
|
|
24247
|
+
}
|
|
24248
|
+
for (const [key, state] of this.tasksById) {
|
|
24249
|
+
if (!stateMatchesOperation(state, event.operationId)) {
|
|
24250
|
+
continue;
|
|
24548
24251
|
}
|
|
24549
|
-
state.
|
|
24550
|
-
this.
|
|
24551
|
-
addScopedOperation(this.activeOperationsByScope, event, state);
|
|
24552
|
-
state.metadata = {
|
|
24553
|
-
...state.metadata,
|
|
24554
|
-
...extractEventMetadata(event),
|
|
24555
|
-
"flue.operation_id": event.operationId
|
|
24556
|
-
};
|
|
24557
|
-
safeLog3(state.span, { metadata: state.metadata });
|
|
24558
|
-
return state;
|
|
24252
|
+
safeEnd(state.span, endTime);
|
|
24253
|
+
this.tasksById.delete(key);
|
|
24559
24254
|
}
|
|
24560
|
-
|
|
24561
|
-
|
|
24562
|
-
|
|
24563
|
-
for (const scope of operationScopeNames(event)) {
|
|
24564
|
-
const operations = this.activeOperationsByScope.get(scope);
|
|
24565
|
-
if (_optionalChain([operations, 'optionalAccess', _605 => _605.length])) {
|
|
24566
|
-
return operations[operations.length - 1];
|
|
24255
|
+
for (const [key, state] of this.compactionsByKey) {
|
|
24256
|
+
if (!stateMatchesOperation(state, event.operationId)) {
|
|
24257
|
+
continue;
|
|
24567
24258
|
}
|
|
24259
|
+
safeLog3(state.span, {
|
|
24260
|
+
metadata: state.metadata,
|
|
24261
|
+
metrics: durationMetrics2(event.durationMs),
|
|
24262
|
+
output: { completed: true }
|
|
24263
|
+
});
|
|
24264
|
+
safeEnd(state.span, eventTime(event.timestamp));
|
|
24265
|
+
this.compactionsByKey.delete(key);
|
|
24568
24266
|
}
|
|
24569
|
-
return void 0;
|
|
24570
24267
|
}
|
|
24571
|
-
|
|
24572
|
-
const
|
|
24573
|
-
for (const [
|
|
24574
|
-
if (!
|
|
24268
|
+
finishPendingSpansForRun(event) {
|
|
24269
|
+
const endTime = eventTime(event.timestamp);
|
|
24270
|
+
for (const [key, state] of this.toolsByKey) {
|
|
24271
|
+
if (!stateMatchesRun(state, event.runId)) {
|
|
24575
24272
|
continue;
|
|
24576
24273
|
}
|
|
24577
|
-
|
|
24274
|
+
safeEnd(state.span, endTime);
|
|
24275
|
+
this.toolsByKey.delete(key);
|
|
24578
24276
|
}
|
|
24579
|
-
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
24584
|
-
|
|
24585
|
-
return queue2.shift();
|
|
24277
|
+
for (const [key, state] of this.turnsByKey) {
|
|
24278
|
+
if (!stateMatchesRun(state, event.runId)) {
|
|
24279
|
+
continue;
|
|
24280
|
+
}
|
|
24281
|
+
safeEnd(state.span, endTime);
|
|
24282
|
+
this.turnsByKey.delete(key);
|
|
24586
24283
|
}
|
|
24587
|
-
for (const [
|
|
24588
|
-
if (
|
|
24589
|
-
|
|
24284
|
+
for (const [key, state] of this.tasksById) {
|
|
24285
|
+
if (!stateMatchesRun(state, event.runId)) {
|
|
24286
|
+
continue;
|
|
24590
24287
|
}
|
|
24288
|
+
safeEnd(state.span, endTime);
|
|
24289
|
+
this.tasksById.delete(key);
|
|
24591
24290
|
}
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24291
|
+
for (const [key, state] of this.compactionsByKey) {
|
|
24292
|
+
if (!stateMatchesRun(state, event.runId)) {
|
|
24293
|
+
continue;
|
|
24294
|
+
}
|
|
24295
|
+
safeLog3(state.span, {
|
|
24296
|
+
metadata: state.metadata,
|
|
24297
|
+
output: { completed: true }
|
|
24298
|
+
});
|
|
24299
|
+
safeEnd(state.span, endTime);
|
|
24300
|
+
this.compactionsByKey.delete(key);
|
|
24301
|
+
}
|
|
24302
|
+
for (const [key, state] of this.operationsById) {
|
|
24303
|
+
if (!stateMatchesRun(state, event.runId)) {
|
|
24304
|
+
continue;
|
|
24305
|
+
}
|
|
24306
|
+
safeLog3(state.span, {
|
|
24307
|
+
metadata: state.metadata,
|
|
24308
|
+
...state.metadata["flue.operation"] === "compact" ? { output: { completed: true } } : {}
|
|
24309
|
+
});
|
|
24310
|
+
safeEnd(state.span, endTime);
|
|
24311
|
+
this.operationsById.delete(key);
|
|
24598
24312
|
}
|
|
24599
|
-
const queue2 = [];
|
|
24600
|
-
this.pendingOperationsByKey.set(key, queue2);
|
|
24601
|
-
return queue2;
|
|
24602
24313
|
}
|
|
24603
24314
|
}, _class22);
|
|
24604
24315
|
function isInstrumentedOperation(operation) {
|
|
24605
|
-
return operation === "prompt" || operation === "skill" || operation === "
|
|
24606
|
-
}
|
|
24607
|
-
function getSessionName(session) {
|
|
24608
|
-
return typeof _optionalChain([session, 'optionalAccess', _607 => _607.name]) === "string" ? session.name : void 0;
|
|
24316
|
+
return operation === "prompt" || operation === "skill" || operation === "compact";
|
|
24609
24317
|
}
|
|
24610
|
-
function
|
|
24611
|
-
return `${_nullishCoalesce(sessionName, () => ( "unknown"))}::${operation}`;
|
|
24612
|
-
}
|
|
24613
|
-
function operationScopePrefixes(event) {
|
|
24614
|
-
const scopes = /* @__PURE__ */ new Set();
|
|
24615
|
-
for (const scope of operationScopeNames(event)) {
|
|
24616
|
-
scopes.add(`${scope}::`);
|
|
24617
|
-
}
|
|
24618
|
-
return scopes;
|
|
24619
|
-
}
|
|
24620
|
-
function operationKeyMatchesScopes(key, scopes) {
|
|
24621
|
-
for (const scope of scopes) {
|
|
24622
|
-
if (key.startsWith(scope)) {
|
|
24623
|
-
return true;
|
|
24624
|
-
}
|
|
24625
|
-
}
|
|
24626
|
-
return false;
|
|
24627
|
-
}
|
|
24628
|
-
function operationScopeNames(event) {
|
|
24629
|
-
const scopes = /* @__PURE__ */ new Set();
|
|
24630
|
-
if (event.session) {
|
|
24631
|
-
scopes.add(event.session);
|
|
24632
|
-
}
|
|
24633
|
-
if (event.parentSession) {
|
|
24634
|
-
scopes.add(event.parentSession);
|
|
24635
|
-
}
|
|
24636
|
-
if (!scopes.size) {
|
|
24637
|
-
scopes.add("unknown");
|
|
24638
|
-
}
|
|
24639
|
-
return scopes;
|
|
24640
|
-
}
|
|
24641
|
-
function addScopedOperation(operationsByScope, event, state) {
|
|
24642
|
-
for (const scope of operationScopeNames(event)) {
|
|
24643
|
-
addOperationToScope(operationsByScope, scope, state);
|
|
24644
|
-
}
|
|
24645
|
-
}
|
|
24646
|
-
function addOperationToScope(operationsByScope, scope, state) {
|
|
24647
|
-
const operations = operationsByScope.get(scope);
|
|
24648
|
-
if (operations) {
|
|
24649
|
-
if (!operations.includes(state)) {
|
|
24650
|
-
operations.push(state);
|
|
24651
|
-
}
|
|
24652
|
-
} else {
|
|
24653
|
-
operationsByScope.set(scope, [state]);
|
|
24654
|
-
}
|
|
24655
|
-
}
|
|
24656
|
-
function removeScopedOperation(operationsByScope, state) {
|
|
24657
|
-
for (const [scope, operations] of operationsByScope) {
|
|
24658
|
-
const index = operations.indexOf(state);
|
|
24659
|
-
if (index === -1) {
|
|
24660
|
-
continue;
|
|
24661
|
-
}
|
|
24662
|
-
operations.splice(index, 1);
|
|
24663
|
-
if (operations.length === 0) {
|
|
24664
|
-
operationsByScope.delete(scope);
|
|
24665
|
-
}
|
|
24666
|
-
}
|
|
24667
|
-
}
|
|
24668
|
-
function removePendingOperation(pendingOperationsByKey, state) {
|
|
24669
|
-
for (const [key, queue2] of pendingOperationsByKey) {
|
|
24670
|
-
const index = queue2.indexOf(state);
|
|
24671
|
-
if (index === -1) {
|
|
24672
|
-
continue;
|
|
24673
|
-
}
|
|
24674
|
-
queue2.splice(index, 1);
|
|
24675
|
-
if (queue2.length === 0) {
|
|
24676
|
-
pendingOperationsByKey.delete(key);
|
|
24677
|
-
}
|
|
24678
|
-
return;
|
|
24679
|
-
}
|
|
24680
|
-
}
|
|
24681
|
-
function extractSessionMetadata(session) {
|
|
24682
|
-
const sessionName = getSessionName(session);
|
|
24683
|
-
return sessionName ? { "flue.session": sessionName } : {};
|
|
24684
|
-
}
|
|
24685
|
-
function extractEventMetadata(event) {
|
|
24318
|
+
function extractEventMetadata(event, ctx) {
|
|
24686
24319
|
return {
|
|
24687
24320
|
...event.runId ? { "flue.run_id": event.runId } : {},
|
|
24321
|
+
...event.instanceId ? { "flue.instance_id": event.instanceId } : {},
|
|
24322
|
+
...event.dispatchId ? { "flue.dispatch_id": event.dispatchId } : {},
|
|
24688
24323
|
...typeof event.eventIndex === "number" ? { "flue.event_index": event.eventIndex } : {},
|
|
24689
24324
|
...event.session ? { "flue.session": event.session } : {},
|
|
24690
24325
|
...event.parentSession ? { "flue.parent_session": event.parentSession } : {},
|
|
24691
24326
|
...event.harness ? { "flue.harness": event.harness } : {},
|
|
24692
24327
|
...event.taskId ? { "flue.task_id": event.taskId } : {},
|
|
24693
|
-
...event.operationId ? { "flue.operation_id": event.operationId } : {}
|
|
24328
|
+
...event.operationId ? { "flue.operation_id": event.operationId } : {},
|
|
24329
|
+
...event.turnId ? { "flue.turn_id": event.turnId } : {},
|
|
24330
|
+
...typeof _optionalChain([ctx, 'optionalAccess', _585 => _585.id]) === "string" ? { "flue.context_id": ctx.id } : {},
|
|
24331
|
+
...typeof _optionalChain([ctx, 'optionalAccess', _586 => _586.runId]) === "string" ? { "flue.context_run_id": ctx.runId } : {}
|
|
24694
24332
|
};
|
|
24695
24333
|
}
|
|
24696
|
-
function
|
|
24697
|
-
|
|
24698
|
-
|
|
24699
|
-
case "task":
|
|
24700
|
-
return args[0];
|
|
24701
|
-
case "skill":
|
|
24702
|
-
return {
|
|
24703
|
-
args: _optionalChain([getOptionObject, 'call', _608 => _608(args[1]), 'optionalAccess', _609 => _609.args]),
|
|
24704
|
-
name: args[0]
|
|
24705
|
-
};
|
|
24706
|
-
case "compact":
|
|
24707
|
-
return void 0;
|
|
24334
|
+
function extractPayloadMetadata(payload) {
|
|
24335
|
+
if (!isObjectLike(payload)) {
|
|
24336
|
+
return {};
|
|
24708
24337
|
}
|
|
24338
|
+
const metadata = Reflect.get(payload, "metadata");
|
|
24339
|
+
if (!isObjectLike(metadata)) {
|
|
24340
|
+
return {};
|
|
24341
|
+
}
|
|
24342
|
+
return Object.fromEntries(Object.entries(metadata));
|
|
24709
24343
|
}
|
|
24710
|
-
function
|
|
24711
|
-
|
|
24712
|
-
|
|
24713
|
-
|
|
24714
|
-
|
|
24715
|
-
..._optionalChain([options, 'optionalAccess', _611 => _611.role]) ? { "flue.role": options.role } : {},
|
|
24716
|
-
..._optionalChain([options, 'optionalAccess', _612 => _612.thinkingLevel]) ? { "flue.thinking_level": options.thinkingLevel } : {},
|
|
24717
|
-
...typeof _optionalChain([options, 'optionalAccess', _613 => _613.cwd]) === "string" ? { "flue.cwd": options.cwd } : {},
|
|
24718
|
-
...Array.isArray(_optionalChain([options, 'optionalAccess', _614 => _614.tools])) ? {
|
|
24719
|
-
"flue.tools_count": options.tools.length,
|
|
24720
|
-
tools: summarizeTools(options.tools)
|
|
24721
|
-
} : {},
|
|
24722
|
-
...Array.isArray(_optionalChain([options, 'optionalAccess', _615 => _615.images])) ? { "flue.images_count": options.images.length } : {},
|
|
24723
|
-
..._optionalChain([options, 'optionalAccess', _616 => _616.result]) || _optionalChain([options, 'optionalAccess', _617 => _617.schema]) ? { "flue.result_schema": true } : {}
|
|
24724
|
-
};
|
|
24725
|
-
}
|
|
24726
|
-
function getOptionObject(value) {
|
|
24727
|
-
return isObject(value) ? value : void 0;
|
|
24728
|
-
}
|
|
24729
|
-
function summarizeTools(tools) {
|
|
24730
|
-
return tools.flatMap((tool) => {
|
|
24731
|
-
if (!isObject(tool)) {
|
|
24732
|
-
return [];
|
|
24733
|
-
}
|
|
24734
|
-
const name = typeof tool.name === "string" ? tool.name : void 0;
|
|
24735
|
-
if (!name) {
|
|
24736
|
-
return [];
|
|
24737
|
-
}
|
|
24738
|
-
return [
|
|
24739
|
-
{
|
|
24740
|
-
function: {
|
|
24741
|
-
description: typeof tool.description === "string" ? tool.description : void 0,
|
|
24742
|
-
name,
|
|
24743
|
-
parameters: tool.parameters
|
|
24744
|
-
},
|
|
24745
|
-
type: "function"
|
|
24746
|
-
}
|
|
24747
|
-
];
|
|
24748
|
-
});
|
|
24344
|
+
function operationOutput(event) {
|
|
24345
|
+
if (event.operationKind === "prompt" || event.operationKind === "skill") {
|
|
24346
|
+
return llmResultFromOperationResult(event.result);
|
|
24347
|
+
}
|
|
24348
|
+
return _nullishCoalesce(event.result, () => ( (event.operationKind === "compact" ? { completed: true } : void 0)));
|
|
24749
24349
|
}
|
|
24750
|
-
function
|
|
24751
|
-
|
|
24752
|
-
|
|
24753
|
-
|
|
24754
|
-
|
|
24755
|
-
|
|
24350
|
+
function llmResultFromOperationResult(result) {
|
|
24351
|
+
if (!isObjectLike(result)) {
|
|
24352
|
+
return result;
|
|
24353
|
+
}
|
|
24354
|
+
const text = Reflect.get(result, "text");
|
|
24355
|
+
return text === void 0 ? result : text;
|
|
24756
24356
|
}
|
|
24757
|
-
function
|
|
24758
|
-
if (!result) {
|
|
24357
|
+
function usageFromOperationResult(result) {
|
|
24358
|
+
if (!isObjectLike(result)) {
|
|
24759
24359
|
return void 0;
|
|
24760
24360
|
}
|
|
24761
|
-
|
|
24762
|
-
return result.data;
|
|
24763
|
-
}
|
|
24764
|
-
if ("text" in result) {
|
|
24765
|
-
return result.text;
|
|
24766
|
-
}
|
|
24767
|
-
return result;
|
|
24361
|
+
return Reflect.get(result, "usage");
|
|
24768
24362
|
}
|
|
24769
24363
|
function metricsFromUsage(usage) {
|
|
24364
|
+
if (!isObjectLike(usage)) {
|
|
24365
|
+
return {};
|
|
24366
|
+
}
|
|
24367
|
+
const cacheRead = Reflect.get(usage, "cacheRead");
|
|
24368
|
+
const cacheWrite = Reflect.get(usage, "cacheWrite");
|
|
24369
|
+
const cost = Reflect.get(usage, "cost");
|
|
24370
|
+
const input = Reflect.get(usage, "input");
|
|
24371
|
+
const output = Reflect.get(usage, "output");
|
|
24372
|
+
const totalTokens = Reflect.get(usage, "totalTokens");
|
|
24373
|
+
const totalCost = isObjectLike(cost) ? Reflect.get(cost, "total") : void 0;
|
|
24770
24374
|
return {
|
|
24771
|
-
...typeof
|
|
24772
|
-
...typeof
|
|
24773
|
-
...typeof
|
|
24774
|
-
...typeof
|
|
24775
|
-
...typeof
|
|
24776
|
-
...typeof
|
|
24777
|
-
};
|
|
24778
|
-
}
|
|
24779
|
-
function buildDurationMetrics3(startTime) {
|
|
24780
|
-
return {
|
|
24781
|
-
duration_ms: Math.max(0, (getCurrentUnixTimestamp() - startTime) * 1e3)
|
|
24375
|
+
...typeof input === "number" ? { prompt_tokens: input } : {},
|
|
24376
|
+
...typeof output === "number" ? { completion_tokens: output } : {},
|
|
24377
|
+
...typeof cacheRead === "number" ? { prompt_cached_tokens: cacheRead } : {},
|
|
24378
|
+
...typeof cacheWrite === "number" ? { prompt_cache_creation_tokens: cacheWrite } : {},
|
|
24379
|
+
...typeof totalTokens === "number" ? { tokens: totalTokens } : {},
|
|
24380
|
+
...typeof totalCost === "number" ? { estimated_cost: totalCost } : {}
|
|
24782
24381
|
};
|
|
24783
24382
|
}
|
|
24784
|
-
function
|
|
24383
|
+
function durationMetrics2(durationMs) {
|
|
24785
24384
|
return typeof durationMs === "number" ? { duration_ms: durationMs } : {};
|
|
24786
24385
|
}
|
|
24787
|
-
function
|
|
24788
|
-
if (
|
|
24789
|
-
return
|
|
24790
|
-
}
|
|
24791
|
-
if (event.taskId) {
|
|
24792
|
-
return `task:${event.taskId}`;
|
|
24793
|
-
}
|
|
24794
|
-
if (event.session) {
|
|
24795
|
-
return `session:${event.session}`;
|
|
24386
|
+
function eventTime(value) {
|
|
24387
|
+
if (typeof value !== "string") {
|
|
24388
|
+
return void 0;
|
|
24796
24389
|
}
|
|
24797
|
-
|
|
24390
|
+
const timestamp = Date.parse(value);
|
|
24391
|
+
return Number.isFinite(timestamp) ? timestamp / 1e3 : void 0;
|
|
24392
|
+
}
|
|
24393
|
+
function turnKey(event) {
|
|
24394
|
+
return event.turnId;
|
|
24798
24395
|
}
|
|
24799
24396
|
function toolKey(event) {
|
|
24800
|
-
return `${
|
|
24397
|
+
return `${_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(event.turnId, () => ( event.operationId)), () => ( event.taskId)), () => ( event.runId)), () => ( "unknown"))}:${_nullishCoalesce(event.toolCallId, () => ( "unknown"))}`;
|
|
24801
24398
|
}
|
|
24802
|
-
function
|
|
24399
|
+
function compactionKey(event) {
|
|
24803
24400
|
return [
|
|
24804
|
-
|
|
24805
|
-
|
|
24806
|
-
|
|
24807
|
-
|
|
24808
|
-
|
|
24809
|
-
|
|
24810
|
-
|
|
24811
|
-
|
|
24812
|
-
|
|
24813
|
-
|
|
24814
|
-
|
|
24815
|
-
|
|
24816
|
-
},
|
|
24817
|
-
...toolCall.toolCallId ? { id: toolCall.toolCallId } : {},
|
|
24818
|
-
type: "function"
|
|
24819
|
-
}))
|
|
24820
|
-
} : {}
|
|
24821
|
-
}
|
|
24822
|
-
}
|
|
24823
|
-
];
|
|
24401
|
+
_nullishCoalesce(event.instanceId, () => ( "")),
|
|
24402
|
+
_nullishCoalesce(event.runId, () => ( "")),
|
|
24403
|
+
_nullishCoalesce(event.session, () => ( "")),
|
|
24404
|
+
_nullishCoalesce(event.operationId, () => ( "")),
|
|
24405
|
+
_nullishCoalesce(event.taskId, () => ( ""))
|
|
24406
|
+
].join(":");
|
|
24407
|
+
}
|
|
24408
|
+
function stateMatchesOperation(state, operationId) {
|
|
24409
|
+
return state.metadata["flue.operation_id"] === operationId;
|
|
24410
|
+
}
|
|
24411
|
+
function stateMatchesRun(state, runId) {
|
|
24412
|
+
return state.metadata["flue.run_id"] === runId;
|
|
24824
24413
|
}
|
|
24825
24414
|
function startFlueSpan(parent, args) {
|
|
24826
24415
|
return parent ? withCurrent(parent, () => startSpan(args)) : startSpan(args);
|
|
@@ -24832,6 +24421,13 @@ function safeLog3(span, event) {
|
|
|
24832
24421
|
logInstrumentationError3("Flue span log", error);
|
|
24833
24422
|
}
|
|
24834
24423
|
}
|
|
24424
|
+
function safeEnd(span, endTime) {
|
|
24425
|
+
try {
|
|
24426
|
+
span.end(endTime === void 0 ? void 0 : { endTime });
|
|
24427
|
+
} catch (error) {
|
|
24428
|
+
logInstrumentationError3("Flue span end", error);
|
|
24429
|
+
}
|
|
24430
|
+
}
|
|
24835
24431
|
function errorToString(error) {
|
|
24836
24432
|
if (error instanceof Error) {
|
|
24837
24433
|
return error.message;
|
|
@@ -24841,7 +24437,7 @@ function errorToString(error) {
|
|
|
24841
24437
|
}
|
|
24842
24438
|
try {
|
|
24843
24439
|
return JSON.stringify(error);
|
|
24844
|
-
} catch (
|
|
24440
|
+
} catch (e48) {
|
|
24845
24441
|
return String(error);
|
|
24846
24442
|
}
|
|
24847
24443
|
}
|
|
@@ -24862,11 +24458,11 @@ var BraintrustLangChainCallbackHandler = (_class23 = class {
|
|
|
24862
24458
|
__init83() {this.firstTokenTimes = /* @__PURE__ */ new Map()}
|
|
24863
24459
|
__init84() {this.ttftMs = /* @__PURE__ */ new Map()}
|
|
24864
24460
|
constructor(options) {;_class23.prototype.__init79.call(this);_class23.prototype.__init80.call(this);_class23.prototype.__init81.call(this);_class23.prototype.__init82.call(this);_class23.prototype.__init83.call(this);_class23.prototype.__init84.call(this);
|
|
24865
|
-
this.parent = _optionalChain([options, 'optionalAccess',
|
|
24461
|
+
this.parent = _optionalChain([options, 'optionalAccess', _587 => _587.parent]);
|
|
24866
24462
|
this.options = {
|
|
24867
|
-
debug: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24868
|
-
excludeMetadataProps: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24869
|
-
logger: _optionalChain([options, 'optionalAccess',
|
|
24463
|
+
debug: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _588 => _588.debug]), () => ( false)),
|
|
24464
|
+
excludeMetadataProps: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _589 => _589.excludeMetadataProps]), () => ( /^(l[sc]_|langgraph_|__pregel_|checkpoint_ns)/)),
|
|
24465
|
+
logger: _optionalChain([options, 'optionalAccess', _590 => _590.logger])
|
|
24870
24466
|
};
|
|
24871
24467
|
}
|
|
24872
24468
|
startSpan({
|
|
@@ -24880,7 +24476,7 @@ var BraintrustLangChainCallbackHandler = (_class23 = class {
|
|
|
24880
24476
|
if (!parentRunId) {
|
|
24881
24477
|
this.rootRunId = runId;
|
|
24882
24478
|
}
|
|
24883
|
-
const tags = _optionalChain([args, 'access',
|
|
24479
|
+
const tags = _optionalChain([args, 'access', _591 => _591.event, 'optionalAccess', _592 => _592.tags]);
|
|
24884
24480
|
const spanAttributes = args.spanAttributes || {};
|
|
24885
24481
|
spanAttributes.type = args.type || spanAttributes.type || "task";
|
|
24886
24482
|
args.type = spanAttributes.type;
|
|
@@ -24900,7 +24496,7 @@ var BraintrustLangChainCallbackHandler = (_class23 = class {
|
|
|
24900
24496
|
tags: void 0,
|
|
24901
24497
|
metadata: {
|
|
24902
24498
|
...tags ? { tags } : {},
|
|
24903
|
-
..._optionalChain([args, 'access',
|
|
24499
|
+
..._optionalChain([args, 'access', _593 => _593.event, 'optionalAccess', _594 => _594.metadata]),
|
|
24904
24500
|
braintrust: {
|
|
24905
24501
|
integration_name: "langchain-js",
|
|
24906
24502
|
sdk_language: "javascript"
|
|
@@ -25002,7 +24598,7 @@ var BraintrustLangChainCallbackHandler = (_class23 = class {
|
|
|
25002
24598
|
});
|
|
25003
24599
|
}
|
|
25004
24600
|
async handleChainStart(chain, inputs, runId, parentRunId, tags, metadata, runType, runName) {
|
|
25005
|
-
if (_optionalChain([tags, 'optionalAccess',
|
|
24601
|
+
if (_optionalChain([tags, 'optionalAccess', _595 => _595.includes, 'call', _596 => _596("langsmith:hidden")])) {
|
|
25006
24602
|
this.skippedRuns.add(runId);
|
|
25007
24603
|
return;
|
|
25008
24604
|
}
|
|
@@ -25112,7 +24708,7 @@ function getSerializedName(serialized) {
|
|
|
25112
24708
|
if (typeof serialized.name === "string") {
|
|
25113
24709
|
return serialized.name;
|
|
25114
24710
|
}
|
|
25115
|
-
const lastIdPart = _optionalChain([serialized, 'access',
|
|
24711
|
+
const lastIdPart = _optionalChain([serialized, 'access', _597 => _597.id, 'optionalAccess', _598 => _598.at, 'call', _599 => _599(-1)]);
|
|
25116
24712
|
return typeof lastIdPart === "string" ? lastIdPart : void 0;
|
|
25117
24713
|
}
|
|
25118
24714
|
function cleanObject(obj) {
|
|
@@ -25190,7 +24786,7 @@ function getMetricsFromResponse(response) {
|
|
|
25190
24786
|
function safeJsonParse(input) {
|
|
25191
24787
|
try {
|
|
25192
24788
|
return JSON.parse(input);
|
|
25193
|
-
} catch (
|
|
24789
|
+
} catch (e49) {
|
|
25194
24790
|
return input;
|
|
25195
24791
|
}
|
|
25196
24792
|
}
|
|
@@ -25199,11 +24795,11 @@ function isRecord(value) {
|
|
|
25199
24795
|
}
|
|
25200
24796
|
|
|
25201
24797
|
// src/instrumentation/plugins/langchain-plugin.ts
|
|
25202
|
-
var LangChainPlugin = (_class24 = class extends BasePlugin {constructor(...
|
|
24798
|
+
var LangChainPlugin = (_class24 = class extends BasePlugin {constructor(...args6) { super(...args6); _class24.prototype.__init85.call(this); }
|
|
25203
24799
|
__init85() {this.injectedManagers = /* @__PURE__ */ new WeakSet()}
|
|
25204
24800
|
onEnable() {
|
|
25205
|
-
this.subscribeToConfigure(
|
|
25206
|
-
this.subscribeToConfigure(
|
|
24801
|
+
this.subscribeToConfigure(_chunkVMBQETG3js.langChainChannels.configure);
|
|
24802
|
+
this.subscribeToConfigure(_chunkVMBQETG3js.langChainChannels.configureSync);
|
|
25207
24803
|
}
|
|
25208
24804
|
onDisable() {
|
|
25209
24805
|
for (const unsubscribe of this.unsubscribers) {
|
|
@@ -25237,7 +24833,7 @@ var LangChainPlugin = (_class24 = class extends BasePlugin {constructor(...args7
|
|
|
25237
24833
|
try {
|
|
25238
24834
|
result.addHandler(new BraintrustLangChainCallbackHandler(), true);
|
|
25239
24835
|
this.injectedManagers.add(result);
|
|
25240
|
-
} catch (
|
|
24836
|
+
} catch (e50) {
|
|
25241
24837
|
}
|
|
25242
24838
|
}
|
|
25243
24839
|
}, _class24);
|
|
@@ -25249,7 +24845,7 @@ function isCallbackManager(value) {
|
|
|
25249
24845
|
return typeof maybeManager.addHandler === "function";
|
|
25250
24846
|
}
|
|
25251
24847
|
function hasBraintrustHandler(manager) {
|
|
25252
|
-
return _nullishCoalesce(_optionalChain([manager, 'access',
|
|
24848
|
+
return _nullishCoalesce(_optionalChain([manager, 'access', _600 => _600.handlers, 'optionalAccess', _601 => _601.some, 'call', _602 => _602((handler) => {
|
|
25253
24849
|
if (typeof handler !== "object" || handler === null) {
|
|
25254
24850
|
return false;
|
|
25255
24851
|
}
|
|
@@ -25549,15 +25145,15 @@ var PluginRegistry = (_class26 = class {constructor() { _class26.prototype.__ini
|
|
|
25549
25145
|
* Get default configuration (all integrations enabled).
|
|
25550
25146
|
*/
|
|
25551
25147
|
getDefaultConfig() {
|
|
25552
|
-
return
|
|
25148
|
+
return _chunkVMBQETG3js.getDefaultInstrumentationIntegrations.call(void 0, );
|
|
25553
25149
|
}
|
|
25554
25150
|
/**
|
|
25555
25151
|
* Read configuration from environment variables.
|
|
25556
25152
|
* Supports: BRAINTRUST_DISABLE_INSTRUMENTATION=openai,anthropic,...
|
|
25557
25153
|
*/
|
|
25558
25154
|
readEnvConfig() {
|
|
25559
|
-
return
|
|
25560
|
-
|
|
25155
|
+
return _chunkVMBQETG3js.readDisabledInstrumentationEnvConfig.call(void 0,
|
|
25156
|
+
_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_DISABLE_INSTRUMENTATION")
|
|
25561
25157
|
);
|
|
25562
25158
|
}
|
|
25563
25159
|
}, _class26);
|
|
@@ -25764,16 +25360,16 @@ function wrapMastraAgent(agent, _options) {
|
|
|
25764
25360
|
// src/node/config.ts
|
|
25765
25361
|
var BRAINTRUST_ENV_SEARCH_PARENT_LIMIT = 64;
|
|
25766
25362
|
function configureNode() {
|
|
25767
|
-
|
|
25768
|
-
|
|
25769
|
-
|
|
25770
|
-
|
|
25363
|
+
_chunkVMBQETG3js.isomorph_default.buildType = "node";
|
|
25364
|
+
_chunkVMBQETG3js.isomorph_default.getRepoInfo = getRepoInfo;
|
|
25365
|
+
_chunkVMBQETG3js.isomorph_default.getPastNAncestors = getPastNAncestors;
|
|
25366
|
+
_chunkVMBQETG3js.isomorph_default.getEnv = (name) => {
|
|
25771
25367
|
const value = process.env[name];
|
|
25772
|
-
return name === "BRAINTRUST_API_KEY" && !_optionalChain([value, 'optionalAccess',
|
|
25368
|
+
return name === "BRAINTRUST_API_KEY" && !_optionalChain([value, 'optionalAccess', _603 => _603.trim, 'call', _604 => _604()]) ? void 0 : value;
|
|
25773
25369
|
};
|
|
25774
|
-
|
|
25370
|
+
_chunkVMBQETG3js.isomorph_default.getBraintrustApiKey = async () => {
|
|
25775
25371
|
const value = process.env.BRAINTRUST_API_KEY;
|
|
25776
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
25372
|
+
if (_optionalChain([value, 'optionalAccess', _605 => _605.trim, 'call', _606 => _606()])) {
|
|
25777
25373
|
return value;
|
|
25778
25374
|
}
|
|
25779
25375
|
const envPaths = [];
|
|
@@ -25804,7 +25400,7 @@ function configureNode() {
|
|
|
25804
25400
|
if ("contents" in nearestResult) {
|
|
25805
25401
|
const parsed = dotenv.parse(nearestResult.contents);
|
|
25806
25402
|
const apiKey = parsed.BRAINTRUST_API_KEY;
|
|
25807
|
-
return _optionalChain([apiKey, 'optionalAccess',
|
|
25403
|
+
return _optionalChain([apiKey, 'optionalAccess', _607 => _607.trim, 'call', _608 => _608()]) ? apiKey : void 0;
|
|
25808
25404
|
}
|
|
25809
25405
|
const e = nearestResult.error;
|
|
25810
25406
|
if (typeof e === "object" && e !== null && "code" in e && e.code === "ENOENT") {
|
|
@@ -25816,48 +25412,48 @@ function configureNode() {
|
|
|
25816
25412
|
}
|
|
25817
25413
|
return void 0;
|
|
25818
25414
|
};
|
|
25819
|
-
|
|
25820
|
-
|
|
25821
|
-
|
|
25822
|
-
|
|
25823
|
-
|
|
25415
|
+
_chunkVMBQETG3js.isomorph_default.getCallerLocation = getCallerLocation;
|
|
25416
|
+
_chunkVMBQETG3js.isomorph_default.newAsyncLocalStorage = () => new (0, _nodeasync_hooks.AsyncLocalStorage)();
|
|
25417
|
+
_chunkVMBQETG3js.isomorph_default.newTracingChannel = (nameOrChannels) => diagnostics_channel.tracingChannel(nameOrChannels);
|
|
25418
|
+
_chunkVMBQETG3js.patchTracingChannel.call(void 0, diagnostics_channel.tracingChannel);
|
|
25419
|
+
_chunkVMBQETG3js.isomorph_default.processOn = (event, handler) => {
|
|
25824
25420
|
process.on(event, handler);
|
|
25825
25421
|
};
|
|
25826
|
-
|
|
25827
|
-
|
|
25828
|
-
|
|
25829
|
-
|
|
25830
|
-
|
|
25831
|
-
|
|
25832
|
-
|
|
25833
|
-
|
|
25834
|
-
|
|
25835
|
-
|
|
25836
|
-
|
|
25837
|
-
|
|
25838
|
-
|
|
25839
|
-
|
|
25840
|
-
|
|
25841
|
-
|
|
25842
|
-
|
|
25843
|
-
|
|
25844
|
-
|
|
25845
|
-
|
|
25846
|
-
|
|
25847
|
-
|
|
25422
|
+
_chunkVMBQETG3js.isomorph_default.basename = path.basename;
|
|
25423
|
+
_chunkVMBQETG3js.isomorph_default.writeln = (text) => process.stdout.write(text + "\n");
|
|
25424
|
+
_chunkVMBQETG3js.isomorph_default.pathJoin = path.join;
|
|
25425
|
+
_chunkVMBQETG3js.isomorph_default.pathDirname = path.dirname;
|
|
25426
|
+
_chunkVMBQETG3js.isomorph_default.mkdir = fs.mkdir;
|
|
25427
|
+
_chunkVMBQETG3js.isomorph_default.writeFile = fs.writeFile;
|
|
25428
|
+
_chunkVMBQETG3js.isomorph_default.readFile = fs.readFile;
|
|
25429
|
+
_chunkVMBQETG3js.isomorph_default.readdir = fs.readdir;
|
|
25430
|
+
_chunkVMBQETG3js.isomorph_default.stat = fs.stat;
|
|
25431
|
+
_chunkVMBQETG3js.isomorph_default.statSync = fsSync.statSync;
|
|
25432
|
+
_chunkVMBQETG3js.isomorph_default.utimes = fs.utimes;
|
|
25433
|
+
_chunkVMBQETG3js.isomorph_default.unlink = fs.unlink;
|
|
25434
|
+
_chunkVMBQETG3js.isomorph_default.homedir = os.homedir;
|
|
25435
|
+
_chunkVMBQETG3js.isomorph_default.tmpdir = os.tmpdir;
|
|
25436
|
+
_chunkVMBQETG3js.isomorph_default.writeFileSync = fsSync.writeFileSync;
|
|
25437
|
+
_chunkVMBQETG3js.isomorph_default.appendFileSync = fsSync.appendFileSync;
|
|
25438
|
+
_chunkVMBQETG3js.isomorph_default.readFileSync = (filename, encoding) => fsSync.readFileSync(filename, encoding);
|
|
25439
|
+
_chunkVMBQETG3js.isomorph_default.unlinkSync = fsSync.unlinkSync;
|
|
25440
|
+
_chunkVMBQETG3js.isomorph_default.openFile = fs.open;
|
|
25441
|
+
_chunkVMBQETG3js.isomorph_default.gzip = _nodeutil.promisify.call(void 0, zlib.gzip);
|
|
25442
|
+
_chunkVMBQETG3js.isomorph_default.gunzip = _nodeutil.promisify.call(void 0, zlib.gunzip);
|
|
25443
|
+
_chunkVMBQETG3js.isomorph_default.hash = (data) => crypto.createHash("sha256").update(data).digest("hex");
|
|
25848
25444
|
_internalSetInitialState();
|
|
25849
|
-
const disabled =
|
|
25850
|
-
|
|
25445
|
+
const disabled = _chunkVMBQETG3js.readDisabledInstrumentationEnvConfig.call(void 0,
|
|
25446
|
+
_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_DISABLE_INSTRUMENTATION")
|
|
25851
25447
|
).integrations;
|
|
25852
|
-
if (!
|
|
25853
|
-
|
|
25448
|
+
if (!_chunkVMBQETG3js.isInstrumentationIntegrationDisabled.call(void 0, disabled, "mastra")) {
|
|
25449
|
+
_chunkVMBQETG3js.installMastraExporterFactory.call(void 0, () => new BraintrustObservabilityExporter());
|
|
25854
25450
|
}
|
|
25855
25451
|
registry.enable();
|
|
25856
25452
|
}
|
|
25857
25453
|
|
|
25858
25454
|
// src/exports.ts
|
|
25859
25455
|
var exports_exports = {};
|
|
25860
|
-
|
|
25456
|
+
_chunkVMBQETG3js.__export.call(void 0, exports_exports, {
|
|
25861
25457
|
Attachment: () => Attachment,
|
|
25862
25458
|
AttachmentReference: () => AttachmentReference,
|
|
25863
25459
|
BRAINTRUST_CURRENT_SPAN_STORE: () => BRAINTRUST_CURRENT_SPAN_STORE,
|
|
@@ -25888,6 +25484,7 @@ _chunkNKD77KGBjs.__export.call(void 0, exports_exports, {
|
|
|
25888
25484
|
LEGACY_CACHED_HEADER: () => LEGACY_CACHED_HEADER,
|
|
25889
25485
|
LOGS3_OVERFLOW_REFERENCE_TYPE: () => LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
25890
25486
|
LazyValue: () => LazyValue,
|
|
25487
|
+
LocalTrace: () => LocalTrace,
|
|
25891
25488
|
Logger: () => Logger,
|
|
25892
25489
|
LoginInvalidOrgError: () => LoginInvalidOrgError,
|
|
25893
25490
|
NOOP_SPAN: () => NOOP_SPAN,
|
|
@@ -25910,9 +25507,10 @@ _chunkNKD77KGBjs.__export.call(void 0, exports_exports, {
|
|
|
25910
25507
|
X_CACHED_HEADER: () => X_CACHED_HEADER,
|
|
25911
25508
|
_exportsForTestingOnly: () => _exportsForTestingOnly,
|
|
25912
25509
|
_internalGetGlobalState: () => _internalGetGlobalState,
|
|
25913
|
-
_internalIso: () =>
|
|
25510
|
+
_internalIso: () => _chunkVMBQETG3js.isomorph_default,
|
|
25914
25511
|
_internalSetInitialState: () => _internalSetInitialState,
|
|
25915
25512
|
addAzureBlobHeaders: () => addAzureBlobHeaders,
|
|
25513
|
+
braintrustFlueObserver: () => braintrustFlueObserver,
|
|
25916
25514
|
braintrustStreamChunkSchema: () => braintrustStreamChunkSchema,
|
|
25917
25515
|
buildLocalSummary: () => buildLocalSummary,
|
|
25918
25516
|
configureInstrumentation: () => configureInstrumentation,
|
|
@@ -25992,8 +25590,6 @@ _chunkNKD77KGBjs.__export.call(void 0, exports_exports, {
|
|
|
25992
25590
|
wrapCohere: () => wrapCohere,
|
|
25993
25591
|
wrapCopilotClient: () => wrapCopilotClient,
|
|
25994
25592
|
wrapCursorSDK: () => wrapCursorSDK,
|
|
25995
|
-
wrapFlueContext: () => wrapFlueContext,
|
|
25996
|
-
wrapFlueSession: () => wrapFlueSession,
|
|
25997
25593
|
wrapGenkit: () => wrapGenkit,
|
|
25998
25594
|
wrapGoogleADK: () => wrapGoogleADK,
|
|
25999
25595
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
@@ -26122,6 +25718,7 @@ async function invoke(args) {
|
|
|
26122
25718
|
mode,
|
|
26123
25719
|
schema,
|
|
26124
25720
|
strict,
|
|
25721
|
+
overrides,
|
|
26125
25722
|
projectId,
|
|
26126
25723
|
...functionIdArgs
|
|
26127
25724
|
} = args;
|
|
@@ -26158,7 +25755,8 @@ async function invoke(args) {
|
|
|
26158
25755
|
tags,
|
|
26159
25756
|
stream,
|
|
26160
25757
|
mode,
|
|
26161
|
-
strict
|
|
25758
|
+
strict,
|
|
25759
|
+
overrides
|
|
26162
25760
|
};
|
|
26163
25761
|
const headers = {
|
|
26164
25762
|
Accept: stream ? "text/event-stream" : "application/json"
|
|
@@ -26189,7 +25787,7 @@ function initFunction({
|
|
|
26189
25787
|
state
|
|
26190
25788
|
}) {
|
|
26191
25789
|
const s = _nullishCoalesce(state, () => ( _internalGetGlobalState()));
|
|
26192
|
-
_optionalChain([s, 'optionalAccess',
|
|
25790
|
+
_optionalChain([s, 'optionalAccess', _609 => _609.spanCache, 'optionalAccess', _610 => _610.disable, 'call', _611 => _611()]);
|
|
26193
25791
|
const f = async (input) => {
|
|
26194
25792
|
return await invoke({
|
|
26195
25793
|
projectName,
|
|
@@ -26266,22 +25864,22 @@ function responsesProxy(openai) {
|
|
|
26266
25864
|
if (name === "create" && typeof target.create === "function") {
|
|
26267
25865
|
return wrapResponsesAsync(
|
|
26268
25866
|
target.create.bind(target),
|
|
26269
|
-
|
|
25867
|
+
_chunkVMBQETG3js.openAIChannels.responsesCreate
|
|
26270
25868
|
);
|
|
26271
25869
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
26272
25870
|
return wrapResponsesSyncStream(
|
|
26273
25871
|
target.stream.bind(target),
|
|
26274
|
-
|
|
25872
|
+
_chunkVMBQETG3js.openAIChannels.responsesStream
|
|
26275
25873
|
);
|
|
26276
25874
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
26277
25875
|
return wrapResponsesAsync(
|
|
26278
25876
|
target.parse.bind(target),
|
|
26279
|
-
|
|
25877
|
+
_chunkVMBQETG3js.openAIChannels.responsesParse
|
|
26280
25878
|
);
|
|
26281
25879
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
26282
25880
|
return wrapResponsesAsync(
|
|
26283
25881
|
target.compact.bind(target),
|
|
26284
|
-
|
|
25882
|
+
_chunkVMBQETG3js.openAIChannels.responsesCompact
|
|
26285
25883
|
);
|
|
26286
25884
|
}
|
|
26287
25885
|
return Reflect.get(target, name, receiver);
|
|
@@ -26354,9 +25952,9 @@ function wrapOpenAIv4(openai) {
|
|
|
26354
25952
|
const embeddingProxy = createEndpointProxy(typedOpenai.embeddings, wrapEmbeddings);
|
|
26355
25953
|
const moderationProxy = createEndpointProxy(typedOpenai.moderations, wrapModerations);
|
|
26356
25954
|
let betaProxy3;
|
|
26357
|
-
if (_optionalChain([typedOpenai, 'access',
|
|
25955
|
+
if (_optionalChain([typedOpenai, 'access', _612 => _612.beta, 'optionalAccess', _613 => _613.chat, 'optionalAccess', _614 => _614.completions, 'optionalAccess', _615 => _615.stream])) {
|
|
26358
25956
|
const betaChatCompletionProxy = new Proxy(
|
|
26359
|
-
_optionalChain([typedOpenai, 'optionalAccess',
|
|
25957
|
+
_optionalChain([typedOpenai, 'optionalAccess', _616 => _616.beta, 'optionalAccess', _617 => _617.chat, 'access', _618 => _618.completions]),
|
|
26360
25958
|
{
|
|
26361
25959
|
get(target, name, receiver) {
|
|
26362
25960
|
const baseVal = Reflect.get(target, name, receiver);
|
|
@@ -26425,7 +26023,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
26425
26023
|
const { span_info, params } = splitSpanInfo(
|
|
26426
26024
|
allParams
|
|
26427
26025
|
);
|
|
26428
|
-
return
|
|
26026
|
+
return _chunkVMBQETG3js.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
26429
26027
|
async () => await completion(params),
|
|
26430
26028
|
{ arguments: [params], span_info }
|
|
26431
26029
|
);
|
|
@@ -26436,7 +26034,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
26436
26034
|
const { span_info, params } = splitSpanInfo(
|
|
26437
26035
|
allParams
|
|
26438
26036
|
);
|
|
26439
|
-
return
|
|
26037
|
+
return _chunkVMBQETG3js.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
26440
26038
|
() => completion(params),
|
|
26441
26039
|
{ arguments: [params], span_info }
|
|
26442
26040
|
);
|
|
@@ -26452,7 +26050,7 @@ function wrapChatCompletion(completion) {
|
|
|
26452
26050
|
if (!executionPromise) {
|
|
26453
26051
|
executionPromise = (async () => {
|
|
26454
26052
|
const traceContext = createChannelContext(
|
|
26455
|
-
|
|
26053
|
+
_chunkVMBQETG3js.openAIChannels.chatCompletionsCreate,
|
|
26456
26054
|
params,
|
|
26457
26055
|
span_info
|
|
26458
26056
|
);
|
|
@@ -26462,7 +26060,7 @@ function wrapChatCompletion(completion) {
|
|
|
26462
26060
|
options
|
|
26463
26061
|
);
|
|
26464
26062
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
26465
|
-
|
|
26063
|
+
_chunkVMBQETG3js.openAIChannels.chatCompletionsCreate,
|
|
26466
26064
|
traceContext,
|
|
26467
26065
|
completionPromise
|
|
26468
26066
|
);
|
|
@@ -26473,7 +26071,7 @@ function wrapChatCompletion(completion) {
|
|
|
26473
26071
|
options
|
|
26474
26072
|
);
|
|
26475
26073
|
const { data, response } = await tracePromiseWithResponse(
|
|
26476
|
-
|
|
26074
|
+
_chunkVMBQETG3js.openAIChannels.chatCompletionsCreate,
|
|
26477
26075
|
traceContext,
|
|
26478
26076
|
completionResponse
|
|
26479
26077
|
);
|
|
@@ -26516,15 +26114,15 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
26516
26114
|
return createLazyAPIPromise(ensureExecuted);
|
|
26517
26115
|
};
|
|
26518
26116
|
}
|
|
26519
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
26520
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
26117
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkVMBQETG3js.openAIChannels.embeddingsCreate);
|
|
26118
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkVMBQETG3js.openAIChannels.moderationsCreate);
|
|
26521
26119
|
|
|
26522
26120
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
26523
26121
|
function isModuleNamespace(obj) {
|
|
26524
26122
|
if (!obj || typeof obj !== "object") {
|
|
26525
26123
|
return false;
|
|
26526
26124
|
}
|
|
26527
|
-
if (_optionalChain([obj, 'access',
|
|
26125
|
+
if (_optionalChain([obj, 'access', _619 => _619.constructor, 'optionalAccess', _620 => _620.name]) === "Module") {
|
|
26528
26126
|
return true;
|
|
26529
26127
|
}
|
|
26530
26128
|
try {
|
|
@@ -26533,7 +26131,7 @@ function isModuleNamespace(obj) {
|
|
|
26533
26131
|
const firstKey = keys[0];
|
|
26534
26132
|
const descriptor = Object.getOwnPropertyDescriptor(obj, firstKey);
|
|
26535
26133
|
return descriptor ? !descriptor.configurable && !descriptor.writable : false;
|
|
26536
|
-
} catch (
|
|
26134
|
+
} catch (e51) {
|
|
26537
26135
|
return false;
|
|
26538
26136
|
}
|
|
26539
26137
|
}
|
|
@@ -26604,7 +26202,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
26604
26202
|
var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
26605
26203
|
const defaultName = `${instance.constructor.name}.generate`;
|
|
26606
26204
|
return async (params) => makeGenerateTextWrapper(
|
|
26607
|
-
|
|
26205
|
+
_chunkVMBQETG3js.aiSDKChannels.generateText,
|
|
26608
26206
|
defaultName,
|
|
26609
26207
|
generate.bind(instance),
|
|
26610
26208
|
{
|
|
@@ -26617,7 +26215,7 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
26617
26215
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
26618
26216
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
26619
26217
|
return (params) => makeStreamWrapper(
|
|
26620
|
-
|
|
26218
|
+
_chunkVMBQETG3js.aiSDKChannels.agentStream,
|
|
26621
26219
|
defaultName,
|
|
26622
26220
|
stream.bind(instance),
|
|
26623
26221
|
{
|
|
@@ -26649,7 +26247,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
26649
26247
|
};
|
|
26650
26248
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
26651
26249
|
return makeGenerateTextWrapper(
|
|
26652
|
-
|
|
26250
|
+
_chunkVMBQETG3js.aiSDKChannels.generateText,
|
|
26653
26251
|
"generateText",
|
|
26654
26252
|
generateText,
|
|
26655
26253
|
{ aiSDK },
|
|
@@ -26658,7 +26256,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
26658
26256
|
};
|
|
26659
26257
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
26660
26258
|
return makeGenerateTextWrapper(
|
|
26661
|
-
|
|
26259
|
+
_chunkVMBQETG3js.aiSDKChannels.generateObject,
|
|
26662
26260
|
"generateObject",
|
|
26663
26261
|
generateObject,
|
|
26664
26262
|
{ aiSDK },
|
|
@@ -26687,7 +26285,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
26687
26285
|
};
|
|
26688
26286
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
26689
26287
|
return makeEmbedWrapper(
|
|
26690
|
-
|
|
26288
|
+
_chunkVMBQETG3js.aiSDKChannels.embed,
|
|
26691
26289
|
"embed",
|
|
26692
26290
|
embed,
|
|
26693
26291
|
{ aiSDK },
|
|
@@ -26696,7 +26294,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
26696
26294
|
};
|
|
26697
26295
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
26698
26296
|
return makeEmbedWrapper(
|
|
26699
|
-
|
|
26297
|
+
_chunkVMBQETG3js.aiSDKChannels.embedMany,
|
|
26700
26298
|
"embedMany",
|
|
26701
26299
|
embedMany,
|
|
26702
26300
|
{ aiSDK },
|
|
@@ -26707,7 +26305,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
26707
26305
|
const wrapper = async function(allParams) {
|
|
26708
26306
|
const { span_info, ...params } = allParams;
|
|
26709
26307
|
const tracedParams = { ...params };
|
|
26710
|
-
return
|
|
26308
|
+
return _chunkVMBQETG3js.aiSDKChannels.rerank.tracePromise(
|
|
26711
26309
|
() => rerank(tracedParams),
|
|
26712
26310
|
createAISDKChannelContext(tracedParams, {
|
|
26713
26311
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -26746,7 +26344,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
26746
26344
|
};
|
|
26747
26345
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
26748
26346
|
return makeStreamWrapper(
|
|
26749
|
-
|
|
26347
|
+
_chunkVMBQETG3js.aiSDKChannels.streamText,
|
|
26750
26348
|
"streamText",
|
|
26751
26349
|
streamText,
|
|
26752
26350
|
{ aiSDK },
|
|
@@ -26755,7 +26353,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
26755
26353
|
};
|
|
26756
26354
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
26757
26355
|
return makeStreamWrapper(
|
|
26758
|
-
|
|
26356
|
+
_chunkVMBQETG3js.aiSDKChannels.streamObject,
|
|
26759
26357
|
"streamObject",
|
|
26760
26358
|
streamObject,
|
|
26761
26359
|
{ aiSDK },
|
|
@@ -26768,11 +26366,11 @@ function mergeSpanInfo(spanInfo, defaults) {
|
|
|
26768
26366
|
}
|
|
26769
26367
|
return {
|
|
26770
26368
|
...spanInfo,
|
|
26771
|
-
..._optionalChain([spanInfo, 'optionalAccess',
|
|
26772
|
-
...defaults.spanType !== void 0 || _optionalChain([spanInfo, 'optionalAccess',
|
|
26369
|
+
..._optionalChain([spanInfo, 'optionalAccess', _621 => _621.name]) ? {} : defaults.name ? { name: defaults.name } : {},
|
|
26370
|
+
...defaults.spanType !== void 0 || _optionalChain([spanInfo, 'optionalAccess', _622 => _622.spanAttributes]) ? {
|
|
26773
26371
|
spanAttributes: {
|
|
26774
26372
|
...defaults.spanType !== void 0 ? { type: defaults.spanType } : {},
|
|
26775
|
-
..._nullishCoalesce(_optionalChain([spanInfo, 'optionalAccess',
|
|
26373
|
+
..._nullishCoalesce(_optionalChain([spanInfo, 'optionalAccess', _623 => _623.spanAttributes]), () => ( {}))
|
|
26776
26374
|
}
|
|
26777
26375
|
} : {}
|
|
26778
26376
|
};
|
|
@@ -26790,7 +26388,7 @@ function createAISDKChannelContext(params, context = {}) {
|
|
|
26790
26388
|
// src/wrappers/ai-sdk/deprecated/wrapAISDKModel.ts
|
|
26791
26389
|
function wrapAISDKModel(model) {
|
|
26792
26390
|
const m = model;
|
|
26793
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
26391
|
+
if (_optionalChain([m, 'optionalAccess', _624 => _624.specificationVersion]) === "v1" && typeof _optionalChain([m, 'optionalAccess', _625 => _625.provider]) === "string" && typeof _optionalChain([m, 'optionalAccess', _626 => _626.modelId]) === "string") {
|
|
26794
26392
|
return new BraintrustLanguageModelWrapper(m);
|
|
26795
26393
|
} else {
|
|
26796
26394
|
console.warn("Unsupported AI SDK model. Not wrapping.");
|
|
@@ -26847,10 +26445,10 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
26847
26445
|
metrics: {
|
|
26848
26446
|
time_to_first_token: getCurrentUnixTimestamp() - startTime,
|
|
26849
26447
|
tokens: !isEmpty2(ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
26850
|
-
prompt_tokens: _optionalChain([ret, 'access',
|
|
26851
|
-
completion_tokens: _optionalChain([ret, 'access',
|
|
26448
|
+
prompt_tokens: _optionalChain([ret, 'access', _627 => _627.usage, 'optionalAccess', _628 => _628.promptTokens]),
|
|
26449
|
+
completion_tokens: _optionalChain([ret, 'access', _629 => _629.usage, 'optionalAccess', _630 => _630.completionTokens]),
|
|
26852
26450
|
cached: parseCachedHeader(
|
|
26853
|
-
_nullishCoalesce(_optionalChain([ret, 'access',
|
|
26451
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _631 => _631.rawResponse, 'optionalAccess', _632 => _632.headers, 'optionalAccess', _633 => _633[X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _634 => _634.rawResponse, 'optionalAccess', _635 => _635.headers, 'optionalAccess', _636 => _636[LEGACY_CACHED_HEADER]])))
|
|
26854
26452
|
)
|
|
26855
26453
|
}
|
|
26856
26454
|
});
|
|
@@ -26942,10 +26540,10 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
26942
26540
|
metrics: {
|
|
26943
26541
|
time_to_first_token,
|
|
26944
26542
|
tokens: !isEmpty2(usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
26945
|
-
prompt_tokens: _optionalChain([usage, 'optionalAccess',
|
|
26946
|
-
completion_tokens: _optionalChain([usage, 'optionalAccess',
|
|
26543
|
+
prompt_tokens: _optionalChain([usage, 'optionalAccess', _637 => _637.promptTokens]),
|
|
26544
|
+
completion_tokens: _optionalChain([usage, 'optionalAccess', _638 => _638.completionTokens]),
|
|
26947
26545
|
cached: parseCachedHeader(
|
|
26948
|
-
_nullishCoalesce(_optionalChain([ret, 'access',
|
|
26546
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _639 => _639.rawResponse, 'optionalAccess', _640 => _640.headers, 'optionalAccess', _641 => _641[X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _642 => _642.rawResponse, 'optionalAccess', _643 => _643.headers, 'optionalAccess', _644 => _644[LEGACY_CACHED_HEADER]])))
|
|
26949
26547
|
)
|
|
26950
26548
|
}
|
|
26951
26549
|
});
|
|
@@ -26989,7 +26587,7 @@ function postProcessPrompt(prompt) {
|
|
|
26989
26587
|
return [
|
|
26990
26588
|
{
|
|
26991
26589
|
role: "assistant",
|
|
26992
|
-
content: _optionalChain([textPart, 'optionalAccess',
|
|
26590
|
+
content: _optionalChain([textPart, 'optionalAccess', _645 => _645.text]),
|
|
26993
26591
|
...toolCallParts.length > 0 ? {
|
|
26994
26592
|
tool_calls: toolCallParts.map((part) => ({
|
|
26995
26593
|
id: part.toolCallId,
|
|
@@ -27062,23 +26660,23 @@ function postProcessOutput(text, toolCalls, finishReason) {
|
|
|
27062
26660
|
|
|
27063
26661
|
// src/wrappers/ai-sdk/deprecated/BraintrustMiddleware.ts
|
|
27064
26662
|
function detectProviderFromResult(result) {
|
|
27065
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
26663
|
+
if (!_optionalChain([result, 'optionalAccess', _646 => _646.providerMetadata])) {
|
|
27066
26664
|
return void 0;
|
|
27067
26665
|
}
|
|
27068
26666
|
const keys = Object.keys(result.providerMetadata);
|
|
27069
|
-
return _optionalChain([keys, 'optionalAccess',
|
|
26667
|
+
return _optionalChain([keys, 'optionalAccess', _647 => _647.at, 'call', _648 => _648(0)]);
|
|
27070
26668
|
}
|
|
27071
26669
|
function extractModelFromResult(result) {
|
|
27072
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
26670
|
+
if (_optionalChain([result, 'optionalAccess', _649 => _649.response, 'optionalAccess', _650 => _650.modelId])) {
|
|
27073
26671
|
return result.response.modelId;
|
|
27074
26672
|
}
|
|
27075
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
26673
|
+
if (_optionalChain([result, 'optionalAccess', _651 => _651.request, 'optionalAccess', _652 => _652.body, 'optionalAccess', _653 => _653.model])) {
|
|
27076
26674
|
return result.request.body.model;
|
|
27077
26675
|
}
|
|
27078
26676
|
return void 0;
|
|
27079
26677
|
}
|
|
27080
26678
|
function extractModelFromWrapGenerateCallback(model) {
|
|
27081
|
-
return _optionalChain([model, 'optionalAccess',
|
|
26679
|
+
return _optionalChain([model, 'optionalAccess', _654 => _654.modelId]);
|
|
27082
26680
|
}
|
|
27083
26681
|
function camelToSnake4(str) {
|
|
27084
26682
|
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
@@ -27123,7 +26721,7 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
27123
26721
|
metrics.prompt_cached_tokens = cachedInputTokens;
|
|
27124
26722
|
}
|
|
27125
26723
|
if (provider === "anthropic") {
|
|
27126
|
-
const anthropicMetadata = _optionalChain([providerMetadata, 'optionalAccess',
|
|
26724
|
+
const anthropicMetadata = _optionalChain([providerMetadata, 'optionalAccess', _655 => _655.anthropic]);
|
|
27127
26725
|
if (anthropicMetadata) {
|
|
27128
26726
|
const cacheReadTokens = getNumberProperty3(anthropicMetadata.usage, "cache_read_input_tokens") || 0;
|
|
27129
26727
|
const cacheCreationTokens = getNumberProperty3(
|
|
@@ -27149,7 +26747,7 @@ function buildAssistantOutputWithToolCalls(result, toolCalls) {
|
|
|
27149
26747
|
{
|
|
27150
26748
|
index: 0,
|
|
27151
26749
|
logprobs: null,
|
|
27152
|
-
finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess',
|
|
26750
|
+
finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess', _656 => _656.finishReason])), () => ( (toolCalls.length ? "tool_calls" : void 0))),
|
|
27153
26751
|
message: {
|
|
27154
26752
|
role: "assistant",
|
|
27155
26753
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
@@ -27162,7 +26760,7 @@ function extractToolCallsFromSteps(steps) {
|
|
|
27162
26760
|
if (!Array.isArray(steps)) return toolCalls;
|
|
27163
26761
|
let idx = 0;
|
|
27164
26762
|
for (const step of steps) {
|
|
27165
|
-
const blocks = _optionalChain([step, 'optionalAccess',
|
|
26763
|
+
const blocks = _optionalChain([step, 'optionalAccess', _657 => _657.content]);
|
|
27166
26764
|
if (!Array.isArray(blocks)) continue;
|
|
27167
26765
|
for (const block of blocks) {
|
|
27168
26766
|
if (block && typeof block === "object" && block.type === "tool-call") {
|
|
@@ -27185,7 +26783,7 @@ function extractToolCallsFromBlocks(blocks) {
|
|
|
27185
26783
|
return extractToolCallsFromSteps([{ content: blocks }]);
|
|
27186
26784
|
}
|
|
27187
26785
|
function extractInput(params) {
|
|
27188
|
-
return _nullishCoalesce(_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
26786
|
+
return _nullishCoalesce(_nullishCoalesce(_optionalChain([params, 'optionalAccess', _658 => _658.prompt]), () => ( _optionalChain([params, 'optionalAccess', _659 => _659.messages]))), () => ( _optionalChain([params, 'optionalAccess', _660 => _660.system])));
|
|
27189
26787
|
}
|
|
27190
26788
|
var V2_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
27191
26789
|
"prompt",
|
|
@@ -27209,16 +26807,16 @@ function BraintrustMiddleware(config = {}) {
|
|
|
27209
26807
|
const rawInput = extractInput(params);
|
|
27210
26808
|
const processedInput = processInputAttachments(rawInput);
|
|
27211
26809
|
const spanArgs = {
|
|
27212
|
-
name: _optionalChain([config, 'access',
|
|
26810
|
+
name: _optionalChain([config, 'access', _661 => _661.spanInfo, 'optionalAccess', _662 => _662.name]) || "ai-sdk.doGenerate",
|
|
27213
26811
|
spanAttributes: {
|
|
27214
26812
|
type: "llm" /* LLM */,
|
|
27215
|
-
..._optionalChain([config, 'access',
|
|
26813
|
+
..._optionalChain([config, 'access', _663 => _663.spanInfo, 'optionalAccess', _664 => _664.spanAttributes]) || {}
|
|
27216
26814
|
},
|
|
27217
26815
|
event: {
|
|
27218
26816
|
input: processedInput,
|
|
27219
26817
|
metadata: {
|
|
27220
26818
|
...extractModelParameters(params, V2_EXCLUDE_KEYS),
|
|
27221
|
-
..._optionalChain([config, 'access',
|
|
26819
|
+
..._optionalChain([config, 'access', _665 => _665.spanInfo, 'optionalAccess', _666 => _666.metadata]) || {}
|
|
27222
26820
|
}
|
|
27223
26821
|
}
|
|
27224
26822
|
};
|
|
@@ -27244,12 +26842,12 @@ function BraintrustMiddleware(config = {}) {
|
|
|
27244
26842
|
metadata.model = modelId;
|
|
27245
26843
|
}
|
|
27246
26844
|
}
|
|
27247
|
-
let toolCalls = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess',
|
|
26845
|
+
let toolCalls = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess', _667 => _667.steps]));
|
|
27248
26846
|
if (!toolCalls || toolCalls.length === 0) {
|
|
27249
|
-
toolCalls = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess',
|
|
26847
|
+
toolCalls = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess', _668 => _668.content]));
|
|
27250
26848
|
}
|
|
27251
26849
|
span.log({
|
|
27252
|
-
output: toolCalls.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls) : _optionalChain([result, 'optionalAccess',
|
|
26850
|
+
output: toolCalls.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls) : _optionalChain([result, 'optionalAccess', _669 => _669.content]),
|
|
27253
26851
|
metadata,
|
|
27254
26852
|
metrics: normalizeUsageMetrics(
|
|
27255
26853
|
result.usage,
|
|
@@ -27271,16 +26869,16 @@ function BraintrustMiddleware(config = {}) {
|
|
|
27271
26869
|
const rawInput = extractInput(params);
|
|
27272
26870
|
const processedInput = processInputAttachments(rawInput);
|
|
27273
26871
|
const spanArgs = {
|
|
27274
|
-
name: _optionalChain([config, 'access',
|
|
26872
|
+
name: _optionalChain([config, 'access', _670 => _670.spanInfo, 'optionalAccess', _671 => _671.name]) || "ai-sdk.doStream",
|
|
27275
26873
|
spanAttributes: {
|
|
27276
26874
|
type: "llm" /* LLM */,
|
|
27277
|
-
..._optionalChain([config, 'access',
|
|
26875
|
+
..._optionalChain([config, 'access', _672 => _672.spanInfo, 'optionalAccess', _673 => _673.spanAttributes]) || {}
|
|
27278
26876
|
},
|
|
27279
26877
|
event: {
|
|
27280
26878
|
input: processedInput,
|
|
27281
26879
|
metadata: {
|
|
27282
26880
|
...extractModelParameters(params, V2_EXCLUDE_KEYS),
|
|
27283
|
-
..._optionalChain([config, 'access',
|
|
26881
|
+
..._optionalChain([config, 'access', _674 => _674.spanInfo, 'optionalAccess', _675 => _675.metadata]) || {}
|
|
27284
26882
|
}
|
|
27285
26883
|
}
|
|
27286
26884
|
};
|
|
@@ -27423,7 +27021,7 @@ function messagesProxy(messages) {
|
|
|
27423
27021
|
return new Proxy(messages, {
|
|
27424
27022
|
get(target, prop, receiver) {
|
|
27425
27023
|
if (prop === "create") {
|
|
27426
|
-
return createProxy(target.create,
|
|
27024
|
+
return createProxy(target.create, _chunkVMBQETG3js.anthropicChannels.messagesCreate);
|
|
27427
27025
|
}
|
|
27428
27026
|
return Reflect.get(target, prop, receiver);
|
|
27429
27027
|
}
|
|
@@ -27433,7 +27031,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
27433
27031
|
return new Proxy(messages, {
|
|
27434
27032
|
get(target, prop, receiver) {
|
|
27435
27033
|
if (prop === "create") {
|
|
27436
|
-
return createProxy(target.create,
|
|
27034
|
+
return createProxy(target.create, _chunkVMBQETG3js.anthropicChannels.betaMessagesCreate);
|
|
27437
27035
|
}
|
|
27438
27036
|
if (prop === "toolRunner") {
|
|
27439
27037
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -27442,7 +27040,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
27442
27040
|
return toolRunnerProxy(
|
|
27443
27041
|
target.toolRunner,
|
|
27444
27042
|
anthropic,
|
|
27445
|
-
|
|
27043
|
+
_chunkVMBQETG3js.anthropicChannels.betaMessagesToolRunner
|
|
27446
27044
|
);
|
|
27447
27045
|
}
|
|
27448
27046
|
return Reflect.get(target, prop, receiver);
|
|
@@ -27503,7 +27101,7 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
27503
27101
|
}
|
|
27504
27102
|
};
|
|
27505
27103
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
27506
|
-
return
|
|
27104
|
+
return _chunkVMBQETG3js.claudeAgentSDKChannels.query.traceSync(
|
|
27507
27105
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
27508
27106
|
// The channel carries no extra context fields, but the generated
|
|
27509
27107
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -27549,8 +27147,8 @@ function wrapCreateSdkMcpServer(createSdkMcpServerFn, localToolMetadataByTool, d
|
|
|
27549
27147
|
apply(target, thisArg, argArray) {
|
|
27550
27148
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
27551
27149
|
const config = argArray[0];
|
|
27552
|
-
const serverName = _optionalChain([config, 'optionalAccess',
|
|
27553
|
-
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess',
|
|
27150
|
+
const serverName = _optionalChain([config, 'optionalAccess', _676 => _676.name]);
|
|
27151
|
+
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess', _677 => _677.tools]))) {
|
|
27554
27152
|
for (const tool of config.tools) {
|
|
27555
27153
|
if (!tool || typeof tool !== "object") {
|
|
27556
27154
|
continue;
|
|
@@ -27644,7 +27242,7 @@ function isModuleNamespace2(obj) {
|
|
|
27644
27242
|
if (!obj || typeof obj !== "object") {
|
|
27645
27243
|
return false;
|
|
27646
27244
|
}
|
|
27647
|
-
if (_optionalChain([obj, 'access',
|
|
27245
|
+
if (_optionalChain([obj, 'access', _678 => _678.constructor, 'optionalAccess', _679 => _679.name]) === "Module") {
|
|
27648
27246
|
return true;
|
|
27649
27247
|
}
|
|
27650
27248
|
const keys = Object.keys(obj);
|
|
@@ -27714,7 +27312,7 @@ function wrapCodexThread(thread) {
|
|
|
27714
27312
|
if (prop === "run" && typeof value === "function") {
|
|
27715
27313
|
return function(input, turnOptions) {
|
|
27716
27314
|
const args = [input, turnOptions];
|
|
27717
|
-
return
|
|
27315
|
+
return _chunkVMBQETG3js.openAICodexChannels.run.tracePromise(
|
|
27718
27316
|
() => Reflect.apply(value, target, args),
|
|
27719
27317
|
{
|
|
27720
27318
|
arguments: args,
|
|
@@ -27727,7 +27325,7 @@ function wrapCodexThread(thread) {
|
|
|
27727
27325
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
27728
27326
|
return function(input, turnOptions) {
|
|
27729
27327
|
const args = [input, turnOptions];
|
|
27730
|
-
return
|
|
27328
|
+
return _chunkVMBQETG3js.openAICodexChannels.runStreamed.tracePromise(
|
|
27731
27329
|
() => Reflect.apply(value, target, args),
|
|
27732
27330
|
{
|
|
27733
27331
|
arguments: args,
|
|
@@ -27774,7 +27372,7 @@ function isModuleNamespace3(obj) {
|
|
|
27774
27372
|
if (!obj || typeof obj !== "object") {
|
|
27775
27373
|
return false;
|
|
27776
27374
|
}
|
|
27777
|
-
if (_optionalChain([obj, 'access',
|
|
27375
|
+
if (_optionalChain([obj, 'access', _680 => _680.constructor, 'optionalAccess', _681 => _681.name]) === "Module") {
|
|
27778
27376
|
return true;
|
|
27779
27377
|
}
|
|
27780
27378
|
const keys = Object.keys(obj);
|
|
@@ -27795,7 +27393,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
27795
27393
|
if (prop === "create" && typeof value === "function") {
|
|
27796
27394
|
const wrapped = async function(options) {
|
|
27797
27395
|
const args = [options];
|
|
27798
|
-
return
|
|
27396
|
+
return _chunkVMBQETG3js.cursorSDKChannels.create.tracePromise(
|
|
27799
27397
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
27800
27398
|
{ arguments: args }
|
|
27801
27399
|
);
|
|
@@ -27806,7 +27404,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
27806
27404
|
if (prop === "resume" && typeof value === "function") {
|
|
27807
27405
|
const wrapped = async function(agentId, options) {
|
|
27808
27406
|
const args = [agentId, options];
|
|
27809
|
-
return
|
|
27407
|
+
return _chunkVMBQETG3js.cursorSDKChannels.resume.tracePromise(
|
|
27810
27408
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
27811
27409
|
{ arguments: args }
|
|
27812
27410
|
);
|
|
@@ -27817,7 +27415,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
27817
27415
|
if (prop === "prompt" && typeof value === "function") {
|
|
27818
27416
|
const wrapped = async function(message, options) {
|
|
27819
27417
|
const args = [message, options];
|
|
27820
|
-
return
|
|
27418
|
+
return _chunkVMBQETG3js.cursorSDKChannels.prompt.tracePromise(
|
|
27821
27419
|
() => Reflect.apply(value, target, args),
|
|
27822
27420
|
{ arguments: args }
|
|
27823
27421
|
);
|
|
@@ -27850,7 +27448,7 @@ function wrapCursorAgent(agent) {
|
|
|
27850
27448
|
if (prop === "send" && typeof value === "function") {
|
|
27851
27449
|
return function(message, options) {
|
|
27852
27450
|
const args = [message, options];
|
|
27853
|
-
return
|
|
27451
|
+
return _chunkVMBQETG3js.cursorSDKChannels.send.tracePromise(
|
|
27854
27452
|
() => Reflect.apply(value, target, args),
|
|
27855
27453
|
{
|
|
27856
27454
|
agent: target,
|
|
@@ -27939,7 +27537,7 @@ function wrapModels(models) {
|
|
|
27939
27537
|
}
|
|
27940
27538
|
function wrapGenerateContent(original) {
|
|
27941
27539
|
return function(params) {
|
|
27942
|
-
return
|
|
27540
|
+
return _chunkVMBQETG3js.googleGenAIChannels.generateContent.tracePromise(
|
|
27943
27541
|
() => original(params),
|
|
27944
27542
|
{ arguments: [params] }
|
|
27945
27543
|
);
|
|
@@ -27947,7 +27545,7 @@ function wrapGenerateContent(original) {
|
|
|
27947
27545
|
}
|
|
27948
27546
|
function wrapGenerateContentStream(original) {
|
|
27949
27547
|
return function(params) {
|
|
27950
|
-
return
|
|
27548
|
+
return _chunkVMBQETG3js.googleGenAIChannels.generateContentStream.tracePromise(
|
|
27951
27549
|
() => original(params),
|
|
27952
27550
|
{ arguments: [params] }
|
|
27953
27551
|
);
|
|
@@ -27955,7 +27553,7 @@ function wrapGenerateContentStream(original) {
|
|
|
27955
27553
|
}
|
|
27956
27554
|
function wrapEmbedContent(original) {
|
|
27957
27555
|
return function(params) {
|
|
27958
|
-
return
|
|
27556
|
+
return _chunkVMBQETG3js.googleGenAIChannels.embedContent.tracePromise(
|
|
27959
27557
|
() => original(params),
|
|
27960
27558
|
{ arguments: [params] }
|
|
27961
27559
|
);
|
|
@@ -28016,7 +27614,7 @@ function wrapRunnerInstance(runner) {
|
|
|
28016
27614
|
function wrapRunnerRunAsync(runner) {
|
|
28017
27615
|
const original = runner.runAsync.bind(runner);
|
|
28018
27616
|
return function(params) {
|
|
28019
|
-
return
|
|
27617
|
+
return _chunkVMBQETG3js.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
28020
27618
|
arguments: [params],
|
|
28021
27619
|
self: runner
|
|
28022
27620
|
});
|
|
@@ -28043,7 +27641,7 @@ function wrapAgentInstance(agent) {
|
|
|
28043
27641
|
function wrapAgentRunAsync(agent) {
|
|
28044
27642
|
const original = agent.runAsync.bind(agent);
|
|
28045
27643
|
return function(parentContext) {
|
|
28046
|
-
return
|
|
27644
|
+
return _chunkVMBQETG3js.googleADKChannels.agentRunAsync.traceSync(
|
|
28047
27645
|
() => original(parentContext),
|
|
28048
27646
|
{ arguments: [parentContext], self: agent }
|
|
28049
27647
|
);
|
|
@@ -28070,7 +27668,7 @@ function wrapToolInstance(tool) {
|
|
|
28070
27668
|
function wrapToolRunAsync(tool) {
|
|
28071
27669
|
const original = tool.runAsync.bind(tool);
|
|
28072
27670
|
return function(req) {
|
|
28073
|
-
return
|
|
27671
|
+
return _chunkVMBQETG3js.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
28074
27672
|
arguments: [req],
|
|
28075
27673
|
self: tool
|
|
28076
27674
|
});
|
|
@@ -28182,7 +27780,7 @@ function patchGenkitRegistryLookup(registry2) {
|
|
|
28182
27780
|
Object.defineProperty(registry2, PATCHED_GENKIT_REGISTRY, {
|
|
28183
27781
|
value: true
|
|
28184
27782
|
});
|
|
28185
|
-
} catch (
|
|
27783
|
+
} catch (e52) {
|
|
28186
27784
|
}
|
|
28187
27785
|
}
|
|
28188
27786
|
function patchGenkitRegistryConstructor(registry2) {
|
|
@@ -28213,31 +27811,31 @@ function patchGenkitRegistryConstructor(registry2) {
|
|
|
28213
27811
|
Object.defineProperty(constructor, PATCHED_GENKIT_REGISTRY_CONSTRUCTOR, {
|
|
28214
27812
|
value: true
|
|
28215
27813
|
});
|
|
28216
|
-
} catch (
|
|
27814
|
+
} catch (e53) {
|
|
28217
27815
|
}
|
|
28218
27816
|
}
|
|
28219
27817
|
function wrapGenerate(generate) {
|
|
28220
|
-
return (input) =>
|
|
27818
|
+
return (input) => _chunkVMBQETG3js.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
28221
27819
|
arguments: [input]
|
|
28222
27820
|
});
|
|
28223
27821
|
}
|
|
28224
27822
|
function wrapGenerateStream(generateStream) {
|
|
28225
|
-
return (input) =>
|
|
27823
|
+
return (input) => _chunkVMBQETG3js.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
28226
27824
|
arguments: [input]
|
|
28227
27825
|
});
|
|
28228
27826
|
}
|
|
28229
27827
|
function wrapEmbed2(embed) {
|
|
28230
|
-
return (params) =>
|
|
27828
|
+
return (params) => _chunkVMBQETG3js.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
28231
27829
|
arguments: [params]
|
|
28232
27830
|
});
|
|
28233
27831
|
}
|
|
28234
27832
|
function wrapEmbedMany2(embedMany) {
|
|
28235
|
-
return (params) =>
|
|
27833
|
+
return (params) => _chunkVMBQETG3js.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
28236
27834
|
arguments: [params]
|
|
28237
27835
|
});
|
|
28238
27836
|
}
|
|
28239
27837
|
function wrapRun(run) {
|
|
28240
|
-
return (name, inputOrFn, maybeFn) =>
|
|
27838
|
+
return (name, inputOrFn, maybeFn) => _chunkVMBQETG3js.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
28241
27839
|
arguments: [name, inputOrFn, maybeFn]
|
|
28242
27840
|
});
|
|
28243
27841
|
}
|
|
@@ -28276,13 +27874,13 @@ function isGenkitAction(value) {
|
|
|
28276
27874
|
return typeof value === "function" && "__action" in value;
|
|
28277
27875
|
}
|
|
28278
27876
|
function traceActionRun(action, run) {
|
|
28279
|
-
return (input, options) =>
|
|
27877
|
+
return (input, options) => _chunkVMBQETG3js.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
28280
27878
|
arguments: [input, options],
|
|
28281
27879
|
self: action
|
|
28282
27880
|
});
|
|
28283
27881
|
}
|
|
28284
27882
|
function traceActionStream(action, stream) {
|
|
28285
|
-
return (input, options) =>
|
|
27883
|
+
return (input, options) => _chunkVMBQETG3js.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
28286
27884
|
arguments: [input, options],
|
|
28287
27885
|
self: action
|
|
28288
27886
|
});
|
|
@@ -28439,14 +28037,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
28439
28037
|
const context = {
|
|
28440
28038
|
arguments: [traceParams]
|
|
28441
28039
|
};
|
|
28442
|
-
return
|
|
28040
|
+
return _chunkVMBQETG3js.huggingFaceChannels.chatCompletion.tracePromise(
|
|
28443
28041
|
() => original(params, options),
|
|
28444
28042
|
context
|
|
28445
28043
|
);
|
|
28446
28044
|
};
|
|
28447
28045
|
}
|
|
28448
28046
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
28449
|
-
return (params, options) =>
|
|
28047
|
+
return (params, options) => _chunkVMBQETG3js.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
28450
28048
|
() => original(params, options),
|
|
28451
28049
|
{
|
|
28452
28050
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -28459,14 +28057,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
28459
28057
|
const context = {
|
|
28460
28058
|
arguments: [traceParams]
|
|
28461
28059
|
};
|
|
28462
|
-
return
|
|
28060
|
+
return _chunkVMBQETG3js.huggingFaceChannels.textGeneration.tracePromise(
|
|
28463
28061
|
() => original(params, options),
|
|
28464
28062
|
context
|
|
28465
28063
|
);
|
|
28466
28064
|
};
|
|
28467
28065
|
}
|
|
28468
28066
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
28469
|
-
return (params, options) =>
|
|
28067
|
+
return (params, options) => _chunkVMBQETG3js.huggingFaceChannels.textGenerationStream.traceSync(
|
|
28470
28068
|
() => original(params, options),
|
|
28471
28069
|
{
|
|
28472
28070
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -28479,7 +28077,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
28479
28077
|
const context = {
|
|
28480
28078
|
arguments: [traceParams]
|
|
28481
28079
|
};
|
|
28482
|
-
return
|
|
28080
|
+
return _chunkVMBQETG3js.huggingFaceChannels.featureExtraction.tracePromise(
|
|
28483
28081
|
() => original(params, options),
|
|
28484
28082
|
context
|
|
28485
28083
|
);
|
|
@@ -28526,7 +28124,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
28526
28124
|
const request = cloneCallModelRequest(argArray[0]);
|
|
28527
28125
|
const options = argArray[1];
|
|
28528
28126
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
28529
|
-
return
|
|
28127
|
+
return _chunkVMBQETG3js.openRouterAgentChannels.callModel.traceSync(
|
|
28530
28128
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
28531
28129
|
{
|
|
28532
28130
|
arguments: [request]
|
|
@@ -28622,24 +28220,24 @@ function rerankProxy(rerank) {
|
|
|
28622
28220
|
});
|
|
28623
28221
|
}
|
|
28624
28222
|
function wrapChatSend(send) {
|
|
28625
|
-
return (request, options) =>
|
|
28223
|
+
return (request, options) => _chunkVMBQETG3js.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
28626
28224
|
arguments: [request]
|
|
28627
28225
|
});
|
|
28628
28226
|
}
|
|
28629
28227
|
function wrapEmbeddingsGenerate(generate) {
|
|
28630
|
-
return (request, options) =>
|
|
28228
|
+
return (request, options) => _chunkVMBQETG3js.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
28631
28229
|
() => generate(request, options),
|
|
28632
28230
|
{ arguments: [request] }
|
|
28633
28231
|
);
|
|
28634
28232
|
}
|
|
28635
28233
|
function wrapResponsesSend(send) {
|
|
28636
|
-
return (request, options) =>
|
|
28234
|
+
return (request, options) => _chunkVMBQETG3js.openRouterChannels.betaResponsesSend.tracePromise(
|
|
28637
28235
|
() => send(request, options),
|
|
28638
28236
|
{ arguments: [request] }
|
|
28639
28237
|
);
|
|
28640
28238
|
}
|
|
28641
28239
|
function wrapRerank2(rerank) {
|
|
28642
|
-
return (request, options) =>
|
|
28240
|
+
return (request, options) => _chunkVMBQETG3js.openRouterChannels.rerankRerank.tracePromise(
|
|
28643
28241
|
() => rerank(request, options),
|
|
28644
28242
|
{ arguments: [request] }
|
|
28645
28243
|
);
|
|
@@ -28647,7 +28245,7 @@ function wrapRerank2(rerank) {
|
|
|
28647
28245
|
function wrapCallModel2(callModel) {
|
|
28648
28246
|
return (request, options) => {
|
|
28649
28247
|
const tracedRequest = { ...request };
|
|
28650
|
-
return
|
|
28248
|
+
return _chunkVMBQETG3js.openRouterChannels.callModel.traceSync(
|
|
28651
28249
|
() => callModel(tracedRequest, options),
|
|
28652
28250
|
{
|
|
28653
28251
|
arguments: [tracedRequest]
|
|
@@ -28780,7 +28378,7 @@ function classifiersProxy(classifiers) {
|
|
|
28780
28378
|
});
|
|
28781
28379
|
}
|
|
28782
28380
|
function wrapChatComplete(complete) {
|
|
28783
|
-
return (request, options) =>
|
|
28381
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.chatComplete.tracePromise(
|
|
28784
28382
|
() => complete(request, options),
|
|
28785
28383
|
{
|
|
28786
28384
|
arguments: [request]
|
|
@@ -28788,52 +28386,52 @@ function wrapChatComplete(complete) {
|
|
|
28788
28386
|
);
|
|
28789
28387
|
}
|
|
28790
28388
|
function wrapChatStream(stream) {
|
|
28791
|
-
return (request, options) =>
|
|
28389
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
28792
28390
|
arguments: [request]
|
|
28793
28391
|
});
|
|
28794
28392
|
}
|
|
28795
28393
|
function wrapEmbeddingsCreate(create) {
|
|
28796
|
-
return (request, options) =>
|
|
28394
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.embeddingsCreate.tracePromise(
|
|
28797
28395
|
() => create(request, options),
|
|
28798
28396
|
{ arguments: [request] }
|
|
28799
28397
|
);
|
|
28800
28398
|
}
|
|
28801
28399
|
function wrapClassifiersModerate(moderate) {
|
|
28802
|
-
return (request, options) =>
|
|
28400
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.classifiersModerate.tracePromise(
|
|
28803
28401
|
() => moderate(request, options),
|
|
28804
28402
|
{ arguments: [request] }
|
|
28805
28403
|
);
|
|
28806
28404
|
}
|
|
28807
28405
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
28808
|
-
return (request, options) =>
|
|
28406
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.classifiersModerateChat.tracePromise(
|
|
28809
28407
|
() => moderateChat(request, options),
|
|
28810
28408
|
{ arguments: [request] }
|
|
28811
28409
|
);
|
|
28812
28410
|
}
|
|
28813
28411
|
function wrapClassifiersClassify(classify) {
|
|
28814
|
-
return (request, options) =>
|
|
28412
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.classifiersClassify.tracePromise(
|
|
28815
28413
|
() => classify(request, options),
|
|
28816
28414
|
{ arguments: [request] }
|
|
28817
28415
|
);
|
|
28818
28416
|
}
|
|
28819
28417
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
28820
|
-
return (request, options) =>
|
|
28418
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
28821
28419
|
() => classifyChat(request, options),
|
|
28822
28420
|
{ arguments: [request] }
|
|
28823
28421
|
);
|
|
28824
28422
|
}
|
|
28825
28423
|
function wrapFimComplete(complete) {
|
|
28826
|
-
return (request, options) =>
|
|
28424
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
28827
28425
|
arguments: [request]
|
|
28828
28426
|
});
|
|
28829
28427
|
}
|
|
28830
28428
|
function wrapFimStream(stream) {
|
|
28831
|
-
return (request, options) =>
|
|
28429
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
28832
28430
|
arguments: [request]
|
|
28833
28431
|
});
|
|
28834
28432
|
}
|
|
28835
28433
|
function wrapAgentsComplete(complete) {
|
|
28836
|
-
return (request, options) =>
|
|
28434
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.agentsComplete.tracePromise(
|
|
28837
28435
|
() => complete(request, options),
|
|
28838
28436
|
{
|
|
28839
28437
|
arguments: [request]
|
|
@@ -28841,7 +28439,7 @@ function wrapAgentsComplete(complete) {
|
|
|
28841
28439
|
);
|
|
28842
28440
|
}
|
|
28843
28441
|
function wrapAgentsStream(stream) {
|
|
28844
|
-
return (request, options) =>
|
|
28442
|
+
return (request, options) => _chunkVMBQETG3js.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
28845
28443
|
arguments: [request]
|
|
28846
28444
|
});
|
|
28847
28445
|
}
|
|
@@ -28894,22 +28492,22 @@ function cohereProxy(cohere) {
|
|
|
28894
28492
|
return proxy;
|
|
28895
28493
|
}
|
|
28896
28494
|
function wrapChat(chat) {
|
|
28897
|
-
return (request, options) =>
|
|
28495
|
+
return (request, options) => _chunkVMBQETG3js.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
28898
28496
|
arguments: [request]
|
|
28899
28497
|
});
|
|
28900
28498
|
}
|
|
28901
28499
|
function wrapChatStream2(chatStream) {
|
|
28902
|
-
return (request, options) =>
|
|
28500
|
+
return (request, options) => _chunkVMBQETG3js.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
28903
28501
|
arguments: [request]
|
|
28904
28502
|
});
|
|
28905
28503
|
}
|
|
28906
28504
|
function wrapEmbed3(embed) {
|
|
28907
|
-
return (request, options) =>
|
|
28505
|
+
return (request, options) => _chunkVMBQETG3js.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
28908
28506
|
arguments: [request]
|
|
28909
28507
|
});
|
|
28910
28508
|
}
|
|
28911
28509
|
function wrapRerank3(rerank) {
|
|
28912
|
-
return (request, options) =>
|
|
28510
|
+
return (request, options) => _chunkVMBQETG3js.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
28913
28511
|
arguments: [request]
|
|
28914
28512
|
});
|
|
28915
28513
|
}
|
|
@@ -28939,7 +28537,7 @@ function isSupportedGroqClient(value) {
|
|
|
28939
28537
|
}
|
|
28940
28538
|
function groqProxy(groq) {
|
|
28941
28539
|
const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
|
|
28942
|
-
const completionProxy = _optionalChain([groq, 'access',
|
|
28540
|
+
const completionProxy = _optionalChain([groq, 'access', _682 => _682.chat, 'optionalAccess', _683 => _683.completions]) ? new Proxy(groq.chat.completions, {
|
|
28943
28541
|
get(target, prop, receiver) {
|
|
28944
28542
|
if (prop === "create") {
|
|
28945
28543
|
return wrapChatCompletionsCreate(target.create.bind(target));
|
|
@@ -28991,13 +28589,13 @@ function groqProxy(groq) {
|
|
|
28991
28589
|
return topLevelProxy;
|
|
28992
28590
|
}
|
|
28993
28591
|
function wrapChatCompletionsCreate(create) {
|
|
28994
|
-
return (request, options) =>
|
|
28592
|
+
return (request, options) => _chunkVMBQETG3js.groqChannels.chatCompletionsCreate.tracePromise(
|
|
28995
28593
|
() => create(request, options),
|
|
28996
28594
|
{ arguments: [request] }
|
|
28997
28595
|
);
|
|
28998
28596
|
}
|
|
28999
28597
|
function wrapEmbeddingsCreate2(create) {
|
|
29000
|
-
return (request, options) =>
|
|
28598
|
+
return (request, options) => _chunkVMBQETG3js.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
29001
28599
|
arguments: [request]
|
|
29002
28600
|
});
|
|
29003
28601
|
}
|
|
@@ -29045,13 +28643,13 @@ function copilotClientProxy(client) {
|
|
|
29045
28643
|
return proxy;
|
|
29046
28644
|
}
|
|
29047
28645
|
function wrappedCreateSession(client) {
|
|
29048
|
-
return (config) =>
|
|
28646
|
+
return (config) => _chunkVMBQETG3js.gitHubCopilotChannels.createSession.tracePromise(
|
|
29049
28647
|
() => client.createSession(config),
|
|
29050
28648
|
{ arguments: [config] }
|
|
29051
28649
|
);
|
|
29052
28650
|
}
|
|
29053
28651
|
function wrappedResumeSession(client) {
|
|
29054
|
-
return (sessionId, config) =>
|
|
28652
|
+
return (sessionId, config) => _chunkVMBQETG3js.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
29055
28653
|
() => client.resumeSession(sessionId, config),
|
|
29056
28654
|
{ arguments: [sessionId, config] }
|
|
29057
28655
|
);
|
|
@@ -29065,7 +28663,7 @@ var VitestContextManager = class {
|
|
|
29065
28663
|
*/
|
|
29066
28664
|
|
|
29067
28665
|
constructor() {
|
|
29068
|
-
this.contextStorage =
|
|
28666
|
+
this.contextStorage = _chunkVMBQETG3js.isomorph_default.newAsyncLocalStorage();
|
|
29069
28667
|
}
|
|
29070
28668
|
getCurrentContext() {
|
|
29071
28669
|
return this.contextStorage.getStore();
|
|
@@ -29278,7 +28876,7 @@ function wrapTest(originalTest, config) {
|
|
|
29278
28876
|
const wrapped = function(name, configOrFn, maybeFn) {
|
|
29279
28877
|
const isEnhanced = typeof configOrFn !== "function";
|
|
29280
28878
|
const testConfig = isEnhanced ? configOrFn : void 0;
|
|
29281
|
-
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess',
|
|
28879
|
+
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _684 => _684.data]) && Array.isArray(testConfig.data)) {
|
|
29282
28880
|
const dataRecords = testConfig.data;
|
|
29283
28881
|
const testFn2 = maybeFn;
|
|
29284
28882
|
if (!testFn2) {
|
|
@@ -29316,7 +28914,7 @@ function wrapTest(originalTest, config) {
|
|
|
29316
28914
|
const registrationContext = getExperimentContext();
|
|
29317
28915
|
const testImplementation = async (vitestContext) => {
|
|
29318
28916
|
const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
|
|
29319
|
-
const experiment = _optionalChain([experimentContext, 'optionalAccess',
|
|
28917
|
+
const experiment = _optionalChain([experimentContext, 'optionalAccess', _685 => _685.experiment]);
|
|
29320
28918
|
if (config.onProgress) {
|
|
29321
28919
|
config.onProgress({ type: "test_start", testName: name });
|
|
29322
28920
|
}
|
|
@@ -29348,11 +28946,11 @@ function wrapTest(originalTest, config) {
|
|
|
29348
28946
|
const result = await runTracedEval({
|
|
29349
28947
|
experiment,
|
|
29350
28948
|
spanName: name,
|
|
29351
|
-
input: _optionalChain([testConfig, 'optionalAccess',
|
|
29352
|
-
expected: _optionalChain([testConfig, 'optionalAccess',
|
|
29353
|
-
metadata: _optionalChain([testConfig, 'optionalAccess',
|
|
29354
|
-
tags: _optionalChain([testConfig, 'optionalAccess',
|
|
29355
|
-
scorers: _optionalChain([testConfig, 'optionalAccess',
|
|
28949
|
+
input: _optionalChain([testConfig, 'optionalAccess', _686 => _686.input]),
|
|
28950
|
+
expected: _optionalChain([testConfig, 'optionalAccess', _687 => _687.expected]),
|
|
28951
|
+
metadata: _optionalChain([testConfig, 'optionalAccess', _688 => _688.metadata]),
|
|
28952
|
+
tags: _optionalChain([testConfig, 'optionalAccess', _689 => _689.tags]),
|
|
28953
|
+
scorers: _optionalChain([testConfig, 'optionalAccess', _690 => _690.scorers]),
|
|
29356
28954
|
fn: async () => {
|
|
29357
28955
|
if (testConfig && maybeFn) {
|
|
29358
28956
|
const params = {
|
|
@@ -29467,8 +29065,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
29467
29065
|
config.onProgress({
|
|
29468
29066
|
type: "suite_complete",
|
|
29469
29067
|
suiteName,
|
|
29470
|
-
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
29471
|
-
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
29068
|
+
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _691 => _691.passed]), () => ( 0)),
|
|
29069
|
+
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _692 => _692.failed]), () => ( 0))
|
|
29472
29070
|
});
|
|
29473
29071
|
}
|
|
29474
29072
|
});
|
|
@@ -29600,7 +29198,7 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
29600
29198
|
return;
|
|
29601
29199
|
}
|
|
29602
29200
|
await summarizeAndFlush(ctx.experiment, {
|
|
29603
|
-
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29201
|
+
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _693 => _693.displaySummary]), () => ( config.displaySummary))
|
|
29604
29202
|
});
|
|
29605
29203
|
}
|
|
29606
29204
|
};
|
|
@@ -29680,7 +29278,7 @@ function initNodeTestSuite(config) {
|
|
|
29680
29278
|
|
|
29681
29279
|
// src/graph-framework.ts
|
|
29682
29280
|
var graph_framework_exports = {};
|
|
29683
|
-
|
|
29281
|
+
_chunkVMBQETG3js.__export.call(void 0, graph_framework_exports, {
|
|
29684
29282
|
AggregatorNode: () => AggregatorNode,
|
|
29685
29283
|
GateNode: () => GateNode,
|
|
29686
29284
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -31124,7 +30722,7 @@ var CachedSpanFetcher = (_class31 = class {
|
|
|
31124
30722
|
async fetchSpans(spanType) {
|
|
31125
30723
|
const spans = await this.fetchFn(spanType, false);
|
|
31126
30724
|
for (const span of spans) {
|
|
31127
|
-
const type = _nullishCoalesce(_optionalChain([span, 'access',
|
|
30725
|
+
const type = _nullishCoalesce(_optionalChain([span, 'access', _694 => _694.span_attributes, 'optionalAccess', _695 => _695.type]), () => ( ""));
|
|
31128
30726
|
const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
|
|
31129
30727
|
existing.push(span);
|
|
31130
30728
|
this.spanCache.set(type, existing);
|
|
@@ -31207,11 +30805,11 @@ var LocalTrace = (_class32 = class {
|
|
|
31207
30805
|
const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
|
|
31208
30806
|
if (cachedSpans && cachedSpans.length > 0) {
|
|
31209
30807
|
let spans = includeScorers ? cachedSpans : cachedSpans.filter(
|
|
31210
|
-
(span) => _optionalChain([span, 'access',
|
|
30808
|
+
(span) => _optionalChain([span, 'access', _696 => _696.span_attributes, 'optionalAccess', _697 => _697.purpose]) !== "scorer"
|
|
31211
30809
|
);
|
|
31212
30810
|
if (spanType && spanType.length > 0) {
|
|
31213
30811
|
spans = spans.filter(
|
|
31214
|
-
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access',
|
|
30812
|
+
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _698 => _698.span_attributes, 'optionalAccess', _699 => _699.type]), () => ( "")))
|
|
31215
30813
|
);
|
|
31216
30814
|
}
|
|
31217
30815
|
return spans.map((span) => ({
|
|
@@ -31236,7 +30834,7 @@ var LocalTrace = (_class32 = class {
|
|
|
31236
30834
|
* Calls the API with the project_default preprocessor (which falls back to "thread").
|
|
31237
30835
|
*/
|
|
31238
30836
|
async getThread(options) {
|
|
31239
|
-
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30837
|
+
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _700 => _700.preprocessor]), () => ( "project_default"));
|
|
31240
30838
|
if (!this.threadCache.has(cacheKey)) {
|
|
31241
30839
|
const promise = this.fetchThread(options);
|
|
31242
30840
|
this.threadCache.set(cacheKey, promise);
|
|
@@ -31247,7 +30845,7 @@ var LocalTrace = (_class32 = class {
|
|
|
31247
30845
|
await this.ensureSpansReady();
|
|
31248
30846
|
await this.state.login({});
|
|
31249
30847
|
const result = await invoke({
|
|
31250
|
-
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30848
|
+
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _701 => _701.preprocessor]), () => ( "project_default")),
|
|
31251
30849
|
functionType: "preprocessor",
|
|
31252
30850
|
input: {
|
|
31253
30851
|
trace_ref: {
|
|
@@ -31423,10 +31021,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
|
|
|
31423
31021
|
const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
|
|
31424
31022
|
const validate = ajv.compile(schema);
|
|
31425
31023
|
if (!validate(parameters)) {
|
|
31426
|
-
const errorMessages = _optionalChain([validate, 'access',
|
|
31024
|
+
const errorMessages = _optionalChain([validate, 'access', _702 => _702.errors, 'optionalAccess', _703 => _703.map, 'call', _704 => _704((err) => {
|
|
31427
31025
|
const path2 = err.instancePath || "root";
|
|
31428
31026
|
return `${path2}: ${err.message}`;
|
|
31429
|
-
}), 'access',
|
|
31027
|
+
}), 'access', _705 => _705.join, 'call', _706 => _706(", ")]);
|
|
31430
31028
|
throw Error(`Invalid parameters: ${errorMessages}`);
|
|
31431
31029
|
}
|
|
31432
31030
|
return rehydrateRemoteParameters(parameters, schema);
|
|
@@ -31788,7 +31386,7 @@ var defaultErrorScoreHandler = ({
|
|
|
31788
31386
|
};
|
|
31789
31387
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
31790
31388
|
if (enableCache) {
|
|
31791
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _internalGetGlobalState()))), 'optionalAccess',
|
|
31389
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _internalGetGlobalState()))), 'optionalAccess', _707 => _707.spanCache, 'optionalAccess', _708 => _708.start, 'call', _709 => _709()]);
|
|
31792
31390
|
}
|
|
31793
31391
|
try {
|
|
31794
31392
|
if (typeof evaluator.data === "string") {
|
|
@@ -31843,7 +31441,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
31843
31441
|
const experimentIdPromise = experiment ? (async () => {
|
|
31844
31442
|
try {
|
|
31845
31443
|
return await experiment.id;
|
|
31846
|
-
} catch (
|
|
31444
|
+
} catch (e54) {
|
|
31847
31445
|
return void 0;
|
|
31848
31446
|
}
|
|
31849
31447
|
})() : void 0;
|
|
@@ -31899,7 +31497,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
31899
31497
|
objectType: parentComponents ? spanObjectTypeV3ToTypedString(
|
|
31900
31498
|
parentComponents.data.object_type
|
|
31901
31499
|
) : "experiment",
|
|
31902
|
-
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async
|
|
31500
|
+
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _710 => _710.data, 'access', async _711 => _711.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
31903
31501
|
rootSpanId: rootSpan.rootSpanId,
|
|
31904
31502
|
ensureSpansFlushed,
|
|
31905
31503
|
state
|
|
@@ -31929,10 +31527,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
31929
31527
|
span,
|
|
31930
31528
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
31931
31529
|
reportProgress: (event) => {
|
|
31932
|
-
_optionalChain([stream, 'optionalCall',
|
|
31530
|
+
_optionalChain([stream, 'optionalCall', _712 => _712({
|
|
31933
31531
|
...event,
|
|
31934
31532
|
id: rootSpan.id,
|
|
31935
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
31533
|
+
origin: _optionalChain([baseEvent, 'access', _713 => _713.event, 'optionalAccess', _714 => _714.origin]),
|
|
31936
31534
|
name: evaluator.evalName,
|
|
31937
31535
|
object_type: "task"
|
|
31938
31536
|
})]);
|
|
@@ -32120,7 +31718,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
32120
31718
|
tags: tags.length ? tags : void 0,
|
|
32121
31719
|
metadata,
|
|
32122
31720
|
error,
|
|
32123
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
31721
|
+
origin: _optionalChain([baseEvent, 'access', _715 => _715.event, 'optionalAccess', _716 => _716.origin])
|
|
32124
31722
|
};
|
|
32125
31723
|
collectedResults.push({
|
|
32126
31724
|
...baseResult,
|
|
@@ -32160,7 +31758,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
32160
31758
|
break;
|
|
32161
31759
|
}
|
|
32162
31760
|
scheduledTrials++;
|
|
32163
|
-
_optionalChain([progressReporter, 'access',
|
|
31761
|
+
_optionalChain([progressReporter, 'access', _717 => _717.setTotal, 'optionalCall', _718 => _718(evaluator.evalName, scheduledTrials)]);
|
|
32164
31762
|
q.pushAsync({ datum, trialIndex }).catch((e) => {
|
|
32165
31763
|
if (queueErrors.length < 5) {
|
|
32166
31764
|
queueErrors.push(e);
|
|
@@ -32222,7 +31820,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
32222
31820
|
} catch (e) {
|
|
32223
31821
|
q.kill();
|
|
32224
31822
|
if (e instanceof InternalAbortError) {
|
|
32225
|
-
if (
|
|
31823
|
+
if (_chunkVMBQETG3js.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
32226
31824
|
debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
32227
31825
|
}
|
|
32228
31826
|
}
|
|
@@ -32245,9 +31843,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
32245
31843
|
);
|
|
32246
31844
|
} finally {
|
|
32247
31845
|
if (enableCache) {
|
|
32248
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _internalGetGlobalState()))), 'optionalAccess',
|
|
32249
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
32250
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
31846
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _internalGetGlobalState()))), 'optionalAccess', _719 => _719.spanCache]);
|
|
31847
|
+
_optionalChain([spanCache, 'optionalAccess', _720 => _720.dispose, 'call', _721 => _721()]);
|
|
31848
|
+
_optionalChain([spanCache, 'optionalAccess', _722 => _722.stop, 'call', _723 => _723()]);
|
|
32251
31849
|
}
|
|
32252
31850
|
}
|
|
32253
31851
|
}
|
|
@@ -32340,25 +31938,25 @@ var defaultReporter = {
|
|
|
32340
31938
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
32341
31939
|
}
|
|
32342
31940
|
if (jsonl) {
|
|
32343
|
-
|
|
31941
|
+
_chunkVMBQETG3js.isomorph_default.writeln(JSON.stringify(summary));
|
|
32344
31942
|
} else {
|
|
32345
|
-
|
|
32346
|
-
|
|
31943
|
+
_chunkVMBQETG3js.isomorph_default.writeln("Experiment summary");
|
|
31944
|
+
_chunkVMBQETG3js.isomorph_default.writeln("==================");
|
|
32347
31945
|
if (summary.comparisonExperimentName) {
|
|
32348
|
-
|
|
31946
|
+
_chunkVMBQETG3js.isomorph_default.writeln(
|
|
32349
31947
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
32350
31948
|
);
|
|
32351
|
-
|
|
31949
|
+
_chunkVMBQETG3js.isomorph_default.writeln("");
|
|
32352
31950
|
}
|
|
32353
31951
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
32354
31952
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
32355
31953
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
32356
31954
|
if (hasScores || hasMetrics) {
|
|
32357
31955
|
if (hasComparison) {
|
|
32358
|
-
|
|
31956
|
+
_chunkVMBQETG3js.isomorph_default.writeln(
|
|
32359
31957
|
"Name Value Change Improvements Regressions"
|
|
32360
31958
|
);
|
|
32361
|
-
|
|
31959
|
+
_chunkVMBQETG3js.isomorph_default.writeln(
|
|
32362
31960
|
"----------------------------------------------------------------"
|
|
32363
31961
|
);
|
|
32364
31962
|
}
|
|
@@ -32374,11 +31972,11 @@ var defaultReporter = {
|
|
|
32374
31972
|
}
|
|
32375
31973
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
32376
31974
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
32377
|
-
|
|
31975
|
+
_chunkVMBQETG3js.isomorph_default.writeln(
|
|
32378
31976
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
32379
31977
|
);
|
|
32380
31978
|
} else {
|
|
32381
|
-
|
|
31979
|
+
_chunkVMBQETG3js.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
32382
31980
|
}
|
|
32383
31981
|
}
|
|
32384
31982
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -32394,23 +31992,23 @@ var defaultReporter = {
|
|
|
32394
31992
|
}
|
|
32395
31993
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
32396
31994
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
32397
|
-
|
|
31995
|
+
_chunkVMBQETG3js.isomorph_default.writeln(
|
|
32398
31996
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
32399
31997
|
);
|
|
32400
31998
|
} else {
|
|
32401
|
-
|
|
31999
|
+
_chunkVMBQETG3js.isomorph_default.writeln(
|
|
32402
32000
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
32403
32001
|
);
|
|
32404
32002
|
}
|
|
32405
32003
|
}
|
|
32406
32004
|
}
|
|
32407
32005
|
if (summary.experimentUrl) {
|
|
32408
|
-
|
|
32409
|
-
|
|
32410
|
-
|
|
32006
|
+
_chunkVMBQETG3js.isomorph_default.writeln("");
|
|
32007
|
+
_chunkVMBQETG3js.isomorph_default.writeln(`View results for ${summary.experimentName}`);
|
|
32008
|
+
_chunkVMBQETG3js.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
|
|
32411
32009
|
}
|
|
32412
32010
|
}
|
|
32413
|
-
|
|
32011
|
+
_chunkVMBQETG3js.isomorph_default.writeln("");
|
|
32414
32012
|
return failingResults.length === 0;
|
|
32415
32013
|
},
|
|
32416
32014
|
async reportRun(evalReports) {
|
|
@@ -32531,7 +32129,7 @@ var ToolBuilder = (_class34 = class {
|
|
|
32531
32129
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
32532
32130
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
32533
32131
|
if (resolvedName.trim().length === 0) {
|
|
32534
|
-
resolvedName = `Tool ${
|
|
32132
|
+
resolvedName = `Tool ${_chunkVMBQETG3js.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
32535
32133
|
}
|
|
32536
32134
|
const tool = new CodeFunction(this.project, {
|
|
32537
32135
|
handler,
|
|
@@ -32560,7 +32158,7 @@ var ScorerBuilder = (_class35 = class {
|
|
|
32560
32158
|
resolvedName = opts.handler.name;
|
|
32561
32159
|
}
|
|
32562
32160
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
32563
|
-
resolvedName = `Scorer ${
|
|
32161
|
+
resolvedName = `Scorer ${_chunkVMBQETG3js.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
32564
32162
|
}
|
|
32565
32163
|
const slug = _nullishCoalesce(opts.slug, () => ( slugify(resolvedName, { lower: true, strict: true })));
|
|
32566
32164
|
if ("handler" in opts) {
|
|
@@ -33119,4 +32717,4 @@ configureNode();
|
|
|
33119
32717
|
|
|
33120
32718
|
|
|
33121
32719
|
|
|
33122
|
-
exports.Attachment = Attachment; exports.AttachmentReference = AttachmentReference; exports.BRAINTRUST_CURRENT_SPAN_STORE = BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BaseAttachment = BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = BraintrustObservabilityExporter; exports.BraintrustState = BraintrustState; exports.BraintrustStream = BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = Dataset2; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = Experiment2; exports.ExternalAttachment = ExternalAttachment; exports.FailedHTTPResponse = FailedHTTPResponse; exports.IDGenerator = IDGenerator; exports.JSONAttachment = JSONAttachment; exports.LEGACY_CACHED_HEADER = LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = LazyValue; exports.Logger = Logger; exports.LoginInvalidOrgError = LoginInvalidOrgError; exports.NOOP_SPAN = NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = NOOP_SPAN_PERMALINK; exports.NoopSpan = NoopSpan; exports.ObjectFetcher = ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = Prompt2; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = ReadonlyAttachment; exports.ReadonlyExperiment = ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = SpanImpl; exports.TestBackgroundLogger = TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = UUIDGenerator; exports.X_CACHED_HEADER = X_CACHED_HEADER; exports._exportsForTestingOnly = _exportsForTestingOnly; exports._internalGetGlobalState = _internalGetGlobalState; exports._internalIso =
|
|
32720
|
+
exports.Attachment = Attachment; exports.AttachmentReference = AttachmentReference; exports.BRAINTRUST_CURRENT_SPAN_STORE = BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BaseAttachment = BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = BraintrustObservabilityExporter; exports.BraintrustState = BraintrustState; exports.BraintrustStream = BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = Dataset2; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = Experiment2; exports.ExternalAttachment = ExternalAttachment; exports.FailedHTTPResponse = FailedHTTPResponse; exports.IDGenerator = IDGenerator; exports.JSONAttachment = JSONAttachment; exports.LEGACY_CACHED_HEADER = LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = Logger; exports.LoginInvalidOrgError = LoginInvalidOrgError; exports.NOOP_SPAN = NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = NOOP_SPAN_PERMALINK; exports.NoopSpan = NoopSpan; exports.ObjectFetcher = ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = Prompt2; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = ReadonlyAttachment; exports.ReadonlyExperiment = ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = SpanImpl; exports.TestBackgroundLogger = TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = UUIDGenerator; exports.X_CACHED_HEADER = X_CACHED_HEADER; exports._exportsForTestingOnly = _exportsForTestingOnly; exports._internalGetGlobalState = _internalGetGlobalState; exports._internalIso = _chunkVMBQETG3js.isomorph_default; exports._internalSetInitialState = _internalSetInitialState; exports.addAzureBlobHeaders = addAzureBlobHeaders; exports.braintrustFlueObserver = braintrustFlueObserver; exports.braintrustStreamChunkSchema = braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = configureInstrumentation; exports.constructLogs3OverflowRequest = constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = createFinalValuePassThroughStream; exports.currentExperiment = currentExperiment; exports.currentLogger = currentLogger; exports.currentSpan = currentSpan; exports.deepCopyEvent = deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = deserializePlainStringAsJSON; exports.devNullWritableStream = devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.flush = flush; exports.getContextManager = getContextManager; exports.getIdGenerator = getIdGenerator; exports.getPromptVersions = getPromptVersions; exports.getSpanParentObject = getSpanParentObject; exports.getTemplateRenderer = getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = init; exports.initDataset = initDataset; exports.initExperiment = initExperiment; exports.initFunction = initFunction; exports.initLogger = initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.invoke = invoke; exports.isTemplateFormat = isTemplateFormat; exports.loadParameters = loadParameters; exports.loadPrompt = loadPrompt; exports.log = log; exports.logError = logError; exports.login = login; exports.loginToState = loginToState; exports.logs3OverflowUploadSchema = logs3OverflowUploadSchema; exports.newId = newId; exports.parseCachedHeader = parseCachedHeader; exports.parseTemplateFormat = parseTemplateFormat; exports.permalink = permalink; exports.pickLogs3OverflowObjectIds = pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = registerTemplatePlugin; exports.renderMessage = renderMessage; exports.renderPromptParams = renderPromptParams; exports.renderTemplateContent = renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = setFetch; exports.setMaskingFunction = setMaskingFunction; exports.spanComponentsToObjectId = spanComponentsToObjectId; exports.startSpan = startSpan; exports.summarize = summarize; exports.templateRegistry = templateRegistry; exports.toolFunctionDefinitionSchema = ToolFunctionDefinition; exports.traceable = traceable; exports.traced = traced; exports.updateSpan = updateSpan; exports.uploadLogs3OverflowPayload = uploadLogs3OverflowPayload; exports.utf8ByteLength = utf8ByteLength; exports.withCurrent = withCurrent; exports.withDataset = withDataset; exports.withExperiment = withExperiment; exports.withLogger = withLogger; exports.withParent = withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCohere = wrapCohere; exports.wrapCopilotClient = wrapCopilotClient; exports.wrapCursorSDK = wrapCursorSDK; exports.wrapGenkit = wrapGenkit; exports.wrapGoogleADK = wrapGoogleADK; exports.wrapGoogleGenAI = wrapGoogleGenAI; exports.wrapGroq = wrapGroq; exports.wrapHuggingFace = wrapHuggingFace; exports.wrapMastraAgent = wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapTraced = wrapTraced; exports.wrapVitest = wrapVitest;
|