braintrust 0.4.1 → 0.4.3
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 +16 -0
- package/dev/dist/index.d.ts +16 -0
- package/dev/dist/index.js +83 -45
- package/dev/dist/index.mjs +67 -29
- package/dist/browser.d.mts +70 -2
- package/dist/browser.d.ts +70 -2
- package/dist/browser.js +125 -50
- package/dist/browser.mjs +105 -30
- package/dist/cli.js +75 -37
- package/dist/index.d.mts +69 -2
- package/dist/index.d.ts +69 -2
- package/dist/index.js +326 -181
- package/dist/index.mjs +215 -70
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3465,7 +3465,6 @@ var init_context = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
3465
3465
|
"src/otel/context.ts"() {
|
|
3466
3466
|
"use strict";
|
|
3467
3467
|
init_logger();
|
|
3468
|
-
init_util();
|
|
3469
3468
|
OTEL_NOT_INSTALLED_MESSAGE = "OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base";
|
|
3470
3469
|
otelTrace = null;
|
|
3471
3470
|
otelContext = null;
|
|
@@ -3528,6 +3527,10 @@ var init_context = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
3528
3527
|
const currentContext = otelContext.active();
|
|
3529
3528
|
let newContext = otelTrace.setSpan(currentContext, wrappedContext);
|
|
3530
3529
|
newContext = newContext.setValue("braintrust_span", span);
|
|
3530
|
+
const parentValue = span._getOtelParent();
|
|
3531
|
+
if (parentValue) {
|
|
3532
|
+
newContext = newContext.setValue("braintrust.parent", parentValue);
|
|
3533
|
+
}
|
|
3531
3534
|
return otelContext.with(newContext, callback);
|
|
3532
3535
|
}
|
|
3533
3536
|
} catch (error2) {
|
|
@@ -3543,34 +3546,6 @@ var init_context = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
3543
3546
|
}
|
|
3544
3547
|
return void 0;
|
|
3545
3548
|
}
|
|
3546
|
-
_getOtelParent(span) {
|
|
3547
|
-
if (!span.parentObjectType || !span.parentObjectId) {
|
|
3548
|
-
return void 0;
|
|
3549
|
-
}
|
|
3550
|
-
try {
|
|
3551
|
-
const parentType = span.parentObjectType;
|
|
3552
|
-
const parentId = span.parentObjectId;
|
|
3553
|
-
if (parentType === 2 /* PROJECT_LOGS */) {
|
|
3554
|
-
const id = typeof parentId === "object" && parentId !== null && "get" in parentId ? (
|
|
3555
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Type guard ensures object has get method
|
|
3556
|
-
parentId.get()
|
|
3557
|
-
) : parentId;
|
|
3558
|
-
if (typeof id === "string") {
|
|
3559
|
-
return `project_id:${id}`;
|
|
3560
|
-
}
|
|
3561
|
-
} else if (parentType === 1 /* EXPERIMENT */) {
|
|
3562
|
-
const id = typeof parentId === "object" && parentId !== null && "get" in parentId ? (
|
|
3563
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Type guard ensures object has get method
|
|
3564
|
-
parentId.get()
|
|
3565
|
-
) : parentId;
|
|
3566
|
-
if (typeof id === "string") {
|
|
3567
|
-
return `experiment_id:${id}`;
|
|
3568
|
-
}
|
|
3569
|
-
}
|
|
3570
|
-
} catch (e9) {
|
|
3571
|
-
}
|
|
3572
|
-
return void 0;
|
|
3573
|
-
}
|
|
3574
3549
|
};
|
|
3575
3550
|
}
|
|
3576
3551
|
});
|
|
@@ -3606,7 +3581,7 @@ function getContextManager() {
|
|
|
3606
3581
|
try {
|
|
3607
3582
|
const { OtelContextManager: OtelContextManager2 } = (init_context(), _chunkCDBUTZMHjs.__toCommonJS.call(void 0, context_exports));
|
|
3608
3583
|
return new OtelContextManager2();
|
|
3609
|
-
} catch (
|
|
3584
|
+
} catch (e9) {
|
|
3610
3585
|
console.warn(
|
|
3611
3586
|
"OTEL not available, falling back to Braintrust-only context manager"
|
|
3612
3587
|
);
|
|
@@ -5272,7 +5247,7 @@ function resetIdGenStateForTests() {
|
|
|
5272
5247
|
state.resetIdGenState();
|
|
5273
5248
|
}
|
|
5274
5249
|
}
|
|
5275
|
-
var BRAINTRUST_ATTACHMENT, EXTERNAL_ATTACHMENT, BRAINTRUST_PARAMS, REDACTION_FIELDS, MaskingError, ContextManager, BraintrustContextManager, NoopSpan, NOOP_SPAN, NOOP_SPAN_PERMALINK, loginSchema, stateNonce, BraintrustState, _globalState, _internalGetGlobalState, FailedHTTPResponse, HTTPConnection, BaseAttachment, Attachment, ExternalAttachment, attachmentMetadataSchema, ReadonlyAttachment, ERR_PERMALINK, Logger, TestBackgroundLogger, BACKGROUND_LOGGER_BASE_SLEEP_TIME_S, HTTPBackgroundLogger, traceable, INTERNAL_BTQL_LIMIT, MAX_BTQL_ITERATIONS, ObjectFetcher, Experiment2, ReadonlyExperiment, executionCounter, SpanImpl, Dataset2, Prompt2, TEST_API_KEY, _exportsForTestingOnly;
|
|
5250
|
+
var BRAINTRUST_ATTACHMENT, EXTERNAL_ATTACHMENT, BRAINTRUST_PARAMS, REDACTION_FIELDS, MaskingError, ContextManager, BraintrustContextManager, NoopSpan, NOOP_SPAN, NOOP_SPAN_PERMALINK, loginSchema, stateNonce, BraintrustState, _globalState, _internalGetGlobalState, FailedHTTPResponse, HTTPConnection, BaseAttachment, Attachment, ExternalAttachment, attachmentMetadataSchema, ReadonlyAttachment, JSONAttachment, ERR_PERMALINK, Logger, TestBackgroundLogger, BACKGROUND_LOGGER_BASE_SLEEP_TIME_S, HTTPBackgroundLogger, traceable, INTERNAL_BTQL_LIMIT, MAX_BTQL_ITERATIONS, ObjectFetcher, Experiment2, ReadonlyExperiment, executionCounter, SpanImpl, Dataset2, Prompt2, TEST_API_KEY, _exportsForTestingOnly;
|
|
5276
5251
|
var init_logger = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
5277
5252
|
"src/logger.ts"() {
|
|
5278
5253
|
"use strict";
|
|
@@ -5381,6 +5356,9 @@ var init_logger = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
5381
5356
|
state() {
|
|
5382
5357
|
return _internalGetGlobalState();
|
|
5383
5358
|
}
|
|
5359
|
+
_getOtelParent() {
|
|
5360
|
+
return void 0;
|
|
5361
|
+
}
|
|
5384
5362
|
// Custom inspect for Node.js console.log
|
|
5385
5363
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
5386
5364
|
return `NoopSpan {
|
|
@@ -6142,6 +6120,44 @@ with a Blob/ArrayBuffer, or run the program on Node.js.`
|
|
|
6142
6120
|
return new LazyValue(download);
|
|
6143
6121
|
}
|
|
6144
6122
|
};
|
|
6123
|
+
JSONAttachment = exports.JSONAttachment = class extends Attachment {
|
|
6124
|
+
/**
|
|
6125
|
+
* Construct a JSONAttachment from a JSON-serializable object.
|
|
6126
|
+
*
|
|
6127
|
+
* @param data The JSON object to attach. Must be JSON-serializable.
|
|
6128
|
+
* @param options Additional options:
|
|
6129
|
+
* - `filename`: The filename for the attachment (defaults to "data.json")
|
|
6130
|
+
* - `pretty`: Whether to pretty-print the JSON (defaults to false)
|
|
6131
|
+
* - `state`: (Optional) For internal use.
|
|
6132
|
+
*
|
|
6133
|
+
* @example
|
|
6134
|
+
* ```typescript
|
|
6135
|
+
* const largeTranscript = [
|
|
6136
|
+
* { role: "user", content: "..." },
|
|
6137
|
+
* { role: "assistant", content: "..." },
|
|
6138
|
+
* // ... many more messages
|
|
6139
|
+
* ];
|
|
6140
|
+
*
|
|
6141
|
+
* logger.log({
|
|
6142
|
+
* input: {
|
|
6143
|
+
* type: "chat",
|
|
6144
|
+
* transcript: new JSONAttachment(largeTranscript, { filename: "transcript.json" })
|
|
6145
|
+
* }
|
|
6146
|
+
* });
|
|
6147
|
+
* ```
|
|
6148
|
+
*/
|
|
6149
|
+
constructor(data, options) {
|
|
6150
|
+
const { filename = "data.json", pretty = false, state } = _nullishCoalesce(options, () => ( {}));
|
|
6151
|
+
const jsonString = pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);
|
|
6152
|
+
const blob = new Blob([jsonString], { type: "application/json" });
|
|
6153
|
+
super({
|
|
6154
|
+
data: blob,
|
|
6155
|
+
filename,
|
|
6156
|
+
contentType: "application/json",
|
|
6157
|
+
state
|
|
6158
|
+
});
|
|
6159
|
+
}
|
|
6160
|
+
};
|
|
6145
6161
|
ERR_PERMALINK = exports.ERR_PERMALINK = "https://braintrust.dev/error-generating-link";
|
|
6146
6162
|
Logger = exports.Logger = (_class6 = class {
|
|
6147
6163
|
|
|
@@ -6175,6 +6191,9 @@ with a Blob/ArrayBuffer, or run the program on Node.js.`
|
|
|
6175
6191
|
get id() {
|
|
6176
6192
|
return (async () => (await this.project).id)();
|
|
6177
6193
|
}
|
|
6194
|
+
get loggingState() {
|
|
6195
|
+
return this.state;
|
|
6196
|
+
}
|
|
6178
6197
|
parentObjectType() {
|
|
6179
6198
|
return 2 /* PROJECT_LOGS */;
|
|
6180
6199
|
}
|
|
@@ -6888,6 +6907,18 @@ Error: ${errorText}`;
|
|
|
6888
6907
|
return (await this.lazyMetadata.get()).experiment.id;
|
|
6889
6908
|
})();
|
|
6890
6909
|
}
|
|
6910
|
+
get loggingState() {
|
|
6911
|
+
return this.state;
|
|
6912
|
+
}
|
|
6913
|
+
/**
|
|
6914
|
+
* Wait for the experiment ID to be resolved. This is useful for ensuring the ID
|
|
6915
|
+
* is available synchronously in child spans (for OTEL parent attributes).
|
|
6916
|
+
* @internal
|
|
6917
|
+
*/
|
|
6918
|
+
async _waitForId() {
|
|
6919
|
+
await this.lazyId.get().catch(() => {
|
|
6920
|
+
});
|
|
6921
|
+
}
|
|
6891
6922
|
get name() {
|
|
6892
6923
|
return (async () => {
|
|
6893
6924
|
return (await this.lazyMetadata.get()).experiment.name;
|
|
@@ -7144,6 +7175,9 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7144
7175
|
return (await this.lazyMetadata.get()).experiment.name;
|
|
7145
7176
|
})();
|
|
7146
7177
|
}
|
|
7178
|
+
get loggingState() {
|
|
7179
|
+
return this.state;
|
|
7180
|
+
}
|
|
7147
7181
|
async getState() {
|
|
7148
7182
|
await this.lazyMetadata.get();
|
|
7149
7183
|
return this.state;
|
|
@@ -7440,6 +7474,42 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7440
7474
|
state() {
|
|
7441
7475
|
return this._state;
|
|
7442
7476
|
}
|
|
7477
|
+
/**
|
|
7478
|
+
* Internal method to get the OTEL parent string for this span.
|
|
7479
|
+
* This is used by OtelContextManager to set the braintrust.parent attribute.
|
|
7480
|
+
* @returns A string like "project_id:X" or "experiment_id:X", or undefined if no parent
|
|
7481
|
+
*/
|
|
7482
|
+
_getOtelParent() {
|
|
7483
|
+
if (!this.parentObjectType) {
|
|
7484
|
+
return void 0;
|
|
7485
|
+
}
|
|
7486
|
+
try {
|
|
7487
|
+
if (this.parentObjectType === 2 /* PROJECT_LOGS */) {
|
|
7488
|
+
const syncResult = this.parentObjectId.getSync();
|
|
7489
|
+
const id = syncResult.value;
|
|
7490
|
+
const args = this.parentComputeObjectMetadataArgs;
|
|
7491
|
+
if (id) {
|
|
7492
|
+
return `project_id:${id}`;
|
|
7493
|
+
}
|
|
7494
|
+
const projectName = _optionalChain([args, 'optionalAccess', _106 => _106.project_name]);
|
|
7495
|
+
if (projectName) {
|
|
7496
|
+
return `project_name:${projectName}`;
|
|
7497
|
+
}
|
|
7498
|
+
} else if (this.parentObjectType === 1 /* EXPERIMENT */) {
|
|
7499
|
+
const syncResult = this.parentObjectId.getSync();
|
|
7500
|
+
const id = syncResult.value;
|
|
7501
|
+
if (!syncResult.resolved) {
|
|
7502
|
+
this.parentObjectId.get().catch(() => {
|
|
7503
|
+
});
|
|
7504
|
+
}
|
|
7505
|
+
if (id) {
|
|
7506
|
+
return `experiment_id:${id}`;
|
|
7507
|
+
}
|
|
7508
|
+
}
|
|
7509
|
+
} catch (e) {
|
|
7510
|
+
}
|
|
7511
|
+
return void 0;
|
|
7512
|
+
}
|
|
7443
7513
|
// Custom inspect for Node.js console.log
|
|
7444
7514
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
7445
7515
|
return `SpanImpl {
|
|
@@ -7496,6 +7566,9 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7496
7566
|
return (await this.lazyMetadata.get()).project;
|
|
7497
7567
|
})();
|
|
7498
7568
|
}
|
|
7569
|
+
get loggingState() {
|
|
7570
|
+
return this.state;
|
|
7571
|
+
}
|
|
7499
7572
|
async getState() {
|
|
7500
7573
|
await this.lazyMetadata.get();
|
|
7501
7574
|
return this.state;
|
|
@@ -7718,13 +7791,13 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7718
7791
|
return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
|
|
7719
7792
|
}
|
|
7720
7793
|
get prompt() {
|
|
7721
|
-
return _optionalChain([this, 'access',
|
|
7794
|
+
return _optionalChain([this, 'access', _107 => _107.getParsedPromptData, 'call', _108 => _108(), 'optionalAccess', _109 => _109.prompt]);
|
|
7722
7795
|
}
|
|
7723
7796
|
get version() {
|
|
7724
7797
|
return this.metadata[TRANSACTION_ID_FIELD];
|
|
7725
7798
|
}
|
|
7726
7799
|
get options() {
|
|
7727
|
-
return _optionalChain([this, 'access',
|
|
7800
|
+
return _optionalChain([this, 'access', _110 => _110.getParsedPromptData, 'call', _111 => _111(), 'optionalAccess', _112 => _112.options]) || {};
|
|
7728
7801
|
}
|
|
7729
7802
|
get promptData() {
|
|
7730
7803
|
return this.getParsedPromptData();
|
|
@@ -7875,7 +7948,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7875
7948
|
return {
|
|
7876
7949
|
type: "chat",
|
|
7877
7950
|
messages,
|
|
7878
|
-
..._optionalChain([prompt, 'access',
|
|
7951
|
+
..._optionalChain([prompt, 'access', _113 => _113.tools, 'optionalAccess', _114 => _114.trim, 'call', _115 => _115()]) ? {
|
|
7879
7952
|
tools: render(prompt.tools)
|
|
7880
7953
|
} : void 0
|
|
7881
7954
|
};
|
|
@@ -8064,7 +8137,7 @@ var init_logging_error_handler = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
8064
8137
|
function globalErrorHandler(ex) {
|
|
8065
8138
|
try {
|
|
8066
8139
|
delegateHandler(ex);
|
|
8067
|
-
} catch (
|
|
8140
|
+
} catch (e10) {
|
|
8068
8141
|
}
|
|
8069
8142
|
}
|
|
8070
8143
|
var delegateHandler;
|
|
@@ -8123,45 +8196,41 @@ var init_version = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
8123
8196
|
}
|
|
8124
8197
|
});
|
|
8125
8198
|
|
|
8126
|
-
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8199
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js
|
|
8127
8200
|
var init_SemanticAttributes = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8128
|
-
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8201
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js"() {
|
|
8129
8202
|
"use strict";
|
|
8130
8203
|
}
|
|
8131
8204
|
});
|
|
8132
8205
|
|
|
8133
|
-
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8206
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js
|
|
8134
8207
|
var init_trace = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8135
|
-
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8208
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js"() {
|
|
8136
8209
|
"use strict";
|
|
8137
8210
|
init_SemanticAttributes();
|
|
8138
8211
|
}
|
|
8139
8212
|
});
|
|
8140
8213
|
|
|
8141
|
-
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8214
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
|
|
8142
8215
|
var init_SemanticResourceAttributes = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8143
|
-
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8216
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js"() {
|
|
8144
8217
|
"use strict";
|
|
8145
8218
|
}
|
|
8146
8219
|
});
|
|
8147
8220
|
|
|
8148
|
-
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8221
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js
|
|
8149
8222
|
var init_resource = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8150
|
-
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8223
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js"() {
|
|
8151
8224
|
"use strict";
|
|
8152
8225
|
init_SemanticResourceAttributes();
|
|
8153
8226
|
}
|
|
8154
8227
|
});
|
|
8155
8228
|
|
|
8156
|
-
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8157
|
-
var
|
|
8229
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
|
|
8230
|
+
var ATTR_TELEMETRY_SDK_LANGUAGE, TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_VERSION;
|
|
8158
8231
|
var init_stable_attributes = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8159
|
-
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8232
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js"() {
|
|
8160
8233
|
"use strict";
|
|
8161
|
-
ATTR_EXCEPTION_MESSAGE = "exception.message";
|
|
8162
|
-
ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
|
|
8163
|
-
ATTR_EXCEPTION_TYPE = "exception.type";
|
|
8164
|
-
ATTR_SERVICE_NAME = "service.name";
|
|
8165
8234
|
ATTR_TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language";
|
|
8166
8235
|
TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS = "nodejs";
|
|
8167
8236
|
ATTR_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
|
|
@@ -8169,21 +8238,29 @@ var init_stable_attributes = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
8169
8238
|
}
|
|
8170
8239
|
});
|
|
8171
8240
|
|
|
8172
|
-
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8241
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js
|
|
8173
8242
|
var init_stable_metrics = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8174
|
-
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8243
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js"() {
|
|
8175
8244
|
"use strict";
|
|
8176
8245
|
}
|
|
8177
8246
|
});
|
|
8178
8247
|
|
|
8179
|
-
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8248
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.js
|
|
8249
|
+
var init_stable_events = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8250
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.js"() {
|
|
8251
|
+
"use strict";
|
|
8252
|
+
}
|
|
8253
|
+
});
|
|
8254
|
+
|
|
8255
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
|
|
8180
8256
|
var init_esm2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8181
|
-
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.
|
|
8257
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.37.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js"() {
|
|
8182
8258
|
"use strict";
|
|
8183
8259
|
init_trace();
|
|
8184
8260
|
init_resource();
|
|
8185
8261
|
init_stable_attributes();
|
|
8186
8262
|
init_stable_metrics();
|
|
8263
|
+
init_stable_events();
|
|
8187
8264
|
}
|
|
8188
8265
|
});
|
|
8189
8266
|
|
|
@@ -8587,6 +8664,69 @@ var init_esm3 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
8587
8664
|
}
|
|
8588
8665
|
});
|
|
8589
8666
|
|
|
8667
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js
|
|
8668
|
+
var init_SemanticAttributes2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8669
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js"() {
|
|
8670
|
+
"use strict";
|
|
8671
|
+
}
|
|
8672
|
+
});
|
|
8673
|
+
|
|
8674
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js
|
|
8675
|
+
var init_trace2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8676
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js"() {
|
|
8677
|
+
"use strict";
|
|
8678
|
+
init_SemanticAttributes2();
|
|
8679
|
+
}
|
|
8680
|
+
});
|
|
8681
|
+
|
|
8682
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
|
|
8683
|
+
var init_SemanticResourceAttributes2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8684
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js"() {
|
|
8685
|
+
"use strict";
|
|
8686
|
+
}
|
|
8687
|
+
});
|
|
8688
|
+
|
|
8689
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js
|
|
8690
|
+
var init_resource2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8691
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js"() {
|
|
8692
|
+
"use strict";
|
|
8693
|
+
init_SemanticResourceAttributes2();
|
|
8694
|
+
}
|
|
8695
|
+
});
|
|
8696
|
+
|
|
8697
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
|
|
8698
|
+
var ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, ATTR_EXCEPTION_TYPE, ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_LANGUAGE2, ATTR_TELEMETRY_SDK_NAME2, ATTR_TELEMETRY_SDK_VERSION2;
|
|
8699
|
+
var init_stable_attributes2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8700
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js"() {
|
|
8701
|
+
"use strict";
|
|
8702
|
+
ATTR_EXCEPTION_MESSAGE = "exception.message";
|
|
8703
|
+
ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
|
|
8704
|
+
ATTR_EXCEPTION_TYPE = "exception.type";
|
|
8705
|
+
ATTR_SERVICE_NAME = "service.name";
|
|
8706
|
+
ATTR_TELEMETRY_SDK_LANGUAGE2 = "telemetry.sdk.language";
|
|
8707
|
+
ATTR_TELEMETRY_SDK_NAME2 = "telemetry.sdk.name";
|
|
8708
|
+
ATTR_TELEMETRY_SDK_VERSION2 = "telemetry.sdk.version";
|
|
8709
|
+
}
|
|
8710
|
+
});
|
|
8711
|
+
|
|
8712
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js
|
|
8713
|
+
var init_stable_metrics2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8714
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js"() {
|
|
8715
|
+
"use strict";
|
|
8716
|
+
}
|
|
8717
|
+
});
|
|
8718
|
+
|
|
8719
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
|
|
8720
|
+
var init_esm4 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8721
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js"() {
|
|
8722
|
+
"use strict";
|
|
8723
|
+
init_trace2();
|
|
8724
|
+
init_resource2();
|
|
8725
|
+
init_stable_attributes2();
|
|
8726
|
+
init_stable_metrics2();
|
|
8727
|
+
}
|
|
8728
|
+
});
|
|
8729
|
+
|
|
8590
8730
|
// ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/default-service-name.js
|
|
8591
8731
|
function defaultServiceName() {
|
|
8592
8732
|
return `unknown_service:${process.argv0}`;
|
|
@@ -8631,9 +8771,9 @@ function resourceFromAttributes(attributes) {
|
|
|
8631
8771
|
function defaultResource() {
|
|
8632
8772
|
return resourceFromAttributes({
|
|
8633
8773
|
[ATTR_SERVICE_NAME]: defaultServiceName(),
|
|
8634
|
-
[
|
|
8635
|
-
[
|
|
8636
|
-
[
|
|
8774
|
+
[ATTR_TELEMETRY_SDK_LANGUAGE2]: SDK_INFO[ATTR_TELEMETRY_SDK_LANGUAGE2],
|
|
8775
|
+
[ATTR_TELEMETRY_SDK_NAME2]: SDK_INFO[ATTR_TELEMETRY_SDK_NAME2],
|
|
8776
|
+
[ATTR_TELEMETRY_SDK_VERSION2]: SDK_INFO[ATTR_TELEMETRY_SDK_VERSION2]
|
|
8637
8777
|
});
|
|
8638
8778
|
}
|
|
8639
8779
|
function guardedRawAttributes(attributes) {
|
|
@@ -8656,7 +8796,7 @@ var init_ResourceImpl = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
8656
8796
|
"use strict";
|
|
8657
8797
|
_chunkCDBUTZMHjs.init_esm.call(void 0, );
|
|
8658
8798
|
init_esm3();
|
|
8659
|
-
|
|
8799
|
+
init_esm4();
|
|
8660
8800
|
init_platform2();
|
|
8661
8801
|
init_utils();
|
|
8662
8802
|
ResourceImpl = (_class15 = class _ResourceImpl {
|
|
@@ -8730,7 +8870,7 @@ var init_ResourceImpl = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
8730
8870
|
});
|
|
8731
8871
|
|
|
8732
8872
|
// ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/index.js
|
|
8733
|
-
var
|
|
8873
|
+
var init_esm5 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
8734
8874
|
"../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/index.js"() {
|
|
8735
8875
|
"use strict";
|
|
8736
8876
|
init_ResourceImpl();
|
|
@@ -8753,7 +8893,7 @@ var init_Span = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
8753
8893
|
"use strict";
|
|
8754
8894
|
_chunkCDBUTZMHjs.init_esm.call(void 0, );
|
|
8755
8895
|
init_esm3();
|
|
8756
|
-
|
|
8896
|
+
init_esm4();
|
|
8757
8897
|
init_enums();
|
|
8758
8898
|
SpanImpl2 = (_class16 = class {
|
|
8759
8899
|
// Below properties are included to implement ReadableSpan for export
|
|
@@ -9248,8 +9388,8 @@ function mergeConfig(userConfig) {
|
|
|
9248
9388
|
}
|
|
9249
9389
|
function reconfigureLimits(userConfig) {
|
|
9250
9390
|
const spanLimits = Object.assign({}, userConfig.spanLimits);
|
|
9251
|
-
spanLimits.attributeCountLimit = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([userConfig, 'access',
|
|
9252
|
-
spanLimits.attributeValueLengthLimit = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([userConfig, 'access',
|
|
9391
|
+
spanLimits.attributeCountLimit = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([userConfig, 'access', _116 => _116.spanLimits, 'optionalAccess', _117 => _117.attributeCountLimit]), () => ( _optionalChain([userConfig, 'access', _118 => _118.generalLimits, 'optionalAccess', _119 => _119.attributeCountLimit]))), () => ( getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT"))), () => ( getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT"))), () => ( DEFAULT_ATTRIBUTE_COUNT_LIMIT));
|
|
9392
|
+
spanLimits.attributeValueLengthLimit = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([userConfig, 'access', _120 => _120.spanLimits, 'optionalAccess', _121 => _121.attributeValueLengthLimit]), () => ( _optionalChain([userConfig, 'access', _122 => _122.generalLimits, 'optionalAccess', _123 => _123.attributeValueLengthLimit]))), () => ( getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT"))), () => ( getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT"))), () => ( DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT));
|
|
9253
9393
|
return Object.assign({}, userConfig, { spanLimits });
|
|
9254
9394
|
}
|
|
9255
9395
|
var DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
|
|
@@ -9283,10 +9423,10 @@ var init_BatchSpanProcessorBase = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
9283
9423
|
__init61() {this._droppedSpansCount = 0}
|
|
9284
9424
|
constructor(_exporter, config) {;_class17.prototype.__init59.call(this);_class17.prototype.__init60.call(this);_class17.prototype.__init61.call(this);
|
|
9285
9425
|
this._exporter = _exporter;
|
|
9286
|
-
this._maxExportBatchSize = typeof _optionalChain([config, 'optionalAccess',
|
|
9287
|
-
this._maxQueueSize = typeof _optionalChain([config, 'optionalAccess',
|
|
9288
|
-
this._scheduledDelayMillis = typeof _optionalChain([config, 'optionalAccess',
|
|
9289
|
-
this._exportTimeoutMillis = typeof _optionalChain([config, 'optionalAccess',
|
|
9426
|
+
this._maxExportBatchSize = typeof _optionalChain([config, 'optionalAccess', _124 => _124.maxExportBatchSize]) === "number" ? config.maxExportBatchSize : _nullishCoalesce(getNumberFromEnv("OTEL_BSP_MAX_EXPORT_BATCH_SIZE"), () => ( 512));
|
|
9427
|
+
this._maxQueueSize = typeof _optionalChain([config, 'optionalAccess', _125 => _125.maxQueueSize]) === "number" ? config.maxQueueSize : _nullishCoalesce(getNumberFromEnv("OTEL_BSP_MAX_QUEUE_SIZE"), () => ( 2048));
|
|
9428
|
+
this._scheduledDelayMillis = typeof _optionalChain([config, 'optionalAccess', _126 => _126.scheduledDelayMillis]) === "number" ? config.scheduledDelayMillis : _nullishCoalesce(getNumberFromEnv("OTEL_BSP_SCHEDULE_DELAY"), () => ( 5e3));
|
|
9429
|
+
this._exportTimeoutMillis = typeof _optionalChain([config, 'optionalAccess', _127 => _127.exportTimeoutMillis]) === "number" ? config.exportTimeoutMillis : _nullishCoalesce(getNumberFromEnv("OTEL_BSP_EXPORT_TIMEOUT"), () => ( 3e4));
|
|
9290
9430
|
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
|
|
9291
9431
|
if (this._maxExportBatchSize > this._maxQueueSize) {
|
|
9292
9432
|
_chunkCDBUTZMHjs.diag.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize");
|
|
@@ -9547,7 +9687,7 @@ var init_Tracer = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
9547
9687
|
const nonRecordingSpan = _chunkCDBUTZMHjs.trace.wrapSpanContext(_chunkCDBUTZMHjs.INVALID_SPAN_CONTEXT);
|
|
9548
9688
|
return nonRecordingSpan;
|
|
9549
9689
|
}
|
|
9550
|
-
const parentSpanContext = _optionalChain([parentSpan, 'optionalAccess',
|
|
9690
|
+
const parentSpanContext = _optionalChain([parentSpan, 'optionalAccess', _128 => _128.spanContext, 'call', _129 => _129()]);
|
|
9551
9691
|
const spanId = this._idGenerator.generateSpanId();
|
|
9552
9692
|
let validParentSpanContext;
|
|
9553
9693
|
let traceId;
|
|
@@ -9682,7 +9822,7 @@ var init_BasicTracerProvider = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
9682
9822
|
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js"() {
|
|
9683
9823
|
"use strict";
|
|
9684
9824
|
init_esm3();
|
|
9685
|
-
|
|
9825
|
+
init_esm5();
|
|
9686
9826
|
init_Tracer();
|
|
9687
9827
|
init_config();
|
|
9688
9828
|
init_MultiSpanProcessor();
|
|
@@ -9705,15 +9845,15 @@ var init_BasicTracerProvider = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
9705
9845
|
resource: this._resource
|
|
9706
9846
|
});
|
|
9707
9847
|
const spanProcessors = [];
|
|
9708
|
-
if (_optionalChain([config, 'access',
|
|
9848
|
+
if (_optionalChain([config, 'access', _130 => _130.spanProcessors, 'optionalAccess', _131 => _131.length])) {
|
|
9709
9849
|
spanProcessors.push(...config.spanProcessors);
|
|
9710
9850
|
}
|
|
9711
9851
|
this._activeSpanProcessor = new MultiSpanProcessor(spanProcessors);
|
|
9712
9852
|
}
|
|
9713
9853
|
getTracer(name, version, options) {
|
|
9714
|
-
const key = `${name}@${version || ""}:${_optionalChain([options, 'optionalAccess',
|
|
9854
|
+
const key = `${name}@${version || ""}:${_optionalChain([options, 'optionalAccess', _132 => _132.schemaUrl]) || ""}`;
|
|
9715
9855
|
if (!this._tracers.has(key)) {
|
|
9716
|
-
this._tracers.set(key, new Tracer({ name, version, schemaUrl: _optionalChain([options, 'optionalAccess',
|
|
9856
|
+
this._tracers.set(key, new Tracer({ name, version, schemaUrl: _optionalChain([options, 'optionalAccess', _133 => _133.schemaUrl]) }, this._config, this._resource, this._activeSpanProcessor));
|
|
9717
9857
|
}
|
|
9718
9858
|
return this._tracers.get(key);
|
|
9719
9859
|
}
|
|
@@ -9797,7 +9937,7 @@ var init_ConsoleSpanExporter = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
9797
9937
|
instrumentationScope: span.instrumentationScope,
|
|
9798
9938
|
traceId: span.spanContext().traceId,
|
|
9799
9939
|
parentSpanContext: span.parentSpanContext,
|
|
9800
|
-
traceState: _optionalChain([span, 'access',
|
|
9940
|
+
traceState: _optionalChain([span, 'access', _134 => _134.spanContext, 'call', _135 => _135(), 'access', _136 => _136.traceState, 'optionalAccess', _137 => _137.serialize, 'call', _138 => _138()]),
|
|
9801
9941
|
name: span.name,
|
|
9802
9942
|
id: span.spanContext().spanId,
|
|
9803
9943
|
kind: span.kind,
|
|
@@ -9906,7 +10046,7 @@ var init_SimpleSpanProcessor = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
9906
10046
|
}
|
|
9907
10047
|
async _doExport(span) {
|
|
9908
10048
|
if (span.resource.asyncAttributesPending) {
|
|
9909
|
-
await _optionalChain([span, 'access',
|
|
10049
|
+
await _optionalChain([span, 'access', _139 => _139.resource, 'access', _140 => _140.waitForAsyncAttributes, 'optionalCall', _141 => _141()]);
|
|
9910
10050
|
}
|
|
9911
10051
|
const result = await internal._export(this._exporter, [span]);
|
|
9912
10052
|
if (result.code !== ExportResultCode.SUCCESS) {
|
|
@@ -9959,7 +10099,7 @@ _chunkCDBUTZMHjs.__export.call(void 0, esm_exports2, {
|
|
|
9959
10099
|
SimpleSpanProcessor: () => SimpleSpanProcessor,
|
|
9960
10100
|
TraceIdRatioBasedSampler: () => TraceIdRatioBasedSampler
|
|
9961
10101
|
});
|
|
9962
|
-
var
|
|
10102
|
+
var init_esm6 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
9963
10103
|
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js"() {
|
|
9964
10104
|
"use strict";
|
|
9965
10105
|
init_BasicTracerProvider();
|
|
@@ -10169,7 +10309,7 @@ var init_ExportResult2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
10169
10309
|
});
|
|
10170
10310
|
|
|
10171
10311
|
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js
|
|
10172
|
-
var
|
|
10312
|
+
var init_esm7 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
10173
10313
|
"../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js"() {
|
|
10174
10314
|
"use strict";
|
|
10175
10315
|
init_time2();
|
|
@@ -10207,7 +10347,7 @@ var OTLPExportDelegate;
|
|
|
10207
10347
|
var init_otlp_export_delegate = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
10208
10348
|
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js"() {
|
|
10209
10349
|
"use strict";
|
|
10210
|
-
|
|
10350
|
+
init_esm7();
|
|
10211
10351
|
init_types();
|
|
10212
10352
|
init_logging_response_handler();
|
|
10213
10353
|
_chunkCDBUTZMHjs.init_esm.call(void 0, );
|
|
@@ -10293,7 +10433,7 @@ var init_otlp_export_delegate = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
10293
10433
|
});
|
|
10294
10434
|
|
|
10295
10435
|
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js
|
|
10296
|
-
var
|
|
10436
|
+
var init_esm8 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
10297
10437
|
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js"() {
|
|
10298
10438
|
"use strict";
|
|
10299
10439
|
init_OTLPExporterBase();
|
|
@@ -10377,7 +10517,7 @@ var encodeTimestamp, DEFAULT_ENCODER;
|
|
|
10377
10517
|
var init_utils3 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
10378
10518
|
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js"() {
|
|
10379
10519
|
"use strict";
|
|
10380
|
-
|
|
10520
|
+
init_esm7();
|
|
10381
10521
|
init_hex_to_binary();
|
|
10382
10522
|
encodeTimestamp = typeof BigInt !== "undefined" ? encodeAsString : hrTimeToNanoseconds2;
|
|
10383
10523
|
DEFAULT_ENCODER = {
|
|
@@ -10443,12 +10583,12 @@ var init_internal = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
10443
10583
|
function sdkSpanToOtlpSpan(span, encoder) {
|
|
10444
10584
|
const ctx = span.spanContext();
|
|
10445
10585
|
const status = span.status;
|
|
10446
|
-
const parentSpanId = _optionalChain([span, 'access',
|
|
10586
|
+
const parentSpanId = _optionalChain([span, 'access', _142 => _142.parentSpanContext, 'optionalAccess', _143 => _143.spanId]) ? encoder.encodeSpanContext(_optionalChain([span, 'access', _144 => _144.parentSpanContext, 'optionalAccess', _145 => _145.spanId])) : void 0;
|
|
10447
10587
|
return {
|
|
10448
10588
|
traceId: encoder.encodeSpanContext(ctx.traceId),
|
|
10449
10589
|
spanId: encoder.encodeSpanContext(ctx.spanId),
|
|
10450
10590
|
parentSpanId,
|
|
10451
|
-
traceState: _optionalChain([ctx, 'access',
|
|
10591
|
+
traceState: _optionalChain([ctx, 'access', _146 => _146.traceState, 'optionalAccess', _147 => _147.serialize, 'call', _148 => _148()]),
|
|
10452
10592
|
name: span.name,
|
|
10453
10593
|
// Span kind is offset by 1 because the API does not define a value for unset
|
|
10454
10594
|
kind: span.kind == null ? 0 : span.kind + 1,
|
|
@@ -10472,7 +10612,7 @@ function toOtlpLink(link, encoder) {
|
|
|
10472
10612
|
attributes: link.attributes ? toAttributes(link.attributes) : [],
|
|
10473
10613
|
spanId: encoder.encodeSpanContext(link.context.spanId),
|
|
10474
10614
|
traceId: encoder.encodeSpanContext(link.context.traceId),
|
|
10475
|
-
traceState: _optionalChain([link, 'access',
|
|
10615
|
+
traceState: _optionalChain([link, 'access', _149 => _149.context, 'access', _150 => _150.traceState, 'optionalAccess', _151 => _151.serialize, 'call', _152 => _152()]),
|
|
10476
10616
|
droppedAttributesCount: link.droppedAttributesCount || 0
|
|
10477
10617
|
};
|
|
10478
10618
|
}
|
|
@@ -10550,7 +10690,7 @@ var init_internal2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
10550
10690
|
|
|
10551
10691
|
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js
|
|
10552
10692
|
var JsonTraceSerializer;
|
|
10553
|
-
var
|
|
10693
|
+
var init_trace3 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
10554
10694
|
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js"() {
|
|
10555
10695
|
"use strict";
|
|
10556
10696
|
init_internal2();
|
|
@@ -10575,12 +10715,12 @@ var init_trace2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
10575
10715
|
var init_json = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
10576
10716
|
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js"() {
|
|
10577
10717
|
"use strict";
|
|
10578
|
-
|
|
10718
|
+
init_trace3();
|
|
10579
10719
|
}
|
|
10580
10720
|
});
|
|
10581
10721
|
|
|
10582
10722
|
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/index.js
|
|
10583
|
-
var
|
|
10723
|
+
var init_esm9 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
10584
10724
|
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/index.js"() {
|
|
10585
10725
|
"use strict";
|
|
10586
10726
|
init_json();
|
|
@@ -10832,7 +10972,7 @@ var init_otlp_http_export_delegate = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
10832
10972
|
|
|
10833
10973
|
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js
|
|
10834
10974
|
function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
|
|
10835
|
-
const envTimeout = _optionalChain([process, 'access',
|
|
10975
|
+
const envTimeout = _optionalChain([process, 'access', _153 => _153.env, 'access', _154 => _154[timeoutEnvVar], 'optionalAccess', _155 => _155.trim, 'call', _156 => _156()]);
|
|
10836
10976
|
if (envTimeout != null && envTimeout !== "") {
|
|
10837
10977
|
const definedTimeout = Number(envTimeout);
|
|
10838
10978
|
if (Number.isFinite(definedTimeout) && definedTimeout > 0) {
|
|
@@ -10848,7 +10988,7 @@ function getTimeoutFromEnv(signalIdentifier) {
|
|
|
10848
10988
|
return _nullishCoalesce(specificTimeout, () => ( nonSpecificTimeout));
|
|
10849
10989
|
}
|
|
10850
10990
|
function parseAndValidateCompressionFromEnv(compressionEnvVar) {
|
|
10851
|
-
const compression = _optionalChain([process, 'access',
|
|
10991
|
+
const compression = _optionalChain([process, 'access', _157 => _157.env, 'access', _158 => _158[compressionEnvVar], 'optionalAccess', _159 => _159.trim, 'call', _160 => _160()]);
|
|
10852
10992
|
if (compression === "") {
|
|
10853
10993
|
return void 0;
|
|
10854
10994
|
}
|
|
@@ -10880,7 +11020,7 @@ var init_shared_env_configuration = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
10880
11020
|
function validateAndNormalizeHeaders(partialHeaders) {
|
|
10881
11021
|
return () => {
|
|
10882
11022
|
const headers = {};
|
|
10883
|
-
Object.entries(_nullishCoalesce(_optionalChain([partialHeaders, 'optionalCall',
|
|
11023
|
+
Object.entries(_nullishCoalesce(_optionalChain([partialHeaders, 'optionalCall', _161 => _161()]), () => ( {}))).forEach(([key, value]) => {
|
|
10884
11024
|
if (typeof value !== "undefined") {
|
|
10885
11025
|
headers[key] = String(value);
|
|
10886
11026
|
} else {
|
|
@@ -10950,8 +11090,8 @@ var init_otlp_http_configuration = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
10950
11090
|
|
|
10951
11091
|
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-env-configuration.js
|
|
10952
11092
|
function getStaticHeadersFromEnv(signalIdentifier) {
|
|
10953
|
-
const signalSpecificRawHeaders = _optionalChain([process, 'access',
|
|
10954
|
-
const nonSignalSpecificRawHeaders = _optionalChain([process, 'access',
|
|
11093
|
+
const signalSpecificRawHeaders = _optionalChain([process, 'access', _162 => _162.env, 'access', _163 => _163[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`], 'optionalAccess', _164 => _164.trim, 'call', _165 => _165()]);
|
|
11094
|
+
const nonSignalSpecificRawHeaders = _optionalChain([process, 'access', _166 => _166.env, 'access', _167 => _167["OTEL_EXPORTER_OTLP_HEADERS"], 'optionalAccess', _168 => _168.trim, 'call', _169 => _169()]);
|
|
10955
11095
|
const signalSpecificHeaders = parseKeyPairsIntoRecord(signalSpecificRawHeaders);
|
|
10956
11096
|
const nonSignalSpecificHeaders = parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
|
|
10957
11097
|
if (Object.keys(signalSpecificHeaders).length === 0 && Object.keys(nonSignalSpecificHeaders).length === 0) {
|
|
@@ -10963,7 +11103,7 @@ function appendRootPathToUrlIfNeeded(url) {
|
|
|
10963
11103
|
try {
|
|
10964
11104
|
const parsedUrl = new URL(url);
|
|
10965
11105
|
return parsedUrl.toString();
|
|
10966
|
-
} catch (
|
|
11106
|
+
} catch (e11) {
|
|
10967
11107
|
_chunkCDBUTZMHjs.diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
|
|
10968
11108
|
return void 0;
|
|
10969
11109
|
}
|
|
@@ -10971,7 +11111,7 @@ function appendRootPathToUrlIfNeeded(url) {
|
|
|
10971
11111
|
function appendResourcePathToUrl(url, path3) {
|
|
10972
11112
|
try {
|
|
10973
11113
|
new URL(url);
|
|
10974
|
-
} catch (
|
|
11114
|
+
} catch (e12) {
|
|
10975
11115
|
_chunkCDBUTZMHjs.diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
|
|
10976
11116
|
return void 0;
|
|
10977
11117
|
}
|
|
@@ -10981,21 +11121,21 @@ function appendResourcePathToUrl(url, path3) {
|
|
|
10981
11121
|
url += path3;
|
|
10982
11122
|
try {
|
|
10983
11123
|
new URL(url);
|
|
10984
|
-
} catch (
|
|
11124
|
+
} catch (e13) {
|
|
10985
11125
|
_chunkCDBUTZMHjs.diag.warn(`Configuration: Provided URL appended with '${path3}' is not a valid URL, using 'undefined' instead of '${url}'`);
|
|
10986
11126
|
return void 0;
|
|
10987
11127
|
}
|
|
10988
11128
|
return url;
|
|
10989
11129
|
}
|
|
10990
11130
|
function getNonSpecificUrlFromEnv(signalResourcePath) {
|
|
10991
|
-
const envUrl = _optionalChain([process, 'access',
|
|
11131
|
+
const envUrl = _optionalChain([process, 'access', _170 => _170.env, 'access', _171 => _171.OTEL_EXPORTER_OTLP_ENDPOINT, 'optionalAccess', _172 => _172.trim, 'call', _173 => _173()]);
|
|
10992
11132
|
if (envUrl == null || envUrl === "") {
|
|
10993
11133
|
return void 0;
|
|
10994
11134
|
}
|
|
10995
11135
|
return appendResourcePathToUrl(envUrl, signalResourcePath);
|
|
10996
11136
|
}
|
|
10997
11137
|
function getSpecificUrlFromEnv(signalIdentifier) {
|
|
10998
|
-
const envUrl = _optionalChain([process, 'access',
|
|
11138
|
+
const envUrl = _optionalChain([process, 'access', _174 => _174.env, 'access', _175 => _175[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`], 'optionalAccess', _176 => _176.trim, 'call', _177 => _177()]);
|
|
10999
11139
|
if (envUrl == null || envUrl === "") {
|
|
11000
11140
|
return void 0;
|
|
11001
11141
|
}
|
|
@@ -11011,7 +11151,7 @@ function getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePat
|
|
|
11011
11151
|
var init_otlp_http_env_configuration = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
11012
11152
|
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-env-configuration.js"() {
|
|
11013
11153
|
"use strict";
|
|
11014
|
-
|
|
11154
|
+
init_esm7();
|
|
11015
11155
|
_chunkCDBUTZMHjs.init_esm.call(void 0, );
|
|
11016
11156
|
init_shared_env_configuration();
|
|
11017
11157
|
init_shared_configuration();
|
|
@@ -11020,7 +11160,7 @@ var init_otlp_http_env_configuration = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
|
11020
11160
|
|
|
11021
11161
|
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js
|
|
11022
11162
|
function convertLegacyAgentOptions(config) {
|
|
11023
|
-
if (_optionalChain([config, 'optionalAccess',
|
|
11163
|
+
if (_optionalChain([config, 'optionalAccess', _178 => _178.keepAlive]) != null) {
|
|
11024
11164
|
if (config.httpAgentOptions != null) {
|
|
11025
11165
|
if (config.httpAgentOptions.keepAlive == null) {
|
|
11026
11166
|
config.httpAgentOptions.keepAlive = config.keepAlive;
|
|
@@ -11070,9 +11210,9 @@ var OTLPTraceExporter;
|
|
|
11070
11210
|
var init_OTLPTraceExporter = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
11071
11211
|
"../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js"() {
|
|
11072
11212
|
"use strict";
|
|
11073
|
-
init_esm7();
|
|
11074
|
-
init_version2();
|
|
11075
11213
|
init_esm8();
|
|
11214
|
+
init_version2();
|
|
11215
|
+
init_esm9();
|
|
11076
11216
|
init_index_node_http();
|
|
11077
11217
|
OTLPTraceExporter = class extends OTLPExporterBase {
|
|
11078
11218
|
constructor(config = {}) {
|
|
@@ -11106,7 +11246,7 @@ var esm_exports3 = {};
|
|
|
11106
11246
|
_chunkCDBUTZMHjs.__export.call(void 0, esm_exports3, {
|
|
11107
11247
|
OTLPTraceExporter: () => OTLPTraceExporter
|
|
11108
11248
|
});
|
|
11109
|
-
var
|
|
11249
|
+
var init_esm10 = _chunkCDBUTZMHjs.__esm.call(void 0, {
|
|
11110
11250
|
"../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js"() {
|
|
11111
11251
|
"use strict";
|
|
11112
11252
|
init_platform4();
|
|
@@ -11144,7 +11284,7 @@ async function getBaseBranch(remote = void 0) {
|
|
|
11144
11284
|
if (git === null) {
|
|
11145
11285
|
throw new Error("Not in a git repo");
|
|
11146
11286
|
}
|
|
11147
|
-
const remoteName = await _asyncNullishCoalesce(remote, async () => ( await _asyncOptionalChain([(await git.getRemotes()), 'access', async
|
|
11287
|
+
const remoteName = await _asyncNullishCoalesce(remote, async () => ( await _asyncOptionalChain([(await git.getRemotes()), 'access', async _179 => _179[0], 'optionalAccess', async _180 => _180.name])));
|
|
11148
11288
|
if (!remoteName) {
|
|
11149
11289
|
throw new Error("No remote found");
|
|
11150
11290
|
}
|
|
@@ -11166,7 +11306,7 @@ async function getBaseBranch(remote = void 0) {
|
|
|
11166
11306
|
throw new Error(`Could not find HEAD branch in remote ${remoteName}`);
|
|
11167
11307
|
}
|
|
11168
11308
|
branch = match[1];
|
|
11169
|
-
} catch (
|
|
11309
|
+
} catch (e14) {
|
|
11170
11310
|
branch = "main";
|
|
11171
11311
|
}
|
|
11172
11312
|
}
|
|
@@ -11237,7 +11377,7 @@ async function getRepoInfo(settings) {
|
|
|
11237
11377
|
return repo;
|
|
11238
11378
|
}
|
|
11239
11379
|
let sanitized = {};
|
|
11240
|
-
_optionalChain([settings, 'access',
|
|
11380
|
+
_optionalChain([settings, 'access', _181 => _181.fields, 'optionalAccess', _182 => _182.forEach, 'call', _183 => _183((field) => {
|
|
11241
11381
|
sanitized = { ...sanitized, [field]: repo[field] };
|
|
11242
11382
|
})]);
|
|
11243
11383
|
return sanitized;
|
|
@@ -11324,9 +11464,9 @@ function getCallerLocation() {
|
|
|
11324
11464
|
const entries = getStackTrace();
|
|
11325
11465
|
for (const frame of entries) {
|
|
11326
11466
|
if (thisDir === void 0) {
|
|
11327
|
-
thisDir = _optionalChain([isomorph_default, 'access',
|
|
11467
|
+
thisDir = _optionalChain([isomorph_default, 'access', _184 => _184.pathDirname, 'optionalCall', _185 => _185(frame.fileName)]);
|
|
11328
11468
|
}
|
|
11329
|
-
if (_optionalChain([isomorph_default, 'access',
|
|
11469
|
+
if (_optionalChain([isomorph_default, 'access', _186 => _186.pathDirname, 'optionalCall', _187 => _187(frame.fileName)]) !== thisDir) {
|
|
11330
11470
|
return {
|
|
11331
11471
|
caller_functionname: frame.functionName,
|
|
11332
11472
|
caller_filename: frame.fileName,
|
|
@@ -11391,6 +11531,7 @@ _chunkCDBUTZMHjs.__export.call(void 0, exports_node_exports, {
|
|
|
11391
11531
|
FailedHTTPResponse: () => FailedHTTPResponse,
|
|
11392
11532
|
IDGenerator: () => IDGenerator,
|
|
11393
11533
|
INTERNAL_BTQL_LIMIT: () => INTERNAL_BTQL_LIMIT,
|
|
11534
|
+
JSONAttachment: () => JSONAttachment,
|
|
11394
11535
|
LEGACY_CACHED_HEADER: () => LEGACY_CACHED_HEADER,
|
|
11395
11536
|
LazyValue: () => LazyValue,
|
|
11396
11537
|
Logger: () => Logger,
|
|
@@ -13164,6 +13305,9 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
13164
13305
|
repoInfo: evaluator.repoInfo,
|
|
13165
13306
|
dataset: Dataset2.isDataset(data) ? data : void 0
|
|
13166
13307
|
});
|
|
13308
|
+
if (experiment && typeof process !== "undefined" && _optionalChain([process, 'access', _188 => _188.env, 'optionalAccess', _189 => _189.BRAINTRUST_OTEL_COMPAT, 'optionalAccess', _190 => _190.toLowerCase, 'call', _191 => _191()]) === "true") {
|
|
13309
|
+
await experiment._waitForId();
|
|
13310
|
+
}
|
|
13167
13311
|
if (experiment && options.onStart) {
|
|
13168
13312
|
const summary = await experiment.summarize({ summarizeScores: false });
|
|
13169
13313
|
options.onStart(summary);
|
|
@@ -13365,10 +13509,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
13365
13509
|
span,
|
|
13366
13510
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
13367
13511
|
reportProgress: (event) => {
|
|
13368
|
-
_optionalChain([stream, 'optionalCall',
|
|
13512
|
+
_optionalChain([stream, 'optionalCall', _192 => _192({
|
|
13369
13513
|
...event,
|
|
13370
13514
|
id: rootSpan.id,
|
|
13371
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
13515
|
+
origin: _optionalChain([baseEvent, 'access', _193 => _193.event, 'optionalAccess', _194 => _194.origin]),
|
|
13372
13516
|
name: evaluator.evalName,
|
|
13373
13517
|
object_type: "task"
|
|
13374
13518
|
})]);
|
|
@@ -13518,7 +13662,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
13518
13662
|
...scores
|
|
13519
13663
|
},
|
|
13520
13664
|
error: error2,
|
|
13521
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
13665
|
+
origin: _optionalChain([baseEvent, 'access', _195 => _195.event, 'optionalAccess', _196 => _196.origin])
|
|
13522
13666
|
});
|
|
13523
13667
|
};
|
|
13524
13668
|
if (!experiment) {
|
|
@@ -14018,7 +14162,7 @@ function parseSpanFromResponseCreateParams(params) {
|
|
|
14018
14162
|
}
|
|
14019
14163
|
function parseEventFromResponseCreateResult(result) {
|
|
14020
14164
|
const data = {};
|
|
14021
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
14165
|
+
if (_optionalChain([result, 'optionalAccess', _197 => _197.output]) !== void 0) {
|
|
14022
14166
|
data.output = processImagesInOutput(result.output);
|
|
14023
14167
|
}
|
|
14024
14168
|
if (result) {
|
|
@@ -14027,7 +14171,7 @@ function parseEventFromResponseCreateResult(result) {
|
|
|
14027
14171
|
data.metadata = metadata;
|
|
14028
14172
|
}
|
|
14029
14173
|
}
|
|
14030
|
-
data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess',
|
|
14174
|
+
data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _198 => _198.usage]));
|
|
14031
14175
|
return data;
|
|
14032
14176
|
}
|
|
14033
14177
|
function processImagesInOutput(output) {
|
|
@@ -14081,7 +14225,7 @@ function parseSpanFromResponseParseParams(params) {
|
|
|
14081
14225
|
}
|
|
14082
14226
|
function parseEventFromResponseParseResult(result) {
|
|
14083
14227
|
const data = {};
|
|
14084
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
14228
|
+
if (_optionalChain([result, 'optionalAccess', _199 => _199.output]) !== void 0) {
|
|
14085
14229
|
data.output = processImagesInOutput(result.output);
|
|
14086
14230
|
}
|
|
14087
14231
|
if (result) {
|
|
@@ -14090,7 +14234,7 @@ function parseEventFromResponseParseResult(result) {
|
|
|
14090
14234
|
data.metadata = metadata;
|
|
14091
14235
|
}
|
|
14092
14236
|
}
|
|
14093
|
-
data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess',
|
|
14237
|
+
data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _200 => _200.usage]));
|
|
14094
14238
|
return data;
|
|
14095
14239
|
}
|
|
14096
14240
|
function traceResponseCreateStream(stream, timedSpan) {
|
|
@@ -14107,7 +14251,7 @@ function traceResponseCreateStream(stream, timedSpan) {
|
|
|
14107
14251
|
return result;
|
|
14108
14252
|
}
|
|
14109
14253
|
const item = result.value;
|
|
14110
|
-
if (!item || !_optionalChain([item, 'optionalAccess',
|
|
14254
|
+
if (!item || !_optionalChain([item, 'optionalAccess', _201 => _201.type]) || !_optionalChain([item, 'optionalAccess', _202 => _202.response])) {
|
|
14111
14255
|
return result;
|
|
14112
14256
|
}
|
|
14113
14257
|
const event = parseLogFromItem(item);
|
|
@@ -14118,14 +14262,14 @@ function traceResponseCreateStream(stream, timedSpan) {
|
|
|
14118
14262
|
};
|
|
14119
14263
|
}
|
|
14120
14264
|
function parseLogFromItem(item) {
|
|
14121
|
-
if (!item || !_optionalChain([item, 'optionalAccess',
|
|
14265
|
+
if (!item || !_optionalChain([item, 'optionalAccess', _203 => _203.type]) || !_optionalChain([item, 'optionalAccess', _204 => _204.response])) {
|
|
14122
14266
|
return {};
|
|
14123
14267
|
}
|
|
14124
14268
|
const response = item.response;
|
|
14125
14269
|
switch (item.type) {
|
|
14126
14270
|
case "response.completed":
|
|
14127
14271
|
const data = {};
|
|
14128
|
-
if (_optionalChain([response, 'optionalAccess',
|
|
14272
|
+
if (_optionalChain([response, 'optionalAccess', _205 => _205.output]) !== void 0) {
|
|
14129
14273
|
data.output = processImagesInOutput(response.output);
|
|
14130
14274
|
}
|
|
14131
14275
|
if (response) {
|
|
@@ -14134,7 +14278,7 @@ function parseLogFromItem(item) {
|
|
|
14134
14278
|
data.metadata = metadata;
|
|
14135
14279
|
}
|
|
14136
14280
|
}
|
|
14137
|
-
data.metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess',
|
|
14281
|
+
data.metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _206 => _206.usage]));
|
|
14138
14282
|
return data;
|
|
14139
14283
|
default:
|
|
14140
14284
|
return {};
|
|
@@ -14318,8 +14462,8 @@ function wrapOpenAIv4(openai) {
|
|
|
14318
14462
|
const embeddingProxy = createEndpointProxy(openai.embeddings, wrapEmbeddings);
|
|
14319
14463
|
const moderationProxy = createEndpointProxy(openai.moderations, wrapModerations);
|
|
14320
14464
|
let betaProxy2;
|
|
14321
|
-
if (_optionalChain([openai, 'access',
|
|
14322
|
-
const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess',
|
|
14465
|
+
if (_optionalChain([openai, 'access', _207 => _207.beta, 'optionalAccess', _208 => _208.chat, 'optionalAccess', _209 => _209.completions, 'optionalAccess', _210 => _210.stream])) {
|
|
14466
|
+
const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess', _211 => _211.beta, 'optionalAccess', _212 => _212.chat, 'access', _213 => _213.completions]), {
|
|
14323
14467
|
get(target, name, receiver) {
|
|
14324
14468
|
const baseVal = Reflect.get(target, name, receiver);
|
|
14325
14469
|
if (name === "parse") {
|
|
@@ -14367,7 +14511,7 @@ function wrapOpenAIv4(openai) {
|
|
|
14367
14511
|
});
|
|
14368
14512
|
}
|
|
14369
14513
|
function logCompletionResponse(startTime, response, span) {
|
|
14370
|
-
const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess',
|
|
14514
|
+
const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _214 => _214.usage]));
|
|
14371
14515
|
metrics.time_to_first_token = getCurrentUnixTimestamp() - startTime;
|
|
14372
14516
|
span.log({
|
|
14373
14517
|
output: response.choices,
|
|
@@ -14597,7 +14741,7 @@ function parseChatCompletionParams(params) {
|
|
|
14597
14741
|
function processEmbeddingResponse(result, span) {
|
|
14598
14742
|
span.log({
|
|
14599
14743
|
output: { embedding_length: result.data[0].embedding.length },
|
|
14600
|
-
metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess',
|
|
14744
|
+
metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _215 => _215.usage]))
|
|
14601
14745
|
});
|
|
14602
14746
|
}
|
|
14603
14747
|
function processModerationResponse(result, span) {
|
|
@@ -14627,10 +14771,10 @@ function postprocessStreamingResults(allResults) {
|
|
|
14627
14771
|
if (result.usage) {
|
|
14628
14772
|
metrics = {
|
|
14629
14773
|
...metrics,
|
|
14630
|
-
...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess',
|
|
14774
|
+
...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _216 => _216.usage]))
|
|
14631
14775
|
};
|
|
14632
14776
|
}
|
|
14633
|
-
const delta = _optionalChain([result, 'access',
|
|
14777
|
+
const delta = _optionalChain([result, 'access', _217 => _217.choices, 'optionalAccess', _218 => _218[0], 'optionalAccess', _219 => _219.delta]);
|
|
14634
14778
|
if (!delta) {
|
|
14635
14779
|
continue;
|
|
14636
14780
|
}
|
|
@@ -14737,23 +14881,23 @@ function extractAnthropicCacheTokens(cacheReadTokens = 0, cacheCreationTokens =
|
|
|
14737
14881
|
// src/wrappers/ai-sdk-shared.ts
|
|
14738
14882
|
init_logger();
|
|
14739
14883
|
function detectProviderFromResult(result) {
|
|
14740
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
14884
|
+
if (!_optionalChain([result, 'optionalAccess', _220 => _220.providerMetadata])) {
|
|
14741
14885
|
return void 0;
|
|
14742
14886
|
}
|
|
14743
14887
|
const keys = Object.keys(result.providerMetadata);
|
|
14744
|
-
return _optionalChain([keys, 'optionalAccess',
|
|
14888
|
+
return _optionalChain([keys, 'optionalAccess', _221 => _221.at, 'call', _222 => _222(0)]);
|
|
14745
14889
|
}
|
|
14746
14890
|
function extractModelFromResult(result) {
|
|
14747
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
14891
|
+
if (_optionalChain([result, 'optionalAccess', _223 => _223.response, 'optionalAccess', _224 => _224.modelId])) {
|
|
14748
14892
|
return result.response.modelId;
|
|
14749
14893
|
}
|
|
14750
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
14894
|
+
if (_optionalChain([result, 'optionalAccess', _225 => _225.request, 'optionalAccess', _226 => _226.body, 'optionalAccess', _227 => _227.model])) {
|
|
14751
14895
|
return result.request.body.model;
|
|
14752
14896
|
}
|
|
14753
14897
|
return void 0;
|
|
14754
14898
|
}
|
|
14755
14899
|
function extractModelFromWrapGenerateCallback(model) {
|
|
14756
|
-
return _optionalChain([model, 'optionalAccess',
|
|
14900
|
+
return _optionalChain([model, 'optionalAccess', _228 => _228.modelId]);
|
|
14757
14901
|
}
|
|
14758
14902
|
function camelToSnake(str) {
|
|
14759
14903
|
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
@@ -14798,7 +14942,7 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
14798
14942
|
metrics.prompt_cached_tokens = cachedInputTokens;
|
|
14799
14943
|
}
|
|
14800
14944
|
if (provider === "anthropic") {
|
|
14801
|
-
const anthropicMetadata = _optionalChain([providerMetadata, 'optionalAccess',
|
|
14945
|
+
const anthropicMetadata = _optionalChain([providerMetadata, 'optionalAccess', _229 => _229.anthropic]);
|
|
14802
14946
|
if (anthropicMetadata) {
|
|
14803
14947
|
const cacheReadTokens = getNumberProperty(anthropicMetadata.usage, "cache_read_input_tokens") || 0;
|
|
14804
14948
|
const cacheCreationTokens = getNumberProperty(
|
|
@@ -14824,7 +14968,7 @@ function extractToolCallsFromSteps(steps) {
|
|
|
14824
14968
|
if (!Array.isArray(steps)) return toolCalls;
|
|
14825
14969
|
let idx = 0;
|
|
14826
14970
|
for (const step of steps) {
|
|
14827
|
-
const blocks = _optionalChain([step, 'optionalAccess',
|
|
14971
|
+
const blocks = _optionalChain([step, 'optionalAccess', _230 => _230.content]);
|
|
14828
14972
|
if (!Array.isArray(blocks)) continue;
|
|
14829
14973
|
for (const block of blocks) {
|
|
14830
14974
|
if (block && typeof block === "object" && block.type === "tool-call") {
|
|
@@ -14847,7 +14991,7 @@ function buildAssistantOutputWithToolCalls(result, toolCalls) {
|
|
|
14847
14991
|
{
|
|
14848
14992
|
index: 0,
|
|
14849
14993
|
logprobs: null,
|
|
14850
|
-
finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess',
|
|
14994
|
+
finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess', _231 => _231.finishReason])), () => ( (toolCalls.length ? "tool_calls" : void 0))),
|
|
14851
14995
|
message: {
|
|
14852
14996
|
role: "assistant",
|
|
14853
14997
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
@@ -14896,7 +15040,7 @@ function wrapTools(tools) {
|
|
|
14896
15040
|
return wrappedTools;
|
|
14897
15041
|
}
|
|
14898
15042
|
function extractInput(params) {
|
|
14899
|
-
return _nullishCoalesce(_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
15043
|
+
return _nullishCoalesce(_nullishCoalesce(_optionalChain([params, 'optionalAccess', _232 => _232.prompt]), () => ( _optionalChain([params, 'optionalAccess', _233 => _233.messages]))), () => ( _optionalChain([params, 'optionalAccess', _234 => _234.system])));
|
|
14900
15044
|
}
|
|
14901
15045
|
|
|
14902
15046
|
// src/wrappers/ai-sdk-v2.ts
|
|
@@ -14953,12 +15097,12 @@ function BraintrustMiddleware(config = {}) {
|
|
|
14953
15097
|
metadata.model = modelId;
|
|
14954
15098
|
}
|
|
14955
15099
|
}
|
|
14956
|
-
let toolCalls = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess',
|
|
15100
|
+
let toolCalls = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess', _235 => _235.steps]));
|
|
14957
15101
|
if (!toolCalls || toolCalls.length === 0) {
|
|
14958
|
-
toolCalls = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess',
|
|
15102
|
+
toolCalls = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess', _236 => _236.content]));
|
|
14959
15103
|
}
|
|
14960
15104
|
span.log({
|
|
14961
|
-
output: toolCalls.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls) : _optionalChain([result, 'optionalAccess',
|
|
15105
|
+
output: toolCalls.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls) : _optionalChain([result, 'optionalAccess', _237 => _237.content]),
|
|
14962
15106
|
metadata,
|
|
14963
15107
|
metrics: normalizeUsageMetrics(
|
|
14964
15108
|
result.usage,
|
|
@@ -15093,7 +15237,7 @@ init_logger();
|
|
|
15093
15237
|
init_util2();
|
|
15094
15238
|
function wrapAISDKModel(model) {
|
|
15095
15239
|
const m = model;
|
|
15096
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
15240
|
+
if (_optionalChain([m, 'optionalAccess', _238 => _238.specificationVersion]) === "v1" && typeof _optionalChain([m, 'optionalAccess', _239 => _239.provider]) === "string" && typeof _optionalChain([m, 'optionalAccess', _240 => _240.modelId]) === "string") {
|
|
15097
15241
|
return new BraintrustLanguageModelWrapper(m);
|
|
15098
15242
|
} else {
|
|
15099
15243
|
console.warn("Unsupported AI SDK model. Not wrapping.");
|
|
@@ -15150,10 +15294,10 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
15150
15294
|
metrics: {
|
|
15151
15295
|
time_to_first_token: getCurrentUnixTimestamp() - startTime,
|
|
15152
15296
|
tokens: !isEmpty(ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
15153
|
-
prompt_tokens: _optionalChain([ret, 'access',
|
|
15154
|
-
completion_tokens: _optionalChain([ret, 'access',
|
|
15297
|
+
prompt_tokens: _optionalChain([ret, 'access', _241 => _241.usage, 'optionalAccess', _242 => _242.promptTokens]),
|
|
15298
|
+
completion_tokens: _optionalChain([ret, 'access', _243 => _243.usage, 'optionalAccess', _244 => _244.completionTokens]),
|
|
15155
15299
|
cached: parseCachedHeader(
|
|
15156
|
-
_nullishCoalesce(_optionalChain([ret, 'access',
|
|
15300
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _245 => _245.rawResponse, 'optionalAccess', _246 => _246.headers, 'optionalAccess', _247 => _247[X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _248 => _248.rawResponse, 'optionalAccess', _249 => _249.headers, 'optionalAccess', _250 => _250[LEGACY_CACHED_HEADER]])))
|
|
15157
15301
|
)
|
|
15158
15302
|
}
|
|
15159
15303
|
});
|
|
@@ -15245,10 +15389,10 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
15245
15389
|
metrics: {
|
|
15246
15390
|
time_to_first_token,
|
|
15247
15391
|
tokens: !isEmpty(usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
15248
|
-
prompt_tokens: _optionalChain([usage, 'optionalAccess',
|
|
15249
|
-
completion_tokens: _optionalChain([usage, 'optionalAccess',
|
|
15392
|
+
prompt_tokens: _optionalChain([usage, 'optionalAccess', _251 => _251.promptTokens]),
|
|
15393
|
+
completion_tokens: _optionalChain([usage, 'optionalAccess', _252 => _252.completionTokens]),
|
|
15250
15394
|
cached: parseCachedHeader(
|
|
15251
|
-
_nullishCoalesce(_optionalChain([ret, 'access',
|
|
15395
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _253 => _253.rawResponse, 'optionalAccess', _254 => _254.headers, 'optionalAccess', _255 => _255[X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _256 => _256.rawResponse, 'optionalAccess', _257 => _257.headers, 'optionalAccess', _258 => _258[LEGACY_CACHED_HEADER]])))
|
|
15252
15396
|
)
|
|
15253
15397
|
}
|
|
15254
15398
|
});
|
|
@@ -15295,7 +15439,7 @@ function postProcessPrompt(prompt) {
|
|
|
15295
15439
|
return [
|
|
15296
15440
|
{
|
|
15297
15441
|
role: "assistant",
|
|
15298
|
-
content: _optionalChain([textPart, 'optionalAccess',
|
|
15442
|
+
content: _optionalChain([textPart, 'optionalAccess', _259 => _259.text]),
|
|
15299
15443
|
...toolCallParts.length > 0 ? {
|
|
15300
15444
|
tool_calls: toolCallParts.map((part) => ({
|
|
15301
15445
|
id: part.toolCallId,
|
|
@@ -15404,7 +15548,7 @@ function wrapAISDK(ai) {
|
|
|
15404
15548
|
});
|
|
15405
15549
|
const provider = detectProviderFromResult(result);
|
|
15406
15550
|
const model = extractModelFromResult(result);
|
|
15407
|
-
const finishReason = normalizeFinishReason(_optionalChain([result, 'optionalAccess',
|
|
15551
|
+
const finishReason = normalizeFinishReason(_optionalChain([result, 'optionalAccess', _260 => _260.finishReason]));
|
|
15408
15552
|
span.log({
|
|
15409
15553
|
input: extractInput(params),
|
|
15410
15554
|
output: result.text,
|
|
@@ -15497,9 +15641,9 @@ function wrapAISDK(ai) {
|
|
|
15497
15641
|
}
|
|
15498
15642
|
const provider = detectProviderFromResult(event);
|
|
15499
15643
|
const model = extractModelFromResult(event);
|
|
15500
|
-
const finishReason = normalizeFinishReason(_optionalChain([event, 'optionalAccess',
|
|
15644
|
+
const finishReason = normalizeFinishReason(_optionalChain([event, 'optionalAccess', _261 => _261.finishReason]));
|
|
15501
15645
|
span.log({
|
|
15502
|
-
output: _optionalChain([event, 'optionalAccess',
|
|
15646
|
+
output: _optionalChain([event, 'optionalAccess', _262 => _262.text]),
|
|
15503
15647
|
metadata: {
|
|
15504
15648
|
...extractModelParameters(params, V3_EXCLUDE_KEYS),
|
|
15505
15649
|
...provider ? { provider } : {},
|
|
@@ -15556,9 +15700,9 @@ function wrapAISDK(ai) {
|
|
|
15556
15700
|
}
|
|
15557
15701
|
const provider = detectProviderFromResult(event);
|
|
15558
15702
|
const model = extractModelFromResult(event);
|
|
15559
|
-
const finishReason = normalizeFinishReason(_optionalChain([event, 'optionalAccess',
|
|
15703
|
+
const finishReason = normalizeFinishReason(_optionalChain([event, 'optionalAccess', _263 => _263.finishReason]));
|
|
15560
15704
|
span.log({
|
|
15561
|
-
output: _optionalChain([event, 'optionalAccess',
|
|
15705
|
+
output: _optionalChain([event, 'optionalAccess', _264 => _264.object]),
|
|
15562
15706
|
metadata: {
|
|
15563
15707
|
...extractModelParameters(params, V3_EXCLUDE_KEYS),
|
|
15564
15708
|
...provider ? { provider } : {},
|
|
@@ -15628,7 +15772,7 @@ function wrapAISDK(ai) {
|
|
|
15628
15772
|
init_logger();
|
|
15629
15773
|
var aiSDKFormatWarning = false;
|
|
15630
15774
|
function wrapMastraAgent(agent, options) {
|
|
15631
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
15775
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _265 => _265.name]), () => ( _optionalChain([options, 'optionalAccess', _266 => _266.span_name]))), () => ( agent.name)), () => ( "Agent"));
|
|
15632
15776
|
if (!hasAllMethods(agent)) {
|
|
15633
15777
|
return agent;
|
|
15634
15778
|
}
|
|
@@ -15662,8 +15806,8 @@ function wrapGenerate(original, target, prefix) {
|
|
|
15662
15806
|
const result = await original.apply(target, args);
|
|
15663
15807
|
const provider = detectProviderFromResult(result);
|
|
15664
15808
|
const model = extractModelFromResult(result);
|
|
15665
|
-
const finishReason = normalizeFinishReason(_optionalChain([result, 'optionalAccess',
|
|
15666
|
-
const metrics = _optionalChain([result, 'optionalAccess',
|
|
15809
|
+
const finishReason = normalizeFinishReason(_optionalChain([result, 'optionalAccess', _267 => _267.finishReason]));
|
|
15810
|
+
const metrics = _optionalChain([result, 'optionalAccess', _268 => _268.usage]) ? normalizeUsageMetrics(
|
|
15667
15811
|
result.usage,
|
|
15668
15812
|
provider,
|
|
15669
15813
|
result.providerMetadata
|
|
@@ -15711,14 +15855,14 @@ function wrapStream(original, target, prefix) {
|
|
|
15711
15855
|
format: baseOpts.format || "aisdk"
|
|
15712
15856
|
// Default to AI SDK v5 format if not specified
|
|
15713
15857
|
};
|
|
15714
|
-
const userOnChunk = _optionalChain([baseOpts, 'optionalAccess',
|
|
15715
|
-
const userOnFinish = _optionalChain([baseOpts, 'optionalAccess',
|
|
15716
|
-
const userOnError = _optionalChain([baseOpts, 'optionalAccess',
|
|
15858
|
+
const userOnChunk = _optionalChain([baseOpts, 'optionalAccess', _269 => _269.onChunk]);
|
|
15859
|
+
const userOnFinish = _optionalChain([baseOpts, 'optionalAccess', _270 => _270.onFinish]);
|
|
15860
|
+
const userOnError = _optionalChain([baseOpts, 'optionalAccess', _271 => _271.onError]);
|
|
15717
15861
|
const startTime = Date.now();
|
|
15718
15862
|
let receivedFirst = false;
|
|
15719
15863
|
wrappedOpts.onChunk = (chunk) => {
|
|
15720
15864
|
try {
|
|
15721
|
-
_optionalChain([userOnChunk, 'optionalCall',
|
|
15865
|
+
_optionalChain([userOnChunk, 'optionalCall', _272 => _272(chunk)]);
|
|
15722
15866
|
} finally {
|
|
15723
15867
|
if (!receivedFirst) {
|
|
15724
15868
|
receivedFirst = true;
|
|
@@ -15730,13 +15874,13 @@ function wrapStream(original, target, prefix) {
|
|
|
15730
15874
|
};
|
|
15731
15875
|
wrappedOpts.onFinish = async (event) => {
|
|
15732
15876
|
try {
|
|
15733
|
-
await _optionalChain([userOnFinish, 'optionalCall',
|
|
15877
|
+
await _optionalChain([userOnFinish, 'optionalCall', _273 => _273(event)]);
|
|
15734
15878
|
} finally {
|
|
15735
15879
|
const e = event;
|
|
15736
15880
|
const provider = detectProviderFromResult(e);
|
|
15737
15881
|
const model = extractModelFromResult(e);
|
|
15738
|
-
const finishReason = normalizeFinishReason(_optionalChain([e, 'optionalAccess',
|
|
15739
|
-
const metrics = _optionalChain([e, 'optionalAccess',
|
|
15882
|
+
const finishReason = normalizeFinishReason(_optionalChain([e, 'optionalAccess', _274 => _274.finishReason]));
|
|
15883
|
+
const metrics = _optionalChain([e, 'optionalAccess', _275 => _275.usage]) ? normalizeUsageMetrics(e.usage, provider, e.providerMetadata) : {};
|
|
15740
15884
|
span.log({
|
|
15741
15885
|
output: _nullishCoalesce(_nullishCoalesce(e.text, () => ( e.content)), () => ( e)),
|
|
15742
15886
|
metadata: {
|
|
@@ -15752,7 +15896,7 @@ function wrapStream(original, target, prefix) {
|
|
|
15752
15896
|
};
|
|
15753
15897
|
wrappedOpts.onError = async (err) => {
|
|
15754
15898
|
try {
|
|
15755
|
-
await _optionalChain([userOnError, 'optionalCall',
|
|
15899
|
+
await _optionalChain([userOnError, 'optionalCall', _276 => _276(err)]);
|
|
15756
15900
|
} finally {
|
|
15757
15901
|
logError(span, err);
|
|
15758
15902
|
span.end();
|
|
@@ -15935,9 +16079,9 @@ function streamNextProxy(stream, sspan) {
|
|
|
15935
16079
|
return result;
|
|
15936
16080
|
}
|
|
15937
16081
|
const item = result.value;
|
|
15938
|
-
switch (_optionalChain([item, 'optionalAccess',
|
|
16082
|
+
switch (_optionalChain([item, 'optionalAccess', _277 => _277.type])) {
|
|
15939
16083
|
case "message_start":
|
|
15940
|
-
const msg = _optionalChain([item, 'optionalAccess',
|
|
16084
|
+
const msg = _optionalChain([item, 'optionalAccess', _278 => _278.message]);
|
|
15941
16085
|
if (msg) {
|
|
15942
16086
|
const event = parseEventFromMessage(msg);
|
|
15943
16087
|
totals = { ...totals, ...event.metrics };
|
|
@@ -15950,20 +16094,20 @@ function streamNextProxy(stream, sspan) {
|
|
|
15950
16094
|
}
|
|
15951
16095
|
break;
|
|
15952
16096
|
case "content_block_delta":
|
|
15953
|
-
if (_optionalChain([item, 'access',
|
|
15954
|
-
const text = _optionalChain([item, 'optionalAccess',
|
|
16097
|
+
if (_optionalChain([item, 'access', _279 => _279.delta, 'optionalAccess', _280 => _280.type]) === "text_delta") {
|
|
16098
|
+
const text = _optionalChain([item, 'optionalAccess', _281 => _281.delta, 'optionalAccess', _282 => _282.text]);
|
|
15955
16099
|
if (text) {
|
|
15956
16100
|
deltas.push(text);
|
|
15957
16101
|
}
|
|
15958
16102
|
}
|
|
15959
16103
|
break;
|
|
15960
16104
|
case "message_delta":
|
|
15961
|
-
const usage = _optionalChain([item, 'optionalAccess',
|
|
16105
|
+
const usage = _optionalChain([item, 'optionalAccess', _283 => _283.usage]);
|
|
15962
16106
|
if (usage) {
|
|
15963
16107
|
const metrics = parseMetricsFromUsage2(usage);
|
|
15964
16108
|
totals = { ...totals, ...metrics };
|
|
15965
16109
|
}
|
|
15966
|
-
const delta = _optionalChain([item, 'optionalAccess',
|
|
16110
|
+
const delta = _optionalChain([item, 'optionalAccess', _284 => _284.delta]);
|
|
15967
16111
|
if (delta) {
|
|
15968
16112
|
metadata = { ...metadata, ...delta };
|
|
15969
16113
|
}
|
|
@@ -15976,7 +16120,7 @@ function streamNextProxy(stream, sspan) {
|
|
|
15976
16120
|
}
|
|
15977
16121
|
function parseEventFromMessage(message) {
|
|
15978
16122
|
const output = message ? { role: message.role, content: message.content } : null;
|
|
15979
|
-
const metrics = parseMetricsFromUsage2(_optionalChain([message, 'optionalAccess',
|
|
16123
|
+
const metrics = parseMetricsFromUsage2(_optionalChain([message, 'optionalAccess', _285 => _285.usage]));
|
|
15980
16124
|
const metas = ["stop_reason", "stop_sequence"];
|
|
15981
16125
|
const metadata = {};
|
|
15982
16126
|
for (const m of metas) {
|
|
@@ -16121,7 +16265,7 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
16121
16265
|
finalResults.push(finalMessageContent);
|
|
16122
16266
|
}
|
|
16123
16267
|
const lastMessage = currentMessages[currentMessages.length - 1];
|
|
16124
|
-
if (_optionalChain([lastMessage, 'optionalAccess',
|
|
16268
|
+
if (_optionalChain([lastMessage, 'optionalAccess', _286 => _286.message, 'optionalAccess', _287 => _287.usage])) {
|
|
16125
16269
|
const outputTokens = getNumberProperty(lastMessage.message.usage, "output_tokens") || 0;
|
|
16126
16270
|
accumulatedOutputTokens += outputTokens;
|
|
16127
16271
|
}
|
|
@@ -16136,20 +16280,20 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
16136
16280
|
);
|
|
16137
16281
|
for await (const message of generator) {
|
|
16138
16282
|
const currentTime = getCurrentUnixTimestamp();
|
|
16139
|
-
const messageId = _optionalChain([message, 'access',
|
|
16283
|
+
const messageId = _optionalChain([message, 'access', _288 => _288.message, 'optionalAccess', _289 => _289.id]);
|
|
16140
16284
|
if (messageId && messageId !== currentMessageId) {
|
|
16141
16285
|
await createLLMSpan();
|
|
16142
16286
|
currentMessageId = messageId;
|
|
16143
16287
|
currentMessageStartTime = currentTime;
|
|
16144
16288
|
}
|
|
16145
|
-
if (message.type === "assistant" && _optionalChain([message, 'access',
|
|
16289
|
+
if (message.type === "assistant" && _optionalChain([message, 'access', _290 => _290.message, 'optionalAccess', _291 => _291.usage])) {
|
|
16146
16290
|
currentMessages.push(message);
|
|
16147
16291
|
}
|
|
16148
16292
|
if (message.type === "result" && message.usage) {
|
|
16149
16293
|
finalUsageMetrics = _extractUsageFromMessage(message);
|
|
16150
16294
|
if (currentMessages.length > 0 && finalUsageMetrics.completion_tokens !== void 0) {
|
|
16151
16295
|
const lastMessage = currentMessages[currentMessages.length - 1];
|
|
16152
|
-
if (_optionalChain([lastMessage, 'optionalAccess',
|
|
16296
|
+
if (_optionalChain([lastMessage, 'optionalAccess', _292 => _292.message, 'optionalAccess', _293 => _293.usage])) {
|
|
16153
16297
|
const adjustedTokens = finalUsageMetrics.completion_tokens - accumulatedOutputTokens;
|
|
16154
16298
|
if (adjustedTokens >= 0) {
|
|
16155
16299
|
lastMessage.message.usage.output_tokens = adjustedTokens;
|
|
@@ -16230,7 +16374,7 @@ function _extractUsageFromMessage(message) {
|
|
|
16230
16374
|
const metrics = {};
|
|
16231
16375
|
let usage;
|
|
16232
16376
|
if (message.type === "assistant") {
|
|
16233
|
-
usage = _optionalChain([message, 'access',
|
|
16377
|
+
usage = _optionalChain([message, 'access', _294 => _294.message, 'optionalAccess', _295 => _295.usage]);
|
|
16234
16378
|
} else if (message.type === "result") {
|
|
16235
16379
|
usage = message.usage;
|
|
16236
16380
|
}
|
|
@@ -16262,14 +16406,14 @@ function _extractUsageFromMessage(message) {
|
|
|
16262
16406
|
async function _createLLMSpanForMessages(messages, prompt, conversationHistory, options, startTime, parentSpan) {
|
|
16263
16407
|
if (messages.length === 0) return void 0;
|
|
16264
16408
|
const lastMessage = messages[messages.length - 1];
|
|
16265
|
-
if (lastMessage.type !== "assistant" || !_optionalChain([lastMessage, 'access',
|
|
16409
|
+
if (lastMessage.type !== "assistant" || !_optionalChain([lastMessage, 'access', _296 => _296.message, 'optionalAccess', _297 => _297.usage])) {
|
|
16266
16410
|
return void 0;
|
|
16267
16411
|
}
|
|
16268
16412
|
const model = lastMessage.message.model || options.model;
|
|
16269
16413
|
const usage = _extractUsageFromMessage(lastMessage);
|
|
16270
16414
|
const input = _buildLLMInput(prompt, conversationHistory);
|
|
16271
16415
|
const outputs = messages.map(
|
|
16272
|
-
(m) => _optionalChain([m, 'access',
|
|
16416
|
+
(m) => _optionalChain([m, 'access', _298 => _298.message, 'optionalAccess', _299 => _299.content]) && _optionalChain([m, 'access', _300 => _300.message, 'optionalAccess', _301 => _301.role]) ? { content: m.message.content, role: m.message.role } : void 0
|
|
16273
16417
|
).filter((c) => c !== void 0);
|
|
16274
16418
|
await traced(
|
|
16275
16419
|
(llmSpan) => {
|
|
@@ -16289,7 +16433,7 @@ async function _createLLMSpanForMessages(messages, prompt, conversationHistory,
|
|
|
16289
16433
|
parent: parentSpan
|
|
16290
16434
|
}
|
|
16291
16435
|
);
|
|
16292
|
-
return _optionalChain([lastMessage, 'access',
|
|
16436
|
+
return _optionalChain([lastMessage, 'access', _302 => _302.message, 'optionalAccess', _303 => _303.content]) && _optionalChain([lastMessage, 'access', _304 => _304.message, 'optionalAccess', _305 => _305.role]) ? { content: lastMessage.message.content, role: lastMessage.message.role } : void 0;
|
|
16293
16437
|
}
|
|
16294
16438
|
function wrapClaudeAgentSDK(sdk) {
|
|
16295
16439
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -16344,9 +16488,9 @@ var otelSdk = null;
|
|
|
16344
16488
|
var OTEL_AVAILABLE2 = false;
|
|
16345
16489
|
try {
|
|
16346
16490
|
otelApi = (_chunkCDBUTZMHjs.init_esm.call(void 0, ), _chunkCDBUTZMHjs.__toCommonJS.call(void 0, _chunkCDBUTZMHjs.esm_exports));
|
|
16347
|
-
otelSdk = (
|
|
16491
|
+
otelSdk = (init_esm6(), _chunkCDBUTZMHjs.__toCommonJS.call(void 0, esm_exports2));
|
|
16348
16492
|
OTEL_AVAILABLE2 = true;
|
|
16349
|
-
} catch (
|
|
16493
|
+
} catch (e15) {
|
|
16350
16494
|
console.warn(
|
|
16351
16495
|
"OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
|
|
16352
16496
|
);
|
|
@@ -16481,7 +16625,7 @@ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
|
|
|
16481
16625
|
try {
|
|
16482
16626
|
const {
|
|
16483
16627
|
OTLPTraceExporter: OTLPTraceExporter2
|
|
16484
|
-
} = (
|
|
16628
|
+
} = (init_esm10(), _chunkCDBUTZMHjs.__toCommonJS.call(void 0, esm_exports3));
|
|
16485
16629
|
const headers = {
|
|
16486
16630
|
Authorization: `Bearer ${apiKey}`,
|
|
16487
16631
|
"Content-Type": "application/json",
|
|
@@ -16501,8 +16645,8 @@ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
|
|
|
16501
16645
|
span.instrumentationScope = span.instrumentationLibrary;
|
|
16502
16646
|
}
|
|
16503
16647
|
if (!span.parentSpanContext && span.parentSpanId) {
|
|
16504
|
-
const spanContext = _optionalChain([span, 'access',
|
|
16505
|
-
if (_optionalChain([spanContext, 'optionalAccess',
|
|
16648
|
+
const spanContext = _optionalChain([span, 'access', _306 => _306.spanContext, 'optionalCall', _307 => _307()]);
|
|
16649
|
+
if (_optionalChain([spanContext, 'optionalAccess', _308 => _308.traceId])) {
|
|
16506
16650
|
span.parentSpanContext = {
|
|
16507
16651
|
spanId: span.parentSpanId,
|
|
16508
16652
|
traceId: spanContext.traceId
|
|
@@ -16545,7 +16689,7 @@ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
|
|
|
16545
16689
|
let parentValue;
|
|
16546
16690
|
if (otelApi && otelApi.context) {
|
|
16547
16691
|
const currentContext = otelApi.context.active();
|
|
16548
|
-
const contextValue = _optionalChain([currentContext, 'access',
|
|
16692
|
+
const contextValue = _optionalChain([currentContext, 'access', _309 => _309.getValue, 'optionalCall', _310 => _310("braintrust.parent")]);
|
|
16549
16693
|
if (typeof contextValue === "string") {
|
|
16550
16694
|
parentValue = contextValue;
|
|
16551
16695
|
}
|
|
@@ -16562,7 +16706,7 @@ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
|
|
|
16562
16706
|
span.setAttributes({ "braintrust.parent": parentValue });
|
|
16563
16707
|
}
|
|
16564
16708
|
}
|
|
16565
|
-
} catch (
|
|
16709
|
+
} catch (e16) {
|
|
16566
16710
|
}
|
|
16567
16711
|
this.aiSpanProcessor.onStart(span, parentContext);
|
|
16568
16712
|
}
|
|
@@ -16578,7 +16722,7 @@ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
|
|
|
16578
16722
|
return typeof parentAttr === "string" ? parentAttr : void 0;
|
|
16579
16723
|
}
|
|
16580
16724
|
return void 0;
|
|
16581
|
-
} catch (
|
|
16725
|
+
} catch (e17) {
|
|
16582
16726
|
return void 0;
|
|
16583
16727
|
}
|
|
16584
16728
|
}
|
|
@@ -16793,4 +16937,5 @@ var index_default = exports_node_exports;
|
|
|
16793
16937
|
|
|
16794
16938
|
|
|
16795
16939
|
|
|
16796
|
-
|
|
16940
|
+
|
|
16941
|
+
exports.AISpanProcessor = AISpanProcessor; exports.Attachment = Attachment; exports.BaseAttachment = BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustExporter = BraintrustExporter; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustSpanProcessor = BraintrustSpanProcessor; exports.BraintrustState = BraintrustState; exports.BraintrustStream = BraintrustStream; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = ContextManager; exports.Dataset = Dataset2; exports.ERR_PERMALINK = ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = Experiment2; exports.ExternalAttachment = ExternalAttachment; exports.FailedHTTPResponse = FailedHTTPResponse; exports.IDGenerator = IDGenerator; exports.INTERNAL_BTQL_LIMIT = INTERNAL_BTQL_LIMIT; exports.JSONAttachment = JSONAttachment; exports.LEGACY_CACHED_HEADER = LEGACY_CACHED_HEADER; exports.LazyValue = LazyValue; exports.Logger = Logger; exports.NOOP_SPAN = NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = NOOP_SPAN_PERMALINK; exports.NoopSpan = NoopSpan; exports.OTELIDGenerator = OTELIDGenerator; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = Prompt2; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = ReadonlyAttachment; exports.ReadonlyExperiment = ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanImpl = SpanImpl; exports.TestBackgroundLogger = TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = UUIDGenerator; exports.X_CACHED_HEADER = X_CACHED_HEADER; exports._exportsForTestingOnly = _exportsForTestingOnly; exports._internalGetGlobalState = _internalGetGlobalState; exports._internalSetInitialState = _internalSetInitialState; exports.braintrustStreamChunkSchema = braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.createFinalValuePassThroughStream = createFinalValuePassThroughStream; exports.currentExperiment = currentExperiment; exports.currentLogger = currentLogger; exports.currentSpan = currentSpan; exports.deepCopyEvent = deepCopyEvent; exports.default = index_default; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = deserializePlainStringAsJSON; exports.devNullWritableStream = devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.flush = flush; exports.getContextManager = getContextManager; exports.getIdGenerator = getIdGenerator; exports.getPromptVersions = getPromptVersions; exports.getSpanParentObject = getSpanParentObject; exports.graph = graph_framework_exports; exports.init = init; exports.initDataset = initDataset; exports.initExperiment = initExperiment; exports.initFunction = initFunction; exports.initLogger = initLogger; exports.invoke = invoke; exports.loadPrompt = loadPrompt; exports.log = log; exports.logError = logError; exports.login = login; exports.loginToState = loginToState; exports.newId = newId; exports.parseCachedHeader = parseCachedHeader; exports.permalink = permalink; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.renderMessage = renderMessage; exports.renderPromptParams = renderPromptParams; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = setFetch; exports.setMaskingFunction = setMaskingFunction; exports.spanComponentsToObjectId = spanComponentsToObjectId; exports.startSpan = startSpan; exports.summarize = summarize; exports.toolFunctionDefinitionSchema = ToolFunctionDefinition; exports.traceable = traceable; exports.traced = traced; exports.updateSpan = updateSpan; exports.withCurrent = withCurrent; exports.withDataset = withDataset; exports.withExperiment = withExperiment; exports.withLogger = withLogger; exports.withParent = withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAnthropic = wrapAnthropic; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapMastraAgent = wrapMastraAgent; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapTraced = wrapTraced;
|