@mastra/core 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +236 -0
- package/dist/agent/agent.d.ts +6 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-VJWRJWSC.cjs → chunk-2X66GWF5.cjs} +94 -16
- package/dist/chunk-2X66GWF5.cjs.map +1 -0
- package/dist/{chunk-YM6245EM.js → chunk-6OXW5E2O.js} +3 -3
- package/dist/{chunk-YM6245EM.js.map → chunk-6OXW5E2O.js.map} +1 -1
- package/dist/{chunk-XWZAKKFT.cjs → chunk-6QBN6MZY.cjs} +14 -14
- package/dist/{chunk-XWZAKKFT.cjs.map → chunk-6QBN6MZY.cjs.map} +1 -1
- package/dist/{chunk-AYHSPIT6.cjs → chunk-7UAJ6LMR.cjs} +820 -259
- package/dist/chunk-7UAJ6LMR.cjs.map +1 -0
- package/dist/{chunk-RZNHRIM7.cjs → chunk-A72NTLFT.cjs} +5 -5
- package/dist/{chunk-RZNHRIM7.cjs.map → chunk-A72NTLFT.cjs.map} +1 -1
- package/dist/{chunk-EEU5NHHU.js → chunk-DFCRXDVK.js} +3 -3
- package/dist/{chunk-EEU5NHHU.js.map → chunk-DFCRXDVK.js.map} +1 -1
- package/dist/{chunk-5K45E5VE.js → chunk-GPJGPARM.js} +3 -2
- package/dist/chunk-GPJGPARM.js.map +1 -0
- package/dist/{chunk-LNKS4TJ6.cjs → chunk-HB6T4554.cjs} +8 -7
- package/dist/chunk-HB6T4554.cjs.map +1 -0
- package/dist/{chunk-DGS2KGDI.js → chunk-KUXNBWN7.js} +6 -5
- package/dist/chunk-KUXNBWN7.js.map +1 -0
- package/dist/{chunk-IHDE4CJV.js → chunk-QSHV7GPT.js} +89 -12
- package/dist/chunk-QSHV7GPT.js.map +1 -0
- package/dist/{chunk-3U3XFMGJ.cjs → chunk-QTAS3HND.cjs} +13 -8
- package/dist/chunk-QTAS3HND.cjs.map +1 -0
- package/dist/{chunk-RHKNKJNM.js → chunk-QWTB53GS.js} +4 -4
- package/dist/{chunk-RHKNKJNM.js.map → chunk-QWTB53GS.js.map} +1 -1
- package/dist/{chunk-4WG5K4CK.js → chunk-R4N65TLG.js} +7 -7
- package/dist/{chunk-4WG5K4CK.js.map → chunk-R4N65TLG.js.map} +1 -1
- package/dist/{chunk-5VQPSWPG.cjs → chunk-RABITNTG.cjs} +48 -48
- package/dist/{chunk-5VQPSWPG.cjs.map → chunk-RABITNTG.cjs.map} +1 -1
- package/dist/{chunk-TVPANHLE.cjs → chunk-SBOHDNIZ.cjs} +3 -2
- package/dist/chunk-SBOHDNIZ.cjs.map +1 -0
- package/dist/{chunk-MWGGSA5Q.js → chunk-T6GAM3SQ.js} +10 -5
- package/dist/chunk-T6GAM3SQ.js.map +1 -0
- package/dist/{chunk-TL2TTA4X.cjs → chunk-YQG7NBPR.cjs} +9 -9
- package/dist/{chunk-TL2TTA4X.cjs.map → chunk-YQG7NBPR.cjs.map} +1 -1
- package/dist/{chunk-XB3DA67Q.js → chunk-ZSBM2SVU.js} +818 -259
- package/dist/chunk-ZSBM2SVU.js.map +1 -0
- package/dist/datasets/experiment/scorer.d.ts.map +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +7 -6
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +4 -3
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/harness/harness.d.ts +21 -1
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/index.cjs +422 -5
- package/dist/harness/index.cjs.map +1 -1
- package/dist/harness/index.d.ts +2 -1
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +418 -3
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/types.d.ts +151 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +45 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/processors/index.d.ts +1 -0
- package/dist/processors/processors/index.d.ts.map +1 -1
- package/dist/processors/processors/workspace-instructions.d.ts +50 -0
- package/dist/processors/processors/workspace-instructions.d.ts.map +1 -0
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +56 -56
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/index.cjs +160 -160
- package/dist/storage/index.js +2 -2
- package/dist/storage/types.d.ts +2 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- 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/vector/index.cjs +7 -7
- package/dist/vector/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 +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workspace/constants/index.d.ts +2 -0
- package/dist/workspace/constants/index.d.ts.map +1 -1
- package/dist/workspace/errors.d.ts +1 -1
- package/dist/workspace/errors.d.ts.map +1 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts +4 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/file-write-lock.d.ts +35 -0
- package/dist/workspace/filesystem/file-write-lock.d.ts.map +1 -0
- package/dist/workspace/filesystem/filesystem.d.ts +5 -1
- package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/index.d.ts +1 -0
- package/dist/workspace/filesystem/index.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +17 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/index.cjs +72 -64
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/lifecycle.d.ts +1 -9
- package/dist/workspace/lifecycle.d.ts.map +1 -1
- package/dist/workspace/sandbox/index.d.ts +2 -0
- package/dist/workspace/sandbox/index.d.ts.map +1 -1
- package/dist/workspace/sandbox/local-process-manager.d.ts +18 -0
- package/dist/workspace/sandbox/local-process-manager.d.ts.map +1 -0
- package/dist/workspace/sandbox/local-sandbox.d.ts +49 -35
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +45 -11
- package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/bubblewrap.d.ts +2 -3
- package/dist/workspace/sandbox/native-sandbox/bubblewrap.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/seatbelt.d.ts +2 -3
- package/dist/workspace/sandbox/native-sandbox/seatbelt.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/wrapper.d.ts +4 -5
- package/dist/workspace/sandbox/native-sandbox/wrapper.d.ts.map +1 -1
- package/dist/workspace/sandbox/process-manager/index.d.ts +4 -0
- package/dist/workspace/sandbox/process-manager/index.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/process-handle.d.ts +107 -0
- package/dist/workspace/sandbox/process-manager/process-handle.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/process-manager.d.ts +59 -0
- package/dist/workspace/sandbox/process-manager/process-manager.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/types.d.ts +24 -0
- package/dist/workspace/sandbox/process-manager/types.d.ts.map +1 -0
- package/dist/workspace/sandbox/sandbox.d.ts +38 -2
- package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/types.d.ts +9 -2
- package/dist/workspace/sandbox/types.d.ts.map +1 -1
- package/dist/workspace/sandbox/utils.d.ts +7 -0
- package/dist/workspace/sandbox/utils.d.ts.map +1 -0
- package/dist/workspace/tools/execute-command.d.ts +53 -2
- package/dist/workspace/tools/execute-command.d.ts.map +1 -1
- package/dist/workspace/tools/get-process-output.d.ts +6 -0
- package/dist/workspace/tools/get-process-output.d.ts.map +1 -0
- package/dist/workspace/tools/index.d.ts +4 -1
- package/dist/workspace/tools/index.d.ts.map +1 -1
- package/dist/workspace/tools/kill-process.d.ts +4 -0
- package/dist/workspace/tools/kill-process.d.ts.map +1 -0
- package/dist/workspace/tools/output-helpers.d.ts +21 -0
- package/dist/workspace/tools/output-helpers.d.ts.map +1 -0
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/dist/workspace/types.d.ts +31 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/utils.d.ts +11 -0
- package/dist/workspace/utils.d.ts.map +1 -0
- package/dist/workspace/workspace.d.ts +36 -0
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-3U3XFMGJ.cjs.map +0 -1
- package/dist/chunk-5K45E5VE.js.map +0 -1
- package/dist/chunk-AYHSPIT6.cjs.map +0 -1
- package/dist/chunk-DGS2KGDI.js.map +0 -1
- package/dist/chunk-IHDE4CJV.js.map +0 -1
- package/dist/chunk-LNKS4TJ6.cjs.map +0 -1
- package/dist/chunk-MWGGSA5Q.js.map +0 -1
- package/dist/chunk-TVPANHLE.cjs.map +0 -1
- package/dist/chunk-VJWRJWSC.cjs.map +0 -1
- package/dist/chunk-XB3DA67Q.js.map +0 -1
- package/dist/docs/SKILL.md +0 -301
- package/dist/docs/assets/SOURCE_MAP.json +0 -1413
- package/dist/docs/references/docs-agents-adding-voice.md +0 -353
- package/dist/docs/references/docs-agents-agent-approval.md +0 -377
- package/dist/docs/references/docs-agents-agent-memory.md +0 -212
- package/dist/docs/references/docs-agents-guardrails.md +0 -382
- package/dist/docs/references/docs-agents-network-approval.md +0 -275
- package/dist/docs/references/docs-agents-networks.md +0 -290
- package/dist/docs/references/docs-agents-overview.md +0 -309
- package/dist/docs/references/docs-agents-processors.md +0 -632
- package/dist/docs/references/docs-agents-structured-output.md +0 -271
- package/dist/docs/references/docs-agents-using-tools.md +0 -214
- package/dist/docs/references/docs-evals-custom-scorers.md +0 -519
- package/dist/docs/references/docs-evals-overview.md +0 -146
- package/dist/docs/references/docs-evals-running-in-ci.md +0 -106
- package/dist/docs/references/docs-mcp-overview.md +0 -370
- package/dist/docs/references/docs-mcp-publishing-mcp-server.md +0 -95
- package/dist/docs/references/docs-memory-memory-processors.md +0 -316
- package/dist/docs/references/docs-memory-observational-memory.md +0 -246
- package/dist/docs/references/docs-memory-overview.md +0 -45
- package/dist/docs/references/docs-memory-semantic-recall.md +0 -272
- package/dist/docs/references/docs-memory-storage.md +0 -261
- package/dist/docs/references/docs-memory-working-memory.md +0 -400
- package/dist/docs/references/docs-observability-datasets-overview.md +0 -188
- package/dist/docs/references/docs-observability-datasets-running-experiments.md +0 -266
- package/dist/docs/references/docs-observability-logging.md +0 -99
- package/dist/docs/references/docs-observability-overview.md +0 -70
- package/dist/docs/references/docs-observability-tracing-bridges-otel.md +0 -209
- package/dist/docs/references/docs-observability-tracing-exporters-arize.md +0 -274
- package/dist/docs/references/docs-observability-tracing-exporters-braintrust.md +0 -111
- package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +0 -129
- package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +0 -187
- package/dist/docs/references/docs-observability-tracing-exporters-default.md +0 -211
- package/dist/docs/references/docs-observability-tracing-exporters-laminar.md +0 -100
- package/dist/docs/references/docs-observability-tracing-exporters-langfuse.md +0 -217
- package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +0 -202
- package/dist/docs/references/docs-observability-tracing-exporters-otel.md +0 -479
- package/dist/docs/references/docs-observability-tracing-exporters-posthog.md +0 -148
- package/dist/docs/references/docs-observability-tracing-overview.md +0 -1114
- package/dist/docs/references/docs-rag-chunking-and-embedding.md +0 -183
- package/dist/docs/references/docs-rag-graph-rag.md +0 -215
- package/dist/docs/references/docs-rag-overview.md +0 -72
- package/dist/docs/references/docs-rag-retrieval.md +0 -521
- package/dist/docs/references/docs-rag-vector-databases.md +0 -648
- package/dist/docs/references/docs-server-auth-auth0.md +0 -222
- package/dist/docs/references/docs-server-auth-clerk.md +0 -132
- package/dist/docs/references/docs-server-auth-composite-auth.md +0 -234
- package/dist/docs/references/docs-server-auth-custom-auth-provider.md +0 -513
- package/dist/docs/references/docs-server-auth-firebase.md +0 -272
- package/dist/docs/references/docs-server-auth-jwt.md +0 -110
- package/dist/docs/references/docs-server-auth-simple-auth.md +0 -178
- package/dist/docs/references/docs-server-auth-supabase.md +0 -117
- package/dist/docs/references/docs-server-auth-workos.md +0 -190
- package/dist/docs/references/docs-server-custom-adapters.md +0 -374
- package/dist/docs/references/docs-server-custom-api-routes.md +0 -267
- package/dist/docs/references/docs-server-mastra-client.md +0 -243
- package/dist/docs/references/docs-server-mastra-server.md +0 -71
- package/dist/docs/references/docs-server-middleware.md +0 -228
- package/dist/docs/references/docs-server-request-context.md +0 -478
- package/dist/docs/references/docs-streaming-events.md +0 -247
- package/dist/docs/references/docs-streaming-tool-streaming.md +0 -178
- package/dist/docs/references/docs-streaming-workflow-streaming.md +0 -109
- package/dist/docs/references/docs-voice-overview.md +0 -979
- package/dist/docs/references/docs-voice-speech-to-speech.md +0 -103
- package/dist/docs/references/docs-voice-speech-to-text.md +0 -80
- package/dist/docs/references/docs-voice-text-to-speech.md +0 -84
- package/dist/docs/references/docs-workflows-agents-and-tools.md +0 -170
- package/dist/docs/references/docs-workflows-control-flow.md +0 -823
- package/dist/docs/references/docs-workflows-error-handling.md +0 -360
- package/dist/docs/references/docs-workflows-human-in-the-loop.md +0 -213
- package/dist/docs/references/docs-workflows-overview.md +0 -372
- package/dist/docs/references/docs-workflows-snapshots.md +0 -238
- package/dist/docs/references/docs-workflows-suspend-and-resume.md +0 -205
- package/dist/docs/references/docs-workflows-time-travel.md +0 -309
- package/dist/docs/references/docs-workflows-workflow-state.md +0 -181
- package/dist/docs/references/docs-workspace-filesystem.md +0 -162
- package/dist/docs/references/docs-workspace-overview.md +0 -239
- package/dist/docs/references/docs-workspace-sandbox.md +0 -63
- package/dist/docs/references/docs-workspace-search.md +0 -219
- package/dist/docs/references/docs-workspace-skills.md +0 -126
- package/dist/docs/references/guides-agent-frameworks-ai-sdk.md +0 -140
- package/dist/docs/references/reference-agents-agent.md +0 -142
- package/dist/docs/references/reference-agents-generate.md +0 -174
- package/dist/docs/references/reference-agents-generateLegacy.md +0 -176
- package/dist/docs/references/reference-agents-getDefaultGenerateOptions.md +0 -36
- package/dist/docs/references/reference-agents-getDefaultOptions.md +0 -34
- package/dist/docs/references/reference-agents-getDefaultStreamOptions.md +0 -36
- package/dist/docs/references/reference-agents-getDescription.md +0 -21
- package/dist/docs/references/reference-agents-getInstructions.md +0 -34
- package/dist/docs/references/reference-agents-getLLM.md +0 -37
- package/dist/docs/references/reference-agents-getMemory.md +0 -34
- package/dist/docs/references/reference-agents-getModel.md +0 -34
- package/dist/docs/references/reference-agents-getTools.md +0 -29
- package/dist/docs/references/reference-agents-getVoice.md +0 -34
- package/dist/docs/references/reference-agents-listAgents.md +0 -35
- package/dist/docs/references/reference-agents-listScorers.md +0 -34
- package/dist/docs/references/reference-agents-listTools.md +0 -34
- package/dist/docs/references/reference-agents-listWorkflows.md +0 -34
- package/dist/docs/references/reference-agents-network.md +0 -134
- package/dist/docs/references/reference-ai-sdk-chat-route.md +0 -82
- package/dist/docs/references/reference-ai-sdk-network-route.md +0 -74
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-stream.md +0 -232
- package/dist/docs/references/reference-ai-sdk-with-mastra.md +0 -59
- package/dist/docs/references/reference-ai-sdk-workflow-route.md +0 -79
- package/dist/docs/references/reference-auth-auth0.md +0 -73
- package/dist/docs/references/reference-auth-clerk.md +0 -36
- package/dist/docs/references/reference-auth-firebase.md +0 -80
- package/dist/docs/references/reference-auth-jwt.md +0 -26
- package/dist/docs/references/reference-auth-supabase.md +0 -33
- package/dist/docs/references/reference-auth-workos.md +0 -84
- package/dist/docs/references/reference-client-js-agents.md +0 -438
- package/dist/docs/references/reference-configuration.md +0 -749
- package/dist/docs/references/reference-core-addGateway.md +0 -42
- package/dist/docs/references/reference-core-getAgent.md +0 -21
- package/dist/docs/references/reference-core-getAgentById.md +0 -21
- package/dist/docs/references/reference-core-getDeployer.md +0 -22
- package/dist/docs/references/reference-core-getGateway.md +0 -38
- package/dist/docs/references/reference-core-getGatewayById.md +0 -41
- package/dist/docs/references/reference-core-getLogger.md +0 -22
- package/dist/docs/references/reference-core-getMCPServer.md +0 -45
- package/dist/docs/references/reference-core-getMCPServerById.md +0 -53
- package/dist/docs/references/reference-core-getMemory.md +0 -50
- package/dist/docs/references/reference-core-getScorer.md +0 -54
- package/dist/docs/references/reference-core-getScorerById.md +0 -54
- package/dist/docs/references/reference-core-getServer.md +0 -22
- package/dist/docs/references/reference-core-getStorage.md +0 -22
- package/dist/docs/references/reference-core-getStoredAgentById.md +0 -89
- package/dist/docs/references/reference-core-getTelemetry.md +0 -22
- package/dist/docs/references/reference-core-getVector.md +0 -22
- package/dist/docs/references/reference-core-getWorkflow.md +0 -40
- package/dist/docs/references/reference-core-listAgents.md +0 -21
- package/dist/docs/references/reference-core-listGateways.md +0 -40
- package/dist/docs/references/reference-core-listLogs.md +0 -38
- package/dist/docs/references/reference-core-listLogsByRunId.md +0 -36
- package/dist/docs/references/reference-core-listMCPServers.md +0 -51
- package/dist/docs/references/reference-core-listMemory.md +0 -56
- package/dist/docs/references/reference-core-listScorers.md +0 -29
- package/dist/docs/references/reference-core-listStoredAgents.md +0 -93
- package/dist/docs/references/reference-core-listVectors.md +0 -22
- package/dist/docs/references/reference-core-listWorkflows.md +0 -21
- package/dist/docs/references/reference-core-mastra-class.md +0 -66
- package/dist/docs/references/reference-core-mastra-model-gateway.md +0 -153
- package/dist/docs/references/reference-core-setLogger.md +0 -26
- package/dist/docs/references/reference-core-setStorage.md +0 -27
- package/dist/docs/references/reference-datasets-addItem.md +0 -35
- package/dist/docs/references/reference-datasets-addItems.md +0 -33
- package/dist/docs/references/reference-datasets-compareExperiments.md +0 -48
- package/dist/docs/references/reference-datasets-create.md +0 -49
- package/dist/docs/references/reference-datasets-dataset.md +0 -78
- package/dist/docs/references/reference-datasets-datasets-manager.md +0 -84
- package/dist/docs/references/reference-datasets-delete.md +0 -23
- package/dist/docs/references/reference-datasets-deleteExperiment.md +0 -25
- package/dist/docs/references/reference-datasets-deleteItem.md +0 -25
- package/dist/docs/references/reference-datasets-deleteItems.md +0 -27
- package/dist/docs/references/reference-datasets-get.md +0 -29
- package/dist/docs/references/reference-datasets-getDetails.md +0 -45
- package/dist/docs/references/reference-datasets-getExperiment.md +0 -28
- package/dist/docs/references/reference-datasets-getItem.md +0 -31
- package/dist/docs/references/reference-datasets-getItemHistory.md +0 -29
- package/dist/docs/references/reference-datasets-list.md +0 -29
- package/dist/docs/references/reference-datasets-listExperimentResults.md +0 -37
- package/dist/docs/references/reference-datasets-listExperiments.md +0 -31
- package/dist/docs/references/reference-datasets-listItems.md +0 -44
- package/dist/docs/references/reference-datasets-listVersions.md +0 -31
- package/dist/docs/references/reference-datasets-startExperiment.md +0 -60
- package/dist/docs/references/reference-datasets-startExperimentAsync.md +0 -41
- package/dist/docs/references/reference-datasets-update.md +0 -46
- package/dist/docs/references/reference-datasets-updateItem.md +0 -36
- package/dist/docs/references/reference-evals-answer-relevancy.md +0 -105
- package/dist/docs/references/reference-evals-answer-similarity.md +0 -99
- package/dist/docs/references/reference-evals-bias.md +0 -120
- package/dist/docs/references/reference-evals-completeness.md +0 -137
- package/dist/docs/references/reference-evals-content-similarity.md +0 -101
- package/dist/docs/references/reference-evals-context-precision.md +0 -196
- package/dist/docs/references/reference-evals-create-scorer.md +0 -270
- package/dist/docs/references/reference-evals-faithfulness.md +0 -114
- package/dist/docs/references/reference-evals-hallucination.md +0 -220
- package/dist/docs/references/reference-evals-keyword-coverage.md +0 -128
- package/dist/docs/references/reference-evals-mastra-scorer.md +0 -123
- package/dist/docs/references/reference-evals-run-evals.md +0 -138
- package/dist/docs/references/reference-evals-scorer-utils.md +0 -330
- package/dist/docs/references/reference-evals-textual-difference.md +0 -113
- package/dist/docs/references/reference-evals-tone-consistency.md +0 -119
- package/dist/docs/references/reference-evals-toxicity.md +0 -123
- package/dist/docs/references/reference-harness-harness-class.md +0 -645
- package/dist/docs/references/reference-logging-pino-logger.md +0 -117
- package/dist/docs/references/reference-memory-deleteMessages.md +0 -40
- package/dist/docs/references/reference-memory-memory-class.md +0 -147
- package/dist/docs/references/reference-memory-observational-memory.md +0 -565
- package/dist/docs/references/reference-observability-tracing-bridges-otel.md +0 -131
- package/dist/docs/references/reference-observability-tracing-configuration.md +0 -178
- package/dist/docs/references/reference-observability-tracing-exporters-console-exporter.md +0 -138
- package/dist/docs/references/reference-observability-tracing-exporters-datadog.md +0 -116
- package/dist/docs/references/reference-observability-tracing-instances.md +0 -109
- package/dist/docs/references/reference-observability-tracing-interfaces.md +0 -749
- package/dist/docs/references/reference-observability-tracing-processors-sensitive-data-filter.md +0 -144
- package/dist/docs/references/reference-observability-tracing-spans.md +0 -224
- package/dist/docs/references/reference-processors-batch-parts-processor.md +0 -61
- package/dist/docs/references/reference-processors-language-detector.md +0 -81
- package/dist/docs/references/reference-processors-message-history-processor.md +0 -85
- package/dist/docs/references/reference-processors-moderation-processor.md +0 -104
- package/dist/docs/references/reference-processors-pii-detector.md +0 -107
- package/dist/docs/references/reference-processors-processor-interface.md +0 -525
- package/dist/docs/references/reference-processors-prompt-injection-detector.md +0 -71
- package/dist/docs/references/reference-processors-semantic-recall-processor.md +0 -123
- package/dist/docs/references/reference-processors-system-prompt-scrubber.md +0 -80
- package/dist/docs/references/reference-processors-token-limiter-processor.md +0 -113
- package/dist/docs/references/reference-processors-tool-call-filter.md +0 -85
- package/dist/docs/references/reference-processors-tool-search-processor.md +0 -113
- package/dist/docs/references/reference-processors-unicode-normalizer.md +0 -62
- package/dist/docs/references/reference-processors-working-memory-processor.md +0 -154
- package/dist/docs/references/reference-rag-database-config.md +0 -264
- package/dist/docs/references/reference-rag-embeddings.md +0 -92
- package/dist/docs/references/reference-server-mastra-server.md +0 -298
- package/dist/docs/references/reference-server-register-api-route.md +0 -249
- package/dist/docs/references/reference-storage-cloudflare-d1.md +0 -218
- package/dist/docs/references/reference-storage-composite.md +0 -235
- package/dist/docs/references/reference-storage-lance.md +0 -131
- package/dist/docs/references/reference-storage-libsql.md +0 -135
- package/dist/docs/references/reference-storage-mongodb.md +0 -262
- package/dist/docs/references/reference-storage-mssql.md +0 -155
- package/dist/docs/references/reference-storage-overview.md +0 -121
- package/dist/docs/references/reference-storage-postgresql.md +0 -529
- package/dist/docs/references/reference-storage-upstash.md +0 -160
- package/dist/docs/references/reference-streaming-ChunkType.md +0 -292
- package/dist/docs/references/reference-streaming-agents-MastraModelOutput.md +0 -182
- package/dist/docs/references/reference-streaming-agents-streamLegacy.md +0 -142
- package/dist/docs/references/reference-streaming-workflows-observeStream.md +0 -42
- package/dist/docs/references/reference-streaming-workflows-resumeStream.md +0 -61
- package/dist/docs/references/reference-streaming-workflows-stream.md +0 -88
- package/dist/docs/references/reference-streaming-workflows-timeTravelStream.md +0 -142
- package/dist/docs/references/reference-templates-overview.md +0 -194
- package/dist/docs/references/reference-tools-create-tool.md +0 -237
- package/dist/docs/references/reference-tools-graph-rag-tool.md +0 -185
- package/dist/docs/references/reference-tools-mcp-client.md +0 -962
- package/dist/docs/references/reference-tools-mcp-server.md +0 -1275
- package/dist/docs/references/reference-tools-vector-query-tool.md +0 -459
- package/dist/docs/references/reference-vectors-libsql.md +0 -305
- package/dist/docs/references/reference-vectors-mongodb.md +0 -295
- package/dist/docs/references/reference-vectors-pg.md +0 -408
- package/dist/docs/references/reference-vectors-upstash.md +0 -294
- package/dist/docs/references/reference-voice-composite-voice.md +0 -121
- package/dist/docs/references/reference-voice-mastra-voice.md +0 -313
- package/dist/docs/references/reference-voice-voice.addInstructions.md +0 -56
- package/dist/docs/references/reference-voice-voice.addTools.md +0 -67
- package/dist/docs/references/reference-voice-voice.connect.md +0 -94
- package/dist/docs/references/reference-voice-voice.events.md +0 -37
- package/dist/docs/references/reference-voice-voice.listen.md +0 -164
- package/dist/docs/references/reference-voice-voice.on.md +0 -111
- package/dist/docs/references/reference-voice-voice.speak.md +0 -157
- package/dist/docs/references/reference-workflows-run-methods-cancel.md +0 -86
- package/dist/docs/references/reference-workflows-run-methods-restart.md +0 -33
- package/dist/docs/references/reference-workflows-run-methods-resume.md +0 -59
- package/dist/docs/references/reference-workflows-run-methods-start.md +0 -58
- package/dist/docs/references/reference-workflows-run-methods-startAsync.md +0 -67
- package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +0 -142
- package/dist/docs/references/reference-workflows-run.md +0 -59
- package/dist/docs/references/reference-workflows-step.md +0 -119
- package/dist/docs/references/reference-workflows-workflow-methods-branch.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-commit.md +0 -17
- package/dist/docs/references/reference-workflows-workflow-methods-create-run.md +0 -63
- package/dist/docs/references/reference-workflows-workflow-methods-dountil.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-dowhile.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-foreach.md +0 -118
- package/dist/docs/references/reference-workflows-workflow-methods-map.md +0 -93
- package/dist/docs/references/reference-workflows-workflow-methods-parallel.md +0 -21
- package/dist/docs/references/reference-workflows-workflow-methods-sleep.md +0 -35
- package/dist/docs/references/reference-workflows-workflow-methods-sleepUntil.md +0 -35
- package/dist/docs/references/reference-workflows-workflow-methods-then.md +0 -21
- package/dist/docs/references/reference-workflows-workflow.md +0 -157
- package/dist/docs/references/reference-workspace-filesystem.md +0 -202
- package/dist/docs/references/reference-workspace-local-filesystem.md +0 -327
- package/dist/docs/references/reference-workspace-local-sandbox.md +0 -285
- package/dist/docs/references/reference-workspace-sandbox.md +0 -81
- package/dist/docs/references/reference-workspace-workspace-class.md +0 -226
- package/dist/docs/references/reference.md +0 -276
|
@@ -23,10 +23,12 @@
|
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
+
import type { RequestContext } from '../../request-context/index.js';
|
|
26
27
|
import type { WorkspaceFilesystem } from '../filesystem/filesystem.js';
|
|
27
28
|
import type { MountResult } from '../filesystem/mount.js';
|
|
28
29
|
import type { SandboxLifecycle } from '../lifecycle.js';
|
|
29
30
|
import type { MountManager } from './mount-manager.js';
|
|
31
|
+
import type { SandboxProcessManager } from './process-manager/index.js';
|
|
30
32
|
import type { CommandResult, ExecuteCommandOptions, SandboxInfo } from './types.js';
|
|
31
33
|
/**
|
|
32
34
|
* Abstract sandbox interface for code and command execution.
|
|
@@ -60,16 +62,50 @@ export interface WorkspaceSandbox extends SandboxLifecycle<SandboxInfo> {
|
|
|
60
62
|
* Get instructions describing how this sandbox works.
|
|
61
63
|
* Used in tool descriptions to help agents understand execution context.
|
|
62
64
|
*
|
|
65
|
+
* @param opts - Optional options including request context for per-request customisation
|
|
63
66
|
* @returns A string describing how to use this sandbox
|
|
64
67
|
*/
|
|
65
|
-
getInstructions?(
|
|
68
|
+
getInstructions?(opts?: {
|
|
69
|
+
requestContext?: RequestContext;
|
|
70
|
+
}): string;
|
|
66
71
|
/**
|
|
67
|
-
* Execute a shell command.
|
|
72
|
+
* Execute a shell command and wait for it to complete.
|
|
68
73
|
* Optional - if not implemented, the workspace_execute_command tool won't be available.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* await sandbox.executeCommand('npm install');
|
|
78
|
+
*
|
|
79
|
+
* // With options
|
|
80
|
+
* await sandbox.executeCommand('npm install', [], { timeout: 60000 });
|
|
81
|
+
*
|
|
82
|
+
* // With args array (each arg is shell-quoted automatically)
|
|
83
|
+
* await sandbox.executeCommand('npm', ['install'], { timeout: 60000 });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
69
86
|
* @throws {SandboxExecutionError} if command fails to start
|
|
70
87
|
* @throws {SandboxTimeoutError} if command times out
|
|
71
88
|
*/
|
|
72
89
|
executeCommand?(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Process manager.
|
|
92
|
+
* Optional - if not implemented, process management tools won't be available.
|
|
93
|
+
*
|
|
94
|
+
* Provides methods to spawn long-running processes, list them, and interact
|
|
95
|
+
* with them via their {@link ProcessHandle} (kill, sendStdin, wait, read output).
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const handle = await sandbox.processes.spawn('node server.js');
|
|
100
|
+
* console.log(handle.pid);
|
|
101
|
+
*
|
|
102
|
+
* const procs = await sandbox.processes.list();
|
|
103
|
+
* const proc = await sandbox.processes.get(handle.pid);
|
|
104
|
+
* await proc?.sendStdin('hello\n');
|
|
105
|
+
* await proc?.kill();
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
readonly processes?: SandboxProcessManager;
|
|
73
109
|
/**
|
|
74
110
|
* Mount manager for tracking and processing filesystem mounts.
|
|
75
111
|
* Only available if the sandbox implements mount().
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/workspace/sandbox/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMjF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB,CAAC,WAAW,CAAC;IACrE,kDAAkD;IAClD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,+BAA+B;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEnC
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/workspace/sandbox/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,K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
48
48
|
args?: string[];
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Shared options for running commands in a sandbox.
|
|
52
|
+
* Base type for both executeCommand and spawn.
|
|
53
|
+
*/
|
|
54
|
+
export interface CommandOptions {
|
|
55
|
+
/** Timeout in milliseconds. Kills the process if exceeded. */
|
|
52
56
|
timeout?: number;
|
|
53
57
|
/** Environment variables */
|
|
54
58
|
env?: NodeJS.ProcessEnv;
|
|
@@ -59,6 +63,9 @@ export interface ExecuteCommandOptions {
|
|
|
59
63
|
/** Callback for stderr chunks (enables streaming) */
|
|
60
64
|
onStderr?: (data: string) => void;
|
|
61
65
|
}
|
|
66
|
+
/** Options for executeCommand. */
|
|
67
|
+
export interface ExecuteCommandOptions extends CommandOptions {
|
|
68
|
+
}
|
|
62
69
|
export interface SandboxInfo {
|
|
63
70
|
id: string;
|
|
64
71
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/workspace/sandbox/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAMnD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,UAAU,EAAE,mBAAmB,CAAC;IAChC,iCAAiC;IACjC,KAAK,EAAE,UAAU,CAAC;IAClB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,0CAA0C;IAC1C,UAAU,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oC;IACpC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,mCAAmC;IACnC,SAAS,CAAC,EAAE;QACV,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAMD,iDAAiD;AACjD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell-quote an argument for safe interpolation into a shell command string.
|
|
3
|
+
* Safe characters (alphanumeric, `.`, `_`, `-`, `/`, `=`, `:`, `@`) pass through.
|
|
4
|
+
* Everything else is wrapped in single quotes with embedded quotes escaped.
|
|
5
|
+
*/
|
|
6
|
+
export declare function shellQuote(arg: string): string;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/workspace/sandbox/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG9C"}
|
|
@@ -1,7 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Base input schema for execute_command (no background param).
|
|
4
|
+
* Extended with `background` in tools.ts when sandbox.processes exists.
|
|
5
|
+
*/
|
|
6
|
+
export declare const executeCommandInputSchema: z.ZodObject<{
|
|
7
|
+
command: z.ZodString;
|
|
8
|
+
timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
9
|
+
cwd: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
|
+
tail: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
command: string;
|
|
13
|
+
timeout?: number | null | undefined;
|
|
14
|
+
cwd?: string | null | undefined;
|
|
15
|
+
tail?: number | null | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
command: string;
|
|
18
|
+
timeout?: number | null | undefined;
|
|
19
|
+
cwd?: string | null | undefined;
|
|
20
|
+
tail?: number | null | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
/** Schema with background param included. */
|
|
23
|
+
export declare const executeCommandWithBackgroundSchema: z.ZodObject<{
|
|
24
|
+
command: z.ZodString;
|
|
25
|
+
timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
26
|
+
cwd: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
tail: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
|
+
} & {
|
|
29
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
command: string;
|
|
32
|
+
timeout?: number | null | undefined;
|
|
33
|
+
cwd?: string | null | undefined;
|
|
34
|
+
tail?: number | null | undefined;
|
|
35
|
+
background?: boolean | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
command: string;
|
|
38
|
+
timeout?: number | null | undefined;
|
|
39
|
+
cwd?: string | null | undefined;
|
|
40
|
+
tail?: number | null | undefined;
|
|
41
|
+
background?: boolean | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
/** Foreground-only tool (no background param in schema). */
|
|
1
44
|
export declare const executeCommandTool: import("../../tools").Tool<{
|
|
2
|
-
args: string[] | null;
|
|
3
45
|
command: string;
|
|
4
46
|
timeout?: number | null | undefined;
|
|
5
47
|
cwd?: string | null | undefined;
|
|
6
|
-
|
|
48
|
+
tail?: number | null | undefined;
|
|
49
|
+
}, string, unknown, unknown, any, "mastra_workspace_execute_command", unknown>;
|
|
50
|
+
/** Tool with background param in schema (used when sandbox.processes exists). */
|
|
51
|
+
export declare const executeCommandWithBackgroundTool: import("../../tools").Tool<{
|
|
52
|
+
command: string;
|
|
53
|
+
timeout?: number | null | undefined;
|
|
54
|
+
cwd?: string | null | undefined;
|
|
55
|
+
tail?: number | null | undefined;
|
|
56
|
+
background?: boolean | undefined;
|
|
57
|
+
}, string, unknown, unknown, any, "mastra_workspace_execute_command", unknown>;
|
|
7
58
|
//# sourceMappingURL=execute-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-command.d.ts","sourceRoot":"","sources":["../../../src/workspace/tools/execute-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute-command.d.ts","sourceRoot":"","sources":["../../../src/workspace/tools/execute-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EAYpC,CAAC;AAEH,6CAA6C;AAC7C,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;EAO7C,CAAC;AAqGH,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB;;;;;8EAK7B,CAAC;AAEH,iFAAiF;AACjF,eAAO,MAAM,gCAAgC;;;;;;8EAO3C,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getProcessOutputTool: import("../../tools").Tool<{
|
|
2
|
+
pid: number;
|
|
3
|
+
tail?: number | undefined;
|
|
4
|
+
wait?: boolean | undefined;
|
|
5
|
+
}, string, unknown, unknown, import("../../tools").ToolExecutionContext<unknown, unknown, unknown>, "mastra_workspace_get_process_output", unknown>;
|
|
6
|
+
//# sourceMappingURL=get-process-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-process-output.d.ts","sourceRoot":"","sources":["../../../src/workspace/tools/get-process-output.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,oBAAoB;;;;mJAsG/B,CAAC"}
|
|
@@ -9,8 +9,11 @@ export { fileStatTool } from './file-stat.js';
|
|
|
9
9
|
export { mkdirTool } from './mkdir.js';
|
|
10
10
|
export { searchTool } from './search.js';
|
|
11
11
|
export { indexContentTool } from './index-content.js';
|
|
12
|
-
export { executeCommandTool } from './execute-command.js';
|
|
12
|
+
export { executeCommandTool, executeCommandWithBackgroundTool, executeCommandInputSchema, executeCommandWithBackgroundSchema, } from './execute-command.js';
|
|
13
|
+
export { getProcessOutputTool } from './get-process-output.js';
|
|
14
|
+
export { killProcessTool } from './kill-process.js';
|
|
13
15
|
export { grepTool } from './grep.js';
|
|
14
16
|
export { requireWorkspace, requireFilesystem, requireSandbox, emitWorkspaceMetadata } from './helpers.js';
|
|
17
|
+
export { applyTail, applyCharLimit, truncateOutput, MAX_OUTPUT_CHARS, DEFAULT_TAIL_LINES } from './output-helpers.js';
|
|
15
18
|
export * from './tree-formatter.js';
|
|
16
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workspace/tools/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAA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,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGnH,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill-process.d.ts","sourceRoot":"","sources":["../../../src/workspace/tools/kill-process.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,eAAe;;6IA4D1B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Default number of lines to return (tail). */
|
|
2
|
+
export declare const DEFAULT_TAIL_LINES = 200;
|
|
3
|
+
/** Hard character limit for tool output. Safety net on top of line-based tail. */
|
|
4
|
+
export declare const MAX_OUTPUT_CHARS = 30000;
|
|
5
|
+
/**
|
|
6
|
+
* Return the last N lines of output, similar to `tail -n`.
|
|
7
|
+
* - `n > 0`: last N lines
|
|
8
|
+
* - `n === 0`: no limit (return all)
|
|
9
|
+
* - `undefined/null`: use DEFAULT_TAIL_LINES
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyTail(output: string, tail: number | null | undefined): string;
|
|
12
|
+
/**
|
|
13
|
+
* Hard character limit. Truncates from the start (keeps the end) and
|
|
14
|
+
* prepends a notice so the agent knows data was lost.
|
|
15
|
+
*/
|
|
16
|
+
export declare function applyCharLimit(output: string, limit?: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Apply both tail (line-based) and char limit (safety net) to output.
|
|
19
|
+
*/
|
|
20
|
+
export declare function truncateOutput(output: string, tail?: number | null, charLimit?: number): string;
|
|
21
|
+
//# sourceMappingURL=output-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-helpers.d.ts","sourceRoot":"","sources":["../../../src/workspace/tools/output-helpers.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAWjF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAyB,GAAG,MAAM,CAIvF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/workspace/tools/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/workspace/tools/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAc9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGpD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,oBAAoB,GAAG,SAAS,EAC7C,QAAQ,EAAE,iBAAiB,GAC1B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,eAAe,EAAE,OAAO,CAAC;IAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,CA4BlF;AAiGD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,uBAkGxD"}
|
|
@@ -3,5 +3,36 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Shared types for the workspace module.
|
|
5
5
|
*/
|
|
6
|
+
import type { RequestContext } from '../request-context/index.js';
|
|
6
7
|
export type WorkspaceStatus = 'pending' | 'initializing' | 'ready' | 'paused' | 'error' | 'destroying' | 'destroyed';
|
|
8
|
+
/**
|
|
9
|
+
* Instructions configuration for workspace providers.
|
|
10
|
+
*
|
|
11
|
+
* - `string` — Fully replaces the default instructions.
|
|
12
|
+
* - `(opts) => string` — Receives the default instructions and optional
|
|
13
|
+
* request context, allowing the caller to extend or customise per-request.
|
|
14
|
+
*
|
|
15
|
+
* @example Static override
|
|
16
|
+
* ```typescript
|
|
17
|
+
* new LocalFilesystem({
|
|
18
|
+
* basePath: './data',
|
|
19
|
+
* instructions: 'Custom instructions for this filesystem.',
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example Function form (extend auto-generated)
|
|
24
|
+
* ```typescript
|
|
25
|
+
* new LocalFilesystem({
|
|
26
|
+
* basePath: './data',
|
|
27
|
+
* instructions: ({ defaultInstructions, requestContext }) => {
|
|
28
|
+
* const locale = requestContext?.get('locale') ?? 'en';
|
|
29
|
+
* return `${defaultInstructions}\nUser locale: ${locale}`;
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export type InstructionsOption = string | ((opts: {
|
|
35
|
+
defaultInstructions: string;
|
|
36
|
+
requestContext?: RequestContext;
|
|
37
|
+
}) => string);
|
|
7
38
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/workspace/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/workspace/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,WAAW,CAAC;AAErH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,CAAC,CAAC,IAAI,EAAE;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,cAAc,CAAA;CAAE,KAAK,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RequestContext } from '../request-context/index.js';
|
|
2
|
+
import type { InstructionsOption } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve an instructions override against default instructions.
|
|
5
|
+
*
|
|
6
|
+
* - `undefined` → return default
|
|
7
|
+
* - `string` → return the string as-is
|
|
8
|
+
* - `function` → call with { defaultInstructions, requestContext }
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveInstructions(override: InstructionsOption | undefined, getDefault: () => string, requestContext?: RequestContext): string;
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/workspace/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EACxC,UAAU,EAAE,MAAM,MAAM,EACxB,cAAc,CAAC,EAAE,cAAc,GAC9B,MAAM,CAKR"}
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
import type { IMastraLogger } from '../logger/index.js';
|
|
33
|
+
import type { RequestContext } from '../request-context/index.js';
|
|
33
34
|
import type { MastraVector } from '../vector/index.js';
|
|
34
35
|
import { CompositeFilesystem } from './filesystem/index.js';
|
|
35
36
|
import type { WorkspaceFilesystem, FilesystemInfo } from './filesystem/index.js';
|
|
@@ -333,6 +334,23 @@ export declare class Workspace<TFilesystem extends WorkspaceFilesystem | undefin
|
|
|
333
334
|
* Returns undefined if no tools config was provided.
|
|
334
335
|
*/
|
|
335
336
|
getToolsConfig(): WorkspaceToolsConfig | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* Update the per-tool configuration for this workspace.
|
|
339
|
+
* Takes effect on the next `createWorkspaceTools()` call.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* // Disable write tools for read-only mode
|
|
344
|
+
* workspace.setToolsConfig({
|
|
345
|
+
* mastra_workspace_write_file: { enabled: false },
|
|
346
|
+
* mastra_workspace_edit_file: { enabled: false },
|
|
347
|
+
* });
|
|
348
|
+
*
|
|
349
|
+
* // Re-enable all tools
|
|
350
|
+
* workspace.setToolsConfig(undefined);
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
setToolsConfig(config: WorkspaceToolsConfig | undefined): void;
|
|
336
354
|
/**
|
|
337
355
|
* Access skills stored in this workspace.
|
|
338
356
|
* Skills are SKILL.md files discovered from the configured skillPaths.
|
|
@@ -413,10 +431,28 @@ export declare class Workspace<TFilesystem extends WorkspaceFilesystem | undefin
|
|
|
413
431
|
getInfo(options?: {
|
|
414
432
|
includeFileCount?: boolean;
|
|
415
433
|
}): Promise<WorkspaceInfo>;
|
|
434
|
+
/**
|
|
435
|
+
* Get human-readable instructions describing the workspace environment.
|
|
436
|
+
*
|
|
437
|
+
* When both a sandbox with mounts and a filesystem exist, each mount path
|
|
438
|
+
* is classified as sandbox-accessible (state === 'mounted') or
|
|
439
|
+
* workspace-only (pending / mounting / error / unsupported). When there's
|
|
440
|
+
* no sandbox or no mounts, falls back to provider-level instructions.
|
|
441
|
+
*
|
|
442
|
+
* @param opts - Optional options including request context for per-request customisation
|
|
443
|
+
* @returns Combined instructions string (may be empty)
|
|
444
|
+
*/
|
|
445
|
+
getInstructions(opts?: {
|
|
446
|
+
requestContext?: RequestContext;
|
|
447
|
+
}): string;
|
|
416
448
|
/**
|
|
417
449
|
* Get information about how filesystem and sandbox paths relate.
|
|
418
450
|
* Useful for understanding how to access workspace files from sandbox code.
|
|
419
451
|
*
|
|
452
|
+
* @deprecated Use {@link getInstructions} instead. `getInstructions()` is
|
|
453
|
+
* mount-state-aware and feeds into the system message via
|
|
454
|
+
* `WorkspaceInstructionsProcessor`.
|
|
455
|
+
*
|
|
420
456
|
* @returns PathContext with paths and instructions from providers
|
|
421
457
|
*/
|
|
422
458
|
getPathContext(): PathContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/workspace/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAIxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG/D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAC;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE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;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB9B;;;OAGG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IA4C/E;;;;;;;;;;OAUG;IACH,eAAe,CAAC,IAAI,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,MAAM;IA0CnE;;;;;;;;;OASG;IACH,cAAc,IAAI,WAAW;IA6B7B;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;CAWzC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -259,12 +259,12 @@
|
|
|
259
259
|
"typescript": "^5.9.3",
|
|
260
260
|
"vitest": "4.0.18",
|
|
261
261
|
"zod": "^3.25.76",
|
|
262
|
-
"@internal/ai-sdk-v4": "0.0.
|
|
263
|
-
"@internal/ai-sdk-v5": "0.0.
|
|
264
|
-
"@internal/
|
|
265
|
-
"@internal/
|
|
266
|
-
"@internal/
|
|
267
|
-
"@internal/
|
|
262
|
+
"@internal/ai-sdk-v4": "0.0.9",
|
|
263
|
+
"@internal/ai-sdk-v5": "0.0.9",
|
|
264
|
+
"@internal/external-types": "0.0.12",
|
|
265
|
+
"@internal/ai-v6": "0.0.9",
|
|
266
|
+
"@internal/types-builder": "0.0.37",
|
|
267
|
+
"@internal/lint": "0.0.62"
|
|
268
268
|
},
|
|
269
269
|
"engines": {
|
|
270
270
|
"node": ">=22.13.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mastra/hooks.ts","../src/evals/run/scorerAccumul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,aAAY,EAAG,IAAA,GAAO,CAAA,gCAAA,EAAmC,QAAQ,KAAK,KAAK,CAAA;AAAA,EACrF;AACF","file":"chunk-3U3XFMGJ.cjs","sourcesContent":["import pMap from 'p-map';\nimport { ErrorCategory, ErrorDomain, MastraError } from '../error';\nimport { saveScorePayloadSchema } from '../evals';\nimport type { ScoringHookInput } from '../evals/types';\nimport type { Mastra } from '../mastra';\nimport type { MastraStorage } from '../storage';\n\nexport function createOnScorerHook(mastra: Mastra) {\n return async (hookData: ScoringHookInput) => {\n const storage = mastra.getStorage();\n\n if (!storage) {\n mastra.getLogger()?.warn('Storage not found, skipping score validation and saving');\n return;\n }\n\n const entityId = hookData.entity.id as string;\n const entityType = hookData.entityType;\n const scorer = hookData.scorer;\n const scorerId = scorer.id as string;\n\n if (!scorerId) {\n mastra.getLogger()?.warn('Scorer ID not found, skipping score validation and saving');\n return;\n }\n\n try {\n const scorerToUse = await findScorer(mastra, entityId, entityType, scorerId);\n\n if (!scorerToUse) {\n throw new MastraError({\n id: 'MASTRA_SCORER_NOT_FOUND',\n domain: ErrorDomain.MASTRA,\n category: ErrorCategory.USER,\n text: `Scorer with ID ${scorerId} not found`,\n });\n }\n\n let input = hookData.input;\n let output = hookData.output;\n\n const { structuredOutput, ...rest } = hookData;\n\n const runResult = await scorerToUse.scorer.run({\n ...rest,\n input,\n output,\n });\n\n let spanId;\n let traceId;\n const currentSpan = hookData.tracingContext?.currentSpan;\n if (currentSpan && currentSpan.isValid) {\n spanId = currentSpan.id;\n traceId = currentSpan.traceId;\n }\n\n const payload = {\n ...rest,\n ...runResult,\n entityId,\n scorerId: scorerId,\n spanId,\n traceId,\n metadata: {\n structuredOutput: !!structuredOutput,\n },\n };\n await validateAndSaveScore(storage, payload);\n\n if (currentSpan && spanId && traceId) {\n await pMap(\n currentSpan.observabilityInstance.getExporters(),\n async exporter => {\n if (exporter.addScoreToTrace) {\n try {\n await exporter.addScoreToTrace({\n traceId: traceId,\n spanId: spanId,\n score: runResult.score as number,\n reason: runResult.reason as string,\n scorerName: scorerToUse.scorer.id,\n metadata: {\n ...(currentSpan.metadata ?? {}),\n },\n });\n } catch (error) {\n // Log error but don't fail the hook if exporter fails\n mastra.getLogger()?.error(`Failed to add score to trace via exporter: ${error}`);\n }\n }\n },\n { concurrency: 3 },\n );\n }\n } catch (error) {\n const mastraError = new MastraError(\n {\n id: 'MASTRA_SCORER_FAILED_TO_RUN_HOOK',\n domain: ErrorDomain.SCORER,\n category: ErrorCategory.USER,\n details: {\n scorerId,\n entityId,\n entityType,\n },\n },\n error,\n );\n\n mastra.getLogger()?.trackException(mastraError);\n mastra.getLogger()?.error(mastraError.toString());\n }\n };\n}\n\nexport async function validateAndSaveScore(storage: MastraStorage, payload: unknown) {\n const scoresStore = await storage.getStore('scores');\n if (!scoresStore) {\n throw new MastraError({\n id: 'MASTRA_SCORES_STORAGE_NOT_AVAILABLE',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.SYSTEM,\n text: 'Scores storage domain is not available',\n });\n }\n const payloadToSave = saveScorePayloadSchema.parse(payload);\n await scoresStore.saveScore(payloadToSave);\n}\n\nasync function findScorer(mastra: Mastra, entityId: string, entityType: string, scorerId: string) {\n let scorerToUse;\n if (entityType === 'AGENT') {\n // Try code-defined agents first\n try {\n const agent = mastra.getAgentById(entityId);\n const scorers = await agent.listScorers();\n for (const [_, scorer] of Object.entries(scorers)) {\n if (scorer.scorer.id === scorerId) {\n scorerToUse = scorer;\n break;\n }\n }\n } catch {\n // Agent not found in code-defined agents, try stored agents via editor\n try {\n const storedAgent = (await mastra.getEditor()?.agent.getById(entityId)) ?? null;\n if (storedAgent) {\n const scorers = await storedAgent.listScorers();\n for (const [_, scorer] of Object.entries(scorers) as [string, any][]) {\n if (scorer.scorer.id === scorerId) {\n scorerToUse = scorer;\n break;\n }\n }\n }\n } catch {\n // Stored agent also not found, will fall back to mastra-registered scorer\n }\n }\n } else if (entityType === 'WORKFLOW') {\n const scorers = await mastra.getWorkflowById(entityId).listScorers();\n for (const [_, scorer] of Object.entries(scorers)) {\n if (scorer.scorer.id === scorerId) {\n scorerToUse = scorer;\n break;\n }\n }\n }\n\n // Fallback to mastra-registered scorer\n if (!scorerToUse) {\n const mastraRegisteredScorer = mastra.getScorerById(scorerId);\n scorerToUse = mastraRegisteredScorer ? { scorer: mastraRegisteredScorer } : undefined;\n }\n\n return scorerToUse;\n}\n","export class ScoreAccumulator {\n private flatScores: Record<string, number[]> = {};\n private workflowScores: Record<string, number[]> = {};\n private stepScores: Record<string, Record<string, number[]>> = {};\n\n addScores(scorerResults: Record<string, any>) {\n const isTargetWorkflowAndHasStepScores = 'steps' in scorerResults;\n if (isTargetWorkflowAndHasStepScores) {\n this.addNestedScores(scorerResults);\n } else {\n this.addFlatScores(scorerResults);\n }\n }\n\n private addFlatScores(scorerResults: Record<string, any>) {\n for (const [scorerName, result] of Object.entries(scorerResults)) {\n if (!this.flatScores[scorerName]) {\n this.flatScores[scorerName] = [];\n }\n this.flatScores[scorerName].push((result as { score: number }).score);\n }\n }\n\n private addNestedScores(scorerResults: Record<string, any>) {\n if ('workflow' in scorerResults && scorerResults.workflow) {\n for (const [scorerName, result] of Object.entries(scorerResults.workflow)) {\n if (!this.workflowScores[scorerName]) {\n this.workflowScores[scorerName] = [];\n }\n this.workflowScores[scorerName].push((result as { score: number }).score);\n }\n }\n\n if ('steps' in scorerResults && scorerResults.steps) {\n for (const [stepId, stepResults] of Object.entries(scorerResults.steps)) {\n if (!this.stepScores[stepId]) {\n this.stepScores[stepId] = {};\n }\n for (const [scorerName, result] of Object.entries(stepResults as Record<string, any>)) {\n if (!this.stepScores[stepId][scorerName]) {\n this.stepScores[stepId][scorerName] = [];\n }\n this.stepScores[stepId][scorerName].push((result as { score: number }).score);\n }\n }\n }\n }\n\n addStepScores(stepScorerResults: Record<string, Record<string, any>>) {\n for (const [stepId, stepResults] of Object.entries(stepScorerResults)) {\n if (!this.stepScores[stepId]) {\n this.stepScores[stepId] = {};\n }\n for (const [scorerName, result] of Object.entries(stepResults)) {\n if (!this.stepScores[stepId][scorerName]) {\n this.stepScores[stepId][scorerName] = [];\n }\n this.stepScores[stepId][scorerName].push((result as { score: number }).score);\n }\n }\n }\n\n getAverageScores(): Record<string, any> {\n const result: Record<string, any> = {};\n\n for (const [scorerName, scoreArray] of Object.entries(this.flatScores)) {\n result[scorerName] = this.getAverageScore(scoreArray);\n }\n\n // Add workflow scores\n if (Object.keys(this.workflowScores).length > 0) {\n result.workflow = {};\n for (const [scorerName, scoreArray] of Object.entries(this.workflowScores)) {\n result.workflow[scorerName] = this.getAverageScore(scoreArray);\n }\n }\n\n if (Object.keys(this.stepScores).length > 0) {\n result.steps = {};\n for (const [stepId, stepScorers] of Object.entries(this.stepScores)) {\n result.steps[stepId] = {};\n for (const [scorerName, scoreArray] of Object.entries(stepScorers)) {\n result.steps[stepId][scorerName] = this.getAverageScore(scoreArray);\n }\n }\n }\n\n return result;\n }\n\n private getAverageScore(scoreArray: number[]): number {\n if (scoreArray.length > 0) {\n return scoreArray.reduce((a, b) => a + b, 0) / scoreArray.length;\n } else {\n return 0;\n }\n }\n}\n","import type { CoreMessage } from '@internal/ai-sdk-v4';\nimport type { Agent, AiMessageType, UIMessageWithMetadata } from '../../agent';\nimport { isSupportedLanguageModel } from '../../agent';\nimport { MastraError } from '../../error';\nimport { validateAndSaveScore } from '../../mastra/hooks';\nimport type { TracingContext } from '../../observability';\nimport type { RequestContext } from '../../request-context';\nimport { Workflow } from '../../workflows';\nimport type { AnyWorkflow, WorkflowResult, StepResult } from '../../workflows';\nimport type { MastraScorer } from '../base';\nimport { ScoreAccumulator } from './scorerAccumulator';\n\ntype RunEvalsDataItem<TTarget = unknown> = {\n input: TTarget extends Workflow<any, any>\n ? any\n : TTarget extends Agent\n ? string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]\n : unknown;\n groundTruth?: any;\n requestContext?: RequestContext;\n tracingContext?: TracingContext;\n};\n\ntype WorkflowScorerConfig = {\n workflow?: MastraScorer<any, any, any, any>[];\n steps?: Record<string, MastraScorer<any, any, any, any>[]>;\n};\n\ntype RunEvalsResult = {\n scores: Record<string, any>;\n summary: {\n totalItems: number;\n };\n};\n\n// Agent with scorers array\nexport function runEvals<TAgent extends Agent>(config: {\n data: RunEvalsDataItem<TAgent>[];\n scorers: MastraScorer<any, any, any, any>[];\n target: TAgent;\n onItemComplete?: (params: {\n item: RunEvalsDataItem<TAgent>;\n targetResult: Awaited<ReturnType<Agent['generate']>>;\n scorerResults: Record<string, any>; // Flat structure: { scorerName: result }\n }) => void | Promise<void>;\n concurrency?: number;\n}): Promise<RunEvalsResult>;\n\n// Workflow with scorers array\nexport function runEvals<TWorkflow extends AnyWorkflow>(config: {\n data: RunEvalsDataItem<TWorkflow>[];\n scorers: MastraScorer<any, any, any, any>[];\n target: TWorkflow;\n onItemComplete?: (params: {\n item: RunEvalsDataItem<TWorkflow>;\n targetResult: WorkflowResult<any, any, any, any>;\n scorerResults: Record<string, any>; // Flat structure: { scorerName: result }\n }) => void | Promise<void>;\n concurrency?: number;\n}): Promise<RunEvalsResult>;\n\n// Workflow with workflow configuration\nexport function runEvals<TWorkflow extends AnyWorkflow>(config: {\n data: RunEvalsDataItem<TWorkflow>[];\n scorers: WorkflowScorerConfig;\n target: TWorkflow;\n onItemComplete?: (params: {\n item: RunEvalsDataItem<TWorkflow>;\n targetResult: WorkflowResult<any, any, any, any>;\n scorerResults: {\n workflow?: Record<string, any>;\n steps?: Record<string, Record<string, any>>;\n };\n }) => void | Promise<void>;\n concurrency?: number;\n}): Promise<RunEvalsResult>;\nexport async function runEvals(config: {\n data: RunEvalsDataItem<any>[];\n scorers: MastraScorer<any, any, any, any>[] | WorkflowScorerConfig;\n target: Agent | Workflow;\n onItemComplete?: (params: {\n item: RunEvalsDataItem<any>;\n targetResult: any;\n scorerResults: any;\n }) => void | Promise<void>;\n concurrency?: number;\n}): Promise<RunEvalsResult> {\n const { data, scorers, target, onItemComplete, concurrency = 1 } = config;\n\n validateEvalsInputs(data, scorers, target);\n\n let totalItems = 0;\n const scoreAccumulator = new ScoreAccumulator();\n\n // Get storage from target's Mastra instance if available\n // Agent uses getMastraInstance(), Workflow uses .mastra getter\n const mastra = (target as any).getMastraInstance?.() || (target as any).mastra;\n const storage = mastra?.getStorage();\n\n const pMap = (await import('p-map')).default;\n await pMap(\n data,\n async (item: RunEvalsDataItem<any>) => {\n const targetResult = await executeTarget(target, item);\n const scorerResults = await runScorers(scorers, targetResult, item);\n scoreAccumulator.addScores(scorerResults);\n\n // Save scores to storage if available\n if (storage) {\n await saveScoresToStorage({\n storage,\n scorerResults,\n target,\n item,\n mastra,\n });\n }\n\n if (onItemComplete) {\n await onItemComplete({\n item,\n targetResult: targetResult as any,\n scorerResults: scorerResults as any,\n });\n }\n\n totalItems++;\n },\n { concurrency },\n );\n\n return {\n scores: scoreAccumulator.getAverageScores(),\n summary: {\n totalItems,\n },\n };\n}\n\nfunction isWorkflow(target: Agent | Workflow): target is Workflow {\n return target instanceof Workflow;\n}\n\nfunction isWorkflowScorerConfig(scorers: any): scorers is WorkflowScorerConfig {\n return typeof scorers === 'object' && !Array.isArray(scorers) && ('workflow' in scorers || 'steps' in scorers);\n}\n\nfunction validateEvalsInputs(\n data: RunEvalsDataItem<any>[],\n scorers: MastraScorer<any, any, any, any>[] | WorkflowScorerConfig,\n target: Agent | Workflow,\n): void {\n if (data.length === 0) {\n throw new MastraError({\n domain: 'SCORER',\n id: 'RUN_EXPERIMENT_FAILED_NO_DATA_PROVIDED',\n category: 'USER',\n text: 'Failed to run experiment: Data array is empty',\n });\n }\n\n for (let i = 0; i < data.length; i++) {\n const item = data[i];\n if (!item || typeof item !== 'object' || !('input' in item)) {\n throw new MastraError({\n domain: 'SCORER',\n id: 'INVALID_DATA_ITEM',\n category: 'USER',\n text: `Invalid data item at index ${i}: must have 'input' properties`,\n });\n }\n }\n\n // Validate scorers\n if (Array.isArray(scorers)) {\n if (scorers.length === 0) {\n throw new MastraError({\n domain: 'SCORER',\n id: 'NO_SCORERS_PROVIDED',\n category: 'USER',\n text: 'At least one scorer must be provided',\n });\n }\n } else if (isWorkflow(target) && isWorkflowScorerConfig(scorers)) {\n const hasScorers =\n (scorers.workflow && scorers.workflow.length > 0) || (scorers.steps && Object.keys(scorers.steps).length > 0);\n\n if (!hasScorers) {\n throw new MastraError({\n domain: 'SCORER',\n id: 'NO_SCORERS_PROVIDED',\n category: 'USER',\n text: 'At least one workflow or step scorer must be provided',\n });\n }\n } else if (!isWorkflow(target) && !Array.isArray(scorers)) {\n throw new MastraError({\n domain: 'SCORER',\n id: 'INVALID_AGENT_SCORERS',\n category: 'USER',\n text: 'Agent scorers must be an array of scorers',\n });\n }\n}\n\nasync function executeTarget(target: Agent | Workflow, item: RunEvalsDataItem<any>) {\n try {\n if (isWorkflow(target)) {\n return await executeWorkflow(target, item);\n } else {\n return await executeAgent(target, item);\n }\n } catch (error) {\n throw new MastraError(\n {\n domain: 'SCORER',\n id: 'RUN_EXPERIMENT_TARGET_FAILED_TO_GENERATE_RESULT',\n category: 'USER',\n text: 'Failed to run experiment: Error generating result from target',\n details: {\n item: JSON.stringify(item),\n },\n },\n error,\n );\n }\n}\n\nasync function executeWorkflow(target: Workflow, item: RunEvalsDataItem<any>) {\n const run = await target.createRun({ disableScorers: true });\n const workflowResult = await run.start({\n inputData: item.input,\n requestContext: item.requestContext,\n });\n\n return {\n scoringData: {\n input: item.input,\n output: workflowResult.status === 'success' ? workflowResult.result : undefined,\n stepResults: workflowResult.steps as Record<string, StepResult<any, any, any, any>>,\n },\n };\n}\n\nasync function executeAgent(agent: Agent, item: RunEvalsDataItem<any>) {\n const model = await agent.getModel();\n if (isSupportedLanguageModel(model)) {\n return await agent.generate(item.input as any, {\n scorers: {},\n returnScorerData: true,\n requestContext: item.requestContext,\n });\n } else {\n return await agent.generateLegacy(item.input as any, {\n scorers: {},\n returnScorerData: true,\n requestContext: item.requestContext,\n });\n }\n}\n\nasync function runScorers(\n scorers: MastraScorer<any, any, any, any>[] | WorkflowScorerConfig,\n targetResult: any,\n item: RunEvalsDataItem<any>,\n): Promise<Record<string, any>> {\n const scorerResults: Record<string, any> = {};\n\n if (Array.isArray(scorers)) {\n for (const scorer of scorers) {\n try {\n const score = await scorer.run({\n input: targetResult.scoringData?.input,\n output: targetResult.scoringData?.output,\n groundTruth: item.groundTruth,\n requestContext: item.requestContext,\n tracingContext: item.tracingContext,\n });\n\n scorerResults[scorer.id] = score;\n } catch (error) {\n throw new MastraError(\n {\n domain: 'SCORER',\n id: 'RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_RESULT',\n category: 'USER',\n text: `Failed to run experiment: Error running scorer ${scorer.id}`,\n details: {\n scorerId: scorer.id,\n item: JSON.stringify(item),\n },\n },\n error,\n );\n }\n }\n } else {\n // Handle workflow scorer config\n if (scorers.workflow) {\n const workflowScorerResults: Record<string, any> = {};\n for (const scorer of scorers.workflow) {\n const score = await scorer.run({\n input: targetResult.scoringData.input,\n output: targetResult.scoringData.output,\n groundTruth: item.groundTruth,\n requestContext: item.requestContext,\n tracingContext: item.tracingContext,\n });\n workflowScorerResults[scorer.id] = score;\n }\n if (Object.keys(workflowScorerResults).length > 0) {\n scorerResults.workflow = workflowScorerResults;\n }\n }\n\n if (scorers.steps) {\n const stepScorerResults: Record<string, any> = {};\n for (const [stepId, stepScorers] of Object.entries(scorers.steps)) {\n const stepResult = targetResult.scoringData.stepResults?.[stepId];\n if (stepResult?.status === 'success' && stepResult.payload && stepResult.output) {\n const stepResults: Record<string, any> = {};\n for (const scorer of stepScorers) {\n try {\n const score = await scorer.run({\n input: stepResult.payload,\n output: stepResult.output,\n groundTruth: item.groundTruth,\n requestContext: item.requestContext,\n tracingContext: item.tracingContext,\n });\n stepResults[scorer.id] = score;\n } catch (error) {\n throw new MastraError(\n {\n domain: 'SCORER',\n id: 'RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT',\n category: 'USER',\n text: `Failed to run experiment: Error running scorer ${scorer.id} on step ${stepId}`,\n details: {\n scorerId: scorer.id,\n stepId,\n },\n },\n error,\n );\n }\n }\n if (Object.keys(stepResults).length > 0) {\n stepScorerResults[stepId] = stepResults;\n }\n }\n }\n if (Object.keys(stepScorerResults).length > 0) {\n scorerResults.steps = stepScorerResults;\n }\n }\n }\n\n return scorerResults;\n}\n\n/**\n * Saves scorer results to storage when running evaluations.\n * This makes scores visible in Studio's observability section.\n */\nasync function saveScoresToStorage({\n storage,\n scorerResults,\n target,\n item,\n mastra,\n}: {\n storage: any;\n scorerResults: Record<string, any>;\n target: Agent | Workflow;\n item: RunEvalsDataItem<any>;\n mastra: any;\n}): Promise<void> {\n const entityId = target.id;\n const entityType = isWorkflow(target) ? 'WORKFLOW' : 'AGENT';\n\n // Handle flat scorer results (for agents or workflow-level scorers)\n if (Array.isArray(scorerResults) || !('workflow' in scorerResults && 'steps' in scorerResults)) {\n for (const [scorerId, scoreResult] of Object.entries(scorerResults)) {\n if (scoreResult && typeof scoreResult === 'object' && 'score' in scoreResult) {\n await saveSingleScore({\n storage,\n scoreResult,\n scorerId,\n entityId,\n entityType,\n mastra,\n target,\n item,\n });\n }\n }\n } else {\n // Handle workflow scorer config with workflow and step scorers\n if (scorerResults.workflow) {\n for (const [scorerId, scoreResult] of Object.entries(scorerResults.workflow)) {\n if (scoreResult && typeof scoreResult === 'object' && 'score' in scoreResult) {\n await saveSingleScore({\n storage,\n scoreResult,\n scorerId,\n entityId,\n entityType: 'WORKFLOW',\n mastra,\n target,\n item,\n });\n }\n }\n }\n\n if (scorerResults.steps) {\n for (const [stepId, stepScorers] of Object.entries(scorerResults.steps)) {\n for (const [scorerId, scoreResult] of Object.entries(stepScorers as Record<string, any>)) {\n if (scoreResult && typeof scoreResult === 'object' && 'score' in scoreResult) {\n await saveSingleScore({\n storage,\n scoreResult,\n scorerId,\n entityId: stepId,\n entityType: 'STEP',\n mastra,\n target,\n item,\n });\n }\n }\n }\n }\n }\n}\n\n/**\n * Saves a single scorer result to storage\n */\nasync function saveSingleScore({\n storage,\n scoreResult,\n scorerId,\n entityId,\n entityType,\n mastra,\n target,\n item,\n}: {\n storage: any;\n scoreResult: any;\n scorerId: string;\n entityId: string;\n entityType: string;\n mastra: any;\n target: Agent | Workflow;\n item: RunEvalsDataItem<any>;\n}): Promise<void> {\n try {\n // Get scorer information\n let scorer = mastra?.getScorerById?.(scorerId);\n\n if (!scorer) {\n // Try to get from target's scorers\n const targetScorers = await (target as any).listScorers?.();\n if (targetScorers) {\n for (const [_, scorerEntry] of Object.entries(targetScorers)) {\n if ((scorerEntry as any).scorer?.id === scorerId) {\n scorer = (scorerEntry as any).scorer;\n break;\n }\n }\n }\n }\n\n // Extract tracing context if available\n let traceId: string | undefined;\n let spanId: string | undefined;\n if (item.tracingContext?.currentSpan && item.tracingContext.currentSpan.isValid) {\n spanId = item.tracingContext.currentSpan.id;\n traceId = item.tracingContext.currentSpan.traceId;\n }\n\n // Build additional context with groundTruth if available\n const additionalContext: Record<string, any> = {};\n if (item.groundTruth !== undefined) {\n additionalContext.groundTruth = item.groundTruth;\n }\n\n const payload = {\n ...scoreResult,\n scorerId,\n entityId,\n entityType,\n source: 'TEST' as const,\n scorer: {\n id: scorer?.id || scorerId,\n name: scorer?.name || scorerId,\n description: scorer?.description || '',\n type: scorer?.type || 'unknown',\n },\n entity: {\n id: target.id,\n name: (target as any).name || target.id,\n },\n // Include requestContext from item\n requestContext: item.requestContext ? Object.fromEntries(item.requestContext.entries()) : undefined,\n // Include additionalContext with groundTruth\n additionalContext: Object.keys(additionalContext).length > 0 ? additionalContext : undefined,\n // Include tracing information\n traceId,\n spanId,\n };\n\n await validateAndSaveScore(storage, payload);\n } catch (error) {\n // Log error but don't fail the evaluation\n mastra?.getLogger?.()?.warn?.(`Failed to save score for scorer ${scorerId}:`, error);\n }\n}\n"]}
|