braintrust 3.22.0 → 3.23.1
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 +43 -0
- package/dev/dist/index.d.mts +1 -1
- package/dev/dist/index.d.ts +1 -1
- package/dev/dist/index.js +1354 -654
- package/dev/dist/index.mjs +736 -36
- 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 +149 -20
- 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 +11 -13
- package/dist/browser.d.ts +11 -13
- package/dist/browser.js +1098 -205
- package/dist/browser.mjs +1098 -205
- package/dist/{chunk-KMGUTPB7.mjs → chunk-36IPYKMG.mjs} +20 -1
- package/dist/{chunk-MWVVR5LR.js → chunk-B6ZQIAK3.js} +1506 -822
- package/dist/{chunk-BFGIH2ZJ.js → chunk-CDIKAHDZ.js} +21 -2
- package/dist/{chunk-ZG2O3XVF.mjs → chunk-RBXD2KYN.mjs} +719 -35
- package/dist/cli.js +737 -37
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +1098 -205
- package/dist/edge-light.mjs +1098 -205
- package/dist/index.d.mts +11 -13
- package/dist/index.d.ts +11 -13
- package/dist/index.js +786 -593
- package/dist/index.mjs +346 -153
- package/dist/instrumentation/index.d.mts +3 -11
- package/dist/instrumentation/index.d.ts +3 -11
- package/dist/instrumentation/index.js +788 -183
- package/dist/instrumentation/index.mjs +788 -183
- 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 +1098 -205
- package/dist/workerd.mjs +1098 -205
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
var
|
|
142
|
+
var _chunkB6ZQIAK3js = require('./chunk-B6ZQIAK3.js');
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
|
|
@@ -162,151 +162,152 @@ var _chunkMWVVR5LRjs = require('./chunk-MWVVR5LR.js');
|
|
|
162
162
|
|
|
163
163
|
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
|
|
166
|
+
var _chunkCDIKAHDZjs = require('./chunk-CDIKAHDZ.js');
|
|
166
167
|
|
|
167
168
|
// src/exports.ts
|
|
168
169
|
var exports_exports = {};
|
|
169
|
-
|
|
170
|
-
Attachment: () =>
|
|
171
|
-
AttachmentReference: () =>
|
|
172
|
-
BAGGAGE_HEADER: () =>
|
|
173
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
174
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
175
|
-
BRAINTRUST_PARENT_KEY: () =>
|
|
176
|
-
BaseAttachment: () =>
|
|
170
|
+
_chunkCDIKAHDZjs.__export.call(void 0, exports_exports, {
|
|
171
|
+
Attachment: () => _chunkB6ZQIAK3js.Attachment,
|
|
172
|
+
AttachmentReference: () => _chunkB6ZQIAK3js.AttachmentReference,
|
|
173
|
+
BAGGAGE_HEADER: () => _chunkB6ZQIAK3js.BAGGAGE_HEADER,
|
|
174
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkB6ZQIAK3js.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
175
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkB6ZQIAK3js.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
176
|
+
BRAINTRUST_PARENT_KEY: () => _chunkB6ZQIAK3js.BRAINTRUST_PARENT_KEY,
|
|
177
|
+
BaseAttachment: () => _chunkB6ZQIAK3js.BaseAttachment,
|
|
177
178
|
BaseExperiment: () => BaseExperiment,
|
|
178
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
179
|
+
BraintrustLangChainCallbackHandler: () => _chunkB6ZQIAK3js.BraintrustLangChainCallbackHandler,
|
|
179
180
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
180
|
-
BraintrustObservabilityExporter: () =>
|
|
181
|
-
BraintrustState: () =>
|
|
182
|
-
BraintrustStream: () =>
|
|
181
|
+
BraintrustObservabilityExporter: () => _chunkB6ZQIAK3js.BraintrustObservabilityExporter,
|
|
182
|
+
BraintrustState: () => _chunkB6ZQIAK3js.BraintrustState,
|
|
183
|
+
BraintrustStream: () => _chunkB6ZQIAK3js.BraintrustStream,
|
|
183
184
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
184
185
|
CodeFunction: () => CodeFunction,
|
|
185
186
|
CodePrompt: () => CodePrompt,
|
|
186
|
-
ContextManager: () =>
|
|
187
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
188
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
189
|
-
Dataset: () =>
|
|
187
|
+
ContextManager: () => _chunkB6ZQIAK3js.ContextManager,
|
|
188
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkB6ZQIAK3js.DEFAULT_FETCH_BATCH_SIZE,
|
|
189
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkB6ZQIAK3js.DEFAULT_MAX_REQUEST_SIZE,
|
|
190
|
+
Dataset: () => _chunkB6ZQIAK3js.Dataset,
|
|
190
191
|
DatasetPipeline: () => DatasetPipeline,
|
|
191
|
-
ERR_PERMALINK: () =>
|
|
192
|
+
ERR_PERMALINK: () => _chunkB6ZQIAK3js.ERR_PERMALINK,
|
|
192
193
|
Eval: () => Eval,
|
|
193
194
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
194
|
-
Experiment: () =>
|
|
195
|
-
ExternalAttachment: () =>
|
|
196
|
-
FailedHTTPResponse: () =>
|
|
197
|
-
IDGenerator: () =>
|
|
198
|
-
JSONAttachment: () =>
|
|
199
|
-
LEGACY_CACHED_HEADER: () =>
|
|
200
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
201
|
-
LazyValue: () =>
|
|
195
|
+
Experiment: () => _chunkB6ZQIAK3js.Experiment,
|
|
196
|
+
ExternalAttachment: () => _chunkB6ZQIAK3js.ExternalAttachment,
|
|
197
|
+
FailedHTTPResponse: () => _chunkB6ZQIAK3js.FailedHTTPResponse,
|
|
198
|
+
IDGenerator: () => _chunkB6ZQIAK3js.IDGenerator,
|
|
199
|
+
JSONAttachment: () => _chunkB6ZQIAK3js.JSONAttachment,
|
|
200
|
+
LEGACY_CACHED_HEADER: () => _chunkB6ZQIAK3js.LEGACY_CACHED_HEADER,
|
|
201
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkB6ZQIAK3js.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
202
|
+
LazyValue: () => _chunkB6ZQIAK3js.LazyValue,
|
|
202
203
|
LocalTrace: () => LocalTrace,
|
|
203
|
-
Logger: () =>
|
|
204
|
-
LoginInvalidOrgError: () =>
|
|
205
|
-
NOOP_SPAN: () =>
|
|
206
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
207
|
-
NoopSpan: () =>
|
|
208
|
-
OTELIDGenerator: () =>
|
|
209
|
-
ObjectFetcher: () =>
|
|
204
|
+
Logger: () => _chunkB6ZQIAK3js.Logger,
|
|
205
|
+
LoginInvalidOrgError: () => _chunkB6ZQIAK3js.LoginInvalidOrgError,
|
|
206
|
+
NOOP_SPAN: () => _chunkB6ZQIAK3js.NOOP_SPAN,
|
|
207
|
+
NOOP_SPAN_PERMALINK: () => _chunkB6ZQIAK3js.NOOP_SPAN_PERMALINK,
|
|
208
|
+
NoopSpan: () => _chunkB6ZQIAK3js.NoopSpan,
|
|
209
|
+
OTELIDGenerator: () => _chunkB6ZQIAK3js.OTELIDGenerator,
|
|
210
|
+
ObjectFetcher: () => _chunkB6ZQIAK3js.ObjectFetcher,
|
|
210
211
|
Project: () => Project2,
|
|
211
212
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
212
|
-
Prompt: () =>
|
|
213
|
+
Prompt: () => _chunkB6ZQIAK3js.Prompt,
|
|
213
214
|
PromptBuilder: () => PromptBuilder,
|
|
214
|
-
ReadonlyAttachment: () =>
|
|
215
|
-
ReadonlyExperiment: () =>
|
|
215
|
+
ReadonlyAttachment: () => _chunkB6ZQIAK3js.ReadonlyAttachment,
|
|
216
|
+
ReadonlyExperiment: () => _chunkB6ZQIAK3js.ReadonlyExperiment,
|
|
216
217
|
Reporter: () => Reporter,
|
|
217
218
|
ScorerBuilder: () => ScorerBuilder,
|
|
218
219
|
SpanFetcher: () => SpanFetcher,
|
|
219
|
-
SpanImpl: () =>
|
|
220
|
-
TRACEPARENT_HEADER: () =>
|
|
221
|
-
TRACESTATE_HEADER: () =>
|
|
222
|
-
TestBackgroundLogger: () =>
|
|
220
|
+
SpanImpl: () => _chunkB6ZQIAK3js.SpanImpl,
|
|
221
|
+
TRACEPARENT_HEADER: () => _chunkB6ZQIAK3js.TRACEPARENT_HEADER,
|
|
222
|
+
TRACESTATE_HEADER: () => _chunkB6ZQIAK3js.TRACESTATE_HEADER,
|
|
223
|
+
TestBackgroundLogger: () => _chunkB6ZQIAK3js.TestBackgroundLogger,
|
|
223
224
|
ToolBuilder: () => ToolBuilder,
|
|
224
|
-
UUIDGenerator: () =>
|
|
225
|
-
X_CACHED_HEADER: () =>
|
|
226
|
-
_exportsForTestingOnly: () =>
|
|
227
|
-
_internalGetGlobalState: () =>
|
|
228
|
-
_internalIso: () =>
|
|
229
|
-
_internalSetInitialState: () =>
|
|
230
|
-
addAzureBlobHeaders: () =>
|
|
225
|
+
UUIDGenerator: () => _chunkB6ZQIAK3js.UUIDGenerator,
|
|
226
|
+
X_CACHED_HEADER: () => _chunkB6ZQIAK3js.X_CACHED_HEADER,
|
|
227
|
+
_exportsForTestingOnly: () => _chunkB6ZQIAK3js._exportsForTestingOnly,
|
|
228
|
+
_internalGetGlobalState: () => _chunkB6ZQIAK3js._internalGetGlobalState,
|
|
229
|
+
_internalIso: () => _chunkCDIKAHDZjs.isomorph_default,
|
|
230
|
+
_internalSetInitialState: () => _chunkB6ZQIAK3js._internalSetInitialState,
|
|
231
|
+
addAzureBlobHeaders: () => _chunkB6ZQIAK3js.addAzureBlobHeaders,
|
|
231
232
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
232
|
-
braintrustAISDKTelemetry: () =>
|
|
233
|
+
braintrustAISDKTelemetry: () => _chunkB6ZQIAK3js.braintrustAISDKTelemetry,
|
|
233
234
|
braintrustEveHook: () => braintrustEveHook,
|
|
234
235
|
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
235
|
-
braintrustFlueInstrumentation: () =>
|
|
236
|
-
braintrustFlueObserver: () =>
|
|
237
|
-
braintrustStreamChunkSchema: () =>
|
|
236
|
+
braintrustFlueInstrumentation: () => _chunkB6ZQIAK3js.braintrustFlueInstrumentation,
|
|
237
|
+
braintrustFlueObserver: () => _chunkB6ZQIAK3js.braintrustFlueObserver,
|
|
238
|
+
braintrustStreamChunkSchema: () => _chunkB6ZQIAK3js.braintrustStreamChunkSchema,
|
|
238
239
|
buildLocalSummary: () => buildLocalSummary,
|
|
239
|
-
configureInstrumentation: () =>
|
|
240
|
-
constructLogs3OverflowRequest: () =>
|
|
241
|
-
createFinalValuePassThroughStream: () =>
|
|
242
|
-
currentExperiment: () =>
|
|
243
|
-
currentLogger: () =>
|
|
244
|
-
currentSpan: () =>
|
|
245
|
-
deepCopyEvent: () =>
|
|
240
|
+
configureInstrumentation: () => _chunkB6ZQIAK3js.configureInstrumentation,
|
|
241
|
+
constructLogs3OverflowRequest: () => _chunkB6ZQIAK3js.constructLogs3OverflowRequest,
|
|
242
|
+
createFinalValuePassThroughStream: () => _chunkB6ZQIAK3js.createFinalValuePassThroughStream,
|
|
243
|
+
currentExperiment: () => _chunkB6ZQIAK3js.currentExperiment,
|
|
244
|
+
currentLogger: () => _chunkB6ZQIAK3js.currentLogger,
|
|
245
|
+
currentSpan: () => _chunkB6ZQIAK3js.currentSpan,
|
|
246
|
+
deepCopyEvent: () => _chunkB6ZQIAK3js.deepCopyEvent,
|
|
246
247
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
247
|
-
deserializePlainStringAsJSON: () =>
|
|
248
|
-
devNullWritableStream: () =>
|
|
248
|
+
deserializePlainStringAsJSON: () => _chunkB6ZQIAK3js.deserializePlainStringAsJSON,
|
|
249
|
+
devNullWritableStream: () => _chunkB6ZQIAK3js.devNullWritableStream,
|
|
249
250
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
250
251
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
251
|
-
extractTraceContextFromHeaders: () =>
|
|
252
|
-
flush: () =>
|
|
253
|
-
getContextManager: () =>
|
|
254
|
-
getIdGenerator: () =>
|
|
255
|
-
getPromptVersions: () =>
|
|
256
|
-
getSpanParentObject: () =>
|
|
257
|
-
getTemplateRenderer: () =>
|
|
252
|
+
extractTraceContextFromHeaders: () => _chunkB6ZQIAK3js.extractTraceContextFromHeaders,
|
|
253
|
+
flush: () => _chunkB6ZQIAK3js.flush,
|
|
254
|
+
getContextManager: () => _chunkB6ZQIAK3js.getContextManager,
|
|
255
|
+
getIdGenerator: () => _chunkB6ZQIAK3js.getIdGenerator,
|
|
256
|
+
getPromptVersions: () => _chunkB6ZQIAK3js.getPromptVersions,
|
|
257
|
+
getSpanParentObject: () => _chunkB6ZQIAK3js.getSpanParentObject,
|
|
258
|
+
getTemplateRenderer: () => _chunkB6ZQIAK3js.getTemplateRenderer,
|
|
258
259
|
graph: () => graph_framework_exports,
|
|
259
|
-
init: () =>
|
|
260
|
-
initDataset: () =>
|
|
261
|
-
initExperiment: () =>
|
|
260
|
+
init: () => _chunkB6ZQIAK3js.init,
|
|
261
|
+
initDataset: () => _chunkB6ZQIAK3js.initDataset,
|
|
262
|
+
initExperiment: () => _chunkB6ZQIAK3js.initExperiment,
|
|
262
263
|
initFunction: () => initFunction,
|
|
263
|
-
initLogger: () =>
|
|
264
|
+
initLogger: () => _chunkB6ZQIAK3js.initLogger,
|
|
264
265
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
265
|
-
injectTraceContext: () =>
|
|
266
|
+
injectTraceContext: () => _chunkB6ZQIAK3js.injectTraceContext,
|
|
266
267
|
invoke: () => invoke,
|
|
267
|
-
isTemplateFormat: () =>
|
|
268
|
-
loadParameters: () =>
|
|
269
|
-
loadPrompt: () =>
|
|
270
|
-
log: () =>
|
|
271
|
-
logError: () =>
|
|
272
|
-
login: () =>
|
|
273
|
-
loginToState: () =>
|
|
274
|
-
logs3OverflowUploadSchema: () =>
|
|
275
|
-
newId: () =>
|
|
276
|
-
parseCachedHeader: () =>
|
|
277
|
-
parseTemplateFormat: () =>
|
|
278
|
-
permalink: () =>
|
|
279
|
-
pickLogs3OverflowObjectIds: () =>
|
|
268
|
+
isTemplateFormat: () => _chunkB6ZQIAK3js.isTemplateFormat,
|
|
269
|
+
loadParameters: () => _chunkB6ZQIAK3js.loadParameters,
|
|
270
|
+
loadPrompt: () => _chunkB6ZQIAK3js.loadPrompt,
|
|
271
|
+
log: () => _chunkB6ZQIAK3js.log,
|
|
272
|
+
logError: () => _chunkB6ZQIAK3js.logError,
|
|
273
|
+
login: () => _chunkB6ZQIAK3js.login,
|
|
274
|
+
loginToState: () => _chunkB6ZQIAK3js.loginToState,
|
|
275
|
+
logs3OverflowUploadSchema: () => _chunkB6ZQIAK3js.logs3OverflowUploadSchema,
|
|
276
|
+
newId: () => _chunkB6ZQIAK3js.newId,
|
|
277
|
+
parseCachedHeader: () => _chunkB6ZQIAK3js.parseCachedHeader,
|
|
278
|
+
parseTemplateFormat: () => _chunkB6ZQIAK3js.parseTemplateFormat,
|
|
279
|
+
permalink: () => _chunkB6ZQIAK3js.permalink,
|
|
280
|
+
pickLogs3OverflowObjectIds: () => _chunkB6ZQIAK3js.pickLogs3OverflowObjectIds,
|
|
280
281
|
projects: () => projects,
|
|
281
282
|
promptContentsSchema: () => promptContentsSchema,
|
|
282
283
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
283
284
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
284
285
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
285
|
-
registerOtelFlush: () =>
|
|
286
|
+
registerOtelFlush: () => _chunkB6ZQIAK3js.registerOtelFlush,
|
|
286
287
|
registerSandbox: () => registerSandbox,
|
|
287
|
-
registerTemplatePlugin: () =>
|
|
288
|
-
renderMessage: () =>
|
|
289
|
-
renderPromptParams: () =>
|
|
290
|
-
renderTemplateContent: () =>
|
|
288
|
+
registerTemplatePlugin: () => _chunkB6ZQIAK3js.registerTemplatePlugin,
|
|
289
|
+
renderMessage: () => _chunkB6ZQIAK3js.renderMessage,
|
|
290
|
+
renderPromptParams: () => _chunkB6ZQIAK3js.renderPromptParams,
|
|
291
|
+
renderTemplateContent: () => _chunkB6ZQIAK3js.renderTemplateContent,
|
|
291
292
|
reportFailures: () => reportFailures,
|
|
292
293
|
runEvaluator: () => runEvaluator,
|
|
293
|
-
setFetch: () =>
|
|
294
|
-
setMaskingFunction: () =>
|
|
295
|
-
spanComponentsToObjectId: () =>
|
|
296
|
-
startSpan: () =>
|
|
297
|
-
summarize: () =>
|
|
298
|
-
templateRegistry: () =>
|
|
299
|
-
toolFunctionDefinitionSchema: () =>
|
|
300
|
-
traceable: () =>
|
|
301
|
-
traced: () =>
|
|
302
|
-
updateSpan: () =>
|
|
303
|
-
uploadLogs3OverflowPayload: () =>
|
|
304
|
-
utf8ByteLength: () =>
|
|
305
|
-
withCurrent: () =>
|
|
306
|
-
withDataset: () =>
|
|
307
|
-
withExperiment: () =>
|
|
308
|
-
withLogger: () =>
|
|
309
|
-
withParent: () =>
|
|
294
|
+
setFetch: () => _chunkB6ZQIAK3js.setFetch,
|
|
295
|
+
setMaskingFunction: () => _chunkB6ZQIAK3js.setMaskingFunction,
|
|
296
|
+
spanComponentsToObjectId: () => _chunkB6ZQIAK3js.spanComponentsToObjectId,
|
|
297
|
+
startSpan: () => _chunkB6ZQIAK3js.startSpan,
|
|
298
|
+
summarize: () => _chunkB6ZQIAK3js.summarize,
|
|
299
|
+
templateRegistry: () => _chunkB6ZQIAK3js.templateRegistry,
|
|
300
|
+
toolFunctionDefinitionSchema: () => _chunkB6ZQIAK3js.ToolFunctionDefinition,
|
|
301
|
+
traceable: () => _chunkB6ZQIAK3js.traceable,
|
|
302
|
+
traced: () => _chunkB6ZQIAK3js.traced,
|
|
303
|
+
updateSpan: () => _chunkB6ZQIAK3js.updateSpan,
|
|
304
|
+
uploadLogs3OverflowPayload: () => _chunkB6ZQIAK3js.uploadLogs3OverflowPayload,
|
|
305
|
+
utf8ByteLength: () => _chunkB6ZQIAK3js.utf8ByteLength,
|
|
306
|
+
withCurrent: () => _chunkB6ZQIAK3js.withCurrent,
|
|
307
|
+
withDataset: () => _chunkB6ZQIAK3js.withDataset,
|
|
308
|
+
withExperiment: () => _chunkB6ZQIAK3js.withExperiment,
|
|
309
|
+
withLogger: () => _chunkB6ZQIAK3js.withLogger,
|
|
310
|
+
withParent: () => _chunkB6ZQIAK3js.withParent,
|
|
310
311
|
wrapAISDK: () => wrapAISDK,
|
|
311
312
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
312
313
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -321,7 +322,10 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
321
322
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
322
323
|
wrapGroq: () => wrapGroq,
|
|
323
324
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
324
|
-
|
|
325
|
+
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
326
|
+
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
327
|
+
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
328
|
+
wrapMastraAgent: () => _chunkB6ZQIAK3js.wrapMastraAgent,
|
|
325
329
|
wrapMistral: () => wrapMistral,
|
|
326
330
|
wrapOpenAI: () => wrapOpenAI,
|
|
327
331
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
@@ -330,7 +334,7 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
330
334
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
331
335
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
332
336
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
333
|
-
wrapTraced: () =>
|
|
337
|
+
wrapTraced: () => _chunkB6ZQIAK3js.wrapTraced,
|
|
334
338
|
wrapVitest: () => wrapVitest
|
|
335
339
|
});
|
|
336
340
|
|
|
@@ -338,7 +342,7 @@ _chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
|
338
342
|
var _v3 = require('zod/v3');
|
|
339
343
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
340
344
|
async function registerSandbox(options) {
|
|
341
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
345
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkB6ZQIAK3js._internalGetGlobalState.call(void 0, )));
|
|
342
346
|
await state.login({
|
|
343
347
|
apiKey: options.apiKey,
|
|
344
348
|
appUrl: options.appUrl,
|
|
@@ -379,7 +383,7 @@ async function registerSandbox(options) {
|
|
|
379
383
|
evaluatorDefinitions
|
|
380
384
|
)) {
|
|
381
385
|
const functionName = evalName;
|
|
382
|
-
const functionSlug =
|
|
386
|
+
const functionSlug = _chunkB6ZQIAK3js.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
383
387
|
const functionDef = {
|
|
384
388
|
project_id: projectId,
|
|
385
389
|
org_name: state.orgName,
|
|
@@ -450,7 +454,7 @@ async function invoke(args) {
|
|
|
450
454
|
projectId,
|
|
451
455
|
...functionIdArgs
|
|
452
456
|
} = args;
|
|
453
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
457
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkB6ZQIAK3js._internalGetGlobalState.call(void 0, )));
|
|
454
458
|
await state.login({
|
|
455
459
|
orgName,
|
|
456
460
|
apiKey,
|
|
@@ -458,8 +462,8 @@ async function invoke(args) {
|
|
|
458
462
|
forceLogin,
|
|
459
463
|
fetch
|
|
460
464
|
});
|
|
461
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
462
|
-
const functionId =
|
|
465
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkB6ZQIAK3js.getSpanParentObject.call(void 0, ).export();
|
|
466
|
+
const functionId = _chunkB6ZQIAK3js.FunctionId.safeParse({
|
|
463
467
|
function_id: functionIdArgs.function_id,
|
|
464
468
|
project_name: functionIdArgs.projectName,
|
|
465
469
|
slug: functionIdArgs.slug,
|
|
@@ -502,7 +506,7 @@ async function invoke(args) {
|
|
|
502
506
|
if (!resp.body) {
|
|
503
507
|
throw new Error("Received empty stream body");
|
|
504
508
|
}
|
|
505
|
-
return new (0,
|
|
509
|
+
return new (0, _chunkB6ZQIAK3js.BraintrustStream)(resp.body);
|
|
506
510
|
} else {
|
|
507
511
|
const data = await resp.json();
|
|
508
512
|
return schema ? schema.parse(data) : data;
|
|
@@ -514,7 +518,7 @@ function initFunction({
|
|
|
514
518
|
version,
|
|
515
519
|
state
|
|
516
520
|
}) {
|
|
517
|
-
const s = _nullishCoalesce(state, () => (
|
|
521
|
+
const s = _nullishCoalesce(state, () => ( _chunkB6ZQIAK3js._internalGetGlobalState.call(void 0, )));
|
|
518
522
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
519
523
|
const f = async (input) => {
|
|
520
524
|
return await invoke({
|
|
@@ -592,22 +596,22 @@ function responsesProxy(openai) {
|
|
|
592
596
|
if (name === "create" && typeof target.create === "function") {
|
|
593
597
|
return wrapResponsesAsync(
|
|
594
598
|
target.create.bind(target),
|
|
595
|
-
|
|
599
|
+
_chunkCDIKAHDZjs.openAIChannels.responsesCreate
|
|
596
600
|
);
|
|
597
601
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
598
602
|
return wrapResponsesSyncStream(
|
|
599
603
|
target.stream.bind(target),
|
|
600
|
-
|
|
604
|
+
_chunkCDIKAHDZjs.openAIChannels.responsesStream
|
|
601
605
|
);
|
|
602
606
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
603
607
|
return wrapResponsesAsync(
|
|
604
608
|
target.parse.bind(target),
|
|
605
|
-
|
|
609
|
+
_chunkCDIKAHDZjs.openAIChannels.responsesParse
|
|
606
610
|
);
|
|
607
611
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
608
612
|
return wrapResponsesAsync(
|
|
609
613
|
target.compact.bind(target),
|
|
610
|
-
|
|
614
|
+
_chunkCDIKAHDZjs.openAIChannels.responsesCompact
|
|
611
615
|
);
|
|
612
616
|
}
|
|
613
617
|
return Reflect.get(target, name, receiver);
|
|
@@ -751,7 +755,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
751
755
|
const { span_info, params } = splitSpanInfo(
|
|
752
756
|
allParams
|
|
753
757
|
);
|
|
754
|
-
return
|
|
758
|
+
return _chunkCDIKAHDZjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
755
759
|
async () => await completion(params),
|
|
756
760
|
{ arguments: [params], span_info }
|
|
757
761
|
);
|
|
@@ -762,7 +766,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
762
766
|
const { span_info, params } = splitSpanInfo(
|
|
763
767
|
allParams
|
|
764
768
|
);
|
|
765
|
-
return
|
|
769
|
+
return _chunkCDIKAHDZjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
766
770
|
() => completion(params),
|
|
767
771
|
{ arguments: [params], span_info }
|
|
768
772
|
);
|
|
@@ -778,7 +782,7 @@ function wrapChatCompletion(completion) {
|
|
|
778
782
|
if (!executionPromise) {
|
|
779
783
|
executionPromise = (async () => {
|
|
780
784
|
const traceContext = createChannelContext(
|
|
781
|
-
|
|
785
|
+
_chunkCDIKAHDZjs.openAIChannels.chatCompletionsCreate,
|
|
782
786
|
params,
|
|
783
787
|
span_info
|
|
784
788
|
);
|
|
@@ -788,7 +792,7 @@ function wrapChatCompletion(completion) {
|
|
|
788
792
|
options
|
|
789
793
|
);
|
|
790
794
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
791
|
-
|
|
795
|
+
_chunkCDIKAHDZjs.openAIChannels.chatCompletionsCreate,
|
|
792
796
|
traceContext,
|
|
793
797
|
completionPromise
|
|
794
798
|
);
|
|
@@ -799,7 +803,7 @@ function wrapChatCompletion(completion) {
|
|
|
799
803
|
options
|
|
800
804
|
);
|
|
801
805
|
const { data, response } = await tracePromiseWithResponse(
|
|
802
|
-
|
|
806
|
+
_chunkCDIKAHDZjs.openAIChannels.chatCompletionsCreate,
|
|
803
807
|
traceContext,
|
|
804
808
|
completionResponse
|
|
805
809
|
);
|
|
@@ -842,8 +846,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
842
846
|
return createLazyAPIPromise(ensureExecuted);
|
|
843
847
|
};
|
|
844
848
|
}
|
|
845
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
846
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
849
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkCDIKAHDZjs.openAIChannels.embeddingsCreate);
|
|
850
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkCDIKAHDZjs.openAIChannels.moderationsCreate);
|
|
847
851
|
|
|
848
852
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
849
853
|
function isModuleNamespace(obj) {
|
|
@@ -943,15 +947,15 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
943
947
|
};
|
|
944
948
|
function generateChannelForAgent(agentName) {
|
|
945
949
|
if (agentName === "ToolLoopAgent") {
|
|
946
|
-
return
|
|
950
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
947
951
|
}
|
|
948
|
-
return
|
|
952
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.agentGenerate;
|
|
949
953
|
}
|
|
950
954
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
951
955
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
952
956
|
return (params) => {
|
|
953
957
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
954
|
-
if (workflowAgent &&
|
|
958
|
+
if (workflowAgent && _chunkB6ZQIAK3js.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
955
959
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
956
960
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
957
961
|
}
|
|
@@ -970,12 +974,12 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
970
974
|
};
|
|
971
975
|
function streamChannelForAgent(agentName) {
|
|
972
976
|
if (agentName === "ToolLoopAgent") {
|
|
973
|
-
return
|
|
977
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.toolLoopAgentStream;
|
|
974
978
|
}
|
|
975
979
|
if (agentName === "WorkflowAgent") {
|
|
976
|
-
return
|
|
980
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.workflowAgentStream;
|
|
977
981
|
}
|
|
978
|
-
return
|
|
982
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.agentStream;
|
|
979
983
|
}
|
|
980
984
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
981
985
|
const wrapper = async function(allParams) {
|
|
@@ -999,7 +1003,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
999
1003
|
};
|
|
1000
1004
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
1001
1005
|
return makeGenerateTextWrapper(
|
|
1002
|
-
|
|
1006
|
+
_chunkCDIKAHDZjs.aiSDKChannels.generateText,
|
|
1003
1007
|
"generateText",
|
|
1004
1008
|
generateText,
|
|
1005
1009
|
{ aiSDK },
|
|
@@ -1008,7 +1012,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
1008
1012
|
};
|
|
1009
1013
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
1010
1014
|
return makeGenerateTextWrapper(
|
|
1011
|
-
|
|
1015
|
+
_chunkCDIKAHDZjs.aiSDKChannels.generateObject,
|
|
1012
1016
|
"generateObject",
|
|
1013
1017
|
generateObject,
|
|
1014
1018
|
{ aiSDK },
|
|
@@ -1037,7 +1041,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
1037
1041
|
};
|
|
1038
1042
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
1039
1043
|
return makeEmbedWrapper(
|
|
1040
|
-
|
|
1044
|
+
_chunkCDIKAHDZjs.aiSDKChannels.embed,
|
|
1041
1045
|
"embed",
|
|
1042
1046
|
embed,
|
|
1043
1047
|
{ aiSDK },
|
|
@@ -1046,7 +1050,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1046
1050
|
};
|
|
1047
1051
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1048
1052
|
return makeEmbedWrapper(
|
|
1049
|
-
|
|
1053
|
+
_chunkCDIKAHDZjs.aiSDKChannels.embedMany,
|
|
1050
1054
|
"embedMany",
|
|
1051
1055
|
embedMany,
|
|
1052
1056
|
{ aiSDK },
|
|
@@ -1057,7 +1061,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1057
1061
|
const wrapper = async function(allParams) {
|
|
1058
1062
|
const { span_info, ...params } = allParams;
|
|
1059
1063
|
const tracedParams = { ...params };
|
|
1060
|
-
return
|
|
1064
|
+
return _chunkCDIKAHDZjs.aiSDKChannels.rerank.tracePromise(
|
|
1061
1065
|
() => rerank(tracedParams),
|
|
1062
1066
|
createAISDKChannelContext(tracedParams, {
|
|
1063
1067
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1096,7 +1100,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1096
1100
|
};
|
|
1097
1101
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1098
1102
|
return makeStreamWrapper(
|
|
1099
|
-
|
|
1103
|
+
_chunkCDIKAHDZjs.aiSDKChannels.streamText,
|
|
1100
1104
|
"streamText",
|
|
1101
1105
|
streamText,
|
|
1102
1106
|
{ aiSDK },
|
|
@@ -1105,7 +1109,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1105
1109
|
};
|
|
1106
1110
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1107
1111
|
return makeStreamWrapper(
|
|
1108
|
-
|
|
1112
|
+
_chunkCDIKAHDZjs.aiSDKChannels.streamObject,
|
|
1109
1113
|
"streamObject",
|
|
1110
1114
|
streamObject,
|
|
1111
1115
|
{ aiSDK },
|
|
@@ -1176,14 +1180,14 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1176
1180
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1177
1181
|
// propagate those via async local storage
|
|
1178
1182
|
async doGenerate(options) {
|
|
1179
|
-
const span =
|
|
1183
|
+
const span = _chunkB6ZQIAK3js.startSpan.call(void 0, {
|
|
1180
1184
|
name: "Chat Completion",
|
|
1181
1185
|
spanAttributes: {
|
|
1182
1186
|
type: "llm"
|
|
1183
1187
|
}
|
|
1184
1188
|
});
|
|
1185
1189
|
const { prompt, mode, ...rest } = options;
|
|
1186
|
-
const startTime =
|
|
1190
|
+
const startTime = _chunkB6ZQIAK3js.getCurrentUnixTimestamp.call(void 0, );
|
|
1187
1191
|
try {
|
|
1188
1192
|
const ret = await this.model.doGenerate(options);
|
|
1189
1193
|
span.log({
|
|
@@ -1195,12 +1199,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1195
1199
|
},
|
|
1196
1200
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1197
1201
|
metrics: {
|
|
1198
|
-
time_to_first_token:
|
|
1199
|
-
tokens: !
|
|
1202
|
+
time_to_first_token: _chunkB6ZQIAK3js.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1203
|
+
tokens: !_chunkB6ZQIAK3js.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1200
1204
|
prompt_tokens: _optionalChain([ret, 'access', _20 => _20.usage, 'optionalAccess', _21 => _21.promptTokens]),
|
|
1201
1205
|
completion_tokens: _optionalChain([ret, 'access', _22 => _22.usage, 'optionalAccess', _23 => _23.completionTokens]),
|
|
1202
|
-
cached:
|
|
1203
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[
|
|
1206
|
+
cached: _chunkB6ZQIAK3js.parseCachedHeader.call(void 0,
|
|
1207
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[_chunkB6ZQIAK3js.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _27 => _27.rawResponse, 'optionalAccess', _28 => _28.headers, 'optionalAccess', _29 => _29[_chunkB6ZQIAK3js.LEGACY_CACHED_HEADER]])))
|
|
1204
1208
|
)
|
|
1205
1209
|
}
|
|
1206
1210
|
});
|
|
@@ -1211,8 +1215,8 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1211
1215
|
}
|
|
1212
1216
|
async doStream(options) {
|
|
1213
1217
|
const { prompt, mode, ...rest } = options;
|
|
1214
|
-
const startTime =
|
|
1215
|
-
const span =
|
|
1218
|
+
const startTime = _chunkB6ZQIAK3js.getCurrentUnixTimestamp.call(void 0, );
|
|
1219
|
+
const span = _chunkB6ZQIAK3js.startSpan.call(void 0, {
|
|
1216
1220
|
name: "Chat Completion",
|
|
1217
1221
|
spanAttributes: {
|
|
1218
1222
|
type: "llm"
|
|
@@ -1246,7 +1250,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1246
1250
|
new TransformStream({
|
|
1247
1251
|
transform(chunk, controller) {
|
|
1248
1252
|
if (time_to_first_token === void 0) {
|
|
1249
|
-
time_to_first_token =
|
|
1253
|
+
time_to_first_token = _chunkB6ZQIAK3js.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1250
1254
|
span.log({ metrics: { time_to_first_token } });
|
|
1251
1255
|
}
|
|
1252
1256
|
switch (chunk.type) {
|
|
@@ -1291,11 +1295,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1291
1295
|
),
|
|
1292
1296
|
metrics: {
|
|
1293
1297
|
time_to_first_token,
|
|
1294
|
-
tokens: !
|
|
1298
|
+
tokens: !_chunkB6ZQIAK3js.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1295
1299
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _30 => _30.promptTokens]),
|
|
1296
1300
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _31 => _31.completionTokens]),
|
|
1297
|
-
cached:
|
|
1298
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[
|
|
1301
|
+
cached: _chunkB6ZQIAK3js.parseCachedHeader.call(void 0,
|
|
1302
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[_chunkB6ZQIAK3js.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _35 => _35.rawResponse, 'optionalAccess', _36 => _36.headers, 'optionalAccess', _37 => _37[_chunkB6ZQIAK3js.LEGACY_CACHED_HEADER]])))
|
|
1299
1303
|
)
|
|
1300
1304
|
}
|
|
1301
1305
|
});
|
|
@@ -1480,12 +1484,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1480
1484
|
anthropicMetadata.usage,
|
|
1481
1485
|
"cache_creation_input_tokens"
|
|
1482
1486
|
) || 0;
|
|
1483
|
-
const cacheTokens =
|
|
1487
|
+
const cacheTokens = _chunkB6ZQIAK3js.extractAnthropicCacheTokens.call(void 0,
|
|
1484
1488
|
cacheReadTokens,
|
|
1485
1489
|
cacheCreationTokens
|
|
1486
1490
|
);
|
|
1487
1491
|
Object.assign(metrics, cacheTokens);
|
|
1488
|
-
Object.assign(metrics,
|
|
1492
|
+
Object.assign(metrics, _chunkB6ZQIAK3js.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1489
1493
|
}
|
|
1490
1494
|
}
|
|
1491
1495
|
return metrics;
|
|
@@ -1557,7 +1561,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1557
1561
|
model: modelFromWrapGenerate
|
|
1558
1562
|
}) => {
|
|
1559
1563
|
const rawInput = extractInput(params);
|
|
1560
|
-
const processedInput =
|
|
1564
|
+
const processedInput = _chunkB6ZQIAK3js.processInputAttachments.call(void 0, rawInput);
|
|
1561
1565
|
const spanArgs = {
|
|
1562
1566
|
name: _optionalChain([config, 'access', _54 => _54.spanInfo, 'optionalAccess', _55 => _55.name]) || "ai-sdk.doGenerate",
|
|
1563
1567
|
spanAttributes: {
|
|
@@ -1572,7 +1576,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1572
1576
|
}
|
|
1573
1577
|
}
|
|
1574
1578
|
};
|
|
1575
|
-
const span =
|
|
1579
|
+
const span = _chunkB6ZQIAK3js.startSpan.call(void 0, spanArgs);
|
|
1576
1580
|
try {
|
|
1577
1581
|
const result = await doGenerate();
|
|
1578
1582
|
const metadata = {};
|
|
@@ -1619,7 +1623,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1619
1623
|
},
|
|
1620
1624
|
wrapStream: async ({ doStream, params }) => {
|
|
1621
1625
|
const rawInput = extractInput(params);
|
|
1622
|
-
const processedInput =
|
|
1626
|
+
const processedInput = _chunkB6ZQIAK3js.processInputAttachments.call(void 0, rawInput);
|
|
1623
1627
|
const spanArgs = {
|
|
1624
1628
|
name: _optionalChain([config, 'access', _63 => _63.spanInfo, 'optionalAccess', _64 => _64.name]) || "ai-sdk.doStream",
|
|
1625
1629
|
spanAttributes: {
|
|
@@ -1634,7 +1638,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1634
1638
|
}
|
|
1635
1639
|
}
|
|
1636
1640
|
};
|
|
1637
|
-
const span =
|
|
1641
|
+
const span = _chunkB6ZQIAK3js.startSpan.call(void 0, spanArgs);
|
|
1638
1642
|
try {
|
|
1639
1643
|
const { stream, ...rest } = await doStream();
|
|
1640
1644
|
const textChunks = [];
|
|
@@ -1757,7 +1761,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1757
1761
|
try {
|
|
1758
1762
|
captureEveModelInput(state, input);
|
|
1759
1763
|
} catch (error) {
|
|
1760
|
-
|
|
1764
|
+
_chunkB6ZQIAK3js.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1761
1765
|
}
|
|
1762
1766
|
}
|
|
1763
1767
|
},
|
|
@@ -1767,7 +1771,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1767
1771
|
};
|
|
1768
1772
|
}
|
|
1769
1773
|
function isEveHandleMessageStreamEvent(event) {
|
|
1770
|
-
return
|
|
1774
|
+
return _chunkB6ZQIAK3js.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1771
1775
|
}
|
|
1772
1776
|
var ResumedEveSpan = class {
|
|
1773
1777
|
constructor(reference) {
|
|
@@ -1787,7 +1791,7 @@ var ResumedEveSpan = class {
|
|
|
1787
1791
|
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1788
1792
|
...event.metrics
|
|
1789
1793
|
};
|
|
1790
|
-
|
|
1794
|
+
_chunkB6ZQIAK3js.updateSpan.call(void 0, {
|
|
1791
1795
|
exported: this.reference.exported,
|
|
1792
1796
|
...this.reference.startEvent,
|
|
1793
1797
|
...event,
|
|
@@ -1796,27 +1800,24 @@ var ResumedEveSpan = class {
|
|
|
1796
1800
|
}
|
|
1797
1801
|
end(args) {
|
|
1798
1802
|
if (this.endTime === void 0) {
|
|
1799
|
-
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.endTime]), () => (
|
|
1803
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.endTime]), () => ( _chunkB6ZQIAK3js.getCurrentUnixTimestamp.call(void 0, )));
|
|
1800
1804
|
this.log({ metrics: { end: this.endTime } });
|
|
1801
1805
|
}
|
|
1802
1806
|
return this.endTime;
|
|
1803
1807
|
}
|
|
1804
1808
|
};
|
|
1805
1809
|
var EveBridge = (_class = class {
|
|
1806
|
-
constructor(state) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
1810
|
+
constructor(state) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
1807
1811
|
this.state = state;
|
|
1808
1812
|
}
|
|
1809
1813
|
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1810
|
-
__init2() {this.
|
|
1811
|
-
max: MAX_EVE_CACHE_ENTRIES
|
|
1812
|
-
})}
|
|
1813
|
-
__init3() {this.completedToolKeys = new (0, _chunkMWVVR5LRjs.LRUCache)({
|
|
1814
|
+
__init2() {this.completedToolKeys = new (0, _chunkB6ZQIAK3js.LRUCache)({
|
|
1814
1815
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1815
1816
|
})}
|
|
1816
|
-
|
|
1817
|
+
__init3() {this.toolsByCallKey = new (0, _chunkB6ZQIAK3js.LRUCache)({
|
|
1817
1818
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1818
1819
|
})}
|
|
1819
|
-
|
|
1820
|
+
__init4() {this.turnsByKey = new (0, _chunkB6ZQIAK3js.LRUCache)({
|
|
1820
1821
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1821
1822
|
})}
|
|
1822
1823
|
async startEveSpan(args) {
|
|
@@ -1827,7 +1828,7 @@ var EveBridge = (_class = class {
|
|
|
1827
1828
|
if (reference) {
|
|
1828
1829
|
return new ResumedEveSpan(reference);
|
|
1829
1830
|
}
|
|
1830
|
-
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.startTime]), () => (
|
|
1831
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.startTime]), () => ( _chunkB6ZQIAK3js.getCurrentUnixTimestamp.call(void 0, )));
|
|
1831
1832
|
const parentSpanIds = _optionalChain([args, 'optionalAccess', _76 => _76.parentSpanIds]);
|
|
1832
1833
|
const startEvent = {
|
|
1833
1834
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1839,9 +1840,9 @@ var EveBridge = (_class = class {
|
|
|
1839
1840
|
},
|
|
1840
1841
|
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
1841
1842
|
};
|
|
1842
|
-
const span =
|
|
1843
|
-
|
|
1844
|
-
() =>
|
|
1843
|
+
const span = _chunkB6ZQIAK3js.withCurrent.call(void 0,
|
|
1844
|
+
_chunkB6ZQIAK3js.NOOP_SPAN,
|
|
1845
|
+
() => _chunkB6ZQIAK3js._internalStartSpanWithInitialMerge.call(void 0, { ...args, startTime })
|
|
1845
1846
|
);
|
|
1846
1847
|
if (typeof rowId !== "string") {
|
|
1847
1848
|
return span;
|
|
@@ -1867,7 +1868,7 @@ var EveBridge = (_class = class {
|
|
|
1867
1868
|
};
|
|
1868
1869
|
});
|
|
1869
1870
|
} catch (error) {
|
|
1870
|
-
|
|
1871
|
+
_chunkB6ZQIAK3js.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
1871
1872
|
}
|
|
1872
1873
|
return span;
|
|
1873
1874
|
}
|
|
@@ -1954,7 +1955,7 @@ var EveBridge = (_class = class {
|
|
|
1954
1955
|
}
|
|
1955
1956
|
}
|
|
1956
1957
|
} catch (error) {
|
|
1957
|
-
|
|
1958
|
+
_chunkB6ZQIAK3js.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
1958
1959
|
}
|
|
1959
1960
|
};
|
|
1960
1961
|
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
@@ -1976,7 +1977,7 @@ var EveBridge = (_class = class {
|
|
|
1976
1977
|
async handleEvent(event, ctx, hookMetadata) {
|
|
1977
1978
|
switch (event.type) {
|
|
1978
1979
|
case "session.started":
|
|
1979
|
-
|
|
1980
|
+
this.handleSessionStarted(event, ctx, hookMetadata);
|
|
1980
1981
|
return true;
|
|
1981
1982
|
case "turn.started":
|
|
1982
1983
|
await this.handleTurnStarted(event, ctx, hookMetadata);
|
|
@@ -2012,22 +2013,22 @@ var EveBridge = (_class = class {
|
|
|
2012
2013
|
this.handleStepFailed(event, ctx);
|
|
2013
2014
|
return true;
|
|
2014
2015
|
case "turn.completed":
|
|
2015
|
-
|
|
2016
|
+
this.handleTurnCompleted(event, ctx);
|
|
2016
2017
|
return true;
|
|
2017
2018
|
case "turn.failed":
|
|
2018
|
-
|
|
2019
|
+
this.handleTurnFailed(event, ctx);
|
|
2019
2020
|
return true;
|
|
2020
2021
|
case "session.failed":
|
|
2021
|
-
|
|
2022
|
+
this.handleSessionFailed(event, ctx);
|
|
2022
2023
|
return true;
|
|
2023
2024
|
case "session.completed":
|
|
2024
|
-
|
|
2025
|
+
this.handleSessionCompleted(event, ctx);
|
|
2025
2026
|
return true;
|
|
2026
2027
|
default:
|
|
2027
2028
|
return false;
|
|
2028
2029
|
}
|
|
2029
2030
|
}
|
|
2030
|
-
|
|
2031
|
+
handleSessionStarted(event, ctx, hookMetadata) {
|
|
2031
2032
|
const sessionId = sessionIdFromContext(ctx);
|
|
2032
2033
|
if (!sessionId) {
|
|
2033
2034
|
return;
|
|
@@ -2043,7 +2044,6 @@ var EveBridge = (_class = class {
|
|
|
2043
2044
|
metadata: { ...normalized.metadata, ...metadata }
|
|
2044
2045
|
};
|
|
2045
2046
|
});
|
|
2046
|
-
await this.ensureSession(sessionId, ctx, metadata, eventTime(event));
|
|
2047
2047
|
for (const [key, turn] of this.turnsByKey) {
|
|
2048
2048
|
if (!key.startsWith(`${sessionId}:`)) {
|
|
2049
2049
|
continue;
|
|
@@ -2061,21 +2061,19 @@ var EveBridge = (_class = class {
|
|
|
2061
2061
|
if (!sessionId) {
|
|
2062
2062
|
return;
|
|
2063
2063
|
}
|
|
2064
|
-
const session = await this.ensureSession(
|
|
2065
|
-
sessionId,
|
|
2066
|
-
ctx,
|
|
2067
|
-
_nullishCoalesce(hookMetadata, () => ( {})),
|
|
2068
|
-
eventTime(event)
|
|
2069
|
-
);
|
|
2070
2064
|
const key = turnKey(sessionId, event.data.turnId);
|
|
2071
|
-
const metadata = {
|
|
2065
|
+
const metadata = {
|
|
2066
|
+
...readEveTraceState(this.state).metadata,
|
|
2067
|
+
..._nullishCoalesce(hookMetadata, () => ( {})),
|
|
2068
|
+
"eve.session_id": sessionId
|
|
2069
|
+
};
|
|
2072
2070
|
const existing = this.turnsByKey.get(key);
|
|
2073
2071
|
if (existing) {
|
|
2074
2072
|
existing.metadata = { ...existing.metadata, ...metadata };
|
|
2075
2073
|
existing.span.log({ metadata: existing.metadata });
|
|
2076
2074
|
return;
|
|
2077
2075
|
}
|
|
2078
|
-
const span = await this.startTurnSpan(
|
|
2076
|
+
const span = await this.startTurnSpan(sessionId, event, ctx, metadata);
|
|
2079
2077
|
span.log({ metadata });
|
|
2080
2078
|
this.turnsByKey.set(key, {
|
|
2081
2079
|
key,
|
|
@@ -2113,10 +2111,7 @@ var EveBridge = (_class = class {
|
|
|
2113
2111
|
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2114
2112
|
}
|
|
2115
2113
|
const stepOrdinal = this.stepOrdinal(event);
|
|
2116
|
-
const metadata = {
|
|
2117
|
-
...turn.metadata,
|
|
2118
|
-
..._nullishCoalesce(_optionalChain([this, 'access', _85 => _85.sessionsById, 'access', _86 => _86.get, 'call', _87 => _87(sessionId), 'optionalAccess', _88 => _88.metadata]), () => ( {}))
|
|
2119
|
-
};
|
|
2114
|
+
const metadata = { ...turn.metadata };
|
|
2120
2115
|
const input = consumeCapturedEveModelInput(
|
|
2121
2116
|
this.state,
|
|
2122
2117
|
sessionId,
|
|
@@ -2153,8 +2148,8 @@ var EveBridge = (_class = class {
|
|
|
2153
2148
|
if (!step) {
|
|
2154
2149
|
return;
|
|
2155
2150
|
}
|
|
2156
|
-
const existingMessage = Array.isArray(step.output) &&
|
|
2157
|
-
const existingToolCalls =
|
|
2151
|
+
const existingMessage = Array.isArray(step.output) && _chunkB6ZQIAK3js.isObject.call(void 0, step.output[0]) ? step.output[0].message : void 0;
|
|
2152
|
+
const existingToolCalls = _chunkB6ZQIAK3js.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2158
2153
|
step.output = [
|
|
2159
2154
|
{
|
|
2160
2155
|
finish_reason: normalizedFinishReason(event.data.finishReason),
|
|
@@ -2211,6 +2206,28 @@ var EveBridge = (_class = class {
|
|
|
2211
2206
|
if (!step) {
|
|
2212
2207
|
return;
|
|
2213
2208
|
}
|
|
2209
|
+
const toolCallsById = /* @__PURE__ */ new Map();
|
|
2210
|
+
if (Array.isArray(step.output) && _chunkB6ZQIAK3js.isObject.call(void 0, step.output[0])) {
|
|
2211
|
+
const message = step.output[0]["message"];
|
|
2212
|
+
if (_chunkB6ZQIAK3js.isObject.call(void 0, message) && Array.isArray(message["tool_calls"])) {
|
|
2213
|
+
for (const toolCall of message["tool_calls"]) {
|
|
2214
|
+
if (_chunkB6ZQIAK3js.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
|
+
}
|
|
2214
2231
|
step.output = [
|
|
2215
2232
|
{
|
|
2216
2233
|
finish_reason: "tool_calls",
|
|
@@ -2218,17 +2235,7 @@ var EveBridge = (_class = class {
|
|
|
2218
2235
|
message: {
|
|
2219
2236
|
content: null,
|
|
2220
2237
|
role: "assistant",
|
|
2221
|
-
tool_calls:
|
|
2222
|
-
const name = action.kind === "tool-call" ? action.toolName : _nullishCoalesce(_nullishCoalesce(action.subagentName, () => ( action.name)), () => ( "agent"));
|
|
2223
|
-
return {
|
|
2224
|
-
function: {
|
|
2225
|
-
arguments: JSON.stringify(action.input),
|
|
2226
|
-
name
|
|
2227
|
-
},
|
|
2228
|
-
id: action.callId,
|
|
2229
|
-
type: "function"
|
|
2230
|
-
};
|
|
2231
|
-
})
|
|
2238
|
+
tool_calls: [...toolCallsById.values()]
|
|
2232
2239
|
}
|
|
2233
2240
|
}
|
|
2234
2241
|
];
|
|
@@ -2275,7 +2282,7 @@ var EveBridge = (_class = class {
|
|
|
2275
2282
|
this.completedToolKeys.set(key, true);
|
|
2276
2283
|
}
|
|
2277
2284
|
async handleSubagentCalled(event, ctx, hookMetadata) {
|
|
2278
|
-
if (_optionalChain([event, 'access',
|
|
2285
|
+
if (_optionalChain([event, 'access', _85 => _85.data, 'access', _86 => _86.remote, 'optionalAccess', _87 => _87.url])) {
|
|
2279
2286
|
return;
|
|
2280
2287
|
}
|
|
2281
2288
|
const turn = await this.ensureTurn(event, ctx, hookMetadata);
|
|
@@ -2395,11 +2402,11 @@ var EveBridge = (_class = class {
|
|
|
2395
2402
|
return;
|
|
2396
2403
|
}
|
|
2397
2404
|
const usage = event.data.usage;
|
|
2398
|
-
const inputTokens = typeof _optionalChain([usage, 'optionalAccess',
|
|
2399
|
-
const outputTokens = typeof _optionalChain([usage, 'optionalAccess',
|
|
2400
|
-
const cacheReadTokens = typeof _optionalChain([usage, 'optionalAccess',
|
|
2401
|
-
const cacheWriteTokens = typeof _optionalChain([usage, 'optionalAccess',
|
|
2402
|
-
const costUsd = typeof _optionalChain([usage, 'optionalAccess',
|
|
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;
|
|
2403
2410
|
const total = inputTokens !== void 0 && outputTokens !== void 0 ? inputTokens + outputTokens : void 0;
|
|
2404
2411
|
const metrics = {
|
|
2405
2412
|
...inputTokens !== void 0 ? { prompt_tokens: inputTokens } : {},
|
|
@@ -2410,7 +2417,7 @@ var EveBridge = (_class = class {
|
|
|
2410
2417
|
...costUsd !== void 0 ? { estimated_cost: costUsd } : {}
|
|
2411
2418
|
};
|
|
2412
2419
|
step.metrics = { ...step.metrics, ...metrics };
|
|
2413
|
-
if (Array.isArray(step.output) &&
|
|
2420
|
+
if (Array.isArray(step.output) && _chunkB6ZQIAK3js.isObject.call(void 0, step.output[0])) {
|
|
2414
2421
|
const finishReason = step.output[0].finish_reason;
|
|
2415
2422
|
if (typeof finishReason !== "string") {
|
|
2416
2423
|
step.output[0].finish_reason = normalizedFinishReason(
|
|
@@ -2449,7 +2456,7 @@ var EveBridge = (_class = class {
|
|
|
2449
2456
|
step.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2450
2457
|
}
|
|
2451
2458
|
const turn = this.turnForEvent(event, ctx);
|
|
2452
|
-
_optionalChain([turn, 'optionalAccess',
|
|
2459
|
+
_optionalChain([turn, 'optionalAccess', _93 => _93.stepsByIndex, 'access', _94 => _94.delete, 'call', _95 => _95(event.data.stepIndex)]);
|
|
2453
2460
|
this.markStepEnded(event.data.turnId, event.data.stepIndex);
|
|
2454
2461
|
}
|
|
2455
2462
|
handleTurnCompleted(event, ctx) {
|
|
@@ -2475,17 +2482,11 @@ var EveBridge = (_class = class {
|
|
|
2475
2482
|
)
|
|
2476
2483
|
});
|
|
2477
2484
|
}
|
|
2478
|
-
|
|
2485
|
+
handleSessionFailed(event, ctx) {
|
|
2479
2486
|
const sessionId = event.data.sessionId || sessionIdFromContext(ctx);
|
|
2480
2487
|
if (!sessionId) {
|
|
2481
2488
|
return;
|
|
2482
2489
|
}
|
|
2483
|
-
const session = await this.ensureSession(
|
|
2484
|
-
sessionId,
|
|
2485
|
-
ctx,
|
|
2486
|
-
{},
|
|
2487
|
-
eventTime(event)
|
|
2488
|
-
);
|
|
2489
2490
|
const error = errorFromMessage(
|
|
2490
2491
|
event.data.message,
|
|
2491
2492
|
event.data.code,
|
|
@@ -2502,29 +2503,20 @@ var EveBridge = (_class = class {
|
|
|
2502
2503
|
}
|
|
2503
2504
|
for (const [key, tool] of this.toolsByCallKey) {
|
|
2504
2505
|
if (key.startsWith(`${sessionId}:`)) {
|
|
2505
|
-
const
|
|
2506
|
+
const endTime = eventTime(event);
|
|
2506
2507
|
if (!tool.endedByTurn) {
|
|
2507
2508
|
tool.span.log({ metadata: tool.metadata });
|
|
2508
|
-
tool.span.end(
|
|
2509
|
+
tool.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2509
2510
|
tool.endedByTurn = true;
|
|
2510
2511
|
}
|
|
2511
2512
|
}
|
|
2512
2513
|
}
|
|
2513
|
-
session.span.log({ error });
|
|
2514
|
-
const endTime = eventTime(event);
|
|
2515
|
-
session.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2516
2514
|
}
|
|
2517
|
-
|
|
2515
|
+
handleSessionCompleted(event, ctx) {
|
|
2518
2516
|
const sessionId = sessionIdFromContext(ctx);
|
|
2519
2517
|
if (!sessionId) {
|
|
2520
2518
|
return;
|
|
2521
2519
|
}
|
|
2522
|
-
const session = await this.ensureSession(
|
|
2523
|
-
sessionId,
|
|
2524
|
-
ctx,
|
|
2525
|
-
{},
|
|
2526
|
-
eventTime(event)
|
|
2527
|
-
);
|
|
2528
2520
|
for (const [key, turn] of this.turnsByKey) {
|
|
2529
2521
|
if (!key.startsWith(`${sessionId}:`)) {
|
|
2530
2522
|
continue;
|
|
@@ -2535,82 +2527,29 @@ var EveBridge = (_class = class {
|
|
|
2535
2527
|
}
|
|
2536
2528
|
for (const [key, tool] of this.toolsByCallKey) {
|
|
2537
2529
|
if (key.startsWith(`${sessionId}:`) && !tool.endedByTurn) {
|
|
2538
|
-
const
|
|
2530
|
+
const endTime = eventTime(event);
|
|
2539
2531
|
tool.span.log({ metadata: tool.metadata });
|
|
2540
|
-
tool.span.end(
|
|
2532
|
+
tool.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2541
2533
|
tool.endedByTurn = true;
|
|
2542
2534
|
}
|
|
2543
2535
|
}
|
|
2544
|
-
session.span.log({ metadata: session.metadata });
|
|
2545
|
-
const endTime = eventTime(event);
|
|
2546
|
-
session.span.end(endTime === void 0 ? void 0 : { endTime });
|
|
2547
|
-
}
|
|
2548
|
-
async ensureSession(sessionId, ctx, metadata, startTime) {
|
|
2549
|
-
metadata = {
|
|
2550
|
-
...readEveTraceState(this.state).metadata,
|
|
2551
|
-
...metadata
|
|
2552
|
-
};
|
|
2553
|
-
const existing = this.sessionsById.get(sessionId);
|
|
2554
|
-
if (existing) {
|
|
2555
|
-
existing.metadata = { ...existing.metadata, ...metadata };
|
|
2556
|
-
existing.span.log({ metadata: existing.metadata });
|
|
2557
|
-
return existing;
|
|
2558
|
-
}
|
|
2559
|
-
const lineage = parentLineageFromContext(ctx);
|
|
2560
|
-
const parentSubagent = lineage ? this.toolsByCallKey.get(toolKey(lineage.sessionId, lineage.callId)) : void 0;
|
|
2561
|
-
const activeParent = _chunkMWVVR5LRjs.currentSpan.call(void 0, );
|
|
2562
|
-
const [
|
|
2563
|
-
{ rowId: eventId, spanId },
|
|
2564
|
-
parentSubagentSpanId,
|
|
2565
|
-
fallbackRootSpanId
|
|
2566
|
-
] = await Promise.all([
|
|
2567
|
-
generateEveIds("session", sessionId),
|
|
2568
|
-
lineage ? spanIdForSubagent(lineage.sessionId, lineage.callId) : Promise.resolve(void 0),
|
|
2569
|
-
lineage ? rootSpanIdForSession(lineage.rootSessionId) : rootSpanIdForSession(sessionId)
|
|
2570
|
-
]);
|
|
2571
|
-
const span = await this.startEveSpan({
|
|
2572
|
-
event: {
|
|
2573
|
-
id: eventId,
|
|
2574
|
-
metadata
|
|
2575
|
-
},
|
|
2576
|
-
name: "eve.session",
|
|
2577
|
-
parentSpanIds: lineage && parentSubagentSpanId ? {
|
|
2578
|
-
rootSpanId: _nullishCoalesce(_optionalChain([parentSubagent, 'optionalAccess', _100 => _100.span, 'access', _101 => _101.rootSpanId]), () => ( fallbackRootSpanId)),
|
|
2579
|
-
spanId: parentSubagentSpanId
|
|
2580
|
-
} : !Object.is(activeParent, _chunkMWVVR5LRjs.NOOP_SPAN) ? {
|
|
2581
|
-
rootSpanId: activeParent.rootSpanId,
|
|
2582
|
-
spanId: activeParent.spanId
|
|
2583
|
-
} : {
|
|
2584
|
-
parentSpanIds: [],
|
|
2585
|
-
rootSpanId: fallbackRootSpanId
|
|
2586
|
-
},
|
|
2587
|
-
spanAttributes: { type: "task" /* TASK */ },
|
|
2588
|
-
spanId,
|
|
2589
|
-
startTime
|
|
2590
|
-
});
|
|
2591
|
-
span.log({ metadata });
|
|
2592
|
-
const session = { metadata, sessionId, span };
|
|
2593
|
-
this.sessionsById.set(sessionId, session);
|
|
2594
|
-
return session;
|
|
2595
2536
|
}
|
|
2596
2537
|
async ensureTurn(event, ctx, hookMetadata) {
|
|
2597
2538
|
const sessionId = sessionIdFromContext(ctx);
|
|
2598
2539
|
if (!sessionId) {
|
|
2599
2540
|
return void 0;
|
|
2600
2541
|
}
|
|
2601
|
-
const session = await this.ensureSession(
|
|
2602
|
-
sessionId,
|
|
2603
|
-
ctx,
|
|
2604
|
-
_nullishCoalesce(hookMetadata, () => ( {})),
|
|
2605
|
-
eventTime(event)
|
|
2606
|
-
);
|
|
2607
2542
|
const key = turnKey(sessionId, event.data.turnId);
|
|
2608
2543
|
const existing = this.turnsByKey.get(key);
|
|
2609
2544
|
if (existing) {
|
|
2610
2545
|
return existing;
|
|
2611
2546
|
}
|
|
2612
|
-
const metadata = {
|
|
2613
|
-
|
|
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);
|
|
2614
2553
|
span.log({ metadata });
|
|
2615
2554
|
const state = {
|
|
2616
2555
|
key,
|
|
@@ -2797,22 +2736,35 @@ var EveBridge = (_class = class {
|
|
|
2797
2736
|
this.toolsByCallKey.set(toolKey(sessionId, result.callId), state);
|
|
2798
2737
|
return state;
|
|
2799
2738
|
}
|
|
2800
|
-
async startTurnSpan(
|
|
2801
|
-
const
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2739
|
+
async startTurnSpan(sessionId, event, ctx, metadata) {
|
|
2740
|
+
const session = _chunkB6ZQIAK3js.isObject.call(void 0, ctx) ? ctx["session"] : void 0;
|
|
2741
|
+
const parent = _chunkB6ZQIAK3js.isObject.call(void 0, session) ? session["parent"] : void 0;
|
|
2742
|
+
const parentTurn = _chunkB6ZQIAK3js.isObject.call(void 0, parent) ? parent["turn"] : void 0;
|
|
2743
|
+
const parentLineage = _chunkB6ZQIAK3js.isObject.call(void 0, parent) && typeof parent["callId"] === "string" && typeof parent["sessionId"] === "string" && _chunkB6ZQIAK3js.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
|
+
]);
|
|
2806
2761
|
return await this.startEveSpan({
|
|
2807
2762
|
event: {
|
|
2808
2763
|
id: eventId,
|
|
2809
2764
|
metadata
|
|
2810
2765
|
},
|
|
2811
2766
|
name: "eve.turn",
|
|
2812
|
-
parentSpanIds: {
|
|
2813
|
-
rootSpanId: session.span.rootSpanId,
|
|
2814
|
-
spanId: session.span.spanId
|
|
2815
|
-
},
|
|
2767
|
+
parentSpanIds: parentSpanId ? { rootSpanId, spanId: parentSpanId } : { parentSpanIds: [], rootSpanId },
|
|
2816
2768
|
spanAttributes: { type: "task" /* TASK */ },
|
|
2817
2769
|
spanId,
|
|
2818
2770
|
startTime: eventTime(event)
|
|
@@ -2823,7 +2775,7 @@ var EveBridge = (_class = class {
|
|
|
2823
2775
|
return sessionId ? this.turnsByKey.get(turnKey(sessionId, event.data.turnId)) : void 0;
|
|
2824
2776
|
}
|
|
2825
2777
|
stepForEvent(event, ctx) {
|
|
2826
|
-
return _optionalChain([this, 'access',
|
|
2778
|
+
return _optionalChain([this, 'access', _98 => _98.turnForEvent, 'call', _99 => _99(event, ctx), 'optionalAccess', _100 => _100.stepsByIndex, 'access', _101 => _101.get, 'call', _102 => _102(
|
|
2827
2779
|
event.data.stepIndex
|
|
2828
2780
|
)]);
|
|
2829
2781
|
}
|
|
@@ -2873,7 +2825,6 @@ var EveBridge = (_class = class {
|
|
|
2873
2825
|
}
|
|
2874
2826
|
cleanupSession(sessionId) {
|
|
2875
2827
|
const keyPrefix = `${sessionId}:`;
|
|
2876
|
-
this.sessionsById.delete(sessionId);
|
|
2877
2828
|
for (const key of this.turnsByKey.keys()) {
|
|
2878
2829
|
if (key.startsWith(keyPrefix)) {
|
|
2879
2830
|
this.turnsByKey.delete(key);
|
|
@@ -2893,10 +2844,10 @@ var EveBridge = (_class = class {
|
|
|
2893
2844
|
}
|
|
2894
2845
|
async flushInstrumentation() {
|
|
2895
2846
|
try {
|
|
2896
|
-
await
|
|
2847
|
+
await _chunkB6ZQIAK3js.flush.call(void 0, );
|
|
2897
2848
|
return true;
|
|
2898
2849
|
} catch (error) {
|
|
2899
|
-
|
|
2850
|
+
_chunkB6ZQIAK3js.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
2900
2851
|
return false;
|
|
2901
2852
|
}
|
|
2902
2853
|
}
|
|
@@ -2910,12 +2861,12 @@ function emptyEveTraceState() {
|
|
|
2910
2861
|
};
|
|
2911
2862
|
}
|
|
2912
2863
|
function normalizeEveTraceState(state) {
|
|
2913
|
-
if (!
|
|
2864
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, state)) {
|
|
2914
2865
|
return emptyEveTraceState();
|
|
2915
2866
|
}
|
|
2916
|
-
const metadata =
|
|
2867
|
+
const metadata = _chunkB6ZQIAK3js.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
2917
2868
|
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
2918
|
-
if (!
|
|
2869
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, entry)) {
|
|
2919
2870
|
return [];
|
|
2920
2871
|
}
|
|
2921
2872
|
const exported = entry["exported"];
|
|
@@ -2924,11 +2875,11 @@ function normalizeEveTraceState(state) {
|
|
|
2924
2875
|
const rowId = entry["rowId"];
|
|
2925
2876
|
const spanId = entry["spanId"];
|
|
2926
2877
|
const startEvent = entry["startEvent"];
|
|
2927
|
-
const startEventCreated =
|
|
2928
|
-
const startEventMetrics =
|
|
2929
|
-
const startEventSpanAttributes =
|
|
2930
|
-
const startEventSpanParents =
|
|
2931
|
-
const normalizedStartEvent = typeof startEventCreated === "string" &&
|
|
2878
|
+
const startEventCreated = _chunkB6ZQIAK3js.isObject.call(void 0, startEvent) ? startEvent["created"] : void 0;
|
|
2879
|
+
const startEventMetrics = _chunkB6ZQIAK3js.isObject.call(void 0, startEvent) ? startEvent["metrics"] : void 0;
|
|
2880
|
+
const startEventSpanAttributes = _chunkB6ZQIAK3js.isObject.call(void 0, startEvent) ? startEvent["span_attributes"] : void 0;
|
|
2881
|
+
const startEventSpanParents = _chunkB6ZQIAK3js.isObject.call(void 0, startEvent) ? startEvent["span_parents"] : void 0;
|
|
2882
|
+
const normalizedStartEvent = typeof startEventCreated === "string" && _chunkB6ZQIAK3js.isObject.call(void 0, startEventMetrics) && typeof startEventMetrics["start"] === "number" && Number.isFinite(startEventMetrics["start"]) && _chunkB6ZQIAK3js.isObject.call(void 0, startEventSpanAttributes) && Array.isArray(startEventSpanParents) && startEventSpanParents.every(
|
|
2932
2883
|
(parent) => typeof parent === "string"
|
|
2933
2884
|
) ? {
|
|
2934
2885
|
created: startEventCreated,
|
|
@@ -2948,7 +2899,7 @@ function normalizeEveTraceState(state) {
|
|
|
2948
2899
|
] : [];
|
|
2949
2900
|
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
2950
2901
|
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
2951
|
-
if (!
|
|
2902
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, entry)) {
|
|
2952
2903
|
return [];
|
|
2953
2904
|
}
|
|
2954
2905
|
const key = entry["key"];
|
|
@@ -2956,7 +2907,7 @@ function normalizeEveTraceState(state) {
|
|
|
2956
2907
|
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
2957
2908
|
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
2958
2909
|
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
2959
|
-
if (!
|
|
2910
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, entry)) {
|
|
2960
2911
|
return [];
|
|
2961
2912
|
}
|
|
2962
2913
|
const ordinal = entry["ordinal"];
|
|
@@ -2975,13 +2926,13 @@ function readEveTraceState(state) {
|
|
|
2975
2926
|
}
|
|
2976
2927
|
}
|
|
2977
2928
|
function captureEveModelInput(state, input) {
|
|
2978
|
-
if (!
|
|
2929
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, input)) {
|
|
2979
2930
|
return;
|
|
2980
2931
|
}
|
|
2981
2932
|
const session = input["session"];
|
|
2982
2933
|
const turn = input["turn"];
|
|
2983
2934
|
const step = input["step"];
|
|
2984
|
-
if (!
|
|
2935
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, session) || !_chunkB6ZQIAK3js.isObject.call(void 0, turn) || !_chunkB6ZQIAK3js.isObject.call(void 0, step)) {
|
|
2985
2936
|
return;
|
|
2986
2937
|
}
|
|
2987
2938
|
const sessionId = session["id"];
|
|
@@ -3016,7 +2967,7 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3016
2967
|
if (index < 0) {
|
|
3017
2968
|
return normalized;
|
|
3018
2969
|
}
|
|
3019
|
-
input = _optionalChain([normalized, 'access',
|
|
2970
|
+
input = _optionalChain([normalized, 'access', _103 => _103.llmInputs, 'access', _104 => _104[index], 'optionalAccess', _105 => _105.input]);
|
|
3020
2971
|
return {
|
|
3021
2972
|
...normalized,
|
|
3022
2973
|
llmInputs: normalized.llmInputs.filter(
|
|
@@ -3026,12 +2977,12 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3026
2977
|
});
|
|
3027
2978
|
return input;
|
|
3028
2979
|
} catch (error) {
|
|
3029
|
-
|
|
2980
|
+
_chunkB6ZQIAK3js.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
3030
2981
|
return void 0;
|
|
3031
2982
|
}
|
|
3032
2983
|
}
|
|
3033
2984
|
function capturedModelInput(modelInput) {
|
|
3034
|
-
if (!
|
|
2985
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, modelInput)) {
|
|
3035
2986
|
return void 0;
|
|
3036
2987
|
}
|
|
3037
2988
|
const messages = modelInput["messages"];
|
|
@@ -3060,11 +3011,11 @@ function llmInputKey(sessionId, turnId, stepIndex) {
|
|
|
3060
3011
|
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3061
3012
|
}
|
|
3062
3013
|
function modelMetadataFromRuntime(runtime) {
|
|
3063
|
-
if (!
|
|
3014
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, runtime)) {
|
|
3064
3015
|
return {};
|
|
3065
3016
|
}
|
|
3066
3017
|
const modelId = runtime["modelId"];
|
|
3067
|
-
return typeof modelId === "string" ? modelMetadataFromModelId(modelId) : {};
|
|
3018
|
+
return typeof modelId === "string" && !modelId.trim().startsWith("dynamic:") ? modelMetadataFromModelId(modelId) : {};
|
|
3068
3019
|
}
|
|
3069
3020
|
function modelMetadataFromModelId(modelId) {
|
|
3070
3021
|
const normalized = modelId.trim();
|
|
@@ -3083,11 +3034,11 @@ function modelMetadataFromModelId(modelId) {
|
|
|
3083
3034
|
};
|
|
3084
3035
|
}
|
|
3085
3036
|
function sessionIdFromContext(ctx) {
|
|
3086
|
-
if (!
|
|
3037
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, ctx)) {
|
|
3087
3038
|
return void 0;
|
|
3088
3039
|
}
|
|
3089
3040
|
const session = ctx["session"];
|
|
3090
|
-
if (!
|
|
3041
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, session)) {
|
|
3091
3042
|
return void 0;
|
|
3092
3043
|
}
|
|
3093
3044
|
const id = session["id"];
|
|
@@ -3097,40 +3048,20 @@ function toolMetadataFromTurn(turn) {
|
|
|
3097
3048
|
const { model: _model, provider: _provider, ...metadata } = turn.metadata;
|
|
3098
3049
|
return metadata;
|
|
3099
3050
|
}
|
|
3100
|
-
function parentLineageFromContext(ctx) {
|
|
3101
|
-
if (!_chunkMWVVR5LRjs.isObject.call(void 0, ctx)) {
|
|
3102
|
-
return void 0;
|
|
3103
|
-
}
|
|
3104
|
-
const session = ctx.session;
|
|
3105
|
-
if (!_chunkMWVVR5LRjs.isObject.call(void 0, session)) {
|
|
3106
|
-
return void 0;
|
|
3107
|
-
}
|
|
3108
|
-
const parent = session["parent"];
|
|
3109
|
-
if (!_chunkMWVVR5LRjs.isObject.call(void 0, parent)) {
|
|
3110
|
-
return void 0;
|
|
3111
|
-
}
|
|
3112
|
-
const callId = parent["callId"];
|
|
3113
|
-
const rootSessionId = parent["rootSessionId"];
|
|
3114
|
-
const sessionId = parent["sessionId"];
|
|
3115
|
-
if (typeof callId !== "string" || typeof rootSessionId !== "string" || typeof sessionId !== "string") {
|
|
3116
|
-
return void 0;
|
|
3117
|
-
}
|
|
3118
|
-
return { callId, rootSessionId, sessionId };
|
|
3119
|
-
}
|
|
3120
3051
|
function isToolCallAction(action) {
|
|
3121
|
-
return
|
|
3052
|
+
return _chunkB6ZQIAK3js.isObject.call(void 0, action) && action["kind"] === "tool-call" && typeof action["callId"] === "string" && typeof action["toolName"] === "string" && _chunkB6ZQIAK3js.isObject.call(void 0, action["input"]);
|
|
3122
3053
|
}
|
|
3123
3054
|
function isLocalSubagentCallAction(action) {
|
|
3124
|
-
return
|
|
3055
|
+
return _chunkB6ZQIAK3js.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkB6ZQIAK3js.isObject.call(void 0, action["input"]);
|
|
3125
3056
|
}
|
|
3126
3057
|
function isTraceableActionRequest(action) {
|
|
3127
3058
|
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3128
3059
|
}
|
|
3129
3060
|
function isToolResult(result) {
|
|
3130
|
-
return
|
|
3061
|
+
return _chunkB6ZQIAK3js.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3131
3062
|
}
|
|
3132
3063
|
function isSubagentResult(result) {
|
|
3133
|
-
return
|
|
3064
|
+
return _chunkB6ZQIAK3js.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3134
3065
|
}
|
|
3135
3066
|
function normalizedFinishReason(finishReason) {
|
|
3136
3067
|
switch (finishReason) {
|
|
@@ -3160,7 +3091,7 @@ function actionResultError(error, output) {
|
|
|
3160
3091
|
return result;
|
|
3161
3092
|
}
|
|
3162
3093
|
function eventTime(event) {
|
|
3163
|
-
if (!_optionalChain([event, 'access',
|
|
3094
|
+
if (!_optionalChain([event, 'access', _106 => _106.meta, 'optionalAccess', _107 => _107.at])) {
|
|
3164
3095
|
return void 0;
|
|
3165
3096
|
}
|
|
3166
3097
|
const timestamp = Date.parse(event.meta.at);
|
|
@@ -3172,9 +3103,6 @@ function turnKey(sessionId, turnId) {
|
|
|
3172
3103
|
function toolKey(sessionId, callId) {
|
|
3173
3104
|
return `${sessionId}:${callId}`;
|
|
3174
3105
|
}
|
|
3175
|
-
async function rootSpanIdForSession(sessionId) {
|
|
3176
|
-
return deterministicEveId("eve:root", sessionId);
|
|
3177
|
-
}
|
|
3178
3106
|
async function generateEveIds(kind, ...parts) {
|
|
3179
3107
|
const [rowId, spanId] = await Promise.all([
|
|
3180
3108
|
deterministicEveId(`eve:row:${kind}`, ...parts),
|
|
@@ -3182,9 +3110,6 @@ async function generateEveIds(kind, ...parts) {
|
|
|
3182
3110
|
]);
|
|
3183
3111
|
return { rowId, spanId };
|
|
3184
3112
|
}
|
|
3185
|
-
async function spanIdForSubagent(sessionId, callId) {
|
|
3186
|
-
return deterministicEveId("eve:subagent", sessionId, callId);
|
|
3187
|
-
}
|
|
3188
3113
|
async function deterministicEveId(...parts) {
|
|
3189
3114
|
const data = new TextEncoder().encode(
|
|
3190
3115
|
parts.map((part) => `${part.length}:${part}`).join("\0")
|
|
@@ -3236,7 +3161,7 @@ function messagesProxy(messages) {
|
|
|
3236
3161
|
return new Proxy(messages, {
|
|
3237
3162
|
get(target, prop, receiver) {
|
|
3238
3163
|
if (prop === "create") {
|
|
3239
|
-
return createProxy(target.create,
|
|
3164
|
+
return createProxy(target.create, _chunkCDIKAHDZjs.anthropicChannels.messagesCreate);
|
|
3240
3165
|
}
|
|
3241
3166
|
return Reflect.get(target, prop, receiver);
|
|
3242
3167
|
}
|
|
@@ -3246,7 +3171,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3246
3171
|
return new Proxy(messages, {
|
|
3247
3172
|
get(target, prop, receiver) {
|
|
3248
3173
|
if (prop === "create") {
|
|
3249
|
-
return createProxy(target.create,
|
|
3174
|
+
return createProxy(target.create, _chunkCDIKAHDZjs.anthropicChannels.betaMessagesCreate);
|
|
3250
3175
|
}
|
|
3251
3176
|
if (prop === "toolRunner") {
|
|
3252
3177
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -3255,7 +3180,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3255
3180
|
return toolRunnerProxy(
|
|
3256
3181
|
target.toolRunner,
|
|
3257
3182
|
anthropic,
|
|
3258
|
-
|
|
3183
|
+
_chunkCDIKAHDZjs.anthropicChannels.betaMessagesToolRunner
|
|
3259
3184
|
);
|
|
3260
3185
|
}
|
|
3261
3186
|
return Reflect.get(target, prop, receiver);
|
|
@@ -3312,11 +3237,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
3312
3237
|
...params,
|
|
3313
3238
|
options: {
|
|
3314
3239
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
3315
|
-
[
|
|
3240
|
+
[_chunkB6ZQIAK3js.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
3316
3241
|
}
|
|
3317
3242
|
};
|
|
3318
3243
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3319
|
-
return
|
|
3244
|
+
return _chunkCDIKAHDZjs.claudeAgentSDKChannels.query.traceSync(
|
|
3320
3245
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
3321
3246
|
// The channel carries no extra context fields, but the generated
|
|
3322
3247
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -3344,7 +3269,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
3344
3269
|
}
|
|
3345
3270
|
const localToolMetadata = { toolName };
|
|
3346
3271
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
3347
|
-
wrappedArgs[handlerIndex] =
|
|
3272
|
+
wrappedArgs[handlerIndex] = _chunkB6ZQIAK3js.wrapLocalClaudeToolHandler.call(void 0,
|
|
3348
3273
|
originalHandler,
|
|
3349
3274
|
() => localToolMetadata
|
|
3350
3275
|
);
|
|
@@ -3362,8 +3287,8 @@ function wrapCreateSdkMcpServer(createSdkMcpServerFn, localToolMetadataByTool, d
|
|
|
3362
3287
|
apply(target, thisArg, argArray) {
|
|
3363
3288
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3364
3289
|
const config = argArray[0];
|
|
3365
|
-
const serverName = _optionalChain([config, 'optionalAccess',
|
|
3366
|
-
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]))) {
|
|
3367
3292
|
for (const tool of config.tools) {
|
|
3368
3293
|
if (!tool || typeof tool !== "object") {
|
|
3369
3294
|
continue;
|
|
@@ -3457,7 +3382,7 @@ function isModuleNamespace2(obj) {
|
|
|
3457
3382
|
if (!obj || typeof obj !== "object") {
|
|
3458
3383
|
return false;
|
|
3459
3384
|
}
|
|
3460
|
-
if (_optionalChain([obj, 'access',
|
|
3385
|
+
if (_optionalChain([obj, 'access', _110 => _110.constructor, 'optionalAccess', _111 => _111.name]) === "Module") {
|
|
3461
3386
|
return true;
|
|
3462
3387
|
}
|
|
3463
3388
|
const keys = Object.keys(obj);
|
|
@@ -3527,7 +3452,7 @@ function wrapCodexThread(thread) {
|
|
|
3527
3452
|
if (prop === "run" && typeof value === "function") {
|
|
3528
3453
|
return function(input, turnOptions) {
|
|
3529
3454
|
const args = [input, turnOptions];
|
|
3530
|
-
return
|
|
3455
|
+
return _chunkCDIKAHDZjs.openAICodexChannels.run.tracePromise(
|
|
3531
3456
|
() => Reflect.apply(value, target, args),
|
|
3532
3457
|
{
|
|
3533
3458
|
arguments: args,
|
|
@@ -3540,7 +3465,7 @@ function wrapCodexThread(thread) {
|
|
|
3540
3465
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
3541
3466
|
return function(input, turnOptions) {
|
|
3542
3467
|
const args = [input, turnOptions];
|
|
3543
|
-
return
|
|
3468
|
+
return _chunkCDIKAHDZjs.openAICodexChannels.runStreamed.tracePromise(
|
|
3544
3469
|
() => Reflect.apply(value, target, args),
|
|
3545
3470
|
{
|
|
3546
3471
|
arguments: args,
|
|
@@ -3587,7 +3512,7 @@ function isModuleNamespace3(obj) {
|
|
|
3587
3512
|
if (!obj || typeof obj !== "object") {
|
|
3588
3513
|
return false;
|
|
3589
3514
|
}
|
|
3590
|
-
if (_optionalChain([obj, 'access',
|
|
3515
|
+
if (_optionalChain([obj, 'access', _112 => _112.constructor, 'optionalAccess', _113 => _113.name]) === "Module") {
|
|
3591
3516
|
return true;
|
|
3592
3517
|
}
|
|
3593
3518
|
const keys = Object.keys(obj);
|
|
@@ -3608,7 +3533,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3608
3533
|
if (prop === "create" && typeof value === "function") {
|
|
3609
3534
|
const wrapped = async function(options) {
|
|
3610
3535
|
const args = [options];
|
|
3611
|
-
return
|
|
3536
|
+
return _chunkCDIKAHDZjs.cursorSDKChannels.create.tracePromise(
|
|
3612
3537
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
3613
3538
|
{ arguments: args }
|
|
3614
3539
|
);
|
|
@@ -3619,7 +3544,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3619
3544
|
if (prop === "resume" && typeof value === "function") {
|
|
3620
3545
|
const wrapped = async function(agentId, options) {
|
|
3621
3546
|
const args = [agentId, options];
|
|
3622
|
-
return
|
|
3547
|
+
return _chunkCDIKAHDZjs.cursorSDKChannels.resume.tracePromise(
|
|
3623
3548
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
3624
3549
|
{ arguments: args }
|
|
3625
3550
|
);
|
|
@@ -3630,7 +3555,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3630
3555
|
if (prop === "prompt" && typeof value === "function") {
|
|
3631
3556
|
const wrapped = async function(message, options) {
|
|
3632
3557
|
const args = [message, options];
|
|
3633
|
-
return
|
|
3558
|
+
return _chunkCDIKAHDZjs.cursorSDKChannels.prompt.tracePromise(
|
|
3634
3559
|
() => Reflect.apply(value, target, args),
|
|
3635
3560
|
{ arguments: args }
|
|
3636
3561
|
);
|
|
@@ -3663,7 +3588,7 @@ function wrapCursorAgent(agent) {
|
|
|
3663
3588
|
if (prop === "send" && typeof value === "function") {
|
|
3664
3589
|
return function(message, options) {
|
|
3665
3590
|
const args = [message, options];
|
|
3666
|
-
return
|
|
3591
|
+
return _chunkCDIKAHDZjs.cursorSDKChannels.send.tracePromise(
|
|
3667
3592
|
() => Reflect.apply(value, target, args),
|
|
3668
3593
|
{
|
|
3669
3594
|
agent: target,
|
|
@@ -3713,7 +3638,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
3713
3638
|
...descriptor,
|
|
3714
3639
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
3715
3640
|
const args = [text, options];
|
|
3716
|
-
return
|
|
3641
|
+
return _chunkCDIKAHDZjs.piCodingAgentChannels.prompt.tracePromise(
|
|
3717
3642
|
() => Reflect.apply(originalPrompt, this, args),
|
|
3718
3643
|
{
|
|
3719
3644
|
arguments: args,
|
|
@@ -3771,7 +3696,7 @@ function isModuleNamespace4(obj) {
|
|
|
3771
3696
|
if (!obj || typeof obj !== "object") {
|
|
3772
3697
|
return false;
|
|
3773
3698
|
}
|
|
3774
|
-
if (_optionalChain([obj, 'access',
|
|
3699
|
+
if (_optionalChain([obj, 'access', _114 => _114.constructor, 'optionalAccess', _115 => _115.name]) === "Module") {
|
|
3775
3700
|
return true;
|
|
3776
3701
|
}
|
|
3777
3702
|
const keys = Object.keys(obj);
|
|
@@ -3833,7 +3758,7 @@ function wrapAgentInstance(agent) {
|
|
|
3833
3758
|
if (prop === "stream" && typeof value === "function") {
|
|
3834
3759
|
return function(args, options) {
|
|
3835
3760
|
const callArgs = [args, options];
|
|
3836
|
-
return
|
|
3761
|
+
return _chunkCDIKAHDZjs.strandsAgentSDKChannels.agentStream.traceSync(
|
|
3837
3762
|
() => Reflect.apply(value, target, callArgs),
|
|
3838
3763
|
{
|
|
3839
3764
|
agent: proxy,
|
|
@@ -3869,7 +3794,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
3869
3794
|
if (prop === "stream" && typeof value === "function") {
|
|
3870
3795
|
return function(input, options) {
|
|
3871
3796
|
const callArgs = [input, options];
|
|
3872
|
-
const channel = kind === "graph" ?
|
|
3797
|
+
const channel = kind === "graph" ? _chunkCDIKAHDZjs.strandsAgentSDKChannels.graphStream : _chunkCDIKAHDZjs.strandsAgentSDKChannels.swarmStream;
|
|
3873
3798
|
return channel.traceSync(
|
|
3874
3799
|
() => Reflect.apply(value, target, callArgs),
|
|
3875
3800
|
{
|
|
@@ -3944,7 +3869,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
3944
3869
|
}
|
|
3945
3870
|
if (prop === "interactions") {
|
|
3946
3871
|
const interactions = Reflect.get(target, prop, receiver);
|
|
3947
|
-
if (!
|
|
3872
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
3948
3873
|
return interactions;
|
|
3949
3874
|
}
|
|
3950
3875
|
if (interactions !== originalInteractions) {
|
|
@@ -3958,7 +3883,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
3958
3883
|
});
|
|
3959
3884
|
}
|
|
3960
3885
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
3961
|
-
if (!
|
|
3886
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
3962
3887
|
return;
|
|
3963
3888
|
}
|
|
3964
3889
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -3991,7 +3916,7 @@ function wrapInteractions(interactions) {
|
|
|
3991
3916
|
}
|
|
3992
3917
|
function wrapGenerateContent(original) {
|
|
3993
3918
|
return function(params) {
|
|
3994
|
-
return
|
|
3919
|
+
return _chunkCDIKAHDZjs.googleGenAIChannels.generateContent.tracePromise(
|
|
3995
3920
|
() => original(params),
|
|
3996
3921
|
{ arguments: [params] }
|
|
3997
3922
|
);
|
|
@@ -3999,7 +3924,7 @@ function wrapGenerateContent(original) {
|
|
|
3999
3924
|
}
|
|
4000
3925
|
function wrapGenerateContentStream(original) {
|
|
4001
3926
|
return function(params) {
|
|
4002
|
-
return
|
|
3927
|
+
return _chunkCDIKAHDZjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
4003
3928
|
() => original(params),
|
|
4004
3929
|
{ arguments: [params] }
|
|
4005
3930
|
);
|
|
@@ -4007,7 +3932,7 @@ function wrapGenerateContentStream(original) {
|
|
|
4007
3932
|
}
|
|
4008
3933
|
function wrapEmbedContent(original) {
|
|
4009
3934
|
return function(params) {
|
|
4010
|
-
return
|
|
3935
|
+
return _chunkCDIKAHDZjs.googleGenAIChannels.embedContent.tracePromise(
|
|
4011
3936
|
() => original(params),
|
|
4012
3937
|
{ arguments: [params] }
|
|
4013
3938
|
);
|
|
@@ -4019,7 +3944,7 @@ function wrapInteractionCreate(original) {
|
|
|
4019
3944
|
return options === void 0 ? original(params) : original(params, options);
|
|
4020
3945
|
}
|
|
4021
3946
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
4022
|
-
return
|
|
3947
|
+
return _chunkCDIKAHDZjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
4023
3948
|
() => options === void 0 ? original(params) : original(params, options),
|
|
4024
3949
|
traceContext
|
|
4025
3950
|
);
|
|
@@ -4080,7 +4005,7 @@ function wrapRunnerInstance(runner) {
|
|
|
4080
4005
|
function wrapRunnerRunAsync(runner) {
|
|
4081
4006
|
const original = runner.runAsync.bind(runner);
|
|
4082
4007
|
return function(params) {
|
|
4083
|
-
return
|
|
4008
|
+
return _chunkCDIKAHDZjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
4084
4009
|
arguments: [params],
|
|
4085
4010
|
self: runner
|
|
4086
4011
|
});
|
|
@@ -4107,7 +4032,7 @@ function wrapAgentInstance2(agent) {
|
|
|
4107
4032
|
function wrapAgentRunAsync(agent) {
|
|
4108
4033
|
const original = agent.runAsync.bind(agent);
|
|
4109
4034
|
return function(parentContext) {
|
|
4110
|
-
return
|
|
4035
|
+
return _chunkCDIKAHDZjs.googleADKChannels.agentRunAsync.traceSync(
|
|
4111
4036
|
() => original(parentContext),
|
|
4112
4037
|
{ arguments: [parentContext], self: agent }
|
|
4113
4038
|
);
|
|
@@ -4134,7 +4059,7 @@ function wrapToolInstance(tool) {
|
|
|
4134
4059
|
function wrapToolRunAsync(tool) {
|
|
4135
4060
|
const original = tool.runAsync.bind(tool);
|
|
4136
4061
|
return function(req) {
|
|
4137
|
-
return
|
|
4062
|
+
return _chunkCDIKAHDZjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
4138
4063
|
arguments: [req],
|
|
4139
4064
|
self: tool
|
|
4140
4065
|
});
|
|
@@ -4281,27 +4206,27 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
4281
4206
|
}
|
|
4282
4207
|
}
|
|
4283
4208
|
function wrapGenerate(generate) {
|
|
4284
|
-
return (input) =>
|
|
4209
|
+
return (input) => _chunkCDIKAHDZjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
4285
4210
|
arguments: [input]
|
|
4286
4211
|
});
|
|
4287
4212
|
}
|
|
4288
4213
|
function wrapGenerateStream(generateStream) {
|
|
4289
|
-
return (input) =>
|
|
4214
|
+
return (input) => _chunkCDIKAHDZjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
4290
4215
|
arguments: [input]
|
|
4291
4216
|
});
|
|
4292
4217
|
}
|
|
4293
4218
|
function wrapEmbed2(embed) {
|
|
4294
|
-
return (params) =>
|
|
4219
|
+
return (params) => _chunkCDIKAHDZjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
4295
4220
|
arguments: [params]
|
|
4296
4221
|
});
|
|
4297
4222
|
}
|
|
4298
4223
|
function wrapEmbedMany2(embedMany) {
|
|
4299
|
-
return (params) =>
|
|
4224
|
+
return (params) => _chunkCDIKAHDZjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
4300
4225
|
arguments: [params]
|
|
4301
4226
|
});
|
|
4302
4227
|
}
|
|
4303
4228
|
function wrapRun(run) {
|
|
4304
|
-
return (name, inputOrFn, maybeFn) =>
|
|
4229
|
+
return (name, inputOrFn, maybeFn) => _chunkCDIKAHDZjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
4305
4230
|
arguments: [name, inputOrFn, maybeFn]
|
|
4306
4231
|
});
|
|
4307
4232
|
}
|
|
@@ -4340,13 +4265,13 @@ function isGenkitAction(value) {
|
|
|
4340
4265
|
return typeof value === "function" && "__action" in value;
|
|
4341
4266
|
}
|
|
4342
4267
|
function traceActionRun(action, run) {
|
|
4343
|
-
return (input, options) =>
|
|
4268
|
+
return (input, options) => _chunkCDIKAHDZjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
4344
4269
|
arguments: [input, options],
|
|
4345
4270
|
self: action
|
|
4346
4271
|
});
|
|
4347
4272
|
}
|
|
4348
4273
|
function traceActionStream(action, stream) {
|
|
4349
|
-
return (input, options) =>
|
|
4274
|
+
return (input, options) => _chunkCDIKAHDZjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
4350
4275
|
arguments: [input, options],
|
|
4351
4276
|
self: action
|
|
4352
4277
|
});
|
|
@@ -4392,10 +4317,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
4392
4317
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
4393
4318
|
}
|
|
4394
4319
|
function hasFunction2(value, methodName) {
|
|
4395
|
-
return
|
|
4320
|
+
return _chunkB6ZQIAK3js.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
4396
4321
|
}
|
|
4397
4322
|
function isSupportedHuggingFaceModule(value) {
|
|
4398
|
-
if (!
|
|
4323
|
+
if (!_chunkB6ZQIAK3js.isObject.call(void 0, value)) {
|
|
4399
4324
|
return false;
|
|
4400
4325
|
}
|
|
4401
4326
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -4503,14 +4428,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
4503
4428
|
const context = {
|
|
4504
4429
|
arguments: [traceParams]
|
|
4505
4430
|
};
|
|
4506
|
-
return
|
|
4431
|
+
return _chunkCDIKAHDZjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
4507
4432
|
() => original(params, options),
|
|
4508
4433
|
context
|
|
4509
4434
|
);
|
|
4510
4435
|
};
|
|
4511
4436
|
}
|
|
4512
4437
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
4513
|
-
return (params, options) =>
|
|
4438
|
+
return (params, options) => _chunkCDIKAHDZjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
4514
4439
|
() => original(params, options),
|
|
4515
4440
|
{
|
|
4516
4441
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -4523,14 +4448,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
4523
4448
|
const context = {
|
|
4524
4449
|
arguments: [traceParams]
|
|
4525
4450
|
};
|
|
4526
|
-
return
|
|
4451
|
+
return _chunkCDIKAHDZjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
4527
4452
|
() => original(params, options),
|
|
4528
4453
|
context
|
|
4529
4454
|
);
|
|
4530
4455
|
};
|
|
4531
4456
|
}
|
|
4532
4457
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
4533
|
-
return (params, options) =>
|
|
4458
|
+
return (params, options) => _chunkCDIKAHDZjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
4534
4459
|
() => original(params, options),
|
|
4535
4460
|
{
|
|
4536
4461
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -4543,7 +4468,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
4543
4468
|
const context = {
|
|
4544
4469
|
arguments: [traceParams]
|
|
4545
4470
|
};
|
|
4546
|
-
return
|
|
4471
|
+
return _chunkCDIKAHDZjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
4547
4472
|
() => original(params, options),
|
|
4548
4473
|
context
|
|
4549
4474
|
);
|
|
@@ -4590,7 +4515,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
4590
4515
|
const request = cloneCallModelRequest(argArray[0]);
|
|
4591
4516
|
const options = argArray[1];
|
|
4592
4517
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
4593
|
-
return
|
|
4518
|
+
return _chunkCDIKAHDZjs.openRouterAgentChannels.callModel.traceSync(
|
|
4594
4519
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
4595
4520
|
{
|
|
4596
4521
|
arguments: [request]
|
|
@@ -4686,24 +4611,24 @@ function rerankProxy(rerank) {
|
|
|
4686
4611
|
});
|
|
4687
4612
|
}
|
|
4688
4613
|
function wrapChatSend(send) {
|
|
4689
|
-
return (request, options) =>
|
|
4614
|
+
return (request, options) => _chunkCDIKAHDZjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
4690
4615
|
arguments: [request]
|
|
4691
4616
|
});
|
|
4692
4617
|
}
|
|
4693
4618
|
function wrapEmbeddingsGenerate(generate) {
|
|
4694
|
-
return (request, options) =>
|
|
4619
|
+
return (request, options) => _chunkCDIKAHDZjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
4695
4620
|
() => generate(request, options),
|
|
4696
4621
|
{ arguments: [request] }
|
|
4697
4622
|
);
|
|
4698
4623
|
}
|
|
4699
4624
|
function wrapResponsesSend(send) {
|
|
4700
|
-
return (request, options) =>
|
|
4625
|
+
return (request, options) => _chunkCDIKAHDZjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
4701
4626
|
() => send(request, options),
|
|
4702
4627
|
{ arguments: [request] }
|
|
4703
4628
|
);
|
|
4704
4629
|
}
|
|
4705
4630
|
function wrapRerank2(rerank) {
|
|
4706
|
-
return (request, options) =>
|
|
4631
|
+
return (request, options) => _chunkCDIKAHDZjs.openRouterChannels.rerankRerank.tracePromise(
|
|
4707
4632
|
() => rerank(request, options),
|
|
4708
4633
|
{ arguments: [request] }
|
|
4709
4634
|
);
|
|
@@ -4711,7 +4636,7 @@ function wrapRerank2(rerank) {
|
|
|
4711
4636
|
function wrapCallModel2(callModel) {
|
|
4712
4637
|
return (request, options) => {
|
|
4713
4638
|
const tracedRequest = { ...request };
|
|
4714
|
-
return
|
|
4639
|
+
return _chunkCDIKAHDZjs.openRouterChannels.callModel.traceSync(
|
|
4715
4640
|
() => callModel(tracedRequest, options),
|
|
4716
4641
|
{
|
|
4717
4642
|
arguments: [tracedRequest]
|
|
@@ -4844,7 +4769,7 @@ function classifiersProxy(classifiers) {
|
|
|
4844
4769
|
});
|
|
4845
4770
|
}
|
|
4846
4771
|
function wrapChatComplete(complete) {
|
|
4847
|
-
return (request, options) =>
|
|
4772
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.chatComplete.tracePromise(
|
|
4848
4773
|
() => complete(request, options),
|
|
4849
4774
|
{
|
|
4850
4775
|
arguments: [request]
|
|
@@ -4852,52 +4777,52 @@ function wrapChatComplete(complete) {
|
|
|
4852
4777
|
);
|
|
4853
4778
|
}
|
|
4854
4779
|
function wrapChatStream(stream) {
|
|
4855
|
-
return (request, options) =>
|
|
4780
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
4856
4781
|
arguments: [request]
|
|
4857
4782
|
});
|
|
4858
4783
|
}
|
|
4859
4784
|
function wrapEmbeddingsCreate(create) {
|
|
4860
|
-
return (request, options) =>
|
|
4785
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
4861
4786
|
() => create(request, options),
|
|
4862
4787
|
{ arguments: [request] }
|
|
4863
4788
|
);
|
|
4864
4789
|
}
|
|
4865
4790
|
function wrapClassifiersModerate(moderate) {
|
|
4866
|
-
return (request, options) =>
|
|
4791
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.classifiersModerate.tracePromise(
|
|
4867
4792
|
() => moderate(request, options),
|
|
4868
4793
|
{ arguments: [request] }
|
|
4869
4794
|
);
|
|
4870
4795
|
}
|
|
4871
4796
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
4872
|
-
return (request, options) =>
|
|
4797
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
4873
4798
|
() => moderateChat(request, options),
|
|
4874
4799
|
{ arguments: [request] }
|
|
4875
4800
|
);
|
|
4876
4801
|
}
|
|
4877
4802
|
function wrapClassifiersClassify(classify) {
|
|
4878
|
-
return (request, options) =>
|
|
4803
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.classifiersClassify.tracePromise(
|
|
4879
4804
|
() => classify(request, options),
|
|
4880
4805
|
{ arguments: [request] }
|
|
4881
4806
|
);
|
|
4882
4807
|
}
|
|
4883
4808
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
4884
|
-
return (request, options) =>
|
|
4809
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
4885
4810
|
() => classifyChat(request, options),
|
|
4886
4811
|
{ arguments: [request] }
|
|
4887
4812
|
);
|
|
4888
4813
|
}
|
|
4889
4814
|
function wrapFimComplete(complete) {
|
|
4890
|
-
return (request, options) =>
|
|
4815
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
4891
4816
|
arguments: [request]
|
|
4892
4817
|
});
|
|
4893
4818
|
}
|
|
4894
4819
|
function wrapFimStream(stream) {
|
|
4895
|
-
return (request, options) =>
|
|
4820
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
4896
4821
|
arguments: [request]
|
|
4897
4822
|
});
|
|
4898
4823
|
}
|
|
4899
4824
|
function wrapAgentsComplete(complete) {
|
|
4900
|
-
return (request, options) =>
|
|
4825
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.agentsComplete.tracePromise(
|
|
4901
4826
|
() => complete(request, options),
|
|
4902
4827
|
{
|
|
4903
4828
|
arguments: [request]
|
|
@@ -4905,7 +4830,7 @@ function wrapAgentsComplete(complete) {
|
|
|
4905
4830
|
);
|
|
4906
4831
|
}
|
|
4907
4832
|
function wrapAgentsStream(stream) {
|
|
4908
|
-
return (request, options) =>
|
|
4833
|
+
return (request, options) => _chunkCDIKAHDZjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
4909
4834
|
arguments: [request]
|
|
4910
4835
|
});
|
|
4911
4836
|
}
|
|
@@ -4958,22 +4883,22 @@ function cohereProxy(cohere) {
|
|
|
4958
4883
|
return proxy;
|
|
4959
4884
|
}
|
|
4960
4885
|
function wrapChat(chat) {
|
|
4961
|
-
return (request, options) =>
|
|
4886
|
+
return (request, options) => _chunkCDIKAHDZjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
4962
4887
|
arguments: [request]
|
|
4963
4888
|
});
|
|
4964
4889
|
}
|
|
4965
4890
|
function wrapChatStream2(chatStream) {
|
|
4966
|
-
return (request, options) =>
|
|
4891
|
+
return (request, options) => _chunkCDIKAHDZjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
4967
4892
|
arguments: [request]
|
|
4968
4893
|
});
|
|
4969
4894
|
}
|
|
4970
4895
|
function wrapEmbed3(embed) {
|
|
4971
|
-
return (request, options) =>
|
|
4896
|
+
return (request, options) => _chunkCDIKAHDZjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
4972
4897
|
arguments: [request]
|
|
4973
4898
|
});
|
|
4974
4899
|
}
|
|
4975
4900
|
function wrapRerank3(rerank) {
|
|
4976
|
-
return (request, options) =>
|
|
4901
|
+
return (request, options) => _chunkCDIKAHDZjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
4977
4902
|
arguments: [request]
|
|
4978
4903
|
});
|
|
4979
4904
|
}
|
|
@@ -5003,7 +4928,7 @@ function isSupportedGroqClient(value) {
|
|
|
5003
4928
|
}
|
|
5004
4929
|
function groqProxy(groq) {
|
|
5005
4930
|
const privateMethodWorkaroundCache = /* @__PURE__ */ new WeakMap();
|
|
5006
|
-
const completionProxy = _optionalChain([groq, 'access',
|
|
4931
|
+
const completionProxy = _optionalChain([groq, 'access', _116 => _116.chat, 'optionalAccess', _117 => _117.completions]) ? new Proxy(groq.chat.completions, {
|
|
5007
4932
|
get(target, prop, receiver) {
|
|
5008
4933
|
if (prop === "create") {
|
|
5009
4934
|
return wrapChatCompletionsCreate(target.create.bind(target));
|
|
@@ -5055,13 +4980,13 @@ function groqProxy(groq) {
|
|
|
5055
4980
|
return topLevelProxy;
|
|
5056
4981
|
}
|
|
5057
4982
|
function wrapChatCompletionsCreate(create) {
|
|
5058
|
-
return (request, options) =>
|
|
4983
|
+
return (request, options) => _chunkCDIKAHDZjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
5059
4984
|
() => create(request, options),
|
|
5060
4985
|
{ arguments: [request] }
|
|
5061
4986
|
);
|
|
5062
4987
|
}
|
|
5063
4988
|
function wrapEmbeddingsCreate2(create) {
|
|
5064
|
-
return (request, options) =>
|
|
4989
|
+
return (request, options) => _chunkCDIKAHDZjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
5065
4990
|
arguments: [request]
|
|
5066
4991
|
});
|
|
5067
4992
|
}
|
|
@@ -5135,16 +5060,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
5135
5060
|
}
|
|
5136
5061
|
function wrapSend(send) {
|
|
5137
5062
|
return (command, optionsOrCb, cb) => {
|
|
5138
|
-
if (
|
|
5063
|
+
if (_chunkB6ZQIAK3js.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
5139
5064
|
return send(command, optionsOrCb, cb);
|
|
5140
5065
|
}
|
|
5141
|
-
return
|
|
5142
|
-
() =>
|
|
5066
|
+
return _chunkCDIKAHDZjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
5067
|
+
() => _chunkB6ZQIAK3js.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
5143
5068
|
() => send(command, optionsOrCb)
|
|
5144
5069
|
),
|
|
5145
5070
|
{
|
|
5146
5071
|
arguments: [command, optionsOrCb],
|
|
5147
|
-
span_info:
|
|
5072
|
+
span_info: _chunkB6ZQIAK3js.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
5148
5073
|
}
|
|
5149
5074
|
);
|
|
5150
5075
|
};
|
|
@@ -5193,18 +5118,283 @@ function copilotClientProxy(client) {
|
|
|
5193
5118
|
return proxy;
|
|
5194
5119
|
}
|
|
5195
5120
|
function wrappedCreateSession(client) {
|
|
5196
|
-
return (config) =>
|
|
5121
|
+
return (config) => _chunkCDIKAHDZjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
5197
5122
|
() => client.createSession(config),
|
|
5198
5123
|
{ arguments: [config] }
|
|
5199
5124
|
);
|
|
5200
5125
|
}
|
|
5201
5126
|
function wrappedResumeSession(client) {
|
|
5202
|
-
return (sessionId, config) =>
|
|
5127
|
+
return (sessionId, config) => _chunkCDIKAHDZjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
5203
5128
|
() => client.resumeSession(sessionId, config),
|
|
5204
5129
|
{ arguments: [sessionId, config] }
|
|
5205
5130
|
);
|
|
5206
5131
|
}
|
|
5207
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
|
+
_chunkB6ZQIAK3js.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
5392
|
+
});
|
|
5393
|
+
} catch (error) {
|
|
5394
|
+
_chunkB6ZQIAK3js.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5208
5398
|
// src/wrappers/vitest/context-manager.ts
|
|
5209
5399
|
var VitestContextManager = class {
|
|
5210
5400
|
/**
|
|
@@ -5213,7 +5403,7 @@ var VitestContextManager = class {
|
|
|
5213
5403
|
*/
|
|
5214
5404
|
|
|
5215
5405
|
constructor() {
|
|
5216
|
-
this.contextStorage =
|
|
5406
|
+
this.contextStorage = _chunkCDIKAHDZjs.isomorph_default.newAsyncLocalStorage();
|
|
5217
5407
|
}
|
|
5218
5408
|
getCurrentContext() {
|
|
5219
5409
|
return this.contextStorage.getStore();
|
|
@@ -5246,15 +5436,15 @@ function getVitestContextManager() {
|
|
|
5246
5436
|
}
|
|
5247
5437
|
|
|
5248
5438
|
// src/wrappers/vitest/flush-manager.ts
|
|
5249
|
-
var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.
|
|
5250
|
-
|
|
5439
|
+
var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__init5.call(this); }
|
|
5440
|
+
__init5() {this.activeFlushes = /* @__PURE__ */ new Map()}
|
|
5251
5441
|
async coordinateFlush(context, config) {
|
|
5252
5442
|
if (!context) return;
|
|
5253
5443
|
const experimentId = await context.experiment.id;
|
|
5254
5444
|
if (this.activeFlushes.has(experimentId)) {
|
|
5255
5445
|
return this.activeFlushes.get(experimentId);
|
|
5256
5446
|
}
|
|
5257
|
-
const flushPromise =
|
|
5447
|
+
const flushPromise = _chunkB6ZQIAK3js.summarizeAndFlush.call(void 0, context.experiment, {
|
|
5258
5448
|
displaySummary: config.displaySummary
|
|
5259
5449
|
});
|
|
5260
5450
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -5352,7 +5542,7 @@ async function runTracedEval(args) {
|
|
|
5352
5542
|
}
|
|
5353
5543
|
if (testError) {
|
|
5354
5544
|
span.log({ scores: { pass: 0 } });
|
|
5355
|
-
|
|
5545
|
+
_chunkB6ZQIAK3js.logError.call(void 0, span, testError);
|
|
5356
5546
|
throw testError;
|
|
5357
5547
|
}
|
|
5358
5548
|
span.log({
|
|
@@ -5385,7 +5575,7 @@ function wrapTest(originalTest, config) {
|
|
|
5385
5575
|
const wrapped = function(name, configOrFn, maybeFn) {
|
|
5386
5576
|
const isEnhanced = typeof configOrFn !== "function";
|
|
5387
5577
|
const testConfig = isEnhanced ? configOrFn : void 0;
|
|
5388
|
-
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess',
|
|
5578
|
+
if (isEnhanced && _optionalChain([testConfig, 'optionalAccess', _121 => _121.data]) && Array.isArray(testConfig.data)) {
|
|
5389
5579
|
const dataRecords = testConfig.data;
|
|
5390
5580
|
const testFn2 = maybeFn;
|
|
5391
5581
|
if (!testFn2) {
|
|
@@ -5423,7 +5613,7 @@ function wrapTest(originalTest, config) {
|
|
|
5423
5613
|
const registrationContext = getExperimentContext();
|
|
5424
5614
|
const testImplementation = async (vitestContext) => {
|
|
5425
5615
|
const experimentContext = _nullishCoalesce(getExperimentContext(), () => ( registrationContext));
|
|
5426
|
-
const experiment = _optionalChain([experimentContext, 'optionalAccess',
|
|
5616
|
+
const experiment = _optionalChain([experimentContext, 'optionalAccess', _122 => _122.experiment]);
|
|
5427
5617
|
if (config.onProgress) {
|
|
5428
5618
|
config.onProgress({ type: "test_start", testName: name });
|
|
5429
5619
|
}
|
|
@@ -5455,11 +5645,11 @@ function wrapTest(originalTest, config) {
|
|
|
5455
5645
|
const result = await runTracedEval({
|
|
5456
5646
|
experiment,
|
|
5457
5647
|
spanName: name,
|
|
5458
|
-
input: _optionalChain([testConfig, 'optionalAccess',
|
|
5459
|
-
expected: _optionalChain([testConfig, 'optionalAccess',
|
|
5460
|
-
metadata: _optionalChain([testConfig, 'optionalAccess',
|
|
5461
|
-
tags: _optionalChain([testConfig, 'optionalAccess',
|
|
5462
|
-
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]),
|
|
5463
5653
|
fn: async () => {
|
|
5464
5654
|
if (testConfig && maybeFn) {
|
|
5465
5655
|
const params = {
|
|
@@ -5526,10 +5716,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
5526
5716
|
const getOrCreateContext = () => {
|
|
5527
5717
|
if (!context) {
|
|
5528
5718
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5529
|
-
const experiment = config.projectId ?
|
|
5719
|
+
const experiment = config.projectId ? _chunkB6ZQIAK3js.initExperiment.call(void 0, {
|
|
5530
5720
|
projectId: config.projectId,
|
|
5531
5721
|
experiment: experimentName
|
|
5532
|
-
}) :
|
|
5722
|
+
}) : _chunkB6ZQIAK3js.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
5533
5723
|
experiment: experimentName
|
|
5534
5724
|
});
|
|
5535
5725
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -5574,8 +5764,8 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
5574
5764
|
config.onProgress({
|
|
5575
5765
|
type: "suite_complete",
|
|
5576
5766
|
suiteName,
|
|
5577
|
-
passed: _nullishCoalesce(_optionalChain([context, 'optionalAccess',
|
|
5578
|
-
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))
|
|
5579
5769
|
});
|
|
5580
5770
|
}
|
|
5581
5771
|
});
|
|
@@ -5637,7 +5827,7 @@ function wrapExpect(originalExpect) {
|
|
|
5637
5827
|
return originalExpect(value);
|
|
5638
5828
|
}
|
|
5639
5829
|
const assertion = originalExpect(value, message);
|
|
5640
|
-
const span =
|
|
5830
|
+
const span = _chunkB6ZQIAK3js.currentSpan.call(void 0, );
|
|
5641
5831
|
if (!span) {
|
|
5642
5832
|
return assertion;
|
|
5643
5833
|
}
|
|
@@ -5649,16 +5839,16 @@ function wrapExpect(originalExpect) {
|
|
|
5649
5839
|
|
|
5650
5840
|
// src/wrappers/shared/logging.ts
|
|
5651
5841
|
function logOutputs(outputs) {
|
|
5652
|
-
|
|
5842
|
+
_chunkB6ZQIAK3js.currentSpan.call(void 0, ).log({ output: outputs });
|
|
5653
5843
|
}
|
|
5654
5844
|
function logFeedback(feedback) {
|
|
5655
|
-
|
|
5845
|
+
_chunkB6ZQIAK3js.currentSpan.call(void 0, ).log({
|
|
5656
5846
|
scores: { [feedback.name]: feedback.score },
|
|
5657
5847
|
metadata: feedback.metadata
|
|
5658
5848
|
});
|
|
5659
5849
|
}
|
|
5660
5850
|
function getCurrentSpan() {
|
|
5661
|
-
return
|
|
5851
|
+
return _chunkB6ZQIAK3js.currentSpan.call(void 0, );
|
|
5662
5852
|
}
|
|
5663
5853
|
|
|
5664
5854
|
// src/wrappers/vitest/index.ts
|
|
@@ -5706,8 +5896,8 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
5706
5896
|
);
|
|
5707
5897
|
return;
|
|
5708
5898
|
}
|
|
5709
|
-
await
|
|
5710
|
-
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5899
|
+
await _chunkB6ZQIAK3js.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
5900
|
+
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _130 => _130.displaySummary]), () => ( config.displaySummary))
|
|
5711
5901
|
});
|
|
5712
5902
|
}
|
|
5713
5903
|
};
|
|
@@ -5721,7 +5911,7 @@ function initNodeTestSuite(config) {
|
|
|
5721
5911
|
return experiment;
|
|
5722
5912
|
}
|
|
5723
5913
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5724
|
-
experiment =
|
|
5914
|
+
experiment = _chunkB6ZQIAK3js.initExperiment.call(void 0, config.projectName, {
|
|
5725
5915
|
experiment: experimentName
|
|
5726
5916
|
});
|
|
5727
5917
|
return experiment;
|
|
@@ -5770,7 +5960,7 @@ function initNodeTestSuite(config) {
|
|
|
5770
5960
|
if (!experiment) {
|
|
5771
5961
|
return;
|
|
5772
5962
|
}
|
|
5773
|
-
await
|
|
5963
|
+
await _chunkB6ZQIAK3js.summarizeAndFlush.call(void 0, experiment, {
|
|
5774
5964
|
displaySummary: config.displaySummary
|
|
5775
5965
|
});
|
|
5776
5966
|
experiment = void 0;
|
|
@@ -5787,7 +5977,7 @@ function initNodeTestSuite(config) {
|
|
|
5787
5977
|
|
|
5788
5978
|
// src/graph-framework.ts
|
|
5789
5979
|
var graph_framework_exports = {};
|
|
5790
|
-
|
|
5980
|
+
_chunkCDIKAHDZjs.__export.call(void 0, graph_framework_exports, {
|
|
5791
5981
|
AggregatorNode: () => AggregatorNode,
|
|
5792
5982
|
GateNode: () => GateNode,
|
|
5793
5983
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -5802,14 +5992,14 @@ _chunkBFGIH2ZJjs.__export.call(void 0, graph_framework_exports, {
|
|
|
5802
5992
|
unescapePath: () => unescapePath
|
|
5803
5993
|
});
|
|
5804
5994
|
var GraphBuilder = (_class3 = class {
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5995
|
+
__init6() {this.nodes = /* @__PURE__ */ new Map()}
|
|
5996
|
+
__init7() {this.edges = {}}
|
|
5997
|
+
__init8() {this.nodeLikeNodes = /* @__PURE__ */ new Map()}
|
|
5808
5998
|
// Maps node-like objects, like prompts, to their nodes
|
|
5809
5999
|
// Special nodes
|
|
5810
6000
|
|
|
5811
6001
|
|
|
5812
|
-
constructor() {;_class3.prototype.
|
|
6002
|
+
constructor() {;_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);
|
|
5813
6003
|
this.IN = this.createInputNode();
|
|
5814
6004
|
this.OUT = this.createOutputNode();
|
|
5815
6005
|
}
|
|
@@ -5861,7 +6051,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
5861
6051
|
};
|
|
5862
6052
|
}
|
|
5863
6053
|
resolveNode(node) {
|
|
5864
|
-
if (node instanceof
|
|
6054
|
+
if (node instanceof _chunkB6ZQIAK3js.Prompt) {
|
|
5865
6055
|
const cached = this.nodeLikeNodes.get(node);
|
|
5866
6056
|
if (cached) {
|
|
5867
6057
|
return [cached, []];
|
|
@@ -5911,7 +6101,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
5911
6101
|
// }
|
|
5912
6102
|
// Helper to generate node IDs
|
|
5913
6103
|
generateId(name) {
|
|
5914
|
-
const uuid =
|
|
6104
|
+
const uuid = _chunkB6ZQIAK3js.newId.call(void 0, );
|
|
5915
6105
|
if (name) {
|
|
5916
6106
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
5917
6107
|
} else {
|
|
@@ -5948,12 +6138,12 @@ function proxyVariableToNode(proxy) {
|
|
|
5948
6138
|
return [proxy.__node, proxy.__path];
|
|
5949
6139
|
}
|
|
5950
6140
|
var BaseNode = (_class4 = class {
|
|
5951
|
-
constructor(graph, id) {;_class4.prototype.
|
|
6141
|
+
constructor(graph, id) {;_class4.prototype.__init9.call(this);_class4.prototype.__init10.call(this);
|
|
5952
6142
|
this.graph = graph;
|
|
5953
6143
|
this.id = id;
|
|
5954
6144
|
}
|
|
5955
|
-
|
|
5956
|
-
|
|
6145
|
+
__init9() {this.__type = "node"}
|
|
6146
|
+
__init10() {this.dependencies = []}
|
|
5957
6147
|
addDependency(dependency) {
|
|
5958
6148
|
this.dependencies.push(dependency);
|
|
5959
6149
|
}
|
|
@@ -7105,7 +7295,7 @@ function waterfall(tasks, callback) {
|
|
|
7105
7295
|
var waterfall$1 = awaitify(waterfall);
|
|
7106
7296
|
|
|
7107
7297
|
// src/trace.ts
|
|
7108
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
7298
|
+
var SpanFetcher = class _SpanFetcher extends _chunkB6ZQIAK3js.ObjectFetcher {
|
|
7109
7299
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
7110
7300
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
7111
7301
|
rootSpanId,
|
|
@@ -7171,10 +7361,10 @@ var SpanFetcher = class _SpanFetcher extends _chunkMWVVR5LRjs.ObjectFetcher {
|
|
|
7171
7361
|
}
|
|
7172
7362
|
};
|
|
7173
7363
|
var CachedSpanFetcher = (_class5 = class {
|
|
7174
|
-
|
|
7175
|
-
|
|
7364
|
+
__init11() {this.spanCache = /* @__PURE__ */ new Map()}
|
|
7365
|
+
__init12() {this.allFetched = false}
|
|
7176
7366
|
|
|
7177
|
-
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;_class5.prototype.
|
|
7367
|
+
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);
|
|
7178
7368
|
if (typeof objectTypeOrFetchFn === "function") {
|
|
7179
7369
|
this.fetchFn = (spanType) => objectTypeOrFetchFn(spanType);
|
|
7180
7370
|
} else {
|
|
@@ -7238,7 +7428,7 @@ var CachedSpanFetcher = (_class5 = class {
|
|
|
7238
7428
|
async fetchSpans(spanType) {
|
|
7239
7429
|
const spans = await this.fetchFn(spanType, false);
|
|
7240
7430
|
for (const span of spans) {
|
|
7241
|
-
const type = _nullishCoalesce(_optionalChain([span, 'access',
|
|
7431
|
+
const type = _nullishCoalesce(_optionalChain([span, 'access', _131 => _131.span_attributes, 'optionalAccess', _132 => _132.type]), () => ( ""));
|
|
7242
7432
|
const existing = _nullishCoalesce(this.spanCache.get(type), () => ( []));
|
|
7243
7433
|
existing.push(span);
|
|
7244
7434
|
this.spanCache.set(type, existing);
|
|
@@ -7262,17 +7452,17 @@ var LocalTrace = (_class6 = class {
|
|
|
7262
7452
|
|
|
7263
7453
|
|
|
7264
7454
|
|
|
7265
|
-
|
|
7266
|
-
|
|
7455
|
+
__init13() {this.spansFlushed = false}
|
|
7456
|
+
__init14() {this.spansFlushPromise = null}
|
|
7267
7457
|
|
|
7268
|
-
|
|
7458
|
+
__init15() {this.threadCache = /* @__PURE__ */ new Map()}
|
|
7269
7459
|
constructor({
|
|
7270
7460
|
objectType,
|
|
7271
7461
|
objectId,
|
|
7272
7462
|
rootSpanId,
|
|
7273
7463
|
ensureSpansFlushed,
|
|
7274
7464
|
state
|
|
7275
|
-
}) {;_class6.prototype.
|
|
7465
|
+
}) {;_class6.prototype.__init13.call(this);_class6.prototype.__init14.call(this);_class6.prototype.__init15.call(this);
|
|
7276
7466
|
this.objectType = objectType;
|
|
7277
7467
|
this.objectId = objectId;
|
|
7278
7468
|
this.rootSpanId = rootSpanId;
|
|
@@ -7321,11 +7511,11 @@ var LocalTrace = (_class6 = class {
|
|
|
7321
7511
|
const cachedSpans = this.state.spanCache.getByRootSpanId(this.rootSpanId);
|
|
7322
7512
|
if (cachedSpans && cachedSpans.length > 0) {
|
|
7323
7513
|
let spans = includeScorers ? cachedSpans : cachedSpans.filter(
|
|
7324
|
-
(span) => _optionalChain([span, 'access',
|
|
7514
|
+
(span) => _optionalChain([span, 'access', _133 => _133.span_attributes, 'optionalAccess', _134 => _134.purpose]) !== "scorer"
|
|
7325
7515
|
);
|
|
7326
7516
|
if (spanType && spanType.length > 0) {
|
|
7327
7517
|
spans = spans.filter(
|
|
7328
|
-
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access',
|
|
7518
|
+
(span) => spanType.includes(_nullishCoalesce(_optionalChain([span, 'access', _135 => _135.span_attributes, 'optionalAccess', _136 => _136.type]), () => ( "")))
|
|
7329
7519
|
);
|
|
7330
7520
|
}
|
|
7331
7521
|
return spans.map((span) => ({
|
|
@@ -7350,7 +7540,7 @@ var LocalTrace = (_class6 = class {
|
|
|
7350
7540
|
* Calls the API with the project_default preprocessor (which falls back to "thread").
|
|
7351
7541
|
*/
|
|
7352
7542
|
async getThread(options) {
|
|
7353
|
-
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7543
|
+
const cacheKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _137 => _137.preprocessor]), () => ( "project_default"));
|
|
7354
7544
|
if (!this.threadCache.has(cacheKey)) {
|
|
7355
7545
|
const promise = this.fetchThread(options);
|
|
7356
7546
|
this.threadCache.set(cacheKey, promise);
|
|
@@ -7361,7 +7551,7 @@ var LocalTrace = (_class6 = class {
|
|
|
7361
7551
|
await this.ensureSpansReady();
|
|
7362
7552
|
await this.state.login({});
|
|
7363
7553
|
const result = await invoke({
|
|
7364
|
-
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7554
|
+
globalFunction: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _138 => _138.preprocessor]), () => ( "project_default")),
|
|
7365
7555
|
functionType: "preprocessor",
|
|
7366
7556
|
input: {
|
|
7367
7557
|
trace_ref: {
|
|
@@ -7418,20 +7608,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
7418
7608
|
prompt: _v3.z.string()
|
|
7419
7609
|
}),
|
|
7420
7610
|
_v3.z.object({
|
|
7421
|
-
messages: _v3.z.array(
|
|
7611
|
+
messages: _v3.z.array(_chunkB6ZQIAK3js.ChatCompletionMessageParam)
|
|
7422
7612
|
})
|
|
7423
7613
|
]);
|
|
7424
7614
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
7425
7615
|
_v3.z.object({
|
|
7426
7616
|
model: _v3.z.string(),
|
|
7427
|
-
params:
|
|
7617
|
+
params: _chunkB6ZQIAK3js.ModelParams.optional(),
|
|
7428
7618
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
7429
7619
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
7430
7620
|
})
|
|
7431
7621
|
);
|
|
7432
7622
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
7433
7623
|
_v3.z.object({
|
|
7434
|
-
tools: _v3.z.array(
|
|
7624
|
+
tools: _v3.z.array(_chunkB6ZQIAK3js.ToolFunctionDefinition).optional()
|
|
7435
7625
|
})
|
|
7436
7626
|
);
|
|
7437
7627
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -7479,7 +7669,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
7479
7669
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
7480
7670
|
return parameters;
|
|
7481
7671
|
}
|
|
7482
|
-
if (
|
|
7672
|
+
if (_chunkB6ZQIAK3js.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
7483
7673
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
7484
7674
|
...resolvedSchema.data,
|
|
7485
7675
|
...parameters
|
|
@@ -7501,14 +7691,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
7501
7691
|
const value = parameters[name];
|
|
7502
7692
|
try {
|
|
7503
7693
|
if ("type" in schema && schema.type === "prompt") {
|
|
7504
|
-
const promptData = value ?
|
|
7694
|
+
const promptData = value ? _chunkB6ZQIAK3js.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
7505
7695
|
schema.default,
|
|
7506
7696
|
schema.default.tools
|
|
7507
7697
|
) : void 0;
|
|
7508
7698
|
if (!promptData) {
|
|
7509
7699
|
throw new Error(`Parameter '${name}' is required`);
|
|
7510
7700
|
}
|
|
7511
|
-
return [name,
|
|
7701
|
+
return [name, _chunkB6ZQIAK3js.Prompt.fromPromptData(name, promptData)];
|
|
7512
7702
|
} else if ("type" in schema && schema.type === "model") {
|
|
7513
7703
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
7514
7704
|
if (model === void 0) {
|
|
@@ -7537,10 +7727,10 @@ function validateParametersWithJsonSchema(parameters, schema) {
|
|
|
7537
7727
|
const ajv = new (0, _ajv2.default)({ coerceTypes: true, useDefaults: true, strict: false });
|
|
7538
7728
|
const validate = ajv.compile(schema);
|
|
7539
7729
|
if (!validate(parameters)) {
|
|
7540
|
-
const errorMessages = _optionalChain([validate, 'access',
|
|
7730
|
+
const errorMessages = _optionalChain([validate, 'access', _139 => _139.errors, 'optionalAccess', _140 => _140.map, 'call', _141 => _141((err) => {
|
|
7541
7731
|
const path = err.instancePath || "root";
|
|
7542
7732
|
return `${path}: ${err.message}`;
|
|
7543
|
-
}), 'access',
|
|
7733
|
+
}), 'access', _142 => _142.join, 'call', _143 => _143(", ")]);
|
|
7544
7734
|
throw Error(`Invalid parameters: ${errorMessages}`);
|
|
7545
7735
|
}
|
|
7546
7736
|
return rehydrateRemoteParameters(parameters, schema);
|
|
@@ -7559,7 +7749,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
7559
7749
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
7560
7750
|
return [
|
|
7561
7751
|
name,
|
|
7562
|
-
|
|
7752
|
+
_chunkB6ZQIAK3js.Prompt.fromPromptData(name, _chunkB6ZQIAK3js.PromptData.parse(value))
|
|
7563
7753
|
];
|
|
7564
7754
|
}
|
|
7565
7755
|
return [name, value];
|
|
@@ -7607,7 +7797,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
7607
7797
|
return out;
|
|
7608
7798
|
}
|
|
7609
7799
|
function initExperiment2(state, options = {}) {
|
|
7610
|
-
return
|
|
7800
|
+
return _chunkB6ZQIAK3js.init.call(void 0, {
|
|
7611
7801
|
state,
|
|
7612
7802
|
...options,
|
|
7613
7803
|
setCurrent: false
|
|
@@ -7618,7 +7808,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
7618
7808
|
return void 0;
|
|
7619
7809
|
}
|
|
7620
7810
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
7621
|
-
if (!
|
|
7811
|
+
if (!_chunkB6ZQIAK3js.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
7622
7812
|
return void 0;
|
|
7623
7813
|
}
|
|
7624
7814
|
if (resolvedParameters.id === void 0) {
|
|
@@ -7654,10 +7844,10 @@ globalThis._evals = {
|
|
|
7654
7844
|
reporters: {}
|
|
7655
7845
|
};
|
|
7656
7846
|
function _initializeSpanContext() {
|
|
7657
|
-
globalThis._spanContext = { currentSpan:
|
|
7847
|
+
globalThis._spanContext = { currentSpan: _chunkB6ZQIAK3js.currentSpan, withCurrent: _chunkB6ZQIAK3js.withCurrent, startSpan: _chunkB6ZQIAK3js.startSpan, NOOP_SPAN: _chunkB6ZQIAK3js.NOOP_SPAN };
|
|
7658
7848
|
}
|
|
7659
7849
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
7660
|
-
const options =
|
|
7850
|
+
const options = _chunkB6ZQIAK3js.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
7661
7851
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
7662
7852
|
if (globalThis._evals.evaluators[evalName]) {
|
|
7663
7853
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -7708,7 +7898,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
7708
7898
|
baseExperimentId: evaluator.baseExperimentId,
|
|
7709
7899
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
7710
7900
|
repoInfo: evaluator.repoInfo,
|
|
7711
|
-
dataset:
|
|
7901
|
+
dataset: _chunkB6ZQIAK3js.Dataset.isDataset(data) ? data : void 0,
|
|
7712
7902
|
parameters
|
|
7713
7903
|
});
|
|
7714
7904
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
@@ -7728,7 +7918,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
7728
7918
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
7729
7919
|
let ret;
|
|
7730
7920
|
if (options.parent) {
|
|
7731
|
-
ret = await
|
|
7921
|
+
ret = await _chunkB6ZQIAK3js.withParent.call(void 0,
|
|
7732
7922
|
options.parent,
|
|
7733
7923
|
() => runEvaluator(
|
|
7734
7924
|
null,
|
|
@@ -7764,7 +7954,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
7764
7954
|
if (experiment) {
|
|
7765
7955
|
await experiment.flush().catch(console.error);
|
|
7766
7956
|
} else if (options.parent) {
|
|
7767
|
-
await
|
|
7957
|
+
await _chunkB6ZQIAK3js.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
7768
7958
|
}
|
|
7769
7959
|
}
|
|
7770
7960
|
} finally {
|
|
@@ -7810,13 +8000,13 @@ function classifierName(classifier, classifier_idx) {
|
|
|
7810
8000
|
}
|
|
7811
8001
|
function buildSpanMetadata(results) {
|
|
7812
8002
|
return results.length === 1 ? results[0].metadata : results.reduce(
|
|
7813
|
-
(prev, s) =>
|
|
8003
|
+
(prev, s) => _chunkB6ZQIAK3js.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
|
|
7814
8004
|
{}
|
|
7815
8005
|
);
|
|
7816
8006
|
}
|
|
7817
8007
|
function buildSpanScores(results) {
|
|
7818
8008
|
const scoresRecord = results.reduce(
|
|
7819
|
-
(prev, s) =>
|
|
8009
|
+
(prev, s) => _chunkB6ZQIAK3js.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
|
|
7820
8010
|
{}
|
|
7821
8011
|
);
|
|
7822
8012
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
@@ -7846,7 +8036,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
7846
8036
|
return failing;
|
|
7847
8037
|
}
|
|
7848
8038
|
function validateClassificationResult(value, scorerName2) {
|
|
7849
|
-
if (!(typeof value === "object" && value !== null && !
|
|
8039
|
+
if (!(typeof value === "object" && value !== null && !_chunkB6ZQIAK3js.isEmpty.call(void 0, value))) {
|
|
7850
8040
|
throw new Error(
|
|
7851
8041
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
7852
8042
|
);
|
|
@@ -7875,7 +8065,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
7875
8065
|
);
|
|
7876
8066
|
metadata[`${kind}_errors`] = errorMap;
|
|
7877
8067
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
7878
|
-
|
|
8068
|
+
_chunkB6ZQIAK3js.debugLogger.forState(state).warn(
|
|
7879
8069
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
7880
8070
|
failures.map((f) => f.error)
|
|
7881
8071
|
);
|
|
@@ -7909,7 +8099,7 @@ var defaultErrorScoreHandler = ({
|
|
|
7909
8099
|
};
|
|
7910
8100
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
7911
8101
|
if (enableCache) {
|
|
7912
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
8102
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkB6ZQIAK3js._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _144 => _144.spanCache, 'optionalAccess', _145 => _145.start, 'call', _146 => _146()]);
|
|
7913
8103
|
}
|
|
7914
8104
|
try {
|
|
7915
8105
|
if (typeof evaluator.data === "string") {
|
|
@@ -7930,7 +8120,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7930
8120
|
);
|
|
7931
8121
|
}
|
|
7932
8122
|
let name = dataResult.name;
|
|
7933
|
-
if (
|
|
8123
|
+
if (_chunkB6ZQIAK3js.isEmpty.call(void 0, name)) {
|
|
7934
8124
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
7935
8125
|
if (!baseExperiment) {
|
|
7936
8126
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -7980,7 +8170,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7980
8170
|
if (cancelled) {
|
|
7981
8171
|
return;
|
|
7982
8172
|
}
|
|
7983
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
8173
|
+
const eventDataset = experiment ? experiment.dataset : _chunkB6ZQIAK3js.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
7984
8174
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
7985
8175
|
object_type: "dataset",
|
|
7986
8176
|
object_id: await eventDataset.id,
|
|
@@ -7988,8 +8178,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7988
8178
|
created: datum.created,
|
|
7989
8179
|
_xact_id: datum._xact_id
|
|
7990
8180
|
} : void 0;
|
|
7991
|
-
const parsedDatumOrigin =
|
|
7992
|
-
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess',
|
|
8181
|
+
const parsedDatumOrigin = _chunkB6ZQIAK3js.ObjectReference.safeParse(datum.origin);
|
|
8182
|
+
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _147 => _147.success]) ? parsedDatumOrigin.data : void 0)));
|
|
7993
8183
|
const baseEvent = {
|
|
7994
8184
|
name: "eval",
|
|
7995
8185
|
spanAttributes: {
|
|
@@ -8004,26 +8194,26 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8004
8194
|
}
|
|
8005
8195
|
};
|
|
8006
8196
|
const callback = async (rootSpan) => {
|
|
8007
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
8197
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkB6ZQIAK3js._internalGetGlobalState.call(void 0, )));
|
|
8008
8198
|
const ensureSpansFlushed = async () => {
|
|
8009
8199
|
if (experiment) {
|
|
8010
|
-
await
|
|
8200
|
+
await _chunkB6ZQIAK3js.flush.call(void 0, { state: experiment.loggingState });
|
|
8011
8201
|
} else if (state) {
|
|
8012
|
-
await
|
|
8202
|
+
await _chunkB6ZQIAK3js.flush.call(void 0, { state });
|
|
8013
8203
|
} else {
|
|
8014
|
-
await
|
|
8204
|
+
await _chunkB6ZQIAK3js.flush.call(void 0, );
|
|
8015
8205
|
}
|
|
8016
8206
|
if (state) {
|
|
8017
8207
|
await state.flushOtel();
|
|
8018
8208
|
}
|
|
8019
8209
|
};
|
|
8020
8210
|
const parentStr = state.currentParent.getStore();
|
|
8021
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
8211
|
+
const parentComponents = typeof parentStr === "string" ? _chunkB6ZQIAK3js.SpanComponentsV4.fromStr(parentStr) : null;
|
|
8022
8212
|
const trace = state ? new LocalTrace({
|
|
8023
|
-
objectType: parentComponents ?
|
|
8213
|
+
objectType: parentComponents ? _chunkB6ZQIAK3js.spanObjectTypeV3ToTypedString.call(void 0,
|
|
8024
8214
|
parentComponents.data.object_type
|
|
8025
8215
|
) : "experiment",
|
|
8026
|
-
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 () => ( "")) : ""))),
|
|
8027
8217
|
rootSpanId: rootSpan.rootSpanId,
|
|
8028
8218
|
ensureSpansFlushed,
|
|
8029
8219
|
state
|
|
@@ -8053,10 +8243,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8053
8243
|
span,
|
|
8054
8244
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
8055
8245
|
reportProgress: (event) => {
|
|
8056
|
-
_optionalChain([stream, 'optionalCall',
|
|
8246
|
+
_optionalChain([stream, 'optionalCall', _150 => _150({
|
|
8057
8247
|
...event,
|
|
8058
8248
|
id: rootSpan.id,
|
|
8059
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8249
|
+
origin: _optionalChain([baseEvent, 'access', _151 => _151.event, 'optionalAccess', _152 => _152.origin]),
|
|
8060
8250
|
name: evaluator.evalName,
|
|
8061
8251
|
object_type: "task"
|
|
8062
8252
|
})]);
|
|
@@ -8095,7 +8285,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8095
8285
|
trace
|
|
8096
8286
|
};
|
|
8097
8287
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
8098
|
-
const propagatedEvent =
|
|
8288
|
+
const propagatedEvent = _chunkB6ZQIAK3js.makeScorerPropagatedEvent.call(void 0,
|
|
8099
8289
|
await rootSpan.export()
|
|
8100
8290
|
);
|
|
8101
8291
|
const getOtherFields = (s) => {
|
|
@@ -8118,14 +8308,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8118
8308
|
if (scoreValue === null) return null;
|
|
8119
8309
|
if (Array.isArray(scoreValue)) {
|
|
8120
8310
|
for (const s of scoreValue) {
|
|
8121
|
-
if (!(typeof s === "object" && !
|
|
8311
|
+
if (!(typeof s === "object" && !_chunkB6ZQIAK3js.isEmpty.call(void 0, s))) {
|
|
8122
8312
|
throw new Error(
|
|
8123
8313
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
8124
8314
|
);
|
|
8125
8315
|
}
|
|
8126
8316
|
}
|
|
8127
8317
|
}
|
|
8128
|
-
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !
|
|
8318
|
+
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkB6ZQIAK3js.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
|
|
8129
8319
|
{
|
|
8130
8320
|
name: scorerNames[score_idx],
|
|
8131
8321
|
score: scoreValue
|
|
@@ -8133,7 +8323,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8133
8323
|
];
|
|
8134
8324
|
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
8135
8325
|
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
8136
|
-
(prev, s) =>
|
|
8326
|
+
(prev, s) => _chunkB6ZQIAK3js.mergeDicts.call(void 0, prev, {
|
|
8137
8327
|
[s.name]: getOtherFields(s)
|
|
8138
8328
|
}),
|
|
8139
8329
|
{}
|
|
@@ -8168,7 +8358,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8168
8358
|
)
|
|
8169
8359
|
);
|
|
8170
8360
|
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
8171
|
-
(prev, r) =>
|
|
8361
|
+
(prev, r) => _chunkB6ZQIAK3js.mergeDicts.call(void 0, prev, {
|
|
8172
8362
|
[r.name]: toClassificationItem(r)
|
|
8173
8363
|
}),
|
|
8174
8364
|
{}
|
|
@@ -8220,7 +8410,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8220
8410
|
evaluator.state
|
|
8221
8411
|
);
|
|
8222
8412
|
} catch (e) {
|
|
8223
|
-
|
|
8413
|
+
_chunkB6ZQIAK3js.logError.call(void 0, rootSpan, e);
|
|
8224
8414
|
error = e;
|
|
8225
8415
|
} finally {
|
|
8226
8416
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -8244,7 +8434,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8244
8434
|
tags: tags.length ? tags : void 0,
|
|
8245
8435
|
metadata,
|
|
8246
8436
|
error,
|
|
8247
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8437
|
+
origin: _optionalChain([baseEvent, 'access', _153 => _153.event, 'optionalAccess', _154 => _154.origin])
|
|
8248
8438
|
};
|
|
8249
8439
|
collectedResults.push({
|
|
8250
8440
|
...baseResult,
|
|
@@ -8254,7 +8444,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8254
8444
|
}
|
|
8255
8445
|
};
|
|
8256
8446
|
if (!experiment) {
|
|
8257
|
-
return await
|
|
8447
|
+
return await _chunkB6ZQIAK3js.traced.call(void 0, callback, {
|
|
8258
8448
|
...baseEvent,
|
|
8259
8449
|
state: evaluator.state
|
|
8260
8450
|
});
|
|
@@ -8284,7 +8474,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8284
8474
|
break;
|
|
8285
8475
|
}
|
|
8286
8476
|
scheduledTrials++;
|
|
8287
|
-
_optionalChain([progressReporter, 'access',
|
|
8477
|
+
_optionalChain([progressReporter, 'access', _155 => _155.setTotal, 'optionalCall', _156 => _156(evaluator.evalName, scheduledTrials)]);
|
|
8288
8478
|
q.pushAsync({ datum, trialIndex }).catch((e) => {
|
|
8289
8479
|
if (queueErrors.length < 5) {
|
|
8290
8480
|
queueErrors.push(e);
|
|
@@ -8296,7 +8486,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8296
8486
|
const cancel = async () => {
|
|
8297
8487
|
await new Promise((_, reject2) => {
|
|
8298
8488
|
if (cancelled) {
|
|
8299
|
-
reject2(new (0,
|
|
8489
|
+
reject2(new (0, _chunkB6ZQIAK3js.InternalAbortError)("Evaluator already cancelled"));
|
|
8300
8490
|
return;
|
|
8301
8491
|
}
|
|
8302
8492
|
let timeoutId;
|
|
@@ -8317,12 +8507,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8317
8507
|
};
|
|
8318
8508
|
if (evaluator.timeout) {
|
|
8319
8509
|
timeoutId = setTimeout(() => {
|
|
8320
|
-
rejectOnce(new (0,
|
|
8510
|
+
rejectOnce(new (0, _chunkB6ZQIAK3js.InternalAbortError)("Evaluator timed out"));
|
|
8321
8511
|
}, evaluator.timeout);
|
|
8322
8512
|
}
|
|
8323
8513
|
if (evaluator.signal) {
|
|
8324
8514
|
abortHandler = () => {
|
|
8325
|
-
rejectOnce(new (0,
|
|
8515
|
+
rejectOnce(new (0, _chunkB6ZQIAK3js.InternalAbortError)("Evaluator aborted"));
|
|
8326
8516
|
};
|
|
8327
8517
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
8328
8518
|
}
|
|
@@ -8345,9 +8535,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8345
8535
|
}
|
|
8346
8536
|
} catch (e) {
|
|
8347
8537
|
q.kill();
|
|
8348
|
-
if (e instanceof
|
|
8349
|
-
if (
|
|
8350
|
-
|
|
8538
|
+
if (e instanceof _chunkB6ZQIAK3js.InternalAbortError) {
|
|
8539
|
+
if (_chunkCDIKAHDZjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
8540
|
+
_chunkB6ZQIAK3js.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
8351
8541
|
}
|
|
8352
8542
|
}
|
|
8353
8543
|
throw e;
|
|
@@ -8371,9 +8561,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8371
8561
|
);
|
|
8372
8562
|
} finally {
|
|
8373
8563
|
if (enableCache) {
|
|
8374
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
8375
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
8376
|
-
_optionalChain([spanCache, 'optionalAccess',
|
|
8564
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkB6ZQIAK3js._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()]);
|
|
8377
8567
|
}
|
|
8378
8568
|
}
|
|
8379
8569
|
}
|
|
@@ -8466,25 +8656,25 @@ var defaultReporter = {
|
|
|
8466
8656
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
8467
8657
|
}
|
|
8468
8658
|
if (jsonl) {
|
|
8469
|
-
|
|
8659
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
8470
8660
|
} else {
|
|
8471
|
-
|
|
8472
|
-
|
|
8661
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("Experiment summary");
|
|
8662
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("==================");
|
|
8473
8663
|
if (summary.comparisonExperimentName) {
|
|
8474
|
-
|
|
8664
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
8475
8665
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
8476
8666
|
);
|
|
8477
|
-
|
|
8667
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("");
|
|
8478
8668
|
}
|
|
8479
8669
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
8480
8670
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
8481
8671
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
8482
8672
|
if (hasScores || hasMetrics) {
|
|
8483
8673
|
if (hasComparison) {
|
|
8484
|
-
|
|
8674
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
8485
8675
|
"Name Value Change Improvements Regressions"
|
|
8486
8676
|
);
|
|
8487
|
-
|
|
8677
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
8488
8678
|
"----------------------------------------------------------------"
|
|
8489
8679
|
);
|
|
8490
8680
|
}
|
|
@@ -8493,18 +8683,18 @@ var defaultReporter = {
|
|
|
8493
8683
|
const scoreValue = `${scorePercent}%`;
|
|
8494
8684
|
if (hasComparison) {
|
|
8495
8685
|
let diffString = "-";
|
|
8496
|
-
if (!
|
|
8686
|
+
if (!_chunkB6ZQIAK3js.isEmpty.call(void 0, score.diff)) {
|
|
8497
8687
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
8498
8688
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
8499
8689
|
diffString = `${diffSign}${diffPercent}%`;
|
|
8500
8690
|
}
|
|
8501
8691
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
8502
8692
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
8503
|
-
|
|
8693
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
8504
8694
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
8505
8695
|
);
|
|
8506
8696
|
} else {
|
|
8507
|
-
|
|
8697
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
8508
8698
|
}
|
|
8509
8699
|
}
|
|
8510
8700
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -8513,30 +8703,30 @@ var defaultReporter = {
|
|
|
8513
8703
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
8514
8704
|
if (hasComparison) {
|
|
8515
8705
|
let diffString = "-";
|
|
8516
|
-
if (!
|
|
8706
|
+
if (!_chunkB6ZQIAK3js.isEmpty.call(void 0, metric.diff)) {
|
|
8517
8707
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
8518
8708
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
8519
8709
|
diffString = `${diffSign}${diffPercent}%`;
|
|
8520
8710
|
}
|
|
8521
8711
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
8522
8712
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
8523
|
-
|
|
8713
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
8524
8714
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
8525
8715
|
);
|
|
8526
8716
|
} else {
|
|
8527
|
-
|
|
8717
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln(
|
|
8528
8718
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
8529
8719
|
);
|
|
8530
8720
|
}
|
|
8531
8721
|
}
|
|
8532
8722
|
}
|
|
8533
8723
|
if (summary.experimentUrl) {
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
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}`);
|
|
8537
8727
|
}
|
|
8538
8728
|
}
|
|
8539
|
-
|
|
8729
|
+
_chunkCDIKAHDZjs.isomorph_default.writeln("");
|
|
8540
8730
|
return failingResults.length === 0;
|
|
8541
8731
|
},
|
|
8542
8732
|
async reportRun(evalReports) {
|
|
@@ -8556,7 +8746,7 @@ function agentAssertionScorer(callback, options = {}) {
|
|
|
8556
8746
|
});
|
|
8557
8747
|
const resources = {};
|
|
8558
8748
|
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
8559
|
-
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"] })]);
|
|
8560
8750
|
}
|
|
8561
8751
|
const results = await Promise.all(
|
|
8562
8752
|
assertions.map(async (assertion) => {
|
|
@@ -8714,7 +8904,7 @@ async function validateSchema(schema, value) {
|
|
|
8714
8904
|
}
|
|
8715
8905
|
}
|
|
8716
8906
|
function toolCalls(spans) {
|
|
8717
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
8907
|
+
return spans.filter((span) => _optionalChain([span, 'access', _165 => _165.span_attributes, 'optionalAccess', _166 => _166.type]) === "tool");
|
|
8718
8908
|
}
|
|
8719
8909
|
function matchingToolCalls(spans, toolName, options) {
|
|
8720
8910
|
return toolCalls(spans).filter((span) => {
|
|
@@ -8732,17 +8922,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
8732
8922
|
});
|
|
8733
8923
|
}
|
|
8734
8924
|
function getToolName(span) {
|
|
8735
|
-
const spanName = [_optionalChain([span, 'access',
|
|
8736
|
-
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("/")])) {
|
|
8737
8927
|
return spanName;
|
|
8738
8928
|
}
|
|
8739
8929
|
const metadataName = [
|
|
8740
|
-
_optionalChain([span, 'access',
|
|
8741
|
-
_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"]])
|
|
8742
8932
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
8743
8933
|
const mcpServer = [
|
|
8744
|
-
_optionalChain([span, 'access',
|
|
8745
|
-
_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"]])
|
|
8746
8936
|
].find((value) => typeof value === "string" && value !== "");
|
|
8747
8937
|
if (metadataName && mcpServer) {
|
|
8748
8938
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -8933,10 +9123,10 @@ var Project2 = (_class7 = class {
|
|
|
8933
9123
|
|
|
8934
9124
|
|
|
8935
9125
|
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
constructor(args) {;_class7.prototype.
|
|
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);
|
|
8940
9130
|
_initializeSpanContext();
|
|
8941
9131
|
this.name = "name" in args ? args.name : void 0;
|
|
8942
9132
|
this.id = "id" in args ? args.id : void 0;
|
|
@@ -8971,7 +9161,7 @@ var Project2 = (_class7 = class {
|
|
|
8971
9161
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
8972
9162
|
return;
|
|
8973
9163
|
}
|
|
8974
|
-
await
|
|
9164
|
+
await _chunkB6ZQIAK3js.login.call(void 0, );
|
|
8975
9165
|
const projectMap = new ProjectNameIdMap();
|
|
8976
9166
|
const functionDefinitions = [];
|
|
8977
9167
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -8985,16 +9175,16 @@ var Project2 = (_class7 = class {
|
|
|
8985
9175
|
functionDefinitions.push(functionDefinition);
|
|
8986
9176
|
}
|
|
8987
9177
|
}
|
|
8988
|
-
await
|
|
9178
|
+
await _chunkB6ZQIAK3js._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
8989
9179
|
functions: functionDefinitions
|
|
8990
9180
|
});
|
|
8991
9181
|
}
|
|
8992
9182
|
}, _class7);
|
|
8993
9183
|
var ToolBuilder = (_class8 = class {
|
|
8994
|
-
constructor(project) {;_class8.prototype.
|
|
9184
|
+
constructor(project) {;_class8.prototype.__init19.call(this);
|
|
8995
9185
|
this.project = project;
|
|
8996
9186
|
}
|
|
8997
|
-
|
|
9187
|
+
__init19() {this.taskCounter = 0}
|
|
8998
9188
|
// This type definition is just a catch all so that the implementation can be
|
|
8999
9189
|
// less specific than the two more specific declarations above.
|
|
9000
9190
|
create(opts) {
|
|
@@ -9003,12 +9193,12 @@ var ToolBuilder = (_class8 = class {
|
|
|
9003
9193
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
9004
9194
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
9005
9195
|
if (resolvedName.trim().length === 0) {
|
|
9006
|
-
resolvedName = `Tool ${
|
|
9196
|
+
resolvedName = `Tool ${_chunkCDIKAHDZjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9007
9197
|
}
|
|
9008
9198
|
const tool = new CodeFunction(this.project, {
|
|
9009
9199
|
handler,
|
|
9010
9200
|
name: resolvedName,
|
|
9011
|
-
slug: _nullishCoalesce(slug, () => (
|
|
9201
|
+
slug: _nullishCoalesce(slug, () => ( _chunkB6ZQIAK3js.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
9012
9202
|
type: "tool",
|
|
9013
9203
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
9014
9204
|
parameters,
|
|
@@ -9021,10 +9211,10 @@ var ToolBuilder = (_class8 = class {
|
|
|
9021
9211
|
}
|
|
9022
9212
|
}, _class8);
|
|
9023
9213
|
var ScorerBuilder = (_class9 = class {
|
|
9024
|
-
constructor(project) {;_class9.prototype.
|
|
9214
|
+
constructor(project) {;_class9.prototype.__init20.call(this);
|
|
9025
9215
|
this.project = project;
|
|
9026
9216
|
}
|
|
9027
|
-
|
|
9217
|
+
__init20() {this.taskCounter = 0}
|
|
9028
9218
|
create(opts) {
|
|
9029
9219
|
this.taskCounter++;
|
|
9030
9220
|
let resolvedName = opts.name;
|
|
@@ -9032,9 +9222,9 @@ var ScorerBuilder = (_class9 = class {
|
|
|
9032
9222
|
resolvedName = opts.handler.name;
|
|
9033
9223
|
}
|
|
9034
9224
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
9035
|
-
resolvedName = `Scorer ${
|
|
9225
|
+
resolvedName = `Scorer ${_chunkCDIKAHDZjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9036
9226
|
}
|
|
9037
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9227
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkB6ZQIAK3js.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
9038
9228
|
if ("handler" in opts) {
|
|
9039
9229
|
const scorer = new CodeFunction(this.project, {
|
|
9040
9230
|
...opts,
|
|
@@ -9080,17 +9270,17 @@ var ScorerBuilder = (_class9 = class {
|
|
|
9080
9270
|
}
|
|
9081
9271
|
}, _class9);
|
|
9082
9272
|
var ClassifierBuilder = (_class10 = class {
|
|
9083
|
-
constructor(project) {;_class10.prototype.
|
|
9273
|
+
constructor(project) {;_class10.prototype.__init21.call(this);
|
|
9084
9274
|
this.project = project;
|
|
9085
9275
|
}
|
|
9086
|
-
|
|
9276
|
+
__init21() {this.taskCounter = 0}
|
|
9087
9277
|
create(opts) {
|
|
9088
9278
|
this.taskCounter++;
|
|
9089
9279
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
9090
9280
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
9091
|
-
resolvedName = `Classifier ${
|
|
9281
|
+
resolvedName = `Classifier ${_chunkCDIKAHDZjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9092
9282
|
}
|
|
9093
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9283
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkB6ZQIAK3js.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
9094
9284
|
const classifier = new CodeFunction(this.project, {
|
|
9095
9285
|
...opts,
|
|
9096
9286
|
name: resolvedName,
|
|
@@ -9217,18 +9407,18 @@ var PromptBuilder = class {
|
|
|
9217
9407
|
rawTools.push(tool);
|
|
9218
9408
|
}
|
|
9219
9409
|
}
|
|
9220
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9410
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkB6ZQIAK3js.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
9221
9411
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
9222
9412
|
const promptRow = {
|
|
9223
9413
|
id: opts.id,
|
|
9224
|
-
_xact_id: opts.version ?
|
|
9414
|
+
_xact_id: opts.version ? _chunkB6ZQIAK3js.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
9225
9415
|
name: opts.name,
|
|
9226
9416
|
slug,
|
|
9227
9417
|
prompt_data: promptData,
|
|
9228
9418
|
tags: opts.tags,
|
|
9229
9419
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
9230
9420
|
};
|
|
9231
|
-
const prompt = new (0,
|
|
9421
|
+
const prompt = new (0, _chunkB6ZQIAK3js.Prompt)(
|
|
9232
9422
|
promptRow,
|
|
9233
9423
|
{},
|
|
9234
9424
|
// It doesn't make sense to specify defaults here.
|
|
@@ -9282,7 +9472,7 @@ var ParametersBuilder = class {
|
|
|
9282
9472
|
this.project = project;
|
|
9283
9473
|
}
|
|
9284
9474
|
create(opts) {
|
|
9285
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
9475
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkB6ZQIAK3js.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
9286
9476
|
const codeParameters = new CodeParameters(this.project, {
|
|
9287
9477
|
name: opts.name,
|
|
9288
9478
|
slug,
|
|
@@ -9321,7 +9511,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
9321
9511
|
required.push(name);
|
|
9322
9512
|
}
|
|
9323
9513
|
} else {
|
|
9324
|
-
const schemaObj =
|
|
9514
|
+
const schemaObj = _chunkB6ZQIAK3js.zodToJsonSchema.call(void 0, value);
|
|
9325
9515
|
properties[name] = schemaObj;
|
|
9326
9516
|
if (!("default" in schemaObj)) {
|
|
9327
9517
|
required.push(name);
|
|
@@ -9345,16 +9535,16 @@ function getDefaultDataFromParametersSchema(schema) {
|
|
|
9345
9535
|
})
|
|
9346
9536
|
);
|
|
9347
9537
|
}
|
|
9348
|
-
var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.
|
|
9349
|
-
|
|
9350
|
-
|
|
9538
|
+
var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__init22.call(this);_class11.prototype.__init23.call(this); }
|
|
9539
|
+
__init22() {this.nameToId = {}}
|
|
9540
|
+
__init23() {this.idToName = {}}
|
|
9351
9541
|
async getId(projectName) {
|
|
9352
9542
|
if (!(projectName in this.nameToId)) {
|
|
9353
|
-
const response = await
|
|
9543
|
+
const response = await _chunkB6ZQIAK3js._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
9354
9544
|
project_name: projectName
|
|
9355
9545
|
});
|
|
9356
9546
|
const result = _v3.z.object({
|
|
9357
|
-
project:
|
|
9547
|
+
project: _chunkB6ZQIAK3js.Project
|
|
9358
9548
|
}).parse(response);
|
|
9359
9549
|
const projectId = result.project.id;
|
|
9360
9550
|
this.nameToId[projectName] = projectId;
|
|
@@ -9364,10 +9554,10 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
9364
9554
|
}
|
|
9365
9555
|
async getName(projectId) {
|
|
9366
9556
|
if (!(projectId in this.idToName)) {
|
|
9367
|
-
const response = await
|
|
9557
|
+
const response = await _chunkB6ZQIAK3js._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
9368
9558
|
id: projectId
|
|
9369
9559
|
});
|
|
9370
|
-
const result = _v3.z.array(
|
|
9560
|
+
const result = _v3.z.array(_chunkB6ZQIAK3js.Project).nonempty().parse(response);
|
|
9371
9561
|
const projectName = result[0].name;
|
|
9372
9562
|
this.idToName[projectId] = projectName;
|
|
9373
9563
|
this.nameToId[projectName] = projectId;
|
|
@@ -9387,16 +9577,16 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
9387
9577
|
var evalBodySchema = _v3.z.object({
|
|
9388
9578
|
name: _v3.z.string(),
|
|
9389
9579
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
9390
|
-
data:
|
|
9580
|
+
data: _chunkB6ZQIAK3js.RunEval.shape.data,
|
|
9391
9581
|
scores: _v3.z.array(
|
|
9392
9582
|
_v3.z.object({
|
|
9393
|
-
function_id:
|
|
9583
|
+
function_id: _chunkB6ZQIAK3js.FunctionId,
|
|
9394
9584
|
name: _v3.z.string()
|
|
9395
9585
|
})
|
|
9396
9586
|
).nullish(),
|
|
9397
9587
|
experiment_name: _v3.z.string().nullish(),
|
|
9398
9588
|
project_id: _v3.z.string().nullish(),
|
|
9399
|
-
parent:
|
|
9589
|
+
parent: _chunkB6ZQIAK3js.InvokeParent.optional(),
|
|
9400
9590
|
stream: _v3.z.boolean().optional()
|
|
9401
9591
|
});
|
|
9402
9592
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -9404,7 +9594,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
9404
9594
|
_v3.z.union([
|
|
9405
9595
|
_v3.z.object({
|
|
9406
9596
|
type: _v3.z.literal("prompt"),
|
|
9407
|
-
default:
|
|
9597
|
+
default: _chunkB6ZQIAK3js.PromptData.optional(),
|
|
9408
9598
|
description: _v3.z.string().optional()
|
|
9409
9599
|
}),
|
|
9410
9600
|
_v3.z.object({
|
|
@@ -9460,7 +9650,10 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
9460
9650
|
);
|
|
9461
9651
|
|
|
9462
9652
|
// src/node/index.ts
|
|
9463
|
-
|
|
9653
|
+
_chunkB6ZQIAK3js.configureNode.call(void 0, );
|
|
9654
|
+
|
|
9655
|
+
|
|
9656
|
+
|
|
9464
9657
|
|
|
9465
9658
|
|
|
9466
9659
|
|
|
@@ -9628,4 +9821,4 @@ _chunkMWVVR5LRjs.configureNode.call(void 0, );
|
|
|
9628
9821
|
|
|
9629
9822
|
|
|
9630
9823
|
|
|
9631
|
-
exports.Attachment =
|
|
9824
|
+
exports.Attachment = _chunkB6ZQIAK3js.Attachment; exports.AttachmentReference = _chunkB6ZQIAK3js.AttachmentReference; exports.BAGGAGE_HEADER = _chunkB6ZQIAK3js.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkB6ZQIAK3js.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkB6ZQIAK3js.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkB6ZQIAK3js.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkB6ZQIAK3js.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkB6ZQIAK3js.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkB6ZQIAK3js.BraintrustObservabilityExporter; exports.BraintrustState = _chunkB6ZQIAK3js.BraintrustState; exports.BraintrustStream = _chunkB6ZQIAK3js.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkB6ZQIAK3js.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkB6ZQIAK3js.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkB6ZQIAK3js.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkB6ZQIAK3js.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkB6ZQIAK3js.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkB6ZQIAK3js.Experiment; exports.ExternalAttachment = _chunkB6ZQIAK3js.ExternalAttachment; exports.FailedHTTPResponse = _chunkB6ZQIAK3js.FailedHTTPResponse; exports.IDGenerator = _chunkB6ZQIAK3js.IDGenerator; exports.JSONAttachment = _chunkB6ZQIAK3js.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkB6ZQIAK3js.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkB6ZQIAK3js.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkB6ZQIAK3js.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkB6ZQIAK3js.Logger; exports.LoginInvalidOrgError = _chunkB6ZQIAK3js.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkB6ZQIAK3js.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkB6ZQIAK3js.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkB6ZQIAK3js.NoopSpan; exports.OTELIDGenerator = _chunkB6ZQIAK3js.OTELIDGenerator; exports.ObjectFetcher = _chunkB6ZQIAK3js.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkB6ZQIAK3js.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkB6ZQIAK3js.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkB6ZQIAK3js.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkB6ZQIAK3js.SpanImpl; exports.TRACEPARENT_HEADER = _chunkB6ZQIAK3js.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkB6ZQIAK3js.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkB6ZQIAK3js.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkB6ZQIAK3js.UUIDGenerator; exports.X_CACHED_HEADER = _chunkB6ZQIAK3js.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkB6ZQIAK3js._exportsForTestingOnly; exports._internalGetGlobalState = _chunkB6ZQIAK3js._internalGetGlobalState; exports._internalIso = _chunkCDIKAHDZjs.isomorph_default; exports._internalSetInitialState = _chunkB6ZQIAK3js._internalSetInitialState; exports.addAzureBlobHeaders = _chunkB6ZQIAK3js.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkB6ZQIAK3js.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkB6ZQIAK3js.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkB6ZQIAK3js.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkB6ZQIAK3js.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkB6ZQIAK3js.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkB6ZQIAK3js.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkB6ZQIAK3js.createFinalValuePassThroughStream; exports.currentExperiment = _chunkB6ZQIAK3js.currentExperiment; exports.currentLogger = _chunkB6ZQIAK3js.currentLogger; exports.currentSpan = _chunkB6ZQIAK3js.currentSpan; exports.deepCopyEvent = _chunkB6ZQIAK3js.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkB6ZQIAK3js.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkB6ZQIAK3js.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkB6ZQIAK3js.extractTraceContextFromHeaders; exports.flush = _chunkB6ZQIAK3js.flush; exports.getContextManager = _chunkB6ZQIAK3js.getContextManager; exports.getIdGenerator = _chunkB6ZQIAK3js.getIdGenerator; exports.getPromptVersions = _chunkB6ZQIAK3js.getPromptVersions; exports.getSpanParentObject = _chunkB6ZQIAK3js.getSpanParentObject; exports.getTemplateRenderer = _chunkB6ZQIAK3js.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkB6ZQIAK3js.init; exports.initDataset = _chunkB6ZQIAK3js.initDataset; exports.initExperiment = _chunkB6ZQIAK3js.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkB6ZQIAK3js.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkB6ZQIAK3js.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkB6ZQIAK3js.isTemplateFormat; exports.loadParameters = _chunkB6ZQIAK3js.loadParameters; exports.loadPrompt = _chunkB6ZQIAK3js.loadPrompt; exports.log = _chunkB6ZQIAK3js.log; exports.logError = _chunkB6ZQIAK3js.logError; exports.login = _chunkB6ZQIAK3js.login; exports.loginToState = _chunkB6ZQIAK3js.loginToState; exports.logs3OverflowUploadSchema = _chunkB6ZQIAK3js.logs3OverflowUploadSchema; exports.newId = _chunkB6ZQIAK3js.newId; exports.parseCachedHeader = _chunkB6ZQIAK3js.parseCachedHeader; exports.parseTemplateFormat = _chunkB6ZQIAK3js.parseTemplateFormat; exports.permalink = _chunkB6ZQIAK3js.permalink; exports.pickLogs3OverflowObjectIds = _chunkB6ZQIAK3js.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkB6ZQIAK3js.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkB6ZQIAK3js.registerTemplatePlugin; exports.renderMessage = _chunkB6ZQIAK3js.renderMessage; exports.renderPromptParams = _chunkB6ZQIAK3js.renderPromptParams; exports.renderTemplateContent = _chunkB6ZQIAK3js.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkB6ZQIAK3js.setFetch; exports.setMaskingFunction = _chunkB6ZQIAK3js.setMaskingFunction; exports.spanComponentsToObjectId = _chunkB6ZQIAK3js.spanComponentsToObjectId; exports.startSpan = _chunkB6ZQIAK3js.startSpan; exports.summarize = _chunkB6ZQIAK3js.summarize; exports.templateRegistry = _chunkB6ZQIAK3js.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkB6ZQIAK3js.ToolFunctionDefinition; exports.traceable = _chunkB6ZQIAK3js.traceable; exports.traced = _chunkB6ZQIAK3js.traced; exports.updateSpan = _chunkB6ZQIAK3js.updateSpan; exports.uploadLogs3OverflowPayload = _chunkB6ZQIAK3js.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkB6ZQIAK3js.utf8ByteLength; exports.withCurrent = _chunkB6ZQIAK3js.withCurrent; exports.withDataset = _chunkB6ZQIAK3js.withDataset; exports.withExperiment = _chunkB6ZQIAK3js.withExperiment; exports.withLogger = _chunkB6ZQIAK3js.withLogger; exports.withParent = _chunkB6ZQIAK3js.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 = _chunkB6ZQIAK3js.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 = _chunkB6ZQIAK3js.wrapTraced; exports.wrapVitest = wrapVitest;
|