preset
import "github.com/barevoidco/zelk/core/preset"Package preset defines host defaults for the two common ways of running zelk: an interactive terminal (CLI) and an unattended server (Server). Constructors seal a validated preset; Settings returns an isolated snapshot. zelk.WithPreset applies it, and zelk.New fails when later options contradict what a preset guarantees. Presets never depend on the model.
Variables
Section titled “Variables”var ErrInvalid = defaults.ErrInvalidErrInvalid reports a preset whose guarantees cannot be met.
Preset
Section titled “Preset”type Preset struct { // contains filtered or unexported fields}Preset is a validated set of host defaults. Construct one with CLI or Server. Its zero value is invalid. Settings returns a snapshot, not a mutable preset.
func CLI() PresetCLI returns interactive defaults with callback input and all terminal modes.
Server
Section titled “Server”func Server(opts ServerOptions) (Preset, error)Server returns bounded unattended defaults with suspended input and no shell.
Example
p, err := preset.Server(preset.ServerOptions{Budget: event.Budget{Total: event.Limit{Max: 500000}}})if err != nil { panic(err)}settings := p.Settings()fmt.Println(settings.Mode, settings.Input, settings.NoShell)// Output: auto suspend trueOutput:
auto suspend truePreset.Settings
Section titled “Preset.Settings”func (p Preset) Settings() SettingsSettings returns a snapshot that shares no mutable configuration with p.
ServerOptions
Section titled “ServerOptions”type ServerOptions struct { // Mode is auto or plan; auto is the default. Mode permission.Mode // Budget is the hard token budget of each run. Required: an // unattended server never runs without one. Every limit must be hard. Budget event.Budget // ApprovalTimeout expires an approval or question no one answered, // which then means deny. The default is one hour. ApprovalTimeout time.Duration // MaxTurns and MaxTime bound each run; the defaults are 100 turns // and an hour. MaxTurns int MaxTime time.Duration}ServerOptions configure the server preset.
Settings
Section titled “Settings”type Settings struct { // Name names the preset in errors. Name string // Mode is the starting mode; Modes the modes switches may select. Mode permission.Mode Modes []permission.Mode // Input is how approvals and questions are answered; InputTimeout // expires an unanswered one, which then fails closed: a denial. Input event.InputPolicy InputTimeout time.Duration // NoShell guarantees sessions can't reach a shell: no Bash or process // tools, and zelk.New fails if the host configures one. NoShell bool // Budget is a hard token budget for each run; nil sets none. Budget *event.Budget // MaxTurns and MaxTime bound each run; zero sets no bound. MaxTurns int MaxTime time.Duration}Settings is a read-only snapshot of a preset’s host defaults.