settings

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package settings writes per-spawn deny-default permission JSON files for interactive claude spawned via PTY drive. The file replicates the tool whitelist that `claude -p --allowedTools` enforced before the 2026-05-19 pivot back to PTY drive (--allowedTools is additive in interactive mode; only --settings with defaultMode:"dontAsk" replicates -p semantics — the documented value per Anthropic's agent-sdk/permissions docs, restored here after #487).

MUST NOT log the allowedTools slice, the JSON payload, or the returned path. Tool names are operational config rather than secret material, but the parent agentrun package family's no-content-logging discipline applies to every subpackage uniformly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteSettings

func WriteSettings(allowedTools []string) (string, error)

WriteSettings generates a per-spawn deny-default permissions JSON file in os.TempDir() and returns the absolute path of the written file. The caller is responsible for cleanup via `defer os.Remove(path)`; the helper does not register cleanup itself on the success path.

JSON shape (compact, no whitespace, trailing \n from json.Encoder.Encode):

{"permissions":{"allow":[<allowedTools>],"defaultMode":"dontAsk"},"enableAllProjectMcpServers":true}

allowedTools is round-tripped verbatim — element order and any duplicates are preserved. The helper performs no deduplication, no sorting, and no canonicalisation.

Validation: returns a non-nil error before any file is created when len(allowedTools) == 0. The caller has already validated non-emptiness at the CLI parse boundary (#470); this check is defence-in-depth.

Tempfile naming: written via os.CreateTemp(os.TempDir(), "pyry-agent-run-settings-*.json"); the random infix is owned by the OS.

Error path: if any operation after os.CreateTemp returns successfully fails (Encode, Close), the helper best-effort removes the tempfile before returning the error. Callers never see a leaked path on the error path — they only get a path on success.

func WriteSettingsWithDeny added in v0.16.0

func WriteSettingsWithDeny(allowedTools, disallowedTools []string) (string, error)

WriteSettingsWithDeny is WriteSettings plus an optional permissions.deny list. Semantics for allowedTools (verbatim round-trip, order + duplicates preserved, non-empty required) are identical to WriteSettings.

disallowedTools lands in permissions.deny, round-tripped verbatim (order and duplicates preserved, no canonicalisation). It is optional: a nil or empty slice omits the "deny" key entirely, producing bytes identical to WriteSettings(allowedTools). Listing a tool in deny removes it from the model's tool surface — it is not offered, not called, no runtime-denial event (#411, origin #398).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL