braintrust 3.29.0 → 3.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev/dist/index.js +1465 -881
- package/dev/dist/index.mjs +846 -262
- package/dist/apply-auto-instrumentation.js +217 -217
- package/dist/apply-auto-instrumentation.mjs +2 -2
- package/dist/auto-instrumentations/bundler/esbuild.cjs +13 -1
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/next.cjs +13 -1
- package/dist/auto-instrumentations/bundler/next.mjs +3 -3
- package/dist/auto-instrumentations/bundler/rollup.cjs +13 -1
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +13 -1
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +13 -1
- package/dist/auto-instrumentations/bundler/webpack.cjs +13 -1
- package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
- package/dist/auto-instrumentations/{chunk-DKTGDNA7.mjs → chunk-LW4HDHXT.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-OMCZ3MV2.mjs → chunk-OXINGIEZ.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-AOIYCVEL.mjs → chunk-U64OYU4Q.mjs} +13 -1
- package/dist/auto-instrumentations/hook.mjs +16 -4
- package/dist/auto-instrumentations/index.cjs +13 -1
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/browser.d.mts +133 -2
- package/dist/browser.d.ts +133 -2
- package/dist/browser.js +1143 -297
- package/dist/browser.mjs +1143 -297
- package/dist/{chunk-6Z5S7VOU.js → chunk-2XDW3UCG.js} +13 -1
- package/dist/{chunk-M6XPNJC4.mjs → chunk-BU6SM54N.mjs} +687 -115
- package/dist/{chunk-7FA6VP2S.mjs → chunk-N3JKQ3D3.mjs} +13 -1
- package/dist/{chunk-XLLGRXGR.js → chunk-TWCDSYJN.js} +1803 -1231
- package/dist/cli.js +819 -235
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +1143 -297
- package/dist/edge-light.mjs +1143 -297
- package/dist/index.d.mts +133 -2
- package/dist/index.d.ts +133 -2
- package/dist/index.js +902 -640
- package/dist/index.mjs +336 -74
- package/dist/instrumentation/index.d.mts +15 -0
- package/dist/instrumentation/index.d.ts +15 -0
- package/dist/instrumentation/index.js +857 -262
- package/dist/instrumentation/index.mjs +857 -262
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +1143 -297
- package/dist/workerd.mjs +1143 -297
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
var
|
|
146
|
+
var _chunkTWCDSYJNjs = require('./chunk-TWCDSYJN.js');
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
|
|
@@ -177,157 +177,160 @@ var _chunkXLLGRXGRjs = require('./chunk-XLLGRXGR.js');
|
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
|
|
180
|
-
var
|
|
180
|
+
var _chunk2XDW3UCGjs = require('./chunk-2XDW3UCG.js');
|
|
181
181
|
|
|
182
182
|
// src/exports.ts
|
|
183
183
|
var exports_exports = {};
|
|
184
|
-
|
|
185
|
-
Attachment: () =>
|
|
186
|
-
AttachmentReference: () =>
|
|
187
|
-
BAGGAGE_HEADER: () =>
|
|
188
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
189
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
190
|
-
BRAINTRUST_PARENT_KEY: () =>
|
|
191
|
-
BaseAttachment: () =>
|
|
184
|
+
_chunk2XDW3UCGjs.__export.call(void 0, exports_exports, {
|
|
185
|
+
Attachment: () => _chunkTWCDSYJNjs.Attachment,
|
|
186
|
+
AttachmentReference: () => _chunkTWCDSYJNjs.AttachmentReference,
|
|
187
|
+
BAGGAGE_HEADER: () => _chunkTWCDSYJNjs.BAGGAGE_HEADER,
|
|
188
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkTWCDSYJNjs.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
189
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkTWCDSYJNjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
190
|
+
BRAINTRUST_PARENT_KEY: () => _chunkTWCDSYJNjs.BRAINTRUST_PARENT_KEY,
|
|
191
|
+
BaseAttachment: () => _chunkTWCDSYJNjs.BaseAttachment,
|
|
192
192
|
BaseExperiment: () => BaseExperiment,
|
|
193
193
|
BatchScorer: () => BatchScorer,
|
|
194
194
|
BatchTask: () => BatchTask,
|
|
195
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
195
|
+
BraintrustLangChainCallbackHandler: () => _chunkTWCDSYJNjs.BraintrustLangChainCallbackHandler,
|
|
196
196
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
197
|
-
BraintrustObservabilityExporter: () =>
|
|
198
|
-
BraintrustState: () =>
|
|
199
|
-
BraintrustStream: () =>
|
|
197
|
+
BraintrustObservabilityExporter: () => _chunkTWCDSYJNjs.BraintrustObservabilityExporter,
|
|
198
|
+
BraintrustState: () => _chunkTWCDSYJNjs.BraintrustState,
|
|
199
|
+
BraintrustStream: () => _chunkTWCDSYJNjs.BraintrustStream,
|
|
200
200
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
201
201
|
CodeFunction: () => CodeFunction,
|
|
202
202
|
CodePrompt: () => CodePrompt,
|
|
203
|
-
ContextManager: () =>
|
|
204
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
205
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
206
|
-
Dataset: () =>
|
|
203
|
+
ContextManager: () => _chunkTWCDSYJNjs.ContextManager,
|
|
204
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkTWCDSYJNjs.DEFAULT_FETCH_BATCH_SIZE,
|
|
205
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkTWCDSYJNjs.DEFAULT_MAX_REQUEST_SIZE,
|
|
206
|
+
Dataset: () => _chunkTWCDSYJNjs.Dataset,
|
|
207
207
|
DatasetPipeline: () => DatasetPipeline,
|
|
208
208
|
DurableEvalMemoryStore: () => DurableEvalMemoryStore,
|
|
209
209
|
DurableEvalRedisStore: () => DurableEvalRedisStore,
|
|
210
|
-
ERR_PERMALINK: () =>
|
|
210
|
+
ERR_PERMALINK: () => _chunkTWCDSYJNjs.ERR_PERMALINK,
|
|
211
211
|
Eval: () => Eval,
|
|
212
212
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
213
|
-
Experiment: () =>
|
|
214
|
-
ExternalAttachment: () =>
|
|
215
|
-
FailedHTTPResponse: () =>
|
|
216
|
-
IDGenerator: () =>
|
|
217
|
-
JSONAttachment: () =>
|
|
218
|
-
LEGACY_CACHED_HEADER: () =>
|
|
219
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
220
|
-
LazyValue: () =>
|
|
213
|
+
Experiment: () => _chunkTWCDSYJNjs.Experiment,
|
|
214
|
+
ExternalAttachment: () => _chunkTWCDSYJNjs.ExternalAttachment,
|
|
215
|
+
FailedHTTPResponse: () => _chunkTWCDSYJNjs.FailedHTTPResponse,
|
|
216
|
+
IDGenerator: () => _chunkTWCDSYJNjs.IDGenerator,
|
|
217
|
+
JSONAttachment: () => _chunkTWCDSYJNjs.JSONAttachment,
|
|
218
|
+
LEGACY_CACHED_HEADER: () => _chunkTWCDSYJNjs.LEGACY_CACHED_HEADER,
|
|
219
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkTWCDSYJNjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
220
|
+
LazyValue: () => _chunkTWCDSYJNjs.LazyValue,
|
|
221
221
|
LocalTrace: () => LocalTrace,
|
|
222
|
-
Logger: () =>
|
|
223
|
-
LoginInvalidOrgError: () =>
|
|
224
|
-
NOOP_SPAN: () =>
|
|
225
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
226
|
-
NoopSpan: () =>
|
|
227
|
-
OTELIDGenerator: () =>
|
|
228
|
-
ObjectFetcher: () =>
|
|
222
|
+
Logger: () => _chunkTWCDSYJNjs.Logger,
|
|
223
|
+
LoginInvalidOrgError: () => _chunkTWCDSYJNjs.LoginInvalidOrgError,
|
|
224
|
+
NOOP_SPAN: () => _chunkTWCDSYJNjs.NOOP_SPAN,
|
|
225
|
+
NOOP_SPAN_PERMALINK: () => _chunkTWCDSYJNjs.NOOP_SPAN_PERMALINK,
|
|
226
|
+
NoopSpan: () => _chunkTWCDSYJNjs.NoopSpan,
|
|
227
|
+
OTELIDGenerator: () => _chunkTWCDSYJNjs.OTELIDGenerator,
|
|
228
|
+
ObjectFetcher: () => _chunkTWCDSYJNjs.ObjectFetcher,
|
|
229
229
|
Project: () => Project2,
|
|
230
230
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
231
|
-
Prompt: () =>
|
|
231
|
+
Prompt: () => _chunkTWCDSYJNjs.Prompt,
|
|
232
232
|
PromptBuilder: () => PromptBuilder,
|
|
233
|
-
ReadonlyAttachment: () =>
|
|
234
|
-
ReadonlyExperiment: () =>
|
|
233
|
+
ReadonlyAttachment: () => _chunkTWCDSYJNjs.ReadonlyAttachment,
|
|
234
|
+
ReadonlyExperiment: () => _chunkTWCDSYJNjs.ReadonlyExperiment,
|
|
235
235
|
Reporter: () => Reporter,
|
|
236
236
|
ScorerBuilder: () => ScorerBuilder,
|
|
237
237
|
SpanFetcher: () => SpanFetcher,
|
|
238
|
-
SpanImpl: () =>
|
|
239
|
-
TRACEPARENT_HEADER: () =>
|
|
240
|
-
TRACESTATE_HEADER: () =>
|
|
241
|
-
TestBackgroundLogger: () =>
|
|
238
|
+
SpanImpl: () => _chunkTWCDSYJNjs.SpanImpl,
|
|
239
|
+
TRACEPARENT_HEADER: () => _chunkTWCDSYJNjs.TRACEPARENT_HEADER,
|
|
240
|
+
TRACESTATE_HEADER: () => _chunkTWCDSYJNjs.TRACESTATE_HEADER,
|
|
241
|
+
TestBackgroundLogger: () => _chunkTWCDSYJNjs.TestBackgroundLogger,
|
|
242
242
|
ToolBuilder: () => ToolBuilder,
|
|
243
|
-
UUIDGenerator: () =>
|
|
244
|
-
X_CACHED_HEADER: () =>
|
|
245
|
-
_exportsForTestingOnly: () =>
|
|
246
|
-
_internalGetGlobalState: () =>
|
|
247
|
-
_internalIso: () =>
|
|
248
|
-
_internalSetInitialState: () =>
|
|
249
|
-
addAzureBlobHeaders: () =>
|
|
243
|
+
UUIDGenerator: () => _chunkTWCDSYJNjs.UUIDGenerator,
|
|
244
|
+
X_CACHED_HEADER: () => _chunkTWCDSYJNjs.X_CACHED_HEADER,
|
|
245
|
+
_exportsForTestingOnly: () => _chunkTWCDSYJNjs._exportsForTestingOnly,
|
|
246
|
+
_internalGetGlobalState: () => _chunkTWCDSYJNjs._internalGetGlobalState,
|
|
247
|
+
_internalIso: () => _chunk2XDW3UCGjs.isomorph_default,
|
|
248
|
+
_internalSetInitialState: () => _chunkTWCDSYJNjs._internalSetInitialState,
|
|
249
|
+
addAzureBlobHeaders: () => _chunkTWCDSYJNjs.addAzureBlobHeaders,
|
|
250
250
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
251
|
-
braintrustAISDKTelemetry: () =>
|
|
251
|
+
braintrustAISDKTelemetry: () => _chunkTWCDSYJNjs.braintrustAISDKTelemetry,
|
|
252
252
|
braintrustEveHook: () => braintrustEveHook,
|
|
253
253
|
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
254
|
-
braintrustFlueInstrumentation: () =>
|
|
255
|
-
braintrustFlueObserver: () =>
|
|
256
|
-
braintrustStreamChunkSchema: () =>
|
|
254
|
+
braintrustFlueInstrumentation: () => _chunkTWCDSYJNjs.braintrustFlueInstrumentation,
|
|
255
|
+
braintrustFlueObserver: () => _chunkTWCDSYJNjs.braintrustFlueObserver,
|
|
256
|
+
braintrustStreamChunkSchema: () => _chunkTWCDSYJNjs.braintrustStreamChunkSchema,
|
|
257
257
|
buildLocalSummary: () => buildLocalSummary,
|
|
258
|
-
collectAnthropicSession: () =>
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
258
|
+
collectAnthropicSession: () => _chunkTWCDSYJNjs.collectAnthropicSession,
|
|
259
|
+
completeOpenAIBatchTrace: () => completeOpenAIBatchTrace,
|
|
260
|
+
configureInstrumentation: () => _chunkTWCDSYJNjs.configureInstrumentation,
|
|
261
|
+
constructLogs3OverflowRequest: () => _chunkTWCDSYJNjs.constructLogs3OverflowRequest,
|
|
262
|
+
createFinalValuePassThroughStream: () => _chunkTWCDSYJNjs.createFinalValuePassThroughStream,
|
|
263
|
+
currentExperiment: () => _chunkTWCDSYJNjs.currentExperiment,
|
|
264
|
+
currentLogger: () => _chunkTWCDSYJNjs.currentLogger,
|
|
265
|
+
currentSpan: () => _chunkTWCDSYJNjs.currentSpan,
|
|
266
|
+
deepCopyEvent: () => _chunkTWCDSYJNjs.deepCopyEvent,
|
|
266
267
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
267
268
|
defineDurableEval: () => defineDurableEval,
|
|
268
|
-
deserializePlainStringAsJSON: () =>
|
|
269
|
-
devNullWritableStream: () =>
|
|
269
|
+
deserializePlainStringAsJSON: () => _chunkTWCDSYJNjs.deserializePlainStringAsJSON,
|
|
270
|
+
devNullWritableStream: () => _chunkTWCDSYJNjs.devNullWritableStream,
|
|
270
271
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
271
272
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
272
|
-
extractTraceContextFromHeaders: () =>
|
|
273
|
-
flush: () =>
|
|
274
|
-
getContextManager: () =>
|
|
275
|
-
getIdGenerator: () =>
|
|
276
|
-
getPromptVersions: () =>
|
|
277
|
-
getSpanParentObject: () =>
|
|
278
|
-
getTemplateRenderer: () =>
|
|
273
|
+
extractTraceContextFromHeaders: () => _chunkTWCDSYJNjs.extractTraceContextFromHeaders,
|
|
274
|
+
flush: () => _chunkTWCDSYJNjs.flush,
|
|
275
|
+
getContextManager: () => _chunkTWCDSYJNjs.getContextManager,
|
|
276
|
+
getIdGenerator: () => _chunkTWCDSYJNjs.getIdGenerator,
|
|
277
|
+
getPromptVersions: () => _chunkTWCDSYJNjs.getPromptVersions,
|
|
278
|
+
getSpanParentObject: () => _chunkTWCDSYJNjs.getSpanParentObject,
|
|
279
|
+
getTemplateRenderer: () => _chunkTWCDSYJNjs.getTemplateRenderer,
|
|
279
280
|
graph: () => graph_framework_exports,
|
|
280
|
-
init: () =>
|
|
281
|
-
initDataset: () =>
|
|
282
|
-
initExperiment: () =>
|
|
281
|
+
init: () => _chunkTWCDSYJNjs.init,
|
|
282
|
+
initDataset: () => _chunkTWCDSYJNjs.initDataset,
|
|
283
|
+
initExperiment: () => _chunkTWCDSYJNjs.initExperiment,
|
|
283
284
|
initFunction: () => initFunction,
|
|
284
|
-
initLogger: () =>
|
|
285
|
+
initLogger: () => _chunkTWCDSYJNjs.initLogger,
|
|
285
286
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
286
|
-
injectTraceContext: () =>
|
|
287
|
+
injectTraceContext: () => _chunkTWCDSYJNjs.injectTraceContext,
|
|
287
288
|
invoke: () => invoke,
|
|
288
|
-
isTemplateFormat: () =>
|
|
289
|
-
loadParameters: () =>
|
|
290
|
-
loadPrompt: () =>
|
|
291
|
-
log: () =>
|
|
292
|
-
logError: () =>
|
|
293
|
-
login: () =>
|
|
294
|
-
loginToState: () =>
|
|
295
|
-
logs3OverflowUploadSchema: () =>
|
|
296
|
-
newId: () =>
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
289
|
+
isTemplateFormat: () => _chunkTWCDSYJNjs.isTemplateFormat,
|
|
290
|
+
loadParameters: () => _chunkTWCDSYJNjs.loadParameters,
|
|
291
|
+
loadPrompt: () => _chunkTWCDSYJNjs.loadPrompt,
|
|
292
|
+
log: () => _chunkTWCDSYJNjs.log,
|
|
293
|
+
logError: () => _chunkTWCDSYJNjs.logError,
|
|
294
|
+
login: () => _chunkTWCDSYJNjs.login,
|
|
295
|
+
loginToState: () => _chunkTWCDSYJNjs.loginToState,
|
|
296
|
+
logs3OverflowUploadSchema: () => _chunkTWCDSYJNjs.logs3OverflowUploadSchema,
|
|
297
|
+
newId: () => _chunkTWCDSYJNjs.newId,
|
|
298
|
+
openaiBatchesRetrieveTraced: () => openaiBatchesRetrieveTraced,
|
|
299
|
+
openaiFilesCreateTraced: () => openaiFilesCreateTraced,
|
|
300
|
+
parseCachedHeader: () => _chunkTWCDSYJNjs.parseCachedHeader,
|
|
301
|
+
parseTemplateFormat: () => _chunkTWCDSYJNjs.parseTemplateFormat,
|
|
302
|
+
permalink: () => _chunkTWCDSYJNjs.permalink,
|
|
303
|
+
pickLogs3OverflowObjectIds: () => _chunkTWCDSYJNjs.pickLogs3OverflowObjectIds,
|
|
301
304
|
projects: () => projects,
|
|
302
305
|
promptContentsSchema: () => promptContentsSchema,
|
|
303
306
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
304
307
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
305
308
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
306
|
-
registerOtelFlush: () =>
|
|
309
|
+
registerOtelFlush: () => _chunkTWCDSYJNjs.registerOtelFlush,
|
|
307
310
|
registerSandbox: () => registerSandbox,
|
|
308
|
-
registerTemplatePlugin: () =>
|
|
309
|
-
renderMessage: () =>
|
|
310
|
-
renderPromptParams: () =>
|
|
311
|
-
renderTemplateContent: () =>
|
|
311
|
+
registerTemplatePlugin: () => _chunkTWCDSYJNjs.registerTemplatePlugin,
|
|
312
|
+
renderMessage: () => _chunkTWCDSYJNjs.renderMessage,
|
|
313
|
+
renderPromptParams: () => _chunkTWCDSYJNjs.renderPromptParams,
|
|
314
|
+
renderTemplateContent: () => _chunkTWCDSYJNjs.renderTemplateContent,
|
|
312
315
|
reportFailures: () => reportFailures,
|
|
313
316
|
runEvaluator: () => runEvaluator,
|
|
314
|
-
setFetch: () =>
|
|
315
|
-
setMaskingFunction: () =>
|
|
316
|
-
spanComponentsToObjectId: () =>
|
|
317
|
-
startSpan: () =>
|
|
318
|
-
summarize: () =>
|
|
319
|
-
templateRegistry: () =>
|
|
320
|
-
toolFunctionDefinitionSchema: () =>
|
|
321
|
-
traceable: () =>
|
|
322
|
-
traced: () =>
|
|
323
|
-
updateSpan: () =>
|
|
324
|
-
uploadLogs3OverflowPayload: () =>
|
|
325
|
-
utf8ByteLength: () =>
|
|
326
|
-
withCurrent: () =>
|
|
327
|
-
withDataset: () =>
|
|
328
|
-
withExperiment: () =>
|
|
329
|
-
withLogger: () =>
|
|
330
|
-
withParent: () =>
|
|
317
|
+
setFetch: () => _chunkTWCDSYJNjs.setFetch,
|
|
318
|
+
setMaskingFunction: () => _chunkTWCDSYJNjs.setMaskingFunction,
|
|
319
|
+
spanComponentsToObjectId: () => _chunkTWCDSYJNjs.spanComponentsToObjectId,
|
|
320
|
+
startSpan: () => _chunkTWCDSYJNjs.startSpan,
|
|
321
|
+
summarize: () => _chunkTWCDSYJNjs.summarize,
|
|
322
|
+
templateRegistry: () => _chunkTWCDSYJNjs.templateRegistry,
|
|
323
|
+
toolFunctionDefinitionSchema: () => _chunkTWCDSYJNjs.ToolFunctionDefinition,
|
|
324
|
+
traceable: () => _chunkTWCDSYJNjs.traceable,
|
|
325
|
+
traced: () => _chunkTWCDSYJNjs.traced,
|
|
326
|
+
updateSpan: () => _chunkTWCDSYJNjs.updateSpan,
|
|
327
|
+
uploadLogs3OverflowPayload: () => _chunkTWCDSYJNjs.uploadLogs3OverflowPayload,
|
|
328
|
+
utf8ByteLength: () => _chunkTWCDSYJNjs.utf8ByteLength,
|
|
329
|
+
withCurrent: () => _chunkTWCDSYJNjs.withCurrent,
|
|
330
|
+
withDataset: () => _chunkTWCDSYJNjs.withDataset,
|
|
331
|
+
withExperiment: () => _chunkTWCDSYJNjs.withExperiment,
|
|
332
|
+
withLogger: () => _chunkTWCDSYJNjs.withLogger,
|
|
333
|
+
withParent: () => _chunkTWCDSYJNjs.withParent,
|
|
331
334
|
wrapAISDK: () => wrapAISDK,
|
|
332
335
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
333
336
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -349,7 +352,7 @@ _chunk6Z5S7VOUjs.__export.call(void 0, exports_exports, {
|
|
|
349
352
|
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
350
353
|
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
351
354
|
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
352
|
-
wrapMastraAgent: () =>
|
|
355
|
+
wrapMastraAgent: () => _chunkTWCDSYJNjs.wrapMastraAgent,
|
|
353
356
|
wrapMistral: () => wrapMistral,
|
|
354
357
|
wrapOllama: () => wrapOllama,
|
|
355
358
|
wrapOpenAI: () => wrapOpenAI,
|
|
@@ -359,7 +362,7 @@ _chunk6Z5S7VOUjs.__export.call(void 0, exports_exports, {
|
|
|
359
362
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
360
363
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
361
364
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
362
|
-
wrapTraced: () =>
|
|
365
|
+
wrapTraced: () => _chunkTWCDSYJNjs.wrapTraced,
|
|
363
366
|
wrapVitest: () => wrapVitest,
|
|
364
367
|
wrapVoyageAI: () => wrapVoyageAI
|
|
365
368
|
});
|
|
@@ -368,7 +371,7 @@ _chunk6Z5S7VOUjs.__export.call(void 0, exports_exports, {
|
|
|
368
371
|
var _v3 = require('zod/v3');
|
|
369
372
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
370
373
|
async function registerSandbox(options) {
|
|
371
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
374
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, )));
|
|
372
375
|
await state.login({
|
|
373
376
|
apiKey: options.apiKey,
|
|
374
377
|
appUrl: options.appUrl,
|
|
@@ -409,7 +412,7 @@ async function registerSandbox(options) {
|
|
|
409
412
|
evaluatorDefinitions
|
|
410
413
|
)) {
|
|
411
414
|
const functionName = evalName;
|
|
412
|
-
const functionSlug =
|
|
415
|
+
const functionSlug = _chunkTWCDSYJNjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
413
416
|
const functionDef = {
|
|
414
417
|
project_id: projectId,
|
|
415
418
|
org_name: state.orgName,
|
|
@@ -458,6 +461,260 @@ async function registerSandbox(options) {
|
|
|
458
461
|
};
|
|
459
462
|
}
|
|
460
463
|
|
|
464
|
+
// src/wrappers/openai-promise-utils.ts
|
|
465
|
+
function splitSpanInfo(allParams) {
|
|
466
|
+
const { span_info, ...params } = allParams;
|
|
467
|
+
return {
|
|
468
|
+
params,
|
|
469
|
+
span_info
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function createChannelContext(_channel, params, span_info) {
|
|
473
|
+
return {
|
|
474
|
+
arguments: (
|
|
475
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
476
|
+
[params]
|
|
477
|
+
),
|
|
478
|
+
span_info
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
async function tracePromiseWithResponse(channel, traceContext, apiPromise) {
|
|
482
|
+
let enhancedResponse;
|
|
483
|
+
const tracePromise = (
|
|
484
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
485
|
+
channel.tracePromise
|
|
486
|
+
);
|
|
487
|
+
const data = await tracePromise(async () => {
|
|
488
|
+
enhancedResponse = await apiPromise.withResponse();
|
|
489
|
+
traceContext.response = enhancedResponse.response;
|
|
490
|
+
return enhancedResponse.data;
|
|
491
|
+
}, traceContext);
|
|
492
|
+
if (!enhancedResponse) {
|
|
493
|
+
throw new Error("Expected withResponse() to provide response");
|
|
494
|
+
}
|
|
495
|
+
return {
|
|
496
|
+
data,
|
|
497
|
+
response: enhancedResponse.response,
|
|
498
|
+
request_id: enhancedResponse.request_id
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
async function tracePromiseAsResponse(channel, traceContext, apiPromise) {
|
|
502
|
+
const tracePromise = (
|
|
503
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
504
|
+
channel.tracePromise
|
|
505
|
+
);
|
|
506
|
+
let response;
|
|
507
|
+
await tracePromise(async () => {
|
|
508
|
+
response = await apiPromise.asResponse();
|
|
509
|
+
traceContext.response = response;
|
|
510
|
+
return void 0;
|
|
511
|
+
}, traceContext);
|
|
512
|
+
if (!response) {
|
|
513
|
+
throw new Error("Expected asResponse() to provide response");
|
|
514
|
+
}
|
|
515
|
+
return response;
|
|
516
|
+
}
|
|
517
|
+
function createLazyAPIPromise(ensureExecuted, ensureResponse, getAPIPromise) {
|
|
518
|
+
let firstConsumption;
|
|
519
|
+
let enhancedResponsePromise;
|
|
520
|
+
let dataPromise;
|
|
521
|
+
let responsePromise;
|
|
522
|
+
const withResponse = () => {
|
|
523
|
+
firstConsumption ??= "data";
|
|
524
|
+
enhancedResponsePromise ??= firstConsumption === "data" ? ensureExecuted() : getAPIPromise().withResponse();
|
|
525
|
+
return enhancedResponsePromise;
|
|
526
|
+
};
|
|
527
|
+
const asResponse = () => {
|
|
528
|
+
firstConsumption ??= "response";
|
|
529
|
+
responsePromise ??= firstConsumption === "response" ? ensureResponse() : getAPIPromise().asResponse();
|
|
530
|
+
return responsePromise;
|
|
531
|
+
};
|
|
532
|
+
return new Proxy({}, {
|
|
533
|
+
get(target, prop, receiver) {
|
|
534
|
+
if (prop === "withResponse") {
|
|
535
|
+
return withResponse;
|
|
536
|
+
}
|
|
537
|
+
if (prop === "asResponse") {
|
|
538
|
+
return asResponse;
|
|
539
|
+
}
|
|
540
|
+
if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
|
|
541
|
+
dataPromise ??= withResponse().then((result) => result.data);
|
|
542
|
+
const value = Reflect.get(dataPromise, prop, receiver);
|
|
543
|
+
return typeof value === "function" ? value.bind(dataPromise) : value;
|
|
544
|
+
}
|
|
545
|
+
return Reflect.get(target, prop, receiver);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// src/openai-batch.ts
|
|
551
|
+
function read(value, key) {
|
|
552
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") {
|
|
553
|
+
return void 0;
|
|
554
|
+
}
|
|
555
|
+
try {
|
|
556
|
+
return Reflect.get(value, key);
|
|
557
|
+
} catch (e2) {
|
|
558
|
+
return void 0;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function isAsyncIterable(value) {
|
|
562
|
+
return typeof read(value, Symbol.asyncIterator) === "function";
|
|
563
|
+
}
|
|
564
|
+
function teeAsyncIterable(source) {
|
|
565
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
566
|
+
const stream = new ReadableStream({
|
|
567
|
+
async pull(controller) {
|
|
568
|
+
try {
|
|
569
|
+
const result = await iterator.next();
|
|
570
|
+
if (result.done) {
|
|
571
|
+
controller.close();
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (!(result.value instanceof Uint8Array)) {
|
|
575
|
+
throw new TypeError(
|
|
576
|
+
"OpenAI upload streams must yield Uint8Array chunks"
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
controller.enqueue(result.value);
|
|
580
|
+
} catch (error) {
|
|
581
|
+
controller.error(error);
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
async cancel(reason) {
|
|
585
|
+
await _optionalChain([iterator, 'access', _2 => _2.return, 'optionalCall', _3 => _3(reason)]);
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
const [uploadStream, trace] = stream.tee();
|
|
589
|
+
const upload = {
|
|
590
|
+
async *[Symbol.asyncIterator]() {
|
|
591
|
+
const reader = uploadStream.getReader();
|
|
592
|
+
try {
|
|
593
|
+
while (true) {
|
|
594
|
+
const result = await reader.read();
|
|
595
|
+
if (result.done) {
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
yield result.value;
|
|
599
|
+
}
|
|
600
|
+
} finally {
|
|
601
|
+
reader.releaseLock();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
const path = read(source, "path");
|
|
606
|
+
if (typeof path === "string") {
|
|
607
|
+
Object.defineProperty(upload, "path", { value: path });
|
|
608
|
+
}
|
|
609
|
+
return { upload, trace: new Response(trace) };
|
|
610
|
+
}
|
|
611
|
+
function teeUpload(upload) {
|
|
612
|
+
if (upload instanceof Blob) {
|
|
613
|
+
return { upload, trace: new Response(upload) };
|
|
614
|
+
}
|
|
615
|
+
if (upload instanceof Response) {
|
|
616
|
+
return { upload, trace: upload.clone() };
|
|
617
|
+
}
|
|
618
|
+
if (isAsyncIterable(upload)) {
|
|
619
|
+
return teeAsyncIterable(upload);
|
|
620
|
+
}
|
|
621
|
+
return void 0;
|
|
622
|
+
}
|
|
623
|
+
function openaiFilesCreateTraced(files) {
|
|
624
|
+
return (params, options) => {
|
|
625
|
+
const parent = _chunkTWCDSYJNjs.getSpanParentObject.call(void 0, );
|
|
626
|
+
const purpose = read(params, "purpose");
|
|
627
|
+
const file = read(params, "file");
|
|
628
|
+
if (purpose !== "batch") {
|
|
629
|
+
return files.create(params, options);
|
|
630
|
+
}
|
|
631
|
+
let branches;
|
|
632
|
+
try {
|
|
633
|
+
branches = teeUpload(file);
|
|
634
|
+
} catch (e3) {
|
|
635
|
+
return files.create(params, options);
|
|
636
|
+
}
|
|
637
|
+
if (!branches) {
|
|
638
|
+
return files.create(params, options);
|
|
639
|
+
}
|
|
640
|
+
const tracedParams = {
|
|
641
|
+
...Object(params),
|
|
642
|
+
file: branches.upload
|
|
643
|
+
};
|
|
644
|
+
const apiPromise = files.create(tracedParams, options);
|
|
645
|
+
let enhancedResponse;
|
|
646
|
+
const tracedResponse = _chunk2XDW3UCGjs.openAIChannels.filesCreateTraced.invoke(
|
|
647
|
+
async () => {
|
|
648
|
+
enhancedResponse = await apiPromise.withResponse();
|
|
649
|
+
return enhancedResponse.data;
|
|
650
|
+
},
|
|
651
|
+
files,
|
|
652
|
+
[{ params, inputFileContent: branches.trace, parent }],
|
|
653
|
+
{}
|
|
654
|
+
).then((data) => {
|
|
655
|
+
if (!enhancedResponse) {
|
|
656
|
+
throw new Error(
|
|
657
|
+
"Expected OpenAI withResponse() to provide a response"
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
return { ...enhancedResponse, data };
|
|
661
|
+
});
|
|
662
|
+
return createLazyAPIPromise(
|
|
663
|
+
() => tracedResponse,
|
|
664
|
+
() => tracedResponse.then(({ response }) => response),
|
|
665
|
+
() => apiPromise
|
|
666
|
+
);
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
function openaiBatchesRetrieveTraced(batches) {
|
|
670
|
+
return (batchId, options) => {
|
|
671
|
+
const apiPromise = batches.retrieve(batchId, options);
|
|
672
|
+
let enhancedResponse;
|
|
673
|
+
const tracedResponse = _chunk2XDW3UCGjs.openAIChannels.batchesRetrieveTraced.invoke(
|
|
674
|
+
async () => {
|
|
675
|
+
enhancedResponse = await apiPromise.withResponse();
|
|
676
|
+
return enhancedResponse.data;
|
|
677
|
+
},
|
|
678
|
+
batches,
|
|
679
|
+
[{ batchId }],
|
|
680
|
+
{}
|
|
681
|
+
).then((data) => {
|
|
682
|
+
if (!enhancedResponse) {
|
|
683
|
+
throw new Error(
|
|
684
|
+
"Expected OpenAI withResponse() to provide a response"
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
return { ...enhancedResponse, data };
|
|
688
|
+
});
|
|
689
|
+
return createLazyAPIPromise(
|
|
690
|
+
() => tracedResponse,
|
|
691
|
+
() => tracedResponse.then(({ response }) => response),
|
|
692
|
+
() => apiPromise
|
|
693
|
+
);
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
async function completeOpenAIBatchTrace(args) {
|
|
697
|
+
const inputFileContent = Promise.resolve(args.inputFileContent);
|
|
698
|
+
const outputFileContent = args.outputFileContent === void 0 ? void 0 : Promise.resolve(args.outputFileContent);
|
|
699
|
+
const errorFileContent = args.errorFileContent === void 0 ? void 0 : Promise.resolve(args.errorFileContent);
|
|
700
|
+
void inputFileContent.catch(() => void 0);
|
|
701
|
+
void _optionalChain([outputFileContent, 'optionalAccess', _4 => _4.catch, 'call', _5 => _5(() => void 0)]);
|
|
702
|
+
void _optionalChain([errorFileContent, 'optionalAccess', _6 => _6.catch, 'call', _7 => _7(() => void 0)]);
|
|
703
|
+
await _chunk2XDW3UCGjs.openAIChannels.batchesCompleteTrace.invoke(
|
|
704
|
+
async () => void 0,
|
|
705
|
+
void 0,
|
|
706
|
+
[
|
|
707
|
+
{
|
|
708
|
+
...args,
|
|
709
|
+
inputFileContent,
|
|
710
|
+
outputFileContent,
|
|
711
|
+
errorFileContent
|
|
712
|
+
}
|
|
713
|
+
],
|
|
714
|
+
{}
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
|
|
461
718
|
// src/functions/invoke.ts
|
|
462
719
|
async function invoke(args) {
|
|
463
720
|
const {
|
|
@@ -480,7 +737,7 @@ async function invoke(args) {
|
|
|
480
737
|
projectId,
|
|
481
738
|
...functionIdArgs
|
|
482
739
|
} = args;
|
|
483
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
740
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, )));
|
|
484
741
|
await state.login({
|
|
485
742
|
orgName,
|
|
486
743
|
apiKey,
|
|
@@ -488,8 +745,8 @@ async function invoke(args) {
|
|
|
488
745
|
forceLogin,
|
|
489
746
|
fetch
|
|
490
747
|
});
|
|
491
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
492
|
-
const functionId =
|
|
748
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkTWCDSYJNjs.getSpanParentObject.call(void 0, ).export();
|
|
749
|
+
const functionId = _chunkTWCDSYJNjs.FunctionId.safeParse({
|
|
493
750
|
function_id: functionIdArgs.function_id,
|
|
494
751
|
project_name: functionIdArgs.projectName,
|
|
495
752
|
slug: functionIdArgs.slug,
|
|
@@ -532,7 +789,7 @@ async function invoke(args) {
|
|
|
532
789
|
if (!resp.body) {
|
|
533
790
|
throw new Error("Received empty stream body");
|
|
534
791
|
}
|
|
535
|
-
return new (0,
|
|
792
|
+
return new (0, _chunkTWCDSYJNjs.BraintrustStream)(resp.body);
|
|
536
793
|
} else {
|
|
537
794
|
const data = await resp.json();
|
|
538
795
|
return schema ? schema.parse(data) : data;
|
|
@@ -544,8 +801,8 @@ function initFunction({
|
|
|
544
801
|
version,
|
|
545
802
|
state
|
|
546
803
|
}) {
|
|
547
|
-
const s = _nullishCoalesce(state, () => (
|
|
548
|
-
_optionalChain([s, 'optionalAccess',
|
|
804
|
+
const s = _nullishCoalesce(state, () => ( _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, )));
|
|
805
|
+
_optionalChain([s, 'optionalAccess', _8 => _8.spanCache, 'optionalAccess', _9 => _9.disable, 'call', _10 => _10()]);
|
|
549
806
|
const f = async (input) => {
|
|
550
807
|
return await invoke({
|
|
551
808
|
projectName,
|
|
@@ -560,58 +817,6 @@ function initFunction({
|
|
|
560
817
|
return f;
|
|
561
818
|
}
|
|
562
819
|
|
|
563
|
-
// src/wrappers/openai-promise-utils.ts
|
|
564
|
-
function splitSpanInfo(allParams) {
|
|
565
|
-
const { span_info, ...params } = allParams;
|
|
566
|
-
return {
|
|
567
|
-
params,
|
|
568
|
-
span_info
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
function createChannelContext(_channel, params, span_info) {
|
|
572
|
-
return {
|
|
573
|
-
arguments: (
|
|
574
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
575
|
-
[params]
|
|
576
|
-
),
|
|
577
|
-
span_info
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
async function tracePromiseWithResponse(channel, traceContext, apiPromise) {
|
|
581
|
-
let enhancedResponse;
|
|
582
|
-
const tracePromise = (
|
|
583
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
584
|
-
channel.tracePromise
|
|
585
|
-
);
|
|
586
|
-
const data = await tracePromise(async () => {
|
|
587
|
-
enhancedResponse = await apiPromise.withResponse();
|
|
588
|
-
traceContext.response = enhancedResponse.response;
|
|
589
|
-
return enhancedResponse.data;
|
|
590
|
-
}, traceContext);
|
|
591
|
-
if (!enhancedResponse) {
|
|
592
|
-
throw new Error("Expected withResponse() to provide response");
|
|
593
|
-
}
|
|
594
|
-
return { data, response: enhancedResponse.response };
|
|
595
|
-
}
|
|
596
|
-
function createLazyAPIPromise(ensureExecuted) {
|
|
597
|
-
let dataPromise = null;
|
|
598
|
-
return new Proxy({}, {
|
|
599
|
-
get(target, prop, receiver) {
|
|
600
|
-
if (prop === "withResponse") {
|
|
601
|
-
return () => ensureExecuted();
|
|
602
|
-
}
|
|
603
|
-
if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
|
|
604
|
-
if (!dataPromise) {
|
|
605
|
-
dataPromise = ensureExecuted().then((result) => result.data);
|
|
606
|
-
}
|
|
607
|
-
const value = Reflect.get(dataPromise, prop, receiver);
|
|
608
|
-
return typeof value === "function" ? value.bind(dataPromise) : value;
|
|
609
|
-
}
|
|
610
|
-
return Reflect.get(target, prop, receiver);
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
|
|
615
820
|
// src/wrappers/oai_responses.ts
|
|
616
821
|
function responsesProxy(openai) {
|
|
617
822
|
if (!openai.responses) {
|
|
@@ -622,22 +827,22 @@ function responsesProxy(openai) {
|
|
|
622
827
|
if (name === "create" && typeof target.create === "function") {
|
|
623
828
|
return wrapResponsesAsync(
|
|
624
829
|
target.create.bind(target),
|
|
625
|
-
|
|
830
|
+
_chunk2XDW3UCGjs.openAIChannels.responsesCreate
|
|
626
831
|
);
|
|
627
832
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
628
833
|
return wrapResponsesSyncStream(
|
|
629
834
|
target.stream.bind(target),
|
|
630
|
-
|
|
835
|
+
_chunk2XDW3UCGjs.openAIChannels.responsesStream
|
|
631
836
|
);
|
|
632
837
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
633
838
|
return wrapResponsesAsync(
|
|
634
839
|
target.parse.bind(target),
|
|
635
|
-
|
|
840
|
+
_chunk2XDW3UCGjs.openAIChannels.responsesParse
|
|
636
841
|
);
|
|
637
842
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
638
843
|
return wrapResponsesAsync(
|
|
639
844
|
target.compact.bind(target),
|
|
640
|
-
|
|
845
|
+
_chunk2XDW3UCGjs.openAIChannels.responsesCompact
|
|
641
846
|
);
|
|
642
847
|
}
|
|
643
848
|
return Reflect.get(target, name, receiver);
|
|
@@ -648,17 +853,33 @@ function wrapResponsesAsync(target, channel) {
|
|
|
648
853
|
return (allParams, options) => {
|
|
649
854
|
const { span_info, params } = splitSpanInfo(allParams);
|
|
650
855
|
let executionPromise = null;
|
|
856
|
+
let apiPromise = null;
|
|
857
|
+
const getAPIPromise = () => {
|
|
858
|
+
apiPromise ??= target(params, options);
|
|
859
|
+
return apiPromise;
|
|
860
|
+
};
|
|
651
861
|
const ensureExecuted = () => {
|
|
652
862
|
if (!executionPromise) {
|
|
653
863
|
executionPromise = (async () => {
|
|
654
864
|
const traceContext = createChannelContext(channel, params, span_info);
|
|
655
|
-
|
|
656
|
-
|
|
865
|
+
return tracePromiseWithResponse(
|
|
866
|
+
channel,
|
|
867
|
+
traceContext,
|
|
868
|
+
getAPIPromise()
|
|
869
|
+
);
|
|
657
870
|
})();
|
|
658
871
|
}
|
|
659
872
|
return executionPromise;
|
|
660
873
|
};
|
|
661
|
-
return createLazyAPIPromise(
|
|
874
|
+
return createLazyAPIPromise(
|
|
875
|
+
ensureExecuted,
|
|
876
|
+
() => tracePromiseAsResponse(
|
|
877
|
+
channel,
|
|
878
|
+
createChannelContext(channel, params, span_info),
|
|
879
|
+
getAPIPromise()
|
|
880
|
+
),
|
|
881
|
+
getAPIPromise
|
|
882
|
+
);
|
|
662
883
|
};
|
|
663
884
|
}
|
|
664
885
|
function wrapResponsesSyncStream(target, channel) {
|
|
@@ -710,9 +931,9 @@ function wrapOpenAIv4(openai) {
|
|
|
710
931
|
const embeddingProxy = createEndpointProxy(typedOpenai.embeddings, wrapEmbeddings);
|
|
711
932
|
const moderationProxy = createEndpointProxy(typedOpenai.moderations, wrapModerations);
|
|
712
933
|
let betaProxy3;
|
|
713
|
-
if (_optionalChain([typedOpenai, 'access',
|
|
934
|
+
if (_optionalChain([typedOpenai, 'access', _11 => _11.beta, 'optionalAccess', _12 => _12.chat, 'optionalAccess', _13 => _13.completions, 'optionalAccess', _14 => _14.stream])) {
|
|
714
935
|
const betaChatCompletionProxy = new Proxy(
|
|
715
|
-
_optionalChain([typedOpenai, 'optionalAccess',
|
|
936
|
+
_optionalChain([typedOpenai, 'optionalAccess', _15 => _15.beta, 'optionalAccess', _16 => _16.chat, 'access', _17 => _17.completions]),
|
|
716
937
|
{
|
|
717
938
|
get(target, name, receiver) {
|
|
718
939
|
const baseVal = Reflect.get(target, name, receiver);
|
|
@@ -781,7 +1002,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
781
1002
|
const { span_info, params } = splitSpanInfo(
|
|
782
1003
|
allParams
|
|
783
1004
|
);
|
|
784
|
-
return
|
|
1005
|
+
return _chunk2XDW3UCGjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
785
1006
|
async () => await completion(params),
|
|
786
1007
|
{ arguments: [params], span_info }
|
|
787
1008
|
);
|
|
@@ -792,7 +1013,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
792
1013
|
const { span_info, params } = splitSpanInfo(
|
|
793
1014
|
allParams
|
|
794
1015
|
);
|
|
795
|
-
return
|
|
1016
|
+
return _chunk2XDW3UCGjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
796
1017
|
() => completion(params),
|
|
797
1018
|
{ arguments: [params], span_info }
|
|
798
1019
|
);
|
|
@@ -804,41 +1025,58 @@ function wrapChatCompletion(completion) {
|
|
|
804
1025
|
allParams
|
|
805
1026
|
);
|
|
806
1027
|
let executionPromise = null;
|
|
1028
|
+
let apiPromise = null;
|
|
1029
|
+
const getAPIPromise = () => {
|
|
1030
|
+
apiPromise ??= completion(params, options);
|
|
1031
|
+
return apiPromise;
|
|
1032
|
+
};
|
|
807
1033
|
const ensureExecuted = () => {
|
|
808
1034
|
if (!executionPromise) {
|
|
809
1035
|
executionPromise = (async () => {
|
|
810
1036
|
const traceContext = createChannelContext(
|
|
811
|
-
|
|
1037
|
+
_chunk2XDW3UCGjs.openAIChannels.chatCompletionsCreate,
|
|
812
1038
|
params,
|
|
813
1039
|
span_info
|
|
814
1040
|
);
|
|
815
1041
|
if (params.stream) {
|
|
816
|
-
const completionPromise =
|
|
817
|
-
|
|
818
|
-
|
|
1042
|
+
const completionPromise = (
|
|
1043
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1044
|
+
getAPIPromise()
|
|
819
1045
|
);
|
|
820
|
-
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
821
|
-
|
|
1046
|
+
const { data: data2, response: response2, request_id: request_id2 } = await tracePromiseWithResponse(
|
|
1047
|
+
_chunk2XDW3UCGjs.openAIChannels.chatCompletionsCreate,
|
|
822
1048
|
traceContext,
|
|
823
1049
|
completionPromise
|
|
824
1050
|
);
|
|
825
|
-
return { data: data2, response: response2 };
|
|
1051
|
+
return { data: data2, response: response2, request_id: request_id2 };
|
|
826
1052
|
}
|
|
827
|
-
const completionResponse =
|
|
828
|
-
|
|
829
|
-
|
|
1053
|
+
const completionResponse = (
|
|
1054
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1055
|
+
getAPIPromise()
|
|
830
1056
|
);
|
|
831
|
-
const { data, response } = await tracePromiseWithResponse(
|
|
832
|
-
|
|
1057
|
+
const { data, response, request_id } = await tracePromiseWithResponse(
|
|
1058
|
+
_chunk2XDW3UCGjs.openAIChannels.chatCompletionsCreate,
|
|
833
1059
|
traceContext,
|
|
834
1060
|
completionResponse
|
|
835
1061
|
);
|
|
836
|
-
return { data, response };
|
|
1062
|
+
return { data, response, request_id };
|
|
837
1063
|
})();
|
|
838
1064
|
}
|
|
839
1065
|
return executionPromise;
|
|
840
1066
|
};
|
|
841
|
-
return createLazyAPIPromise(
|
|
1067
|
+
return createLazyAPIPromise(
|
|
1068
|
+
ensureExecuted,
|
|
1069
|
+
() => tracePromiseAsResponse(
|
|
1070
|
+
_chunk2XDW3UCGjs.openAIChannels.chatCompletionsCreate,
|
|
1071
|
+
createChannelContext(
|
|
1072
|
+
_chunk2XDW3UCGjs.openAIChannels.chatCompletionsCreate,
|
|
1073
|
+
params,
|
|
1074
|
+
span_info
|
|
1075
|
+
),
|
|
1076
|
+
getAPIPromise()
|
|
1077
|
+
),
|
|
1078
|
+
getAPIPromise
|
|
1079
|
+
);
|
|
842
1080
|
};
|
|
843
1081
|
}
|
|
844
1082
|
function createEndpointProxy(target, wrapperFn) {
|
|
@@ -856,6 +1094,11 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
856
1094
|
return (allParams, options) => {
|
|
857
1095
|
const { span_info, params } = splitSpanInfo(allParams);
|
|
858
1096
|
let executionPromise = null;
|
|
1097
|
+
let apiPromise = null;
|
|
1098
|
+
const getAPIPromise = () => {
|
|
1099
|
+
apiPromise ??= create(params, options);
|
|
1100
|
+
return apiPromise;
|
|
1101
|
+
};
|
|
859
1102
|
const ensureExecuted = () => {
|
|
860
1103
|
if (!executionPromise) {
|
|
861
1104
|
executionPromise = (async () => {
|
|
@@ -863,24 +1106,32 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
863
1106
|
return tracePromiseWithResponse(
|
|
864
1107
|
channel,
|
|
865
1108
|
traceContext,
|
|
866
|
-
|
|
1109
|
+
getAPIPromise()
|
|
867
1110
|
);
|
|
868
1111
|
})();
|
|
869
1112
|
}
|
|
870
1113
|
return executionPromise;
|
|
871
1114
|
};
|
|
872
|
-
return createLazyAPIPromise(
|
|
1115
|
+
return createLazyAPIPromise(
|
|
1116
|
+
ensureExecuted,
|
|
1117
|
+
() => tracePromiseAsResponse(
|
|
1118
|
+
channel,
|
|
1119
|
+
createChannelContext(channel, params, span_info),
|
|
1120
|
+
getAPIPromise()
|
|
1121
|
+
),
|
|
1122
|
+
getAPIPromise
|
|
1123
|
+
);
|
|
873
1124
|
};
|
|
874
1125
|
}
|
|
875
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
876
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
1126
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunk2XDW3UCGjs.openAIChannels.embeddingsCreate);
|
|
1127
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunk2XDW3UCGjs.openAIChannels.moderationsCreate);
|
|
877
1128
|
|
|
878
1129
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
879
1130
|
function isModuleNamespace(obj) {
|
|
880
1131
|
if (!obj || typeof obj !== "object") {
|
|
881
1132
|
return false;
|
|
882
1133
|
}
|
|
883
|
-
if (_optionalChain([obj, 'access',
|
|
1134
|
+
if (_optionalChain([obj, 'access', _18 => _18.constructor, 'optionalAccess', _19 => _19.name]) === "Module") {
|
|
884
1135
|
return true;
|
|
885
1136
|
}
|
|
886
1137
|
try {
|
|
@@ -889,7 +1140,7 @@ function isModuleNamespace(obj) {
|
|
|
889
1140
|
const firstKey = keys[0];
|
|
890
1141
|
const descriptor = Object.getOwnPropertyDescriptor(obj, firstKey);
|
|
891
1142
|
return descriptor ? !descriptor.configurable && !descriptor.writable : false;
|
|
892
|
-
} catch (
|
|
1143
|
+
} catch (e4) {
|
|
893
1144
|
return false;
|
|
894
1145
|
}
|
|
895
1146
|
}
|
|
@@ -944,17 +1195,17 @@ function isHarnessAgentInstance(instance) {
|
|
|
944
1195
|
let prototype = Object.getPrototypeOf(instance);
|
|
945
1196
|
while (prototype !== null && !visited.has(prototype)) {
|
|
946
1197
|
visited.add(prototype);
|
|
947
|
-
const constructor = _optionalChain([Object, 'access',
|
|
1198
|
+
const constructor = _optionalChain([Object, 'access', _20 => _20.getOwnPropertyDescriptor, 'call', _21 => _21(
|
|
948
1199
|
prototype,
|
|
949
1200
|
"constructor"
|
|
950
|
-
), 'optionalAccess',
|
|
951
|
-
const constructorName = typeof constructor === "function" ? _optionalChain([Object, 'access',
|
|
1201
|
+
), 'optionalAccess', _22 => _22.value]);
|
|
1202
|
+
const constructorName = typeof constructor === "function" ? _optionalChain([Object, 'access', _23 => _23.getOwnPropertyDescriptor, 'call', _24 => _24(constructor, "name"), 'optionalAccess', _25 => _25.value]) : void 0;
|
|
952
1203
|
if (constructorName === "HarnessAgent") {
|
|
953
1204
|
return true;
|
|
954
1205
|
}
|
|
955
1206
|
prototype = Object.getPrototypeOf(prototype);
|
|
956
1207
|
}
|
|
957
|
-
} catch (
|
|
1208
|
+
} catch (e5) {
|
|
958
1209
|
}
|
|
959
1210
|
return false;
|
|
960
1211
|
}
|
|
@@ -983,7 +1234,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
983
1234
|
return wrapHarnessAgentGenerate(
|
|
984
1235
|
original,
|
|
985
1236
|
harnessAgent,
|
|
986
|
-
|
|
1237
|
+
_chunk2XDW3UCGjs.harnessAgentChannels.generate,
|
|
987
1238
|
"HarnessAgent.generate",
|
|
988
1239
|
options
|
|
989
1240
|
);
|
|
@@ -991,7 +1242,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
991
1242
|
return wrapHarnessAgentStream(
|
|
992
1243
|
original,
|
|
993
1244
|
harnessAgent,
|
|
994
|
-
|
|
1245
|
+
_chunk2XDW3UCGjs.harnessAgentChannels.stream,
|
|
995
1246
|
"HarnessAgent.stream",
|
|
996
1247
|
options
|
|
997
1248
|
);
|
|
@@ -999,7 +1250,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
999
1250
|
return wrapHarnessAgentGenerate(
|
|
1000
1251
|
original,
|
|
1001
1252
|
harnessAgent,
|
|
1002
|
-
|
|
1253
|
+
_chunk2XDW3UCGjs.harnessAgentChannels.continueGenerate,
|
|
1003
1254
|
"HarnessAgent.continueGenerate",
|
|
1004
1255
|
options
|
|
1005
1256
|
);
|
|
@@ -1007,7 +1258,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
1007
1258
|
return wrapHarnessAgentStream(
|
|
1008
1259
|
original,
|
|
1009
1260
|
harnessAgent,
|
|
1010
|
-
|
|
1261
|
+
_chunk2XDW3UCGjs.harnessAgentChannels.continueStream,
|
|
1011
1262
|
"HarnessAgent.continueStream",
|
|
1012
1263
|
options
|
|
1013
1264
|
);
|
|
@@ -1030,7 +1281,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
1030
1281
|
};
|
|
1031
1282
|
var wrapHarnessAgentCreateSession = (createSession, instance) => {
|
|
1032
1283
|
const wrapper = function(params) {
|
|
1033
|
-
return
|
|
1284
|
+
return _chunk2XDW3UCGjs.harnessAgentChannels.createSession.tracePromise(
|
|
1034
1285
|
() => params === void 0 ? createSession.call(instance) : createSession.call(instance, params),
|
|
1035
1286
|
createAISDKChannelContext(_nullishCoalesce(params, () => ( {})), { self: instance })
|
|
1036
1287
|
);
|
|
@@ -1076,15 +1327,15 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
1076
1327
|
};
|
|
1077
1328
|
function generateChannelForAgent(agentName) {
|
|
1078
1329
|
if (agentName === "ToolLoopAgent") {
|
|
1079
|
-
return
|
|
1330
|
+
return _chunk2XDW3UCGjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
1080
1331
|
}
|
|
1081
|
-
return
|
|
1332
|
+
return _chunk2XDW3UCGjs.aiSDKChannels.agentGenerate;
|
|
1082
1333
|
}
|
|
1083
1334
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
1084
1335
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
1085
1336
|
return (params) => {
|
|
1086
1337
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
1087
|
-
if (workflowAgent &&
|
|
1338
|
+
if (workflowAgent && _chunkTWCDSYJNjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
1088
1339
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
1089
1340
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
1090
1341
|
}
|
|
@@ -1103,12 +1354,12 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
1103
1354
|
};
|
|
1104
1355
|
function streamChannelForAgent(agentName) {
|
|
1105
1356
|
if (agentName === "ToolLoopAgent") {
|
|
1106
|
-
return
|
|
1357
|
+
return _chunk2XDW3UCGjs.aiSDKChannels.toolLoopAgentStream;
|
|
1107
1358
|
}
|
|
1108
1359
|
if (agentName === "WorkflowAgent") {
|
|
1109
|
-
return
|
|
1360
|
+
return _chunk2XDW3UCGjs.aiSDKChannels.workflowAgentStream;
|
|
1110
1361
|
}
|
|
1111
|
-
return
|
|
1362
|
+
return _chunk2XDW3UCGjs.aiSDKChannels.agentStream;
|
|
1112
1363
|
}
|
|
1113
1364
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
1114
1365
|
const wrapper = async function(allParams) {
|
|
@@ -1132,7 +1383,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
1132
1383
|
};
|
|
1133
1384
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
1134
1385
|
return makeGenerateTextWrapper(
|
|
1135
|
-
|
|
1386
|
+
_chunk2XDW3UCGjs.aiSDKChannels.generateText,
|
|
1136
1387
|
"generateText",
|
|
1137
1388
|
generateText,
|
|
1138
1389
|
{ aiSDK },
|
|
@@ -1141,7 +1392,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
1141
1392
|
};
|
|
1142
1393
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
1143
1394
|
return makeGenerateTextWrapper(
|
|
1144
|
-
|
|
1395
|
+
_chunk2XDW3UCGjs.aiSDKChannels.generateObject,
|
|
1145
1396
|
"generateObject",
|
|
1146
1397
|
generateObject,
|
|
1147
1398
|
{ aiSDK },
|
|
@@ -1155,7 +1406,7 @@ var makeGenerateImageWrapper = (generateImage, contextOptions = {}, options = {}
|
|
|
1155
1406
|
const wrapper = async function(allParams) {
|
|
1156
1407
|
const { span_info, ...params } = allParams;
|
|
1157
1408
|
const tracedParams = { ...params };
|
|
1158
|
-
return
|
|
1409
|
+
return _chunk2XDW3UCGjs.aiSDKChannels.generateImage.tracePromise(
|
|
1159
1410
|
() => generateImage(tracedParams),
|
|
1160
1411
|
createAISDKChannelContext(tracedParams, {
|
|
1161
1412
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1196,7 +1447,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
1196
1447
|
};
|
|
1197
1448
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
1198
1449
|
return makeEmbedWrapper(
|
|
1199
|
-
|
|
1450
|
+
_chunk2XDW3UCGjs.aiSDKChannels.embed,
|
|
1200
1451
|
"embed",
|
|
1201
1452
|
embed,
|
|
1202
1453
|
{ aiSDK },
|
|
@@ -1205,7 +1456,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1205
1456
|
};
|
|
1206
1457
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1207
1458
|
return makeEmbedWrapper(
|
|
1208
|
-
|
|
1459
|
+
_chunk2XDW3UCGjs.aiSDKChannels.embedMany,
|
|
1209
1460
|
"embedMany",
|
|
1210
1461
|
embedMany,
|
|
1211
1462
|
{ aiSDK },
|
|
@@ -1216,7 +1467,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1216
1467
|
const wrapper = async function(allParams) {
|
|
1217
1468
|
const { span_info, ...params } = allParams;
|
|
1218
1469
|
const tracedParams = { ...params };
|
|
1219
|
-
return
|
|
1470
|
+
return _chunk2XDW3UCGjs.aiSDKChannels.rerank.tracePromise(
|
|
1220
1471
|
() => rerank(tracedParams),
|
|
1221
1472
|
createAISDKChannelContext(tracedParams, {
|
|
1222
1473
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1255,7 +1506,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1255
1506
|
};
|
|
1256
1507
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1257
1508
|
return makeStreamWrapper(
|
|
1258
|
-
|
|
1509
|
+
_chunk2XDW3UCGjs.aiSDKChannels.streamText,
|
|
1259
1510
|
"streamText",
|
|
1260
1511
|
streamText,
|
|
1261
1512
|
{ aiSDK },
|
|
@@ -1264,7 +1515,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1264
1515
|
};
|
|
1265
1516
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1266
1517
|
return makeStreamWrapper(
|
|
1267
|
-
|
|
1518
|
+
_chunk2XDW3UCGjs.aiSDKChannels.streamObject,
|
|
1268
1519
|
"streamObject",
|
|
1269
1520
|
streamObject,
|
|
1270
1521
|
{ aiSDK },
|
|
@@ -1277,11 +1528,11 @@ function mergeSpanInfo(spanInfo, defaults) {
|
|
|
1277
1528
|
}
|
|
1278
1529
|
return {
|
|
1279
1530
|
...spanInfo,
|
|
1280
|
-
..._optionalChain([spanInfo, 'optionalAccess',
|
|
1281
|
-
...defaults.spanType !== void 0 || _optionalChain([spanInfo, 'optionalAccess',
|
|
1531
|
+
..._optionalChain([spanInfo, 'optionalAccess', _26 => _26.name]) ? {} : defaults.name ? { name: defaults.name } : {},
|
|
1532
|
+
...defaults.spanType !== void 0 || _optionalChain([spanInfo, 'optionalAccess', _27 => _27.spanAttributes]) ? {
|
|
1282
1533
|
spanAttributes: {
|
|
1283
1534
|
...defaults.spanType !== void 0 ? { type: defaults.spanType } : {},
|
|
1284
|
-
..._nullishCoalesce(_optionalChain([spanInfo, 'optionalAccess',
|
|
1535
|
+
..._nullishCoalesce(_optionalChain([spanInfo, 'optionalAccess', _28 => _28.spanAttributes]), () => ( {}))
|
|
1285
1536
|
}
|
|
1286
1537
|
} : {}
|
|
1287
1538
|
};
|
|
@@ -1299,7 +1550,7 @@ function createAISDKChannelContext(params, context = {}) {
|
|
|
1299
1550
|
// src/wrappers/ai-sdk/deprecated/wrapAISDKModel.ts
|
|
1300
1551
|
function wrapAISDKModel(model) {
|
|
1301
1552
|
const m = model;
|
|
1302
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
1553
|
+
if (_optionalChain([m, 'optionalAccess', _29 => _29.specificationVersion]) === "v1" && typeof _optionalChain([m, 'optionalAccess', _30 => _30.provider]) === "string" && typeof _optionalChain([m, 'optionalAccess', _31 => _31.modelId]) === "string") {
|
|
1303
1554
|
return new BraintrustLanguageModelWrapper(m);
|
|
1304
1555
|
} else {
|
|
1305
1556
|
console.warn("Unsupported AI SDK model. Not wrapping.");
|
|
@@ -1336,19 +1587,19 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1336
1587
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1337
1588
|
// propagate those via async local storage
|
|
1338
1589
|
async doGenerate(options) {
|
|
1339
|
-
const span =
|
|
1340
|
-
|
|
1590
|
+
const span = _chunkTWCDSYJNjs.startSpan.call(void 0,
|
|
1591
|
+
_chunk2XDW3UCGjs.withSpanInstrumentationName.call(void 0,
|
|
1341
1592
|
{
|
|
1342
1593
|
name: "Chat Completion",
|
|
1343
1594
|
spanAttributes: {
|
|
1344
1595
|
type: "llm"
|
|
1345
1596
|
}
|
|
1346
1597
|
},
|
|
1347
|
-
|
|
1598
|
+
_chunk2XDW3UCGjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1348
1599
|
)
|
|
1349
1600
|
);
|
|
1350
1601
|
const { prompt, mode, ...rest } = options;
|
|
1351
|
-
const startTime =
|
|
1602
|
+
const startTime = _chunkTWCDSYJNjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1352
1603
|
try {
|
|
1353
1604
|
const ret = await this.model.doGenerate(options);
|
|
1354
1605
|
span.log({
|
|
@@ -1360,12 +1611,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1360
1611
|
},
|
|
1361
1612
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1362
1613
|
metrics: {
|
|
1363
|
-
time_to_first_token:
|
|
1364
|
-
tokens: !
|
|
1365
|
-
prompt_tokens: _optionalChain([ret, 'access',
|
|
1366
|
-
completion_tokens: _optionalChain([ret, 'access',
|
|
1367
|
-
cached:
|
|
1368
|
-
_nullishCoalesce(_optionalChain([ret, 'access',
|
|
1614
|
+
time_to_first_token: _chunkTWCDSYJNjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1615
|
+
tokens: !_chunkTWCDSYJNjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1616
|
+
prompt_tokens: _optionalChain([ret, 'access', _32 => _32.usage, 'optionalAccess', _33 => _33.promptTokens]),
|
|
1617
|
+
completion_tokens: _optionalChain([ret, 'access', _34 => _34.usage, 'optionalAccess', _35 => _35.completionTokens]),
|
|
1618
|
+
cached: _chunkTWCDSYJNjs.parseCachedHeader.call(void 0,
|
|
1619
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _36 => _36.rawResponse, 'optionalAccess', _37 => _37.headers, 'optionalAccess', _38 => _38[_chunkTWCDSYJNjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _39 => _39.rawResponse, 'optionalAccess', _40 => _40.headers, 'optionalAccess', _41 => _41[_chunkTWCDSYJNjs.LEGACY_CACHED_HEADER]])))
|
|
1369
1620
|
)
|
|
1370
1621
|
}
|
|
1371
1622
|
});
|
|
@@ -1376,16 +1627,16 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1376
1627
|
}
|
|
1377
1628
|
async doStream(options) {
|
|
1378
1629
|
const { prompt, mode, ...rest } = options;
|
|
1379
|
-
const startTime =
|
|
1380
|
-
const span =
|
|
1381
|
-
|
|
1630
|
+
const startTime = _chunkTWCDSYJNjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1631
|
+
const span = _chunkTWCDSYJNjs.startSpan.call(void 0,
|
|
1632
|
+
_chunk2XDW3UCGjs.withSpanInstrumentationName.call(void 0,
|
|
1382
1633
|
{
|
|
1383
1634
|
name: "Chat Completion",
|
|
1384
1635
|
spanAttributes: {
|
|
1385
1636
|
type: "llm"
|
|
1386
1637
|
}
|
|
1387
1638
|
},
|
|
1388
|
-
|
|
1639
|
+
_chunk2XDW3UCGjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1389
1640
|
)
|
|
1390
1641
|
);
|
|
1391
1642
|
span.log({
|
|
@@ -1416,7 +1667,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1416
1667
|
new TransformStream({
|
|
1417
1668
|
transform(chunk, controller) {
|
|
1418
1669
|
if (time_to_first_token === void 0) {
|
|
1419
|
-
time_to_first_token =
|
|
1670
|
+
time_to_first_token = _chunkTWCDSYJNjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1420
1671
|
span.log({ metrics: { time_to_first_token } });
|
|
1421
1672
|
}
|
|
1422
1673
|
switch (chunk.type) {
|
|
@@ -1461,11 +1712,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1461
1712
|
),
|
|
1462
1713
|
metrics: {
|
|
1463
1714
|
time_to_first_token,
|
|
1464
|
-
tokens: !
|
|
1465
|
-
prompt_tokens: _optionalChain([usage, 'optionalAccess',
|
|
1466
|
-
completion_tokens: _optionalChain([usage, 'optionalAccess',
|
|
1467
|
-
cached:
|
|
1468
|
-
_nullishCoalesce(_optionalChain([ret, 'access',
|
|
1715
|
+
tokens: !_chunkTWCDSYJNjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1716
|
+
prompt_tokens: _optionalChain([usage, 'optionalAccess', _42 => _42.promptTokens]),
|
|
1717
|
+
completion_tokens: _optionalChain([usage, 'optionalAccess', _43 => _43.completionTokens]),
|
|
1718
|
+
cached: _chunkTWCDSYJNjs.parseCachedHeader.call(void 0,
|
|
1719
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _44 => _44.rawResponse, 'optionalAccess', _45 => _45.headers, 'optionalAccess', _46 => _46[_chunkTWCDSYJNjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _47 => _47.rawResponse, 'optionalAccess', _48 => _48.headers, 'optionalAccess', _49 => _49[_chunkTWCDSYJNjs.LEGACY_CACHED_HEADER]])))
|
|
1469
1720
|
)
|
|
1470
1721
|
}
|
|
1471
1722
|
});
|
|
@@ -1509,7 +1760,7 @@ function postProcessPrompt(prompt) {
|
|
|
1509
1760
|
return [
|
|
1510
1761
|
{
|
|
1511
1762
|
role: "assistant",
|
|
1512
|
-
content: _optionalChain([textPart, 'optionalAccess',
|
|
1763
|
+
content: _optionalChain([textPart, 'optionalAccess', _50 => _50.text]),
|
|
1513
1764
|
...toolCallParts.length > 0 ? {
|
|
1514
1765
|
tool_calls: toolCallParts.map((part) => ({
|
|
1515
1766
|
id: part.toolCallId,
|
|
@@ -1582,23 +1833,23 @@ function postProcessOutput(text, toolCalls2, finishReason) {
|
|
|
1582
1833
|
|
|
1583
1834
|
// src/wrappers/ai-sdk/deprecated/BraintrustMiddleware.ts
|
|
1584
1835
|
function detectProviderFromResult(result) {
|
|
1585
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
1836
|
+
if (!_optionalChain([result, 'optionalAccess', _51 => _51.providerMetadata])) {
|
|
1586
1837
|
return void 0;
|
|
1587
1838
|
}
|
|
1588
1839
|
const keys = Object.keys(result.providerMetadata);
|
|
1589
|
-
return _optionalChain([keys, 'optionalAccess',
|
|
1840
|
+
return _optionalChain([keys, 'optionalAccess', _52 => _52.at, 'call', _53 => _53(0)]);
|
|
1590
1841
|
}
|
|
1591
1842
|
function extractModelFromResult(result) {
|
|
1592
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
1843
|
+
if (_optionalChain([result, 'optionalAccess', _54 => _54.response, 'optionalAccess', _55 => _55.modelId])) {
|
|
1593
1844
|
return result.response.modelId;
|
|
1594
1845
|
}
|
|
1595
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
1846
|
+
if (_optionalChain([result, 'optionalAccess', _56 => _56.request, 'optionalAccess', _57 => _57.body, 'optionalAccess', _58 => _58.model])) {
|
|
1596
1847
|
return result.request.body.model;
|
|
1597
1848
|
}
|
|
1598
1849
|
return void 0;
|
|
1599
1850
|
}
|
|
1600
1851
|
function extractModelFromWrapGenerateCallback(model) {
|
|
1601
|
-
return _optionalChain([model, 'optionalAccess',
|
|
1852
|
+
return _optionalChain([model, 'optionalAccess', _59 => _59.modelId]);
|
|
1602
1853
|
}
|
|
1603
1854
|
function camelToSnake(str) {
|
|
1604
1855
|
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
@@ -1643,19 +1894,19 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1643
1894
|
metrics.prompt_cached_tokens = cachedInputTokens;
|
|
1644
1895
|
}
|
|
1645
1896
|
if (provider === "anthropic") {
|
|
1646
|
-
const anthropicMetadata = _optionalChain([providerMetadata, 'optionalAccess',
|
|
1897
|
+
const anthropicMetadata = _optionalChain([providerMetadata, 'optionalAccess', _60 => _60.anthropic]);
|
|
1647
1898
|
if (anthropicMetadata) {
|
|
1648
1899
|
const cacheReadTokens = getNumberProperty(anthropicMetadata.usage, "cache_read_input_tokens") || 0;
|
|
1649
1900
|
const cacheCreationTokens = getNumberProperty(
|
|
1650
1901
|
anthropicMetadata.usage,
|
|
1651
1902
|
"cache_creation_input_tokens"
|
|
1652
1903
|
) || 0;
|
|
1653
|
-
const cacheTokens =
|
|
1904
|
+
const cacheTokens = _chunkTWCDSYJNjs.extractAnthropicCacheTokens.call(void 0,
|
|
1654
1905
|
cacheReadTokens,
|
|
1655
1906
|
cacheCreationTokens
|
|
1656
1907
|
);
|
|
1657
1908
|
Object.assign(metrics, cacheTokens);
|
|
1658
|
-
return
|
|
1909
|
+
return _chunkTWCDSYJNjs.toNumericMetrics.call(void 0, _chunkTWCDSYJNjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1659
1910
|
}
|
|
1660
1911
|
}
|
|
1661
1912
|
return metrics;
|
|
@@ -1669,7 +1920,7 @@ function buildAssistantOutputWithToolCalls(result, toolCalls2) {
|
|
|
1669
1920
|
{
|
|
1670
1921
|
index: 0,
|
|
1671
1922
|
logprobs: null,
|
|
1672
|
-
finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess',
|
|
1923
|
+
finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess', _61 => _61.finishReason])), () => ( (toolCalls2.length ? "tool_calls" : void 0))),
|
|
1673
1924
|
message: {
|
|
1674
1925
|
role: "assistant",
|
|
1675
1926
|
tool_calls: toolCalls2.length > 0 ? toolCalls2 : void 0
|
|
@@ -1682,7 +1933,7 @@ function extractToolCallsFromSteps(steps) {
|
|
|
1682
1933
|
if (!Array.isArray(steps)) return toolCalls2;
|
|
1683
1934
|
let idx = 0;
|
|
1684
1935
|
for (const step of steps) {
|
|
1685
|
-
const blocks = _optionalChain([step, 'optionalAccess',
|
|
1936
|
+
const blocks = _optionalChain([step, 'optionalAccess', _62 => _62.content]);
|
|
1686
1937
|
if (!Array.isArray(blocks)) continue;
|
|
1687
1938
|
for (const block of blocks) {
|
|
1688
1939
|
if (block && typeof block === "object" && block.type === "tool-call") {
|
|
@@ -1705,7 +1956,7 @@ function extractToolCallsFromBlocks(blocks) {
|
|
|
1705
1956
|
return extractToolCallsFromSteps([{ content: blocks }]);
|
|
1706
1957
|
}
|
|
1707
1958
|
function extractInput(params) {
|
|
1708
|
-
return _nullishCoalesce(_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
1959
|
+
return _nullishCoalesce(_nullishCoalesce(_optionalChain([params, 'optionalAccess', _63 => _63.prompt]), () => ( _optionalChain([params, 'optionalAccess', _64 => _64.messages]))), () => ( _optionalChain([params, 'optionalAccess', _65 => _65.system])));
|
|
1709
1960
|
}
|
|
1710
1961
|
var V2_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
1711
1962
|
"prompt",
|
|
@@ -1727,23 +1978,23 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1727
1978
|
model: modelFromWrapGenerate
|
|
1728
1979
|
}) => {
|
|
1729
1980
|
const rawInput = extractInput(params);
|
|
1730
|
-
const processedInput =
|
|
1981
|
+
const processedInput = _chunkTWCDSYJNjs.processInputAttachments.call(void 0, rawInput);
|
|
1731
1982
|
const spanArgs = {
|
|
1732
|
-
name: _optionalChain([config, 'access',
|
|
1983
|
+
name: _optionalChain([config, 'access', _66 => _66.spanInfo, 'optionalAccess', _67 => _67.name]) || "ai-sdk.doGenerate",
|
|
1733
1984
|
spanAttributes: {
|
|
1734
1985
|
type: "llm" /* LLM */,
|
|
1735
|
-
..._optionalChain([config, 'access',
|
|
1986
|
+
..._optionalChain([config, 'access', _68 => _68.spanInfo, 'optionalAccess', _69 => _69.spanAttributes]) || {}
|
|
1736
1987
|
},
|
|
1737
1988
|
event: {
|
|
1738
1989
|
input: processedInput,
|
|
1739
1990
|
metadata: {
|
|
1740
1991
|
...extractModelParameters(params, V2_EXCLUDE_KEYS),
|
|
1741
|
-
..._optionalChain([config, 'access',
|
|
1992
|
+
..._optionalChain([config, 'access', _70 => _70.spanInfo, 'optionalAccess', _71 => _71.metadata]) || {}
|
|
1742
1993
|
}
|
|
1743
1994
|
}
|
|
1744
1995
|
};
|
|
1745
|
-
const span =
|
|
1746
|
-
|
|
1996
|
+
const span = _chunkTWCDSYJNjs.startSpan.call(void 0,
|
|
1997
|
+
_chunk2XDW3UCGjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunk2XDW3UCGjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1747
1998
|
);
|
|
1748
1999
|
try {
|
|
1749
2000
|
const result = await doGenerate();
|
|
@@ -1766,12 +2017,12 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1766
2017
|
metadata.model = modelId;
|
|
1767
2018
|
}
|
|
1768
2019
|
}
|
|
1769
|
-
let toolCalls2 = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess',
|
|
2020
|
+
let toolCalls2 = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess', _72 => _72.steps]));
|
|
1770
2021
|
if (!toolCalls2 || toolCalls2.length === 0) {
|
|
1771
|
-
toolCalls2 = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess',
|
|
2022
|
+
toolCalls2 = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess', _73 => _73.content]));
|
|
1772
2023
|
}
|
|
1773
2024
|
span.log({
|
|
1774
|
-
output: toolCalls2.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls2) : _optionalChain([result, 'optionalAccess',
|
|
2025
|
+
output: toolCalls2.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls2) : _optionalChain([result, 'optionalAccess', _74 => _74.content]),
|
|
1775
2026
|
metadata,
|
|
1776
2027
|
metrics: normalizeUsageMetrics(
|
|
1777
2028
|
result.usage,
|
|
@@ -1791,23 +2042,23 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1791
2042
|
},
|
|
1792
2043
|
wrapStream: async ({ doStream, params }) => {
|
|
1793
2044
|
const rawInput = extractInput(params);
|
|
1794
|
-
const processedInput =
|
|
2045
|
+
const processedInput = _chunkTWCDSYJNjs.processInputAttachments.call(void 0, rawInput);
|
|
1795
2046
|
const spanArgs = {
|
|
1796
|
-
name: _optionalChain([config, 'access',
|
|
2047
|
+
name: _optionalChain([config, 'access', _75 => _75.spanInfo, 'optionalAccess', _76 => _76.name]) || "ai-sdk.doStream",
|
|
1797
2048
|
spanAttributes: {
|
|
1798
2049
|
type: "llm" /* LLM */,
|
|
1799
|
-
..._optionalChain([config, 'access',
|
|
2050
|
+
..._optionalChain([config, 'access', _77 => _77.spanInfo, 'optionalAccess', _78 => _78.spanAttributes]) || {}
|
|
1800
2051
|
},
|
|
1801
2052
|
event: {
|
|
1802
2053
|
input: processedInput,
|
|
1803
2054
|
metadata: {
|
|
1804
2055
|
...extractModelParameters(params, V2_EXCLUDE_KEYS),
|
|
1805
|
-
..._optionalChain([config, 'access',
|
|
2056
|
+
..._optionalChain([config, 'access', _79 => _79.spanInfo, 'optionalAccess', _80 => _80.metadata]) || {}
|
|
1806
2057
|
}
|
|
1807
2058
|
}
|
|
1808
2059
|
};
|
|
1809
|
-
const span =
|
|
1810
|
-
|
|
2060
|
+
const span = _chunkTWCDSYJNjs.startSpan.call(void 0,
|
|
2061
|
+
_chunk2XDW3UCGjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunk2XDW3UCGjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1811
2062
|
);
|
|
1812
2063
|
try {
|
|
1813
2064
|
const { stream, ...rest } = await doStream();
|
|
@@ -1932,7 +2183,7 @@ function createLegacyEveInstrumentation(options) {
|
|
|
1932
2183
|
try {
|
|
1933
2184
|
captureEveModelInput(state, input);
|
|
1934
2185
|
} catch (error) {
|
|
1935
|
-
|
|
2186
|
+
_chunk2XDW3UCGjs.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1936
2187
|
}
|
|
1937
2188
|
}
|
|
1938
2189
|
},
|
|
@@ -1942,7 +2193,7 @@ function createLegacyEveInstrumentation(options) {
|
|
|
1942
2193
|
};
|
|
1943
2194
|
}
|
|
1944
2195
|
function isEveHandleMessageStreamEvent(event) {
|
|
1945
|
-
return
|
|
2196
|
+
return _chunkTWCDSYJNjs.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1946
2197
|
}
|
|
1947
2198
|
var ResumedEveSpan = class {
|
|
1948
2199
|
constructor(reference) {
|
|
@@ -1959,11 +2210,11 @@ var ResumedEveSpan = class {
|
|
|
1959
2210
|
}
|
|
1960
2211
|
log(event) {
|
|
1961
2212
|
const metrics = {
|
|
1962
|
-
..._optionalChain([this, 'access',
|
|
2213
|
+
..._optionalChain([this, 'access', _81 => _81.reference, 'access', _82 => _82.startEvent, 'optionalAccess', _83 => _83.metrics]),
|
|
1963
2214
|
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1964
2215
|
...event.metrics
|
|
1965
2216
|
};
|
|
1966
|
-
|
|
2217
|
+
_chunkTWCDSYJNjs.updateSpan.call(void 0, {
|
|
1967
2218
|
exported: this.reference.exported,
|
|
1968
2219
|
...this.reference.startEvent,
|
|
1969
2220
|
...event,
|
|
@@ -1972,7 +2223,7 @@ var ResumedEveSpan = class {
|
|
|
1972
2223
|
}
|
|
1973
2224
|
end(args) {
|
|
1974
2225
|
if (this.endTime === void 0) {
|
|
1975
|
-
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
2226
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _84 => _84.endTime]), () => ( _chunkTWCDSYJNjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1976
2227
|
this.log({ metrics: { end: this.endTime } });
|
|
1977
2228
|
}
|
|
1978
2229
|
return this.endTime;
|
|
@@ -1984,41 +2235,41 @@ var EveBridge = (_class = class {
|
|
|
1984
2235
|
}
|
|
1985
2236
|
|
|
1986
2237
|
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1987
|
-
__init2() {this.completedToolKeys = new (0,
|
|
2238
|
+
__init2() {this.completedToolKeys = new (0, _chunkTWCDSYJNjs.LRUCache)({
|
|
1988
2239
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1989
2240
|
})}
|
|
1990
|
-
__init3() {this.toolsByCallKey = new (0,
|
|
2241
|
+
__init3() {this.toolsByCallKey = new (0, _chunkTWCDSYJNjs.LRUCache)({
|
|
1991
2242
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1992
2243
|
})}
|
|
1993
|
-
__init4() {this.turnsByKey = new (0,
|
|
2244
|
+
__init4() {this.turnsByKey = new (0, _chunkTWCDSYJNjs.LRUCache)({
|
|
1994
2245
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1995
2246
|
})}
|
|
1996
2247
|
async startEveSpan(args) {
|
|
1997
|
-
const rowId = _optionalChain([args, 'optionalAccess',
|
|
2248
|
+
const rowId = _optionalChain([args, 'optionalAccess', _85 => _85.event, 'optionalAccess', _86 => _86.id]);
|
|
1998
2249
|
const reference = typeof rowId === "string" && readEveTraceState(this.state).spanReferences.find(
|
|
1999
2250
|
(candidate) => candidate.rowId === rowId
|
|
2000
2251
|
);
|
|
2001
2252
|
if (reference) {
|
|
2002
2253
|
return new ResumedEveSpan(reference);
|
|
2003
2254
|
}
|
|
2004
|
-
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
2005
|
-
const parentSpanIds = _optionalChain([args, 'optionalAccess',
|
|
2255
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _87 => _87.startTime]), () => ( _chunkTWCDSYJNjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
2256
|
+
const parentSpanIds = _optionalChain([args, 'optionalAccess', _88 => _88.parentSpanIds]);
|
|
2006
2257
|
const startEvent = {
|
|
2007
2258
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2008
2259
|
metrics: { start: startTime },
|
|
2009
2260
|
span_attributes: {
|
|
2010
|
-
..._optionalChain([args, 'optionalAccess',
|
|
2011
|
-
..._optionalChain([args, 'optionalAccess',
|
|
2012
|
-
..._optionalChain([args, 'optionalAccess',
|
|
2261
|
+
..._optionalChain([args, 'optionalAccess', _89 => _89.name]) ? { name: args.name } : {},
|
|
2262
|
+
..._optionalChain([args, 'optionalAccess', _90 => _90.type]) ? { type: args.type } : {},
|
|
2263
|
+
..._optionalChain([args, 'optionalAccess', _91 => _91.spanAttributes])
|
|
2013
2264
|
},
|
|
2014
2265
|
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
2015
2266
|
};
|
|
2016
|
-
const span =
|
|
2017
|
-
|
|
2018
|
-
() =>
|
|
2019
|
-
|
|
2267
|
+
const span = _chunkTWCDSYJNjs.withCurrent.call(void 0,
|
|
2268
|
+
_chunkTWCDSYJNjs.NOOP_SPAN,
|
|
2269
|
+
() => _chunkTWCDSYJNjs._internalStartSpanWithInitialMerge.call(void 0,
|
|
2270
|
+
_chunk2XDW3UCGjs.withSpanInstrumentationName.call(void 0,
|
|
2020
2271
|
{ ...args, startTime },
|
|
2021
|
-
|
|
2272
|
+
_chunk2XDW3UCGjs.INSTRUMENTATION_NAMES.EVE
|
|
2022
2273
|
)
|
|
2023
2274
|
)
|
|
2024
2275
|
);
|
|
@@ -2046,7 +2297,7 @@ var EveBridge = (_class = class {
|
|
|
2046
2297
|
};
|
|
2047
2298
|
});
|
|
2048
2299
|
} catch (error) {
|
|
2049
|
-
|
|
2300
|
+
_chunk2XDW3UCGjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
2050
2301
|
}
|
|
2051
2302
|
return span;
|
|
2052
2303
|
}
|
|
@@ -2066,7 +2317,7 @@ var EveBridge = (_class = class {
|
|
|
2066
2317
|
const previous = state.stepStarts.filter(
|
|
2067
2318
|
(entry) => entry.turnId === event.data.turnId && entry.stepIndex === event.data.stepIndex
|
|
2068
2319
|
).at(-1);
|
|
2069
|
-
if (_optionalChain([previous, 'optionalAccess',
|
|
2320
|
+
if (_optionalChain([previous, 'optionalAccess', _92 => _92.open])) {
|
|
2070
2321
|
ordinal = previous.ordinal;
|
|
2071
2322
|
return state;
|
|
2072
2323
|
}
|
|
@@ -2094,12 +2345,12 @@ var EveBridge = (_class = class {
|
|
|
2094
2345
|
let index = -1;
|
|
2095
2346
|
for (let i = state.stepStarts.length - 1; i >= 0; i--) {
|
|
2096
2347
|
const entry = state.stepStarts[i];
|
|
2097
|
-
if (_optionalChain([entry, 'optionalAccess',
|
|
2348
|
+
if (_optionalChain([entry, 'optionalAccess', _93 => _93.turnId]) === turnId && entry.stepIndex === stepIndex) {
|
|
2098
2349
|
index = i;
|
|
2099
2350
|
break;
|
|
2100
2351
|
}
|
|
2101
2352
|
}
|
|
2102
|
-
if (index < 0 || !_optionalChain([state, 'access',
|
|
2353
|
+
if (index < 0 || !_optionalChain([state, 'access', _94 => _94.stepStarts, 'access', _95 => _95[index], 'optionalAccess', _96 => _96.open])) {
|
|
2103
2354
|
return state;
|
|
2104
2355
|
}
|
|
2105
2356
|
return {
|
|
@@ -2133,7 +2384,7 @@ var EveBridge = (_class = class {
|
|
|
2133
2384
|
}
|
|
2134
2385
|
}
|
|
2135
2386
|
} catch (error) {
|
|
2136
|
-
|
|
2387
|
+
_chunk2XDW3UCGjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
2137
2388
|
}
|
|
2138
2389
|
};
|
|
2139
2390
|
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
@@ -2361,7 +2612,7 @@ var EveBridge = (_class = class {
|
|
|
2361
2612
|
return;
|
|
2362
2613
|
}
|
|
2363
2614
|
const existingMessage = eveOutputMessage(step.output);
|
|
2364
|
-
const existingToolCalls =
|
|
2615
|
+
const existingToolCalls = _chunkTWCDSYJNjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2365
2616
|
step.output = mergeEveReasoning(
|
|
2366
2617
|
[
|
|
2367
2618
|
{
|
|
@@ -2425,11 +2676,11 @@ var EveBridge = (_class = class {
|
|
|
2425
2676
|
return;
|
|
2426
2677
|
}
|
|
2427
2678
|
const toolCallsById = /* @__PURE__ */ new Map();
|
|
2428
|
-
if (Array.isArray(step.output) &&
|
|
2679
|
+
if (Array.isArray(step.output) && _chunkTWCDSYJNjs.isObject.call(void 0, step.output[0])) {
|
|
2429
2680
|
const message = step.output[0]["message"];
|
|
2430
|
-
if (
|
|
2681
|
+
if (_chunkTWCDSYJNjs.isObject.call(void 0, message) && Array.isArray(message["tool_calls"])) {
|
|
2431
2682
|
for (const toolCall of message["tool_calls"]) {
|
|
2432
|
-
if (
|
|
2683
|
+
if (_chunkTWCDSYJNjs.isObject.call(void 0, toolCall) && typeof toolCall["id"] === "string") {
|
|
2433
2684
|
toolCallsById.set(toolCall["id"], toolCall);
|
|
2434
2685
|
}
|
|
2435
2686
|
}
|
|
@@ -2502,7 +2753,7 @@ var EveBridge = (_class = class {
|
|
|
2502
2753
|
this.completedToolKeys.set(key, true);
|
|
2503
2754
|
}
|
|
2504
2755
|
async handleSubagentCalled(event, ctx, hookMetadata) {
|
|
2505
|
-
if (_optionalChain([event, 'access',
|
|
2756
|
+
if (_optionalChain([event, 'access', _97 => _97.data, 'access', _98 => _98.remote, 'optionalAccess', _99 => _99.url])) {
|
|
2506
2757
|
return;
|
|
2507
2758
|
}
|
|
2508
2759
|
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
@@ -2622,11 +2873,11 @@ var EveBridge = (_class = class {
|
|
|
2622
2873
|
return;
|
|
2623
2874
|
}
|
|
2624
2875
|
const usage = event.data.usage;
|
|
2625
|
-
const inputTokens = typeof _optionalChain([usage, 'optionalAccess',
|
|
2626
|
-
const outputTokens = typeof _optionalChain([usage, 'optionalAccess',
|
|
2627
|
-
const cacheReadTokens = typeof _optionalChain([usage, 'optionalAccess',
|
|
2628
|
-
const cacheWriteTokens = typeof _optionalChain([usage, 'optionalAccess',
|
|
2629
|
-
const costUsd = typeof _optionalChain([usage, 'optionalAccess',
|
|
2876
|
+
const inputTokens = typeof _optionalChain([usage, 'optionalAccess', _100 => _100.inputTokens]) === "number" && Number.isFinite(usage.inputTokens) && usage.inputTokens >= 0 ? usage.inputTokens : void 0;
|
|
2877
|
+
const outputTokens = typeof _optionalChain([usage, 'optionalAccess', _101 => _101.outputTokens]) === "number" && Number.isFinite(usage.outputTokens) && usage.outputTokens >= 0 ? usage.outputTokens : void 0;
|
|
2878
|
+
const cacheReadTokens = typeof _optionalChain([usage, 'optionalAccess', _102 => _102.cacheReadTokens]) === "number" && Number.isFinite(usage.cacheReadTokens) && usage.cacheReadTokens >= 0 ? usage.cacheReadTokens : void 0;
|
|
2879
|
+
const cacheWriteTokens = typeof _optionalChain([usage, 'optionalAccess', _103 => _103.cacheWriteTokens]) === "number" && Number.isFinite(usage.cacheWriteTokens) && usage.cacheWriteTokens >= 0 ? usage.cacheWriteTokens : void 0;
|
|
2880
|
+
const costUsd = typeof _optionalChain([usage, 'optionalAccess', _104 => _104.costUsd]) === "number" && Number.isFinite(usage.costUsd) && usage.costUsd >= 0 ? usage.costUsd : void 0;
|
|
2630
2881
|
const total = inputTokens !== void 0 && outputTokens !== void 0 ? inputTokens + outputTokens : void 0;
|
|
2631
2882
|
const metrics = {
|
|
2632
2883
|
...inputTokens !== void 0 ? { prompt_tokens: inputTokens } : {},
|
|
@@ -2638,7 +2889,7 @@ var EveBridge = (_class = class {
|
|
|
2638
2889
|
};
|
|
2639
2890
|
step.metrics = { ...step.metrics, ...metrics };
|
|
2640
2891
|
const sessionId = sessionIdFromContext(ctx);
|
|
2641
|
-
if (Array.isArray(step.output) &&
|
|
2892
|
+
if (Array.isArray(step.output) && _chunkTWCDSYJNjs.isObject.call(void 0, step.output[0])) {
|
|
2642
2893
|
const finishReason = step.output[0].finish_reason;
|
|
2643
2894
|
if (typeof finishReason !== "string") {
|
|
2644
2895
|
step.output[0].finish_reason = normalizedFinishReason(
|
|
@@ -2685,7 +2936,7 @@ var EveBridge = (_class = class {
|
|
|
2685
2936
|
step.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2686
2937
|
}
|
|
2687
2938
|
const turn = this.turnForEvent(event, ctx);
|
|
2688
|
-
_optionalChain([turn, 'optionalAccess',
|
|
2939
|
+
_optionalChain([turn, 'optionalAccess', _105 => _105.stepsByIndex, 'access', _106 => _106.delete, 'call', _107 => _107(event.data.stepIndex)]);
|
|
2689
2940
|
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2690
2941
|
const sessionId = sessionIdFromContext(ctx);
|
|
2691
2942
|
if (sessionId) {
|
|
@@ -2976,10 +3227,10 @@ var EveBridge = (_class = class {
|
|
|
2976
3227
|
return state;
|
|
2977
3228
|
}
|
|
2978
3229
|
async startTurnSpan(sessionId, event, ctx, metadata) {
|
|
2979
|
-
const session =
|
|
2980
|
-
const parent =
|
|
2981
|
-
const parentTurn =
|
|
2982
|
-
const parentLineage =
|
|
3230
|
+
const session = _chunkTWCDSYJNjs.isObject.call(void 0, ctx) ? ctx["session"] : void 0;
|
|
3231
|
+
const parent = _chunkTWCDSYJNjs.isObject.call(void 0, session) ? session["parent"] : void 0;
|
|
3232
|
+
const parentTurn = _chunkTWCDSYJNjs.isObject.call(void 0, parent) ? parent["turn"] : void 0;
|
|
3233
|
+
const parentLineage = _chunkTWCDSYJNjs.isObject.call(void 0, parent) && typeof parent["callId"] === "string" && typeof parent["sessionId"] === "string" && _chunkTWCDSYJNjs.isObject.call(void 0, parentTurn) && typeof parentTurn["id"] === "string" ? {
|
|
2983
3234
|
callId: parent["callId"],
|
|
2984
3235
|
sessionId: parent["sessionId"],
|
|
2985
3236
|
turnId: parentTurn["id"]
|
|
@@ -2988,8 +3239,8 @@ var EveBridge = (_class = class {
|
|
|
2988
3239
|
generateEveIds("turn", sessionId, event.data.turnId),
|
|
2989
3240
|
deterministicEveId(
|
|
2990
3241
|
"eve:root",
|
|
2991
|
-
_nullishCoalesce(_optionalChain([parentLineage, 'optionalAccess',
|
|
2992
|
-
_nullishCoalesce(_optionalChain([parentLineage, 'optionalAccess',
|
|
3242
|
+
_nullishCoalesce(_optionalChain([parentLineage, 'optionalAccess', _108 => _108.sessionId]), () => ( sessionId)),
|
|
3243
|
+
_nullishCoalesce(_optionalChain([parentLineage, 'optionalAccess', _109 => _109.turnId]), () => ( event.data.turnId))
|
|
2993
3244
|
),
|
|
2994
3245
|
parentLineage ? deterministicEveId(
|
|
2995
3246
|
"eve:subagent",
|
|
@@ -3014,7 +3265,7 @@ var EveBridge = (_class = class {
|
|
|
3014
3265
|
return sessionId ? this.turnsByKey.get(turnKey(sessionId, event.data.turnId)) : void 0;
|
|
3015
3266
|
}
|
|
3016
3267
|
stepForEvent(event, ctx) {
|
|
3017
|
-
return _optionalChain([this, 'access',
|
|
3268
|
+
return _optionalChain([this, 'access', _110 => _110.turnForEvent, 'call', _111 => _111(event, ctx), 'optionalAccess', _112 => _112.stepsByIndex, 'access', _113 => _113.get, 'call', _114 => _114(
|
|
3018
3269
|
event.data.stepIndex
|
|
3019
3270
|
)]);
|
|
3020
3271
|
}
|
|
@@ -3086,10 +3337,10 @@ var EveBridge = (_class = class {
|
|
|
3086
3337
|
}
|
|
3087
3338
|
async flushInstrumentation() {
|
|
3088
3339
|
try {
|
|
3089
|
-
await
|
|
3340
|
+
await _chunkTWCDSYJNjs.flush.call(void 0, );
|
|
3090
3341
|
return true;
|
|
3091
3342
|
} catch (error) {
|
|
3092
|
-
|
|
3343
|
+
_chunk2XDW3UCGjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
3093
3344
|
return false;
|
|
3094
3345
|
}
|
|
3095
3346
|
}
|
|
@@ -3104,12 +3355,12 @@ function emptyEveTraceState() {
|
|
|
3104
3355
|
};
|
|
3105
3356
|
}
|
|
3106
3357
|
function normalizeEveTraceState(state) {
|
|
3107
|
-
if (!
|
|
3358
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, state)) {
|
|
3108
3359
|
return emptyEveTraceState();
|
|
3109
3360
|
}
|
|
3110
|
-
const metadata =
|
|
3361
|
+
const metadata = _chunkTWCDSYJNjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
3111
3362
|
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
3112
|
-
if (!
|
|
3363
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, entry)) {
|
|
3113
3364
|
return [];
|
|
3114
3365
|
}
|
|
3115
3366
|
const exported = entry["exported"];
|
|
@@ -3118,11 +3369,11 @@ function normalizeEveTraceState(state) {
|
|
|
3118
3369
|
const rowId = entry["rowId"];
|
|
3119
3370
|
const spanId = entry["spanId"];
|
|
3120
3371
|
const startEvent = entry["startEvent"];
|
|
3121
|
-
const startEventCreated =
|
|
3122
|
-
const startEventMetrics =
|
|
3123
|
-
const startEventSpanAttributes =
|
|
3124
|
-
const startEventSpanParents =
|
|
3125
|
-
const normalizedStartEvent = typeof startEventCreated === "string" &&
|
|
3372
|
+
const startEventCreated = _chunkTWCDSYJNjs.isObject.call(void 0, startEvent) ? startEvent["created"] : void 0;
|
|
3373
|
+
const startEventMetrics = _chunkTWCDSYJNjs.isObject.call(void 0, startEvent) ? startEvent["metrics"] : void 0;
|
|
3374
|
+
const startEventSpanAttributes = _chunkTWCDSYJNjs.isObject.call(void 0, startEvent) ? startEvent["span_attributes"] : void 0;
|
|
3375
|
+
const startEventSpanParents = _chunkTWCDSYJNjs.isObject.call(void 0, startEvent) ? startEvent["span_parents"] : void 0;
|
|
3376
|
+
const normalizedStartEvent = typeof startEventCreated === "string" && _chunkTWCDSYJNjs.isObject.call(void 0, startEventMetrics) && typeof startEventMetrics["start"] === "number" && Number.isFinite(startEventMetrics["start"]) && _chunkTWCDSYJNjs.isObject.call(void 0, startEventSpanAttributes) && Array.isArray(startEventSpanParents) && startEventSpanParents.every(
|
|
3126
3377
|
(parent) => typeof parent === "string"
|
|
3127
3378
|
) ? {
|
|
3128
3379
|
created: startEventCreated,
|
|
@@ -3142,7 +3393,7 @@ function normalizeEveTraceState(state) {
|
|
|
3142
3393
|
] : [];
|
|
3143
3394
|
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
3144
3395
|
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
3145
|
-
if (!
|
|
3396
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, entry)) {
|
|
3146
3397
|
return [];
|
|
3147
3398
|
}
|
|
3148
3399
|
const key = entry["key"];
|
|
@@ -3150,7 +3401,7 @@ function normalizeEveTraceState(state) {
|
|
|
3150
3401
|
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
3151
3402
|
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
3152
3403
|
const reasoningBlocks = Array.isArray(state["reasoningBlocks"]) ? state["reasoningBlocks"].flatMap((entry) => {
|
|
3153
|
-
if (!
|
|
3404
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, entry)) {
|
|
3154
3405
|
return [];
|
|
3155
3406
|
}
|
|
3156
3407
|
const content = entry["content"];
|
|
@@ -3165,7 +3416,7 @@ function normalizeEveTraceState(state) {
|
|
|
3165
3416
|
] : [];
|
|
3166
3417
|
}).slice(-MAX_STORED_REASONING_BLOCKS) : [];
|
|
3167
3418
|
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
3168
|
-
if (!
|
|
3419
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, entry)) {
|
|
3169
3420
|
return [];
|
|
3170
3421
|
}
|
|
3171
3422
|
const ordinal = entry["ordinal"];
|
|
@@ -3185,12 +3436,12 @@ function normalizeEveTraceState(state) {
|
|
|
3185
3436
|
function readEveTraceState(state) {
|
|
3186
3437
|
try {
|
|
3187
3438
|
return normalizeEveTraceState(state.get());
|
|
3188
|
-
} catch (
|
|
3439
|
+
} catch (e6) {
|
|
3189
3440
|
return emptyEveTraceState();
|
|
3190
3441
|
}
|
|
3191
3442
|
}
|
|
3192
3443
|
function storeEveReasoning(state, sessionId, event) {
|
|
3193
|
-
const eventAt = _optionalChain([event, 'access',
|
|
3444
|
+
const eventAt = _optionalChain([event, 'access', _115 => _115.meta, 'optionalAccess', _116 => _116.at]);
|
|
3194
3445
|
const key = llmInputKey(sessionId, event.data.turnId, event.data.stepIndex);
|
|
3195
3446
|
let stored = [];
|
|
3196
3447
|
state.update((current) => {
|
|
@@ -3242,14 +3493,14 @@ function clearStoredEveReasoning(state, sessionId, turnId, stepIndex) {
|
|
|
3242
3493
|
});
|
|
3243
3494
|
}
|
|
3244
3495
|
function eveOutputMessage(output) {
|
|
3245
|
-
return Array.isArray(output) &&
|
|
3496
|
+
return Array.isArray(output) && _chunkTWCDSYJNjs.isObject.call(void 0, output[0]) ? output[0]["message"] : void 0;
|
|
3246
3497
|
}
|
|
3247
3498
|
function mergeEveReasoning(output, reasoning) {
|
|
3248
3499
|
if (reasoning.length === 0) {
|
|
3249
3500
|
return output;
|
|
3250
3501
|
}
|
|
3251
|
-
const choice = Array.isArray(output) &&
|
|
3252
|
-
const message =
|
|
3502
|
+
const choice = Array.isArray(output) && _chunkTWCDSYJNjs.isObject.call(void 0, output[0]) ? output[0] : {};
|
|
3503
|
+
const message = _chunkTWCDSYJNjs.isObject.call(void 0, choice["message"]) ? choice["message"] : {};
|
|
3253
3504
|
return [
|
|
3254
3505
|
{
|
|
3255
3506
|
...choice,
|
|
@@ -3293,7 +3544,7 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3293
3544
|
if (index < 0) {
|
|
3294
3545
|
return normalized;
|
|
3295
3546
|
}
|
|
3296
|
-
input = _optionalChain([normalized, 'access',
|
|
3547
|
+
input = _optionalChain([normalized, 'access', _117 => _117.llmInputs, 'access', _118 => _118[index], 'optionalAccess', _119 => _119.input]);
|
|
3297
3548
|
return {
|
|
3298
3549
|
...normalized,
|
|
3299
3550
|
llmInputs: normalized.llmInputs.filter(
|
|
@@ -3303,7 +3554,7 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3303
3554
|
});
|
|
3304
3555
|
return input;
|
|
3305
3556
|
} catch (error) {
|
|
3306
|
-
|
|
3557
|
+
_chunk2XDW3UCGjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
3307
3558
|
return void 0;
|
|
3308
3559
|
}
|
|
3309
3560
|
}
|
|
@@ -3324,7 +3575,7 @@ function capturedModelInput(modelInput) {
|
|
|
3324
3575
|
return void 0;
|
|
3325
3576
|
}
|
|
3326
3577
|
return cloned;
|
|
3327
|
-
} catch (
|
|
3578
|
+
} catch (e7) {
|
|
3328
3579
|
return void 0;
|
|
3329
3580
|
}
|
|
3330
3581
|
}
|
|
@@ -3443,14 +3694,14 @@ function capturedEveModelContentPart(part) {
|
|
|
3443
3694
|
}
|
|
3444
3695
|
function isCapturedModelInput(input) {
|
|
3445
3696
|
return Array.isArray(input) && input.every(
|
|
3446
|
-
(message) =>
|
|
3697
|
+
(message) => _chunkTWCDSYJNjs.isObject.call(void 0, message) && (message["role"] === "system" || message["role"] === "user" || message["role"] === "assistant" || message["role"] === "tool") && (typeof message["content"] === "string" || Array.isArray(message["content"]) && message["content"].every(_chunkTWCDSYJNjs.isObject))
|
|
3447
3698
|
);
|
|
3448
3699
|
}
|
|
3449
3700
|
function llmInputKey(sessionId, turnId, stepIndex) {
|
|
3450
3701
|
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3451
3702
|
}
|
|
3452
3703
|
function modelMetadataFromRuntime(runtime) {
|
|
3453
|
-
if (!
|
|
3704
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, runtime)) {
|
|
3454
3705
|
return {};
|
|
3455
3706
|
}
|
|
3456
3707
|
const modelId = runtime["modelId"];
|
|
@@ -3473,11 +3724,11 @@ function modelMetadataFromModelId(modelId) {
|
|
|
3473
3724
|
};
|
|
3474
3725
|
}
|
|
3475
3726
|
function sessionIdFromContext(ctx) {
|
|
3476
|
-
if (!
|
|
3727
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, ctx)) {
|
|
3477
3728
|
return void 0;
|
|
3478
3729
|
}
|
|
3479
3730
|
const session = ctx["session"];
|
|
3480
|
-
if (!
|
|
3731
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, session)) {
|
|
3481
3732
|
return void 0;
|
|
3482
3733
|
}
|
|
3483
3734
|
const id = session["id"];
|
|
@@ -3488,19 +3739,19 @@ function toolMetadataFromTurn(turn) {
|
|
|
3488
3739
|
return metadata;
|
|
3489
3740
|
}
|
|
3490
3741
|
function isToolCallAction(action) {
|
|
3491
|
-
return
|
|
3742
|
+
return _chunkTWCDSYJNjs.isObject.call(void 0, action) && action["kind"] === "tool-call" && typeof action["callId"] === "string" && typeof action["toolName"] === "string" && _chunkTWCDSYJNjs.isObject.call(void 0, action["input"]);
|
|
3492
3743
|
}
|
|
3493
3744
|
function isLocalSubagentCallAction(action) {
|
|
3494
|
-
return
|
|
3745
|
+
return _chunkTWCDSYJNjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkTWCDSYJNjs.isObject.call(void 0, action["input"]);
|
|
3495
3746
|
}
|
|
3496
3747
|
function isTraceableActionRequest(action) {
|
|
3497
3748
|
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3498
3749
|
}
|
|
3499
3750
|
function isToolResult(result) {
|
|
3500
|
-
return
|
|
3751
|
+
return _chunkTWCDSYJNjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3501
3752
|
}
|
|
3502
3753
|
function isSubagentResult(result) {
|
|
3503
|
-
return
|
|
3754
|
+
return _chunkTWCDSYJNjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3504
3755
|
}
|
|
3505
3756
|
function normalizedFinishReason(finishReason) {
|
|
3506
3757
|
switch (finishReason) {
|
|
@@ -3530,7 +3781,7 @@ function actionResultError(error, output) {
|
|
|
3530
3781
|
return result;
|
|
3531
3782
|
}
|
|
3532
3783
|
function eventTime(event) {
|
|
3533
|
-
if (!_optionalChain([event, 'access',
|
|
3784
|
+
if (!_optionalChain([event, 'access', _120 => _120.meta, 'optionalAccess', _121 => _121.at])) {
|
|
3534
3785
|
return void 0;
|
|
3535
3786
|
}
|
|
3536
3787
|
const timestamp = Date.parse(event.meta.at);
|
|
@@ -3564,7 +3815,15 @@ var MAX_EVE_PROVIDER_CACHE_ENTRIES = 1e4;
|
|
|
3564
3815
|
function createEveInstrumentationProvider(options = {}) {
|
|
3565
3816
|
const bridge = new EveProviderBridge(options.metadata);
|
|
3566
3817
|
return {
|
|
3818
|
+
// Eve versions before tracePolicy use capture to decide whether provider
|
|
3819
|
+
// events include content. Newer versions prefer tracePolicy when both are
|
|
3820
|
+
// present, so keep the deprecated field for backwards compatibility.
|
|
3567
3821
|
capture: "content",
|
|
3822
|
+
tracePolicy: () => ({
|
|
3823
|
+
emit: true,
|
|
3824
|
+
recordInputs: true,
|
|
3825
|
+
recordOutputs: true
|
|
3826
|
+
}),
|
|
3568
3827
|
events: {
|
|
3569
3828
|
"action.completed": (event, context) => bridge.handleActionTerminal(event, context),
|
|
3570
3829
|
"action.failed": (event, context) => bridge.handleActionTerminal(event, context),
|
|
@@ -3579,7 +3838,7 @@ function createEveInstrumentationProvider(options = {}) {
|
|
|
3579
3838
|
"turn.failed": (event, context) => bridge.handleTurnTerminal(event, context),
|
|
3580
3839
|
"turn.started": (event, context) => bridge.handleTurnStarted(event, context)
|
|
3581
3840
|
},
|
|
3582
|
-
flush:
|
|
3841
|
+
flush: _chunkTWCDSYJNjs.flush,
|
|
3583
3842
|
setup: options.setup
|
|
3584
3843
|
};
|
|
3585
3844
|
}
|
|
@@ -3591,10 +3850,10 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3591
3850
|
__init5() {this.activeActions = /* @__PURE__ */ new Map()}
|
|
3592
3851
|
__init6() {this.activeModels = /* @__PURE__ */ new Map()}
|
|
3593
3852
|
__init7() {this.modelsByAttempt = /* @__PURE__ */ new Map()}
|
|
3594
|
-
__init8() {this.settledOperations = new (0,
|
|
3853
|
+
__init8() {this.settledOperations = new (0, _chunkTWCDSYJNjs.LRUCache)({
|
|
3595
3854
|
max: MAX_EVE_PROVIDER_CACHE_ENTRIES
|
|
3596
3855
|
})}
|
|
3597
|
-
__init9() {this.turns = new (0,
|
|
3856
|
+
__init9() {this.turns = new (0, _chunkTWCDSYJNjs.LRUCache)({
|
|
3598
3857
|
max: MAX_EVE_PROVIDER_CACHE_ENTRIES
|
|
3599
3858
|
})}
|
|
3600
3859
|
async handleTurnStarted(event, context) {
|
|
@@ -3621,7 +3880,7 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3621
3880
|
event.parentLineage.turnId
|
|
3622
3881
|
);
|
|
3623
3882
|
const parentTurn = this.turns.get(parentTurnKey);
|
|
3624
|
-
rootSpanId = await _asyncNullishCoalesce(await _asyncOptionalChain([parentTurn, 'optionalAccess', async
|
|
3883
|
+
rootSpanId = await _asyncNullishCoalesce(await _asyncOptionalChain([parentTurn, 'optionalAccess', async _122 => _122.rootSpanId]), async () => ( // Eve propagates the root session through every nested subagent. Use
|
|
3625
3884
|
// it instead of the immediate parent session when no ancestor ran
|
|
3626
3885
|
// in-process.
|
|
3627
3886
|
(await generateEveIds(
|
|
@@ -3652,7 +3911,7 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3652
3911
|
},
|
|
3653
3912
|
rootSpanId
|
|
3654
3913
|
);
|
|
3655
|
-
_optionalChain([span, 'optionalAccess',
|
|
3914
|
+
_optionalChain([span, 'optionalAccess', _123 => _123.log, 'call', _124 => _124({ metadata })]);
|
|
3656
3915
|
this.turns.set(key, {
|
|
3657
3916
|
rootSpanId,
|
|
3658
3917
|
spanId
|
|
@@ -3669,7 +3928,7 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3669
3928
|
this.drainActionsForTurn(event.sessionId, event.turnId, error);
|
|
3670
3929
|
const stored = storedSpan(context);
|
|
3671
3930
|
if (stored && "exported" in stored) {
|
|
3672
|
-
|
|
3931
|
+
_chunkTWCDSYJNjs.updateSpan.call(void 0, {
|
|
3673
3932
|
exported: stored.exported,
|
|
3674
3933
|
...error !== void 0 ? { error } : {},
|
|
3675
3934
|
metrics: { end: Date.now() / 1e3 }
|
|
@@ -3740,7 +3999,7 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3740
3999
|
} else {
|
|
3741
4000
|
const stored = storedSpan(context);
|
|
3742
4001
|
if (stored && "exported" in stored) {
|
|
3743
|
-
|
|
4002
|
+
_chunkTWCDSYJNjs.updateSpan.call(void 0, {
|
|
3744
4003
|
exported: stored.exported,
|
|
3745
4004
|
...event.type === "model.call.failed" ? event.error !== void 0 ? { error: event.error } : {} : { output: modelOutput(event) },
|
|
3746
4005
|
metrics: {
|
|
@@ -3799,7 +4058,7 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3799
4058
|
return;
|
|
3800
4059
|
}
|
|
3801
4060
|
const stored = storedSpan(context);
|
|
3802
|
-
if (_optionalChain([stored, 'optionalAccess',
|
|
4061
|
+
if (_optionalChain([stored, 'optionalAccess', _125 => _125.skip])) {
|
|
3803
4062
|
context.state.set(void 0);
|
|
3804
4063
|
return;
|
|
3805
4064
|
}
|
|
@@ -3822,7 +4081,7 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3822
4081
|
} else {
|
|
3823
4082
|
const stored2 = storedSpan(context);
|
|
3824
4083
|
if (stored2 && "exported" in stored2) {
|
|
3825
|
-
|
|
4084
|
+
_chunkTWCDSYJNjs.updateSpan.call(void 0, {
|
|
3826
4085
|
exported: stored2.exported,
|
|
3827
4086
|
...event.type === "action.failed" ? {
|
|
3828
4087
|
error: _nullishCoalesce(event.error, () => ( new Error(_nullishCoalesce(event.errorCode, () => ( `Eve action ${event.outcome}`)))))
|
|
@@ -3873,10 +4132,10 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3873
4132
|
return { rootSpanId, spanId };
|
|
3874
4133
|
}
|
|
3875
4134
|
async startSpan(context, args, rootSpanId) {
|
|
3876
|
-
const span =
|
|
3877
|
-
|
|
3878
|
-
() =>
|
|
3879
|
-
|
|
4135
|
+
const span = _chunkTWCDSYJNjs.withCurrent.call(void 0,
|
|
4136
|
+
_chunkTWCDSYJNjs.NOOP_SPAN,
|
|
4137
|
+
() => _chunkTWCDSYJNjs._internalStartSpanWithInitialMerge.call(void 0,
|
|
4138
|
+
_chunk2XDW3UCGjs.withSpanInstrumentationName.call(void 0, _nullishCoalesce(args, () => ( {})), _chunk2XDW3UCGjs.INSTRUMENTATION_NAMES.EVE)
|
|
3880
4139
|
)
|
|
3881
4140
|
);
|
|
3882
4141
|
try {
|
|
@@ -3885,7 +4144,7 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3885
4144
|
...rootSpanId ? { rootSpanId } : {}
|
|
3886
4145
|
});
|
|
3887
4146
|
} catch (error) {
|
|
3888
|
-
|
|
4147
|
+
_chunk2XDW3UCGjs.debugLogger.warn("Error exporting Eve provider span:", error);
|
|
3889
4148
|
}
|
|
3890
4149
|
return span;
|
|
3891
4150
|
}
|
|
@@ -3901,8 +4160,8 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3901
4160
|
forgetModel(attemptId, idempotencyKey) {
|
|
3902
4161
|
this.activeModels.delete(idempotencyKey);
|
|
3903
4162
|
const keys = this.modelsByAttempt.get(attemptId);
|
|
3904
|
-
_optionalChain([keys, 'optionalAccess',
|
|
3905
|
-
if (_optionalChain([keys, 'optionalAccess',
|
|
4163
|
+
_optionalChain([keys, 'optionalAccess', _126 => _126.delete, 'call', _127 => _127(idempotencyKey)]);
|
|
4164
|
+
if (_optionalChain([keys, 'optionalAccess', _128 => _128.size]) === 0) this.modelsByAttempt.delete(attemptId);
|
|
3906
4165
|
}
|
|
3907
4166
|
spanMetadata(sessionId) {
|
|
3908
4167
|
return {
|
|
@@ -3914,13 +4173,13 @@ var EveProviderBridge = (_class2 = class {
|
|
|
3914
4173
|
try {
|
|
3915
4174
|
await fn();
|
|
3916
4175
|
} catch (error) {
|
|
3917
|
-
|
|
4176
|
+
_chunk2XDW3UCGjs.debugLogger.warn(`Error in Eve provider ${operation}:`, error);
|
|
3918
4177
|
}
|
|
3919
4178
|
}
|
|
3920
4179
|
}, _class2);
|
|
3921
4180
|
function storedSpan(context) {
|
|
3922
4181
|
const value = context.state.get();
|
|
3923
|
-
if (!
|
|
4182
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, value)) return void 0;
|
|
3924
4183
|
if (value["skip"] === true) return { skip: true };
|
|
3925
4184
|
return typeof value["exported"] === "string" ? {
|
|
3926
4185
|
exported: value["exported"],
|
|
@@ -3965,10 +4224,10 @@ function usageMetrics(usage) {
|
|
|
3965
4224
|
const promptTokens = nonNegativeNumber(usage.inputTokens);
|
|
3966
4225
|
const completionTokens = nonNegativeNumber(usage.outputTokens);
|
|
3967
4226
|
const cachedTokens = nonNegativeNumber(
|
|
3968
|
-
_optionalChain([usage, 'access',
|
|
4227
|
+
_optionalChain([usage, 'access', _129 => _129.inputTokenDetails, 'optionalAccess', _130 => _130.cacheReadTokens])
|
|
3969
4228
|
);
|
|
3970
4229
|
const cacheCreationTokens = nonNegativeNumber(
|
|
3971
|
-
_optionalChain([usage, 'access',
|
|
4230
|
+
_optionalChain([usage, 'access', _131 => _131.inputTokenDetails, 'optionalAccess', _132 => _132.cacheWriteTokens])
|
|
3972
4231
|
);
|
|
3973
4232
|
return {
|
|
3974
4233
|
...promptTokens !== void 0 ? { prompt_tokens: promptTokens } : {},
|
|
@@ -3992,7 +4251,7 @@ function normalizeFinishReason2(value) {
|
|
|
3992
4251
|
function safeJsonStringify(value) {
|
|
3993
4252
|
try {
|
|
3994
4253
|
return _nullishCoalesce(JSON.stringify(value), () => ( "null"));
|
|
3995
|
-
} catch (
|
|
4254
|
+
} catch (e8) {
|
|
3996
4255
|
return "null";
|
|
3997
4256
|
}
|
|
3998
4257
|
}
|
|
@@ -4076,7 +4335,7 @@ function betaSessionEventsProxy(events) {
|
|
|
4076
4335
|
if (prop === "stream") {
|
|
4077
4336
|
return new TypedApplyProxy(target.stream, {
|
|
4078
4337
|
apply(stream, thisArg, argArray) {
|
|
4079
|
-
return
|
|
4338
|
+
return _chunk2XDW3UCGjs.anthropicChannels.betaSessionsEventsStream.tracePromise(
|
|
4080
4339
|
() => Reflect.apply(stream, thisArg, argArray),
|
|
4081
4340
|
{ arguments: argArray }
|
|
4082
4341
|
);
|
|
@@ -4103,7 +4362,7 @@ function betaSessionThreadEventsProxy(events) {
|
|
|
4103
4362
|
if (prop === "stream") {
|
|
4104
4363
|
return new TypedApplyProxy(target.stream, {
|
|
4105
4364
|
apply(stream, thisArg, argArray) {
|
|
4106
|
-
return
|
|
4365
|
+
return _chunk2XDW3UCGjs.anthropicChannels.betaSessionsThreadsEventsStream.tracePromise(
|
|
4107
4366
|
() => Reflect.apply(stream, thisArg, argArray),
|
|
4108
4367
|
{ arguments: argArray }
|
|
4109
4368
|
);
|
|
@@ -4118,7 +4377,7 @@ function messagesProxy(messages) {
|
|
|
4118
4377
|
return new Proxy(messages, {
|
|
4119
4378
|
get(target, prop, receiver) {
|
|
4120
4379
|
if (prop === "create") {
|
|
4121
|
-
return createProxy(target.create,
|
|
4380
|
+
return createProxy(target.create, _chunk2XDW3UCGjs.anthropicChannels.messagesCreate);
|
|
4122
4381
|
}
|
|
4123
4382
|
return Reflect.get(target, prop, receiver);
|
|
4124
4383
|
}
|
|
@@ -4128,7 +4387,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
4128
4387
|
return new Proxy(messages, {
|
|
4129
4388
|
get(target, prop, receiver) {
|
|
4130
4389
|
if (prop === "create") {
|
|
4131
|
-
return createProxy(target.create,
|
|
4390
|
+
return createProxy(target.create, _chunk2XDW3UCGjs.anthropicChannels.betaMessagesCreate);
|
|
4132
4391
|
}
|
|
4133
4392
|
if (prop === "toolRunner") {
|
|
4134
4393
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -4137,7 +4396,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
4137
4396
|
return toolRunnerProxy(
|
|
4138
4397
|
target.toolRunner,
|
|
4139
4398
|
anthropic,
|
|
4140
|
-
|
|
4399
|
+
_chunk2XDW3UCGjs.anthropicChannels.betaMessagesToolRunner
|
|
4141
4400
|
);
|
|
4142
4401
|
}
|
|
4143
4402
|
return Reflect.get(target, prop, receiver);
|
|
@@ -4194,11 +4453,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
4194
4453
|
...params,
|
|
4195
4454
|
options: {
|
|
4196
4455
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
4197
|
-
[
|
|
4456
|
+
[_chunkTWCDSYJNjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
4198
4457
|
}
|
|
4199
4458
|
};
|
|
4200
4459
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
4201
|
-
return
|
|
4460
|
+
return _chunk2XDW3UCGjs.claudeAgentSDKChannels.query.invoke(
|
|
4202
4461
|
target,
|
|
4203
4462
|
invocationTarget,
|
|
4204
4463
|
[wrappedParams],
|
|
@@ -4226,7 +4485,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
4226
4485
|
}
|
|
4227
4486
|
const localToolMetadata = { toolName };
|
|
4228
4487
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
4229
|
-
wrappedArgs[handlerIndex] =
|
|
4488
|
+
wrappedArgs[handlerIndex] = _chunkTWCDSYJNjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
4230
4489
|
originalHandler,
|
|
4231
4490
|
() => localToolMetadata
|
|
4232
4491
|
);
|
|
@@ -4244,8 +4503,8 @@ function wrapCreateSdkMcpServer(createSdkMcpServerFn, localToolMetadataByTool, d
|
|
|
4244
4503
|
apply(target, thisArg, argArray) {
|
|
4245
4504
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
4246
4505
|
const config = argArray[0];
|
|
4247
|
-
const serverName = _optionalChain([config, 'optionalAccess',
|
|
4248
|
-
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess',
|
|
4506
|
+
const serverName = _optionalChain([config, 'optionalAccess', _133 => _133.name]);
|
|
4507
|
+
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess', _134 => _134.tools]))) {
|
|
4249
4508
|
for (const tool of config.tools) {
|
|
4250
4509
|
if (!tool || typeof tool !== "object") {
|
|
4251
4510
|
continue;
|
|
@@ -4333,7 +4592,7 @@ function patchThinkClass(Think) {
|
|
|
4333
4592
|
...descriptor,
|
|
4334
4593
|
value: function wrappedCloudflareThinkRunInferenceLoop(input) {
|
|
4335
4594
|
const args = [input];
|
|
4336
|
-
return
|
|
4595
|
+
return _chunk2XDW3UCGjs.cloudflareThinkChannels.runInferenceLoop.tracePromise(
|
|
4337
4596
|
() => Reflect.apply(original, this, args),
|
|
4338
4597
|
{
|
|
4339
4598
|
arguments: args,
|
|
@@ -4385,7 +4644,7 @@ function isModuleNamespace2(obj) {
|
|
|
4385
4644
|
if (!obj || typeof obj !== "object") {
|
|
4386
4645
|
return false;
|
|
4387
4646
|
}
|
|
4388
|
-
if (_optionalChain([obj, 'access',
|
|
4647
|
+
if (_optionalChain([obj, 'access', _135 => _135.constructor, 'optionalAccess', _136 => _136.name]) === "Module") {
|
|
4389
4648
|
return true;
|
|
4390
4649
|
}
|
|
4391
4650
|
const keys = Object.keys(obj);
|
|
@@ -4455,7 +4714,7 @@ function wrapCodexThread(thread) {
|
|
|
4455
4714
|
if (prop === "run" && typeof value === "function") {
|
|
4456
4715
|
return function(input, turnOptions) {
|
|
4457
4716
|
const args = [input, turnOptions];
|
|
4458
|
-
return
|
|
4717
|
+
return _chunk2XDW3UCGjs.openAICodexChannels.run.tracePromise(
|
|
4459
4718
|
() => Reflect.apply(value, target, args),
|
|
4460
4719
|
{
|
|
4461
4720
|
arguments: args,
|
|
@@ -4468,7 +4727,7 @@ function wrapCodexThread(thread) {
|
|
|
4468
4727
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
4469
4728
|
return function(input, turnOptions) {
|
|
4470
4729
|
const args = [input, turnOptions];
|
|
4471
|
-
return
|
|
4730
|
+
return _chunk2XDW3UCGjs.openAICodexChannels.runStreamed.tracePromise(
|
|
4472
4731
|
() => Reflect.apply(value, target, args),
|
|
4473
4732
|
{
|
|
4474
4733
|
arguments: args,
|
|
@@ -4515,7 +4774,7 @@ function isModuleNamespace3(obj) {
|
|
|
4515
4774
|
if (!obj || typeof obj !== "object") {
|
|
4516
4775
|
return false;
|
|
4517
4776
|
}
|
|
4518
|
-
if (_optionalChain([obj, 'access',
|
|
4777
|
+
if (_optionalChain([obj, 'access', _137 => _137.constructor, 'optionalAccess', _138 => _138.name]) === "Module") {
|
|
4519
4778
|
return true;
|
|
4520
4779
|
}
|
|
4521
4780
|
const keys = Object.keys(obj);
|
|
@@ -4536,7 +4795,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4536
4795
|
if (prop === "create" && typeof value === "function") {
|
|
4537
4796
|
const wrapped = async function(options) {
|
|
4538
4797
|
const args = [options];
|
|
4539
|
-
return
|
|
4798
|
+
return _chunk2XDW3UCGjs.cursorSDKChannels.create.tracePromise(
|
|
4540
4799
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
4541
4800
|
{ arguments: args }
|
|
4542
4801
|
);
|
|
@@ -4547,7 +4806,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4547
4806
|
if (prop === "resume" && typeof value === "function") {
|
|
4548
4807
|
const wrapped = async function(agentId, options) {
|
|
4549
4808
|
const args = [agentId, options];
|
|
4550
|
-
return
|
|
4809
|
+
return _chunk2XDW3UCGjs.cursorSDKChannels.resume.tracePromise(
|
|
4551
4810
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
4552
4811
|
{ arguments: args }
|
|
4553
4812
|
);
|
|
@@ -4558,7 +4817,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4558
4817
|
if (prop === "prompt" && typeof value === "function") {
|
|
4559
4818
|
const wrapped = async function(message, options) {
|
|
4560
4819
|
const args = [message, options];
|
|
4561
|
-
return
|
|
4820
|
+
return _chunk2XDW3UCGjs.cursorSDKChannels.prompt.tracePromise(
|
|
4562
4821
|
() => Reflect.apply(value, target, args),
|
|
4563
4822
|
{ arguments: args }
|
|
4564
4823
|
);
|
|
@@ -4591,7 +4850,7 @@ function wrapCursorAgent(agent) {
|
|
|
4591
4850
|
if (prop === "send" && typeof value === "function") {
|
|
4592
4851
|
return function(message, options) {
|
|
4593
4852
|
const args = [message, options];
|
|
4594
|
-
return
|
|
4853
|
+
return _chunk2XDW3UCGjs.cursorSDKChannels.send.tracePromise(
|
|
4595
4854
|
() => Reflect.apply(value, target, args),
|
|
4596
4855
|
{
|
|
4597
4856
|
agent: target,
|
|
@@ -4641,7 +4900,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
4641
4900
|
...descriptor,
|
|
4642
4901
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
4643
4902
|
const args = [text, options];
|
|
4644
|
-
return
|
|
4903
|
+
return _chunk2XDW3UCGjs.piCodingAgentChannels.prompt.invoke(originalPrompt, this, args, {
|
|
4645
4904
|
session: this
|
|
4646
4905
|
});
|
|
4647
4906
|
}
|
|
@@ -4687,7 +4946,7 @@ function wrapCloudflareAgent(Agent) {
|
|
|
4687
4946
|
if (ownValue(options, "detached")) {
|
|
4688
4947
|
return Reflect.apply(originalRunAgentTool, this, args);
|
|
4689
4948
|
}
|
|
4690
|
-
return
|
|
4949
|
+
return _chunk2XDW3UCGjs.cloudflareAgentsChannels.runAgentTool.tracePromise(
|
|
4691
4950
|
() => Reflect.apply(originalRunAgentTool, this, args),
|
|
4692
4951
|
{ arguments: args, self: this }
|
|
4693
4952
|
);
|
|
@@ -4711,7 +4970,7 @@ function isObjectLike(value) {
|
|
|
4711
4970
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
4712
4971
|
}
|
|
4713
4972
|
function warnUnsupportedAgent() {
|
|
4714
|
-
|
|
4973
|
+
_chunk2XDW3UCGjs.debugLogger.warn("Unsupported Cloudflare Agents Agent class. Not wrapping.");
|
|
4715
4974
|
}
|
|
4716
4975
|
|
|
4717
4976
|
// src/wrappers/strands-agent-sdk.ts
|
|
@@ -4755,7 +5014,7 @@ function isModuleNamespace4(obj) {
|
|
|
4755
5014
|
if (!obj || typeof obj !== "object") {
|
|
4756
5015
|
return false;
|
|
4757
5016
|
}
|
|
4758
|
-
if (_optionalChain([obj, 'access',
|
|
5017
|
+
if (_optionalChain([obj, 'access', _139 => _139.constructor, 'optionalAccess', _140 => _140.name]) === "Module") {
|
|
4759
5018
|
return true;
|
|
4760
5019
|
}
|
|
4761
5020
|
const keys = Object.keys(obj);
|
|
@@ -4817,7 +5076,7 @@ function wrapAgentInstance(agent) {
|
|
|
4817
5076
|
if (prop === "stream" && typeof value === "function") {
|
|
4818
5077
|
return function(args, options) {
|
|
4819
5078
|
const callArgs = [args, options];
|
|
4820
|
-
return
|
|
5079
|
+
return _chunk2XDW3UCGjs.strandsAgentSDKChannels.agentStream.invoke(
|
|
4821
5080
|
value,
|
|
4822
5081
|
target,
|
|
4823
5082
|
callArgs,
|
|
@@ -4851,7 +5110,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
4851
5110
|
if (prop === "stream" && typeof value === "function") {
|
|
4852
5111
|
return function(input, options) {
|
|
4853
5112
|
const callArgs = [input, options];
|
|
4854
|
-
const channel = kind === "graph" ?
|
|
5113
|
+
const channel = kind === "graph" ? _chunk2XDW3UCGjs.strandsAgentSDKChannels.graphStream : _chunk2XDW3UCGjs.strandsAgentSDKChannels.swarmStream;
|
|
4855
5114
|
return channel.invoke(
|
|
4856
5115
|
value,
|
|
4857
5116
|
target,
|
|
@@ -4891,11 +5150,11 @@ function wrapCloudflareAIChat(module) {
|
|
|
4891
5150
|
try {
|
|
4892
5151
|
AIChatAgent = Reflect.get(candidate, "AIChatAgent");
|
|
4893
5152
|
} catch (error) {
|
|
4894
|
-
|
|
5153
|
+
_chunk2XDW3UCGjs.debugLogger.debug("Failed to inspect @cloudflare/ai-chat module:", error);
|
|
4895
5154
|
return module;
|
|
4896
5155
|
}
|
|
4897
5156
|
if (typeof AIChatAgent !== "function") {
|
|
4898
|
-
|
|
5157
|
+
_chunk2XDW3UCGjs.debugLogger.warn(
|
|
4899
5158
|
"Unsupported @cloudflare/ai-chat module. AIChatAgent was not found; not wrapping."
|
|
4900
5159
|
);
|
|
4901
5160
|
return module;
|
|
@@ -4929,7 +5188,7 @@ function wrapAIChatAgentClass(AgentClass) {
|
|
|
4929
5188
|
args,
|
|
4930
5189
|
newTarget
|
|
4931
5190
|
);
|
|
4932
|
-
return
|
|
5191
|
+
return _chunkTWCDSYJNjs.instrumentCloudflareAIChatAgent.call(void 0, instance);
|
|
4933
5192
|
}
|
|
4934
5193
|
});
|
|
4935
5194
|
wrappedClasses.set(AgentClass, wrapped);
|
|
@@ -4950,7 +5209,7 @@ function isModuleNamespace5(value) {
|
|
|
4950
5209
|
}
|
|
4951
5210
|
const descriptor = Object.getOwnPropertyDescriptor(value, keys[0]);
|
|
4952
5211
|
return descriptor ? !descriptor.configurable && !descriptor.writable : false;
|
|
4953
|
-
} catch (
|
|
5212
|
+
} catch (e9) {
|
|
4954
5213
|
return false;
|
|
4955
5214
|
}
|
|
4956
5215
|
}
|
|
@@ -5001,7 +5260,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
5001
5260
|
}
|
|
5002
5261
|
if (prop === "interactions") {
|
|
5003
5262
|
const interactions = Reflect.get(target, prop, receiver);
|
|
5004
|
-
if (!
|
|
5263
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
5005
5264
|
return interactions;
|
|
5006
5265
|
}
|
|
5007
5266
|
if (interactions !== originalInteractions) {
|
|
@@ -5015,7 +5274,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
5015
5274
|
});
|
|
5016
5275
|
}
|
|
5017
5276
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
5018
|
-
if (!
|
|
5277
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
5019
5278
|
return;
|
|
5020
5279
|
}
|
|
5021
5280
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -5048,7 +5307,7 @@ function wrapInteractions(interactions) {
|
|
|
5048
5307
|
}
|
|
5049
5308
|
function wrapGenerateContent(original) {
|
|
5050
5309
|
return function(params) {
|
|
5051
|
-
return
|
|
5310
|
+
return _chunk2XDW3UCGjs.googleGenAIChannels.generateContent.tracePromise(
|
|
5052
5311
|
() => original(params),
|
|
5053
5312
|
{ arguments: [params] }
|
|
5054
5313
|
);
|
|
@@ -5056,7 +5315,7 @@ function wrapGenerateContent(original) {
|
|
|
5056
5315
|
}
|
|
5057
5316
|
function wrapGenerateContentStream(original) {
|
|
5058
5317
|
return function(params) {
|
|
5059
|
-
return
|
|
5318
|
+
return _chunk2XDW3UCGjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
5060
5319
|
() => original(params),
|
|
5061
5320
|
{ arguments: [params] }
|
|
5062
5321
|
);
|
|
@@ -5064,7 +5323,7 @@ function wrapGenerateContentStream(original) {
|
|
|
5064
5323
|
}
|
|
5065
5324
|
function wrapEmbedContent(original) {
|
|
5066
5325
|
return function(params) {
|
|
5067
|
-
return
|
|
5326
|
+
return _chunk2XDW3UCGjs.googleGenAIChannels.embedContent.tracePromise(
|
|
5068
5327
|
() => original(params),
|
|
5069
5328
|
{ arguments: [params] }
|
|
5070
5329
|
);
|
|
@@ -5076,7 +5335,7 @@ function wrapInteractionCreate(original) {
|
|
|
5076
5335
|
return options === void 0 ? original(params) : original(params, options);
|
|
5077
5336
|
}
|
|
5078
5337
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
5079
|
-
return
|
|
5338
|
+
return _chunk2XDW3UCGjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
5080
5339
|
() => options === void 0 ? original(params) : original(params, options),
|
|
5081
5340
|
traceContext
|
|
5082
5341
|
);
|
|
@@ -5137,7 +5396,7 @@ function wrapRunnerInstance(runner) {
|
|
|
5137
5396
|
function wrapRunnerRunAsync(runner) {
|
|
5138
5397
|
const original = runner.runAsync.bind(runner);
|
|
5139
5398
|
return function(params) {
|
|
5140
|
-
return
|
|
5399
|
+
return _chunk2XDW3UCGjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
5141
5400
|
arguments: [params],
|
|
5142
5401
|
self: runner
|
|
5143
5402
|
});
|
|
@@ -5164,7 +5423,7 @@ function wrapAgentInstance2(agent) {
|
|
|
5164
5423
|
function wrapAgentRunAsync(agent) {
|
|
5165
5424
|
const original = agent.runAsync.bind(agent);
|
|
5166
5425
|
return function(parentContext) {
|
|
5167
|
-
return
|
|
5426
|
+
return _chunk2XDW3UCGjs.googleADKChannels.agentRunAsync.traceSync(
|
|
5168
5427
|
() => original(parentContext),
|
|
5169
5428
|
{ arguments: [parentContext], self: agent }
|
|
5170
5429
|
);
|
|
@@ -5191,7 +5450,7 @@ function wrapToolInstance(tool) {
|
|
|
5191
5450
|
function wrapToolRunAsync(tool) {
|
|
5192
5451
|
const original = tool.runAsync.bind(tool);
|
|
5193
5452
|
return function(req) {
|
|
5194
|
-
return
|
|
5453
|
+
return _chunk2XDW3UCGjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
5195
5454
|
arguments: [req],
|
|
5196
5455
|
self: tool
|
|
5197
5456
|
});
|
|
@@ -5303,7 +5562,7 @@ function patchGenkitRegistryLookup(registry) {
|
|
|
5303
5562
|
Object.defineProperty(registry, PATCHED_GENKIT_REGISTRY, {
|
|
5304
5563
|
value: true
|
|
5305
5564
|
});
|
|
5306
|
-
} catch (
|
|
5565
|
+
} catch (e10) {
|
|
5307
5566
|
}
|
|
5308
5567
|
}
|
|
5309
5568
|
function patchGenkitRegistryConstructor(registry) {
|
|
@@ -5334,31 +5593,31 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
5334
5593
|
Object.defineProperty(constructor, PATCHED_GENKIT_REGISTRY_CONSTRUCTOR, {
|
|
5335
5594
|
value: true
|
|
5336
5595
|
});
|
|
5337
|
-
} catch (
|
|
5596
|
+
} catch (e11) {
|
|
5338
5597
|
}
|
|
5339
5598
|
}
|
|
5340
5599
|
function wrapGenerate(generate) {
|
|
5341
|
-
return (input) =>
|
|
5600
|
+
return (input) => _chunk2XDW3UCGjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
5342
5601
|
arguments: [input]
|
|
5343
5602
|
});
|
|
5344
5603
|
}
|
|
5345
5604
|
function wrapGenerateStream(generateStream) {
|
|
5346
|
-
return (input) =>
|
|
5605
|
+
return (input) => _chunk2XDW3UCGjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
5347
5606
|
arguments: [input]
|
|
5348
5607
|
});
|
|
5349
5608
|
}
|
|
5350
5609
|
function wrapEmbed2(embed) {
|
|
5351
|
-
return (params) =>
|
|
5610
|
+
return (params) => _chunk2XDW3UCGjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
5352
5611
|
arguments: [params]
|
|
5353
5612
|
});
|
|
5354
5613
|
}
|
|
5355
5614
|
function wrapEmbedMany2(embedMany) {
|
|
5356
|
-
return (params) =>
|
|
5615
|
+
return (params) => _chunk2XDW3UCGjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
5357
5616
|
arguments: [params]
|
|
5358
5617
|
});
|
|
5359
5618
|
}
|
|
5360
5619
|
function wrapRun(run) {
|
|
5361
|
-
return (name, inputOrFn, maybeFn) =>
|
|
5620
|
+
return (name, inputOrFn, maybeFn) => _chunk2XDW3UCGjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
5362
5621
|
arguments: [name, inputOrFn, maybeFn]
|
|
5363
5622
|
});
|
|
5364
5623
|
}
|
|
@@ -5397,13 +5656,13 @@ function isGenkitAction(value) {
|
|
|
5397
5656
|
return typeof value === "function" && "__action" in value;
|
|
5398
5657
|
}
|
|
5399
5658
|
function traceActionRun(action, run) {
|
|
5400
|
-
return (input, options) =>
|
|
5659
|
+
return (input, options) => _chunk2XDW3UCGjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
5401
5660
|
arguments: [input, options],
|
|
5402
5661
|
self: action
|
|
5403
5662
|
});
|
|
5404
5663
|
}
|
|
5405
5664
|
function traceActionStream(action, stream) {
|
|
5406
|
-
return (input, options) =>
|
|
5665
|
+
return (input, options) => _chunk2XDW3UCGjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
5407
5666
|
arguments: [input, options],
|
|
5408
5667
|
self: action
|
|
5409
5668
|
});
|
|
@@ -5449,10 +5708,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
5449
5708
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
5450
5709
|
}
|
|
5451
5710
|
function hasFunction2(value, methodName) {
|
|
5452
|
-
return
|
|
5711
|
+
return _chunkTWCDSYJNjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
5453
5712
|
}
|
|
5454
5713
|
function isSupportedHuggingFaceModule(value) {
|
|
5455
|
-
if (!
|
|
5714
|
+
if (!_chunkTWCDSYJNjs.isObject.call(void 0, value)) {
|
|
5456
5715
|
return false;
|
|
5457
5716
|
}
|
|
5458
5717
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -5560,14 +5819,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
5560
5819
|
const context = {
|
|
5561
5820
|
arguments: [traceParams]
|
|
5562
5821
|
};
|
|
5563
|
-
return
|
|
5822
|
+
return _chunk2XDW3UCGjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
5564
5823
|
() => original(params, options),
|
|
5565
5824
|
context
|
|
5566
5825
|
);
|
|
5567
5826
|
};
|
|
5568
5827
|
}
|
|
5569
5828
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
5570
|
-
return (params, options) =>
|
|
5829
|
+
return (params, options) => _chunk2XDW3UCGjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
5571
5830
|
() => original(params, options),
|
|
5572
5831
|
{
|
|
5573
5832
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -5580,14 +5839,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
5580
5839
|
const context = {
|
|
5581
5840
|
arguments: [traceParams]
|
|
5582
5841
|
};
|
|
5583
|
-
return
|
|
5842
|
+
return _chunk2XDW3UCGjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
5584
5843
|
() => original(params, options),
|
|
5585
5844
|
context
|
|
5586
5845
|
);
|
|
5587
5846
|
};
|
|
5588
5847
|
}
|
|
5589
5848
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
5590
|
-
return (params, options) =>
|
|
5849
|
+
return (params, options) => _chunk2XDW3UCGjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
5591
5850
|
() => original(params, options),
|
|
5592
5851
|
{
|
|
5593
5852
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -5600,7 +5859,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
5600
5859
|
const context = {
|
|
5601
5860
|
arguments: [traceParams]
|
|
5602
5861
|
};
|
|
5603
|
-
return
|
|
5862
|
+
return _chunk2XDW3UCGjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
5604
5863
|
() => original(params, options),
|
|
5605
5864
|
context
|
|
5606
5865
|
);
|
|
@@ -5617,8 +5876,8 @@ var PIPELINE_CONSTRUCTOR_KEYS = /* @__PURE__ */ new Set([
|
|
|
5617
5876
|
]);
|
|
5618
5877
|
var wrappedValues = /* @__PURE__ */ new WeakMap();
|
|
5619
5878
|
function wrapHuggingFaceTransformers(transformers) {
|
|
5620
|
-
const pipelineTask = _optionalChain([transformers, 'optionalAccess',
|
|
5621
|
-
if (typeof transformers === "function" &&
|
|
5879
|
+
const pipelineTask = _optionalChain([transformers, 'optionalAccess', _141 => _141.task]);
|
|
5880
|
+
if (typeof transformers === "function" && _chunk2XDW3UCGjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipelineTask)) {
|
|
5622
5881
|
return wrapPipeline(transformers);
|
|
5623
5882
|
}
|
|
5624
5883
|
if (!isSupportedModule(transformers)) {
|
|
@@ -5670,8 +5929,8 @@ function wrapPipelineFactory(factory) {
|
|
|
5670
5929
|
const context = {
|
|
5671
5930
|
arguments: args
|
|
5672
5931
|
};
|
|
5673
|
-
return
|
|
5674
|
-
if (
|
|
5932
|
+
return _chunk2XDW3UCGjs.huggingFaceTransformersChannels.pipeline.tracePromise(() => Reflect.apply(factory, this, args), context).then((pipeline) => {
|
|
5933
|
+
if (_chunk2XDW3UCGjs.isSupportedHuggingFaceTransformersTask.call(void 0, _nullishCoalesce(pipeline.task, () => ( task)))) {
|
|
5675
5934
|
return wrapPipeline(pipeline);
|
|
5676
5935
|
}
|
|
5677
5936
|
return pipeline;
|
|
@@ -5689,7 +5948,7 @@ function wrapPipelineConstructor(constructor) {
|
|
|
5689
5948
|
const proxy = new Proxy(constructor, {
|
|
5690
5949
|
construct(target, args, newTarget) {
|
|
5691
5950
|
const pipeline = Reflect.construct(target, args, newTarget);
|
|
5692
|
-
if (
|
|
5951
|
+
if (_chunk2XDW3UCGjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipeline.task)) {
|
|
5693
5952
|
return wrapPipeline(pipeline);
|
|
5694
5953
|
}
|
|
5695
5954
|
return pipeline;
|
|
@@ -5710,7 +5969,7 @@ function wrapPipeline(pipeline) {
|
|
|
5710
5969
|
arguments: args,
|
|
5711
5970
|
self: target
|
|
5712
5971
|
};
|
|
5713
|
-
return
|
|
5972
|
+
return _chunk2XDW3UCGjs.huggingFaceTransformersChannels.pipelineCall.tracePromise(
|
|
5714
5973
|
() => Reflect.apply(target, thisArg, args),
|
|
5715
5974
|
context
|
|
5716
5975
|
);
|
|
@@ -5761,7 +6020,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
5761
6020
|
const request = cloneCallModelRequest(argArray[0]);
|
|
5762
6021
|
const options = argArray[1];
|
|
5763
6022
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
5764
|
-
return
|
|
6023
|
+
return _chunk2XDW3UCGjs.openRouterAgentChannels.callModel.traceSync(
|
|
5765
6024
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
5766
6025
|
{
|
|
5767
6026
|
arguments: [request]
|
|
@@ -5857,24 +6116,24 @@ function rerankProxy(rerank) {
|
|
|
5857
6116
|
});
|
|
5858
6117
|
}
|
|
5859
6118
|
function wrapChatSend(send) {
|
|
5860
|
-
return (request, options) =>
|
|
6119
|
+
return (request, options) => _chunk2XDW3UCGjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
5861
6120
|
arguments: [request]
|
|
5862
6121
|
});
|
|
5863
6122
|
}
|
|
5864
6123
|
function wrapEmbeddingsGenerate(generate) {
|
|
5865
|
-
return (request, options) =>
|
|
6124
|
+
return (request, options) => _chunk2XDW3UCGjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
5866
6125
|
() => generate(request, options),
|
|
5867
6126
|
{ arguments: [request] }
|
|
5868
6127
|
);
|
|
5869
6128
|
}
|
|
5870
6129
|
function wrapResponsesSend(send) {
|
|
5871
|
-
return (request, options) =>
|
|
6130
|
+
return (request, options) => _chunk2XDW3UCGjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
5872
6131
|
() => send(request, options),
|
|
5873
6132
|
{ arguments: [request] }
|
|
5874
6133
|
);
|
|
5875
6134
|
}
|
|
5876
6135
|
function wrapRerank2(rerank) {
|
|
5877
|
-
return (request, options) =>
|
|
6136
|
+
return (request, options) => _chunk2XDW3UCGjs.openRouterChannels.rerankRerank.tracePromise(
|
|
5878
6137
|
() => rerank(request, options),
|
|
5879
6138
|
{ arguments: [request] }
|
|
5880
6139
|
);
|
|
@@ -5882,7 +6141,7 @@ function wrapRerank2(rerank) {
|
|
|
5882
6141
|
function wrapCallModel2(callModel) {
|
|
5883
6142
|
return (request, options) => {
|
|
5884
6143
|
const tracedRequest = { ...request };
|
|
5885
|
-
return
|
|
6144
|
+
return _chunk2XDW3UCGjs.openRouterChannels.callModel.traceSync(
|
|
5886
6145
|
() => callModel(tracedRequest, options),
|
|
5887
6146
|
{
|
|
5888
6147
|
arguments: [tracedRequest]
|
|
@@ -6015,7 +6274,7 @@ function classifiersProxy(classifiers) {
|
|
|
6015
6274
|
});
|
|
6016
6275
|
}
|
|
6017
6276
|
function wrapChatComplete(complete) {
|
|
6018
|
-
return (request, options) =>
|
|
6277
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.chatComplete.tracePromise(
|
|
6019
6278
|
() => complete(request, options),
|
|
6020
6279
|
{
|
|
6021
6280
|
arguments: [request]
|
|
@@ -6023,52 +6282,52 @@ function wrapChatComplete(complete) {
|
|
|
6023
6282
|
);
|
|
6024
6283
|
}
|
|
6025
6284
|
function wrapChatStream(stream) {
|
|
6026
|
-
return (request, options) =>
|
|
6285
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
6027
6286
|
arguments: [request]
|
|
6028
6287
|
});
|
|
6029
6288
|
}
|
|
6030
6289
|
function wrapEmbeddingsCreate(create) {
|
|
6031
|
-
return (request, options) =>
|
|
6290
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
6032
6291
|
() => create(request, options),
|
|
6033
6292
|
{ arguments: [request] }
|
|
6034
6293
|
);
|
|
6035
6294
|
}
|
|
6036
6295
|
function wrapClassifiersModerate(moderate) {
|
|
6037
|
-
return (request, options) =>
|
|
6296
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.classifiersModerate.tracePromise(
|
|
6038
6297
|
() => moderate(request, options),
|
|
6039
6298
|
{ arguments: [request] }
|
|
6040
6299
|
);
|
|
6041
6300
|
}
|
|
6042
6301
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
6043
|
-
return (request, options) =>
|
|
6302
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
6044
6303
|
() => moderateChat(request, options),
|
|
6045
6304
|
{ arguments: [request] }
|
|
6046
6305
|
);
|
|
6047
6306
|
}
|
|
6048
6307
|
function wrapClassifiersClassify(classify) {
|
|
6049
|
-
return (request, options) =>
|
|
6308
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.classifiersClassify.tracePromise(
|
|
6050
6309
|
() => classify(request, options),
|
|
6051
6310
|
{ arguments: [request] }
|
|
6052
6311
|
);
|
|
6053
6312
|
}
|
|
6054
6313
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
6055
|
-
return (request, options) =>
|
|
6314
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
6056
6315
|
() => classifyChat(request, options),
|
|
6057
6316
|
{ arguments: [request] }
|
|
6058
6317
|
);
|
|
6059
6318
|
}
|
|
6060
6319
|
function wrapFimComplete(complete) {
|
|
6061
|
-
return (request, options) =>
|
|
6320
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
6062
6321
|
arguments: [request]
|
|
6063
6322
|
});
|
|
6064
6323
|
}
|
|
6065
6324
|
function wrapFimStream(stream) {
|
|
6066
|
-
return (request, options) =>
|
|
6325
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
6067
6326
|
arguments: [request]
|
|
6068
6327
|
});
|
|
6069
6328
|
}
|
|
6070
6329
|
function wrapAgentsComplete(complete) {
|
|
6071
|
-
return (request, options) =>
|
|
6330
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.agentsComplete.tracePromise(
|
|
6072
6331
|
() => complete(request, options),
|
|
6073
6332
|
{
|
|
6074
6333
|
arguments: [request]
|
|
@@ -6076,7 +6335,7 @@ function wrapAgentsComplete(complete) {
|
|
|
6076
6335
|
);
|
|
6077
6336
|
}
|
|
6078
6337
|
function wrapAgentsStream(stream) {
|
|
6079
|
-
return (request, options) =>
|
|
6338
|
+
return (request, options) => _chunk2XDW3UCGjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
6080
6339
|
arguments: [request]
|
|
6081
6340
|
});
|
|
6082
6341
|
}
|
|
@@ -6086,12 +6345,12 @@ function wrapOllama(ollama) {
|
|
|
6086
6345
|
if (isSupportedOllamaClient(ollama)) {
|
|
6087
6346
|
return ollamaProxy(ollama);
|
|
6088
6347
|
}
|
|
6089
|
-
|
|
6348
|
+
_chunk2XDW3UCGjs.debugLogger.warn("Unsupported Ollama library. Not wrapping.");
|
|
6090
6349
|
return ollama;
|
|
6091
6350
|
}
|
|
6092
6351
|
var ollamaProxyCache = /* @__PURE__ */ new WeakMap();
|
|
6093
6352
|
function isSupportedOllamaClient(value) {
|
|
6094
|
-
return
|
|
6353
|
+
return _chunkTWCDSYJNjs.isObject.call(void 0, value) && ["chat", "generate", "embed"].some(
|
|
6095
6354
|
(name) => typeof value[name] === "function"
|
|
6096
6355
|
);
|
|
6097
6356
|
}
|
|
@@ -6143,17 +6402,17 @@ function ollamaProxy(ollama) {
|
|
|
6143
6402
|
return proxy;
|
|
6144
6403
|
}
|
|
6145
6404
|
function wrapChat(chat) {
|
|
6146
|
-
return (request) =>
|
|
6405
|
+
return (request) => _chunk2XDW3UCGjs.ollamaChannels.chat.tracePromise(() => chat(request), {
|
|
6147
6406
|
arguments: [request]
|
|
6148
6407
|
});
|
|
6149
6408
|
}
|
|
6150
6409
|
function wrapGenerate2(generate) {
|
|
6151
|
-
return (request) =>
|
|
6410
|
+
return (request) => _chunk2XDW3UCGjs.ollamaChannels.generate.tracePromise(() => generate(request), {
|
|
6152
6411
|
arguments: [request]
|
|
6153
6412
|
});
|
|
6154
6413
|
}
|
|
6155
6414
|
function wrapEmbed3(embed) {
|
|
6156
|
-
return (request) =>
|
|
6415
|
+
return (request) => _chunk2XDW3UCGjs.ollamaChannels.embed.tracePromise(() => embed(request), {
|
|
6157
6416
|
arguments: [request]
|
|
6158
6417
|
});
|
|
6159
6418
|
}
|
|
@@ -6206,22 +6465,22 @@ function cohereProxy(cohere) {
|
|
|
6206
6465
|
return proxy;
|
|
6207
6466
|
}
|
|
6208
6467
|
function wrapChat2(chat) {
|
|
6209
|
-
return (request, options) =>
|
|
6468
|
+
return (request, options) => _chunk2XDW3UCGjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
6210
6469
|
arguments: [request]
|
|
6211
6470
|
});
|
|
6212
6471
|
}
|
|
6213
6472
|
function wrapChatStream2(chatStream) {
|
|
6214
|
-
return (request, options) =>
|
|
6473
|
+
return (request, options) => _chunk2XDW3UCGjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
6215
6474
|
arguments: [request]
|
|
6216
6475
|
});
|
|
6217
6476
|
}
|
|
6218
6477
|
function wrapEmbed4(embed) {
|
|
6219
|
-
return (request, options) =>
|
|
6478
|
+
return (request, options) => _chunk2XDW3UCGjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
6220
6479
|
arguments: [request]
|
|
6221
6480
|
});
|
|
6222
6481
|
}
|
|
6223
6482
|
function wrapRerank3(rerank) {
|
|
6224
|
-
return (request, options) =>
|
|
6483
|
+
return (request, options) => _chunk2XDW3UCGjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
6225
6484
|
arguments: [request]
|
|
6226
6485
|
});
|
|
6227
6486
|
}
|
|
@@ -6259,7 +6518,7 @@ function voyageAIProxy(client) {
|
|
|
6259
6518
|
if (typeof target.embed !== "function") {
|
|
6260
6519
|
return target.embed;
|
|
6261
6520
|
}
|
|
6262
|
-
return (request, options) =>
|
|
6521
|
+
return (request, options) => _chunk2XDW3UCGjs.voyageAIChannels.embed.invoke(
|
|
6263
6522
|
target.embed,
|
|
6264
6523
|
target,
|
|
6265
6524
|
[request, options],
|
|
@@ -6269,7 +6528,7 @@ function voyageAIProxy(client) {
|
|
|
6269
6528
|
if (typeof target.multimodalEmbed !== "function") {
|
|
6270
6529
|
return target.multimodalEmbed;
|
|
6271
6530
|
}
|
|
6272
|
-
return (request, options) =>
|
|
6531
|
+
return (request, options) => _chunk2XDW3UCGjs.voyageAIChannels.multimodalEmbed.invoke(
|
|
6273
6532
|
target.multimodalEmbed,
|
|
6274
6533
|
target,
|
|
6275
6534
|
[request, options],
|
|
@@ -6279,7 +6538,7 @@ function voyageAIProxy(client) {
|
|
|
6279
6538
|
if (typeof target.rerank !== "function") {
|
|
6280
6539
|
return target.rerank;
|
|
6281
6540
|
}
|
|
6282
|
-
return (request, options) =>
|
|
6541
|
+
return (request, options) => _chunk2XDW3UCGjs.voyageAIChannels.rerank.invoke(
|
|
6283
6542
|
target.rerank,
|
|
6284
6543
|
target,
|
|
6285
6544
|
[request, options],
|
|
@@ -6289,7 +6548,7 @@ function voyageAIProxy(client) {
|
|
|
6289
6548
|
if (typeof target.contextualizedEmbed !== "function") {
|
|
6290
6549
|
return target.contextualizedEmbed;
|
|
6291
6550
|
}
|
|
6292
|
-
return (request, options) =>
|
|
6551
|
+
return (request, options) => _chunk2XDW3UCGjs.voyageAIChannels.contextualizedEmbed.invoke(
|
|
6293
6552
|
target.contextualizedEmbed,
|
|
6294
6553
|
target,
|
|
6295
6554
|
[request, options],
|
|
@@ -6329,7 +6588,7 @@ function isSupportedGroqClient(value) {
|
|
|
6329
6588
|
}
|
|
6330
6589
|
function groqProxy(groq) {
|
|
6331
6590
|
const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
|
|
6332
|
-
const completionProxy = _optionalChain([groq, 'access',
|
|
6591
|
+
const completionProxy = _optionalChain([groq, 'access', _142 => _142.chat, 'optionalAccess', _143 => _143.completions]) ? new Proxy(groq.chat.completions, {
|
|
6333
6592
|
get(target, prop, receiver) {
|
|
6334
6593
|
if (prop === "create") {
|
|
6335
6594
|
return wrapChatCompletionsCreate(target.create.bind(target));
|
|
@@ -6381,13 +6640,13 @@ function groqProxy(groq) {
|
|
|
6381
6640
|
return topLevelProxy;
|
|
6382
6641
|
}
|
|
6383
6642
|
function wrapChatCompletionsCreate(create) {
|
|
6384
|
-
return (request, options) =>
|
|
6643
|
+
return (request, options) => _chunk2XDW3UCGjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
6385
6644
|
() => create(request, options),
|
|
6386
6645
|
{ arguments: [request] }
|
|
6387
6646
|
);
|
|
6388
6647
|
}
|
|
6389
6648
|
function wrapEmbeddingsCreate2(create) {
|
|
6390
|
-
return (request, options) =>
|
|
6649
|
+
return (request, options) => _chunk2XDW3UCGjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
6391
6650
|
arguments: [request]
|
|
6392
6651
|
});
|
|
6393
6652
|
}
|
|
@@ -6461,16 +6720,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
6461
6720
|
}
|
|
6462
6721
|
function wrapSend(send) {
|
|
6463
6722
|
return (command, optionsOrCb, cb) => {
|
|
6464
|
-
if (
|
|
6723
|
+
if (_chunkTWCDSYJNjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
6465
6724
|
return send(command, optionsOrCb, cb);
|
|
6466
6725
|
}
|
|
6467
|
-
return
|
|
6468
|
-
() =>
|
|
6726
|
+
return _chunk2XDW3UCGjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
6727
|
+
() => _chunkTWCDSYJNjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
6469
6728
|
() => send(command, optionsOrCb)
|
|
6470
6729
|
),
|
|
6471
6730
|
{
|
|
6472
6731
|
arguments: [command, optionsOrCb],
|
|
6473
|
-
span_info:
|
|
6732
|
+
span_info: _chunkTWCDSYJNjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
6474
6733
|
}
|
|
6475
6734
|
);
|
|
6476
6735
|
};
|
|
@@ -6519,13 +6778,13 @@ function copilotClientProxy(client) {
|
|
|
6519
6778
|
return proxy;
|
|
6520
6779
|
}
|
|
6521
6780
|
function wrappedCreateSession(client) {
|
|
6522
|
-
return (config) =>
|
|
6781
|
+
return (config) => _chunk2XDW3UCGjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
6523
6782
|
() => client.createSession(config),
|
|
6524
6783
|
{ arguments: [config] }
|
|
6525
6784
|
);
|
|
6526
6785
|
}
|
|
6527
6786
|
function wrappedResumeSession(client) {
|
|
6528
|
-
return (sessionId, config) =>
|
|
6787
|
+
return (sessionId, config) => _chunk2XDW3UCGjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
6529
6788
|
() => client.resumeSession(sessionId, config),
|
|
6530
6789
|
{ arguments: [sessionId, config] }
|
|
6531
6790
|
);
|
|
@@ -6630,7 +6889,7 @@ function isModuleNamespace6(value) {
|
|
|
6630
6889
|
if (!value || typeof value !== "object") {
|
|
6631
6890
|
return false;
|
|
6632
6891
|
}
|
|
6633
|
-
if (_optionalChain([value, 'access',
|
|
6892
|
+
if (_optionalChain([value, 'access', _144 => _144.constructor, 'optionalAccess', _145 => _145.name]) === "Module") {
|
|
6634
6893
|
return true;
|
|
6635
6894
|
}
|
|
6636
6895
|
const firstKey = Object.keys(value)[0];
|
|
@@ -6654,7 +6913,7 @@ function wrapTraceable(traceable2) {
|
|
|
6654
6913
|
apply(target, thisArg, argArray) {
|
|
6655
6914
|
const [fn, rawConfig] = argArray;
|
|
6656
6915
|
const config = rawConfig && typeof rawConfig === "object" ? rawConfig : void 0;
|
|
6657
|
-
const originalOnEnd = _optionalChain([config, 'optionalAccess',
|
|
6916
|
+
const originalOnEnd = _optionalChain([config, 'optionalAccess', _146 => _146.on_end]);
|
|
6658
6917
|
const wrappedConfig = {
|
|
6659
6918
|
...config,
|
|
6660
6919
|
on_end(runTree) {
|
|
@@ -6703,13 +6962,13 @@ function wrapRunTreeInstance(runTree) {
|
|
|
6703
6962
|
wrapped = (...args) => wrapRunTreeInstance(Reflect.apply(value, target, args));
|
|
6704
6963
|
} else if (prop === "postRun") {
|
|
6705
6964
|
const method = value;
|
|
6706
|
-
wrapped = (...args) =>
|
|
6965
|
+
wrapped = (...args) => _chunk2XDW3UCGjs.langSmithChannels.createRun.tracePromise(
|
|
6707
6966
|
() => Reflect.apply(method, target, args),
|
|
6708
6967
|
{ arguments: [target] }
|
|
6709
6968
|
);
|
|
6710
6969
|
} else if (prop === "patchRun") {
|
|
6711
6970
|
const method = value;
|
|
6712
|
-
wrapped = (...args) =>
|
|
6971
|
+
wrapped = (...args) => _chunk2XDW3UCGjs.langSmithChannels.updateRun.tracePromise(
|
|
6713
6972
|
() => Reflect.apply(method, target, args),
|
|
6714
6973
|
{
|
|
6715
6974
|
arguments: [
|
|
@@ -6758,19 +7017,19 @@ function wrapClientInstance(client) {
|
|
|
6758
7017
|
let wrapped;
|
|
6759
7018
|
if (prop === "createRun") {
|
|
6760
7019
|
const method = value;
|
|
6761
|
-
wrapped = (...args) =>
|
|
7020
|
+
wrapped = (...args) => _chunk2XDW3UCGjs.langSmithChannels.createRun.tracePromise(
|
|
6762
7021
|
() => Reflect.apply(method, target, args),
|
|
6763
7022
|
{ arguments: args }
|
|
6764
7023
|
);
|
|
6765
7024
|
} else if (prop === "updateRun") {
|
|
6766
7025
|
const method = value;
|
|
6767
|
-
wrapped = (...args) =>
|
|
7026
|
+
wrapped = (...args) => _chunk2XDW3UCGjs.langSmithChannels.updateRun.tracePromise(
|
|
6768
7027
|
() => Reflect.apply(method, target, args),
|
|
6769
7028
|
{ arguments: args }
|
|
6770
7029
|
);
|
|
6771
7030
|
} else if (prop === "batchIngestRuns") {
|
|
6772
7031
|
const method = value;
|
|
6773
|
-
wrapped = (...args) =>
|
|
7032
|
+
wrapped = (...args) => _chunk2XDW3UCGjs.langSmithChannels.batchIngestRuns.tracePromise(
|
|
6774
7033
|
() => Reflect.apply(method, target, args),
|
|
6775
7034
|
{ arguments: args }
|
|
6776
7035
|
);
|
|
@@ -6786,13 +7045,13 @@ function publishRunUpdate(runTree) {
|
|
|
6786
7045
|
return;
|
|
6787
7046
|
}
|
|
6788
7047
|
try {
|
|
6789
|
-
void
|
|
7048
|
+
void _chunk2XDW3UCGjs.langSmithChannels.updateRun.tracePromise(() => Promise.resolve(void 0), {
|
|
6790
7049
|
arguments: [runTree.id, runTree]
|
|
6791
7050
|
}).catch((error) => {
|
|
6792
|
-
|
|
7051
|
+
_chunk2XDW3UCGjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
6793
7052
|
});
|
|
6794
7053
|
} catch (error) {
|
|
6795
|
-
|
|
7054
|
+
_chunk2XDW3UCGjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
6796
7055
|
}
|
|
6797
7056
|
}
|
|
6798
7057
|
|
|
@@ -6804,7 +7063,7 @@ var VitestContextManager = class {
|
|
|
6804
7063
|
*/
|
|
6805
7064
|
|
|
6806
7065
|
constructor() {
|
|
6807
|
-
this.contextStorage =
|
|
7066
|
+
this.contextStorage = _chunk2XDW3UCGjs.isomorph_default.newAsyncLocalStorage();
|
|
6808
7067
|
}
|
|
6809
7068
|
getCurrentContext() {
|
|
6810
7069
|
return this.contextStorage.getStore();
|
|
@@ -6842,7 +7101,7 @@ var FlushCoordinator = (_class3 = class {constructor() { _class3.prototype.__ini
|
|
|
6842
7101
|
if (this.activeFlushes.has(experimentId)) {
|
|
6843
7102
|
return this.activeFlushes.get(experimentId);
|
|
6844
7103
|
}
|
|
6845
|
-
const flushPromise =
|
|
7104
|
+
const flushPromise = _chunkTWCDSYJNjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
6846
7105
|
displaySummary: config.displaySummary
|
|
6847
7106
|
});
|
|
6848
7107
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -6940,7 +7199,7 @@ async function runTracedEval(args) {
|
|
|
6940
7199
|
}
|
|
6941
7200
|
if (testError) {
|
|
6942
7201
|
span.log({ scores: { pass: 0 } });
|
|
6943
|
-
|
|
7202
|
+
_chunkTWCDSYJNjs.logError.call(void 0, span, testError);
|
|
6944
7203
|
throw testError;
|
|
6945
7204
|
}
|
|
6946
7205
|
span.log({
|
|
@@ -6973,7 +7232,7 @@ function wrapTest(originalTest, config) {
|
|
|
6973
7232
|
const wrapped = function(name, configOrFn, maybeFn) {
|
|
6974
7233
|
const isEnhanced = typeof configOrFn !== "function";
|
|
6975
7234
|
const testConfig = isEnhanced ? configOrFn : void 0;
|
|
6976
|
-
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess',
|
|
7235
|
+
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _147 => _147.data]) && Array.isArray(testConfig.data)) {
|
|
6977
7236
|
const dataRecords = testConfig.data;
|
|
6978
7237
|
const testFn2 = maybeFn;
|
|
6979
7238
|
if (!testFn2) {
|
|
@@ -7011,7 +7270,7 @@ function wrapTest(originalTest, config) {
|
|
|
7011
7270
|
const registrationContext = getExperimentContext();
|
|
7012
7271
|
const testImplementation = async (vitestContext) => {
|
|
7013
7272
|
const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
|
|
7014
|
-
const experiment = _optionalChain([experimentContext, 'optionalAccess',
|
|
7273
|
+
const experiment = _optionalChain([experimentContext, 'optionalAccess', _148 => _148.experiment]);
|
|
7015
7274
|
if (config.onProgress) {
|
|
7016
7275
|
config.onProgress({ type: "test_start", testName: name });
|
|
7017
7276
|
}
|
|
@@ -7043,11 +7302,11 @@ function wrapTest(originalTest, config) {
|
|
|
7043
7302
|
const result = await runTracedEval({
|
|
7044
7303
|
experiment,
|
|
7045
7304
|
spanName: name,
|
|
7046
|
-
input: _optionalChain([testConfig, 'optionalAccess',
|
|
7047
|
-
expected: _optionalChain([testConfig, 'optionalAccess',
|
|
7048
|
-
metadata: _optionalChain([testConfig, 'optionalAccess',
|
|
7049
|
-
tags: _optionalChain([testConfig, 'optionalAccess',
|
|
7050
|
-
scorers: _optionalChain([testConfig, 'optionalAccess',
|
|
7305
|
+
input: _optionalChain([testConfig, 'optionalAccess', _149 => _149.input]),
|
|
7306
|
+
expected: _optionalChain([testConfig, 'optionalAccess', _150 => _150.expected]),
|
|
7307
|
+
metadata: _optionalChain([testConfig, 'optionalAccess', _151 => _151.metadata]),
|
|
7308
|
+
tags: _optionalChain([testConfig, 'optionalAccess', _152 => _152.tags]),
|
|
7309
|
+
scorers: _optionalChain([testConfig, 'optionalAccess', _153 => _153.scorers]),
|
|
7051
7310
|
fn: async () => {
|
|
7052
7311
|
if (testConfig && maybeFn) {
|
|
7053
7312
|
const params = {
|
|
@@ -7114,10 +7373,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
7114
7373
|
const getOrCreateContext = () => {
|
|
7115
7374
|
if (!context) {
|
|
7116
7375
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
7117
|
-
const experiment = config.projectId ?
|
|
7376
|
+
const experiment = config.projectId ? _chunkTWCDSYJNjs.initExperiment.call(void 0, {
|
|
7118
7377
|
projectId: config.projectId,
|
|
7119
7378
|
experiment: experimentName
|
|
7120
|
-
}) :
|
|
7379
|
+
}) : _chunkTWCDSYJNjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
7121
7380
|
experiment: experimentName
|
|
7122
7381
|
});
|
|
7123
7382
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -7161,8 +7420,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
7161
7420
|
config.onProgress({
|
|
7162
7421
|
type: "suite_complete",
|
|
7163
7422
|
suiteName,
|
|
7164
|
-
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
7165
|
-
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
7423
|
+
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _154 => _154.passed]), () => ( 0)),
|
|
7424
|
+
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _155 => _155.failed]), () => ( 0))
|
|
7166
7425
|
});
|
|
7167
7426
|
}
|
|
7168
7427
|
});
|
|
@@ -7224,7 +7483,7 @@ function wrapExpect(originalExpect) {
|
|
|
7224
7483
|
return originalExpect(value);
|
|
7225
7484
|
}
|
|
7226
7485
|
const assertion = originalExpect(value, message);
|
|
7227
|
-
const span =
|
|
7486
|
+
const span = _chunkTWCDSYJNjs.currentSpan.call(void 0, );
|
|
7228
7487
|
if (!span) {
|
|
7229
7488
|
return assertion;
|
|
7230
7489
|
}
|
|
@@ -7236,16 +7495,16 @@ function wrapExpect(originalExpect) {
|
|
|
7236
7495
|
|
|
7237
7496
|
// src/wrappers/shared/logging.ts
|
|
7238
7497
|
function logOutputs(outputs) {
|
|
7239
|
-
|
|
7498
|
+
_chunkTWCDSYJNjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
7240
7499
|
}
|
|
7241
7500
|
function logFeedback(feedback) {
|
|
7242
|
-
|
|
7501
|
+
_chunkTWCDSYJNjs.currentSpan.call(void 0, ).log({
|
|
7243
7502
|
scores: { [feedback.name]: feedback.score },
|
|
7244
7503
|
metadata: feedback.metadata
|
|
7245
7504
|
});
|
|
7246
7505
|
}
|
|
7247
7506
|
function getCurrentSpan() {
|
|
7248
|
-
return
|
|
7507
|
+
return _chunkTWCDSYJNjs.currentSpan.call(void 0, );
|
|
7249
7508
|
}
|
|
7250
7509
|
|
|
7251
7510
|
// src/wrappers/vitest/index.ts
|
|
@@ -7293,8 +7552,8 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
7293
7552
|
);
|
|
7294
7553
|
return;
|
|
7295
7554
|
}
|
|
7296
|
-
await
|
|
7297
|
-
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7555
|
+
await _chunkTWCDSYJNjs.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
7556
|
+
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _156 => _156.displaySummary]), () => ( config.displaySummary))
|
|
7298
7557
|
});
|
|
7299
7558
|
}
|
|
7300
7559
|
};
|
|
@@ -7308,7 +7567,7 @@ function initNodeTestSuite(config) {
|
|
|
7308
7567
|
return experiment;
|
|
7309
7568
|
}
|
|
7310
7569
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
7311
|
-
experiment =
|
|
7570
|
+
experiment = _chunkTWCDSYJNjs.initExperiment.call(void 0, config.projectName, {
|
|
7312
7571
|
experiment: experimentName
|
|
7313
7572
|
});
|
|
7314
7573
|
return experiment;
|
|
@@ -7357,7 +7616,7 @@ function initNodeTestSuite(config) {
|
|
|
7357
7616
|
if (!experiment) {
|
|
7358
7617
|
return;
|
|
7359
7618
|
}
|
|
7360
|
-
await
|
|
7619
|
+
await _chunkTWCDSYJNjs.summarizeAndFlush.call(void 0, experiment, {
|
|
7361
7620
|
displaySummary: config.displaySummary
|
|
7362
7621
|
});
|
|
7363
7622
|
experiment = void 0;
|
|
@@ -7374,7 +7633,7 @@ function initNodeTestSuite(config) {
|
|
|
7374
7633
|
|
|
7375
7634
|
// src/graph-framework.ts
|
|
7376
7635
|
var graph_framework_exports = {};
|
|
7377
|
-
|
|
7636
|
+
_chunk2XDW3UCGjs.__export.call(void 0, graph_framework_exports, {
|
|
7378
7637
|
AggregatorNode: () => AggregatorNode,
|
|
7379
7638
|
GateNode: () => GateNode,
|
|
7380
7639
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -7448,7 +7707,7 @@ var GraphBuilder = (_class4 = class {
|
|
|
7448
7707
|
};
|
|
7449
7708
|
}
|
|
7450
7709
|
resolveNode(node) {
|
|
7451
|
-
if (node instanceof
|
|
7710
|
+
if (node instanceof _chunkTWCDSYJNjs.Prompt) {
|
|
7452
7711
|
const cached = this.nodeLikeNodes.get(node);
|
|
7453
7712
|
if (cached) {
|
|
7454
7713
|
return [cached, []];
|
|
@@ -7498,7 +7757,7 @@ var GraphBuilder = (_class4 = class {
|
|
|
7498
7757
|
// }
|
|
7499
7758
|
// Helper to generate node IDs
|
|
7500
7759
|
generateId(name) {
|
|
7501
|
-
const uuid =
|
|
7760
|
+
const uuid = _chunkTWCDSYJNjs.newId.call(void 0, );
|
|
7502
7761
|
if (name) {
|
|
7503
7762
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
7504
7763
|
} else {
|
|
@@ -7732,7 +7991,7 @@ function isAsync(fn) {
|
|
|
7732
7991
|
function isAsyncGenerator(fn) {
|
|
7733
7992
|
return fn[Symbol.toStringTag] === "AsyncGenerator";
|
|
7734
7993
|
}
|
|
7735
|
-
function
|
|
7994
|
+
function isAsyncIterable2(obj) {
|
|
7736
7995
|
return typeof obj[Symbol.asyncIterator] === "function";
|
|
7737
7996
|
}
|
|
7738
7997
|
function wrapAsync(asyncFn) {
|
|
@@ -7904,7 +8163,7 @@ var eachOfLimit$2 = (limit) => {
|
|
|
7904
8163
|
if (isAsyncGenerator(obj)) {
|
|
7905
8164
|
return asyncEachOfLimit(obj, limit, iteratee, callback);
|
|
7906
8165
|
}
|
|
7907
|
-
if (
|
|
8166
|
+
if (isAsyncIterable2(obj)) {
|
|
7908
8167
|
return asyncEachOfLimit(obj[Symbol.asyncIterator](), limit, iteratee, callback);
|
|
7909
8168
|
}
|
|
7910
8169
|
var nextElem = createIterator(obj);
|
|
@@ -8698,7 +8957,7 @@ function waterfall(tasks, callback) {
|
|
|
8698
8957
|
var waterfall$1 = awaitify(waterfall);
|
|
8699
8958
|
|
|
8700
8959
|
// src/trace.ts
|
|
8701
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
8960
|
+
var SpanFetcher = class _SpanFetcher extends _chunkTWCDSYJNjs.ObjectFetcher {
|
|
8702
8961
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
8703
8962
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
8704
8963
|
rootSpanId,
|
|
@@ -8835,7 +9094,7 @@ var CachedSpanFetcher = (_class6 = class {
|
|
|
8835
9094
|
async fetchSpans(spanType) {
|
|
8836
9095
|
const spans = await this.fetchFn(spanType, false);
|
|
8837
9096
|
for (const span of spans) {
|
|
8838
|
-
const type = _nullishCoalesce(_optionalChain([span, 'access',
|
|
9097
|
+
const type = _nullishCoalesce(_optionalChain([span, 'access', _157 => _157.span_attributes, 'optionalAccess', _158 => _158.type]), () => ( ""));
|
|
8839
9098
|
const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
|
|
8840
9099
|
existing.push(span);
|
|
8841
9100
|
this.spanCache.set(type, existing);
|
|
@@ -8918,11 +9177,11 @@ var LocalTrace = (_class7 = class {
|
|
|
8918
9177
|
const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
|
|
8919
9178
|
if (cachedSpans && cachedSpans.length > 0) {
|
|
8920
9179
|
let spans = includeScorers ? cachedSpans : cachedSpans.filter(
|
|
8921
|
-
(span) => _optionalChain([span, 'access',
|
|
9180
|
+
(span) => _optionalChain([span, 'access', _159 => _159.span_attributes, 'optionalAccess', _160 => _160.purpose]) !== "scorer"
|
|
8922
9181
|
);
|
|
8923
9182
|
if (spanType && spanType.length > 0) {
|
|
8924
9183
|
spans = spans.filter(
|
|
8925
|
-
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access',
|
|
9184
|
+
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _161 => _161.span_attributes, 'optionalAccess', _162 => _162.type]), () => ( "")))
|
|
8926
9185
|
);
|
|
8927
9186
|
}
|
|
8928
9187
|
return spans.map((span) => ({
|
|
@@ -8947,7 +9206,7 @@ var LocalTrace = (_class7 = class {
|
|
|
8947
9206
|
* Calls the API with the project_default preprocessor (which falls back to "thread").
|
|
8948
9207
|
*/
|
|
8949
9208
|
async getThread(options) {
|
|
8950
|
-
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
9209
|
+
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _163 => _163.preprocessor]), () => ( "project_default"));
|
|
8951
9210
|
if (!this.threadCache.has(cacheKey)) {
|
|
8952
9211
|
const promise = this.fetchThread(options);
|
|
8953
9212
|
this.threadCache.set(cacheKey, promise);
|
|
@@ -8958,7 +9217,7 @@ var LocalTrace = (_class7 = class {
|
|
|
8958
9217
|
await this.ensureSpansReady();
|
|
8959
9218
|
await this.state.login({});
|
|
8960
9219
|
const result = await invoke({
|
|
8961
|
-
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
9220
|
+
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _164 => _164.preprocessor]), () => ( "project_default")),
|
|
8962
9221
|
functionType: "preprocessor",
|
|
8963
9222
|
input: {
|
|
8964
9223
|
trace_ref: {
|
|
@@ -9015,20 +9274,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
9015
9274
|
prompt: _v3.z.string()
|
|
9016
9275
|
}),
|
|
9017
9276
|
_v3.z.object({
|
|
9018
|
-
messages: _v3.z.array(
|
|
9277
|
+
messages: _v3.z.array(_chunkTWCDSYJNjs.ChatCompletionMessageParam)
|
|
9019
9278
|
})
|
|
9020
9279
|
]);
|
|
9021
9280
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
9022
9281
|
_v3.z.object({
|
|
9023
9282
|
model: _v3.z.string(),
|
|
9024
|
-
params:
|
|
9283
|
+
params: _chunkTWCDSYJNjs.ModelParams.optional(),
|
|
9025
9284
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
9026
9285
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
9027
9286
|
})
|
|
9028
9287
|
);
|
|
9029
9288
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
9030
9289
|
_v3.z.object({
|
|
9031
|
-
tools: _v3.z.array(
|
|
9290
|
+
tools: _v3.z.array(_chunkTWCDSYJNjs.ToolFunctionDefinition).optional()
|
|
9032
9291
|
})
|
|
9033
9292
|
);
|
|
9034
9293
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -9076,7 +9335,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
9076
9335
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
9077
9336
|
return parameters;
|
|
9078
9337
|
}
|
|
9079
|
-
if (
|
|
9338
|
+
if (_chunkTWCDSYJNjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
9080
9339
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
9081
9340
|
...resolvedSchema.data,
|
|
9082
9341
|
...parameters
|
|
@@ -9098,14 +9357,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
9098
9357
|
const value = parameters[name];
|
|
9099
9358
|
try {
|
|
9100
9359
|
if ("type" in schema && schema.type === "prompt") {
|
|
9101
|
-
const promptData = value ?
|
|
9360
|
+
const promptData = value ? _chunkTWCDSYJNjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
9102
9361
|
schema.default,
|
|
9103
9362
|
schema.default.tools
|
|
9104
9363
|
) : void 0;
|
|
9105
9364
|
if (!promptData) {
|
|
9106
9365
|
throw new Error(`Parameter '${name}' is required`);
|
|
9107
9366
|
}
|
|
9108
|
-
return [name,
|
|
9367
|
+
return [name, _chunkTWCDSYJNjs.Prompt.fromPromptData(name, promptData)];
|
|
9109
9368
|
} else if ("type" in schema && schema.type === "model") {
|
|
9110
9369
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
9111
9370
|
if (model === void 0) {
|
|
@@ -9134,10 +9393,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
|
|
|
9134
9393
|
const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
|
|
9135
9394
|
const validate = ajv.compile(schema);
|
|
9136
9395
|
if (!validate(parameters)) {
|
|
9137
|
-
const errorMessages = _optionalChain([validate, 'access',
|
|
9396
|
+
const errorMessages = _optionalChain([validate, 'access', _165 => _165.errors, 'optionalAccess', _166 => _166.map, 'call', _167 => _167((err) => {
|
|
9138
9397
|
const path = err.instancePath || "root";
|
|
9139
9398
|
return `${path}: ${err.message}`;
|
|
9140
|
-
}), 'access',
|
|
9399
|
+
}), 'access', _168 => _168.join, 'call', _169 => _169(", ")]);
|
|
9141
9400
|
throw Error(`Invalid parameters: ${errorMessages}`);
|
|
9142
9401
|
}
|
|
9143
9402
|
return rehydrateRemoteParameters(parameters, schema);
|
|
@@ -9156,7 +9415,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
9156
9415
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
9157
9416
|
return [
|
|
9158
9417
|
name,
|
|
9159
|
-
|
|
9418
|
+
_chunkTWCDSYJNjs.Prompt.fromPromptData(name, _chunkTWCDSYJNjs.PromptData.parse(value))
|
|
9160
9419
|
];
|
|
9161
9420
|
}
|
|
9162
9421
|
return [name, value];
|
|
@@ -9194,7 +9453,7 @@ var EvalResultWithSummary = class {
|
|
|
9194
9453
|
async function getPersistedBaseExperimentId(experiment) {
|
|
9195
9454
|
try {
|
|
9196
9455
|
return await experiment._getBaseExperimentId();
|
|
9197
|
-
} catch (
|
|
9456
|
+
} catch (e12) {
|
|
9198
9457
|
return void 0;
|
|
9199
9458
|
}
|
|
9200
9459
|
}
|
|
@@ -9206,7 +9465,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
9206
9465
|
return out;
|
|
9207
9466
|
}
|
|
9208
9467
|
function initExperiment2(state, options = {}) {
|
|
9209
|
-
return
|
|
9468
|
+
return _chunkTWCDSYJNjs.init.call(void 0, {
|
|
9210
9469
|
state,
|
|
9211
9470
|
...options,
|
|
9212
9471
|
setCurrent: false
|
|
@@ -9217,7 +9476,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
9217
9476
|
return void 0;
|
|
9218
9477
|
}
|
|
9219
9478
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
9220
|
-
if (!
|
|
9479
|
+
if (!_chunkTWCDSYJNjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
9221
9480
|
return void 0;
|
|
9222
9481
|
}
|
|
9223
9482
|
if (resolvedParameters.id === void 0) {
|
|
@@ -9244,7 +9503,7 @@ async function _internalInitEvaluatorExperiment(projectName, evaluator, data, op
|
|
|
9244
9503
|
baseExperimentId: evaluator.baseExperimentId,
|
|
9245
9504
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
9246
9505
|
repoInfo: evaluator.repoInfo,
|
|
9247
|
-
dataset:
|
|
9506
|
+
dataset: _chunkTWCDSYJNjs.Dataset.isDataset(data) ? data : void 0,
|
|
9248
9507
|
parameters
|
|
9249
9508
|
});
|
|
9250
9509
|
}
|
|
@@ -9259,7 +9518,7 @@ function callEvaluatorData(data) {
|
|
|
9259
9518
|
baseExperiment
|
|
9260
9519
|
};
|
|
9261
9520
|
}
|
|
9262
|
-
function
|
|
9521
|
+
function isAsyncIterable3(value) {
|
|
9263
9522
|
return typeof value === "object" && value !== null && Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === "function";
|
|
9264
9523
|
}
|
|
9265
9524
|
function isIterable(value) {
|
|
@@ -9280,7 +9539,7 @@ async function _internalResolveEvaluatorData(evaluator, experiment) {
|
|
|
9280
9539
|
);
|
|
9281
9540
|
}
|
|
9282
9541
|
let name = dataResult.name;
|
|
9283
|
-
if (
|
|
9542
|
+
if (_chunkTWCDSYJNjs.isEmpty.call(void 0, name)) {
|
|
9284
9543
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
9285
9544
|
if (!baseExperiment) {
|
|
9286
9545
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -9294,7 +9553,7 @@ async function _internalResolveEvaluatorData(evaluator, experiment) {
|
|
|
9294
9553
|
}).asDataset();
|
|
9295
9554
|
}
|
|
9296
9555
|
const resolvedDataResult = dataResult instanceof Promise ? await dataResult : dataResult;
|
|
9297
|
-
if (
|
|
9556
|
+
if (isAsyncIterable3(resolvedDataResult)) {
|
|
9298
9557
|
return resolvedDataResult;
|
|
9299
9558
|
}
|
|
9300
9559
|
if (Array.isArray(resolvedDataResult) || isIterable(resolvedDataResult)) {
|
|
@@ -9315,10 +9574,10 @@ globalThis._evals = {
|
|
|
9315
9574
|
reporters: {}
|
|
9316
9575
|
};
|
|
9317
9576
|
function _initializeSpanContext() {
|
|
9318
|
-
globalThis._spanContext = { currentSpan:
|
|
9577
|
+
globalThis._spanContext = { currentSpan: _chunkTWCDSYJNjs.currentSpan, withCurrent: _chunkTWCDSYJNjs.withCurrent, startSpan: _chunkTWCDSYJNjs.startSpan, NOOP_SPAN: _chunkTWCDSYJNjs.NOOP_SPAN };
|
|
9319
9578
|
}
|
|
9320
9579
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
9321
|
-
const options =
|
|
9580
|
+
const options = _chunkTWCDSYJNjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
9322
9581
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
9323
9582
|
if (globalThis._evals.evaluators[evalName]) {
|
|
9324
9583
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -9377,7 +9636,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
9377
9636
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
9378
9637
|
let ret;
|
|
9379
9638
|
if (options.parent) {
|
|
9380
|
-
ret = await
|
|
9639
|
+
ret = await _chunkTWCDSYJNjs.withParent.call(void 0,
|
|
9381
9640
|
options.parent,
|
|
9382
9641
|
() => runEvaluator(
|
|
9383
9642
|
null,
|
|
@@ -9413,7 +9672,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
9413
9672
|
if (experiment) {
|
|
9414
9673
|
await experiment.flush().catch(console.error);
|
|
9415
9674
|
} else if (options.parent) {
|
|
9416
|
-
await
|
|
9675
|
+
await _chunkTWCDSYJNjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
9417
9676
|
}
|
|
9418
9677
|
}
|
|
9419
9678
|
} finally {
|
|
@@ -9496,7 +9755,7 @@ function _internalPrepareEvaluatorScore(scoreValue, name) {
|
|
|
9496
9755
|
if (scoreValue === null) return { results: null };
|
|
9497
9756
|
if (Array.isArray(scoreValue)) {
|
|
9498
9757
|
for (const score of scoreValue) {
|
|
9499
|
-
if (!(typeof score === "object" && !
|
|
9758
|
+
if (!(typeof score === "object" && !_chunkTWCDSYJNjs.isEmpty.call(void 0, score))) {
|
|
9500
9759
|
throw new Error(
|
|
9501
9760
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(score)}`
|
|
9502
9761
|
);
|
|
@@ -9506,7 +9765,7 @@ function _internalPrepareEvaluatorScore(scoreValue, name) {
|
|
|
9506
9765
|
let results;
|
|
9507
9766
|
if (Array.isArray(scoreValue)) {
|
|
9508
9767
|
results = scoreValue;
|
|
9509
|
-
} else if (typeof scoreValue === "object" && !
|
|
9768
|
+
} else if (typeof scoreValue === "object" && !_chunkTWCDSYJNjs.isEmpty.call(void 0, scoreValue)) {
|
|
9510
9769
|
results = [scoreValue];
|
|
9511
9770
|
} else {
|
|
9512
9771
|
results = [{ name, score: scoreValue }];
|
|
@@ -9550,7 +9809,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
9550
9809
|
return failing;
|
|
9551
9810
|
}
|
|
9552
9811
|
function validateClassificationResult(value, scorerName2) {
|
|
9553
|
-
if (!(typeof value === "object" && value !== null && !
|
|
9812
|
+
if (!(typeof value === "object" && value !== null && !_chunkTWCDSYJNjs.isEmpty.call(void 0, value))) {
|
|
9554
9813
|
throw new Error(
|
|
9555
9814
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
9556
9815
|
);
|
|
@@ -9600,7 +9859,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
9600
9859
|
);
|
|
9601
9860
|
metadata[`${kind}_errors`] = errorMap;
|
|
9602
9861
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
9603
|
-
|
|
9862
|
+
_chunk2XDW3UCGjs.debugLogger.forState(state).warn(
|
|
9604
9863
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
9605
9864
|
failures.map((f) => f.error)
|
|
9606
9865
|
);
|
|
@@ -9634,7 +9893,7 @@ var defaultErrorScoreHandler = ({
|
|
|
9634
9893
|
};
|
|
9635
9894
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
9636
9895
|
if (enableCache) {
|
|
9637
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
9896
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _170 => _170.spanCache, 'optionalAccess', _171 => _171.start, 'call', _172 => _172()]);
|
|
9638
9897
|
}
|
|
9639
9898
|
try {
|
|
9640
9899
|
parameters = await validateParameters(
|
|
@@ -9649,7 +9908,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9649
9908
|
const experimentIdPromise = experiment ? (async () => {
|
|
9650
9909
|
try {
|
|
9651
9910
|
return await experiment.id;
|
|
9652
|
-
} catch (
|
|
9911
|
+
} catch (e13) {
|
|
9653
9912
|
return void 0;
|
|
9654
9913
|
}
|
|
9655
9914
|
})() : void 0;
|
|
@@ -9665,7 +9924,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9665
9924
|
if (cancelled) {
|
|
9666
9925
|
return;
|
|
9667
9926
|
}
|
|
9668
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
9927
|
+
const eventDataset = experiment ? experiment.dataset : _chunkTWCDSYJNjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
9669
9928
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
9670
9929
|
object_type: "dataset",
|
|
9671
9930
|
object_id: await eventDataset.id,
|
|
@@ -9673,8 +9932,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9673
9932
|
created: datum.created,
|
|
9674
9933
|
_xact_id: datum._xact_id
|
|
9675
9934
|
} : void 0;
|
|
9676
|
-
const parsedDatumOrigin =
|
|
9677
|
-
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess',
|
|
9935
|
+
const parsedDatumOrigin = _chunkTWCDSYJNjs.ObjectReference.safeParse(datum.origin);
|
|
9936
|
+
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _173 => _173.success]) ? parsedDatumOrigin.data : void 0)));
|
|
9678
9937
|
const baseEvent = {
|
|
9679
9938
|
name: "eval",
|
|
9680
9939
|
spanAttributes: {
|
|
@@ -9689,26 +9948,26 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9689
9948
|
}
|
|
9690
9949
|
};
|
|
9691
9950
|
const callback = async (rootSpan) => {
|
|
9692
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
9951
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, )));
|
|
9693
9952
|
const ensureSpansFlushed = async () => {
|
|
9694
9953
|
if (experiment) {
|
|
9695
|
-
await
|
|
9954
|
+
await _chunkTWCDSYJNjs.flush.call(void 0, { state: experiment.loggingState });
|
|
9696
9955
|
} else if (state) {
|
|
9697
|
-
await
|
|
9956
|
+
await _chunkTWCDSYJNjs.flush.call(void 0, { state });
|
|
9698
9957
|
} else {
|
|
9699
|
-
await
|
|
9958
|
+
await _chunkTWCDSYJNjs.flush.call(void 0, );
|
|
9700
9959
|
}
|
|
9701
9960
|
if (state) {
|
|
9702
9961
|
await state.flushOtel();
|
|
9703
9962
|
}
|
|
9704
9963
|
};
|
|
9705
9964
|
const parentStr = state.currentParent.getStore();
|
|
9706
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
9965
|
+
const parentComponents = typeof parentStr === "string" ? _chunkTWCDSYJNjs.SpanComponentsV4.fromStr(parentStr) : null;
|
|
9707
9966
|
const trace = state ? new LocalTrace({
|
|
9708
|
-
objectType: parentComponents ?
|
|
9967
|
+
objectType: parentComponents ? _chunkTWCDSYJNjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
9709
9968
|
parentComponents.data.object_type
|
|
9710
9969
|
) : "experiment",
|
|
9711
|
-
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async
|
|
9970
|
+
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _174 => _174.data, 'access', async _175 => _175.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
9712
9971
|
rootSpanId: rootSpan.rootSpanId,
|
|
9713
9972
|
ensureSpansFlushed,
|
|
9714
9973
|
state
|
|
@@ -9734,10 +9993,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9734
9993
|
_nullishCoalesce(parameters, () => ( {})),
|
|
9735
9994
|
span,
|
|
9736
9995
|
(event) => {
|
|
9737
|
-
_optionalChain([stream, 'optionalCall',
|
|
9996
|
+
_optionalChain([stream, 'optionalCall', _176 => _176({
|
|
9738
9997
|
...event,
|
|
9739
9998
|
id: rootSpan.id,
|
|
9740
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
9999
|
+
origin: _optionalChain([baseEvent, 'access', _177 => _177.event, 'optionalAccess', _178 => _178.origin]),
|
|
9741
10000
|
name: evaluator.evalName,
|
|
9742
10001
|
object_type: "task"
|
|
9743
10002
|
})]);
|
|
@@ -9770,7 +10029,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9770
10029
|
trace
|
|
9771
10030
|
};
|
|
9772
10031
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
9773
|
-
const propagatedEvent =
|
|
10032
|
+
const propagatedEvent = _chunkTWCDSYJNjs.makeScorerPropagatedEvent.call(void 0,
|
|
9774
10033
|
await rootSpan.export()
|
|
9775
10034
|
);
|
|
9776
10035
|
const [scoreResults, classificationResults] = await Promise.all([
|
|
@@ -9865,7 +10124,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9865
10124
|
evaluator.state
|
|
9866
10125
|
);
|
|
9867
10126
|
} catch (e) {
|
|
9868
|
-
|
|
10127
|
+
_chunkTWCDSYJNjs.logError.call(void 0, rootSpan, e);
|
|
9869
10128
|
error = e;
|
|
9870
10129
|
} finally {
|
|
9871
10130
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -9889,7 +10148,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9889
10148
|
tags: tags.length ? tags : void 0,
|
|
9890
10149
|
metadata,
|
|
9891
10150
|
error,
|
|
9892
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
10151
|
+
origin: _optionalChain([baseEvent, 'access', _179 => _179.event, 'optionalAccess', _180 => _180.origin])
|
|
9893
10152
|
};
|
|
9894
10153
|
collectedResults.push({
|
|
9895
10154
|
...baseResult,
|
|
@@ -9899,7 +10158,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9899
10158
|
}
|
|
9900
10159
|
};
|
|
9901
10160
|
if (!experiment) {
|
|
9902
|
-
return await
|
|
10161
|
+
return await _chunkTWCDSYJNjs.traced.call(void 0, callback, {
|
|
9903
10162
|
...baseEvent,
|
|
9904
10163
|
state: evaluator.state
|
|
9905
10164
|
});
|
|
@@ -9929,7 +10188,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9929
10188
|
break;
|
|
9930
10189
|
}
|
|
9931
10190
|
scheduledTrials++;
|
|
9932
|
-
_optionalChain([progressReporter, 'access',
|
|
10191
|
+
_optionalChain([progressReporter, 'access', _181 => _181.setTotal, 'optionalCall', _182 => _182(evaluator.evalName, scheduledTrials)]);
|
|
9933
10192
|
q.pushAsync({ datum, trialIndex }).catch((e) => {
|
|
9934
10193
|
if (queueErrors.length < 5) {
|
|
9935
10194
|
queueErrors.push(e);
|
|
@@ -9953,7 +10212,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9953
10212
|
const cancel = async () => {
|
|
9954
10213
|
await new Promise((_, reject2) => {
|
|
9955
10214
|
if (cancelled) {
|
|
9956
|
-
reject2(new (0,
|
|
10215
|
+
reject2(new (0, _chunkTWCDSYJNjs.InternalAbortError)("Evaluator already cancelled"));
|
|
9957
10216
|
return;
|
|
9958
10217
|
}
|
|
9959
10218
|
const rejectOnce = (error) => {
|
|
@@ -9966,12 +10225,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9966
10225
|
};
|
|
9967
10226
|
if (evaluator.timeout) {
|
|
9968
10227
|
timeoutId = setTimeout(() => {
|
|
9969
|
-
rejectOnce(new (0,
|
|
10228
|
+
rejectOnce(new (0, _chunkTWCDSYJNjs.InternalAbortError)("Evaluator timed out"));
|
|
9970
10229
|
}, evaluator.timeout);
|
|
9971
10230
|
}
|
|
9972
10231
|
if (evaluator.signal) {
|
|
9973
10232
|
abortHandler = () => {
|
|
9974
|
-
rejectOnce(new (0,
|
|
10233
|
+
rejectOnce(new (0, _chunkTWCDSYJNjs.InternalAbortError)("Evaluator aborted"));
|
|
9975
10234
|
};
|
|
9976
10235
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
9977
10236
|
}
|
|
@@ -9994,9 +10253,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9994
10253
|
}
|
|
9995
10254
|
} catch (e) {
|
|
9996
10255
|
q.kill();
|
|
9997
|
-
if (e instanceof
|
|
9998
|
-
if (
|
|
9999
|
-
|
|
10256
|
+
if (e instanceof _chunkTWCDSYJNjs.InternalAbortError) {
|
|
10257
|
+
if (_chunk2XDW3UCGjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
10258
|
+
_chunk2XDW3UCGjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
10000
10259
|
}
|
|
10001
10260
|
}
|
|
10002
10261
|
throw e;
|
|
@@ -10021,9 +10280,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
10021
10280
|
);
|
|
10022
10281
|
} finally {
|
|
10023
10282
|
if (enableCache) {
|
|
10024
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
10025
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
10026
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
10283
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _183 => _183.spanCache]);
|
|
10284
|
+
_optionalChain([spanCache, 'optionalAccess', _184 => _184.dispose, 'call', _185 => _185()]);
|
|
10285
|
+
_optionalChain([spanCache, 'optionalAccess', _186 => _186.stop, 'call', _187 => _187()]);
|
|
10027
10286
|
}
|
|
10028
10287
|
}
|
|
10029
10288
|
}
|
|
@@ -10116,25 +10375,25 @@ var defaultReporter = {
|
|
|
10116
10375
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
10117
10376
|
}
|
|
10118
10377
|
if (jsonl) {
|
|
10119
|
-
|
|
10378
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
10120
10379
|
} else {
|
|
10121
|
-
|
|
10122
|
-
|
|
10380
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln("Experiment summary");
|
|
10381
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln("==================");
|
|
10123
10382
|
if (summary.comparisonExperimentName) {
|
|
10124
|
-
|
|
10383
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(
|
|
10125
10384
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
10126
10385
|
);
|
|
10127
|
-
|
|
10386
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln("");
|
|
10128
10387
|
}
|
|
10129
10388
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
10130
10389
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
10131
10390
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
10132
10391
|
if (hasScores || hasMetrics) {
|
|
10133
10392
|
if (hasComparison) {
|
|
10134
|
-
|
|
10393
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(
|
|
10135
10394
|
"Name Value Change Improvements Regressions"
|
|
10136
10395
|
);
|
|
10137
|
-
|
|
10396
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(
|
|
10138
10397
|
"----------------------------------------------------------------"
|
|
10139
10398
|
);
|
|
10140
10399
|
}
|
|
@@ -10143,18 +10402,18 @@ var defaultReporter = {
|
|
|
10143
10402
|
const scoreValue = `${scorePercent}%`;
|
|
10144
10403
|
if (hasComparison) {
|
|
10145
10404
|
let diffString = "-";
|
|
10146
|
-
if (!
|
|
10405
|
+
if (!_chunkTWCDSYJNjs.isEmpty.call(void 0, score.diff)) {
|
|
10147
10406
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
10148
10407
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
10149
10408
|
diffString = `${diffSign}${diffPercent}%`;
|
|
10150
10409
|
}
|
|
10151
10410
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
10152
10411
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
10153
|
-
|
|
10412
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(
|
|
10154
10413
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
10155
10414
|
);
|
|
10156
10415
|
} else {
|
|
10157
|
-
|
|
10416
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
10158
10417
|
}
|
|
10159
10418
|
}
|
|
10160
10419
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -10163,30 +10422,30 @@ var defaultReporter = {
|
|
|
10163
10422
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
10164
10423
|
if (hasComparison) {
|
|
10165
10424
|
let diffString = "-";
|
|
10166
|
-
if (!
|
|
10425
|
+
if (!_chunkTWCDSYJNjs.isEmpty.call(void 0, metric.diff)) {
|
|
10167
10426
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
10168
10427
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
10169
10428
|
diffString = `${diffSign}${diffPercent}%`;
|
|
10170
10429
|
}
|
|
10171
10430
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
10172
10431
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
10173
|
-
|
|
10432
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(
|
|
10174
10433
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
10175
10434
|
);
|
|
10176
10435
|
} else {
|
|
10177
|
-
|
|
10436
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(
|
|
10178
10437
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
10179
10438
|
);
|
|
10180
10439
|
}
|
|
10181
10440
|
}
|
|
10182
10441
|
}
|
|
10183
10442
|
if (summary.experimentUrl) {
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10443
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln("");
|
|
10444
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(`View results for ${summary.experimentName}`);
|
|
10445
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
|
|
10187
10446
|
}
|
|
10188
10447
|
}
|
|
10189
|
-
|
|
10448
|
+
_chunk2XDW3UCGjs.isomorph_default.writeln("");
|
|
10190
10449
|
return failingResults.length === 0;
|
|
10191
10450
|
},
|
|
10192
10451
|
async reportRun(evalReports) {
|
|
@@ -10203,7 +10462,7 @@ var DEFAULT_BATCH_SIZE = 1e3;
|
|
|
10203
10462
|
var DurableEvalMemoryStore = (_class8 = class {constructor() { _class8.prototype.__init21.call(this); }
|
|
10204
10463
|
__init21() {this.values = /* @__PURE__ */ new Map()}
|
|
10205
10464
|
async read(key) {
|
|
10206
|
-
return _optionalChain([this, 'access',
|
|
10465
|
+
return _optionalChain([this, 'access', _188 => _188.values, 'access', _189 => _189.get, 'call', _190 => _190(key), 'optionalAccess', _191 => _191.slice, 'call', _192 => _192()]);
|
|
10207
10466
|
}
|
|
10208
10467
|
async write(key, value) {
|
|
10209
10468
|
this.values.set(key, value.slice());
|
|
@@ -10233,13 +10492,13 @@ var DurableEvalRedisStore = class {
|
|
|
10233
10492
|
if (typeof value !== "string") {
|
|
10234
10493
|
throw new Error("DurableEvalRedisStore expected GET to return a string");
|
|
10235
10494
|
}
|
|
10236
|
-
return
|
|
10495
|
+
return _chunkTWCDSYJNjs.base64ToUint8Array.call(void 0, value);
|
|
10237
10496
|
}
|
|
10238
10497
|
async write(key, value) {
|
|
10239
10498
|
const client = this.client;
|
|
10240
10499
|
const set = client.set;
|
|
10241
10500
|
const redisKey = `${this.keyPrefix}${key}`;
|
|
10242
|
-
const encoded =
|
|
10501
|
+
const encoded = _chunkTWCDSYJNjs.uint8ArrayToBase64.call(void 0, value);
|
|
10243
10502
|
if (typeof client.defineCommand === "function") {
|
|
10244
10503
|
await set.call(client, redisKey, encoded, "PX", this.ttlMs);
|
|
10245
10504
|
} else if (typeof client.sendCommand === "function") {
|
|
@@ -10254,7 +10513,7 @@ var DurableEvalRedisStore = class {
|
|
|
10254
10513
|
}
|
|
10255
10514
|
async getOrSet(key, value) {
|
|
10256
10515
|
const redisKey = `${this.keyPrefix}${key}`;
|
|
10257
|
-
const encoded =
|
|
10516
|
+
const encoded = _chunkTWCDSYJNjs.uint8ArrayToBase64.call(void 0, value);
|
|
10258
10517
|
const client = this.client;
|
|
10259
10518
|
const set = client.set;
|
|
10260
10519
|
let setOptions;
|
|
@@ -10276,7 +10535,7 @@ var DurableEvalRedisStore = class {
|
|
|
10276
10535
|
"DurableEvalRedisStore expected atomic SET to return a string or null"
|
|
10277
10536
|
);
|
|
10278
10537
|
}
|
|
10279
|
-
return { value:
|
|
10538
|
+
return { value: _chunkTWCDSYJNjs.base64ToUint8Array.call(void 0, existing), created: false };
|
|
10280
10539
|
}
|
|
10281
10540
|
};
|
|
10282
10541
|
var BatchTask = (_class9 = class {
|
|
@@ -10310,7 +10569,7 @@ function defineDurableEval(projectName, evaluator) {
|
|
|
10310
10569
|
}
|
|
10311
10570
|
async function startDurableEval(definition, options) {
|
|
10312
10571
|
const store = definition.evaluator.store;
|
|
10313
|
-
const runId =
|
|
10572
|
+
const runId = _chunkTWCDSYJNjs.newId.call(void 0, );
|
|
10314
10573
|
const key = runKey(definition.projectName, definition.evalName, runId);
|
|
10315
10574
|
const { data } = callEvaluatorData(definition.evaluator.data);
|
|
10316
10575
|
const parameters = await validateParameters(
|
|
@@ -10358,7 +10617,7 @@ async function startDurableEval(definition, options) {
|
|
|
10358
10617
|
cases: [],
|
|
10359
10618
|
batches: []
|
|
10360
10619
|
};
|
|
10361
|
-
await _optionalChain([experiment, 'optionalAccess',
|
|
10620
|
+
await _optionalChain([experiment, 'optionalAccess', _193 => _193.flush, 'call', _194 => _194()]);
|
|
10362
10621
|
await writeRunRecord(store, key, state2);
|
|
10363
10622
|
return currentStatus(definition, state2);
|
|
10364
10623
|
}
|
|
@@ -10523,9 +10782,9 @@ function currentStatus(definition, state) {
|
|
|
10523
10782
|
return { status: "waiting", runId: state.runId, pending };
|
|
10524
10783
|
}
|
|
10525
10784
|
async function startCaseRoot(definition, state, record, experiment) {
|
|
10526
|
-
if (!experiment) return
|
|
10785
|
+
if (!experiment) return _chunkTWCDSYJNjs.NOOP_SPAN;
|
|
10527
10786
|
const datum = record.datum;
|
|
10528
|
-
return
|
|
10787
|
+
return _chunkTWCDSYJNjs._internalStartSpanWithInitialMerge.call(void 0, {
|
|
10529
10788
|
...definition.evaluator.state ? { state: definition.evaluator.state } : {},
|
|
10530
10789
|
parent: await experiment.export(),
|
|
10531
10790
|
name: "eval",
|
|
@@ -10591,7 +10850,7 @@ async function logTaskResult(definition, state, record, experiment, task) {
|
|
|
10591
10850
|
record.rootSpan = await root.export();
|
|
10592
10851
|
record.taskLogged = true;
|
|
10593
10852
|
} catch (error) {
|
|
10594
|
-
|
|
10853
|
+
_chunkTWCDSYJNjs.logError.call(void 0, root, error);
|
|
10595
10854
|
throw error;
|
|
10596
10855
|
} finally {
|
|
10597
10856
|
root.end();
|
|
@@ -10606,7 +10865,7 @@ async function logCompletedTasks(definition, state, store, key, experiment) {
|
|
|
10606
10865
|
changed.push(record);
|
|
10607
10866
|
}
|
|
10608
10867
|
if (changed.length > 0) {
|
|
10609
|
-
await _optionalChain([experiment, 'optionalAccess',
|
|
10868
|
+
await _optionalChain([experiment, 'optionalAccess', _195 => _195.flush, 'call', _196 => _196()]);
|
|
10610
10869
|
await writeCaseRecords(store, key, changed);
|
|
10611
10870
|
}
|
|
10612
10871
|
}
|
|
@@ -10624,7 +10883,7 @@ async function runTaskStage(definition, state, store, key, experiment) {
|
|
|
10624
10883
|
changed.push(record);
|
|
10625
10884
|
}
|
|
10626
10885
|
if (changed.length > 0) {
|
|
10627
|
-
await _optionalChain([experiment, 'optionalAccess',
|
|
10886
|
+
await _optionalChain([experiment, 'optionalAccess', _197 => _197.flush, 'call', _198 => _198()]);
|
|
10628
10887
|
await writeCaseRecords(store, key, changed);
|
|
10629
10888
|
}
|
|
10630
10889
|
}
|
|
@@ -10633,7 +10892,7 @@ async function runScoreStages(definition, state, store, key, experiment) {
|
|
|
10633
10892
|
const changed = /* @__PURE__ */ new Map();
|
|
10634
10893
|
const persistChangedCases = async () => {
|
|
10635
10894
|
if (changed.size === 0) return;
|
|
10636
|
-
await _optionalChain([experiment, 'optionalAccess',
|
|
10895
|
+
await _optionalChain([experiment, 'optionalAccess', _199 => _199.flush, 'call', _200 => _200()]);
|
|
10637
10896
|
await writeCaseRecords(store, key, [...changed.values()]);
|
|
10638
10897
|
changed.clear();
|
|
10639
10898
|
};
|
|
@@ -10701,11 +10960,11 @@ function scorerArgs(record) {
|
|
|
10701
10960
|
};
|
|
10702
10961
|
}
|
|
10703
10962
|
function resumeCaseRoot(definition, record, experiment) {
|
|
10704
|
-
if (!experiment) return
|
|
10963
|
+
if (!experiment) return _chunkTWCDSYJNjs.NOOP_SPAN;
|
|
10705
10964
|
if (!record.rootSpan) {
|
|
10706
10965
|
throw new Error(`Durable eval case ${record.caseId} has no root span`);
|
|
10707
10966
|
}
|
|
10708
|
-
return
|
|
10967
|
+
return _chunkTWCDSYJNjs._internalResumeSpan.call(void 0, {
|
|
10709
10968
|
exported: record.rootSpan,
|
|
10710
10969
|
state: definition.evaluator.state
|
|
10711
10970
|
});
|
|
@@ -10737,14 +10996,14 @@ async function evaluateAndLogScore(definition, state, record, name, experiment,
|
|
|
10737
10996
|
type: "score" /* SCORE */,
|
|
10738
10997
|
purpose: "scorer"
|
|
10739
10998
|
},
|
|
10740
|
-
propagatedEvent:
|
|
10999
|
+
propagatedEvent: _chunkTWCDSYJNjs.makeScorerPropagatedEvent.call(void 0, rootExport || void 0),
|
|
10741
11000
|
event: { input: scorerArgs(record) }
|
|
10742
11001
|
}
|
|
10743
11002
|
);
|
|
10744
11003
|
if (prepared.scores) root.log({ scores: prepared.scores });
|
|
10745
11004
|
record.loggedScores[name] = true;
|
|
10746
11005
|
} catch (error) {
|
|
10747
|
-
|
|
11006
|
+
_chunkTWCDSYJNjs.logError.call(void 0, root, error);
|
|
10748
11007
|
throw error;
|
|
10749
11008
|
} finally {
|
|
10750
11009
|
root.end();
|
|
@@ -10776,7 +11035,7 @@ async function evaluateAndLogClassification(definition, state, record, name, cla
|
|
|
10776
11035
|
type: "classifier" /* CLASSIFIER */,
|
|
10777
11036
|
purpose: "scorer"
|
|
10778
11037
|
},
|
|
10779
|
-
propagatedEvent:
|
|
11038
|
+
propagatedEvent: _chunkTWCDSYJNjs.makeScorerPropagatedEvent.call(void 0, rootExport || void 0),
|
|
10780
11039
|
event: { input: scorerArgs(record) }
|
|
10781
11040
|
}
|
|
10782
11041
|
);
|
|
@@ -10785,7 +11044,7 @@ async function evaluateAndLogClassification(definition, state, record, name, cla
|
|
|
10785
11044
|
}
|
|
10786
11045
|
record.loggedClassifications[name] = true;
|
|
10787
11046
|
} catch (error) {
|
|
10788
|
-
|
|
11047
|
+
_chunkTWCDSYJNjs.logError.call(void 0, root, error);
|
|
10789
11048
|
throw error;
|
|
10790
11049
|
} finally {
|
|
10791
11050
|
root.end();
|
|
@@ -10898,9 +11157,9 @@ function processorForStage(definition, kind, scorerName2) {
|
|
|
10898
11157
|
}
|
|
10899
11158
|
return definition.evaluator.task.processor;
|
|
10900
11159
|
}
|
|
10901
|
-
const scorer = _optionalChain([resolveScorers, 'call',
|
|
11160
|
+
const scorer = _optionalChain([resolveScorers, 'call', _201 => _201(_nullishCoalesce(definition.evaluator.scores, () => ( []))), 'access', _202 => _202.find, 'call', _203 => _203(
|
|
10902
11161
|
({ name }) => name === scorerName2
|
|
10903
|
-
), 'optionalAccess',
|
|
11162
|
+
), 'optionalAccess', _204 => _204.scorer]);
|
|
10904
11163
|
if (!isBatchScorer(scorer)) {
|
|
10905
11164
|
throw new Error(`Definition no longer contains scorer ${scorerName2}`);
|
|
10906
11165
|
}
|
|
@@ -11027,7 +11286,7 @@ async function finishExperiment(definition, state, experiment) {
|
|
|
11027
11286
|
if (!comparisonExperimentId) {
|
|
11028
11287
|
try {
|
|
11029
11288
|
comparisonExperimentId = await experiment._getBaseExperimentId();
|
|
11030
|
-
} catch (
|
|
11289
|
+
} catch (e14) {
|
|
11031
11290
|
comparisonExperimentId = void 0;
|
|
11032
11291
|
}
|
|
11033
11292
|
}
|
|
@@ -11046,7 +11305,7 @@ function runKey(projectName, evalName, runId) {
|
|
|
11046
11305
|
return `durable-eval/v1/runs/${contentVersion(encoder.encode(`${projectName}\0${evalName}\0${runId}`))}`;
|
|
11047
11306
|
}
|
|
11048
11307
|
function encodedKeyPart(value) {
|
|
11049
|
-
return
|
|
11308
|
+
return _chunkTWCDSYJNjs.uint8ArrayToBase64.call(void 0, encoder.encode(value)).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
11050
11309
|
}
|
|
11051
11310
|
function caseRecordKey(key, caseId, kind, ...names) {
|
|
11052
11311
|
const suffix = names.map(encodedKeyPart).join("/");
|
|
@@ -11170,12 +11429,12 @@ async function readCaseRecord(definition, store, key, id) {
|
|
|
11170
11429
|
}
|
|
11171
11430
|
return {
|
|
11172
11431
|
...base,
|
|
11173
|
-
metadata: _nullishCoalesce(_optionalChain([task, 'optionalAccess',
|
|
11432
|
+
metadata: _nullishCoalesce(_optionalChain([task, 'optionalAccess', _205 => _205.metadata]), () => ( base.metadata)),
|
|
11174
11433
|
tags: task ? task.tags : base.tags,
|
|
11175
11434
|
taskComplete: task !== void 0,
|
|
11176
11435
|
taskLogged: taskLog !== void 0,
|
|
11177
|
-
output: _optionalChain([task, 'optionalAccess',
|
|
11178
|
-
rootSpan: _optionalChain([taskLog, 'optionalAccess',
|
|
11436
|
+
output: _optionalChain([task, 'optionalAccess', _206 => _206.output]),
|
|
11437
|
+
rootSpan: _optionalChain([taskLog, 'optionalAccess', _207 => _207.rootSpan]),
|
|
11179
11438
|
scores,
|
|
11180
11439
|
loggedScores,
|
|
11181
11440
|
classifications,
|
|
@@ -11291,7 +11550,7 @@ function deterministicId(value) {
|
|
|
11291
11550
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-5${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
11292
11551
|
}
|
|
11293
11552
|
function contentVersion(value) {
|
|
11294
|
-
if (
|
|
11553
|
+
if (_chunk2XDW3UCGjs.isomorph_default.hash) return _chunk2XDW3UCGjs.isomorph_default.hash(decoder.decode(value));
|
|
11295
11554
|
let hash = 2166136261;
|
|
11296
11555
|
for (const byte of value) {
|
|
11297
11556
|
hash ^= byte;
|
|
@@ -11356,7 +11615,7 @@ function agentAssertionScorer(callback, options = {}) {
|
|
|
11356
11615
|
});
|
|
11357
11616
|
const resources = {};
|
|
11358
11617
|
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
11359
|
-
resources.spans = await _optionalChain([args, 'access',
|
|
11618
|
+
resources.spans = await _optionalChain([args, 'access', _208 => _208.trace, 'optionalAccess', _209 => _209.getSpans, 'call', _210 => _210({ spanType: ["tool"] })]);
|
|
11360
11619
|
}
|
|
11361
11620
|
const results = await Promise.all(
|
|
11362
11621
|
assertions.map(async (assertion) => {
|
|
@@ -11514,7 +11773,7 @@ async function validateSchema(schema, value) {
|
|
|
11514
11773
|
}
|
|
11515
11774
|
}
|
|
11516
11775
|
function toolCalls(spans) {
|
|
11517
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
11776
|
+
return spans.filter((span) => _optionalChain([span, 'access', _211 => _211.span_attributes, 'optionalAccess', _212 => _212.type]) === "tool");
|
|
11518
11777
|
}
|
|
11519
11778
|
function matchingToolCalls(spans, toolName, options) {
|
|
11520
11779
|
return toolCalls(spans).filter((span) => {
|
|
@@ -11532,17 +11791,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
11532
11791
|
});
|
|
11533
11792
|
}
|
|
11534
11793
|
function getToolName(span) {
|
|
11535
|
-
const spanName = [_optionalChain([span, 'access',
|
|
11536
|
-
if (_optionalChain([spanName, 'optionalAccess',
|
|
11794
|
+
const spanName = [_optionalChain([span, 'access', _213 => _213.span_attributes, 'optionalAccess', _214 => _214.name]), span.name].map(normalizeToolName).find((value) => value !== void 0);
|
|
11795
|
+
if (_optionalChain([spanName, 'optionalAccess', _215 => _215.includes, 'call', _216 => _216("/")])) {
|
|
11537
11796
|
return spanName;
|
|
11538
11797
|
}
|
|
11539
11798
|
const metadataName = [
|
|
11540
|
-
_optionalChain([span, 'access',
|
|
11541
|
-
_optionalChain([span, 'access',
|
|
11799
|
+
_optionalChain([span, 'access', _217 => _217.metadata, 'optionalAccess', _218 => _218.tool_name]),
|
|
11800
|
+
_optionalChain([span, 'access', _219 => _219.metadata, 'optionalAccess', _220 => _220["gen_ai.tool.name"]])
|
|
11542
11801
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
11543
11802
|
const mcpServer = [
|
|
11544
|
-
_optionalChain([span, 'access',
|
|
11545
|
-
_optionalChain([span, 'access',
|
|
11803
|
+
_optionalChain([span, 'access', _221 => _221.metadata, 'optionalAccess', _222 => _222["mcp.server"]]),
|
|
11804
|
+
_optionalChain([span, 'access', _223 => _223.metadata, 'optionalAccess', _224 => _224["openai_codex.mcp.server"]])
|
|
11546
11805
|
].find((value) => typeof value === "string" && value !== "");
|
|
11547
11806
|
if (metadataName && mcpServer) {
|
|
11548
11807
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -11612,7 +11871,7 @@ function formatValue(value) {
|
|
|
11612
11871
|
return serialized;
|
|
11613
11872
|
}
|
|
11614
11873
|
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
11615
|
-
} catch (
|
|
11874
|
+
} catch (e15) {
|
|
11616
11875
|
return String(value);
|
|
11617
11876
|
}
|
|
11618
11877
|
}
|
|
@@ -11771,7 +12030,7 @@ var Project2 = (_class11 = class {
|
|
|
11771
12030
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
11772
12031
|
return;
|
|
11773
12032
|
}
|
|
11774
|
-
await
|
|
12033
|
+
await _chunkTWCDSYJNjs.login.call(void 0, );
|
|
11775
12034
|
const projectMap = new ProjectNameIdMap();
|
|
11776
12035
|
const functionDefinitions = [];
|
|
11777
12036
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -11785,7 +12044,7 @@ var Project2 = (_class11 = class {
|
|
|
11785
12044
|
functionDefinitions.push(functionDefinition);
|
|
11786
12045
|
}
|
|
11787
12046
|
}
|
|
11788
|
-
await
|
|
12047
|
+
await _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
11789
12048
|
functions: functionDefinitions
|
|
11790
12049
|
});
|
|
11791
12050
|
}
|
|
@@ -11804,12 +12063,12 @@ var ToolBuilder = (_class12 = class {
|
|
|
11804
12063
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
11805
12064
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
11806
12065
|
if (resolvedName.trim().length === 0) {
|
|
11807
|
-
resolvedName = `Tool ${
|
|
12066
|
+
resolvedName = `Tool ${_chunk2XDW3UCGjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
11808
12067
|
}
|
|
11809
12068
|
const tool = new CodeFunction(this.project, {
|
|
11810
12069
|
handler,
|
|
11811
12070
|
name: resolvedName,
|
|
11812
|
-
slug: _nullishCoalesce(slug, () => (
|
|
12071
|
+
slug: _nullishCoalesce(slug, () => ( _chunkTWCDSYJNjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
11813
12072
|
type: "tool",
|
|
11814
12073
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
11815
12074
|
parameters,
|
|
@@ -11834,9 +12093,9 @@ var ScorerBuilder = (_class13 = class {
|
|
|
11834
12093
|
resolvedName = opts.handler.name;
|
|
11835
12094
|
}
|
|
11836
12095
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
11837
|
-
resolvedName = `Scorer ${
|
|
12096
|
+
resolvedName = `Scorer ${_chunk2XDW3UCGjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
11838
12097
|
}
|
|
11839
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
12098
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkTWCDSYJNjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
11840
12099
|
if ("handler" in opts) {
|
|
11841
12100
|
const scorer = new CodeFunction(this.project, {
|
|
11842
12101
|
...opts,
|
|
@@ -11891,9 +12150,9 @@ var ClassifierBuilder = (_class14 = class {
|
|
|
11891
12150
|
this.taskCounter++;
|
|
11892
12151
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
11893
12152
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
11894
|
-
resolvedName = `Classifier ${
|
|
12153
|
+
resolvedName = `Classifier ${_chunk2XDW3UCGjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
11895
12154
|
}
|
|
11896
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
12155
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkTWCDSYJNjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
11897
12156
|
const classifier = new CodeFunction(this.project, {
|
|
11898
12157
|
...opts,
|
|
11899
12158
|
name: resolvedName,
|
|
@@ -12022,18 +12281,18 @@ var PromptBuilder = class {
|
|
|
12022
12281
|
rawTools.push(tool);
|
|
12023
12282
|
}
|
|
12024
12283
|
}
|
|
12025
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
12284
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkTWCDSYJNjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
12026
12285
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
12027
12286
|
const promptRow = {
|
|
12028
12287
|
id: opts.id,
|
|
12029
|
-
_xact_id: opts.version ?
|
|
12288
|
+
_xact_id: opts.version ? _chunkTWCDSYJNjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
12030
12289
|
name: opts.name,
|
|
12031
12290
|
slug,
|
|
12032
12291
|
prompt_data: promptData,
|
|
12033
12292
|
tags: opts.tags,
|
|
12034
12293
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
12035
12294
|
};
|
|
12036
|
-
const prompt = new (0,
|
|
12295
|
+
const prompt = new (0, _chunkTWCDSYJNjs.Prompt)(
|
|
12037
12296
|
promptRow,
|
|
12038
12297
|
{},
|
|
12039
12298
|
// It doesn't make sense to specify defaults here.
|
|
@@ -12088,7 +12347,7 @@ var ParametersBuilder = class {
|
|
|
12088
12347
|
}
|
|
12089
12348
|
|
|
12090
12349
|
create(opts) {
|
|
12091
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
12350
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkTWCDSYJNjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
12092
12351
|
const codeParameters = new CodeParameters(this.project, {
|
|
12093
12352
|
name: opts.name,
|
|
12094
12353
|
slug,
|
|
@@ -12127,7 +12386,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
12127
12386
|
required.push(name);
|
|
12128
12387
|
}
|
|
12129
12388
|
} else {
|
|
12130
|
-
const schemaObj =
|
|
12389
|
+
const schemaObj = _chunkTWCDSYJNjs.zodToJsonSchema.call(void 0, value);
|
|
12131
12390
|
properties[name] = schemaObj;
|
|
12132
12391
|
if (!("default" in schemaObj)) {
|
|
12133
12392
|
required.push(name);
|
|
@@ -12156,11 +12415,11 @@ var ProjectNameIdMap = (_class15 = class {constructor() { _class15.prototype.__i
|
|
|
12156
12415
|
__init31() {this.idToName = {}}
|
|
12157
12416
|
async getId(projectName) {
|
|
12158
12417
|
if (!(projectName in this.nameToId)) {
|
|
12159
|
-
const response = await
|
|
12418
|
+
const response = await _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
12160
12419
|
project_name: projectName
|
|
12161
12420
|
});
|
|
12162
12421
|
const result = _v3.z.object({
|
|
12163
|
-
project:
|
|
12422
|
+
project: _chunkTWCDSYJNjs.Project
|
|
12164
12423
|
}).parse(response);
|
|
12165
12424
|
const projectId = result.project.id;
|
|
12166
12425
|
this.nameToId[projectName] = projectId;
|
|
@@ -12170,10 +12429,10 @@ var ProjectNameIdMap = (_class15 = class {constructor() { _class15.prototype.__i
|
|
|
12170
12429
|
}
|
|
12171
12430
|
async getName(projectId) {
|
|
12172
12431
|
if (!(projectId in this.idToName)) {
|
|
12173
|
-
const response = await
|
|
12432
|
+
const response = await _chunkTWCDSYJNjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
12174
12433
|
id: projectId
|
|
12175
12434
|
});
|
|
12176
|
-
const result = _v3.z.array(
|
|
12435
|
+
const result = _v3.z.array(_chunkTWCDSYJNjs.Project).nonempty().parse(response);
|
|
12177
12436
|
const projectName = result[0].name;
|
|
12178
12437
|
this.idToName[projectId] = projectName;
|
|
12179
12438
|
this.nameToId[projectName] = projectId;
|
|
@@ -12193,16 +12452,16 @@ var ProjectNameIdMap = (_class15 = class {constructor() { _class15.prototype.__i
|
|
|
12193
12452
|
var evalBodySchema = _v3.z.object({
|
|
12194
12453
|
name: _v3.z.string(),
|
|
12195
12454
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
12196
|
-
data:
|
|
12455
|
+
data: _chunkTWCDSYJNjs.RunEval.shape.data,
|
|
12197
12456
|
scores: _v3.z.array(
|
|
12198
12457
|
_v3.z.object({
|
|
12199
|
-
function_id:
|
|
12458
|
+
function_id: _chunkTWCDSYJNjs.FunctionId,
|
|
12200
12459
|
name: _v3.z.string()
|
|
12201
12460
|
})
|
|
12202
12461
|
).nullish(),
|
|
12203
12462
|
experiment_name: _v3.z.string().nullish(),
|
|
12204
12463
|
project_id: _v3.z.string().nullish(),
|
|
12205
|
-
parent:
|
|
12464
|
+
parent: _chunkTWCDSYJNjs.InvokeParent.optional(),
|
|
12206
12465
|
stream: _v3.z.boolean().optional()
|
|
12207
12466
|
});
|
|
12208
12467
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -12210,7 +12469,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
12210
12469
|
_v3.z.union([
|
|
12211
12470
|
_v3.z.object({
|
|
12212
12471
|
type: _v3.z.literal("prompt"),
|
|
12213
|
-
default:
|
|
12472
|
+
default: _chunkTWCDSYJNjs.PromptData.optional(),
|
|
12214
12473
|
description: _v3.z.string().optional()
|
|
12215
12474
|
}),
|
|
12216
12475
|
_v3.z.object({
|
|
@@ -12266,7 +12525,10 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
12266
12525
|
);
|
|
12267
12526
|
|
|
12268
12527
|
// src/node/index.ts
|
|
12269
|
-
|
|
12528
|
+
_chunkTWCDSYJNjs.configureNode.call(void 0, );
|
|
12529
|
+
|
|
12530
|
+
|
|
12531
|
+
|
|
12270
12532
|
|
|
12271
12533
|
|
|
12272
12534
|
|
|
@@ -12449,4 +12711,4 @@ _chunkXLLGRXGRjs.configureNode.call(void 0, );
|
|
|
12449
12711
|
|
|
12450
12712
|
|
|
12451
12713
|
|
|
12452
|
-
exports.Attachment = _chunkXLLGRXGRjs.Attachment; exports.AttachmentReference = _chunkXLLGRXGRjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkXLLGRXGRjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkXLLGRXGRjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkXLLGRXGRjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkXLLGRXGRjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkXLLGRXGRjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BatchScorer = BatchScorer; exports.BatchTask = BatchTask; exports.BraintrustLangChainCallbackHandler = _chunkXLLGRXGRjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkXLLGRXGRjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkXLLGRXGRjs.BraintrustState; exports.BraintrustStream = _chunkXLLGRXGRjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkXLLGRXGRjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkXLLGRXGRjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkXLLGRXGRjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkXLLGRXGRjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.DurableEvalMemoryStore = DurableEvalMemoryStore; exports.DurableEvalRedisStore = DurableEvalRedisStore; exports.ERR_PERMALINK = _chunkXLLGRXGRjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkXLLGRXGRjs.Experiment; exports.ExternalAttachment = _chunkXLLGRXGRjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkXLLGRXGRjs.FailedHTTPResponse; exports.IDGenerator = _chunkXLLGRXGRjs.IDGenerator; exports.JSONAttachment = _chunkXLLGRXGRjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkXLLGRXGRjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkXLLGRXGRjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkXLLGRXGRjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkXLLGRXGRjs.Logger; exports.LoginInvalidOrgError = _chunkXLLGRXGRjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkXLLGRXGRjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkXLLGRXGRjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkXLLGRXGRjs.NoopSpan; exports.OTELIDGenerator = _chunkXLLGRXGRjs.OTELIDGenerator; exports.ObjectFetcher = _chunkXLLGRXGRjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkXLLGRXGRjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkXLLGRXGRjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkXLLGRXGRjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkXLLGRXGRjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkXLLGRXGRjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkXLLGRXGRjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkXLLGRXGRjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkXLLGRXGRjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkXLLGRXGRjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkXLLGRXGRjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkXLLGRXGRjs._internalGetGlobalState; exports._internalIso = _chunk6Z5S7VOUjs.isomorph_default; exports._internalSetInitialState = _chunkXLLGRXGRjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkXLLGRXGRjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkXLLGRXGRjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkXLLGRXGRjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkXLLGRXGRjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkXLLGRXGRjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.collectAnthropicSession = _chunkXLLGRXGRjs.collectAnthropicSession; exports.configureInstrumentation = _chunkXLLGRXGRjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkXLLGRXGRjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkXLLGRXGRjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkXLLGRXGRjs.currentExperiment; exports.currentLogger = _chunkXLLGRXGRjs.currentLogger; exports.currentSpan = _chunkXLLGRXGRjs.currentSpan; exports.deepCopyEvent = _chunkXLLGRXGRjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.defineDurableEval = defineDurableEval; exports.deserializePlainStringAsJSON = _chunkXLLGRXGRjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkXLLGRXGRjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkXLLGRXGRjs.extractTraceContextFromHeaders; exports.flush = _chunkXLLGRXGRjs.flush; exports.getContextManager = _chunkXLLGRXGRjs.getContextManager; exports.getIdGenerator = _chunkXLLGRXGRjs.getIdGenerator; exports.getPromptVersions = _chunkXLLGRXGRjs.getPromptVersions; exports.getSpanParentObject = _chunkXLLGRXGRjs.getSpanParentObject; exports.getTemplateRenderer = _chunkXLLGRXGRjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkXLLGRXGRjs.init; exports.initDataset = _chunkXLLGRXGRjs.initDataset; exports.initExperiment = _chunkXLLGRXGRjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkXLLGRXGRjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkXLLGRXGRjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkXLLGRXGRjs.isTemplateFormat; exports.loadParameters = _chunkXLLGRXGRjs.loadParameters; exports.loadPrompt = _chunkXLLGRXGRjs.loadPrompt; exports.log = _chunkXLLGRXGRjs.log; exports.logError = _chunkXLLGRXGRjs.logError; exports.login = _chunkXLLGRXGRjs.login; exports.loginToState = _chunkXLLGRXGRjs.loginToState; exports.logs3OverflowUploadSchema = _chunkXLLGRXGRjs.logs3OverflowUploadSchema; exports.newId = _chunkXLLGRXGRjs.newId; exports.parseCachedHeader = _chunkXLLGRXGRjs.parseCachedHeader; exports.parseTemplateFormat = _chunkXLLGRXGRjs.parseTemplateFormat; exports.permalink = _chunkXLLGRXGRjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkXLLGRXGRjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkXLLGRXGRjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkXLLGRXGRjs.registerTemplatePlugin; exports.renderMessage = _chunkXLLGRXGRjs.renderMessage; exports.renderPromptParams = _chunkXLLGRXGRjs.renderPromptParams; exports.renderTemplateContent = _chunkXLLGRXGRjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkXLLGRXGRjs.setFetch; exports.setMaskingFunction = _chunkXLLGRXGRjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkXLLGRXGRjs.spanComponentsToObjectId; exports.startSpan = _chunkXLLGRXGRjs.startSpan; exports.summarize = _chunkXLLGRXGRjs.summarize; exports.templateRegistry = _chunkXLLGRXGRjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkXLLGRXGRjs.ToolFunctionDefinition; exports.traceable = _chunkXLLGRXGRjs.traceable; exports.traced = _chunkXLLGRXGRjs.traced; exports.updateSpan = _chunkXLLGRXGRjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkXLLGRXGRjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkXLLGRXGRjs.utf8ByteLength; exports.withCurrent = _chunkXLLGRXGRjs.withCurrent; exports.withDataset = _chunkXLLGRXGRjs.withDataset; exports.withExperiment = _chunkXLLGRXGRjs.withExperiment; exports.withLogger = _chunkXLLGRXGRjs.withLogger; exports.withParent = _chunkXLLGRXGRjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCloudflareAIChat = wrapCloudflareAIChat; exports.wrapCloudflareAgent = wrapCloudflareAgent; exports.wrapCloudflareThink = wrapCloudflareThink; 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.wrapHuggingFaceTransformers = wrapHuggingFaceTransformers; exports.wrapLangSmithClient = wrapLangSmithClient; exports.wrapLangSmithRunTrees = wrapLangSmithRunTrees; exports.wrapLangSmithTraceable = wrapLangSmithTraceable; exports.wrapMastraAgent = _chunkXLLGRXGRjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOllama = wrapOllama; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkXLLGRXGRjs.wrapTraced; exports.wrapVitest = wrapVitest; exports.wrapVoyageAI = wrapVoyageAI;
|
|
12714
|
+
exports.Attachment = _chunkTWCDSYJNjs.Attachment; exports.AttachmentReference = _chunkTWCDSYJNjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkTWCDSYJNjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkTWCDSYJNjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkTWCDSYJNjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkTWCDSYJNjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkTWCDSYJNjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BatchScorer = BatchScorer; exports.BatchTask = BatchTask; exports.BraintrustLangChainCallbackHandler = _chunkTWCDSYJNjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkTWCDSYJNjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkTWCDSYJNjs.BraintrustState; exports.BraintrustStream = _chunkTWCDSYJNjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkTWCDSYJNjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkTWCDSYJNjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkTWCDSYJNjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkTWCDSYJNjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.DurableEvalMemoryStore = DurableEvalMemoryStore; exports.DurableEvalRedisStore = DurableEvalRedisStore; exports.ERR_PERMALINK = _chunkTWCDSYJNjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkTWCDSYJNjs.Experiment; exports.ExternalAttachment = _chunkTWCDSYJNjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkTWCDSYJNjs.FailedHTTPResponse; exports.IDGenerator = _chunkTWCDSYJNjs.IDGenerator; exports.JSONAttachment = _chunkTWCDSYJNjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkTWCDSYJNjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkTWCDSYJNjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkTWCDSYJNjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkTWCDSYJNjs.Logger; exports.LoginInvalidOrgError = _chunkTWCDSYJNjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkTWCDSYJNjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkTWCDSYJNjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkTWCDSYJNjs.NoopSpan; exports.OTELIDGenerator = _chunkTWCDSYJNjs.OTELIDGenerator; exports.ObjectFetcher = _chunkTWCDSYJNjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkTWCDSYJNjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkTWCDSYJNjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkTWCDSYJNjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkTWCDSYJNjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkTWCDSYJNjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkTWCDSYJNjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkTWCDSYJNjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkTWCDSYJNjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkTWCDSYJNjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkTWCDSYJNjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkTWCDSYJNjs._internalGetGlobalState; exports._internalIso = _chunk2XDW3UCGjs.isomorph_default; exports._internalSetInitialState = _chunkTWCDSYJNjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkTWCDSYJNjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkTWCDSYJNjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkTWCDSYJNjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkTWCDSYJNjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkTWCDSYJNjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.collectAnthropicSession = _chunkTWCDSYJNjs.collectAnthropicSession; exports.completeOpenAIBatchTrace = completeOpenAIBatchTrace; exports.configureInstrumentation = _chunkTWCDSYJNjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkTWCDSYJNjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkTWCDSYJNjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkTWCDSYJNjs.currentExperiment; exports.currentLogger = _chunkTWCDSYJNjs.currentLogger; exports.currentSpan = _chunkTWCDSYJNjs.currentSpan; exports.deepCopyEvent = _chunkTWCDSYJNjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.defineDurableEval = defineDurableEval; exports.deserializePlainStringAsJSON = _chunkTWCDSYJNjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkTWCDSYJNjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkTWCDSYJNjs.extractTraceContextFromHeaders; exports.flush = _chunkTWCDSYJNjs.flush; exports.getContextManager = _chunkTWCDSYJNjs.getContextManager; exports.getIdGenerator = _chunkTWCDSYJNjs.getIdGenerator; exports.getPromptVersions = _chunkTWCDSYJNjs.getPromptVersions; exports.getSpanParentObject = _chunkTWCDSYJNjs.getSpanParentObject; exports.getTemplateRenderer = _chunkTWCDSYJNjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkTWCDSYJNjs.init; exports.initDataset = _chunkTWCDSYJNjs.initDataset; exports.initExperiment = _chunkTWCDSYJNjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkTWCDSYJNjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkTWCDSYJNjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkTWCDSYJNjs.isTemplateFormat; exports.loadParameters = _chunkTWCDSYJNjs.loadParameters; exports.loadPrompt = _chunkTWCDSYJNjs.loadPrompt; exports.log = _chunkTWCDSYJNjs.log; exports.logError = _chunkTWCDSYJNjs.logError; exports.login = _chunkTWCDSYJNjs.login; exports.loginToState = _chunkTWCDSYJNjs.loginToState; exports.logs3OverflowUploadSchema = _chunkTWCDSYJNjs.logs3OverflowUploadSchema; exports.newId = _chunkTWCDSYJNjs.newId; exports.openaiBatchesRetrieveTraced = openaiBatchesRetrieveTraced; exports.openaiFilesCreateTraced = openaiFilesCreateTraced; exports.parseCachedHeader = _chunkTWCDSYJNjs.parseCachedHeader; exports.parseTemplateFormat = _chunkTWCDSYJNjs.parseTemplateFormat; exports.permalink = _chunkTWCDSYJNjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkTWCDSYJNjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkTWCDSYJNjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkTWCDSYJNjs.registerTemplatePlugin; exports.renderMessage = _chunkTWCDSYJNjs.renderMessage; exports.renderPromptParams = _chunkTWCDSYJNjs.renderPromptParams; exports.renderTemplateContent = _chunkTWCDSYJNjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkTWCDSYJNjs.setFetch; exports.setMaskingFunction = _chunkTWCDSYJNjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkTWCDSYJNjs.spanComponentsToObjectId; exports.startSpan = _chunkTWCDSYJNjs.startSpan; exports.summarize = _chunkTWCDSYJNjs.summarize; exports.templateRegistry = _chunkTWCDSYJNjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkTWCDSYJNjs.ToolFunctionDefinition; exports.traceable = _chunkTWCDSYJNjs.traceable; exports.traced = _chunkTWCDSYJNjs.traced; exports.updateSpan = _chunkTWCDSYJNjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkTWCDSYJNjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkTWCDSYJNjs.utf8ByteLength; exports.withCurrent = _chunkTWCDSYJNjs.withCurrent; exports.withDataset = _chunkTWCDSYJNjs.withDataset; exports.withExperiment = _chunkTWCDSYJNjs.withExperiment; exports.withLogger = _chunkTWCDSYJNjs.withLogger; exports.withParent = _chunkTWCDSYJNjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCloudflareAIChat = wrapCloudflareAIChat; exports.wrapCloudflareAgent = wrapCloudflareAgent; exports.wrapCloudflareThink = wrapCloudflareThink; 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.wrapHuggingFaceTransformers = wrapHuggingFaceTransformers; exports.wrapLangSmithClient = wrapLangSmithClient; exports.wrapLangSmithRunTrees = wrapLangSmithRunTrees; exports.wrapLangSmithTraceable = wrapLangSmithTraceable; exports.wrapMastraAgent = _chunkTWCDSYJNjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOllama = wrapOllama; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkTWCDSYJNjs.wrapTraced; exports.wrapVitest = wrapVitest; exports.wrapVoyageAI = wrapVoyageAI;
|