@mastra/core 1.87.0-alpha.6 → 1.87.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/agent/agent.d.ts +3 -1
- package/dist/agent/durable/index.cjs +1 -1
- package/dist/agent/durable/index.js +1 -1
- package/dist/agent/index.cjs +3 -2
- package/dist/agent/index.d.ts +2 -0
- package/dist/agent/index.js +3 -3
- package/dist/agent/merge-persona.d.ts +15 -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 +2 -2
- package/dist/agent-controller/index.js +2 -2
- package/dist/{agent-controller-BkG0M35j.js → agent-controller-C4zDemm6.js} +7 -7
- package/dist/{agent-controller-BL-0CKSF.cjs → agent-controller-CrEpnHiS.cjs} +7 -7
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-DL-ATSvp.cjs → background-tasks-Co3gtkk9.cjs} +1 -1
- package/dist/{background-tasks-CQ1M8SHw.js → background-tasks-DKY9-67c.js} +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-CVEDotdf.cjs → builder-DSyz2DUR.cjs} +2 -2
- package/dist/{builder-DnbKjNuO.js → builder-ntKskSX0.js} +2 -2
- package/dist/capabilities/302ai.json +208 -208
- package/dist/capabilities/abliteratedllm.json +34 -34
- package/dist/capabilities/abliteration-ai.json +11 -11
- package/dist/capabilities/above.json +24 -24
- package/dist/capabilities/adaption.json +15 -15
- package/dist/capabilities/adzuki.json +29 -29
- package/dist/capabilities/agentrouter.json +9 -9
- package/dist/capabilities/agnes.json +3 -3
- package/dist/capabilities/ai-router.json +8 -8
- package/dist/capabilities/aiand.json +25 -25
- package/dist/capabilities/aigrow.json +13 -13
- package/dist/capabilities/aimlapi.json +150 -150
- package/dist/capabilities/aixy.json +22 -22
- package/dist/capabilities/aki-io.json +14 -14
- package/dist/capabilities/alibaba-cn.json +108 -102
- package/dist/capabilities/alibaba-coding-plan-cn.json +6 -6
- package/dist/capabilities/alibaba-coding-plan.json +6 -6
- package/dist/capabilities/alibaba-token-plan-cn.json +53 -53
- package/dist/capabilities/alibaba-token-plan.json +52 -52
- package/dist/capabilities/alibaba.json +71 -71
- package/dist/capabilities/ambient.json +17 -17
- package/dist/capabilities/amd.json +9 -9
- package/dist/capabilities/anthropic.json +49 -49
- package/dist/capabilities/anyapi.json +16 -16
- package/dist/capabilities/apiko.json +5 -5
- package/dist/capabilities/arcee.json +7 -7
- package/dist/capabilities/augure.json +4 -4
- package/dist/capabilities/auriko.json +20 -20
- package/dist/capabilities/bailing.json +4 -4
- package/dist/capabilities/baseten.json +36 -36
- package/dist/capabilities/bee.json +4 -4
- package/dist/capabilities/berget.json +4 -4
- package/dist/capabilities/bothub.json +16 -16
- package/dist/capabilities/boundless.json +33 -33
- package/dist/capabilities/bumo.json +36 -36
- package/dist/capabilities/byteplus.json +29 -29
- package/dist/capabilities/cheapaimodel.json +10 -10
- package/dist/capabilities/cheapest-token.json +30 -30
- package/dist/capabilities/chutes.json +8 -8
- package/dist/capabilities/cline-pass.json +41 -41
- package/dist/capabilities/cloudcode.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +18 -18
- package/dist/capabilities/commandcode.json +137 -137
- package/dist/capabilities/concentrate.json +270 -270
- package/dist/capabilities/cortecs.json +113 -113
- package/dist/capabilities/crossmodel.json +188 -188
- package/dist/capabilities/crusoe.json +10 -10
- package/dist/capabilities/daoxe.json +7 -7
- package/dist/capabilities/databricks.json +133 -133
- package/dist/capabilities/deepinfra.json +94 -94
- package/dist/capabilities/deepseek.json +4 -4
- package/dist/capabilities/digitalocean.json +114 -114
- package/dist/capabilities/dothoosh.json +30 -30
- package/dist/capabilities/doubleword.json +25 -25
- package/dist/capabilities/edenai.json +278 -278
- package/dist/capabilities/empiriolabs.json +168 -168
- package/dist/capabilities/engy.json +19 -19
- package/dist/capabilities/entrim.json +6 -6
- package/dist/capabilities/evroc.json +14 -14
- package/dist/capabilities/ezkielyna.json +5 -5
- package/dist/capabilities/fastrouter.json +80 -80
- package/dist/capabilities/fireworks-ai.json +83 -83
- package/dist/capabilities/freemodel.json +20 -20
- package/dist/capabilities/friendli.json +6 -6
- package/dist/capabilities/frogbot.json +93 -93
- package/dist/capabilities/gisoo.json +20 -20
- package/dist/capabilities/gmicloud.json +14 -14
- package/dist/capabilities/google.json +52 -52
- package/dist/capabilities/graphn.json +12 -12
- package/dist/capabilities/greenpt.json +35 -35
- package/dist/capabilities/groq.json +8 -8
- package/dist/capabilities/helicone.json +82 -82
- package/dist/capabilities/hostinger-router.json +8 -8
- package/dist/capabilities/hpc-ai.json +12 -12
- package/dist/capabilities/huawei-maas.json +15 -15
- package/dist/capabilities/hubris.json +30 -30
- package/dist/capabilities/huggingface.json +70 -174
- package/dist/capabilities/hyper.json +24 -24
- package/dist/capabilities/impossibl.json +147 -147
- 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 +14 -14
- package/dist/capabilities/inference-coop.json +2 -2
- package/dist/capabilities/inferenceapis.json +27 -27
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +14 -14
- package/dist/capabilities/inferx.json +2 -2
- package/dist/capabilities/infomaniak.json +2 -2
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +55 -55
- package/dist/capabilities/jad-ai.json +2 -2
- package/dist/capabilities/jalapeno.json +10 -10
- package/dist/capabilities/jiekou.json +70 -70
- package/dist/capabilities/joingonka.json +4 -4
- package/dist/capabilities/jzstoken.json +54 -54
- package/dist/capabilities/keln.json +24 -24
- package/dist/capabilities/kenari.json +124 -124
- package/dist/capabilities/kilo.json +634 -641
- package/dist/capabilities/kimi-code-plan-cn.json +9 -9
- package/dist/capabilities/kimi-code-plan-global.json +9 -9
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +20 -20
- package/dist/capabilities/korouter.json +30 -30
- package/dist/capabilities/kunavo.json +6 -6
- package/dist/capabilities/liquid.json +9 -9
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +935 -919
- package/dist/capabilities/llmgateway.json +340 -338
- package/dist/capabilities/llmtr.json +22 -22
- package/dist/capabilities/lowrouter.json +52 -52
- package/dist/capabilities/lyceum.json +10 -10
- package/dist/capabilities/melious.json +15 -15
- package/dist/capabilities/merge-gateway.json +279 -279
- package/dist/capabilities/meta.json +6 -6
- package/dist/capabilities/minimax-cn-coding-plan.json +2 -2
- package/dist/capabilities/minimax-coding-plan.json +2 -2
- package/dist/capabilities/mistral.json +20 -20
- package/dist/capabilities/mixlayer.json +4 -4
- package/dist/capabilities/modal.json +12 -12
- package/dist/capabilities/model-oracle-ai.json +15 -15
- package/dist/capabilities/modelis.json +15 -15
- package/dist/capabilities/modular.json +6 -6
- package/dist/capabilities/moneo.json +13 -13
- 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 +6 -6
- package/dist/capabilities/munito.json +10 -10
- package/dist/capabilities/nan.json +28 -28
- package/dist/capabilities/nano-gpt.json +576 -583
- package/dist/capabilities/nearai.json +108 -108
- package/dist/capabilities/nebius.json +34 -34
- package/dist/capabilities/neon.json +135 -135
- package/dist/capabilities/neuralwatt.json +42 -42
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +169 -169
- package/dist/capabilities/nvidia.json +41 -41
- package/dist/capabilities/obscurify.json +28 -28
- package/dist/capabilities/oci.json +8 -8
- package/dist/capabilities/ofox.json +396 -396
- package/dist/capabilities/ollama-cloud.json +60 -60
- package/dist/capabilities/openai.json +55 -55
- package/dist/capabilities/opencode-go.json +86 -86
- package/dist/capabilities/openreason.json +6 -6
- package/dist/capabilities/openrouter.json +567 -568
- package/dist/capabilities/opper.json +29 -29
- package/dist/capabilities/orcarouter.json +247 -247
- package/dist/capabilities/outerlabs.json +25 -25
- package/dist/capabilities/ovhcloud.json +19 -19
- package/dist/capabilities/pareto.json +5 -5
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +65 -65
- package/dist/capabilities/phala.json +32 -32
- package/dist/capabilities/pioneer.json +25 -25
- package/dist/capabilities/poe.json +132 -132
- package/dist/capabilities/poolside.json +3 -3
- package/dist/capabilities/powerspring.json +4 -4
- package/dist/capabilities/primalabs.json +10 -10
- package/dist/capabilities/prime.json +122 -113
- package/dist/capabilities/privatemode-ai.json +8 -8
- package/dist/capabilities/proxystacks.json +3 -3
- package/dist/capabilities/qiniu-ai.json +11 -11
- package/dist/capabilities/refuseless.json +3 -3
- package/dist/capabilities/regolo-ai.json +10 -10
- package/dist/capabilities/requesty.json +369 -165
- package/dist/capabilities/ruapi.json +16 -16
- package/dist/capabilities/runcrate.json +12 -12
- package/dist/capabilities/runinfra.json +17 -17
- package/dist/capabilities/sakana.json +5 -5
- package/dist/capabilities/sambanova.json +5 -5
- package/dist/capabilities/sandbase.json +21 -21
- package/dist/capabilities/sarvam.json +10 -10
- package/dist/capabilities/scaleway.json +15 -15
- package/dist/capabilities/scnet-token-plan.json +13 -13
- package/dist/capabilities/scx-ai.json +27 -27
- package/dist/capabilities/sensenova.json +15 -15
- package/dist/capabilities/siliconflow-cn.json +72 -72
- package/dist/capabilities/siliconflow.json +56 -56
- package/dist/capabilities/snowflake-cortex.json +25 -25
- package/dist/capabilities/sokkan.json +9 -9
- package/dist/capabilities/sparrowcodes.json +21 -21
- package/dist/capabilities/standardcompute.json +101 -101
- package/dist/capabilities/steadyrouter.json +45 -45
- package/dist/capabilities/stepping-stone.json +17 -17
- package/dist/capabilities/synthetic.json +14 -14
- package/dist/capabilities/synthorai.json +25 -25
- package/dist/capabilities/teamorouter.json +24 -24
- package/dist/capabilities/teapot-router.json +5 -5
- package/dist/capabilities/tencent-token-plan-intl.json +22 -22
- package/dist/capabilities/tencent-token-plan.json +44 -44
- package/dist/capabilities/tencent-tokenhub.json +44 -44
- package/dist/capabilities/tensorx.json +42 -42
- package/dist/capabilities/the-grid-ai.json +23 -23
- package/dist/capabilities/thinkingmachines.json +56 -56
- package/dist/capabilities/tinfoil.json +10 -10
- package/dist/capabilities/toapis.json +3 -3
- package/dist/capabilities/togetherai.json +51 -51
- package/dist/capabilities/tokengo.json +25 -25
- package/dist/capabilities/tokenify.json +10 -10
- package/dist/capabilities/trustedrouter.json +5 -5
- package/dist/capabilities/trustedtokens.json +17 -17
- package/dist/capabilities/umans-ai-coding-plan.json +16 -16
- package/dist/capabilities/umans-ai.json +13 -13
- package/dist/capabilities/unrestricted.json +4 -4
- package/dist/capabilities/uplinkswitch.json +15 -15
- package/dist/capabilities/upstage.json +5 -5
- package/dist/capabilities/vancine.json +24 -24
- package/dist/capabilities/vercel.json +560 -560
- package/dist/capabilities/vivgrid.json +80 -80
- package/dist/capabilities/volcengine-coding-plan.json +27 -27
- package/dist/capabilities/volcengine.json +29 -28
- package/dist/capabilities/vultr.json +32 -32
- package/dist/capabilities/wafer.ai.json +19 -19
- package/dist/capabilities/wally.json +12 -12
- package/dist/capabilities/wandb.json +21 -21
- package/dist/capabilities/watt.json +21 -21
- package/dist/capabilities/xai.json +4 -4
- package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
- package/dist/capabilities/xiaomi.json +2 -2
- package/dist/capabilities/xpersona.json +11 -11
- package/dist/capabilities/xxapi.json +28 -28
- package/dist/capabilities/zai-coding-plan.json +18 -18
- package/dist/capabilities/zai.json +27 -27
- package/dist/capabilities/zenifra.json +30 -30
- package/dist/capabilities/zenmux.json +181 -181
- package/dist/capabilities/zerogpu.json +12 -12
- package/dist/capabilities/zhipuai-coding-plan.json +4 -4
- package/dist/capabilities/zhipuai.json +26 -26
- package/dist/capabilities/zro.json +5 -5
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/{channels-DCd_dDOB.cjs → channels-CO1XGZll.cjs} +1 -1
- package/dist/{channels-DwAd1RtQ.js → channels-EtP7uAxI.js} +1 -1
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/datasets/index.cjs +2 -2
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +534 -519
- package/dist/docs/references/docs-agents-code-mode.md +20 -0
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +2 -0
- package/dist/docs/references/reference-tools-create-code-mode.md +22 -0
- 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/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/agent-scopes.d.ts +17 -0
- package/dist/knowledge/declarations.d.ts +2 -0
- package/dist/knowledge/held-scopes-state-processor.d.ts +50 -0
- package/dist/knowledge/importers/types.d.ts +2 -0
- package/dist/knowledge/index.cjs +65 -15
- package/dist/knowledge/index.d.ts +6 -0
- package/dist/knowledge/index.js +64 -16
- package/dist/knowledge/page-tools.d.ts +14 -0
- package/dist/knowledge/run.d.ts +1 -0
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +7982 -7987
- package/dist/{llm-DQTGexjo.cjs → llm-BFX_NqOg.cjs} +2 -2
- package/dist/{llm-BdHdjrHp.js → llm-CCrVS2x2.js} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/{manager-BxE49QHe.js → manager-UMKLXQfC.js} +2 -2
- package/dist/{manager-CjT4ivOl.cjs → manager-thZrFty9.cjs} +2 -2
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-DKjpNZ-1.js → mastra-BIFCuq8a.js} +16 -16
- package/dist/{mastra-CraMHXhw.cjs → mastra-Dum21R9e.cjs} +16 -16
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.js +2 -2
- package/dist/{model-BEFQWHnG.cjs → model-BSJM-uPh.cjs} +1 -1
- package/dist/{model-X2gWHlAy.js → model-ylucqLzJ.js} +1 -1
- package/dist/{netlify-BFgeBsaW.cjs → netlify-DlmO_1PJ.cjs} +1 -1
- package/dist/{netlify-kxJSdqCW.js → netlify-Dwaz8kVT.js} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- 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/runner.d.ts +12 -0
- package/dist/{provider-registry-BXDosXMN.cjs → provider-registry-BPAmstg2.cjs} +22839 -22840
- package/dist/{provider-registry-DgezoItQ.js → provider-registry-BmJ_yV84.js} +22839 -22840
- package/dist/provider-registry.json +23227 -23224
- package/dist/{registry-generator-BMXgTdbx.cjs → registry-generator-BDMF_ksT.cjs} +1 -1
- package/dist/{registry-generator-B50FrVGs.js → registry-generator-BJvpKeLl.js} +1 -1
- package/dist/{rehydrate-CBcjKKGA.cjs → rehydrate-BLx0h6x3.cjs} +2 -2
- package/dist/{rehydrate-Dp8f_1MN.js → rehydrate-BxSMnG8L.js} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-BRO8xz9z.cjs → run-registry-BjGLELnz.cjs} +343 -17
- package/dist/{run-registry-H2qdwHni.js → run-registry-Bs0kCDZZ.js} +320 -18
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +2 -2
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/{stream-DcYRY4r3.js → stream-DdF6q5TA.js} +35 -12
- package/dist/{stream-nABk9CJK.cjs → stream-DiZTdV_p.cjs} +35 -12
- 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-D1Rufbcz.cjs → tool-loop-agent-ACOMyW_5.cjs} +3 -3
- package/dist/{tool-loop-agent-DO-GkLD_.js → tool-loop-agent-DLsAaJ2M.js} +3 -3
- package/dist/tools/code-mode/index.d.ts +2 -0
- package/dist/tools/code-mode/log-collector.d.ts +49 -0
- package/dist/tools/code-mode/types.d.ts +71 -0
- package/dist/tools/index.cjs +3 -1
- package/dist/tools/index.js +2 -2
- package/dist/{tools-n9lqzDNe.cjs → tools-BEYxowf0.cjs} +316 -30
- package/dist/{tools-DDfA_ES4.js → tools-tPy2FwMI.js} +305 -31
- package/dist/{utils-DY0lTRKE.cjs → utils-C68cIPq9.cjs} +1 -1
- package/dist/{utils-DlsFs_sO.js → utils-DUTHqSao.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-DP9DxgFq.cjs → validate-DB0f9rHc.cjs} +1 -1
- package/dist/{validate-D4nqo7Ri.js → validate-Di90-o2o.js} +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-8MNVG9Ja.js → worker-BJXBb4t7.js} +2 -2
- package/dist/{worker-LryffZas.cjs → worker-BuvCA4E5.cjs} +2 -2
- package/dist/{worker-Ckryk6RZ.js → worker-DCjlSDNL.js} +2 -2
- package/dist/{worker-CqEMDlAQ.cjs → worker-_e7Td4xZ.cjs} +2 -2
- package/dist/{workflow-B0mhMnuQ.js → workflow-BLs4Y-pr.js} +3 -3
- package/dist/{workflow-BN6YiI09.cjs → workflow-DqDzCAZR.cjs} +3 -3
- 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/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/sandbox/teardown-context.d.ts +74 -0
- package/dist/{workspace-Pv3J8K0c.cjs → workspace-C8Zo5_qK.cjs} +106 -5
- package/dist/{workspace-BK9ltbSa.js → workspace-DOAil8mG.js} +106 -5
- package/package.json +4 -4
- package/src/llm/model/provider-types.generated.d.ts +7982 -7987
package/dist/workspace/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_workspace = require("../workspace-
|
|
2
|
+
const require_workspace = require("../workspace-C8Zo5_qK.cjs");
|
|
3
3
|
const require_errors = require("../errors-D5kMB1FQ.cjs");
|
|
4
4
|
const require_workspace_skills = require("../workspace-skills-BcquhPDn.cjs");
|
|
5
5
|
exports.CompositeFilesystem = require_workspace.CompositeFilesystem;
|
package/dist/workspace/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as SandboxAbortError, A as deleteFileTool, B as MastraSandbox, C as fileStatTool, E as truncateOutput, F as LocalSandbox, G as supportsComputer, H as UnsupportedStdinCloseError, I as detectIsolation, J as MountManager, K as supportsNetworking, L as getRecommendedIsolation, M as requireFilesystem, N as requireSandbox, P as requireWorkspace, Q as MountNotSupportedError, R as isIsolationAvailable, S as indexContentTool, T as DEFAULT_TAIL_LINES, U as MAX_SANDBOX_FILE_MODE, V as ProcessHandle, W as assertModesUnsupported, X as IsolationUnavailableError, Y as FilesystemNotMountableError, Z as MountError, _ as writeFileTool, a as describeFactorySandbox, b as mkdirTool, c as Workspace, ct as MastraFilesystem, d as collectSkillForPublish, dt as WORKSPACE_TOOLS, et as SandboxError, f as publishSkillFromSource, ft as WORKSPACE_TOOLS_PREFIX, g as resolveToolConfig, h as createWorkspaceTools, i as FactorySandbox, it as SandboxUnsupportedFeatureError, j as applyPatchTool, k as editFileTool, l as createSkillTools, lt as CompositeFilesystem, m as VersionedSkillSource, n as createRecreateSandboxTool, nt as SandboxNotReadyError, o as isFactorySandbox, p as CompositeVersionedSkillSource, q as validateSandboxFileMode, r as FACTORY_SANDBOX_BRAND, rt as SandboxTimeoutError, s as normalizeFactorySandboxSettings, st as LocalFilesystem, t as RECREATE_SANDBOX_TOOL_ID, tt as SandboxExecutionError, u as formatSkillActivation, ut as callLifecycle, v as searchTool, w as executeCommandTool, x as listFilesTool, y as readFileTool, z as SandboxProcessManager } from "../workspace-
|
|
1
|
+
import { $ as SandboxAbortError, A as deleteFileTool, B as MastraSandbox, C as fileStatTool, E as truncateOutput, F as LocalSandbox, G as supportsComputer, H as UnsupportedStdinCloseError, I as detectIsolation, J as MountManager, K as supportsNetworking, L as getRecommendedIsolation, M as requireFilesystem, N as requireSandbox, P as requireWorkspace, Q as MountNotSupportedError, R as isIsolationAvailable, S as indexContentTool, T as DEFAULT_TAIL_LINES, U as MAX_SANDBOX_FILE_MODE, V as ProcessHandle, W as assertModesUnsupported, X as IsolationUnavailableError, Y as FilesystemNotMountableError, Z as MountError, _ as writeFileTool, a as describeFactorySandbox, b as mkdirTool, c as Workspace, ct as MastraFilesystem, d as collectSkillForPublish, dt as WORKSPACE_TOOLS, et as SandboxError, f as publishSkillFromSource, ft as WORKSPACE_TOOLS_PREFIX, g as resolveToolConfig, h as createWorkspaceTools, i as FactorySandbox, it as SandboxUnsupportedFeatureError, j as applyPatchTool, k as editFileTool, l as createSkillTools, lt as CompositeFilesystem, m as VersionedSkillSource, n as createRecreateSandboxTool, nt as SandboxNotReadyError, o as isFactorySandbox, p as CompositeVersionedSkillSource, q as validateSandboxFileMode, r as FACTORY_SANDBOX_BRAND, rt as SandboxTimeoutError, s as normalizeFactorySandboxSettings, st as LocalFilesystem, t as RECREATE_SANDBOX_TOOL_ID, tt as SandboxExecutionError, u as formatSkillActivation, ut as callLifecycle, v as searchTool, w as executeCommandTool, x as listFilesTool, y as readFileTool, z as SandboxProcessManager } from "../workspace-DOAil8mG.js";
|
|
2
2
|
import { _ as WorkspaceError, a as FileReadRequiredError, b as WorkspaceReadOnlyError, c as FilesystemNotReadyError, d as PermissionError, f as SandboxFeatureNotSupportedError, g as UnsupportedGrepPatternError, h as StaleFileError, i as FileNotFoundError, l as IsDirectoryError, m as SearchNotAvailableError, n as DirectoryNotFoundError, o as FilesystemError, p as SandboxNotAvailableError, r as FileExistsError, s as FilesystemNotAvailableError, t as DirectoryNotEmptyError, u as NotDirectoryError, v as WorkspaceNotAvailableError, y as WorkspaceNotReadyError } from "../errors-CzFYpCHw.js";
|
|
3
3
|
import { b as getMimeType, f as createGlobMatcher, h as matchGlob, l as LocalSkillSource, m as isGlobPattern, p as extractGlobBase } from "../workspace-skills-38OY32_b.js";
|
|
4
4
|
export { CompositeFilesystem, CompositeVersionedSkillSource, DEFAULT_TAIL_LINES, DirectoryNotEmptyError, DirectoryNotFoundError, FACTORY_SANDBOX_BRAND, FactorySandbox, FileExistsError, FileNotFoundError, FileReadRequiredError, FilesystemError, FilesystemNotAvailableError, FilesystemNotMountableError, FilesystemNotReadyError, IsDirectoryError, IsolationUnavailableError, LocalFilesystem, LocalSandbox, LocalSkillSource, MAX_SANDBOX_FILE_MODE, MastraFilesystem, MastraSandbox, MountError, MountManager, MountNotSupportedError, NotDirectoryError, PermissionError, ProcessHandle, RECREATE_SANDBOX_TOOL_ID, SandboxAbortError, SandboxError, SandboxExecutionError, SandboxFeatureNotSupportedError, SandboxNotAvailableError, SandboxNotReadyError, SandboxProcessManager, SandboxTimeoutError, SandboxUnsupportedFeatureError, SearchNotAvailableError, StaleFileError, UnsupportedGrepPatternError, UnsupportedStdinCloseError, VersionedSkillSource, WORKSPACE_TOOLS, WORKSPACE_TOOLS_PREFIX, Workspace, WorkspaceError, WorkspaceNotAvailableError, WorkspaceNotReadyError, WorkspaceReadOnlyError, applyPatchTool, assertModesUnsupported, callLifecycle, collectSkillForPublish, createGlobMatcher, createRecreateSandboxTool, createSkillTools, createWorkspaceTools, deleteFileTool, describeFactorySandbox, detectIsolation, editFileTool, executeCommandTool, extractGlobBase, fileStatTool, formatSkillActivation, getMimeType, getRecommendedIsolation, indexContentTool, isFactorySandbox, isGlobPattern, isIsolationAvailable, listFilesTool, matchGlob, mkdirTool, normalizeFactorySandboxSettings, publishSkillFromSource, readFileTool, requireFilesystem, requireSandbox, requireWorkspace, resolveToolConfig, searchTool, supportsComputer, supportsNetworking, truncateOutput, validateSandboxFileMode, writeFileTool };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox teardown context (internal).
|
|
3
|
+
*
|
|
4
|
+
* `MastraSandbox.ensureRunning()` must let a provider's own teardown traffic
|
|
5
|
+
* through while blocking unrelated callers: `stop()`/`destroy()` legitimately
|
|
6
|
+
* list and kill processes, and those calls re-enter `ensureRunning()` on the
|
|
7
|
+
* same sandbox. Blocking them would deadlock teardown; letting every caller
|
|
8
|
+
* through lets a command interleave with a stop and run against a sandbox that
|
|
9
|
+
* is being torn down.
|
|
10
|
+
*
|
|
11
|
+
* The fix is caller identity, not a global flag: `stop()`/`destroy()` run their
|
|
12
|
+
* hook + provider work inside an {@link AsyncLocalStorage} scope holding the
|
|
13
|
+
* sandbox instance, so `ensureRunning()` can tell "this call is part of *this*
|
|
14
|
+
* sandbox's teardown" from "this call is external". Identity survives arbitrary
|
|
15
|
+
* awaits, so it reaches nested hooks and process-manager wrappers.
|
|
16
|
+
*
|
|
17
|
+
* Two properties keep that identity honest:
|
|
18
|
+
*
|
|
19
|
+
* - A scope expires when the teardown it opened settles. Work that outlives the
|
|
20
|
+
* teardown (a timer or an unawaited call scheduled inside a hook) still sees
|
|
21
|
+
* the scope as its store, but must not stay authorized to bypass the fence.
|
|
22
|
+
* - Scopes chain to the teardown that opened them, so one sandbox's hook tearing
|
|
23
|
+
* down another (`A.onStop` calling `B._stop()`) can still reach `A` from inside
|
|
24
|
+
* `B`'s teardown instead of deadlocking on `A`'s own in-flight stop. The chain
|
|
25
|
+
* only spans *live* teardowns: a settled scope ends it, so work an inner
|
|
26
|
+
* teardown left behind is an external caller of every sandbox, not a member of
|
|
27
|
+
* the enclosing teardown.
|
|
28
|
+
*
|
|
29
|
+
* Not exported from `workspace/sandbox/index.ts` or any package export.
|
|
30
|
+
*/
|
|
31
|
+
/** The lifecycles that may re-enter the sandbox while it is torn down. */
|
|
32
|
+
type SandboxTeardownPhase = 'stopping' | 'destroying';
|
|
33
|
+
/**
|
|
34
|
+
* Whether this runtime can attribute a re-entrant call to its teardown scope.
|
|
35
|
+
*
|
|
36
|
+
* When it cannot, `ensureRunning()` keeps the legacy behavior of letting calls
|
|
37
|
+
* during `stopping` through (awaiting teardown without caller identity would
|
|
38
|
+
* deadlock providers doing process teardown). `destroying` still rejects.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isSandboxTeardownScopeSupported(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Run `work` inside `sandbox`'s teardown scope for `phase`, so nested calls
|
|
43
|
+
* into the sandbox are recognized as part of this teardown.
|
|
44
|
+
*
|
|
45
|
+
* The scope deliberately covers only the teardown work itself — hook execution
|
|
46
|
+
* and the provider's `stop()`/`destroy()` — never unrelated external work, and
|
|
47
|
+
* it closes as soon as `work` settles: a callback the hook left behind (a timer,
|
|
48
|
+
* an unawaited command) sees the scope as its store once inherited, but is no
|
|
49
|
+
* longer authorized once the teardown it belongs to is over.
|
|
50
|
+
*/
|
|
51
|
+
export declare function runInSandboxTeardown<T>(sandbox: unknown, phase: SandboxTeardownPhase, work: () => T | Promise<T>): Promise<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the current async scope is `sandbox`'s own in-flight teardown. Matched
|
|
54
|
+
* by instance identity, so one sandbox's teardown never authorizes another's.
|
|
55
|
+
*
|
|
56
|
+
* Walks the scope chain, which links each teardown to the one it ran inside: a
|
|
57
|
+
* sandbox torn down from inside another sandbox's teardown is still that outer
|
|
58
|
+
* teardown's work, and attributing it elsewhere would make it wait on the very
|
|
59
|
+
* stop it is part of.
|
|
60
|
+
*
|
|
61
|
+
* The walk requires every scope it crosses to be active. A settled scope ends
|
|
62
|
+
* it, because work that outlived a teardown (a timer or unawaited call the hook
|
|
63
|
+
* left behind) is an ordinary external caller: reaching through the expired
|
|
64
|
+
* scope to an enclosing teardown would hand that orphaned work permission its
|
|
65
|
+
* own teardown no longer has, and would make one sandbox's leftover callback
|
|
66
|
+
* count as another sandbox's teardown.
|
|
67
|
+
*
|
|
68
|
+
* The trade-off is deliberate: an outer teardown must not *await* work that an
|
|
69
|
+
* inner teardown left behind, since that work is now external and will wait on
|
|
70
|
+
* the outer stop. Only work still inside a live teardown is authorized.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isInSandboxTeardown(sandbox: unknown): boolean;
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=teardown-context.d.ts.map
|
|
@@ -2746,6 +2746,97 @@ var ProcessHandle = class {
|
|
|
2746
2746
|
return this._writer;
|
|
2747
2747
|
}
|
|
2748
2748
|
};
|
|
2749
|
+
// src/workspace/sandbox/teardown-context.ts
|
|
2750
|
+
let storage;
|
|
2751
|
+
let storageResolved = false;
|
|
2752
|
+
/**
|
|
2753
|
+
* Resolve `AsyncLocalStorage` lazily, without a static `node:async_hooks`
|
|
2754
|
+
* import.
|
|
2755
|
+
*
|
|
2756
|
+
* Studio's client bundle transitively imports the agent runtime, which pulls in
|
|
2757
|
+
* the sandbox modules, so a top-level `import 'node:async_hooks'` would hoist a
|
|
2758
|
+
* Node builtin into a browser graph. `process.getBuiltinModule` is available on
|
|
2759
|
+
* the supported Node baseline (>= 22.13) and returns the builtin without a
|
|
2760
|
+
* module-resolution step, so directly constructed sandboxes have no async
|
|
2761
|
+
* initialization gap. Elsewhere (import-only or browser-like runtimes) this
|
|
2762
|
+
* resolves to `undefined`.
|
|
2763
|
+
*/
|
|
2764
|
+
function getStorage() {
|
|
2765
|
+
if (storageResolved) return storage;
|
|
2766
|
+
storageResolved = true;
|
|
2767
|
+
try {
|
|
2768
|
+
const getBuiltinModule = globalThis.process?.getBuiltinModule;
|
|
2769
|
+
const AsyncLocalStorage = (typeof getBuiltinModule === "function" ? getBuiltinModule("node:async_hooks") : void 0)?.AsyncLocalStorage;
|
|
2770
|
+
if (typeof AsyncLocalStorage === "function") storage = new AsyncLocalStorage();
|
|
2771
|
+
} catch {
|
|
2772
|
+
storage = void 0;
|
|
2773
|
+
}
|
|
2774
|
+
return storage;
|
|
2775
|
+
}
|
|
2776
|
+
/**
|
|
2777
|
+
* Whether this runtime can attribute a re-entrant call to its teardown scope.
|
|
2778
|
+
*
|
|
2779
|
+
* When it cannot, `ensureRunning()` keeps the legacy behavior of letting calls
|
|
2780
|
+
* during `stopping` through (awaiting teardown without caller identity would
|
|
2781
|
+
* deadlock providers doing process teardown). `destroying` still rejects.
|
|
2782
|
+
*/
|
|
2783
|
+
function isSandboxTeardownScopeSupported() {
|
|
2784
|
+
return getStorage() !== void 0;
|
|
2785
|
+
}
|
|
2786
|
+
/**
|
|
2787
|
+
* Run `work` inside `sandbox`'s teardown scope for `phase`, so nested calls
|
|
2788
|
+
* into the sandbox are recognized as part of this teardown.
|
|
2789
|
+
*
|
|
2790
|
+
* The scope deliberately covers only the teardown work itself — hook execution
|
|
2791
|
+
* and the provider's `stop()`/`destroy()` — never unrelated external work, and
|
|
2792
|
+
* it closes as soon as `work` settles: a callback the hook left behind (a timer,
|
|
2793
|
+
* an unawaited command) sees the scope as its store once inherited, but is no
|
|
2794
|
+
* longer authorized once the teardown it belongs to is over.
|
|
2795
|
+
*/
|
|
2796
|
+
async function runInSandboxTeardown(sandbox, phase, work) {
|
|
2797
|
+
const activeStorage = getStorage();
|
|
2798
|
+
if (!activeStorage) return work();
|
|
2799
|
+
const scope = {
|
|
2800
|
+
sandbox,
|
|
2801
|
+
phase,
|
|
2802
|
+
parent: activeStorage.getStore(),
|
|
2803
|
+
active: true
|
|
2804
|
+
};
|
|
2805
|
+
try {
|
|
2806
|
+
return await activeStorage.run(scope, work);
|
|
2807
|
+
} finally {
|
|
2808
|
+
scope.active = false;
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
/**
|
|
2812
|
+
* Whether the current async scope is `sandbox`'s own in-flight teardown. Matched
|
|
2813
|
+
* by instance identity, so one sandbox's teardown never authorizes another's.
|
|
2814
|
+
*
|
|
2815
|
+
* Walks the scope chain, which links each teardown to the one it ran inside: a
|
|
2816
|
+
* sandbox torn down from inside another sandbox's teardown is still that outer
|
|
2817
|
+
* teardown's work, and attributing it elsewhere would make it wait on the very
|
|
2818
|
+
* stop it is part of.
|
|
2819
|
+
*
|
|
2820
|
+
* The walk requires every scope it crosses to be active. A settled scope ends
|
|
2821
|
+
* it, because work that outlived a teardown (a timer or unawaited call the hook
|
|
2822
|
+
* left behind) is an ordinary external caller: reaching through the expired
|
|
2823
|
+
* scope to an enclosing teardown would hand that orphaned work permission its
|
|
2824
|
+
* own teardown no longer has, and would make one sandbox's leftover callback
|
|
2825
|
+
* count as another sandbox's teardown.
|
|
2826
|
+
*
|
|
2827
|
+
* The trade-off is deliberate: an outer teardown must not *await* work that an
|
|
2828
|
+
* inner teardown left behind, since that work is now external and will wait on
|
|
2829
|
+
* the outer stop. Only work still inside a live teardown is authorized.
|
|
2830
|
+
*/
|
|
2831
|
+
function isInSandboxTeardown(sandbox) {
|
|
2832
|
+
const activeStorage = getStorage();
|
|
2833
|
+
if (!activeStorage) return false;
|
|
2834
|
+
for (let scope = activeStorage.getStore(); scope; scope = scope.parent) {
|
|
2835
|
+
if (!scope.active) return false;
|
|
2836
|
+
if (scope.sandbox === sandbox) return true;
|
|
2837
|
+
}
|
|
2838
|
+
return false;
|
|
2839
|
+
}
|
|
2749
2840
|
// src/workspace/sandbox/mastra-sandbox.ts
|
|
2750
2841
|
/**
|
|
2751
2842
|
* MastraSandbox Base Class
|
|
@@ -3109,8 +3200,14 @@ var MastraSandbox = class MastraSandbox extends require_base.MastraBase {
|
|
|
3109
3200
|
* ```
|
|
3110
3201
|
*/
|
|
3111
3202
|
async ensureRunning() {
|
|
3203
|
+
if (isInSandboxTeardown(this)) return;
|
|
3112
3204
|
if (this.status === "destroyed") throw new SandboxNotReadyError(this.id);
|
|
3113
|
-
if (this.status === "destroying"
|
|
3205
|
+
if (this.status === "destroying") throw new SandboxNotReadyError(this.id);
|
|
3206
|
+
if (this.status === "stopping") {
|
|
3207
|
+
if (!isSandboxTeardownScopeSupported()) return;
|
|
3208
|
+
const stopPromise = this._stopPromise;
|
|
3209
|
+
if (stopPromise) await stopPromise;
|
|
3210
|
+
}
|
|
3114
3211
|
if (this.status !== "running") await this._start();
|
|
3115
3212
|
if (this.status !== "running") throw new SandboxNotReadyError(this.id);
|
|
3116
3213
|
}
|
|
@@ -3139,8 +3236,10 @@ var MastraSandbox = class MastraSandbox extends require_base.MastraBase {
|
|
|
3139
3236
|
async _executeStop() {
|
|
3140
3237
|
this.status = "stopping";
|
|
3141
3238
|
try {
|
|
3142
|
-
await this
|
|
3143
|
-
|
|
3239
|
+
await runInSandboxTeardown(this, "stopping", async () => {
|
|
3240
|
+
await this._onStop?.({ sandbox: this });
|
|
3241
|
+
await this.stop();
|
|
3242
|
+
});
|
|
3144
3243
|
this.status = "stopped";
|
|
3145
3244
|
} catch (error) {
|
|
3146
3245
|
this.status = "error";
|
|
@@ -3184,8 +3283,10 @@ var MastraSandbox = class MastraSandbox extends require_base.MastraBase {
|
|
|
3184
3283
|
async _executeDestroy() {
|
|
3185
3284
|
this.status = "destroying";
|
|
3186
3285
|
try {
|
|
3187
|
-
await this
|
|
3188
|
-
|
|
3286
|
+
await runInSandboxTeardown(this, "destroying", async () => {
|
|
3287
|
+
await this._onDestroy?.({ sandbox: this });
|
|
3288
|
+
await this.destroy();
|
|
3289
|
+
});
|
|
3189
3290
|
this.status = "destroyed";
|
|
3190
3291
|
} catch (error) {
|
|
3191
3292
|
this.status = "error";
|
|
@@ -2741,6 +2741,97 @@ var ProcessHandle = class {
|
|
|
2741
2741
|
return this._writer;
|
|
2742
2742
|
}
|
|
2743
2743
|
};
|
|
2744
|
+
// src/workspace/sandbox/teardown-context.ts
|
|
2745
|
+
let storage;
|
|
2746
|
+
let storageResolved = false;
|
|
2747
|
+
/**
|
|
2748
|
+
* Resolve `AsyncLocalStorage` lazily, without a static `node:async_hooks`
|
|
2749
|
+
* import.
|
|
2750
|
+
*
|
|
2751
|
+
* Studio's client bundle transitively imports the agent runtime, which pulls in
|
|
2752
|
+
* the sandbox modules, so a top-level `import 'node:async_hooks'` would hoist a
|
|
2753
|
+
* Node builtin into a browser graph. `process.getBuiltinModule` is available on
|
|
2754
|
+
* the supported Node baseline (>= 22.13) and returns the builtin without a
|
|
2755
|
+
* module-resolution step, so directly constructed sandboxes have no async
|
|
2756
|
+
* initialization gap. Elsewhere (import-only or browser-like runtimes) this
|
|
2757
|
+
* resolves to `undefined`.
|
|
2758
|
+
*/
|
|
2759
|
+
function getStorage() {
|
|
2760
|
+
if (storageResolved) return storage;
|
|
2761
|
+
storageResolved = true;
|
|
2762
|
+
try {
|
|
2763
|
+
const getBuiltinModule = globalThis.process?.getBuiltinModule;
|
|
2764
|
+
const AsyncLocalStorage = (typeof getBuiltinModule === "function" ? getBuiltinModule("node:async_hooks") : void 0)?.AsyncLocalStorage;
|
|
2765
|
+
if (typeof AsyncLocalStorage === "function") storage = new AsyncLocalStorage();
|
|
2766
|
+
} catch {
|
|
2767
|
+
storage = void 0;
|
|
2768
|
+
}
|
|
2769
|
+
return storage;
|
|
2770
|
+
}
|
|
2771
|
+
/**
|
|
2772
|
+
* Whether this runtime can attribute a re-entrant call to its teardown scope.
|
|
2773
|
+
*
|
|
2774
|
+
* When it cannot, `ensureRunning()` keeps the legacy behavior of letting calls
|
|
2775
|
+
* during `stopping` through (awaiting teardown without caller identity would
|
|
2776
|
+
* deadlock providers doing process teardown). `destroying` still rejects.
|
|
2777
|
+
*/
|
|
2778
|
+
function isSandboxTeardownScopeSupported() {
|
|
2779
|
+
return getStorage() !== void 0;
|
|
2780
|
+
}
|
|
2781
|
+
/**
|
|
2782
|
+
* Run `work` inside `sandbox`'s teardown scope for `phase`, so nested calls
|
|
2783
|
+
* into the sandbox are recognized as part of this teardown.
|
|
2784
|
+
*
|
|
2785
|
+
* The scope deliberately covers only the teardown work itself — hook execution
|
|
2786
|
+
* and the provider's `stop()`/`destroy()` — never unrelated external work, and
|
|
2787
|
+
* it closes as soon as `work` settles: a callback the hook left behind (a timer,
|
|
2788
|
+
* an unawaited command) sees the scope as its store once inherited, but is no
|
|
2789
|
+
* longer authorized once the teardown it belongs to is over.
|
|
2790
|
+
*/
|
|
2791
|
+
async function runInSandboxTeardown(sandbox, phase, work) {
|
|
2792
|
+
const activeStorage = getStorage();
|
|
2793
|
+
if (!activeStorage) return work();
|
|
2794
|
+
const scope = {
|
|
2795
|
+
sandbox,
|
|
2796
|
+
phase,
|
|
2797
|
+
parent: activeStorage.getStore(),
|
|
2798
|
+
active: true
|
|
2799
|
+
};
|
|
2800
|
+
try {
|
|
2801
|
+
return await activeStorage.run(scope, work);
|
|
2802
|
+
} finally {
|
|
2803
|
+
scope.active = false;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
/**
|
|
2807
|
+
* Whether the current async scope is `sandbox`'s own in-flight teardown. Matched
|
|
2808
|
+
* by instance identity, so one sandbox's teardown never authorizes another's.
|
|
2809
|
+
*
|
|
2810
|
+
* Walks the scope chain, which links each teardown to the one it ran inside: a
|
|
2811
|
+
* sandbox torn down from inside another sandbox's teardown is still that outer
|
|
2812
|
+
* teardown's work, and attributing it elsewhere would make it wait on the very
|
|
2813
|
+
* stop it is part of.
|
|
2814
|
+
*
|
|
2815
|
+
* The walk requires every scope it crosses to be active. A settled scope ends
|
|
2816
|
+
* it, because work that outlived a teardown (a timer or unawaited call the hook
|
|
2817
|
+
* left behind) is an ordinary external caller: reaching through the expired
|
|
2818
|
+
* scope to an enclosing teardown would hand that orphaned work permission its
|
|
2819
|
+
* own teardown no longer has, and would make one sandbox's leftover callback
|
|
2820
|
+
* count as another sandbox's teardown.
|
|
2821
|
+
*
|
|
2822
|
+
* The trade-off is deliberate: an outer teardown must not *await* work that an
|
|
2823
|
+
* inner teardown left behind, since that work is now external and will wait on
|
|
2824
|
+
* the outer stop. Only work still inside a live teardown is authorized.
|
|
2825
|
+
*/
|
|
2826
|
+
function isInSandboxTeardown(sandbox) {
|
|
2827
|
+
const activeStorage = getStorage();
|
|
2828
|
+
if (!activeStorage) return false;
|
|
2829
|
+
for (let scope = activeStorage.getStore(); scope; scope = scope.parent) {
|
|
2830
|
+
if (!scope.active) return false;
|
|
2831
|
+
if (scope.sandbox === sandbox) return true;
|
|
2832
|
+
}
|
|
2833
|
+
return false;
|
|
2834
|
+
}
|
|
2744
2835
|
// src/workspace/sandbox/mastra-sandbox.ts
|
|
2745
2836
|
/**
|
|
2746
2837
|
* MastraSandbox Base Class
|
|
@@ -3104,8 +3195,14 @@ var MastraSandbox = class MastraSandbox extends MastraBase {
|
|
|
3104
3195
|
* ```
|
|
3105
3196
|
*/
|
|
3106
3197
|
async ensureRunning() {
|
|
3198
|
+
if (isInSandboxTeardown(this)) return;
|
|
3107
3199
|
if (this.status === "destroyed") throw new SandboxNotReadyError(this.id);
|
|
3108
|
-
if (this.status === "destroying"
|
|
3200
|
+
if (this.status === "destroying") throw new SandboxNotReadyError(this.id);
|
|
3201
|
+
if (this.status === "stopping") {
|
|
3202
|
+
if (!isSandboxTeardownScopeSupported()) return;
|
|
3203
|
+
const stopPromise = this._stopPromise;
|
|
3204
|
+
if (stopPromise) await stopPromise;
|
|
3205
|
+
}
|
|
3109
3206
|
if (this.status !== "running") await this._start();
|
|
3110
3207
|
if (this.status !== "running") throw new SandboxNotReadyError(this.id);
|
|
3111
3208
|
}
|
|
@@ -3134,8 +3231,10 @@ var MastraSandbox = class MastraSandbox extends MastraBase {
|
|
|
3134
3231
|
async _executeStop() {
|
|
3135
3232
|
this.status = "stopping";
|
|
3136
3233
|
try {
|
|
3137
|
-
await this
|
|
3138
|
-
|
|
3234
|
+
await runInSandboxTeardown(this, "stopping", async () => {
|
|
3235
|
+
await this._onStop?.({ sandbox: this });
|
|
3236
|
+
await this.stop();
|
|
3237
|
+
});
|
|
3139
3238
|
this.status = "stopped";
|
|
3140
3239
|
} catch (error) {
|
|
3141
3240
|
this.status = "error";
|
|
@@ -3179,8 +3278,10 @@ var MastraSandbox = class MastraSandbox extends MastraBase {
|
|
|
3179
3278
|
async _executeDestroy() {
|
|
3180
3279
|
this.status = "destroying";
|
|
3181
3280
|
try {
|
|
3182
|
-
await this
|
|
3183
|
-
|
|
3281
|
+
await runInSandboxTeardown(this, "destroying", async () => {
|
|
3282
|
+
await this._onDestroy?.({ sandbox: this });
|
|
3283
|
+
await this.destroy();
|
|
3284
|
+
});
|
|
3184
3285
|
this.status = "destroyed";
|
|
3185
3286
|
} catch (error) {
|
|
3186
3287
|
this.status = "error";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/core",
|
|
3
|
-
"version": "1.87.0-alpha.
|
|
3
|
+
"version": "1.87.0-alpha.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -966,16 +966,16 @@
|
|
|
966
966
|
"vscode-languageserver-protocol": "^3.18.5",
|
|
967
967
|
"zod": "^4.6.7",
|
|
968
968
|
"zod-v3": "npm:zod@3.25.76",
|
|
969
|
-
"@internal/ai-sdk-v4": "0.0.99",
|
|
970
969
|
"@internal/ai-sdk-v5": "0.0.99",
|
|
971
|
-
"@internal/ai-v7": "0.0.99",
|
|
972
970
|
"@internal/ai-v6": "0.0.99",
|
|
971
|
+
"@internal/ai-v7": "0.0.99",
|
|
972
|
+
"@internal/ai-sdk-v4": "0.0.99",
|
|
973
973
|
"@internal/auth": "0.0.40",
|
|
974
974
|
"@internal/core": "0.1.4",
|
|
975
975
|
"@internal/deployer": "0.0.5",
|
|
976
976
|
"@internal/lint": "0.0.152",
|
|
977
|
-
"@internal/external-types": "0.0.102",
|
|
978
977
|
"@internal/llm-recorder": "0.0.88",
|
|
978
|
+
"@internal/external-types": "0.0.102",
|
|
979
979
|
"@internal/test-utils": "0.0.88",
|
|
980
980
|
"@internal/types-builder": "0.0.127",
|
|
981
981
|
"@internal/voice": "0.0.48"
|