feat: add allow_tmpdir permission for scoped tmpdir access
#6123
+396
−96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an
allow_tmpdirpermission that allows file operations in the system's temporary directory without requiringexternal_directoryapproval prompts.The
permission.allow_tmpdir: boolean(defaults tofalse) and is in both global/merged config and per-agent config/schemas.specifically:
external_directorydefaults to"ask", prompting for permission on any file operation outside the current working directoryexternal_directory: "allow") permits access to ALL external directories, which is overly broadsecurity:
/tmp→/private/tmp)falsemaintains current security model (opt-in)external_directorysettingstests:
Filesystem.tmpdir(),isInTmpdir(),containsResolved()utilities tested for symlink resolution and non-existent pathsallow_tmpdir: truepermits tmpdir workdir whileexternal_directory: denyis setallow_tmpdir: truedoes not bypassexternal_directoryfor non-tmpdir pathsusage example:
{ "$schema": "https://opencode.ai/config.json", "permission": { "allow_tmpdir": true, "external_directory": "ask" } }Or per-agent:
{ "agent": { "build": { "permission": { "allow_tmpdir": true } } } }related: