-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Enabling sandboxing for terminal commands execution through copilot chat. #280236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds sandboxing functionality for terminal command execution through Copilot chat. It introduces a new setting that allows commands run via the "run in terminal" tool to be executed in a sandboxed environment using the @anthropic-ai/sandbox-runtime package (via the srt CLI tool). The feature is designed for Linux and macOS only.
Key Changes:
- Adds
sandboxSettingsResourceto user data profiles to store sandbox configuration files - Introduces a new experimental setting
chat.tools.terminal.sandboxto control sandboxing behavior with filesystem and network restrictions - Implements logic to wrap terminal commands with the
srtsandboxing tool and provides a retry mechanism when sandboxed commands fail
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 31 comments.
Show a summary per file
| File | Description |
|---|---|
src/vs/platform/userDataProfile/common/userDataProfile.ts |
Adds sandboxSettingsResource property to IUserDataProfile interface for storing sandbox configuration |
src/vs/platform/terminal/common/terminal.ts |
Defines sandbox-related interfaces (ISandboxRuntimeConfig, ISandboxTerminalSettings) and adds sandbox properties to shell launch config |
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts |
Adds schema for the new chat.tools.terminal.sandbox setting with filesystem and network access controls |
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts |
Main implementation: wraps commands with srt, manages sandbox config files, handles retry without sandboxing |
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.ts |
Registers retry action that allows users to re-run failed commands without sandboxing |
src/vs/platform/terminal/node/terminalEnvironment.ts |
Adds shell integration support for sandboxed bash terminals on Windows |
package.json / package-lock.json |
Adds @anthropic-ai/sandbox-runtime dependency (v0.0.13) |
| Test files (multiple) | Updates test fixtures to include the new sandboxSettingsResource property |
.vscode/launch.json |
Adds debugging configuration for ptyhost inspection |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
...rminalContrib/chatAgentTools/browser/tools/commandLineRewriter/sandboxCommandLineRewriter.ts
Outdated
Show resolved
Hide resolved
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to learn more what a sandboxSettingsResource is and what the new dependency is @anthropic-ai/sandbox-runtime
Are we really pushing this in on the last day of the iteration?
Sure I can setup a call if needed. Daniel is OOF and I dont think it will go this week. |
e5335e3 to
40882e1
Compare
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
...bench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.ts
Outdated
Show resolved
Hide resolved
Tyriar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't merge this without a proper review from me.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
...bench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.ts
Outdated
Show resolved
Hide resolved
...bench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.ts
Outdated
Show resolved
Hide resolved
...rkbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts
Outdated
Show resolved
Hide resolved
...bench/contrib/terminalContrib/chatAgentTools/test/electron-browser/runInTerminalTool.test.ts
Outdated
Show resolved
Hide resolved
|
Overarching comment is to not change the style of the code you're in, that includes not adding whitespace, tweaking trailing commas, etc. Also there are conflicts |
...rib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 11 comments.
Comments suppressed due to low confidence (3)
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts:864
- Multiple consecutive blank lines (lines 859-860 and 863-864). According to VS Code style guidelines, there should be at most one blank line between code blocks. Remove the extra blank lines.
}
}
} catch (e) {
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts:935
- Extra blank line before method definition. Remove line 934 for consistency.
private _handleTerminalVisibility(toolTerminal: IToolTerminal, chatSessionResource: URI) {
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts:965
- Multiple consecutive blank lines (lines 963-964). Remove one blank line for consistency.
private async _initForegroundTerminal(chatSessionResource: URI, termId: string, terminalToolSessionId: string | undefined, token: CancellationToken): Promise<IToolTerminal> {
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
...rib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/editSessions/test/browser/editSessions.test.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
...bench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.ts
Show resolved
Hide resolved
| private _needsForceUpdateConfigFile = true; | ||
| private _tempDir: URI | undefined; | ||
| private _sandboxSettingsId: string | undefined; | ||
| private _os: OperatingSystem = OS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to make this a promise to avoid a possible race? You'd need isEnabled to be async then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of fire and forget approach that is set in the constructor during singleton creation. Want to keep the usage of isEnabled simple without async.
fixes #277286