braintrust 0.3.7 → 0.4.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 +25 -0
- package/dev/dist/index.d.ts +25 -0
- package/dev/dist/index.js +454 -122
- package/dev/dist/index.mjs +1360 -1028
- package/dist/browser.d.mts +31 -2
- package/dist/browser.d.ts +31 -2
- package/dist/browser.js +309 -114
- package/dist/browser.mjs +1183 -988
- package/dist/cli.js +1361 -1023
- package/dist/index.d.mts +131 -2
- package/dist/index.d.ts +131 -2
- package/dist/index.js +814 -177
- package/dist/index.mjs +1681 -1044
- package/package.json +6 -4
- package/util/dist/index.d.mts +65 -2
- package/util/dist/index.d.ts +65 -2
- package/util/dist/index.js +229 -17
- package/util/dist/index.mjs +230 -18
package/dev/dist/index.js
CHANGED
|
@@ -303,6 +303,44 @@ var Queue = (_class = class {
|
|
|
303
303
|
}
|
|
304
304
|
}, _class);
|
|
305
305
|
|
|
306
|
+
// src/id-gen.ts
|
|
307
|
+
|
|
308
|
+
function generateHexId(bytes) {
|
|
309
|
+
let result = "";
|
|
310
|
+
for (let i = 0; i < bytes; i++) {
|
|
311
|
+
result += Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
|
|
312
|
+
}
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
var IDGenerator = class {
|
|
316
|
+
};
|
|
317
|
+
var UUIDGenerator = class extends IDGenerator {
|
|
318
|
+
getSpanId() {
|
|
319
|
+
return _uuid.v4.call(void 0, );
|
|
320
|
+
}
|
|
321
|
+
getTraceId() {
|
|
322
|
+
return _uuid.v4.call(void 0, );
|
|
323
|
+
}
|
|
324
|
+
shareRootSpanId() {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
var OTELIDGenerator = class extends IDGenerator {
|
|
329
|
+
getSpanId() {
|
|
330
|
+
return generateHexId(8);
|
|
331
|
+
}
|
|
332
|
+
getTraceId() {
|
|
333
|
+
return generateHexId(16);
|
|
334
|
+
}
|
|
335
|
+
shareRootSpanId() {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
function getIdGenerator() {
|
|
340
|
+
const useOtel = typeof process !== "undefined" && _optionalChain([process, 'access', _11 => _11.env, 'optionalAccess', _12 => _12.BRAINTRUST_OTEL_COMPAT, 'optionalAccess', _13 => _13.toLowerCase, 'call', _14 => _14()]) === "true";
|
|
341
|
+
return useOtel ? new OTELIDGenerator() : new UUIDGenerator();
|
|
342
|
+
}
|
|
343
|
+
|
|
306
344
|
// util/db_fields.ts
|
|
307
345
|
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
308
346
|
var IS_MERGE_FIELD = "_is_merge";
|
|
@@ -453,7 +491,7 @@ var SpanComponentsV1 = class _SpanComponentsV1 {
|
|
|
453
491
|
return {
|
|
454
492
|
objectType: this.objectType,
|
|
455
493
|
objectId: this.objectId,
|
|
456
|
-
rowIds: _optionalChain([this, 'access',
|
|
494
|
+
rowIds: _optionalChain([this, 'access', _15 => _15.rowIds, 'optionalAccess', _16 => _16.toObject, 'call', _17 => _17()])
|
|
457
495
|
};
|
|
458
496
|
}
|
|
459
497
|
};
|
|
@@ -667,7 +705,7 @@ var SpanComponentsV2 = class _SpanComponentsV2 {
|
|
|
667
705
|
objectType: this.objectType,
|
|
668
706
|
objectId: this.objectId,
|
|
669
707
|
computeObjectMetadataArgs: this.computeObjectMetadataArgs,
|
|
670
|
-
rowIds: _optionalChain([this, 'access',
|
|
708
|
+
rowIds: _optionalChain([this, 'access', _18 => _18.rowIds, 'optionalAccess', _19 => _19.toObject, 'call', _20 => _20()])
|
|
671
709
|
};
|
|
672
710
|
}
|
|
673
711
|
};
|
|
@@ -908,22 +946,6 @@ var SpanComponentsV3 = class _SpanComponentsV3 {
|
|
|
908
946
|
return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
|
|
909
947
|
}
|
|
910
948
|
};
|
|
911
|
-
function parseParent(parent) {
|
|
912
|
-
return typeof parent === "string" ? parent : parent ? new SpanComponentsV3({
|
|
913
|
-
object_type: parent.object_type === "experiment" ? 1 /* EXPERIMENT */ : parent.object_type === "playground_logs" ? 3 /* PLAYGROUND_LOGS */ : 2 /* PROJECT_LOGS */,
|
|
914
|
-
object_id: parent.object_id,
|
|
915
|
-
...parent.row_ids ? {
|
|
916
|
-
row_id: parent.row_ids.id,
|
|
917
|
-
span_id: parent.row_ids.span_id,
|
|
918
|
-
root_span_id: parent.row_ids.root_span_id
|
|
919
|
-
} : {
|
|
920
|
-
row_id: void 0,
|
|
921
|
-
span_id: void 0,
|
|
922
|
-
root_span_id: void 0
|
|
923
|
-
},
|
|
924
|
-
propagated_event: parent.propagated_event
|
|
925
|
-
}).toStr() : void 0;
|
|
926
|
-
}
|
|
927
949
|
|
|
928
950
|
// util/http_headers.ts
|
|
929
951
|
var BT_FOUND_EXISTING_HEADER = "x-bt-found-existing";
|
|
@@ -1019,14 +1041,14 @@ function depthFirstSearch(args) {
|
|
|
1019
1041
|
while (events.length) {
|
|
1020
1042
|
const { eventType, vertex, extras } = events.pop();
|
|
1021
1043
|
if (eventType === "last") {
|
|
1022
|
-
_optionalChain([lastVisitF, 'optionalCall',
|
|
1044
|
+
_optionalChain([lastVisitF, 'optionalCall', _21 => _21(vertex)]);
|
|
1023
1045
|
continue;
|
|
1024
1046
|
}
|
|
1025
1047
|
if (firstVisitedVertices.has(vertex)) {
|
|
1026
1048
|
continue;
|
|
1027
1049
|
}
|
|
1028
1050
|
firstVisitedVertices.add(vertex);
|
|
1029
|
-
_optionalChain([firstVisitF, 'optionalCall',
|
|
1051
|
+
_optionalChain([firstVisitF, 'optionalCall', _22 => _22(vertex, { parentVertex: extras.parentVertex })]);
|
|
1030
1052
|
events.push({ eventType: "last", vertex, extras: {} });
|
|
1031
1053
|
mapAt(graph, vertex).forEach((child) => {
|
|
1032
1054
|
events.push({
|
|
@@ -1048,7 +1070,7 @@ function undirectedConnectedComponents(graph) {
|
|
|
1048
1070
|
let labelCounter = 0;
|
|
1049
1071
|
const vertexLabels = /* @__PURE__ */ new Map();
|
|
1050
1072
|
const firstVisitF = (vertex, args) => {
|
|
1051
|
-
const label = _optionalChain([args, 'optionalAccess',
|
|
1073
|
+
const label = _optionalChain([args, 'optionalAccess', _23 => _23.parentVertex]) !== void 0 ? mapAt(vertexLabels, _optionalChain([args, 'optionalAccess', _24 => _24.parentVertex])) : labelCounter++;
|
|
1052
1074
|
vertexLabels.set(vertex, label);
|
|
1053
1075
|
};
|
|
1054
1076
|
depthFirstSearch({ graph: directedGraph, firstVisitF });
|
|
@@ -1270,6 +1292,232 @@ function _urljoin(...parts) {
|
|
|
1270
1292
|
).filter((x) => x.trim() !== "").join("/");
|
|
1271
1293
|
}
|
|
1272
1294
|
|
|
1295
|
+
// util/span_identifier_v4.ts
|
|
1296
|
+
|
|
1297
|
+
var ENCODING_VERSION_NUMBER_V4 = 4;
|
|
1298
|
+
function tryMakeHexTraceId(s) {
|
|
1299
|
+
try {
|
|
1300
|
+
if (typeof s === "string" && s.length === 32) {
|
|
1301
|
+
const bytes = new Uint8Array(16);
|
|
1302
|
+
for (let i = 0; i < 16; i++) {
|
|
1303
|
+
const hex = s.substr(i * 2, 2);
|
|
1304
|
+
const byte = parseInt(hex, 16);
|
|
1305
|
+
if (isNaN(byte)) throw new Error();
|
|
1306
|
+
bytes[i] = byte;
|
|
1307
|
+
}
|
|
1308
|
+
return { bytes, isHex: true };
|
|
1309
|
+
}
|
|
1310
|
+
} catch (e5) {
|
|
1311
|
+
}
|
|
1312
|
+
return { bytes: void 0, isHex: false };
|
|
1313
|
+
}
|
|
1314
|
+
function tryMakeHexSpanId(s) {
|
|
1315
|
+
try {
|
|
1316
|
+
if (typeof s === "string" && s.length === 16) {
|
|
1317
|
+
const bytes = new Uint8Array(8);
|
|
1318
|
+
for (let i = 0; i < 8; i++) {
|
|
1319
|
+
const hex = s.substr(i * 2, 2);
|
|
1320
|
+
const byte = parseInt(hex, 16);
|
|
1321
|
+
if (isNaN(byte)) throw new Error();
|
|
1322
|
+
bytes[i] = byte;
|
|
1323
|
+
}
|
|
1324
|
+
return { bytes, isHex: true };
|
|
1325
|
+
}
|
|
1326
|
+
} catch (e6) {
|
|
1327
|
+
}
|
|
1328
|
+
return { bytes: void 0, isHex: false };
|
|
1329
|
+
}
|
|
1330
|
+
var INVALID_ENCODING_ERRMSG_V4 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER_V4}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
|
|
1331
|
+
var FIELDS_ID_TO_NAME = {
|
|
1332
|
+
[1 /* OBJECT_ID */]: "object_id",
|
|
1333
|
+
[2 /* ROW_ID */]: "row_id",
|
|
1334
|
+
[3 /* SPAN_ID */]: "span_id",
|
|
1335
|
+
[4 /* ROOT_SPAN_ID */]: "root_span_id"
|
|
1336
|
+
};
|
|
1337
|
+
var spanComponentsV4Schema = _v3.z.object({
|
|
1338
|
+
object_type: spanObjectTypeV3EnumSchema,
|
|
1339
|
+
propagated_event: _v3.z.record(_v3.z.unknown()).nullish()
|
|
1340
|
+
}).and(
|
|
1341
|
+
_v3.z.union([
|
|
1342
|
+
// Must provide one or the other.
|
|
1343
|
+
_v3.z.object({
|
|
1344
|
+
object_id: _v3.z.string().nullish(),
|
|
1345
|
+
compute_object_metadata_args: _v3.z.optional(_v3.z.null())
|
|
1346
|
+
}),
|
|
1347
|
+
_v3.z.object({
|
|
1348
|
+
object_id: _v3.z.optional(_v3.z.null()),
|
|
1349
|
+
compute_object_metadata_args: _v3.z.record(_v3.z.unknown())
|
|
1350
|
+
})
|
|
1351
|
+
])
|
|
1352
|
+
).and(
|
|
1353
|
+
_v3.z.union([
|
|
1354
|
+
// Either all of these must be provided or none.
|
|
1355
|
+
_v3.z.object({
|
|
1356
|
+
row_id: _v3.z.string(),
|
|
1357
|
+
span_id: _v3.z.string(),
|
|
1358
|
+
root_span_id: _v3.z.string()
|
|
1359
|
+
}),
|
|
1360
|
+
_v3.z.object({
|
|
1361
|
+
row_id: _v3.z.optional(_v3.z.null()),
|
|
1362
|
+
span_id: _v3.z.optional(_v3.z.null()),
|
|
1363
|
+
root_span_id: _v3.z.optional(_v3.z.null())
|
|
1364
|
+
})
|
|
1365
|
+
])
|
|
1366
|
+
);
|
|
1367
|
+
var SpanComponentsV4 = class _SpanComponentsV4 {
|
|
1368
|
+
constructor(data) {
|
|
1369
|
+
this.data = data;
|
|
1370
|
+
}
|
|
1371
|
+
toStr() {
|
|
1372
|
+
const jsonObj = {
|
|
1373
|
+
compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
|
|
1374
|
+
propagated_event: this.data.propagated_event || void 0
|
|
1375
|
+
};
|
|
1376
|
+
Object.keys(jsonObj).forEach((key) => {
|
|
1377
|
+
if (jsonObj[key] === void 0) {
|
|
1378
|
+
delete jsonObj[key];
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
const allBuffers = [];
|
|
1382
|
+
allBuffers.push(
|
|
1383
|
+
new Uint8Array([ENCODING_VERSION_NUMBER_V4, this.data.object_type])
|
|
1384
|
+
);
|
|
1385
|
+
const hexEntries = [];
|
|
1386
|
+
function addHexField(origVal, fieldId) {
|
|
1387
|
+
let hexResult;
|
|
1388
|
+
if (fieldId === 3 /* SPAN_ID */) {
|
|
1389
|
+
hexResult = tryMakeHexSpanId(origVal);
|
|
1390
|
+
} else if (fieldId === 4 /* ROOT_SPAN_ID */) {
|
|
1391
|
+
hexResult = tryMakeHexTraceId(origVal);
|
|
1392
|
+
} else {
|
|
1393
|
+
hexResult = { bytes: void 0, isHex: false };
|
|
1394
|
+
}
|
|
1395
|
+
if (hexResult.isHex) {
|
|
1396
|
+
hexEntries.push(
|
|
1397
|
+
concatUint8Arrays(new Uint8Array([fieldId]), hexResult.bytes)
|
|
1398
|
+
);
|
|
1399
|
+
} else {
|
|
1400
|
+
jsonObj[FIELDS_ID_TO_NAME[fieldId]] = origVal;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
if (this.data.object_id) {
|
|
1404
|
+
addHexField(this.data.object_id, 1 /* OBJECT_ID */);
|
|
1405
|
+
}
|
|
1406
|
+
if (this.data.row_id) {
|
|
1407
|
+
addHexField(this.data.row_id, 2 /* ROW_ID */);
|
|
1408
|
+
}
|
|
1409
|
+
if (this.data.span_id) {
|
|
1410
|
+
addHexField(this.data.span_id, 3 /* SPAN_ID */);
|
|
1411
|
+
}
|
|
1412
|
+
if (this.data.root_span_id) {
|
|
1413
|
+
addHexField(this.data.root_span_id, 4 /* ROOT_SPAN_ID */);
|
|
1414
|
+
}
|
|
1415
|
+
if (hexEntries.length > 255) {
|
|
1416
|
+
throw new Error("Impossible: too many hex entries to encode");
|
|
1417
|
+
}
|
|
1418
|
+
allBuffers.push(new Uint8Array([hexEntries.length]));
|
|
1419
|
+
allBuffers.push(...hexEntries);
|
|
1420
|
+
if (Object.keys(jsonObj).length > 0) {
|
|
1421
|
+
allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
|
|
1422
|
+
}
|
|
1423
|
+
return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
|
|
1424
|
+
}
|
|
1425
|
+
static fromStr(s) {
|
|
1426
|
+
try {
|
|
1427
|
+
const rawBytes = base64ToUint8Array(s);
|
|
1428
|
+
const jsonObj = {};
|
|
1429
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER_V4) {
|
|
1430
|
+
const v3Components = SpanComponentsV3.fromStr(s);
|
|
1431
|
+
jsonObj["object_type"] = v3Components.data.object_type;
|
|
1432
|
+
jsonObj["object_id"] = v3Components.data.object_id;
|
|
1433
|
+
jsonObj["compute_object_metadata_args"] = v3Components.data.compute_object_metadata_args;
|
|
1434
|
+
jsonObj["row_id"] = v3Components.data.row_id;
|
|
1435
|
+
jsonObj["span_id"] = v3Components.data.span_id;
|
|
1436
|
+
jsonObj["root_span_id"] = v3Components.data.root_span_id;
|
|
1437
|
+
jsonObj["propagated_event"] = v3Components.data.propagated_event;
|
|
1438
|
+
} else {
|
|
1439
|
+
jsonObj["object_type"] = rawBytes[1];
|
|
1440
|
+
const numHexEntries = rawBytes[2];
|
|
1441
|
+
let byteOffset = 3;
|
|
1442
|
+
for (let i = 0; i < numHexEntries; i++) {
|
|
1443
|
+
const fieldId = rawBytes[byteOffset];
|
|
1444
|
+
if (fieldId === 3 /* SPAN_ID */) {
|
|
1445
|
+
const hexBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 9);
|
|
1446
|
+
byteOffset += 9;
|
|
1447
|
+
jsonObj[FIELDS_ID_TO_NAME[fieldId]] = Array.from(
|
|
1448
|
+
hexBytes,
|
|
1449
|
+
(b) => b.toString(16).padStart(2, "0")
|
|
1450
|
+
).join("");
|
|
1451
|
+
} else if (fieldId === 4 /* ROOT_SPAN_ID */) {
|
|
1452
|
+
const hexBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
|
|
1453
|
+
byteOffset += 17;
|
|
1454
|
+
jsonObj[FIELDS_ID_TO_NAME[fieldId]] = Array.from(
|
|
1455
|
+
hexBytes,
|
|
1456
|
+
(b) => b.toString(16).padStart(2, "0")
|
|
1457
|
+
).join("");
|
|
1458
|
+
} else {
|
|
1459
|
+
const hexBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
|
|
1460
|
+
byteOffset += 17;
|
|
1461
|
+
jsonObj[FIELDS_ID_TO_NAME[fieldId]] = Array.from(
|
|
1462
|
+
hexBytes,
|
|
1463
|
+
(b) => b.toString(16).padStart(2, "0")
|
|
1464
|
+
).join("");
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
if (byteOffset < rawBytes.length) {
|
|
1468
|
+
const remainingJsonObj = JSON.parse(
|
|
1469
|
+
uint8ArrayToString(rawBytes.subarray(byteOffset))
|
|
1470
|
+
);
|
|
1471
|
+
Object.assign(jsonObj, remainingJsonObj);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
return _SpanComponentsV4.fromJsonObj(jsonObj);
|
|
1475
|
+
} catch (e7) {
|
|
1476
|
+
throw new Error(INVALID_ENCODING_ERRMSG_V4);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
objectIdFields() {
|
|
1480
|
+
if (!this.data.object_id) {
|
|
1481
|
+
throw new Error(
|
|
1482
|
+
"Impossible: cannot invoke `objectIdFields` unless SpanComponentsV4 is initialized with an `object_id`"
|
|
1483
|
+
);
|
|
1484
|
+
}
|
|
1485
|
+
switch (this.data.object_type) {
|
|
1486
|
+
case 1 /* EXPERIMENT */:
|
|
1487
|
+
return { experiment_id: this.data.object_id };
|
|
1488
|
+
case 2 /* PROJECT_LOGS */:
|
|
1489
|
+
return { project_id: this.data.object_id, log_id: "g" };
|
|
1490
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
1491
|
+
return { prompt_session_id: this.data.object_id, log_id: "x" };
|
|
1492
|
+
default:
|
|
1493
|
+
const _ = this.data.object_type;
|
|
1494
|
+
throw new Error(`Invalid object_type ${this.data.object_type}`);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
async export() {
|
|
1498
|
+
return this.toStr();
|
|
1499
|
+
}
|
|
1500
|
+
static fromJsonObj(jsonObj) {
|
|
1501
|
+
return new _SpanComponentsV4(spanComponentsV4Schema.parse(jsonObj));
|
|
1502
|
+
}
|
|
1503
|
+
};
|
|
1504
|
+
function parseParent(parent) {
|
|
1505
|
+
return typeof parent === "string" ? parent : parent ? new SpanComponentsV4({
|
|
1506
|
+
object_type: parent.object_type === "experiment" ? 1 /* EXPERIMENT */ : parent.object_type === "playground_logs" ? 3 /* PLAYGROUND_LOGS */ : 2 /* PROJECT_LOGS */,
|
|
1507
|
+
object_id: parent.object_id,
|
|
1508
|
+
...parent.row_ids ? {
|
|
1509
|
+
row_id: parent.row_ids.id,
|
|
1510
|
+
span_id: parent.row_ids.span_id,
|
|
1511
|
+
root_span_id: parent.row_ids.root_span_id
|
|
1512
|
+
} : {
|
|
1513
|
+
row_id: void 0,
|
|
1514
|
+
span_id: void 0,
|
|
1515
|
+
root_span_id: void 0
|
|
1516
|
+
},
|
|
1517
|
+
propagated_event: parent.propagated_event
|
|
1518
|
+
}).toStr() : void 0;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1273
1521
|
// util/git_fields.ts
|
|
1274
1522
|
function mergeGitMetadataSettings(s1, s2) {
|
|
1275
1523
|
if (s1.collect === "all") {
|
|
@@ -3202,7 +3450,7 @@ function getMustacheVars(prompt) {
|
|
|
3202
3450
|
return _mustache2.default.parse(prompt).filter(
|
|
3203
3451
|
(span) => span[0] === "name" || span[0] === "&"
|
|
3204
3452
|
);
|
|
3205
|
-
} catch (
|
|
3453
|
+
} catch (e8) {
|
|
3206
3454
|
return [];
|
|
3207
3455
|
}
|
|
3208
3456
|
}
|
|
@@ -3268,7 +3516,7 @@ var NoopSpan = (_class4 = class {
|
|
|
3268
3516
|
return this;
|
|
3269
3517
|
}
|
|
3270
3518
|
end(args) {
|
|
3271
|
-
return _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
3519
|
+
return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _25 => _25.endTime]), () => ( getCurrentUnixTimestamp()));
|
|
3272
3520
|
}
|
|
3273
3521
|
async export() {
|
|
3274
3522
|
return "";
|
|
@@ -3292,6 +3540,20 @@ var NoopSpan = (_class4 = class {
|
|
|
3292
3540
|
state() {
|
|
3293
3541
|
return _internalGetGlobalState();
|
|
3294
3542
|
}
|
|
3543
|
+
// Custom inspect for Node.js console.log
|
|
3544
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
3545
|
+
return `NoopSpan {
|
|
3546
|
+
kind: '${this.kind}',
|
|
3547
|
+
id: '${this.id}',
|
|
3548
|
+
spanId: '${this.spanId}',
|
|
3549
|
+
rootSpanId: '${this.rootSpanId}',
|
|
3550
|
+
spanParents: ${JSON.stringify(this.spanParents)}
|
|
3551
|
+
}`;
|
|
3552
|
+
}
|
|
3553
|
+
// Custom toString
|
|
3554
|
+
toString() {
|
|
3555
|
+
return `NoopSpan(id=${this.id}, spanId=${this.spanId})`;
|
|
3556
|
+
}
|
|
3295
3557
|
}, _class4);
|
|
3296
3558
|
var NOOP_SPAN = new NoopSpan();
|
|
3297
3559
|
var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
|
|
@@ -3307,7 +3569,7 @@ var loginSchema = _zod.z.strictObject({
|
|
|
3307
3569
|
});
|
|
3308
3570
|
var stateNonce = 0;
|
|
3309
3571
|
var BraintrustState = (_class5 = class _BraintrustState {
|
|
3310
|
-
constructor(loginParams) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);
|
|
3572
|
+
constructor(loginParams) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);
|
|
3311
3573
|
this.loginParams = loginParams;
|
|
3312
3574
|
this.id = `${(/* @__PURE__ */ new Date()).toLocaleString()}-${stateNonce++}`;
|
|
3313
3575
|
this.currentExperiment = void 0;
|
|
@@ -3361,6 +3623,7 @@ var BraintrustState = (_class5 = class _BraintrustState {
|
|
|
3361
3623
|
__init18() {this._apiConn = null}
|
|
3362
3624
|
__init19() {this._proxyConn = null}
|
|
3363
3625
|
|
|
3626
|
+
__init20() {this._idGenerator = null}
|
|
3364
3627
|
resetLoginInfo() {
|
|
3365
3628
|
this.appUrl = null;
|
|
3366
3629
|
this.appPublicUrl = null;
|
|
@@ -3375,6 +3638,15 @@ var BraintrustState = (_class5 = class _BraintrustState {
|
|
|
3375
3638
|
this._apiConn = null;
|
|
3376
3639
|
this._proxyConn = null;
|
|
3377
3640
|
}
|
|
3641
|
+
resetIdGenState() {
|
|
3642
|
+
this._idGenerator = null;
|
|
3643
|
+
}
|
|
3644
|
+
get idGenerator() {
|
|
3645
|
+
if (this._idGenerator === null) {
|
|
3646
|
+
this._idGenerator = getIdGenerator();
|
|
3647
|
+
}
|
|
3648
|
+
return this._idGenerator;
|
|
3649
|
+
}
|
|
3378
3650
|
copyLoginInfo(other) {
|
|
3379
3651
|
this.appUrl = other.appUrl;
|
|
3380
3652
|
this.appPublicUrl = other.appPublicUrl;
|
|
@@ -3442,8 +3714,8 @@ var BraintrustState = (_class5 = class _BraintrustState {
|
|
|
3442
3714
|
setFetch(fetch2) {
|
|
3443
3715
|
this.loginParams.fetch = fetch2;
|
|
3444
3716
|
this.fetch = fetch2;
|
|
3445
|
-
_optionalChain([this, 'access',
|
|
3446
|
-
_optionalChain([this, 'access',
|
|
3717
|
+
_optionalChain([this, 'access', _26 => _26._apiConn, 'optionalAccess', _27 => _27.setFetch, 'call', _28 => _28(fetch2)]);
|
|
3718
|
+
_optionalChain([this, 'access', _29 => _29._appConn, 'optionalAccess', _30 => _30.setFetch, 'call', _31 => _31(fetch2)]);
|
|
3447
3719
|
}
|
|
3448
3720
|
setMaskingFunction(maskingFunction) {
|
|
3449
3721
|
this.bgLogger().setMaskingFunction(maskingFunction);
|
|
@@ -3512,6 +3784,37 @@ var BraintrustState = (_class5 = class _BraintrustState {
|
|
|
3512
3784
|
enforceQueueSizeLimit(enforce) {
|
|
3513
3785
|
this._bgLogger.get().enforceQueueSizeLimit(enforce);
|
|
3514
3786
|
}
|
|
3787
|
+
// Custom serialization to avoid logging sensitive data
|
|
3788
|
+
toJSON() {
|
|
3789
|
+
return {
|
|
3790
|
+
id: this.id,
|
|
3791
|
+
orgId: this.orgId,
|
|
3792
|
+
orgName: this.orgName,
|
|
3793
|
+
appUrl: this.appUrl,
|
|
3794
|
+
appPublicUrl: this.appPublicUrl,
|
|
3795
|
+
apiUrl: this.apiUrl,
|
|
3796
|
+
proxyUrl: this.proxyUrl,
|
|
3797
|
+
loggedIn: this.loggedIn
|
|
3798
|
+
// Explicitly exclude loginToken, _apiConn, _appConn, _proxyConn and other sensitive fields
|
|
3799
|
+
};
|
|
3800
|
+
}
|
|
3801
|
+
// Custom inspect for Node.js console.log
|
|
3802
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
3803
|
+
return `BraintrustState {
|
|
3804
|
+
id: '${this.id}',
|
|
3805
|
+
orgId: ${this.orgId ? `'${this.orgId}'` : "null"},
|
|
3806
|
+
orgName: ${this.orgName ? `'${this.orgName}'` : "null"},
|
|
3807
|
+
appUrl: ${this.appUrl ? `'${this.appUrl}'` : "null"},
|
|
3808
|
+
apiUrl: ${this.apiUrl ? `'${this.apiUrl}'` : "null"},
|
|
3809
|
+
proxyUrl: ${this.proxyUrl ? `'${this.proxyUrl}'` : "null"},
|
|
3810
|
+
loggedIn: ${this.loggedIn},
|
|
3811
|
+
loginToken: '[REDACTED]'
|
|
3812
|
+
}`;
|
|
3813
|
+
}
|
|
3814
|
+
// Custom toString
|
|
3815
|
+
toString() {
|
|
3816
|
+
return `BraintrustState(id=${this.id}, org=${this.orgName || "none"}, loggedIn=${this.loggedIn})`;
|
|
3817
|
+
}
|
|
3515
3818
|
}, _class5);
|
|
3516
3819
|
var _globalState;
|
|
3517
3820
|
function _internalSetInitialState() {
|
|
@@ -3655,6 +3958,17 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
3655
3958
|
});
|
|
3656
3959
|
return await resp.json();
|
|
3657
3960
|
}
|
|
3961
|
+
// Custom inspect for Node.js console.log
|
|
3962
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
3963
|
+
return `HTTPConnection {
|
|
3964
|
+
base_url: '${this.base_url}',
|
|
3965
|
+
token: '[REDACTED]'
|
|
3966
|
+
}`;
|
|
3967
|
+
}
|
|
3968
|
+
// Custom toString
|
|
3969
|
+
toString() {
|
|
3970
|
+
return `HTTPConnection(${this.base_url})`;
|
|
3971
|
+
}
|
|
3658
3972
|
};
|
|
3659
3973
|
var BaseAttachment = class {
|
|
3660
3974
|
|
|
@@ -4075,9 +4389,9 @@ async function permalink(slug, opts) {
|
|
|
4075
4389
|
if (slug === "") {
|
|
4076
4390
|
return NOOP_SPAN_PERMALINK;
|
|
4077
4391
|
}
|
|
4078
|
-
const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
4392
|
+
const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _32 => _32.state]), () => ( _globalState));
|
|
4079
4393
|
const getOrgName = async () => {
|
|
4080
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
4394
|
+
if (_optionalChain([opts, 'optionalAccess', _33 => _33.orgName])) {
|
|
4081
4395
|
return opts.orgName;
|
|
4082
4396
|
}
|
|
4083
4397
|
await state.login({});
|
|
@@ -4087,7 +4401,7 @@ async function permalink(slug, opts) {
|
|
|
4087
4401
|
return state.orgName;
|
|
4088
4402
|
};
|
|
4089
4403
|
const getAppUrl = async () => {
|
|
4090
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
4404
|
+
if (_optionalChain([opts, 'optionalAccess', _34 => _34.appUrl])) {
|
|
4091
4405
|
return opts.appUrl;
|
|
4092
4406
|
}
|
|
4093
4407
|
await state.login({});
|
|
@@ -4174,8 +4488,8 @@ var Logger = (_class6 = class {
|
|
|
4174
4488
|
|
|
4175
4489
|
|
|
4176
4490
|
// For type identification.
|
|
4177
|
-
|
|
4178
|
-
constructor(state, lazyMetadata, logOptions = {}) {;_class6.prototype.
|
|
4491
|
+
__init21() {this.kind = "logger"}
|
|
4492
|
+
constructor(state, lazyMetadata, logOptions = {}) {;_class6.prototype.__init21.call(this);
|
|
4179
4493
|
this.lazyMetadata = lazyMetadata;
|
|
4180
4494
|
this._asyncFlush = logOptions.asyncFlush;
|
|
4181
4495
|
this.computeMetadataArgs = logOptions.computeMetadataArgs;
|
|
@@ -4217,7 +4531,7 @@ var Logger = (_class6 = class {
|
|
|
4217
4531
|
* @returns The `id` of the logged event.
|
|
4218
4532
|
*/
|
|
4219
4533
|
log(event, options) {
|
|
4220
|
-
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess',
|
|
4534
|
+
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _35 => _35.allowConcurrentWithSpans])) {
|
|
4221
4535
|
throw new Error(
|
|
4222
4536
|
"Cannot run toplevel `log` method while using spans. To log to the span, call `logger.traced` and then log with `span.log`"
|
|
4223
4537
|
);
|
|
@@ -4285,12 +4599,12 @@ var Logger = (_class6 = class {
|
|
|
4285
4599
|
state: this.state,
|
|
4286
4600
|
...startSpanParentArgs({
|
|
4287
4601
|
state: this.state,
|
|
4288
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
4602
|
+
parent: _optionalChain([args, 'optionalAccess', _36 => _36.parent]),
|
|
4289
4603
|
parentObjectType: this.parentObjectType(),
|
|
4290
4604
|
parentObjectId: this.lazyId,
|
|
4291
4605
|
parentComputeObjectMetadataArgs: this.computeMetadataArgs,
|
|
4292
|
-
parentSpanIds: _optionalChain([args, 'optionalAccess',
|
|
4293
|
-
propagatedEvent: _optionalChain([args, 'optionalAccess',
|
|
4606
|
+
parentSpanIds: _optionalChain([args, 'optionalAccess', _37 => _37.parentSpanIds]),
|
|
4607
|
+
propagatedEvent: _optionalChain([args, 'optionalAccess', _38 => _38.propagatedEvent])
|
|
4294
4608
|
}),
|
|
4295
4609
|
defaultRootType: "task" /* TASK */
|
|
4296
4610
|
});
|
|
@@ -4368,26 +4682,26 @@ var BACKGROUND_LOGGER_BASE_SLEEP_TIME_S = 1;
|
|
|
4368
4682
|
var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
|
|
4369
4683
|
|
|
4370
4684
|
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4685
|
+
__init22() {this.activeFlush = Promise.resolve()}
|
|
4686
|
+
__init23() {this.activeFlushResolved = true}
|
|
4687
|
+
__init24() {this.activeFlushError = void 0}
|
|
4374
4688
|
|
|
4375
|
-
|
|
4376
|
-
|
|
4689
|
+
__init25() {this.maskingFunction = null}
|
|
4690
|
+
__init26() {this.syncFlush = false}
|
|
4377
4691
|
// 6 MB for the AWS lambda gateway (from our own testing).
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4692
|
+
__init27() {this.maxRequestSize = 6 * 1024 * 1024}
|
|
4693
|
+
__init28() {this.defaultBatchSize = 100}
|
|
4694
|
+
__init29() {this.numTries = 3}
|
|
4695
|
+
__init30() {this.queueDropExceedingMaxsize = DEFAULT_QUEUE_SIZE}
|
|
4696
|
+
__init31() {this.queueDropLoggingPeriod = 60}
|
|
4697
|
+
__init32() {this.failedPublishPayloadsDir = void 0}
|
|
4698
|
+
__init33() {this.allPublishPayloadsDir = void 0}
|
|
4699
|
+
__init34() {this._disabled = false}
|
|
4700
|
+
__init35() {this.queueDropLoggingState = {
|
|
4387
4701
|
numDropped: 0,
|
|
4388
4702
|
lastLoggedTimestamp: 0
|
|
4389
4703
|
}}
|
|
4390
|
-
constructor(apiConn, opts) {;_class7.prototype.
|
|
4704
|
+
constructor(apiConn, opts) {;_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);
|
|
4391
4705
|
opts = _nullishCoalesce(opts, () => ( {}));
|
|
4392
4706
|
this.apiConn = apiConn;
|
|
4393
4707
|
const syncFlushEnv = Number(isomorph_default.getEnv("BRAINTRUST_SYNC_FLUSH"));
|
|
@@ -4476,7 +4790,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
|
|
|
4476
4790
|
this.queue.clear();
|
|
4477
4791
|
return;
|
|
4478
4792
|
}
|
|
4479
|
-
const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4793
|
+
const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _39 => _39.batchSize]), () => ( this.defaultBatchSize));
|
|
4480
4794
|
const wrappedItems = this.queue.drain();
|
|
4481
4795
|
const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
|
|
4482
4796
|
if (allItems.length === 0) {
|
|
@@ -4725,10 +5039,10 @@ Error: ${errorText}`;
|
|
|
4725
5039
|
} catch (err) {
|
|
4726
5040
|
if (err instanceof AggregateError) {
|
|
4727
5041
|
for (const e of err.errors) {
|
|
4728
|
-
_optionalChain([this, 'access',
|
|
5042
|
+
_optionalChain([this, 'access', _40 => _40.onFlushError, 'optionalCall', _41 => _41(e)]);
|
|
4729
5043
|
}
|
|
4730
5044
|
} else {
|
|
4731
|
-
_optionalChain([this, 'access',
|
|
5045
|
+
_optionalChain([this, 'access', _42 => _42.onFlushError, 'optionalCall', _43 => _43(err)]);
|
|
4732
5046
|
}
|
|
4733
5047
|
this.activeFlushError = err;
|
|
4734
5048
|
} finally {
|
|
@@ -5123,24 +5437,24 @@ async function loginToState(options = {}) {
|
|
|
5123
5437
|
return state;
|
|
5124
5438
|
}
|
|
5125
5439
|
function currentExperiment(options) {
|
|
5126
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5440
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _44 => _44.state]), () => ( _globalState));
|
|
5127
5441
|
return state.currentExperiment;
|
|
5128
5442
|
}
|
|
5129
5443
|
function currentLogger(options) {
|
|
5130
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5131
|
-
return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess',
|
|
5444
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.state]), () => ( _globalState));
|
|
5445
|
+
return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _46 => _46.asyncFlush]));
|
|
5132
5446
|
}
|
|
5133
5447
|
function currentSpan(options) {
|
|
5134
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5448
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _47 => _47.state]), () => ( _globalState));
|
|
5135
5449
|
return _nullishCoalesce(state.currentSpan.getStore(), () => ( NOOP_SPAN));
|
|
5136
5450
|
}
|
|
5137
5451
|
function getSpanParentObject(options) {
|
|
5138
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5452
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _48 => _48.state]), () => ( _globalState));
|
|
5139
5453
|
const parentSpan = currentSpan({ state });
|
|
5140
5454
|
if (!Object.is(parentSpan, NOOP_SPAN)) {
|
|
5141
5455
|
return parentSpan;
|
|
5142
5456
|
}
|
|
5143
|
-
const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5457
|
+
const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.parent]), () => ( state.currentParent.getStore()));
|
|
5144
5458
|
if (parentStr) return SpanComponentsV3.fromStr(parentStr);
|
|
5145
5459
|
const experiment = currentExperiment();
|
|
5146
5460
|
if (experiment) {
|
|
@@ -5169,7 +5483,7 @@ function traced(callback, args) {
|
|
|
5169
5483
|
const { span, isSyncFlushLogger } = startSpanAndIsLogger(args);
|
|
5170
5484
|
const ret = runCatchFinally(
|
|
5171
5485
|
() => {
|
|
5172
|
-
if (_nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
5486
|
+
if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _50 => _50.setCurrent]), () => ( true))) {
|
|
5173
5487
|
return withCurrent(span, callback);
|
|
5174
5488
|
} else {
|
|
5175
5489
|
return callback(span);
|
|
@@ -5181,7 +5495,7 @@ function traced(callback, args) {
|
|
|
5181
5495
|
},
|
|
5182
5496
|
() => span.end()
|
|
5183
5497
|
);
|
|
5184
|
-
if (_optionalChain([args, 'optionalAccess',
|
|
5498
|
+
if (_optionalChain([args, 'optionalAccess', _51 => _51.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _52 => _52.asyncFlush])) {
|
|
5185
5499
|
return ret;
|
|
5186
5500
|
} else {
|
|
5187
5501
|
return (async () => {
|
|
@@ -5197,14 +5511,14 @@ function startSpan(args) {
|
|
|
5197
5511
|
return startSpanAndIsLogger(args).span;
|
|
5198
5512
|
}
|
|
5199
5513
|
async function flush(options) {
|
|
5200
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5514
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.state]), () => ( _globalState));
|
|
5201
5515
|
return await state.bgLogger().flush();
|
|
5202
5516
|
}
|
|
5203
5517
|
function startSpanAndIsLogger(args) {
|
|
5204
|
-
const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
5518
|
+
const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _54 => _54.state]), () => ( _globalState));
|
|
5205
5519
|
const parentObject = getSpanParentObject({
|
|
5206
|
-
asyncFlush: _optionalChain([args, 'optionalAccess',
|
|
5207
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
5520
|
+
asyncFlush: _optionalChain([args, 'optionalAccess', _55 => _55.asyncFlush]),
|
|
5521
|
+
parent: _optionalChain([args, 'optionalAccess', _56 => _56.parent]),
|
|
5208
5522
|
state
|
|
5209
5523
|
});
|
|
5210
5524
|
if (parentObject instanceof SpanComponentsV3) {
|
|
@@ -5221,14 +5535,14 @@ function startSpanAndIsLogger(args) {
|
|
|
5221
5535
|
),
|
|
5222
5536
|
parentComputeObjectMetadataArgs: _nullishCoalesce(parentObject.data.compute_object_metadata_args, () => ( void 0)),
|
|
5223
5537
|
parentSpanIds,
|
|
5224
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
5538
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _57 => _57.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5225
5539
|
(_nullishCoalesce(parentObject.data.propagated_event, () => ( void 0)))))
|
|
5226
5540
|
});
|
|
5227
5541
|
return {
|
|
5228
5542
|
span,
|
|
5229
5543
|
isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
|
|
5230
5544
|
// behavior, and therefore propagate along whatever we get from the arguments
|
|
5231
|
-
_optionalChain([args, 'optionalAccess',
|
|
5545
|
+
_optionalChain([args, 'optionalAccess', _58 => _58.asyncFlush]) === false
|
|
5232
5546
|
};
|
|
5233
5547
|
} else {
|
|
5234
5548
|
const span = parentObject.startSpan(args);
|
|
@@ -5371,10 +5685,10 @@ function extractAttachments(event, attachments) {
|
|
|
5371
5685
|
event[key] = value.reference;
|
|
5372
5686
|
continue;
|
|
5373
5687
|
}
|
|
5374
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
5688
|
+
if (_optionalChain([value, 'optionalAccess', _59 => _59.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
|
|
5375
5689
|
continue;
|
|
5376
5690
|
}
|
|
5377
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
5691
|
+
if (_optionalChain([value, 'optionalAccess', _60 => _60.reference, 'optionalAccess', _61 => _61.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _62 => _62.uploader])) {
|
|
5378
5692
|
const attachment = new Attachment({
|
|
5379
5693
|
data: value.dataDebugString,
|
|
5380
5694
|
filename: value.reference.filename,
|
|
@@ -5441,13 +5755,13 @@ function validateAndSanitizeExperimentLogFullArgs(event, hasDataset) {
|
|
|
5441
5755
|
var INTERNAL_BTQL_LIMIT = 1e3;
|
|
5442
5756
|
var MAX_BTQL_ITERATIONS = 1e4;
|
|
5443
5757
|
var ObjectFetcher = (_class8 = class {
|
|
5444
|
-
constructor(objectType, pinnedVersion, mutateRecord, _internal_btql) {;_class8.prototype.
|
|
5758
|
+
constructor(objectType, pinnedVersion, mutateRecord, _internal_btql) {;_class8.prototype.__init36.call(this);
|
|
5445
5759
|
this.objectType = objectType;
|
|
5446
5760
|
this.pinnedVersion = pinnedVersion;
|
|
5447
5761
|
this.mutateRecord = mutateRecord;
|
|
5448
5762
|
this._internal_btql = _internal_btql;
|
|
5449
5763
|
}
|
|
5450
|
-
|
|
5764
|
+
__init36() {this._fetchedData = void 0}
|
|
5451
5765
|
get id() {
|
|
5452
5766
|
throw new Error("ObjectFetcher subclasses must have an 'id' attribute");
|
|
5453
5767
|
}
|
|
@@ -5512,7 +5826,7 @@ var ObjectFetcher = (_class8 = class {
|
|
|
5512
5826
|
throw new Error("Too many BTQL iterations");
|
|
5513
5827
|
}
|
|
5514
5828
|
}
|
|
5515
|
-
this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess',
|
|
5829
|
+
this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _63 => _63.map, 'call', _64 => _64(this.mutateRecord)]) : data;
|
|
5516
5830
|
}
|
|
5517
5831
|
return this._fetchedData || [];
|
|
5518
5832
|
}
|
|
@@ -5543,9 +5857,9 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
5543
5857
|
|
|
5544
5858
|
|
|
5545
5859
|
// For type identification.
|
|
5546
|
-
|
|
5860
|
+
__init37() {this.kind = "experiment"}
|
|
5547
5861
|
constructor(state, lazyMetadata, dataset) {
|
|
5548
|
-
super("experiment", void 0, (r) => enrichAttachments(r, state));_class9.prototype.
|
|
5862
|
+
super("experiment", void 0, (r) => enrichAttachments(r, state));_class9.prototype.__init37.call(this);;
|
|
5549
5863
|
this.lazyMetadata = lazyMetadata;
|
|
5550
5864
|
this.dataset = dataset;
|
|
5551
5865
|
this.lastStartTime = getCurrentUnixTimestamp();
|
|
@@ -5593,7 +5907,7 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
5593
5907
|
* @returns The `id` of the logged event.
|
|
5594
5908
|
*/
|
|
5595
5909
|
log(event, options) {
|
|
5596
|
-
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess',
|
|
5910
|
+
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _65 => _65.allowConcurrentWithSpans])) {
|
|
5597
5911
|
throw new Error(
|
|
5598
5912
|
"Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
|
|
5599
5913
|
);
|
|
@@ -5646,12 +5960,12 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
5646
5960
|
state: this.state,
|
|
5647
5961
|
...startSpanParentArgs({
|
|
5648
5962
|
state: this.state,
|
|
5649
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
5963
|
+
parent: _optionalChain([args, 'optionalAccess', _66 => _66.parent]),
|
|
5650
5964
|
parentObjectType: this.parentObjectType(),
|
|
5651
5965
|
parentObjectId: this.lazyId,
|
|
5652
5966
|
parentComputeObjectMetadataArgs: void 0,
|
|
5653
5967
|
parentSpanIds: void 0,
|
|
5654
|
-
propagatedEvent: _optionalChain([args, 'optionalAccess',
|
|
5968
|
+
propagatedEvent: _optionalChain([args, 'optionalAccess', _67 => _67.propagatedEvent])
|
|
5655
5969
|
}),
|
|
5656
5970
|
defaultRootType: "eval" /* EVAL */
|
|
5657
5971
|
});
|
|
@@ -5852,8 +6166,8 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5852
6166
|
|
|
5853
6167
|
|
|
5854
6168
|
|
|
5855
|
-
|
|
5856
|
-
constructor(args) {;_class10.prototype.
|
|
6169
|
+
__init38() {this.kind = "span"}
|
|
6170
|
+
constructor(args) {;_class10.prototype.__init38.call(this);
|
|
5857
6171
|
this._state = args.state;
|
|
5858
6172
|
const spanAttributes = _nullishCoalesce(args.spanAttributes, () => ( {}));
|
|
5859
6173
|
const rawEvent = _nullishCoalesce(args.event, () => ( {}));
|
|
@@ -5893,13 +6207,17 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5893
6207
|
},
|
|
5894
6208
|
created: (/* @__PURE__ */ new Date()).toISOString()
|
|
5895
6209
|
};
|
|
5896
|
-
this._id = _nullishCoalesce(eventId, () => (
|
|
5897
|
-
this._spanId = _nullishCoalesce(args.spanId, () => (
|
|
6210
|
+
this._id = _nullishCoalesce(eventId, () => ( this._state.idGenerator.getSpanId()));
|
|
6211
|
+
this._spanId = _nullishCoalesce(args.spanId, () => ( this._state.idGenerator.getSpanId()));
|
|
5898
6212
|
if (args.parentSpanIds) {
|
|
5899
6213
|
this._rootSpanId = args.parentSpanIds.rootSpanId;
|
|
5900
6214
|
this._spanParents = "parentSpanIds" in args.parentSpanIds ? args.parentSpanIds.parentSpanIds : [args.parentSpanIds.spanId];
|
|
5901
6215
|
} else {
|
|
5902
|
-
this.
|
|
6216
|
+
if (this._state.idGenerator.shareRootSpanId()) {
|
|
6217
|
+
this._rootSpanId = this._spanId;
|
|
6218
|
+
} else {
|
|
6219
|
+
this._rootSpanId = this._state.idGenerator.getTraceId();
|
|
6220
|
+
}
|
|
5903
6221
|
this._spanParents = void 0;
|
|
5904
6222
|
}
|
|
5905
6223
|
this.isMerge = false;
|
|
@@ -5943,10 +6261,10 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5943
6261
|
...serializableInternalData,
|
|
5944
6262
|
[IS_MERGE_FIELD]: this.isMerge
|
|
5945
6263
|
});
|
|
5946
|
-
if (_optionalChain([partialRecord, 'access',
|
|
5947
|
-
this.loggedEndTime = _optionalChain([partialRecord, 'access',
|
|
6264
|
+
if (_optionalChain([partialRecord, 'access', _68 => _68.metrics, 'optionalAccess', _69 => _69.end])) {
|
|
6265
|
+
this.loggedEndTime = _optionalChain([partialRecord, 'access', _70 => _70.metrics, 'optionalAccess', _71 => _71.end]);
|
|
5948
6266
|
}
|
|
5949
|
-
if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access',
|
|
6267
|
+
if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _72 => _72._spanParents, 'optionalAccess', _73 => _73.length])) {
|
|
5950
6268
|
throw new Error("Tags can only be logged to the root span");
|
|
5951
6269
|
}
|
|
5952
6270
|
const computeRecord = async () => ({
|
|
@@ -5991,18 +6309,18 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5991
6309
|
);
|
|
5992
6310
|
}
|
|
5993
6311
|
startSpan(args) {
|
|
5994
|
-
const parentSpanIds = _optionalChain([args, 'optionalAccess',
|
|
6312
|
+
const parentSpanIds = _optionalChain([args, 'optionalAccess', _74 => _74.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
|
|
5995
6313
|
return new _SpanImpl({
|
|
5996
6314
|
state: this._state,
|
|
5997
6315
|
...args,
|
|
5998
6316
|
...startSpanParentArgs({
|
|
5999
6317
|
state: this._state,
|
|
6000
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
6318
|
+
parent: _optionalChain([args, 'optionalAccess', _75 => _75.parent]),
|
|
6001
6319
|
parentObjectType: this.parentObjectType,
|
|
6002
6320
|
parentObjectId: this.parentObjectId,
|
|
6003
6321
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
6004
6322
|
parentSpanIds,
|
|
6005
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6323
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _76 => _76.propagatedEvent]), () => ( this.propagatedEvent))
|
|
6006
6324
|
})
|
|
6007
6325
|
});
|
|
6008
6326
|
}
|
|
@@ -6016,12 +6334,12 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
6016
6334
|
...args,
|
|
6017
6335
|
...startSpanParentArgs({
|
|
6018
6336
|
state: this._state,
|
|
6019
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
6337
|
+
parent: _optionalChain([args, 'optionalAccess', _77 => _77.parent]),
|
|
6020
6338
|
parentObjectType: this.parentObjectType,
|
|
6021
6339
|
parentObjectId: this.parentObjectId,
|
|
6022
6340
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
6023
6341
|
parentSpanIds,
|
|
6024
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6342
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.propagatedEvent]), () => ( this.propagatedEvent))
|
|
6025
6343
|
}),
|
|
6026
6344
|
spanId
|
|
6027
6345
|
});
|
|
@@ -6030,7 +6348,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
6030
6348
|
let endTime;
|
|
6031
6349
|
let internalData = {};
|
|
6032
6350
|
if (!this.loggedEndTime) {
|
|
6033
|
-
endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6351
|
+
endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _79 => _79.endTime]), () => ( getCurrentUnixTimestamp()));
|
|
6034
6352
|
internalData = { metrics: { end: endTime } };
|
|
6035
6353
|
} else {
|
|
6036
6354
|
endTime = this.loggedEndTime;
|
|
@@ -6073,8 +6391,8 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
6073
6391
|
const args = this.parentComputeObjectMetadataArgs;
|
|
6074
6392
|
switch (this.parentObjectType) {
|
|
6075
6393
|
case 2 /* PROJECT_LOGS */: {
|
|
6076
|
-
const projectID = _optionalChain([args, 'optionalAccess',
|
|
6077
|
-
const projectName = _optionalChain([args, 'optionalAccess',
|
|
6394
|
+
const projectID = _optionalChain([args, 'optionalAccess', _80 => _80.project_id]) || this.parentObjectId.getSync().value;
|
|
6395
|
+
const projectName = _optionalChain([args, 'optionalAccess', _81 => _81.project_name]);
|
|
6078
6396
|
if (projectID) {
|
|
6079
6397
|
return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
|
|
6080
6398
|
} else if (projectName) {
|
|
@@ -6084,7 +6402,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
6084
6402
|
}
|
|
6085
6403
|
}
|
|
6086
6404
|
case 1 /* EXPERIMENT */: {
|
|
6087
|
-
const expID = _optionalChain([args, 'optionalAccess',
|
|
6405
|
+
const expID = _optionalChain([args, 'optionalAccess', _82 => _82.experiment_id]) || _optionalChain([this, 'access', _83 => _83.parentObjectId, 'optionalAccess', _84 => _84.getSync, 'call', _85 => _85(), 'optionalAccess', _86 => _86.value]);
|
|
6088
6406
|
if (!expID) {
|
|
6089
6407
|
return getErrPermlink("provide-experiment-id");
|
|
6090
6408
|
} else {
|
|
@@ -6110,6 +6428,20 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
6110
6428
|
state() {
|
|
6111
6429
|
return this._state;
|
|
6112
6430
|
}
|
|
6431
|
+
// Custom inspect for Node.js console.log
|
|
6432
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
6433
|
+
return `SpanImpl {
|
|
6434
|
+
kind: '${this.kind}',
|
|
6435
|
+
id: '${this.id}',
|
|
6436
|
+
spanId: '${this.spanId}',
|
|
6437
|
+
rootSpanId: '${this.rootSpanId}',
|
|
6438
|
+
spanParents: ${JSON.stringify(this.spanParents)}
|
|
6439
|
+
}`;
|
|
6440
|
+
}
|
|
6441
|
+
// Custom toString
|
|
6442
|
+
toString() {
|
|
6443
|
+
return `SpanImpl(id=${this.id}, spanId=${this.spanId})`;
|
|
6444
|
+
}
|
|
6113
6445
|
}, _class10);
|
|
6114
6446
|
function splitLoggingData({
|
|
6115
6447
|
event,
|
|
@@ -6160,13 +6492,13 @@ var Dataset2 = (_class11 = class extends ObjectFetcher {
|
|
|
6160
6492
|
)
|
|
6161
6493
|
),
|
|
6162
6494
|
_internal_btql
|
|
6163
|
-
);_class11.prototype.
|
|
6495
|
+
);_class11.prototype.__init39.call(this);_class11.prototype.__init40.call(this);;
|
|
6164
6496
|
this.state = state;
|
|
6165
6497
|
this.lazyMetadata = lazyMetadata;
|
|
6166
6498
|
}
|
|
6167
6499
|
|
|
6168
|
-
|
|
6169
|
-
|
|
6500
|
+
__init39() {this.__braintrust_dataset_marker = true}
|
|
6501
|
+
__init40() {this.newRecords = 0}
|
|
6170
6502
|
get id() {
|
|
6171
6503
|
return (async () => {
|
|
6172
6504
|
return (await this.lazyMetadata.get()).dataset.id;
|
|
@@ -6489,14 +6821,14 @@ function renderPromptParams(params, args, options) {
|
|
|
6489
6821
|
return params;
|
|
6490
6822
|
}
|
|
6491
6823
|
var Prompt2 = (_class12 = class _Prompt {
|
|
6492
|
-
constructor(metadata, defaults, noTrace) {;_class12.prototype.
|
|
6824
|
+
constructor(metadata, defaults, noTrace) {;_class12.prototype.__init41.call(this);_class12.prototype.__init42.call(this);
|
|
6493
6825
|
this.metadata = metadata;
|
|
6494
6826
|
this.defaults = defaults;
|
|
6495
6827
|
this.noTrace = noTrace;
|
|
6496
6828
|
}
|
|
6497
6829
|
|
|
6498
|
-
|
|
6499
|
-
|
|
6830
|
+
__init41() {this.hasParsedPromptData = false}
|
|
6831
|
+
__init42() {this.__braintrust_prompt_marker = true}
|
|
6500
6832
|
get id() {
|
|
6501
6833
|
return this.metadata.id;
|
|
6502
6834
|
}
|
|
@@ -6510,13 +6842,13 @@ var Prompt2 = (_class12 = class _Prompt {
|
|
|
6510
6842
|
return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
|
|
6511
6843
|
}
|
|
6512
6844
|
get prompt() {
|
|
6513
|
-
return _optionalChain([this, 'access',
|
|
6845
|
+
return _optionalChain([this, 'access', _87 => _87.getParsedPromptData, 'call', _88 => _88(), 'optionalAccess', _89 => _89.prompt]);
|
|
6514
6846
|
}
|
|
6515
6847
|
get version() {
|
|
6516
6848
|
return this.metadata[TRANSACTION_ID_FIELD];
|
|
6517
6849
|
}
|
|
6518
6850
|
get options() {
|
|
6519
|
-
return _optionalChain([this, 'access',
|
|
6851
|
+
return _optionalChain([this, 'access', _90 => _90.getParsedPromptData, 'call', _91 => _91(), 'optionalAccess', _92 => _92.options]) || {};
|
|
6520
6852
|
}
|
|
6521
6853
|
get promptData() {
|
|
6522
6854
|
return this.getParsedPromptData();
|
|
@@ -6667,7 +6999,7 @@ var Prompt2 = (_class12 = class _Prompt {
|
|
|
6667
6999
|
return {
|
|
6668
7000
|
type: "chat",
|
|
6669
7001
|
messages,
|
|
6670
|
-
..._optionalChain([prompt, 'access',
|
|
7002
|
+
..._optionalChain([prompt, 'access', _93 => _93.tools, 'optionalAccess', _94 => _94.trim, 'call', _95 => _95()]) ? {
|
|
6671
7003
|
tools: render(prompt.tools)
|
|
6672
7004
|
} : void 0
|
|
6673
7005
|
};
|
|
@@ -7801,8 +8133,8 @@ function fitNameToSpaces(name, length) {
|
|
|
7801
8133
|
}
|
|
7802
8134
|
var BarProgressReporter = (_class13 = class {
|
|
7803
8135
|
|
|
7804
|
-
|
|
7805
|
-
constructor() {;_class13.prototype.
|
|
8136
|
+
__init43() {this.bars = {}}
|
|
8137
|
+
constructor() {;_class13.prototype.__init43.call(this);
|
|
7806
8138
|
this.multiBar = new cliProgress.MultiBar(
|
|
7807
8139
|
{
|
|
7808
8140
|
clearOnComplete: false,
|
|
@@ -7845,9 +8177,9 @@ var Project2 = (_class14 = class {
|
|
|
7845
8177
|
|
|
7846
8178
|
|
|
7847
8179
|
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
constructor(args) {;_class14.prototype.
|
|
8180
|
+
__init44() {this._publishableCodeFunctions = []}
|
|
8181
|
+
__init45() {this._publishablePrompts = []}
|
|
8182
|
+
constructor(args) {;_class14.prototype.__init44.call(this);_class14.prototype.__init45.call(this);
|
|
7851
8183
|
_initializeSpanContext();
|
|
7852
8184
|
this.name = "name" in args ? args.name : void 0;
|
|
7853
8185
|
this.id = "id" in args ? args.id : void 0;
|
|
@@ -7892,10 +8224,10 @@ var Project2 = (_class14 = class {
|
|
|
7892
8224
|
}
|
|
7893
8225
|
}, _class14);
|
|
7894
8226
|
var ToolBuilder = (_class15 = class {
|
|
7895
|
-
constructor(project) {;_class15.prototype.
|
|
8227
|
+
constructor(project) {;_class15.prototype.__init46.call(this);
|
|
7896
8228
|
this.project = project;
|
|
7897
8229
|
}
|
|
7898
|
-
|
|
8230
|
+
__init46() {this.taskCounter = 0}
|
|
7899
8231
|
// This type definition is just a catch all so that the implementation can be
|
|
7900
8232
|
// less specific than the two more specific declarations above.
|
|
7901
8233
|
create(opts) {
|
|
@@ -7922,10 +8254,10 @@ var ToolBuilder = (_class15 = class {
|
|
|
7922
8254
|
}
|
|
7923
8255
|
}, _class15);
|
|
7924
8256
|
var ScorerBuilder = (_class16 = class {
|
|
7925
|
-
constructor(project) {;_class16.prototype.
|
|
8257
|
+
constructor(project) {;_class16.prototype.__init47.call(this);
|
|
7926
8258
|
this.project = project;
|
|
7927
8259
|
}
|
|
7928
|
-
|
|
8260
|
+
__init47() {this.taskCounter = 0}
|
|
7929
8261
|
create(opts) {
|
|
7930
8262
|
this.taskCounter++;
|
|
7931
8263
|
let resolvedName = opts.name;
|
|
@@ -8142,9 +8474,9 @@ function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
|
8142
8474
|
}
|
|
8143
8475
|
};
|
|
8144
8476
|
}
|
|
8145
|
-
var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.
|
|
8146
|
-
|
|
8147
|
-
|
|
8477
|
+
var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__init48.call(this);_class17.prototype.__init49.call(this); }
|
|
8478
|
+
__init48() {this.nameToId = {}}
|
|
8479
|
+
__init49() {this.idToName = {}}
|
|
8148
8480
|
async getId(projectName) {
|
|
8149
8481
|
if (!(projectName in this.nameToId)) {
|
|
8150
8482
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
|
|
@@ -8506,10 +8838,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8506
8838
|
span,
|
|
8507
8839
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
8508
8840
|
reportProgress: (event) => {
|
|
8509
|
-
_optionalChain([stream, 'optionalCall',
|
|
8841
|
+
_optionalChain([stream, 'optionalCall', _96 => _96({
|
|
8510
8842
|
...event,
|
|
8511
8843
|
id: rootSpan.id,
|
|
8512
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8844
|
+
origin: _optionalChain([baseEvent, 'access', _97 => _97.event, 'optionalAccess', _98 => _98.origin]),
|
|
8513
8845
|
name: evaluator.evalName,
|
|
8514
8846
|
object_type: "task"
|
|
8515
8847
|
})]);
|
|
@@ -8659,7 +8991,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8659
8991
|
...scores
|
|
8660
8992
|
},
|
|
8661
8993
|
error: error2,
|
|
8662
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8994
|
+
origin: _optionalChain([baseEvent, 'access', _99 => _99.event, 'optionalAccess', _100 => _100.origin])
|
|
8663
8995
|
});
|
|
8664
8996
|
};
|
|
8665
8997
|
if (!experiment) {
|
|
@@ -8882,12 +9214,12 @@ async function cachedLogin(options) {
|
|
|
8882
9214
|
}
|
|
8883
9215
|
function makeCheckAuthorized(allowedOrgName) {
|
|
8884
9216
|
return async (req, _res, next) => {
|
|
8885
|
-
if (!_optionalChain([req, 'access',
|
|
9217
|
+
if (!_optionalChain([req, 'access', _101 => _101.ctx, 'optionalAccess', _102 => _102.token])) {
|
|
8886
9218
|
return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
|
|
8887
9219
|
}
|
|
8888
9220
|
try {
|
|
8889
9221
|
const state = await cachedLogin({
|
|
8890
|
-
apiKey: _optionalChain([req, 'access',
|
|
9222
|
+
apiKey: _optionalChain([req, 'access', _103 => _103.ctx, 'optionalAccess', _104 => _104.token]),
|
|
8891
9223
|
orgName: allowedOrgName
|
|
8892
9224
|
});
|
|
8893
9225
|
req.ctx.state = state;
|
|
@@ -9093,7 +9425,7 @@ function runDevServer(evaluators, opts) {
|
|
|
9093
9425
|
scores,
|
|
9094
9426
|
stream
|
|
9095
9427
|
} = evalBodySchema.parse(req.body);
|
|
9096
|
-
if (!_optionalChain([req, 'access',
|
|
9428
|
+
if (!_optionalChain([req, 'access', _105 => _105.ctx, 'optionalAccess', _106 => _106.state])) {
|
|
9097
9429
|
res.status(500).json({ error: "Braintrust state not initialized in request" });
|
|
9098
9430
|
return;
|
|
9099
9431
|
}
|
|
@@ -9150,7 +9482,7 @@ function runDevServer(evaluators, opts) {
|
|
|
9150
9482
|
...evaluator,
|
|
9151
9483
|
data: evalData.data,
|
|
9152
9484
|
scores: evaluator.scores.concat(
|
|
9153
|
-
_nullishCoalesce(_optionalChain([scores, 'optionalAccess',
|
|
9485
|
+
_nullishCoalesce(_optionalChain([scores, 'optionalAccess', _107 => _107.map, 'call', _108 => _108(
|
|
9154
9486
|
(score) => makeScorer(state, score.name, score.function_id)
|
|
9155
9487
|
)]), () => ( []))
|
|
9156
9488
|
),
|