braintrust 3.21.0 → 3.23.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 +47 -0
- package/dev/dist/index.d.mts +1030 -1
- package/dev/dist/index.d.ts +1030 -1
- package/dev/dist/index.js +1429 -663
- package/dev/dist/index.mjs +811 -45
- package/dist/apply-auto-instrumentation.js +222 -186
- package/dist/apply-auto-instrumentation.mjs +37 -1
- package/dist/auto-instrumentations/bundler/esbuild.cjs +53 -1
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/next.cjs +53 -1
- package/dist/auto-instrumentations/bundler/next.mjs +3 -3
- package/dist/auto-instrumentations/bundler/rollup.cjs +53 -1
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +53 -1
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +53 -1
- package/dist/auto-instrumentations/bundler/webpack.cjs +53 -1
- package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
- package/dist/auto-instrumentations/{chunk-TKRPRPGD.mjs → chunk-EXY7QCJD.mjs} +5 -2
- package/dist/auto-instrumentations/{chunk-T6J4C7LX.mjs → chunk-KIMLYPRW.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-BRQX23KL.mjs → chunk-YXLNSAMJ.mjs} +51 -0
- package/dist/auto-instrumentations/hook.mjs +224 -31
- package/dist/auto-instrumentations/index.cjs +52 -0
- package/dist/auto-instrumentations/index.d.mts +3 -1
- package/dist/auto-instrumentations/index.d.ts +3 -1
- package/dist/auto-instrumentations/index.mjs +3 -1
- package/dist/browser.d.mts +3273 -93
- package/dist/browser.d.ts +3273 -93
- package/dist/browser.js +2495 -63
- package/dist/browser.mjs +2495 -63
- package/dist/{chunk-KMGUTPB7.mjs → chunk-36IPYKMG.mjs} +20 -1
- package/dist/{chunk-BFGIH2ZJ.js → chunk-CDIKAHDZ.js} +21 -2
- package/dist/{chunk-FY7DAKA5.js → chunk-FZWPFCVE.js} +1590 -832
- package/dist/{chunk-O2P765XK.mjs → chunk-IXL4PMY4.mjs} +802 -44
- package/dist/cli.js +816 -47
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +2495 -63
- package/dist/edge-light.mjs +2495 -63
- package/dist/index.d.mts +3273 -93
- package/dist/index.d.ts +3273 -93
- package/dist/index.js +2078 -416
- package/dist/index.mjs +1664 -2
- package/dist/instrumentation/index.d.mts +912 -2
- package/dist/instrumentation/index.d.ts +912 -2
- package/dist/instrumentation/index.js +2202 -42
- package/dist/instrumentation/index.mjs +2200 -42
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +2495 -63
- package/dist/workerd.mjs +2495 -63
- 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,9 +137,9 @@
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
var _chunkFY7DAKA5js = require('./chunk-FY7DAKA5.js');
|
|
141
140
|
|
|
142
141
|
|
|
142
|
+
var _chunkFZWPFCVEjs = require('./chunk-FZWPFCVE.js');
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
|
|
@@ -160,149 +160,154 @@ var _chunkFY7DAKA5js = require('./chunk-FY7DAKA5.js');
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
var _chunkCDIKAHDZjs = require('./chunk-CDIKAHDZ.js');
|
|
164
167
|
|
|
165
168
|
// src/exports.ts
|
|
166
169
|
var exports_exports = {};
|
|
167
|
-
|
|
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
|
+
_chunkCDIKAHDZjs.__export.call(void 0, exports_exports, {
|
|
171
|
+
Attachment: () => _chunkFZWPFCVEjs.Attachment,
|
|
172
|
+
AttachmentReference: () => _chunkFZWPFCVEjs.AttachmentReference,
|
|
173
|
+
BAGGAGE_HEADER: () => _chunkFZWPFCVEjs.BAGGAGE_HEADER,
|
|
174
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkFZWPFCVEjs.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
175
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkFZWPFCVEjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
176
|
+
BRAINTRUST_PARENT_KEY: () => _chunkFZWPFCVEjs.BRAINTRUST_PARENT_KEY,
|
|
177
|
+
BaseAttachment: () => _chunkFZWPFCVEjs.BaseAttachment,
|
|
175
178
|
BaseExperiment: () => BaseExperiment,
|
|
176
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
179
|
+
BraintrustLangChainCallbackHandler: () => _chunkFZWPFCVEjs.BraintrustLangChainCallbackHandler,
|
|
177
180
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
178
|
-
BraintrustObservabilityExporter: () =>
|
|
179
|
-
BraintrustState: () =>
|
|
180
|
-
BraintrustStream: () =>
|
|
181
|
+
BraintrustObservabilityExporter: () => _chunkFZWPFCVEjs.BraintrustObservabilityExporter,
|
|
182
|
+
BraintrustState: () => _chunkFZWPFCVEjs.BraintrustState,
|
|
183
|
+
BraintrustStream: () => _chunkFZWPFCVEjs.BraintrustStream,
|
|
181
184
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
182
185
|
CodeFunction: () => CodeFunction,
|
|
183
186
|
CodePrompt: () => CodePrompt,
|
|
184
|
-
ContextManager: () =>
|
|
185
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
186
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
187
|
-
Dataset: () =>
|
|
187
|
+
ContextManager: () => _chunkFZWPFCVEjs.ContextManager,
|
|
188
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkFZWPFCVEjs.DEFAULT_FETCH_BATCH_SIZE,
|
|
189
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkFZWPFCVEjs.DEFAULT_MAX_REQUEST_SIZE,
|
|
190
|
+
Dataset: () => _chunkFZWPFCVEjs.Dataset,
|
|
188
191
|
DatasetPipeline: () => DatasetPipeline,
|
|
189
|
-
ERR_PERMALINK: () =>
|
|
192
|
+
ERR_PERMALINK: () => _chunkFZWPFCVEjs.ERR_PERMALINK,
|
|
190
193
|
Eval: () => Eval,
|
|
191
194
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
192
|
-
Experiment: () =>
|
|
193
|
-
ExternalAttachment: () =>
|
|
194
|
-
FailedHTTPResponse: () =>
|
|
195
|
-
IDGenerator: () =>
|
|
196
|
-
JSONAttachment: () =>
|
|
197
|
-
LEGACY_CACHED_HEADER: () =>
|
|
198
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
199
|
-
LazyValue: () =>
|
|
195
|
+
Experiment: () => _chunkFZWPFCVEjs.Experiment,
|
|
196
|
+
ExternalAttachment: () => _chunkFZWPFCVEjs.ExternalAttachment,
|
|
197
|
+
FailedHTTPResponse: () => _chunkFZWPFCVEjs.FailedHTTPResponse,
|
|
198
|
+
IDGenerator: () => _chunkFZWPFCVEjs.IDGenerator,
|
|
199
|
+
JSONAttachment: () => _chunkFZWPFCVEjs.JSONAttachment,
|
|
200
|
+
LEGACY_CACHED_HEADER: () => _chunkFZWPFCVEjs.LEGACY_CACHED_HEADER,
|
|
201
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkFZWPFCVEjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
202
|
+
LazyValue: () => _chunkFZWPFCVEjs.LazyValue,
|
|
200
203
|
LocalTrace: () => LocalTrace,
|
|
201
|
-
Logger: () =>
|
|
202
|
-
LoginInvalidOrgError: () =>
|
|
203
|
-
NOOP_SPAN: () =>
|
|
204
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
205
|
-
NoopSpan: () =>
|
|
206
|
-
OTELIDGenerator: () =>
|
|
207
|
-
ObjectFetcher: () =>
|
|
204
|
+
Logger: () => _chunkFZWPFCVEjs.Logger,
|
|
205
|
+
LoginInvalidOrgError: () => _chunkFZWPFCVEjs.LoginInvalidOrgError,
|
|
206
|
+
NOOP_SPAN: () => _chunkFZWPFCVEjs.NOOP_SPAN,
|
|
207
|
+
NOOP_SPAN_PERMALINK: () => _chunkFZWPFCVEjs.NOOP_SPAN_PERMALINK,
|
|
208
|
+
NoopSpan: () => _chunkFZWPFCVEjs.NoopSpan,
|
|
209
|
+
OTELIDGenerator: () => _chunkFZWPFCVEjs.OTELIDGenerator,
|
|
210
|
+
ObjectFetcher: () => _chunkFZWPFCVEjs.ObjectFetcher,
|
|
208
211
|
Project: () => Project2,
|
|
209
212
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
210
|
-
Prompt: () =>
|
|
213
|
+
Prompt: () => _chunkFZWPFCVEjs.Prompt,
|
|
211
214
|
PromptBuilder: () => PromptBuilder,
|
|
212
|
-
ReadonlyAttachment: () =>
|
|
213
|
-
ReadonlyExperiment: () =>
|
|
215
|
+
ReadonlyAttachment: () => _chunkFZWPFCVEjs.ReadonlyAttachment,
|
|
216
|
+
ReadonlyExperiment: () => _chunkFZWPFCVEjs.ReadonlyExperiment,
|
|
214
217
|
Reporter: () => Reporter,
|
|
215
218
|
ScorerBuilder: () => ScorerBuilder,
|
|
216
219
|
SpanFetcher: () => SpanFetcher,
|
|
217
|
-
SpanImpl: () =>
|
|
218
|
-
TRACEPARENT_HEADER: () =>
|
|
219
|
-
TRACESTATE_HEADER: () =>
|
|
220
|
-
TestBackgroundLogger: () =>
|
|
220
|
+
SpanImpl: () => _chunkFZWPFCVEjs.SpanImpl,
|
|
221
|
+
TRACEPARENT_HEADER: () => _chunkFZWPFCVEjs.TRACEPARENT_HEADER,
|
|
222
|
+
TRACESTATE_HEADER: () => _chunkFZWPFCVEjs.TRACESTATE_HEADER,
|
|
223
|
+
TestBackgroundLogger: () => _chunkFZWPFCVEjs.TestBackgroundLogger,
|
|
221
224
|
ToolBuilder: () => ToolBuilder,
|
|
222
|
-
UUIDGenerator: () =>
|
|
223
|
-
X_CACHED_HEADER: () =>
|
|
224
|
-
_exportsForTestingOnly: () =>
|
|
225
|
-
_internalGetGlobalState: () =>
|
|
226
|
-
_internalIso: () =>
|
|
227
|
-
_internalSetInitialState: () =>
|
|
228
|
-
addAzureBlobHeaders: () =>
|
|
225
|
+
UUIDGenerator: () => _chunkFZWPFCVEjs.UUIDGenerator,
|
|
226
|
+
X_CACHED_HEADER: () => _chunkFZWPFCVEjs.X_CACHED_HEADER,
|
|
227
|
+
_exportsForTestingOnly: () => _chunkFZWPFCVEjs._exportsForTestingOnly,
|
|
228
|
+
_internalGetGlobalState: () => _chunkFZWPFCVEjs._internalGetGlobalState,
|
|
229
|
+
_internalIso: () => _chunkCDIKAHDZjs.isomorph_default,
|
|
230
|
+
_internalSetInitialState: () => _chunkFZWPFCVEjs._internalSetInitialState,
|
|
231
|
+
addAzureBlobHeaders: () => _chunkFZWPFCVEjs.addAzureBlobHeaders,
|
|
229
232
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
230
|
-
braintrustAISDKTelemetry: () =>
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
braintrustAISDKTelemetry: () => _chunkFZWPFCVEjs.braintrustAISDKTelemetry,
|
|
234
|
+
braintrustEveHook: () => braintrustEveHook,
|
|
235
|
+
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
236
|
+
braintrustFlueInstrumentation: () => _chunkFZWPFCVEjs.braintrustFlueInstrumentation,
|
|
237
|
+
braintrustFlueObserver: () => _chunkFZWPFCVEjs.braintrustFlueObserver,
|
|
238
|
+
braintrustStreamChunkSchema: () => _chunkFZWPFCVEjs.braintrustStreamChunkSchema,
|
|
234
239
|
buildLocalSummary: () => buildLocalSummary,
|
|
235
|
-
configureInstrumentation: () =>
|
|
236
|
-
constructLogs3OverflowRequest: () =>
|
|
237
|
-
createFinalValuePassThroughStream: () =>
|
|
238
|
-
currentExperiment: () =>
|
|
239
|
-
currentLogger: () =>
|
|
240
|
-
currentSpan: () =>
|
|
241
|
-
deepCopyEvent: () =>
|
|
240
|
+
configureInstrumentation: () => _chunkFZWPFCVEjs.configureInstrumentation,
|
|
241
|
+
constructLogs3OverflowRequest: () => _chunkFZWPFCVEjs.constructLogs3OverflowRequest,
|
|
242
|
+
createFinalValuePassThroughStream: () => _chunkFZWPFCVEjs.createFinalValuePassThroughStream,
|
|
243
|
+
currentExperiment: () => _chunkFZWPFCVEjs.currentExperiment,
|
|
244
|
+
currentLogger: () => _chunkFZWPFCVEjs.currentLogger,
|
|
245
|
+
currentSpan: () => _chunkFZWPFCVEjs.currentSpan,
|
|
246
|
+
deepCopyEvent: () => _chunkFZWPFCVEjs.deepCopyEvent,
|
|
242
247
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
243
|
-
deserializePlainStringAsJSON: () =>
|
|
244
|
-
devNullWritableStream: () =>
|
|
248
|
+
deserializePlainStringAsJSON: () => _chunkFZWPFCVEjs.deserializePlainStringAsJSON,
|
|
249
|
+
devNullWritableStream: () => _chunkFZWPFCVEjs.devNullWritableStream,
|
|
245
250
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
246
251
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
247
|
-
extractTraceContextFromHeaders: () =>
|
|
248
|
-
flush: () =>
|
|
249
|
-
getContextManager: () =>
|
|
250
|
-
getIdGenerator: () =>
|
|
251
|
-
getPromptVersions: () =>
|
|
252
|
-
getSpanParentObject: () =>
|
|
253
|
-
getTemplateRenderer: () =>
|
|
252
|
+
extractTraceContextFromHeaders: () => _chunkFZWPFCVEjs.extractTraceContextFromHeaders,
|
|
253
|
+
flush: () => _chunkFZWPFCVEjs.flush,
|
|
254
|
+
getContextManager: () => _chunkFZWPFCVEjs.getContextManager,
|
|
255
|
+
getIdGenerator: () => _chunkFZWPFCVEjs.getIdGenerator,
|
|
256
|
+
getPromptVersions: () => _chunkFZWPFCVEjs.getPromptVersions,
|
|
257
|
+
getSpanParentObject: () => _chunkFZWPFCVEjs.getSpanParentObject,
|
|
258
|
+
getTemplateRenderer: () => _chunkFZWPFCVEjs.getTemplateRenderer,
|
|
254
259
|
graph: () => graph_framework_exports,
|
|
255
|
-
init: () =>
|
|
256
|
-
initDataset: () =>
|
|
257
|
-
initExperiment: () =>
|
|
260
|
+
init: () => _chunkFZWPFCVEjs.init,
|
|
261
|
+
initDataset: () => _chunkFZWPFCVEjs.initDataset,
|
|
262
|
+
initExperiment: () => _chunkFZWPFCVEjs.initExperiment,
|
|
258
263
|
initFunction: () => initFunction,
|
|
259
|
-
initLogger: () =>
|
|
264
|
+
initLogger: () => _chunkFZWPFCVEjs.initLogger,
|
|
260
265
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
261
|
-
injectTraceContext: () =>
|
|
266
|
+
injectTraceContext: () => _chunkFZWPFCVEjs.injectTraceContext,
|
|
262
267
|
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: () =>
|
|
268
|
+
isTemplateFormat: () => _chunkFZWPFCVEjs.isTemplateFormat,
|
|
269
|
+
loadParameters: () => _chunkFZWPFCVEjs.loadParameters,
|
|
270
|
+
loadPrompt: () => _chunkFZWPFCVEjs.loadPrompt,
|
|
271
|
+
log: () => _chunkFZWPFCVEjs.log,
|
|
272
|
+
logError: () => _chunkFZWPFCVEjs.logError,
|
|
273
|
+
login: () => _chunkFZWPFCVEjs.login,
|
|
274
|
+
loginToState: () => _chunkFZWPFCVEjs.loginToState,
|
|
275
|
+
logs3OverflowUploadSchema: () => _chunkFZWPFCVEjs.logs3OverflowUploadSchema,
|
|
276
|
+
newId: () => _chunkFZWPFCVEjs.newId,
|
|
277
|
+
parseCachedHeader: () => _chunkFZWPFCVEjs.parseCachedHeader,
|
|
278
|
+
parseTemplateFormat: () => _chunkFZWPFCVEjs.parseTemplateFormat,
|
|
279
|
+
permalink: () => _chunkFZWPFCVEjs.permalink,
|
|
280
|
+
pickLogs3OverflowObjectIds: () => _chunkFZWPFCVEjs.pickLogs3OverflowObjectIds,
|
|
276
281
|
projects: () => projects,
|
|
277
282
|
promptContentsSchema: () => promptContentsSchema,
|
|
278
283
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
279
284
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
280
285
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
281
|
-
registerOtelFlush: () =>
|
|
286
|
+
registerOtelFlush: () => _chunkFZWPFCVEjs.registerOtelFlush,
|
|
282
287
|
registerSandbox: () => registerSandbox,
|
|
283
|
-
registerTemplatePlugin: () =>
|
|
284
|
-
renderMessage: () =>
|
|
285
|
-
renderPromptParams: () =>
|
|
286
|
-
renderTemplateContent: () =>
|
|
288
|
+
registerTemplatePlugin: () => _chunkFZWPFCVEjs.registerTemplatePlugin,
|
|
289
|
+
renderMessage: () => _chunkFZWPFCVEjs.renderMessage,
|
|
290
|
+
renderPromptParams: () => _chunkFZWPFCVEjs.renderPromptParams,
|
|
291
|
+
renderTemplateContent: () => _chunkFZWPFCVEjs.renderTemplateContent,
|
|
287
292
|
reportFailures: () => reportFailures,
|
|
288
293
|
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: () =>
|
|
294
|
+
setFetch: () => _chunkFZWPFCVEjs.setFetch,
|
|
295
|
+
setMaskingFunction: () => _chunkFZWPFCVEjs.setMaskingFunction,
|
|
296
|
+
spanComponentsToObjectId: () => _chunkFZWPFCVEjs.spanComponentsToObjectId,
|
|
297
|
+
startSpan: () => _chunkFZWPFCVEjs.startSpan,
|
|
298
|
+
summarize: () => _chunkFZWPFCVEjs.summarize,
|
|
299
|
+
templateRegistry: () => _chunkFZWPFCVEjs.templateRegistry,
|
|
300
|
+
toolFunctionDefinitionSchema: () => _chunkFZWPFCVEjs.ToolFunctionDefinition,
|
|
301
|
+
traceable: () => _chunkFZWPFCVEjs.traceable,
|
|
302
|
+
traced: () => _chunkFZWPFCVEjs.traced,
|
|
303
|
+
updateSpan: () => _chunkFZWPFCVEjs.updateSpan,
|
|
304
|
+
uploadLogs3OverflowPayload: () => _chunkFZWPFCVEjs.uploadLogs3OverflowPayload,
|
|
305
|
+
utf8ByteLength: () => _chunkFZWPFCVEjs.utf8ByteLength,
|
|
306
|
+
withCurrent: () => _chunkFZWPFCVEjs.withCurrent,
|
|
307
|
+
withDataset: () => _chunkFZWPFCVEjs.withDataset,
|
|
308
|
+
withExperiment: () => _chunkFZWPFCVEjs.withExperiment,
|
|
309
|
+
withLogger: () => _chunkFZWPFCVEjs.withLogger,
|
|
310
|
+
withParent: () => _chunkFZWPFCVEjs.withParent,
|
|
306
311
|
wrapAISDK: () => wrapAISDK,
|
|
307
312
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
308
313
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -317,7 +322,10 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
317
322
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
318
323
|
wrapGroq: () => wrapGroq,
|
|
319
324
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
320
|
-
|
|
325
|
+
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
326
|
+
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
327
|
+
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
328
|
+
wrapMastraAgent: () => _chunkFZWPFCVEjs.wrapMastraAgent,
|
|
321
329
|
wrapMistral: () => wrapMistral,
|
|
322
330
|
wrapOpenAI: () => wrapOpenAI,
|
|
323
331
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
@@ -326,7 +334,7 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
326
334
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
327
335
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
328
336
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
329
|
-
wrapTraced: () =>
|
|
337
|
+
wrapTraced: () => _chunkFZWPFCVEjs.wrapTraced,
|
|
330
338
|
wrapVitest: () => wrapVitest
|
|
331
339
|
});
|
|
332
340
|
|
|
@@ -334,7 +342,7 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
334
342
|
var _v3 = require('zod/v3');
|
|
335
343
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
336
344
|
async function registerSandbox(options) {
|
|
337
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
345
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, )));
|
|
338
346
|
await state.login({
|
|
339
347
|
apiKey: options.apiKey,
|
|
340
348
|
appUrl: options.appUrl,
|
|
@@ -375,7 +383,7 @@ async function registerSandbox(options) {
|
|
|
375
383
|
evaluatorDefinitions
|
|
376
384
|
)) {
|
|
377
385
|
const functionName = evalName;
|
|
378
|
-
const functionSlug =
|
|
386
|
+
const functionSlug = _chunkFZWPFCVEjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
379
387
|
const functionDef = {
|
|
380
388
|
project_id: projectId,
|
|
381
389
|
org_name: state.orgName,
|
|
@@ -446,7 +454,7 @@ async function invoke(args) {
|
|
|
446
454
|
projectId,
|
|
447
455
|
...functionIdArgs
|
|
448
456
|
} = args;
|
|
449
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
457
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, )));
|
|
450
458
|
await state.login({
|
|
451
459
|
orgName,
|
|
452
460
|
apiKey,
|
|
@@ -454,8 +462,8 @@ async function invoke(args) {
|
|
|
454
462
|
forceLogin,
|
|
455
463
|
fetch
|
|
456
464
|
});
|
|
457
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
458
|
-
const functionId =
|
|
465
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkFZWPFCVEjs.getSpanParentObject.call(void 0, ).export();
|
|
466
|
+
const functionId = _chunkFZWPFCVEjs.FunctionId.safeParse({
|
|
459
467
|
function_id: functionIdArgs.function_id,
|
|
460
468
|
project_name: functionIdArgs.projectName,
|
|
461
469
|
slug: functionIdArgs.slug,
|
|
@@ -498,7 +506,7 @@ async function invoke(args) {
|
|
|
498
506
|
if (!resp.body) {
|
|
499
507
|
throw new Error("Received empty stream body");
|
|
500
508
|
}
|
|
501
|
-
return new (0,
|
|
509
|
+
return new (0, _chunkFZWPFCVEjs.BraintrustStream)(resp.body);
|
|
502
510
|
} else {
|
|
503
511
|
const data = await resp.json();
|
|
504
512
|
return schema ? schema.parse(data) : data;
|
|
@@ -510,7 +518,7 @@ function initFunction({
|
|
|
510
518
|
version,
|
|
511
519
|
state
|
|
512
520
|
}) {
|
|
513
|
-
const s = _nullishCoalesce(state, () => (
|
|
521
|
+
const s = _nullishCoalesce(state, () => ( _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, )));
|
|
514
522
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
515
523
|
const f = async (input) => {
|
|
516
524
|
return await invoke({
|
|
@@ -588,22 +596,22 @@ function responsesProxy(openai) {
|
|
|
588
596
|
if (name === "create" && typeof target.create === "function") {
|
|
589
597
|
return wrapResponsesAsync(
|
|
590
598
|
target.create.bind(target),
|
|
591
|
-
|
|
599
|
+
_chunkCDIKAHDZjs.openAIChannels.responsesCreate
|
|
592
600
|
);
|
|
593
601
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
594
602
|
return wrapResponsesSyncStream(
|
|
595
603
|
target.stream.bind(target),
|
|
596
|
-
|
|
604
|
+
_chunkCDIKAHDZjs.openAIChannels.responsesStream
|
|
597
605
|
);
|
|
598
606
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
599
607
|
return wrapResponsesAsync(
|
|
600
608
|
target.parse.bind(target),
|
|
601
|
-
|
|
609
|
+
_chunkCDIKAHDZjs.openAIChannels.responsesParse
|
|
602
610
|
);
|
|
603
611
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
604
612
|
return wrapResponsesAsync(
|
|
605
613
|
target.compact.bind(target),
|
|
606
|
-
|
|
614
|
+
_chunkCDIKAHDZjs.openAIChannels.responsesCompact
|
|
607
615
|
);
|
|
608
616
|
}
|
|
609
617
|
return Reflect.get(target, name, receiver);
|
|
@@ -747,7 +755,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
747
755
|
const { span_info, params } = splitSpanInfo(
|
|
748
756
|
allParams
|
|
749
757
|
);
|
|
750
|
-
return
|
|
758
|
+
return _chunkCDIKAHDZjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
751
759
|
async () => await completion(params),
|
|
752
760
|
{ arguments: [params], span_info }
|
|
753
761
|
);
|
|
@@ -758,7 +766,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
758
766
|
const { span_info, params } = splitSpanInfo(
|
|
759
767
|
allParams
|
|
760
768
|
);
|
|
761
|
-
return
|
|
769
|
+
return _chunkCDIKAHDZjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
762
770
|
() => completion(params),
|
|
763
771
|
{ arguments: [params], span_info }
|
|
764
772
|
);
|
|
@@ -774,7 +782,7 @@ function wrapChatCompletion(completion) {
|
|
|
774
782
|
if (!executionPromise) {
|
|
775
783
|
executionPromise = (async () => {
|
|
776
784
|
const traceContext = createChannelContext(
|
|
777
|
-
|
|
785
|
+
_chunkCDIKAHDZjs.openAIChannels.chatCompletionsCreate,
|
|
778
786
|
params,
|
|
779
787
|
span_info
|
|
780
788
|
);
|
|
@@ -784,7 +792,7 @@ function wrapChatCompletion(completion) {
|
|
|
784
792
|
options
|
|
785
793
|
);
|
|
786
794
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
787
|
-
|
|
795
|
+
_chunkCDIKAHDZjs.openAIChannels.chatCompletionsCreate,
|
|
788
796
|
traceContext,
|
|
789
797
|
completionPromise
|
|
790
798
|
);
|
|
@@ -795,7 +803,7 @@ function wrapChatCompletion(completion) {
|
|
|
795
803
|
options
|
|
796
804
|
);
|
|
797
805
|
const { data, response } = await tracePromiseWithResponse(
|
|
798
|
-
|
|
806
|
+
_chunkCDIKAHDZjs.openAIChannels.chatCompletionsCreate,
|
|
799
807
|
traceContext,
|
|
800
808
|
completionResponse
|
|
801
809
|
);
|
|
@@ -838,8 +846,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
838
846
|
return createLazyAPIPromise(ensureExecuted);
|
|
839
847
|
};
|
|
840
848
|
}
|
|
841
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
842
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
849
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkCDIKAHDZjs.openAIChannels.embeddingsCreate);
|
|
850
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkCDIKAHDZjs.openAIChannels.moderationsCreate);
|
|
843
851
|
|
|
844
852
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
845
853
|
function isModuleNamespace(obj) {
|
|
@@ -939,15 +947,15 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
939
947
|
};
|
|
940
948
|
function generateChannelForAgent(agentName) {
|
|
941
949
|
if (agentName === "ToolLoopAgent") {
|
|
942
|
-
return
|
|
950
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
943
951
|
}
|
|
944
|
-
return
|
|
952
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.agentGenerate;
|
|
945
953
|
}
|
|
946
954
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
947
955
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
948
956
|
return (params) => {
|
|
949
957
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
950
|
-
if (workflowAgent &&
|
|
958
|
+
if (workflowAgent && _chunkFZWPFCVEjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
951
959
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
952
960
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
953
961
|
}
|
|
@@ -966,12 +974,12 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
966
974
|
};
|
|
967
975
|
function streamChannelForAgent(agentName) {
|
|
968
976
|
if (agentName === "ToolLoopAgent") {
|
|
969
|
-
return
|
|
977
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.toolLoopAgentStream;
|
|
970
978
|
}
|
|
971
979
|
if (agentName === "WorkflowAgent") {
|
|
972
|
-
return
|
|
980
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.workflowAgentStream;
|
|
973
981
|
}
|
|
974
|
-
return
|
|
982
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.agentStream;
|
|
975
983
|
}
|
|
976
984
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
977
985
|
const wrapper = async function(allParams) {
|
|
@@ -995,7 +1003,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
995
1003
|
};
|
|
996
1004
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
997
1005
|
return makeGenerateTextWrapper(
|
|
998
|
-
|
|
1006
|
+
_chunkCDIKAHDZjs.aiSDKChannels.generateText,
|
|
999
1007
|
"generateText",
|
|
1000
1008
|
generateText,
|
|
1001
1009
|
{ aiSDK },
|
|
@@ -1004,7 +1012,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
1004
1012
|
};
|
|
1005
1013
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
1006
1014
|
return makeGenerateTextWrapper(
|
|
1007
|
-
|
|
1015
|
+
_chunkCDIKAHDZjs.aiSDKChannels.generateObject,
|
|
1008
1016
|
"generateObject",
|
|
1009
1017
|
generateObject,
|
|
1010
1018
|
{ aiSDK },
|
|
@@ -1033,7 +1041,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
1033
1041
|
};
|
|
1034
1042
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
1035
1043
|
return makeEmbedWrapper(
|
|
1036
|
-
|
|
1044
|
+
_chunkCDIKAHDZjs.aiSDKChannels.embed,
|
|
1037
1045
|
"embed",
|
|
1038
1046
|
embed,
|
|
1039
1047
|
{ aiSDK },
|
|
@@ -1042,7 +1050,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1042
1050
|
};
|
|
1043
1051
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1044
1052
|
return makeEmbedWrapper(
|
|
1045
|
-
|
|
1053
|
+
_chunkCDIKAHDZjs.aiSDKChannels.embedMany,
|
|
1046
1054
|
"embedMany",
|
|
1047
1055
|
embedMany,
|
|
1048
1056
|
{ aiSDK },
|
|
@@ -1053,7 +1061,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1053
1061
|
const wrapper = async function(allParams) {
|
|
1054
1062
|
const { span_info, ...params } = allParams;
|
|
1055
1063
|
const tracedParams = { ...params };
|
|
1056
|
-
return
|
|
1064
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.rerank.tracePromise(
|
|
1057
1065
|
() => rerank(tracedParams),
|
|
1058
1066
|
createAISDKChannelContext(tracedParams, {
|
|
1059
1067
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1092,7 +1100,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1092
1100
|
};
|
|
1093
1101
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1094
1102
|
return makeStreamWrapper(
|
|
1095
|
-
|
|
1103
|
+
_chunkCDIKAHDZjs.aiSDKChannels.streamText,
|
|
1096
1104
|
"streamText",
|
|
1097
1105
|
streamText,
|
|
1098
1106
|
{ aiSDK },
|
|
@@ -1101,7 +1109,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1101
1109
|
};
|
|
1102
1110
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1103
1111
|
return makeStreamWrapper(
|
|
1104
|
-
|
|
1112
|
+
_chunkCDIKAHDZjs.aiSDKChannels.streamObject,
|
|
1105
1113
|
"streamObject",
|
|
1106
1114
|
streamObject,
|
|
1107
1115
|
{ aiSDK },
|
|
@@ -1172,14 +1180,14 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1172
1180
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1173
1181
|
// propagate those via async local storage
|
|
1174
1182
|
async doGenerate(options) {
|
|
1175
|
-
const span =
|
|
1183
|
+
const span = _chunkFZWPFCVEjs.startSpan.call(void 0, {
|
|
1176
1184
|
name: "Chat Completion",
|
|
1177
1185
|
spanAttributes: {
|
|
1178
1186
|
type: "llm"
|
|
1179
1187
|
}
|
|
1180
1188
|
});
|
|
1181
1189
|
const { prompt, mode, ...rest } = options;
|
|
1182
|
-
const startTime =
|
|
1190
|
+
const startTime = _chunkFZWPFCVEjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1183
1191
|
try {
|
|
1184
1192
|
const ret = await this.model.doGenerate(options);
|
|
1185
1193
|
span.log({
|
|
@@ -1191,12 +1199,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1191
1199
|
},
|
|
1192
1200
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1193
1201
|
metrics: {
|
|
1194
|
-
time_to_first_token:
|
|
1195
|
-
tokens: !
|
|
1202
|
+
time_to_first_token: _chunkFZWPFCVEjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1203
|
+
tokens: !_chunkFZWPFCVEjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1196
1204
|
prompt_tokens: _optionalChain([ret, 'access', _20 => _20.usage, 'optionalAccess', _21 => _21.promptTokens]),
|
|
1197
1205
|
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[
|
|
1206
|
+
cached: _chunkFZWPFCVEjs.parseCachedHeader.call(void 0,
|
|
1207
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[_chunkFZWPFCVEjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _27 => _27.rawResponse, 'optionalAccess', _28 => _28.headers, 'optionalAccess', _29 => _29[_chunkFZWPFCVEjs.LEGACY_CACHED_HEADER]])))
|
|
1200
1208
|
)
|
|
1201
1209
|
}
|
|
1202
1210
|
});
|
|
@@ -1207,8 +1215,8 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1207
1215
|
}
|
|
1208
1216
|
async doStream(options) {
|
|
1209
1217
|
const { prompt, mode, ...rest } = options;
|
|
1210
|
-
const startTime =
|
|
1211
|
-
const span =
|
|
1218
|
+
const startTime = _chunkFZWPFCVEjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1219
|
+
const span = _chunkFZWPFCVEjs.startSpan.call(void 0, {
|
|
1212
1220
|
name: "Chat Completion",
|
|
1213
1221
|
spanAttributes: {
|
|
1214
1222
|
type: "llm"
|
|
@@ -1242,7 +1250,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1242
1250
|
new TransformStream({
|
|
1243
1251
|
transform(chunk, controller) {
|
|
1244
1252
|
if (time_to_first_token === void 0) {
|
|
1245
|
-
time_to_first_token =
|
|
1253
|
+
time_to_first_token = _chunkFZWPFCVEjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1246
1254
|
span.log({ metrics: { time_to_first_token } });
|
|
1247
1255
|
}
|
|
1248
1256
|
switch (chunk.type) {
|
|
@@ -1287,11 +1295,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1287
1295
|
),
|
|
1288
1296
|
metrics: {
|
|
1289
1297
|
time_to_first_token,
|
|
1290
|
-
tokens: !
|
|
1298
|
+
tokens: !_chunkFZWPFCVEjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1291
1299
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _30 => _30.promptTokens]),
|
|
1292
1300
|
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[
|
|
1301
|
+
cached: _chunkFZWPFCVEjs.parseCachedHeader.call(void 0,
|
|
1302
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[_chunkFZWPFCVEjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _35 => _35.rawResponse, 'optionalAccess', _36 => _36.headers, 'optionalAccess', _37 => _37[_chunkFZWPFCVEjs.LEGACY_CACHED_HEADER]])))
|
|
1295
1303
|
)
|
|
1296
1304
|
}
|
|
1297
1305
|
});
|
|
@@ -1476,12 +1484,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1476
1484
|
anthropicMetadata.usage,
|
|
1477
1485
|
"cache_creation_input_tokens"
|
|
1478
1486
|
) || 0;
|
|
1479
|
-
const cacheTokens =
|
|
1487
|
+
const cacheTokens = _chunkFZWPFCVEjs.extractAnthropicCacheTokens.call(void 0,
|
|
1480
1488
|
cacheReadTokens,
|
|
1481
1489
|
cacheCreationTokens
|
|
1482
1490
|
);
|
|
1483
1491
|
Object.assign(metrics, cacheTokens);
|
|
1484
|
-
Object.assign(metrics,
|
|
1492
|
+
Object.assign(metrics, _chunkFZWPFCVEjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1485
1493
|
}
|
|
1486
1494
|
}
|
|
1487
1495
|
return metrics;
|
|
@@ -1553,7 +1561,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1553
1561
|
model: modelFromWrapGenerate
|
|
1554
1562
|
}) => {
|
|
1555
1563
|
const rawInput = extractInput(params);
|
|
1556
|
-
const processedInput =
|
|
1564
|
+
const processedInput = _chunkFZWPFCVEjs.processInputAttachments.call(void 0, rawInput);
|
|
1557
1565
|
const spanArgs = {
|
|
1558
1566
|
name: _optionalChain([config, 'access', _54 => _54.spanInfo, 'optionalAccess', _55 => _55.name]) || "ai-sdk.doGenerate",
|
|
1559
1567
|
spanAttributes: {
|
|
@@ -1568,7 +1576,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1568
1576
|
}
|
|
1569
1577
|
}
|
|
1570
1578
|
};
|
|
1571
|
-
const span =
|
|
1579
|
+
const span = _chunkFZWPFCVEjs.startSpan.call(void 0, spanArgs);
|
|
1572
1580
|
try {
|
|
1573
1581
|
const result = await doGenerate();
|
|
1574
1582
|
const metadata = {};
|
|
@@ -1615,7 +1623,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1615
1623
|
},
|
|
1616
1624
|
wrapStream: async ({ doStream, params }) => {
|
|
1617
1625
|
const rawInput = extractInput(params);
|
|
1618
|
-
const processedInput =
|
|
1626
|
+
const processedInput = _chunkFZWPFCVEjs.processInputAttachments.call(void 0, rawInput);
|
|
1619
1627
|
const spanArgs = {
|
|
1620
1628
|
name: _optionalChain([config, 'access', _63 => _63.spanInfo, 'optionalAccess', _64 => _64.name]) || "ai-sdk.doStream",
|
|
1621
1629
|
spanAttributes: {
|
|
@@ -1630,7 +1638,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1630
1638
|
}
|
|
1631
1639
|
}
|
|
1632
1640
|
};
|
|
1633
|
-
const span =
|
|
1641
|
+
const span = _chunkFZWPFCVEjs.startSpan.call(void 0, spanArgs);
|
|
1634
1642
|
try {
|
|
1635
1643
|
const { stream, ...rest } = await doStream();
|
|
1636
1644
|
const textChunks = [];
|
|
@@ -1728,6 +1736,1390 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1728
1736
|
};
|
|
1729
1737
|
}
|
|
1730
1738
|
|
|
1739
|
+
// src/instrumentation/plugins/eve-plugin.ts
|
|
1740
|
+
var EVE_TRACE_STATE_KEY = "braintrust.eve.tracing";
|
|
1741
|
+
var MAX_EVE_CACHE_ENTRIES = 1e4;
|
|
1742
|
+
var MAX_STORED_LLM_INPUTS = 100;
|
|
1743
|
+
var MAX_STORED_SPAN_REFERENCES = 1e4;
|
|
1744
|
+
var MAX_STORED_STEP_STARTS = 1e4;
|
|
1745
|
+
function braintrustEveHook(options) {
|
|
1746
|
+
const state = options.defineState(EVE_TRACE_STATE_KEY, emptyEveTraceState);
|
|
1747
|
+
const bridge = new EveBridge(state);
|
|
1748
|
+
return {
|
|
1749
|
+
events: {
|
|
1750
|
+
"*": async (event, ctx) => {
|
|
1751
|
+
await bridge.handle(event, ctx, options.metadata);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
function braintrustEveInstrumentation(options) {
|
|
1757
|
+
const state = options.defineState(EVE_TRACE_STATE_KEY, emptyEveTraceState);
|
|
1758
|
+
return {
|
|
1759
|
+
events: {
|
|
1760
|
+
"step.started": (input) => {
|
|
1761
|
+
try {
|
|
1762
|
+
captureEveModelInput(state, input);
|
|
1763
|
+
} catch (error) {
|
|
1764
|
+
_chunkFZWPFCVEjs.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
},
|
|
1768
|
+
recordInputs: false,
|
|
1769
|
+
recordOutputs: false,
|
|
1770
|
+
setup: options.setup
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
function isEveHandleMessageStreamEvent(event) {
|
|
1774
|
+
return _chunkFZWPFCVEjs.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1775
|
+
}
|
|
1776
|
+
var ResumedEveSpan = class {
|
|
1777
|
+
constructor(reference) {
|
|
1778
|
+
this.reference = reference;
|
|
1779
|
+
this.endTime = reference.endTime;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
get rootSpanId() {
|
|
1783
|
+
return this.reference.rootSpanId;
|
|
1784
|
+
}
|
|
1785
|
+
get spanId() {
|
|
1786
|
+
return this.reference.spanId;
|
|
1787
|
+
}
|
|
1788
|
+
log(event) {
|
|
1789
|
+
const metrics = {
|
|
1790
|
+
..._optionalChain([this, 'access', _69 => _69.reference, 'access', _70 => _70.startEvent, 'optionalAccess', _71 => _71.metrics]),
|
|
1791
|
+
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1792
|
+
...event.metrics
|
|
1793
|
+
};
|
|
1794
|
+
_chunkFZWPFCVEjs.updateSpan.call(void 0, {
|
|
1795
|
+
exported: this.reference.exported,
|
|
1796
|
+
...this.reference.startEvent,
|
|
1797
|
+
...event,
|
|
1798
|
+
...Object.keys(metrics).length > 0 ? { metrics } : {}
|
|
1799
|
+
});
|
|
1800
|
+
}
|
|
1801
|
+
end(args) {
|
|
1802
|
+
if (this.endTime === void 0) {
|
|
1803
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.endTime]), () => ( _chunkFZWPFCVEjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1804
|
+
this.log({ metrics: { end: this.endTime } });
|
|
1805
|
+
}
|
|
1806
|
+
return this.endTime;
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
var EveBridge = (_class = class {
|
|
1810
|
+
constructor(state) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
1811
|
+
this.state = state;
|
|
1812
|
+
}
|
|
1813
|
+
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1814
|
+
__init2() {this.completedToolKeys = new (0, _chunkFZWPFCVEjs.LRUCache)({
|
|
1815
|
+
max: MAX_EVE_CACHE_ENTRIES
|
|
1816
|
+
})}
|
|
1817
|
+
__init3() {this.toolsByCallKey = new (0, _chunkFZWPFCVEjs.LRUCache)({
|
|
1818
|
+
max: MAX_EVE_CACHE_ENTRIES
|
|
1819
|
+
})}
|
|
1820
|
+
__init4() {this.turnsByKey = new (0, _chunkFZWPFCVEjs.LRUCache)({
|
|
1821
|
+
max: MAX_EVE_CACHE_ENTRIES
|
|
1822
|
+
})}
|
|
1823
|
+
async startEveSpan(args) {
|
|
1824
|
+
const rowId = _optionalChain([args, 'optionalAccess', _73 => _73.event, 'optionalAccess', _74 => _74.id]);
|
|
1825
|
+
const reference = typeof rowId === "string" && readEveTraceState(this.state).spanReferences.find(
|
|
1826
|
+
(candidate) => candidate.rowId === rowId
|
|
1827
|
+
);
|
|
1828
|
+
if (reference) {
|
|
1829
|
+
return new ResumedEveSpan(reference);
|
|
1830
|
+
}
|
|
1831
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.startTime]), () => ( _chunkFZWPFCVEjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1832
|
+
const parentSpanIds = _optionalChain([args, 'optionalAccess', _76 => _76.parentSpanIds]);
|
|
1833
|
+
const startEvent = {
|
|
1834
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1835
|
+
metrics: { start: startTime },
|
|
1836
|
+
span_attributes: {
|
|
1837
|
+
..._optionalChain([args, 'optionalAccess', _77 => _77.name]) ? { name: args.name } : {},
|
|
1838
|
+
..._optionalChain([args, 'optionalAccess', _78 => _78.type]) ? { type: args.type } : {},
|
|
1839
|
+
..._optionalChain([args, 'optionalAccess', _79 => _79.spanAttributes])
|
|
1840
|
+
},
|
|
1841
|
+
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
1842
|
+
};
|
|
1843
|
+
const span = _chunkFZWPFCVEjs.withCurrent.call(void 0,
|
|
1844
|
+
_chunkFZWPFCVEjs.NOOP_SPAN,
|
|
1845
|
+
() => _chunkFZWPFCVEjs._internalStartSpanWithInitialMerge.call(void 0, { ...args, startTime })
|
|
1846
|
+
);
|
|
1847
|
+
if (typeof rowId !== "string") {
|
|
1848
|
+
return span;
|
|
1849
|
+
}
|
|
1850
|
+
try {
|
|
1851
|
+
const exported = await span.export();
|
|
1852
|
+
const reference2 = {
|
|
1853
|
+
exported,
|
|
1854
|
+
rootSpanId: span.rootSpanId,
|
|
1855
|
+
rowId,
|
|
1856
|
+
spanId: span.spanId,
|
|
1857
|
+
startEvent
|
|
1858
|
+
};
|
|
1859
|
+
this.state.update((current) => {
|
|
1860
|
+
const normalized = normalizeEveTraceState(current);
|
|
1861
|
+
return normalized.spanReferences.some(
|
|
1862
|
+
(candidate) => candidate.rowId === rowId
|
|
1863
|
+
) ? normalized : {
|
|
1864
|
+
...normalized,
|
|
1865
|
+
spanReferences: [...normalized.spanReferences, reference2].slice(
|
|
1866
|
+
-MAX_STORED_SPAN_REFERENCES
|
|
1867
|
+
)
|
|
1868
|
+
};
|
|
1869
|
+
});
|
|
1870
|
+
} catch (error) {
|
|
1871
|
+
_chunkFZWPFCVEjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
1872
|
+
}
|
|
1873
|
+
return span;
|
|
1874
|
+
}
|
|
1875
|
+
async startEveChildSpan(parent, args) {
|
|
1876
|
+
return await this.startEveSpan({
|
|
1877
|
+
...args,
|
|
1878
|
+
parentSpanIds: {
|
|
1879
|
+
rootSpanId: parent.rootSpanId,
|
|
1880
|
+
spanId: parent.spanId
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
stepOrdinal(event) {
|
|
1885
|
+
let ordinal = 0;
|
|
1886
|
+
this.state.update((current) => {
|
|
1887
|
+
const state = normalizeEveTraceState(current);
|
|
1888
|
+
const previous = state.stepStarts.filter(
|
|
1889
|
+
(entry) => entry.turnId === event.data.turnId && entry.stepIndex === event.data.stepIndex
|
|
1890
|
+
).at(-1);
|
|
1891
|
+
if (_optionalChain([previous, 'optionalAccess', _80 => _80.open])) {
|
|
1892
|
+
ordinal = previous.ordinal;
|
|
1893
|
+
return state;
|
|
1894
|
+
}
|
|
1895
|
+
ordinal = state.stepStarts.filter(
|
|
1896
|
+
(entry) => entry.turnId === event.data.turnId
|
|
1897
|
+
).length;
|
|
1898
|
+
return {
|
|
1899
|
+
...state,
|
|
1900
|
+
stepStarts: [
|
|
1901
|
+
...state.stepStarts,
|
|
1902
|
+
{
|
|
1903
|
+
open: true,
|
|
1904
|
+
ordinal,
|
|
1905
|
+
stepIndex: event.data.stepIndex,
|
|
1906
|
+
turnId: event.data.turnId
|
|
1907
|
+
}
|
|
1908
|
+
].slice(-MAX_STORED_STEP_STARTS)
|
|
1909
|
+
};
|
|
1910
|
+
});
|
|
1911
|
+
return ordinal;
|
|
1912
|
+
}
|
|
1913
|
+
markStepEnded(turnId, stepIndex) {
|
|
1914
|
+
this.state.update((current) => {
|
|
1915
|
+
const state = normalizeEveTraceState(current);
|
|
1916
|
+
let index = -1;
|
|
1917
|
+
for (let i = state.stepStarts.length - 1; i >= 0; i--) {
|
|
1918
|
+
const entry = state.stepStarts[i];
|
|
1919
|
+
if (_optionalChain([entry, 'optionalAccess', _81 => _81.turnId]) === turnId && entry.stepIndex === stepIndex) {
|
|
1920
|
+
index = i;
|
|
1921
|
+
break;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
if (index < 0 || !_optionalChain([state, 'access', _82 => _82.stepStarts, 'access', _83 => _83[index], 'optionalAccess', _84 => _84.open])) {
|
|
1925
|
+
return state;
|
|
1926
|
+
}
|
|
1927
|
+
return {
|
|
1928
|
+
...state,
|
|
1929
|
+
stepStarts: state.stepStarts.map(
|
|
1930
|
+
(entry, entryIndex) => entryIndex === index ? { ...entry, open: false } : entry
|
|
1931
|
+
)
|
|
1932
|
+
};
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
async handle(event, ctx, hookMetadata) {
|
|
1936
|
+
if (!isEveHandleMessageStreamEvent(event)) {
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
const run = async () => {
|
|
1940
|
+
try {
|
|
1941
|
+
if (!await this.handleEvent(event, ctx, hookMetadata)) {
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
if (event.type === "session.failed") {
|
|
1945
|
+
const sessionId2 = event.data.sessionId || sessionIdFromContext(ctx);
|
|
1946
|
+
await this.flushInstrumentation();
|
|
1947
|
+
if (sessionId2) {
|
|
1948
|
+
this.cleanupSession(sessionId2);
|
|
1949
|
+
}
|
|
1950
|
+
} else if (event.type === "session.completed") {
|
|
1951
|
+
const sessionId2 = sessionIdFromContext(ctx);
|
|
1952
|
+
await this.flushInstrumentation();
|
|
1953
|
+
if (sessionId2) {
|
|
1954
|
+
this.cleanupSession(sessionId2);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
} catch (error) {
|
|
1958
|
+
_chunkFZWPFCVEjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
1962
|
+
if (!sessionId) {
|
|
1963
|
+
await run();
|
|
1964
|
+
return;
|
|
1965
|
+
}
|
|
1966
|
+
const previous = this.eventQueuesBySession.get(sessionId);
|
|
1967
|
+
const queued = previous ? previous.then(run) : run();
|
|
1968
|
+
this.eventQueuesBySession.set(sessionId, queued);
|
|
1969
|
+
try {
|
|
1970
|
+
await queued;
|
|
1971
|
+
} finally {
|
|
1972
|
+
if (this.eventQueuesBySession.get(sessionId) === queued) {
|
|
1973
|
+
this.eventQueuesBySession.delete(sessionId);
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
async handleEvent(event, ctx, hookMetadata) {
|
|
1978
|
+
switch (event.type) {
|
|
1979
|
+
case "session.started":
|
|
1980
|
+
this.handleSessionStarted(event, ctx, hookMetadata);
|
|
1981
|
+
return true;
|
|
1982
|
+
case "turn.started":
|
|
1983
|
+
await this.handleTurnStarted(event, ctx, hookMetadata);
|
|
1984
|
+
return true;
|
|
1985
|
+
case "message.received":
|
|
1986
|
+
await this.handleMessageReceived(event, ctx, hookMetadata);
|
|
1987
|
+
return true;
|
|
1988
|
+
case "step.started":
|
|
1989
|
+
await this.handleStepStarted(event, ctx, hookMetadata);
|
|
1990
|
+
return true;
|
|
1991
|
+
case "message.completed":
|
|
1992
|
+
this.handleMessageCompleted(event, ctx);
|
|
1993
|
+
return true;
|
|
1994
|
+
case "result.completed":
|
|
1995
|
+
this.handleResultCompleted(event, ctx);
|
|
1996
|
+
return true;
|
|
1997
|
+
case "actions.requested":
|
|
1998
|
+
await this.handleActionsRequested(event, ctx, hookMetadata);
|
|
1999
|
+
return true;
|
|
2000
|
+
case "action.result":
|
|
2001
|
+
await this.handleActionResult(event, ctx, hookMetadata);
|
|
2002
|
+
return true;
|
|
2003
|
+
case "subagent.called":
|
|
2004
|
+
await this.handleSubagentCalled(event, ctx, hookMetadata);
|
|
2005
|
+
return true;
|
|
2006
|
+
case "subagent.completed":
|
|
2007
|
+
await this.handleSubagentCompleted(event, ctx, hookMetadata);
|
|
2008
|
+
return true;
|
|
2009
|
+
case "step.completed":
|
|
2010
|
+
this.handleStepCompleted(event, ctx);
|
|
2011
|
+
return true;
|
|
2012
|
+
case "step.failed":
|
|
2013
|
+
this.handleStepFailed(event, ctx);
|
|
2014
|
+
return true;
|
|
2015
|
+
case "turn.completed":
|
|
2016
|
+
this.handleTurnCompleted(event, ctx);
|
|
2017
|
+
return true;
|
|
2018
|
+
case "turn.failed":
|
|
2019
|
+
this.handleTurnFailed(event, ctx);
|
|
2020
|
+
return true;
|
|
2021
|
+
case "session.failed":
|
|
2022
|
+
this.handleSessionFailed(event, ctx);
|
|
2023
|
+
return true;
|
|
2024
|
+
case "session.completed":
|
|
2025
|
+
this.handleSessionCompleted(event, ctx);
|
|
2026
|
+
return true;
|
|
2027
|
+
default:
|
|
2028
|
+
return false;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
handleSessionStarted(event, ctx, hookMetadata) {
|
|
2032
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2033
|
+
if (!sessionId) {
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
const metadata = {
|
|
2037
|
+
..._nullishCoalesce(hookMetadata, () => ( {})),
|
|
2038
|
+
...modelMetadataFromRuntime(event.data.runtime)
|
|
2039
|
+
};
|
|
2040
|
+
this.state.update((current) => {
|
|
2041
|
+
const normalized = normalizeEveTraceState(current);
|
|
2042
|
+
return {
|
|
2043
|
+
...normalized,
|
|
2044
|
+
metadata: { ...normalized.metadata, ...metadata }
|
|
2045
|
+
};
|
|
2046
|
+
});
|
|
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 key = turnKey(sessionId, event.data.turnId);
|
|
2065
|
+
const metadata = {
|
|
2066
|
+
...readEveTraceState(this.state).metadata,
|
|
2067
|
+
..._nullishCoalesce(hookMetadata, () => ( {})),
|
|
2068
|
+
"eve.session_id": sessionId
|
|
2069
|
+
};
|
|
2070
|
+
const existing = this.turnsByKey.get(key);
|
|
2071
|
+
if (existing) {
|
|
2072
|
+
existing.metadata = { ...existing.metadata, ...metadata };
|
|
2073
|
+
existing.span.log({ metadata: existing.metadata });
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
const span = await this.startTurnSpan(sessionId, event, ctx, metadata);
|
|
2077
|
+
span.log({ metadata });
|
|
2078
|
+
this.turnsByKey.set(key, {
|
|
2079
|
+
key,
|
|
2080
|
+
metadata,
|
|
2081
|
+
metrics: {},
|
|
2082
|
+
span,
|
|
2083
|
+
stepsByIndex: /* @__PURE__ */ new Map(),
|
|
2084
|
+
turnId: event.data.turnId
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
async handleMessageReceived(event, ctx, hookMetadata) {
|
|
2088
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2089
|
+
if (!turn) {
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
const input = [{ content: event.data.message, role: "user" }];
|
|
2093
|
+
turn.span.log({ input });
|
|
2094
|
+
}
|
|
2095
|
+
async handleStepStarted(event, ctx, hookMetadata) {
|
|
2096
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2097
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2098
|
+
if (!turn || !sessionId) {
|
|
2099
|
+
return;
|
|
2100
|
+
}
|
|
2101
|
+
const existing = turn.stepsByIndex.get(event.data.stepIndex);
|
|
2102
|
+
if (existing) {
|
|
2103
|
+
existing.span.log({
|
|
2104
|
+
...existing.input !== void 0 ? { input: existing.input } : {},
|
|
2105
|
+
metadata: existing.metadata,
|
|
2106
|
+
metrics: existing.metrics,
|
|
2107
|
+
output: existing.output
|
|
2108
|
+
});
|
|
2109
|
+
const endTime = eventTime(event);
|
|
2110
|
+
existing.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2111
|
+
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2112
|
+
}
|
|
2113
|
+
const stepOrdinal = this.stepOrdinal(event);
|
|
2114
|
+
const metadata = { ...turn.metadata };
|
|
2115
|
+
const input = consumeCapturedEveModelInput(
|
|
2116
|
+
this.state,
|
|
2117
|
+
sessionId,
|
|
2118
|
+
event.data.turnId,
|
|
2119
|
+
event.data.stepIndex
|
|
2120
|
+
);
|
|
2121
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2122
|
+
"step",
|
|
2123
|
+
sessionId,
|
|
2124
|
+
event.data.turnId,
|
|
2125
|
+
String(stepOrdinal)
|
|
2126
|
+
);
|
|
2127
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2128
|
+
event: {
|
|
2129
|
+
id: eventId,
|
|
2130
|
+
...input !== void 0 ? { input } : {},
|
|
2131
|
+
metadata
|
|
2132
|
+
},
|
|
2133
|
+
name: "eve.step",
|
|
2134
|
+
spanAttributes: { type: "llm" /* LLM */ },
|
|
2135
|
+
spanId,
|
|
2136
|
+
startTime: eventTime(event)
|
|
2137
|
+
});
|
|
2138
|
+
span.log({ ...input !== void 0 ? { input } : {}, metadata });
|
|
2139
|
+
turn.stepsByIndex.set(event.data.stepIndex, {
|
|
2140
|
+
...input !== void 0 ? { input } : {},
|
|
2141
|
+
metadata,
|
|
2142
|
+
metrics: {},
|
|
2143
|
+
span
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
handleMessageCompleted(event, ctx) {
|
|
2147
|
+
const step = this.stepForEvent(event, ctx);
|
|
2148
|
+
if (!step) {
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2151
|
+
const existingMessage = Array.isArray(step.output) && _chunkFZWPFCVEjs.isObject.call(void 0, step.output[0]) ? step.output[0].message : void 0;
|
|
2152
|
+
const existingToolCalls = _chunkFZWPFCVEjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2153
|
+
step.output = [
|
|
2154
|
+
{
|
|
2155
|
+
finish_reason: normalizedFinishReason(event.data.finishReason),
|
|
2156
|
+
index: 0,
|
|
2157
|
+
message: {
|
|
2158
|
+
content: event.data.message,
|
|
2159
|
+
role: "assistant",
|
|
2160
|
+
...Array.isArray(existingToolCalls) ? { tool_calls: existingToolCalls } : {}
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
];
|
|
2164
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2165
|
+
if (turn && event.data.finishReason !== "tool-calls") {
|
|
2166
|
+
turn.output = event.data.message;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
handleResultCompleted(event, ctx) {
|
|
2170
|
+
const step = this.stepForEvent(event, ctx);
|
|
2171
|
+
if (step) {
|
|
2172
|
+
step.output = [
|
|
2173
|
+
{
|
|
2174
|
+
finish_reason: "stop",
|
|
2175
|
+
index: 0,
|
|
2176
|
+
message: {
|
|
2177
|
+
content: event.data.result,
|
|
2178
|
+
role: "assistant"
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
];
|
|
2182
|
+
}
|
|
2183
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2184
|
+
if (turn) {
|
|
2185
|
+
turn.output = event.data.result;
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
async handleActionsRequested(event, ctx, hookMetadata) {
|
|
2189
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2190
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2191
|
+
if (!turn || !sessionId) {
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
const traceActions = event.data.actions.filter(isTraceableActionRequest);
|
|
2195
|
+
if (traceActions.length === 0) {
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
for (const action of traceActions) {
|
|
2199
|
+
if (isToolCallAction(action)) {
|
|
2200
|
+
await this.startRequestedTool(event, turn, sessionId, action);
|
|
2201
|
+
} else if (isLocalSubagentCallAction(action)) {
|
|
2202
|
+
await this.startRequestedSubagent(event, turn, sessionId, action);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
const step = turn.stepsByIndex.get(event.data.stepIndex);
|
|
2206
|
+
if (!step) {
|
|
2207
|
+
return;
|
|
2208
|
+
}
|
|
2209
|
+
const toolCallsById = /* @__PURE__ */ new Map();
|
|
2210
|
+
if (Array.isArray(step.output) && _chunkFZWPFCVEjs.isObject.call(void 0, step.output[0])) {
|
|
2211
|
+
const message = step.output[0]["message"];
|
|
2212
|
+
if (_chunkFZWPFCVEjs.isObject.call(void 0, message) && Array.isArray(message["tool_calls"])) {
|
|
2213
|
+
for (const toolCall of message["tool_calls"]) {
|
|
2214
|
+
if (_chunkFZWPFCVEjs.isObject.call(void 0, toolCall) && typeof toolCall["id"] === "string") {
|
|
2215
|
+
toolCallsById.set(toolCall["id"], toolCall);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
for (const action of traceActions) {
|
|
2221
|
+
const name = action.kind === "tool-call" ? action.toolName : _nullishCoalesce(_nullishCoalesce(action.subagentName, () => ( action.name)), () => ( "agent"));
|
|
2222
|
+
toolCallsById.set(action.callId, {
|
|
2223
|
+
function: {
|
|
2224
|
+
arguments: JSON.stringify(action.input),
|
|
2225
|
+
name
|
|
2226
|
+
},
|
|
2227
|
+
id: action.callId,
|
|
2228
|
+
type: "function"
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
step.output = [
|
|
2232
|
+
{
|
|
2233
|
+
finish_reason: "tool_calls",
|
|
2234
|
+
index: 0,
|
|
2235
|
+
message: {
|
|
2236
|
+
content: null,
|
|
2237
|
+
role: "assistant",
|
|
2238
|
+
tool_calls: [...toolCallsById.values()]
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
];
|
|
2242
|
+
step.span.log({ metadata: step.metadata, output: step.output });
|
|
2243
|
+
}
|
|
2244
|
+
async handleActionResult(event, ctx, hookMetadata) {
|
|
2245
|
+
if (isToolResult(event.data.result)) {
|
|
2246
|
+
await this.handleToolResult(event, ctx, event.data.result, hookMetadata);
|
|
2247
|
+
return;
|
|
2248
|
+
}
|
|
2249
|
+
if (isSubagentResult(event.data.result)) {
|
|
2250
|
+
await this.handleSubagentResult(
|
|
2251
|
+
event,
|
|
2252
|
+
ctx,
|
|
2253
|
+
event.data.result,
|
|
2254
|
+
hookMetadata
|
|
2255
|
+
);
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
async handleToolResult(event, ctx, result, hookMetadata) {
|
|
2259
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2260
|
+
if (!sessionId) {
|
|
2261
|
+
return;
|
|
2262
|
+
}
|
|
2263
|
+
const key = toolKey(sessionId, result.callId);
|
|
2264
|
+
if (this.completedToolKeys.has(key)) {
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
const tool = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticTool(event, ctx, result, hookMetadata)));
|
|
2268
|
+
if (!tool) {
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
const failed = event.data.status === "failed" || result.isError === true || event.data.error !== void 0;
|
|
2272
|
+
tool.span.log({
|
|
2273
|
+
...failed ? {
|
|
2274
|
+
error: actionResultError(event.data.error, result.output)
|
|
2275
|
+
} : {},
|
|
2276
|
+
metadata: tool.metadata,
|
|
2277
|
+
output: result.output
|
|
2278
|
+
});
|
|
2279
|
+
const endTime = eventTime(event);
|
|
2280
|
+
tool.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2281
|
+
this.toolsByCallKey.delete(key);
|
|
2282
|
+
this.completedToolKeys.set(key, true);
|
|
2283
|
+
}
|
|
2284
|
+
async handleSubagentCalled(event, ctx, hookMetadata) {
|
|
2285
|
+
if (_optionalChain([event, 'access', _85 => _85.data, 'access', _86 => _86.remote, 'optionalAccess', _87 => _87.url])) {
|
|
2286
|
+
return;
|
|
2287
|
+
}
|
|
2288
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2289
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2290
|
+
if (!turn || !sessionId) {
|
|
2291
|
+
return;
|
|
2292
|
+
}
|
|
2293
|
+
const key = toolKey(sessionId, event.data.callId);
|
|
2294
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2295
|
+
const existing = this.toolsByCallKey.get(key);
|
|
2296
|
+
if (existing) {
|
|
2297
|
+
existing.metadata = { ...existing.metadata, ...metadata };
|
|
2298
|
+
existing.span.log({ metadata: existing.metadata });
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
if (this.completedToolKeys.has(key)) {
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2305
|
+
"subagent",
|
|
2306
|
+
sessionId,
|
|
2307
|
+
event.data.callId
|
|
2308
|
+
);
|
|
2309
|
+
const pending = this.toolsByCallKey.get(key);
|
|
2310
|
+
if (pending || this.completedToolKeys.has(key)) {
|
|
2311
|
+
if (pending) {
|
|
2312
|
+
pending.metadata = { ...pending.metadata, ...metadata };
|
|
2313
|
+
pending.span.log({ metadata: pending.metadata });
|
|
2314
|
+
}
|
|
2315
|
+
return;
|
|
2316
|
+
}
|
|
2317
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2318
|
+
event: {
|
|
2319
|
+
id: eventId,
|
|
2320
|
+
metadata
|
|
2321
|
+
},
|
|
2322
|
+
name: _nullishCoalesce(event.data.toolName, () => ( event.data.name)),
|
|
2323
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2324
|
+
spanId,
|
|
2325
|
+
startTime: eventTime(event)
|
|
2326
|
+
});
|
|
2327
|
+
span.log({ metadata });
|
|
2328
|
+
this.toolsByCallKey.set(key, {
|
|
2329
|
+
metadata,
|
|
2330
|
+
span,
|
|
2331
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
async handleSubagentCompleted(event, ctx, hookMetadata) {
|
|
2335
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2336
|
+
if (!sessionId) {
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2339
|
+
const key = toolKey(sessionId, event.data.callId);
|
|
2340
|
+
if (this.completedToolKeys.has(key)) {
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
const subagent = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticSubagent(event, ctx, hookMetadata)));
|
|
2344
|
+
if (!subagent) {
|
|
2345
|
+
return;
|
|
2346
|
+
}
|
|
2347
|
+
subagent.span.log({
|
|
2348
|
+
...event.data.status === "failed" ? {
|
|
2349
|
+
error: actionResultError(event.data.error, event.data.output)
|
|
2350
|
+
} : {},
|
|
2351
|
+
metadata: subagent.metadata,
|
|
2352
|
+
...event.data.output !== void 0 ? { output: event.data.output } : {}
|
|
2353
|
+
});
|
|
2354
|
+
const endTime = eventTime(event);
|
|
2355
|
+
const recordedEndTime = subagent.span.end(
|
|
2356
|
+
endTime === void 0 ? void 0 : { endTime }
|
|
2357
|
+
);
|
|
2358
|
+
this.state.update((current) => {
|
|
2359
|
+
const normalized = normalizeEveTraceState(current);
|
|
2360
|
+
return {
|
|
2361
|
+
...normalized,
|
|
2362
|
+
spanReferences: normalized.spanReferences.map(
|
|
2363
|
+
(reference) => reference.spanId === subagent.span.spanId ? { ...reference, endTime: recordedEndTime } : reference
|
|
2364
|
+
)
|
|
2365
|
+
};
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
async handleSubagentResult(event, ctx, result, hookMetadata) {
|
|
2369
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2370
|
+
if (!sessionId) {
|
|
2371
|
+
return;
|
|
2372
|
+
}
|
|
2373
|
+
const key = toolKey(sessionId, result.callId);
|
|
2374
|
+
if (this.completedToolKeys.has(key)) {
|
|
2375
|
+
return;
|
|
2376
|
+
}
|
|
2377
|
+
const subagent = await _asyncNullishCoalesce(this.toolsByCallKey.get(key), async () => ( await this.startSyntheticSubagentResult(
|
|
2378
|
+
event,
|
|
2379
|
+
ctx,
|
|
2380
|
+
result,
|
|
2381
|
+
hookMetadata
|
|
2382
|
+
)));
|
|
2383
|
+
if (!subagent) {
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
const isError = event.data.status === "failed" || result.isError === true || event.data.error !== void 0;
|
|
2387
|
+
subagent.span.log({
|
|
2388
|
+
...isError ? {
|
|
2389
|
+
error: actionResultError(event.data.error, result.output)
|
|
2390
|
+
} : {},
|
|
2391
|
+
metadata: subagent.metadata,
|
|
2392
|
+
output: result.output
|
|
2393
|
+
});
|
|
2394
|
+
const endTime = eventTime(event);
|
|
2395
|
+
subagent.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2396
|
+
this.toolsByCallKey.delete(key);
|
|
2397
|
+
this.completedToolKeys.set(key, true);
|
|
2398
|
+
}
|
|
2399
|
+
handleStepCompleted(event, ctx) {
|
|
2400
|
+
const step = this.stepForEvent(event, ctx);
|
|
2401
|
+
if (!step) {
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
const usage = event.data.usage;
|
|
2405
|
+
const inputTokens = typeof _optionalChain([usage, 'optionalAccess', _88 => _88.inputTokens]) === "number" && Number.isFinite(usage.inputTokens) && usage.inputTokens >= 0 ? usage.inputTokens : void 0;
|
|
2406
|
+
const outputTokens = typeof _optionalChain([usage, 'optionalAccess', _89 => _89.outputTokens]) === "number" && Number.isFinite(usage.outputTokens) && usage.outputTokens >= 0 ? usage.outputTokens : void 0;
|
|
2407
|
+
const cacheReadTokens = typeof _optionalChain([usage, 'optionalAccess', _90 => _90.cacheReadTokens]) === "number" && Number.isFinite(usage.cacheReadTokens) && usage.cacheReadTokens >= 0 ? usage.cacheReadTokens : void 0;
|
|
2408
|
+
const cacheWriteTokens = typeof _optionalChain([usage, 'optionalAccess', _91 => _91.cacheWriteTokens]) === "number" && Number.isFinite(usage.cacheWriteTokens) && usage.cacheWriteTokens >= 0 ? usage.cacheWriteTokens : void 0;
|
|
2409
|
+
const costUsd = typeof _optionalChain([usage, 'optionalAccess', _92 => _92.costUsd]) === "number" && Number.isFinite(usage.costUsd) && usage.costUsd >= 0 ? usage.costUsd : void 0;
|
|
2410
|
+
const total = inputTokens !== void 0 && outputTokens !== void 0 ? inputTokens + outputTokens : void 0;
|
|
2411
|
+
const metrics = {
|
|
2412
|
+
...inputTokens !== void 0 ? { prompt_tokens: inputTokens } : {},
|
|
2413
|
+
...outputTokens !== void 0 ? { completion_tokens: outputTokens } : {},
|
|
2414
|
+
...total !== void 0 ? { tokens: total } : {},
|
|
2415
|
+
...cacheReadTokens !== void 0 ? { prompt_cached_tokens: cacheReadTokens } : {},
|
|
2416
|
+
...cacheWriteTokens !== void 0 ? { prompt_cache_creation_tokens: cacheWriteTokens } : {},
|
|
2417
|
+
...costUsd !== void 0 ? { estimated_cost: costUsd } : {}
|
|
2418
|
+
};
|
|
2419
|
+
step.metrics = { ...step.metrics, ...metrics };
|
|
2420
|
+
if (Array.isArray(step.output) && _chunkFZWPFCVEjs.isObject.call(void 0, step.output[0])) {
|
|
2421
|
+
const finishReason = step.output[0].finish_reason;
|
|
2422
|
+
if (typeof finishReason !== "string") {
|
|
2423
|
+
step.output[0].finish_reason = normalizedFinishReason(
|
|
2424
|
+
event.data.finishReason
|
|
2425
|
+
);
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
step.span.log({
|
|
2429
|
+
...step.input !== void 0 ? { input: step.input } : {},
|
|
2430
|
+
metadata: step.metadata,
|
|
2431
|
+
metrics,
|
|
2432
|
+
output: step.output
|
|
2433
|
+
});
|
|
2434
|
+
const endTime = eventTime(event);
|
|
2435
|
+
step.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2436
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2437
|
+
if (turn) {
|
|
2438
|
+
for (const [key, value] of Object.entries(metrics)) {
|
|
2439
|
+
turn.metrics[key] = (_nullishCoalesce(turn.metrics[key], () => ( 0))) + value;
|
|
2440
|
+
}
|
|
2441
|
+
turn.stepsByIndex.delete(event.data.stepIndex);
|
|
2442
|
+
}
|
|
2443
|
+
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2444
|
+
}
|
|
2445
|
+
handleStepFailed(event, ctx) {
|
|
2446
|
+
const step = this.stepForEvent(event, ctx);
|
|
2447
|
+
if (step) {
|
|
2448
|
+
step.span.log({
|
|
2449
|
+
error: errorFromMessage(
|
|
2450
|
+
event.data.message,
|
|
2451
|
+
event.data.code,
|
|
2452
|
+
event.data.details
|
|
2453
|
+
)
|
|
2454
|
+
});
|
|
2455
|
+
const endTime = eventTime(event);
|
|
2456
|
+
step.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2457
|
+
}
|
|
2458
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2459
|
+
_optionalChain([turn, 'optionalAccess', _93 => _93.stepsByIndex, 'access', _94 => _94.delete, 'call', _95 => _95(event.data.stepIndex)]);
|
|
2460
|
+
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2461
|
+
}
|
|
2462
|
+
handleTurnCompleted(event, ctx) {
|
|
2463
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2464
|
+
if (!turn) {
|
|
2465
|
+
return;
|
|
2466
|
+
}
|
|
2467
|
+
this.finalizeTurn(turn, {
|
|
2468
|
+
endTime: eventTime(event)
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
handleTurnFailed(event, ctx) {
|
|
2472
|
+
const turn = this.turnForEvent(event, ctx);
|
|
2473
|
+
if (!turn) {
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
this.finalizeTurn(turn, {
|
|
2477
|
+
endTime: eventTime(event),
|
|
2478
|
+
error: errorFromMessage(
|
|
2479
|
+
event.data.message,
|
|
2480
|
+
event.data.code,
|
|
2481
|
+
event.data.details
|
|
2482
|
+
)
|
|
2483
|
+
});
|
|
2484
|
+
}
|
|
2485
|
+
handleSessionFailed(event, ctx) {
|
|
2486
|
+
const sessionId = event.data.sessionId || sessionIdFromContext(ctx);
|
|
2487
|
+
if (!sessionId) {
|
|
2488
|
+
return;
|
|
2489
|
+
}
|
|
2490
|
+
const error = errorFromMessage(
|
|
2491
|
+
event.data.message,
|
|
2492
|
+
event.data.code,
|
|
2493
|
+
event.data.details
|
|
2494
|
+
);
|
|
2495
|
+
for (const [key, turn] of this.turnsByKey) {
|
|
2496
|
+
if (!key.startsWith(`${sessionId}:`)) {
|
|
2497
|
+
continue;
|
|
2498
|
+
}
|
|
2499
|
+
this.finalizeTurn(turn, {
|
|
2500
|
+
endTime: eventTime(event),
|
|
2501
|
+
error
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
for (const [key, tool] of this.toolsByCallKey) {
|
|
2505
|
+
if (key.startsWith(`${sessionId}:`)) {
|
|
2506
|
+
const endTime = eventTime(event);
|
|
2507
|
+
if (!tool.endedByTurn) {
|
|
2508
|
+
tool.span.log({ metadata: tool.metadata });
|
|
2509
|
+
tool.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2510
|
+
tool.endedByTurn = true;
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
handleSessionCompleted(event, ctx) {
|
|
2516
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2517
|
+
if (!sessionId) {
|
|
2518
|
+
return;
|
|
2519
|
+
}
|
|
2520
|
+
for (const [key, turn] of this.turnsByKey) {
|
|
2521
|
+
if (!key.startsWith(`${sessionId}:`)) {
|
|
2522
|
+
continue;
|
|
2523
|
+
}
|
|
2524
|
+
this.finalizeTurn(turn, {
|
|
2525
|
+
endTime: eventTime(event)
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
for (const [key, tool] of this.toolsByCallKey) {
|
|
2529
|
+
if (key.startsWith(`${sessionId}:`) && !tool.endedByTurn) {
|
|
2530
|
+
const endTime = eventTime(event);
|
|
2531
|
+
tool.span.log({ metadata: tool.metadata });
|
|
2532
|
+
tool.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2533
|
+
tool.endedByTurn = true;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
async ensureTurn(event, ctx, hookMetadata) {
|
|
2538
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2539
|
+
if (!sessionId) {
|
|
2540
|
+
return void 0;
|
|
2541
|
+
}
|
|
2542
|
+
const key = turnKey(sessionId, event.data.turnId);
|
|
2543
|
+
const existing = this.turnsByKey.get(key);
|
|
2544
|
+
if (existing) {
|
|
2545
|
+
return existing;
|
|
2546
|
+
}
|
|
2547
|
+
const metadata = {
|
|
2548
|
+
...readEveTraceState(this.state).metadata,
|
|
2549
|
+
..._nullishCoalesce(hookMetadata, () => ( {})),
|
|
2550
|
+
"eve.session_id": sessionId
|
|
2551
|
+
};
|
|
2552
|
+
const span = await this.startTurnSpan(sessionId, event, ctx, metadata);
|
|
2553
|
+
span.log({ metadata });
|
|
2554
|
+
const state = {
|
|
2555
|
+
key,
|
|
2556
|
+
metadata,
|
|
2557
|
+
metrics: {},
|
|
2558
|
+
span,
|
|
2559
|
+
stepsByIndex: /* @__PURE__ */ new Map(),
|
|
2560
|
+
turnId: event.data.turnId
|
|
2561
|
+
};
|
|
2562
|
+
this.turnsByKey.set(key, state);
|
|
2563
|
+
return state;
|
|
2564
|
+
}
|
|
2565
|
+
async startRequestedTool(event, turn, sessionId, action) {
|
|
2566
|
+
const key = toolKey(sessionId, action.callId);
|
|
2567
|
+
if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
|
|
2568
|
+
return;
|
|
2569
|
+
}
|
|
2570
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2571
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2572
|
+
"tool",
|
|
2573
|
+
sessionId,
|
|
2574
|
+
event.data.turnId,
|
|
2575
|
+
action.callId
|
|
2576
|
+
);
|
|
2577
|
+
if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2581
|
+
event: {
|
|
2582
|
+
id: eventId,
|
|
2583
|
+
input: action.input,
|
|
2584
|
+
metadata
|
|
2585
|
+
},
|
|
2586
|
+
name: action.toolName,
|
|
2587
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2588
|
+
spanId,
|
|
2589
|
+
startTime: eventTime(event)
|
|
2590
|
+
});
|
|
2591
|
+
span.log({ input: action.input, metadata });
|
|
2592
|
+
this.toolsByCallKey.set(key, {
|
|
2593
|
+
metadata,
|
|
2594
|
+
span,
|
|
2595
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
async startRequestedSubagent(event, turn, sessionId, action) {
|
|
2599
|
+
const key = toolKey(sessionId, action.callId);
|
|
2600
|
+
if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
const name = _nullishCoalesce(_nullishCoalesce(action.subagentName, () => ( action.name)), () => ( "agent"));
|
|
2604
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2605
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2606
|
+
"subagent",
|
|
2607
|
+
sessionId,
|
|
2608
|
+
action.callId
|
|
2609
|
+
);
|
|
2610
|
+
if (this.toolsByCallKey.has(key) || this.completedToolKeys.has(key)) {
|
|
2611
|
+
return;
|
|
2612
|
+
}
|
|
2613
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2614
|
+
event: {
|
|
2615
|
+
id: eventId,
|
|
2616
|
+
input: action.input,
|
|
2617
|
+
metadata
|
|
2618
|
+
},
|
|
2619
|
+
name,
|
|
2620
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2621
|
+
spanId,
|
|
2622
|
+
startTime: eventTime(event)
|
|
2623
|
+
});
|
|
2624
|
+
span.log({ input: action.input, metadata });
|
|
2625
|
+
this.toolsByCallKey.set(key, {
|
|
2626
|
+
metadata,
|
|
2627
|
+
span,
|
|
2628
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2631
|
+
async startSyntheticTool(event, ctx, result, hookMetadata) {
|
|
2632
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2633
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2634
|
+
if (!turn || !sessionId) {
|
|
2635
|
+
return void 0;
|
|
2636
|
+
}
|
|
2637
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2638
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2639
|
+
"tool",
|
|
2640
|
+
sessionId,
|
|
2641
|
+
event.data.turnId,
|
|
2642
|
+
result.callId
|
|
2643
|
+
);
|
|
2644
|
+
const existing = this.toolsByCallKey.get(toolKey(sessionId, result.callId));
|
|
2645
|
+
if (existing) {
|
|
2646
|
+
return existing;
|
|
2647
|
+
}
|
|
2648
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2649
|
+
event: {
|
|
2650
|
+
id: eventId,
|
|
2651
|
+
metadata
|
|
2652
|
+
},
|
|
2653
|
+
name: result.toolName,
|
|
2654
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2655
|
+
spanId,
|
|
2656
|
+
startTime: eventTime(event)
|
|
2657
|
+
});
|
|
2658
|
+
span.log({ metadata });
|
|
2659
|
+
const state = {
|
|
2660
|
+
metadata,
|
|
2661
|
+
span,
|
|
2662
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2663
|
+
};
|
|
2664
|
+
this.toolsByCallKey.set(toolKey(sessionId, result.callId), state);
|
|
2665
|
+
return state;
|
|
2666
|
+
}
|
|
2667
|
+
async startSyntheticSubagent(event, ctx, hookMetadata) {
|
|
2668
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2669
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2670
|
+
if (!turn || !sessionId) {
|
|
2671
|
+
return void 0;
|
|
2672
|
+
}
|
|
2673
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2674
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2675
|
+
"subagent",
|
|
2676
|
+
sessionId,
|
|
2677
|
+
event.data.callId
|
|
2678
|
+
);
|
|
2679
|
+
const existing = this.toolsByCallKey.get(
|
|
2680
|
+
toolKey(sessionId, event.data.callId)
|
|
2681
|
+
);
|
|
2682
|
+
if (existing) {
|
|
2683
|
+
return existing;
|
|
2684
|
+
}
|
|
2685
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2686
|
+
event: {
|
|
2687
|
+
id: eventId,
|
|
2688
|
+
metadata
|
|
2689
|
+
},
|
|
2690
|
+
name: event.data.subagentName,
|
|
2691
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2692
|
+
spanId,
|
|
2693
|
+
startTime: eventTime(event)
|
|
2694
|
+
});
|
|
2695
|
+
span.log({ metadata });
|
|
2696
|
+
const state = {
|
|
2697
|
+
metadata,
|
|
2698
|
+
span,
|
|
2699
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2700
|
+
};
|
|
2701
|
+
this.toolsByCallKey.set(toolKey(sessionId, event.data.callId), state);
|
|
2702
|
+
return state;
|
|
2703
|
+
}
|
|
2704
|
+
async startSyntheticSubagentResult(event, ctx, result, hookMetadata) {
|
|
2705
|
+
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
2706
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2707
|
+
if (!turn || !sessionId) {
|
|
2708
|
+
return void 0;
|
|
2709
|
+
}
|
|
2710
|
+
const metadata = toolMetadataFromTurn(turn);
|
|
2711
|
+
const { rowId: eventId, spanId } = await generateEveIds(
|
|
2712
|
+
"subagent",
|
|
2713
|
+
sessionId,
|
|
2714
|
+
result.callId
|
|
2715
|
+
);
|
|
2716
|
+
const existing = this.toolsByCallKey.get(toolKey(sessionId, result.callId));
|
|
2717
|
+
if (existing) {
|
|
2718
|
+
return existing;
|
|
2719
|
+
}
|
|
2720
|
+
const span = await this.startEveChildSpan(turn.span, {
|
|
2721
|
+
event: {
|
|
2722
|
+
id: eventId,
|
|
2723
|
+
metadata
|
|
2724
|
+
},
|
|
2725
|
+
name: result.subagentName,
|
|
2726
|
+
spanAttributes: { type: "tool" /* TOOL */ },
|
|
2727
|
+
spanId,
|
|
2728
|
+
startTime: eventTime(event)
|
|
2729
|
+
});
|
|
2730
|
+
span.log({ metadata });
|
|
2731
|
+
const state = {
|
|
2732
|
+
metadata,
|
|
2733
|
+
span,
|
|
2734
|
+
turnKey: turnKey(sessionId, event.data.turnId)
|
|
2735
|
+
};
|
|
2736
|
+
this.toolsByCallKey.set(toolKey(sessionId, result.callId), state);
|
|
2737
|
+
return state;
|
|
2738
|
+
}
|
|
2739
|
+
async startTurnSpan(sessionId, event, ctx, metadata) {
|
|
2740
|
+
const session = _chunkFZWPFCVEjs.isObject.call(void 0, ctx) ? ctx["session"] : void 0;
|
|
2741
|
+
const parent = _chunkFZWPFCVEjs.isObject.call(void 0, session) ? session["parent"] : void 0;
|
|
2742
|
+
const parentTurn = _chunkFZWPFCVEjs.isObject.call(void 0, parent) ? parent["turn"] : void 0;
|
|
2743
|
+
const parentLineage = _chunkFZWPFCVEjs.isObject.call(void 0, parent) && typeof parent["callId"] === "string" && typeof parent["sessionId"] === "string" && _chunkFZWPFCVEjs.isObject.call(void 0, parentTurn) && typeof parentTurn["id"] === "string" ? {
|
|
2744
|
+
callId: parent["callId"],
|
|
2745
|
+
sessionId: parent["sessionId"],
|
|
2746
|
+
turnId: parentTurn["id"]
|
|
2747
|
+
} : void 0;
|
|
2748
|
+
const [{ rowId: eventId, spanId }, rootSpanId, parentSpanId] = await Promise.all([
|
|
2749
|
+
generateEveIds("turn", sessionId, event.data.turnId),
|
|
2750
|
+
deterministicEveId(
|
|
2751
|
+
"eve:root",
|
|
2752
|
+
_nullishCoalesce(_optionalChain([parentLineage, 'optionalAccess', _96 => _96.sessionId]), () => ( sessionId)),
|
|
2753
|
+
_nullishCoalesce(_optionalChain([parentLineage, 'optionalAccess', _97 => _97.turnId]), () => ( event.data.turnId))
|
|
2754
|
+
),
|
|
2755
|
+
parentLineage ? deterministicEveId(
|
|
2756
|
+
"eve:subagent",
|
|
2757
|
+
parentLineage.sessionId,
|
|
2758
|
+
parentLineage.callId
|
|
2759
|
+
) : Promise.resolve(void 0)
|
|
2760
|
+
]);
|
|
2761
|
+
return await this.startEveSpan({
|
|
2762
|
+
event: {
|
|
2763
|
+
id: eventId,
|
|
2764
|
+
metadata
|
|
2765
|
+
},
|
|
2766
|
+
name: "eve.turn",
|
|
2767
|
+
parentSpanIds: parentSpanId ? { rootSpanId, spanId: parentSpanId } : { parentSpanIds: [], rootSpanId },
|
|
2768
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
2769
|
+
spanId,
|
|
2770
|
+
startTime: eventTime(event)
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
turnForEvent(event, ctx) {
|
|
2774
|
+
const sessionId = sessionIdFromContext(ctx);
|
|
2775
|
+
return sessionId ? this.turnsByKey.get(turnKey(sessionId, event.data.turnId)) : void 0;
|
|
2776
|
+
}
|
|
2777
|
+
stepForEvent(event, ctx) {
|
|
2778
|
+
return _optionalChain([this, 'access', _98 => _98.turnForEvent, 'call', _99 => _99(event, ctx), 'optionalAccess', _100 => _100.stepsByIndex, 'access', _101 => _101.get, 'call', _102 => _102(
|
|
2779
|
+
event.data.stepIndex
|
|
2780
|
+
)]);
|
|
2781
|
+
}
|
|
2782
|
+
finalizeTurn(turn, args) {
|
|
2783
|
+
const { endTime } = args;
|
|
2784
|
+
for (const step of turn.stepsByIndex.values()) {
|
|
2785
|
+
step.span.log({
|
|
2786
|
+
...step.input !== void 0 ? { input: step.input } : {},
|
|
2787
|
+
metadata: step.metadata,
|
|
2788
|
+
metrics: step.metrics,
|
|
2789
|
+
output: step.output
|
|
2790
|
+
});
|
|
2791
|
+
step.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2792
|
+
}
|
|
2793
|
+
turn.stepsByIndex.clear();
|
|
2794
|
+
for (const tool of this.toolsByCallKey.values()) {
|
|
2795
|
+
if (tool.turnKey !== turn.key) {
|
|
2796
|
+
continue;
|
|
2797
|
+
}
|
|
2798
|
+
if (tool.endedByTurn) {
|
|
2799
|
+
continue;
|
|
2800
|
+
}
|
|
2801
|
+
tool.span.log({ metadata: tool.metadata });
|
|
2802
|
+
tool.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2803
|
+
tool.endedByTurn = true;
|
|
2804
|
+
}
|
|
2805
|
+
if (args.error) {
|
|
2806
|
+
turn.span.log({ error: args.error });
|
|
2807
|
+
} else {
|
|
2808
|
+
turn.span.log({
|
|
2809
|
+
metadata: turn.metadata,
|
|
2810
|
+
metrics: turn.metrics,
|
|
2811
|
+
output: turn.output
|
|
2812
|
+
});
|
|
2813
|
+
}
|
|
2814
|
+
turn.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2815
|
+
this.turnsByKey.delete(turn.key);
|
|
2816
|
+
this.state.update((current) => {
|
|
2817
|
+
const normalized = normalizeEveTraceState(current);
|
|
2818
|
+
return {
|
|
2819
|
+
...normalized,
|
|
2820
|
+
stepStarts: normalized.stepStarts.filter(
|
|
2821
|
+
(entry) => entry.turnId !== turn.turnId
|
|
2822
|
+
)
|
|
2823
|
+
};
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2826
|
+
cleanupSession(sessionId) {
|
|
2827
|
+
const keyPrefix = `${sessionId}:`;
|
|
2828
|
+
for (const key of this.turnsByKey.keys()) {
|
|
2829
|
+
if (key.startsWith(keyPrefix)) {
|
|
2830
|
+
this.turnsByKey.delete(key);
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
for (const key of this.toolsByCallKey.keys()) {
|
|
2834
|
+
if (key.startsWith(keyPrefix)) {
|
|
2835
|
+
this.toolsByCallKey.delete(key);
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
for (const key of this.completedToolKeys.keys()) {
|
|
2839
|
+
if (key.startsWith(keyPrefix)) {
|
|
2840
|
+
this.completedToolKeys.delete(key);
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
this.state.update(() => emptyEveTraceState());
|
|
2844
|
+
}
|
|
2845
|
+
async flushInstrumentation() {
|
|
2846
|
+
try {
|
|
2847
|
+
await _chunkFZWPFCVEjs.flush.call(void 0, );
|
|
2848
|
+
return true;
|
|
2849
|
+
} catch (error) {
|
|
2850
|
+
_chunkFZWPFCVEjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
2851
|
+
return false;
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
}, _class);
|
|
2855
|
+
function emptyEveTraceState() {
|
|
2856
|
+
return {
|
|
2857
|
+
llmInputs: [],
|
|
2858
|
+
metadata: {},
|
|
2859
|
+
spanReferences: [],
|
|
2860
|
+
stepStarts: []
|
|
2861
|
+
};
|
|
2862
|
+
}
|
|
2863
|
+
function normalizeEveTraceState(state) {
|
|
2864
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, state)) {
|
|
2865
|
+
return emptyEveTraceState();
|
|
2866
|
+
}
|
|
2867
|
+
const metadata = _chunkFZWPFCVEjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
2868
|
+
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
2869
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, entry)) {
|
|
2870
|
+
return [];
|
|
2871
|
+
}
|
|
2872
|
+
const exported = entry["exported"];
|
|
2873
|
+
const endTime = entry["endTime"];
|
|
2874
|
+
const rootSpanId = entry["rootSpanId"];
|
|
2875
|
+
const rowId = entry["rowId"];
|
|
2876
|
+
const spanId = entry["spanId"];
|
|
2877
|
+
const startEvent = entry["startEvent"];
|
|
2878
|
+
const startEventCreated = _chunkFZWPFCVEjs.isObject.call(void 0, startEvent) ? startEvent["created"] : void 0;
|
|
2879
|
+
const startEventMetrics = _chunkFZWPFCVEjs.isObject.call(void 0, startEvent) ? startEvent["metrics"] : void 0;
|
|
2880
|
+
const startEventSpanAttributes = _chunkFZWPFCVEjs.isObject.call(void 0, startEvent) ? startEvent["span_attributes"] : void 0;
|
|
2881
|
+
const startEventSpanParents = _chunkFZWPFCVEjs.isObject.call(void 0, startEvent) ? startEvent["span_parents"] : void 0;
|
|
2882
|
+
const normalizedStartEvent = typeof startEventCreated === "string" && _chunkFZWPFCVEjs.isObject.call(void 0, startEventMetrics) && typeof startEventMetrics["start"] === "number" && Number.isFinite(startEventMetrics["start"]) && _chunkFZWPFCVEjs.isObject.call(void 0, startEventSpanAttributes) && Array.isArray(startEventSpanParents) && startEventSpanParents.every(
|
|
2883
|
+
(parent) => typeof parent === "string"
|
|
2884
|
+
) ? {
|
|
2885
|
+
created: startEventCreated,
|
|
2886
|
+
metrics: { start: startEventMetrics["start"] },
|
|
2887
|
+
span_attributes: { ...startEventSpanAttributes },
|
|
2888
|
+
span_parents: [...startEventSpanParents]
|
|
2889
|
+
} : void 0;
|
|
2890
|
+
return typeof exported === "string" && typeof rootSpanId === "string" && typeof rowId === "string" && typeof spanId === "string" ? [
|
|
2891
|
+
{
|
|
2892
|
+
...typeof endTime === "number" && Number.isFinite(endTime) ? { endTime } : {},
|
|
2893
|
+
exported,
|
|
2894
|
+
rootSpanId,
|
|
2895
|
+
rowId,
|
|
2896
|
+
spanId,
|
|
2897
|
+
...normalizedStartEvent ? { startEvent: normalizedStartEvent } : {}
|
|
2898
|
+
}
|
|
2899
|
+
] : [];
|
|
2900
|
+
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
2901
|
+
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
2902
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, entry)) {
|
|
2903
|
+
return [];
|
|
2904
|
+
}
|
|
2905
|
+
const key = entry["key"];
|
|
2906
|
+
const input = entry["input"];
|
|
2907
|
+
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
2908
|
+
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
2909
|
+
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
2910
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, entry)) {
|
|
2911
|
+
return [];
|
|
2912
|
+
}
|
|
2913
|
+
const ordinal = entry["ordinal"];
|
|
2914
|
+
const open = entry["open"];
|
|
2915
|
+
const stepIndex = entry["stepIndex"];
|
|
2916
|
+
const turnId = entry["turnId"];
|
|
2917
|
+
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 }] : [];
|
|
2918
|
+
}).slice(-MAX_STORED_STEP_STARTS) : [];
|
|
2919
|
+
return { llmInputs, metadata: { ...metadata }, spanReferences, stepStarts };
|
|
2920
|
+
}
|
|
2921
|
+
function readEveTraceState(state) {
|
|
2922
|
+
try {
|
|
2923
|
+
return normalizeEveTraceState(state.get());
|
|
2924
|
+
} catch (e3) {
|
|
2925
|
+
return emptyEveTraceState();
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
function captureEveModelInput(state, input) {
|
|
2929
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, input)) {
|
|
2930
|
+
return;
|
|
2931
|
+
}
|
|
2932
|
+
const session = input["session"];
|
|
2933
|
+
const turn = input["turn"];
|
|
2934
|
+
const step = input["step"];
|
|
2935
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, session) || !_chunkFZWPFCVEjs.isObject.call(void 0, turn) || !_chunkFZWPFCVEjs.isObject.call(void 0, step)) {
|
|
2936
|
+
return;
|
|
2937
|
+
}
|
|
2938
|
+
const sessionId = session["id"];
|
|
2939
|
+
const turnId = turn["id"];
|
|
2940
|
+
const stepIndex = step["index"];
|
|
2941
|
+
if (typeof sessionId !== "string" || typeof turnId !== "string" || typeof stepIndex !== "number" || !Number.isInteger(stepIndex)) {
|
|
2942
|
+
return;
|
|
2943
|
+
}
|
|
2944
|
+
const captured = capturedModelInput(input["modelInput"]);
|
|
2945
|
+
if (!captured) {
|
|
2946
|
+
return;
|
|
2947
|
+
}
|
|
2948
|
+
const key = llmInputKey(sessionId, turnId, stepIndex);
|
|
2949
|
+
state.update((current) => {
|
|
2950
|
+
const normalized = normalizeEveTraceState(current);
|
|
2951
|
+
const llmInputs = [...normalized.llmInputs, { input: captured, key }];
|
|
2952
|
+
return {
|
|
2953
|
+
...normalized,
|
|
2954
|
+
llmInputs: llmInputs.slice(-MAX_STORED_LLM_INPUTS)
|
|
2955
|
+
};
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
2959
|
+
try {
|
|
2960
|
+
const key = llmInputKey(sessionId, turnId, stepIndex);
|
|
2961
|
+
let input;
|
|
2962
|
+
state.update((current) => {
|
|
2963
|
+
const normalized = normalizeEveTraceState(current);
|
|
2964
|
+
const index = normalized.llmInputs.findIndex(
|
|
2965
|
+
(candidate) => candidate.key === key
|
|
2966
|
+
);
|
|
2967
|
+
if (index < 0) {
|
|
2968
|
+
return normalized;
|
|
2969
|
+
}
|
|
2970
|
+
input = _optionalChain([normalized, 'access', _103 => _103.llmInputs, 'access', _104 => _104[index], 'optionalAccess', _105 => _105.input]);
|
|
2971
|
+
return {
|
|
2972
|
+
...normalized,
|
|
2973
|
+
llmInputs: normalized.llmInputs.filter(
|
|
2974
|
+
(_, candidateIndex) => candidateIndex !== index
|
|
2975
|
+
)
|
|
2976
|
+
};
|
|
2977
|
+
});
|
|
2978
|
+
return input;
|
|
2979
|
+
} catch (error) {
|
|
2980
|
+
_chunkFZWPFCVEjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
2981
|
+
return void 0;
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
function capturedModelInput(modelInput) {
|
|
2985
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, modelInput)) {
|
|
2986
|
+
return void 0;
|
|
2987
|
+
}
|
|
2988
|
+
const messages = modelInput["messages"];
|
|
2989
|
+
if (!Array.isArray(messages)) {
|
|
2990
|
+
return void 0;
|
|
2991
|
+
}
|
|
2992
|
+
const instructions = modelInput["instructions"];
|
|
2993
|
+
const value = [
|
|
2994
|
+
...instructions !== void 0 ? [{ content: instructions, role: "system" }] : [],
|
|
2995
|
+
...messages
|
|
2996
|
+
];
|
|
2997
|
+
try {
|
|
2998
|
+
const cloned = JSON.parse(JSON.stringify(value));
|
|
2999
|
+
if (!Array.isArray(cloned)) {
|
|
3000
|
+
return void 0;
|
|
3001
|
+
}
|
|
3002
|
+
return cloned;
|
|
3003
|
+
} catch (e4) {
|
|
3004
|
+
return void 0;
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
function isCapturedModelInput(input) {
|
|
3008
|
+
return Array.isArray(input);
|
|
3009
|
+
}
|
|
3010
|
+
function llmInputKey(sessionId, turnId, stepIndex) {
|
|
3011
|
+
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3012
|
+
}
|
|
3013
|
+
function modelMetadataFromRuntime(runtime) {
|
|
3014
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, runtime)) {
|
|
3015
|
+
return {};
|
|
3016
|
+
}
|
|
3017
|
+
const modelId = runtime["modelId"];
|
|
3018
|
+
return typeof modelId === "string" && !modelId.trim().startsWith("dynamic:") ? modelMetadataFromModelId(modelId) : {};
|
|
3019
|
+
}
|
|
3020
|
+
function modelMetadataFromModelId(modelId) {
|
|
3021
|
+
const normalized = modelId.trim();
|
|
3022
|
+
if (!normalized) {
|
|
3023
|
+
return {};
|
|
3024
|
+
}
|
|
3025
|
+
const slashIndex = normalized.indexOf("/");
|
|
3026
|
+
if (slashIndex > 0 && slashIndex < normalized.length - 1) {
|
|
3027
|
+
return {
|
|
3028
|
+
model: normalized.slice(slashIndex + 1),
|
|
3029
|
+
provider: normalized.slice(0, slashIndex)
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
return {
|
|
3033
|
+
model: normalized
|
|
3034
|
+
};
|
|
3035
|
+
}
|
|
3036
|
+
function sessionIdFromContext(ctx) {
|
|
3037
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, ctx)) {
|
|
3038
|
+
return void 0;
|
|
3039
|
+
}
|
|
3040
|
+
const session = ctx["session"];
|
|
3041
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, session)) {
|
|
3042
|
+
return void 0;
|
|
3043
|
+
}
|
|
3044
|
+
const id = session["id"];
|
|
3045
|
+
return typeof id === "string" ? id : void 0;
|
|
3046
|
+
}
|
|
3047
|
+
function toolMetadataFromTurn(turn) {
|
|
3048
|
+
const { model: _model, provider: _provider, ...metadata } = turn.metadata;
|
|
3049
|
+
return metadata;
|
|
3050
|
+
}
|
|
3051
|
+
function isToolCallAction(action) {
|
|
3052
|
+
return _chunkFZWPFCVEjs.isObject.call(void 0, action) && action["kind"] === "tool-call" && typeof action["callId"] === "string" && typeof action["toolName"] === "string" && _chunkFZWPFCVEjs.isObject.call(void 0, action["input"]);
|
|
3053
|
+
}
|
|
3054
|
+
function isLocalSubagentCallAction(action) {
|
|
3055
|
+
return _chunkFZWPFCVEjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkFZWPFCVEjs.isObject.call(void 0, action["input"]);
|
|
3056
|
+
}
|
|
3057
|
+
function isTraceableActionRequest(action) {
|
|
3058
|
+
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3059
|
+
}
|
|
3060
|
+
function isToolResult(result) {
|
|
3061
|
+
return _chunkFZWPFCVEjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3062
|
+
}
|
|
3063
|
+
function isSubagentResult(result) {
|
|
3064
|
+
return _chunkFZWPFCVEjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3065
|
+
}
|
|
3066
|
+
function normalizedFinishReason(finishReason) {
|
|
3067
|
+
switch (finishReason) {
|
|
3068
|
+
case "content-filter":
|
|
3069
|
+
return "content_filter";
|
|
3070
|
+
case "tool-calls":
|
|
3071
|
+
return "tool_calls";
|
|
3072
|
+
default:
|
|
3073
|
+
return finishReason;
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
function errorFromMessage(message, code, details) {
|
|
3077
|
+
const error = new Error(`${code}: ${message}`);
|
|
3078
|
+
if (details !== void 0) {
|
|
3079
|
+
error.cause = details;
|
|
3080
|
+
}
|
|
3081
|
+
return error;
|
|
3082
|
+
}
|
|
3083
|
+
function actionResultError(error, output) {
|
|
3084
|
+
if (error) {
|
|
3085
|
+
return errorFromMessage(error.message, error.code);
|
|
3086
|
+
}
|
|
3087
|
+
const result = new Error("Eve action failed");
|
|
3088
|
+
if (output !== void 0) {
|
|
3089
|
+
result.cause = output;
|
|
3090
|
+
}
|
|
3091
|
+
return result;
|
|
3092
|
+
}
|
|
3093
|
+
function eventTime(event) {
|
|
3094
|
+
if (!_optionalChain([event, 'access', _106 => _106.meta, 'optionalAccess', _107 => _107.at])) {
|
|
3095
|
+
return void 0;
|
|
3096
|
+
}
|
|
3097
|
+
const timestamp = Date.parse(event.meta.at);
|
|
3098
|
+
return Number.isFinite(timestamp) ? timestamp / 1e3 : void 0;
|
|
3099
|
+
}
|
|
3100
|
+
function turnKey(sessionId, turnId) {
|
|
3101
|
+
return `${sessionId}:${turnId}`;
|
|
3102
|
+
}
|
|
3103
|
+
function toolKey(sessionId, callId) {
|
|
3104
|
+
return `${sessionId}:${callId}`;
|
|
3105
|
+
}
|
|
3106
|
+
async function generateEveIds(kind, ...parts) {
|
|
3107
|
+
const [rowId, spanId] = await Promise.all([
|
|
3108
|
+
deterministicEveId(`eve:row:${kind}`, ...parts),
|
|
3109
|
+
deterministicEveId(`eve:${kind}`, ...parts)
|
|
3110
|
+
]);
|
|
3111
|
+
return { rowId, spanId };
|
|
3112
|
+
}
|
|
3113
|
+
async function deterministicEveId(...parts) {
|
|
3114
|
+
const data = new TextEncoder().encode(
|
|
3115
|
+
parts.map((part) => `${part.length}:${part}`).join("\0")
|
|
3116
|
+
);
|
|
3117
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", data);
|
|
3118
|
+
const bytes = Array.from(new Uint8Array(digest, 0, 16));
|
|
3119
|
+
const hex = bytes.map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3120
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
3121
|
+
}
|
|
3122
|
+
|
|
1731
3123
|
// src/typed-instrumentation-helpers.ts
|
|
1732
3124
|
var TypedApplyProxy = Proxy;
|
|
1733
3125
|
|
|
@@ -1769,7 +3161,7 @@ function messagesProxy(messages) {
|
|
|
1769
3161
|
return new Proxy(messages, {
|
|
1770
3162
|
get(target, prop, receiver) {
|
|
1771
3163
|
if (prop === "create") {
|
|
1772
|
-
return createProxy(target.create,
|
|
3164
|
+
return createProxy(target.create, _chunkCDIKAHDZjs.anthropicChannels.messagesCreate);
|
|
1773
3165
|
}
|
|
1774
3166
|
return Reflect.get(target, prop, receiver);
|
|
1775
3167
|
}
|
|
@@ -1779,7 +3171,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
1779
3171
|
return new Proxy(messages, {
|
|
1780
3172
|
get(target, prop, receiver) {
|
|
1781
3173
|
if (prop === "create") {
|
|
1782
|
-
return createProxy(target.create,
|
|
3174
|
+
return createProxy(target.create, _chunkCDIKAHDZjs.anthropicChannels.betaMessagesCreate);
|
|
1783
3175
|
}
|
|
1784
3176
|
if (prop === "toolRunner") {
|
|
1785
3177
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -1788,7 +3180,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
1788
3180
|
return toolRunnerProxy(
|
|
1789
3181
|
target.toolRunner,
|
|
1790
3182
|
anthropic,
|
|
1791
|
-
|
|
3183
|
+
_chunkCDIKAHDZjs.anthropicChannels.betaMessagesToolRunner
|
|
1792
3184
|
);
|
|
1793
3185
|
}
|
|
1794
3186
|
return Reflect.get(target, prop, receiver);
|
|
@@ -1845,11 +3237,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
1845
3237
|
...params,
|
|
1846
3238
|
options: {
|
|
1847
3239
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
1848
|
-
[
|
|
3240
|
+
[_chunkFZWPFCVEjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
1849
3241
|
}
|
|
1850
3242
|
};
|
|
1851
3243
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
1852
|
-
return
|
|
3244
|
+
return _chunkCDIKAHDZjs.claudeAgentSDKChannels.query.traceSync(
|
|
1853
3245
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
1854
3246
|
// The channel carries no extra context fields, but the generated
|
|
1855
3247
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -1877,7 +3269,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
1877
3269
|
}
|
|
1878
3270
|
const localToolMetadata = { toolName };
|
|
1879
3271
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
1880
|
-
wrappedArgs[handlerIndex] =
|
|
3272
|
+
wrappedArgs[handlerIndex] = _chunkFZWPFCVEjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
1881
3273
|
originalHandler,
|
|
1882
3274
|
() => localToolMetadata
|
|
1883
3275
|
);
|
|
@@ -1895,8 +3287,8 @@ function wrapCreateSdkMcpServer(createSdkMcpServerFn, localToolMetadataByTool, d
|
|
|
1895
3287
|
apply(target, thisArg, argArray) {
|
|
1896
3288
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
1897
3289
|
const config = argArray[0];
|
|
1898
|
-
const serverName = _optionalChain([config, 'optionalAccess',
|
|
1899
|
-
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess',
|
|
3290
|
+
const serverName = _optionalChain([config, 'optionalAccess', _108 => _108.name]);
|
|
3291
|
+
if (typeof serverName === "string" && Array.isArray(_optionalChain([config, 'optionalAccess', _109 => _109.tools]))) {
|
|
1900
3292
|
for (const tool of config.tools) {
|
|
1901
3293
|
if (!tool || typeof tool !== "object") {
|
|
1902
3294
|
continue;
|
|
@@ -1990,7 +3382,7 @@ function isModuleNamespace2(obj) {
|
|
|
1990
3382
|
if (!obj || typeof obj !== "object") {
|
|
1991
3383
|
return false;
|
|
1992
3384
|
}
|
|
1993
|
-
if (_optionalChain([obj, 'access',
|
|
3385
|
+
if (_optionalChain([obj, 'access', _110 => _110.constructor, 'optionalAccess', _111 => _111.name]) === "Module") {
|
|
1994
3386
|
return true;
|
|
1995
3387
|
}
|
|
1996
3388
|
const keys = Object.keys(obj);
|
|
@@ -2060,7 +3452,7 @@ function wrapCodexThread(thread) {
|
|
|
2060
3452
|
if (prop === "run" && typeof value === "function") {
|
|
2061
3453
|
return function(input, turnOptions) {
|
|
2062
3454
|
const args = [input, turnOptions];
|
|
2063
|
-
return
|
|
3455
|
+
return _chunkCDIKAHDZjs.openAICodexChannels.run.tracePromise(
|
|
2064
3456
|
() => Reflect.apply(value, target, args),
|
|
2065
3457
|
{
|
|
2066
3458
|
arguments: args,
|
|
@@ -2073,7 +3465,7 @@ function wrapCodexThread(thread) {
|
|
|
2073
3465
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
2074
3466
|
return function(input, turnOptions) {
|
|
2075
3467
|
const args = [input, turnOptions];
|
|
2076
|
-
return
|
|
3468
|
+
return _chunkCDIKAHDZjs.openAICodexChannels.runStreamed.tracePromise(
|
|
2077
3469
|
() => Reflect.apply(value, target, args),
|
|
2078
3470
|
{
|
|
2079
3471
|
arguments: args,
|
|
@@ -2120,7 +3512,7 @@ function isModuleNamespace3(obj) {
|
|
|
2120
3512
|
if (!obj || typeof obj !== "object") {
|
|
2121
3513
|
return false;
|
|
2122
3514
|
}
|
|
2123
|
-
if (_optionalChain([obj, 'access',
|
|
3515
|
+
if (_optionalChain([obj, 'access', _112 => _112.constructor, 'optionalAccess', _113 => _113.name]) === "Module") {
|
|
2124
3516
|
return true;
|
|
2125
3517
|
}
|
|
2126
3518
|
const keys = Object.keys(obj);
|
|
@@ -2141,7 +3533,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2141
3533
|
if (prop === "create" && typeof value === "function") {
|
|
2142
3534
|
const wrapped = async function(options) {
|
|
2143
3535
|
const args = [options];
|
|
2144
|
-
return
|
|
3536
|
+
return _chunkCDIKAHDZjs.cursorSDKChannels.create.tracePromise(
|
|
2145
3537
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
2146
3538
|
{ arguments: args }
|
|
2147
3539
|
);
|
|
@@ -2152,7 +3544,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2152
3544
|
if (prop === "resume" && typeof value === "function") {
|
|
2153
3545
|
const wrapped = async function(agentId, options) {
|
|
2154
3546
|
const args = [agentId, options];
|
|
2155
|
-
return
|
|
3547
|
+
return _chunkCDIKAHDZjs.cursorSDKChannels.resume.tracePromise(
|
|
2156
3548
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
2157
3549
|
{ arguments: args }
|
|
2158
3550
|
);
|
|
@@ -2163,7 +3555,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2163
3555
|
if (prop === "prompt" && typeof value === "function") {
|
|
2164
3556
|
const wrapped = async function(message, options) {
|
|
2165
3557
|
const args = [message, options];
|
|
2166
|
-
return
|
|
3558
|
+
return _chunkCDIKAHDZjs.cursorSDKChannels.prompt.tracePromise(
|
|
2167
3559
|
() => Reflect.apply(value, target, args),
|
|
2168
3560
|
{ arguments: args }
|
|
2169
3561
|
);
|
|
@@ -2196,7 +3588,7 @@ function wrapCursorAgent(agent) {
|
|
|
2196
3588
|
if (prop === "send" && typeof value === "function") {
|
|
2197
3589
|
return function(message, options) {
|
|
2198
3590
|
const args = [message, options];
|
|
2199
|
-
return
|
|
3591
|
+
return _chunkCDIKAHDZjs.cursorSDKChannels.send.tracePromise(
|
|
2200
3592
|
() => Reflect.apply(value, target, args),
|
|
2201
3593
|
{
|
|
2202
3594
|
agent: target,
|
|
@@ -2246,7 +3638,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
2246
3638
|
...descriptor,
|
|
2247
3639
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
2248
3640
|
const args = [text, options];
|
|
2249
|
-
return
|
|
3641
|
+
return _chunkCDIKAHDZjs.piCodingAgentChannels.prompt.tracePromise(
|
|
2250
3642
|
() => Reflect.apply(originalPrompt, this, args),
|
|
2251
3643
|
{
|
|
2252
3644
|
arguments: args,
|
|
@@ -2304,7 +3696,7 @@ function isModuleNamespace4(obj) {
|
|
|
2304
3696
|
if (!obj || typeof obj !== "object") {
|
|
2305
3697
|
return false;
|
|
2306
3698
|
}
|
|
2307
|
-
if (_optionalChain([obj, 'access',
|
|
3699
|
+
if (_optionalChain([obj, 'access', _114 => _114.constructor, 'optionalAccess', _115 => _115.name]) === "Module") {
|
|
2308
3700
|
return true;
|
|
2309
3701
|
}
|
|
2310
3702
|
const keys = Object.keys(obj);
|
|
@@ -2366,7 +3758,7 @@ function wrapAgentInstance(agent) {
|
|
|
2366
3758
|
if (prop === "stream" && typeof value === "function") {
|
|
2367
3759
|
return function(args, options) {
|
|
2368
3760
|
const callArgs = [args, options];
|
|
2369
|
-
return
|
|
3761
|
+
return _chunkCDIKAHDZjs.strandsAgentSDKChannels.agentStream.traceSync(
|
|
2370
3762
|
() => Reflect.apply(value, target, callArgs),
|
|
2371
3763
|
{
|
|
2372
3764
|
agent: proxy,
|
|
@@ -2402,7 +3794,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
2402
3794
|
if (prop === "stream" && typeof value === "function") {
|
|
2403
3795
|
return function(input, options) {
|
|
2404
3796
|
const callArgs = [input, options];
|
|
2405
|
-
const channel = kind === "graph" ?
|
|
3797
|
+
const channel = kind === "graph" ? _chunkCDIKAHDZjs.strandsAgentSDKChannels.graphStream : _chunkCDIKAHDZjs.strandsAgentSDKChannels.swarmStream;
|
|
2406
3798
|
return channel.traceSync(
|
|
2407
3799
|
() => Reflect.apply(value, target, callArgs),
|
|
2408
3800
|
{
|
|
@@ -2477,7 +3869,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2477
3869
|
}
|
|
2478
3870
|
if (prop === "interactions") {
|
|
2479
3871
|
const interactions = Reflect.get(target, prop, receiver);
|
|
2480
|
-
if (!
|
|
3872
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
2481
3873
|
return interactions;
|
|
2482
3874
|
}
|
|
2483
3875
|
if (interactions !== originalInteractions) {
|
|
@@ -2491,7 +3883,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2491
3883
|
});
|
|
2492
3884
|
}
|
|
2493
3885
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
2494
|
-
if (!
|
|
3886
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
2495
3887
|
return;
|
|
2496
3888
|
}
|
|
2497
3889
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -2524,7 +3916,7 @@ function wrapInteractions(interactions) {
|
|
|
2524
3916
|
}
|
|
2525
3917
|
function wrapGenerateContent(original) {
|
|
2526
3918
|
return function(params) {
|
|
2527
|
-
return
|
|
3919
|
+
return _chunkCDIKAHDZjs.googleGenAIChannels.generateContent.tracePromise(
|
|
2528
3920
|
() => original(params),
|
|
2529
3921
|
{ arguments: [params] }
|
|
2530
3922
|
);
|
|
@@ -2532,7 +3924,7 @@ function wrapGenerateContent(original) {
|
|
|
2532
3924
|
}
|
|
2533
3925
|
function wrapGenerateContentStream(original) {
|
|
2534
3926
|
return function(params) {
|
|
2535
|
-
return
|
|
3927
|
+
return _chunkCDIKAHDZjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
2536
3928
|
() => original(params),
|
|
2537
3929
|
{ arguments: [params] }
|
|
2538
3930
|
);
|
|
@@ -2540,7 +3932,7 @@ function wrapGenerateContentStream(original) {
|
|
|
2540
3932
|
}
|
|
2541
3933
|
function wrapEmbedContent(original) {
|
|
2542
3934
|
return function(params) {
|
|
2543
|
-
return
|
|
3935
|
+
return _chunkCDIKAHDZjs.googleGenAIChannels.embedContent.tracePromise(
|
|
2544
3936
|
() => original(params),
|
|
2545
3937
|
{ arguments: [params] }
|
|
2546
3938
|
);
|
|
@@ -2552,7 +3944,7 @@ function wrapInteractionCreate(original) {
|
|
|
2552
3944
|
return options === void 0 ? original(params) : original(params, options);
|
|
2553
3945
|
}
|
|
2554
3946
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
2555
|
-
return
|
|
3947
|
+
return _chunkCDIKAHDZjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
2556
3948
|
() => options === void 0 ? original(params) : original(params, options),
|
|
2557
3949
|
traceContext
|
|
2558
3950
|
);
|
|
@@ -2613,7 +4005,7 @@ function wrapRunnerInstance(runner) {
|
|
|
2613
4005
|
function wrapRunnerRunAsync(runner) {
|
|
2614
4006
|
const original = runner.runAsync.bind(runner);
|
|
2615
4007
|
return function(params) {
|
|
2616
|
-
return
|
|
4008
|
+
return _chunkCDIKAHDZjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
2617
4009
|
arguments: [params],
|
|
2618
4010
|
self: runner
|
|
2619
4011
|
});
|
|
@@ -2640,7 +4032,7 @@ function wrapAgentInstance2(agent) {
|
|
|
2640
4032
|
function wrapAgentRunAsync(agent) {
|
|
2641
4033
|
const original = agent.runAsync.bind(agent);
|
|
2642
4034
|
return function(parentContext) {
|
|
2643
|
-
return
|
|
4035
|
+
return _chunkCDIKAHDZjs.googleADKChannels.agentRunAsync.traceSync(
|
|
2644
4036
|
() => original(parentContext),
|
|
2645
4037
|
{ arguments: [parentContext], self: agent }
|
|
2646
4038
|
);
|
|
@@ -2667,7 +4059,7 @@ function wrapToolInstance(tool) {
|
|
|
2667
4059
|
function wrapToolRunAsync(tool) {
|
|
2668
4060
|
const original = tool.runAsync.bind(tool);
|
|
2669
4061
|
return function(req) {
|
|
2670
|
-
return
|
|
4062
|
+
return _chunkCDIKAHDZjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
2671
4063
|
arguments: [req],
|
|
2672
4064
|
self: tool
|
|
2673
4065
|
});
|
|
@@ -2779,7 +4171,7 @@ function patchGenkitRegistryLookup(registry) {
|
|
|
2779
4171
|
Object.defineProperty(registry, PATCHED_GENKIT_REGISTRY, {
|
|
2780
4172
|
value: true
|
|
2781
4173
|
});
|
|
2782
|
-
} catch (
|
|
4174
|
+
} catch (e5) {
|
|
2783
4175
|
}
|
|
2784
4176
|
}
|
|
2785
4177
|
function patchGenkitRegistryConstructor(registry) {
|
|
@@ -2810,31 +4202,31 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
2810
4202
|
Object.defineProperty(constructor, PATCHED_GENKIT_REGISTRY_CONSTRUCTOR, {
|
|
2811
4203
|
value: true
|
|
2812
4204
|
});
|
|
2813
|
-
} catch (
|
|
4205
|
+
} catch (e6) {
|
|
2814
4206
|
}
|
|
2815
4207
|
}
|
|
2816
4208
|
function wrapGenerate(generate) {
|
|
2817
|
-
return (input) =>
|
|
4209
|
+
return (input) => _chunkCDIKAHDZjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
2818
4210
|
arguments: [input]
|
|
2819
4211
|
});
|
|
2820
4212
|
}
|
|
2821
4213
|
function wrapGenerateStream(generateStream) {
|
|
2822
|
-
return (input) =>
|
|
4214
|
+
return (input) => _chunkCDIKAHDZjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
2823
4215
|
arguments: [input]
|
|
2824
4216
|
});
|
|
2825
4217
|
}
|
|
2826
4218
|
function wrapEmbed2(embed) {
|
|
2827
|
-
return (params) =>
|
|
4219
|
+
return (params) => _chunkCDIKAHDZjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
2828
4220
|
arguments: [params]
|
|
2829
4221
|
});
|
|
2830
4222
|
}
|
|
2831
4223
|
function wrapEmbedMany2(embedMany) {
|
|
2832
|
-
return (params) =>
|
|
4224
|
+
return (params) => _chunkCDIKAHDZjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
2833
4225
|
arguments: [params]
|
|
2834
4226
|
});
|
|
2835
4227
|
}
|
|
2836
4228
|
function wrapRun(run) {
|
|
2837
|
-
return (name, inputOrFn, maybeFn) =>
|
|
4229
|
+
return (name, inputOrFn, maybeFn) => _chunkCDIKAHDZjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
2838
4230
|
arguments: [name, inputOrFn, maybeFn]
|
|
2839
4231
|
});
|
|
2840
4232
|
}
|
|
@@ -2873,13 +4265,13 @@ function isGenkitAction(value) {
|
|
|
2873
4265
|
return typeof value === "function" && "__action" in value;
|
|
2874
4266
|
}
|
|
2875
4267
|
function traceActionRun(action, run) {
|
|
2876
|
-
return (input, options) =>
|
|
4268
|
+
return (input, options) => _chunkCDIKAHDZjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
2877
4269
|
arguments: [input, options],
|
|
2878
4270
|
self: action
|
|
2879
4271
|
});
|
|
2880
4272
|
}
|
|
2881
4273
|
function traceActionStream(action, stream) {
|
|
2882
|
-
return (input, options) =>
|
|
4274
|
+
return (input, options) => _chunkCDIKAHDZjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
2883
4275
|
arguments: [input, options],
|
|
2884
4276
|
self: action
|
|
2885
4277
|
});
|
|
@@ -2925,10 +4317,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
2925
4317
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
2926
4318
|
}
|
|
2927
4319
|
function hasFunction2(value, methodName) {
|
|
2928
|
-
return
|
|
4320
|
+
return _chunkFZWPFCVEjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
2929
4321
|
}
|
|
2930
4322
|
function isSupportedHuggingFaceModule(value) {
|
|
2931
|
-
if (!
|
|
4323
|
+
if (!_chunkFZWPFCVEjs.isObject.call(void 0, value)) {
|
|
2932
4324
|
return false;
|
|
2933
4325
|
}
|
|
2934
4326
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -3036,14 +4428,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
3036
4428
|
const context = {
|
|
3037
4429
|
arguments: [traceParams]
|
|
3038
4430
|
};
|
|
3039
|
-
return
|
|
4431
|
+
return _chunkCDIKAHDZjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
3040
4432
|
() => original(params, options),
|
|
3041
4433
|
context
|
|
3042
4434
|
);
|
|
3043
4435
|
};
|
|
3044
4436
|
}
|
|
3045
4437
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
3046
|
-
return (params, options) =>
|
|
4438
|
+
return (params, options) => _chunkCDIKAHDZjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
3047
4439
|
() => original(params, options),
|
|
3048
4440
|
{
|
|
3049
4441
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -3056,14 +4448,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
3056
4448
|
const context = {
|
|
3057
4449
|
arguments: [traceParams]
|
|
3058
4450
|
};
|
|
3059
|
-
return
|
|
4451
|
+
return _chunkCDIKAHDZjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
3060
4452
|
() => original(params, options),
|
|
3061
4453
|
context
|
|
3062
4454
|
);
|
|
3063
4455
|
};
|
|
3064
4456
|
}
|
|
3065
4457
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
3066
|
-
return (params, options) =>
|
|
4458
|
+
return (params, options) => _chunkCDIKAHDZjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
3067
4459
|
() => original(params, options),
|
|
3068
4460
|
{
|
|
3069
4461
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -3076,7 +4468,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
3076
4468
|
const context = {
|
|
3077
4469
|
arguments: [traceParams]
|
|
3078
4470
|
};
|
|
3079
|
-
return
|
|
4471
|
+
return _chunkCDIKAHDZjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
3080
4472
|
() => original(params, options),
|
|
3081
4473
|
context
|
|
3082
4474
|
);
|
|
@@ -3123,7 +4515,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
3123
4515
|
const request = cloneCallModelRequest(argArray[0]);
|
|
3124
4516
|
const options = argArray[1];
|
|
3125
4517
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3126
|
-
return
|
|
4518
|
+
return _chunkCDIKAHDZjs.openRouterAgentChannels.callModel.traceSync(
|
|
3127
4519
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
3128
4520
|
{
|
|
3129
4521
|
arguments: [request]
|
|
@@ -3219,24 +4611,24 @@ function rerankProxy(rerank) {
|
|
|
3219
4611
|
});
|
|
3220
4612
|
}
|
|
3221
4613
|
function wrapChatSend(send) {
|
|
3222
|
-
return (request, options) =>
|
|
4614
|
+
return (request, options) => _chunkCDIKAHDZjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
3223
4615
|
arguments: [request]
|
|
3224
4616
|
});
|
|
3225
4617
|
}
|
|
3226
4618
|
function wrapEmbeddingsGenerate(generate) {
|
|
3227
|
-
return (request, options) =>
|
|
4619
|
+
return (request, options) => _chunkCDIKAHDZjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
3228
4620
|
() => generate(request, options),
|
|
3229
4621
|
{ arguments: [request] }
|
|
3230
4622
|
);
|
|
3231
4623
|
}
|
|
3232
4624
|
function wrapResponsesSend(send) {
|
|
3233
|
-
return (request, options) =>
|
|
4625
|
+
return (request, options) => _chunkCDIKAHDZjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
3234
4626
|
() => send(request, options),
|
|
3235
4627
|
{ arguments: [request] }
|
|
3236
4628
|
);
|
|
3237
4629
|
}
|
|
3238
4630
|
function wrapRerank2(rerank) {
|
|
3239
|
-
return (request, options) =>
|
|
4631
|
+
return (request, options) => _chunkCDIKAHDZjs.openRouterChannels.rerankRerank.tracePromise(
|
|
3240
4632
|
() => rerank(request, options),
|
|
3241
4633
|
{ arguments: [request] }
|
|
3242
4634
|
);
|
|
@@ -3244,7 +4636,7 @@ function wrapRerank2(rerank) {
|
|
|
3244
4636
|
function wrapCallModel2(callModel) {
|
|
3245
4637
|
return (request, options) => {
|
|
3246
4638
|
const tracedRequest = { ...request };
|
|
3247
|
-
return
|
|
4639
|
+
return _chunkCDIKAHDZjs.openRouterChannels.callModel.traceSync(
|
|
3248
4640
|
() => callModel(tracedRequest, options),
|
|
3249
4641
|
{
|
|
3250
4642
|
arguments: [tracedRequest]
|
|
@@ -3377,7 +4769,7 @@ function classifiersProxy(classifiers) {
|
|
|
3377
4769
|
});
|
|
3378
4770
|
}
|
|
3379
4771
|
function wrapChatComplete(complete) {
|
|
3380
|
-
return (request, options) =>
|
|
4772
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.chatComplete.tracePromise(
|
|
3381
4773
|
() => complete(request, options),
|
|
3382
4774
|
{
|
|
3383
4775
|
arguments: [request]
|
|
@@ -3385,52 +4777,52 @@ function wrapChatComplete(complete) {
|
|
|
3385
4777
|
);
|
|
3386
4778
|
}
|
|
3387
4779
|
function wrapChatStream(stream) {
|
|
3388
|
-
return (request, options) =>
|
|
4780
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
3389
4781
|
arguments: [request]
|
|
3390
4782
|
});
|
|
3391
4783
|
}
|
|
3392
4784
|
function wrapEmbeddingsCreate(create) {
|
|
3393
|
-
return (request, options) =>
|
|
4785
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
3394
4786
|
() => create(request, options),
|
|
3395
4787
|
{ arguments: [request] }
|
|
3396
4788
|
);
|
|
3397
4789
|
}
|
|
3398
4790
|
function wrapClassifiersModerate(moderate) {
|
|
3399
|
-
return (request, options) =>
|
|
4791
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.classifiersModerate.tracePromise(
|
|
3400
4792
|
() => moderate(request, options),
|
|
3401
4793
|
{ arguments: [request] }
|
|
3402
4794
|
);
|
|
3403
4795
|
}
|
|
3404
4796
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
3405
|
-
return (request, options) =>
|
|
4797
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
3406
4798
|
() => moderateChat(request, options),
|
|
3407
4799
|
{ arguments: [request] }
|
|
3408
4800
|
);
|
|
3409
4801
|
}
|
|
3410
4802
|
function wrapClassifiersClassify(classify) {
|
|
3411
|
-
return (request, options) =>
|
|
4803
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.classifiersClassify.tracePromise(
|
|
3412
4804
|
() => classify(request, options),
|
|
3413
4805
|
{ arguments: [request] }
|
|
3414
4806
|
);
|
|
3415
4807
|
}
|
|
3416
4808
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
3417
|
-
return (request, options) =>
|
|
4809
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
3418
4810
|
() => classifyChat(request, options),
|
|
3419
4811
|
{ arguments: [request] }
|
|
3420
4812
|
);
|
|
3421
4813
|
}
|
|
3422
4814
|
function wrapFimComplete(complete) {
|
|
3423
|
-
return (request, options) =>
|
|
4815
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
3424
4816
|
arguments: [request]
|
|
3425
4817
|
});
|
|
3426
4818
|
}
|
|
3427
4819
|
function wrapFimStream(stream) {
|
|
3428
|
-
return (request, options) =>
|
|
4820
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
3429
4821
|
arguments: [request]
|
|
3430
4822
|
});
|
|
3431
4823
|
}
|
|
3432
4824
|
function wrapAgentsComplete(complete) {
|
|
3433
|
-
return (request, options) =>
|
|
4825
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.agentsComplete.tracePromise(
|
|
3434
4826
|
() => complete(request, options),
|
|
3435
4827
|
{
|
|
3436
4828
|
arguments: [request]
|
|
@@ -3438,7 +4830,7 @@ function wrapAgentsComplete(complete) {
|
|
|
3438
4830
|
);
|
|
3439
4831
|
}
|
|
3440
4832
|
function wrapAgentsStream(stream) {
|
|
3441
|
-
return (request, options) =>
|
|
4833
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
3442
4834
|
arguments: [request]
|
|
3443
4835
|
});
|
|
3444
4836
|
}
|
|
@@ -3491,22 +4883,22 @@ function cohereProxy(cohere) {
|
|
|
3491
4883
|
return proxy;
|
|
3492
4884
|
}
|
|
3493
4885
|
function wrapChat(chat) {
|
|
3494
|
-
return (request, options) =>
|
|
4886
|
+
return (request, options) => _chunkCDIKAHDZjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
3495
4887
|
arguments: [request]
|
|
3496
4888
|
});
|
|
3497
4889
|
}
|
|
3498
4890
|
function wrapChatStream2(chatStream) {
|
|
3499
|
-
return (request, options) =>
|
|
4891
|
+
return (request, options) => _chunkCDIKAHDZjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
3500
4892
|
arguments: [request]
|
|
3501
4893
|
});
|
|
3502
4894
|
}
|
|
3503
4895
|
function wrapEmbed3(embed) {
|
|
3504
|
-
return (request, options) =>
|
|
4896
|
+
return (request, options) => _chunkCDIKAHDZjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
3505
4897
|
arguments: [request]
|
|
3506
4898
|
});
|
|
3507
4899
|
}
|
|
3508
4900
|
function wrapRerank3(rerank) {
|
|
3509
|
-
return (request, options) =>
|
|
4901
|
+
return (request, options) => _chunkCDIKAHDZjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
3510
4902
|
arguments: [request]
|
|
3511
4903
|
});
|
|
3512
4904
|
}
|
|
@@ -3536,7 +4928,7 @@ function isSupportedGroqClient(value) {
|
|
|
3536
4928
|
}
|
|
3537
4929
|
function groqProxy(groq) {
|
|
3538
4930
|
const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
|
|
3539
|
-
const completionProxy = _optionalChain([groq, 'access',
|
|
4931
|
+
const completionProxy = _optionalChain([groq, 'access', _116 => _116.chat, 'optionalAccess', _117 => _117.completions]) ? new Proxy(groq.chat.completions, {
|
|
3540
4932
|
get(target, prop, receiver) {
|
|
3541
4933
|
if (prop === "create") {
|
|
3542
4934
|
return wrapChatCompletionsCreate(target.create.bind(target));
|
|
@@ -3588,13 +4980,13 @@ function groqProxy(groq) {
|
|
|
3588
4980
|
return topLevelProxy;
|
|
3589
4981
|
}
|
|
3590
4982
|
function wrapChatCompletionsCreate(create) {
|
|
3591
|
-
return (request, options) =>
|
|
4983
|
+
return (request, options) => _chunkCDIKAHDZjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
3592
4984
|
() => create(request, options),
|
|
3593
4985
|
{ arguments: [request] }
|
|
3594
4986
|
);
|
|
3595
4987
|
}
|
|
3596
4988
|
function wrapEmbeddingsCreate2(create) {
|
|
3597
|
-
return (request, options) =>
|
|
4989
|
+
return (request, options) => _chunkCDIKAHDZjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
3598
4990
|
arguments: [request]
|
|
3599
4991
|
});
|
|
3600
4992
|
}
|
|
@@ -3668,16 +5060,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
3668
5060
|
}
|
|
3669
5061
|
function wrapSend(send) {
|
|
3670
5062
|
return (command, optionsOrCb, cb) => {
|
|
3671
|
-
if (
|
|
5063
|
+
if (_chunkFZWPFCVEjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
3672
5064
|
return send(command, optionsOrCb, cb);
|
|
3673
5065
|
}
|
|
3674
|
-
return
|
|
3675
|
-
() =>
|
|
5066
|
+
return _chunkCDIKAHDZjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
5067
|
+
() => _chunkFZWPFCVEjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
3676
5068
|
() => send(command, optionsOrCb)
|
|
3677
5069
|
),
|
|
3678
5070
|
{
|
|
3679
5071
|
arguments: [command, optionsOrCb],
|
|
3680
|
-
span_info:
|
|
5072
|
+
span_info: _chunkFZWPFCVEjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
3681
5073
|
}
|
|
3682
5074
|
);
|
|
3683
5075
|
};
|
|
@@ -3726,18 +5118,283 @@ function copilotClientProxy(client) {
|
|
|
3726
5118
|
return proxy;
|
|
3727
5119
|
}
|
|
3728
5120
|
function wrappedCreateSession(client) {
|
|
3729
|
-
return (config) =>
|
|
5121
|
+
return (config) => _chunkCDIKAHDZjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
3730
5122
|
() => client.createSession(config),
|
|
3731
5123
|
{ arguments: [config] }
|
|
3732
5124
|
);
|
|
3733
5125
|
}
|
|
3734
5126
|
function wrappedResumeSession(client) {
|
|
3735
|
-
return (sessionId, config) =>
|
|
5127
|
+
return (sessionId, config) => _chunkCDIKAHDZjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
3736
5128
|
() => client.resumeSession(sessionId, config),
|
|
3737
5129
|
{ arguments: [sessionId, config] }
|
|
3738
5130
|
);
|
|
3739
5131
|
}
|
|
3740
5132
|
|
|
5133
|
+
// src/wrappers/langsmith.ts
|
|
5134
|
+
var WRAPPED_CLIENT_CLASS = /* @__PURE__ */ Symbol.for(
|
|
5135
|
+
"braintrust.langsmith.wrapped-client-class"
|
|
5136
|
+
);
|
|
5137
|
+
var WRAPPED_CLIENT_INSTANCE = /* @__PURE__ */ Symbol.for(
|
|
5138
|
+
"braintrust.langsmith.wrapped-client-instance"
|
|
5139
|
+
);
|
|
5140
|
+
var WRAPPED_CLIENT_NAMESPACE = /* @__PURE__ */ Symbol.for(
|
|
5141
|
+
"braintrust.langsmith.wrapped-client-namespace"
|
|
5142
|
+
);
|
|
5143
|
+
var WRAPPED_RUN_TREE_CLASS = /* @__PURE__ */ Symbol.for(
|
|
5144
|
+
"braintrust.langsmith.wrapped-run-tree-class"
|
|
5145
|
+
);
|
|
5146
|
+
var WRAPPED_RUN_TREE_INSTANCE = /* @__PURE__ */ Symbol.for(
|
|
5147
|
+
"braintrust.langsmith.wrapped-run-tree-instance"
|
|
5148
|
+
);
|
|
5149
|
+
var WRAPPED_RUN_TREES_NAMESPACE = /* @__PURE__ */ Symbol.for(
|
|
5150
|
+
"braintrust.langsmith.wrapped-run-trees-namespace"
|
|
5151
|
+
);
|
|
5152
|
+
var WRAPPED_TRACEABLE = /* @__PURE__ */ Symbol.for("braintrust.langsmith.wrapped-traceable");
|
|
5153
|
+
var WRAPPED_TRACEABLE_NAMESPACE = /* @__PURE__ */ Symbol.for(
|
|
5154
|
+
"braintrust.langsmith.wrapped-traceable-namespace"
|
|
5155
|
+
);
|
|
5156
|
+
function wrapLangSmithTraceable(namespace) {
|
|
5157
|
+
return wrapNamespaceExport(
|
|
5158
|
+
namespace,
|
|
5159
|
+
"traceable",
|
|
5160
|
+
WRAPPED_TRACEABLE_NAMESPACE,
|
|
5161
|
+
(value) => wrapTraceable(value)
|
|
5162
|
+
);
|
|
5163
|
+
}
|
|
5164
|
+
function wrapLangSmithRunTrees(namespace) {
|
|
5165
|
+
return wrapNamespaceExport(
|
|
5166
|
+
namespace,
|
|
5167
|
+
"RunTree",
|
|
5168
|
+
WRAPPED_RUN_TREES_NAMESPACE,
|
|
5169
|
+
(value) => wrapRunTreeClass(value)
|
|
5170
|
+
);
|
|
5171
|
+
}
|
|
5172
|
+
function wrapLangSmithClient(namespace) {
|
|
5173
|
+
return wrapNamespaceExport(
|
|
5174
|
+
namespace,
|
|
5175
|
+
"Client",
|
|
5176
|
+
WRAPPED_CLIENT_NAMESPACE,
|
|
5177
|
+
(value) => wrapClientClass(value)
|
|
5178
|
+
);
|
|
5179
|
+
}
|
|
5180
|
+
function wrapNamespaceExport(namespace, exportName, marker, wrap2) {
|
|
5181
|
+
if (!namespace || typeof namespace !== "object") {
|
|
5182
|
+
return namespace;
|
|
5183
|
+
}
|
|
5184
|
+
const candidate = namespace;
|
|
5185
|
+
if (candidate[marker] === true) {
|
|
5186
|
+
return namespace;
|
|
5187
|
+
}
|
|
5188
|
+
if (typeof candidate[exportName] !== "function") {
|
|
5189
|
+
console.warn(
|
|
5190
|
+
`Unsupported LangSmith ${exportName} namespace. Not wrapping.`
|
|
5191
|
+
);
|
|
5192
|
+
return namespace;
|
|
5193
|
+
}
|
|
5194
|
+
const target = isModuleNamespace5(namespace) ? Object.setPrototypeOf({}, namespace) : candidate;
|
|
5195
|
+
const moduleNamespace = target !== candidate;
|
|
5196
|
+
let wrappedExport;
|
|
5197
|
+
return new Proxy(target, {
|
|
5198
|
+
get(target2, prop, receiver) {
|
|
5199
|
+
if (prop === marker) {
|
|
5200
|
+
return true;
|
|
5201
|
+
}
|
|
5202
|
+
const value = Reflect.get(target2, prop, receiver);
|
|
5203
|
+
if (prop !== exportName || typeof value !== "function") {
|
|
5204
|
+
return value;
|
|
5205
|
+
}
|
|
5206
|
+
wrappedExport ??= wrap2(value);
|
|
5207
|
+
return wrappedExport;
|
|
5208
|
+
},
|
|
5209
|
+
getOwnPropertyDescriptor(target2, prop) {
|
|
5210
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target2, prop);
|
|
5211
|
+
if (descriptor || !moduleNamespace) {
|
|
5212
|
+
return descriptor;
|
|
5213
|
+
}
|
|
5214
|
+
const namespaceDescriptor = Reflect.getOwnPropertyDescriptor(
|
|
5215
|
+
candidate,
|
|
5216
|
+
prop
|
|
5217
|
+
);
|
|
5218
|
+
return namespaceDescriptor ? { ...namespaceDescriptor, configurable: true } : void 0;
|
|
5219
|
+
},
|
|
5220
|
+
has(target2, prop) {
|
|
5221
|
+
return Reflect.has(target2, prop) || moduleNamespace && prop in candidate;
|
|
5222
|
+
},
|
|
5223
|
+
ownKeys(target2) {
|
|
5224
|
+
return moduleNamespace ? Reflect.ownKeys(candidate) : Reflect.ownKeys(target2);
|
|
5225
|
+
}
|
|
5226
|
+
});
|
|
5227
|
+
}
|
|
5228
|
+
function isModuleNamespace5(value) {
|
|
5229
|
+
if (!value || typeof value !== "object") {
|
|
5230
|
+
return false;
|
|
5231
|
+
}
|
|
5232
|
+
if (_optionalChain([value, 'access', _118 => _118.constructor, 'optionalAccess', _119 => _119.name]) === "Module") {
|
|
5233
|
+
return true;
|
|
5234
|
+
}
|
|
5235
|
+
const firstKey = Object.keys(value)[0];
|
|
5236
|
+
if (!firstKey) {
|
|
5237
|
+
return false;
|
|
5238
|
+
}
|
|
5239
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, firstKey);
|
|
5240
|
+
return descriptor ? !descriptor.configurable && !descriptor.writable : false;
|
|
5241
|
+
}
|
|
5242
|
+
function wrapTraceable(traceable2) {
|
|
5243
|
+
if (traceable2[WRAPPED_TRACEABLE]) {
|
|
5244
|
+
return traceable2;
|
|
5245
|
+
}
|
|
5246
|
+
return new Proxy(traceable2, {
|
|
5247
|
+
get(target, prop, receiver) {
|
|
5248
|
+
if (prop === WRAPPED_TRACEABLE) {
|
|
5249
|
+
return true;
|
|
5250
|
+
}
|
|
5251
|
+
return Reflect.get(target, prop, receiver);
|
|
5252
|
+
},
|
|
5253
|
+
apply(target, thisArg, argArray) {
|
|
5254
|
+
const [fn, rawConfig] = argArray;
|
|
5255
|
+
const config = rawConfig && typeof rawConfig === "object" ? rawConfig : void 0;
|
|
5256
|
+
const originalOnEnd = _optionalChain([config, 'optionalAccess', _120 => _120.on_end]);
|
|
5257
|
+
const wrappedConfig = {
|
|
5258
|
+
...config,
|
|
5259
|
+
on_end(runTree) {
|
|
5260
|
+
publishRunUpdate(runTree);
|
|
5261
|
+
if (originalOnEnd) {
|
|
5262
|
+
Reflect.apply(originalOnEnd, config, [runTree]);
|
|
5263
|
+
}
|
|
5264
|
+
}
|
|
5265
|
+
};
|
|
5266
|
+
return Reflect.apply(target, thisArg, [fn, wrappedConfig]);
|
|
5267
|
+
}
|
|
5268
|
+
});
|
|
5269
|
+
}
|
|
5270
|
+
function wrapRunTreeClass(RunTree) {
|
|
5271
|
+
if (RunTree[WRAPPED_RUN_TREE_CLASS]) {
|
|
5272
|
+
return RunTree;
|
|
5273
|
+
}
|
|
5274
|
+
return new Proxy(RunTree, {
|
|
5275
|
+
get(target, prop, receiver) {
|
|
5276
|
+
if (prop === WRAPPED_RUN_TREE_CLASS) {
|
|
5277
|
+
return true;
|
|
5278
|
+
}
|
|
5279
|
+
const value = Reflect.get(target, prop, receiver);
|
|
5280
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
5281
|
+
},
|
|
5282
|
+
construct(target, args, newTarget) {
|
|
5283
|
+
return wrapRunTreeInstance(Reflect.construct(target, args, newTarget));
|
|
5284
|
+
}
|
|
5285
|
+
});
|
|
5286
|
+
}
|
|
5287
|
+
function wrapRunTreeInstance(runTree) {
|
|
5288
|
+
if (runTree[WRAPPED_RUN_TREE_INSTANCE]) {
|
|
5289
|
+
return runTree;
|
|
5290
|
+
}
|
|
5291
|
+
return new Proxy(runTree, {
|
|
5292
|
+
get(target, prop, receiver) {
|
|
5293
|
+
if (prop === WRAPPED_RUN_TREE_INSTANCE) {
|
|
5294
|
+
return true;
|
|
5295
|
+
}
|
|
5296
|
+
const value = Reflect.get(target, prop, receiver);
|
|
5297
|
+
if (typeof value !== "function") {
|
|
5298
|
+
return value;
|
|
5299
|
+
}
|
|
5300
|
+
let wrapped;
|
|
5301
|
+
if (prop === "createChild") {
|
|
5302
|
+
wrapped = (...args) => wrapRunTreeInstance(Reflect.apply(value, target, args));
|
|
5303
|
+
} else if (prop === "postRun") {
|
|
5304
|
+
const method = value;
|
|
5305
|
+
wrapped = (...args) => _chunkCDIKAHDZjs.langSmithChannels.createRun.tracePromise(
|
|
5306
|
+
() => Reflect.apply(method, target, args),
|
|
5307
|
+
{ arguments: [target] }
|
|
5308
|
+
);
|
|
5309
|
+
} else if (prop === "patchRun") {
|
|
5310
|
+
const method = value;
|
|
5311
|
+
wrapped = (...args) => _chunkCDIKAHDZjs.langSmithChannels.updateRun.tracePromise(
|
|
5312
|
+
() => Reflect.apply(method, target, args),
|
|
5313
|
+
{
|
|
5314
|
+
arguments: [
|
|
5315
|
+
typeof target.id === "string" ? target.id : "",
|
|
5316
|
+
target
|
|
5317
|
+
]
|
|
5318
|
+
}
|
|
5319
|
+
);
|
|
5320
|
+
} else {
|
|
5321
|
+
wrapped = value.bind(target);
|
|
5322
|
+
}
|
|
5323
|
+
return wrapped;
|
|
5324
|
+
}
|
|
5325
|
+
});
|
|
5326
|
+
}
|
|
5327
|
+
function wrapClientClass(Client) {
|
|
5328
|
+
if (Client[WRAPPED_CLIENT_CLASS]) {
|
|
5329
|
+
return Client;
|
|
5330
|
+
}
|
|
5331
|
+
return new Proxy(Client, {
|
|
5332
|
+
get(target, prop, receiver) {
|
|
5333
|
+
if (prop === WRAPPED_CLIENT_CLASS) {
|
|
5334
|
+
return true;
|
|
5335
|
+
}
|
|
5336
|
+
const value = Reflect.get(target, prop, receiver);
|
|
5337
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
5338
|
+
},
|
|
5339
|
+
construct(target, args, newTarget) {
|
|
5340
|
+
return wrapClientInstance(Reflect.construct(target, args, newTarget));
|
|
5341
|
+
}
|
|
5342
|
+
});
|
|
5343
|
+
}
|
|
5344
|
+
function wrapClientInstance(client) {
|
|
5345
|
+
if (client[WRAPPED_CLIENT_INSTANCE]) {
|
|
5346
|
+
return client;
|
|
5347
|
+
}
|
|
5348
|
+
return new Proxy(client, {
|
|
5349
|
+
get(target, prop, receiver) {
|
|
5350
|
+
if (prop === WRAPPED_CLIENT_INSTANCE) {
|
|
5351
|
+
return true;
|
|
5352
|
+
}
|
|
5353
|
+
const value = Reflect.get(target, prop, receiver);
|
|
5354
|
+
if (typeof value !== "function") {
|
|
5355
|
+
return value;
|
|
5356
|
+
}
|
|
5357
|
+
let wrapped;
|
|
5358
|
+
if (prop === "createRun") {
|
|
5359
|
+
const method = value;
|
|
5360
|
+
wrapped = (...args) => _chunkCDIKAHDZjs.langSmithChannels.createRun.tracePromise(
|
|
5361
|
+
() => Reflect.apply(method, target, args),
|
|
5362
|
+
{ arguments: args }
|
|
5363
|
+
);
|
|
5364
|
+
} else if (prop === "updateRun") {
|
|
5365
|
+
const method = value;
|
|
5366
|
+
wrapped = (...args) => _chunkCDIKAHDZjs.langSmithChannels.updateRun.tracePromise(
|
|
5367
|
+
() => Reflect.apply(method, target, args),
|
|
5368
|
+
{ arguments: args }
|
|
5369
|
+
);
|
|
5370
|
+
} else if (prop === "batchIngestRuns") {
|
|
5371
|
+
const method = value;
|
|
5372
|
+
wrapped = (...args) => _chunkCDIKAHDZjs.langSmithChannels.batchIngestRuns.tracePromise(
|
|
5373
|
+
() => Reflect.apply(method, target, args),
|
|
5374
|
+
{ arguments: args }
|
|
5375
|
+
);
|
|
5376
|
+
} else {
|
|
5377
|
+
wrapped = value.bind(target);
|
|
5378
|
+
}
|
|
5379
|
+
return wrapped;
|
|
5380
|
+
}
|
|
5381
|
+
});
|
|
5382
|
+
}
|
|
5383
|
+
function publishRunUpdate(runTree) {
|
|
5384
|
+
if (!runTree || typeof runTree.id !== "string" || !runTree.id) {
|
|
5385
|
+
return;
|
|
5386
|
+
}
|
|
5387
|
+
try {
|
|
5388
|
+
void _chunkCDIKAHDZjs.langSmithChannels.updateRun.tracePromise(() => Promise.resolve(void 0), {
|
|
5389
|
+
arguments: [runTree.id, runTree]
|
|
5390
|
+
}).catch((error) => {
|
|
5391
|
+
_chunkFZWPFCVEjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
5392
|
+
});
|
|
5393
|
+
} catch (error) {
|
|
5394
|
+
_chunkFZWPFCVEjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
|
|
3741
5398
|
// src/wrappers/vitest/context-manager.ts
|
|
3742
5399
|
var VitestContextManager = class {
|
|
3743
5400
|
/**
|
|
@@ -3746,7 +5403,7 @@ var VitestContextManager = class {
|
|
|
3746
5403
|
*/
|
|
3747
5404
|
|
|
3748
5405
|
constructor() {
|
|
3749
|
-
this.contextStorage =
|
|
5406
|
+
this.contextStorage = _chunkCDIKAHDZjs.isomorph_default.newAsyncLocalStorage();
|
|
3750
5407
|
}
|
|
3751
5408
|
getCurrentContext() {
|
|
3752
5409
|
return this.contextStorage.getStore();
|
|
@@ -3779,15 +5436,15 @@ function getVitestContextManager() {
|
|
|
3779
5436
|
}
|
|
3780
5437
|
|
|
3781
5438
|
// src/wrappers/vitest/flush-manager.ts
|
|
3782
|
-
var FlushCoordinator = (
|
|
3783
|
-
|
|
5439
|
+
var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__init5.call(this); }
|
|
5440
|
+
__init5() {this.activeFlushes = /* @__PURE__ */ new Map()}
|
|
3784
5441
|
async coordinateFlush(context, config) {
|
|
3785
5442
|
if (!context) return;
|
|
3786
5443
|
const experimentId = await context.experiment.id;
|
|
3787
5444
|
if (this.activeFlushes.has(experimentId)) {
|
|
3788
5445
|
return this.activeFlushes.get(experimentId);
|
|
3789
5446
|
}
|
|
3790
|
-
const flushPromise =
|
|
5447
|
+
const flushPromise = _chunkFZWPFCVEjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
3791
5448
|
displaySummary: config.displaySummary
|
|
3792
5449
|
});
|
|
3793
5450
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -3797,7 +5454,7 @@ var FlushCoordinator = (_class = class {constructor() { _class.prototype.__init.
|
|
|
3797
5454
|
this.activeFlushes.delete(experimentId);
|
|
3798
5455
|
}
|
|
3799
5456
|
}
|
|
3800
|
-
},
|
|
5457
|
+
}, _class2);
|
|
3801
5458
|
var flushCoordinator = new FlushCoordinator();
|
|
3802
5459
|
async function flushExperimentWithSync(context, config) {
|
|
3803
5460
|
return flushCoordinator.coordinateFlush(context, config);
|
|
@@ -3885,7 +5542,7 @@ async function runTracedEval(args) {
|
|
|
3885
5542
|
}
|
|
3886
5543
|
if (testError) {
|
|
3887
5544
|
span.log({ scores: { pass: 0 } });
|
|
3888
|
-
|
|
5545
|
+
_chunkFZWPFCVEjs.logError.call(void 0, span, testError);
|
|
3889
5546
|
throw testError;
|
|
3890
5547
|
}
|
|
3891
5548
|
span.log({
|
|
@@ -3918,7 +5575,7 @@ function wrapTest(originalTest, config) {
|
|
|
3918
5575
|
const wrapped = function(name, configOrFn, maybeFn) {
|
|
3919
5576
|
const isEnhanced = typeof configOrFn !== "function";
|
|
3920
5577
|
const testConfig = isEnhanced ? configOrFn : void 0;
|
|
3921
|
-
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess',
|
|
5578
|
+
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _121 => _121.data]) && Array.isArray(testConfig.data)) {
|
|
3922
5579
|
const dataRecords = testConfig.data;
|
|
3923
5580
|
const testFn2 = maybeFn;
|
|
3924
5581
|
if (!testFn2) {
|
|
@@ -3956,7 +5613,7 @@ function wrapTest(originalTest, config) {
|
|
|
3956
5613
|
const registrationContext = getExperimentContext();
|
|
3957
5614
|
const testImplementation = async (vitestContext) => {
|
|
3958
5615
|
const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
|
|
3959
|
-
const experiment = _optionalChain([experimentContext, 'optionalAccess',
|
|
5616
|
+
const experiment = _optionalChain([experimentContext, 'optionalAccess', _122 => _122.experiment]);
|
|
3960
5617
|
if (config.onProgress) {
|
|
3961
5618
|
config.onProgress({ type: "test_start", testName: name });
|
|
3962
5619
|
}
|
|
@@ -3988,11 +5645,11 @@ function wrapTest(originalTest, config) {
|
|
|
3988
5645
|
const result = await runTracedEval({
|
|
3989
5646
|
experiment,
|
|
3990
5647
|
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',
|
|
5648
|
+
input: _optionalChain([testConfig, 'optionalAccess', _123 => _123.input]),
|
|
5649
|
+
expected: _optionalChain([testConfig, 'optionalAccess', _124 => _124.expected]),
|
|
5650
|
+
metadata: _optionalChain([testConfig, 'optionalAccess', _125 => _125.metadata]),
|
|
5651
|
+
tags: _optionalChain([testConfig, 'optionalAccess', _126 => _126.tags]),
|
|
5652
|
+
scorers: _optionalChain([testConfig, 'optionalAccess', _127 => _127.scorers]),
|
|
3996
5653
|
fn: async () => {
|
|
3997
5654
|
if (testConfig && maybeFn) {
|
|
3998
5655
|
const params = {
|
|
@@ -4059,10 +5716,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
4059
5716
|
const getOrCreateContext = () => {
|
|
4060
5717
|
if (!context) {
|
|
4061
5718
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4062
|
-
const experiment = config.projectId ?
|
|
5719
|
+
const experiment = config.projectId ? _chunkFZWPFCVEjs.initExperiment.call(void 0, {
|
|
4063
5720
|
projectId: config.projectId,
|
|
4064
5721
|
experiment: experimentName
|
|
4065
|
-
}) :
|
|
5722
|
+
}) : _chunkFZWPFCVEjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
4066
5723
|
experiment: experimentName
|
|
4067
5724
|
});
|
|
4068
5725
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -4107,8 +5764,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
4107
5764
|
config.onProgress({
|
|
4108
5765
|
type: "suite_complete",
|
|
4109
5766
|
suiteName,
|
|
4110
|
-
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
4111
|
-
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
5767
|
+
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _128 => _128.passed]), () => ( 0)),
|
|
5768
|
+
failed: _nullishCoalesce(_optionalChain([context, 'optionalAccess', _129 => _129.failed]), () => ( 0))
|
|
4112
5769
|
});
|
|
4113
5770
|
}
|
|
4114
5771
|
});
|
|
@@ -4170,7 +5827,7 @@ function wrapExpect(originalExpect) {
|
|
|
4170
5827
|
return originalExpect(value);
|
|
4171
5828
|
}
|
|
4172
5829
|
const assertion = originalExpect(value, message);
|
|
4173
|
-
const span =
|
|
5830
|
+
const span = _chunkFZWPFCVEjs.currentSpan.call(void 0, );
|
|
4174
5831
|
if (!span) {
|
|
4175
5832
|
return assertion;
|
|
4176
5833
|
}
|
|
@@ -4182,16 +5839,16 @@ function wrapExpect(originalExpect) {
|
|
|
4182
5839
|
|
|
4183
5840
|
// src/wrappers/shared/logging.ts
|
|
4184
5841
|
function logOutputs(outputs) {
|
|
4185
|
-
|
|
5842
|
+
_chunkFZWPFCVEjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
4186
5843
|
}
|
|
4187
5844
|
function logFeedback(feedback) {
|
|
4188
|
-
|
|
5845
|
+
_chunkFZWPFCVEjs.currentSpan.call(void 0, ).log({
|
|
4189
5846
|
scores: { [feedback.name]: feedback.score },
|
|
4190
5847
|
metadata: feedback.metadata
|
|
4191
5848
|
});
|
|
4192
5849
|
}
|
|
4193
5850
|
function getCurrentSpan() {
|
|
4194
|
-
return
|
|
5851
|
+
return _chunkFZWPFCVEjs.currentSpan.call(void 0, );
|
|
4195
5852
|
}
|
|
4196
5853
|
|
|
4197
5854
|
// src/wrappers/vitest/index.ts
|
|
@@ -4239,8 +5896,8 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
4239
5896
|
);
|
|
4240
5897
|
return;
|
|
4241
5898
|
}
|
|
4242
|
-
await
|
|
4243
|
-
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5899
|
+
await _chunkFZWPFCVEjs.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
5900
|
+
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _130 => _130.displaySummary]), () => ( config.displaySummary))
|
|
4244
5901
|
});
|
|
4245
5902
|
}
|
|
4246
5903
|
};
|
|
@@ -4254,7 +5911,7 @@ function initNodeTestSuite(config) {
|
|
|
4254
5911
|
return experiment;
|
|
4255
5912
|
}
|
|
4256
5913
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4257
|
-
experiment =
|
|
5914
|
+
experiment = _chunkFZWPFCVEjs.initExperiment.call(void 0, config.projectName, {
|
|
4258
5915
|
experiment: experimentName
|
|
4259
5916
|
});
|
|
4260
5917
|
return experiment;
|
|
@@ -4303,7 +5960,7 @@ function initNodeTestSuite(config) {
|
|
|
4303
5960
|
if (!experiment) {
|
|
4304
5961
|
return;
|
|
4305
5962
|
}
|
|
4306
|
-
await
|
|
5963
|
+
await _chunkFZWPFCVEjs.summarizeAndFlush.call(void 0, experiment, {
|
|
4307
5964
|
displaySummary: config.displaySummary
|
|
4308
5965
|
});
|
|
4309
5966
|
experiment = void 0;
|
|
@@ -4320,7 +5977,7 @@ function initNodeTestSuite(config) {
|
|
|
4320
5977
|
|
|
4321
5978
|
// src/graph-framework.ts
|
|
4322
5979
|
var graph_framework_exports = {};
|
|
4323
|
-
|
|
5980
|
+
_chunkCDIKAHDZjs.__export.call(void 0, graph_framework_exports, {
|
|
4324
5981
|
AggregatorNode: () => AggregatorNode,
|
|
4325
5982
|
GateNode: () => GateNode,
|
|
4326
5983
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -4334,15 +5991,15 @@ _chunkBFGIH2ZJjs.__export.call(void 0, graph_framework_exports, {
|
|
|
4334
5991
|
escapePath: () => escapePath,
|
|
4335
5992
|
unescapePath: () => unescapePath
|
|
4336
5993
|
});
|
|
4337
|
-
var GraphBuilder = (
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
5994
|
+
var GraphBuilder = (_class3 = class {
|
|
5995
|
+
__init6() {this.nodes = /* @__PURE__ */ new Map()}
|
|
5996
|
+
__init7() {this.edges = {}}
|
|
5997
|
+
__init8() {this.nodeLikeNodes = /* @__PURE__ */ new Map()}
|
|
4341
5998
|
// Maps node-like objects, like prompts, to their nodes
|
|
4342
5999
|
// Special nodes
|
|
4343
6000
|
|
|
4344
6001
|
|
|
4345
|
-
constructor() {;
|
|
6002
|
+
constructor() {;_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);
|
|
4346
6003
|
this.IN = this.createInputNode();
|
|
4347
6004
|
this.OUT = this.createOutputNode();
|
|
4348
6005
|
}
|
|
@@ -4394,7 +6051,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4394
6051
|
};
|
|
4395
6052
|
}
|
|
4396
6053
|
resolveNode(node) {
|
|
4397
|
-
if (node instanceof
|
|
6054
|
+
if (node instanceof _chunkFZWPFCVEjs.Prompt) {
|
|
4398
6055
|
const cached = this.nodeLikeNodes.get(node);
|
|
4399
6056
|
if (cached) {
|
|
4400
6057
|
return [cached, []];
|
|
@@ -4444,7 +6101,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4444
6101
|
// }
|
|
4445
6102
|
// Helper to generate node IDs
|
|
4446
6103
|
generateId(name) {
|
|
4447
|
-
const uuid =
|
|
6104
|
+
const uuid = _chunkFZWPFCVEjs.newId.call(void 0, );
|
|
4448
6105
|
if (name) {
|
|
4449
6106
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
4450
6107
|
} else {
|
|
@@ -4472,7 +6129,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4472
6129
|
this.nodes.set(id, promptNode);
|
|
4473
6130
|
return promptNode;
|
|
4474
6131
|
}
|
|
4475
|
-
},
|
|
6132
|
+
}, _class3);
|
|
4476
6133
|
function isProxyVariable(node) {
|
|
4477
6134
|
return typeof node === "object" && node !== null && "__type" in node && // @ts-ignore
|
|
4478
6135
|
node.__type === "proxy-variable";
|
|
@@ -4480,17 +6137,17 @@ function isProxyVariable(node) {
|
|
|
4480
6137
|
function proxyVariableToNode(proxy) {
|
|
4481
6138
|
return [proxy.__node, proxy.__path];
|
|
4482
6139
|
}
|
|
4483
|
-
var BaseNode = (
|
|
4484
|
-
constructor(graph, id) {;
|
|
6140
|
+
var BaseNode = (_class4 = class {
|
|
6141
|
+
constructor(graph, id) {;_class4.prototype.__init9.call(this);_class4.prototype.__init10.call(this);
|
|
4485
6142
|
this.graph = graph;
|
|
4486
6143
|
this.id = id;
|
|
4487
6144
|
}
|
|
4488
|
-
|
|
4489
|
-
|
|
6145
|
+
__init9() {this.__type = "node"}
|
|
6146
|
+
__init10() {this.dependencies = []}
|
|
4490
6147
|
addDependency(dependency) {
|
|
4491
6148
|
this.dependencies.push(dependency);
|
|
4492
6149
|
}
|
|
4493
|
-
},
|
|
6150
|
+
}, _class4);
|
|
4494
6151
|
var InputNode = class extends BaseNode {
|
|
4495
6152
|
constructor(graph, id) {
|
|
4496
6153
|
super(graph, id);
|
|
@@ -5638,7 +7295,7 @@ function waterfall(tasks, callback) {
|
|
|
5638
7295
|
var waterfall$1 = awaitify(waterfall);
|
|
5639
7296
|
|
|
5640
7297
|
// src/trace.ts
|
|
5641
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
7298
|
+
var SpanFetcher = class _SpanFetcher extends _chunkFZWPFCVEjs.ObjectFetcher {
|
|
5642
7299
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
5643
7300
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
5644
7301
|
rootSpanId,
|
|
@@ -5703,11 +7360,11 @@ var SpanFetcher = class _SpanFetcher extends _chunkFY7DAKA5js.ObjectFetcher {
|
|
|
5703
7360
|
return this._state;
|
|
5704
7361
|
}
|
|
5705
7362
|
};
|
|
5706
|
-
var CachedSpanFetcher = (
|
|
5707
|
-
|
|
5708
|
-
|
|
7363
|
+
var CachedSpanFetcher = (_class5 = class {
|
|
7364
|
+
__init11() {this.spanCache = /* @__PURE__ */ new Map()}
|
|
7365
|
+
__init12() {this.allFetched = false}
|
|
5709
7366
|
|
|
5710
|
-
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;
|
|
7367
|
+
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);
|
|
5711
7368
|
if (typeof objectTypeOrFetchFn === "function") {
|
|
5712
7369
|
this.fetchFn = (spanType) => objectTypeOrFetchFn(spanType);
|
|
5713
7370
|
} else {
|
|
@@ -5771,7 +7428,7 @@ var CachedSpanFetcher = (_class4 = class {
|
|
|
5771
7428
|
async fetchSpans(spanType) {
|
|
5772
7429
|
const spans = await this.fetchFn(spanType, false);
|
|
5773
7430
|
for (const span of spans) {
|
|
5774
|
-
const type = _nullishCoalesce(_optionalChain([span, 'access',
|
|
7431
|
+
const type = _nullishCoalesce(_optionalChain([span, 'access', _131 => _131.span_attributes, 'optionalAccess', _132 => _132.type]), () => ( ""));
|
|
5775
7432
|
const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
|
|
5776
7433
|
existing.push(span);
|
|
5777
7434
|
this.spanCache.set(type, existing);
|
|
@@ -5788,24 +7445,24 @@ var CachedSpanFetcher = (_class4 = class {
|
|
|
5788
7445
|
}
|
|
5789
7446
|
return result;
|
|
5790
7447
|
}
|
|
5791
|
-
},
|
|
5792
|
-
var LocalTrace = (
|
|
7448
|
+
}, _class5);
|
|
7449
|
+
var LocalTrace = (_class6 = class {
|
|
5793
7450
|
|
|
5794
7451
|
|
|
5795
7452
|
|
|
5796
7453
|
|
|
5797
7454
|
|
|
5798
|
-
|
|
5799
|
-
|
|
7455
|
+
__init13() {this.spansFlushed = false}
|
|
7456
|
+
__init14() {this.spansFlushPromise = null}
|
|
5800
7457
|
|
|
5801
|
-
|
|
7458
|
+
__init15() {this.threadCache = /* @__PURE__ */ new Map()}
|
|
5802
7459
|
constructor({
|
|
5803
7460
|
objectType,
|
|
5804
7461
|
objectId,
|
|
5805
7462
|
rootSpanId,
|
|
5806
7463
|
ensureSpansFlushed,
|
|
5807
7464
|
state
|
|
5808
|
-
}) {;
|
|
7465
|
+
}) {;_class6.prototype.__init13.call(this);_class6.prototype.__init14.call(this);_class6.prototype.__init15.call(this);
|
|
5809
7466
|
this.objectType = objectType;
|
|
5810
7467
|
this.objectId = objectId;
|
|
5811
7468
|
this.rootSpanId = rootSpanId;
|
|
@@ -5854,11 +7511,11 @@ var LocalTrace = (_class5 = class {
|
|
|
5854
7511
|
const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
|
|
5855
7512
|
if (cachedSpans && cachedSpans.length > 0) {
|
|
5856
7513
|
let spans = includeScorers ? cachedSpans : cachedSpans.filter(
|
|
5857
|
-
(span) => _optionalChain([span, 'access',
|
|
7514
|
+
(span) => _optionalChain([span, 'access', _133 => _133.span_attributes, 'optionalAccess', _134 => _134.purpose]) !== "scorer"
|
|
5858
7515
|
);
|
|
5859
7516
|
if (spanType && spanType.length > 0) {
|
|
5860
7517
|
spans = spans.filter(
|
|
5861
|
-
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access',
|
|
7518
|
+
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _135 => _135.span_attributes, 'optionalAccess', _136 => _136.type]), () => ( "")))
|
|
5862
7519
|
);
|
|
5863
7520
|
}
|
|
5864
7521
|
return spans.map((span) => ({
|
|
@@ -5883,7 +7540,7 @@ var LocalTrace = (_class5 = class {
|
|
|
5883
7540
|
* Calls the API with the project_default preprocessor (which falls back to "thread").
|
|
5884
7541
|
*/
|
|
5885
7542
|
async getThread(options) {
|
|
5886
|
-
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7543
|
+
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _137 => _137.preprocessor]), () => ( "project_default"));
|
|
5887
7544
|
if (!this.threadCache.has(cacheKey)) {
|
|
5888
7545
|
const promise = this.fetchThread(options);
|
|
5889
7546
|
this.threadCache.set(cacheKey, promise);
|
|
@@ -5894,7 +7551,7 @@ var LocalTrace = (_class5 = class {
|
|
|
5894
7551
|
await this.ensureSpansReady();
|
|
5895
7552
|
await this.state.login({});
|
|
5896
7553
|
const result = await invoke({
|
|
5897
|
-
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7554
|
+
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _138 => _138.preprocessor]), () => ( "project_default")),
|
|
5898
7555
|
functionType: "preprocessor",
|
|
5899
7556
|
input: {
|
|
5900
7557
|
trace_ref: {
|
|
@@ -5925,7 +7582,7 @@ var LocalTrace = (_class5 = class {
|
|
|
5925
7582
|
}
|
|
5926
7583
|
await this.spansFlushPromise;
|
|
5927
7584
|
}
|
|
5928
|
-
},
|
|
7585
|
+
}, _class6);
|
|
5929
7586
|
|
|
5930
7587
|
// src/reporters/progress.ts
|
|
5931
7588
|
var SimpleProgressReporter = class {
|
|
@@ -5951,20 +7608,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
5951
7608
|
prompt: _v3.z.string()
|
|
5952
7609
|
}),
|
|
5953
7610
|
_v3.z.object({
|
|
5954
|
-
messages: _v3.z.array(
|
|
7611
|
+
messages: _v3.z.array(_chunkFZWPFCVEjs.ChatCompletionMessageParam)
|
|
5955
7612
|
})
|
|
5956
7613
|
]);
|
|
5957
7614
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
5958
7615
|
_v3.z.object({
|
|
5959
7616
|
model: _v3.z.string(),
|
|
5960
|
-
params:
|
|
7617
|
+
params: _chunkFZWPFCVEjs.ModelParams.optional(),
|
|
5961
7618
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
5962
7619
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
5963
7620
|
})
|
|
5964
7621
|
);
|
|
5965
7622
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
5966
7623
|
_v3.z.object({
|
|
5967
|
-
tools: _v3.z.array(
|
|
7624
|
+
tools: _v3.z.array(_chunkFZWPFCVEjs.ToolFunctionDefinition).optional()
|
|
5968
7625
|
})
|
|
5969
7626
|
);
|
|
5970
7627
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -6012,7 +7669,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
6012
7669
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
6013
7670
|
return parameters;
|
|
6014
7671
|
}
|
|
6015
|
-
if (
|
|
7672
|
+
if (_chunkFZWPFCVEjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
6016
7673
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
6017
7674
|
...resolvedSchema.data,
|
|
6018
7675
|
...parameters
|
|
@@ -6034,14 +7691,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
6034
7691
|
const value = parameters[name];
|
|
6035
7692
|
try {
|
|
6036
7693
|
if ("type" in schema && schema.type === "prompt") {
|
|
6037
|
-
const promptData = value ?
|
|
7694
|
+
const promptData = value ? _chunkFZWPFCVEjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
6038
7695
|
schema.default,
|
|
6039
7696
|
schema.default.tools
|
|
6040
7697
|
) : void 0;
|
|
6041
7698
|
if (!promptData) {
|
|
6042
7699
|
throw new Error(`Parameter '${name}' is required`);
|
|
6043
7700
|
}
|
|
6044
|
-
return [name,
|
|
7701
|
+
return [name, _chunkFZWPFCVEjs.Prompt.fromPromptData(name, promptData)];
|
|
6045
7702
|
} else if ("type" in schema && schema.type === "model") {
|
|
6046
7703
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
6047
7704
|
if (model === void 0) {
|
|
@@ -6070,10 +7727,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
|
|
|
6070
7727
|
const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
|
|
6071
7728
|
const validate = ajv.compile(schema);
|
|
6072
7729
|
if (!validate(parameters)) {
|
|
6073
|
-
const errorMessages = _optionalChain([validate, 'access',
|
|
7730
|
+
const errorMessages = _optionalChain([validate, 'access', _139 => _139.errors, 'optionalAccess', _140 => _140.map, 'call', _141 => _141((err) => {
|
|
6074
7731
|
const path = err.instancePath || "root";
|
|
6075
7732
|
return `${path}: ${err.message}`;
|
|
6076
|
-
}), 'access',
|
|
7733
|
+
}), 'access', _142 => _142.join, 'call', _143 => _143(", ")]);
|
|
6077
7734
|
throw Error(`Invalid parameters: ${errorMessages}`);
|
|
6078
7735
|
}
|
|
6079
7736
|
return rehydrateRemoteParameters(parameters, schema);
|
|
@@ -6092,7 +7749,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
6092
7749
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
6093
7750
|
return [
|
|
6094
7751
|
name,
|
|
6095
|
-
|
|
7752
|
+
_chunkFZWPFCVEjs.Prompt.fromPromptData(name, _chunkFZWPFCVEjs.PromptData.parse(value))
|
|
6096
7753
|
];
|
|
6097
7754
|
}
|
|
6098
7755
|
return [name, value];
|
|
@@ -6128,7 +7785,7 @@ var EvalResultWithSummary = class {
|
|
|
6128
7785
|
async function getPersistedBaseExperimentId(experiment) {
|
|
6129
7786
|
try {
|
|
6130
7787
|
return await experiment._getBaseExperimentId();
|
|
6131
|
-
} catch (
|
|
7788
|
+
} catch (e7) {
|
|
6132
7789
|
return void 0;
|
|
6133
7790
|
}
|
|
6134
7791
|
}
|
|
@@ -6140,7 +7797,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
6140
7797
|
return out;
|
|
6141
7798
|
}
|
|
6142
7799
|
function initExperiment2(state, options = {}) {
|
|
6143
|
-
return
|
|
7800
|
+
return _chunkFZWPFCVEjs.init.call(void 0, {
|
|
6144
7801
|
state,
|
|
6145
7802
|
...options,
|
|
6146
7803
|
setCurrent: false
|
|
@@ -6151,7 +7808,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
6151
7808
|
return void 0;
|
|
6152
7809
|
}
|
|
6153
7810
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
6154
|
-
if (!
|
|
7811
|
+
if (!_chunkFZWPFCVEjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
6155
7812
|
return void 0;
|
|
6156
7813
|
}
|
|
6157
7814
|
if (resolvedParameters.id === void 0) {
|
|
@@ -6187,10 +7844,10 @@ globalThis._evals = {
|
|
|
6187
7844
|
reporters: {}
|
|
6188
7845
|
};
|
|
6189
7846
|
function _initializeSpanContext() {
|
|
6190
|
-
globalThis._spanContext = { currentSpan:
|
|
7847
|
+
globalThis._spanContext = { currentSpan: _chunkFZWPFCVEjs.currentSpan, withCurrent: _chunkFZWPFCVEjs.withCurrent, startSpan: _chunkFZWPFCVEjs.startSpan, NOOP_SPAN: _chunkFZWPFCVEjs.NOOP_SPAN };
|
|
6191
7848
|
}
|
|
6192
7849
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
6193
|
-
const options =
|
|
7850
|
+
const options = _chunkFZWPFCVEjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
6194
7851
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
6195
7852
|
if (globalThis._evals.evaluators[evalName]) {
|
|
6196
7853
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -6241,7 +7898,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6241
7898
|
baseExperimentId: evaluator.baseExperimentId,
|
|
6242
7899
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
6243
7900
|
repoInfo: evaluator.repoInfo,
|
|
6244
|
-
dataset:
|
|
7901
|
+
dataset: _chunkFZWPFCVEjs.Dataset.isDataset(data) ? data : void 0,
|
|
6245
7902
|
parameters
|
|
6246
7903
|
});
|
|
6247
7904
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
@@ -6261,7 +7918,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6261
7918
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
6262
7919
|
let ret;
|
|
6263
7920
|
if (options.parent) {
|
|
6264
|
-
ret = await
|
|
7921
|
+
ret = await _chunkFZWPFCVEjs.withParent.call(void 0,
|
|
6265
7922
|
options.parent,
|
|
6266
7923
|
() => runEvaluator(
|
|
6267
7924
|
null,
|
|
@@ -6297,7 +7954,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6297
7954
|
if (experiment) {
|
|
6298
7955
|
await experiment.flush().catch(console.error);
|
|
6299
7956
|
} else if (options.parent) {
|
|
6300
|
-
await
|
|
7957
|
+
await _chunkFZWPFCVEjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
6301
7958
|
}
|
|
6302
7959
|
}
|
|
6303
7960
|
} finally {
|
|
@@ -6343,13 +8000,13 @@ function classifierName(classifier, classifier_idx) {
|
|
|
6343
8000
|
}
|
|
6344
8001
|
function buildSpanMetadata(results) {
|
|
6345
8002
|
return results.length === 1 ? results[0].metadata : results.reduce(
|
|
6346
|
-
(prev, s) =>
|
|
8003
|
+
(prev, s) => _chunkFZWPFCVEjs.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
|
|
6347
8004
|
{}
|
|
6348
8005
|
);
|
|
6349
8006
|
}
|
|
6350
8007
|
function buildSpanScores(results) {
|
|
6351
8008
|
const scoresRecord = results.reduce(
|
|
6352
|
-
(prev, s) =>
|
|
8009
|
+
(prev, s) => _chunkFZWPFCVEjs.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
|
|
6353
8010
|
{}
|
|
6354
8011
|
);
|
|
6355
8012
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
@@ -6379,7 +8036,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
6379
8036
|
return failing;
|
|
6380
8037
|
}
|
|
6381
8038
|
function validateClassificationResult(value, scorerName2) {
|
|
6382
|
-
if (!(typeof value === "object" && value !== null && !
|
|
8039
|
+
if (!(typeof value === "object" && value !== null && !_chunkFZWPFCVEjs.isEmpty.call(void 0, value))) {
|
|
6383
8040
|
throw new Error(
|
|
6384
8041
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
6385
8042
|
);
|
|
@@ -6408,7 +8065,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
6408
8065
|
);
|
|
6409
8066
|
metadata[`${kind}_errors`] = errorMap;
|
|
6410
8067
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
6411
|
-
|
|
8068
|
+
_chunkFZWPFCVEjs.debugLogger.forState(state).warn(
|
|
6412
8069
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
6413
8070
|
failures.map((f) => f.error)
|
|
6414
8071
|
);
|
|
@@ -6442,7 +8099,7 @@ var defaultErrorScoreHandler = ({
|
|
|
6442
8099
|
};
|
|
6443
8100
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
6444
8101
|
if (enableCache) {
|
|
6445
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
8102
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _144 => _144.spanCache, 'optionalAccess', _145 => _145.start, 'call', _146 => _146()]);
|
|
6446
8103
|
}
|
|
6447
8104
|
try {
|
|
6448
8105
|
if (typeof evaluator.data === "string") {
|
|
@@ -6463,7 +8120,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6463
8120
|
);
|
|
6464
8121
|
}
|
|
6465
8122
|
let name = dataResult.name;
|
|
6466
|
-
if (
|
|
8123
|
+
if (_chunkFZWPFCVEjs.isEmpty.call(void 0, name)) {
|
|
6467
8124
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
6468
8125
|
if (!baseExperiment) {
|
|
6469
8126
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -6497,7 +8154,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6497
8154
|
const experimentIdPromise = experiment ? (async () => {
|
|
6498
8155
|
try {
|
|
6499
8156
|
return await experiment.id;
|
|
6500
|
-
} catch (
|
|
8157
|
+
} catch (e8) {
|
|
6501
8158
|
return void 0;
|
|
6502
8159
|
}
|
|
6503
8160
|
})() : void 0;
|
|
@@ -6513,7 +8170,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6513
8170
|
if (cancelled) {
|
|
6514
8171
|
return;
|
|
6515
8172
|
}
|
|
6516
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
8173
|
+
const eventDataset = experiment ? experiment.dataset : _chunkFZWPFCVEjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
6517
8174
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
6518
8175
|
object_type: "dataset",
|
|
6519
8176
|
object_id: await eventDataset.id,
|
|
@@ -6521,8 +8178,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6521
8178
|
created: datum.created,
|
|
6522
8179
|
_xact_id: datum._xact_id
|
|
6523
8180
|
} : void 0;
|
|
6524
|
-
const parsedDatumOrigin =
|
|
6525
|
-
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess',
|
|
8181
|
+
const parsedDatumOrigin = _chunkFZWPFCVEjs.ObjectReference.safeParse(datum.origin);
|
|
8182
|
+
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _147 => _147.success]) ? parsedDatumOrigin.data : void 0)));
|
|
6526
8183
|
const baseEvent = {
|
|
6527
8184
|
name: "eval",
|
|
6528
8185
|
spanAttributes: {
|
|
@@ -6537,26 +8194,26 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6537
8194
|
}
|
|
6538
8195
|
};
|
|
6539
8196
|
const callback = async (rootSpan) => {
|
|
6540
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
8197
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, )));
|
|
6541
8198
|
const ensureSpansFlushed = async () => {
|
|
6542
8199
|
if (experiment) {
|
|
6543
|
-
await
|
|
8200
|
+
await _chunkFZWPFCVEjs.flush.call(void 0, { state: experiment.loggingState });
|
|
6544
8201
|
} else if (state) {
|
|
6545
|
-
await
|
|
8202
|
+
await _chunkFZWPFCVEjs.flush.call(void 0, { state });
|
|
6546
8203
|
} else {
|
|
6547
|
-
await
|
|
8204
|
+
await _chunkFZWPFCVEjs.flush.call(void 0, );
|
|
6548
8205
|
}
|
|
6549
8206
|
if (state) {
|
|
6550
8207
|
await state.flushOtel();
|
|
6551
8208
|
}
|
|
6552
8209
|
};
|
|
6553
8210
|
const parentStr = state.currentParent.getStore();
|
|
6554
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
8211
|
+
const parentComponents = typeof parentStr === "string" ? _chunkFZWPFCVEjs.SpanComponentsV4.fromStr(parentStr) : null;
|
|
6555
8212
|
const trace = state ? new LocalTrace({
|
|
6556
|
-
objectType: parentComponents ?
|
|
8213
|
+
objectType: parentComponents ? _chunkFZWPFCVEjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
6557
8214
|
parentComponents.data.object_type
|
|
6558
8215
|
) : "experiment",
|
|
6559
|
-
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async
|
|
8216
|
+
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _148 => _148.data, 'access', async _149 => _149.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
6560
8217
|
rootSpanId: rootSpan.rootSpanId,
|
|
6561
8218
|
ensureSpansFlushed,
|
|
6562
8219
|
state
|
|
@@ -6586,10 +8243,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6586
8243
|
span,
|
|
6587
8244
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
6588
8245
|
reportProgress: (event) => {
|
|
6589
|
-
_optionalChain([stream, 'optionalCall',
|
|
8246
|
+
_optionalChain([stream, 'optionalCall', _150 => _150({
|
|
6590
8247
|
...event,
|
|
6591
8248
|
id: rootSpan.id,
|
|
6592
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8249
|
+
origin: _optionalChain([baseEvent, 'access', _151 => _151.event, 'optionalAccess', _152 => _152.origin]),
|
|
6593
8250
|
name: evaluator.evalName,
|
|
6594
8251
|
object_type: "task"
|
|
6595
8252
|
})]);
|
|
@@ -6628,7 +8285,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6628
8285
|
trace
|
|
6629
8286
|
};
|
|
6630
8287
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
6631
|
-
const propagatedEvent =
|
|
8288
|
+
const propagatedEvent = _chunkFZWPFCVEjs.makeScorerPropagatedEvent.call(void 0,
|
|
6632
8289
|
await rootSpan.export()
|
|
6633
8290
|
);
|
|
6634
8291
|
const getOtherFields = (s) => {
|
|
@@ -6651,14 +8308,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6651
8308
|
if (scoreValue === null) return null;
|
|
6652
8309
|
if (Array.isArray(scoreValue)) {
|
|
6653
8310
|
for (const s of scoreValue) {
|
|
6654
|
-
if (!(typeof s === "object" && !
|
|
8311
|
+
if (!(typeof s === "object" && !_chunkFZWPFCVEjs.isEmpty.call(void 0, s))) {
|
|
6655
8312
|
throw new Error(
|
|
6656
8313
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
6657
8314
|
);
|
|
6658
8315
|
}
|
|
6659
8316
|
}
|
|
6660
8317
|
}
|
|
6661
|
-
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !
|
|
8318
|
+
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkFZWPFCVEjs.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
|
|
6662
8319
|
{
|
|
6663
8320
|
name: scorerNames[score_idx],
|
|
6664
8321
|
score: scoreValue
|
|
@@ -6666,7 +8323,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6666
8323
|
];
|
|
6667
8324
|
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
6668
8325
|
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
6669
|
-
(prev, s) =>
|
|
8326
|
+
(prev, s) => _chunkFZWPFCVEjs.mergeDicts.call(void 0, prev, {
|
|
6670
8327
|
[s.name]: getOtherFields(s)
|
|
6671
8328
|
}),
|
|
6672
8329
|
{}
|
|
@@ -6701,7 +8358,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6701
8358
|
)
|
|
6702
8359
|
);
|
|
6703
8360
|
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
6704
|
-
(prev, r) =>
|
|
8361
|
+
(prev, r) => _chunkFZWPFCVEjs.mergeDicts.call(void 0, prev, {
|
|
6705
8362
|
[r.name]: toClassificationItem(r)
|
|
6706
8363
|
}),
|
|
6707
8364
|
{}
|
|
@@ -6753,7 +8410,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6753
8410
|
evaluator.state
|
|
6754
8411
|
);
|
|
6755
8412
|
} catch (e) {
|
|
6756
|
-
|
|
8413
|
+
_chunkFZWPFCVEjs.logError.call(void 0, rootSpan, e);
|
|
6757
8414
|
error = e;
|
|
6758
8415
|
} finally {
|
|
6759
8416
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -6777,7 +8434,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6777
8434
|
tags: tags.length ? tags : void 0,
|
|
6778
8435
|
metadata,
|
|
6779
8436
|
error,
|
|
6780
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8437
|
+
origin: _optionalChain([baseEvent, 'access', _153 => _153.event, 'optionalAccess', _154 => _154.origin])
|
|
6781
8438
|
};
|
|
6782
8439
|
collectedResults.push({
|
|
6783
8440
|
...baseResult,
|
|
@@ -6787,7 +8444,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6787
8444
|
}
|
|
6788
8445
|
};
|
|
6789
8446
|
if (!experiment) {
|
|
6790
|
-
return await
|
|
8447
|
+
return await _chunkFZWPFCVEjs.traced.call(void 0, callback, {
|
|
6791
8448
|
...baseEvent,
|
|
6792
8449
|
state: evaluator.state
|
|
6793
8450
|
});
|
|
@@ -6817,7 +8474,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6817
8474
|
break;
|
|
6818
8475
|
}
|
|
6819
8476
|
scheduledTrials++;
|
|
6820
|
-
_optionalChain([progressReporter, 'access',
|
|
8477
|
+
_optionalChain([progressReporter, 'access', _155 => _155.setTotal, 'optionalCall', _156 => _156(evaluator.evalName, scheduledTrials)]);
|
|
6821
8478
|
q.pushAsync({ datum, trialIndex }).catch((e) => {
|
|
6822
8479
|
if (queueErrors.length < 5) {
|
|
6823
8480
|
queueErrors.push(e);
|
|
@@ -6829,7 +8486,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6829
8486
|
const cancel = async () => {
|
|
6830
8487
|
await new Promise((_, reject2) => {
|
|
6831
8488
|
if (cancelled) {
|
|
6832
|
-
reject2(new (0,
|
|
8489
|
+
reject2(new (0, _chunkFZWPFCVEjs.InternalAbortError)("Evaluator already cancelled"));
|
|
6833
8490
|
return;
|
|
6834
8491
|
}
|
|
6835
8492
|
let timeoutId;
|
|
@@ -6850,12 +8507,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6850
8507
|
};
|
|
6851
8508
|
if (evaluator.timeout) {
|
|
6852
8509
|
timeoutId = setTimeout(() => {
|
|
6853
|
-
rejectOnce(new (0,
|
|
8510
|
+
rejectOnce(new (0, _chunkFZWPFCVEjs.InternalAbortError)("Evaluator timed out"));
|
|
6854
8511
|
}, evaluator.timeout);
|
|
6855
8512
|
}
|
|
6856
8513
|
if (evaluator.signal) {
|
|
6857
8514
|
abortHandler = () => {
|
|
6858
|
-
rejectOnce(new (0,
|
|
8515
|
+
rejectOnce(new (0, _chunkFZWPFCVEjs.InternalAbortError)("Evaluator aborted"));
|
|
6859
8516
|
};
|
|
6860
8517
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
6861
8518
|
}
|
|
@@ -6878,9 +8535,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6878
8535
|
}
|
|
6879
8536
|
} catch (e) {
|
|
6880
8537
|
q.kill();
|
|
6881
|
-
if (e instanceof
|
|
6882
|
-
if (
|
|
6883
|
-
|
|
8538
|
+
if (e instanceof _chunkFZWPFCVEjs.InternalAbortError) {
|
|
8539
|
+
if (_chunkCDIKAHDZjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
8540
|
+
_chunkFZWPFCVEjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
6884
8541
|
}
|
|
6885
8542
|
}
|
|
6886
8543
|
throw e;
|
|
@@ -6904,9 +8561,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6904
8561
|
);
|
|
6905
8562
|
} finally {
|
|
6906
8563
|
if (enableCache) {
|
|
6907
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
6908
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
6909
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
8564
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _157 => _157.spanCache]);
|
|
8565
|
+
_optionalChain([spanCache, 'optionalAccess', _158 => _158.dispose, 'call', _159 => _159()]);
|
|
8566
|
+
_optionalChain([spanCache, 'optionalAccess', _160 => _160.stop, 'call', _161 => _161()]);
|
|
6910
8567
|
}
|
|
6911
8568
|
}
|
|
6912
8569
|
}
|
|
@@ -6999,25 +8656,25 @@ var defaultReporter = {
|
|
|
6999
8656
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
7000
8657
|
}
|
|
7001
8658
|
if (jsonl) {
|
|
7002
|
-
|
|
8659
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
7003
8660
|
} else {
|
|
7004
|
-
|
|
7005
|
-
|
|
8661
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("Experiment summary");
|
|
8662
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("==================");
|
|
7006
8663
|
if (summary.comparisonExperimentName) {
|
|
7007
|
-
|
|
8664
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
7008
8665
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
7009
8666
|
);
|
|
7010
|
-
|
|
8667
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("");
|
|
7011
8668
|
}
|
|
7012
8669
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
7013
8670
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
7014
8671
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
7015
8672
|
if (hasScores || hasMetrics) {
|
|
7016
8673
|
if (hasComparison) {
|
|
7017
|
-
|
|
8674
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
7018
8675
|
"Name Value Change Improvements Regressions"
|
|
7019
8676
|
);
|
|
7020
|
-
|
|
8677
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
7021
8678
|
"----------------------------------------------------------------"
|
|
7022
8679
|
);
|
|
7023
8680
|
}
|
|
@@ -7026,18 +8683,18 @@ var defaultReporter = {
|
|
|
7026
8683
|
const scoreValue = `${scorePercent}%`;
|
|
7027
8684
|
if (hasComparison) {
|
|
7028
8685
|
let diffString = "-";
|
|
7029
|
-
if (!
|
|
8686
|
+
if (!_chunkFZWPFCVEjs.isEmpty.call(void 0, score.diff)) {
|
|
7030
8687
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
7031
8688
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
7032
8689
|
diffString = `${diffSign}${diffPercent}%`;
|
|
7033
8690
|
}
|
|
7034
8691
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
7035
8692
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
7036
|
-
|
|
8693
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
7037
8694
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
7038
8695
|
);
|
|
7039
8696
|
} else {
|
|
7040
|
-
|
|
8697
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
7041
8698
|
}
|
|
7042
8699
|
}
|
|
7043
8700
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -7046,30 +8703,30 @@ var defaultReporter = {
|
|
|
7046
8703
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
7047
8704
|
if (hasComparison) {
|
|
7048
8705
|
let diffString = "-";
|
|
7049
|
-
if (!
|
|
8706
|
+
if (!_chunkFZWPFCVEjs.isEmpty.call(void 0, metric.diff)) {
|
|
7050
8707
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
7051
8708
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
7052
8709
|
diffString = `${diffSign}${diffPercent}%`;
|
|
7053
8710
|
}
|
|
7054
8711
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
7055
8712
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
7056
|
-
|
|
8713
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
7057
8714
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
7058
8715
|
);
|
|
7059
8716
|
} else {
|
|
7060
|
-
|
|
8717
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
7061
8718
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
7062
8719
|
);
|
|
7063
8720
|
}
|
|
7064
8721
|
}
|
|
7065
8722
|
}
|
|
7066
8723
|
if (summary.experimentUrl) {
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
8724
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("");
|
|
8725
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(`View results for ${summary.experimentName}`);
|
|
8726
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
|
|
7070
8727
|
}
|
|
7071
8728
|
}
|
|
7072
|
-
|
|
8729
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("");
|
|
7073
8730
|
return failingResults.length === 0;
|
|
7074
8731
|
},
|
|
7075
8732
|
async reportRun(evalReports) {
|
|
@@ -7089,7 +8746,7 @@ function agentAssertionScorer(callback, options = {}) {
|
|
|
7089
8746
|
});
|
|
7090
8747
|
const resources = {};
|
|
7091
8748
|
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
7092
|
-
resources.spans = await _optionalChain([args, 'access',
|
|
8749
|
+
resources.spans = await _optionalChain([args, 'access', _162 => _162.trace, 'optionalAccess', _163 => _163.getSpans, 'call', _164 => _164({ spanType: ["tool"] })]);
|
|
7093
8750
|
}
|
|
7094
8751
|
const results = await Promise.all(
|
|
7095
8752
|
assertions.map(async (assertion) => {
|
|
@@ -7247,7 +8904,7 @@ async function validateSchema(schema, value) {
|
|
|
7247
8904
|
}
|
|
7248
8905
|
}
|
|
7249
8906
|
function toolCalls(spans) {
|
|
7250
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
8907
|
+
return spans.filter((span) => _optionalChain([span, 'access', _165 => _165.span_attributes, 'optionalAccess', _166 => _166.type]) === "tool");
|
|
7251
8908
|
}
|
|
7252
8909
|
function matchingToolCalls(spans, toolName, options) {
|
|
7253
8910
|
return toolCalls(spans).filter((span) => {
|
|
@@ -7265,17 +8922,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
7265
8922
|
});
|
|
7266
8923
|
}
|
|
7267
8924
|
function getToolName(span) {
|
|
7268
|
-
const spanName = [_optionalChain([span, 'access',
|
|
7269
|
-
if (_optionalChain([spanName, 'optionalAccess',
|
|
8925
|
+
const spanName = [_optionalChain([span, 'access', _167 => _167.span_attributes, 'optionalAccess', _168 => _168.name]), span.name].map(normalizeToolName).find((value) => value !== void 0);
|
|
8926
|
+
if (_optionalChain([spanName, 'optionalAccess', _169 => _169.includes, 'call', _170 => _170("/")])) {
|
|
7270
8927
|
return spanName;
|
|
7271
8928
|
}
|
|
7272
8929
|
const metadataName = [
|
|
7273
|
-
_optionalChain([span, 'access',
|
|
7274
|
-
_optionalChain([span, 'access',
|
|
8930
|
+
_optionalChain([span, 'access', _171 => _171.metadata, 'optionalAccess', _172 => _172.tool_name]),
|
|
8931
|
+
_optionalChain([span, 'access', _173 => _173.metadata, 'optionalAccess', _174 => _174["gen_ai.tool.name"]])
|
|
7275
8932
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
7276
8933
|
const mcpServer = [
|
|
7277
|
-
_optionalChain([span, 'access',
|
|
7278
|
-
_optionalChain([span, 'access',
|
|
8934
|
+
_optionalChain([span, 'access', _175 => _175.metadata, 'optionalAccess', _176 => _176["mcp.server"]]),
|
|
8935
|
+
_optionalChain([span, 'access', _177 => _177.metadata, 'optionalAccess', _178 => _178["openai_codex.mcp.server"]])
|
|
7279
8936
|
].find((value) => typeof value === "string" && value !== "");
|
|
7280
8937
|
if (metadataName && mcpServer) {
|
|
7281
8938
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -7345,7 +9002,7 @@ function formatValue(value) {
|
|
|
7345
9002
|
return serialized;
|
|
7346
9003
|
}
|
|
7347
9004
|
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
7348
|
-
} catch (
|
|
9005
|
+
} catch (e9) {
|
|
7349
9006
|
return String(value);
|
|
7350
9007
|
}
|
|
7351
9008
|
}
|
|
@@ -7458,7 +9115,7 @@ var ProjectBuilder = class {
|
|
|
7458
9115
|
}
|
|
7459
9116
|
};
|
|
7460
9117
|
var projects = new ProjectBuilder();
|
|
7461
|
-
var Project2 = (
|
|
9118
|
+
var Project2 = (_class7 = class {
|
|
7462
9119
|
|
|
7463
9120
|
|
|
7464
9121
|
|
|
@@ -7466,10 +9123,10 @@ var Project2 = (_class6 = class {
|
|
|
7466
9123
|
|
|
7467
9124
|
|
|
7468
9125
|
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
constructor(args) {;
|
|
9126
|
+
__init16() {this._publishableCodeFunctions = []}
|
|
9127
|
+
__init17() {this._publishablePrompts = []}
|
|
9128
|
+
__init18() {this._publishableParameters = []}
|
|
9129
|
+
constructor(args) {;_class7.prototype.__init16.call(this);_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);
|
|
7473
9130
|
_initializeSpanContext();
|
|
7474
9131
|
this.name = "name" in args ? args.name : void 0;
|
|
7475
9132
|
this.id = "id" in args ? args.id : void 0;
|
|
@@ -7504,7 +9161,7 @@ var Project2 = (_class6 = class {
|
|
|
7504
9161
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
7505
9162
|
return;
|
|
7506
9163
|
}
|
|
7507
|
-
await
|
|
9164
|
+
await _chunkFZWPFCVEjs.login.call(void 0, );
|
|
7508
9165
|
const projectMap = new ProjectNameIdMap();
|
|
7509
9166
|
const functionDefinitions = [];
|
|
7510
9167
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -7518,16 +9175,16 @@ var Project2 = (_class6 = class {
|
|
|
7518
9175
|
functionDefinitions.push(functionDefinition);
|
|
7519
9176
|
}
|
|
7520
9177
|
}
|
|
7521
|
-
await
|
|
9178
|
+
await _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
7522
9179
|
functions: functionDefinitions
|
|
7523
9180
|
});
|
|
7524
9181
|
}
|
|
7525
|
-
},
|
|
7526
|
-
var ToolBuilder = (
|
|
7527
|
-
constructor(project) {;
|
|
9182
|
+
}, _class7);
|
|
9183
|
+
var ToolBuilder = (_class8 = class {
|
|
9184
|
+
constructor(project) {;_class8.prototype.__init19.call(this);
|
|
7528
9185
|
this.project = project;
|
|
7529
9186
|
}
|
|
7530
|
-
|
|
9187
|
+
__init19() {this.taskCounter = 0}
|
|
7531
9188
|
// This type definition is just a catch all so that the implementation can be
|
|
7532
9189
|
// less specific than the two more specific declarations above.
|
|
7533
9190
|
create(opts) {
|
|
@@ -7536,12 +9193,12 @@ var ToolBuilder = (_class7 = class {
|
|
|
7536
9193
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
7537
9194
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
7538
9195
|
if (resolvedName.trim().length === 0) {
|
|
7539
|
-
resolvedName = `Tool ${
|
|
9196
|
+
resolvedName = `Tool ${_chunkCDIKAHDZjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7540
9197
|
}
|
|
7541
9198
|
const tool = new CodeFunction(this.project, {
|
|
7542
9199
|
handler,
|
|
7543
9200
|
name: resolvedName,
|
|
7544
|
-
slug: _nullishCoalesce(slug, () => (
|
|
9201
|
+
slug: _nullishCoalesce(slug, () => ( _chunkFZWPFCVEjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
7545
9202
|
type: "tool",
|
|
7546
9203
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
7547
9204
|
parameters,
|
|
@@ -7552,12 +9209,12 @@ var ToolBuilder = (_class7 = class {
|
|
|
7552
9209
|
this.project.addCodeFunction(tool);
|
|
7553
9210
|
return tool;
|
|
7554
9211
|
}
|
|
7555
|
-
},
|
|
7556
|
-
var ScorerBuilder = (
|
|
7557
|
-
constructor(project) {;
|
|
9212
|
+
}, _class8);
|
|
9213
|
+
var ScorerBuilder = (_class9 = class {
|
|
9214
|
+
constructor(project) {;_class9.prototype.__init20.call(this);
|
|
7558
9215
|
this.project = project;
|
|
7559
9216
|
}
|
|
7560
|
-
|
|
9217
|
+
__init20() {this.taskCounter = 0}
|
|
7561
9218
|
create(opts) {
|
|
7562
9219
|
this.taskCounter++;
|
|
7563
9220
|
let resolvedName = opts.name;
|
|
@@ -7565,9 +9222,9 @@ var ScorerBuilder = (_class8 = class {
|
|
|
7565
9222
|
resolvedName = opts.handler.name;
|
|
7566
9223
|
}
|
|
7567
9224
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7568
|
-
resolvedName = `Scorer ${
|
|
9225
|
+
resolvedName = `Scorer ${_chunkCDIKAHDZjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7569
9226
|
}
|
|
7570
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9227
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFZWPFCVEjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7571
9228
|
if ("handler" in opts) {
|
|
7572
9229
|
const scorer = new CodeFunction(this.project, {
|
|
7573
9230
|
...opts,
|
|
@@ -7611,19 +9268,19 @@ var ScorerBuilder = (_class8 = class {
|
|
|
7611
9268
|
this.project.addPrompt(codePrompt);
|
|
7612
9269
|
}
|
|
7613
9270
|
}
|
|
7614
|
-
},
|
|
7615
|
-
var ClassifierBuilder = (
|
|
7616
|
-
constructor(project) {;
|
|
9271
|
+
}, _class9);
|
|
9272
|
+
var ClassifierBuilder = (_class10 = class {
|
|
9273
|
+
constructor(project) {;_class10.prototype.__init21.call(this);
|
|
7617
9274
|
this.project = project;
|
|
7618
9275
|
}
|
|
7619
|
-
|
|
9276
|
+
__init21() {this.taskCounter = 0}
|
|
7620
9277
|
create(opts) {
|
|
7621
9278
|
this.taskCounter++;
|
|
7622
9279
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
7623
9280
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7624
|
-
resolvedName = `Classifier ${
|
|
9281
|
+
resolvedName = `Classifier ${_chunkCDIKAHDZjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7625
9282
|
}
|
|
7626
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9283
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFZWPFCVEjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7627
9284
|
const classifier = new CodeFunction(this.project, {
|
|
7628
9285
|
...opts,
|
|
7629
9286
|
name: resolvedName,
|
|
@@ -7633,7 +9290,7 @@ var ClassifierBuilder = (_class9 = class {
|
|
|
7633
9290
|
this.project.addCodeFunction(classifier);
|
|
7634
9291
|
return classifier;
|
|
7635
9292
|
}
|
|
7636
|
-
},
|
|
9293
|
+
}, _class10);
|
|
7637
9294
|
var CodeFunction = class {
|
|
7638
9295
|
constructor(project, opts) {
|
|
7639
9296
|
this.project = project;
|
|
@@ -7750,18 +9407,18 @@ var PromptBuilder = class {
|
|
|
7750
9407
|
rawTools.push(tool);
|
|
7751
9408
|
}
|
|
7752
9409
|
}
|
|
7753
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9410
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFZWPFCVEjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7754
9411
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
7755
9412
|
const promptRow = {
|
|
7756
9413
|
id: opts.id,
|
|
7757
|
-
_xact_id: opts.version ?
|
|
9414
|
+
_xact_id: opts.version ? _chunkFZWPFCVEjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
7758
9415
|
name: opts.name,
|
|
7759
9416
|
slug,
|
|
7760
9417
|
prompt_data: promptData,
|
|
7761
9418
|
tags: opts.tags,
|
|
7762
9419
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
7763
9420
|
};
|
|
7764
|
-
const prompt = new (0,
|
|
9421
|
+
const prompt = new (0, _chunkFZWPFCVEjs.Prompt)(
|
|
7765
9422
|
promptRow,
|
|
7766
9423
|
{},
|
|
7767
9424
|
// It doesn't make sense to specify defaults here.
|
|
@@ -7815,7 +9472,7 @@ var ParametersBuilder = class {
|
|
|
7815
9472
|
this.project = project;
|
|
7816
9473
|
}
|
|
7817
9474
|
create(opts) {
|
|
7818
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9475
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFZWPFCVEjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7819
9476
|
const codeParameters = new CodeParameters(this.project, {
|
|
7820
9477
|
name: opts.name,
|
|
7821
9478
|
slug,
|
|
@@ -7854,7 +9511,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
7854
9511
|
required.push(name);
|
|
7855
9512
|
}
|
|
7856
9513
|
} else {
|
|
7857
|
-
const schemaObj =
|
|
9514
|
+
const schemaObj = _chunkFZWPFCVEjs.zodToJsonSchema.call(void 0, value);
|
|
7858
9515
|
properties[name] = schemaObj;
|
|
7859
9516
|
if (!("default" in schemaObj)) {
|
|
7860
9517
|
required.push(name);
|
|
@@ -7878,16 +9535,16 @@ function getDefaultDataFromParametersSchema(schema) {
|
|
|
7878
9535
|
})
|
|
7879
9536
|
);
|
|
7880
9537
|
}
|
|
7881
|
-
var ProjectNameIdMap = (
|
|
7882
|
-
|
|
7883
|
-
|
|
9538
|
+
var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__init22.call(this);_class11.prototype.__init23.call(this); }
|
|
9539
|
+
__init22() {this.nameToId = {}}
|
|
9540
|
+
__init23() {this.idToName = {}}
|
|
7884
9541
|
async getId(projectName) {
|
|
7885
9542
|
if (!(projectName in this.nameToId)) {
|
|
7886
|
-
const response = await
|
|
9543
|
+
const response = await _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
7887
9544
|
project_name: projectName
|
|
7888
9545
|
});
|
|
7889
9546
|
const result = _v3.z.object({
|
|
7890
|
-
project:
|
|
9547
|
+
project: _chunkFZWPFCVEjs.Project
|
|
7891
9548
|
}).parse(response);
|
|
7892
9549
|
const projectId = result.project.id;
|
|
7893
9550
|
this.nameToId[projectName] = projectId;
|
|
@@ -7897,10 +9554,10 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7897
9554
|
}
|
|
7898
9555
|
async getName(projectId) {
|
|
7899
9556
|
if (!(projectId in this.idToName)) {
|
|
7900
|
-
const response = await
|
|
9557
|
+
const response = await _chunkFZWPFCVEjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
7901
9558
|
id: projectId
|
|
7902
9559
|
});
|
|
7903
|
-
const result = _v3.z.array(
|
|
9560
|
+
const result = _v3.z.array(_chunkFZWPFCVEjs.Project).nonempty().parse(response);
|
|
7904
9561
|
const projectName = result[0].name;
|
|
7905
9562
|
this.idToName[projectId] = projectName;
|
|
7906
9563
|
this.nameToId[projectName] = projectId;
|
|
@@ -7913,23 +9570,23 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7913
9570
|
}
|
|
7914
9571
|
return this.getId(project.name);
|
|
7915
9572
|
}
|
|
7916
|
-
},
|
|
9573
|
+
}, _class11);
|
|
7917
9574
|
|
|
7918
9575
|
// dev/types.ts
|
|
7919
9576
|
|
|
7920
9577
|
var evalBodySchema = _v3.z.object({
|
|
7921
9578
|
name: _v3.z.string(),
|
|
7922
9579
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
7923
|
-
data:
|
|
9580
|
+
data: _chunkFZWPFCVEjs.RunEval.shape.data,
|
|
7924
9581
|
scores: _v3.z.array(
|
|
7925
9582
|
_v3.z.object({
|
|
7926
|
-
function_id:
|
|
9583
|
+
function_id: _chunkFZWPFCVEjs.FunctionId,
|
|
7927
9584
|
name: _v3.z.string()
|
|
7928
9585
|
})
|
|
7929
9586
|
).nullish(),
|
|
7930
9587
|
experiment_name: _v3.z.string().nullish(),
|
|
7931
9588
|
project_id: _v3.z.string().nullish(),
|
|
7932
|
-
parent:
|
|
9589
|
+
parent: _chunkFZWPFCVEjs.InvokeParent.optional(),
|
|
7933
9590
|
stream: _v3.z.boolean().optional()
|
|
7934
9591
|
});
|
|
7935
9592
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -7937,7 +9594,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
7937
9594
|
_v3.z.union([
|
|
7938
9595
|
_v3.z.object({
|
|
7939
9596
|
type: _v3.z.literal("prompt"),
|
|
7940
|
-
default:
|
|
9597
|
+
default: _chunkFZWPFCVEjs.PromptData.optional(),
|
|
7941
9598
|
description: _v3.z.string().optional()
|
|
7942
9599
|
}),
|
|
7943
9600
|
_v3.z.object({
|
|
@@ -7993,7 +9650,12 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
7993
9650
|
);
|
|
7994
9651
|
|
|
7995
9652
|
// src/node/index.ts
|
|
7996
|
-
|
|
9653
|
+
_chunkFZWPFCVEjs.configureNode.call(void 0, );
|
|
9654
|
+
|
|
9655
|
+
|
|
9656
|
+
|
|
9657
|
+
|
|
9658
|
+
|
|
7997
9659
|
|
|
7998
9660
|
|
|
7999
9661
|
|
|
@@ -8159,4 +9821,4 @@ _chunkFY7DAKA5js.configureNode.call(void 0, );
|
|
|
8159
9821
|
|
|
8160
9822
|
|
|
8161
9823
|
|
|
8162
|
-
exports.Attachment =
|
|
9824
|
+
exports.Attachment = _chunkFZWPFCVEjs.Attachment; exports.AttachmentReference = _chunkFZWPFCVEjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkFZWPFCVEjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkFZWPFCVEjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkFZWPFCVEjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkFZWPFCVEjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkFZWPFCVEjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkFZWPFCVEjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkFZWPFCVEjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkFZWPFCVEjs.BraintrustState; exports.BraintrustStream = _chunkFZWPFCVEjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkFZWPFCVEjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkFZWPFCVEjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkFZWPFCVEjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkFZWPFCVEjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkFZWPFCVEjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkFZWPFCVEjs.Experiment; exports.ExternalAttachment = _chunkFZWPFCVEjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkFZWPFCVEjs.FailedHTTPResponse; exports.IDGenerator = _chunkFZWPFCVEjs.IDGenerator; exports.JSONAttachment = _chunkFZWPFCVEjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkFZWPFCVEjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkFZWPFCVEjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkFZWPFCVEjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkFZWPFCVEjs.Logger; exports.LoginInvalidOrgError = _chunkFZWPFCVEjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkFZWPFCVEjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkFZWPFCVEjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkFZWPFCVEjs.NoopSpan; exports.OTELIDGenerator = _chunkFZWPFCVEjs.OTELIDGenerator; exports.ObjectFetcher = _chunkFZWPFCVEjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkFZWPFCVEjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkFZWPFCVEjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkFZWPFCVEjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkFZWPFCVEjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkFZWPFCVEjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkFZWPFCVEjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkFZWPFCVEjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkFZWPFCVEjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkFZWPFCVEjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkFZWPFCVEjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkFZWPFCVEjs._internalGetGlobalState; exports._internalIso = _chunkCDIKAHDZjs.isomorph_default; exports._internalSetInitialState = _chunkFZWPFCVEjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkFZWPFCVEjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkFZWPFCVEjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkFZWPFCVEjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkFZWPFCVEjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkFZWPFCVEjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkFZWPFCVEjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkFZWPFCVEjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkFZWPFCVEjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkFZWPFCVEjs.currentExperiment; exports.currentLogger = _chunkFZWPFCVEjs.currentLogger; exports.currentSpan = _chunkFZWPFCVEjs.currentSpan; exports.deepCopyEvent = _chunkFZWPFCVEjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkFZWPFCVEjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkFZWPFCVEjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkFZWPFCVEjs.extractTraceContextFromHeaders; exports.flush = _chunkFZWPFCVEjs.flush; exports.getContextManager = _chunkFZWPFCVEjs.getContextManager; exports.getIdGenerator = _chunkFZWPFCVEjs.getIdGenerator; exports.getPromptVersions = _chunkFZWPFCVEjs.getPromptVersions; exports.getSpanParentObject = _chunkFZWPFCVEjs.getSpanParentObject; exports.getTemplateRenderer = _chunkFZWPFCVEjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkFZWPFCVEjs.init; exports.initDataset = _chunkFZWPFCVEjs.initDataset; exports.initExperiment = _chunkFZWPFCVEjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkFZWPFCVEjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkFZWPFCVEjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkFZWPFCVEjs.isTemplateFormat; exports.loadParameters = _chunkFZWPFCVEjs.loadParameters; exports.loadPrompt = _chunkFZWPFCVEjs.loadPrompt; exports.log = _chunkFZWPFCVEjs.log; exports.logError = _chunkFZWPFCVEjs.logError; exports.login = _chunkFZWPFCVEjs.login; exports.loginToState = _chunkFZWPFCVEjs.loginToState; exports.logs3OverflowUploadSchema = _chunkFZWPFCVEjs.logs3OverflowUploadSchema; exports.newId = _chunkFZWPFCVEjs.newId; exports.parseCachedHeader = _chunkFZWPFCVEjs.parseCachedHeader; exports.parseTemplateFormat = _chunkFZWPFCVEjs.parseTemplateFormat; exports.permalink = _chunkFZWPFCVEjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkFZWPFCVEjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkFZWPFCVEjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkFZWPFCVEjs.registerTemplatePlugin; exports.renderMessage = _chunkFZWPFCVEjs.renderMessage; exports.renderPromptParams = _chunkFZWPFCVEjs.renderPromptParams; exports.renderTemplateContent = _chunkFZWPFCVEjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkFZWPFCVEjs.setFetch; exports.setMaskingFunction = _chunkFZWPFCVEjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkFZWPFCVEjs.spanComponentsToObjectId; exports.startSpan = _chunkFZWPFCVEjs.startSpan; exports.summarize = _chunkFZWPFCVEjs.summarize; exports.templateRegistry = _chunkFZWPFCVEjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkFZWPFCVEjs.ToolFunctionDefinition; exports.traceable = _chunkFZWPFCVEjs.traceable; exports.traced = _chunkFZWPFCVEjs.traced; exports.updateSpan = _chunkFZWPFCVEjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkFZWPFCVEjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkFZWPFCVEjs.utf8ByteLength; exports.withCurrent = _chunkFZWPFCVEjs.withCurrent; exports.withDataset = _chunkFZWPFCVEjs.withDataset; exports.withExperiment = _chunkFZWPFCVEjs.withExperiment; exports.withLogger = _chunkFZWPFCVEjs.withLogger; exports.withParent = _chunkFZWPFCVEjs.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.wrapLangSmithClient = wrapLangSmithClient; exports.wrapLangSmithRunTrees = wrapLangSmithRunTrees; exports.wrapLangSmithTraceable = wrapLangSmithTraceable; exports.wrapMastraAgent = _chunkFZWPFCVEjs.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 = _chunkFZWPFCVEjs.wrapTraced; exports.wrapVitest = wrapVitest;
|