@mastra/core 1.4.0 → 1.5.0-alpha.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/CHANGELOG.md +368 -0
- package/dist/agent/agent.d.ts +3 -2
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/conversion/output-converter.d.ts.map +1 -1
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/merge/MessageMerger.d.ts.map +1 -1
- package/dist/agent/message-list/message-list.d.ts.map +1 -1
- package/dist/agent/types.d.ts +2 -2
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +1 -0
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +1 -0
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts +8 -0
- package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
- package/dist/{chunk-Y3TQ52UE.js → chunk-33TGTTTS.js} +4 -3
- package/dist/chunk-33TGTTTS.js.map +1 -0
- package/dist/{chunk-3X3CZUXI.js → chunk-3KJW4EMO.js} +660 -206
- package/dist/chunk-3KJW4EMO.js.map +1 -0
- package/dist/{chunk-YNNJLLFN.cjs → chunk-3YMDR4OL.cjs} +661 -207
- package/dist/chunk-3YMDR4OL.cjs.map +1 -0
- package/dist/{chunk-NJ7TL3LQ.js → chunk-5EOLBHHS.js} +26 -15
- package/dist/chunk-5EOLBHHS.js.map +1 -0
- package/dist/{chunk-RZ4CIIZR.js → chunk-6DUTLERJ.js} +4 -4
- package/dist/{chunk-RZ4CIIZR.js.map → chunk-6DUTLERJ.js.map} +1 -1
- package/dist/{chunk-VTE2OBKS.cjs → chunk-A6EWCOGA.cjs} +417 -77
- package/dist/chunk-A6EWCOGA.cjs.map +1 -0
- package/dist/{chunk-4XSAZPPS.js → chunk-A7V2NSY3.js} +313 -137
- package/dist/chunk-A7V2NSY3.js.map +1 -0
- package/dist/{chunk-FLPEGTEK.js → chunk-AIRMLZ43.js} +5 -5
- package/dist/{chunk-FLPEGTEK.js.map → chunk-AIRMLZ43.js.map} +1 -1
- package/dist/{chunk-DBSVT6AR.cjs → chunk-BKQAP27M.cjs} +9 -9
- package/dist/{chunk-DBSVT6AR.cjs.map → chunk-BKQAP27M.cjs.map} +1 -1
- package/dist/{chunk-RS6CZXGA.js → chunk-BQHWJLXU.js} +15 -4
- package/dist/chunk-BQHWJLXU.js.map +1 -0
- package/dist/{chunk-V2MLGA7T.js → chunk-CXVMDV2B.js} +417 -78
- package/dist/chunk-CXVMDV2B.js.map +1 -0
- package/dist/{chunk-NKYWDNCI.cjs → chunk-E2FHTXAI.cjs} +7 -7
- package/dist/{chunk-NKYWDNCI.cjs.map → chunk-E2FHTXAI.cjs.map} +1 -1
- package/dist/{chunk-7UWHFWST.cjs → chunk-EAZ6YDCQ.cjs} +15 -3
- package/dist/chunk-EAZ6YDCQ.cjs.map +1 -0
- package/dist/{chunk-64WGYTQK.cjs → chunk-FTBLAVTF.cjs} +55 -55
- package/dist/{chunk-64WGYTQK.cjs.map → chunk-FTBLAVTF.cjs.map} +1 -1
- package/dist/{chunk-4EHGOATH.js → chunk-FZ5DRHKE.js} +1337 -547
- package/dist/chunk-FZ5DRHKE.js.map +1 -0
- package/dist/{chunk-4TQ4EBYX.js → chunk-GEDGDKQ6.js} +9 -9
- package/dist/chunk-GEDGDKQ6.js.map +1 -0
- package/dist/{chunk-QTTWRCB5.js → chunk-I3AWF54W.js} +5 -5
- package/dist/{chunk-QTTWRCB5.js.map → chunk-I3AWF54W.js.map} +1 -1
- package/dist/{chunk-U2HKJZCI.js → chunk-IBNCZTNQ.js} +6 -6
- package/dist/{chunk-U2HKJZCI.js.map → chunk-IBNCZTNQ.js.map} +1 -1
- package/dist/{chunk-3JVFFAJX.cjs → chunk-IJIE3ZID.cjs} +27 -16
- package/dist/chunk-IJIE3ZID.cjs.map +1 -0
- package/dist/{chunk-NZG2JAKS.cjs → chunk-JWG272ZZ.cjs} +19 -19
- package/dist/chunk-JWG272ZZ.cjs.map +1 -0
- package/dist/{chunk-BP7VYTOP.cjs → chunk-JZ6TH4HQ.cjs} +954 -401
- package/dist/chunk-JZ6TH4HQ.cjs.map +1 -0
- package/dist/{chunk-SU5APAM6.cjs → chunk-KNXZ7KYL.cjs} +94 -6
- package/dist/chunk-KNXZ7KYL.cjs.map +1 -0
- package/dist/{chunk-CYUP7QWT.cjs → chunk-KRAGJ433.cjs} +4 -3
- package/dist/chunk-KRAGJ433.cjs.map +1 -0
- package/dist/{chunk-XDD5V446.cjs → chunk-MDC6VYA6.cjs} +6 -2
- package/dist/{chunk-XDD5V446.cjs.map → chunk-MDC6VYA6.cjs.map} +1 -1
- package/dist/{chunk-AXHBJ4GX.js → chunk-NN26FSKL.js} +10 -8
- package/dist/chunk-NN26FSKL.js.map +1 -0
- package/dist/{chunk-AY6DBRS3.js → chunk-OHLVZVIK.js} +36 -2
- package/dist/chunk-OHLVZVIK.js.map +1 -0
- package/dist/{chunk-5Q5Y34SS.js → chunk-PECKKR4C.js} +4 -4
- package/dist/{chunk-5Q5Y34SS.js.map → chunk-PECKKR4C.js.map} +1 -1
- package/dist/{chunk-HYRYTTMT.cjs → chunk-PHHJLGZU.cjs} +9 -9
- package/dist/{chunk-HYRYTTMT.cjs.map → chunk-PHHJLGZU.cjs.map} +1 -1
- package/dist/{chunk-65PHUUMF.cjs → chunk-QDH6MVJ7.cjs} +24 -22
- package/dist/chunk-QDH6MVJ7.cjs.map +1 -0
- package/dist/{chunk-VD5YA6RH.cjs → chunk-QSN5KQXZ.cjs} +18 -18
- package/dist/{chunk-VD5YA6RH.cjs.map → chunk-QSN5KQXZ.cjs.map} +1 -1
- package/dist/{chunk-4IJ4UDZX.cjs → chunk-RH2K66O2.cjs} +399 -223
- package/dist/chunk-RH2K66O2.cjs.map +1 -0
- package/dist/{chunk-4KFEMXTV.cjs → chunk-S4VVZI4E.cjs} +1361 -546
- package/dist/chunk-S4VVZI4E.cjs.map +1 -0
- package/dist/{chunk-ZATLLPIH.js → chunk-TPDMP7OD.js} +6 -2
- package/dist/chunk-TPDMP7OD.js.map +1 -0
- package/dist/{chunk-PS5ONCXY.js → chunk-UZFGMMKU.js} +82 -4
- package/dist/chunk-UZFGMMKU.js.map +1 -0
- package/dist/{chunk-7NKUSQEV.js → chunk-YIN5F7VO.js} +936 -389
- package/dist/chunk-YIN5F7VO.js.map +1 -0
- package/dist/{chunk-CZ4NQANZ.cjs → chunk-YW54RH77.cjs} +36 -2
- package/dist/chunk-YW54RH77.cjs.map +1 -0
- package/dist/datasets/experiment/executor.d.ts.map +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +27 -1
- package/dist/docs/assets/SOURCE_MAP.json +463 -389
- package/dist/docs/references/docs-agents-processors.md +52 -0
- package/dist/docs/references/docs-observability-datasets-overview.md +188 -0
- package/dist/docs/references/docs-observability-datasets-running-experiments.md +266 -0
- package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +7 -4
- package/dist/docs/references/reference-agents-generate.md +1 -1
- package/dist/docs/references/reference-configuration.md +3 -4
- package/dist/docs/references/reference-datasets-addItem.md +35 -0
- package/dist/docs/references/reference-datasets-addItems.md +33 -0
- package/dist/docs/references/reference-datasets-compareExperiments.md +48 -0
- package/dist/docs/references/reference-datasets-create.md +49 -0
- package/dist/docs/references/reference-datasets-dataset.md +78 -0
- package/dist/docs/references/reference-datasets-datasets-manager.md +84 -0
- package/dist/docs/references/reference-datasets-delete.md +23 -0
- package/dist/docs/references/reference-datasets-deleteExperiment.md +25 -0
- package/dist/docs/references/reference-datasets-deleteItem.md +25 -0
- package/dist/docs/references/reference-datasets-deleteItems.md +27 -0
- package/dist/docs/references/reference-datasets-get.md +29 -0
- package/dist/docs/references/reference-datasets-getDetails.md +45 -0
- package/dist/docs/references/reference-datasets-getExperiment.md +28 -0
- package/dist/docs/references/reference-datasets-getItem.md +31 -0
- package/dist/docs/references/reference-datasets-getItemHistory.md +29 -0
- package/dist/docs/references/reference-datasets-list.md +29 -0
- package/dist/docs/references/reference-datasets-listExperimentResults.md +37 -0
- package/dist/docs/references/reference-datasets-listExperiments.md +31 -0
- package/dist/docs/references/reference-datasets-listItems.md +44 -0
- package/dist/docs/references/reference-datasets-listVersions.md +31 -0
- package/dist/docs/references/reference-datasets-startExperiment.md +60 -0
- package/dist/docs/references/reference-datasets-startExperimentAsync.md +41 -0
- package/dist/docs/references/reference-datasets-update.md +46 -0
- package/dist/docs/references/reference-datasets-updateItem.md +36 -0
- package/dist/docs/references/reference-memory-observational-memory.md +36 -0
- package/dist/docs/references/reference-processors-processor-interface.md +4 -0
- package/dist/docs/references/reference-tools-create-tool.md +1 -1
- package/dist/docs/references/reference.md +24 -0
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.d.ts.map +1 -1
- package/dist/editor/types.d.ts +108 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/harness/harness.d.ts +281 -0
- package/dist/harness/harness.d.ts.map +1 -0
- package/dist/harness/index.cjs +1728 -0
- package/dist/harness/index.cjs.map +1 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +1723 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/harness/tools.d.ts +65 -0
- package/dist/harness/tools.d.ts.map +1 -0
- package/dist/harness/types.d.ts +561 -0
- package/dist/harness/types.d.ts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +20 -20
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/gateways/constants.d.ts.map +1 -1
- package/dist/llm/model/gateways/models-dev.d.ts +2 -3
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +312 -93
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +3 -3
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +10 -0
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/types.d.ts +24 -0
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-BW2GAM3K.cjs +12 -0
- package/dist/{models-dev-PPIXUUCU.cjs.map → models-dev-BW2GAM3K.cjs.map} +1 -1
- package/dist/models-dev-MDI5E2YA.js +3 -0
- package/dist/{models-dev-FQVUTQ7L.js.map → models-dev-MDI5E2YA.js.map} +1 -1
- package/dist/observability/index.cjs +11 -11
- package/dist/observability/index.js +1 -1
- package/dist/observability/utils.d.ts.map +1 -1
- package/dist/processors/index.cjs +41 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/processors/skills.d.ts +5 -0
- package/dist/processors/processors/skills.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +2 -2
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +218 -49453
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-4PH2JPIA.cjs +40 -0
- package/dist/{provider-registry-6LZAGQET.cjs.map → provider-registry-4PH2JPIA.cjs.map} +1 -1
- package/dist/provider-registry-VEJ3PN4S.js +3 -0
- package/dist/{provider-registry-QUNT7S55.js.map → provider-registry-VEJ3PN4S.js.map} +1 -1
- package/dist/provider-registry.json +657 -203
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/server/composite-auth.d.ts.map +1 -1
- package/dist/server/index.cjs +6 -1
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +6 -1
- package/dist/server/index.js.map +1 -1
- package/dist/storage/base.d.ts +4 -1
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +82 -42
- package/dist/storage/constants.d.ts +11 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/blobs/base.d.ts +47 -0
- package/dist/storage/domains/blobs/base.d.ts.map +1 -0
- package/dist/storage/domains/blobs/index.d.ts +3 -0
- package/dist/storage/domains/blobs/index.d.ts.map +1 -0
- package/dist/storage/domains/blobs/inmemory.d.ts +17 -0
- package/dist/storage/domains/blobs/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/datasets/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/index.d.ts +3 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +7 -1
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
- package/dist/storage/domains/mcp-clients/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/prompt-blocks/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/scorer-definitions/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/skills/base.d.ts +47 -0
- package/dist/storage/domains/skills/base.d.ts.map +1 -0
- package/dist/storage/domains/skills/index.d.ts +3 -0
- package/dist/storage/domains/skills/index.d.ts.map +1 -0
- package/dist/storage/domains/skills/inmemory.d.ts +31 -0
- package/dist/storage/domains/skills/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/versioned.d.ts +12 -3
- package/dist/storage/domains/versioned.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/base.d.ts +47 -0
- package/dist/storage/domains/workspaces/base.d.ts.map +1 -0
- package/dist/storage/domains/workspaces/index.d.ts +3 -0
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -0
- package/dist/storage/domains/workspaces/inmemory.d.ts +31 -0
- package/dist/storage/domains/workspaces/inmemory.d.ts.map +1 -0
- package/dist/storage/index.cjs +202 -138
- package/dist/storage/index.js +2 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +422 -12
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tools/index.cjs +8 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/tool.d.ts +13 -0
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/toolchecks.d.ts.map +1 -1
- package/dist/tools/types.d.ts +24 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/types/zod-compat.d.ts +27 -6
- package/dist/types/zod-compat.d.ts.map +1 -1
- package/dist/utils.cjs +23 -23
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +12 -12
- package/dist/vector/index.js +2 -2
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/handlers/entry.d.ts.map +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/workflow.d.ts +2 -2
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/dist/workspace/constants/index.d.ts +1 -0
- package/dist/workspace/constants/index.d.ts.map +1 -1
- package/dist/workspace/errors.d.ts +3 -0
- package/dist/workspace/errors.d.ts.map +1 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts +75 -6
- package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +42 -0
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/glob.d.ts +61 -0
- package/dist/workspace/glob.d.ts.map +1 -0
- package/dist/workspace/index.cjs +133 -41
- package/dist/workspace/index.d.ts +8 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/skills/composite-versioned-skill-source.d.ts +44 -0
- package/dist/workspace/skills/composite-versioned-skill-source.d.ts.map +1 -0
- package/dist/workspace/skills/index.d.ts +3 -0
- package/dist/workspace/skills/index.d.ts.map +1 -1
- package/dist/workspace/skills/local-skill-source.d.ts.map +1 -1
- package/dist/workspace/skills/publish.d.ts +34 -0
- package/dist/workspace/skills/publish.d.ts.map +1 -0
- package/dist/workspace/skills/skill-source.d.ts +2 -0
- package/dist/workspace/skills/skill-source.d.ts.map +1 -1
- package/dist/workspace/skills/types.d.ts +16 -0
- package/dist/workspace/skills/types.d.ts.map +1 -1
- package/dist/workspace/skills/versioned-skill-source.d.ts +20 -0
- package/dist/workspace/skills/versioned-skill-source.d.ts.map +1 -0
- package/dist/workspace/skills/workspace-skills.d.ts +5 -0
- package/dist/workspace/skills/workspace-skills.d.ts.map +1 -1
- package/dist/workspace/tools/delete-file.d.ts +5 -0
- package/dist/workspace/tools/delete-file.d.ts.map +1 -0
- package/dist/workspace/tools/edit-file.d.ts +7 -0
- package/dist/workspace/tools/edit-file.d.ts.map +1 -0
- package/dist/workspace/tools/execute-command.d.ts +7 -0
- package/dist/workspace/tools/execute-command.d.ts.map +1 -0
- package/dist/workspace/tools/file-stat.d.ts +4 -0
- package/dist/workspace/tools/file-stat.d.ts.map +1 -0
- package/dist/workspace/tools/grep.d.ts +9 -0
- package/dist/workspace/tools/grep.d.ts.map +1 -0
- package/dist/workspace/tools/helpers.d.ts +36 -0
- package/dist/workspace/tools/helpers.d.ts.map +1 -0
- package/dist/workspace/tools/index-content.d.ts +6 -0
- package/dist/workspace/tools/index-content.d.ts.map +1 -0
- package/dist/workspace/tools/index.d.ts +13 -1
- package/dist/workspace/tools/index.d.ts.map +1 -1
- package/dist/workspace/tools/list-files.d.ts +10 -0
- package/dist/workspace/tools/list-files.d.ts.map +1 -0
- package/dist/workspace/tools/mkdir.d.ts +5 -0
- package/dist/workspace/tools/mkdir.d.ts.map +1 -0
- package/dist/workspace/tools/read-file.d.ts +8 -0
- package/dist/workspace/tools/read-file.d.ts.map +1 -0
- package/dist/workspace/tools/search.d.ts +7 -0
- package/dist/workspace/tools/search.d.ts.map +1 -0
- package/dist/workspace/tools/tools.d.ts +5 -7
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/dist/workspace/tools/tree-formatter.d.ts +2 -0
- package/dist/workspace/tools/tree-formatter.d.ts.map +1 -1
- package/dist/workspace/tools/write-file.d.ts +6 -0
- package/dist/workspace/tools/write-file.d.ts.map +1 -0
- package/dist/workspace/workspace.d.ts +56 -10
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/harness.d.ts +1 -0
- package/package.json +8 -6
- package/src/llm/model/provider-types.generated.d.ts +312 -93
- package/dist/chunk-3JVFFAJX.cjs.map +0 -1
- package/dist/chunk-3X3CZUXI.js.map +0 -1
- package/dist/chunk-4EHGOATH.js.map +0 -1
- package/dist/chunk-4IJ4UDZX.cjs.map +0 -1
- package/dist/chunk-4KFEMXTV.cjs.map +0 -1
- package/dist/chunk-4TQ4EBYX.js.map +0 -1
- package/dist/chunk-4XSAZPPS.js.map +0 -1
- package/dist/chunk-65PHUUMF.cjs.map +0 -1
- package/dist/chunk-7NKUSQEV.js.map +0 -1
- package/dist/chunk-7UWHFWST.cjs.map +0 -1
- package/dist/chunk-AXHBJ4GX.js.map +0 -1
- package/dist/chunk-AY6DBRS3.js.map +0 -1
- package/dist/chunk-BP7VYTOP.cjs.map +0 -1
- package/dist/chunk-CYUP7QWT.cjs.map +0 -1
- package/dist/chunk-CZ4NQANZ.cjs.map +0 -1
- package/dist/chunk-NJ7TL3LQ.js.map +0 -1
- package/dist/chunk-NZG2JAKS.cjs.map +0 -1
- package/dist/chunk-PS5ONCXY.js.map +0 -1
- package/dist/chunk-RS6CZXGA.js.map +0 -1
- package/dist/chunk-SU5APAM6.cjs.map +0 -1
- package/dist/chunk-V2MLGA7T.js.map +0 -1
- package/dist/chunk-VTE2OBKS.cjs.map +0 -1
- package/dist/chunk-Y3TQ52UE.js.map +0 -1
- package/dist/chunk-YNNJLLFN.cjs.map +0 -1
- package/dist/chunk-ZATLLPIH.js.map +0 -1
- package/dist/models-dev-FQVUTQ7L.js +0 -3
- package/dist/models-dev-PPIXUUCU.cjs +0 -12
- package/dist/provider-registry-6LZAGQET.cjs +0 -40
- package/dist/provider-registry-QUNT7S55.js +0 -3
|
@@ -342,6 +342,58 @@ export class CustomOutputProcessor implements Processor {
|
|
|
342
342
|
}
|
|
343
343
|
```
|
|
344
344
|
|
|
345
|
+
#### Emitting custom stream events with writer
|
|
346
|
+
|
|
347
|
+
Output processors receive a `writer` object that lets you emit custom data chunks back to the client during streaming. This is useful for use cases like streaming moderation results or sending UI update signals without blocking the original stream.
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
import type { Processor, ChunkType, MastraDBMessage } from "@mastra/core";
|
|
351
|
+
|
|
352
|
+
export class ModerationProcessor implements Processor {
|
|
353
|
+
id = "moderation";
|
|
354
|
+
|
|
355
|
+
async processOutputResult({ messages, writer }) {
|
|
356
|
+
// Run moderation on the final output
|
|
357
|
+
const text = messages
|
|
358
|
+
.filter((m) => m.role === "assistant")
|
|
359
|
+
.flatMap((m) => m.content.parts?.filter((p) => p.type === "text"))
|
|
360
|
+
.map((p) => p.text)
|
|
361
|
+
.join(" ");
|
|
362
|
+
|
|
363
|
+
const result = await runModeration(text);
|
|
364
|
+
|
|
365
|
+
if (result.requiresChange) {
|
|
366
|
+
// Emit a custom event to the client with the moderated text
|
|
367
|
+
await writer?.custom({
|
|
368
|
+
type: "data-moderation-update",
|
|
369
|
+
data: {
|
|
370
|
+
originalText: text,
|
|
371
|
+
moderatedText: result.moderatedText,
|
|
372
|
+
reason: result.reason,
|
|
373
|
+
},
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return messages;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
On the client, listen for the custom chunk type in the stream:
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
const stream = await agent.stream("Hello");
|
|
386
|
+
|
|
387
|
+
for await (const chunk of stream.fullStream) {
|
|
388
|
+
if (chunk.type === "data-moderation-update") {
|
|
389
|
+
// Update the UI with moderated text
|
|
390
|
+
updateDisplayedMessage(chunk.data.moderatedText);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Custom chunk types must use the `data-` prefix (e.g., `data-moderation-update`, `data-status`).
|
|
396
|
+
|
|
345
397
|
#### Adding metadata in output processors
|
|
346
398
|
|
|
347
399
|
You can add custom metadata to messages in `processOutputResult`. This metadata is accessible via the response object:
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Datasets Overview
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.4.0`
|
|
4
|
+
|
|
5
|
+
Datasets are collections of test cases that you run experiments against to measure how well your agents and workflows perform. Each mutation creates a new version, so you can reproduce past experiments exactly. Pair datasets with [scorers](https://mastra.ai/docs/evals/overview) to track quality across prompts, models, or code changes.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
### Configure storage
|
|
10
|
+
|
|
11
|
+
Configure storage in your Mastra instance. Datasets require a storage adapter that provides the `datasets` domain:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Mastra } from "@mastra/core";
|
|
15
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
16
|
+
|
|
17
|
+
export const mastra = new Mastra({
|
|
18
|
+
storage: new LibSQLStore({
|
|
19
|
+
id: "my-store",
|
|
20
|
+
url: "file:./mastra.db",
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Accessing the datasets API
|
|
26
|
+
|
|
27
|
+
All dataset operations are available through `mastra.datasets`:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
const datasets = mastra.datasets;
|
|
31
|
+
|
|
32
|
+
// Create a dataset
|
|
33
|
+
const dataset = await datasets.create({ name: "my-dataset" });
|
|
34
|
+
|
|
35
|
+
// Retrieve an existing dataset
|
|
36
|
+
const existing = await datasets.get({ id: "dataset-id" });
|
|
37
|
+
|
|
38
|
+
// List all datasets
|
|
39
|
+
const { datasets: all } = await datasets.list();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
> **Info:** Visit the [`DatasetsManager` reference](https://mastra.ai/reference/datasets/datasets-manager) for the full list of methods.
|
|
43
|
+
|
|
44
|
+
## Creating a dataset
|
|
45
|
+
|
|
46
|
+
Call [`create()`](https://mastra.ai/reference/datasets/create) with a name and optional description:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { mastra } from "../index";
|
|
50
|
+
|
|
51
|
+
const dataset = await mastra.datasets.create({
|
|
52
|
+
name: "translation-pairs",
|
|
53
|
+
description: "English to Spanish translation test cases",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
console.log(dataset.id); // auto-generated UUID
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Defining schemas
|
|
60
|
+
|
|
61
|
+
You can enforce the shape of `input` and `groundTruth` by passing Zod schemas. Mastra converts them to JSON Schema at creation time:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { z } from "zod";
|
|
65
|
+
import { mastra } from "../index";
|
|
66
|
+
|
|
67
|
+
const dataset = await mastra.datasets.create({
|
|
68
|
+
name: "translation-pairs",
|
|
69
|
+
inputSchema: z.object({
|
|
70
|
+
text: z.string(),
|
|
71
|
+
sourceLang: z.string(),
|
|
72
|
+
targetLang: z.string(),
|
|
73
|
+
}),
|
|
74
|
+
groundTruthSchema: z.object({
|
|
75
|
+
translation: z.string(),
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Items that don't match the schema are rejected at insert time.
|
|
81
|
+
|
|
82
|
+
## Adding items
|
|
83
|
+
|
|
84
|
+
Use [`addItem()`](https://mastra.ai/reference/datasets/addItem) for a single item or [`addItems()`](https://mastra.ai/reference/datasets/addItems) to insert in bulk:
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// Single item
|
|
88
|
+
await dataset.addItem({
|
|
89
|
+
input: { text: "Hello", sourceLang: "en", targetLang: "es" },
|
|
90
|
+
groundTruth: { translation: "Hola" },
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Bulk insert
|
|
94
|
+
await dataset.addItems({
|
|
95
|
+
items: [
|
|
96
|
+
{
|
|
97
|
+
input: { text: "Goodbye", sourceLang: "en", targetLang: "es" },
|
|
98
|
+
groundTruth: { translation: "Adiós" },
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
input: { text: "Thank you", sourceLang: "en", targetLang: "es" },
|
|
102
|
+
groundTruth: { translation: "Gracias" },
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Updating and deleting items
|
|
109
|
+
|
|
110
|
+
[`updateItem()`](https://mastra.ai/reference/datasets/updateItem), [`deleteItem()`](https://mastra.ai/reference/datasets/deleteItem), and [`deleteItems()`](https://mastra.ai/reference/datasets/deleteItems) let you modify or remove existing items by `itemId`:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
await dataset.updateItem({
|
|
114
|
+
itemId: "item-abc-123",
|
|
115
|
+
groundTruth: { translation: "¡Hola!" },
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
await dataset.deleteItem({ itemId: "item-abc-123" });
|
|
119
|
+
|
|
120
|
+
await dataset.deleteItems({ itemIds: ["item-1", "item-2"] });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Listing and searching items
|
|
124
|
+
|
|
125
|
+
[`listItems()`](https://mastra.ai/reference/datasets/listItems) supports pagination and full-text search:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
// Paginated list
|
|
129
|
+
const { items, pagination } = await dataset.listItems({
|
|
130
|
+
page: 0,
|
|
131
|
+
perPage: 50,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Full-text search
|
|
135
|
+
const { items: matches } = await dataset.listItems({
|
|
136
|
+
search: "Hello",
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// List items at a specific version
|
|
140
|
+
const v2Items = await dataset.listItems({ version: 2 });
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Versioning
|
|
144
|
+
|
|
145
|
+
Every mutation to a dataset's items (add, update, or delete) bumps the dataset version. This lets you pin experiments to a specific snapshot of the data.
|
|
146
|
+
|
|
147
|
+
### Listing versions
|
|
148
|
+
|
|
149
|
+
Use [`listVersions()`](https://mastra.ai/reference/datasets/listVersions) to see the paginated history of versions:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const { versions, pagination } = await dataset.listVersions();
|
|
153
|
+
|
|
154
|
+
for (const v of versions) {
|
|
155
|
+
console.log(`Version ${v.version} — created ${v.createdAt}`);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Viewing item history
|
|
160
|
+
|
|
161
|
+
See how a specific item changed across versions by calling [`getItemHistory()`](https://mastra.ai/reference/datasets/getItemHistory) with the `itemId`:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const history = await dataset.getItemHistory({ itemId: "item-abc-123" });
|
|
165
|
+
|
|
166
|
+
for (const row of history) {
|
|
167
|
+
console.log(`Version ${row.datasetVersion}`, row.input, row.groundTruth);
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Pinning to a version
|
|
172
|
+
|
|
173
|
+
Fetch the exact items that existed at a past version:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
const items = await dataset.listItems({ version: 2 });
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
You can also pin experiments to a version, see [running experiments](https://mastra.ai/docs/observability/datasets/running-experiments).
|
|
180
|
+
|
|
181
|
+
> **Info:** Visit the [`Dataset` reference](https://mastra.ai/reference/datasets/dataset) for the full list of methods and parameters.
|
|
182
|
+
|
|
183
|
+
## Related
|
|
184
|
+
|
|
185
|
+
- [Running experiments](https://mastra.ai/docs/observability/datasets/running-experiments)
|
|
186
|
+
- [Scorers overview](https://mastra.ai/docs/evals/overview)
|
|
187
|
+
- [DatasetsManager reference](https://mastra.ai/reference/datasets/datasets-manager)
|
|
188
|
+
- [Dataset reference](https://mastra.ai/reference/datasets/dataset)
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Running Experiments
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.4.0`
|
|
4
|
+
|
|
5
|
+
An experiment runs every item in a dataset through a target (an agent, a workflow, or a scorer) and then optionally scores the outputs. Use a scorer as the target when you want to evaluate an LLM judge itself. Results are persisted to storage so you can compare runs across different prompts, models, or code changes.
|
|
6
|
+
|
|
7
|
+
## Basic experiment
|
|
8
|
+
|
|
9
|
+
Call [`startExperiment()`](https://mastra.ai/reference/datasets/startExperiment) with a target and scorers:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { mastra } from "../index";
|
|
13
|
+
|
|
14
|
+
const dataset = await mastra.datasets.get({ id: "translation-dataset-id" });
|
|
15
|
+
|
|
16
|
+
const summary = await dataset.startExperiment({
|
|
17
|
+
name: "gpt-5.1-baseline",
|
|
18
|
+
targetType: "agent",
|
|
19
|
+
targetId: "translation-agent",
|
|
20
|
+
scorers: ["accuracy", "fluency"],
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log(summary.status); // 'completed' | 'failed'
|
|
24
|
+
console.log(summary.succeededCount); // number of items that ran successfully
|
|
25
|
+
console.log(summary.failedCount); // number of items that failed
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`startExperiment()` blocks until all items finish. For fire-and-forget execution, see [async experiments](#async-experiments).
|
|
29
|
+
|
|
30
|
+
## Experiment targets
|
|
31
|
+
|
|
32
|
+
You can point an experiment at a registered agent, workflow, or scorer.
|
|
33
|
+
|
|
34
|
+
### Registered agent
|
|
35
|
+
|
|
36
|
+
Point to an agent registered on your Mastra instance:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const summary = await dataset.startExperiment({
|
|
40
|
+
name: "agent-v2-eval",
|
|
41
|
+
targetType: "agent",
|
|
42
|
+
targetId: "translation-agent",
|
|
43
|
+
scorers: ["accuracy"],
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Each item's `input` is passed directly to `agent.generate()`, so it must be a `string`, `string[]`, or `CoreMessage[]`.
|
|
48
|
+
|
|
49
|
+
### Registered workflow
|
|
50
|
+
|
|
51
|
+
Point to a workflow registered on your Mastra instance:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const summary = await dataset.startExperiment({
|
|
55
|
+
name: "workflow-eval",
|
|
56
|
+
targetType: "workflow",
|
|
57
|
+
targetId: "translation-workflow",
|
|
58
|
+
scorers: ["accuracy"],
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The workflow receives each item's `input` as its trigger data.
|
|
63
|
+
|
|
64
|
+
### Registered scorer
|
|
65
|
+
|
|
66
|
+
Point to a scorer to evaluate an LLM judge against ground truth:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const summary = await dataset.startExperiment({
|
|
70
|
+
name: "judge-accuracy-eval",
|
|
71
|
+
targetType: "scorer",
|
|
72
|
+
targetId: "accuracy",
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The scorer receives each item's `input` and `groundTruth`. LLM-based judges can drift over time as underlying models change, so it's important to periodically realign them against known-good labels. A dataset gives you a stable benchmark to detect that drift.
|
|
77
|
+
|
|
78
|
+
## Scoring results
|
|
79
|
+
|
|
80
|
+
Scorers automatically run after each item's target execution. Pass scorer instances or registered scorer IDs:
|
|
81
|
+
|
|
82
|
+
**Scorer IDs**:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// Reference scorers registered on the Mastra instance
|
|
86
|
+
const summary = await dataset.startExperiment({
|
|
87
|
+
name: "with-registered-scorers",
|
|
88
|
+
targetType: "agent",
|
|
89
|
+
targetId: "translation-agent",
|
|
90
|
+
scorers: ["accuracy", "fluency"],
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Scorer instances**:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { createAnswerRelevancyScorer } from "@mastra/evals/scorers/prebuilt";
|
|
98
|
+
|
|
99
|
+
const relevancy = createAnswerRelevancyScorer({ model: "openai/gpt-4.1-nano" });
|
|
100
|
+
|
|
101
|
+
const summary = await dataset.startExperiment({
|
|
102
|
+
name: "with-scorer-instances",
|
|
103
|
+
targetType: "agent",
|
|
104
|
+
targetId: "translation-agent",
|
|
105
|
+
scorers: [relevancy],
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Each item's results include per-scorer scores:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
for (const item of summary.results) {
|
|
113
|
+
console.log(item.itemId, item.output);
|
|
114
|
+
for (const score of item.scores) {
|
|
115
|
+
console.log(` ${score.scorerName}: ${score.score} — ${score.reason}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
> **Info:** Visit the [Scorers overview](https://mastra.ai/docs/evals/overview) for details on available and custom scorers.
|
|
121
|
+
|
|
122
|
+
## Async experiments
|
|
123
|
+
|
|
124
|
+
`startExperiment()` blocks until every item completes. For long-running datasets, use [`startExperimentAsync()`](https://mastra.ai/reference/datasets/startExperimentAsync) to start the experiment in the background:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
const { experimentId, status } = await dataset.startExperimentAsync({
|
|
128
|
+
name: "large-dataset-run",
|
|
129
|
+
targetType: "agent",
|
|
130
|
+
targetId: "translation-agent",
|
|
131
|
+
scorers: ["accuracy"],
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
console.log(experimentId); // UUID
|
|
135
|
+
console.log(status); // 'pending'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Poll for completion using [`getExperiment()`](https://mastra.ai/reference/datasets/getExperiment):
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
let experiment = await dataset.getExperiment({ experimentId });
|
|
142
|
+
|
|
143
|
+
while (experiment.status === "pending" || experiment.status === "running") {
|
|
144
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
145
|
+
experiment = await dataset.getExperiment({ experimentId });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
console.log(experiment.status); // 'completed' | 'failed'
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Configuration options
|
|
152
|
+
|
|
153
|
+
### Concurrency
|
|
154
|
+
|
|
155
|
+
Control how many items run in parallel (default: 5):
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
const summary = await dataset.startExperiment({
|
|
159
|
+
targetType: "agent",
|
|
160
|
+
targetId: "translation-agent",
|
|
161
|
+
maxConcurrency: 10,
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Timeouts and retries
|
|
166
|
+
|
|
167
|
+
Set a per-item timeout (in milliseconds) and retry count:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const summary = await dataset.startExperiment({
|
|
171
|
+
targetType: "agent",
|
|
172
|
+
targetId: "translation-agent",
|
|
173
|
+
itemTimeout: 30_000, // 30 seconds per item
|
|
174
|
+
maxRetries: 2, // retry failed items up to 2 times
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Retries use exponential backoff. Abort errors are never retried.
|
|
179
|
+
|
|
180
|
+
### Aborting an experiment
|
|
181
|
+
|
|
182
|
+
Pass an `AbortSignal` to cancel a running experiment:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
const controller = new AbortController();
|
|
186
|
+
|
|
187
|
+
// Cancel after 60 seconds
|
|
188
|
+
setTimeout(() => controller.abort(), 60_000);
|
|
189
|
+
|
|
190
|
+
const summary = await dataset.startExperiment({
|
|
191
|
+
targetType: "agent",
|
|
192
|
+
targetId: "translation-agent",
|
|
193
|
+
signal: controller.signal,
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Remaining items are marked as skipped in the summary.
|
|
198
|
+
|
|
199
|
+
### Pinning a dataset version
|
|
200
|
+
|
|
201
|
+
Run against a specific snapshot of the dataset:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
const summary = await dataset.startExperiment({
|
|
205
|
+
targetType: "agent",
|
|
206
|
+
targetId: "translation-agent",
|
|
207
|
+
version: 3, // use items from dataset version 3
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Viewing results
|
|
212
|
+
|
|
213
|
+
### Listing experiments
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
const { experiments, pagination } = await dataset.listExperiments({
|
|
217
|
+
page: 0,
|
|
218
|
+
perPage: 10,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
for (const exp of experiments) {
|
|
222
|
+
console.log(`${exp.name} — ${exp.status} (${exp.succeededCount}/${exp.totalItems})`);
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Experiment details
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
const experiment = await dataset.getExperiment({
|
|
230
|
+
experimentId: "exp-abc-123",
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
console.log(experiment.status);
|
|
234
|
+
console.log(experiment.startedAt);
|
|
235
|
+
console.log(experiment.completedAt);
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Item-level results
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
const { results, pagination } = await dataset.listExperimentResults({
|
|
242
|
+
experimentId: "exp-abc-123",
|
|
243
|
+
page: 0,
|
|
244
|
+
perPage: 50,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
for (const result of results) {
|
|
248
|
+
console.log(result.itemId, result.output, result.error);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Understanding the summary
|
|
253
|
+
|
|
254
|
+
`startExperiment()` returns an `ExperimentSummary` with counts and per-item results:
|
|
255
|
+
|
|
256
|
+
- `completedWithErrors` is `true` when the experiment finished but some items failed.
|
|
257
|
+
- Items cancelled via `signal` appear in `skippedCount`.
|
|
258
|
+
|
|
259
|
+
> **Info:** Visit the [`startExperiment` reference](https://mastra.ai/reference/datasets/startExperiment) for the full parameter and return type documentation.
|
|
260
|
+
|
|
261
|
+
## Related
|
|
262
|
+
|
|
263
|
+
- [Datasets overview](https://mastra.ai/docs/observability/datasets/overview)
|
|
264
|
+
- [Scorers overview](https://mastra.ai/docs/evals/overview)
|
|
265
|
+
- [`startExperiment` reference](https://mastra.ai/reference/datasets/startExperiment)
|
|
266
|
+
- [`listExperimentResults` reference](https://mastra.ai/reference/datasets/listExperimentResults)
|
|
@@ -7,8 +7,9 @@ The `CloudExporter` sends traces to Mastra Cloud for centralized monitoring and
|
|
|
7
7
|
### Prerequisites
|
|
8
8
|
|
|
9
9
|
1. **Mastra Cloud Account**: Sign up at [cloud.mastra.ai](https://cloud.mastra.ai)
|
|
10
|
-
2. **
|
|
11
|
-
3. **
|
|
10
|
+
2. **Mastra Cloud Project**: Create a project in Mastra Cloud. Traces are scoped per project, so even if you only want observability, you need a project to act as the destination for your traces.
|
|
11
|
+
3. **Access Token**: Generate in your project's sidebar under **Project Settings → Access Tokens**
|
|
12
|
+
4. **Environment Variables**: Set your credentials:
|
|
12
13
|
|
|
13
14
|
```bash
|
|
14
15
|
MASTRA_CLOUD_ACCESS_TOKEN=mst_xxxxxxxxxxxxxxxx
|
|
@@ -90,9 +91,9 @@ new CloudExporter({
|
|
|
90
91
|
|
|
91
92
|
1. Navigate to [cloud.mastra.ai](https://cloud.mastra.ai)
|
|
92
93
|
|
|
93
|
-
2. Select your
|
|
94
|
+
2. Select the project associated with your access token
|
|
94
95
|
|
|
95
|
-
3. Go to Observability → Traces
|
|
96
|
+
3. Go to **Observability → Traces**
|
|
96
97
|
|
|
97
98
|
4. Use filters to find specific traces:
|
|
98
99
|
|
|
@@ -101,6 +102,8 @@ new CloudExporter({
|
|
|
101
102
|
- Trace ID
|
|
102
103
|
- Error status
|
|
103
104
|
|
|
105
|
+
> **Note:** Traces are scoped to the project that issued the access token. To view traces, make sure you're viewing the same project you generated the token from.
|
|
106
|
+
|
|
104
107
|
### Features
|
|
105
108
|
|
|
106
109
|
- **Trace Timeline** - Visual execution flow
|
|
@@ -55,7 +55,7 @@ console.log(`Remaining requests: ${remainingRequests}, Remaining tokens: ${remai
|
|
|
55
55
|
|
|
56
56
|
**stopWhen?:** (`LoopOptions['stopWhen']`): Conditions for stopping execution (e.g., step count, token limit).
|
|
57
57
|
|
|
58
|
-
**scorers?:** (`MastraScorers | Record<string, { scorer: MastraScorer['name']; sampling?: ScoringSamplingConfig }>`): scorer:stringName of the scorer to use.sampling?:ScoringSamplingConfigSampling configuration for the scorer.
|
|
58
|
+
**scorers?:** (`MastraScorers | Record<string, { scorer: MastraScorer['name']; sampling?: ScoringSamplingConfig }>`): scorer:stringName of the scorer to use.sampling?:ScoringSamplingConfigSampling configuration for the scorer.type:'none' | 'ratio'Type of sampling strategy. Use 'none' to disable sampling or 'ratio' for percentage-based sampling.rate?:numberSampling rate (0-1). Required when type is 'ratio'.
|
|
59
59
|
|
|
60
60
|
**returnScorerData?:** (`boolean`): Whether to return detailed scoring data in the response.
|
|
61
61
|
|
|
@@ -49,10 +49,7 @@ import { Mastra } from "@mastra/core";
|
|
|
49
49
|
import { NetlifyDeployer } from "@mastra/deployer-netlify";
|
|
50
50
|
|
|
51
51
|
export const mastra = new Mastra({
|
|
52
|
-
deployer: new NetlifyDeployer(
|
|
53
|
-
scope: "your-team",
|
|
54
|
-
siteId: "your-site-id",
|
|
55
|
-
}),
|
|
52
|
+
deployer: new NetlifyDeployer(),
|
|
56
53
|
});
|
|
57
54
|
```
|
|
58
55
|
|
|
@@ -673,6 +670,8 @@ export const mastra = new Mastra({
|
|
|
673
670
|
|
|
674
671
|
Custom error handler called when an unhandled error occurs. Use this to customize error responses, log errors to external services like Sentry, or implement custom error formatting.
|
|
675
672
|
|
|
673
|
+
This hook is supported by all server adapters. The `c` parameter provides a Hono-compatible context object — for non-Hono adapters (Koa, Express, Fastify), a shim is provided with commonly used methods like `c.json()` and `c.req.path`.
|
|
674
|
+
|
|
676
675
|
```typescript
|
|
677
676
|
import { Mastra } from "@mastra/core";
|
|
678
677
|
import * as Sentry from "@sentry/node";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# dataset.addItem()
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.4.0`
|
|
4
|
+
|
|
5
|
+
Adds a single item to the dataset. Each item has an input, optional ground truth, and optional metadata.
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Mastra } from "@mastra/core";
|
|
11
|
+
|
|
12
|
+
const mastra = new Mastra({ /* storage config */ });
|
|
13
|
+
|
|
14
|
+
const dataset = await mastra.datasets.get({ id: "dataset-id" });
|
|
15
|
+
|
|
16
|
+
const item = await dataset.addItem({
|
|
17
|
+
input: { question: "What is TypeScript?" },
|
|
18
|
+
groundTruth: { answer: "A typed superset of JavaScript" },
|
|
19
|
+
metadata: { source: "manual" },
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
console.log(item.id);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Parameters
|
|
26
|
+
|
|
27
|
+
**input:** (`unknown`): Input data for the item.
|
|
28
|
+
|
|
29
|
+
**groundTruth?:** (`unknown`): Expected output or ground truth for scoring.
|
|
30
|
+
|
|
31
|
+
**metadata?:** (`Record<string, unknown>`): Arbitrary metadata for the item.
|
|
32
|
+
|
|
33
|
+
## Returns
|
|
34
|
+
|
|
35
|
+
**result:** (`Promise<DatasetItem>`): DatasetItemid:stringUnique identifier of the item.datasetId:stringID of the parent dataset.datasetVersion:numberDataset version when the item was created.input:unknownInput data.groundTruth?:unknownGround truth data.metadata?:Record\<string, unknown>Item metadata.createdAt:DateWhen the item was created.updatedAt:DateWhen the item was last updated.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# dataset.addItems()
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.4.0`
|
|
4
|
+
|
|
5
|
+
Adds multiple items to the dataset in a single bulk operation.
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Mastra } from "@mastra/core";
|
|
11
|
+
|
|
12
|
+
const mastra = new Mastra({ /* storage config */ });
|
|
13
|
+
|
|
14
|
+
const dataset = await mastra.datasets.get({ id: "dataset-id" });
|
|
15
|
+
|
|
16
|
+
const items = await dataset.addItems({
|
|
17
|
+
items: [
|
|
18
|
+
{ input: { question: "What is AI?" }, groundTruth: { answer: "Artificial Intelligence" } },
|
|
19
|
+
{ input: { question: "What is ML?" }, groundTruth: { answer: "Machine Learning" } },
|
|
20
|
+
{ input: { question: "What is DL?" }, metadata: { category: "deep-learning" } },
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log(`Added ${items.length} items`);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
**items:** (`Array<object>`): DatasetIteminput:unknownInput data for the item.groundTruth?:unknownExpected output or ground truth.metadata?:Record\<string, unknown>Arbitrary metadata.
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
**result:** (`Promise<DatasetItem[]>`): Array of created dataset items. See dataset.addItem() for the item shape.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# DatasetsManager.compareExperiments()
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.4.0`
|
|
4
|
+
|
|
5
|
+
Compares two or more experiments, producing per-item and per-scorer comparisons. Requires at least two experiment IDs.
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Mastra } from "@mastra/core";
|
|
11
|
+
|
|
12
|
+
const mastra = new Mastra({ /* storage config */ });
|
|
13
|
+
|
|
14
|
+
const comparison = await mastra.datasets.compareExperiments({
|
|
15
|
+
experimentIds: ["exp-baseline", "exp-new"],
|
|
16
|
+
baselineId: "exp-baseline",
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
console.log(`Baseline: ${comparison.baselineId}`);
|
|
20
|
+
|
|
21
|
+
for (const item of comparison.items) {
|
|
22
|
+
console.log(`Item ${item.itemId}:`);
|
|
23
|
+
console.log(` Input: ${JSON.stringify(item.input)}`);
|
|
24
|
+
|
|
25
|
+
for (const [expId, result] of Object.entries(item.results)) {
|
|
26
|
+
if (result) {
|
|
27
|
+
console.log(` ${expId}: output=${JSON.stringify(result.output)}, scores=${JSON.stringify(result.scores)}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Parameters
|
|
34
|
+
|
|
35
|
+
**experimentIds:** (`string[]`): Array of experiment IDs to compare. Must contain at least 2.
|
|
36
|
+
|
|
37
|
+
**baselineId?:** (`string`): ID of the baseline experiment. Defaults to the first ID in \`experimentIds\`.
|
|
38
|
+
|
|
39
|
+
## Returns
|
|
40
|
+
|
|
41
|
+
Throws `MastraError` if fewer than 2 experiment IDs are provided.
|
|
42
|
+
|
|
43
|
+
**result:** (`Promise<object>`): objectbaselineId:stringID of the baseline experiment used for comparison.items:Array\<object>Per-item comparison data.objectitemId:stringID of the dataset item.input:unknown | nullInput data for the item.groundTruth:unknown | nullGround truth for the item.results:Record\<string, { output: unknown; scores: Record\<string, number | null> } | null>Results keyed by experiment ID. Each entry contains the output and scorer results for that experiment.
|
|
44
|
+
|
|
45
|
+
## Related
|
|
46
|
+
|
|
47
|
+
- [dataset.startExperiment()](https://mastra.ai/reference/datasets/startExperiment)
|
|
48
|
+
- [dataset.listExperiments()](https://mastra.ai/reference/datasets/listExperiments)
|