@mastra/core 1.86.0-alpha.7 → 1.86.0-alpha.9
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/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +363 -0
- package/dist/a2a/index.cjs +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/agent/agent.d.ts +72 -1
- package/dist/agent/agent.types.d.ts +30 -2
- package/dist/agent/durable/create-evented-agent.d.ts +6 -0
- package/dist/agent/durable/durable-agent.d.ts +1 -15
- package/dist/agent/durable/index.cjs +7 -26
- package/dist/agent/durable/index.js +7 -26
- package/dist/agent/durable/preparation.d.ts +2 -0
- package/dist/agent/durable/utils/resolve-runtime.d.ts +9 -0
- package/dist/agent/durable/workflows/durable-loop-builder.d.ts +4 -0
- package/dist/agent/durable/workflows/finalize-run.d.ts +3 -1
- package/dist/agent/durable/workflows/steps/llm-execution.d.ts +1 -0
- package/dist/agent/index.cjs +3 -3
- package/dist/agent/index.js +3 -3
- package/dist/agent/message-list/index.cjs +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/message-list.d.ts +11 -0
- package/dist/agent/message-list/utils/provider-compat.d.ts +1 -0
- package/dist/agent/request-context-snapshot.d.ts +1 -1
- package/dist/agent/streams/types.d.ts +10 -0
- package/dist/agent/thread-stream-runtime.d.ts +5 -0
- package/dist/agent/types.d.ts +25 -0
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/index.cjs +1 -1
- package/dist/agent-controller/index.js +1 -1
- package/dist/{agent-controller-K5vHtqfO.cjs → agent-controller-CrQ9OF80.cjs} +8 -8
- package/dist/{agent-controller-Cf3_IuY8.js → agent-controller-SSlKzE6A.js} +8 -8
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-DqnQMfuf.cjs → background-tasks-BDrYBis-.cjs} +5 -3
- package/dist/{background-tasks-BgpX1P_s.js → background-tasks-BnJfNLFo.js} +5 -3
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-x295GDL6.js → builder-Cl-0BWkh.js} +2 -2
- package/dist/{builder-D8Osghdo.cjs → builder-Cw8u3pPl.cjs} +2 -2
- package/dist/capabilities/302ai.json +192 -192
- package/dist/capabilities/abliteratedllm.json +34 -34
- package/dist/capabilities/abliteration-ai.json +11 -11
- package/dist/capabilities/above.json +17 -17
- package/dist/capabilities/adaption.json +12 -12
- package/dist/capabilities/adzuki.json +30 -30
- package/dist/capabilities/agentrouter.json +10 -10
- package/dist/capabilities/agnes.json +4 -4
- package/dist/capabilities/ai-router.json +9 -9
- package/dist/capabilities/aiand.json +19 -11
- package/dist/capabilities/aigrow.json +11 -11
- package/dist/capabilities/aimlapi.json +146 -149
- package/dist/capabilities/aipg.json +2 -2
- package/dist/capabilities/aixy.json +14 -14
- package/dist/capabilities/aki-io.json +11 -11
- package/dist/capabilities/alibaba-cn.json +128 -109
- package/dist/capabilities/alibaba-coding-plan-cn.json +7 -19
- package/dist/capabilities/alibaba-coding-plan.json +7 -19
- package/dist/capabilities/alibaba-token-plan-cn.json +49 -67
- package/dist/capabilities/alibaba-token-plan.json +51 -69
- package/dist/capabilities/alibaba.json +71 -118
- package/dist/capabilities/ambient.json +14 -14
- package/dist/capabilities/amd.json +11 -11
- package/dist/capabilities/anthropic.json +48 -48
- package/dist/capabilities/anyapi.json +18 -18
- package/dist/capabilities/apiko.json +2 -2
- package/dist/capabilities/arcee.json +10 -10
- package/dist/capabilities/augure.json +6 -6
- package/dist/capabilities/auriko.json +20 -20
- package/dist/capabilities/bailing.json +5 -5
- package/dist/capabilities/baseten.json +46 -16
- package/dist/capabilities/bee.json +5 -5
- package/dist/capabilities/berget.json +4 -4
- package/dist/capabilities/bothub.json +16 -16
- package/dist/capabilities/boundless.json +36 -36
- package/dist/capabilities/bumo.json +40 -40
- package/dist/capabilities/byteplus.json +32 -32
- package/dist/capabilities/cerebras.json +4 -4
- package/dist/capabilities/cheapaimodel.json +5 -5
- package/dist/capabilities/cheapest-token.json +24 -24
- package/dist/capabilities/chutes.json +9 -9
- package/dist/capabilities/cline-pass.json +37 -37
- package/dist/capabilities/cloudcode.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +24 -24
- package/dist/capabilities/commandcode.json +152 -152
- package/dist/capabilities/concentrate.json +290 -266
- package/dist/capabilities/cortecs.json +105 -105
- package/dist/capabilities/crossmodel.json +160 -160
- package/dist/capabilities/crusoe.json +10 -10
- package/dist/capabilities/daoxe.json +7 -7
- package/dist/capabilities/databricks.json +318 -62
- package/dist/capabilities/deepinfra.json +73 -129
- package/dist/capabilities/deepseek.json +2 -2
- package/dist/capabilities/digitalocean.json +114 -114
- package/dist/capabilities/dothoosh.json +28 -28
- package/dist/capabilities/doubleword.json +24 -24
- package/dist/capabilities/edenai.json +458 -458
- package/dist/capabilities/empiriolabs.json +166 -166
- package/dist/capabilities/engy.json +20 -20
- package/dist/capabilities/evroc.json +8 -8
- package/dist/capabilities/ezkielyna.json +8 -8
- package/dist/capabilities/fastrouter.json +85 -85
- package/dist/capabilities/fireworks-ai.json +107 -44
- package/dist/capabilities/freemodel.json +23 -23
- package/dist/capabilities/friendli.json +9 -9
- package/dist/capabilities/frogbot.json +94 -94
- package/dist/capabilities/gisoo.json +16 -16
- package/dist/capabilities/gmicloud.json +17 -17
- package/dist/capabilities/google.json +57 -57
- package/dist/capabilities/graphn.json +10 -10
- package/dist/capabilities/greenpt.json +36 -36
- package/dist/capabilities/groq.json +2 -2
- package/dist/capabilities/helicone.json +68 -68
- package/dist/capabilities/hopper.json +2 -2
- package/dist/capabilities/hostinger-router.json +12 -12
- package/dist/capabilities/hpc-ai.json +13 -13
- package/dist/capabilities/huawei-maas.json +17 -17
- package/dist/capabilities/hubris.json +30 -30
- package/dist/capabilities/huggingface.json +193 -37
- package/dist/capabilities/hyper.json +23 -23
- package/dist/capabilities/impossibl.json +140 -140
- package/dist/capabilities/inception.json +2 -2
- package/dist/capabilities/inceptron.json +4 -4
- package/dist/capabilities/inco.json +3 -3
- package/dist/capabilities/infer.json +15 -15
- package/dist/capabilities/inferall.json +10 -10
- package/dist/capabilities/inference-coop.json +9 -9
- package/dist/capabilities/inferenceapis.json +9 -9
- package/dist/capabilities/inferris.json +3 -3
- package/dist/capabilities/infersia.json +2 -2
- package/dist/capabilities/inferx.json +3 -3
- package/dist/capabilities/infomaniak.json +4 -4
- package/dist/capabilities/io-net.json +2 -2
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +60 -60
- package/dist/capabilities/jad-ai.json +3 -3
- package/dist/capabilities/jalapeno.json +12 -12
- package/dist/capabilities/jiekou.json +63 -63
- package/dist/capabilities/jzstoken.json +50 -50
- package/dist/capabilities/keln.json +14 -21
- package/dist/capabilities/kenari.json +123 -120
- package/dist/capabilities/kilo.json +622 -647
- package/dist/capabilities/kimi-code-plan-cn.json +5 -5
- package/dist/capabilities/kimi-code-plan-global.json +5 -5
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +18 -18
- package/dist/capabilities/korouter.json +29 -29
- package/dist/capabilities/kunavo.json +10 -10
- package/dist/capabilities/liquid.json +11 -11
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +932 -905
- package/dist/capabilities/llmgateway.json +336 -336
- package/dist/capabilities/llmtr.json +22 -22
- package/dist/capabilities/logits.json +2 -2
- package/dist/capabilities/longcat.json +2 -7
- package/dist/capabilities/lowrouter.json +54 -54
- package/dist/capabilities/lyceum.json +12 -12
- package/dist/capabilities/melious.json +13 -13
- package/dist/capabilities/merge-gateway.json +260 -260
- package/dist/capabilities/meta.json +7 -7
- package/dist/capabilities/mistral.json +20 -20
- package/dist/capabilities/mixlayer.json +4 -4
- package/dist/capabilities/modal.json +10 -10
- package/dist/capabilities/model-oracle-ai.json +25 -25
- package/dist/capabilities/modelis.json +20 -20
- package/dist/capabilities/modular.json +6 -6
- package/dist/capabilities/moneo.json +16 -16
- package/dist/capabilities/moonshotai-cn.json +7 -7
- package/dist/capabilities/moonshotai.json +7 -7
- package/dist/capabilities/morph.json +11 -11
- package/dist/capabilities/munito-eu.json +6 -6
- package/dist/capabilities/munito.json +6 -6
- package/dist/capabilities/nan.json +27 -27
- package/dist/capabilities/nano-gpt.json +578 -578
- package/dist/capabilities/nearai.json +84 -84
- package/dist/capabilities/nebius.json +37 -28
- package/dist/capabilities/neon.json +126 -126
- package/dist/capabilities/neuralwatt.json +41 -41
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +154 -154
- package/dist/capabilities/nvidia.json +35 -35
- package/dist/capabilities/oathbreaker.json +2 -2
- package/dist/capabilities/obscurify.json +32 -32
- package/dist/capabilities/oci.json +7 -7
- package/dist/capabilities/ofox.json +357 -357
- package/dist/capabilities/ollama-cloud.json +56 -56
- package/dist/capabilities/openai.json +51 -51
- package/dist/capabilities/opencode-go.json +85 -84
- package/dist/capabilities/openrouter.json +542 -567
- package/dist/capabilities/opper.json +30 -24
- package/dist/capabilities/orcarouter.json +236 -236
- package/dist/capabilities/outerlabs.json +32 -32
- package/dist/capabilities/ovhcloud.json +7 -7
- package/dist/capabilities/pareto.json +6 -6
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +61 -61
- package/dist/capabilities/phala.json +34 -34
- package/dist/capabilities/pioneer.json +30 -30
- package/dist/capabilities/poe.json +136 -136
- package/dist/capabilities/powerspring.json +13 -13
- package/dist/capabilities/primalabs.json +10 -10
- package/dist/capabilities/prime.json +124 -107
- package/dist/capabilities/privatemode-ai.json +14 -14
- package/dist/capabilities/proxystacks.json +6 -6
- package/dist/capabilities/qiniu-ai.json +16 -16
- package/dist/capabilities/refuseless.json +6 -6
- package/dist/capabilities/regolo-ai.json +6 -6
- package/dist/capabilities/requesty.json +172 -172
- package/dist/capabilities/ruapi.json +17 -17
- package/dist/capabilities/runcrate.json +5 -5
- package/dist/capabilities/runinfra.json +13 -13
- package/dist/capabilities/sakana.json +6 -6
- package/dist/capabilities/sambanova.json +9 -9
- package/dist/capabilities/sandbase.json +27 -27
- package/dist/capabilities/sarvam.json +12 -12
- package/dist/capabilities/scaleway.json +14 -14
- package/dist/capabilities/scnet-token-plan.json +9 -9
- package/dist/capabilities/scx-ai.json +26 -26
- package/dist/capabilities/sensenova.json +12 -12
- package/dist/capabilities/siliconflow-cn.json +49 -49
- package/dist/capabilities/siliconflow.json +46 -46
- package/dist/capabilities/snowflake-cortex.json +20 -20
- package/dist/capabilities/sokkan.json +7 -7
- package/dist/capabilities/sparrowcodes.json +25 -25
- package/dist/capabilities/standardcompute.json +102 -102
- package/dist/capabilities/steadyrouter.json +40 -40
- package/dist/capabilities/stepfun-ai-step-plan.json +6 -6
- package/dist/capabilities/stepfun-ai.json +15 -8
- package/dist/capabilities/stepfun-step-plan.json +15 -8
- package/dist/capabilities/stepfun.json +15 -8
- package/dist/capabilities/stepping-stone.json +16 -16
- package/dist/capabilities/synthetic.json +13 -13
- package/dist/capabilities/synthorai.json +19 -19
- package/dist/capabilities/teamorouter.json +24 -24
- package/dist/capabilities/teapot-router.json +13 -13
- package/dist/capabilities/tencent-coding-plan.json +1 -23
- package/dist/capabilities/tencent-token-plan.json +60 -23
- package/dist/capabilities/tencent-tokenhub.json +182 -7
- package/dist/capabilities/tensorx.json +50 -50
- package/dist/capabilities/tenstorrent.json +6 -6
- package/dist/capabilities/the-grid-ai.json +28 -28
- package/dist/capabilities/thinkingmachines.json +72 -55
- package/dist/capabilities/tinfoil.json +13 -13
- package/dist/capabilities/toapis.json +2 -2
- package/dist/capabilities/togetherai.json +54 -83
- package/dist/capabilities/tokengo.json +25 -25
- package/dist/capabilities/tokenify.json +9 -9
- package/dist/capabilities/trustedrouter.json +4 -4
- package/dist/capabilities/trustedtokens.json +17 -17
- package/dist/capabilities/umans-ai-coding-plan.json +13 -13
- package/dist/capabilities/umans-ai.json +10 -10
- package/dist/capabilities/unrestricted.json +6 -6
- package/dist/capabilities/uplinkswitch.json +21 -21
- package/dist/capabilities/upstage.json +4 -4
- package/dist/capabilities/vancine.json +23 -23
- package/dist/capabilities/vercel.json +540 -527
- package/dist/capabilities/vivgrid.json +80 -80
- package/dist/capabilities/volcengine-coding-plan.json +24 -54
- package/dist/capabilities/volcengine.json +55 -60
- package/dist/capabilities/vultr.json +24 -24
- package/dist/capabilities/wafer.ai.json +19 -19
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +11 -11
- package/dist/capabilities/wandb.json +21 -21
- package/dist/capabilities/watt.json +24 -24
- package/dist/capabilities/xai.json +7 -7
- package/dist/capabilities/xiaomi-token-plan-ams.json +2 -12
- package/dist/capabilities/xiaomi-token-plan-cn.json +2 -12
- package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -12
- package/dist/capabilities/xiaomi.json +3 -25
- package/dist/capabilities/xpersona.json +13 -13
- package/dist/capabilities/xxapi.json +31 -31
- package/dist/capabilities/zai-coding-plan.json +18 -18
- package/dist/capabilities/zai.json +49 -26
- package/dist/capabilities/zenifra.json +26 -26
- package/dist/capabilities/zenmux.json +205 -205
- package/dist/capabilities/zerogpu.json +11 -11
- package/dist/capabilities/zhipuai-coding-plan.json +6 -6
- package/dist/capabilities/zhipuai.json +39 -24
- package/dist/capabilities/zro.json +6 -6
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/{channels-Dx4jiXeK.js → channels-Cz1y3W6u.js} +1 -1
- package/dist/{channels-q6qnuRNV.cjs → channels-DQg4v_gm.cjs} +1 -1
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/datasets/dataset.d.ts +13 -6
- package/dist/datasets/experiment/durable.d.ts +16 -0
- package/dist/datasets/experiment/index.d.ts +2 -1
- package/dist/datasets/experiment/item.d.ts +26 -4
- package/dist/datasets/experiment/retries.d.ts +18 -0
- package/dist/datasets/experiment/types.d.ts +18 -0
- package/dist/datasets/experiment/workflow-id.d.ts +7 -0
- package/dist/datasets/experiment/workflow.d.ts +74 -0
- package/dist/datasets/index.cjs +3 -2
- package/dist/datasets/index.d.ts +2 -1
- package/dist/datasets/index.js +3 -3
- package/dist/docs/SKILL.md +4 -3
- package/dist/docs/assets/SOURCE_MAP.json +928 -903
- package/dist/docs/references/docs-deployment-workers.md +1 -1
- package/dist/docs/references/docs-evals-experiments.md +29 -1
- package/dist/docs/references/docs-harness-background-tasks.md +4 -1
- package/dist/docs/references/docs-harness-durable-agents.md +9 -5
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +1 -0
- package/dist/docs/references/docs-knowledge-importers.md +195 -0
- package/dist/docs/references/docs-knowledge-load-your-content.md +2 -2
- package/dist/docs/references/docs-knowledge-overview.md +1 -1
- package/dist/docs/references/docs-mastra-platform-observability-overview.md +1 -1
- package/dist/docs/references/docs-sandbox-filesystem.md +1 -1
- package/dist/docs/references/docs-server-pubsub.md +51 -8
- package/dist/docs/references/docs-signals-running-across-processes.md +2 -0
- package/dist/docs/references/docs-signals-thread-streams.md +1 -1
- package/dist/docs/references/docs-studio-auth.md +54 -7
- package/dist/docs/references/docs-workflows-overview.md +1 -1
- package/dist/docs/references/docs-workflows-scheduled-workflows.md +1 -1
- package/dist/docs/references/integrations-auth-clerk.md +48 -4
- package/dist/docs/references/integrations-channels-slack.md +4 -2
- package/dist/docs/references/integrations.md +6 -0
- package/dist/docs/references/reference-agents-agent.md +3 -1
- package/dist/docs/references/reference-agents-channels.md +116 -27
- package/dist/docs/references/reference-agents-durable-agent.md +12 -4
- package/dist/docs/references/reference-auth-clerk.md +21 -1
- package/dist/docs/references/reference-datasets-runExperimentItem.md +13 -1
- package/dist/docs/references/reference-datasets-startExperimentAsync.md +3 -1
- package/dist/docs/references/reference-editor-mastra-editor.md +3 -1
- package/dist/docs/references/reference-knowledge-knowledge-class.md +13 -6
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +43 -20
- package/dist/docs/references/reference-memory-observational-memory.md +2 -2
- package/dist/docs/references/reference-processors-moderation-processor.md +2 -2
- package/dist/docs/references/reference-pubsub-base.md +5 -1
- package/dist/docs/references/reference-pubsub-event-emitter.md +2 -0
- package/dist/docs/references/reference-pubsub-redis-streams.md +1 -1
- package/dist/docs/references/reference-pubsub-unix-socket-pubsub.md +2 -0
- package/dist/docs/references/reference-streaming-ChunkType.md +3 -3
- package/dist/docs/references/reference-workers-overview.md +1 -1
- package/dist/docs/references/reference-workflows-run-methods-start.md +23 -0
- package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +4 -0
- package/dist/docs/references/reference-workflows-run.md +1 -1
- package/dist/docs/references/reference-workspace-local-sandbox.md +2 -0
- package/dist/error/index.cjs +1 -1
- package/dist/error/index.js +1 -1
- package/dist/{error-C9d_24w-.js → error-BLwEXqOK.js} +2 -2
- package/dist/{error-BRQf2ku0.cjs → error-BdEvO8za.cjs} +2 -2
- package/dist/evals/index.cjs +1 -1
- package/dist/evals/index.js +1 -1
- package/dist/evals/scoreTraces/index.cjs +1 -1
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/events/caching-pubsub.d.ts +1 -0
- package/dist/events/event-emitter/index.d.ts +12 -5
- package/dist/events/index.cjs +15 -1
- package/dist/events/index.js +15 -1
- package/dist/events/pubsub.d.ts +29 -0
- package/dist/events/reach.d.ts +11 -0
- package/dist/events/unix-socket-pubsub.d.ts +14 -0
- package/dist/features/index.cjs +1 -0
- package/dist/features/index.js +1 -0
- package/dist/{filesystem-B5X-5G0x.js → filesystem-B8ad6kAW.js} +1 -1
- package/dist/{filesystem-BDSpwBke.cjs → filesystem-BB5YWXH-.cjs} +1 -1
- package/dist/{filesystem-DzM9pcQ8.js → filesystem-BDHUxbHn.js} +1 -1
- package/dist/{filesystem-B0AZrbj8.cjs → filesystem-BP5yz5LG.cjs} +1 -1
- package/dist/{filesystem-BsdkC311.js → filesystem-B_afSgYk.js} +1 -1
- package/dist/{filesystem-C-cyJfi1.cjs → filesystem-BaOJOc-V.cjs} +1 -1
- package/dist/{filesystem-B3s0WRud.js → filesystem-BhYgU8qg.js} +1 -1
- package/dist/{filesystem-DzfqVTO_.js → filesystem-CLBVmR5j.js} +1 -1
- package/dist/{filesystem-CEbD_77-.cjs → filesystem-Cgxc2a_-.cjs} +1 -1
- package/dist/{filesystem-Cv79mHRk.js → filesystem-ClBOBoDc.js} +1 -1
- package/dist/{filesystem-DsCQiBl2.cjs → filesystem-DVVecqZt.cjs} +1 -1
- package/dist/{filesystem-CUAgLugE.cjs → filesystem-Fpsu7e24.cjs} +1 -1
- package/dist/{filesystem-versioned-Bijb_p9l.js → filesystem-versioned-BL1ojJLo.js} +1 -1
- package/dist/{filesystem-versioned-DZGyPbNC.cjs → filesystem-versioned-BavRtYWJ.cjs} +1 -1
- package/dist/harness/index.cjs +1 -1
- package/dist/harness/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/config.d.ts +10 -0
- package/dist/knowledge/host-writes.d.ts +10 -0
- package/dist/knowledge/importers/conformance.d.ts +25 -0
- package/dist/knowledge/importers/define.d.ts +204 -0
- package/dist/knowledge/importers/host.d.ts +143 -0
- package/dist/knowledge/importers/index.d.ts +12 -0
- package/dist/knowledge/importers/local-host.d.ts +106 -0
- package/dist/knowledge/importers/manifest.d.ts +25 -0
- package/dist/knowledge/importers/runner.d.ts +61 -0
- package/dist/knowledge/importers/sink.d.ts +105 -0
- package/dist/knowledge/importers/types.d.ts +144 -0
- package/dist/knowledge/index.cjs +2715 -8
- package/dist/knowledge/index.d.ts +54 -4
- package/dist/knowledge/index.js +2692 -9
- package/dist/knowledge/instructions.d.ts +1 -1
- package/dist/knowledge/links.d.ts +8 -0
- package/dist/knowledge/pinned-state-processor.d.ts +5 -0
- package/dist/knowledge/pinned.d.ts +4 -1
- package/dist/knowledge/scope-runtime.d.ts +10 -0
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +7812 -7831
- package/dist/llm/model/shared.types.d.ts +31 -0
- package/dist/{llm-CsQuqKPc.cjs → llm-8Av3mSjD.cjs} +2 -2
- package/dist/{llm-DnXK3Pmw.js → llm-B5A5cwJr.js} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +2 -2
- package/dist/{manager-BsghM-UL.js → manager-DfWQCJUK.js} +460 -94
- package/dist/{manager-DwFnIrI6.cjs → manager-sv35JY-z.cjs} +476 -92
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.d.ts +13 -0
- package/dist/mastra/index.js +1 -1
- package/dist/mastra/resolve-agent.d.ts +3 -1
- package/dist/{mastra-B8i1UDZs.js → mastra-CigBrT7X.js} +32 -23
- package/dist/{mastra-Cn5NC6Es.cjs → mastra-D4hvfuxX.cjs} +34 -25
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.js +3 -3
- package/dist/{message-list-DPXPXvin.cjs → message-list-Cj0Sq_JP.cjs} +63 -8
- package/dist/{message-list-DEuRl82K.js → message-list-KRbg-TnI.js} +63 -8
- package/dist/{model-CNPfry_X.cjs → model-BK93CMtl.cjs} +1 -1
- package/dist/{model-CsOcWMUt.js → model-CYtXw861.js} +1 -1
- package/dist/{netlify-C-83Fxus.cjs → netlify-BAnn3ouY.cjs} +1 -1
- package/dist/{netlify-C-OpNSGp.js → netlify-CuI1ZrwR.js} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/{output-helpers-JL-HeCbT.cjs → output-helpers-1Zu4Vt9C.cjs} +68 -25
- package/dist/{output-helpers-D4II19No.js → output-helpers-CedRCE17.js} +69 -26
- package/dist/processor-provider/index.cjs +1 -1
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/abort-signal-scope.d.ts +6 -0
- package/dist/processors/index.cjs +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/{provider-registry-9O-H9osy.cjs → provider-registry-BwuI_IpT.cjs} +21690 -21811
- package/dist/{provider-registry-RZ8EgSe8.js → provider-registry-CmQLzLF_.js} +21690 -21811
- package/dist/provider-registry.json +22113 -22215
- package/dist/{registry-generator-e8sltJls.js → registry-generator-C17V4WfG.js} +1 -1
- package/dist/{registry-generator-DxCX-FiO.cjs → registry-generator-C_0ae7Ce.cjs} +1 -1
- package/dist/{rehydrate-B-wrAN7C.cjs → rehydrate-CDQ4dOYj.cjs} +2 -2
- package/dist/{rehydrate-D3fPgJwp.js → rehydrate-PnaVawGX.js} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-5_LQBGn_.cjs → run-registry-BmckDVBk.cjs} +1698 -497
- package/dist/{run-registry-DC03XLeZ.js → run-registry-BwEcwYlU.js} +1614 -467
- package/dist/{source-DDwx-87N.cjs → source-BVOi8Xhp.cjs} +1 -1
- package/dist/{source-Did_2XQc.js → source-fNa6u1kH.js} +1 -1
- package/dist/storage/domains/agents/index.cjs +1 -1
- package/dist/storage/domains/agents/index.js +1 -1
- package/dist/storage/domains/knowledge/base.d.ts +72 -0
- package/dist/storage/domains/knowledge/importers-inmemory.d.ts +146 -0
- package/dist/storage/domains/knowledge/importers.d.ts +287 -0
- package/dist/storage/domains/knowledge/index.d.ts +1 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +12 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +12 -1
- package/dist/storage/domains/knowledge/pages.d.ts +25 -7
- package/dist/storage/domains/mcp-clients/index.cjs +1 -1
- package/dist/storage/domains/mcp-clients/index.js +1 -1
- package/dist/storage/domains/mcp-servers/index.cjs +1 -1
- package/dist/storage/domains/mcp-servers/index.js +1 -1
- package/dist/storage/domains/prompt-blocks/index.cjs +1 -1
- package/dist/storage/domains/prompt-blocks/index.js +1 -1
- package/dist/storage/domains/scorer-definitions/index.cjs +1 -1
- package/dist/storage/domains/scorer-definitions/index.js +1 -1
- package/dist/storage/domains/skills/index.cjs +1 -1
- package/dist/storage/domains/skills/index.js +1 -1
- package/dist/storage/domains/workspaces/index.cjs +1 -1
- package/dist/storage/domains/workspaces/index.js +1 -1
- package/dist/storage/index.cjs +15 -10
- package/dist/storage/index.js +11 -11
- package/dist/stream/base/output.d.ts +59 -15
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +24 -2
- package/dist/{stream-4aNIw_TQ.cjs → stream-0kdqBOOn.cjs} +64 -9
- package/dist/{stream-CJUm6EAH.js → stream-D1y9GzoD.js} +29 -10
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/{tool-loop-agent-FEEwHfmg.js → tool-loop-agent-BdjWGVIb.js} +4 -4
- package/dist/{tool-loop-agent-Dn0QCB9n.cjs → tool-loop-agent-kWaZAT6Q.cjs} +4 -4
- package/dist/tools/types.d.ts +27 -1
- package/dist/{utils-DY01hxVd.cjs → utils-BKUCaZ12.cjs} +1 -1
- package/dist/{utils-Bd_y1_a-.js → utils-GHY3hmLx.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-CX0yQo_q.js → validate-CB-q-R2F.js} +1 -1
- package/dist/{validate-CuB_1Zd3.cjs → validate-De92squ7.cjs} +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +2 -2
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/{worker-CbaSmip-.cjs → worker-BbWPQuPR.cjs} +2 -2
- package/dist/{worker-B80xkcKG.js → worker-C3u_xzY2.js} +2 -2
- package/dist/{worker-GsGIxPMa.cjs → worker-CAKvQj9_.cjs} +2 -2
- package/dist/{worker-DSEfMPmq.js → worker-Kwm8EKcj.js} +2 -2
- package/dist/{workflow-CnBPXTpv.cjs → workflow-CSjXeNcR.cjs} +4 -4
- package/dist/{workflow-CZHY_C85.js → workflow-CVmI1Sw-.js} +4 -4
- package/dist/workflows/builder/index.cjs +1 -1
- package/dist/workflows/builder/index.js +1 -1
- package/dist/workflows/evented/index.cjs +1 -1
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/setup-warning.d.ts +18 -0
- package/dist/workflows/evented/workflow-event-processor/run-status.d.ts +37 -0
- package/dist/workflows/evented/workflow.d.ts +10 -0
- package/dist/workflows/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/dist/workflows/workflow.d.ts +6 -1
- package/dist/workspace/filesystem/filesystem.d.ts +5 -0
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts +16 -7
- package/dist/workspace/sandbox/native-sandbox/types.d.ts +11 -1
- package/dist/{workspace-D7TIleIt.js → workspace-DY2Nxiyi.js} +235 -34
- package/dist/{workspace-D2drutNg.cjs → workspace-X2RHJZU9.cjs} +235 -34
- package/package.json +7 -7
- package/src/llm/model/provider-types.generated.d.ts +7812 -7831
|
@@ -1,14 +1,23 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BrhgMLW6.cjs");
|
|
2
|
+
const require_run_registry = require("./run-registry-BmckDVBk.cjs");
|
|
1
3
|
const require_observability = require("./observability-B0R_D1PZ.cjs");
|
|
2
4
|
const require_error = require("./error-D90lJ6M7.cjs");
|
|
3
|
-
const require_stream = require("./stream-
|
|
5
|
+
const require_stream = require("./stream-0kdqBOOn.cjs");
|
|
4
6
|
const require_request_context = require("./request-context-D9RXYCy8.cjs");
|
|
5
|
-
const require_run_registry = require("./run-registry-5_LQBGn_.cjs");
|
|
6
7
|
const require_storage = require("./storage-CfG0I2aF.cjs");
|
|
7
8
|
const require_utils = require("./utils-D-eNsgDM.cjs");
|
|
8
9
|
const require_deep_equal = require("./deep-equal-TMDmByBC.cjs");
|
|
9
10
|
const require_constants = require("./constants-B9ZDvXZ4.cjs");
|
|
11
|
+
let zod = require("zod");
|
|
10
12
|
let _mastra_schema_compat = require("@mastra/schema-compat");
|
|
11
13
|
let _mastra_schema_compat_zod_to_json = require("@mastra/schema-compat/zod-to-json");
|
|
14
|
+
// src/datasets/experiment/workflow-id.ts
|
|
15
|
+
/**
|
|
16
|
+
* Id of the internal evented workflow that runs durable experiments. Lives in
|
|
17
|
+
* its own file so `mastra/index.ts` can check for it without statically
|
|
18
|
+
* importing `./workflow` (and through it the evented engine).
|
|
19
|
+
*/
|
|
20
|
+
const EXPERIMENT_WORKFLOW_ID = "__mastra-experiment";
|
|
12
21
|
// src/datasets/experiment/agent-model.ts
|
|
13
22
|
/** `agentModel` swaps an agent's model, so it is meaningless for workflows, scorers and inline tasks. */
|
|
14
23
|
function assertAgentModelTarget(config) {
|
|
@@ -34,6 +43,284 @@ function withAgentModelMetadata(metadata, agentModel) {
|
|
|
34
43
|
agentModel: agentModelLabel(agentModel)
|
|
35
44
|
} : metadata;
|
|
36
45
|
}
|
|
46
|
+
// src/datasets/experiment/resolve-target.ts
|
|
47
|
+
/**
|
|
48
|
+
* Resolve a target from Mastra's registries by type and ID.
|
|
49
|
+
* When `agentVersion` is provided for an agent target, the returned agent
|
|
50
|
+
* will have the versioned config applied (via `applyStoredOverrides`).
|
|
51
|
+
*
|
|
52
|
+
* The result is wrapped in `{ target }` because `Workflow` has a `.then`
|
|
53
|
+
* method for step chaining, which makes it thenable. Returning a thenable
|
|
54
|
+
* from an async function causes the Promise machinery to attempt to unwrap
|
|
55
|
+
* it, which hangs forever since the builder `.then` never invokes its
|
|
56
|
+
* callbacks. Wrapping in a plain object avoids the unwrap.
|
|
57
|
+
*/
|
|
58
|
+
async function resolveTarget(mastra, targetType, targetId, agentVersion) {
|
|
59
|
+
let resolved = null;
|
|
60
|
+
switch (targetType) {
|
|
61
|
+
case "agent":
|
|
62
|
+
try {
|
|
63
|
+
if (agentVersion) resolved = await mastra.getAgentById(targetId, { versionId: agentVersion });
|
|
64
|
+
else resolved = mastra.getAgentById(targetId);
|
|
65
|
+
} catch {
|
|
66
|
+
try {
|
|
67
|
+
if (agentVersion) resolved = await mastra.getAgent(targetId, { versionId: agentVersion });
|
|
68
|
+
else resolved = mastra.getAgent(targetId);
|
|
69
|
+
} catch {}
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case "workflow":
|
|
73
|
+
try {
|
|
74
|
+
resolved = mastra.getWorkflowById(targetId);
|
|
75
|
+
} catch {
|
|
76
|
+
try {
|
|
77
|
+
resolved = mastra.getWorkflow(targetId);
|
|
78
|
+
} catch {}
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case "scorer": try {
|
|
82
|
+
resolved = mastra.getScorerById(targetId) ?? null;
|
|
83
|
+
} catch {}
|
|
84
|
+
}
|
|
85
|
+
return resolved ? { target: resolved } : null;
|
|
86
|
+
}
|
|
87
|
+
// src/datasets/experiment/workflow.ts
|
|
88
|
+
var workflow_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ buildExperimentWorkflow: () => buildExperimentWorkflow });
|
|
89
|
+
const DEFAULT_MAX_CONCURRENCY = 5;
|
|
90
|
+
const versionSelectorSchema = zod.z.union([zod.z.object({ versionId: zod.z.string() }), zod.z.object({ status: zod.z.enum(["draft", "published"]) })]);
|
|
91
|
+
/**
|
|
92
|
+
* Input of a durable experiment run. Everything here is JSON so the run can be
|
|
93
|
+
* picked up by any process sharing the storage and pubsub.
|
|
94
|
+
*/
|
|
95
|
+
const experimentWorkflowInputSchema = zod.z.object({
|
|
96
|
+
datasetId: zod.z.string(),
|
|
97
|
+
experimentId: zod.z.string(),
|
|
98
|
+
organizationId: zod.z.string().optional(),
|
|
99
|
+
projectId: zod.z.string().optional(),
|
|
100
|
+
maxConcurrency: zod.z.number().int().positive().optional(),
|
|
101
|
+
itemTimeout: zod.z.number().int().positive().optional(),
|
|
102
|
+
maxRetries: zod.z.number().int().nonnegative().optional(),
|
|
103
|
+
/** `provider/model` string; model objects aren't serializable. */
|
|
104
|
+
agentModel: zod.z.string().optional(),
|
|
105
|
+
unmockedToolPolicy: zod.z.enum(["allow", "deny"]).optional(),
|
|
106
|
+
requestContext: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
107
|
+
versions: zod.z.object({
|
|
108
|
+
agents: zod.z.record(zod.z.string(), versionSelectorSchema).optional(),
|
|
109
|
+
defaultStatus: zod.z.enum(["draft", "published"]).optional()
|
|
110
|
+
}).optional()
|
|
111
|
+
});
|
|
112
|
+
const itemRefSchema = zod.z.object({ itemId: zod.z.string() });
|
|
113
|
+
const itemOutcomeSchema = zod.z.object({
|
|
114
|
+
itemId: zod.z.string(),
|
|
115
|
+
failed: zod.z.boolean()
|
|
116
|
+
});
|
|
117
|
+
function datasetHandle(mastra, input) {
|
|
118
|
+
return mastra.datasets.get({
|
|
119
|
+
id: input.datasetId,
|
|
120
|
+
organizationId: input.organizationId,
|
|
121
|
+
projectId: input.projectId
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Marks the experiment `failed` when a step throws, then rethrows so the run
|
|
126
|
+
* fails too. Item target errors never get here: they're recorded on the item's
|
|
127
|
+
* row. This covers setup errors and items that couldn't be run or saved.
|
|
128
|
+
*
|
|
129
|
+
* The experiment is only touched when the run's dataset, scope and experiment
|
|
130
|
+
* belong together, so a run naming another project's experiment can't change it.
|
|
131
|
+
*/
|
|
132
|
+
async function failExperimentOnError(mastra, input, body) {
|
|
133
|
+
try {
|
|
134
|
+
return await body();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
mastra.getLogger()?.error(`Experiment ${input.experimentId} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
137
|
+
const owned = await datasetHandle(mastra, input).then((dataset) => dataset.getExperiment({ experimentId: input.experimentId })).catch(() => null);
|
|
138
|
+
if (owned) await (await mastra.getStorage()?.getStore("experiments"))?.updateExperiment({
|
|
139
|
+
id: owned.id,
|
|
140
|
+
status: "failed",
|
|
141
|
+
completedAt: /* @__PURE__ */ new Date()
|
|
142
|
+
}).catch(() => {});
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const prepareStep = require_run_registry.createStep({
|
|
147
|
+
id: "prepare",
|
|
148
|
+
inputSchema: experimentWorkflowInputSchema,
|
|
149
|
+
outputSchema: zod.z.array(itemRefSchema),
|
|
150
|
+
execute: async ({ getInitData, mastra }) => {
|
|
151
|
+
const inputData = getInitData();
|
|
152
|
+
return failExperimentOnError(mastra, inputData, async () => {
|
|
153
|
+
const experimentsStore = await mastra.getStorage()?.getStore("experiments");
|
|
154
|
+
const datasetsStore = await mastra.getStorage()?.getStore("datasets");
|
|
155
|
+
if (!experimentsStore || !datasetsStore) throw new require_error.MastraError({
|
|
156
|
+
id: "EXPERIMENTS_STORAGE_NOT_CONFIGURED",
|
|
157
|
+
text: "Durable experiments need datasets and experiments storage on the Mastra instance.",
|
|
158
|
+
domain: "STORAGE",
|
|
159
|
+
category: "USER"
|
|
160
|
+
});
|
|
161
|
+
const dataset = await datasetHandle(mastra, inputData);
|
|
162
|
+
const experiment = await dataset.getExperiment({ experimentId: inputData.experimentId });
|
|
163
|
+
if (!experiment) throw new require_error.MastraError({
|
|
164
|
+
id: "EXPERIMENT_NOT_FOUND",
|
|
165
|
+
text: `Experiment not found: ${inputData.experimentId}`,
|
|
166
|
+
domain: "STORAGE",
|
|
167
|
+
category: "USER"
|
|
168
|
+
});
|
|
169
|
+
if (experiment.status === "completed" || experiment.status === "failed") return [];
|
|
170
|
+
if (experiment.targetType === null || experiment.targetId === null) throw new require_error.MastraError({
|
|
171
|
+
id: "EXPERIMENT_HAS_NO_TARGET",
|
|
172
|
+
text: `Experiment ${experiment.id} has no target to run`,
|
|
173
|
+
domain: "STORAGE",
|
|
174
|
+
category: "USER"
|
|
175
|
+
});
|
|
176
|
+
if (!await resolveTarget(mastra, experiment.targetType, experiment.targetId, experiment.agentVersion ?? void 0)) throw new require_error.MastraError({
|
|
177
|
+
id: "EXPERIMENT_TARGET_NOT_FOUND",
|
|
178
|
+
text: `Target not found: ${experiment.targetType} "${experiment.targetId}"`,
|
|
179
|
+
domain: "STORAGE",
|
|
180
|
+
category: "USER"
|
|
181
|
+
});
|
|
182
|
+
const items = await datasetsStore.getItemsByVersion({
|
|
183
|
+
datasetId: dataset.id,
|
|
184
|
+
version: experiment.datasetVersion ?? 0
|
|
185
|
+
});
|
|
186
|
+
if (experiment.status !== "running") await experimentsStore.updateExperiment({
|
|
187
|
+
id: experiment.id,
|
|
188
|
+
status: "running",
|
|
189
|
+
startedAt: /* @__PURE__ */ new Date()
|
|
190
|
+
});
|
|
191
|
+
return items.map((item) => ({ itemId: item.id }));
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const runItemStep = require_run_registry.createStep({
|
|
196
|
+
id: "runItem",
|
|
197
|
+
inputSchema: itemRefSchema,
|
|
198
|
+
outputSchema: itemOutcomeSchema,
|
|
199
|
+
execute: async ({ inputData, getInitData, mastra }) => {
|
|
200
|
+
const input = getInitData();
|
|
201
|
+
return failExperimentOnError(mastra, input, async () => {
|
|
202
|
+
const { result } = await (await datasetHandle(mastra, input)).runExperimentItem({
|
|
203
|
+
experimentId: input.experimentId,
|
|
204
|
+
itemId: inputData.itemId,
|
|
205
|
+
requestContext: input.requestContext,
|
|
206
|
+
agentModel: input.agentModel,
|
|
207
|
+
unmockedToolPolicy: input.unmockedToolPolicy,
|
|
208
|
+
itemTimeout: input.itemTimeout,
|
|
209
|
+
maxRetries: input.maxRetries,
|
|
210
|
+
versions: input.versions
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
itemId: inputData.itemId,
|
|
214
|
+
failed: result.error !== null
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
const finalizeStep = require_run_registry.createStep({
|
|
220
|
+
id: "finalize",
|
|
221
|
+
inputSchema: zod.z.array(itemOutcomeSchema),
|
|
222
|
+
outputSchema: zod.z.object({
|
|
223
|
+
experimentId: zod.z.string(),
|
|
224
|
+
status: zod.z.string(),
|
|
225
|
+
succeededCount: zod.z.number(),
|
|
226
|
+
failedCount: zod.z.number(),
|
|
227
|
+
skippedCount: zod.z.number()
|
|
228
|
+
}),
|
|
229
|
+
execute: async ({ getInitData, mastra }) => {
|
|
230
|
+
const input = getInitData();
|
|
231
|
+
return failExperimentOnError(mastra, input, async () => {
|
|
232
|
+
const experiment = await (await datasetHandle(mastra, input)).finalizeExperiment({ experimentId: input.experimentId });
|
|
233
|
+
return {
|
|
234
|
+
experimentId: experiment.id,
|
|
235
|
+
status: experiment.status,
|
|
236
|
+
succeededCount: experiment.succeededCount,
|
|
237
|
+
failedCount: experiment.failedCount,
|
|
238
|
+
skippedCount: experiment.skippedCount
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
/**
|
|
244
|
+
* Runs a stored experiment on the evented engine: `prepare` lists the items,
|
|
245
|
+
* each item runs as its own step via `runExperimentItem` (one result row per
|
|
246
|
+
* item, so a redelivered step converges), and `finalize` counts the rows.
|
|
247
|
+
*/
|
|
248
|
+
function buildExperimentWorkflow() {
|
|
249
|
+
return require_run_registry.createWorkflow$1({
|
|
250
|
+
id: EXPERIMENT_WORKFLOW_ID,
|
|
251
|
+
inputSchema: experimentWorkflowInputSchema,
|
|
252
|
+
outputSchema: finalizeStep.outputSchema
|
|
253
|
+
}).then(prepareStep).foreach(runItemStep, { concurrency: ({ getInitData }) => experimentWorkflowInputSchema.parse(getInitData()).maxConcurrency ?? DEFAULT_MAX_CONCURRENCY }).then(finalizeStep).commit();
|
|
254
|
+
}
|
|
255
|
+
// src/datasets/experiment/durable.ts
|
|
256
|
+
/** Error id thrown when `durable: true` is combined with an option a durable run can't carry. */
|
|
257
|
+
const EXPERIMENT_NOT_DURABLE = "EXPERIMENT_NOT_DURABLE";
|
|
258
|
+
function notDurable(option, reason) {
|
|
259
|
+
return new require_error.MastraError({
|
|
260
|
+
id: EXPERIMENT_NOT_DURABLE,
|
|
261
|
+
domain: "STORAGE",
|
|
262
|
+
category: "USER",
|
|
263
|
+
text: `durable experiments can't use \`${option}\`: ${reason}`
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/** Strings, finite numbers, booleans, null, arrays and plain objects survive a JSON broker unchanged. */
|
|
267
|
+
function isPlainJson(value) {
|
|
268
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
269
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
270
|
+
if (Array.isArray(value)) return value.every(isPlainJson);
|
|
271
|
+
if (typeof value !== "object") return false;
|
|
272
|
+
const proto = Object.getPrototypeOf(value);
|
|
273
|
+
return (proto === Object.prototype || proto === null) && Object.values(value).every(isPlainJson);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Check a `durable: true` config and return the run options the experiment
|
|
277
|
+
* workflow carries, plus the scorer ids to pin on the experiment. A durable run may continue in another process, so every
|
|
278
|
+
* option has to be JSON: functions, signals, model objects and scorer objects
|
|
279
|
+
* are rejected before anything is created.
|
|
280
|
+
*/
|
|
281
|
+
function durableRunOptions(config) {
|
|
282
|
+
if (config.task) throw notDurable("task", "run a registered target (targetType + targetId) instead");
|
|
283
|
+
if (!config.targetType || !config.targetId) throw notDurable("targetType", "targetType and targetId must name a registered target");
|
|
284
|
+
for (const hook of [
|
|
285
|
+
"beforeAll",
|
|
286
|
+
"afterAll",
|
|
287
|
+
"beforeEach",
|
|
288
|
+
"afterEach"
|
|
289
|
+
]) if (config[hook]) throw notDurable(hook, "hooks are functions and only run in the starting process");
|
|
290
|
+
if (config.onEvent) throw notDurable("onEvent", "observers only run in the starting process");
|
|
291
|
+
if (config.signal) throw notDurable("signal", "an AbortSignal only exists in the starting process");
|
|
292
|
+
let scorerIds;
|
|
293
|
+
if (config.scorers !== void 0) {
|
|
294
|
+
if (!Array.isArray(config.scorers)) throw notDurable("scorers", "pass an array of registered scorer ids (step scorers are not supported)");
|
|
295
|
+
scorerIds = config.scorers.filter((scorer) => typeof scorer === "string");
|
|
296
|
+
if (scorerIds.length !== config.scorers.length) throw notDurable("scorers", "pass registered scorer ids, not scorer objects");
|
|
297
|
+
}
|
|
298
|
+
if (config.persistence?.experiments === "none" || config.persistence?.scores === "none") throw notDurable("persistence", "a durable run is tracked through stored experiments and scores");
|
|
299
|
+
const requestContext = config.requestContext === void 0 ? void 0 : require_request_context.withoutLiveRequestKeys(config.requestContext);
|
|
300
|
+
if (requestContext !== void 0 && !isPlainJson(requestContext)) throw notDurable("requestContext", "values must be plain JSON (no functions, class instances, undefined or NaN)");
|
|
301
|
+
if (config.agentModel !== void 0 && typeof config.agentModel !== "string") throw notDurable("agentModel", "pass a \"provider/model\" string, not a model object");
|
|
302
|
+
const runOptions = {
|
|
303
|
+
maxConcurrency: config.maxConcurrency,
|
|
304
|
+
itemTimeout: config.itemTimeout,
|
|
305
|
+
maxRetries: config.maxRetries,
|
|
306
|
+
agentModel: config.agentModel,
|
|
307
|
+
unmockedToolPolicy: config.unmockedToolPolicy,
|
|
308
|
+
requestContext,
|
|
309
|
+
versions: config.versions
|
|
310
|
+
};
|
|
311
|
+
const parsed = experimentWorkflowInputSchema.omit({
|
|
312
|
+
datasetId: true,
|
|
313
|
+
experimentId: true
|
|
314
|
+
}).safeParse(runOptions);
|
|
315
|
+
if (!parsed.success) {
|
|
316
|
+
const issue = parsed.error.issues[0];
|
|
317
|
+
throw notDurable(String(issue.path[0]), issue.message);
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
runOptions,
|
|
321
|
+
scorerIds
|
|
322
|
+
};
|
|
323
|
+
}
|
|
37
324
|
// src/datasets/experiment/events.ts
|
|
38
325
|
var ExperimentEventDispatcher = class {
|
|
39
326
|
abortController = new AbortController();
|
|
@@ -638,46 +925,67 @@ function handleWorkflowResult(result) {
|
|
|
638
925
|
spanId
|
|
639
926
|
};
|
|
640
927
|
}
|
|
641
|
-
// src/datasets/experiment/
|
|
928
|
+
// src/datasets/experiment/retries.ts
|
|
642
929
|
/**
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* will have the versioned config applied (via `applyStoredOverrides`).
|
|
646
|
-
*
|
|
647
|
-
* The result is wrapped in `{ target }` because `Workflow` has a `.then`
|
|
648
|
-
* method for step chaining, which makes it thenable. Returning a thenable
|
|
649
|
-
* from an async function causes the Promise machinery to attempt to unwrap
|
|
650
|
-
* it, which hangs forever since the builder `.then` never invokes its
|
|
651
|
-
* callbacks. Wrapping in a plain object avoids the unwrap.
|
|
930
|
+
* Tool-mock failures are deterministic: the matcher state can't change between
|
|
931
|
+
* attempts, so retrying would always fail identically.
|
|
652
932
|
*/
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
933
|
+
const NON_RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
934
|
+
TOOL_MOCK_MISMATCH,
|
|
935
|
+
TOOL_MOCK_EXHAUSTED,
|
|
936
|
+
TOOL_MOCK_NOT_DECLARED
|
|
937
|
+
]);
|
|
938
|
+
/** Resolves after `ms`, or as soon as `signal` aborts. */
|
|
939
|
+
function wait(ms, signal) {
|
|
940
|
+
return new Promise((resolve) => {
|
|
941
|
+
if (signal?.aborted) return resolve();
|
|
942
|
+
const done = () => {
|
|
943
|
+
clearTimeout(timer);
|
|
944
|
+
signal?.removeEventListener("abort", done);
|
|
945
|
+
resolve();
|
|
946
|
+
};
|
|
947
|
+
const timer = setTimeout(done, ms);
|
|
948
|
+
signal?.addEventListener("abort", done, { once: true });
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Run one item, retrying a failed execution up to `maxRetries` times with
|
|
953
|
+
* exponential backoff (1s doubling, capped at 30s, plus up to 20% jitter).
|
|
954
|
+
* Abort/timeout errors and tool-mock failures are never retried. Throws an
|
|
955
|
+
* `AbortError` when `cancelSignal` is aborted between attempts. When
|
|
956
|
+
* `timeoutSignal` (the item timeout) fires during the backoff, the wait ends
|
|
957
|
+
* and the item fails with the timeout error instead of retrying.
|
|
958
|
+
*/
|
|
959
|
+
async function executeWithRetries(execute, options) {
|
|
960
|
+
let retryCount = 0;
|
|
961
|
+
let execResult = await execute();
|
|
962
|
+
while (execResult.error && retryCount < options.maxRetries) {
|
|
963
|
+
if (execResult.error.message.toLowerCase().includes("abort")) break;
|
|
964
|
+
if (execResult.error.code && NON_RETRYABLE_ERROR_CODES.has(execResult.error.code)) break;
|
|
965
|
+
const delay = Math.min(1e3 * Math.pow(2, retryCount), 3e4);
|
|
966
|
+
await wait(delay + delay * .2 * Math.random(), options.timeoutSignal);
|
|
967
|
+
if (options.cancelSignal?.aborted) throw new DOMException("Aborted", "AbortError");
|
|
968
|
+
if (options.timeoutSignal?.aborted) {
|
|
969
|
+
const reason = options.timeoutSignal.reason;
|
|
970
|
+
return {
|
|
971
|
+
execResult: {
|
|
972
|
+
...execResult,
|
|
973
|
+
output: null,
|
|
974
|
+
error: {
|
|
975
|
+
message: reason instanceof Error ? reason.message : String(reason),
|
|
976
|
+
stack: reason instanceof Error ? reason.stack : void 0
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
retryCount
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
retryCount++;
|
|
983
|
+
execResult = await execute();
|
|
679
984
|
}
|
|
680
|
-
return
|
|
985
|
+
return {
|
|
986
|
+
execResult,
|
|
987
|
+
retryCount
|
|
988
|
+
};
|
|
681
989
|
}
|
|
682
990
|
// src/datasets/experiment/scorer.ts
|
|
683
991
|
function toScorerTargetEntityType(targetType) {
|
|
@@ -1401,9 +1709,9 @@ function buildEmptyResult(experimentA, experimentB, versionMismatch, warnings) {
|
|
|
1401
1709
|
* ({@link EXPERIMENT_ITEM_SCORER_NOT_FOUND}): the target is not executed and
|
|
1402
1710
|
* the error is recorded on the row.
|
|
1403
1711
|
*
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1712
|
+
* Applies the same per-item run options as the in-process runner (model
|
|
1713
|
+
* override, tool mocks, timeout, retries) but excludes its loop-level concerns:
|
|
1714
|
+
* hooks, event dispatch, and step scorers.
|
|
1407
1715
|
*/
|
|
1408
1716
|
async function executeExperimentItem(args) {
|
|
1409
1717
|
const { mastra, experiment, item } = args;
|
|
@@ -1445,13 +1753,27 @@ async function executeExperimentItem(args) {
|
|
|
1445
1753
|
...args.requestContext,
|
|
1446
1754
|
...item.requestContext
|
|
1447
1755
|
} : void 0;
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1756
|
+
const targetType = experiment.targetType;
|
|
1757
|
+
const isAgent = targetType === "agent";
|
|
1758
|
+
const signal = args.itemTimeout ? AbortSignal.timeout(args.itemTimeout) : void 0;
|
|
1759
|
+
const { execResult, retryCount } = scorerConfigError ? {
|
|
1760
|
+
execResult: {
|
|
1761
|
+
output: null,
|
|
1762
|
+
error: scorerConfigError,
|
|
1763
|
+
traceId: null
|
|
1764
|
+
},
|
|
1765
|
+
retryCount: 0
|
|
1766
|
+
} : await executeWithRetries(() => executeTarget(resolved.target, targetType, item, {
|
|
1767
|
+
signal,
|
|
1453
1768
|
requestContext: mergedRequestContext,
|
|
1454
|
-
experimentId: experiment.id
|
|
1769
|
+
experimentId: experiment.id,
|
|
1770
|
+
versions: args.versions,
|
|
1771
|
+
agentModel: args.agentModel,
|
|
1772
|
+
toolMocks: isAgent ? item.toolMocks : void 0,
|
|
1773
|
+
unmockedToolPolicy: isAgent ? item.unmockedToolPolicy ?? args.unmockedToolPolicy ?? "allow" : void 0
|
|
1774
|
+
}), {
|
|
1775
|
+
maxRetries: args.maxRetries ?? 0,
|
|
1776
|
+
timeoutSignal: signal
|
|
1455
1777
|
});
|
|
1456
1778
|
const completedAt = /* @__PURE__ */ new Date();
|
|
1457
1779
|
let scores = [];
|
|
@@ -1473,11 +1795,13 @@ async function executeExperimentItem(args) {
|
|
|
1473
1795
|
input: item.input,
|
|
1474
1796
|
output: execResult.output,
|
|
1475
1797
|
groundTruth: item.groundTruth ?? null,
|
|
1798
|
+
metadata: item.metadata ?? null,
|
|
1476
1799
|
error: execResult.error,
|
|
1477
1800
|
startedAt,
|
|
1478
1801
|
completedAt,
|
|
1479
|
-
retryCount
|
|
1802
|
+
retryCount,
|
|
1480
1803
|
traceId: execResult.traceId,
|
|
1804
|
+
toolMockReport: execResult.toolMockReport ?? null,
|
|
1481
1805
|
organizationId: args.organizationId ?? null,
|
|
1482
1806
|
projectId: args.projectId ?? null
|
|
1483
1807
|
}),
|
|
@@ -1798,11 +2122,8 @@ async function runExperiment(mastra, config) {
|
|
|
1798
2122
|
message: `Item scorer configuration references unregistered scorer IDs: ${resolution.missingIds.join(", ")}`
|
|
1799
2123
|
};
|
|
1800
2124
|
} else itemScorers = datasetScorers;
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
const timeoutSignal = AbortSignal.timeout(itemTimeout);
|
|
1804
|
-
itemSignal = executionSignal ? AbortSignal.any([executionSignal, timeoutSignal]) : timeoutSignal;
|
|
1805
|
-
}
|
|
2125
|
+
const timeoutSignal = itemTimeout ? AbortSignal.timeout(itemTimeout) : void 0;
|
|
2126
|
+
const itemSignal = executionSignal && timeoutSignal ? AbortSignal.any([executionSignal, timeoutSignal]) : timeoutSignal ?? executionSignal;
|
|
1806
2127
|
let beforeEachError = null;
|
|
1807
2128
|
if (beforeEach && !scorerConfigError) try {
|
|
1808
2129
|
await beforeEach({
|
|
@@ -1821,23 +2142,19 @@ async function runExperiment(mastra, config) {
|
|
|
1821
2142
|
stack: hookError instanceof Error ? hookError.stack : void 0
|
|
1822
2143
|
};
|
|
1823
2144
|
}
|
|
1824
|
-
let retryCount = 0;
|
|
1825
2145
|
const preflightError = scorerConfigError ?? beforeEachError;
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
if (executionSignal?.aborted) throw new DOMException("Aborted", "AbortError");
|
|
1839
|
-
execResult = await execFn(itemWithMetadataSnapshot(), itemSignal);
|
|
1840
|
-
}
|
|
2146
|
+
const { execResult, retryCount } = preflightError ? {
|
|
2147
|
+
execResult: {
|
|
2148
|
+
output: null,
|
|
2149
|
+
error: preflightError,
|
|
2150
|
+
traceId: null
|
|
2151
|
+
},
|
|
2152
|
+
retryCount: 0
|
|
2153
|
+
} : await executeWithRetries(() => execFn(itemWithMetadataSnapshot(), itemSignal), {
|
|
2154
|
+
maxRetries,
|
|
2155
|
+
cancelSignal: executionSignal,
|
|
2156
|
+
timeoutSignal
|
|
2157
|
+
});
|
|
1841
2158
|
const itemCompletedAt = /* @__PURE__ */ new Date();
|
|
1842
2159
|
const itemResult = {
|
|
1843
2160
|
itemId: item.id,
|
|
@@ -2224,6 +2541,18 @@ var Dataset = class {
|
|
|
2224
2541
|
if (record.datasetId !== this.id) return null;
|
|
2225
2542
|
return record;
|
|
2226
2543
|
}
|
|
2544
|
+
/** Counts the items at a dataset version. `perPage: 0` makes storage return the total without any item rows. */
|
|
2545
|
+
async #countItems(version) {
|
|
2546
|
+
const { pagination } = await (await this.#getDatasetsStore()).listItems({
|
|
2547
|
+
datasetId: this.id,
|
|
2548
|
+
version,
|
|
2549
|
+
pagination: {
|
|
2550
|
+
page: 0,
|
|
2551
|
+
perPage: 0
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
return pagination.total;
|
|
2555
|
+
}
|
|
2227
2556
|
/**
|
|
2228
2557
|
* Get the full dataset record from storage.
|
|
2229
2558
|
*/
|
|
@@ -2412,12 +2741,16 @@ var Dataset = class {
|
|
|
2412
2741
|
/**
|
|
2413
2742
|
* Start an experiment asynchronously (fire-and-forget).
|
|
2414
2743
|
* Returns immediately with the experiment ID and pending status.
|
|
2744
|
+
*
|
|
2745
|
+
* With `durable: true` the experiment runs as an evented workflow whose run
|
|
2746
|
+
* id is the experiment id; see {@link StartExperimentAsyncConfig.durable}.
|
|
2415
2747
|
*/
|
|
2416
|
-
async startExperimentAsync(
|
|
2748
|
+
async startExperimentAsync(asyncConfig) {
|
|
2749
|
+
const { durable, ...config } = asyncConfig;
|
|
2417
2750
|
assertAgentModelTarget(config);
|
|
2751
|
+
const durableRun = durable ? durableRunOptions(config) : void 0;
|
|
2418
2752
|
const experimentsStore = config.persistence?.experiments !== "none" ? await this.#getExperimentsStore() : void 0;
|
|
2419
|
-
const
|
|
2420
|
-
const dataset = await datasetsStore.getDatasetById({
|
|
2753
|
+
const dataset = await (await this.#getDatasetsStore()).getDatasetById({
|
|
2421
2754
|
id: this.id,
|
|
2422
2755
|
filters: this.#scope
|
|
2423
2756
|
});
|
|
@@ -2428,11 +2761,8 @@ var Dataset = class {
|
|
|
2428
2761
|
category: "USER"
|
|
2429
2762
|
});
|
|
2430
2763
|
const targetVersion = config.version ?? dataset.version;
|
|
2431
|
-
const
|
|
2432
|
-
|
|
2433
|
-
version: targetVersion
|
|
2434
|
-
});
|
|
2435
|
-
if (items.length === 0) throw new require_error.MastraError({
|
|
2764
|
+
const totalItems = await this.#countItems(targetVersion);
|
|
2765
|
+
if (totalItems === 0) throw new require_error.MastraError({
|
|
2436
2766
|
id: "EXPERIMENT_NO_ITEMS",
|
|
2437
2767
|
text: `Cannot run experiment: dataset "${this.id}" has no items at version ${targetVersion}`,
|
|
2438
2768
|
domain: "STORAGE",
|
|
@@ -2445,7 +2775,7 @@ var Dataset = class {
|
|
|
2445
2775
|
datasetVersion: targetVersion,
|
|
2446
2776
|
targetType: config.targetType ?? "agent",
|
|
2447
2777
|
targetId: config.targetId ?? "inline",
|
|
2448
|
-
totalItems
|
|
2778
|
+
totalItems,
|
|
2449
2779
|
name: config.name,
|
|
2450
2780
|
description: config.description,
|
|
2451
2781
|
metadata: withAgentModelMetadata(config.metadata, config.agentModel),
|
|
@@ -2456,8 +2786,33 @@ var Dataset = class {
|
|
|
2456
2786
|
trialIndex: config.grouping?.trialIndex,
|
|
2457
2787
|
agentVersion: config.agentVersion,
|
|
2458
2788
|
organizationId: dataset.organizationId ?? null,
|
|
2459
|
-
projectId: dataset.projectId ?? null
|
|
2789
|
+
projectId: dataset.projectId ?? null,
|
|
2790
|
+
...durableRun ? { scorerIds: durableRun.scorerIds ?? null } : {}
|
|
2460
2791
|
});
|
|
2792
|
+
if (durableRun) {
|
|
2793
|
+
try {
|
|
2794
|
+
await this.#mastra.__ensureExperimentWorkflow();
|
|
2795
|
+
await (await this.#mastra.__getInternalWorkflow(EXPERIMENT_WORKFLOW_ID).createRun({ runId: experimentId })).startAsync({ inputData: {
|
|
2796
|
+
datasetId: this.id,
|
|
2797
|
+
experimentId,
|
|
2798
|
+
organizationId: this.#scope?.organizationId,
|
|
2799
|
+
projectId: this.#scope?.projectId,
|
|
2800
|
+
...durableRun.runOptions
|
|
2801
|
+
} });
|
|
2802
|
+
} catch (err) {
|
|
2803
|
+
await experimentsStore?.updateExperiment({
|
|
2804
|
+
id: experimentId,
|
|
2805
|
+
status: "failed",
|
|
2806
|
+
completedAt: /* @__PURE__ */ new Date()
|
|
2807
|
+
});
|
|
2808
|
+
throw err;
|
|
2809
|
+
}
|
|
2810
|
+
return {
|
|
2811
|
+
experimentId,
|
|
2812
|
+
status: "pending",
|
|
2813
|
+
totalItems
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2461
2816
|
runExperiment(this.#mastra, {
|
|
2462
2817
|
datasetId: this.id,
|
|
2463
2818
|
experimentId,
|
|
@@ -2475,7 +2830,7 @@ var Dataset = class {
|
|
|
2475
2830
|
return {
|
|
2476
2831
|
experimentId,
|
|
2477
2832
|
status: "pending",
|
|
2478
|
-
totalItems
|
|
2833
|
+
totalItems
|
|
2479
2834
|
};
|
|
2480
2835
|
}
|
|
2481
2836
|
/**
|
|
@@ -2702,11 +3057,8 @@ var Dataset = class {
|
|
|
2702
3057
|
}
|
|
2703
3058
|
}
|
|
2704
3059
|
const targetVersion = args?.version ?? dataset.version;
|
|
2705
|
-
const
|
|
2706
|
-
|
|
2707
|
-
version: targetVersion
|
|
2708
|
-
});
|
|
2709
|
-
if (items.length === 0) throw new require_error.MastraError({
|
|
3060
|
+
const totalItems = await this.#countItems(targetVersion);
|
|
3061
|
+
if (totalItems === 0) throw new require_error.MastraError({
|
|
2710
3062
|
id: "EXPERIMENT_NO_ITEMS",
|
|
2711
3063
|
text: `Cannot create experiment: dataset "${this.id}" has no items at version ${targetVersion}`,
|
|
2712
3064
|
domain: "STORAGE",
|
|
@@ -2721,7 +3073,7 @@ var Dataset = class {
|
|
|
2721
3073
|
targetType: args?.targetType ?? null,
|
|
2722
3074
|
targetId: args?.targetId ?? null,
|
|
2723
3075
|
scorerIds: args?.scorers?.length ? args.scorers : null,
|
|
2724
|
-
totalItems
|
|
3076
|
+
totalItems,
|
|
2725
3077
|
name: args?.name,
|
|
2726
3078
|
description: args?.description,
|
|
2727
3079
|
metadata: args?.metadata,
|
|
@@ -2763,7 +3115,7 @@ var Dataset = class {
|
|
|
2763
3115
|
return {
|
|
2764
3116
|
experimentId,
|
|
2765
3117
|
status: "running",
|
|
2766
|
-
totalItems
|
|
3118
|
+
totalItems,
|
|
2767
3119
|
datasetVersion: targetVersion,
|
|
2768
3120
|
startedAt
|
|
2769
3121
|
};
|
|
@@ -2774,15 +3126,22 @@ var Dataset = class {
|
|
|
2774
3126
|
* keyed by `(experimentId, itemId, attempt)`.
|
|
2775
3127
|
*
|
|
2776
3128
|
* Built for caller-driven loops (mode 2): a durable orchestrator (e.g. a
|
|
2777
|
-
* Temporal workflow) fans out one call per item
|
|
2778
|
-
*
|
|
2779
|
-
*
|
|
3129
|
+
* Temporal workflow) fans out one call per item — a retried call converges
|
|
3130
|
+
* on the same row. Requires an experiment created with a target via
|
|
3131
|
+
* {@link Dataset.createExperiment}. The run options (`agentModel`,
|
|
3132
|
+
* `unmockedToolPolicy`, `itemTimeout`, `maxRetries`, `versions`) behave as
|
|
3133
|
+
* they do in {@link Dataset.startExperiment}; the experiment record doesn't
|
|
3134
|
+
* store them, so pass them on every call.
|
|
2780
3135
|
*
|
|
2781
3136
|
* Scorer precedence: experiment `scorers` → item `scorerIds` → dataset
|
|
2782
3137
|
* `scorerIds` → none.
|
|
2783
3138
|
*/
|
|
2784
3139
|
async runExperimentItem(args) {
|
|
2785
3140
|
const experiment = await this.#getOwnedExperiment(args.experimentId);
|
|
3141
|
+
assertAgentModelTarget({
|
|
3142
|
+
agentModel: args.agentModel,
|
|
3143
|
+
targetType: experiment.targetType ?? void 0
|
|
3144
|
+
});
|
|
2786
3145
|
if (experiment.targetType === null) throw new require_error.MastraError({
|
|
2787
3146
|
id: "EXPERIMENT_HAS_NO_TARGET",
|
|
2788
3147
|
text: `Experiment ${args.experimentId} has no target; ingest results via submitExperimentResult instead`,
|
|
@@ -2821,11 +3180,18 @@ var Dataset = class {
|
|
|
2821
3180
|
expectedTrajectory: item.expectedTrajectory ?? void 0,
|
|
2822
3181
|
requestContext: item.requestContext ?? void 0,
|
|
2823
3182
|
metadata: item.metadata ?? void 0,
|
|
2824
|
-
scorerIds: item.scorerIds ?? void 0
|
|
3183
|
+
scorerIds: item.scorerIds ?? void 0,
|
|
3184
|
+
toolMocks: item.toolMocks ?? void 0,
|
|
3185
|
+
unmockedToolPolicy: item.unmockedToolPolicy ?? void 0
|
|
2825
3186
|
},
|
|
2826
3187
|
datasetScorerIds: dataset?.scorerIds ?? null,
|
|
2827
3188
|
attempt: args.attempt ?? 0,
|
|
2828
3189
|
requestContext: args.requestContext,
|
|
3190
|
+
agentModel: args.agentModel,
|
|
3191
|
+
unmockedToolPolicy: args.unmockedToolPolicy,
|
|
3192
|
+
itemTimeout: args.itemTimeout,
|
|
3193
|
+
maxRetries: args.maxRetries,
|
|
3194
|
+
versions: args.versions,
|
|
2829
3195
|
organizationId: experiment.organizationId ?? dataset?.organizationId ?? null,
|
|
2830
3196
|
projectId: experiment.projectId ?? dataset?.projectId ?? null
|
|
2831
3197
|
});
|
|
@@ -3298,6 +3664,18 @@ Object.defineProperty(exports, "EXPERIMENT_ITEM_SCORER_NOT_FOUND", {
|
|
|
3298
3664
|
return EXPERIMENT_ITEM_SCORER_NOT_FOUND;
|
|
3299
3665
|
}
|
|
3300
3666
|
});
|
|
3667
|
+
Object.defineProperty(exports, "EXPERIMENT_NOT_DURABLE", {
|
|
3668
|
+
enumerable: true,
|
|
3669
|
+
get: function() {
|
|
3670
|
+
return EXPERIMENT_NOT_DURABLE;
|
|
3671
|
+
}
|
|
3672
|
+
});
|
|
3673
|
+
Object.defineProperty(exports, "EXPERIMENT_WORKFLOW_ID", {
|
|
3674
|
+
enumerable: true,
|
|
3675
|
+
get: function() {
|
|
3676
|
+
return EXPERIMENT_WORKFLOW_ID;
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3301
3679
|
Object.defineProperty(exports, "TOOL_MOCK_EXHAUSTED", {
|
|
3302
3680
|
enumerable: true,
|
|
3303
3681
|
get: function() {
|
|
@@ -3382,3 +3760,9 @@ Object.defineProperty(exports, "runScorersForItem", {
|
|
|
3382
3760
|
return runScorersForItem;
|
|
3383
3761
|
}
|
|
3384
3762
|
});
|
|
3763
|
+
Object.defineProperty(exports, "workflow_exports", {
|
|
3764
|
+
enumerable: true,
|
|
3765
|
+
get: function() {
|
|
3766
|
+
return workflow_exports;
|
|
3767
|
+
}
|
|
3768
|
+
});
|