Finalize `sandbox_permissions` configuration option
Originally, the TypeScript CLI tried to provide a simple set of sandboxing/approval options: --suggest, --auto-edit, and --full-auto. We shortly discovered that we were conflating two concepts: approvals and sandboxing, which we worked to separate in the Rust CLI.
In an attempt to provide flexibility, we introduced more fine-grained sandbox permissions in the Rust CLI that could be specified individually where --sandbox-permission could be specified multiple times. This has confused people because doing --sandbox-permission network-full-access would "reset" all of your permissions and include only network-full-access, losing permissions such as disk-full-read-access, which is almost never what the user wants.
It also makes the TUI really noisy, as the start of the conversation includes something verbose like:
sandbox: SandboxPolicy { permissions: [DiskFullReadAccess, DiskWritePlatformUserTempFolder, DiskWritePlatformGlobalTempFolder, DiskWriteCwd }
Ideally, we would have something that:
- Affords a simple flag for the common case (e.g.,
--full-auto) that can also be expressed succinctly inconfig.tomlso users don't have to pass the simple flag each time. - Affords more fine-grained configuration without as much risk of users shooting themselves in the foot.
- Can be expressed succinctly at the start of a session so the user is clear what aggregate sandbox config they ended up with.
7 Comments
I think a good solution to this problem would have the following properties:
--full-auto) to use as a "base configuration," to which additional rules can be applied on top. These "additional rules" can add or remove priviliges.config.toml.In principle, we have three types of permissions today:
Roughly, each permission could have "three" settings:
Though certainly "custom" is where things get dicey. Currently, we do not even support "custom" configuration for disk read or network access (only all or nothing), but the customization for disk write is a bit complicated because we support specifying exact folders as well as more "declarative" type things like
disk-write-cwd.Spitballing, perhaps introducing support for
enable-anddisable-prefixes would make it more straightforward to build on top of a sandbox preset:though then perhaps the TOML would have to look something like:
which seems distasteful.
It also reinforces this issue where
--full-autois overloaded to provide a base config for both sandboxing and approvals.Maybe something more like:
In this scheme, the TOML has one sandbox-related config option, which is always a list:
Note that overriding
sandboxas defined inconfig.tomlon the command line would effectively be easier to do via-sthan via-cbecause-cwould only support redefiningsandboxoutright rather than amending entries to the existing list.In other words,
-sargs would have to satisfy one of the following conditions:enable-disable--presetIn the header in the TUI, the sandbox entry would likely be more succinct than it is today since we wouldn't expand the
presetdefinition there.We would also have to define what happens if multiple
preset-values are passed via-sas well as what happens if-s dangerously-operate-without-a-sandbox-presetis used in combination withdisable-options...Revisiting this issue, I think my last proposal is too verbose. For example, there should be a limited set of presets, so the
-presetsuffix should be unnecessary since we can ensure their names not overlap with other options. Similarly,enable-should be far more common thandisable-, so we should omit theenable-prefix, as it should be an implicit default.In practice, today we have three "sandbox presets" that we want to support:
In terms of "relaxing" the sandbox, the only thing we really let you do is add more writable roots. (Though we might want to let users enable network while still limiting writes?)
As far as naming these preset modes, we could go with:
read-onlyworkspace-writedanger-full-accessAnd perhaps to simplify things, we require a "base mode" (defaults to
read-only) and any further sandbox permissions must be "additive" to the mode that was originally specified.Here is a simpler scheme:
read-only,workspace-write,danger-full-accessdanger-full-accessmode)danger-full-accessmode)For now, there is no way to disable global read-only access (or restrict it to a specific set of folders), but we can consider that later, if appropriate.
In the config file, this would look like:
Upon further consideration, a better config file format is probably: