braintrust 1.0.1 → 1.0.3-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023 Braintrust Data LLC
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -7982,8 +7982,6 @@ declare class LazyValue<T> {
7982
7982
  get hasSucceeded(): boolean;
7983
7983
  }
7984
7984
 
7985
- /// <reference lib="dom" />
7986
-
7987
7985
  interface ContextParentSpanIds {
7988
7986
  rootSpanId: string;
7989
7987
  spanParents: string[];
@@ -8517,11 +8515,24 @@ declare class ObjectFetcher<RecordType> implements AsyncIterable<WithTransaction
8517
8515
  get id(): Promise<string>;
8518
8516
  protected getState(): Promise<BraintrustState>;
8519
8517
  private fetchRecordsFromApi;
8520
- fetch(): AsyncGenerator<WithTransactionId<RecordType>>;
8518
+ /**
8519
+ * Fetch all records from the object.
8520
+ *
8521
+ * @param options Optional parameters for fetching.
8522
+ * @param options.batchSize The number of records to fetch per request. Defaults to 1000.
8523
+ * @returns An async generator of records.
8524
+ */
8525
+ fetch(options?: {
8526
+ batchSize?: number;
8527
+ }): AsyncGenerator<WithTransactionId<RecordType>>;
8521
8528
  [Symbol.asyncIterator](): AsyncIterator<WithTransactionId<RecordType>>;
8522
- fetchedData(): Promise<WithTransactionId<RecordType>[]>;
8529
+ fetchedData(options?: {
8530
+ batchSize?: number;
8531
+ }): Promise<WithTransactionId<RecordType>[]>;
8523
8532
  clearCache(): void;
8524
- version(): Promise<string | undefined>;
8533
+ version(options?: {
8534
+ batchSize?: number;
8535
+ }): Promise<string | undefined>;
8525
8536
  }
8526
8537
  type BaseMetadata = Record<string, unknown> | void;
8527
8538
  type DefaultMetadataType = void;
@@ -7982,8 +7982,6 @@ declare class LazyValue<T> {
7982
7982
  get hasSucceeded(): boolean;
7983
7983
  }
7984
7984
 
7985
- /// <reference lib="dom" />
7986
-
7987
7985
  interface ContextParentSpanIds {
7988
7986
  rootSpanId: string;
7989
7987
  spanParents: string[];
@@ -8517,11 +8515,24 @@ declare class ObjectFetcher<RecordType> implements AsyncIterable<WithTransaction
8517
8515
  get id(): Promise<string>;
8518
8516
  protected getState(): Promise<BraintrustState>;
8519
8517
  private fetchRecordsFromApi;
8520
- fetch(): AsyncGenerator<WithTransactionId<RecordType>>;
8518
+ /**
8519
+ * Fetch all records from the object.
8520
+ *
8521
+ * @param options Optional parameters for fetching.
8522
+ * @param options.batchSize The number of records to fetch per request. Defaults to 1000.
8523
+ * @returns An async generator of records.
8524
+ */
8525
+ fetch(options?: {
8526
+ batchSize?: number;
8527
+ }): AsyncGenerator<WithTransactionId<RecordType>>;
8521
8528
  [Symbol.asyncIterator](): AsyncIterator<WithTransactionId<RecordType>>;
8522
- fetchedData(): Promise<WithTransactionId<RecordType>[]>;
8529
+ fetchedData(options?: {
8530
+ batchSize?: number;
8531
+ }): Promise<WithTransactionId<RecordType>[]>;
8523
8532
  clearCache(): void;
8524
- version(): Promise<string | undefined>;
8533
+ version(options?: {
8534
+ batchSize?: number;
8535
+ }): Promise<string | undefined>;
8525
8536
  }
8526
8537
  type BaseMetadata = Record<string, unknown> | void;
8527
8538
  type DefaultMetadataType = void;
