Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowCommand ¶
func AllowCommand(profile Profile, risk CommandRisk, interactive bool) error
AllowCommand decides whether a slash command can run under current policy profile.
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Time time.Time
Profile Profile
Tool string
Args map[string]any
Allow bool
Reason string // empty when allowed
}
AuditEntry is the data passed to an optional audit hook.
type CommandRisk ¶
type CommandRisk string
CommandRisk describes slash-command risk level.
const ( RiskLow CommandRisk = "low" RiskMedium CommandRisk = "medium" RiskHigh CommandRisk = "high" )
type Config ¶
type Config struct {
Profile Profile
Workspace string
Interactive bool
OnAudit func(AuditEntry) // nil = no auditing
AllowedCommands []string // pre-loaded from project config
}
Config configures the policy engine.
type ConfirmFunc ¶ added in v0.0.2
type ConfirmFunc func(ctx context.Context, req PermitRequest) (PermitDecision, error)
ConfirmFunc blocks until the user makes a permission decision.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine validates tool calls before execution.
func (*Engine) Permission ¶
Permission validates one tool call.
func (*Engine) SetConfirmFn ¶ added in v0.0.2
func (e *Engine) SetConfirmFn(fn ConfirmFunc)
SetConfirmFn sets the interactive confirmation callback. Called by the TUI layer after the tea.Program is created.
func (*Engine) SetPersistFn ¶ added in v0.0.2
SetPersistFn sets the callback to persist "always allow" commands to project config.
type PermitDecision ¶ added in v0.0.2
type PermitDecision int
PermitDecision is the user's response to an interactive permission prompt.
const ( PermitDeny PermitDecision = iota PermitAllowOnce // allow this invocation only PermitAllowSession // allow for the rest of the session PermitAllowAlways // persist to project config )
type PermitRequest ¶ added in v0.0.2
type PermitRequest struct {
Tool string // e.g. "bash"
Command string // full command text
Reason string // e.g. "dangerous command: sudo"
}
PermitRequest describes the operation awaiting user approval.