feat(security): add sandboxed agent execution (host/docker/apple), fail-closed retries, dead-letter queue, and ops docs #30#55
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3f32ff6e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/lib/runner.ts
Outdated
| args.push('--user', '1000:1000'); | ||
| args.push('--mount', `type=bind,src=${request.workingDir},dst=${containerWorkingDir}`); |
There was a problem hiding this comment.
Run sandbox container as the current host UID/GID
The sandbox runner hard-codes --user 1000:1000 while bind-mounting the agent workspace, which causes write failures whenever that workspace is owned by a different UID/GID (common on macOS with UID 501 or root-owned deployments), so provider CLIs cannot persist conversation state or output files and containerized invocations fail with permission errors; derive UID/GID from the running process (or make it configurable) instead of assuming 1000.
Useful? React with 👍 / 👎.
src/lib/runner.ts
Outdated
| return runContainer(request, 'docker'); | ||
| } | ||
|
|
||
| return runContainer(request, 'apple'); |
There was a problem hiding this comment.
Validate sandbox mode instead of defaulting to apple
runInSandbox falls through to Apple mode for any unrecognized sandbox.mode, so a typo or corrupted config value silently runs the wrong runtime and surfaces misleading Apple runtime errors instead of an explicit configuration failure; unknown modes should be rejected with a terminal config error.
Useful? React with 👍 / 👎.
Detailed code review of the sandbox execution feature covering: - Security issues (secret exposure via --env args, hard-coded UID) - Bugs (unvalidated sandbox mode fallthrough) - Design concerns (unbounded buffers, falsy-check defaults) - Code quality items (style reformatting, missing validation) https://claude.ai/code/session_01QD8DbEFLdkbLik4hgvrgDm
PR Review Summary
Blocking Issues
Non-blocking / High-priority Suggestions
Local Validation Notes
Ready-to-paste PR Overall CommentRequesting changes due to 2 blocking issues: |
Summary
This PR adds sandbox support for TinyClaw agent execution with runtime modes:
host(existing behavior)docker(ephemeral container per invocation)apple(runtime-command adapter)It preserves existing queue/team routing behavior and adds fail-closed security controls, retry/dead-letter handling, diagnostics commands, and documentation.
This is an enhancement for #30.
Why
Agent invocations were executed directly on host. This change introduces isolated runtime options and explicit runtime/env validation for safer and more predictable operations.
Changes
Runtime and Invocation
src/lib/runner.ts:HostRunner,DockerRunner,AppleRunnerOPENAI_API_KEY,ANTHROPIC_API_KEY)src/lib/invoke.tsto execute through runner abstraction while preserving response parsing.sandbox_invocation_startsandbox_invocation_endsandbox_invocation_errorConfig and Types
src/lib/types.ts:sandboxconfigsandbox_modeattempt,firstSeenAt,errorClass)src/lib/config.ts:getSandboxConfig(...)QUEUE_DEAD_LETTERQueue Reliability
src/queue-processor.ts:terminalvstransient)sandbox.max_attempts~/.tinyclaw/queue/dead-letter[send_file: ...]path mapping for sandbox outputsCLI and Setup
tinyclaw.sh sandboxsubcommands:showset <host|docker|apple>doctorbuild-imagelib/setup-wizard.shto configure sandbox settings.Dockerfile.agent-runner.Documentation
docs/SANDBOX.mddocs/MIGRATION-SANDBOX.mddocs/OPERATIONS-RUNBOOK.mdREADME.mddocs/INSTALL.mddocs/AGENTS.mddocs/QUEUE.mddocs/TROUBLESHOOTING.mdBehavior Notes
docker run --rmper invocation), sodocker psmay not show long-lived containers.hostmode unless changed by user).Validation
npx tsc --noEmit✅npm run build✅bash -n tinyclaw.sh lib/setup-wizard.sh✅Known Limitations
Dockerfile.agent-runneris minimal; production image should include required provider CLIs (claude,codex).sandbox.apple.runtime_commandand runtime environment parity.