braintrust 3.30.0 → 3.31.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.d.mts +4 -1
- package/dev/dist/index.d.ts +4 -1
- package/dev/dist/index.js +28 -7
- package/dev/dist/index.mjs +28 -7
- package/dist/apply-auto-instrumentation.js +216 -216
- package/dist/apply-auto-instrumentation.mjs +1 -1
- package/dist/auto-instrumentations/bundler/next.cjs +9 -3
- package/dist/auto-instrumentations/bundler/next.mjs +9 -3
- package/dist/auto-instrumentations/hook.mjs +3 -1
- package/dist/browser.d.mts +481 -478
- package/dist/browser.d.ts +481 -478
- package/dist/browser.js +30 -9
- package/dist/browser.mjs +30 -9
- package/dist/{chunk-2XDW3UCG.js → chunk-4AQGZS6X.js} +1 -1
- package/dist/{chunk-BU6SM54N.mjs → chunk-AJT4FR25.mjs} +17 -6
- package/dist/{chunk-N3JKQ3D3.mjs → chunk-CE3BLB2L.mjs} +1 -1
- package/dist/{chunk-TWCDSYJN.js → chunk-V32LW47Z.js} +535 -524
- package/dist/cli.js +29 -8
- package/dist/edge-light.js +30 -9
- package/dist/edge-light.mjs +30 -9
- package/dist/index.d.mts +481 -478
- package/dist/index.d.ts +481 -478
- package/dist/index.js +460 -450
- package/dist/index.mjs +15 -5
- package/dist/instrumentation/index.js +17 -6
- package/dist/instrumentation/index.mjs +17 -6
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.js +30 -9
- package/dist/workerd.mjs +30 -9
- package/package.json +1 -1
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
var
|
|
55
|
+
var _chunk4AQGZS6Xjs = require('./chunk-4AQGZS6X.js');
|
|
56
56
|
|
|
57
57
|
// src/id-gen.ts
|
|
58
58
|
var _uuid = require('uuid'); var uuid3 = _interopRequireWildcard(_uuid); var uuid2 = _interopRequireWildcard(_uuid); var uuid = _interopRequireWildcard(_uuid);
|
|
@@ -88,7 +88,7 @@ var OTELIDGenerator = class extends IDGenerator {
|
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
function parseEnvBool(name) {
|
|
91
|
-
const raw =
|
|
91
|
+
const raw = _chunk4AQGZS6Xjs.isomorph_default.getEnv(name);
|
|
92
92
|
if (raw === void 0 || raw === null) {
|
|
93
93
|
return false;
|
|
94
94
|
}
|
|
@@ -101,7 +101,7 @@ function resolveUseLegacyUuidIds() {
|
|
|
101
101
|
if (parseEnvBool("BRAINTRUST_OTEL_COMPAT")) {
|
|
102
102
|
if (legacy && !_warnedLegacyUuidConflict) {
|
|
103
103
|
_warnedLegacyUuidConflict = true;
|
|
104
|
-
|
|
104
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
105
105
|
"BRAINTRUST_LEGACY_IDS is ignored because BRAINTRUST_OTEL_COMPAT requires OpenTelemetry-compatible hex span IDs. Using hex IDs."
|
|
106
106
|
);
|
|
107
107
|
}
|
|
@@ -3016,6 +3016,7 @@ var ProjectSettings = _v3.z.union([
|
|
|
3016
3016
|
]),
|
|
3017
3017
|
disable_realtime_queries: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
3018
3018
|
monitor_charts_use_metrics_start: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
3019
|
+
blind_reviews: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
3019
3020
|
default_preprocessor: NullableSavedFunctionId
|
|
3020
3021
|
}).partial(),
|
|
3021
3022
|
_v3.z.null()
|
|
@@ -3077,6 +3078,7 @@ var WindowedAutomationConfig = _v3.z.object({
|
|
|
3077
3078
|
auto_approve_tools: _v3.z.array(_v3.z.string().min(1)).optional().default([]),
|
|
3078
3079
|
harness: _v3.z.enum(["native", "codex", "claude-code"]).optional(),
|
|
3079
3080
|
model: _v3.z.string().min(1).optional(),
|
|
3081
|
+
endpoint_name: _v3.z.string().min(1).optional(),
|
|
3080
3082
|
reasoning_effort: _v3.z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional()
|
|
3081
3083
|
}).optional(),
|
|
3082
3084
|
actions: _v3.z.array(
|
|
@@ -4125,7 +4127,7 @@ var Queue = (_class4 = class {
|
|
|
4125
4127
|
__init6() {this.enforceSizeLimit = false}
|
|
4126
4128
|
constructor(maxSize) {;_class4.prototype.__init5.call(this);_class4.prototype.__init6.call(this);
|
|
4127
4129
|
if (maxSize < 1) {
|
|
4128
|
-
|
|
4130
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
4129
4131
|
`maxSize ${maxSize} is <1, using default ${DEFAULT_QUEUE_SIZE}`
|
|
4130
4132
|
);
|
|
4131
4133
|
maxSize = DEFAULT_QUEUE_SIZE;
|
|
@@ -4179,7 +4181,7 @@ var _functions = require('@vercel/functions');
|
|
|
4179
4181
|
|
|
4180
4182
|
// src/prompt-cache/disk-cache.ts
|
|
4181
4183
|
function canUseDiskCache() {
|
|
4182
|
-
return !!(
|
|
4184
|
+
return !!(_chunk4AQGZS6Xjs.isomorph_default.hash && _chunk4AQGZS6Xjs.isomorph_default.gunzip && _chunk4AQGZS6Xjs.isomorph_default.gzip && _chunk4AQGZS6Xjs.isomorph_default.stat && _chunk4AQGZS6Xjs.isomorph_default.readFile && _chunk4AQGZS6Xjs.isomorph_default.writeFile && _chunk4AQGZS6Xjs.isomorph_default.utimes && _chunk4AQGZS6Xjs.isomorph_default.readdir && _chunk4AQGZS6Xjs.isomorph_default.mkdir && _chunk4AQGZS6Xjs.isomorph_default.unlink && _chunk4AQGZS6Xjs.isomorph_default.homedir);
|
|
4183
4185
|
}
|
|
4184
4186
|
var DiskCache = class {
|
|
4185
4187
|
|
|
@@ -4200,8 +4202,8 @@ var DiskCache = class {
|
|
|
4200
4202
|
this.mkdir = _nullishCoalesce(options.mkdir, () => ( true));
|
|
4201
4203
|
}
|
|
4202
4204
|
getEntryPath(key) {
|
|
4203
|
-
const hashed =
|
|
4204
|
-
return
|
|
4205
|
+
const hashed = _chunk4AQGZS6Xjs.isomorph_default.hash(key);
|
|
4206
|
+
return _chunk4AQGZS6Xjs.isomorph_default.pathJoin(this.dir, hashed);
|
|
4205
4207
|
}
|
|
4206
4208
|
/**
|
|
4207
4209
|
* Retrieves a value from the cache.
|
|
@@ -4213,8 +4215,8 @@ var DiskCache = class {
|
|
|
4213
4215
|
async get(key) {
|
|
4214
4216
|
try {
|
|
4215
4217
|
const filePath = this.getEntryPath(key);
|
|
4216
|
-
const data = await
|
|
4217
|
-
await
|
|
4218
|
+
const data = await _chunk4AQGZS6Xjs.isomorph_default.gunzip(await _chunk4AQGZS6Xjs.isomorph_default.readFile(filePath));
|
|
4219
|
+
await _chunk4AQGZS6Xjs.isomorph_default.utimes(filePath, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date());
|
|
4218
4220
|
return JSON.parse(data.toString());
|
|
4219
4221
|
} catch (e) {
|
|
4220
4222
|
if (e.code === "ENOENT") {
|
|
@@ -4236,11 +4238,11 @@ var DiskCache = class {
|
|
|
4236
4238
|
async set(key, value) {
|
|
4237
4239
|
try {
|
|
4238
4240
|
if (this.mkdir) {
|
|
4239
|
-
await
|
|
4241
|
+
await _chunk4AQGZS6Xjs.isomorph_default.mkdir(this.dir, { recursive: true });
|
|
4240
4242
|
}
|
|
4241
4243
|
const filePath = this.getEntryPath(key);
|
|
4242
|
-
const data = await
|
|
4243
|
-
await
|
|
4244
|
+
const data = await _chunk4AQGZS6Xjs.isomorph_default.gzip(JSON.stringify(value));
|
|
4245
|
+
await _chunk4AQGZS6Xjs.isomorph_default.writeFile(filePath, data);
|
|
4244
4246
|
await this.evictOldestIfFull();
|
|
4245
4247
|
} catch (e) {
|
|
4246
4248
|
if (this.logWarnings) {
|
|
@@ -4253,14 +4255,14 @@ var DiskCache = class {
|
|
|
4253
4255
|
if (!this.max) {
|
|
4254
4256
|
return;
|
|
4255
4257
|
}
|
|
4256
|
-
const files = await
|
|
4257
|
-
const paths = files.map((file) =>
|
|
4258
|
+
const files = await _chunk4AQGZS6Xjs.isomorph_default.readdir(this.dir);
|
|
4259
|
+
const paths = files.map((file) => _chunk4AQGZS6Xjs.isomorph_default.pathJoin(this.dir, file));
|
|
4258
4260
|
if (paths.length <= this.max) {
|
|
4259
4261
|
return;
|
|
4260
4262
|
}
|
|
4261
4263
|
const stats = await Promise.all(
|
|
4262
4264
|
paths.map(async (path3) => {
|
|
4263
|
-
const stat2 = await
|
|
4265
|
+
const stat2 = await _chunk4AQGZS6Xjs.isomorph_default.stat(path3);
|
|
4264
4266
|
return {
|
|
4265
4267
|
path: path3,
|
|
4266
4268
|
mtime: stat2.mtime.getTime()
|
|
@@ -4269,7 +4271,7 @@ var DiskCache = class {
|
|
|
4269
4271
|
);
|
|
4270
4272
|
stats.sort((a, b) => a.mtime - b.mtime);
|
|
4271
4273
|
const toRemove = stats.slice(0, stats.length - this.max);
|
|
4272
|
-
await Promise.all(toRemove.map((stat2) =>
|
|
4274
|
+
await Promise.all(toRemove.map((stat2) => _chunk4AQGZS6Xjs.isomorph_default.unlink(stat2.path)));
|
|
4273
4275
|
}
|
|
4274
4276
|
};
|
|
4275
4277
|
|
|
@@ -4374,7 +4376,7 @@ function warnInvalidCacheMode(value) {
|
|
|
4374
4376
|
return;
|
|
4375
4377
|
}
|
|
4376
4378
|
warnedInvalidCacheModeEnvValue = true;
|
|
4377
|
-
|
|
4379
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
4378
4380
|
`Invalid ${CACHE_LOCATION_ENV_VAR} value "${value}". Expected "mixed", "memory", "disk", or "none". Falling back to "mixed".`
|
|
4379
4381
|
);
|
|
4380
4382
|
}
|
|
@@ -4383,12 +4385,12 @@ function warnUnavailableDiskCache() {
|
|
|
4383
4385
|
return;
|
|
4384
4386
|
}
|
|
4385
4387
|
warnedUnavailableDiskCacheMode = true;
|
|
4386
|
-
|
|
4388
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
4387
4389
|
`Disk cache is not supported on this platform, so ${CACHE_LOCATION_ENV_VAR}="disk" disables prompt and parameters caching.`
|
|
4388
4390
|
);
|
|
4389
4391
|
}
|
|
4390
4392
|
function parseCacheMode() {
|
|
4391
|
-
const value =
|
|
4393
|
+
const value = _chunk4AQGZS6Xjs.isomorph_default.getEnv(CACHE_LOCATION_ENV_VAR);
|
|
4392
4394
|
const normalized = _optionalChain([value, 'optionalAccess', _17 => _17.trim, 'call', _18 => _18(), 'access', _19 => _19.toLowerCase, 'call', _20 => _20()]);
|
|
4393
4395
|
if (!normalized) {
|
|
4394
4396
|
return "mixed";
|
|
@@ -4400,7 +4402,7 @@ function parseCacheMode() {
|
|
|
4400
4402
|
return "mixed";
|
|
4401
4403
|
}
|
|
4402
4404
|
function parsePositiveIntegerEnv(envVar, defaultValue) {
|
|
4403
|
-
const value = Number(
|
|
4405
|
+
const value = Number(_chunk4AQGZS6Xjs.isomorph_default.getEnv(envVar));
|
|
4404
4406
|
return Number.isInteger(value) && value > 0 ? value : defaultValue;
|
|
4405
4407
|
}
|
|
4406
4408
|
function createCacheLayers({
|
|
@@ -4420,7 +4422,7 @@ function createCacheLayers({
|
|
|
4420
4422
|
if (mode === "mixed" || mode === "disk") {
|
|
4421
4423
|
if (canUseDiskCache()) {
|
|
4422
4424
|
diskCache = new DiskCache({
|
|
4423
|
-
cacheDir: _nullishCoalesce(
|
|
4425
|
+
cacheDir: _nullishCoalesce(_chunk4AQGZS6Xjs.isomorph_default.getEnv(diskCacheDirEnvVar), () => ( getDefaultDiskCacheDir())),
|
|
4424
4426
|
max: parsePositiveIntegerEnv(diskMaxEnvVar, DEFAULT_CACHE_DISK_MAX)
|
|
4425
4427
|
});
|
|
4426
4428
|
} else if (mode === "disk") {
|
|
@@ -4606,7 +4608,7 @@ var ParametersCache = class _ParametersCache {
|
|
|
4606
4608
|
var activeCaches = /* @__PURE__ */ new Set();
|
|
4607
4609
|
var exitHandlersRegistered = false;
|
|
4608
4610
|
function canUseSpanCache() {
|
|
4609
|
-
return !!(
|
|
4611
|
+
return !!(_chunk4AQGZS6Xjs.isomorph_default.pathJoin && _chunk4AQGZS6Xjs.isomorph_default.tmpdir && _chunk4AQGZS6Xjs.isomorph_default.writeFileSync && _chunk4AQGZS6Xjs.isomorph_default.appendFileSync && _chunk4AQGZS6Xjs.isomorph_default.readFileSync && _chunk4AQGZS6Xjs.isomorph_default.unlinkSync && _chunk4AQGZS6Xjs.isomorph_default.openFile);
|
|
4610
4612
|
}
|
|
4611
4613
|
var SpanCache = (_class5 = class {
|
|
4612
4614
|
__init7() {this.cacheFilePath = null}
|
|
@@ -4671,16 +4673,16 @@ var SpanCache = (_class5 = class {
|
|
|
4671
4673
|
return this.initPromise;
|
|
4672
4674
|
}
|
|
4673
4675
|
this.initPromise = (async () => {
|
|
4674
|
-
if (!
|
|
4676
|
+
if (!_chunk4AQGZS6Xjs.isomorph_default.tmpdir || !_chunk4AQGZS6Xjs.isomorph_default.pathJoin || !_chunk4AQGZS6Xjs.isomorph_default.openFile) {
|
|
4675
4677
|
return;
|
|
4676
4678
|
}
|
|
4677
|
-
const tmpDir =
|
|
4679
|
+
const tmpDir = _chunk4AQGZS6Xjs.isomorph_default.tmpdir();
|
|
4678
4680
|
const uniqueId = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
4679
|
-
this.cacheFilePath =
|
|
4681
|
+
this.cacheFilePath = _chunk4AQGZS6Xjs.isomorph_default.pathJoin(
|
|
4680
4682
|
tmpDir,
|
|
4681
4683
|
`braintrust-span-cache-${uniqueId}.jsonl`
|
|
4682
4684
|
);
|
|
4683
|
-
this.fileHandle = await
|
|
4685
|
+
this.fileHandle = await _chunk4AQGZS6Xjs.isomorph_default.openFile(this.cacheFilePath, "a+");
|
|
4684
4686
|
this.initialized = true;
|
|
4685
4687
|
this.registerExitHandler();
|
|
4686
4688
|
})();
|
|
@@ -4704,9 +4706,9 @@ var SpanCache = (_class5 = class {
|
|
|
4704
4706
|
} catch (e11) {
|
|
4705
4707
|
}
|
|
4706
4708
|
}
|
|
4707
|
-
if (cache.cacheFilePath && canUseSpanCache() &&
|
|
4709
|
+
if (cache.cacheFilePath && canUseSpanCache() && _chunk4AQGZS6Xjs.isomorph_default.unlinkSync) {
|
|
4708
4710
|
try {
|
|
4709
|
-
|
|
4711
|
+
_chunk4AQGZS6Xjs.isomorph_default.unlinkSync(cache.cacheFilePath);
|
|
4710
4712
|
} catch (e12) {
|
|
4711
4713
|
}
|
|
4712
4714
|
}
|
|
@@ -4785,9 +4787,9 @@ var SpanCache = (_class5 = class {
|
|
|
4785
4787
|
return void 0;
|
|
4786
4788
|
}
|
|
4787
4789
|
const spanMap = /* @__PURE__ */ new Map();
|
|
4788
|
-
if (this.initialized && this.cacheFilePath &&
|
|
4790
|
+
if (this.initialized && this.cacheFilePath && _chunk4AQGZS6Xjs.isomorph_default.readFileSync) {
|
|
4789
4791
|
try {
|
|
4790
|
-
const content =
|
|
4792
|
+
const content = _chunk4AQGZS6Xjs.isomorph_default.readFileSync(this.cacheFilePath, "utf8");
|
|
4791
4793
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
4792
4794
|
for (const line of lines) {
|
|
4793
4795
|
try {
|
|
@@ -4876,9 +4878,9 @@ var SpanCache = (_class5 = class {
|
|
|
4876
4878
|
});
|
|
4877
4879
|
this.fileHandle = null;
|
|
4878
4880
|
}
|
|
4879
|
-
if (this.cacheFilePath && canUseSpanCache() &&
|
|
4881
|
+
if (this.cacheFilePath && canUseSpanCache() && _chunk4AQGZS6Xjs.isomorph_default.unlinkSync) {
|
|
4880
4882
|
try {
|
|
4881
|
-
|
|
4883
|
+
_chunk4AQGZS6Xjs.isomorph_default.unlinkSync(this.cacheFilePath);
|
|
4882
4884
|
} catch (e15) {
|
|
4883
4885
|
}
|
|
4884
4886
|
this.cacheFilePath = null;
|
|
@@ -5011,7 +5013,7 @@ var BraintrustContextManager = class extends ContextManager {
|
|
|
5011
5013
|
|
|
5012
5014
|
constructor() {
|
|
5013
5015
|
super();
|
|
5014
|
-
this._currentSpan =
|
|
5016
|
+
this._currentSpan = _chunk4AQGZS6Xjs.isomorph_default.newAsyncLocalStorage();
|
|
5015
5017
|
this[BRAINTRUST_CURRENT_SPAN_STORE] = this._currentSpan;
|
|
5016
5018
|
}
|
|
5017
5019
|
getParentSpanIds() {
|
|
@@ -5171,12 +5173,12 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5171
5173
|
|
|
5172
5174
|
constructor(loginParams) {;_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);_class7.prototype.__init24.call(this);_class7.prototype.__init25.call(this);_class7.prototype.__init26.call(this);_class7.prototype.__init27.call(this);_class7.prototype.__init28.call(this);_class7.prototype.__init29.call(this);_class7.prototype.__init30.call(this);_class7.prototype.__init31.call(this);_class7.prototype.__init32.call(this);_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);
|
|
5173
5175
|
this.loginParams = { ...loginParams };
|
|
5174
|
-
this.activeLoginOrgNameSelector = _nullishCoalesce(loginParams.orgName, () => (
|
|
5176
|
+
this.activeLoginOrgNameSelector = _nullishCoalesce(loginParams.orgName, () => ( _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_ORG_NAME")));
|
|
5175
5177
|
this.id = `${(/* @__PURE__ */ new Date()).toLocaleString()}-${stateNonce++}`;
|
|
5176
5178
|
this.currentExperiment = void 0;
|
|
5177
5179
|
this.currentLogger = void 0;
|
|
5178
|
-
this.currentParent =
|
|
5179
|
-
this.currentSpan =
|
|
5180
|
+
this.currentParent = _chunk4AQGZS6Xjs.isomorph_default.newAsyncLocalStorage();
|
|
5181
|
+
this.currentSpan = _chunk4AQGZS6Xjs.isomorph_default.newAsyncLocalStorage();
|
|
5180
5182
|
if (loginParams.fetch) {
|
|
5181
5183
|
this.fetch = loginParams.fetch;
|
|
5182
5184
|
}
|
|
@@ -5189,20 +5191,20 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5189
5191
|
);
|
|
5190
5192
|
if (loginParams.debugLogLevel !== void 0) {
|
|
5191
5193
|
this.debugLogLevelConfigured = true;
|
|
5192
|
-
this.debugLogLevel =
|
|
5194
|
+
this.debugLogLevel = _chunk4AQGZS6Xjs.normalizeDebugLogLevelOption.call(void 0,
|
|
5193
5195
|
loginParams.debugLogLevel
|
|
5194
5196
|
);
|
|
5195
|
-
|
|
5197
|
+
_chunk4AQGZS6Xjs.setGlobalDebugLogLevel.call(void 0, _nullishCoalesce(this.debugLogLevel, () => ( false)));
|
|
5196
5198
|
} else {
|
|
5197
|
-
this.debugLogLevel =
|
|
5198
|
-
|
|
5199
|
+
this.debugLogLevel = _chunk4AQGZS6Xjs.getEnvDebugLogLevel.call(void 0, );
|
|
5200
|
+
_chunk4AQGZS6Xjs.setGlobalDebugLogLevel.call(void 0, void 0);
|
|
5199
5201
|
}
|
|
5200
5202
|
this.resetLoginInfo();
|
|
5201
5203
|
const { memoryCache, diskCache } = createCacheLayers({
|
|
5202
5204
|
memoryMaxEnvVar: "BRAINTRUST_PROMPT_CACHE_MEMORY_MAX",
|
|
5203
5205
|
diskCacheDirEnvVar: "BRAINTRUST_PROMPT_CACHE_DIR",
|
|
5204
5206
|
diskMaxEnvVar: "BRAINTRUST_PROMPT_CACHE_DISK_MAX",
|
|
5205
|
-
getDefaultDiskCacheDir: () => `${_nullishCoalesce(
|
|
5207
|
+
getDefaultDiskCacheDir: () => `${_nullishCoalesce(_chunk4AQGZS6Xjs.isomorph_default.getEnv("HOME"), () => ( _chunk4AQGZS6Xjs.isomorph_default.homedir()))}/.braintrust/prompt_cache`
|
|
5206
5208
|
});
|
|
5207
5209
|
this.promptCache = new PromptCache({ memoryCache, diskCache });
|
|
5208
5210
|
const {
|
|
@@ -5213,7 +5215,7 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5213
5215
|
memoryMaxEnvVar: "BRAINTRUST_PARAMETERS_CACHE_MEMORY_MAX",
|
|
5214
5216
|
diskCacheDirEnvVar: "BRAINTRUST_PARAMETERS_CACHE_DIR",
|
|
5215
5217
|
diskMaxEnvVar: "BRAINTRUST_PARAMETERS_CACHE_DISK_MAX",
|
|
5216
|
-
getDefaultDiskCacheDir: () => `${_nullishCoalesce(
|
|
5218
|
+
getDefaultDiskCacheDir: () => `${_nullishCoalesce(_chunk4AQGZS6Xjs.isomorph_default.getEnv("HOME"), () => ( _chunk4AQGZS6Xjs.isomorph_default.homedir()))}/.braintrust/parameters_cache`
|
|
5217
5219
|
}
|
|
5218
5220
|
);
|
|
5219
5221
|
this.parametersCache = new ParametersCache({
|
|
@@ -5221,7 +5223,7 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5221
5223
|
diskCache: parametersDiskCache
|
|
5222
5224
|
});
|
|
5223
5225
|
this.spanCache = new SpanCache({ disabled: loginParams.disableSpanCache });
|
|
5224
|
-
this.spanOriginEnvironment =
|
|
5226
|
+
this.spanOriginEnvironment = _chunk4AQGZS6Xjs.detectSpanOriginEnvironment.call(void 0, );
|
|
5225
5227
|
this._internalSetTraceContextSigningSecret(loginParams.apiKey);
|
|
5226
5228
|
}
|
|
5227
5229
|
/** @internal */
|
|
@@ -5233,7 +5235,7 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5233
5235
|
}
|
|
5234
5236
|
/** @internal */
|
|
5235
5237
|
_internalGetTraceContextSigningSecret() {
|
|
5236
|
-
return _optionalChain([(_nullishCoalesce(_nullishCoalesce(this.traceContextSigningSecret, () => ( this.loginToken)), () => (
|
|
5238
|
+
return _optionalChain([(_nullishCoalesce(_nullishCoalesce(this.traceContextSigningSecret, () => ( this.loginToken)), () => ( _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_API_KEY")))), 'optionalAccess', _37 => _37.trim, 'call', _38 => _38()]);
|
|
5237
5239
|
}
|
|
5238
5240
|
resetLoginInfo() {
|
|
5239
5241
|
this.appUrl = null;
|
|
@@ -5258,8 +5260,8 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5258
5260
|
fetch: fetch2,
|
|
5259
5261
|
forceLogin
|
|
5260
5262
|
}) {
|
|
5261
|
-
const resolvedAppUrl = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(appUrl, () => ( (this.loggedIn ? _nullishCoalesce(this.appUrl, () => ( void 0)) : void 0))), () => ( this.loginParams.appUrl)), () => (
|
|
5262
|
-
const resolvedApiKey = await _asyncNullishCoalesce(await _asyncNullishCoalesce(await _asyncNullishCoalesce(apiKey, async () => ( (this.loggedIn ? _nullishCoalesce(this.loginToken, () => ( void 0)) : void 0))), async () => ( this.loginParams.apiKey)), async () => ( await
|
|
5263
|
+
const resolvedAppUrl = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(appUrl, () => ( (this.loggedIn ? _nullishCoalesce(this.appUrl, () => ( void 0)) : void 0))), () => ( this.loginParams.appUrl)), () => ( _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_APP_URL"))), () => ( "https://www.braintrust.dev"));
|
|
5264
|
+
const resolvedApiKey = await _asyncNullishCoalesce(await _asyncNullishCoalesce(await _asyncNullishCoalesce(apiKey, async () => ( (this.loggedIn ? _nullishCoalesce(this.loginToken, () => ( void 0)) : void 0))), async () => ( this.loginParams.apiKey)), async () => ( await _chunk4AQGZS6Xjs.isomorph_default.getBraintrustApiKey()));
|
|
5263
5265
|
if (!resolvedApiKey) {
|
|
5264
5266
|
throw new Error(
|
|
5265
5267
|
"Please specify an api key (e.g. by setting BRAINTRUST_API_KEY)."
|
|
@@ -5267,7 +5269,7 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5267
5269
|
}
|
|
5268
5270
|
const normalizedApiKey = HTTPConnection.sanitize_token(resolvedApiKey);
|
|
5269
5271
|
const usesActiveCredential = this.loggedIn && normalizedApiKey === this.loginToken;
|
|
5270
|
-
const requestedOrgName = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(orgName, () => ( (usesActiveCredential ? this.activeLoginOrgNameSelector : void 0))), () => ( this.loginParams.orgName)), () => (
|
|
5272
|
+
const requestedOrgName = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(orgName, () => ( (usesActiveCredential ? this.activeLoginOrgNameSelector : void 0))), () => ( this.loginParams.orgName)), () => ( _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_ORG_NAME")));
|
|
5271
5273
|
const resolvedOrgName = _nullishCoalesce(_nullishCoalesce(orgName, () => ( (usesActiveCredential ? _nullishCoalesce(this.orgName, () => ( void 0)) : void 0))), () => ( requestedOrgName));
|
|
5272
5274
|
const resolvedFetch = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(fetch2, () => ( (this.loggedIn ? this.fetch : void 0))), () => ( this.loginParams.fetch)), () => ( globalThis.fetch));
|
|
5273
5275
|
const credentialCacheNamespace = JSON.stringify([
|
|
@@ -5393,7 +5395,7 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5393
5395
|
this.traceContextSigningSecret = other.traceContextSigningSecret;
|
|
5394
5396
|
this.fetch = other.fetch;
|
|
5395
5397
|
this.activeLoginOrgNameSelector = other.activeLoginOrgNameSelector;
|
|
5396
|
-
|
|
5398
|
+
_chunk4AQGZS6Xjs.setGlobalDebugLogLevel.call(void 0,
|
|
5397
5399
|
this.debugLogLevelConfigured ? _nullishCoalesce(this.debugLogLevel, () => ( false)) : void 0
|
|
5398
5400
|
);
|
|
5399
5401
|
this._appConn = other._appConn;
|
|
@@ -5450,7 +5452,7 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5450
5452
|
}
|
|
5451
5453
|
state.loggedIn = true;
|
|
5452
5454
|
state.debugLogLevelConfigured = "debugLogLevel" in serializedParsed.data || !!serializedParsed.data.debugLogLevelDisabled;
|
|
5453
|
-
|
|
5455
|
+
_chunk4AQGZS6Xjs.setGlobalDebugLogLevel.call(void 0,
|
|
5454
5456
|
state.debugLogLevelConfigured ? _nullishCoalesce(state.debugLogLevel, () => ( false)) : void 0
|
|
5455
5457
|
);
|
|
5456
5458
|
state.loginReplaceApiConn(state.apiConn());
|
|
@@ -5470,8 +5472,8 @@ var BraintrustState = (_class7 = class _BraintrustState {
|
|
|
5470
5472
|
return;
|
|
5471
5473
|
}
|
|
5472
5474
|
this.debugLogLevelConfigured = true;
|
|
5473
|
-
this.debugLogLevel =
|
|
5474
|
-
|
|
5475
|
+
this.debugLogLevel = _chunk4AQGZS6Xjs.normalizeDebugLogLevelOption.call(void 0, option);
|
|
5476
|
+
_chunk4AQGZS6Xjs.setGlobalDebugLogLevel.call(void 0, _nullishCoalesce(this.debugLogLevel, () => ( false)));
|
|
5475
5477
|
}
|
|
5476
5478
|
getDebugLogLevel() {
|
|
5477
5479
|
return this.debugLogLevel;
|
|
@@ -5623,7 +5625,7 @@ function _internalSetInitialState() {
|
|
|
5623
5625
|
_globalState = existing;
|
|
5624
5626
|
}
|
|
5625
5627
|
var _internalGetGlobalState = () => _globalState;
|
|
5626
|
-
|
|
5628
|
+
_chunk4AQGZS6Xjs.setDebugLogStateResolver.call(void 0, () => _internalGetGlobalState());
|
|
5627
5629
|
function registerOtelFlush(callback) {
|
|
5628
5630
|
_optionalChain([_globalState, 'optionalAccess', _49 => _49.registerOtelFlush, 'call', _50 => _50(callback)]);
|
|
5629
5631
|
_optionalChain([_globalState, 'optionalAccess', _51 => _51.spanCache, 'optionalAccess', _52 => _52.disable, 'call', _53 => _53()]);
|
|
@@ -5805,11 +5807,11 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
5805
5807
|
if (i === tries - 1 || !isRetryableHTTPError(error)) {
|
|
5806
5808
|
throw error;
|
|
5807
5809
|
}
|
|
5808
|
-
|
|
5810
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(
|
|
5809
5811
|
`Retrying API request ${path3} after ${formatHTTPError(error)}`
|
|
5810
5812
|
);
|
|
5811
5813
|
const sleepTimeMs = HTTP_RETRY_BASE_SLEEP_TIME_S * 1e3 * 2 ** i + Math.random() * HTTP_RETRY_JITTER_MS;
|
|
5812
|
-
|
|
5814
|
+
_chunk4AQGZS6Xjs.debugLogger.info(
|
|
5813
5815
|
`Sleeping for ${sleepTimeMs}ms before retrying API request`
|
|
5814
5816
|
);
|
|
5815
5817
|
await waitForRetry(sleepTimeMs, _optionalChain([config, 'optionalAccess', _60 => _60.signal]));
|
|
@@ -5825,11 +5827,11 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
5825
5827
|
return await readJSONResponse(resp, this.classifyTransportErrors);
|
|
5826
5828
|
} catch (e) {
|
|
5827
5829
|
if (i < tries - 1) {
|
|
5828
|
-
|
|
5830
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(
|
|
5829
5831
|
`Retrying API request ${object_type} ${JSON.stringify(args)} ${e.status} ${e.text}`
|
|
5830
5832
|
);
|
|
5831
5833
|
const sleepTimeS = HTTP_RETRY_BASE_SLEEP_TIME_S * 2 ** i;
|
|
5832
|
-
|
|
5834
|
+
_chunk4AQGZS6Xjs.debugLogger.info(
|
|
5833
5835
|
`Sleeping for ${sleepTimeS}s before retrying API request`
|
|
5834
5836
|
);
|
|
5835
5837
|
await new Promise(
|
|
@@ -6023,7 +6025,7 @@ var Attachment = class extends BaseAttachment {
|
|
|
6023
6025
|
initData(data) {
|
|
6024
6026
|
if (typeof data === "string") {
|
|
6025
6027
|
this.ensureFileReadable(data);
|
|
6026
|
-
const readFile2 =
|
|
6028
|
+
const readFile2 = _chunk4AQGZS6Xjs.isomorph_default.readFile;
|
|
6027
6029
|
if (!readFile2) {
|
|
6028
6030
|
throw new Error(
|
|
6029
6031
|
`This platform does not support reading the filesystem. Construct the Attachment
|
|
@@ -6036,7 +6038,7 @@ with a Blob/ArrayBuffer, or run the program on Node.js.`
|
|
|
6036
6038
|
}
|
|
6037
6039
|
}
|
|
6038
6040
|
ensureFileReadable(data) {
|
|
6039
|
-
const statSync2 =
|
|
6041
|
+
const statSync2 = _chunk4AQGZS6Xjs.isomorph_default.statSync;
|
|
6040
6042
|
if (!statSync2) {
|
|
6041
6043
|
throw new Error(
|
|
6042
6044
|
`This platform does not support reading the filesystem. Construct the Attachment
|
|
@@ -6046,7 +6048,7 @@ with a Blob/ArrayBuffer, or run the program on Node.js.`
|
|
|
6046
6048
|
try {
|
|
6047
6049
|
statSync2(data);
|
|
6048
6050
|
} catch (e) {
|
|
6049
|
-
|
|
6051
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(`Failed to read file: ${e}`);
|
|
6050
6052
|
}
|
|
6051
6053
|
}
|
|
6052
6054
|
};
|
|
@@ -6448,10 +6450,10 @@ function getErrPermlink(msg) {
|
|
|
6448
6450
|
return `${ERR_PERMALINK}?msg=${encodeURIComponent(msg)}`;
|
|
6449
6451
|
}
|
|
6450
6452
|
function _getAppUrl(appUrl) {
|
|
6451
|
-
return appUrl ||
|
|
6453
|
+
return appUrl || _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_APP_URL") || "https://www.braintrust.dev";
|
|
6452
6454
|
}
|
|
6453
6455
|
function _getOrgName(orgName) {
|
|
6454
|
-
return orgName ||
|
|
6456
|
+
return orgName || _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_ORG_NAME") || void 0;
|
|
6455
6457
|
}
|
|
6456
6458
|
function _getLinkBaseUrl(state, linkArgs) {
|
|
6457
6459
|
const appUrl = _getAppUrl(state.appUrl || _optionalChain([linkArgs, 'optionalAccess', _67 => _67.app_url]));
|
|
@@ -7002,62 +7004,62 @@ var HTTPBackgroundLogger = (_class10 = class _HTTPBackgroundLogger {
|
|
|
7002
7004
|
constructor(apiConn, opts) {;_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);_class10.prototype.__init55.call(this);
|
|
7003
7005
|
opts = _nullishCoalesce(opts, () => ( {}));
|
|
7004
7006
|
this.apiConn = apiConn;
|
|
7005
|
-
const syncFlushEnv = Number(
|
|
7007
|
+
const syncFlushEnv = Number(_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_SYNC_FLUSH"));
|
|
7006
7008
|
if (!isNaN(syncFlushEnv)) {
|
|
7007
7009
|
this.syncFlush = Boolean(syncFlushEnv);
|
|
7008
7010
|
}
|
|
7009
7011
|
const defaultBatchSizeEnv = Number(
|
|
7010
|
-
|
|
7012
|
+
_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_DEFAULT_BATCH_SIZE")
|
|
7011
7013
|
);
|
|
7012
7014
|
if (!isNaN(defaultBatchSizeEnv)) {
|
|
7013
7015
|
this.defaultBatchSize = defaultBatchSizeEnv;
|
|
7014
7016
|
}
|
|
7015
|
-
const maxRequestSizeEnv = Number(
|
|
7017
|
+
const maxRequestSizeEnv = Number(_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_MAX_REQUEST_SIZE"));
|
|
7016
7018
|
if (!isNaN(maxRequestSizeEnv)) {
|
|
7017
7019
|
this.maxRequestSizeOverride = maxRequestSizeEnv;
|
|
7018
7020
|
}
|
|
7019
|
-
const numTriesEnv = Number(
|
|
7021
|
+
const numTriesEnv = Number(_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_NUM_RETRIES"));
|
|
7020
7022
|
if (!isNaN(numTriesEnv)) {
|
|
7021
7023
|
this.numTries = numTriesEnv + 1;
|
|
7022
7024
|
}
|
|
7023
7025
|
const queueDropExceedingMaxsizeEnv = Number(
|
|
7024
|
-
|
|
7026
|
+
_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_QUEUE_DROP_EXCEEDING_MAXSIZE")
|
|
7025
7027
|
);
|
|
7026
7028
|
if (!isNaN(queueDropExceedingMaxsizeEnv)) {
|
|
7027
7029
|
this.queueDropExceedingMaxsize = queueDropExceedingMaxsizeEnv;
|
|
7028
7030
|
}
|
|
7029
7031
|
this.queue = new Queue(this.queueDropExceedingMaxsize);
|
|
7030
7032
|
const queueDropLoggingPeriodEnv = Number(
|
|
7031
|
-
|
|
7033
|
+
_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_QUEUE_DROP_LOGGING_PERIOD")
|
|
7032
7034
|
);
|
|
7033
7035
|
if (!isNaN(queueDropLoggingPeriodEnv)) {
|
|
7034
7036
|
this.queueDropLoggingPeriod = queueDropLoggingPeriodEnv;
|
|
7035
7037
|
}
|
|
7036
|
-
if (
|
|
7037
|
-
|
|
7038
|
+
if (_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_LOG_FLUSH_CHUNK_SIZE")) {
|
|
7039
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
7038
7040
|
"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."
|
|
7039
7041
|
);
|
|
7040
7042
|
}
|
|
7041
7043
|
const flushBackpressureBytesEnv = Number(
|
|
7042
|
-
|
|
7044
|
+
_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_FLUSH_BACKPRESSURE_BYTES")
|
|
7043
7045
|
);
|
|
7044
7046
|
if (!isNaN(flushBackpressureBytesEnv) && flushBackpressureBytesEnv > 0) {
|
|
7045
7047
|
this._flushBackpressureBytes = flushBackpressureBytesEnv;
|
|
7046
7048
|
}
|
|
7047
|
-
const failedPublishPayloadsDirEnv =
|
|
7049
|
+
const failedPublishPayloadsDirEnv = _chunk4AQGZS6Xjs.isomorph_default.getEnv(
|
|
7048
7050
|
"BRAINTRUST_FAILED_PUBLISH_PAYLOADS_DIR"
|
|
7049
7051
|
);
|
|
7050
7052
|
if (failedPublishPayloadsDirEnv) {
|
|
7051
7053
|
this.failedPublishPayloadsDir = failedPublishPayloadsDirEnv;
|
|
7052
7054
|
}
|
|
7053
|
-
const allPublishPayloadsDirEnv =
|
|
7055
|
+
const allPublishPayloadsDirEnv = _chunk4AQGZS6Xjs.isomorph_default.getEnv(
|
|
7054
7056
|
"BRAINTRUST_ALL_PUBLISH_PAYLOADS_DIR"
|
|
7055
7057
|
);
|
|
7056
7058
|
if (allPublishPayloadsDirEnv) {
|
|
7057
7059
|
this.allPublishPayloadsDir = allPublishPayloadsDirEnv;
|
|
7058
7060
|
}
|
|
7059
7061
|
if (!opts.noExitFlush) {
|
|
7060
|
-
|
|
7062
|
+
_chunk4AQGZS6Xjs.isomorph_default.processOn("beforeExit", async () => {
|
|
7061
7063
|
await this.flush();
|
|
7062
7064
|
});
|
|
7063
7065
|
}
|
|
@@ -7096,7 +7098,7 @@ var HTTPBackgroundLogger = (_class10 = class _HTTPBackgroundLogger {
|
|
|
7096
7098
|
const versionInfo = await conn.get_json("version");
|
|
7097
7099
|
serverLimit = _nullishCoalesce(_v3.z.object({ logs3_payload_max_bytes: _v3.z.number().nullish() }).parse(versionInfo).logs3_payload_max_bytes, () => ( null));
|
|
7098
7100
|
} catch (e) {
|
|
7099
|
-
|
|
7101
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
7100
7102
|
"Failed to fetch version info for payload limit:",
|
|
7101
7103
|
e
|
|
7102
7104
|
);
|
|
@@ -7243,16 +7245,16 @@ var HTTPBackgroundLogger = (_class10 = class _HTTPBackgroundLogger {
|
|
|
7243
7245
|
if (isRetrying) {
|
|
7244
7246
|
errmsg += ". Retrying";
|
|
7245
7247
|
}
|
|
7246
|
-
|
|
7248
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(errmsg);
|
|
7247
7249
|
if (!isRetrying) {
|
|
7248
|
-
|
|
7250
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
7249
7251
|
`Failed to construct log records to flush after ${this.numTries} attempts. Dropping batch`
|
|
7250
7252
|
);
|
|
7251
7253
|
throw e;
|
|
7252
7254
|
} else {
|
|
7253
|
-
|
|
7255
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(e);
|
|
7254
7256
|
const sleepTimeS = BACKGROUND_LOGGER_BASE_SLEEP_TIME_S * 2 ** i;
|
|
7255
|
-
|
|
7257
|
+
_chunk4AQGZS6Xjs.debugLogger.info(`Sleeping for ${sleepTimeS}s`);
|
|
7256
7258
|
await new Promise(
|
|
7257
7259
|
(resolve) => setTimeout(resolve, sleepTimeS * 1e3)
|
|
7258
7260
|
);
|
|
@@ -7353,15 +7355,15 @@ Error: ${errorText}`;
|
|
|
7353
7355
|
this.logFailedPayloadsDir();
|
|
7354
7356
|
}
|
|
7355
7357
|
if (!isRetrying) {
|
|
7356
|
-
|
|
7358
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
7357
7359
|
`log request failed after ${this.numTries} retries. Dropping batch`
|
|
7358
7360
|
);
|
|
7359
7361
|
throw new Error(errMsg);
|
|
7360
7362
|
} else {
|
|
7361
|
-
|
|
7363
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(errMsg);
|
|
7362
7364
|
if (isRetrying) {
|
|
7363
7365
|
const sleepTimeS = BACKGROUND_LOGGER_BASE_SLEEP_TIME_S * 2 ** i;
|
|
7364
|
-
|
|
7366
|
+
_chunk4AQGZS6Xjs.debugLogger.info(`Sleeping for ${sleepTimeS}s`);
|
|
7365
7367
|
await new Promise(
|
|
7366
7368
|
(resolve) => setTimeout(resolve, sleepTimeS * 1e3)
|
|
7367
7369
|
);
|
|
@@ -7376,7 +7378,7 @@ Error: ${errorText}`;
|
|
|
7376
7378
|
this.queueDropLoggingState.numDropped += numItems;
|
|
7377
7379
|
const timeNow = getCurrentUnixTimestamp();
|
|
7378
7380
|
if (timeNow - this.queueDropLoggingState.lastLoggedTimestamp > this.queueDropLoggingPeriod) {
|
|
7379
|
-
|
|
7381
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
7380
7382
|
`Dropped ${this.queueDropLoggingState.numDropped} elements due to full queue`
|
|
7381
7383
|
);
|
|
7382
7384
|
if (this.failedPublishPayloadsDir) {
|
|
@@ -7408,28 +7410,28 @@ Error: ${errorText}`;
|
|
|
7408
7410
|
await _HTTPBackgroundLogger.writePayloadToDir({ payloadDir, payload });
|
|
7409
7411
|
}
|
|
7410
7412
|
} catch (e) {
|
|
7411
|
-
|
|
7413
|
+
_chunk4AQGZS6Xjs.debugLogger.error(e);
|
|
7412
7414
|
}
|
|
7413
7415
|
}
|
|
7414
7416
|
static async writePayloadToDir({
|
|
7415
7417
|
payloadDir,
|
|
7416
7418
|
payload
|
|
7417
7419
|
}) {
|
|
7418
|
-
if (!(
|
|
7419
|
-
|
|
7420
|
+
if (!(_chunk4AQGZS6Xjs.isomorph_default.pathJoin && _chunk4AQGZS6Xjs.isomorph_default.mkdir && _chunk4AQGZS6Xjs.isomorph_default.writeFile)) {
|
|
7421
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
7420
7422
|
"Cannot dump payloads: filesystem-operations not supported on this platform"
|
|
7421
7423
|
);
|
|
7422
7424
|
return;
|
|
7423
7425
|
}
|
|
7424
|
-
const payloadFile =
|
|
7426
|
+
const payloadFile = _chunk4AQGZS6Xjs.isomorph_default.pathJoin(
|
|
7425
7427
|
payloadDir,
|
|
7426
7428
|
`payload_${getCurrentUnixTimestamp()}_${_uuid.v4.call(void 0, ).slice(0, 8)}.json`
|
|
7427
7429
|
);
|
|
7428
7430
|
try {
|
|
7429
|
-
await
|
|
7430
|
-
await
|
|
7431
|
+
await _chunk4AQGZS6Xjs.isomorph_default.mkdir(payloadDir, { recursive: true });
|
|
7432
|
+
await _chunk4AQGZS6Xjs.isomorph_default.writeFile(payloadFile, payload);
|
|
7431
7433
|
} catch (e) {
|
|
7432
|
-
|
|
7434
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
7433
7435
|
`Failed to write failed payload to output file ${payloadFile}:
|
|
7434
7436
|
`,
|
|
7435
7437
|
e
|
|
@@ -7460,7 +7462,7 @@ Error: ${errorText}`;
|
|
|
7460
7462
|
}
|
|
7461
7463
|
}
|
|
7462
7464
|
logFailedPayloadsDir() {
|
|
7463
|
-
|
|
7465
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
7464
7466
|
`Logging failed payloads to ${this.failedPublishPayloadsDir}`
|
|
7465
7467
|
);
|
|
7466
7468
|
}
|
|
@@ -7610,7 +7612,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
7610
7612
|
state.gitMetadataSettings,
|
|
7611
7613
|
_nullishCoalesce(gitMetadataSettings, () => ( { collect: "all" }))
|
|
7612
7614
|
);
|
|
7613
|
-
return await
|
|
7615
|
+
return await _chunk4AQGZS6Xjs.isomorph_default.getRepoInfo(mergedGitMetadataSettings);
|
|
7614
7616
|
})();
|
|
7615
7617
|
if (repoInfoArg) {
|
|
7616
7618
|
args["repo_info"] = repoInfoArg;
|
|
@@ -7620,7 +7622,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
7620
7622
|
} else if (baseExperiment) {
|
|
7621
7623
|
args["base_experiment"] = baseExperiment;
|
|
7622
7624
|
} else {
|
|
7623
|
-
args["ancestor_commits"] = await
|
|
7625
|
+
args["ancestor_commits"] = await _chunk4AQGZS6Xjs.isomorph_default.getPastNAncestors();
|
|
7624
7626
|
}
|
|
7625
7627
|
if (dataset !== void 0) {
|
|
7626
7628
|
const datasetSelection = await serializeDatasetForExperiment({
|
|
@@ -7669,7 +7671,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
7669
7671
|
break;
|
|
7670
7672
|
} catch (e) {
|
|
7671
7673
|
if (args["base_experiment"] && `${"data" in e && e.data}`.includes("base experiment")) {
|
|
7672
|
-
|
|
7674
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(state).warn(`Base experiment ${args["base_experiment"]} not found.`);
|
|
7673
7675
|
delete args["base_experiment"];
|
|
7674
7676
|
} else {
|
|
7675
7677
|
throw e;
|
|
@@ -7717,14 +7719,14 @@ function initExperiment(projectOrOptions, optionalOptions) {
|
|
|
7717
7719
|
return init(options);
|
|
7718
7720
|
}
|
|
7719
7721
|
function withExperiment(project, callback, options = {}) {
|
|
7720
|
-
|
|
7722
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(options.state).warn(
|
|
7721
7723
|
"withExperiment is deprecated and will be removed in a future version of braintrust. Simply create the experiment with `init`."
|
|
7722
7724
|
);
|
|
7723
7725
|
const experiment = init(project, options);
|
|
7724
7726
|
return callback(experiment);
|
|
7725
7727
|
}
|
|
7726
7728
|
function withLogger(callback, options = {}) {
|
|
7727
|
-
|
|
7729
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(options.state).warn(
|
|
7728
7730
|
"withLogger is deprecated and will be removed in a future version of braintrust. Simply create the logger with `initLogger`."
|
|
7729
7731
|
);
|
|
7730
7732
|
const logger = initLogger(options);
|
|
@@ -8020,7 +8022,7 @@ function initDataset(projectOrOptions, optionalOptions) {
|
|
|
8020
8022
|
return datasetObject;
|
|
8021
8023
|
}
|
|
8022
8024
|
function withDataset(project, callback, options = {}) {
|
|
8023
|
-
|
|
8025
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(options.state).warn(
|
|
8024
8026
|
"withDataset is deprecated and will be removed in a future version of braintrust. Simply create the dataset with `initDataset`."
|
|
8025
8027
|
);
|
|
8026
8028
|
const dataset = initDataset(project, options);
|
|
@@ -8092,7 +8094,7 @@ function initLogger(options = {}) {
|
|
|
8092
8094
|
const state = _nullishCoalesce(stateArg, () => ( _globalState));
|
|
8093
8095
|
state._internalSetTraceContextSigningSecret(apiKey);
|
|
8094
8096
|
state.setDebugLogLevel(debugLogLevel);
|
|
8095
|
-
state.spanOriginEnvironment =
|
|
8097
|
+
state.spanOriginEnvironment = _chunk4AQGZS6Xjs.detectSpanOriginEnvironment.call(void 0, environment);
|
|
8096
8098
|
state.enforceQueueSizeLimit(true);
|
|
8097
8099
|
const lazyMetadata = new LazyValue(
|
|
8098
8100
|
async () => {
|
|
@@ -8188,7 +8190,7 @@ async function loadPrompt({
|
|
|
8188
8190
|
if (version || environment) {
|
|
8189
8191
|
throw new Error(`Prompt not found with specified parameters: ${e}`);
|
|
8190
8192
|
}
|
|
8191
|
-
|
|
8193
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(state).warn("Failed to load prompt, attempting to fall back to cache:", e);
|
|
8192
8194
|
let prompt2;
|
|
8193
8195
|
if (id) {
|
|
8194
8196
|
prompt2 = await promptCache.get({ id });
|
|
@@ -8246,7 +8248,7 @@ async function loadPrompt({
|
|
|
8246
8248
|
);
|
|
8247
8249
|
}
|
|
8248
8250
|
} catch (e) {
|
|
8249
|
-
|
|
8251
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(state).warn("Failed to set prompt in cache:", e);
|
|
8250
8252
|
}
|
|
8251
8253
|
return prompt;
|
|
8252
8254
|
}
|
|
@@ -8305,7 +8307,7 @@ async function loadParameters({
|
|
|
8305
8307
|
if (version || environment) {
|
|
8306
8308
|
throw new Error(`Parameters not found with specified parameters: ${e}`);
|
|
8307
8309
|
}
|
|
8308
|
-
|
|
8310
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(state).warn("Failed to load parameters, attempting to fall back to cache:", e);
|
|
8309
8311
|
let parameters2;
|
|
8310
8312
|
if (id) {
|
|
8311
8313
|
parameters2 = await parametersCache.get({ id });
|
|
@@ -8363,7 +8365,7 @@ async function loadParameters({
|
|
|
8363
8365
|
);
|
|
8364
8366
|
}
|
|
8365
8367
|
} catch (e) {
|
|
8366
|
-
|
|
8368
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(state).warn("Failed to set parameters in cache:", e);
|
|
8367
8369
|
}
|
|
8368
8370
|
return parameters;
|
|
8369
8371
|
}
|
|
@@ -8428,7 +8430,7 @@ async function loginToLoaderRequestState({
|
|
|
8428
8430
|
);
|
|
8429
8431
|
const org = selectLoginOrg(info.org_info, orgName);
|
|
8430
8432
|
orgId = org.id;
|
|
8431
|
-
apiUrl = _nullishCoalesce(
|
|
8433
|
+
apiUrl = _nullishCoalesce(_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_API_URL"), () => ( org.api_url));
|
|
8432
8434
|
if (!apiUrl) {
|
|
8433
8435
|
throw new Error(
|
|
8434
8436
|
orgName ? `Unable to log into organization '${orgName}'. Are you sure this credential is scoped to the organization?` : "Unable to log into any organization with the provided credential."
|
|
@@ -8446,13 +8448,13 @@ async function loginToLoaderRequestState({
|
|
|
8446
8448
|
}
|
|
8447
8449
|
async function loginToState(options = {}) {
|
|
8448
8450
|
const {
|
|
8449
|
-
appUrl =
|
|
8451
|
+
appUrl = _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_APP_URL") || "https://www.braintrust.dev",
|
|
8450
8452
|
apiKey: apiKeyArg,
|
|
8451
|
-
orgName =
|
|
8453
|
+
orgName = _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_ORG_NAME"),
|
|
8452
8454
|
fetch: fetch2 = globalThis.fetch
|
|
8453
8455
|
} = options || {};
|
|
8454
|
-
const apiKey = apiKeyArg !== void 0 ? apiKeyArg : await
|
|
8455
|
-
const appPublicUrl =
|
|
8456
|
+
const apiKey = apiKeyArg !== void 0 ? apiKeyArg : await _chunk4AQGZS6Xjs.isomorph_default.getBraintrustApiKey();
|
|
8457
|
+
const appPublicUrl = _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_APP_PUBLIC_URL") || appUrl;
|
|
8456
8458
|
const state = new BraintrustState(options);
|
|
8457
8459
|
state.resetLoginInfo();
|
|
8458
8460
|
state.appUrl = appUrl;
|
|
@@ -8516,7 +8518,7 @@ async function loginToState(options = {}) {
|
|
|
8516
8518
|
return state;
|
|
8517
8519
|
}
|
|
8518
8520
|
function log(event) {
|
|
8519
|
-
|
|
8521
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
8520
8522
|
"braintrust.log is deprecated and will be removed in a future version of braintrust. Use `experiment.log` instead."
|
|
8521
8523
|
);
|
|
8522
8524
|
const e = currentExperiment();
|
|
@@ -8526,7 +8528,7 @@ function log(event) {
|
|
|
8526
8528
|
return e.log(event);
|
|
8527
8529
|
}
|
|
8528
8530
|
async function summarize(options = {}) {
|
|
8529
|
-
|
|
8531
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
8530
8532
|
"braintrust.summarize is deprecated and will be removed in a future version of braintrust. Use `experiment.summarize` instead."
|
|
8531
8533
|
);
|
|
8532
8534
|
const e = currentExperiment();
|
|
@@ -8748,7 +8750,7 @@ function injectTraceContext(carrier, options) {
|
|
|
8748
8750
|
try {
|
|
8749
8751
|
return span.inject(resolvedCarrier);
|
|
8750
8752
|
} catch (e) {
|
|
8751
|
-
|
|
8753
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(`Error injecting trace context: ${e}`);
|
|
8752
8754
|
return resolvedCarrier;
|
|
8753
8755
|
}
|
|
8754
8756
|
}
|
|
@@ -8787,14 +8789,14 @@ function resolveW3cParent(context, state) {
|
|
|
8787
8789
|
braintrustParent = currentBraintrustParent(state);
|
|
8788
8790
|
}
|
|
8789
8791
|
if (!braintrustParent) {
|
|
8790
|
-
|
|
8792
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
8791
8793
|
"Received traceparent without a braintrust.parent and no active logger/experiment; cannot route the trace. Starting a fresh local span instead."
|
|
8792
8794
|
);
|
|
8793
8795
|
return { parentSlug: void 0, propagatedState: void 0 };
|
|
8794
8796
|
}
|
|
8795
8797
|
const parsedParent = braintrustParentToComponents(braintrustParent);
|
|
8796
8798
|
if (parsedParent === void 0) {
|
|
8797
|
-
|
|
8799
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
8798
8800
|
`Invalid braintrust.parent: ${JSON.stringify(braintrustParent)}`
|
|
8799
8801
|
);
|
|
8800
8802
|
return { parentSlug: void 0, propagatedState: void 0 };
|
|
@@ -8881,7 +8883,7 @@ function wrapTracedSyncGenerator(fn, spanArgs, noTraceIO) {
|
|
|
8881
8883
|
if (!noTraceIO) {
|
|
8882
8884
|
span.log({ input: fnArgs });
|
|
8883
8885
|
}
|
|
8884
|
-
const envValue =
|
|
8886
|
+
const envValue = _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_MAX_GENERATOR_ITEMS");
|
|
8885
8887
|
const maxItems = envValue !== void 0 ? Number(envValue) : 1e3;
|
|
8886
8888
|
if (!noTraceIO && maxItems !== 0) {
|
|
8887
8889
|
let collected = [];
|
|
@@ -8894,7 +8896,7 @@ function wrapTracedSyncGenerator(fn, spanArgs, noTraceIO) {
|
|
|
8894
8896
|
} else {
|
|
8895
8897
|
truncated = true;
|
|
8896
8898
|
collected = [];
|
|
8897
|
-
|
|
8899
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
8898
8900
|
`Generator output exceeded limit of ${maxItems} items, output not logged. Increase BRAINTRUST_MAX_GENERATOR_ITEMS or set to -1 to disable limit.`
|
|
8899
8901
|
);
|
|
8900
8902
|
}
|
|
@@ -8930,7 +8932,7 @@ function wrapTracedAsyncGenerator(fn, spanArgs, noTraceIO) {
|
|
|
8930
8932
|
if (!noTraceIO) {
|
|
8931
8933
|
span.log({ input: fnArgs });
|
|
8932
8934
|
}
|
|
8933
|
-
const envValue =
|
|
8935
|
+
const envValue = _chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_MAX_GENERATOR_ITEMS");
|
|
8934
8936
|
const maxItems = envValue !== void 0 ? Number(envValue) : 1e3;
|
|
8935
8937
|
if (!noTraceIO && maxItems !== 0) {
|
|
8936
8938
|
let collected = [];
|
|
@@ -8943,7 +8945,7 @@ function wrapTracedAsyncGenerator(fn, spanArgs, noTraceIO) {
|
|
|
8943
8945
|
} else {
|
|
8944
8946
|
truncated = true;
|
|
8945
8947
|
collected = [];
|
|
8946
|
-
|
|
8948
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
8947
8949
|
`Generator output exceeded limit of ${maxItems} items, output not logged. Increase BRAINTRUST_MAX_GENERATOR_ITEMS or set to -1 to disable limit.`
|
|
8948
8950
|
);
|
|
8949
8951
|
}
|
|
@@ -9152,8 +9154,8 @@ function _saveOrgInfo(state, orgInfo, orgName) {
|
|
|
9152
9154
|
const org = selectLoginOrg(orgInfo, orgName);
|
|
9153
9155
|
state.orgId = org.id;
|
|
9154
9156
|
state.orgName = org.name;
|
|
9155
|
-
state.apiUrl = _nullishCoalesce(
|
|
9156
|
-
state.proxyUrl = _nullishCoalesce(
|
|
9157
|
+
state.apiUrl = _nullishCoalesce(_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_API_URL"), () => ( org.api_url));
|
|
9158
|
+
state.proxyUrl = _nullishCoalesce(_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_PROXY_URL"), () => ( org.proxy_url));
|
|
9157
9159
|
state.gitMetadataSettings = org.git_metadata || void 0;
|
|
9158
9160
|
}
|
|
9159
9161
|
function selectLoginOrg(orgInfo, orgName) {
|
|
@@ -9734,7 +9736,7 @@ var Experiment2 = (_class12 = class extends ObjectFetcher {
|
|
|
9734
9736
|
scores = results["scores"];
|
|
9735
9737
|
metrics = results["metrics"];
|
|
9736
9738
|
} catch (e) {
|
|
9737
|
-
|
|
9739
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(state).warn(
|
|
9738
9740
|
`Failed to fetch experiment scores and metrics: ${e}
|
|
9739
9741
|
|
|
9740
9742
|
View complete results in Braintrust or run experiment.summarize() again.`
|
|
@@ -9820,7 +9822,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
9820
9822
|
* @deprecated This function is deprecated. You can simply remove it from your code.
|
|
9821
9823
|
*/
|
|
9822
9824
|
async close() {
|
|
9823
|
-
|
|
9825
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(this.state).warn(
|
|
9824
9826
|
"close is deprecated and will be removed in a future version of braintrust. It is now a no-op and can be removed"
|
|
9825
9827
|
);
|
|
9826
9828
|
return this.id;
|
|
@@ -9927,7 +9929,7 @@ var SpanImpl = (_class13 = class _SpanImpl {
|
|
|
9927
9929
|
constructor(args) {;_class13.prototype.__init58.call(this);
|
|
9928
9930
|
this._state = args.state;
|
|
9929
9931
|
this._propagatedState = args.propagatedState;
|
|
9930
|
-
const instrumentationName = _nullishCoalesce(
|
|
9932
|
+
const instrumentationName = _nullishCoalesce(_chunk4AQGZS6Xjs.getSpanInstrumentationName.call(void 0, args), () => ( _chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.BRAINTRUST_JS_LOGGER));
|
|
9931
9933
|
const spanAttributes = _nullishCoalesce(args.spanAttributes, () => ( {}));
|
|
9932
9934
|
const rawEvent = _nullishCoalesce(args.event, () => ( {}));
|
|
9933
9935
|
const type = _nullishCoalesce(args.type, () => ( (args.parentSpanIds ? void 0 : args.defaultRootType)));
|
|
@@ -9940,7 +9942,7 @@ var SpanImpl = (_class13 = class _SpanImpl {
|
|
|
9940
9942
|
mergeDicts(rawEvent, this.propagatedEvent);
|
|
9941
9943
|
}
|
|
9942
9944
|
const { id: eventId, ...event } = rawEvent;
|
|
9943
|
-
const callerLocation =
|
|
9945
|
+
const callerLocation = _chunk4AQGZS6Xjs.isomorph_default.getCallerLocation();
|
|
9944
9946
|
const name = (() => {
|
|
9945
9947
|
if (args.name) return args.name;
|
|
9946
9948
|
if (!args.parentSpanIds) return "root";
|
|
@@ -9957,7 +9959,7 @@ var SpanImpl = (_class13 = class _SpanImpl {
|
|
|
9957
9959
|
metrics: {
|
|
9958
9960
|
start: _nullishCoalesce(args.startTime, () => ( getCurrentUnixTimestamp()))
|
|
9959
9961
|
},
|
|
9960
|
-
context:
|
|
9962
|
+
context: _chunk4AQGZS6Xjs.mergeSpanOriginContext.call(void 0,
|
|
9961
9963
|
{ ...callerLocation, ...args[INTERNAL_SPAN_CONTEXT] },
|
|
9962
9964
|
instrumentationName,
|
|
9963
9965
|
this._state.spanOriginEnvironment
|
|
@@ -10192,7 +10194,7 @@ var SpanImpl = (_class13 = class _SpanImpl {
|
|
|
10192
10194
|
propagatedState: this._propagatedState
|
|
10193
10195
|
});
|
|
10194
10196
|
} catch (e) {
|
|
10195
|
-
|
|
10197
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(`Error injecting trace context: ${e}`);
|
|
10196
10198
|
}
|
|
10197
10199
|
return resolvedCarrier;
|
|
10198
10200
|
}
|
|
@@ -10314,7 +10316,7 @@ var Dataset2 = (_class14 = class extends ObjectFetcher {
|
|
|
10314
10316
|
constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql, pinState) {
|
|
10315
10317
|
const isLegacyDataset = _nullishCoalesce(legacy, () => ( DEFAULT_IS_LEGACY_DATASET));
|
|
10316
10318
|
if (isLegacyDataset) {
|
|
10317
|
-
|
|
10319
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(state).warn(
|
|
10318
10320
|
`Records will be fetched from this dataset in the legacy format, with the "expected" field renamed to "output". Please update your code to use "expected", and use \`braintrust.initDataset()\` with \`{ useOutput: false }\`, which will become the default in a future version of Braintrust.`
|
|
10319
10321
|
);
|
|
10320
10322
|
}
|
|
@@ -10670,7 +10672,7 @@ var Dataset2 = (_class14 = class extends ObjectFetcher {
|
|
|
10670
10672
|
* @deprecated This function is deprecated. You can simply remove it from your code.
|
|
10671
10673
|
*/
|
|
10672
10674
|
async close() {
|
|
10673
|
-
|
|
10675
|
+
_chunk4AQGZS6Xjs.debugLogger.forState(this.state).warn(
|
|
10674
10676
|
"close is deprecated and will be removed in a future version of braintrust. It is now a no-op and can be removed"
|
|
10675
10677
|
);
|
|
10676
10678
|
return this.id;
|
|
@@ -11232,7 +11234,7 @@ var _exportsForTestingOnly = {
|
|
|
11232
11234
|
deepCopyEvent,
|
|
11233
11235
|
useTestBackgroundLogger,
|
|
11234
11236
|
clearTestBackgroundLogger,
|
|
11235
|
-
resetDebugLoggerForTests:
|
|
11237
|
+
resetDebugLoggerForTests: _chunk4AQGZS6Xjs.resetDebugLoggerForTests,
|
|
11236
11238
|
simulateLoginForTests,
|
|
11237
11239
|
simulateLogoutForTests,
|
|
11238
11240
|
setInitialTestState,
|
|
@@ -11242,7 +11244,7 @@ var _exportsForTestingOnly = {
|
|
|
11242
11244
|
resetIdGenStateForTests,
|
|
11243
11245
|
validateTags,
|
|
11244
11246
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11245
|
-
isomorph:
|
|
11247
|
+
isomorph: _chunk4AQGZS6Xjs.isomorph_default
|
|
11246
11248
|
// Expose isomorph for build type detection
|
|
11247
11249
|
};
|
|
11248
11250
|
|
|
@@ -11315,7 +11317,7 @@ function collectAnthropicSession(stream) {
|
|
|
11315
11317
|
try {
|
|
11316
11318
|
collector();
|
|
11317
11319
|
} catch (error) {
|
|
11318
|
-
|
|
11320
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Failed to collect Anthropic Sessions stream:", error);
|
|
11319
11321
|
}
|
|
11320
11322
|
return stream;
|
|
11321
11323
|
}
|
|
@@ -11350,7 +11352,7 @@ function patchStreamIfNeeded(stream, options) {
|
|
|
11350
11352
|
try {
|
|
11351
11353
|
await (_nullishCoalesce(options.onCancel, () => ( options.onComplete)))(chunks);
|
|
11352
11354
|
} catch (error) {
|
|
11353
|
-
|
|
11355
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Error in stream cancellation handler:", error);
|
|
11354
11356
|
}
|
|
11355
11357
|
};
|
|
11356
11358
|
const patchAbortIfPresent = () => {
|
|
@@ -11369,7 +11371,7 @@ function patchStreamIfNeeded(stream, options) {
|
|
|
11369
11371
|
};
|
|
11370
11372
|
}
|
|
11371
11373
|
} catch (error) {
|
|
11372
|
-
|
|
11374
|
+
_chunk4AQGZS6Xjs.debugLogger.warn("Failed to patch stream abort method:", error);
|
|
11373
11375
|
}
|
|
11374
11376
|
};
|
|
11375
11377
|
if (hasAsyncIteratorMethods(stream) && isSelfAsyncIterator(stream)) {
|
|
@@ -11598,7 +11600,7 @@ function resolveConfigName(name, event) {
|
|
|
11598
11600
|
const resolved = name(_nullishCoalesce(event.arguments, () => ( [])), event);
|
|
11599
11601
|
return resolved || "unknown";
|
|
11600
11602
|
} catch (error) {
|
|
11601
|
-
|
|
11603
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Error resolving instrumentation span name:", error);
|
|
11602
11604
|
return "unknown";
|
|
11603
11605
|
}
|
|
11604
11606
|
}
|
|
@@ -11648,7 +11650,7 @@ var BasePlugin = (_class17 = class {constructor() { _class17.prototype.__init64.
|
|
|
11648
11650
|
* @param handlers - Event handlers
|
|
11649
11651
|
*/
|
|
11650
11652
|
subscribe(channelName, handlers) {
|
|
11651
|
-
const channel =
|
|
11653
|
+
const channel = _chunk4AQGZS6Xjs.isomorph_default.newTracingChannel(channelName);
|
|
11652
11654
|
channel.subscribe(handlers);
|
|
11653
11655
|
}
|
|
11654
11656
|
/**
|
|
@@ -11656,7 +11658,7 @@ var BasePlugin = (_class17 = class {constructor() { _class17.prototype.__init64.
|
|
|
11656
11658
|
* Creates a span and logs input/output/metrics.
|
|
11657
11659
|
*/
|
|
11658
11660
|
subscribeToChannel(channelName, config) {
|
|
11659
|
-
const channel =
|
|
11661
|
+
const channel = _chunk4AQGZS6Xjs.isomorph_default.newTracingChannel(channelName);
|
|
11660
11662
|
const spans = /* @__PURE__ */ new WeakMap();
|
|
11661
11663
|
const handlers = {
|
|
11662
11664
|
start: (event) => {
|
|
@@ -11725,7 +11727,7 @@ var BasePlugin = (_class17 = class {constructor() { _class17.prototype.__init64.
|
|
|
11725
11727
|
* Handles both streaming and non-streaming responses.
|
|
11726
11728
|
*/
|
|
11727
11729
|
subscribeToStreamingChannel(channelName, config) {
|
|
11728
|
-
const channel =
|
|
11730
|
+
const channel = _chunk4AQGZS6Xjs.isomorph_default.newTracingChannel(channelName);
|
|
11729
11731
|
const spans = /* @__PURE__ */ new WeakMap();
|
|
11730
11732
|
const handlers = {
|
|
11731
11733
|
start: (event) => {
|
|
@@ -11852,7 +11854,7 @@ var BasePlugin = (_class17 = class {constructor() { _class17.prototype.__init64.
|
|
|
11852
11854
|
* Used for methods like beta.chat.completions.stream() and responses.stream().
|
|
11853
11855
|
*/
|
|
11854
11856
|
subscribeToSyncStreamChannel(channelName, config) {
|
|
11855
|
-
const channel =
|
|
11857
|
+
const channel = _chunk4AQGZS6Xjs.isomorph_default.newTracingChannel(channelName);
|
|
11856
11858
|
const spans = /* @__PURE__ */ new WeakMap();
|
|
11857
11859
|
const handlers = {
|
|
11858
11860
|
start: (event) => {
|
|
@@ -11984,7 +11986,7 @@ function toLoggedError(error) {
|
|
|
11984
11986
|
// src/instrumentation/auto-instrumentation-suppression.ts
|
|
11985
11987
|
var autoInstrumentationSuppressionStore;
|
|
11986
11988
|
function suppressionStore() {
|
|
11987
|
-
autoInstrumentationSuppressionStore ??=
|
|
11989
|
+
autoInstrumentationSuppressionStore ??= _chunk4AQGZS6Xjs.isomorph_default.newAsyncLocalStorage();
|
|
11988
11990
|
return autoInstrumentationSuppressionStore;
|
|
11989
11991
|
}
|
|
11990
11992
|
function isAutoInstrumentationSuppressed() {
|
|
@@ -12012,7 +12014,7 @@ function startSpanForEvent(config, event, channelName, instrumentationName) {
|
|
|
12012
12014
|
config,
|
|
12013
12015
|
event
|
|
12014
12016
|
);
|
|
12015
|
-
const spanArgs =
|
|
12017
|
+
const spanArgs = _chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
12016
12018
|
{
|
|
12017
12019
|
name,
|
|
12018
12020
|
spanAttributes
|
|
@@ -12023,7 +12025,7 @@ function startSpanForEvent(config, event, channelName, instrumentationName) {
|
|
|
12023
12025
|
try {
|
|
12024
12026
|
span = _nullishCoalesce(_optionalChain([config, 'access', _176 => _176.startSpan, 'optionalCall', _177 => _177(spanArgs)]), () => ( startSpan(spanArgs)));
|
|
12025
12027
|
} catch (error) {
|
|
12026
|
-
|
|
12028
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error starting span for ${channelName}:`, error);
|
|
12027
12029
|
span = startSpan(spanArgs);
|
|
12028
12030
|
}
|
|
12029
12031
|
const startTime = getCurrentUnixTimestamp();
|
|
@@ -12038,7 +12040,7 @@ function startSpanForEvent(config, event, channelName, instrumentationName) {
|
|
|
12038
12040
|
metadata: mergeInputMetadata(metadata, spanInfoMetadata)
|
|
12039
12041
|
});
|
|
12040
12042
|
} catch (error) {
|
|
12041
|
-
|
|
12043
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error extracting input for ${channelName}:`, error);
|
|
12042
12044
|
}
|
|
12043
12045
|
return { span, startTime };
|
|
12044
12046
|
}
|
|
@@ -12049,7 +12051,7 @@ function shouldTraceEvent(config, event, channelName) {
|
|
|
12049
12051
|
try {
|
|
12050
12052
|
return config.shouldTrace(event.arguments, event);
|
|
12051
12053
|
} catch (error) {
|
|
12052
|
-
|
|
12054
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
12053
12055
|
`Error checking trace predicate for ${channelName}:`,
|
|
12054
12056
|
error
|
|
12055
12057
|
);
|
|
@@ -12110,12 +12112,12 @@ function logErrorAndEnd(states, event, channelName) {
|
|
|
12110
12112
|
try {
|
|
12111
12113
|
spanData.span.log({ error: event.error });
|
|
12112
12114
|
} catch (error) {
|
|
12113
|
-
|
|
12115
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error logging failure for ${channelName}:`, error);
|
|
12114
12116
|
}
|
|
12115
12117
|
try {
|
|
12116
12118
|
spanData.span.end();
|
|
12117
12119
|
} catch (error) {
|
|
12118
|
-
|
|
12120
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error ending span for ${channelName}:`, error);
|
|
12119
12121
|
}
|
|
12120
12122
|
states.delete(event);
|
|
12121
12123
|
}
|
|
@@ -12136,7 +12138,7 @@ function runStreamingCompletionHook(args) {
|
|
|
12136
12138
|
startTime: args.startTime
|
|
12137
12139
|
});
|
|
12138
12140
|
} catch (error) {
|
|
12139
|
-
|
|
12141
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
12140
12142
|
`Error in onComplete hook for ${args.channelName}:`,
|
|
12141
12143
|
error
|
|
12142
12144
|
);
|
|
@@ -12155,7 +12157,7 @@ function runStreamingErrorHook(args) {
|
|
|
12155
12157
|
startTime: args.startTime
|
|
12156
12158
|
});
|
|
12157
12159
|
} catch (error) {
|
|
12158
|
-
|
|
12160
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error in onError hook for ${args.channelName}:`, error);
|
|
12159
12161
|
}
|
|
12160
12162
|
}
|
|
12161
12163
|
function traceAsyncChannel(channel, config) {
|
|
@@ -12209,7 +12211,7 @@ function traceAsyncChannel(channel, config) {
|
|
|
12209
12211
|
metrics
|
|
12210
12212
|
});
|
|
12211
12213
|
} catch (error) {
|
|
12212
|
-
|
|
12214
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error extracting output for ${channelName}:`, error);
|
|
12213
12215
|
} finally {
|
|
12214
12216
|
span.end();
|
|
12215
12217
|
states.delete(event);
|
|
@@ -12262,7 +12264,7 @@ function traceStreamingChannel(channel, config) {
|
|
|
12262
12264
|
try {
|
|
12263
12265
|
span.log({ error });
|
|
12264
12266
|
} catch (loggingError) {
|
|
12265
|
-
|
|
12267
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
12266
12268
|
`Error logging failure for ${channelName}:`,
|
|
12267
12269
|
loggingError
|
|
12268
12270
|
);
|
|
@@ -12270,7 +12272,7 @@ function traceStreamingChannel(channel, config) {
|
|
|
12270
12272
|
try {
|
|
12271
12273
|
span.end();
|
|
12272
12274
|
} catch (endingError) {
|
|
12273
|
-
|
|
12275
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
12274
12276
|
`Error ending span for ${channelName}:`,
|
|
12275
12277
|
endingError
|
|
12276
12278
|
);
|
|
@@ -12334,7 +12336,7 @@ function traceStreamingChannel(channel, config) {
|
|
|
12334
12336
|
metrics
|
|
12335
12337
|
});
|
|
12336
12338
|
} catch (error) {
|
|
12337
|
-
|
|
12339
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
12338
12340
|
`Error extracting output for ${channelName}:`,
|
|
12339
12341
|
error
|
|
12340
12342
|
);
|
|
@@ -12342,7 +12344,7 @@ function traceStreamingChannel(channel, config) {
|
|
|
12342
12344
|
try {
|
|
12343
12345
|
span.end();
|
|
12344
12346
|
} catch (error) {
|
|
12345
|
-
|
|
12347
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
12346
12348
|
`Error ending span for ${channelName}:`,
|
|
12347
12349
|
error
|
|
12348
12350
|
);
|
|
@@ -12409,12 +12411,12 @@ function traceStreamingChannel(channel, config) {
|
|
|
12409
12411
|
metrics
|
|
12410
12412
|
});
|
|
12411
12413
|
} catch (error) {
|
|
12412
|
-
|
|
12414
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error extracting output for ${channelName}:`, error);
|
|
12413
12415
|
} finally {
|
|
12414
12416
|
try {
|
|
12415
12417
|
span.end();
|
|
12416
12418
|
} catch (error) {
|
|
12417
|
-
|
|
12419
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error ending span for ${channelName}:`, error);
|
|
12418
12420
|
}
|
|
12419
12421
|
states.delete(event);
|
|
12420
12422
|
}
|
|
@@ -12523,7 +12525,7 @@ function traceSyncStreamChannel(channel, config) {
|
|
|
12523
12525
|
});
|
|
12524
12526
|
}
|
|
12525
12527
|
} catch (error) {
|
|
12526
|
-
|
|
12528
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
12527
12529
|
`Error extracting chatCompletion for ${channelName}:`,
|
|
12528
12530
|
error
|
|
12529
12531
|
);
|
|
@@ -12547,7 +12549,7 @@ function traceSyncStreamChannel(channel, config) {
|
|
|
12547
12549
|
span.log(extracted);
|
|
12548
12550
|
}
|
|
12549
12551
|
} catch (error) {
|
|
12550
|
-
|
|
12552
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
12551
12553
|
`Error extracting event for ${channelName}:`,
|
|
12552
12554
|
error
|
|
12553
12555
|
);
|
|
@@ -12879,7 +12881,7 @@ function serializedTurnContext(value) {
|
|
|
12879
12881
|
parent: context.parent,
|
|
12880
12882
|
sessionId: context.sessionId
|
|
12881
12883
|
});
|
|
12882
|
-
if (!expectedSignature || !_optionalChain([
|
|
12884
|
+
if (!expectedSignature || !_optionalChain([_chunk4AQGZS6Xjs.isomorph_default, 'access', _191 => _191.timingSafeEqual, 'optionalCall', _192 => _192(context.signature, expectedSignature)])) {
|
|
12883
12885
|
return void 0;
|
|
12884
12886
|
}
|
|
12885
12887
|
const parent = SpanComponentsV4.fromStr(context.parent);
|
|
@@ -12893,7 +12895,7 @@ function serializedTurnContext(value) {
|
|
|
12893
12895
|
}
|
|
12894
12896
|
function signTurnContext(context) {
|
|
12895
12897
|
const secret = _internalGetGlobalState()._internalGetTraceContextSigningSecret();
|
|
12896
|
-
return secret ? _optionalChain([
|
|
12898
|
+
return secret ? _optionalChain([_chunk4AQGZS6Xjs.isomorph_default, 'access', _193 => _193.hmacSha256, 'optionalCall', _194 => _194(
|
|
12897
12899
|
secret,
|
|
12898
12900
|
JSON.stringify([BRAINTRUST_TURN_CONTEXT_KEY, context])
|
|
12899
12901
|
)]) : void 0;
|
|
@@ -13069,7 +13071,7 @@ function bindHarnessTurnParentToStart(tracingChannel, parentFromEvent) {
|
|
|
13069
13071
|
return () => {
|
|
13070
13072
|
};
|
|
13071
13073
|
}
|
|
13072
|
-
harnessTurnParentStore ??=
|
|
13074
|
+
harnessTurnParentStore ??= _chunk4AQGZS6Xjs.isomorph_default.newAsyncLocalStorage();
|
|
13073
13075
|
const store = harnessTurnParentStore;
|
|
13074
13076
|
startChannel.bindStore(
|
|
13075
13077
|
store,
|
|
@@ -13080,9 +13082,9 @@ function bindHarnessTurnParentToStart(tracingChannel, parentFromEvent) {
|
|
|
13080
13082
|
};
|
|
13081
13083
|
}
|
|
13082
13084
|
function startHarnessTurnChildSpan(parent, args) {
|
|
13083
|
-
const spanArgs =
|
|
13085
|
+
const spanArgs = _chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
13084
13086
|
args,
|
|
13085
|
-
|
|
13087
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
13086
13088
|
);
|
|
13087
13089
|
return typeof parent === "string" ? startSpan({ ...spanArgs, parent }) : parent.startSpan(spanArgs);
|
|
13088
13090
|
}
|
|
@@ -13251,16 +13253,16 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13251
13253
|
this.unsubscribers.push(subscribeToHarnessAgentCreateSession());
|
|
13252
13254
|
this.unsubscribers.push(
|
|
13253
13255
|
subscribeToHarnessContinuation(
|
|
13254
|
-
|
|
13256
|
+
_chunk4AQGZS6Xjs.harnessAgentChannels.continueGenerate,
|
|
13255
13257
|
denyOutputPaths
|
|
13256
13258
|
),
|
|
13257
13259
|
subscribeToHarnessContinuation(
|
|
13258
|
-
|
|
13260
|
+
_chunk4AQGZS6Xjs.harnessAgentChannels.continueStream,
|
|
13259
13261
|
denyOutputPaths
|
|
13260
13262
|
)
|
|
13261
13263
|
);
|
|
13262
13264
|
this.unsubscribers.push(
|
|
13263
|
-
traceStreamingChannel(
|
|
13265
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.generateText, {
|
|
13264
13266
|
name: "generateText",
|
|
13265
13267
|
type: "function" /* FUNCTION */,
|
|
13266
13268
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13276,7 +13278,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13276
13278
|
})
|
|
13277
13279
|
);
|
|
13278
13280
|
this.unsubscribers.push(
|
|
13279
|
-
traceAsyncChannel(
|
|
13281
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.aiSDKChannels.generateImage, {
|
|
13280
13282
|
name: "generateImage",
|
|
13281
13283
|
type: "llm" /* LLM */,
|
|
13282
13284
|
extractInput: ([params], event) => prepareAISDKGenerateImageInput(params, event.self),
|
|
@@ -13288,7 +13290,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13288
13290
|
})
|
|
13289
13291
|
);
|
|
13290
13292
|
this.unsubscribers.push(
|
|
13291
|
-
traceStreamingChannel(
|
|
13293
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.streamText, {
|
|
13292
13294
|
name: "streamText",
|
|
13293
13295
|
type: "function" /* FUNCTION */,
|
|
13294
13296
|
shouldTrace: () => currentCloudflareThinkSpan() === void 0,
|
|
@@ -13309,7 +13311,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13309
13311
|
})
|
|
13310
13312
|
);
|
|
13311
13313
|
this.unsubscribers.push(
|
|
13312
|
-
traceSyncStreamChannel(
|
|
13314
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.aiSDKChannels.streamTextSync, {
|
|
13313
13315
|
name: "streamText",
|
|
13314
13316
|
type: "function" /* FUNCTION */,
|
|
13315
13317
|
shouldTrace: () => currentCloudflareThinkSpan() === void 0,
|
|
@@ -13324,7 +13326,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13324
13326
|
})
|
|
13325
13327
|
);
|
|
13326
13328
|
this.unsubscribers.push(
|
|
13327
|
-
traceStreamingChannel(
|
|
13329
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.generateObject, {
|
|
13328
13330
|
name: "generateObject",
|
|
13329
13331
|
type: "function" /* FUNCTION */,
|
|
13330
13332
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13340,7 +13342,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13340
13342
|
})
|
|
13341
13343
|
);
|
|
13342
13344
|
this.unsubscribers.push(
|
|
13343
|
-
traceStreamingChannel(
|
|
13345
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.streamObject, {
|
|
13344
13346
|
name: "streamObject",
|
|
13345
13347
|
type: "function" /* FUNCTION */,
|
|
13346
13348
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13360,7 +13362,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13360
13362
|
})
|
|
13361
13363
|
);
|
|
13362
13364
|
this.unsubscribers.push(
|
|
13363
|
-
traceSyncStreamChannel(
|
|
13365
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.aiSDKChannels.streamObjectSync, {
|
|
13364
13366
|
name: "streamObject",
|
|
13365
13367
|
type: "function" /* FUNCTION */,
|
|
13366
13368
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths),
|
|
@@ -13374,7 +13376,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13374
13376
|
})
|
|
13375
13377
|
);
|
|
13376
13378
|
this.unsubscribers.push(
|
|
13377
|
-
traceAsyncChannel(
|
|
13379
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.aiSDKChannels.embed, {
|
|
13378
13380
|
name: "embed",
|
|
13379
13381
|
type: "function" /* FUNCTION */,
|
|
13380
13382
|
extractInput: ([params], event) => prepareAISDKEmbedInput(params, event.self),
|
|
@@ -13386,7 +13388,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13386
13388
|
})
|
|
13387
13389
|
);
|
|
13388
13390
|
this.unsubscribers.push(
|
|
13389
|
-
traceAsyncChannel(
|
|
13391
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.aiSDKChannels.embedMany, {
|
|
13390
13392
|
name: "embedMany",
|
|
13391
13393
|
type: "function" /* FUNCTION */,
|
|
13392
13394
|
extractInput: ([params], event) => prepareAISDKEmbedInput(params, event.self),
|
|
@@ -13398,7 +13400,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13398
13400
|
})
|
|
13399
13401
|
);
|
|
13400
13402
|
this.unsubscribers.push(
|
|
13401
|
-
traceAsyncChannel(
|
|
13403
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.aiSDKChannels.rerank, {
|
|
13402
13404
|
name: "rerank",
|
|
13403
13405
|
type: "function" /* FUNCTION */,
|
|
13404
13406
|
extractInput: ([params], event) => prepareAISDKRerankInput(params, event.self),
|
|
@@ -13410,7 +13412,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13410
13412
|
})
|
|
13411
13413
|
);
|
|
13412
13414
|
this.unsubscribers.push(
|
|
13413
|
-
traceStreamingChannel(
|
|
13415
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.agentGenerate, {
|
|
13414
13416
|
name: "Agent.generate",
|
|
13415
13417
|
type: "function" /* FUNCTION */,
|
|
13416
13418
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths, {
|
|
@@ -13428,7 +13430,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13428
13430
|
})
|
|
13429
13431
|
);
|
|
13430
13432
|
this.unsubscribers.push(
|
|
13431
|
-
traceStreamingChannel(
|
|
13433
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.agentStream, {
|
|
13432
13434
|
name: "Agent.stream",
|
|
13433
13435
|
type: "function" /* FUNCTION */,
|
|
13434
13436
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths, {
|
|
@@ -13450,7 +13452,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13450
13452
|
})
|
|
13451
13453
|
);
|
|
13452
13454
|
this.unsubscribers.push(
|
|
13453
|
-
traceSyncStreamChannel(
|
|
13455
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.aiSDKChannels.agentStreamSync, {
|
|
13454
13456
|
name: "Agent.stream",
|
|
13455
13457
|
type: "function" /* FUNCTION */,
|
|
13456
13458
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths, {
|
|
@@ -13466,7 +13468,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13466
13468
|
})
|
|
13467
13469
|
);
|
|
13468
13470
|
this.unsubscribers.push(
|
|
13469
|
-
traceStreamingChannel(
|
|
13471
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.harnessAgentChannels.generate, {
|
|
13470
13472
|
name: "HarnessAgent.generate",
|
|
13471
13473
|
startSpan: _internalStartSpanWithInitialMerge,
|
|
13472
13474
|
type: "task" /* TASK */,
|
|
@@ -13480,7 +13482,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13480
13482
|
})
|
|
13481
13483
|
);
|
|
13482
13484
|
this.unsubscribers.push(
|
|
13483
|
-
traceStreamingChannel(
|
|
13485
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.harnessAgentChannels.stream, {
|
|
13484
13486
|
name: "HarnessAgent.stream",
|
|
13485
13487
|
startSpan: _internalStartSpanWithInitialMerge,
|
|
13486
13488
|
type: "task" /* TASK */,
|
|
@@ -13507,7 +13509,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13507
13509
|
})
|
|
13508
13510
|
);
|
|
13509
13511
|
this.unsubscribers.push(
|
|
13510
|
-
traceStreamingChannel(
|
|
13512
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.harnessAgentChannels.continueGenerate, {
|
|
13511
13513
|
name: "HarnessAgent.continueGenerate",
|
|
13512
13514
|
shouldTrace: (args) => !harnessContinuationParent(harnessSessionFromArguments(args)),
|
|
13513
13515
|
startSpan: _internalStartSpanWithInitialMerge,
|
|
@@ -13522,7 +13524,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13522
13524
|
})
|
|
13523
13525
|
);
|
|
13524
13526
|
this.unsubscribers.push(
|
|
13525
|
-
traceStreamingChannel(
|
|
13527
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.harnessAgentChannels.continueStream, {
|
|
13526
13528
|
name: "HarnessAgent.continueStream",
|
|
13527
13529
|
shouldTrace: (args) => !harnessContinuationParent(harnessSessionFromArguments(args)),
|
|
13528
13530
|
startSpan: _internalStartSpanWithInitialMerge,
|
|
@@ -13550,7 +13552,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13550
13552
|
})
|
|
13551
13553
|
);
|
|
13552
13554
|
this.unsubscribers.push(
|
|
13553
|
-
traceStreamingChannel(
|
|
13555
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.toolLoopAgentGenerate, {
|
|
13554
13556
|
name: "ToolLoopAgent.generate",
|
|
13555
13557
|
type: "function" /* FUNCTION */,
|
|
13556
13558
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths, {
|
|
@@ -13568,7 +13570,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13568
13570
|
})
|
|
13569
13571
|
);
|
|
13570
13572
|
this.unsubscribers.push(
|
|
13571
|
-
traceStreamingChannel(
|
|
13573
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.toolLoopAgentStream, {
|
|
13572
13574
|
name: "ToolLoopAgent.stream",
|
|
13573
13575
|
type: "function" /* FUNCTION */,
|
|
13574
13576
|
extractInput: ([params], event, span) => prepareAISDKCallInput(params, event, span, denyOutputPaths, {
|
|
@@ -13590,7 +13592,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13590
13592
|
})
|
|
13591
13593
|
);
|
|
13592
13594
|
this.unsubscribers.push(
|
|
13593
|
-
traceStreamingChannel(
|
|
13595
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.aiSDKChannels.workflowAgentStream, {
|
|
13594
13596
|
name: "WorkflowAgent.stream",
|
|
13595
13597
|
type: "function" /* FUNCTION */,
|
|
13596
13598
|
extractInput: ([params], event, span) => prepareAISDKWorkflowAgentStreamInput(
|
|
@@ -13630,7 +13632,7 @@ var AISDKPlugin = class extends BasePlugin {
|
|
|
13630
13632
|
}
|
|
13631
13633
|
};
|
|
13632
13634
|
function subscribeToHarnessAgentCreateSession() {
|
|
13633
|
-
const channel =
|
|
13635
|
+
const channel = _chunk4AQGZS6Xjs.harnessAgentChannels.createSession.tracingChannel();
|
|
13634
13636
|
const parents = /* @__PURE__ */ new WeakMap();
|
|
13635
13637
|
const handlers = {
|
|
13636
13638
|
start: (event) => {
|
|
@@ -13679,7 +13681,7 @@ function subscribeToHarnessContinuation(continuationChannel, defaultDenyOutputPa
|
|
|
13679
13681
|
prepareAISDKHarnessAgentInput(params, event.self);
|
|
13680
13682
|
}
|
|
13681
13683
|
} catch (error) {
|
|
13682
|
-
|
|
13684
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
13683
13685
|
"Error preparing Harness continuation telemetry:",
|
|
13684
13686
|
error
|
|
13685
13687
|
);
|
|
@@ -13717,7 +13719,7 @@ function subscribeToHarnessContinuation(continuationChannel, defaultDenyOutputPa
|
|
|
13717
13719
|
output
|
|
13718
13720
|
});
|
|
13719
13721
|
} catch (error) {
|
|
13720
|
-
|
|
13722
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
13721
13723
|
"Error aggregating Harness continuation stream:",
|
|
13722
13724
|
error
|
|
13723
13725
|
);
|
|
@@ -13752,7 +13754,7 @@ function subscribeToHarnessContinuation(continuationChannel, defaultDenyOutputPa
|
|
|
13752
13754
|
});
|
|
13753
13755
|
span.end();
|
|
13754
13756
|
} catch (error) {
|
|
13755
|
-
|
|
13757
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Error tracing Harness continuation:", error);
|
|
13756
13758
|
span.end();
|
|
13757
13759
|
}
|
|
13758
13760
|
},
|
|
@@ -13778,7 +13780,7 @@ function subscribeToHarnessContinuation(continuationChannel, defaultDenyOutputPa
|
|
|
13778
13780
|
}
|
|
13779
13781
|
function interceptAISDKV7TelemetryDispatcher() {
|
|
13780
13782
|
const telemetry = braintrustAISDKTelemetry();
|
|
13781
|
-
return
|
|
13783
|
+
return _chunk4AQGZS6Xjs.aiSDKChannels.v7CreateTelemetryDispatcher.intercept(
|
|
13782
13784
|
(target, thisArg, args) => {
|
|
13783
13785
|
const dispatcher = Reflect.apply(target, thisArg, args);
|
|
13784
13786
|
const telemetryOptions = _optionalChain([args, 'access', _216 => _216[0], 'optionalAccess', _217 => _217.telemetry]);
|
|
@@ -13790,7 +13792,7 @@ function interceptAISDKV7TelemetryDispatcher() {
|
|
|
13790
13792
|
telemetryOptions
|
|
13791
13793
|
);
|
|
13792
13794
|
} catch (error) {
|
|
13793
|
-
|
|
13795
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
13794
13796
|
"Error instrumenting AI SDK v7 telemetry dispatcher:",
|
|
13795
13797
|
error
|
|
13796
13798
|
);
|
|
@@ -14775,7 +14777,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
14775
14777
|
activeEntry.openSpans.delete(span);
|
|
14776
14778
|
}
|
|
14777
14779
|
},
|
|
14778
|
-
|
|
14780
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
14779
14781
|
{
|
|
14780
14782
|
name: "doGenerate",
|
|
14781
14783
|
spanAttributes: {
|
|
@@ -14789,7 +14791,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
14789
14791
|
}
|
|
14790
14792
|
)
|
|
14791
14793
|
},
|
|
14792
|
-
|
|
14794
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
14793
14795
|
)
|
|
14794
14796
|
);
|
|
14795
14797
|
};
|
|
@@ -14801,7 +14803,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
14801
14803
|
}
|
|
14802
14804
|
closeOpenAISDKModelPatchSpans(activeEntry);
|
|
14803
14805
|
const span = activeEntry.parentSpan.startSpan(
|
|
14804
|
-
|
|
14806
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
14805
14807
|
{
|
|
14806
14808
|
name: "doStream",
|
|
14807
14809
|
spanAttributes: {
|
|
@@ -14815,7 +14817,7 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
14815
14817
|
}
|
|
14816
14818
|
)
|
|
14817
14819
|
},
|
|
14818
|
-
|
|
14820
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
14819
14821
|
)
|
|
14820
14822
|
);
|
|
14821
14823
|
activeEntry.openSpans.add(span);
|
|
@@ -14987,20 +14989,26 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
14987
14989
|
if (!activeEntry) {
|
|
14988
14990
|
return result;
|
|
14989
14991
|
}
|
|
14992
|
+
const executionOptions = args[1];
|
|
14993
|
+
const toolCallId = isObject(executionOptions) ? executionOptions.toolCallId : void 0;
|
|
14994
|
+
const toolInput = {
|
|
14995
|
+
input: serializeToolExecutionInput(args),
|
|
14996
|
+
...typeof toolCallId === "string" ? { metadata: { toolCallId } } : {}
|
|
14997
|
+
};
|
|
14990
14998
|
if (isAsyncGenerator(result)) {
|
|
14991
14999
|
return (async function* () {
|
|
14992
15000
|
const span = activeEntry.parentSpan.startSpan(
|
|
14993
|
-
|
|
15001
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
14994
15002
|
{
|
|
14995
15003
|
name: activeEntry.name,
|
|
14996
15004
|
spanAttributes: {
|
|
14997
15005
|
type: "tool" /* TOOL */
|
|
14998
15006
|
}
|
|
14999
15007
|
},
|
|
15000
|
-
|
|
15008
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
15001
15009
|
)
|
|
15002
15010
|
);
|
|
15003
|
-
span.log(
|
|
15011
|
+
span.log(toolInput);
|
|
15004
15012
|
try {
|
|
15005
15013
|
let lastValue;
|
|
15006
15014
|
for await (const value of result) {
|
|
@@ -15018,19 +15026,19 @@ function prepareAISDKChildTracing(params, self, parentSpan, denyOutputPaths, aiS
|
|
|
15018
15026
|
}
|
|
15019
15027
|
return activeEntry.parentSpan.traced(
|
|
15020
15028
|
async (span) => {
|
|
15021
|
-
span.log(
|
|
15029
|
+
span.log(toolInput);
|
|
15022
15030
|
const awaitedResult = await result;
|
|
15023
15031
|
span.log({ output: awaitedResult });
|
|
15024
15032
|
return awaitedResult;
|
|
15025
15033
|
},
|
|
15026
|
-
|
|
15034
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
15027
15035
|
{
|
|
15028
15036
|
name: activeEntry.name,
|
|
15029
15037
|
spanAttributes: {
|
|
15030
15038
|
type: "tool" /* TOOL */
|
|
15031
15039
|
}
|
|
15032
15040
|
},
|
|
15033
|
-
|
|
15041
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
15034
15042
|
)
|
|
15035
15043
|
);
|
|
15036
15044
|
};
|
|
@@ -15213,30 +15221,30 @@ function patchAISDKStreamingResult(args) {
|
|
|
15213
15221
|
try {
|
|
15214
15222
|
finalizeAISDKChildTracing(endEvent);
|
|
15215
15223
|
} catch (error) {
|
|
15216
|
-
|
|
15224
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Error finalizing AI SDK child tracing:", error);
|
|
15217
15225
|
}
|
|
15218
15226
|
try {
|
|
15219
15227
|
span.end();
|
|
15220
15228
|
} catch (error) {
|
|
15221
|
-
|
|
15229
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Error ending AI SDK streaming span:", error);
|
|
15222
15230
|
}
|
|
15223
15231
|
if (outcome && "error" in outcome) {
|
|
15224
15232
|
try {
|
|
15225
15233
|
_optionalChain([onError, 'optionalCall', _262 => _262(outcome.error)]);
|
|
15226
15234
|
} catch (error) {
|
|
15227
|
-
|
|
15235
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Error in AI SDK streaming error hook:", error);
|
|
15228
15236
|
}
|
|
15229
15237
|
} else if (outcome) {
|
|
15230
15238
|
try {
|
|
15231
15239
|
_optionalChain([onComplete, 'optionalCall', _263 => _263(outcome)]);
|
|
15232
15240
|
} catch (error) {
|
|
15233
|
-
|
|
15241
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Error in AI SDK streaming completion hook:", error);
|
|
15234
15242
|
}
|
|
15235
15243
|
} else {
|
|
15236
15244
|
try {
|
|
15237
15245
|
_optionalChain([onCancel, 'optionalCall', _264 => _264()]);
|
|
15238
15246
|
} catch (error) {
|
|
15239
|
-
|
|
15247
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
15240
15248
|
"Error in AI SDK streaming cancellation hook:",
|
|
15241
15249
|
error
|
|
15242
15250
|
);
|
|
@@ -15283,7 +15291,7 @@ function patchAISDKStreamingResult(args) {
|
|
|
15283
15291
|
metrics
|
|
15284
15292
|
});
|
|
15285
15293
|
} catch (error) {
|
|
15286
|
-
|
|
15294
|
+
_chunk4AQGZS6Xjs.debugLogger.error("Error logging AI SDK streaming output:", error);
|
|
15287
15295
|
}
|
|
15288
15296
|
finalize({ metrics, output });
|
|
15289
15297
|
} catch (error) {
|
|
@@ -15291,7 +15299,7 @@ function patchAISDKStreamingResult(args) {
|
|
|
15291
15299
|
try {
|
|
15292
15300
|
span.log({ error: loggedError });
|
|
15293
15301
|
} catch (loggingError) {
|
|
15294
|
-
|
|
15302
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
15295
15303
|
"Error logging AI SDK streaming failure:",
|
|
15296
15304
|
loggingError
|
|
15297
15305
|
);
|
|
@@ -15318,7 +15326,7 @@ function patchAISDKStreamingResult(args) {
|
|
|
15318
15326
|
try {
|
|
15319
15327
|
span.log({ error });
|
|
15320
15328
|
} catch (loggingError) {
|
|
15321
|
-
|
|
15329
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
15322
15330
|
"Error logging AI SDK stream failure:",
|
|
15323
15331
|
loggingError
|
|
15324
15332
|
);
|
|
@@ -15414,7 +15422,7 @@ function patchAISDKStreamingResult(args) {
|
|
|
15414
15422
|
try {
|
|
15415
15423
|
span.log({ error: loggedError });
|
|
15416
15424
|
} catch (loggingError) {
|
|
15417
|
-
|
|
15425
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
15418
15426
|
"Error logging AI SDK base stream failure:",
|
|
15419
15427
|
loggingError
|
|
15420
15428
|
);
|
|
@@ -16272,13 +16280,13 @@ function braintrustAISDKTelemetry() {
|
|
|
16272
16280
|
};
|
|
16273
16281
|
const startChildSpan = (operationKey, name, type, event, parentOverride) => {
|
|
16274
16282
|
const parent = _optionalChain([operations, 'access', _308 => _308.get, 'call', _309 => _309(operationKey), 'optionalAccess', _310 => _310.span]);
|
|
16275
|
-
const spanArgs =
|
|
16283
|
+
const spanArgs = _chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
16276
16284
|
{
|
|
16277
16285
|
name,
|
|
16278
16286
|
spanAttributes: { type },
|
|
16279
16287
|
...event ? { event } : {}
|
|
16280
16288
|
},
|
|
16281
|
-
|
|
16289
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
16282
16290
|
);
|
|
16283
16291
|
const span = parentOverride ? startHarnessTurnChildSpan(parentOverride, spanArgs) : parent ? parent.startSpan(spanArgs) : startSpan(spanArgs);
|
|
16284
16292
|
const state = operations.get(operationKey);
|
|
@@ -16549,20 +16557,20 @@ function braintrustAISDKTelemetry() {
|
|
|
16549
16557
|
const harnessTurnParent = currentHarnessTurnParent();
|
|
16550
16558
|
const span = ownsSpan ? harnessTurnParent ? startHarnessTurnChildSpan(
|
|
16551
16559
|
harnessTurnParent,
|
|
16552
|
-
|
|
16560
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
16553
16561
|
{
|
|
16554
16562
|
name: operationName,
|
|
16555
16563
|
spanAttributes: { type: "function" /* FUNCTION */ }
|
|
16556
16564
|
},
|
|
16557
|
-
|
|
16565
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
16558
16566
|
)
|
|
16559
16567
|
) : startSpan(
|
|
16560
|
-
|
|
16568
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
16561
16569
|
{
|
|
16562
16570
|
name: operationName,
|
|
16563
16571
|
spanAttributes: { type: "function" /* FUNCTION */ }
|
|
16564
16572
|
},
|
|
16565
|
-
|
|
16573
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
16566
16574
|
)
|
|
16567
16575
|
) : wrapperSpan;
|
|
16568
16576
|
const operationKey = createOperationKey(event, operationName);
|
|
@@ -17079,7 +17087,7 @@ function enableFlueAutoInstrumentation() {
|
|
|
17079
17087
|
const state = getAutoState();
|
|
17080
17088
|
state.refCount += 1;
|
|
17081
17089
|
if (!state.createContextHandlers) {
|
|
17082
|
-
const createContextChannel =
|
|
17090
|
+
const createContextChannel = _chunk4AQGZS6Xjs.flueChannels.createContext.tracingChannel();
|
|
17083
17091
|
const handlers = {
|
|
17084
17092
|
end: (event) => {
|
|
17085
17093
|
subscribeToFlueContext(event.result, state);
|
|
@@ -17385,7 +17393,7 @@ var FlueObserveBridge = (_class18 = class {constructor() { _class18.prototype.__
|
|
|
17385
17393
|
return;
|
|
17386
17394
|
}
|
|
17387
17395
|
const span = startSpan(
|
|
17388
|
-
|
|
17396
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
17389
17397
|
{
|
|
17390
17398
|
name: `workflow:${workflowName}`,
|
|
17391
17399
|
spanAttributes: { type: "task" /* TASK */ },
|
|
@@ -17395,7 +17403,7 @@ var FlueObserveBridge = (_class18 = class {constructor() { _class18.prototype.__
|
|
|
17395
17403
|
metadata
|
|
17396
17404
|
}
|
|
17397
17405
|
},
|
|
17398
|
-
|
|
17406
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.FLUE
|
|
17399
17407
|
)
|
|
17400
17408
|
);
|
|
17401
17409
|
this.runsById.set(event.runId, { metadata, span });
|
|
@@ -17418,14 +17426,14 @@ var FlueObserveBridge = (_class18 = class {constructor() { _class18.prototype.__
|
|
|
17418
17426
|
return;
|
|
17419
17427
|
}
|
|
17420
17428
|
const span = startSpan(
|
|
17421
|
-
|
|
17429
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
17422
17430
|
{
|
|
17423
17431
|
name: `workflow:${workflowName}`,
|
|
17424
17432
|
spanAttributes: { type: "task" /* TASK */ },
|
|
17425
17433
|
startTime: eventTime(_nullishCoalesce(event.startedAt, () => ( event.timestamp))),
|
|
17426
17434
|
event: { metadata }
|
|
17427
17435
|
},
|
|
17428
|
-
|
|
17436
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.FLUE
|
|
17429
17437
|
)
|
|
17430
17438
|
);
|
|
17431
17439
|
this.runsById.set(event.runId, { metadata, span });
|
|
@@ -18189,10 +18197,10 @@ function startFlueSpan(parent, args) {
|
|
|
18189
18197
|
return parent ? withCurrent(
|
|
18190
18198
|
parent,
|
|
18191
18199
|
() => startSpan(
|
|
18192
|
-
|
|
18200
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0, args, _chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.FLUE)
|
|
18193
18201
|
)
|
|
18194
18202
|
) : startSpan(
|
|
18195
|
-
|
|
18203
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0, args, _chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.FLUE)
|
|
18196
18204
|
);
|
|
18197
18205
|
}
|
|
18198
18206
|
function startFlueRootSpan(args) {
|
|
@@ -18202,7 +18210,7 @@ function startFlueRootSpan(args) {
|
|
|
18202
18210
|
return withCurrent(
|
|
18203
18211
|
NOOP_SPAN,
|
|
18204
18212
|
() => startSpan({
|
|
18205
|
-
...
|
|
18213
|
+
..._chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0, args, _chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.FLUE),
|
|
18206
18214
|
parentSpanIds: { parentSpanIds: [], rootSpanId },
|
|
18207
18215
|
spanId,
|
|
18208
18216
|
state
|
|
@@ -18234,7 +18242,7 @@ function safeEnd(span, endTime) {
|
|
|
18234
18242
|
}
|
|
18235
18243
|
}
|
|
18236
18244
|
function logInstrumentationError(label, error) {
|
|
18237
|
-
|
|
18245
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(`Error in ${label} instrumentation:`, error);
|
|
18238
18246
|
}
|
|
18239
18247
|
|
|
18240
18248
|
// src/wrappers/langchain/callback-handler.ts
|
|
@@ -18298,9 +18306,9 @@ var BraintrustLangChainCallbackHandler = (_class19 = class {
|
|
|
18298
18306
|
...this.options.debug ? { runId, parentRunId } : {}
|
|
18299
18307
|
}
|
|
18300
18308
|
};
|
|
18301
|
-
const spanArgs =
|
|
18309
|
+
const spanArgs = _chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
18302
18310
|
args,
|
|
18303
|
-
|
|
18311
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.LANGCHAIN
|
|
18304
18312
|
);
|
|
18305
18313
|
let span = parentSpan.startSpan(spanArgs);
|
|
18306
18314
|
if (!Object.is(this.options.logger, NOOP_SPAN) && Object.is(span, NOOP_SPAN)) {
|
|
@@ -18572,14 +18580,17 @@ function getMetricsFromResponse(response) {
|
|
|
18572
18580
|
if (!isRecord(usageMetadata)) {
|
|
18573
18581
|
continue;
|
|
18574
18582
|
}
|
|
18575
|
-
const inputTokenDetails = usageMetadata.input_token_details;
|
|
18583
|
+
const inputTokenDetails = isRecord(usageMetadata.input_token_details) ? usageMetadata.input_token_details : {};
|
|
18576
18584
|
const outputTokenDetails = usageMetadata.output_token_details;
|
|
18577
18585
|
return normalizeTokenMetrics({
|
|
18578
18586
|
total_tokens: usageMetadata.total_tokens,
|
|
18579
18587
|
prompt_tokens: usageMetadata.input_tokens,
|
|
18580
18588
|
completion_tokens: usageMetadata.output_tokens,
|
|
18581
|
-
|
|
18582
|
-
|
|
18589
|
+
// Prefer TTL-specific cache writes over the aggregate when available.
|
|
18590
|
+
prompt_cache_creation_tokens: inputTokenDetails.ephemeral_5m_input_tokens == null && inputTokenDetails.ephemeral_1h_input_tokens == null ? inputTokenDetails.cache_creation : void 0,
|
|
18591
|
+
prompt_cache_creation_5m_tokens: inputTokenDetails.ephemeral_5m_input_tokens,
|
|
18592
|
+
prompt_cache_creation_1h_tokens: inputTokenDetails.ephemeral_1h_input_tokens,
|
|
18593
|
+
prompt_cached_tokens: inputTokenDetails.cache_read,
|
|
18583
18594
|
completion_reasoning_tokens: isRecord(outputTokenDetails) ? outputTokenDetails.reasoning : void 0
|
|
18584
18595
|
});
|
|
18585
18596
|
}
|
|
@@ -18717,7 +18728,7 @@ function validCustomId(value) {
|
|
|
18717
18728
|
return typeof value === "string" && value.length > 0 && value.length <= 64;
|
|
18718
18729
|
}
|
|
18719
18730
|
function logBatchInstrumentationError(context, error) {
|
|
18720
|
-
|
|
18731
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(`OpenAI Batch instrumentation ${context}:`, error);
|
|
18721
18732
|
}
|
|
18722
18733
|
async function exportParent(parent) {
|
|
18723
18734
|
if ("toStr" in parent && typeof parent.toStr === "function") {
|
|
@@ -18771,7 +18782,7 @@ async function startBatchSpan(context) {
|
|
|
18771
18782
|
return withCurrent(
|
|
18772
18783
|
NOOP_SPAN,
|
|
18773
18784
|
() => _internalStartSpanWithInitialMergeAndParentSpanIds(
|
|
18774
|
-
|
|
18785
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
18775
18786
|
{
|
|
18776
18787
|
name: "openai.batch",
|
|
18777
18788
|
type: "task" /* TASK */,
|
|
@@ -18793,7 +18804,7 @@ async function startBatchSpan(context) {
|
|
|
18793
18804
|
}
|
|
18794
18805
|
}
|
|
18795
18806
|
},
|
|
18796
|
-
|
|
18807
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI
|
|
18797
18808
|
)
|
|
18798
18809
|
)
|
|
18799
18810
|
);
|
|
@@ -18803,7 +18814,7 @@ async function startBatchChild(context, taskParent, input) {
|
|
|
18803
18814
|
return withCurrent(
|
|
18804
18815
|
NOOP_SPAN,
|
|
18805
18816
|
() => _internalStartSpanWithInitialMerge(
|
|
18806
|
-
|
|
18817
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
18807
18818
|
{
|
|
18808
18819
|
name: context.endpoint === "/v1/chat/completions" ? "Chat Completion" : "openai.responses.create",
|
|
18809
18820
|
type: "llm" /* LLM */,
|
|
@@ -18820,7 +18831,7 @@ async function startBatchChild(context, taskParent, input) {
|
|
|
18820
18831
|
}
|
|
18821
18832
|
}
|
|
18822
18833
|
},
|
|
18823
|
-
|
|
18834
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI
|
|
18824
18835
|
)
|
|
18825
18836
|
)
|
|
18826
18837
|
);
|
|
@@ -19240,18 +19251,18 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
19240
19251
|
}
|
|
19241
19252
|
onEnable() {
|
|
19242
19253
|
this.unsubscribers.push(
|
|
19243
|
-
|
|
19254
|
+
_chunk4AQGZS6Xjs.openAIChannels.filesCreateTraced.intercept(
|
|
19244
19255
|
interceptOpenAIFilesCreateTraced
|
|
19245
19256
|
),
|
|
19246
|
-
|
|
19257
|
+
_chunk4AQGZS6Xjs.openAIChannels.batchesRetrieveTraced.intercept(
|
|
19247
19258
|
interceptOpenAIBatchesRetrieveTraced
|
|
19248
19259
|
),
|
|
19249
|
-
|
|
19260
|
+
_chunk4AQGZS6Xjs.openAIChannels.batchesCompleteTrace.intercept(
|
|
19250
19261
|
interceptOpenAIBatchTraceComplete
|
|
19251
19262
|
)
|
|
19252
19263
|
);
|
|
19253
19264
|
this.unsubscribers.push(
|
|
19254
|
-
traceStreamingChannel(
|
|
19265
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.openAIChannels.chatCompletionsCreate, {
|
|
19255
19266
|
name: "Chat Completion",
|
|
19256
19267
|
type: "llm" /* LLM */,
|
|
19257
19268
|
extractInput: ([params]) => extractOpenAIChatInput(params),
|
|
@@ -19273,7 +19284,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
19273
19284
|
})
|
|
19274
19285
|
);
|
|
19275
19286
|
this.unsubscribers.push(
|
|
19276
|
-
traceAsyncChannel(
|
|
19287
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.openAIChannels.embeddingsCreate, {
|
|
19277
19288
|
name: "Embedding",
|
|
19278
19289
|
type: "llm" /* LLM */,
|
|
19279
19290
|
extractInput: ([params]) => {
|
|
@@ -19297,7 +19308,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
19297
19308
|
})
|
|
19298
19309
|
);
|
|
19299
19310
|
this.unsubscribers.push(
|
|
19300
|
-
traceStreamingChannel(
|
|
19311
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.openAIChannels.betaChatCompletionsParse, {
|
|
19301
19312
|
name: "Chat Completion",
|
|
19302
19313
|
type: "llm" /* LLM */,
|
|
19303
19314
|
extractInput: ([params]) => extractOpenAIChatInput(params),
|
|
@@ -19319,14 +19330,14 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
19319
19330
|
})
|
|
19320
19331
|
);
|
|
19321
19332
|
this.unsubscribers.push(
|
|
19322
|
-
traceSyncStreamChannel(
|
|
19333
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.openAIChannels.betaChatCompletionsStream, {
|
|
19323
19334
|
name: "Chat Completion",
|
|
19324
19335
|
type: "llm" /* LLM */,
|
|
19325
19336
|
extractInput: ([params]) => extractOpenAIChatInput(params)
|
|
19326
19337
|
})
|
|
19327
19338
|
);
|
|
19328
19339
|
this.unsubscribers.push(
|
|
19329
|
-
traceAsyncChannel(
|
|
19340
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.openAIChannels.moderationsCreate, {
|
|
19330
19341
|
name: "Moderation",
|
|
19331
19342
|
type: "llm" /* LLM */,
|
|
19332
19343
|
extractInput: ([params]) => {
|
|
@@ -19349,7 +19360,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
19349
19360
|
})
|
|
19350
19361
|
);
|
|
19351
19362
|
this.unsubscribers.push(
|
|
19352
|
-
traceStreamingChannel(
|
|
19363
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.openAIChannels.responsesCreate, {
|
|
19353
19364
|
name: "openai.responses.create",
|
|
19354
19365
|
type: "llm" /* LLM */,
|
|
19355
19366
|
extractInput: ([params]) => extractOpenAIResponsesInput(params),
|
|
@@ -19372,7 +19383,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
19372
19383
|
})
|
|
19373
19384
|
);
|
|
19374
19385
|
this.unsubscribers.push(
|
|
19375
|
-
traceSyncStreamChannel(
|
|
19386
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.openAIChannels.responsesStream, {
|
|
19376
19387
|
name: "openai.responses.create",
|
|
19377
19388
|
type: "llm" /* LLM */,
|
|
19378
19389
|
extractInput: ([params]) => extractOpenAIResponsesInput(params),
|
|
@@ -19395,7 +19406,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
19395
19406
|
})
|
|
19396
19407
|
);
|
|
19397
19408
|
this.unsubscribers.push(
|
|
19398
|
-
traceStreamingChannel(
|
|
19409
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.openAIChannels.responsesParse, {
|
|
19399
19410
|
name: "openai.responses.parse",
|
|
19400
19411
|
type: "llm" /* LLM */,
|
|
19401
19412
|
extractInput: ([params]) => extractOpenAIResponsesInput(params),
|
|
@@ -19418,7 +19429,7 @@ var OpenAIPlugin = class extends BasePlugin {
|
|
|
19418
19429
|
})
|
|
19419
19430
|
);
|
|
19420
19431
|
this.unsubscribers.push(
|
|
19421
|
-
traceAsyncChannel(
|
|
19432
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.openAIChannels.responsesCompact, {
|
|
19422
19433
|
name: "openai.responses.compact",
|
|
19423
19434
|
type: "llm" /* LLM */,
|
|
19424
19435
|
extractInput: ([params]) => extractOpenAIResponsesInput(params),
|
|
@@ -19661,7 +19672,7 @@ var OpenAICodexPlugin = class extends BasePlugin {
|
|
|
19661
19672
|
this.unsubscribers = [];
|
|
19662
19673
|
}
|
|
19663
19674
|
subscribeToRun() {
|
|
19664
|
-
const channel =
|
|
19675
|
+
const channel = _chunk4AQGZS6Xjs.openAICodexChannels.run.tracingChannel();
|
|
19665
19676
|
const states = /* @__PURE__ */ new WeakMap();
|
|
19666
19677
|
const handlers = {
|
|
19667
19678
|
start: (event) => {
|
|
@@ -19690,7 +19701,7 @@ var OpenAICodexPlugin = class extends BasePlugin {
|
|
|
19690
19701
|
});
|
|
19691
19702
|
}
|
|
19692
19703
|
subscribeToRunStreamed() {
|
|
19693
|
-
const channel =
|
|
19704
|
+
const channel = _chunk4AQGZS6Xjs.openAICodexChannels.runStreamed.tracingChannel();
|
|
19694
19705
|
const states = /* @__PURE__ */ new WeakMap();
|
|
19695
19706
|
const handlers = {
|
|
19696
19707
|
start: (event) => {
|
|
@@ -19732,12 +19743,12 @@ function startCodexRun(event, operation) {
|
|
|
19732
19743
|
...event.moduleVersion ? { "openai_codex.version": event.moduleVersion } : {}
|
|
19733
19744
|
};
|
|
19734
19745
|
const span = startSpan(
|
|
19735
|
-
|
|
19746
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
19736
19747
|
{
|
|
19737
19748
|
name: "OpenAI Codex",
|
|
19738
19749
|
spanAttributes: { type: "task" /* TASK */ }
|
|
19739
19750
|
},
|
|
19740
|
-
|
|
19751
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI_CODEX
|
|
19741
19752
|
)
|
|
19742
19753
|
);
|
|
19743
19754
|
const startTime = getCurrentUnixTimestamp();
|
|
@@ -19818,7 +19829,7 @@ async function handleCodexEvent(state, event) {
|
|
|
19818
19829
|
return;
|
|
19819
19830
|
case "error":
|
|
19820
19831
|
if (event.message) {
|
|
19821
|
-
|
|
19832
|
+
_chunk4AQGZS6Xjs.debugLogger.debug("OpenAI Codex stream event:", event.message);
|
|
19822
19833
|
}
|
|
19823
19834
|
return;
|
|
19824
19835
|
default:
|
|
@@ -19889,9 +19900,9 @@ async function createCompletedItemSpan(state, item) {
|
|
|
19889
19900
|
return;
|
|
19890
19901
|
}
|
|
19891
19902
|
const span = startSpan(
|
|
19892
|
-
|
|
19903
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
19893
19904
|
spanArgs.start,
|
|
19894
|
-
|
|
19905
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI_CODEX
|
|
19895
19906
|
)
|
|
19896
19907
|
);
|
|
19897
19908
|
safeLog2(span, spanArgs.end);
|
|
@@ -19936,7 +19947,7 @@ async function ensureActiveLlmSpan(state) {
|
|
|
19936
19947
|
"openai_codex.llm_sequence": sequence
|
|
19937
19948
|
};
|
|
19938
19949
|
const span = startSpan(
|
|
19939
|
-
|
|
19950
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
19940
19951
|
{
|
|
19941
19952
|
event: {
|
|
19942
19953
|
...sequence === 1 ? { input: state.input } : {},
|
|
@@ -19946,7 +19957,7 @@ async function ensureActiveLlmSpan(state) {
|
|
|
19946
19957
|
parent: await state.span.export(),
|
|
19947
19958
|
spanAttributes: { type: "llm" /* LLM */ }
|
|
19948
19959
|
},
|
|
19949
|
-
|
|
19960
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI_CODEX
|
|
19950
19961
|
)
|
|
19951
19962
|
);
|
|
19952
19963
|
state.activeLlmSpan = {
|
|
@@ -19997,9 +20008,9 @@ async function startCodexItemSpan(state, item) {
|
|
|
19997
20008
|
state.activeItemSpans.set(
|
|
19998
20009
|
itemId,
|
|
19999
20010
|
startSpan(
|
|
20000
|
-
|
|
20011
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
20001
20012
|
spanArgs.start,
|
|
20002
|
-
|
|
20013
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI_CODEX
|
|
20003
20014
|
)
|
|
20004
20015
|
)
|
|
20005
20016
|
);
|
|
@@ -20288,7 +20299,7 @@ function safeLog2(span, event) {
|
|
|
20288
20299
|
}
|
|
20289
20300
|
}
|
|
20290
20301
|
function logInstrumentationError2(context, error) {
|
|
20291
|
-
|
|
20302
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error processing ${context}:`, error);
|
|
20292
20303
|
}
|
|
20293
20304
|
|
|
20294
20305
|
// src/wrappers/anthropic-tokens-util.ts
|
|
@@ -20383,17 +20394,17 @@ var AnthropicPlugin = class extends BasePlugin {
|
|
|
20383
20394
|
aggregateChunks: (chunks) => aggregateAnthropicStreamChunks(chunks)
|
|
20384
20395
|
};
|
|
20385
20396
|
this.unsubscribers.push(
|
|
20386
|
-
traceStreamingChannel(
|
|
20397
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.anthropicChannels.messagesCreate, anthropicConfig)
|
|
20387
20398
|
);
|
|
20388
20399
|
this.unsubscribers.push(
|
|
20389
|
-
traceStreamingChannel(
|
|
20400
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.anthropicChannels.betaMessagesCreate, {
|
|
20390
20401
|
...anthropicConfig,
|
|
20391
20402
|
name: "anthropic.messages.create"
|
|
20392
20403
|
})
|
|
20393
20404
|
);
|
|
20394
20405
|
}
|
|
20395
20406
|
subscribeToAnthropicToolRunner() {
|
|
20396
|
-
const tracingChannel =
|
|
20407
|
+
const tracingChannel = _chunk4AQGZS6Xjs.anthropicChannels.betaMessagesToolRunner.tracingChannel();
|
|
20397
20408
|
const states = /* @__PURE__ */ new WeakMap();
|
|
20398
20409
|
const handlers = {
|
|
20399
20410
|
start: (event) => {
|
|
@@ -20402,14 +20413,14 @@ var AnthropicPlugin = class extends BasePlugin {
|
|
|
20402
20413
|
}
|
|
20403
20414
|
const params = _nullishCoalesce(event.arguments[0], () => ( {}));
|
|
20404
20415
|
const span = startSpan(
|
|
20405
|
-
|
|
20416
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
20406
20417
|
{
|
|
20407
20418
|
name: "anthropic.beta.messages.toolRunner",
|
|
20408
20419
|
spanAttributes: {
|
|
20409
20420
|
type: "task" /* TASK */
|
|
20410
20421
|
}
|
|
20411
20422
|
},
|
|
20412
|
-
|
|
20423
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.ANTHROPIC
|
|
20413
20424
|
)
|
|
20414
20425
|
);
|
|
20415
20426
|
span.log({
|
|
@@ -20457,11 +20468,11 @@ var AnthropicPlugin = class extends BasePlugin {
|
|
|
20457
20468
|
}
|
|
20458
20469
|
subscribeToAnthropicSessionStreams() {
|
|
20459
20470
|
this.subscribeToAnthropicSessionStream(
|
|
20460
|
-
|
|
20471
|
+
_chunk4AQGZS6Xjs.anthropicChannels.betaSessionsEventsStream,
|
|
20461
20472
|
false
|
|
20462
20473
|
);
|
|
20463
20474
|
this.subscribeToAnthropicSessionStream(
|
|
20464
|
-
|
|
20475
|
+
_chunk4AQGZS6Xjs.anthropicChannels.betaSessionsThreadsEventsStream,
|
|
20465
20476
|
true
|
|
20466
20477
|
);
|
|
20467
20478
|
}
|
|
@@ -20602,7 +20613,7 @@ function handleAnthropicSessionEvent(state, event) {
|
|
|
20602
20613
|
break;
|
|
20603
20614
|
}
|
|
20604
20615
|
} catch (error) {
|
|
20605
|
-
|
|
20616
|
+
_chunk4AQGZS6Xjs.debugLogger.debug("Error processing Anthropic Sessions event:", error);
|
|
20606
20617
|
}
|
|
20607
20618
|
}
|
|
20608
20619
|
function ensureAnthropicSessionTurn(state) {
|
|
@@ -20612,7 +20623,7 @@ function ensureAnthropicSessionTurn(state) {
|
|
|
20612
20623
|
const input = state.pendingInput;
|
|
20613
20624
|
state.pendingInput = [];
|
|
20614
20625
|
const span = startSpan(
|
|
20615
|
-
|
|
20626
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
20616
20627
|
{
|
|
20617
20628
|
event: {
|
|
20618
20629
|
...input.length > 0 ? { input } : {},
|
|
@@ -20621,7 +20632,7 @@ function ensureAnthropicSessionTurn(state) {
|
|
|
20621
20632
|
name: state.isThread ? "anthropic.beta.sessions.thread.turn" : "anthropic.beta.sessions.turn",
|
|
20622
20633
|
spanAttributes: { type: "task" /* TASK */ }
|
|
20623
20634
|
},
|
|
20624
|
-
|
|
20635
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.ANTHROPIC
|
|
20625
20636
|
)
|
|
20626
20637
|
);
|
|
20627
20638
|
state.activeTurn = {
|
|
@@ -20653,7 +20664,7 @@ function startAnthropicSessionModel(state, startEventId) {
|
|
|
20653
20664
|
const span = withCurrent(
|
|
20654
20665
|
turn.span,
|
|
20655
20666
|
() => startSpan(
|
|
20656
|
-
|
|
20667
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
20657
20668
|
{
|
|
20658
20669
|
event: {
|
|
20659
20670
|
...state.history.length > 0 ? { input: state.history.slice() } : {},
|
|
@@ -20662,7 +20673,7 @@ function startAnthropicSessionModel(state, startEventId) {
|
|
|
20662
20673
|
name: "anthropic.messages.create",
|
|
20663
20674
|
spanAttributes: { type: "llm" /* LLM */ }
|
|
20664
20675
|
},
|
|
20665
|
-
|
|
20676
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.ANTHROPIC
|
|
20666
20677
|
)
|
|
20667
20678
|
)
|
|
20668
20679
|
);
|
|
@@ -20711,13 +20722,13 @@ function startAnthropicSessionTool(state, event) {
|
|
|
20711
20722
|
const span = withCurrent(
|
|
20712
20723
|
turn.span,
|
|
20713
20724
|
() => startSpan(
|
|
20714
|
-
|
|
20725
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
20715
20726
|
{
|
|
20716
20727
|
event: { input: event.input },
|
|
20717
20728
|
name: event.name,
|
|
20718
20729
|
spanAttributes: { type: "tool" /* TOOL */ }
|
|
20719
20730
|
},
|
|
20720
|
-
|
|
20731
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.ANTHROPIC
|
|
20721
20732
|
)
|
|
20722
20733
|
)
|
|
20723
20734
|
);
|
|
@@ -20857,7 +20868,7 @@ function safeAnthropicSessionLog(span, event) {
|
|
|
20857
20868
|
try {
|
|
20858
20869
|
span.log(event);
|
|
20859
20870
|
} catch (error) {
|
|
20860
|
-
|
|
20871
|
+
_chunk4AQGZS6Xjs.debugLogger.debug("Error logging Anthropic Sessions span:", error);
|
|
20861
20872
|
}
|
|
20862
20873
|
}
|
|
20863
20874
|
function parseMetricsFromUsage2(usage) {
|
|
@@ -20974,7 +20985,7 @@ function wrapAnthropicToolRunnerTool(tool, index, state) {
|
|
|
20974
20985
|
return finalizeError(error);
|
|
20975
20986
|
}
|
|
20976
20987
|
},
|
|
20977
|
-
|
|
20988
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
20978
20989
|
{
|
|
20979
20990
|
event: {
|
|
20980
20991
|
input: getAnthropicToolRunnerInput(args),
|
|
@@ -20988,7 +20999,7 @@ function wrapAnthropicToolRunnerTool(tool, index, state) {
|
|
|
20988
20999
|
type: "tool" /* TOOL */
|
|
20989
21000
|
}
|
|
20990
21001
|
},
|
|
20991
|
-
|
|
21002
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.ANTHROPIC
|
|
20992
21003
|
)
|
|
20993
21004
|
);
|
|
20994
21005
|
},
|
|
@@ -21458,7 +21469,7 @@ function coalesceInput(messages, system) {
|
|
|
21458
21469
|
var CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION = "__braintrust_skip_local_tool_hooks";
|
|
21459
21470
|
|
|
21460
21471
|
// src/instrumentation/plugins/claude-agent-sdk-local-tool-context.ts
|
|
21461
|
-
var localToolContextStore =
|
|
21472
|
+
var localToolContextStore = _chunk4AQGZS6Xjs.isomorph_default.newAsyncLocalStorage();
|
|
21462
21473
|
var localToolParentResolversByToolUseId = /* @__PURE__ */ new Map();
|
|
21463
21474
|
function runWithClaudeLocalToolContext(callback, resolver) {
|
|
21464
21475
|
return localToolContextStore.run(resolver, callback);
|
|
@@ -21504,7 +21515,7 @@ function wrapLocalClaudeToolHandler(handler, getMetadata) {
|
|
|
21504
21515
|
const runWithResolvedParent = async () => {
|
|
21505
21516
|
const parent = toolUseId && localToolParentResolver ? await localToolParentResolver(toolUseId).catch(() => void 0) : void 0;
|
|
21506
21517
|
const span = startSpan(
|
|
21507
|
-
|
|
21518
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
21508
21519
|
{
|
|
21509
21520
|
event: {
|
|
21510
21521
|
input: handlerArgs[0],
|
|
@@ -21521,7 +21532,7 @@ function wrapLocalClaudeToolHandler(handler, getMetadata) {
|
|
|
21521
21532
|
...parent && { parent },
|
|
21522
21533
|
spanAttributes: { type: "tool" /* TOOL */ }
|
|
21523
21534
|
},
|
|
21524
|
-
|
|
21535
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK
|
|
21525
21536
|
)
|
|
21526
21537
|
);
|
|
21527
21538
|
const runHandler = () => Reflect.apply(handler, this, handlerArgs);
|
|
@@ -21909,7 +21920,7 @@ async function createLLMSpanForMessages(messages, promptMessages, conversationHi
|
|
|
21909
21920
|
(c) => c !== void 0
|
|
21910
21921
|
);
|
|
21911
21922
|
const span = _nullishCoalesce(existingSpan, () => ( startSpan(
|
|
21912
|
-
|
|
21923
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
21913
21924
|
{
|
|
21914
21925
|
name: "anthropic.messages.create",
|
|
21915
21926
|
parent: parentSpan,
|
|
@@ -21918,7 +21929,7 @@ async function createLLMSpanForMessages(messages, promptMessages, conversationHi
|
|
|
21918
21929
|
},
|
|
21919
21930
|
startTime
|
|
21920
21931
|
},
|
|
21921
|
-
|
|
21932
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK
|
|
21922
21933
|
)
|
|
21923
21934
|
)));
|
|
21924
21935
|
span.log({
|
|
@@ -22031,7 +22042,7 @@ function createToolTracingHooks(resolveParentSpan, taskIdToToolUseId, toolUseToP
|
|
|
22031
22042
|
}
|
|
22032
22043
|
const parsed = parseToolName(input.tool_name);
|
|
22033
22044
|
const toolSpan = startSpan(
|
|
22034
|
-
|
|
22045
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
22035
22046
|
{
|
|
22036
22047
|
event: {
|
|
22037
22048
|
input: input.tool_input,
|
|
@@ -22051,7 +22062,7 @@ function createToolTracingHooks(resolveParentSpan, taskIdToToolUseId, toolUseToP
|
|
|
22051
22062
|
}),
|
|
22052
22063
|
spanAttributes: { type: "tool" /* TOOL */ }
|
|
22053
22064
|
},
|
|
22054
|
-
|
|
22065
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK
|
|
22055
22066
|
)
|
|
22056
22067
|
);
|
|
22057
22068
|
activeToolSpans.set(toolUseID, toolSpan);
|
|
@@ -22436,7 +22447,7 @@ async function ensureSubAgentSpan(subAgentDetailsByToolUseId, rootSpan, activeTo
|
|
|
22436
22447
|
const parentToolSpan = activeToolSpans.get(parentToolUseId);
|
|
22437
22448
|
const parentSpan = parentToolSpan ? await parentToolSpan.export() : await rootSpan.export();
|
|
22438
22449
|
const subAgentSpan = startSpan(
|
|
22439
|
-
|
|
22450
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
22440
22451
|
{
|
|
22441
22452
|
event: {
|
|
22442
22453
|
metadata: subAgentDetailsToMetadata(details)
|
|
@@ -22445,7 +22456,7 @@ async function ensureSubAgentSpan(subAgentDetailsByToolUseId, rootSpan, activeTo
|
|
|
22445
22456
|
parent: parentSpan,
|
|
22446
22457
|
spanAttributes: { type: "task" /* TASK */ }
|
|
22447
22458
|
},
|
|
22448
|
-
|
|
22459
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK
|
|
22449
22460
|
)
|
|
22450
22461
|
);
|
|
22451
22462
|
subAgentSpans.set(parentToolUseId, subAgentSpan);
|
|
@@ -22473,7 +22484,7 @@ async function ensureActiveLlmSpanForParentToolUse(rootSpan, activeLlmSpansByPar
|
|
|
22473
22484
|
return racedLlmSpan;
|
|
22474
22485
|
}
|
|
22475
22486
|
const llmSpan = startSpan(
|
|
22476
|
-
|
|
22487
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
22477
22488
|
{
|
|
22478
22489
|
name: "anthropic.messages.create",
|
|
22479
22490
|
parent: llmParentSpan,
|
|
@@ -22482,7 +22493,7 @@ async function ensureActiveLlmSpanForParentToolUse(rootSpan, activeLlmSpansByPar
|
|
|
22482
22493
|
},
|
|
22483
22494
|
startTime
|
|
22484
22495
|
},
|
|
22485
|
-
|
|
22496
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK
|
|
22486
22497
|
)
|
|
22487
22498
|
);
|
|
22488
22499
|
activeLlmSpansByParentToolUse.set(parentKey, llmSpan);
|
|
@@ -22772,14 +22783,14 @@ var ClaudeAgentSDKPlugin = class extends BasePlugin {
|
|
|
22772
22783
|
})();
|
|
22773
22784
|
}
|
|
22774
22785
|
const span = startSpan(
|
|
22775
|
-
|
|
22786
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
22776
22787
|
{
|
|
22777
22788
|
name: "Claude Agent",
|
|
22778
22789
|
spanAttributes: {
|
|
22779
22790
|
type: "task" /* TASK */
|
|
22780
22791
|
}
|
|
22781
22792
|
},
|
|
22782
|
-
|
|
22793
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLAUDE_AGENT_SDK
|
|
22783
22794
|
)
|
|
22784
22795
|
);
|
|
22785
22796
|
const startTime = getCurrentUnixTimestamp();
|
|
@@ -22911,13 +22922,13 @@ var ClaudeAgentSDKPlugin = class extends BasePlugin {
|
|
|
22911
22922
|
}
|
|
22912
22923
|
};
|
|
22913
22924
|
this.unsubscribers.push(
|
|
22914
|
-
|
|
22925
|
+
_chunk4AQGZS6Xjs.claudeAgentSDKChannels.query.intercept((target, thisArg, args) => {
|
|
22915
22926
|
let state;
|
|
22916
22927
|
try {
|
|
22917
22928
|
args[0] ??= {};
|
|
22918
22929
|
state = startQuery(args[0]);
|
|
22919
22930
|
} catch (error) {
|
|
22920
|
-
|
|
22931
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
22921
22932
|
"Error starting Claude Agent SDK instrumentation:",
|
|
22922
22933
|
error
|
|
22923
22934
|
);
|
|
@@ -22932,7 +22943,7 @@ var ClaudeAgentSDKPlugin = class extends BasePlugin {
|
|
|
22932
22943
|
try {
|
|
22933
22944
|
finishQuery(state, result);
|
|
22934
22945
|
} catch (error) {
|
|
22935
|
-
|
|
22946
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
22936
22947
|
"Error finalizing Claude Agent SDK instrumentation:",
|
|
22937
22948
|
error
|
|
22938
22949
|
);
|
|
@@ -22947,7 +22958,7 @@ var ClaudeAgentSDKPlugin = class extends BasePlugin {
|
|
|
22947
22958
|
});
|
|
22948
22959
|
state.span.end();
|
|
22949
22960
|
} catch (instrumentationError) {
|
|
22950
|
-
|
|
22961
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
22951
22962
|
"Error handling Claude Agent SDK instrumentation failure:",
|
|
22952
22963
|
instrumentationError
|
|
22953
22964
|
);
|
|
@@ -22980,7 +22991,7 @@ var CloudflareThinkPlugin = (_class20 = class extends BasePlugin {constructor(..
|
|
|
22980
22991
|
this.statesBySpanId.clear();
|
|
22981
22992
|
}
|
|
22982
22993
|
subscribeToThinkRuns() {
|
|
22983
|
-
const channel =
|
|
22994
|
+
const channel = _chunk4AQGZS6Xjs.cloudflareThinkChannels.runInferenceLoop.tracingChannel();
|
|
22984
22995
|
const states = /* @__PURE__ */ new WeakMap();
|
|
22985
22996
|
const state = _internalGetGlobalState();
|
|
22986
22997
|
const contextManager = _optionalChain([state, 'optionalAccess', _570 => _570.contextManager]);
|
|
@@ -22994,12 +23005,12 @@ var CloudflareThinkPlugin = (_class20 = class extends BasePlugin {constructor(..
|
|
|
22994
23005
|
return existing;
|
|
22995
23006
|
}
|
|
22996
23007
|
const span = startSpan(
|
|
22997
|
-
|
|
23008
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
22998
23009
|
{
|
|
22999
23010
|
name: "Think.runTurn",
|
|
23000
23011
|
spanAttributes: { type: "task" /* TASK */ }
|
|
23001
23012
|
},
|
|
23002
|
-
|
|
23013
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLOUDFLARE_THINK
|
|
23003
23014
|
)
|
|
23004
23015
|
);
|
|
23005
23016
|
const runState = {
|
|
@@ -23060,7 +23071,7 @@ var CloudflareThinkPlugin = (_class20 = class extends BasePlugin {constructor(..
|
|
|
23060
23071
|
this.unsubscribers.push(() => channel.unsubscribe(handlers));
|
|
23061
23072
|
}
|
|
23062
23073
|
subscribeToAISDKStreamTextSync() {
|
|
23063
|
-
const channel =
|
|
23074
|
+
const channel = _chunk4AQGZS6Xjs.aiSDKChannels.streamTextSync.tracingChannel();
|
|
23064
23075
|
const handlers = {
|
|
23065
23076
|
start: (event) => {
|
|
23066
23077
|
this.startAISDKStream(event);
|
|
@@ -23076,7 +23087,7 @@ var CloudflareThinkPlugin = (_class20 = class extends BasePlugin {constructor(..
|
|
|
23076
23087
|
this.unsubscribers.push(() => channel.unsubscribe(handlers));
|
|
23077
23088
|
}
|
|
23078
23089
|
subscribeToAISDKStreamTextAsync() {
|
|
23079
|
-
const channel =
|
|
23090
|
+
const channel = _chunk4AQGZS6Xjs.aiSDKChannels.streamText.tracingChannel();
|
|
23080
23091
|
const handlers = {
|
|
23081
23092
|
start: (event) => {
|
|
23082
23093
|
this.startAISDKStream(event);
|
|
@@ -23116,7 +23127,7 @@ var CloudflareThinkPlugin = (_class20 = class extends BasePlugin {constructor(..
|
|
|
23116
23127
|
runState.aiEvent = event;
|
|
23117
23128
|
Reflect.set(event, THINK_STATE_ID, runState.span.spanId);
|
|
23118
23129
|
} catch (error) {
|
|
23119
|
-
|
|
23130
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
23120
23131
|
"Error preparing @cloudflare/think AI SDK tracing:",
|
|
23121
23132
|
error
|
|
23122
23133
|
);
|
|
@@ -23256,8 +23267,8 @@ var CursorSDKPlugin = (_class21 = class extends BasePlugin {constructor(...args4
|
|
|
23256
23267
|
this.promptDepth = 0;
|
|
23257
23268
|
}
|
|
23258
23269
|
subscribeToAgentFactories() {
|
|
23259
|
-
this.subscribeToAgentFactory(
|
|
23260
|
-
this.subscribeToAgentFactory(
|
|
23270
|
+
this.subscribeToAgentFactory(_chunk4AQGZS6Xjs.cursorSDKChannels.create);
|
|
23271
|
+
this.subscribeToAgentFactory(_chunk4AQGZS6Xjs.cursorSDKChannels.resume);
|
|
23261
23272
|
}
|
|
23262
23273
|
subscribeToAgentFactory(channel) {
|
|
23263
23274
|
const tracingChannel = channel.tracingChannel();
|
|
@@ -23274,7 +23285,7 @@ var CursorSDKPlugin = (_class21 = class extends BasePlugin {constructor(...args4
|
|
|
23274
23285
|
});
|
|
23275
23286
|
}
|
|
23276
23287
|
subscribeToPrompt() {
|
|
23277
|
-
const channel =
|
|
23288
|
+
const channel = _chunk4AQGZS6Xjs.cursorSDKChannels.prompt.tracingChannel();
|
|
23278
23289
|
const states = /* @__PURE__ */ new WeakMap();
|
|
23279
23290
|
const handlers = {
|
|
23280
23291
|
start: (event) => {
|
|
@@ -23288,12 +23299,12 @@ var CursorSDKPlugin = (_class21 = class extends BasePlugin {constructor(...args4
|
|
|
23288
23299
|
...event.moduleVersion ? { "cursor_sdk.version": event.moduleVersion } : {}
|
|
23289
23300
|
};
|
|
23290
23301
|
const span = startSpan(
|
|
23291
|
-
|
|
23302
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
23292
23303
|
{
|
|
23293
23304
|
name: "Cursor Agent",
|
|
23294
23305
|
spanAttributes: { type: "task" /* TASK */ }
|
|
23295
23306
|
},
|
|
23296
|
-
|
|
23307
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CURSOR_SDK
|
|
23297
23308
|
)
|
|
23298
23309
|
);
|
|
23299
23310
|
const startTime = getCurrentUnixTimestamp();
|
|
@@ -23340,7 +23351,7 @@ var CursorSDKPlugin = (_class21 = class extends BasePlugin {constructor(...args4
|
|
|
23340
23351
|
});
|
|
23341
23352
|
}
|
|
23342
23353
|
subscribeToSend() {
|
|
23343
|
-
const channel =
|
|
23354
|
+
const channel = _chunk4AQGZS6Xjs.cursorSDKChannels.send.tracingChannel();
|
|
23344
23355
|
const states = /* @__PURE__ */ new WeakMap();
|
|
23345
23356
|
const handlers = {
|
|
23346
23357
|
start: (event) => {
|
|
@@ -23358,12 +23369,12 @@ var CursorSDKPlugin = (_class21 = class extends BasePlugin {constructor(...args4
|
|
|
23358
23369
|
...event.moduleVersion ? { "cursor_sdk.version": event.moduleVersion } : {}
|
|
23359
23370
|
};
|
|
23360
23371
|
const span = startSpan(
|
|
23361
|
-
|
|
23372
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
23362
23373
|
{
|
|
23363
23374
|
name: "Cursor Agent",
|
|
23364
23375
|
spanAttributes: { type: "task" /* TASK */ }
|
|
23365
23376
|
},
|
|
23366
|
-
|
|
23377
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CURSOR_SDK
|
|
23367
23378
|
)
|
|
23368
23379
|
);
|
|
23369
23380
|
const startTime = getCurrentUnixTimestamp();
|
|
@@ -23444,7 +23455,7 @@ function patchCursorAgentInPlace(agent) {
|
|
|
23444
23455
|
configurable: true,
|
|
23445
23456
|
value(message, options) {
|
|
23446
23457
|
const args = [message, options];
|
|
23447
|
-
return
|
|
23458
|
+
return _chunk4AQGZS6Xjs.cursorSDKChannels.send.tracePromise(
|
|
23448
23459
|
() => originalSend(...args),
|
|
23449
23460
|
{
|
|
23450
23461
|
agent: agentRecord,
|
|
@@ -23813,7 +23824,7 @@ async function startToolSpan(state, args) {
|
|
|
23813
23824
|
metadata["cursor_sdk.tool.result_truncated"] = args.truncated.result;
|
|
23814
23825
|
}
|
|
23815
23826
|
const span = startSpan(
|
|
23816
|
-
|
|
23827
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
23817
23828
|
{
|
|
23818
23829
|
event: {
|
|
23819
23830
|
input: args.args,
|
|
@@ -23823,13 +23834,13 @@ async function startToolSpan(state, args) {
|
|
|
23823
23834
|
parent: await state.span.export(),
|
|
23824
23835
|
spanAttributes: { type: "tool" /* TOOL */ }
|
|
23825
23836
|
},
|
|
23826
|
-
|
|
23837
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CURSOR_SDK
|
|
23827
23838
|
)
|
|
23828
23839
|
);
|
|
23829
23840
|
let subAgentSpan;
|
|
23830
23841
|
if (isSubAgentToolName(name)) {
|
|
23831
23842
|
subAgentSpan = startSpan(
|
|
23832
|
-
|
|
23843
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
23833
23844
|
{
|
|
23834
23845
|
event: {
|
|
23835
23846
|
input: args.args,
|
|
@@ -23842,7 +23853,7 @@ async function startToolSpan(state, args) {
|
|
|
23842
23853
|
parent: await span.export(),
|
|
23843
23854
|
spanAttributes: { type: "task" /* TASK */ }
|
|
23844
23855
|
},
|
|
23845
|
-
|
|
23856
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CURSOR_SDK
|
|
23846
23857
|
)
|
|
23847
23858
|
);
|
|
23848
23859
|
}
|
|
@@ -24090,7 +24101,7 @@ function safeLog3(span, event) {
|
|
|
24090
24101
|
}
|
|
24091
24102
|
}
|
|
24092
24103
|
function logInstrumentationError3(context, error) {
|
|
24093
|
-
|
|
24104
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error processing ${context}:`, error);
|
|
24094
24105
|
}
|
|
24095
24106
|
function cleanMetrics2(metrics) {
|
|
24096
24107
|
const cleaned = {};
|
|
@@ -24216,17 +24227,17 @@ var OpenAIAgentsTraceProcessor = (_class22 = class _OpenAIAgentsTraceProcessor {
|
|
|
24216
24227
|
this.evictOldestTrace();
|
|
24217
24228
|
}
|
|
24218
24229
|
const current = currentSpan();
|
|
24219
|
-
const spanArgs =
|
|
24230
|
+
const spanArgs = _chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
24220
24231
|
{
|
|
24221
24232
|
name: trace.name,
|
|
24222
24233
|
type: "task" /* TASK */
|
|
24223
24234
|
},
|
|
24224
|
-
|
|
24235
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI_AGENTS
|
|
24225
24236
|
);
|
|
24226
24237
|
const span = current && current !== NOOP_SPAN ? current.startSpan(spanArgs) : this.logger ? this.logger.startSpan(spanArgs) : startSpan(
|
|
24227
|
-
|
|
24238
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
24228
24239
|
spanArgs,
|
|
24229
|
-
|
|
24240
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI_AGENTS
|
|
24230
24241
|
)
|
|
24231
24242
|
);
|
|
24232
24243
|
span.log({
|
|
@@ -24280,12 +24291,12 @@ var OpenAIAgentsTraceProcessor = (_class22 = class _OpenAIAgentsTraceProcessor {
|
|
|
24280
24291
|
return Promise.resolve();
|
|
24281
24292
|
}
|
|
24282
24293
|
const childSpan = parentSpan.startSpan(
|
|
24283
|
-
|
|
24294
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
24284
24295
|
{
|
|
24285
24296
|
name: spanNameFromAgents(span),
|
|
24286
24297
|
type: spanTypeFromAgents(span)
|
|
24287
24298
|
},
|
|
24288
|
-
|
|
24299
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.OPENAI_AGENTS
|
|
24289
24300
|
)
|
|
24290
24301
|
);
|
|
24291
24302
|
traceData.childSpans.set(span.spanId, childSpan);
|
|
@@ -24498,7 +24509,7 @@ var OpenAIAgentsPlugin = (_class23 = class extends BasePlugin {constructor(...ar
|
|
|
24498
24509
|
void this.processor.shutdown();
|
|
24499
24510
|
}
|
|
24500
24511
|
subscribeToTraceLifecycle() {
|
|
24501
|
-
const traceStartChannel =
|
|
24512
|
+
const traceStartChannel = _chunk4AQGZS6Xjs.openAIAgentsCoreChannels.onTraceStart.tracingChannel();
|
|
24502
24513
|
const traceStartHandlers = {
|
|
24503
24514
|
start: (event) => {
|
|
24504
24515
|
const trace = firstArgument(event.arguments);
|
|
@@ -24511,7 +24522,7 @@ var OpenAIAgentsPlugin = (_class23 = class extends BasePlugin {constructor(...ar
|
|
|
24511
24522
|
this.unsubscribers.push(
|
|
24512
24523
|
() => traceStartChannel.unsubscribe(traceStartHandlers)
|
|
24513
24524
|
);
|
|
24514
|
-
const traceEndChannel =
|
|
24525
|
+
const traceEndChannel = _chunk4AQGZS6Xjs.openAIAgentsCoreChannels.onTraceEnd.tracingChannel();
|
|
24515
24526
|
const traceEndHandlers = {
|
|
24516
24527
|
start: (event) => {
|
|
24517
24528
|
const trace = firstArgument(event.arguments);
|
|
@@ -24524,7 +24535,7 @@ var OpenAIAgentsPlugin = (_class23 = class extends BasePlugin {constructor(...ar
|
|
|
24524
24535
|
this.unsubscribers.push(
|
|
24525
24536
|
() => traceEndChannel.unsubscribe(traceEndHandlers)
|
|
24526
24537
|
);
|
|
24527
|
-
const spanStartChannel =
|
|
24538
|
+
const spanStartChannel = _chunk4AQGZS6Xjs.openAIAgentsCoreChannels.onSpanStart.tracingChannel();
|
|
24528
24539
|
const spanStartHandlers = {
|
|
24529
24540
|
start: (event) => {
|
|
24530
24541
|
const span = firstArgument(event.arguments);
|
|
@@ -24537,7 +24548,7 @@ var OpenAIAgentsPlugin = (_class23 = class extends BasePlugin {constructor(...ar
|
|
|
24537
24548
|
this.unsubscribers.push(
|
|
24538
24549
|
() => spanStartChannel.unsubscribe(spanStartHandlers)
|
|
24539
24550
|
);
|
|
24540
|
-
const spanEndChannel =
|
|
24551
|
+
const spanEndChannel = _chunk4AQGZS6Xjs.openAIAgentsCoreChannels.onSpanEnd.tracingChannel();
|
|
24541
24552
|
const spanEndHandlers = {
|
|
24542
24553
|
start: (event) => {
|
|
24543
24554
|
const span = firstArgument(event.arguments);
|
|
@@ -24578,7 +24589,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24578
24589
|
this.subscribeToInteractionsCreateChannel();
|
|
24579
24590
|
}
|
|
24580
24591
|
subscribeToGenerateContentChannel() {
|
|
24581
|
-
const tracingChannel =
|
|
24592
|
+
const tracingChannel = _chunk4AQGZS6Xjs.googleGenAIChannels.generateContent.tracingChannel();
|
|
24582
24593
|
const states = /* @__PURE__ */ new WeakMap();
|
|
24583
24594
|
const unbindCurrentSpanStore = bindCurrentSpanStoreToStart2(
|
|
24584
24595
|
tracingChannel,
|
|
@@ -24588,7 +24599,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24588
24599
|
const input = serializeGenerateContentInput(params);
|
|
24589
24600
|
const metadata = extractGenerateContentMetadata(params);
|
|
24590
24601
|
const span = startSpan(
|
|
24591
|
-
|
|
24602
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
24592
24603
|
{
|
|
24593
24604
|
name: "generate_content",
|
|
24594
24605
|
spanAttributes: {
|
|
@@ -24596,7 +24607,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24596
24607
|
},
|
|
24597
24608
|
event: createWrapperParityEvent({ input, metadata })
|
|
24598
24609
|
},
|
|
24599
|
-
|
|
24610
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GOOGLE_GENAI
|
|
24600
24611
|
)
|
|
24601
24612
|
);
|
|
24602
24613
|
return {
|
|
@@ -24612,7 +24623,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24612
24623
|
const input = serializeGenerateContentInput(params);
|
|
24613
24624
|
const metadata = extractGenerateContentMetadata(params);
|
|
24614
24625
|
const span = startSpan(
|
|
24615
|
-
|
|
24626
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
24616
24627
|
{
|
|
24617
24628
|
name: "generate_content",
|
|
24618
24629
|
spanAttributes: {
|
|
@@ -24620,7 +24631,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24620
24631
|
},
|
|
24621
24632
|
event: createWrapperParityEvent({ input, metadata })
|
|
24622
24633
|
},
|
|
24623
|
-
|
|
24634
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GOOGLE_GENAI
|
|
24624
24635
|
)
|
|
24625
24636
|
);
|
|
24626
24637
|
return {
|
|
@@ -24662,7 +24673,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24662
24673
|
});
|
|
24663
24674
|
}
|
|
24664
24675
|
subscribeToGenerateContentStreamChannel() {
|
|
24665
|
-
const tracingChannel =
|
|
24676
|
+
const tracingChannel = _chunk4AQGZS6Xjs.googleGenAIChannels.generateContentStream.tracingChannel();
|
|
24666
24677
|
const handlers = {
|
|
24667
24678
|
start: (event) => {
|
|
24668
24679
|
const streamEvent = event;
|
|
@@ -24689,7 +24700,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24689
24700
|
});
|
|
24690
24701
|
}
|
|
24691
24702
|
subscribeToEmbedContentChannel() {
|
|
24692
|
-
const tracingChannel =
|
|
24703
|
+
const tracingChannel = _chunk4AQGZS6Xjs.googleGenAIChannels.embedContent.tracingChannel();
|
|
24693
24704
|
const states = /* @__PURE__ */ new WeakMap();
|
|
24694
24705
|
const unbindCurrentSpanStore = bindCurrentSpanStoreToStart2(
|
|
24695
24706
|
tracingChannel,
|
|
@@ -24699,7 +24710,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24699
24710
|
const input = serializeEmbedContentInput(params);
|
|
24700
24711
|
const metadata = extractEmbedContentMetadata(params);
|
|
24701
24712
|
const span = startSpan(
|
|
24702
|
-
|
|
24713
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
24703
24714
|
{
|
|
24704
24715
|
name: "embed_content",
|
|
24705
24716
|
spanAttributes: {
|
|
@@ -24707,7 +24718,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24707
24718
|
},
|
|
24708
24719
|
event: createWrapperParityEvent({ input, metadata })
|
|
24709
24720
|
},
|
|
24710
|
-
|
|
24721
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GOOGLE_GENAI
|
|
24711
24722
|
)
|
|
24712
24723
|
);
|
|
24713
24724
|
return {
|
|
@@ -24723,7 +24734,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24723
24734
|
const input = serializeEmbedContentInput(params);
|
|
24724
24735
|
const metadata = extractEmbedContentMetadata(params);
|
|
24725
24736
|
const span = startSpan(
|
|
24726
|
-
|
|
24737
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
24727
24738
|
{
|
|
24728
24739
|
name: "embed_content",
|
|
24729
24740
|
spanAttributes: {
|
|
@@ -24731,7 +24742,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24731
24742
|
},
|
|
24732
24743
|
event: createWrapperParityEvent({ input, metadata })
|
|
24733
24744
|
},
|
|
24734
|
-
|
|
24745
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GOOGLE_GENAI
|
|
24735
24746
|
)
|
|
24736
24747
|
);
|
|
24737
24748
|
return {
|
|
@@ -24771,7 +24782,7 @@ var GoogleGenAIPlugin = class extends BasePlugin {
|
|
|
24771
24782
|
subscribeToInteractionsCreateChannel() {
|
|
24772
24783
|
this.unsubscribers.push(
|
|
24773
24784
|
traceStreamingChannel(
|
|
24774
|
-
|
|
24785
|
+
_chunk4AQGZS6Xjs.googleGenAIChannels.interactionsCreate,
|
|
24775
24786
|
{
|
|
24776
24787
|
name: "create_interaction",
|
|
24777
24788
|
shouldTrace: ([params]) => !isBackgroundInteractionCreate(params),
|
|
@@ -24845,7 +24856,7 @@ function patchGoogleGenAIStreamingResult(args) {
|
|
|
24845
24856
|
const ensureSpan = () => {
|
|
24846
24857
|
if (!span) {
|
|
24847
24858
|
span = startSpan(
|
|
24848
|
-
|
|
24859
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
24849
24860
|
{
|
|
24850
24861
|
name: "generate_content_stream",
|
|
24851
24862
|
spanAttributes: {
|
|
@@ -24856,7 +24867,7 @@ function patchGoogleGenAIStreamingResult(args) {
|
|
|
24856
24867
|
metadata
|
|
24857
24868
|
}
|
|
24858
24869
|
},
|
|
24859
|
-
|
|
24870
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GOOGLE_GENAI
|
|
24860
24871
|
)
|
|
24861
24872
|
);
|
|
24862
24873
|
}
|
|
@@ -25681,7 +25692,7 @@ var RESPONSE_METADATA_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
|
25681
25692
|
var HuggingFacePlugin = class extends BasePlugin {
|
|
25682
25693
|
onEnable() {
|
|
25683
25694
|
this.unsubscribers.push(
|
|
25684
|
-
traceAsyncChannel(
|
|
25695
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.huggingFaceChannels.chatCompletion, {
|
|
25685
25696
|
name: "huggingface.chat_completion",
|
|
25686
25697
|
type: "llm" /* LLM */,
|
|
25687
25698
|
extractInput: extractChatInputWithMetadata,
|
|
@@ -25689,7 +25700,7 @@ var HuggingFacePlugin = class extends BasePlugin {
|
|
|
25689
25700
|
extractMetadata: (result) => extractResponseMetadata2(result),
|
|
25690
25701
|
extractMetrics: (result) => parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _673 => _673.usage]))
|
|
25691
25702
|
}),
|
|
25692
|
-
traceSyncStreamChannel(
|
|
25703
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.huggingFaceChannels.chatCompletionStream, {
|
|
25693
25704
|
name: "huggingface.chat_completion_stream",
|
|
25694
25705
|
type: "llm" /* LLM */,
|
|
25695
25706
|
extractInput: extractChatInputWithMetadata,
|
|
@@ -25699,7 +25710,7 @@ var HuggingFacePlugin = class extends BasePlugin {
|
|
|
25699
25710
|
startTime
|
|
25700
25711
|
})
|
|
25701
25712
|
}),
|
|
25702
|
-
traceAsyncChannel(
|
|
25713
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.huggingFaceChannels.textGeneration, {
|
|
25703
25714
|
name: "huggingface.text_generation",
|
|
25704
25715
|
type: "llm" /* LLM */,
|
|
25705
25716
|
extractInput: extractTextGenerationInputWithMetadata,
|
|
@@ -25707,7 +25718,7 @@ var HuggingFacePlugin = class extends BasePlugin {
|
|
|
25707
25718
|
extractMetadata: extractTextGenerationMetadata,
|
|
25708
25719
|
extractMetrics: (result) => extractTextGenerationMetrics(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _674 => _674.details]), () => ( null)))
|
|
25709
25720
|
}),
|
|
25710
|
-
traceSyncStreamChannel(
|
|
25721
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.huggingFaceChannels.textGenerationStream, {
|
|
25711
25722
|
name: "huggingface.text_generation_stream",
|
|
25712
25723
|
type: "llm" /* LLM */,
|
|
25713
25724
|
extractInput: extractTextGenerationInputWithMetadata,
|
|
@@ -25717,7 +25728,7 @@ var HuggingFacePlugin = class extends BasePlugin {
|
|
|
25717
25728
|
startTime
|
|
25718
25729
|
})
|
|
25719
25730
|
}),
|
|
25720
|
-
traceAsyncChannel(
|
|
25731
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.huggingFaceChannels.featureExtraction, {
|
|
25721
25732
|
name: "huggingface.feature_extraction",
|
|
25722
25733
|
type: "llm" /* LLM */,
|
|
25723
25734
|
extractInput: extractFeatureExtractionInputWithMetadata,
|
|
@@ -26091,14 +26102,14 @@ var HuggingFaceTransformersPlugin = class extends BasePlugin {
|
|
|
26091
26102
|
onEnable() {
|
|
26092
26103
|
this.subscribeToPipelineFactory();
|
|
26093
26104
|
this.unsubscribers.push(
|
|
26094
|
-
traceAsyncChannel(
|
|
26105
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.huggingFaceTransformersChannels.pipelineCall, {
|
|
26095
26106
|
name: (_args, event) => {
|
|
26096
26107
|
const task = getTask(event);
|
|
26097
26108
|
const operation = _nullishCoalesce(_optionalChain([task, 'optionalAccess', _689 => _689.replaceAll, 'call', _690 => _690("-", "_")]), () => ( "unknown"));
|
|
26098
26109
|
return `huggingface.transformers.${operation}`;
|
|
26099
26110
|
},
|
|
26100
26111
|
type: "llm" /* LLM */,
|
|
26101
|
-
shouldTrace: (_args, event) =>
|
|
26112
|
+
shouldTrace: (_args, event) => _chunk4AQGZS6Xjs.isSupportedHuggingFaceTransformersTask.call(void 0,
|
|
26102
26113
|
getTask(event)
|
|
26103
26114
|
),
|
|
26104
26115
|
extractInput: (args, event) => ({
|
|
@@ -26123,13 +26134,13 @@ var HuggingFaceTransformersPlugin = class extends BasePlugin {
|
|
|
26123
26134
|
this.unsubscribers = unsubscribeAll(this.unsubscribers);
|
|
26124
26135
|
}
|
|
26125
26136
|
subscribeToPipelineFactory() {
|
|
26126
|
-
const channel =
|
|
26137
|
+
const channel = _chunk4AQGZS6Xjs.huggingFaceTransformersChannels.pipeline.tracingChannel();
|
|
26127
26138
|
const handlers = {
|
|
26128
26139
|
asyncEnd: (event) => {
|
|
26129
26140
|
if (typeof event.result !== "function") {
|
|
26130
26141
|
return;
|
|
26131
26142
|
}
|
|
26132
|
-
|
|
26143
|
+
_chunk4AQGZS6Xjs.registerHuggingFaceTransformersPipeline.call(void 0,
|
|
26133
26144
|
event.result,
|
|
26134
26145
|
_optionalChain([event, 'access', _691 => _691.arguments, 'optionalAccess', _692 => _692[0]]),
|
|
26135
26146
|
_optionalChain([event, 'access', _693 => _693.arguments, 'optionalAccess', _694 => _694[1]])
|
|
@@ -26142,7 +26153,7 @@ var HuggingFaceTransformersPlugin = class extends BasePlugin {
|
|
|
26142
26153
|
};
|
|
26143
26154
|
function getTask(event) {
|
|
26144
26155
|
const self = event.self;
|
|
26145
|
-
const registeredTask = _optionalChain([
|
|
26156
|
+
const registeredTask = _optionalChain([_chunk4AQGZS6Xjs.getHuggingFaceTransformersPipelineInfo.call(void 0, self), 'optionalAccess', _695 => _695.task]);
|
|
26146
26157
|
if (registeredTask !== void 0) {
|
|
26147
26158
|
return registeredTask;
|
|
26148
26159
|
}
|
|
@@ -26155,7 +26166,7 @@ function extractMetadata(event, args) {
|
|
|
26155
26166
|
const metadata = {
|
|
26156
26167
|
provider: "huggingface"
|
|
26157
26168
|
};
|
|
26158
|
-
const registeredModel = _optionalChain([
|
|
26169
|
+
const registeredModel = _optionalChain([_chunk4AQGZS6Xjs.getHuggingFaceTransformersPipelineInfo.call(void 0,
|
|
26159
26170
|
event.self
|
|
26160
26171
|
), 'optionalAccess', _697 => _697.model]);
|
|
26161
26172
|
const model = _nullishCoalesce(registeredModel, () => ( modelIdentifier(event.self)));
|
|
@@ -26343,7 +26354,7 @@ var OpenRouterAgentPlugin = class extends BasePlugin {
|
|
|
26343
26354
|
}
|
|
26344
26355
|
subscribeToOpenRouterAgentChannels() {
|
|
26345
26356
|
this.unsubscribers.push(
|
|
26346
|
-
traceSyncStreamChannel(
|
|
26357
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.openRouterAgentChannels.callModel, {
|
|
26347
26358
|
name: "openrouter.callModel",
|
|
26348
26359
|
type: "task" /* TASK */,
|
|
26349
26360
|
extractInput: (args) => {
|
|
@@ -26363,7 +26374,7 @@ var OpenRouterAgentPlugin = class extends BasePlugin {
|
|
|
26363
26374
|
})
|
|
26364
26375
|
);
|
|
26365
26376
|
this.unsubscribers.push(
|
|
26366
|
-
traceAsyncChannel(
|
|
26377
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.openRouterAgentChannels.callModelTurn, {
|
|
26367
26378
|
name: "openrouter.beta.responses.send",
|
|
26368
26379
|
type: "llm" /* LLM */,
|
|
26369
26380
|
extractInput: (args, event) => {
|
|
@@ -26399,7 +26410,7 @@ var OpenRouterAgentPlugin = class extends BasePlugin {
|
|
|
26399
26410
|
})
|
|
26400
26411
|
);
|
|
26401
26412
|
this.unsubscribers.push(
|
|
26402
|
-
traceStreamingChannel(
|
|
26413
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.openRouterAgentChannels.toolExecute, {
|
|
26403
26414
|
name: "openrouter.tool",
|
|
26404
26415
|
type: "tool" /* TOOL */,
|
|
26405
26416
|
extractInput: (args, event) => ({
|
|
@@ -26418,7 +26429,7 @@ var OpenRouterAgentPlugin = class extends BasePlugin {
|
|
|
26418
26429
|
})
|
|
26419
26430
|
})
|
|
26420
26431
|
);
|
|
26421
|
-
const callModelChannel =
|
|
26432
|
+
const callModelChannel = _chunk4AQGZS6Xjs.openRouterAgentChannels.callModel.tracingChannel();
|
|
26422
26433
|
const callModelHandlers = {
|
|
26423
26434
|
start: (event) => {
|
|
26424
26435
|
const request = getOpenRouterCallModelRequestArg(event.arguments);
|
|
@@ -26712,7 +26723,7 @@ function isWrappedTool(tool) {
|
|
|
26712
26723
|
return Boolean(tool[OPENROUTER_WRAPPED_TOOL]);
|
|
26713
26724
|
}
|
|
26714
26725
|
function traceToolExecution(args) {
|
|
26715
|
-
const tracingChannel =
|
|
26726
|
+
const tracingChannel = _chunk4AQGZS6Xjs.openRouterAgentChannels.toolExecute.tracingChannel();
|
|
26716
26727
|
const input = args.args.length > 0 ? args.args[0] : void 0;
|
|
26717
26728
|
const event = {
|
|
26718
26729
|
arguments: [input],
|
|
@@ -26967,7 +26978,7 @@ async function traceOpenRouterCallModelTurn(args) {
|
|
|
26967
26978
|
};
|
|
26968
26979
|
return await withCurrent(
|
|
26969
26980
|
args.parentSpan,
|
|
26970
|
-
() =>
|
|
26981
|
+
() => _chunk4AQGZS6Xjs.openRouterAgentChannels.callModelTurn.tracePromise(args.fn, context)
|
|
26971
26982
|
);
|
|
26972
26983
|
}
|
|
26973
26984
|
function isWrappedCallModelResult(value) {
|
|
@@ -27110,7 +27121,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
27110
27121
|
}
|
|
27111
27122
|
subscribeToOpenRouterChannels() {
|
|
27112
27123
|
this.unsubscribers.push(
|
|
27113
|
-
traceStreamingChannel(
|
|
27124
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.openRouterChannels.chatSend, {
|
|
27114
27125
|
name: "openrouter.chat.send",
|
|
27115
27126
|
type: "llm" /* LLM */,
|
|
27116
27127
|
extractInput: (args) => {
|
|
@@ -27138,7 +27149,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
27138
27149
|
})
|
|
27139
27150
|
);
|
|
27140
27151
|
this.unsubscribers.push(
|
|
27141
|
-
traceAsyncChannel(
|
|
27152
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.openRouterChannels.embeddingsGenerate, {
|
|
27142
27153
|
name: "openrouter.embeddings.generate",
|
|
27143
27154
|
type: "llm" /* LLM */,
|
|
27144
27155
|
extractInput: (args) => {
|
|
@@ -27175,7 +27186,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
27175
27186
|
})
|
|
27176
27187
|
);
|
|
27177
27188
|
this.unsubscribers.push(
|
|
27178
|
-
traceAsyncChannel(
|
|
27189
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.openRouterChannels.rerankRerank, {
|
|
27179
27190
|
name: "openrouter.rerank.rerank",
|
|
27180
27191
|
type: "llm" /* LLM */,
|
|
27181
27192
|
extractInput: (args) => {
|
|
@@ -27203,7 +27214,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
27203
27214
|
})
|
|
27204
27215
|
);
|
|
27205
27216
|
this.unsubscribers.push(
|
|
27206
|
-
traceStreamingChannel(
|
|
27217
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.openRouterChannels.betaResponsesSend, {
|
|
27207
27218
|
name: "openrouter.beta.responses.send",
|
|
27208
27219
|
type: "llm" /* LLM */,
|
|
27209
27220
|
extractInput: (args) => {
|
|
@@ -27230,7 +27241,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
27230
27241
|
})
|
|
27231
27242
|
);
|
|
27232
27243
|
this.unsubscribers.push(
|
|
27233
|
-
traceSyncStreamChannel(
|
|
27244
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.openRouterChannels.callModel, {
|
|
27234
27245
|
name: "openrouter.callModel",
|
|
27235
27246
|
type: "task" /* TASK */,
|
|
27236
27247
|
extractInput: (args) => {
|
|
@@ -27250,7 +27261,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
27250
27261
|
})
|
|
27251
27262
|
);
|
|
27252
27263
|
this.unsubscribers.push(
|
|
27253
|
-
traceAsyncChannel(
|
|
27264
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.openRouterChannels.callModelTurn, {
|
|
27254
27265
|
name: "openrouter.beta.responses.send",
|
|
27255
27266
|
type: "llm" /* LLM */,
|
|
27256
27267
|
extractInput: (args, event) => {
|
|
@@ -27286,7 +27297,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
27286
27297
|
})
|
|
27287
27298
|
);
|
|
27288
27299
|
this.unsubscribers.push(
|
|
27289
|
-
traceStreamingChannel(
|
|
27300
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.openRouterChannels.toolExecute, {
|
|
27290
27301
|
name: "openrouter.tool",
|
|
27291
27302
|
type: "tool" /* TOOL */,
|
|
27292
27303
|
extractInput: (args, event) => ({
|
|
@@ -27305,7 +27316,7 @@ var OpenRouterPlugin = class extends BasePlugin {
|
|
|
27305
27316
|
})
|
|
27306
27317
|
})
|
|
27307
27318
|
);
|
|
27308
|
-
const callModelChannel =
|
|
27319
|
+
const callModelChannel = _chunk4AQGZS6Xjs.openRouterChannels.callModel.tracingChannel();
|
|
27309
27320
|
const callModelHandlers = {
|
|
27310
27321
|
start: (event) => {
|
|
27311
27322
|
const request = getOpenRouterCallModelRequestArg2(event.arguments);
|
|
@@ -27618,7 +27629,7 @@ function isWrappedTool2(tool) {
|
|
|
27618
27629
|
return Boolean(tool[OPENROUTER_WRAPPED_TOOL2]);
|
|
27619
27630
|
}
|
|
27620
27631
|
function traceToolExecution2(args) {
|
|
27621
|
-
const tracingChannel =
|
|
27632
|
+
const tracingChannel = _chunk4AQGZS6Xjs.openRouterChannels.toolExecute.tracingChannel();
|
|
27622
27633
|
const input = args.args.length > 0 ? args.args[0] : void 0;
|
|
27623
27634
|
const event = {
|
|
27624
27635
|
arguments: [input],
|
|
@@ -28004,7 +28015,7 @@ async function traceOpenRouterCallModelTurn2(args) {
|
|
|
28004
28015
|
};
|
|
28005
28016
|
return await withCurrent(
|
|
28006
28017
|
args.parentSpan,
|
|
28007
|
-
() =>
|
|
28018
|
+
() => _chunk4AQGZS6Xjs.openRouterChannels.callModelTurn.tracePromise(args.fn, context)
|
|
28008
28019
|
);
|
|
28009
28020
|
}
|
|
28010
28021
|
function isWrappedCallModelResult2(value) {
|
|
@@ -28147,7 +28158,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28147
28158
|
}
|
|
28148
28159
|
subscribeToMistralChannels() {
|
|
28149
28160
|
this.unsubscribers.push(
|
|
28150
|
-
traceStreamingChannel(
|
|
28161
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.mistralChannels.chatComplete, {
|
|
28151
28162
|
name: "mistral.chat.complete",
|
|
28152
28163
|
type: "llm" /* LLM */,
|
|
28153
28164
|
extractInput: extractMessagesInputWithMetadata,
|
|
@@ -28159,7 +28170,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28159
28170
|
})
|
|
28160
28171
|
);
|
|
28161
28172
|
this.unsubscribers.push(
|
|
28162
|
-
traceStreamingChannel(
|
|
28173
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.mistralChannels.chatStream, {
|
|
28163
28174
|
name: "mistral.chat.stream",
|
|
28164
28175
|
type: "llm" /* LLM */,
|
|
28165
28176
|
extractInput: extractMessagesInputWithMetadata,
|
|
@@ -28170,7 +28181,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28170
28181
|
})
|
|
28171
28182
|
);
|
|
28172
28183
|
this.unsubscribers.push(
|
|
28173
|
-
traceAsyncChannel(
|
|
28184
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.mistralChannels.embeddingsCreate, {
|
|
28174
28185
|
name: "mistral.embeddings.create",
|
|
28175
28186
|
type: "llm" /* LLM */,
|
|
28176
28187
|
extractInput: extractEmbeddingInputWithMetadata,
|
|
@@ -28183,7 +28194,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28183
28194
|
})
|
|
28184
28195
|
);
|
|
28185
28196
|
this.unsubscribers.push(
|
|
28186
|
-
traceAsyncChannel(
|
|
28197
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.mistralChannels.classifiersModerate, {
|
|
28187
28198
|
name: "mistral.classifiers.moderate",
|
|
28188
28199
|
type: "llm" /* LLM */,
|
|
28189
28200
|
extractInput: extractClassifierInputWithMetadata,
|
|
@@ -28193,7 +28204,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28193
28204
|
})
|
|
28194
28205
|
);
|
|
28195
28206
|
this.unsubscribers.push(
|
|
28196
|
-
traceAsyncChannel(
|
|
28207
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.mistralChannels.classifiersModerateChat, {
|
|
28197
28208
|
name: "mistral.classifiers.moderateChat",
|
|
28198
28209
|
type: "llm" /* LLM */,
|
|
28199
28210
|
extractInput: extractClassifierInputWithMetadata,
|
|
@@ -28203,7 +28214,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28203
28214
|
})
|
|
28204
28215
|
);
|
|
28205
28216
|
this.unsubscribers.push(
|
|
28206
|
-
traceAsyncChannel(
|
|
28217
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.mistralChannels.classifiersClassify, {
|
|
28207
28218
|
name: "mistral.classifiers.classify",
|
|
28208
28219
|
type: "llm" /* LLM */,
|
|
28209
28220
|
extractInput: extractClassifierInputWithMetadata,
|
|
@@ -28213,7 +28224,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28213
28224
|
})
|
|
28214
28225
|
);
|
|
28215
28226
|
this.unsubscribers.push(
|
|
28216
|
-
traceAsyncChannel(
|
|
28227
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.mistralChannels.classifiersClassifyChat, {
|
|
28217
28228
|
name: "mistral.classifiers.classifyChat",
|
|
28218
28229
|
type: "llm" /* LLM */,
|
|
28219
28230
|
extractInput: extractClassifierInputWithMetadata,
|
|
@@ -28223,7 +28234,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28223
28234
|
})
|
|
28224
28235
|
);
|
|
28225
28236
|
this.unsubscribers.push(
|
|
28226
|
-
traceStreamingChannel(
|
|
28237
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.mistralChannels.fimComplete, {
|
|
28227
28238
|
name: "mistral.fim.complete",
|
|
28228
28239
|
type: "llm" /* LLM */,
|
|
28229
28240
|
extractInput: extractPromptInputWithMetadata,
|
|
@@ -28235,7 +28246,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28235
28246
|
})
|
|
28236
28247
|
);
|
|
28237
28248
|
this.unsubscribers.push(
|
|
28238
|
-
traceStreamingChannel(
|
|
28249
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.mistralChannels.fimStream, {
|
|
28239
28250
|
name: "mistral.fim.stream",
|
|
28240
28251
|
type: "llm" /* LLM */,
|
|
28241
28252
|
extractInput: extractPromptInputWithMetadata,
|
|
@@ -28246,7 +28257,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28246
28257
|
})
|
|
28247
28258
|
);
|
|
28248
28259
|
this.unsubscribers.push(
|
|
28249
|
-
traceStreamingChannel(
|
|
28260
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.mistralChannels.agentsComplete, {
|
|
28250
28261
|
name: "mistral.agents.complete",
|
|
28251
28262
|
type: "llm" /* LLM */,
|
|
28252
28263
|
extractInput: extractMessagesInputWithMetadata,
|
|
@@ -28258,7 +28269,7 @@ var MistralPlugin = class extends BasePlugin {
|
|
|
28258
28269
|
})
|
|
28259
28270
|
);
|
|
28260
28271
|
this.unsubscribers.push(
|
|
28261
|
-
traceStreamingChannel(
|
|
28272
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.mistralChannels.agentsStream, {
|
|
28262
28273
|
name: "mistral.agents.stream",
|
|
28263
28274
|
type: "llm" /* LLM */,
|
|
28264
28275
|
extractInput: extractMessagesInputWithMetadata,
|
|
@@ -28758,7 +28769,7 @@ function aggregateMistralStreamChunks(chunks) {
|
|
|
28758
28769
|
var OllamaPlugin = class extends BasePlugin {
|
|
28759
28770
|
onEnable() {
|
|
28760
28771
|
this.unsubscribers.push(
|
|
28761
|
-
traceStreamingChannel(
|
|
28772
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.ollamaChannels.chat, {
|
|
28762
28773
|
name: "ollama.chat",
|
|
28763
28774
|
type: "llm" /* LLM */,
|
|
28764
28775
|
extractInput: extractOllamaChatInput,
|
|
@@ -28770,7 +28781,7 @@ var OllamaPlugin = class extends BasePlugin {
|
|
|
28770
28781
|
extractMetrics: extractOllamaMetrics,
|
|
28771
28782
|
aggregateChunks: aggregateOllamaChatChunks
|
|
28772
28783
|
}),
|
|
28773
|
-
traceStreamingChannel(
|
|
28784
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.ollamaChannels.generate, {
|
|
28774
28785
|
name: "ollama.generate",
|
|
28775
28786
|
type: "llm" /* LLM */,
|
|
28776
28787
|
extractInput: extractOllamaGenerateInput,
|
|
@@ -28779,7 +28790,7 @@ var OllamaPlugin = class extends BasePlugin {
|
|
|
28779
28790
|
extractMetrics: extractOllamaMetrics,
|
|
28780
28791
|
aggregateChunks: aggregateOllamaGenerateChunks
|
|
28781
28792
|
}),
|
|
28782
|
-
traceAsyncChannel(
|
|
28793
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.ollamaChannels.embed, {
|
|
28783
28794
|
name: "ollama.embed",
|
|
28784
28795
|
type: "llm" /* LLM */,
|
|
28785
28796
|
extractInput: extractOllamaEmbedInput,
|
|
@@ -28909,9 +28920,9 @@ function normalizeTextAndImages(content, images) {
|
|
|
28909
28920
|
gif: "image/gif",
|
|
28910
28921
|
webp: "image/webp"
|
|
28911
28922
|
}[_nullishCoalesce(extension, () => ( ""))];
|
|
28912
|
-
if (extensionMediaType &&
|
|
28923
|
+
if (extensionMediaType && _chunk4AQGZS6Xjs.isomorph_default.statSync) {
|
|
28913
28924
|
try {
|
|
28914
|
-
if (
|
|
28925
|
+
if (_chunk4AQGZS6Xjs.isomorph_default.statSync(image).isFile()) {
|
|
28915
28926
|
localImagePath = image;
|
|
28916
28927
|
localPathMediaType = extensionMediaType;
|
|
28917
28928
|
}
|
|
@@ -29216,20 +29227,20 @@ var GoogleADKPlugin = (_class24 = class extends BasePlugin {constructor(...args6
|
|
|
29216
29227
|
this.activeAgentSpans.clear();
|
|
29217
29228
|
}
|
|
29218
29229
|
subscribeToRunnerRunAsync() {
|
|
29219
|
-
const tracingChannel =
|
|
29230
|
+
const tracingChannel = _chunk4AQGZS6Xjs.googleADKChannels.runnerRunAsync.tracingChannel();
|
|
29220
29231
|
const states = /* @__PURE__ */ new WeakMap();
|
|
29221
29232
|
const createState = (event) => {
|
|
29222
29233
|
const params = _nullishCoalesce(event.arguments[0], () => ( {}));
|
|
29223
29234
|
const contextKey = extractRunnerContextKey(params);
|
|
29224
29235
|
const span = startSpan(
|
|
29225
|
-
|
|
29236
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
29226
29237
|
{
|
|
29227
29238
|
name: "Google ADK Runner",
|
|
29228
29239
|
spanAttributes: {
|
|
29229
29240
|
type: "task" /* TASK */
|
|
29230
29241
|
}
|
|
29231
29242
|
},
|
|
29232
|
-
|
|
29243
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GOOGLE_ADK
|
|
29233
29244
|
)
|
|
29234
29245
|
);
|
|
29235
29246
|
const startTime = getCurrentUnixTimestamp();
|
|
@@ -29306,7 +29317,7 @@ var GoogleADKPlugin = (_class24 = class extends BasePlugin {constructor(...args6
|
|
|
29306
29317
|
});
|
|
29307
29318
|
}
|
|
29308
29319
|
subscribeToAgentRunAsync() {
|
|
29309
|
-
const tracingChannel =
|
|
29320
|
+
const tracingChannel = _chunk4AQGZS6Xjs.googleADKChannels.agentRunAsync.tracingChannel();
|
|
29310
29321
|
const states = /* @__PURE__ */ new WeakMap();
|
|
29311
29322
|
const createState = (event) => {
|
|
29312
29323
|
const parentContext = event.arguments[0];
|
|
@@ -29318,7 +29329,7 @@ var GoogleADKPlugin = (_class24 = class extends BasePlugin {constructor(...args6
|
|
|
29318
29329
|
);
|
|
29319
29330
|
const contextKey = extractInvocationContextKey(parentContext);
|
|
29320
29331
|
const span = startSpan(
|
|
29321
|
-
|
|
29332
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
29322
29333
|
{
|
|
29323
29334
|
name: agentName ? `Agent: ${agentName}` : "Google ADK Agent",
|
|
29324
29335
|
spanAttributes: {
|
|
@@ -29331,7 +29342,7 @@ var GoogleADKPlugin = (_class24 = class extends BasePlugin {constructor(...args6
|
|
|
29331
29342
|
}
|
|
29332
29343
|
} : {}
|
|
29333
29344
|
},
|
|
29334
|
-
|
|
29345
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GOOGLE_ADK
|
|
29335
29346
|
)
|
|
29336
29347
|
);
|
|
29337
29348
|
const startTime = getCurrentUnixTimestamp();
|
|
@@ -29414,7 +29425,7 @@ var GoogleADKPlugin = (_class24 = class extends BasePlugin {constructor(...args6
|
|
|
29414
29425
|
});
|
|
29415
29426
|
}
|
|
29416
29427
|
subscribeToToolRunAsync() {
|
|
29417
|
-
const tracingChannel =
|
|
29428
|
+
const tracingChannel = _chunk4AQGZS6Xjs.googleADKChannels.toolRunAsync.tracingChannel();
|
|
29418
29429
|
const states = /* @__PURE__ */ new WeakMap();
|
|
29419
29430
|
const handlers = {
|
|
29420
29431
|
start: (event) => {
|
|
@@ -29427,7 +29438,7 @@ var GoogleADKPlugin = (_class24 = class extends BasePlugin {constructor(...args6
|
|
|
29427
29438
|
this.activeRunnerSpans
|
|
29428
29439
|
);
|
|
29429
29440
|
const createSpan = () => startSpan(
|
|
29430
|
-
|
|
29441
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
29431
29442
|
{
|
|
29432
29443
|
name: toolName ? `tool: ${toolName}` : "Google ADK Tool",
|
|
29433
29444
|
spanAttributes: {
|
|
@@ -29444,7 +29455,7 @@ var GoogleADKPlugin = (_class24 = class extends BasePlugin {constructor(...args6
|
|
|
29444
29455
|
}
|
|
29445
29456
|
}
|
|
29446
29457
|
},
|
|
29447
|
-
|
|
29458
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GOOGLE_ADK
|
|
29448
29459
|
)
|
|
29449
29460
|
);
|
|
29450
29461
|
const span = parentSpan ? withCurrent(parentSpan, () => createSpan()) : createSpan();
|
|
@@ -29884,7 +29895,7 @@ var CoherePlugin = class extends BasePlugin {
|
|
|
29884
29895
|
}
|
|
29885
29896
|
subscribeToCohereChannels() {
|
|
29886
29897
|
this.unsubscribers.push(
|
|
29887
|
-
traceStreamingChannel(
|
|
29898
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.cohereChannels.chat, {
|
|
29888
29899
|
name: "cohere.chat",
|
|
29889
29900
|
type: "llm" /* LLM */,
|
|
29890
29901
|
extractInput: extractChatInputWithMetadata2,
|
|
@@ -29900,7 +29911,7 @@ var CoherePlugin = class extends BasePlugin {
|
|
|
29900
29911
|
})
|
|
29901
29912
|
);
|
|
29902
29913
|
this.unsubscribers.push(
|
|
29903
|
-
traceStreamingChannel(
|
|
29914
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.cohereChannels.chatStream, {
|
|
29904
29915
|
name: "cohere.chatStream",
|
|
29905
29916
|
type: "llm" /* LLM */,
|
|
29906
29917
|
extractInput: extractChatInputWithMetadata2,
|
|
@@ -29911,7 +29922,7 @@ var CoherePlugin = class extends BasePlugin {
|
|
|
29911
29922
|
})
|
|
29912
29923
|
);
|
|
29913
29924
|
this.unsubscribers.push(
|
|
29914
|
-
traceAsyncChannel(
|
|
29925
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.cohereChannels.embed, {
|
|
29915
29926
|
name: "cohere.embed",
|
|
29916
29927
|
type: "llm" /* LLM */,
|
|
29917
29928
|
extractInput: extractEmbedInputWithMetadata,
|
|
@@ -29921,7 +29932,7 @@ var CoherePlugin = class extends BasePlugin {
|
|
|
29921
29932
|
})
|
|
29922
29933
|
);
|
|
29923
29934
|
this.unsubscribers.push(
|
|
29924
|
-
traceAsyncChannel(
|
|
29935
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.cohereChannels.rerank, {
|
|
29925
29936
|
name: "cohere.rerank",
|
|
29926
29937
|
type: "llm" /* LLM */,
|
|
29927
29938
|
extractInput: extractRerankInputWithMetadata,
|
|
@@ -30544,7 +30555,7 @@ function aggregateCohereChatStreamChunks(chunks) {
|
|
|
30544
30555
|
var GroqPlugin = class extends BasePlugin {
|
|
30545
30556
|
onEnable() {
|
|
30546
30557
|
this.unsubscribers.push(
|
|
30547
|
-
traceStreamingChannel(
|
|
30558
|
+
traceStreamingChannel(_chunk4AQGZS6Xjs.groqChannels.chatCompletionsCreate, {
|
|
30548
30559
|
name: "groq.chat.completions.create",
|
|
30549
30560
|
type: "llm" /* LLM */,
|
|
30550
30561
|
extractInput: ([params]) => {
|
|
@@ -30566,7 +30577,7 @@ var GroqPlugin = class extends BasePlugin {
|
|
|
30566
30577
|
})
|
|
30567
30578
|
);
|
|
30568
30579
|
this.unsubscribers.push(
|
|
30569
|
-
traceAsyncChannel(
|
|
30580
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.groqChannels.embeddingsCreate, {
|
|
30570
30581
|
name: "groq.embeddings.create",
|
|
30571
30582
|
type: "llm" /* LLM */,
|
|
30572
30583
|
extractInput: ([params]) => {
|
|
@@ -30682,9 +30693,9 @@ var BedrockRuntimePlugin = class extends BasePlugin {
|
|
|
30682
30693
|
onEnable() {
|
|
30683
30694
|
this.unsubscribers.push(
|
|
30684
30695
|
...[
|
|
30685
|
-
|
|
30686
|
-
|
|
30687
|
-
|
|
30696
|
+
_chunk4AQGZS6Xjs.bedrockRuntimeChannels.clientSend,
|
|
30697
|
+
_chunk4AQGZS6Xjs.smithyCoreChannels.clientSend,
|
|
30698
|
+
_chunk4AQGZS6Xjs.smithyClientChannels.clientSend
|
|
30688
30699
|
].map((channel) => traceBedrockRuntimeClientSendChannel(channel))
|
|
30689
30700
|
);
|
|
30690
30701
|
}
|
|
@@ -31277,7 +31288,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
31277
31288
|
}
|
|
31278
31289
|
subscribeToGenkitChannels() {
|
|
31279
31290
|
this.unsubscribers.push(
|
|
31280
|
-
traceAsyncChannel(
|
|
31291
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.genkitChannels.generate, {
|
|
31281
31292
|
name: "genkit.generate",
|
|
31282
31293
|
type: "llm" /* LLM */,
|
|
31283
31294
|
extractInput: ([input]) => extractGenerateInput(input),
|
|
@@ -31287,7 +31298,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
31287
31298
|
})
|
|
31288
31299
|
);
|
|
31289
31300
|
this.unsubscribers.push(
|
|
31290
|
-
traceSyncStreamChannel(
|
|
31301
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.genkitChannels.generateStream, {
|
|
31291
31302
|
name: "genkit.generateStream",
|
|
31292
31303
|
type: "llm" /* LLM */,
|
|
31293
31304
|
extractInput: ([input]) => extractGenerateInput(input),
|
|
@@ -31295,7 +31306,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
31295
31306
|
})
|
|
31296
31307
|
);
|
|
31297
31308
|
this.unsubscribers.push(
|
|
31298
|
-
traceAsyncChannel(
|
|
31309
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.genkitChannels.embed, {
|
|
31299
31310
|
name: "genkit.embed",
|
|
31300
31311
|
type: "function" /* FUNCTION */,
|
|
31301
31312
|
extractInput: ([params]) => extractEmbedInput(params),
|
|
@@ -31305,7 +31316,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
31305
31316
|
})
|
|
31306
31317
|
);
|
|
31307
31318
|
this.unsubscribers.push(
|
|
31308
|
-
traceAsyncChannel(
|
|
31319
|
+
traceAsyncChannel(_chunk4AQGZS6Xjs.genkitChannels.embedMany, {
|
|
31309
31320
|
name: "genkit.embedMany",
|
|
31310
31321
|
type: "function" /* FUNCTION */,
|
|
31311
31322
|
extractInput: ([params]) => extractEmbedManyInput(params),
|
|
@@ -31319,7 +31330,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
31319
31330
|
this.subscribeToActionStream();
|
|
31320
31331
|
}
|
|
31321
31332
|
subscribeToActionRun() {
|
|
31322
|
-
const tracingChannel =
|
|
31333
|
+
const tracingChannel = _chunk4AQGZS6Xjs.genkitChannels.actionRun.tracingChannel();
|
|
31323
31334
|
const states = /* @__PURE__ */ new WeakMap();
|
|
31324
31335
|
const unbindCurrentSpanStore = bindActionCurrentSpanStoreToStart(
|
|
31325
31336
|
tracingChannel,
|
|
@@ -31366,7 +31377,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
31366
31377
|
});
|
|
31367
31378
|
}
|
|
31368
31379
|
subscribeToActionSpan() {
|
|
31369
|
-
const tracingChannel =
|
|
31380
|
+
const tracingChannel = _chunk4AQGZS6Xjs.genkitCoreChannels.actionSpan.tracingChannel();
|
|
31370
31381
|
const states = /* @__PURE__ */ new WeakMap();
|
|
31371
31382
|
const unbindCurrentSpanStore = bindActionCurrentSpanStoreToStart(
|
|
31372
31383
|
tracingChannel,
|
|
@@ -31415,7 +31426,7 @@ var GenkitPlugin = class extends BasePlugin {
|
|
|
31415
31426
|
}
|
|
31416
31427
|
subscribeToActionStream() {
|
|
31417
31428
|
this.unsubscribers.push(
|
|
31418
|
-
traceSyncStreamChannel(
|
|
31429
|
+
traceSyncStreamChannel(_chunk4AQGZS6Xjs.genkitChannels.actionStream, {
|
|
31419
31430
|
name: "genkit.action.stream",
|
|
31420
31431
|
type: "task" /* TASK */,
|
|
31421
31432
|
extractInput: ([input], event) => ({
|
|
@@ -31451,14 +31462,14 @@ function startActionSpanState(args) {
|
|
|
31451
31462
|
return void 0;
|
|
31452
31463
|
}
|
|
31453
31464
|
const span = startSpan(
|
|
31454
|
-
|
|
31465
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
31455
31466
|
{
|
|
31456
31467
|
name: actionSpanName(args.metadata, args.runStepName),
|
|
31457
31468
|
spanAttributes: {
|
|
31458
31469
|
type: actionSpanType(args.metadata)
|
|
31459
31470
|
}
|
|
31460
31471
|
},
|
|
31461
|
-
|
|
31472
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GENKIT
|
|
31462
31473
|
)
|
|
31463
31474
|
);
|
|
31464
31475
|
const startTime = getCurrentUnixTimestamp();
|
|
@@ -31910,13 +31921,13 @@ async function handleTurnStart(state, agentId) {
|
|
|
31910
31921
|
}
|
|
31911
31922
|
const parentId = await getParentIdForAgent(state, agentId);
|
|
31912
31923
|
const span = startSpan(
|
|
31913
|
-
|
|
31924
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
31914
31925
|
{
|
|
31915
31926
|
name: "Copilot Turn",
|
|
31916
31927
|
parent: parentId,
|
|
31917
31928
|
spanAttributes: { type: "task" /* TASK */ }
|
|
31918
31929
|
},
|
|
31919
|
-
|
|
31930
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GITHUB_COPILOT
|
|
31920
31931
|
)
|
|
31921
31932
|
);
|
|
31922
31933
|
const pendingUserMessage = state.pendingUserMessages.get(key);
|
|
@@ -31950,13 +31961,13 @@ async function handleUsage(state, agentId, usage) {
|
|
|
31950
31961
|
const content = state.currentMessageContent.get(key);
|
|
31951
31962
|
const { metrics, metadata } = extractMetricsFromUsage(usage);
|
|
31952
31963
|
const llmSpan = startSpan(
|
|
31953
|
-
|
|
31964
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
31954
31965
|
{
|
|
31955
31966
|
name: "github.copilot.llm",
|
|
31956
31967
|
parent: parentId,
|
|
31957
31968
|
spanAttributes: { type: "llm" /* LLM */ }
|
|
31958
31969
|
},
|
|
31959
|
-
|
|
31970
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GITHUB_COPILOT
|
|
31960
31971
|
)
|
|
31961
31972
|
);
|
|
31962
31973
|
llmSpan.log({
|
|
@@ -31985,13 +31996,13 @@ async function handleToolStart(state, agentId, toolCallId, toolName, args, mcpSe
|
|
|
31985
31996
|
const parentId = await getToolParentId(state, agentId);
|
|
31986
31997
|
const displayName = mcpServerName ? `tool: ${mcpServerName}/${toolName}` : `tool: ${toolName}`;
|
|
31987
31998
|
const span = startSpan(
|
|
31988
|
-
|
|
31999
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
31989
32000
|
{
|
|
31990
32001
|
name: displayName,
|
|
31991
32002
|
parent: parentId,
|
|
31992
32003
|
spanAttributes: { type: "tool" /* TOOL */ }
|
|
31993
32004
|
},
|
|
31994
|
-
|
|
32005
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GITHUB_COPILOT
|
|
31995
32006
|
)
|
|
31996
32007
|
);
|
|
31997
32008
|
const metadata = {
|
|
@@ -32030,13 +32041,13 @@ async function handleSubagentStarted(state, agentId, toolCallId, agentDisplayNam
|
|
|
32030
32041
|
const tool = state.activeTools.get(toolCallId);
|
|
32031
32042
|
const parentId = tool ? await tool.id : await state.session.id;
|
|
32032
32043
|
const span = startSpan(
|
|
32033
|
-
|
|
32044
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
32034
32045
|
{
|
|
32035
32046
|
name: `Agent: ${agentDisplayName}`,
|
|
32036
32047
|
parent: parentId,
|
|
32037
32048
|
spanAttributes: { type: "task" /* TASK */ }
|
|
32038
32049
|
},
|
|
32039
|
-
|
|
32050
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GITHUB_COPILOT
|
|
32040
32051
|
)
|
|
32041
32052
|
);
|
|
32042
32053
|
span.log({
|
|
@@ -32265,12 +32276,12 @@ function makeSessionHandlers(sessionStates, configArgIndex, includeProviderMetad
|
|
|
32265
32276
|
return;
|
|
32266
32277
|
}
|
|
32267
32278
|
const sessionSpan = startSpan(
|
|
32268
|
-
|
|
32279
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
32269
32280
|
{
|
|
32270
32281
|
name: "Copilot Session",
|
|
32271
32282
|
spanAttributes: { type: "task" /* TASK */ }
|
|
32272
32283
|
},
|
|
32273
|
-
|
|
32284
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.GITHUB_COPILOT
|
|
32274
32285
|
)
|
|
32275
32286
|
);
|
|
32276
32287
|
const metadata = {};
|
|
@@ -32333,8 +32344,8 @@ var GitHubCopilotPlugin = class extends BasePlugin {
|
|
|
32333
32344
|
this.unsubscribers = [];
|
|
32334
32345
|
}
|
|
32335
32346
|
subscribeToSessionChannels() {
|
|
32336
|
-
const createChannel =
|
|
32337
|
-
const resumeChannel =
|
|
32347
|
+
const createChannel = _chunk4AQGZS6Xjs.gitHubCopilotChannels.createSession.tracingChannel();
|
|
32348
|
+
const resumeChannel = _chunk4AQGZS6Xjs.gitHubCopilotChannels.resumeSession.tracingChannel();
|
|
32338
32349
|
const sessionStates = /* @__PURE__ */ new WeakMap();
|
|
32339
32350
|
const createHandlers = makeSessionHandlers(
|
|
32340
32351
|
sessionStates,
|
|
@@ -32363,8 +32374,8 @@ var GitHubCopilotPlugin = class extends BasePlugin {
|
|
|
32363
32374
|
var LangChainPlugin = (_class25 = class extends BasePlugin {constructor(...args7) { super(...args7); _class25.prototype.__init87.call(this); }
|
|
32364
32375
|
__init87() {this.injectedManagers = /* @__PURE__ */ new WeakSet()}
|
|
32365
32376
|
onEnable() {
|
|
32366
|
-
this.subscribeToConfigure(
|
|
32367
|
-
this.subscribeToConfigure(
|
|
32377
|
+
this.subscribeToConfigure(_chunk4AQGZS6Xjs.langChainChannels.configure);
|
|
32378
|
+
this.subscribeToConfigure(_chunk4AQGZS6Xjs.langChainChannels.configureSync);
|
|
32368
32379
|
}
|
|
32369
32380
|
onDisable() {
|
|
32370
32381
|
for (const unsubscribe of this.unsubscribers) {
|
|
@@ -32473,7 +32484,7 @@ var LangSmithPlugin = (_class26 = class extends BasePlugin {
|
|
|
32473
32484
|
this.skipLangChainRuns = _nullishCoalesce(options.skipLangChainRuns, () => ( true));
|
|
32474
32485
|
}
|
|
32475
32486
|
onEnable() {
|
|
32476
|
-
const createChannel =
|
|
32487
|
+
const createChannel = _chunk4AQGZS6Xjs.langSmithChannels.createRun.tracingChannel();
|
|
32477
32488
|
const createHandlers = {
|
|
32478
32489
|
start: (event) => {
|
|
32479
32490
|
this.containLifecycleFailure("createRun", () => {
|
|
@@ -32483,7 +32494,7 @@ var LangSmithPlugin = (_class26 = class extends BasePlugin {
|
|
|
32483
32494
|
};
|
|
32484
32495
|
createChannel.subscribe(createHandlers);
|
|
32485
32496
|
this.unsubscribers.push(() => createChannel.unsubscribe(createHandlers));
|
|
32486
|
-
const updateChannel =
|
|
32497
|
+
const updateChannel = _chunk4AQGZS6Xjs.langSmithChannels.updateRun.tracingChannel();
|
|
32487
32498
|
const updateHandlers = {
|
|
32488
32499
|
start: (event) => {
|
|
32489
32500
|
this.containLifecycleFailure("updateRun", () => {
|
|
@@ -32493,7 +32504,7 @@ var LangSmithPlugin = (_class26 = class extends BasePlugin {
|
|
|
32493
32504
|
};
|
|
32494
32505
|
updateChannel.subscribe(updateHandlers);
|
|
32495
32506
|
this.unsubscribers.push(() => updateChannel.unsubscribe(updateHandlers));
|
|
32496
|
-
const batchChannel =
|
|
32507
|
+
const batchChannel = _chunk4AQGZS6Xjs.langSmithChannels.batchIngestRuns.tracingChannel();
|
|
32497
32508
|
const batchHandlers = {
|
|
32498
32509
|
start: (event) => {
|
|
32499
32510
|
this.containLifecycleFailure("batchIngestRuns", () => {
|
|
@@ -32607,7 +32618,7 @@ var LangSmithPlugin = (_class26 = class extends BasePlugin {
|
|
|
32607
32618
|
const parentId = _nullishCoalesce(stringValue2(ownValue(run, "parent_run_id")), () => ( stringValue2(ownValue(ownValue(run, "parent_run"), "id"))));
|
|
32608
32619
|
const startTime = timestampSeconds(ownValue(run, "start_time"));
|
|
32609
32620
|
return startSpan(
|
|
32610
|
-
|
|
32621
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
32611
32622
|
{
|
|
32612
32623
|
name: _nullishCoalesce(stringValue2(ownValue(run, "name")), () => ( "LangSmith run")),
|
|
32613
32624
|
spanId: id,
|
|
@@ -32621,7 +32632,7 @@ var LangSmithPlugin = (_class26 = class extends BasePlugin {
|
|
|
32621
32632
|
...startTime === void 0 ? {} : { startTime },
|
|
32622
32633
|
event: { id }
|
|
32623
32634
|
},
|
|
32624
|
-
|
|
32635
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.LANGSMITH
|
|
32625
32636
|
)
|
|
32626
32637
|
);
|
|
32627
32638
|
}
|
|
@@ -32661,7 +32672,7 @@ var LangSmithPlugin = (_class26 = class extends BasePlugin {
|
|
|
32661
32672
|
try {
|
|
32662
32673
|
fn();
|
|
32663
32674
|
} catch (error) {
|
|
32664
|
-
|
|
32675
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
32665
32676
|
`Failed to process LangSmith ${operation} instrumentation:`,
|
|
32666
32677
|
error
|
|
32667
32678
|
);
|
|
@@ -32896,7 +32907,7 @@ var PiCodingAgentPlugin = (_class27 = class extends BasePlugin {constructor(...a
|
|
|
32896
32907
|
}
|
|
32897
32908
|
interceptPrompt() {
|
|
32898
32909
|
this.unsubscribers.push(
|
|
32899
|
-
|
|
32910
|
+
_chunk4AQGZS6Xjs.piCodingAgentChannels.prompt.intercept(
|
|
32900
32911
|
(target, thisArg, args, additional) => {
|
|
32901
32912
|
const invokeTarget = () => Reflect.apply(target, thisArg, args);
|
|
32902
32913
|
let state;
|
|
@@ -32969,7 +32980,7 @@ function startPiPromptRun(event, onFinalize) {
|
|
|
32969
32980
|
...event.moduleVersion ? { "pi_coding_agent.version": event.moduleVersion } : {}
|
|
32970
32981
|
};
|
|
32971
32982
|
const span = startSpan(
|
|
32972
|
-
|
|
32983
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
32973
32984
|
{
|
|
32974
32985
|
event: {
|
|
32975
32986
|
input: extractPromptInput(event.arguments[0], event.arguments[1]),
|
|
@@ -32978,7 +32989,7 @@ function startPiPromptRun(event, onFinalize) {
|
|
|
32978
32989
|
name: "AgentSession.prompt",
|
|
32979
32990
|
spanAttributes: { type: "task" /* TASK */ }
|
|
32980
32991
|
},
|
|
32981
|
-
|
|
32992
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.PI_CODING_AGENT
|
|
32982
32993
|
)
|
|
32983
32994
|
);
|
|
32984
32995
|
const options = event.arguments[1];
|
|
@@ -33007,7 +33018,7 @@ function isPiAgent(value) {
|
|
|
33007
33018
|
return isObject(value) && (typeof value.streamFunction === "function" || typeof value.streamFn === "function") && typeof value.subscribe === "function";
|
|
33008
33019
|
}
|
|
33009
33020
|
function promptContextStore() {
|
|
33010
|
-
piPromptContextStore ??=
|
|
33021
|
+
piPromptContextStore ??= _chunk4AQGZS6Xjs.isomorph_default.newAsyncLocalStorage();
|
|
33011
33022
|
return piPromptContextStore;
|
|
33012
33023
|
}
|
|
33013
33024
|
function currentPiPromptState() {
|
|
@@ -33112,7 +33123,7 @@ async function startPiLlmSpan(state, model, context, property, options) {
|
|
|
33112
33123
|
"pi_coding_agent.operation": `agent.${property}`
|
|
33113
33124
|
};
|
|
33114
33125
|
const span = startSpan(
|
|
33115
|
-
|
|
33126
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
33116
33127
|
{
|
|
33117
33128
|
event: {
|
|
33118
33129
|
input: processInputAttachments(normalizePiContextInput(context)),
|
|
@@ -33122,7 +33133,7 @@ async function startPiLlmSpan(state, model, context, property, options) {
|
|
|
33122
33133
|
parent: await state.span.export(),
|
|
33123
33134
|
spanAttributes: { type: "llm" /* LLM */ }
|
|
33124
33135
|
},
|
|
33125
|
-
|
|
33136
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.PI_CODING_AGENT
|
|
33126
33137
|
)
|
|
33127
33138
|
);
|
|
33128
33139
|
const llmState = {
|
|
@@ -33281,7 +33292,7 @@ async function startPiToolSpan(state, event) {
|
|
|
33281
33292
|
"pi_coding_agent.tool.name": event.toolName
|
|
33282
33293
|
};
|
|
33283
33294
|
const span = startSpan(
|
|
33284
|
-
|
|
33295
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
33285
33296
|
{
|
|
33286
33297
|
event: {
|
|
33287
33298
|
input: event.args,
|
|
@@ -33291,7 +33302,7 @@ async function startPiToolSpan(state, event) {
|
|
|
33291
33302
|
parent: await state.span.export(),
|
|
33292
33303
|
spanAttributes: { type: "tool" /* TOOL */ }
|
|
33293
33304
|
},
|
|
33294
|
-
|
|
33305
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.PI_CODING_AGENT
|
|
33295
33306
|
)
|
|
33296
33307
|
);
|
|
33297
33308
|
state.activeToolSpans.set(event.toolCallId, { span });
|
|
@@ -33680,7 +33691,7 @@ function safeLog4(span, event) {
|
|
|
33680
33691
|
}
|
|
33681
33692
|
}
|
|
33682
33693
|
function logInstrumentationError4(context, error) {
|
|
33683
|
-
|
|
33694
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(`${context}:`, error);
|
|
33684
33695
|
}
|
|
33685
33696
|
|
|
33686
33697
|
// src/instrumentation/plugins/strands-agent-sdk-plugin.ts
|
|
@@ -33690,11 +33701,11 @@ var StrandsAgentSDKPlugin = (_class28 = class extends BasePlugin {constructor(..
|
|
|
33690
33701
|
onEnable() {
|
|
33691
33702
|
this.interceptAgentStream();
|
|
33692
33703
|
this.interceptMultiAgentStream(
|
|
33693
|
-
|
|
33704
|
+
_chunk4AQGZS6Xjs.strandsAgentSDKChannels.graphStream,
|
|
33694
33705
|
"Graph.stream"
|
|
33695
33706
|
);
|
|
33696
33707
|
this.interceptMultiAgentStream(
|
|
33697
|
-
|
|
33708
|
+
_chunk4AQGZS6Xjs.strandsAgentSDKChannels.swarmStream,
|
|
33698
33709
|
"Swarm.stream"
|
|
33699
33710
|
);
|
|
33700
33711
|
}
|
|
@@ -33706,7 +33717,7 @@ var StrandsAgentSDKPlugin = (_class28 = class extends BasePlugin {constructor(..
|
|
|
33706
33717
|
}
|
|
33707
33718
|
interceptAgentStream() {
|
|
33708
33719
|
this.unsubscribers.push(
|
|
33709
|
-
|
|
33720
|
+
_chunk4AQGZS6Xjs.strandsAgentSDKChannels.agentStream.intercept(
|
|
33710
33721
|
(target, thisArg, args, additional) => instrumentStrandsStreamInvocation({
|
|
33711
33722
|
finalize: finalizeAgentStream,
|
|
33712
33723
|
handleChunk: handleAgentStreamEvent,
|
|
@@ -33750,7 +33761,7 @@ function instrumentStrandsStreamInvocation(options) {
|
|
|
33750
33761
|
try {
|
|
33751
33762
|
state = options.start();
|
|
33752
33763
|
} catch (error) {
|
|
33753
|
-
|
|
33764
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error starting ${options.name} instrumentation:`, error);
|
|
33754
33765
|
}
|
|
33755
33766
|
let result;
|
|
33756
33767
|
try {
|
|
@@ -33760,7 +33771,7 @@ function instrumentStrandsStreamInvocation(options) {
|
|
|
33760
33771
|
try {
|
|
33761
33772
|
options.finalize(state, error);
|
|
33762
33773
|
} catch (instrumentationError) {
|
|
33763
|
-
|
|
33774
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
33764
33775
|
`Error handling ${options.name} instrumentation failure:`,
|
|
33765
33776
|
instrumentationError
|
|
33766
33777
|
);
|
|
@@ -33781,7 +33792,7 @@ function instrumentStrandsStreamInvocation(options) {
|
|
|
33781
33792
|
options.finalize(state, void 0, result);
|
|
33782
33793
|
}
|
|
33783
33794
|
} catch (error) {
|
|
33784
|
-
|
|
33795
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
33785
33796
|
`Error finalizing ${options.name} instrumentation:`,
|
|
33786
33797
|
error
|
|
33787
33798
|
);
|
|
@@ -33803,7 +33814,7 @@ function startAgentStream(input, agent, activeChildParents) {
|
|
|
33803
33814
|
const span = parentSpan ? withCurrent(
|
|
33804
33815
|
parentSpan,
|
|
33805
33816
|
() => startSpan(
|
|
33806
|
-
|
|
33817
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
33807
33818
|
{
|
|
33808
33819
|
event: {
|
|
33809
33820
|
input: processedInput,
|
|
@@ -33812,11 +33823,11 @@ function startAgentStream(input, agent, activeChildParents) {
|
|
|
33812
33823
|
name: formatAgentSpanName(agent),
|
|
33813
33824
|
spanAttributes: { type: "task" /* TASK */ }
|
|
33814
33825
|
},
|
|
33815
|
-
|
|
33826
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK
|
|
33816
33827
|
)
|
|
33817
33828
|
)
|
|
33818
33829
|
) : startSpan(
|
|
33819
|
-
|
|
33830
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
33820
33831
|
{
|
|
33821
33832
|
event: {
|
|
33822
33833
|
input: processedInput,
|
|
@@ -33825,7 +33836,7 @@ function startAgentStream(input, agent, activeChildParents) {
|
|
|
33825
33836
|
name: formatAgentSpanName(agent),
|
|
33826
33837
|
spanAttributes: { type: "task" /* TASK */ }
|
|
33827
33838
|
},
|
|
33828
|
-
|
|
33839
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK
|
|
33829
33840
|
)
|
|
33830
33841
|
);
|
|
33831
33842
|
return {
|
|
@@ -33848,7 +33859,7 @@ function startMultiAgentStream(input, orchestrator, operation, activeChildParent
|
|
|
33848
33859
|
const span = parentSpan ? withCurrent(
|
|
33849
33860
|
parentSpan,
|
|
33850
33861
|
() => startSpan(
|
|
33851
|
-
|
|
33862
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
33852
33863
|
{
|
|
33853
33864
|
event: {
|
|
33854
33865
|
input: processedInput,
|
|
@@ -33857,11 +33868,11 @@ function startMultiAgentStream(input, orchestrator, operation, activeChildParent
|
|
|
33857
33868
|
name: operation === "Graph.stream" ? "Strands Graph" : "Strands Swarm",
|
|
33858
33869
|
spanAttributes: { type: "task" /* TASK */ }
|
|
33859
33870
|
},
|
|
33860
|
-
|
|
33871
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK
|
|
33861
33872
|
)
|
|
33862
33873
|
)
|
|
33863
33874
|
) : startSpan(
|
|
33864
|
-
|
|
33875
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
33865
33876
|
{
|
|
33866
33877
|
event: {
|
|
33867
33878
|
input: processedInput,
|
|
@@ -33870,7 +33881,7 @@ function startMultiAgentStream(input, orchestrator, operation, activeChildParent
|
|
|
33870
33881
|
name: operation === "Graph.stream" ? "Strands Graph" : "Strands Swarm",
|
|
33871
33882
|
spanAttributes: { type: "task" /* TASK */ }
|
|
33872
33883
|
},
|
|
33873
|
-
|
|
33884
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK
|
|
33874
33885
|
)
|
|
33875
33886
|
);
|
|
33876
33887
|
return {
|
|
@@ -33984,7 +33995,7 @@ function startModelSpan(state, event) {
|
|
|
33984
33995
|
const span = withCurrent(
|
|
33985
33996
|
state.span,
|
|
33986
33997
|
() => startSpan(
|
|
33987
|
-
|
|
33998
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
33988
33999
|
{
|
|
33989
34000
|
event: {
|
|
33990
34001
|
input: buildModelSpanInput(event, state.attachmentCache),
|
|
@@ -33993,7 +34004,7 @@ function startModelSpan(state, event) {
|
|
|
33993
34004
|
name: formatModelSpanName(model),
|
|
33994
34005
|
spanAttributes: { type: "llm" /* LLM */ }
|
|
33995
34006
|
},
|
|
33996
|
-
|
|
34007
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK
|
|
33997
34008
|
)
|
|
33998
34009
|
)
|
|
33999
34010
|
);
|
|
@@ -34048,7 +34059,7 @@ function startToolSpan2(state, event) {
|
|
|
34048
34059
|
const span = withCurrent(
|
|
34049
34060
|
state.span,
|
|
34050
34061
|
() => startSpan(
|
|
34051
|
-
|
|
34062
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
34052
34063
|
{
|
|
34053
34064
|
event: {
|
|
34054
34065
|
input: _optionalChain([toolUse, 'optionalAccess', _991 => _991.input]),
|
|
@@ -34063,7 +34074,7 @@ function startToolSpan2(state, event) {
|
|
|
34063
34074
|
name: `tool: ${name}`,
|
|
34064
34075
|
spanAttributes: { type: "tool" /* TOOL */ }
|
|
34065
34076
|
},
|
|
34066
|
-
|
|
34077
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK
|
|
34067
34078
|
)
|
|
34068
34079
|
)
|
|
34069
34080
|
);
|
|
@@ -34137,13 +34148,13 @@ function startNodeSpan(state, event, activeChildParents) {
|
|
|
34137
34148
|
const span = withCurrent(
|
|
34138
34149
|
state.span,
|
|
34139
34150
|
() => startSpan(
|
|
34140
|
-
|
|
34151
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
34141
34152
|
{
|
|
34142
34153
|
event: { metadata },
|
|
34143
34154
|
name: `node: ${nodeId}`,
|
|
34144
34155
|
spanAttributes: { type: "task" /* TASK */ }
|
|
34145
34156
|
},
|
|
34146
|
-
|
|
34157
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK
|
|
34147
34158
|
)
|
|
34148
34159
|
)
|
|
34149
34160
|
);
|
|
@@ -34624,7 +34635,7 @@ function safeLog5(span, event) {
|
|
|
34624
34635
|
}
|
|
34625
34636
|
}
|
|
34626
34637
|
function logInstrumentationError5(context, error) {
|
|
34627
|
-
|
|
34638
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(`${context}:`, error);
|
|
34628
34639
|
}
|
|
34629
34640
|
|
|
34630
34641
|
// src/instrumentation/plugins/voyageai-plugin.ts
|
|
@@ -34638,27 +34649,27 @@ var VoyageAIPlugin = class extends BasePlugin {
|
|
|
34638
34649
|
onEnable() {
|
|
34639
34650
|
this.unsubscribers.push(
|
|
34640
34651
|
interceptVoyageAICall(
|
|
34641
|
-
|
|
34652
|
+
_chunk4AQGZS6Xjs.voyageAIChannels.embed,
|
|
34642
34653
|
"voyageai.embed",
|
|
34643
34654
|
extractTextEmbeddingInput,
|
|
34644
34655
|
summarizeEmbeddingOutput,
|
|
34645
34656
|
extractEmbeddingUsageMetrics
|
|
34646
34657
|
),
|
|
34647
34658
|
interceptVoyageAICall(
|
|
34648
|
-
|
|
34659
|
+
_chunk4AQGZS6Xjs.voyageAIChannels.multimodalEmbed,
|
|
34649
34660
|
"voyageai.multimodalEmbed",
|
|
34650
34661
|
extractMultimodalEmbeddingInput,
|
|
34651
34662
|
summarizeEmbeddingOutput,
|
|
34652
34663
|
extractEmbeddingUsageMetrics
|
|
34653
34664
|
),
|
|
34654
34665
|
interceptVoyageAICall(
|
|
34655
|
-
|
|
34666
|
+
_chunk4AQGZS6Xjs.voyageAIChannels.rerank,
|
|
34656
34667
|
"voyageai.rerank",
|
|
34657
34668
|
extractRerankInput,
|
|
34658
34669
|
summarizeRerankOutput
|
|
34659
34670
|
),
|
|
34660
34671
|
interceptVoyageAICall(
|
|
34661
|
-
|
|
34672
|
+
_chunk4AQGZS6Xjs.voyageAIChannels.contextualizedEmbed,
|
|
34662
34673
|
"voyageai.contextualizedEmbed",
|
|
34663
34674
|
extractContextualizedEmbeddingInput,
|
|
34664
34675
|
summarizeContextualizedEmbeddingOutput,
|
|
@@ -34680,17 +34691,17 @@ function interceptVoyageAICall(channel, name, extractInput2, extractOutput2, ext
|
|
|
34680
34691
|
try {
|
|
34681
34692
|
const { input, metadata } = extractInput2(args);
|
|
34682
34693
|
span = startSpan(
|
|
34683
|
-
|
|
34694
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
34684
34695
|
{
|
|
34685
34696
|
event: { input, metadata },
|
|
34686
34697
|
name,
|
|
34687
34698
|
spanAttributes: { type: "llm" /* LLM */ }
|
|
34688
34699
|
},
|
|
34689
|
-
|
|
34700
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.VOYAGEAI
|
|
34690
34701
|
)
|
|
34691
34702
|
);
|
|
34692
34703
|
} catch (error) {
|
|
34693
|
-
|
|
34704
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error starting span for ${name}:`, error);
|
|
34694
34705
|
return invokeTarget();
|
|
34695
34706
|
}
|
|
34696
34707
|
let result;
|
|
@@ -34721,12 +34732,12 @@ function finishVoyageAISpan(span, name, log2) {
|
|
|
34721
34732
|
try {
|
|
34722
34733
|
log2();
|
|
34723
34734
|
} catch (error) {
|
|
34724
|
-
|
|
34735
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error logging span for ${name}:`, error);
|
|
34725
34736
|
}
|
|
34726
34737
|
try {
|
|
34727
34738
|
span.end();
|
|
34728
34739
|
} catch (error) {
|
|
34729
|
-
|
|
34740
|
+
_chunk4AQGZS6Xjs.debugLogger.error(`Error ending span for ${name}:`, error);
|
|
34730
34741
|
}
|
|
34731
34742
|
}
|
|
34732
34743
|
function getRequestArg2(args) {
|
|
@@ -34927,7 +34938,7 @@ function instrumentCloudflareAIChatAgent(agent) {
|
|
|
34927
34938
|
return agent;
|
|
34928
34939
|
}
|
|
34929
34940
|
const wrapped = async function(...args) {
|
|
34930
|
-
return
|
|
34941
|
+
return _chunk4AQGZS6Xjs.cloudflareAIChatChannels.runExclusiveChatTurn.tracePromise(
|
|
34931
34942
|
() => Reflect.apply(original, this, args),
|
|
34932
34943
|
{
|
|
34933
34944
|
arguments: args,
|
|
@@ -34938,7 +34949,7 @@ function instrumentCloudflareAIChatAgent(agent) {
|
|
|
34938
34949
|
wrappedTurnRunners.add(wrapped);
|
|
34939
34950
|
defineWrappedMethod(agent, "_runExclusiveChatTurn", original, wrapped);
|
|
34940
34951
|
} catch (error) {
|
|
34941
|
-
|
|
34952
|
+
_chunk4AQGZS6Xjs.debugLogger.debug("Failed to wrap @cloudflare/ai-chat turn runner:", error);
|
|
34942
34953
|
}
|
|
34943
34954
|
return agent;
|
|
34944
34955
|
}
|
|
@@ -34950,7 +34961,7 @@ function instrumentCloudflareAIChatResponseHook(agent) {
|
|
|
34950
34961
|
}
|
|
34951
34962
|
const wrapped = function(result) {
|
|
34952
34963
|
const args = [result];
|
|
34953
|
-
return
|
|
34964
|
+
return _chunk4AQGZS6Xjs.cloudflareAIChatChannels.onChatResponse.traceSync(
|
|
34954
34965
|
() => Reflect.apply(original, this, args),
|
|
34955
34966
|
{
|
|
34956
34967
|
arguments: args,
|
|
@@ -34961,7 +34972,7 @@ function instrumentCloudflareAIChatResponseHook(agent) {
|
|
|
34961
34972
|
wrappedResponseHooks.add(wrapped);
|
|
34962
34973
|
defineWrappedMethod(agent, "onChatResponse", original, wrapped);
|
|
34963
34974
|
} catch (error) {
|
|
34964
|
-
|
|
34975
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(
|
|
34965
34976
|
"Failed to wrap @cloudflare/ai-chat response hook:",
|
|
34966
34977
|
error
|
|
34967
34978
|
);
|
|
@@ -35006,7 +35017,7 @@ var CloudflareAIChatPlugin = (_class29 = class extends BasePlugin {constructor(.
|
|
|
35006
35017
|
this.activeStates.clear();
|
|
35007
35018
|
}
|
|
35008
35019
|
subscribeToTurnRunner() {
|
|
35009
|
-
const tracingChannel =
|
|
35020
|
+
const tracingChannel = _chunk4AQGZS6Xjs.cloudflareAIChatChannels.runExclusiveChatTurn.tracingChannel();
|
|
35010
35021
|
const unbindCurrentSpanStore = this.bindCurrentSpanStore(tracingChannel);
|
|
35011
35022
|
const handlers = {
|
|
35012
35023
|
start: (event) => {
|
|
@@ -35026,7 +35037,7 @@ var CloudflareAIChatPlugin = (_class29 = class extends BasePlugin {constructor(.
|
|
|
35026
35037
|
});
|
|
35027
35038
|
}
|
|
35028
35039
|
subscribeToResponseHook() {
|
|
35029
|
-
const tracingChannel =
|
|
35040
|
+
const tracingChannel = _chunk4AQGZS6Xjs.cloudflareAIChatChannels.onChatResponse.tracingChannel();
|
|
35030
35041
|
const handlers = {
|
|
35031
35042
|
start: (event) => {
|
|
35032
35043
|
let state;
|
|
@@ -35053,7 +35064,7 @@ var CloudflareAIChatPlugin = (_class29 = class extends BasePlugin {constructor(.
|
|
|
35053
35064
|
...status === "error" && error !== void 0 ? { error } : {}
|
|
35054
35065
|
});
|
|
35055
35066
|
} catch (error) {
|
|
35056
|
-
|
|
35067
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(
|
|
35057
35068
|
"Failed to process @cloudflare/ai-chat response hook:",
|
|
35058
35069
|
error
|
|
35059
35070
|
);
|
|
@@ -35104,7 +35115,7 @@ var CloudflareAIChatPlugin = (_class29 = class extends BasePlugin {constructor(.
|
|
|
35104
35115
|
}
|
|
35105
35116
|
return state;
|
|
35106
35117
|
} catch (error) {
|
|
35107
|
-
|
|
35118
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(
|
|
35108
35119
|
"Failed to start @cloudflare/ai-chat instrumentation:",
|
|
35109
35120
|
error
|
|
35110
35121
|
);
|
|
@@ -35113,12 +35124,12 @@ var CloudflareAIChatPlugin = (_class29 = class extends BasePlugin {constructor(.
|
|
|
35113
35124
|
}
|
|
35114
35125
|
createTurnState(agent, key) {
|
|
35115
35126
|
const span = startSpan(
|
|
35116
|
-
|
|
35127
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
35117
35128
|
{
|
|
35118
35129
|
name: "AIChatAgent.onChatMessage",
|
|
35119
35130
|
spanAttributes: { type: "task" /* TASK */ }
|
|
35120
35131
|
},
|
|
35121
|
-
|
|
35132
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLOUDFLARE_AI_CHAT
|
|
35122
35133
|
)
|
|
35123
35134
|
);
|
|
35124
35135
|
const state = {
|
|
@@ -35151,7 +35162,7 @@ var CloudflareAIChatPlugin = (_class29 = class extends BasePlugin {constructor(.
|
|
|
35151
35162
|
state.span.log({ input });
|
|
35152
35163
|
}
|
|
35153
35164
|
} catch (error) {
|
|
35154
|
-
|
|
35165
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(
|
|
35155
35166
|
"Failed to capture @cloudflare/ai-chat messages:",
|
|
35156
35167
|
error
|
|
35157
35168
|
);
|
|
@@ -35160,7 +35171,7 @@ var CloudflareAIChatPlugin = (_class29 = class extends BasePlugin {constructor(.
|
|
|
35160
35171
|
});
|
|
35161
35172
|
};
|
|
35162
35173
|
} catch (error) {
|
|
35163
|
-
|
|
35174
|
+
_chunk4AQGZS6Xjs.debugLogger.debug(
|
|
35164
35175
|
"Failed to bind @cloudflare/ai-chat turn callback context:",
|
|
35165
35176
|
error
|
|
35166
35177
|
);
|
|
@@ -35332,7 +35343,7 @@ var CLOUDFLARE_WORKERS_CONTEXT = {
|
|
|
35332
35343
|
};
|
|
35333
35344
|
var CloudflareAgentsPlugin = class extends BasePlugin {
|
|
35334
35345
|
onEnable() {
|
|
35335
|
-
const channel =
|
|
35346
|
+
const channel = _chunk4AQGZS6Xjs.cloudflareAgentsChannels.runAgentTool.tracingChannel();
|
|
35336
35347
|
const spans = /* @__PURE__ */ new WeakMap();
|
|
35337
35348
|
const handlers = {
|
|
35338
35349
|
start: (event) => {
|
|
@@ -35344,13 +35355,13 @@ var CloudflareAgentsPlugin = class extends BasePlugin {
|
|
|
35344
35355
|
}
|
|
35345
35356
|
const name = ownValue3(agentClass, "name");
|
|
35346
35357
|
if (typeof name !== "string" || name.length === 0) {
|
|
35347
|
-
|
|
35358
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
35348
35359
|
"Skipping Cloudflare Agents runAgentTool span because the child agent class has no name."
|
|
35349
35360
|
);
|
|
35350
35361
|
return;
|
|
35351
35362
|
}
|
|
35352
35363
|
const span = _internalStartSpanWithContext(
|
|
35353
|
-
|
|
35364
|
+
_chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
35354
35365
|
{
|
|
35355
35366
|
name,
|
|
35356
35367
|
spanAttributes: { type: "tool" /* TOOL */ },
|
|
@@ -35358,7 +35369,7 @@ var CloudflareAgentsPlugin = class extends BasePlugin {
|
|
|
35358
35369
|
input: ownValue3(options, "input")
|
|
35359
35370
|
}
|
|
35360
35371
|
},
|
|
35361
|
-
|
|
35372
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.CLOUDFLARE_AGENTS
|
|
35362
35373
|
),
|
|
35363
35374
|
CLOUDFLARE_WORKERS_CONTEXT
|
|
35364
35375
|
);
|
|
@@ -35432,7 +35443,7 @@ function safelyEndSpan(span) {
|
|
|
35432
35443
|
}
|
|
35433
35444
|
}
|
|
35434
35445
|
function logInstrumentationError6(operation, error) {
|
|
35435
|
-
|
|
35446
|
+
_chunk4AQGZS6Xjs.debugLogger.error(
|
|
35436
35447
|
`Failed to process Cloudflare Agents ${operation} instrumentation:`,
|
|
35437
35448
|
error
|
|
35438
35449
|
);
|
|
@@ -35715,7 +35726,7 @@ var BraintrustPlugin = (_class30 = class extends BasePlugin {
|
|
|
35715
35726
|
|
|
35716
35727
|
// src/instrumentation/registry.ts
|
|
35717
35728
|
var REGISTRY_STATE_KEY = /* @__PURE__ */ Symbol.for(
|
|
35718
|
-
`braintrust.registry.global-hooks.v${
|
|
35729
|
+
`braintrust.registry.global-hooks.v${_chunk4AQGZS6Xjs.GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION}`
|
|
35719
35730
|
);
|
|
35720
35731
|
function getSharedState() {
|
|
35721
35732
|
const state = globalThis[/* @__PURE__ */ Symbol.for("braintrust-state")];
|
|
@@ -35793,15 +35804,15 @@ var PluginRegistry = (_class31 = class {constructor() { _class31.prototype.__ini
|
|
|
35793
35804
|
* Get default configuration (all integrations enabled).
|
|
35794
35805
|
*/
|
|
35795
35806
|
getDefaultConfig() {
|
|
35796
|
-
return
|
|
35807
|
+
return _chunk4AQGZS6Xjs.getDefaultInstrumentationIntegrations.call(void 0, );
|
|
35797
35808
|
}
|
|
35798
35809
|
/**
|
|
35799
35810
|
* Read configuration from environment variables.
|
|
35800
35811
|
* Supports: BRAINTRUST_DISABLE_INSTRUMENTATION=openai,anthropic,...
|
|
35801
35812
|
*/
|
|
35802
35813
|
readEnvConfig() {
|
|
35803
|
-
return
|
|
35804
|
-
|
|
35814
|
+
return _chunk4AQGZS6Xjs.readDisabledInstrumentationEnvConfig.call(void 0,
|
|
35815
|
+
_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_DISABLE_INSTRUMENTATION")
|
|
35805
35816
|
);
|
|
35806
35817
|
}
|
|
35807
35818
|
}, _class31);
|
|
@@ -35947,7 +35958,7 @@ var BraintrustObservabilityExporter = (_class32 = class {
|
|
|
35947
35958
|
}
|
|
35948
35959
|
onStart(exported) {
|
|
35949
35960
|
if (this.spans.has(exported.id)) return;
|
|
35950
|
-
const args =
|
|
35961
|
+
const args = _chunk4AQGZS6Xjs.withSpanInstrumentationName.call(void 0,
|
|
35951
35962
|
{
|
|
35952
35963
|
name: exported.name,
|
|
35953
35964
|
spanAttributes: { type: spanTypeFor(exported.type) },
|
|
@@ -35959,7 +35970,7 @@ var BraintrustObservabilityExporter = (_class32 = class {
|
|
|
35959
35970
|
// external caller could know.
|
|
35960
35971
|
event: { id: exported.id }
|
|
35961
35972
|
},
|
|
35962
|
-
|
|
35973
|
+
_chunk4AQGZS6Xjs.INSTRUMENTATION_NAMES.MASTRA
|
|
35963
35974
|
);
|
|
35964
35975
|
const parentRecord = exported.parentSpanId ? this.spans.get(exported.parentSpanId) : void 0;
|
|
35965
35976
|
if (!this.capturedParent) {
|
|
@@ -36024,7 +36035,7 @@ var BraintrustObservabilityExporter = (_class32 = class {
|
|
|
36024
36035
|
}
|
|
36025
36036
|
}, _class32);
|
|
36026
36037
|
function logExporterError(err) {
|
|
36027
|
-
|
|
36038
|
+
_chunk4AQGZS6Xjs.debugLogger.warn("Mastra exporter failure:", err);
|
|
36028
36039
|
}
|
|
36029
36040
|
function wrapMastraAgent(agent, _options) {
|
|
36030
36041
|
return agent;
|
|
@@ -36181,7 +36192,7 @@ async function getPastNAncestors(n = 1e3, remote = void 0) {
|
|
|
36181
36192
|
try {
|
|
36182
36193
|
ancestor = await getBaseBranchAncestor(remote);
|
|
36183
36194
|
} catch (e) {
|
|
36184
|
-
|
|
36195
|
+
_chunk4AQGZS6Xjs.debugLogger.warn(
|
|
36185
36196
|
"Skipping git metadata. This is likely because the repository has not been published to a remote yet.",
|
|
36186
36197
|
`${e}`
|
|
36187
36198
|
);
|
|
@@ -36312,9 +36323,9 @@ function getCallerLocation() {
|
|
|
36312
36323
|
const entries = getStackTrace();
|
|
36313
36324
|
for (const frame of entries) {
|
|
36314
36325
|
if (thisDir === void 0) {
|
|
36315
|
-
thisDir = _optionalChain([
|
|
36326
|
+
thisDir = _optionalChain([_chunk4AQGZS6Xjs.isomorph_default, 'access', _1079 => _1079.pathDirname, 'optionalCall', _1080 => _1080(frame.fileName)]);
|
|
36316
36327
|
}
|
|
36317
|
-
if (_optionalChain([
|
|
36328
|
+
if (_optionalChain([_chunk4AQGZS6Xjs.isomorph_default, 'access', _1081 => _1081.pathDirname, 'optionalCall', _1082 => _1082(frame.fileName)]) !== thisDir) {
|
|
36318
36329
|
return {
|
|
36319
36330
|
caller_functionname: frame.functionName,
|
|
36320
36331
|
caller_filename: frame.fileName,
|
|
@@ -36328,10 +36339,10 @@ function getCallerLocation() {
|
|
|
36328
36339
|
// src/node/config.ts
|
|
36329
36340
|
var BRAINTRUST_ENV_SEARCH_PARENT_LIMIT = 64;
|
|
36330
36341
|
function configureNode() {
|
|
36331
|
-
|
|
36332
|
-
|
|
36333
|
-
|
|
36334
|
-
|
|
36342
|
+
_chunk4AQGZS6Xjs.isomorph_default.buildType = "node";
|
|
36343
|
+
_chunk4AQGZS6Xjs.isomorph_default.getRepoInfo = getRepoInfo;
|
|
36344
|
+
_chunk4AQGZS6Xjs.isomorph_default.getPastNAncestors = getPastNAncestors;
|
|
36345
|
+
_chunk4AQGZS6Xjs.isomorph_default.getEnv = (name) => {
|
|
36335
36346
|
const value = process.env[name];
|
|
36336
36347
|
if (name === "BRAINTRUST_API_KEY") {
|
|
36337
36348
|
return _optionalChain([value, 'optionalAccess', _1083 => _1083.trim, 'call', _1084 => _1084()]) ? value : void 0;
|
|
@@ -36341,7 +36352,7 @@ function configureNode() {
|
|
|
36341
36352
|
}
|
|
36342
36353
|
return value;
|
|
36343
36354
|
};
|
|
36344
|
-
|
|
36355
|
+
_chunk4AQGZS6Xjs.isomorph_default.getBraintrustApiKey = async () => {
|
|
36345
36356
|
const value = process.env.BRAINTRUST_API_KEY;
|
|
36346
36357
|
if (_optionalChain([value, 'optionalAccess', _1087 => _1087.trim, 'call', _1088 => _1088()])) {
|
|
36347
36358
|
return value;
|
|
@@ -36386,45 +36397,45 @@ function configureNode() {
|
|
|
36386
36397
|
}
|
|
36387
36398
|
return void 0;
|
|
36388
36399
|
};
|
|
36389
|
-
|
|
36390
|
-
|
|
36391
|
-
|
|
36400
|
+
_chunk4AQGZS6Xjs.isomorph_default.getCallerLocation = getCallerLocation;
|
|
36401
|
+
_chunk4AQGZS6Xjs.isomorph_default.newAsyncLocalStorage = () => new (0, _nodeasync_hooks.AsyncLocalStorage)();
|
|
36402
|
+
_chunk4AQGZS6Xjs.isomorph_default.processOn = (event, handler) => {
|
|
36392
36403
|
process.on(event, handler);
|
|
36393
36404
|
};
|
|
36394
|
-
|
|
36395
|
-
|
|
36396
|
-
|
|
36397
|
-
|
|
36398
|
-
|
|
36399
|
-
|
|
36400
|
-
|
|
36401
|
-
|
|
36402
|
-
|
|
36403
|
-
|
|
36404
|
-
|
|
36405
|
-
|
|
36406
|
-
|
|
36407
|
-
|
|
36408
|
-
|
|
36409
|
-
|
|
36410
|
-
|
|
36411
|
-
|
|
36412
|
-
|
|
36413
|
-
|
|
36414
|
-
|
|
36415
|
-
|
|
36416
|
-
|
|
36417
|
-
|
|
36405
|
+
_chunk4AQGZS6Xjs.isomorph_default.basename = path2.basename;
|
|
36406
|
+
_chunk4AQGZS6Xjs.isomorph_default.writeln = (text) => process.stdout.write(text + "\n");
|
|
36407
|
+
_chunk4AQGZS6Xjs.isomorph_default.pathJoin = path2.join;
|
|
36408
|
+
_chunk4AQGZS6Xjs.isomorph_default.pathDirname = path2.dirname;
|
|
36409
|
+
_chunk4AQGZS6Xjs.isomorph_default.mkdir = fs.mkdir;
|
|
36410
|
+
_chunk4AQGZS6Xjs.isomorph_default.writeFile = fs.writeFile;
|
|
36411
|
+
_chunk4AQGZS6Xjs.isomorph_default.readFile = fs.readFile;
|
|
36412
|
+
_chunk4AQGZS6Xjs.isomorph_default.readdir = fs.readdir;
|
|
36413
|
+
_chunk4AQGZS6Xjs.isomorph_default.stat = fs.stat;
|
|
36414
|
+
_chunk4AQGZS6Xjs.isomorph_default.statSync = fsSync.statSync;
|
|
36415
|
+
_chunk4AQGZS6Xjs.isomorph_default.utimes = fs.utimes;
|
|
36416
|
+
_chunk4AQGZS6Xjs.isomorph_default.unlink = fs.unlink;
|
|
36417
|
+
_chunk4AQGZS6Xjs.isomorph_default.homedir = os.homedir;
|
|
36418
|
+
_chunk4AQGZS6Xjs.isomorph_default.tmpdir = os.tmpdir;
|
|
36419
|
+
_chunk4AQGZS6Xjs.isomorph_default.writeFileSync = fsSync.writeFileSync;
|
|
36420
|
+
_chunk4AQGZS6Xjs.isomorph_default.appendFileSync = fsSync.appendFileSync;
|
|
36421
|
+
_chunk4AQGZS6Xjs.isomorph_default.readFileSync = (filename, encoding) => fsSync.readFileSync(filename, encoding);
|
|
36422
|
+
_chunk4AQGZS6Xjs.isomorph_default.unlinkSync = fsSync.unlinkSync;
|
|
36423
|
+
_chunk4AQGZS6Xjs.isomorph_default.openFile = fs.open;
|
|
36424
|
+
_chunk4AQGZS6Xjs.isomorph_default.gzip = _nodeutil.promisify.call(void 0, zlib.gzip);
|
|
36425
|
+
_chunk4AQGZS6Xjs.isomorph_default.gunzip = _nodeutil.promisify.call(void 0, zlib.gunzip);
|
|
36426
|
+
_chunk4AQGZS6Xjs.isomorph_default.hash = (data) => crypto.createHash("sha256").update(data).digest("hex");
|
|
36427
|
+
_chunk4AQGZS6Xjs.isomorph_default.hmacSha256 = (key, data) => crypto.createHmac("sha256", key).update(data).digest("hex");
|
|
36428
|
+
_chunk4AQGZS6Xjs.isomorph_default.timingSafeEqual = (left, right) => {
|
|
36418
36429
|
const leftBuffer = Buffer.from(left);
|
|
36419
36430
|
const rightBuffer = Buffer.from(right);
|
|
36420
36431
|
return leftBuffer.length === rightBuffer.length && crypto.timingSafeEqual(leftBuffer, rightBuffer);
|
|
36421
36432
|
};
|
|
36422
36433
|
_internalSetInitialState();
|
|
36423
|
-
const disabled =
|
|
36424
|
-
|
|
36434
|
+
const disabled = _chunk4AQGZS6Xjs.readDisabledInstrumentationEnvConfig.call(void 0,
|
|
36435
|
+
_chunk4AQGZS6Xjs.isomorph_default.getEnv("BRAINTRUST_DISABLE_INSTRUMENTATION")
|
|
36425
36436
|
).integrations;
|
|
36426
|
-
if (!
|
|
36427
|
-
|
|
36437
|
+
if (!_chunk4AQGZS6Xjs.isInstrumentationIntegrationDisabled.call(void 0, disabled, "mastra")) {
|
|
36438
|
+
_chunk4AQGZS6Xjs.installMastraExporterFactory.call(void 0, () => new BraintrustObservabilityExporter());
|
|
36428
36439
|
}
|
|
36429
36440
|
registry.enable();
|
|
36430
36441
|
}
|