presets

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package presets implements agent presets, matching core/agent-preset. Each preset combines independent tools and prompts for an agent instance. The registry groups presets by standingKey: composeFrom overlays matching presets, recompose rebuilds the combination, and select chooses by key.

Permission presets combine sandbox mode and approval policy (M28), matching interaction/permission-presets. Built-ins are safe, danger, review, and custom; custom supplies a baseline for user overrides. Injected policy mappings avoid a dependency cycle with approval. DerivedState exposes the final preset and override combination to UI and SDK consumers.

Index

Constants

View Source
const (
	PresetSafe   = "safe"
	PresetDanger = "danger"
	PresetReview = "review"
	PresetCustom = "custom"
)

Preset names.

Variables

This section is empty.

Functions

func ApprovalMapper

func ApprovalMapper() func(string) (approval.Policy, bool)

ApprovalMapper supplies preset-to-policy mapping to approval.Service. Unknown presets use the custom ask-dangerous policy.

func PresetNames

func PresetNames() []string

PresetNames returns built-in names in lexical order.

func SandboxMapper

func SandboxMapper() func(string) (sandbox.SandboxMode, bool)

SandboxMapper maps preset names to sandbox modes.

Types

type AgentPreset

type AgentPreset struct {
	// Key is the standing key.
	Key StandingKey
	// Tools contains the allowed tool names for this preset.
	Tools []string
	// Prompt contains a system-prompt fragment.
	Prompt string
}

AgentPreset combines an agent preset's settings.

func ComposeFrom

func ComposeFrom(key StandingKey, bases ...*AgentPreset) *AgentPreset

ComposeFrom combines base presets using a tool union and concatenated prompts.

type DerivedState

type DerivedState struct {
	// ActivePreset names the effective preset.
	ActivePreset string `json:"activePreset"`
	// SandboxMode includes any custom override.
	SandboxMode sandbox.SandboxMode `json:"sandboxMode"`
	// ApprovalPolicy is the derived approval policy.
	ApprovalPolicy approval.Policy `json:"approvalPolicy"`
	// IsCustom indicates a custom derived state.
	IsCustom bool `json:"isCustom"`
}

DerivedState exposes permission state after preset and override resolution.

func Derive

func Derive(presetName string, sandboxOverride *sandbox.SandboxMode, approvalOverride *approval.Policy) DerivedState

Derive applies optional sandbox and approval overrides to a preset. Nonnil overrides replace their fields; IsCustom signals the resulting custom state.

type PermissionPreset

type PermissionPreset struct {
	// Name identifies the preset.
	Name string `json:"name"`
	// SandboxMode is the preset's sandbox mode.
	SandboxMode sandbox.SandboxMode `json:"sandboxMode"`
	// ApprovalPolicy is the preset's approval policy.
	ApprovalPolicy approval.Policy `json:"approvalPolicy"`
}

PermissionPreset combines sandbox mode and approval policy.

func Resolve

func Resolve(name string) (PermissionPreset, bool)

Resolve resolves a preset name, falling back to the custom baseline for unknown names.

type PresetRegistry

type PresetRegistry struct {
	// contains filtered or unexported fields
}

PresetRegistry layers host defaults and scoped overrides for agent presets.

func NewPresetRegistry

func NewPresetRegistry() *PresetRegistry

NewPresetRegistry creates an empty registry.

func (*PresetRegistry) Mount

func (r *PresetRegistry) Mount(p *AgentPreset)

Mount installs a host-layer preset, replacing the same name while retaining others.

func (*PresetRegistry) Recompose

func (r *PresetRegistry) Recompose(p *AgentPreset)

Recompose replaces a key's composition with a new preset.

func (*PresetRegistry) Select

func (r *PresetRegistry) Select(key StandingKey) (*AgentPreset, bool)

Select resolves a key using nearest-scope-wins.

type StandingKey

type StandingKey string

StandingKey is a persistent preset key such as code, research, or default.

func StandingKeyFor

func StandingKeyFor(key StandingKey) StandingKey

StandingKeyFor returns the agent's standing key; currently it returns the supplied key.

Jump to

Keyboard shortcuts

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