Repository navigation
feat: simplify DockerSandbox interface to take container ID - #1141
gautamsirdeshmukh wants to merge 1 commit into
Conversation
1de7f8f to
90c22ea
Compare
| @@ -62,169 +21,36 @@ export interface DockerSandboxOptions { | |||
| * If you specify a custom path, it must already exist in the image and be writable by `user`. | |||
| */ | |||
There was a problem hiding this comment.
Issue: The TSDoc for workingDir references --cap-drop ALL which is no longer managed by this class (it was part of the old lifecycle logic). This will confuse users who now create containers externally.
Suggestion: Simplify to focus on what the user needs to know:
/**
* Working directory inside the container. Defaults to `"/tmp"`.
*
* `/tmp` is world-writable on standard base images, making it a safe default for
* non-root users. If you specify a custom path, ensure it exists and is writable
* by the configured `user`.
*/| yield OK | ||
| }) | ||
| await sandbox.start() | ||
| const args = vi.mocked(streamProcess).mock.calls[0]![1] |
There was a problem hiding this comment.
Issue: There's no unit test covering the custom user option, which is the only security-relevant configuration left in this class.
Suggestion: Add a test verifying custom user is passed through:
it('passes custom user to docker exec', async () => {
const sandbox = new DockerSandbox({ containerId: 'c', user: 'root' })
await sandbox.execute('x')
const args = vi.mocked(streamProcess).mock.calls[0]![1]
expect(args[args.indexOf('--user') + 1]).toBe('root')
})|
Assessment: Comment This is a clean simplification that removes significant complexity. The "bring-your-own-container" approach is much easier to reason about. Review Categories
The resulting implementation is refreshingly simple — 56 lines for a focused exec wrapper is the right level of abstraction. |
|
Closing + will reopen against the monorepo (sdk-python) |
Description
Simplify
DockerSandboxto "bring-your-own-container" (thin docker exec wrapper). The SDK no longer manages container lifecycle, security policies, volumes, or resource limits. Users create and configure their container externally.Removed:
start()/stop()methods, AsyncDisposable usageimage,name,volumes,env,memory,cpus,pidsLimit, network optionsWhat remains:
containerId(required),workingDir(default /tmp),user(default 1000:1000)executeStreamingmethod that shells out todocker execRelated Issues
Updates #1110
Documentation PR
Not yet
Type of Change
(breaking) change
Testing
How have you tested the change?
hatch run preparefor Python,npm run checkfor TypeScript)Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.