braintrust 3.20.0 → 3.22.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.
Files changed (88) hide show
  1. package/NOTICE +20 -0
  2. package/README.md +6 -0
  3. package/dev/dist/index.d.mts +1338 -199
  4. package/dev/dist/index.d.ts +1338 -199
  5. package/dev/dist/index.js +2904 -997
  6. package/dev/dist/index.mjs +2418 -511
  7. package/dist/apply-auto-instrumentation.js +781 -199
  8. package/dist/apply-auto-instrumentation.mjs +588 -6
  9. package/dist/auto-instrumentations/bundler/esbuild.cjs +594 -2
  10. package/dist/auto-instrumentations/bundler/esbuild.d.mts +2 -2
  11. package/dist/auto-instrumentations/bundler/esbuild.d.ts +2 -2
  12. package/dist/auto-instrumentations/bundler/esbuild.mjs +3 -3
  13. package/dist/auto-instrumentations/bundler/next.cjs +594 -2
  14. package/dist/auto-instrumentations/bundler/next.mjs +4 -4
  15. package/dist/auto-instrumentations/bundler/rollup.cjs +594 -2
  16. package/dist/auto-instrumentations/bundler/rollup.d.mts +2 -2
  17. package/dist/auto-instrumentations/bundler/rollup.d.ts +2 -2
  18. package/dist/auto-instrumentations/bundler/rollup.mjs +3 -3
  19. package/dist/auto-instrumentations/bundler/vite.cjs +594 -2
  20. package/dist/auto-instrumentations/bundler/vite.d.mts +2 -2
  21. package/dist/auto-instrumentations/bundler/vite.d.ts +2 -2
  22. package/dist/auto-instrumentations/bundler/vite.mjs +3 -3
  23. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +593 -9
  24. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +68 -1
  25. package/dist/auto-instrumentations/bundler/webpack.cjs +594 -2
  26. package/dist/auto-instrumentations/bundler/webpack.d.mts +2 -2
  27. package/dist/auto-instrumentations/bundler/webpack.d.ts +2 -2
  28. package/dist/auto-instrumentations/bundler/webpack.mjs +4 -4
  29. package/dist/auto-instrumentations/{chunk-W4E36GIW.mjs → chunk-BRQX23KL.mjs} +16 -0
  30. package/dist/auto-instrumentations/chunk-M6DLIJ2Z.mjs +784 -0
  31. package/dist/auto-instrumentations/{chunk-K74TZGGM.mjs → chunk-T6J4C7LX.mjs} +1 -1
  32. package/dist/auto-instrumentations/{chunk-S4374IP6.mjs → chunk-TKRPRPGD.mjs} +4 -6
  33. package/dist/auto-instrumentations/chunk-VT6DDNKM.mjs +856 -0
  34. package/dist/auto-instrumentations/hook.mjs +824 -56
  35. package/dist/auto-instrumentations/index.cjs +16 -0
  36. package/dist/auto-instrumentations/index.d.mts +2 -3
  37. package/dist/auto-instrumentations/index.d.ts +2 -3
  38. package/dist/auto-instrumentations/index.mjs +1 -1
  39. package/dist/auto-instrumentations/loader/cjs-patch.cjs +578 -4
  40. package/dist/auto-instrumentations/loader/cjs-patch.d.mts +1 -1
  41. package/dist/auto-instrumentations/loader/cjs-patch.d.ts +1 -1
  42. package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -7
  43. package/dist/auto-instrumentations/loader/esm-hook.mjs +2 -6
  44. package/dist/auto-instrumentations/{plugin-D7nDswtC.d.mts → plugin-D0KHwSJv.d.mts} +1 -1
  45. package/dist/auto-instrumentations/{plugin-D7nDswtC.d.ts → plugin-G6fgxk1b.d.ts} +1 -1
  46. package/dist/auto-instrumentations/types-RNPaKi9o.d.mts +70 -0
  47. package/dist/auto-instrumentations/types-RNPaKi9o.d.ts +70 -0
  48. package/dist/browser.d.mts +4411 -719
  49. package/dist/browser.d.ts +4411 -719
  50. package/dist/browser.js +4274 -480
  51. package/dist/browser.mjs +4274 -480
  52. package/dist/{chunk-LPC4W2WX.js → chunk-BFGIH2ZJ.js} +4 -0
  53. package/dist/{chunk-Y7W7WP6H.mjs → chunk-KMGUTPB7.mjs} +4 -0
  54. package/dist/{chunk-POCCIJAL.js → chunk-MWVVR5LR.js} +3278 -1334
  55. package/dist/{chunk-F73OMF66.mjs → chunk-ZG2O3XVF.mjs} +2542 -598
  56. package/dist/cli.js +2338 -419
  57. package/dist/edge-light.d.mts +1 -1
  58. package/dist/edge-light.d.ts +1 -1
  59. package/dist/edge-light.js +4274 -480
  60. package/dist/edge-light.mjs +4274 -480
  61. package/dist/index.d.mts +4926 -1234
  62. package/dist/index.d.ts +4926 -1234
  63. package/dist/index.js +2303 -435
  64. package/dist/index.mjs +1914 -46
  65. package/dist/instrumentation/index.d.mts +1026 -20
  66. package/dist/instrumentation/index.d.ts +1026 -20
  67. package/dist/instrumentation/index.js +3864 -483
  68. package/dist/instrumentation/index.mjs +3862 -483
  69. package/dist/vitest-evals-reporter.js +16 -16
  70. package/dist/vitest-evals-reporter.mjs +2 -2
  71. package/dist/workerd.d.mts +1 -1
  72. package/dist/workerd.d.ts +1 -1
  73. package/dist/workerd.js +4274 -480
  74. package/dist/workerd.mjs +4274 -480
  75. package/licenses/import-in-the-middle/LICENSE +201 -0
  76. package/licenses/import-in-the-middle/LICENSE-3rdparty.csv +4 -0
  77. package/licenses/import-in-the-middle/NOTICE +34 -0
  78. package/licenses/orchestrion-js/LICENSE +202 -0
  79. package/licenses/orchestrion-js/LICENSE-3rdparty.csv +8 -0
  80. package/licenses/orchestrion-js/NOTICE +3 -0
  81. package/licenses/require-in-the-middle/LICENSE +23 -0
  82. package/package.json +16 -4
  83. package/util/dist/index.d.mts +1 -0
  84. package/util/dist/index.d.ts +1 -0
  85. package/util/dist/index.js +4 -4
  86. package/util/dist/index.mjs +2 -2
  87. package/dist/auto-instrumentations/chunk-J57YF7WS.mjs +0 -208
  88. package/dist/auto-instrumentations/chunk-QFMACSOL.mjs +0 -280
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11;
2
2
 
3
3
 
4
4
 
@@ -129,7 +129,6 @@
129
129
 
130
130
 
131
131
 
132
- var _chunkPOCCIJALjs = require('./chunk-POCCIJAL.js');
133
132
 
134
133
 
135
134
 
@@ -140,6 +139,7 @@ var _chunkPOCCIJALjs = require('./chunk-POCCIJAL.js');
140
139
 
141
140
 
142
141
 
142
+ var _chunkMWVVR5LRjs = require('./chunk-MWVVR5LR.js');
143
143
 
144
144
 
145
145
 
@@ -152,141 +152,161 @@ var _chunkPOCCIJALjs = require('./chunk-POCCIJAL.js');
152
152
 
153
153
 
154
154
 
155
- var _chunkLPC4W2WXjs = require('./chunk-LPC4W2WX.js');
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+ var _chunkBFGIH2ZJjs = require('./chunk-BFGIH2ZJ.js');
156
166
 
157
167
  // src/exports.ts
158
168
  var exports_exports = {};
159
- _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
160
- Attachment: () => _chunkPOCCIJALjs.Attachment,
161
- AttachmentReference: () => _chunkPOCCIJALjs.AttachmentReference,
162
- BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkPOCCIJALjs.BRAINTRUST_CURRENT_SPAN_STORE,
163
- BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkPOCCIJALjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
164
- BaseAttachment: () => _chunkPOCCIJALjs.BaseAttachment,
169
+ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
170
+ Attachment: () => _chunkMWVVR5LRjs.Attachment,
171
+ AttachmentReference: () => _chunkMWVVR5LRjs.AttachmentReference,
172
+ BAGGAGE_HEADER: () => _chunkMWVVR5LRjs.BAGGAGE_HEADER,
173
+ BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkMWVVR5LRjs.BRAINTRUST_CURRENT_SPAN_STORE,
174
+ BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkMWVVR5LRjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
175
+ BRAINTRUST_PARENT_KEY: () => _chunkMWVVR5LRjs.BRAINTRUST_PARENT_KEY,
176
+ BaseAttachment: () => _chunkMWVVR5LRjs.BaseAttachment,
165
177
  BaseExperiment: () => BaseExperiment,
166
- BraintrustLangChainCallbackHandler: () => _chunkPOCCIJALjs.BraintrustLangChainCallbackHandler,
178
+ BraintrustLangChainCallbackHandler: () => _chunkMWVVR5LRjs.BraintrustLangChainCallbackHandler,
167
179
  BraintrustMiddleware: () => BraintrustMiddleware,
168
- BraintrustObservabilityExporter: () => _chunkPOCCIJALjs.BraintrustObservabilityExporter,
169
- BraintrustState: () => _chunkPOCCIJALjs.BraintrustState,
170
- BraintrustStream: () => _chunkPOCCIJALjs.BraintrustStream,
180
+ BraintrustObservabilityExporter: () => _chunkMWVVR5LRjs.BraintrustObservabilityExporter,
181
+ BraintrustState: () => _chunkMWVVR5LRjs.BraintrustState,
182
+ BraintrustStream: () => _chunkMWVVR5LRjs.BraintrustStream,
171
183
  CachedSpanFetcher: () => CachedSpanFetcher,
172
184
  CodeFunction: () => CodeFunction,
173
185
  CodePrompt: () => CodePrompt,
174
- ContextManager: () => _chunkPOCCIJALjs.ContextManager,
175
- DEFAULT_FETCH_BATCH_SIZE: () => _chunkPOCCIJALjs.DEFAULT_FETCH_BATCH_SIZE,
176
- DEFAULT_MAX_REQUEST_SIZE: () => _chunkPOCCIJALjs.DEFAULT_MAX_REQUEST_SIZE,
177
- Dataset: () => _chunkPOCCIJALjs.Dataset,
186
+ ContextManager: () => _chunkMWVVR5LRjs.ContextManager,
187
+ DEFAULT_FETCH_BATCH_SIZE: () => _chunkMWVVR5LRjs.DEFAULT_FETCH_BATCH_SIZE,
188
+ DEFAULT_MAX_REQUEST_SIZE: () => _chunkMWVVR5LRjs.DEFAULT_MAX_REQUEST_SIZE,
189
+ Dataset: () => _chunkMWVVR5LRjs.Dataset,
178
190
  DatasetPipeline: () => DatasetPipeline,
179
- ERR_PERMALINK: () => _chunkPOCCIJALjs.ERR_PERMALINK,
191
+ ERR_PERMALINK: () => _chunkMWVVR5LRjs.ERR_PERMALINK,
180
192
  Eval: () => Eval,
181
193
  EvalResultWithSummary: () => EvalResultWithSummary,
182
- Experiment: () => _chunkPOCCIJALjs.Experiment,
183
- ExternalAttachment: () => _chunkPOCCIJALjs.ExternalAttachment,
184
- FailedHTTPResponse: () => _chunkPOCCIJALjs.FailedHTTPResponse,
185
- IDGenerator: () => _chunkPOCCIJALjs.IDGenerator,
186
- JSONAttachment: () => _chunkPOCCIJALjs.JSONAttachment,
187
- LEGACY_CACHED_HEADER: () => _chunkPOCCIJALjs.LEGACY_CACHED_HEADER,
188
- LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkPOCCIJALjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
189
- LazyValue: () => _chunkPOCCIJALjs.LazyValue,
194
+ Experiment: () => _chunkMWVVR5LRjs.Experiment,
195
+ ExternalAttachment: () => _chunkMWVVR5LRjs.ExternalAttachment,
196
+ FailedHTTPResponse: () => _chunkMWVVR5LRjs.FailedHTTPResponse,
197
+ IDGenerator: () => _chunkMWVVR5LRjs.IDGenerator,
198
+ JSONAttachment: () => _chunkMWVVR5LRjs.JSONAttachment,
199
+ LEGACY_CACHED_HEADER: () => _chunkMWVVR5LRjs.LEGACY_CACHED_HEADER,
200
+ LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkMWVVR5LRjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
201
+ LazyValue: () => _chunkMWVVR5LRjs.LazyValue,
190
202
  LocalTrace: () => LocalTrace,
191
- Logger: () => _chunkPOCCIJALjs.Logger,
192
- LoginInvalidOrgError: () => _chunkPOCCIJALjs.LoginInvalidOrgError,
193
- NOOP_SPAN: () => _chunkPOCCIJALjs.NOOP_SPAN,
194
- NOOP_SPAN_PERMALINK: () => _chunkPOCCIJALjs.NOOP_SPAN_PERMALINK,
195
- NoopSpan: () => _chunkPOCCIJALjs.NoopSpan,
196
- ObjectFetcher: () => _chunkPOCCIJALjs.ObjectFetcher,
203
+ Logger: () => _chunkMWVVR5LRjs.Logger,
204
+ LoginInvalidOrgError: () => _chunkMWVVR5LRjs.LoginInvalidOrgError,
205
+ NOOP_SPAN: () => _chunkMWVVR5LRjs.NOOP_SPAN,
206
+ NOOP_SPAN_PERMALINK: () => _chunkMWVVR5LRjs.NOOP_SPAN_PERMALINK,
207
+ NoopSpan: () => _chunkMWVVR5LRjs.NoopSpan,
208
+ OTELIDGenerator: () => _chunkMWVVR5LRjs.OTELIDGenerator,
209
+ ObjectFetcher: () => _chunkMWVVR5LRjs.ObjectFetcher,
197
210
  Project: () => Project2,
198
211
  ProjectNameIdMap: () => ProjectNameIdMap,
199
- Prompt: () => _chunkPOCCIJALjs.Prompt,
212
+ Prompt: () => _chunkMWVVR5LRjs.Prompt,
200
213
  PromptBuilder: () => PromptBuilder,
201
- ReadonlyAttachment: () => _chunkPOCCIJALjs.ReadonlyAttachment,
202
- ReadonlyExperiment: () => _chunkPOCCIJALjs.ReadonlyExperiment,
214
+ ReadonlyAttachment: () => _chunkMWVVR5LRjs.ReadonlyAttachment,
215
+ ReadonlyExperiment: () => _chunkMWVVR5LRjs.ReadonlyExperiment,
203
216
  Reporter: () => Reporter,
204
217
  ScorerBuilder: () => ScorerBuilder,
205
218
  SpanFetcher: () => SpanFetcher,
206
- SpanImpl: () => _chunkPOCCIJALjs.SpanImpl,
207
- TestBackgroundLogger: () => _chunkPOCCIJALjs.TestBackgroundLogger,
219
+ SpanImpl: () => _chunkMWVVR5LRjs.SpanImpl,
220
+ TRACEPARENT_HEADER: () => _chunkMWVVR5LRjs.TRACEPARENT_HEADER,
221
+ TRACESTATE_HEADER: () => _chunkMWVVR5LRjs.TRACESTATE_HEADER,
222
+ TestBackgroundLogger: () => _chunkMWVVR5LRjs.TestBackgroundLogger,
208
223
  ToolBuilder: () => ToolBuilder,
209
- UUIDGenerator: () => _chunkPOCCIJALjs.UUIDGenerator,
210
- X_CACHED_HEADER: () => _chunkPOCCIJALjs.X_CACHED_HEADER,
211
- _exportsForTestingOnly: () => _chunkPOCCIJALjs._exportsForTestingOnly,
212
- _internalGetGlobalState: () => _chunkPOCCIJALjs._internalGetGlobalState,
213
- _internalIso: () => _chunkLPC4W2WXjs.isomorph_default,
214
- _internalSetInitialState: () => _chunkPOCCIJALjs._internalSetInitialState,
215
- addAzureBlobHeaders: () => _chunkPOCCIJALjs.addAzureBlobHeaders,
216
- braintrustAISDKTelemetry: () => _chunkPOCCIJALjs.braintrustAISDKTelemetry,
217
- braintrustFlueInstrumentation: () => _chunkPOCCIJALjs.braintrustFlueInstrumentation,
218
- braintrustFlueObserver: () => _chunkPOCCIJALjs.braintrustFlueObserver,
219
- braintrustStreamChunkSchema: () => _chunkPOCCIJALjs.braintrustStreamChunkSchema,
224
+ UUIDGenerator: () => _chunkMWVVR5LRjs.UUIDGenerator,
225
+ X_CACHED_HEADER: () => _chunkMWVVR5LRjs.X_CACHED_HEADER,
226
+ _exportsForTestingOnly: () => _chunkMWVVR5LRjs._exportsForTestingOnly,
227
+ _internalGetGlobalState: () => _chunkMWVVR5LRjs._internalGetGlobalState,
228
+ _internalIso: () => _chunkBFGIH2ZJjs.isomorph_default,
229
+ _internalSetInitialState: () => _chunkMWVVR5LRjs._internalSetInitialState,
230
+ addAzureBlobHeaders: () => _chunkMWVVR5LRjs.addAzureBlobHeaders,
231
+ agentAssertionScorer: () => agentAssertionScorer,
232
+ braintrustAISDKTelemetry: () => _chunkMWVVR5LRjs.braintrustAISDKTelemetry,
233
+ braintrustEveHook: () => braintrustEveHook,
234
+ braintrustEveInstrumentation: () => braintrustEveInstrumentation,
235
+ braintrustFlueInstrumentation: () => _chunkMWVVR5LRjs.braintrustFlueInstrumentation,
236
+ braintrustFlueObserver: () => _chunkMWVVR5LRjs.braintrustFlueObserver,
237
+ braintrustStreamChunkSchema: () => _chunkMWVVR5LRjs.braintrustStreamChunkSchema,
220
238
  buildLocalSummary: () => buildLocalSummary,
221
- configureInstrumentation: () => _chunkPOCCIJALjs.configureInstrumentation,
222
- constructLogs3OverflowRequest: () => _chunkPOCCIJALjs.constructLogs3OverflowRequest,
223
- createFinalValuePassThroughStream: () => _chunkPOCCIJALjs.createFinalValuePassThroughStream,
224
- currentExperiment: () => _chunkPOCCIJALjs.currentExperiment,
225
- currentLogger: () => _chunkPOCCIJALjs.currentLogger,
226
- currentSpan: () => _chunkPOCCIJALjs.currentSpan,
227
- deepCopyEvent: () => _chunkPOCCIJALjs.deepCopyEvent,
239
+ configureInstrumentation: () => _chunkMWVVR5LRjs.configureInstrumentation,
240
+ constructLogs3OverflowRequest: () => _chunkMWVVR5LRjs.constructLogs3OverflowRequest,
241
+ createFinalValuePassThroughStream: () => _chunkMWVVR5LRjs.createFinalValuePassThroughStream,
242
+ currentExperiment: () => _chunkMWVVR5LRjs.currentExperiment,
243
+ currentLogger: () => _chunkMWVVR5LRjs.currentLogger,
244
+ currentSpan: () => _chunkMWVVR5LRjs.currentSpan,
245
+ deepCopyEvent: () => _chunkMWVVR5LRjs.deepCopyEvent,
228
246
  defaultErrorScoreHandler: () => defaultErrorScoreHandler,
229
- deserializePlainStringAsJSON: () => _chunkPOCCIJALjs.deserializePlainStringAsJSON,
230
- devNullWritableStream: () => _chunkPOCCIJALjs.devNullWritableStream,
247
+ deserializePlainStringAsJSON: () => _chunkMWVVR5LRjs.deserializePlainStringAsJSON,
248
+ devNullWritableStream: () => _chunkMWVVR5LRjs.devNullWritableStream,
231
249
  evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
232
250
  evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
233
- flush: () => _chunkPOCCIJALjs.flush,
234
- getContextManager: () => _chunkPOCCIJALjs.getContextManager,
235
- getIdGenerator: () => _chunkPOCCIJALjs.getIdGenerator,
236
- getPromptVersions: () => _chunkPOCCIJALjs.getPromptVersions,
237
- getSpanParentObject: () => _chunkPOCCIJALjs.getSpanParentObject,
238
- getTemplateRenderer: () => _chunkPOCCIJALjs.getTemplateRenderer,
251
+ extractTraceContextFromHeaders: () => _chunkMWVVR5LRjs.extractTraceContextFromHeaders,
252
+ flush: () => _chunkMWVVR5LRjs.flush,
253
+ getContextManager: () => _chunkMWVVR5LRjs.getContextManager,
254
+ getIdGenerator: () => _chunkMWVVR5LRjs.getIdGenerator,
255
+ getPromptVersions: () => _chunkMWVVR5LRjs.getPromptVersions,
256
+ getSpanParentObject: () => _chunkMWVVR5LRjs.getSpanParentObject,
257
+ getTemplateRenderer: () => _chunkMWVVR5LRjs.getTemplateRenderer,
239
258
  graph: () => graph_framework_exports,
240
- init: () => _chunkPOCCIJALjs.init,
241
- initDataset: () => _chunkPOCCIJALjs.initDataset,
242
- initExperiment: () => _chunkPOCCIJALjs.initExperiment,
259
+ init: () => _chunkMWVVR5LRjs.init,
260
+ initDataset: () => _chunkMWVVR5LRjs.initDataset,
261
+ initExperiment: () => _chunkMWVVR5LRjs.initExperiment,
243
262
  initFunction: () => initFunction,
244
- initLogger: () => _chunkPOCCIJALjs.initLogger,
263
+ initLogger: () => _chunkMWVVR5LRjs.initLogger,
245
264
  initNodeTestSuite: () => initNodeTestSuite,
265
+ injectTraceContext: () => _chunkMWVVR5LRjs.injectTraceContext,
246
266
  invoke: () => invoke,
247
- isTemplateFormat: () => _chunkPOCCIJALjs.isTemplateFormat,
248
- loadParameters: () => _chunkPOCCIJALjs.loadParameters,
249
- loadPrompt: () => _chunkPOCCIJALjs.loadPrompt,
250
- log: () => _chunkPOCCIJALjs.log,
251
- logError: () => _chunkPOCCIJALjs.logError,
252
- login: () => _chunkPOCCIJALjs.login,
253
- loginToState: () => _chunkPOCCIJALjs.loginToState,
254
- logs3OverflowUploadSchema: () => _chunkPOCCIJALjs.logs3OverflowUploadSchema,
255
- newId: () => _chunkPOCCIJALjs.newId,
256
- parseCachedHeader: () => _chunkPOCCIJALjs.parseCachedHeader,
257
- parseTemplateFormat: () => _chunkPOCCIJALjs.parseTemplateFormat,
258
- permalink: () => _chunkPOCCIJALjs.permalink,
259
- pickLogs3OverflowObjectIds: () => _chunkPOCCIJALjs.pickLogs3OverflowObjectIds,
267
+ isTemplateFormat: () => _chunkMWVVR5LRjs.isTemplateFormat,
268
+ loadParameters: () => _chunkMWVVR5LRjs.loadParameters,
269
+ loadPrompt: () => _chunkMWVVR5LRjs.loadPrompt,
270
+ log: () => _chunkMWVVR5LRjs.log,
271
+ logError: () => _chunkMWVVR5LRjs.logError,
272
+ login: () => _chunkMWVVR5LRjs.login,
273
+ loginToState: () => _chunkMWVVR5LRjs.loginToState,
274
+ logs3OverflowUploadSchema: () => _chunkMWVVR5LRjs.logs3OverflowUploadSchema,
275
+ newId: () => _chunkMWVVR5LRjs.newId,
276
+ parseCachedHeader: () => _chunkMWVVR5LRjs.parseCachedHeader,
277
+ parseTemplateFormat: () => _chunkMWVVR5LRjs.parseTemplateFormat,
278
+ permalink: () => _chunkMWVVR5LRjs.permalink,
279
+ pickLogs3OverflowObjectIds: () => _chunkMWVVR5LRjs.pickLogs3OverflowObjectIds,
260
280
  projects: () => projects,
261
281
  promptContentsSchema: () => promptContentsSchema,
262
282
  promptDefinitionSchema: () => promptDefinitionSchema,
263
283
  promptDefinitionToPromptData: () => promptDefinitionToPromptData,
264
284
  promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
265
- registerOtelFlush: () => _chunkPOCCIJALjs.registerOtelFlush,
285
+ registerOtelFlush: () => _chunkMWVVR5LRjs.registerOtelFlush,
266
286
  registerSandbox: () => registerSandbox,
267
- registerTemplatePlugin: () => _chunkPOCCIJALjs.registerTemplatePlugin,
268
- renderMessage: () => _chunkPOCCIJALjs.renderMessage,
269
- renderPromptParams: () => _chunkPOCCIJALjs.renderPromptParams,
270
- renderTemplateContent: () => _chunkPOCCIJALjs.renderTemplateContent,
287
+ registerTemplatePlugin: () => _chunkMWVVR5LRjs.registerTemplatePlugin,
288
+ renderMessage: () => _chunkMWVVR5LRjs.renderMessage,
289
+ renderPromptParams: () => _chunkMWVVR5LRjs.renderPromptParams,
290
+ renderTemplateContent: () => _chunkMWVVR5LRjs.renderTemplateContent,
271
291
  reportFailures: () => reportFailures,
272
292
  runEvaluator: () => runEvaluator,
273
- setFetch: () => _chunkPOCCIJALjs.setFetch,
274
- setMaskingFunction: () => _chunkPOCCIJALjs.setMaskingFunction,
275
- spanComponentsToObjectId: () => _chunkPOCCIJALjs.spanComponentsToObjectId,
276
- startSpan: () => _chunkPOCCIJALjs.startSpan,
277
- summarize: () => _chunkPOCCIJALjs.summarize,
278
- templateRegistry: () => _chunkPOCCIJALjs.templateRegistry,
279
- toolFunctionDefinitionSchema: () => _chunkPOCCIJALjs.ToolFunctionDefinition,
280
- traceable: () => _chunkPOCCIJALjs.traceable,
281
- traced: () => _chunkPOCCIJALjs.traced,
282
- updateSpan: () => _chunkPOCCIJALjs.updateSpan,
283
- uploadLogs3OverflowPayload: () => _chunkPOCCIJALjs.uploadLogs3OverflowPayload,
284
- utf8ByteLength: () => _chunkPOCCIJALjs.utf8ByteLength,
285
- withCurrent: () => _chunkPOCCIJALjs.withCurrent,
286
- withDataset: () => _chunkPOCCIJALjs.withDataset,
287
- withExperiment: () => _chunkPOCCIJALjs.withExperiment,
288
- withLogger: () => _chunkPOCCIJALjs.withLogger,
289
- withParent: () => _chunkPOCCIJALjs.withParent,
293
+ setFetch: () => _chunkMWVVR5LRjs.setFetch,
294
+ setMaskingFunction: () => _chunkMWVVR5LRjs.setMaskingFunction,
295
+ spanComponentsToObjectId: () => _chunkMWVVR5LRjs.spanComponentsToObjectId,
296
+ startSpan: () => _chunkMWVVR5LRjs.startSpan,
297
+ summarize: () => _chunkMWVVR5LRjs.summarize,
298
+ templateRegistry: () => _chunkMWVVR5LRjs.templateRegistry,
299
+ toolFunctionDefinitionSchema: () => _chunkMWVVR5LRjs.ToolFunctionDefinition,
300
+ traceable: () => _chunkMWVVR5LRjs.traceable,
301
+ traced: () => _chunkMWVVR5LRjs.traced,
302
+ updateSpan: () => _chunkMWVVR5LRjs.updateSpan,
303
+ uploadLogs3OverflowPayload: () => _chunkMWVVR5LRjs.uploadLogs3OverflowPayload,
304
+ utf8ByteLength: () => _chunkMWVVR5LRjs.utf8ByteLength,
305
+ withCurrent: () => _chunkMWVVR5LRjs.withCurrent,
306
+ withDataset: () => _chunkMWVVR5LRjs.withDataset,
307
+ withExperiment: () => _chunkMWVVR5LRjs.withExperiment,
308
+ withLogger: () => _chunkMWVVR5LRjs.withLogger,
309
+ withParent: () => _chunkMWVVR5LRjs.withParent,
290
310
  wrapAISDK: () => wrapAISDK,
291
311
  wrapAISDKModel: () => wrapAISDKModel,
292
312
  wrapAgentClass: () => wrapAgentClass,
@@ -301,7 +321,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
301
321
  wrapGoogleGenAI: () => wrapGoogleGenAI,
302
322
  wrapGroq: () => wrapGroq,
303
323
  wrapHuggingFace: () => wrapHuggingFace,
304
- wrapMastraAgent: () => _chunkPOCCIJALjs.wrapMastraAgent,
324
+ wrapMastraAgent: () => _chunkMWVVR5LRjs.wrapMastraAgent,
305
325
  wrapMistral: () => wrapMistral,
306
326
  wrapOpenAI: () => wrapOpenAI,
307
327
  wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
@@ -310,7 +330,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
310
330
  wrapOpenRouterAgent: () => wrapOpenRouterAgent,
311
331
  wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
312
332
  wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
313
- wrapTraced: () => _chunkPOCCIJALjs.wrapTraced,
333
+ wrapTraced: () => _chunkMWVVR5LRjs.wrapTraced,
314
334
  wrapVitest: () => wrapVitest
315
335
  });
316
336
 
@@ -318,7 +338,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
318
338
  var _v3 = require('zod/v3');
319
339
  var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
