braintrust 3.25.0 → 3.26.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/NOTICE +6 -0
- package/dev/dist/index.d.mts +130 -2
- package/dev/dist/index.d.ts +130 -2
- package/dev/dist/index.js +2455 -1116
- package/dev/dist/index.mjs +1599 -260
- package/dist/apply-auto-instrumentation.js +439 -398
- package/dist/apply-auto-instrumentation.mjs +242 -201
- package/dist/auto-instrumentations/bundler/esbuild.cjs +853 -337
- package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -8
- package/dist/auto-instrumentations/bundler/next.cjs +852 -356
- package/dist/auto-instrumentations/bundler/next.mjs +6 -29
- package/dist/auto-instrumentations/bundler/rollup.cjs +853 -337
- package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.mjs +5 -8
- package/dist/auto-instrumentations/bundler/vite.cjs +853 -337
- package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/vite.mjs +5 -8
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1006 -266
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
- package/dist/auto-instrumentations/bundler/webpack.cjs +853 -337
- package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.mjs +5 -4
- package/dist/auto-instrumentations/{chunk-JPVCUKTY.mjs → chunk-6E22MYSW.mjs} +165 -73
- package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
- package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
- package/dist/auto-instrumentations/{chunk-7P6563SW.mjs → chunk-V5LEODRX.mjs} +2 -6
- package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
- package/dist/auto-instrumentations/{chunk-CZ24KNHT.mjs → chunk-XZHHE4Y3.mjs} +77 -68
- package/dist/auto-instrumentations/hook.mjs +247 -182
- package/dist/auto-instrumentations/index.cjs +557 -48
- package/dist/auto-instrumentations/index.d.mts +6 -2
- package/dist/auto-instrumentations/index.d.ts +6 -2
- package/dist/auto-instrumentations/index.mjs +6 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
- package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
- package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
- package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
- package/dist/browser.d.mts +817 -197
- package/dist/browser.d.ts +817 -197
- package/dist/browser.js +1883 -265
- package/dist/browser.mjs +1883 -265
- package/dist/{chunk-ABR2QWDP.mjs → chunk-PN7EWK66.mjs} +581 -133
- package/dist/{chunk-GSIDVFE6.js → chunk-VRZZQPAA.js} +1670 -736
- package/dist/{chunk-P25IOOU4.js → chunk-VYNNEKSA.js} +586 -138
- package/dist/{chunk-2SANLSWX.mjs → chunk-XIZOM2HO.mjs} +1052 -118
- package/dist/cli.js +1601 -263
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +1883 -268
- package/dist/edge-light.mjs +1883 -268
- package/dist/index.d.mts +817 -197
- package/dist/index.d.ts +817 -197
- package/dist/index.js +695 -435
- package/dist/index.mjs +264 -4
- package/dist/instrumentation/index.d.mts +130 -6
- package/dist/instrumentation/index.d.ts +130 -6
- package/dist/instrumentation/index.js +1510 -80
- package/dist/instrumentation/index.mjs +1510 -80
- 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 +1883 -268
- package/dist/workerd.mjs +1883 -268
- package/licenses/node-diagnostics-channel/LICENSE +19 -0
- package/package.json +34 -35
- package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
- package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
package/dist/index.js
CHANGED
|
@@ -139,8 +139,8 @@
|
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
var _chunkGSIDVFE6js = require('./chunk-GSIDVFE6.js');
|
|
143
142
|
|
|
143
|
+
var _chunkVRZZQPAAjs = require('./chunk-VRZZQPAA.js');
|
|
144
144
|
|
|
145
145
|
|
|
146
146
|
|
|
@@ -166,157 +166,163 @@ var _chunkGSIDVFE6js = require('./chunk-GSIDVFE6.js');
|
|
|
166
166
|
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
var _chunkVYNNEKSAjs = require('./chunk-VYNNEKSA.js');
|
|
170
174
|
|
|
171
175
|
// src/exports.ts
|
|
172
176
|
var exports_exports = {};
|
|
173
|
-
|
|
174
|
-
Attachment: () =>
|
|
175
|
-
AttachmentReference: () =>
|
|
176
|
-
BAGGAGE_HEADER: () =>
|
|
177
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
178
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
179
|
-
BRAINTRUST_PARENT_KEY: () =>
|
|
180
|
-
BaseAttachment: () =>
|
|
177
|
+
_chunkVYNNEKSAjs.__export.call(void 0, exports_exports, {
|
|
178
|
+
Attachment: () => _chunkVRZZQPAAjs.Attachment,
|
|
179
|
+
AttachmentReference: () => _chunkVRZZQPAAjs.AttachmentReference,
|
|
180
|
+
BAGGAGE_HEADER: () => _chunkVRZZQPAAjs.BAGGAGE_HEADER,
|
|
181
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkVRZZQPAAjs.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
182
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkVRZZQPAAjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
183
|
+
BRAINTRUST_PARENT_KEY: () => _chunkVRZZQPAAjs.BRAINTRUST_PARENT_KEY,
|
|
184
|
+
BaseAttachment: () => _chunkVRZZQPAAjs.BaseAttachment,
|
|
181
185
|
BaseExperiment: () => BaseExperiment,
|
|
182
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
186
|
+
BraintrustLangChainCallbackHandler: () => _chunkVRZZQPAAjs.BraintrustLangChainCallbackHandler,
|
|
183
187
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
184
|
-
BraintrustObservabilityExporter: () =>
|
|
185
|
-
BraintrustState: () =>
|
|
186
|
-
BraintrustStream: () =>
|
|
188
|
+
BraintrustObservabilityExporter: () => _chunkVRZZQPAAjs.BraintrustObservabilityExporter,
|
|
189
|
+
BraintrustState: () => _chunkVRZZQPAAjs.BraintrustState,
|
|
190
|
+
BraintrustStream: () => _chunkVRZZQPAAjs.BraintrustStream,
|
|
187
191
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
188
192
|
CodeFunction: () => CodeFunction,
|
|
189
193
|
CodePrompt: () => CodePrompt,
|
|
190
|
-
ContextManager: () =>
|
|
191
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
192
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
193
|
-
Dataset: () =>
|
|
194
|
+
ContextManager: () => _chunkVRZZQPAAjs.ContextManager,
|
|
195
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkVRZZQPAAjs.DEFAULT_FETCH_BATCH_SIZE,
|
|
196
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkVRZZQPAAjs.DEFAULT_MAX_REQUEST_SIZE,
|
|
197
|
+
Dataset: () => _chunkVRZZQPAAjs.Dataset,
|
|
194
198
|
DatasetPipeline: () => DatasetPipeline,
|
|
195
|
-
ERR_PERMALINK: () =>
|
|
199
|
+
ERR_PERMALINK: () => _chunkVRZZQPAAjs.ERR_PERMALINK,
|
|
196
200
|
Eval: () => Eval,
|
|
197
201
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
198
|
-
Experiment: () =>
|
|
199
|
-
ExternalAttachment: () =>
|
|
200
|
-
FailedHTTPResponse: () =>
|
|
201
|
-
IDGenerator: () =>
|
|
202
|
-
JSONAttachment: () =>
|
|
203
|
-
LEGACY_CACHED_HEADER: () =>
|
|
204
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
205
|
-
LazyValue: () =>
|
|
202
|
+
Experiment: () => _chunkVRZZQPAAjs.Experiment,
|
|
203
|
+
ExternalAttachment: () => _chunkVRZZQPAAjs.ExternalAttachment,
|
|
204
|
+
FailedHTTPResponse: () => _chunkVRZZQPAAjs.FailedHTTPResponse,
|
|
205
|
+
IDGenerator: () => _chunkVRZZQPAAjs.IDGenerator,
|
|
206
|
+
JSONAttachment: () => _chunkVRZZQPAAjs.JSONAttachment,
|
|
207
|
+
LEGACY_CACHED_HEADER: () => _chunkVRZZQPAAjs.LEGACY_CACHED_HEADER,
|
|
208
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkVRZZQPAAjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
209
|
+
LazyValue: () => _chunkVRZZQPAAjs.LazyValue,
|
|
206
210
|
LocalTrace: () => LocalTrace,
|
|
207
|
-
Logger: () =>
|
|
208
|
-
LoginInvalidOrgError: () =>
|
|
209
|
-
NOOP_SPAN: () =>
|
|
210
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
211
|
-
NoopSpan: () =>
|
|
212
|
-
OTELIDGenerator: () =>
|
|
213
|
-
ObjectFetcher: () =>
|
|
211
|
+
Logger: () => _chunkVRZZQPAAjs.Logger,
|
|
212
|
+
LoginInvalidOrgError: () => _chunkVRZZQPAAjs.LoginInvalidOrgError,
|
|
213
|
+
NOOP_SPAN: () => _chunkVRZZQPAAjs.NOOP_SPAN,
|
|
214
|
+
NOOP_SPAN_PERMALINK: () => _chunkVRZZQPAAjs.NOOP_SPAN_PERMALINK,
|
|
215
|
+
NoopSpan: () => _chunkVRZZQPAAjs.NoopSpan,
|
|
216
|
+
OTELIDGenerator: () => _chunkVRZZQPAAjs.OTELIDGenerator,
|
|
217
|
+
ObjectFetcher: () => _chunkVRZZQPAAjs.ObjectFetcher,
|
|
214
218
|
Project: () => Project2,
|
|
215
219
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
216
|
-
Prompt: () =>
|
|
220
|
+
Prompt: () => _chunkVRZZQPAAjs.Prompt,
|
|
217
221
|
PromptBuilder: () => PromptBuilder,
|
|
218
|
-
ReadonlyAttachment: () =>
|
|
219
|
-
ReadonlyExperiment: () =>
|
|
222
|
+
ReadonlyAttachment: () => _chunkVRZZQPAAjs.ReadonlyAttachment,
|
|
223
|
+
ReadonlyExperiment: () => _chunkVRZZQPAAjs.ReadonlyExperiment,
|
|
220
224
|
Reporter: () => Reporter,
|
|
221
225
|
ScorerBuilder: () => ScorerBuilder,
|
|
222
226
|
SpanFetcher: () => SpanFetcher,
|
|
223
|
-
SpanImpl: () =>
|
|
224
|
-
TRACEPARENT_HEADER: () =>
|
|
225
|
-
TRACESTATE_HEADER: () =>
|
|
226
|
-
TestBackgroundLogger: () =>
|
|
227
|
+
SpanImpl: () => _chunkVRZZQPAAjs.SpanImpl,
|
|
228
|
+
TRACEPARENT_HEADER: () => _chunkVRZZQPAAjs.TRACEPARENT_HEADER,
|
|
229
|
+
TRACESTATE_HEADER: () => _chunkVRZZQPAAjs.TRACESTATE_HEADER,
|
|
230
|
+
TestBackgroundLogger: () => _chunkVRZZQPAAjs.TestBackgroundLogger,
|
|
227
231
|
ToolBuilder: () => ToolBuilder,
|
|
228
|
-
UUIDGenerator: () =>
|
|
229
|
-
X_CACHED_HEADER: () =>
|
|
230
|
-
_exportsForTestingOnly: () =>
|
|
231
|
-
_internalGetGlobalState: () =>
|
|
232
|
-
_internalIso: () =>
|
|
233
|
-
_internalSetInitialState: () =>
|
|
234
|
-
addAzureBlobHeaders: () =>
|
|
232
|
+
UUIDGenerator: () => _chunkVRZZQPAAjs.UUIDGenerator,
|
|
233
|
+
X_CACHED_HEADER: () => _chunkVRZZQPAAjs.X_CACHED_HEADER,
|
|
234
|
+
_exportsForTestingOnly: () => _chunkVRZZQPAAjs._exportsForTestingOnly,
|
|
235
|
+
_internalGetGlobalState: () => _chunkVRZZQPAAjs._internalGetGlobalState,
|
|
236
|
+
_internalIso: () => _chunkVYNNEKSAjs.isomorph_default,
|
|
237
|
+
_internalSetInitialState: () => _chunkVRZZQPAAjs._internalSetInitialState,
|
|
238
|
+
addAzureBlobHeaders: () => _chunkVRZZQPAAjs.addAzureBlobHeaders,
|
|
235
239
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
236
|
-
braintrustAISDKTelemetry: () =>
|
|
240
|
+
braintrustAISDKTelemetry: () => _chunkVRZZQPAAjs.braintrustAISDKTelemetry,
|
|
237
241
|
braintrustEveHook: () => braintrustEveHook,
|
|
238
242
|
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
239
|
-
braintrustFlueInstrumentation: () =>
|
|
240
|
-
braintrustFlueObserver: () =>
|
|
241
|
-
braintrustStreamChunkSchema: () =>
|
|
243
|
+
braintrustFlueInstrumentation: () => _chunkVRZZQPAAjs.braintrustFlueInstrumentation,
|
|
244
|
+
braintrustFlueObserver: () => _chunkVRZZQPAAjs.braintrustFlueObserver,
|
|
245
|
+
braintrustStreamChunkSchema: () => _chunkVRZZQPAAjs.braintrustStreamChunkSchema,
|
|
242
246
|
buildLocalSummary: () => buildLocalSummary,
|
|
243
|
-
configureInstrumentation: () =>
|
|
244
|
-
constructLogs3OverflowRequest: () =>
|
|
245
|
-
createFinalValuePassThroughStream: () =>
|
|
246
|
-
currentExperiment: () =>
|
|
247
|
-
currentLogger: () =>
|
|
248
|
-
currentSpan: () =>
|
|
249
|
-
deepCopyEvent: () =>
|
|
247
|
+
configureInstrumentation: () => _chunkVRZZQPAAjs.configureInstrumentation,
|
|
248
|
+
constructLogs3OverflowRequest: () => _chunkVRZZQPAAjs.constructLogs3OverflowRequest,
|
|
249
|
+
createFinalValuePassThroughStream: () => _chunkVRZZQPAAjs.createFinalValuePassThroughStream,
|
|
250
|
+
currentExperiment: () => _chunkVRZZQPAAjs.currentExperiment,
|
|
251
|
+
currentLogger: () => _chunkVRZZQPAAjs.currentLogger,
|
|
252
|
+
currentSpan: () => _chunkVRZZQPAAjs.currentSpan,
|
|
253
|
+
deepCopyEvent: () => _chunkVRZZQPAAjs.deepCopyEvent,
|
|
250
254
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
251
|
-
deserializePlainStringAsJSON: () =>
|
|
252
|
-
devNullWritableStream: () =>
|
|
255
|
+
deserializePlainStringAsJSON: () => _chunkVRZZQPAAjs.deserializePlainStringAsJSON,
|
|
256
|
+
devNullWritableStream: () => _chunkVRZZQPAAjs.devNullWritableStream,
|
|
253
257
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
254
258
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
255
|
-
extractTraceContextFromHeaders: () =>
|
|
256
|
-
flush: () =>
|
|
257
|
-
getContextManager: () =>
|
|
258
|
-
getIdGenerator: () =>
|
|
259
|
-
getPromptVersions: () =>
|
|
260
|
-
getSpanParentObject: () =>
|
|
261
|
-
getTemplateRenderer: () =>
|
|
259
|
+
extractTraceContextFromHeaders: () => _chunkVRZZQPAAjs.extractTraceContextFromHeaders,
|
|
260
|
+
flush: () => _chunkVRZZQPAAjs.flush,
|
|
261
|
+
getContextManager: () => _chunkVRZZQPAAjs.getContextManager,
|
|
262
|
+
getIdGenerator: () => _chunkVRZZQPAAjs.getIdGenerator,
|
|
263
|
+
getPromptVersions: () => _chunkVRZZQPAAjs.getPromptVersions,
|
|
264
|
+
getSpanParentObject: () => _chunkVRZZQPAAjs.getSpanParentObject,
|
|
265
|
+
getTemplateRenderer: () => _chunkVRZZQPAAjs.getTemplateRenderer,
|
|
262
266
|
graph: () => graph_framework_exports,
|
|
263
|
-
init: () =>
|
|
264
|
-
initDataset: () =>
|
|
265
|
-
initExperiment: () =>
|
|
267
|
+
init: () => _chunkVRZZQPAAjs.init,
|
|
268
|
+
initDataset: () => _chunkVRZZQPAAjs.initDataset,
|
|
269
|
+
initExperiment: () => _chunkVRZZQPAAjs.initExperiment,
|
|
266
270
|
initFunction: () => initFunction,
|
|
267
|
-
initLogger: () =>
|
|
271
|
+
initLogger: () => _chunkVRZZQPAAjs.initLogger,
|
|
268
272
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
269
|
-
injectTraceContext: () =>
|
|
273
|
+
injectTraceContext: () => _chunkVRZZQPAAjs.injectTraceContext,
|
|
270
274
|
invoke: () => invoke,
|
|
271
|
-
isTemplateFormat: () =>
|
|
272
|
-
loadParameters: () =>
|
|
273
|
-
loadPrompt: () =>
|
|
274
|
-
log: () =>
|
|
275
|
-
logError: () =>
|
|
276
|
-
login: () =>
|
|
277
|
-
loginToState: () =>
|
|
278
|
-
logs3OverflowUploadSchema: () =>
|
|
279
|
-
newId: () =>
|
|
280
|
-
parseCachedHeader: () =>
|
|
281
|
-
parseTemplateFormat: () =>
|
|
282
|
-
permalink: () =>
|
|
283
|
-
pickLogs3OverflowObjectIds: () =>
|
|
275
|
+
isTemplateFormat: () => _chunkVRZZQPAAjs.isTemplateFormat,
|
|
276
|
+
loadParameters: () => _chunkVRZZQPAAjs.loadParameters,
|
|
277
|
+
loadPrompt: () => _chunkVRZZQPAAjs.loadPrompt,
|
|
278
|
+
log: () => _chunkVRZZQPAAjs.log,
|
|
279
|
+
logError: () => _chunkVRZZQPAAjs.logError,
|
|
280
|
+
login: () => _chunkVRZZQPAAjs.login,
|
|
281
|
+
loginToState: () => _chunkVRZZQPAAjs.loginToState,
|
|
282
|
+
logs3OverflowUploadSchema: () => _chunkVRZZQPAAjs.logs3OverflowUploadSchema,
|
|
283
|
+
newId: () => _chunkVRZZQPAAjs.newId,
|
|
284
|
+
parseCachedHeader: () => _chunkVRZZQPAAjs.parseCachedHeader,
|
|
285
|
+
parseTemplateFormat: () => _chunkVRZZQPAAjs.parseTemplateFormat,
|
|
286
|
+
permalink: () => _chunkVRZZQPAAjs.permalink,
|
|
287
|
+
pickLogs3OverflowObjectIds: () => _chunkVRZZQPAAjs.pickLogs3OverflowObjectIds,
|
|
284
288
|
projects: () => projects,
|
|
285
289
|
promptContentsSchema: () => promptContentsSchema,
|
|
286
290
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
287
291
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
288
292
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
289
|
-
registerOtelFlush: () =>
|
|
293
|
+
registerOtelFlush: () => _chunkVRZZQPAAjs.registerOtelFlush,
|
|
290
294
|
registerSandbox: () => registerSandbox,
|
|
291
|
-
registerTemplatePlugin: () =>
|
|
292
|
-
renderMessage: () =>
|
|
293
|
-
renderPromptParams: () =>
|
|
294
|
-
renderTemplateContent: () =>
|
|
295
|
+
registerTemplatePlugin: () => _chunkVRZZQPAAjs.registerTemplatePlugin,
|
|
296
|
+
renderMessage: () => _chunkVRZZQPAAjs.renderMessage,
|
|
297
|
+
renderPromptParams: () => _chunkVRZZQPAAjs.renderPromptParams,
|
|
298
|
+
renderTemplateContent: () => _chunkVRZZQPAAjs.renderTemplateContent,
|
|
295
299
|
reportFailures: () => reportFailures,
|
|
296
300
|
runEvaluator: () => runEvaluator,
|
|
297
|
-
setFetch: () =>
|
|
298
|
-
setMaskingFunction: () =>
|
|
299
|
-
spanComponentsToObjectId: () =>
|
|
300
|
-
startSpan: () =>
|
|
301
|
-
summarize: () =>
|
|
302
|
-
templateRegistry: () =>
|
|
303
|
-
toolFunctionDefinitionSchema: () =>
|
|
304
|
-
traceable: () =>
|
|
305
|
-
traced: () =>
|
|
306
|
-
updateSpan: () =>
|
|
307
|
-
uploadLogs3OverflowPayload: () =>
|
|
308
|
-
utf8ByteLength: () =>
|
|
309
|
-
withCurrent: () =>
|
|
310
|
-
withDataset: () =>
|
|
311
|
-
withExperiment: () =>
|
|
312
|
-
withLogger: () =>
|
|
313
|
-
withParent: () =>
|
|
301
|
+
setFetch: () => _chunkVRZZQPAAjs.setFetch,
|
|
302
|
+
setMaskingFunction: () => _chunkVRZZQPAAjs.setMaskingFunction,
|
|
303
|
+
spanComponentsToObjectId: () => _chunkVRZZQPAAjs.spanComponentsToObjectId,
|
|
304
|
+
startSpan: () => _chunkVRZZQPAAjs.startSpan,
|
|
305
|
+
summarize: () => _chunkVRZZQPAAjs.summarize,
|
|
306
|
+
templateRegistry: () => _chunkVRZZQPAAjs.templateRegistry,
|
|
307
|
+
toolFunctionDefinitionSchema: () => _chunkVRZZQPAAjs.ToolFunctionDefinition,
|
|
308
|
+
traceable: () => _chunkVRZZQPAAjs.traceable,
|
|
309
|
+
traced: () => _chunkVRZZQPAAjs.traced,
|
|
310
|
+
updateSpan: () => _chunkVRZZQPAAjs.updateSpan,
|
|
311
|
+
uploadLogs3OverflowPayload: () => _chunkVRZZQPAAjs.uploadLogs3OverflowPayload,
|
|
312
|
+
utf8ByteLength: () => _chunkVRZZQPAAjs.utf8ByteLength,
|
|
313
|
+
withCurrent: () => _chunkVRZZQPAAjs.withCurrent,
|
|
314
|
+
withDataset: () => _chunkVRZZQPAAjs.withDataset,
|
|
315
|
+
withExperiment: () => _chunkVRZZQPAAjs.withExperiment,
|
|
316
|
+
withLogger: () => _chunkVRZZQPAAjs.withLogger,
|
|
317
|
+
withParent: () => _chunkVRZZQPAAjs.withParent,
|
|
314
318
|
wrapAISDK: () => wrapAISDK,
|
|
315
319
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
316
320
|
wrapAgentClass: () => wrapAgentClass,
|
|
317
321
|
wrapAnthropic: () => wrapAnthropic,
|
|
318
322
|
wrapBedrockRuntime: () => wrapBedrockRuntime,
|
|
319
323
|
wrapClaudeAgentSDK: () => wrapClaudeAgentSDK,
|
|
324
|
+
wrapCloudflareAIChat: () => wrapCloudflareAIChat,
|
|
325
|
+
wrapCloudflareAgent: () => wrapCloudflareAgent,
|
|
320
326
|
wrapCohere: () => wrapCohere,
|
|
321
327
|
wrapCopilotClient: () => wrapCopilotClient,
|
|
322
328
|
wrapCursorSDK: () => wrapCursorSDK,
|
|
@@ -325,10 +331,11 @@ _chunkP25IOOU4js.__export.call(void 0, exports_exports, {
|
|
|
325
331
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
326
332
|
wrapGroq: () => wrapGroq,
|
|
327
333
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
334
|
+
wrapHuggingFaceTransformers: () => wrapHuggingFaceTransformers,
|
|
328
335
|
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
329
336
|
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
330
337
|
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
331
|
-
wrapMastraAgent: () =>
|
|
338
|
+
wrapMastraAgent: () => _chunkVRZZQPAAjs.wrapMastraAgent,
|
|
332
339
|
wrapMistral: () => wrapMistral,
|
|
333
340
|
wrapOpenAI: () => wrapOpenAI,
|
|
334
341
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
@@ -337,7 +344,7 @@ _chunkP25IOOU4js.__export.call(void 0, exports_exports, {
|
|
|
337
344
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
338
345
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
339
346
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
340
|
-
wrapTraced: () =>
|
|
347
|
+
wrapTraced: () => _chunkVRZZQPAAjs.wrapTraced,
|
|
341
348
|
wrapVitest: () => wrapVitest
|
|
342
349
|
});
|
|
343
350
|
|
|
@@ -345,7 +352,7 @@ _chunkP25IOOU4js.__export.call(void 0, exports_exports, {
|
|
|
345
352
|
var _v3 = require('zod/v3');
|
|
346
353
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
347
354
|
async function registerSandbox(options) {
|
|
348
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
355
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )));
|
|
349
356
|
await state.login({
|
|
350
357
|
apiKey: options.apiKey,
|
|
351
358
|
appUrl: options.appUrl,
|
|
@@ -386,7 +393,7 @@ async function registerSandbox(options) {
|
|
|
386
393
|
evaluatorDefinitions
|
|
387
394
|
)) {
|
|
388
395
|
const functionName = evalName;
|
|
389
|
-
const functionSlug =
|
|
396
|
+
const functionSlug = _chunkVRZZQPAAjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
390
397
|
const functionDef = {
|
|
391
398
|
project_id: projectId,
|
|
392
399
|
org_name: state.orgName,
|
|
@@ -457,7 +464,7 @@ async function invoke(args) {
|
|
|
457
464
|
projectId,
|
|
458
465
|
...functionIdArgs
|
|
459
466
|
} = args;
|
|
460
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
467
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )));
|
|
461
468
|
await state.login({
|
|
462
469
|
orgName,
|
|
463
470
|
apiKey,
|
|
@@ -465,8 +472,8 @@ async function invoke(args) {
|
|
|
465
472
|
forceLogin,
|
|
466
473
|
fetch
|
|
467
474
|
});
|
|
468
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
469
|
-
const functionId =
|
|
475
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkVRZZQPAAjs.getSpanParentObject.call(void 0, ).export();
|
|
476
|
+
const functionId = _chunkVRZZQPAAjs.FunctionId.safeParse({
|
|
470
477
|
function_id: functionIdArgs.function_id,
|
|
471
478
|
project_name: functionIdArgs.projectName,
|
|
472
479
|
slug: functionIdArgs.slug,
|
|
@@ -509,7 +516,7 @@ async function invoke(args) {
|
|
|
509
516
|
if (!resp.body) {
|
|
510
517
|
throw new Error("Received empty stream body");
|
|
511
518
|
}
|
|
512
|
-
return new (0,
|
|
519
|
+
return new (0, _chunkVRZZQPAAjs.BraintrustStream)(resp.body);
|
|
513
520
|
} else {
|
|
514
521
|
const data = await resp.json();
|
|
515
522
|
return schema ? schema.parse(data) : data;
|
|
@@ -521,7 +528,7 @@ function initFunction({
|
|
|
521
528
|
version,
|
|
522
529
|
state
|
|
523
530
|
}) {
|
|
524
|
-
const s = _nullishCoalesce(state, () => (
|
|
531
|
+
const s = _nullishCoalesce(state, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )));
|
|
525
532
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
526
533
|
const f = async (input) => {
|
|
527
534
|
return await invoke({
|
|
@@ -599,22 +606,22 @@ function responsesProxy(openai) {
|
|
|
599
606
|
if (name === "create" && typeof target.create === "function") {
|
|
600
607
|
return wrapResponsesAsync(
|
|
601
608
|
target.create.bind(target),
|
|
602
|
-
|
|
609
|
+
_chunkVYNNEKSAjs.openAIChannels.responsesCreate
|
|
603
610
|
);
|
|
604
611
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
605
612
|
return wrapResponsesSyncStream(
|
|
606
613
|
target.stream.bind(target),
|
|
607
|
-
|
|
614
|
+
_chunkVYNNEKSAjs.openAIChannels.responsesStream
|
|
608
615
|
);
|
|
609
616
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
610
617
|
return wrapResponsesAsync(
|
|
611
618
|
target.parse.bind(target),
|
|
612
|
-
|
|
619
|
+
_chunkVYNNEKSAjs.openAIChannels.responsesParse
|
|
613
620
|
);
|
|
614
621
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
615
622
|
return wrapResponsesAsync(
|
|
616
623
|
target.compact.bind(target),
|
|
617
|
-
|
|
624
|
+
_chunkVYNNEKSAjs.openAIChannels.responsesCompact
|
|
618
625
|
);
|
|
619
626
|
}
|
|
620
627
|
return Reflect.get(target, name, receiver);
|
|
@@ -758,7 +765,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
758
765
|
const { span_info, params } = splitSpanInfo(
|
|
759
766
|
allParams
|
|
760
767
|
);
|
|
761
|
-
return
|
|
768
|
+
return _chunkVYNNEKSAjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
762
769
|
async () => await completion(params),
|
|
763
770
|
{ arguments: [params], span_info }
|
|
764
771
|
);
|
|
@@ -769,7 +776,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
769
776
|
const { span_info, params } = splitSpanInfo(
|
|
770
777
|
allParams
|
|
771
778
|
);
|
|
772
|
-
return
|
|
779
|
+
return _chunkVYNNEKSAjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
773
780
|
() => completion(params),
|
|
774
781
|
{ arguments: [params], span_info }
|
|
775
782
|
);
|
|
@@ -785,7 +792,7 @@ function wrapChatCompletion(completion) {
|
|
|
785
792
|
if (!executionPromise) {
|
|
786
793
|
executionPromise = (async () => {
|
|
787
794
|
const traceContext = createChannelContext(
|
|
788
|
-
|
|
795
|
+
_chunkVYNNEKSAjs.openAIChannels.chatCompletionsCreate,
|
|
789
796
|
params,
|
|
790
797
|
span_info
|
|
791
798
|
);
|
|
@@ -795,7 +802,7 @@ function wrapChatCompletion(completion) {
|
|
|
795
802
|
options
|
|
796
803
|
);
|
|
797
804
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
798
|
-
|
|
805
|
+
_chunkVYNNEKSAjs.openAIChannels.chatCompletionsCreate,
|
|
799
806
|
traceContext,
|
|
800
807
|
completionPromise
|
|
801
808
|
);
|
|
@@ -806,7 +813,7 @@ function wrapChatCompletion(completion) {
|
|
|
806
813
|
options
|
|
807
814
|
);
|
|
808
815
|
const { data, response } = await tracePromiseWithResponse(
|
|
809
|
-
|
|
816
|
+
_chunkVYNNEKSAjs.openAIChannels.chatCompletionsCreate,
|
|
810
817
|
traceContext,
|
|
811
818
|
completionResponse
|
|
812
819
|
);
|
|
@@ -849,8 +856,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
849
856
|
return createLazyAPIPromise(ensureExecuted);
|
|
850
857
|
};
|
|
851
858
|
}
|
|
852
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
853
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
859
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkVYNNEKSAjs.openAIChannels.embeddingsCreate);
|
|
860
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkVYNNEKSAjs.openAIChannels.moderationsCreate);
|
|
854
861
|
|
|
855
862
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
856
863
|
function isModuleNamespace(obj) {
|
|
@@ -953,7 +960,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
953
960
|
return wrapHarnessAgentGenerate(
|
|
954
961
|
original,
|
|
955
962
|
harnessAgent,
|
|
956
|
-
|
|
963
|
+
_chunkVYNNEKSAjs.harnessAgentChannels.generate,
|
|
957
964
|
"HarnessAgent.generate",
|
|
958
965
|
options
|
|
959
966
|
);
|
|
@@ -961,7 +968,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
961
968
|
return wrapHarnessAgentStream(
|
|
962
969
|
original,
|
|
963
970
|
harnessAgent,
|
|
964
|
-
|
|
971
|
+
_chunkVYNNEKSAjs.harnessAgentChannels.stream,
|
|
965
972
|
"HarnessAgent.stream",
|
|
966
973
|
options
|
|
967
974
|
);
|
|
@@ -969,7 +976,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
969
976
|
return wrapHarnessAgentGenerate(
|
|
970
977
|
original,
|
|
971
978
|
harnessAgent,
|
|
972
|
-
|
|
979
|
+
_chunkVYNNEKSAjs.harnessAgentChannels.continueGenerate,
|
|
973
980
|
"HarnessAgent.continueGenerate",
|
|
974
981
|
options
|
|
975
982
|
);
|
|
@@ -977,7 +984,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
977
984
|
return wrapHarnessAgentStream(
|
|
978
985
|
original,
|
|
979
986
|
harnessAgent,
|
|
980
|
-
|
|
987
|
+
_chunkVYNNEKSAjs.harnessAgentChannels.continueStream,
|
|
981
988
|
"HarnessAgent.continueStream",
|
|
982
989
|
options
|
|
983
990
|
);
|
|
@@ -1000,7 +1007,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
1000
1007
|
};
|
|
1001
1008
|
var wrapHarnessAgentCreateSession = (createSession, instance) => {
|
|
1002
1009
|
const wrapper = function(params) {
|
|
1003
|
-
return
|
|
1010
|
+
return _chunkVYNNEKSAjs.harnessAgentChannels.createSession.tracePromise(
|
|
1004
1011
|
() => params === void 0 ? createSession.call(instance) : createSession.call(instance, params),
|
|
1005
1012
|
createAISDKChannelContext(_nullishCoalesce(params, () => ( {})), { self: instance })
|
|
1006
1013
|
);
|
|
@@ -1046,15 +1053,15 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
1046
1053
|
};
|
|
1047
1054
|
function generateChannelForAgent(agentName) {
|
|
1048
1055
|
if (agentName === "ToolLoopAgent") {
|
|
1049
|
-
return
|
|
1056
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
1050
1057
|
}
|
|
1051
|
-
return
|
|
1058
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.agentGenerate;
|
|
1052
1059
|
}
|
|
1053
1060
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
1054
1061
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
1055
1062
|
return (params) => {
|
|
1056
1063
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
1057
|
-
if (workflowAgent &&
|
|
1064
|
+
if (workflowAgent && _chunkVRZZQPAAjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
1058
1065
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
1059
1066
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
1060
1067
|
}
|
|
@@ -1073,12 +1080,12 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
1073
1080
|
};
|
|
1074
1081
|
function streamChannelForAgent(agentName) {
|
|
1075
1082
|
if (agentName === "ToolLoopAgent") {
|
|
1076
|
-
return
|
|
1083
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.toolLoopAgentStream;
|
|
1077
1084
|
}
|
|
1078
1085
|
if (agentName === "WorkflowAgent") {
|
|
1079
|
-
return
|
|
1086
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.workflowAgentStream;
|
|
1080
1087
|
}
|
|
1081
|
-
return
|
|
1088
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.agentStream;
|
|
1082
1089
|
}
|
|
1083
1090
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
1084
1091
|
const wrapper = async function(allParams) {
|
|
@@ -1102,7 +1109,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
1102
1109
|
};
|
|
1103
1110
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
1104
1111
|
return makeGenerateTextWrapper(
|
|
1105
|
-
|
|
1112
|
+
_chunkVYNNEKSAjs.aiSDKChannels.generateText,
|
|
1106
1113
|
"generateText",
|
|
1107
1114
|
generateText,
|
|
1108
1115
|
{ aiSDK },
|
|
@@ -1111,7 +1118,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
1111
1118
|
};
|
|
1112
1119
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
1113
1120
|
return makeGenerateTextWrapper(
|
|
1114
|
-
|
|
1121
|
+
_chunkVYNNEKSAjs.aiSDKChannels.generateObject,
|
|
1115
1122
|
"generateObject",
|
|
1116
1123
|
generateObject,
|
|
1117
1124
|
{ aiSDK },
|
|
@@ -1140,7 +1147,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
1140
1147
|
};
|
|
1141
1148
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
1142
1149
|
return makeEmbedWrapper(
|
|
1143
|
-
|
|
1150
|
+
_chunkVYNNEKSAjs.aiSDKChannels.embed,
|
|
1144
1151
|
"embed",
|
|
1145
1152
|
embed,
|
|
1146
1153
|
{ aiSDK },
|
|
@@ -1149,7 +1156,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1149
1156
|
};
|
|
1150
1157
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1151
1158
|
return makeEmbedWrapper(
|
|
1152
|
-
|
|
1159
|
+
_chunkVYNNEKSAjs.aiSDKChannels.embedMany,
|
|
1153
1160
|
"embedMany",
|
|
1154
1161
|
embedMany,
|
|
1155
1162
|
{ aiSDK },
|
|
@@ -1160,7 +1167,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1160
1167
|
const wrapper = async function(allParams) {
|
|
1161
1168
|
const { span_info, ...params } = allParams;
|
|
1162
1169
|
const tracedParams = { ...params };
|
|
1163
|
-
return
|
|
1170
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.rerank.tracePromise(
|
|
1164
1171
|
() => rerank(tracedParams),
|
|
1165
1172
|
createAISDKChannelContext(tracedParams, {
|
|
1166
1173
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1199,7 +1206,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1199
1206
|
};
|
|
1200
1207
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1201
1208
|
return makeStreamWrapper(
|
|
1202
|
-
|
|
1209
|
+
_chunkVYNNEKSAjs.aiSDKChannels.streamText,
|
|
1203
1210
|
"streamText",
|
|
1204
1211
|
streamText,
|
|
1205
1212
|
{ aiSDK },
|
|
@@ -1208,7 +1215,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1208
1215
|
};
|
|
1209
1216
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1210
1217
|
return makeStreamWrapper(
|
|
1211
|
-
|
|
1218
|
+
_chunkVYNNEKSAjs.aiSDKChannels.streamObject,
|
|
1212
1219
|
"streamObject",
|
|
1213
1220
|
streamObject,
|
|
1214
1221
|
{ aiSDK },
|
|
@@ -1280,19 +1287,19 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1280
1287
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1281
1288
|
// propagate those via async local storage
|
|
1282
1289
|
async doGenerate(options) {
|
|
1283
|
-
const span =
|
|
1284
|
-
|
|
1290
|
+
const span = _chunkVRZZQPAAjs.startSpan.call(void 0,
|
|
1291
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0,
|
|
1285
1292
|
{
|
|
1286
1293
|
name: "Chat Completion",
|
|
1287
1294
|
spanAttributes: {
|
|
1288
1295
|
type: "llm"
|
|
1289
1296
|
}
|
|
1290
1297
|
},
|
|
1291
|
-
|
|
1298
|
+
_chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1292
1299
|
)
|
|
1293
1300
|
);
|
|
1294
1301
|
const { prompt, mode, ...rest } = options;
|
|
1295
|
-
const startTime =
|
|
1302
|
+
const startTime = _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1296
1303
|
try {
|
|
1297
1304
|
const ret = await this.model.doGenerate(options);
|
|
1298
1305
|
span.log({
|
|
@@ -1304,12 +1311,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1304
1311
|
},
|
|
1305
1312
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1306
1313
|
metrics: {
|
|
1307
|
-
time_to_first_token:
|
|
1308
|
-
tokens: !
|
|
1314
|
+
time_to_first_token: _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1315
|
+
tokens: !_chunkVRZZQPAAjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1309
1316
|
prompt_tokens: _optionalChain([ret, 'access', _26 => _26.usage, 'optionalAccess', _27 => _27.promptTokens]),
|
|
1310
1317
|
completion_tokens: _optionalChain([ret, 'access', _28 => _28.usage, 'optionalAccess', _29 => _29.completionTokens]),
|
|
1311
|
-
cached:
|
|
1312
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _30 => _30.rawResponse, 'optionalAccess', _31 => _31.headers, 'optionalAccess', _32 => _32[
|
|
1318
|
+
cached: _chunkVRZZQPAAjs.parseCachedHeader.call(void 0,
|
|
1319
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _30 => _30.rawResponse, 'optionalAccess', _31 => _31.headers, 'optionalAccess', _32 => _32[_chunkVRZZQPAAjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _33 => _33.rawResponse, 'optionalAccess', _34 => _34.headers, 'optionalAccess', _35 => _35[_chunkVRZZQPAAjs.LEGACY_CACHED_HEADER]])))
|
|
1313
1320
|
)
|
|
1314
1321
|
}
|
|
1315
1322
|
});
|
|
@@ -1320,16 +1327,16 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1320
1327
|
}
|
|
1321
1328
|
async doStream(options) {
|
|
1322
1329
|
const { prompt, mode, ...rest } = options;
|
|
1323
|
-
const startTime =
|
|
1324
|
-
const span =
|
|
1325
|
-
|
|
1330
|
+
const startTime = _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1331
|
+
const span = _chunkVRZZQPAAjs.startSpan.call(void 0,
|
|
1332
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0,
|
|
1326
1333
|
{
|
|
1327
1334
|
name: "Chat Completion",
|
|
1328
1335
|
spanAttributes: {
|
|
1329
1336
|
type: "llm"
|
|
1330
1337
|
}
|
|
1331
1338
|
},
|
|
1332
|
-
|
|
1339
|
+
_chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1333
1340
|
)
|
|
1334
1341
|
);
|
|
1335
1342
|
span.log({
|
|
@@ -1360,7 +1367,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1360
1367
|
new TransformStream({
|
|
1361
1368
|
transform(chunk, controller) {
|
|
1362
1369
|
if (time_to_first_token === void 0) {
|
|
1363
|
-
time_to_first_token =
|
|
1370
|
+
time_to_first_token = _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1364
1371
|
span.log({ metrics: { time_to_first_token } });
|
|
1365
1372
|
}
|
|
1366
1373
|
switch (chunk.type) {
|
|
@@ -1405,11 +1412,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1405
1412
|
),
|
|
1406
1413
|
metrics: {
|
|
1407
1414
|
time_to_first_token,
|
|
1408
|
-
tokens: !
|
|
1415
|
+
tokens: !_chunkVRZZQPAAjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1409
1416
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _36 => _36.promptTokens]),
|
|
1410
1417
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _37 => _37.completionTokens]),
|
|
1411
|
-
cached:
|
|
1412
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _38 => _38.rawResponse, 'optionalAccess', _39 => _39.headers, 'optionalAccess', _40 => _40[
|
|
1418
|
+
cached: _chunkVRZZQPAAjs.parseCachedHeader.call(void 0,
|
|
1419
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _38 => _38.rawResponse, 'optionalAccess', _39 => _39.headers, 'optionalAccess', _40 => _40[_chunkVRZZQPAAjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _41 => _41.rawResponse, 'optionalAccess', _42 => _42.headers, 'optionalAccess', _43 => _43[_chunkVRZZQPAAjs.LEGACY_CACHED_HEADER]])))
|
|
1413
1420
|
)
|
|
1414
1421
|
}
|
|
1415
1422
|
});
|
|
@@ -1594,12 +1601,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1594
1601
|
anthropicMetadata.usage,
|
|
1595
1602
|
"cache_creation_input_tokens"
|
|
1596
1603
|
) || 0;
|
|
1597
|
-
const cacheTokens =
|
|
1604
|
+
const cacheTokens = _chunkVRZZQPAAjs.extractAnthropicCacheTokens.call(void 0,
|
|
1598
1605
|
cacheReadTokens,
|
|
1599
1606
|
cacheCreationTokens
|
|
1600
1607
|
);
|
|
1601
1608
|
Object.assign(metrics, cacheTokens);
|
|
1602
|
-
Object.assign(metrics,
|
|
1609
|
+
Object.assign(metrics, _chunkVRZZQPAAjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1603
1610
|
}
|
|
1604
1611
|
}
|
|
1605
1612
|
return metrics;
|
|
@@ -1671,7 +1678,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1671
1678
|
model: modelFromWrapGenerate
|
|
1672
1679
|
}) => {
|
|
1673
1680
|
const rawInput = extractInput(params);
|
|
1674
|
-
const processedInput =
|
|
1681
|
+
const processedInput = _chunkVRZZQPAAjs.processInputAttachments.call(void 0, rawInput);
|
|
1675
1682
|
const spanArgs = {
|
|
1676
1683
|
name: _optionalChain([config, 'access', _60 => _60.spanInfo, 'optionalAccess', _61 => _61.name]) || "ai-sdk.doGenerate",
|
|
1677
1684
|
spanAttributes: {
|
|
@@ -1686,8 +1693,8 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1686
1693
|
}
|
|
1687
1694
|
}
|
|
1688
1695
|
};
|
|
1689
|
-
const span =
|
|
1690
|
-
|
|
1696
|
+
const span = _chunkVRZZQPAAjs.startSpan.call(void 0,
|
|
1697
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1691
1698
|
);
|
|
1692
1699
|
try {
|
|
1693
1700
|
const result = await doGenerate();
|
|
@@ -1735,7 +1742,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1735
1742
|
},
|
|
1736
1743
|
wrapStream: async ({ doStream, params }) => {
|
|
1737
1744
|
const rawInput = extractInput(params);
|
|
1738
|
-
const processedInput =
|
|
1745
|
+
const processedInput = _chunkVRZZQPAAjs.processInputAttachments.call(void 0, rawInput);
|
|
1739
1746
|
const spanArgs = {
|
|
1740
1747
|
name: _optionalChain([config, 'access', _69 => _69.spanInfo, 'optionalAccess', _70 => _70.name]) || "ai-sdk.doStream",
|
|
1741
1748
|
spanAttributes: {
|
|
@@ -1750,8 +1757,8 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1750
1757
|
}
|
|
1751
1758
|
}
|
|
1752
1759
|
};
|
|
1753
|
-
const span =
|
|
1754
|
-
|
|
1760
|
+
const span = _chunkVRZZQPAAjs.startSpan.call(void 0,
|
|
1761
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1755
1762
|
);
|
|
1756
1763
|
try {
|
|
1757
1764
|
const { stream, ...rest } = await doStream();
|
|
@@ -1876,7 +1883,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1876
1883
|
try {
|
|
1877
1884
|
captureEveModelInput(state, input);
|
|
1878
1885
|
} catch (error) {
|
|
1879
|
-
|
|
1886
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1880
1887
|
}
|
|
1881
1888
|
}
|
|
1882
1889
|
},
|
|
@@ -1886,7 +1893,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1886
1893
|
};
|
|
1887
1894
|
}
|
|
1888
1895
|
function isEveHandleMessageStreamEvent(event) {
|
|
1889
|
-
return
|
|
1896
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1890
1897
|
}
|
|
1891
1898
|
var ResumedEveSpan = class {
|
|
1892
1899
|
constructor(reference) {
|
|
@@ -1907,7 +1914,7 @@ var ResumedEveSpan = class {
|
|
|
1907
1914
|
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1908
1915
|
...event.metrics
|
|
1909
1916
|
};
|
|
1910
|
-
|
|
1917
|
+
_chunkVRZZQPAAjs.updateSpan.call(void 0, {
|
|
1911
1918
|
exported: this.reference.exported,
|
|
1912
1919
|
...this.reference.startEvent,
|
|
1913
1920
|
...event,
|
|
@@ -1916,7 +1923,7 @@ var ResumedEveSpan = class {
|
|
|
1916
1923
|
}
|
|
1917
1924
|
end(args) {
|
|
1918
1925
|
if (this.endTime === void 0) {
|
|
1919
|
-
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => (
|
|
1926
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => ( _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1920
1927
|
this.log({ metrics: { end: this.endTime } });
|
|
1921
1928
|
}
|
|
1922
1929
|
return this.endTime;
|
|
@@ -1928,13 +1935,13 @@ var EveBridge = (_class = class {
|
|
|
1928
1935
|
}
|
|
1929
1936
|
|
|
1930
1937
|
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1931
|
-
__init2() {this.completedToolKeys = new (0,
|
|
1938
|
+
__init2() {this.completedToolKeys = new (0, _chunkVRZZQPAAjs.LRUCache)({
|
|
1932
1939
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1933
1940
|
})}
|
|
1934
|
-
__init3() {this.toolsByCallKey = new (0,
|
|
1941
|
+
__init3() {this.toolsByCallKey = new (0, _chunkVRZZQPAAjs.LRUCache)({
|
|
1935
1942
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1936
1943
|
})}
|
|
1937
|
-
__init4() {this.turnsByKey = new (0,
|
|
1944
|
+
__init4() {this.turnsByKey = new (0, _chunkVRZZQPAAjs.LRUCache)({
|
|
1938
1945
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1939
1946
|
})}
|
|
1940
1947
|
async startEveSpan(args) {
|
|
@@ -1945,7 +1952,7 @@ var EveBridge = (_class = class {
|
|
|
1945
1952
|
if (reference) {
|
|
1946
1953
|
return new ResumedEveSpan(reference);
|
|
1947
1954
|
}
|
|
1948
|
-
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => (
|
|
1955
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => ( _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1949
1956
|
const parentSpanIds = _optionalChain([args, 'optionalAccess', _82 => _82.parentSpanIds]);
|
|
1950
1957
|
const startEvent = {
|
|
1951
1958
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1957,12 +1964,12 @@ var EveBridge = (_class = class {
|
|
|
1957
1964
|
},
|
|
1958
1965
|
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
1959
1966
|
};
|
|
1960
|
-
const span =
|
|
1961
|
-
|
|
1962
|
-
() =>
|
|
1963
|
-
|
|
1967
|
+
const span = _chunkVRZZQPAAjs.withCurrent.call(void 0,
|
|
1968
|
+
_chunkVRZZQPAAjs.NOOP_SPAN,
|
|
1969
|
+
() => _chunkVRZZQPAAjs._internalStartSpanWithInitialMerge.call(void 0,
|
|
1970
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0,
|
|
1964
1971
|
{ ...args, startTime },
|
|
1965
|
-
|
|
1972
|
+
_chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.EVE
|
|
1966
1973
|
)
|
|
1967
1974
|
)
|
|
1968
1975
|
);
|
|
@@ -1990,7 +1997,7 @@ var EveBridge = (_class = class {
|
|
|
1990
1997
|
};
|
|
1991
1998
|
});
|
|
1992
1999
|
} catch (error) {
|
|
1993
|
-
|
|
2000
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
1994
2001
|
}
|
|
1995
2002
|
return span;
|
|
1996
2003
|
}
|
|
@@ -2077,7 +2084,7 @@ var EveBridge = (_class = class {
|
|
|
2077
2084
|
}
|
|
2078
2085
|
}
|
|
2079
2086
|
} catch (error) {
|
|
2080
|
-
|
|
2087
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
2081
2088
|
}
|
|
2082
2089
|
};
|
|
2083
2090
|
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
@@ -2305,7 +2312,7 @@ var EveBridge = (_class = class {
|
|
|
2305
2312
|
return;
|
|
2306
2313
|
}
|
|
2307
2314
|
const existingMessage = eveOutputMessage(step.output);
|
|
2308
|
-
const existingToolCalls =
|
|
2315
|
+
const existingToolCalls = _chunkVRZZQPAAjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2309
2316
|
step.output = mergeEveReasoning(
|
|
2310
2317
|
[
|
|
2311
2318
|
{
|
|
@@ -2369,11 +2376,11 @@ var EveBridge = (_class = class {
|
|
|
2369
2376
|
return;
|
|
2370
2377
|
}
|
|
2371
2378
|
const toolCallsById = /* @__PURE__ */ new Map();
|
|
2372
|
-
if (Array.isArray(step.output) &&
|
|
2379
|
+
if (Array.isArray(step.output) && _chunkVRZZQPAAjs.isObject.call(void 0, step.output[0])) {
|
|
2373
2380
|
const message = step.output[0]["message"];
|
|
2374
|
-
if (
|
|
2381
|
+
if (_chunkVRZZQPAAjs.isObject.call(void 0, message) && Array.isArray(message["tool_calls"])) {
|
|
2375
2382
|
for (const toolCall of message["tool_calls"]) {
|
|
2376
|
-
if (
|
|
2383
|
+
if (_chunkVRZZQPAAjs.isObject.call(void 0, toolCall) && typeof toolCall["id"] === "string") {
|
|
2377
2384
|
toolCallsById.set(toolCall["id"], toolCall);
|
|
2378
2385
|
}
|
|
2379
2386
|
}
|
|
@@ -2582,7 +2589,7 @@ var EveBridge = (_class = class {
|
|
|
2582
2589
|
};
|
|
2583
2590
|
step.metrics = { ...step.metrics, ...metrics };
|
|
2584
2591
|
const sessionId = sessionIdFromContext(ctx);
|
|
2585
|
-
if (Array.isArray(step.output) &&
|
|
2592
|
+
if (Array.isArray(step.output) && _chunkVRZZQPAAjs.isObject.call(void 0, step.output[0])) {
|
|
2586
2593
|
const finishReason = step.output[0].finish_reason;
|
|
2587
2594
|
if (typeof finishReason !== "string") {
|
|
2588
2595
|
step.output[0].finish_reason = normalizedFinishReason(
|
|
@@ -2920,10 +2927,10 @@ var EveBridge = (_class = class {
|
|
|
2920
2927
|
return state;
|
|
2921
2928
|
}
|
|
2922
2929
|
async startTurnSpan(sessionId, event, ctx, metadata) {
|
|
2923
|
-
const session =
|
|
2924
|
-
const parent =
|
|
2925
|
-
const parentTurn =
|
|
2926
|
-
const parentLineage =
|
|
2930
|
+
const session = _chunkVRZZQPAAjs.isObject.call(void 0, ctx) ? ctx["session"] : void 0;
|
|
2931
|
+
const parent = _chunkVRZZQPAAjs.isObject.call(void 0, session) ? session["parent"] : void 0;
|
|
2932
|
+
const parentTurn = _chunkVRZZQPAAjs.isObject.call(void 0, parent) ? parent["turn"] : void 0;
|
|
2933
|
+
const parentLineage = _chunkVRZZQPAAjs.isObject.call(void 0, parent) && typeof parent["callId"] === "string" && typeof parent["sessionId"] === "string" && _chunkVRZZQPAAjs.isObject.call(void 0, parentTurn) && typeof parentTurn["id"] === "string" ? {
|
|
2927
2934
|
callId: parent["callId"],
|
|
2928
2935
|
sessionId: parent["sessionId"],
|
|
2929
2936
|
turnId: parentTurn["id"]
|
|
@@ -3030,10 +3037,10 @@ var EveBridge = (_class = class {
|
|
|
3030
3037
|
}
|
|
3031
3038
|
async flushInstrumentation() {
|
|
3032
3039
|
try {
|
|
3033
|
-
await
|
|
3040
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, );
|
|
3034
3041
|
return true;
|
|
3035
3042
|
} catch (error) {
|
|
3036
|
-
|
|
3043
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
3037
3044
|
return false;
|
|
3038
3045
|
}
|
|
3039
3046
|
}
|
|
@@ -3048,12 +3055,12 @@ function emptyEveTraceState() {
|
|
|
3048
3055
|
};
|
|
3049
3056
|
}
|
|
3050
3057
|
function normalizeEveTraceState(state) {
|
|
3051
|
-
if (!
|
|
3058
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, state)) {
|
|
3052
3059
|
return emptyEveTraceState();
|
|
3053
3060
|
}
|
|
3054
|
-
const metadata =
|
|
3061
|
+
const metadata = _chunkVRZZQPAAjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
3055
3062
|
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
3056
|
-
if (!
|
|
3063
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, entry)) {
|
|
3057
3064
|
return [];
|
|
3058
3065
|
}
|
|
3059
3066
|
const exported = entry["exported"];
|
|
@@ -3062,11 +3069,11 @@ function normalizeEveTraceState(state) {
|
|
|
3062
3069
|
const rowId = entry["rowId"];
|
|
3063
3070
|
const spanId = entry["spanId"];
|
|
3064
3071
|
const startEvent = entry["startEvent"];
|
|
3065
|
-
const startEventCreated =
|
|
3066
|
-
const startEventMetrics =
|
|
3067
|
-
const startEventSpanAttributes =
|
|
3068
|
-
const startEventSpanParents =
|
|
3069
|
-
const normalizedStartEvent = typeof startEventCreated === "string" &&
|
|
3072
|
+
const startEventCreated = _chunkVRZZQPAAjs.isObject.call(void 0, startEvent) ? startEvent["created"] : void 0;
|
|
3073
|
+
const startEventMetrics = _chunkVRZZQPAAjs.isObject.call(void 0, startEvent) ? startEvent["metrics"] : void 0;
|
|
3074
|
+
const startEventSpanAttributes = _chunkVRZZQPAAjs.isObject.call(void 0, startEvent) ? startEvent["span_attributes"] : void 0;
|
|
3075
|
+
const startEventSpanParents = _chunkVRZZQPAAjs.isObject.call(void 0, startEvent) ? startEvent["span_parents"] : void 0;
|
|
3076
|
+
const normalizedStartEvent = typeof startEventCreated === "string" && _chunkVRZZQPAAjs.isObject.call(void 0, startEventMetrics) && typeof startEventMetrics["start"] === "number" && Number.isFinite(startEventMetrics["start"]) && _chunkVRZZQPAAjs.isObject.call(void 0, startEventSpanAttributes) && Array.isArray(startEventSpanParents) && startEventSpanParents.every(
|
|
3070
3077
|
(parent) => typeof parent === "string"
|
|
3071
3078
|
) ? {
|
|
3072
3079
|
created: startEventCreated,
|
|
@@ -3086,7 +3093,7 @@ function normalizeEveTraceState(state) {
|
|
|
3086
3093
|
] : [];
|
|
3087
3094
|
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
3088
3095
|
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
3089
|
-
if (!
|
|
3096
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, entry)) {
|
|
3090
3097
|
return [];
|
|
3091
3098
|
}
|
|
3092
3099
|
const key = entry["key"];
|
|
@@ -3094,7 +3101,7 @@ function normalizeEveTraceState(state) {
|
|
|
3094
3101
|
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
3095
3102
|
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
3096
3103
|
const reasoningBlocks = Array.isArray(state["reasoningBlocks"]) ? state["reasoningBlocks"].flatMap((entry) => {
|
|
3097
|
-
if (!
|
|
3104
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, entry)) {
|
|
3098
3105
|
return [];
|
|
3099
3106
|
}
|
|
3100
3107
|
const content = entry["content"];
|
|
@@ -3109,7 +3116,7 @@ function normalizeEveTraceState(state) {
|
|
|
3109
3116
|
] : [];
|
|
3110
3117
|
}).slice(-MAX_STORED_REASONING_BLOCKS) : [];
|
|
3111
3118
|
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
3112
|
-
if (!
|
|
3119
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, entry)) {
|
|
3113
3120
|
return [];
|
|
3114
3121
|
}
|
|
3115
3122
|
const ordinal = entry["ordinal"];
|
|
@@ -3186,14 +3193,14 @@ function clearStoredEveReasoning(state, sessionId, turnId, stepIndex) {
|
|
|
3186
3193
|
});
|
|
3187
3194
|
}
|
|
3188
3195
|
function eveOutputMessage(output) {
|
|
3189
|
-
return Array.isArray(output) &&
|
|
3196
|
+
return Array.isArray(output) && _chunkVRZZQPAAjs.isObject.call(void 0, output[0]) ? output[0]["message"] : void 0;
|
|
3190
3197
|
}
|
|
3191
3198
|
function mergeEveReasoning(output, reasoning) {
|
|
3192
3199
|
if (reasoning.length === 0) {
|
|
3193
3200
|
return output;
|
|
3194
3201
|
}
|
|
3195
|
-
const choice = Array.isArray(output) &&
|
|
3196
|
-
const message =
|
|
3202
|
+
const choice = Array.isArray(output) && _chunkVRZZQPAAjs.isObject.call(void 0, output[0]) ? output[0] : {};
|
|
3203
|
+
const message = _chunkVRZZQPAAjs.isObject.call(void 0, choice["message"]) ? choice["message"] : {};
|
|
3197
3204
|
return [
|
|
3198
3205
|
{
|
|
3199
3206
|
...choice,
|
|
@@ -3247,7 +3254,7 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3247
3254
|
});
|
|
3248
3255
|
return input;
|
|
3249
3256
|
} catch (error) {
|
|
3250
|
-
|
|
3257
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
3251
3258
|
return void 0;
|
|
3252
3259
|
}
|
|
3253
3260
|
}
|
|
@@ -3385,14 +3392,14 @@ function capturedEveModelContentPart(part) {
|
|
|
3385
3392
|
}
|
|
3386
3393
|
function isCapturedModelInput(input) {
|
|
3387
3394
|
return Array.isArray(input) && input.every(
|
|
3388
|
-
(message) =>
|
|
3395
|
+
(message) => _chunkVRZZQPAAjs.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(_chunkVRZZQPAAjs.isObject))
|
|
3389
3396
|
);
|
|
3390
3397
|
}
|
|
3391
3398
|
function llmInputKey(sessionId, turnId, stepIndex) {
|
|
3392
3399
|
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3393
3400
|
}
|
|
3394
3401
|
function modelMetadataFromRuntime(runtime) {
|
|
3395
|
-
if (!
|
|
3402
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, runtime)) {
|
|
3396
3403
|
return {};
|
|
3397
3404
|
}
|
|
3398
3405
|
const modelId = runtime["modelId"];
|
|
@@ -3415,11 +3422,11 @@ function modelMetadataFromModelId(modelId) {
|
|
|
3415
3422
|
};
|
|
3416
3423
|
}
|
|
3417
3424
|
function sessionIdFromContext(ctx) {
|
|
3418
|
-
if (!
|
|
3425
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, ctx)) {
|
|
3419
3426
|
return void 0;
|
|
3420
3427
|
}
|
|
3421
3428
|
const session = ctx["session"];
|
|
3422
|
-
if (!
|
|
3429
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, session)) {
|
|
3423
3430
|
return void 0;
|
|
3424
3431
|
}
|
|
3425
3432
|
const id = session["id"];
|
|
@@ -3430,19 +3437,19 @@ function toolMetadataFromTurn(turn) {
|
|
|
3430
3437
|
return metadata;
|
|
3431
3438
|
}
|
|
3432
3439
|
function isToolCallAction(action) {
|
|
3433
|
-
return
|
|
3440
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, action) && action["kind"] === "tool-call" && typeof action["callId"] === "string" && typeof action["toolName"] === "string" && _chunkVRZZQPAAjs.isObject.call(void 0, action["input"]);
|
|
3434
3441
|
}
|
|
3435
3442
|
function isLocalSubagentCallAction(action) {
|
|
3436
|
-
return
|
|
3443
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkVRZZQPAAjs.isObject.call(void 0, action["input"]);
|
|
3437
3444
|
}
|
|
3438
3445
|
function isTraceableActionRequest(action) {
|
|
3439
3446
|
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3440
3447
|
}
|
|
3441
3448
|
function isToolResult(result) {
|
|
3442
|
-
return
|
|
3449
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3443
3450
|
}
|
|
3444
3451
|
function isSubagentResult(result) {
|
|
3445
|
-
return
|
|
3452
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3446
3453
|
}
|
|
3447
3454
|
function normalizedFinishReason(finishReason) {
|
|
3448
3455
|
switch (finishReason) {
|
|
@@ -3542,7 +3549,7 @@ function messagesProxy(messages) {
|
|
|
3542
3549
|
return new Proxy(messages, {
|
|
3543
3550
|
get(target, prop, receiver) {
|
|
3544
3551
|
if (prop === "create") {
|
|
3545
|
-
return createProxy(target.create,
|
|
3552
|
+
return createProxy(target.create, _chunkVYNNEKSAjs.anthropicChannels.messagesCreate);
|
|
3546
3553
|
}
|
|
3547
3554
|
return Reflect.get(target, prop, receiver);
|
|
3548
3555
|
}
|
|
@@ -3552,7 +3559,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3552
3559
|
return new Proxy(messages, {
|
|
3553
3560
|
get(target, prop, receiver) {
|
|
3554
3561
|
if (prop === "create") {
|
|
3555
|
-
return createProxy(target.create,
|
|
3562
|
+
return createProxy(target.create, _chunkVYNNEKSAjs.anthropicChannels.betaMessagesCreate);
|
|
3556
3563
|
}
|
|
3557
3564
|
if (prop === "toolRunner") {
|
|
3558
3565
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -3561,7 +3568,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3561
3568
|
return toolRunnerProxy(
|
|
3562
3569
|
target.toolRunner,
|
|
3563
3570
|
anthropic,
|
|
3564
|
-
|
|
3571
|
+
_chunkVYNNEKSAjs.anthropicChannels.betaMessagesToolRunner
|
|
3565
3572
|
);
|
|
3566
3573
|
}
|
|
3567
3574
|
return Reflect.get(target, prop, receiver);
|
|
@@ -3618,11 +3625,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
3618
3625
|
...params,
|
|
3619
3626
|
options: {
|
|
3620
3627
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
3621
|
-
[
|
|
3628
|
+
[_chunkVRZZQPAAjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
3622
3629
|
}
|
|
3623
3630
|
};
|
|
3624
3631
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3625
|
-
return
|
|
3632
|
+
return _chunkVYNNEKSAjs.claudeAgentSDKChannels.query.traceSync(
|
|
3626
3633
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
3627
3634
|
// The channel carries no extra context fields, but the generated
|
|
3628
3635
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -3650,7 +3657,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
3650
3657
|
}
|
|
3651
3658
|
const localToolMetadata = { toolName };
|
|
3652
3659
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
3653
|
-
wrappedArgs[handlerIndex] =
|
|
3660
|
+
wrappedArgs[handlerIndex] = _chunkVRZZQPAAjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
3654
3661
|
originalHandler,
|
|
3655
3662
|
() => localToolMetadata
|
|
3656
3663
|
);
|
|
@@ -3833,7 +3840,7 @@ function wrapCodexThread(thread) {
|
|
|
3833
3840
|
if (prop === "run" && typeof value === "function") {
|
|
3834
3841
|
return function(input, turnOptions) {
|
|
3835
3842
|
const args = [input, turnOptions];
|
|
3836
|
-
return
|
|
3843
|
+
return _chunkVYNNEKSAjs.openAICodexChannels.run.tracePromise(
|
|
3837
3844
|
() => Reflect.apply(value, target, args),
|
|
3838
3845
|
{
|
|
3839
3846
|
arguments: args,
|
|
@@ -3846,7 +3853,7 @@ function wrapCodexThread(thread) {
|
|
|
3846
3853
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
3847
3854
|
return function(input, turnOptions) {
|
|
3848
3855
|
const args = [input, turnOptions];
|
|
3849
|
-
return
|
|
3856
|
+
return _chunkVYNNEKSAjs.openAICodexChannels.runStreamed.tracePromise(
|
|
3850
3857
|
() => Reflect.apply(value, target, args),
|
|
3851
3858
|
{
|
|
3852
3859
|
arguments: args,
|
|
@@ -3914,7 +3921,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3914
3921
|
if (prop === "create" && typeof value === "function") {
|
|
3915
3922
|
const wrapped = async function(options) {
|
|
3916
3923
|
const args = [options];
|
|
3917
|
-
return
|
|
3924
|
+
return _chunkVYNNEKSAjs.cursorSDKChannels.create.tracePromise(
|
|
3918
3925
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
3919
3926
|
{ arguments: args }
|
|
3920
3927
|
);
|
|
@@ -3925,7 +3932,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3925
3932
|
if (prop === "resume" && typeof value === "function") {
|
|
3926
3933
|
const wrapped = async function(agentId, options) {
|
|
3927
3934
|
const args = [agentId, options];
|
|
3928
|
-
return
|
|
3935
|
+
return _chunkVYNNEKSAjs.cursorSDKChannels.resume.tracePromise(
|
|
3929
3936
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
3930
3937
|
{ arguments: args }
|
|
3931
3938
|
);
|
|
@@ -3936,7 +3943,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3936
3943
|
if (prop === "prompt" && typeof value === "function") {
|
|
3937
3944
|
const wrapped = async function(message, options) {
|
|
3938
3945
|
const args = [message, options];
|
|
3939
|
-
return
|
|
3946
|
+
return _chunkVYNNEKSAjs.cursorSDKChannels.prompt.tracePromise(
|
|
3940
3947
|
() => Reflect.apply(value, target, args),
|
|
3941
3948
|
{ arguments: args }
|
|
3942
3949
|
);
|
|
@@ -3969,7 +3976,7 @@ function wrapCursorAgent(agent) {
|
|
|
3969
3976
|
if (prop === "send" && typeof value === "function") {
|
|
3970
3977
|
return function(message, options) {
|
|
3971
3978
|
const args = [message, options];
|
|
3972
|
-
return
|
|
3979
|
+
return _chunkVYNNEKSAjs.cursorSDKChannels.send.tracePromise(
|
|
3973
3980
|
() => Reflect.apply(value, target, args),
|
|
3974
3981
|
{
|
|
3975
3982
|
agent: target,
|
|
@@ -4019,7 +4026,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
4019
4026
|
...descriptor,
|
|
4020
4027
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
4021
4028
|
const args = [text, options];
|
|
4022
|
-
return
|
|
4029
|
+
return _chunkVYNNEKSAjs.piCodingAgentChannels.prompt.tracePromise(
|
|
4023
4030
|
() => Reflect.apply(originalPrompt, this, args),
|
|
4024
4031
|
{
|
|
4025
4032
|
arguments: args,
|
|
@@ -4036,6 +4043,67 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
4036
4043
|
});
|
|
4037
4044
|
}
|
|
4038
4045
|
|
|
4046
|
+
// src/wrappers/cloudflare-agent.ts
|
|
4047
|
+
var WRAPPED_RUN_AGENT_TOOL = /* @__PURE__ */ Symbol.for(
|
|
4048
|
+
"braintrust.cloudflare-agents.wrapped-run-agent-tool"
|
|
4049
|
+
);
|
|
4050
|
+
function wrapCloudflareAgent(Agent) {
|
|
4051
|
+
if (typeof Agent !== "function") {
|
|
4052
|
+
warnUnsupportedAgent();
|
|
4053
|
+
return Agent;
|
|
4054
|
+
}
|
|
4055
|
+
const prototypeDescriptor = Object.getOwnPropertyDescriptor(
|
|
4056
|
+
Agent,
|
|
4057
|
+
"prototype"
|
|
4058
|
+
);
|
|
4059
|
+
const prototype = prototypeDescriptor && "value" in prototypeDescriptor ? prototypeDescriptor.value : void 0;
|
|
4060
|
+
if (!isObjectLike(prototype)) {
|
|
4061
|
+
warnUnsupportedAgent();
|
|
4062
|
+
return Agent;
|
|
4063
|
+
}
|
|
4064
|
+
if (ownValue(prototype, WRAPPED_RUN_AGENT_TOOL) === true) {
|
|
4065
|
+
return Agent;
|
|
4066
|
+
}
|
|
4067
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, "runAgentTool");
|
|
4068
|
+
if (!descriptor || typeof descriptor.value !== "function") {
|
|
4069
|
+
warnUnsupportedAgent();
|
|
4070
|
+
return Agent;
|
|
4071
|
+
}
|
|
4072
|
+
const originalRunAgentTool = descriptor.value;
|
|
4073
|
+
Object.defineProperty(prototype, "runAgentTool", {
|
|
4074
|
+
...descriptor,
|
|
4075
|
+
value: function wrappedRunAgentTool(...args) {
|
|
4076
|
+
const options = args[1];
|
|
4077
|
+
if (ownValue(options, "detached")) {
|
|
4078
|
+
return Reflect.apply(originalRunAgentTool, this, args);
|
|
4079
|
+
}
|
|
4080
|
+
return _chunkVYNNEKSAjs.cloudflareAgentsChannels.runAgentTool.tracePromise(
|
|
4081
|
+
() => Reflect.apply(originalRunAgentTool, this, args),
|
|
4082
|
+
{ arguments: args, self: this }
|
|
4083
|
+
);
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
Object.defineProperty(prototype, WRAPPED_RUN_AGENT_TOOL, {
|
|
4087
|
+
configurable: false,
|
|
4088
|
+
enumerable: false,
|
|
4089
|
+
value: true
|
|
4090
|
+
});
|
|
4091
|
+
return Agent;
|
|
4092
|
+
}
|
|
4093
|
+
function ownValue(value, key) {
|
|
4094
|
+
if (!isObjectLike(value)) {
|
|
4095
|
+
return void 0;
|
|
4096
|
+
}
|
|
4097
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
4098
|
+
return descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
4099
|
+
}
|
|
4100
|
+
function isObjectLike(value) {
|
|
4101
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
4102
|
+
}
|
|
4103
|
+
function warnUnsupportedAgent() {
|
|
4104
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Unsupported Cloudflare Agents Agent class. Not wrapping.");
|
|
4105
|
+
}
|
|
4106
|
+
|
|
4039
4107
|
// src/wrappers/strands-agent-sdk.ts
|
|
4040
4108
|
var WRAPPED_CLASS = /* @__PURE__ */ Symbol.for("braintrust.strands-agent-sdk.wrapped-class");
|
|
4041
4109
|
var WRAPPED_INSTANCE = /* @__PURE__ */ Symbol.for(
|
|
@@ -4139,7 +4207,7 @@ function wrapAgentInstance(agent) {
|
|
|
4139
4207
|
if (prop === "stream" && typeof value === "function") {
|
|
4140
4208
|
return function(args, options) {
|
|
4141
4209
|
const callArgs = [args, options];
|
|
4142
|
-
return
|
|
4210
|
+
return _chunkVYNNEKSAjs.strandsAgentSDKChannels.agentStream.traceSync(
|
|
4143
4211
|
() => Reflect.apply(value, target, callArgs),
|
|
4144
4212
|
{
|
|
4145
4213
|
agent: proxy,
|
|
@@ -4175,7 +4243,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
4175
4243
|
if (prop === "stream" && typeof value === "function") {
|
|
4176
4244
|
return function(input, options) {
|
|
4177
4245
|
const callArgs = [input, options];
|
|
4178
|
-
const channel = kind === "graph" ?
|
|
4246
|
+
const channel = kind === "graph" ? _chunkVYNNEKSAjs.strandsAgentSDKChannels.graphStream : _chunkVYNNEKSAjs.strandsAgentSDKChannels.swarmStream;
|
|
4179
4247
|
return channel.traceSync(
|
|
4180
4248
|
() => Reflect.apply(value, target, callArgs),
|
|
4181
4249
|
{
|
|
@@ -4204,6 +4272,81 @@ async function consumeAsyncGenerator(generator) {
|
|
|
4204
4272
|
return result.value;
|
|
4205
4273
|
}
|
|
4206
4274
|
|
|
4275
|
+
// src/wrappers/cloudflare-ai-chat.ts
|
|
4276
|
+
var wrappedClasses = /* @__PURE__ */ new WeakMap();
|
|
4277
|
+
function wrapCloudflareAIChat(module) {
|
|
4278
|
+
if (!module || typeof module !== "object") {
|
|
4279
|
+
return module;
|
|
4280
|
+
}
|
|
4281
|
+
const candidate = module;
|
|
4282
|
+
let AIChatAgent;
|
|
4283
|
+
try {
|
|
4284
|
+
AIChatAgent = Reflect.get(candidate, "AIChatAgent");
|
|
4285
|
+
} catch (error) {
|
|
4286
|
+
_chunkVRZZQPAAjs.debugLogger.debug("Failed to inspect @cloudflare/ai-chat module:", error);
|
|
4287
|
+
return module;
|
|
4288
|
+
}
|
|
4289
|
+
if (typeof AIChatAgent !== "function") {
|
|
4290
|
+
_chunkVRZZQPAAjs.debugLogger.warn(
|
|
4291
|
+
"Unsupported @cloudflare/ai-chat module. AIChatAgent was not found; not wrapping."
|
|
4292
|
+
);
|
|
4293
|
+
return module;
|
|
4294
|
+
}
|
|
4295
|
+
const target = isModuleNamespace5(module) ? Object.setPrototypeOf({}, module) : candidate;
|
|
4296
|
+
return new Proxy(target, {
|
|
4297
|
+
get(target2, property, receiver) {
|
|
4298
|
+
const value = Reflect.get(target2, property, receiver);
|
|
4299
|
+
if (property === "AIChatAgent" && typeof value === "function") {
|
|
4300
|
+
return wrapAIChatAgentClass(
|
|
4301
|
+
value
|
|
4302
|
+
);
|
|
4303
|
+
}
|
|
4304
|
+
return value;
|
|
4305
|
+
}
|
|
4306
|
+
});
|
|
4307
|
+
}
|
|
4308
|
+
function wrapAIChatAgentClass(AgentClass) {
|
|
4309
|
+
const cached = wrappedClasses.get(AgentClass);
|
|
4310
|
+
if (cached) {
|
|
4311
|
+
return cached;
|
|
4312
|
+
}
|
|
4313
|
+
const wrapped = new Proxy(AgentClass, {
|
|
4314
|
+
get(target, property) {
|
|
4315
|
+
const value = Reflect.get(target, property, target);
|
|
4316
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
4317
|
+
},
|
|
4318
|
+
construct(target, args, newTarget) {
|
|
4319
|
+
const instance = Reflect.construct(
|
|
4320
|
+
target,
|
|
4321
|
+
args,
|
|
4322
|
+
newTarget
|
|
4323
|
+
);
|
|
4324
|
+
return _chunkVRZZQPAAjs.instrumentCloudflareAIChatAgent.call(void 0, instance);
|
|
4325
|
+
}
|
|
4326
|
+
});
|
|
4327
|
+
wrappedClasses.set(AgentClass, wrapped);
|
|
4328
|
+
wrappedClasses.set(wrapped, wrapped);
|
|
4329
|
+
return wrapped;
|
|
4330
|
+
}
|
|
4331
|
+
function isModuleNamespace5(value) {
|
|
4332
|
+
if (!value || typeof value !== "object") {
|
|
4333
|
+
return false;
|
|
4334
|
+
}
|
|
4335
|
+
try {
|
|
4336
|
+
if (Reflect.get(value, Symbol.toStringTag) === "Module") {
|
|
4337
|
+
return true;
|
|
4338
|
+
}
|
|
4339
|
+
const keys = Object.keys(value);
|
|
4340
|
+
if (keys.length === 0) {
|
|
4341
|
+
return false;
|
|
4342
|
+
}
|
|
4343
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, keys[0]);
|
|
4344
|
+
return descriptor ? !descriptor.configurable && !descriptor.writable : false;
|
|
4345
|
+
} catch (e6) {
|
|
4346
|
+
return false;
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
|
|
4207
4350
|
// src/wrappers/google-genai.ts
|
|
4208
4351
|
function wrapGoogleGenAI(googleGenAI) {
|
|
4209
4352
|
if (!googleGenAI || typeof googleGenAI !== "object") {
|
|
@@ -4250,7 +4393,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4250
4393
|
}
|
|
4251
4394
|
if (prop === "interactions") {
|
|
4252
4395
|
const interactions = Reflect.get(target, prop, receiver);
|
|
4253
|
-
if (!
|
|
4396
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
4254
4397
|
return interactions;
|
|
4255
4398
|
}
|
|
4256
4399
|
if (interactions !== originalInteractions) {
|
|
@@ -4264,7 +4407,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4264
4407
|
});
|
|
4265
4408
|
}
|
|
4266
4409
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
4267
|
-
if (!
|
|
4410
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
4268
4411
|
return;
|
|
4269
4412
|
}
|
|
4270
4413
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -4297,7 +4440,7 @@ function wrapInteractions(interactions) {
|
|
|
4297
4440
|
}
|
|
4298
4441
|
function wrapGenerateContent(original) {
|
|
4299
4442
|
return function(params) {
|
|
4300
|
-
return
|
|
4443
|
+
return _chunkVYNNEKSAjs.googleGenAIChannels.generateContent.tracePromise(
|
|
4301
4444
|
() => original(params),
|
|
4302
4445
|
{ arguments: [params] }
|
|
4303
4446
|
);
|
|
@@ -4305,7 +4448,7 @@ function wrapGenerateContent(original) {
|
|
|
4305
4448
|
}
|
|
4306
4449
|
function wrapGenerateContentStream(original) {
|
|
4307
4450
|
return function(params) {
|
|
4308
|
-
return
|
|
4451
|
+
return _chunkVYNNEKSAjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
4309
4452
|
() => original(params),
|
|
4310
4453
|
{ arguments: [params] }
|
|
4311
4454
|
);
|
|
@@ -4313,7 +4456,7 @@ function wrapGenerateContentStream(original) {
|
|
|
4313
4456
|
}
|
|
4314
4457
|
function wrapEmbedContent(original) {
|
|
4315
4458
|
return function(params) {
|
|
4316
|
-
return
|
|
4459
|
+
return _chunkVYNNEKSAjs.googleGenAIChannels.embedContent.tracePromise(
|
|
4317
4460
|
() => original(params),
|
|
4318
4461
|
{ arguments: [params] }
|
|
4319
4462
|
);
|
|
@@ -4325,7 +4468,7 @@ function wrapInteractionCreate(original) {
|
|
|
4325
4468
|
return options === void 0 ? original(params) : original(params, options);
|
|
4326
4469
|
}
|
|
4327
4470
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
4328
|
-
return
|
|
4471
|
+
return _chunkVYNNEKSAjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
4329
4472
|
() => options === void 0 ? original(params) : original(params, options),
|
|
4330
4473
|
traceContext
|
|
4331
4474
|
);
|
|
@@ -4386,7 +4529,7 @@ function wrapRunnerInstance(runner) {
|
|
|
4386
4529
|
function wrapRunnerRunAsync(runner) {
|
|
4387
4530
|
const original = runner.runAsync.bind(runner);
|
|
4388
4531
|
return function(params) {
|
|
4389
|
-
return
|
|
4532
|
+
return _chunkVYNNEKSAjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
4390
4533
|
arguments: [params],
|
|
4391
4534
|
self: runner
|
|
4392
4535
|
});
|
|
@@ -4413,7 +4556,7 @@ function wrapAgentInstance2(agent) {
|
|
|
4413
4556
|
function wrapAgentRunAsync(agent) {
|
|
4414
4557
|
const original = agent.runAsync.bind(agent);
|
|
4415
4558
|
return function(parentContext) {
|
|
4416
|
-
return
|
|
4559
|
+
return _chunkVYNNEKSAjs.googleADKChannels.agentRunAsync.traceSync(
|
|
4417
4560
|
() => original(parentContext),
|
|
4418
4561
|
{ arguments: [parentContext], self: agent }
|
|
4419
4562
|
);
|
|
@@ -4440,7 +4583,7 @@ function wrapToolInstance(tool) {
|
|
|
4440
4583
|
function wrapToolRunAsync(tool) {
|
|
4441
4584
|
const original = tool.runAsync.bind(tool);
|
|
4442
4585
|
return function(req) {
|
|
4443
|
-
return
|
|
4586
|
+
return _chunkVYNNEKSAjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
4444
4587
|
arguments: [req],
|
|
4445
4588
|
self: tool
|
|
4446
4589
|
});
|
|
@@ -4552,7 +4695,7 @@ function patchGenkitRegistryLookup(registry) {
|
|
|
4552
4695
|
Object.defineProperty(registry, PATCHED_GENKIT_REGISTRY, {
|
|
4553
4696
|
value: true
|
|
4554
4697
|
});
|
|
4555
|
-
} catch (
|
|
4698
|
+
} catch (e7) {
|
|
4556
4699
|
}
|
|
4557
4700
|
}
|
|
4558
4701
|
function patchGenkitRegistryConstructor(registry) {
|
|
@@ -4583,31 +4726,31 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
4583
4726
|
Object.defineProperty(constructor, PATCHED_GENKIT_REGISTRY_CONSTRUCTOR, {
|
|
4584
4727
|
value: true
|
|
4585
4728
|
});
|
|
4586
|
-
} catch (
|
|
4729
|
+
} catch (e8) {
|
|
4587
4730
|
}
|
|
4588
4731
|
}
|
|
4589
4732
|
function wrapGenerate(generate) {
|
|
4590
|
-
return (input) =>
|
|
4733
|
+
return (input) => _chunkVYNNEKSAjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
4591
4734
|
arguments: [input]
|
|
4592
4735
|
});
|
|
4593
4736
|
}
|
|
4594
4737
|
function wrapGenerateStream(generateStream) {
|
|
4595
|
-
return (input) =>
|
|
4738
|
+
return (input) => _chunkVYNNEKSAjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
4596
4739
|
arguments: [input]
|
|
4597
4740
|
});
|
|
4598
4741
|
}
|
|
4599
4742
|
function wrapEmbed2(embed) {
|
|
4600
|
-
return (params) =>
|
|
4743
|
+
return (params) => _chunkVYNNEKSAjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
4601
4744
|
arguments: [params]
|
|
4602
4745
|
});
|
|
4603
4746
|
}
|
|
4604
4747
|
function wrapEmbedMany2(embedMany) {
|
|
4605
|
-
return (params) =>
|
|
4748
|
+
return (params) => _chunkVYNNEKSAjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
4606
4749
|
arguments: [params]
|
|
4607
4750
|
});
|
|
4608
4751
|
}
|
|
4609
4752
|
function wrapRun(run) {
|
|
4610
|
-
return (name, inputOrFn, maybeFn) =>
|
|
4753
|
+
return (name, inputOrFn, maybeFn) => _chunkVYNNEKSAjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
4611
4754
|
arguments: [name, inputOrFn, maybeFn]
|
|
4612
4755
|
});
|
|
4613
4756
|
}
|
|
@@ -4646,13 +4789,13 @@ function isGenkitAction(value) {
|
|
|
4646
4789
|
return typeof value === "function" && "__action" in value;
|
|
4647
4790
|
}
|
|
4648
4791
|
function traceActionRun(action, run) {
|
|
4649
|
-
return (input, options) =>
|
|
4792
|
+
return (input, options) => _chunkVYNNEKSAjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
4650
4793
|
arguments: [input, options],
|
|
4651
4794
|
self: action
|
|
4652
4795
|
});
|
|
4653
4796
|
}
|
|
4654
4797
|
function traceActionStream(action, stream) {
|
|
4655
|
-
return (input, options) =>
|
|
4798
|
+
return (input, options) => _chunkVYNNEKSAjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
4656
4799
|
arguments: [input, options],
|
|
4657
4800
|
self: action
|
|
4658
4801
|
});
|
|
@@ -4698,10 +4841,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
4698
4841
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
4699
4842
|
}
|
|
4700
4843
|
function hasFunction2(value, methodName) {
|
|
4701
|
-
return
|
|
4844
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
4702
4845
|
}
|
|
4703
4846
|
function isSupportedHuggingFaceModule(value) {
|
|
4704
|
-
if (!
|
|
4847
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, value)) {
|
|
4705
4848
|
return false;
|
|
4706
4849
|
}
|
|
4707
4850
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -4809,14 +4952,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
4809
4952
|
const context = {
|
|
4810
4953
|
arguments: [traceParams]
|
|
4811
4954
|
};
|
|
4812
|
-
return
|
|
4955
|
+
return _chunkVYNNEKSAjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
4813
4956
|
() => original(params, options),
|
|
4814
4957
|
context
|
|
4815
4958
|
);
|
|
4816
4959
|
};
|
|
4817
4960
|
}
|
|
4818
4961
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
4819
|
-
return (params, options) =>
|
|
4962
|
+
return (params, options) => _chunkVYNNEKSAjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
4820
4963
|
() => original(params, options),
|
|
4821
4964
|
{
|
|
4822
4965
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -4829,14 +4972,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
4829
4972
|
const context = {
|
|
4830
4973
|
arguments: [traceParams]
|
|
4831
4974
|
};
|
|
4832
|
-
return
|
|
4975
|
+
return _chunkVYNNEKSAjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
4833
4976
|
() => original(params, options),
|
|
4834
4977
|
context
|
|
4835
4978
|
);
|
|
4836
4979
|
};
|
|
4837
4980
|
}
|
|
4838
4981
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
4839
|
-
return (params, options) =>
|
|
4982
|
+
return (params, options) => _chunkVYNNEKSAjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
4840
4983
|
() => original(params, options),
|
|
4841
4984
|
{
|
|
4842
4985
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -4849,13 +4992,127 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
4849
4992
|
const context = {
|
|
4850
4993
|
arguments: [traceParams]
|
|
4851
4994
|
};
|
|
4852
|
-
return
|
|
4995
|
+
return _chunkVYNNEKSAjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
4853
4996
|
() => original(params, options),
|
|
4854
4997
|
context
|
|
4855
4998
|
);
|
|
4856
4999
|
};
|
|
4857
5000
|
}
|
|
4858
5001
|
|
|
5002
|
+
// src/wrappers/huggingface-transformers.ts
|
|
5003
|
+
var PIPELINE_CONSTRUCTOR_KEYS = /* @__PURE__ */ new Set([
|
|
5004
|
+
"TextGenerationPipeline",
|
|
5005
|
+
"Text2TextGenerationPipeline",
|
|
5006
|
+
"SummarizationPipeline",
|
|
5007
|
+
"FeatureExtractionPipeline",
|
|
5008
|
+
"QuestionAnsweringPipeline"
|
|
5009
|
+
]);
|
|
5010
|
+
var wrappedValues = /* @__PURE__ */ new WeakMap();
|
|
5011
|
+
function wrapHuggingFaceTransformers(transformers) {
|
|
5012
|
+
const pipelineTask = _optionalChain([transformers, 'optionalAccess', _124 => _124.task]);
|
|
5013
|
+
if (typeof transformers === "function" && _chunkVYNNEKSAjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipelineTask)) {
|
|
5014
|
+
return wrapPipeline(transformers);
|
|
5015
|
+
}
|
|
5016
|
+
if (!isSupportedModule(transformers)) {
|
|
5017
|
+
return transformers;
|
|
5018
|
+
}
|
|
5019
|
+
const existing = wrappedValues.get(transformers);
|
|
5020
|
+
if (existing) {
|
|
5021
|
+
return existing;
|
|
5022
|
+
}
|
|
5023
|
+
const proxy = new Proxy(Object.create(transformers), {
|
|
5024
|
+
get(_target, property, receiver) {
|
|
5025
|
+
const value = Reflect.get(transformers, property, receiver);
|
|
5026
|
+
if (property === "pipeline" && typeof value === "function") {
|
|
5027
|
+
return wrapPipelineFactory(value);
|
|
5028
|
+
}
|
|
5029
|
+
if (typeof property === "string" && PIPELINE_CONSTRUCTOR_KEYS.has(property) && typeof value === "function") {
|
|
5030
|
+
return wrapPipelineConstructor(
|
|
5031
|
+
value
|
|
5032
|
+
);
|
|
5033
|
+
}
|
|
5034
|
+
return value;
|
|
5035
|
+
}
|
|
5036
|
+
});
|
|
5037
|
+
wrappedValues.set(transformers, proxy);
|
|
5038
|
+
wrappedValues.set(proxy, proxy);
|
|
5039
|
+
return proxy;
|
|
5040
|
+
}
|
|
5041
|
+
function isSupportedModule(value) {
|
|
5042
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") {
|
|
5043
|
+
return false;
|
|
5044
|
+
}
|
|
5045
|
+
if (typeof Reflect.get(value, "pipeline") === "function") {
|
|
5046
|
+
return true;
|
|
5047
|
+
}
|
|
5048
|
+
for (const key of PIPELINE_CONSTRUCTOR_KEYS) {
|
|
5049
|
+
if (typeof Reflect.get(value, key) === "function") {
|
|
5050
|
+
return true;
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
return false;
|
|
5054
|
+
}
|
|
5055
|
+
function wrapPipelineFactory(factory) {
|
|
5056
|
+
const existing = wrappedValues.get(factory);
|
|
5057
|
+
if (existing) {
|
|
5058
|
+
return existing;
|
|
5059
|
+
}
|
|
5060
|
+
const wrapped = function(...args) {
|
|
5061
|
+
const [task] = args;
|
|
5062
|
+
const context = {
|
|
5063
|
+
arguments: args
|
|
5064
|
+
};
|
|
5065
|
+
return _chunkVYNNEKSAjs.huggingFaceTransformersChannels.pipeline.tracePromise(() => Reflect.apply(factory, this, args), context).then((pipeline) => {
|
|
5066
|
+
if (_chunkVYNNEKSAjs.isSupportedHuggingFaceTransformersTask.call(void 0, _nullishCoalesce(pipeline.task, () => ( task)))) {
|
|
5067
|
+
return wrapPipeline(pipeline);
|
|
5068
|
+
}
|
|
5069
|
+
return pipeline;
|
|
5070
|
+
});
|
|
5071
|
+
};
|
|
5072
|
+
wrappedValues.set(factory, wrapped);
|
|
5073
|
+
wrappedValues.set(wrapped, wrapped);
|
|
5074
|
+
return wrapped;
|
|
5075
|
+
}
|
|
5076
|
+
function wrapPipelineConstructor(constructor) {
|
|
5077
|
+
const existing = wrappedValues.get(constructor);
|
|
5078
|
+
if (existing) {
|
|
5079
|
+
return existing;
|
|
5080
|
+
}
|
|
5081
|
+
const proxy = new Proxy(constructor, {
|
|
5082
|
+
construct(target, args, newTarget) {
|
|
5083
|
+
const pipeline = Reflect.construct(target, args, newTarget);
|
|
5084
|
+
if (_chunkVYNNEKSAjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipeline.task)) {
|
|
5085
|
+
return wrapPipeline(pipeline);
|
|
5086
|
+
}
|
|
5087
|
+
return pipeline;
|
|
5088
|
+
}
|
|
5089
|
+
});
|
|
5090
|
+
wrappedValues.set(constructor, proxy);
|
|
5091
|
+
wrappedValues.set(proxy, proxy);
|
|
5092
|
+
return proxy;
|
|
5093
|
+
}
|
|
5094
|
+
function wrapPipeline(pipeline) {
|
|
5095
|
+
const existing = wrappedValues.get(pipeline);
|
|
5096
|
+
if (existing) {
|
|
5097
|
+
return existing;
|
|
5098
|
+
}
|
|
5099
|
+
const proxy = new Proxy(pipeline, {
|
|
5100
|
+
apply(target, thisArg, args) {
|
|
5101
|
+
const context = {
|
|
5102
|
+
arguments: args,
|
|
5103
|
+
self: target
|
|
5104
|
+
};
|
|
5105
|
+
return _chunkVYNNEKSAjs.huggingFaceTransformersChannels.pipelineCall.tracePromise(
|
|
5106
|
+
() => Reflect.apply(target, thisArg, args),
|
|
5107
|
+
context
|
|
5108
|
+
);
|
|
5109
|
+
}
|
|
5110
|
+
});
|
|
5111
|
+
wrappedValues.set(pipeline, proxy);
|
|
5112
|
+
wrappedValues.set(proxy, proxy);
|
|
5113
|
+
return proxy;
|
|
5114
|
+
}
|
|
5115
|
+
|
|
4859
5116
|
// src/wrappers/openrouter-agent.ts
|
|
4860
5117
|
function wrapOpenRouterAgent(agent) {
|
|
4861
5118
|
const candidate = agent;
|
|
@@ -4896,7 +5153,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
4896
5153
|
const request = cloneCallModelRequest(argArray[0]);
|
|
4897
5154
|
const options = argArray[1];
|
|
4898
5155
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
4899
|
-
return
|
|
5156
|
+
return _chunkVYNNEKSAjs.openRouterAgentChannels.callModel.traceSync(
|
|
4900
5157
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
4901
5158
|
{
|
|
4902
5159
|
arguments: [request]
|
|
@@ -4992,24 +5249,24 @@ function rerankProxy(rerank) {
|
|
|
4992
5249
|
});
|
|
4993
5250
|
}
|
|
4994
5251
|
function wrapChatSend(send) {
|
|
4995
|
-
return (request, options) =>
|
|
5252
|
+
return (request, options) => _chunkVYNNEKSAjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
4996
5253
|
arguments: [request]
|
|
4997
5254
|
});
|
|
4998
5255
|
}
|
|
4999
5256
|
function wrapEmbeddingsGenerate(generate) {
|
|
5000
|
-
return (request, options) =>
|
|
5257
|
+
return (request, options) => _chunkVYNNEKSAjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
5001
5258
|
() => generate(request, options),
|
|
5002
5259
|
{ arguments: [request] }
|
|
5003
5260
|
);
|
|
5004
5261
|
}
|
|
5005
5262
|
function wrapResponsesSend(send) {
|
|
5006
|
-
return (request, options) =>
|
|
5263
|
+
return (request, options) => _chunkVYNNEKSAjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
5007
5264
|
() => send(request, options),
|
|
5008
5265
|
{ arguments: [request] }
|
|
5009
5266
|
);
|
|
5010
5267
|
}
|
|
5011
5268
|
function wrapRerank2(rerank) {
|
|
5012
|
-
return (request, options) =>
|
|
5269
|
+
return (request, options) => _chunkVYNNEKSAjs.openRouterChannels.rerankRerank.tracePromise(
|
|
5013
5270
|
() => rerank(request, options),
|
|
5014
5271
|
{ arguments: [request] }
|
|
5015
5272
|
);
|
|
@@ -5017,7 +5274,7 @@ function wrapRerank2(rerank) {
|
|
|
5017
5274
|
function wrapCallModel2(callModel) {
|
|
5018
5275
|
return (request, options) => {
|
|
5019
5276
|
const tracedRequest = { ...request };
|
|
5020
|
-
return
|
|
5277
|
+
return _chunkVYNNEKSAjs.openRouterChannels.callModel.traceSync(
|
|
5021
5278
|
() => callModel(tracedRequest, options),
|
|
5022
5279
|
{
|
|
5023
5280
|
arguments: [tracedRequest]
|
|
@@ -5150,7 +5407,7 @@ function classifiersProxy(classifiers) {
|
|
|
5150
5407
|
});
|
|
5151
5408
|
}
|
|
5152
5409
|
function wrapChatComplete(complete) {
|
|
5153
|
-
return (request, options) =>
|
|
5410
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.chatComplete.tracePromise(
|
|
5154
5411
|
() => complete(request, options),
|
|
5155
5412
|
{
|
|
5156
5413
|
arguments: [request]
|
|
@@ -5158,52 +5415,52 @@ function wrapChatComplete(complete) {
|
|
|
5158
5415
|
);
|
|
5159
5416
|
}
|
|
5160
5417
|
function wrapChatStream(stream) {
|
|
5161
|
-
return (request, options) =>
|
|
5418
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
5162
5419
|
arguments: [request]
|
|
5163
5420
|
});
|
|
5164
5421
|
}
|
|
5165
5422
|
function wrapEmbeddingsCreate(create) {
|
|
5166
|
-
return (request, options) =>
|
|
5423
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
5167
5424
|
() => create(request, options),
|
|
5168
5425
|
{ arguments: [request] }
|
|
5169
5426
|
);
|
|
5170
5427
|
}
|
|
5171
5428
|
function wrapClassifiersModerate(moderate) {
|
|
5172
|
-
return (request, options) =>
|
|
5429
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.classifiersModerate.tracePromise(
|
|
5173
5430
|
() => moderate(request, options),
|
|
5174
5431
|
{ arguments: [request] }
|
|
5175
5432
|
);
|
|
5176
5433
|
}
|
|
5177
5434
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
5178
|
-
return (request, options) =>
|
|
5435
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
5179
5436
|
() => moderateChat(request, options),
|
|
5180
5437
|
{ arguments: [request] }
|
|
5181
5438
|
);
|
|
5182
5439
|
}
|
|
5183
5440
|
function wrapClassifiersClassify(classify) {
|
|
5184
|
-
return (request, options) =>
|
|
5441
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.classifiersClassify.tracePromise(
|
|
5185
5442
|
() => classify(request, options),
|
|
5186
5443
|
{ arguments: [request] }
|
|
5187
5444
|
);
|
|
5188
5445
|
}
|
|
5189
5446
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
5190
|
-
return (request, options) =>
|
|
5447
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
5191
5448
|
() => classifyChat(request, options),
|
|
5192
5449
|
{ arguments: [request] }
|
|
5193
5450
|
);
|
|
5194
5451
|
}
|
|
5195
5452
|
function wrapFimComplete(complete) {
|
|
5196
|
-
return (request, options) =>
|
|
5453
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
5197
5454
|
arguments: [request]
|
|
5198
5455
|
});
|
|
5199
5456
|
}
|
|
5200
5457
|
function wrapFimStream(stream) {
|
|
5201
|
-
return (request, options) =>
|
|
5458
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
5202
5459
|
arguments: [request]
|
|
5203
5460
|
});
|
|
5204
5461
|
}
|
|
5205
5462
|
function wrapAgentsComplete(complete) {
|
|
5206
|
-
return (request, options) =>
|
|
5463
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.agentsComplete.tracePromise(
|
|
5207
5464
|
() => complete(request, options),
|
|
5208
5465
|
{
|
|
5209
5466
|
arguments: [request]
|
|
@@ -5211,7 +5468,7 @@ function wrapAgentsComplete(complete) {
|
|
|
5211
5468
|
);
|
|
5212
5469
|
}
|
|
5213
5470
|
function wrapAgentsStream(stream) {
|
|
5214
|
-
return (request, options) =>
|
|
5471
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
5215
5472
|
arguments: [request]
|
|
5216
5473
|
});
|
|
5217
5474
|
}
|
|
@@ -5264,22 +5521,22 @@ function cohereProxy(cohere) {
|
|
|
5264
5521
|
return proxy;
|
|
5265
5522
|
}
|
|
5266
5523
|
function wrapChat(chat) {
|
|
5267
|
-
return (request, options) =>
|
|
5524
|
+
return (request, options) => _chunkVYNNEKSAjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
5268
5525
|
arguments: [request]
|
|
5269
5526
|
});
|
|
5270
5527
|
}
|
|
5271
5528
|
function wrapChatStream2(chatStream) {
|
|
5272
|
-
return (request, options) =>
|
|
5529
|
+
return (request, options) => _chunkVYNNEKSAjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
5273
5530
|
arguments: [request]
|
|
5274
5531
|
});
|
|
5275
5532
|
}
|
|
5276
5533
|
function wrapEmbed3(embed) {
|
|
5277
|
-
return (request, options) =>
|
|
5534
|
+
return (request, options) => _chunkVYNNEKSAjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
5278
5535
|
arguments: [request]
|
|
5279
5536
|
});
|
|
5280
5537
|
}
|
|
5281
5538
|
function wrapRerank3(rerank) {
|
|
5282
|
-
return (request, options) =>
|
|
5539
|
+
return (request, options) => _chunkVYNNEKSAjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
5283
5540
|
arguments: [request]
|
|
5284
5541
|
});
|
|
5285
5542
|
}
|
|
@@ -5309,7 +5566,7 @@ function isSupportedGroqClient(value) {
|
|
|
5309
5566
|
}
|
|
5310
5567
|
function groqProxy(groq) {
|
|
5311
5568
|
const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
|
|
5312
|
-
const completionProxy = _optionalChain([groq, 'access',
|
|
5569
|
+
const completionProxy = _optionalChain([groq, 'access', _125 => _125.chat, 'optionalAccess', _126 => _126.completions]) ? new Proxy(groq.chat.completions, {
|
|
5313
5570
|
get(target, prop, receiver) {
|
|
5314
5571
|
if (prop === "create") {
|
|
5315
5572
|
return wrapChatCompletionsCreate(target.create.bind(target));
|
|
@@ -5361,13 +5618,13 @@ function groqProxy(groq) {
|
|
|
5361
5618
|
return topLevelProxy;
|
|
5362
5619
|
}
|
|
5363
5620
|
function wrapChatCompletionsCreate(create) {
|
|
5364
|
-
return (request, options) =>
|
|
5621
|
+
return (request, options) => _chunkVYNNEKSAjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
5365
5622
|
() => create(request, options),
|
|
5366
5623
|
{ arguments: [request] }
|
|
5367
5624
|
);
|
|
5368
5625
|
}
|
|
5369
5626
|
function wrapEmbeddingsCreate2(create) {
|
|
5370
|
-
return (request, options) =>
|
|
5627
|
+
return (request, options) => _chunkVYNNEKSAjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
5371
5628
|
arguments: [request]
|
|
5372
5629
|
});
|
|
5373
5630
|
}
|
|
@@ -5441,16 +5698,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
5441
5698
|
}
|
|
5442
5699
|
function wrapSend(send) {
|
|
5443
5700
|
return (command, optionsOrCb, cb) => {
|
|
5444
|
-
if (
|
|
5701
|
+
if (_chunkVRZZQPAAjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
5445
5702
|
return send(command, optionsOrCb, cb);
|
|
5446
5703
|
}
|
|
5447
|
-
return
|
|
5448
|
-
() =>
|
|
5704
|
+
return _chunkVYNNEKSAjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
5705
|
+
() => _chunkVRZZQPAAjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
5449
5706
|
() => send(command, optionsOrCb)
|
|
5450
5707
|
),
|
|
5451
5708
|
{
|
|
5452
5709
|
arguments: [command, optionsOrCb],
|
|
5453
|
-
span_info:
|
|
5710
|
+
span_info: _chunkVRZZQPAAjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
5454
5711
|
}
|
|
5455
5712
|
);
|
|
5456
5713
|
};
|
|
@@ -5499,13 +5756,13 @@ function copilotClientProxy(client) {
|
|
|
5499
5756
|
return proxy;
|
|
5500
5757
|
}
|
|
5501
5758
|
function wrappedCreateSession(client) {
|
|
5502
|
-
return (config) =>
|
|
5759
|
+
return (config) => _chunkVYNNEKSAjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
5503
5760
|
() => client.createSession(config),
|
|
5504
5761
|
{ arguments: [config] }
|
|
5505
5762
|
);
|
|
5506
5763
|
}
|
|
5507
5764
|
function wrappedResumeSession(client) {
|
|
5508
|
-
return (sessionId, config) =>
|
|
5765
|
+
return (sessionId, config) => _chunkVYNNEKSAjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
5509
5766
|
() => client.resumeSession(sessionId, config),
|
|
5510
5767
|
{ arguments: [sessionId, config] }
|
|
5511
5768
|
);
|
|
@@ -5572,7 +5829,7 @@ function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
|
|
|
5572
5829
|
);
|
|
5573
5830
|
return namespace;
|
|
5574
5831
|
}
|
|
5575
|
-
const target =
|
|
5832
|
+
const target = isModuleNamespace6(namespace) ? Object.setPrototypeOf({}, namespace) : candidate;
|
|
5576
5833
|
const moduleNamespace = target !== candidate;
|
|
5577
5834
|
let wrappedExport;
|
|
5578
5835
|
return new Proxy(target, {
|
|
@@ -5606,11 +5863,11 @@ function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
|
|
|
5606
5863
|
}
|
|
5607
5864
|
});
|
|
5608
5865
|
}
|
|
5609
|
-
function
|
|
5866
|
+
function isModuleNamespace6(value) {
|
|
5610
5867
|
if (!value || typeof value !== "object") {
|
|
5611
5868
|
return false;
|
|
5612
5869
|
}
|
|
5613
|
-
if (_optionalChain([value, 'access',
|
|
5870
|
+
if (_optionalChain([value, 'access', _127 => _127.constructor, 'optionalAccess', _128 => _128.name]) === "Module") {
|
|
5614
5871
|
return true;
|
|
5615
5872
|
}
|
|
5616
5873
|
const firstKey = Object.keys(value)[0];
|
|
@@ -5634,7 +5891,7 @@ function wrapTraceable(traceable2) {
|
|
|
5634
5891
|
apply(target, thisArg, argArray) {
|
|
5635
5892
|
const [fn, rawConfig] = argArray;
|
|
5636
5893
|
const config = rawConfig && typeof rawConfig === "object" ? rawConfig : void 0;
|
|
5637
|
-
const originalOnEnd = _optionalChain([config, 'optionalAccess',
|
|
5894
|
+
const originalOnEnd = _optionalChain([config, 'optionalAccess', _129 => _129.on_end]);
|
|
5638
5895
|
const wrappedConfig = {
|
|
5639
5896
|
...config,
|
|
5640
5897
|
on_end(runTree) {
|
|
@@ -5683,13 +5940,13 @@ function wrapRunTreeInstance(runTree) {
|
|
|
5683
5940
|
wrapped = (...args) => wrapRunTreeInstance(Reflect.apply(value, target, args));
|
|
5684
5941
|
} else if (prop === "postRun") {
|
|
5685
5942
|
const method = value;
|
|
5686
|
-
wrapped = (...args) =>
|
|
5943
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.createRun.tracePromise(
|
|
5687
5944
|
() => Reflect.apply(method, target, args),
|
|
5688
5945
|
{ arguments: [target] }
|
|
5689
5946
|
);
|
|
5690
5947
|
} else if (prop === "patchRun") {
|
|
5691
5948
|
const method = value;
|
|
5692
|
-
wrapped = (...args) =>
|
|
5949
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.updateRun.tracePromise(
|
|
5693
5950
|
() => Reflect.apply(method, target, args),
|
|
5694
5951
|
{
|
|
5695
5952
|
arguments: [
|
|
@@ -5738,19 +5995,19 @@ function wrapClientInstance(client) {
|
|
|
5738
5995
|
let wrapped;
|
|
5739
5996
|
if (prop === "createRun") {
|
|
5740
5997
|
const method = value;
|
|
5741
|
-
wrapped = (...args) =>
|
|
5998
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.createRun.tracePromise(
|
|
5742
5999
|
() => Reflect.apply(method, target, args),
|
|
5743
6000
|
{ arguments: args }
|
|
5744
6001
|
);
|
|
5745
6002
|
} else if (prop === "updateRun") {
|
|
5746
6003
|
const method = value;
|
|
5747
|
-
wrapped = (...args) =>
|
|
6004
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.updateRun.tracePromise(
|
|
5748
6005
|
() => Reflect.apply(method, target, args),
|
|
5749
6006
|
{ arguments: args }
|
|
5750
6007
|
);
|
|
5751
6008
|
} else if (prop === "batchIngestRuns") {
|
|
5752
6009
|
const method = value;
|
|
5753
|
-
wrapped = (...args) =>
|
|
6010
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.batchIngestRuns.tracePromise(
|
|
5754
6011
|
() => Reflect.apply(method, target, args),
|
|
5755
6012
|
{ arguments: args }
|
|
5756
6013
|
);
|
|
@@ -5766,13 +6023,13 @@ function publishRunUpdate(runTree) {
|
|
|
5766
6023
|
return;
|
|
5767
6024
|
}
|
|
5768
6025
|
try {
|
|
5769
|
-
void
|
|
6026
|
+
void _chunkVYNNEKSAjs.langSmithChannels.updateRun.tracePromise(() => Promise.resolve(void 0), {
|
|
5770
6027
|
arguments: [runTree.id, runTree]
|
|
5771
6028
|
}).catch((error) => {
|
|
5772
|
-
|
|
6029
|
+
_chunkVRZZQPAAjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
5773
6030
|
});
|
|
5774
6031
|
} catch (error) {
|
|
5775
|
-
|
|
6032
|
+
_chunkVRZZQPAAjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
5776
6033
|
}
|
|
5777
6034
|
}
|
|
5778
6035
|
|
|
@@ -5784,7 +6041,7 @@ var VitestContextManager = class {
|
|
|
5784
6041
|
*/
|
|
5785
6042
|
|
|
5786
6043
|
constructor() {
|
|
5787
|
-
this.contextStorage =
|
|
6044
|
+
this.contextStorage = _chunkVYNNEKSAjs.isomorph_default.newAsyncLocalStorage();
|
|
5788
6045
|
}
|
|
5789
6046
|
getCurrentContext() {
|
|
5790
6047
|
return this.contextStorage.getStore();
|
|
@@ -5825,7 +6082,7 @@ var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__ini
|
|
|
5825
6082
|
if (this.activeFlushes.has(experimentId)) {
|
|
5826
6083
|
return this.activeFlushes.get(experimentId);
|
|
5827
6084
|
}
|
|
5828
|
-
const flushPromise =
|
|
6085
|
+
const flushPromise = _chunkVRZZQPAAjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
5829
6086
|
displaySummary: config.displaySummary
|
|
5830
6087
|
});
|
|
5831
6088
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -5923,7 +6180,7 @@ async function runTracedEval(args) {
|
|
|
5923
6180
|
}
|
|
5924
6181
|
if (testError) {
|
|
5925
6182
|
span.log({ scores: { pass: 0 } });
|
|
5926
|
-
|
|
6183
|
+
_chunkVRZZQPAAjs.logError.call(void 0, span, testError);
|
|
5927
6184
|
throw testError;
|
|
5928
6185
|
}
|
|
5929
6186
|
span.log({
|
|
@@ -5956,7 +6213,7 @@ function wrapTest(originalTest, config) {
|
|
|
5956
6213
|
const wrapped = function(name, configOrFn, maybeFn) {
|
|
5957
6214
|
const isEnhanced = typeof configOrFn !== "function";
|
|
5958
6215
|
const testConfig = isEnhanced ? configOrFn : void 0;
|
|
5959
|
-
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess',
|
|
6216
|
+
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _130 => _130.data]) && Array.isArray(testConfig.data)) {
|
|
5960
6217
|
const dataRecords = testConfig.data;
|
|
5961
6218
|
const testFn2 = maybeFn;
|
|
5962
6219
|
if (!testFn2) {
|
|
@@ -5994,7 +6251,7 @@ function wrapTest(originalTest, config) {
|
|
|
5994
6251
|
const registrationContext = getExperimentContext();
|
|
5995
6252
|
const testImplementation = async (vitestContext) => {
|
|
5996
6253
|
const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
|
|
5997
|
-
const experiment = _optionalChain([experimentContext, 'optionalAccess',
|
|
6254
|
+
const experiment = _optionalChain([experimentContext, 'optionalAccess', _131 => _131.experiment]);
|
|
5998
6255
|
if (config.onProgress) {
|
|
5999
6256
|
config.onProgress({ type: "test_start", testName: name });
|
|
6000
6257
|
}
|
|
@@ -6026,11 +6283,11 @@ function wrapTest(originalTest, config) {
|
|
|
6026
6283
|
const result = await runTracedEval({
|
|
6027
6284
|
experiment,
|
|
6028
6285
|
spanName: name,
|
|
6029
|
-
input: _optionalChain([testConfig, 'optionalAccess',
|
|
6030
|
-
expected: _optionalChain([testConfig, 'optionalAccess',
|
|
6031
|
-
metadata: _optionalChain([testConfig, 'optionalAccess',
|
|
6032
|
-
tags: _optionalChain([testConfig, 'optionalAccess',
|
|
6033
|
-
scorers: _optionalChain([testConfig, 'optionalAccess',
|
|
6286
|
+
input: _optionalChain([testConfig, 'optionalAccess', _132 => _132.input]),
|
|
6287
|
+
expected: _optionalChain([testConfig, 'optionalAccess', _133 => _133.expected]),
|
|
6288
|
+
metadata: _optionalChain([testConfig, 'optionalAccess', _134 => _134.metadata]),
|
|
6289
|
+
tags: _optionalChain([testConfig, 'optionalAccess', _135 => _135.tags]),
|
|
6290
|
+
scorers: _optionalChain([testConfig, 'optionalAccess', _136 => _136.scorers]),
|
|
6034
6291
|
fn: async () => {
|
|
6035
6292
|
if (testConfig && maybeFn) {
|
|
6036
6293
|
const params = {
|
|
@@ -6097,10 +6354,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6097
6354
|
const getOrCreateContext = () => {
|
|
6098
6355
|
if (!context) {
|
|
6099
6356
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6100
|
-
const experiment = config.projectId ?
|
|
6357
|
+
const experiment = config.projectId ? _chunkVRZZQPAAjs.initExperiment.call(void 0, {
|
|
6101
6358
|
projectId: config.projectId,
|
|
6102
6359
|
experiment: experimentName
|
|
6103
|
-
}) :
|
|
6360
|
+
}) : _chunkVRZZQPAAjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
6104
6361
|
experiment: experimentName
|
|
6105
6362
|
});
|
|
6106
6363
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -6145,8 +6402,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6145
6402
|
config.onProgress({
|
|
6146
6403
|
type: "suite_complete",
|
|
6147
6404
|
suiteName,
|
|
6148
|
-
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
6149
|
-
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
6405
|
+
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _137 => _137.passed]), () => ( 0)),
|
|
6406
|
+
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _138 => _138.failed]), () => ( 0))
|
|
6150
6407
|
});
|
|
6151
6408
|
}
|
|
6152
6409
|
});
|
|
@@ -6208,7 +6465,7 @@ function wrapExpect(originalExpect) {
|
|
|
6208
6465
|
return originalExpect(value);
|
|
6209
6466
|
}
|
|
6210
6467
|
const assertion = originalExpect(value, message);
|
|
6211
|
-
const span =
|
|
6468
|
+
const span = _chunkVRZZQPAAjs.currentSpan.call(void 0, );
|
|
6212
6469
|
if (!span) {
|
|
6213
6470
|
return assertion;
|
|
6214
6471
|
}
|
|
@@ -6220,16 +6477,16 @@ function wrapExpect(originalExpect) {
|
|
|
6220
6477
|
|
|
6221
6478
|
// src/wrappers/shared/logging.ts
|
|
6222
6479
|
function logOutputs(outputs) {
|
|
6223
|
-
|
|
6480
|
+
_chunkVRZZQPAAjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
6224
6481
|
}
|
|
6225
6482
|
function logFeedback(feedback) {
|
|
6226
|
-
|
|
6483
|
+
_chunkVRZZQPAAjs.currentSpan.call(void 0, ).log({
|
|
6227
6484
|
scores: { [feedback.name]: feedback.score },
|
|
6228
6485
|
metadata: feedback.metadata
|
|
6229
6486
|
});
|
|
6230
6487
|
}
|
|
6231
6488
|
function getCurrentSpan() {
|
|
6232
|
-
return
|
|
6489
|
+
return _chunkVRZZQPAAjs.currentSpan.call(void 0, );
|
|
6233
6490
|
}
|
|
6234
6491
|
|
|
6235
6492
|
// src/wrappers/vitest/index.ts
|
|
@@ -6277,8 +6534,8 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
6277
6534
|
);
|
|
6278
6535
|
return;
|
|
6279
6536
|
}
|
|
6280
|
-
await
|
|
6281
|
-
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
6537
|
+
await _chunkVRZZQPAAjs.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
6538
|
+
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _139 => _139.displaySummary]), () => ( config.displaySummary))
|
|
6282
6539
|
});
|
|
6283
6540
|
}
|
|
6284
6541
|
};
|
|
@@ -6292,7 +6549,7 @@ function initNodeTestSuite(config) {
|
|
|
6292
6549
|
return experiment;
|
|
6293
6550
|
}
|
|
6294
6551
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6295
|
-
experiment =
|
|
6552
|
+
experiment = _chunkVRZZQPAAjs.initExperiment.call(void 0, config.projectName, {
|
|
6296
6553
|
experiment: experimentName
|
|
6297
6554
|
});
|
|
6298
6555
|
return experiment;
|
|
@@ -6341,7 +6598,7 @@ function initNodeTestSuite(config) {
|
|
|
6341
6598
|
if (!experiment) {
|
|
6342
6599
|
return;
|
|
6343
6600
|
}
|
|
6344
|
-
await
|
|
6601
|
+
await _chunkVRZZQPAAjs.summarizeAndFlush.call(void 0, experiment, {
|
|
6345
6602
|
displaySummary: config.displaySummary
|
|
6346
6603
|
});
|
|
6347
6604
|
experiment = void 0;
|
|
@@ -6358,7 +6615,7 @@ function initNodeTestSuite(config) {
|
|
|
6358
6615
|
|
|
6359
6616
|
// src/graph-framework.ts
|
|
6360
6617
|
var graph_framework_exports = {};
|
|
6361
|
-
|
|
6618
|
+
_chunkVYNNEKSAjs.__export.call(void 0, graph_framework_exports, {
|
|
6362
6619
|
AggregatorNode: () => AggregatorNode,
|
|
6363
6620
|
GateNode: () => GateNode,
|
|
6364
6621
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -6432,7 +6689,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6432
6689
|
};
|
|
6433
6690
|
}
|
|
6434
6691
|
resolveNode(node) {
|
|
6435
|
-
if (node instanceof
|
|
6692
|
+
if (node instanceof _chunkVRZZQPAAjs.Prompt) {
|
|
6436
6693
|
const cached = this.nodeLikeNodes.get(node);
|
|
6437
6694
|
if (cached) {
|
|
6438
6695
|
return [cached, []];
|
|
@@ -6482,7 +6739,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6482
6739
|
// }
|
|
6483
6740
|
// Helper to generate node IDs
|
|
6484
6741
|
generateId(name) {
|
|
6485
|
-
const uuid =
|
|
6742
|
+
const uuid = _chunkVRZZQPAAjs.newId.call(void 0, );
|
|
6486
6743
|
if (name) {
|
|
6487
6744
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
6488
6745
|
} else {
|
|
@@ -7682,7 +7939,7 @@ function waterfall(tasks, callback) {
|
|
|
7682
7939
|
var waterfall$1 = awaitify(waterfall);
|
|
7683
7940
|
|
|
7684
7941
|
// src/trace.ts
|
|
7685
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
7942
|
+
var SpanFetcher = class _SpanFetcher extends _chunkVRZZQPAAjs.ObjectFetcher {
|
|
7686
7943
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
7687
7944
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
7688
7945
|
rootSpanId,
|
|
@@ -7819,7 +8076,7 @@ var CachedSpanFetcher = (_class5 = class {
|
|
|
7819
8076
|
async fetchSpans(spanType) {
|
|
7820
8077
|
const spans = await this.fetchFn(spanType, false);
|
|
7821
8078
|
for (const span of spans) {
|
|
7822
|
-
const type = _nullishCoalesce(_optionalChain([span, 'access',
|
|
8079
|
+
const type = _nullishCoalesce(_optionalChain([span, 'access', _140 => _140.span_attributes, 'optionalAccess', _141 => _141.type]), () => ( ""));
|
|
7823
8080
|
const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
|
|
7824
8081
|
existing.push(span);
|
|
7825
8082
|
this.spanCache.set(type, existing);
|
|
@@ -7902,11 +8159,11 @@ var LocalTrace = (_class6 = class {
|
|
|
7902
8159
|
const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
|
|
7903
8160
|
if (cachedSpans && cachedSpans.length > 0) {
|
|
7904
8161
|
let spans = includeScorers ? cachedSpans : cachedSpans.filter(
|
|
7905
|
-
(span) => _optionalChain([span, 'access',
|
|
8162
|
+
(span) => _optionalChain([span, 'access', _142 => _142.span_attributes, 'optionalAccess', _143 => _143.purpose]) !== "scorer"
|
|
7906
8163
|
);
|
|
7907
8164
|
if (spanType && spanType.length > 0) {
|
|
7908
8165
|
spans = spans.filter(
|
|
7909
|
-
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access',
|
|
8166
|
+
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _144 => _144.span_attributes, 'optionalAccess', _145 => _145.type]), () => ( "")))
|
|
7910
8167
|
);
|
|
7911
8168
|
}
|
|
7912
8169
|
return spans.map((span) => ({
|
|
@@ -7931,7 +8188,7 @@ var LocalTrace = (_class6 = class {
|
|
|
7931
8188
|
* Calls the API with the project_default preprocessor (which falls back to "thread").
|
|
7932
8189
|
*/
|
|
7933
8190
|
async getThread(options) {
|
|
7934
|
-
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8191
|
+
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _146 => _146.preprocessor]), () => ( "project_default"));
|
|
7935
8192
|
if (!this.threadCache.has(cacheKey)) {
|
|
7936
8193
|
const promise = this.fetchThread(options);
|
|
7937
8194
|
this.threadCache.set(cacheKey, promise);
|
|
@@ -7942,7 +8199,7 @@ var LocalTrace = (_class6 = class {
|
|
|
7942
8199
|
await this.ensureSpansReady();
|
|
7943
8200
|
await this.state.login({});
|
|
7944
8201
|
const result = await invoke({
|
|
7945
|
-
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8202
|
+
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _147 => _147.preprocessor]), () => ( "project_default")),
|
|
7946
8203
|
functionType: "preprocessor",
|
|
7947
8204
|
input: {
|
|
7948
8205
|
trace_ref: {
|
|
@@ -7999,20 +8256,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
7999
8256
|
prompt: _v3.z.string()
|
|
8000
8257
|
}),
|
|
8001
8258
|
_v3.z.object({
|
|
8002
|
-
messages: _v3.z.array(
|
|
8259
|
+
messages: _v3.z.array(_chunkVRZZQPAAjs.ChatCompletionMessageParam)
|
|
8003
8260
|
})
|
|
8004
8261
|
]);
|
|
8005
8262
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
8006
8263
|
_v3.z.object({
|
|
8007
8264
|
model: _v3.z.string(),
|
|
8008
|
-
params:
|
|
8265
|
+
params: _chunkVRZZQPAAjs.ModelParams.optional(),
|
|
8009
8266
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
8010
8267
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
8011
8268
|
})
|
|
8012
8269
|
);
|
|
8013
8270
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
8014
8271
|
_v3.z.object({
|
|
8015
|
-
tools: _v3.z.array(
|
|
8272
|
+
tools: _v3.z.array(_chunkVRZZQPAAjs.ToolFunctionDefinition).optional()
|
|
8016
8273
|
})
|
|
8017
8274
|
);
|
|
8018
8275
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -8060,7 +8317,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
8060
8317
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
8061
8318
|
return parameters;
|
|
8062
8319
|
}
|
|
8063
|
-
if (
|
|
8320
|
+
if (_chunkVRZZQPAAjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
8064
8321
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
8065
8322
|
...resolvedSchema.data,
|
|
8066
8323
|
...parameters
|
|
@@ -8082,14 +8339,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
8082
8339
|
const value = parameters[name];
|
|
8083
8340
|
try {
|
|
8084
8341
|
if ("type" in schema && schema.type === "prompt") {
|
|
8085
|
-
const promptData = value ?
|
|
8342
|
+
const promptData = value ? _chunkVRZZQPAAjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
8086
8343
|
schema.default,
|
|
8087
8344
|
schema.default.tools
|
|
8088
8345
|
) : void 0;
|
|
8089
8346
|
if (!promptData) {
|
|
8090
8347
|
throw new Error(`Parameter '${name}' is required`);
|
|
8091
8348
|
}
|
|
8092
|
-
return [name,
|
|
8349
|
+
return [name, _chunkVRZZQPAAjs.Prompt.fromPromptData(name, promptData)];
|
|
8093
8350
|
} else if ("type" in schema && schema.type === "model") {
|
|
8094
8351
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
8095
8352
|
if (model === void 0) {
|
|
@@ -8118,10 +8375,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
|
|
|
8118
8375
|
const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
|
|
8119
8376
|
const validate = ajv.compile(schema);
|
|
8120
8377
|
if (!validate(parameters)) {
|
|
8121
|
-
const errorMessages = _optionalChain([validate, 'access',
|
|
8378
|
+
const errorMessages = _optionalChain([validate, 'access', _148 => _148.errors, 'optionalAccess', _149 => _149.map, 'call', _150 => _150((err) => {
|
|
8122
8379
|
const path = err.instancePath || "root";
|
|
8123
8380
|
return `${path}: ${err.message}`;
|
|
8124
|
-
}), 'access',
|
|
8381
|
+
}), 'access', _151 => _151.join, 'call', _152 => _152(", ")]);
|
|
8125
8382
|
throw Error(`Invalid parameters: ${errorMessages}`);
|
|
8126
8383
|
}
|
|
8127
8384
|
return rehydrateRemoteParameters(parameters, schema);
|
|
@@ -8140,7 +8397,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
8140
8397
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
8141
8398
|
return [
|
|
8142
8399
|
name,
|
|
8143
|
-
|
|
8400
|
+
_chunkVRZZQPAAjs.Prompt.fromPromptData(name, _chunkVRZZQPAAjs.PromptData.parse(value))
|
|
8144
8401
|
];
|
|
8145
8402
|
}
|
|
8146
8403
|
return [name, value];
|
|
@@ -8178,7 +8435,7 @@ var EvalResultWithSummary = class {
|
|
|
8178
8435
|
async function getPersistedBaseExperimentId(experiment) {
|
|
8179
8436
|
try {
|
|
8180
8437
|
return await experiment._getBaseExperimentId();
|
|
8181
|
-
} catch (
|
|
8438
|
+
} catch (e9) {
|
|
8182
8439
|
return void 0;
|
|
8183
8440
|
}
|
|
8184
8441
|
}
|
|
@@ -8190,7 +8447,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
8190
8447
|
return out;
|
|
8191
8448
|
}
|
|
8192
8449
|
function initExperiment2(state, options = {}) {
|
|
8193
|
-
return
|
|
8450
|
+
return _chunkVRZZQPAAjs.init.call(void 0, {
|
|
8194
8451
|
state,
|
|
8195
8452
|
...options,
|
|
8196
8453
|
setCurrent: false
|
|
@@ -8201,7 +8458,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
8201
8458
|
return void 0;
|
|
8202
8459
|
}
|
|
8203
8460
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
8204
|
-
if (!
|
|
8461
|
+
if (!_chunkVRZZQPAAjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
8205
8462
|
return void 0;
|
|
8206
8463
|
}
|
|
8207
8464
|
if (resolvedParameters.id === void 0) {
|
|
@@ -8237,10 +8494,10 @@ globalThis._evals = {
|
|
|
8237
8494
|
reporters: {}
|
|
8238
8495
|
};
|
|
8239
8496
|
function _initializeSpanContext() {
|
|
8240
|
-
globalThis._spanContext = { currentSpan:
|
|
8497
|
+
globalThis._spanContext = { currentSpan: _chunkVRZZQPAAjs.currentSpan, withCurrent: _chunkVRZZQPAAjs.withCurrent, startSpan: _chunkVRZZQPAAjs.startSpan, NOOP_SPAN: _chunkVRZZQPAAjs.NOOP_SPAN };
|
|
8241
8498
|
}
|
|
8242
8499
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
8243
|
-
const options =
|
|
8500
|
+
const options = _chunkVRZZQPAAjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
8244
8501
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
8245
8502
|
if (globalThis._evals.evaluators[evalName]) {
|
|
8246
8503
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -8291,7 +8548,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8291
8548
|
baseExperimentId: evaluator.baseExperimentId,
|
|
8292
8549
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
8293
8550
|
repoInfo: evaluator.repoInfo,
|
|
8294
|
-
dataset:
|
|
8551
|
+
dataset: _chunkVRZZQPAAjs.Dataset.isDataset(data) ? data : void 0,
|
|
8295
8552
|
parameters
|
|
8296
8553
|
});
|
|
8297
8554
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
@@ -8311,7 +8568,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8311
8568
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
8312
8569
|
let ret;
|
|
8313
8570
|
if (options.parent) {
|
|
8314
|
-
ret = await
|
|
8571
|
+
ret = await _chunkVRZZQPAAjs.withParent.call(void 0,
|
|
8315
8572
|
options.parent,
|
|
8316
8573
|
() => runEvaluator(
|
|
8317
8574
|
null,
|
|
@@ -8347,7 +8604,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8347
8604
|
if (experiment) {
|
|
8348
8605
|
await experiment.flush().catch(console.error);
|
|
8349
8606
|
} else if (options.parent) {
|
|
8350
|
-
await
|
|
8607
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
8351
8608
|
}
|
|
8352
8609
|
}
|
|
8353
8610
|
} finally {
|
|
@@ -8393,13 +8650,13 @@ function classifierName(classifier, classifier_idx) {
|
|
|
8393
8650
|
}
|
|
8394
8651
|
function buildSpanMetadata(results) {
|
|
8395
8652
|
return results.length === 1 ? results[0].metadata : results.reduce(
|
|
8396
|
-
(prev, s) =>
|
|
8653
|
+
(prev, s) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
|
|
8397
8654
|
{}
|
|
8398
8655
|
);
|
|
8399
8656
|
}
|
|
8400
8657
|
function buildSpanScores(results) {
|
|
8401
8658
|
const scoresRecord = results.reduce(
|
|
8402
|
-
(prev, s) =>
|
|
8659
|
+
(prev, s) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
|
|
8403
8660
|
{}
|
|
8404
8661
|
);
|
|
8405
8662
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
@@ -8429,7 +8686,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
8429
8686
|
return failing;
|
|
8430
8687
|
}
|
|
8431
8688
|
function validateClassificationResult(value, scorerName2) {
|
|
8432
|
-
if (!(typeof value === "object" && value !== null && !
|
|
8689
|
+
if (!(typeof value === "object" && value !== null && !_chunkVRZZQPAAjs.isEmpty.call(void 0, value))) {
|
|
8433
8690
|
throw new Error(
|
|
8434
8691
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
8435
8692
|
);
|
|
@@ -8458,7 +8715,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
8458
8715
|
);
|
|
8459
8716
|
metadata[`${kind}_errors`] = errorMap;
|
|
8460
8717
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
8461
|
-
|
|
8718
|
+
_chunkVRZZQPAAjs.debugLogger.forState(state).warn(
|
|
8462
8719
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
8463
8720
|
failures.map((f) => f.error)
|
|
8464
8721
|
);
|
|
@@ -8492,7 +8749,7 @@ var defaultErrorScoreHandler = ({
|
|
|
8492
8749
|
};
|
|
8493
8750
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
8494
8751
|
if (enableCache) {
|
|
8495
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
8752
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _153 => _153.spanCache, 'optionalAccess', _154 => _154.start, 'call', _155 => _155()]);
|
|
8496
8753
|
}
|
|
8497
8754
|
try {
|
|
8498
8755
|
if (typeof evaluator.data === "string") {
|
|
@@ -8513,7 +8770,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8513
8770
|
);
|
|
8514
8771
|
}
|
|
8515
8772
|
let name = dataResult.name;
|
|
8516
|
-
if (
|
|
8773
|
+
if (_chunkVRZZQPAAjs.isEmpty.call(void 0, name)) {
|
|
8517
8774
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
8518
8775
|
if (!baseExperiment) {
|
|
8519
8776
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -8547,7 +8804,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8547
8804
|
const experimentIdPromise = experiment ? (async () => {
|
|
8548
8805
|
try {
|
|
8549
8806
|
return await experiment.id;
|
|
8550
|
-
} catch (
|
|
8807
|
+
} catch (e10) {
|
|
8551
8808
|
return void 0;
|
|
8552
8809
|
}
|
|
8553
8810
|
})() : void 0;
|
|
@@ -8563,7 +8820,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8563
8820
|
if (cancelled) {
|
|
8564
8821
|
return;
|
|
8565
8822
|
}
|
|
8566
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
8823
|
+
const eventDataset = experiment ? experiment.dataset : _chunkVRZZQPAAjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
8567
8824
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
8568
8825
|
object_type: "dataset",
|
|
8569
8826
|
object_id: await eventDataset.id,
|
|
@@ -8571,8 +8828,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8571
8828
|
created: datum.created,
|
|
8572
8829
|
_xact_id: datum._xact_id
|
|
8573
8830
|
} : void 0;
|
|
8574
|
-
const parsedDatumOrigin =
|
|
8575
|
-
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess',
|
|
8831
|
+
const parsedDatumOrigin = _chunkVRZZQPAAjs.ObjectReference.safeParse(datum.origin);
|
|
8832
|
+
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _156 => _156.success]) ? parsedDatumOrigin.data : void 0)));
|
|
8576
8833
|
const baseEvent = {
|
|
8577
8834
|
name: "eval",
|
|
8578
8835
|
spanAttributes: {
|
|
@@ -8587,26 +8844,26 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8587
8844
|
}
|
|
8588
8845
|
};
|
|
8589
8846
|
const callback = async (rootSpan) => {
|
|
8590
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
8847
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )));
|
|
8591
8848
|
const ensureSpansFlushed = async () => {
|
|
8592
8849
|
if (experiment) {
|
|
8593
|
-
await
|
|
8850
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, { state: experiment.loggingState });
|
|
8594
8851
|
} else if (state) {
|
|
8595
|
-
await
|
|
8852
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, { state });
|
|
8596
8853
|
} else {
|
|
8597
|
-
await
|
|
8854
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, );
|
|
8598
8855
|
}
|
|
8599
8856
|
if (state) {
|
|
8600
8857
|
await state.flushOtel();
|
|
8601
8858
|
}
|
|
8602
8859
|
};
|
|
8603
8860
|
const parentStr = state.currentParent.getStore();
|
|
8604
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
8861
|
+
const parentComponents = typeof parentStr === "string" ? _chunkVRZZQPAAjs.SpanComponentsV4.fromStr(parentStr) : null;
|
|
8605
8862
|
const trace = state ? new LocalTrace({
|
|
8606
|
-
objectType: parentComponents ?
|
|
8863
|
+
objectType: parentComponents ? _chunkVRZZQPAAjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
8607
8864
|
parentComponents.data.object_type
|
|
8608
8865
|
) : "experiment",
|
|
8609
|
-
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async
|
|
8866
|
+
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _157 => _157.data, 'access', async _158 => _158.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
8610
8867
|
rootSpanId: rootSpan.rootSpanId,
|
|
8611
8868
|
ensureSpansFlushed,
|
|
8612
8869
|
state
|
|
@@ -8636,10 +8893,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8636
8893
|
span,
|
|
8637
8894
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
8638
8895
|
reportProgress: (event) => {
|
|
8639
|
-
_optionalChain([stream, 'optionalCall',
|
|
8896
|
+
_optionalChain([stream, 'optionalCall', _159 => _159({
|
|
8640
8897
|
...event,
|
|
8641
8898
|
id: rootSpan.id,
|
|
8642
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8899
|
+
origin: _optionalChain([baseEvent, 'access', _160 => _160.event, 'optionalAccess', _161 => _161.origin]),
|
|
8643
8900
|
name: evaluator.evalName,
|
|
8644
8901
|
object_type: "task"
|
|
8645
8902
|
})]);
|
|
@@ -8678,7 +8935,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8678
8935
|
trace
|
|
8679
8936
|
};
|
|
8680
8937
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
8681
|
-
const propagatedEvent =
|
|
8938
|
+
const propagatedEvent = _chunkVRZZQPAAjs.makeScorerPropagatedEvent.call(void 0,
|
|
8682
8939
|
await rootSpan.export()
|
|
8683
8940
|
);
|
|
8684
8941
|
const getOtherFields = (s) => {
|
|
@@ -8701,14 +8958,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8701
8958
|
if (scoreValue === null) return null;
|
|
8702
8959
|
if (Array.isArray(scoreValue)) {
|
|
8703
8960
|
for (const s of scoreValue) {
|
|
8704
|
-
if (!(typeof s === "object" && !
|
|
8961
|
+
if (!(typeof s === "object" && !_chunkVRZZQPAAjs.isEmpty.call(void 0, s))) {
|
|
8705
8962
|
throw new Error(
|
|
8706
8963
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
8707
8964
|
);
|
|
8708
8965
|
}
|
|
8709
8966
|
}
|
|
8710
8967
|
}
|
|
8711
|
-
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !
|
|
8968
|
+
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkVRZZQPAAjs.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
|
|
8712
8969
|
{
|
|
8713
8970
|
name: scorerNames[score_idx],
|
|
8714
8971
|
score: scoreValue
|
|
@@ -8716,7 +8973,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8716
8973
|
];
|
|
8717
8974
|
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
8718
8975
|
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
8719
|
-
(prev, s) =>
|
|
8976
|
+
(prev, s) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, {
|
|
8720
8977
|
[s.name]: getOtherFields(s)
|
|
8721
8978
|
}),
|
|
8722
8979
|
{}
|
|
@@ -8751,7 +9008,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8751
9008
|
)
|
|
8752
9009
|
);
|
|
8753
9010
|
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
8754
|
-
(prev, r) =>
|
|
9011
|
+
(prev, r) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, {
|
|
8755
9012
|
[r.name]: toClassificationItem(r)
|
|
8756
9013
|
}),
|
|
8757
9014
|
{}
|
|
@@ -8803,7 +9060,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8803
9060
|
evaluator.state
|
|
8804
9061
|
);
|
|
8805
9062
|
} catch (e) {
|
|
8806
|
-
|
|
9063
|
+
_chunkVRZZQPAAjs.logError.call(void 0, rootSpan, e);
|
|
8807
9064
|
error = e;
|
|
8808
9065
|
} finally {
|
|
8809
9066
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -8827,7 +9084,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8827
9084
|
tags: tags.length ? tags : void 0,
|
|
8828
9085
|
metadata,
|
|
8829
9086
|
error,
|
|
8830
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
9087
|
+
origin: _optionalChain([baseEvent, 'access', _162 => _162.event, 'optionalAccess', _163 => _163.origin])
|
|
8831
9088
|
};
|
|
8832
9089
|
collectedResults.push({
|
|
8833
9090
|
...baseResult,
|
|
@@ -8837,7 +9094,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8837
9094
|
}
|
|
8838
9095
|
};
|
|
8839
9096
|
if (!experiment) {
|
|
8840
|
-
return await
|
|
9097
|
+
return await _chunkVRZZQPAAjs.traced.call(void 0, callback, {
|
|
8841
9098
|
...baseEvent,
|
|
8842
9099
|
state: evaluator.state
|
|
8843
9100
|
});
|
|
@@ -8867,7 +9124,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8867
9124
|
break;
|
|
8868
9125
|
}
|
|
8869
9126
|
scheduledTrials++;
|
|
8870
|
-
_optionalChain([progressReporter, 'access',
|
|
9127
|
+
_optionalChain([progressReporter, 'access', _164 => _164.setTotal, 'optionalCall', _165 => _165(evaluator.evalName, scheduledTrials)]);
|
|
8871
9128
|
q.pushAsync({ datum, trialIndex }).catch((e) => {
|
|
8872
9129
|
if (queueErrors.length < 5) {
|
|
8873
9130
|
queueErrors.push(e);
|
|
@@ -8891,7 +9148,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8891
9148
|
const cancel = async () => {
|
|
8892
9149
|
await new Promise((_, reject2) => {
|
|
8893
9150
|
if (cancelled) {
|
|
8894
|
-
reject2(new (0,
|
|
9151
|
+
reject2(new (0, _chunkVRZZQPAAjs.InternalAbortError)("Evaluator already cancelled"));
|
|
8895
9152
|
return;
|
|
8896
9153
|
}
|
|
8897
9154
|
const rejectOnce = (error) => {
|
|
@@ -8904,12 +9161,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8904
9161
|
};
|
|
8905
9162
|
if (evaluator.timeout) {
|
|
8906
9163
|
timeoutId = setTimeout(() => {
|
|
8907
|
-
rejectOnce(new (0,
|
|
9164
|
+
rejectOnce(new (0, _chunkVRZZQPAAjs.InternalAbortError)("Evaluator timed out"));
|
|
8908
9165
|
}, evaluator.timeout);
|
|
8909
9166
|
}
|
|
8910
9167
|
if (evaluator.signal) {
|
|
8911
9168
|
abortHandler = () => {
|
|
8912
|
-
rejectOnce(new (0,
|
|
9169
|
+
rejectOnce(new (0, _chunkVRZZQPAAjs.InternalAbortError)("Evaluator aborted"));
|
|
8913
9170
|
};
|
|
8914
9171
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
8915
9172
|
}
|
|
@@ -8932,9 +9189,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8932
9189
|
}
|
|
8933
9190
|
} catch (e) {
|
|
8934
9191
|
q.kill();
|
|
8935
|
-
if (e instanceof
|
|
8936
|
-
if (
|
|
8937
|
-
|
|
9192
|
+
if (e instanceof _chunkVRZZQPAAjs.InternalAbortError) {
|
|
9193
|
+
if (_chunkVYNNEKSAjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
9194
|
+
_chunkVRZZQPAAjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
8938
9195
|
}
|
|
8939
9196
|
}
|
|
8940
9197
|
throw e;
|
|
@@ -8959,9 +9216,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8959
9216
|
);
|
|
8960
9217
|
} finally {
|
|
8961
9218
|
if (enableCache) {
|
|
8962
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
8963
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
8964
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
9219
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _166 => _166.spanCache]);
|
|
9220
|
+
_optionalChain([spanCache, 'optionalAccess', _167 => _167.dispose, 'call', _168 => _168()]);
|
|
9221
|
+
_optionalChain([spanCache, 'optionalAccess', _169 => _169.stop, 'call', _170 => _170()]);
|
|
8965
9222
|
}
|
|
8966
9223
|
}
|
|
8967
9224
|
}
|
|
@@ -9054,25 +9311,25 @@ var defaultReporter = {
|
|
|
9054
9311
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
9055
9312
|
}
|
|
9056
9313
|
if (jsonl) {
|
|
9057
|
-
|
|
9314
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
9058
9315
|
} else {
|
|
9059
|
-
|
|
9060
|
-
|
|
9316
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("Experiment summary");
|
|
9317
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("==================");
|
|
9061
9318
|
if (summary.comparisonExperimentName) {
|
|
9062
|
-
|
|
9319
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9063
9320
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
9064
9321
|
);
|
|
9065
|
-
|
|
9322
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("");
|
|
9066
9323
|
}
|
|
9067
9324
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
9068
9325
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
9069
9326
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
9070
9327
|
if (hasScores || hasMetrics) {
|
|
9071
9328
|
if (hasComparison) {
|
|
9072
|
-
|
|
9329
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9073
9330
|
"Name Value Change Improvements Regressions"
|
|
9074
9331
|
);
|
|
9075
|
-
|
|
9332
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9076
9333
|
"----------------------------------------------------------------"
|
|
9077
9334
|
);
|
|
9078
9335
|
}
|
|
@@ -9081,18 +9338,18 @@ var defaultReporter = {
|
|
|
9081
9338
|
const scoreValue = `${scorePercent}%`;
|
|
9082
9339
|
if (hasComparison) {
|
|
9083
9340
|
let diffString = "-";
|
|
9084
|
-
if (!
|
|
9341
|
+
if (!_chunkVRZZQPAAjs.isEmpty.call(void 0, score.diff)) {
|
|
9085
9342
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
9086
9343
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
9087
9344
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9088
9345
|
}
|
|
9089
9346
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
9090
9347
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
9091
|
-
|
|
9348
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9092
9349
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9093
9350
|
);
|
|
9094
9351
|
} else {
|
|
9095
|
-
|
|
9352
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
9096
9353
|
}
|
|
9097
9354
|
}
|
|
9098
9355
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -9101,30 +9358,30 @@ var defaultReporter = {
|
|
|
9101
9358
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
9102
9359
|
if (hasComparison) {
|
|
9103
9360
|
let diffString = "-";
|
|
9104
|
-
if (!
|
|
9361
|
+
if (!_chunkVRZZQPAAjs.isEmpty.call(void 0, metric.diff)) {
|
|
9105
9362
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
9106
9363
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
9107
9364
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9108
9365
|
}
|
|
9109
9366
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
9110
9367
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
9111
|
-
|
|
9368
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9112
9369
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9113
9370
|
);
|
|
9114
9371
|
} else {
|
|
9115
|
-
|
|
9372
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9116
9373
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
9117
9374
|
);
|
|
9118
9375
|
}
|
|
9119
9376
|
}
|
|
9120
9377
|
}
|
|
9121
9378
|
if (summary.experimentUrl) {
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9379
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("");
|
|
9380
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(`View results for ${summary.experimentName}`);
|
|
9381
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
|
|
9125
9382
|
}
|
|
9126
9383
|
}
|
|
9127
|
-
|
|
9384
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("");
|
|
9128
9385
|
return failingResults.length === 0;
|
|
9129
9386
|
},
|
|
9130
9387
|
async reportRun(evalReports) {
|
|
@@ -9144,7 +9401,7 @@ function agentAssertionScorer(callback, options = {}) {
|
|
|
9144
9401
|
});
|
|
9145
9402
|
const resources = {};
|
|
9146
9403
|
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
9147
|
-
resources.spans = await _optionalChain([args, 'access',
|
|
9404
|
+
resources.spans = await _optionalChain([args, 'access', _171 => _171.trace, 'optionalAccess', _172 => _172.getSpans, 'call', _173 => _173({ spanType: ["tool"] })]);
|
|
9148
9405
|
}
|
|
9149
9406
|
const results = await Promise.all(
|
|
9150
9407
|
assertions.map(async (assertion) => {
|
|
@@ -9302,7 +9559,7 @@ async function validateSchema(schema, value) {
|
|
|
9302
9559
|
}
|
|
9303
9560
|
}
|
|
9304
9561
|
function toolCalls(spans) {
|
|
9305
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
9562
|
+
return spans.filter((span) => _optionalChain([span, 'access', _174 => _174.span_attributes, 'optionalAccess', _175 => _175.type]) === "tool");
|
|
9306
9563
|
}
|
|
9307
9564
|
function matchingToolCalls(spans, toolName, options) {
|
|
9308
9565
|
return toolCalls(spans).filter((span) => {
|
|
@@ -9320,17 +9577,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
9320
9577
|
});
|
|
9321
9578
|
}
|
|
9322
9579
|
function getToolName(span) {
|
|
9323
|
-
const spanName = [_optionalChain([span, 'access',
|
|
9324
|
-
if (_optionalChain([spanName, 'optionalAccess',
|
|
9580
|
+
const spanName = [_optionalChain([span, 'access', _176 => _176.span_attributes, 'optionalAccess', _177 => _177.name]), span.name].map(normalizeToolName).find((value) => value !== void 0);
|
|
9581
|
+
if (_optionalChain([spanName, 'optionalAccess', _178 => _178.includes, 'call', _179 => _179("/")])) {
|
|
9325
9582
|
return spanName;
|
|
9326
9583
|
}
|
|
9327
9584
|
const metadataName = [
|
|
9328
|
-
_optionalChain([span, 'access',
|
|
9329
|
-
_optionalChain([span, 'access',
|
|
9585
|
+
_optionalChain([span, 'access', _180 => _180.metadata, 'optionalAccess', _181 => _181.tool_name]),
|
|
9586
|
+
_optionalChain([span, 'access', _182 => _182.metadata, 'optionalAccess', _183 => _183["gen_ai.tool.name"]])
|
|
9330
9587
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
9331
9588
|
const mcpServer = [
|
|
9332
|
-
_optionalChain([span, 'access',
|
|
9333
|
-
_optionalChain([span, 'access',
|
|
9589
|
+
_optionalChain([span, 'access', _184 => _184.metadata, 'optionalAccess', _185 => _185["mcp.server"]]),
|
|
9590
|
+
_optionalChain([span, 'access', _186 => _186.metadata, 'optionalAccess', _187 => _187["openai_codex.mcp.server"]])
|
|
9334
9591
|
].find((value) => typeof value === "string" && value !== "");
|
|
9335
9592
|
if (metadataName && mcpServer) {
|
|
9336
9593
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -9400,7 +9657,7 @@ function formatValue(value) {
|
|
|
9400
9657
|
return serialized;
|
|
9401
9658
|
}
|
|
9402
9659
|
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
9403
|
-
} catch (
|
|
9660
|
+
} catch (e11) {
|
|
9404
9661
|
return String(value);
|
|
9405
9662
|
}
|
|
9406
9663
|
}
|
|
@@ -9559,7 +9816,7 @@ var Project2 = (_class7 = class {
|
|
|
9559
9816
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
9560
9817
|
return;
|
|
9561
9818
|
}
|
|
9562
|
-
await
|
|
9819
|
+
await _chunkVRZZQPAAjs.login.call(void 0, );
|
|
9563
9820
|
const projectMap = new ProjectNameIdMap();
|
|
9564
9821
|
const functionDefinitions = [];
|
|
9565
9822
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -9573,7 +9830,7 @@ var Project2 = (_class7 = class {
|
|
|
9573
9830
|
functionDefinitions.push(functionDefinition);
|
|
9574
9831
|
}
|
|
9575
9832
|
}
|
|
9576
|
-
await
|
|
9833
|
+
await _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
9577
9834
|
functions: functionDefinitions
|
|
9578
9835
|
});
|
|
9579
9836
|
}
|
|
@@ -9592,12 +9849,12 @@ var ToolBuilder = (_class8 = class {
|
|
|
9592
9849
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
9593
9850
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
9594
9851
|
if (resolvedName.trim().length === 0) {
|
|
9595
|
-
resolvedName = `Tool ${
|
|
9852
|
+
resolvedName = `Tool ${_chunkVYNNEKSAjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9596
9853
|
}
|
|
9597
9854
|
const tool = new CodeFunction(this.project, {
|
|
9598
9855
|
handler,
|
|
9599
9856
|
name: resolvedName,
|
|
9600
|
-
slug: _nullishCoalesce(slug, () => (
|
|
9857
|
+
slug: _nullishCoalesce(slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
9601
9858
|
type: "tool",
|
|
9602
9859
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
9603
9860
|
parameters,
|
|
@@ -9622,9 +9879,9 @@ var ScorerBuilder = (_class9 = class {
|
|
|
9622
9879
|
resolvedName = opts.handler.name;
|
|
9623
9880
|
}
|
|
9624
9881
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
9625
|
-
resolvedName = `Scorer ${
|
|
9882
|
+
resolvedName = `Scorer ${_chunkVYNNEKSAjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9626
9883
|
}
|
|
9627
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9884
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
9628
9885
|
if ("handler" in opts) {
|
|
9629
9886
|
const scorer = new CodeFunction(this.project, {
|
|
9630
9887
|
...opts,
|
|
@@ -9679,9 +9936,9 @@ var ClassifierBuilder = (_class10 = class {
|
|
|
9679
9936
|
this.taskCounter++;
|
|
9680
9937
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
9681
9938
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
9682
|
-
resolvedName = `Classifier ${
|
|
9939
|
+
resolvedName = `Classifier ${_chunkVYNNEKSAjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9683
9940
|
}
|
|
9684
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9941
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
9685
9942
|
const classifier = new CodeFunction(this.project, {
|
|
9686
9943
|
...opts,
|
|
9687
9944
|
name: resolvedName,
|
|
@@ -9810,18 +10067,18 @@ var PromptBuilder = class {
|
|
|
9810
10067
|
rawTools.push(tool);
|
|
9811
10068
|
}
|
|
9812
10069
|
}
|
|
9813
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
10070
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
9814
10071
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
9815
10072
|
const promptRow = {
|
|
9816
10073
|
id: opts.id,
|
|
9817
|
-
_xact_id: opts.version ?
|
|
10074
|
+
_xact_id: opts.version ? _chunkVRZZQPAAjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
9818
10075
|
name: opts.name,
|
|
9819
10076
|
slug,
|
|
9820
10077
|
prompt_data: promptData,
|
|
9821
10078
|
tags: opts.tags,
|
|
9822
10079
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
9823
10080
|
};
|
|
9824
|
-
const prompt = new (0,
|
|
10081
|
+
const prompt = new (0, _chunkVRZZQPAAjs.Prompt)(
|
|
9825
10082
|
promptRow,
|
|
9826
10083
|
{},
|
|
9827
10084
|
// It doesn't make sense to specify defaults here.
|
|
@@ -9876,7 +10133,7 @@ var ParametersBuilder = class {
|
|
|
9876
10133
|
}
|
|
9877
10134
|
|
|
9878
10135
|
create(opts) {
|
|
9879
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
10136
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
9880
10137
|
const codeParameters = new CodeParameters(this.project, {
|
|
9881
10138
|
name: opts.name,
|
|
9882
10139
|
slug,
|
|
@@ -9915,7 +10172,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
9915
10172
|
required.push(name);
|
|
9916
10173
|
}
|
|
9917
10174
|
} else {
|
|
9918
|
-
const schemaObj =
|
|
10175
|
+
const schemaObj = _chunkVRZZQPAAjs.zodToJsonSchema.call(void 0, value);
|
|
9919
10176
|
properties[name] = schemaObj;
|
|
9920
10177
|
if (!("default" in schemaObj)) {
|
|
9921
10178
|
required.push(name);
|
|
@@ -9944,11 +10201,11 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
9944
10201
|
__init23() {this.idToName = {}}
|
|
9945
10202
|
async getId(projectName) {
|
|
9946
10203
|
if (!(projectName in this.nameToId)) {
|
|
9947
|
-
const response = await
|
|
10204
|
+
const response = await _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
9948
10205
|
project_name: projectName
|
|
9949
10206
|
});
|
|
9950
10207
|
const result = _v3.z.object({
|
|
9951
|
-
project:
|
|
10208
|
+
project: _chunkVRZZQPAAjs.Project
|
|
9952
10209
|
}).parse(response);
|
|
9953
10210
|
const projectId = result.project.id;
|
|
9954
10211
|
this.nameToId[projectName] = projectId;
|
|
@@ -9958,10 +10215,10 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
9958
10215
|
}
|
|
9959
10216
|
async getName(projectId) {
|
|
9960
10217
|
if (!(projectId in this.idToName)) {
|
|
9961
|
-
const response = await
|
|
10218
|
+
const response = await _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
9962
10219
|
id: projectId
|
|
9963
10220
|
});
|
|
9964
|
-
const result = _v3.z.array(
|
|
10221
|
+
const result = _v3.z.array(_chunkVRZZQPAAjs.Project).nonempty().parse(response);
|
|
9965
10222
|
const projectName = result[0].name;
|
|
9966
10223
|
this.idToName[projectId] = projectName;
|
|
9967
10224
|
this.nameToId[projectName] = projectId;
|
|
@@ -9981,16 +10238,16 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
9981
10238
|
var evalBodySchema = _v3.z.object({
|
|
9982
10239
|
name: _v3.z.string(),
|
|
9983
10240
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
9984
|
-
data:
|
|
10241
|
+
data: _chunkVRZZQPAAjs.RunEval.shape.data,
|
|
9985
10242
|
scores: _v3.z.array(
|
|
9986
10243
|
_v3.z.object({
|
|
9987
|
-
function_id:
|
|
10244
|
+
function_id: _chunkVRZZQPAAjs.FunctionId,
|
|
9988
10245
|
name: _v3.z.string()
|
|
9989
10246
|
})
|
|
9990
10247
|
).nullish(),
|
|
9991
10248
|
experiment_name: _v3.z.string().nullish(),
|
|
9992
10249
|
project_id: _v3.z.string().nullish(),
|
|
9993
|
-
parent:
|
|
10250
|
+
parent: _chunkVRZZQPAAjs.InvokeParent.optional(),
|
|
9994
10251
|
stream: _v3.z.boolean().optional()
|
|
9995
10252
|
});
|
|
9996
10253
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -9998,7 +10255,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
9998
10255
|
_v3.z.union([
|
|
9999
10256
|
_v3.z.object({
|
|
10000
10257
|
type: _v3.z.literal("prompt"),
|
|
10001
|
-
default:
|
|
10258
|
+
default: _chunkVRZZQPAAjs.PromptData.optional(),
|
|
10002
10259
|
description: _v3.z.string().optional()
|
|
10003
10260
|
}),
|
|
10004
10261
|
_v3.z.object({
|
|
@@ -10054,7 +10311,10 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
10054
10311
|
);
|
|
10055
10312
|
|
|
10056
10313
|
// src/node/index.ts
|
|
10057
|
-
|
|
10314
|
+
_chunkVRZZQPAAjs.configureNode.call(void 0, );
|
|
10315
|
+
|
|
10316
|
+
|
|
10317
|
+
|
|
10058
10318
|
|
|
10059
10319
|
|
|
10060
10320
|
|
|
@@ -10225,4 +10485,4 @@ _chunkGSIDVFE6js.configureNode.call(void 0, );
|
|
|
10225
10485
|
|
|
10226
10486
|
|
|
10227
10487
|
|
|
10228
|
-
exports.Attachment =
|
|
10488
|
+
exports.Attachment = _chunkVRZZQPAAjs.Attachment; exports.AttachmentReference = _chunkVRZZQPAAjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkVRZZQPAAjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkVRZZQPAAjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkVRZZQPAAjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkVRZZQPAAjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkVRZZQPAAjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkVRZZQPAAjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkVRZZQPAAjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkVRZZQPAAjs.BraintrustState; exports.BraintrustStream = _chunkVRZZQPAAjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkVRZZQPAAjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkVRZZQPAAjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkVRZZQPAAjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkVRZZQPAAjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkVRZZQPAAjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkVRZZQPAAjs.Experiment; exports.ExternalAttachment = _chunkVRZZQPAAjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkVRZZQPAAjs.FailedHTTPResponse; exports.IDGenerator = _chunkVRZZQPAAjs.IDGenerator; exports.JSONAttachment = _chunkVRZZQPAAjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkVRZZQPAAjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkVRZZQPAAjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkVRZZQPAAjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkVRZZQPAAjs.Logger; exports.LoginInvalidOrgError = _chunkVRZZQPAAjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkVRZZQPAAjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkVRZZQPAAjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkVRZZQPAAjs.NoopSpan; exports.OTELIDGenerator = _chunkVRZZQPAAjs.OTELIDGenerator; exports.ObjectFetcher = _chunkVRZZQPAAjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkVRZZQPAAjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkVRZZQPAAjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkVRZZQPAAjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkVRZZQPAAjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkVRZZQPAAjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkVRZZQPAAjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkVRZZQPAAjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkVRZZQPAAjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkVRZZQPAAjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkVRZZQPAAjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkVRZZQPAAjs._internalGetGlobalState; exports._internalIso = _chunkVYNNEKSAjs.isomorph_default; exports._internalSetInitialState = _chunkVRZZQPAAjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkVRZZQPAAjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkVRZZQPAAjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkVRZZQPAAjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkVRZZQPAAjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkVRZZQPAAjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkVRZZQPAAjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkVRZZQPAAjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkVRZZQPAAjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkVRZZQPAAjs.currentExperiment; exports.currentLogger = _chunkVRZZQPAAjs.currentLogger; exports.currentSpan = _chunkVRZZQPAAjs.currentSpan; exports.deepCopyEvent = _chunkVRZZQPAAjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkVRZZQPAAjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkVRZZQPAAjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkVRZZQPAAjs.extractTraceContextFromHeaders; exports.flush = _chunkVRZZQPAAjs.flush; exports.getContextManager = _chunkVRZZQPAAjs.getContextManager; exports.getIdGenerator = _chunkVRZZQPAAjs.getIdGenerator; exports.getPromptVersions = _chunkVRZZQPAAjs.getPromptVersions; exports.getSpanParentObject = _chunkVRZZQPAAjs.getSpanParentObject; exports.getTemplateRenderer = _chunkVRZZQPAAjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkVRZZQPAAjs.init; exports.initDataset = _chunkVRZZQPAAjs.initDataset; exports.initExperiment = _chunkVRZZQPAAjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkVRZZQPAAjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkVRZZQPAAjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkVRZZQPAAjs.isTemplateFormat; exports.loadParameters = _chunkVRZZQPAAjs.loadParameters; exports.loadPrompt = _chunkVRZZQPAAjs.loadPrompt; exports.log = _chunkVRZZQPAAjs.log; exports.logError = _chunkVRZZQPAAjs.logError; exports.login = _chunkVRZZQPAAjs.login; exports.loginToState = _chunkVRZZQPAAjs.loginToState; exports.logs3OverflowUploadSchema = _chunkVRZZQPAAjs.logs3OverflowUploadSchema; exports.newId = _chunkVRZZQPAAjs.newId; exports.parseCachedHeader = _chunkVRZZQPAAjs.parseCachedHeader; exports.parseTemplateFormat = _chunkVRZZQPAAjs.parseTemplateFormat; exports.permalink = _chunkVRZZQPAAjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkVRZZQPAAjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkVRZZQPAAjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkVRZZQPAAjs.registerTemplatePlugin; exports.renderMessage = _chunkVRZZQPAAjs.renderMessage; exports.renderPromptParams = _chunkVRZZQPAAjs.renderPromptParams; exports.renderTemplateContent = _chunkVRZZQPAAjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkVRZZQPAAjs.setFetch; exports.setMaskingFunction = _chunkVRZZQPAAjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkVRZZQPAAjs.spanComponentsToObjectId; exports.startSpan = _chunkVRZZQPAAjs.startSpan; exports.summarize = _chunkVRZZQPAAjs.summarize; exports.templateRegistry = _chunkVRZZQPAAjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkVRZZQPAAjs.ToolFunctionDefinition; exports.traceable = _chunkVRZZQPAAjs.traceable; exports.traced = _chunkVRZZQPAAjs.traced; exports.updateSpan = _chunkVRZZQPAAjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkVRZZQPAAjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkVRZZQPAAjs.utf8ByteLength; exports.withCurrent = _chunkVRZZQPAAjs.withCurrent; exports.withDataset = _chunkVRZZQPAAjs.withDataset; exports.withExperiment = _chunkVRZZQPAAjs.withExperiment; exports.withLogger = _chunkVRZZQPAAjs.withLogger; exports.withParent = _chunkVRZZQPAAjs.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.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 = _chunkVRZZQPAAjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkVRZZQPAAjs.wrapTraced; exports.wrapVitest = wrapVitest;
|