@mastra/core 1.86.0-alpha.6 → 1.86.0-alpha.8
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/memory/index.d.ts +25 -0
- package/dist/agent/agent.d.ts +87 -12
- package/dist/agent/agent.types.d.ts +34 -2
- package/dist/agent/durable/create-durable-agent.d.ts +1 -1
- package/dist/agent/durable/create-evented-agent.d.ts +6 -0
- package/dist/agent/durable/durable-agent.d.ts +30 -514
- package/dist/agent/durable/durable-stream-until-idle.d.ts +2 -1
- package/dist/agent/durable/evented-agent.d.ts +2 -5
- package/dist/agent/durable/execution-engine.d.ts +20 -3
- package/dist/agent/durable/index.cjs +61 -6351
- package/dist/agent/durable/index.d.ts +3 -2
- package/dist/agent/durable/index.js +50 -6340
- package/dist/agent/durable/stream-adapter.d.ts +5 -5
- package/dist/agent/durable/types.d.ts +454 -3
- package/dist/agent/durable/workflows/durable-loop-builder.d.ts +7 -9
- package/dist/agent/helpers.d.ts +1 -1
- package/dist/agent/index.cjs +4 -4
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +4 -4
- package/dist/agent/streams/execution-capability.d.ts +3 -2
- package/dist/agent/streams/execution-policy.d.ts +1 -1
- package/dist/agent/streams/types.d.ts +3 -3
- package/dist/agent/types.d.ts +30 -5
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/index.cjs +2 -2
- package/dist/agent-controller/index.js +2 -2
- package/dist/{agent-controller-c4KbZ8DY.js → agent-controller-B7POPub5.js} +9 -9
- package/dist/{agent-controller-6ORqG6hK.cjs → agent-controller-DEPayioq.cjs} +9 -9
- package/dist/{agent-skills-resolver-BIeWsb01.cjs → agent-skills-resolver-BMoCDoaK.cjs} +1 -1
- package/dist/{agent-skills-resolver-k04IRam7.js → agent-skills-resolver-CUEIMDbx.js} +1 -1
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-Da0c3R-J.cjs → background-tasks-7iftnRK_.cjs} +1 -1
- package/dist/{background-tasks-CEglmAt7.js → background-tasks-Cv1ecD6S.js} +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-DS826dWf.cjs → builder-DuJBbQDH.cjs} +3 -3
- package/dist/{builder-0V9N8S15.js → builder-Gg-xnX_E.js} +3 -3
- package/dist/capabilities/302ai.json +198 -198
- package/dist/capabilities/abliteratedllm.json +38 -38
- package/dist/capabilities/abliteration-ai.json +6 -6
- package/dist/capabilities/above.json +23 -23
- package/dist/capabilities/adaption.json +14 -14
- package/dist/capabilities/adzuki.json +22 -22
- package/dist/capabilities/agentrouter.json +7 -7
- package/dist/capabilities/agnes.json +2 -2
- package/dist/capabilities/ai-router.json +5 -5
- package/dist/capabilities/aiand.json +23 -23
- package/dist/capabilities/aigrow.json +15 -15
- package/dist/capabilities/aimlapi.json +143 -143
- package/dist/capabilities/aipg.json +2 -2
- package/dist/capabilities/aixy.json +16 -16
- package/dist/capabilities/aki-io.json +12 -12
- package/dist/capabilities/alibaba-cn.json +84 -84
- package/dist/capabilities/alibaba-coding-plan-cn.json +5 -5
- package/dist/capabilities/alibaba-coding-plan.json +5 -5
- package/dist/capabilities/alibaba-token-plan-cn.json +51 -51
- package/dist/capabilities/alibaba-token-plan.json +52 -52
- package/dist/capabilities/alibaba.json +69 -69
- package/dist/capabilities/ambient.json +12 -12
- package/dist/capabilities/amd.json +10 -10
- package/dist/capabilities/anthropic.json +64 -40
- package/dist/capabilities/anyapi.json +12 -12
- package/dist/capabilities/apiko.json +5 -5
- package/dist/capabilities/arcee.json +7 -7
- package/dist/capabilities/augure.json +8 -8
- package/dist/capabilities/auriko.json +21 -21
- package/dist/capabilities/bailing.json +2 -2
- package/dist/capabilities/baseten.json +26 -26
- package/dist/capabilities/bee.json +4 -4
- package/dist/capabilities/berget.json +4 -4
- package/dist/capabilities/bothub.json +17 -17
- package/dist/capabilities/boundless.json +41 -41
- package/dist/capabilities/bumo.json +43 -43
- package/dist/capabilities/byteplus.json +31 -31
- package/dist/capabilities/cerebras.json +4 -4
- package/dist/capabilities/cheapaimodel.json +6 -6
- package/dist/capabilities/cheapest-token.json +32 -32
- package/dist/capabilities/chutes.json +10 -10
- package/dist/capabilities/cline-pass.json +43 -43
- package/dist/capabilities/cloudcode.json +8 -8
- package/dist/capabilities/cloudferro-sherlock.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +31 -31
- package/dist/capabilities/commandcode.json +151 -151
- package/dist/capabilities/concentrate.json +287 -263
- package/dist/capabilities/cortecs.json +106 -106
- package/dist/capabilities/crossmodel.json +189 -189
- package/dist/capabilities/crusoe.json +3 -3
- package/dist/capabilities/daoxe.json +9 -9
- package/dist/capabilities/databricks.json +62 -62
- package/dist/capabilities/deepinfra.json +97 -88
- package/dist/capabilities/deepseek.json +3 -3
- package/dist/capabilities/digitalocean.json +114 -114
- package/dist/capabilities/dothoosh.json +36 -36
- package/dist/capabilities/doubleword.json +29 -29
- package/dist/capabilities/edenai.json +443 -442
- package/dist/capabilities/empiriolabs.json +172 -172
- package/dist/capabilities/engy.json +20 -20
- package/dist/capabilities/entrim.json +8 -8
- package/dist/capabilities/evroc.json +15 -15
- package/dist/capabilities/ezkielyna.json +7 -7
- package/dist/capabilities/fastrouter.json +82 -82
- package/dist/capabilities/fireworks-ai.json +50 -50
- package/dist/capabilities/freemodel.json +24 -24
- package/dist/capabilities/friendli.json +6 -6
- package/dist/capabilities/frogbot.json +98 -98
- package/dist/capabilities/gisoo.json +20 -20
- package/dist/capabilities/gmicloud.json +14 -14
- package/dist/capabilities/google.json +60 -60
- package/dist/capabilities/graphn.json +12 -12
- package/dist/capabilities/greenpt.json +33 -33
- package/dist/capabilities/groq.json +9 -9
- package/dist/capabilities/helicone.json +81 -81
- package/dist/capabilities/hopper.json +2 -2
- package/dist/capabilities/hostinger-router.json +12 -12
- package/dist/capabilities/hpc-ai.json +10 -10
- package/dist/capabilities/huawei-maas.json +15 -15
- package/dist/capabilities/hubris.json +27 -27
- package/dist/capabilities/huggingface.json +59 -50
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +25 -25
- package/dist/capabilities/impossibl.json +140 -140
- package/dist/capabilities/inception.json +2 -2
- package/dist/capabilities/inceptron.json +8 -8
- package/dist/capabilities/inco.json +4 -4
- package/dist/capabilities/infer.json +14 -14
- package/dist/capabilities/inferall.json +7 -7
- package/dist/capabilities/inference-coop.json +15 -15
- package/dist/capabilities/inferenceapis.json +18 -18
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +13 -13
- package/dist/capabilities/infomaniak.json +2 -2
- package/dist/capabilities/io-net.json +5 -5
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +54 -54
- package/dist/capabilities/jalapeno.json +12 -12
- package/dist/capabilities/jiekou.json +63 -63
- package/dist/capabilities/joingonka.json +4 -4
- package/dist/capabilities/jzstoken.json +56 -56
- package/dist/capabilities/keln.json +27 -27
- package/dist/capabilities/kenari.json +117 -111
- package/dist/capabilities/kilo.json +625 -649
- package/dist/capabilities/kimi-code-plan-cn.json +6 -6
- package/dist/capabilities/kimi-code-plan-global.json +6 -6
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +21 -21
- package/dist/capabilities/korouter.json +33 -33
- package/dist/capabilities/kunavo.json +9 -9
- package/dist/capabilities/liquid.json +8 -8
- package/dist/capabilities/lithosai.json +3 -3
- package/dist/capabilities/llmgateway-providers.json +932 -905
- package/dist/capabilities/llmgateway.json +343 -343
- package/dist/capabilities/llmtr.json +25 -25
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +48 -48
- package/dist/capabilities/lyceum.json +13 -13
- package/dist/capabilities/melious.json +13 -13
- package/dist/capabilities/merge-gateway.json +294 -294
- package/dist/capabilities/meta.json +10 -10
- package/dist/capabilities/minimax-cn-coding-plan.json +6 -6
- package/dist/capabilities/minimax-coding-plan.json +6 -6
- package/dist/capabilities/mistral.json +20 -20
- package/dist/capabilities/mixlayer.json +3 -3
- package/dist/capabilities/modal.json +14 -14
- package/dist/capabilities/model-oracle-ai.json +19 -19
- package/dist/capabilities/modelis.json +19 -19
- package/dist/capabilities/modular.json +5 -5
- package/dist/capabilities/moneo.json +17 -17
- package/dist/capabilities/moonshotai-cn.json +5 -5
- package/dist/capabilities/moonshotai.json +5 -5
- package/dist/capabilities/morph.json +14 -14
- package/dist/capabilities/munito-eu.json +8 -8
- package/dist/capabilities/munito.json +10 -10
- package/dist/capabilities/nan.json +28 -28
- package/dist/capabilities/nano-gpt.json +597 -567
- package/dist/capabilities/nearai.json +89 -89
- package/dist/capabilities/nebius.json +40 -31
- package/dist/capabilities/neon.json +135 -135
- package/dist/capabilities/neuralwatt.json +39 -39
- package/dist/capabilities/nokeep.json +2 -2
- package/dist/capabilities/novita-ai.json +158 -158
- package/dist/capabilities/nvidia.json +35 -35
- package/dist/capabilities/oathbreaker.json +2 -2
- package/dist/capabilities/obscurify.json +26 -26
- package/dist/capabilities/oci.json +6 -6
- package/dist/capabilities/ofox.json +352 -352
- package/dist/capabilities/ollama-cloud.json +52 -52
- package/dist/capabilities/openai.json +49 -56
- package/dist/capabilities/opencode-go.json +82 -81
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +557 -567
- package/dist/capabilities/opper.json +28 -22
- package/dist/capabilities/orcarouter.json +230 -230
- package/dist/capabilities/outerlabs.json +33 -33
- package/dist/capabilities/ovhcloud.json +6 -6
- package/dist/capabilities/pareto.json +6 -6
- package/dist/capabilities/perplexity-agent.json +58 -58
- package/dist/capabilities/perplexity.json +2 -2
- package/dist/capabilities/phala.json +22 -22
- package/dist/capabilities/pioneer.json +30 -30
- package/dist/capabilities/poe.json +122 -122
- package/dist/capabilities/poolside.json +3 -3
- package/dist/capabilities/powerspring.json +10 -10
- package/dist/capabilities/primalabs.json +8 -8
- package/dist/capabilities/prime.json +114 -97
- package/dist/capabilities/privatemode-ai.json +11 -11
- package/dist/capabilities/proxystacks.json +7 -7
- package/dist/capabilities/qiniu-ai.json +13 -13
- package/dist/capabilities/refuseless.json +7 -7
- package/dist/capabilities/regolo-ai.json +6 -6
- package/dist/capabilities/requesty.json +172 -189
- package/dist/capabilities/ruapi.json +18 -18
- package/dist/capabilities/runcrate.json +17 -17
- package/dist/capabilities/runinfra.json +16 -16
- package/dist/capabilities/sakana.json +6 -6
- package/dist/capabilities/sambanova.json +4 -4
- package/dist/capabilities/sandbase.json +24 -24
- package/dist/capabilities/sarvam.json +12 -12
- package/dist/capabilities/scaleway.json +19 -19
- package/dist/capabilities/scnet-token-plan.json +10 -10
- package/dist/capabilities/scx-ai.json +23 -23
- package/dist/capabilities/sensenova.json +14 -14
- package/dist/capabilities/siliconflow-cn.json +64 -64
- package/dist/capabilities/siliconflow.json +63 -63
- package/dist/capabilities/snowflake-cortex.json +23 -23
- package/dist/capabilities/sokkan.json +12 -12
- package/dist/capabilities/sparrowcodes.json +23 -23
- package/dist/capabilities/standardcompute.json +83 -83
- package/dist/capabilities/steadyrouter.json +39 -39
- package/dist/capabilities/stepfun-ai-step-plan.json +5 -5
- package/dist/capabilities/stepfun-ai.json +5 -5
- package/dist/capabilities/stepfun-step-plan.json +5 -5
- package/dist/capabilities/stepfun.json +5 -5
- package/dist/capabilities/stepping-stone.json +16 -16
- package/dist/capabilities/superbot-gg.json +4 -4
- package/dist/capabilities/synthetic.json +14 -14
- package/dist/capabilities/synthorai.json +29 -29
- package/dist/capabilities/teamorouter.json +26 -26
- package/dist/capabilities/teapot-router.json +13 -13
- package/dist/capabilities/tencent-coding-plan.json +2 -2
- package/dist/capabilities/tencent-token-plan.json +30 -30
- package/dist/capabilities/tencent-tokenhub.json +8 -8
- package/dist/capabilities/tensorx.json +45 -45
- package/dist/capabilities/tenstorrent.json +8 -8
- package/dist/capabilities/the-grid-ai.json +35 -35
- package/dist/capabilities/thinkingmachines.json +59 -59
- package/dist/capabilities/tinfoil.json +5 -5
- package/dist/capabilities/toapis.json +2 -2
- package/dist/capabilities/togetherai.json +59 -59
- package/dist/capabilities/tokengo.json +24 -24
- package/dist/capabilities/tokenify.json +9 -9
- package/dist/capabilities/trustedrouter.json +5 -5
- package/dist/capabilities/trustedtokens.json +18 -18
- package/dist/capabilities/umans-ai-coding-plan.json +18 -18
- package/dist/capabilities/umans-ai.json +15 -15
- package/dist/capabilities/uncensuredai.json +4 -4
- package/dist/capabilities/unrestricted.json +4 -4
- package/dist/capabilities/uplinkswitch.json +21 -21
- package/dist/capabilities/upstage.json +7 -7
- package/dist/capabilities/vancine.json +20 -20
- package/dist/capabilities/vercel.json +568 -576
- package/dist/capabilities/vivgrid.json +78 -78
- package/dist/capabilities/volcengine-coding-plan.json +30 -30
- package/dist/capabilities/volcengine.json +35 -35
- package/dist/capabilities/vultr.json +27 -27
- package/dist/capabilities/wafer.ai.json +16 -16
- 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 +26 -26
- package/dist/capabilities/xai.json +7 -7
- package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-cn.json +3 -3
- package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
- package/dist/capabilities/xiaomi.json +6 -6
- package/dist/capabilities/xpersona.json +12 -12
- package/dist/capabilities/xxapi.json +31 -31
- package/dist/capabilities/zai-coding-plan.json +13 -13
- package/dist/capabilities/zai.json +27 -27
- package/dist/capabilities/zenifra.json +27 -27
- package/dist/capabilities/zenmux.json +195 -195
- package/dist/capabilities/zerogpu.json +12 -12
- package/dist/capabilities/zhipuai-coding-plan.json +8 -8
- package/dist/capabilities/zhipuai.json +27 -27
- package/dist/capabilities/zro.json +6 -6
- package/dist/channels/agent-channels.d.ts +11 -0
- package/dist/channels/chat-tools.d.ts +156 -0
- package/dist/channels/index.cjs +7 -2
- package/dist/channels/index.d.ts +2 -0
- package/dist/channels/index.js +3 -3
- package/dist/{channels-C5DxhFRc.js → channels-BRVCOutx.js} +1 -1
- package/dist/{channels-B57qQolh.cjs → channels-MjTA9bFp.cjs} +1 -1
- package/dist/coding-agent/index.cjs +4 -4
- package/dist/coding-agent/index.js +4 -4
- package/dist/{constants-DaBkXs5H.cjs → constants-B9ZDvXZ4.cjs} +41 -0
- package/dist/{constants-BDHIyN28.js → constants-BmdTvEYN.js} +30 -1
- 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 +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1309 -1304
- 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-durable-agents.md +9 -5
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +1 -0
- package/dist/docs/references/docs-knowledge-load-your-content.md +1 -1
- package/dist/docs/references/docs-mastra-platform-observability-overview.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-workflows-overview.md +1 -1
- package/dist/docs/references/docs-workflows-scheduled-workflows.md +1 -1
- 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 +146 -24
- package/dist/docs/references/reference-agents-durable-agent.md +28 -2
- 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 +2 -2
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +43 -20
- 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 +1 -1
- 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/evals/index.cjs +2 -2
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +2 -2
- package/dist/evals/scoreTraces/index.js +2 -2
- 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/{filesystem-CUj0vclS.cjs → filesystem-B0AZrbj8.cjs} +1 -1
- package/dist/{filesystem-BBqrAmKK.js → filesystem-B3s0WRud.js} +1 -1
- package/dist/{filesystem-B_HACoLS.js → filesystem-B5X-5G0x.js} +1 -1
- package/dist/{filesystem-pZNvxjuW.cjs → filesystem-BDSpwBke.cjs} +1 -1
- package/dist/{filesystem-5Z777gYZ.js → filesystem-BsdkC311.js} +1 -1
- package/dist/{filesystem-BNHPgtjJ.cjs → filesystem-C-cyJfi1.cjs} +1 -1
- package/dist/{filesystem-U5o28b5w.cjs → filesystem-CEbD_77-.cjs} +1 -1
- package/dist/{filesystem-yHKEz2Pr.cjs → filesystem-CUAgLugE.cjs} +1 -1
- package/dist/{filesystem-Cb8iTPM-.js → filesystem-Cv79mHRk.js} +1 -1
- package/dist/{filesystem-DhiaddZe.cjs → filesystem-DsCQiBl2.cjs} +1 -1
- package/dist/{filesystem-DSYDB3ek.js → filesystem-DzM9pcQ8.js} +1 -1
- package/dist/{filesystem-gpIfFMed.js → filesystem-DzfqVTO_.js} +1 -1
- package/dist/{filesystem-versioned-CxbiSJF-.js → filesystem-versioned-Bijb_p9l.js} +44 -44
- package/dist/harness/index.cjs +2 -2
- package/dist/harness/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/index.cjs +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +7720 -7720
- package/dist/llm/model/shared.types.d.ts +31 -0
- package/dist/{llm-B0VtQDgT.js → llm-Djd8Qzi0.js} +2 -2
- package/dist/{llm-ByskI6z3.cjs → llm-DmUucguC.cjs} +2 -2
- package/dist/loop/base-loop-builder.d.ts +60 -0
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/loop/loop-builder.d.ts +10 -32
- package/dist/loop/workflows/agentic-execution/index.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +2 -2
- package/dist/loop/workflows/agentic-loop/index.d.ts +1 -1
- package/dist/{manager-C2RGNH68.js → manager-CO_Xz2zR.js} +461 -95
- package/dist/{manager-BJKx4lQf.cjs → manager-D27PkIPo.cjs} +477 -93
- 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-zUTq9ilk.js → mastra-Ch00nEAJ.js} +66 -25
- package/dist/{mastra-FXCeC5rF.cjs → mastra-qsVWpOTi.cjs} +66 -25
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.js +2 -2
- package/dist/{model-BTNRPDgQ.js → model-CW-mfGYA.js} +1 -1
- package/dist/{model-BmTFNo62.cjs → model-Do6DTJoj.cjs} +1 -1
- package/dist/{netlify-B_XdjYPY.cjs → netlify-DU32SDT6.cjs} +1 -1
- package/dist/{netlify-BCSVhO5q.js → netlify-DZSAbdve.js} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/{output-helpers-CncZ3y-g.cjs → output-helpers-1Zu4Vt9C.cjs} +112 -69
- package/dist/{output-helpers-RlvE2WPA.js → output-helpers-CedRCE17.js} +113 -70
- package/dist/processor-provider/index.cjs +1 -1
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/processors/processors/pii-detector.d.ts +1 -0
- package/dist/{provider-registry-Ble43Wb4.js → provider-registry-deA0x-Gd.js} +21349 -21338
- package/dist/{provider-registry-D8O1G18A.cjs → provider-registry-zGezZVsL.cjs} +21349 -21338
- package/dist/provider-registry.json +21695 -21680
- package/dist/{registry-generator-BQ1noftK.cjs → registry-generator-BkQ1AxZn.cjs} +1 -1
- package/dist/{registry-generator-D1Zslex6.js → registry-generator-VvBfOKAD.js} +1 -1
- package/dist/{rehydrate-CgxEur9m.js → rehydrate-BjLV643n.js} +2 -2
- package/dist/{rehydrate-BiA_HUJH.cjs → rehydrate-DDYFpQsV.cjs} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-aomba2_Z.cjs → run-registry-5Suldxz3.cjs} +83965 -77543
- package/dist/{run-registry-BUFmc_78.js → run-registry-CGRPldLH.js} +84057 -77017
- package/dist/{scheduler-BuivoTeD.js → scheduler-B-VZUvv_.js} +1 -1
- package/dist/{scheduler-COSuIH7R.cjs → scheduler-D00X03jQ.cjs} +1 -1
- package/dist/schedules/index.cjs +1 -1
- package/dist/schedules/index.js +1 -1
- package/dist/{schedules-Dmu9qOgc.js → schedules-DZfSx-7P.js} +94 -94
- package/dist/{signal-provider-CicwpNwY.cjs → signal-provider-BFAvh_AJ.cjs} +1 -1
- package/dist/{signal-provider-BOtSN-_0.js → signal-provider-BslnAjWG.js} +1 -1
- package/dist/signals/index.cjs +3 -3
- package/dist/signals/index.js +3 -3
- package/dist/{signals-6EBDPHQX.cjs → signals-B1JSj-Ew.cjs} +2 -2
- package/dist/{signals-BH__LS8Y.js → signals-De9VnwL2.js} +2 -2
- package/dist/skills/index.cjs +2 -2
- package/dist/skills/index.js +2 -2
- package/dist/{source-8qxr6KJv.cjs → source-DDwx-87N.cjs} +1 -1
- package/dist/{source-DRqDgbCv.js → source-Did_2XQc.js} +1 -1
- package/dist/{state-processor-BRk8t1OR.js → state-processor-B9kxpM53.js} +140 -140
- package/dist/{state-processor-Bfs9LkY8.cjs → state-processor-kRNZ38Nf.cjs} +139 -139
- package/dist/storage/constants.cjs +1 -1
- package/dist/storage/constants.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 +5 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
- package/dist/storage/domains/knowledge/pages.d.ts +24 -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/memory/base.d.ts +3 -1
- package/dist/storage/domains/memory/observational-memory-lifecycle.d.ts +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 +12 -11
- package/dist/storage/index.js +12 -12
- package/dist/storage/types.d.ts +13 -0
- package/dist/stream/base/output.d.ts +42 -15
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +19 -0
- package/dist/{stream-S_NC5v9e.js → stream-Dpwx0whf.js} +1 -1
- package/dist/{stream-DUrp3Fcy.cjs → stream-Dvy_0o14.cjs} +1 -1
- 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-BhCzpGfr.js → tool-loop-agent-PbWrEj1k.js} +3 -3
- package/dist/{tool-loop-agent-DU0BiemT.cjs → tool-loop-agent-UxOv3FoK.cjs} +3 -3
- package/dist/tools/index.cjs +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/types.d.ts +27 -1
- package/dist/{utils-CeEt4K7t.cjs → utils-BbMTlyBO.cjs} +1 -1
- package/dist/{utils-DYIai19q.js → utils-BnNi1BYM.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-BRikrNhF.js → validate-HSBcm96b.js} +1 -1
- package/dist/{validate-BckgxuJ0.cjs → validate-Skps-cM3.cjs} +1 -1
- package/dist/vector/index.cjs +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/{worker-BfhUD77l.cjs → worker-BE-0DyKL.cjs} +3 -3
- package/dist/{worker-DcBfwJqD.js → worker-BKrKHZzU.js} +3 -3
- package/dist/{worker-D9WwmcJa.cjs → worker-BNS5A3qP.cjs} +3 -3
- package/dist/{worker-Du5ybt5o.js → worker-DehaD4qD.js} +3 -3
- package/dist/{workflow-BWV5m9Mx.cjs → workflow-BjUTwaK9.cjs} +4 -4
- package/dist/{workflow-jNWVBYDJ.js → workflow-Bvw6yDjc.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 +11 -1
- package/dist/workflows/index.cjs +6 -6
- package/dist/workflows/index.js +6 -6
- package/dist/workflows/workflow.d.ts +6 -1
- package/dist/workspace/index.cjs +2 -2
- package/dist/workspace/index.js +2 -2
- package/dist/{workspace-D7JRhn1Z.js → workspace-C05xDH60.js} +564 -411
- package/dist/{workspace-BQ2wZj5D.cjs → workspace-D1OzzlLw.cjs} +564 -411
- package/dist/{workspace-skills-CGiXfKzA.js → workspace-skills-38OY32_b.js} +531 -531
- package/package.json +6 -6
- package/src/llm/model/provider-types.generated.d.ts +7720 -7720
- package/dist/agent/durable/evented-execution-engine.d.ts +0 -20
- package/dist/{filesystem-versioned-D-OCaYSl.cjs → filesystem-versioned-DZGyPbNC.cjs} +43 -43
- package/dist/{schedules-qIHUKsj4.cjs → schedules-BZS8McF7.cjs} +93 -93
- package/dist/{workspace-skills-CUSjYHdi.cjs → workspace-skills-BcquhPDn.cjs} +530 -530
|
@@ -1,5 +1,140 @@
|
|
|
1
1
|
import { r as createTool } from "./tool-Z3bykc1m.js";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
+
// src/agent/goal/objective.ts
|
|
4
|
+
/** RequestContext key under which the current objective is surfaced within a turn. */
|
|
5
|
+
const GOAL_REQUEST_CONTEXT_KEY = "mastra:goal";
|
|
6
|
+
/** State-signal lane id used for the current objective. */
|
|
7
|
+
const GOAL_STATE_ID = "goal";
|
|
8
|
+
/** `threadState` storage `type` namespace under which the objective is stored. */
|
|
9
|
+
const GOAL_STATE_TYPE = "goal";
|
|
10
|
+
/** Default max goal evaluations before the goal stops. */
|
|
11
|
+
const DEFAULT_GOAL_MAX_RUNS = 50;
|
|
12
|
+
/**
|
|
13
|
+
* Score the default goal scorer emits to signal an explicit "waiting for the
|
|
14
|
+
* user" checkpoint (tri-state decision `waiting`). It is deliberately neither 1
|
|
15
|
+
* (complete) nor 0 (continue): the generic completion reducer treats it as "not
|
|
16
|
+
* passed" (so the loop does not declare the goal done), while the goal step
|
|
17
|
+
* detects this exact value and stops the auto-loop (`isContinued = false`) so
|
|
18
|
+
* the user gets a chance to provide input. The record stays `active` — the next
|
|
19
|
+
* agent turn is still judged. Shared between `scorer.ts` and `goal-step.ts`.
|
|
20
|
+
*/
|
|
21
|
+
const GOAL_SCORE_WAITING = .5;
|
|
22
|
+
/**
|
|
23
|
+
* Stable id of the built-in goal scorer (see `createGoalScorer`). The goal step
|
|
24
|
+
* uses this to attribute the `GOAL_SCORE_WAITING` sentinel to the default
|
|
25
|
+
* scorer only — a custom `goal.scorer` that happens to return `0.5` must not be
|
|
26
|
+
* misread as an explicit "waiting" checkpoint.
|
|
27
|
+
*/
|
|
28
|
+
const GOAL_SCORER_ID = "goal-scorer";
|
|
29
|
+
/**
|
|
30
|
+
* Default goal-judge system prompt. Ported from MastraCode's `JUDGE_SYSTEM_PROMPT`
|
|
31
|
+
* so the native goal scorer behaves like the original `/goal` judge. A
|
|
32
|
+
* user-supplied `goal.prompt` (or per-objective `prompt`) overrides this.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_GOAL_JUDGE_PROMPT = `You are the goal judge. Your decision directly controls whether the assistant continues working toward the goal.
|
|
35
|
+
|
|
36
|
+
Given a goal and the assistant's latest response, reason about whether the goal's requirements have been satisfied. Compare what the goal asks for against what the assistant has actually produced. Focus on substance, not phrasing.
|
|
37
|
+
|
|
38
|
+
Use "done" when the goal is fully achieved.
|
|
39
|
+
Use "waiting" when the goal explicitly requires a user checkpoint, user feedback, human verification, human confirmation, or another external event outside the goal-judge loop before the assistant should continue, and the assistant has correctly stopped at that checkpoint.
|
|
40
|
+
Use "waiting" when the latest user message asks a question or requests clarification and the latest assistant message answers it; let the user acknowledge the answer, ask a follow-up, or otherwise return control before continuing goal work. Use common sense and do not wait if the user explicitly asked the assistant to continue autonomously after answering.
|
|
41
|
+
Use "continue" when the goal is not done and the assistant should keep working autonomously, including when it asked for input that the goal did not explicitly require.
|
|
42
|
+
If your previous decision was "waiting" for an explicit user checkpoint, keep choosing "waiting" when the user's latest response asks a question, requests clarification, or otherwise does not satisfy the checkpoint. Do not continue until the required user feedback/confirmation/verification has actually been provided.
|
|
43
|
+
If the goal says to wait for the goal judge, judge, evaluator, or you to respond, approve, verify, validate, tell the assistant to continue, or otherwise provide the next signal, treat your own decision as that judge response. Verification can be performed by you unless the goal explicitly says it needs human/user verification. Choose "continue" when the assistant should proceed to the next step. Do not choose "waiting" for judge-controlled checkpoints, because that would mean waiting for yourself.
|
|
44
|
+
|
|
45
|
+
Your "reason" field is sent back to the assistant as guidance when the goal is not yet done \u2014 be specific about what still needs to be accomplished. When choosing "continue", write the reason as an instruction for what the assistant should do next. When choosing "waiting", explain what specific user checkpoint is still outstanding.`;
|
|
46
|
+
/**
|
|
47
|
+
* Apply the precedence rule: ThreadState record value if present, else the
|
|
48
|
+
* agent's `goal` config default, else a built-in default. A record only persists
|
|
49
|
+
* the fields a caller explicitly provided, so unset fields fall back here.
|
|
50
|
+
*/
|
|
51
|
+
function resolveEffectiveGoalSettings(record, agentDefaults) {
|
|
52
|
+
return {
|
|
53
|
+
judgeModelId: record?.judgeModelId ?? agentDefaults?.judgeModelId,
|
|
54
|
+
maxRuns: record?.maxRuns ?? agentDefaults?.maxRuns ?? 50,
|
|
55
|
+
prompt: record?.prompt ?? agentDefaults?.prompt ?? "You are the goal judge. Your decision directly controls whether the assistant continues working toward the goal.\n\nGiven a goal and the assistant's latest response, reason about whether the goal's requirements have been satisfied. Compare what the goal asks for against what the assistant has actually produced. Focus on substance, not phrasing.\n\nUse \"done\" when the goal is fully achieved.\nUse \"waiting\" when the goal explicitly requires a user checkpoint, user feedback, human verification, human confirmation, or another external event outside the goal-judge loop before the assistant should continue, and the assistant has correctly stopped at that checkpoint.\nUse \"waiting\" when the latest user message asks a question or requests clarification and the latest assistant message answers it; let the user acknowledge the answer, ask a follow-up, or otherwise return control before continuing goal work. Use common sense and do not wait if the user explicitly asked the assistant to continue autonomously after answering.\nUse \"continue\" when the goal is not done and the assistant should keep working autonomously, including when it asked for input that the goal did not explicitly require.\nIf your previous decision was \"waiting\" for an explicit user checkpoint, keep choosing \"waiting\" when the user's latest response asks a question, requests clarification, or otherwise does not satisfy the checkpoint. Do not continue until the required user feedback/confirmation/verification has actually been provided.\nIf the goal says to wait for the goal judge, judge, evaluator, or you to respond, approve, verify, validate, tell the assistant to continue, or otherwise provide the next signal, treat your own decision as that judge response. Verification can be performed by you unless the goal explicitly says it needs human/user verification. Choose \"continue\" when the assistant should proceed to the next step. Do not choose \"waiting\" for judge-controlled checkpoints, because that would mean waiting for yourself.\n\nYour \"reason\" field is sent back to the assistant as guidance when the goal is not yet done \u2014 be specific about what still needs to be accomplished. When choosing \"continue\", write the reason as an instruction for what the assistant should do next. When choosing \"waiting\", explain what specific user checkpoint is still outstanding.",
|
|
56
|
+
maxSteps: agentDefaults?.maxSteps
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* User-facing reason persisted (and emitted on the `goal` chunk) when an
|
|
61
|
+
* objective runs out of evaluation budget before reaching the goal. It is
|
|
62
|
+
* shown in the TUI's paused box and `/goal status`, and it is what the
|
|
63
|
+
* changeset promises, so the non-durable and durable goal steps must not
|
|
64
|
+
* drift: both call this helper.
|
|
65
|
+
*/
|
|
66
|
+
function formatGoalBudgetPausedReason(maxRuns) {
|
|
67
|
+
return `Ran out of evaluation budget (${maxRuns} runs) before reaching the goal \u2014 raise maxRuns to resume.`;
|
|
68
|
+
}
|
|
69
|
+
function isThreadStateStore$2(value) {
|
|
70
|
+
return !!value && typeof value.getState === "function" && typeof value.setState === "function" && typeof value.deleteState === "function";
|
|
71
|
+
}
|
|
72
|
+
/** Resolve the thread-scoped state store from a Mastra instance, if available. */
|
|
73
|
+
async function resolveGoalStore(mastra) {
|
|
74
|
+
const store = await mastra?.getStorage?.()?.getStore("threadState");
|
|
75
|
+
return isThreadStateStore$2(store) ? store : void 0;
|
|
76
|
+
}
|
|
77
|
+
/** Read the current objective record for a thread from the store. */
|
|
78
|
+
async function readObjective(store, threadId) {
|
|
79
|
+
if (!store || !threadId) return void 0;
|
|
80
|
+
return store.getState({
|
|
81
|
+
threadId,
|
|
82
|
+
type: GOAL_STATE_TYPE
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Persist an objective record for a thread, surfacing it on the RequestContext
|
|
87
|
+
* so the state processor reflects the write in the same step.
|
|
88
|
+
*/
|
|
89
|
+
async function writeObjective(store, threadId, record, requestContext) {
|
|
90
|
+
if (!store || !threadId) return;
|
|
91
|
+
await store.setState({
|
|
92
|
+
threadId,
|
|
93
|
+
type: GOAL_STATE_TYPE,
|
|
94
|
+
value: record
|
|
95
|
+
});
|
|
96
|
+
requestContext?.set(GOAL_REQUEST_CONTEXT_KEY, record);
|
|
97
|
+
}
|
|
98
|
+
/** Drop the objective for a thread. */
|
|
99
|
+
async function clearObjective(store, threadId, requestContext) {
|
|
100
|
+
if (!store || !threadId) return;
|
|
101
|
+
await store.deleteState({
|
|
102
|
+
threadId,
|
|
103
|
+
type: GOAL_STATE_TYPE
|
|
104
|
+
});
|
|
105
|
+
requestContext?.set(GOAL_REQUEST_CONTEXT_KEY, void 0);
|
|
106
|
+
}
|
|
107
|
+
function isGoalObjectiveRecord(value) {
|
|
108
|
+
return !!value && typeof value.objective === "string" && typeof value.status === "string";
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Read the within-turn objective a `setObjective` surfaced on the shared
|
|
112
|
+
* RequestContext this step, if any. Returns `null` when the objective was
|
|
113
|
+
* explicitly cleared this step, `undefined` when nothing was carried (so the
|
|
114
|
+
* caller can fall back to the durable store).
|
|
115
|
+
*/
|
|
116
|
+
function getObjectiveFromRequestContext(requestContext) {
|
|
117
|
+
if (!requestContext?.has?.("mastra:goal")) return void 0;
|
|
118
|
+
const carried = requestContext.get(GOAL_REQUEST_CONTEXT_KEY);
|
|
119
|
+
if (carried === void 0) return null;
|
|
120
|
+
return isGoalObjectiveRecord(carried) ? carried : void 0;
|
|
121
|
+
}
|
|
122
|
+
// src/agent/goal/activity-cache.ts
|
|
123
|
+
const GOAL_OBJECTIVE_CACHE_KEY = "__mastra_goal_objective_cache";
|
|
124
|
+
function clearCachedGoalObjective(requestContext) {
|
|
125
|
+
requestContext?.delete(GOAL_OBJECTIVE_CACHE_KEY);
|
|
126
|
+
}
|
|
127
|
+
function cacheGoalObjective(requestContext, threadId, objective) {
|
|
128
|
+
requestContext?.set(GOAL_OBJECTIVE_CACHE_KEY, {
|
|
129
|
+
threadId,
|
|
130
|
+
objective: objective ?? null
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function takeCachedGoalObjective(requestContext, threadId) {
|
|
134
|
+
const cached = requestContext?.get(GOAL_OBJECTIVE_CACHE_KEY);
|
|
135
|
+
clearCachedGoalObjective(requestContext);
|
|
136
|
+
return cached?.threadId === threadId ? cached : void 0;
|
|
137
|
+
}
|
|
3
138
|
// src/tools/builtin/task-tools.ts
|
|
4
139
|
/** RequestContext key under which the current working task list is surfaced within a turn. */
|
|
5
140
|
const TASKS_REQUEST_CONTEXT_KEY = "mastra:tasks";
|
|
@@ -183,13 +318,13 @@ const taskMutationQueues = /* @__PURE__ */ new WeakMap();
|
|
|
183
318
|
function isMemoryBacked(agent) {
|
|
184
319
|
return Boolean(agent?.threadId && agent?.resourceId);
|
|
185
320
|
}
|
|
186
|
-
function isThreadStateStore$
|
|
321
|
+
function isThreadStateStore$1(value) {
|
|
187
322
|
return !!value && typeof value.getState === "function" && typeof value.setState === "function";
|
|
188
323
|
}
|
|
189
324
|
/** Resolve the thread-scoped state store from the agent's Mastra storage, if available. */
|
|
190
325
|
async function resolveTaskStore(context) {
|
|
191
326
|
const store = await context.mastra?.getStorage?.()?.getStore("threadState");
|
|
192
|
-
return isThreadStateStore$
|
|
327
|
+
return isThreadStateStore$1(store) ? store : void 0;
|
|
193
328
|
}
|
|
194
329
|
function emitTaskDisplayUpdate(requestContext, tasks) {
|
|
195
330
|
(requestContext?.get("controller"))?.emitEvent?.({
|
|
@@ -467,7 +602,7 @@ function getTasksFromRequestContext(requestContext) {
|
|
|
467
602
|
return isTaskItemArray(carried) ? carried : void 0;
|
|
468
603
|
}
|
|
469
604
|
// src/tools/builtin/task-state-processor.ts
|
|
470
|
-
function isThreadStateStore
|
|
605
|
+
function isThreadStateStore(value) {
|
|
471
606
|
return !!value && typeof value.getState === "function";
|
|
472
607
|
}
|
|
473
608
|
function renderTaskList(tasks) {
|
|
@@ -581,7 +716,7 @@ var TaskStateProcessor = class {
|
|
|
581
716
|
}
|
|
582
717
|
async resolveTaskStore() {
|
|
583
718
|
const store = await this.mastra?.getStorage?.()?.getStore("threadState");
|
|
584
|
-
return isThreadStateStore
|
|
719
|
+
return isThreadStateStore(store) ? store : void 0;
|
|
585
720
|
}
|
|
586
721
|
async computeStateSignal(args) {
|
|
587
722
|
const priorTasks = effectivePriorTasks(args);
|
|
@@ -627,141 +762,6 @@ var TaskStateProcessor = class {
|
|
|
627
762
|
};
|
|
628
763
|
}
|
|
629
764
|
};
|
|
630
|
-
// src/agent/goal/objective.ts
|
|
631
|
-
/** RequestContext key under which the current objective is surfaced within a turn. */
|
|
632
|
-
const GOAL_REQUEST_CONTEXT_KEY = "mastra:goal";
|
|
633
|
-
/** State-signal lane id used for the current objective. */
|
|
634
|
-
const GOAL_STATE_ID = "goal";
|
|
635
|
-
/** `threadState` storage `type` namespace under which the objective is stored. */
|
|
636
|
-
const GOAL_STATE_TYPE = "goal";
|
|
637
|
-
/** Default max goal evaluations before the goal stops. */
|
|
638
|
-
const DEFAULT_GOAL_MAX_RUNS = 50;
|
|
639
|
-
/**
|
|
640
|
-
* Score the default goal scorer emits to signal an explicit "waiting for the
|
|
641
|
-
* user" checkpoint (tri-state decision `waiting`). It is deliberately neither 1
|
|
642
|
-
* (complete) nor 0 (continue): the generic completion reducer treats it as "not
|
|
643
|
-
* passed" (so the loop does not declare the goal done), while the goal step
|
|
644
|
-
* detects this exact value and stops the auto-loop (`isContinued = false`) so
|
|
645
|
-
* the user gets a chance to provide input. The record stays `active` — the next
|
|
646
|
-
* agent turn is still judged. Shared between `scorer.ts` and `goal-step.ts`.
|
|
647
|
-
*/
|
|
648
|
-
const GOAL_SCORE_WAITING = .5;
|
|
649
|
-
/**
|
|
650
|
-
* Stable id of the built-in goal scorer (see `createGoalScorer`). The goal step
|
|
651
|
-
* uses this to attribute the `GOAL_SCORE_WAITING` sentinel to the default
|
|
652
|
-
* scorer only — a custom `goal.scorer` that happens to return `0.5` must not be
|
|
653
|
-
* misread as an explicit "waiting" checkpoint.
|
|
654
|
-
*/
|
|
655
|
-
const GOAL_SCORER_ID = "goal-scorer";
|
|
656
|
-
/**
|
|
657
|
-
* Default goal-judge system prompt. Ported from MastraCode's `JUDGE_SYSTEM_PROMPT`
|
|
658
|
-
* so the native goal scorer behaves like the original `/goal` judge. A
|
|
659
|
-
* user-supplied `goal.prompt` (or per-objective `prompt`) overrides this.
|
|
660
|
-
*/
|
|
661
|
-
const DEFAULT_GOAL_JUDGE_PROMPT = `You are the goal judge. Your decision directly controls whether the assistant continues working toward the goal.
|
|
662
|
-
|
|
663
|
-
Given a goal and the assistant's latest response, reason about whether the goal's requirements have been satisfied. Compare what the goal asks for against what the assistant has actually produced. Focus on substance, not phrasing.
|
|
664
|
-
|
|
665
|
-
Use "done" when the goal is fully achieved.
|
|
666
|
-
Use "waiting" when the goal explicitly requires a user checkpoint, user feedback, human verification, human confirmation, or another external event outside the goal-judge loop before the assistant should continue, and the assistant has correctly stopped at that checkpoint.
|
|
667
|
-
Use "waiting" when the latest user message asks a question or requests clarification and the latest assistant message answers it; let the user acknowledge the answer, ask a follow-up, or otherwise return control before continuing goal work. Use common sense and do not wait if the user explicitly asked the assistant to continue autonomously after answering.
|
|
668
|
-
Use "continue" when the goal is not done and the assistant should keep working autonomously, including when it asked for input that the goal did not explicitly require.
|
|
669
|
-
If your previous decision was "waiting" for an explicit user checkpoint, keep choosing "waiting" when the user's latest response asks a question, requests clarification, or otherwise does not satisfy the checkpoint. Do not continue until the required user feedback/confirmation/verification has actually been provided.
|
|
670
|
-
If the goal says to wait for the goal judge, judge, evaluator, or you to respond, approve, verify, validate, tell the assistant to continue, or otherwise provide the next signal, treat your own decision as that judge response. Verification can be performed by you unless the goal explicitly says it needs human/user verification. Choose "continue" when the assistant should proceed to the next step. Do not choose "waiting" for judge-controlled checkpoints, because that would mean waiting for yourself.
|
|
671
|
-
|
|
672
|
-
Your "reason" field is sent back to the assistant as guidance when the goal is not yet done \u2014 be specific about what still needs to be accomplished. When choosing "continue", write the reason as an instruction for what the assistant should do next. When choosing "waiting", explain what specific user checkpoint is still outstanding.`;
|
|
673
|
-
/**
|
|
674
|
-
* Apply the precedence rule: ThreadState record value if present, else the
|
|
675
|
-
* agent's `goal` config default, else a built-in default. A record only persists
|
|
676
|
-
* the fields a caller explicitly provided, so unset fields fall back here.
|
|
677
|
-
*/
|
|
678
|
-
function resolveEffectiveGoalSettings(record, agentDefaults) {
|
|
679
|
-
return {
|
|
680
|
-
judgeModelId: record?.judgeModelId ?? agentDefaults?.judgeModelId,
|
|
681
|
-
maxRuns: record?.maxRuns ?? agentDefaults?.maxRuns ?? 50,
|
|
682
|
-
prompt: record?.prompt ?? agentDefaults?.prompt ?? "You are the goal judge. Your decision directly controls whether the assistant continues working toward the goal.\n\nGiven a goal and the assistant's latest response, reason about whether the goal's requirements have been satisfied. Compare what the goal asks for against what the assistant has actually produced. Focus on substance, not phrasing.\n\nUse \"done\" when the goal is fully achieved.\nUse \"waiting\" when the goal explicitly requires a user checkpoint, user feedback, human verification, human confirmation, or another external event outside the goal-judge loop before the assistant should continue, and the assistant has correctly stopped at that checkpoint.\nUse \"waiting\" when the latest user message asks a question or requests clarification and the latest assistant message answers it; let the user acknowledge the answer, ask a follow-up, or otherwise return control before continuing goal work. Use common sense and do not wait if the user explicitly asked the assistant to continue autonomously after answering.\nUse \"continue\" when the goal is not done and the assistant should keep working autonomously, including when it asked for input that the goal did not explicitly require.\nIf your previous decision was \"waiting\" for an explicit user checkpoint, keep choosing \"waiting\" when the user's latest response asks a question, requests clarification, or otherwise does not satisfy the checkpoint. Do not continue until the required user feedback/confirmation/verification has actually been provided.\nIf the goal says to wait for the goal judge, judge, evaluator, or you to respond, approve, verify, validate, tell the assistant to continue, or otherwise provide the next signal, treat your own decision as that judge response. Verification can be performed by you unless the goal explicitly says it needs human/user verification. Choose \"continue\" when the assistant should proceed to the next step. Do not choose \"waiting\" for judge-controlled checkpoints, because that would mean waiting for yourself.\n\nYour \"reason\" field is sent back to the assistant as guidance when the goal is not yet done \u2014 be specific about what still needs to be accomplished. When choosing \"continue\", write the reason as an instruction for what the assistant should do next. When choosing \"waiting\", explain what specific user checkpoint is still outstanding.",
|
|
683
|
-
maxSteps: agentDefaults?.maxSteps
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
* User-facing reason persisted (and emitted on the `goal` chunk) when an
|
|
688
|
-
* objective runs out of evaluation budget before reaching the goal. It is
|
|
689
|
-
* shown in the TUI's paused box and `/goal status`, and it is what the
|
|
690
|
-
* changeset promises, so the non-durable and durable goal steps must not
|
|
691
|
-
* drift: both call this helper.
|
|
692
|
-
*/
|
|
693
|
-
function formatGoalBudgetPausedReason(maxRuns) {
|
|
694
|
-
return `Ran out of evaluation budget (${maxRuns} runs) before reaching the goal \u2014 raise maxRuns to resume.`;
|
|
695
|
-
}
|
|
696
|
-
function isThreadStateStore(value) {
|
|
697
|
-
return !!value && typeof value.getState === "function" && typeof value.setState === "function" && typeof value.deleteState === "function";
|
|
698
|
-
}
|
|
699
|
-
/** Resolve the thread-scoped state store from a Mastra instance, if available. */
|
|
700
|
-
async function resolveGoalStore(mastra) {
|
|
701
|
-
const store = await mastra?.getStorage?.()?.getStore("threadState");
|
|
702
|
-
return isThreadStateStore(store) ? store : void 0;
|
|
703
|
-
}
|
|
704
|
-
/** Read the current objective record for a thread from the store. */
|
|
705
|
-
async function readObjective(store, threadId) {
|
|
706
|
-
if (!store || !threadId) return void 0;
|
|
707
|
-
return store.getState({
|
|
708
|
-
threadId,
|
|
709
|
-
type: GOAL_STATE_TYPE
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Persist an objective record for a thread, surfacing it on the RequestContext
|
|
714
|
-
* so the state processor reflects the write in the same step.
|
|
715
|
-
*/
|
|
716
|
-
async function writeObjective(store, threadId, record, requestContext) {
|
|
717
|
-
if (!store || !threadId) return;
|
|
718
|
-
await store.setState({
|
|
719
|
-
threadId,
|
|
720
|
-
type: GOAL_STATE_TYPE,
|
|
721
|
-
value: record
|
|
722
|
-
});
|
|
723
|
-
requestContext?.set(GOAL_REQUEST_CONTEXT_KEY, record);
|
|
724
|
-
}
|
|
725
|
-
/** Drop the objective for a thread. */
|
|
726
|
-
async function clearObjective(store, threadId, requestContext) {
|
|
727
|
-
if (!store || !threadId) return;
|
|
728
|
-
await store.deleteState({
|
|
729
|
-
threadId,
|
|
730
|
-
type: GOAL_STATE_TYPE
|
|
731
|
-
});
|
|
732
|
-
requestContext?.set(GOAL_REQUEST_CONTEXT_KEY, void 0);
|
|
733
|
-
}
|
|
734
|
-
function isGoalObjectiveRecord(value) {
|
|
735
|
-
return !!value && typeof value.objective === "string" && typeof value.status === "string";
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Read the within-turn objective a `setObjective` surfaced on the shared
|
|
739
|
-
* RequestContext this step, if any. Returns `null` when the objective was
|
|
740
|
-
* explicitly cleared this step, `undefined` when nothing was carried (so the
|
|
741
|
-
* caller can fall back to the durable store).
|
|
742
|
-
*/
|
|
743
|
-
function getObjectiveFromRequestContext(requestContext) {
|
|
744
|
-
if (!requestContext?.has?.("mastra:goal")) return void 0;
|
|
745
|
-
const carried = requestContext.get(GOAL_REQUEST_CONTEXT_KEY);
|
|
746
|
-
if (carried === void 0) return null;
|
|
747
|
-
return isGoalObjectiveRecord(carried) ? carried : void 0;
|
|
748
|
-
}
|
|
749
|
-
// src/agent/goal/activity-cache.ts
|
|
750
|
-
const GOAL_OBJECTIVE_CACHE_KEY = "__mastra_goal_objective_cache";
|
|
751
|
-
function clearCachedGoalObjective(requestContext) {
|
|
752
|
-
requestContext?.delete(GOAL_OBJECTIVE_CACHE_KEY);
|
|
753
|
-
}
|
|
754
|
-
function cacheGoalObjective(requestContext, threadId, objective) {
|
|
755
|
-
requestContext?.set(GOAL_OBJECTIVE_CACHE_KEY, {
|
|
756
|
-
threadId,
|
|
757
|
-
objective: objective ?? null
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
function takeCachedGoalObjective(requestContext, threadId) {
|
|
761
|
-
const cached = requestContext?.get(GOAL_OBJECTIVE_CACHE_KEY);
|
|
762
|
-
clearCachedGoalObjective(requestContext);
|
|
763
|
-
return cached?.threadId === threadId ? cached : void 0;
|
|
764
|
-
}
|
|
765
765
|
// src/agent/goal/state-processor.ts
|
|
766
766
|
function renderObjective(record) {
|
|
767
767
|
return `\n ${record.objective}\n`;
|
|
@@ -843,4 +843,4 @@ var GoalStateProcessor = class {
|
|
|
843
843
|
};
|
|
844
844
|
}
|
|
845
845
|
};
|
|
846
|
-
export {
|
|
846
|
+
export { writeObjective as A, GOAL_STATE_TYPE as C, readObjective as D, getObjectiveFromRequestContext as E, resolveEffectiveGoalSettings as O, GOAL_STATE_ID as S, formatGoalBudgetPausedReason as T, clearCachedGoalObjective as _, TASK_STATE_TYPE as a, GOAL_SCORER_ID as b, formatTaskListResult as c, summarizeTaskCheck as d, taskCheckTool as f, cacheGoalObjective as g, taskWriteTool as h, TASKS_STATE_ID as i, resolveGoalStore as k, getTasksFromRequestContext as l, taskUpdateTool as m, TaskStateProcessor as n, assignTaskIds as o, taskCompleteTool as p, TASKS_REQUEST_CONTEXT_KEY as r, demoteExtraInProgress as s, GoalStateProcessor as t, hasMultipleInProgress as u, DEFAULT_GOAL_JUDGE_PROMPT as v, clearObjective as w, GOAL_SCORE_WAITING as x, DEFAULT_GOAL_MAX_RUNS as y };
|
|
@@ -1,5 +1,140 @@
|
|
|
1
1
|
const require_tool = require("./tool-CYlT2UA-.cjs");
|
|
2
2
|
let zod_v4 = require("zod/v4");
|
|
3
|
+
// src/agent/goal/objective.ts
|
|
4
|
+
/** RequestContext key under which the current objective is surfaced within a turn. */
|
|
5
|
+
const GOAL_REQUEST_CONTEXT_KEY = "mastra:goal";
|
|
6
|
+
/** State-signal lane id used for the current objective. */
|
|
7
|
+
const GOAL_STATE_ID = "goal";
|
|
8
|
+
/** `threadState` storage `type` namespace under which the objective is stored. */
|
|
9
|
+
const GOAL_STATE_TYPE = "goal";
|
|
10
|
+
/** Default max goal evaluations before the goal stops. */
|
|
11
|
+
const DEFAULT_GOAL_MAX_RUNS = 50;
|
|
12
|
+
/**
|
|
13
|
+
* Score the default goal scorer emits to signal an explicit "waiting for the
|
|
14
|
+
* user" checkpoint (tri-state decision `waiting`). It is deliberately neither 1
|
|
15
|
+
* (complete) nor 0 (continue): the generic completion reducer treats it as "not
|
|
16
|
+
* passed" (so the loop does not declare the goal done), while the goal step
|
|
17
|
+
* detects this exact value and stops the auto-loop (`isContinued = false`) so
|
|
18
|
+
* the user gets a chance to provide input. The record stays `active` — the next
|
|
19
|
+
* agent turn is still judged. Shared between `scorer.ts` and `goal-step.ts`.
|
|
20
|
+
*/
|
|
21
|
+
const GOAL_SCORE_WAITING = .5;
|
|
22
|
+
/**
|
|
23
|
+
* Stable id of the built-in goal scorer (see `createGoalScorer`). The goal step
|
|
24
|
+
* uses this to attribute the `GOAL_SCORE_WAITING` sentinel to the default
|
|
25
|
+
* scorer only — a custom `goal.scorer` that happens to return `0.5` must not be
|
|
26
|
+
* misread as an explicit "waiting" checkpoint.
|
|
27
|
+
*/
|
|
28
|
+
const GOAL_SCORER_ID = "goal-scorer";
|
|
29
|
+
/**
|
|
30
|
+
* Default goal-judge system prompt. Ported from MastraCode's `JUDGE_SYSTEM_PROMPT`
|
|
31
|
+
* so the native goal scorer behaves like the original `/goal` judge. A
|
|
32
|
+
* user-supplied `goal.prompt` (or per-objective `prompt`) overrides this.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_GOAL_JUDGE_PROMPT = `You are the goal judge. Your decision directly controls whether the assistant continues working toward the goal.
|
|
35
|
+
|
|
36
|
+
Given a goal and the assistant's latest response, reason about whether the goal's requirements have been satisfied. Compare what the goal asks for against what the assistant has actually produced. Focus on substance, not phrasing.
|
|
37
|
+
|
|
38
|
+
Use "done" when the goal is fully achieved.
|
|
39
|
+
Use "waiting" when the goal explicitly requires a user checkpoint, user feedback, human verification, human confirmation, or another external event outside the goal-judge loop before the assistant should continue, and the assistant has correctly stopped at that checkpoint.
|
|
40
|
+
Use "waiting" when the latest user message asks a question or requests clarification and the latest assistant message answers it; let the user acknowledge the answer, ask a follow-up, or otherwise return control before continuing goal work. Use common sense and do not wait if the user explicitly asked the assistant to continue autonomously after answering.
|
|
41
|
+
Use "continue" when the goal is not done and the assistant should keep working autonomously, including when it asked for input that the goal did not explicitly require.
|
|
42
|
+
If your previous decision was "waiting" for an explicit user checkpoint, keep choosing "waiting" when the user's latest response asks a question, requests clarification, or otherwise does not satisfy the checkpoint. Do not continue until the required user feedback/confirmation/verification has actually been provided.
|
|
43
|
+
If the goal says to wait for the goal judge, judge, evaluator, or you to respond, approve, verify, validate, tell the assistant to continue, or otherwise provide the next signal, treat your own decision as that judge response. Verification can be performed by you unless the goal explicitly says it needs human/user verification. Choose "continue" when the assistant should proceed to the next step. Do not choose "waiting" for judge-controlled checkpoints, because that would mean waiting for yourself.
|
|
44
|
+
|
|
45
|
+
Your "reason" field is sent back to the assistant as guidance when the goal is not yet done \u2014 be specific about what still needs to be accomplished. When choosing "continue", write the reason as an instruction for what the assistant should do next. When choosing "waiting", explain what specific user checkpoint is still outstanding.`;
|
|
46
|
+
/**
|
|
47
|
+
* Apply the precedence rule: ThreadState record value if present, else the
|
|
48
|
+
* agent's `goal` config default, else a built-in default. A record only persists
|
|
49
|
+
* the fields a caller explicitly provided, so unset fields fall back here.
|
|
50
|
+
*/
|
|
51
|
+
function resolveEffectiveGoalSettings(record, agentDefaults) {
|
|
52
|
+
return {
|
|
53
|
+
judgeModelId: record?.judgeModelId ?? agentDefaults?.judgeModelId,
|
|
54
|
+
maxRuns: record?.maxRuns ?? agentDefaults?.maxRuns ?? 50,
|
|
55
|
+
prompt: record?.prompt ?? agentDefaults?.prompt ?? "You are the goal judge. Your decision directly controls whether the assistant continues working toward the goal.\n\nGiven a goal and the assistant's latest response, reason about whether the goal's requirements have been satisfied. Compare what the goal asks for against what the assistant has actually produced. Focus on substance, not phrasing.\n\nUse \"done\" when the goal is fully achieved.\nUse \"waiting\" when the goal explicitly requires a user checkpoint, user feedback, human verification, human confirmation, or another external event outside the goal-judge loop before the assistant should continue, and the assistant has correctly stopped at that checkpoint.\nUse \"waiting\" when the latest user message asks a question or requests clarification and the latest assistant message answers it; let the user acknowledge the answer, ask a follow-up, or otherwise return control before continuing goal work. Use common sense and do not wait if the user explicitly asked the assistant to continue autonomously after answering.\nUse \"continue\" when the goal is not done and the assistant should keep working autonomously, including when it asked for input that the goal did not explicitly require.\nIf your previous decision was \"waiting\" for an explicit user checkpoint, keep choosing \"waiting\" when the user's latest response asks a question, requests clarification, or otherwise does not satisfy the checkpoint. Do not continue until the required user feedback/confirmation/verification has actually been provided.\nIf the goal says to wait for the goal judge, judge, evaluator, or you to respond, approve, verify, validate, tell the assistant to continue, or otherwise provide the next signal, treat your own decision as that judge response. Verification can be performed by you unless the goal explicitly says it needs human/user verification. Choose \"continue\" when the assistant should proceed to the next step. Do not choose \"waiting\" for judge-controlled checkpoints, because that would mean waiting for yourself.\n\nYour \"reason\" field is sent back to the assistant as guidance when the goal is not yet done \u2014 be specific about what still needs to be accomplished. When choosing \"continue\", write the reason as an instruction for what the assistant should do next. When choosing \"waiting\", explain what specific user checkpoint is still outstanding.",
|
|
56
|
+
maxSteps: agentDefaults?.maxSteps
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* User-facing reason persisted (and emitted on the `goal` chunk) when an
|
|
61
|
+
* objective runs out of evaluation budget before reaching the goal. It is
|
|
62
|
+
* shown in the TUI's paused box and `/goal status`, and it is what the
|
|
63
|
+
* changeset promises, so the non-durable and durable goal steps must not
|
|
64
|
+
* drift: both call this helper.
|
|
65
|
+
*/
|
|
66
|
+
function formatGoalBudgetPausedReason(maxRuns) {
|
|
67
|
+
return `Ran out of evaluation budget (${maxRuns} runs) before reaching the goal \u2014 raise maxRuns to resume.`;
|
|
68
|
+
}
|
|
69
|
+
function isThreadStateStore$2(value) {
|
|
70
|
+
return !!value && typeof value.getState === "function" && typeof value.setState === "function" && typeof value.deleteState === "function";
|
|
71
|
+
}
|
|
72
|
+
/** Resolve the thread-scoped state store from a Mastra instance, if available. */
|
|
73
|
+
async function resolveGoalStore(mastra) {
|
|
74
|
+
const store = await mastra?.getStorage?.()?.getStore("threadState");
|
|
75
|
+
return isThreadStateStore$2(store) ? store : void 0;
|
|
76
|
+
}
|
|
77
|
+
/** Read the current objective record for a thread from the store. */
|
|
78
|
+
async function readObjective(store, threadId) {
|
|
79
|
+
if (!store || !threadId) return void 0;
|
|
80
|
+
return store.getState({
|
|
81
|
+
threadId,
|
|
82
|
+
type: GOAL_STATE_TYPE
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Persist an objective record for a thread, surfacing it on the RequestContext
|
|
87
|
+
* so the state processor reflects the write in the same step.
|
|
88
|
+
*/
|
|
89
|
+
async function writeObjective(store, threadId, record, requestContext) {
|
|
90
|
+
if (!store || !threadId) return;
|
|
91
|
+
await store.setState({
|
|
92
|
+
threadId,
|
|
93
|
+
type: GOAL_STATE_TYPE,
|
|
94
|
+
value: record
|
|
95
|
+
});
|
|
96
|
+
requestContext?.set(GOAL_REQUEST_CONTEXT_KEY, record);
|
|
97
|
+
}
|
|
98
|
+
/** Drop the objective for a thread. */
|
|
99
|
+
async function clearObjective(store, threadId, requestContext) {
|
|
100
|
+
if (!store || !threadId) return;
|
|
101
|
+
await store.deleteState({
|
|
102
|
+
threadId,
|
|
103
|
+
type: GOAL_STATE_TYPE
|
|
104
|
+
});
|
|
105
|
+
requestContext?.set(GOAL_REQUEST_CONTEXT_KEY, void 0);
|
|
106
|
+
}
|
|
107
|
+
function isGoalObjectiveRecord(value) {
|
|
108
|
+
return !!value && typeof value.objective === "string" && typeof value.status === "string";
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Read the within-turn objective a `setObjective` surfaced on the shared
|
|
112
|
+
* RequestContext this step, if any. Returns `null` when the objective was
|
|
113
|
+
* explicitly cleared this step, `undefined` when nothing was carried (so the
|
|
114
|
+
* caller can fall back to the durable store).
|
|
115
|
+
*/
|
|
116
|
+
function getObjectiveFromRequestContext(requestContext) {
|
|
117
|
+
if (!requestContext?.has?.("mastra:goal")) return void 0;
|
|
118
|
+
const carried = requestContext.get(GOAL_REQUEST_CONTEXT_KEY);
|
|
119
|
+
if (carried === void 0) return null;
|
|
120
|
+
return isGoalObjectiveRecord(carried) ? carried : void 0;
|
|
121
|
+
}
|
|
122
|
+
// src/agent/goal/activity-cache.ts
|
|
123
|
+
const GOAL_OBJECTIVE_CACHE_KEY = "__mastra_goal_objective_cache";
|
|
124
|
+
function clearCachedGoalObjective(requestContext) {
|
|
125
|
+
requestContext?.delete(GOAL_OBJECTIVE_CACHE_KEY);
|
|
126
|
+
}
|
|
127
|
+
function cacheGoalObjective(requestContext, threadId, objective) {
|
|
128
|
+
requestContext?.set(GOAL_OBJECTIVE_CACHE_KEY, {
|
|
129
|
+
threadId,
|
|
130
|
+
objective: objective ?? null
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function takeCachedGoalObjective(requestContext, threadId) {
|
|
134
|
+
const cached = requestContext?.get(GOAL_OBJECTIVE_CACHE_KEY);
|
|
135
|
+
clearCachedGoalObjective(requestContext);
|
|
136
|
+
return cached?.threadId === threadId ? cached : void 0;
|
|
137
|
+
}
|
|
3
138
|
// src/tools/builtin/task-tools.ts
|
|
4
139
|
/** RequestContext key under which the current working task list is surfaced within a turn. */
|
|
5
140
|
const TASKS_REQUEST_CONTEXT_KEY = "mastra:tasks";
|
|
@@ -183,13 +318,13 @@ const taskMutationQueues = /* @__PURE__ */ new WeakMap();
|
|
|
183
318
|
function isMemoryBacked(agent) {
|
|
184
319
|
return Boolean(agent?.threadId && agent?.resourceId);
|
|
185
320
|
}
|
|
186
|
-
function isThreadStateStore$
|
|
321
|
+
function isThreadStateStore$1(value) {
|
|
187
322
|
return !!value && typeof value.getState === "function" && typeof value.setState === "function";
|
|
188
323
|
}
|
|
189
324
|
/** Resolve the thread-scoped state store from the agent's Mastra storage, if available. */
|
|
190
325
|
async function resolveTaskStore(context) {
|
|
191
326
|
const store = await context.mastra?.getStorage?.()?.getStore("threadState");
|
|
192
|
-
return isThreadStateStore$
|
|
327
|
+
return isThreadStateStore$1(store) ? store : void 0;
|
|
193
328
|
}
|
|
194
329
|
function emitTaskDisplayUpdate(requestContext, tasks) {
|
|
195
330
|
(requestContext?.get("controller"))?.emitEvent?.({
|
|
@@ -467,7 +602,7 @@ function getTasksFromRequestContext(requestContext) {
|
|
|
467
602
|
return isTaskItemArray(carried) ? carried : void 0;
|
|
468
603
|
}
|
|
469
604
|
// src/tools/builtin/task-state-processor.ts
|
|
470
|
-
function isThreadStateStore
|
|
605
|
+
function isThreadStateStore(value) {
|
|
471
606
|
return !!value && typeof value.getState === "function";
|
|
472
607
|
}
|
|
473
608
|
function renderTaskList(tasks) {
|
|
@@ -581,7 +716,7 @@ var TaskStateProcessor = class {
|
|
|
581
716
|
}
|
|
582
717
|
async resolveTaskStore() {
|
|
583
718
|
const store = await this.mastra?.getStorage?.()?.getStore("threadState");
|
|
584
|
-
return isThreadStateStore
|
|
719
|
+
return isThreadStateStore(store) ? store : void 0;
|
|
585
720
|
}
|
|
586
721
|
async computeStateSignal(args) {
|
|
587
722
|
const priorTasks = effectivePriorTasks(args);
|
|
@@ -627,141 +762,6 @@ var TaskStateProcessor = class {
|
|
|
627
762
|
};
|
|
628
763
|
}
|
|
629
764
|
};
|
|
630
|
-
// src/agent/goal/objective.ts
|
|
631
|
-
/** RequestContext key under which the current objective is surfaced within a turn. */
|
|
632
|
-
const GOAL_REQUEST_CONTEXT_KEY = "mastra:goal";
|
|
633
|
-
/** State-signal lane id used for the current objective. */
|
|
634
|
-
const GOAL_STATE_ID = "goal";
|
|
635
|
-
/** `threadState` storage `type` namespace under which the objective is stored. */
|
|
636
|
-
const GOAL_STATE_TYPE = "goal";
|
|
637
|
-
/** Default max goal evaluations before the goal stops. */
|
|
638
|
-
const DEFAULT_GOAL_MAX_RUNS = 50;
|
|
639
|
-
/**
|
|
640
|
-
* Score the default goal scorer emits to signal an explicit "waiting for the
|
|
641
|
-
* user" checkpoint (tri-state decision `waiting`). It is deliberately neither 1
|
|
642
|
-
* (complete) nor 0 (continue): the generic completion reducer treats it as "not
|
|
643
|
-
* passed" (so the loop does not declare the goal done), while the goal step
|
|
644
|
-
* detects this exact value and stops the auto-loop (`isContinued = false`) so
|
|
645
|
-
* the user gets a chance to provide input. The record stays `active` — the next
|
|
646
|
-
* agent turn is still judged. Shared between `scorer.ts` and `goal-step.ts`.
|
|
647
|
-
*/
|
|
648
|
-
const GOAL_SCORE_WAITING = .5;
|
|
649
|
-
/**
|
|
650
|
-
* Stable id of the built-in goal scorer (see `createGoalScorer`). The goal step
|
|
651
|
-
* uses this to attribute the `GOAL_SCORE_WAITING` sentinel to the default
|
|
652
|
-
* scorer only — a custom `goal.scorer` that happens to return `0.5` must not be
|
|
653
|
-
* misread as an explicit "waiting" checkpoint.
|
|
654
|
-
*/
|
|
655
|
-
const GOAL_SCORER_ID = "goal-scorer";
|
|
656
|
-
/**
|
|
657
|
-
* Default goal-judge system prompt. Ported from MastraCode's `JUDGE_SYSTEM_PROMPT`
|
|
658
|
-
* so the native goal scorer behaves like the original `/goal` judge. A
|
|
659
|
-
* user-supplied `goal.prompt` (or per-objective `prompt`) overrides this.
|
|
660
|
-
*/
|
|
661
|
-
const DEFAULT_GOAL_JUDGE_PROMPT = `You are the goal judge. Your decision directly controls whether the assistant continues working toward the goal.
|
|
662
|
-
|
|
663
|
-
Given a goal and the assistant's latest response, reason about whether the goal's requirements have been satisfied. Compare what the goal asks for against what the assistant has actually produced. Focus on substance, not phrasing.
|
|
664
|
-
|
|
665
|
-
Use "done" when the goal is fully achieved.
|
|
666
|
-
Use "waiting" when the goal explicitly requires a user checkpoint, user feedback, human verification, human confirmation, or another external event outside the goal-judge loop before the assistant should continue, and the assistant has correctly stopped at that checkpoint.
|
|
667
|
-
Use "waiting" when the latest user message asks a question or requests clarification and the latest assistant message answers it; let the user acknowledge the answer, ask a follow-up, or otherwise return control before continuing goal work. Use common sense and do not wait if the user explicitly asked the assistant to continue autonomously after answering.
|
|
668
|
-
Use "continue" when the goal is not done and the assistant should keep working autonomously, including when it asked for input that the goal did not explicitly require.
|
|
669
|
-
If your previous decision was "waiting" for an explicit user checkpoint, keep choosing "waiting" when the user's latest response asks a question, requests clarification, or otherwise does not satisfy the checkpoint. Do not continue until the required user feedback/confirmation/verification has actually been provided.
|
|
670
|
-
If the goal says to wait for the goal judge, judge, evaluator, or you to respond, approve, verify, validate, tell the assistant to continue, or otherwise provide the next signal, treat your own decision as that judge response. Verification can be performed by you unless the goal explicitly says it needs human/user verification. Choose "continue" when the assistant should proceed to the next step. Do not choose "waiting" for judge-controlled checkpoints, because that would mean waiting for yourself.
|
|
671
|
-
|
|
672
|
-
Your "reason" field is sent back to the assistant as guidance when the goal is not yet done \u2014 be specific about what still needs to be accomplished. When choosing "continue", write the reason as an instruction for what the assistant should do next. When choosing "waiting", explain what specific user checkpoint is still outstanding.`;
|
|
673
|
-
/**
|
|
674
|
-
* Apply the precedence rule: ThreadState record value if present, else the
|
|
675
|
-
* agent's `goal` config default, else a built-in default. A record only persists
|
|
676
|
-
* the fields a caller explicitly provided, so unset fields fall back here.
|
|
677
|
-
*/
|
|
678
|
-
function resolveEffectiveGoalSettings(record, agentDefaults) {
|
|
679
|
-
return {
|
|
680
|
-
judgeModelId: record?.judgeModelId ?? agentDefaults?.judgeModelId,
|
|
681
|
-
maxRuns: record?.maxRuns ?? agentDefaults?.maxRuns ?? 50,
|
|
682
|
-
prompt: record?.prompt ?? agentDefaults?.prompt ?? "You are the goal judge. Your decision directly controls whether the assistant continues working toward the goal.\n\nGiven a goal and the assistant's latest response, reason about whether the goal's requirements have been satisfied. Compare what the goal asks for against what the assistant has actually produced. Focus on substance, not phrasing.\n\nUse \"done\" when the goal is fully achieved.\nUse \"waiting\" when the goal explicitly requires a user checkpoint, user feedback, human verification, human confirmation, or another external event outside the goal-judge loop before the assistant should continue, and the assistant has correctly stopped at that checkpoint.\nUse \"waiting\" when the latest user message asks a question or requests clarification and the latest assistant message answers it; let the user acknowledge the answer, ask a follow-up, or otherwise return control before continuing goal work. Use common sense and do not wait if the user explicitly asked the assistant to continue autonomously after answering.\nUse \"continue\" when the goal is not done and the assistant should keep working autonomously, including when it asked for input that the goal did not explicitly require.\nIf your previous decision was \"waiting\" for an explicit user checkpoint, keep choosing \"waiting\" when the user's latest response asks a question, requests clarification, or otherwise does not satisfy the checkpoint. Do not continue until the required user feedback/confirmation/verification has actually been provided.\nIf the goal says to wait for the goal judge, judge, evaluator, or you to respond, approve, verify, validate, tell the assistant to continue, or otherwise provide the next signal, treat your own decision as that judge response. Verification can be performed by you unless the goal explicitly says it needs human/user verification. Choose \"continue\" when the assistant should proceed to the next step. Do not choose \"waiting\" for judge-controlled checkpoints, because that would mean waiting for yourself.\n\nYour \"reason\" field is sent back to the assistant as guidance when the goal is not yet done \u2014 be specific about what still needs to be accomplished. When choosing \"continue\", write the reason as an instruction for what the assistant should do next. When choosing \"waiting\", explain what specific user checkpoint is still outstanding.",
|
|
683
|
-
maxSteps: agentDefaults?.maxSteps
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
* User-facing reason persisted (and emitted on the `goal` chunk) when an
|
|
688
|
-
* objective runs out of evaluation budget before reaching the goal. It is
|
|
689
|
-
* shown in the TUI's paused box and `/goal status`, and it is what the
|
|
690
|
-
* changeset promises, so the non-durable and durable goal steps must not
|
|
691
|
-
* drift: both call this helper.
|
|
692
|
-
*/
|
|
693
|
-
function formatGoalBudgetPausedReason(maxRuns) {
|
|
694
|
-
return `Ran out of evaluation budget (${maxRuns} runs) before reaching the goal \u2014 raise maxRuns to resume.`;
|
|
695
|
-
}
|
|
696
|
-
function isThreadStateStore(value) {
|
|
697
|
-
return !!value && typeof value.getState === "function" && typeof value.setState === "function" && typeof value.deleteState === "function";
|
|
698
|
-
}
|
|
699
|
-
/** Resolve the thread-scoped state store from a Mastra instance, if available. */
|
|
700
|
-
async function resolveGoalStore(mastra) {
|
|
701
|
-
const store = await mastra?.getStorage?.()?.getStore("threadState");
|
|
702
|
-
return isThreadStateStore(store) ? store : void 0;
|
|
703
|
-
}
|
|
704
|
-
/** Read the current objective record for a thread from the store. */
|
|
705
|
-
async function readObjective(store, threadId) {
|
|
706
|
-
if (!store || !threadId) return void 0;
|
|
707
|
-
return store.getState({
|
|
708
|
-
threadId,
|
|
709
|
-
type: GOAL_STATE_TYPE
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Persist an objective record for a thread, surfacing it on the RequestContext
|
|
714
|
-
* so the state processor reflects the write in the same step.
|
|
715
|
-
*/
|
|
716
|
-
async function writeObjective(store, threadId, record, requestContext) {
|
|
717
|
-
if (!store || !threadId) return;
|
|
718
|
-
await store.setState({
|
|
719
|
-
threadId,
|
|
720
|
-
type: GOAL_STATE_TYPE,
|
|
721
|
-
value: record
|
|
722
|
-
});
|
|
723
|
-
requestContext?.set(GOAL_REQUEST_CONTEXT_KEY, record);
|
|
724
|
-
}
|
|
725
|
-
/** Drop the objective for a thread. */
|
|
726
|
-
async function clearObjective(store, threadId, requestContext) {
|
|
727
|
-
if (!store || !threadId) return;
|
|
728
|
-
await store.deleteState({
|
|
729
|
-
threadId,
|
|
730
|
-
type: GOAL_STATE_TYPE
|
|
731
|
-
});
|
|
732
|
-
requestContext?.set(GOAL_REQUEST_CONTEXT_KEY, void 0);
|
|
733
|
-
}
|
|
734
|
-
function isGoalObjectiveRecord(value) {
|
|
735
|
-
return !!value && typeof value.objective === "string" && typeof value.status === "string";
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Read the within-turn objective a `setObjective` surfaced on the shared
|
|
739
|
-
* RequestContext this step, if any. Returns `null` when the objective was
|
|
740
|
-
* explicitly cleared this step, `undefined` when nothing was carried (so the
|
|
741
|
-
* caller can fall back to the durable store).
|
|
742
|
-
*/
|
|
743
|
-
function getObjectiveFromRequestContext(requestContext) {
|
|
744
|
-
if (!requestContext?.has?.("mastra:goal")) return void 0;
|
|
745
|
-
const carried = requestContext.get(GOAL_REQUEST_CONTEXT_KEY);
|
|
746
|
-
if (carried === void 0) return null;
|
|
747
|
-
return isGoalObjectiveRecord(carried) ? carried : void 0;
|
|
748
|
-
}
|
|
749
|
-
// src/agent/goal/activity-cache.ts
|
|
750
|
-
const GOAL_OBJECTIVE_CACHE_KEY = "__mastra_goal_objective_cache";
|
|
751
|
-
function clearCachedGoalObjective(requestContext) {
|
|
752
|
-
requestContext?.delete(GOAL_OBJECTIVE_CACHE_KEY);
|
|
753
|
-
}
|
|
754
|
-
function cacheGoalObjective(requestContext, threadId, objective) {
|
|
755
|
-
requestContext?.set(GOAL_OBJECTIVE_CACHE_KEY, {
|
|
756
|
-
threadId,
|
|
757
|
-
objective: objective ?? null
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
function takeCachedGoalObjective(requestContext, threadId) {
|
|
761
|
-
const cached = requestContext?.get(GOAL_OBJECTIVE_CACHE_KEY);
|
|
762
|
-
clearCachedGoalObjective(requestContext);
|
|
763
|
-
return cached?.threadId === threadId ? cached : void 0;
|
|
764
|
-
}
|
|
765
765
|
// src/agent/goal/state-processor.ts
|
|
766
766
|
function renderObjective(record) {
|
|
767
767
|
return `\n ${record.objective}\n`;
|