Documentation
¶
Index ¶
- Constants
- func CheckSensitiveFile(m *ignore.SensitiveMatcher, path string, isDir bool) (bool, string, error)
- func ClassifyDanger(toolName string, args json.RawMessage, workspaceRoot string) (bool, string)
- func DescribeFlags(flagged []string) string
- func DescribeRedactions(hits []string) string
- func InvalidateSensitiveIdentityCache(root string)
- func IsBlockedByIdentity(set []os.FileInfo, info os.FileInfo) bool
- func RedactToolOutput(output string) (string, []string)
- func ScrubbedEnv(extra []string) []string
- func SensitiveIdentitySet(root string, m *ignore.SensitiveMatcher) []os.FileInfo
- func ToolAction(tool Tool) string
- func ValidatePath(workspaceRoot, requestedPath string) (string, error)
- func WithHookApproval(ctx context.Context, toolCallID string) context.Context
- type ActionTool
- type ApprovalChoice
- type ApprovalGate
- func (g *ApprovalGate) AutoApproveSession(sessionID string)
- func (g *ApprovalGate) BeginTurn()
- func (g *ApprovalGate) GrantHookApproval(toolCallID string)
- func (g *ApprovalGate) InheritAutoApproval(parent, child string)
- func (g *ApprovalGate) IsAutoApproved(toolName string) bool
- func (g *ApprovalGate) IsDenied(toolName string) bool
- func (g *ApprovalGate) Mode() PermissionMode
- func (g *ApprovalGate) PendingRequestIDs() []string
- func (g *ApprovalGate) Prepare(ctx context.Context, tool Tool, args json.RawMessage) (func(context.Context) (Result, error), error)
- func (g *ApprovalGate) PrepareWithID(ctx context.Context, tool Tool, args json.RawMessage, toolCallID string) (func(context.Context) (Result, error), error)
- func (g *ApprovalGate) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)
- func (g *ApprovalGate) Resolve(id string, choice ApprovalChoice) bool
- func (g *ApprovalGate) SessionGrantCount() int
- func (g *ApprovalGate) SessionGrantKeys() []PermissionKey
- func (g *ApprovalGate) SetDangerTools(names []string)
- func (g *ApprovalGate) SetInputReader(r *bufio.Reader)
- func (g *ApprovalGate) SetMode(mode PermissionMode) error
- func (g *ApprovalGate) SetPermissions(autoApprove, deny []string)
- func (g *ApprovalGate) SetSessionID(id string)
- func (g *ApprovalGate) SetWorkspaceRoot(root string)
- func (g *ApprovalGate) WrapExecution(ctx context.Context, tool Tool, args json.RawMessage) (Result, error)
- type ApprovalPrompt
- type CodeSearchTool
- type FilePatchTool
- type FileReadTool
- type FileWriteTool
- type PermissionBus
- type PermissionKey
- type PermissionMode
- type PlanItem
- type PlanStore
- type PlanTool
- type Preview
- type Previewer
- type PromptObserver
- type PromptOutcome
- type ReadOnlyTool
- type Registry
- type Result
- type ScratchpadStore
- type ScratchpadTool
- type ShellExecTool
- type ShellGuard
- type Tool
- type ToolSpec
Constants ¶
const ( PlanStatusPending = "pending" PlanStatusInProgress = "in_progress" PlanStatusDone = "done" )
Plan item statuses accepted by the plan tool.
const MaxScratchpadBytes = 8 * 1024
MaxScratchpadBytes bounds the working-state text the model may record. It is small on purpose: the scratchpad is a compaction-safe summary, not a log.
Variables ¶
This section is empty.
Functions ¶
func CheckSensitiveFile ¶ added in v0.7.0
CheckSensitiveFile rejects normalisation tricks, then applies ignore and case-folded sensitive checks.
func ClassifyDanger ¶ added in v0.8.0
ClassifyDanger reports whether a tool invocation looks destructive and why. workspaceRoot may be empty (the process working directory is used as the containment base then). Invalid or missing args are never dangerous by themselves — execution-time validation still applies.
func DescribeFlags ¶ added in v0.5.0
DescribeFlags renders the advisory warnings shown in the approval preview.
func DescribeRedactions ¶ added in v0.5.0
DescribeRedactions renders a note listing which secret patterns were masked.
func InvalidateSensitiveIdentityCache ¶ added in v0.7.4
func InvalidateSensitiveIdentityCache(root string)
InvalidateSensitiveIdentityCache drops cached identity sets for root. It is called after a successful file_write/file_patch so approvals and subsequent checks never rely on pre-write identities for the TTL window.
func IsBlockedByIdentity ¶ added in v0.7.0
IsBlockedByIdentity reports whether info is SameFile-equal to any entry in set.
func RedactToolOutput ¶ added in v0.7.0
RedactToolOutput masks credential-shaped values unconditionally. SECURITY: it is the transcript boundary.
func ScrubbedEnv ¶ added in v0.7.4
ScrubbedEnv returns os.Environ minus credential-shaped variables and any names or patterns in extra. Essential variables always survive. Child processes therefore never inherit provider API keys by default.
func SensitiveIdentitySet ¶ added in v0.7.0
func SensitiveIdentitySet(root string, m *ignore.SensitiveMatcher) []os.FileInfo
SensitiveIdentitySet returns FileInfo of blocked files. SECURITY: hardlink aliases match by identity. Callers filter candidates by identity instead of by name.
The set is cached per (normalized root, matcher) for sensitiveIdentityCacheTTL and MUST be treated as read-only: the returned slice may be shared with other callers, so callers must never mutate or append to it. Invalidate the cache with InvalidateSensitiveIdentityCache after modifying the workspace.
func ToolAction ¶ added in v0.8.0
ToolAction reports the action component for a tool: the ActionTool interface when implemented, otherwise the documented built-in mapping. MCP and future tools opt in via the interface.
func ValidatePath ¶ added in v0.4.0
ValidatePath ensures the requested path resolves inside the workspace root. Returns the absolute path.
func WithHookApproval ¶ added in v0.8.0
WithHookApproval stamps ctx with a hook approval for toolCallID. The gate honors it only when the same call id was registered via GrantHookApproval and the call being prepared carries that exact id.
Types ¶
type ActionTool ¶ added in v0.8.0
type ActionTool interface {
Action() string
}
ActionTool is implemented by tools that expose a sub-action for "tool:action" permission matching. Tools without it have an empty action.
type ApprovalChoice ¶ added in v0.7.4
type ApprovalChoice int
ApprovalChoice is the user's answer to an approval prompt. It is richer than a bool so a UI can offer once-only, session-scoped, and edit paths.
const ( // ApprovalDeny rejects this invocation. ApprovalDeny ApprovalChoice = iota // ApprovalOnce approves this invocation only. ApprovalOnce // ApprovalGrantExact approves this invocation and remembers its keyed // grant (tool, action, directory, grant key) for the life of this gate. ApprovalGrantExact // ApprovalReadOnlyTurn allows tools that declare themselves read-only for // the rest of the current turn. ApprovalReadOnlyTurn // ApprovalEdit asks the gate to collect edited arguments and re-prompt. ApprovalEdit )
func (ApprovalChoice) Approved ¶ added in v0.7.4
func (c ApprovalChoice) Approved() bool
Approved reports whether the choice approves the current invocation. The read-only flag itself is not an approval of the pending call: the gate re-checks whether that particular tool is read-only.
type ApprovalGate ¶
type ApprovalGate struct {
// SessionScope maps a session to a prompt queue. Nil means
// the default GLOBAL scope: one prompt at a time app-wide. Different
// scopes never wait on each other.
SessionScope func(ctx context.Context, sessionID string) string
// Bus, when set, receives permission_request / permission_notification /
// permission_mode_changed payloads (must-deliver on the bus). Nil-safe.
Bus PermissionBus
// Observer is the async PromptShown/PromptResolved tap. It
// runs off the requesting goroutine and cannot delay or alter a decision.
Observer PromptObserver
// OnPresentPrompt is the richest presentation hook: it receives the
// request id and the danger reason. When set it takes precedence over
// OnPresentChoice and OnPresent.
OnPresentPrompt func(ApprovalPrompt) (ApprovalChoice, error)
OnPresent func(toolName string, args json.RawMessage, preview string) (bool, error)
// OnPresentChoice is the choice-aware presentation hook. When set it takes
// precedence over OnPresent, letting a UI return grant/read-only/edit
// choices instead of a plain yes/no.
OnPresentChoice func(toolName string, args json.RawMessage, preview string) (ApprovalChoice, error)
// EditArgs collects replacement arguments when the user chooses edit. The
// gate validates the result, regenerates the preview when it has one, and
// re-prompts exactly once. Nil means editing is unavailable.
EditArgs func(toolName string, args json.RawMessage) (json.RawMessage, error)
// OnDecision, when set, observes every approval outcome: auto-approved,
// denied by policy, and user-decided. It cannot alter the decision; the
// loop uses it for per-turn metrics. Nil means no observer.
OnDecision func(toolName string, approved bool, auto bool)
// contains filtered or unexported fields
}
func NewApprovalGate ¶
func NewApprovalGate() *ApprovalGate
func NewApprovalGateWithPermissions ¶ added in v0.2.0
func NewApprovalGateWithPermissions(autoApprove, deny []string) *ApprovalGate
func (*ApprovalGate) AutoApproveSession ¶ added in v0.8.0
func (g *ApprovalGate) AutoApproveSession(sessionID string)
AutoApproveSession marks a session as never-prompting: every approval-gated call that survives the deny-list, mode and config checks is granted with a Granted notification. Headless opt-in uses it; interactive sessions never set it.
func (*ApprovalGate) BeginTurn ¶ added in v0.7.4
func (g *ApprovalGate) BeginTurn()
BeginTurn clears the per-turn read-only flag and any unconsumed per-call hook approvals: a hook approval is per-call only and never outlives the turn that set it. Session grants intentionally survive: they are scoped to the gate, not to a turn. RunTurn calls this at the top of every user turn so the flag never outlives the turn that set it.
func (*ApprovalGate) GrantHookApproval ¶ added in v0.8.0
func (g *ApprovalGate) GrantHookApproval(toolCallID string)
GrantHookApproval registers a one-shot hook approval for toolCallID. The loop calls it when a PreToolUse aggregation answers allow; the matching PrepareWithID consumes it. An empty id is ignored.
func (*ApprovalGate) InheritAutoApproval ¶ added in v0.8.0
func (g *ApprovalGate) InheritAutoApproval(parent, child string)
InheritAutoApproval copies a parent session's auto-approval to a child (future subagents): otherwise a subagent would deadlock on a prompt nobody can answer. A parent without auto-approval grants nothing.
func (*ApprovalGate) IsAutoApproved ¶ added in v0.2.0
func (g *ApprovalGate) IsAutoApproved(toolName string) bool
IsAutoApproved reports whether the bare tool name is allowlisted (every action of that tool). "tool:action" entries are checked by isAutoApprovedAction with the call's action.
func (*ApprovalGate) IsDenied ¶ added in v0.2.0
func (g *ApprovalGate) IsDenied(toolName string) bool
func (*ApprovalGate) Mode ¶ added in v0.8.0
func (g *ApprovalGate) Mode() PermissionMode
Mode reports the current prompt policy.
func (*ApprovalGate) PendingRequestIDs ¶ added in v0.8.0
func (g *ApprovalGate) PendingRequestIDs() []string
PendingRequestIDs lists the ids of currently open prompts (inspection/tests).
func (*ApprovalGate) Prepare ¶ added in v0.7.4
func (g *ApprovalGate) Prepare(ctx context.Context, tool Tool, args json.RawMessage) (func(context.Context) (Result, error), error)
Prepare runs the whole decision flow — permissions, mode, session grants, the per-turn read-only flag, preview, and the user prompt — and returns a closure that runs the approved call with the final arguments. A denial returns a closure that reports the denial Result and never executes the tool.
Running every decision before any execution lets a caller prompt for a whole batch in a deterministic order and then execute independent calls concurrently. Prepare only mutates gate state (grants, read-only flag, decision observers); the closure only runs the tool.
func (*ApprovalGate) PrepareWithID ¶ added in v0.8.0
func (g *ApprovalGate) PrepareWithID(ctx context.Context, tool Tool, args json.RawMessage, toolCallID string) (func(context.Context) (Result, error), error)
PrepareWithID is Prepare with the model's tool-call id, carried onto the bus PermissionRequest so observers can correlate prompt and call.
func (*ApprovalGate) RequestApproval ¶
func (g *ApprovalGate) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)
RequestApproval is the legacy yes/no entry point. It accepts the same keys as the full prompt; a grant it records has the same session scope. Mode and keyed grants apply here too, and the deny-list still outranks everything.
func (*ApprovalGate) Resolve ¶ added in v0.8.0
func (g *ApprovalGate) Resolve(id string, choice ApprovalChoice) bool
Resolve answers a pending request by id (the only thing a responder ever echoes). The FIRST terminal answer wins; later answers are no-ops returning false. Resolution uses the server-stored request parameters, so a dishonest responder cannot widen the grant. Edit is not a terminal answer and is rejected here (the edit pass is gate-internal, driven by the prompt hook).
func (*ApprovalGate) SessionGrantCount ¶ added in v0.7.4
func (g *ApprovalGate) SessionGrantCount() int
SessionGrantCount reports how many keyed grants this gate holds.
func (*ApprovalGate) SessionGrantKeys ¶ added in v0.8.0
func (g *ApprovalGate) SessionGrantKeys() []PermissionKey
SessionGrantKeys returns a copy of the remembered grant keys (inspection and tests; the footer renders tool names from the UI side).
func (*ApprovalGate) SetDangerTools ¶ added in v0.8.0
func (g *ApprovalGate) SetDangerTools(names []string)
SetDangerTools installs the configurable per-tool danger list ([permissions] dangerous_tools). Listed tools are always classified dangerous, on top of the pure classifier's rules.
func (*ApprovalGate) SetInputReader ¶ added in v0.5.0
func (g *ApprovalGate) SetInputReader(r *bufio.Reader)
SetInputReader makes the gate read answers from r. Callers sharing the stream must pass their reader.
func (*ApprovalGate) SetMode ¶ added in v0.8.0
func (g *ApprovalGate) SetMode(mode PermissionMode) error
SetMode switches the prompt policy and publishes permission_mode_changed on the bus when the mode actually changes. Unknown modes are rejected.
func (*ApprovalGate) SetPermissions ¶ added in v0.2.0
func (g *ApprovalGate) SetPermissions(autoApprove, deny []string)
func (*ApprovalGate) SetSessionID ¶ added in v0.8.0
func (g *ApprovalGate) SetSessionID(id string)
SetSessionID binds the gate to the session whose grants it remembers. NewAgentLoop installs it; a gate without one uses the empty session id.
func (*ApprovalGate) SetWorkspaceRoot ¶ added in v0.8.0
func (g *ApprovalGate) SetWorkspaceRoot(root string)
SetWorkspaceRoot sets the containment base for danger classification and path normalization. The loop installs it at the start of every turn.
func (*ApprovalGate) WrapExecution ¶
func (g *ApprovalGate) WrapExecution(ctx context.Context, tool Tool, args json.RawMessage) (Result, error)
WrapExecution runs preview → approval → execute. Denied operations never call Execute.
type ApprovalPrompt ¶ added in v0.8.0
type ApprovalPrompt struct {
ID string
ToolName string
Args json.RawMessage
Preview string
Danger string
}
ApprovalPrompt is the full presentation payload handed to OnPresentPrompt. Danger is empty for non-dangerous calls, otherwise the classifier reason.
type CodeSearchTool ¶ added in v0.4.0
type CodeSearchTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
// MaxFileBytes skips files larger than this; 0 uses defaultMaxSearchFileBytes.
MaxFileBytes int64
// MaxScanLines caps lines scanned per file; 0 uses defaultSearchScanLines.
MaxScanLines int
}
CodeSearchTool searches for patterns across workspace files.
func (*CodeSearchTool) Execute ¶ added in v0.4.0
func (c *CodeSearchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*CodeSearchTool) RequiresApproval ¶ added in v0.4.0
func (c *CodeSearchTool) RequiresApproval() bool
func (*CodeSearchTool) Spec ¶ added in v0.4.0
func (c *CodeSearchTool) Spec() ToolSpec
type FilePatchTool ¶
type FilePatchTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
OnModified func(path string)
// contains filtered or unexported fields
}
func (*FilePatchTool) Execute ¶
func (f *FilePatchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
Execute applies the patch. Called only after approval.
func (*FilePatchTool) Preview ¶ added in v0.4.0
func (f *FilePatchTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview shows a diff preview without modifying files.
func (*FilePatchTool) RequiresApproval ¶
func (f *FilePatchTool) RequiresApproval() bool
func (*FilePatchTool) Spec ¶
func (f *FilePatchTool) Spec() ToolSpec
type FileReadTool ¶
type FileReadTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
// MaxFileBytes bounds whole-file reads; 0 uses defaultMaxFileBytes. Ranged
// reads (offset/limit) stream instead of rejecting an oversized file.
MaxFileBytes int64
}
func (*FileReadTool) Execute ¶
func (f *FileReadTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*FileReadTool) RequiresApproval ¶
func (f *FileReadTool) RequiresApproval() bool
func (*FileReadTool) Spec ¶
func (f *FileReadTool) Spec() ToolSpec
type FileWriteTool ¶
type FileWriteTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
OnModified func(path string)
// contains filtered or unexported fields
}
func (*FileWriteTool) Execute ¶
func (f *FileWriteTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
Execute writes the file. Called only after approval.
func (*FileWriteTool) Preview ¶ added in v0.4.0
func (f *FileWriteTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview shows a diff preview without modifying files.
func (*FileWriteTool) RequiresApproval ¶
func (f *FileWriteTool) RequiresApproval() bool
func (*FileWriteTool) Spec ¶
func (f *FileWriteTool) Spec() ToolSpec
type PermissionBus ¶ added in v0.8.0
type PermissionBus interface {
PublishPermissionRequest(ctx context.Context, req pubsub.PermissionRequest)
PublishPermissionNotification(ctx context.Context, n pubsub.PermissionNotification)
PublishPermissionModeChanged(ctx context.Context, change pubsub.PermissionModeChanged)
}
PermissionBus is the gate's view of the event bus. The agent loop implements it by publishing LoopEvents; the gate never imports the agent package. All publishes are nil-safe and must-deliver on the bus side.
type PermissionKey ¶ added in v0.8.0
type PermissionKey struct {
SessionID string
ToolName string
Action string
Path string
GrantKey string
}
PermissionKey identifies one remembered session grant. In-memory only, cleared on process exit. Path is normalized to a DIRECTORY (file → its dir, "." → the workspace). GrantKey narrows the grant: shell tools use the command string (approving ls does not approve sudo); every other tool uses the canonical exact arguments, preserving the historical exact-args grant class.
type PermissionMode ¶ added in v0.8.0
type PermissionMode string
PermissionMode selects the prompt policy.
const ( // ModeNormal prompts for approval-gated calls (the historical flow). ModeNormal PermissionMode = "normal" // ModeYolo skips prompts for non-dangerous calls and REFUSES dangerous // calls without asking, naming the way out in the tool result. ModeYolo PermissionMode = "yolo" )
func (PermissionMode) RefusesDangerous ¶ added in v0.8.0
func (m PermissionMode) RefusesDangerous() bool
RefusesDangerous reports whether dangerous calls are refused outright (yolo only; normal prompts with a danger warning instead).
func (PermissionMode) SkipsPrompts ¶ added in v0.8.0
func (m PermissionMode) SkipsPrompts() bool
SkipsPrompts reports whether the mode answers approval-gated calls without a user prompt.
func (PermissionMode) Valid ¶ added in v0.8.0
func (m PermissionMode) Valid() bool
Valid reports whether m is a known mode.
type PlanItem ¶ added in v0.7.4
type PlanItem struct {
ID string `json:"id"`
Text string `json:"text"`
Status string `json:"status"`
}
PlanItem is one entry in an agent-maintained task list.
type PlanStore ¶ added in v0.7.4
type PlanStore struct {
// contains filtered or unexported fields
}
PlanStore holds the current plan. It is shared by the plan tool, which writes it, and the agent loop, which renders it into the system prompt.
func NewPlanStore ¶ added in v0.7.4
func NewPlanStore() *PlanStore
NewPlanStore returns an empty store.
type PlanTool ¶ added in v0.7.4
type PlanTool struct {
Store *PlanStore
}
PlanTool lets the model maintain a task list for multi-step work. It only records text; it cannot touch the workspace, so it needs no approval.
func (*PlanTool) RequiresApproval ¶ added in v0.7.4
RequiresApproval is false: the tool only records text in the session.
type Preview ¶ added in v0.4.0
type Preview struct {
Description string `json:"description,omitempty"`
Diff string `json:"diff,omitempty"`
Command string `json:"command,omitempty"`
WorkDir string `json:"work_dir,omitempty"`
}
Preview contains the information shown to the user before approval.
type Previewer ¶ added in v0.4.0
Previewer optionally provides a preview for approval before execution.
type PromptObserver ¶ added in v0.8.0
type PromptObserver interface {
PromptShown(req pubsub.PermissionRequest)
PromptResolved(req pubsub.PermissionRequest, outcome PromptOutcome)
}
PromptObserver is the async audit tap. Both methods run OFF the requesting goroutine, so a slow observer never delays the tool. hooks attach here. Panics inside an observer are contained.
type PromptOutcome ¶ added in v0.8.0
type PromptOutcome int
PromptOutcome is the terminal state of a permission prompt.
const ( PromptGranted PromptOutcome = iota PromptDenied PromptCancelled )
func (PromptOutcome) String ¶ added in v0.8.0
func (o PromptOutcome) String() string
type ReadOnlyTool ¶ added in v0.7.4
type ReadOnlyTool interface {
ReadOnly() bool
}
ReadOnlyTool is implemented by tools that are safe to auto-approve for a turn after the user chooses "read-only tools this turn". Built-in read-only tools do not prompt at all; the interface is for MCP and future tools that require approval even when they only read.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
type Result ¶
type Result struct {
Output string `json:"output,omitempty"`
Error string `json:"error,omitempty"`
Diff string `json:"diff,omitempty"`
}
func RedactToolResult ¶ added in v0.7.4
RedactToolResult applies the same transcript boundary to a result a caller executed itself from a Prepare closure. It cannot be turned off.
type ScratchpadStore ¶ added in v0.7.4
type ScratchpadStore struct {
// contains filtered or unexported fields
}
ScratchpadStore holds agent-maintained working state (goal, decisions, open files) that must survive history compaction. It is shared by the scratchpad tool, which writes it, and the agent loop, which mirrors it into the session and therefore into the system prompt.
func NewScratchpadStore ¶ added in v0.7.4
func NewScratchpadStore() *ScratchpadStore
NewScratchpadStore returns an empty store.
func (*ScratchpadStore) Append ¶ added in v0.7.4
func (s *ScratchpadStore) Append(content string) error
Append adds content after the existing scratchpad, separating the parts with a newline. The combined text must fit MaxScratchpadBytes.
func (*ScratchpadStore) Get ¶ added in v0.7.4
func (s *ScratchpadStore) Get() string
Get returns the raw scratchpad text.
func (*ScratchpadStore) Render ¶ added in v0.7.4
func (s *ScratchpadStore) Render() string
Render returns the scratchpad text trimmed for prompt rendering. An empty scratchpad renders as the empty string.
func (*ScratchpadStore) Set ¶ added in v0.7.4
func (s *ScratchpadStore) Set(content string) error
Set replaces the whole scratchpad. Content larger than MaxScratchpadBytes is rejected and leaves the previous value untouched. An empty value clears it.
type ScratchpadTool ¶ added in v0.7.4
type ScratchpadTool struct {
Store *ScratchpadStore
}
ScratchpadTool lets the model record working state that must survive compaction. It only records text; it cannot touch the workspace, so it needs no approval.
func (*ScratchpadTool) Execute ¶ added in v0.7.4
func (t *ScratchpadTool) Execute(_ context.Context, args json.RawMessage) (Result, error)
func (*ScratchpadTool) RequiresApproval ¶ added in v0.7.4
func (t *ScratchpadTool) RequiresApproval() bool
RequiresApproval is false: the tool only records text in the session.
func (*ScratchpadTool) Spec ¶ added in v0.7.4
func (t *ScratchpadTool) Spec() ToolSpec
type ShellExecTool ¶
type ShellExecTool struct {
Timeout time.Duration
WorkspaceRoot string
MaxOutputBytes int
// EnvScrub lists additional env var names or patterns to drop from the
// child process environment, on top of the built-in credential patterns.
EnvScrub []string
// Guard redacts secrets and warns about sensitive paths in previews. May be nil.
Guard *ShellGuard
}
func (*ShellExecTool) Execute ¶
func (s *ShellExecTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*ShellExecTool) Preview ¶ added in v0.4.0
func (s *ShellExecTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview returns command execution metadata without running the command.
func (*ShellExecTool) RequiresApproval ¶
func (s *ShellExecTool) RequiresApproval() bool
func (*ShellExecTool) Spec ¶
func (s *ShellExecTool) Spec() ToolSpec
type ShellGuard ¶ added in v0.5.0
type ShellGuard struct {
// SensitiveMatcher flags sensitive paths. May be nil; redaction still applies.
SensitiveMatcher *ignore.SensitiveMatcher
// RedactSecretOutput enables redaction of secret-shaped values in output.
RedactSecretOutput bool
}
ShellGuard redacts secrets from shell output and warns about sensitive paths. It does not sandbox the shell. SECURITY: file tools stay confined via ValidatePath; the shell is advisory-only.
func (*ShellGuard) FlagSensitivePaths ¶ added in v0.5.0
func (g *ShellGuard) FlagSensitivePaths(command string) []string
FlagSensitivePaths returns sensitive paths referenced by a command for the approval preview. Advisory only.
func (*ShellGuard) RedactSecrets ¶ added in v0.5.0
func (g *ShellGuard) RedactSecrets(output string) (string, []string)
RedactSecrets masks secret-shaped values. With redaction disabled the text is unchanged.