320
340
  async function registerSandbox(options) {
321
- const state = _nullishCoalesce(options.state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )));
341
+ const state = _nullishCoalesce(options.state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )));
322
342
  await state.login({
323
343
  apiKey: options.apiKey,
324
344
  appUrl: options.appUrl,
@@ -359,7 +379,7 @@ async function registerSandbox(options) {
359
379
  evaluatorDefinitions
360
380
  )) {
361
381
  const functionName = evalName;
362
- const functionSlug = _chunkPOCCIJALjs.slugify.call(void 0, evalName, { lower: true, strict: true });
382
+ const functionSlug = _chunkMWVVR5LRjs.slugify.call(void 0, evalName, { lower: true, strict: true });
363
383
  const functionDef = {
364
384
  project_id: projectId,
365
385
  org_name: state.orgName,
@@ -430,7 +450,7 @@ async function invoke(args) {
430
450
  projectId,
431
451
  ...functionIdArgs
432
452
  } = args;
433
- const state = _nullishCoalesce(stateArg, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )));
453
+ const state = _nullishCoalesce(stateArg, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )));
434
454
  await state.login({
435
455
  orgName,
436
456
  apiKey,
@@ -438,8 +458,8 @@ async function invoke(args) {
438
458
  forceLogin,
439
459
  fetch
440
460
  });
441
- const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkPOCCIJALjs.getSpanParentObject.call(void 0, ).export();
442
- const functionId = _chunkPOCCIJALjs.FunctionId.safeParse({
461
+ const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkMWVVR5LRjs.getSpanParentObject.call(void 0, ).export();
462
+ const functionId = _chunkMWVVR5LRjs.FunctionId.safeParse({
443
463
  function_id: functionIdArgs.function_id,
444
464
  project_name: functionIdArgs.projectName,
445
465
  slug: functionIdArgs.slug,
@@ -482,7 +502,7 @@ async function invoke(args) {
482
502
  if (!resp.body) {
483
503
  throw new Error("Received empty stream body");
484
504
  }
485
- return new (0, _chunkPOCCIJALjs.BraintrustStream)(resp.body);
505
+ return new (0, _chunkMWVVR5LRjs.BraintrustStream)(resp.body);
486
506
  } else {
487
507
  const data = await resp.json();
488
508
  return schema ? schema.parse(data) : data;
@@ -494,7 +514,7 @@ function initFunction({
494
514
  version,
495
515
  state
496
516
  }) {
497
- const s = _nullishCoalesce(state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )));
517
+ const s = _nullishCoalesce(state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )));
498
518
  _optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
499
519
  const f = async (input) => {
500
520
  return await invoke({
@@ -572,22 +592,22 @@ function responsesProxy(openai) {
572
592
  if (name === "create" && typeof target.create === "function") {
573
593
  return wrapResponsesAsync(
574
594
  target.create.bind(target),
575
- _chunkLPC4W2WXjs.openAIChannels.responsesCreate
595
+ _chunkBFGIH2ZJjs.openAIChannels.responsesCreate
576
596
  );
577
597
  } else if (name === "stream" && typeof target.stream === "function") {
578
598
  return wrapResponsesSyncStream(
579
599
  target.stream.bind(target),
580
- _chunkLPC4W2WXjs.openAIChannels.responsesStream
600
+ _chunkBFGIH2ZJjs.openAIChannels.responsesStream
581
601
  );
582
602
  } else if (name === "parse" && typeof target.parse === "function") {
583
603
  return wrapResponsesAsync(
584
604
  target.parse.bind(target),
585
- _chunkLPC4W2WXjs.openAIChannels.responsesParse
605
+ _chunkBFGIH2ZJjs.openAIChannels.responsesParse
586
606
  );
587
607
  } else if (name === "compact" && typeof target.compact === "function") {
588
608
  return wrapResponsesAsync(
589
609
  target.compact.bind(target),
590
- _chunkLPC4W2WXjs.openAIChannels.responsesCompact
610
+ _chunkBFGIH2ZJjs.openAIChannels.responsesCompact
591
611
  );
592
612
  }
593
613
  return Reflect.get(target, name, receiver);
@@ -731,7 +751,7 @@ function wrapBetaChatCompletionParse(completion) {
731
751
  const { span_info, params } = splitSpanInfo(
732
752
  allParams
733
753
  );
734
- return _chunkLPC4W2WXjs.openAIChannels.betaChatCompletionsParse.tracePromise(
754
+ return _chunkBFGIH2ZJjs.openAIChannels.betaChatCompletionsParse.tracePromise(
735
755
  async () => await completion(params),
736
756
  { arguments: [params], span_info }
737
757
  );
@@ -742,7 +762,7 @@ function wrapBetaChatCompletionStream(completion) {
742
762
  const { span_info, params } = splitSpanInfo(
743
763
  allParams
744
764
  );
745
- return _chunkLPC4W2WXjs.openAIChannels.betaChatCompletionsStream.traceSync(
765
+ return _chunkBFGIH2ZJjs.openAIChannels.betaChatCompletionsStream.traceSync(
746
766
  () => completion(params),
747
767
  { arguments: [params], span_info }
748
768
  );
@@ -758,7 +778,7 @@ function wrapChatCompletion(completion) {
758
778
  if (!executionPromise) {
759
779
  executionPromise = (async () => {
760
780
  const traceContext = createChannelContext(
761
- _chunkLPC4W2WXjs.openAIChannels.chatCompletionsCreate,
781
+ _chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
762
782
  params,
763
783
  span_info
764
784
  );
@@ -768,7 +788,7 @@ function wrapChatCompletion(completion) {
768
788
  options
769
789
  );
770
790
  const { data: data2, response: response2 } = await tracePromiseWithResponse(
771
- _chunkLPC4W2WXjs.openAIChannels.chatCompletionsCreate,
791
+ _chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
772
792
  traceContext,
773
793
  completionPromise
774
794
  );
@@ -779,7 +799,7 @@ function wrapChatCompletion(completion) {
779
799
  options
780
800
  );
781
801
  const { data, response } = await tracePromiseWithResponse(
782
- _chunkLPC4W2WXjs.openAIChannels.chatCompletionsCreate,
802
+ _chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
783
803
  traceContext,
784
804
  completionResponse
785
805
  );
@@ -822,8 +842,8 @@ function wrapApiCreateWithChannel(create, channel) {
822
842
  return createLazyAPIPromise(ensureExecuted);
823
843
  };
824
844
  }
825
- var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkLPC4W2WXjs.openAIChannels.embeddingsCreate);
826
- var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkLPC4W2WXjs.openAIChannels.moderationsCreate);
845
+ var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkBFGIH2ZJjs.openAIChannels.embeddingsCreate);
846
+ var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkBFGIH2ZJjs.openAIChannels.moderationsCreate);
827
847
 
828
848
  // src/wrappers/ai-sdk/ai-sdk.ts
829
849
  function isModuleNamespace(obj) {
@@ -874,6 +894,7 @@ function wrapAISDK(aiSDK, options = {}) {
874
894
  case "Agent":
875
895
  case "Experimental_Agent":
876
896
  case "ToolLoopAgent":
897
+ case "WorkflowAgent":
877
898
  return original ? wrapAgentClass(original, options) : original;
878
899
  }
879
900
  return original;
@@ -892,10 +913,10 @@ var wrapAgentClass = (AgentClass, options = {}) => {
892
913
  return new Proxy(instance, {
893
914
  get(instanceTarget, prop, instanceReceiver) {
894
915
  const original = Reflect.get(instanceTarget, prop, instanceTarget);
895
- if (prop === "generate") {
916
+ if (prop === "generate" && typeof original === "function" && instanceTarget.constructor.name !== "WorkflowAgent") {
896
917
  return wrapAgentGenerate(original, instanceTarget, options);
897
918
  }
898
- if (prop === "stream") {
919
+ if (prop === "stream" && typeof original === "function") {
899
920
  return wrapAgentStream(original, instanceTarget, options);
900
921
  }
901
922
  if (typeof original === "function") {
@@ -910,7 +931,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
910
931
  var wrapAgentGenerate = (generate, instance, options = {}) => {
911
932
  const defaultName = `${instance.constructor.name}.generate`;
912
933
  return async (params) => makeGenerateTextWrapper(
913
- _chunkLPC4W2WXjs.aiSDKChannels.generateText,
934
+ generateChannelForAgent(instance.constructor.name),
914
935
  defaultName,
915
936
  generate.bind(instance),
916
937
  {
@@ -920,19 +941,42 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
920
941
  options
921
942
  )({ ...instance.settings, ...params });
922
943
  };
944
+ function generateChannelForAgent(agentName) {
945
+ if (agentName === "ToolLoopAgent") {
946
+ return _chunkBFGIH2ZJjs.aiSDKChannels.toolLoopAgentGenerate;
947
+ }
948
+ return _chunkBFGIH2ZJjs.aiSDKChannels.agentGenerate;
949
+ }
923
950
  var wrapAgentStream = (stream, instance, options = {}) => {
924
951
  const defaultName = `${instance.constructor.name}.stream`;
925
- return (params) => makeStreamWrapper(
926
- _chunkLPC4W2WXjs.aiSDKChannels.agentStream,
927
- defaultName,
928
- stream.bind(instance),
929
- {
930
- self: instance,
931
- spanType: "function" /* FUNCTION */
932
- },
933
- options
934
- )({ ...instance.settings, ...params });
952
+ return (params) => {
953
+ const workflowAgent = instance.constructor.name === "WorkflowAgent";
954
+ if (workflowAgent && _chunkMWVVR5LRjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
955
+ const { span_info: _spanInfo, ...cleanParams } = params;
956
+ return stream.call(instance, { ...instance.settings, ...cleanParams });
957
+ }
958
+ const trace = () => makeStreamWrapper(
959
+ streamChannelForAgent(instance.constructor.name),
960
+ defaultName,
961
+ stream.bind(instance),
962
+ {
963
+ self: instance,
964
+ spanType: "function" /* FUNCTION */
965
+ },
966
+ options
967
+ )({ ...instance.settings, ...params });
968
+ return trace();
969
+ };
935
970
  };
971
+ function streamChannelForAgent(agentName) {
972
+ if (agentName === "ToolLoopAgent") {
973
+ return _chunkBFGIH2ZJjs.aiSDKChannels.toolLoopAgentStream;
974
+ }
975
+ if (agentName === "WorkflowAgent") {
976
+ return _chunkBFGIH2ZJjs.aiSDKChannels.workflowAgentStream;
977
+ }
978
+ return _chunkBFGIH2ZJjs.aiSDKChannels.agentStream;
979
+ }
936
980
  var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
937
981
  const wrapper = async function(allParams) {
938
982
  const { span_info, ...params } = allParams;
@@ -955,7 +999,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
955
999
  };
956
1000
  var wrapGenerateText = (generateText, options = {}, aiSDK) => {
957
1001
  return makeGenerateTextWrapper(
958
- _chunkLPC4W2WXjs.aiSDKChannels.generateText,
1002
+ _chunkBFGIH2ZJjs.aiSDKChannels.generateText,
959
1003
  "generateText",
960
1004
  generateText,
961
1005
  { aiSDK },
@@ -964,7 +1008,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
964
1008
  };
965
1009
  var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
966
1010
  return makeGenerateTextWrapper(
967
- _chunkLPC4W2WXjs.aiSDKChannels.generateObject,
1011
+ _chunkBFGIH2ZJjs.aiSDKChannels.generateObject,
968
1012
  "generateObject",
969
1013
  generateObject,
970
1014
  { aiSDK },
@@ -993,7 +1037,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
993
1037
  };
994
1038
  var wrapEmbed = (embed, options = {}, aiSDK) => {
995
1039
  return makeEmbedWrapper(
996
- _chunkLPC4W2WXjs.aiSDKChannels.embed,
1040
+ _chunkBFGIH2ZJjs.aiSDKChannels.embed,
997
1041
  "embed",
998
1042
  embed,
999
1043
  { aiSDK },
@@ -1002,7 +1046,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
1002
1046
  };
1003
1047
  var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
1004
1048
  return makeEmbedWrapper(
1005
- _chunkLPC4W2WXjs.aiSDKChannels.embedMany,
1049
+ _chunkBFGIH2ZJjs.aiSDKChannels.embedMany,
1006
1050
  "embedMany",
1007
1051
  embedMany,
1008
1052
  { aiSDK },
@@ -1013,7 +1057,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
1013
1057
  const wrapper = async function(allParams) {
1014
1058
  const { span_info, ...params } = allParams;
1015
1059
  const tracedParams = { ...params };
1016
- return _chunkLPC4W2WXjs.aiSDKChannels.rerank.tracePromise(
1060
+ return _chunkBFGIH2ZJjs.aiSDKChannels.rerank.tracePromise(
1017
1061
  () => rerank(tracedParams),
1018
1062
  createAISDKChannelContext(tracedParams, {
1019
1063
  aiSDK: contextOptions.aiSDK,
@@ -1052,7 +1096,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
1052
1096
  };
1053
1097
  var wrapStreamText = (streamText, options = {}, aiSDK) => {
1054
1098
  return makeStreamWrapper(
1055
- _chunkLPC4W2WXjs.aiSDKChannels.streamText,
1099
+ _chunkBFGIH2ZJjs.aiSDKChannels.streamText,
1056
1100
  "streamText",
1057
1101
  streamText,
1058
1102
  { aiSDK },
@@ -1061,7 +1105,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
1061
1105
  };
1062
1106
  var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
1063
1107
  return makeStreamWrapper(
1064
- _chunkLPC4W2WXjs.aiSDKChannels.streamObject,
1108
+ _chunkBFGIH2ZJjs.aiSDKChannels.streamObject,
1065
1109
  "streamObject",
1066
1110
  streamObject,
1067
1111
  { aiSDK },
@@ -1132,14 +1176,14 @@ var BraintrustLanguageModelWrapper = class {
1132
1176
  // For the first cut, do not support custom span_info arguments. We can
1133
1177
  // propagate those via async local storage
1134
1178
  async doGenerate(options) {
1135
- const span = _chunkPOCCIJALjs.startSpan.call(void 0, {
1179
+ const span = _chunkMWVVR5LRjs.startSpan.call(void 0, {
1136
1180
  name: "Chat Completion",
1137
1181
  spanAttributes: {
1138
1182
  type: "llm"
1139
1183
  }
1140
1184
  });
1141
1185
  const { prompt, mode, ...rest } = options;
1142
- const startTime = _chunkPOCCIJALjs.getCurrentUnixTimestamp.call(void 0, );
1186
+ const startTime = _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, );
1143
1187
  try {
1144
1188
  const ret = await this.model.doGenerate(options);
1145
1189
  span.log({
@@ -1151,12 +1195,12 @@ var BraintrustLanguageModelWrapper = class {
1151
1195
  },
1152
1196
  output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
1153
1197
  metrics: {
1154
- time_to_first_token: _chunkPOCCIJALjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
1155
- tokens: !_chunkPOCCIJALjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
1198
+ time_to_first_token: _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
1199
+ tokens: !_chunkMWVVR5LRjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
1156
1200
  prompt_tokens: _optionalChain([ret, 'access', _20 => _20.usage, 'optionalAccess', _21 => _21.promptTokens]),
1157
1201
  completion_tokens: _optionalChain([ret, 'access', _22 => _22.usage, 'optionalAccess', _23 => _23.completionTokens]),
1158
- cached: _chunkPOCCIJALjs.parseCachedHeader.call(void 0,
1159
- _nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[_chunkPOCCIJALjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _27 => _27.rawResponse, 'optionalAccess', _28 => _28.headers, 'optionalAccess', _29 => _29[_chunkPOCCIJALjs.LEGACY_CACHED_HEADER]])))
1202
+ cached: _chunkMWVVR5LRjs.parseCachedHeader.call(void 0,
1203
+ _nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[_chunkMWVVR5LRjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _27 => _27.rawResponse, 'optionalAccess', _28 => _28.headers, 'optionalAccess', _29 => _29[_chunkMWVVR5LRjs.LEGACY_CACHED_HEADER]])))
1160
1204
  )
1161
1205
  }
1162
1206
  });
@@ -1167,8 +1211,8 @@ var BraintrustLanguageModelWrapper = class {
1167
1211
  }
1168
1212
  async doStream(options) {
1169
1213
  const { prompt, mode, ...rest } = options;
1170
- const startTime = _chunkPOCCIJALjs.getCurrentUnixTimestamp.call(void 0, );
1171
- const span = _chunkPOCCIJALjs.startSpan.call(void 0, {
1214
+ const startTime = _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, );
1215
+ const span = _chunkMWVVR5LRjs.startSpan.call(void 0, {
1172
1216
  name: "Chat Completion",
1173
1217
  spanAttributes: {
1174
1218
  type: "llm"
@@ -1194,7 +1238,7 @@ var BraintrustLanguageModelWrapper = class {
1194
1238
  let time_to_first_token = void 0;
1195
1239
  let usage = void 0;
1196
1240
  let fullText = void 0;
1197
- const toolCalls = {};
1241
+ const toolCalls2 = {};
1198
1242
  let finishReason = void 0;
1199
1243
  return {
1200
1244
  ...ret,
@@ -1202,7 +1246,7 @@ var BraintrustLanguageModelWrapper = class {
1202
1246
  new TransformStream({
1203
1247
  transform(chunk, controller) {
1204
1248
  if (time_to_first_token === void 0) {
1205
- time_to_first_token = _chunkPOCCIJALjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
1249
+ time_to_first_token = _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
1206
1250
  span.log({ metrics: { time_to_first_token } });
1207
1251
  }
1208
1252
  switch (chunk.type) {
@@ -1213,7 +1257,7 @@ var BraintrustLanguageModelWrapper = class {
1213
1257
  fullText += chunk.textDelta;
1214
1258
  break;
1215
1259
  case "tool-call":
1216
- toolCalls[chunk.toolCallId] = {
1260
+ toolCalls2[chunk.toolCallId] = {
1217
1261
  toolCallType: chunk.toolCallType,
1218
1262
  toolCallId: chunk.toolCallId,
1219
1263
  toolName: chunk.toolName,
@@ -1221,15 +1265,15 @@ var BraintrustLanguageModelWrapper = class {
1221
1265
  };
1222
1266
  break;
1223
1267
  case "tool-call-delta":
1224
- if (toolCalls[chunk.toolCallId] === void 0) {
1225
- toolCalls[chunk.toolCallId] = {
1268
+ if (toolCalls2[chunk.toolCallId] === void 0) {
1269
+ toolCalls2[chunk.toolCallId] = {
1226
1270
  toolCallType: chunk.toolCallType,
1227
1271
  toolCallId: chunk.toolCallId,
1228
1272
  toolName: chunk.toolName,
1229
1273
  args: ""
1230
1274
  };
1231
1275
  }
1232
- toolCalls[chunk.toolCallId].args += chunk.argsTextDelta;
1276
+ toolCalls2[chunk.toolCallId].args += chunk.argsTextDelta;
1233
1277
  break;
1234
1278
  case "finish":
1235
1279
  usage = chunk.usage;
@@ -1242,16 +1286,16 @@ var BraintrustLanguageModelWrapper = class {
1242
1286
  span.log({
1243
1287
  output: postProcessOutput(
1244
1288
  fullText,
1245
- Object.keys(toolCalls).length > 0 ? Object.values(toolCalls) : void 0,
1289
+ Object.keys(toolCalls2).length > 0 ? Object.values(toolCalls2) : void 0,
1246
1290
  finishReason
1247
1291
  ),
1248
1292
  metrics: {
1249
1293
  time_to_first_token,
1250
- tokens: !_chunkPOCCIJALjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
1294
+ tokens: !_chunkMWVVR5LRjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
1251
1295
  prompt_tokens: _optionalChain([usage, 'optionalAccess', _30 => _30.promptTokens]),
1252
1296
  completion_tokens: _optionalChain([usage, 'optionalAccess', _31 => _31.completionTokens]),
1253
- cached: _chunkPOCCIJALjs.parseCachedHeader.call(void 0,
1254
- _nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[_chunkPOCCIJALjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _35 => _35.rawResponse, 'optionalAccess', _36 => _36.headers, 'optionalAccess', _37 => _37[_chunkPOCCIJALjs.LEGACY_CACHED_HEADER]])))
1297
+ cached: _chunkMWVVR5LRjs.parseCachedHeader.call(void 0,
1298
+ _nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[_chunkMWVVR5LRjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _35 => _35.rawResponse, 'optionalAccess', _36 => _36.headers, 'optionalAccess', _37 => _37[_chunkMWVVR5LRjs.LEGACY_CACHED_HEADER]])))
1255
1299
  )
1256
1300
  }
1257
1301
  });
@@ -1343,15 +1387,15 @@ function postProcessPrompt(prompt) {
1343
1387
  }
1344
1388
  });
1345
1389
  }
1346
- function postProcessOutput(text, toolCalls, finishReason) {
1390
+ function postProcessOutput(text, toolCalls2, finishReason) {
1347
1391
  return [
1348
1392
  {
1349
1393
  index: 0,
1350
1394
  message: {
1351
1395
  role: "assistant",
1352
1396
  content: _nullishCoalesce(text, () => ( "")),
1353
- ...toolCalls && toolCalls.length > 0 ? {
1354
- tool_calls: toolCalls.map((toolCall) => ({
1397
+ ...toolCalls2 && toolCalls2.length > 0 ? {
1398
+ tool_calls: toolCalls2.map((toolCall) => ({
1355
1399
  id: toolCall.toolCallId,
1356
1400
  function: {
1357
1401
  name: toolCall.toolName,
@@ -1436,12 +1480,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
1436
1480
  anthropicMetadata.usage,
1437
1481
  "cache_creation_input_tokens"
1438
1482
  ) || 0;
1439
- const cacheTokens = _chunkPOCCIJALjs.extractAnthropicCacheTokens.call(void 0,
1483
+ const cacheTokens = _chunkMWVVR5LRjs.extractAnthropicCacheTokens.call(void 0,
1440
1484
  cacheReadTokens,
1441
1485
  cacheCreationTokens
1442
1486
  );
1443
1487
  Object.assign(metrics, cacheTokens);
1444
- Object.assign(metrics, _chunkPOCCIJALjs.finalizeAnthropicTokens.call(void 0, metrics));
1488
+ Object.assign(metrics, _chunkMWVVR5LRjs.finalizeAnthropicTokens.call(void 0, metrics));
1445
1489
  }
1446
1490
  }
1447
1491
  return metrics;
@@ -1450,29 +1494,29 @@ function normalizeFinishReason(reason) {
1450
1494
  if (typeof reason !== "string") return void 0;
1451
1495
  return reason.replace(/-/g, "_");
1452
1496
  }
1453
- function buildAssistantOutputWithToolCalls(result, toolCalls) {
1497
+ function buildAssistantOutputWithToolCalls(result, toolCalls2) {
1454
1498
  return [
1455
1499
  {
1456
1500
  index: 0,
1457
1501
  logprobs: null,
1458
- finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess', _49 => _49.finishReason])), () => ( (toolCalls.length ? "tool_calls" : void 0))),
1502
+ finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess', _49 => _49.finishReason])), () => ( (toolCalls2.length ? "tool_calls" : void 0))),
1459
1503
  message: {
1460
1504
  role: "assistant",
1461
- tool_calls: toolCalls.length > 0 ? toolCalls : void 0
1505
+ tool_calls: toolCalls2.length > 0 ? toolCalls2 : void 0
1462
1506
  }
1463
1507
  }
1464
1508
  ];
1465
1509
  }
1466
1510
  function extractToolCallsFromSteps(steps) {
1467
- const toolCalls = [];
1468
- if (!Array.isArray(steps)) return toolCalls;
1511
+ const toolCalls2 = [];
1512
+ if (!Array.isArray(steps)) return toolCalls2;
1469
1513
  let idx = 0;
1470
1514
  for (const step of steps) {
1471
1515
  const blocks = _optionalChain([step, 'optionalAccess', _50 => _50.content]);
1472
1516
  if (!Array.isArray(blocks)) continue;
1473
1517
  for (const block of blocks) {
1474
1518
  if (block && typeof block === "object" && block.type === "tool-call") {
1475
- toolCalls.push({
1519
+ toolCalls2.push({
1476
1520
  id: block.toolCallId,
1477
1521
  type: "function",
1478
1522
  index: idx++,
@@ -1484,7 +1528,7 @@ function extractToolCallsFromSteps(steps) {
1484
1528
  }
1485
1529
  }
1486
1530
  }
1487
- return toolCalls;
1531
+ return toolCalls2;
1488
1532
  }
1489
1533
  function extractToolCallsFromBlocks(blocks) {
1490
1534
  if (!Array.isArray(blocks)) return [];
@@ -1513,7 +1557,7 @@ function BraintrustMiddleware(config = {}) {
1513
1557
  model: modelFromWrapGenerate
1514
1558
  }) => {
1515
1559
  const rawInput = extractInput(params);
1516
- const processedInput = _chunkPOCCIJALjs.processInputAttachments.call(void 0, rawInput);
1560
+ const processedInput = _chunkMWVVR5LRjs.processInputAttachments.call(void 0, rawInput);
1517
1561
  const spanArgs = {
1518
1562
  name: _optionalChain([config, 'access', _54 => _54.spanInfo, 'optionalAccess', _55 => _55.name]) || "ai-sdk.doGenerate",
1519
1563
  spanAttributes: {
@@ -1528,7 +1572,7 @@ function BraintrustMiddleware(config = {}) {
1528
1572
  }
1529
1573
  }
1530
1574
  };
1531
- const span = _chunkPOCCIJALjs.startSpan.call(void 0, spanArgs);
1575
+ const span = _chunkMWVVR5LRjs.startSpan.call(void 0, spanArgs);
1532
1576
  try {
1533
1577
  const result = await doGenerate();
1534
1578
  const metadata = {};
@@ -1550,12 +1594,12 @@ function BraintrustMiddleware(config = {}) {
1550
1594
  metadata.model = modelId;
1551
1595
  }
1552
1596
  }
1553
- let toolCalls = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess', _60 => _60.steps]));
1554
- if (!toolCalls || toolCalls.length === 0) {
1555
- toolCalls = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess', _61 => _61.content]));
1597
+ let toolCalls2 = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess', _60 => _60.steps]));
1598
+ if (!toolCalls2 || toolCalls2.length === 0) {
1599
+ toolCalls2 = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess', _61 => _61.content]));
1556
1600
  }
1557
1601
  span.log({
1558
- output: toolCalls.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls) : _optionalChain([result, 'optionalAccess', _62 => _62.content]),
1602
+ output: toolCalls2.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls2) : _optionalChain([result, 'optionalAccess', _62 => _62.content]),
1559
1603
  metadata,
1560
1604
  metrics: normalizeUsageMetrics(
1561
1605
  result.usage,
@@ -1575,7 +1619,7 @@ function BraintrustMiddleware(config = {}) {
1575
1619
  },
1576
1620
  wrapStream: async ({ doStream, params }) => {
1577
1621
  const rawInput = extractInput(params);
1578
- const processedInput = _chunkPOCCIJALjs.processInputAttachments.call(void 0, rawInput);
1622
+ const processedInput = _chunkMWVVR5LRjs.processInputAttachments.call(void 0, rawInput);
1579
1623
  const spanArgs = {
1580
1624
  name: _optionalChain([config, 'access', _63 => _63.spanInfo, 'optionalAccess', _64 => _64.name]) || "ai-sdk.doStream",
1581
1625
  spanAttributes: {
@@ -1590,7 +1634,7 @@ function BraintrustMiddleware(config = {}) {
1590
1634
  }
1591
1635
  }
1592
1636
  };
1593
- const span = _chunkPOCCIJALjs.startSpan.call(void 0, spanArgs);
1637
+ const span = _chunkMWVVR5LRjs.startSpan.call(void 0, spanArgs);
1594
1638
  try {
1595
1639
  const { stream, ...rest } = await doStream();
1596
1640
  const textChunks = [];
@@ -1644,13 +1688,13 @@ function BraintrustMiddleware(config = {}) {
1644
1688
  metadata.model = model;
1645
1689
  }
1646
1690
  if (toolBlocks.length > 0) {
1647
- const toolCalls = extractToolCallsFromSteps([
1691
+ const toolCalls2 = extractToolCallsFromSteps([
1648
1692
  { content: toolBlocks }
1649
1693
  ]);
1650
- if (toolCalls.length > 0) {
1694
+ if (toolCalls2.length > 0) {
1651
1695
  output = buildAssistantOutputWithToolCalls(
1652
1696
  resultForDetection,
1653
- toolCalls
1697
+ toolCalls2
1654
1698
  );
1655
1699
  }
1656
1700
  }
@@ -1688,6 +1732,1469 @@ function BraintrustMiddleware(config = {}) {
1688
1732
  };
1689
1733
  }
1690
1734
 
1735
+ // src/instrumentation/plugins/eve-plugin.ts
1736
+ var EVE_TRACE_STATE_KEY = "braintrust.eve.tracing";
1737
+ var MAX_EVE_CACHE_ENTRIES = 1e4;
1738
+ var MAX_STORED_LLM_INPUTS = 100;
1739
+ var MAX_STORED_SPAN_REFERENCES = 1e4;
1740
+ var MAX_STORED_STEP_STARTS = 1e4;
1741
+ function braintrustEveHook(options) {
1742
+ const state = options.defineState(EVE_TRACE_STATE_KEY, emptyEveTraceState);
1743
+ const bridge = new EveBridge(state);
1744
+ return {
1745
+ events: {
1746
+ "*": async (event, ctx) => {
1747
+ await bridge.handle(event, ctx, options.metadata);
1748
+ }
1749
+ }
1750
+ };
1751
+ }
1752
+ function braintrustEveInstrumentation(options) {
1753
+ const state = options.defineState(EVE_TRACE_STATE_KEY, emptyEveTraceState);
1754
+ return {
1755
+ events: {
1756
+ "step.started": (input) => {
1757
+ try {
1758
+ captureEveModelInput(state, input);
1759
+ } catch (error) {
1760
+ _chunkMWVVR5LRjs.debugLogger.warn("Error in Eve LLM input capture:", error);
1761
+ }
1762
+ }
1763
+ },
1764
+ recordInputs: false,
1765
+ recordOutputs: false,
1766
+ setup: options.setup
1767
+ };
1768
+ }
1769
+ function isEveHandleMessageStreamEvent(event) {
1770
+ return _chunkMWVVR5LRjs.isObject.call(void 0, event) && typeof event["type"] === "string";
1771
+ }
1772
+ var ResumedEveSpan = class {
1773
+ constructor(reference) {
1774
+ this.reference = reference;
1775
+ this.endTime = reference.endTime;
1776
+ }
1777
+
1778
+ get rootSpanId() {
1779
+ return this.reference.rootSpanId;
1780
+ }
1781
+ get spanId() {
1782
+ return this.reference.spanId;
1783
+ }
1784
+ log(event) {
1785
+ const metrics = {
1786
+ ..._optionalChain([this, 'access', _69 => _69.reference, 'access', _70 => _70.startEvent, 'optionalAccess', _71 => _71.metrics]),
1787
+ ...this.endTime === void 0 ? {} : { end: this.endTime },
1788
+ ...event.metrics
1789
+ };
1790
+ _chunkMWVVR5LRjs.updateSpan.call(void 0, {
1791
+ exported: this.reference.exported,
1792
+ ...this.reference.startEvent,
1793
+ ...event,
1794
+ ...Object.keys(metrics).length > 0 ? { metrics } : {}
1795
+ });
1796
+ }
1797
+ end(args) {
1798
+ if (this.endTime === void 0) {
1799
+ this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.endTime]), () => ( _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, )));
1800
+ this.log({ metrics: { end: this.endTime } });
1801
+ }
1802
+ return this.endTime;
1803
+ }
1804
+ };
1805
+ var EveBridge = (_class = class {
1806
+ constructor(state) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);
1807
+ this.state = state;
1808
+ }
1809
+ __init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
1810
+ __init2() {this.sessionsById = new (0, _chunkMWVVR5LRjs.LRUCache)({
1811
+ max: MAX_EVE_CACHE_ENTRIES
1812
+ })}
1813
+ __init3() {this.completedToolKeys = new (0, _chunkMWVVR5LRjs.LRUCache)({
1814
+ max: MAX_EVE_CACHE_ENTRIES
1815
+ })}
1816
+ __init4() {this.toolsByCallKey = new (0, _chunkMWVVR5LRjs.LRUCache)({
1817
+ max: MAX_EVE_CACHE_ENTRIES
1818
+ })}
1819
+ __init5() {this.turnsByKey = new (0, _chunkMWVVR5LRjs.LRUCache)({
1820
+ max: MAX_EVE_CACHE_ENTRIES
1821
+ })}
1822
+ async startEveSpan(args) {
1823
+ const rowId = _optionalChain([args, 'optionalAccess', _73 => _73.event, 'optionalAccess', _74 => _74.id]);
1824
+ const reference = typeof rowId === "string" && readEveTraceState(this.state).spanReferences.find(
1825
+ (candidate) => candidate.rowId === rowId
1826
+ );
1827
+ if (reference) {
1828
+ return new ResumedEveSpan(reference);
1829
+ }
1830
+ const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.startTime]), () => ( _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, )));
1831
+ const parentSpanIds = _optionalChain([args, 'optionalAccess', _76 => _76.parentSpanIds]);
1832
+ const startEvent = {
1833
+ created: (/* @__PURE__ */ new Date()).toISOString(),
1834
+ metrics: { start: startTime },
1835
+ span_attributes: {
1836
+ ..._optionalChain([args, 'optionalAccess', _77 => _77.name]) ? { name: args.name } : {},
1837
+ ..._optionalChain([args, 'optionalAccess', _78 => _78.type]) ? { type: args.type } : {},
1838
+ ..._optionalChain([args, 'optionalAccess', _79 => _79.spanAttributes])
1839
+ },
1840
+ span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
1841
+ };
1842
+ const span = _chunkMWVVR5LRjs.withCurrent.call(void 0,
1843
+ _chunkMWVVR5LRjs.NOOP_SPAN,
1844
+ () => _chunkMWVVR5LRjs._internalStartSpanWithInitialMerge.call(void 0, { ...args, startTime })
1845
+ );
1846
+ if (typeof rowId !== "string") {
1847
+ return span;
1848
+ }
1849
+ try {
1850
+ const exported = await span.export();
1851
+ const reference2 = {
1852
+ exported,
1853
+ rootSpanId: span.rootSpanId,
1854
+ rowId,
1855
+ spanId: span.spanId,
1856
+ startEvent
1857
+ };
1858
+ this.state.update((current) => {
1859
+ const normalized = normalizeEveTraceState(current);
1860
+ return normalized.spanReferences.some(
1861
+ (candidate) => candidate.rowId === rowId
1862
+ ) ? normalized : {
1863
+ ...normalized,
1864
+ spanReferences: [...normalized.spanReferences, reference2].slice(
1865
+ -MAX_STORED_SPAN_REFERENCES
1866
+ )
1867
+ };
1868
+ });
1869
+ } catch (error) {
1870
+ _chunkMWVVR5LRjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
1871
+ }
1872
+ return span;
1873
+ }
1874
+ async startEveChildSpan(parent, args) {
1875
+ return await this.startEveSpan({
1876
+ ...args,
1877
+ parentSpanIds: {
1878
+ rootSpanId: parent.rootSpanId,
1879
+ spanId: parent.spanId
1880
+ }
1881
+ });
1882
+ }
1883
+ stepOrdinal(event) {
1884
+ let ordinal = 0;
1885
+ this.state.update((current) => {
1886
+ const state = normalizeEveTraceState(current);
1887
+ const previous = state.stepStarts.filter(
1888
+ (entry) => entry.turnId === event.data.turnId && entry.stepIndex === event.data.stepIndex
1889
+ ).at(-1);
1890
+ if (_optionalChain([previous, 'optionalAccess', _80 => _80.open])) {
1891
+ ordinal = previous.ordinal;
1892
+ return state;
1893
+ }
1894
+ ordinal = state.stepStarts.filter(
1895
+ (entry) => entry.turnId === event.data.turnId
1896
+ ).length;
1897
+ return {
1898
+ ...state,
1899
+ stepStarts: [
1900
+ ...state.stepStarts,
1901
+ {
1902
+ open: true,
1903
+ ordinal,
1904
+ stepIndex: event.data.stepIndex,
1905
+ turnId: event.data.turnId
1906
+ }
1907
+ ].slice(-MAX_STORED_STEP_STARTS)
1908
+ };
1909
+ });
1910
+ return ordinal;
1911
+ }
1912
+ markStepEnded(turnId, stepIndex) {
1913
+ this.state.update((current) => {
1914
+ const state = normalizeEveTraceState(current);
1915
+ let index = -1;
1916
+ for (let i = state.stepStarts.length - 1; i >= 0; i--) {
1917
+ const entry = state.stepStarts[i];
1918
+ if (_optionalChain([entry, 'optionalAccess', _81 => _81.turnId]) === turnId && entry.stepIndex === stepIndex) {
1919
+ index = i;
1920
+ break;
1921
+ }
1922
+ }
1923
+ if (index < 0 || !_optionalChain([state, 'access', _82 => _82.stepStarts, 'access', _83 => _83[index], 'optionalAccess', _84 => _84.open])) {
1924
+ return state;
1925
+ }
1926
+ return {
1927
+ ...state,
1928
+ stepStarts: state.stepStarts.map(
1929
+ (entry, entryIndex) => entryIndex === index ? { ...entry, open: false } : entry
1930
+ )
1931
+ };
1932
+ });
1933
+ }
1934
+ async handle(event, ctx, hookMetadata) {
1935
+ if (!isEveHandleMessageStreamEvent(event)) {
1936
+ return;
1937
+ }
1938
+ const run = async () => {
1939
+ try {
1940
+ if (!await this.handleEvent(event, ctx, hookMetadata)) {
1941
+ return;
1942
+ }
1943
+ if (event.type === "session.failed") {
1944
+ const sessionId2 = event.data.sessionId || sessionIdFromContext(ctx);
1945
+ await this.flushInstrumentation();
1946
+ if (sessionId2) {
1947
+ this.cleanupSession(sessionId2);
1948
+ }
1949
+ } else if (event.type === "session.completed") {
1950
+ const sessionId2 = sessionIdFromContext(ctx);
1951
+ await this.flushInstrumentation();
1952
+ if (sessionId2) {
1953
+ this.cleanupSession(sessionId2);
1954
+ }
1955
+ }
1956
+ } catch (error) {
1957
+ _chunkMWVVR5LRjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
1958
+ }
1959
+ };
1960
+ const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
1961
+ if (!sessionId) {
1962
+ await run();
1963
+ return;
1964
+ }
1965
+ const previous = this.eventQueuesBySession.get(sessionId);
1966
+ const queued = previous ? previous.then(run) : run();
1967
+ this.eventQueuesBySession.set(sessionId, queued);
1968
+ try {
1969
+ await queued;
1970
+ } finally {
1971
+ if (this.eventQueuesBySession.get(sessionId) === queued) {
1972
+ this.eventQueuesBySession.delete(sessionId);
1973
+ }
1974
+ }
1975
+ }
1976
+ async handleEvent(event, ctx, hookMetadata) {
1977
+ switch (event.type) {
1978
+ case "session.started":
1979
+ await this.handleSessionStarted(event, ctx, hookMetadata);
1980
+ return true;
1981
+ case "turn.started":
1982
+ await this.handleTurnStarted(event, ctx, hookMetadata);
1983
+ return true;
1984
+ case "message.received":
1985
+ await this.handleMessageReceived(event, ctx, hookMetadata);
1986
+ return true;
1987
+ case "step.started":
1988
+ await this.handleStepStarted(event, ctx, hookMetadata);
1989
+ return true;
1990
+ case "message.completed":
1991
+ this.handleMessageCompleted(event, ctx);
1992
+ return true;
1993
+ case "result.completed":
1994
+ this.handleResultCompleted(event, ctx);
1995
+ return true;
1996
+ case "actions.requested":
1997
+ await this.handleActionsRequested(event, ctx, hookMetadata);
1998
+ return true;
1999
+ case "action.result":
2000
+ await this.handleActionResult(event, ctx, hookMetadata);
2001
+ return true;
2002
+ case "subagent.called":
2003
+ await this.handleSubagentCalled(event, ctx, hookMetadata);
2004
+ return true;
2005
+ case "subagent.completed":
2006
+ await this.handleSubagentCompleted(event, ctx, hookMetadata);
2007
+ return true;
2008
+ case "step.completed":
2009
+ this.handleStepCompleted(event, ctx);
2010
+ return true;
2011
+ case "step.failed":
2012
+ this.handleStepFailed(event, ctx);
2013
+ return true;
2014
+ case "turn.completed":
2015
+ await this.handleTurnCompleted(event, ctx);
2016
+ return true;
2017
+ case "turn.failed":
2018
+ await this.handleTurnFailed(event, ctx);
2019
+ return true;
2020
+ case "session.failed":
2021
+ await this.handleSessionFailed(event, ctx);
2022
+ return true;
2023
+ case "session.completed":
2024
+ await this.handleSessionCompleted(event, ctx);
2025
+ return true;
2026
+ default:
2027
+ return false;
2028
+ }
2029
+ }
2030
+ async handleSessionStarted(event, ctx, hookMetadata) {
2031
+ const sessionId = sessionIdFromContext(ctx);
2032
+ if (!sessionId) {
2033
+ return;
2034
+ }
2035
+ const metadata = {
2036
+ ..._nullishCoalesce(hookMetadata, () => ( {})),
2037
+ ...modelMetadataFromRuntime(event.data.runtime)
2038
+ };
2039
+ this.state.update((current) => {
2040
+ const normalized = normalizeEveTraceState(current);
2041
+ return {
2042
+ ...normalized,
2043
+ metadata: { ...normalized.metadata, ...metadata }
2044
+ };
2045
+ });
2046
+ await this.ensureSession(sessionId, ctx, metadata, eventTime(event));
2047
+ for (const [key, turn] of this.turnsByKey) {
2048
+ if (!key.startsWith(`${sessionId}:`)) {
2049
+ continue;
2050
+ }
2051
+ turn.metadata = { ...turn.metadata, ...metadata };
2052
+ turn.span.log({ metadata: turn.metadata });
2053
+ for (const step of turn.stepsByIndex.values()) {
2054
+ step.metadata = { ...step.metadata, ...metadata };
2055
+ step.span.log({ metadata: step.metadata });
2056
+ }
2057
+ }
2058
+ }
2059
+ async handleTurnStarted(event, ctx, hookMetadata) {
2060
+ const sessionId = sessionIdFromContext(ctx);
2061
+ if (!sessionId) {
2062
+ return;
2063
+ }
2064
+ const session = await this.ensureSession(
2065
+ sessionId,
2066
+ ctx,
2067
+ _nullishCoalesce(hookMetadata, () => ( {})),
2068
+ eventTime(event)
2069
+ );
2070
+ const key = turnKey(sessionId, event.data.turnId);
2071
+ const metadata = { ...session.metadata };
2072
+ const existing = this.turnsByKey.get(key);
2073
+ if (existing) {
2074
+ existing.metadata = { ...existing.metadata, ...metadata };
2075
+ existing.span.log({ metadata: existing.metadata });
2076
+ return;
2077
+ }
2078
+ const span = await this.startTurnSpan(session, event, metadata);
2079
+ span.log({ metadata });
2080
+ this.turnsByKey.set(key, {
2081
+ key,
2082
+ metadata,
2083
+ metrics: {},
2084
+ span,
2085
+ stepsByIndex: /* @__PURE__ */ new Map(),
2086
+ turnId: event.data.turnId
2087
+ });
2088
+ }
2089
+ async handleMessageReceived(event, ctx, hookMetadata) {
2090
+ const turn = await this.ensureTurn(event, ctx, hookMetadata);
2091
+ if (!turn) {
2092
+ return;
2093
+ }
2094
+ const input = [{ content: event.data.message, role: "user" }];
2095
+ turn.span.log({ input });
2096
+ }
2097
+ async handleStepStarted(event, ctx, hookMetadata) {
2098
+ const turn = await this.ensureTurn(event, ctx, hookMetadata);
2099
+ const sessionId = sessionIdFromContext(ctx);
2100
+ if (!turn || !sessionId) {
2101
+ return;
2102
+ }
2103
+ const existing = turn.stepsByIndex.get(event.data.stepIndex);
2104
+ if (existing) {
2105
+ existing.span.log({
2106
+ ...existing.input !== void 0 ? { input: existing.input } : {},
2107
+ metadata: existing.metadata,
2108
+ metrics: existing.metrics,
2109
+ output: existing.output
2110
+ });
2111
+ const endTime = eventTime(event);
2112
+ existing.span.end(endTime === void 0 ? void 0 : { endTime });
2113
+ this.markStepEnded(event.data.turnId, event.data.stepIndex);
2114
+ }
2115
+ const stepOrdinal = this.stepOrdinal(event);
2116
+ const metadata = {
2117
+ ...turn.metadata,
2118
+ ..._nullishCoalesce(_optionalChain([this, 'access', _85 => _85.sessionsById, 'access', _86 => _86.get, 'call', _87 => _87(sessionId), 'optionalAccess', _88 => _88.metadata]), () => ( {}))
2119
+ };
2120
+ const input = consumeCapturedEveModelInput(
2121
+ this.state,
2122
+ sessionId,
2123
+ event.data.turnId,
2124
+ event.data.stepIndex
2125
+ );
2126
+ const { rowId: eventId, spanId } = await generateEveIds(
2127
+ "step",
2128
+ sessionId,
2129
+ event.data.turnId,
2130
+ String(stepOrdinal)
2131
+ );
2132
+ const span = await this.startEveChildSpan(turn.span, {
2133
+ event: {
2134
+ id: eventId,
2135
+ ...input !== void 0 ? { input } : {},
2136
+ metadata
2137
+ },
2138
+ name: "eve.step",
2139
+ spanAttributes: { type: "llm" /* LLM */ },
2140
+ spanId,
2141
+ startTime: eventTime(event)
2142
+ });
2143
+ span.log({ ...input !== void 0 ? { input } : {}, metadata });
2144
+ turn.stepsByIndex.set(event.data.stepIndex, {
2145
+ ...input !== void 0 ? { input } : {},
2146
+ metadata,
2147
+ metrics: {},
2148
+ span
2149
+ });
2150
+ }
2151
+ handleMessageCompleted(event, ctx) {
2152
+ const step = this.stepForEvent(event, ctx);
2153
+ if (!step) {
2154
+ return;
2155
+ }
2156
+ const existingMessage = Array.isArray(step.output) && _chunkMWVVR5LRjs.isObject.call(void 0, step.output[0]) ? step.output[0].message : void 0;
2157
+ const existingToolCalls = _chunkMWVVR5LRjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
2158
+ step.output = [
2159
+ {
2160
+ finish_reason: normalizedFinishReason(event.data.finishReason),
2161
+ index: 0,
2162
+ message: {
2163
+ content: event.data.message,
2164
+ role: "assistant",
2165
+ ...Array.isArray(existingToolCalls) ? { tool_calls: existingToolCalls } : {}
2166
+ }
2167
+ }
2168
+ ];
2169
+ const turn = this.turnForEvent(event, ctx);
2170
+ if (turn && event.data.finishReason !== "tool-calls") {
2171
+ turn.output = event.data.message;
2172
+ }
2173
+ }
2174
+ handleResultCompleted(event, ctx) {
2175
+ const step = this.stepForEvent(event, ctx);
2176
+ if (step) {
2177
+ step.output = [
2178
+ {
2179
+ finish_reason: "stop",
2180
+ index: 0,
2181
+ message: {
2182
+ content: event.data.result,
2183
+ role: "assistant"
2184
+ }
2185
+ }
2186
+ ];
2187
+ }
2188
+ const turn = this.turnForEvent(event, ctx);
2189
+ if (turn) {
2190
+ turn.output = event.data.result;
2191
+ }
2192
+ }
2193
+ async handleActionsRequested(event, ctx, hookMetadata) {
2194
+ const turn = await this.ensureTurn(event, ctx, hookMetadata);
2195
+ const sessionId = sessionIdFromContext(ctx);
2196
+ if (!turn || !sessionId) {
2197
+ return;
2198
+ }
2199
+ const traceActions = event.data.actions.filter(isTraceableActionRequest);
2200
+ if (traceActions.length === 0) {
2201
+ return;
2202
+ }
2203
+ for (const action of traceActions) {
2204
+ if (isToolCallAction(action)) {
2205
+ await this.startRequestedTool(event, turn, sessionId, action);
2206
+ } else if (isLocalSubagentCallAction(action)) {
2207
+ await this.startRequestedSubagent(event, turn, sessionId, action);
2208
+ }
2209
+ }
2210
+ const step = turn.stepsByIndex.get(event.data.stepIndex);
2211
+ if (!step) {
2212
+ return;
2213
+ }
2214
+ step.output = [
2215
+ {
2216
+ finish_reason: "tool_calls",
2217
+ index: 0,
2218
+ message: {
2219
+ content: null,
2220
+ role: "assistant",
2221
+ tool_calls: traceActions.map((action) => {
2222
+ const name = action.kind === "tool-call" ? action.toolName : _nullishCoalesce(_nullishCoalesce(action.subagentName, () => ( action.name)), () => ( "agent"));
2223
+ return {
2224
+ function: {
2225
+ arguments: JSON.stringify(action.input),
2226
+ name
2227
+ },
2228
+ id: action.callId,
2229
+ type: "function"
2230
+ };
2231
+ })
2232
+ }
2233
+ }
2234
+ ];
2235
+ step.span.log({ metadata: step.metadata, output: step.output });
2236
+ }
2237
+ async handleActionResult(event, ctx, hookMetadata) {
2238
+ if (isToolResult(event.data.result)) {
2239
+ await this.handleToolResult(event, ctx, event.data.result, hookMetadata);
2240
+ return;
2241
+ }
2242
+ if (isSubagentResult(event.data.result)) {
2243
+ await this.handleSubagentResult(
2244
+ event,
2245
+ ctx,
2246
+ event.data.result,
2247
+ hookMetadata
2248
+ );
2249
+ }
2250
+ }
2251
+ async handleToolResult(event, ctx, result, hookMetadata) {
2252
+ const sessionId = sessionIdFromContext(ctx);
2253
+ if (!sessionId) {
2254
+ return;
2255
+ }
2256
+ const key = toolKey(sessionId, result.callId);
2257
+ if (this.completedToolKeys.has(key)) {
2258
+ return;
2259
+ }
2260
+ const tool = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticTool(event, ctx, result, hookMetadata)));
2261
+ if (!tool) {
2262
+ return;
2263
+ }
2264
+ const failed = event.data.status === "failed" || result.isError === true || event.data.error !== void 0;
2265
+ tool.span.log({
2266
+ ...failed ? {
2267
+ error: actionResultError(event.data.error, result.output)
2268
+ } : {},
2269
+ metadata: tool.metadata,
2270
+ output: result.output
2271
+ });
2272
+ const endTime = eventTime(event);
2273
+ tool.span.end(endTime === void 0 ? void 0 : { endTime });
2274
+ this.toolsByCallKey.delete(key);
2275
+ this.completedToolKeys.set(key, true);
2276
+ }
2277
+ async handleSubagentCalled(event, ctx, hookMetadata) {
2278
+ if (_optionalChain([event, 'access', _89 => _89.data, 'access', _90 => _90.remote, 'optionalAccess', _91 => _91.url])) {
2279
+ return;
2280
+ }
2281
+ const turn = await this.ensureTurn(event, ctx, hookMetadata);
2282
+ const sessionId = sessionIdFromContext(ctx);
2283
+ if (!turn || !sessionId) {
2284
+ return;
2285
+ }
2286
+ const key = toolKey(sessionId, event.data.callId);
2287
+ const metadata = toolMetadataFromTurn(turn);
2288
+ const existing = this.toolsByCallKey.get(key);
2289
+ if (existing) {
2290
+ existing.metadata = { ...existing.metadata, ...metadata };
2291
+ existing.span.log({ metadata: existing.metadata });
2292
+ return;
2293
+ }
2294
+ if (this.completedToolKeys.has(key)) {
2295
+ return;
2296
+ }
2297
+ const { rowId: eventId, spanId } = await generateEveIds(
2298
+ "subagent",
2299
+ sessionId,
2300
+ event.data.callId
2301
+ );
2302
+ const pending = this.toolsByCallKey.get(key);
2303
+ if (pending || this.completedToolKeys.has(key)) {
2304
+ if (pending) {
2305
+ pending.metadata = { ...pending.metadata, ...metadata };
2306
+ pending.span.log({ metadata: pending.metadata });
2307
+ }
2308
+ return;
2309
+ }
2310
+ const span = await this.startEveChildSpan(turn.span, {
2311
+ event: {
2312
+ id: eventId,
2313
+ metadata
2314
+ },
2315
+ name: _nullishCoalesce(event.data.toolName, () => ( event.data.name)),
2316
+ spanAttributes: { type: "tool" /* TOOL */ },
2317
+ spanId,
2318
+ startTime: eventTime(event)
2319
+ });
2320
+ span.log({ metadata });
2321
+ this.toolsByCallKey.set(key, {
2322
+ metadata,
2323
+ span,
2324
+ turnKey: turnKey(sessionId, event.data.turnId)
2325
+ });
2326
+ }
2327
+ async handleSubagentCompleted(event, ctx, hookMetadata) {
2328
+ const sessionId = sessionIdFromContext(ctx);
2329
+ if (!sessionId) {
2330
+ return;
2331
+ }
2332
+ const key = toolKey(sessionId, event.data.callId);
2333
+ if (this.completedToolKeys.has(key)) {
2334
+ return;
2335
+ }
2336
+ const subagent = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticSubagent(event, ctx, hookMetadata)));
2337
+ if (!subagent) {
2338
+ return;
2339
+ }
2340
+ subagent.span.log({
2341
+ ...event.data.status === "failed" ? {
2342
+ error: actionResultError(event.data.error, event.data.output)
2343
+ } : {},
2344
+ metadata: subagent.metadata,
2345
+ ...event.data.output !== void 0 ? { output: event.data.output } : {}
2346
+ });
2347
+ const endTime = eventTime(event);
2348
+ const recordedEndTime = subagent.span.end(
2349
+ endTime === void 0 ? void 0 : { endTime }
2350
+ );
2351
+ this.state.update((current) => {
2352
+ const normalized = normalizeEveTraceState(current);
2353
+ return {
2354
+ ...normalized,
2355
+ spanReferences: normalized.spanReferences.map(
2356
+ (reference) => reference.spanId === subagent.span.spanId ? { ...reference, endTime: recordedEndTime } : reference
2357
+ )
2358
+ };
2359
+ });
2360
+ }
2361
+ async handleSubagentResult(event, ctx, result, hookMetadata) {
2362
+ const sessionId = sessionIdFromContext(ctx);
2363
+ if (!sessionId) {
2364
+ return;
2365
+ }
2366
+ const key = toolKey(sessionId, result.callId);
2367
+ if (this.completedToolKeys.has(key)) {
2368
+ return;
2369
+ }
2370
+ const subagent = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticSubagentResult(
2371
+ event,
2372
+ ctx,
2373
+ result,
2374
+ hookMetadata
2375
+ )));
2376
+ if (!subagent) {
2377
+ return;
2378
+ }
2379
+ const isError = event.data.status === "failed" || result.isError === true || event.data.error !== void 0;
2380
+ subagent.span.log({
2381
+ ...isError ? {
2382
+ error: actionResultError(event.data.error, result.output)
2383
+ } : {},
2384
+ metadata: subagent.metadata,
2385
+ output: result.output
2386
+ });
2387
+ const endTime = eventTime(event);
2388
+ subagent.span.end(endTime === void 0 ? void 0 : { endTime });
2389
+ this.toolsByCallKey.delete(key);
2390
+ this.completedToolKeys.set(key, true);
2391
+ }
2392
+ handleStepCompleted(event, ctx) {
2393
+ const step = this.stepForEvent(event, ctx);
2394
+ if (!step) {
2395
+ return;
2396
+ }
2397
+ const usage = event.data.usage;
2398
+ const inputTokens = typeof _optionalChain([usage, 'optionalAccess', _92 => _92.inputTokens]) === "number" && Number.isFinite(usage.inputTokens) && usage.inputTokens >= 0 ? usage.inputTokens : void 0;
2399
+ const outputTokens = typeof _optionalChain([usage, 'optionalAccess', _93 => _93.outputTokens]) === "number" && Number.isFinite(usage.outputTokens) && usage.outputTokens >= 0 ? usage.outputTokens : void 0;
2400
+ const cacheReadTokens = typeof _optionalChain([usage, 'optionalAccess', _94 => _94.cacheReadTokens]) === "number" && Number.isFinite(usage.cacheReadTokens) && usage.cacheReadTokens >= 0 ? usage.cacheReadTokens : void 0;
2401
+ const cacheWriteTokens = typeof _optionalChain([usage, 'optionalAccess', _95 => _95.cacheWriteTokens]) === "number" && Number.isFinite(usage.cacheWriteTokens) && usage.cacheWriteTokens >= 0 ? usage.cacheWriteTokens : void 0;
2402
+ const costUsd = typeof _optionalChain([usage, 'optionalAccess', _96 => _96.costUsd]) === "number" && Number.isFinite(usage.costUsd) && usage.costUsd >= 0 ? usage.costUsd : void 0;
2403
+ const total = inputTokens !== void 0 && outputTokens !== void 0 ? inputTokens + outputTokens : void 0;
2404
+ const metrics = {
2405
+ ...inputTokens !== void 0 ? { prompt_tokens: inputTokens } : {},
2406
+ ...outputTokens !== void 0 ? { completion_tokens: outputTokens } : {},
2407
+ ...total !== void 0 ? { tokens: total } : {},
2408
+ ...cacheReadTokens !== void 0 ? { prompt_cached_tokens: cacheReadTokens } : {},
2409
+ ...cacheWriteTokens !== void 0 ? { prompt_cache_creation_tokens: cacheWriteTokens } : {},
2410
+ ...costUsd !== void 0 ? { estimated_cost: costUsd } : {}
2411
+ };
2412
+ step.metrics = { ...step.metrics, ...metrics };
2413
+ if (Array.isArray(step.output) && _chunkMWVVR5LRjs.isObject.call(void 0, step.output[0])) {
2414
+ const finishReason = step.output[0].finish_reason;
2415
+ if (typeof finishReason !== "string") {
2416
+ step.output[0].finish_reason = normalizedFinishReason(
2417
+ event.data.finishReason
2418
+ );
2419
+ }
2420
+ }
2421
+ step.span.log({
2422
+ ...step.input !== void 0 ? { input: step.input } : {},
2423
+ metadata: step.metadata,
2424
+ metrics,
2425
+ output: step.output
2426
+ });
2427
+ const endTime = eventTime(event);
2428
+ step.span.end(endTime === void 0 ? void 0 : { endTime });
2429
+ const turn = this.turnForEvent(event, ctx);
2430
+ if (turn) {
2431
+ for (const [key, value] of Object.entries(metrics)) {
2432
+ turn.metrics[key] = (_nullishCoalesce(turn.metrics[key], () => ( 0))) + value;
2433
+ }
2434
+ turn.stepsByIndex.delete(event.data.stepIndex);
2435
+ }
2436
+ this.markStepEnded(event.data.turnId, event.data.stepIndex);
2437
+ }
2438
+ handleStepFailed(event, ctx) {
2439
+ const step = this.stepForEvent(event, ctx);
2440
+ if (step) {
2441
+ step.span.log({
2442
+ error: errorFromMessage(
2443
+ event.data.message,
2444
+ event.data.code,
2445
+ event.data.details
2446
+ )
2447
+ });
2448
+ const endTime = eventTime(event);
2449
+ step.span.end(endTime === void 0 ? void 0 : { endTime });
2450
+ }
2451
+ const turn = this.turnForEvent(event, ctx);
2452
+ _optionalChain([turn, 'optionalAccess', _97 => _97.stepsByIndex, 'access', _98 => _98.delete, 'call', _99 => _99(event.data.stepIndex)]);
2453
+ this.markStepEnded(event.data.turnId, event.data.stepIndex);
2454
+ }
2455
+ handleTurnCompleted(event, ctx) {
2456
+ const turn = this.turnForEvent(event, ctx);
2457
+ if (!turn) {
2458
+ return;
2459
+ }
2460
+ this.finalizeTurn(turn, {
2461
+ endTime: eventTime(event)
2462
+ });
2463
+ }
2464
+ handleTurnFailed(event, ctx) {
2465
+ const turn = this.turnForEvent(event, ctx);
2466
+ if (!turn) {
2467
+ return;
2468
+ }
2469
+ this.finalizeTurn(turn, {
2470
+ endTime: eventTime(event),
2471
+ error: errorFromMessage(
2472
+ event.data.message,
2473
+ event.data.code,
2474
+ event.data.details
2475
+ )
2476
+ });
2477
+ }
2478
+ async handleSessionFailed(event, ctx) {
2479
+ const sessionId = event.data.sessionId || sessionIdFromContext(ctx);
2480
+ if (!sessionId) {
2481
+ return;
2482
+ }
2483
+ const session = await this.ensureSession(
2484
+ sessionId,
2485
+ ctx,
2486
+ {},
2487
+ eventTime(event)
2488
+ );
2489
+ const error = errorFromMessage(
2490
+ event.data.message,
2491
+ event.data.code,
2492
+ event.data.details
2493
+ );
2494
+ for (const [key, turn] of this.turnsByKey) {
2495
+ if (!key.startsWith(`${sessionId}:`)) {
2496
+ continue;
2497
+ }
2498
+ this.finalizeTurn(turn, {
2499
+ endTime: eventTime(event),
2500
+ error
2501
+ });
2502
+ }
2503
+ for (const [key, tool] of this.toolsByCallKey) {
2504
+ if (key.startsWith(`${sessionId}:`)) {
2505
+ const endTime2 = eventTime(event);
2506
+ if (!tool.endedByTurn) {
2507
+ tool.span.log({ metadata: tool.metadata });
2508
+ tool.span.end(endTime2 === void 0 ? void 0 : { endTime: endTime2 });
2509
+ tool.endedByTurn = true;
2510
+ }
2511
+ }
2512
+ }
2513
+ session.span.log({ error });
2514
+ const endTime = eventTime(event);
2515
+ session.span.end(endTime === void 0 ? void 0 : { endTime });
2516
+ }
2517
+ async handleSessionCompleted(event, ctx) {
2518
+ const sessionId = sessionIdFromContext(ctx);
2519
+ if (!sessionId) {
2520
+ return;
2521
+ }
2522
+ const session = await this.ensureSession(
2523
+ sessionId,
2524
+ ctx,
2525
+ {},
2526
+ eventTime(event)
2527
+ );
2528
+ for (const [key, turn] of this.turnsByKey) {
2529
+ if (!key.startsWith(`${sessionId}:`)) {
2530
+ continue;
2531
+ }
2532
+ this.finalizeTurn(turn, {
2533
+ endTime: eventTime(event)
2534
+ });
2535
+ }
2536
+ for (const [key, tool] of this.toolsByCallKey) {
2537
+ if (key.startsWith(`${sessionId}:`) && !tool.endedByTurn) {
2538
+ const endTime2 = eventTime(event);
2539
+ tool.span.log({ metadata: tool.metadata });
2540
+ tool.span.end(endTime2 === void 0 ? void 0 : { endTime: endTime2 });
2541
+ tool.endedByTurn = true;
2542
+ }
2543
+ }
2544
+ session.span.log({ metadata: session.metadata });
2545
+ const endTime = eventTime(event);
2546
+ session.span.end(endTime === void 0 ? void 0 : { endTime });
2547
+ }
2548
+ async ensureSession(sessionId, ctx, metadata, startTime) {
2549
+ metadata = {
2550
+ ...readEveTraceState(this.state).metadata,
2551
+ ...metadata
2552
+ };
2553
+ const existing = this.sessionsById.get(sessionId);
2554
+ if (existing) {
2555
+ existing.metadata = { ...existing.metadata, ...metadata };
2556
+ existing.span.log({ metadata: existing.metadata });
2557
+ return existing;
2558
+ }
2559
+ const lineage = parentLineageFromContext(ctx);
2560
+ const parentSubagent = lineage ? this.toolsByCallKey.get(toolKey(lineage.sessionId, lineage.callId)) : void 0;
2561
+ const activeParent = _chunkMWVVR5LRjs.currentSpan.call(void 0, );
2562
+ const [
2563
+ { rowId: eventId, spanId },
2564
+ parentSubagentSpanId,
2565
+ fallbackRootSpanId
2566
+ ] = await Promise.all([
2567
+ generateEveIds("session", sessionId),
2568
+ lineage ? spanIdForSubagent(lineage.sessionId, lineage.callId) : Promise.resolve(void 0),
2569
+ lineage ? rootSpanIdForSession(lineage.rootSessionId) : rootSpanIdForSession(sessionId)
2570
+ ]);
2571
+ const span = await this.startEveSpan({
2572
+ event: {
2573
+ id: eventId,
2574
+ metadata
2575
+ },
2576
+ name: "eve.session",
2577
+ parentSpanIds: lineage && parentSubagentSpanId ? {
2578
+ rootSpanId: _nullishCoalesce(_optionalChain([parentSubagent, 'optionalAccess', _100 => _100.span, 'access', _101 => _101.rootSpanId]), () => ( fallbackRootSpanId)),
2579
+ spanId: parentSubagentSpanId
2580
+ } : !Object.is(activeParent, _chunkMWVVR5LRjs.NOOP_SPAN) ? {
2581
+ rootSpanId: activeParent.rootSpanId,
2582
+ spanId: activeParent.spanId
2583
+ } : {
2584
+ parentSpanIds: [],
2585
+ rootSpanId: fallbackRootSpanId
2586
+ },
2587
+ spanAttributes: { type: "task" /* TASK */ },
2588
+ spanId,
2589
+ startTime
2590
+ });
2591
+ span.log({ metadata });
2592
+ const session = { metadata, sessionId, span };
2593
+ this.sessionsById.set(sessionId, session);
2594
+ return session;
2595
+ }
2596
+ async ensureTurn(event, ctx, hookMetadata) {
2597
+ const sessionId = sessionIdFromContext(ctx);
2598
+ if (!sessionId) {
2599
+ return void 0;
2600
+ }
2601
+ const session = await this.ensureSession(
2602
+ sessionId,
2603
+ ctx,
2604
+ _nullishCoalesce(hookMetadata, () => ( {})),
2605
+ eventTime(event)
2606
+ );
2607
+ const key = turnKey(sessionId, event.data.turnId);
2608
+ const existing = this.turnsByKey.get(key);
2609
+ if (existing) {
2610
+ return existing;
2611
+ }
2612
+ const metadata = { ...session.metadata };
2613
+ const span = await this.startTurnSpan(session, event, metadata);
2614
+ span.log({ metadata });
2615
+ const state = {
2616
+ key,
2617
+ metadata,
2618
+ metrics: {},
2619
+ span,
2620
+ stepsByIndex: /* @__PURE__ */ new Map(),
2621
+ turnId: event.data.turnId
2622
+ };
2623
+ this.turnsByKey.set(key, state);
2624
+ return state;
2625
+ }
2626
+ async startRequestedTool(event, turn, sessionId, action) {
2627
+ const key = toolKey(sessionId, action.callId);
2628
+ if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
2629
+ return;
2630
+ }
2631
+ const metadata = toolMetadataFromTurn(turn);
2632
+ const { rowId: eventId, spanId } = await generateEveIds(
2633
+ "tool",
2634
+ sessionId,
2635
+ event.data.turnId,
2636
+ action.callId
2637
+ );
2638
+ if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
2639
+ return;
2640
+ }
2641
+ const span = await this.startEveChildSpan(turn.span, {
2642
+ event: {
2643
+ id: eventId,
2644
+ input: action.input,
2645
+ metadata
2646
+ },
2647
+ name: action.toolName,
2648
+ spanAttributes: { type: "tool" /* TOOL */ },
2649
+ spanId,
2650
+ startTime: eventTime(event)
2651
+ });
2652
+ span.log({ input: action.input, metadata });
2653
+ this.toolsByCallKey.set(key, {
2654
+ metadata,
2655
+ span,
2656
+ turnKey: turnKey(sessionId, event.data.turnId)
2657
+ });
2658
+ }
2659
+ async startRequestedSubagent(event, turn, sessionId, action) {
2660
+ const key = toolKey(sessionId, action.callId);
2661
+ if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
2662
+ return;
2663
+ }
2664
+ const name = _nullishCoalesce(_nullishCoalesce(action.subagentName, () => ( action.name)), () => ( "agent"));
2665
+ const metadata = toolMetadataFromTurn(turn);
2666
+ const { rowId: eventId, spanId } = await generateEveIds(
2667
+ "subagent",
2668
+ sessionId,
2669
+ action.callId
2670
+ );
2671
+ if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
2672
+ return;
2673
+ }
2674
+ const span = await this.startEveChildSpan(turn.span, {
2675
+ event: {
2676
+ id: eventId,
2677
+ input: action.input,
2678
+ metadata
2679
+ },
2680
+ name,
2681
+ spanAttributes: { type: "tool" /* TOOL */ },
2682
+ spanId,
2683
+ startTime: eventTime(event)
2684
+ });
2685
+ span.log({ input: action.input, metadata });
2686
+ this.toolsByCallKey.set(key, {
2687
+ metadata,
2688
+ span,
2689
+ turnKey: turnKey(sessionId, event.data.turnId)
2690
+ });
2691
+ }
2692
+ async startSyntheticTool(event, ctx, result, hookMetadata) {
2693
+ const turn = await this.ensureTurn(event, ctx, hookMetadata);
2694
+ const sessionId = sessionIdFromContext(ctx);
2695
+ if (!turn || !sessionId) {
2696
+ return void 0;
2697
+ }
2698
+ const metadata = toolMetadataFromTurn(turn);
2699
+ const { rowId: eventId, spanId } = await generateEveIds(
2700
+ "tool",
2701
+ sessionId,
2702
+ event.data.turnId,
2703
+ result.callId
2704
+ );
2705
+ const existing = this.toolsByCallKey.get(toolKey(sessionId, result.callId));
2706
+ if (existing) {
2707
+ return existing;
2708
+ }
2709
+ const span = await this.startEveChildSpan(turn.span, {
2710
+ event: {
2711
+ id: eventId,
2712
+ metadata
2713
+ },
2714
+ name: result.toolName,
2715
+ spanAttributes: { type: "tool" /* TOOL */ },
2716
+ spanId,
2717
+ startTime: eventTime(event)
2718
+ });
2719
+ span.log({ metadata });
2720
+ const state = {
2721
+ metadata,
2722
+ span,
2723
+ turnKey: turnKey(sessionId, event.data.turnId)
2724
+ };
2725
+ this.toolsByCallKey.set(toolKey(sessionId, result.callId), state);
2726
+ return state;
2727
+ }
2728
+ async startSyntheticSubagent(event, ctx, hookMetadata) {
2729
+ const turn = await this.ensureTurn(event, ctx, hookMetadata);
2730
+ const sessionId = sessionIdFromContext(ctx);
2731
+ if (!turn || !sessionId) {
2732
+ return void 0;
2733
+ }
2734
+ const metadata = toolMetadataFromTurn(turn);
2735
+ const { rowId: eventId, spanId } = await generateEveIds(
2736
+ "subagent",
2737
+ sessionId,
2738
+ event.data.callId
2739
+ );
2740
+ const existing = this.toolsByCallKey.get(
2741
+ toolKey(sessionId, event.data.callId)
2742
+ );
2743
+ if (existing) {
2744
+ return existing;
2745
+ }
2746
+ const span = await this.startEveChildSpan(turn.span, {
2747
+ event: {
2748
+ id: eventId,
2749
+ metadata
2750
+ },
2751
+ name: event.data.subagentName,
2752
+ spanAttributes: { type: "tool" /* TOOL */ },
2753
+ spanId,
2754
+ startTime: eventTime(event)
2755
+ });
2756
+ span.log({ metadata });
2757
+ const state = {
2758
+ metadata,
2759
+ span,
2760
+ turnKey: turnKey(sessionId, event.data.turnId)
2761
+ };
2762
+ this.toolsByCallKey.set(toolKey(sessionId, event.data.callId), state);
2763
+ return state;
2764
+ }
2765
+ async startSyntheticSubagentResult(event, ctx, result, hookMetadata) {
2766
+ const turn = await this.ensureTurn(event, ctx, hookMetadata);
2767
+ const sessionId = sessionIdFromContext(ctx);
2768
+ if (!turn || !sessionId) {
2769
+ return void 0;
2770
+ }
2771
+ const metadata = toolMetadataFromTurn(turn);
2772
+ const { rowId: eventId, spanId } = await generateEveIds(
2773
+ "subagent",
2774
+ sessionId,
2775
+ result.callId
2776
+ );
2777
+ const existing = this.toolsByCallKey.get(toolKey(sessionId, result.callId));
2778
+ if (existing) {
2779
+ return existing;
2780
+ }
2781
+ const span = await this.startEveChildSpan(turn.span, {
2782
+ event: {
2783
+ id: eventId,
2784
+ metadata
2785
+ },
2786
+ name: result.subagentName,
2787
+ spanAttributes: { type: "tool" /* TOOL */ },
2788
+ spanId,
2789
+ startTime: eventTime(event)
2790
+ });
2791
+ span.log({ metadata });
2792
+ const state = {
2793
+ metadata,
2794
+ span,
2795
+ turnKey: turnKey(sessionId, event.data.turnId)
2796
+ };
2797
+ this.toolsByCallKey.set(toolKey(sessionId, result.callId), state);
2798
+ return state;
2799
+ }
2800
+ async startTurnSpan(session, event, metadata) {
2801
+ const { rowId: eventId, spanId } = await generateEveIds(
2802
+ "turn",
2803
+ session.sessionId,
2804
+ event.data.turnId
2805
+ );
2806
+ return await this.startEveSpan({
2807
+ event: {
2808
+ id: eventId,
2809
+ metadata
2810
+ },
2811
+ name: "eve.turn",
2812
+ parentSpanIds: {
2813
+ rootSpanId: session.span.rootSpanId,
2814
+ spanId: session.span.spanId
2815
+ },
2816
+ spanAttributes: { type: "task" /* TASK */ },
2817
+ spanId,
2818
+ startTime: eventTime(event)
2819
+ });
2820
+ }
2821
+ turnForEvent(event, ctx) {
2822
+ const sessionId = sessionIdFromContext(ctx);
2823
+ return sessionId ? this.turnsByKey.get(turnKey(sessionId, event.data.turnId)) : void 0;
2824
+ }
2825
+ stepForEvent(event, ctx) {
2826
+ return _optionalChain([this, 'access', _102 => _102.turnForEvent, 'call', _103 => _103(event, ctx), 'optionalAccess', _104 => _104.stepsByIndex, 'access', _105 => _105.get, 'call', _106 => _106(
2827
+ event.data.stepIndex
2828
+ )]);
2829
+ }
2830
+ finalizeTurn(turn, args) {
2831
+ const { endTime } = args;
2832
+ for (const step of turn.stepsByIndex.values()) {
2833
+ step.span.log({
2834
+ ...step.input !== void 0 ? { input: step.input } : {},
2835
+ metadata: step.metadata,
2836
+ metrics: step.metrics,
2837
+ output: step.output
2838
+ });
2839
+ step.span.end(endTime === void 0 ? void 0 : { endTime });
2840
+ }
2841
+ turn.stepsByIndex.clear();
2842
+ for (const tool of this.toolsByCallKey.values()) {
2843
+ if (tool.turnKey !== turn.key) {
2844
+ continue;
2845
+ }
2846
+ if (tool.endedByTurn) {
2847
+ continue;
2848
+ }
2849
+ tool.span.log({ metadata: tool.metadata });
2850
+ tool.span.end(endTime === void 0 ? void 0 : { endTime });
2851
+ tool.endedByTurn = true;
2852
+ }
2853
+ if (args.error) {
2854
+ turn.span.log({ error: args.error });
2855
+ } else {
2856
+ turn.span.log({
2857
+ metadata: turn.metadata,
2858
+ metrics: turn.metrics,
2859
+ output: turn.output
2860
+ });
2861
+ }
2862
+ turn.span.end(endTime === void 0 ? void 0 : { endTime });
2863
+ this.turnsByKey.delete(turn.key);
2864
+ this.state.update((current) => {
2865
+ const normalized = normalizeEveTraceState(current);
2866
+ return {
2867
+ ...normalized,
2868
+ stepStarts: normalized.stepStarts.filter(
2869
+ (entry) => entry.turnId !== turn.turnId
2870
+ )
2871
+ };
2872
+ });
2873
+ }
2874
+ cleanupSession(sessionId) {
2875
+ const keyPrefix = `${sessionId}:`;
2876
+ this.sessionsById.delete(sessionId);
2877
+ for (const key of this.turnsByKey.keys()) {
2878
+ if (key.startsWith(keyPrefix)) {
2879
+ this.turnsByKey.delete(key);
2880
+ }
2881
+ }
2882
+ for (const key of this.toolsByCallKey.keys()) {
2883
+ if (key.startsWith(keyPrefix)) {
2884
+ this.toolsByCallKey.delete(key);
2885
+ }
2886
+ }
2887
+ for (const key of this.completedToolKeys.keys()) {
2888
+ if (key.startsWith(keyPrefix)) {
2889
+ this.completedToolKeys.delete(key);
2890
+ }
2891
+ }
2892
+ this.state.update(() => emptyEveTraceState());
2893
+ }
2894
+ async flushInstrumentation() {
2895
+ try {
2896
+ await _chunkMWVVR5LRjs.flush.call(void 0, );
2897
+ return true;
2898
+ } catch (error) {
2899
+ _chunkMWVVR5LRjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
2900
+ return false;
2901
+ }
2902
+ }
2903
+ }, _class);
2904
+ function emptyEveTraceState() {
2905
+ return {
2906
+ llmInputs: [],
2907
+ metadata: {},
2908
+ spanReferences: [],
2909
+ stepStarts: []
2910
+ };
2911
+ }
2912
+ function normalizeEveTraceState(state) {
2913
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, state)) {
2914
+ return emptyEveTraceState();
2915
+ }
2916
+ const metadata = _chunkMWVVR5LRjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
2917
+ const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
2918
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, entry)) {
2919
+ return [];
2920
+ }
2921
+ const exported = entry["exported"];
2922
+ const endTime = entry["endTime"];
2923
+ const rootSpanId = entry["rootSpanId"];
2924
+ const rowId = entry["rowId"];
2925
+ const spanId = entry["spanId"];
2926
+ const startEvent = entry["startEvent"];
2927
+ const startEventCreated = _chunkMWVVR5LRjs.isObject.call(void 0, startEvent) ? startEvent["created"] : void 0;
2928
+ const startEventMetrics = _chunkMWVVR5LRjs.isObject.call(void 0, startEvent) ? startEvent["metrics"] : void 0;
2929
+ const startEventSpanAttributes = _chunkMWVVR5LRjs.isObject.call(void 0, startEvent) ? startEvent["span_attributes"] : void 0;
2930
+ const startEventSpanParents = _chunkMWVVR5LRjs.isObject.call(void 0, startEvent) ? startEvent["span_parents"] : void 0;
2931
+ const normalizedStartEvent = typeof startEventCreated === "string" && _chunkMWVVR5LRjs.isObject.call(void 0, startEventMetrics) && typeof startEventMetrics["start"] === "number" && Number.isFinite(startEventMetrics["start"]) && _chunkMWVVR5LRjs.isObject.call(void 0, startEventSpanAttributes) && Array.isArray(startEventSpanParents) && startEventSpanParents.every(
2932
+ (parent) => typeof parent === "string"
2933
+ ) ? {
2934
+ created: startEventCreated,
2935
+ metrics: { start: startEventMetrics["start"] },
2936
+ span_attributes: { ...startEventSpanAttributes },
2937
+ span_parents: [...startEventSpanParents]
2938
+ } : void 0;
2939
+ return typeof exported === "string" && typeof rootSpanId === "string" && typeof rowId === "string" && typeof spanId === "string" ? [
2940
+ {
2941
+ ...typeof endTime === "number" && Number.isFinite(endTime) ? { endTime } : {},
2942
+ exported,
2943
+ rootSpanId,
2944
+ rowId,
2945
+ spanId,
2946
+ ...normalizedStartEvent ? { startEvent: normalizedStartEvent } : {}
2947
+ }
2948
+ ] : [];
2949
+ }).slice(-MAX_STORED_SPAN_REFERENCES) : [];
2950
+ const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
2951
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, entry)) {
2952
+ return [];
2953
+ }
2954
+ const key = entry["key"];
2955
+ const input = entry["input"];
2956
+ return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
2957
+ }).slice(-MAX_STORED_LLM_INPUTS) : [];
2958
+ const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
2959
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, entry)) {
2960
+ return [];
2961
+ }
2962
+ const ordinal = entry["ordinal"];
2963
+ const open = entry["open"];
2964
+ const stepIndex = entry["stepIndex"];
2965
+ const turnId = entry["turnId"];
2966
+ return typeof ordinal === "number" && Number.isInteger(ordinal) && ordinal >= 0 && typeof open === "boolean" && typeof stepIndex === "number" && Number.isInteger(stepIndex) && typeof turnId === "string" ? [{ open, ordinal, stepIndex, turnId }] : [];
2967
+ }).slice(-MAX_STORED_STEP_STARTS) : [];
2968
+ return { llmInputs, metadata: { ...metadata }, spanReferences, stepStarts };
2969
+ }
2970
+ function readEveTraceState(state) {
2971
+ try {
2972
+ return normalizeEveTraceState(state.get());
2973
+ } catch (e3) {
2974
+ return emptyEveTraceState();
2975
+ }
2976
+ }
2977
+ function captureEveModelInput(state, input) {
2978
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, input)) {
2979
+ return;
2980
+ }
2981
+ const session = input["session"];
2982
+ const turn = input["turn"];
2983
+ const step = input["step"];
2984
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, session) || !_chunkMWVVR5LRjs.isObject.call(void 0, turn) || !_chunkMWVVR5LRjs.isObject.call(void 0, step)) {
2985
+ return;
2986
+ }
2987
+ const sessionId = session["id"];
2988
+ const turnId = turn["id"];
2989
+ const stepIndex = step["index"];
2990
+ if (typeof sessionId !== "string" || typeof turnId !== "string" || typeof stepIndex !== "number" || !Number.isInteger(stepIndex)) {
2991
+ return;
2992
+ }
2993
+ const captured = capturedModelInput(input["modelInput"]);
2994
+ if (!captured) {
2995
+ return;
2996
+ }
2997
+ const key = llmInputKey(sessionId, turnId, stepIndex);
2998
+ state.update((current) => {
2999
+ const normalized = normalizeEveTraceState(current);
3000
+ const llmInputs = [...normalized.llmInputs, { input: captured, key }];
3001
+ return {
3002
+ ...normalized,
3003
+ llmInputs: llmInputs.slice(-MAX_STORED_LLM_INPUTS)
3004
+ };
3005
+ });
3006
+ }
3007
+ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
3008
+ try {
3009
+ const key = llmInputKey(sessionId, turnId, stepIndex);
3010
+ let input;
3011
+ state.update((current) => {
3012
+ const normalized = normalizeEveTraceState(current);
3013
+ const index = normalized.llmInputs.findIndex(
3014
+ (candidate) => candidate.key === key
3015
+ );
3016
+ if (index < 0) {
3017
+ return normalized;
3018
+ }
3019
+ input = _optionalChain([normalized, 'access', _107 => _107.llmInputs, 'access', _108 => _108[index], 'optionalAccess', _109 => _109.input]);
3020
+ return {
3021
+ ...normalized,
3022
+ llmInputs: normalized.llmInputs.filter(
3023
+ (_, candidateIndex) => candidateIndex !== index
3024
+ )
3025
+ };
3026
+ });
3027
+ return input;
3028
+ } catch (error) {
3029
+ _chunkMWVVR5LRjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
3030
+ return void 0;
3031
+ }
3032
+ }
3033
+ function capturedModelInput(modelInput) {
3034
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, modelInput)) {
3035
+ return void 0;
3036
+ }
3037
+ const messages = modelInput["messages"];
3038
+ if (!Array.isArray(messages)) {
3039
+ return void 0;
3040
+ }
3041
+ const instructions = modelInput["instructions"];
3042
+ const value = [
3043
+ ...instructions !== void 0 ? [{ content: instructions, role: "system" }] : [],
3044
+ ...messages
3045
+ ];
3046
+ try {
3047
+ const cloned = JSON.parse(JSON.stringify(value));
3048
+ if (!Array.isArray(cloned)) {
3049
+ return void 0;
3050
+ }
3051
+ return cloned;
3052
+ } catch (e4) {
3053
+ return void 0;
3054
+ }
3055
+ }
3056
+ function isCapturedModelInput(input) {
3057
+ return Array.isArray(input);
3058
+ }
3059
+ function llmInputKey(sessionId, turnId, stepIndex) {
3060
+ return `${sessionId}\0${turnId}\0${stepIndex}`;
3061
+ }
3062
+ function modelMetadataFromRuntime(runtime) {
3063
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, runtime)) {
3064
+ return {};
3065
+ }
3066
+ const modelId = runtime["modelId"];
3067
+ return typeof modelId === "string" ? modelMetadataFromModelId(modelId) : {};
3068
+ }
3069
+ function modelMetadataFromModelId(modelId) {
3070
+ const normalized = modelId.trim();
3071
+ if (!normalized) {
3072
+ return {};
3073
+ }
3074
+ const slashIndex = normalized.indexOf("/");
3075
+ if (slashIndex > 0 && slashIndex < normalized.length - 1) {
3076
+ return {
3077
+ model: normalized.slice(slashIndex + 1),
3078
+ provider: normalized.slice(0, slashIndex)
3079
+ };
3080
+ }
3081
+ return {
3082
+ model: normalized
3083
+ };
3084
+ }
3085
+ function sessionIdFromContext(ctx) {
3086
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, ctx)) {
3087
+ return void 0;
3088
+ }
3089
+ const session = ctx["session"];
3090
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, session)) {
3091
+ return void 0;
3092
+ }
3093
+ const id = session["id"];
3094
+ return typeof id === "string" ? id : void 0;
3095
+ }
3096
+ function toolMetadataFromTurn(turn) {
3097
+ const { model: _model, provider: _provider, ...metadata } = turn.metadata;
3098
+ return metadata;
3099
+ }
3100
+ function parentLineageFromContext(ctx) {
3101
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, ctx)) {
3102
+ return void 0;
3103
+ }
3104
+ const session = ctx.session;
3105
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, session)) {
3106
+ return void 0;
3107
+ }
3108
+ const parent = session["parent"];
3109
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, parent)) {
3110
+ return void 0;
3111
+ }
3112
+ const callId = parent["callId"];
3113
+ const rootSessionId = parent["rootSessionId"];
3114
+ const sessionId = parent["sessionId"];
3115
+ if (typeof callId !== "string" || typeof rootSessionId !== "string" || typeof sessionId !== "string") {
3116
+ return void 0;
3117
+ }
3118
+ return { callId, rootSessionId, sessionId };
3119
+ }
3120
+ function isToolCallAction(action) {
3121
+ return _chunkMWVVR5LRjs.isObject.call(void 0, action) && action["kind"] === "tool-call" && typeof action["callId"] === "string" && typeof action["toolName"] === "string" && _chunkMWVVR5LRjs.isObject.call(void 0, action["input"]);
3122
+ }
3123
+ function isLocalSubagentCallAction(action) {
3124
+ return _chunkMWVVR5LRjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkMWVVR5LRjs.isObject.call(void 0, action["input"]);
3125
+ }
3126
+ function isTraceableActionRequest(action) {
3127
+ return isToolCallAction(action) || isLocalSubagentCallAction(action);
3128
+ }
3129
+ function isToolResult(result) {
3130
+ return _chunkMWVVR5LRjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
3131
+ }
3132
+ function isSubagentResult(result) {
3133
+ return _chunkMWVVR5LRjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
3134
+ }
3135
+ function normalizedFinishReason(finishReason) {
3136
+ switch (finishReason) {
3137
+ case "content-filter":
3138
+ return "content_filter";
3139
+ case "tool-calls":
3140
+ return "tool_calls";
3141
+ default:
3142
+ return finishReason;
3143
+ }
3144
+ }
3145
+ function errorFromMessage(message, code, details) {
3146
+ const error = new Error(`${code}: ${message}`);
3147
+ if (details !== void 0) {
3148
+ error.cause = details;
3149
+ }
3150
+ return error;
3151
+ }
3152
+ function actionResultError(error, output) {
3153
+ if (error) {
3154
+ return errorFromMessage(error.message, error.code);
3155
+ }
3156
+ const result = new Error("Eve action failed");
3157
+ if (output !== void 0) {
3158
+ result.cause = output;
3159
+ }
3160
+ return result;
3161
+ }
3162
+ function eventTime(event) {
3163
+ if (!_optionalChain([event, 'access', _110 => _110.meta, 'optionalAccess', _111 => _111.at])) {
3164
+ return void 0;
3165
+ }
3166
+ const timestamp = Date.parse(event.meta.at);
3167
+ return Number.isFinite(timestamp) ? timestamp / 1e3 : void 0;
3168
+ }
3169
+ function turnKey(sessionId, turnId) {
3170
+ return `${sessionId}:${turnId}`;
3171
+ }
3172
+ function toolKey(sessionId, callId) {
3173
+ return `${sessionId}:${callId}`;
3174
+ }
3175
+ async function rootSpanIdForSession(sessionId) {
3176
+ return deterministicEveId("eve:root", sessionId);
3177
+ }
3178
+ async function generateEveIds(kind, ...parts) {
3179
+ const [rowId, spanId] = await Promise.all([
3180
+ deterministicEveId(`eve:row:${kind}`, ...parts),
3181
+ deterministicEveId(`eve:${kind}`, ...parts)
3182
+ ]);
3183
+ return { rowId, spanId };
3184
+ }
3185
+ async function spanIdForSubagent(sessionId, callId) {
3186
+ return deterministicEveId("eve:subagent", sessionId, callId);
3187
+ }
3188
+ async function deterministicEveId(...parts) {
3189
+ const data = new TextEncoder().encode(
3190
+ parts.map((part) => `${part.length}:${part}`).join("\0")
3191
+ );
3192
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", data);
3193
+ const bytes = Array.from(new Uint8Array(digest, 0, 16));
3194
+ const hex = bytes.map((byte) => byte.toString(16).padStart(2, "0")).join("");
3195
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
3196
+ }
3197
+
1691
3198
  // src/typed-instrumentation-helpers.ts
1692
3199
  var TypedApplyProxy = Proxy;
1693
3200
 
@@ -1729,7 +3236,7 @@ function messagesProxy(messages) {
1729
3236
  return new Proxy(messages, {
1730
3237
  get(target, prop, receiver) {
1731
3238
  if (prop === "create") {
1732
- return createProxy(target.create, _chunkLPC4W2WXjs.anthropicChannels.messagesCreate);
3239
+ return createProxy(target.create, _chunkBFGIH2ZJjs.anthropicChannels.messagesCreate);
1733
3240
  }
1734
3241
  return Reflect.get(target, prop, receiver);
1735
3242
  }
@@ -1739,7 +3246,7 @@ function betaMessagesProxy(messages, anthropic) {
1739
3246
  return new Proxy(messages, {
1740
3247
  get(target, prop, receiver) {
1741
3248
  if (prop === "create") {
1742
- return createProxy(target.create, _chunkLPC4W2WXjs.anthropicChannels.betaMessagesCreate);
3249
+ return createProxy(target.create, _chunkBFGIH2ZJjs.anthropicChannels.betaMessagesCreate);
1743
3250
  }
1744
3251
  if (prop === "toolRunner") {
1745
3252
  if (typeof target.toolRunner !== "function") {
@@ -1748,7 +3255,7 @@ function betaMessagesProxy(messages, anthropic) {
1748
3255
  return toolRunnerProxy(
1749
3256
  target.toolRunner,
1750
3257
  anthropic,
1751
- _chunkLPC4W2WXjs.anthropicChannels.betaMessagesToolRunner
3258
+ _chunkBFGIH2ZJjs.anthropicChannels.betaMessagesToolRunner
1752
3259
  );
1753
3260
  }
1754
3261
  return Reflect.get(target, prop, receiver);
@@ -1805,11 +3312,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
1805
3312
  ...params,
1806
3313
  options: {
1807
3314
  ..._nullishCoalesce(params.options, () => ( {})),
1808
- [_chunkPOCCIJALjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
3315
+ [_chunkMWVVR5LRjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
1809
3316
  }
1810
3317
  };
1811
3318
  const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
1812
- return _chunkLPC4W2WXjs.claudeAgentSDKChannels.query.traceSync(
3319
+ return _chunkBFGIH2ZJjs.claudeAgentSDKChannels.query.traceSync(
1813
3320
  () => Reflect.apply(target, invocationTarget, [wrappedParams]),
1814
3321
  // The channel carries no extra context fields, but the generated
1815
3322
  // StartOf<> type for Record<string, never> is overly strict here.
@@ -1837,7 +3344,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
1837
3344
  }
1838
3345
  const localToolMetadata = { toolName };
1839
3346
  const originalHandler = wrappedArgs[handlerIndex];
1840
- wrappedArgs[handlerIndex] = _chunkPOCCIJALjs.wrapLocalClaudeToolHandler.call(void 0,
3347
+ wrappedArgs[handlerIndex] = _chunkMWVVR5LRjs.wrapLocalClaudeToolHandler.call(void 0,
1841
3348
  originalHandler,
1842
3349
  () => localToolMetadata
1843
3350
  );
@@ -1855,8 +3362,8 @@ function wrapCreateSdkMcpServer(createSdkMcpServerFn, localToolMetadataByTool, d
1855
3362
  apply(target, thisArg, argArray) {
1856
3363
  const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
1857
3364
  const config = argArray[0];
1858
- const serverName = _optionalChain([config, 'optionalAccess', _69 => _69.name]);
1859
- if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess', _70 => _70.tools]))) {
3365
+ const serverName = _optionalChain([config, 'optionalAccess', _112 => _112.name]);
3366
+ if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess', _113 => _113.tools]))) {
1860
3367
  for (const tool of config.tools) {
1861
3368
  if (!tool || typeof tool !== "object") {
1862
3369
  continue;
@@ -1950,7 +3457,7 @@ function isModuleNamespace2(obj) {
1950
3457
  if (!obj || typeof obj !== "object") {
1951
3458
  return false;
1952
3459
  }
1953
- if (_optionalChain([obj, 'access', _71 => _71.constructor, 'optionalAccess', _72 => _72.name]) === "Module") {
3460
+ if (_optionalChain([obj, 'access', _114 => _114.constructor, 'optionalAccess', _115 => _115.name]) === "Module") {
1954
3461
  return true;
1955
3462
  }
1956
3463
  const keys = Object.keys(obj);
@@ -2020,7 +3527,7 @@ function wrapCodexThread(thread) {
2020
3527
  if (prop === "run" && typeof value === "function") {
2021
3528
  return function(input, turnOptions) {
2022
3529
  const args = [input, turnOptions];
2023
- return _chunkLPC4W2WXjs.openAICodexChannels.run.tracePromise(
3530
+ return _chunkBFGIH2ZJjs.openAICodexChannels.run.tracePromise(
2024
3531
  () => Reflect.apply(value, target, args),
2025
3532
  {
2026
3533
  arguments: args,
@@ -2033,7 +3540,7 @@ function wrapCodexThread(thread) {
2033
3540
  if (prop === "runStreamed" && typeof value === "function") {
2034
3541
  return function(input, turnOptions) {
2035
3542
  const args = [input, turnOptions];
2036
- return _chunkLPC4W2WXjs.openAICodexChannels.runStreamed.tracePromise(
3543
+ return _chunkBFGIH2ZJjs.openAICodexChannels.runStreamed.tracePromise(
2037
3544
  () => Reflect.apply(value, target, args),
2038
3545
  {
2039
3546
  arguments: args,
@@ -2080,7 +3587,7 @@ function isModuleNamespace3(obj) {
2080
3587
  if (!obj || typeof obj !== "object") {
2081
3588
  return false;
2082
3589
  }
2083
- if (_optionalChain([obj, 'access', _73 => _73.constructor, 'optionalAccess', _74 => _74.name]) === "Module") {
3590
+ if (_optionalChain([obj, 'access', _116 => _116.constructor, 'optionalAccess', _117 => _117.name]) === "Module") {
2084
3591
  return true;
2085
3592
  }
2086
3593
  const keys = Object.keys(obj);
@@ -2101,7 +3608,7 @@ function wrapCursorAgentClass(Agent) {
2101
3608
  if (prop === "create" && typeof value === "function") {
2102
3609
  const wrapped = async function(options) {
2103
3610
  const args = [options];
2104
- return _chunkLPC4W2WXjs.cursorSDKChannels.create.tracePromise(
3611
+ return _chunkBFGIH2ZJjs.cursorSDKChannels.create.tracePromise(
2105
3612
  async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
2106
3613
  { arguments: args }
2107
3614
  );
@@ -2112,7 +3619,7 @@ function wrapCursorAgentClass(Agent) {
2112
3619
  if (prop === "resume" && typeof value === "function") {
2113
3620
  const wrapped = async function(agentId, options) {
2114
3621
  const args = [agentId, options];
2115
- return _chunkLPC4W2WXjs.cursorSDKChannels.resume.tracePromise(
3622
+ return _chunkBFGIH2ZJjs.cursorSDKChannels.resume.tracePromise(
2116
3623
  async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
2117
3624
  { arguments: args }
2118
3625
  );
@@ -2123,7 +3630,7 @@ function wrapCursorAgentClass(Agent) {
2123
3630
  if (prop === "prompt" && typeof value === "function") {
2124
3631
  const wrapped = async function(message, options) {
2125
3632
  const args = [message, options];
2126
- return _chunkLPC4W2WXjs.cursorSDKChannels.prompt.tracePromise(
3633
+ return _chunkBFGIH2ZJjs.cursorSDKChannels.prompt.tracePromise(
2127
3634
  () => Reflect.apply(value, target, args),
2128
3635
  { arguments: args }
2129
3636
  );
@@ -2156,7 +3663,7 @@ function wrapCursorAgent(agent) {
2156
3663
  if (prop === "send" && typeof value === "function") {
2157
3664
  return function(message, options) {
2158
3665
  const args = [message, options];
2159
- return _chunkLPC4W2WXjs.cursorSDKChannels.send.tracePromise(
3666
+ return _chunkBFGIH2ZJjs.cursorSDKChannels.send.tracePromise(
2160
3667
  () => Reflect.apply(value, target, args),
2161
3668
  {
2162
3669
  agent: target,
@@ -2206,7 +3713,7 @@ function patchAgentSessionClass(AgentSession) {
2206
3713
  ...descriptor,
2207
3714
  value: function wrappedPiCodingAgentPrompt(text, options) {
2208
3715
  const args = [text, options];
2209
- return _chunkLPC4W2WXjs.piCodingAgentChannels.prompt.tracePromise(
3716
+ return _chunkBFGIH2ZJjs.piCodingAgentChannels.prompt.tracePromise(
2210
3717
  () => Reflect.apply(originalPrompt, this, args),
2211
3718
  {
2212
3719
  arguments: args,
@@ -2264,7 +3771,7 @@ function isModuleNamespace4(obj) {
2264
3771
  if (!obj || typeof obj !== "object") {
2265
3772
  return false;
2266
3773
  }
2267
- if (_optionalChain([obj, 'access', _75 => _75.constructor, 'optionalAccess', _76 => _76.name]) === "Module") {
3774
+ if (_optionalChain([obj, 'access', _118 => _118.constructor, 'optionalAccess', _119 => _119.name]) === "Module") {
2268
3775
  return true;
2269
3776
  }
2270
3777
  const keys = Object.keys(obj);
@@ -2326,7 +3833,7 @@ function wrapAgentInstance(agent) {
2326
3833
  if (prop === "stream" && typeof value === "function") {
2327
3834
  return function(args, options) {
2328
3835
  const callArgs = [args, options];
2329
- return _chunkLPC4W2WXjs.strandsAgentSDKChannels.agentStream.traceSync(
3836
+ return _chunkBFGIH2ZJjs.strandsAgentSDKChannels.agentStream.traceSync(
2330
3837
  () => Reflect.apply(value, target, callArgs),
2331
3838
  {
2332
3839
  agent: proxy,
@@ -2362,7 +3869,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
2362
3869
  if (prop === "stream" && typeof value === "function") {
2363
3870
  return function(input, options) {
2364
3871
  const callArgs = [input, options];
2365
- const channel = kind === "graph" ? _chunkLPC4W2WXjs.strandsAgentSDKChannels.graphStream : _chunkLPC4W2WXjs.strandsAgentSDKChannels.swarmStream;
3872
+ const channel = kind === "graph" ? _chunkBFGIH2ZJjs.strandsAgentSDKChannels.graphStream : _chunkBFGIH2ZJjs.strandsAgentSDKChannels.swarmStream;
2366
3873
  return channel.traceSync(
2367
3874
  () => Reflect.apply(value, target, callArgs),
2368
3875
  {
@@ -2437,7 +3944,7 @@ function wrapGoogleGenAIInstance(instance) {
2437
3944
  }
2438
3945
  if (prop === "interactions") {
2439
3946
  const interactions = Reflect.get(target, prop, receiver);
2440
- if (!_chunkPOCCIJALjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
3947
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
2441
3948
  return interactions;
2442
3949
  }
2443
3950
  if (interactions !== originalInteractions) {
@@ -2451,7 +3958,7 @@ function wrapGoogleGenAIInstance(instance) {
2451
3958
  });
2452
3959
  }
2453
3960
  function patchGoogleGenAIChats(instance, wrappedModels) {
2454
- if (!_chunkPOCCIJALjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
3961
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
2455
3962
  return;
2456
3963
  }
2457
3964
  Reflect.set(instance.chats, "modelsModule", wrappedModels);
@@ -2484,7 +3991,7 @@ function wrapInteractions(interactions) {
2484
3991
  }
2485
3992
  function wrapGenerateContent(original) {
2486
3993
  return function(params) {
2487
- return _chunkLPC4W2WXjs.googleGenAIChannels.generateContent.tracePromise(
3994
+ return _chunkBFGIH2ZJjs.googleGenAIChannels.generateContent.tracePromise(
2488
3995
  () => original(params),
2489
3996
  { arguments: [params] }
2490
3997
  );
@@ -2492,7 +3999,7 @@ function wrapGenerateContent(original) {
2492
3999
  }
2493
4000
  function wrapGenerateContentStream(original) {
2494
4001
  return function(params) {
2495
- return _chunkLPC4W2WXjs.googleGenAIChannels.generateContentStream.tracePromise(
4002
+ return _chunkBFGIH2ZJjs.googleGenAIChannels.generateContentStream.tracePromise(
2496
4003
  () => original(params),
2497
4004
  { arguments: [params] }
2498
4005
  );
@@ -2500,7 +4007,7 @@ function wrapGenerateContentStream(original) {
2500
4007
  }
2501
4008
  function wrapEmbedContent(original) {
2502
4009
  return function(params) {
2503
- return _chunkLPC4W2WXjs.googleGenAIChannels.embedContent.tracePromise(
4010
+ return _chunkBFGIH2ZJjs.googleGenAIChannels.embedContent.tracePromise(
2504
4011
  () => original(params),
2505
4012
  { arguments: [params] }
2506
4013
  );
@@ -2512,7 +4019,7 @@ function wrapInteractionCreate(original) {
2512
4019
  return options === void 0 ? original(params) : original(params, options);
2513
4020
  }
2514
4021
  const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
2515
- return _chunkLPC4W2WXjs.googleGenAIChannels.interactionsCreate.tracePromise(
4022
+ return _chunkBFGIH2ZJjs.googleGenAIChannels.interactionsCreate.tracePromise(
2516
4023
  () => options === void 0 ? original(params) : original(params, options),
2517
4024
  traceContext
2518
4025
  );
@@ -2573,7 +4080,7 @@ function wrapRunnerInstance(runner) {
2573
4080
  function wrapRunnerRunAsync(runner) {
2574
4081
  const original = runner.runAsync.bind(runner);
2575
4082
  return function(params) {
2576
- return _chunkLPC4W2WXjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
4083
+ return _chunkBFGIH2ZJjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
2577
4084
  arguments: [params],
2578
4085
  self: runner
2579
4086
  });
@@ -2600,7 +4107,7 @@ function wrapAgentInstance2(agent) {
2600
4107
  function wrapAgentRunAsync(agent) {
2601
4108
  const original = agent.runAsync.bind(agent);
2602
4109
  return function(parentContext) {
2603
- return _chunkLPC4W2WXjs.googleADKChannels.agentRunAsync.traceSync(
4110
+ return _chunkBFGIH2ZJjs.googleADKChannels.agentRunAsync.traceSync(
2604
4111
  () => original(parentContext),
2605
4112
  { arguments: [parentContext], self: agent }
2606
4113
  );
@@ -2627,7 +4134,7 @@ function wrapToolInstance(tool) {
2627
4134
  function wrapToolRunAsync(tool) {
2628
4135
  const original = tool.runAsync.bind(tool);
2629
4136
  return function(req) {
2630
- return _chunkLPC4W2WXjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
4137
+ return _chunkBFGIH2ZJjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
2631
4138
  arguments: [req],
2632
4139
  self: tool
2633
4140
  });
@@ -2739,7 +4246,7 @@ function patchGenkitRegistryLookup(registry) {
2739
4246
  Object.defineProperty(registry, PATCHED_GENKIT_REGISTRY, {
2740
4247
  value: true
2741
4248
  });
2742
- } catch (e3) {
4249
+ } catch (e5) {
2743
4250
  }
2744
4251
  }
2745
4252
  function patchGenkitRegistryConstructor(registry) {
@@ -2770,31 +4277,31 @@ function patchGenkitRegistryConstructor(registry) {
2770
4277
  Object.defineProperty(constructor, PATCHED_GENKIT_REGISTRY_CONSTRUCTOR, {
2771
4278
  value: true
2772
4279
  });
2773
- } catch (e4) {
4280
+ } catch (e6) {
2774
4281
  }
2775
4282
  }
2776
4283
  function wrapGenerate(generate) {
2777
- return (input) => _chunkLPC4W2WXjs.genkitChannels.generate.tracePromise(() => generate(input), {
4284
+ return (input) => _chunkBFGIH2ZJjs.genkitChannels.generate.tracePromise(() => generate(input), {
2778
4285
  arguments: [input]
2779
4286
  });
2780
4287
  }
2781
4288
  function wrapGenerateStream(generateStream) {
2782
- return (input) => _chunkLPC4W2WXjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
4289
+ return (input) => _chunkBFGIH2ZJjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
2783
4290
  arguments: [input]
2784
4291
  });
2785
4292
  }
2786
4293
  function wrapEmbed2(embed) {
2787
- return (params) => _chunkLPC4W2WXjs.genkitChannels.embed.tracePromise(() => embed(params), {
4294
+ return (params) => _chunkBFGIH2ZJjs.genkitChannels.embed.tracePromise(() => embed(params), {
2788
4295
  arguments: [params]
2789
4296
  });
2790
4297
  }
2791
4298
  function wrapEmbedMany2(embedMany) {
2792
- return (params) => _chunkLPC4W2WXjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
4299
+ return (params) => _chunkBFGIH2ZJjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
2793
4300
  arguments: [params]
2794
4301
  });
2795
4302
  }
2796
4303
  function wrapRun(run) {
2797
- return (name, inputOrFn, maybeFn) => _chunkLPC4W2WXjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
4304
+ return (name, inputOrFn, maybeFn) => _chunkBFGIH2ZJjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
2798
4305
  arguments: [name, inputOrFn, maybeFn]
2799
4306
  });
2800
4307
  }
@@ -2833,13 +4340,13 @@ function isGenkitAction(value) {
2833
4340
  return typeof value === "function" && "__action" in value;
2834
4341
  }
2835
4342
  function traceActionRun(action, run) {
2836
- return (input, options) => _chunkLPC4W2WXjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
4343
+ return (input, options) => _chunkBFGIH2ZJjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
2837
4344
  arguments: [input, options],
2838
4345
  self: action
2839
4346
  });
2840
4347
  }
2841
4348
  function traceActionStream(action, stream) {
2842
- return (input, options) => _chunkLPC4W2WXjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
4349
+ return (input, options) => _chunkBFGIH2ZJjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
2843
4350
  arguments: [input, options],
2844
4351
  self: action
2845
4352
  });
@@ -2885,10 +4392,10 @@ function isHuggingFaceConstructorKey(value) {
2885
4392
  return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
2886
4393
  }
2887
4394
  function hasFunction2(value, methodName) {
2888
- return _chunkPOCCIJALjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
4395
+ return _chunkMWVVR5LRjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
2889
4396
  }
2890
4397
  function isSupportedHuggingFaceModule(value) {
2891
- if (!_chunkPOCCIJALjs.isObject.call(void 0, value)) {
4398
+ if (!_chunkMWVVR5LRjs.isObject.call(void 0, value)) {
2892
4399
  return false;
2893
4400
  }
2894
4401
  return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
@@ -2996,14 +4503,14 @@ function wrapChatCompletion2(original, endpointUrl) {
2996
4503
  const context = {
2997
4504
  arguments: [traceParams]
2998
4505
  };
2999
- return _chunkLPC4W2WXjs.huggingFaceChannels.chatCompletion.tracePromise(
4506
+ return _chunkBFGIH2ZJjs.huggingFaceChannels.chatCompletion.tracePromise(
3000
4507
  () => original(params, options),
3001
4508
  context
3002
4509
  );
3003
4510
  };
3004
4511
  }
3005
4512
  function wrapChatCompletionStream(original, endpointUrl) {
3006
- return (params, options) => _chunkLPC4W2WXjs.huggingFaceChannels.chatCompletionStream.traceSync(
4513
+ return (params, options) => _chunkBFGIH2ZJjs.huggingFaceChannels.chatCompletionStream.traceSync(
3007
4514
  () => original(params, options),
3008
4515
  {
3009
4516
  arguments: [withEndpointUrl(params, endpointUrl)]
@@ -3016,14 +4523,14 @@ function wrapTextGeneration(original, endpointUrl) {
3016
4523
  const context = {
3017
4524
  arguments: [traceParams]
3018
4525
  };
3019
- return _chunkLPC4W2WXjs.huggingFaceChannels.textGeneration.tracePromise(
4526
+ return _chunkBFGIH2ZJjs.huggingFaceChannels.textGeneration.tracePromise(
3020
4527
  () => original(params, options),
3021
4528
  context
3022
4529
  );
3023
4530
  };
3024
4531
  }
3025
4532
  function wrapTextGenerationStream(original, endpointUrl) {
3026
- return (params, options) => _chunkLPC4W2WXjs.huggingFaceChannels.textGenerationStream.traceSync(
4533
+ return (params, options) => _chunkBFGIH2ZJjs.huggingFaceChannels.textGenerationStream.traceSync(
3027
4534
  () => original(params, options),
3028
4535
  {
3029
4536
  arguments: [withEndpointUrl(params, endpointUrl)]
@@ -3036,7 +4543,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
3036
4543
  const context = {
3037
4544
  arguments: [traceParams]
3038
4545
  };
3039
- return _chunkLPC4W2WXjs.huggingFaceChannels.featureExtraction.tracePromise(
4546
+ return _chunkBFGIH2ZJjs.huggingFaceChannels.featureExtraction.tracePromise(
3040
4547
  () => original(params, options),
3041
4548
  context
3042
4549
  );
@@ -3083,7 +4590,7 @@ function wrapCallModel(callModelFn, defaultThis) {
3083
4590
  const request = cloneCallModelRequest(argArray[0]);
3084
4591
  const options = argArray[1];
3085
4592
  const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
3086
- return _chunkLPC4W2WXjs.openRouterAgentChannels.callModel.traceSync(
4593
+ return _chunkBFGIH2ZJjs.openRouterAgentChannels.callModel.traceSync(
3087
4594
  () => Reflect.apply(target, invocationTarget, [request, options]),
3088
4595
  {
3089
4596
  arguments: [request]
@@ -3179,24 +4686,24 @@ function rerankProxy(rerank) {
3179
4686
  });
3180
4687
  }
3181
4688
  function wrapChatSend(send) {
3182
- return (request, options) => _chunkLPC4W2WXjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
4689
+ return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
3183
4690
  arguments: [request]
3184
4691
  });
3185
4692
  }
3186
4693
  function wrapEmbeddingsGenerate(generate) {
3187
- return (request, options) => _chunkLPC4W2WXjs.openRouterChannels.embeddingsGenerate.tracePromise(
4694
+ return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.embeddingsGenerate.tracePromise(
3188
4695
  () => generate(request, options),
3189
4696
  { arguments: [request] }
3190
4697
  );
3191
4698
  }
3192
4699
  function wrapResponsesSend(send) {
3193
- return (request, options) => _chunkLPC4W2WXjs.openRouterChannels.betaResponsesSend.tracePromise(
4700
+ return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.betaResponsesSend.tracePromise(
3194
4701
  () => send(request, options),
3195
4702
  { arguments: [request] }
3196
4703
  );
3197
4704
  }
3198
4705
  function wrapRerank2(rerank) {
3199
- return (request, options) => _chunkLPC4W2WXjs.openRouterChannels.rerankRerank.tracePromise(
4706
+ return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.rerankRerank.tracePromise(
3200
4707
  () => rerank(request, options),
3201
4708
  { arguments: [request] }
3202
4709
  );
@@ -3204,7 +4711,7 @@ function wrapRerank2(rerank) {
3204
4711
  function wrapCallModel2(callModel) {
3205
4712
  return (request, options) => {
3206
4713
  const tracedRequest = { ...request };
3207
- return _chunkLPC4W2WXjs.openRouterChannels.callModel.traceSync(
4714
+ return _chunkBFGIH2ZJjs.openRouterChannels.callModel.traceSync(
3208
4715
  () => callModel(tracedRequest, options),
3209
4716
  {
3210
4717
  arguments: [tracedRequest]
@@ -3337,7 +4844,7 @@ function classifiersProxy(classifiers) {
3337
4844
  });
3338
4845
  }
3339
4846
  function wrapChatComplete(complete) {
3340
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.chatComplete.tracePromise(
4847
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.chatComplete.tracePromise(
3341
4848
  () => complete(request, options),
3342
4849
  {
3343
4850
  arguments: [request]
@@ -3345,52 +4852,52 @@ function wrapChatComplete(complete) {
3345
4852
  );
3346
4853
  }
3347
4854
  function wrapChatStream(stream) {
3348
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
4855
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
3349
4856
  arguments: [request]
3350
4857
  });
3351
4858
  }
3352
4859
  function wrapEmbeddingsCreate(create) {
3353
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.embeddingsCreate.tracePromise(
4860
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.embeddingsCreate.tracePromise(
3354
4861
  () => create(request, options),
3355
4862
  { arguments: [request] }
3356
4863
  );
3357
4864
  }
3358
4865
  function wrapClassifiersModerate(moderate) {
3359
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.classifiersModerate.tracePromise(
4866
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersModerate.tracePromise(
3360
4867
  () => moderate(request, options),
3361
4868
  { arguments: [request] }
3362
4869
  );
3363
4870
  }
3364
4871
  function wrapClassifiersModerateChat(moderateChat) {
3365
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.classifiersModerateChat.tracePromise(
4872
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersModerateChat.tracePromise(
3366
4873
  () => moderateChat(request, options),
3367
4874
  { arguments: [request] }
3368
4875
  );
3369
4876
  }
3370
4877
  function wrapClassifiersClassify(classify) {
3371
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.classifiersClassify.tracePromise(
4878
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersClassify.tracePromise(
3372
4879
  () => classify(request, options),
3373
4880
  { arguments: [request] }
3374
4881
  );
3375
4882
  }
3376
4883
  function wrapClassifiersClassifyChat(classifyChat) {
3377
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.classifiersClassifyChat.tracePromise(
4884
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersClassifyChat.tracePromise(
3378
4885
  () => classifyChat(request, options),
3379
4886
  { arguments: [request] }
3380
4887
  );
3381
4888
  }
3382
4889
  function wrapFimComplete(complete) {
3383
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
4890
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
3384
4891
  arguments: [request]
3385
4892
  });
3386
4893
  }
3387
4894
  function wrapFimStream(stream) {
3388
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
4895
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
3389
4896
  arguments: [request]
3390
4897
  });
3391
4898
  }
3392
4899
  function wrapAgentsComplete(complete) {
3393
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.agentsComplete.tracePromise(
4900
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.agentsComplete.tracePromise(
3394
4901
  () => complete(request, options),
3395
4902
  {
3396
4903
  arguments: [request]
@@ -3398,7 +4905,7 @@ function wrapAgentsComplete(complete) {
3398
4905
  );
3399
4906
  }
3400
4907
  function wrapAgentsStream(stream) {
3401
- return (request, options) => _chunkLPC4W2WXjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
4908
+ return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
3402
4909
  arguments: [request]
3403
4910
  });
3404
4911
  }
@@ -3451,22 +4958,22 @@ function cohereProxy(cohere) {
3451
4958
  return proxy;
3452
4959
  }
3453
4960
  function wrapChat(chat) {
3454
- return (request, options) => _chunkLPC4W2WXjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
4961
+ return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
3455
4962
  arguments: [request]
3456
4963
  });
3457
4964
  }
3458
4965
  function wrapChatStream2(chatStream) {
3459
- return (request, options) => _chunkLPC4W2WXjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
4966
+ return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
3460
4967
  arguments: [request]
3461
4968
  });
3462
4969
  }
3463
4970
  function wrapEmbed3(embed) {
3464
- return (request, options) => _chunkLPC4W2WXjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
4971
+ return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
3465
4972
  arguments: [request]
3466
4973
  });
3467
4974
  }
3468
4975
  function wrapRerank3(rerank) {
3469
- return (request, options) => _chunkLPC4W2WXjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
4976
+ return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
3470
4977
  arguments: [request]
3471
4978
  });
3472
4979
  }
@@ -3496,7 +5003,7 @@ function isSupportedGroqClient(value) {
3496
5003
  }
3497
5004
  function groqProxy(groq) {
3498
5005
  const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
3499
- const completionProxy = _optionalChain([groq, 'access', _77 => _77.chat, 'optionalAccess', _78 => _78.completions]) ? new Proxy(groq.chat.completions, {
5006
+ const completionProxy = _optionalChain([groq, 'access', _120 => _120.chat, 'optionalAccess', _121 => _121.completions]) ? new Proxy(groq.chat.completions, {
3500
5007
  get(target, prop, receiver) {
3501
5008
  if (prop === "create") {
3502
5009
  return wrapChatCompletionsCreate(target.create.bind(target));
@@ -3548,13 +5055,13 @@ function groqProxy(groq) {
3548
5055
  return topLevelProxy;
3549
5056
  }
3550
5057
  function wrapChatCompletionsCreate(create) {
3551
- return (request, options) => _chunkLPC4W2WXjs.groqChannels.chatCompletionsCreate.tracePromise(
5058
+ return (request, options) => _chunkBFGIH2ZJjs.groqChannels.chatCompletionsCreate.tracePromise(
3552
5059
  () => create(request, options),
3553
5060
  { arguments: [request] }
3554
5061
  );
3555
5062
  }
3556
5063
  function wrapEmbeddingsCreate2(create) {
3557
- return (request, options) => _chunkLPC4W2WXjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
5064
+ return (request, options) => _chunkBFGIH2ZJjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
3558
5065
  arguments: [request]
3559
5066
  });
3560
5067
  }
@@ -3628,16 +5135,16 @@ function bedrockRuntimeProxy(client) {
3628
5135
  }
3629
5136
  function wrapSend(send) {
3630
5137
  return (command, optionsOrCb, cb) => {
3631
- if (_chunkPOCCIJALjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
5138
+ if (_chunkMWVVR5LRjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
3632
5139
  return send(command, optionsOrCb, cb);
3633
5140
  }
3634
- return _chunkLPC4W2WXjs.bedrockRuntimeChannels.clientSend.tracePromise(
3635
- () => _chunkPOCCIJALjs.runWithAutoInstrumentationSuppressed.call(void 0,
5141
+ return _chunkBFGIH2ZJjs.bedrockRuntimeChannels.clientSend.tracePromise(
5142
+ () => _chunkMWVVR5LRjs.runWithAutoInstrumentationSuppressed.call(void 0,
3636
5143
  () => send(command, optionsOrCb)
3637
5144
  ),
3638
5145
  {
3639
5146
  arguments: [command, optionsOrCb],
3640
- span_info: _chunkPOCCIJALjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
5147
+ span_info: _chunkMWVVR5LRjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
3641
5148
  }
3642
5149
  );
3643
5150
  };
@@ -3686,13 +5193,13 @@ function copilotClientProxy(client) {
3686
5193
  return proxy;
3687
5194
  }
3688
5195
  function wrappedCreateSession(client) {
3689
- return (config) => _chunkLPC4W2WXjs.gitHubCopilotChannels.createSession.tracePromise(
5196
+ return (config) => _chunkBFGIH2ZJjs.gitHubCopilotChannels.createSession.tracePromise(
3690
5197
  () => client.createSession(config),
3691
5198
  { arguments: [config] }
3692
5199
  );
3693
5200
  }
3694
5201
  function wrappedResumeSession(client) {
3695
- return (sessionId, config) => _chunkLPC4W2WXjs.gitHubCopilotChannels.resumeSession.tracePromise(
5202
+ return (sessionId, config) => _chunkBFGIH2ZJjs.gitHubCopilotChannels.resumeSession.tracePromise(
3696
5203
  () => client.resumeSession(sessionId, config),
3697
5204
  { arguments: [sessionId, config] }
3698
5205
  );
@@ -3706,7 +5213,7 @@ var VitestContextManager = class {
3706
5213
  */
3707
5214
 
3708
5215
  constructor() {
3709
- this.contextStorage = _chunkLPC4W2WXjs.isomorph_default.newAsyncLocalStorage();
5216
+ this.contextStorage = _chunkBFGIH2ZJjs.isomorph_default.newAsyncLocalStorage();
3710
5217
  }
3711
5218
  getCurrentContext() {
3712
5219
  return this.contextStorage.getStore();
@@ -3739,15 +5246,15 @@ function getVitestContextManager() {
3739
5246
  }
3740
5247
 
3741
5248
  // src/wrappers/vitest/flush-manager.ts
3742
- var FlushCoordinator = (_class = class {constructor() { _class.prototype.__init.call(this); }
3743
- __init() {this.activeFlushes = /* @__PURE__ */ new Map()}
5249
+ var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__init6.call(this); }
5250
+ __init6() {this.activeFlushes = /* @__PURE__ */ new Map()}
3744
5251
  async coordinateFlush(context, config) {
3745
5252
  if (!context) return;
3746
5253
  const experimentId = await context.experiment.id;
3747
5254
  if (this.activeFlushes.has(experimentId)) {
3748
5255
  return this.activeFlushes.get(experimentId);
3749
5256
  }
3750
- const flushPromise = _chunkPOCCIJALjs.summarizeAndFlush.call(void 0, context.experiment, {
5257
+ const flushPromise = _chunkMWVVR5LRjs.summarizeAndFlush.call(void 0, context.experiment, {
3751
5258
  displaySummary: config.displaySummary
3752
5259
  });
3753
5260
  this.activeFlushes.set(experimentId, flushPromise);
@@ -3757,7 +5264,7 @@ var FlushCoordinator = (_class = class {constructor() { _class.prototype.__init.
3757
5264
  this.activeFlushes.delete(experimentId);
3758
5265
  }
3759
5266
  }
3760
- }, _class);
5267
+ }, _class2);
3761
5268
  var flushCoordinator = new FlushCoordinator();
3762
5269
  async function flushExperimentWithSync(context, config) {
3763
5270
  return flushCoordinator.coordinateFlush(context, config);
@@ -3845,7 +5352,7 @@ async function runTracedEval(args) {
3845
5352
  }
3846
5353
  if (testError) {
3847
5354
  span.log({ scores: { pass: 0 } });
3848
- _chunkPOCCIJALjs.logError.call(void 0, span, testError);
5355
+ _chunkMWVVR5LRjs.logError.call(void 0, span, testError);
3849
5356
  throw testError;
3850
5357
  }
3851
5358
  span.log({
@@ -3878,7 +5385,7 @@ function wrapTest(originalTest, config) {
3878
5385
  const wrapped = function(name, configOrFn, maybeFn) {
3879
5386
  const isEnhanced = typeof configOrFn !== "function";
3880
5387
  const testConfig = isEnhanced ? configOrFn : void 0;
3881
- if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _79 => _79.data]) && Array.isArray(testConfig.data)) {
5388
+ if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _122 => _122.data]) && Array.isArray(testConfig.data)) {
3882
5389
  const dataRecords = testConfig.data;
3883
5390
  const testFn2 = maybeFn;
3884
5391
  if (!testFn2) {
@@ -3916,7 +5423,7 @@ function wrapTest(originalTest, config) {
3916
5423
  const registrationContext = getExperimentContext();
3917
5424
  const testImplementation = async (vitestContext) => {
3918
5425
  const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
3919
- const experiment = _optionalChain([experimentContext, 'optionalAccess', _80 => _80.experiment]);
5426
+ const experiment = _optionalChain([experimentContext, 'optionalAccess', _123 => _123.experiment]);
3920
5427
  if (config.onProgress) {
3921
5428
  config.onProgress({ type: "test_start", testName: name });
3922
5429
  }
@@ -3948,11 +5455,11 @@ function wrapTest(originalTest, config) {
3948
5455
  const result = await runTracedEval({
3949
5456
  experiment,
3950
5457
  spanName: name,
3951
- input: _optionalChain([testConfig, 'optionalAccess', _81 => _81.input]),
3952
- expected: _optionalChain([testConfig, 'optionalAccess', _82 => _82.expected]),
3953
- metadata: _optionalChain([testConfig, 'optionalAccess', _83 => _83.metadata]),
3954
- tags: _optionalChain([testConfig, 'optionalAccess', _84 => _84.tags]),
3955
- scorers: _optionalChain([testConfig, 'optionalAccess', _85 => _85.scorers]),
5458
+ input: _optionalChain([testConfig, 'optionalAccess', _124 => _124.input]),
5459
+ expected: _optionalChain([testConfig, 'optionalAccess', _125 => _125.expected]),
5460
+ metadata: _optionalChain([testConfig, 'optionalAccess', _126 => _126.metadata]),
5461
+ tags: _optionalChain([testConfig, 'optionalAccess', _127 => _127.tags]),
5462
+ scorers: _optionalChain([testConfig, 'optionalAccess', _128 => _128.scorers]),
3956
5463
  fn: async () => {
3957
5464
  if (testConfig && maybeFn) {
3958
5465
  const params = {
@@ -4019,10 +5526,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
4019
5526
  const getOrCreateContext = () => {
4020
5527
  if (!context) {
4021
5528
  const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
4022
- const experiment = config.projectId ? _chunkPOCCIJALjs.initExperiment.call(void 0, {
5529
+ const experiment = config.projectId ? _chunkMWVVR5LRjs.initExperiment.call(void 0, {
4023
5530
  projectId: config.projectId,
4024
5531
  experiment: experimentName
4025
- }) : _chunkPOCCIJALjs.initExperiment.call(void 0, config.projectName || suiteName, {
5532
+ }) : _chunkMWVVR5LRjs.initExperiment.call(void 0, config.projectName || suiteName, {
4026
5533
  experiment: experimentName
4027
5534
  });
4028
5535
  context = contextManager.createChildContext(void 0, experiment);
@@ -4067,8 +5574,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
4067
5574
  config.onProgress({
4068
5575
  type: "suite_complete",
4069
5576
  suiteName,
4070
- passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _86 => _86.passed]), () => ( 0)),
4071
- failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _87 => _87.failed]), () => ( 0))
5577
+ passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _129 => _129.passed]), () => ( 0)),
5578
+ failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _130 => _130.failed]), () => ( 0))
4072
5579
  });
4073
5580
  }
4074
5581
  });
@@ -4130,7 +5637,7 @@ function wrapExpect(originalExpect) {
4130
5637
  return originalExpect(value);
4131
5638
  }
4132
5639
  const assertion = originalExpect(value, message);
4133
- const span = _chunkPOCCIJALjs.currentSpan.call(void 0, );
5640
+ const span = _chunkMWVVR5LRjs.currentSpan.call(void 0, );
4134
5641
  if (!span) {
4135
5642
  return assertion;
4136
5643
  }
@@ -4142,16 +5649,16 @@ function wrapExpect(originalExpect) {
4142
5649
 
4143
5650
  // src/wrappers/shared/logging.ts
4144
5651
  function logOutputs(outputs) {
4145
- _chunkPOCCIJALjs.currentSpan.call(void 0, ).log({ output: outputs });
5652
+ _chunkMWVVR5LRjs.currentSpan.call(void 0, ).log({ output: outputs });
4146
5653
  }
4147
5654
  function logFeedback(feedback) {
4148
- _chunkPOCCIJALjs.currentSpan.call(void 0, ).log({
5655
+ _chunkMWVVR5LRjs.currentSpan.call(void 0, ).log({
4149
5656
  scores: { [feedback.name]: feedback.score },
4150
5657
  metadata: feedback.metadata
4151
5658
  });
4152
5659
  }
4153
5660
  function getCurrentSpan() {
4154
- return _chunkPOCCIJALjs.currentSpan.call(void 0, );
5661
+ return _chunkMWVVR5LRjs.currentSpan.call(void 0, );
4155
5662
  }
4156
5663
 
4157
5664
  // src/wrappers/vitest/index.ts
@@ -4199,8 +5706,8 @@ function wrapVitest(vitestMethods, config = {}) {
4199
5706
  );
4200
5707
  return;
4201
5708
  }
4202
- await _chunkPOCCIJALjs.summarizeAndFlush.call(void 0, ctx.experiment, {
4203
- displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _88 => _88.displaySummary]), () => ( config.displaySummary))
5709
+ await _chunkMWVVR5LRjs.summarizeAndFlush.call(void 0, ctx.experiment, {
5710
+ displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _131 => _131.displaySummary]), () => ( config.displaySummary))
4204
5711
  });
4205
5712
  }
4206
5713
  };
@@ -4214,7 +5721,7 @@ function initNodeTestSuite(config) {
4214
5721
  return experiment;
4215
5722
  }
4216
5723
  const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
4217
- experiment = _chunkPOCCIJALjs.initExperiment.call(void 0, config.projectName, {
5724
+ experiment = _chunkMWVVR5LRjs.initExperiment.call(void 0, config.projectName, {
4218
5725
  experiment: experimentName
4219
5726
  });
4220
5727
  return experiment;
@@ -4263,7 +5770,7 @@ function initNodeTestSuite(config) {
4263
5770
  if (!experiment) {
4264
5771
  return;
4265
5772
  }
4266
- await _chunkPOCCIJALjs.summarizeAndFlush.call(void 0, experiment, {
5773
+ await _chunkMWVVR5LRjs.summarizeAndFlush.call(void 0, experiment, {
4267
5774
  displaySummary: config.displaySummary
4268
5775
  });
4269
5776
  experiment = void 0;
@@ -4280,7 +5787,7 @@ function initNodeTestSuite(config) {
4280
5787
 
4281
5788
  // src/graph-framework.ts
4282
5789
  var graph_framework_exports = {};
4283
- _chunkLPC4W2WXjs.__export.call(void 0, graph_framework_exports, {
5790
+ _chunkBFGIH2ZJjs.__export.call(void 0, graph_framework_exports, {
4284
5791
  AggregatorNode: () => AggregatorNode,
4285
5792
  GateNode: () => GateNode,
4286
5793
  GraphBuilder: () => GraphBuilder,
@@ -4294,15 +5801,15 @@ _chunkLPC4W2WXjs.__export.call(void 0, graph_framework_exports, {
4294
5801
  escapePath: () => escapePath,
4295
5802
  unescapePath: () => unescapePath
4296
5803
  });
4297
- var GraphBuilder = (_class2 = class {
4298
- __init2() {this.nodes = /* @__PURE__ */ new Map()}
4299
- __init3() {this.edges = {}}
4300
- __init4() {this.nodeLikeNodes = /* @__PURE__ */ new Map()}
5804
+ var GraphBuilder = (_class3 = class {
5805
+ __init7() {this.nodes = /* @__PURE__ */ new Map()}
5806
+ __init8() {this.edges = {}}
5807
+ __init9() {this.nodeLikeNodes = /* @__PURE__ */ new Map()}
4301
5808
  // Maps node-like objects, like prompts, to their nodes
4302
5809
  // Special nodes
4303
5810
 
4304
5811
 
4305
- constructor() {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);
5812
+ constructor() {;_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);
4306
5813
  this.IN = this.createInputNode();
4307
5814
  this.OUT = this.createOutputNode();
4308
5815
  }
@@ -4354,7 +5861,7 @@ var GraphBuilder = (_class2 = class {
4354
5861
  };
4355
5862
  }
4356
5863
  resolveNode(node) {
4357
- if (node instanceof _chunkPOCCIJALjs.Prompt) {
5864
+ if (node instanceof _chunkMWVVR5LRjs.Prompt) {
4358
5865
  const cached = this.nodeLikeNodes.get(node);
4359
5866
  if (cached) {
4360
5867
  return [cached, []];
@@ -4404,7 +5911,7 @@ var GraphBuilder = (_class2 = class {
4404
5911
  // }
4405
5912
  // Helper to generate node IDs
4406
5913
  generateId(name) {
4407
- const uuid = _chunkPOCCIJALjs.newId.call(void 0, );
5914
+ const uuid = _chunkMWVVR5LRjs.newId.call(void 0, );
4408
5915
  if (name) {
4409
5916
  return `${name}-${uuid.slice(0, 8)}`;
4410
5917
  } else {
@@ -4432,7 +5939,7 @@ var GraphBuilder = (_class2 = class {
4432
5939
  this.nodes.set(id, promptNode);
4433
5940
  return promptNode;
4434
5941
  }
4435
- }, _class2);
5942
+ }, _class3);
4436
5943
  function isProxyVariable(node) {
4437
5944
  return typeof node === "object" && node !== null && "__type" in node && // @ts-ignore
4438
5945
  node.__type === "proxy-variable";
@@ -4440,17 +5947,17 @@ function isProxyVariable(node) {
4440
5947
  function proxyVariableToNode(proxy) {
4441
5948
  return [proxy.__node, proxy.__path];
4442
5949
  }
4443
- var BaseNode = (_class3 = class {
4444
- constructor(graph, id) {;_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);
5950
+ var BaseNode = (_class4 = class {
5951
+ constructor(graph, id) {;_class4.prototype.__init10.call(this);_class4.prototype.__init11.call(this);
4445
5952
  this.graph = graph;
4446
5953
  this.id = id;
4447
5954
  }
4448
- __init5() {this.__type = "node"}
4449
- __init6() {this.dependencies = []}
5955
+ __init10() {this.__type = "node"}
5956
+ __init11() {this.dependencies = []}
4450
5957
  addDependency(dependency) {
4451
5958
  this.dependencies.push(dependency);
4452
5959
  }
4453
- }, _class3);
5960
+ }, _class4);
4454
5961
  var InputNode = class extends BaseNode {
4455
5962
  constructor(graph, id) {
4456
5963
  super(graph, id);
@@ -5598,16 +7105,22 @@ function waterfall(tasks, callback) {
5598
7105
  var waterfall$1 = awaitify(waterfall);
5599
7106
 
5600
7107
  // src/trace.ts
5601
- var SpanFetcher = class _SpanFetcher extends _chunkPOCCIJALjs.ObjectFetcher {
5602
- constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false) {
7108
+ var SpanFetcher = class _SpanFetcher extends _chunkMWVVR5LRjs.ObjectFetcher {
7109
+ constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
5603
7110
  const filterExpr = _SpanFetcher.buildFilter(
5604
7111
  rootSpanId,
5605
7112
  spanTypeFilter,
5606
7113
  includeScorers
5607
7114
  );
5608
- super(objectType, void 0, void 0, {
5609
- filter: filterExpr
5610
- });
7115
+ super(
7116
+ objectType,
7117
+ void 0,
7118
+ void 0,
7119
+ {
7120
+ filter: filterExpr
7121
+ },
7122
+ brainstoreRealtime
7123
+ );
5611
7124
  this._objectId = _objectId;
5612
7125
  this.rootSpanId = rootSpanId;
5613
7126
  this._state = _state;
@@ -5657,11 +7170,11 @@ var SpanFetcher = class _SpanFetcher extends _chunkPOCCIJALjs.ObjectFetcher {
5657
7170
  return this._state;
5658
7171
  }
5659
7172
  };
5660
- var CachedSpanFetcher = (_class4 = class {
5661
- __init7() {this.spanCache = /* @__PURE__ */ new Map()}
5662
- __init8() {this.allFetched = false}
7173
+ var CachedSpanFetcher = (_class5 = class {
7174
+ __init12() {this.spanCache = /* @__PURE__ */ new Map()}
7175
+ __init13() {this.allFetched = false}
5663
7176
 
5664
- constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState) {;_class4.prototype.__init7.call(this);_class4.prototype.__init8.call(this);
7177
+ constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);
5665
7178
  if (typeof objectTypeOrFetchFn === "function") {
5666
7179
  this.fetchFn = (spanType) => objectTypeOrFetchFn(spanType);
5667
7180
  } else {
@@ -5674,7 +7187,8 @@ var CachedSpanFetcher = (_class4 = class {
5674
7187
  rootSpanId,
5675
7188
  state,
5676
7189
  spanType,
5677
- includeScorers
7190
+ includeScorers,
7191
+ brainstoreRealtime
5678
7192
  );
5679
7193
  const rows = await fetcher.fetchedData();
5680
7194
  return rows.map((row) => ({
@@ -5724,7 +7238,7 @@ var CachedSpanFetcher = (_class4 = class {
5724
7238
  async fetchSpans(spanType) {
5725
7239
  const spans = await this.fetchFn(spanType, false);
5726
7240
  for (const span of spans) {
5727
- const type = _nullishCoalesce(_optionalChain([span, 'access', _89 => _89.span_attributes, 'optionalAccess', _90 => _90.type]), () => ( ""));
7241
+ const type = _nullishCoalesce(_optionalChain([span, 'access', _132 => _132.span_attributes, 'optionalAccess', _133 => _133.type]), () => ( ""));
5728
7242
  const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
5729
7243
  existing.push(span);
5730
7244
  this.spanCache.set(type, existing);
@@ -5741,24 +7255,24 @@ var CachedSpanFetcher = (_class4 = class {
5741
7255
  }
5742
7256
  return result;
5743
7257
  }
5744
- }, _class4);
5745
- var LocalTrace = (_class5 = class {
7258
+ }, _class5);
7259
+ var LocalTrace = (_class6 = class {
5746
7260
 
5747
7261
 
5748
7262
 
5749
7263
 
5750
7264
 
5751
- __init9() {this.spansFlushed = false}
5752
- __init10() {this.spansFlushPromise = null}
7265
+ __init14() {this.spansFlushed = false}
7266
+ __init15() {this.spansFlushPromise = null}
5753
7267
 
5754
- __init11() {this.threadCache = /* @__PURE__ */ new Map()}
7268
+ __init16() {this.threadCache = /* @__PURE__ */ new Map()}
5755
7269
  constructor({
5756
7270
  objectType,
5757
7271
  objectId,
5758
7272
  rootSpanId,
5759
7273
  ensureSpansFlushed,
5760
7274
  state
5761
- }) {;_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);
7275
+ }) {;_class6.prototype.__init14.call(this);_class6.prototype.__init15.call(this);_class6.prototype.__init16.call(this);
5762
7276
  this.objectType = objectType;
5763
7277
  this.objectId = objectId;
5764
7278
  this.rootSpanId = rootSpanId;
@@ -5807,11 +7321,11 @@ var LocalTrace = (_class5 = class {
5807
7321
  const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
5808
7322
  if (cachedSpans && cachedSpans.length > 0) {
5809
7323
  let spans = includeScorers ? cachedSpans : cachedSpans.filter(
5810
- (span) => _optionalChain([span, 'access', _91 => _91.span_attributes, 'optionalAccess', _92 => _92.purpose]) !== "scorer"
7324
+ (span) => _optionalChain([span, 'access', _134 => _134.span_attributes, 'optionalAccess', _135 => _135.purpose]) !== "scorer"
5811
7325
  );
5812
7326
  if (spanType && spanType.length > 0) {
5813
7327
  spans = spans.filter(
5814
- (span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _93 => _93.span_attributes, 'optionalAccess', _94 => _94.type]), () => ( "")))
7328
+ (span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _136 => _136.span_attributes, 'optionalAccess', _137 => _137.type]), () => ( "")))
5815
7329
  );
5816
7330
  }
5817
7331
  return spans.map((span) => ({
@@ -5836,7 +7350,7 @@ var LocalTrace = (_class5 = class {
5836
7350
  * Calls the API with the project_default preprocessor (which falls back to "thread").
5837
7351
  */
5838
7352
  async getThread(options) {
5839
- const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _95 => _95.preprocessor]), () => ( "project_default"));
7353
+ const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _138 => _138.preprocessor]), () => ( "project_default"));
5840
7354
  if (!this.threadCache.has(cacheKey)) {
5841
7355
  const promise = this.fetchThread(options);
5842
7356
  this.threadCache.set(cacheKey, promise);
@@ -5847,7 +7361,7 @@ var LocalTrace = (_class5 = class {
5847
7361
  await this.ensureSpansReady();
5848
7362
  await this.state.login({});
5849
7363
  const result = await invoke({
5850
- globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _96 => _96.preprocessor]), () => ( "project_default")),
7364
+ globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _139 => _139.preprocessor]), () => ( "project_default")),
5851
7365
  functionType: "preprocessor",
5852
7366
  input: {
5853
7367
  trace_ref: {
@@ -5878,7 +7392,7 @@ var LocalTrace = (_class5 = class {
5878
7392
  }
5879
7393
  await this.spansFlushPromise;
5880
7394
  }
5881
- }, _class5);
7395
+ }, _class6);
5882
7396
 
5883
7397
  // src/reporters/progress.ts
5884
7398
  var SimpleProgressReporter = class {
@@ -5904,20 +7418,20 @@ var promptContentsSchema = _v3.z.union([
5904
7418
  prompt: _v3.z.string()
5905
7419
  }),
5906
7420
  _v3.z.object({
5907
- messages: _v3.z.array(_chunkPOCCIJALjs.ChatCompletionMessageParam)
7421
+ messages: _v3.z.array(_chunkMWVVR5LRjs.ChatCompletionMessageParam)
5908
7422
  })
5909
7423
  ]);
5910
7424
  var promptDefinitionSchema = promptContentsSchema.and(
5911
7425
  _v3.z.object({
5912
7426
  model: _v3.z.string(),
5913
- params: _chunkPOCCIJALjs.ModelParams.optional(),
7427
+ params: _chunkMWVVR5LRjs.ModelParams.optional(),
5914
7428
  templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
5915
7429
  environments: _v3.z.array(_v3.z.string()).optional()
5916
7430
  })
5917
7431
  );
5918
7432
  var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
5919
7433
  _v3.z.object({
5920
- tools: _v3.z.array(_chunkPOCCIJALjs.ToolFunctionDefinition).optional()
7434
+ tools: _v3.z.array(_chunkMWVVR5LRjs.ToolFunctionDefinition).optional()
5921
7435
  })
5922
7436
  );
5923
7437
  function promptDefinitionToPromptData(promptDefinition, rawTools) {
@@ -5965,7 +7479,7 @@ async function validateParameters(parameters, parameterSchema) {
5965
7479
  if (resolvedSchema === void 0 || resolvedSchema === null) {
5966
7480
  return parameters;
5967
7481
  }
5968
- if (_chunkPOCCIJALjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
7482
+ if (_chunkMWVVR5LRjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
5969
7483
  const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
5970
7484
  ...resolvedSchema.data,
5971
7485
  ...parameters
@@ -5987,14 +7501,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
5987
7501
  const value = parameters[name];
5988
7502
  try {
5989
7503
  if ("type" in schema && schema.type === "prompt") {
5990
- const promptData = value ? _chunkPOCCIJALjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
7504
+ const promptData = value ? _chunkMWVVR5LRjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
5991
7505
  schema.default,
5992
7506
  schema.default.tools
5993
7507
  ) : void 0;
5994
7508
  if (!promptData) {
5995
7509
  throw new Error(`Parameter '${name}' is required`);
5996
7510
  }
5997
- return [name, _chunkPOCCIJALjs.Prompt.fromPromptData(name, promptData)];
7511
+ return [name, _chunkMWVVR5LRjs.Prompt.fromPromptData(name, promptData)];
5998
7512
  } else if ("type" in schema && schema.type === "model") {
5999
7513
  const model = _nullishCoalesce(value, () => ( schema.default));
6000
7514
  if (model === void 0) {
@@ -6023,10 +7537,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
6023
7537
  const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
6024
7538
  const validate = ajv.compile(schema);
6025
7539
  if (!validate(parameters)) {
6026
- const errorMessages = _optionalChain([validate, 'access', _97 => _97.errors, 'optionalAccess', _98 => _98.map, 'call', _99 => _99((err) => {
7540
+ const errorMessages = _optionalChain([validate, 'access', _140 => _140.errors, 'optionalAccess', _141 => _141.map, 'call', _142 => _142((err) => {
6027
7541
  const path = err.instancePath || "root";
6028
7542
  return `${path}: ${err.message}`;
6029
- }), 'access', _100 => _100.join, 'call', _101 => _101(", ")]);
7543
+ }), 'access', _143 => _143.join, 'call', _144 => _144(", ")]);
6030
7544
  throw Error(`Invalid parameters: ${errorMessages}`);
6031
7545
  }
6032
7546
  return rehydrateRemoteParameters(parameters, schema);
@@ -6045,7 +7559,7 @@ function rehydrateRemoteParameters(parameters, schema) {
6045
7559
  if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
6046
7560
  return [
6047
7561
  name,
6048
- _chunkPOCCIJALjs.Prompt.fromPromptData(name, _chunkPOCCIJALjs.PromptData.parse(value))
7562
+ _chunkMWVVR5LRjs.Prompt.fromPromptData(name, _chunkMWVVR5LRjs.PromptData.parse(value))
6049
7563
  ];
6050
7564
  }
6051
7565
  return [name, value];
@@ -6081,7 +7595,7 @@ var EvalResultWithSummary = class {
6081
7595
  async function getPersistedBaseExperimentId(experiment) {
6082
7596
  try {
6083
7597
  return await experiment._getBaseExperimentId();
6084
- } catch (e5) {
7598
+ } catch (e7) {
6085
7599
  return void 0;
6086
7600
  }
6087
7601
  }
@@ -6093,7 +7607,7 @@ function makeEvalName(projectName, experimentName) {
6093
7607
  return out;
6094
7608
  }
6095
7609
  function initExperiment2(state, options = {}) {
6096
- return _chunkPOCCIJALjs.init.call(void 0, {
7610
+ return _chunkMWVVR5LRjs.init.call(void 0, {
6097
7611
  state,
6098
7612
  ...options,
6099
7613
  setCurrent: false
@@ -6104,7 +7618,7 @@ async function getExperimentParametersRef(parameters) {
6104
7618
  return void 0;
6105
7619
  }
6106
7620
  const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
6107
- if (!_chunkPOCCIJALjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
7621
+ if (!_chunkMWVVR5LRjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
6108
7622
  return void 0;
6109
7623
  }
6110
7624
  if (resolvedParameters.id === void 0) {
@@ -6140,10 +7654,10 @@ globalThis._evals = {
6140
7654
  reporters: {}
6141
7655
  };
6142
7656
  function _initializeSpanContext() {
6143
- globalThis._spanContext = { currentSpan: _chunkPOCCIJALjs.currentSpan, withCurrent: _chunkPOCCIJALjs.withCurrent, startSpan: _chunkPOCCIJALjs.startSpan, NOOP_SPAN: _chunkPOCCIJALjs.NOOP_SPAN };
7657
+ globalThis._spanContext = { currentSpan: _chunkMWVVR5LRjs.currentSpan, withCurrent: _chunkMWVVR5LRjs.withCurrent, startSpan: _chunkMWVVR5LRjs.startSpan, NOOP_SPAN: _chunkMWVVR5LRjs.NOOP_SPAN };
6144
7658
  }
6145
7659
  async function Eval(name, evaluator, reporterOrOpts) {
6146
- const options = _chunkPOCCIJALjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
7660
+ const options = _chunkMWVVR5LRjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
6147
7661
  let evalName = makeEvalName(name, evaluator.experimentName);
6148
7662
  if (globalThis._evals.evaluators[evalName]) {
6149
7663
  evalName = `${evalName}_${Object.keys(_evals).length}`;
@@ -6194,7 +7708,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
6194
7708
  baseExperimentId: evaluator.baseExperimentId,
6195
7709
  gitMetadataSettings: evaluator.gitMetadataSettings,
6196
7710
  repoInfo: evaluator.repoInfo,
6197
- dataset: _chunkPOCCIJALjs.Dataset.isDataset(data) ? data : void 0,
7711
+ dataset: _chunkMWVVR5LRjs.Dataset.isDataset(data) ? data : void 0,
6198
7712
  parameters
6199
7713
  });
6200
7714
  if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
@@ -6214,7 +7728,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
6214
7728
  const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
6215
7729
  let ret;
6216
7730
  if (options.parent) {
6217
- ret = await _chunkPOCCIJALjs.withParent.call(void 0,
7731
+ ret = await _chunkMWVVR5LRjs.withParent.call(void 0,
6218
7732
  options.parent,
6219
7733
  () => runEvaluator(
6220
7734
  null,
@@ -6250,7 +7764,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
6250
7764
  if (experiment) {
6251
7765
  await experiment.flush().catch(console.error);
6252
7766
  } else if (options.parent) {
6253
- await _chunkPOCCIJALjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
7767
+ await _chunkMWVVR5LRjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
6254
7768
  }
6255
7769
  }
6256
7770
  } finally {
@@ -6296,13 +7810,13 @@ function classifierName(classifier, classifier_idx) {
6296
7810
  }
6297
7811
  function buildSpanMetadata(results) {
6298
7812
  return results.length === 1 ? results[0].metadata : results.reduce(
6299
- (prev, s) => _chunkPOCCIJALjs.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
7813
+ (prev, s) => _chunkMWVVR5LRjs.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
6300
7814
  {}
6301
7815
  );
6302
7816
  }
6303
7817
  function buildSpanScores(results) {
6304
7818
  const scoresRecord = results.reduce(
6305
- (prev, s) => _chunkPOCCIJALjs.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
7819
+ (prev, s) => _chunkMWVVR5LRjs.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
6306
7820
  {}
6307
7821
  );
6308
7822
  return { resultMetadata: buildSpanMetadata(results), scoresRecord };
@@ -6332,7 +7846,7 @@ function collectScoringResults(runResults, names, onResult) {
6332
7846
  return failing;
6333
7847
  }
6334
7848
  function validateClassificationResult(value, scorerName2) {
6335
- if (!(typeof value === "object" && value !== null && !_chunkPOCCIJALjs.isEmpty.call(void 0, value))) {
7849
+ if (!(typeof value === "object" && value !== null && !_chunkMWVVR5LRjs.isEmpty.call(void 0, value))) {
6336
7850
  throw new Error(
6337
7851
  `When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
6338
7852
  );
@@ -6361,7 +7875,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
6361
7875
  );
6362
7876
  metadata[`${kind}_errors`] = errorMap;
6363
7877
  rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
6364
- _chunkPOCCIJALjs.debugLogger.forState(state).warn(
7878
+ _chunkMWVVR5LRjs.debugLogger.forState(state).warn(
6365
7879
  `Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
6366
7880
  failures.map((f) => f.error)
6367
7881
  );
@@ -6395,7 +7909,7 @@ var defaultErrorScoreHandler = ({
6395
7909
  };
6396
7910
  async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
6397
7911
  if (enableCache) {
6398
- _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _102 => _102.spanCache, 'optionalAccess', _103 => _103.start, 'call', _104 => _104()]);
7912
+ _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _145 => _145.spanCache, 'optionalAccess', _146 => _146.start, 'call', _147 => _147()]);
6399
7913
  }
6400
7914
  try {
6401
7915
  if (typeof evaluator.data === "string") {
@@ -6416,7 +7930,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6416
7930
  );
6417
7931
  }
6418
7932
  let name = dataResult.name;
6419
- if (_chunkPOCCIJALjs.isEmpty.call(void 0, name)) {
7933
+ if (_chunkMWVVR5LRjs.isEmpty.call(void 0, name)) {
6420
7934
  const baseExperiment = await experiment.fetchBaseExperiment();
6421
7935
  if (!baseExperiment) {
6422
7936
  throw new Error("BaseExperiment() failed to fetch base experiment");
@@ -6450,7 +7964,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6450
7964
  const experimentIdPromise = experiment ? (async () => {
6451
7965
  try {
6452
7966
  return await experiment.id;
6453
- } catch (e6) {
7967
+ } catch (e8) {
6454
7968
  return void 0;
6455
7969
  }
6456
7970
  })() : void 0;
@@ -6466,7 +7980,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6466
7980
  if (cancelled) {
6467
7981
  return;
6468
7982
  }
6469
- const eventDataset = experiment ? experiment.dataset : _chunkPOCCIJALjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
7983
+ const eventDataset = experiment ? experiment.dataset : _chunkMWVVR5LRjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
6470
7984
  const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
6471
7985
  object_type: "dataset",
6472
7986
  object_id: await eventDataset.id,
@@ -6474,8 +7988,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6474
7988
  created: datum.created,
6475
7989
  _xact_id: datum._xact_id
6476
7990
  } : void 0;
6477
- const parsedDatumOrigin = _chunkPOCCIJALjs.ObjectReference.safeParse(datum.origin);
6478
- const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _105 => _105.success]) ? parsedDatumOrigin.data : void 0)));
7991
+ const parsedDatumOrigin = _chunkMWVVR5LRjs.ObjectReference.safeParse(datum.origin);
7992
+ const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _148 => _148.success]) ? parsedDatumOrigin.data : void 0)));
6479
7993
  const baseEvent = {
6480
7994
  name: "eval",
6481
7995
  spanAttributes: {
@@ -6490,26 +8004,26 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6490
8004
  }
6491
8005
  };
6492
8006
  const callback = async (rootSpan) => {
6493
- const state = _nullishCoalesce(evaluator.state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )));
8007
+ const state = _nullishCoalesce(evaluator.state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )));
6494
8008
  const ensureSpansFlushed = async () => {
6495
8009
  if (experiment) {
6496
- await _chunkPOCCIJALjs.flush.call(void 0, { state: experiment.loggingState });
8010
+ await _chunkMWVVR5LRjs.flush.call(void 0, { state: experiment.loggingState });
6497
8011
  } else if (state) {
6498
- await _chunkPOCCIJALjs.flush.call(void 0, { state });
8012
+ await _chunkMWVVR5LRjs.flush.call(void 0, { state });
6499
8013
  } else {
6500
- await _chunkPOCCIJALjs.flush.call(void 0, );
8014
+ await _chunkMWVVR5LRjs.flush.call(void 0, );
6501
8015
  }
6502
8016
  if (state) {
6503
8017
  await state.flushOtel();
6504
8018
  }
6505
8019
  };
6506
8020
  const parentStr = state.currentParent.getStore();
6507
- const parentComponents = parentStr ? _chunkPOCCIJALjs.SpanComponentsV3.fromStr(parentStr) : null;
8021
+ const parentComponents = typeof parentStr === "string" ? _chunkMWVVR5LRjs.SpanComponentsV4.fromStr(parentStr) : null;
6508
8022
  const trace = state ? new LocalTrace({
6509
- objectType: parentComponents ? _chunkPOCCIJALjs.spanObjectTypeV3ToTypedString.call(void 0,
8023
+ objectType: parentComponents ? _chunkMWVVR5LRjs.spanObjectTypeV3ToTypedString.call(void 0,
6510
8024
  parentComponents.data.object_type
6511
8025
  ) : "experiment",
6512
- objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _106 => _106.data, 'access', async _107 => _107.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
8026
+ objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _149 => _149.data, 'access', async _150 => _150.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
6513
8027
  rootSpanId: rootSpan.rootSpanId,
6514
8028
  ensureSpansFlushed,
6515
8029
  state
@@ -6539,10 +8053,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6539
8053
  span,
6540
8054
  parameters: _nullishCoalesce(parameters, () => ( {})),
6541
8055
  reportProgress: (event) => {
6542
- _optionalChain([stream, 'optionalCall', _108 => _108({
8056
+ _optionalChain([stream, 'optionalCall', _151 => _151({
6543
8057
  ...event,
6544
8058
  id: rootSpan.id,
6545
- origin: _optionalChain([baseEvent, 'access', _109 => _109.event, 'optionalAccess', _110 => _110.origin]),
8059
+ origin: _optionalChain([baseEvent, 'access', _152 => _152.event, 'optionalAccess', _153 => _153.origin]),
6546
8060
  name: evaluator.evalName,
6547
8061
  object_type: "task"
6548
8062
  })]);
@@ -6581,7 +8095,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6581
8095
  trace
6582
8096
  };
6583
8097
  const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
6584
- const propagatedEvent = _chunkPOCCIJALjs.makeScorerPropagatedEvent.call(void 0,
8098
+ const propagatedEvent = _chunkMWVVR5LRjs.makeScorerPropagatedEvent.call(void 0,
6585
8099
  await rootSpan.export()
6586
8100
  );
6587
8101
  const getOtherFields = (s) => {
@@ -6604,14 +8118,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6604
8118
  if (scoreValue === null) return null;
6605
8119
  if (Array.isArray(scoreValue)) {
6606
8120
  for (const s of scoreValue) {
6607
- if (!(typeof s === "object" && !_chunkPOCCIJALjs.isEmpty.call(void 0, s))) {
8121
+ if (!(typeof s === "object" && !_chunkMWVVR5LRjs.isEmpty.call(void 0, s))) {
6608
8122
  throw new Error(
6609
8123
  `When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
6610
8124
  );
6611
8125
  }
6612
8126
  }
6613
8127
  }
6614
- const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkPOCCIJALjs.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
8128
+ const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkMWVVR5LRjs.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
6615
8129
  {
6616
8130
  name: scorerNames[score_idx],
6617
8131
  score: scoreValue
@@ -6619,7 +8133,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6619
8133
  ];
6620
8134
  const { resultMetadata, scoresRecord } = buildSpanScores(results);
6621
8135
  const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
6622
- (prev, s) => _chunkPOCCIJALjs.mergeDicts.call(void 0, prev, {
8136
+ (prev, s) => _chunkMWVVR5LRjs.mergeDicts.call(void 0, prev, {
6623
8137
  [s.name]: getOtherFields(s)
6624
8138
  }),
6625
8139
  {}
@@ -6654,7 +8168,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6654
8168
  )
6655
8169
  );
6656
8170
  const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
6657
- (prev, r) => _chunkPOCCIJALjs.mergeDicts.call(void 0, prev, {
8171
+ (prev, r) => _chunkMWVVR5LRjs.mergeDicts.call(void 0, prev, {
6658
8172
  [r.name]: toClassificationItem(r)
6659
8173
  }),
6660
8174
  {}
@@ -6706,7 +8220,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6706
8220
  evaluator.state
6707
8221
  );
6708
8222
  } catch (e) {
6709
- _chunkPOCCIJALjs.logError.call(void 0, rootSpan, e);
8223
+ _chunkMWVVR5LRjs.logError.call(void 0, rootSpan, e);
6710
8224
  error = e;
6711
8225
  } finally {
6712
8226
  progressReporter.increment(evaluator.evalName);
@@ -6730,7 +8244,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6730
8244
  tags: tags.length ? tags : void 0,
6731
8245
  metadata,
6732
8246
  error,
6733
- origin: _optionalChain([baseEvent, 'access', _111 => _111.event, 'optionalAccess', _112 => _112.origin])
8247
+ origin: _optionalChain([baseEvent, 'access', _154 => _154.event, 'optionalAccess', _155 => _155.origin])
6734
8248
  };
6735
8249
  collectedResults.push({
6736
8250
  ...baseResult,
@@ -6740,7 +8254,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6740
8254
  }
6741
8255
  };
6742
8256
  if (!experiment) {
6743
- return await _chunkPOCCIJALjs.traced.call(void 0, callback, {
8257
+ return await _chunkMWVVR5LRjs.traced.call(void 0, callback, {
6744
8258
  ...baseEvent,
6745
8259
  state: evaluator.state
6746
8260
  });
@@ -6770,7 +8284,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6770
8284
  break;
6771
8285
  }
6772
8286
  scheduledTrials++;
6773
- _optionalChain([progressReporter, 'access', _113 => _113.setTotal, 'optionalCall', _114 => _114(evaluator.evalName, scheduledTrials)]);
8287
+ _optionalChain([progressReporter, 'access', _156 => _156.setTotal, 'optionalCall', _157 => _157(evaluator.evalName, scheduledTrials)]);
6774
8288
  q.pushAsync({ datum, trialIndex }).catch((e) => {
6775
8289
  if (queueErrors.length < 5) {
6776
8290
  queueErrors.push(e);
@@ -6782,7 +8296,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6782
8296
  const cancel = async () => {
6783
8297
  await new Promise((_, reject2) => {
6784
8298
  if (cancelled) {
6785
- reject2(new (0, _chunkPOCCIJALjs.InternalAbortError)("Evaluator already cancelled"));
8299
+ reject2(new (0, _chunkMWVVR5LRjs.InternalAbortError)("Evaluator already cancelled"));
6786
8300
  return;
6787
8301
  }
6788
8302
  let timeoutId;
@@ -6803,12 +8317,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6803
8317
  };
6804
8318
  if (evaluator.timeout) {
6805
8319
  timeoutId = setTimeout(() => {
6806
- rejectOnce(new (0, _chunkPOCCIJALjs.InternalAbortError)("Evaluator timed out"));
8320
+ rejectOnce(new (0, _chunkMWVVR5LRjs.InternalAbortError)("Evaluator timed out"));
6807
8321
  }, evaluator.timeout);
6808
8322
  }
6809
8323
  if (evaluator.signal) {
6810
8324
  abortHandler = () => {
6811
- rejectOnce(new (0, _chunkPOCCIJALjs.InternalAbortError)("Evaluator aborted"));
8325
+ rejectOnce(new (0, _chunkMWVVR5LRjs.InternalAbortError)("Evaluator aborted"));
6812
8326
  };
6813
8327
  evaluator.signal.addEventListener("abort", abortHandler);
6814
8328
  }
@@ -6831,9 +8345,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6831
8345
  }
6832
8346
  } catch (e) {
6833
8347
  q.kill();
6834
- if (e instanceof _chunkPOCCIJALjs.InternalAbortError) {
6835
- if (_chunkLPC4W2WXjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
6836
- _chunkPOCCIJALjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
8348
+ if (e instanceof _chunkMWVVR5LRjs.InternalAbortError) {
8349
+ if (_chunkBFGIH2ZJjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
8350
+ _chunkMWVVR5LRjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
6837
8351
  }
6838
8352
  }
6839
8353
  throw e;
@@ -6857,9 +8371,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6857
8371
  );
6858
8372
  } finally {
6859
8373
  if (enableCache) {
6860
- const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _115 => _115.spanCache]);
6861
- _optionalChain([spanCache, 'optionalAccess', _116 => _116.dispose, 'call', _117 => _117()]);
6862
- _optionalChain([spanCache, 'optionalAccess', _118 => _118.stop, 'call', _119 => _119()]);
8374
+ const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _158 => _158.spanCache]);
8375
+ _optionalChain([spanCache, 'optionalAccess', _159 => _159.dispose, 'call', _160 => _160()]);
8376
+ _optionalChain([spanCache, 'optionalAccess', _161 => _161.stop, 'call', _162 => _162()]);
6863
8377
  }
6864
8378
  }
6865
8379
  }
@@ -6952,25 +8466,25 @@ var defaultReporter = {
6952
8466
  reportFailures(evaluator, failingResults, { verbose, jsonl });
6953
8467
  }
6954
8468
  if (jsonl) {
6955
- _chunkLPC4W2WXjs.isomorph_default.writeln(JSON.stringify(summary));
8469
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(JSON.stringify(summary));
6956
8470
  } else {
6957
- _chunkLPC4W2WXjs.isomorph_default.writeln("Experiment summary");
6958
- _chunkLPC4W2WXjs.isomorph_default.writeln("==================");
8471
+ _chunkBFGIH2ZJjs.isomorph_default.writeln("Experiment summary");
8472
+ _chunkBFGIH2ZJjs.isomorph_default.writeln("==================");
6959
8473
  if (summary.comparisonExperimentName) {
6960
- _chunkLPC4W2WXjs.isomorph_default.writeln(
8474
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(
6961
8475
  `${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
6962
8476
  );
6963
- _chunkLPC4W2WXjs.isomorph_default.writeln("");
8477
+ _chunkBFGIH2ZJjs.isomorph_default.writeln("");
6964
8478
  }
6965
8479
  const hasScores = Object.keys(summary.scores).length > 0;
6966
8480
  const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
6967
8481
  const hasComparison = !!summary.comparisonExperimentName;
6968
8482
  if (hasScores || hasMetrics) {
6969
8483
  if (hasComparison) {
6970
- _chunkLPC4W2WXjs.isomorph_default.writeln(
8484
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(
6971
8485
  "Name Value Change Improvements Regressions"
6972
8486
  );
6973
- _chunkLPC4W2WXjs.isomorph_default.writeln(
8487
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(
6974
8488
  "----------------------------------------------------------------"
6975
8489
  );
6976
8490
  }
@@ -6979,18 +8493,18 @@ var defaultReporter = {
6979
8493
  const scoreValue = `${scorePercent}%`;
6980
8494
  if (hasComparison) {
6981
8495
  let diffString = "-";
6982
- if (!_chunkPOCCIJALjs.isEmpty.call(void 0, score.diff)) {
8496
+ if (!_chunkMWVVR5LRjs.isEmpty.call(void 0, score.diff)) {
6983
8497
  const diffPercent = (score.diff * 100).toFixed(2);
6984
8498
  const diffSign = score.diff > 0 ? "+" : "";
6985
8499
  diffString = `${diffSign}${diffPercent}%`;
6986
8500
  }
6987
8501
  const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
6988
8502
  const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
6989
- _chunkLPC4W2WXjs.isomorph_default.writeln(
8503
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(
6990
8504
  `${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
6991
8505
  );
6992
8506
  } else {
6993
- _chunkLPC4W2WXjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
8507
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
6994
8508
  }
6995
8509
  }
6996
8510
  for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
@@ -6999,30 +8513,30 @@ var defaultReporter = {
6999
8513
  const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
7000
8514
  if (hasComparison) {
7001
8515
  let diffString = "-";
7002
- if (!_chunkPOCCIJALjs.isEmpty.call(void 0, metric.diff)) {
8516
+ if (!_chunkMWVVR5LRjs.isEmpty.call(void 0, metric.diff)) {
7003
8517
  const diffPercent = (metric.diff * 100).toFixed(2);
7004
8518
  const diffSign = metric.diff > 0 ? "+" : "";
7005
8519
  diffString = `${diffSign}${diffPercent}%`;
7006
8520
  }
7007
8521
  const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
7008
8522
  const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
7009
- _chunkLPC4W2WXjs.isomorph_default.writeln(
8523
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(
7010
8524
  `${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
7011
8525
  );
7012
8526
  } else {
7013
- _chunkLPC4W2WXjs.isomorph_default.writeln(
8527
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(
7014
8528
  `${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
7015
8529
  );
7016
8530
  }
7017
8531
  }
7018
8532
  }
7019
8533
  if (summary.experimentUrl) {
7020
- _chunkLPC4W2WXjs.isomorph_default.writeln("");
7021
- _chunkLPC4W2WXjs.isomorph_default.writeln(`View results for ${summary.experimentName}`);
7022
- _chunkLPC4W2WXjs.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
8534
+ _chunkBFGIH2ZJjs.isomorph_default.writeln("");
8535
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(`View results for ${summary.experimentName}`);
8536
+ _chunkBFGIH2ZJjs.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
7023
8537
  }
7024
8538
  }
7025
- _chunkLPC4W2WXjs.isomorph_default.writeln("");
8539
+ _chunkBFGIH2ZJjs.isomorph_default.writeln("");
7026
8540
  return failingResults.length === 0;
7027
8541
  },
7028
8542
  async reportRun(evalReports) {
@@ -7030,6 +8544,350 @@ var defaultReporter = {
7030
8544
  }
7031
8545
  };
7032
8546
 
8547
+ // src/agent-assertions.ts
8548
+ function agentAssertionScorer(callback, options = {}) {
8549
+ return async (args) => {
8550
+ const { trace: _trace, ...callbackArgs } = args;
8551
+ const callbackMetadata = _nullishCoalesce(callbackArgs.metadata, () => ( {}));
8552
+ const assertions = await callback({
8553
+ ...callbackArgs,
8554
+ metadata: callbackMetadata,
8555
+ assert: agentAssertionHelpers
8556
+ });
8557
+ const resources = {};
8558
+ if (assertions.some((assertion) => assertion.requiresTrace)) {
8559
+ resources.spans = await _optionalChain([args, 'access', _163 => _163.trace, 'optionalAccess', _164 => _164.getSpans, 'call', _165 => _165({ spanType: ["tool"] })]);
8560
+ }
8561
+ const results = await Promise.all(
8562
+ assertions.map(async (assertion) => {
8563
+ const result = await assertion.evaluate(resources);
8564
+ return {
8565
+ name: assertion.name,
8566
+ passed: result.passed,
8567
+ failure: result.failure
8568
+ };
8569
+ })
8570
+ );
8571
+ const passed = results.filter((result) => result.passed).length;
8572
+ const total = results.length;
8573
+ const failed = results.filter((result) => !result.passed).map(
8574
+ (result) => `${result.name}: ${_nullishCoalesce(result.failure, () => ( "assertion did not pass"))}`
8575
+ );
8576
+ return {
8577
+ name: _nullishCoalesce(options.name, () => ( "assertions")),
8578
+ score: total === 0 ? 1 : passed / total,
8579
+ metadata: {
8580
+ assertions: results.map(({ name, passed: passed2 }) => ({ name, passed: passed2 })),
8581
+ failed
8582
+ }
8583
+ };
8584
+ };
8585
+ }
8586
+ var agentAssertionHelpers = {
8587
+ equals: (actual, expected, name = "equals") => ({
8588
+ name,
8589
+ evaluate: () => {
8590
+ const passed = deepEqual(actual, expected);
8591
+ return {
8592
+ passed,
8593
+ failure: passed ? void 0 : `expected ${formatValue(actual)} to equal ${formatValue(expected)}`
8594
+ };
8595
+ }
8596
+ }),
8597
+ notEquals: (actual, expected, name = "not equals") => ({
8598
+ name,
8599
+ evaluate: () => {
8600
+ const passed = !deepEqual(actual, expected);
8601
+ return {
8602
+ passed,
8603
+ failure: passed ? void 0 : `expected ${formatValue(actual)} not to equal ${formatValue(expected)}`
8604
+ };
8605
+ }
8606
+ }),
8607
+ contains: (value, expected, name = "contains") => ({
8608
+ name,
8609
+ evaluate: () => {
8610
+ const searchedValue = typeof value === "string" ? value : formatValue(value);
8611
+ const passed = expected instanceof RegExp ? testRegex(expected, value) : searchedValue.includes(expected);
8612
+ return {
8613
+ passed,
8614
+ failure: passed ? void 0 : `expected ${formatValue(value)} to contain ${formatValue(expected)}`
8615
+ };
8616
+ }
8617
+ }),
8618
+ matches: (value, schema, name = "matches schema") => ({
8619
+ name,
8620
+ evaluate: async () => {
8621
+ const result = await validateSchema(schema, value);
8622
+ return {
8623
+ passed: result.passed,
8624
+ failure: result.passed ? void 0 : `expected value to match schema: ${result.message}`
8625
+ };
8626
+ }
8627
+ }),
8628
+ calledTool: (toolName, options = {}, name = `called tool ${toolName}`) => ({
8629
+ name,
8630
+ requiresTrace: true,
8631
+ evaluate: ({ spans }) => {
8632
+ const calls = matchingToolCalls(_nullishCoalesce(spans, () => ( [])), toolName, options);
8633
+ const passed = options.times === void 0 ? calls.length > 0 : calls.length === options.times;
8634
+ return {
8635
+ passed,
8636
+ failure: passed ? void 0 : options.times === void 0 ? `expected tool "${toolName}" to be called; found ${calls.length} matching call${calls.length === 1 ? "" : "s"}` : `expected tool "${toolName}" to be called ${options.times} time${options.times === 1 ? "" : "s"}; found ${calls.length} matching call${calls.length === 1 ? "" : "s"}`
8637
+ };
8638
+ }
8639
+ }),
8640
+ notCalledTool: (toolName, name = `did not call tool ${toolName}`) => ({
8641
+ name,
8642
+ requiresTrace: true,
8643
+ evaluate: ({ spans }) => {
8644
+ const calls = toolCalls(_nullishCoalesce(spans, () => ( []))).filter(
8645
+ (span) => getToolName(span) === toolName
8646
+ );
8647
+ const passed = calls.length === 0;
8648
+ return {
8649
+ passed,
8650
+ failure: passed ? void 0 : `expected tool "${toolName}" not to be called; found ${calls.length} call${calls.length === 1 ? "" : "s"}`
8651
+ };
8652
+ }
8653
+ }),
8654
+ toolOrder: (toolNames, name = "tool order") => ({
8655
+ name,
8656
+ requiresTrace: true,
8657
+ evaluate: ({ spans }) => {
8658
+ const observed = toolCalls(_nullishCoalesce(spans, () => ( []))).map(getToolName).filter((toolName) => toolName !== void 0);
8659
+ let fromIndex = 0;
8660
+ const passed = toolNames.every((toolName) => {
8661
+ const index = observed.indexOf(toolName, fromIndex);
8662
+ if (index === -1) return false;
8663
+ fromIndex = index + 1;
8664
+ return true;
8665
+ });
8666
+ return {
8667
+ passed,
8668
+ failure: passed ? void 0 : `expected tool order ${toolNames.join(" -> ")}; observed ${observed.join(" -> ") || "no tools"}`
8669
+ };
8670
+ }
8671
+ }),
8672
+ usedNoTools: (name = "used no tools") => ({
8673
+ name,
8674
+ requiresTrace: true,
8675
+ evaluate: ({ spans }) => {
8676
+ const calls = toolCalls(_nullishCoalesce(spans, () => ( [])));
8677
+ const passed = calls.length === 0;
8678
+ return {
8679
+ passed,
8680
+ failure: passed ? void 0 : `expected no tool calls; found ${calls.length}`
8681
+ };
8682
+ }
8683
+ }),
8684
+ maxToolCalls: (max, name = `at most ${max} tool calls`) => ({
8685
+ name,
8686
+ requiresTrace: true,
8687
+ evaluate: ({ spans }) => {
8688
+ const calls = toolCalls(_nullishCoalesce(spans, () => ( [])));
8689
+ const passed = calls.length <= max;
8690
+ return {
8691
+ passed,
8692
+ failure: passed ? void 0 : `expected at most ${max} tool call${max === 1 ? "" : "s"}; found ${calls.length}`
8693
+ };
8694
+ }
8695
+ })
8696
+ };
8697
+ async function validateSchema(schema, value) {
8698
+ try {
8699
+ if ("safeParse" in schema) {
8700
+ const result2 = schema.safeParse(value);
8701
+ return result2.success ? { passed: true, message: "" } : { passed: false, message: formatSchemaError(result2.error) };
8702
+ }
8703
+ if ("parse" in schema) {
8704
+ schema.parse(value);
8705
+ return { passed: true, message: "" };
8706
+ }
8707
+ const result = await schema["~standard"].validate(value);
8708
+ if (typeof result === "object" && result !== null && "issues" in result && Array.isArray(result.issues) && result.issues.length > 0) {
8709
+ return { passed: false, message: formatValue(result.issues) };
8710
+ }
8711
+ return { passed: true, message: "" };
8712
+ } catch (e) {
8713
+ return { passed: false, message: formatSchemaError(e) };
8714
+ }
8715
+ }
8716
+ function toolCalls(spans) {
8717
+ return spans.filter((span) => _optionalChain([span, 'access', _166 => _166.span_attributes, 'optionalAccess', _167 => _167.type]) === "tool");
8718
+ }
8719
+ function matchingToolCalls(spans, toolName, options) {
8720
+ return toolCalls(spans).filter((span) => {
8721
+ if (getToolName(span) !== toolName) return false;
8722
+ if (Object.prototype.hasOwnProperty.call(options, "input") && !matchesValue(span.input, options.input)) {
8723
+ return false;
8724
+ }
8725
+ if (Object.prototype.hasOwnProperty.call(options, "output") && !matchesValue(span.output, options.output)) {
8726
+ return false;
8727
+ }
8728
+ if (options.isError !== void 0 && Boolean(span.error) !== options.isError) {
8729
+ return false;
8730
+ }
8731
+ return true;
8732
+ });
8733
+ }
8734
+ function getToolName(span) {
8735
+ const spanName = [_optionalChain([span, 'access', _168 => _168.span_attributes, 'optionalAccess', _169 => _169.name]), span.name].map(normalizeToolName).find((value) => value !== void 0);
8736
+ if (_optionalChain([spanName, 'optionalAccess', _170 => _170.includes, 'call', _171 => _171("/")])) {
8737
+ return spanName;
8738
+ }
8739
+ const metadataName = [
8740
+ _optionalChain([span, 'access', _172 => _172.metadata, 'optionalAccess', _173 => _173.tool_name]),
8741
+ _optionalChain([span, 'access', _174 => _174.metadata, 'optionalAccess', _175 => _175["gen_ai.tool.name"]])
8742
+ ].map(normalizeToolName).find((value) => value !== void 0);
8743
+ const mcpServer = [
8744
+ _optionalChain([span, 'access', _176 => _176.metadata, 'optionalAccess', _177 => _177["mcp.server"]]),
8745
+ _optionalChain([span, 'access', _178 => _178.metadata, 'optionalAccess', _179 => _179["openai_codex.mcp.server"]])
8746
+ ].find((value) => typeof value === "string" && value !== "");
8747
+ if (metadataName && mcpServer) {
8748
+ return `${mcpServer}/${metadataName}`;
8749
+ }
8750
+ return _nullishCoalesce(metadataName, () => ( spanName));
8751
+ }
8752
+ function normalizeToolName(value) {
8753
+ if (typeof value !== "string" || value === "") {
8754
+ return void 0;
8755
+ }
8756
+ return value.startsWith("tool:") ? value.slice("tool:".length).trim() : value;
8757
+ }
8758
+ function matchesValue(actual, matcher) {
8759
+ if (matcher instanceof RegExp) {
8760
+ return testRegex(matcher, actual);
8761
+ }
8762
+ if (typeof matcher === "function") {
8763
+ return matcher(actual);
8764
+ }
8765
+ if (Array.isArray(matcher)) {
8766
+ return Array.isArray(actual) && actual.length === matcher.length && matcher.every((value, index) => matchesValue(actual[index], value));
8767
+ }
8768
+ if (isPlainObject(matcher) && isPlainObject(actual)) {
8769
+ return Object.entries(matcher).every(
8770
+ ([key, value]) => Object.prototype.hasOwnProperty.call(actual, key) && matchesValue(actual[key], value)
8771
+ );
8772
+ }
8773
+ return deepEqual(actual, matcher);
8774
+ }
8775
+ function testRegex(matcher, value) {
8776
+ matcher.lastIndex = 0;
8777
+ return matcher.test(typeof value === "string" ? value : formatValue(value));
8778
+ }
8779
+ function deepEqual(left, right) {
8780
+ if (Object.is(left, right)) return true;
8781
+ if (Array.isArray(left) && Array.isArray(right)) {
8782
+ return left.length === right.length && left.every((item, index) => deepEqual(item, right[index]));
8783
+ }
8784
+ if (isPlainObject(left) && isPlainObject(right)) {
8785
+ const leftKeys = Object.keys(left);
8786
+ const rightKeys = Object.keys(right);
8787
+ return leftKeys.length === rightKeys.length && leftKeys.every(
8788
+ (key) => Object.prototype.hasOwnProperty.call(right, key) && deepEqual(left[key], right[key])
8789
+ );
8790
+ }
8791
+ return false;
8792
+ }
8793
+ function isPlainObject(value) {
8794
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
8795
+ }
8796
+ function formatSchemaError(error) {
8797
+ if (error instanceof Error) {
8798
+ return error.message;
8799
+ }
8800
+ return formatValue(error);
8801
+ }
8802
+ function formatValue(value) {
8803
+ if (value instanceof RegExp) {
8804
+ return value.toString();
8805
+ }
8806
+ if (typeof value === "string") {
8807
+ return JSON.stringify(value);
8808
+ }
8809
+ try {
8810
+ const serialized = JSON.stringify(value);
8811
+ if (serialized !== void 0 && !hasUndefinedJsonValue(value)) {
8812
+ return serialized;
8813
+ }
8814
+ return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
8815
+ } catch (e9) {
8816
+ return String(value);
8817
+ }
8818
+ }
8819
+ function hasUndefinedJsonValue(value, seen = /* @__PURE__ */ new Set()) {
8820
+ if (value === void 0) {
8821
+ return true;
8822
+ }
8823
+ if (typeof value !== "object" || value === null) {
8824
+ return false;
8825
+ }
8826
+ if (seen.has(value)) {
8827
+ return false;
8828
+ }
8829
+ seen.add(value);
8830
+ if (Array.isArray(value)) {
8831
+ return Array.from({ length: value.length }).some(
8832
+ (_, index) => hasUndefinedJsonValue(value[index], seen)
8833
+ );
8834
+ }
8835
+ return Object.keys(value).some(
8836
+ (key) => hasUndefinedJsonValue(value[key], seen)
8837
+ );
8838
+ }
8839
+ function formatValueWithUndefined(value, seen) {
8840
+ if (value === void 0) {
8841
+ return "undefined";
8842
+ }
8843
+ if (value === null) {
8844
+ return "null";
8845
+ }
8846
+ if (typeof value === "string") {
8847
+ return JSON.stringify(value);
8848
+ }
8849
+ if (typeof value === "number" || typeof value === "boolean") {
8850
+ return JSON.stringify(value);
8851
+ }
8852
+ if (typeof value === "bigint" || typeof value === "function") {
8853
+ return String(value);
8854
+ }
8855
+ if (typeof value === "symbol") {
8856
+ return String(value);
8857
+ }
8858
+ if (value instanceof RegExp) {
8859
+ return value.toString();
8860
+ }
8861
+ if (typeof value !== "object") {
8862
+ return String(value);
8863
+ }
8864
+ if (seen.has(value)) {
8865
+ return '"[Circular]"';
8866
+ }
8867
+ seen.add(value);
8868
+ if (typeof value.toJSON === "function") {
8869
+ const jsonValue = value.toJSON();
8870
+ seen.delete(value);
8871
+ return formatValueWithUndefined(jsonValue, seen);
8872
+ }
8873
+ if (Array.isArray(value)) {
8874
+ const formatted2 = Array.from(
8875
+ { length: value.length },
8876
+ (_, index) => formatValueWithUndefined(value[index], seen)
8877
+ );
8878
+ seen.delete(value);
8879
+ return `[${formatted2.join(",")}]`;
8880
+ }
8881
+ const formatted = Object.keys(value).map(
8882
+ (key) => `${JSON.stringify(key)}:${formatValueWithUndefined(
8883
+ value[key],
8884
+ seen
8885
+ )}`
8886
+ );
8887
+ seen.delete(value);
8888
+ return `{${formatted.join(",")}}`;
8889
+ }
8890
+
7033
8891
  // src/dataset-pipeline.ts
7034
8892
  function DatasetPipeline(definition) {
7035
8893
  if (!globalThis.__braintrust_dataset_pipelines) {
@@ -7067,7 +8925,7 @@ var ProjectBuilder = class {
7067
8925
  }
7068
8926
  };
7069
8927
  var projects = new ProjectBuilder();
7070
- var Project2 = (_class6 = class {
8928
+ var Project2 = (_class7 = class {
7071
8929
 
7072
8930
 
7073
8931
 
@@ -7075,10 +8933,10 @@ var Project2 = (_class6 = class {
7075
8933
 
7076
8934
 
7077
8935
 
7078
- __init12() {this._publishableCodeFunctions = []}
7079
- __init13() {this._publishablePrompts = []}
7080
- __init14() {this._publishableParameters = []}
7081
- constructor(args) {;_class6.prototype.__init12.call(this);_class6.prototype.__init13.call(this);_class6.prototype.__init14.call(this);
8936
+ __init17() {this._publishableCodeFunctions = []}
8937
+ __init18() {this._publishablePrompts = []}
8938
+ __init19() {this._publishableParameters = []}
8939
+ constructor(args) {;_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);
7082
8940
  _initializeSpanContext();
7083
8941
  this.name = "name" in args ? args.name : void 0;
7084
8942
  this.id = "id" in args ? args.id : void 0;
@@ -7113,7 +8971,7 @@ var Project2 = (_class6 = class {
7113
8971
  console.warn("publish() is a no-op when running `braintrust push`.");
7114
8972
  return;
7115
8973
  }
7116
- await _chunkPOCCIJALjs.login.call(void 0, );
8974
+ await _chunkMWVVR5LRjs.login.call(void 0, );
7117
8975
  const projectMap = new ProjectNameIdMap();
7118
8976
  const functionDefinitions = [];
7119
8977
  if (this._publishableCodeFunctions.length > 0) {
@@ -7127,16 +8985,16 @@ var Project2 = (_class6 = class {
7127
8985
  functionDefinitions.push(functionDefinition);
7128
8986
  }
7129
8987
  }
7130
- await _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
8988
+ await _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
7131
8989
  functions: functionDefinitions
7132
8990
  });
7133
8991
  }
7134
- }, _class6);
7135
- var ToolBuilder = (_class7 = class {
7136
- constructor(project) {;_class7.prototype.__init15.call(this);
8992
+ }, _class7);
8993
+ var ToolBuilder = (_class8 = class {
8994
+ constructor(project) {;_class8.prototype.__init20.call(this);
7137
8995
  this.project = project;
7138
8996
  }
7139
- __init15() {this.taskCounter = 0}
8997
+ __init20() {this.taskCounter = 0}
7140
8998
  // This type definition is just a catch all so that the implementation can be
7141
8999
  // less specific than the two more specific declarations above.
7142
9000
  create(opts) {
@@ -7145,12 +9003,12 @@ var ToolBuilder = (_class7 = class {
7145
9003
  const { handler, name, slug, parameters, returns, ...rest } = opts;
7146
9004
  let resolvedName = _nullishCoalesce(name, () => ( handler.name));
7147
9005
  if (resolvedName.trim().length === 0) {
7148
- resolvedName = `Tool ${_chunkLPC4W2WXjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
9006
+ resolvedName = `Tool ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
7149
9007
  }
7150
9008
  const tool = new CodeFunction(this.project, {
7151
9009
  handler,
7152
9010
  name: resolvedName,
7153
- slug: _nullishCoalesce(slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
9011
+ slug: _nullishCoalesce(slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
7154
9012
  type: "tool",
7155
9013
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
7156
9014
  parameters,
@@ -7161,12 +9019,12 @@ var ToolBuilder = (_class7 = class {
7161
9019
  this.project.addCodeFunction(tool);
7162
9020
  return tool;
7163
9021
  }
7164
- }, _class7);
7165
- var ScorerBuilder = (_class8 = class {
7166
- constructor(project) {;_class8.prototype.__init16.call(this);
9022
+ }, _class8);
9023
+ var ScorerBuilder = (_class9 = class {
9024
+ constructor(project) {;_class9.prototype.__init21.call(this);
7167
9025
  this.project = project;
7168
9026
  }
7169
- __init16() {this.taskCounter = 0}
9027
+ __init21() {this.taskCounter = 0}
7170
9028
  create(opts) {
7171
9029
  this.taskCounter++;
7172
9030
  let resolvedName = opts.name;
@@ -7174,9 +9032,9 @@ var ScorerBuilder = (_class8 = class {
7174
9032
  resolvedName = opts.handler.name;
7175
9033
  }
7176
9034
  if (!resolvedName || resolvedName.trim().length === 0) {
7177
- resolvedName = `Scorer ${_chunkLPC4W2WXjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
9035
+ resolvedName = `Scorer ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
7178
9036
  }
7179
- const slug = _nullishCoalesce(opts.slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
9037
+ const slug = _nullishCoalesce(opts.slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
7180
9038
  if ("handler" in opts) {
7181
9039
  const scorer = new CodeFunction(this.project, {
7182
9040
  ...opts,
@@ -7220,19 +9078,19 @@ var ScorerBuilder = (_class8 = class {
7220
9078
  this.project.addPrompt(codePrompt);
7221
9079
  }
7222
9080
  }
7223
- }, _class8);
7224
- var ClassifierBuilder = (_class9 = class {
7225
- constructor(project) {;_class9.prototype.__init17.call(this);
9081
+ }, _class9);
9082
+ var ClassifierBuilder = (_class10 = class {
9083
+ constructor(project) {;_class10.prototype.__init22.call(this);
7226
9084
  this.project = project;
7227
9085
  }
7228
- __init17() {this.taskCounter = 0}
9086
+ __init22() {this.taskCounter = 0}
7229
9087
  create(opts) {
7230
9088
  this.taskCounter++;
7231
9089
  let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
7232
9090
  if (!resolvedName || resolvedName.trim().length === 0) {
7233
- resolvedName = `Classifier ${_chunkLPC4W2WXjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
9091
+ resolvedName = `Classifier ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
7234
9092
  }
7235
- const slug = _nullishCoalesce(opts.slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
9093
+ const slug = _nullishCoalesce(opts.slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
7236
9094
  const classifier = new CodeFunction(this.project, {
7237
9095
  ...opts,
7238
9096
  name: resolvedName,
@@ -7242,7 +9100,7 @@ var ClassifierBuilder = (_class9 = class {
7242
9100
  this.project.addCodeFunction(classifier);
7243
9101
  return classifier;
7244
9102
  }
7245
- }, _class9);
9103
+ }, _class10);
7246
9104
  var CodeFunction = class {
7247
9105
  constructor(project, opts) {
7248
9106
  this.project = project;
@@ -7359,18 +9217,18 @@ var PromptBuilder = class {
7359
9217
  rawTools.push(tool);
7360
9218
  }
7361
9219
  }
7362
- const slug = _nullishCoalesce(opts.slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
9220
+ const slug = _nullishCoalesce(opts.slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
7363
9221
  const promptData = promptDefinitionToPromptData(opts, rawTools);
7364
9222
  const promptRow = {
7365
9223
  id: opts.id,
7366
- _xact_id: opts.version ? _chunkPOCCIJALjs.loadPrettyXact.call(void 0, opts.version) : void 0,
9224
+ _xact_id: opts.version ? _chunkMWVVR5LRjs.loadPrettyXact.call(void 0, opts.version) : void 0,
7367
9225
  name: opts.name,
7368
9226
  slug,
7369
9227
  prompt_data: promptData,
7370
9228
  tags: opts.tags,
7371
9229
  ...this.project.id !== void 0 ? { project_id: this.project.id } : {}
7372
9230
  };
7373
- const prompt = new (0, _chunkPOCCIJALjs.Prompt)(
9231
+ const prompt = new (0, _chunkMWVVR5LRjs.Prompt)(
7374
9232
  promptRow,
7375
9233
  {},
7376
9234
  // It doesn't make sense to specify defaults here.
@@ -7424,7 +9282,7 @@ var ParametersBuilder = class {
7424
9282
  this.project = project;
7425
9283
  }
7426
9284
  create(opts) {
7427
- const slug = _nullishCoalesce(opts.slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
9285
+ const slug = _nullishCoalesce(opts.slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
7428
9286
  const codeParameters = new CodeParameters(this.project, {
7429
9287
  name: opts.name,
7430
9288
  slug,
@@ -7463,7 +9321,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
7463
9321
  required.push(name);
7464
9322
  }
7465
9323
  } else {
7466
- const schemaObj = _chunkPOCCIJALjs.zodToJsonSchema.call(void 0, value);
9324
+ const schemaObj = _chunkMWVVR5LRjs.zodToJsonSchema.call(void 0, value);
7467
9325
  properties[name] = schemaObj;
7468
9326
  if (!("default" in schemaObj)) {
7469
9327
  required.push(name);
@@ -7487,16 +9345,16 @@ function getDefaultDataFromParametersSchema(schema) {
7487
9345
  })
7488
9346
  );
7489
9347
  }
7490
- var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__init18.call(this);_class10.prototype.__init19.call(this); }
7491
- __init18() {this.nameToId = {}}
7492
- __init19() {this.idToName = {}}
9348
+ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__init23.call(this);_class11.prototype.__init24.call(this); }
9349
+ __init23() {this.nameToId = {}}
9350
+ __init24() {this.idToName = {}}
7493
9351
  async getId(projectName) {
7494
9352
  if (!(projectName in this.nameToId)) {
7495
- const response = await _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
9353
+ const response = await _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
7496
9354
  project_name: projectName
7497
9355
  });
7498
9356
  const result = _v3.z.object({
7499
- project: _chunkPOCCIJALjs.Project
9357
+ project: _chunkMWVVR5LRjs.Project
7500
9358
  }).parse(response);
7501
9359
  const projectId = result.project.id;
7502
9360
  this.nameToId[projectName] = projectId;
@@ -7506,10 +9364,10 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
7506
9364
  }
7507
9365
  async getName(projectId) {
7508
9366
  if (!(projectId in this.idToName)) {
7509
- const response = await _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
9367
+ const response = await _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
7510
9368
  id: projectId
7511
9369
  });
7512
- const result = _v3.z.array(_chunkPOCCIJALjs.Project).nonempty().parse(response);
9370
+ const result = _v3.z.array(_chunkMWVVR5LRjs.Project).nonempty().parse(response);
7513
9371
  const projectName = result[0].name;
7514
9372
  this.idToName[projectId] = projectName;
7515
9373
  this.nameToId[projectName] = projectId;
@@ -7522,23 +9380,23 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
7522
9380
  }
7523
9381
  return this.getId(project.name);
7524
9382
  }
7525
- }, _class10);
9383
+ }, _class11);
7526
9384
 
7527
9385
  // dev/types.ts
7528
9386
 
7529
9387
  var evalBodySchema = _v3.z.object({
7530
9388
  name: _v3.z.string(),
7531
9389
  parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
7532
- data: _chunkPOCCIJALjs.RunEval.shape.data,
9390
+ data: _chunkMWVVR5LRjs.RunEval.shape.data,
7533
9391
  scores: _v3.z.array(
7534
9392
  _v3.z.object({
7535
- function_id: _chunkPOCCIJALjs.FunctionId,
9393
+ function_id: _chunkMWVVR5LRjs.FunctionId,
7536
9394
  name: _v3.z.string()
7537
9395
  })
7538
9396
  ).nullish(),
7539
9397
  experiment_name: _v3.z.string().nullish(),
7540
9398
  project_id: _v3.z.string().nullish(),
7541
- parent: _chunkPOCCIJALjs.InvokeParent.optional(),
9399
+ parent: _chunkMWVVR5LRjs.InvokeParent.optional(),
7542
9400
  stream: _v3.z.boolean().optional()
7543
9401
  });
7544
9402
  var staticParametersSchema = _v3.z.record(
@@ -7546,7 +9404,7 @@ var staticParametersSchema = _v3.z.record(
7546
9404
  _v3.z.union([
7547
9405
  _v3.z.object({
7548
9406
  type: _v3.z.literal("prompt"),
7549
- default: _chunkPOCCIJALjs.PromptData.optional(),
9407
+ default: _chunkMWVVR5LRjs.PromptData.optional(),
7550
9408
  description: _v3.z.string().optional()
7551
9409
  }),
7552
9410
  _v3.z.object({
@@ -7602,7 +9460,17 @@ var evaluatorDefinitionsSchema = _v3.z.record(
7602
9460
  );
7603
9461
 
7604
9462
  // src/node/index.ts
7605
- _chunkPOCCIJALjs.configureNode.call(void 0, );
9463
+ _chunkMWVVR5LRjs.configureNode.call(void 0, );
9464
+
9465
+
9466
+
9467
+
9468
+
9469
+
9470
+
9471
+
9472
+
9473
+
7606
9474
 
7607
9475
 
7608
9476
 
@@ -7760,4 +9628,4 @@ _chunkPOCCIJALjs.configureNode.call(void 0, );
7760
9628
 
7761
9629
 
7762
9630
 
7763
- exports.Attachment = _chunkPOCCIJALjs.Attachment; exports.AttachmentReference = _chunkPOCCIJALjs.AttachmentReference; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkPOCCIJALjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkPOCCIJALjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BaseAttachment = _chunkPOCCIJALjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkPOCCIJALjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkPOCCIJALjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkPOCCIJALjs.BraintrustState; exports.BraintrustStream = _chunkPOCCIJALjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkPOCCIJALjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkPOCCIJALjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkPOCCIJALjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkPOCCIJALjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkPOCCIJALjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkPOCCIJALjs.Experiment; exports.ExternalAttachment = _chunkPOCCIJALjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkPOCCIJALjs.FailedHTTPResponse; exports.IDGenerator = _chunkPOCCIJALjs.IDGenerator; exports.JSONAttachment = _chunkPOCCIJALjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkPOCCIJALjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkPOCCIJALjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkPOCCIJALjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkPOCCIJALjs.Logger; exports.LoginInvalidOrgError = _chunkPOCCIJALjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkPOCCIJALjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkPOCCIJALjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkPOCCIJALjs.NoopSpan; exports.ObjectFetcher = _chunkPOCCIJALjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkPOCCIJALjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkPOCCIJALjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkPOCCIJALjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkPOCCIJALjs.SpanImpl; exports.TestBackgroundLogger = _chunkPOCCIJALjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkPOCCIJALjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkPOCCIJALjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkPOCCIJALjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkPOCCIJALjs._internalGetGlobalState; exports._internalIso = _chunkLPC4W2WXjs.isomorph_default; exports._internalSetInitialState = _chunkPOCCIJALjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkPOCCIJALjs.addAzureBlobHeaders; exports.braintrustAISDKTelemetry = _chunkPOCCIJALjs.braintrustAISDKTelemetry; exports.braintrustFlueInstrumentation = _chunkPOCCIJALjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkPOCCIJALjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkPOCCIJALjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkPOCCIJALjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkPOCCIJALjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkPOCCIJALjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkPOCCIJALjs.currentExperiment; exports.currentLogger = _chunkPOCCIJALjs.currentLogger; exports.currentSpan = _chunkPOCCIJALjs.currentSpan; exports.deepCopyEvent = _chunkPOCCIJALjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkPOCCIJALjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkPOCCIJALjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.flush = _chunkPOCCIJALjs.flush; exports.getContextManager = _chunkPOCCIJALjs.getContextManager; exports.getIdGenerator = _chunkPOCCIJALjs.getIdGenerator; exports.getPromptVersions = _chunkPOCCIJALjs.getPromptVersions; exports.getSpanParentObject = _chunkPOCCIJALjs.getSpanParentObject; exports.getTemplateRenderer = _chunkPOCCIJALjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkPOCCIJALjs.init; exports.initDataset = _chunkPOCCIJALjs.initDataset; exports.initExperiment = _chunkPOCCIJALjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkPOCCIJALjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.invoke = invoke; exports.isTemplateFormat = _chunkPOCCIJALjs.isTemplateFormat; exports.loadParameters = _chunkPOCCIJALjs.loadParameters; exports.loadPrompt = _chunkPOCCIJALjs.loadPrompt; exports.log = _chunkPOCCIJALjs.log; exports.logError = _chunkPOCCIJALjs.logError; exports.login = _chunkPOCCIJALjs.login; exports.loginToState = _chunkPOCCIJALjs.loginToState; exports.logs3OverflowUploadSchema = _chunkPOCCIJALjs.logs3OverflowUploadSchema; exports.newId = _chunkPOCCIJALjs.newId; exports.parseCachedHeader = _chunkPOCCIJALjs.parseCachedHeader; exports.parseTemplateFormat = _chunkPOCCIJALjs.parseTemplateFormat; exports.permalink = _chunkPOCCIJALjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkPOCCIJALjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkPOCCIJALjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkPOCCIJALjs.registerTemplatePlugin; exports.renderMessage = _chunkPOCCIJALjs.renderMessage; exports.renderPromptParams = _chunkPOCCIJALjs.renderPromptParams; exports.renderTemplateContent = _chunkPOCCIJALjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkPOCCIJALjs.setFetch; exports.setMaskingFunction = _chunkPOCCIJALjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkPOCCIJALjs.spanComponentsToObjectId; exports.startSpan = _chunkPOCCIJALjs.startSpan; exports.summarize = _chunkPOCCIJALjs.summarize; exports.templateRegistry = _chunkPOCCIJALjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkPOCCIJALjs.ToolFunctionDefinition; exports.traceable = _chunkPOCCIJALjs.traceable; exports.traced = _chunkPOCCIJALjs.traced; exports.updateSpan = _chunkPOCCIJALjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkPOCCIJALjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkPOCCIJALjs.utf8ByteLength; exports.withCurrent = _chunkPOCCIJALjs.withCurrent; exports.withDataset = _chunkPOCCIJALjs.withDataset; exports.withExperiment = _chunkPOCCIJALjs.withExperiment; exports.withLogger = _chunkPOCCIJALjs.withLogger; exports.withParent = _chunkPOCCIJALjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCohere = wrapCohere; exports.wrapCopilotClient = wrapCopilotClient; exports.wrapCursorSDK = wrapCursorSDK; exports.wrapGenkit = wrapGenkit; exports.wrapGoogleADK = wrapGoogleADK; exports.wrapGoogleGenAI = wrapGoogleGenAI; exports.wrapGroq = wrapGroq; exports.wrapHuggingFace = wrapHuggingFace; exports.wrapMastraAgent = _chunkPOCCIJALjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkPOCCIJALjs.wrapTraced; exports.wrapVitest = wrapVitest;
9631
+ exports.Attachment = _chunkMWVVR5LRjs.Attachment; exports.AttachmentReference = _chunkMWVVR5LRjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkMWVVR5LRjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkMWVVR5LRjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkMWVVR5LRjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkMWVVR5LRjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkMWVVR5LRjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkMWVVR5LRjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkMWVVR5LRjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkMWVVR5LRjs.BraintrustState; exports.BraintrustStream = _chunkMWVVR5LRjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkMWVVR5LRjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkMWVVR5LRjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkMWVVR5LRjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkMWVVR5LRjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkMWVVR5LRjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkMWVVR5LRjs.Experiment; exports.ExternalAttachment = _chunkMWVVR5LRjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkMWVVR5LRjs.FailedHTTPResponse; exports.IDGenerator = _chunkMWVVR5LRjs.IDGenerator; exports.JSONAttachment = _chunkMWVVR5LRjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkMWVVR5LRjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkMWVVR5LRjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkMWVVR5LRjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkMWVVR5LRjs.Logger; exports.LoginInvalidOrgError = _chunkMWVVR5LRjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkMWVVR5LRjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkMWVVR5LRjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkMWVVR5LRjs.NoopSpan; exports.OTELIDGenerator = _chunkMWVVR5LRjs.OTELIDGenerator; exports.ObjectFetcher = _chunkMWVVR5LRjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkMWVVR5LRjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkMWVVR5LRjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkMWVVR5LRjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkMWVVR5LRjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkMWVVR5LRjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkMWVVR5LRjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkMWVVR5LRjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkMWVVR5LRjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkMWVVR5LRjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkMWVVR5LRjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkMWVVR5LRjs._internalGetGlobalState; exports._internalIso = _chunkBFGIH2ZJjs.isomorph_default; exports._internalSetInitialState = _chunkMWVVR5LRjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkMWVVR5LRjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkMWVVR5LRjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkMWVVR5LRjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkMWVVR5LRjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkMWVVR5LRjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkMWVVR5LRjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkMWVVR5LRjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkMWVVR5LRjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkMWVVR5LRjs.currentExperiment; exports.currentLogger = _chunkMWVVR5LRjs.currentLogger; exports.currentSpan = _chunkMWVVR5LRjs.currentSpan; exports.deepCopyEvent = _chunkMWVVR5LRjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkMWVVR5LRjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkMWVVR5LRjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkMWVVR5LRjs.extractTraceContextFromHeaders; exports.flush = _chunkMWVVR5LRjs.flush; exports.getContextManager = _chunkMWVVR5LRjs.getContextManager; exports.getIdGenerator = _chunkMWVVR5LRjs.getIdGenerator; exports.getPromptVersions = _chunkMWVVR5LRjs.getPromptVersions; exports.getSpanParentObject = _chunkMWVVR5LRjs.getSpanParentObject; exports.getTemplateRenderer = _chunkMWVVR5LRjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkMWVVR5LRjs.init; exports.initDataset = _chunkMWVVR5LRjs.initDataset; exports.initExperiment = _chunkMWVVR5LRjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkMWVVR5LRjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkMWVVR5LRjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkMWVVR5LRjs.isTemplateFormat; exports.loadParameters = _chunkMWVVR5LRjs.loadParameters; exports.loadPrompt = _chunkMWVVR5LRjs.loadPrompt; exports.log = _chunkMWVVR5LRjs.log; exports.logError = _chunkMWVVR5LRjs.logError; exports.login = _chunkMWVVR5LRjs.login; exports.loginToState = _chunkMWVVR5LRjs.loginToState; exports.logs3OverflowUploadSchema = _chunkMWVVR5LRjs.logs3OverflowUploadSchema; exports.newId = _chunkMWVVR5LRjs.newId; exports.parseCachedHeader = _chunkMWVVR5LRjs.parseCachedHeader; exports.parseTemplateFormat = _chunkMWVVR5LRjs.parseTemplateFormat; exports.permalink = _chunkMWVVR5LRjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkMWVVR5LRjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkMWVVR5LRjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkMWVVR5LRjs.registerTemplatePlugin; exports.renderMessage = _chunkMWVVR5LRjs.renderMessage; exports.renderPromptParams = _chunkMWVVR5LRjs.renderPromptParams; exports.renderTemplateContent = _chunkMWVVR5LRjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkMWVVR5LRjs.setFetch; exports.setMaskingFunction = _chunkMWVVR5LRjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkMWVVR5LRjs.spanComponentsToObjectId; exports.startSpan = _chunkMWVVR5LRjs.startSpan; exports.summarize = _chunkMWVVR5LRjs.summarize; exports.templateRegistry = _chunkMWVVR5LRjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkMWVVR5LRjs.ToolFunctionDefinition; exports.traceable = _chunkMWVVR5LRjs.traceable; exports.traced = _chunkMWVVR5LRjs.traced; exports.updateSpan = _chunkMWVVR5LRjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkMWVVR5LRjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkMWVVR5LRjs.utf8ByteLength; exports.withCurrent = _chunkMWVVR5LRjs.withCurrent; exports.withDataset = _chunkMWVVR5LRjs.withDataset; exports.withExperiment = _chunkMWVVR5LRjs.withExperiment; exports.withLogger = _chunkMWVVR5LRjs.withLogger; exports.withParent = _chunkMWVVR5LRjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCohere = wrapCohere; exports.wrapCopilotClient = wrapCopilotClient; exports.wrapCursorSDK = wrapCursorSDK; exports.wrapGenkit = wrapGenkit; exports.wrapGoogleADK = wrapGoogleADK; exports.wrapGoogleGenAI = wrapGoogleGenAI; exports.wrapGroq = wrapGroq; exports.wrapHuggingFace = wrapHuggingFace; exports.wrapMastraAgent = _chunkMWVVR5LRjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkMWVVR5LRjs.wrapTraced; exports.wrapVitest = wrapVitest;