Documentation
¶
Index ¶
- func AllowedDirectories(cfg *config.Config) []string
- func BashAllowedCommands(cfg *config.Config, mode agentdomain.AgentMode) []string
- func BashCommandDeniedPath(cfg *config.Config, command string) (string, bool)
- func BashCommandRejectionHint(cfg *config.Config, command string) string
- func BlockingDenials(cfg *config.Config) []sandboxdomain.Denied
- func Denies(cfg *config.Config, projectDir, absPath string) bool
- func GrantFor(cfg *config.Config, denial *sandboxdomain.DeniedError) sandboxdomain.Allowed
- func IsAnchored(rulePath string) bool
- func IsBashCommandAllowed(cfg *config.Config, command string, mode agentdomain.AgentMode) bool
- func IsUnrestricted(allow []string) bool
- func ReadOnlyCarveOuts() []string
- func ValidateRead(cfg *config.Config, path string) error
- func ValidateWrite(ctx context.Context, cfg *config.Config, path string) error
- func WritableCarveOuts(cfg *config.Config) []string
- func WritePaths(cfg *config.Config, mode agentdomain.AgentMode) []string
- type Grants
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowedDirectories ¶
AllowedDirectories are the anchored allowed paths, in order, for callers that want somewhere sensible to look.
func BashAllowedCommands ¶
func BashAllowedCommands(cfg *config.Config, mode agentdomain.AgentMode) []string
BashAllowedCommands returns the effective bash allow-list for mode: the shared mode.all baseline unioned with that mode's own bucket. This is the ONE place an AgentMode maps to a tools.bash.mode.<bucket> list: Plan -> plan, AutoAccept -> auto, Standard/AutoWithJudge/unknown -> standard, ReadOnly -> baseline only. The system prompt lists it so the agent knows what runs.
func BashCommandDeniedPath ¶ added in v0.262.0
BashCommandDeniedPath reports the first path in command's statically nameable arguments that a blocking deny entry matches, for the Bash tool to refuse in every mode: auto mode's unrestricted allow-list skips the path check, and no approval reopens what the policy blocks.
func BashCommandRejectionHint ¶
BashCommandRejectionHint explains why the guard rejected command, or a path outside the sandbox, so the model can correct course instead of retrying. It returns "" when the command is simply not in the allow-list. A nil config skips the sandbox reason.
func BlockingDenials ¶ added in v0.262.0
func BlockingDenials(cfg *config.Config) []sandboxdomain.Denied
BlockingDenials lists the deny entries that refuse rather than ask, so every layer honors them the same way: the file tools' exclusion, the Bash tool's walker, and the kernel's read denial where the OS can express one.
func Denies ¶ added in v0.239.0
Denies reports whether a denied entry of the policy matches a file of a project, given its absolute path and its path relative to the project dir. A session checkpoint uses it to keep denied files, such as *.env and *.key, out of the repository it packs, wherever the daemon itself runs.
func GrantFor ¶
func GrantFor(cfg *config.Config, denial *sandboxdomain.DeniedError) sandboxdomain.Allowed
GrantFor is the entry worth asking the user for after a denial: the exact path when a denied entry matched or it sits in a config dir, otherwise the directory around it so the agent can keep working there without a prompt per file.
func IsAnchored ¶
func IsBashCommandAllowed ¶
IsBashCommandAllowed reports whether command is auto-approved in mode, for the Bash tool, the approval policy and agent auto-approval alike. A ".*" entry allows anything. Otherwise the command must pass cleanSingleCommand, match an allow entry whole, and name only paths inside the sandbox. What is not allowed asks in chat and is rejected in headless mode.
func IsUnrestricted ¶
IsUnrestricted reports whether the allow-list contains the "allow any command" sentinel, which makes the mode unrestricted (and skips the clean-command guard). ".*", "^.*$", ".+", and a few trivially-equivalent forms qualify.
func ReadOnlyCarveOuts ¶ added in v0.262.0
func ReadOnlyCarveOuts() []string
ReadOnlyCarveOuts lists the language library directories the file tools may read but never write: the Go module cache and standard library source, the Cargo registry and git sources, and the rustup toolchain sources.
func ValidateRead ¶
ValidateRead checks that a path and the file it resolves to through symlinks may both be read. Checking the target stops a link inside the sandbox from reaching a file outside it.
func ValidateWrite ¶
ValidateWrite is ValidateRead for writes. The userspace policy files and the custom-tool directories are never writable, whatever the rules say. In plan mode only the project scratchpad may be written: the gate runs before grants and the configured allowed list, since no grant can widen plan mode.
func WritableCarveOuts ¶ added in v0.262.0
WritableCarveOuts lists the built-in directories the file tools may write although the config dirs ask: skills, plugins, runtime output, plans, insights and memory.
func WritePaths ¶ added in v0.262.0
func WritePaths(cfg *config.Config, mode agentdomain.AgentMode) []string
WritePaths lists the directories a bash child may write while the kernel confines it: the writable allowed entries and grants, the carve-outs the file tools may write, the temp and tool cache dirs a build needs, and /dev. In plan mode the project gives way to the scratchpad, as ValidateWrite does.
Types ¶
type Grants ¶
type Grants struct {
// contains filtered or unexported fields
}
Grants are the entries the user approved after a denial. They extend the configured policy for the rest of the process and never feed the system prompt, which must stay byte-stable within a session.
var Granted Grants
Granted holds the process-wide grants. ponytail: process-wide like the port registry, fold into an injected guard if one process ever runs multiple configs.
func (*Grants) Add ¶
func (g *Grants) Add(entry sandboxdomain.Allowed)
Add grants entry for the rest of the process. Idempotent.
func (*Grants) List ¶
func (g *Grants) List() []sandboxdomain.Allowed
List returns a copy of the granted entries.