@mastra/code-sdk 0.0.0-client-tool-results-20260912062135
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/LICENSE.md +32 -0
- package/README.md +37 -0
- package/dist/acp/agent.d.ts +35 -0
- package/dist/acp/agent.d.ts.map +1 -0
- package/dist/acp/agent.js +161 -0
- package/dist/acp/agent.js.map +1 -0
- package/dist/acp/event-mapper.d.ts +22 -0
- package/dist/acp/event-mapper.d.ts.map +1 -0
- package/dist/acp/event-mapper.js +214 -0
- package/dist/acp/event-mapper.js.map +1 -0
- package/dist/acp/index.d.ts +8 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +65 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/server.d.ts +7 -0
- package/dist/acp/server.d.ts.map +1 -0
- package/dist/acp/server.js +35 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.d.ts.map +1 -0
- package/dist/acp.js +2 -0
- package/dist/agents/context-audit.d.ts +84 -0
- package/dist/agents/context-audit.d.ts.map +1 -0
- package/dist/agents/context-audit.js +118 -0
- package/dist/agents/context-audit.js.map +1 -0
- package/dist/agents/credential-resolver.d.ts +63 -0
- package/dist/agents/credential-resolver.d.ts.map +1 -0
- package/dist/agents/credential-resolver.js +97 -0
- package/dist/agents/credential-resolver.js.map +1 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.d.ts.map +1 -0
- package/dist/agents/custom-provider-source.js +25 -0
- package/dist/agents/custom-provider-source.js.map +1 -0
- package/dist/agents/instructions.d.ts +29 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +58 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/mastracode-gateway.d.ts +74 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -0
- package/dist/agents/mastracode-gateway.js +431 -0
- package/dist/agents/mastracode-gateway.js.map +1 -0
- package/dist/agents/memory.d.ts +30 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +171 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/model.d.ts +81 -0
- package/dist/agents/model.d.ts.map +1 -0
- package/dist/agents/model.js +155 -0
- package/dist/agents/model.js.map +1 -0
- package/dist/agents/modes/build.d.ts +10 -0
- package/dist/agents/modes/build.d.ts.map +1 -0
- package/dist/agents/modes/build.js +49 -0
- package/dist/agents/modes/build.js.map +1 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.d.ts.map +1 -0
- package/dist/agents/modes/explore.js +42 -0
- package/dist/agents/modes/explore.js.map +1 -0
- package/dist/agents/modes/plan.d.ts +6 -0
- package/dist/agents/modes/plan.d.ts.map +1 -0
- package/dist/agents/modes/plan.js +42 -0
- package/dist/agents/modes/plan.js.map +1 -0
- package/dist/agents/prompts/agent-instructions.d.ts +70 -0
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
- package/dist/agents/prompts/agent-instructions.js +211 -0
- package/dist/agents/prompts/agent-instructions.js.map +1 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.d.ts.map +1 -0
- package/dist/agents/prompts/build.js +76 -0
- package/dist/agents/prompts/build.js.map +1 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.d.ts.map +1 -0
- package/dist/agents/prompts/fast.js +26 -0
- package/dist/agents/prompts/fast.js.map +1 -0
- package/dist/agents/prompts/index.d.ts +50 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/index.js +119 -0
- package/dist/agents/prompts/index.js.map +1 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.d.ts.map +1 -0
- package/dist/agents/prompts/model.js +23 -0
- package/dist/agents/prompts/model.js.map +1 -0
- package/dist/agents/prompts/plan.d.ts +6 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -0
- package/dist/agents/prompts/plan.js +111 -0
- package/dist/agents/prompts/plan.js.map +1 -0
- package/dist/agents/prompts/tool-guidance.d.ts +18 -0
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
- package/dist/agents/prompts/tool-guidance.js +180 -0
- package/dist/agents/prompts/tool-guidance.js.map +1 -0
- package/dist/agents/sandbox-filesystem.d.ts +117 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
- package/dist/agents/sandbox-filesystem.js +356 -0
- package/dist/agents/sandbox-filesystem.js.map +1 -0
- package/dist/agents/subagents/execute.d.ts +3 -0
- package/dist/agents/subagents/execute.d.ts.map +1 -0
- package/dist/agents/subagents/execute.js +27 -0
- package/dist/agents/subagents/execute.js.map +1 -0
- package/dist/agents/subagents/explore.d.ts +3 -0
- package/dist/agents/subagents/explore.d.ts.map +1 -0
- package/dist/agents/subagents/explore.js +18 -0
- package/dist/agents/subagents/explore.js.map +1 -0
- package/dist/agents/subagents/plan.d.ts +3 -0
- package/dist/agents/subagents/plan.d.ts.map +1 -0
- package/dist/agents/subagents/plan.js +18 -0
- package/dist/agents/subagents/plan.js.map +1 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.d.ts.map +1 -0
- package/dist/agents/thread-caveman-state.js +107 -0
- package/dist/agents/thread-caveman-state.js.map +1 -0
- package/dist/agents/tool-availability.d.ts +10 -0
- package/dist/agents/tool-availability.d.ts.map +1 -0
- package/dist/agents/tool-availability.js +96 -0
- package/dist/agents/tool-availability.js.map +1 -0
- package/dist/agents/tools.d.ts +36 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +117 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/workflow-builder-agent.d.ts +2 -0
- package/dist/agents/workflow-builder-agent.d.ts.map +1 -0
- package/dist/agents/workflow-builder-agent.js +80 -0
- package/dist/agents/workflow-builder-agent.js.map +1 -0
- package/dist/agents/workspace.d.ts +32 -0
- package/dist/agents/workspace.d.ts.map +1 -0
- package/dist/agents/workspace.js +208 -0
- package/dist/agents/workspace.js.map +1 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +163 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.d.ts.map +1 -0
- package/dist/auth/authorization-input.js +42 -0
- package/dist/auth/authorization-input.js.map +1 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.d.ts.map +1 -0
- package/dist/auth/device-code.js +129 -0
- package/dist/auth/device-code.js.map +1 -0
- package/dist/auth/index.d.ts +12 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +32 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/provider-auth-error.d.ts +12 -0
- package/dist/auth/provider-auth-error.d.ts.map +1 -0
- package/dist/auth/provider-auth-error.js +16 -0
- package/dist/auth/provider-auth-error.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +126 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.d.ts.map +1 -0
- package/dist/auth/providers/github-copilot.js +340 -0
- package/dist/auth/providers/github-copilot.js.map +1 -0
- package/dist/auth/providers/kimi-coding.d.ts +38 -0
- package/dist/auth/providers/kimi-coding.d.ts.map +1 -0
- package/dist/auth/providers/kimi-coding.js +232 -0
- package/dist/auth/providers/kimi-coding.js.map +1 -0
- package/dist/auth/providers/openai-codex.d.ts +139 -0
- package/dist/auth/providers/openai-codex.d.ts.map +1 -0
- package/dist/auth/providers/openai-codex.js +519 -0
- package/dist/auth/providers/openai-codex.js.map +1 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.d.ts.map +1 -0
- package/dist/auth/providers/xai.js +205 -0
- package/dist/auth/providers/xai.js.map +1 -0
- package/dist/auth/storage.d.ts +92 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +211 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/auth/types.d.ts +89 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +226 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +18 -0
- package/dist/constants.js.map +1 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.d.ts.map +1 -0
- package/dist/error-classification.js +22 -0
- package/dist/error-classification.js.map +1 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.d.ts.map +1 -0
- package/dist/evals/context-builder.js +161 -0
- package/dist/evals/context-builder.js.map +1 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +5 -0
- package/dist/evals/scorers/classify-command.d.ts +31 -0
- package/dist/evals/scorers/classify-command.d.ts.map +1 -0
- package/dist/evals/scorers/classify-command.js +73 -0
- package/dist/evals/scorers/classify-command.js.map +1 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.d.ts.map +1 -0
- package/dist/evals/scorers/efficiency.js +259 -0
- package/dist/evals/scorers/efficiency.js.map +1 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
- package/dist/evals/scorers/extract-tools.js +60 -0
- package/dist/evals/scorers/extract-tools.js.map +1 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.d.ts.map +1 -0
- package/dist/evals/scorers/index.js +3 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.d.ts.map +1 -0
- package/dist/evals/scorers/outcome.js +347 -0
- package/dist/evals/scorers/outcome.js.map +1 -0
- package/dist/goal-manager.d.ts +78 -0
- package/dist/goal-manager.d.ts.map +1 -0
- package/dist/goal-manager.js +273 -0
- package/dist/goal-manager.js.map +1 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.d.ts.map +1 -0
- package/dist/goal-signal.js +17 -0
- package/dist/goal-signal.js.map +1 -0
- package/dist/headless/cli.d.ts +42 -0
- package/dist/headless/cli.d.ts.map +1 -0
- package/dist/headless/cli.js +209 -0
- package/dist/headless/cli.js.map +1 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.d.ts.map +1 -0
- package/dist/headless/flags.js +190 -0
- package/dist/headless/flags.js.map +1 -0
- package/dist/headless/format.d.ts +38 -0
- package/dist/headless/format.d.ts.map +1 -0
- package/dist/headless/format.js +89 -0
- package/dist/headless/format.js.map +1 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.d.ts.map +1 -0
- package/dist/headless/index.js +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.d.ts.map +1 -0
- package/dist/headless/policy.js +42 -0
- package/dist/headless/policy.js.map +1 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.d.ts.map +1 -0
- package/dist/headless/run-mc.js +346 -0
- package/dist/headless/run-mc.js.map +1 -0
- package/dist/headless/types.d.ts +158 -0
- package/dist/headless/types.d.ts.map +1 -0
- package/dist/headless/types.js +19 -0
- package/dist/headless/types.js.map +1 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.d.ts.map +1 -0
- package/dist/hooks/config.js +73 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +129 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/manager.d.ts +54 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +241 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +172 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +8 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +341 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +919 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.d.ts.map +1 -0
- package/dist/ipc/ipc-reporter.js +21 -0
- package/dist/ipc/ipc-reporter.js.map +1 -0
- package/dist/knowledge-inspector.d.ts +119 -0
- package/dist/knowledge-inspector.d.ts.map +1 -0
- package/dist/knowledge-inspector.js +508 -0
- package/dist/knowledge-inspector.js.map +1 -0
- package/dist/knowledge-scope.d.ts +35 -0
- package/dist/knowledge-scope.d.ts.map +1 -0
- package/dist/knowledge-scope.js +47 -0
- package/dist/knowledge-scope.js.map +1 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.d.ts.map +1 -0
- package/dist/lsp/client.js +251 -0
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.d.ts.map +1 -0
- package/dist/lsp/index.js +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.d.ts.map +1 -0
- package/dist/lsp/language.js +44 -0
- package/dist/lsp/language.js.map +1 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.d.ts.map +1 -0
- package/dist/lsp/manager.js +82 -0
- package/dist/lsp/manager.js.map +1 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.d.ts.map +1 -0
- package/dist/lsp/server.js +159 -0
- package/dist/lsp/server.js.map +1 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.d.ts.map +1 -0
- package/dist/lsp/workspace.js +55 -0
- package/dist/lsp/workspace.js.map +1 -0
- package/dist/mcp/config.d.ts +62 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +301 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +101 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +644 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/state.d.ts +35 -0
- package/dist/mcp/state.d.ts.map +1 -0
- package/dist/mcp/state.js +97 -0
- package/dist/mcp/state.js.map +1 -0
- package/dist/mcp/types.d.ts +125 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.d.ts.map +1 -0
- package/dist/onboarding/custom-packs.js +17 -0
- package/dist/onboarding/custom-packs.js.map +1 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.d.ts.map +1 -0
- package/dist/onboarding/custom-providers.js +30 -0
- package/dist/onboarding/custom-providers.js.map +1 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +3 -0
- package/dist/onboarding/om-settings.d.ts +25 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -0
- package/dist/onboarding/om-settings.js +47 -0
- package/dist/onboarding/om-settings.js.map +1 -0
- package/dist/onboarding/packs.d.ts +49 -0
- package/dist/onboarding/packs.d.ts.map +1 -0
- package/dist/onboarding/packs.js +182 -0
- package/dist/onboarding/packs.js.map +1 -0
- package/dist/onboarding/settings.d.ts +438 -0
- package/dist/onboarding/settings.d.ts.map +1 -0
- package/dist/onboarding/settings.js +847 -0
- package/dist/onboarding/settings.js.map +1 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +137 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugin.d.ts +144 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +30 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.d.ts.map +1 -0
- package/dist/plugins/dependencies.js +88 -0
- package/dist/plugins/dependencies.js.map +1 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.d.ts.map +1 -0
- package/dist/plugins/install.js +190 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +19 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +258 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +98 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +456 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +50 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.d.ts.map +1 -0
- package/dist/plugins/package-link.js +61 -0
- package/dist/plugins/package-link.js.map +1 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.d.ts.map +1 -0
- package/dist/plugins/paths.js +25 -0
- package/dist/plugins/paths.js.map +1 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +112 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.d.ts.map +1 -0
- package/dist/plugins/scaffold.js +116 -0
- package/dist/plugins/scaffold.js.map +1 -0
- package/dist/plugins/signal-lane.d.ts +58 -0
- package/dist/plugins/signal-lane.d.ts.map +1 -0
- package/dist/plugins/signal-lane.js +166 -0
- package/dist/plugins/signal-lane.js.map +1 -0
- package/dist/plugins/types.d.ts +81 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +1 -0
- package/dist/process-memory-diagnostics.d.ts +135 -0
- package/dist/process-memory-diagnostics.d.ts.map +1 -0
- package/dist/process-memory-diagnostics.js +500 -0
- package/dist/process-memory-diagnostics.js.map +1 -0
- package/dist/processors/plan-rejection-abort.d.ts +12 -0
- package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
- package/dist/processors/plan-rejection-abort.js +54 -0
- package/dist/processors/plan-rejection-abort.js.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.js +153 -0
- package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.js +102 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/claude-max.d.ts +65 -0
- package/dist/providers/claude-max.d.ts.map +1 -0
- package/dist/providers/claude-max.js +252 -0
- package/dist/providers/claude-max.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +266 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/kimi-coding.d.ts +15 -0
- package/dist/providers/kimi-coding.d.ts.map +1 -0
- package/dist/providers/kimi-coding.js +69 -0
- package/dist/providers/kimi-coding.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +73 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +306 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.d.ts.map +1 -0
- package/dist/providers/xai.js +71 -0
- package/dist/providers/xai.js.map +1 -0
- package/dist/schema.d.ts +200 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +92 -0
- package/dist/schema.js.map +1 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.d.ts.map +1 -0
- package/dist/theme-palette.js +21 -0
- package/dist/theme-palette.js.map +1 -0
- package/dist/thinking.d.ts +33 -0
- package/dist/thinking.d.ts.map +1 -0
- package/dist/thinking.js +58 -0
- package/dist/thinking.js.map +1 -0
- package/dist/tool-names.d.ts +73 -0
- package/dist/tool-names.d.ts.map +1 -0
- package/dist/tool-names.js +52 -0
- package/dist/tool-names.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.d.ts.map +1 -0
- package/dist/tools/request-sandbox-access.js +79 -0
- package/dist/tools/request-sandbox-access.js.map +1 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +32 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +114 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +155 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/workflows/create-workflow.d.ts +7 -0
- package/dist/tools/workflows/create-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/create-workflow.js +81 -0
- package/dist/tools/workflows/create-workflow.js.map +1 -0
- package/dist/tools/workflows/delete-workflow.d.ts +7 -0
- package/dist/tools/workflows/delete-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/delete-workflow.js +21 -0
- package/dist/tools/workflows/delete-workflow.js.map +1 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts +7 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts.map +1 -0
- package/dist/tools/workflows/ephemeral-memory.js +45 -0
- package/dist/tools/workflows/ephemeral-memory.js.map +1 -0
- package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
- package/dist/tools/workflows/extract-json-schema.d.ts.map +1 -0
- package/dist/tools/workflows/extract-json-schema.js +22 -0
- package/dist/tools/workflows/extract-json-schema.js.map +1 -0
- package/dist/tools/workflows/get-workflow.d.ts +11 -0
- package/dist/tools/workflows/get-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/get-workflow.js +34 -0
- package/dist/tools/workflows/get-workflow.js.map +1 -0
- package/dist/tools/workflows/list-available-agents.d.ts +8 -0
- package/dist/tools/workflows/list-available-agents.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-agents.js +32 -0
- package/dist/tools/workflows/list-available-agents.js.map +1 -0
- package/dist/tools/workflows/list-available-tools.d.ts +9 -0
- package/dist/tools/workflows/list-available-tools.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-tools.js +40 -0
- package/dist/tools/workflows/list-available-tools.js.map +1 -0
- package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-available-workflows.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-workflows.js +32 -0
- package/dist/tools/workflows/list-available-workflows.js.map +1 -0
- package/dist/tools/workflows/list-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-workflows.d.ts.map +1 -0
- package/dist/tools/workflows/list-workflows.js +33 -0
- package/dist/tools/workflows/list-workflows.js.map +1 -0
- package/dist/tools/workflows/run-workflow.d.ts +9 -0
- package/dist/tools/workflows/run-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/run-workflow.js +52 -0
- package/dist/tools/workflows/run-workflow.js.map +1 -0
- package/dist/tools/workflows/save-workflow.d.ts +1015 -0
- package/dist/tools/workflows/save-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/save-workflow.js +28 -0
- package/dist/tools/workflows/save-workflow.js.map +1 -0
- package/dist/tools/workflows/tool-ids.d.ts +15 -0
- package/dist/tools/workflows/tool-ids.d.ts.map +1 -0
- package/dist/tools/workflows/tool-ids.js +19 -0
- package/dist/tools/workflows/tool-ids.js.map +1 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.d.ts.map +1 -0
- package/dist/utils/binaries.js +78 -0
- package/dist/utils/binaries.js.map +1 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.d.ts.map +1 -0
- package/dist/utils/debug-log.js +59 -0
- package/dist/utils/debug-log.js.map +1 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +196 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.d.ts.map +1 -0
- package/dist/utils/gateway-sync.js +61 -0
- package/dist/utils/gateway-sync.js.map +1 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.d.ts.map +1 -0
- package/dist/utils/path-security.js +10 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.d.ts.map +1 -0
- package/dist/utils/plan-diff.js +62 -0
- package/dist/utils/plan-diff.js.map +1 -0
- package/dist/utils/plans.d.ts +59 -0
- package/dist/utils/plans.d.ts.map +1 -0
- package/dist/utils/plans.js +117 -0
- package/dist/utils/plans.js.map +1 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +364 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/signals-pubsub.d.ts +41 -0
- package/dist/utils/signals-pubsub.d.ts.map +1 -0
- package/dist/utils/signals-pubsub.js +122 -0
- package/dist/utils/signals-pubsub.js.map +1 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.d.ts.map +1 -0
- package/dist/utils/slash-command-loader.js +142 -0
- package/dist/utils/slash-command-loader.js.map +1 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.d.ts.map +1 -0
- package/dist/utils/slash-command-processor.js +109 -0
- package/dist/utils/slash-command-processor.js.map +1 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.d.ts.map +1 -0
- package/dist/utils/stdin-pipe.js +96 -0
- package/dist/utils/stdin-pipe.js.map +1 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.d.ts.map +1 -0
- package/dist/utils/storage-factory.js +121 -0
- package/dist/utils/storage-factory.js.map +1 -0
- package/dist/utils/storage-maintenance.d.ts +103 -0
- package/dist/utils/storage-maintenance.d.ts.map +1 -0
- package/dist/utils/storage-maintenance.js +274 -0
- package/dist/utils/storage-maintenance.js.map +1 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.d.ts.map +1 -0
- package/dist/utils/thread-lock.js +112 -0
- package/dist/utils/thread-lock.js.map +1 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.d.ts.map +1 -0
- package/dist/utils/token-estimator.js +21 -0
- package/dist/utils/token-estimator.js.map +1 -0
- package/dist/utils/update-check.d.ts +101 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +383 -0
- package/dist/utils/update-check.js.map +1 -0
- package/dist/voice/stt-registry.d.ts +64 -0
- package/dist/voice/stt-registry.d.ts.map +1 -0
- package/dist/voice/stt-registry.js +144 -0
- package/dist/voice/stt-registry.js.map +1 -0
- package/dist/workflows/register-primitives.d.ts +52 -0
- package/dist/workflows/register-primitives.d.ts.map +1 -0
- package/dist/workflows/register-primitives.js +40 -0
- package/dist/workflows/register-primitives.js.map +1 -0
- package/dist/workflows/service.d.ts +64 -0
- package/dist/workflows/service.d.ts.map +1 -0
- package/dist/workflows/service.js +53 -0
- package/dist/workflows/service.js.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SandboxFilesystem
|
|
3
|
+
*
|
|
4
|
+
* A `WorkspaceFilesystem` that stores files inside a remote `MastraSandbox`
|
|
5
|
+
* (e.g. a Railway VM) rather than on the server host. File operations are
|
|
6
|
+
* implemented by shelling out through the sandbox's `executeCommand`, so the
|
|
7
|
+
* agent's file tools and command tools share one VM and one view of the repo.
|
|
8
|
+
*
|
|
9
|
+
* Paths are workspace-relative (`/src/foo.ts`) and resolve under the sandbox
|
|
10
|
+
* working directory (`basePath`). A traversal guard rejects any path that
|
|
11
|
+
* escapes the workdir, mirroring `LocalFilesystem`'s contained mode.
|
|
12
|
+
*
|
|
13
|
+
* Reads/writes use base64 over the wire so binary content survives the shell.
|
|
14
|
+
*/
|
|
15
|
+
import type { CopyOptions, FileContent, FileEntry, FileStat, FilesystemInfo, ListOptions, ProviderStatus, ReadOptions, RemoveOptions, WorkspaceFilesystem, WriteOptions } from '@mastra/core/workspace';
|
|
16
|
+
/** Minimal command result shape we depend on. */
|
|
17
|
+
export interface SandboxCommandResult {
|
|
18
|
+
exitCode: number;
|
|
19
|
+
stdout: string;
|
|
20
|
+
stderr: string;
|
|
21
|
+
}
|
|
22
|
+
/** Minimal sandbox surface the filesystem needs. */
|
|
23
|
+
export interface SandboxExec {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
executeCommand(command: string, args?: string[], options?: {
|
|
26
|
+
timeout?: number;
|
|
27
|
+
}): Promise<SandboxCommandResult>;
|
|
28
|
+
}
|
|
29
|
+
export interface SandboxFilesystemOptions {
|
|
30
|
+
/** Live sandbox to run commands in. */
|
|
31
|
+
sandbox: SandboxExec;
|
|
32
|
+
/**
|
|
33
|
+
* Absolute path inside the sandbox that is the workspace root — or a lazy
|
|
34
|
+
* resolver for it. The resolver form exists for sandboxes whose workspace
|
|
35
|
+
* root is only knowable once the VM is running (e.g. `$HOME/<repo>` under
|
|
36
|
+
* a provider-chosen home dir): it is awaited on the first file operation
|
|
37
|
+
* (which itself may lazily start the VM) and the result is memoized.
|
|
38
|
+
*/
|
|
39
|
+
workdir: string | (() => Promise<string> | string);
|
|
40
|
+
/** Optional stable id; defaults to a sandbox-derived id. */
|
|
41
|
+
id?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare class SandboxFilesystem implements WorkspaceFilesystem {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly name = "SandboxFilesystem";
|
|
46
|
+
readonly provider = "sandbox";
|
|
47
|
+
status: ProviderStatus;
|
|
48
|
+
private readonly sandbox;
|
|
49
|
+
private readonly workdirSource;
|
|
50
|
+
private resolvedBase?;
|
|
51
|
+
private resolvingBase?;
|
|
52
|
+
constructor(options: SandboxFilesystemOptions);
|
|
53
|
+
/** The resolved workspace root; empty until a lazy workdir first resolves. */
|
|
54
|
+
get basePath(): string;
|
|
55
|
+
/** Await (and memoize) the workspace root, resolving a lazy workdir once. */
|
|
56
|
+
private base;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve a workspace path to an absolute path inside the sandbox, enforcing
|
|
59
|
+
* that it stays within the workdir. Awaits the workspace root first, which
|
|
60
|
+
* for a lazy workdir may start the VM.
|
|
61
|
+
*/
|
|
62
|
+
private resolveAsync;
|
|
63
|
+
/**
|
|
64
|
+
* Resolve a workspace path against a known base, enforcing that it stays
|
|
65
|
+
* within the workdir.
|
|
66
|
+
*
|
|
67
|
+
* Accepts both workspace-relative paths (`src/foo.ts`, `/src/foo.ts`) and
|
|
68
|
+
* absolute sandbox paths that already live under the workdir — the agent's
|
|
69
|
+
* prompt advertises the workdir as its working directory, so tools are
|
|
70
|
+
* routinely called with fully-qualified paths like `<workdir>/src/foo.ts`.
|
|
71
|
+
*/
|
|
72
|
+
private resolveAgainst;
|
|
73
|
+
resolveAbsolutePath(inputPath: string): string | undefined;
|
|
74
|
+
private exec;
|
|
75
|
+
/**
|
|
76
|
+
* Lexical guard catches `..` traversal, but a symlink inside the workdir can
|
|
77
|
+
* still point outside it. After resolving a path that refers to an existing
|
|
78
|
+
* entry, verify its realpath is still contained in the workdir.
|
|
79
|
+
*
|
|
80
|
+
* Canonicalization tries `realpath`, then `readlink -f` (GNU/busybox), then
|
|
81
|
+
* `cd && pwd -P` for directories — covering GNU hosts, macOS/BSD, and
|
|
82
|
+
* busybox. If the path exists but cannot be canonicalized we fail CLOSED:
|
|
83
|
+
* returning without a check would let a symlink bypass containment.
|
|
84
|
+
*/
|
|
85
|
+
private assertContainedRealpath;
|
|
86
|
+
/**
|
|
87
|
+
* Guard for write destinations. The lexical guard catches `..`, but a symlink
|
|
88
|
+
* inside the workdir can redirect a write outside it. For an existing target
|
|
89
|
+
* we check its realpath; for a not-yet-existing target we check the realpath
|
|
90
|
+
* of its nearest existing ancestor directory, since a symlinked parent is the
|
|
91
|
+
* escape vector (e.g. `link -> /etc` then writing `link/passwd`).
|
|
92
|
+
*/
|
|
93
|
+
private assertContainedDest;
|
|
94
|
+
private execOk;
|
|
95
|
+
readFile(path: string, options?: ReadOptions): Promise<string | Buffer>;
|
|
96
|
+
writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void>;
|
|
97
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
98
|
+
deleteFile(path: string, options?: RemoveOptions): Promise<void>;
|
|
99
|
+
copyFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
100
|
+
moveFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
101
|
+
mkdir(path: string, options?: {
|
|
102
|
+
recursive?: boolean;
|
|
103
|
+
}): Promise<void>;
|
|
104
|
+
rmdir(path: string, options?: RemoveOptions): Promise<void>;
|
|
105
|
+
readdir(path: string, options?: ListOptions): Promise<FileEntry[]>;
|
|
106
|
+
private parseListOutput;
|
|
107
|
+
private parseFindOutput;
|
|
108
|
+
private matchesExtension;
|
|
109
|
+
exists(path: string): Promise<boolean>;
|
|
110
|
+
stat(path: string): Promise<FileStat>;
|
|
111
|
+
init(): Promise<void>;
|
|
112
|
+
destroy(): Promise<void>;
|
|
113
|
+
isReady(): Promise<boolean>;
|
|
114
|
+
getInfo(): FilesystemInfo;
|
|
115
|
+
getInstructions(): string;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=sandbox-filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-filesystem.d.ts","sourceRoot":"","sources":["../../src/agents/sandbox-filesystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,cAAc,EACd,WAAW,EACX,cAAc,EACd,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,YAAY,EACb,MAAM,wBAAwB,CAAC;AAWhC,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACjH;AAED,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,OAAO,EAAE,WAAW,CAAC;IACrB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IACnD,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAmBD,qBAAa,iBAAkB,YAAW,mBAAmB;IAC3D,QAAQ,CAAC,EAAE,EAAE,MAA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AO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCzE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB3D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAuBxE,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,gBAAgB;IAQlB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMtC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IA+BrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAKjC,OAAO,IAAI,cAAc;IAUzB,eAAe,IAAI,MAAM;CAG1B"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { posix } from "path";
|
|
2
|
+
import { FileExistsError, FileNotFoundError, IsDirectoryError } from "@mastra/core/workspace";
|
|
3
|
+
//#region src/agents/sandbox-filesystem.ts
|
|
4
|
+
/**
|
|
5
|
+
* SandboxFilesystem
|
|
6
|
+
*
|
|
7
|
+
* A `WorkspaceFilesystem` that stores files inside a remote `MastraSandbox`
|
|
8
|
+
* (e.g. a Railway VM) rather than on the server host. File operations are
|
|
9
|
+
* implemented by shelling out through the sandbox's `executeCommand`, so the
|
|
10
|
+
* agent's file tools and command tools share one VM and one view of the repo.
|
|
11
|
+
*
|
|
12
|
+
* Paths are workspace-relative (`/src/foo.ts`) and resolve under the sandbox
|
|
13
|
+
* working directory (`basePath`). A traversal guard rejects any path that
|
|
14
|
+
* escapes the workdir, mirroring `LocalFilesystem`'s contained mode.
|
|
15
|
+
*
|
|
16
|
+
* Reads/writes use base64 over the wire so binary content survives the shell.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Sentinel exit codes used by guard clauses that run before the real command,
|
|
20
|
+
* so shell failures can be mapped to typed filesystem errors.
|
|
21
|
+
*/
|
|
22
|
+
const EXIT_NOT_FOUND = 20;
|
|
23
|
+
const EXIT_IS_DIRECTORY = 21;
|
|
24
|
+
const EXIT_EXISTS = 22;
|
|
25
|
+
/** Default per-command deadline so a hung sandbox can't block file tools forever. */
|
|
26
|
+
const COMMAND_TIMEOUT_MS = 3e4;
|
|
27
|
+
/** Single-quote a string for safe POSIX shell interpolation. */
|
|
28
|
+
function shellQuote(value) {
|
|
29
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
30
|
+
}
|
|
31
|
+
function isFileContentString(content) {
|
|
32
|
+
return typeof content === "string";
|
|
33
|
+
}
|
|
34
|
+
function toBuffer(content) {
|
|
35
|
+
if (isFileContentString(content)) return Buffer.from(content, "utf8");
|
|
36
|
+
return Buffer.from(content);
|
|
37
|
+
}
|
|
38
|
+
var SandboxFilesystem = class {
|
|
39
|
+
id;
|
|
40
|
+
name = "SandboxFilesystem";
|
|
41
|
+
provider = "sandbox";
|
|
42
|
+
status = "ready";
|
|
43
|
+
sandbox;
|
|
44
|
+
workdirSource;
|
|
45
|
+
resolvedBase;
|
|
46
|
+
resolvingBase;
|
|
47
|
+
constructor(options) {
|
|
48
|
+
this.sandbox = options.sandbox;
|
|
49
|
+
this.workdirSource = options.workdir;
|
|
50
|
+
if (typeof options.workdir === "string") this.resolvedBase = options.workdir;
|
|
51
|
+
this.id = options.id ?? (typeof options.workdir === "string" ? `sandbox-fs:${options.sandbox.id}:${options.workdir}` : `sandbox-fs:${options.sandbox.id}`);
|
|
52
|
+
}
|
|
53
|
+
/** The resolved workspace root; empty until a lazy workdir first resolves. */
|
|
54
|
+
get basePath() {
|
|
55
|
+
return this.resolvedBase ?? "";
|
|
56
|
+
}
|
|
57
|
+
/** Await (and memoize) the workspace root, resolving a lazy workdir once. */
|
|
58
|
+
async base() {
|
|
59
|
+
if (this.resolvedBase) return this.resolvedBase;
|
|
60
|
+
const source = this.workdirSource;
|
|
61
|
+
if (typeof source === "string") return this.resolvedBase = source;
|
|
62
|
+
this.resolvingBase ??= Promise.resolve().then(source).then((resolved) => {
|
|
63
|
+
if (!resolved) throw new Error("Sandbox workspace root resolution returned an empty path");
|
|
64
|
+
return this.resolvedBase = resolved;
|
|
65
|
+
}).finally(() => {
|
|
66
|
+
this.resolvingBase = void 0;
|
|
67
|
+
});
|
|
68
|
+
return this.resolvingBase;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Resolve a workspace path to an absolute path inside the sandbox, enforcing
|
|
72
|
+
* that it stays within the workdir. Awaits the workspace root first, which
|
|
73
|
+
* for a lazy workdir may start the VM.
|
|
74
|
+
*/
|
|
75
|
+
async resolveAsync(inputPath) {
|
|
76
|
+
return this.resolveAgainst(await this.base(), inputPath);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Resolve a workspace path against a known base, enforcing that it stays
|
|
80
|
+
* within the workdir.
|
|
81
|
+
*
|
|
82
|
+
* Accepts both workspace-relative paths (`src/foo.ts`, `/src/foo.ts`) and
|
|
83
|
+
* absolute sandbox paths that already live under the workdir — the agent's
|
|
84
|
+
* prompt advertises the workdir as its working directory, so tools are
|
|
85
|
+
* routinely called with fully-qualified paths like `<workdir>/src/foo.ts`.
|
|
86
|
+
*/
|
|
87
|
+
resolveAgainst(basePath, inputPath) {
|
|
88
|
+
const base = posix.normalize(basePath);
|
|
89
|
+
const normalizedInput = posix.normalize(inputPath);
|
|
90
|
+
const rel = normalizedInput === base ? "" : normalizedInput.startsWith(`${base}/`) ? normalizedInput.slice(base.length + 1) : inputPath.startsWith("/") ? inputPath.slice(1) : inputPath;
|
|
91
|
+
const resolved = posix.normalize(posix.join(base, rel));
|
|
92
|
+
if (resolved !== base && !resolved.startsWith(`${base}/`)) throw new Error(`Path escapes workspace root: ${inputPath}`);
|
|
93
|
+
return resolved;
|
|
94
|
+
}
|
|
95
|
+
resolveAbsolutePath(inputPath) {
|
|
96
|
+
if (!this.resolvedBase) return void 0;
|
|
97
|
+
return this.resolveAgainst(this.resolvedBase, inputPath);
|
|
98
|
+
}
|
|
99
|
+
async exec(script) {
|
|
100
|
+
return this.sandbox.executeCommand("sh", ["-c", script], { timeout: COMMAND_TIMEOUT_MS });
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Lexical guard catches `..` traversal, but a symlink inside the workdir can
|
|
104
|
+
* still point outside it. After resolving a path that refers to an existing
|
|
105
|
+
* entry, verify its realpath is still contained in the workdir.
|
|
106
|
+
*
|
|
107
|
+
* Canonicalization tries `realpath`, then `readlink -f` (GNU/busybox), then
|
|
108
|
+
* `cd && pwd -P` for directories — covering GNU hosts, macOS/BSD, and
|
|
109
|
+
* busybox. If the path exists but cannot be canonicalized we fail CLOSED:
|
|
110
|
+
* returning without a check would let a symlink bypass containment.
|
|
111
|
+
*/
|
|
112
|
+
async assertContainedRealpath(abs, inputPath) {
|
|
113
|
+
const result = await this.exec([
|
|
114
|
+
`p=${shellQuote(abs)}`,
|
|
115
|
+
`if [ ! -e "$p" ] && [ ! -L "$p" ]; then exit ${EXIT_NOT_FOUND}; fi`,
|
|
116
|
+
`root=$(cd ${shellQuote(this.basePath)} 2>/dev/null && pwd -P)`,
|
|
117
|
+
`[ -n "$root" ] || exit 1`,
|
|
118
|
+
`rp=$(realpath "$p" 2>/dev/null) || rp=$(readlink -f "$p" 2>/dev/null) || { [ -d "$p" ] && rp=$(cd "$p" 2>/dev/null && pwd -P); }`,
|
|
119
|
+
`[ -n "$rp" ] || exit 1`,
|
|
120
|
+
`printf '%s\\n%s' "$root" "$rp"`
|
|
121
|
+
].join("\n"));
|
|
122
|
+
if (result.exitCode === EXIT_NOT_FOUND) return;
|
|
123
|
+
const [root, real] = result.stdout.split("\n").map((s) => s.trim());
|
|
124
|
+
if (result.exitCode !== 0 || !root || !real) throw new Error(`Unable to verify path stays within workspace root: ${inputPath}`);
|
|
125
|
+
if (real !== root && !real.startsWith(`${root}/`)) throw new Error(`Path escapes workspace root (symlink): ${inputPath}`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Guard for write destinations. The lexical guard catches `..`, but a symlink
|
|
129
|
+
* inside the workdir can redirect a write outside it. For an existing target
|
|
130
|
+
* we check its realpath; for a not-yet-existing target we check the realpath
|
|
131
|
+
* of its nearest existing ancestor directory, since a symlinked parent is the
|
|
132
|
+
* escape vector (e.g. `link -> /etc` then writing `link/passwd`).
|
|
133
|
+
*/
|
|
134
|
+
async assertContainedDest(abs, inputPath) {
|
|
135
|
+
await this.assertContainedRealpath(abs, inputPath);
|
|
136
|
+
const parent = posix.dirname(abs);
|
|
137
|
+
if (parent && parent !== abs) await this.assertContainedRealpath(parent, inputPath);
|
|
138
|
+
}
|
|
139
|
+
async execOk(script, context) {
|
|
140
|
+
const result = await this.exec(script);
|
|
141
|
+
if (result.exitCode !== 0) throw new Error(`${context} failed (exit ${result.exitCode}): ${result.stderr.trim() || result.stdout.trim()}`);
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
async readFile(path, options) {
|
|
145
|
+
const abs = await this.resolveAsync(path);
|
|
146
|
+
await this.assertContainedRealpath(abs, path);
|
|
147
|
+
const result = await this.exec(`if [ -d ${shellQuote(abs)} ]; then exit ${EXIT_IS_DIRECTORY}; elif [ ! -e ${shellQuote(abs)} ]; then exit ${EXIT_NOT_FOUND}; fi; base64 < ${shellQuote(abs)}`);
|
|
148
|
+
if (result.exitCode === EXIT_IS_DIRECTORY) throw new IsDirectoryError(path);
|
|
149
|
+
if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(path);
|
|
150
|
+
if (result.exitCode !== 0) throw new Error(`readFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
151
|
+
const buffer = Buffer.from(result.stdout.replace(/\s/g, ""), "base64");
|
|
152
|
+
if (options?.encoding) return buffer.toString(options.encoding);
|
|
153
|
+
return buffer;
|
|
154
|
+
}
|
|
155
|
+
async writeFile(path, content, options) {
|
|
156
|
+
const abs = await this.resolveAsync(path);
|
|
157
|
+
await this.assertContainedDest(abs, path);
|
|
158
|
+
const b64 = toBuffer(content).toString("base64");
|
|
159
|
+
const dir = posix.dirname(abs);
|
|
160
|
+
const mkdir = options?.recursive === false ? "" : `mkdir -p ${shellQuote(dir)} && `;
|
|
161
|
+
if (options?.overwrite === false) {
|
|
162
|
+
const result = await this.exec(`${mkdir}{ (set -C; printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(abs)}) 2>/dev/null || { [ -e ${shellQuote(abs)} ] && exit ${EXIT_EXISTS} || exit 1; }; }`);
|
|
163
|
+
if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(path);
|
|
164
|
+
if (result.exitCode !== 0) throw new Error(`writeFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
await this.execOk(`${mkdir}printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(abs)}`, `writeFile ${path}`);
|
|
168
|
+
}
|
|
169
|
+
async appendFile(path, content) {
|
|
170
|
+
const abs = await this.resolveAsync(path);
|
|
171
|
+
await this.assertContainedDest(abs, path);
|
|
172
|
+
const b64 = toBuffer(content).toString("base64");
|
|
173
|
+
await this.execOk(`mkdir -p ${shellQuote(posix.dirname(abs))} && printf %s ${shellQuote(b64)} | base64 -d >> ${shellQuote(abs)}`, `appendFile ${path}`);
|
|
174
|
+
}
|
|
175
|
+
async deleteFile(path, options) {
|
|
176
|
+
const abs = await this.resolveAsync(path);
|
|
177
|
+
await this.assertContainedRealpath(posix.dirname(abs), path);
|
|
178
|
+
if (options?.force) {
|
|
179
|
+
await this.execOk(`rm -f ${shellQuote(abs)}`, `deleteFile ${path}`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const result = await this.exec(`if [ ! -e ${shellQuote(abs)} ]; then exit ${EXIT_NOT_FOUND}; fi; rm ${shellQuote(abs)}`);
|
|
183
|
+
if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(path);
|
|
184
|
+
if (result.exitCode !== 0) throw new Error(`deleteFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
185
|
+
}
|
|
186
|
+
async copyFile(src, dest, options) {
|
|
187
|
+
const srcAbs = await this.resolveAsync(src);
|
|
188
|
+
const destAbs = await this.resolveAsync(dest);
|
|
189
|
+
await this.assertContainedRealpath(srcAbs, src);
|
|
190
|
+
await this.assertContainedDest(destAbs, dest);
|
|
191
|
+
const recursive = options?.recursive ? "-r " : "";
|
|
192
|
+
if (options?.overwrite === false) {
|
|
193
|
+
const result = await this.exec([
|
|
194
|
+
`src=${shellQuote(srcAbs)}`,
|
|
195
|
+
`dest=${shellQuote(destAbs)}`,
|
|
196
|
+
`if [ ! -e "$src" ] && [ ! -L "$src" ]; then exit ${EXIT_NOT_FOUND}; fi`,
|
|
197
|
+
`mkdir -p ${shellQuote(posix.dirname(destAbs))} || exit 1`,
|
|
198
|
+
`if [ -d "$src" ]; then`,
|
|
199
|
+
` mkdir "$dest" 2>/dev/null || exit ${EXIT_EXISTS}`,
|
|
200
|
+
` cp -R "$src"/. "$dest"/`,
|
|
201
|
+
`else`,
|
|
202
|
+
` tmp="$dest.__cptmp$$"`,
|
|
203
|
+
` cp "$src" "$tmp" || exit 1`,
|
|
204
|
+
` ln "$tmp" "$dest" 2>/dev/null || { rm -f "$tmp"; [ -e "$dest" ] && exit ${EXIT_EXISTS} || exit 1; }`,
|
|
205
|
+
` rm -f "$tmp"`,
|
|
206
|
+
`fi`
|
|
207
|
+
].join("\n"));
|
|
208
|
+
if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);
|
|
209
|
+
if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(dest);
|
|
210
|
+
if (result.exitCode !== 0) throw new Error(`copyFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const result = await this.exec(`if [ ! -e ${shellQuote(srcAbs)} ]; then exit ${EXIT_NOT_FOUND}; fi; mkdir -p ${shellQuote(posix.dirname(destAbs))} && cp ${recursive}${shellQuote(srcAbs)} ${shellQuote(destAbs)}`);
|
|
214
|
+
if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);
|
|
215
|
+
if (result.exitCode !== 0) throw new Error(`copyFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
216
|
+
}
|
|
217
|
+
async moveFile(src, dest, options) {
|
|
218
|
+
const srcAbs = await this.resolveAsync(src);
|
|
219
|
+
const destAbs = await this.resolveAsync(dest);
|
|
220
|
+
await this.assertContainedRealpath(srcAbs, src);
|
|
221
|
+
await this.assertContainedDest(destAbs, dest);
|
|
222
|
+
if (options?.overwrite === false) {
|
|
223
|
+
const result = await this.exec([
|
|
224
|
+
`src=${shellQuote(srcAbs)}`,
|
|
225
|
+
`dest=${shellQuote(destAbs)}`,
|
|
226
|
+
`if [ ! -e "$src" ] && [ ! -L "$src" ]; then exit ${EXIT_NOT_FOUND}; fi`,
|
|
227
|
+
`mkdir -p ${shellQuote(posix.dirname(destAbs))} || exit 1`,
|
|
228
|
+
`mv -n "$src" "$dest" 2>/dev/null || exit 1`,
|
|
229
|
+
`if [ -e "$src" ] || [ -L "$src" ]; then exit ${EXIT_EXISTS}; fi`
|
|
230
|
+
].join("\n"));
|
|
231
|
+
if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);
|
|
232
|
+
if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(dest);
|
|
233
|
+
if (result.exitCode !== 0) throw new Error(`moveFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const result = await this.exec(`if [ ! -e ${shellQuote(srcAbs)} ]; then exit ${EXIT_NOT_FOUND}; fi; mkdir -p ${shellQuote(posix.dirname(destAbs))} && mv ${shellQuote(srcAbs)} ${shellQuote(destAbs)}`);
|
|
237
|
+
if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);
|
|
238
|
+
if (result.exitCode !== 0) throw new Error(`moveFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
239
|
+
}
|
|
240
|
+
async mkdir(path, options) {
|
|
241
|
+
const abs = await this.resolveAsync(path);
|
|
242
|
+
await this.assertContainedDest(abs, path);
|
|
243
|
+
const flag = options?.recursive === false ? "" : "-p ";
|
|
244
|
+
await this.execOk(`mkdir ${flag}${shellQuote(abs)}`, `mkdir ${path}`);
|
|
245
|
+
}
|
|
246
|
+
async rmdir(path, options) {
|
|
247
|
+
const abs = await this.resolveAsync(path);
|
|
248
|
+
await this.assertContainedRealpath(posix.dirname(abs), path);
|
|
249
|
+
if (options?.recursive) {
|
|
250
|
+
const force = options?.force ? "-f " : "";
|
|
251
|
+
await this.execOk(`rm -r ${force}${shellQuote(abs)}`, `rmdir ${path}`);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if ((await this.exec(`rmdir ${shellQuote(abs)}`)).exitCode !== 0 && !options?.force) throw new Error(`Directory not empty or not found: ${path}`);
|
|
255
|
+
}
|
|
256
|
+
async readdir(path, options) {
|
|
257
|
+
const abs = await this.resolveAsync(path);
|
|
258
|
+
await this.assertContainedRealpath(abs, path);
|
|
259
|
+
if (options?.recursive) {
|
|
260
|
+
const result = await this.exec(`test -d ${shellQuote(abs)} && find ${shellQuote(abs)} -mindepth 1 ${options.maxDepth ? `-maxdepth ${Number(options.maxDepth)} ` : ""}2>/dev/null | while IFS= read -r f; do if [ -d "$f" ]; then printf 'd\\t%s\\n' "$f"; else printf 'f\\t%s\\n' "$f"; fi; done`);
|
|
261
|
+
if (result.exitCode !== 0) throw new Error(`Directory not found: ${path}`);
|
|
262
|
+
return this.parseFindOutput(result.stdout, abs, options);
|
|
263
|
+
}
|
|
264
|
+
const result = await this.exec(`cd ${shellQuote(abs)} 2>/dev/null && for f in * .[!.]*; do [ -e "$f" ] || continue; if [ -d "$f" ]; then printf 'd\\t%s\\n' "$f"; else printf 'f\\t%s\\n' "$f"; fi; done`);
|
|
265
|
+
if (result.exitCode !== 0) throw new Error(`Directory not found: ${path}`);
|
|
266
|
+
return this.parseListOutput(result.stdout, options);
|
|
267
|
+
}
|
|
268
|
+
parseListOutput(stdout, options) {
|
|
269
|
+
const entries = [];
|
|
270
|
+
for (const line of stdout.split("\n")) {
|
|
271
|
+
if (!line) continue;
|
|
272
|
+
const tab = line.indexOf(" ");
|
|
273
|
+
if (tab < 0) continue;
|
|
274
|
+
const type = line.slice(0, tab) === "d" ? "directory" : "file";
|
|
275
|
+
const name = line.slice(tab + 1);
|
|
276
|
+
if (!name || name === "." || name === "..") continue;
|
|
277
|
+
if (type === "file" && !this.matchesExtension(name, options?.extension)) continue;
|
|
278
|
+
entries.push({
|
|
279
|
+
name,
|
|
280
|
+
type
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return entries;
|
|
284
|
+
}
|
|
285
|
+
parseFindOutput(stdout, base, options) {
|
|
286
|
+
const entries = [];
|
|
287
|
+
for (const line of stdout.split("\n")) {
|
|
288
|
+
if (!line) continue;
|
|
289
|
+
const tab = line.indexOf(" ");
|
|
290
|
+
if (tab < 0) continue;
|
|
291
|
+
const type = line.slice(0, tab) === "d" ? "directory" : "file";
|
|
292
|
+
const fullPath = line.slice(tab + 1);
|
|
293
|
+
const name = posix.relative(base, fullPath);
|
|
294
|
+
if (!name) continue;
|
|
295
|
+
if (type === "file" && !this.matchesExtension(name, options?.extension)) continue;
|
|
296
|
+
entries.push({
|
|
297
|
+
name,
|
|
298
|
+
type
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return entries;
|
|
302
|
+
}
|
|
303
|
+
matchesExtension(name, extension) {
|
|
304
|
+
if (!extension) return true;
|
|
305
|
+
return (Array.isArray(extension) ? extension : [extension]).some((ext) => name.endsWith(ext));
|
|
306
|
+
}
|
|
307
|
+
async exists(path) {
|
|
308
|
+
const abs = await this.resolveAsync(path);
|
|
309
|
+
return (await this.exec(`test -e ${shellQuote(abs)}`)).exitCode === 0;
|
|
310
|
+
}
|
|
311
|
+
async stat(path) {
|
|
312
|
+
const abs = await this.resolveAsync(path);
|
|
313
|
+
await this.assertContainedRealpath(abs, path);
|
|
314
|
+
const result = await this.exec(`stat -c '%F|%s|%Y|%W' ${shellQuote(abs)} 2>/dev/null || stat -f '%HT|%z|%m|%B' ${shellQuote(abs)}`);
|
|
315
|
+
if (result.exitCode !== 0) throw new FileNotFoundError(path);
|
|
316
|
+
const [kind, sizeStr, mtimeStr, ctimeStr] = result.stdout.trim().split("|");
|
|
317
|
+
const type = kind && kind.toLowerCase().includes("directory") ? "directory" : "file";
|
|
318
|
+
const size = Number(sizeStr) || 0;
|
|
319
|
+
const mtime = Number(mtimeStr) || 0;
|
|
320
|
+
const ctime = Number(ctimeStr);
|
|
321
|
+
return {
|
|
322
|
+
name: posix.basename(abs),
|
|
323
|
+
path: `/${posix.relative(this.basePath, abs)}`,
|
|
324
|
+
type,
|
|
325
|
+
size: type === "directory" ? 0 : size,
|
|
326
|
+
modifiedAt: /* @__PURE__ */ new Date(mtime * 1e3),
|
|
327
|
+
createdAt: /* @__PURE__ */ new Date((ctime > 0 ? ctime : mtime) * 1e3)
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
async init() {
|
|
331
|
+
await this.execOk(`mkdir -p ${shellQuote(await this.base())}`, "init workdir");
|
|
332
|
+
}
|
|
333
|
+
async destroy() {}
|
|
334
|
+
async isReady() {
|
|
335
|
+
return (await this.exec(`test -d ${shellQuote(await this.base())}`)).exitCode === 0;
|
|
336
|
+
}
|
|
337
|
+
getInfo() {
|
|
338
|
+
return {
|
|
339
|
+
id: this.id,
|
|
340
|
+
name: this.name,
|
|
341
|
+
provider: this.provider,
|
|
342
|
+
status: this.status,
|
|
343
|
+
metadata: {
|
|
344
|
+
basePath: this.basePath,
|
|
345
|
+
sandboxId: this.sandbox.id
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
getInstructions() {
|
|
350
|
+
return `Files are stored in a remote sandbox at ${this.basePath}. Use absolute workspace paths like /src/index.ts. All reads, writes and commands run inside the same sandbox.`;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
//#endregion
|
|
354
|
+
export { SandboxFilesystem };
|
|
355
|
+
|
|
356
|
+
//# sourceMappingURL=sandbox-filesystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-filesystem.js","names":["posixPath"],"sources":["../../src/agents/sandbox-filesystem.ts"],"sourcesContent":["/**\n * SandboxFilesystem\n *\n * A `WorkspaceFilesystem` that stores files inside a remote `MastraSandbox`\n * (e.g. a Railway VM) rather than on the server host. File operations are\n * implemented by shelling out through the sandbox's `executeCommand`, so the\n * agent's file tools and command tools share one VM and one view of the repo.\n *\n * Paths are workspace-relative (`/src/foo.ts`) and resolve under the sandbox\n * working directory (`basePath`). A traversal guard rejects any path that\n * escapes the workdir, mirroring `LocalFilesystem`'s contained mode.\n *\n * Reads/writes use base64 over the wire so binary content survives the shell.\n */\n\nimport { posix as posixPath } from 'node:path';\nimport type {\n CopyOptions,\n FileContent,\n FileEntry,\n FileStat,\n FilesystemInfo,\n ListOptions,\n ProviderStatus,\n ReadOptions,\n RemoveOptions,\n WorkspaceFilesystem,\n WriteOptions,\n} from '@mastra/core/workspace';\nimport { FileExistsError, FileNotFoundError, IsDirectoryError } from '@mastra/core/workspace';\n\n/**\n * Sentinel exit codes used by guard clauses that run before the real command,\n * so shell failures can be mapped to typed filesystem errors.\n */\nconst EXIT_NOT_FOUND = 20;\nconst EXIT_IS_DIRECTORY = 21;\nconst EXIT_EXISTS = 22;\n\n/** Minimal command result shape we depend on. */\nexport interface SandboxCommandResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\n/** Minimal sandbox surface the filesystem needs. */\nexport interface SandboxExec {\n readonly id: string;\n executeCommand(command: string, args?: string[], options?: { timeout?: number }): Promise<SandboxCommandResult>;\n}\n\nexport interface SandboxFilesystemOptions {\n /** Live sandbox to run commands in. */\n sandbox: SandboxExec;\n /**\n * Absolute path inside the sandbox that is the workspace root — or a lazy\n * resolver for it. The resolver form exists for sandboxes whose workspace\n * root is only knowable once the VM is running (e.g. `$HOME/<repo>` under\n * a provider-chosen home dir): it is awaited on the first file operation\n * (which itself may lazily start the VM) and the result is memoized.\n */\n workdir: string | (() => Promise<string> | string);\n /** Optional stable id; defaults to a sandbox-derived id. */\n id?: string;\n}\n\n/** Default per-command deadline so a hung sandbox can't block file tools forever. */\nconst COMMAND_TIMEOUT_MS = 30_000;\n\n/** Single-quote a string for safe POSIX shell interpolation. */\nfunction shellQuote(value: string): string {\n return `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\nfunction isFileContentString(content: FileContent): content is string {\n return typeof content === 'string';\n}\n\nfunction toBuffer(content: FileContent): Buffer {\n if (isFileContentString(content)) return Buffer.from(content, 'utf8');\n return Buffer.from(content);\n}\n\nexport class SandboxFilesystem implements WorkspaceFilesystem {\n readonly id: string;\n readonly name = 'SandboxFilesystem';\n readonly provider = 'sandbox';\n status: ProviderStatus = 'ready';\n\n private readonly sandbox: SandboxExec;\n private readonly workdirSource: string | (() => Promise<string> | string);\n private resolvedBase?: string;\n private resolvingBase?: Promise<string>;\n\n constructor(options: SandboxFilesystemOptions) {\n this.sandbox = options.sandbox;\n this.workdirSource = options.workdir;\n if (typeof options.workdir === 'string') this.resolvedBase = options.workdir;\n // Include the workdir when known: one sandbox can back several\n // filesystems rooted at different checkouts, and each needs a distinct\n // id. Lazy-workdir callers pass an explicit id.\n this.id =\n options.id ??\n (typeof options.workdir === 'string'\n ? `sandbox-fs:${options.sandbox.id}:${options.workdir}`\n : `sandbox-fs:${options.sandbox.id}`);\n }\n\n /** The resolved workspace root; empty until a lazy workdir first resolves. */\n get basePath(): string {\n return this.resolvedBase ?? '';\n }\n\n /** Await (and memoize) the workspace root, resolving a lazy workdir once. */\n private async base(): Promise<string> {\n if (this.resolvedBase) return this.resolvedBase;\n const source = this.workdirSource;\n if (typeof source === 'string') return (this.resolvedBase = source);\n this.resolvingBase ??= Promise.resolve()\n .then(source)\n .then(resolved => {\n if (!resolved) throw new Error('Sandbox workspace root resolution returned an empty path');\n return (this.resolvedBase = resolved);\n })\n .finally(() => {\n this.resolvingBase = undefined;\n });\n return this.resolvingBase;\n }\n\n // ── Path handling ──────────────────────────────────────────────────────\n\n /**\n * Resolve a workspace path to an absolute path inside the sandbox, enforcing\n * that it stays within the workdir. Awaits the workspace root first, which\n * for a lazy workdir may start the VM.\n */\n private async resolveAsync(inputPath: string): Promise<string> {\n return this.resolveAgainst(await this.base(), inputPath);\n }\n\n /**\n * Resolve a workspace path against a known base, enforcing that it stays\n * within the workdir.\n *\n * Accepts both workspace-relative paths (`src/foo.ts`, `/src/foo.ts`) and\n * absolute sandbox paths that already live under the workdir — the agent's\n * prompt advertises the workdir as its working directory, so tools are\n * routinely called with fully-qualified paths like `<workdir>/src/foo.ts`.\n */\n private resolveAgainst(basePath: string, inputPath: string): string {\n const base = posixPath.normalize(basePath);\n const normalizedInput = posixPath.normalize(inputPath);\n const rel =\n normalizedInput === base\n ? ''\n : normalizedInput.startsWith(`${base}/`)\n ? normalizedInput.slice(base.length + 1)\n : inputPath.startsWith('/')\n ? inputPath.slice(1)\n : inputPath;\n const resolved = posixPath.normalize(posixPath.join(base, rel));\n if (resolved !== base && !resolved.startsWith(`${base}/`)) {\n throw new Error(`Path escapes workspace root: ${inputPath}`);\n }\n return resolved;\n }\n\n resolveAbsolutePath(inputPath: string): string | undefined {\n // Sync interface: a lazy workdir that has not resolved yet has no\n // absolute form to offer.\n if (!this.resolvedBase) return undefined;\n return this.resolveAgainst(this.resolvedBase, inputPath);\n }\n\n // ── Command helper ─────────────────────────────────────────────────────\n\n private async exec(script: string): Promise<SandboxCommandResult> {\n return this.sandbox.executeCommand('sh', ['-c', script], { timeout: COMMAND_TIMEOUT_MS });\n }\n\n /**\n * Lexical guard catches `..` traversal, but a symlink inside the workdir can\n * still point outside it. After resolving a path that refers to an existing\n * entry, verify its realpath is still contained in the workdir.\n *\n * Canonicalization tries `realpath`, then `readlink -f` (GNU/busybox), then\n * `cd && pwd -P` for directories — covering GNU hosts, macOS/BSD, and\n * busybox. If the path exists but cannot be canonicalized we fail CLOSED:\n * returning without a check would let a symlink bypass containment.\n */\n private async assertContainedRealpath(abs: string, inputPath: string): Promise<void> {\n const result = await this.exec(\n [\n `p=${shellQuote(abs)}`,\n `if [ ! -e \"$p\" ] && [ ! -L \"$p\" ]; then exit ${EXIT_NOT_FOUND}; fi`,\n // The workdir itself may contain symlinked components (/tmp on macOS),\n // so canonicalize it as the comparison root.\n `root=$(cd ${shellQuote(this.basePath)} 2>/dev/null && pwd -P)`,\n `[ -n \"$root\" ] || exit 1`,\n `rp=$(realpath \"$p\" 2>/dev/null) || rp=$(readlink -f \"$p\" 2>/dev/null) || { [ -d \"$p\" ] && rp=$(cd \"$p\" 2>/dev/null && pwd -P); }`,\n `[ -n \"$rp\" ] || exit 1`,\n `printf '%s\\\\n%s' \"$root\" \"$rp\"`,\n ].join('\\n'),\n );\n // Path doesn't exist yet: nothing to canonicalize (writes to a fresh leaf\n // are covered by assertContainedDest checking the parent directory).\n if (result.exitCode === EXIT_NOT_FOUND) return;\n const [root, real] = result.stdout.split('\\n').map(s => s.trim());\n if (result.exitCode !== 0 || !root || !real) {\n throw new Error(`Unable to verify path stays within workspace root: ${inputPath}`);\n }\n if (real !== root && !real.startsWith(`${root}/`)) {\n throw new Error(`Path escapes workspace root (symlink): ${inputPath}`);\n }\n }\n\n /**\n * Guard for write destinations. The lexical guard catches `..`, but a symlink\n * inside the workdir can redirect a write outside it. For an existing target\n * we check its realpath; for a not-yet-existing target we check the realpath\n * of its nearest existing ancestor directory, since a symlinked parent is the\n * escape vector (e.g. `link -> /etc` then writing `link/passwd`).\n */\n private async assertContainedDest(abs: string, inputPath: string): Promise<void> {\n // First check the target itself (covers overwriting an existing symlink).\n await this.assertContainedRealpath(abs, inputPath);\n // Then check the parent directory's realpath; readlink -f resolves the\n // nearest existing ancestor when the leaf doesn't exist yet.\n const parent = posixPath.dirname(abs);\n if (parent && parent !== abs) {\n await this.assertContainedRealpath(parent, inputPath);\n }\n }\n\n private async execOk(script: string, context: string): Promise<SandboxCommandResult> {\n const result = await this.exec(script);\n if (result.exitCode !== 0) {\n throw new Error(`${context} failed (exit ${result.exitCode}): ${result.stderr.trim() || result.stdout.trim()}`);\n }\n return result;\n }\n\n // ── File operations ────────────────────────────────────────────────────\n\n async readFile(path: string, options?: ReadOptions): Promise<string | Buffer> {\n const abs = await this.resolveAsync(path);\n await this.assertContainedRealpath(abs, path);\n // Guard clauses first: redirecting from a directory \"succeeds\" with empty\n // output on some shells, so classify before reading.\n const result = await this.exec(\n `if [ -d ${shellQuote(abs)} ]; then exit ${EXIT_IS_DIRECTORY}; elif [ ! -e ${shellQuote(abs)} ]; then exit ${EXIT_NOT_FOUND}; fi; base64 < ${shellQuote(abs)}`,\n );\n if (result.exitCode === EXIT_IS_DIRECTORY) throw new IsDirectoryError(path);\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(path);\n if (result.exitCode !== 0) {\n throw new Error(`readFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n const buffer = Buffer.from(result.stdout.replace(/\\s/g, ''), 'base64');\n if (options?.encoding) {\n return buffer.toString(options.encoding);\n }\n return buffer;\n }\n\n async writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void> {\n const abs = await this.resolveAsync(path);\n await this.assertContainedDest(abs, path);\n const b64 = toBuffer(content).toString('base64');\n const dir = posixPath.dirname(abs);\n const mkdir = options?.recursive === false ? '' : `mkdir -p ${shellQuote(dir)} && `;\n if (options?.overwrite === false) {\n // `set -C` (noclobber) makes the redirect itself the exclusivity check —\n // no exists() pre-check that could race with a concurrent writer.\n const result = await this.exec(\n `${mkdir}{ (set -C; printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(abs)}) 2>/dev/null || { [ -e ${shellQuote(abs)} ] && exit ${EXIT_EXISTS} || exit 1; }; }`,\n );\n if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(path);\n if (result.exitCode !== 0) {\n throw new Error(`writeFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n return;\n }\n await this.execOk(`${mkdir}printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(abs)}`, `writeFile ${path}`);\n }\n\n async appendFile(path: string, content: FileContent): Promise<void> {\n const abs = await this.resolveAsync(path);\n await this.assertContainedDest(abs, path);\n const b64 = toBuffer(content).toString('base64');\n await this.execOk(\n `mkdir -p ${shellQuote(posixPath.dirname(abs))} && printf %s ${shellQuote(b64)} | base64 -d >> ${shellQuote(abs)}`,\n `appendFile ${path}`,\n );\n }\n\n async deleteFile(path: string, options?: RemoveOptions): Promise<void> {\n const abs = await this.resolveAsync(path);\n // Contain the parent's realpath: deleting `link/file` where `link` points\n // outside the workdir must fail, while deleting a symlink entry itself\n // (which lives inside the workdir) stays allowed.\n await this.assertContainedRealpath(posixPath.dirname(abs), path);\n if (options?.force) {\n // `rm -f` already succeeds for a missing file, but still fails for\n // directories and permission errors — surface those.\n await this.execOk(`rm -f ${shellQuote(abs)}`, `deleteFile ${path}`);\n return;\n }\n const result = await this.exec(\n `if [ ! -e ${shellQuote(abs)} ]; then exit ${EXIT_NOT_FOUND}; fi; rm ${shellQuote(abs)}`,\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(path);\n if (result.exitCode !== 0) {\n throw new Error(`deleteFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n const srcAbs = await this.resolveAsync(src);\n const destAbs = await this.resolveAsync(dest);\n await this.assertContainedRealpath(srcAbs, src);\n await this.assertContainedDest(destAbs, dest);\n const recursive = options?.recursive ? '-r ' : '';\n if (options?.overwrite === false) {\n // Atomic no-clobber: directories claim the destination with an exclusive\n // mkdir; files copy to a temp name then hardlink into place (link(2)\n // fails if the destination exists). No racy exists() pre-check.\n const result = await this.exec(\n [\n `src=${shellQuote(srcAbs)}`,\n `dest=${shellQuote(destAbs)}`,\n `if [ ! -e \"$src\" ] && [ ! -L \"$src\" ]; then exit ${EXIT_NOT_FOUND}; fi`,\n `mkdir -p ${shellQuote(posixPath.dirname(destAbs))} || exit 1`,\n `if [ -d \"$src\" ]; then`,\n ` mkdir \"$dest\" 2>/dev/null || exit ${EXIT_EXISTS}`,\n ` cp -R \"$src\"/. \"$dest\"/`,\n `else`,\n ` tmp=\"$dest.__cptmp$$\"`,\n ` cp \"$src\" \"$tmp\" || exit 1`,\n ` ln \"$tmp\" \"$dest\" 2>/dev/null || { rm -f \"$tmp\"; [ -e \"$dest\" ] && exit ${EXIT_EXISTS} || exit 1; }`,\n ` rm -f \"$tmp\"`,\n `fi`,\n ].join('\\n'),\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);\n if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(dest);\n if (result.exitCode !== 0) {\n throw new Error(`copyFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n return;\n }\n const result = await this.exec(\n `if [ ! -e ${shellQuote(srcAbs)} ]; then exit ${EXIT_NOT_FOUND}; fi; mkdir -p ${shellQuote(posixPath.dirname(destAbs))} && cp ${recursive}${shellQuote(srcAbs)} ${shellQuote(destAbs)}`,\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);\n if (result.exitCode !== 0) {\n throw new Error(`copyFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n const srcAbs = await this.resolveAsync(src);\n const destAbs = await this.resolveAsync(dest);\n await this.assertContainedRealpath(srcAbs, src);\n await this.assertContainedDest(destAbs, dest);\n if (options?.overwrite === false) {\n // `mv -n` exits 0 even when it skips, so detect a skipped move by the\n // source surviving. The no-clobber rename itself is atomic; no racy\n // exists() pre-check.\n const result = await this.exec(\n [\n `src=${shellQuote(srcAbs)}`,\n `dest=${shellQuote(destAbs)}`,\n `if [ ! -e \"$src\" ] && [ ! -L \"$src\" ]; then exit ${EXIT_NOT_FOUND}; fi`,\n `mkdir -p ${shellQuote(posixPath.dirname(destAbs))} || exit 1`,\n `mv -n \"$src\" \"$dest\" 2>/dev/null || exit 1`,\n `if [ -e \"$src\" ] || [ -L \"$src\" ]; then exit ${EXIT_EXISTS}; fi`,\n ].join('\\n'),\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);\n if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(dest);\n if (result.exitCode !== 0) {\n throw new Error(`moveFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n return;\n }\n const result = await this.exec(\n `if [ ! -e ${shellQuote(srcAbs)} ]; then exit ${EXIT_NOT_FOUND}; fi; mkdir -p ${shellQuote(posixPath.dirname(destAbs))} && mv ${shellQuote(srcAbs)} ${shellQuote(destAbs)}`,\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);\n if (result.exitCode !== 0) {\n throw new Error(`moveFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n }\n\n // ── Directory operations ───────────────────────────────────────────────\n\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n const abs = await this.resolveAsync(path);\n await this.assertContainedDest(abs, path);\n const flag = options?.recursive === false ? '' : '-p ';\n await this.execOk(`mkdir ${flag}${shellQuote(abs)}`, `mkdir ${path}`);\n }\n\n async rmdir(path: string, options?: RemoveOptions): Promise<void> {\n const abs = await this.resolveAsync(path);\n // Same parent containment as deleteFile — `rm -r` through a symlinked\n // parent would otherwise delete outside the workspace.\n await this.assertContainedRealpath(posixPath.dirname(abs), path);\n if (options?.recursive) {\n const force = options?.force ? '-f ' : '';\n await this.execOk(`rm -r ${force}${shellQuote(abs)}`, `rmdir ${path}`);\n return;\n }\n const result = await this.exec(`rmdir ${shellQuote(abs)}`);\n if (result.exitCode !== 0 && !options?.force) {\n throw new Error(`Directory not empty or not found: ${path}`);\n }\n }\n\n async readdir(path: string, options?: ListOptions): Promise<FileEntry[]> {\n const abs = await this.resolveAsync(path);\n await this.assertContainedRealpath(abs, path);\n if (options?.recursive) {\n // Recursive listing emitting \"type\\tpath\". `find -printf` is GNU-only\n // (fails on macOS/BSD hosts backing a local sandbox), so classify each\n // entry with a portable shell loop instead.\n const result = await this.exec(\n `test -d ${shellQuote(abs)} && find ${shellQuote(abs)} -mindepth 1 ${options.maxDepth ? `-maxdepth ${Number(options.maxDepth)} ` : ''}2>/dev/null | while IFS= read -r f; do if [ -d \"$f\" ]; then printf 'd\\\\t%s\\\\n' \"$f\"; else printf 'f\\\\t%s\\\\n' \"$f\"; fi; done`,\n );\n if (result.exitCode !== 0) throw new Error(`Directory not found: ${path}`);\n return this.parseFindOutput(result.stdout, abs, options);\n }\n // Non-recursive: list with name + type via a portable loop. Use printf,\n // not echo — bash-as-/bin/sh (macOS local sandboxes) does not expand \\t\n // in echo arguments.\n const result = await this.exec(\n `cd ${shellQuote(abs)} 2>/dev/null && for f in * .[!.]*; do [ -e \"$f\" ] || continue; if [ -d \"$f\" ]; then printf 'd\\\\t%s\\\\n' \"$f\"; else printf 'f\\\\t%s\\\\n' \"$f\"; fi; done`,\n );\n if (result.exitCode !== 0) throw new Error(`Directory not found: ${path}`);\n return this.parseListOutput(result.stdout, options);\n }\n\n private parseListOutput(stdout: string, options?: ListOptions): FileEntry[] {\n const entries: FileEntry[] = [];\n for (const line of stdout.split('\\n')) {\n if (!line) continue;\n const tab = line.indexOf('\\t');\n if (tab < 0) continue;\n const type = line.slice(0, tab) === 'd' ? 'directory' : 'file';\n const name = line.slice(tab + 1);\n if (!name || name === '.' || name === '..') continue;\n if (type === 'file' && !this.matchesExtension(name, options?.extension)) continue;\n entries.push({ name, type });\n }\n return entries;\n }\n\n private parseFindOutput(stdout: string, base: string, options?: ListOptions): FileEntry[] {\n const entries: FileEntry[] = [];\n for (const line of stdout.split('\\n')) {\n if (!line) continue;\n const tab = line.indexOf('\\t');\n if (tab < 0) continue;\n const type = line.slice(0, tab) === 'd' ? 'directory' : 'file';\n const fullPath = line.slice(tab + 1);\n const name = posixPath.relative(base, fullPath);\n if (!name) continue;\n if (type === 'file' && !this.matchesExtension(name, options?.extension)) continue;\n entries.push({ name, type });\n }\n return entries;\n }\n\n private matchesExtension(name: string, extension?: string | string[]): boolean {\n if (!extension) return true;\n const exts = Array.isArray(extension) ? extension : [extension];\n return exts.some(ext => name.endsWith(ext));\n }\n\n // ── Path / metadata ────────────────────────────────────────────────────\n\n async exists(path: string): Promise<boolean> {\n const abs = await this.resolveAsync(path);\n const result = await this.exec(`test -e ${shellQuote(abs)}`);\n return result.exitCode === 0;\n }\n\n async stat(path: string): Promise<FileStat> {\n const abs = await this.resolveAsync(path);\n await this.assertContainedRealpath(abs, path);\n // GNU stat: %F=type, %s=size, %Y=mtime (epoch seconds), %W=birth (or -1).\n // BSD/macOS stat (local sandbox hosts) rejects `-c`; fall back to its\n // `-f` format with the same field order (%HT=type, %z=size, %m=mtime,\n // %B=birth). Delimit with `|` — neither stat interprets `\\t` escapes in\n // its format string.\n const result = await this.exec(\n `stat -c '%F|%s|%Y|%W' ${shellQuote(abs)} 2>/dev/null || stat -f '%HT|%z|%m|%B' ${shellQuote(abs)}`,\n );\n if (result.exitCode !== 0) {\n throw new FileNotFoundError(path);\n }\n const [kind, sizeStr, mtimeStr, ctimeStr] = result.stdout.trim().split('|');\n const type = kind && kind.toLowerCase().includes('directory') ? 'directory' : 'file';\n const size = Number(sizeStr) || 0;\n const mtime = Number(mtimeStr) || 0;\n const ctime = Number(ctimeStr);\n return {\n name: posixPath.basename(abs),\n path: `/${posixPath.relative(this.basePath, abs)}`,\n type,\n size: type === 'directory' ? 0 : size,\n modifiedAt: new Date(mtime * 1000),\n createdAt: new Date((ctime > 0 ? ctime : mtime) * 1000),\n };\n }\n\n // ── Lifecycle ──────────────────────────────────────────────────────────\n\n async init(): Promise<void> {\n await this.execOk(`mkdir -p ${shellQuote(await this.base())}`, 'init workdir');\n }\n\n async destroy(): Promise<void> {\n // The sandbox lifecycle is owned by the caller; nothing to tear down here.\n }\n\n async isReady(): Promise<boolean> {\n const result = await this.exec(`test -d ${shellQuote(await this.base())}`);\n return result.exitCode === 0;\n }\n\n getInfo(): FilesystemInfo {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n metadata: { basePath: this.basePath, sandboxId: this.sandbox.id },\n };\n }\n\n getInstructions(): string {\n return `Files are stored in a remote sandbox at ${this.basePath}. Use absolute workspace paths like /src/index.ts. All reads, writes and commands run inside the same sandbox.`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,cAAc;;AA+BpB,MAAM,qBAAqB;;AAG3B,SAAS,WAAW,OAAuB;CACzC,OAAO,IAAI,MAAM,QAAQ,MAAM,OAAO,EAAE;AAC1C;AAEA,SAAS,oBAAoB,SAAyC;CACpE,OAAO,OAAO,YAAY;AAC5B;AAEA,SAAS,SAAS,SAA8B;CAC9C,IAAI,oBAAoB,OAAO,GAAG,OAAO,OAAO,KAAK,SAAS,MAAM;CACpE,OAAO,OAAO,KAAK,OA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,CAAC,SAAS,WAAW,IAAI,cAAc;EAC9E,MAAM,OAAO,OAAO,OAAO,KAAK;EAChC,MAAM,QAAQ,OAAO,QAAQ,KAAK;EAClC,MAAM,QAAQ,OAAO,QAAQ;EAC7B,OAAO;GACL,MAAMA,MAAU,SAAS,GAAG;GAC5B,MAAM,IAAIA,MAAU,SAAS,KAAK,UAAU,GAAG;GAC/C;GACA,MAAM,SAAS,cAAc,IAAI;GACjC,4BAAY,IAAI,KAAK,QAAQ,GAAI;GACjC,2BAAW,IAAI,MAAM,QAAQ,IAAI,QAAQ,SAAS,GAAI;EACxD;CACF;CAIA,MAAM,OAAsB;EAC1B,MAAM,KAAK,OAAO,YAAY,WAAW,MAAM,KAAK,KAAK,CAAC,KAAK,cAAc;CAC/E;CAEA,MAAM,UAAyB,CAE/B;CAEA,MAAM,UAA4B;EAEhC,QAAO,MADc,KAAK,KAAK,WAAW,WAAW,MAAM,KAAK,KAAK,CAAC,GAAG,EAAA,CAC3D,aAAa;CAC7B;CAEA,UAA0B;EACxB,OAAO;GACL,IAAI,KAAK;GACT,MAAM,KAAK;GACX,UAAU,KAAK;GACf,QAAQ,KAAK;GACb,UAAU;IAAE,UAAU,KAAK;IAAU,WAAW,KAAK,QAAQ;GAAG;EAClE;CACF;CAEA,kBAA0B;EACxB,OAAO,2CAA2C,KAAK,SAAS;CAClE;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,eAAO,MAAM,eAAe,EAAE,uBAoB7B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MC_TOOLS } from "../../tool-names.js";
|
|
2
|
+
//#region src/agents/subagents/execute.ts
|
|
3
|
+
const executeSubagent = {
|
|
4
|
+
id: "execute",
|
|
5
|
+
name: "Execute",
|
|
6
|
+
description: "Implement a focused task, run relevant checks, and report the result.",
|
|
7
|
+
instructions: `You are a focused execution agent. Read relevant files before editing them and follow existing conventions. Stay within the assigned task; do not make unrelated changes. Use workspace tools to edit files and execute commands to verify your changes. Do not delegate work or modify the parent task list. Return a concise summary of changed files, verification results, and any blockers. Never claim checks passed unless you ran them successfully.`,
|
|
8
|
+
allowedWorkspaceTools: [
|
|
9
|
+
MC_TOOLS.VIEW,
|
|
10
|
+
MC_TOOLS.FIND_FILES,
|
|
11
|
+
MC_TOOLS.SEARCH_CONTENT,
|
|
12
|
+
MC_TOOLS.FILE_STAT,
|
|
13
|
+
MC_TOOLS.WRITE_FILE,
|
|
14
|
+
MC_TOOLS.STRING_REPLACE_LSP,
|
|
15
|
+
MC_TOOLS.DELETE_FILE,
|
|
16
|
+
MC_TOOLS.MKDIR,
|
|
17
|
+
MC_TOOLS.AST_SMART_EDIT,
|
|
18
|
+
MC_TOOLS.EXECUTE_COMMAND,
|
|
19
|
+
MC_TOOLS.GET_PROCESS_OUTPUT,
|
|
20
|
+
MC_TOOLS.KILL_PROCESS,
|
|
21
|
+
MC_TOOLS.LSP_INSPECT
|
|
22
|
+
]
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { executeSubagent };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","names":[],"sources":["../../../src/agents/subagents/execute.ts"],"sourcesContent":["import type { AgentControllerSubagent } from '@mastra/core/agent-controller';\nimport { MC_TOOLS } from '../../tool-names.js';\n\nexport const executeSubagent: AgentControllerSubagent = {\n id: 'execute',\n name: 'Execute',\n description: 'Implement a focused task, run relevant checks, and report the result.',\n instructions: `You are a focused execution agent. Read relevant files before editing them and follow existing conventions. Stay within the assigned task; do not make unrelated changes. Use workspace tools to edit files and execute commands to verify your changes. Do not delegate work or modify the parent task list. Return a concise summary of changed files, verification results, and any blockers. Never claim checks passed unless you ran them successfully.`,\n allowedWorkspaceTools: [\n MC_TOOLS.VIEW,\n MC_TOOLS.FIND_FILES,\n MC_TOOLS.SEARCH_CONTENT,\n MC_TOOLS.FILE_STAT,\n MC_TOOLS.WRITE_FILE,\n MC_TOOLS.STRING_REPLACE_LSP,\n MC_TOOLS.DELETE_FILE,\n MC_TOOLS.MKDIR,\n MC_TOOLS.AST_SMART_EDIT,\n MC_TOOLS.EXECUTE_COMMAND,\n MC_TOOLS.GET_PROCESS_OUTPUT,\n MC_TOOLS.KILL_PROCESS,\n MC_TOOLS.LSP_INSPECT,\n ],\n};\n"],"mappings":";;AAGA,MAAa,kBAA2C;CACtD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;CACd,uBAAuB;EACrB,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;CACX;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explore.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/explore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,eAAO,MAAM,eAAe,EAAE,uBAM7B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MC_TOOLS } from "../../tool-names.js";
|
|
2
|
+
//#region src/agents/subagents/explore.ts
|
|
3
|
+
const exploreSubagent = {
|
|
4
|
+
id: "explore",
|
|
5
|
+
name: "Explore",
|
|
6
|
+
description: "Explore the codebase and answer focused questions without modifying files.",
|
|
7
|
+
instructions: `You are a read-only codebase exploration agent. Read relevant files before drawing conclusions. Use view, find_files, search_content, and file_stat to investigate. Do not modify files or run shell commands. Return concise findings with file paths and line numbers, and clearly distinguish verified facts from assumptions.`,
|
|
8
|
+
allowedWorkspaceTools: [
|
|
9
|
+
MC_TOOLS.VIEW,
|
|
10
|
+
MC_TOOLS.FIND_FILES,
|
|
11
|
+
MC_TOOLS.SEARCH_CONTENT,
|
|
12
|
+
MC_TOOLS.FILE_STAT
|
|
13
|
+
]
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { exploreSubagent };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=explore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explore.js","names":[],"sources":["../../../src/agents/subagents/explore.ts"],"sourcesContent":["import type { AgentControllerSubagent } from '@mastra/core/agent-controller';\nimport { MC_TOOLS } from '../../tool-names.js';\n\nexport const exploreSubagent: AgentControllerSubagent = {\n id: 'explore',\n name: 'Explore',\n description: 'Explore the codebase and answer focused questions without modifying files.',\n instructions: `You are a read-only codebase exploration agent. Read relevant files before drawing conclusions. Use view, find_files, search_content, and file_stat to investigate. Do not modify files or run shell commands. Return concise findings with file paths and line numbers, and clearly distinguish verified facts from assumptions.`,\n allowedWorkspaceTools: [MC_TOOLS.VIEW, MC_TOOLS.FIND_FILES, MC_TOOLS.SEARCH_CONTENT, MC_TOOLS.FILE_STAT],\n};\n"],"mappings":";;AAGA,MAAa,kBAA2C;CACtD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;CACd,uBAAuB;EAAC,SAAS;EAAM,SAAS;EAAY,SAAS;EAAgB,SAAS;CAAS;AACzG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,eAAO,MAAM,YAAY,EAAE,uBAM1B,CAAC"}
|