@mastra/core 1.31.0-alpha.3 → 1.31.0-alpha.5
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/CHANGELOG.md +46 -0
- package/dist/agent/durable/index.cjs +22 -22
- package/dist/agent/durable/index.js +4 -4
- package/dist/agent/index.cjs +9 -9
- package/dist/agent/index.js +1 -1
- package/dist/browser/index.cjs +5 -5
- package/dist/browser/index.js +2 -2
- package/dist/channels/index.cjs +4 -4
- package/dist/channels/index.js +1 -1
- package/dist/{chunk-LEXSJDD5.cjs → chunk-3CBQ4FAZ.cjs} +215 -18
- package/dist/chunk-3CBQ4FAZ.cjs.map +1 -0
- package/dist/{chunk-EMLA7DXA.cjs → chunk-4RFGOX6E.cjs} +9 -9
- package/dist/{chunk-EMLA7DXA.cjs.map → chunk-4RFGOX6E.cjs.map} +1 -1
- package/dist/{chunk-P5XCYDW7.js → chunk-52IAV52S.js} +3 -3
- package/dist/{chunk-P5XCYDW7.js.map → chunk-52IAV52S.js.map} +1 -1
- package/dist/{chunk-OQ6ORZLY.cjs → chunk-5ANWVE3P.cjs} +216 -35
- package/dist/chunk-5ANWVE3P.cjs.map +1 -0
- package/dist/{chunk-HBCHXSQT.js → chunk-5AZE6Y7E.js} +6 -6
- package/dist/{chunk-HBCHXSQT.js.map → chunk-5AZE6Y7E.js.map} +1 -1
- package/dist/{chunk-JXWLABNY.cjs → chunk-ALZAXC3J.cjs} +19 -19
- package/dist/{chunk-JXWLABNY.cjs.map → chunk-ALZAXC3J.cjs.map} +1 -1
- package/dist/{chunk-IKXZNMTB.cjs → chunk-ATJ2RA5L.cjs} +5 -5
- package/dist/{chunk-IKXZNMTB.cjs.map → chunk-ATJ2RA5L.cjs.map} +1 -1
- package/dist/{chunk-BEDXCJ3D.js → chunk-D6WNIFWU.js} +4 -4
- package/dist/{chunk-BEDXCJ3D.js.map → chunk-D6WNIFWU.js.map} +1 -1
- package/dist/{chunk-C6KGFSLD.js → chunk-D7ORPD2O.js} +3 -3
- package/dist/{chunk-C6KGFSLD.js.map → chunk-D7ORPD2O.js.map} +1 -1
- package/dist/{chunk-WYDQEW3F.cjs → chunk-DZBT3XFM.cjs} +7 -7
- package/dist/{chunk-WYDQEW3F.cjs.map → chunk-DZBT3XFM.cjs.map} +1 -1
- package/dist/{chunk-3MJ2YZKW.js → chunk-EZANPKCM.js} +3 -3
- package/dist/{chunk-3MJ2YZKW.js.map → chunk-EZANPKCM.js.map} +1 -1
- package/dist/{chunk-5AFU6MDJ.js → chunk-F4PWGVHW.js} +212 -32
- package/dist/chunk-F4PWGVHW.js.map +1 -0
- package/dist/{chunk-N3MFQ5IC.cjs → chunk-GYK5WRWE.cjs} +3 -3
- package/dist/{chunk-N3MFQ5IC.cjs.map → chunk-GYK5WRWE.cjs.map} +1 -1
- package/dist/{chunk-FBSDOK7N.cjs → chunk-HDZV5R52.cjs} +224 -224
- package/dist/{chunk-FBSDOK7N.cjs.map → chunk-HDZV5R52.cjs.map} +1 -1
- package/dist/{chunk-ORGS37CO.js → chunk-IB3UPSY2.js} +9 -9
- package/dist/{chunk-ORGS37CO.js.map → chunk-IB3UPSY2.js.map} +1 -1
- package/dist/{chunk-ZTVCTOC4.js → chunk-II2JGWWS.js} +3 -3
- package/dist/{chunk-ZTVCTOC4.js.map → chunk-II2JGWWS.js.map} +1 -1
- package/dist/{chunk-QYT6OF4I.cjs → chunk-O4NY7VXW.cjs} +17 -17
- package/dist/{chunk-QYT6OF4I.cjs.map → chunk-O4NY7VXW.cjs.map} +1 -1
- package/dist/{chunk-BICHLSKY.cjs → chunk-PLCMSZZR.cjs} +20 -20
- package/dist/{chunk-BICHLSKY.cjs.map → chunk-PLCMSZZR.cjs.map} +1 -1
- package/dist/{chunk-U7SCBEKL.js → chunk-PW5TFXZI.js} +3 -3
- package/dist/{chunk-U7SCBEKL.js.map → chunk-PW5TFXZI.js.map} +1 -1
- package/dist/{chunk-6YTX2D43.cjs → chunk-QB6SFTJF.cjs} +57 -57
- package/dist/{chunk-6YTX2D43.cjs.map → chunk-QB6SFTJF.cjs.map} +1 -1
- package/dist/{chunk-7CDGKPLZ.cjs → chunk-U7C3WU7B.cjs} +389 -389
- package/dist/{chunk-7CDGKPLZ.cjs.map → chunk-U7C3WU7B.cjs.map} +1 -1
- package/dist/{chunk-ENFUF5ZE.js → chunk-URCXU22J.js} +8 -8
- package/dist/{chunk-ENFUF5ZE.js.map → chunk-URCXU22J.js.map} +1 -1
- package/dist/{chunk-SE2NIAOC.js → chunk-X735G7KE.js} +4 -4
- package/dist/{chunk-SE2NIAOC.js.map → chunk-X735G7KE.js.map} +1 -1
- package/dist/{chunk-6BMV3INL.js → chunk-ZKHNSFUH.js} +213 -16
- package/dist/chunk-ZKHNSFUH.js.map +1 -0
- package/dist/datasets/experiment/index.d.ts.map +1 -1
- package/dist/datasets/experiment/scorer.d.ts +25 -0
- package/dist/datasets/experiment/scorer.d.ts.map +1 -1
- package/dist/datasets/experiment/types.d.ts +18 -2
- package/dist/datasets/experiment/types.d.ts.map +1 -1
- package/dist/datasets/index.cjs +11 -11
- package/dist/datasets/index.js +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +140 -140
- package/dist/docs/references/docs-agents-adding-voice.md +14 -13
- package/dist/docs/references/docs-voice-overview.md +66 -0
- package/dist/docs/references/docs-voice-speech-to-speech.md +45 -1
- package/dist/docs/references/docs-workspace-search.md +39 -0
- package/dist/docs/references/reference-datasets-startExperiment.md +28 -2
- package/dist/docs/references/reference-workspace-workspace-class.md +1 -1
- package/dist/docs/references/reference.md +2 -0
- package/dist/evals/index.cjs +6 -6
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/harness/index.cjs +11 -11
- package/dist/harness/index.js +6 -6
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +20 -20
- package/dist/llm/index.js +5 -5
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/mastra-OCULSBP5.js +3 -0
- package/dist/{mastra-ZMGSDAUN.js.map → mastra-OCULSBP5.js.map} +1 -1
- package/dist/mastra-VMPA5UVF.cjs +12 -0
- package/dist/{mastra-P7T3UKV5.cjs.map → mastra-VMPA5UVF.cjs.map} +1 -1
- package/dist/memory/index.cjs +19 -19
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-CCJECLMT.cjs +12 -0
- package/dist/{models-dev-GJQCRHM3.cjs.map → models-dev-CCJECLMT.cjs.map} +1 -1
- package/dist/models-dev-F6OUM7S7.js +3 -0
- package/dist/{models-dev-DL6NWDNP.js.map → models-dev-F6OUM7S7.js.map} +1 -1
- package/dist/netlify-2YTGXPQW.js +3 -0
- package/dist/{netlify-3CKP3DSR.js.map → netlify-2YTGXPQW.js.map} +1 -1
- package/dist/netlify-4NR3G6EJ.cjs +12 -0
- package/dist/{netlify-O34AZQ5R.cjs.map → netlify-4NR3G6EJ.cjs.map} +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +49 -49
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-HZHKE2KN.cjs +44 -0
- package/dist/{provider-registry-DI3SQCLD.cjs.map → provider-registry-HZHKE2KN.cjs.map} +1 -1
- package/dist/provider-registry-QREDL7WJ.js +3 -0
- package/dist/{provider-registry-ZTTSZTTB.js.map → provider-registry-QREDL7WJ.js.map} +1 -1
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/runner-FOG455RH.js +3 -0
- package/dist/{runner-BIOR2SMR.js.map → runner-FOG455RH.js.map} +1 -1
- package/dist/runner-PDJYD3PQ.cjs +16 -0
- package/dist/{runner-J24LBLPO.cjs.map → runner-PDJYD3PQ.cjs.map} +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/dist/workspace/index.cjs +68 -68
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/search/search-engine.d.ts +67 -4
- package/dist/workspace/search/search-engine.d.ts.map +1 -1
- package/dist/workspace/workspace.d.ts +14 -0
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-5AFU6MDJ.js.map +0 -1
- package/dist/chunk-6BMV3INL.js.map +0 -1
- package/dist/chunk-LEXSJDD5.cjs.map +0 -1
- package/dist/chunk-OQ6ORZLY.cjs.map +0 -1
- package/dist/mastra-P7T3UKV5.cjs +0 -12
- package/dist/mastra-ZMGSDAUN.js +0 -3
- package/dist/models-dev-DL6NWDNP.js +0 -3
- package/dist/models-dev-GJQCRHM3.cjs +0 -12
- package/dist/netlify-3CKP3DSR.js +0 -3
- package/dist/netlify-O34AZQ5R.cjs +0 -12
- package/dist/provider-registry-DI3SQCLD.cjs +0 -44
- package/dist/provider-registry-ZTTSZTTB.js +0 -3
- package/dist/runner-BIOR2SMR.js +0 -3
- package/dist/runner-J24LBLPO.cjs +0 -16
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkATJ2RA5L_cjs = require('./chunk-ATJ2RA5L.cjs');
|
|
4
|
+
var chunkO4NY7VXW_cjs = require('./chunk-O4NY7VXW.cjs');
|
|
5
|
+
var chunkAAGXQKWU_cjs = require('./chunk-AAGXQKWU.cjs');
|
|
5
6
|
var chunkIBQB7RSW_cjs = require('./chunk-IBQB7RSW.cjs');
|
|
6
7
|
var chunk5K2PRY26_cjs = require('./chunk-5K2PRY26.cjs');
|
|
7
8
|
var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
|
|
@@ -107,7 +108,7 @@ async function executeAgent(agent, item, signal, requestContext, experimentId, v
|
|
|
107
108
|
const input = item.input;
|
|
108
109
|
const reqCtx = requestContext ? new chunkKF4FCWWL_cjs.RequestContext(Object.entries(requestContext)) : void 0;
|
|
109
110
|
const tracingOptions = experimentId ? { metadata: { experimentId } } : void 0;
|
|
110
|
-
const rawResult =
|
|
111
|
+
const rawResult = chunkO4NY7VXW_cjs.isSupportedLanguageModel(model) ? await agent.generate(input, {
|
|
111
112
|
scorers: {},
|
|
112
113
|
returnScorerData: true,
|
|
113
114
|
abortSignal: signal,
|
|
@@ -240,8 +241,26 @@ function resolveScorers(mastra, scorers) {
|
|
|
240
241
|
return scorer;
|
|
241
242
|
}).filter((s) => s !== null);
|
|
242
243
|
}
|
|
244
|
+
async function extractTrajectoryFromStorage(storage, traceId) {
|
|
245
|
+
if (!storage || !traceId) return void 0;
|
|
246
|
+
try {
|
|
247
|
+
const observabilityStore = await storage.getStore("observability");
|
|
248
|
+
if (!observabilityStore) return void 0;
|
|
249
|
+
const trace = await observabilityStore.getTrace({ traceId });
|
|
250
|
+
if (!trace?.spans?.length) return void 0;
|
|
251
|
+
return chunkAAGXQKWU_cjs.extractTrajectoryFromTrace(trace.spans);
|
|
252
|
+
} catch {
|
|
253
|
+
return void 0;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
243
256
|
async function runScorersForItem(scorers, item, output, storage, runId, targetType, targetId, itemId, scorerInput, scorerOutput, traceId, workflowData) {
|
|
244
257
|
if (scorers.length === 0) return [];
|
|
258
|
+
const hasTrajectoryScorer = scorers.some((s) => s.type === "trajectory");
|
|
259
|
+
let trajectoryOutput;
|
|
260
|
+
if (hasTrajectoryScorer) {
|
|
261
|
+
const traceTrajectory = await extractTrajectoryFromStorage(storage, traceId);
|
|
262
|
+
trajectoryOutput = traceTrajectory ?? (scorerOutput ? chunkAAGXQKWU_cjs.extractTrajectory(scorerOutput) : { steps: [] });
|
|
263
|
+
}
|
|
245
264
|
const targetCorrelationContext = {
|
|
246
265
|
...traceId ? { traceId } : {},
|
|
247
266
|
entityType: toScorerTargetEntityType(targetType),
|
|
@@ -260,11 +279,12 @@ async function runScorersForItem(scorers, item, output, storage, runId, targetTy
|
|
|
260
279
|
targetType,
|
|
261
280
|
traceId,
|
|
262
281
|
targetCorrelationContext,
|
|
282
|
+
scorer.type === "trajectory" ? trajectoryOutput : void 0,
|
|
263
283
|
workflowData
|
|
264
284
|
);
|
|
265
285
|
if (storage && result.score !== null) {
|
|
266
286
|
try {
|
|
267
|
-
await
|
|
287
|
+
await chunkATJ2RA5L_cjs.validateAndSaveScore(storage, {
|
|
268
288
|
scorerId: scorer.id,
|
|
269
289
|
score: result.score,
|
|
270
290
|
reason: result.reason ?? void 0,
|
|
@@ -295,22 +315,33 @@ async function runScorersForItem(scorers, item, output, storage, runId, targetTy
|
|
|
295
315
|
return result;
|
|
296
316
|
})
|
|
297
317
|
);
|
|
298
|
-
return settled.map(
|
|
299
|
-
(s
|
|
300
|
-
|
|
318
|
+
return settled.map((s, i) => {
|
|
319
|
+
if (s.status === "fulfilled") return s.value;
|
|
320
|
+
const scorer = scorers[i];
|
|
321
|
+
return {
|
|
322
|
+
scorerId: scorer.id,
|
|
323
|
+
scorerName: scorer.name,
|
|
324
|
+
score: null,
|
|
325
|
+
reason: null,
|
|
326
|
+
error: String(s.reason),
|
|
327
|
+
targetScope: scorer.type === "trajectory" ? "trajectory" : "span"
|
|
328
|
+
};
|
|
329
|
+
});
|
|
301
330
|
}
|
|
302
|
-
async function runScorerSafe(scorer, item, output, scorerInput, scorerOutput, targetType, targetTraceId, targetCorrelationContext, workflowData) {
|
|
331
|
+
async function runScorerSafe(scorer, item, output, scorerInput, scorerOutput, targetType, targetTraceId, targetCorrelationContext, trajectoryOutput, workflowData) {
|
|
303
332
|
try {
|
|
304
|
-
const
|
|
333
|
+
const effectiveOutput = trajectoryOutput ?? scorerOutput ?? output;
|
|
334
|
+
const effectiveScope = trajectoryOutput ? "trajectory" : "span";
|
|
335
|
+
const targetMetadata = !trajectoryOutput && workflowData && (workflowData.stepResults || workflowData.stepExecutionPath) ? {
|
|
305
336
|
...workflowData.stepResults ? { stepResults: workflowData.stepResults } : {},
|
|
306
337
|
...workflowData.stepExecutionPath ? { stepExecutionPath: workflowData.stepExecutionPath } : {}
|
|
307
338
|
} : void 0;
|
|
308
339
|
const scoreResult = await scorer.run({
|
|
309
340
|
input: scorerInput ?? item.input,
|
|
310
|
-
output:
|
|
341
|
+
output: effectiveOutput,
|
|
311
342
|
groundTruth: item.groundTruth,
|
|
312
343
|
scoreSource: "experiment",
|
|
313
|
-
targetScope:
|
|
344
|
+
targetScope: effectiveScope,
|
|
314
345
|
targetEntityType: toScorerTargetEntityType(targetType),
|
|
315
346
|
targetTraceId,
|
|
316
347
|
...workflowData?.spanId ? { targetSpanId: workflowData.spanId } : {},
|
|
@@ -343,7 +374,8 @@ async function runScorerSafe(scorer, item, output, scorerInput, scorerOutput, ta
|
|
|
343
374
|
scorerName: scorer.name,
|
|
344
375
|
score,
|
|
345
376
|
reason,
|
|
346
|
-
error: null
|
|
377
|
+
error: null,
|
|
378
|
+
targetScope: effectiveScope
|
|
347
379
|
},
|
|
348
380
|
promptMetadata: {
|
|
349
381
|
generateScorePrompt: str("generateScorePrompt"),
|
|
@@ -361,12 +393,151 @@ async function runScorerSafe(scorer, item, output, scorerInput, scorerOutput, ta
|
|
|
361
393
|
scorerName: scorer.name,
|
|
362
394
|
score: null,
|
|
363
395
|
reason: null,
|
|
364
|
-
error: error instanceof Error ? error.message : String(error)
|
|
396
|
+
error: error instanceof Error ? error.message : String(error),
|
|
397
|
+
targetScope: trajectoryOutput ? "trajectory" : "span"
|
|
365
398
|
},
|
|
366
399
|
promptMetadata: {}
|
|
367
400
|
};
|
|
368
401
|
}
|
|
369
402
|
}
|
|
403
|
+
function resolveStepScorers(mastra, stepsConfig) {
|
|
404
|
+
if (!stepsConfig) return {};
|
|
405
|
+
const resolved = {};
|
|
406
|
+
for (const [stepId, scorers] of Object.entries(stepsConfig)) {
|
|
407
|
+
const stepScorers = resolveScorers(mastra, scorers);
|
|
408
|
+
if (stepScorers.length > 0) resolved[stepId] = stepScorers;
|
|
409
|
+
}
|
|
410
|
+
return resolved;
|
|
411
|
+
}
|
|
412
|
+
async function runStepScorersForItem(stepScorers, item, workflowData, storage, runId, targetType, targetId, itemId, traceId) {
|
|
413
|
+
const stepIds = Object.keys(stepScorers);
|
|
414
|
+
if (stepIds.length === 0) return [];
|
|
415
|
+
const results = [];
|
|
416
|
+
const stepResults = workflowData?.stepResults;
|
|
417
|
+
for (const stepId of stepIds) {
|
|
418
|
+
const scorers = stepScorers[stepId];
|
|
419
|
+
const stepResult = stepResults?.[stepId];
|
|
420
|
+
if (!stepResult || stepResult.status !== "success" || stepResult.output === void 0) {
|
|
421
|
+
for (const scorer of scorers) {
|
|
422
|
+
results.push({
|
|
423
|
+
scorerId: scorer.id,
|
|
424
|
+
scorerName: scorer.name,
|
|
425
|
+
score: null,
|
|
426
|
+
reason: null,
|
|
427
|
+
error: `Step "${stepId}" did not produce a successful output (status: ${stepResult?.status ?? "missing"})`,
|
|
428
|
+
targetScope: "span",
|
|
429
|
+
stepId
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const stepInput = stepResult.payload !== void 0 ? stepResult.payload : item.input;
|
|
435
|
+
const stepOutput = stepResult.output;
|
|
436
|
+
const targetCorrelationContext = {
|
|
437
|
+
...traceId ? { traceId } : {},
|
|
438
|
+
entityType: chunk5K2PRY26_cjs.EntityType.WORKFLOW_STEP,
|
|
439
|
+
entityId: stepId,
|
|
440
|
+
entityName: stepId,
|
|
441
|
+
experimentId: runId
|
|
442
|
+
};
|
|
443
|
+
const settled = await Promise.allSettled(
|
|
444
|
+
scorers.map(async (scorer) => {
|
|
445
|
+
try {
|
|
446
|
+
const scoreResult = await scorer.run({
|
|
447
|
+
input: stepInput,
|
|
448
|
+
output: stepOutput,
|
|
449
|
+
groundTruth: item.groundTruth,
|
|
450
|
+
scoreSource: "experiment",
|
|
451
|
+
targetScope: "span",
|
|
452
|
+
targetEntityType: chunk5K2PRY26_cjs.EntityType.WORKFLOW_STEP,
|
|
453
|
+
targetTraceId: traceId,
|
|
454
|
+
...targetCorrelationContext ? { targetCorrelationContext } : {}
|
|
455
|
+
});
|
|
456
|
+
if (typeof scoreResult !== "object" || scoreResult === null) {
|
|
457
|
+
return {
|
|
458
|
+
scorerId: scorer.id,
|
|
459
|
+
scorerName: scorer.name,
|
|
460
|
+
score: null,
|
|
461
|
+
reason: null,
|
|
462
|
+
error: `Scorer ${scorer.name} (${scorer.id}) returned invalid result on step ${stepId}`,
|
|
463
|
+
targetScope: "span",
|
|
464
|
+
stepId
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
const fields = scoreResult;
|
|
468
|
+
const score = typeof fields.score === "number" ? fields.score : null;
|
|
469
|
+
const reason = typeof fields.reason === "string" ? fields.reason : null;
|
|
470
|
+
if (storage && score !== null) {
|
|
471
|
+
try {
|
|
472
|
+
await chunkATJ2RA5L_cjs.validateAndSaveScore(storage, {
|
|
473
|
+
scorerId: scorer.id,
|
|
474
|
+
score,
|
|
475
|
+
reason: reason ?? void 0,
|
|
476
|
+
input: stepInput,
|
|
477
|
+
output: stepOutput,
|
|
478
|
+
additionalContext: { ...item.metadata, stepId },
|
|
479
|
+
entityType: "WORKFLOW_STEP",
|
|
480
|
+
entityId: itemId,
|
|
481
|
+
source: "TEST",
|
|
482
|
+
runId,
|
|
483
|
+
traceId,
|
|
484
|
+
scorer: {
|
|
485
|
+
id: scorer.id,
|
|
486
|
+
name: scorer.name,
|
|
487
|
+
description: scorer.description ?? "",
|
|
488
|
+
hasJudge: !!scorer.judge
|
|
489
|
+
},
|
|
490
|
+
entity: {
|
|
491
|
+
id: targetId,
|
|
492
|
+
name: targetId
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
} catch (saveError) {
|
|
496
|
+
console.warn(`Failed to save score for step scorer ${scorer.id} on ${stepId}:`, saveError);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return {
|
|
500
|
+
scorerId: scorer.id,
|
|
501
|
+
scorerName: scorer.name,
|
|
502
|
+
score,
|
|
503
|
+
reason,
|
|
504
|
+
error: null,
|
|
505
|
+
targetScope: "span",
|
|
506
|
+
stepId
|
|
507
|
+
};
|
|
508
|
+
} catch (error) {
|
|
509
|
+
return {
|
|
510
|
+
scorerId: scorer.id,
|
|
511
|
+
scorerName: scorer.name,
|
|
512
|
+
score: null,
|
|
513
|
+
reason: null,
|
|
514
|
+
error: error instanceof Error ? error.message : String(error),
|
|
515
|
+
targetScope: "span",
|
|
516
|
+
stepId
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
})
|
|
520
|
+
);
|
|
521
|
+
for (let i = 0; i < settled.length; i++) {
|
|
522
|
+
const s = settled[i];
|
|
523
|
+
if (s.status === "fulfilled") {
|
|
524
|
+
results.push(s.value);
|
|
525
|
+
} else {
|
|
526
|
+
const scorer = scorers[i];
|
|
527
|
+
results.push({
|
|
528
|
+
scorerId: scorer.id,
|
|
529
|
+
scorerName: scorer.name,
|
|
530
|
+
score: null,
|
|
531
|
+
reason: null,
|
|
532
|
+
error: String(s.reason),
|
|
533
|
+
targetScope: "span",
|
|
534
|
+
stepId
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return results;
|
|
540
|
+
}
|
|
370
541
|
|
|
371
542
|
// src/datasets/experiment/analytics/aggregate.ts
|
|
372
543
|
function computeMean(values) {
|
|
@@ -719,10 +890,23 @@ async function runExperiment(mastra, config) {
|
|
|
719
890
|
await markFailedOnSetupError(err);
|
|
720
891
|
throw err;
|
|
721
892
|
}
|
|
722
|
-
let
|
|
893
|
+
let stepsConfigInput;
|
|
894
|
+
const flatScorerInput = (() => {
|
|
895
|
+
if (!scorerInput) return void 0;
|
|
896
|
+
if (Array.isArray(scorerInput)) return scorerInput;
|
|
897
|
+
const flat = [];
|
|
898
|
+
if ("agent" in scorerInput && scorerInput.agent) flat.push(...scorerInput.agent);
|
|
899
|
+
if ("workflow" in scorerInput && scorerInput.workflow) flat.push(...scorerInput.workflow);
|
|
900
|
+
if ("trajectory" in scorerInput && scorerInput.trajectory) flat.push(...scorerInput.trajectory);
|
|
901
|
+
if ("steps" in scorerInput && scorerInput.steps) {
|
|
902
|
+
stepsConfigInput = scorerInput.steps;
|
|
903
|
+
}
|
|
904
|
+
return flat;
|
|
905
|
+
})();
|
|
906
|
+
let mergedScorerInput = flatScorerInput;
|
|
723
907
|
const datasetScorerIds = datasetRecord?.scorerIds ?? [];
|
|
724
908
|
if (datasetScorerIds.length > 0) {
|
|
725
|
-
mergedScorerInput = [...
|
|
909
|
+
mergedScorerInput = [...flatScorerInput ?? [], ...datasetScorerIds];
|
|
726
910
|
}
|
|
727
911
|
if (mergedScorerInput && mergedScorerInput.length > 0) {
|
|
728
912
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -736,6 +920,7 @@ async function runExperiment(mastra, config) {
|
|
|
736
920
|
});
|
|
737
921
|
}
|
|
738
922
|
const scorers = resolveScorers(mastra, mergedScorerInput);
|
|
923
|
+
const stepScorers = resolveStepScorers(mastra, stepsConfigInput);
|
|
739
924
|
if (experimentsStore) {
|
|
740
925
|
if (!providedExperimentId) {
|
|
741
926
|
await experimentsStore.createExperiment({
|
|
@@ -812,7 +997,7 @@ async function runExperiment(mastra, config) {
|
|
|
812
997
|
stepExecutionPath: execResult.stepExecutionPath,
|
|
813
998
|
spanId: execResult.spanId
|
|
814
999
|
} : void 0;
|
|
815
|
-
const
|
|
1000
|
+
const flatScores = await runScorersForItem(
|
|
816
1001
|
scorers,
|
|
817
1002
|
item,
|
|
818
1003
|
execResult.output,
|
|
@@ -826,6 +1011,18 @@ async function runExperiment(mastra, config) {
|
|
|
826
1011
|
execResult.traceId ?? void 0,
|
|
827
1012
|
workflowData
|
|
828
1013
|
);
|
|
1014
|
+
const stepScores = await runStepScorersForItem(
|
|
1015
|
+
stepScorers,
|
|
1016
|
+
item,
|
|
1017
|
+
workflowData,
|
|
1018
|
+
storage ?? null,
|
|
1019
|
+
experimentId,
|
|
1020
|
+
targetType ?? "agent",
|
|
1021
|
+
targetId ?? "inline",
|
|
1022
|
+
item.id,
|
|
1023
|
+
execResult.traceId ?? void 0
|
|
1024
|
+
);
|
|
1025
|
+
const itemScores = [...flatScores, ...stepScores];
|
|
829
1026
|
if (experimentsStore) {
|
|
830
1027
|
try {
|
|
831
1028
|
await experimentsStore.addExperimentResult({
|
|
@@ -1447,5 +1644,5 @@ exports.isRegression = isRegression;
|
|
|
1447
1644
|
exports.resolveScorers = resolveScorers;
|
|
1448
1645
|
exports.runExperiment = runExperiment;
|
|
1449
1646
|
exports.runScorersForItem = runScorersForItem;
|
|
1450
|
-
//# sourceMappingURL=chunk-
|
|
1451
|
-
//# sourceMappingURL=chunk-
|
|
1647
|
+
//# sourceMappingURL=chunk-3CBQ4FAZ.cjs.map
|
|
1648
|
+
//# sourceMappingURL=chunk-3CBQ4FAZ.cjs.map
|