braintrust 3.21.0 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dev/dist/index.d.mts +1029 -0
- package/dev/dist/index.d.ts +1029 -0
- package/dev/dist/index.js +75 -11
- package/dev/dist/index.mjs +75 -11
- package/dist/auto-instrumentations/hook.mjs +75 -11
- package/dist/browser.d.mts +3274 -92
- package/dist/browser.d.ts +3274 -92
- package/dist/browser.js +1548 -11
- package/dist/browser.mjs +1548 -11
- package/dist/{chunk-FY7DAKA5.js → chunk-MWVVR5LR.js} +84 -12
- package/dist/{chunk-O2P765XK.mjs → chunk-ZG2O3XVF.mjs} +83 -11
- package/dist/cli.js +80 -13
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +1548 -11
- package/dist/edge-light.mjs +1548 -11
- package/dist/index.d.mts +3274 -92
- package/dist/index.d.ts +3274 -92
- package/dist/index.js +1780 -311
- package/dist/index.mjs +1470 -1
- package/dist/instrumentation/index.d.mts +919 -1
- package/dist/instrumentation/index.d.ts +919 -1
- package/dist/instrumentation/index.js +1563 -10
- package/dist/instrumentation/index.mjs +1561 -10
- package/dist/vitest-evals-reporter.js +15 -15
- package/dist/vitest-evals-reporter.mjs +1 -1
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +1548 -11
- package/dist/workerd.mjs +1548 -11
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -137,7 +137,9 @@
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
var _chunkMWVVR5LRjs = require('./chunk-MWVVR5LR.js');
|
|
141
143
|
|
|
142
144
|
|
|
143
145
|
|
|
@@ -165,144 +167,146 @@ var _chunkBFGIH2ZJjs = require('./chunk-BFGIH2ZJ.js');
|
|
|
165
167
|
// src/exports.ts
|
|
166
168
|
var exports_exports = {};
|
|
167
169
|
_chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
168
|
-
Attachment: () =>
|
|
169
|
-
AttachmentReference: () =>
|
|
170
|
-
BAGGAGE_HEADER: () =>
|
|
171
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
172
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
173
|
-
BRAINTRUST_PARENT_KEY: () =>
|
|
174
|
-
BaseAttachment: () =>
|
|
170
|
+
Attachment: () => _chunkMWVVR5LRjs.Attachment,
|
|
171
|
+
AttachmentReference: () => _chunkMWVVR5LRjs.AttachmentReference,
|
|
172
|
+
BAGGAGE_HEADER: () => _chunkMWVVR5LRjs.BAGGAGE_HEADER,
|
|
173
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkMWVVR5LRjs.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
174
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkMWVVR5LRjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
175
|
+
BRAINTRUST_PARENT_KEY: () => _chunkMWVVR5LRjs.BRAINTRUST_PARENT_KEY,
|
|
176
|
+
BaseAttachment: () => _chunkMWVVR5LRjs.BaseAttachment,
|
|
175
177
|
BaseExperiment: () => BaseExperiment,
|
|
176
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
178
|
+
BraintrustLangChainCallbackHandler: () => _chunkMWVVR5LRjs.BraintrustLangChainCallbackHandler,
|
|
177
179
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
178
|
-
BraintrustObservabilityExporter: () =>
|
|
179
|
-
BraintrustState: () =>
|
|
180
|
-
BraintrustStream: () =>
|
|
180
|
+
BraintrustObservabilityExporter: () => _chunkMWVVR5LRjs.BraintrustObservabilityExporter,
|
|
181
|
+
BraintrustState: () => _chunkMWVVR5LRjs.BraintrustState,
|
|
182
|
+
BraintrustStream: () => _chunkMWVVR5LRjs.BraintrustStream,
|
|
181
183
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
182
184
|
CodeFunction: () => CodeFunction,
|
|
183
185
|
CodePrompt: () => CodePrompt,
|
|
184
|
-
ContextManager: () =>
|
|
185
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
186
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
187
|
-
Dataset: () =>
|
|
186
|
+
ContextManager: () => _chunkMWVVR5LRjs.ContextManager,
|
|
187
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkMWVVR5LRjs.DEFAULT_FETCH_BATCH_SIZE,
|
|
188
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkMWVVR5LRjs.DEFAULT_MAX_REQUEST_SIZE,
|
|
189
|
+
Dataset: () => _chunkMWVVR5LRjs.Dataset,
|
|
188
190
|
DatasetPipeline: () => DatasetPipeline,
|
|
189
|
-
ERR_PERMALINK: () =>
|
|
191
|
+
ERR_PERMALINK: () => _chunkMWVVR5LRjs.ERR_PERMALINK,
|
|
190
192
|
Eval: () => Eval,
|
|
191
193
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
192
|
-
Experiment: () =>
|
|
193
|
-
ExternalAttachment: () =>
|
|
194
|
-
FailedHTTPResponse: () =>
|
|
195
|
-
IDGenerator: () =>
|
|
196
|
-
JSONAttachment: () =>
|
|
197
|
-
LEGACY_CACHED_HEADER: () =>
|
|
198
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
199
|
-
LazyValue: () =>
|
|
194
|
+
Experiment: () => _chunkMWVVR5LRjs.Experiment,
|
|
195
|
+
ExternalAttachment: () => _chunkMWVVR5LRjs.ExternalAttachment,
|
|
196
|
+
FailedHTTPResponse: () => _chunkMWVVR5LRjs.FailedHTTPResponse,
|
|
197
|
+
IDGenerator: () => _chunkMWVVR5LRjs.IDGenerator,
|
|
198
|
+
JSONAttachment: () => _chunkMWVVR5LRjs.JSONAttachment,
|
|
199
|
+
LEGACY_CACHED_HEADER: () => _chunkMWVVR5LRjs.LEGACY_CACHED_HEADER,
|
|
200
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkMWVVR5LRjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
201
|
+
LazyValue: () => _chunkMWVVR5LRjs.LazyValue,
|
|
200
202
|
LocalTrace: () => LocalTrace,
|
|
201
|
-
Logger: () =>
|
|
202
|
-
LoginInvalidOrgError: () =>
|
|
203
|
-
NOOP_SPAN: () =>
|
|
204
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
205
|
-
NoopSpan: () =>
|
|
206
|
-
OTELIDGenerator: () =>
|
|
207
|
-
ObjectFetcher: () =>
|
|
203
|
+
Logger: () => _chunkMWVVR5LRjs.Logger,
|
|
204
|
+
LoginInvalidOrgError: () => _chunkMWVVR5LRjs.LoginInvalidOrgError,
|
|
205
|
+
NOOP_SPAN: () => _chunkMWVVR5LRjs.NOOP_SPAN,
|
|
206
|
+
NOOP_SPAN_PERMALINK: () => _chunkMWVVR5LRjs.NOOP_SPAN_PERMALINK,
|
|
207
|
+
NoopSpan: () => _chunkMWVVR5LRjs.NoopSpan,
|
|
208
|
+
OTELIDGenerator: () => _chunkMWVVR5LRjs.OTELIDGenerator,
|
|
209
|
+
ObjectFetcher: () => _chunkMWVVR5LRjs.ObjectFetcher,
|
|
208
210
|
Project: () => Project2,
|
|
209
211
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
210
|
-
Prompt: () =>
|
|
212
|
+
Prompt: () => _chunkMWVVR5LRjs.Prompt,
|
|
211
213
|
PromptBuilder: () => PromptBuilder,
|
|
212
|
-
ReadonlyAttachment: () =>
|
|
213
|
-
ReadonlyExperiment: () =>
|
|
214
|
+
ReadonlyAttachment: () => _chunkMWVVR5LRjs.ReadonlyAttachment,
|
|
215
|
+
ReadonlyExperiment: () => _chunkMWVVR5LRjs.ReadonlyExperiment,
|
|
214
216
|
Reporter: () => Reporter,
|
|
215
217
|
ScorerBuilder: () => ScorerBuilder,
|
|
216
218
|
SpanFetcher: () => SpanFetcher,
|
|
217
|
-
SpanImpl: () =>
|
|
218
|
-
TRACEPARENT_HEADER: () =>
|
|
219
|
-
TRACESTATE_HEADER: () =>
|
|
220
|
-
TestBackgroundLogger: () =>
|
|
219
|
+
SpanImpl: () => _chunkMWVVR5LRjs.SpanImpl,
|
|
220
|
+
TRACEPARENT_HEADER: () => _chunkMWVVR5LRjs.TRACEPARENT_HEADER,
|
|
221
|
+
TRACESTATE_HEADER: () => _chunkMWVVR5LRjs.TRACESTATE_HEADER,
|
|
222
|
+
TestBackgroundLogger: () => _chunkMWVVR5LRjs.TestBackgroundLogger,
|
|
221
223
|
ToolBuilder: () => ToolBuilder,
|
|
222
|
-
UUIDGenerator: () =>
|
|
223
|
-
X_CACHED_HEADER: () =>
|
|
224
|
-
_exportsForTestingOnly: () =>
|
|
225
|
-
_internalGetGlobalState: () =>
|
|
224
|
+
UUIDGenerator: () => _chunkMWVVR5LRjs.UUIDGenerator,
|
|
225
|
+
X_CACHED_HEADER: () => _chunkMWVVR5LRjs.X_CACHED_HEADER,
|
|
226
|
+
_exportsForTestingOnly: () => _chunkMWVVR5LRjs._exportsForTestingOnly,
|
|
227
|
+
_internalGetGlobalState: () => _chunkMWVVR5LRjs._internalGetGlobalState,
|
|
226
228
|
_internalIso: () => _chunkBFGIH2ZJjs.isomorph_default,
|
|
227
|
-
_internalSetInitialState: () =>
|
|
228
|
-
addAzureBlobHeaders: () =>
|
|
229
|
+
_internalSetInitialState: () => _chunkMWVVR5LRjs._internalSetInitialState,
|
|
230
|
+
addAzureBlobHeaders: () => _chunkMWVVR5LRjs.addAzureBlobHeaders,
|
|
229
231
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
230
|
-
braintrustAISDKTelemetry: () =>
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
braintrustAISDKTelemetry: () => _chunkMWVVR5LRjs.braintrustAISDKTelemetry,
|
|
233
|
+
braintrustEveHook: () => braintrustEveHook,
|
|
234
|
+
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
235
|
+
braintrustFlueInstrumentation: () => _chunkMWVVR5LRjs.braintrustFlueInstrumentation,
|
|
236
|
+
braintrustFlueObserver: () => _chunkMWVVR5LRjs.braintrustFlueObserver,
|
|
237
|
+
braintrustStreamChunkSchema: () => _chunkMWVVR5LRjs.braintrustStreamChunkSchema,
|
|
234
238
|
buildLocalSummary: () => buildLocalSummary,
|
|
235
|
-
configureInstrumentation: () =>
|
|
236
|
-
constructLogs3OverflowRequest: () =>
|
|
237
|
-
createFinalValuePassThroughStream: () =>
|
|
238
|
-
currentExperiment: () =>
|
|
239
|
-
currentLogger: () =>
|
|
240
|
-
currentSpan: () =>
|
|
241
|
-
deepCopyEvent: () =>
|
|
239
|
+
configureInstrumentation: () => _chunkMWVVR5LRjs.configureInstrumentation,
|
|
240
|
+
constructLogs3OverflowRequest: () => _chunkMWVVR5LRjs.constructLogs3OverflowRequest,
|
|
241
|
+
createFinalValuePassThroughStream: () => _chunkMWVVR5LRjs.createFinalValuePassThroughStream,
|
|
242
|
+
currentExperiment: () => _chunkMWVVR5LRjs.currentExperiment,
|
|
243
|
+
currentLogger: () => _chunkMWVVR5LRjs.currentLogger,
|
|
244
|
+
currentSpan: () => _chunkMWVVR5LRjs.currentSpan,
|
|
245
|
+
deepCopyEvent: () => _chunkMWVVR5LRjs.deepCopyEvent,
|
|
242
246
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
243
|
-
deserializePlainStringAsJSON: () =>
|
|
244
|
-
devNullWritableStream: () =>
|
|
247
|
+
deserializePlainStringAsJSON: () => _chunkMWVVR5LRjs.deserializePlainStringAsJSON,
|
|
248
|
+
devNullWritableStream: () => _chunkMWVVR5LRjs.devNullWritableStream,
|
|
245
249
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
246
250
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
247
|
-
extractTraceContextFromHeaders: () =>
|
|
248
|
-
flush: () =>
|
|
249
|
-
getContextManager: () =>
|
|
250
|
-
getIdGenerator: () =>
|
|
251
|
-
getPromptVersions: () =>
|
|
252
|
-
getSpanParentObject: () =>
|
|
253
|
-
getTemplateRenderer: () =>
|
|
251
|
+
extractTraceContextFromHeaders: () => _chunkMWVVR5LRjs.extractTraceContextFromHeaders,
|
|
252
|
+
flush: () => _chunkMWVVR5LRjs.flush,
|
|
253
|
+
getContextManager: () => _chunkMWVVR5LRjs.getContextManager,
|
|
254
|
+
getIdGenerator: () => _chunkMWVVR5LRjs.getIdGenerator,
|
|
255
|
+
getPromptVersions: () => _chunkMWVVR5LRjs.getPromptVersions,
|
|
256
|
+
getSpanParentObject: () => _chunkMWVVR5LRjs.getSpanParentObject,
|
|
257
|
+
getTemplateRenderer: () => _chunkMWVVR5LRjs.getTemplateRenderer,
|
|
254
258
|
graph: () => graph_framework_exports,
|
|
255
|
-
init: () =>
|
|
256
|
-
initDataset: () =>
|
|
257
|
-
initExperiment: () =>
|
|
259
|
+
init: () => _chunkMWVVR5LRjs.init,
|
|
260
|
+
initDataset: () => _chunkMWVVR5LRjs.initDataset,
|
|
261
|
+
initExperiment: () => _chunkMWVVR5LRjs.initExperiment,
|
|
258
262
|
initFunction: () => initFunction,
|
|
259
|
-
initLogger: () =>
|
|
263
|
+
initLogger: () => _chunkMWVVR5LRjs.initLogger,
|
|
260
264
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
261
|
-
injectTraceContext: () =>
|
|
265
|
+
injectTraceContext: () => _chunkMWVVR5LRjs.injectTraceContext,
|
|
262
266
|
invoke: () => invoke,
|
|
263
|
-
isTemplateFormat: () =>
|
|
264
|
-
loadParameters: () =>
|
|
265
|
-
loadPrompt: () =>
|
|
266
|
-
log: () =>
|
|
267
|
-
logError: () =>
|
|
268
|
-
login: () =>
|
|
269
|
-
loginToState: () =>
|
|
270
|
-
logs3OverflowUploadSchema: () =>
|
|
271
|
-
newId: () =>
|
|
272
|
-
parseCachedHeader: () =>
|
|
273
|
-
parseTemplateFormat: () =>
|
|
274
|
-
permalink: () =>
|
|
275
|
-
pickLogs3OverflowObjectIds: () =>
|
|
267
|
+
isTemplateFormat: () => _chunkMWVVR5LRjs.isTemplateFormat,
|
|
268
|
+
loadParameters: () => _chunkMWVVR5LRjs.loadParameters,
|
|
269
|
+
loadPrompt: () => _chunkMWVVR5LRjs.loadPrompt,
|
|
270
|
+
log: () => _chunkMWVVR5LRjs.log,
|
|
271
|
+
logError: () => _chunkMWVVR5LRjs.logError,
|
|
272
|
+
login: () => _chunkMWVVR5LRjs.login,
|
|
273
|
+
loginToState: () => _chunkMWVVR5LRjs.loginToState,
|
|
274
|
+
logs3OverflowUploadSchema: () => _chunkMWVVR5LRjs.logs3OverflowUploadSchema,
|
|
275
|
+
newId: () => _chunkMWVVR5LRjs.newId,
|
|
276
|
+
parseCachedHeader: () => _chunkMWVVR5LRjs.parseCachedHeader,
|
|
277
|
+
parseTemplateFormat: () => _chunkMWVVR5LRjs.parseTemplateFormat,
|
|
278
|
+
permalink: () => _chunkMWVVR5LRjs.permalink,
|
|
279
|
+
pickLogs3OverflowObjectIds: () => _chunkMWVVR5LRjs.pickLogs3OverflowObjectIds,
|
|
276
280
|
projects: () => projects,
|
|
277
281
|
promptContentsSchema: () => promptContentsSchema,
|
|
278
282
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
279
283
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
280
284
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
281
|
-
registerOtelFlush: () =>
|
|
285
|
+
registerOtelFlush: () => _chunkMWVVR5LRjs.registerOtelFlush,
|
|
282
286
|
registerSandbox: () => registerSandbox,
|
|
283
|
-
registerTemplatePlugin: () =>
|
|
284
|
-
renderMessage: () =>
|
|
285
|
-
renderPromptParams: () =>
|
|
286
|
-
renderTemplateContent: () =>
|
|
287
|
+
registerTemplatePlugin: () => _chunkMWVVR5LRjs.registerTemplatePlugin,
|
|
288
|
+
renderMessage: () => _chunkMWVVR5LRjs.renderMessage,
|
|
289
|
+
renderPromptParams: () => _chunkMWVVR5LRjs.renderPromptParams,
|
|
290
|
+
renderTemplateContent: () => _chunkMWVVR5LRjs.renderTemplateContent,
|
|
287
291
|
reportFailures: () => reportFailures,
|
|
288
292
|
runEvaluator: () => runEvaluator,
|
|
289
|
-
setFetch: () =>
|
|
290
|
-
setMaskingFunction: () =>
|
|
291
|
-
spanComponentsToObjectId: () =>
|
|
292
|
-
startSpan: () =>
|
|
293
|
-
summarize: () =>
|
|
294
|
-
templateRegistry: () =>
|
|
295
|
-
toolFunctionDefinitionSchema: () =>
|
|
296
|
-
traceable: () =>
|
|
297
|
-
traced: () =>
|
|
298
|
-
updateSpan: () =>
|
|
299
|
-
uploadLogs3OverflowPayload: () =>
|
|
300
|
-
utf8ByteLength: () =>
|
|
301
|
-
withCurrent: () =>
|
|
302
|
-
withDataset: () =>
|
|
303
|
-
withExperiment: () =>
|
|
304
|
-
withLogger: () =>
|
|
305
|
-
withParent: () =>
|
|
293
|
+
setFetch: () => _chunkMWVVR5LRjs.setFetch,
|
|
294
|
+
setMaskingFunction: () => _chunkMWVVR5LRjs.setMaskingFunction,
|
|
295
|
+
spanComponentsToObjectId: () => _chunkMWVVR5LRjs.spanComponentsToObjectId,
|
|
296
|
+
startSpan: () => _chunkMWVVR5LRjs.startSpan,
|
|
297
|
+
summarize: () => _chunkMWVVR5LRjs.summarize,
|
|
298
|
+
templateRegistry: () => _chunkMWVVR5LRjs.templateRegistry,
|
|
299
|
+
toolFunctionDefinitionSchema: () => _chunkMWVVR5LRjs.ToolFunctionDefinition,
|
|
300
|
+
traceable: () => _chunkMWVVR5LRjs.traceable,
|
|
301
|
+
traced: () => _chunkMWVVR5LRjs.traced,
|
|
302
|
+
updateSpan: () => _chunkMWVVR5LRjs.updateSpan,
|
|
303
|
+
uploadLogs3OverflowPayload: () => _chunkMWVVR5LRjs.uploadLogs3OverflowPayload,
|
|
304
|
+
utf8ByteLength: () => _chunkMWVVR5LRjs.utf8ByteLength,
|
|
305
|
+
withCurrent: () => _chunkMWVVR5LRjs.withCurrent,
|
|
306
|
+
withDataset: () => _chunkMWVVR5LRjs.withDataset,
|
|
307
|
+
withExperiment: () => _chunkMWVVR5LRjs.withExperiment,
|
|
308
|
+
withLogger: () => _chunkMWVVR5LRjs.withLogger,
|
|
309
|
+
withParent: () => _chunkMWVVR5LRjs.withParent,
|
|
306
310
|
wrapAISDK: () => wrapAISDK,
|
|
307
311
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
308
312
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -317,7 +321,7 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
317
321
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
318
322
|
wrapGroq: () => wrapGroq,
|
|
319
323
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
320
|
-
wrapMastraAgent: () =>
|
|
324
|
+
wrapMastraAgent: () => _chunkMWVVR5LRjs.wrapMastraAgent,
|
|
321
325
|
wrapMistral: () => wrapMistral,
|
|
322
326
|
wrapOpenAI: () => wrapOpenAI,
|
|
323
327
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
@@ -326,7 +330,7 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
326
330
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
327
331
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
328
332
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
329
|
-
wrapTraced: () =>
|
|
333
|
+
wrapTraced: () => _chunkMWVVR5LRjs.wrapTraced,
|
|
330
334
|
wrapVitest: () => wrapVitest
|
|
331
335
|
});
|
|
332
336
|
|
|
@@ -334,7 +338,7 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
334
338
|
var _v3 = require('zod/v3');
|
|
335
339
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
336
340
|
async function registerSandbox(options) {
|
|
337
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
341
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )));
|
|
338
342
|
await state.login({
|
|
339
343
|
apiKey: options.apiKey,
|
|
340
344
|
appUrl: options.appUrl,
|
|
@@ -375,7 +379,7 @@ async function registerSandbox(options) {
|
|
|
375
379
|
evaluatorDefinitions
|
|
376
380
|
)) {
|
|
377
381
|
const functionName = evalName;
|
|
378
|
-
const functionSlug =
|
|
382
|
+
const functionSlug = _chunkMWVVR5LRjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
379
383
|
const functionDef = {
|
|
380
384
|
project_id: projectId,
|
|
381
385
|
org_name: state.orgName,
|
|
@@ -446,7 +450,7 @@ async function invoke(args) {
|
|
|
446
450
|
projectId,
|
|
447
451
|
...functionIdArgs
|
|
448
452
|
} = args;
|
|
449
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
453
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )));
|
|
450
454
|
await state.login({
|
|
451
455
|
orgName,
|
|
452
456
|
apiKey,
|
|
@@ -454,8 +458,8 @@ async function invoke(args) {
|
|
|
454
458
|
forceLogin,
|
|
455
459
|
fetch
|
|
456
460
|
});
|
|
457
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
458
|
-
const functionId =
|
|
461
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkMWVVR5LRjs.getSpanParentObject.call(void 0, ).export();
|
|
462
|
+
const functionId = _chunkMWVVR5LRjs.FunctionId.safeParse({
|
|
459
463
|
function_id: functionIdArgs.function_id,
|
|
460
464
|
project_name: functionIdArgs.projectName,
|
|
461
465
|
slug: functionIdArgs.slug,
|
|
@@ -498,7 +502,7 @@ async function invoke(args) {
|
|
|
498
502
|
if (!resp.body) {
|
|
499
503
|
throw new Error("Received empty stream body");
|
|
500
504
|
}
|
|
501
|
-
return new (0,
|
|
505
|
+
return new (0, _chunkMWVVR5LRjs.BraintrustStream)(resp.body);
|
|
502
506
|
} else {
|
|
503
507
|
const data = await resp.json();
|
|
504
508
|
return schema ? schema.parse(data) : data;
|
|
@@ -510,7 +514,7 @@ function initFunction({
|
|
|
510
514
|
version,
|
|
511
515
|
state
|
|
512
516
|
}) {
|
|
513
|
-
const s = _nullishCoalesce(state, () => (
|
|
517
|
+
const s = _nullishCoalesce(state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )));
|
|
514
518
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
515
519
|
const f = async (input) => {
|
|
516
520
|
return await invoke({
|
|
@@ -947,7 +951,7 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
947
951
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
948
952
|
return (params) => {
|
|
949
953
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
950
|
-
if (workflowAgent &&
|
|
954
|
+
if (workflowAgent && _chunkMWVVR5LRjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
951
955
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
952
956
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
953
957
|
}
|
|
@@ -1172,14 +1176,14 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1172
1176
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1173
1177
|
// propagate those via async local storage
|
|
1174
1178
|
async doGenerate(options) {
|
|
1175
|
-
const span =
|
|
1179
|
+
const span = _chunkMWVVR5LRjs.startSpan.call(void 0, {
|
|
1176
1180
|
name: "Chat Completion",
|
|
1177
1181
|
spanAttributes: {
|
|
1178
1182
|
type: "llm"
|
|
1179
1183
|
}
|
|
1180
1184
|
});
|
|
1181
1185
|
const { prompt, mode, ...rest } = options;
|
|
1182
|
-
const startTime =
|
|
1186
|
+
const startTime = _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1183
1187
|
try {
|
|
1184
1188
|
const ret = await this.model.doGenerate(options);
|
|
1185
1189
|
span.log({
|
|
@@ -1191,12 +1195,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1191
1195
|
},
|
|
1192
1196
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1193
1197
|
metrics: {
|
|
1194
|
-
time_to_first_token:
|
|
1195
|
-
tokens: !
|
|
1198
|
+
time_to_first_token: _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1199
|
+
tokens: !_chunkMWVVR5LRjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1196
1200
|
prompt_tokens: _optionalChain([ret, 'access', _20 => _20.usage, 'optionalAccess', _21 => _21.promptTokens]),
|
|
1197
1201
|
completion_tokens: _optionalChain([ret, 'access', _22 => _22.usage, 'optionalAccess', _23 => _23.completionTokens]),
|
|
1198
|
-
cached:
|
|
1199
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[
|
|
1202
|
+
cached: _chunkMWVVR5LRjs.parseCachedHeader.call(void 0,
|
|
1203
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[_chunkMWVVR5LRjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _27 => _27.rawResponse, 'optionalAccess', _28 => _28.headers, 'optionalAccess', _29 => _29[_chunkMWVVR5LRjs.LEGACY_CACHED_HEADER]])))
|
|
1200
1204
|
)
|
|
1201
1205
|
}
|
|
1202
1206
|
});
|
|
@@ -1207,8 +1211,8 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1207
1211
|
}
|
|
1208
1212
|
async doStream(options) {
|
|
1209
1213
|
const { prompt, mode, ...rest } = options;
|
|
1210
|
-
const startTime =
|
|
1211
|
-
const span =
|
|
1214
|
+
const startTime = _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1215
|
+
const span = _chunkMWVVR5LRjs.startSpan.call(void 0, {
|
|
1212
1216
|
name: "Chat Completion",
|
|
1213
1217
|
spanAttributes: {
|
|
1214
1218
|
type: "llm"
|
|
@@ -1242,7 +1246,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1242
1246
|
new TransformStream({
|
|
1243
1247
|
transform(chunk, controller) {
|
|
1244
1248
|
if (time_to_first_token === void 0) {
|
|
1245
|
-
time_to_first_token =
|
|
1249
|
+
time_to_first_token = _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1246
1250
|
span.log({ metrics: { time_to_first_token } });
|
|
1247
1251
|
}
|
|
1248
1252
|
switch (chunk.type) {
|
|
@@ -1287,11 +1291,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1287
1291
|
),
|
|
1288
1292
|
metrics: {
|
|
1289
1293
|
time_to_first_token,
|
|
1290
|
-
tokens: !
|
|
1294
|
+
tokens: !_chunkMWVVR5LRjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1291
1295
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _30 => _30.promptTokens]),
|
|
1292
1296
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _31 => _31.completionTokens]),
|
|
1293
|
-
cached:
|
|
1294
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[
|
|
1297
|
+
cached: _chunkMWVVR5LRjs.parseCachedHeader.call(void 0,
|
|
1298
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[_chunkMWVVR5LRjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _35 => _35.rawResponse, 'optionalAccess', _36 => _36.headers, 'optionalAccess', _37 => _37[_chunkMWVVR5LRjs.LEGACY_CACHED_HEADER]])))
|
|
1295
1299
|
)
|
|
1296
1300
|
}
|
|
1297
1301
|
});
|
|
@@ -1476,12 +1480,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1476
1480
|
anthropicMetadata.usage,
|
|
1477
1481
|
"cache_creation_input_tokens"
|
|
1478
1482
|
) || 0;
|
|
1479
|
-
const cacheTokens =
|
|
1483
|
+
const cacheTokens = _chunkMWVVR5LRjs.extractAnthropicCacheTokens.call(void 0,
|
|
1480
1484
|
cacheReadTokens,
|
|
1481
1485
|
cacheCreationTokens
|
|
1482
1486
|
);
|
|
1483
1487
|
Object.assign(metrics, cacheTokens);
|
|
1484
|
-
Object.assign(metrics,
|
|
1488
|
+
Object.assign(metrics, _chunkMWVVR5LRjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1485
1489
|
}
|
|
1486
1490
|
}
|
|
1487
1491
|
return metrics;
|
|
@@ -1553,7 +1557,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1553
1557
|
model: modelFromWrapGenerate
|
|
1554
1558
|
}) => {
|
|
1555
1559
|
const rawInput = extractInput(params);
|
|
1556
|
-
const processedInput =
|
|
1560
|
+
const processedInput = _chunkMWVVR5LRjs.processInputAttachments.call(void 0, rawInput);
|
|
1557
1561
|
const spanArgs = {
|
|
1558
1562
|
name: _optionalChain([config, 'access', _54 => _54.spanInfo, 'optionalAccess', _55 => _55.name]) || "ai-sdk.doGenerate",
|
|
1559
1563
|
spanAttributes: {
|
|
@@ -1568,7 +1572,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1568
1572
|
}
|
|
1569
1573
|
}
|
|
1570
1574
|
};
|
|
1571
|
-
const span =
|
|
1575
|
+
const span = _chunkMWVVR5LRjs.startSpan.call(void 0, spanArgs);
|
|
1572
1576
|
try {
|
|
1573
1577
|
const result = await doGenerate();
|
|
1574
1578
|
const metadata = {};
|
|
@@ -1615,7 +1619,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1615
1619
|
},
|
|
1616
1620
|
wrapStream: async ({ doStream, params }) => {
|
|
1617
1621
|
const rawInput = extractInput(params);
|
|
1618
|
-
const processedInput =
|
|
1622
|
+
const processedInput = _chunkMWVVR5LRjs.processInputAttachments.call(void 0, rawInput);
|
|
1619
1623
|
const spanArgs = {
|
|
1620
1624
|
name: _optionalChain([config, 'access', _63 => _63.spanInfo, 'optionalAccess', _64 => _64.name]) || "ai-sdk.doStream",
|
|
1621
1625
|
spanAttributes: {
|
|
@@ -1630,7 +1634,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1630
1634
|
}
|
|
1631
1635
|
}
|
|
1632
1636
|
};
|
|
1633
|
-
const span =
|
|
1637
|
+
const span = _chunkMWVVR5LRjs.startSpan.call(void 0, spanArgs);
|
|
1634
1638
|
try {
|
|
1635
1639
|
const { stream, ...rest } = await doStream();
|
|
1636
1640
|
const textChunks = [];
|
|
@@ -1728,6 +1732,1469 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1728
1732
|
};
|
|
1729
1733
|
}
|
|
1730
1734
|
|
|
1735
|
+
// src/instrumentation/plugins/eve-plugin.ts
|
|
1736
|
+
var EVE_TRACE_STATE_KEY = "braintrust.eve.tracing";
|
|
1737
|
+
var MAX_EVE_CACHE_ENTRIES = 1e4;
|
|
1738
|
+
var MAX_STORED_LLM_INPUTS = 100;
|
|
1739
|
+
var MAX_STORED_SPAN_REFERENCES = 1e4;
|
|
1740
|
+
var MAX_STORED_STEP_STARTS = 1e4;
|
|
1741
|
+
function braintrustEveHook(options) {
|
|
1742
|
+
const state = options.defineState(EVE_TRACE_STATE_KEY, emptyEveTraceState);
|
|
1743
|
+
const bridge = new EveBridge(state);
|
|
1744
|
+
return {
|
|
1745
|
+
events: {
|
|
1746
|
+
"*": async (event, ctx) => {
|
|
1747
|
+
await bridge.handle(event, ctx, options.metadata);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
function braintrustEveInstrumentation(options) {
|
|
1753
|
+
const state = options.defineState(EVE_TRACE_STATE_KEY, emptyEveTraceState);
|
|
1754
|
+
return {
|
|
1755
|
+
events: {
|
|
1756
|
+
"step.started": (input) => {
|
|
1757
|
+
try {
|
|
1758
|
+
captureEveModelInput(state, input);
|
|
1759
|
+
} catch (error) {
|
|
1760
|
+
_chunkMWVVR5LRjs.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
},
|
|
1764
|
+
recordInputs: false,
|
|
1765
|
+
recordOutputs: false,
|
|
1766
|
+
setup: options.setup
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
function isEveHandleMessageStreamEvent(event) {
|
|
1770
|
+
return _chunkMWVVR5LRjs.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1771
|
+
}
|
|
1772
|
+
var ResumedEveSpan = class {
|
|
1773
|
+
constructor(reference) {
|
|
1774
|
+
this.reference = reference;
|
|
1775
|
+
this.endTime = reference.endTime;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
get rootSpanId() {
|
|
1779
|
+
return this.reference.rootSpanId;
|
|
1780
|
+
}
|
|
1781
|
+
get spanId() {
|
|
1782
|
+
return this.reference.spanId;
|
|
1783
|
+
}
|
|
1784
|
+
log(event) {
|
|
1785
|
+
const metrics = {
|
|
1786
|
+
..._optionalChain([this, 'access', _69 => _69.reference, 'access', _70 => _70.startEvent, 'optionalAccess', _71 => _71.metrics]),
|
|
1787
|
+
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1788
|
+
...event.metrics
|
|
1789
|
+
};
|
|
1790
|
+
_chunkMWVVR5LRjs.updateSpan.call(void 0, {
|
|
1791
|
+
exported: this.reference.exported,
|
|
1792
|
+
...this.reference.startEvent,
|
|
1793
|
+
...event,
|
|
1794
|
+
...Object.keys(metrics).length > 0 ? { metrics } : {}
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
end(args) {
|
|
1798
|
+
if (this.endTime === void 0) {
|
|
1799
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.endTime]), () => ( _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1800
|
+
this.log({ metrics: { end: this.endTime } });
|
|
1801
|
+
}
|
|
1802
|
+
return this.endTime;
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
var EveBridge = (_class = class {
|
|
1806
|
+
constructor(state) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);
|
|
1807
|
+
this.state = state;
|
|
1808
|
+
}
|
|
1809
|
+
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1810
|
+
__init2() {this.sessionsById = new (0, _chunkMWVVR5LRjs.LRUCache)({
|
|
1811
|
+
max: MAX_EVE_CACHE_ENTRIES
|
|
1812
|
+
})}
|
|
1813
|
+
__init3() {this.completedToolKeys = new (0, _chunkMWVVR5LRjs.LRUCache)({
|
|
1814
|
+
max: MAX_EVE_CACHE_ENTRIES
|
|
1815
|
+
})}
|
|
1816
|
+
__init4() {this.toolsByCallKey = new (0, _chunkMWVVR5LRjs.LRUCache)({
|
|
1817
|
+
max: MAX_EVE_CACHE_ENTRIES
|
|
1818
|
+
})}
|
|
1819
|
+
__init5() {this.turnsByKey = new (0, _chunkMWVVR5LRjs.LRUCache)({
|
|
1820
|
+
max: MAX_EVE_CACHE_ENTRIES
|
|
1821
|
+
})}
|
|
1822
|
+
async startEveSpan(args) {
|
|
1823
|
+
const rowId = _optionalChain([args, 'optionalAccess', _73 => _73.event, 'optionalAccess', _74 => _74.id]);
|
|
1824
|
+
const reference = typeof rowId === "string" && readEveTraceState(this.state).spanReferences.find(
|
|
1825
|
+
(candidate) => candidate.rowId === rowId
|
|
1826
|
+
);
|
|
1827
|
+
if (reference) {
|
|
1828
|
+
return new ResumedEveSpan(reference);
|
|
1829
|
+
}
|
|
1830
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.startTime]), () => ( _chunkMWVVR5LRjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1831
|
+
const parentSpanIds = _optionalChain([args, 'optionalAccess', _76 => _76.parentSpanIds]);
|
|
1832
|
+
const startEvent = {
|
|
1833
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1834
|
+
metrics: { start: startTime },
|
|
1835
|
+
span_attributes: {
|
|
1836
|
+
..._optionalChain([args, 'optionalAccess', _77 => _77.name]) ? { name: args.name } : {},
|
|
1837
|
+
..._optionalChain([args, 'optionalAccess', _78 => _78.type]) ? { type: args.type } : {},
|
|
1838
|
+
..._optionalChain([args, 'optionalAccess', _79 => _79.spanAttributes])
|
|
1839
|
+
},
|
|
1840
|
+
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
1841
|
+
};
|
|
1842
|
+
const span = _chunkMWVVR5LRjs.withCurrent.call(void 0,
|
|
1843
|
+
_chunkMWVVR5LRjs.NOOP_SPAN,
|
|
1844
|
+
() => _chunkMWVVR5LRjs._internalStartSpanWithInitialMerge.call(void 0, { ...args, startTime })
|
|
1845
|
+
);
|
|
1846
|
+
if (typeof rowId !== "string") {
|
|
1847
|
+
return span;
|
|
1848
|
+
}
|
|
1849
|
+
try {
|
|
1850
|
+
const exported = await span.export();
|
|
1851
|
+
const reference2 = {
|
|
1852
|
+
exported,
|
|
1853
|
+
rootSpanId: span.rootSpanId,
|
|
1854
|
+
rowId,
|
|
1855
|
+
spanId: span.spanId,
|
|
1856
|
+
startEvent
|
|
1857
|
+
};
|
|
1858
|
+
this.state.update((current) => {
|
|
1859
|
+
const normalized = normalizeEveTraceState(current);
|
|
1860
|
+
return normalized.spanReferences.some(
|
|
1861
|
+
(candidate) => candidate.rowId === rowId
|
|
1862
|
+
) ? normalized : {
|
|
1863
|
+
...normalized,
|
|
1864
|
+
spanReferences: [...normalized.spanReferences, reference2].slice(
|
|
1865
|
+
-MAX_STORED_SPAN_REFERENCES
|
|
1866
|
+
)
|
|
1867
|
+
};
|
|
1868
|
+
});
|
|
1869
|
+
} catch (error) {
|
|
1870
|
+
_chunkMWVVR5LRjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
1871
|
+
}
|
|
1872
|
+
return span;
|
|
1873
|
+
}
|
|
1874
|
+
async startEveChildSpan(parent, args) {
|
|
1875
|
+
return await this.startEveSpan({
|
|
1876
|
+
...args,
|
|
1877
|
+
parentSpanIds: {
|
|
1878
|
+
rootSpanId: parent.rootSpanId,
|
|
1879
|
+
spanId: parent.spanId
|
|
1880
|
+
}
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
stepOrdinal(event) {
|
|
1884
|
+
let ordinal = 0;
|
|
1885
|
+
this.state.update((current) => {
|
|
1886
|
+
const state = normalizeEveTraceState(current);
|
|
1887
|
+
const previous = state.stepStarts.filter(
|
|
1888
|
+
(entry) => entry.turnId === event.data.turnId && entry.stepIndex === event.data.stepIndex
|
|
1889
|
+
).at(-1);
|
|
1890
|
+
if (_optionalChain([previous, 'optionalAccess', _80 => _80.open])) {
|
|
1891
|
+
ordinal = previous.ordinal;
|
|
1892
|
+
return state;
|
|
1893
|
+
}
|
|
1894
|
+
ordinal = state.stepStarts.filter(
|
|
1895
|
+
(entry) => entry.turnId === event.data.turnId
|
|
1896
|
+
).length;
|
|
1897
|
+
return {
|
|
1898
|
+
...state,
|
|
1899
|
+
stepStarts: [
|
|
1900
|
+
...state.stepStarts,
|
|
1901
|
+
{
|
|
1902
|
+
open: true,
|
|
1903
|
+
ordinal,
|
|
1904
|
+
stepIndex: event.data.stepIndex,
|
|
1905
|
+
turnId: event.data.turnId
|
|
1906
|
+
}
|
|
1907
|
+
].slice(-MAX_STORED_STEP_STARTS)
|
|
1908
|
+
};
|
|
1909
|
+
});
|
|
1910
|
+
return ordinal;
|
|
1911
|
+
}
|
|
1912
|
+
markStepEnded(turnId, stepIndex) {
|
|
1913
|
+
this.state.update((current) => {
|
|
1914
|
+
const state = normalizeEveTraceState(current);
|
|
1915
|
+
let index = -1;
|
|
1916
|
+
for (let i = state.stepStarts.length - 1; i >= 0; i--) {
|
|
1917
|
+
const entry = state.stepStarts[i];
|
|
1918
|
+
if (_optionalChain([entry, 'optionalAccess', _81 => _81.turnId]) === turnId && entry.stepIndex === stepIndex) {
|
|
1919
|
+
index = i;
|
|
1920
|
+
break;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
if (index < 0 || !_optionalChain([state, 'access', _82 => _82.stepStarts, 'access', _83 => _83[index], 'optionalAccess', _84 => _84.open])) {
|
|
1924
|
+
return state;
|
|
1925
|
+
}
|
|
1926
|
+
return {
|
|
1927
|
+
...state,
|
|
1928
|
+
stepStarts: state.stepStarts.map(
|
|
1929
|
+
(entry, entryIndex) => entryIndex === index ? { ...entry, open: false } : entry
|
|
1930
|
+
)
|
|
1931
|
+
};
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
async handle(event, ctx, hookMetadata) {
|
|
1935
|
+
if (!isEveHandleMessageStreamEvent(event)) {
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1938
|
+
const run = async () => {
|
|
1939
|
+
try {
|
|
1940
|
+
if (!await this.handleEvent(event, ctx, hookMetadata)) {
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
if (event.type === "session.failed") {
|
|
1944
|
+
const sessionId2 = event.data.sessionId || sessionIdFromContext(ctx);
|
|
1945
|
+
await this.flushInstrumentation();
|
|
1946
|
+
if (sessionId2) {
|
|
1947
|
+
this.cleanupSession(sessionId2);
|
|
1948
|
+
}
|
|
1949
|
+
} else if (event.type === "session.completed") {
|
|
1950
|
+
const sessionId2 = sessionIdFromContext(ctx);
|
|
1951
|
+
await this.flushInstrumentation();
|
|
1952
|
+
if (sessionId2) {
|
|
1953
|
+
this.cleanupSession(sessionId2);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
} catch (error) {
|
|
1957
|
+
_chunkMWVVR5LRjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
1961
|
+
if (!sessionId) {
|
|
1962
|
+
await run();
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
const previous = this.eventQueuesBySession.get(sessionId);
|
|
1966
|
+
const queued = previous ? previous.then(run) : run();
|
|
1967
|
+
this.eventQueuesBySession.set(sessionId, queued);
|
|
1968
|
+
try {
|
|
1969
|
+
await queued;
|
|
1970
|
+
} finally {
|
|
1971
|
+
if (this.eventQueuesBySession.get(sessionId) === queued) {
|
|
1972
|
+
this.eventQueuesBySession.delete(sessionId);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
async handleEvent(event, ctx, hookMetadata) {
|
|
1977
|
+
switch (event.type) {
|
|
1978
|
+
case "session.started":
|
|
1979
|
+
await this.handleSessionStarted(event, ctx, hookMetadata);
|
|
1980
|
+
return true;
|
|
1981
|
+
case "turn.started":
|
|
1982
|
+
await this.handleTurnStarted(event, ctx, hookMetadata);
|
|
1983
|
+
return true;
|
|
1984
|
+
case "message.received":
|
|
1985
|
+
await this.handleMessageReceived(event, ctx, hookMetadata);
|
|
1986
|
+
return true;
|
|
1987
|
+
case "step.started":
|
|
1988
|
+
await this.handleStepStarted(event, ctx, hookMetadata);
|
|
1989
|
+
return true;
|
|
1990
|
+
case "message.completed":
|
|
1991
|
+
this.handleMessageCompleted(event, ctx);
|
|
1992
|
+
return true;
|
|
1993
|
+
case "result.completed":
|
|
1994
|
+
this.handleResultCompleted(event, ctx);
|
|
1995
|
+
return true;
|
|
1996
|
+
case "actions.requested":
|
|
1997
|
+
await this.handleActionsRequested(event, ctx, hookMetadata);
|
|
1998
|
+
return true;
|
|
1999
|
+
case "action.result":
|
|
2000
|
+
await this.handleActionResult(event, ctx, hookMetadata);
|
|
2001
|
+
return true;
|
|
2002
|
+
case "subagent.called":
|
|
2003
|
+
await this.handleSubagentCalled(event, ctx, hookMetadata);
|
|
2004
|
+
return true;
|
|
2005
|
+
case "subagent.completed":
|
|
2006
|
+
await this.handleSubagentCompleted(event, ctx, hookMetadata);
|
|
2007
|
+
return true;
|
|
2008
|
+
case "step.completed":
|
|
2009
|
+
this.handleStepCompleted(event, ctx);
|
|
2010
|
+
return true;
|
|
2011
|
+
case "step.failed":
|
|
2012
|
+
this.handleStepFailed(event, ctx);
|
|
2013
|
+
return true;
|
|
2014
|
+
case "turn.completed":
|
|
2015
|
+
await this.handleTurnCompleted(event, ctx);
|
|
2016
|
+
return true;
|
|
2017
|
+
case "turn.failed":
|
|
2018
|
+
await this.handleTurnFailed(event, ctx);
|
|
2019
|
+
return true;
|
|
2020
|
+
case "session.failed":
|
|
2021
|
+
await this.handleSessionFailed(event, ctx);
|
|
2022
|
+
return true;
|
|
2023
|
+
case "session.completed":
|
|
2024
|
+
await this.handleSessionCompleted(event, ctx);
|
|
2025
|
+
return true;
|
|
2026
|
+
default:
|
|
2027
|
+
return false;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
async handleSessionStarted(event, ctx, hookMetadata) {
|
|
2031
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2032
|
+
if (!sessionId) {
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
2035
|
+
const metadata = {
|
|
2036
|
+
..._nullishCoalesce(hookMetadata, () => ( {})),
|
|
2037
|
+
...modelMetadataFromRuntime(event.data.runtime)
|
|
2038
|
+
};
|
|
2039
|
+
this.state.update((current) => {
|
|
2040
|
+
const normalized = normalizeEveTraceState(current);
|
|
2041
|
+
return {
|
|
2042
|
+
...normalized,
|
|
2043
|
+
metadata: { ...normalized.metadata, ...metadata }
|
|
2044
|
+
};
|
|
2045
|
+
});
|
|
2046
|
+
await this.ensureSession(sessionId, ctx, metadata, eventTime(event));
|
|
2047
|
+
for (const [key, turn] of this.turnsByKey) {
|
|
2048
|
+
if (!key.startsWith(`${sessionId}:`)) {
|
|
2049
|
+
continue;
|
|
2050
|
+
}
|
|
2051
|
+
turn.metadata = { ...turn.metadata, ...metadata };
|
|
2052
|
+
turn.span.log({ metadata: turn.metadata });
|
|
2053
|
+
for (const step of turn.stepsByIndex.values()) {
|
|
2054
|
+
step.metadata = { ...step.metadata, ...metadata };
|
|
2055
|
+
step.span.log({ metadata: step.metadata });
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
async handleTurnStarted(event, ctx, hookMetadata) {
|
|
2060
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2061
|
+
if (!sessionId) {
|
|
2062
|
+
return;
|
|
2063
|
+
}
|
|
2064
|
+
const session = await this.ensureSession(
|
|
2065
|
+
sessionId,
|
|
2066
|
+
ctx,
|
|
2067
|
+
_nullishCoalesce(hookMetadata, () => ( {})),
|
|
2068
|
+
eventTime(event)
|
|
2069
|
+
);
|
|
2070
|
+
const key = turnKey(sessionId, event.data.turnId);
|
|
2071
|
+
const metadata = { ...session.metadata };
|
|
2072
|
+
const existing = this.turnsByKey.get(key);
|
|
2073
|
+
if (existing) {
|
|
2074
|
+
existing.metadata = { ...existing.metadata, ...metadata };
|
|
2075
|
+
existing.span.log({ metadata: existing.metadata });
|
|
2076
|
+
return;
|
|
2077
|
+
}
|
|
2078
|
+
const span = await this.startTurnSpan(session, event, metadata);
|
|
2079
|
+
span.log({ metadata });
|
|
2080
|
+
this.turnsByKey.set(key, {
|
|
2081
|
+
key,
|
|
2082
|
+
metadata,
|
|
2083
|
+
metrics: {},
|
|
2084
|
+
span,
|
|
2085
|
+
stepsByIndex: /* @__PURE__ */ new Map(),
|
|
2086
|
+
turnId: event.data.turnId
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
async handleMessageReceived(event, ctx, hookMetadata) {
|
|
2090
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2091
|
+
if (!turn) {
|
|
2092
|
+
return;
|
|
2093
|
+
}
|
|
2094
|
+
const input = [{ content: event.data.message, role: "user" }];
|
|
2095
|
+
turn.span.log({ input });
|
|
2096
|
+
}
|
|
2097
|
+
async handleStepStarted(event, ctx, hookMetadata) {
|
|
2098
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2099
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2100
|
+
if (!turn || !sessionId) {
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
const existing = turn.stepsByIndex.get(event.data.stepIndex);
|
|
2104
|
+
if (existing) {
|
|
2105
|
+
existing.span.log({
|
|
2106
|
+
...existing.input !== void 0 ? { input: existing.input } : {},
|
|
2107
|
+
metadata: existing.metadata,
|
|
2108
|
+
metrics: existing.metrics,
|
|
2109
|
+
output: existing.output
|
|
2110
|
+
});
|
|
2111
|
+
const endTime = eventTime(event);
|
|
2112
|
+
existing.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2113
|
+
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2114
|
+
}
|
|
2115
|
+
const stepOrdinal = this.stepOrdinal(event);
|
|
2116
|
+
const metadata = {
|
|
2117
|
+
...turn.metadata,
|
|
2118
|
+
..._nullishCoalesce(_optionalChain([this, 'access', _85 => _85.sessionsById, 'access', _86 => _86.get, 'call', _87 => _87(sessionId), 'optionalAccess', _88 => _88.metadata]), () => ( {}))
|
|
2119
|
+
};
|
|
2120
|
+
const input = consumeCapturedEveModelInput(
|
|
2121
|
+
this.state,
|
|
2122
|
+
sessionId,
|
|
2123
|
+
event.data.turnId,
|
|
2124
|
+
event.data.stepIndex
|
|
2125
|
+
);
|
|
2126
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2127
|
+
"step",
|
|
2128
|
+
sessionId,
|
|
2129
|
+
event.data.turnId,
|
|
2130
|
+
String(stepOrdinal)
|
|
2131
|
+
);
|
|
2132
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2133
|
+
event: {
|
|
2134
|
+
id: eventId,
|
|
2135
|
+
...input !== void 0 ? { input } : {},
|
|
2136
|
+
metadata
|
|
2137
|
+
},
|
|
2138
|
+
name: "eve.step",
|
|
2139
|
+
spanAttributes: { type: "llm" /* LLM */ },
|
|
2140
|
+
spanId,
|
|
2141
|
+
startTime: eventTime(event)
|
|
2142
|
+
});
|
|
2143
|
+
span.log({ ...input !== void 0 ? { input } : {}, metadata });
|
|
2144
|
+
turn.stepsByIndex.set(event.data.stepIndex, {
|
|
2145
|
+
...input !== void 0 ? { input } : {},
|
|
2146
|
+
metadata,
|
|
2147
|
+
metrics: {},
|
|
2148
|
+
span
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
handleMessageCompleted(event, ctx) {
|
|
2152
|
+
const step = this.stepForEvent(event, ctx);
|
|
2153
|
+
if (!step) {
|
|
2154
|
+
return;
|
|
2155
|
+
}
|
|
2156
|
+
const existingMessage = Array.isArray(step.output) && _chunkMWVVR5LRjs.isObject.call(void 0, step.output[0]) ? step.output[0].message : void 0;
|
|
2157
|
+
const existingToolCalls = _chunkMWVVR5LRjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2158
|
+
step.output = [
|
|
2159
|
+
{
|
|
2160
|
+
finish_reason: normalizedFinishReason(event.data.finishReason),
|
|
2161
|
+
index: 0,
|
|
2162
|
+
message: {
|
|
2163
|
+
content: event.data.message,
|
|
2164
|
+
role: "assistant",
|
|
2165
|
+
...Array.isArray(existingToolCalls) ? { tool_calls: existingToolCalls } : {}
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
];
|
|
2169
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2170
|
+
if (turn && event.data.finishReason !== "tool-calls") {
|
|
2171
|
+
turn.output = event.data.message;
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
handleResultCompleted(event, ctx) {
|
|
2175
|
+
const step = this.stepForEvent(event, ctx);
|
|
2176
|
+
if (step) {
|
|
2177
|
+
step.output = [
|
|
2178
|
+
{
|
|
2179
|
+
finish_reason: "stop",
|
|
2180
|
+
index: 0,
|
|
2181
|
+
message: {
|
|
2182
|
+
content: event.data.result,
|
|
2183
|
+
role: "assistant"
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
];
|
|
2187
|
+
}
|
|
2188
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2189
|
+
if (turn) {
|
|
2190
|
+
turn.output = event.data.result;
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
async handleActionsRequested(event, ctx, hookMetadata) {
|
|
2194
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2195
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2196
|
+
if (!turn || !sessionId) {
|
|
2197
|
+
return;
|
|
2198
|
+
}
|
|
2199
|
+
const traceActions = event.data.actions.filter(isTraceableActionRequest);
|
|
2200
|
+
if (traceActions.length === 0) {
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
for (const action of traceActions) {
|
|
2204
|
+
if (isToolCallAction(action)) {
|
|
2205
|
+
await this.startRequestedTool(event, turn, sessionId, action);
|
|
2206
|
+
} else if (isLocalSubagentCallAction(action)) {
|
|
2207
|
+
await this.startRequestedSubagent(event, turn, sessionId, action);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
const step = turn.stepsByIndex.get(event.data.stepIndex);
|
|
2211
|
+
if (!step) {
|
|
2212
|
+
return;
|
|
2213
|
+
}
|
|
2214
|
+
step.output = [
|
|
2215
|
+
{
|
|
2216
|
+
finish_reason: "tool_calls",
|
|
2217
|
+
index: 0,
|
|
2218
|
+
message: {
|
|
2219
|
+
content: null,
|
|
2220
|
+
role: "assistant",
|
|
2221
|
+
tool_calls: traceActions.map((action) => {
|
|
2222
|
+
const name = action.kind === "tool-call" ? action.toolName : _nullishCoalesce(_nullishCoalesce(action.subagentName, () => ( action.name)), () => ( "agent"));
|
|
2223
|
+
return {
|
|
2224
|
+
function: {
|
|
2225
|
+
arguments: JSON.stringify(action.input),
|
|
2226
|
+
name
|
|
2227
|
+
},
|
|
2228
|
+
id: action.callId,
|
|
2229
|
+
type: "function"
|
|
2230
|
+
};
|
|
2231
|
+
})
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
];
|
|
2235
|
+
step.span.log({ metadata: step.metadata, output: step.output });
|
|
2236
|
+
}
|
|
2237
|
+
async handleActionResult(event, ctx, hookMetadata) {
|
|
2238
|
+
if (isToolResult(event.data.result)) {
|
|
2239
|
+
await this.handleToolResult(event, ctx, event.data.result, hookMetadata);
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
2242
|
+
if (isSubagentResult(event.data.result)) {
|
|
2243
|
+
await this.handleSubagentResult(
|
|
2244
|
+
event,
|
|
2245
|
+
ctx,
|
|
2246
|
+
event.data.result,
|
|
2247
|
+
hookMetadata
|
|
2248
|
+
);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
async handleToolResult(event, ctx, result, hookMetadata) {
|
|
2252
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2253
|
+
if (!sessionId) {
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
const key = toolKey(sessionId, result.callId);
|
|
2257
|
+
if (this.completedToolKeys.has(key)) {
|
|
2258
|
+
return;
|
|
2259
|
+
}
|
|
2260
|
+
const tool = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticTool(event, ctx, result, hookMetadata)));
|
|
2261
|
+
if (!tool) {
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
const failed = event.data.status === "failed" || result.isError === true || event.data.error !== void 0;
|
|
2265
|
+
tool.span.log({
|
|
2266
|
+
...failed ? {
|
|
2267
|
+
error: actionResultError(event.data.error, result.output)
|
|
2268
|
+
} : {},
|
|
2269
|
+
metadata: tool.metadata,
|
|
2270
|
+
output: result.output
|
|
2271
|
+
});
|
|
2272
|
+
const endTime = eventTime(event);
|
|
2273
|
+
tool.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2274
|
+
this.toolsByCallKey.delete(key);
|
|
2275
|
+
this.completedToolKeys.set(key, true);
|
|
2276
|
+
}
|
|
2277
|
+
async handleSubagentCalled(event, ctx, hookMetadata) {
|
|
2278
|
+
if (_optionalChain([event, 'access', _89 => _89.data, 'access', _90 => _90.remote, 'optionalAccess', _91 => _91.url])) {
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2282
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2283
|
+
if (!turn || !sessionId) {
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
const key = toolKey(sessionId, event.data.callId);
|
|
2287
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2288
|
+
const existing = this.toolsByCallKey.get(key);
|
|
2289
|
+
if (existing) {
|
|
2290
|
+
existing.metadata = { ...existing.metadata, ...metadata };
|
|
2291
|
+
existing.span.log({ metadata: existing.metadata });
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
if (this.completedToolKeys.has(key)) {
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2298
|
+
"subagent",
|
|
2299
|
+
sessionId,
|
|
2300
|
+
event.data.callId
|
|
2301
|
+
);
|
|
2302
|
+
const pending = this.toolsByCallKey.get(key);
|
|
2303
|
+
if (pending || this.completedToolKeys.has(key)) {
|
|
2304
|
+
if (pending) {
|
|
2305
|
+
pending.metadata = { ...pending.metadata, ...metadata };
|
|
2306
|
+
pending.span.log({ metadata: pending.metadata });
|
|
2307
|
+
}
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2311
|
+
event: {
|
|
2312
|
+
id: eventId,
|
|
2313
|
+
metadata
|
|
2314
|
+
},
|
|
2315
|
+
name: _nullishCoalesce(event.data.toolName, () => ( event.data.name)),
|
|
2316
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2317
|
+
spanId,
|
|
2318
|
+
startTime: eventTime(event)
|
|
2319
|
+
});
|
|
2320
|
+
span.log({ metadata });
|
|
2321
|
+
this.toolsByCallKey.set(key, {
|
|
2322
|
+
metadata,
|
|
2323
|
+
span,
|
|
2324
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
async handleSubagentCompleted(event, ctx, hookMetadata) {
|
|
2328
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2329
|
+
if (!sessionId) {
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
const key = toolKey(sessionId, event.data.callId);
|
|
2333
|
+
if (this.completedToolKeys.has(key)) {
|
|
2334
|
+
return;
|
|
2335
|
+
}
|
|
2336
|
+
const subagent = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticSubagent(event, ctx, hookMetadata)));
|
|
2337
|
+
if (!subagent) {
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
subagent.span.log({
|
|
2341
|
+
...event.data.status === "failed" ? {
|
|
2342
|
+
error: actionResultError(event.data.error, event.data.output)
|
|
2343
|
+
} : {},
|
|
2344
|
+
metadata: subagent.metadata,
|
|
2345
|
+
...event.data.output !== void 0 ? { output: event.data.output } : {}
|
|
2346
|
+
});
|
|
2347
|
+
const endTime = eventTime(event);
|
|
2348
|
+
const recordedEndTime = subagent.span.end(
|
|
2349
|
+
endTime === void 0 ? void 0 : { endTime }
|
|
2350
|
+
);
|
|
2351
|
+
this.state.update((current) => {
|
|
2352
|
+
const normalized = normalizeEveTraceState(current);
|
|
2353
|
+
return {
|
|
2354
|
+
...normalized,
|
|
2355
|
+
spanReferences: normalized.spanReferences.map(
|
|
2356
|
+
(reference) => reference.spanId === subagent.span.spanId ? { ...reference, endTime: recordedEndTime } : reference
|
|
2357
|
+
)
|
|
2358
|
+
};
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
async handleSubagentResult(event, ctx, result, hookMetadata) {
|
|
2362
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2363
|
+
if (!sessionId) {
|
|
2364
|
+
return;
|
|
2365
|
+
}
|
|
2366
|
+
const key = toolKey(sessionId, result.callId);
|
|
2367
|
+
if (this.completedToolKeys.has(key)) {
|
|
2368
|
+
return;
|
|
2369
|
+
}
|
|
2370
|
+
const subagent = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticSubagentResult(
|
|
2371
|
+
event,
|
|
2372
|
+
ctx,
|
|
2373
|
+
result,
|
|
2374
|
+
hookMetadata
|
|
2375
|
+
)));
|
|
2376
|
+
if (!subagent) {
|
|
2377
|
+
return;
|
|
2378
|
+
}
|
|
2379
|
+
const isError = event.data.status === "failed" || result.isError === true || event.data.error !== void 0;
|
|
2380
|
+
subagent.span.log({
|
|
2381
|
+
...isError ? {
|
|
2382
|
+
error: actionResultError(event.data.error, result.output)
|
|
2383
|
+
} : {},
|
|
2384
|
+
metadata: subagent.metadata,
|
|
2385
|
+
output: result.output
|
|
2386
|
+
});
|
|
2387
|
+
const endTime = eventTime(event);
|
|
2388
|
+
subagent.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2389
|
+
this.toolsByCallKey.delete(key);
|
|
2390
|
+
this.completedToolKeys.set(key, true);
|
|
2391
|
+
}
|
|
2392
|
+
handleStepCompleted(event, ctx) {
|
|
2393
|
+
const step = this.stepForEvent(event, ctx);
|
|
2394
|
+
if (!step) {
|
|
2395
|
+
return;
|
|
2396
|
+
}
|
|
2397
|
+
const usage = event.data.usage;
|
|
2398
|
+
const inputTokens = typeof _optionalChain([usage, 'optionalAccess', _92 => _92.inputTokens]) === "number" && Number.isFinite(usage.inputTokens) && usage.inputTokens >= 0 ? usage.inputTokens : void 0;
|
|
2399
|
+
const outputTokens = typeof _optionalChain([usage, 'optionalAccess', _93 => _93.outputTokens]) === "number" && Number.isFinite(usage.outputTokens) && usage.outputTokens >= 0 ? usage.outputTokens : void 0;
|
|
2400
|
+
const cacheReadTokens = typeof _optionalChain([usage, 'optionalAccess', _94 => _94.cacheReadTokens]) === "number" && Number.isFinite(usage.cacheReadTokens) && usage.cacheReadTokens >= 0 ? usage.cacheReadTokens : void 0;
|
|
2401
|
+
const cacheWriteTokens = typeof _optionalChain([usage, 'optionalAccess', _95 => _95.cacheWriteTokens]) === "number" && Number.isFinite(usage.cacheWriteTokens) && usage.cacheWriteTokens >= 0 ? usage.cacheWriteTokens : void 0;
|
|
2402
|
+
const costUsd = typeof _optionalChain([usage, 'optionalAccess', _96 => _96.costUsd]) === "number" && Number.isFinite(usage.costUsd) && usage.costUsd >= 0 ? usage.costUsd : void 0;
|
|
2403
|
+
const total = inputTokens !== void 0 && outputTokens !== void 0 ? inputTokens + outputTokens : void 0;
|
|
2404
|
+
const metrics = {
|
|
2405
|
+
...inputTokens !== void 0 ? { prompt_tokens: inputTokens } : {},
|
|
2406
|
+
...outputTokens !== void 0 ? { completion_tokens: outputTokens } : {},
|
|
2407
|
+
...total !== void 0 ? { tokens: total } : {},
|
|
2408
|
+
...cacheReadTokens !== void 0 ? { prompt_cached_tokens: cacheReadTokens } : {},
|
|
2409
|
+
...cacheWriteTokens !== void 0 ? { prompt_cache_creation_tokens: cacheWriteTokens } : {},
|
|
2410
|
+
...costUsd !== void 0 ? { estimated_cost: costUsd } : {}
|
|
2411
|
+
};
|
|
2412
|
+
step.metrics = { ...step.metrics, ...metrics };
|
|
2413
|
+
if (Array.isArray(step.output) && _chunkMWVVR5LRjs.isObject.call(void 0, step.output[0])) {
|
|
2414
|
+
const finishReason = step.output[0].finish_reason;
|
|
2415
|
+
if (typeof finishReason !== "string") {
|
|
2416
|
+
step.output[0].finish_reason = normalizedFinishReason(
|
|
2417
|
+
event.data.finishReason
|
|
2418
|
+
);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
step.span.log({
|
|
2422
|
+
...step.input !== void 0 ? { input: step.input } : {},
|
|
2423
|
+
metadata: step.metadata,
|
|
2424
|
+
metrics,
|
|
2425
|
+
output: step.output
|
|
2426
|
+
});
|
|
2427
|
+
const endTime = eventTime(event);
|
|
2428
|
+
step.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2429
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2430
|
+
if (turn) {
|
|
2431
|
+
for (const [key, value] of Object.entries(metrics)) {
|
|
2432
|
+
turn.metrics[key] = (_nullishCoalesce(turn.metrics[key], () => ( 0))) + value;
|
|
2433
|
+
}
|
|
2434
|
+
turn.stepsByIndex.delete(event.data.stepIndex);
|
|
2435
|
+
}
|
|
2436
|
+
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2437
|
+
}
|
|
2438
|
+
handleStepFailed(event, ctx) {
|
|
2439
|
+
const step = this.stepForEvent(event, ctx);
|
|
2440
|
+
if (step) {
|
|
2441
|
+
step.span.log({
|
|
2442
|
+
error: errorFromMessage(
|
|
2443
|
+
event.data.message,
|
|
2444
|
+
event.data.code,
|
|
2445
|
+
event.data.details
|
|
2446
|
+
)
|
|
2447
|
+
});
|
|
2448
|
+
const endTime = eventTime(event);
|
|
2449
|
+
step.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2450
|
+
}
|
|
2451
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2452
|
+
_optionalChain([turn, 'optionalAccess', _97 => _97.stepsByIndex, 'access', _98 => _98.delete, 'call', _99 => _99(event.data.stepIndex)]);
|
|
2453
|
+
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2454
|
+
}
|
|
2455
|
+
handleTurnCompleted(event, ctx) {
|
|
2456
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2457
|
+
if (!turn) {
|
|
2458
|
+
return;
|
|
2459
|
+
}
|
|
2460
|
+
this.finalizeTurn(turn, {
|
|
2461
|
+
endTime: eventTime(event)
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
handleTurnFailed(event, ctx) {
|
|
2465
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2466
|
+
if (!turn) {
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2469
|
+
this.finalizeTurn(turn, {
|
|
2470
|
+
endTime: eventTime(event),
|
|
2471
|
+
error: errorFromMessage(
|
|
2472
|
+
event.data.message,
|
|
2473
|
+
event.data.code,
|
|
2474
|
+
event.data.details
|
|
2475
|
+
)
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
async handleSessionFailed(event, ctx) {
|
|
2479
|
+
const sessionId = event.data.sessionId || sessionIdFromContext(ctx);
|
|
2480
|
+
if (!sessionId) {
|
|
2481
|
+
return;
|
|
2482
|
+
}
|
|
2483
|
+
const session = await this.ensureSession(
|
|
2484
|
+
sessionId,
|
|
2485
|
+
ctx,
|
|
2486
|
+
{},
|
|
2487
|
+
eventTime(event)
|
|
2488
|
+
);
|
|
2489
|
+
const error = errorFromMessage(
|
|
2490
|
+
event.data.message,
|
|
2491
|
+
event.data.code,
|
|
2492
|
+
event.data.details
|
|
2493
|
+
);
|
|
2494
|
+
for (const [key, turn] of this.turnsByKey) {
|
|
2495
|
+
if (!key.startsWith(`${sessionId}:`)) {
|
|
2496
|
+
continue;
|
|
2497
|
+
}
|
|
2498
|
+
this.finalizeTurn(turn, {
|
|
2499
|
+
endTime: eventTime(event),
|
|
2500
|
+
error
|
|
2501
|
+
});
|
|
2502
|
+
}
|
|
2503
|
+
for (const [key, tool] of this.toolsByCallKey) {
|
|
2504
|
+
if (key.startsWith(`${sessionId}:`)) {
|
|
2505
|
+
const endTime2 = eventTime(event);
|
|
2506
|
+
if (!tool.endedByTurn) {
|
|
2507
|
+
tool.span.log({ metadata: tool.metadata });
|
|
2508
|
+
tool.span.end(endTime2 === void 0 ? void 0 : { endTime: endTime2 });
|
|
2509
|
+
tool.endedByTurn = true;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
session.span.log({ error });
|
|
2514
|
+
const endTime = eventTime(event);
|
|
2515
|
+
session.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2516
|
+
}
|
|
2517
|
+
async handleSessionCompleted(event, ctx) {
|
|
2518
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2519
|
+
if (!sessionId) {
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
const session = await this.ensureSession(
|
|
2523
|
+
sessionId,
|
|
2524
|
+
ctx,
|
|
2525
|
+
{},
|
|
2526
|
+
eventTime(event)
|
|
2527
|
+
);
|
|
2528
|
+
for (const [key, turn] of this.turnsByKey) {
|
|
2529
|
+
if (!key.startsWith(`${sessionId}:`)) {
|
|
2530
|
+
continue;
|
|
2531
|
+
}
|
|
2532
|
+
this.finalizeTurn(turn, {
|
|
2533
|
+
endTime: eventTime(event)
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2536
|
+
for (const [key, tool] of this.toolsByCallKey) {
|
|
2537
|
+
if (key.startsWith(`${sessionId}:`) && !tool.endedByTurn) {
|
|
2538
|
+
const endTime2 = eventTime(event);
|
|
2539
|
+
tool.span.log({ metadata: tool.metadata });
|
|
2540
|
+
tool.span.end(endTime2 === void 0 ? void 0 : { endTime: endTime2 });
|
|
2541
|
+
tool.endedByTurn = true;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
session.span.log({ metadata: session.metadata });
|
|
2545
|
+
const endTime = eventTime(event);
|
|
2546
|
+
session.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2547
|
+
}
|
|
2548
|
+
async ensureSession(sessionId, ctx, metadata, startTime) {
|
|
2549
|
+
metadata = {
|
|
2550
|
+
...readEveTraceState(this.state).metadata,
|
|
2551
|
+
...metadata
|
|
2552
|
+
};
|
|
2553
|
+
const existing = this.sessionsById.get(sessionId);
|
|
2554
|
+
if (existing) {
|
|
2555
|
+
existing.metadata = { ...existing.metadata, ...metadata };
|
|
2556
|
+
existing.span.log({ metadata: existing.metadata });
|
|
2557
|
+
return existing;
|
|
2558
|
+
}
|
|
2559
|
+
const lineage = parentLineageFromContext(ctx);
|
|
2560
|
+
const parentSubagent = lineage ? this.toolsByCallKey.get(toolKey(lineage.sessionId, lineage.callId)) : void 0;
|
|
2561
|
+
const activeParent = _chunkMWVVR5LRjs.currentSpan.call(void 0, );
|
|
2562
|
+
const [
|
|
2563
|
+
{ rowId: eventId, spanId },
|
|
2564
|
+
parentSubagentSpanId,
|
|
2565
|
+
fallbackRootSpanId
|
|
2566
|
+
] = await Promise.all([
|
|
2567
|
+
generateEveIds("session", sessionId),
|
|
2568
|
+
lineage ? spanIdForSubagent(lineage.sessionId, lineage.callId) : Promise.resolve(void 0),
|
|
2569
|
+
lineage ? rootSpanIdForSession(lineage.rootSessionId) : rootSpanIdForSession(sessionId)
|
|
2570
|
+
]);
|
|
2571
|
+
const span = await this.startEveSpan({
|
|
2572
|
+
event: {
|
|
2573
|
+
id: eventId,
|
|
2574
|
+
metadata
|
|
2575
|
+
},
|
|
2576
|
+
name: "eve.session",
|
|
2577
|
+
parentSpanIds: lineage && parentSubagentSpanId ? {
|
|
2578
|
+
rootSpanId: _nullishCoalesce(_optionalChain([parentSubagent, 'optionalAccess', _100 => _100.span, 'access', _101 => _101.rootSpanId]), () => ( fallbackRootSpanId)),
|
|
2579
|
+
spanId: parentSubagentSpanId
|
|
2580
|
+
} : !Object.is(activeParent, _chunkMWVVR5LRjs.NOOP_SPAN) ? {
|
|
2581
|
+
rootSpanId: activeParent.rootSpanId,
|
|
2582
|
+
spanId: activeParent.spanId
|
|
2583
|
+
} : {
|
|
2584
|
+
parentSpanIds: [],
|
|
2585
|
+
rootSpanId: fallbackRootSpanId
|
|
2586
|
+
},
|
|
2587
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
2588
|
+
spanId,
|
|
2589
|
+
startTime
|
|
2590
|
+
});
|
|
2591
|
+
span.log({ metadata });
|
|
2592
|
+
const session = { metadata, sessionId, span };
|
|
2593
|
+
this.sessionsById.set(sessionId, session);
|
|
2594
|
+
return session;
|
|
2595
|
+
}
|
|
2596
|
+
async ensureTurn(event, ctx, hookMetadata) {
|
|
2597
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2598
|
+
if (!sessionId) {
|
|
2599
|
+
return void 0;
|
|
2600
|
+
}
|
|
2601
|
+
const session = await this.ensureSession(
|
|
2602
|
+
sessionId,
|
|
2603
|
+
ctx,
|
|
2604
|
+
_nullishCoalesce(hookMetadata, () => ( {})),
|
|
2605
|
+
eventTime(event)
|
|
2606
|
+
);
|
|
2607
|
+
const key = turnKey(sessionId, event.data.turnId);
|
|
2608
|
+
const existing = this.turnsByKey.get(key);
|
|
2609
|
+
if (existing) {
|
|
2610
|
+
return existing;
|
|
2611
|
+
}
|
|
2612
|
+
const metadata = { ...session.metadata };
|
|
2613
|
+
const span = await this.startTurnSpan(session, event, metadata);
|
|
2614
|
+
span.log({ metadata });
|
|
2615
|
+
const state = {
|
|
2616
|
+
key,
|
|
2617
|
+
metadata,
|
|
2618
|
+
metrics: {},
|
|
2619
|
+
span,
|
|
2620
|
+
stepsByIndex: /* @__PURE__ */ new Map(),
|
|
2621
|
+
turnId: event.data.turnId
|
|
2622
|
+
};
|
|
2623
|
+
this.turnsByKey.set(key, state);
|
|
2624
|
+
return state;
|
|
2625
|
+
}
|
|
2626
|
+
async startRequestedTool(event, turn, sessionId, action) {
|
|
2627
|
+
const key = toolKey(sessionId, action.callId);
|
|
2628
|
+
if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
|
|
2629
|
+
return;
|
|
2630
|
+
}
|
|
2631
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2632
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2633
|
+
"tool",
|
|
2634
|
+
sessionId,
|
|
2635
|
+
event.data.turnId,
|
|
2636
|
+
action.callId
|
|
2637
|
+
);
|
|
2638
|
+
if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
|
|
2639
|
+
return;
|
|
2640
|
+
}
|
|
2641
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2642
|
+
event: {
|
|
2643
|
+
id: eventId,
|
|
2644
|
+
input: action.input,
|
|
2645
|
+
metadata
|
|
2646
|
+
},
|
|
2647
|
+
name: action.toolName,
|
|
2648
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2649
|
+
spanId,
|
|
2650
|
+
startTime: eventTime(event)
|
|
2651
|
+
});
|
|
2652
|
+
span.log({ input: action.input, metadata });
|
|
2653
|
+
this.toolsByCallKey.set(key, {
|
|
2654
|
+
metadata,
|
|
2655
|
+
span,
|
|
2656
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
async startRequestedSubagent(event, turn, sessionId, action) {
|
|
2660
|
+
const key = toolKey(sessionId, action.callId);
|
|
2661
|
+
if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
const name = _nullishCoalesce(_nullishCoalesce(action.subagentName, () => ( action.name)), () => ( "agent"));
|
|
2665
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2666
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2667
|
+
"subagent",
|
|
2668
|
+
sessionId,
|
|
2669
|
+
action.callId
|
|
2670
|
+
);
|
|
2671
|
+
if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2675
|
+
event: {
|
|
2676
|
+
id: eventId,
|
|
2677
|
+
input: action.input,
|
|
2678
|
+
metadata
|
|
2679
|
+
},
|
|
2680
|
+
name,
|
|
2681
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2682
|
+
spanId,
|
|
2683
|
+
startTime: eventTime(event)
|
|
2684
|
+
});
|
|
2685
|
+
span.log({ input: action.input, metadata });
|
|
2686
|
+
this.toolsByCallKey.set(key, {
|
|
2687
|
+
metadata,
|
|
2688
|
+
span,
|
|
2689
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2692
|
+
async startSyntheticTool(event, ctx, result, hookMetadata) {
|
|
2693
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2694
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2695
|
+
if (!turn || !sessionId) {
|
|
2696
|
+
return void 0;
|
|
2697
|
+
}
|
|
2698
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2699
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2700
|
+
"tool",
|
|
2701
|
+
sessionId,
|
|
2702
|
+
event.data.turnId,
|
|
2703
|
+
result.callId
|
|
2704
|
+
);
|
|
2705
|
+
const existing = this.toolsByCallKey.get(toolKey(sessionId, result.callId));
|
|
2706
|
+
if (existing) {
|
|
2707
|
+
return existing;
|
|
2708
|
+
}
|
|
2709
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2710
|
+
event: {
|
|
2711
|
+
id: eventId,
|
|
2712
|
+
metadata
|
|
2713
|
+
},
|
|
2714
|
+
name: result.toolName,
|
|
2715
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2716
|
+
spanId,
|
|
2717
|
+
startTime: eventTime(event)
|
|
2718
|
+
});
|
|
2719
|
+
span.log({ metadata });
|
|
2720
|
+
const state = {
|
|
2721
|
+
metadata,
|
|
2722
|
+
span,
|
|
2723
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2724
|
+
};
|
|
2725
|
+
this.toolsByCallKey.set(toolKey(sessionId, result.callId), state);
|
|
2726
|
+
return state;
|
|
2727
|
+
}
|
|
2728
|
+
async startSyntheticSubagent(event, ctx, hookMetadata) {
|
|
2729
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2730
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2731
|
+
if (!turn || !sessionId) {
|
|
2732
|
+
return void 0;
|
|
2733
|
+
}
|
|
2734
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2735
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2736
|
+
"subagent",
|
|
2737
|
+
sessionId,
|
|
2738
|
+
event.data.callId
|
|
2739
|
+
);
|
|
2740
|
+
const existing = this.toolsByCallKey.get(
|
|
2741
|
+
toolKey(sessionId, event.data.callId)
|
|
2742
|
+
);
|
|
2743
|
+
if (existing) {
|
|
2744
|
+
return existing;
|
|
2745
|
+
}
|
|
2746
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2747
|
+
event: {
|
|
2748
|
+
id: eventId,
|
|
2749
|
+
metadata
|
|
2750
|
+
},
|
|
2751
|
+
name: event.data.subagentName,
|
|
2752
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2753
|
+
spanId,
|
|
2754
|
+
startTime: eventTime(event)
|
|
2755
|
+
});
|
|
2756
|
+
span.log({ metadata });
|
|
2757
|
+
const state = {
|
|
2758
|
+
metadata,
|
|
2759
|
+
span,
|
|
2760
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2761
|
+
};
|
|
2762
|
+
this.toolsByCallKey.set(toolKey(sessionId, event.data.callId), state);
|
|
2763
|
+
return state;
|
|
2764
|
+
}
|
|
2765
|
+
async startSyntheticSubagentResult(event, ctx, result, hookMetadata) {
|
|
2766
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2767
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2768
|
+
if (!turn || !sessionId) {
|
|
2769
|
+
return void 0;
|
|
2770
|
+
}
|
|
2771
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2772
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2773
|
+
"subagent",
|
|
2774
|
+
sessionId,
|
|
2775
|
+
result.callId
|
|
2776
|
+
);
|
|
2777
|
+
const existing = this.toolsByCallKey.get(toolKey(sessionId, result.callId));
|
|
2778
|
+
if (existing) {
|
|
2779
|
+
return existing;
|
|
2780
|
+
}
|
|
2781
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2782
|
+
event: {
|
|
2783
|
+
id: eventId,
|
|
2784
|
+
metadata
|
|
2785
|
+
},
|
|
2786
|
+
name: result.subagentName,
|
|
2787
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2788
|
+
spanId,
|
|
2789
|
+
startTime: eventTime(event)
|
|
2790
|
+
});
|
|
2791
|
+
span.log({ metadata });
|
|
2792
|
+
const state = {
|
|
2793
|
+
metadata,
|
|
2794
|
+
span,
|
|
2795
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2796
|
+
};
|
|
2797
|
+
this.toolsByCallKey.set(toolKey(sessionId, result.callId), state);
|
|
2798
|
+
return state;
|
|
2799
|
+
}
|
|
2800
|
+
async startTurnSpan(session, event, metadata) {
|
|
2801
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2802
|
+
"turn",
|
|
2803
|
+
session.sessionId,
|
|
2804
|
+
event.data.turnId
|
|
2805
|
+
);
|
|
2806
|
+
return await this.startEveSpan({
|
|
2807
|
+
event: {
|
|
2808
|
+
id: eventId,
|
|
2809
|
+
metadata
|
|
2810
|
+
},
|
|
2811
|
+
name: "eve.turn",
|
|
2812
|
+
parentSpanIds: {
|
|
2813
|
+
rootSpanId: session.span.rootSpanId,
|
|
2814
|
+
spanId: session.span.spanId
|
|
2815
|
+
},
|
|
2816
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
2817
|
+
spanId,
|
|
2818
|
+
startTime: eventTime(event)
|
|
2819
|
+
});
|
|
2820
|
+
}
|
|
2821
|
+
turnForEvent(event, ctx) {
|
|
2822
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2823
|
+
return sessionId ? this.turnsByKey.get(turnKey(sessionId, event.data.turnId)) : void 0;
|
|
2824
|
+
}
|
|
2825
|
+
stepForEvent(event, ctx) {
|
|
2826
|
+
return _optionalChain([this, 'access', _102 => _102.turnForEvent, 'call', _103 => _103(event, ctx), 'optionalAccess', _104 => _104.stepsByIndex, 'access', _105 => _105.get, 'call', _106 => _106(
|
|
2827
|
+
event.data.stepIndex
|
|
2828
|
+
)]);
|
|
2829
|
+
}
|
|
2830
|
+
finalizeTurn(turn, args) {
|
|
2831
|
+
const { endTime } = args;
|
|
2832
|
+
for (const step of turn.stepsByIndex.values()) {
|
|
2833
|
+
step.span.log({
|
|
2834
|
+
...step.input !== void 0 ? { input: step.input } : {},
|
|
2835
|
+
metadata: step.metadata,
|
|
2836
|
+
metrics: step.metrics,
|
|
2837
|
+
output: step.output
|
|
2838
|
+
});
|
|
2839
|
+
step.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2840
|
+
}
|
|
2841
|
+
turn.stepsByIndex.clear();
|
|
2842
|
+
for (const tool of this.toolsByCallKey.values()) {
|
|
2843
|
+
if (tool.turnKey !== turn.key) {
|
|
2844
|
+
continue;
|
|
2845
|
+
}
|
|
2846
|
+
if (tool.endedByTurn) {
|
|
2847
|
+
continue;
|
|
2848
|
+
}
|
|
2849
|
+
tool.span.log({ metadata: tool.metadata });
|
|
2850
|
+
tool.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2851
|
+
tool.endedByTurn = true;
|
|
2852
|
+
}
|
|
2853
|
+
if (args.error) {
|
|
2854
|
+
turn.span.log({ error: args.error });
|
|
2855
|
+
} else {
|
|
2856
|
+
turn.span.log({
|
|
2857
|
+
metadata: turn.metadata,
|
|
2858
|
+
metrics: turn.metrics,
|
|
2859
|
+
output: turn.output
|
|
2860
|
+
});
|
|
2861
|
+
}
|
|
2862
|
+
turn.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2863
|
+
this.turnsByKey.delete(turn.key);
|
|
2864
|
+
this.state.update((current) => {
|
|
2865
|
+
const normalized = normalizeEveTraceState(current);
|
|
2866
|
+
return {
|
|
2867
|
+
...normalized,
|
|
2868
|
+
stepStarts: normalized.stepStarts.filter(
|
|
2869
|
+
(entry) => entry.turnId !== turn.turnId
|
|
2870
|
+
)
|
|
2871
|
+
};
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
cleanupSession(sessionId) {
|
|
2875
|
+
const keyPrefix = `${sessionId}:`;
|
|
2876
|
+
this.sessionsById.delete(sessionId);
|
|
2877
|
+
for (const key of this.turnsByKey.keys()) {
|
|
2878
|
+
if (key.startsWith(keyPrefix)) {
|
|
2879
|
+
this.turnsByKey.delete(key);
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
for (const key of this.toolsByCallKey.keys()) {
|
|
2883
|
+
if (key.startsWith(keyPrefix)) {
|
|
2884
|
+
this.toolsByCallKey.delete(key);
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
for (const key of this.completedToolKeys.keys()) {
|
|
2888
|
+
if (key.startsWith(keyPrefix)) {
|
|
2889
|
+
this.completedToolKeys.delete(key);
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
this.state.update(() => emptyEveTraceState());
|
|
2893
|
+
}
|
|
2894
|
+
async flushInstrumentation() {
|
|
2895
|
+
try {
|
|
2896
|
+
await _chunkMWVVR5LRjs.flush.call(void 0, );
|
|
2897
|
+
return true;
|
|
2898
|
+
} catch (error) {
|
|
2899
|
+
_chunkMWVVR5LRjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
2900
|
+
return false;
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
}, _class);
|
|
2904
|
+
function emptyEveTraceState() {
|
|
2905
|
+
return {
|
|
2906
|
+
llmInputs: [],
|
|
2907
|
+
metadata: {},
|
|
2908
|
+
spanReferences: [],
|
|
2909
|
+
stepStarts: []
|
|
2910
|
+
};
|
|
2911
|
+
}
|
|
2912
|
+
function normalizeEveTraceState(state) {
|
|
2913
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, state)) {
|
|
2914
|
+
return emptyEveTraceState();
|
|
2915
|
+
}
|
|
2916
|
+
const metadata = _chunkMWVVR5LRjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
2917
|
+
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
2918
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, entry)) {
|
|
2919
|
+
return [];
|
|
2920
|
+
}
|
|
2921
|
+
const exported = entry["exported"];
|
|
2922
|
+
const endTime = entry["endTime"];
|
|
2923
|
+
const rootSpanId = entry["rootSpanId"];
|
|
2924
|
+
const rowId = entry["rowId"];
|
|
2925
|
+
const spanId = entry["spanId"];
|
|
2926
|
+
const startEvent = entry["startEvent"];
|
|
2927
|
+
const startEventCreated = _chunkMWVVR5LRjs.isObject.call(void 0, startEvent) ? startEvent["created"] : void 0;
|
|
2928
|
+
const startEventMetrics = _chunkMWVVR5LRjs.isObject.call(void 0, startEvent) ? startEvent["metrics"] : void 0;
|
|
2929
|
+
const startEventSpanAttributes = _chunkMWVVR5LRjs.isObject.call(void 0, startEvent) ? startEvent["span_attributes"] : void 0;
|
|
2930
|
+
const startEventSpanParents = _chunkMWVVR5LRjs.isObject.call(void 0, startEvent) ? startEvent["span_parents"] : void 0;
|
|
2931
|
+
const normalizedStartEvent = typeof startEventCreated === "string" && _chunkMWVVR5LRjs.isObject.call(void 0, startEventMetrics) && typeof startEventMetrics["start"] === "number" && Number.isFinite(startEventMetrics["start"]) && _chunkMWVVR5LRjs.isObject.call(void 0, startEventSpanAttributes) && Array.isArray(startEventSpanParents) && startEventSpanParents.every(
|
|
2932
|
+
(parent) => typeof parent === "string"
|
|
2933
|
+
) ? {
|
|
2934
|
+
created: startEventCreated,
|
|
2935
|
+
metrics: { start: startEventMetrics["start"] },
|
|
2936
|
+
span_attributes: { ...startEventSpanAttributes },
|
|
2937
|
+
span_parents: [...startEventSpanParents]
|
|
2938
|
+
} : void 0;
|
|
2939
|
+
return typeof exported === "string" && typeof rootSpanId === "string" && typeof rowId === "string" && typeof spanId === "string" ? [
|
|
2940
|
+
{
|
|
2941
|
+
...typeof endTime === "number" && Number.isFinite(endTime) ? { endTime } : {},
|
|
2942
|
+
exported,
|
|
2943
|
+
rootSpanId,
|
|
2944
|
+
rowId,
|
|
2945
|
+
spanId,
|
|
2946
|
+
...normalizedStartEvent ? { startEvent: normalizedStartEvent } : {}
|
|
2947
|
+
}
|
|
2948
|
+
] : [];
|
|
2949
|
+
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
2950
|
+
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
2951
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, entry)) {
|
|
2952
|
+
return [];
|
|
2953
|
+
}
|
|
2954
|
+
const key = entry["key"];
|
|
2955
|
+
const input = entry["input"];
|
|
2956
|
+
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
2957
|
+
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
2958
|
+
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
2959
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, entry)) {
|
|
2960
|
+
return [];
|
|
2961
|
+
}
|
|
2962
|
+
const ordinal = entry["ordinal"];
|
|
2963
|
+
const open = entry["open"];
|
|
2964
|
+
const stepIndex = entry["stepIndex"];
|
|
2965
|
+
const turnId = entry["turnId"];
|
|
2966
|
+
return typeof ordinal === "number" && Number.isInteger(ordinal) && ordinal >= 0 && typeof open === "boolean" && typeof stepIndex === "number" && Number.isInteger(stepIndex) && typeof turnId === "string" ? [{ open, ordinal, stepIndex, turnId }] : [];
|
|
2967
|
+
}).slice(-MAX_STORED_STEP_STARTS) : [];
|
|
2968
|
+
return { llmInputs, metadata: { ...metadata }, spanReferences, stepStarts };
|
|
2969
|
+
}
|
|
2970
|
+
function readEveTraceState(state) {
|
|
2971
|
+
try {
|
|
2972
|
+
return normalizeEveTraceState(state.get());
|
|
2973
|
+
} catch (e3) {
|
|
2974
|
+
return emptyEveTraceState();
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
function captureEveModelInput(state, input) {
|
|
2978
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, input)) {
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
const session = input["session"];
|
|
2982
|
+
const turn = input["turn"];
|
|
2983
|
+
const step = input["step"];
|
|
2984
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, session) || !_chunkMWVVR5LRjs.isObject.call(void 0, turn) || !_chunkMWVVR5LRjs.isObject.call(void 0, step)) {
|
|
2985
|
+
return;
|
|
2986
|
+
}
|
|
2987
|
+
const sessionId = session["id"];
|
|
2988
|
+
const turnId = turn["id"];
|
|
2989
|
+
const stepIndex = step["index"];
|
|
2990
|
+
if (typeof sessionId !== "string" || typeof turnId !== "string" || typeof stepIndex !== "number" || !Number.isInteger(stepIndex)) {
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2993
|
+
const captured = capturedModelInput(input["modelInput"]);
|
|
2994
|
+
if (!captured) {
|
|
2995
|
+
return;
|
|
2996
|
+
}
|
|
2997
|
+
const key = llmInputKey(sessionId, turnId, stepIndex);
|
|
2998
|
+
state.update((current) => {
|
|
2999
|
+
const normalized = normalizeEveTraceState(current);
|
|
3000
|
+
const llmInputs = [...normalized.llmInputs, { input: captured, key }];
|
|
3001
|
+
return {
|
|
3002
|
+
...normalized,
|
|
3003
|
+
llmInputs: llmInputs.slice(-MAX_STORED_LLM_INPUTS)
|
|
3004
|
+
};
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
3007
|
+
function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
3008
|
+
try {
|
|
3009
|
+
const key = llmInputKey(sessionId, turnId, stepIndex);
|
|
3010
|
+
let input;
|
|
3011
|
+
state.update((current) => {
|
|
3012
|
+
const normalized = normalizeEveTraceState(current);
|
|
3013
|
+
const index = normalized.llmInputs.findIndex(
|
|
3014
|
+
(candidate) => candidate.key === key
|
|
3015
|
+
);
|
|
3016
|
+
if (index < 0) {
|
|
3017
|
+
return normalized;
|
|
3018
|
+
}
|
|
3019
|
+
input = _optionalChain([normalized, 'access', _107 => _107.llmInputs, 'access', _108 => _108[index], 'optionalAccess', _109 => _109.input]);
|
|
3020
|
+
return {
|
|
3021
|
+
...normalized,
|
|
3022
|
+
llmInputs: normalized.llmInputs.filter(
|
|
3023
|
+
(_, candidateIndex) => candidateIndex !== index
|
|
3024
|
+
)
|
|
3025
|
+
};
|
|
3026
|
+
});
|
|
3027
|
+
return input;
|
|
3028
|
+
} catch (error) {
|
|
3029
|
+
_chunkMWVVR5LRjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
3030
|
+
return void 0;
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
function capturedModelInput(modelInput) {
|
|
3034
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, modelInput)) {
|
|
3035
|
+
return void 0;
|
|
3036
|
+
}
|
|
3037
|
+
const messages = modelInput["messages"];
|
|
3038
|
+
if (!Array.isArray(messages)) {
|
|
3039
|
+
return void 0;
|
|
3040
|
+
}
|
|
3041
|
+
const instructions = modelInput["instructions"];
|
|
3042
|
+
const value = [
|
|
3043
|
+
...instructions !== void 0 ? [{ content: instructions, role: "system" }] : [],
|
|
3044
|
+
...messages
|
|
3045
|
+
];
|
|
3046
|
+
try {
|
|
3047
|
+
const cloned = JSON.parse(JSON.stringify(value));
|
|
3048
|
+
if (!Array.isArray(cloned)) {
|
|
3049
|
+
return void 0;
|
|
3050
|
+
}
|
|
3051
|
+
return cloned;
|
|
3052
|
+
} catch (e4) {
|
|
3053
|
+
return void 0;
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
function isCapturedModelInput(input) {
|
|
3057
|
+
return Array.isArray(input);
|
|
3058
|
+
}
|
|
3059
|
+
function llmInputKey(sessionId, turnId, stepIndex) {
|
|
3060
|
+
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3061
|
+
}
|
|
3062
|
+
function modelMetadataFromRuntime(runtime) {
|
|
3063
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, runtime)) {
|
|
3064
|
+
return {};
|
|
3065
|
+
}
|
|
3066
|
+
const modelId = runtime["modelId"];
|
|
3067
|
+
return typeof modelId === "string" ? modelMetadataFromModelId(modelId) : {};
|
|
3068
|
+
}
|
|
3069
|
+
function modelMetadataFromModelId(modelId) {
|
|
3070
|
+
const normalized = modelId.trim();
|
|
3071
|
+
if (!normalized) {
|
|
3072
|
+
return {};
|
|
3073
|
+
}
|
|
3074
|
+
const slashIndex = normalized.indexOf("/");
|
|
3075
|
+
if (slashIndex > 0 && slashIndex < normalized.length - 1) {
|
|
3076
|
+
return {
|
|
3077
|
+
model: normalized.slice(slashIndex + 1),
|
|
3078
|
+
provider: normalized.slice(0, slashIndex)
|
|
3079
|
+
};
|
|
3080
|
+
}
|
|
3081
|
+
return {
|
|
3082
|
+
model: normalized
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
3085
|
+
function sessionIdFromContext(ctx) {
|
|
3086
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, ctx)) {
|
|
3087
|
+
return void 0;
|
|
3088
|
+
}
|
|
3089
|
+
const session = ctx["session"];
|
|
3090
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, session)) {
|
|
3091
|
+
return void 0;
|
|
3092
|
+
}
|
|
3093
|
+
const id = session["id"];
|
|
3094
|
+
return typeof id === "string" ? id : void 0;
|
|
3095
|
+
}
|
|
3096
|
+
function toolMetadataFromTurn(turn) {
|
|
3097
|
+
const { model: _model, provider: _provider, ...metadata } = turn.metadata;
|
|
3098
|
+
return metadata;
|
|
3099
|
+
}
|
|
3100
|
+
function parentLineageFromContext(ctx) {
|
|
3101
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, ctx)) {
|
|
3102
|
+
return void 0;
|
|
3103
|
+
}
|
|
3104
|
+
const session = ctx.session;
|
|
3105
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, session)) {
|
|
3106
|
+
return void 0;
|
|
3107
|
+
}
|
|
3108
|
+
const parent = session["parent"];
|
|
3109
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, parent)) {
|
|
3110
|
+
return void 0;
|
|
3111
|
+
}
|
|
3112
|
+
const callId = parent["callId"];
|
|
3113
|
+
const rootSessionId = parent["rootSessionId"];
|
|
3114
|
+
const sessionId = parent["sessionId"];
|
|
3115
|
+
if (typeof callId !== "string" || typeof rootSessionId !== "string" || typeof sessionId !== "string") {
|
|
3116
|
+
return void 0;
|
|
3117
|
+
}
|
|
3118
|
+
return { callId, rootSessionId, sessionId };
|
|
3119
|
+
}
|
|
3120
|
+
function isToolCallAction(action) {
|
|
3121
|
+
return _chunkMWVVR5LRjs.isObject.call(void 0, action) && action["kind"] === "tool-call" && typeof action["callId"] === "string" && typeof action["toolName"] === "string" && _chunkMWVVR5LRjs.isObject.call(void 0, action["input"]);
|
|
3122
|
+
}
|
|
3123
|
+
function isLocalSubagentCallAction(action) {
|
|
3124
|
+
return _chunkMWVVR5LRjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkMWVVR5LRjs.isObject.call(void 0, action["input"]);
|
|
3125
|
+
}
|
|
3126
|
+
function isTraceableActionRequest(action) {
|
|
3127
|
+
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3128
|
+
}
|
|
3129
|
+
function isToolResult(result) {
|
|
3130
|
+
return _chunkMWVVR5LRjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3131
|
+
}
|
|
3132
|
+
function isSubagentResult(result) {
|
|
3133
|
+
return _chunkMWVVR5LRjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3134
|
+
}
|
|
3135
|
+
function normalizedFinishReason(finishReason) {
|
|
3136
|
+
switch (finishReason) {
|
|
3137
|
+
case "content-filter":
|
|
3138
|
+
return "content_filter";
|
|
3139
|
+
case "tool-calls":
|
|
3140
|
+
return "tool_calls";
|
|
3141
|
+
default:
|
|
3142
|
+
return finishReason;
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
function errorFromMessage(message, code, details) {
|
|
3146
|
+
const error = new Error(`${code}: ${message}`);
|
|
3147
|
+
if (details !== void 0) {
|
|
3148
|
+
error.cause = details;
|
|
3149
|
+
}
|
|
3150
|
+
return error;
|
|
3151
|
+
}
|
|
3152
|
+
function actionResultError(error, output) {
|
|
3153
|
+
if (error) {
|
|
3154
|
+
return errorFromMessage(error.message, error.code);
|
|
3155
|
+
}
|
|
3156
|
+
const result = new Error("Eve action failed");
|
|
3157
|
+
if (output !== void 0) {
|
|
3158
|
+
result.cause = output;
|
|
3159
|
+
}
|
|
3160
|
+
return result;
|
|
3161
|
+
}
|
|
3162
|
+
function eventTime(event) {
|
|
3163
|
+
if (!_optionalChain([event, 'access', _110 => _110.meta, 'optionalAccess', _111 => _111.at])) {
|
|
3164
|
+
return void 0;
|
|
3165
|
+
}
|
|
3166
|
+
const timestamp = Date.parse(event.meta.at);
|
|
3167
|
+
return Number.isFinite(timestamp) ? timestamp / 1e3 : void 0;
|
|
3168
|
+
}
|
|
3169
|
+
function turnKey(sessionId, turnId) {
|
|
3170
|
+
return `${sessionId}:${turnId}`;
|
|
3171
|
+
}
|
|
3172
|
+
function toolKey(sessionId, callId) {
|
|
3173
|
+
return `${sessionId}:${callId}`;
|
|
3174
|
+
}
|
|
3175
|
+
async function rootSpanIdForSession(sessionId) {
|
|
3176
|
+
return deterministicEveId("eve:root", sessionId);
|
|
3177
|
+
}
|
|
3178
|
+
async function generateEveIds(kind, ...parts) {
|
|
3179
|
+
const [rowId, spanId] = await Promise.all([
|
|
3180
|
+
deterministicEveId(`eve:row:${kind}`, ...parts),
|
|
3181
|
+
deterministicEveId(`eve:${kind}`, ...parts)
|
|
3182
|
+
]);
|
|
3183
|
+
return { rowId, spanId };
|
|
3184
|
+
}
|
|
3185
|
+
async function spanIdForSubagent(sessionId, callId) {
|
|
3186
|
+
return deterministicEveId("eve:subagent", sessionId, callId);
|
|
3187
|
+
}
|
|
3188
|
+
async function deterministicEveId(...parts) {
|
|
3189
|
+
const data = new TextEncoder().encode(
|
|
3190
|
+
parts.map((part) => `${part.length}:${part}`).join("\0")
|
|
3191
|
+
);
|
|
3192
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", data);
|
|
3193
|
+
const bytes = Array.from(new Uint8Array(digest, 0, 16));
|
|
3194
|
+
const hex = bytes.map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3195
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
3196
|
+
}
|
|
3197
|
+
|
|
1731
3198
|
// src/typed-instrumentation-helpers.ts
|
|
1732
3199
|
var TypedApplyProxy = Proxy;
|
|
1733
3200
|
|
|
@@ -1845,7 +3312,7 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
1845
3312
|
...params,
|
|
1846
3313
|
options: {
|
|
1847
3314
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
1848
|
-
[
|
|
3315
|
+
[_chunkMWVVR5LRjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
1849
3316
|
}
|
|
1850
3317
|
};
|
|
1851
3318
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
@@ -1877,7 +3344,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
1877
3344
|
}
|
|
1878
3345
|
const localToolMetadata = { toolName };
|
|
1879
3346
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
1880
|
-
wrappedArgs[handlerIndex] =
|
|
3347
|
+
wrappedArgs[handlerIndex] = _chunkMWVVR5LRjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
1881
3348
|
originalHandler,
|
|
1882
3349
|
() => localToolMetadata
|
|
1883
3350
|
);
|
|
@@ -1895,8 +3362,8 @@ function wrapCreateSdkMcpServer(createSdkMcpServerFn, localToolMetadataByTool, d
|
|
|
1895
3362
|
apply(target, thisArg, argArray) {
|
|
1896
3363
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
1897
3364
|
const config = argArray[0];
|
|
1898
|
-
const serverName = _optionalChain([config, 'optionalAccess',
|
|
1899
|
-
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess',
|
|
3365
|
+
const serverName = _optionalChain([config, 'optionalAccess', _112 => _112.name]);
|
|
3366
|
+
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess', _113 => _113.tools]))) {
|
|
1900
3367
|
for (const tool of config.tools) {
|
|
1901
3368
|
if (!tool || typeof tool !== "object") {
|
|
1902
3369
|
continue;
|
|
@@ -1990,7 +3457,7 @@ function isModuleNamespace2(obj) {
|
|
|
1990
3457
|
if (!obj || typeof obj !== "object") {
|
|
1991
3458
|
return false;
|
|
1992
3459
|
}
|
|
1993
|
-
if (_optionalChain([obj, 'access',
|
|
3460
|
+
if (_optionalChain([obj, 'access', _114 => _114.constructor, 'optionalAccess', _115 => _115.name]) === "Module") {
|
|
1994
3461
|
return true;
|
|
1995
3462
|
}
|
|
1996
3463
|
const keys = Object.keys(obj);
|
|
@@ -2120,7 +3587,7 @@ function isModuleNamespace3(obj) {
|
|
|
2120
3587
|
if (!obj || typeof obj !== "object") {
|
|
2121
3588
|
return false;
|
|
2122
3589
|
}
|
|
2123
|
-
if (_optionalChain([obj, 'access',
|
|
3590
|
+
if (_optionalChain([obj, 'access', _116 => _116.constructor, 'optionalAccess', _117 => _117.name]) === "Module") {
|
|
2124
3591
|
return true;
|
|
2125
3592
|
}
|
|
2126
3593
|
const keys = Object.keys(obj);
|
|
@@ -2304,7 +3771,7 @@ function isModuleNamespace4(obj) {
|
|
|
2304
3771
|
if (!obj || typeof obj !== "object") {
|
|
2305
3772
|
return false;
|
|
2306
3773
|
}
|
|
2307
|
-
if (_optionalChain([obj, 'access',
|
|
3774
|
+
if (_optionalChain([obj, 'access', _118 => _118.constructor, 'optionalAccess', _119 => _119.name]) === "Module") {
|
|
2308
3775
|
return true;
|
|
2309
3776
|
}
|
|
2310
3777
|
const keys = Object.keys(obj);
|
|
@@ -2477,7 +3944,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2477
3944
|
}
|
|
2478
3945
|
if (prop === "interactions") {
|
|
2479
3946
|
const interactions = Reflect.get(target, prop, receiver);
|
|
2480
|
-
if (!
|
|
3947
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
2481
3948
|
return interactions;
|
|
2482
3949
|
}
|
|
2483
3950
|
if (interactions !== originalInteractions) {
|
|
@@ -2491,7 +3958,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2491
3958
|
});
|
|
2492
3959
|
}
|
|
2493
3960
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
2494
|
-
if (!
|
|
3961
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
2495
3962
|
return;
|
|
2496
3963
|
}
|
|
2497
3964
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -2779,7 +4246,7 @@ function patchGenkitRegistryLookup(registry) {
|
|
|
2779
4246
|
Object.defineProperty(registry, PATCHED_GENKIT_REGISTRY, {
|
|
2780
4247
|
value: true
|
|
2781
4248
|
});
|
|
2782
|
-
} catch (
|
|
4249
|
+
} catch (e5) {
|
|
2783
4250
|
}
|
|
2784
4251
|
}
|
|
2785
4252
|
function patchGenkitRegistryConstructor(registry) {
|
|
@@ -2810,7 +4277,7 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
2810
4277
|
Object.defineProperty(constructor, PATCHED_GENKIT_REGISTRY_CONSTRUCTOR, {
|
|
2811
4278
|
value: true
|
|
2812
4279
|
});
|
|
2813
|
-
} catch (
|
|
4280
|
+
} catch (e6) {
|
|
2814
4281
|
}
|
|
2815
4282
|
}
|
|
2816
4283
|
function wrapGenerate(generate) {
|
|
@@ -2925,10 +4392,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
2925
4392
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
2926
4393
|
}
|
|
2927
4394
|
function hasFunction2(value, methodName) {
|
|
2928
|
-
return
|
|
4395
|
+
return _chunkMWVVR5LRjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
2929
4396
|
}
|
|
2930
4397
|
function isSupportedHuggingFaceModule(value) {
|
|
2931
|
-
if (!
|
|
4398
|
+
if (!_chunkMWVVR5LRjs.isObject.call(void 0, value)) {
|
|
2932
4399
|
return false;
|
|
2933
4400
|
}
|
|
2934
4401
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -3536,7 +5003,7 @@ function isSupportedGroqClient(value) {
|
|
|
3536
5003
|
}
|
|
3537
5004
|
function groqProxy(groq) {
|
|
3538
5005
|
const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
|
|
3539
|
-
const completionProxy = _optionalChain([groq, 'access',
|
|
5006
|
+
const completionProxy = _optionalChain([groq, 'access', _120 => _120.chat, 'optionalAccess', _121 => _121.completions]) ? new Proxy(groq.chat.completions, {
|
|
3540
5007
|
get(target, prop, receiver) {
|
|
3541
5008
|
if (prop === "create") {
|
|
3542
5009
|
return wrapChatCompletionsCreate(target.create.bind(target));
|
|
@@ -3668,16 +5135,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
3668
5135
|
}
|
|
3669
5136
|
function wrapSend(send) {
|
|
3670
5137
|
return (command, optionsOrCb, cb) => {
|
|
3671
|
-
if (
|
|
5138
|
+
if (_chunkMWVVR5LRjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
3672
5139
|
return send(command, optionsOrCb, cb);
|
|
3673
5140
|
}
|
|
3674
5141
|
return _chunkBFGIH2ZJjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
3675
|
-
() =>
|
|
5142
|
+
() => _chunkMWVVR5LRjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
3676
5143
|
() => send(command, optionsOrCb)
|
|
3677
5144
|
),
|
|
3678
5145
|
{
|
|
3679
5146
|
arguments: [command, optionsOrCb],
|
|
3680
|
-
span_info:
|
|
5147
|
+
span_info: _chunkMWVVR5LRjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
3681
5148
|
}
|
|
3682
5149
|
);
|
|
3683
5150
|
};
|
|
@@ -3779,15 +5246,15 @@ function getVitestContextManager() {
|
|
|
3779
5246
|
}
|
|
3780
5247
|
|
|
3781
5248
|
// src/wrappers/vitest/flush-manager.ts
|
|
3782
|
-
var FlushCoordinator = (
|
|
3783
|
-
|
|
5249
|
+
var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__init6.call(this); }
|
|
5250
|
+
__init6() {this.activeFlushes = /* @__PURE__ */ new Map()}
|
|
3784
5251
|
async coordinateFlush(context, config) {
|
|
3785
5252
|
if (!context) return;
|
|
3786
5253
|
const experimentId = await context.experiment.id;
|
|
3787
5254
|
if (this.activeFlushes.has(experimentId)) {
|
|
3788
5255
|
return this.activeFlushes.get(experimentId);
|
|
3789
5256
|
}
|
|
3790
|
-
const flushPromise =
|
|
5257
|
+
const flushPromise = _chunkMWVVR5LRjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
3791
5258
|
displaySummary: config.displaySummary
|
|
3792
5259
|
});
|
|
3793
5260
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -3797,7 +5264,7 @@ var FlushCoordinator = (_class = class {constructor() { _class.prototype.__init.
|
|
|
3797
5264
|
this.activeFlushes.delete(experimentId);
|
|
3798
5265
|
}
|
|
3799
5266
|
}
|
|
3800
|
-
},
|
|
5267
|
+
}, _class2);
|
|
3801
5268
|
var flushCoordinator = new FlushCoordinator();
|
|
3802
5269
|
async function flushExperimentWithSync(context, config) {
|
|
3803
5270
|
return flushCoordinator.coordinateFlush(context, config);
|
|
@@ -3885,7 +5352,7 @@ async function runTracedEval(args) {
|
|
|
3885
5352
|
}
|
|
3886
5353
|
if (testError) {
|
|
3887
5354
|
span.log({ scores: { pass: 0 } });
|
|
3888
|
-
|
|
5355
|
+
_chunkMWVVR5LRjs.logError.call(void 0, span, testError);
|
|
3889
5356
|
throw testError;
|
|
3890
5357
|
}
|
|
3891
5358
|
span.log({
|
|
@@ -3918,7 +5385,7 @@ function wrapTest(originalTest, config) {
|
|
|
3918
5385
|
const wrapped = function(name, configOrFn, maybeFn) {
|
|
3919
5386
|
const isEnhanced = typeof configOrFn !== "function";
|
|
3920
5387
|
const testConfig = isEnhanced ? configOrFn : void 0;
|
|
3921
|
-
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess',
|
|
5388
|
+
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _122 => _122.data]) && Array.isArray(testConfig.data)) {
|
|
3922
5389
|
const dataRecords = testConfig.data;
|
|
3923
5390
|
const testFn2 = maybeFn;
|
|
3924
5391
|
if (!testFn2) {
|
|
@@ -3956,7 +5423,7 @@ function wrapTest(originalTest, config) {
|
|
|
3956
5423
|
const registrationContext = getExperimentContext();
|
|
3957
5424
|
const testImplementation = async (vitestContext) => {
|
|
3958
5425
|
const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
|
|
3959
|
-
const experiment = _optionalChain([experimentContext, 'optionalAccess',
|
|
5426
|
+
const experiment = _optionalChain([experimentContext, 'optionalAccess', _123 => _123.experiment]);
|
|
3960
5427
|
if (config.onProgress) {
|
|
3961
5428
|
config.onProgress({ type: "test_start", testName: name });
|
|
3962
5429
|
}
|
|
@@ -3988,11 +5455,11 @@ function wrapTest(originalTest, config) {
|
|
|
3988
5455
|
const result = await runTracedEval({
|
|
3989
5456
|
experiment,
|
|
3990
5457
|
spanName: name,
|
|
3991
|
-
input: _optionalChain([testConfig, 'optionalAccess',
|
|
3992
|
-
expected: _optionalChain([testConfig, 'optionalAccess',
|
|
3993
|
-
metadata: _optionalChain([testConfig, 'optionalAccess',
|
|
3994
|
-
tags: _optionalChain([testConfig, 'optionalAccess',
|
|
3995
|
-
scorers: _optionalChain([testConfig, 'optionalAccess',
|
|
5458
|
+
input: _optionalChain([testConfig, 'optionalAccess', _124 => _124.input]),
|
|
5459
|
+
expected: _optionalChain([testConfig, 'optionalAccess', _125 => _125.expected]),
|
|
5460
|
+
metadata: _optionalChain([testConfig, 'optionalAccess', _126 => _126.metadata]),
|
|
5461
|
+
tags: _optionalChain([testConfig, 'optionalAccess', _127 => _127.tags]),
|
|
5462
|
+
scorers: _optionalChain([testConfig, 'optionalAccess', _128 => _128.scorers]),
|
|
3996
5463
|
fn: async () => {
|
|
3997
5464
|
if (testConfig && maybeFn) {
|
|
3998
5465
|
const params = {
|
|
@@ -4059,10 +5526,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
4059
5526
|
const getOrCreateContext = () => {
|
|
4060
5527
|
if (!context) {
|
|
4061
5528
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4062
|
-
const experiment = config.projectId ?
|
|
5529
|
+
const experiment = config.projectId ? _chunkMWVVR5LRjs.initExperiment.call(void 0, {
|
|
4063
5530
|
projectId: config.projectId,
|
|
4064
5531
|
experiment: experimentName
|
|
4065
|
-
}) :
|
|
5532
|
+
}) : _chunkMWVVR5LRjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
4066
5533
|
experiment: experimentName
|
|
4067
5534
|
});
|
|
4068
5535
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -4107,8 +5574,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
4107
5574
|
config.onProgress({
|
|
4108
5575
|
type: "suite_complete",
|
|
4109
5576
|
suiteName,
|
|
4110
|
-
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
4111
|
-
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
5577
|
+
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _129 => _129.passed]), () => ( 0)),
|
|
5578
|
+
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _130 => _130.failed]), () => ( 0))
|
|
4112
5579
|
});
|
|
4113
5580
|
}
|
|
4114
5581
|
});
|
|
@@ -4170,7 +5637,7 @@ function wrapExpect(originalExpect) {
|
|
|
4170
5637
|
return originalExpect(value);
|
|
4171
5638
|
}
|
|
4172
5639
|
const assertion = originalExpect(value, message);
|
|
4173
|
-
const span =
|
|
5640
|
+
const span = _chunkMWVVR5LRjs.currentSpan.call(void 0, );
|
|
4174
5641
|
if (!span) {
|
|
4175
5642
|
return assertion;
|
|
4176
5643
|
}
|
|
@@ -4182,16 +5649,16 @@ function wrapExpect(originalExpect) {
|
|
|
4182
5649
|
|
|
4183
5650
|
// src/wrappers/shared/logging.ts
|
|
4184
5651
|
function logOutputs(outputs) {
|
|
4185
|
-
|
|
5652
|
+
_chunkMWVVR5LRjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
4186
5653
|
}
|
|
4187
5654
|
function logFeedback(feedback) {
|
|
4188
|
-
|
|
5655
|
+
_chunkMWVVR5LRjs.currentSpan.call(void 0, ).log({
|
|
4189
5656
|
scores: { [feedback.name]: feedback.score },
|
|
4190
5657
|
metadata: feedback.metadata
|
|
4191
5658
|
});
|
|
4192
5659
|
}
|
|
4193
5660
|
function getCurrentSpan() {
|
|
4194
|
-
return
|
|
5661
|
+
return _chunkMWVVR5LRjs.currentSpan.call(void 0, );
|
|
4195
5662
|
}
|
|
4196
5663
|
|
|
4197
5664
|
// src/wrappers/vitest/index.ts
|
|
@@ -4239,8 +5706,8 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
4239
5706
|
);
|
|
4240
5707
|
return;
|
|
4241
5708
|
}
|
|
4242
|
-
await
|
|
4243
|
-
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5709
|
+
await _chunkMWVVR5LRjs.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
5710
|
+
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _131 => _131.displaySummary]), () => ( config.displaySummary))
|
|
4244
5711
|
});
|
|
4245
5712
|
}
|
|
4246
5713
|
};
|
|
@@ -4254,7 +5721,7 @@ function initNodeTestSuite(config) {
|
|
|
4254
5721
|
return experiment;
|
|
4255
5722
|
}
|
|
4256
5723
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4257
|
-
experiment =
|
|
5724
|
+
experiment = _chunkMWVVR5LRjs.initExperiment.call(void 0, config.projectName, {
|
|
4258
5725
|
experiment: experimentName
|
|
4259
5726
|
});
|
|
4260
5727
|
return experiment;
|
|
@@ -4303,7 +5770,7 @@ function initNodeTestSuite(config) {
|
|
|
4303
5770
|
if (!experiment) {
|
|
4304
5771
|
return;
|
|
4305
5772
|
}
|
|
4306
|
-
await
|
|
5773
|
+
await _chunkMWVVR5LRjs.summarizeAndFlush.call(void 0, experiment, {
|
|
4307
5774
|
displaySummary: config.displaySummary
|
|
4308
5775
|
});
|
|
4309
5776
|
experiment = void 0;
|
|
@@ -4334,15 +5801,15 @@ _chunkBFGIH2ZJjs.__export.call(void 0, graph_framework_exports, {
|
|
|
4334
5801
|
escapePath: () => escapePath,
|
|
4335
5802
|
unescapePath: () => unescapePath
|
|
4336
5803
|
});
|
|
4337
|
-
var GraphBuilder = (
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
5804
|
+
var GraphBuilder = (_class3 = class {
|
|
5805
|
+
__init7() {this.nodes = /* @__PURE__ */ new Map()}
|
|
5806
|
+
__init8() {this.edges = {}}
|
|
5807
|
+
__init9() {this.nodeLikeNodes = /* @__PURE__ */ new Map()}
|
|
4341
5808
|
// Maps node-like objects, like prompts, to their nodes
|
|
4342
5809
|
// Special nodes
|
|
4343
5810
|
|
|
4344
5811
|
|
|
4345
|
-
constructor() {;
|
|
5812
|
+
constructor() {;_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);
|
|
4346
5813
|
this.IN = this.createInputNode();
|
|
4347
5814
|
this.OUT = this.createOutputNode();
|
|
4348
5815
|
}
|
|
@@ -4394,7 +5861,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4394
5861
|
};
|
|
4395
5862
|
}
|
|
4396
5863
|
resolveNode(node) {
|
|
4397
|
-
if (node instanceof
|
|
5864
|
+
if (node instanceof _chunkMWVVR5LRjs.Prompt) {
|
|
4398
5865
|
const cached = this.nodeLikeNodes.get(node);
|
|
4399
5866
|
if (cached) {
|
|
4400
5867
|
return [cached, []];
|
|
@@ -4444,7 +5911,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4444
5911
|
// }
|
|
4445
5912
|
// Helper to generate node IDs
|
|
4446
5913
|
generateId(name) {
|
|
4447
|
-
const uuid =
|
|
5914
|
+
const uuid = _chunkMWVVR5LRjs.newId.call(void 0, );
|
|
4448
5915
|
if (name) {
|
|
4449
5916
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
4450
5917
|
} else {
|
|
@@ -4472,7 +5939,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4472
5939
|
this.nodes.set(id, promptNode);
|
|
4473
5940
|
return promptNode;
|
|
4474
5941
|
}
|
|
4475
|
-
},
|
|
5942
|
+
}, _class3);
|
|
4476
5943
|
function isProxyVariable(node) {
|
|
4477
5944
|
return typeof node === "object" && node !== null && "__type" in node && // @ts-ignore
|
|
4478
5945
|
node.__type === "proxy-variable";
|
|
@@ -4480,17 +5947,17 @@ function isProxyVariable(node) {
|
|
|
4480
5947
|
function proxyVariableToNode(proxy) {
|
|
4481
5948
|
return [proxy.__node, proxy.__path];
|
|
4482
5949
|
}
|
|
4483
|
-
var BaseNode = (
|
|
4484
|
-
constructor(graph, id) {;
|
|
5950
|
+
var BaseNode = (_class4 = class {
|
|
5951
|
+
constructor(graph, id) {;_class4.prototype.__init10.call(this);_class4.prototype.__init11.call(this);
|
|
4485
5952
|
this.graph = graph;
|
|
4486
5953
|
this.id = id;
|
|
4487
5954
|
}
|
|
4488
|
-
|
|
4489
|
-
|
|
5955
|
+
__init10() {this.__type = "node"}
|
|
5956
|
+
__init11() {this.dependencies = []}
|
|
4490
5957
|
addDependency(dependency) {
|
|
4491
5958
|
this.dependencies.push(dependency);
|
|
4492
5959
|
}
|
|
4493
|
-
},
|
|
5960
|
+
}, _class4);
|
|
4494
5961
|
var InputNode = class extends BaseNode {
|
|
4495
5962
|
constructor(graph, id) {
|
|
4496
5963
|
super(graph, id);
|
|
@@ -5638,7 +7105,7 @@ function waterfall(tasks, callback) {
|
|
|
5638
7105
|
var waterfall$1 = awaitify(waterfall);
|
|
5639
7106
|
|
|
5640
7107
|
// src/trace.ts
|
|
5641
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
7108
|
+
var SpanFetcher = class _SpanFetcher extends _chunkMWVVR5LRjs.ObjectFetcher {
|
|
5642
7109
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
5643
7110
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
5644
7111
|
rootSpanId,
|
|
@@ -5703,11 +7170,11 @@ var SpanFetcher = class _SpanFetcher extends _chunkFY7DAKA5js.ObjectFetcher {
|
|
|
5703
7170
|
return this._state;
|
|
5704
7171
|
}
|
|
5705
7172
|
};
|
|
5706
|
-
var CachedSpanFetcher = (
|
|
5707
|
-
|
|
5708
|
-
|
|
7173
|
+
var CachedSpanFetcher = (_class5 = class {
|
|
7174
|
+
__init12() {this.spanCache = /* @__PURE__ */ new Map()}
|
|
7175
|
+
__init13() {this.allFetched = false}
|
|
5709
7176
|
|
|
5710
|
-
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;
|
|
7177
|
+
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);
|
|
5711
7178
|
if (typeof objectTypeOrFetchFn === "function") {
|
|
5712
7179
|
this.fetchFn = (spanType) => objectTypeOrFetchFn(spanType);
|
|
5713
7180
|
} else {
|
|
@@ -5771,7 +7238,7 @@ var CachedSpanFetcher = (_class4 = class {
|
|
|
5771
7238
|
async fetchSpans(spanType) {
|
|
5772
7239
|
const spans = await this.fetchFn(spanType, false);
|
|
5773
7240
|
for (const span of spans) {
|
|
5774
|
-
const type = _nullishCoalesce(_optionalChain([span, 'access',
|
|
7241
|
+
const type = _nullishCoalesce(_optionalChain([span, 'access', _132 => _132.span_attributes, 'optionalAccess', _133 => _133.type]), () => ( ""));
|
|
5775
7242
|
const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
|
|
5776
7243
|
existing.push(span);
|
|
5777
7244
|
this.spanCache.set(type, existing);
|
|
@@ -5788,24 +7255,24 @@ var CachedSpanFetcher = (_class4 = class {
|
|
|
5788
7255
|
}
|
|
5789
7256
|
return result;
|
|
5790
7257
|
}
|
|
5791
|
-
},
|
|
5792
|
-
var LocalTrace = (
|
|
7258
|
+
}, _class5);
|
|
7259
|
+
var LocalTrace = (_class6 = class {
|
|
5793
7260
|
|
|
5794
7261
|
|
|
5795
7262
|
|
|
5796
7263
|
|
|
5797
7264
|
|
|
5798
|
-
|
|
5799
|
-
|
|
7265
|
+
__init14() {this.spansFlushed = false}
|
|
7266
|
+
__init15() {this.spansFlushPromise = null}
|
|
5800
7267
|
|
|
5801
|
-
|
|
7268
|
+
__init16() {this.threadCache = /* @__PURE__ */ new Map()}
|
|
5802
7269
|
constructor({
|
|
5803
7270
|
objectType,
|
|
5804
7271
|
objectId,
|
|
5805
7272
|
rootSpanId,
|
|
5806
7273
|
ensureSpansFlushed,
|
|
5807
7274
|
state
|
|
5808
|
-
}) {;
|
|
7275
|
+
}) {;_class6.prototype.__init14.call(this);_class6.prototype.__init15.call(this);_class6.prototype.__init16.call(this);
|
|
5809
7276
|
this.objectType = objectType;
|
|
5810
7277
|
this.objectId = objectId;
|
|
5811
7278
|
this.rootSpanId = rootSpanId;
|
|
@@ -5854,11 +7321,11 @@ var LocalTrace = (_class5 = class {
|
|
|
5854
7321
|
const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
|
|
5855
7322
|
if (cachedSpans && cachedSpans.length > 0) {
|
|
5856
7323
|
let spans = includeScorers ? cachedSpans : cachedSpans.filter(
|
|
5857
|
-
(span) => _optionalChain([span, 'access',
|
|
7324
|
+
(span) => _optionalChain([span, 'access', _134 => _134.span_attributes, 'optionalAccess', _135 => _135.purpose]) !== "scorer"
|
|
5858
7325
|
);
|
|
5859
7326
|
if (spanType && spanType.length > 0) {
|
|
5860
7327
|
spans = spans.filter(
|
|
5861
|
-
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access',
|
|
7328
|
+
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _136 => _136.span_attributes, 'optionalAccess', _137 => _137.type]), () => ( "")))
|
|
5862
7329
|
);
|
|
5863
7330
|
}
|
|
5864
7331
|
return spans.map((span) => ({
|
|
@@ -5883,7 +7350,7 @@ var LocalTrace = (_class5 = class {
|
|
|
5883
7350
|
* Calls the API with the project_default preprocessor (which falls back to "thread").
|
|
5884
7351
|
*/
|
|
5885
7352
|
async getThread(options) {
|
|
5886
|
-
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7353
|
+
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _138 => _138.preprocessor]), () => ( "project_default"));
|
|
5887
7354
|
if (!this.threadCache.has(cacheKey)) {
|
|
5888
7355
|
const promise = this.fetchThread(options);
|
|
5889
7356
|
this.threadCache.set(cacheKey, promise);
|
|
@@ -5894,7 +7361,7 @@ var LocalTrace = (_class5 = class {
|
|
|
5894
7361
|
await this.ensureSpansReady();
|
|
5895
7362
|
await this.state.login({});
|
|
5896
7363
|
const result = await invoke({
|
|
5897
|
-
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7364
|
+
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _139 => _139.preprocessor]), () => ( "project_default")),
|
|
5898
7365
|
functionType: "preprocessor",
|
|
5899
7366
|
input: {
|
|
5900
7367
|
trace_ref: {
|
|
@@ -5925,7 +7392,7 @@ var LocalTrace = (_class5 = class {
|
|
|
5925
7392
|
}
|
|
5926
7393
|
await this.spansFlushPromise;
|
|
5927
7394
|
}
|
|
5928
|
-
},
|
|
7395
|
+
}, _class6);
|
|
5929
7396
|
|
|
5930
7397
|
// src/reporters/progress.ts
|
|
5931
7398
|
var SimpleProgressReporter = class {
|
|
@@ -5951,20 +7418,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
5951
7418
|
prompt: _v3.z.string()
|
|
5952
7419
|
}),
|
|
5953
7420
|
_v3.z.object({
|
|
5954
|
-
messages: _v3.z.array(
|
|
7421
|
+
messages: _v3.z.array(_chunkMWVVR5LRjs.ChatCompletionMessageParam)
|
|
5955
7422
|
})
|
|
5956
7423
|
]);
|
|
5957
7424
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
5958
7425
|
_v3.z.object({
|
|
5959
7426
|
model: _v3.z.string(),
|
|
5960
|
-
params:
|
|
7427
|
+
params: _chunkMWVVR5LRjs.ModelParams.optional(),
|
|
5961
7428
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
5962
7429
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
5963
7430
|
})
|
|
5964
7431
|
);
|
|
5965
7432
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
5966
7433
|
_v3.z.object({
|
|
5967
|
-
tools: _v3.z.array(
|
|
7434
|
+
tools: _v3.z.array(_chunkMWVVR5LRjs.ToolFunctionDefinition).optional()
|
|
5968
7435
|
})
|
|
5969
7436
|
);
|
|
5970
7437
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -6012,7 +7479,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
6012
7479
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
6013
7480
|
return parameters;
|
|
6014
7481
|
}
|
|
6015
|
-
if (
|
|
7482
|
+
if (_chunkMWVVR5LRjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
6016
7483
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
6017
7484
|
...resolvedSchema.data,
|
|
6018
7485
|
...parameters
|
|
@@ -6034,14 +7501,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
6034
7501
|
const value = parameters[name];
|
|
6035
7502
|
try {
|
|
6036
7503
|
if ("type" in schema && schema.type === "prompt") {
|
|
6037
|
-
const promptData = value ?
|
|
7504
|
+
const promptData = value ? _chunkMWVVR5LRjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
6038
7505
|
schema.default,
|
|
6039
7506
|
schema.default.tools
|
|
6040
7507
|
) : void 0;
|
|
6041
7508
|
if (!promptData) {
|
|
6042
7509
|
throw new Error(`Parameter '${name}' is required`);
|
|
6043
7510
|
}
|
|
6044
|
-
return [name,
|
|
7511
|
+
return [name, _chunkMWVVR5LRjs.Prompt.fromPromptData(name, promptData)];
|
|
6045
7512
|
} else if ("type" in schema && schema.type === "model") {
|
|
6046
7513
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
6047
7514
|
if (model === void 0) {
|
|
@@ -6070,10 +7537,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
|
|
|
6070
7537
|
const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
|
|
6071
7538
|
const validate = ajv.compile(schema);
|
|
6072
7539
|
if (!validate(parameters)) {
|
|
6073
|
-
const errorMessages = _optionalChain([validate, 'access',
|
|
7540
|
+
const errorMessages = _optionalChain([validate, 'access', _140 => _140.errors, 'optionalAccess', _141 => _141.map, 'call', _142 => _142((err) => {
|
|
6074
7541
|
const path = err.instancePath || "root";
|
|
6075
7542
|
return `${path}: ${err.message}`;
|
|
6076
|
-
}), 'access',
|
|
7543
|
+
}), 'access', _143 => _143.join, 'call', _144 => _144(", ")]);
|
|
6077
7544
|
throw Error(`Invalid parameters: ${errorMessages}`);
|
|
6078
7545
|
}
|
|
6079
7546
|
return rehydrateRemoteParameters(parameters, schema);
|
|
@@ -6092,7 +7559,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
6092
7559
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
6093
7560
|
return [
|
|
6094
7561
|
name,
|
|
6095
|
-
|
|
7562
|
+
_chunkMWVVR5LRjs.Prompt.fromPromptData(name, _chunkMWVVR5LRjs.PromptData.parse(value))
|
|
6096
7563
|
];
|
|
6097
7564
|
}
|
|
6098
7565
|
return [name, value];
|
|
@@ -6128,7 +7595,7 @@ var EvalResultWithSummary = class {
|
|
|
6128
7595
|
async function getPersistedBaseExperimentId(experiment) {
|
|
6129
7596
|
try {
|
|
6130
7597
|
return await experiment._getBaseExperimentId();
|
|
6131
|
-
} catch (
|
|
7598
|
+
} catch (e7) {
|
|
6132
7599
|
return void 0;
|
|
6133
7600
|
}
|
|
6134
7601
|
}
|
|
@@ -6140,7 +7607,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
6140
7607
|
return out;
|
|
6141
7608
|
}
|
|
6142
7609
|
function initExperiment2(state, options = {}) {
|
|
6143
|
-
return
|
|
7610
|
+
return _chunkMWVVR5LRjs.init.call(void 0, {
|
|
6144
7611
|
state,
|
|
6145
7612
|
...options,
|
|
6146
7613
|
setCurrent: false
|
|
@@ -6151,7 +7618,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
6151
7618
|
return void 0;
|
|
6152
7619
|
}
|
|
6153
7620
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
6154
|
-
if (!
|
|
7621
|
+
if (!_chunkMWVVR5LRjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
6155
7622
|
return void 0;
|
|
6156
7623
|
}
|
|
6157
7624
|
if (resolvedParameters.id === void 0) {
|
|
@@ -6187,10 +7654,10 @@ globalThis._evals = {
|
|
|
6187
7654
|
reporters: {}
|
|
6188
7655
|
};
|
|
6189
7656
|
function _initializeSpanContext() {
|
|
6190
|
-
globalThis._spanContext = { currentSpan:
|
|
7657
|
+
globalThis._spanContext = { currentSpan: _chunkMWVVR5LRjs.currentSpan, withCurrent: _chunkMWVVR5LRjs.withCurrent, startSpan: _chunkMWVVR5LRjs.startSpan, NOOP_SPAN: _chunkMWVVR5LRjs.NOOP_SPAN };
|
|
6191
7658
|
}
|
|
6192
7659
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
6193
|
-
const options =
|
|
7660
|
+
const options = _chunkMWVVR5LRjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
6194
7661
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
6195
7662
|
if (globalThis._evals.evaluators[evalName]) {
|
|
6196
7663
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -6241,7 +7708,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6241
7708
|
baseExperimentId: evaluator.baseExperimentId,
|
|
6242
7709
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
6243
7710
|
repoInfo: evaluator.repoInfo,
|
|
6244
|
-
dataset:
|
|
7711
|
+
dataset: _chunkMWVVR5LRjs.Dataset.isDataset(data) ? data : void 0,
|
|
6245
7712
|
parameters
|
|
6246
7713
|
});
|
|
6247
7714
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
@@ -6261,7 +7728,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6261
7728
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
6262
7729
|
let ret;
|
|
6263
7730
|
if (options.parent) {
|
|
6264
|
-
ret = await
|
|
7731
|
+
ret = await _chunkMWVVR5LRjs.withParent.call(void 0,
|
|
6265
7732
|
options.parent,
|
|
6266
7733
|
() => runEvaluator(
|
|
6267
7734
|
null,
|
|
@@ -6297,7 +7764,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6297
7764
|
if (experiment) {
|
|
6298
7765
|
await experiment.flush().catch(console.error);
|
|
6299
7766
|
} else if (options.parent) {
|
|
6300
|
-
await
|
|
7767
|
+
await _chunkMWVVR5LRjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
6301
7768
|
}
|
|
6302
7769
|
}
|
|
6303
7770
|
} finally {
|
|
@@ -6343,13 +7810,13 @@ function classifierName(classifier, classifier_idx) {
|
|
|
6343
7810
|
}
|
|
6344
7811
|
function buildSpanMetadata(results) {
|
|
6345
7812
|
return results.length === 1 ? results[0].metadata : results.reduce(
|
|
6346
|
-
(prev, s) =>
|
|
7813
|
+
(prev, s) => _chunkMWVVR5LRjs.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
|
|
6347
7814
|
{}
|
|
6348
7815
|
);
|
|
6349
7816
|
}
|
|
6350
7817
|
function buildSpanScores(results) {
|
|
6351
7818
|
const scoresRecord = results.reduce(
|
|
6352
|
-
(prev, s) =>
|
|
7819
|
+
(prev, s) => _chunkMWVVR5LRjs.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
|
|
6353
7820
|
{}
|
|
6354
7821
|
);
|
|
6355
7822
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
@@ -6379,7 +7846,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
6379
7846
|
return failing;
|
|
6380
7847
|
}
|
|
6381
7848
|
function validateClassificationResult(value, scorerName2) {
|
|
6382
|
-
if (!(typeof value === "object" && value !== null && !
|
|
7849
|
+
if (!(typeof value === "object" && value !== null && !_chunkMWVVR5LRjs.isEmpty.call(void 0, value))) {
|
|
6383
7850
|
throw new Error(
|
|
6384
7851
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
6385
7852
|
);
|
|
@@ -6408,7 +7875,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
6408
7875
|
);
|
|
6409
7876
|
metadata[`${kind}_errors`] = errorMap;
|
|
6410
7877
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
6411
|
-
|
|
7878
|
+
_chunkMWVVR5LRjs.debugLogger.forState(state).warn(
|
|
6412
7879
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
6413
7880
|
failures.map((f) => f.error)
|
|
6414
7881
|
);
|
|
@@ -6442,7 +7909,7 @@ var defaultErrorScoreHandler = ({
|
|
|
6442
7909
|
};
|
|
6443
7910
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
6444
7911
|
if (enableCache) {
|
|
6445
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
7912
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _145 => _145.spanCache, 'optionalAccess', _146 => _146.start, 'call', _147 => _147()]);
|
|
6446
7913
|
}
|
|
6447
7914
|
try {
|
|
6448
7915
|
if (typeof evaluator.data === "string") {
|
|
@@ -6463,7 +7930,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6463
7930
|
);
|
|
6464
7931
|
}
|
|
6465
7932
|
let name = dataResult.name;
|
|
6466
|
-
if (
|
|
7933
|
+
if (_chunkMWVVR5LRjs.isEmpty.call(void 0, name)) {
|
|
6467
7934
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
6468
7935
|
if (!baseExperiment) {
|
|
6469
7936
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -6497,7 +7964,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6497
7964
|
const experimentIdPromise = experiment ? (async () => {
|
|
6498
7965
|
try {
|
|
6499
7966
|
return await experiment.id;
|
|
6500
|
-
} catch (
|
|
7967
|
+
} catch (e8) {
|
|
6501
7968
|
return void 0;
|
|
6502
7969
|
}
|
|
6503
7970
|
})() : void 0;
|
|
@@ -6513,7 +7980,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6513
7980
|
if (cancelled) {
|
|
6514
7981
|
return;
|
|
6515
7982
|
}
|
|
6516
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
7983
|
+
const eventDataset = experiment ? experiment.dataset : _chunkMWVVR5LRjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
6517
7984
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
6518
7985
|
object_type: "dataset",
|
|
6519
7986
|
object_id: await eventDataset.id,
|
|
@@ -6521,8 +7988,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6521
7988
|
created: datum.created,
|
|
6522
7989
|
_xact_id: datum._xact_id
|
|
6523
7990
|
} : void 0;
|
|
6524
|
-
const parsedDatumOrigin =
|
|
6525
|
-
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess',
|
|
7991
|
+
const parsedDatumOrigin = _chunkMWVVR5LRjs.ObjectReference.safeParse(datum.origin);
|
|
7992
|
+
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _148 => _148.success]) ? parsedDatumOrigin.data : void 0)));
|
|
6526
7993
|
const baseEvent = {
|
|
6527
7994
|
name: "eval",
|
|
6528
7995
|
spanAttributes: {
|
|
@@ -6537,26 +8004,26 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6537
8004
|
}
|
|
6538
8005
|
};
|
|
6539
8006
|
const callback = async (rootSpan) => {
|
|
6540
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
8007
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )));
|
|
6541
8008
|
const ensureSpansFlushed = async () => {
|
|
6542
8009
|
if (experiment) {
|
|
6543
|
-
await
|
|
8010
|
+
await _chunkMWVVR5LRjs.flush.call(void 0, { state: experiment.loggingState });
|
|
6544
8011
|
} else if (state) {
|
|
6545
|
-
await
|
|
8012
|
+
await _chunkMWVVR5LRjs.flush.call(void 0, { state });
|
|
6546
8013
|
} else {
|
|
6547
|
-
await
|
|
8014
|
+
await _chunkMWVVR5LRjs.flush.call(void 0, );
|
|
6548
8015
|
}
|
|
6549
8016
|
if (state) {
|
|
6550
8017
|
await state.flushOtel();
|
|
6551
8018
|
}
|
|
6552
8019
|
};
|
|
6553
8020
|
const parentStr = state.currentParent.getStore();
|
|
6554
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
8021
|
+
const parentComponents = typeof parentStr === "string" ? _chunkMWVVR5LRjs.SpanComponentsV4.fromStr(parentStr) : null;
|
|
6555
8022
|
const trace = state ? new LocalTrace({
|
|
6556
|
-
objectType: parentComponents ?
|
|
8023
|
+
objectType: parentComponents ? _chunkMWVVR5LRjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
6557
8024
|
parentComponents.data.object_type
|
|
6558
8025
|
) : "experiment",
|
|
6559
|
-
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async
|
|
8026
|
+
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _149 => _149.data, 'access', async _150 => _150.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
6560
8027
|
rootSpanId: rootSpan.rootSpanId,
|
|
6561
8028
|
ensureSpansFlushed,
|
|
6562
8029
|
state
|
|
@@ -6586,10 +8053,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6586
8053
|
span,
|
|
6587
8054
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
6588
8055
|
reportProgress: (event) => {
|
|
6589
|
-
_optionalChain([stream, 'optionalCall',
|
|
8056
|
+
_optionalChain([stream, 'optionalCall', _151 => _151({
|
|
6590
8057
|
...event,
|
|
6591
8058
|
id: rootSpan.id,
|
|
6592
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8059
|
+
origin: _optionalChain([baseEvent, 'access', _152 => _152.event, 'optionalAccess', _153 => _153.origin]),
|
|
6593
8060
|
name: evaluator.evalName,
|
|
6594
8061
|
object_type: "task"
|
|
6595
8062
|
})]);
|
|
@@ -6628,7 +8095,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6628
8095
|
trace
|
|
6629
8096
|
};
|
|
6630
8097
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
6631
|
-
const propagatedEvent =
|
|
8098
|
+
const propagatedEvent = _chunkMWVVR5LRjs.makeScorerPropagatedEvent.call(void 0,
|
|
6632
8099
|
await rootSpan.export()
|
|
6633
8100
|
);
|
|
6634
8101
|
const getOtherFields = (s) => {
|
|
@@ -6651,14 +8118,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6651
8118
|
if (scoreValue === null) return null;
|
|
6652
8119
|
if (Array.isArray(scoreValue)) {
|
|
6653
8120
|
for (const s of scoreValue) {
|
|
6654
|
-
if (!(typeof s === "object" && !
|
|
8121
|
+
if (!(typeof s === "object" && !_chunkMWVVR5LRjs.isEmpty.call(void 0, s))) {
|
|
6655
8122
|
throw new Error(
|
|
6656
8123
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
6657
8124
|
);
|
|
6658
8125
|
}
|
|
6659
8126
|
}
|
|
6660
8127
|
}
|
|
6661
|
-
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !
|
|
8128
|
+
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkMWVVR5LRjs.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
|
|
6662
8129
|
{
|
|
6663
8130
|
name: scorerNames[score_idx],
|
|
6664
8131
|
score: scoreValue
|
|
@@ -6666,7 +8133,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6666
8133
|
];
|
|
6667
8134
|
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
6668
8135
|
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
6669
|
-
(prev, s) =>
|
|
8136
|
+
(prev, s) => _chunkMWVVR5LRjs.mergeDicts.call(void 0, prev, {
|
|
6670
8137
|
[s.name]: getOtherFields(s)
|
|
6671
8138
|
}),
|
|
6672
8139
|
{}
|
|
@@ -6701,7 +8168,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6701
8168
|
)
|
|
6702
8169
|
);
|
|
6703
8170
|
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
6704
|
-
(prev, r) =>
|
|
8171
|
+
(prev, r) => _chunkMWVVR5LRjs.mergeDicts.call(void 0, prev, {
|
|
6705
8172
|
[r.name]: toClassificationItem(r)
|
|
6706
8173
|
}),
|
|
6707
8174
|
{}
|
|
@@ -6753,7 +8220,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6753
8220
|
evaluator.state
|
|
6754
8221
|
);
|
|
6755
8222
|
} catch (e) {
|
|
6756
|
-
|
|
8223
|
+
_chunkMWVVR5LRjs.logError.call(void 0, rootSpan, e);
|
|
6757
8224
|
error = e;
|
|
6758
8225
|
} finally {
|
|
6759
8226
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -6777,7 +8244,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6777
8244
|
tags: tags.length ? tags : void 0,
|
|
6778
8245
|
metadata,
|
|
6779
8246
|
error,
|
|
6780
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8247
|
+
origin: _optionalChain([baseEvent, 'access', _154 => _154.event, 'optionalAccess', _155 => _155.origin])
|
|
6781
8248
|
};
|
|
6782
8249
|
collectedResults.push({
|
|
6783
8250
|
...baseResult,
|
|
@@ -6787,7 +8254,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6787
8254
|
}
|
|
6788
8255
|
};
|
|
6789
8256
|
if (!experiment) {
|
|
6790
|
-
return await
|
|
8257
|
+
return await _chunkMWVVR5LRjs.traced.call(void 0, callback, {
|
|
6791
8258
|
...baseEvent,
|
|
6792
8259
|
state: evaluator.state
|
|
6793
8260
|
});
|
|
@@ -6817,7 +8284,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6817
8284
|
break;
|
|
6818
8285
|
}
|
|
6819
8286
|
scheduledTrials++;
|
|
6820
|
-
_optionalChain([progressReporter, 'access',
|
|
8287
|
+
_optionalChain([progressReporter, 'access', _156 => _156.setTotal, 'optionalCall', _157 => _157(evaluator.evalName, scheduledTrials)]);
|
|
6821
8288
|
q.pushAsync({ datum, trialIndex }).catch((e) => {
|
|
6822
8289
|
if (queueErrors.length < 5) {
|
|
6823
8290
|
queueErrors.push(e);
|
|
@@ -6829,7 +8296,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6829
8296
|
const cancel = async () => {
|
|
6830
8297
|
await new Promise((_, reject2) => {
|
|
6831
8298
|
if (cancelled) {
|
|
6832
|
-
reject2(new (0,
|
|
8299
|
+
reject2(new (0, _chunkMWVVR5LRjs.InternalAbortError)("Evaluator already cancelled"));
|
|
6833
8300
|
return;
|
|
6834
8301
|
}
|
|
6835
8302
|
let timeoutId;
|
|
@@ -6850,12 +8317,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6850
8317
|
};
|
|
6851
8318
|
if (evaluator.timeout) {
|
|
6852
8319
|
timeoutId = setTimeout(() => {
|
|
6853
|
-
rejectOnce(new (0,
|
|
8320
|
+
rejectOnce(new (0, _chunkMWVVR5LRjs.InternalAbortError)("Evaluator timed out"));
|
|
6854
8321
|
}, evaluator.timeout);
|
|
6855
8322
|
}
|
|
6856
8323
|
if (evaluator.signal) {
|
|
6857
8324
|
abortHandler = () => {
|
|
6858
|
-
rejectOnce(new (0,
|
|
8325
|
+
rejectOnce(new (0, _chunkMWVVR5LRjs.InternalAbortError)("Evaluator aborted"));
|
|
6859
8326
|
};
|
|
6860
8327
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
6861
8328
|
}
|
|
@@ -6878,9 +8345,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6878
8345
|
}
|
|
6879
8346
|
} catch (e) {
|
|
6880
8347
|
q.kill();
|
|
6881
|
-
if (e instanceof
|
|
8348
|
+
if (e instanceof _chunkMWVVR5LRjs.InternalAbortError) {
|
|
6882
8349
|
if (_chunkBFGIH2ZJjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
6883
|
-
|
|
8350
|
+
_chunkMWVVR5LRjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
6884
8351
|
}
|
|
6885
8352
|
}
|
|
6886
8353
|
throw e;
|
|
@@ -6904,9 +8371,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6904
8371
|
);
|
|
6905
8372
|
} finally {
|
|
6906
8373
|
if (enableCache) {
|
|
6907
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
6908
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
6909
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
8374
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _158 => _158.spanCache]);
|
|
8375
|
+
_optionalChain([spanCache, 'optionalAccess', _159 => _159.dispose, 'call', _160 => _160()]);
|
|
8376
|
+
_optionalChain([spanCache, 'optionalAccess', _161 => _161.stop, 'call', _162 => _162()]);
|
|
6910
8377
|
}
|
|
6911
8378
|
}
|
|
6912
8379
|
}
|
|
@@ -7026,7 +8493,7 @@ var defaultReporter = {
|
|
|
7026
8493
|
const scoreValue = `${scorePercent}%`;
|
|
7027
8494
|
if (hasComparison) {
|
|
7028
8495
|
let diffString = "-";
|
|
7029
|
-
if (!
|
|
8496
|
+
if (!_chunkMWVVR5LRjs.isEmpty.call(void 0, score.diff)) {
|
|
7030
8497
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
7031
8498
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
7032
8499
|
diffString = `${diffSign}${diffPercent}%`;
|
|
@@ -7046,7 +8513,7 @@ var defaultReporter = {
|
|
|
7046
8513
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
7047
8514
|
if (hasComparison) {
|
|
7048
8515
|
let diffString = "-";
|
|
7049
|
-
if (!
|
|
8516
|
+
if (!_chunkMWVVR5LRjs.isEmpty.call(void 0, metric.diff)) {
|
|
7050
8517
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
7051
8518
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
7052
8519
|
diffString = `${diffSign}${diffPercent}%`;
|
|
@@ -7089,7 +8556,7 @@ function agentAssertionScorer(callback, options = {}) {
|
|
|
7089
8556
|
});
|
|
7090
8557
|
const resources = {};
|
|
7091
8558
|
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
7092
|
-
resources.spans = await _optionalChain([args, 'access',
|
|
8559
|
+
resources.spans = await _optionalChain([args, 'access', _163 => _163.trace, 'optionalAccess', _164 => _164.getSpans, 'call', _165 => _165({ spanType: ["tool"] })]);
|
|
7093
8560
|
}
|
|
7094
8561
|
const results = await Promise.all(
|
|
7095
8562
|
assertions.map(async (assertion) => {
|
|
@@ -7247,7 +8714,7 @@ async function validateSchema(schema, value) {
|
|
|
7247
8714
|
}
|
|
7248
8715
|
}
|
|
7249
8716
|
function toolCalls(spans) {
|
|
7250
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
8717
|
+
return spans.filter((span) => _optionalChain([span, 'access', _166 => _166.span_attributes, 'optionalAccess', _167 => _167.type]) === "tool");
|
|
7251
8718
|
}
|
|
7252
8719
|
function matchingToolCalls(spans, toolName, options) {
|
|
7253
8720
|
return toolCalls(spans).filter((span) => {
|
|
@@ -7265,17 +8732,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
7265
8732
|
});
|
|
7266
8733
|
}
|
|
7267
8734
|
function getToolName(span) {
|
|
7268
|
-
const spanName = [_optionalChain([span, 'access',
|
|
7269
|
-
if (_optionalChain([spanName, 'optionalAccess',
|
|
8735
|
+
const spanName = [_optionalChain([span, 'access', _168 => _168.span_attributes, 'optionalAccess', _169 => _169.name]), span.name].map(normalizeToolName).find((value) => value !== void 0);
|
|
8736
|
+
if (_optionalChain([spanName, 'optionalAccess', _170 => _170.includes, 'call', _171 => _171("/")])) {
|
|
7270
8737
|
return spanName;
|
|
7271
8738
|
}
|
|
7272
8739
|
const metadataName = [
|
|
7273
|
-
_optionalChain([span, 'access',
|
|
7274
|
-
_optionalChain([span, 'access',
|
|
8740
|
+
_optionalChain([span, 'access', _172 => _172.metadata, 'optionalAccess', _173 => _173.tool_name]),
|
|
8741
|
+
_optionalChain([span, 'access', _174 => _174.metadata, 'optionalAccess', _175 => _175["gen_ai.tool.name"]])
|
|
7275
8742
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
7276
8743
|
const mcpServer = [
|
|
7277
|
-
_optionalChain([span, 'access',
|
|
7278
|
-
_optionalChain([span, 'access',
|
|
8744
|
+
_optionalChain([span, 'access', _176 => _176.metadata, 'optionalAccess', _177 => _177["mcp.server"]]),
|
|
8745
|
+
_optionalChain([span, 'access', _178 => _178.metadata, 'optionalAccess', _179 => _179["openai_codex.mcp.server"]])
|
|
7279
8746
|
].find((value) => typeof value === "string" && value !== "");
|
|
7280
8747
|
if (metadataName && mcpServer) {
|
|
7281
8748
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -7345,7 +8812,7 @@ function formatValue(value) {
|
|
|
7345
8812
|
return serialized;
|
|
7346
8813
|
}
|
|
7347
8814
|
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
7348
|
-
} catch (
|
|
8815
|
+
} catch (e9) {
|
|
7349
8816
|
return String(value);
|
|
7350
8817
|
}
|
|
7351
8818
|
}
|
|
@@ -7458,7 +8925,7 @@ var ProjectBuilder = class {
|
|
|
7458
8925
|
}
|
|
7459
8926
|
};
|
|
7460
8927
|
var projects = new ProjectBuilder();
|
|
7461
|
-
var Project2 = (
|
|
8928
|
+
var Project2 = (_class7 = class {
|
|
7462
8929
|
|
|
7463
8930
|
|
|
7464
8931
|
|
|
@@ -7466,10 +8933,10 @@ var Project2 = (_class6 = class {
|
|
|
7466
8933
|
|
|
7467
8934
|
|
|
7468
8935
|
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
constructor(args) {;
|
|
8936
|
+
__init17() {this._publishableCodeFunctions = []}
|
|
8937
|
+
__init18() {this._publishablePrompts = []}
|
|
8938
|
+
__init19() {this._publishableParameters = []}
|
|
8939
|
+
constructor(args) {;_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);
|
|
7473
8940
|
_initializeSpanContext();
|
|
7474
8941
|
this.name = "name" in args ? args.name : void 0;
|
|
7475
8942
|
this.id = "id" in args ? args.id : void 0;
|
|
@@ -7504,7 +8971,7 @@ var Project2 = (_class6 = class {
|
|
|
7504
8971
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
7505
8972
|
return;
|
|
7506
8973
|
}
|
|
7507
|
-
await
|
|
8974
|
+
await _chunkMWVVR5LRjs.login.call(void 0, );
|
|
7508
8975
|
const projectMap = new ProjectNameIdMap();
|
|
7509
8976
|
const functionDefinitions = [];
|
|
7510
8977
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -7518,16 +8985,16 @@ var Project2 = (_class6 = class {
|
|
|
7518
8985
|
functionDefinitions.push(functionDefinition);
|
|
7519
8986
|
}
|
|
7520
8987
|
}
|
|
7521
|
-
await
|
|
8988
|
+
await _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
7522
8989
|
functions: functionDefinitions
|
|
7523
8990
|
});
|
|
7524
8991
|
}
|
|
7525
|
-
},
|
|
7526
|
-
var ToolBuilder = (
|
|
7527
|
-
constructor(project) {;
|
|
8992
|
+
}, _class7);
|
|
8993
|
+
var ToolBuilder = (_class8 = class {
|
|
8994
|
+
constructor(project) {;_class8.prototype.__init20.call(this);
|
|
7528
8995
|
this.project = project;
|
|
7529
8996
|
}
|
|
7530
|
-
|
|
8997
|
+
__init20() {this.taskCounter = 0}
|
|
7531
8998
|
// This type definition is just a catch all so that the implementation can be
|
|
7532
8999
|
// less specific than the two more specific declarations above.
|
|
7533
9000
|
create(opts) {
|
|
@@ -7541,7 +9008,7 @@ var ToolBuilder = (_class7 = class {
|
|
|
7541
9008
|
const tool = new CodeFunction(this.project, {
|
|
7542
9009
|
handler,
|
|
7543
9010
|
name: resolvedName,
|
|
7544
|
-
slug: _nullishCoalesce(slug, () => (
|
|
9011
|
+
slug: _nullishCoalesce(slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
7545
9012
|
type: "tool",
|
|
7546
9013
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
7547
9014
|
parameters,
|
|
@@ -7552,12 +9019,12 @@ var ToolBuilder = (_class7 = class {
|
|
|
7552
9019
|
this.project.addCodeFunction(tool);
|
|
7553
9020
|
return tool;
|
|
7554
9021
|
}
|
|
7555
|
-
},
|
|
7556
|
-
var ScorerBuilder = (
|
|
7557
|
-
constructor(project) {;
|
|
9022
|
+
}, _class8);
|
|
9023
|
+
var ScorerBuilder = (_class9 = class {
|
|
9024
|
+
constructor(project) {;_class9.prototype.__init21.call(this);
|
|
7558
9025
|
this.project = project;
|
|
7559
9026
|
}
|
|
7560
|
-
|
|
9027
|
+
__init21() {this.taskCounter = 0}
|
|
7561
9028
|
create(opts) {
|
|
7562
9029
|
this.taskCounter++;
|
|
7563
9030
|
let resolvedName = opts.name;
|
|
@@ -7567,7 +9034,7 @@ var ScorerBuilder = (_class8 = class {
|
|
|
7567
9034
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7568
9035
|
resolvedName = `Scorer ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7569
9036
|
}
|
|
7570
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9037
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7571
9038
|
if ("handler" in opts) {
|
|
7572
9039
|
const scorer = new CodeFunction(this.project, {
|
|
7573
9040
|
...opts,
|
|
@@ -7611,19 +9078,19 @@ var ScorerBuilder = (_class8 = class {
|
|
|
7611
9078
|
this.project.addPrompt(codePrompt);
|
|
7612
9079
|
}
|
|
7613
9080
|
}
|
|
7614
|
-
},
|
|
7615
|
-
var ClassifierBuilder = (
|
|
7616
|
-
constructor(project) {;
|
|
9081
|
+
}, _class9);
|
|
9082
|
+
var ClassifierBuilder = (_class10 = class {
|
|
9083
|
+
constructor(project) {;_class10.prototype.__init22.call(this);
|
|
7617
9084
|
this.project = project;
|
|
7618
9085
|
}
|
|
7619
|
-
|
|
9086
|
+
__init22() {this.taskCounter = 0}
|
|
7620
9087
|
create(opts) {
|
|
7621
9088
|
this.taskCounter++;
|
|
7622
9089
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
7623
9090
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7624
9091
|
resolvedName = `Classifier ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7625
9092
|
}
|
|
7626
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9093
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7627
9094
|
const classifier = new CodeFunction(this.project, {
|
|
7628
9095
|
...opts,
|
|
7629
9096
|
name: resolvedName,
|
|
@@ -7633,7 +9100,7 @@ var ClassifierBuilder = (_class9 = class {
|
|
|
7633
9100
|
this.project.addCodeFunction(classifier);
|
|
7634
9101
|
return classifier;
|
|
7635
9102
|
}
|
|
7636
|
-
},
|
|
9103
|
+
}, _class10);
|
|
7637
9104
|
var CodeFunction = class {
|
|
7638
9105
|
constructor(project, opts) {
|
|
7639
9106
|
this.project = project;
|
|
@@ -7750,18 +9217,18 @@ var PromptBuilder = class {
|
|
|
7750
9217
|
rawTools.push(tool);
|
|
7751
9218
|
}
|
|
7752
9219
|
}
|
|
7753
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9220
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7754
9221
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
7755
9222
|
const promptRow = {
|
|
7756
9223
|
id: opts.id,
|
|
7757
|
-
_xact_id: opts.version ?
|
|
9224
|
+
_xact_id: opts.version ? _chunkMWVVR5LRjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
7758
9225
|
name: opts.name,
|
|
7759
9226
|
slug,
|
|
7760
9227
|
prompt_data: promptData,
|
|
7761
9228
|
tags: opts.tags,
|
|
7762
9229
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
7763
9230
|
};
|
|
7764
|
-
const prompt = new (0,
|
|
9231
|
+
const prompt = new (0, _chunkMWVVR5LRjs.Prompt)(
|
|
7765
9232
|
promptRow,
|
|
7766
9233
|
{},
|
|
7767
9234
|
// It doesn't make sense to specify defaults here.
|
|
@@ -7815,7 +9282,7 @@ var ParametersBuilder = class {
|
|
|
7815
9282
|
this.project = project;
|
|
7816
9283
|
}
|
|
7817
9284
|
create(opts) {
|
|
7818
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9285
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkMWVVR5LRjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7819
9286
|
const codeParameters = new CodeParameters(this.project, {
|
|
7820
9287
|
name: opts.name,
|
|
7821
9288
|
slug,
|
|
@@ -7854,7 +9321,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
7854
9321
|
required.push(name);
|
|
7855
9322
|
}
|
|
7856
9323
|
} else {
|
|
7857
|
-
const schemaObj =
|
|
9324
|
+
const schemaObj = _chunkMWVVR5LRjs.zodToJsonSchema.call(void 0, value);
|
|
7858
9325
|
properties[name] = schemaObj;
|
|
7859
9326
|
if (!("default" in schemaObj)) {
|
|
7860
9327
|
required.push(name);
|
|
@@ -7878,16 +9345,16 @@ function getDefaultDataFromParametersSchema(schema) {
|
|
|
7878
9345
|
})
|
|
7879
9346
|
);
|
|
7880
9347
|
}
|
|
7881
|
-
var ProjectNameIdMap = (
|
|
7882
|
-
|
|
7883
|
-
|
|
9348
|
+
var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__init23.call(this);_class11.prototype.__init24.call(this); }
|
|
9349
|
+
__init23() {this.nameToId = {}}
|
|
9350
|
+
__init24() {this.idToName = {}}
|
|
7884
9351
|
async getId(projectName) {
|
|
7885
9352
|
if (!(projectName in this.nameToId)) {
|
|
7886
|
-
const response = await
|
|
9353
|
+
const response = await _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
7887
9354
|
project_name: projectName
|
|
7888
9355
|
});
|
|
7889
9356
|
const result = _v3.z.object({
|
|
7890
|
-
project:
|
|
9357
|
+
project: _chunkMWVVR5LRjs.Project
|
|
7891
9358
|
}).parse(response);
|
|
7892
9359
|
const projectId = result.project.id;
|
|
7893
9360
|
this.nameToId[projectName] = projectId;
|
|
@@ -7897,10 +9364,10 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7897
9364
|
}
|
|
7898
9365
|
async getName(projectId) {
|
|
7899
9366
|
if (!(projectId in this.idToName)) {
|
|
7900
|
-
const response = await
|
|
9367
|
+
const response = await _chunkMWVVR5LRjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
7901
9368
|
id: projectId
|
|
7902
9369
|
});
|
|
7903
|
-
const result = _v3.z.array(
|
|
9370
|
+
const result = _v3.z.array(_chunkMWVVR5LRjs.Project).nonempty().parse(response);
|
|
7904
9371
|
const projectName = result[0].name;
|
|
7905
9372
|
this.idToName[projectId] = projectName;
|
|
7906
9373
|
this.nameToId[projectName] = projectId;
|
|
@@ -7913,23 +9380,23 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7913
9380
|
}
|
|
7914
9381
|
return this.getId(project.name);
|
|
7915
9382
|
}
|
|
7916
|
-
},
|
|
9383
|
+
}, _class11);
|
|
7917
9384
|
|
|
7918
9385
|
// dev/types.ts
|
|
7919
9386
|
|
|
7920
9387
|
var evalBodySchema = _v3.z.object({
|
|
7921
9388
|
name: _v3.z.string(),
|
|
7922
9389
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
7923
|
-
data:
|
|
9390
|
+
data: _chunkMWVVR5LRjs.RunEval.shape.data,
|
|
7924
9391
|
scores: _v3.z.array(
|
|
7925
9392
|
_v3.z.object({
|
|
7926
|
-
function_id:
|
|
9393
|
+
function_id: _chunkMWVVR5LRjs.FunctionId,
|
|
7927
9394
|
name: _v3.z.string()
|
|
7928
9395
|
})
|
|
7929
9396
|
).nullish(),
|
|
7930
9397
|
experiment_name: _v3.z.string().nullish(),
|
|
7931
9398
|
project_id: _v3.z.string().nullish(),
|
|
7932
|
-
parent:
|
|
9399
|
+
parent: _chunkMWVVR5LRjs.InvokeParent.optional(),
|
|
7933
9400
|
stream: _v3.z.boolean().optional()
|
|
7934
9401
|
});
|
|
7935
9402
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -7937,7 +9404,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
7937
9404
|
_v3.z.union([
|
|
7938
9405
|
_v3.z.object({
|
|
7939
9406
|
type: _v3.z.literal("prompt"),
|
|
7940
|
-
default:
|
|
9407
|
+
default: _chunkMWVVR5LRjs.PromptData.optional(),
|
|
7941
9408
|
description: _v3.z.string().optional()
|
|
7942
9409
|
}),
|
|
7943
9410
|
_v3.z.object({
|
|
@@ -7993,7 +9460,9 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
7993
9460
|
);
|
|
7994
9461
|
|
|
7995
9462
|
// src/node/index.ts
|
|
7996
|
-
|
|
9463
|
+
_chunkMWVVR5LRjs.configureNode.call(void 0, );
|
|
9464
|
+
|
|
9465
|
+
|
|
7997
9466
|
|
|
7998
9467
|
|
|
7999
9468
|
|
|
@@ -8159,4 +9628,4 @@ _chunkFY7DAKA5js.configureNode.call(void 0, );
|
|
|
8159
9628
|
|
|
8160
9629
|
|
|
8161
9630
|
|
|
8162
|
-
exports.Attachment =
|
|
9631
|
+
exports.Attachment = _chunkMWVVR5LRjs.Attachment; exports.AttachmentReference = _chunkMWVVR5LRjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkMWVVR5LRjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkMWVVR5LRjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkMWVVR5LRjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkMWVVR5LRjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkMWVVR5LRjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkMWVVR5LRjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkMWVVR5LRjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkMWVVR5LRjs.BraintrustState; exports.BraintrustStream = _chunkMWVVR5LRjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkMWVVR5LRjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkMWVVR5LRjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkMWVVR5LRjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkMWVVR5LRjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkMWVVR5LRjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkMWVVR5LRjs.Experiment; exports.ExternalAttachment = _chunkMWVVR5LRjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkMWVVR5LRjs.FailedHTTPResponse; exports.IDGenerator = _chunkMWVVR5LRjs.IDGenerator; exports.JSONAttachment = _chunkMWVVR5LRjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkMWVVR5LRjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkMWVVR5LRjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkMWVVR5LRjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkMWVVR5LRjs.Logger; exports.LoginInvalidOrgError = _chunkMWVVR5LRjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkMWVVR5LRjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkMWVVR5LRjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkMWVVR5LRjs.NoopSpan; exports.OTELIDGenerator = _chunkMWVVR5LRjs.OTELIDGenerator; exports.ObjectFetcher = _chunkMWVVR5LRjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkMWVVR5LRjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkMWVVR5LRjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkMWVVR5LRjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkMWVVR5LRjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkMWVVR5LRjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkMWVVR5LRjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkMWVVR5LRjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkMWVVR5LRjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkMWVVR5LRjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkMWVVR5LRjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkMWVVR5LRjs._internalGetGlobalState; exports._internalIso = _chunkBFGIH2ZJjs.isomorph_default; exports._internalSetInitialState = _chunkMWVVR5LRjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkMWVVR5LRjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkMWVVR5LRjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkMWVVR5LRjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkMWVVR5LRjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkMWVVR5LRjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkMWVVR5LRjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkMWVVR5LRjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkMWVVR5LRjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkMWVVR5LRjs.currentExperiment; exports.currentLogger = _chunkMWVVR5LRjs.currentLogger; exports.currentSpan = _chunkMWVVR5LRjs.currentSpan; exports.deepCopyEvent = _chunkMWVVR5LRjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkMWVVR5LRjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkMWVVR5LRjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkMWVVR5LRjs.extractTraceContextFromHeaders; exports.flush = _chunkMWVVR5LRjs.flush; exports.getContextManager = _chunkMWVVR5LRjs.getContextManager; exports.getIdGenerator = _chunkMWVVR5LRjs.getIdGenerator; exports.getPromptVersions = _chunkMWVVR5LRjs.getPromptVersions; exports.getSpanParentObject = _chunkMWVVR5LRjs.getSpanParentObject; exports.getTemplateRenderer = _chunkMWVVR5LRjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkMWVVR5LRjs.init; exports.initDataset = _chunkMWVVR5LRjs.initDataset; exports.initExperiment = _chunkMWVVR5LRjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkMWVVR5LRjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkMWVVR5LRjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkMWVVR5LRjs.isTemplateFormat; exports.loadParameters = _chunkMWVVR5LRjs.loadParameters; exports.loadPrompt = _chunkMWVVR5LRjs.loadPrompt; exports.log = _chunkMWVVR5LRjs.log; exports.logError = _chunkMWVVR5LRjs.logError; exports.login = _chunkMWVVR5LRjs.login; exports.loginToState = _chunkMWVVR5LRjs.loginToState; exports.logs3OverflowUploadSchema = _chunkMWVVR5LRjs.logs3OverflowUploadSchema; exports.newId = _chunkMWVVR5LRjs.newId; exports.parseCachedHeader = _chunkMWVVR5LRjs.parseCachedHeader; exports.parseTemplateFormat = _chunkMWVVR5LRjs.parseTemplateFormat; exports.permalink = _chunkMWVVR5LRjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkMWVVR5LRjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkMWVVR5LRjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkMWVVR5LRjs.registerTemplatePlugin; exports.renderMessage = _chunkMWVVR5LRjs.renderMessage; exports.renderPromptParams = _chunkMWVVR5LRjs.renderPromptParams; exports.renderTemplateContent = _chunkMWVVR5LRjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkMWVVR5LRjs.setFetch; exports.setMaskingFunction = _chunkMWVVR5LRjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkMWVVR5LRjs.spanComponentsToObjectId; exports.startSpan = _chunkMWVVR5LRjs.startSpan; exports.summarize = _chunkMWVVR5LRjs.summarize; exports.templateRegistry = _chunkMWVVR5LRjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkMWVVR5LRjs.ToolFunctionDefinition; exports.traceable = _chunkMWVVR5LRjs.traceable; exports.traced = _chunkMWVVR5LRjs.traced; exports.updateSpan = _chunkMWVVR5LRjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkMWVVR5LRjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkMWVVR5LRjs.utf8ByteLength; exports.withCurrent = _chunkMWVVR5LRjs.withCurrent; exports.withDataset = _chunkMWVVR5LRjs.withDataset; exports.withExperiment = _chunkMWVVR5LRjs.withExperiment; exports.withLogger = _chunkMWVVR5LRjs.withLogger; exports.withParent = _chunkMWVVR5LRjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCohere = wrapCohere; exports.wrapCopilotClient = wrapCopilotClient; exports.wrapCursorSDK = wrapCursorSDK; exports.wrapGenkit = wrapGenkit; exports.wrapGoogleADK = wrapGoogleADK; exports.wrapGoogleGenAI = wrapGoogleGenAI; exports.wrapGroq = wrapGroq; exports.wrapHuggingFace = wrapHuggingFace; exports.wrapMastraAgent = _chunkMWVVR5LRjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkMWVVR5LRjs.wrapTraced; exports.wrapVitest = wrapVitest;
|