braintrust 0.2.6 → 0.3.7

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/dist/cli.js CHANGED
@@ -1232,7 +1232,7 @@ var require_package = __commonJS({
1232
1232
  "package.json"(exports2, module2) {
1233
1233
  module2.exports = {
1234
1234
  name: "braintrust",
1235
- version: "0.2.6",
1235
+ version: "0.3.7",
1236
1236
  description: "SDK for integrating Braintrust",
1237
1237
  repository: {
1238
1238
  type: "git",
@@ -1270,26 +1270,32 @@ var require_package = __commonJS({
1270
1270
  import: "./dev/dist/index.mjs",
1271
1271
  module: "./dev/dist/index.mjs",
1272
1272
  require: "./dev/dist/index.js"
1273
+ },
1274
+ "./util": {
1275
+ types: "./util/dist/index.d.ts",
1276
+ import: "./util/dist/index.mjs",
1277
+ module: "./util/dist/index.mjs",
1278
+ require: "./util/dist/index.js"
1273
1279
  }
1274
1280
  },
1275
1281
  files: [
1276
1282
  "dist/**/*",
1277
- "dev/dist/**/*"
1283
+ "dev/dist/**/*",
1284
+ "util/dist/**/*"
1278
1285
  ],
1279
1286
  scripts: {
1280
1287
  build: 'cross-env NODE_OPTIONS="--max-old-space-size=8192" tsup',
1281
1288
  watch: "tsup --watch",
1282
1289
  clean: "rm -r dist/* && rm -r dev/dist/*",
1283
1290
  docs: "npx typedoc --options typedoc.json src/index.ts",
1284
- prepublishOnly: "../../scripts/node_prepublish_sdk.py",
1285
- postpublish: "../../scripts/node_postpublish_sdk.py",
1286
- test: "vitest run --exclude src/wrappers/anthropic.test.ts --exclude src/wrappers/oai.test.ts --exclude src/otel.test.ts --exclude src/otel-no-deps.test.ts --exclude src/wrappers/ai-sdk-v1.test.ts --exclude src/wrappers/ai-sdk-v2.test.ts",
1291
+ test: "vitest run --exclude src/wrappers/anthropic.test.ts --exclude src/wrappers/oai.test.ts --exclude src/otel.test.ts --exclude src/otel-no-deps.test.ts --exclude src/wrappers/ai-sdk-v1.test.ts --exclude src/wrappers/ai-sdk-v2.test.ts --exclude src/wrappers/ai-sdk-v3.test.ts",
1287
1292
  "test:anthropic": "vitest run src/wrappers/anthropic.test.ts",
1288
1293
  "test:openai": "vitest run src/wrappers/oai.test.ts",
1289
1294
  "test:otel": "vitest run src/otel.test.ts",
1290
1295
  "test:otel-no-deps": "vitest run src/otel-no-deps.test.ts --reporter=verbose",
1291
1296
  "test:ai-sdk-v1": "vitest run src/wrappers/ai-sdk-v1.test.ts",
1292
- "test:ai-sdk-v2": "vitest run src/wrappers/ai-sdk-v2.test.ts src/wrappers/ai-sdk-v1.test.ts"
1297
+ "test:ai-sdk-v2": "vitest run src/wrappers/ai-sdk-v2.test.ts src/wrappers/ai-sdk-v1.test.ts",
1298
+ "test:ai-sdk-v3": "vitest run src/wrappers/ai-sdk-v3.test.ts"
1293
1299
  },
1294
1300
  author: "",
1295
1301
  license: "MIT",
@@ -1328,7 +1334,6 @@ var require_package = __commonJS({
1328
1334
  },
1329
1335
  dependencies: {
1330
1336
  "@ai-sdk/provider": "^1.1.3",
1331
- "@braintrust/core": "0.0.95",
1332
1337
  "@next/env": "^14.2.3",
1333
1338
  "@vercel/functions": "^1.0.2",
1334
1339
  argparse: "^2.0.1",
@@ -1371,7 +1376,7 @@ var dotenv2 = __toESM(require("dotenv"));
1371
1376
  var import_fs2 = __toESM(require("fs"));
1372
1377
  var import_os = __toESM(require("os"));
1373
1378
  var import_path6 = __toESM(require("path"));
1374
- var import_util6 = __toESM(require("util"));
1379
+ var import_util14 = __toESM(require("util"));
1375
1380
  var fsWalk = __toESM(require_out3());
1376
1381
  var import_minimatch = require("minimatch");
1377
1382
  var import_argparse = require("argparse");
@@ -1437,13 +1442,1026 @@ var Queue = class {
1437
1442
  }
1438
1443
  };
1439
1444
 
1440
- // src/logger.ts
1441
- var import_core2 = require("@braintrust/core");
1445
+ // util/db_fields.ts
1446
+ var TRANSACTION_ID_FIELD = "_xact_id";
1447
+ var IS_MERGE_FIELD = "_is_merge";
1448
+ var AUDIT_SOURCE_FIELD = "_audit_source";
1449
+ var AUDIT_METADATA_FIELD = "_audit_metadata";
1450
+ var VALID_SOURCES = ["app", "api", "external"];
1451
+ var PARENT_ID_FIELD = "_parent_id";
1452
+
1453
+ // util/span_identifier_v3.ts
1454
+ var uuid3 = __toESM(require("uuid"));
1455
+
1456
+ // util/span_identifier_v2.ts
1457
+ var uuid2 = __toESM(require("uuid"));
1458
+
1459
+ // util/span_identifier_v1.ts
1460
+ var uuid = __toESM(require("uuid"));
1461
+ var import_v3 = require("zod/v3");
1462
+ function tryMakeUuid(s) {
1463
+ try {
1464
+ const ret = uuid.parse(s);
1465
+ if (ret.length !== 16) {
1466
+ throw new Error();
1467
+ }
1468
+ return { bytes: Buffer.from(ret), isUUID: true };
1469
+ } catch (e) {
1470
+ return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
1471
+ }
1472
+ }
1473
+ var ENCODING_VERSION_NUMBER = 1;
1474
+ var INVALID_ENCODING_ERRMSG = "SpanComponents string is not properly encoded. This may be due to a version mismatch between the SDK library used to export the span and the library used to decode it. Please make sure you are using the same SDK version across the board";
1475
+ var SpanObjectTypeV1 = /* @__PURE__ */ ((SpanObjectTypeV12) => {
1476
+ SpanObjectTypeV12[SpanObjectTypeV12["EXPERIMENT"] = 1] = "EXPERIMENT";
1477
+ SpanObjectTypeV12[SpanObjectTypeV12["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
1478
+ return SpanObjectTypeV12;
1479
+ })(SpanObjectTypeV1 || {});
1480
+ var SpanObjectTypeV1EnumSchema = import_v3.z.nativeEnum(SpanObjectTypeV1);
1481
+ var SpanRowIdsV1 = class {
1482
+ rowId;
1483
+ spanId;
1484
+ rootSpanId;
1485
+ constructor(args) {
1486
+ this.rowId = args.rowId;
1487
+ this.spanId = args.spanId;
1488
+ this.rootSpanId = args.rootSpanId;
1489
+ if (!this.rowId) {
1490
+ throw new Error("rowId must be nonempty string");
1491
+ }
1492
+ if (!this.spanId) {
1493
+ throw new Error("spanId must be nonempty string");
1494
+ }
1495
+ if (!this.rootSpanId) {
1496
+ throw new Error("rootSpanId must be nonempty string");
1497
+ }
1498
+ }
1499
+ toObject() {
1500
+ return {
1501
+ rowId: this.rowId,
1502
+ spanId: this.spanId,
1503
+ rootSpanId: this.rootSpanId
1504
+ };
1505
+ }
1506
+ };
1507
+ var SpanComponentsV1 = class _SpanComponentsV1 {
1508
+ objectType;
1509
+ objectId;
1510
+ rowIds;
1511
+ constructor(args) {
1512
+ this.objectType = args.objectType;
1513
+ this.objectId = args.objectId;
1514
+ this.rowIds = args.rowIds;
1515
+ }
1516
+ toStr() {
1517
+ const allBuffers = [];
1518
+ const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
1519
+ allBuffers.push(
1520
+ Buffer.from([
1521
+ ENCODING_VERSION_NUMBER,
1522
+ this.objectType,
1523
+ this.rowIds ? 1 : 0,
1524
+ rowIdIsUUID ? 1 : 0
1525
+ ])
1526
+ );
1527
+ const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid(
1528
+ this.objectId
1529
+ );
1530
+ if (!objectIdIsUUID) {
1531
+ throw new Error("object_id component must be a valid UUID");
1532
+ }
1533
+ allBuffers.push(objectIdBytes);
1534
+ if (this.rowIds) {
1535
+ const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid(
1536
+ this.rowIds.spanId
1537
+ );
1538
+ if (!spanIdIsUUID) {
1539
+ throw new Error("span_id component must be a valid UUID");
1540
+ }
1541
+ const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid(
1542
+ this.rowIds.rootSpanId
1543
+ );
1544
+ if (!rootSpanIdIsUUID) {
1545
+ throw new Error("root_span_id component must be a valid UUID");
1546
+ }
1547
+ allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
1548
+ }
1549
+ return Buffer.concat(allBuffers).toString("base64");
1550
+ }
1551
+ static fromStr(s) {
1552
+ try {
1553
+ const rawBytes = Buffer.from(s, "base64");
1554
+ if (rawBytes[0] !== ENCODING_VERSION_NUMBER) {
1555
+ throw new Error();
1556
+ }
1557
+ const objectType = SpanObjectTypeV1EnumSchema.parse(rawBytes[1]);
1558
+ if (![0, 1].includes(rawBytes[2])) {
1559
+ throw new Error();
1560
+ }
1561
+ if (![0, 1].includes(rawBytes[3])) {
1562
+ throw new Error();
1563
+ }
1564
+ const hasRowId = rawBytes[2] == 1;
1565
+ const rowIdIsUUID = rawBytes[3] == 1;
1566
+ const objectId = uuid.stringify(rawBytes.subarray(4, 20));
1567
+ const rowIds = (() => {
1568
+ if (!hasRowId) {
1569
+ return void 0;
1570
+ }
1571
+ const spanId = uuid.stringify(rawBytes.subarray(20, 36));
1572
+ const rootSpanId = uuid.stringify(rawBytes.subarray(36, 52));
1573
+ const rowId = rowIdIsUUID ? uuid.stringify(rawBytes.subarray(52)) : rawBytes.subarray(52).toString("utf-8");
1574
+ return new SpanRowIdsV1({ rowId, spanId, rootSpanId });
1575
+ })();
1576
+ return new _SpanComponentsV1({ objectType, objectId, rowIds });
1577
+ } catch (e) {
1578
+ throw new Error(INVALID_ENCODING_ERRMSG);
1579
+ }
1580
+ }
1581
+ objectIdFields() {
1582
+ switch (this.objectType) {
1583
+ case 1 /* EXPERIMENT */:
1584
+ return { experiment_id: this.objectId };
1585
+ case 2 /* PROJECT_LOGS */:
1586
+ return { project_id: this.objectId, log_id: "g" };
1587
+ default:
1588
+ throw new Error("Impossible");
1589
+ }
1590
+ }
1591
+ toObject() {
1592
+ return {
1593
+ objectType: this.objectType,
1594
+ objectId: this.objectId,
1595
+ rowIds: this.rowIds?.toObject()
1596
+ };
1597
+ }
1598
+ };
1599
+
1600
+ // util/span_identifier_v2.ts
1601
+ var import_v32 = require("zod/v3");
1602
+ function tryMakeUuid2(s) {
1603
+ try {
1604
+ const ret = uuid2.parse(s);
1605
+ if (ret.length !== 16) {
1606
+ throw new Error();
1607
+ }
1608
+ return { bytes: Buffer.from(ret), isUUID: true };
1609
+ } catch (e) {
1610
+ return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
1611
+ }
1612
+ }
1613
+ var ENCODING_VERSION_NUMBER2 = 2;
1614
+ var INVALID_ENCODING_ERRMSG2 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER2}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
1615
+ var INTEGER_ENCODING_NUM_BYTES = 4;
1616
+ var SpanObjectTypeV2 = /* @__PURE__ */ ((SpanObjectTypeV22) => {
1617
+ SpanObjectTypeV22[SpanObjectTypeV22["EXPERIMENT"] = 1] = "EXPERIMENT";
1618
+ SpanObjectTypeV22[SpanObjectTypeV22["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
1619
+ return SpanObjectTypeV22;
1620
+ })(SpanObjectTypeV2 || {});
1621
+ var SpanObjectTypeV2EnumSchema = import_v32.z.nativeEnum(SpanObjectTypeV2);
1622
+ var SpanRowIdsV2 = class {
1623
+ rowId;
1624
+ spanId;
1625
+ rootSpanId;
1626
+ constructor(args) {
1627
+ this.rowId = args.rowId;
1628
+ this.spanId = args.spanId;
1629
+ this.rootSpanId = args.rootSpanId;
1630
+ if (!this.rowId) {
1631
+ throw new Error("rowId must be nonempty string");
1632
+ }
1633
+ if (!this.spanId) {
1634
+ throw new Error("spanId must be nonempty string");
1635
+ }
1636
+ if (!this.rootSpanId) {
1637
+ throw new Error("rootSpanId must be nonempty string");
1638
+ }
1639
+ }
1640
+ toObject() {
1641
+ return {
1642
+ rowId: this.rowId,
1643
+ spanId: this.spanId,
1644
+ rootSpanId: this.rootSpanId
1645
+ };
1646
+ }
1647
+ };
1648
+ var SpanComponentsV2 = class _SpanComponentsV2 {
1649
+ objectType;
1650
+ objectId;
1651
+ computeObjectMetadataArgs;
1652
+ rowIds;
1653
+ constructor(args) {
1654
+ this.objectType = args.objectType;
1655
+ this.objectId = args.objectId;
1656
+ this.computeObjectMetadataArgs = args.computeObjectMetadataArgs;
1657
+ this.rowIds = args.rowIds;
1658
+ if (!(this.objectId || this.computeObjectMetadataArgs)) {
1659
+ throw new Error(
1660
+ "Must provide either objectId or computeObjectMetadataArgs"
1661
+ );
1662
+ }
1663
+ }
1664
+ toStr() {
1665
+ const allBuffers = [];
1666
+ const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid2(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
1667
+ allBuffers.push(
1668
+ Buffer.from([
1669
+ ENCODING_VERSION_NUMBER2,
1670
+ this.objectType,
1671
+ this.objectId ? 1 : 0,
1672
+ this.computeObjectMetadataArgs ? 1 : 0,
1673
+ this.rowIds ? 1 : 0,
1674
+ rowIdIsUUID ? 1 : 0
1675
+ ])
1676
+ );
1677
+ if (this.objectId) {
1678
+ const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid2(
1679
+ this.objectId
1680
+ );
1681
+ if (!objectIdIsUUID) {
1682
+ throw new Error("object_id component must be a valid UUID");
1683
+ }
1684
+ allBuffers.push(objectIdBytes);
1685
+ }
1686
+ if (this.computeObjectMetadataArgs) {
1687
+ const computeObjectMetadataBytes = Buffer.from(
1688
+ JSON.stringify(this.computeObjectMetadataArgs),
1689
+ "utf-8"
1690
+ );
1691
+ const serializedLenBytes = Buffer.alloc(INTEGER_ENCODING_NUM_BYTES);
1692
+ serializedLenBytes.writeInt32BE(computeObjectMetadataBytes.length);
1693
+ allBuffers.push(serializedLenBytes, computeObjectMetadataBytes);
1694
+ }
1695
+ if (this.rowIds) {
1696
+ const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid2(
1697
+ this.rowIds.spanId
1698
+ );
1699
+ if (!spanIdIsUUID) {
1700
+ throw new Error("span_id component must be a valid UUID");
1701
+ }
1702
+ const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid2(
1703
+ this.rowIds.rootSpanId
1704
+ );
1705
+ if (!rootSpanIdIsUUID) {
1706
+ throw new Error("root_span_id component must be a valid UUID");
1707
+ }
1708
+ allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
1709
+ }
1710
+ return Buffer.concat(allBuffers).toString("base64");
1711
+ }
1712
+ static fromStr(s) {
1713
+ try {
1714
+ const rawBytes = Buffer.from(s, "base64");
1715
+ if (rawBytes[0] < ENCODING_VERSION_NUMBER2) {
1716
+ const spanComponentsOld = SpanComponentsV1.fromStr(s);
1717
+ return new _SpanComponentsV2({
1718
+ objectType: SpanObjectTypeV2EnumSchema.parse(
1719
+ spanComponentsOld.objectType
1720
+ ),
1721
+ objectId: spanComponentsOld.objectId,
1722
+ rowIds: spanComponentsOld.rowIds ? new SpanRowIdsV2({
1723
+ rowId: spanComponentsOld.rowIds.rowId,
1724
+ spanId: spanComponentsOld.rowIds.spanId,
1725
+ rootSpanId: spanComponentsOld.rowIds.rootSpanId
1726
+ }) : void 0
1727
+ });
1728
+ }
1729
+ if (rawBytes[0] !== ENCODING_VERSION_NUMBER2) {
1730
+ throw new Error();
1731
+ }
1732
+ const objectType = SpanObjectTypeV2EnumSchema.parse(rawBytes[1]);
1733
+ for (let i = 2; i < 6; ++i) {
1734
+ if (![0, 1].includes(rawBytes[i])) {
1735
+ throw new Error();
1736
+ }
1737
+ }
1738
+ const hasObjectId = rawBytes[2] == 1;
1739
+ const hasComputeObjectMetadataArgs = rawBytes[3] == 1;
1740
+ const hasRowId = rawBytes[4] == 1;
1741
+ const rowIdIsUUID = rawBytes[5] == 1;
1742
+ let byteCursor = 6;
1743
+ let objectId = void 0;
1744
+ if (hasObjectId) {
1745
+ const nextByteCursor = byteCursor + 16;
1746
+ objectId = uuid2.stringify(
1747
+ rawBytes.subarray(byteCursor, nextByteCursor)
1748
+ );
1749
+ byteCursor = nextByteCursor;
1750
+ }
1751
+ let computeObjectMetadataArgs;
1752
+ if (hasComputeObjectMetadataArgs) {
1753
+ let nextByteCursor = byteCursor + INTEGER_ENCODING_NUM_BYTES;
1754
+ const serializedLenBytes = rawBytes.readInt32BE(byteCursor);
1755
+ byteCursor = nextByteCursor;
1756
+ nextByteCursor = byteCursor + serializedLenBytes;
1757
+ computeObjectMetadataArgs = JSON.parse(
1758
+ rawBytes.subarray(byteCursor, nextByteCursor).toString("utf-8")
1759
+ );
1760
+ byteCursor = nextByteCursor;
1761
+ }
1762
+ const rowIds = (() => {
1763
+ if (!hasRowId) {
1764
+ return void 0;
1765
+ }
1766
+ let nextByteCursor = byteCursor + 16;
1767
+ const spanId = uuid2.stringify(
1768
+ rawBytes.subarray(byteCursor, nextByteCursor)
1769
+ );
1770
+ byteCursor = nextByteCursor;
1771
+ nextByteCursor = byteCursor + 16;
1772
+ const rootSpanId = uuid2.stringify(
1773
+ rawBytes.subarray(byteCursor, nextByteCursor)
1774
+ );
1775
+ byteCursor = nextByteCursor;
1776
+ const rowId = rowIdIsUUID ? uuid2.stringify(rawBytes.subarray(byteCursor)) : rawBytes.subarray(byteCursor).toString("utf-8");
1777
+ return new SpanRowIdsV2({ rowId, spanId, rootSpanId });
1778
+ })();
1779
+ return new _SpanComponentsV2({
1780
+ objectType,
1781
+ objectId,
1782
+ computeObjectMetadataArgs,
1783
+ rowIds
1784
+ });
1785
+ } catch (e) {
1786
+ throw new Error(INVALID_ENCODING_ERRMSG2);
1787
+ }
1788
+ }
1789
+ objectIdFields() {
1790
+ if (!this.objectId) {
1791
+ throw new Error(
1792
+ "Impossible: cannot invoke `object_id_fields` unless SpanComponentsV2 is initialized with an `object_id`"
1793
+ );
1794
+ }
1795
+ switch (this.objectType) {
1796
+ case 1 /* EXPERIMENT */:
1797
+ return { experiment_id: this.objectId };
1798
+ case 2 /* PROJECT_LOGS */:
1799
+ return { project_id: this.objectId, log_id: "g" };
1800
+ default:
1801
+ throw new Error("Impossible");
1802
+ }
1803
+ }
1804
+ toObject() {
1805
+ return {
1806
+ objectType: this.objectType,
1807
+ objectId: this.objectId,
1808
+ computeObjectMetadataArgs: this.computeObjectMetadataArgs,
1809
+ rowIds: this.rowIds?.toObject()
1810
+ };
1811
+ }
1812
+ };
1813
+
1814
+ // util/span_identifier_v3.ts
1815
+ var import_v33 = require("zod/v3");
1816
+
1817
+ // util/bytes.ts
1818
+ function concatUint8Arrays(...arrays) {
1819
+ const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
1820
+ const result = new Uint8Array(totalLength);
1821
+ let offset = 0;
1822
+ for (const arr of arrays) {
1823
+ result.set(arr, offset);
1824
+ offset += arr.length;
1825
+ }
1826
+ return result;
1827
+ }
1828
+ function uint8ArrayToBase64(uint8Array) {
1829
+ let binary = "";
1830
+ for (let i = 0; i < uint8Array.length; i++) {
1831
+ binary += String.fromCharCode(uint8Array[i]);
1832
+ }
1833
+ return btoa(binary);
1834
+ }
1835
+ function base64ToUint8Array(base64) {
1836
+ const binary = atob(base64);
1837
+ const uint8Array = new Uint8Array(binary.length);
1838
+ for (let i = 0; i < binary.length; i++) {
1839
+ uint8Array[i] = binary.charCodeAt(i);
1840
+ }
1841
+ return uint8Array;
1842
+ }
1843
+ function uint8ArrayToString(uint8Array) {
1844
+ const decoder = new TextDecoder("utf-8");
1845
+ return decoder.decode(uint8Array);
1846
+ }
1847
+ function stringToUint8Array(str) {
1848
+ const encoder = new TextEncoder();
1849
+ return encoder.encode(str);
1850
+ }
1851
+
1852
+ // util/span_identifier_v3.ts
1853
+ function tryMakeUuid3(s) {
1854
+ try {
1855
+ const ret = uuid3.parse(s);
1856
+ if (ret.length !== 16) {
1857
+ throw new Error();
1858
+ }
1859
+ return { bytes: new Uint8Array(ret), isUUID: true };
1860
+ } catch {
1861
+ return { bytes: void 0, isUUID: false };
1862
+ }
1863
+ }
1864
+ var ENCODING_VERSION_NUMBER3 = 3;
1865
+ var INVALID_ENCODING_ERRMSG3 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER3}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
1866
+ var SpanObjectTypeV3 = /* @__PURE__ */ ((SpanObjectTypeV32) => {
1867
+ SpanObjectTypeV32[SpanObjectTypeV32["EXPERIMENT"] = 1] = "EXPERIMENT";
1868
+ SpanObjectTypeV32[SpanObjectTypeV32["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
1869
+ SpanObjectTypeV32[SpanObjectTypeV32["PLAYGROUND_LOGS"] = 3] = "PLAYGROUND_LOGS";
1870
+ return SpanObjectTypeV32;
1871
+ })(SpanObjectTypeV3 || {});
1872
+ var spanObjectTypeV3EnumSchema = import_v33.z.nativeEnum(SpanObjectTypeV3);
1873
+ function spanObjectTypeV3ToString(objectType) {
1874
+ switch (objectType) {
1875
+ case 1 /* EXPERIMENT */:
1876
+ return "experiment";
1877
+ case 2 /* PROJECT_LOGS */:
1878
+ return "project_logs";
1879
+ case 3 /* PLAYGROUND_LOGS */:
1880
+ return "playground_logs";
1881
+ default:
1882
+ const x = objectType;
1883
+ throw new Error(`Unknown SpanObjectTypeV3: ${x}`);
1884
+ }
1885
+ }
1886
+ var InternalSpanComponentUUIDFields = /* @__PURE__ */ ((InternalSpanComponentUUIDFields2) => {
1887
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["OBJECT_ID"] = 1] = "OBJECT_ID";
1888
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROW_ID"] = 2] = "ROW_ID";
1889
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["SPAN_ID"] = 3] = "SPAN_ID";
1890
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROOT_SPAN_ID"] = 4] = "ROOT_SPAN_ID";
1891
+ return InternalSpanComponentUUIDFields2;
1892
+ })(InternalSpanComponentUUIDFields || {});
1893
+ var internalSpanComponentUUIDFieldsEnumSchema = import_v33.z.nativeEnum(
1894
+ InternalSpanComponentUUIDFields
1895
+ );
1896
+ var _INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME = {
1897
+ [1 /* OBJECT_ID */]: "object_id",
1898
+ [2 /* ROW_ID */]: "row_id",
1899
+ [3 /* SPAN_ID */]: "span_id",
1900
+ [4 /* ROOT_SPAN_ID */]: "root_span_id"
1901
+ };
1902
+ var spanComponentsV3Schema = import_v33.z.object({
1903
+ object_type: spanObjectTypeV3EnumSchema,
1904
+ // TODO(manu): We should have a more elaborate zod schema for
1905
+ // `propagated_event`. This will required zod-ifying the contents of
1906
+ // sdk/js/util/object.ts.
1907
+ propagated_event: import_v33.z.record(import_v33.z.unknown()).nullish()
1908
+ }).and(
1909
+ import_v33.z.union([
1910
+ // Must provide one or the other.
1911
+ import_v33.z.object({
1912
+ object_id: import_v33.z.string().nullish(),
1913
+ compute_object_metadata_args: import_v33.z.optional(import_v33.z.null())
1914
+ }),
1915
+ import_v33.z.object({
1916
+ object_id: import_v33.z.optional(import_v33.z.null()),
1917
+ compute_object_metadata_args: import_v33.z.record(import_v33.z.unknown())
1918
+ })
1919
+ ])
1920
+ ).and(
1921
+ import_v33.z.union([
1922
+ // Either all of these must be provided or none.
1923
+ import_v33.z.object({
1924
+ row_id: import_v33.z.string(),
1925
+ span_id: import_v33.z.string(),
1926
+ root_span_id: import_v33.z.string()
1927
+ }),
1928
+ import_v33.z.object({
1929
+ row_id: import_v33.z.optional(import_v33.z.null()),
1930
+ span_id: import_v33.z.optional(import_v33.z.null()),
1931
+ root_span_id: import_v33.z.optional(import_v33.z.null())
1932
+ })
1933
+ ])
1934
+ );
1935
+ var SpanComponentsV3 = class _SpanComponentsV3 {
1936
+ constructor(data) {
1937
+ this.data = data;
1938
+ }
1939
+ toStr() {
1940
+ const jsonObj = {
1941
+ compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
1942
+ propagated_event: this.data.propagated_event || void 0
1943
+ };
1944
+ const allBuffers = [];
1945
+ allBuffers.push(
1946
+ new Uint8Array([ENCODING_VERSION_NUMBER3, this.data.object_type])
1947
+ );
1948
+ const uuidEntries = [];
1949
+ function addUuidField(origVal, fieldId) {
1950
+ const ret = tryMakeUuid3(origVal);
1951
+ if (ret.isUUID) {
1952
+ uuidEntries.push(
1953
+ concatUint8Arrays(new Uint8Array([fieldId]), ret.bytes)
1954
+ );
1955
+ } else {
1956
+ jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = origVal;
1957
+ }
1958
+ }
1959
+ if (this.data.object_id) {
1960
+ addUuidField(
1961
+ this.data.object_id,
1962
+ 1 /* OBJECT_ID */
1963
+ );
1964
+ }
1965
+ if (this.data.row_id) {
1966
+ addUuidField(this.data.row_id, 2 /* ROW_ID */);
1967
+ }
1968
+ if (this.data.span_id) {
1969
+ addUuidField(this.data.span_id, 3 /* SPAN_ID */);
1970
+ }
1971
+ if (this.data.root_span_id) {
1972
+ addUuidField(
1973
+ this.data.root_span_id,
1974
+ 4 /* ROOT_SPAN_ID */
1975
+ );
1976
+ }
1977
+ if (uuidEntries.length > 255) {
1978
+ throw new Error("Impossible: too many UUID entries to encode");
1979
+ }
1980
+ allBuffers.push(new Uint8Array([uuidEntries.length]));
1981
+ allBuffers.push(...uuidEntries);
1982
+ if (Object.keys(jsonObj).length > 0) {
1983
+ allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
1984
+ }
1985
+ return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
1986
+ }
1987
+ static fromStr(s) {
1988
+ try {
1989
+ const rawBytes = base64ToUint8Array(s);
1990
+ const jsonObj = {};
1991
+ if (rawBytes[0] < ENCODING_VERSION_NUMBER3) {
1992
+ const spanComponentsOld = SpanComponentsV2.fromStr(s);
1993
+ jsonObj["object_type"] = spanComponentsOld.objectType;
1994
+ jsonObj["object_id"] = spanComponentsOld.objectId;
1995
+ jsonObj["compute_object_metadata_args"] = spanComponentsOld.computeObjectMetadataArgs;
1996
+ if (spanComponentsOld.rowIds) {
1997
+ jsonObj["row_id"] = spanComponentsOld.rowIds.rowId;
1998
+ jsonObj["span_id"] = spanComponentsOld.rowIds.spanId;
1999
+ jsonObj["root_span_id"] = spanComponentsOld.rowIds.rootSpanId;
2000
+ }
2001
+ } else {
2002
+ jsonObj["object_type"] = rawBytes[1];
2003
+ const numUuidEntries = rawBytes[2];
2004
+ let byteOffset = 3;
2005
+ for (let i = 0; i < numUuidEntries; ++i) {
2006
+ const fieldId = internalSpanComponentUUIDFieldsEnumSchema.parse(
2007
+ rawBytes[byteOffset]
2008
+ );
2009
+ const fieldBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
2010
+ byteOffset += 17;
2011
+ jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = uuid3.stringify(fieldBytes);
2012
+ }
2013
+ if (byteOffset < rawBytes.length) {
2014
+ const remainingJsonObj = JSON.parse(
2015
+ uint8ArrayToString(rawBytes.subarray(byteOffset))
2016
+ );
2017
+ Object.assign(jsonObj, remainingJsonObj);
2018
+ }
2019
+ }
2020
+ return _SpanComponentsV3.fromJsonObj(jsonObj);
2021
+ } catch {
2022
+ throw new Error(INVALID_ENCODING_ERRMSG3);
2023
+ }
2024
+ }
2025
+ objectIdFields() {
2026
+ if (!this.data.object_id) {
2027
+ throw new Error(
2028
+ "Impossible: cannot invoke `objectIdFields` unless SpanComponentsV3 is initialized with an `object_id`"
2029
+ );
2030
+ }
2031
+ switch (this.data.object_type) {
2032
+ case 1 /* EXPERIMENT */:
2033
+ return { experiment_id: this.data.object_id };
2034
+ case 2 /* PROJECT_LOGS */:
2035
+ return { project_id: this.data.object_id, log_id: "g" };
2036
+ case 3 /* PLAYGROUND_LOGS */:
2037
+ return { prompt_session_id: this.data.object_id, log_id: "x" };
2038
+ default:
2039
+ const _ = this.data.object_type;
2040
+ throw new Error("Impossible");
2041
+ }
2042
+ }
2043
+ async export() {
2044
+ return this.toStr();
2045
+ }
2046
+ static fromJsonObj(jsonObj) {
2047
+ return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
2048
+ }
2049
+ };
2050
+ function parseParent(parent) {
2051
+ return typeof parent === "string" ? parent : parent ? new SpanComponentsV3({
2052
+ object_type: parent.object_type === "experiment" ? 1 /* EXPERIMENT */ : parent.object_type === "playground_logs" ? 3 /* PLAYGROUND_LOGS */ : 2 /* PROJECT_LOGS */,
2053
+ object_id: parent.object_id,
2054
+ ...parent.row_ids ? {
2055
+ row_id: parent.row_ids.id,
2056
+ span_id: parent.row_ids.span_id,
2057
+ root_span_id: parent.row_ids.root_span_id
2058
+ } : {
2059
+ row_id: void 0,
2060
+ span_id: void 0,
2061
+ root_span_id: void 0
2062
+ },
2063
+ propagated_event: parent.propagated_event
2064
+ }).toStr() : void 0;
2065
+ }
2066
+
2067
+ // util/http_headers.ts
2068
+ var BT_FOUND_EXISTING_HEADER = "x-bt-found-existing";
2069
+ var BT_CURSOR_HEADER = "x-bt-cursor";
2070
+
2071
+ // util/type_util.ts
2072
+ function isObject(value) {
2073
+ return value instanceof Object && !(value instanceof Array);
2074
+ }
2075
+ function isArray(value) {
2076
+ return value instanceof Array;
2077
+ }
2078
+ function isObjectOrArray(value) {
2079
+ return value instanceof Object;
2080
+ }
2081
+ function isEmpty(a) {
2082
+ return a === void 0 || a === null;
2083
+ }
2084
+
2085
+ // util/object_util.ts
2086
+ function mergeDictsWithPaths({
2087
+ mergeInto,
2088
+ mergeFrom,
2089
+ mergePaths
2090
+ }) {
2091
+ const mergePathsSerialized = new Set(
2092
+ mergePaths.map((p) => JSON.stringify(p))
2093
+ );
2094
+ return mergeDictsWithPathsHelper({
2095
+ mergeInto,
2096
+ mergeFrom,
2097
+ path: [],
2098
+ mergePaths: mergePathsSerialized
2099
+ });
2100
+ }
2101
+ function mergeDictsWithPathsHelper({
2102
+ mergeInto,
2103
+ mergeFrom,
2104
+ path: path9,
2105
+ mergePaths
2106
+ }) {
2107
+ Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
2108
+ const fullPath = path9.concat([k]);
2109
+ const fullPathSerialized = JSON.stringify(fullPath);
2110
+ const mergeIntoV = recordFind(mergeInto, k);
2111
+ if (isObject(mergeIntoV) && isObject(mergeFromV) && !mergePaths.has(fullPathSerialized)) {
2112
+ mergeDictsWithPathsHelper({
2113
+ mergeInto: mergeIntoV,
2114
+ mergeFrom: mergeFromV,
2115
+ path: fullPath,
2116
+ mergePaths
2117
+ });
2118
+ } else {
2119
+ mergeInto[k] = mergeFromV;
2120
+ }
2121
+ });
2122
+ return mergeInto;
2123
+ }
2124
+ function mergeDicts(mergeInto, mergeFrom) {
2125
+ return mergeDictsWithPaths({ mergeInto, mergeFrom, mergePaths: [] });
2126
+ }
2127
+ function mapAt(m, k) {
2128
+ const ret = m.get(k);
2129
+ if (ret === void 0) {
2130
+ throw new Error(`Map does not contain key ${k}`);
2131
+ }
2132
+ return ret;
2133
+ }
2134
+ function recordFind(m, k) {
2135
+ return m[k];
2136
+ }
2137
+ function getObjValueByPath(row, path9) {
2138
+ let curr = row;
2139
+ for (const p of path9) {
2140
+ if (!isObjectOrArray(curr)) {
2141
+ return null;
2142
+ }
2143
+ curr = curr[p];
2144
+ }
2145
+ return curr;
2146
+ }
2147
+
2148
+ // util/graph_util.ts
2149
+ function depthFirstSearch(args) {
2150
+ const { graph, firstVisitF, lastVisitF } = args;
2151
+ for (const vs of graph.values()) {
2152
+ for (const v of vs.values()) {
2153
+ if (!graph.has(v)) {
2154
+ throw new Error(`Outgoing vertex ${v} must be a key in the graph`);
2155
+ }
2156
+ }
2157
+ }
2158
+ const firstVisitedVertices = /* @__PURE__ */ new Set();
2159
+ const visitationOrder = args.visitationOrder ?? [...graph.keys()];
2160
+ const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
2161
+ while (events.length) {
2162
+ const { eventType, vertex, extras } = events.pop();
2163
+ if (eventType === "last") {
2164
+ lastVisitF?.(vertex);
2165
+ continue;
2166
+ }
2167
+ if (firstVisitedVertices.has(vertex)) {
2168
+ continue;
2169
+ }
2170
+ firstVisitedVertices.add(vertex);
2171
+ firstVisitF?.(vertex, { parentVertex: extras.parentVertex });
2172
+ events.push({ eventType: "last", vertex, extras: {} });
2173
+ mapAt(graph, vertex).forEach((child) => {
2174
+ events.push({
2175
+ eventType: "first",
2176
+ vertex: child,
2177
+ extras: { parentVertex: vertex }
2178
+ });
2179
+ });
2180
+ }
2181
+ }
2182
+ function undirectedConnectedComponents(graph) {
2183
+ const directedGraph = new Map(
2184
+ [...graph.vertices].map((v) => [v, /* @__PURE__ */ new Set()])
2185
+ );
2186
+ for (const [i, j] of graph.edges) {
2187
+ mapAt(directedGraph, i).add(j);
2188
+ mapAt(directedGraph, j).add(i);
2189
+ }
2190
+ let labelCounter = 0;
2191
+ const vertexLabels = /* @__PURE__ */ new Map();
2192
+ const firstVisitF = (vertex, args) => {
2193
+ const label = args?.parentVertex !== void 0 ? mapAt(vertexLabels, args?.parentVertex) : labelCounter++;
2194
+ vertexLabels.set(vertex, label);
2195
+ };
2196
+ depthFirstSearch({ graph: directedGraph, firstVisitF });
2197
+ const output = Array.from({ length: labelCounter }).map(() => []);
2198
+ for (const [vertex, label] of vertexLabels.entries()) {
2199
+ output[label].push(vertex);
2200
+ }
2201
+ return output;
2202
+ }
2203
+ function topologicalSort(graph, visitationOrder) {
2204
+ const reverseOrdering = [];
2205
+ const lastVisitF = (vertex) => {
2206
+ reverseOrdering.push(vertex);
2207
+ };
2208
+ depthFirstSearch({ graph, lastVisitF, visitationOrder });
2209
+ return reverseOrdering.reverse();
2210
+ }
2211
+
2212
+ // util/merge_row_batch.ts
2213
+ function generateMergedRowKey(row, useParentIdForId) {
2214
+ return JSON.stringify(
2215
+ [
2216
+ "org_id",
2217
+ "project_id",
2218
+ "experiment_id",
2219
+ "dataset_id",
2220
+ "prompt_session_id",
2221
+ "log_id",
2222
+ useParentIdForId ?? false ? PARENT_ID_FIELD : "id"
2223
+ ].map((k) => row[k])
2224
+ );
2225
+ }
2226
+ var MERGE_ROW_SKIP_FIELDS = [
2227
+ "created",
2228
+ "span_id",
2229
+ "root_span_id",
2230
+ "span_parents",
2231
+ "_parent_id"
2232
+ // TODO: handle merge paths.
2233
+ ];
2234
+ function popMergeRowSkipFields(row) {
2235
+ const popped = {};
2236
+ for (const field of MERGE_ROW_SKIP_FIELDS) {
2237
+ if (field in row) {
2238
+ popped[field] = row[field];
2239
+ delete row[field];
2240
+ }
2241
+ }
2242
+ return popped;
2243
+ }
2244
+ function restoreMergeRowSkipFields(row, skipFields) {
2245
+ for (const field of MERGE_ROW_SKIP_FIELDS) {
2246
+ delete row[field];
2247
+ if (field in skipFields) {
2248
+ row[field] = skipFields[field];
2249
+ }
2250
+ }
2251
+ }
2252
+ function mergeRowBatch(rows) {
2253
+ for (const row of rows) {
2254
+ if (row.id === void 0) {
2255
+ throw new Error(
2256
+ "Logged row is missing an id. This is an internal braintrust error. Please contact us at info@braintrust.dev for help"
2257
+ );
2258
+ }
2259
+ }
2260
+ const rowGroups = /* @__PURE__ */ new Map();
2261
+ for (const row of rows) {
2262
+ const key = generateMergedRowKey(row);
2263
+ const existingRow = rowGroups.get(key);
2264
+ if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
2265
+ const skipFields = popMergeRowSkipFields(existingRow);
2266
+ const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
2267
+ mergeDicts(existingRow, row);
2268
+ restoreMergeRowSkipFields(existingRow, skipFields);
2269
+ if (preserveNoMerge) {
2270
+ delete existingRow[IS_MERGE_FIELD];
2271
+ }
2272
+ } else {
2273
+ rowGroups.set(key, row);
2274
+ }
2275
+ }
2276
+ const merged = [...rowGroups.values()];
2277
+ const rowToLabel = new Map(
2278
+ merged.map((r, i) => [generateMergedRowKey(r), i])
2279
+ );
2280
+ const graph = new Map(
2281
+ Array.from({ length: merged.length }).map((_, i) => [i, /* @__PURE__ */ new Set()])
2282
+ );
2283
+ merged.forEach((r, i) => {
2284
+ const parentId = r[PARENT_ID_FIELD];
2285
+ if (!parentId) {
2286
+ return;
2287
+ }
2288
+ const parentRowKey = generateMergedRowKey(
2289
+ r,
2290
+ true
2291
+ /* useParentIdForId */
2292
+ );
2293
+ const parentLabel = rowToLabel.get(parentRowKey);
2294
+ if (parentLabel !== void 0) {
2295
+ mapAt(graph, parentLabel).add(i);
2296
+ }
2297
+ });
2298
+ const connectedComponents = undirectedConnectedComponents({
2299
+ vertices: new Set(graph.keys()),
2300
+ edges: new Set(
2301
+ [...graph.entries()].flatMap(
2302
+ ([k, vs]) => [...vs].map((v) => {
2303
+ const ret = [k, v];
2304
+ return ret;
2305
+ })
2306
+ )
2307
+ )
2308
+ });
2309
+ const buckets = connectedComponents.map(
2310
+ (cc) => topologicalSort(
2311
+ graph,
2312
+ cc
2313
+ /* visitationOrder */
2314
+ )
2315
+ );
2316
+ return buckets.map((bucket) => bucket.map((i) => merged[i]));
2317
+ }
2318
+ function batchItems(args) {
2319
+ let { items } = args;
2320
+ const batchMaxNumItems = args.batchMaxNumItems ?? Number.POSITIVE_INFINITY;
2321
+ const batchMaxNumBytes = args.batchMaxNumBytes ?? Number.POSITIVE_INFINITY;
2322
+ const output = [];
2323
+ let nextItems = [];
2324
+ let batchSet = [];
2325
+ let batch = [];
2326
+ let batchLen = 0;
2327
+ function addToBatch(item) {
2328
+ batch.push(item);
2329
+ batchLen += item.length;
2330
+ }
2331
+ function flushBatch() {
2332
+ batchSet.push(batch);
2333
+ batch = [];
2334
+ batchLen = 0;
2335
+ }
2336
+ while (items.length) {
2337
+ for (const bucket of items) {
2338
+ let i = 0;
2339
+ for (const item of bucket) {
2340
+ if (batch.length === 0 || item.length + batchLen < batchMaxNumBytes && batch.length < batchMaxNumItems) {
2341
+ addToBatch(item);
2342
+ } else if (i === 0) {
2343
+ flushBatch();
2344
+ addToBatch(item);
2345
+ } else {
2346
+ break;
2347
+ }
2348
+ ++i;
2349
+ }
2350
+ if (i < bucket.length) {
2351
+ nextItems.push(bucket.slice(i));
2352
+ }
2353
+ if (batchLen >= batchMaxNumBytes || batch.length > batchMaxNumItems) {
2354
+ flushBatch();
2355
+ }
2356
+ }
2357
+ if (batch.length) {
2358
+ flushBatch();
2359
+ }
2360
+ if (batchSet.length) {
2361
+ output.push(batchSet);
2362
+ batchSet = [];
2363
+ }
2364
+ items = nextItems;
2365
+ nextItems = [];
2366
+ }
2367
+ return output;
2368
+ }
2369
+
2370
+ // util/object.ts
2371
+ var DEFAULT_IS_LEGACY_DATASET = false;
2372
+ function ensureDatasetRecord(r, legacy) {
2373
+ if (legacy) {
2374
+ return ensureLegacyDatasetRecord(r);
2375
+ } else {
2376
+ return ensureNewDatasetRecord(r);
2377
+ }
2378
+ }
2379
+ function ensureLegacyDatasetRecord(r) {
2380
+ if ("output" in r) {
2381
+ return r;
2382
+ }
2383
+ const row = {
2384
+ ...r,
2385
+ output: r.expected
2386
+ };
2387
+ delete row.expected;
2388
+ return row;
2389
+ }
2390
+ function ensureNewDatasetRecord(r) {
2391
+ if ("expected" in r) {
2392
+ return r;
2393
+ }
2394
+ const row = {
2395
+ ...r,
2396
+ tags: null,
2397
+ expected: r.output
2398
+ };
2399
+ delete row.output;
2400
+ return row;
2401
+ }
2402
+
2403
+ // util/json_util.ts
2404
+ function constructJsonArray(items) {
2405
+ return `[${items.join(",")}]`;
2406
+ }
2407
+
2408
+ // util/string_util.ts
2409
+ function _urljoin(...parts) {
2410
+ return parts.map(
2411
+ (x, i) => x.replace(/^\//, "").replace(i < parts.length - 1 ? /\/$/ : "", "")
2412
+ ).filter((x) => x.trim() !== "").join("/");
2413
+ }
2414
+ function capitalize(s, sep) {
2415
+ const items = sep ? s.split(sep) : [s];
2416
+ return items.map((s2) => s2 ? s2.charAt(0).toUpperCase() + s2.slice(1) : s2).join(sep || "");
2417
+ }
2418
+
2419
+ // util/git_fields.ts
2420
+ function mergeGitMetadataSettings(s1, s2) {
2421
+ if (s1.collect === "all") {
2422
+ return s2;
2423
+ } else if (s2.collect === "all") {
2424
+ return s1;
2425
+ } else if (s1.collect === "none") {
2426
+ return s1;
2427
+ } else if (s2.collect === "none") {
2428
+ return s2;
2429
+ }
2430
+ const fields = (s1.fields ?? []).filter((f) => (s2.fields ?? []).includes(f));
2431
+ const collect = fields.length > 0 ? "some" : "none";
2432
+ return { collect, fields };
2433
+ }
2434
+
2435
+ // util/xact-ids.ts
2436
+ var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
2437
+ var MOD = BigInt(1) << BigInt(64);
2438
+ var COPRIME = BigInt("205891132094649");
2439
+ var COPRIME_INVERSE = BigInt("1522336535492693385");
2440
+ function modularMultiply(value, prime) {
2441
+ return value * prime % MOD;
2442
+ }
2443
+ function prettifyXact(valueString) {
2444
+ const value = BigInt(valueString);
2445
+ const encoded = modularMultiply(value, COPRIME);
2446
+ return encoded.toString(16).padStart(16, "0");
2447
+ }
2448
+ function loadPrettyXact(encodedHex) {
2449
+ if (encodedHex.length !== 16) {
2450
+ return encodedHex;
2451
+ }
2452
+ const value = BigInt(`0x${encodedHex}`);
2453
+ const multipliedInverse = modularMultiply(value, COPRIME_INVERSE);
2454
+ const withTopBits = TOP_BITS | multipliedInverse;
2455
+ return withTopBits.toString();
2456
+ }
2457
+
2458
+ // util/zod_util.ts
2459
+ var import_v34 = require("zod/v3");
1442
2460
 
1443
2461
  // src/generated_types.ts
1444
- var import_zod = require("zod");
1445
- var AclObjectType = import_zod.z.union([
1446
- import_zod.z.enum([
2462
+ var import_v35 = require("zod/v3");
2463
+ var AclObjectType = import_v35.z.union([
2464
+ import_v35.z.enum([
1447
2465
  "organization",
1448
2466
  "project",
1449
2467
  "experiment",
@@ -1456,9 +2474,9 @@ var AclObjectType = import_zod.z.union([
1456
2474
  "project_log",
1457
2475
  "org_project"
1458
2476
  ]),
1459
- import_zod.z.null()
2477
+ import_v35.z.null()
1460
2478
  ]);
1461
- var Permission = import_zod.z.enum([
2479
+ var Permission = import_v35.z.enum([
1462
2480
  "create",
1463
2481
  "read",
1464
2482
  "update",
@@ -1468,310 +2486,310 @@ var Permission = import_zod.z.enum([
1468
2486
  "update_acls",
1469
2487
  "delete_acls"
1470
2488
  ]);
1471
- var Acl = import_zod.z.object({
1472
- id: import_zod.z.string().uuid(),
1473
- object_type: AclObjectType.and(import_zod.z.string()),
1474
- object_id: import_zod.z.string().uuid(),
1475
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1476
- group_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1477
- permission: Permission.and(import_zod.z.union([import_zod.z.string(), import_zod.z.null()])).optional(),
1478
- restrict_object_type: AclObjectType.and(import_zod.z.unknown()).optional(),
1479
- role_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1480
- _object_org_id: import_zod.z.string().uuid(),
1481
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
2489
+ var Acl = import_v35.z.object({
2490
+ id: import_v35.z.string().uuid(),
2491
+ object_type: AclObjectType.and(import_v35.z.string()),
2492
+ object_id: import_v35.z.string().uuid(),
2493
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2494
+ group_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2495
+ permission: Permission.and(import_v35.z.union([import_v35.z.string(), import_v35.z.null()])).optional(),
2496
+ restrict_object_type: AclObjectType.and(import_v35.z.unknown()).optional(),
2497
+ role_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2498
+ _object_org_id: import_v35.z.string().uuid(),
2499
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
1482
2500
  });
1483
- var AISecret = import_zod.z.object({
1484
- id: import_zod.z.string().uuid(),
1485
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1486
- updated_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1487
- org_id: import_zod.z.string().uuid(),
1488
- name: import_zod.z.string(),
1489
- type: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1490
- metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional(),
1491
- preview_secret: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
2501
+ var AISecret = import_v35.z.object({
2502
+ id: import_v35.z.string().uuid(),
2503
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2504
+ updated_at: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2505
+ org_id: import_v35.z.string().uuid(),
2506
+ name: import_v35.z.string(),
2507
+ type: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2508
+ metadata: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]).optional(),
2509
+ preview_secret: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
1492
2510
  });
1493
- var ResponseFormatJsonSchema = import_zod.z.object({
1494
- name: import_zod.z.string(),
1495
- description: import_zod.z.string().optional(),
1496
- schema: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.string()]).optional(),
1497
- strict: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
2511
+ var ResponseFormatJsonSchema = import_v35.z.object({
2512
+ name: import_v35.z.string(),
2513
+ description: import_v35.z.string().optional(),
2514
+ schema: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.string()]).optional(),
2515
+ strict: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional()
1498
2516
  });
1499
- var ResponseFormatNullish = import_zod.z.union([
1500
- import_zod.z.object({ type: import_zod.z.literal("json_object") }),
1501
- import_zod.z.object({
1502
- type: import_zod.z.literal("json_schema"),
2517
+ var ResponseFormatNullish = import_v35.z.union([
2518
+ import_v35.z.object({ type: import_v35.z.literal("json_object") }),
2519
+ import_v35.z.object({
2520
+ type: import_v35.z.literal("json_schema"),
1503
2521
  json_schema: ResponseFormatJsonSchema
1504
2522
  }),
1505
- import_zod.z.object({ type: import_zod.z.literal("text") }),
1506
- import_zod.z.null()
2523
+ import_v35.z.object({ type: import_v35.z.literal("text") }),
2524
+ import_v35.z.null()
1507
2525
  ]);
1508
- var AnyModelParams = import_zod.z.object({
1509
- temperature: import_zod.z.number().optional(),
1510
- top_p: import_zod.z.number().optional(),
1511
- max_tokens: import_zod.z.number(),
1512
- max_completion_tokens: import_zod.z.number().optional(),
1513
- frequency_penalty: import_zod.z.number().optional(),
1514
- presence_penalty: import_zod.z.number().optional(),
2526
+ var AnyModelParams = import_v35.z.object({
2527
+ temperature: import_v35.z.number().optional(),
2528
+ top_p: import_v35.z.number().optional(),
2529
+ max_tokens: import_v35.z.number(),
2530
+ max_completion_tokens: import_v35.z.number().optional(),
2531
+ frequency_penalty: import_v35.z.number().optional(),
2532
+ presence_penalty: import_v35.z.number().optional(),
1515
2533
  response_format: ResponseFormatNullish.optional(),
1516
- tool_choice: import_zod.z.union([
1517
- import_zod.z.literal("auto"),
1518
- import_zod.z.literal("none"),
1519
- import_zod.z.literal("required"),
1520
- import_zod.z.object({
1521
- type: import_zod.z.literal("function"),
1522
- function: import_zod.z.object({ name: import_zod.z.string() })
2534
+ tool_choice: import_v35.z.union([
2535
+ import_v35.z.literal("auto"),
2536
+ import_v35.z.literal("none"),
2537
+ import_v35.z.literal("required"),
2538
+ import_v35.z.object({
2539
+ type: import_v35.z.literal("function"),
2540
+ function: import_v35.z.object({ name: import_v35.z.string() })
1523
2541
  })
1524
2542
  ]).optional(),
1525
- function_call: import_zod.z.union([
1526
- import_zod.z.literal("auto"),
1527
- import_zod.z.literal("none"),
1528
- import_zod.z.object({ name: import_zod.z.string() })
2543
+ function_call: import_v35.z.union([
2544
+ import_v35.z.literal("auto"),
2545
+ import_v35.z.literal("none"),
2546
+ import_v35.z.object({ name: import_v35.z.string() })
1529
2547
  ]).optional(),
1530
- n: import_zod.z.number().optional(),
1531
- stop: import_zod.z.array(import_zod.z.string()).optional(),
1532
- reasoning_effort: import_zod.z.enum(["minimal", "low", "medium", "high"]).optional(),
1533
- verbosity: import_zod.z.enum(["low", "medium", "high"]).optional(),
1534
- top_k: import_zod.z.number().optional(),
1535
- stop_sequences: import_zod.z.array(import_zod.z.string()).optional(),
1536
- max_tokens_to_sample: import_zod.z.number().optional(),
1537
- maxOutputTokens: import_zod.z.number().optional(),
1538
- topP: import_zod.z.number().optional(),
1539
- topK: import_zod.z.number().optional(),
1540
- use_cache: import_zod.z.boolean().optional()
2548
+ n: import_v35.z.number().optional(),
2549
+ stop: import_v35.z.array(import_v35.z.string()).optional(),
2550
+ reasoning_effort: import_v35.z.enum(["minimal", "low", "medium", "high"]).optional(),
2551
+ verbosity: import_v35.z.enum(["low", "medium", "high"]).optional(),
2552
+ top_k: import_v35.z.number().optional(),
2553
+ stop_sequences: import_v35.z.array(import_v35.z.string()).optional(),
2554
+ max_tokens_to_sample: import_v35.z.number().optional(),
2555
+ maxOutputTokens: import_v35.z.number().optional(),
2556
+ topP: import_v35.z.number().optional(),
2557
+ topK: import_v35.z.number().optional(),
2558
+ use_cache: import_v35.z.boolean().optional()
1541
2559
  });
1542
- var ApiKey = import_zod.z.object({
1543
- id: import_zod.z.string().uuid(),
1544
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1545
- name: import_zod.z.string(),
1546
- preview_name: import_zod.z.string(),
1547
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1548
- user_email: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1549
- user_given_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1550
- user_family_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1551
- org_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
2560
+ var ApiKey = import_v35.z.object({
2561
+ id: import_v35.z.string().uuid(),
2562
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2563
+ name: import_v35.z.string(),
2564
+ preview_name: import_v35.z.string(),
2565
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2566
+ user_email: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2567
+ user_given_name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2568
+ user_family_name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2569
+ org_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
1552
2570
  });
1553
- var AsyncScoringState = import_zod.z.union([
1554
- import_zod.z.object({
1555
- status: import_zod.z.literal("enabled"),
1556
- token: import_zod.z.string(),
1557
- function_ids: import_zod.z.array(import_zod.z.unknown()).min(1),
1558
- skip_logging: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
2571
+ var AsyncScoringState = import_v35.z.union([
2572
+ import_v35.z.object({
2573
+ status: import_v35.z.literal("enabled"),
2574
+ token: import_v35.z.string(),
2575
+ function_ids: import_v35.z.array(import_v35.z.unknown()).min(1),
2576
+ skip_logging: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional()
1559
2577
  }),
1560
- import_zod.z.object({ status: import_zod.z.literal("disabled") }),
1561
- import_zod.z.null(),
1562
- import_zod.z.null()
2578
+ import_v35.z.object({ status: import_v35.z.literal("disabled") }),
2579
+ import_v35.z.null(),
2580
+ import_v35.z.null()
1563
2581
  ]);
1564
- var AsyncScoringControl = import_zod.z.union([
1565
- import_zod.z.object({ kind: import_zod.z.literal("score_update"), token: import_zod.z.string() }),
1566
- import_zod.z.object({ kind: import_zod.z.literal("state_override"), state: AsyncScoringState }),
1567
- import_zod.z.object({ kind: import_zod.z.literal("state_force_reselect") }),
1568
- import_zod.z.object({ kind: import_zod.z.literal("state_enabled_force_rescore") })
2582
+ var AsyncScoringControl = import_v35.z.union([
2583
+ import_v35.z.object({ kind: import_v35.z.literal("score_update"), token: import_v35.z.string() }),
2584
+ import_v35.z.object({ kind: import_v35.z.literal("state_override"), state: AsyncScoringState }),
2585
+ import_v35.z.object({ kind: import_v35.z.literal("state_force_reselect") }),
2586
+ import_v35.z.object({ kind: import_v35.z.literal("state_enabled_force_rescore") })
1569
2587
  ]);
1570
- var BraintrustAttachmentReference = import_zod.z.object({
1571
- type: import_zod.z.literal("braintrust_attachment"),
1572
- filename: import_zod.z.string().min(1),
1573
- content_type: import_zod.z.string().min(1),
1574
- key: import_zod.z.string().min(1)
2588
+ var BraintrustAttachmentReference = import_v35.z.object({
2589
+ type: import_v35.z.literal("braintrust_attachment"),
2590
+ filename: import_v35.z.string().min(1),
2591
+ content_type: import_v35.z.string().min(1),
2592
+ key: import_v35.z.string().min(1)
1575
2593
  });
1576
- var ExternalAttachmentReference = import_zod.z.object({
1577
- type: import_zod.z.literal("external_attachment"),
1578
- filename: import_zod.z.string().min(1),
1579
- content_type: import_zod.z.string().min(1),
1580
- url: import_zod.z.string().min(1)
2594
+ var ExternalAttachmentReference = import_v35.z.object({
2595
+ type: import_v35.z.literal("external_attachment"),
2596
+ filename: import_v35.z.string().min(1),
2597
+ content_type: import_v35.z.string().min(1),
2598
+ url: import_v35.z.string().min(1)
1581
2599
  });
1582
- var AttachmentReference = import_zod.z.discriminatedUnion("type", [
2600
+ var AttachmentReference = import_v35.z.discriminatedUnion("type", [
1583
2601
  BraintrustAttachmentReference,
1584
2602
  ExternalAttachmentReference
1585
2603
  ]);
1586
- var UploadStatus = import_zod.z.enum(["uploading", "done", "error"]);
1587
- var AttachmentStatus = import_zod.z.object({
2604
+ var UploadStatus = import_v35.z.enum(["uploading", "done", "error"]);
2605
+ var AttachmentStatus = import_v35.z.object({
1588
2606
  upload_status: UploadStatus,
1589
- error_message: import_zod.z.string().optional()
2607
+ error_message: import_v35.z.string().optional()
1590
2608
  });
1591
- var BraintrustModelParams = import_zod.z.object({ use_cache: import_zod.z.boolean() }).partial();
1592
- var CallEvent = import_zod.z.union([
1593
- import_zod.z.object({
1594
- id: import_zod.z.string().optional(),
1595
- data: import_zod.z.string(),
1596
- event: import_zod.z.literal("text_delta")
2609
+ var BraintrustModelParams = import_v35.z.object({ use_cache: import_v35.z.boolean() }).partial();
2610
+ var CallEvent = import_v35.z.union([
2611
+ import_v35.z.object({
2612
+ id: import_v35.z.string().optional(),
2613
+ data: import_v35.z.string(),
2614
+ event: import_v35.z.literal("text_delta")
1597
2615
  }),
1598
- import_zod.z.object({
1599
- id: import_zod.z.string().optional(),
1600
- data: import_zod.z.string(),
1601
- event: import_zod.z.literal("reasoning_delta")
2616
+ import_v35.z.object({
2617
+ id: import_v35.z.string().optional(),
2618
+ data: import_v35.z.string(),
2619
+ event: import_v35.z.literal("reasoning_delta")
1602
2620
  }),
1603
- import_zod.z.object({
1604
- id: import_zod.z.string().optional(),
1605
- data: import_zod.z.string(),
1606
- event: import_zod.z.literal("json_delta")
2621
+ import_v35.z.object({
2622
+ id: import_v35.z.string().optional(),
2623
+ data: import_v35.z.string(),
2624
+ event: import_v35.z.literal("json_delta")
1607
2625
  }),
1608
- import_zod.z.object({
1609
- id: import_zod.z.string().optional(),
1610
- data: import_zod.z.string(),
1611
- event: import_zod.z.literal("progress")
2626
+ import_v35.z.object({
2627
+ id: import_v35.z.string().optional(),
2628
+ data: import_v35.z.string(),
2629
+ event: import_v35.z.literal("progress")
1612
2630
  }),
1613
- import_zod.z.object({
1614
- id: import_zod.z.string().optional(),
1615
- data: import_zod.z.string(),
1616
- event: import_zod.z.literal("error")
2631
+ import_v35.z.object({
2632
+ id: import_v35.z.string().optional(),
2633
+ data: import_v35.z.string(),
2634
+ event: import_v35.z.literal("error")
1617
2635
  }),
1618
- import_zod.z.object({
1619
- id: import_zod.z.string().optional(),
1620
- data: import_zod.z.string(),
1621
- event: import_zod.z.literal("console")
2636
+ import_v35.z.object({
2637
+ id: import_v35.z.string().optional(),
2638
+ data: import_v35.z.string(),
2639
+ event: import_v35.z.literal("console")
1622
2640
  }),
1623
- import_zod.z.object({
1624
- id: import_zod.z.string().optional(),
1625
- event: import_zod.z.literal("start"),
1626
- data: import_zod.z.literal("")
2641
+ import_v35.z.object({
2642
+ id: import_v35.z.string().optional(),
2643
+ event: import_v35.z.literal("start"),
2644
+ data: import_v35.z.literal("")
1627
2645
  }),
1628
- import_zod.z.object({
1629
- id: import_zod.z.string().optional(),
1630
- event: import_zod.z.literal("done"),
1631
- data: import_zod.z.literal("")
2646
+ import_v35.z.object({
2647
+ id: import_v35.z.string().optional(),
2648
+ event: import_v35.z.literal("done"),
2649
+ data: import_v35.z.literal("")
1632
2650
  })
1633
2651
  ]);
1634
- var ChatCompletionContentPartTextWithTitle = import_zod.z.object({
1635
- text: import_zod.z.string().default(""),
1636
- type: import_zod.z.literal("text"),
1637
- cache_control: import_zod.z.object({ type: import_zod.z.literal("ephemeral") }).optional()
2652
+ var ChatCompletionContentPartTextWithTitle = import_v35.z.object({
2653
+ text: import_v35.z.string().default(""),
2654
+ type: import_v35.z.literal("text"),
2655
+ cache_control: import_v35.z.object({ type: import_v35.z.literal("ephemeral") }).optional()
1638
2656
  });
1639
- var ChatCompletionContentPartImageWithTitle = import_zod.z.object({
1640
- image_url: import_zod.z.object({
1641
- url: import_zod.z.string(),
1642
- detail: import_zod.z.union([import_zod.z.literal("auto"), import_zod.z.literal("low"), import_zod.z.literal("high")]).optional()
2657
+ var ChatCompletionContentPartImageWithTitle = import_v35.z.object({
2658
+ image_url: import_v35.z.object({
2659
+ url: import_v35.z.string(),
2660
+ detail: import_v35.z.union([import_v35.z.literal("auto"), import_v35.z.literal("low"), import_v35.z.literal("high")]).optional()
1643
2661
  }),
1644
- type: import_zod.z.literal("image_url")
2662
+ type: import_v35.z.literal("image_url")
1645
2663
  });
1646
- var ChatCompletionContentPart = import_zod.z.union([
2664
+ var ChatCompletionContentPart = import_v35.z.union([
1647
2665
  ChatCompletionContentPartTextWithTitle,
1648
2666
  ChatCompletionContentPartImageWithTitle
1649
2667
  ]);
1650
- var ChatCompletionContentPartText = import_zod.z.object({
1651
- text: import_zod.z.string().default(""),
1652
- type: import_zod.z.literal("text"),
1653
- cache_control: import_zod.z.object({ type: import_zod.z.literal("ephemeral") }).optional()
2668
+ var ChatCompletionContentPartText = import_v35.z.object({
2669
+ text: import_v35.z.string().default(""),
2670
+ type: import_v35.z.literal("text"),
2671
+ cache_control: import_v35.z.object({ type: import_v35.z.literal("ephemeral") }).optional()
1654
2672
  });
1655
- var ChatCompletionMessageToolCall = import_zod.z.object({
1656
- id: import_zod.z.string(),
1657
- function: import_zod.z.object({ arguments: import_zod.z.string(), name: import_zod.z.string() }),
1658
- type: import_zod.z.literal("function")
2673
+ var ChatCompletionMessageToolCall = import_v35.z.object({
2674
+ id: import_v35.z.string(),
2675
+ function: import_v35.z.object({ arguments: import_v35.z.string(), name: import_v35.z.string() }),
2676
+ type: import_v35.z.literal("function")
1659
2677
  });
1660
- var ChatCompletionMessageReasoning = import_zod.z.object({ id: import_zod.z.string(), content: import_zod.z.string() }).partial();
1661
- var ChatCompletionMessageParam = import_zod.z.union([
1662
- import_zod.z.object({
1663
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
1664
- role: import_zod.z.literal("system"),
1665
- name: import_zod.z.string().optional()
2678
+ var ChatCompletionMessageReasoning = import_v35.z.object({ id: import_v35.z.string(), content: import_v35.z.string() }).partial();
2679
+ var ChatCompletionMessageParam = import_v35.z.union([
2680
+ import_v35.z.object({
2681
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPartText)]),
2682
+ role: import_v35.z.literal("system"),
2683
+ name: import_v35.z.string().optional()
1666
2684
  }),
1667
- import_zod.z.object({
1668
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPart)]),
1669
- role: import_zod.z.literal("user"),
1670
- name: import_zod.z.string().optional()
2685
+ import_v35.z.object({
2686
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPart)]),
2687
+ role: import_v35.z.literal("user"),
2688
+ name: import_v35.z.string().optional()
1671
2689
  }),
1672
- import_zod.z.object({
1673
- role: import_zod.z.literal("assistant"),
1674
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText), import_zod.z.null()]).optional(),
1675
- function_call: import_zod.z.object({ arguments: import_zod.z.string(), name: import_zod.z.string() }).optional(),
1676
- name: import_zod.z.string().optional(),
1677
- tool_calls: import_zod.z.array(ChatCompletionMessageToolCall).optional(),
1678
- reasoning: import_zod.z.array(ChatCompletionMessageReasoning).optional()
2690
+ import_v35.z.object({
2691
+ role: import_v35.z.literal("assistant"),
2692
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPartText), import_v35.z.null()]).optional(),
2693
+ function_call: import_v35.z.object({ arguments: import_v35.z.string(), name: import_v35.z.string() }).optional(),
2694
+ name: import_v35.z.string().optional(),
2695
+ tool_calls: import_v35.z.array(ChatCompletionMessageToolCall).optional(),
2696
+ reasoning: import_v35.z.array(ChatCompletionMessageReasoning).optional()
1679
2697
  }),
1680
- import_zod.z.object({
1681
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
1682
- role: import_zod.z.literal("tool"),
1683
- tool_call_id: import_zod.z.string().default("")
2698
+ import_v35.z.object({
2699
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPartText)]),
2700
+ role: import_v35.z.literal("tool"),
2701
+ tool_call_id: import_v35.z.string().default("")
1684
2702
  }),
1685
- import_zod.z.object({
1686
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1687
- name: import_zod.z.string(),
1688
- role: import_zod.z.literal("function")
2703
+ import_v35.z.object({
2704
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2705
+ name: import_v35.z.string(),
2706
+ role: import_v35.z.literal("function")
1689
2707
  }),
1690
- import_zod.z.object({
1691
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
1692
- role: import_zod.z.literal("developer"),
1693
- name: import_zod.z.string().optional()
2708
+ import_v35.z.object({
2709
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPartText)]),
2710
+ role: import_v35.z.literal("developer"),
2711
+ name: import_v35.z.string().optional()
1694
2712
  }),
1695
- import_zod.z.object({
1696
- role: import_zod.z.literal("model"),
1697
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
2713
+ import_v35.z.object({
2714
+ role: import_v35.z.literal("model"),
2715
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
1698
2716
  })
1699
2717
  ]);
1700
- var ChatCompletionOpenAIMessageParam = import_zod.z.union([
1701
- import_zod.z.object({
1702
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
1703
- role: import_zod.z.literal("system"),
1704
- name: import_zod.z.string().optional()
2718
+ var ChatCompletionOpenAIMessageParam = import_v35.z.union([
2719
+ import_v35.z.object({
2720
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPartText)]),
2721
+ role: import_v35.z.literal("system"),
2722
+ name: import_v35.z.string().optional()
1705
2723
  }),
1706
- import_zod.z.object({
1707
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPart)]),
1708
- role: import_zod.z.literal("user"),
1709
- name: import_zod.z.string().optional()
2724
+ import_v35.z.object({
2725
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPart)]),
2726
+ role: import_v35.z.literal("user"),
2727
+ name: import_v35.z.string().optional()
1710
2728
  }),
1711
- import_zod.z.object({
1712
- role: import_zod.z.literal("assistant"),
1713
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText), import_zod.z.null()]).optional(),
1714
- function_call: import_zod.z.object({ arguments: import_zod.z.string(), name: import_zod.z.string() }).optional(),
1715
- name: import_zod.z.string().optional(),
1716
- tool_calls: import_zod.z.array(ChatCompletionMessageToolCall).optional(),
1717
- reasoning: import_zod.z.array(ChatCompletionMessageReasoning).optional()
2729
+ import_v35.z.object({
2730
+ role: import_v35.z.literal("assistant"),
2731
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPartText), import_v35.z.null()]).optional(),
2732
+ function_call: import_v35.z.object({ arguments: import_v35.z.string(), name: import_v35.z.string() }).optional(),
2733
+ name: import_v35.z.string().optional(),
2734
+ tool_calls: import_v35.z.array(ChatCompletionMessageToolCall).optional(),
2735
+ reasoning: import_v35.z.array(ChatCompletionMessageReasoning).optional()
1718
2736
  }),
1719
- import_zod.z.object({
1720
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
1721
- role: import_zod.z.literal("tool"),
1722
- tool_call_id: import_zod.z.string().default("")
2737
+ import_v35.z.object({
2738
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPartText)]),
2739
+ role: import_v35.z.literal("tool"),
2740
+ tool_call_id: import_v35.z.string().default("")
1723
2741
  }),
1724
- import_zod.z.object({
1725
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1726
- name: import_zod.z.string(),
1727
- role: import_zod.z.literal("function")
2742
+ import_v35.z.object({
2743
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2744
+ name: import_v35.z.string(),
2745
+ role: import_v35.z.literal("function")
1728
2746
  }),
1729
- import_zod.z.object({
1730
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
1731
- role: import_zod.z.literal("developer"),
1732
- name: import_zod.z.string().optional()
2747
+ import_v35.z.object({
2748
+ content: import_v35.z.union([import_v35.z.string(), import_v35.z.array(ChatCompletionContentPartText)]),
2749
+ role: import_v35.z.literal("developer"),
2750
+ name: import_v35.z.string().optional()
1733
2751
  })
1734
2752
  ]);
1735
- var ChatCompletionTool = import_zod.z.object({
1736
- function: import_zod.z.object({
1737
- name: import_zod.z.string(),
1738
- description: import_zod.z.string().optional(),
1739
- parameters: import_zod.z.object({}).partial().passthrough().optional()
2753
+ var ChatCompletionTool = import_v35.z.object({
2754
+ function: import_v35.z.object({
2755
+ name: import_v35.z.string(),
2756
+ description: import_v35.z.string().optional(),
2757
+ parameters: import_v35.z.object({}).partial().passthrough().optional()
1740
2758
  }),
1741
- type: import_zod.z.literal("function")
2759
+ type: import_v35.z.literal("function")
1742
2760
  });
1743
- var CodeBundle = import_zod.z.object({
1744
- runtime_context: import_zod.z.object({
1745
- runtime: import_zod.z.enum(["node", "python"]),
1746
- version: import_zod.z.string()
2761
+ var CodeBundle = import_v35.z.object({
2762
+ runtime_context: import_v35.z.object({
2763
+ runtime: import_v35.z.enum(["node", "python"]),
2764
+ version: import_v35.z.string()
1747
2765
  }),
1748
- location: import_zod.z.union([
1749
- import_zod.z.object({
1750
- type: import_zod.z.literal("experiment"),
1751
- eval_name: import_zod.z.string(),
1752
- position: import_zod.z.union([
1753
- import_zod.z.object({ type: import_zod.z.literal("task") }),
1754
- import_zod.z.object({ type: import_zod.z.literal("scorer"), index: import_zod.z.number().int().gte(0) })
2766
+ location: import_v35.z.union([
2767
+ import_v35.z.object({
2768
+ type: import_v35.z.literal("experiment"),
2769
+ eval_name: import_v35.z.string(),
2770
+ position: import_v35.z.union([
2771
+ import_v35.z.object({ type: import_v35.z.literal("task") }),
2772
+ import_v35.z.object({ type: import_v35.z.literal("scorer"), index: import_v35.z.number().int().gte(0) })
1755
2773
  ])
1756
2774
  }),
1757
- import_zod.z.object({ type: import_zod.z.literal("function"), index: import_zod.z.number().int().gte(0) })
2775
+ import_v35.z.object({ type: import_v35.z.literal("function"), index: import_v35.z.number().int().gte(0) })
1758
2776
  ]),
1759
- bundle_id: import_zod.z.string(),
1760
- preview: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
2777
+ bundle_id: import_v35.z.string(),
2778
+ preview: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
1761
2779
  });
1762
- var Dataset = import_zod.z.object({
1763
- id: import_zod.z.string().uuid(),
1764
- project_id: import_zod.z.string().uuid(),
1765
- name: import_zod.z.string(),
1766
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1767
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1768
- deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1769
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1770
- metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional()
2780
+ var Dataset = import_v35.z.object({
2781
+ id: import_v35.z.string().uuid(),
2782
+ project_id: import_v35.z.string().uuid(),
2783
+ name: import_v35.z.string(),
2784
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2785
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2786
+ deleted_at: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2787
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2788
+ metadata: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]).optional()
1771
2789
  });
1772
- var ObjectReferenceNullish = import_zod.z.union([
1773
- import_zod.z.object({
1774
- object_type: import_zod.z.enum([
2790
+ var ObjectReferenceNullish = import_v35.z.union([
2791
+ import_v35.z.object({
2792
+ object_type: import_v35.z.enum([
1775
2793
  "project_logs",
1776
2794
  "experiment",
1777
2795
  "dataset",
@@ -1779,399 +2797,399 @@ var ObjectReferenceNullish = import_zod.z.union([
1779
2797
  "function",
1780
2798
  "prompt_session"
1781
2799
  ]),
1782
- object_id: import_zod.z.string().uuid(),
1783
- id: import_zod.z.string(),
1784
- _xact_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1785
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
2800
+ object_id: import_v35.z.string().uuid(),
2801
+ id: import_v35.z.string(),
2802
+ _xact_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2803
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
1786
2804
  }),
1787
- import_zod.z.null()
2805
+ import_v35.z.null()
1788
2806
  ]);
1789
- var DatasetEvent = import_zod.z.object({
1790
- id: import_zod.z.string(),
1791
- _xact_id: import_zod.z.string(),
1792
- created: import_zod.z.string().datetime({ offset: true }),
1793
- _pagination_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1794
- project_id: import_zod.z.string().uuid(),
1795
- dataset_id: import_zod.z.string().uuid(),
1796
- input: import_zod.z.unknown().optional(),
1797
- expected: import_zod.z.unknown().optional(),
1798
- metadata: import_zod.z.union([
1799
- import_zod.z.object({ model: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]) }).partial().passthrough(),
1800
- import_zod.z.null()
2807
+ var DatasetEvent = import_v35.z.object({
2808
+ id: import_v35.z.string(),
2809
+ _xact_id: import_v35.z.string(),
2810
+ created: import_v35.z.string().datetime({ offset: true }),
2811
+ _pagination_key: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2812
+ project_id: import_v35.z.string().uuid(),
2813
+ dataset_id: import_v35.z.string().uuid(),
2814
+ input: import_v35.z.unknown().optional(),
2815
+ expected: import_v35.z.unknown().optional(),
2816
+ metadata: import_v35.z.union([
2817
+ import_v35.z.object({ model: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]) }).partial().passthrough(),
2818
+ import_v35.z.null()
1801
2819
  ]).optional(),
1802
- tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
1803
- span_id: import_zod.z.string(),
1804
- root_span_id: import_zod.z.string(),
1805
- is_root: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
2820
+ tags: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional(),
2821
+ span_id: import_v35.z.string(),
2822
+ root_span_id: import_v35.z.string(),
2823
+ is_root: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional(),
1806
2824
  origin: ObjectReferenceNullish.optional()
1807
2825
  });
1808
- var EnvVar = import_zod.z.object({
1809
- id: import_zod.z.string().uuid(),
1810
- object_type: import_zod.z.enum(["organization", "project", "function"]),
1811
- object_id: import_zod.z.string().uuid(),
1812
- name: import_zod.z.string(),
1813
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1814
- used: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
2826
+ var EnvVar = import_v35.z.object({
2827
+ id: import_v35.z.string().uuid(),
2828
+ object_type: import_v35.z.enum(["organization", "project", "function"]),
2829
+ object_id: import_v35.z.string().uuid(),
2830
+ name: import_v35.z.string(),
2831
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2832
+ used: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
1815
2833
  });
1816
- var RepoInfo = import_zod.z.union([
1817
- import_zod.z.object({
1818
- commit: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1819
- branch: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1820
- tag: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1821
- dirty: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
1822
- author_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1823
- author_email: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1824
- commit_message: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1825
- commit_time: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1826
- git_diff: import_zod.z.union([import_zod.z.string(), import_zod.z.null()])
2834
+ var RepoInfo = import_v35.z.union([
2835
+ import_v35.z.object({
2836
+ commit: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2837
+ branch: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2838
+ tag: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2839
+ dirty: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]),
2840
+ author_name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2841
+ author_email: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2842
+ commit_message: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2843
+ commit_time: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2844
+ git_diff: import_v35.z.union([import_v35.z.string(), import_v35.z.null()])
1827
2845
  }).partial(),
1828
- import_zod.z.null()
2846
+ import_v35.z.null()
1829
2847
  ]);
1830
- var Experiment = import_zod.z.object({
1831
- id: import_zod.z.string().uuid(),
1832
- project_id: import_zod.z.string().uuid(),
1833
- name: import_zod.z.string(),
1834
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1835
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2848
+ var Experiment = import_v35.z.object({
2849
+ id: import_v35.z.string().uuid(),
2850
+ project_id: import_v35.z.string().uuid(),
2851
+ name: import_v35.z.string(),
2852
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2853
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
1836
2854
  repo_info: RepoInfo.optional(),
1837
- commit: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1838
- base_exp_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1839
- deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1840
- dataset_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1841
- dataset_version: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1842
- public: import_zod.z.boolean(),
1843
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1844
- metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional(),
1845
- tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional()
2855
+ commit: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2856
+ base_exp_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2857
+ deleted_at: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2858
+ dataset_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2859
+ dataset_version: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2860
+ public: import_v35.z.boolean(),
2861
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2862
+ metadata: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]).optional(),
2863
+ tags: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional()
1846
2864
  });
1847
- var SpanType = import_zod.z.union([
1848
- import_zod.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
1849
- import_zod.z.null()
2865
+ var SpanType = import_v35.z.union([
2866
+ import_v35.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
2867
+ import_v35.z.null()
1850
2868
  ]);
1851
- var SpanAttributes = import_zod.z.union([
1852
- import_zod.z.object({ name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]), type: SpanType }).partial().passthrough(),
1853
- import_zod.z.null()
2869
+ var SpanAttributes = import_v35.z.union([
2870
+ import_v35.z.object({ name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]), type: SpanType }).partial().passthrough(),
2871
+ import_v35.z.null()
1854
2872
  ]);
1855
- var ExperimentEvent = import_zod.z.object({
1856
- id: import_zod.z.string(),
1857
- _xact_id: import_zod.z.string(),
1858
- created: import_zod.z.string().datetime({ offset: true }),
1859
- _pagination_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
1860
- project_id: import_zod.z.string().uuid(),
1861
- experiment_id: import_zod.z.string().uuid(),
1862
- input: import_zod.z.unknown().optional(),
1863
- output: import_zod.z.unknown().optional(),
1864
- expected: import_zod.z.unknown().optional(),
1865
- error: import_zod.z.unknown().optional(),
1866
- scores: import_zod.z.union([import_zod.z.record(import_zod.z.union([import_zod.z.number(), import_zod.z.null()])), import_zod.z.null()]).optional(),
1867
- metadata: import_zod.z.union([
1868
- import_zod.z.object({ model: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]) }).partial().passthrough(),
1869
- import_zod.z.null()
2873
+ var ExperimentEvent = import_v35.z.object({
2874
+ id: import_v35.z.string(),
2875
+ _xact_id: import_v35.z.string(),
2876
+ created: import_v35.z.string().datetime({ offset: true }),
2877
+ _pagination_key: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2878
+ project_id: import_v35.z.string().uuid(),
2879
+ experiment_id: import_v35.z.string().uuid(),
2880
+ input: import_v35.z.unknown().optional(),
2881
+ output: import_v35.z.unknown().optional(),
2882
+ expected: import_v35.z.unknown().optional(),
2883
+ error: import_v35.z.unknown().optional(),
2884
+ scores: import_v35.z.union([import_v35.z.record(import_v35.z.union([import_v35.z.number(), import_v35.z.null()])), import_v35.z.null()]).optional(),
2885
+ metadata: import_v35.z.union([
2886
+ import_v35.z.object({ model: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]) }).partial().passthrough(),
2887
+ import_v35.z.null()
1870
2888
  ]).optional(),
1871
- tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
1872
- metrics: import_zod.z.union([import_zod.z.record(import_zod.z.number()), import_zod.z.null()]).optional(),
1873
- context: import_zod.z.union([
1874
- import_zod.z.object({
1875
- caller_functionname: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1876
- caller_filename: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
1877
- caller_lineno: import_zod.z.union([import_zod.z.number(), import_zod.z.null()])
2889
+ tags: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional(),
2890
+ metrics: import_v35.z.union([import_v35.z.record(import_v35.z.number()), import_v35.z.null()]).optional(),
2891
+ context: import_v35.z.union([
2892
+ import_v35.z.object({
2893
+ caller_functionname: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2894
+ caller_filename: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2895
+ caller_lineno: import_v35.z.union([import_v35.z.number(), import_v35.z.null()])
1878
2896
  }).partial().passthrough(),
1879
- import_zod.z.null()
2897
+ import_v35.z.null()
1880
2898
  ]).optional(),
1881
- span_id: import_zod.z.string(),
1882
- span_parents: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
1883
- root_span_id: import_zod.z.string(),
2899
+ span_id: import_v35.z.string(),
2900
+ span_parents: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional(),
2901
+ root_span_id: import_v35.z.string(),
1884
2902
  span_attributes: SpanAttributes.optional(),
1885
- is_root: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
2903
+ is_root: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional(),
1886
2904
  origin: ObjectReferenceNullish.optional()
1887
2905
  });
1888
- var ExtendedSavedFunctionId = import_zod.z.union([
1889
- import_zod.z.object({ type: import_zod.z.literal("function"), id: import_zod.z.string() }),
1890
- import_zod.z.object({ type: import_zod.z.literal("global"), name: import_zod.z.string() }),
1891
- import_zod.z.object({
1892
- type: import_zod.z.literal("slug"),
1893
- project_id: import_zod.z.string(),
1894
- slug: import_zod.z.string()
2906
+ var ExtendedSavedFunctionId = import_v35.z.union([
2907
+ import_v35.z.object({ type: import_v35.z.literal("function"), id: import_v35.z.string() }),
2908
+ import_v35.z.object({ type: import_v35.z.literal("global"), name: import_v35.z.string() }),
2909
+ import_v35.z.object({
2910
+ type: import_v35.z.literal("slug"),
2911
+ project_id: import_v35.z.string(),
2912
+ slug: import_v35.z.string()
1895
2913
  })
1896
2914
  ]);
1897
- var PromptBlockDataNullish = import_zod.z.union([
1898
- import_zod.z.object({ type: import_zod.z.literal("completion"), content: import_zod.z.string() }),
1899
- import_zod.z.object({
1900
- type: import_zod.z.literal("chat"),
1901
- messages: import_zod.z.array(ChatCompletionMessageParam),
1902
- tools: import_zod.z.string().optional()
2915
+ var PromptBlockDataNullish = import_v35.z.union([
2916
+ import_v35.z.object({ type: import_v35.z.literal("completion"), content: import_v35.z.string() }),
2917
+ import_v35.z.object({
2918
+ type: import_v35.z.literal("chat"),
2919
+ messages: import_v35.z.array(ChatCompletionMessageParam),
2920
+ tools: import_v35.z.string().optional()
1903
2921
  }),
1904
- import_zod.z.null()
2922
+ import_v35.z.null()
1905
2923
  ]);
1906
- var ModelParams = import_zod.z.union([
1907
- import_zod.z.object({
1908
- use_cache: import_zod.z.boolean(),
1909
- temperature: import_zod.z.number(),
1910
- top_p: import_zod.z.number(),
1911
- max_tokens: import_zod.z.number(),
1912
- max_completion_tokens: import_zod.z.number(),
1913
- frequency_penalty: import_zod.z.number(),
1914
- presence_penalty: import_zod.z.number(),
2924
+ var ModelParams = import_v35.z.union([
2925
+ import_v35.z.object({
2926
+ use_cache: import_v35.z.boolean(),
2927
+ temperature: import_v35.z.number(),
2928
+ top_p: import_v35.z.number(),
2929
+ max_tokens: import_v35.z.number(),
2930
+ max_completion_tokens: import_v35.z.number(),
2931
+ frequency_penalty: import_v35.z.number(),
2932
+ presence_penalty: import_v35.z.number(),
1915
2933
  response_format: ResponseFormatNullish,
1916
- tool_choice: import_zod.z.union([
1917
- import_zod.z.literal("auto"),
1918
- import_zod.z.literal("none"),
1919
- import_zod.z.literal("required"),
1920
- import_zod.z.object({
1921
- type: import_zod.z.literal("function"),
1922
- function: import_zod.z.object({ name: import_zod.z.string() })
2934
+ tool_choice: import_v35.z.union([
2935
+ import_v35.z.literal("auto"),
2936
+ import_v35.z.literal("none"),
2937
+ import_v35.z.literal("required"),
2938
+ import_v35.z.object({
2939
+ type: import_v35.z.literal("function"),
2940
+ function: import_v35.z.object({ name: import_v35.z.string() })
1923
2941
  })
1924
2942
  ]),
1925
- function_call: import_zod.z.union([
1926
- import_zod.z.literal("auto"),
1927
- import_zod.z.literal("none"),
1928
- import_zod.z.object({ name: import_zod.z.string() })
2943
+ function_call: import_v35.z.union([
2944
+ import_v35.z.literal("auto"),
2945
+ import_v35.z.literal("none"),
2946
+ import_v35.z.object({ name: import_v35.z.string() })
1929
2947
  ]),
1930
- n: import_zod.z.number(),
1931
- stop: import_zod.z.array(import_zod.z.string()),
1932
- reasoning_effort: import_zod.z.enum(["minimal", "low", "medium", "high"]),
1933
- verbosity: import_zod.z.enum(["low", "medium", "high"])
2948
+ n: import_v35.z.number(),
2949
+ stop: import_v35.z.array(import_v35.z.string()),
2950
+ reasoning_effort: import_v35.z.enum(["minimal", "low", "medium", "high"]),
2951
+ verbosity: import_v35.z.enum(["low", "medium", "high"])
1934
2952
  }).partial().passthrough(),
1935
- import_zod.z.object({
1936
- use_cache: import_zod.z.boolean().optional(),
1937
- max_tokens: import_zod.z.number(),
1938
- temperature: import_zod.z.number(),
1939
- top_p: import_zod.z.number().optional(),
1940
- top_k: import_zod.z.number().optional(),
1941
- stop_sequences: import_zod.z.array(import_zod.z.string()).optional(),
1942
- max_tokens_to_sample: import_zod.z.number().optional()
2953
+ import_v35.z.object({
2954
+ use_cache: import_v35.z.boolean().optional(),
2955
+ max_tokens: import_v35.z.number(),
2956
+ temperature: import_v35.z.number(),
2957
+ top_p: import_v35.z.number().optional(),
2958
+ top_k: import_v35.z.number().optional(),
2959
+ stop_sequences: import_v35.z.array(import_v35.z.string()).optional(),
2960
+ max_tokens_to_sample: import_v35.z.number().optional()
1943
2961
  }).passthrough(),
1944
- import_zod.z.object({
1945
- use_cache: import_zod.z.boolean(),
1946
- temperature: import_zod.z.number(),
1947
- maxOutputTokens: import_zod.z.number(),
1948
- topP: import_zod.z.number(),
1949
- topK: import_zod.z.number()
2962
+ import_v35.z.object({
2963
+ use_cache: import_v35.z.boolean(),
2964
+ temperature: import_v35.z.number(),
2965
+ maxOutputTokens: import_v35.z.number(),
2966
+ topP: import_v35.z.number(),
2967
+ topK: import_v35.z.number()
1950
2968
  }).partial().passthrough(),
1951
- import_zod.z.object({
1952
- use_cache: import_zod.z.boolean(),
1953
- temperature: import_zod.z.number(),
1954
- topK: import_zod.z.number()
2969
+ import_v35.z.object({
2970
+ use_cache: import_v35.z.boolean(),
2971
+ temperature: import_v35.z.number(),
2972
+ topK: import_v35.z.number()
1955
2973
  }).partial().passthrough(),
1956
- import_zod.z.object({ use_cache: import_zod.z.boolean() }).partial().passthrough()
2974
+ import_v35.z.object({ use_cache: import_v35.z.boolean() }).partial().passthrough()
1957
2975
  ]);
1958
- var PromptOptionsNullish = import_zod.z.union([
1959
- import_zod.z.object({ model: import_zod.z.string(), params: ModelParams, position: import_zod.z.string() }).partial(),
1960
- import_zod.z.null()
2976
+ var PromptOptionsNullish = import_v35.z.union([
2977
+ import_v35.z.object({ model: import_v35.z.string(), params: ModelParams, position: import_v35.z.string() }).partial(),
2978
+ import_v35.z.null()
1961
2979
  ]);
1962
- var PromptParserNullish = import_zod.z.union([
1963
- import_zod.z.object({
1964
- type: import_zod.z.literal("llm_classifier"),
1965
- use_cot: import_zod.z.boolean(),
1966
- choice_scores: import_zod.z.record(import_zod.z.number().gte(0).lte(1))
2980
+ var PromptParserNullish = import_v35.z.union([
2981
+ import_v35.z.object({
2982
+ type: import_v35.z.literal("llm_classifier"),
2983
+ use_cot: import_v35.z.boolean(),
2984
+ choice_scores: import_v35.z.record(import_v35.z.number().gte(0).lte(1))
1967
2985
  }),
1968
- import_zod.z.null()
2986
+ import_v35.z.null()
1969
2987
  ]);
1970
- var SavedFunctionId = import_zod.z.union([
1971
- import_zod.z.object({ type: import_zod.z.literal("function"), id: import_zod.z.string() }),
1972
- import_zod.z.object({ type: import_zod.z.literal("global"), name: import_zod.z.string() })
2988
+ var SavedFunctionId = import_v35.z.union([
2989
+ import_v35.z.object({ type: import_v35.z.literal("function"), id: import_v35.z.string() }),
2990
+ import_v35.z.object({ type: import_v35.z.literal("global"), name: import_v35.z.string() })
1973
2991
  ]);
1974
- var PromptDataNullish = import_zod.z.union([
1975
- import_zod.z.object({
2992
+ var PromptDataNullish = import_v35.z.union([
2993
+ import_v35.z.object({
1976
2994
  prompt: PromptBlockDataNullish,
1977
2995
  options: PromptOptionsNullish,
1978
2996
  parser: PromptParserNullish,
1979
- tool_functions: import_zod.z.union([import_zod.z.array(SavedFunctionId), import_zod.z.null()]),
1980
- origin: import_zod.z.union([
1981
- import_zod.z.object({
1982
- prompt_id: import_zod.z.string(),
1983
- project_id: import_zod.z.string(),
1984
- prompt_version: import_zod.z.string()
2997
+ tool_functions: import_v35.z.union([import_v35.z.array(SavedFunctionId), import_v35.z.null()]),
2998
+ origin: import_v35.z.union([
2999
+ import_v35.z.object({
3000
+ prompt_id: import_v35.z.string(),
3001
+ project_id: import_v35.z.string(),
3002
+ prompt_version: import_v35.z.string()
1985
3003
  }).partial(),
1986
- import_zod.z.null()
3004
+ import_v35.z.null()
1987
3005
  ])
1988
3006
  }).partial(),
1989
- import_zod.z.null()
3007
+ import_v35.z.null()
1990
3008
  ]);
1991
- var FunctionTypeEnumNullish = import_zod.z.union([
1992
- import_zod.z.enum(["llm", "scorer", "task", "tool"]),
1993
- import_zod.z.null()
3009
+ var FunctionTypeEnumNullish = import_v35.z.union([
3010
+ import_v35.z.enum(["llm", "scorer", "task", "tool"]),
3011
+ import_v35.z.null()
1994
3012
  ]);
1995
- var FunctionIdRef = import_zod.z.object({}).partial().passthrough();
1996
- var PromptBlockData = import_zod.z.union([
1997
- import_zod.z.object({ type: import_zod.z.literal("completion"), content: import_zod.z.string() }),
1998
- import_zod.z.object({
1999
- type: import_zod.z.literal("chat"),
2000
- messages: import_zod.z.array(ChatCompletionMessageParam),
2001
- tools: import_zod.z.string().optional()
3013
+ var FunctionIdRef = import_v35.z.object({}).partial().passthrough();
3014
+ var PromptBlockData = import_v35.z.union([
3015
+ import_v35.z.object({ type: import_v35.z.literal("completion"), content: import_v35.z.string() }),
3016
+ import_v35.z.object({
3017
+ type: import_v35.z.literal("chat"),
3018
+ messages: import_v35.z.array(ChatCompletionMessageParam),
3019
+ tools: import_v35.z.string().optional()
2002
3020
  })
2003
3021
  ]);
2004
- var GraphNode = import_zod.z.union([
2005
- import_zod.z.object({
2006
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2007
- position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
2008
- type: import_zod.z.literal("function"),
3022
+ var GraphNode = import_v35.z.union([
3023
+ import_v35.z.object({
3024
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3025
+ position: import_v35.z.union([import_v35.z.object({ x: import_v35.z.number(), y: import_v35.z.number() }), import_v35.z.null()]).optional(),
3026
+ type: import_v35.z.literal("function"),
2009
3027
  function: FunctionIdRef
2010
3028
  }),
2011
- import_zod.z.object({
2012
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2013
- position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
2014
- type: import_zod.z.literal("input")
3029
+ import_v35.z.object({
3030
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3031
+ position: import_v35.z.union([import_v35.z.object({ x: import_v35.z.number(), y: import_v35.z.number() }), import_v35.z.null()]).optional(),
3032
+ type: import_v35.z.literal("input")
2015
3033
  }),
2016
- import_zod.z.object({
2017
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2018
- position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
2019
- type: import_zod.z.literal("output")
3034
+ import_v35.z.object({
3035
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3036
+ position: import_v35.z.union([import_v35.z.object({ x: import_v35.z.number(), y: import_v35.z.number() }), import_v35.z.null()]).optional(),
3037
+ type: import_v35.z.literal("output")
2020
3038
  }),
2021
- import_zod.z.object({
2022
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2023
- position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
2024
- type: import_zod.z.literal("literal"),
2025
- value: import_zod.z.unknown().optional()
3039
+ import_v35.z.object({
3040
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3041
+ position: import_v35.z.union([import_v35.z.object({ x: import_v35.z.number(), y: import_v35.z.number() }), import_v35.z.null()]).optional(),
3042
+ type: import_v35.z.literal("literal"),
3043
+ value: import_v35.z.unknown().optional()
2026
3044
  }),
2027
- import_zod.z.object({
2028
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2029
- position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
2030
- type: import_zod.z.literal("btql"),
2031
- expr: import_zod.z.string()
3045
+ import_v35.z.object({
3046
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3047
+ position: import_v35.z.union([import_v35.z.object({ x: import_v35.z.number(), y: import_v35.z.number() }), import_v35.z.null()]).optional(),
3048
+ type: import_v35.z.literal("btql"),
3049
+ expr: import_v35.z.string()
2032
3050
  }),
2033
- import_zod.z.object({
2034
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2035
- position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
2036
- type: import_zod.z.literal("gate"),
2037
- condition: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3051
+ import_v35.z.object({
3052
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3053
+ position: import_v35.z.union([import_v35.z.object({ x: import_v35.z.number(), y: import_v35.z.number() }), import_v35.z.null()]).optional(),
3054
+ type: import_v35.z.literal("gate"),
3055
+ condition: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2038
3056
  }),
2039
- import_zod.z.object({
2040
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2041
- position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
2042
- type: import_zod.z.literal("aggregator")
3057
+ import_v35.z.object({
3058
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3059
+ position: import_v35.z.union([import_v35.z.object({ x: import_v35.z.number(), y: import_v35.z.number() }), import_v35.z.null()]).optional(),
3060
+ type: import_v35.z.literal("aggregator")
2043
3061
  }),
2044
- import_zod.z.object({
2045
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2046
- position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
2047
- type: import_zod.z.literal("prompt_template"),
3062
+ import_v35.z.object({
3063
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3064
+ position: import_v35.z.union([import_v35.z.object({ x: import_v35.z.number(), y: import_v35.z.number() }), import_v35.z.null()]).optional(),
3065
+ type: import_v35.z.literal("prompt_template"),
2048
3066
  prompt: PromptBlockData
2049
3067
  })
2050
3068
  ]);
2051
- var GraphEdge = import_zod.z.object({
2052
- source: import_zod.z.object({ node: import_zod.z.string().max(1024), variable: import_zod.z.string() }),
2053
- target: import_zod.z.object({ node: import_zod.z.string().max(1024), variable: import_zod.z.string() }),
2054
- purpose: import_zod.z.enum(["control", "data", "messages"])
3069
+ var GraphEdge = import_v35.z.object({
3070
+ source: import_v35.z.object({ node: import_v35.z.string().max(1024), variable: import_v35.z.string() }),
3071
+ target: import_v35.z.object({ node: import_v35.z.string().max(1024), variable: import_v35.z.string() }),
3072
+ purpose: import_v35.z.enum(["control", "data", "messages"])
2055
3073
  });
2056
- var GraphData = import_zod.z.object({
2057
- type: import_zod.z.literal("graph"),
2058
- nodes: import_zod.z.record(GraphNode),
2059
- edges: import_zod.z.record(GraphEdge)
3074
+ var GraphData = import_v35.z.object({
3075
+ type: import_v35.z.literal("graph"),
3076
+ nodes: import_v35.z.record(GraphNode),
3077
+ edges: import_v35.z.record(GraphEdge)
2060
3078
  });
2061
- var FunctionData = import_zod.z.union([
2062
- import_zod.z.object({ type: import_zod.z.literal("prompt") }),
2063
- import_zod.z.object({
2064
- type: import_zod.z.literal("code"),
2065
- data: import_zod.z.union([
2066
- import_zod.z.object({ type: import_zod.z.literal("bundle") }).and(CodeBundle),
2067
- import_zod.z.object({
2068
- type: import_zod.z.literal("inline"),
2069
- runtime_context: import_zod.z.object({
2070
- runtime: import_zod.z.enum(["node", "python"]),
2071
- version: import_zod.z.string()
3079
+ var FunctionData = import_v35.z.union([
3080
+ import_v35.z.object({ type: import_v35.z.literal("prompt") }),
3081
+ import_v35.z.object({
3082
+ type: import_v35.z.literal("code"),
3083
+ data: import_v35.z.union([
3084
+ import_v35.z.object({ type: import_v35.z.literal("bundle") }).and(CodeBundle),
3085
+ import_v35.z.object({
3086
+ type: import_v35.z.literal("inline"),
3087
+ runtime_context: import_v35.z.object({
3088
+ runtime: import_v35.z.enum(["node", "python"]),
3089
+ version: import_v35.z.string()
2072
3090
  }),
2073
- code: import_zod.z.string()
3091
+ code: import_v35.z.string()
2074
3092
  })
2075
3093
  ])
2076
3094
  }),
2077
3095
  GraphData,
2078
- import_zod.z.object({
2079
- type: import_zod.z.literal("remote_eval"),
2080
- endpoint: import_zod.z.string(),
2081
- eval_name: import_zod.z.string(),
2082
- parameters: import_zod.z.object({}).partial().passthrough()
3096
+ import_v35.z.object({
3097
+ type: import_v35.z.literal("remote_eval"),
3098
+ endpoint: import_v35.z.string(),
3099
+ eval_name: import_v35.z.string(),
3100
+ parameters: import_v35.z.object({}).partial().passthrough()
2083
3101
  }),
2084
- import_zod.z.object({ type: import_zod.z.literal("global"), name: import_zod.z.string() })
3102
+ import_v35.z.object({ type: import_v35.z.literal("global"), name: import_v35.z.string() })
2085
3103
  ]);
2086
- var Function2 = import_zod.z.object({
2087
- id: import_zod.z.string().uuid(),
2088
- _xact_id: import_zod.z.string(),
2089
- project_id: import_zod.z.string().uuid(),
2090
- log_id: import_zod.z.literal("p"),
2091
- org_id: import_zod.z.string().uuid(),
2092
- name: import_zod.z.string(),
2093
- slug: import_zod.z.string(),
2094
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2095
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
3104
+ var Function2 = import_v35.z.object({
3105
+ id: import_v35.z.string().uuid(),
3106
+ _xact_id: import_v35.z.string(),
3107
+ project_id: import_v35.z.string().uuid(),
3108
+ log_id: import_v35.z.literal("p"),
3109
+ org_id: import_v35.z.string().uuid(),
3110
+ name: import_v35.z.string(),
3111
+ slug: import_v35.z.string(),
3112
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3113
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2096
3114
  prompt_data: PromptDataNullish.optional(),
2097
- tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
2098
- metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional(),
3115
+ tags: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional(),
3116
+ metadata: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]).optional(),
2099
3117
  function_type: FunctionTypeEnumNullish.optional(),
2100
3118
  function_data: FunctionData,
2101
- origin: import_zod.z.union([
2102
- import_zod.z.object({
2103
- object_type: AclObjectType.and(import_zod.z.string()),
2104
- object_id: import_zod.z.string().uuid(),
2105
- internal: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
3119
+ origin: import_v35.z.union([
3120
+ import_v35.z.object({
3121
+ object_type: AclObjectType.and(import_v35.z.string()),
3122
+ object_id: import_v35.z.string().uuid(),
3123
+ internal: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional()
2106
3124
  }),
2107
- import_zod.z.null()
3125
+ import_v35.z.null()
2108
3126
  ]).optional(),
2109
- function_schema: import_zod.z.union([
2110
- import_zod.z.object({ parameters: import_zod.z.unknown(), returns: import_zod.z.unknown() }).partial(),
2111
- import_zod.z.null()
3127
+ function_schema: import_v35.z.union([
3128
+ import_v35.z.object({ parameters: import_v35.z.unknown(), returns: import_v35.z.unknown() }).partial(),
3129
+ import_v35.z.null()
2112
3130
  ]).optional()
2113
3131
  });
2114
- var FunctionFormat = import_zod.z.enum(["llm", "code", "global", "graph"]);
2115
- var PromptData = import_zod.z.object({
3132
+ var FunctionFormat = import_v35.z.enum(["llm", "code", "global", "graph"]);
3133
+ var PromptData = import_v35.z.object({
2116
3134
  prompt: PromptBlockDataNullish,
2117
3135
  options: PromptOptionsNullish,
2118
3136
  parser: PromptParserNullish,
2119
- tool_functions: import_zod.z.union([import_zod.z.array(SavedFunctionId), import_zod.z.null()]),
2120
- origin: import_zod.z.union([
2121
- import_zod.z.object({
2122
- prompt_id: import_zod.z.string(),
2123
- project_id: import_zod.z.string(),
2124
- prompt_version: import_zod.z.string()
3137
+ tool_functions: import_v35.z.union([import_v35.z.array(SavedFunctionId), import_v35.z.null()]),
3138
+ origin: import_v35.z.union([
3139
+ import_v35.z.object({
3140
+ prompt_id: import_v35.z.string(),
3141
+ project_id: import_v35.z.string(),
3142
+ prompt_version: import_v35.z.string()
2125
3143
  }).partial(),
2126
- import_zod.z.null()
3144
+ import_v35.z.null()
2127
3145
  ])
2128
3146
  }).partial();
2129
- var FunctionTypeEnum = import_zod.z.enum(["llm", "scorer", "task", "tool"]);
2130
- var FunctionId = import_zod.z.union([
2131
- import_zod.z.object({ function_id: import_zod.z.string(), version: import_zod.z.string().optional() }),
2132
- import_zod.z.object({
2133
- project_name: import_zod.z.string(),
2134
- slug: import_zod.z.string(),
2135
- version: import_zod.z.string().optional()
3147
+ var FunctionTypeEnum = import_v35.z.enum(["llm", "scorer", "task", "tool"]);
3148
+ var FunctionId = import_v35.z.union([
3149
+ import_v35.z.object({ function_id: import_v35.z.string(), version: import_v35.z.string().optional() }),
3150
+ import_v35.z.object({
3151
+ project_name: import_v35.z.string(),
3152
+ slug: import_v35.z.string(),
3153
+ version: import_v35.z.string().optional()
2136
3154
  }),
2137
- import_zod.z.object({ global_function: import_zod.z.string() }),
2138
- import_zod.z.object({
2139
- prompt_session_id: import_zod.z.string(),
2140
- prompt_session_function_id: import_zod.z.string(),
2141
- version: import_zod.z.string().optional()
3155
+ import_v35.z.object({ global_function: import_v35.z.string() }),
3156
+ import_v35.z.object({
3157
+ prompt_session_id: import_v35.z.string(),
3158
+ prompt_session_function_id: import_v35.z.string(),
3159
+ version: import_v35.z.string().optional()
2142
3160
  }),
2143
- import_zod.z.object({
2144
- inline_context: import_zod.z.object({
2145
- runtime: import_zod.z.enum(["node", "python"]),
2146
- version: import_zod.z.string()
3161
+ import_v35.z.object({
3162
+ inline_context: import_v35.z.object({
3163
+ runtime: import_v35.z.enum(["node", "python"]),
3164
+ version: import_v35.z.string()
2147
3165
  }),
2148
- code: import_zod.z.string(),
2149
- name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3166
+ code: import_v35.z.string(),
3167
+ name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2150
3168
  }),
2151
- import_zod.z.object({
3169
+ import_v35.z.object({
2152
3170
  inline_prompt: PromptData.optional(),
2153
- inline_function: import_zod.z.object({}).partial().passthrough(),
3171
+ inline_function: import_v35.z.object({}).partial().passthrough(),
2154
3172
  function_type: FunctionTypeEnum.optional(),
2155
- name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3173
+ name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2156
3174
  }),
2157
- import_zod.z.object({
3175
+ import_v35.z.object({
2158
3176
  inline_prompt: PromptData,
2159
3177
  function_type: FunctionTypeEnum.optional(),
2160
- name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3178
+ name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2161
3179
  })
2162
3180
  ]);
2163
- var FunctionObjectType = import_zod.z.enum([
3181
+ var FunctionObjectType = import_v35.z.enum([
2164
3182
  "prompt",
2165
3183
  "tool",
2166
3184
  "scorer",
2167
3185
  "task",
2168
3186
  "agent"
2169
3187
  ]);
2170
- var FunctionOutputType = import_zod.z.enum(["completion", "score", "any"]);
2171
- var GitMetadataSettings = import_zod.z.object({
2172
- collect: import_zod.z.enum(["all", "none", "some"]),
2173
- fields: import_zod.z.array(
2174
- import_zod.z.enum([
3188
+ var FunctionOutputType = import_v35.z.enum(["completion", "score", "any"]);
3189
+ var GitMetadataSettings = import_v35.z.object({
3190
+ collect: import_v35.z.enum(["all", "none", "some"]),
3191
+ fields: import_v35.z.array(
3192
+ import_v35.z.enum([
2175
3193
  "commit",
2176
3194
  "branch",
2177
3195
  "tag",
@@ -2184,49 +3202,49 @@ var GitMetadataSettings = import_zod.z.object({
2184
3202
  ])
2185
3203
  ).optional()
2186
3204
  });
2187
- var Group = import_zod.z.object({
2188
- id: import_zod.z.string().uuid(),
2189
- org_id: import_zod.z.string().uuid(),
2190
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2191
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2192
- name: import_zod.z.string(),
2193
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2194
- deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2195
- member_users: import_zod.z.union([import_zod.z.array(import_zod.z.string().uuid()), import_zod.z.null()]).optional(),
2196
- member_groups: import_zod.z.union([import_zod.z.array(import_zod.z.string().uuid()), import_zod.z.null()]).optional()
3205
+ var Group = import_v35.z.object({
3206
+ id: import_v35.z.string().uuid(),
3207
+ org_id: import_v35.z.string().uuid(),
3208
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3209
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3210
+ name: import_v35.z.string(),
3211
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3212
+ deleted_at: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3213
+ member_users: import_v35.z.union([import_v35.z.array(import_v35.z.string().uuid()), import_v35.z.null()]).optional(),
3214
+ member_groups: import_v35.z.union([import_v35.z.array(import_v35.z.string().uuid()), import_v35.z.null()]).optional()
2197
3215
  });
2198
- var IfExists = import_zod.z.enum(["error", "ignore", "replace"]);
2199
- var InvokeParent = import_zod.z.union([
2200
- import_zod.z.object({
2201
- object_type: import_zod.z.enum(["project_logs", "experiment", "playground_logs"]),
2202
- object_id: import_zod.z.string(),
2203
- row_ids: import_zod.z.union([
2204
- import_zod.z.object({
2205
- id: import_zod.z.string(),
2206
- span_id: import_zod.z.string(),
2207
- root_span_id: import_zod.z.string()
3216
+ var IfExists = import_v35.z.enum(["error", "ignore", "replace"]);
3217
+ var InvokeParent = import_v35.z.union([
3218
+ import_v35.z.object({
3219
+ object_type: import_v35.z.enum(["project_logs", "experiment", "playground_logs"]),
3220
+ object_id: import_v35.z.string(),
3221
+ row_ids: import_v35.z.union([
3222
+ import_v35.z.object({
3223
+ id: import_v35.z.string(),
3224
+ span_id: import_v35.z.string(),
3225
+ root_span_id: import_v35.z.string()
2208
3226
  }),
2209
- import_zod.z.null()
3227
+ import_v35.z.null()
2210
3228
  ]).optional(),
2211
- propagated_event: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional()
3229
+ propagated_event: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]).optional()
2212
3230
  }),
2213
- import_zod.z.string()
3231
+ import_v35.z.string()
2214
3232
  ]);
2215
- var StreamingMode = import_zod.z.union([import_zod.z.enum(["auto", "parallel"]), import_zod.z.null()]);
3233
+ var StreamingMode = import_v35.z.union([import_v35.z.enum(["auto", "parallel"]), import_v35.z.null()]);
2216
3234
  var InvokeFunction = FunctionId.and(
2217
- import_zod.z.object({
2218
- input: import_zod.z.unknown(),
2219
- expected: import_zod.z.unknown(),
2220
- metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]),
2221
- tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]),
2222
- messages: import_zod.z.array(ChatCompletionMessageParam),
3235
+ import_v35.z.object({
3236
+ input: import_v35.z.unknown(),
3237
+ expected: import_v35.z.unknown(),
3238
+ metadata: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]),
3239
+ tags: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]),
3240
+ messages: import_v35.z.array(ChatCompletionMessageParam),
2223
3241
  parent: InvokeParent,
2224
- stream: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
3242
+ stream: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]),
2225
3243
  mode: StreamingMode,
2226
- strict: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()])
3244
+ strict: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()])
2227
3245
  }).partial()
2228
3246
  );
2229
- var MessageRole = import_zod.z.enum([
3247
+ var MessageRole = import_v35.z.enum([
2230
3248
  "system",
2231
3249
  "user",
2232
3250
  "assistant",
@@ -2235,8 +3253,8 @@ var MessageRole = import_zod.z.enum([
2235
3253
  "model",
2236
3254
  "developer"
2237
3255
  ]);
2238
- var ObjectReference = import_zod.z.object({
2239
- object_type: import_zod.z.enum([
3256
+ var ObjectReference = import_v35.z.object({
3257
+ object_type: import_v35.z.enum([
2240
3258
  "project_logs",
2241
3259
  "experiment",
2242
3260
  "dataset",
@@ -2244,146 +3262,146 @@ var ObjectReference = import_zod.z.object({
2244
3262
  "function",
2245
3263
  "prompt_session"
2246
3264
  ]),
2247
- object_id: import_zod.z.string().uuid(),
2248
- id: import_zod.z.string(),
2249
- _xact_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2250
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3265
+ object_id: import_v35.z.string().uuid(),
3266
+ id: import_v35.z.string(),
3267
+ _xact_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3268
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2251
3269
  });
2252
- var OnlineScoreConfig = import_zod.z.union([
2253
- import_zod.z.object({
2254
- sampling_rate: import_zod.z.number().gte(0).lte(1),
2255
- scorers: import_zod.z.array(SavedFunctionId),
2256
- btql_filter: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2257
- apply_to_root_span: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
2258
- apply_to_span_names: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
2259
- skip_logging: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
3270
+ var OnlineScoreConfig = import_v35.z.union([
3271
+ import_v35.z.object({
3272
+ sampling_rate: import_v35.z.number().gte(0).lte(1),
3273
+ scorers: import_v35.z.array(SavedFunctionId),
3274
+ btql_filter: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3275
+ apply_to_root_span: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional(),
3276
+ apply_to_span_names: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional(),
3277
+ skip_logging: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional()
2260
3278
  }),
2261
- import_zod.z.null()
3279
+ import_v35.z.null()
2262
3280
  ]);
2263
- var Organization = import_zod.z.object({
2264
- id: import_zod.z.string().uuid(),
2265
- name: import_zod.z.string(),
2266
- api_url: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2267
- is_universal_api: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
2268
- proxy_url: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2269
- realtime_url: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2270
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3281
+ var Organization = import_v35.z.object({
3282
+ id: import_v35.z.string().uuid(),
3283
+ name: import_v35.z.string(),
3284
+ api_url: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3285
+ is_universal_api: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional(),
3286
+ proxy_url: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3287
+ realtime_url: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3288
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2271
3289
  });
2272
- var ProjectSettings = import_zod.z.union([
2273
- import_zod.z.object({
2274
- comparison_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2275
- baseline_experiment_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2276
- spanFieldOrder: import_zod.z.union([
2277
- import_zod.z.array(
2278
- import_zod.z.object({
2279
- object_type: import_zod.z.string(),
2280
- column_id: import_zod.z.string(),
2281
- position: import_zod.z.string(),
2282
- layout: import_zod.z.union([import_zod.z.literal("full"), import_zod.z.literal("two_column"), import_zod.z.null()]).optional()
3290
+ var ProjectSettings = import_v35.z.union([
3291
+ import_v35.z.object({
3292
+ comparison_key: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3293
+ baseline_experiment_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3294
+ spanFieldOrder: import_v35.z.union([
3295
+ import_v35.z.array(
3296
+ import_v35.z.object({
3297
+ object_type: import_v35.z.string(),
3298
+ column_id: import_v35.z.string(),
3299
+ position: import_v35.z.string(),
3300
+ layout: import_v35.z.union([import_v35.z.literal("full"), import_v35.z.literal("two_column"), import_v35.z.null()]).optional()
2283
3301
  })
2284
3302
  ),
2285
- import_zod.z.null()
3303
+ import_v35.z.null()
2286
3304
  ]),
2287
- remote_eval_sources: import_zod.z.union([
2288
- import_zod.z.array(
2289
- import_zod.z.object({
2290
- url: import_zod.z.string(),
2291
- name: import_zod.z.string(),
2292
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3305
+ remote_eval_sources: import_v35.z.union([
3306
+ import_v35.z.array(
3307
+ import_v35.z.object({
3308
+ url: import_v35.z.string(),
3309
+ name: import_v35.z.string(),
3310
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2293
3311
  })
2294
3312
  ),
2295
- import_zod.z.null()
3313
+ import_v35.z.null()
2296
3314
  ])
2297
3315
  }).partial(),
2298
- import_zod.z.null()
3316
+ import_v35.z.null()
2299
3317
  ]);
2300
- var Project = import_zod.z.object({
2301
- id: import_zod.z.string().uuid(),
2302
- org_id: import_zod.z.string().uuid(),
2303
- name: import_zod.z.string(),
2304
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2305
- deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2306
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
3318
+ var Project = import_v35.z.object({
3319
+ id: import_v35.z.string().uuid(),
3320
+ org_id: import_v35.z.string().uuid(),
3321
+ name: import_v35.z.string(),
3322
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3323
+ deleted_at: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3324
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2307
3325
  settings: ProjectSettings.optional()
2308
3326
  });
2309
- var RetentionObjectType = import_zod.z.enum([
3327
+ var RetentionObjectType = import_v35.z.enum([
2310
3328
  "project_logs",
2311
3329
  "experiment",
2312
3330
  "dataset"
2313
3331
  ]);
2314
- var ProjectAutomation = import_zod.z.object({
2315
- id: import_zod.z.string().uuid(),
2316
- project_id: import_zod.z.string().uuid(),
2317
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2318
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2319
- name: import_zod.z.string(),
2320
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2321
- config: import_zod.z.union([
2322
- import_zod.z.object({
2323
- event_type: import_zod.z.literal("logs"),
2324
- btql_filter: import_zod.z.string(),
2325
- interval_seconds: import_zod.z.number().gte(1).lte(2592e3),
2326
- action: import_zod.z.object({ type: import_zod.z.literal("webhook"), url: import_zod.z.string() })
3332
+ var ProjectAutomation = import_v35.z.object({
3333
+ id: import_v35.z.string().uuid(),
3334
+ project_id: import_v35.z.string().uuid(),
3335
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3336
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3337
+ name: import_v35.z.string(),
3338
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3339
+ config: import_v35.z.union([
3340
+ import_v35.z.object({
3341
+ event_type: import_v35.z.literal("logs"),
3342
+ btql_filter: import_v35.z.string(),
3343
+ interval_seconds: import_v35.z.number().gte(1).lte(2592e3),
3344
+ action: import_v35.z.object({ type: import_v35.z.literal("webhook"), url: import_v35.z.string() })
2327
3345
  }),
2328
- import_zod.z.object({
2329
- event_type: import_zod.z.literal("btql_export"),
2330
- export_definition: import_zod.z.union([
2331
- import_zod.z.object({ type: import_zod.z.literal("log_traces") }),
2332
- import_zod.z.object({ type: import_zod.z.literal("log_spans") }),
2333
- import_zod.z.object({ type: import_zod.z.literal("btql_query"), btql_query: import_zod.z.string() })
3346
+ import_v35.z.object({
3347
+ event_type: import_v35.z.literal("btql_export"),
3348
+ export_definition: import_v35.z.union([
3349
+ import_v35.z.object({ type: import_v35.z.literal("log_traces") }),
3350
+ import_v35.z.object({ type: import_v35.z.literal("log_spans") }),
3351
+ import_v35.z.object({ type: import_v35.z.literal("btql_query"), btql_query: import_v35.z.string() })
2334
3352
  ]),
2335
- export_path: import_zod.z.string(),
2336
- format: import_zod.z.enum(["jsonl", "parquet"]),
2337
- interval_seconds: import_zod.z.number().gte(1).lte(2592e3),
2338
- credentials: import_zod.z.object({
2339
- type: import_zod.z.literal("aws_iam"),
2340
- role_arn: import_zod.z.string(),
2341
- external_id: import_zod.z.string()
3353
+ export_path: import_v35.z.string(),
3354
+ format: import_v35.z.enum(["jsonl", "parquet"]),
3355
+ interval_seconds: import_v35.z.number().gte(1).lte(2592e3),
3356
+ credentials: import_v35.z.object({
3357
+ type: import_v35.z.literal("aws_iam"),
3358
+ role_arn: import_v35.z.string(),
3359
+ external_id: import_v35.z.string()
2342
3360
  }),
2343
- batch_size: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]).optional()
3361
+ batch_size: import_v35.z.union([import_v35.z.number(), import_v35.z.null()]).optional()
2344
3362
  }),
2345
- import_zod.z.object({
2346
- event_type: import_zod.z.literal("retention"),
3363
+ import_v35.z.object({
3364
+ event_type: import_v35.z.literal("retention"),
2347
3365
  object_type: RetentionObjectType,
2348
- retention_days: import_zod.z.number().gte(0)
3366
+ retention_days: import_v35.z.number().gte(0)
2349
3367
  })
2350
3368
  ])
2351
3369
  });
2352
- var ProjectLogsEvent = import_zod.z.object({
2353
- id: import_zod.z.string(),
2354
- _xact_id: import_zod.z.string(),
2355
- _pagination_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2356
- created: import_zod.z.string().datetime({ offset: true }),
2357
- org_id: import_zod.z.string().uuid(),
2358
- project_id: import_zod.z.string().uuid(),
2359
- log_id: import_zod.z.literal("g"),
2360
- input: import_zod.z.unknown().optional(),
2361
- output: import_zod.z.unknown().optional(),
2362
- expected: import_zod.z.unknown().optional(),
2363
- error: import_zod.z.unknown().optional(),
2364
- scores: import_zod.z.union([import_zod.z.record(import_zod.z.union([import_zod.z.number(), import_zod.z.null()])), import_zod.z.null()]).optional(),
2365
- metadata: import_zod.z.union([
2366
- import_zod.z.object({ model: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]) }).partial().passthrough(),
2367
- import_zod.z.null()
3370
+ var ProjectLogsEvent = import_v35.z.object({
3371
+ id: import_v35.z.string(),
3372
+ _xact_id: import_v35.z.string(),
3373
+ _pagination_key: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3374
+ created: import_v35.z.string().datetime({ offset: true }),
3375
+ org_id: import_v35.z.string().uuid(),
3376
+ project_id: import_v35.z.string().uuid(),
3377
+ log_id: import_v35.z.literal("g"),
3378
+ input: import_v35.z.unknown().optional(),
3379
+ output: import_v35.z.unknown().optional(),
3380
+ expected: import_v35.z.unknown().optional(),
3381
+ error: import_v35.z.unknown().optional(),
3382
+ scores: import_v35.z.union([import_v35.z.record(import_v35.z.union([import_v35.z.number(), import_v35.z.null()])), import_v35.z.null()]).optional(),
3383
+ metadata: import_v35.z.union([
3384
+ import_v35.z.object({ model: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]) }).partial().passthrough(),
3385
+ import_v35.z.null()
2368
3386
  ]).optional(),
2369
- tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
2370
- metrics: import_zod.z.union([import_zod.z.record(import_zod.z.number()), import_zod.z.null()]).optional(),
2371
- context: import_zod.z.union([
2372
- import_zod.z.object({
2373
- caller_functionname: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2374
- caller_filename: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2375
- caller_lineno: import_zod.z.union([import_zod.z.number(), import_zod.z.null()])
3387
+ tags: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional(),
3388
+ metrics: import_v35.z.union([import_v35.z.record(import_v35.z.number()), import_v35.z.null()]).optional(),
3389
+ context: import_v35.z.union([
3390
+ import_v35.z.object({
3391
+ caller_functionname: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3392
+ caller_filename: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3393
+ caller_lineno: import_v35.z.union([import_v35.z.number(), import_v35.z.null()])
2376
3394
  }).partial().passthrough(),
2377
- import_zod.z.null()
3395
+ import_v35.z.null()
2378
3396
  ]).optional(),
2379
- span_id: import_zod.z.string(),
2380
- span_parents: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
2381
- root_span_id: import_zod.z.string(),
2382
- is_root: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
3397
+ span_id: import_v35.z.string(),
3398
+ span_parents: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional(),
3399
+ root_span_id: import_v35.z.string(),
3400
+ is_root: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional(),
2383
3401
  span_attributes: SpanAttributes.optional(),
2384
3402
  origin: ObjectReferenceNullish.optional()
2385
3403
  });
2386
- var ProjectScoreType = import_zod.z.enum([
3404
+ var ProjectScoreType = import_v35.z.enum([
2387
3405
  "slider",
2388
3406
  "categorical",
2389
3407
  "weighted",
@@ -2392,172 +3410,172 @@ var ProjectScoreType = import_zod.z.enum([
2392
3410
  "online",
2393
3411
  "free-form"
2394
3412
  ]);
2395
- var ProjectScoreCategory = import_zod.z.object({
2396
- name: import_zod.z.string(),
2397
- value: import_zod.z.number()
3413
+ var ProjectScoreCategory = import_v35.z.object({
3414
+ name: import_v35.z.string(),
3415
+ value: import_v35.z.number()
2398
3416
  });
2399
- var ProjectScoreCategories = import_zod.z.union([
2400
- import_zod.z.array(ProjectScoreCategory),
2401
- import_zod.z.record(import_zod.z.number()),
2402
- import_zod.z.array(import_zod.z.string()),
2403
- import_zod.z.null()
3417
+ var ProjectScoreCategories = import_v35.z.union([
3418
+ import_v35.z.array(ProjectScoreCategory),
3419
+ import_v35.z.record(import_v35.z.number()),
3420
+ import_v35.z.array(import_v35.z.string()),
3421
+ import_v35.z.null()
2404
3422
  ]);
2405
- var ProjectScoreConfig = import_zod.z.union([
2406
- import_zod.z.object({
2407
- multi_select: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
2408
- destination: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
3423
+ var ProjectScoreConfig = import_v35.z.union([
3424
+ import_v35.z.object({
3425
+ multi_select: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]),
3426
+ destination: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
2409
3427
  online: OnlineScoreConfig
2410
3428
  }).partial(),
2411
- import_zod.z.null()
3429
+ import_v35.z.null()
2412
3430
  ]);
2413
- var ProjectScore = import_zod.z.object({
2414
- id: import_zod.z.string().uuid(),
2415
- project_id: import_zod.z.string().uuid(),
2416
- user_id: import_zod.z.string().uuid(),
2417
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2418
- name: import_zod.z.string(),
2419
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
3431
+ var ProjectScore = import_v35.z.object({
3432
+ id: import_v35.z.string().uuid(),
3433
+ project_id: import_v35.z.string().uuid(),
3434
+ user_id: import_v35.z.string().uuid(),
3435
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3436
+ name: import_v35.z.string(),
3437
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2420
3438
  score_type: ProjectScoreType,
2421
3439
  categories: ProjectScoreCategories.optional(),
2422
3440
  config: ProjectScoreConfig.optional(),
2423
- position: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3441
+ position: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2424
3442
  });
2425
- var ProjectTag = import_zod.z.object({
2426
- id: import_zod.z.string().uuid(),
2427
- project_id: import_zod.z.string().uuid(),
2428
- user_id: import_zod.z.string().uuid(),
2429
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2430
- name: import_zod.z.string(),
2431
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2432
- color: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2433
- position: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3443
+ var ProjectTag = import_v35.z.object({
3444
+ id: import_v35.z.string().uuid(),
3445
+ project_id: import_v35.z.string().uuid(),
3446
+ user_id: import_v35.z.string().uuid(),
3447
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3448
+ name: import_v35.z.string(),
3449
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3450
+ color: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3451
+ position: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2434
3452
  });
2435
- var Prompt = import_zod.z.object({
2436
- id: import_zod.z.string().uuid(),
2437
- _xact_id: import_zod.z.string(),
2438
- project_id: import_zod.z.string().uuid(),
2439
- log_id: import_zod.z.literal("p"),
2440
- org_id: import_zod.z.string().uuid(),
2441
- name: import_zod.z.string(),
2442
- slug: import_zod.z.string(),
2443
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2444
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
3453
+ var Prompt = import_v35.z.object({
3454
+ id: import_v35.z.string().uuid(),
3455
+ _xact_id: import_v35.z.string(),
3456
+ project_id: import_v35.z.string().uuid(),
3457
+ log_id: import_v35.z.literal("p"),
3458
+ org_id: import_v35.z.string().uuid(),
3459
+ name: import_v35.z.string(),
3460
+ slug: import_v35.z.string(),
3461
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3462
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2445
3463
  prompt_data: PromptDataNullish.optional(),
2446
- tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
2447
- metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional(),
3464
+ tags: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional(),
3465
+ metadata: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]).optional(),
2448
3466
  function_type: FunctionTypeEnumNullish.optional()
2449
3467
  });
2450
- var PromptOptions = import_zod.z.object({ model: import_zod.z.string(), params: ModelParams, position: import_zod.z.string() }).partial();
2451
- var PromptSessionEvent = import_zod.z.object({
2452
- id: import_zod.z.string(),
2453
- _xact_id: import_zod.z.string(),
2454
- created: import_zod.z.string().datetime({ offset: true }),
2455
- _pagination_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2456
- project_id: import_zod.z.string().uuid(),
2457
- prompt_session_id: import_zod.z.string().uuid(),
2458
- prompt_session_data: import_zod.z.unknown().optional(),
2459
- prompt_data: import_zod.z.unknown().optional(),
2460
- function_data: import_zod.z.unknown().optional(),
3468
+ var PromptOptions = import_v35.z.object({ model: import_v35.z.string(), params: ModelParams, position: import_v35.z.string() }).partial();
3469
+ var PromptSessionEvent = import_v35.z.object({
3470
+ id: import_v35.z.string(),
3471
+ _xact_id: import_v35.z.string(),
3472
+ created: import_v35.z.string().datetime({ offset: true }),
3473
+ _pagination_key: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3474
+ project_id: import_v35.z.string().uuid(),
3475
+ prompt_session_id: import_v35.z.string().uuid(),
3476
+ prompt_session_data: import_v35.z.unknown().optional(),
3477
+ prompt_data: import_v35.z.unknown().optional(),
3478
+ function_data: import_v35.z.unknown().optional(),
2461
3479
  function_type: FunctionTypeEnumNullish.optional(),
2462
- object_data: import_zod.z.unknown().optional(),
2463
- completion: import_zod.z.unknown().optional(),
2464
- tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional()
3480
+ object_data: import_v35.z.unknown().optional(),
3481
+ completion: import_v35.z.unknown().optional(),
3482
+ tags: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]).optional()
2465
3483
  });
2466
- var ResponseFormat = import_zod.z.union([
2467
- import_zod.z.object({ type: import_zod.z.literal("json_object") }),
2468
- import_zod.z.object({
2469
- type: import_zod.z.literal("json_schema"),
3484
+ var ResponseFormat = import_v35.z.union([
3485
+ import_v35.z.object({ type: import_v35.z.literal("json_object") }),
3486
+ import_v35.z.object({
3487
+ type: import_v35.z.literal("json_schema"),
2470
3488
  json_schema: ResponseFormatJsonSchema
2471
3489
  }),
2472
- import_zod.z.object({ type: import_zod.z.literal("text") })
3490
+ import_v35.z.object({ type: import_v35.z.literal("text") })
2473
3491
  ]);
2474
- var Role = import_zod.z.object({
2475
- id: import_zod.z.string().uuid(),
2476
- org_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2477
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2478
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2479
- name: import_zod.z.string(),
2480
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2481
- deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2482
- member_permissions: import_zod.z.union([
2483
- import_zod.z.array(
2484
- import_zod.z.object({
3492
+ var Role = import_v35.z.object({
3493
+ id: import_v35.z.string().uuid(),
3494
+ org_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3495
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3496
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3497
+ name: import_v35.z.string(),
3498
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3499
+ deleted_at: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3500
+ member_permissions: import_v35.z.union([
3501
+ import_v35.z.array(
3502
+ import_v35.z.object({
2485
3503
  permission: Permission,
2486
3504
  restrict_object_type: AclObjectType.optional()
2487
3505
  })
2488
3506
  ),
2489
- import_zod.z.null()
3507
+ import_v35.z.null()
2490
3508
  ]).optional(),
2491
- member_roles: import_zod.z.union([import_zod.z.array(import_zod.z.string().uuid()), import_zod.z.null()]).optional()
3509
+ member_roles: import_v35.z.union([import_v35.z.array(import_v35.z.string().uuid()), import_v35.z.null()]).optional()
2492
3510
  });
2493
- var RunEval = import_zod.z.object({
2494
- project_id: import_zod.z.string(),
2495
- data: import_zod.z.union([
2496
- import_zod.z.object({
2497
- dataset_id: import_zod.z.string(),
2498
- _internal_btql: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional()
3511
+ var RunEval = import_v35.z.object({
3512
+ project_id: import_v35.z.string(),
3513
+ data: import_v35.z.union([
3514
+ import_v35.z.object({
3515
+ dataset_id: import_v35.z.string(),
3516
+ _internal_btql: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]).optional()
2499
3517
  }),
2500
- import_zod.z.object({
2501
- project_name: import_zod.z.string(),
2502
- dataset_name: import_zod.z.string(),
2503
- _internal_btql: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional()
3518
+ import_v35.z.object({
3519
+ project_name: import_v35.z.string(),
3520
+ dataset_name: import_v35.z.string(),
3521
+ _internal_btql: import_v35.z.union([import_v35.z.object({}).partial().passthrough(), import_v35.z.null()]).optional()
2504
3522
  }),
2505
- import_zod.z.object({ data: import_zod.z.array(import_zod.z.unknown()) })
3523
+ import_v35.z.object({ data: import_v35.z.array(import_v35.z.unknown()) })
2506
3524
  ]),
2507
- task: FunctionId.and(import_zod.z.unknown()),
2508
- scores: import_zod.z.array(FunctionId),
2509
- experiment_name: import_zod.z.string().optional(),
2510
- metadata: import_zod.z.object({}).partial().passthrough().optional(),
2511
- parent: InvokeParent.and(import_zod.z.unknown()).optional(),
2512
- stream: import_zod.z.boolean().optional(),
2513
- trial_count: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]).optional(),
2514
- is_public: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
2515
- timeout: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]).optional(),
2516
- max_concurrency: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]).optional().default(10),
2517
- base_experiment_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2518
- base_experiment_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
3525
+ task: FunctionId.and(import_v35.z.unknown()),
3526
+ scores: import_v35.z.array(FunctionId),
3527
+ experiment_name: import_v35.z.string().optional(),
3528
+ metadata: import_v35.z.object({}).partial().passthrough().optional(),
3529
+ parent: InvokeParent.and(import_v35.z.unknown()).optional(),
3530
+ stream: import_v35.z.boolean().optional(),
3531
+ trial_count: import_v35.z.union([import_v35.z.number(), import_v35.z.null()]).optional(),
3532
+ is_public: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional(),
3533
+ timeout: import_v35.z.union([import_v35.z.number(), import_v35.z.null()]).optional(),
3534
+ max_concurrency: import_v35.z.union([import_v35.z.number(), import_v35.z.null()]).optional().default(10),
3535
+ base_experiment_name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3536
+ base_experiment_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2519
3537
  git_metadata_settings: GitMetadataSettings.and(
2520
- import_zod.z.union([import_zod.z.object({}).partial(), import_zod.z.null()])
3538
+ import_v35.z.union([import_v35.z.object({}).partial(), import_v35.z.null()])
2521
3539
  ).optional(),
2522
- repo_info: RepoInfo.and(import_zod.z.unknown()).optional(),
2523
- strict: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
2524
- stop_token: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2525
- extra_messages: import_zod.z.string().optional(),
2526
- tags: import_zod.z.array(import_zod.z.string()).optional()
3540
+ repo_info: RepoInfo.and(import_v35.z.unknown()).optional(),
3541
+ strict: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional(),
3542
+ stop_token: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3543
+ extra_messages: import_v35.z.string().optional(),
3544
+ tags: import_v35.z.array(import_v35.z.string()).optional()
2527
3545
  });
2528
- var ServiceToken = import_zod.z.object({
2529
- id: import_zod.z.string().uuid(),
2530
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2531
- name: import_zod.z.string(),
2532
- preview_name: import_zod.z.string(),
2533
- service_account_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2534
- service_account_email: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2535
- service_account_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2536
- org_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3546
+ var ServiceToken = import_v35.z.object({
3547
+ id: import_v35.z.string().uuid(),
3548
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3549
+ name: import_v35.z.string(),
3550
+ preview_name: import_v35.z.string(),
3551
+ service_account_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3552
+ service_account_email: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3553
+ service_account_name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3554
+ org_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2537
3555
  });
2538
- var SpanIFrame = import_zod.z.object({
2539
- id: import_zod.z.string().uuid(),
2540
- project_id: import_zod.z.string().uuid(),
2541
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2542
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2543
- deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2544
- name: import_zod.z.string(),
2545
- description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2546
- url: import_zod.z.string(),
2547
- post_message: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
3556
+ var SpanIFrame = import_v35.z.object({
3557
+ id: import_v35.z.string().uuid(),
3558
+ project_id: import_v35.z.string().uuid(),
3559
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3560
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3561
+ deleted_at: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3562
+ name: import_v35.z.string(),
3563
+ description: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3564
+ url: import_v35.z.string(),
3565
+ post_message: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional()
2548
3566
  });
2549
- var SSEConsoleEventData = import_zod.z.object({
2550
- stream: import_zod.z.enum(["stderr", "stdout"]),
2551
- message: import_zod.z.string()
3567
+ var SSEConsoleEventData = import_v35.z.object({
3568
+ stream: import_v35.z.enum(["stderr", "stdout"]),
3569
+ message: import_v35.z.string()
2552
3570
  });
2553
- var SSEProgressEventData = import_zod.z.object({
2554
- id: import_zod.z.string(),
3571
+ var SSEProgressEventData = import_v35.z.object({
3572
+ id: import_v35.z.string(),
2555
3573
  object_type: FunctionObjectType,
2556
- origin: ObjectReferenceNullish.and(import_zod.z.unknown()).optional(),
3574
+ origin: ObjectReferenceNullish.and(import_v35.z.unknown()).optional(),
2557
3575
  format: FunctionFormat,
2558
3576
  output_type: FunctionOutputType,
2559
- name: import_zod.z.string(),
2560
- event: import_zod.z.enum([
3577
+ name: import_v35.z.string(),
3578
+ event: import_v35.z.enum([
2561
3579
  "reasoning_delta",
2562
3580
  "text_delta",
2563
3581
  "json_delta",
@@ -2567,110 +3585,110 @@ var SSEProgressEventData = import_zod.z.object({
2567
3585
  "done",
2568
3586
  "progress"
2569
3587
  ]),
2570
- data: import_zod.z.string()
3588
+ data: import_v35.z.string()
2571
3589
  });
2572
- var ToolFunctionDefinition = import_zod.z.object({
2573
- type: import_zod.z.literal("function"),
2574
- function: import_zod.z.object({
2575
- name: import_zod.z.string(),
2576
- description: import_zod.z.string().optional(),
2577
- parameters: import_zod.z.object({}).partial().passthrough().optional(),
2578
- strict: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
3590
+ var ToolFunctionDefinition = import_v35.z.object({
3591
+ type: import_v35.z.literal("function"),
3592
+ function: import_v35.z.object({
3593
+ name: import_v35.z.string(),
3594
+ description: import_v35.z.string().optional(),
3595
+ parameters: import_v35.z.object({}).partial().passthrough().optional(),
3596
+ strict: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]).optional()
2579
3597
  })
2580
3598
  });
2581
- var User = import_zod.z.object({
2582
- id: import_zod.z.string().uuid(),
2583
- given_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2584
- family_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2585
- email: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2586
- avatar_url: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2587
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3599
+ var User = import_v35.z.object({
3600
+ id: import_v35.z.string().uuid(),
3601
+ given_name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3602
+ family_name: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3603
+ email: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3604
+ avatar_url: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3605
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2588
3606
  });
2589
- var ViewDataSearch = import_zod.z.union([
2590
- import_zod.z.object({
2591
- filter: import_zod.z.union([import_zod.z.array(import_zod.z.unknown()), import_zod.z.null()]),
2592
- tag: import_zod.z.union([import_zod.z.array(import_zod.z.unknown()), import_zod.z.null()]),
2593
- match: import_zod.z.union([import_zod.z.array(import_zod.z.unknown()), import_zod.z.null()]),
2594
- sort: import_zod.z.union([import_zod.z.array(import_zod.z.unknown()), import_zod.z.null()])
3607
+ var ViewDataSearch = import_v35.z.union([
3608
+ import_v35.z.object({
3609
+ filter: import_v35.z.union([import_v35.z.array(import_v35.z.unknown()), import_v35.z.null()]),
3610
+ tag: import_v35.z.union([import_v35.z.array(import_v35.z.unknown()), import_v35.z.null()]),
3611
+ match: import_v35.z.union([import_v35.z.array(import_v35.z.unknown()), import_v35.z.null()]),
3612
+ sort: import_v35.z.union([import_v35.z.array(import_v35.z.unknown()), import_v35.z.null()])
2595
3613
  }).partial(),
2596
- import_zod.z.null()
3614
+ import_v35.z.null()
2597
3615
  ]);
2598
- var ViewData = import_zod.z.union([
2599
- import_zod.z.object({ search: ViewDataSearch }).partial(),
2600
- import_zod.z.null()
3616
+ var ViewData = import_v35.z.union([
3617
+ import_v35.z.object({ search: ViewDataSearch }).partial(),
3618
+ import_v35.z.null()
2601
3619
  ]);
2602
- var ViewOptions = import_zod.z.union([
2603
- import_zod.z.object({
2604
- viewType: import_zod.z.literal("monitor"),
2605
- options: import_zod.z.object({
2606
- spanType: import_zod.z.union([import_zod.z.enum(["range", "frame"]), import_zod.z.null()]),
2607
- rangeValue: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2608
- frameStart: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2609
- frameEnd: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2610
- tzUTC: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
2611
- chartVisibility: import_zod.z.union([import_zod.z.record(import_zod.z.boolean()), import_zod.z.null()]),
2612
- projectId: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2613
- type: import_zod.z.union([import_zod.z.enum(["project", "experiment"]), import_zod.z.null()]),
2614
- groupBy: import_zod.z.union([import_zod.z.string(), import_zod.z.null()])
3620
+ var ViewOptions = import_v35.z.union([
3621
+ import_v35.z.object({
3622
+ viewType: import_v35.z.literal("monitor"),
3623
+ options: import_v35.z.object({
3624
+ spanType: import_v35.z.union([import_v35.z.enum(["range", "frame"]), import_v35.z.null()]),
3625
+ rangeValue: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3626
+ frameStart: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3627
+ frameEnd: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3628
+ tzUTC: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]),
3629
+ chartVisibility: import_v35.z.union([import_v35.z.record(import_v35.z.boolean()), import_v35.z.null()]),
3630
+ projectId: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3631
+ type: import_v35.z.union([import_v35.z.enum(["project", "experiment"]), import_v35.z.null()]),
3632
+ groupBy: import_v35.z.union([import_v35.z.string(), import_v35.z.null()])
2615
3633
  }).partial()
2616
3634
  }),
2617
- import_zod.z.object({
2618
- columnVisibility: import_zod.z.union([import_zod.z.record(import_zod.z.boolean()), import_zod.z.null()]),
2619
- columnOrder: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]),
2620
- columnSizing: import_zod.z.union([import_zod.z.record(import_zod.z.number()), import_zod.z.null()]),
2621
- grouping: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2622
- rowHeight: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2623
- tallGroupRows: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
2624
- layout: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2625
- chartHeight: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]),
2626
- excludedMeasures: import_zod.z.union([
2627
- import_zod.z.array(
2628
- import_zod.z.object({
2629
- type: import_zod.z.enum(["none", "score", "metric", "metadata"]),
2630
- value: import_zod.z.string()
3635
+ import_v35.z.object({
3636
+ columnVisibility: import_v35.z.union([import_v35.z.record(import_v35.z.boolean()), import_v35.z.null()]),
3637
+ columnOrder: import_v35.z.union([import_v35.z.array(import_v35.z.string()), import_v35.z.null()]),
3638
+ columnSizing: import_v35.z.union([import_v35.z.record(import_v35.z.number()), import_v35.z.null()]),
3639
+ grouping: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3640
+ rowHeight: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3641
+ tallGroupRows: import_v35.z.union([import_v35.z.boolean(), import_v35.z.null()]),
3642
+ layout: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3643
+ chartHeight: import_v35.z.union([import_v35.z.number(), import_v35.z.null()]),
3644
+ excludedMeasures: import_v35.z.union([
3645
+ import_v35.z.array(
3646
+ import_v35.z.object({
3647
+ type: import_v35.z.enum(["none", "score", "metric", "metadata"]),
3648
+ value: import_v35.z.string()
2631
3649
  })
2632
3650
  ),
2633
- import_zod.z.null()
3651
+ import_v35.z.null()
2634
3652
  ]),
2635
- yMetric: import_zod.z.union([
2636
- import_zod.z.object({
2637
- type: import_zod.z.enum(["none", "score", "metric", "metadata"]),
2638
- value: import_zod.z.string()
3653
+ yMetric: import_v35.z.union([
3654
+ import_v35.z.object({
3655
+ type: import_v35.z.enum(["none", "score", "metric", "metadata"]),
3656
+ value: import_v35.z.string()
2639
3657
  }),
2640
- import_zod.z.null()
3658
+ import_v35.z.null()
2641
3659
  ]),
2642
- xAxis: import_zod.z.union([
2643
- import_zod.z.object({
2644
- type: import_zod.z.enum(["none", "score", "metric", "metadata"]),
2645
- value: import_zod.z.string()
3660
+ xAxis: import_v35.z.union([
3661
+ import_v35.z.object({
3662
+ type: import_v35.z.enum(["none", "score", "metric", "metadata"]),
3663
+ value: import_v35.z.string()
2646
3664
  }),
2647
- import_zod.z.null()
3665
+ import_v35.z.null()
2648
3666
  ]),
2649
- symbolGrouping: import_zod.z.union([
2650
- import_zod.z.object({
2651
- type: import_zod.z.enum(["none", "score", "metric", "metadata"]),
2652
- value: import_zod.z.string()
3667
+ symbolGrouping: import_v35.z.union([
3668
+ import_v35.z.object({
3669
+ type: import_v35.z.enum(["none", "score", "metric", "metadata"]),
3670
+ value: import_v35.z.string()
2653
3671
  }),
2654
- import_zod.z.null()
3672
+ import_v35.z.null()
2655
3673
  ]),
2656
- xAxisAggregation: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
2657
- chartAnnotations: import_zod.z.union([
2658
- import_zod.z.array(import_zod.z.object({ id: import_zod.z.string(), text: import_zod.z.string() })),
2659
- import_zod.z.null()
3674
+ xAxisAggregation: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]),
3675
+ chartAnnotations: import_v35.z.union([
3676
+ import_v35.z.array(import_v35.z.object({ id: import_v35.z.string(), text: import_v35.z.string() })),
3677
+ import_v35.z.null()
2660
3678
  ]),
2661
- timeRangeFilter: import_zod.z.union([
2662
- import_zod.z.string(),
2663
- import_zod.z.object({ from: import_zod.z.string(), to: import_zod.z.string() }),
2664
- import_zod.z.null()
3679
+ timeRangeFilter: import_v35.z.union([
3680
+ import_v35.z.string(),
3681
+ import_v35.z.object({ from: import_v35.z.string(), to: import_v35.z.string() }),
3682
+ import_v35.z.null()
2665
3683
  ])
2666
3684
  }).partial(),
2667
- import_zod.z.null()
3685
+ import_v35.z.null()
2668
3686
  ]);
2669
- var View = import_zod.z.object({
2670
- id: import_zod.z.string().uuid(),
2671
- object_type: AclObjectType.and(import_zod.z.string()),
2672
- object_id: import_zod.z.string().uuid(),
2673
- view_type: import_zod.z.enum([
3687
+ var View = import_v35.z.object({
3688
+ id: import_v35.z.string().uuid(),
3689
+ object_type: AclObjectType.and(import_v35.z.string()),
3690
+ object_id: import_v35.z.string().uuid(),
3691
+ view_type: import_v35.z.enum([
2674
3692
  "projects",
2675
3693
  "experiments",
2676
3694
  "experiment",
@@ -2685,54 +3703,54 @@ var View = import_zod.z.object({
2685
3703
  "agents",
2686
3704
  "monitor"
2687
3705
  ]),
2688
- name: import_zod.z.string(),
2689
- created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
3706
+ name: import_v35.z.string(),
3707
+ created: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
2690
3708
  view_data: ViewData.optional(),
2691
3709
  options: ViewOptions.optional(),
2692
- user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
2693
- deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
3710
+ user_id: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional(),
3711
+ deleted_at: import_v35.z.union([import_v35.z.string(), import_v35.z.null()]).optional()
2694
3712
  });
2695
3713
 
2696
3714
  // src/logger.ts
2697
3715
  var import_functions = require("@vercel/functions");
2698
3716
  var import_mustache2 = __toESM(require("mustache"));
2699
- var import_zod3 = require("zod");
3717
+ var import_zod = require("zod");
2700
3718
 
2701
3719
  // src/functions/stream.ts
2702
3720
  var import_eventsource_parser = require("eventsource-parser");
2703
- var import_zod2 = require("zod");
2704
- var braintrustStreamChunkSchema = import_zod2.z.union([
2705
- import_zod2.z.object({
2706
- type: import_zod2.z.literal("text_delta"),
2707
- data: import_zod2.z.string()
3721
+ var import_v36 = require("zod/v3");
3722
+ var braintrustStreamChunkSchema = import_v36.z.union([
3723
+ import_v36.z.object({
3724
+ type: import_v36.z.literal("text_delta"),
3725
+ data: import_v36.z.string()
2708
3726
  }),
2709
- import_zod2.z.object({
2710
- type: import_zod2.z.literal("reasoning_delta"),
2711
- data: import_zod2.z.string()
3727
+ import_v36.z.object({
3728
+ type: import_v36.z.literal("reasoning_delta"),
3729
+ data: import_v36.z.string()
2712
3730
  }),
2713
- import_zod2.z.object({
2714
- type: import_zod2.z.literal("json_delta"),
2715
- data: import_zod2.z.string()
3731
+ import_v36.z.object({
3732
+ type: import_v36.z.literal("json_delta"),
3733
+ data: import_v36.z.string()
2716
3734
  }),
2717
- import_zod2.z.object({
2718
- type: import_zod2.z.literal("error"),
2719
- data: import_zod2.z.string()
3735
+ import_v36.z.object({
3736
+ type: import_v36.z.literal("error"),
3737
+ data: import_v36.z.string()
2720
3738
  }),
2721
- import_zod2.z.object({
2722
- type: import_zod2.z.literal("console"),
3739
+ import_v36.z.object({
3740
+ type: import_v36.z.literal("console"),
2723
3741
  data: SSEConsoleEventData
2724
3742
  }),
2725
- import_zod2.z.object({
2726
- type: import_zod2.z.literal("progress"),
3743
+ import_v36.z.object({
3744
+ type: import_v36.z.literal("progress"),
2727
3745
  data: SSEProgressEventData
2728
3746
  }),
2729
- import_zod2.z.object({
2730
- type: import_zod2.z.literal("start"),
2731
- data: import_zod2.z.string()
3747
+ import_v36.z.object({
3748
+ type: import_v36.z.literal("start"),
3749
+ data: import_v36.z.string()
2732
3750
  }),
2733
- import_zod2.z.object({
2734
- type: import_zod2.z.literal("done"),
2735
- data: import_zod2.z.string()
3751
+ import_v36.z.object({
3752
+ type: import_v36.z.literal("done"),
3753
+ data: import_v36.z.string()
2736
3754
  })
2737
3755
  ]);
2738
3756
  var BraintrustStream = class _BraintrustStream {
@@ -3268,7 +4286,7 @@ function runCatchFinally(f, catchF, finallyF) {
3268
4286
  function getCurrentUnixTimestamp() {
3269
4287
  return (/* @__PURE__ */ new Date()).getTime() / 1e3;
3270
4288
  }
3271
- function isEmpty(a) {
4289
+ function isEmpty2(a) {
3272
4290
  return a === void 0 || a === null;
3273
4291
  }
3274
4292
  var LazyValue = class {
@@ -3341,13 +4359,12 @@ var InternalAbortError = class extends Error {
3341
4359
  };
3342
4360
 
3343
4361
  // src/mustache-utils.ts
3344
- var import_core = require("@braintrust/core");
3345
4362
  var import_mustache = __toESM(require("mustache"));
3346
4363
  function lintTemplate(template, context2) {
3347
4364
  const variables = getMustacheVars(template);
3348
4365
  for (const variable of variables) {
3349
4366
  const arrPathsReplaced = variable[1].replaceAll(/\.\d+/g, ".0");
3350
- const fieldExists = (0, import_core.getObjValueByPath)(context2, arrPathsReplaced.split(".")) !== void 0;
4367
+ const fieldExists = getObjValueByPath(context2, arrPathsReplaced.split(".")) !== void 0;
3351
4368
  if (!fieldExists) {
3352
4369
  throw new Error(`Variable '${variable[1]}' does not exist.`);
3353
4370
  }
@@ -3364,7 +4381,6 @@ function getMustacheVars(prompt) {
3364
4381
  }
3365
4382
 
3366
4383
  // src/logger.ts
3367
- var import_core3 = require("@braintrust/core");
3368
4384
  var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
3369
4385
  var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
3370
4386
  var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
@@ -3452,14 +4468,14 @@ var NoopSpan = class {
3452
4468
  };
3453
4469
  var NOOP_SPAN = new NoopSpan();
3454
4470
  var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
3455
- var loginSchema = import_zod3.z.strictObject({
3456
- appUrl: import_zod3.z.string(),
3457
- appPublicUrl: import_zod3.z.string(),
3458
- orgName: import_zod3.z.string(),
3459
- apiUrl: import_zod3.z.string(),
3460
- proxyUrl: import_zod3.z.string(),
3461
- loginToken: import_zod3.z.string(),
3462
- orgId: import_zod3.z.string().nullish(),
4471
+ var loginSchema = import_zod.z.strictObject({
4472
+ appUrl: import_zod.z.string(),
4473
+ appPublicUrl: import_zod.z.string(),
4474
+ orgName: import_zod.z.string(),
4475
+ apiUrl: import_zod.z.string(),
4476
+ proxyUrl: import_zod.z.string(),
4477
+ loginToken: import_zod.z.string(),
4478
+ orgId: import_zod.z.string().nullish(),
3463
4479
  gitMetadataSettings: GitMetadataSettings.nullish()
3464
4480
  });
3465
4481
  var stateNonce = 0;
@@ -3612,7 +4628,7 @@ var BraintrustState = class _BraintrustState {
3612
4628
  const newState = await loginToState({
3613
4629
  ...this.loginParams,
3614
4630
  ...Object.fromEntries(
3615
- Object.entries(loginParams).filter(([k, v]) => !isEmpty(v))
4631
+ Object.entries(loginParams).filter(([k, v]) => !isEmpty2(v))
3616
4632
  )
3617
4633
  });
3618
4634
  this.copyLoginInfo(newState);
@@ -3748,7 +4764,7 @@ var HTTPConnection = class _HTTPConnection {
3748
4764
  }
3749
4765
  async get(path9, params = void 0, config3) {
3750
4766
  const { headers, ...rest } = config3 || {};
3751
- const url = new URL((0, import_core2._urljoin)(this.base_url, path9));
4767
+ const url = new URL(_urljoin(this.base_url, path9));
3752
4768
  url.search = new URLSearchParams(
3753
4769
  params ? Object.entries(params).filter(([_, v]) => v !== void 0).flatMap(
3754
4770
  ([k, v]) => v !== void 0 ? typeof v === "string" ? [[k, v]] : v.map((x) => [k, x]) : []
@@ -3775,7 +4791,7 @@ var HTTPConnection = class _HTTPConnection {
3775
4791
  const this_base_url = this.base_url;
3776
4792
  const this_headers = this.headers;
3777
4793
  return await checkResponse(
3778
- await this_fetch((0, import_core2._urljoin)(this_base_url, path9), {
4794
+ await this_fetch(_urljoin(this_base_url, path9), {
3779
4795
  method: "POST",
3780
4796
  headers: {
3781
4797
  Accept: "application/json",
@@ -3912,12 +4928,12 @@ var Attachment = class extends BaseAttachment {
3912
4928
  let signedUrl;
3913
4929
  let headers;
3914
4930
  try {
3915
- ({ signedUrl, headers } = import_zod3.z.object({
3916
- signedUrl: import_zod3.z.string().url(),
3917
- headers: import_zod3.z.record(import_zod3.z.string())
4931
+ ({ signedUrl, headers } = import_zod.z.object({
4932
+ signedUrl: import_zod.z.string().url(),
4933
+ headers: import_zod.z.record(import_zod.z.string())
3918
4934
  }).parse(await metadataResponse.json()));
3919
4935
  } catch (error2) {
3920
- if (error2 instanceof import_zod3.ZodError) {
4936
+ if (error2 instanceof import_zod.ZodError) {
3921
4937
  const errorStr = JSON.stringify(error2.flatten());
3922
4938
  throw new Error(`Invalid response from API server: ${errorStr}`);
3923
4939
  }
@@ -4002,8 +5018,8 @@ with a Blob/ArrayBuffer, or run the program on Node.js.`
4002
5018
  }
4003
5019
  }
4004
5020
  };
4005
- var attachmentMetadataSchema = import_zod3.z.object({
4006
- downloadUrl: import_zod3.z.string(),
5021
+ var attachmentMetadataSchema = import_zod.z.object({
5022
+ downloadUrl: import_zod.z.string(),
4007
5023
  status: AttachmentStatus
4008
5024
  });
4009
5025
  var ReadonlyAttachment = class {
@@ -4103,10 +5119,10 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
4103
5119
  source: inputSource
4104
5120
  }) {
4105
5121
  const source = inputSource ?? "external";
4106
- if (!import_core2.VALID_SOURCES.includes(source)) {
4107
- throw new Error(`source must be one of ${import_core2.VALID_SOURCES}`);
5122
+ if (!VALID_SOURCES.includes(source)) {
5123
+ throw new Error(`source must be one of ${VALID_SOURCES}`);
4108
5124
  }
4109
- if (isEmpty(scores) && isEmpty(expected) && isEmpty(tags) && isEmpty(comment)) {
5125
+ if (isEmpty2(scores) && isEmpty2(expected) && isEmpty2(tags) && isEmpty2(comment)) {
4110
5126
  throw new Error(
4111
5127
  "At least one of scores, expected, tags, or comment must be specified"
4112
5128
  );
@@ -4119,9 +5135,9 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
4119
5135
  });
4120
5136
  let { metadata, ...updateEvent } = deepCopyEvent(validatedEvent);
4121
5137
  updateEvent = Object.fromEntries(
4122
- Object.entries(updateEvent).filter(([_, v]) => !isEmpty(v))
5138
+ Object.entries(updateEvent).filter(([_, v]) => !isEmpty2(v))
4123
5139
  );
4124
- const parentIds = async () => new import_core2.SpanComponentsV3({
5140
+ const parentIds = async () => new SpanComponentsV3({
4125
5141
  object_type: parentObjectType,
4126
5142
  object_id: await parentObjectId.get()
4127
5143
  }).objectIdFields();
@@ -4131,14 +5147,14 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
4131
5147
  id,
4132
5148
  ...updateEvent,
4133
5149
  ...await parentIds(),
4134
- [import_core2.AUDIT_SOURCE_FIELD]: source,
4135
- [import_core2.AUDIT_METADATA_FIELD]: metadata,
4136
- [import_core2.IS_MERGE_FIELD]: true
5150
+ [AUDIT_SOURCE_FIELD]: source,
5151
+ [AUDIT_METADATA_FIELD]: metadata,
5152
+ [IS_MERGE_FIELD]: true
4137
5153
  };
4138
5154
  });
4139
5155
  state.bgLogger().log([record]);
4140
5156
  }
4141
- if (!isEmpty(comment)) {
5157
+ if (!isEmpty2(comment)) {
4142
5158
  const record = new LazyValue(async () => {
4143
5159
  return {
4144
5160
  id: (0, import_uuid.v4)(),
@@ -4152,8 +5168,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
4152
5168
  text: comment
4153
5169
  },
4154
5170
  ...await parentIds(),
4155
- [import_core2.AUDIT_SOURCE_FIELD]: source,
4156
- [import_core2.AUDIT_METADATA_FIELD]: metadata
5171
+ [AUDIT_SOURCE_FIELD]: source,
5172
+ [AUDIT_METADATA_FIELD]: metadata
4157
5173
  };
4158
5174
  });
4159
5175
  state.bgLogger().log([record]);
@@ -4172,7 +5188,7 @@ function updateSpanImpl({
4172
5188
  ...event
4173
5189
  })
4174
5190
  );
4175
- const parentIds = async () => new import_core2.SpanComponentsV3({
5191
+ const parentIds = async () => new SpanComponentsV3({
4176
5192
  object_type: parentObjectType,
4177
5193
  object_id: await parentObjectId.get()
4178
5194
  }).objectIdFields();
@@ -4180,7 +5196,7 @@ function updateSpanImpl({
4180
5196
  id,
4181
5197
  ...updateEvent,
4182
5198
  ...await parentIds(),
4183
- [import_core2.IS_MERGE_FIELD]: true
5199
+ [IS_MERGE_FIELD]: true
4184
5200
  }));
4185
5201
  state.bgLogger().log([record]);
4186
5202
  }
@@ -4195,15 +5211,15 @@ function spanComponentsToObjectIdLambda(state, components) {
4195
5211
  );
4196
5212
  }
4197
5213
  switch (components.data.object_type) {
4198
- case import_core2.SpanObjectTypeV3.EXPERIMENT:
5214
+ case 1 /* EXPERIMENT */:
4199
5215
  throw new Error(
4200
5216
  "Impossible: computeObjectMetadataArgs not supported for experiments"
4201
5217
  );
4202
- case import_core2.SpanObjectTypeV3.PLAYGROUND_LOGS:
5218
+ case 3 /* PLAYGROUND_LOGS */:
4203
5219
  throw new Error(
4204
5220
  "Impossible: computeObjectMetadataArgs not supported for prompt sessions"
4205
5221
  );
4206
- case import_core2.SpanObjectTypeV3.PROJECT_LOGS:
5222
+ case 2 /* PROJECT_LOGS */:
4207
5223
  return async () => (await computeLoggerMetadata(state, {
4208
5224
  ...components.data.compute_object_metadata_args
4209
5225
  })).project.id;
@@ -4254,8 +5270,8 @@ async function permalink(slug, opts) {
4254
5270
  return state.appUrl;
4255
5271
  };
4256
5272
  try {
4257
- const components = import_core2.SpanComponentsV3.fromStr(slug);
4258
- const object_type = (0, import_core2.spanObjectTypeV3ToString)(components.data.object_type);
5273
+ const components = SpanComponentsV3.fromStr(slug);
5274
+ const object_type = spanObjectTypeV3ToString(components.data.object_type);
4259
5275
  const [orgName, appUrl, object_id] = await Promise.all([
4260
5276
  getOrgName(),
4261
5277
  getAppUrl(),
@@ -4282,7 +5298,7 @@ function startSpanParentArgs(args) {
4282
5298
  if (args.parentSpanIds) {
4283
5299
  throw new Error("Cannot specify both parent and parentSpanIds");
4284
5300
  }
4285
- const parentComponents = import_core2.SpanComponentsV3.fromStr(args.parent);
5301
+ const parentComponents = SpanComponentsV3.fromStr(args.parent);
4286
5302
  if (args.parentObjectType !== parentComponents.data.object_type) {
4287
5303
  throw new Error(
4288
5304
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -4355,7 +5371,7 @@ var Logger = class {
4355
5371
  return (async () => (await this.project).id)();
4356
5372
  }
4357
5373
  parentObjectType() {
4358
- return import_core2.SpanObjectTypeV3.PROJECT_LOGS;
5374
+ return 2 /* PROJECT_LOGS */;
4359
5375
  }
4360
5376
  /**
4361
5377
  * Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
@@ -4449,7 +5465,7 @@ var Logger = class {
4449
5465
  parentSpanIds: args?.parentSpanIds,
4450
5466
  propagatedEvent: args?.propagatedEvent
4451
5467
  }),
4452
- defaultRootType: import_core2.SpanTypeAttribute.TASK
5468
+ defaultRootType: "task" /* TASK */
4453
5469
  });
4454
5470
  }
4455
5471
  /**
@@ -4491,7 +5507,7 @@ var Logger = class {
4491
5507
  * See {@link Span.startSpan} for more details.
4492
5508
  */
4493
5509
  async export() {
4494
- return new import_core2.SpanComponentsV3({
5510
+ return new SpanComponentsV3({
4495
5511
  object_type: this.parentObjectType(),
4496
5512
  ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
4497
5513
  }).toStr();
@@ -4516,7 +5532,7 @@ function castLogger(logger, asyncFlush) {
4516
5532
  return logger;
4517
5533
  }
4518
5534
  function constructLogs3Data(items) {
4519
- return `{"rows": ${(0, import_core2.constructJsonArray)(items)}, "api_version": 2}`;
5535
+ return `{"rows": ${constructJsonArray(items)}, "api_version": 2}`;
4520
5536
  }
4521
5537
  function now() {
4522
5538
  return (/* @__PURE__ */ new Date()).getTime();
@@ -4642,7 +5658,7 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
4642
5658
  const allItemsStr = allItems.map(
4643
5659
  (bucket) => bucket.map((item) => JSON.stringify(item))
4644
5660
  );
4645
- const batchSets = (0, import_core2.batchItems)({
5661
+ const batchSets = batchItems({
4646
5662
  items: allItemsStr,
4647
5663
  batchMaxNumItems: batchSize,
4648
5664
  batchMaxNumBytes: this.maxRequestSize / 2
@@ -4696,7 +5712,7 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
4696
5712
  const items = await Promise.all(wrappedItems.map((x) => x.get()));
4697
5713
  const attachments = [];
4698
5714
  items.forEach((item) => extractAttachments(item, attachments));
4699
- let mergedItems = (0, import_core2.mergeRowBatch)(items);
5715
+ let mergedItems = mergeRowBatch(items);
4700
5716
  if (this.maskingFunction) {
4701
5717
  mergedItems = mergedItems.map(
4702
5718
  (batch) => batch.map((item) => {
@@ -4952,7 +5968,7 @@ function init(projectOrOptions, optionalOptions) {
4952
5968
  const state = stateArg ?? _globalState;
4953
5969
  state.enforceQueueSizeLimit(false);
4954
5970
  if (open) {
4955
- if (isEmpty(experiment)) {
5971
+ if (isEmpty2(experiment)) {
4956
5972
  throw new Error(`Cannot open an experiment without specifying its name`);
4957
5973
  }
4958
5974
  const lazyMetadata2 = new LazyValue(
@@ -5015,7 +6031,7 @@ function init(projectOrOptions, optionalOptions) {
5015
6031
  }
5016
6032
  };
5017
6033
  if (gitMetadataSettings) {
5018
- mergedGitMetadataSettings = (0, import_core2.mergeGitMetadataSettings)(
6034
+ mergedGitMetadataSettings = mergeGitMetadataSettings(
5019
6035
  mergedGitMetadataSettings,
5020
6036
  gitMetadataSettings
5021
6037
  );
@@ -5155,7 +6171,7 @@ async function computeLoggerMetadata(state, {
5155
6171
  }) {
5156
6172
  await state.login({});
5157
6173
  const org_id = state.orgId;
5158
- if (isEmpty(project_id)) {
6174
+ if (isEmpty2(project_id)) {
5159
6175
  const response = await state.appConn().post_json("api/project/register", {
5160
6176
  project_name: project_name || GLOBAL_PROJECT,
5161
6177
  org_id
@@ -5168,7 +6184,7 @@ async function computeLoggerMetadata(state, {
5168
6184
  fullInfo: response.project
5169
6185
  }
5170
6186
  };
5171
- } else if (isEmpty(project_name)) {
6187
+ } else if (isEmpty2(project_name)) {
5172
6188
  const response = await state.appConn().get_json("api/project", {
5173
6189
  id: project_id
5174
6190
  });
@@ -5191,7 +6207,7 @@ async function login(options = {}) {
5191
6207
  const { forceLogin = false } = options || {};
5192
6208
  if (_globalState.loggedIn && !forceLogin) {
5193
6209
  let checkUpdatedParam2 = function(varname, arg, orig) {
5194
- if (!isEmpty(arg) && !isEmpty(orig) && arg !== orig) {
6210
+ if (!isEmpty2(arg) && !isEmpty2(orig) && arg !== orig) {
5195
6211
  throw new Error(
5196
6212
  `Re-logging in with different ${varname} (${arg}) than original (${orig}). To force re-login, pass \`forceLogin: true\``
5197
6213
  );
@@ -5242,7 +6258,7 @@ async function loginToState(options = {}) {
5242
6258
  return state;
5243
6259
  } else {
5244
6260
  const resp = await checkResponse(
5245
- await fetch2((0, import_core2._urljoin)(state.appUrl, `/api/apikey/login`), {
6261
+ await fetch2(_urljoin(state.appUrl, `/api/apikey/login`), {
5246
6262
  method: "POST",
5247
6263
  headers: {
5248
6264
  "Content-Type": "application/json",
@@ -5297,6 +6313,8 @@ function getSpanParentObject(options) {
5297
6313
  if (!Object.is(parentSpan, NOOP_SPAN)) {
5298
6314
  return parentSpan;
5299
6315
  }
6316
+ const parentStr = options?.parent ?? state.currentParent.getStore();
6317
+ if (parentStr) return SpanComponentsV3.fromStr(parentStr);
5300
6318
  const experiment = currentExperiment();
5301
6319
  if (experiment) {
5302
6320
  return experiment;
@@ -5357,35 +6375,35 @@ async function flush(options) {
5357
6375
  }
5358
6376
  function startSpanAndIsLogger(args) {
5359
6377
  const state = args?.state ?? _globalState;
5360
- const parentStr = args?.parent ?? state.currentParent.getStore();
5361
- const components = parentStr ? import_core2.SpanComponentsV3.fromStr(parentStr) : void 0;
5362
- if (components) {
5363
- const parentSpanIds = components.data.row_id ? {
5364
- spanId: components.data.span_id,
5365
- rootSpanId: components.data.root_span_id
6378
+ const parentObject = getSpanParentObject({
6379
+ asyncFlush: args?.asyncFlush,
6380
+ parent: args?.parent,
6381
+ state
6382
+ });
6383
+ if (parentObject instanceof SpanComponentsV3) {
6384
+ const parentSpanIds = parentObject.data.row_id ? {
6385
+ spanId: parentObject.data.span_id,
6386
+ rootSpanId: parentObject.data.root_span_id
5366
6387
  } : void 0;
5367
6388
  const span = new SpanImpl({
5368
6389
  state,
5369
6390
  ...args,
5370
- parentObjectType: components.data.object_type,
6391
+ parentObjectType: parentObject.data.object_type,
5371
6392
  parentObjectId: new LazyValue(
5372
- spanComponentsToObjectIdLambda(state, components)
6393
+ spanComponentsToObjectIdLambda(state, parentObject)
5373
6394
  ),
5374
- parentComputeObjectMetadataArgs: components.data.compute_object_metadata_args ?? void 0,
6395
+ parentComputeObjectMetadataArgs: parentObject.data.compute_object_metadata_args ?? void 0,
5375
6396
  parentSpanIds,
5376
6397
  propagatedEvent: args?.propagatedEvent ?? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5377
- (components.data.propagated_event ?? void 0)
6398
+ (parentObject.data.propagated_event ?? void 0)
5378
6399
  });
5379
6400
  return {
5380
6401
  span,
5381
- isSyncFlushLogger: components.data.object_type === import_core2.SpanObjectTypeV3.PROJECT_LOGS && // Since there's no parent logger here, we're free to choose the async flush
6402
+ isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
5382
6403
  // behavior, and therefore propagate along whatever we get from the arguments
5383
6404
  args?.asyncFlush === false
5384
6405
  };
5385
6406
  } else {
5386
- const parentObject = getSpanParentObject({
5387
- asyncFlush: args?.asyncFlush
5388
- });
5389
6407
  const span = parentObject.startSpan(args);
5390
6408
  return {
5391
6409
  span,
@@ -5489,7 +6507,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
5489
6507
  function deepCopyEvent(event) {
5490
6508
  const attachments = [];
5491
6509
  const IDENTIFIER = "_bt_internal_saved_attachment";
5492
- const savedAttachmentSchema = import_zod3.z.strictObject({ [IDENTIFIER]: import_zod3.z.number() });
6510
+ const savedAttachmentSchema = import_zod.z.strictObject({ [IDENTIFIER]: import_zod.z.number() });
5493
6511
  const serialized = JSON.stringify(event, (_k, v) => {
5494
6512
  if (v instanceof SpanImpl || v instanceof NoopSpan) {
5495
6513
  return `<span>`;
@@ -5573,15 +6591,15 @@ async function resolveAttachmentsToBase64(event, state) {
5573
6591
  return event;
5574
6592
  }
5575
6593
  function validateAndSanitizeExperimentLogFullArgs(event, hasDataset) {
5576
- if ("input" in event && !isEmpty(event.input) && "inputs" in event && !isEmpty(event.inputs) || !("input" in event) && !("inputs" in event)) {
6594
+ if ("input" in event && !isEmpty2(event.input) && "inputs" in event && !isEmpty2(event.inputs) || !("input" in event) && !("inputs" in event)) {
5577
6595
  throw new Error(
5578
6596
  "Exactly one of input or inputs (deprecated) must be specified. Prefer input."
5579
6597
  );
5580
6598
  }
5581
- if (isEmpty(event.output)) {
6599
+ if (isEmpty2(event.output)) {
5582
6600
  throw new Error("output must be specified");
5583
6601
  }
5584
- if (isEmpty(event.scores)) {
6602
+ if (isEmpty2(event.scores)) {
5585
6603
  throw new Error("scores must be specified");
5586
6604
  }
5587
6605
  if (hasDataset && event.datasetRecordId === void 0) {
@@ -5681,7 +6699,7 @@ var ObjectFetcher = class {
5681
6699
  const fetchedData = await this.fetchedData();
5682
6700
  let maxVersion = void 0;
5683
6701
  for (const record of fetchedData) {
5684
- const xactId = String(record[import_core2.TRANSACTION_ID_FIELD] ?? "0");
6702
+ const xactId = String(record[TRANSACTION_ID_FIELD] ?? "0");
5685
6703
  if (maxVersion === void 0 || xactId > maxVersion) {
5686
6704
  maxVersion = xactId;
5687
6705
  }
@@ -5724,7 +6742,7 @@ var Experiment2 = class extends ObjectFetcher {
5724
6742
  })();
5725
6743
  }
5726
6744
  parentObjectType() {
5727
- return import_core2.SpanObjectTypeV3.EXPERIMENT;
6745
+ return 1 /* EXPERIMENT */;
5728
6746
  }
5729
6747
  async getState() {
5730
6748
  await this.lazyMetadata.get();
@@ -5808,7 +6826,7 @@ var Experiment2 = class extends ObjectFetcher {
5808
6826
  parentSpanIds: void 0,
5809
6827
  propagatedEvent: args?.propagatedEvent
5810
6828
  }),
5811
- defaultRootType: import_core2.SpanTypeAttribute.EVAL
6829
+ defaultRootType: "eval" /* EVAL */
5812
6830
  });
5813
6831
  }
5814
6832
  async fetchBaseExperiment() {
@@ -5932,7 +6950,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
5932
6950
  * See {@link Span.startSpan} for more details.
5933
6951
  */
5934
6952
  async export() {
5935
- return new import_core2.SpanComponentsV3({
6953
+ return new SpanComponentsV3({
5936
6954
  object_type: this.parentObjectType(),
5937
6955
  object_id: await this.id
5938
6956
  }).toStr();
@@ -6019,7 +7037,7 @@ var SpanImpl = class _SpanImpl {
6019
7037
  this.parentComputeObjectMetadataArgs = args.parentComputeObjectMetadataArgs;
6020
7038
  this.propagatedEvent = args.propagatedEvent;
6021
7039
  if (this.propagatedEvent) {
6022
- (0, import_core2.mergeDicts)(rawEvent, this.propagatedEvent);
7040
+ mergeDicts(rawEvent, this.propagatedEvent);
6023
7041
  }
6024
7042
  const { id: eventId, ...event } = rawEvent;
6025
7043
  const callerLocation = isomorph_default.getCallerLocation();
@@ -6096,7 +7114,7 @@ var SpanImpl = class _SpanImpl {
6096
7114
  root_span_id: this._rootSpanId,
6097
7115
  span_parents: this._spanParents,
6098
7116
  ...serializableInternalData,
6099
- [import_core2.IS_MERGE_FIELD]: this.isMerge
7117
+ [IS_MERGE_FIELD]: this.isMerge
6100
7118
  });
6101
7119
  if (partialRecord.metrics?.end) {
6102
7120
  this.loggedEndTime = partialRecord.metrics?.end;
@@ -6114,7 +7132,7 @@ var SpanImpl = class _SpanImpl {
6114
7132
  ])
6115
7133
  )
6116
7134
  ),
6117
- ...new import_core2.SpanComponentsV3({
7135
+ ...new SpanComponentsV3({
6118
7136
  object_type: this.parentObjectType,
6119
7137
  object_id: await this.parentObjectId.get()
6120
7138
  }).objectIdFields()
@@ -6194,7 +7212,7 @@ var SpanImpl = class _SpanImpl {
6194
7212
  return endTime;
6195
7213
  }
6196
7214
  async export() {
6197
- return new import_core2.SpanComponentsV3({
7215
+ return new SpanComponentsV3({
6198
7216
  object_type: this.parentObjectType,
6199
7217
  ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
6200
7218
  row_id: this.id,
@@ -6227,7 +7245,7 @@ var SpanImpl = class _SpanImpl {
6227
7245
  const baseUrl = `${appUrl}/app/${orgName}`;
6228
7246
  const args = this.parentComputeObjectMetadataArgs;
6229
7247
  switch (this.parentObjectType) {
6230
- case import_core2.SpanObjectTypeV3.PROJECT_LOGS: {
7248
+ case 2 /* PROJECT_LOGS */: {
6231
7249
  const projectID = args?.project_id || this.parentObjectId.getSync().value;
6232
7250
  const projectName = args?.project_name;
6233
7251
  if (projectID) {
@@ -6238,7 +7256,7 @@ var SpanImpl = class _SpanImpl {
6238
7256
  return getErrPermlink("provide-project-name-or-id");
6239
7257
  }
6240
7258
  }
6241
- case import_core2.SpanObjectTypeV3.EXPERIMENT: {
7259
+ case 1 /* EXPERIMENT */: {
6242
7260
  const expID = args?.experiment_id || this.parentObjectId?.getSync()?.value;
6243
7261
  if (!expID) {
6244
7262
  return getErrPermlink("provide-experiment-id");
@@ -6246,7 +7264,7 @@ var SpanImpl = class _SpanImpl {
6246
7264
  return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
6247
7265
  }
6248
7266
  }
6249
- case import_core2.SpanObjectTypeV3.PLAYGROUND_LOGS: {
7267
+ case 3 /* PLAYGROUND_LOGS */: {
6250
7268
  return NOOP_SPAN_PERMALINK;
6251
7269
  }
6252
7270
  default: {
@@ -6272,8 +7290,8 @@ function splitLoggingData({
6272
7290
  }) {
6273
7291
  const sanitized = validateAndSanitizeExperimentLogPartialArgs(event ?? {});
6274
7292
  const sanitizedAndInternalData = {};
6275
- (0, import_core2.mergeDicts)(sanitizedAndInternalData, internalData || {});
6276
- (0, import_core2.mergeDicts)(sanitizedAndInternalData, sanitized);
7293
+ mergeDicts(sanitizedAndInternalData, internalData || {});
7294
+ mergeDicts(sanitizedAndInternalData, sanitized);
6277
7295
  const serializableInternalData = {};
6278
7296
  const lazyInternalData = {};
6279
7297
  for (const [key, value] of Object.entries(sanitizedAndInternalData)) {
@@ -6298,7 +7316,7 @@ function splitLoggingData({
6298
7316
  }
6299
7317
  var Dataset2 = class extends ObjectFetcher {
6300
7318
  constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
6301
- const isLegacyDataset = legacy ?? import_core2.DEFAULT_IS_LEGACY_DATASET;
7319
+ const isLegacyDataset = legacy ?? DEFAULT_IS_LEGACY_DATASET;
6302
7320
  if (isLegacyDataset) {
6303
7321
  console.warn(
6304
7322
  `Records will be fetched from this dataset in the legacy format, with the "expected" field renamed to "output". Please update your code to use "expected", and use \`braintrust.initDataset()\` with \`{ useOutput: false }\`, which will become the default in a future version of Braintrust.`
@@ -6309,7 +7327,7 @@ var Dataset2 = class extends ObjectFetcher {
6309
7327
  pinnedVersion,
6310
7328
  (r) => (
6311
7329
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
6312
- (0, import_core2.ensureDatasetRecord)(
7330
+ ensureDatasetRecord(
6313
7331
  enrichAttachments(r, this.state),
6314
7332
  isLegacyDataset
6315
7333
  )
@@ -6385,7 +7403,7 @@ var Dataset2 = class extends ObjectFetcher {
6385
7403
  //if we're merging/updating an event we will not add this ts
6386
7404
  metadata,
6387
7405
  ...!!isMerge ? {
6388
- [import_core2.IS_MERGE_FIELD]: true
7406
+ [IS_MERGE_FIELD]: true
6389
7407
  } : {}
6390
7408
  };
6391
7409
  return args;
@@ -6494,8 +7512,8 @@ var Dataset2 = class extends ObjectFetcher {
6494
7512
  )}`;
6495
7513
  let dataSummary;
6496
7514
  if (summarizeData) {
6497
- const rawDataSummary = import_zod3.z.object({
6498
- total_records: import_zod3.z.number()
7515
+ const rawDataSummary = import_zod.z.object({
7516
+ total_records: import_zod.z.number()
6499
7517
  }).parse(
6500
7518
  await state.apiConn().get_json(
6501
7519
  "dataset-summary",
@@ -6541,12 +7559,12 @@ function renderMessage(render, message) {
6541
7559
  return {
6542
7560
  ...message,
6543
7561
  ..."content" in message ? {
6544
- content: isEmpty(message.content) ? void 0 : typeof message.content === "string" ? render(message.content) : message.content.map((c) => {
7562
+ content: isEmpty2(message.content) ? void 0 : typeof message.content === "string" ? render(message.content) : message.content.map((c) => {
6545
7563
  switch (c.type) {
6546
7564
  case "text":
6547
7565
  return { ...c, text: render(c.text) };
6548
7566
  case "image_url":
6549
- if ((0, import_core2.isObject)(c.image_url.url)) {
7567
+ if (isObject(c.image_url.url)) {
6550
7568
  throw new Error(
6551
7569
  "Attachments must be replaced with URLs before calling `build()`"
6552
7570
  );
@@ -6565,7 +7583,7 @@ function renderMessage(render, message) {
6565
7583
  })
6566
7584
  } : {},
6567
7585
  ..."tool_calls" in message ? {
6568
- tool_calls: isEmpty(message.tool_calls) ? void 0 : message.tool_calls.map((t) => {
7586
+ tool_calls: isEmpty2(message.tool_calls) ? void 0 : message.tool_calls.map((t) => {
6569
7587
  return {
6570
7588
  type: t.type,
6571
7589
  id: render(t.id),
@@ -6605,9 +7623,9 @@ function renderTemplatedObject(obj, args, options) {
6605
7623
  }
6606
7624
  }
6607
7625
  });
6608
- } else if ((0, import_core2.isArray)(obj)) {
7626
+ } else if (isArray(obj)) {
6609
7627
  return obj.map((item) => renderTemplatedObject(item, args, options));
6610
- } else if ((0, import_core2.isObject)(obj)) {
7628
+ } else if (isObject(obj)) {
6611
7629
  return Object.fromEntries(
6612
7630
  Object.entries(obj).map(([key, value]) => [
6613
7631
  key,
@@ -6618,11 +7636,11 @@ function renderTemplatedObject(obj, args, options) {
6618
7636
  return obj;
6619
7637
  }
6620
7638
  function renderPromptParams(params, args, options) {
6621
- const schemaParsed = import_zod3.z.object({
6622
- response_format: import_zod3.z.object({
6623
- type: import_zod3.z.literal("json_schema"),
7639
+ const schemaParsed = import_zod.z.object({
7640
+ response_format: import_zod.z.object({
7641
+ type: import_zod.z.literal("json_schema"),
6624
7642
  json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
6625
- schema: import_zod3.z.unknown()
7643
+ schema: import_zod.z.unknown()
6626
7644
  })
6627
7645
  })
6628
7646
  }).safeParse(params);
@@ -6668,7 +7686,7 @@ var Prompt2 = class _Prompt {
6668
7686
  return this.getParsedPromptData()?.prompt;
6669
7687
  }
6670
7688
  get version() {
6671
- return this.metadata[import_core2.TRANSACTION_ID_FIELD];
7689
+ return this.metadata[TRANSACTION_ID_FIELD];
6672
7690
  }
6673
7691
  get options() {
6674
7692
  return this.getParsedPromptData()?.options || {};
@@ -6714,11 +7732,11 @@ var Prompt2 = class _Prompt {
6714
7732
  ([k, _v]) => !BRAINTRUST_PARAMS.includes(k)
6715
7733
  )
6716
7734
  ),
6717
- ...!isEmpty(this.options.model) ? {
7735
+ ...!isEmpty2(this.options.model) ? {
6718
7736
  model: this.options.model
6719
7737
  } : {}
6720
7738
  };
6721
- if (!("model" in params) || isEmpty(params.model)) {
7739
+ if (!("model" in params) || isEmpty2(params.model)) {
6722
7740
  throw new Error(
6723
7741
  "No model specified. Either specify it in the prompt or as a default"
6724
7742
  );
@@ -6740,7 +7758,7 @@ var Prompt2 = class _Prompt {
6740
7758
  if (!prompt) {
6741
7759
  throw new Error("Empty prompt");
6742
7760
  }
6743
- const dictArgParsed = import_zod3.z.record(import_zod3.z.unknown()).safeParse(buildArgs);
7761
+ const dictArgParsed = import_zod.z.record(import_zod.z.unknown()).safeParse(buildArgs);
6744
7762
  const variables = {
6745
7763
  input: buildArgs,
6746
7764
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -6795,7 +7813,7 @@ var Prompt2 = class _Prompt {
6795
7813
  return JSON.stringify(v);
6796
7814
  }
6797
7815
  };
6798
- const dictArgParsed = import_zod3.z.record(import_zod3.z.unknown()).safeParse(buildArgs);
7816
+ const dictArgParsed = import_zod.z.record(import_zod.z.unknown()).safeParse(buildArgs);
6799
7817
  const variables = {
6800
7818
  input: buildArgs,
6801
7819
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -6916,9 +7934,6 @@ var BarProgressReporter = class {
6916
7934
  }
6917
7935
  };
6918
7936
 
6919
- // src/framework.ts
6920
- var import_core5 = require("@braintrust/core");
6921
-
6922
7937
  // ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
6923
7938
  function initialParams(fn) {
6924
7939
  return function(...args) {
@@ -7961,13 +8976,12 @@ var import_chalk = __toESM(require("chalk"));
7961
8976
  var import_pluralize = __toESM(require("pluralize"));
7962
8977
 
7963
8978
  // src/eval-parameters.ts
7964
- var import_zod5 = require("zod");
8979
+ var import_v38 = require("zod/v3");
7965
8980
 
7966
8981
  // src/framework2.ts
7967
8982
  var import_path = __toESM(require("path"));
7968
8983
  var import_slugify = __toESM(require("slugify"));
7969
- var import_zod4 = require("zod");
7970
- var import_core4 = require("@braintrust/core");
8984
+ var import_v37 = require("zod/v3");
7971
8985
  var ProjectBuilder = class {
7972
8986
  create(opts) {
7973
8987
  return new Project2(opts);
@@ -8201,23 +9215,23 @@ var CodePrompt = class {
8201
9215
  };
8202
9216
  }
8203
9217
  };
8204
- var promptContentsSchema = import_zod4.z.union([
8205
- import_zod4.z.object({
8206
- prompt: import_zod4.z.string()
9218
+ var promptContentsSchema = import_v37.z.union([
9219
+ import_v37.z.object({
9220
+ prompt: import_v37.z.string()
8207
9221
  }),
8208
- import_zod4.z.object({
8209
- messages: import_zod4.z.array(ChatCompletionMessageParam)
9222
+ import_v37.z.object({
9223
+ messages: import_v37.z.array(ChatCompletionMessageParam)
8210
9224
  })
8211
9225
  ]);
8212
9226
  var promptDefinitionSchema = promptContentsSchema.and(
8213
- import_zod4.z.object({
8214
- model: import_zod4.z.string(),
9227
+ import_v37.z.object({
9228
+ model: import_v37.z.string(),
8215
9229
  params: ModelParams.optional()
8216
9230
  })
8217
9231
  );
8218
9232
  var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
8219
- import_zod4.z.object({
8220
- tools: import_zod4.z.array(ToolFunctionDefinition).optional()
9233
+ import_v37.z.object({
9234
+ tools: import_v37.z.array(ToolFunctionDefinition).optional()
8221
9235
  })
8222
9236
  );
8223
9237
  var PromptBuilder = class {
@@ -8240,7 +9254,7 @@ var PromptBuilder = class {
8240
9254
  const promptData = promptDefinitionToPromptData(opts, rawTools);
8241
9255
  const promptRow = {
8242
9256
  id: opts.id,
8243
- _xact_id: opts.version ? (0, import_core4.loadPrettyXact)(opts.version) : void 0,
9257
+ _xact_id: opts.version ? loadPrettyXact(opts.version) : void 0,
8244
9258
  name: opts.name,
8245
9259
  slug,
8246
9260
  prompt_data: promptData,
@@ -8285,7 +9299,7 @@ var ProjectNameIdMap = class {
8285
9299
  const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
8286
9300
  project_name: projectName
8287
9301
  });
8288
- const result = import_zod4.z.object({
9302
+ const result = import_v37.z.object({
8289
9303
  project: Project
8290
9304
  }).parse(response);
8291
9305
  const projectId = result.project.id;
@@ -8299,7 +9313,7 @@ var ProjectNameIdMap = class {
8299
9313
  const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
8300
9314
  id: projectId
8301
9315
  });
8302
- const result = import_zod4.z.array(Project).nonempty().parse(response);
9316
+ const result = import_v37.z.array(Project).nonempty().parse(response);
8303
9317
  const projectName = result[0].name;
8304
9318
  this.idToName[projectId] = projectName;
8305
9319
  this.nameToId[projectName] = projectId;
@@ -8315,15 +9329,15 @@ var ProjectNameIdMap = class {
8315
9329
  };
8316
9330
 
8317
9331
  // src/eval-parameters.ts
8318
- var evalParametersSchema = import_zod5.z.record(
8319
- import_zod5.z.string(),
8320
- import_zod5.z.union([
8321
- import_zod5.z.object({
8322
- type: import_zod5.z.literal("prompt"),
9332
+ var evalParametersSchema = import_v38.z.record(
9333
+ import_v38.z.string(),
9334
+ import_v38.z.union([
9335
+ import_v38.z.object({
9336
+ type: import_v38.z.literal("prompt"),
8323
9337
  default: promptDefinitionWithToolsSchema.optional(),
8324
- description: import_zod5.z.string().optional()
9338
+ description: import_v38.z.string().optional()
8325
9339
  }),
8326
- import_zod5.z.instanceof(import_zod5.z.ZodType)
9340
+ import_v38.z.instanceof(import_v38.z.ZodType)
8327
9341
  // For Zod schemas
8328
9342
  ])
8329
9343
  );
@@ -8409,7 +9423,7 @@ function _initializeSpanContext() {
8409
9423
  globalThis._spanContext = { currentSpan, withCurrent, startSpan, NOOP_SPAN };
8410
9424
  }
8411
9425
  async function Eval(name, evaluator, reporterOrOpts) {
8412
- const options = isEmpty(reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
9426
+ const options = isEmpty2(reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
8413
9427
  let evalName = makeEvalName(name, evaluator.experimentName);
8414
9428
  if (globalThis._evals.evaluators[evalName]) {
8415
9429
  evalName = `${evalName}_${Object.keys(_evals).length}`;
@@ -8587,7 +9601,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8587
9601
  );
8588
9602
  }
8589
9603
  let name = dataResult.name;
8590
- if (isEmpty(name)) {
9604
+ if (isEmpty2(name)) {
8591
9605
  const baseExperiment = await experiment.fetchBaseExperiment();
8592
9606
  if (!baseExperiment) {
8593
9607
  throw new Error("BaseExperiment() failed to fetch base experiment");
@@ -8629,7 +9643,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8629
9643
  const baseEvent = {
8630
9644
  name: "eval",
8631
9645
  spanAttributes: {
8632
- type: import_core5.SpanTypeAttribute.EVAL
9646
+ type: "eval" /* EVAL */
8633
9647
  },
8634
9648
  event: {
8635
9649
  input: datum.input,
@@ -8689,7 +9703,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8689
9703
  },
8690
9704
  {
8691
9705
  name: "task",
8692
- spanAttributes: { type: import_core5.SpanTypeAttribute.TASK },
9706
+ spanAttributes: { type: "task" /* TASK */ },
8693
9707
  event: { input: datum.input }
8694
9708
  }
8695
9709
  );
@@ -8715,7 +9729,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8715
9729
  }
8716
9730
  if (Array.isArray(scoreValue)) {
8717
9731
  for (const s of scoreValue) {
8718
- if (!(typeof s === "object" && !isEmpty(s))) {
9732
+ if (!(typeof s === "object" && !isEmpty2(s))) {
8719
9733
  throw new Error(
8720
9734
  `When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(
8721
9735
  s
@@ -8724,7 +9738,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8724
9738
  }
8725
9739
  }
8726
9740
  }
8727
- const results3 = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !isEmpty(scoreValue) ? [scoreValue] : [
9741
+ const results3 = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !isEmpty2(scoreValue) ? [scoreValue] : [
8728
9742
  {
8729
9743
  name: scorerNames[score_idx],
8730
9744
  score: scoreValue
@@ -8735,17 +9749,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8735
9749
  return rest;
8736
9750
  };
8737
9751
  const resultMetadata = results3.length === 1 ? results3[0].metadata : results3.reduce(
8738
- (prev, s) => (0, import_core5.mergeDicts)(prev, {
9752
+ (prev, s) => mergeDicts(prev, {
8739
9753
  [s.name]: s.metadata
8740
9754
  }),
8741
9755
  {}
8742
9756
  );
8743
9757
  const resultOutput = results3.length === 1 ? getOtherFields(results3[0]) : results3.reduce(
8744
- (prev, s) => (0, import_core5.mergeDicts)(prev, { [s.name]: getOtherFields(s) }),
9758
+ (prev, s) => mergeDicts(prev, { [s.name]: getOtherFields(s) }),
8745
9759
  {}
8746
9760
  );
8747
9761
  const scores2 = results3.reduce(
8748
- (prev, s) => (0, import_core5.mergeDicts)(prev, { [s.name]: s.score }),
9762
+ (prev, s) => mergeDicts(prev, { [s.name]: s.score }),
8749
9763
  {}
8750
9764
  );
8751
9765
  span.log({
@@ -8758,7 +9772,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
8758
9772
  const results2 = await rootSpan.traced(runScorer, {
8759
9773
  name: scorerNames[score_idx],
8760
9774
  spanAttributes: {
8761
- type: import_core5.SpanTypeAttribute.SCORE
9775
+ type: "score" /* SCORE */
8762
9776
  },
8763
9777
  event: { input: scoringArgs }
8764
9778
  });
@@ -8963,7 +9977,7 @@ function formatExperimentSummary(summary) {
8963
9977
  ${comparisonLine}` + Object.values(summary.scores).map((score) => formatScoreSummary(score, longestScoreName)).join("\n") + (Object.keys(summary.scores).length ? "\n\n" : "") + Object.values(summary.metrics ?? {}).map((metric) => formatMetricSummary(metric, longestMetricName)).join("\n") + (Object.keys(summary.metrics ?? {}).length ? "\n\n" : "") + (summary.experimentUrl ? `See results for ${summary.experimentName} at ${summary.experimentUrl}` : "");
8964
9978
  }
8965
9979
  function formatScoreSummary(summary, longestScoreName) {
8966
- const diffString = isEmpty(summary.diff) ? "" : ` (${summary.diff > 0 ? "+" : ""}${(summary.diff * 100).toFixed(2)}%)`;
9980
+ const diffString = isEmpty2(summary.diff) ? "" : ` (${summary.diff > 0 ? "+" : ""}${(summary.diff * 100).toFixed(2)}%)`;
8967
9981
  const scoreName = `'${summary.name}'`.padEnd(longestScoreName + 2);
8968
9982
  return `${(summary.score * 100).toFixed(
8969
9983
  2
@@ -9198,7 +10212,7 @@ function getCallerLocation() {
9198
10212
  }
9199
10213
 
9200
10214
  // src/node.ts
9201
- var import_util3 = require("util");
10215
+ var import_util8 = require("util");
9202
10216
  var zlib = __toESM(require("zlib"));
9203
10217
  function configureNode() {
9204
10218
  isomorph_default.getRepoInfo = getRepoInfo;
@@ -9220,8 +10234,8 @@ function configureNode() {
9220
10234
  isomorph_default.utimes = fs.utimes;
9221
10235
  isomorph_default.unlink = fs.unlink;
9222
10236
  isomorph_default.homedir = os.homedir;
9223
- isomorph_default.gzip = (0, import_util3.promisify)(zlib.gzip);
9224
- isomorph_default.gunzip = (0, import_util3.promisify)(zlib.gunzip);
10237
+ isomorph_default.gzip = (0, import_util8.promisify)(zlib.gzip);
10238
+ isomorph_default.gunzip = (0, import_util8.promisify)(zlib.gunzip);
9225
10239
  isomorph_default.hash = (data) => crypto.createHash("sha256").update(data).digest("hex");
9226
10240
  _internalSetInitialState();
9227
10241
  }
@@ -9233,8 +10247,7 @@ var import_env2 = require("@next/env");
9233
10247
  var import_fs = __toESM(require("fs"));
9234
10248
  var import_path4 = __toESM(require("path"));
9235
10249
  var import_zlib = require("zlib");
9236
- var import_zod6 = require("zod");
9237
- var import_core6 = require("@braintrust/core");
10250
+ var import_v39 = require("zod/v3");
9238
10251
 
9239
10252
  // src/functions/infer-source.ts
9240
10253
  var import_source_map = require("source-map");
@@ -9490,9 +10503,9 @@ async function getTsModule() {
9490
10503
  var import_slugify2 = __toESM(require("slugify"));
9491
10504
  var import_zod_to_json_schema = require("zod-to-json-schema");
9492
10505
  var import_pluralize2 = __toESM(require("pluralize"));
9493
- var pathInfoSchema = import_zod6.z.strictObject({
9494
- url: import_zod6.z.string(),
9495
- bundleId: import_zod6.z.string()
10506
+ var pathInfoSchema = import_v39.z.strictObject({
10507
+ url: import_v39.z.string(),
10508
+ bundleId: import_v39.z.string()
9496
10509
  }).strip();
9497
10510
  async function uploadHandleBundles({
9498
10511
  buildResults,
@@ -9667,7 +10680,7 @@ async function uploadBundles({
9667
10680
  return false;
9668
10681
  }
9669
10682
  }
9670
- if (isEmpty(bundleFileName)) {
10683
+ if (isEmpty2(bundleFileName)) {
9671
10684
  throw new Error("No bundle file found");
9672
10685
  }
9673
10686
  const bundleFile = import_path4.default.resolve(bundleFileName);
@@ -9759,7 +10772,7 @@ async function uploadBundles({
9759
10772
  function formatNameAndSlug(pieces) {
9760
10773
  const nonEmptyPieces = pieces.filter((piece) => piece.trim() !== "");
9761
10774
  return {
9762
- name: (0, import_core6.capitalize)(nonEmptyPieces.join(" ")),
10775
+ name: capitalize(nonEmptyPieces.join(" ")),
9763
10776
  slug: (0, import_slugify2.default)(nonEmptyPieces.join("-"))
9764
10777
  };
9765
10778
  }
@@ -9832,12 +10845,11 @@ async function bundleCommand(args) {
9832
10845
  }
9833
10846
 
9834
10847
  // src/cli-util/pull.ts
9835
- var import_zod7 = require("zod");
10848
+ var import_v310 = require("zod/v3");
9836
10849
  var import_promises = __toESM(require("fs/promises"));
9837
- var import_util5 = __toESM(require("util"));
10850
+ var import_util11 = __toESM(require("util"));
9838
10851
  var import_slugify3 = __toESM(require("slugify"));
9839
10852
  var import_path5 = __toESM(require("path"));
9840
- var import_core7 = require("@braintrust/core");
9841
10853
  var import_pluralize3 = __toESM(require("pluralize"));
9842
10854
  async function pullCommand(args) {
9843
10855
  await loadCLIEnv(args);
@@ -9847,9 +10859,9 @@ async function pullCommand(args) {
9847
10859
  ...args.project_name ? { project_name: args.project_name } : {},
9848
10860
  ...args.slug ? { slug: args.slug } : {},
9849
10861
  ...args.id ? { ids: [args.id] } : {},
9850
- ...args.version ? { version: (0, import_core7.loadPrettyXact)(args.version) } : {}
10862
+ ...args.version ? { version: loadPrettyXact(args.version) } : {}
9851
10863
  });
9852
- const functionObjects = import_zod7.z.object({ objects: import_zod7.z.array(import_zod7.z.unknown()) }).parse(functions);
10864
+ const functionObjects = import_v310.z.object({ objects: import_v310.z.array(import_v310.z.unknown()) }).parse(functions);
9853
10865
  const projectNameToFunctions = {};
9854
10866
  const projectNameIdMap = new ProjectNameIdMap();
9855
10867
  for (const rawFunc of functionObjects.objects) {
@@ -10012,7 +11024,7 @@ function makeFunctionDefinition({
10012
11024
  const objectType = "prompt";
10013
11025
  const prompt = func.prompt_data.prompt;
10014
11026
  const promptContents = prompt.type === "completion" ? `prompt: ${doubleQuote(prompt.content)}` : `messages: ${safeStringify(prompt.messages).trimStart()}`;
10015
- const rawToolsParsed = prompt.type === "chat" && prompt.tools && prompt.tools.length > 0 ? import_zod7.z.array(ToolFunctionDefinition).safeParse(JSON.parse(prompt.tools)) : void 0;
11027
+ const rawToolsParsed = prompt.type === "chat" && prompt.tools && prompt.tools.length > 0 ? import_v310.z.array(ToolFunctionDefinition).safeParse(JSON.parse(prompt.tools)) : void 0;
10016
11028
  if (rawToolsParsed && !rawToolsParsed.success) {
10017
11029
  console.warn(
10018
11030
  warning(
@@ -10033,7 +11045,7 @@ function makeFunctionDefinition({
10033
11045
  id: ${doubleQuote(func.id)},
10034
11046
  name: ${doubleQuote(func.name)},
10035
11047
  slug: ${doubleQuote(func.slug)},
10036
- version: ${doubleQuote((0, import_core7.prettifyXact)(func._xact_id))}, ${printOptionalField("description", func.description)}${printOptionalField("model", model)}
11048
+ version: ${doubleQuote(prettifyXact(func._xact_id))}, ${printOptionalField("description", func.description)}${printOptionalField("model", model)}
10037
11049
  ${indent(promptContents, 2)},
10038
11050
  ${indent(paramsString, 2)}
10039
11051
  ${indent(toolsString, 2)}
@@ -10053,7 +11065,7 @@ function indent(str, numSpaces) {
10053
11065
  return str.replace(/^/gm, " ".repeat(numSpaces));
10054
11066
  }
10055
11067
  function printOptionalField(fieldName, fieldValue) {
10056
- return !(0, import_core7.isEmpty)(fieldValue) ? `
11068
+ return !isEmpty(fieldValue) ? `
10057
11069
  ${fieldName}: ${doubleQuote(fieldValue)},` : "";
10058
11070
  }
10059
11071
  var prettierImportAttempted = false;
@@ -10107,7 +11119,7 @@ function safeStringify(obj) {
10107
11119
  return JSON.stringify(obj, null, 2);
10108
11120
  } catch (error2) {
10109
11121
  try {
10110
- return import_util5.default.inspect(obj, {
11122
+ return import_util11.default.inspect(obj, {
10111
11123
  depth: 5,
10112
11124
  maxStringLength: 1e3,
10113
11125
  breakLength: 80,
@@ -10124,7 +11136,7 @@ var import_express = __toESM(require("express"));
10124
11136
  var import_cors = __toESM(require("cors"));
10125
11137
 
10126
11138
  // dev/errorHandler.ts
10127
- var import_zod8 = require("zod");
11139
+ var import_v311 = require("zod/v3");
10128
11140
  var errorHandler = (err, req, res, next) => {
10129
11141
  if ("status" in err) {
10130
11142
  res.status(err.status).json({
@@ -10135,7 +11147,7 @@ var errorHandler = (err, req, res, next) => {
10135
11147
  });
10136
11148
  return;
10137
11149
  }
10138
- if (err instanceof import_zod8.z.ZodError) {
11150
+ if (err instanceof import_v311.z.ZodError) {
10139
11151
  res.status(400).json({
10140
11152
  error: {
10141
11153
  message: "Invalid request",
@@ -10159,7 +11171,8 @@ function authorizeRequest(req, res, next) {
10159
11171
  try {
10160
11172
  const ctx = {
10161
11173
  appOrigin: extractAllowedOrigin(req.headers[ORIGIN_HEADER]),
10162
- token: void 0
11174
+ token: void 0,
11175
+ state: void 0
10163
11176
  };
10164
11177
  if (req.headers.authorization || req.headers[BRAINTRUST_AUTH_TOKEN_HEADER]) {
10165
11178
  const tokenText = parseBraintrustAuthHeader(req.headers);
@@ -10174,11 +11187,37 @@ function authorizeRequest(req, res, next) {
10174
11187
  next(e);
10175
11188
  }
10176
11189
  }
10177
- function checkAuthorized(req, res, next) {
10178
- if (!req.ctx?.token) {
10179
- return next((0, import_http_errors.default)(401, "Unauthorized"));
11190
+ var loginCache = new LRUCache({
11191
+ max: 32
11192
+ // TODO: Make this configurable
11193
+ });
11194
+ async function cachedLogin(options) {
11195
+ const key = JSON.stringify(options);
11196
+ const cached = loginCache.get(key);
11197
+ if (cached) {
11198
+ return cached;
10180
11199
  }
10181
- next();
11200
+ const state = await loginToState(options);
11201
+ loginCache.set(key, state);
11202
+ return state;
11203
+ }
11204
+ function makeCheckAuthorized(allowedOrgName) {
11205
+ return async (req, _res, next) => {
11206
+ if (!req.ctx?.token) {
11207
+ return next((0, import_http_errors.default)(401, "Unauthorized"));
11208
+ }
11209
+ try {
11210
+ const state = await cachedLogin({
11211
+ apiKey: req.ctx?.token,
11212
+ orgName: allowedOrgName
11213
+ });
11214
+ req.ctx.state = state;
11215
+ next();
11216
+ } catch (e) {
11217
+ console.error("Authorization error:", e);
11218
+ return next((0, import_http_errors.default)(401, "Unauthorized"));
11219
+ }
11220
+ };
10182
11221
  }
10183
11222
  function parseBraintrustAuthHeader(headers) {
10184
11223
  const tokenString = parseHeader(headers, BRAINTRUST_AUTH_TOKEN_HEADER);
@@ -10263,58 +11302,55 @@ var baseAllowedHeaders = [
10263
11302
  "x-stainless-arch"
10264
11303
  ];
10265
11304
 
10266
- // dev/server.ts
10267
- var import_core8 = require("@braintrust/core");
10268
-
10269
11305
  // dev/stream.ts
10270
11306
  function serializeSSEEvent(event) {
10271
11307
  return Object.entries(event).filter(([_key, value]) => value !== void 0).map(([key, value]) => `${key}: ${value}`).join("\n") + "\n\n";
10272
11308
  }
10273
11309
 
10274
11310
  // dev/types.ts
10275
- var import_zod9 = require("zod");
10276
- var evalBodySchema = import_zod9.z.object({
10277
- name: import_zod9.z.string(),
10278
- parameters: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.unknown()).nullish(),
11311
+ var import_v312 = require("zod/v3");
11312
+ var evalBodySchema = import_v312.z.object({
11313
+ name: import_v312.z.string(),
11314
+ parameters: import_v312.z.record(import_v312.z.string(), import_v312.z.unknown()).nullish(),
10279
11315
  data: RunEval.shape.data,
10280
- scores: import_zod9.z.array(
10281
- import_zod9.z.object({
11316
+ scores: import_v312.z.array(
11317
+ import_v312.z.object({
10282
11318
  function_id: FunctionId,
10283
- name: import_zod9.z.string()
11319
+ name: import_v312.z.string()
10284
11320
  })
10285
11321
  ).nullish(),
10286
- experiment_name: import_zod9.z.string().nullish(),
10287
- project_id: import_zod9.z.string().nullish(),
11322
+ experiment_name: import_v312.z.string().nullish(),
11323
+ project_id: import_v312.z.string().nullish(),
10288
11324
  parent: InvokeParent.optional(),
10289
- stream: import_zod9.z.boolean().optional()
11325
+ stream: import_v312.z.boolean().optional()
10290
11326
  });
10291
- var evalParametersSerializedSchema = import_zod9.z.record(
10292
- import_zod9.z.string(),
10293
- import_zod9.z.union([
10294
- import_zod9.z.object({
10295
- type: import_zod9.z.literal("prompt"),
11327
+ var evalParametersSerializedSchema = import_v312.z.record(
11328
+ import_v312.z.string(),
11329
+ import_v312.z.union([
11330
+ import_v312.z.object({
11331
+ type: import_v312.z.literal("prompt"),
10296
11332
  default: PromptData.optional(),
10297
- description: import_zod9.z.string().optional()
11333
+ description: import_v312.z.string().optional()
10298
11334
  }),
10299
- import_zod9.z.object({
10300
- type: import_zod9.z.literal("data"),
10301
- schema: import_zod9.z.record(import_zod9.z.unknown()),
11335
+ import_v312.z.object({
11336
+ type: import_v312.z.literal("data"),
11337
+ schema: import_v312.z.record(import_v312.z.unknown()),
10302
11338
  // JSON Schema
10303
- default: import_zod9.z.unknown().optional(),
10304
- description: import_zod9.z.string().optional()
11339
+ default: import_v312.z.unknown().optional(),
11340
+ description: import_v312.z.string().optional()
10305
11341
  })
10306
11342
  ])
10307
11343
  );
10308
- var evaluatorDefinitionSchema = import_zod9.z.object({
11344
+ var evaluatorDefinitionSchema = import_v312.z.object({
10309
11345
  parameters: evalParametersSerializedSchema.optional()
10310
11346
  });
10311
- var evaluatorDefinitionsSchema = import_zod9.z.record(
10312
- import_zod9.z.string(),
11347
+ var evaluatorDefinitionsSchema = import_v312.z.record(
11348
+ import_v312.z.string(),
10313
11349
  evaluatorDefinitionSchema
10314
11350
  );
10315
11351
 
10316
11352
  // dev/server.ts
10317
- var import_zod10 = require("zod");
11353
+ var import_v313 = require("zod/v3");
10318
11354
  var import_zod_to_json_schema2 = __toESM(require("zod-to-json-schema"));
10319
11355
  function runDevServer(evaluators, opts) {
10320
11356
  const allEvaluators = Object.fromEntries(
@@ -10330,6 +11366,7 @@ function runDevServer(evaluators, opts) {
10330
11366
  }
10331
11367
  next();
10332
11368
  });
11369
+ const checkAuthorized = makeCheckAuthorized(opts.orgName);
10333
11370
  app.use(
10334
11371
  (0, import_cors.default)({
10335
11372
  origin: checkOrigin,
@@ -10337,8 +11374,8 @@ function runDevServer(evaluators, opts) {
10337
11374
  allowedHeaders: baseAllowedHeaders,
10338
11375
  credentials: true,
10339
11376
  exposedHeaders: [
10340
- import_core8.BT_CURSOR_HEADER,
10341
- import_core8.BT_FOUND_EXISTING_HEADER,
11377
+ BT_CURSOR_HEADER,
11378
+ BT_FOUND_EXISTING_HEADER,
10342
11379
  "x-bt-span-id",
10343
11380
  "x-bt-span-export"
10344
11381
  ],
@@ -10349,7 +11386,7 @@ function runDevServer(evaluators, opts) {
10349
11386
  app.get("/", (req, res) => {
10350
11387
  res.send("Hello, world!");
10351
11388
  });
10352
- app.get("/list", (req, res) => {
11389
+ app.get("/list", checkAuthorized, (req, res) => {
10353
11390
  const evalDefs = Object.fromEntries(
10354
11391
  Object.entries(allEvaluators).map(([name, evaluator]) => [
10355
11392
  name,
@@ -10377,7 +11414,11 @@ function runDevServer(evaluators, opts) {
10377
11414
  scores,
10378
11415
  stream
10379
11416
  } = evalBodySchema.parse(req.body);
10380
- const state = await cachedLogin({ apiKey: req.ctx?.token });
11417
+ if (!req.ctx?.state) {
11418
+ res.status(500).json({ error: "Braintrust state not initialized in request" });
11419
+ return;
11420
+ }
11421
+ const state = req.ctx.state;
10381
11422
  const evaluator = allEvaluators[name];
10382
11423
  if (!evaluator) {
10383
11424
  res.status(404).json({ error: `Evaluator '${name}' not found` });
@@ -10394,7 +11435,7 @@ function runDevServer(evaluators, opts) {
10394
11435
  validateParameters(parameters ?? {}, evaluator.parameters);
10395
11436
  } catch (e) {
10396
11437
  console.error("Error validating parameters", e);
10397
- if (e instanceof import_zod10.z.ZodError || e instanceof Error) {
11438
+ if (e instanceof import_v313.z.ZodError || e instanceof Error) {
10398
11439
  res.status(400).json({
10399
11440
  error: e.message
10400
11441
  });
@@ -10470,7 +11511,7 @@ function runDevServer(evaluators, opts) {
10470
11511
  );
10471
11512
  }
10472
11513
  },
10473
- parent: (0, import_core8.parseParent)(parent),
11514
+ parent: parseParent(parent),
10474
11515
  parameters: parameters ?? {}
10475
11516
  }
10476
11517
  );
@@ -10515,20 +11556,6 @@ function runDevServer(evaluators, opts) {
10515
11556
  var asyncHandler = (fn) => (req, res, next) => {
10516
11557
  Promise.resolve(fn(req, res, next)).catch(next);
10517
11558
  };
10518
- var loginCache = new LRUCache({
10519
- max: 32
10520
- // TODO: Make this configurable
10521
- });
10522
- async function cachedLogin(options) {
10523
- const key = JSON.stringify(options);
10524
- const cached = loginCache.get(key);
10525
- if (cached) {
10526
- return cached;
10527
- }
10528
- const state = await loginToState(options);
10529
- loginCache.set(key, state);
10530
- return state;
10531
- }
10532
11559
  async function getDataset(state, data) {
10533
11560
  if ("project_name" in data) {
10534
11561
  return initDataset({
@@ -10552,9 +11579,9 @@ async function getDataset(state, data) {
10552
11579
  return data.data;
10553
11580
  }
10554
11581
  }
10555
- var datasetFetchSchema = import_zod10.z.object({
10556
- project_id: import_zod10.z.string(),
10557
- name: import_zod10.z.string()
11582
+ var datasetFetchSchema = import_v313.z.object({
11583
+ project_id: import_v313.z.string(),
11584
+ name: import_v313.z.string()
10558
11585
  });
10559
11586
  async function getDatasetById({
10560
11587
  state,
@@ -10563,7 +11590,7 @@ async function getDatasetById({
10563
11590
  const dataset = await state.appConn().post_json("api/dataset/get", {
10564
11591
  id: datasetId
10565
11592
  });
10566
- const parsed = import_zod10.z.array(datasetFetchSchema).parse(dataset);
11593
+ const parsed = import_v313.z.array(datasetFetchSchema).parse(dataset);
10567
11594
  if (parsed.length === 0) {
10568
11595
  throw new Error(`Dataset '${datasetId}' not found`);
10569
11596
  }
@@ -10700,7 +11727,7 @@ function resolveReporter(reporter, reporters) {
10700
11727
  throw new Error(`Reporter ${reporter} not found`);
10701
11728
  }
10702
11729
  return reporters[reporter];
10703
- } else if (!isEmpty(reporter)) {
11730
+ } else if (!isEmpty2(reporter)) {
10704
11731
  return reporter;
10705
11732
  } else if (Object.keys(reporters).length === 0) {
10706
11733
  return defaultReporter;
@@ -11087,7 +12114,7 @@ async function collectFiles(inputPath, mode) {
11087
12114
  }
11088
12115
  files.push(inputPath);
11089
12116
  } else {
11090
- const walked = await import_util6.default.promisify(fsWalk.walk)(inputPath, {
12117
+ const walked = await import_util14.default.promisify(fsWalk.walk)(inputPath, {
11091
12118
  deepFilter: (entry) => {
11092
12119
  return checkMatch(entry.path, null, EXCLUDE);
11093
12120
  },
@@ -11280,7 +12307,8 @@ async function run(args) {
11280
12307
  );
11281
12308
  runDevServer(allEvaluators, {
11282
12309
  host: args.dev_host,
11283
- port: args.dev_port
12310
+ port: args.dev_port,
12311
+ orgName: args.dev_org_name
11284
12312
  });
11285
12313
  return;
11286
12314
  }
@@ -11396,7 +12424,7 @@ async function main() {
11396
12424
  });
11397
12425
  parser_run.add_argument("--dev", {
11398
12426
  action: "store_true",
11399
- help: "Run the evaluators in dev mode. This will start a dev server which you can connect to via the playground."
12427
+ help: "Run the evaluators in dev mode. This will start a dev server which you can connect to via the playground's remote evals feature."
11400
12428
  });
11401
12429
  parser_run.add_argument("--dev-host", {
11402
12430
  help: "The host to bind the dev server to. Defaults to localhost. Set to 0.0.0.0 to bind to all interfaces.",
@@ -11408,6 +12436,10 @@ async function main() {
11408
12436
  type: Number,
11409
12437
  default: 8300
11410
12438
  });
12439
+ parser_run.add_argument("--dev-org-name", {
12440
+ help: "Only allow users that belong this to this org name to run remote evals.",
12441
+ type: String
12442
+ });
11411
12443
  parser_run.set_defaults({ func: run });
11412
12444
  const parser_push = subparser.add_parser("push", {
11413
12445
  help: "Bundle prompts, tools, scorers, and other resources into Braintrust"