package/dev/dist/index.js CHANGED
@@ -3605,7 +3605,7 @@ var NoopSpan = (_class4 = class {
3605
3605
  return _internalGetGlobalState();
3606
3606
  }
3607
3607
  // Custom inspect for Node.js console.log
3608
- [Symbol.for("nodejs.util.inspect.custom")]() {
3608
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
3609
3609
  return `NoopSpan {
3610
3610
  kind: '${this.kind}',
3611
3611
  id: '${this.id}',
@@ -3870,7 +3870,7 @@ var BraintrustState = (_class5 = class _BraintrustState {
3870
3870
  };
3871
3871
  }
3872
3872
  // Custom inspect for Node.js console.log
3873
- [Symbol.for("nodejs.util.inspect.custom")]() {
3873
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
3874
3874
  return `BraintrustState {
3875
3875
  id: '${this.id}',
3876
3876
  orgId: ${this.orgId ? `'${this.orgId}'` : "null"},
@@ -4030,7 +4030,7 @@ var HTTPConnection = class _HTTPConnection {
4030
4030
  return await resp.json();
4031
4031
  }
4032
4032
  // Custom inspect for Node.js console.log
4033
- [Symbol.for("nodejs.util.inspect.custom")]() {
4033
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
4034
4034
  return `HTTPConnection {
4035
4035
  base_url: '${this.base_url}',
4036
4036
  token: '[REDACTED]'
@@ -5852,7 +5852,7 @@ function validateAndSanitizeExperimentLogFullArgs(event, hasDataset) {
5852
5852
  }
5853
5853
  return event;
5854
5854
  }
5855
- var INTERNAL_BTQL_LIMIT = 1e3;
5855
+ var DEFAULT_FETCH_BATCH_SIZE = 1e3;
5856
5856
  var MAX_BTQL_ITERATIONS = 1e4;
5857
5857
  var ObjectFetcher = (_class8 = class {
5858
5858
  constructor(objectType, pinnedVersion, mutateRecord, _internal_btql) {;_class8.prototype.__init38.call(this);
@@ -5868,9 +5868,10 @@ var ObjectFetcher = (_class8 = class {
5868
5868
  async getState() {
5869
5869
  throw new Error("ObjectFetcher subclasses must have a 'getState' method");
5870
5870
  }
5871
- async *fetchRecordsFromApi() {
5871
+ async *fetchRecordsFromApi(batchSize) {
5872
5872
  const state = await this.getState();
5873
5873
  const objectId = await this.id;
5874
+ const limit = _nullishCoalesce(batchSize, () => ( DEFAULT_FETCH_BATCH_SIZE));
5874
5875
  let cursor = void 0;
5875
5876
  let iterations = 0;
5876
5877
  while (true) {
@@ -5898,7 +5899,7 @@ var ObjectFetcher = (_class8 = class {
5898
5899
  ]
5899
5900
  },
5900
5901
  cursor,
5901
- limit: INTERNAL_BTQL_LIMIT
5902
+ limit
5902
5903
  },
5903
5904
  use_columnstore: false,
5904
5905
  brainstore_realtime: true,
@@ -5924,24 +5925,31 @@ var ObjectFetcher = (_class8 = class {
5924
5925
  }
5925
5926
  }
5926
5927
  }
5927
- async *fetch() {
5928
+ /**
5929
+ * Fetch all records from the object.
5930
+ *
5931
+ * @param options Optional parameters for fetching.
5932
+ * @param options.batchSize The number of records to fetch per request. Defaults to 1000.
5933
+ * @returns An async generator of records.
5934
+ */
5935
+ async *fetch(options) {
5928
5936
  if (this._fetchedData !== void 0) {
5929
5937
  for (const record of this._fetchedData) {
5930
5938
  yield record;
5931
5939
  }
5932
5940
  return;
5933
5941
  }
5934
- for await (const record of this.fetchRecordsFromApi()) {
5942
+ for await (const record of this.fetchRecordsFromApi(_optionalChain([options, 'optionalAccess', _59 => _59.batchSize]))) {
5935
5943
  yield record;
5936
5944
  }
5937
5945
  }
5938
5946
  [Symbol.asyncIterator]() {
5939
5947
  return this.fetch();
5940
5948
  }
5941
- async fetchedData() {
5949
+ async fetchedData(options) {
5942
5950
  if (this._fetchedData === void 0) {
5943
5951
  const data = [];
5944
- for await (const record of this.fetchRecordsFromApi()) {
5952
+ for await (const record of this.fetchRecordsFromApi(_optionalChain([options, 'optionalAccess', _60 => _60.batchSize]))) {
5945
5953
  data.push(record);
5946
5954
  }
5947
5955
  this._fetchedData = data;
@@ -5951,12 +5959,12 @@ var ObjectFetcher = (_class8 = class {
5951
5959
  clearCache() {
5952
5960
  this._fetchedData = void 0;
5953
5961
  }
5954
- async version() {
5962
+ async version(options) {
5955
5963
  if (this.pinnedVersion !== void 0) {
5956
5964
  return this.pinnedVersion;
5957
5965
  } else {
5958
5966
  let maxVersion = void 0;
5959
- for await (const record of this.fetch()) {
5967
+ for await (const record of this.fetch(options)) {
5960
5968
  const xactId = String(_nullishCoalesce(record[TRANSACTION_ID_FIELD], () => ( "0")));
5961
5969
  if (maxVersion === void 0 || xactId > maxVersion) {
5962
5970
  maxVersion = xactId;
@@ -6036,7 +6044,7 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
6036
6044
  * @returns The `id` of the logged event.
6037
6045
  */
6038
6046
  log(event, options) {
6039
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _59 => _59.allowConcurrentWithSpans])) {
6047
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _61 => _61.allowConcurrentWithSpans])) {
6040
6048
  throw new Error(
6041
6049
  "Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
6042
6050
  );
@@ -6089,12 +6097,12 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
6089
6097
  state: this.state,
6090
6098
  ...startSpanParentArgs({
6091
6099
  state: this.state,
6092
- parent: _optionalChain([args, 'optionalAccess', _60 => _60.parent]),
6100
+ parent: _optionalChain([args, 'optionalAccess', _62 => _62.parent]),
6093
6101
  parentObjectType: this.parentObjectType(),
6094
6102
  parentObjectId: this.lazyId,
6095
6103
  parentComputeObjectMetadataArgs: void 0,
6096
6104
  parentSpanIds: void 0,
6097
- propagatedEvent: _optionalChain([args, 'optionalAccess', _61 => _61.propagatedEvent])
6105
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _63 => _63.propagatedEvent])
6098
6106
  }),
6099
6107
  defaultRootType: "eval" /* EVAL */
6100
6108
  });
@@ -6264,8 +6272,8 @@ var ReadonlyExperiment = class extends ObjectFetcher {
6264
6272
  await this.lazyMetadata.get();
6265
6273
  return this.state;
6266
6274
  }
6267
- async *asDataset() {
6268
- const records = this.fetch();
6275
+ async *asDataset(options) {
6276
+ const records = this.fetch(options);
6269
6277
  for await (const record of records) {
6270
6278
  if (record.root_span_id !== record.span_id) {
6271
6279
  continue;
@@ -6432,10 +6440,10 @@ var SpanImpl = (_class10 = class _SpanImpl {
6432
6440
  ...serializableInternalData,
6433
6441
  [IS_MERGE_FIELD]: this.isMerge
6434
6442
  });
6435
- if (_optionalChain([partialRecord, 'access', _62 => _62.metrics, 'optionalAccess', _63 => _63.end])) {
6436
- this.loggedEndTime = _optionalChain([partialRecord, 'access', _64 => _64.metrics, 'optionalAccess', _65 => _65.end]);
6443
+ if (_optionalChain([partialRecord, 'access', _64 => _64.metrics, 'optionalAccess', _65 => _65.end])) {
6444
+ this.loggedEndTime = _optionalChain([partialRecord, 'access', _66 => _66.metrics, 'optionalAccess', _67 => _67.end]);
6437
6445
  }
6438
- if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _66 => _66._spanParents, 'optionalAccess', _67 => _67.length])) {
6446
+ if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _68 => _68._spanParents, 'optionalAccess', _69 => _69.length])) {
6439
6447
  throw new Error("Tags can only be logged to the root span");
6440
6448
  }
6441
6449
  const computeRecord = async () => ({
@@ -6480,18 +6488,18 @@ var SpanImpl = (_class10 = class _SpanImpl {
6480
6488
  );
6481
6489
  }
6482
6490
  startSpan(args) {
6483
- const parentSpanIds = _optionalChain([args, 'optionalAccess', _68 => _68.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
6491
+ const parentSpanIds = _optionalChain([args, 'optionalAccess', _70 => _70.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
6484
6492
  return new _SpanImpl({
6485
6493
  state: this._state,
6486
6494
  ...args,
6487
6495
  ...startSpanParentArgs({
6488
6496
  state: this._state,
6489
- parent: _optionalChain([args, 'optionalAccess', _69 => _69.parent]),
6497
+ parent: _optionalChain([args, 'optionalAccess', _71 => _71.parent]),
6490
6498
  parentObjectType: this.parentObjectType,
6491
6499
  parentObjectId: this.parentObjectId,
6492
6500
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
6493
6501
  parentSpanIds,
6494
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _70 => _70.propagatedEvent]), () => ( this.propagatedEvent))
6502
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.propagatedEvent]), () => ( this.propagatedEvent))
6495
6503
  })
6496
6504
  });
6497
6505
  }
@@ -6505,12 +6513,12 @@ var SpanImpl = (_class10 = class _SpanImpl {
6505
6513
  ...args,
6506
6514
  ...startSpanParentArgs({
6507
6515
  state: this._state,
6508
- parent: _optionalChain([args, 'optionalAccess', _71 => _71.parent]),
6516
+ parent: _optionalChain([args, 'optionalAccess', _73 => _73.parent]),
6509
6517
  parentObjectType: this.parentObjectType,
6510
6518
  parentObjectId: this.parentObjectId,
6511
6519
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
6512
6520
  parentSpanIds,
6513
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.propagatedEvent]), () => ( this.propagatedEvent))
6521
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _74 => _74.propagatedEvent]), () => ( this.propagatedEvent))
6514
6522
  }),
6515
6523
  spanId
6516
6524
  });
@@ -6519,7 +6527,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
6519
6527
  let endTime;
6520
6528
  let internalData = {};
6521
6529
  if (!this.loggedEndTime) {
6522
- endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _73 => _73.endTime]), () => ( getCurrentUnixTimestamp()));
6530
+ endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.endTime]), () => ( getCurrentUnixTimestamp()));
6523
6531
  internalData = { metrics: { end: endTime } };
6524
6532
  } else {
6525
6533
  endTime = this.loggedEndTime;
@@ -6562,8 +6570,8 @@ var SpanImpl = (_class10 = class _SpanImpl {
6562
6570
  const args = this.parentComputeObjectMetadataArgs;
6563
6571
  switch (this.parentObjectType) {
6564
6572
  case 2 /* PROJECT_LOGS */: {
6565
- const projectID = _optionalChain([args, 'optionalAccess', _74 => _74.project_id]) || this.parentObjectId.getSync().value;
6566
- const projectName = _optionalChain([args, 'optionalAccess', _75 => _75.project_name]);
6573
+ const projectID = _optionalChain([args, 'optionalAccess', _76 => _76.project_id]) || this.parentObjectId.getSync().value;
6574
+ const projectName = _optionalChain([args, 'optionalAccess', _77 => _77.project_name]);
6567
6575
  if (projectID) {
6568
6576
  return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
6569
6577
  } else if (projectName) {
@@ -6573,7 +6581,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
6573
6581
  }
6574
6582
  }
6575
6583
  case 1 /* EXPERIMENT */: {
6576
- const expID = _optionalChain([args, 'optionalAccess', _76 => _76.experiment_id]) || _optionalChain([this, 'access', _77 => _77.parentObjectId, 'optionalAccess', _78 => _78.getSync, 'call', _79 => _79(), 'optionalAccess', _80 => _80.value]);
6584
+ const expID = _optionalChain([args, 'optionalAccess', _78 => _78.experiment_id]) || _optionalChain([this, 'access', _79 => _79.parentObjectId, 'optionalAccess', _80 => _80.getSync, 'call', _81 => _81(), 'optionalAccess', _82 => _82.value]);
6577
6585
  if (!expID) {
6578
6586
  return getErrPermlink("provide-experiment-id");
6579
6587
  } else {
@@ -6600,7 +6608,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
6600
6608
  return this._state;
6601
6609
  }
6602
6610
  // Custom inspect for Node.js console.log
6603
- [Symbol.for("nodejs.util.inspect.custom")]() {
6611
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
6604
6612
  return `SpanImpl {
6605
6613
  kind: '${this.kind}',
6606
6614
  id: '${this.id}',
@@ -7029,13 +7037,13 @@ var Prompt2 = (_class12 = class _Prompt {
7029
7037
  return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
7030
7038
  }
7031
7039
  get prompt() {
7032
- return _optionalChain([this, 'access', _81 => _81.getParsedPromptData, 'call', _82 => _82(), 'optionalAccess', _83 => _83.prompt]);
7040
+ return _optionalChain([this, 'access', _83 => _83.getParsedPromptData, 'call', _84 => _84(), 'optionalAccess', _85 => _85.prompt]);
7033
7041
  }
7034
7042
  get version() {
7035
7043
  return this.metadata[TRANSACTION_ID_FIELD];
7036
7044
  }
7037
7045
  get options() {
7038
- return _optionalChain([this, 'access', _84 => _84.getParsedPromptData, 'call', _85 => _85(), 'optionalAccess', _86 => _86.options]) || {};
7046
+ return _optionalChain([this, 'access', _86 => _86.getParsedPromptData, 'call', _87 => _87(), 'optionalAccess', _88 => _88.options]) || {};
7039
7047
  }
7040
7048
  get promptData() {
7041
7049
  return this.getParsedPromptData();
@@ -7186,7 +7194,7 @@ var Prompt2 = (_class12 = class _Prompt {
7186
7194
  return {
7187
7195
  type: "chat",
7188
7196
  messages,
7189
- ..._optionalChain([prompt, 'access', _87 => _87.tools, 'optionalAccess', _88 => _88.trim, 'call', _89 => _89()]) ? {
7197
+ ..._optionalChain([prompt, 'access', _89 => _89.tools, 'optionalAccess', _90 => _90.trim, 'call', _91 => _91()]) ? {
7190
7198
  tools: render(prompt.tools)
7191
7199
  } : void 0
7192
7200
  };
@@ -7267,7 +7275,7 @@ function configureNode() {
7267
7275
  var _express = require('express'); var _express2 = _interopRequireDefault(_express);
7268
7276
  var _cors = require('cors'); var _cors2 = _interopRequireDefault(_cors);
7269
7277
 
7270
- // ../node_modules/async/dist/async.mjs
7278
+ // ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
7271
7279
  function initialParams(fn) {
7272
7280
  return function(...args) {
7273
7281
  var callback = args.pop();
@@ -7392,6 +7400,7 @@ function isArrayLike(value) {
7392
7400
  return value && typeof value.length === "number" && value.length >= 0 && value.length % 1 === 0;
7393
7401
  }
7394
7402
  var breakLoop = {};
7403
+ var breakLoop$1 = breakLoop;
7395
7404
  function once(fn) {
7396
7405
  function wrapper(...args) {
7397
7406
  if (fn === null) return;
@@ -7483,7 +7492,7 @@ function asyncEachOfLimit(generator, limit, iteratee, callback) {
7483
7492
  canceled = true;
7484
7493
  return;
7485
7494
  }
7486
- if (result === breakLoop || done && running <= 0) {
7495
+ if (result === breakLoop$1 || done && running <= 0) {
7487
7496
  done = true;
7488
7497
  return callback(null);
7489
7498
  }
@@ -7526,7 +7535,7 @@ var eachOfLimit$2 = (limit) => {
7526
7535
  } else if (err === false) {
7527
7536
  done = true;
7528
7537
  canceled = true;
7529
- } else if (value === breakLoop || done && running <= 0) {
7538
+ } else if (value === breakLoop$1 || done && running <= 0) {
7530
7539
  done = true;
7531
7540
  return callback(null);
7532
7541
  } else if (!looping) {
@@ -7569,7 +7578,7 @@ function eachOfArrayLike(coll, iteratee, callback) {
7569
7578
  if (canceled === true) return;
7570
7579
  if (err) {
7571
7580
  callback(err);
7572
- } else if (++completed === length || value === breakLoop) {
7581
+ } else if (++completed === length || value === breakLoop$1) {
7573
7582
  callback(null);
7574
7583
  }
7575
7584
  }
@@ -7599,7 +7608,6 @@ function mapSeries(coll, iteratee, callback) {
7599
7608
  }
7600
7609
  var mapSeries$1 = awaitify(mapSeries, 3);
7601
7610
  var applyEachSeries = applyEach$1(mapSeries$1);
7602
- var PROMISE_SYMBOL = Symbol("promiseCallback");
7603
7611
  var DLL = class {
7604
7612
  constructor() {
7605
7613
  this.head = this.tail = null;
@@ -7965,7 +7973,7 @@ function _createTester(check, getResult) {
7965
7973
  if (check(result) && !testResult) {
7966
7974
  testPassed = true;
7967
7975
  testResult = getResult(true, value);
7968
- return callback(null, breakLoop);
7976
+ return callback(null, breakLoop$1);
7969
7977
  }
7970
7978
  callback();
7971
7979
  });
@@ -8761,7 +8769,7 @@ var EvalResultWithSummary = class {
8761
8769
  toString() {
8762
8770
  return formatExperimentSummary(this.summary);
8763
8771
  }
8764
- [Symbol.for("nodejs.util.inspect.custom")]() {
8772
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
8765
8773
  return `EvalResultWithSummary(summary="...", results=[...])`;
8766
8774
  }
8767
8775
  toJSON() {
@@ -9056,10 +9064,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
9056
9064
  span,
9057
9065
  parameters: _nullishCoalesce(parameters, () => ( {})),
9058
9066
  reportProgress: (event) => {
9059
- _optionalChain([stream, 'optionalCall', _90 => _90({
9067
+ _optionalChain([stream, 'optionalCall', _92 => _92({
9060
9068
  ...event,
9061
9069
  id: rootSpan.id,
9062
- origin: _optionalChain([baseEvent, 'access', _91 => _91.event, 'optionalAccess', _92 => _92.origin]),
9070
+ origin: _optionalChain([baseEvent, 'access', _93 => _93.event, 'optionalAccess', _94 => _94.origin]),
9063
9071
  name: evaluator.evalName,
9064
9072
  object_type: "task"
9065
9073
  })]);
@@ -9214,7 +9222,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
9214
9222
  metadata,
9215
9223
  scores: mergedScores,
9216
9224
  error: error2,
9217
- origin: _optionalChain([baseEvent, 'access', _93 => _93.event, 'optionalAccess', _94 => _94.origin])
9225
+ origin: _optionalChain([baseEvent, 'access', _95 => _95.event, 'optionalAccess', _96 => _96.origin])
9218
9226
  });
9219
9227
  }
9220
9228
  };
@@ -9247,7 +9255,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
9247
9255
  break;
9248
9256
  }
9249
9257
  scheduledTrials++;
9250
- _optionalChain([progressReporter, 'access', _95 => _95.setTotal, 'optionalCall', _96 => _96(evaluator.evalName, scheduledTrials)]);
9258
+ _optionalChain([progressReporter, 'access', _97 => _97.setTotal, 'optionalCall', _98 => _98(evaluator.evalName, scheduledTrials)]);
9251
9259
  q.push({ datum, trialIndex });
9252
9260
  }
9253
9261
  }
@@ -9593,7 +9601,7 @@ async function cachedLogin(options) {
9593
9601
  }
9594
9602
  function makeCheckAuthorized(allowedOrgName) {
9595
9603
  return async (req, _res, next) => {
9596
- if (!_optionalChain([req, 'access', _97 => _97.ctx, 'optionalAccess', _98 => _98.token])) {
9604
+ if (!_optionalChain([req, 'access', _99 => _99.ctx, 'optionalAccess', _100 => _100.token])) {
9597
9605
  return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
9598
9606
  }
9599
9607
  try {
@@ -9606,7 +9614,7 @@ function makeCheckAuthorized(allowedOrgName) {
9606
9614
  return next(_httperrors2.default.call(void 0, 403, errorMessage));
9607
9615
  }
9608
9616
  const state = await cachedLogin({
9609
- apiKey: _optionalChain([req, 'access', _99 => _99.ctx, 'optionalAccess', _100 => _100.token]),
9617
+ apiKey: _optionalChain([req, 'access', _101 => _101.ctx, 'optionalAccess', _102 => _102.token]),
9610
9618
  orgName
9611
9619
  });
9612
9620
  req.ctx.state = state;
@@ -9814,7 +9822,7 @@ function runDevServer(evaluators, opts) {
9814
9822
  scores,
9815
9823
  stream
9816
9824
  } = evalBodySchema.parse(req.body);
9817
- if (!_optionalChain([req, 'access', _101 => _101.ctx, 'optionalAccess', _102 => _102.state])) {
9825
+ if (!_optionalChain([req, 'access', _103 => _103.ctx, 'optionalAccess', _104 => _104.state])) {
9818
9826
  res.status(500).json({ error: "Braintrust state not initialized in request" });
9819
9827
  return;
9820
9828
  }
@@ -9871,12 +9879,12 @@ function runDevServer(evaluators, opts) {
9871
9879
  ...evaluator,
9872
9880
  data: evalData.data,
9873
9881
  scores: evaluator.scores.concat(
9874
- _nullishCoalesce(_optionalChain([scores, 'optionalAccess', _103 => _103.map, 'call', _104 => _104(
9882
+ _nullishCoalesce(_optionalChain([scores, 'optionalAccess', _105 => _105.map, 'call', _106 => _106(
9875
9883
  (score) => makeScorer(
9876
9884
  state,
9877
9885
  score.name,
9878
9886
  score.function_id,
9879
- _optionalChain([req, 'access', _105 => _105.ctx, 'optionalAccess', _106 => _106.projectId])
9887
+ _optionalChain([req, 'access', _107 => _107.ctx, 'optionalAccess', _108 => _108.projectId])
9880
9888
  )
9881
9889
  )]), () => ( []))
9882
9890
  ),