braintrust 3.28.0 → 3.29.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/README.md +1 -1
- package/dev/dist/index.d.mts +356 -7
- package/dev/dist/index.d.ts +356 -7
- package/dev/dist/index.js +1815 -1548
- package/dev/dist/index.mjs +1054 -787
- package/dist/apply-auto-instrumentation.js +297 -264
- package/dist/apply-auto-instrumentation.mjs +84 -51
- package/dist/auto-instrumentations/bundler/esbuild.cjs +43 -5
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/next.cjs +43 -5
- package/dist/auto-instrumentations/bundler/next.mjs +3 -3
- package/dist/auto-instrumentations/bundler/rollup.cjs +43 -5
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +43 -5
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +43 -5
- package/dist/auto-instrumentations/bundler/webpack.cjs +43 -5
- package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
- package/dist/auto-instrumentations/{chunk-NP7V4XB2.mjs → chunk-AOIYCVEL.mjs} +32 -2
- package/dist/auto-instrumentations/{chunk-26PKVUKB.mjs → chunk-DKTGDNA7.mjs} +12 -4
- package/dist/auto-instrumentations/{chunk-HD35AM3M.mjs → chunk-OMCZ3MV2.mjs} +1 -1
- package/dist/auto-instrumentations/hook.mjs +952 -133
- package/dist/auto-instrumentations/index.cjs +32 -2
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/browser.d.mts +760 -22
- package/dist/browser.d.ts +760 -22
- package/dist/browser.js +1661 -848
- package/dist/browser.mjs +1661 -848
- package/dist/{chunk-BBE7SNRV.js → chunk-6Z5S7VOU.js} +143 -23
- package/dist/{chunk-ZHUHZWFY.mjs → chunk-7FA6VP2S.mjs} +140 -20
- package/dist/{chunk-UPFNQCGB.mjs → chunk-M6XPNJC4.mjs} +1144 -931
- package/dist/{chunk-OBBWQW6K.js → chunk-XLLGRXGR.js} +2335 -2122
- package/dist/cli.js +5134 -1090
- package/dist/edge-light.js +1661 -848
- package/dist/edge-light.mjs +1661 -848
- package/dist/index.d.mts +760 -22
- package/dist/index.d.ts +760 -22
- package/dist/index.js +1054 -567
- package/dist/index.mjs +514 -27
- package/dist/instrumentation/index.d.mts +548 -9
- package/dist/instrumentation/index.d.ts +548 -9
- package/dist/instrumentation/index.js +1975 -765
- package/dist/instrumentation/index.mjs +1975 -765
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.js +1661 -848
- package/dist/workerd.mjs +1661 -848
- package/package.json +1 -1
- package/util/dist/index.d.mts +42 -0
- package/util/dist/index.d.ts +42 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -143,8 +143,8 @@
|
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
|
|
146
|
+
var _chunkXLLGRXGRjs = require('./chunk-XLLGRXGR.js');
|
|
146
147
|
|
|
147
|
-
var _chunkOBBWQW6Kjs = require('./chunk-OBBWQW6K.js');
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
|
|
@@ -177,157 +177,157 @@ var _chunkOBBWQW6Kjs = require('./chunk-OBBWQW6K.js');
|
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
|
|
180
|
-
var
|
|
180
|
+
var _chunk6Z5S7VOUjs = require('./chunk-6Z5S7VOU.js');
|
|
181
181
|
|
|
182
182
|
// src/exports.ts
|
|
183
183
|
var exports_exports = {};
|
|
184
|
-
|
|
185
|
-
Attachment: () =>
|
|
186
|
-
AttachmentReference: () =>
|
|
187
|
-
BAGGAGE_HEADER: () =>
|
|
188
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
189
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
190
|
-
BRAINTRUST_PARENT_KEY: () =>
|
|
191
|
-
BaseAttachment: () =>
|
|
184
|
+
_chunk6Z5S7VOUjs.__export.call(void 0, exports_exports, {
|
|
185
|
+
Attachment: () => _chunkXLLGRXGRjs.Attachment,
|
|
186
|
+
AttachmentReference: () => _chunkXLLGRXGRjs.AttachmentReference,
|
|
187
|
+
BAGGAGE_HEADER: () => _chunkXLLGRXGRjs.BAGGAGE_HEADER,
|
|
188
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkXLLGRXGRjs.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
189
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkXLLGRXGRjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
190
|
+
BRAINTRUST_PARENT_KEY: () => _chunkXLLGRXGRjs.BRAINTRUST_PARENT_KEY,
|
|
191
|
+
BaseAttachment: () => _chunkXLLGRXGRjs.BaseAttachment,
|
|
192
192
|
BaseExperiment: () => BaseExperiment,
|
|
193
193
|
BatchScorer: () => BatchScorer,
|
|
194
194
|
BatchTask: () => BatchTask,
|
|
195
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
195
|
+
BraintrustLangChainCallbackHandler: () => _chunkXLLGRXGRjs.BraintrustLangChainCallbackHandler,
|
|
196
196
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
197
|
-
BraintrustObservabilityExporter: () =>
|
|
198
|
-
BraintrustState: () =>
|
|
199
|
-
BraintrustStream: () =>
|
|
197
|
+
BraintrustObservabilityExporter: () => _chunkXLLGRXGRjs.BraintrustObservabilityExporter,
|
|
198
|
+
BraintrustState: () => _chunkXLLGRXGRjs.BraintrustState,
|
|
199
|
+
BraintrustStream: () => _chunkXLLGRXGRjs.BraintrustStream,
|
|
200
200
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
201
201
|
CodeFunction: () => CodeFunction,
|
|
202
202
|
CodePrompt: () => CodePrompt,
|
|
203
|
-
ContextManager: () =>
|
|
204
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
205
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
206
|
-
Dataset: () =>
|
|
203
|
+
ContextManager: () => _chunkXLLGRXGRjs.ContextManager,
|
|
204
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkXLLGRXGRjs.DEFAULT_FETCH_BATCH_SIZE,
|
|
205
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkXLLGRXGRjs.DEFAULT_MAX_REQUEST_SIZE,
|
|
206
|
+
Dataset: () => _chunkXLLGRXGRjs.Dataset,
|
|
207
207
|
DatasetPipeline: () => DatasetPipeline,
|
|
208
208
|
DurableEvalMemoryStore: () => DurableEvalMemoryStore,
|
|
209
209
|
DurableEvalRedisStore: () => DurableEvalRedisStore,
|
|
210
|
-
ERR_PERMALINK: () =>
|
|
210
|
+
ERR_PERMALINK: () => _chunkXLLGRXGRjs.ERR_PERMALINK,
|
|
211
211
|
Eval: () => Eval,
|
|
212
212
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
213
|
-
Experiment: () =>
|
|
214
|
-
ExternalAttachment: () =>
|
|
215
|
-
FailedHTTPResponse: () =>
|
|
216
|
-
IDGenerator: () =>
|
|
217
|
-
JSONAttachment: () =>
|
|
218
|
-
LEGACY_CACHED_HEADER: () =>
|
|
219
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
220
|
-
LazyValue: () =>
|
|
213
|
+
Experiment: () => _chunkXLLGRXGRjs.Experiment,
|
|
214
|
+
ExternalAttachment: () => _chunkXLLGRXGRjs.ExternalAttachment,
|
|
215
|
+
FailedHTTPResponse: () => _chunkXLLGRXGRjs.FailedHTTPResponse,
|
|
216
|
+
IDGenerator: () => _chunkXLLGRXGRjs.IDGenerator,
|
|
217
|
+
JSONAttachment: () => _chunkXLLGRXGRjs.JSONAttachment,
|
|
218
|
+
LEGACY_CACHED_HEADER: () => _chunkXLLGRXGRjs.LEGACY_CACHED_HEADER,
|
|
219
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkXLLGRXGRjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
220
|
+
LazyValue: () => _chunkXLLGRXGRjs.LazyValue,
|
|
221
221
|
LocalTrace: () => LocalTrace,
|
|
222
|
-
Logger: () =>
|
|
223
|
-
LoginInvalidOrgError: () =>
|
|
224
|
-
NOOP_SPAN: () =>
|
|
225
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
226
|
-
NoopSpan: () =>
|
|
227
|
-
OTELIDGenerator: () =>
|
|
228
|
-
ObjectFetcher: () =>
|
|
222
|
+
Logger: () => _chunkXLLGRXGRjs.Logger,
|
|
223
|
+
LoginInvalidOrgError: () => _chunkXLLGRXGRjs.LoginInvalidOrgError,
|
|
224
|
+
NOOP_SPAN: () => _chunkXLLGRXGRjs.NOOP_SPAN,
|
|
225
|
+
NOOP_SPAN_PERMALINK: () => _chunkXLLGRXGRjs.NOOP_SPAN_PERMALINK,
|
|
226
|
+
NoopSpan: () => _chunkXLLGRXGRjs.NoopSpan,
|
|
227
|
+
OTELIDGenerator: () => _chunkXLLGRXGRjs.OTELIDGenerator,
|
|
228
|
+
ObjectFetcher: () => _chunkXLLGRXGRjs.ObjectFetcher,
|
|
229
229
|
Project: () => Project2,
|
|
230
230
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
231
|
-
Prompt: () =>
|
|
231
|
+
Prompt: () => _chunkXLLGRXGRjs.Prompt,
|
|
232
232
|
PromptBuilder: () => PromptBuilder,
|
|
233
|
-
ReadonlyAttachment: () =>
|
|
234
|
-
ReadonlyExperiment: () =>
|
|
233
|
+
ReadonlyAttachment: () => _chunkXLLGRXGRjs.ReadonlyAttachment,
|
|
234
|
+
ReadonlyExperiment: () => _chunkXLLGRXGRjs.ReadonlyExperiment,
|
|
235
235
|
Reporter: () => Reporter,
|
|
236
236
|
ScorerBuilder: () => ScorerBuilder,
|
|
237
237
|
SpanFetcher: () => SpanFetcher,
|
|
238
|
-
SpanImpl: () =>
|
|
239
|
-
TRACEPARENT_HEADER: () =>
|
|
240
|
-
TRACESTATE_HEADER: () =>
|
|
241
|
-
TestBackgroundLogger: () =>
|
|
238
|
+
SpanImpl: () => _chunkXLLGRXGRjs.SpanImpl,
|
|
239
|
+
TRACEPARENT_HEADER: () => _chunkXLLGRXGRjs.TRACEPARENT_HEADER,
|
|
240
|
+
TRACESTATE_HEADER: () => _chunkXLLGRXGRjs.TRACESTATE_HEADER,
|
|
241
|
+
TestBackgroundLogger: () => _chunkXLLGRXGRjs.TestBackgroundLogger,
|
|
242
242
|
ToolBuilder: () => ToolBuilder,
|
|
243
|
-
UUIDGenerator: () =>
|
|
244
|
-
X_CACHED_HEADER: () =>
|
|
245
|
-
_exportsForTestingOnly: () =>
|
|
246
|
-
_internalGetGlobalState: () =>
|
|
247
|
-
_internalIso: () =>
|
|
248
|
-
_internalSetInitialState: () =>
|
|
249
|
-
addAzureBlobHeaders: () =>
|
|
243
|
+
UUIDGenerator: () => _chunkXLLGRXGRjs.UUIDGenerator,
|
|
244
|
+
X_CACHED_HEADER: () => _chunkXLLGRXGRjs.X_CACHED_HEADER,
|
|
245
|
+
_exportsForTestingOnly: () => _chunkXLLGRXGRjs._exportsForTestingOnly,
|
|
246
|
+
_internalGetGlobalState: () => _chunkXLLGRXGRjs._internalGetGlobalState,
|
|
247
|
+
_internalIso: () => _chunk6Z5S7VOUjs.isomorph_default,
|
|
248
|
+
_internalSetInitialState: () => _chunkXLLGRXGRjs._internalSetInitialState,
|
|
249
|
+
addAzureBlobHeaders: () => _chunkXLLGRXGRjs.addAzureBlobHeaders,
|
|
250
250
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
251
|
-
braintrustAISDKTelemetry: () =>
|
|
251
|
+
braintrustAISDKTelemetry: () => _chunkXLLGRXGRjs.braintrustAISDKTelemetry,
|
|
252
252
|
braintrustEveHook: () => braintrustEveHook,
|
|
253
253
|
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
254
|
-
braintrustFlueInstrumentation: () =>
|
|
255
|
-
braintrustFlueObserver: () =>
|
|
256
|
-
braintrustStreamChunkSchema: () =>
|
|
254
|
+
braintrustFlueInstrumentation: () => _chunkXLLGRXGRjs.braintrustFlueInstrumentation,
|
|
255
|
+
braintrustFlueObserver: () => _chunkXLLGRXGRjs.braintrustFlueObserver,
|
|
256
|
+
braintrustStreamChunkSchema: () => _chunkXLLGRXGRjs.braintrustStreamChunkSchema,
|
|
257
257
|
buildLocalSummary: () => buildLocalSummary,
|
|
258
|
-
collectAnthropicSession: () =>
|
|
259
|
-
configureInstrumentation: () =>
|
|
260
|
-
constructLogs3OverflowRequest: () =>
|
|
261
|
-
createFinalValuePassThroughStream: () =>
|
|
262
|
-
currentExperiment: () =>
|
|
263
|
-
currentLogger: () =>
|
|
264
|
-
currentSpan: () =>
|
|
265
|
-
deepCopyEvent: () =>
|
|
258
|
+
collectAnthropicSession: () => _chunkXLLGRXGRjs.collectAnthropicSession,
|
|
259
|
+
configureInstrumentation: () => _chunkXLLGRXGRjs.configureInstrumentation,
|
|
260
|
+
constructLogs3OverflowRequest: () => _chunkXLLGRXGRjs.constructLogs3OverflowRequest,
|
|
261
|
+
createFinalValuePassThroughStream: () => _chunkXLLGRXGRjs.createFinalValuePassThroughStream,
|
|
262
|
+
currentExperiment: () => _chunkXLLGRXGRjs.currentExperiment,
|
|
263
|
+
currentLogger: () => _chunkXLLGRXGRjs.currentLogger,
|
|
264
|
+
currentSpan: () => _chunkXLLGRXGRjs.currentSpan,
|
|
265
|
+
deepCopyEvent: () => _chunkXLLGRXGRjs.deepCopyEvent,
|
|
266
266
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
267
267
|
defineDurableEval: () => defineDurableEval,
|
|
268
|
-
deserializePlainStringAsJSON: () =>
|
|
269
|
-
devNullWritableStream: () =>
|
|
268
|
+
deserializePlainStringAsJSON: () => _chunkXLLGRXGRjs.deserializePlainStringAsJSON,
|
|
269
|
+
devNullWritableStream: () => _chunkXLLGRXGRjs.devNullWritableStream,
|
|
270
270
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
271
271
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
272
|
-
extractTraceContextFromHeaders: () =>
|
|
273
|
-
flush: () =>
|
|
274
|
-
getContextManager: () =>
|
|
275
|
-
getIdGenerator: () =>
|
|
276
|
-
getPromptVersions: () =>
|
|
277
|
-
getSpanParentObject: () =>
|
|
278
|
-
getTemplateRenderer: () =>
|
|
272
|
+
extractTraceContextFromHeaders: () => _chunkXLLGRXGRjs.extractTraceContextFromHeaders,
|
|
273
|
+
flush: () => _chunkXLLGRXGRjs.flush,
|
|
274
|
+
getContextManager: () => _chunkXLLGRXGRjs.getContextManager,
|
|
275
|
+
getIdGenerator: () => _chunkXLLGRXGRjs.getIdGenerator,
|
|
276
|
+
getPromptVersions: () => _chunkXLLGRXGRjs.getPromptVersions,
|
|
277
|
+
getSpanParentObject: () => _chunkXLLGRXGRjs.getSpanParentObject,
|
|
278
|
+
getTemplateRenderer: () => _chunkXLLGRXGRjs.getTemplateRenderer,
|
|
279
279
|
graph: () => graph_framework_exports,
|
|
280
|
-
init: () =>
|
|
281
|
-
initDataset: () =>
|
|
282
|
-
initExperiment: () =>
|
|
280
|
+
init: () => _chunkXLLGRXGRjs.init,
|
|
281
|
+
initDataset: () => _chunkXLLGRXGRjs.initDataset,
|
|
282
|
+
initExperiment: () => _chunkXLLGRXGRjs.initExperiment,
|
|
283
283
|
initFunction: () => initFunction,
|
|
284
|
-
initLogger: () =>
|
|
284
|
+
initLogger: () => _chunkXLLGRXGRjs.initLogger,
|
|
285
285
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
286
|
-
injectTraceContext: () =>
|
|
286
|
+
injectTraceContext: () => _chunkXLLGRXGRjs.injectTraceContext,
|
|
287
287
|
invoke: () => invoke,
|
|
288
|
-
isTemplateFormat: () =>
|
|
289
|
-
loadParameters: () =>
|
|
290
|
-
loadPrompt: () =>
|
|
291
|
-
log: () =>
|
|
292
|
-
logError: () =>
|
|
293
|
-
login: () =>
|
|
294
|
-
loginToState: () =>
|
|
295
|
-
logs3OverflowUploadSchema: () =>
|
|
296
|
-
newId: () =>
|
|
297
|
-
parseCachedHeader: () =>
|
|
298
|
-
parseTemplateFormat: () =>
|
|
299
|
-
permalink: () =>
|
|
300
|
-
pickLogs3OverflowObjectIds: () =>
|
|
288
|
+
isTemplateFormat: () => _chunkXLLGRXGRjs.isTemplateFormat,
|
|
289
|
+
loadParameters: () => _chunkXLLGRXGRjs.loadParameters,
|
|
290
|
+
loadPrompt: () => _chunkXLLGRXGRjs.loadPrompt,
|
|
291
|
+
log: () => _chunkXLLGRXGRjs.log,
|
|
292
|
+
logError: () => _chunkXLLGRXGRjs.logError,
|
|
293
|
+
login: () => _chunkXLLGRXGRjs.login,
|
|
294
|
+
loginToState: () => _chunkXLLGRXGRjs.loginToState,
|
|
295
|
+
logs3OverflowUploadSchema: () => _chunkXLLGRXGRjs.logs3OverflowUploadSchema,
|
|
296
|
+
newId: () => _chunkXLLGRXGRjs.newId,
|
|
297
|
+
parseCachedHeader: () => _chunkXLLGRXGRjs.parseCachedHeader,
|
|
298
|
+
parseTemplateFormat: () => _chunkXLLGRXGRjs.parseTemplateFormat,
|
|
299
|
+
permalink: () => _chunkXLLGRXGRjs.permalink,
|
|
300
|
+
pickLogs3OverflowObjectIds: () => _chunkXLLGRXGRjs.pickLogs3OverflowObjectIds,
|
|
301
301
|
projects: () => projects,
|
|
302
302
|
promptContentsSchema: () => promptContentsSchema,
|
|
303
303
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
304
304
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
305
305
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
306
|
-
registerOtelFlush: () =>
|
|
306
|
+
registerOtelFlush: () => _chunkXLLGRXGRjs.registerOtelFlush,
|
|
307
307
|
registerSandbox: () => registerSandbox,
|
|
308
|
-
registerTemplatePlugin: () =>
|
|
309
|
-
renderMessage: () =>
|
|
310
|
-
renderPromptParams: () =>
|
|
311
|
-
renderTemplateContent: () =>
|
|
308
|
+
registerTemplatePlugin: () => _chunkXLLGRXGRjs.registerTemplatePlugin,
|
|
309
|
+
renderMessage: () => _chunkXLLGRXGRjs.renderMessage,
|
|
310
|
+
renderPromptParams: () => _chunkXLLGRXGRjs.renderPromptParams,
|
|
311
|
+
renderTemplateContent: () => _chunkXLLGRXGRjs.renderTemplateContent,
|
|
312
312
|
reportFailures: () => reportFailures,
|
|
313
313
|
runEvaluator: () => runEvaluator,
|
|
314
|
-
setFetch: () =>
|
|
315
|
-
setMaskingFunction: () =>
|
|
316
|
-
spanComponentsToObjectId: () =>
|
|
317
|
-
startSpan: () =>
|
|
318
|
-
summarize: () =>
|
|
319
|
-
templateRegistry: () =>
|
|
320
|
-
toolFunctionDefinitionSchema: () =>
|
|
321
|
-
traceable: () =>
|
|
322
|
-
traced: () =>
|
|
323
|
-
updateSpan: () =>
|
|
324
|
-
uploadLogs3OverflowPayload: () =>
|
|
325
|
-
utf8ByteLength: () =>
|
|
326
|
-
withCurrent: () =>
|
|
327
|
-
withDataset: () =>
|
|
328
|
-
withExperiment: () =>
|
|
329
|
-
withLogger: () =>
|
|
330
|
-
withParent: () =>
|
|
314
|
+
setFetch: () => _chunkXLLGRXGRjs.setFetch,
|
|
315
|
+
setMaskingFunction: () => _chunkXLLGRXGRjs.setMaskingFunction,
|
|
316
|
+
spanComponentsToObjectId: () => _chunkXLLGRXGRjs.spanComponentsToObjectId,
|
|
317
|
+
startSpan: () => _chunkXLLGRXGRjs.startSpan,
|
|
318
|
+
summarize: () => _chunkXLLGRXGRjs.summarize,
|
|
319
|
+
templateRegistry: () => _chunkXLLGRXGRjs.templateRegistry,
|
|
320
|
+
toolFunctionDefinitionSchema: () => _chunkXLLGRXGRjs.ToolFunctionDefinition,
|
|
321
|
+
traceable: () => _chunkXLLGRXGRjs.traceable,
|
|
322
|
+
traced: () => _chunkXLLGRXGRjs.traced,
|
|
323
|
+
updateSpan: () => _chunkXLLGRXGRjs.updateSpan,
|
|
324
|
+
uploadLogs3OverflowPayload: () => _chunkXLLGRXGRjs.uploadLogs3OverflowPayload,
|
|
325
|
+
utf8ByteLength: () => _chunkXLLGRXGRjs.utf8ByteLength,
|
|
326
|
+
withCurrent: () => _chunkXLLGRXGRjs.withCurrent,
|
|
327
|
+
withDataset: () => _chunkXLLGRXGRjs.withDataset,
|
|
328
|
+
withExperiment: () => _chunkXLLGRXGRjs.withExperiment,
|
|
329
|
+
withLogger: () => _chunkXLLGRXGRjs.withLogger,
|
|
330
|
+
withParent: () => _chunkXLLGRXGRjs.withParent,
|
|
331
331
|
wrapAISDK: () => wrapAISDK,
|
|
332
332
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
333
333
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -349,7 +349,7 @@ _chunkBBE7SNRVjs.__export.call(void 0, exports_exports, {
|
|
|
349
349
|
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
350
350
|
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
351
351
|
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
352
|
-
wrapMastraAgent: () =>
|
|
352
|
+
wrapMastraAgent: () => _chunkXLLGRXGRjs.wrapMastraAgent,
|
|
353
353
|
wrapMistral: () => wrapMistral,
|
|
354
354
|
wrapOllama: () => wrapOllama,
|
|
355
355
|
wrapOpenAI: () => wrapOpenAI,
|
|
@@ -359,7 +359,7 @@ _chunkBBE7SNRVjs.__export.call(void 0, exports_exports, {
|
|
|
359
359
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
360
360
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
361
361
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
362
|
-
wrapTraced: () =>
|
|
362
|
+
wrapTraced: () => _chunkXLLGRXGRjs.wrapTraced,
|
|
363
363
|
wrapVitest: () => wrapVitest,
|
|
364
364
|
wrapVoyageAI: () => wrapVoyageAI
|
|
365
365
|
});
|
|
@@ -368,7 +368,7 @@ _chunkBBE7SNRVjs.__export.call(void 0, exports_exports, {
|
|
|
368
368
|
var _v3 = require('zod/v3');
|
|
369
369
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
370
370
|
async function registerSandbox(options) {
|
|
371
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
371
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, )));
|
|
372
372
|
await state.login({
|
|
373
373
|
apiKey: options.apiKey,
|
|
374
374
|
appUrl: options.appUrl,
|
|
@@ -409,7 +409,7 @@ async function registerSandbox(options) {
|
|
|
409
409
|
evaluatorDefinitions
|
|
410
410
|
)) {
|
|
411
411
|
const functionName = evalName;
|
|
412
|
-
const functionSlug =
|
|
412
|
+
const functionSlug = _chunkXLLGRXGRjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
413
413
|
const functionDef = {
|
|
414
414
|
project_id: projectId,
|
|
415
415
|
org_name: state.orgName,
|
|
@@ -480,7 +480,7 @@ async function invoke(args) {
|
|
|
480
480
|
projectId,
|
|
481
481
|
...functionIdArgs
|
|
482
482
|
} = args;
|
|
483
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
483
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, )));
|
|
484
484
|
await state.login({
|
|
485
485
|
orgName,
|
|
486
486
|
apiKey,
|
|
@@ -488,8 +488,8 @@ async function invoke(args) {
|
|
|
488
488
|
forceLogin,
|
|
489
489
|
fetch
|
|
490
490
|
});
|
|
491
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
492
|
-
const functionId =
|
|
491
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkXLLGRXGRjs.getSpanParentObject.call(void 0, ).export();
|
|
492
|
+
const functionId = _chunkXLLGRXGRjs.FunctionId.safeParse({
|
|
493
493
|
function_id: functionIdArgs.function_id,
|
|
494
494
|
project_name: functionIdArgs.projectName,
|
|
495
495
|
slug: functionIdArgs.slug,
|
|
@@ -532,7 +532,7 @@ async function invoke(args) {
|
|
|
532
532
|
if (!resp.body) {
|
|
533
533
|
throw new Error("Received empty stream body");
|
|
534
534
|
}
|
|
535
|
-
return new (0,
|
|
535
|
+
return new (0, _chunkXLLGRXGRjs.BraintrustStream)(resp.body);
|
|
536
536
|
} else {
|
|
537
537
|
const data = await resp.json();
|
|
538
538
|
return schema ? schema.parse(data) : data;
|
|
@@ -544,7 +544,7 @@ function initFunction({
|
|
|
544
544
|
version,
|
|
545
545
|
state
|
|
546
546
|
}) {
|
|
547
|
-
const s = _nullishCoalesce(state, () => (
|
|
547
|
+
const s = _nullishCoalesce(state, () => ( _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, )));
|
|
548
548
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
549
549
|
const f = async (input) => {
|
|
550
550
|
return await invoke({
|
|
@@ -622,22 +622,22 @@ function responsesProxy(openai) {
|
|
|
622
622
|
if (name === "create" && typeof target.create === "function") {
|
|
623
623
|
return wrapResponsesAsync(
|
|
624
624
|
target.create.bind(target),
|
|
625
|
-
|
|
625
|
+
_chunk6Z5S7VOUjs.openAIChannels.responsesCreate
|
|
626
626
|
);
|
|
627
627
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
628
628
|
return wrapResponsesSyncStream(
|
|
629
629
|
target.stream.bind(target),
|
|
630
|
-
|
|
630
|
+
_chunk6Z5S7VOUjs.openAIChannels.responsesStream
|
|
631
631
|
);
|
|
632
632
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
633
633
|
return wrapResponsesAsync(
|
|
634
634
|
target.parse.bind(target),
|
|
635
|
-
|
|
635
|
+
_chunk6Z5S7VOUjs.openAIChannels.responsesParse
|
|
636
636
|
);
|
|
637
637
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
638
638
|
return wrapResponsesAsync(
|
|
639
639
|
target.compact.bind(target),
|
|
640
|
-
|
|
640
|
+
_chunk6Z5S7VOUjs.openAIChannels.responsesCompact
|
|
641
641
|
);
|
|
642
642
|
}
|
|
643
643
|
return Reflect.get(target, name, receiver);
|
|
@@ -781,7 +781,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
781
781
|
const { span_info, params } = splitSpanInfo(
|
|
782
782
|
allParams
|
|
783
783
|
);
|
|
784
|
-
return
|
|
784
|
+
return _chunk6Z5S7VOUjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
785
785
|
async () => await completion(params),
|
|
786
786
|
{ arguments: [params], span_info }
|
|
787
787
|
);
|
|
@@ -792,7 +792,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
792
792
|
const { span_info, params } = splitSpanInfo(
|
|
793
793
|
allParams
|
|
794
794
|
);
|
|
795
|
-
return
|
|
795
|
+
return _chunk6Z5S7VOUjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
796
796
|
() => completion(params),
|
|
797
797
|
{ arguments: [params], span_info }
|
|
798
798
|
);
|
|
@@ -808,7 +808,7 @@ function wrapChatCompletion(completion) {
|
|
|
808
808
|
if (!executionPromise) {
|
|
809
809
|
executionPromise = (async () => {
|
|
810
810
|
const traceContext = createChannelContext(
|
|
811
|
-
|
|
811
|
+
_chunk6Z5S7VOUjs.openAIChannels.chatCompletionsCreate,
|
|
812
812
|
params,
|
|
813
813
|
span_info
|
|
814
814
|
);
|
|
@@ -818,7 +818,7 @@ function wrapChatCompletion(completion) {
|
|
|
818
818
|
options
|
|
819
819
|
);
|
|
820
820
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
821
|
-
|
|
821
|
+
_chunk6Z5S7VOUjs.openAIChannels.chatCompletionsCreate,
|
|
822
822
|
traceContext,
|
|
823
823
|
completionPromise
|
|
824
824
|
);
|
|
@@ -829,7 +829,7 @@ function wrapChatCompletion(completion) {
|
|
|
829
829
|
options
|
|
830
830
|
);
|
|
831
831
|
const { data, response } = await tracePromiseWithResponse(
|
|
832
|
-
|
|
832
|
+
_chunk6Z5S7VOUjs.openAIChannels.chatCompletionsCreate,
|
|
833
833
|
traceContext,
|
|
834
834
|
completionResponse
|
|
835
835
|
);
|
|
@@ -872,8 +872,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
872
872
|
return createLazyAPIPromise(ensureExecuted);
|
|
873
873
|
};
|
|
874
874
|
}
|
|
875
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
876
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
875
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunk6Z5S7VOUjs.openAIChannels.embeddingsCreate);
|
|
876
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunk6Z5S7VOUjs.openAIChannels.moderationsCreate);
|
|
877
877
|
|
|
878
878
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
879
879
|
function isModuleNamespace(obj) {
|
|
@@ -905,6 +905,13 @@ function wrapAISDK(aiSDK, options = {}) {
|
|
|
905
905
|
switch (prop) {
|
|
906
906
|
case "generateText":
|
|
907
907
|
return wrapGenerateText(typedAISDK.generateText, options, typedAISDK);
|
|
908
|
+
case "generateImage":
|
|
909
|
+
case "experimental_generateImage":
|
|
910
|
+
return typeof original === "function" ? wrapGenerateImage(
|
|
911
|
+
original,
|
|
912
|
+
options,
|
|
913
|
+
typedAISDK
|
|
914
|
+
) : original;
|
|
908
915
|
case "streamText":
|
|
909
916
|
return wrapStreamText(typedAISDK.streamText, options, typedAISDK);
|
|
910
917
|
case "generateObject":
|
|
@@ -976,7 +983,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
976
983
|
return wrapHarnessAgentGenerate(
|
|
977
984
|
original,
|
|
978
985
|
harnessAgent,
|
|
979
|
-
|
|
986
|
+
_chunk6Z5S7VOUjs.harnessAgentChannels.generate,
|
|
980
987
|
"HarnessAgent.generate",
|
|
981
988
|
options
|
|
982
989
|
);
|
|
@@ -984,7 +991,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
984
991
|
return wrapHarnessAgentStream(
|
|
985
992
|
original,
|
|
986
993
|
harnessAgent,
|
|
987
|
-
|
|
994
|
+
_chunk6Z5S7VOUjs.harnessAgentChannels.stream,
|
|
988
995
|
"HarnessAgent.stream",
|
|
989
996
|
options
|
|
990
997
|
);
|
|
@@ -992,7 +999,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
992
999
|
return wrapHarnessAgentGenerate(
|
|
993
1000
|
original,
|
|
994
1001
|
harnessAgent,
|
|
995
|
-
|
|
1002
|
+
_chunk6Z5S7VOUjs.harnessAgentChannels.continueGenerate,
|
|
996
1003
|
"HarnessAgent.continueGenerate",
|
|
997
1004
|
options
|
|
998
1005
|
);
|
|
@@ -1000,7 +1007,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
1000
1007
|
return wrapHarnessAgentStream(
|
|
1001
1008
|
original,
|
|
1002
1009
|
harnessAgent,
|
|
1003
|
-
|
|
1010
|
+
_chunk6Z5S7VOUjs.harnessAgentChannels.continueStream,
|
|
1004
1011
|
"HarnessAgent.continueStream",
|
|
1005
1012
|
options
|
|
1006
1013
|
);
|
|
@@ -1023,7 +1030,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
1023
1030
|
};
|
|
1024
1031
|
var wrapHarnessAgentCreateSession = (createSession, instance) => {
|
|
1025
1032
|
const wrapper = function(params) {
|
|
1026
|
-
return
|
|
1033
|
+
return _chunk6Z5S7VOUjs.harnessAgentChannels.createSession.tracePromise(
|
|
1027
1034
|
() => params === void 0 ? createSession.call(instance) : createSession.call(instance, params),
|
|
1028
1035
|
createAISDKChannelContext(_nullishCoalesce(params, () => ( {})), { self: instance })
|
|
1029
1036
|
);
|
|
@@ -1069,15 +1076,15 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
1069
1076
|
};
|
|
1070
1077
|
function generateChannelForAgent(agentName) {
|
|
1071
1078
|
if (agentName === "ToolLoopAgent") {
|
|
1072
|
-
return
|
|
1079
|
+
return _chunk6Z5S7VOUjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
1073
1080
|
}
|
|
1074
|
-
return
|
|
1081
|
+
return _chunk6Z5S7VOUjs.aiSDKChannels.agentGenerate;
|
|
1075
1082
|
}
|
|
1076
1083
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
1077
1084
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
1078
1085
|
return (params) => {
|
|
1079
1086
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
1080
|
-
if (workflowAgent &&
|
|
1087
|
+
if (workflowAgent && _chunkXLLGRXGRjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
1081
1088
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
1082
1089
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
1083
1090
|
}
|
|
@@ -1096,12 +1103,12 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
1096
1103
|
};
|
|
1097
1104
|
function streamChannelForAgent(agentName) {
|
|
1098
1105
|
if (agentName === "ToolLoopAgent") {
|
|
1099
|
-
return
|
|
1106
|
+
return _chunk6Z5S7VOUjs.aiSDKChannels.toolLoopAgentStream;
|
|
1100
1107
|
}
|
|
1101
1108
|
if (agentName === "WorkflowAgent") {
|
|
1102
|
-
return
|
|
1109
|
+
return _chunk6Z5S7VOUjs.aiSDKChannels.workflowAgentStream;
|
|
1103
1110
|
}
|
|
1104
|
-
return
|
|
1111
|
+
return _chunk6Z5S7VOUjs.aiSDKChannels.agentStream;
|
|
1105
1112
|
}
|
|
1106
1113
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
1107
1114
|
const wrapper = async function(allParams) {
|
|
@@ -1125,7 +1132,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
1125
1132
|
};
|
|
1126
1133
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
1127
1134
|
return makeGenerateTextWrapper(
|
|
1128
|
-
|
|
1135
|
+
_chunk6Z5S7VOUjs.aiSDKChannels.generateText,
|
|
1129
1136
|
"generateText",
|
|
1130
1137
|
generateText,
|
|
1131
1138
|
{ aiSDK },
|
|
@@ -1134,13 +1141,39 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
1134
1141
|
};
|
|
1135
1142
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
1136
1143
|
return makeGenerateTextWrapper(
|
|
1137
|
-
|
|
1144
|
+
_chunk6Z5S7VOUjs.aiSDKChannels.generateObject,
|
|
1138
1145
|
"generateObject",
|
|
1139
1146
|
generateObject,
|
|
1140
1147
|
{ aiSDK },
|
|
1141
1148
|
options
|
|
1142
1149
|
);
|
|
1143
1150
|
};
|
|
1151
|
+
var wrapGenerateImage = (generateImage, options = {}, aiSDK) => {
|
|
1152
|
+
return makeGenerateImageWrapper(generateImage, { aiSDK }, options);
|
|
1153
|
+
};
|
|
1154
|
+
var makeGenerateImageWrapper = (generateImage, contextOptions = {}, options = {}) => {
|
|
1155
|
+
const wrapper = async function(allParams) {
|
|
1156
|
+
const { span_info, ...params } = allParams;
|
|
1157
|
+
const tracedParams = { ...params };
|
|
1158
|
+
return _chunk6Z5S7VOUjs.aiSDKChannels.generateImage.tracePromise(
|
|
1159
|
+
() => generateImage(tracedParams),
|
|
1160
|
+
createAISDKChannelContext(tracedParams, {
|
|
1161
|
+
aiSDK: contextOptions.aiSDK,
|
|
1162
|
+
denyOutputPaths: options.denyOutputPaths,
|
|
1163
|
+
self: contextOptions.self,
|
|
1164
|
+
span_info: mergeSpanInfo(span_info, {
|
|
1165
|
+
name: "generateImage",
|
|
1166
|
+
spanType: contextOptions.spanType
|
|
1167
|
+
})
|
|
1168
|
+
})
|
|
1169
|
+
);
|
|
1170
|
+
};
|
|
1171
|
+
Object.defineProperty(wrapper, "name", {
|
|
1172
|
+
value: "generateImage",
|
|
1173
|
+
writable: false
|
|
1174
|
+
});
|
|
1175
|
+
return wrapper;
|
|
1176
|
+
};
|
|
1144
1177
|
var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {}) => {
|
|
1145
1178
|
const wrapper = async function(allParams) {
|
|
1146
1179
|
const { span_info, ...params } = allParams;
|
|
@@ -1163,7 +1196,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
1163
1196
|
};
|
|
1164
1197
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
1165
1198
|
return makeEmbedWrapper(
|
|
1166
|
-
|
|
1199
|
+
_chunk6Z5S7VOUjs.aiSDKChannels.embed,
|
|
1167
1200
|
"embed",
|
|
1168
1201
|
embed,
|
|
1169
1202
|
{ aiSDK },
|
|
@@ -1172,7 +1205,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1172
1205
|
};
|
|
1173
1206
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1174
1207
|
return makeEmbedWrapper(
|
|
1175
|
-
|
|
1208
|
+
_chunk6Z5S7VOUjs.aiSDKChannels.embedMany,
|
|
1176
1209
|
"embedMany",
|
|
1177
1210
|
embedMany,
|
|
1178
1211
|
{ aiSDK },
|
|
@@ -1183,7 +1216,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1183
1216
|
const wrapper = async function(allParams) {
|
|
1184
1217
|
const { span_info, ...params } = allParams;
|
|
1185
1218
|
const tracedParams = { ...params };
|
|
1186
|
-
return
|
|
1219
|
+
return _chunk6Z5S7VOUjs.aiSDKChannels.rerank.tracePromise(
|
|
1187
1220
|
() => rerank(tracedParams),
|
|
1188
1221
|
createAISDKChannelContext(tracedParams, {
|
|
1189
1222
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1222,7 +1255,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1222
1255
|
};
|
|
1223
1256
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1224
1257
|
return makeStreamWrapper(
|
|
1225
|
-
|
|
1258
|
+
_chunk6Z5S7VOUjs.aiSDKChannels.streamText,
|
|
1226
1259
|
"streamText",
|
|
1227
1260
|
streamText,
|
|
1228
1261
|
{ aiSDK },
|
|
@@ -1231,7 +1264,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1231
1264
|
};
|
|
1232
1265
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1233
1266
|
return makeStreamWrapper(
|
|
1234
|
-
|
|
1267
|
+
_chunk6Z5S7VOUjs.aiSDKChannels.streamObject,
|
|
1235
1268
|
"streamObject",
|
|
1236
1269
|
streamObject,
|
|
1237
1270
|
{ aiSDK },
|
|
@@ -1303,19 +1336,19 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1303
1336
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1304
1337
|
// propagate those via async local storage
|
|
1305
1338
|
async doGenerate(options) {
|
|
1306
|
-
const span =
|
|
1307
|
-
|
|
1339
|
+
const span = _chunkXLLGRXGRjs.startSpan.call(void 0,
|
|
1340
|
+
_chunk6Z5S7VOUjs.withSpanInstrumentationName.call(void 0,
|
|
1308
1341
|
{
|
|
1309
1342
|
name: "Chat Completion",
|
|
1310
1343
|
spanAttributes: {
|
|
1311
1344
|
type: "llm"
|
|
1312
1345
|
}
|
|
1313
1346
|
},
|
|
1314
|
-
|
|
1347
|
+
_chunk6Z5S7VOUjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1315
1348
|
)
|
|
1316
1349
|
);
|
|
1317
1350
|
const { prompt, mode, ...rest } = options;
|
|
1318
|
-
const startTime =
|
|
1351
|
+
const startTime = _chunkXLLGRXGRjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1319
1352
|
try {
|
|
1320
1353
|
const ret = await this.model.doGenerate(options);
|
|
1321
1354
|
span.log({
|
|
@@ -1327,12 +1360,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1327
1360
|
},
|
|
1328
1361
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1329
1362
|
metrics: {
|
|
1330
|
-
time_to_first_token:
|
|
1331
|
-
tokens: !
|
|
1363
|
+
time_to_first_token: _chunkXLLGRXGRjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1364
|
+
tokens: !_chunkXLLGRXGRjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1332
1365
|
prompt_tokens: _optionalChain([ret, 'access', _26 => _26.usage, 'optionalAccess', _27 => _27.promptTokens]),
|
|
1333
1366
|
completion_tokens: _optionalChain([ret, 'access', _28 => _28.usage, 'optionalAccess', _29 => _29.completionTokens]),
|
|
1334
|
-
cached:
|
|
1335
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _30 => _30.rawResponse, 'optionalAccess', _31 => _31.headers, 'optionalAccess', _32 => _32[
|
|
1367
|
+
cached: _chunkXLLGRXGRjs.parseCachedHeader.call(void 0,
|
|
1368
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _30 => _30.rawResponse, 'optionalAccess', _31 => _31.headers, 'optionalAccess', _32 => _32[_chunkXLLGRXGRjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _33 => _33.rawResponse, 'optionalAccess', _34 => _34.headers, 'optionalAccess', _35 => _35[_chunkXLLGRXGRjs.LEGACY_CACHED_HEADER]])))
|
|
1336
1369
|
)
|
|
1337
1370
|
}
|
|
1338
1371
|
});
|
|
@@ -1343,16 +1376,16 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1343
1376
|
}
|
|
1344
1377
|
async doStream(options) {
|
|
1345
1378
|
const { prompt, mode, ...rest } = options;
|
|
1346
|
-
const startTime =
|
|
1347
|
-
const span =
|
|
1348
|
-
|
|
1379
|
+
const startTime = _chunkXLLGRXGRjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1380
|
+
const span = _chunkXLLGRXGRjs.startSpan.call(void 0,
|
|
1381
|
+
_chunk6Z5S7VOUjs.withSpanInstrumentationName.call(void 0,
|
|
1349
1382
|
{
|
|
1350
1383
|
name: "Chat Completion",
|
|
1351
1384
|
spanAttributes: {
|
|
1352
1385
|
type: "llm"
|
|
1353
1386
|
}
|
|
1354
1387
|
},
|
|
1355
|
-
|
|
1388
|
+
_chunk6Z5S7VOUjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1356
1389
|
)
|
|
1357
1390
|
);
|
|
1358
1391
|
span.log({
|
|
@@ -1383,7 +1416,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1383
1416
|
new TransformStream({
|
|
1384
1417
|
transform(chunk, controller) {
|
|
1385
1418
|
if (time_to_first_token === void 0) {
|
|
1386
|
-
time_to_first_token =
|
|
1419
|
+
time_to_first_token = _chunkXLLGRXGRjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1387
1420
|
span.log({ metrics: { time_to_first_token } });
|
|
1388
1421
|
}
|
|
1389
1422
|
switch (chunk.type) {
|
|
@@ -1428,11 +1461,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1428
1461
|
),
|
|
1429
1462
|
metrics: {
|
|
1430
1463
|
time_to_first_token,
|
|
1431
|
-
tokens: !
|
|
1464
|
+
tokens: !_chunkXLLGRXGRjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1432
1465
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _36 => _36.promptTokens]),
|
|
1433
1466
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _37 => _37.completionTokens]),
|
|
1434
|
-
cached:
|
|
1435
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _38 => _38.rawResponse, 'optionalAccess', _39 => _39.headers, 'optionalAccess', _40 => _40[
|
|
1467
|
+
cached: _chunkXLLGRXGRjs.parseCachedHeader.call(void 0,
|
|
1468
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _38 => _38.rawResponse, 'optionalAccess', _39 => _39.headers, 'optionalAccess', _40 => _40[_chunkXLLGRXGRjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _41 => _41.rawResponse, 'optionalAccess', _42 => _42.headers, 'optionalAccess', _43 => _43[_chunkXLLGRXGRjs.LEGACY_CACHED_HEADER]])))
|
|
1436
1469
|
)
|
|
1437
1470
|
}
|
|
1438
1471
|
});
|
|
@@ -1617,12 +1650,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1617
1650
|
anthropicMetadata.usage,
|
|
1618
1651
|
"cache_creation_input_tokens"
|
|
1619
1652
|
) || 0;
|
|
1620
|
-
const cacheTokens =
|
|
1653
|
+
const cacheTokens = _chunkXLLGRXGRjs.extractAnthropicCacheTokens.call(void 0,
|
|
1621
1654
|
cacheReadTokens,
|
|
1622
1655
|
cacheCreationTokens
|
|
1623
1656
|
);
|
|
1624
1657
|
Object.assign(metrics, cacheTokens);
|
|
1625
|
-
return
|
|
1658
|
+
return _chunkXLLGRXGRjs.toNumericMetrics.call(void 0, _chunkXLLGRXGRjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1626
1659
|
}
|
|
1627
1660
|
}
|
|
1628
1661
|
return metrics;
|
|
@@ -1694,7 +1727,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1694
1727
|
model: modelFromWrapGenerate
|
|
1695
1728
|
}) => {
|
|
1696
1729
|
const rawInput = extractInput(params);
|
|
1697
|
-
const processedInput =
|
|
1730
|
+
const processedInput = _chunkXLLGRXGRjs.processInputAttachments.call(void 0, rawInput);
|
|
1698
1731
|
const spanArgs = {
|
|
1699
1732
|
name: _optionalChain([config, 'access', _60 => _60.spanInfo, 'optionalAccess', _61 => _61.name]) || "ai-sdk.doGenerate",
|
|
1700
1733
|
spanAttributes: {
|
|
@@ -1709,8 +1742,8 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1709
1742
|
}
|
|
1710
1743
|
}
|
|
1711
1744
|
};
|
|
1712
|
-
const span =
|
|
1713
|
-
|
|
1745
|
+
const span = _chunkXLLGRXGRjs.startSpan.call(void 0,
|
|
1746
|
+
_chunk6Z5S7VOUjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunk6Z5S7VOUjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1714
1747
|
);
|
|
1715
1748
|
try {
|
|
1716
1749
|
const result = await doGenerate();
|
|
@@ -1758,7 +1791,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1758
1791
|
},
|
|
1759
1792
|
wrapStream: async ({ doStream, params }) => {
|
|
1760
1793
|
const rawInput = extractInput(params);
|
|
1761
|
-
const processedInput =
|
|
1794
|
+
const processedInput = _chunkXLLGRXGRjs.processInputAttachments.call(void 0, rawInput);
|
|
1762
1795
|
const spanArgs = {
|
|
1763
1796
|
name: _optionalChain([config, 'access', _69 => _69.spanInfo, 'optionalAccess', _70 => _70.name]) || "ai-sdk.doStream",
|
|
1764
1797
|
spanAttributes: {
|
|
@@ -1773,8 +1806,8 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1773
1806
|
}
|
|
1774
1807
|
}
|
|
1775
1808
|
};
|
|
1776
|
-
const span =
|
|
1777
|
-
|
|
1809
|
+
const span = _chunkXLLGRXGRjs.startSpan.call(void 0,
|
|
1810
|
+
_chunk6Z5S7VOUjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunk6Z5S7VOUjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1778
1811
|
);
|
|
1779
1812
|
try {
|
|
1780
1813
|
const { stream, ...rest } = await doStream();
|
|
@@ -1891,7 +1924,7 @@ function braintrustEveHook(options) {
|
|
|
1891
1924
|
}
|
|
1892
1925
|
};
|
|
1893
1926
|
}
|
|
1894
|
-
function
|
|
1927
|
+
function createLegacyEveInstrumentation(options) {
|
|
1895
1928
|
const state = options.defineState(EVE_TRACE_STATE_KEY, emptyEveTraceState);
|
|
1896
1929
|
return {
|
|
1897
1930
|
events: {
|
|
@@ -1899,7 +1932,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1899
1932
|
try {
|
|
1900
1933
|
captureEveModelInput(state, input);
|
|
1901
1934
|
} catch (error) {
|
|
1902
|
-
|
|
1935
|
+
_chunk6Z5S7VOUjs.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1903
1936
|
}
|
|
1904
1937
|
}
|
|
1905
1938
|
},
|
|
@@ -1909,7 +1942,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1909
1942
|
};
|
|
1910
1943
|
}
|
|
1911
1944
|
function isEveHandleMessageStreamEvent(event) {
|
|
1912
|
-
return
|
|
1945
|
+
return _chunkXLLGRXGRjs.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1913
1946
|
}
|
|
1914
1947
|
var ResumedEveSpan = class {
|
|
1915
1948
|
constructor(reference) {
|
|
@@ -1930,7 +1963,7 @@ var ResumedEveSpan = class {
|
|
|
1930
1963
|
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1931
1964
|
...event.metrics
|
|
1932
1965
|
};
|
|
1933
|
-
|
|
1966
|
+
_chunkXLLGRXGRjs.updateSpan.call(void 0, {
|
|
1934
1967
|
exported: this.reference.exported,
|
|
1935
1968
|
...this.reference.startEvent,
|
|
1936
1969
|
...event,
|
|
@@ -1939,7 +1972,7 @@ var ResumedEveSpan = class {
|
|
|
1939
1972
|
}
|
|
1940
1973
|
end(args) {
|
|
1941
1974
|
if (this.endTime === void 0) {
|
|
1942
|
-
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => (
|
|
1975
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => ( _chunkXLLGRXGRjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1943
1976
|
this.log({ metrics: { end: this.endTime } });
|
|
1944
1977
|
}
|
|
1945
1978
|
return this.endTime;
|
|
@@ -1951,13 +1984,13 @@ var EveBridge = (_class = class {
|
|
|
1951
1984
|
}
|
|
1952
1985
|
|
|
1953
1986
|
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1954
|
-
__init2() {this.completedToolKeys = new (0,
|
|
1987
|
+
__init2() {this.completedToolKeys = new (0, _chunkXLLGRXGRjs.LRUCache)({
|
|
1955
1988
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1956
1989
|
})}
|
|
1957
|
-
__init3() {this.toolsByCallKey = new (0,
|
|
1990
|
+
__init3() {this.toolsByCallKey = new (0, _chunkXLLGRXGRjs.LRUCache)({
|
|
1958
1991
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1959
1992
|
})}
|
|
1960
|
-
__init4() {this.turnsByKey = new (0,
|
|
1993
|
+
__init4() {this.turnsByKey = new (0, _chunkXLLGRXGRjs.LRUCache)({
|
|
1961
1994
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1962
1995
|
})}
|
|
1963
1996
|
async startEveSpan(args) {
|
|
@@ -1968,7 +2001,7 @@ var EveBridge = (_class = class {
|
|
|
1968
2001
|
if (reference) {
|
|
1969
2002
|
return new ResumedEveSpan(reference);
|
|
1970
2003
|
}
|
|
1971
|
-
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => (
|
|
2004
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => ( _chunkXLLGRXGRjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1972
2005
|
const parentSpanIds = _optionalChain([args, 'optionalAccess', _82 => _82.parentSpanIds]);
|
|
1973
2006
|
const startEvent = {
|
|
1974
2007
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1980,12 +2013,12 @@ var EveBridge = (_class = class {
|
|
|
1980
2013
|
},
|
|
1981
2014
|
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
1982
2015
|
};
|
|
1983
|
-
const span =
|
|
1984
|
-
|
|
1985
|
-
() =>
|
|
1986
|
-
|
|
2016
|
+
const span = _chunkXLLGRXGRjs.withCurrent.call(void 0,
|
|
2017
|
+
_chunkXLLGRXGRjs.NOOP_SPAN,
|
|
2018
|
+
() => _chunkXLLGRXGRjs._internalStartSpanWithInitialMerge.call(void 0,
|
|
2019
|
+
_chunk6Z5S7VOUjs.withSpanInstrumentationName.call(void 0,
|
|
1987
2020
|
{ ...args, startTime },
|
|
1988
|
-
|
|
2021
|
+
_chunk6Z5S7VOUjs.INSTRUMENTATION_NAMES.EVE
|
|
1989
2022
|
)
|
|
1990
2023
|
)
|
|
1991
2024
|
);
|
|
@@ -2013,7 +2046,7 @@ var EveBridge = (_class = class {
|
|
|
2013
2046
|
};
|
|
2014
2047
|
});
|
|
2015
2048
|
} catch (error) {
|
|
2016
|
-
|
|
2049
|
+
_chunk6Z5S7VOUjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
2017
2050
|
}
|
|
2018
2051
|
return span;
|
|
2019
2052
|
}
|
|
@@ -2100,7 +2133,7 @@ var EveBridge = (_class = class {
|
|
|
2100
2133
|
}
|
|
2101
2134
|
}
|
|
2102
2135
|
} catch (error) {
|
|
2103
|
-
|
|
2136
|
+
_chunk6Z5S7VOUjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
2104
2137
|
}
|
|
2105
2138
|
};
|
|
2106
2139
|
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
@@ -2328,7 +2361,7 @@ var EveBridge = (_class = class {
|
|
|
2328
2361
|
return;
|
|
2329
2362
|
}
|
|
2330
2363
|
const existingMessage = eveOutputMessage(step.output);
|
|
2331
|
-
const existingToolCalls =
|
|
2364
|
+
const existingToolCalls = _chunkXLLGRXGRjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2332
2365
|
step.output = mergeEveReasoning(
|
|
2333
2366
|
[
|
|
2334
2367
|
{
|
|
@@ -2392,11 +2425,11 @@ var EveBridge = (_class = class {
|
|
|
2392
2425
|
return;
|
|
2393
2426
|
}
|
|
2394
2427
|
const toolCallsById = /* @__PURE__ */ new Map();
|
|
2395
|
-
if (Array.isArray(step.output) &&
|
|
2428
|
+
if (Array.isArray(step.output) && _chunkXLLGRXGRjs.isObject.call(void 0, step.output[0])) {
|
|
2396
2429
|
const message = step.output[0]["message"];
|
|
2397
|
-
if (
|
|
2430
|
+
if (_chunkXLLGRXGRjs.isObject.call(void 0, message) && Array.isArray(message["tool_calls"])) {
|
|
2398
2431
|
for (const toolCall of message["tool_calls"]) {
|
|
2399
|
-
if (
|
|
2432
|
+
if (_chunkXLLGRXGRjs.isObject.call(void 0, toolCall) && typeof toolCall["id"] === "string") {
|
|
2400
2433
|
toolCallsById.set(toolCall["id"], toolCall);
|
|
2401
2434
|
}
|
|
2402
2435
|
}
|
|
@@ -2605,7 +2638,7 @@ var EveBridge = (_class = class {
|
|
|
2605
2638
|
};
|
|
2606
2639
|
step.metrics = { ...step.metrics, ...metrics };
|
|
2607
2640
|
const sessionId = sessionIdFromContext(ctx);
|
|
2608
|
-
if (Array.isArray(step.output) &&
|
|
2641
|
+
if (Array.isArray(step.output) && _chunkXLLGRXGRjs.isObject.call(void 0, step.output[0])) {
|
|
2609
2642
|
const finishReason = step.output[0].finish_reason;
|
|
2610
2643
|
if (typeof finishReason !== "string") {
|
|
2611
2644
|
step.output[0].finish_reason = normalizedFinishReason(
|
|
@@ -2943,10 +2976,10 @@ var EveBridge = (_class = class {
|
|
|
2943
2976
|
return state;
|
|
2944
2977
|
}
|
|
2945
2978
|
async startTurnSpan(sessionId, event, ctx, metadata) {
|
|
2946
|
-
const session =
|
|
2947
|
-
const parent =
|
|
2948
|
-
const parentTurn =
|
|
2949
|
-
const parentLineage =
|
|
2979
|
+
const session = _chunkXLLGRXGRjs.isObject.call(void 0, ctx) ? ctx["session"] : void 0;
|
|
2980
|
+
const parent = _chunkXLLGRXGRjs.isObject.call(void 0, session) ? session["parent"] : void 0;
|
|
2981
|
+
const parentTurn = _chunkXLLGRXGRjs.isObject.call(void 0, parent) ? parent["turn"] : void 0;
|
|
2982
|
+
const parentLineage = _chunkXLLGRXGRjs.isObject.call(void 0, parent) && typeof parent["callId"] === "string" && typeof parent["sessionId"] === "string" && _chunkXLLGRXGRjs.isObject.call(void 0, parentTurn) && typeof parentTurn["id"] === "string" ? {
|
|
2950
2983
|
callId: parent["callId"],
|
|
2951
2984
|
sessionId: parent["sessionId"],
|
|
2952
2985
|
turnId: parentTurn["id"]
|
|
@@ -3053,10 +3086,10 @@ var EveBridge = (_class = class {
|
|
|
3053
3086
|
}
|
|
3054
3087
|
async flushInstrumentation() {
|
|
3055
3088
|
try {
|
|
3056
|
-
await
|
|
3089
|
+
await _chunkXLLGRXGRjs.flush.call(void 0, );
|
|
3057
3090
|
return true;
|
|
3058
3091
|
} catch (error) {
|
|
3059
|
-
|
|
3092
|
+
_chunk6Z5S7VOUjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
3060
3093
|
return false;
|
|
3061
3094
|
}
|
|
3062
3095
|
}
|
|
@@ -3071,12 +3104,12 @@ function emptyEveTraceState() {
|
|
|
3071
3104
|
};
|
|
3072
3105
|
}
|
|
3073
3106
|
function normalizeEveTraceState(state) {
|
|
3074
|
-
if (!
|
|
3107
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, state)) {
|
|
3075
3108
|
return emptyEveTraceState();
|
|
3076
3109
|
}
|
|
3077
|
-
const metadata =
|
|
3110
|
+
const metadata = _chunkXLLGRXGRjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
3078
3111
|
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
3079
|
-
if (!
|
|
3112
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, entry)) {
|
|
3080
3113
|
return [];
|
|
3081
3114
|
}
|
|
3082
3115
|
const exported = entry["exported"];
|
|
@@ -3085,11 +3118,11 @@ function normalizeEveTraceState(state) {
|
|
|
3085
3118
|
const rowId = entry["rowId"];
|
|
3086
3119
|
const spanId = entry["spanId"];
|
|
3087
3120
|
const startEvent = entry["startEvent"];
|
|
3088
|
-
const startEventCreated =
|
|
3089
|
-
const startEventMetrics =
|
|
3090
|
-
const startEventSpanAttributes =
|
|
3091
|
-
const startEventSpanParents =
|
|
3092
|
-
const normalizedStartEvent = typeof startEventCreated === "string" &&
|
|
3121
|
+
const startEventCreated = _chunkXLLGRXGRjs.isObject.call(void 0, startEvent) ? startEvent["created"] : void 0;
|
|
3122
|
+
const startEventMetrics = _chunkXLLGRXGRjs.isObject.call(void 0, startEvent) ? startEvent["metrics"] : void 0;
|
|
3123
|
+
const startEventSpanAttributes = _chunkXLLGRXGRjs.isObject.call(void 0, startEvent) ? startEvent["span_attributes"] : void 0;
|
|
3124
|
+
const startEventSpanParents = _chunkXLLGRXGRjs.isObject.call(void 0, startEvent) ? startEvent["span_parents"] : void 0;
|
|
3125
|
+
const normalizedStartEvent = typeof startEventCreated === "string" && _chunkXLLGRXGRjs.isObject.call(void 0, startEventMetrics) && typeof startEventMetrics["start"] === "number" && Number.isFinite(startEventMetrics["start"]) && _chunkXLLGRXGRjs.isObject.call(void 0, startEventSpanAttributes) && Array.isArray(startEventSpanParents) && startEventSpanParents.every(
|
|
3093
3126
|
(parent) => typeof parent === "string"
|
|
3094
3127
|
) ? {
|
|
3095
3128
|
created: startEventCreated,
|
|
@@ -3109,7 +3142,7 @@ function normalizeEveTraceState(state) {
|
|
|
3109
3142
|
] : [];
|
|
3110
3143
|
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
3111
3144
|
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
3112
|
-
if (!
|
|
3145
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, entry)) {
|
|
3113
3146
|
return [];
|
|
3114
3147
|
}
|
|
3115
3148
|
const key = entry["key"];
|
|
@@ -3117,7 +3150,7 @@ function normalizeEveTraceState(state) {
|
|
|
3117
3150
|
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
3118
3151
|
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
3119
3152
|
const reasoningBlocks = Array.isArray(state["reasoningBlocks"]) ? state["reasoningBlocks"].flatMap((entry) => {
|
|
3120
|
-
if (!
|
|
3153
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, entry)) {
|
|
3121
3154
|
return [];
|
|
3122
3155
|
}
|
|
3123
3156
|
const content = entry["content"];
|
|
@@ -3132,7 +3165,7 @@ function normalizeEveTraceState(state) {
|
|
|
3132
3165
|
] : [];
|
|
3133
3166
|
}).slice(-MAX_STORED_REASONING_BLOCKS) : [];
|
|
3134
3167
|
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
3135
|
-
if (!
|
|
3168
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, entry)) {
|
|
3136
3169
|
return [];
|
|
3137
3170
|
}
|
|
3138
3171
|
const ordinal = entry["ordinal"];
|
|
@@ -3209,14 +3242,14 @@ function clearStoredEveReasoning(state, sessionId, turnId, stepIndex) {
|
|
|
3209
3242
|
});
|
|
3210
3243
|
}
|
|
3211
3244
|
function eveOutputMessage(output) {
|
|
3212
|
-
return Array.isArray(output) &&
|
|
3245
|
+
return Array.isArray(output) && _chunkXLLGRXGRjs.isObject.call(void 0, output[0]) ? output[0]["message"] : void 0;
|
|
3213
3246
|
}
|
|
3214
3247
|
function mergeEveReasoning(output, reasoning) {
|
|
3215
3248
|
if (reasoning.length === 0) {
|
|
3216
3249
|
return output;
|
|
3217
3250
|
}
|
|
3218
|
-
const choice = Array.isArray(output) &&
|
|
3219
|
-
const message =
|
|
3251
|
+
const choice = Array.isArray(output) && _chunkXLLGRXGRjs.isObject.call(void 0, output[0]) ? output[0] : {};
|
|
3252
|
+
const message = _chunkXLLGRXGRjs.isObject.call(void 0, choice["message"]) ? choice["message"] : {};
|
|
3220
3253
|
return [
|
|
3221
3254
|
{
|
|
3222
3255
|
...choice,
|
|
@@ -3270,7 +3303,7 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3270
3303
|
});
|
|
3271
3304
|
return input;
|
|
3272
3305
|
} catch (error) {
|
|
3273
|
-
|
|
3306
|
+
_chunk6Z5S7VOUjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
3274
3307
|
return void 0;
|
|
3275
3308
|
}
|
|
3276
3309
|
}
|
|
@@ -3279,8 +3312,10 @@ function capturedModelInput(modelInput) {
|
|
|
3279
3312
|
const value = [];
|
|
3280
3313
|
if (typeof instructions === "string") {
|
|
3281
3314
|
value.push({ content: instructions, role: "system" });
|
|
3282
|
-
} else if (instructions) {
|
|
3315
|
+
} else if (Array.isArray(instructions)) {
|
|
3283
3316
|
value.push(...instructions.map(capturedEveModelMessage));
|
|
3317
|
+
} else if (instructions) {
|
|
3318
|
+
value.push(capturedEveModelMessage(instructions));
|
|
3284
3319
|
}
|
|
3285
3320
|
value.push(...messages.map(capturedEveModelMessage));
|
|
3286
3321
|
try {
|
|
@@ -3408,14 +3443,14 @@ function capturedEveModelContentPart(part) {
|
|
|
3408
3443
|
}
|
|
3409
3444
|
function isCapturedModelInput(input) {
|
|
3410
3445
|
return Array.isArray(input) && input.every(
|
|
3411
|
-
(message) =>
|
|
3446
|
+
(message) => _chunkXLLGRXGRjs.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(_chunkXLLGRXGRjs.isObject))
|
|
3412
3447
|
);
|
|
3413
3448
|
}
|
|
3414
3449
|
function llmInputKey(sessionId, turnId, stepIndex) {
|
|
3415
3450
|
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3416
3451
|
}
|
|
3417
3452
|
function modelMetadataFromRuntime(runtime) {
|
|
3418
|
-
if (!
|
|
3453
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, runtime)) {
|
|
3419
3454
|
return {};
|
|
3420
3455
|
}
|
|
3421
3456
|
const modelId = runtime["modelId"];
|
|
@@ -3438,11 +3473,11 @@ function modelMetadataFromModelId(modelId) {
|
|
|
3438
3473
|
};
|
|
3439
3474
|
}
|
|
3440
3475
|
function sessionIdFromContext(ctx) {
|
|
3441
|
-
if (!
|
|
3476
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, ctx)) {
|
|
3442
3477
|
return void 0;
|
|
3443
3478
|
}
|
|
3444
3479
|
const session = ctx["session"];
|
|
3445
|
-
if (!
|
|
3480
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, session)) {
|
|
3446
3481
|
return void 0;
|
|
3447
3482
|
}
|
|
3448
3483
|
const id = session["id"];
|
|
@@ -3453,19 +3488,19 @@ function toolMetadataFromTurn(turn) {
|
|
|
3453
3488
|
return metadata;
|
|
3454
3489
|
}
|
|
3455
3490
|
function isToolCallAction(action) {
|
|
3456
|
-
return
|
|
3491
|
+
return _chunkXLLGRXGRjs.isObject.call(void 0, action) && action["kind"] === "tool-call" && typeof action["callId"] === "string" && typeof action["toolName"] === "string" && _chunkXLLGRXGRjs.isObject.call(void 0, action["input"]);
|
|
3457
3492
|
}
|
|
3458
3493
|
function isLocalSubagentCallAction(action) {
|
|
3459
|
-
return
|
|
3494
|
+
return _chunkXLLGRXGRjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkXLLGRXGRjs.isObject.call(void 0, action["input"]);
|
|
3460
3495
|
}
|
|
3461
3496
|
function isTraceableActionRequest(action) {
|
|
3462
3497
|
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3463
3498
|
}
|
|
3464
3499
|
function isToolResult(result) {
|
|
3465
|
-
return
|
|
3500
|
+
return _chunkXLLGRXGRjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3466
3501
|
}
|
|
3467
3502
|
function isSubagentResult(result) {
|
|
3468
|
-
return
|
|
3503
|
+
return _chunkXLLGRXGRjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3469
3504
|
}
|
|
3470
3505
|
function normalizedFinishReason(finishReason) {
|
|
3471
3506
|
switch (finishReason) {
|
|
@@ -3524,6 +3559,464 @@ async function deterministicEveId(...parts) {
|
|
|
3524
3559
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
3525
3560
|
}
|
|
3526
3561
|
|
|
3562
|
+
// src/instrumentation/plugins/eve-provider.ts
|
|
3563
|
+
var MAX_EVE_PROVIDER_CACHE_ENTRIES = 1e4;
|
|
3564
|
+
function createEveInstrumentationProvider(options = {}) {
|
|
3565
|
+
const bridge = new EveProviderBridge(options.metadata);
|
|
3566
|
+
return {
|
|
3567
|
+
capture: "content",
|
|
3568
|
+
events: {
|
|
3569
|
+
"action.completed": (event, context) => bridge.handleActionTerminal(event, context),
|
|
3570
|
+
"action.failed": (event, context) => bridge.handleActionTerminal(event, context),
|
|
3571
|
+
"action.started": (event, context) => bridge.handleActionStarted(event, context),
|
|
3572
|
+
"model.call.completed": (event, context) => bridge.handleModelTerminal(event, context),
|
|
3573
|
+
"model.call.failed": (event, context) => bridge.handleModelTerminal(event, context),
|
|
3574
|
+
"model.call.started": (event, context) => bridge.handleModelStarted(event, context),
|
|
3575
|
+
"step.attempt.completed": (event) => bridge.handleStepAttemptTerminal(event),
|
|
3576
|
+
"step.attempt.failed": (event) => bridge.handleStepAttemptTerminal(event),
|
|
3577
|
+
"turn.cancelled": (event, context) => bridge.handleTurnTerminal(event, context),
|
|
3578
|
+
"turn.completed": (event, context) => bridge.handleTurnTerminal(event, context),
|
|
3579
|
+
"turn.failed": (event, context) => bridge.handleTurnTerminal(event, context),
|
|
3580
|
+
"turn.started": (event, context) => bridge.handleTurnStarted(event, context)
|
|
3581
|
+
},
|
|
3582
|
+
flush: _chunkXLLGRXGRjs.flush,
|
|
3583
|
+
setup: options.setup
|
|
3584
|
+
};
|
|
3585
|
+
}
|
|
3586
|
+
var EveProviderBridge = (_class2 = class {
|
|
3587
|
+
constructor(metadata) {;_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);
|
|
3588
|
+
this.metadata = metadata;
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
__init5() {this.activeActions = /* @__PURE__ */ new Map()}
|
|
3592
|
+
__init6() {this.activeModels = /* @__PURE__ */ new Map()}
|
|
3593
|
+
__init7() {this.modelsByAttempt = /* @__PURE__ */ new Map()}
|
|
3594
|
+
__init8() {this.settledOperations = new (0, _chunkXLLGRXGRjs.LRUCache)({
|
|
3595
|
+
max: MAX_EVE_PROVIDER_CACHE_ENTRIES
|
|
3596
|
+
})}
|
|
3597
|
+
__init9() {this.turns = new (0, _chunkXLLGRXGRjs.LRUCache)({
|
|
3598
|
+
max: MAX_EVE_PROVIDER_CACHE_ENTRIES
|
|
3599
|
+
})}
|
|
3600
|
+
async handleTurnStarted(event, context) {
|
|
3601
|
+
await this.contain("turn start", async () => {
|
|
3602
|
+
if (this.settledOperations.has(event.idempotencyKey)) {
|
|
3603
|
+
context.state.set({ skip: true });
|
|
3604
|
+
return;
|
|
3605
|
+
}
|
|
3606
|
+
const { rowId, spanId } = await generateEveIds(
|
|
3607
|
+
"turn",
|
|
3608
|
+
event.idempotencyKey
|
|
3609
|
+
);
|
|
3610
|
+
const key = turnKey2(event.sessionId, event.turnId);
|
|
3611
|
+
const stored = storedSpan(context);
|
|
3612
|
+
if (stored && "exported" in stored && stored.rootSpanId) {
|
|
3613
|
+
this.turns.set(key, { rootSpanId: stored.rootSpanId, spanId });
|
|
3614
|
+
return;
|
|
3615
|
+
}
|
|
3616
|
+
let rootSpanId = spanId;
|
|
3617
|
+
let parentSpanId;
|
|
3618
|
+
if (event.parentLineage) {
|
|
3619
|
+
const parentTurnKey = turnKey2(
|
|
3620
|
+
event.parentLineage.sessionId,
|
|
3621
|
+
event.parentLineage.turnId
|
|
3622
|
+
);
|
|
3623
|
+
const parentTurn = this.turns.get(parentTurnKey);
|
|
3624
|
+
rootSpanId = await _asyncNullishCoalesce(await _asyncOptionalChain([parentTurn, 'optionalAccess', async _116 => _116.rootSpanId]), async () => ( // Eve propagates the root session through every nested subagent. Use
|
|
3625
|
+
// it instead of the immediate parent session when no ancestor ran
|
|
3626
|
+
// in-process.
|
|
3627
|
+
(await generateEveIds(
|
|
3628
|
+
"turn",
|
|
3629
|
+
turnIdempotencyKey(
|
|
3630
|
+
event.rootSessionId,
|
|
3631
|
+
event.parentLineage.turnId
|
|
3632
|
+
)
|
|
3633
|
+
)).spanId));
|
|
3634
|
+
parentSpanId = (await generateEveIds(
|
|
3635
|
+
"subagent",
|
|
3636
|
+
actionIdempotencyKey(
|
|
3637
|
+
event.parentLineage.sessionId,
|
|
3638
|
+
event.parentLineage.turnId,
|
|
3639
|
+
event.parentLineage.callId
|
|
3640
|
+
)
|
|
3641
|
+
)).spanId;
|
|
3642
|
+
}
|
|
3643
|
+
const metadata = this.spanMetadata(event.sessionId);
|
|
3644
|
+
const span = await this.startSpan(
|
|
3645
|
+
context,
|
|
3646
|
+
{
|
|
3647
|
+
event: { id: rowId, metadata },
|
|
3648
|
+
name: "eve.turn",
|
|
3649
|
+
parentSpanIds: parentSpanId ? { rootSpanId, spanId: parentSpanId } : { parentSpanIds: [], rootSpanId },
|
|
3650
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
3651
|
+
spanId
|
|
3652
|
+
},
|
|
3653
|
+
rootSpanId
|
|
3654
|
+
);
|
|
3655
|
+
_optionalChain([span, 'optionalAccess', _117 => _117.log, 'call', _118 => _118({ metadata })]);
|
|
3656
|
+
this.turns.set(key, {
|
|
3657
|
+
rootSpanId,
|
|
3658
|
+
spanId
|
|
3659
|
+
});
|
|
3660
|
+
});
|
|
3661
|
+
}
|
|
3662
|
+
async handleTurnTerminal(event, context) {
|
|
3663
|
+
await this.contain("turn terminal", async () => {
|
|
3664
|
+
if (this.settledOperations.has(event.idempotencyKey)) {
|
|
3665
|
+
context.state.set(void 0);
|
|
3666
|
+
return;
|
|
3667
|
+
}
|
|
3668
|
+
const error = event.type === "turn.failed" ? event.error : void 0;
|
|
3669
|
+
this.drainActionsForTurn(event.sessionId, event.turnId, error);
|
|
3670
|
+
const stored = storedSpan(context);
|
|
3671
|
+
if (stored && "exported" in stored) {
|
|
3672
|
+
_chunkXLLGRXGRjs.updateSpan.call(void 0, {
|
|
3673
|
+
exported: stored.exported,
|
|
3674
|
+
...error !== void 0 ? { error } : {},
|
|
3675
|
+
metrics: { end: Date.now() / 1e3 }
|
|
3676
|
+
});
|
|
3677
|
+
}
|
|
3678
|
+
this.settledOperations.set(event.idempotencyKey, true);
|
|
3679
|
+
context.state.set(void 0);
|
|
3680
|
+
this.turns.delete(turnKey2(event.sessionId, event.turnId));
|
|
3681
|
+
});
|
|
3682
|
+
}
|
|
3683
|
+
async handleModelStarted(event, context) {
|
|
3684
|
+
await this.contain("model start", async () => {
|
|
3685
|
+
if (this.settledOperations.has(event.idempotencyKey)) {
|
|
3686
|
+
context.state.set({ skip: true });
|
|
3687
|
+
return;
|
|
3688
|
+
}
|
|
3689
|
+
const parent = await this.parentForScope(event.scope);
|
|
3690
|
+
const { rowId, spanId } = await generateEveIds(
|
|
3691
|
+
"step",
|
|
3692
|
+
event.idempotencyKey
|
|
3693
|
+
);
|
|
3694
|
+
const input = event.input ? capturedModelInput(event.input) : void 0;
|
|
3695
|
+
const metadata = {
|
|
3696
|
+
...this.spanMetadata(event.scope.sessionId),
|
|
3697
|
+
model: event.model.modelId,
|
|
3698
|
+
provider: event.model.provider
|
|
3699
|
+
};
|
|
3700
|
+
const span = await this.startSpan(context, {
|
|
3701
|
+
event: {
|
|
3702
|
+
id: rowId,
|
|
3703
|
+
...input !== void 0 ? { input } : {},
|
|
3704
|
+
metadata
|
|
3705
|
+
},
|
|
3706
|
+
name: "eve.step",
|
|
3707
|
+
parentSpanIds: parent,
|
|
3708
|
+
spanAttributes: { type: "llm" /* LLM */ },
|
|
3709
|
+
spanId
|
|
3710
|
+
});
|
|
3711
|
+
if (!span) return;
|
|
3712
|
+
span.log({ ...input !== void 0 ? { input } : {}, metadata });
|
|
3713
|
+
this.activeModels.set(event.idempotencyKey, {
|
|
3714
|
+
span,
|
|
3715
|
+
turnKey: turnKey2(event.scope.sessionId, event.scope.turnId)
|
|
3716
|
+
});
|
|
3717
|
+
const keys = _nullishCoalesce(this.modelsByAttempt.get(event.scope.attemptId), () => ( /* @__PURE__ */ new Set()));
|
|
3718
|
+
keys.add(event.idempotencyKey);
|
|
3719
|
+
this.modelsByAttempt.set(event.scope.attemptId, keys);
|
|
3720
|
+
});
|
|
3721
|
+
}
|
|
3722
|
+
async handleModelTerminal(event, context) {
|
|
3723
|
+
await this.contain("model terminal", async () => {
|
|
3724
|
+
if (this.settledOperations.has(event.idempotencyKey)) {
|
|
3725
|
+
context.state.set(void 0);
|
|
3726
|
+
return;
|
|
3727
|
+
}
|
|
3728
|
+
const active = this.activeModels.get(event.idempotencyKey);
|
|
3729
|
+
if (active) {
|
|
3730
|
+
const span = active.span;
|
|
3731
|
+
if (event.type === "model.call.failed") {
|
|
3732
|
+
if (event.error !== void 0) span.log({ error: event.error });
|
|
3733
|
+
} else {
|
|
3734
|
+
span.log({
|
|
3735
|
+
metrics: usageMetrics(event.usage),
|
|
3736
|
+
output: modelOutput(event)
|
|
3737
|
+
});
|
|
3738
|
+
}
|
|
3739
|
+
span.end();
|
|
3740
|
+
} else {
|
|
3741
|
+
const stored = storedSpan(context);
|
|
3742
|
+
if (stored && "exported" in stored) {
|
|
3743
|
+
_chunkXLLGRXGRjs.updateSpan.call(void 0, {
|
|
3744
|
+
exported: stored.exported,
|
|
3745
|
+
...event.type === "model.call.failed" ? event.error !== void 0 ? { error: event.error } : {} : { output: modelOutput(event) },
|
|
3746
|
+
metrics: {
|
|
3747
|
+
...event.type === "model.call.completed" ? usageMetrics(event.usage) : {},
|
|
3748
|
+
end: Date.now() / 1e3
|
|
3749
|
+
}
|
|
3750
|
+
});
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
this.settledOperations.set(event.idempotencyKey, true);
|
|
3754
|
+
this.forgetModel(event.scope.attemptId, event.idempotencyKey);
|
|
3755
|
+
context.state.set(void 0);
|
|
3756
|
+
});
|
|
3757
|
+
}
|
|
3758
|
+
async handleActionStarted(event, context) {
|
|
3759
|
+
await this.contain("action start", async () => {
|
|
3760
|
+
if (event.kind === "load-skill" || this.settledOperations.has(event.idempotencyKey)) {
|
|
3761
|
+
context.state.set({ skip: true });
|
|
3762
|
+
return;
|
|
3763
|
+
}
|
|
3764
|
+
const parent = await this.parentForScope(event.scope);
|
|
3765
|
+
const { rowId, spanId } = await generateEveIds(
|
|
3766
|
+
event.kind === "subagent-call" ? "subagent" : "tool",
|
|
3767
|
+
event.idempotencyKey
|
|
3768
|
+
);
|
|
3769
|
+
const metadata = {
|
|
3770
|
+
...this.spanMetadata(event.scope.sessionId),
|
|
3771
|
+
"eve.action_kind": event.kind
|
|
3772
|
+
};
|
|
3773
|
+
const span = await this.startSpan(context, {
|
|
3774
|
+
event: {
|
|
3775
|
+
id: rowId,
|
|
3776
|
+
...event.input !== void 0 ? { input: event.input } : {},
|
|
3777
|
+
metadata
|
|
3778
|
+
},
|
|
3779
|
+
name: event.name,
|
|
3780
|
+
parentSpanIds: parent,
|
|
3781
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
3782
|
+
spanId
|
|
3783
|
+
});
|
|
3784
|
+
if (!span) return;
|
|
3785
|
+
span.log({
|
|
3786
|
+
...event.input !== void 0 ? { input: event.input } : {},
|
|
3787
|
+
metadata
|
|
3788
|
+
});
|
|
3789
|
+
this.activeActions.set(event.idempotencyKey, {
|
|
3790
|
+
span,
|
|
3791
|
+
turnKey: turnKey2(event.scope.sessionId, event.scope.turnId)
|
|
3792
|
+
});
|
|
3793
|
+
});
|
|
3794
|
+
}
|
|
3795
|
+
async handleActionTerminal(event, context) {
|
|
3796
|
+
await this.contain("action terminal", async () => {
|
|
3797
|
+
if (this.settledOperations.has(event.idempotencyKey)) {
|
|
3798
|
+
context.state.set(void 0);
|
|
3799
|
+
return;
|
|
3800
|
+
}
|
|
3801
|
+
const stored = storedSpan(context);
|
|
3802
|
+
if (_optionalChain([stored, 'optionalAccess', _119 => _119.skip])) {
|
|
3803
|
+
context.state.set(void 0);
|
|
3804
|
+
return;
|
|
3805
|
+
}
|
|
3806
|
+
const active = this.activeActions.get(event.idempotencyKey);
|
|
3807
|
+
const end = _nullishCoalesce(finiteTimestamp(event.acceptedAtMs), () => ( Date.now()));
|
|
3808
|
+
if (active) {
|
|
3809
|
+
const span = active.span;
|
|
3810
|
+
if (event.type === "action.failed") {
|
|
3811
|
+
span.log({
|
|
3812
|
+
error: _nullishCoalesce(event.error, () => ( new Error(_nullishCoalesce(event.errorCode, () => ( `Eve action ${event.outcome}`)))))
|
|
3813
|
+
});
|
|
3814
|
+
} else if (event.output.type === "error") {
|
|
3815
|
+
span.log({
|
|
3816
|
+
error: _nullishCoalesce(event.output.error, () => ( new Error("Eve action returned an error")))
|
|
3817
|
+
});
|
|
3818
|
+
} else {
|
|
3819
|
+
span.log({ output: event.output.output });
|
|
3820
|
+
}
|
|
3821
|
+
span.end({ endTime: end / 1e3 });
|
|
3822
|
+
} else {
|
|
3823
|
+
const stored2 = storedSpan(context);
|
|
3824
|
+
if (stored2 && "exported" in stored2) {
|
|
3825
|
+
_chunkXLLGRXGRjs.updateSpan.call(void 0, {
|
|
3826
|
+
exported: stored2.exported,
|
|
3827
|
+
...event.type === "action.failed" ? {
|
|
3828
|
+
error: _nullishCoalesce(event.error, () => ( new Error(_nullishCoalesce(event.errorCode, () => ( `Eve action ${event.outcome}`)))))
|
|
3829
|
+
} : event.output.type === "error" ? {
|
|
3830
|
+
error: _nullishCoalesce(event.output.error, () => ( new Error("Eve action returned an error")))
|
|
3831
|
+
} : { output: event.output.output },
|
|
3832
|
+
metrics: { end: end / 1e3 }
|
|
3833
|
+
});
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
this.settledOperations.set(event.idempotencyKey, true);
|
|
3837
|
+
this.activeActions.delete(event.idempotencyKey);
|
|
3838
|
+
context.state.set(void 0);
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3841
|
+
handleStepAttemptTerminal(event) {
|
|
3842
|
+
void this.contain("step attempt terminal", () => {
|
|
3843
|
+
const keys = this.modelsByAttempt.get(event.scope.attemptId);
|
|
3844
|
+
if (!keys) return;
|
|
3845
|
+
for (const key of keys) {
|
|
3846
|
+
const active = this.activeModels.get(key);
|
|
3847
|
+
if (!active) continue;
|
|
3848
|
+
if (event.type === "step.attempt.failed" && event.error !== void 0) {
|
|
3849
|
+
active.span.log({ error: event.error });
|
|
3850
|
+
}
|
|
3851
|
+
active.span.end();
|
|
3852
|
+
this.activeModels.delete(key);
|
|
3853
|
+
}
|
|
3854
|
+
this.modelsByAttempt.delete(event.scope.attemptId);
|
|
3855
|
+
});
|
|
3856
|
+
}
|
|
3857
|
+
async parentForScope(scope) {
|
|
3858
|
+
const key = turnKey2(scope.sessionId, scope.turnId);
|
|
3859
|
+
const known = this.turns.get(key);
|
|
3860
|
+
if (known) {
|
|
3861
|
+
return { rootSpanId: known.rootSpanId, spanId: known.spanId };
|
|
3862
|
+
}
|
|
3863
|
+
const [{ spanId }, { spanId: rootSpanId }] = await Promise.all([
|
|
3864
|
+
generateEveIds("turn", turnIdempotencyKey(scope.sessionId, scope.turnId)),
|
|
3865
|
+
generateEveIds(
|
|
3866
|
+
"turn",
|
|
3867
|
+
turnIdempotencyKey(
|
|
3868
|
+
_nullishCoalesce(scope.rootSessionId, () => ( scope.sessionId)),
|
|
3869
|
+
scope.turnId
|
|
3870
|
+
)
|
|
3871
|
+
)
|
|
3872
|
+
]);
|
|
3873
|
+
return { rootSpanId, spanId };
|
|
3874
|
+
}
|
|
3875
|
+
async startSpan(context, args, rootSpanId) {
|
|
3876
|
+
const span = _chunkXLLGRXGRjs.withCurrent.call(void 0,
|
|
3877
|
+
_chunkXLLGRXGRjs.NOOP_SPAN,
|
|
3878
|
+
() => _chunkXLLGRXGRjs._internalStartSpanWithInitialMerge.call(void 0,
|
|
3879
|
+
_chunk6Z5S7VOUjs.withSpanInstrumentationName.call(void 0, _nullishCoalesce(args, () => ( {})), _chunk6Z5S7VOUjs.INSTRUMENTATION_NAMES.EVE)
|
|
3880
|
+
)
|
|
3881
|
+
);
|
|
3882
|
+
try {
|
|
3883
|
+
context.state.set({
|
|
3884
|
+
exported: await span.export(),
|
|
3885
|
+
...rootSpanId ? { rootSpanId } : {}
|
|
3886
|
+
});
|
|
3887
|
+
} catch (error) {
|
|
3888
|
+
_chunk6Z5S7VOUjs.debugLogger.warn("Error exporting Eve provider span:", error);
|
|
3889
|
+
}
|
|
3890
|
+
return span;
|
|
3891
|
+
}
|
|
3892
|
+
drainActionsForTurn(sessionId, turnId, error) {
|
|
3893
|
+
const key = turnKey2(sessionId, turnId);
|
|
3894
|
+
for (const [idempotencyKey, active] of this.activeActions) {
|
|
3895
|
+
if (active.turnKey !== key) continue;
|
|
3896
|
+
if (error !== void 0) active.span.log({ error });
|
|
3897
|
+
active.span.end();
|
|
3898
|
+
this.activeActions.delete(idempotencyKey);
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
forgetModel(attemptId, idempotencyKey) {
|
|
3902
|
+
this.activeModels.delete(idempotencyKey);
|
|
3903
|
+
const keys = this.modelsByAttempt.get(attemptId);
|
|
3904
|
+
_optionalChain([keys, 'optionalAccess', _120 => _120.delete, 'call', _121 => _121(idempotencyKey)]);
|
|
3905
|
+
if (_optionalChain([keys, 'optionalAccess', _122 => _122.size]) === 0) this.modelsByAttempt.delete(attemptId);
|
|
3906
|
+
}
|
|
3907
|
+
spanMetadata(sessionId) {
|
|
3908
|
+
return {
|
|
3909
|
+
..._nullishCoalesce(this.metadata, () => ( {})),
|
|
3910
|
+
"eve.session_id": sessionId
|
|
3911
|
+
};
|
|
3912
|
+
}
|
|
3913
|
+
async contain(operation, fn) {
|
|
3914
|
+
try {
|
|
3915
|
+
await fn();
|
|
3916
|
+
} catch (error) {
|
|
3917
|
+
_chunk6Z5S7VOUjs.debugLogger.warn(`Error in Eve provider ${operation}:`, error);
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
}, _class2);
|
|
3921
|
+
function storedSpan(context) {
|
|
3922
|
+
const value = context.state.get();
|
|
3923
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, value)) return void 0;
|
|
3924
|
+
if (value["skip"] === true) return { skip: true };
|
|
3925
|
+
return typeof value["exported"] === "string" ? {
|
|
3926
|
+
exported: value["exported"],
|
|
3927
|
+
...typeof value["rootSpanId"] === "string" && value["rootSpanId"].length > 0 ? { rootSpanId: value["rootSpanId"] } : {}
|
|
3928
|
+
} : void 0;
|
|
3929
|
+
}
|
|
3930
|
+
function modelOutput(event) {
|
|
3931
|
+
const content = _nullishCoalesce(event.content, () => ( []));
|
|
3932
|
+
let text = "";
|
|
3933
|
+
const reasoning = [];
|
|
3934
|
+
const toolCalls2 = [];
|
|
3935
|
+
for (const part of content) {
|
|
3936
|
+
if (part.type === "text") {
|
|
3937
|
+
text += part.text;
|
|
3938
|
+
} else if (part.type === "reasoning" && part.text.trim().length > 0) {
|
|
3939
|
+
reasoning.push({ content: part.text });
|
|
3940
|
+
} else if (part.type === "tool-call") {
|
|
3941
|
+
toolCalls2.push({
|
|
3942
|
+
function: {
|
|
3943
|
+
arguments: safeJsonStringify(part.input),
|
|
3944
|
+
name: part.toolName
|
|
3945
|
+
},
|
|
3946
|
+
id: part.callId,
|
|
3947
|
+
type: "function"
|
|
3948
|
+
});
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
return [
|
|
3952
|
+
{
|
|
3953
|
+
finish_reason: normalizeFinishReason2(event.finishReason),
|
|
3954
|
+
index: 0,
|
|
3955
|
+
message: {
|
|
3956
|
+
content: text || null,
|
|
3957
|
+
...reasoning.length > 0 ? { reasoning } : {},
|
|
3958
|
+
role: "assistant",
|
|
3959
|
+
...toolCalls2.length > 0 ? { tool_calls: toolCalls2 } : {}
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
];
|
|
3963
|
+
}
|
|
3964
|
+
function usageMetrics(usage) {
|
|
3965
|
+
const promptTokens = nonNegativeNumber(usage.inputTokens);
|
|
3966
|
+
const completionTokens = nonNegativeNumber(usage.outputTokens);
|
|
3967
|
+
const cachedTokens = nonNegativeNumber(
|
|
3968
|
+
_optionalChain([usage, 'access', _123 => _123.inputTokenDetails, 'optionalAccess', _124 => _124.cacheReadTokens])
|
|
3969
|
+
);
|
|
3970
|
+
const cacheCreationTokens = nonNegativeNumber(
|
|
3971
|
+
_optionalChain([usage, 'access', _125 => _125.inputTokenDetails, 'optionalAccess', _126 => _126.cacheWriteTokens])
|
|
3972
|
+
);
|
|
3973
|
+
return {
|
|
3974
|
+
...promptTokens !== void 0 ? { prompt_tokens: promptTokens } : {},
|
|
3975
|
+
...completionTokens !== void 0 ? { completion_tokens: completionTokens } : {},
|
|
3976
|
+
...promptTokens !== void 0 && completionTokens !== void 0 ? { tokens: promptTokens + completionTokens } : {},
|
|
3977
|
+
...cachedTokens !== void 0 ? { prompt_cached_tokens: cachedTokens } : {},
|
|
3978
|
+
...cacheCreationTokens !== void 0 ? { prompt_cache_creation_tokens: cacheCreationTokens } : {}
|
|
3979
|
+
};
|
|
3980
|
+
}
|
|
3981
|
+
function nonNegativeNumber(value) {
|
|
3982
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
3983
|
+
}
|
|
3984
|
+
function finiteTimestamp(value) {
|
|
3985
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
3986
|
+
}
|
|
3987
|
+
function normalizeFinishReason2(value) {
|
|
3988
|
+
if (value === "content-filter") return "content_filter";
|
|
3989
|
+
if (value === "tool-calls") return "tool_calls";
|
|
3990
|
+
return value;
|
|
3991
|
+
}
|
|
3992
|
+
function safeJsonStringify(value) {
|
|
3993
|
+
try {
|
|
3994
|
+
return _nullishCoalesce(JSON.stringify(value), () => ( "null"));
|
|
3995
|
+
} catch (e6) {
|
|
3996
|
+
return "null";
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
function turnKey2(sessionId, turnId) {
|
|
4000
|
+
return `${sessionId}:${turnId}`;
|
|
4001
|
+
}
|
|
4002
|
+
function turnIdempotencyKey(sessionId, turnId) {
|
|
4003
|
+
return `turn:${sessionId}:${turnId}`;
|
|
4004
|
+
}
|
|
4005
|
+
function actionIdempotencyKey(sessionId, turnId, callId) {
|
|
4006
|
+
return `action:${sessionId}:${turnId}:${callId}`;
|
|
4007
|
+
}
|
|
4008
|
+
|
|
4009
|
+
// src/instrumentation/plugins/eve-instrumentation.ts
|
|
4010
|
+
var EVE_INSTRUMENTATION_PROVIDER = /* @__PURE__ */ Symbol.for("eve.instrumentation.provider");
|
|
4011
|
+
function braintrustEveInstrumentation(options) {
|
|
4012
|
+
const definition = "defineState" in options ? createLegacyEveInstrumentation(options) : createEveInstrumentationProvider(options);
|
|
4013
|
+
const declaration = {
|
|
4014
|
+
...definition,
|
|
4015
|
+
[EVE_INSTRUMENTATION_PROVIDER]: true
|
|
4016
|
+
};
|
|
4017
|
+
return declaration;
|
|
4018
|
+
}
|
|
4019
|
+
|
|
3527
4020
|
// src/typed-instrumentation-helpers.ts
|
|
3528
4021
|
var TypedApplyProxy = Proxy;
|
|
3529
4022
|
|
|
@@ -3583,7 +4076,7 @@ function betaSessionEventsProxy(events) {
|
|
|
3583
4076
|
if (prop === "stream") {
|
|
3584
4077
|
return new TypedApplyProxy(target.stream, {
|
|
3585
4078
|
apply(stream, thisArg, argArray) {
|
|
3586
|
-
return
|
|
4079
|
+
return _chunk6Z5S7VOUjs.anthropicChannels.betaSessionsEventsStream.tracePromise(
|
|
3587
4080
|
() => Reflect.apply(stream, thisArg, argArray),
|
|
3588
4081
|
{ arguments: argArray }
|
|
3589
4082
|
);
|
|
@@ -3610,7 +4103,7 @@ function betaSessionThreadEventsProxy(events) {
|
|
|
3610
4103
|
if (prop === "stream") {
|
|
3611
4104
|
return new TypedApplyProxy(target.stream, {
|
|
3612
4105
|
apply(stream, thisArg, argArray) {
|
|
3613
|
-
return
|
|
4106
|
+
return _chunk6Z5S7VOUjs.anthropicChannels.betaSessionsThreadsEventsStream.tracePromise(
|
|
3614
4107
|
() => Reflect.apply(stream, thisArg, argArray),
|
|
3615
4108
|
{ arguments: argArray }
|
|
3616
4109
|
);
|
|
@@ -3625,7 +4118,7 @@ function messagesProxy(messages) {
|
|
|
3625
4118
|
return new Proxy(messages, {
|
|
3626
4119
|
get(target, prop, receiver) {
|
|
3627
4120
|
if (prop === "create") {
|
|
3628
|
-
return createProxy(target.create,
|
|
4121
|
+
return createProxy(target.create, _chunk6Z5S7VOUjs.anthropicChannels.messagesCreate);
|
|
3629
4122
|
}
|
|
3630
4123
|
return Reflect.get(target, prop, receiver);
|
|
3631
4124
|
}
|
|
@@ -3635,7 +4128,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3635
4128
|
return new Proxy(messages, {
|
|
3636
4129
|
get(target, prop, receiver) {
|
|
3637
4130
|
if (prop === "create") {
|
|
3638
|
-
return createProxy(target.create,
|
|
4131
|
+
return createProxy(target.create, _chunk6Z5S7VOUjs.anthropicChannels.betaMessagesCreate);
|
|
3639
4132
|
}
|
|
3640
4133
|
if (prop === "toolRunner") {
|
|
3641
4134
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -3644,7 +4137,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3644
4137
|
return toolRunnerProxy(
|
|
3645
4138
|
target.toolRunner,
|
|
3646
4139
|
anthropic,
|
|
3647
|
-
|
|
4140
|
+
_chunk6Z5S7VOUjs.anthropicChannels.betaMessagesToolRunner
|
|
3648
4141
|
);
|
|
3649
4142
|
}
|
|
3650
4143
|
return Reflect.get(target, prop, receiver);
|
|
@@ -3701,15 +4194,15 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
3701
4194
|
...params,
|
|
3702
4195
|
options: {
|
|
3703
4196
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
3704
|
-
[
|
|
4197
|
+
[_chunkXLLGRXGRjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
3705
4198
|
}
|
|
3706
4199
|
};
|
|
3707
4200
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3708
|
-
return
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
{
|
|
4201
|
+
return _chunk6Z5S7VOUjs.claudeAgentSDKChannels.query.invoke(
|
|
4202
|
+
target,
|
|
4203
|
+
invocationTarget,
|
|
4204
|
+
[wrappedParams],
|
|
4205
|
+
{}
|
|
3713
4206
|
);
|
|
3714
4207
|
}
|
|
3715
4208
|
});
|
|
@@ -3733,7 +4226,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
3733
4226
|
}
|
|
3734
4227
|
const localToolMetadata = { toolName };
|
|
3735
4228
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
3736
|
-
wrappedArgs[handlerIndex] =
|
|
4229
|
+
wrappedArgs[handlerIndex] = _chunkXLLGRXGRjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
3737
4230
|
originalHandler,
|
|
3738
4231
|
() => localToolMetadata
|
|
3739
4232
|
);
|
|
@@ -3751,8 +4244,8 @@ function wrapCreateSdkMcpServer(createSdkMcpServerFn, localToolMetadataByTool, d
|
|
|
3751
4244
|
apply(target, thisArg, argArray) {
|
|
3752
4245
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3753
4246
|
const config = argArray[0];
|
|
3754
|
-
const serverName = _optionalChain([config, 'optionalAccess',
|
|
3755
|
-
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess',
|
|
4247
|
+
const serverName = _optionalChain([config, 'optionalAccess', _127 => _127.name]);
|
|
4248
|
+
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess', _128 => _128.tools]))) {
|
|
3756
4249
|
for (const tool of config.tools) {
|
|
3757
4250
|
if (!tool || typeof tool !== "object") {
|
|
3758
4251
|
continue;
|
|
@@ -3840,7 +4333,7 @@ function patchThinkClass(Think) {
|
|
|
3840
4333
|
...descriptor,
|
|
3841
4334
|
value: function wrappedCloudflareThinkRunInferenceLoop(input) {
|
|
3842
4335
|
const args = [input];
|
|
3843
|
-
return
|
|
4336
|
+
return _chunk6Z5S7VOUjs.cloudflareThinkChannels.runInferenceLoop.tracePromise(
|
|
3844
4337
|
() => Reflect.apply(original, this, args),
|
|
3845
4338
|
{
|
|
3846
4339
|
arguments: args,
|
|
@@ -3892,7 +4385,7 @@ function isModuleNamespace2(obj) {
|
|
|
3892
4385
|
if (!obj || typeof obj !== "object") {
|
|
3893
4386
|
return false;
|
|
3894
4387
|
}
|
|
3895
|
-
if (_optionalChain([obj, 'access',
|
|
4388
|
+
if (_optionalChain([obj, 'access', _129 => _129.constructor, 'optionalAccess', _130 => _130.name]) === "Module") {
|
|
3896
4389
|
return true;
|
|
3897
4390
|
}
|
|
3898
4391
|
const keys = Object.keys(obj);
|
|
@@ -3962,7 +4455,7 @@ function wrapCodexThread(thread) {
|
|
|
3962
4455
|
if (prop === "run" && typeof value === "function") {
|
|
3963
4456
|
return function(input, turnOptions) {
|
|
3964
4457
|
const args = [input, turnOptions];
|
|
3965
|
-
return
|
|
4458
|
+
return _chunk6Z5S7VOUjs.openAICodexChannels.run.tracePromise(
|
|
3966
4459
|
() => Reflect.apply(value, target, args),
|
|
3967
4460
|
{
|
|
3968
4461
|
arguments: args,
|
|
@@ -3975,7 +4468,7 @@ function wrapCodexThread(thread) {
|
|
|
3975
4468
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
3976
4469
|
return function(input, turnOptions) {
|
|
3977
4470
|
const args = [input, turnOptions];
|
|
3978
|
-
return
|
|
4471
|
+
return _chunk6Z5S7VOUjs.openAICodexChannels.runStreamed.tracePromise(
|
|
3979
4472
|
() => Reflect.apply(value, target, args),
|
|
3980
4473
|
{
|
|
3981
4474
|
arguments: args,
|
|
@@ -4022,7 +4515,7 @@ function isModuleNamespace3(obj) {
|
|
|
4022
4515
|
if (!obj || typeof obj !== "object") {
|
|
4023
4516
|
return false;
|
|
4024
4517
|
}
|
|
4025
|
-
if (_optionalChain([obj, 'access',
|
|
4518
|
+
if (_optionalChain([obj, 'access', _131 => _131.constructor, 'optionalAccess', _132 => _132.name]) === "Module") {
|
|
4026
4519
|
return true;
|
|
4027
4520
|
}
|
|
4028
4521
|
const keys = Object.keys(obj);
|
|
@@ -4043,7 +4536,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4043
4536
|
if (prop === "create" && typeof value === "function") {
|
|
4044
4537
|
const wrapped = async function(options) {
|
|
4045
4538
|
const args = [options];
|
|
4046
|
-
return
|
|
4539
|
+
return _chunk6Z5S7VOUjs.cursorSDKChannels.create.tracePromise(
|
|
4047
4540
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
4048
4541
|
{ arguments: args }
|
|
4049
4542
|
);
|
|
@@ -4054,7 +4547,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4054
4547
|
if (prop === "resume" && typeof value === "function") {
|
|
4055
4548
|
const wrapped = async function(agentId, options) {
|
|
4056
4549
|
const args = [agentId, options];
|
|
4057
|
-
return
|
|
4550
|
+
return _chunk6Z5S7VOUjs.cursorSDKChannels.resume.tracePromise(
|
|
4058
4551
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
4059
4552
|
{ arguments: args }
|
|
4060
4553
|
);
|
|
@@ -4065,7 +4558,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4065
4558
|
if (prop === "prompt" && typeof value === "function") {
|
|
4066
4559
|
const wrapped = async function(message, options) {
|
|
4067
4560
|
const args = [message, options];
|
|
4068
|
-
return
|
|
4561
|
+
return _chunk6Z5S7VOUjs.cursorSDKChannels.prompt.tracePromise(
|
|
4069
4562
|
() => Reflect.apply(value, target, args),
|
|
4070
4563
|
{ arguments: args }
|
|
4071
4564
|
);
|
|
@@ -4098,7 +4591,7 @@ function wrapCursorAgent(agent) {
|
|
|
4098
4591
|
if (prop === "send" && typeof value === "function") {
|
|
4099
4592
|
return function(message, options) {
|
|
4100
4593
|
const args = [message, options];
|
|
4101
|
-
return
|
|
4594
|
+
return _chunk6Z5S7VOUjs.cursorSDKChannels.send.tracePromise(
|
|
4102
4595
|
() => Reflect.apply(value, target, args),
|
|
4103
4596
|
{
|
|
4104
4597
|
agent: target,
|
|
@@ -4148,7 +4641,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
4148
4641
|
...descriptor,
|
|
4149
4642
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
4150
4643
|
const args = [text, options];
|
|
4151
|
-
return
|
|
4644
|
+
return _chunk6Z5S7VOUjs.piCodingAgentChannels.prompt.invoke(originalPrompt, this, args, {
|
|
4152
4645
|
session: this
|
|
4153
4646
|
});
|
|
4154
4647
|
}
|
|
@@ -4194,7 +4687,7 @@ function wrapCloudflareAgent(Agent) {
|
|
|
4194
4687
|
if (ownValue(options, "detached")) {
|
|
4195
4688
|
return Reflect.apply(originalRunAgentTool, this, args);
|
|
4196
4689
|
}
|
|
4197
|
-
return
|
|
4690
|
+
return _chunk6Z5S7VOUjs.cloudflareAgentsChannels.runAgentTool.tracePromise(
|
|
4198
4691
|
() => Reflect.apply(originalRunAgentTool, this, args),
|
|
4199
4692
|
{ arguments: args, self: this }
|
|
4200
4693
|
);
|
|
@@ -4218,7 +4711,7 @@ function isObjectLike(value) {
|
|
|
4218
4711
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
4219
4712
|
}
|
|
4220
4713
|
function warnUnsupportedAgent() {
|
|
4221
|
-
|
|
4714
|
+
_chunk6Z5S7VOUjs.debugLogger.warn("Unsupported Cloudflare Agents Agent class. Not wrapping.");
|
|
4222
4715
|
}
|
|
4223
4716
|
|
|
4224
4717
|
// src/wrappers/strands-agent-sdk.ts
|
|
@@ -4262,7 +4755,7 @@ function isModuleNamespace4(obj) {
|
|
|
4262
4755
|
if (!obj || typeof obj !== "object") {
|
|
4263
4756
|
return false;
|
|
4264
4757
|
}
|
|
4265
|
-
if (_optionalChain([obj, 'access',
|
|
4758
|
+
if (_optionalChain([obj, 'access', _133 => _133.constructor, 'optionalAccess', _134 => _134.name]) === "Module") {
|
|
4266
4759
|
return true;
|
|
4267
4760
|
}
|
|
4268
4761
|
const keys = Object.keys(obj);
|
|
@@ -4324,13 +4817,11 @@ function wrapAgentInstance(agent) {
|
|
|
4324
4817
|
if (prop === "stream" && typeof value === "function") {
|
|
4325
4818
|
return function(args, options) {
|
|
4326
4819
|
const callArgs = [args, options];
|
|
4327
|
-
return
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
self: proxy
|
|
4333
|
-
}
|
|
4820
|
+
return _chunk6Z5S7VOUjs.strandsAgentSDKChannels.agentStream.invoke(
|
|
4821
|
+
value,
|
|
4822
|
+
target,
|
|
4823
|
+
callArgs,
|
|
4824
|
+
{ agent: proxy }
|
|
4334
4825
|
);
|
|
4335
4826
|
};
|
|
4336
4827
|
}
|
|
@@ -4360,13 +4851,13 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
4360
4851
|
if (prop === "stream" && typeof value === "function") {
|
|
4361
4852
|
return function(input, options) {
|
|
4362
4853
|
const callArgs = [input, options];
|
|
4363
|
-
const channel = kind === "graph" ?
|
|
4364
|
-
return channel.
|
|
4365
|
-
|
|
4854
|
+
const channel = kind === "graph" ? _chunk6Z5S7VOUjs.strandsAgentSDKChannels.graphStream : _chunk6Z5S7VOUjs.strandsAgentSDKChannels.swarmStream;
|
|
4855
|
+
return channel.invoke(
|
|
4856
|
+
value,
|
|
4857
|
+
target,
|
|
4858
|
+
callArgs,
|
|
4366
4859
|
{
|
|
4367
|
-
|
|
4368
|
-
orchestrator: proxy,
|
|
4369
|
-
self: proxy
|
|
4860
|
+
orchestrator: proxy
|
|
4370
4861
|
}
|
|
4371
4862
|
);
|
|
4372
4863
|
};
|
|
@@ -4400,11 +4891,11 @@ function wrapCloudflareAIChat(module) {
|
|
|
4400
4891
|
try {
|
|
4401
4892
|
AIChatAgent = Reflect.get(candidate, "AIChatAgent");
|
|
4402
4893
|
} catch (error) {
|
|
4403
|
-
|
|
4894
|
+
_chunk6Z5S7VOUjs.debugLogger.debug("Failed to inspect @cloudflare/ai-chat module:", error);
|
|
4404
4895
|
return module;
|
|
4405
4896
|
}
|
|
4406
4897
|
if (typeof AIChatAgent !== "function") {
|
|
4407
|
-
|
|
4898
|
+
_chunk6Z5S7VOUjs.debugLogger.warn(
|
|
4408
4899
|
"Unsupported @cloudflare/ai-chat module. AIChatAgent was not found; not wrapping."
|
|
4409
4900
|
);
|
|
4410
4901
|
return module;
|
|
@@ -4438,7 +4929,7 @@ function wrapAIChatAgentClass(AgentClass) {
|
|
|
4438
4929
|
args,
|
|
4439
4930
|
newTarget
|
|
4440
4931
|
);
|
|
4441
|
-
return
|
|
4932
|
+
return _chunkXLLGRXGRjs.instrumentCloudflareAIChatAgent.call(void 0, instance);
|
|
4442
4933
|
}
|
|
4443
4934
|
});
|
|
4444
4935
|
wrappedClasses.set(AgentClass, wrapped);
|
|
@@ -4459,7 +4950,7 @@ function isModuleNamespace5(value) {
|
|
|
4459
4950
|
}
|
|
4460
4951
|
const descriptor = Object.getOwnPropertyDescriptor(value, keys[0]);
|
|
4461
4952
|
return descriptor ? !descriptor.configurable && !descriptor.writable : false;
|
|
4462
|
-
} catch (
|
|
4953
|
+
} catch (e7) {
|
|
4463
4954
|
return false;
|
|
4464
4955
|
}
|
|
4465
4956
|
}
|
|
@@ -4510,7 +5001,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4510
5001
|
}
|
|
4511
5002
|
if (prop === "interactions") {
|
|
4512
5003
|
const interactions = Reflect.get(target, prop, receiver);
|
|
4513
|
-
if (!
|
|
5004
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
4514
5005
|
return interactions;
|
|
4515
5006
|
}
|
|
4516
5007
|
if (interactions !== originalInteractions) {
|
|
@@ -4524,7 +5015,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4524
5015
|
});
|
|
4525
5016
|
}
|
|
4526
5017
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
4527
|
-
if (!
|
|
5018
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
4528
5019
|
return;
|
|
4529
5020
|
}
|
|
4530
5021
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -4557,7 +5048,7 @@ function wrapInteractions(interactions) {
|
|
|
4557
5048
|
}
|
|
4558
5049
|
function wrapGenerateContent(original) {
|
|
4559
5050
|
return function(params) {
|
|
4560
|
-
return
|
|
5051
|
+
return _chunk6Z5S7VOUjs.googleGenAIChannels.generateContent.tracePromise(
|
|
4561
5052
|
() => original(params),
|
|
4562
5053
|
{ arguments: [params] }
|
|
4563
5054
|
);
|
|
@@ -4565,7 +5056,7 @@ function wrapGenerateContent(original) {
|
|
|
4565
5056
|
}
|
|
4566
5057
|
function wrapGenerateContentStream(original) {
|
|
4567
5058
|
return function(params) {
|
|
4568
|
-
return
|
|
5059
|
+
return _chunk6Z5S7VOUjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
4569
5060
|
() => original(params),
|
|
4570
5061
|
{ arguments: [params] }
|
|
4571
5062
|
);
|
|
@@ -4573,7 +5064,7 @@ function wrapGenerateContentStream(original) {
|
|
|
4573
5064
|
}
|
|
4574
5065
|
function wrapEmbedContent(original) {
|
|
4575
5066
|
return function(params) {
|
|
4576
|
-
return
|
|
5067
|
+
return _chunk6Z5S7VOUjs.googleGenAIChannels.embedContent.tracePromise(
|
|
4577
5068
|
() => original(params),
|
|
4578
5069
|
{ arguments: [params] }
|
|
4579
5070
|
);
|
|
@@ -4585,7 +5076,7 @@ function wrapInteractionCreate(original) {
|
|
|
4585
5076
|
return options === void 0 ? original(params) : original(params, options);
|
|
4586
5077
|
}
|
|
4587
5078
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
4588
|
-
return
|
|
5079
|
+
return _chunk6Z5S7VOUjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
4589
5080
|
() => options === void 0 ? original(params) : original(params, options),
|
|
4590
5081
|
traceContext
|
|
4591
5082
|
);
|
|
@@ -4646,7 +5137,7 @@ function wrapRunnerInstance(runner) {
|
|
|
4646
5137
|
function wrapRunnerRunAsync(runner) {
|
|
4647
5138
|
const original = runner.runAsync.bind(runner);
|
|
4648
5139
|
return function(params) {
|
|
4649
|
-
return
|
|
5140
|
+
return _chunk6Z5S7VOUjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
4650
5141
|
arguments: [params],
|
|
4651
5142
|
self: runner
|
|
4652
5143
|
});
|
|
@@ -4673,7 +5164,7 @@ function wrapAgentInstance2(agent) {
|
|
|
4673
5164
|
function wrapAgentRunAsync(agent) {
|
|
4674
5165
|
const original = agent.runAsync.bind(agent);
|
|
4675
5166
|
return function(parentContext) {
|
|
4676
|
-
return
|
|
5167
|
+
return _chunk6Z5S7VOUjs.googleADKChannels.agentRunAsync.traceSync(
|
|
4677
5168
|
() => original(parentContext),
|
|
4678
5169
|
{ arguments: [parentContext], self: agent }
|
|
4679
5170
|
);
|
|
@@ -4700,7 +5191,7 @@ function wrapToolInstance(tool) {
|
|
|
4700
5191
|
function wrapToolRunAsync(tool) {
|
|
4701
5192
|
const original = tool.runAsync.bind(tool);
|
|
4702
5193
|
return function(req) {
|
|
4703
|
-
return
|
|
5194
|
+
return _chunk6Z5S7VOUjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
4704
5195
|
arguments: [req],
|
|
4705
5196
|
self: tool
|
|
4706
5197
|
});
|
|
@@ -4812,7 +5303,7 @@ function patchGenkitRegistryLookup(registry) {
|
|
|
4812
5303
|
Object.defineProperty(registry, PATCHED_GENKIT_REGISTRY, {
|
|
4813
5304
|
value: true
|
|
4814
5305
|
});
|
|
4815
|
-
} catch (
|
|
5306
|
+
} catch (e8) {
|
|
4816
5307
|
}
|
|
4817
5308
|
}
|
|
4818
5309
|
function patchGenkitRegistryConstructor(registry) {
|
|
@@ -4843,31 +5334,31 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
4843
5334
|
Object.defineProperty(constructor, PATCHED_GENKIT_REGISTRY_CONSTRUCTOR, {
|
|
4844
5335
|
value: true
|
|
4845
5336
|
});
|
|
4846
|
-
} catch (
|
|
5337
|
+
} catch (e9) {
|
|
4847
5338
|
}
|
|
4848
5339
|
}
|
|
4849
5340
|
function wrapGenerate(generate) {
|
|
4850
|
-
return (input) =>
|
|
5341
|
+
return (input) => _chunk6Z5S7VOUjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
4851
5342
|
arguments: [input]
|
|
4852
5343
|
});
|
|
4853
5344
|
}
|
|
4854
5345
|
function wrapGenerateStream(generateStream) {
|
|
4855
|
-
return (input) =>
|
|
5346
|
+
return (input) => _chunk6Z5S7VOUjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
4856
5347
|
arguments: [input]
|
|
4857
5348
|
});
|
|
4858
5349
|
}
|
|
4859
5350
|
function wrapEmbed2(embed) {
|
|
4860
|
-
return (params) =>
|
|
5351
|
+
return (params) => _chunk6Z5S7VOUjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
4861
5352
|
arguments: [params]
|
|
4862
5353
|
});
|
|
4863
5354
|
}
|
|
4864
5355
|
function wrapEmbedMany2(embedMany) {
|
|
4865
|
-
return (params) =>
|
|
5356
|
+
return (params) => _chunk6Z5S7VOUjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
4866
5357
|
arguments: [params]
|
|
4867
5358
|
});
|
|
4868
5359
|
}
|
|
4869
5360
|
function wrapRun(run) {
|
|
4870
|
-
return (name, inputOrFn, maybeFn) =>
|
|
5361
|
+
return (name, inputOrFn, maybeFn) => _chunk6Z5S7VOUjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
4871
5362
|
arguments: [name, inputOrFn, maybeFn]
|
|
4872
5363
|
});
|
|
4873
5364
|
}
|
|
@@ -4906,13 +5397,13 @@ function isGenkitAction(value) {
|
|
|
4906
5397
|
return typeof value === "function" && "__action" in value;
|
|
4907
5398
|
}
|
|
4908
5399
|
function traceActionRun(action, run) {
|
|
4909
|
-
return (input, options) =>
|
|
5400
|
+
return (input, options) => _chunk6Z5S7VOUjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
4910
5401
|
arguments: [input, options],
|
|
4911
5402
|
self: action
|
|
4912
5403
|
});
|
|
4913
5404
|
}
|
|
4914
5405
|
function traceActionStream(action, stream) {
|
|
4915
|
-
return (input, options) =>
|
|
5406
|
+
return (input, options) => _chunk6Z5S7VOUjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
4916
5407
|
arguments: [input, options],
|
|
4917
5408
|
self: action
|
|
4918
5409
|
});
|
|
@@ -4958,10 +5449,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
4958
5449
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
4959
5450
|
}
|
|
4960
5451
|
function hasFunction2(value, methodName) {
|
|
4961
|
-
return
|
|
5452
|
+
return _chunkXLLGRXGRjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
4962
5453
|
}
|
|
4963
5454
|
function isSupportedHuggingFaceModule(value) {
|
|
4964
|
-
if (!
|
|
5455
|
+
if (!_chunkXLLGRXGRjs.isObject.call(void 0, value)) {
|
|
4965
5456
|
return false;
|
|
4966
5457
|
}
|
|
4967
5458
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -5069,14 +5560,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
5069
5560
|
const context = {
|
|
5070
5561
|
arguments: [traceParams]
|
|
5071
5562
|
};
|
|
5072
|
-
return
|
|
5563
|
+
return _chunk6Z5S7VOUjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
5073
5564
|
() => original(params, options),
|
|
5074
5565
|
context
|
|
5075
5566
|
);
|
|
5076
5567
|
};
|
|
5077
5568
|
}
|
|
5078
5569
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
5079
|
-
return (params, options) =>
|
|
5570
|
+
return (params, options) => _chunk6Z5S7VOUjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
5080
5571
|
() => original(params, options),
|
|
5081
5572
|
{
|
|
5082
5573
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -5089,14 +5580,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
5089
5580
|
const context = {
|
|
5090
5581
|
arguments: [traceParams]
|
|
5091
5582
|
};
|
|
5092
|
-
return
|
|
5583
|
+
return _chunk6Z5S7VOUjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
5093
5584
|
() => original(params, options),
|
|
5094
5585
|
context
|
|
5095
5586
|
);
|
|
5096
5587
|
};
|
|
5097
5588
|
}
|
|
5098
5589
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
5099
|
-
return (params, options) =>
|
|
5590
|
+
return (params, options) => _chunk6Z5S7VOUjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
5100
5591
|
() => original(params, options),
|
|
5101
5592
|
{
|
|
5102
5593
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -5109,7 +5600,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
5109
5600
|
const context = {
|
|
5110
5601
|
arguments: [traceParams]
|
|
5111
5602
|
};
|
|
5112
|
-
return
|
|
5603
|
+
return _chunk6Z5S7VOUjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
5113
5604
|
() => original(params, options),
|
|
5114
5605
|
context
|
|
5115
5606
|
);
|
|
@@ -5126,8 +5617,8 @@ var PIPELINE_CONSTRUCTOR_KEYS = /* @__PURE__ */ new Set([
|
|
|
5126
5617
|
]);
|
|
5127
5618
|
var wrappedValues = /* @__PURE__ */ new WeakMap();
|
|
5128
5619
|
function wrapHuggingFaceTransformers(transformers) {
|
|
5129
|
-
const pipelineTask = _optionalChain([transformers, 'optionalAccess',
|
|
5130
|
-
if (typeof transformers === "function" &&
|
|
5620
|
+
const pipelineTask = _optionalChain([transformers, 'optionalAccess', _135 => _135.task]);
|
|
5621
|
+
if (typeof transformers === "function" && _chunk6Z5S7VOUjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipelineTask)) {
|
|
5131
5622
|
return wrapPipeline(transformers);
|
|
5132
5623
|
}
|
|
5133
5624
|
if (!isSupportedModule(transformers)) {
|
|
@@ -5179,8 +5670,8 @@ function wrapPipelineFactory(factory) {
|
|
|
5179
5670
|
const context = {
|
|
5180
5671
|
arguments: args
|
|
5181
5672
|
};
|
|
5182
|
-
return
|
|
5183
|
-
if (
|
|
5673
|
+
return _chunk6Z5S7VOUjs.huggingFaceTransformersChannels.pipeline.tracePromise(() => Reflect.apply(factory, this, args), context).then((pipeline) => {
|
|
5674
|
+
if (_chunk6Z5S7VOUjs.isSupportedHuggingFaceTransformersTask.call(void 0, _nullishCoalesce(pipeline.task, () => ( task)))) {
|
|
5184
5675
|
return wrapPipeline(pipeline);
|
|
5185
5676
|
}
|
|
5186
5677
|
return pipeline;
|
|
@@ -5198,7 +5689,7 @@ function wrapPipelineConstructor(constructor) {
|
|
|
5198
5689
|
const proxy = new Proxy(constructor, {
|
|
5199
5690
|
construct(target, args, newTarget) {
|
|
5200
5691
|
const pipeline = Reflect.construct(target, args, newTarget);
|
|
5201
|
-
if (
|
|
5692
|
+
if (_chunk6Z5S7VOUjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipeline.task)) {
|
|
5202
5693
|
return wrapPipeline(pipeline);
|
|
5203
5694
|
}
|
|
5204
5695
|
return pipeline;
|
|
@@ -5219,7 +5710,7 @@ function wrapPipeline(pipeline) {
|
|
|
5219
5710
|
arguments: args,
|
|
5220
5711
|
self: target
|
|
5221
5712
|
};
|
|
5222
|
-
return
|
|
5713
|
+
return _chunk6Z5S7VOUjs.huggingFaceTransformersChannels.pipelineCall.tracePromise(
|
|
5223
5714
|
() => Reflect.apply(target, thisArg, args),
|
|
5224
5715
|
context
|
|
5225
5716
|
);
|
|
@@ -5270,7 +5761,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
5270
5761
|
const request = cloneCallModelRequest(argArray[0]);
|
|
5271
5762
|
const options = argArray[1];
|
|
5272
5763
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
5273
|
-
return
|
|
5764
|
+
return _chunk6Z5S7VOUjs.openRouterAgentChannels.callModel.traceSync(
|
|
5274
5765
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
5275
5766
|
{
|
|
5276
5767
|
arguments: [request]
|
|
@@ -5366,24 +5857,24 @@ function rerankProxy(rerank) {
|
|
|
5366
5857
|
});
|
|
5367
5858
|
}
|
|
5368
5859
|
function wrapChatSend(send) {
|
|
5369
|
-
return (request, options) =>
|
|
5860
|
+
return (request, options) => _chunk6Z5S7VOUjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
5370
5861
|
arguments: [request]
|
|
5371
5862
|
});
|
|
5372
5863
|
}
|
|
5373
5864
|
function wrapEmbeddingsGenerate(generate) {
|
|
5374
|
-
return (request, options) =>
|
|
5865
|
+
return (request, options) => _chunk6Z5S7VOUjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
5375
5866
|
() => generate(request, options),
|
|
5376
5867
|
{ arguments: [request] }
|
|
5377
5868
|
);
|
|
5378
5869
|
}
|
|
5379
5870
|
function wrapResponsesSend(send) {
|
|
5380
|
-
return (request, options) =>
|
|
5871
|
+
return (request, options) => _chunk6Z5S7VOUjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
5381
5872
|
() => send(request, options),
|
|
5382
5873
|
{ arguments: [request] }
|
|
5383
5874
|
);
|
|
5384
5875
|
}
|
|
5385
5876
|
function wrapRerank2(rerank) {
|
|
5386
|
-
return (request, options) =>
|
|
5877
|
+
return (request, options) => _chunk6Z5S7VOUjs.openRouterChannels.rerankRerank.tracePromise(
|
|
5387
5878
|
() => rerank(request, options),
|
|
5388
5879
|
{ arguments: [request] }
|
|
5389
5880
|
);
|
|
@@ -5391,7 +5882,7 @@ function wrapRerank2(rerank) {
|
|
|
5391
5882
|
function wrapCallModel2(callModel) {
|
|
5392
5883
|
return (request, options) => {
|
|
5393
5884
|
const tracedRequest = { ...request };
|
|
5394
|
-
return
|
|
5885
|
+
return _chunk6Z5S7VOUjs.openRouterChannels.callModel.traceSync(
|
|
5395
5886
|
() => callModel(tracedRequest, options),
|
|
5396
5887
|
{
|
|
5397
5888
|
arguments: [tracedRequest]
|
|
@@ -5524,7 +6015,7 @@ function classifiersProxy(classifiers) {
|
|
|
5524
6015
|
});
|
|
5525
6016
|
}
|
|
5526
6017
|
function wrapChatComplete(complete) {
|
|
5527
|
-
return (request, options) =>
|
|
6018
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.chatComplete.tracePromise(
|
|
5528
6019
|
() => complete(request, options),
|
|
5529
6020
|
{
|
|
5530
6021
|
arguments: [request]
|
|
@@ -5532,52 +6023,52 @@ function wrapChatComplete(complete) {
|
|
|
5532
6023
|
);
|
|
5533
6024
|
}
|
|
5534
6025
|
function wrapChatStream(stream) {
|
|
5535
|
-
return (request, options) =>
|
|
6026
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
5536
6027
|
arguments: [request]
|
|
5537
6028
|
});
|
|
5538
6029
|
}
|
|
5539
6030
|
function wrapEmbeddingsCreate(create) {
|
|
5540
|
-
return (request, options) =>
|
|
6031
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
5541
6032
|
() => create(request, options),
|
|
5542
6033
|
{ arguments: [request] }
|
|
5543
6034
|
);
|
|
5544
6035
|
}
|
|
5545
6036
|
function wrapClassifiersModerate(moderate) {
|
|
5546
|
-
return (request, options) =>
|
|
6037
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.classifiersModerate.tracePromise(
|
|
5547
6038
|
() => moderate(request, options),
|
|
5548
6039
|
{ arguments: [request] }
|
|
5549
6040
|
);
|
|
5550
6041
|
}
|
|
5551
6042
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
5552
|
-
return (request, options) =>
|
|
6043
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
5553
6044
|
() => moderateChat(request, options),
|
|
5554
6045
|
{ arguments: [request] }
|
|
5555
6046
|
);
|
|
5556
6047
|
}
|
|
5557
6048
|
function wrapClassifiersClassify(classify) {
|
|
5558
|
-
return (request, options) =>
|
|
6049
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.classifiersClassify.tracePromise(
|
|
5559
6050
|
() => classify(request, options),
|
|
5560
6051
|
{ arguments: [request] }
|
|
5561
6052
|
);
|
|
5562
6053
|
}
|
|
5563
6054
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
5564
|
-
return (request, options) =>
|
|
6055
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
5565
6056
|
() => classifyChat(request, options),
|
|
5566
6057
|
{ arguments: [request] }
|
|
5567
6058
|
);
|
|
5568
6059
|
}
|
|
5569
6060
|
function wrapFimComplete(complete) {
|
|
5570
|
-
return (request, options) =>
|
|
6061
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
5571
6062
|
arguments: [request]
|
|
5572
6063
|
});
|
|
5573
6064
|
}
|
|
5574
6065
|
function wrapFimStream(stream) {
|
|
5575
|
-
return (request, options) =>
|
|
6066
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
5576
6067
|
arguments: [request]
|
|
5577
6068
|
});
|
|
5578
6069
|
}
|
|
5579
6070
|
function wrapAgentsComplete(complete) {
|
|
5580
|
-
return (request, options) =>
|
|
6071
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.agentsComplete.tracePromise(
|
|
5581
6072
|
() => complete(request, options),
|
|
5582
6073
|
{
|
|
5583
6074
|
arguments: [request]
|
|
@@ -5585,7 +6076,7 @@ function wrapAgentsComplete(complete) {
|
|
|
5585
6076
|
);
|
|
5586
6077
|
}
|
|
5587
6078
|
function wrapAgentsStream(stream) {
|
|
5588
|
-
return (request, options) =>
|
|
6079
|
+
return (request, options) => _chunk6Z5S7VOUjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
5589
6080
|
arguments: [request]
|
|
5590
6081
|
});
|
|
5591
6082
|
}
|
|
@@ -5595,12 +6086,12 @@ function wrapOllama(ollama) {
|
|
|
5595
6086
|
if (isSupportedOllamaClient(ollama)) {
|
|
5596
6087
|
return ollamaProxy(ollama);
|
|
5597
6088
|
}
|
|
5598
|
-
|
|
6089
|
+
_chunk6Z5S7VOUjs.debugLogger.warn("Unsupported Ollama library. Not wrapping.");
|
|
5599
6090
|
return ollama;
|
|
5600
6091
|
}
|
|
5601
6092
|
var ollamaProxyCache = /* @__PURE__ */ new WeakMap();
|
|
5602
6093
|
function isSupportedOllamaClient(value) {
|
|
5603
|
-
return
|
|
6094
|
+
return _chunkXLLGRXGRjs.isObject.call(void 0, value) && ["chat", "generate", "embed"].some(
|
|
5604
6095
|
(name) => typeof value[name] === "function"
|
|
5605
6096
|
);
|
|
5606
6097
|
}
|
|
@@ -5652,17 +6143,17 @@ function ollamaProxy(ollama) {
|
|
|
5652
6143
|
return proxy;
|
|
5653
6144
|
}
|
|
5654
6145
|
function wrapChat(chat) {
|
|
5655
|
-
return (request) =>
|
|
6146
|
+
return (request) => _chunk6Z5S7VOUjs.ollamaChannels.chat.tracePromise(() => chat(request), {
|
|
5656
6147
|
arguments: [request]
|
|
5657
6148
|
});
|
|
5658
6149
|
}
|
|
5659
6150
|
function wrapGenerate2(generate) {
|
|
5660
|
-
return (request) =>
|
|
6151
|
+
return (request) => _chunk6Z5S7VOUjs.ollamaChannels.generate.tracePromise(() => generate(request), {
|
|
5661
6152
|
arguments: [request]
|
|
5662
6153
|
});
|
|
5663
6154
|
}
|
|
5664
6155
|
function wrapEmbed3(embed) {
|
|
5665
|
-
return (request) =>
|
|
6156
|
+
return (request) => _chunk6Z5S7VOUjs.ollamaChannels.embed.tracePromise(() => embed(request), {
|
|
5666
6157
|
arguments: [request]
|
|
5667
6158
|
});
|
|
5668
6159
|
}
|
|
@@ -5715,22 +6206,22 @@ function cohereProxy(cohere) {
|
|
|
5715
6206
|
return proxy;
|
|
5716
6207
|
}
|
|
5717
6208
|
function wrapChat2(chat) {
|
|
5718
|
-
return (request, options) =>
|
|
6209
|
+
return (request, options) => _chunk6Z5S7VOUjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
5719
6210
|
arguments: [request]
|
|
5720
6211
|
});
|
|
5721
6212
|
}
|
|
5722
6213
|
function wrapChatStream2(chatStream) {
|
|
5723
|
-
return (request, options) =>
|
|
6214
|
+
return (request, options) => _chunk6Z5S7VOUjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
5724
6215
|
arguments: [request]
|
|
5725
6216
|
});
|
|
5726
6217
|
}
|
|
5727
6218
|
function wrapEmbed4(embed) {
|
|
5728
|
-
return (request, options) =>
|
|
6219
|
+
return (request, options) => _chunk6Z5S7VOUjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
5729
6220
|
arguments: [request]
|
|
5730
6221
|
});
|
|
5731
6222
|
}
|
|
5732
6223
|
function wrapRerank3(rerank) {
|
|
5733
|
-
return (request, options) =>
|
|
6224
|
+
return (request, options) => _chunk6Z5S7VOUjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
5734
6225
|
arguments: [request]
|
|
5735
6226
|
});
|
|
5736
6227
|
}
|
|
@@ -5768,7 +6259,7 @@ function voyageAIProxy(client) {
|
|
|
5768
6259
|
if (typeof target.embed !== "function") {
|
|
5769
6260
|
return target.embed;
|
|
5770
6261
|
}
|
|
5771
|
-
return (request, options) =>
|
|
6262
|
+
return (request, options) => _chunk6Z5S7VOUjs.voyageAIChannels.embed.invoke(
|
|
5772
6263
|
target.embed,
|
|
5773
6264
|
target,
|
|
5774
6265
|
[request, options],
|
|
@@ -5778,7 +6269,7 @@ function voyageAIProxy(client) {
|
|
|
5778
6269
|
if (typeof target.multimodalEmbed !== "function") {
|
|
5779
6270
|
return target.multimodalEmbed;
|
|
5780
6271
|
}
|
|
5781
|
-
return (request, options) =>
|
|
6272
|
+
return (request, options) => _chunk6Z5S7VOUjs.voyageAIChannels.multimodalEmbed.invoke(
|
|
5782
6273
|
target.multimodalEmbed,
|
|
5783
6274
|
target,
|
|
5784
6275
|
[request, options],
|
|
@@ -5788,7 +6279,7 @@ function voyageAIProxy(client) {
|
|
|
5788
6279
|
if (typeof target.rerank !== "function") {
|
|
5789
6280
|
return target.rerank;
|
|
5790
6281
|
}
|
|
5791
|
-
return (request, options) =>
|
|
6282
|
+
return (request, options) => _chunk6Z5S7VOUjs.voyageAIChannels.rerank.invoke(
|
|
5792
6283
|
target.rerank,
|
|
5793
6284
|
target,
|
|
5794
6285
|
[request, options],
|
|
@@ -5798,7 +6289,7 @@ function voyageAIProxy(client) {
|
|
|
5798
6289
|
if (typeof target.contextualizedEmbed !== "function") {
|
|
5799
6290
|
return target.contextualizedEmbed;
|
|
5800
6291
|
}
|
|
5801
|
-
return (request, options) =>
|
|
6292
|
+
return (request, options) => _chunk6Z5S7VOUjs.voyageAIChannels.contextualizedEmbed.invoke(
|
|
5802
6293
|
target.contextualizedEmbed,
|
|
5803
6294
|
target,
|
|
5804
6295
|
[request, options],
|
|
@@ -5838,7 +6329,7 @@ function isSupportedGroqClient(value) {
|
|
|
5838
6329
|
}
|
|
5839
6330
|
function groqProxy(groq) {
|
|
5840
6331
|
const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
|
|
5841
|
-
const completionProxy = _optionalChain([groq, 'access',
|
|
6332
|
+
const completionProxy = _optionalChain([groq, 'access', _136 => _136.chat, 'optionalAccess', _137 => _137.completions]) ? new Proxy(groq.chat.completions, {
|
|
5842
6333
|
get(target, prop, receiver) {
|
|
5843
6334
|
if (prop === "create") {
|
|
5844
6335
|
return wrapChatCompletionsCreate(target.create.bind(target));
|
|
@@ -5890,13 +6381,13 @@ function groqProxy(groq) {
|
|
|
5890
6381
|
return topLevelProxy;
|
|
5891
6382
|
}
|
|
5892
6383
|
function wrapChatCompletionsCreate(create) {
|
|
5893
|
-
return (request, options) =>
|
|
6384
|
+
return (request, options) => _chunk6Z5S7VOUjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
5894
6385
|
() => create(request, options),
|
|
5895
6386
|
{ arguments: [request] }
|
|
5896
6387
|
);
|
|
5897
6388
|
}
|
|
5898
6389
|
function wrapEmbeddingsCreate2(create) {
|
|
5899
|
-
return (request, options) =>
|
|
6390
|
+
return (request, options) => _chunk6Z5S7VOUjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
5900
6391
|
arguments: [request]
|
|
5901
6392
|
});
|
|
5902
6393
|
}
|
|
@@ -5970,16 +6461,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
5970
6461
|
}
|
|
5971
6462
|
function wrapSend(send) {
|
|
5972
6463
|
return (command, optionsOrCb, cb) => {
|
|
5973
|
-
if (
|
|
6464
|
+
if (_chunkXLLGRXGRjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
5974
6465
|
return send(command, optionsOrCb, cb);
|
|
5975
6466
|
}
|
|
5976
|
-
return
|
|
5977
|
-
() =>
|
|
6467
|
+
return _chunk6Z5S7VOUjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
6468
|
+
() => _chunkXLLGRXGRjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
5978
6469
|
() => send(command, optionsOrCb)
|
|
5979
6470
|
),
|
|
5980
6471
|
{
|
|
5981
6472
|
arguments: [command, optionsOrCb],
|
|
5982
|
-
span_info:
|
|
6473
|
+
span_info: _chunkXLLGRXGRjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
5983
6474
|
}
|
|
5984
6475
|
);
|
|
5985
6476
|
};
|
|
@@ -6028,13 +6519,13 @@ function copilotClientProxy(client) {
|
|
|
6028
6519
|
return proxy;
|
|
6029
6520
|
}
|
|
6030
6521
|
function wrappedCreateSession(client) {
|
|
6031
|
-
return (config) =>
|
|
6522
|
+
return (config) => _chunk6Z5S7VOUjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
6032
6523
|
() => client.createSession(config),
|
|
6033
6524
|
{ arguments: [config] }
|
|
6034
6525
|
);
|
|
6035
6526
|
}
|
|
6036
6527
|
function wrappedResumeSession(client) {
|
|
6037
|
-
return (sessionId, config) =>
|
|
6528
|
+
return (sessionId, config) => _chunk6Z5S7VOUjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
6038
6529
|
() => client.resumeSession(sessionId, config),
|
|
6039
6530
|
{ arguments: [sessionId, config] }
|
|
6040
6531
|
);
|
|
@@ -6139,7 +6630,7 @@ function isModuleNamespace6(value) {
|
|
|
6139
6630
|
if (!value || typeof value !== "object") {
|
|
6140
6631
|
return false;
|
|
6141
6632
|
}
|
|
6142
|
-
if (_optionalChain([value, 'access',
|
|
6633
|
+
if (_optionalChain([value, 'access', _138 => _138.constructor, 'optionalAccess', _139 => _139.name]) === "Module") {
|
|
6143
6634
|
return true;
|
|
6144
6635
|
}
|
|
6145
6636
|
const firstKey = Object.keys(value)[0];
|
|
@@ -6163,7 +6654,7 @@ function wrapTraceable(traceable2) {
|
|
|
6163
6654
|
apply(target, thisArg, argArray) {
|
|
6164
6655
|
const [fn, rawConfig] = argArray;
|
|
6165
6656
|
const config = rawConfig && typeof rawConfig === "object" ? rawConfig : void 0;
|
|
6166
|
-
const originalOnEnd = _optionalChain([config, 'optionalAccess',
|
|
6657
|
+
const originalOnEnd = _optionalChain([config, 'optionalAccess', _140 => _140.on_end]);
|
|
6167
6658
|
const wrappedConfig = {
|
|
6168
6659
|
...config,
|
|
6169
6660
|
on_end(runTree) {
|
|
@@ -6212,13 +6703,13 @@ function wrapRunTreeInstance(runTree) {
|
|
|
6212
6703
|
wrapped = (...args) => wrapRunTreeInstance(Reflect.apply(value, target, args));
|
|
6213
6704
|
} else if (prop === "postRun") {
|
|
6214
6705
|
const method = value;
|
|
6215
|
-
wrapped = (...args) =>
|
|
6706
|
+
wrapped = (...args) => _chunk6Z5S7VOUjs.langSmithChannels.createRun.tracePromise(
|
|
6216
6707
|
() => Reflect.apply(method, target, args),
|
|
6217
6708
|
{ arguments: [target] }
|
|
6218
6709
|
);
|
|
6219
6710
|
} else if (prop === "patchRun") {
|
|
6220
6711
|
const method = value;
|
|
6221
|
-
wrapped = (...args) =>
|
|
6712
|
+
wrapped = (...args) => _chunk6Z5S7VOUjs.langSmithChannels.updateRun.tracePromise(
|
|
6222
6713
|
() => Reflect.apply(method, target, args),
|
|
6223
6714
|
{
|
|
6224
6715
|
arguments: [
|
|
@@ -6267,19 +6758,19 @@ function wrapClientInstance(client) {
|
|
|
6267
6758
|
let wrapped;
|
|
6268
6759
|
if (prop === "createRun") {
|
|
6269
6760
|
const method = value;
|
|
6270
|
-
wrapped = (...args) =>
|
|
6761
|
+
wrapped = (...args) => _chunk6Z5S7VOUjs.langSmithChannels.createRun.tracePromise(
|
|
6271
6762
|
() => Reflect.apply(method, target, args),
|
|
6272
6763
|
{ arguments: args }
|
|
6273
6764
|
);
|
|
6274
6765
|
} else if (prop === "updateRun") {
|
|
6275
6766
|
const method = value;
|
|
6276
|
-
wrapped = (...args) =>
|
|
6767
|
+
wrapped = (...args) => _chunk6Z5S7VOUjs.langSmithChannels.updateRun.tracePromise(
|
|
6277
6768
|
() => Reflect.apply(method, target, args),
|
|
6278
6769
|
{ arguments: args }
|
|
6279
6770
|
);
|
|
6280
6771
|
} else if (prop === "batchIngestRuns") {
|
|
6281
6772
|
const method = value;
|
|
6282
|
-
wrapped = (...args) =>
|
|
6773
|
+
wrapped = (...args) => _chunk6Z5S7VOUjs.langSmithChannels.batchIngestRuns.tracePromise(
|
|
6283
6774
|
() => Reflect.apply(method, target, args),
|
|
6284
6775
|
{ arguments: args }
|
|
6285
6776
|
);
|
|
@@ -6295,13 +6786,13 @@ function publishRunUpdate(runTree) {
|
|
|
6295
6786
|
return;
|
|
6296
6787
|
}
|
|
6297
6788
|
try {
|
|
6298
|
-
void
|
|
6789
|
+
void _chunk6Z5S7VOUjs.langSmithChannels.updateRun.tracePromise(() => Promise.resolve(void 0), {
|
|
6299
6790
|
arguments: [runTree.id, runTree]
|
|
6300
6791
|
}).catch((error) => {
|
|
6301
|
-
|
|
6792
|
+
_chunk6Z5S7VOUjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
6302
6793
|
});
|
|
6303
6794
|
} catch (error) {
|
|
6304
|
-
|
|
6795
|
+
_chunk6Z5S7VOUjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
6305
6796
|
}
|
|
6306
6797
|
}
|
|
6307
6798
|
|
|
@@ -6313,14 +6804,11 @@ var VitestContextManager = class {
|
|
|
6313
6804
|
*/
|
|
6314
6805
|
|
|
6315
6806
|
constructor() {
|
|
6316
|
-
this.contextStorage =
|
|
6807
|
+
this.contextStorage = _chunk6Z5S7VOUjs.isomorph_default.newAsyncLocalStorage();
|
|
6317
6808
|
}
|
|
6318
6809
|
getCurrentContext() {
|
|
6319
6810
|
return this.contextStorage.getStore();
|
|
6320
6811
|
}
|
|
6321
|
-
setContext(context) {
|
|
6322
|
-
this.contextStorage.enterWith(context);
|
|
6323
|
-
}
|
|
6324
6812
|
runInContext(context, callback) {
|
|
6325
6813
|
return this.contextStorage.run(context, callback);
|
|
6326
6814
|
}
|
|
@@ -6346,15 +6834,15 @@ function getVitestContextManager() {
|
|
|
6346
6834
|
}
|
|
6347
6835
|
|
|
6348
6836
|
// src/wrappers/vitest/flush-manager.ts
|
|
6349
|
-
var FlushCoordinator = (
|
|
6350
|
-
|
|
6837
|
+
var FlushCoordinator = (_class3 = class {constructor() { _class3.prototype.__init10.call(this); }
|
|
6838
|
+
__init10() {this.activeFlushes = /* @__PURE__ */ new Map()}
|
|
6351
6839
|
async coordinateFlush(context, config) {
|
|
6352
6840
|
if (!context) return;
|
|
6353
6841
|
const experimentId = await context.experiment.id;
|
|
6354
6842
|
if (this.activeFlushes.has(experimentId)) {
|
|
6355
6843
|
return this.activeFlushes.get(experimentId);
|
|
6356
6844
|
}
|
|
6357
|
-
const flushPromise =
|
|
6845
|
+
const flushPromise = _chunkXLLGRXGRjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
6358
6846
|
displaySummary: config.displaySummary
|
|
6359
6847
|
});
|
|
6360
6848
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -6364,7 +6852,7 @@ var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__ini
|
|
|
6364
6852
|
this.activeFlushes.delete(experimentId);
|
|
6365
6853
|
}
|
|
6366
6854
|
}
|
|
6367
|
-
},
|
|
6855
|
+
}, _class3);
|
|
6368
6856
|
var flushCoordinator = new FlushCoordinator();
|
|
6369
6857
|
async function flushExperimentWithSync(context, config) {
|
|
6370
6858
|
return flushCoordinator.coordinateFlush(context, config);
|
|
@@ -6452,7 +6940,7 @@ async function runTracedEval(args) {
|
|
|
6452
6940
|
}
|
|
6453
6941
|
if (testError) {
|
|
6454
6942
|
span.log({ scores: { pass: 0 } });
|
|
6455
|
-
|
|
6943
|
+
_chunkXLLGRXGRjs.logError.call(void 0, span, testError);
|
|
6456
6944
|
throw testError;
|
|
6457
6945
|
}
|
|
6458
6946
|
span.log({
|
|
@@ -6485,7 +6973,7 @@ function wrapTest(originalTest, config) {
|
|
|
6485
6973
|
const wrapped = function(name, configOrFn, maybeFn) {
|
|
6486
6974
|
const isEnhanced = typeof configOrFn !== "function";
|
|
6487
6975
|
const testConfig = isEnhanced ? configOrFn : void 0;
|
|
6488
|
-
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess',
|
|
6976
|
+
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _141 => _141.data]) && Array.isArray(testConfig.data)) {
|
|
6489
6977
|
const dataRecords = testConfig.data;
|
|
6490
6978
|
const testFn2 = maybeFn;
|
|
6491
6979
|
if (!testFn2) {
|
|
@@ -6523,7 +7011,7 @@ function wrapTest(originalTest, config) {
|
|
|
6523
7011
|
const registrationContext = getExperimentContext();
|
|
6524
7012
|
const testImplementation = async (vitestContext) => {
|
|
6525
7013
|
const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
|
|
6526
|
-
const experiment = _optionalChain([experimentContext, 'optionalAccess',
|
|
7014
|
+
const experiment = _optionalChain([experimentContext, 'optionalAccess', _142 => _142.experiment]);
|
|
6527
7015
|
if (config.onProgress) {
|
|
6528
7016
|
config.onProgress({ type: "test_start", testName: name });
|
|
6529
7017
|
}
|
|
@@ -6555,11 +7043,11 @@ function wrapTest(originalTest, config) {
|
|
|
6555
7043
|
const result = await runTracedEval({
|
|
6556
7044
|
experiment,
|
|
6557
7045
|
spanName: name,
|
|
6558
|
-
input: _optionalChain([testConfig, 'optionalAccess',
|
|
6559
|
-
expected: _optionalChain([testConfig, 'optionalAccess',
|
|
6560
|
-
metadata: _optionalChain([testConfig, 'optionalAccess',
|
|
6561
|
-
tags: _optionalChain([testConfig, 'optionalAccess',
|
|
6562
|
-
scorers: _optionalChain([testConfig, 'optionalAccess',
|
|
7046
|
+
input: _optionalChain([testConfig, 'optionalAccess', _143 => _143.input]),
|
|
7047
|
+
expected: _optionalChain([testConfig, 'optionalAccess', _144 => _144.expected]),
|
|
7048
|
+
metadata: _optionalChain([testConfig, 'optionalAccess', _145 => _145.metadata]),
|
|
7049
|
+
tags: _optionalChain([testConfig, 'optionalAccess', _146 => _146.tags]),
|
|
7050
|
+
scorers: _optionalChain([testConfig, 'optionalAccess', _147 => _147.scorers]),
|
|
6563
7051
|
fn: async () => {
|
|
6564
7052
|
if (testConfig && maybeFn) {
|
|
6565
7053
|
const params = {
|
|
@@ -6626,10 +7114,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6626
7114
|
const getOrCreateContext = () => {
|
|
6627
7115
|
if (!context) {
|
|
6628
7116
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6629
|
-
const experiment = config.projectId ?
|
|
7117
|
+
const experiment = config.projectId ? _chunkXLLGRXGRjs.initExperiment.call(void 0, {
|
|
6630
7118
|
projectId: config.projectId,
|
|
6631
7119
|
experiment: experimentName
|
|
6632
|
-
}) :
|
|
7120
|
+
}) : _chunkXLLGRXGRjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
6633
7121
|
experiment: experimentName
|
|
6634
7122
|
});
|
|
6635
7123
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -6665,8 +7153,7 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6665
7153
|
if (config.onProgress) {
|
|
6666
7154
|
config.onProgress({ type: "suite_start", suiteName });
|
|
6667
7155
|
}
|
|
6668
|
-
contextManager.
|
|
6669
|
-
factory();
|
|
7156
|
+
contextManager.runInContext(lazyContext, factory);
|
|
6670
7157
|
if (afterAll) {
|
|
6671
7158
|
afterAll(async () => {
|
|
6672
7159
|
await flushExperimentWithSync(context, config);
|
|
@@ -6674,8 +7161,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6674
7161
|
config.onProgress({
|
|
6675
7162
|
type: "suite_complete",
|
|
6676
7163
|
suiteName,
|
|
6677
|
-
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
6678
|
-
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
7164
|
+
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _148 => _148.passed]), () => ( 0)),
|
|
7165
|
+
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _149 => _149.failed]), () => ( 0))
|
|
6679
7166
|
});
|
|
6680
7167
|
}
|
|
6681
7168
|
});
|
|
@@ -6737,7 +7224,7 @@ function wrapExpect(originalExpect) {
|
|
|
6737
7224
|
return originalExpect(value);
|
|
6738
7225
|
}
|
|
6739
7226
|
const assertion = originalExpect(value, message);
|
|
6740
|
-
const span =
|
|
7227
|
+
const span = _chunkXLLGRXGRjs.currentSpan.call(void 0, );
|
|
6741
7228
|
if (!span) {
|
|
6742
7229
|
return assertion;
|
|
6743
7230
|
}
|
|
@@ -6749,16 +7236,16 @@ function wrapExpect(originalExpect) {
|
|
|
6749
7236
|
|
|
6750
7237
|
// src/wrappers/shared/logging.ts
|
|
6751
7238
|
function logOutputs(outputs) {
|
|
6752
|
-
|
|
7239
|
+
_chunkXLLGRXGRjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
6753
7240
|
}
|
|
6754
7241
|
function logFeedback(feedback) {
|
|
6755
|
-
|
|
7242
|
+
_chunkXLLGRXGRjs.currentSpan.call(void 0, ).log({
|
|
6756
7243
|
scores: { [feedback.name]: feedback.score },
|
|
6757
7244
|
metadata: feedback.metadata
|
|
6758
7245
|
});
|
|
6759
7246
|
}
|
|
6760
7247
|
function getCurrentSpan() {
|
|
6761
|
-
return
|
|
7248
|
+
return _chunkXLLGRXGRjs.currentSpan.call(void 0, );
|
|
6762
7249
|
}
|
|
6763
7250
|
|
|
6764
7251
|
// src/wrappers/vitest/index.ts
|
|
@@ -6806,8 +7293,8 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
6806
7293
|
);
|
|
6807
7294
|
return;
|
|
6808
7295
|
}
|
|
6809
|
-
await
|
|
6810
|
-
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7296
|
+
await _chunkXLLGRXGRjs.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
7297
|
+
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _150 => _150.displaySummary]), () => ( config.displaySummary))
|
|
6811
7298
|
});
|
|
6812
7299
|
}
|
|
6813
7300
|
};
|
|
@@ -6821,7 +7308,7 @@ function initNodeTestSuite(config) {
|
|
|
6821
7308
|
return experiment;
|
|
6822
7309
|
}
|
|
6823
7310
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6824
|
-
experiment =
|
|
7311
|
+
experiment = _chunkXLLGRXGRjs.initExperiment.call(void 0, config.projectName, {
|
|
6825
7312
|
experiment: experimentName
|
|
6826
7313
|
});
|
|
6827
7314
|
return experiment;
|
|
@@ -6870,7 +7357,7 @@ function initNodeTestSuite(config) {
|
|
|
6870
7357
|
if (!experiment) {
|
|
6871
7358
|
return;
|
|
6872
7359
|
}
|
|
6873
|
-
await
|
|
7360
|
+
await _chunkXLLGRXGRjs.summarizeAndFlush.call(void 0, experiment, {
|
|
6874
7361
|
displaySummary: config.displaySummary
|
|
6875
7362
|
});
|
|
6876
7363
|
experiment = void 0;
|
|
@@ -6887,7 +7374,7 @@ function initNodeTestSuite(config) {
|
|
|
6887
7374
|
|
|
6888
7375
|
// src/graph-framework.ts
|
|
6889
7376
|
var graph_framework_exports = {};
|
|
6890
|
-
|
|
7377
|
+
_chunk6Z5S7VOUjs.__export.call(void 0, graph_framework_exports, {
|
|
6891
7378
|
AggregatorNode: () => AggregatorNode,
|
|
6892
7379
|
GateNode: () => GateNode,
|
|
6893
7380
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -6901,15 +7388,15 @@ _chunkBBE7SNRVjs.__export.call(void 0, graph_framework_exports, {
|
|
|
6901
7388
|
escapePath: () => escapePath,
|
|
6902
7389
|
unescapePath: () => unescapePath
|
|
6903
7390
|
});
|
|
6904
|
-
var GraphBuilder = (
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
7391
|
+
var GraphBuilder = (_class4 = class {
|
|
7392
|
+
__init11() {this.nodes = /* @__PURE__ */ new Map()}
|
|
7393
|
+
__init12() {this.edges = {}}
|
|
7394
|
+
__init13() {this.nodeLikeNodes = /* @__PURE__ */ new Map()}
|
|
6908
7395
|
// Maps node-like objects, like prompts, to their nodes
|
|
6909
7396
|
// Special nodes
|
|
6910
7397
|
|
|
6911
7398
|
|
|
6912
|
-
constructor() {;
|
|
7399
|
+
constructor() {;_class4.prototype.__init11.call(this);_class4.prototype.__init12.call(this);_class4.prototype.__init13.call(this);
|
|
6913
7400
|
this.IN = this.createInputNode();
|
|
6914
7401
|
this.OUT = this.createOutputNode();
|
|
6915
7402
|
}
|
|
@@ -6961,7 +7448,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6961
7448
|
};
|
|
6962
7449
|
}
|
|
6963
7450
|
resolveNode(node) {
|
|
6964
|
-
if (node instanceof
|
|
7451
|
+
if (node instanceof _chunkXLLGRXGRjs.Prompt) {
|
|
6965
7452
|
const cached = this.nodeLikeNodes.get(node);
|
|
6966
7453
|
if (cached) {
|
|
6967
7454
|
return [cached, []];
|
|
@@ -7011,7 +7498,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
7011
7498
|
// }
|
|
7012
7499
|
// Helper to generate node IDs
|
|
7013
7500
|
generateId(name) {
|
|
7014
|
-
const uuid =
|
|
7501
|
+
const uuid = _chunkXLLGRXGRjs.newId.call(void 0, );
|
|
7015
7502
|
if (name) {
|
|
7016
7503
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
7017
7504
|
} else {
|
|
@@ -7039,7 +7526,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
7039
7526
|
this.nodes.set(id, promptNode);
|
|
7040
7527
|
return promptNode;
|
|
7041
7528
|
}
|
|
7042
|
-
},
|
|
7529
|
+
}, _class4);
|
|
7043
7530
|
function isProxyVariable(node) {
|
|
7044
7531
|
return typeof node === "object" && node !== null && "__type" in node && // @ts-ignore
|
|
7045
7532
|
node.__type === "proxy-variable";
|
|
@@ -7047,19 +7534,19 @@ function isProxyVariable(node) {
|
|
|
7047
7534
|
function proxyVariableToNode(proxy) {
|
|
7048
7535
|
return [proxy.__node, proxy.__path];
|
|
7049
7536
|
}
|
|
7050
|
-
var BaseNode = (
|
|
7051
|
-
constructor(graph, id) {;
|
|
7537
|
+
var BaseNode = (_class5 = class {
|
|
7538
|
+
constructor(graph, id) {;_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);
|
|
7052
7539
|
this.graph = graph;
|
|
7053
7540
|
this.id = id;
|
|
7054
7541
|
}
|
|
7055
7542
|
|
|
7056
7543
|
|
|
7057
|
-
|
|
7058
|
-
|
|
7544
|
+
__init14() {this.__type = "node"}
|
|
7545
|
+
__init15() {this.dependencies = []}
|
|
7059
7546
|
addDependency(dependency) {
|
|
7060
7547
|
this.dependencies.push(dependency);
|
|
7061
7548
|
}
|
|
7062
|
-
},
|
|
7549
|
+
}, _class5);
|
|
7063
7550
|
var InputNode = class extends BaseNode {
|
|
7064
7551
|
constructor(graph, id) {
|
|
7065
7552
|
super(graph, id);
|
|
@@ -8211,7 +8698,7 @@ function waterfall(tasks, callback) {
|
|
|
8211
8698
|
var waterfall$1 = awaitify(waterfall);
|
|
8212
8699
|
|
|
8213
8700
|
// src/trace.ts
|
|
8214
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
8701
|
+
var SpanFetcher = class _SpanFetcher extends _chunkXLLGRXGRjs.ObjectFetcher {
|
|
8215
8702
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
8216
8703
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
8217
8704
|
rootSpanId,
|
|
@@ -8280,11 +8767,11 @@ var SpanFetcher = class _SpanFetcher extends _chunkOBBWQW6Kjs.ObjectFetcher {
|
|
|
8280
8767
|
return this._state;
|
|
8281
8768
|
}
|
|
8282
8769
|
};
|
|
8283
|
-
var CachedSpanFetcher = (
|
|
8284
|
-
|
|
8285
|
-
|
|
8770
|
+
var CachedSpanFetcher = (_class6 = class {
|
|
8771
|
+
__init16() {this.spanCache = /* @__PURE__ */ new Map()}
|
|
8772
|
+
__init17() {this.allFetched = false}
|
|
8286
8773
|
|
|
8287
|
-
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;
|
|
8774
|
+
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;_class6.prototype.__init16.call(this);_class6.prototype.__init17.call(this);
|
|
8288
8775
|
if (typeof objectTypeOrFetchFn === "function") {
|
|
8289
8776
|
this.fetchFn = (spanType) => objectTypeOrFetchFn(spanType);
|
|
8290
8777
|
} else {
|
|
@@ -8348,7 +8835,7 @@ var CachedSpanFetcher = (_class5 = class {
|
|
|
8348
8835
|
async fetchSpans(spanType) {
|
|
8349
8836
|
const spans = await this.fetchFn(spanType, false);
|
|
8350
8837
|
for (const span of spans) {
|
|
8351
|
-
const type = _nullishCoalesce(_optionalChain([span, 'access',
|
|
8838
|
+
const type = _nullishCoalesce(_optionalChain([span, 'access', _151 => _151.span_attributes, 'optionalAccess', _152 => _152.type]), () => ( ""));
|
|
8352
8839
|
const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
|
|
8353
8840
|
existing.push(span);
|
|
8354
8841
|
this.spanCache.set(type, existing);
|
|
@@ -8365,24 +8852,24 @@ var CachedSpanFetcher = (_class5 = class {
|
|
|
8365
8852
|
}
|
|
8366
8853
|
return result;
|
|
8367
8854
|
}
|
|
8368
|
-
},
|
|
8369
|
-
var LocalTrace = (
|
|
8855
|
+
}, _class6);
|
|
8856
|
+
var LocalTrace = (_class7 = class {
|
|
8370
8857
|
|
|
8371
8858
|
|
|
8372
8859
|
|
|
8373
8860
|
|
|
8374
8861
|
|
|
8375
|
-
|
|
8376
|
-
|
|
8862
|
+
__init18() {this.spansFlushed = false}
|
|
8863
|
+
__init19() {this.spansFlushPromise = null}
|
|
8377
8864
|
|
|
8378
|
-
|
|
8865
|
+
__init20() {this.threadCache = /* @__PURE__ */ new Map()}
|
|
8379
8866
|
constructor({
|
|
8380
8867
|
objectType,
|
|
8381
8868
|
objectId,
|
|
8382
8869
|
rootSpanId,
|
|
8383
8870
|
ensureSpansFlushed,
|
|
8384
8871
|
state
|
|
8385
|
-
}) {;
|
|
8872
|
+
}) {;_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);
|
|
8386
8873
|
this.objectType = objectType;
|
|
8387
8874
|
this.objectId = objectId;
|
|
8388
8875
|
this.rootSpanId = rootSpanId;
|
|
@@ -8431,11 +8918,11 @@ var LocalTrace = (_class6 = class {
|
|
|
8431
8918
|
const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
|
|
8432
8919
|
if (cachedSpans && cachedSpans.length > 0) {
|
|
8433
8920
|
let spans = includeScorers ? cachedSpans : cachedSpans.filter(
|
|
8434
|
-
(span) => _optionalChain([span, 'access',
|
|
8921
|
+
(span) => _optionalChain([span, 'access', _153 => _153.span_attributes, 'optionalAccess', _154 => _154.purpose]) !== "scorer"
|
|
8435
8922
|
);
|
|
8436
8923
|
if (spanType && spanType.length > 0) {
|
|
8437
8924
|
spans = spans.filter(
|
|
8438
|
-
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access',
|
|
8925
|
+
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _155 => _155.span_attributes, 'optionalAccess', _156 => _156.type]), () => ( "")))
|
|
8439
8926
|
);
|
|
8440
8927
|
}
|
|
8441
8928
|
return spans.map((span) => ({
|
|
@@ -8460,7 +8947,7 @@ var LocalTrace = (_class6 = class {
|
|
|
8460
8947
|
* Calls the API with the project_default preprocessor (which falls back to "thread").
|
|
8461
8948
|
*/
|
|
8462
8949
|
async getThread(options) {
|
|
8463
|
-
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8950
|
+
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _157 => _157.preprocessor]), () => ( "project_default"));
|
|
8464
8951
|
if (!this.threadCache.has(cacheKey)) {
|
|
8465
8952
|
const promise = this.fetchThread(options);
|
|
8466
8953
|
this.threadCache.set(cacheKey, promise);
|
|
@@ -8471,7 +8958,7 @@ var LocalTrace = (_class6 = class {
|
|
|
8471
8958
|
await this.ensureSpansReady();
|
|
8472
8959
|
await this.state.login({});
|
|
8473
8960
|
const result = await invoke({
|
|
8474
|
-
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8961
|
+
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _158 => _158.preprocessor]), () => ( "project_default")),
|
|
8475
8962
|
functionType: "preprocessor",
|
|
8476
8963
|
input: {
|
|
8477
8964
|
trace_ref: {
|
|
@@ -8502,7 +8989,7 @@ var LocalTrace = (_class6 = class {
|
|
|
8502
8989
|
}
|
|
8503
8990
|
await this.spansFlushPromise;
|
|
8504
8991
|
}
|
|
8505
|
-
},
|
|
8992
|
+
}, _class7);
|
|
8506
8993
|
|
|
8507
8994
|
// src/reporters/progress.ts
|
|
8508
8995
|
var SimpleProgressReporter = class {
|
|
@@ -8528,20 +9015,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
8528
9015
|
prompt: _v3.z.string()
|
|
8529
9016
|
}),
|
|
8530
9017
|
_v3.z.object({
|
|
8531
|
-
messages: _v3.z.array(
|
|
9018
|
+
messages: _v3.z.array(_chunkXLLGRXGRjs.ChatCompletionMessageParam)
|
|
8532
9019
|
})
|
|
8533
9020
|
]);
|
|
8534
9021
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
8535
9022
|
_v3.z.object({
|
|
8536
9023
|
model: _v3.z.string(),
|
|
8537
|
-
params:
|
|
9024
|
+
params: _chunkXLLGRXGRjs.ModelParams.optional(),
|
|
8538
9025
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
8539
9026
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
8540
9027
|
})
|
|
8541
9028
|
);
|
|
8542
9029
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
8543
9030
|
_v3.z.object({
|
|
8544
|
-
tools: _v3.z.array(
|
|
9031
|
+
tools: _v3.z.array(_chunkXLLGRXGRjs.ToolFunctionDefinition).optional()
|
|
8545
9032
|
})
|
|
8546
9033
|
);
|
|
8547
9034
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -8589,7 +9076,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
8589
9076
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
8590
9077
|
return parameters;
|
|
8591
9078
|
}
|
|
8592
|
-
if (
|
|
9079
|
+
if (_chunkXLLGRXGRjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
8593
9080
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
8594
9081
|
...resolvedSchema.data,
|
|
8595
9082
|
...parameters
|
|
@@ -8611,14 +9098,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
8611
9098
|
const value = parameters[name];
|
|
8612
9099
|
try {
|
|
8613
9100
|
if ("type" in schema && schema.type === "prompt") {
|
|
8614
|
-
const promptData = value ?
|
|
9101
|
+
const promptData = value ? _chunkXLLGRXGRjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
8615
9102
|
schema.default,
|
|
8616
9103
|
schema.default.tools
|
|
8617
9104
|
) : void 0;
|
|
8618
9105
|
if (!promptData) {
|
|
8619
9106
|
throw new Error(`Parameter '${name}' is required`);
|
|
8620
9107
|
}
|
|
8621
|
-
return [name,
|
|
9108
|
+
return [name, _chunkXLLGRXGRjs.Prompt.fromPromptData(name, promptData)];
|
|
8622
9109
|
} else if ("type" in schema && schema.type === "model") {
|
|
8623
9110
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
8624
9111
|
if (model === void 0) {
|
|
@@ -8647,10 +9134,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
|
|
|
8647
9134
|
const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
|
|
8648
9135
|
const validate = ajv.compile(schema);
|
|
8649
9136
|
if (!validate(parameters)) {
|
|
8650
|
-
const errorMessages = _optionalChain([validate, 'access',
|
|
9137
|
+
const errorMessages = _optionalChain([validate, 'access', _159 => _159.errors, 'optionalAccess', _160 => _160.map, 'call', _161 => _161((err) => {
|
|
8651
9138
|
const path = err.instancePath || "root";
|
|
8652
9139
|
return `${path}: ${err.message}`;
|
|
8653
|
-
}), 'access',
|
|
9140
|
+
}), 'access', _162 => _162.join, 'call', _163 => _163(", ")]);
|
|
8654
9141
|
throw Error(`Invalid parameters: ${errorMessages}`);
|
|
8655
9142
|
}
|
|
8656
9143
|
return rehydrateRemoteParameters(parameters, schema);
|
|
@@ -8669,7 +9156,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
8669
9156
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
8670
9157
|
return [
|
|
8671
9158
|
name,
|
|
8672
|
-
|
|
9159
|
+
_chunkXLLGRXGRjs.Prompt.fromPromptData(name, _chunkXLLGRXGRjs.PromptData.parse(value))
|
|
8673
9160
|
];
|
|
8674
9161
|
}
|
|
8675
9162
|
return [name, value];
|
|
@@ -8707,7 +9194,7 @@ var EvalResultWithSummary = class {
|
|
|
8707
9194
|
async function getPersistedBaseExperimentId(experiment) {
|
|
8708
9195
|
try {
|
|
8709
9196
|
return await experiment._getBaseExperimentId();
|
|
8710
|
-
} catch (
|
|
9197
|
+
} catch (e10) {
|
|
8711
9198
|
return void 0;
|
|
8712
9199
|
}
|
|
8713
9200
|
}
|
|
@@ -8719,7 +9206,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
8719
9206
|
return out;
|
|
8720
9207
|
}
|
|
8721
9208
|
function initExperiment2(state, options = {}) {
|
|
8722
|
-
return
|
|
9209
|
+
return _chunkXLLGRXGRjs.init.call(void 0, {
|
|
8723
9210
|
state,
|
|
8724
9211
|
...options,
|
|
8725
9212
|
setCurrent: false
|
|
@@ -8730,7 +9217,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
8730
9217
|
return void 0;
|
|
8731
9218
|
}
|
|
8732
9219
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
8733
|
-
if (!
|
|
9220
|
+
if (!_chunkXLLGRXGRjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
8734
9221
|
return void 0;
|
|
8735
9222
|
}
|
|
8736
9223
|
if (resolvedParameters.id === void 0) {
|
|
@@ -8757,7 +9244,7 @@ async function _internalInitEvaluatorExperiment(projectName, evaluator, data, op
|
|
|
8757
9244
|
baseExperimentId: evaluator.baseExperimentId,
|
|
8758
9245
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
8759
9246
|
repoInfo: evaluator.repoInfo,
|
|
8760
|
-
dataset:
|
|
9247
|
+
dataset: _chunkXLLGRXGRjs.Dataset.isDataset(data) ? data : void 0,
|
|
8761
9248
|
parameters
|
|
8762
9249
|
});
|
|
8763
9250
|
}
|
|
@@ -8793,7 +9280,7 @@ async function _internalResolveEvaluatorData(evaluator, experiment) {
|
|
|
8793
9280
|
);
|
|
8794
9281
|
}
|
|
8795
9282
|
let name = dataResult.name;
|
|
8796
|
-
if (
|
|
9283
|
+
if (_chunkXLLGRXGRjs.isEmpty.call(void 0, name)) {
|
|
8797
9284
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
8798
9285
|
if (!baseExperiment) {
|
|
8799
9286
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -8828,10 +9315,10 @@ globalThis._evals = {
|
|
|
8828
9315
|
reporters: {}
|
|
8829
9316
|
};
|
|
8830
9317
|
function _initializeSpanContext() {
|
|
8831
|
-
globalThis._spanContext = { currentSpan:
|
|
9318
|
+
globalThis._spanContext = { currentSpan: _chunkXLLGRXGRjs.currentSpan, withCurrent: _chunkXLLGRXGRjs.withCurrent, startSpan: _chunkXLLGRXGRjs.startSpan, NOOP_SPAN: _chunkXLLGRXGRjs.NOOP_SPAN };
|
|
8832
9319
|
}
|
|
8833
9320
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
8834
|
-
const options =
|
|
9321
|
+
const options = _chunkXLLGRXGRjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
8835
9322
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
8836
9323
|
if (globalThis._evals.evaluators[evalName]) {
|
|
8837
9324
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -8890,7 +9377,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8890
9377
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
8891
9378
|
let ret;
|
|
8892
9379
|
if (options.parent) {
|
|
8893
|
-
ret = await
|
|
9380
|
+
ret = await _chunkXLLGRXGRjs.withParent.call(void 0,
|
|
8894
9381
|
options.parent,
|
|
8895
9382
|
() => runEvaluator(
|
|
8896
9383
|
null,
|
|
@@ -8926,7 +9413,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8926
9413
|
if (experiment) {
|
|
8927
9414
|
await experiment.flush().catch(console.error);
|
|
8928
9415
|
} else if (options.parent) {
|
|
8929
|
-
await
|
|
9416
|
+
await _chunkXLLGRXGRjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
8930
9417
|
}
|
|
8931
9418
|
}
|
|
8932
9419
|
} finally {
|
|
@@ -9009,7 +9496,7 @@ function _internalPrepareEvaluatorScore(scoreValue, name) {
|
|
|
9009
9496
|
if (scoreValue === null) return { results: null };
|
|
9010
9497
|
if (Array.isArray(scoreValue)) {
|
|
9011
9498
|
for (const score of scoreValue) {
|
|
9012
|
-
if (!(typeof score === "object" && !
|
|
9499
|
+
if (!(typeof score === "object" && !_chunkXLLGRXGRjs.isEmpty.call(void 0, score))) {
|
|
9013
9500
|
throw new Error(
|
|
9014
9501
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(score)}`
|
|
9015
9502
|
);
|
|
@@ -9019,7 +9506,7 @@ function _internalPrepareEvaluatorScore(scoreValue, name) {
|
|
|
9019
9506
|
let results;
|
|
9020
9507
|
if (Array.isArray(scoreValue)) {
|
|
9021
9508
|
results = scoreValue;
|
|
9022
|
-
} else if (typeof scoreValue === "object" && !
|
|
9509
|
+
} else if (typeof scoreValue === "object" && !_chunkXLLGRXGRjs.isEmpty.call(void 0, scoreValue)) {
|
|
9023
9510
|
results = [scoreValue];
|
|
9024
9511
|
} else {
|
|
9025
9512
|
results = [{ name, score: scoreValue }];
|
|
@@ -9063,7 +9550,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
9063
9550
|
return failing;
|
|
9064
9551
|
}
|
|
9065
9552
|
function validateClassificationResult(value, scorerName2) {
|
|
9066
|
-
if (!(typeof value === "object" && value !== null && !
|
|
9553
|
+
if (!(typeof value === "object" && value !== null && !_chunkXLLGRXGRjs.isEmpty.call(void 0, value))) {
|
|
9067
9554
|
throw new Error(
|
|
9068
9555
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
9069
9556
|
);
|
|
@@ -9113,7 +9600,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
9113
9600
|
);
|
|
9114
9601
|
metadata[`${kind}_errors`] = errorMap;
|
|
9115
9602
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
9116
|
-
|
|
9603
|
+
_chunk6Z5S7VOUjs.debugLogger.forState(state).warn(
|
|
9117
9604
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
9118
9605
|
failures.map((f) => f.error)
|
|
9119
9606
|
);
|
|
@@ -9147,7 +9634,7 @@ var defaultErrorScoreHandler = ({
|
|
|
9147
9634
|
};
|
|
9148
9635
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
9149
9636
|
if (enableCache) {
|
|
9150
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
9637
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _164 => _164.spanCache, 'optionalAccess', _165 => _165.start, 'call', _166 => _166()]);
|
|
9151
9638
|
}
|
|
9152
9639
|
try {
|
|
9153
9640
|
parameters = await validateParameters(
|
|
@@ -9162,7 +9649,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9162
9649
|
const experimentIdPromise = experiment ? (async () => {
|
|
9163
9650
|
try {
|
|
9164
9651
|
return await experiment.id;
|
|
9165
|
-
} catch (
|
|
9652
|
+
} catch (e11) {
|
|
9166
9653
|
return void 0;
|
|
9167
9654
|
}
|
|
9168
9655
|
})() : void 0;
|
|
@@ -9178,7 +9665,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9178
9665
|
if (cancelled) {
|
|
9179
9666
|
return;
|
|
9180
9667
|
}
|
|
9181
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
9668
|
+
const eventDataset = experiment ? experiment.dataset : _chunkXLLGRXGRjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
9182
9669
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
9183
9670
|
object_type: "dataset",
|
|
9184
9671
|
object_id: await eventDataset.id,
|
|
@@ -9186,8 +9673,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9186
9673
|
created: datum.created,
|
|
9187
9674
|
_xact_id: datum._xact_id
|
|
9188
9675
|
} : void 0;
|
|
9189
|
-
const parsedDatumOrigin =
|
|
9190
|
-
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess',
|
|
9676
|
+
const parsedDatumOrigin = _chunkXLLGRXGRjs.ObjectReference.safeParse(datum.origin);
|
|
9677
|
+
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _167 => _167.success]) ? parsedDatumOrigin.data : void 0)));
|
|
9191
9678
|
const baseEvent = {
|
|
9192
9679
|
name: "eval",
|
|
9193
9680
|
spanAttributes: {
|
|
@@ -9202,26 +9689,26 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9202
9689
|
}
|
|
9203
9690
|
};
|
|
9204
9691
|
const callback = async (rootSpan) => {
|
|
9205
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
9692
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, )));
|
|
9206
9693
|
const ensureSpansFlushed = async () => {
|
|
9207
9694
|
if (experiment) {
|
|
9208
|
-
await
|
|
9695
|
+
await _chunkXLLGRXGRjs.flush.call(void 0, { state: experiment.loggingState });
|
|
9209
9696
|
} else if (state) {
|
|
9210
|
-
await
|
|
9697
|
+
await _chunkXLLGRXGRjs.flush.call(void 0, { state });
|
|
9211
9698
|
} else {
|
|
9212
|
-
await
|
|
9699
|
+
await _chunkXLLGRXGRjs.flush.call(void 0, );
|
|
9213
9700
|
}
|
|
9214
9701
|
if (state) {
|
|
9215
9702
|
await state.flushOtel();
|
|
9216
9703
|
}
|
|
9217
9704
|
};
|
|
9218
9705
|
const parentStr = state.currentParent.getStore();
|
|
9219
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
9706
|
+
const parentComponents = typeof parentStr === "string" ? _chunkXLLGRXGRjs.SpanComponentsV4.fromStr(parentStr) : null;
|
|
9220
9707
|
const trace = state ? new LocalTrace({
|
|
9221
|
-
objectType: parentComponents ?
|
|
9708
|
+
objectType: parentComponents ? _chunkXLLGRXGRjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
9222
9709
|
parentComponents.data.object_type
|
|
9223
9710
|
) : "experiment",
|
|
9224
|
-
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async
|
|
9711
|
+
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _168 => _168.data, 'access', async _169 => _169.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
9225
9712
|
rootSpanId: rootSpan.rootSpanId,
|
|
9226
9713
|
ensureSpansFlushed,
|
|
9227
9714
|
state
|
|
@@ -9247,10 +9734,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9247
9734
|
_nullishCoalesce(parameters, () => ( {})),
|
|
9248
9735
|
span,
|
|
9249
9736
|
(event) => {
|
|
9250
|
-
_optionalChain([stream, 'optionalCall',
|
|
9737
|
+
_optionalChain([stream, 'optionalCall', _170 => _170({
|
|
9251
9738
|
...event,
|
|
9252
9739
|
id: rootSpan.id,
|
|
9253
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
9740
|
+
origin: _optionalChain([baseEvent, 'access', _171 => _171.event, 'optionalAccess', _172 => _172.origin]),
|
|
9254
9741
|
name: evaluator.evalName,
|
|
9255
9742
|
object_type: "task"
|
|
9256
9743
|
})]);
|
|
@@ -9283,7 +9770,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9283
9770
|
trace
|
|
9284
9771
|
};
|
|
9285
9772
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
9286
|
-
const propagatedEvent =
|
|
9773
|
+
const propagatedEvent = _chunkXLLGRXGRjs.makeScorerPropagatedEvent.call(void 0,
|
|
9287
9774
|
await rootSpan.export()
|
|
9288
9775
|
);
|
|
9289
9776
|
const [scoreResults, classificationResults] = await Promise.all([
|
|
@@ -9378,7 +9865,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9378
9865
|
evaluator.state
|
|
9379
9866
|
);
|
|
9380
9867
|
} catch (e) {
|
|
9381
|
-
|
|
9868
|
+
_chunkXLLGRXGRjs.logError.call(void 0, rootSpan, e);
|
|
9382
9869
|
error = e;
|
|
9383
9870
|
} finally {
|
|
9384
9871
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -9402,7 +9889,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9402
9889
|
tags: tags.length ? tags : void 0,
|
|
9403
9890
|
metadata,
|
|
9404
9891
|
error,
|
|
9405
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
9892
|
+
origin: _optionalChain([baseEvent, 'access', _173 => _173.event, 'optionalAccess', _174 => _174.origin])
|
|
9406
9893
|
};
|
|
9407
9894
|
collectedResults.push({
|
|
9408
9895
|
...baseResult,
|
|
@@ -9412,7 +9899,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9412
9899
|
}
|
|
9413
9900
|
};
|
|
9414
9901
|
if (!experiment) {
|
|
9415
|
-
return await
|
|
9902
|
+
return await _chunkXLLGRXGRjs.traced.call(void 0, callback, {
|
|
9416
9903
|
...baseEvent,
|
|
9417
9904
|
state: evaluator.state
|
|
9418
9905
|
});
|
|
@@ -9442,7 +9929,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9442
9929
|
break;
|
|
9443
9930
|
}
|
|
9444
9931
|
scheduledTrials++;
|
|
9445
|
-
_optionalChain([progressReporter, 'access',
|
|
9932
|
+
_optionalChain([progressReporter, 'access', _175 => _175.setTotal, 'optionalCall', _176 => _176(evaluator.evalName, scheduledTrials)]);
|
|
9446
9933
|
q.pushAsync({ datum, trialIndex }).catch((e) => {
|
|
9447
9934
|
if (queueErrors.length < 5) {
|
|
9448
9935
|
queueErrors.push(e);
|
|
@@ -9466,7 +9953,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9466
9953
|
const cancel = async () => {
|
|
9467
9954
|
await new Promise((_, reject2) => {
|
|
9468
9955
|
if (cancelled) {
|
|
9469
|
-
reject2(new (0,
|
|
9956
|
+
reject2(new (0, _chunkXLLGRXGRjs.InternalAbortError)("Evaluator already cancelled"));
|
|
9470
9957
|
return;
|
|
9471
9958
|
}
|
|
9472
9959
|
const rejectOnce = (error) => {
|
|
@@ -9479,12 +9966,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9479
9966
|
};
|
|
9480
9967
|
if (evaluator.timeout) {
|
|
9481
9968
|
timeoutId = setTimeout(() => {
|
|
9482
|
-
rejectOnce(new (0,
|
|
9969
|
+
rejectOnce(new (0, _chunkXLLGRXGRjs.InternalAbortError)("Evaluator timed out"));
|
|
9483
9970
|
}, evaluator.timeout);
|
|
9484
9971
|
}
|
|
9485
9972
|
if (evaluator.signal) {
|
|
9486
9973
|
abortHandler = () => {
|
|
9487
|
-
rejectOnce(new (0,
|
|
9974
|
+
rejectOnce(new (0, _chunkXLLGRXGRjs.InternalAbortError)("Evaluator aborted"));
|
|
9488
9975
|
};
|
|
9489
9976
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
9490
9977
|
}
|
|
@@ -9507,9 +9994,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9507
9994
|
}
|
|
9508
9995
|
} catch (e) {
|
|
9509
9996
|
q.kill();
|
|
9510
|
-
if (e instanceof
|
|
9511
|
-
if (
|
|
9512
|
-
|
|
9997
|
+
if (e instanceof _chunkXLLGRXGRjs.InternalAbortError) {
|
|
9998
|
+
if (_chunk6Z5S7VOUjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
9999
|
+
_chunk6Z5S7VOUjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
9513
10000
|
}
|
|
9514
10001
|
}
|
|
9515
10002
|
throw e;
|
|
@@ -9534,9 +10021,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9534
10021
|
);
|
|
9535
10022
|
} finally {
|
|
9536
10023
|
if (enableCache) {
|
|
9537
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
9538
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
9539
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
10024
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _177 => _177.spanCache]);
|
|
10025
|
+
_optionalChain([spanCache, 'optionalAccess', _178 => _178.dispose, 'call', _179 => _179()]);
|
|
10026
|
+
_optionalChain([spanCache, 'optionalAccess', _180 => _180.stop, 'call', _181 => _181()]);
|
|
9540
10027
|
}
|
|
9541
10028
|
}
|
|
9542
10029
|
}
|
|
@@ -9629,25 +10116,25 @@ var defaultReporter = {
|
|
|
9629
10116
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
9630
10117
|
}
|
|
9631
10118
|
if (jsonl) {
|
|
9632
|
-
|
|
10119
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
9633
10120
|
} else {
|
|
9634
|
-
|
|
9635
|
-
|
|
10121
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln("Experiment summary");
|
|
10122
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln("==================");
|
|
9636
10123
|
if (summary.comparisonExperimentName) {
|
|
9637
|
-
|
|
10124
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(
|
|
9638
10125
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
9639
10126
|
);
|
|
9640
|
-
|
|
10127
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln("");
|
|
9641
10128
|
}
|
|
9642
10129
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
9643
10130
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
9644
10131
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
9645
10132
|
if (hasScores || hasMetrics) {
|
|
9646
10133
|
if (hasComparison) {
|
|
9647
|
-
|
|
10134
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(
|
|
9648
10135
|
"Name Value Change Improvements Regressions"
|
|
9649
10136
|
);
|
|
9650
|
-
|
|
10137
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(
|
|
9651
10138
|
"----------------------------------------------------------------"
|
|
9652
10139
|
);
|
|
9653
10140
|
}
|
|
@@ -9656,18 +10143,18 @@ var defaultReporter = {
|
|
|
9656
10143
|
const scoreValue = `${scorePercent}%`;
|
|
9657
10144
|
if (hasComparison) {
|
|
9658
10145
|
let diffString = "-";
|
|
9659
|
-
if (!
|
|
10146
|
+
if (!_chunkXLLGRXGRjs.isEmpty.call(void 0, score.diff)) {
|
|
9660
10147
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
9661
10148
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
9662
10149
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9663
10150
|
}
|
|
9664
10151
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
9665
10152
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
9666
|
-
|
|
10153
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(
|
|
9667
10154
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9668
10155
|
);
|
|
9669
10156
|
} else {
|
|
9670
|
-
|
|
10157
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
9671
10158
|
}
|
|
9672
10159
|
}
|
|
9673
10160
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -9676,30 +10163,30 @@ var defaultReporter = {
|
|
|
9676
10163
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
9677
10164
|
if (hasComparison) {
|
|
9678
10165
|
let diffString = "-";
|
|
9679
|
-
if (!
|
|
10166
|
+
if (!_chunkXLLGRXGRjs.isEmpty.call(void 0, metric.diff)) {
|
|
9680
10167
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
9681
10168
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
9682
10169
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9683
10170
|
}
|
|
9684
10171
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
9685
10172
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
9686
|
-
|
|
10173
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(
|
|
9687
10174
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9688
10175
|
);
|
|
9689
10176
|
} else {
|
|
9690
|
-
|
|
10177
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(
|
|
9691
10178
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
9692
10179
|
);
|
|
9693
10180
|
}
|
|
9694
10181
|
}
|
|
9695
10182
|
}
|
|
9696
10183
|
if (summary.experimentUrl) {
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
10184
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln("");
|
|
10185
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(`View results for ${summary.experimentName}`);
|
|
10186
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
|
|
9700
10187
|
}
|
|
9701
10188
|
}
|
|
9702
|
-
|
|
10189
|
+
_chunk6Z5S7VOUjs.isomorph_default.writeln("");
|
|
9703
10190
|
return failingResults.length === 0;
|
|
9704
10191
|
},
|
|
9705
10192
|
async reportRun(evalReports) {
|
|
@@ -9713,10 +10200,10 @@ var decoder = new TextDecoder();
|
|
|
9713
10200
|
var BATCH_TASK_KIND = "braintrust.durable.batch-task";
|
|
9714
10201
|
var BATCH_SCORER_KIND = "braintrust.durable.batch-scorer";
|
|
9715
10202
|
var DEFAULT_BATCH_SIZE = 1e3;
|
|
9716
|
-
var DurableEvalMemoryStore = (
|
|
9717
|
-
|
|
10203
|
+
var DurableEvalMemoryStore = (_class8 = class {constructor() { _class8.prototype.__init21.call(this); }
|
|
10204
|
+
__init21() {this.values = /* @__PURE__ */ new Map()}
|
|
9718
10205
|
async read(key) {
|
|
9719
|
-
return _optionalChain([this, 'access',
|
|
10206
|
+
return _optionalChain([this, 'access', _182 => _182.values, 'access', _183 => _183.get, 'call', _184 => _184(key), 'optionalAccess', _185 => _185.slice, 'call', _186 => _186()]);
|
|
9720
10207
|
}
|
|
9721
10208
|
async write(key, value) {
|
|
9722
10209
|
this.values.set(key, value.slice());
|
|
@@ -9727,7 +10214,7 @@ var DurableEvalMemoryStore = (_class7 = class {constructor() { _class7.prototype
|
|
|
9727
10214
|
this.values.set(key, value.slice());
|
|
9728
10215
|
return { value: value.slice(), created: true };
|
|
9729
10216
|
}
|
|
9730
|
-
},
|
|
10217
|
+
}, _class8);
|
|
9731
10218
|
var DurableEvalRedisStore = class {
|
|
9732
10219
|
|
|
9733
10220
|
|
|
@@ -9746,13 +10233,13 @@ var DurableEvalRedisStore = class {
|
|
|
9746
10233
|
if (typeof value !== "string") {
|
|
9747
10234
|
throw new Error("DurableEvalRedisStore expected GET to return a string");
|
|
9748
10235
|
}
|
|
9749
|
-
return
|
|
10236
|
+
return _chunkXLLGRXGRjs.base64ToUint8Array.call(void 0, value);
|
|
9750
10237
|
}
|
|
9751
10238
|
async write(key, value) {
|
|
9752
10239
|
const client = this.client;
|
|
9753
10240
|
const set = client.set;
|
|
9754
10241
|
const redisKey = `${this.keyPrefix}${key}`;
|
|
9755
|
-
const encoded =
|
|
10242
|
+
const encoded = _chunkXLLGRXGRjs.uint8ArrayToBase64.call(void 0, value);
|
|
9756
10243
|
if (typeof client.defineCommand === "function") {
|
|
9757
10244
|
await set.call(client, redisKey, encoded, "PX", this.ttlMs);
|
|
9758
10245
|
} else if (typeof client.sendCommand === "function") {
|
|
@@ -9767,7 +10254,7 @@ var DurableEvalRedisStore = class {
|
|
|
9767
10254
|
}
|
|
9768
10255
|
async getOrSet(key, value) {
|
|
9769
10256
|
const redisKey = `${this.keyPrefix}${key}`;
|
|
9770
|
-
const encoded =
|
|
10257
|
+
const encoded = _chunkXLLGRXGRjs.uint8ArrayToBase64.call(void 0, value);
|
|
9771
10258
|
const client = this.client;
|
|
9772
10259
|
const set = client.set;
|
|
9773
10260
|
let setOptions;
|
|
@@ -9789,25 +10276,25 @@ var DurableEvalRedisStore = class {
|
|
|
9789
10276
|
"DurableEvalRedisStore expected atomic SET to return a string or null"
|
|
9790
10277
|
);
|
|
9791
10278
|
}
|
|
9792
|
-
return { value:
|
|
10279
|
+
return { value: _chunkXLLGRXGRjs.base64ToUint8Array.call(void 0, existing), created: false };
|
|
9793
10280
|
}
|
|
9794
10281
|
};
|
|
9795
|
-
var BatchTask = (
|
|
9796
|
-
constructor(processor) {;
|
|
10282
|
+
var BatchTask = (_class9 = class {
|
|
10283
|
+
constructor(processor) {;_class9.prototype.__init22.call(this);
|
|
9797
10284
|
this.processor = processor;
|
|
9798
10285
|
}
|
|
9799
10286
|
|
|
9800
|
-
|
|
9801
|
-
},
|
|
9802
|
-
var BatchScorer = (
|
|
9803
|
-
constructor(processor) {;
|
|
10287
|
+
__init22() {this.kind = BATCH_TASK_KIND}
|
|
10288
|
+
}, _class9);
|
|
10289
|
+
var BatchScorer = (_class10 = class {
|
|
10290
|
+
constructor(processor) {;_class10.prototype.__init23.call(this);
|
|
9804
10291
|
this.processor = processor;
|
|
9805
10292
|
this.name = processor.name;
|
|
9806
10293
|
}
|
|
9807
10294
|
|
|
9808
|
-
|
|
10295
|
+
__init23() {this.kind = BATCH_SCORER_KIND}
|
|
9809
10296
|
|
|
9810
|
-
},
|
|
10297
|
+
}, _class10);
|
|
9811
10298
|
function defineDurableEval(projectName, evaluator) {
|
|
9812
10299
|
const definition = {
|
|
9813
10300
|
projectName,
|
|
@@ -9823,7 +10310,7 @@ function defineDurableEval(projectName, evaluator) {
|
|
|
9823
10310
|
}
|
|
9824
10311
|
async function startDurableEval(definition, options) {
|
|
9825
10312
|
const store = definition.evaluator.store;
|
|
9826
|
-
const runId =
|
|
10313
|
+
const runId = _chunkXLLGRXGRjs.newId.call(void 0, );
|
|
9827
10314
|
const key = runKey(definition.projectName, definition.evalName, runId);
|
|
9828
10315
|
const { data } = callEvaluatorData(definition.evaluator.data);
|
|
9829
10316
|
const parameters = await validateParameters(
|
|
@@ -9871,7 +10358,7 @@ async function startDurableEval(definition, options) {
|
|
|
9871
10358
|
cases: [],
|
|
9872
10359
|
batches: []
|
|
9873
10360
|
};
|
|
9874
|
-
await _optionalChain([experiment, 'optionalAccess',
|
|
10361
|
+
await _optionalChain([experiment, 'optionalAccess', _187 => _187.flush, 'call', _188 => _188()]);
|
|
9875
10362
|
await writeRunRecord(store, key, state2);
|
|
9876
10363
|
return currentStatus(definition, state2);
|
|
9877
10364
|
}
|
|
@@ -10036,9 +10523,9 @@ function currentStatus(definition, state) {
|
|
|
10036
10523
|
return { status: "waiting", runId: state.runId, pending };
|
|
10037
10524
|
}
|
|
10038
10525
|
async function startCaseRoot(definition, state, record, experiment) {
|
|
10039
|
-
if (!experiment) return
|
|
10526
|
+
if (!experiment) return _chunkXLLGRXGRjs.NOOP_SPAN;
|
|
10040
10527
|
const datum = record.datum;
|
|
10041
|
-
return
|
|
10528
|
+
return _chunkXLLGRXGRjs._internalStartSpanWithInitialMerge.call(void 0, {
|
|
10042
10529
|
...definition.evaluator.state ? { state: definition.evaluator.state } : {},
|
|
10043
10530
|
parent: await experiment.export(),
|
|
10044
10531
|
name: "eval",
|
|
@@ -10104,7 +10591,7 @@ async function logTaskResult(definition, state, record, experiment, task) {
|
|
|
10104
10591
|
record.rootSpan = await root.export();
|
|
10105
10592
|
record.taskLogged = true;
|
|
10106
10593
|
} catch (error) {
|
|
10107
|
-
|
|
10594
|
+
_chunkXLLGRXGRjs.logError.call(void 0, root, error);
|
|
10108
10595
|
throw error;
|
|
10109
10596
|
} finally {
|
|
10110
10597
|
root.end();
|
|
@@ -10119,7 +10606,7 @@ async function logCompletedTasks(definition, state, store, key, experiment) {
|
|
|
10119
10606
|
changed.push(record);
|
|
10120
10607
|
}
|
|
10121
10608
|
if (changed.length > 0) {
|
|
10122
|
-
await _optionalChain([experiment, 'optionalAccess',
|
|
10609
|
+
await _optionalChain([experiment, 'optionalAccess', _189 => _189.flush, 'call', _190 => _190()]);
|
|
10123
10610
|
await writeCaseRecords(store, key, changed);
|
|
10124
10611
|
}
|
|
10125
10612
|
}
|
|
@@ -10137,7 +10624,7 @@ async function runTaskStage(definition, state, store, key, experiment) {
|
|
|
10137
10624
|
changed.push(record);
|
|
10138
10625
|
}
|
|
10139
10626
|
if (changed.length > 0) {
|
|
10140
|
-
await _optionalChain([experiment, 'optionalAccess',
|
|
10627
|
+
await _optionalChain([experiment, 'optionalAccess', _191 => _191.flush, 'call', _192 => _192()]);
|
|
10141
10628
|
await writeCaseRecords(store, key, changed);
|
|
10142
10629
|
}
|
|
10143
10630
|
}
|
|
@@ -10146,7 +10633,7 @@ async function runScoreStages(definition, state, store, key, experiment) {
|
|
|
10146
10633
|
const changed = /* @__PURE__ */ new Map();
|
|
10147
10634
|
const persistChangedCases = async () => {
|
|
10148
10635
|
if (changed.size === 0) return;
|
|
10149
|
-
await _optionalChain([experiment, 'optionalAccess',
|
|
10636
|
+
await _optionalChain([experiment, 'optionalAccess', _193 => _193.flush, 'call', _194 => _194()]);
|
|
10150
10637
|
await writeCaseRecords(store, key, [...changed.values()]);
|
|
10151
10638
|
changed.clear();
|
|
10152
10639
|
};
|
|
@@ -10214,11 +10701,11 @@ function scorerArgs(record) {
|
|
|
10214
10701
|
};
|
|
10215
10702
|
}
|
|
10216
10703
|
function resumeCaseRoot(definition, record, experiment) {
|
|
10217
|
-
if (!experiment) return
|
|
10704
|
+
if (!experiment) return _chunkXLLGRXGRjs.NOOP_SPAN;
|
|
10218
10705
|
if (!record.rootSpan) {
|
|
10219
10706
|
throw new Error(`Durable eval case ${record.caseId} has no root span`);
|
|
10220
10707
|
}
|
|
10221
|
-
return
|
|
10708
|
+
return _chunkXLLGRXGRjs._internalResumeSpan.call(void 0, {
|
|
10222
10709
|
exported: record.rootSpan,
|
|
10223
10710
|
state: definition.evaluator.state
|
|
10224
10711
|
});
|
|
@@ -10250,14 +10737,14 @@ async function evaluateAndLogScore(definition, state, record, name, experiment,
|
|
|
10250
10737
|
type: "score" /* SCORE */,
|
|
10251
10738
|
purpose: "scorer"
|
|
10252
10739
|
},
|
|
10253
|
-
propagatedEvent:
|
|
10740
|
+
propagatedEvent: _chunkXLLGRXGRjs.makeScorerPropagatedEvent.call(void 0, rootExport || void 0),
|
|
10254
10741
|
event: { input: scorerArgs(record) }
|
|
10255
10742
|
}
|
|
10256
10743
|
);
|
|
10257
10744
|
if (prepared.scores) root.log({ scores: prepared.scores });
|
|
10258
10745
|
record.loggedScores[name] = true;
|
|
10259
10746
|
} catch (error) {
|
|
10260
|
-
|
|
10747
|
+
_chunkXLLGRXGRjs.logError.call(void 0, root, error);
|
|
10261
10748
|
throw error;
|
|
10262
10749
|
} finally {
|
|
10263
10750
|
root.end();
|
|
@@ -10289,7 +10776,7 @@ async function evaluateAndLogClassification(definition, state, record, name, cla
|
|
|
10289
10776
|
type: "classifier" /* CLASSIFIER */,
|
|
10290
10777
|
purpose: "scorer"
|
|
10291
10778
|
},
|
|
10292
|
-
propagatedEvent:
|
|
10779
|
+
propagatedEvent: _chunkXLLGRXGRjs.makeScorerPropagatedEvent.call(void 0, rootExport || void 0),
|
|
10293
10780
|
event: { input: scorerArgs(record) }
|
|
10294
10781
|
}
|
|
10295
10782
|
);
|
|
@@ -10298,7 +10785,7 @@ async function evaluateAndLogClassification(definition, state, record, name, cla
|
|
|
10298
10785
|
}
|
|
10299
10786
|
record.loggedClassifications[name] = true;
|
|
10300
10787
|
} catch (error) {
|
|
10301
|
-
|
|
10788
|
+
_chunkXLLGRXGRjs.logError.call(void 0, root, error);
|
|
10302
10789
|
throw error;
|
|
10303
10790
|
} finally {
|
|
10304
10791
|
root.end();
|
|
@@ -10411,9 +10898,9 @@ function processorForStage(definition, kind, scorerName2) {
|
|
|
10411
10898
|
}
|
|
10412
10899
|
return definition.evaluator.task.processor;
|
|
10413
10900
|
}
|
|
10414
|
-
const scorer = _optionalChain([resolveScorers, 'call',
|
|
10901
|
+
const scorer = _optionalChain([resolveScorers, 'call', _195 => _195(_nullishCoalesce(definition.evaluator.scores, () => ( []))), 'access', _196 => _196.find, 'call', _197 => _197(
|
|
10415
10902
|
({ name }) => name === scorerName2
|
|
10416
|
-
), 'optionalAccess',
|
|
10903
|
+
), 'optionalAccess', _198 => _198.scorer]);
|
|
10417
10904
|
if (!isBatchScorer(scorer)) {
|
|
10418
10905
|
throw new Error(`Definition no longer contains scorer ${scorerName2}`);
|
|
10419
10906
|
}
|
|
@@ -10540,7 +11027,7 @@ async function finishExperiment(definition, state, experiment) {
|
|
|
10540
11027
|
if (!comparisonExperimentId) {
|
|
10541
11028
|
try {
|
|
10542
11029
|
comparisonExperimentId = await experiment._getBaseExperimentId();
|
|
10543
|
-
} catch (
|
|
11030
|
+
} catch (e12) {
|
|
10544
11031
|
comparisonExperimentId = void 0;
|
|
10545
11032
|
}
|
|
10546
11033
|
}
|
|
@@ -10559,7 +11046,7 @@ function runKey(projectName, evalName, runId) {
|
|
|
10559
11046
|
return `durable-eval/v1/runs/${contentVersion(encoder.encode(`${projectName}\0${evalName}\0${runId}`))}`;
|
|
10560
11047
|
}
|
|
10561
11048
|
function encodedKeyPart(value) {
|
|
10562
|
-
return
|
|
11049
|
+
return _chunkXLLGRXGRjs.uint8ArrayToBase64.call(void 0, encoder.encode(value)).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
10563
11050
|
}
|
|
10564
11051
|
function caseRecordKey(key, caseId, kind, ...names) {
|
|
10565
11052
|
const suffix = names.map(encodedKeyPart).join("/");
|
|
@@ -10683,12 +11170,12 @@ async function readCaseRecord(definition, store, key, id) {
|
|
|
10683
11170
|
}
|
|
10684
11171
|
return {
|
|
10685
11172
|
...base,
|
|
10686
|
-
metadata: _nullishCoalesce(_optionalChain([task, 'optionalAccess',
|
|
11173
|
+
metadata: _nullishCoalesce(_optionalChain([task, 'optionalAccess', _199 => _199.metadata]), () => ( base.metadata)),
|
|
10687
11174
|
tags: task ? task.tags : base.tags,
|
|
10688
11175
|
taskComplete: task !== void 0,
|
|
10689
11176
|
taskLogged: taskLog !== void 0,
|
|
10690
|
-
output: _optionalChain([task, 'optionalAccess',
|
|
10691
|
-
rootSpan: _optionalChain([taskLog, 'optionalAccess',
|
|
11177
|
+
output: _optionalChain([task, 'optionalAccess', _200 => _200.output]),
|
|
11178
|
+
rootSpan: _optionalChain([taskLog, 'optionalAccess', _201 => _201.rootSpan]),
|
|
10692
11179
|
scores,
|
|
10693
11180
|
loggedScores,
|
|
10694
11181
|
classifications,
|
|
@@ -10804,7 +11291,7 @@ function deterministicId(value) {
|
|
|
10804
11291
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-5${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
10805
11292
|
}
|
|
10806
11293
|
function contentVersion(value) {
|
|
10807
|
-
if (
|
|
11294
|
+
if (_chunk6Z5S7VOUjs.isomorph_default.hash) return _chunk6Z5S7VOUjs.isomorph_default.hash(decoder.decode(value));
|
|
10808
11295
|
let hash = 2166136261;
|
|
10809
11296
|
for (const byte of value) {
|
|
10810
11297
|
hash ^= byte;
|
|
@@ -10869,7 +11356,7 @@ function agentAssertionScorer(callback, options = {}) {
|
|
|
10869
11356
|
});
|
|
10870
11357
|
const resources = {};
|
|
10871
11358
|
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
10872
|
-
resources.spans = await _optionalChain([args, 'access',
|
|
11359
|
+
resources.spans = await _optionalChain([args, 'access', _202 => _202.trace, 'optionalAccess', _203 => _203.getSpans, 'call', _204 => _204({ spanType: ["tool"] })]);
|
|
10873
11360
|
}
|
|
10874
11361
|
const results = await Promise.all(
|
|
10875
11362
|
assertions.map(async (assertion) => {
|
|
@@ -11027,7 +11514,7 @@ async function validateSchema(schema, value) {
|
|
|
11027
11514
|
}
|
|
11028
11515
|
}
|
|
11029
11516
|
function toolCalls(spans) {
|
|
11030
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
11517
|
+
return spans.filter((span) => _optionalChain([span, 'access', _205 => _205.span_attributes, 'optionalAccess', _206 => _206.type]) === "tool");
|
|
11031
11518
|
}
|
|
11032
11519
|
function matchingToolCalls(spans, toolName, options) {
|
|
11033
11520
|
return toolCalls(spans).filter((span) => {
|
|
@@ -11045,17 +11532,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
11045
11532
|
});
|
|
11046
11533
|
}
|
|
11047
11534
|
function getToolName(span) {
|
|
11048
|
-
const spanName = [_optionalChain([span, 'access',
|
|
11049
|
-
if (_optionalChain([spanName, 'optionalAccess',
|
|
11535
|
+
const spanName = [_optionalChain([span, 'access', _207 => _207.span_attributes, 'optionalAccess', _208 => _208.name]), span.name].map(normalizeToolName).find((value) => value !== void 0);
|
|
11536
|
+
if (_optionalChain([spanName, 'optionalAccess', _209 => _209.includes, 'call', _210 => _210("/")])) {
|
|
11050
11537
|
return spanName;
|
|
11051
11538
|
}
|
|
11052
11539
|
const metadataName = [
|
|
11053
|
-
_optionalChain([span, 'access',
|
|
11054
|
-
_optionalChain([span, 'access',
|
|
11540
|
+
_optionalChain([span, 'access', _211 => _211.metadata, 'optionalAccess', _212 => _212.tool_name]),
|
|
11541
|
+
_optionalChain([span, 'access', _213 => _213.metadata, 'optionalAccess', _214 => _214["gen_ai.tool.name"]])
|
|
11055
11542
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
11056
11543
|
const mcpServer = [
|
|
11057
|
-
_optionalChain([span, 'access',
|
|
11058
|
-
_optionalChain([span, 'access',
|
|
11544
|
+
_optionalChain([span, 'access', _215 => _215.metadata, 'optionalAccess', _216 => _216["mcp.server"]]),
|
|
11545
|
+
_optionalChain([span, 'access', _217 => _217.metadata, 'optionalAccess', _218 => _218["openai_codex.mcp.server"]])
|
|
11059
11546
|
].find((value) => typeof value === "string" && value !== "");
|
|
11060
11547
|
if (metadataName && mcpServer) {
|
|
11061
11548
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -11125,7 +11612,7 @@ function formatValue(value) {
|
|
|
11125
11612
|
return serialized;
|
|
11126
11613
|
}
|
|
11127
11614
|
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
11128
|
-
} catch (
|
|
11615
|
+
} catch (e13) {
|
|
11129
11616
|
return String(value);
|
|
11130
11617
|
}
|
|
11131
11618
|
}
|
|
@@ -11238,7 +11725,7 @@ var ProjectBuilder = class {
|
|
|
11238
11725
|
}
|
|
11239
11726
|
};
|
|
11240
11727
|
var projects = new ProjectBuilder();
|
|
11241
|
-
var Project2 = (
|
|
11728
|
+
var Project2 = (_class11 = class {
|
|
11242
11729
|
|
|
11243
11730
|
|
|
11244
11731
|
|
|
@@ -11246,10 +11733,10 @@ var Project2 = (_class10 = class {
|
|
|
11246
11733
|
|
|
11247
11734
|
|
|
11248
11735
|
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
constructor(args) {;
|
|
11736
|
+
__init24() {this._publishableCodeFunctions = []}
|
|
11737
|
+
__init25() {this._publishablePrompts = []}
|
|
11738
|
+
__init26() {this._publishableParameters = []}
|
|
11739
|
+
constructor(args) {;_class11.prototype.__init24.call(this);_class11.prototype.__init25.call(this);_class11.prototype.__init26.call(this);
|
|
11253
11740
|
_initializeSpanContext();
|
|
11254
11741
|
this.name = "name" in args ? args.name : void 0;
|
|
11255
11742
|
this.id = "id" in args ? args.id : void 0;
|
|
@@ -11284,7 +11771,7 @@ var Project2 = (_class10 = class {
|
|
|
11284
11771
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
11285
11772
|
return;
|
|
11286
11773
|
}
|
|
11287
|
-
await
|
|
11774
|
+
await _chunkXLLGRXGRjs.login.call(void 0, );
|
|
11288
11775
|
const projectMap = new ProjectNameIdMap();
|
|
11289
11776
|
const functionDefinitions = [];
|
|
11290
11777
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -11298,17 +11785,17 @@ var Project2 = (_class10 = class {
|
|
|
11298
11785
|
functionDefinitions.push(functionDefinition);
|
|
11299
11786
|
}
|
|
11300
11787
|
}
|
|
11301
|
-
await
|
|
11788
|
+
await _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
11302
11789
|
functions: functionDefinitions
|
|
11303
11790
|
});
|
|
11304
11791
|
}
|
|
11305
|
-
},
|
|
11306
|
-
var ToolBuilder = (
|
|
11307
|
-
constructor(project) {;
|
|
11792
|
+
}, _class11);
|
|
11793
|
+
var ToolBuilder = (_class12 = class {
|
|
11794
|
+
constructor(project) {;_class12.prototype.__init27.call(this);
|
|
11308
11795
|
this.project = project;
|
|
11309
11796
|
}
|
|
11310
11797
|
|
|
11311
|
-
|
|
11798
|
+
__init27() {this.taskCounter = 0}
|
|
11312
11799
|
// This type definition is just a catch all so that the implementation can be
|
|
11313
11800
|
// less specific than the two more specific declarations above.
|
|
11314
11801
|
create(opts) {
|
|
@@ -11317,12 +11804,12 @@ var ToolBuilder = (_class11 = class {
|
|
|
11317
11804
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
11318
11805
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
11319
11806
|
if (resolvedName.trim().length === 0) {
|
|
11320
|
-
resolvedName = `Tool ${
|
|
11807
|
+
resolvedName = `Tool ${_chunk6Z5S7VOUjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
11321
11808
|
}
|
|
11322
11809
|
const tool = new CodeFunction(this.project, {
|
|
11323
11810
|
handler,
|
|
11324
11811
|
name: resolvedName,
|
|
11325
|
-
slug: _nullishCoalesce(slug, () => (
|
|
11812
|
+
slug: _nullishCoalesce(slug, () => ( _chunkXLLGRXGRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
11326
11813
|
type: "tool",
|
|
11327
11814
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
11328
11815
|
parameters,
|
|
@@ -11333,13 +11820,13 @@ var ToolBuilder = (_class11 = class {
|
|
|
11333
11820
|
this.project.addCodeFunction(tool);
|
|
11334
11821
|
return tool;
|
|
11335
11822
|
}
|
|
11336
|
-
},
|
|
11337
|
-
var ScorerBuilder = (
|
|
11338
|
-
constructor(project) {;
|
|
11823
|
+
}, _class12);
|
|
11824
|
+
var ScorerBuilder = (_class13 = class {
|
|
11825
|
+
constructor(project) {;_class13.prototype.__init28.call(this);
|
|
11339
11826
|
this.project = project;
|
|
11340
11827
|
}
|
|
11341
11828
|
|
|
11342
|
-
|
|
11829
|
+
__init28() {this.taskCounter = 0}
|
|
11343
11830
|
create(opts) {
|
|
11344
11831
|
this.taskCounter++;
|
|
11345
11832
|
let resolvedName = opts.name;
|
|
@@ -11347,9 +11834,9 @@ var ScorerBuilder = (_class12 = class {
|
|
|
11347
11834
|
resolvedName = opts.handler.name;
|
|
11348
11835
|
}
|
|
11349
11836
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
11350
|
-
resolvedName = `Scorer ${
|
|
11837
|
+
resolvedName = `Scorer ${_chunk6Z5S7VOUjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
11351
11838
|
}
|
|
11352
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11839
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkXLLGRXGRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
11353
11840
|
if ("handler" in opts) {
|
|
11354
11841
|
const scorer = new CodeFunction(this.project, {
|
|
11355
11842
|
...opts,
|
|
@@ -11393,20 +11880,20 @@ var ScorerBuilder = (_class12 = class {
|
|
|
11393
11880
|
this.project.addPrompt(codePrompt);
|
|
11394
11881
|
}
|
|
11395
11882
|
}
|
|
11396
|
-
},
|
|
11397
|
-
var ClassifierBuilder = (
|
|
11398
|
-
constructor(project) {;
|
|
11883
|
+
}, _class13);
|
|
11884
|
+
var ClassifierBuilder = (_class14 = class {
|
|
11885
|
+
constructor(project) {;_class14.prototype.__init29.call(this);
|
|
11399
11886
|
this.project = project;
|
|
11400
11887
|
}
|
|
11401
11888
|
|
|
11402
|
-
|
|
11889
|
+
__init29() {this.taskCounter = 0}
|
|
11403
11890
|
create(opts) {
|
|
11404
11891
|
this.taskCounter++;
|
|
11405
11892
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
11406
11893
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
11407
|
-
resolvedName = `Classifier ${
|
|
11894
|
+
resolvedName = `Classifier ${_chunk6Z5S7VOUjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
11408
11895
|
}
|
|
11409
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11896
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkXLLGRXGRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
11410
11897
|
const classifier = new CodeFunction(this.project, {
|
|
11411
11898
|
...opts,
|
|
11412
11899
|
name: resolvedName,
|
|
@@ -11416,7 +11903,7 @@ var ClassifierBuilder = (_class13 = class {
|
|
|
11416
11903
|
this.project.addCodeFunction(classifier);
|
|
11417
11904
|
return classifier;
|
|
11418
11905
|
}
|
|
11419
|
-
},
|
|
11906
|
+
}, _class14);
|
|
11420
11907
|
var CodeFunction = class {
|
|
11421
11908
|
constructor(project, opts) {
|
|
11422
11909
|
this.project = project;
|
|
@@ -11535,18 +12022,18 @@ var PromptBuilder = class {
|
|
|
11535
12022
|
rawTools.push(tool);
|
|
11536
12023
|
}
|
|
11537
12024
|
}
|
|
11538
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
12025
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkXLLGRXGRjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
11539
12026
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
11540
12027
|
const promptRow = {
|
|
11541
12028
|
id: opts.id,
|
|
11542
|
-
_xact_id: opts.version ?
|
|
12029
|
+
_xact_id: opts.version ? _chunkXLLGRXGRjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
11543
12030
|
name: opts.name,
|
|
11544
12031
|
slug,
|
|
11545
12032
|
prompt_data: promptData,
|
|
11546
12033
|
tags: opts.tags,
|
|
11547
12034
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
11548
12035
|
};
|
|
11549
|
-
const prompt = new (0,
|
|
12036
|
+
const prompt = new (0, _chunkXLLGRXGRjs.Prompt)(
|
|
11550
12037
|
promptRow,
|
|
11551
12038
|
{},
|
|
11552
12039
|
// It doesn't make sense to specify defaults here.
|
|
@@ -11601,7 +12088,7 @@ var ParametersBuilder = class {
|
|
|
11601
12088
|
}
|
|
11602
12089
|
|
|
11603
12090
|
create(opts) {
|
|
11604
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
12091
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkXLLGRXGRjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
11605
12092
|
const codeParameters = new CodeParameters(this.project, {
|
|
11606
12093
|
name: opts.name,
|
|
11607
12094
|
slug,
|
|
@@ -11640,7 +12127,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
11640
12127
|
required.push(name);
|
|
11641
12128
|
}
|
|
11642
12129
|
} else {
|
|
11643
|
-
const schemaObj =
|
|
12130
|
+
const schemaObj = _chunkXLLGRXGRjs.zodToJsonSchema.call(void 0, value);
|
|
11644
12131
|
properties[name] = schemaObj;
|
|
11645
12132
|
if (!("default" in schemaObj)) {
|
|
11646
12133
|
required.push(name);
|
|
@@ -11664,16 +12151,16 @@ function getDefaultDataFromParametersSchema(schema) {
|
|
|
11664
12151
|
})
|
|
11665
12152
|
);
|
|
11666
12153
|
}
|
|
11667
|
-
var ProjectNameIdMap = (
|
|
11668
|
-
|
|
11669
|
-
|
|
12154
|
+
var ProjectNameIdMap = (_class15 = class {constructor() { _class15.prototype.__init30.call(this);_class15.prototype.__init31.call(this); }
|
|
12155
|
+
__init30() {this.nameToId = {}}
|
|
12156
|
+
__init31() {this.idToName = {}}
|
|
11670
12157
|
async getId(projectName) {
|
|
11671
12158
|
if (!(projectName in this.nameToId)) {
|
|
11672
|
-
const response = await
|
|
12159
|
+
const response = await _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
11673
12160
|
project_name: projectName
|
|
11674
12161
|
});
|
|
11675
12162
|
const result = _v3.z.object({
|
|
11676
|
-
project:
|
|
12163
|
+
project: _chunkXLLGRXGRjs.Project
|
|
11677
12164
|
}).parse(response);
|
|
11678
12165
|
const projectId = result.project.id;
|
|
11679
12166
|
this.nameToId[projectName] = projectId;
|
|
@@ -11683,10 +12170,10 @@ var ProjectNameIdMap = (_class14 = class {constructor() { _class14.prototype.__i
|
|
|
11683
12170
|
}
|
|
11684
12171
|
async getName(projectId) {
|
|
11685
12172
|
if (!(projectId in this.idToName)) {
|
|
11686
|
-
const response = await
|
|
12173
|
+
const response = await _chunkXLLGRXGRjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
11687
12174
|
id: projectId
|
|
11688
12175
|
});
|
|
11689
|
-
const result = _v3.z.array(
|
|
12176
|
+
const result = _v3.z.array(_chunkXLLGRXGRjs.Project).nonempty().parse(response);
|
|
11690
12177
|
const projectName = result[0].name;
|
|
11691
12178
|
this.idToName[projectId] = projectName;
|
|
11692
12179
|
this.nameToId[projectName] = projectId;
|
|
@@ -11699,23 +12186,23 @@ var ProjectNameIdMap = (_class14 = class {constructor() { _class14.prototype.__i
|
|
|
11699
12186
|
}
|
|
11700
12187
|
return this.getId(project.name);
|
|
11701
12188
|
}
|
|
11702
|
-
},
|
|
12189
|
+
}, _class15);
|
|
11703
12190
|
|
|
11704
12191
|
// dev/types.ts
|
|
11705
12192
|
|
|
11706
12193
|
var evalBodySchema = _v3.z.object({
|
|
11707
12194
|
name: _v3.z.string(),
|
|
11708
12195
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
11709
|
-
data:
|
|
12196
|
+
data: _chunkXLLGRXGRjs.RunEval.shape.data,
|
|
11710
12197
|
scores: _v3.z.array(
|
|
11711
12198
|
_v3.z.object({
|
|
11712
|
-
function_id:
|
|
12199
|
+
function_id: _chunkXLLGRXGRjs.FunctionId,
|
|
11713
12200
|
name: _v3.z.string()
|
|
11714
12201
|
})
|
|
11715
12202
|
).nullish(),
|
|
11716
12203
|
experiment_name: _v3.z.string().nullish(),
|
|
11717
12204
|
project_id: _v3.z.string().nullish(),
|
|
11718
|
-
parent:
|
|
12205
|
+
parent: _chunkXLLGRXGRjs.InvokeParent.optional(),
|
|
11719
12206
|
stream: _v3.z.boolean().optional()
|
|
11720
12207
|
});
|
|
11721
12208
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -11723,7 +12210,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
11723
12210
|
_v3.z.union([
|
|
11724
12211
|
_v3.z.object({
|
|
11725
12212
|
type: _v3.z.literal("prompt"),
|
|
11726
|
-
default:
|
|
12213
|
+
default: _chunkXLLGRXGRjs.PromptData.optional(),
|
|
11727
12214
|
description: _v3.z.string().optional()
|
|
11728
12215
|
}),
|
|
11729
12216
|
_v3.z.object({
|
|
@@ -11779,7 +12266,7 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
11779
12266
|
);
|
|
11780
12267
|
|
|
11781
12268
|
// src/node/index.ts
|
|
11782
|
-
|
|
12269
|
+
_chunkXLLGRXGRjs.configureNode.call(void 0, );
|
|
11783
12270
|
|
|
11784
12271
|
|
|
11785
12272
|
|
|
@@ -11962,4 +12449,4 @@ _chunkOBBWQW6Kjs.configureNode.call(void 0, );
|
|
|
11962
12449
|
|
|
11963
12450
|
|
|
11964
12451
|
|
|
11965
|
-
exports.Attachment = _chunkOBBWQW6Kjs.Attachment; exports.AttachmentReference = _chunkOBBWQW6Kjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkOBBWQW6Kjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkOBBWQW6Kjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkOBBWQW6Kjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkOBBWQW6Kjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkOBBWQW6Kjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BatchScorer = BatchScorer; exports.BatchTask = BatchTask; exports.BraintrustLangChainCallbackHandler = _chunkOBBWQW6Kjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkOBBWQW6Kjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkOBBWQW6Kjs.BraintrustState; exports.BraintrustStream = _chunkOBBWQW6Kjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkOBBWQW6Kjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkOBBWQW6Kjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkOBBWQW6Kjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkOBBWQW6Kjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.DurableEvalMemoryStore = DurableEvalMemoryStore; exports.DurableEvalRedisStore = DurableEvalRedisStore; exports.ERR_PERMALINK = _chunkOBBWQW6Kjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkOBBWQW6Kjs.Experiment; exports.ExternalAttachment = _chunkOBBWQW6Kjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkOBBWQW6Kjs.FailedHTTPResponse; exports.IDGenerator = _chunkOBBWQW6Kjs.IDGenerator; exports.JSONAttachment = _chunkOBBWQW6Kjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkOBBWQW6Kjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkOBBWQW6Kjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkOBBWQW6Kjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkOBBWQW6Kjs.Logger; exports.LoginInvalidOrgError = _chunkOBBWQW6Kjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkOBBWQW6Kjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkOBBWQW6Kjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkOBBWQW6Kjs.NoopSpan; exports.OTELIDGenerator = _chunkOBBWQW6Kjs.OTELIDGenerator; exports.ObjectFetcher = _chunkOBBWQW6Kjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkOBBWQW6Kjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkOBBWQW6Kjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkOBBWQW6Kjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkOBBWQW6Kjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkOBBWQW6Kjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkOBBWQW6Kjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkOBBWQW6Kjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkOBBWQW6Kjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkOBBWQW6Kjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkOBBWQW6Kjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkOBBWQW6Kjs._internalGetGlobalState; exports._internalIso = _chunkBBE7SNRVjs.isomorph_default; exports._internalSetInitialState = _chunkOBBWQW6Kjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkOBBWQW6Kjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkOBBWQW6Kjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkOBBWQW6Kjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkOBBWQW6Kjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkOBBWQW6Kjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.collectAnthropicSession = _chunkOBBWQW6Kjs.collectAnthropicSession; exports.configureInstrumentation = _chunkOBBWQW6Kjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkOBBWQW6Kjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkOBBWQW6Kjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkOBBWQW6Kjs.currentExperiment; exports.currentLogger = _chunkOBBWQW6Kjs.currentLogger; exports.currentSpan = _chunkOBBWQW6Kjs.currentSpan; exports.deepCopyEvent = _chunkOBBWQW6Kjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.defineDurableEval = defineDurableEval; exports.deserializePlainStringAsJSON = _chunkOBBWQW6Kjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkOBBWQW6Kjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkOBBWQW6Kjs.extractTraceContextFromHeaders; exports.flush = _chunkOBBWQW6Kjs.flush; exports.getContextManager = _chunkOBBWQW6Kjs.getContextManager; exports.getIdGenerator = _chunkOBBWQW6Kjs.getIdGenerator; exports.getPromptVersions = _chunkOBBWQW6Kjs.getPromptVersions; exports.getSpanParentObject = _chunkOBBWQW6Kjs.getSpanParentObject; exports.getTemplateRenderer = _chunkOBBWQW6Kjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkOBBWQW6Kjs.init; exports.initDataset = _chunkOBBWQW6Kjs.initDataset; exports.initExperiment = _chunkOBBWQW6Kjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkOBBWQW6Kjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkOBBWQW6Kjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkOBBWQW6Kjs.isTemplateFormat; exports.loadParameters = _chunkOBBWQW6Kjs.loadParameters; exports.loadPrompt = _chunkOBBWQW6Kjs.loadPrompt; exports.log = _chunkOBBWQW6Kjs.log; exports.logError = _chunkOBBWQW6Kjs.logError; exports.login = _chunkOBBWQW6Kjs.login; exports.loginToState = _chunkOBBWQW6Kjs.loginToState; exports.logs3OverflowUploadSchema = _chunkOBBWQW6Kjs.logs3OverflowUploadSchema; exports.newId = _chunkOBBWQW6Kjs.newId; exports.parseCachedHeader = _chunkOBBWQW6Kjs.parseCachedHeader; exports.parseTemplateFormat = _chunkOBBWQW6Kjs.parseTemplateFormat; exports.permalink = _chunkOBBWQW6Kjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkOBBWQW6Kjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkOBBWQW6Kjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkOBBWQW6Kjs.registerTemplatePlugin; exports.renderMessage = _chunkOBBWQW6Kjs.renderMessage; exports.renderPromptParams = _chunkOBBWQW6Kjs.renderPromptParams; exports.renderTemplateContent = _chunkOBBWQW6Kjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkOBBWQW6Kjs.setFetch; exports.setMaskingFunction = _chunkOBBWQW6Kjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkOBBWQW6Kjs.spanComponentsToObjectId; exports.startSpan = _chunkOBBWQW6Kjs.startSpan; exports.summarize = _chunkOBBWQW6Kjs.summarize; exports.templateRegistry = _chunkOBBWQW6Kjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkOBBWQW6Kjs.ToolFunctionDefinition; exports.traceable = _chunkOBBWQW6Kjs.traceable; exports.traced = _chunkOBBWQW6Kjs.traced; exports.updateSpan = _chunkOBBWQW6Kjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkOBBWQW6Kjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkOBBWQW6Kjs.utf8ByteLength; exports.withCurrent = _chunkOBBWQW6Kjs.withCurrent; exports.withDataset = _chunkOBBWQW6Kjs.withDataset; exports.withExperiment = _chunkOBBWQW6Kjs.withExperiment; exports.withLogger = _chunkOBBWQW6Kjs.withLogger; exports.withParent = _chunkOBBWQW6Kjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCloudflareAIChat = wrapCloudflareAIChat; exports.wrapCloudflareAgent = wrapCloudflareAgent; exports.wrapCloudflareThink = wrapCloudflareThink; exports.wrapCohere = wrapCohere; exports.wrapCopilotClient = wrapCopilotClient; exports.wrapCursorSDK = wrapCursorSDK; exports.wrapGenkit = wrapGenkit; exports.wrapGoogleADK = wrapGoogleADK; exports.wrapGoogleGenAI = wrapGoogleGenAI; exports.wrapGroq = wrapGroq; exports.wrapHuggingFace = wrapHuggingFace; exports.wrapHuggingFaceTransformers = wrapHuggingFaceTransformers; exports.wrapLangSmithClient = wrapLangSmithClient; exports.wrapLangSmithRunTrees = wrapLangSmithRunTrees; exports.wrapLangSmithTraceable = wrapLangSmithTraceable; exports.wrapMastraAgent = _chunkOBBWQW6Kjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOllama = wrapOllama; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkOBBWQW6Kjs.wrapTraced; exports.wrapVitest = wrapVitest; exports.wrapVoyageAI = wrapVoyageAI;
|
|
12452
|
+
exports.Attachment = _chunkXLLGRXGRjs.Attachment; exports.AttachmentReference = _chunkXLLGRXGRjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkXLLGRXGRjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkXLLGRXGRjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkXLLGRXGRjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkXLLGRXGRjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkXLLGRXGRjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BatchScorer = BatchScorer; exports.BatchTask = BatchTask; exports.BraintrustLangChainCallbackHandler = _chunkXLLGRXGRjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkXLLGRXGRjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkXLLGRXGRjs.BraintrustState; exports.BraintrustStream = _chunkXLLGRXGRjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkXLLGRXGRjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkXLLGRXGRjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkXLLGRXGRjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkXLLGRXGRjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.DurableEvalMemoryStore = DurableEvalMemoryStore; exports.DurableEvalRedisStore = DurableEvalRedisStore; exports.ERR_PERMALINK = _chunkXLLGRXGRjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkXLLGRXGRjs.Experiment; exports.ExternalAttachment = _chunkXLLGRXGRjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkXLLGRXGRjs.FailedHTTPResponse; exports.IDGenerator = _chunkXLLGRXGRjs.IDGenerator; exports.JSONAttachment = _chunkXLLGRXGRjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkXLLGRXGRjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkXLLGRXGRjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkXLLGRXGRjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkXLLGRXGRjs.Logger; exports.LoginInvalidOrgError = _chunkXLLGRXGRjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkXLLGRXGRjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkXLLGRXGRjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkXLLGRXGRjs.NoopSpan; exports.OTELIDGenerator = _chunkXLLGRXGRjs.OTELIDGenerator; exports.ObjectFetcher = _chunkXLLGRXGRjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkXLLGRXGRjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkXLLGRXGRjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkXLLGRXGRjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkXLLGRXGRjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkXLLGRXGRjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkXLLGRXGRjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkXLLGRXGRjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkXLLGRXGRjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkXLLGRXGRjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkXLLGRXGRjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkXLLGRXGRjs._internalGetGlobalState; exports._internalIso = _chunk6Z5S7VOUjs.isomorph_default; exports._internalSetInitialState = _chunkXLLGRXGRjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkXLLGRXGRjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkXLLGRXGRjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkXLLGRXGRjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkXLLGRXGRjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkXLLGRXGRjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.collectAnthropicSession = _chunkXLLGRXGRjs.collectAnthropicSession; exports.configureInstrumentation = _chunkXLLGRXGRjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkXLLGRXGRjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkXLLGRXGRjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkXLLGRXGRjs.currentExperiment; exports.currentLogger = _chunkXLLGRXGRjs.currentLogger; exports.currentSpan = _chunkXLLGRXGRjs.currentSpan; exports.deepCopyEvent = _chunkXLLGRXGRjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.defineDurableEval = defineDurableEval; exports.deserializePlainStringAsJSON = _chunkXLLGRXGRjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkXLLGRXGRjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkXLLGRXGRjs.extractTraceContextFromHeaders; exports.flush = _chunkXLLGRXGRjs.flush; exports.getContextManager = _chunkXLLGRXGRjs.getContextManager; exports.getIdGenerator = _chunkXLLGRXGRjs.getIdGenerator; exports.getPromptVersions = _chunkXLLGRXGRjs.getPromptVersions; exports.getSpanParentObject = _chunkXLLGRXGRjs.getSpanParentObject; exports.getTemplateRenderer = _chunkXLLGRXGRjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkXLLGRXGRjs.init; exports.initDataset = _chunkXLLGRXGRjs.initDataset; exports.initExperiment = _chunkXLLGRXGRjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkXLLGRXGRjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkXLLGRXGRjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkXLLGRXGRjs.isTemplateFormat; exports.loadParameters = _chunkXLLGRXGRjs.loadParameters; exports.loadPrompt = _chunkXLLGRXGRjs.loadPrompt; exports.log = _chunkXLLGRXGRjs.log; exports.logError = _chunkXLLGRXGRjs.logError; exports.login = _chunkXLLGRXGRjs.login; exports.loginToState = _chunkXLLGRXGRjs.loginToState; exports.logs3OverflowUploadSchema = _chunkXLLGRXGRjs.logs3OverflowUploadSchema; exports.newId = _chunkXLLGRXGRjs.newId; exports.parseCachedHeader = _chunkXLLGRXGRjs.parseCachedHeader; exports.parseTemplateFormat = _chunkXLLGRXGRjs.parseTemplateFormat; exports.permalink = _chunkXLLGRXGRjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkXLLGRXGRjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkXLLGRXGRjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkXLLGRXGRjs.registerTemplatePlugin; exports.renderMessage = _chunkXLLGRXGRjs.renderMessage; exports.renderPromptParams = _chunkXLLGRXGRjs.renderPromptParams; exports.renderTemplateContent = _chunkXLLGRXGRjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkXLLGRXGRjs.setFetch; exports.setMaskingFunction = _chunkXLLGRXGRjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkXLLGRXGRjs.spanComponentsToObjectId; exports.startSpan = _chunkXLLGRXGRjs.startSpan; exports.summarize = _chunkXLLGRXGRjs.summarize; exports.templateRegistry = _chunkXLLGRXGRjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkXLLGRXGRjs.ToolFunctionDefinition; exports.traceable = _chunkXLLGRXGRjs.traceable; exports.traced = _chunkXLLGRXGRjs.traced; exports.updateSpan = _chunkXLLGRXGRjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkXLLGRXGRjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkXLLGRXGRjs.utf8ByteLength; exports.withCurrent = _chunkXLLGRXGRjs.withCurrent; exports.withDataset = _chunkXLLGRXGRjs.withDataset; exports.withExperiment = _chunkXLLGRXGRjs.withExperiment; exports.withLogger = _chunkXLLGRXGRjs.withLogger; exports.withParent = _chunkXLLGRXGRjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCloudflareAIChat = wrapCloudflareAIChat; exports.wrapCloudflareAgent = wrapCloudflareAgent; exports.wrapCloudflareThink = wrapCloudflareThink; exports.wrapCohere = wrapCohere; exports.wrapCopilotClient = wrapCopilotClient; exports.wrapCursorSDK = wrapCursorSDK; exports.wrapGenkit = wrapGenkit; exports.wrapGoogleADK = wrapGoogleADK; exports.wrapGoogleGenAI = wrapGoogleGenAI; exports.wrapGroq = wrapGroq; exports.wrapHuggingFace = wrapHuggingFace; exports.wrapHuggingFaceTransformers = wrapHuggingFaceTransformers; exports.wrapLangSmithClient = wrapLangSmithClient; exports.wrapLangSmithRunTrees = wrapLangSmithRunTrees; exports.wrapLangSmithTraceable = wrapLangSmithTraceable; exports.wrapMastraAgent = _chunkXLLGRXGRjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOllama = wrapOllama; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkXLLGRXGRjs.wrapTraced; exports.wrapVitest = wrapVitest; exports.wrapVoyageAI = wrapVoyageAI;
|