@mastra/code-sdk 0.0.0-agent-tags-alpha-20261125185303
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 +284 -0
- package/dist/acp/agent.d.ts +48 -0
- package/dist/acp/agent.js +414 -0
- package/dist/acp/errors.d.ts +3 -0
- package/dist/acp/errors.js +11 -0
- package/dist/acp/event-mapper.d.ts +28 -0
- package/dist/acp/event-mapper.js +274 -0
- package/dist/acp/index.d.ts +9 -0
- package/dist/acp/index.js +21 -0
- package/dist/acp/runtime.d.ts +5 -0
- package/dist/acp/runtime.js +91 -0
- package/dist/acp/server.d.ts +4 -0
- package/dist/acp/server.js +35 -0
- package/dist/acp/skills.d.ts +6 -0
- package/dist/acp/skills.js +30 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.js +1 -0
- package/dist/agent-connections/messaging-processor.d.ts +17 -0
- package/dist/agent-connections/messaging-processor.js +131 -0
- package/dist/agent-connections/ownership.d.ts +24 -0
- package/dist/agent-connections/ownership.js +96 -0
- package/dist/agent-connections/registry.d.ts +20 -0
- package/dist/agent-connections/registry.js +167 -0
- package/dist/agent-connections/session-advertisement.d.ts +27 -0
- package/dist/agent-connections/session-advertisement.js +86 -0
- package/dist/agent-connections/signal-provider.d.ts +141 -0
- package/dist/agent-connections/signal-provider.js +35 -0
- package/dist/agent-connections/state-processor.d.ts +23 -0
- package/dist/agent-connections/state-processor.js +270 -0
- package/dist/agent-connections/thread-state.d.ts +41 -0
- package/dist/agent-connections/thread-state.js +157 -0
- package/dist/agent-connections/tools.d.ts +133 -0
- package/dist/agent-connections/tools.js +616 -0
- package/dist/agent-connections/types.d.ts +99 -0
- package/dist/agent-connections/types.js +4 -0
- package/dist/agent-connections/untrusted-text.d.ts +5 -0
- package/dist/agent-connections/untrusted-text.js +19 -0
- package/dist/agents/background-completion-events.d.ts +16 -0
- package/dist/agents/background-completion-events.js +16 -0
- package/dist/agents/background-completion.d.ts +22 -0
- package/dist/agents/background-completion.js +73 -0
- package/dist/agents/context-audit.d.ts +84 -0
- package/dist/agents/context-audit.js +115 -0
- package/dist/agents/credential-resolver.d.ts +74 -0
- package/dist/agents/credential-resolver.js +142 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.js +22 -0
- package/dist/agents/fastembed-subprocess.d.ts +52 -0
- package/dist/agents/fastembed-subprocess.js +282 -0
- package/dist/agents/instructions.d.ts +42 -0
- package/dist/agents/instructions.js +69 -0
- package/dist/agents/mastracode-gateway.d.ts +85 -0
- package/dist/agents/mastracode-gateway.js +500 -0
- package/dist/agents/memory.d.ts +36 -0
- package/dist/agents/memory.js +248 -0
- package/dist/agents/model.d.ts +158 -0
- package/dist/agents/model.js +382 -0
- package/dist/agents/modes/build.d.ts +12 -0
- package/dist/agents/modes/build.js +33 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.js +25 -0
- package/dist/agents/modes/plan.d.ts +8 -0
- package/dist/agents/modes/plan.js +43 -0
- package/dist/agents/prompts/agent-instructions.d.ts +122 -0
- package/dist/agents/prompts/agent-instructions.js +617 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.js +73 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.js +23 -0
- package/dist/agents/prompts/index.d.ts +61 -0
- package/dist/agents/prompts/index.js +141 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.js +20 -0
- package/dist/agents/prompts/plan.d.ts +11 -0
- package/dist/agents/prompts/plan.js +132 -0
- package/dist/agents/prompts/tool-guidance.d.ts +18 -0
- package/dist/agents/prompts/tool-guidance.js +158 -0
- package/dist/agents/sandbox-filesystem.d.ts +232 -0
- package/dist/agents/sandbox-filesystem.js +851 -0
- package/dist/agents/subagents/execute.d.ts +3 -0
- package/dist/agents/subagents/execute.js +24 -0
- package/dist/agents/subagents/explore.d.ts +3 -0
- package/dist/agents/subagents/explore.js +15 -0
- package/dist/agents/subagents/index.d.ts +6 -0
- package/dist/agents/subagents/index.js +15 -0
- package/dist/agents/subagents/plan.d.ts +3 -0
- package/dist/agents/subagents/plan.js +15 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.js +104 -0
- package/dist/agents/tool-availability.d.ts +17 -0
- package/dist/agents/tool-availability.js +134 -0
- package/dist/agents/tools.d.ts +37 -0
- package/dist/agents/tools.js +154 -0
- package/dist/agents/workflow-builder-agent.d.ts +2 -0
- package/dist/agents/workflow-builder-agent.js +79 -0
- package/dist/agents/workspace.d.ts +35 -0
- package/dist/agents/workspace.js +207 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.js +159 -0
- package/dist/auth/account-rotation-processor.d.ts +210 -0
- package/dist/auth/account-rotation-processor.js +662 -0
- package/dist/auth/account-routing-context.d.ts +17 -0
- package/dist/auth/account-routing-context.js +38 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.js +39 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.js +126 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.js +9 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.js +29 -0
- package/dist/auth/provider-auth-error.d.ts +24 -0
- package/dist/auth/provider-auth-error.js +44 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.js +117 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.js +359 -0
- package/dist/auth/providers/kimi-coding.d.ts +38 -0
- package/dist/auth/providers/kimi-coding.js +225 -0
- package/dist/auth/providers/openai-codex.d.ts +141 -0
- package/dist/auth/providers/openai-codex.js +531 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.js +223 -0
- package/dist/auth/storage.d.ts +222 -0
- package/dist/auth/storage.js +805 -0
- package/dist/auth/types.d.ts +164 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.js +224 -0
- package/dist/constants.d.ts +29 -0
- package/dist/constants.js +34 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.js +19 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.js +156 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.js +5 -0
- package/dist/evals/scorers/classify-command.d.ts +30 -0
- package/dist/evals/scorers/classify-command.js +61 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.js +256 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.js +57 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.js +3 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.js +360 -0
- package/dist/experimental-agent.d.ts +19 -0
- package/dist/experimental-agent.js +45 -0
- package/dist/factory/client.d.ts +44 -0
- package/dist/factory/client.js +110 -0
- package/dist/factory/remote-controller.d.ts +34 -0
- package/dist/factory/remote-controller.js +40 -0
- package/dist/factory/remote-session.d.ts +210 -0
- package/dist/factory/remote-session.js +415 -0
- package/dist/goal-manager.d.ts +114 -0
- package/dist/goal-manager.js +351 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.js +14 -0
- package/dist/headless/cli.d.ts +55 -0
- package/dist/headless/cli.js +261 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.js +207 -0
- package/dist/headless/format.d.ts +41 -0
- package/dist/headless/format.js +94 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.js +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.js +39 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.js +438 -0
- package/dist/headless/types.d.ts +175 -0
- package/dist/headless/types.js +16 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.js +77 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.js +128 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/manager.d.ts +75 -0
- package/dist/hooks/manager.js +289 -0
- package/dist/hooks/types.d.ts +180 -0
- package/dist/hooks/types.js +5 -0
- package/dist/index.d.ts +537 -0
- package/dist/index.js +1399 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.js +18 -0
- package/dist/knowledge-inspector.d.ts +139 -0
- package/dist/knowledge-inspector.js +533 -0
- package/dist/knowledge-scope-id.d.ts +7 -0
- package/dist/knowledge-scope-id.js +10 -0
- package/dist/knowledge-scope.d.ts +41 -0
- package/dist/knowledge-scope.js +85 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.js +248 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.js +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.js +41 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.js +79 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.js +158 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.js +52 -0
- package/dist/mcp/config.d.ts +77 -0
- package/dist/mcp/config.js +313 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +104 -0
- package/dist/mcp/manager.js +693 -0
- package/dist/mcp/state.d.ts +35 -0
- package/dist/mcp/state.js +94 -0
- package/dist/mcp/types.d.ts +139 -0
- package/dist/mcp/types.js +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.js +17 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.js +27 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.js +3 -0
- package/dist/onboarding/om-settings.d.ts +47 -0
- package/dist/onboarding/om-settings.js +80 -0
- package/dist/onboarding/pack-activation.d.ts +43 -0
- package/dist/onboarding/pack-activation.js +105 -0
- package/dist/onboarding/packs.d.ts +106 -0
- package/dist/onboarding/packs.js +283 -0
- package/dist/onboarding/settings.d.ts +563 -0
- package/dist/onboarding/settings.js +1110 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.js +139 -0
- package/dist/platform/index.d.ts +74 -0
- package/dist/platform/index.js +199 -0
- package/dist/plugin.d.ts +156 -0
- package/dist/plugin.js +27 -0
- package/dist/plugins/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.js +84 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.js +187 -0
- package/dist/plugins/loader.d.ts +25 -0
- package/dist/plugins/loader.js +264 -0
- package/dist/plugins/manager.d.ts +115 -0
- package/dist/plugins/manager.js +507 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.js +47 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.js +58 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.js +22 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.js +109 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.js +115 -0
- package/dist/plugins/signal-lane.d.ts +59 -0
- package/dist/plugins/signal-lane.js +163 -0
- package/dist/plugins/types.d.ts +95 -0
- package/dist/plugins/types.js +1 -0
- package/dist/process-memory-diagnostics.d.ts +136 -0
- package/dist/process-memory-diagnostics.js +497 -0
- package/dist/processors/plan-rejection-abort.d.ts +16 -0
- package/dist/processors/plan-rejection-abort.js +62 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.js +142 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.js +99 -0
- package/dist/providers/anthropic-prompt-cache.d.ts +19 -0
- package/dist/providers/anthropic-prompt-cache.js +8 -0
- package/dist/providers/anthropic-thinking.d.ts +5 -0
- package/dist/providers/anthropic-thinking.js +22 -0
- package/dist/providers/claude-max.d.ts +67 -0
- package/dist/providers/claude-max.js +232 -0
- package/dist/providers/github-copilot-gateway.d.ts +35 -0
- package/dist/providers/github-copilot-gateway.js +58 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.js +320 -0
- package/dist/providers/google-thinking.d.ts +31 -0
- package/dist/providers/google-thinking.js +64 -0
- package/dist/providers/google-vertex-gateway.d.ts +23 -0
- package/dist/providers/google-vertex-gateway.js +49 -0
- package/dist/providers/google-vertex.d.ts +6 -0
- package/dist/providers/google-vertex.js +51 -0
- package/dist/providers/kimi-coding.d.ts +14 -0
- package/dist/providers/kimi-coding.js +80 -0
- package/dist/providers/model-ids.d.ts +53 -0
- package/dist/providers/model-ids.js +132 -0
- package/dist/providers/openai-codex.d.ts +114 -0
- package/dist/providers/openai-codex.js +427 -0
- package/dist/providers/provider-thinking.d.ts +23 -0
- package/dist/providers/provider-thinking.js +61 -0
- package/dist/providers/thinking-request.d.ts +14 -0
- package/dist/providers/thinking-request.js +87 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.js +72 -0
- package/dist/schedules/index.d.ts +10 -0
- package/dist/schedules/index.js +6 -0
- package/dist/schedules/interval.d.ts +49 -0
- package/dist/schedules/interval.js +212 -0
- package/dist/schedules/prompt.d.ts +36 -0
- package/dist/schedules/prompt.js +36 -0
- package/dist/schedules/run-script.d.ts +8 -0
- package/dist/schedules/run-script.js +80 -0
- package/dist/schedules/scheduler.d.ts +101 -0
- package/dist/schedules/scheduler.js +167 -0
- package/dist/schedules/tools.d.ts +57 -0
- package/dist/schedules/tools.js +217 -0
- package/dist/schema.d.ts +499 -0
- package/dist/schema.js +131 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.js +18 -0
- package/dist/thinking-catalog.d.ts +4 -0
- package/dist/thinking-catalog.js +13 -0
- package/dist/thinking.d.ts +37 -0
- package/dist/thinking.js +134 -0
- package/dist/tool-names.d.ts +77 -0
- package/dist/tool-names.js +53 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.js +80 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.js +31 -0
- package/dist/tools/web-search.d.ts +116 -0
- package/dist/tools/web-search.js +158 -0
- package/dist/tools/workflows/create-workflow.d.ts +7 -0
- package/dist/tools/workflows/create-workflow.js +82 -0
- package/dist/tools/workflows/delete-workflow.d.ts +7 -0
- package/dist/tools/workflows/delete-workflow.js +18 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts +28 -0
- package/dist/tools/workflows/ephemeral-memory.js +41 -0
- package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
- package/dist/tools/workflows/extract-json-schema.js +19 -0
- package/dist/tools/workflows/get-workflow.d.ts +11 -0
- package/dist/tools/workflows/get-workflow.js +31 -0
- package/dist/tools/workflows/list-available-agents.d.ts +8 -0
- package/dist/tools/workflows/list-available-agents.js +29 -0
- package/dist/tools/workflows/list-available-classifiers.d.ts +19 -0
- package/dist/tools/workflows/list-available-classifiers.js +53 -0
- package/dist/tools/workflows/list-available-tools.d.ts +9 -0
- package/dist/tools/workflows/list-available-tools.js +37 -0
- package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-available-workflows.js +29 -0
- package/dist/tools/workflows/list-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-workflows.js +30 -0
- package/dist/tools/workflows/run-workflow.d.ts +9 -0
- package/dist/tools/workflows/run-workflow.js +49 -0
- package/dist/tools/workflows/save-workflow.d.ts +1125 -0
- package/dist/tools/workflows/save-workflow.js +25 -0
- package/dist/tools/workflows/tool-ids.d.ts +16 -0
- package/dist/tools/workflows/tool-ids.js +17 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.js +97 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.js +56 -0
- package/dist/utils/discarding-scores-storage.d.ts +33 -0
- package/dist/utils/discarding-scores-storage.js +51 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.js +215 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.js +58 -0
- package/dist/utils/local-observability.d.ts +19 -0
- package/dist/utils/local-observability.js +54 -0
- package/dist/utils/maintenance-lock.d.ts +42 -0
- package/dist/utils/maintenance-lock.js +196 -0
- package/dist/utils/notification-dispatch.d.ts +74 -0
- package/dist/utils/notification-dispatch.js +128 -0
- package/dist/utils/open-url.d.ts +10 -0
- package/dist/utils/open-url.js +27 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.js +7 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.js +59 -0
- package/dist/utils/plans.d.ts +61 -0
- package/dist/utils/plans.js +120 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.js +361 -0
- package/dist/utils/prune-cli.d.ts +24 -0
- package/dist/utils/prune-cli.js +124 -0
- package/dist/utils/signals-pubsub.d.ts +103 -0
- package/dist/utils/signals-pubsub.js +409 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.js +139 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.js +106 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.js +93 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.js +118 -0
- package/dist/utils/storage-maintenance.d.ts +121 -0
- package/dist/utils/storage-maintenance.js +352 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.js +109 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.js +19 -0
- package/dist/utils/update-check.d.ts +151 -0
- package/dist/utils/update-check.js +430 -0
- package/dist/utils/wake-session.d.ts +44 -0
- package/dist/utils/wake-session.js +83 -0
- package/dist/voice/stt-registry.d.ts +67 -0
- package/dist/voice/stt-registry.js +144 -0
- package/dist/voice/transcribe.d.ts +10 -0
- package/dist/voice/transcribe.js +75 -0
- package/dist/workflows/register-primitives.d.ts +52 -0
- package/dist/workflows/register-primitives.js +40 -0
- package/dist/workflows/service.d.ts +64 -0
- package/dist/workflows/service.js +50 -0
- package/package.json +117 -0
|
@@ -0,0 +1,232 @@
|
|
|
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
|
+
* When the sandbox exposes its own `filesystem`, file operations use it
|
|
9
|
+
* instead, which takes one round trip rather than several commands; grep and
|
|
10
|
+
* walks still run as shell commands.
|
|
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
|
+
import type { CopyOptions, FileContent, FileEntry, FileStat, FilesystemGrepOptions, FilesystemGrepResult, FilesystemInfo, ListOptions, ProviderStatus, ReadOptions, RemoveOptions, WalkEntry, WalkOptions, WorkspaceFilesystem, WriteOptions } from '@mastra/core/workspace';
|
|
19
|
+
/** Minimal command result shape we depend on. */
|
|
20
|
+
export interface SandboxCommandResult {
|
|
21
|
+
exitCode: number;
|
|
22
|
+
stdout: string;
|
|
23
|
+
stderr: string;
|
|
24
|
+
}
|
|
25
|
+
/** Minimal sandbox surface the filesystem needs. */
|
|
26
|
+
export interface SandboxExec {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
/**
|
|
29
|
+
* The sandbox's own file API, when it has one (`WorkspaceSandbox.filesystem`).
|
|
30
|
+
* File operations go through it instead of shell commands.
|
|
31
|
+
*/
|
|
32
|
+
readonly filesystem?: WorkspaceFilesystem;
|
|
33
|
+
executeCommand(command: string, args?: string[], options?: {
|
|
34
|
+
timeout?: number;
|
|
35
|
+
maxRetainedBytes?: number;
|
|
36
|
+
}): Promise<SandboxCommandResult>;
|
|
37
|
+
}
|
|
38
|
+
export interface SandboxFilesystemOptions {
|
|
39
|
+
/** Live sandbox to run commands in. */
|
|
40
|
+
sandbox: SandboxExec;
|
|
41
|
+
/**
|
|
42
|
+
* Absolute path inside the sandbox that is the workspace root — or a lazy
|
|
43
|
+
* resolver for it. The resolver form exists for sandboxes whose workspace
|
|
44
|
+
* root is only knowable once the VM is running (e.g. `$HOME/<repo>` under
|
|
45
|
+
* a provider-chosen home dir): it is awaited on the first file operation
|
|
46
|
+
* (which itself may lazily start the VM) and the result is memoized.
|
|
47
|
+
*/
|
|
48
|
+
workdir: string | (() => Promise<string> | string);
|
|
49
|
+
/** Optional stable id; defaults to a sandbox-derived id. */
|
|
50
|
+
id?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Check that symlinks don't lead outside the workdir when using the
|
|
53
|
+
* sandbox's native filesystem. Off by default: native file APIs follow
|
|
54
|
+
* symlinks, and inside a sandbox the agent can read anything with a command
|
|
55
|
+
* anyway. Turn it on when files are served to someone other than the agent.
|
|
56
|
+
*
|
|
57
|
+
* Each path is checked once per instance, so keep such instances
|
|
58
|
+
* short-lived. Without a native filesystem the shell path always checks.
|
|
59
|
+
*/
|
|
60
|
+
verifySymlinks?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Additional file extensions to treat as text, extending (not replacing) the
|
|
63
|
+
* built-in set. Affects which files tools like `grep` will search. Values are
|
|
64
|
+
* normalized like `LocalFilesystem`'s option, so `'sas'`, `'.sas'` and
|
|
65
|
+
* `'.SAS'` are equivalent.
|
|
66
|
+
*/
|
|
67
|
+
textExtensions?: string[];
|
|
68
|
+
}
|
|
69
|
+
export declare class SandboxFilesystem implements WorkspaceFilesystem {
|
|
70
|
+
readonly id: string;
|
|
71
|
+
readonly name = "SandboxFilesystem";
|
|
72
|
+
readonly provider = "sandbox";
|
|
73
|
+
status: ProviderStatus;
|
|
74
|
+
private readonly sandbox;
|
|
75
|
+
private readonly workdirSource;
|
|
76
|
+
private resolvedBase?;
|
|
77
|
+
private resolvingBase?;
|
|
78
|
+
private readonly verifySymlinks;
|
|
79
|
+
/**
|
|
80
|
+
* Classifies file names as text: the built-in extensions plus
|
|
81
|
+
* `textExtensions`, normalized exactly as `LocalFilesystem` does. Only its
|
|
82
|
+
* `isTextFile` is ever called; it never touches a file.
|
|
83
|
+
*/
|
|
84
|
+
private readonly textClassifier;
|
|
85
|
+
/** `check:absolutePath` keys that passed while the entry existed. */
|
|
86
|
+
private readonly verified;
|
|
87
|
+
constructor(options: SandboxFilesystemOptions);
|
|
88
|
+
/** The resolved workspace root; empty until a lazy workdir first resolves. */
|
|
89
|
+
get basePath(): string;
|
|
90
|
+
/**
|
|
91
|
+
* The sandbox directory shell commands default to: the same root file paths
|
|
92
|
+
* resolve against, so a relative path means the same thing to a shell command
|
|
93
|
+
* and to a file tool. Non-empty whenever the workspace root is known.
|
|
94
|
+
*/
|
|
95
|
+
getCommandCwd(): Promise<string | undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* Whether tools like `grep` should treat a file as text: the built-in text
|
|
98
|
+
* extensions plus any `textExtensions` passed to the constructor.
|
|
99
|
+
*/
|
|
100
|
+
isTextFile(filename: string): boolean;
|
|
101
|
+
/** Await (and memoize) the workspace root, resolving a lazy workdir once. */
|
|
102
|
+
private base;
|
|
103
|
+
/**
|
|
104
|
+
* Resolve a workspace path to an absolute path inside the sandbox, enforcing
|
|
105
|
+
* that it stays within the workdir. Awaits the workspace root first, which
|
|
106
|
+
* for a lazy workdir may start the VM.
|
|
107
|
+
*/
|
|
108
|
+
private resolveAsync;
|
|
109
|
+
/**
|
|
110
|
+
* Resolve a workspace path against a known base, enforcing that it stays
|
|
111
|
+
* within the workdir.
|
|
112
|
+
*
|
|
113
|
+
* Accepts both workspace-relative paths (`src/foo.ts`, `/src/foo.ts`) and
|
|
114
|
+
* absolute sandbox paths that already live under the workdir — the agent's
|
|
115
|
+
* prompt advertises the workdir as its working directory, so tools are
|
|
116
|
+
* routinely called with fully-qualified paths like `<workdir>/src/foo.ts`.
|
|
117
|
+
*/
|
|
118
|
+
private resolveAgainst;
|
|
119
|
+
/**
|
|
120
|
+
* A miss on an absolute path outside the workdir (e.g. `/tmp/x/a.ts`) that
|
|
121
|
+
* does exist at that real sandbox path: the agent meant the sandbox path,
|
|
122
|
+
* but it was remapped under the workdir. Explain that instead of a bare
|
|
123
|
+
* not-found. Undefined when the path is inside the workdir or doesn't exist.
|
|
124
|
+
*/
|
|
125
|
+
private outsideWorkdirNotFound;
|
|
126
|
+
resolveAbsolutePath(inputPath: string): string | undefined;
|
|
127
|
+
private exec;
|
|
128
|
+
/**
|
|
129
|
+
* Lexical guard catches `..` traversal, but a symlink inside the workdir can
|
|
130
|
+
* still point outside it. After resolving a path that refers to an existing
|
|
131
|
+
* entry, verify its realpath is still contained in the workdir.
|
|
132
|
+
*
|
|
133
|
+
* Canonicalization tries `realpath`, then `readlink -f` (GNU/busybox), then
|
|
134
|
+
* `cd && pwd -P` for directories — covering GNU hosts, macOS/BSD, and
|
|
135
|
+
* busybox. If the path exists but cannot be canonicalized we fail CLOSED:
|
|
136
|
+
* returning without a check would let a symlink bypass containment.
|
|
137
|
+
*/
|
|
138
|
+
private assertContainedRealpath;
|
|
139
|
+
/**
|
|
140
|
+
* Guard for write destinations. The lexical guard catches `..`, but a symlink
|
|
141
|
+
* inside the workdir can redirect a write outside it. For an existing target
|
|
142
|
+
* we check its realpath; for a not-yet-existing target we check the realpath
|
|
143
|
+
* of its nearest existing ancestor directory, since a symlinked parent is the
|
|
144
|
+
* escape vector (e.g. `link -> /etc` then writing `link/passwd`).
|
|
145
|
+
*/
|
|
146
|
+
private assertContainedDest;
|
|
147
|
+
/**
|
|
148
|
+
* Before a native filesystem call, run the containment check the shell path
|
|
149
|
+
* runs for that operation, when `verifySymlinks` is on. A pass is remembered
|
|
150
|
+
* only for an entry that exists: a missing path may later appear as a
|
|
151
|
+
* symlink that leads outside the workdir.
|
|
152
|
+
*/
|
|
153
|
+
private verifyNative;
|
|
154
|
+
private execOk;
|
|
155
|
+
readFile(path: string, options?: ReadOptions): Promise<string | Buffer>;
|
|
156
|
+
writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void>;
|
|
157
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
158
|
+
deleteFile(path: string, options?: RemoveOptions): Promise<void>;
|
|
159
|
+
copyFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
160
|
+
moveFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
161
|
+
mkdir(path: string, options?: {
|
|
162
|
+
recursive?: boolean;
|
|
163
|
+
}): Promise<void>;
|
|
164
|
+
rmdir(path: string, options?: RemoveOptions): Promise<void>;
|
|
165
|
+
readdir(path: string, options?: ListOptions): Promise<FileEntry[]>;
|
|
166
|
+
private parseListOutput;
|
|
167
|
+
private parseFindOutput;
|
|
168
|
+
private matchesExtension;
|
|
169
|
+
/**
|
|
170
|
+
* Walk the tree in a single sandbox command instead of one readdir round
|
|
171
|
+
* trip per directory. Uses `find` with a portable classification loop
|
|
172
|
+
* (`find -printf` is GNU-only and fails on macOS/BSD hosts). `find` does
|
|
173
|
+
* not follow symlinked directories by default, matching the host-side
|
|
174
|
+
* walker's no-recursion-into-symlinks behavior.
|
|
175
|
+
*/
|
|
176
|
+
walk(path: string, options?: WalkOptions): Promise<WalkEntry[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Content search executed inside the sandbox in one command, using the best
|
|
179
|
+
* engine the sandbox has: ripgrep, then GNU grep (with git choosing files
|
|
180
|
+
* inside repositories), then POSIX `grep -rnE`. Patterns the grep engines
|
|
181
|
+
* can't express (PCRE-style classes, word boundaries, lookarounds,
|
|
182
|
+
* non-greedy quantifiers) throw {@link UnsupportedGrepPatternError} so
|
|
183
|
+
* callers use their host-side walk.
|
|
184
|
+
*
|
|
185
|
+
* ripgrep and GNU grep apply every `.gitignore` in the tree, relative to the
|
|
186
|
+
* directory that holds it, and skip `node_modules` unless the search path
|
|
187
|
+
* is inside one. Callers still apply their own hidden/glob filtering.
|
|
188
|
+
*/
|
|
189
|
+
grep(options: FilesystemGrepOptions): Promise<FilesystemGrepResult[]>;
|
|
190
|
+
private toolsCheck;
|
|
191
|
+
private searchTools;
|
|
192
|
+
private grepWithRipgrep;
|
|
193
|
+
private parseRipgrepJson;
|
|
194
|
+
/**
|
|
195
|
+
* Patterns whose meaning differs between POSIX ERE and JS RegExp. The grep
|
|
196
|
+
* runs with ERE but match columns are recomputed with JS, so anything that
|
|
197
|
+
* only one side understands (PCRE classes, lookarounds, lazy quantifiers,
|
|
198
|
+
* POSIX bracket classes, GNU word anchors) must fall back to the host walk.
|
|
199
|
+
*/
|
|
200
|
+
private static readonly ERE_UNSUPPORTED;
|
|
201
|
+
/**
|
|
202
|
+
* Escapes that `grep -P` (PCRE) and JS RegExp (without the `u` flag) both
|
|
203
|
+
* accept but read differently, e.g. `\A` is "start of subject" in PCRE and
|
|
204
|
+
* a literal `A` in JS, plus POSIX bracket classes. PCRE-only syntax that JS
|
|
205
|
+
* rejects (inline flags, possessive quantifiers, atomic groups) already
|
|
206
|
+
* fails the JS compile below.
|
|
207
|
+
*/
|
|
208
|
+
private static readonly PCRE_UNSUPPORTED;
|
|
209
|
+
/** Reject patterns grep can't run with the same meaning as JS; return the JS regex used for columns. */
|
|
210
|
+
private static grepRegex;
|
|
211
|
+
/**
|
|
212
|
+
* GNU grep without ripgrep. Inside a git checkout, `git grep` picks the
|
|
213
|
+
* files (tracked plus untracked, every `.gitignore` applied) and GNU grep
|
|
214
|
+
* prints them with context. Outside a checkout (e.g. a multi-repo root),
|
|
215
|
+
* each child repository is searched the same way and plain grep covers the
|
|
216
|
+
* remaining files, skipping `node_modules`. `--null` ends each file name
|
|
217
|
+
* with NUL, so match (`N:`) and context (`N-`) lines parse unambiguously.
|
|
218
|
+
* When grep and git support it, patterns run as PCRE (`-P`), so `\d`,
|
|
219
|
+
* `\w`, `\s`, `\b`, and lookarounds don't need the host walk.
|
|
220
|
+
*/
|
|
221
|
+
private grepWithGnuGrep;
|
|
222
|
+
private grepWithPosixGrep;
|
|
223
|
+
private applyTotalCap;
|
|
224
|
+
exists(path: string): Promise<boolean>;
|
|
225
|
+
stat(path: string): Promise<FileStat>;
|
|
226
|
+
init(): Promise<void>;
|
|
227
|
+
destroy(): Promise<void>;
|
|
228
|
+
isReady(): Promise<boolean>;
|
|
229
|
+
getInfo(): FilesystemInfo;
|
|
230
|
+
getInstructions(): string;
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=sandbox-filesystem.d.ts.map
|