braintrust 3.24.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 +135 -2
- package/dev/dist/index.d.ts +135 -2
- package/dev/dist/index.js +4426 -2040
- package/dev/dist/index.mjs +3594 -1208
- package/dist/apply-auto-instrumentation.js +445 -403
- package/dist/apply-auto-instrumentation.mjs +249 -207
- package/dist/auto-instrumentations/bundler/esbuild.cjs +1449 -799
- 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 +1448 -818
- package/dist/auto-instrumentations/bundler/next.mjs +6 -29
- package/dist/auto-instrumentations/bundler/rollup.cjs +1449 -799
- 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 +1449 -799
- 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 +1602 -728
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
- package/dist/auto-instrumentations/bundler/webpack.cjs +1449 -799
- 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-GSZHTAQW.mjs → chunk-6E22MYSW.mjs} +194 -93
- 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-BURMPO7L.mjs → chunk-V5LEODRX.mjs} +2 -6
- package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
- package/dist/auto-instrumentations/{chunk-F43DNLPD.mjs → chunk-XZHHE4Y3.mjs} +646 -510
- package/dist/auto-instrumentations/hook.mjs +894 -657
- package/dist/auto-instrumentations/index.cjs +1125 -490
- 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 +824 -197
- package/dist/browser.d.ts +824 -197
- package/dist/browser.js +3897 -1228
- package/dist/browser.mjs +3897 -1228
- package/dist/chunk-PN7EWK66.mjs +1784 -0
- package/dist/{chunk-SU6EHKJV.js → chunk-VRZZQPAA.js} +3289 -1577
- package/dist/chunk-VYNNEKSA.js +1784 -0
- package/dist/{chunk-XE5FS7QY.mjs → chunk-XIZOM2HO.mjs} +2470 -758
- package/dist/cli.js +3596 -1211
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +3897 -1231
- package/dist/edge-light.mjs +3897 -1231
- package/dist/index.d.mts +824 -197
- package/dist/index.d.ts +824 -197
- package/dist/index.js +750 -445
- package/dist/index.mjs +334 -29
- package/dist/instrumentation/index.d.mts +135 -6
- package/dist/instrumentation/index.d.ts +135 -6
- package/dist/instrumentation/index.js +3696 -1257
- package/dist/instrumentation/index.mjs +3696 -1257
- 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 +3897 -1231
- package/dist/workerd.mjs +3897 -1231
- 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/chunk-7AUY2XWX.js +0 -1090
- package/dist/chunk-7F6GCRHH.mjs +0 -1090
package/dist/index.js
CHANGED
|
@@ -139,8 +139,8 @@
|
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
var _chunkSU6EHKJVjs = require('./chunk-SU6EHKJV.js');
|
|
143
142
|
|
|
143
|
+
var _chunkVRZZQPAAjs = require('./chunk-VRZZQPAA.js');
|
|
144
144
|
|
|
145
145
|
|
|
146
146
|
|
|
@@ -164,157 +164,165 @@ var _chunkSU6EHKJVjs = require('./chunk-SU6EHKJV.js');
|
|
|
164
164
|
|
|
165
165
|
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
var _chunkVYNNEKSAjs = require('./chunk-VYNNEKSA.js');
|
|
168
174
|
|
|
169
175
|
// src/exports.ts
|
|
170
176
|
var exports_exports = {};
|
|
171
|
-
|
|
172
|
-
Attachment: () =>
|
|
173
|
-
AttachmentReference: () =>
|
|
174
|
-
BAGGAGE_HEADER: () =>
|
|
175
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
176
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
177
|
-
BRAINTRUST_PARENT_KEY: () =>
|
|
178
|
-
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,
|
|
179
185
|
BaseExperiment: () => BaseExperiment,
|
|
180
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
186
|
+
BraintrustLangChainCallbackHandler: () => _chunkVRZZQPAAjs.BraintrustLangChainCallbackHandler,
|
|
181
187
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
182
|
-
BraintrustObservabilityExporter: () =>
|
|
183
|
-
BraintrustState: () =>
|
|
184
|
-
BraintrustStream: () =>
|
|
188
|
+
BraintrustObservabilityExporter: () => _chunkVRZZQPAAjs.BraintrustObservabilityExporter,
|
|
189
|
+
BraintrustState: () => _chunkVRZZQPAAjs.BraintrustState,
|
|
190
|
+
BraintrustStream: () => _chunkVRZZQPAAjs.BraintrustStream,
|
|
185
191
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
186
192
|
CodeFunction: () => CodeFunction,
|
|
187
193
|
CodePrompt: () => CodePrompt,
|
|
188
|
-
ContextManager: () =>
|
|
189
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
190
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
191
|
-
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,
|
|
192
198
|
DatasetPipeline: () => DatasetPipeline,
|
|
193
|
-
ERR_PERMALINK: () =>
|
|
199
|
+
ERR_PERMALINK: () => _chunkVRZZQPAAjs.ERR_PERMALINK,
|
|
194
200
|
Eval: () => Eval,
|
|
195
201
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
196
|
-
Experiment: () =>
|
|
197
|
-
ExternalAttachment: () =>
|
|
198
|
-
FailedHTTPResponse: () =>
|
|
199
|
-
IDGenerator: () =>
|
|
200
|
-
JSONAttachment: () =>
|
|
201
|
-
LEGACY_CACHED_HEADER: () =>
|
|
202
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
203
|
-
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,
|
|
204
210
|
LocalTrace: () => LocalTrace,
|
|
205
|
-
Logger: () =>
|
|
206
|
-
LoginInvalidOrgError: () =>
|
|
207
|
-
NOOP_SPAN: () =>
|
|
208
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
209
|
-
NoopSpan: () =>
|
|
210
|
-
OTELIDGenerator: () =>
|
|
211
|
-
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,
|
|
212
218
|
Project: () => Project2,
|
|
213
219
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
214
|
-
Prompt: () =>
|
|
220
|
+
Prompt: () => _chunkVRZZQPAAjs.Prompt,
|
|
215
221
|
PromptBuilder: () => PromptBuilder,
|
|
216
|
-
ReadonlyAttachment: () =>
|
|
217
|
-
ReadonlyExperiment: () =>
|
|
222
|
+
ReadonlyAttachment: () => _chunkVRZZQPAAjs.ReadonlyAttachment,
|
|
223
|
+
ReadonlyExperiment: () => _chunkVRZZQPAAjs.ReadonlyExperiment,
|
|
218
224
|
Reporter: () => Reporter,
|
|
219
225
|
ScorerBuilder: () => ScorerBuilder,
|
|
220
226
|
SpanFetcher: () => SpanFetcher,
|
|
221
|
-
SpanImpl: () =>
|
|
222
|
-
TRACEPARENT_HEADER: () =>
|
|
223
|
-
TRACESTATE_HEADER: () =>
|
|
224
|
-
TestBackgroundLogger: () =>
|
|
227
|
+
SpanImpl: () => _chunkVRZZQPAAjs.SpanImpl,
|
|
228
|
+
TRACEPARENT_HEADER: () => _chunkVRZZQPAAjs.TRACEPARENT_HEADER,
|
|
229
|
+
TRACESTATE_HEADER: () => _chunkVRZZQPAAjs.TRACESTATE_HEADER,
|
|
230
|
+
TestBackgroundLogger: () => _chunkVRZZQPAAjs.TestBackgroundLogger,
|
|
225
231
|
ToolBuilder: () => ToolBuilder,
|
|
226
|
-
UUIDGenerator: () =>
|
|
227
|
-
X_CACHED_HEADER: () =>
|
|
228
|
-
_exportsForTestingOnly: () =>
|
|
229
|
-
_internalGetGlobalState: () =>
|
|
230
|
-
_internalIso: () =>
|
|
231
|
-
_internalSetInitialState: () =>
|
|
232
|
-
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,
|
|
233
239
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
234
|
-
braintrustAISDKTelemetry: () =>
|
|
240
|
+
braintrustAISDKTelemetry: () => _chunkVRZZQPAAjs.braintrustAISDKTelemetry,
|
|
235
241
|
braintrustEveHook: () => braintrustEveHook,
|
|
236
242
|
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
237
|
-
braintrustFlueInstrumentation: () =>
|
|
238
|
-
braintrustFlueObserver: () =>
|
|
239
|
-
braintrustStreamChunkSchema: () =>
|
|
243
|
+
braintrustFlueInstrumentation: () => _chunkVRZZQPAAjs.braintrustFlueInstrumentation,
|
|
244
|
+
braintrustFlueObserver: () => _chunkVRZZQPAAjs.braintrustFlueObserver,
|
|
245
|
+
braintrustStreamChunkSchema: () => _chunkVRZZQPAAjs.braintrustStreamChunkSchema,
|
|
240
246
|
buildLocalSummary: () => buildLocalSummary,
|
|
241
|
-
configureInstrumentation: () =>
|
|
242
|
-
constructLogs3OverflowRequest: () =>
|
|
243
|
-
createFinalValuePassThroughStream: () =>
|
|
244
|
-
currentExperiment: () =>
|
|
245
|
-
currentLogger: () =>
|
|
246
|
-
currentSpan: () =>
|
|
247
|
-
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,
|
|
248
254
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
249
|
-
deserializePlainStringAsJSON: () =>
|
|
250
|
-
devNullWritableStream: () =>
|
|
255
|
+
deserializePlainStringAsJSON: () => _chunkVRZZQPAAjs.deserializePlainStringAsJSON,
|
|
256
|
+
devNullWritableStream: () => _chunkVRZZQPAAjs.devNullWritableStream,
|
|
251
257
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
252
258
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
253
|
-
extractTraceContextFromHeaders: () =>
|
|
254
|
-
flush: () =>
|
|
255
|
-
getContextManager: () =>
|
|
256
|
-
getIdGenerator: () =>
|
|
257
|
-
getPromptVersions: () =>
|
|
258
|
-
getSpanParentObject: () =>
|
|
259
|
-
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,
|
|
260
266
|
graph: () => graph_framework_exports,
|
|
261
|
-
init: () =>
|
|
262
|
-
initDataset: () =>
|
|
263
|
-
initExperiment: () =>
|
|
267
|
+
init: () => _chunkVRZZQPAAjs.init,
|
|
268
|
+
initDataset: () => _chunkVRZZQPAAjs.initDataset,
|
|
269
|
+
initExperiment: () => _chunkVRZZQPAAjs.initExperiment,
|
|
264
270
|
initFunction: () => initFunction,
|
|
265
|
-
initLogger: () =>
|
|
271
|
+
initLogger: () => _chunkVRZZQPAAjs.initLogger,
|
|
266
272
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
267
|
-
injectTraceContext: () =>
|
|
273
|
+
injectTraceContext: () => _chunkVRZZQPAAjs.injectTraceContext,
|
|
268
274
|
invoke: () => invoke,
|
|
269
|
-
isTemplateFormat: () =>
|
|
270
|
-
loadParameters: () =>
|
|
271
|
-
loadPrompt: () =>
|
|
272
|
-
log: () =>
|
|
273
|
-
logError: () =>
|
|
274
|
-
login: () =>
|
|
275
|
-
loginToState: () =>
|
|
276
|
-
logs3OverflowUploadSchema: () =>
|
|
277
|
-
newId: () =>
|
|
278
|
-
parseCachedHeader: () =>
|
|
279
|
-
parseTemplateFormat: () =>
|
|
280
|
-
permalink: () =>
|
|
281
|
-
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,
|
|
282
288
|
projects: () => projects,
|
|
283
289
|
promptContentsSchema: () => promptContentsSchema,
|
|
284
290
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
285
291
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
286
292
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
287
|
-
registerOtelFlush: () =>
|
|
293
|
+
registerOtelFlush: () => _chunkVRZZQPAAjs.registerOtelFlush,
|
|
288
294
|
registerSandbox: () => registerSandbox,
|
|
289
|
-
registerTemplatePlugin: () =>
|
|
290
|
-
renderMessage: () =>
|
|
291
|
-
renderPromptParams: () =>
|
|
292
|
-
renderTemplateContent: () =>
|
|
295
|
+
registerTemplatePlugin: () => _chunkVRZZQPAAjs.registerTemplatePlugin,
|
|
296
|
+
renderMessage: () => _chunkVRZZQPAAjs.renderMessage,
|
|
297
|
+
renderPromptParams: () => _chunkVRZZQPAAjs.renderPromptParams,
|
|
298
|
+
renderTemplateContent: () => _chunkVRZZQPAAjs.renderTemplateContent,
|
|
293
299
|
reportFailures: () => reportFailures,
|
|
294
300
|
runEvaluator: () => runEvaluator,
|
|
295
|
-
setFetch: () =>
|
|
296
|
-
setMaskingFunction: () =>
|
|
297
|
-
spanComponentsToObjectId: () =>
|
|
298
|
-
startSpan: () =>
|
|
299
|
-
summarize: () =>
|
|
300
|
-
templateRegistry: () =>
|
|
301
|
-
toolFunctionDefinitionSchema: () =>
|
|
302
|
-
traceable: () =>
|
|
303
|
-
traced: () =>
|
|
304
|
-
updateSpan: () =>
|
|
305
|
-
uploadLogs3OverflowPayload: () =>
|
|
306
|
-
utf8ByteLength: () =>
|
|
307
|
-
withCurrent: () =>
|
|
308
|
-
withDataset: () =>
|
|
309
|
-
withExperiment: () =>
|
|
310
|
-
withLogger: () =>
|
|
311
|
-
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,
|
|
312
318
|
wrapAISDK: () => wrapAISDK,
|
|
313
319
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
314
320
|
wrapAgentClass: () => wrapAgentClass,
|
|
315
321
|
wrapAnthropic: () => wrapAnthropic,
|
|
316
322
|
wrapBedrockRuntime: () => wrapBedrockRuntime,
|
|
317
323
|
wrapClaudeAgentSDK: () => wrapClaudeAgentSDK,
|
|
324
|
+
wrapCloudflareAIChat: () => wrapCloudflareAIChat,
|
|
325
|
+
wrapCloudflareAgent: () => wrapCloudflareAgent,
|
|
318
326
|
wrapCohere: () => wrapCohere,
|
|
319
327
|
wrapCopilotClient: () => wrapCopilotClient,
|
|
320
328
|
wrapCursorSDK: () => wrapCursorSDK,
|
|
@@ -323,10 +331,11 @@ _chunk7AUY2XWXjs.__export.call(void 0, exports_exports, {
|
|
|
323
331
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
324
332
|
wrapGroq: () => wrapGroq,
|
|
325
333
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
334
|
+
wrapHuggingFaceTransformers: () => wrapHuggingFaceTransformers,
|
|
326
335
|
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
327
336
|
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
328
337
|
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
329
|
-
wrapMastraAgent: () =>
|
|
338
|
+
wrapMastraAgent: () => _chunkVRZZQPAAjs.wrapMastraAgent,
|
|
330
339
|
wrapMistral: () => wrapMistral,
|
|
331
340
|
wrapOpenAI: () => wrapOpenAI,
|
|
332
341
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
@@ -335,7 +344,7 @@ _chunk7AUY2XWXjs.__export.call(void 0, exports_exports, {
|
|
|
335
344
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
336
345
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
337
346
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
338
|
-
wrapTraced: () =>
|
|
347
|
+
wrapTraced: () => _chunkVRZZQPAAjs.wrapTraced,
|
|
339
348
|
wrapVitest: () => wrapVitest
|
|
340
349
|
});
|
|
341
350
|
|
|
@@ -343,7 +352,7 @@ _chunk7AUY2XWXjs.__export.call(void 0, exports_exports, {
|
|
|
343
352
|
var _v3 = require('zod/v3');
|
|
344
353
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
345
354
|
async function registerSandbox(options) {
|
|
346
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
355
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )));
|
|
347
356
|
await state.login({
|
|
348
357
|
apiKey: options.apiKey,
|
|
349
358
|
appUrl: options.appUrl,
|
|
@@ -384,7 +393,7 @@ async function registerSandbox(options) {
|
|
|
384
393
|
evaluatorDefinitions
|
|
385
394
|
)) {
|
|
386
395
|
const functionName = evalName;
|
|
387
|
-
const functionSlug =
|
|
396
|
+
const functionSlug = _chunkVRZZQPAAjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
388
397
|
const functionDef = {
|
|
389
398
|
project_id: projectId,
|
|
390
399
|
org_name: state.orgName,
|
|
@@ -455,7 +464,7 @@ async function invoke(args) {
|
|
|
455
464
|
projectId,
|
|
456
465
|
...functionIdArgs
|
|
457
466
|
} = args;
|
|
458
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
467
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )));
|
|
459
468
|
await state.login({
|
|
460
469
|
orgName,
|
|
461
470
|
apiKey,
|
|
@@ -463,8 +472,8 @@ async function invoke(args) {
|
|
|
463
472
|
forceLogin,
|
|
464
473
|
fetch
|
|
465
474
|
});
|
|
466
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
467
|
-
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({
|
|
468
477
|
function_id: functionIdArgs.function_id,
|
|
469
478
|
project_name: functionIdArgs.projectName,
|
|
470
479
|
slug: functionIdArgs.slug,
|
|
@@ -507,7 +516,7 @@ async function invoke(args) {
|
|
|
507
516
|
if (!resp.body) {
|
|
508
517
|
throw new Error("Received empty stream body");
|
|
509
518
|
}
|
|
510
|
-
return new (0,
|
|
519
|
+
return new (0, _chunkVRZZQPAAjs.BraintrustStream)(resp.body);
|
|
511
520
|
} else {
|
|
512
521
|
const data = await resp.json();
|
|
513
522
|
return schema ? schema.parse(data) : data;
|
|
@@ -519,7 +528,7 @@ function initFunction({
|
|
|
519
528
|
version,
|
|
520
529
|
state
|
|
521
530
|
}) {
|
|
522
|
-
const s = _nullishCoalesce(state, () => (
|
|
531
|
+
const s = _nullishCoalesce(state, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )));
|
|
523
532
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
524
533
|
const f = async (input) => {
|
|
525
534
|
return await invoke({
|
|
@@ -597,22 +606,22 @@ function responsesProxy(openai) {
|
|
|
597
606
|
if (name === "create" && typeof target.create === "function") {
|
|
598
607
|
return wrapResponsesAsync(
|
|
599
608
|
target.create.bind(target),
|
|
600
|
-
|
|
609
|
+
_chunkVYNNEKSAjs.openAIChannels.responsesCreate
|
|
601
610
|
);
|
|
602
611
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
603
612
|
return wrapResponsesSyncStream(
|
|
604
613
|
target.stream.bind(target),
|
|
605
|
-
|
|
614
|
+
_chunkVYNNEKSAjs.openAIChannels.responsesStream
|
|
606
615
|
);
|
|
607
616
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
608
617
|
return wrapResponsesAsync(
|
|
609
618
|
target.parse.bind(target),
|
|
610
|
-
|
|
619
|
+
_chunkVYNNEKSAjs.openAIChannels.responsesParse
|
|
611
620
|
);
|
|
612
621
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
613
622
|
return wrapResponsesAsync(
|
|
614
623
|
target.compact.bind(target),
|
|
615
|
-
|
|
624
|
+
_chunkVYNNEKSAjs.openAIChannels.responsesCompact
|
|
616
625
|
);
|
|
617
626
|
}
|
|
618
627
|
return Reflect.get(target, name, receiver);
|
|
@@ -756,7 +765,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
756
765
|
const { span_info, params } = splitSpanInfo(
|
|
757
766
|
allParams
|
|
758
767
|
);
|
|
759
|
-
return
|
|
768
|
+
return _chunkVYNNEKSAjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
760
769
|
async () => await completion(params),
|
|
761
770
|
{ arguments: [params], span_info }
|
|
762
771
|
);
|
|
@@ -767,7 +776,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
767
776
|
const { span_info, params } = splitSpanInfo(
|
|
768
777
|
allParams
|
|
769
778
|
);
|
|
770
|
-
return
|
|
779
|
+
return _chunkVYNNEKSAjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
771
780
|
() => completion(params),
|
|
772
781
|
{ arguments: [params], span_info }
|
|
773
782
|
);
|
|
@@ -783,7 +792,7 @@ function wrapChatCompletion(completion) {
|
|
|
783
792
|
if (!executionPromise) {
|
|
784
793
|
executionPromise = (async () => {
|
|
785
794
|
const traceContext = createChannelContext(
|
|
786
|
-
|
|
795
|
+
_chunkVYNNEKSAjs.openAIChannels.chatCompletionsCreate,
|
|
787
796
|
params,
|
|
788
797
|
span_info
|
|
789
798
|
);
|
|
@@ -793,7 +802,7 @@ function wrapChatCompletion(completion) {
|
|
|
793
802
|
options
|
|
794
803
|
);
|
|
795
804
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
796
|
-
|
|
805
|
+
_chunkVYNNEKSAjs.openAIChannels.chatCompletionsCreate,
|
|
797
806
|
traceContext,
|
|
798
807
|
completionPromise
|
|
799
808
|
);
|
|
@@ -804,7 +813,7 @@ function wrapChatCompletion(completion) {
|
|
|
804
813
|
options
|
|
805
814
|
);
|
|
806
815
|
const { data, response } = await tracePromiseWithResponse(
|
|
807
|
-
|
|
816
|
+
_chunkVYNNEKSAjs.openAIChannels.chatCompletionsCreate,
|
|
808
817
|
traceContext,
|
|
809
818
|
completionResponse
|
|
810
819
|
);
|
|
@@ -847,8 +856,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
847
856
|
return createLazyAPIPromise(ensureExecuted);
|
|
848
857
|
};
|
|
849
858
|
}
|
|
850
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
851
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
859
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkVYNNEKSAjs.openAIChannels.embeddingsCreate);
|
|
860
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkVYNNEKSAjs.openAIChannels.moderationsCreate);
|
|
852
861
|
|
|
853
862
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
854
863
|
function isModuleNamespace(obj) {
|
|
@@ -941,11 +950,17 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
941
950
|
const original = Reflect.get(instanceTarget, prop, instanceTarget);
|
|
942
951
|
if (harnessAgent && typeof original === "function") {
|
|
943
952
|
switch (prop) {
|
|
953
|
+
case "createSession":
|
|
954
|
+
return wrapHarnessAgentCreateSession(
|
|
955
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
956
|
+
original,
|
|
957
|
+
harnessAgent
|
|
958
|
+
);
|
|
944
959
|
case "generate":
|
|
945
960
|
return wrapHarnessAgentGenerate(
|
|
946
961
|
original,
|
|
947
962
|
harnessAgent,
|
|
948
|
-
|
|
963
|
+
_chunkVYNNEKSAjs.harnessAgentChannels.generate,
|
|
949
964
|
"HarnessAgent.generate",
|
|
950
965
|
options
|
|
951
966
|
);
|
|
@@ -953,7 +968,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
953
968
|
return wrapHarnessAgentStream(
|
|
954
969
|
original,
|
|
955
970
|
harnessAgent,
|
|
956
|
-
|
|
971
|
+
_chunkVYNNEKSAjs.harnessAgentChannels.stream,
|
|
957
972
|
"HarnessAgent.stream",
|
|
958
973
|
options
|
|
959
974
|
);
|
|
@@ -961,7 +976,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
961
976
|
return wrapHarnessAgentGenerate(
|
|
962
977
|
original,
|
|
963
978
|
harnessAgent,
|
|
964
|
-
|
|
979
|
+
_chunkVYNNEKSAjs.harnessAgentChannels.continueGenerate,
|
|
965
980
|
"HarnessAgent.continueGenerate",
|
|
966
981
|
options
|
|
967
982
|
);
|
|
@@ -969,7 +984,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
969
984
|
return wrapHarnessAgentStream(
|
|
970
985
|
original,
|
|
971
986
|
harnessAgent,
|
|
972
|
-
|
|
987
|
+
_chunkVYNNEKSAjs.harnessAgentChannels.continueStream,
|
|
973
988
|
"HarnessAgent.continueStream",
|
|
974
989
|
options
|
|
975
990
|
);
|
|
@@ -990,6 +1005,19 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
990
1005
|
}
|
|
991
1006
|
});
|
|
992
1007
|
};
|
|
1008
|
+
var wrapHarnessAgentCreateSession = (createSession, instance) => {
|
|
1009
|
+
const wrapper = function(params) {
|
|
1010
|
+
return _chunkVYNNEKSAjs.harnessAgentChannels.createSession.tracePromise(
|
|
1011
|
+
() => params === void 0 ? createSession.call(instance) : createSession.call(instance, params),
|
|
1012
|
+
createAISDKChannelContext(_nullishCoalesce(params, () => ( {})), { self: instance })
|
|
1013
|
+
);
|
|
1014
|
+
};
|
|
1015
|
+
Object.defineProperty(wrapper, "name", {
|
|
1016
|
+
value: "HarnessAgent.createSession",
|
|
1017
|
+
writable: false
|
|
1018
|
+
});
|
|
1019
|
+
return wrapper;
|
|
1020
|
+
};
|
|
993
1021
|
var wrapHarnessAgentGenerate = (generate, instance, channel, name, options) => makeGenerateTextWrapper(
|
|
994
1022
|
channel,
|
|
995
1023
|
name,
|
|
@@ -1025,15 +1053,15 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
1025
1053
|
};
|
|
1026
1054
|
function generateChannelForAgent(agentName) {
|
|
1027
1055
|
if (agentName === "ToolLoopAgent") {
|
|
1028
|
-
return
|
|
1056
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
1029
1057
|
}
|
|
1030
|
-
return
|
|
1058
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.agentGenerate;
|
|
1031
1059
|
}
|
|
1032
1060
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
1033
1061
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
1034
1062
|
return (params) => {
|
|
1035
1063
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
1036
|
-
if (workflowAgent &&
|
|
1064
|
+
if (workflowAgent && _chunkVRZZQPAAjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
1037
1065
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
1038
1066
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
1039
1067
|
}
|
|
@@ -1052,12 +1080,12 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
1052
1080
|
};
|
|
1053
1081
|
function streamChannelForAgent(agentName) {
|
|
1054
1082
|
if (agentName === "ToolLoopAgent") {
|
|
1055
|
-
return
|
|
1083
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.toolLoopAgentStream;
|
|
1056
1084
|
}
|
|
1057
1085
|
if (agentName === "WorkflowAgent") {
|
|
1058
|
-
return
|
|
1086
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.workflowAgentStream;
|
|
1059
1087
|
}
|
|
1060
|
-
return
|
|
1088
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.agentStream;
|
|
1061
1089
|
}
|
|
1062
1090
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
1063
1091
|
const wrapper = async function(allParams) {
|
|
@@ -1081,7 +1109,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
1081
1109
|
};
|
|
1082
1110
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
1083
1111
|
return makeGenerateTextWrapper(
|
|
1084
|
-
|
|
1112
|
+
_chunkVYNNEKSAjs.aiSDKChannels.generateText,
|
|
1085
1113
|
"generateText",
|
|
1086
1114
|
generateText,
|
|
1087
1115
|
{ aiSDK },
|
|
@@ -1090,7 +1118,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
1090
1118
|
};
|
|
1091
1119
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
1092
1120
|
return makeGenerateTextWrapper(
|
|
1093
|
-
|
|
1121
|
+
_chunkVYNNEKSAjs.aiSDKChannels.generateObject,
|
|
1094
1122
|
"generateObject",
|
|
1095
1123
|
generateObject,
|
|
1096
1124
|
{ aiSDK },
|
|
@@ -1119,7 +1147,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
1119
1147
|
};
|
|
1120
1148
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
1121
1149
|
return makeEmbedWrapper(
|
|
1122
|
-
|
|
1150
|
+
_chunkVYNNEKSAjs.aiSDKChannels.embed,
|
|
1123
1151
|
"embed",
|
|
1124
1152
|
embed,
|
|
1125
1153
|
{ aiSDK },
|
|
@@ -1128,7 +1156,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1128
1156
|
};
|
|
1129
1157
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1130
1158
|
return makeEmbedWrapper(
|
|
1131
|
-
|
|
1159
|
+
_chunkVYNNEKSAjs.aiSDKChannels.embedMany,
|
|
1132
1160
|
"embedMany",
|
|
1133
1161
|
embedMany,
|
|
1134
1162
|
{ aiSDK },
|
|
@@ -1139,7 +1167,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1139
1167
|
const wrapper = async function(allParams) {
|
|
1140
1168
|
const { span_info, ...params } = allParams;
|
|
1141
1169
|
const tracedParams = { ...params };
|
|
1142
|
-
return
|
|
1170
|
+
return _chunkVYNNEKSAjs.aiSDKChannels.rerank.tracePromise(
|
|
1143
1171
|
() => rerank(tracedParams),
|
|
1144
1172
|
createAISDKChannelContext(tracedParams, {
|
|
1145
1173
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1178,7 +1206,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1178
1206
|
};
|
|
1179
1207
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1180
1208
|
return makeStreamWrapper(
|
|
1181
|
-
|
|
1209
|
+
_chunkVYNNEKSAjs.aiSDKChannels.streamText,
|
|
1182
1210
|
"streamText",
|
|
1183
1211
|
streamText,
|
|
1184
1212
|
{ aiSDK },
|
|
@@ -1187,7 +1215,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1187
1215
|
};
|
|
1188
1216
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1189
1217
|
return makeStreamWrapper(
|
|
1190
|
-
|
|
1218
|
+
_chunkVYNNEKSAjs.aiSDKChannels.streamObject,
|
|
1191
1219
|
"streamObject",
|
|
1192
1220
|
streamObject,
|
|
1193
1221
|
{ aiSDK },
|
|
@@ -1259,14 +1287,19 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1259
1287
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1260
1288
|
// propagate those via async local storage
|
|
1261
1289
|
async doGenerate(options) {
|
|
1262
|
-
const span =
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1290
|
+
const span = _chunkVRZZQPAAjs.startSpan.call(void 0,
|
|
1291
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0,
|
|
1292
|
+
{
|
|
1293
|
+
name: "Chat Completion",
|
|
1294
|
+
spanAttributes: {
|
|
1295
|
+
type: "llm"
|
|
1296
|
+
}
|
|
1297
|
+
},
|
|
1298
|
+
_chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1299
|
+
)
|
|
1300
|
+
);
|
|
1268
1301
|
const { prompt, mode, ...rest } = options;
|
|
1269
|
-
const startTime =
|
|
1302
|
+
const startTime = _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1270
1303
|
try {
|
|
1271
1304
|
const ret = await this.model.doGenerate(options);
|
|
1272
1305
|
span.log({
|
|
@@ -1278,12 +1311,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1278
1311
|
},
|
|
1279
1312
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1280
1313
|
metrics: {
|
|
1281
|
-
time_to_first_token:
|
|
1282
|
-
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,
|
|
1283
1316
|
prompt_tokens: _optionalChain([ret, 'access', _26 => _26.usage, 'optionalAccess', _27 => _27.promptTokens]),
|
|
1284
1317
|
completion_tokens: _optionalChain([ret, 'access', _28 => _28.usage, 'optionalAccess', _29 => _29.completionTokens]),
|
|
1285
|
-
cached:
|
|
1286
|
-
_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]])))
|
|
1287
1320
|
)
|
|
1288
1321
|
}
|
|
1289
1322
|
});
|
|
@@ -1294,13 +1327,18 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1294
1327
|
}
|
|
1295
1328
|
async doStream(options) {
|
|
1296
1329
|
const { prompt, mode, ...rest } = options;
|
|
1297
|
-
const startTime =
|
|
1298
|
-
const span =
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1330
|
+
const startTime = _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1331
|
+
const span = _chunkVRZZQPAAjs.startSpan.call(void 0,
|
|
1332
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0,
|
|
1333
|
+
{
|
|
1334
|
+
name: "Chat Completion",
|
|
1335
|
+
spanAttributes: {
|
|
1336
|
+
type: "llm"
|
|
1337
|
+
}
|
|
1338
|
+
},
|
|
1339
|
+
_chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1340
|
+
)
|
|
1341
|
+
);
|
|
1304
1342
|
span.log({
|
|
1305
1343
|
input: postProcessPrompt(prompt),
|
|
1306
1344
|
metadata: {
|
|
@@ -1329,7 +1367,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1329
1367
|
new TransformStream({
|
|
1330
1368
|
transform(chunk, controller) {
|
|
1331
1369
|
if (time_to_first_token === void 0) {
|
|
1332
|
-
time_to_first_token =
|
|
1370
|
+
time_to_first_token = _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1333
1371
|
span.log({ metrics: { time_to_first_token } });
|
|
1334
1372
|
}
|
|
1335
1373
|
switch (chunk.type) {
|
|
@@ -1374,11 +1412,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1374
1412
|
),
|
|
1375
1413
|
metrics: {
|
|
1376
1414
|
time_to_first_token,
|
|
1377
|
-
tokens: !
|
|
1415
|
+
tokens: !_chunkVRZZQPAAjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1378
1416
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _36 => _36.promptTokens]),
|
|
1379
1417
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _37 => _37.completionTokens]),
|
|
1380
|
-
cached:
|
|
1381
|
-
_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]])))
|
|
1382
1420
|
)
|
|
1383
1421
|
}
|
|
1384
1422
|
});
|
|
@@ -1563,12 +1601,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1563
1601
|
anthropicMetadata.usage,
|
|
1564
1602
|
"cache_creation_input_tokens"
|
|
1565
1603
|
) || 0;
|
|
1566
|
-
const cacheTokens =
|
|
1604
|
+
const cacheTokens = _chunkVRZZQPAAjs.extractAnthropicCacheTokens.call(void 0,
|
|
1567
1605
|
cacheReadTokens,
|
|
1568
1606
|
cacheCreationTokens
|
|
1569
1607
|
);
|
|
1570
1608
|
Object.assign(metrics, cacheTokens);
|
|
1571
|
-
Object.assign(metrics,
|
|
1609
|
+
Object.assign(metrics, _chunkVRZZQPAAjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1572
1610
|
}
|
|
1573
1611
|
}
|
|
1574
1612
|
return metrics;
|
|
@@ -1640,7 +1678,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1640
1678
|
model: modelFromWrapGenerate
|
|
1641
1679
|
}) => {
|
|
1642
1680
|
const rawInput = extractInput(params);
|
|
1643
|
-
const processedInput =
|
|
1681
|
+
const processedInput = _chunkVRZZQPAAjs.processInputAttachments.call(void 0, rawInput);
|
|
1644
1682
|
const spanArgs = {
|
|
1645
1683
|
name: _optionalChain([config, 'access', _60 => _60.spanInfo, 'optionalAccess', _61 => _61.name]) || "ai-sdk.doGenerate",
|
|
1646
1684
|
spanAttributes: {
|
|
@@ -1655,7 +1693,9 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1655
1693
|
}
|
|
1656
1694
|
}
|
|
1657
1695
|
};
|
|
1658
|
-
const span =
|
|
1696
|
+
const span = _chunkVRZZQPAAjs.startSpan.call(void 0,
|
|
1697
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1698
|
+
);
|
|
1659
1699
|
try {
|
|
1660
1700
|
const result = await doGenerate();
|
|
1661
1701
|
const metadata = {};
|
|
@@ -1702,7 +1742,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1702
1742
|
},
|
|
1703
1743
|
wrapStream: async ({ doStream, params }) => {
|
|
1704
1744
|
const rawInput = extractInput(params);
|
|
1705
|
-
const processedInput =
|
|
1745
|
+
const processedInput = _chunkVRZZQPAAjs.processInputAttachments.call(void 0, rawInput);
|
|
1706
1746
|
const spanArgs = {
|
|
1707
1747
|
name: _optionalChain([config, 'access', _69 => _69.spanInfo, 'optionalAccess', _70 => _70.name]) || "ai-sdk.doStream",
|
|
1708
1748
|
spanAttributes: {
|
|
@@ -1717,7 +1757,9 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1717
1757
|
}
|
|
1718
1758
|
}
|
|
1719
1759
|
};
|
|
1720
|
-
const span =
|
|
1760
|
+
const span = _chunkVRZZQPAAjs.startSpan.call(void 0,
|
|
1761
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1762
|
+
);
|
|
1721
1763
|
try {
|
|
1722
1764
|
const { stream, ...rest } = await doStream();
|
|
1723
1765
|
const textChunks = [];
|
|
@@ -1841,7 +1883,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1841
1883
|
try {
|
|
1842
1884
|
captureEveModelInput(state, input);
|
|
1843
1885
|
} catch (error) {
|
|
1844
|
-
|
|
1886
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1845
1887
|
}
|
|
1846
1888
|
}
|
|
1847
1889
|
},
|
|
@@ -1851,7 +1893,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1851
1893
|
};
|
|
1852
1894
|
}
|
|
1853
1895
|
function isEveHandleMessageStreamEvent(event) {
|
|
1854
|
-
return
|
|
1896
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1855
1897
|
}
|
|
1856
1898
|
var ResumedEveSpan = class {
|
|
1857
1899
|
constructor(reference) {
|
|
@@ -1872,7 +1914,7 @@ var ResumedEveSpan = class {
|
|
|
1872
1914
|
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1873
1915
|
...event.metrics
|
|
1874
1916
|
};
|
|
1875
|
-
|
|
1917
|
+
_chunkVRZZQPAAjs.updateSpan.call(void 0, {
|
|
1876
1918
|
exported: this.reference.exported,
|
|
1877
1919
|
...this.reference.startEvent,
|
|
1878
1920
|
...event,
|
|
@@ -1881,7 +1923,7 @@ var ResumedEveSpan = class {
|
|
|
1881
1923
|
}
|
|
1882
1924
|
end(args) {
|
|
1883
1925
|
if (this.endTime === void 0) {
|
|
1884
|
-
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => (
|
|
1926
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => ( _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1885
1927
|
this.log({ metrics: { end: this.endTime } });
|
|
1886
1928
|
}
|
|
1887
1929
|
return this.endTime;
|
|
@@ -1893,13 +1935,13 @@ var EveBridge = (_class = class {
|
|
|
1893
1935
|
}
|
|
1894
1936
|
|
|
1895
1937
|
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1896
|
-
__init2() {this.completedToolKeys = new (0,
|
|
1938
|
+
__init2() {this.completedToolKeys = new (0, _chunkVRZZQPAAjs.LRUCache)({
|
|
1897
1939
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1898
1940
|
})}
|
|
1899
|
-
__init3() {this.toolsByCallKey = new (0,
|
|
1941
|
+
__init3() {this.toolsByCallKey = new (0, _chunkVRZZQPAAjs.LRUCache)({
|
|
1900
1942
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1901
1943
|
})}
|
|
1902
|
-
__init4() {this.turnsByKey = new (0,
|
|
1944
|
+
__init4() {this.turnsByKey = new (0, _chunkVRZZQPAAjs.LRUCache)({
|
|
1903
1945
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1904
1946
|
})}
|
|
1905
1947
|
async startEveSpan(args) {
|
|
@@ -1910,7 +1952,7 @@ var EveBridge = (_class = class {
|
|
|
1910
1952
|
if (reference) {
|
|
1911
1953
|
return new ResumedEveSpan(reference);
|
|
1912
1954
|
}
|
|
1913
|
-
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => (
|
|
1955
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => ( _chunkVRZZQPAAjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1914
1956
|
const parentSpanIds = _optionalChain([args, 'optionalAccess', _82 => _82.parentSpanIds]);
|
|
1915
1957
|
const startEvent = {
|
|
1916
1958
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1922,9 +1964,14 @@ var EveBridge = (_class = class {
|
|
|
1922
1964
|
},
|
|
1923
1965
|
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
1924
1966
|
};
|
|
1925
|
-
const span =
|
|
1926
|
-
|
|
1927
|
-
() =>
|
|
1967
|
+
const span = _chunkVRZZQPAAjs.withCurrent.call(void 0,
|
|
1968
|
+
_chunkVRZZQPAAjs.NOOP_SPAN,
|
|
1969
|
+
() => _chunkVRZZQPAAjs._internalStartSpanWithInitialMerge.call(void 0,
|
|
1970
|
+
_chunkVYNNEKSAjs.withSpanInstrumentationName.call(void 0,
|
|
1971
|
+
{ ...args, startTime },
|
|
1972
|
+
_chunkVYNNEKSAjs.INSTRUMENTATION_NAMES.EVE
|
|
1973
|
+
)
|
|
1974
|
+
)
|
|
1928
1975
|
);
|
|
1929
1976
|
if (typeof rowId !== "string") {
|
|
1930
1977
|
return span;
|
|
@@ -1950,7 +1997,7 @@ var EveBridge = (_class = class {
|
|
|
1950
1997
|
};
|
|
1951
1998
|
});
|
|
1952
1999
|
} catch (error) {
|
|
1953
|
-
|
|
2000
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
1954
2001
|
}
|
|
1955
2002
|
return span;
|
|
1956
2003
|
}
|
|
@@ -2037,7 +2084,7 @@ var EveBridge = (_class = class {
|
|
|
2037
2084
|
}
|
|
2038
2085
|
}
|
|
2039
2086
|
} catch (error) {
|
|
2040
|
-
|
|
2087
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
2041
2088
|
}
|
|
2042
2089
|
};
|
|
2043
2090
|
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
@@ -2265,7 +2312,7 @@ var EveBridge = (_class = class {
|
|
|
2265
2312
|
return;
|
|
2266
2313
|
}
|
|
2267
2314
|
const existingMessage = eveOutputMessage(step.output);
|
|
2268
|
-
const existingToolCalls =
|
|
2315
|
+
const existingToolCalls = _chunkVRZZQPAAjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2269
2316
|
step.output = mergeEveReasoning(
|
|
2270
2317
|
[
|
|
2271
2318
|
{
|
|
@@ -2329,11 +2376,11 @@ var EveBridge = (_class = class {
|
|
|
2329
2376
|
return;
|
|
2330
2377
|
}
|
|
2331
2378
|
const toolCallsById = /* @__PURE__ */ new Map();
|
|
2332
|
-
if (Array.isArray(step.output) &&
|
|
2379
|
+
if (Array.isArray(step.output) && _chunkVRZZQPAAjs.isObject.call(void 0, step.output[0])) {
|
|
2333
2380
|
const message = step.output[0]["message"];
|
|
2334
|
-
if (
|
|
2381
|
+
if (_chunkVRZZQPAAjs.isObject.call(void 0, message) && Array.isArray(message["tool_calls"])) {
|
|
2335
2382
|
for (const toolCall of message["tool_calls"]) {
|
|
2336
|
-
if (
|
|
2383
|
+
if (_chunkVRZZQPAAjs.isObject.call(void 0, toolCall) && typeof toolCall["id"] === "string") {
|
|
2337
2384
|
toolCallsById.set(toolCall["id"], toolCall);
|
|
2338
2385
|
}
|
|
2339
2386
|
}
|
|
@@ -2542,7 +2589,7 @@ var EveBridge = (_class = class {
|
|
|
2542
2589
|
};
|
|
2543
2590
|
step.metrics = { ...step.metrics, ...metrics };
|
|
2544
2591
|
const sessionId = sessionIdFromContext(ctx);
|
|
2545
|
-
if (Array.isArray(step.output) &&
|
|
2592
|
+
if (Array.isArray(step.output) && _chunkVRZZQPAAjs.isObject.call(void 0, step.output[0])) {
|
|
2546
2593
|
const finishReason = step.output[0].finish_reason;
|
|
2547
2594
|
if (typeof finishReason !== "string") {
|
|
2548
2595
|
step.output[0].finish_reason = normalizedFinishReason(
|
|
@@ -2880,10 +2927,10 @@ var EveBridge = (_class = class {
|
|
|
2880
2927
|
return state;
|
|
2881
2928
|
}
|
|
2882
2929
|
async startTurnSpan(sessionId, event, ctx, metadata) {
|
|
2883
|
-
const session =
|
|
2884
|
-
const parent =
|
|
2885
|
-
const parentTurn =
|
|
2886
|
-
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" ? {
|
|
2887
2934
|
callId: parent["callId"],
|
|
2888
2935
|
sessionId: parent["sessionId"],
|
|
2889
2936
|
turnId: parentTurn["id"]
|
|
@@ -2990,10 +3037,10 @@ var EveBridge = (_class = class {
|
|
|
2990
3037
|
}
|
|
2991
3038
|
async flushInstrumentation() {
|
|
2992
3039
|
try {
|
|
2993
|
-
await
|
|
3040
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, );
|
|
2994
3041
|
return true;
|
|
2995
3042
|
} catch (error) {
|
|
2996
|
-
|
|
3043
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
2997
3044
|
return false;
|
|
2998
3045
|
}
|
|
2999
3046
|
}
|
|
@@ -3008,12 +3055,12 @@ function emptyEveTraceState() {
|
|
|
3008
3055
|
};
|
|
3009
3056
|
}
|
|
3010
3057
|
function normalizeEveTraceState(state) {
|
|
3011
|
-
if (!
|
|
3058
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, state)) {
|
|
3012
3059
|
return emptyEveTraceState();
|
|
3013
3060
|
}
|
|
3014
|
-
const metadata =
|
|
3061
|
+
const metadata = _chunkVRZZQPAAjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
3015
3062
|
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
3016
|
-
if (!
|
|
3063
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, entry)) {
|
|
3017
3064
|
return [];
|
|
3018
3065
|
}
|
|
3019
3066
|
const exported = entry["exported"];
|
|
@@ -3022,11 +3069,11 @@ function normalizeEveTraceState(state) {
|
|
|
3022
3069
|
const rowId = entry["rowId"];
|
|
3023
3070
|
const spanId = entry["spanId"];
|
|
3024
3071
|
const startEvent = entry["startEvent"];
|
|
3025
|
-
const startEventCreated =
|
|
3026
|
-
const startEventMetrics =
|
|
3027
|
-
const startEventSpanAttributes =
|
|
3028
|
-
const startEventSpanParents =
|
|
3029
|
-
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(
|
|
3030
3077
|
(parent) => typeof parent === "string"
|
|
3031
3078
|
) ? {
|
|
3032
3079
|
created: startEventCreated,
|
|
@@ -3046,7 +3093,7 @@ function normalizeEveTraceState(state) {
|
|
|
3046
3093
|
] : [];
|
|
3047
3094
|
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
3048
3095
|
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
3049
|
-
if (!
|
|
3096
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, entry)) {
|
|
3050
3097
|
return [];
|
|
3051
3098
|
}
|
|
3052
3099
|
const key = entry["key"];
|
|
@@ -3054,7 +3101,7 @@ function normalizeEveTraceState(state) {
|
|
|
3054
3101
|
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
3055
3102
|
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
3056
3103
|
const reasoningBlocks = Array.isArray(state["reasoningBlocks"]) ? state["reasoningBlocks"].flatMap((entry) => {
|
|
3057
|
-
if (!
|
|
3104
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, entry)) {
|
|
3058
3105
|
return [];
|
|
3059
3106
|
}
|
|
3060
3107
|
const content = entry["content"];
|
|
@@ -3069,7 +3116,7 @@ function normalizeEveTraceState(state) {
|
|
|
3069
3116
|
] : [];
|
|
3070
3117
|
}).slice(-MAX_STORED_REASONING_BLOCKS) : [];
|
|
3071
3118
|
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
3072
|
-
if (!
|
|
3119
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, entry)) {
|
|
3073
3120
|
return [];
|
|
3074
3121
|
}
|
|
3075
3122
|
const ordinal = entry["ordinal"];
|
|
@@ -3146,14 +3193,14 @@ function clearStoredEveReasoning(state, sessionId, turnId, stepIndex) {
|
|
|
3146
3193
|
});
|
|
3147
3194
|
}
|
|
3148
3195
|
function eveOutputMessage(output) {
|
|
3149
|
-
return Array.isArray(output) &&
|
|
3196
|
+
return Array.isArray(output) && _chunkVRZZQPAAjs.isObject.call(void 0, output[0]) ? output[0]["message"] : void 0;
|
|
3150
3197
|
}
|
|
3151
3198
|
function mergeEveReasoning(output, reasoning) {
|
|
3152
3199
|
if (reasoning.length === 0) {
|
|
3153
3200
|
return output;
|
|
3154
3201
|
}
|
|
3155
|
-
const choice = Array.isArray(output) &&
|
|
3156
|
-
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"] : {};
|
|
3157
3204
|
return [
|
|
3158
3205
|
{
|
|
3159
3206
|
...choice,
|
|
@@ -3207,7 +3254,7 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3207
3254
|
});
|
|
3208
3255
|
return input;
|
|
3209
3256
|
} catch (error) {
|
|
3210
|
-
|
|
3257
|
+
_chunkVRZZQPAAjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
3211
3258
|
return void 0;
|
|
3212
3259
|
}
|
|
3213
3260
|
}
|
|
@@ -3345,14 +3392,14 @@ function capturedEveModelContentPart(part) {
|
|
|
3345
3392
|
}
|
|
3346
3393
|
function isCapturedModelInput(input) {
|
|
3347
3394
|
return Array.isArray(input) && input.every(
|
|
3348
|
-
(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))
|
|
3349
3396
|
);
|
|
3350
3397
|
}
|
|
3351
3398
|
function llmInputKey(sessionId, turnId, stepIndex) {
|
|
3352
3399
|
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3353
3400
|
}
|
|
3354
3401
|
function modelMetadataFromRuntime(runtime) {
|
|
3355
|
-
if (!
|
|
3402
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, runtime)) {
|
|
3356
3403
|
return {};
|
|
3357
3404
|
}
|
|
3358
3405
|
const modelId = runtime["modelId"];
|
|
@@ -3375,11 +3422,11 @@ function modelMetadataFromModelId(modelId) {
|
|
|
3375
3422
|
};
|
|
3376
3423
|
}
|
|
3377
3424
|
function sessionIdFromContext(ctx) {
|
|
3378
|
-
if (!
|
|
3425
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, ctx)) {
|
|
3379
3426
|
return void 0;
|
|
3380
3427
|
}
|
|
3381
3428
|
const session = ctx["session"];
|
|
3382
|
-
if (!
|
|
3429
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, session)) {
|
|
3383
3430
|
return void 0;
|
|
3384
3431
|
}
|
|
3385
3432
|
const id = session["id"];
|
|
@@ -3390,19 +3437,19 @@ function toolMetadataFromTurn(turn) {
|
|
|
3390
3437
|
return metadata;
|
|
3391
3438
|
}
|
|
3392
3439
|
function isToolCallAction(action) {
|
|
3393
|
-
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"]);
|
|
3394
3441
|
}
|
|
3395
3442
|
function isLocalSubagentCallAction(action) {
|
|
3396
|
-
return
|
|
3443
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkVRZZQPAAjs.isObject.call(void 0, action["input"]);
|
|
3397
3444
|
}
|
|
3398
3445
|
function isTraceableActionRequest(action) {
|
|
3399
3446
|
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3400
3447
|
}
|
|
3401
3448
|
function isToolResult(result) {
|
|
3402
|
-
return
|
|
3449
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3403
3450
|
}
|
|
3404
3451
|
function isSubagentResult(result) {
|
|
3405
|
-
return
|
|
3452
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3406
3453
|
}
|
|
3407
3454
|
function normalizedFinishReason(finishReason) {
|
|
3408
3455
|
switch (finishReason) {
|
|
@@ -3502,7 +3549,7 @@ function messagesProxy(messages) {
|
|
|
3502
3549
|
return new Proxy(messages, {
|
|
3503
3550
|
get(target, prop, receiver) {
|
|
3504
3551
|
if (prop === "create") {
|
|
3505
|
-
return createProxy(target.create,
|
|
3552
|
+
return createProxy(target.create, _chunkVYNNEKSAjs.anthropicChannels.messagesCreate);
|
|
3506
3553
|
}
|
|
3507
3554
|
return Reflect.get(target, prop, receiver);
|
|
3508
3555
|
}
|
|
@@ -3512,7 +3559,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3512
3559
|
return new Proxy(messages, {
|
|
3513
3560
|
get(target, prop, receiver) {
|
|
3514
3561
|
if (prop === "create") {
|
|
3515
|
-
return createProxy(target.create,
|
|
3562
|
+
return createProxy(target.create, _chunkVYNNEKSAjs.anthropicChannels.betaMessagesCreate);
|
|
3516
3563
|
}
|
|
3517
3564
|
if (prop === "toolRunner") {
|
|
3518
3565
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -3521,7 +3568,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3521
3568
|
return toolRunnerProxy(
|
|
3522
3569
|
target.toolRunner,
|
|
3523
3570
|
anthropic,
|
|
3524
|
-
|
|
3571
|
+
_chunkVYNNEKSAjs.anthropicChannels.betaMessagesToolRunner
|
|
3525
3572
|
);
|
|
3526
3573
|
}
|
|
3527
3574
|
return Reflect.get(target, prop, receiver);
|
|
@@ -3578,11 +3625,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
3578
3625
|
...params,
|
|
3579
3626
|
options: {
|
|
3580
3627
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
3581
|
-
[
|
|
3628
|
+
[_chunkVRZZQPAAjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
3582
3629
|
}
|
|
3583
3630
|
};
|
|
3584
3631
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3585
|
-
return
|
|
3632
|
+
return _chunkVYNNEKSAjs.claudeAgentSDKChannels.query.traceSync(
|
|
3586
3633
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
3587
3634
|
// The channel carries no extra context fields, but the generated
|
|
3588
3635
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -3610,7 +3657,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
3610
3657
|
}
|
|
3611
3658
|
const localToolMetadata = { toolName };
|
|
3612
3659
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
3613
|
-
wrappedArgs[handlerIndex] =
|
|
3660
|
+
wrappedArgs[handlerIndex] = _chunkVRZZQPAAjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
3614
3661
|
originalHandler,
|
|
3615
3662
|
() => localToolMetadata
|
|
3616
3663
|
);
|
|
@@ -3793,7 +3840,7 @@ function wrapCodexThread(thread) {
|
|
|
3793
3840
|
if (prop === "run" && typeof value === "function") {
|
|
3794
3841
|
return function(input, turnOptions) {
|
|
3795
3842
|
const args = [input, turnOptions];
|
|
3796
|
-
return
|
|
3843
|
+
return _chunkVYNNEKSAjs.openAICodexChannels.run.tracePromise(
|
|
3797
3844
|
() => Reflect.apply(value, target, args),
|
|
3798
3845
|
{
|
|
3799
3846
|
arguments: args,
|
|
@@ -3806,7 +3853,7 @@ function wrapCodexThread(thread) {
|
|
|
3806
3853
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
3807
3854
|
return function(input, turnOptions) {
|
|
3808
3855
|
const args = [input, turnOptions];
|
|
3809
|
-
return
|
|
3856
|
+
return _chunkVYNNEKSAjs.openAICodexChannels.runStreamed.tracePromise(
|
|
3810
3857
|
() => Reflect.apply(value, target, args),
|
|
3811
3858
|
{
|
|
3812
3859
|
arguments: args,
|
|
@@ -3874,7 +3921,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3874
3921
|
if (prop === "create" && typeof value === "function") {
|
|
3875
3922
|
const wrapped = async function(options) {
|
|
3876
3923
|
const args = [options];
|
|
3877
|
-
return
|
|
3924
|
+
return _chunkVYNNEKSAjs.cursorSDKChannels.create.tracePromise(
|
|
3878
3925
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
3879
3926
|
{ arguments: args }
|
|
3880
3927
|
);
|
|
@@ -3885,7 +3932,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3885
3932
|
if (prop === "resume" && typeof value === "function") {
|
|
3886
3933
|
const wrapped = async function(agentId, options) {
|
|
3887
3934
|
const args = [agentId, options];
|
|
3888
|
-
return
|
|
3935
|
+
return _chunkVYNNEKSAjs.cursorSDKChannels.resume.tracePromise(
|
|
3889
3936
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
3890
3937
|
{ arguments: args }
|
|
3891
3938
|
);
|
|
@@ -3896,7 +3943,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3896
3943
|
if (prop === "prompt" && typeof value === "function") {
|
|
3897
3944
|
const wrapped = async function(message, options) {
|
|
3898
3945
|
const args = [message, options];
|
|
3899
|
-
return
|
|
3946
|
+
return _chunkVYNNEKSAjs.cursorSDKChannels.prompt.tracePromise(
|
|
3900
3947
|
() => Reflect.apply(value, target, args),
|
|
3901
3948
|
{ arguments: args }
|
|
3902
3949
|
);
|
|
@@ -3929,7 +3976,7 @@ function wrapCursorAgent(agent) {
|
|
|
3929
3976
|
if (prop === "send" && typeof value === "function") {
|
|
3930
3977
|
return function(message, options) {
|
|
3931
3978
|
const args = [message, options];
|
|
3932
|
-
return
|
|
3979
|
+
return _chunkVYNNEKSAjs.cursorSDKChannels.send.tracePromise(
|
|
3933
3980
|
() => Reflect.apply(value, target, args),
|
|
3934
3981
|
{
|
|
3935
3982
|
agent: target,
|
|
@@ -3979,7 +4026,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
3979
4026
|
...descriptor,
|
|
3980
4027
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
3981
4028
|
const args = [text, options];
|
|
3982
|
-
return
|
|
4029
|
+
return _chunkVYNNEKSAjs.piCodingAgentChannels.prompt.tracePromise(
|
|
3983
4030
|
() => Reflect.apply(originalPrompt, this, args),
|
|
3984
4031
|
{
|
|
3985
4032
|
arguments: args,
|
|
@@ -3996,6 +4043,67 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
3996
4043
|
});
|
|
3997
4044
|
}
|
|
3998
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
|
+
|
|
3999
4107
|
// src/wrappers/strands-agent-sdk.ts
|
|
4000
4108
|
var WRAPPED_CLASS = /* @__PURE__ */ Symbol.for("braintrust.strands-agent-sdk.wrapped-class");
|
|
4001
4109
|
var WRAPPED_INSTANCE = /* @__PURE__ */ Symbol.for(
|
|
@@ -4099,7 +4207,7 @@ function wrapAgentInstance(agent) {
|
|
|
4099
4207
|
if (prop === "stream" && typeof value === "function") {
|
|
4100
4208
|
return function(args, options) {
|
|
4101
4209
|
const callArgs = [args, options];
|
|
4102
|
-
return
|
|
4210
|
+
return _chunkVYNNEKSAjs.strandsAgentSDKChannels.agentStream.traceSync(
|
|
4103
4211
|
() => Reflect.apply(value, target, callArgs),
|
|
4104
4212
|
{
|
|
4105
4213
|
agent: proxy,
|
|
@@ -4135,7 +4243,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
4135
4243
|
if (prop === "stream" && typeof value === "function") {
|
|
4136
4244
|
return function(input, options) {
|
|
4137
4245
|
const callArgs = [input, options];
|
|
4138
|
-
const channel = kind === "graph" ?
|
|
4246
|
+
const channel = kind === "graph" ? _chunkVYNNEKSAjs.strandsAgentSDKChannels.graphStream : _chunkVYNNEKSAjs.strandsAgentSDKChannels.swarmStream;
|
|
4139
4247
|
return channel.traceSync(
|
|
4140
4248
|
() => Reflect.apply(value, target, callArgs),
|
|
4141
4249
|
{
|
|
@@ -4164,6 +4272,81 @@ async function consumeAsyncGenerator(generator) {
|
|
|
4164
4272
|
return result.value;
|
|
4165
4273
|
}
|
|
4166
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
|
+
|
|
4167
4350
|
// src/wrappers/google-genai.ts
|
|
4168
4351
|
function wrapGoogleGenAI(googleGenAI) {
|
|
4169
4352
|
if (!googleGenAI || typeof googleGenAI !== "object") {
|
|
@@ -4210,7 +4393,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4210
4393
|
}
|
|
4211
4394
|
if (prop === "interactions") {
|
|
4212
4395
|
const interactions = Reflect.get(target, prop, receiver);
|
|
4213
|
-
if (!
|
|
4396
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
4214
4397
|
return interactions;
|
|
4215
4398
|
}
|
|
4216
4399
|
if (interactions !== originalInteractions) {
|
|
@@ -4224,7 +4407,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4224
4407
|
});
|
|
4225
4408
|
}
|
|
4226
4409
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
4227
|
-
if (!
|
|
4410
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
4228
4411
|
return;
|
|
4229
4412
|
}
|
|
4230
4413
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -4257,7 +4440,7 @@ function wrapInteractions(interactions) {
|
|
|
4257
4440
|
}
|
|
4258
4441
|
function wrapGenerateContent(original) {
|
|
4259
4442
|
return function(params) {
|
|
4260
|
-
return
|
|
4443
|
+
return _chunkVYNNEKSAjs.googleGenAIChannels.generateContent.tracePromise(
|
|
4261
4444
|
() => original(params),
|
|
4262
4445
|
{ arguments: [params] }
|
|
4263
4446
|
);
|
|
@@ -4265,7 +4448,7 @@ function wrapGenerateContent(original) {
|
|
|
4265
4448
|
}
|
|
4266
4449
|
function wrapGenerateContentStream(original) {
|
|
4267
4450
|
return function(params) {
|
|
4268
|
-
return
|
|
4451
|
+
return _chunkVYNNEKSAjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
4269
4452
|
() => original(params),
|
|
4270
4453
|
{ arguments: [params] }
|
|
4271
4454
|
);
|
|
@@ -4273,7 +4456,7 @@ function wrapGenerateContentStream(original) {
|
|
|
4273
4456
|
}
|
|
4274
4457
|
function wrapEmbedContent(original) {
|
|
4275
4458
|
return function(params) {
|
|
4276
|
-
return
|
|
4459
|
+
return _chunkVYNNEKSAjs.googleGenAIChannels.embedContent.tracePromise(
|
|
4277
4460
|
() => original(params),
|
|
4278
4461
|
{ arguments: [params] }
|
|
4279
4462
|
);
|
|
@@ -4285,7 +4468,7 @@ function wrapInteractionCreate(original) {
|
|
|
4285
4468
|
return options === void 0 ? original(params) : original(params, options);
|
|
4286
4469
|
}
|
|
4287
4470
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
4288
|
-
return
|
|
4471
|
+
return _chunkVYNNEKSAjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
4289
4472
|
() => options === void 0 ? original(params) : original(params, options),
|
|
4290
4473
|
traceContext
|
|
4291
4474
|
);
|
|
@@ -4346,7 +4529,7 @@ function wrapRunnerInstance(runner) {
|
|
|
4346
4529
|
function wrapRunnerRunAsync(runner) {
|
|
4347
4530
|
const original = runner.runAsync.bind(runner);
|
|
4348
4531
|
return function(params) {
|
|
4349
|
-
return
|
|
4532
|
+
return _chunkVYNNEKSAjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
4350
4533
|
arguments: [params],
|
|
4351
4534
|
self: runner
|
|
4352
4535
|
});
|
|
@@ -4373,7 +4556,7 @@ function wrapAgentInstance2(agent) {
|
|
|
4373
4556
|
function wrapAgentRunAsync(agent) {
|
|
4374
4557
|
const original = agent.runAsync.bind(agent);
|
|
4375
4558
|
return function(parentContext) {
|
|
4376
|
-
return
|
|
4559
|
+
return _chunkVYNNEKSAjs.googleADKChannels.agentRunAsync.traceSync(
|
|
4377
4560
|
() => original(parentContext),
|
|
4378
4561
|
{ arguments: [parentContext], self: agent }
|
|
4379
4562
|
);
|
|
@@ -4400,7 +4583,7 @@ function wrapToolInstance(tool) {
|
|
|
4400
4583
|
function wrapToolRunAsync(tool) {
|
|
4401
4584
|
const original = tool.runAsync.bind(tool);
|
|
4402
4585
|
return function(req) {
|
|
4403
|
-
return
|
|
4586
|
+
return _chunkVYNNEKSAjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
4404
4587
|
arguments: [req],
|
|
4405
4588
|
self: tool
|
|
4406
4589
|
});
|
|
@@ -4512,7 +4695,7 @@ function patchGenkitRegistryLookup(registry) {
|
|
|
4512
4695
|
Object.defineProperty(registry, PATCHED_GENKIT_REGISTRY, {
|
|
4513
4696
|
value: true
|
|
4514
4697
|
});
|
|
4515
|
-
} catch (
|
|
4698
|
+
} catch (e7) {
|
|
4516
4699
|
}
|
|
4517
4700
|
}
|
|
4518
4701
|
function patchGenkitRegistryConstructor(registry) {
|
|
@@ -4543,31 +4726,31 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
4543
4726
|
Object.defineProperty(constructor, PATCHED_GENKIT_REGISTRY_CONSTRUCTOR, {
|
|
4544
4727
|
value: true
|
|
4545
4728
|
});
|
|
4546
|
-
} catch (
|
|
4729
|
+
} catch (e8) {
|
|
4547
4730
|
}
|
|
4548
4731
|
}
|
|
4549
4732
|
function wrapGenerate(generate) {
|
|
4550
|
-
return (input) =>
|
|
4733
|
+
return (input) => _chunkVYNNEKSAjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
4551
4734
|
arguments: [input]
|
|
4552
4735
|
});
|
|
4553
4736
|
}
|
|
4554
4737
|
function wrapGenerateStream(generateStream) {
|
|
4555
|
-
return (input) =>
|
|
4738
|
+
return (input) => _chunkVYNNEKSAjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
4556
4739
|
arguments: [input]
|
|
4557
4740
|
});
|
|
4558
4741
|
}
|
|
4559
4742
|
function wrapEmbed2(embed) {
|
|
4560
|
-
return (params) =>
|
|
4743
|
+
return (params) => _chunkVYNNEKSAjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
4561
4744
|
arguments: [params]
|
|
4562
4745
|
});
|
|
4563
4746
|
}
|
|
4564
4747
|
function wrapEmbedMany2(embedMany) {
|
|
4565
|
-
return (params) =>
|
|
4748
|
+
return (params) => _chunkVYNNEKSAjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
4566
4749
|
arguments: [params]
|
|
4567
4750
|
});
|
|
4568
4751
|
}
|
|
4569
4752
|
function wrapRun(run) {
|
|
4570
|
-
return (name, inputOrFn, maybeFn) =>
|
|
4753
|
+
return (name, inputOrFn, maybeFn) => _chunkVYNNEKSAjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
4571
4754
|
arguments: [name, inputOrFn, maybeFn]
|
|
4572
4755
|
});
|
|
4573
4756
|
}
|
|
@@ -4606,13 +4789,13 @@ function isGenkitAction(value) {
|
|
|
4606
4789
|
return typeof value === "function" && "__action" in value;
|
|
4607
4790
|
}
|
|
4608
4791
|
function traceActionRun(action, run) {
|
|
4609
|
-
return (input, options) =>
|
|
4792
|
+
return (input, options) => _chunkVYNNEKSAjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
4610
4793
|
arguments: [input, options],
|
|
4611
4794
|
self: action
|
|
4612
4795
|
});
|
|
4613
4796
|
}
|
|
4614
4797
|
function traceActionStream(action, stream) {
|
|
4615
|
-
return (input, options) =>
|
|
4798
|
+
return (input, options) => _chunkVYNNEKSAjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
4616
4799
|
arguments: [input, options],
|
|
4617
4800
|
self: action
|
|
4618
4801
|
});
|
|
@@ -4658,10 +4841,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
4658
4841
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
4659
4842
|
}
|
|
4660
4843
|
function hasFunction2(value, methodName) {
|
|
4661
|
-
return
|
|
4844
|
+
return _chunkVRZZQPAAjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
4662
4845
|
}
|
|
4663
4846
|
function isSupportedHuggingFaceModule(value) {
|
|
4664
|
-
if (!
|
|
4847
|
+
if (!_chunkVRZZQPAAjs.isObject.call(void 0, value)) {
|
|
4665
4848
|
return false;
|
|
4666
4849
|
}
|
|
4667
4850
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -4769,14 +4952,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
4769
4952
|
const context = {
|
|
4770
4953
|
arguments: [traceParams]
|
|
4771
4954
|
};
|
|
4772
|
-
return
|
|
4955
|
+
return _chunkVYNNEKSAjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
4773
4956
|
() => original(params, options),
|
|
4774
4957
|
context
|
|
4775
4958
|
);
|
|
4776
4959
|
};
|
|
4777
4960
|
}
|
|
4778
4961
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
4779
|
-
return (params, options) =>
|
|
4962
|
+
return (params, options) => _chunkVYNNEKSAjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
4780
4963
|
() => original(params, options),
|
|
4781
4964
|
{
|
|
4782
4965
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -4789,14 +4972,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
4789
4972
|
const context = {
|
|
4790
4973
|
arguments: [traceParams]
|
|
4791
4974
|
};
|
|
4792
|
-
return
|
|
4975
|
+
return _chunkVYNNEKSAjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
4793
4976
|
() => original(params, options),
|
|
4794
4977
|
context
|
|
4795
4978
|
);
|
|
4796
4979
|
};
|
|
4797
4980
|
}
|
|
4798
4981
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
4799
|
-
return (params, options) =>
|
|
4982
|
+
return (params, options) => _chunkVYNNEKSAjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
4800
4983
|
() => original(params, options),
|
|
4801
4984
|
{
|
|
4802
4985
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -4809,13 +4992,127 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
4809
4992
|
const context = {
|
|
4810
4993
|
arguments: [traceParams]
|
|
4811
4994
|
};
|
|
4812
|
-
return
|
|
4995
|
+
return _chunkVYNNEKSAjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
4813
4996
|
() => original(params, options),
|
|
4814
4997
|
context
|
|
4815
4998
|
);
|
|
4816
4999
|
};
|
|
4817
5000
|
}
|
|
4818
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
|
+
|
|
4819
5116
|
// src/wrappers/openrouter-agent.ts
|
|
4820
5117
|
function wrapOpenRouterAgent(agent) {
|
|
4821
5118
|
const candidate = agent;
|
|
@@ -4856,7 +5153,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
4856
5153
|
const request = cloneCallModelRequest(argArray[0]);
|
|
4857
5154
|
const options = argArray[1];
|
|
4858
5155
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
4859
|
-
return
|
|
5156
|
+
return _chunkVYNNEKSAjs.openRouterAgentChannels.callModel.traceSync(
|
|
4860
5157
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
4861
5158
|
{
|
|
4862
5159
|
arguments: [request]
|
|
@@ -4952,24 +5249,24 @@ function rerankProxy(rerank) {
|
|
|
4952
5249
|
});
|
|
4953
5250
|
}
|
|
4954
5251
|
function wrapChatSend(send) {
|
|
4955
|
-
return (request, options) =>
|
|
5252
|
+
return (request, options) => _chunkVYNNEKSAjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
4956
5253
|
arguments: [request]
|
|
4957
5254
|
});
|
|
4958
5255
|
}
|
|
4959
5256
|
function wrapEmbeddingsGenerate(generate) {
|
|
4960
|
-
return (request, options) =>
|
|
5257
|
+
return (request, options) => _chunkVYNNEKSAjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
4961
5258
|
() => generate(request, options),
|
|
4962
5259
|
{ arguments: [request] }
|
|
4963
5260
|
);
|
|
4964
5261
|
}
|
|
4965
5262
|
function wrapResponsesSend(send) {
|
|
4966
|
-
return (request, options) =>
|
|
5263
|
+
return (request, options) => _chunkVYNNEKSAjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
4967
5264
|
() => send(request, options),
|
|
4968
5265
|
{ arguments: [request] }
|
|
4969
5266
|
);
|
|
4970
5267
|
}
|
|
4971
5268
|
function wrapRerank2(rerank) {
|
|
4972
|
-
return (request, options) =>
|
|
5269
|
+
return (request, options) => _chunkVYNNEKSAjs.openRouterChannels.rerankRerank.tracePromise(
|
|
4973
5270
|
() => rerank(request, options),
|
|
4974
5271
|
{ arguments: [request] }
|
|
4975
5272
|
);
|
|
@@ -4977,7 +5274,7 @@ function wrapRerank2(rerank) {
|
|
|
4977
5274
|
function wrapCallModel2(callModel) {
|
|
4978
5275
|
return (request, options) => {
|
|
4979
5276
|
const tracedRequest = { ...request };
|
|
4980
|
-
return
|
|
5277
|
+
return _chunkVYNNEKSAjs.openRouterChannels.callModel.traceSync(
|
|
4981
5278
|
() => callModel(tracedRequest, options),
|
|
4982
5279
|
{
|
|
4983
5280
|
arguments: [tracedRequest]
|
|
@@ -5110,7 +5407,7 @@ function classifiersProxy(classifiers) {
|
|
|
5110
5407
|
});
|
|
5111
5408
|
}
|
|
5112
5409
|
function wrapChatComplete(complete) {
|
|
5113
|
-
return (request, options) =>
|
|
5410
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.chatComplete.tracePromise(
|
|
5114
5411
|
() => complete(request, options),
|
|
5115
5412
|
{
|
|
5116
5413
|
arguments: [request]
|
|
@@ -5118,52 +5415,52 @@ function wrapChatComplete(complete) {
|
|
|
5118
5415
|
);
|
|
5119
5416
|
}
|
|
5120
5417
|
function wrapChatStream(stream) {
|
|
5121
|
-
return (request, options) =>
|
|
5418
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
5122
5419
|
arguments: [request]
|
|
5123
5420
|
});
|
|
5124
5421
|
}
|
|
5125
5422
|
function wrapEmbeddingsCreate(create) {
|
|
5126
|
-
return (request, options) =>
|
|
5423
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
5127
5424
|
() => create(request, options),
|
|
5128
5425
|
{ arguments: [request] }
|
|
5129
5426
|
);
|
|
5130
5427
|
}
|
|
5131
5428
|
function wrapClassifiersModerate(moderate) {
|
|
5132
|
-
return (request, options) =>
|
|
5429
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.classifiersModerate.tracePromise(
|
|
5133
5430
|
() => moderate(request, options),
|
|
5134
5431
|
{ arguments: [request] }
|
|
5135
5432
|
);
|
|
5136
5433
|
}
|
|
5137
5434
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
5138
|
-
return (request, options) =>
|
|
5435
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
5139
5436
|
() => moderateChat(request, options),
|
|
5140
5437
|
{ arguments: [request] }
|
|
5141
5438
|
);
|
|
5142
5439
|
}
|
|
5143
5440
|
function wrapClassifiersClassify(classify) {
|
|
5144
|
-
return (request, options) =>
|
|
5441
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.classifiersClassify.tracePromise(
|
|
5145
5442
|
() => classify(request, options),
|
|
5146
5443
|
{ arguments: [request] }
|
|
5147
5444
|
);
|
|
5148
5445
|
}
|
|
5149
5446
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
5150
|
-
return (request, options) =>
|
|
5447
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
5151
5448
|
() => classifyChat(request, options),
|
|
5152
5449
|
{ arguments: [request] }
|
|
5153
5450
|
);
|
|
5154
5451
|
}
|
|
5155
5452
|
function wrapFimComplete(complete) {
|
|
5156
|
-
return (request, options) =>
|
|
5453
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
5157
5454
|
arguments: [request]
|
|
5158
5455
|
});
|
|
5159
5456
|
}
|
|
5160
5457
|
function wrapFimStream(stream) {
|
|
5161
|
-
return (request, options) =>
|
|
5458
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
5162
5459
|
arguments: [request]
|
|
5163
5460
|
});
|
|
5164
5461
|
}
|
|
5165
5462
|
function wrapAgentsComplete(complete) {
|
|
5166
|
-
return (request, options) =>
|
|
5463
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.agentsComplete.tracePromise(
|
|
5167
5464
|
() => complete(request, options),
|
|
5168
5465
|
{
|
|
5169
5466
|
arguments: [request]
|
|
@@ -5171,7 +5468,7 @@ function wrapAgentsComplete(complete) {
|
|
|
5171
5468
|
);
|
|
5172
5469
|
}
|
|
5173
5470
|
function wrapAgentsStream(stream) {
|
|
5174
|
-
return (request, options) =>
|
|
5471
|
+
return (request, options) => _chunkVYNNEKSAjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
5175
5472
|
arguments: [request]
|
|
5176
5473
|
});
|
|
5177
5474
|
}
|
|
@@ -5224,22 +5521,22 @@ function cohereProxy(cohere) {
|
|
|
5224
5521
|
return proxy;
|
|
5225
5522
|
}
|
|
5226
5523
|
function wrapChat(chat) {
|
|
5227
|
-
return (request, options) =>
|
|
5524
|
+
return (request, options) => _chunkVYNNEKSAjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
5228
5525
|
arguments: [request]
|
|
5229
5526
|
});
|
|
5230
5527
|
}
|
|
5231
5528
|
function wrapChatStream2(chatStream) {
|
|
5232
|
-
return (request, options) =>
|
|
5529
|
+
return (request, options) => _chunkVYNNEKSAjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
5233
5530
|
arguments: [request]
|
|
5234
5531
|
});
|
|
5235
5532
|
}
|
|
5236
5533
|
function wrapEmbed3(embed) {
|
|
5237
|
-
return (request, options) =>
|
|
5534
|
+
return (request, options) => _chunkVYNNEKSAjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
5238
5535
|
arguments: [request]
|
|
5239
5536
|
});
|
|
5240
5537
|
}
|
|
5241
5538
|
function wrapRerank3(rerank) {
|
|
5242
|
-
return (request, options) =>
|
|
5539
|
+
return (request, options) => _chunkVYNNEKSAjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
5243
5540
|
arguments: [request]
|
|
5244
5541
|
});
|
|
5245
5542
|
}
|
|
@@ -5269,7 +5566,7 @@ function isSupportedGroqClient(value) {
|
|
|
5269
5566
|
}
|
|
5270
5567
|
function groqProxy(groq) {
|
|
5271
5568
|
const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
|
|
5272
|
-
const completionProxy = _optionalChain([groq, 'access',
|
|
5569
|
+
const completionProxy = _optionalChain([groq, 'access', _125 => _125.chat, 'optionalAccess', _126 => _126.completions]) ? new Proxy(groq.chat.completions, {
|
|
5273
5570
|
get(target, prop, receiver) {
|
|
5274
5571
|
if (prop === "create") {
|
|
5275
5572
|
return wrapChatCompletionsCreate(target.create.bind(target));
|
|
@@ -5321,13 +5618,13 @@ function groqProxy(groq) {
|
|
|
5321
5618
|
return topLevelProxy;
|
|
5322
5619
|
}
|
|
5323
5620
|
function wrapChatCompletionsCreate(create) {
|
|
5324
|
-
return (request, options) =>
|
|
5621
|
+
return (request, options) => _chunkVYNNEKSAjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
5325
5622
|
() => create(request, options),
|
|
5326
5623
|
{ arguments: [request] }
|
|
5327
5624
|
);
|
|
5328
5625
|
}
|
|
5329
5626
|
function wrapEmbeddingsCreate2(create) {
|
|
5330
|
-
return (request, options) =>
|
|
5627
|
+
return (request, options) => _chunkVYNNEKSAjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
5331
5628
|
arguments: [request]
|
|
5332
5629
|
});
|
|
5333
5630
|
}
|
|
@@ -5401,16 +5698,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
5401
5698
|
}
|
|
5402
5699
|
function wrapSend(send) {
|
|
5403
5700
|
return (command, optionsOrCb, cb) => {
|
|
5404
|
-
if (
|
|
5701
|
+
if (_chunkVRZZQPAAjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
5405
5702
|
return send(command, optionsOrCb, cb);
|
|
5406
5703
|
}
|
|
5407
|
-
return
|
|
5408
|
-
() =>
|
|
5704
|
+
return _chunkVYNNEKSAjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
5705
|
+
() => _chunkVRZZQPAAjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
5409
5706
|
() => send(command, optionsOrCb)
|
|
5410
5707
|
),
|
|
5411
5708
|
{
|
|
5412
5709
|
arguments: [command, optionsOrCb],
|
|
5413
|
-
span_info:
|
|
5710
|
+
span_info: _chunkVRZZQPAAjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
5414
5711
|
}
|
|
5415
5712
|
);
|
|
5416
5713
|
};
|
|
@@ -5459,13 +5756,13 @@ function copilotClientProxy(client) {
|
|
|
5459
5756
|
return proxy;
|
|
5460
5757
|
}
|
|
5461
5758
|
function wrappedCreateSession(client) {
|
|
5462
|
-
return (config) =>
|
|
5759
|
+
return (config) => _chunkVYNNEKSAjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
5463
5760
|
() => client.createSession(config),
|
|
5464
5761
|
{ arguments: [config] }
|
|
5465
5762
|
);
|
|
5466
5763
|
}
|
|
5467
5764
|
function wrappedResumeSession(client) {
|
|
5468
|
-
return (sessionId, config) =>
|
|
5765
|
+
return (sessionId, config) => _chunkVYNNEKSAjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
5469
5766
|
() => client.resumeSession(sessionId, config),
|
|
5470
5767
|
{ arguments: [sessionId, config] }
|
|
5471
5768
|
);
|
|
@@ -5532,7 +5829,7 @@ function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
|
|
|
5532
5829
|
);
|
|
5533
5830
|
return namespace;
|
|
5534
5831
|
}
|
|
5535
|
-
const target =
|
|
5832
|
+
const target = isModuleNamespace6(namespace) ? Object.setPrototypeOf({}, namespace) : candidate;
|
|
5536
5833
|
const moduleNamespace = target !== candidate;
|
|
5537
5834
|
let wrappedExport;
|
|
5538
5835
|
return new Proxy(target, {
|
|
@@ -5566,11 +5863,11 @@ function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
|
|
|
5566
5863
|
}
|
|
5567
5864
|
});
|
|
5568
5865
|
}
|
|
5569
|
-
function
|
|
5866
|
+
function isModuleNamespace6(value) {
|
|
5570
5867
|
if (!value || typeof value !== "object") {
|
|
5571
5868
|
return false;
|
|
5572
5869
|
}
|
|
5573
|
-
if (_optionalChain([value, 'access',
|
|
5870
|
+
if (_optionalChain([value, 'access', _127 => _127.constructor, 'optionalAccess', _128 => _128.name]) === "Module") {
|
|
5574
5871
|
return true;
|
|
5575
5872
|
}
|
|
5576
5873
|
const firstKey = Object.keys(value)[0];
|
|
@@ -5594,7 +5891,7 @@ function wrapTraceable(traceable2) {
|
|
|
5594
5891
|
apply(target, thisArg, argArray) {
|
|
5595
5892
|
const [fn, rawConfig] = argArray;
|
|
5596
5893
|
const config = rawConfig && typeof rawConfig === "object" ? rawConfig : void 0;
|
|
5597
|
-
const originalOnEnd = _optionalChain([config, 'optionalAccess',
|
|
5894
|
+
const originalOnEnd = _optionalChain([config, 'optionalAccess', _129 => _129.on_end]);
|
|
5598
5895
|
const wrappedConfig = {
|
|
5599
5896
|
...config,
|
|
5600
5897
|
on_end(runTree) {
|
|
@@ -5643,13 +5940,13 @@ function wrapRunTreeInstance(runTree) {
|
|
|
5643
5940
|
wrapped = (...args) => wrapRunTreeInstance(Reflect.apply(value, target, args));
|
|
5644
5941
|
} else if (prop === "postRun") {
|
|
5645
5942
|
const method = value;
|
|
5646
|
-
wrapped = (...args) =>
|
|
5943
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.createRun.tracePromise(
|
|
5647
5944
|
() => Reflect.apply(method, target, args),
|
|
5648
5945
|
{ arguments: [target] }
|
|
5649
5946
|
);
|
|
5650
5947
|
} else if (prop === "patchRun") {
|
|
5651
5948
|
const method = value;
|
|
5652
|
-
wrapped = (...args) =>
|
|
5949
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.updateRun.tracePromise(
|
|
5653
5950
|
() => Reflect.apply(method, target, args),
|
|
5654
5951
|
{
|
|
5655
5952
|
arguments: [
|
|
@@ -5698,19 +5995,19 @@ function wrapClientInstance(client) {
|
|
|
5698
5995
|
let wrapped;
|
|
5699
5996
|
if (prop === "createRun") {
|
|
5700
5997
|
const method = value;
|
|
5701
|
-
wrapped = (...args) =>
|
|
5998
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.createRun.tracePromise(
|
|
5702
5999
|
() => Reflect.apply(method, target, args),
|
|
5703
6000
|
{ arguments: args }
|
|
5704
6001
|
);
|
|
5705
6002
|
} else if (prop === "updateRun") {
|
|
5706
6003
|
const method = value;
|
|
5707
|
-
wrapped = (...args) =>
|
|
6004
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.updateRun.tracePromise(
|
|
5708
6005
|
() => Reflect.apply(method, target, args),
|
|
5709
6006
|
{ arguments: args }
|
|
5710
6007
|
);
|
|
5711
6008
|
} else if (prop === "batchIngestRuns") {
|
|
5712
6009
|
const method = value;
|
|
5713
|
-
wrapped = (...args) =>
|
|
6010
|
+
wrapped = (...args) => _chunkVYNNEKSAjs.langSmithChannels.batchIngestRuns.tracePromise(
|
|
5714
6011
|
() => Reflect.apply(method, target, args),
|
|
5715
6012
|
{ arguments: args }
|
|
5716
6013
|
);
|
|
@@ -5726,13 +6023,13 @@ function publishRunUpdate(runTree) {
|
|
|
5726
6023
|
return;
|
|
5727
6024
|
}
|
|
5728
6025
|
try {
|
|
5729
|
-
void
|
|
6026
|
+
void _chunkVYNNEKSAjs.langSmithChannels.updateRun.tracePromise(() => Promise.resolve(void 0), {
|
|
5730
6027
|
arguments: [runTree.id, runTree]
|
|
5731
6028
|
}).catch((error) => {
|
|
5732
|
-
|
|
6029
|
+
_chunkVRZZQPAAjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
5733
6030
|
});
|
|
5734
6031
|
} catch (error) {
|
|
5735
|
-
|
|
6032
|
+
_chunkVRZZQPAAjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
5736
6033
|
}
|
|
5737
6034
|
}
|
|
5738
6035
|
|
|
@@ -5744,7 +6041,7 @@ var VitestContextManager = class {
|
|
|
5744
6041
|
*/
|
|
5745
6042
|
|
|
5746
6043
|
constructor() {
|
|
5747
|
-
this.contextStorage =
|
|
6044
|
+
this.contextStorage = _chunkVYNNEKSAjs.isomorph_default.newAsyncLocalStorage();
|
|
5748
6045
|
}
|
|
5749
6046
|
getCurrentContext() {
|
|
5750
6047
|
return this.contextStorage.getStore();
|
|
@@ -5785,7 +6082,7 @@ var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__ini
|
|
|
5785
6082
|
if (this.activeFlushes.has(experimentId)) {
|
|
5786
6083
|
return this.activeFlushes.get(experimentId);
|
|
5787
6084
|
}
|
|
5788
|
-
const flushPromise =
|
|
6085
|
+
const flushPromise = _chunkVRZZQPAAjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
5789
6086
|
displaySummary: config.displaySummary
|
|
5790
6087
|
});
|
|
5791
6088
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -5883,7 +6180,7 @@ async function runTracedEval(args) {
|
|
|
5883
6180
|
}
|
|
5884
6181
|
if (testError) {
|
|
5885
6182
|
span.log({ scores: { pass: 0 } });
|
|
5886
|
-
|
|
6183
|
+
_chunkVRZZQPAAjs.logError.call(void 0, span, testError);
|
|
5887
6184
|
throw testError;
|
|
5888
6185
|
}
|
|
5889
6186
|
span.log({
|
|
@@ -5916,7 +6213,7 @@ function wrapTest(originalTest, config) {
|
|
|
5916
6213
|
const wrapped = function(name, configOrFn, maybeFn) {
|
|
5917
6214
|
const isEnhanced = typeof configOrFn !== "function";
|
|
5918
6215
|
const testConfig = isEnhanced ? configOrFn : void 0;
|
|
5919
|
-
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess',
|
|
6216
|
+
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _130 => _130.data]) && Array.isArray(testConfig.data)) {
|
|
5920
6217
|
const dataRecords = testConfig.data;
|
|
5921
6218
|
const testFn2 = maybeFn;
|
|
5922
6219
|
if (!testFn2) {
|
|
@@ -5954,7 +6251,7 @@ function wrapTest(originalTest, config) {
|
|
|
5954
6251
|
const registrationContext = getExperimentContext();
|
|
5955
6252
|
const testImplementation = async (vitestContext) => {
|
|
5956
6253
|
const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
|
|
5957
|
-
const experiment = _optionalChain([experimentContext, 'optionalAccess',
|
|
6254
|
+
const experiment = _optionalChain([experimentContext, 'optionalAccess', _131 => _131.experiment]);
|
|
5958
6255
|
if (config.onProgress) {
|
|
5959
6256
|
config.onProgress({ type: "test_start", testName: name });
|
|
5960
6257
|
}
|
|
@@ -5986,11 +6283,11 @@ function wrapTest(originalTest, config) {
|
|
|
5986
6283
|
const result = await runTracedEval({
|
|
5987
6284
|
experiment,
|
|
5988
6285
|
spanName: name,
|
|
5989
|
-
input: _optionalChain([testConfig, 'optionalAccess',
|
|
5990
|
-
expected: _optionalChain([testConfig, 'optionalAccess',
|
|
5991
|
-
metadata: _optionalChain([testConfig, 'optionalAccess',
|
|
5992
|
-
tags: _optionalChain([testConfig, 'optionalAccess',
|
|
5993
|
-
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]),
|
|
5994
6291
|
fn: async () => {
|
|
5995
6292
|
if (testConfig && maybeFn) {
|
|
5996
6293
|
const params = {
|
|
@@ -6057,10 +6354,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6057
6354
|
const getOrCreateContext = () => {
|
|
6058
6355
|
if (!context) {
|
|
6059
6356
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6060
|
-
const experiment = config.projectId ?
|
|
6357
|
+
const experiment = config.projectId ? _chunkVRZZQPAAjs.initExperiment.call(void 0, {
|
|
6061
6358
|
projectId: config.projectId,
|
|
6062
6359
|
experiment: experimentName
|
|
6063
|
-
}) :
|
|
6360
|
+
}) : _chunkVRZZQPAAjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
6064
6361
|
experiment: experimentName
|
|
6065
6362
|
});
|
|
6066
6363
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -6105,8 +6402,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6105
6402
|
config.onProgress({
|
|
6106
6403
|
type: "suite_complete",
|
|
6107
6404
|
suiteName,
|
|
6108
|
-
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
6109
|
-
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))
|
|
6110
6407
|
});
|
|
6111
6408
|
}
|
|
6112
6409
|
});
|
|
@@ -6168,7 +6465,7 @@ function wrapExpect(originalExpect) {
|
|
|
6168
6465
|
return originalExpect(value);
|
|
6169
6466
|
}
|
|
6170
6467
|
const assertion = originalExpect(value, message);
|
|
6171
|
-
const span =
|
|
6468
|
+
const span = _chunkVRZZQPAAjs.currentSpan.call(void 0, );
|
|
6172
6469
|
if (!span) {
|
|
6173
6470
|
return assertion;
|
|
6174
6471
|
}
|
|
@@ -6180,16 +6477,16 @@ function wrapExpect(originalExpect) {
|
|
|
6180
6477
|
|
|
6181
6478
|
// src/wrappers/shared/logging.ts
|
|
6182
6479
|
function logOutputs(outputs) {
|
|
6183
|
-
|
|
6480
|
+
_chunkVRZZQPAAjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
6184
6481
|
}
|
|
6185
6482
|
function logFeedback(feedback) {
|
|
6186
|
-
|
|
6483
|
+
_chunkVRZZQPAAjs.currentSpan.call(void 0, ).log({
|
|
6187
6484
|
scores: { [feedback.name]: feedback.score },
|
|
6188
6485
|
metadata: feedback.metadata
|
|
6189
6486
|
});
|
|
6190
6487
|
}
|
|
6191
6488
|
function getCurrentSpan() {
|
|
6192
|
-
return
|
|
6489
|
+
return _chunkVRZZQPAAjs.currentSpan.call(void 0, );
|
|
6193
6490
|
}
|
|
6194
6491
|
|
|
6195
6492
|
// src/wrappers/vitest/index.ts
|
|
@@ -6237,8 +6534,8 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
6237
6534
|
);
|
|
6238
6535
|
return;
|
|
6239
6536
|
}
|
|
6240
|
-
await
|
|
6241
|
-
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))
|
|
6242
6539
|
});
|
|
6243
6540
|
}
|
|
6244
6541
|
};
|
|
@@ -6252,7 +6549,7 @@ function initNodeTestSuite(config) {
|
|
|
6252
6549
|
return experiment;
|
|
6253
6550
|
}
|
|
6254
6551
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6255
|
-
experiment =
|
|
6552
|
+
experiment = _chunkVRZZQPAAjs.initExperiment.call(void 0, config.projectName, {
|
|
6256
6553
|
experiment: experimentName
|
|
6257
6554
|
});
|
|
6258
6555
|
return experiment;
|
|
@@ -6301,7 +6598,7 @@ function initNodeTestSuite(config) {
|
|
|
6301
6598
|
if (!experiment) {
|
|
6302
6599
|
return;
|
|
6303
6600
|
}
|
|
6304
|
-
await
|
|
6601
|
+
await _chunkVRZZQPAAjs.summarizeAndFlush.call(void 0, experiment, {
|
|
6305
6602
|
displaySummary: config.displaySummary
|
|
6306
6603
|
});
|
|
6307
6604
|
experiment = void 0;
|
|
@@ -6318,7 +6615,7 @@ function initNodeTestSuite(config) {
|
|
|
6318
6615
|
|
|
6319
6616
|
// src/graph-framework.ts
|
|
6320
6617
|
var graph_framework_exports = {};
|
|
6321
|
-
|
|
6618
|
+
_chunkVYNNEKSAjs.__export.call(void 0, graph_framework_exports, {
|
|
6322
6619
|
AggregatorNode: () => AggregatorNode,
|
|
6323
6620
|
GateNode: () => GateNode,
|
|
6324
6621
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -6392,7 +6689,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6392
6689
|
};
|
|
6393
6690
|
}
|
|
6394
6691
|
resolveNode(node) {
|
|
6395
|
-
if (node instanceof
|
|
6692
|
+
if (node instanceof _chunkVRZZQPAAjs.Prompt) {
|
|
6396
6693
|
const cached = this.nodeLikeNodes.get(node);
|
|
6397
6694
|
if (cached) {
|
|
6398
6695
|
return [cached, []];
|
|
@@ -6442,7 +6739,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6442
6739
|
// }
|
|
6443
6740
|
// Helper to generate node IDs
|
|
6444
6741
|
generateId(name) {
|
|
6445
|
-
const uuid =
|
|
6742
|
+
const uuid = _chunkVRZZQPAAjs.newId.call(void 0, );
|
|
6446
6743
|
if (name) {
|
|
6447
6744
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
6448
6745
|
} else {
|
|
@@ -7642,7 +7939,7 @@ function waterfall(tasks, callback) {
|
|
|
7642
7939
|
var waterfall$1 = awaitify(waterfall);
|
|
7643
7940
|
|
|
7644
7941
|
// src/trace.ts
|
|
7645
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
7942
|
+
var SpanFetcher = class _SpanFetcher extends _chunkVRZZQPAAjs.ObjectFetcher {
|
|
7646
7943
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
7647
7944
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
7648
7945
|
rootSpanId,
|
|
@@ -7779,7 +8076,7 @@ var CachedSpanFetcher = (_class5 = class {
|
|
|
7779
8076
|
async fetchSpans(spanType) {
|
|
7780
8077
|
const spans = await this.fetchFn(spanType, false);
|
|
7781
8078
|
for (const span of spans) {
|
|
7782
|
-
const type = _nullishCoalesce(_optionalChain([span, 'access',
|
|
8079
|
+
const type = _nullishCoalesce(_optionalChain([span, 'access', _140 => _140.span_attributes, 'optionalAccess', _141 => _141.type]), () => ( ""));
|
|
7783
8080
|
const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
|
|
7784
8081
|
existing.push(span);
|
|
7785
8082
|
this.spanCache.set(type, existing);
|
|
@@ -7862,11 +8159,11 @@ var LocalTrace = (_class6 = class {
|
|
|
7862
8159
|
const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
|
|
7863
8160
|
if (cachedSpans && cachedSpans.length > 0) {
|
|
7864
8161
|
let spans = includeScorers ? cachedSpans : cachedSpans.filter(
|
|
7865
|
-
(span) => _optionalChain([span, 'access',
|
|
8162
|
+
(span) => _optionalChain([span, 'access', _142 => _142.span_attributes, 'optionalAccess', _143 => _143.purpose]) !== "scorer"
|
|
7866
8163
|
);
|
|
7867
8164
|
if (spanType && spanType.length > 0) {
|
|
7868
8165
|
spans = spans.filter(
|
|
7869
|
-
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access',
|
|
8166
|
+
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _144 => _144.span_attributes, 'optionalAccess', _145 => _145.type]), () => ( "")))
|
|
7870
8167
|
);
|
|
7871
8168
|
}
|
|
7872
8169
|
return spans.map((span) => ({
|
|
@@ -7891,7 +8188,7 @@ var LocalTrace = (_class6 = class {
|
|
|
7891
8188
|
* Calls the API with the project_default preprocessor (which falls back to "thread").
|
|
7892
8189
|
*/
|
|
7893
8190
|
async getThread(options) {
|
|
7894
|
-
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8191
|
+
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _146 => _146.preprocessor]), () => ( "project_default"));
|
|
7895
8192
|
if (!this.threadCache.has(cacheKey)) {
|
|
7896
8193
|
const promise = this.fetchThread(options);
|
|
7897
8194
|
this.threadCache.set(cacheKey, promise);
|
|
@@ -7902,7 +8199,7 @@ var LocalTrace = (_class6 = class {
|
|
|
7902
8199
|
await this.ensureSpansReady();
|
|
7903
8200
|
await this.state.login({});
|
|
7904
8201
|
const result = await invoke({
|
|
7905
|
-
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8202
|
+
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _147 => _147.preprocessor]), () => ( "project_default")),
|
|
7906
8203
|
functionType: "preprocessor",
|
|
7907
8204
|
input: {
|
|
7908
8205
|
trace_ref: {
|
|
@@ -7959,20 +8256,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
7959
8256
|
prompt: _v3.z.string()
|
|
7960
8257
|
}),
|
|
7961
8258
|
_v3.z.object({
|
|
7962
|
-
messages: _v3.z.array(
|
|
8259
|
+
messages: _v3.z.array(_chunkVRZZQPAAjs.ChatCompletionMessageParam)
|
|
7963
8260
|
})
|
|
7964
8261
|
]);
|
|
7965
8262
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
7966
8263
|
_v3.z.object({
|
|
7967
8264
|
model: _v3.z.string(),
|
|
7968
|
-
params:
|
|
8265
|
+
params: _chunkVRZZQPAAjs.ModelParams.optional(),
|
|
7969
8266
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
7970
8267
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
7971
8268
|
})
|
|
7972
8269
|
);
|
|
7973
8270
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
7974
8271
|
_v3.z.object({
|
|
7975
|
-
tools: _v3.z.array(
|
|
8272
|
+
tools: _v3.z.array(_chunkVRZZQPAAjs.ToolFunctionDefinition).optional()
|
|
7976
8273
|
})
|
|
7977
8274
|
);
|
|
7978
8275
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -8020,7 +8317,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
8020
8317
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
8021
8318
|
return parameters;
|
|
8022
8319
|
}
|
|
8023
|
-
if (
|
|
8320
|
+
if (_chunkVRZZQPAAjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
8024
8321
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
8025
8322
|
...resolvedSchema.data,
|
|
8026
8323
|
...parameters
|
|
@@ -8042,14 +8339,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
8042
8339
|
const value = parameters[name];
|
|
8043
8340
|
try {
|
|
8044
8341
|
if ("type" in schema && schema.type === "prompt") {
|
|
8045
|
-
const promptData = value ?
|
|
8342
|
+
const promptData = value ? _chunkVRZZQPAAjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
8046
8343
|
schema.default,
|
|
8047
8344
|
schema.default.tools
|
|
8048
8345
|
) : void 0;
|
|
8049
8346
|
if (!promptData) {
|
|
8050
8347
|
throw new Error(`Parameter '${name}' is required`);
|
|
8051
8348
|
}
|
|
8052
|
-
return [name,
|
|
8349
|
+
return [name, _chunkVRZZQPAAjs.Prompt.fromPromptData(name, promptData)];
|
|
8053
8350
|
} else if ("type" in schema && schema.type === "model") {
|
|
8054
8351
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
8055
8352
|
if (model === void 0) {
|
|
@@ -8078,10 +8375,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
|
|
|
8078
8375
|
const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
|
|
8079
8376
|
const validate = ajv.compile(schema);
|
|
8080
8377
|
if (!validate(parameters)) {
|
|
8081
|
-
const errorMessages = _optionalChain([validate, 'access',
|
|
8378
|
+
const errorMessages = _optionalChain([validate, 'access', _148 => _148.errors, 'optionalAccess', _149 => _149.map, 'call', _150 => _150((err) => {
|
|
8082
8379
|
const path = err.instancePath || "root";
|
|
8083
8380
|
return `${path}: ${err.message}`;
|
|
8084
|
-
}), 'access',
|
|
8381
|
+
}), 'access', _151 => _151.join, 'call', _152 => _152(", ")]);
|
|
8085
8382
|
throw Error(`Invalid parameters: ${errorMessages}`);
|
|
8086
8383
|
}
|
|
8087
8384
|
return rehydrateRemoteParameters(parameters, schema);
|
|
@@ -8100,7 +8397,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
8100
8397
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
8101
8398
|
return [
|
|
8102
8399
|
name,
|
|
8103
|
-
|
|
8400
|
+
_chunkVRZZQPAAjs.Prompt.fromPromptData(name, _chunkVRZZQPAAjs.PromptData.parse(value))
|
|
8104
8401
|
];
|
|
8105
8402
|
}
|
|
8106
8403
|
return [name, value];
|
|
@@ -8138,7 +8435,7 @@ var EvalResultWithSummary = class {
|
|
|
8138
8435
|
async function getPersistedBaseExperimentId(experiment) {
|
|
8139
8436
|
try {
|
|
8140
8437
|
return await experiment._getBaseExperimentId();
|
|
8141
|
-
} catch (
|
|
8438
|
+
} catch (e9) {
|
|
8142
8439
|
return void 0;
|
|
8143
8440
|
}
|
|
8144
8441
|
}
|
|
@@ -8150,7 +8447,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
8150
8447
|
return out;
|
|
8151
8448
|
}
|
|
8152
8449
|
function initExperiment2(state, options = {}) {
|
|
8153
|
-
return
|
|
8450
|
+
return _chunkVRZZQPAAjs.init.call(void 0, {
|
|
8154
8451
|
state,
|
|
8155
8452
|
...options,
|
|
8156
8453
|
setCurrent: false
|
|
@@ -8161,7 +8458,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
8161
8458
|
return void 0;
|
|
8162
8459
|
}
|
|
8163
8460
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
8164
|
-
if (!
|
|
8461
|
+
if (!_chunkVRZZQPAAjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
8165
8462
|
return void 0;
|
|
8166
8463
|
}
|
|
8167
8464
|
if (resolvedParameters.id === void 0) {
|
|
@@ -8197,10 +8494,10 @@ globalThis._evals = {
|
|
|
8197
8494
|
reporters: {}
|
|
8198
8495
|
};
|
|
8199
8496
|
function _initializeSpanContext() {
|
|
8200
|
-
globalThis._spanContext = { currentSpan:
|
|
8497
|
+
globalThis._spanContext = { currentSpan: _chunkVRZZQPAAjs.currentSpan, withCurrent: _chunkVRZZQPAAjs.withCurrent, startSpan: _chunkVRZZQPAAjs.startSpan, NOOP_SPAN: _chunkVRZZQPAAjs.NOOP_SPAN };
|
|
8201
8498
|
}
|
|
8202
8499
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
8203
|
-
const options =
|
|
8500
|
+
const options = _chunkVRZZQPAAjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
8204
8501
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
8205
8502
|
if (globalThis._evals.evaluators[evalName]) {
|
|
8206
8503
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -8251,7 +8548,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8251
8548
|
baseExperimentId: evaluator.baseExperimentId,
|
|
8252
8549
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
8253
8550
|
repoInfo: evaluator.repoInfo,
|
|
8254
|
-
dataset:
|
|
8551
|
+
dataset: _chunkVRZZQPAAjs.Dataset.isDataset(data) ? data : void 0,
|
|
8255
8552
|
parameters
|
|
8256
8553
|
});
|
|
8257
8554
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
@@ -8271,7 +8568,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8271
8568
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
8272
8569
|
let ret;
|
|
8273
8570
|
if (options.parent) {
|
|
8274
|
-
ret = await
|
|
8571
|
+
ret = await _chunkVRZZQPAAjs.withParent.call(void 0,
|
|
8275
8572
|
options.parent,
|
|
8276
8573
|
() => runEvaluator(
|
|
8277
8574
|
null,
|
|
@@ -8307,7 +8604,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8307
8604
|
if (experiment) {
|
|
8308
8605
|
await experiment.flush().catch(console.error);
|
|
8309
8606
|
} else if (options.parent) {
|
|
8310
|
-
await
|
|
8607
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
8311
8608
|
}
|
|
8312
8609
|
}
|
|
8313
8610
|
} finally {
|
|
@@ -8353,13 +8650,13 @@ function classifierName(classifier, classifier_idx) {
|
|
|
8353
8650
|
}
|
|
8354
8651
|
function buildSpanMetadata(results) {
|
|
8355
8652
|
return results.length === 1 ? results[0].metadata : results.reduce(
|
|
8356
|
-
(prev, s) =>
|
|
8653
|
+
(prev, s) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
|
|
8357
8654
|
{}
|
|
8358
8655
|
);
|
|
8359
8656
|
}
|
|
8360
8657
|
function buildSpanScores(results) {
|
|
8361
8658
|
const scoresRecord = results.reduce(
|
|
8362
|
-
(prev, s) =>
|
|
8659
|
+
(prev, s) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
|
|
8363
8660
|
{}
|
|
8364
8661
|
);
|
|
8365
8662
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
@@ -8389,7 +8686,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
8389
8686
|
return failing;
|
|
8390
8687
|
}
|
|
8391
8688
|
function validateClassificationResult(value, scorerName2) {
|
|
8392
|
-
if (!(typeof value === "object" && value !== null && !
|
|
8689
|
+
if (!(typeof value === "object" && value !== null && !_chunkVRZZQPAAjs.isEmpty.call(void 0, value))) {
|
|
8393
8690
|
throw new Error(
|
|
8394
8691
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
8395
8692
|
);
|
|
@@ -8418,7 +8715,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
8418
8715
|
);
|
|
8419
8716
|
metadata[`${kind}_errors`] = errorMap;
|
|
8420
8717
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
8421
|
-
|
|
8718
|
+
_chunkVRZZQPAAjs.debugLogger.forState(state).warn(
|
|
8422
8719
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
8423
8720
|
failures.map((f) => f.error)
|
|
8424
8721
|
);
|
|
@@ -8452,7 +8749,7 @@ var defaultErrorScoreHandler = ({
|
|
|
8452
8749
|
};
|
|
8453
8750
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
8454
8751
|
if (enableCache) {
|
|
8455
|
-
_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()]);
|
|
8456
8753
|
}
|
|
8457
8754
|
try {
|
|
8458
8755
|
if (typeof evaluator.data === "string") {
|
|
@@ -8473,7 +8770,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8473
8770
|
);
|
|
8474
8771
|
}
|
|
8475
8772
|
let name = dataResult.name;
|
|
8476
|
-
if (
|
|
8773
|
+
if (_chunkVRZZQPAAjs.isEmpty.call(void 0, name)) {
|
|
8477
8774
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
8478
8775
|
if (!baseExperiment) {
|
|
8479
8776
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -8507,7 +8804,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8507
8804
|
const experimentIdPromise = experiment ? (async () => {
|
|
8508
8805
|
try {
|
|
8509
8806
|
return await experiment.id;
|
|
8510
|
-
} catch (
|
|
8807
|
+
} catch (e10) {
|
|
8511
8808
|
return void 0;
|
|
8512
8809
|
}
|
|
8513
8810
|
})() : void 0;
|
|
@@ -8523,7 +8820,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8523
8820
|
if (cancelled) {
|
|
8524
8821
|
return;
|
|
8525
8822
|
}
|
|
8526
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
8823
|
+
const eventDataset = experiment ? experiment.dataset : _chunkVRZZQPAAjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
8527
8824
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
8528
8825
|
object_type: "dataset",
|
|
8529
8826
|
object_id: await eventDataset.id,
|
|
@@ -8531,8 +8828,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8531
8828
|
created: datum.created,
|
|
8532
8829
|
_xact_id: datum._xact_id
|
|
8533
8830
|
} : void 0;
|
|
8534
|
-
const parsedDatumOrigin =
|
|
8535
|
-
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)));
|
|
8536
8833
|
const baseEvent = {
|
|
8537
8834
|
name: "eval",
|
|
8538
8835
|
spanAttributes: {
|
|
@@ -8547,26 +8844,26 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8547
8844
|
}
|
|
8548
8845
|
};
|
|
8549
8846
|
const callback = async (rootSpan) => {
|
|
8550
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
8847
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, )));
|
|
8551
8848
|
const ensureSpansFlushed = async () => {
|
|
8552
8849
|
if (experiment) {
|
|
8553
|
-
await
|
|
8850
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, { state: experiment.loggingState });
|
|
8554
8851
|
} else if (state) {
|
|
8555
|
-
await
|
|
8852
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, { state });
|
|
8556
8853
|
} else {
|
|
8557
|
-
await
|
|
8854
|
+
await _chunkVRZZQPAAjs.flush.call(void 0, );
|
|
8558
8855
|
}
|
|
8559
8856
|
if (state) {
|
|
8560
8857
|
await state.flushOtel();
|
|
8561
8858
|
}
|
|
8562
8859
|
};
|
|
8563
8860
|
const parentStr = state.currentParent.getStore();
|
|
8564
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
8861
|
+
const parentComponents = typeof parentStr === "string" ? _chunkVRZZQPAAjs.SpanComponentsV4.fromStr(parentStr) : null;
|
|
8565
8862
|
const trace = state ? new LocalTrace({
|
|
8566
|
-
objectType: parentComponents ?
|
|
8863
|
+
objectType: parentComponents ? _chunkVRZZQPAAjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
8567
8864
|
parentComponents.data.object_type
|
|
8568
8865
|
) : "experiment",
|
|
8569
|
-
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 () => ( "")) : ""))),
|
|
8570
8867
|
rootSpanId: rootSpan.rootSpanId,
|
|
8571
8868
|
ensureSpansFlushed,
|
|
8572
8869
|
state
|
|
@@ -8596,10 +8893,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8596
8893
|
span,
|
|
8597
8894
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
8598
8895
|
reportProgress: (event) => {
|
|
8599
|
-
_optionalChain([stream, 'optionalCall',
|
|
8896
|
+
_optionalChain([stream, 'optionalCall', _159 => _159({
|
|
8600
8897
|
...event,
|
|
8601
8898
|
id: rootSpan.id,
|
|
8602
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8899
|
+
origin: _optionalChain([baseEvent, 'access', _160 => _160.event, 'optionalAccess', _161 => _161.origin]),
|
|
8603
8900
|
name: evaluator.evalName,
|
|
8604
8901
|
object_type: "task"
|
|
8605
8902
|
})]);
|
|
@@ -8638,7 +8935,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8638
8935
|
trace
|
|
8639
8936
|
};
|
|
8640
8937
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
8641
|
-
const propagatedEvent =
|
|
8938
|
+
const propagatedEvent = _chunkVRZZQPAAjs.makeScorerPropagatedEvent.call(void 0,
|
|
8642
8939
|
await rootSpan.export()
|
|
8643
8940
|
);
|
|
8644
8941
|
const getOtherFields = (s) => {
|
|
@@ -8661,14 +8958,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8661
8958
|
if (scoreValue === null) return null;
|
|
8662
8959
|
if (Array.isArray(scoreValue)) {
|
|
8663
8960
|
for (const s of scoreValue) {
|
|
8664
|
-
if (!(typeof s === "object" && !
|
|
8961
|
+
if (!(typeof s === "object" && !_chunkVRZZQPAAjs.isEmpty.call(void 0, s))) {
|
|
8665
8962
|
throw new Error(
|
|
8666
8963
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
8667
8964
|
);
|
|
8668
8965
|
}
|
|
8669
8966
|
}
|
|
8670
8967
|
}
|
|
8671
|
-
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] : [
|
|
8672
8969
|
{
|
|
8673
8970
|
name: scorerNames[score_idx],
|
|
8674
8971
|
score: scoreValue
|
|
@@ -8676,7 +8973,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8676
8973
|
];
|
|
8677
8974
|
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
8678
8975
|
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
8679
|
-
(prev, s) =>
|
|
8976
|
+
(prev, s) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, {
|
|
8680
8977
|
[s.name]: getOtherFields(s)
|
|
8681
8978
|
}),
|
|
8682
8979
|
{}
|
|
@@ -8711,7 +9008,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8711
9008
|
)
|
|
8712
9009
|
);
|
|
8713
9010
|
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
8714
|
-
(prev, r) =>
|
|
9011
|
+
(prev, r) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, {
|
|
8715
9012
|
[r.name]: toClassificationItem(r)
|
|
8716
9013
|
}),
|
|
8717
9014
|
{}
|
|
@@ -8763,7 +9060,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8763
9060
|
evaluator.state
|
|
8764
9061
|
);
|
|
8765
9062
|
} catch (e) {
|
|
8766
|
-
|
|
9063
|
+
_chunkVRZZQPAAjs.logError.call(void 0, rootSpan, e);
|
|
8767
9064
|
error = e;
|
|
8768
9065
|
} finally {
|
|
8769
9066
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -8787,7 +9084,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8787
9084
|
tags: tags.length ? tags : void 0,
|
|
8788
9085
|
metadata,
|
|
8789
9086
|
error,
|
|
8790
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
9087
|
+
origin: _optionalChain([baseEvent, 'access', _162 => _162.event, 'optionalAccess', _163 => _163.origin])
|
|
8791
9088
|
};
|
|
8792
9089
|
collectedResults.push({
|
|
8793
9090
|
...baseResult,
|
|
@@ -8797,7 +9094,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8797
9094
|
}
|
|
8798
9095
|
};
|
|
8799
9096
|
if (!experiment) {
|
|
8800
|
-
return await
|
|
9097
|
+
return await _chunkVRZZQPAAjs.traced.call(void 0, callback, {
|
|
8801
9098
|
...baseEvent,
|
|
8802
9099
|
state: evaluator.state
|
|
8803
9100
|
});
|
|
@@ -8827,7 +9124,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8827
9124
|
break;
|
|
8828
9125
|
}
|
|
8829
9126
|
scheduledTrials++;
|
|
8830
|
-
_optionalChain([progressReporter, 'access',
|
|
9127
|
+
_optionalChain([progressReporter, 'access', _164 => _164.setTotal, 'optionalCall', _165 => _165(evaluator.evalName, scheduledTrials)]);
|
|
8831
9128
|
q.pushAsync({ datum, trialIndex }).catch((e) => {
|
|
8832
9129
|
if (queueErrors.length < 5) {
|
|
8833
9130
|
queueErrors.push(e);
|
|
@@ -8836,36 +9133,40 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8836
9133
|
}
|
|
8837
9134
|
}
|
|
8838
9135
|
})();
|
|
9136
|
+
let timeoutId;
|
|
9137
|
+
let abortHandler;
|
|
9138
|
+
const cleanupCancellation = () => {
|
|
9139
|
+
if (timeoutId !== void 0) {
|
|
9140
|
+
clearTimeout(timeoutId);
|
|
9141
|
+
timeoutId = void 0;
|
|
9142
|
+
}
|
|
9143
|
+
if (abortHandler && evaluator.signal) {
|
|
9144
|
+
evaluator.signal.removeEventListener("abort", abortHandler);
|
|
9145
|
+
abortHandler = void 0;
|
|
9146
|
+
}
|
|
9147
|
+
};
|
|
8839
9148
|
const cancel = async () => {
|
|
8840
9149
|
await new Promise((_, reject2) => {
|
|
8841
9150
|
if (cancelled) {
|
|
8842
|
-
reject2(new (0,
|
|
9151
|
+
reject2(new (0, _chunkVRZZQPAAjs.InternalAbortError)("Evaluator already cancelled"));
|
|
8843
9152
|
return;
|
|
8844
9153
|
}
|
|
8845
|
-
let timeoutId;
|
|
8846
|
-
let abortHandler;
|
|
8847
9154
|
const rejectOnce = (error) => {
|
|
8848
9155
|
if (cancelled) {
|
|
8849
9156
|
return;
|
|
8850
9157
|
}
|
|
8851
9158
|
cancelled = true;
|
|
8852
|
-
|
|
8853
|
-
clearTimeout(timeoutId);
|
|
8854
|
-
timeoutId = void 0;
|
|
8855
|
-
}
|
|
8856
|
-
if (abortHandler && evaluator.signal) {
|
|
8857
|
-
evaluator.signal.removeEventListener("abort", abortHandler);
|
|
8858
|
-
}
|
|
9159
|
+
cleanupCancellation();
|
|
8859
9160
|
reject2(error);
|
|
8860
9161
|
};
|
|
8861
9162
|
if (evaluator.timeout) {
|
|
8862
9163
|
timeoutId = setTimeout(() => {
|
|
8863
|
-
rejectOnce(new (0,
|
|
9164
|
+
rejectOnce(new (0, _chunkVRZZQPAAjs.InternalAbortError)("Evaluator timed out"));
|
|
8864
9165
|
}, evaluator.timeout);
|
|
8865
9166
|
}
|
|
8866
9167
|
if (evaluator.signal) {
|
|
8867
9168
|
abortHandler = () => {
|
|
8868
|
-
rejectOnce(new (0,
|
|
9169
|
+
rejectOnce(new (0, _chunkVRZZQPAAjs.InternalAbortError)("Evaluator aborted"));
|
|
8869
9170
|
};
|
|
8870
9171
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
8871
9172
|
}
|
|
@@ -8888,13 +9189,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8888
9189
|
}
|
|
8889
9190
|
} catch (e) {
|
|
8890
9191
|
q.kill();
|
|
8891
|
-
if (e instanceof
|
|
8892
|
-
if (
|
|
8893
|
-
|
|
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);
|
|
8894
9195
|
}
|
|
8895
9196
|
}
|
|
8896
9197
|
throw e;
|
|
8897
9198
|
} finally {
|
|
9199
|
+
cleanupCancellation();
|
|
8898
9200
|
if (!collectResults) {
|
|
8899
9201
|
collectedResults.length = 0;
|
|
8900
9202
|
}
|
|
@@ -8914,9 +9216,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8914
9216
|
);
|
|
8915
9217
|
} finally {
|
|
8916
9218
|
if (enableCache) {
|
|
8917
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
8918
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
8919
|
-
_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()]);
|
|
8920
9222
|
}
|
|
8921
9223
|
}
|
|
8922
9224
|
}
|
|
@@ -9009,25 +9311,25 @@ var defaultReporter = {
|
|
|
9009
9311
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
9010
9312
|
}
|
|
9011
9313
|
if (jsonl) {
|
|
9012
|
-
|
|
9314
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
9013
9315
|
} else {
|
|
9014
|
-
|
|
9015
|
-
|
|
9316
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("Experiment summary");
|
|
9317
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("==================");
|
|
9016
9318
|
if (summary.comparisonExperimentName) {
|
|
9017
|
-
|
|
9319
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9018
9320
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
9019
9321
|
);
|
|
9020
|
-
|
|
9322
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("");
|
|
9021
9323
|
}
|
|
9022
9324
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
9023
9325
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
9024
9326
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
9025
9327
|
if (hasScores || hasMetrics) {
|
|
9026
9328
|
if (hasComparison) {
|
|
9027
|
-
|
|
9329
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9028
9330
|
"Name Value Change Improvements Regressions"
|
|
9029
9331
|
);
|
|
9030
|
-
|
|
9332
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9031
9333
|
"----------------------------------------------------------------"
|
|
9032
9334
|
);
|
|
9033
9335
|
}
|
|
@@ -9036,18 +9338,18 @@ var defaultReporter = {
|
|
|
9036
9338
|
const scoreValue = `${scorePercent}%`;
|
|
9037
9339
|
if (hasComparison) {
|
|
9038
9340
|
let diffString = "-";
|
|
9039
|
-
if (!
|
|
9341
|
+
if (!_chunkVRZZQPAAjs.isEmpty.call(void 0, score.diff)) {
|
|
9040
9342
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
9041
9343
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
9042
9344
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9043
9345
|
}
|
|
9044
9346
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
9045
9347
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
9046
|
-
|
|
9348
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9047
9349
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9048
9350
|
);
|
|
9049
9351
|
} else {
|
|
9050
|
-
|
|
9352
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
9051
9353
|
}
|
|
9052
9354
|
}
|
|
9053
9355
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -9056,30 +9358,30 @@ var defaultReporter = {
|
|
|
9056
9358
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
9057
9359
|
if (hasComparison) {
|
|
9058
9360
|
let diffString = "-";
|
|
9059
|
-
if (!
|
|
9361
|
+
if (!_chunkVRZZQPAAjs.isEmpty.call(void 0, metric.diff)) {
|
|
9060
9362
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
9061
9363
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
9062
9364
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9063
9365
|
}
|
|
9064
9366
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
9065
9367
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
9066
|
-
|
|
9368
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9067
9369
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9068
9370
|
);
|
|
9069
9371
|
} else {
|
|
9070
|
-
|
|
9372
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln(
|
|
9071
9373
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
9072
9374
|
);
|
|
9073
9375
|
}
|
|
9074
9376
|
}
|
|
9075
9377
|
}
|
|
9076
9378
|
if (summary.experimentUrl) {
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
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}`);
|
|
9080
9382
|
}
|
|
9081
9383
|
}
|
|
9082
|
-
|
|
9384
|
+
_chunkVYNNEKSAjs.isomorph_default.writeln("");
|
|
9083
9385
|
return failingResults.length === 0;
|
|
9084
9386
|
},
|
|
9085
9387
|
async reportRun(evalReports) {
|
|
@@ -9099,7 +9401,7 @@ function agentAssertionScorer(callback, options = {}) {
|
|
|
9099
9401
|
});
|
|
9100
9402
|
const resources = {};
|
|
9101
9403
|
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
9102
|
-
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"] })]);
|
|
9103
9405
|
}
|
|
9104
9406
|
const results = await Promise.all(
|
|
9105
9407
|
assertions.map(async (assertion) => {
|
|
@@ -9257,7 +9559,7 @@ async function validateSchema(schema, value) {
|
|
|
9257
9559
|
}
|
|
9258
9560
|
}
|
|
9259
9561
|
function toolCalls(spans) {
|
|
9260
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
9562
|
+
return spans.filter((span) => _optionalChain([span, 'access', _174 => _174.span_attributes, 'optionalAccess', _175 => _175.type]) === "tool");
|
|
9261
9563
|
}
|
|
9262
9564
|
function matchingToolCalls(spans, toolName, options) {
|
|
9263
9565
|
return toolCalls(spans).filter((span) => {
|
|
@@ -9275,17 +9577,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
9275
9577
|
});
|
|
9276
9578
|
}
|
|
9277
9579
|
function getToolName(span) {
|
|
9278
|
-
const spanName = [_optionalChain([span, 'access',
|
|
9279
|
-
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("/")])) {
|
|
9280
9582
|
return spanName;
|
|
9281
9583
|
}
|
|
9282
9584
|
const metadataName = [
|
|
9283
|
-
_optionalChain([span, 'access',
|
|
9284
|
-
_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"]])
|
|
9285
9587
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
9286
9588
|
const mcpServer = [
|
|
9287
|
-
_optionalChain([span, 'access',
|
|
9288
|
-
_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"]])
|
|
9289
9591
|
].find((value) => typeof value === "string" && value !== "");
|
|
9290
9592
|
if (metadataName && mcpServer) {
|
|
9291
9593
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -9355,7 +9657,7 @@ function formatValue(value) {
|
|
|
9355
9657
|
return serialized;
|
|
9356
9658
|
}
|
|
9357
9659
|
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
9358
|
-
} catch (
|
|
9660
|
+
} catch (e11) {
|
|
9359
9661
|
return String(value);
|
|
9360
9662
|
}
|
|
9361
9663
|
}
|
|
@@ -9514,7 +9816,7 @@ var Project2 = (_class7 = class {
|
|
|
9514
9816
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
9515
9817
|
return;
|
|
9516
9818
|
}
|
|
9517
|
-
await
|
|
9819
|
+
await _chunkVRZZQPAAjs.login.call(void 0, );
|
|
9518
9820
|
const projectMap = new ProjectNameIdMap();
|
|
9519
9821
|
const functionDefinitions = [];
|
|
9520
9822
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -9528,7 +9830,7 @@ var Project2 = (_class7 = class {
|
|
|
9528
9830
|
functionDefinitions.push(functionDefinition);
|
|
9529
9831
|
}
|
|
9530
9832
|
}
|
|
9531
|
-
await
|
|
9833
|
+
await _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
9532
9834
|
functions: functionDefinitions
|
|
9533
9835
|
});
|
|
9534
9836
|
}
|
|
@@ -9547,12 +9849,12 @@ var ToolBuilder = (_class8 = class {
|
|
|
9547
9849
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
9548
9850
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
9549
9851
|
if (resolvedName.trim().length === 0) {
|
|
9550
|
-
resolvedName = `Tool ${
|
|
9852
|
+
resolvedName = `Tool ${_chunkVYNNEKSAjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9551
9853
|
}
|
|
9552
9854
|
const tool = new CodeFunction(this.project, {
|
|
9553
9855
|
handler,
|
|
9554
9856
|
name: resolvedName,
|
|
9555
|
-
slug: _nullishCoalesce(slug, () => (
|
|
9857
|
+
slug: _nullishCoalesce(slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
9556
9858
|
type: "tool",
|
|
9557
9859
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
9558
9860
|
parameters,
|
|
@@ -9577,9 +9879,9 @@ var ScorerBuilder = (_class9 = class {
|
|
|
9577
9879
|
resolvedName = opts.handler.name;
|
|
9578
9880
|
}
|
|
9579
9881
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
9580
|
-
resolvedName = `Scorer ${
|
|
9882
|
+
resolvedName = `Scorer ${_chunkVYNNEKSAjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9581
9883
|
}
|
|
9582
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9884
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
9583
9885
|
if ("handler" in opts) {
|
|
9584
9886
|
const scorer = new CodeFunction(this.project, {
|
|
9585
9887
|
...opts,
|
|
@@ -9634,9 +9936,9 @@ var ClassifierBuilder = (_class10 = class {
|
|
|
9634
9936
|
this.taskCounter++;
|
|
9635
9937
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
9636
9938
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
9637
|
-
resolvedName = `Classifier ${
|
|
9939
|
+
resolvedName = `Classifier ${_chunkVYNNEKSAjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9638
9940
|
}
|
|
9639
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9941
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
9640
9942
|
const classifier = new CodeFunction(this.project, {
|
|
9641
9943
|
...opts,
|
|
9642
9944
|
name: resolvedName,
|
|
@@ -9765,18 +10067,18 @@ var PromptBuilder = class {
|
|
|
9765
10067
|
rawTools.push(tool);
|
|
9766
10068
|
}
|
|
9767
10069
|
}
|
|
9768
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
10070
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
9769
10071
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
9770
10072
|
const promptRow = {
|
|
9771
10073
|
id: opts.id,
|
|
9772
|
-
_xact_id: opts.version ?
|
|
10074
|
+
_xact_id: opts.version ? _chunkVRZZQPAAjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
9773
10075
|
name: opts.name,
|
|
9774
10076
|
slug,
|
|
9775
10077
|
prompt_data: promptData,
|
|
9776
10078
|
tags: opts.tags,
|
|
9777
10079
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
9778
10080
|
};
|
|
9779
|
-
const prompt = new (0,
|
|
10081
|
+
const prompt = new (0, _chunkVRZZQPAAjs.Prompt)(
|
|
9780
10082
|
promptRow,
|
|
9781
10083
|
{},
|
|
9782
10084
|
// It doesn't make sense to specify defaults here.
|
|
@@ -9831,7 +10133,7 @@ var ParametersBuilder = class {
|
|
|
9831
10133
|
}
|
|
9832
10134
|
|
|
9833
10135
|
create(opts) {
|
|
9834
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
10136
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkVRZZQPAAjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
9835
10137
|
const codeParameters = new CodeParameters(this.project, {
|
|
9836
10138
|
name: opts.name,
|
|
9837
10139
|
slug,
|
|
@@ -9870,7 +10172,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
9870
10172
|
required.push(name);
|
|
9871
10173
|
}
|
|
9872
10174
|
} else {
|
|
9873
|
-
const schemaObj =
|
|
10175
|
+
const schemaObj = _chunkVRZZQPAAjs.zodToJsonSchema.call(void 0, value);
|
|
9874
10176
|
properties[name] = schemaObj;
|
|
9875
10177
|
if (!("default" in schemaObj)) {
|
|
9876
10178
|
required.push(name);
|
|
@@ -9899,11 +10201,11 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
9899
10201
|
__init23() {this.idToName = {}}
|
|
9900
10202
|
async getId(projectName) {
|
|
9901
10203
|
if (!(projectName in this.nameToId)) {
|
|
9902
|
-
const response = await
|
|
10204
|
+
const response = await _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
9903
10205
|
project_name: projectName
|
|
9904
10206
|
});
|
|
9905
10207
|
const result = _v3.z.object({
|
|
9906
|
-
project:
|
|
10208
|
+
project: _chunkVRZZQPAAjs.Project
|
|
9907
10209
|
}).parse(response);
|
|
9908
10210
|
const projectId = result.project.id;
|
|
9909
10211
|
this.nameToId[projectName] = projectId;
|
|
@@ -9913,10 +10215,10 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
9913
10215
|
}
|
|
9914
10216
|
async getName(projectId) {
|
|
9915
10217
|
if (!(projectId in this.idToName)) {
|
|
9916
|
-
const response = await
|
|
10218
|
+
const response = await _chunkVRZZQPAAjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
9917
10219
|
id: projectId
|
|
9918
10220
|
});
|
|
9919
|
-
const result = _v3.z.array(
|
|
10221
|
+
const result = _v3.z.array(_chunkVRZZQPAAjs.Project).nonempty().parse(response);
|
|
9920
10222
|
const projectName = result[0].name;
|
|
9921
10223
|
this.idToName[projectId] = projectName;
|
|
9922
10224
|
this.nameToId[projectName] = projectId;
|
|
@@ -9936,16 +10238,16 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
9936
10238
|
var evalBodySchema = _v3.z.object({
|
|
9937
10239
|
name: _v3.z.string(),
|
|
9938
10240
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
9939
|
-
data:
|
|
10241
|
+
data: _chunkVRZZQPAAjs.RunEval.shape.data,
|
|
9940
10242
|
scores: _v3.z.array(
|
|
9941
10243
|
_v3.z.object({
|
|
9942
|
-
function_id:
|
|
10244
|
+
function_id: _chunkVRZZQPAAjs.FunctionId,
|
|
9943
10245
|
name: _v3.z.string()
|
|
9944
10246
|
})
|
|
9945
10247
|
).nullish(),
|
|
9946
10248
|
experiment_name: _v3.z.string().nullish(),
|
|
9947
10249
|
project_id: _v3.z.string().nullish(),
|
|
9948
|
-
parent:
|
|
10250
|
+
parent: _chunkVRZZQPAAjs.InvokeParent.optional(),
|
|
9949
10251
|
stream: _v3.z.boolean().optional()
|
|
9950
10252
|
});
|
|
9951
10253
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -9953,7 +10255,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
9953
10255
|
_v3.z.union([
|
|
9954
10256
|
_v3.z.object({
|
|
9955
10257
|
type: _v3.z.literal("prompt"),
|
|
9956
|
-
default:
|
|
10258
|
+
default: _chunkVRZZQPAAjs.PromptData.optional(),
|
|
9957
10259
|
description: _v3.z.string().optional()
|
|
9958
10260
|
}),
|
|
9959
10261
|
_v3.z.object({
|
|
@@ -10009,7 +10311,10 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
10009
10311
|
);
|
|
10010
10312
|
|
|
10011
10313
|
// src/node/index.ts
|
|
10012
|
-
|
|
10314
|
+
_chunkVRZZQPAAjs.configureNode.call(void 0, );
|
|
10315
|
+
|
|
10316
|
+
|
|
10317
|
+
|
|
10013
10318
|
|
|
10014
10319
|
|
|
10015
10320
|
|
|
@@ -10180,4 +10485,4 @@ _chunkSU6EHKJVjs.configureNode.call(void 0, );
|
|
|
10180
10485
|
|
|
10181
10486
|
|
|
10182
10487
|
|
|
10183
|
-
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;
|