agent

package
v0.1.57 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHookOutputCapBytes = 256 * 1024
	DefaultHookTimeout        = 600 * time.Second
	MinimumHookTimeout        = time.Second
)

Variables

View Source
var ErrBudgetExceeded = errors.New("session budget exhausted")
View Source
var ErrSessionBusy = errors.New("session is currently processing another request")

Functions

func FormatPlanUpdateForDisplay added in v0.1.15

func FormatPlanUpdateForDisplay(update PlanUpdateInfo) string

func HookActiveTrust added in v0.1.32

func HookActiveTrust(entry HookListEntry) bool

func HookNeedsReview added in v0.1.32

func HookNeedsReview(entry HookListEntry) bool

func KnownHookEvent added in v0.1.32

func KnownHookEvent(event HookEvent) bool

func WorkflowAuthoringSystemBlock added in v0.1.43

func WorkflowAuthoringSystemBlock() string

Types

type Agent

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

func NewAgent

func NewAgent(provider llm.Provider, store store.MessageStore, tools []core.Tool) *Agent

func NewAgentWithRegistry

func NewAgentWithRegistry(provider llm.Provider, store store.MessageStore, tools *core.ToolRegistry, opts ...AgentOption) *Agent

func (*Agent) CompactSession

func (a *Agent) CompactSession(ctx context.Context, sessionID string) (CompactInfo, error)

func (*Agent) InjectTurnInput added in v0.1.35

func (a *Agent) InjectTurnInput(ctx context.Context, sessionID string, newMessages []core.Message) (bool, error)

func (*Agent) RunSession added in v0.1.24

func (a *Agent) RunSession(ctx context.Context, sessionID, input string) (core.Message, error)

func (*Agent) RunSideQuestion added in v0.1.17

func (a *Agent) RunSideQuestion(ctx context.Context, sessionID, question string) (<-chan SideQuestionEvent, error)

func (*Agent) RunSideQuestionWithOptions added in v0.1.21

func (a *Agent) RunSideQuestionWithOptions(ctx context.Context, sessionID, question string, opts RunOptions) (<-chan SideQuestionEvent, error)

func (*Agent) RunStream

func (a *Agent) RunStream(ctx context.Context, sessionID, input string) (<-chan AgentEvent, error)

func (*Agent) RunStreamWithContentOptions added in v0.1.39

func (a *Agent) RunStreamWithContentOptions(ctx context.Context, sessionID string, parts []core.MessagePart, opts RunOptions) (<-chan AgentEvent, error)

func (*Agent) RunStreamWithInjectedContentOptions added in v0.1.39

func (a *Agent) RunStreamWithInjectedContentOptions(ctx context.Context, sessionID string, visibleParts []core.MessagePart, hiddenInput string, opts RunOptions) (<-chan AgentEvent, error)

func (*Agent) RunStreamWithInjectedInput added in v0.1.4

func (a *Agent) RunStreamWithInjectedInput(ctx context.Context, sessionID, visibleInput, hiddenInput string) (<-chan AgentEvent, error)

func (*Agent) RunStreamWithInjectedInputOptions added in v0.1.17

func (a *Agent) RunStreamWithInjectedInputOptions(ctx context.Context, sessionID, visibleInput, hiddenInput string, opts RunOptions) (<-chan AgentEvent, error)

func (*Agent) RunStreamWithOptions

func (a *Agent) RunStreamWithOptions(ctx context.Context, sessionID, input string, hiddenInput bool) (<-chan AgentEvent, error)

func (*Agent) RunStreamWithTurnOptions added in v0.1.17

func (a *Agent) RunStreamWithTurnOptions(ctx context.Context, sessionID, input string, opts RunOptions) (<-chan AgentEvent, error)

type AgentEvent

type AgentEvent struct {
	Type           AgentEventType
	Content        string
	ReasoningDelta string
	ToolArgs       *ToolArgsProgress
	ToolArgsRepair *ToolArgsRepair
	ToolBlocked    *ToolCallBlocked
	Approval       *ToolApprovalRequired
	ApprovalGrant  *ToolApprovalGranted
	Scavenged      *ToolCallScavenged
	Policy         *ToolPolicyDecision
	Recovery       *ToolRecoveryInfo
	ProviderRetry  *llmretry.Info
	Compact        *CompactInfo
	PrefixDrift    *PrefixDriftInfo
	CacheMetrics   *PrefixCacheMetricsInfo
	Usage          *UsageInfo
	Budget         *BudgetWarningInfo
	Hook           *HookEventInfo
	Task           *TaskActivityInfo
	PlanUpdate     *PlanUpdateInfo
	ToolCall       *core.ToolCall
	UserInputReq   *core.UserInputRequest
	UserInputResp  *core.UserInputResponse
	Result         *core.ToolResult
	Message        *core.Message
	Err            error
}

type AgentEventType

type AgentEventType string
const (
	AgentEventTypeAssistantDelta         AgentEventType = "assistant_delta"
	AgentEventTypeReasoningDelta         AgentEventType = "reasoning_delta"
	AgentEventTypeToolArgsDelta          AgentEventType = "tool_args_delta"
	AgentEventTypeToolArgsRepaired       AgentEventType = "tool_args_repaired"
	AgentEventTypeToolCallBlocked        AgentEventType = "tool_call_blocked"
	AgentEventTypeToolModeBlocked        AgentEventType = "tool_mode_blocked"
	AgentEventTypeToolApprovalRequired   AgentEventType = "tool_approval_required"
	AgentEventTypeToolApprovalGranted    AgentEventType = "tool_approval_granted"
	AgentEventTypeToolCallScavenged      AgentEventType = "tool_call_scavenged"
	AgentEventTypeToolPolicyDecision     AgentEventType = "tool_policy_decision"
	AgentEventTypeToolCall               AgentEventType = "tool_call"
	AgentEventTypeToolResult             AgentEventType = "tool_result"
	AgentEventTypeUserInputRequired      AgentEventType = "user_input_required"
	AgentEventTypeUserInputSubmitted     AgentEventType = "user_input_submitted"
	AgentEventTypeUserInputCancelled     AgentEventType = "user_input_cancelled"
	AgentEventTypePlanDelta              AgentEventType = "plan_delta"
	AgentEventTypePlanCompleted          AgentEventType = "plan_completed"
	AgentEventTypePlanUpdate             AgentEventType = "plan_update"
	AgentEventTypePlanStepBlocked        AgentEventType = "plan_step_blocked"
	AgentEventTypeProviderRetryScheduled AgentEventType = "provider_retry_scheduled"
	AgentEventTypeResponseReset          AgentEventType = "response_reset"
	AgentEventTypeLeakedToolCallScrubbed AgentEventType = "leaked_tool_call_scrubbed"
	AgentEventTypeToolRecoveryScheduled  AgentEventType = "tool_recovery_scheduled"
	AgentEventTypeToolRecoveryAttempt    AgentEventType = "tool_recovery_attempt"
	AgentEventTypeToolRecoveryExhausted  AgentEventType = "tool_recovery_exhausted"
	AgentEventTypeReplanRequiredSet      AgentEventType = "replan_required_set"
	AgentEventTypeContextCompacted       AgentEventType = "context_compacted"
	AgentEventTypePrefixDrift            AgentEventType = "prefix_drift"
	AgentEventTypePrefixCacheMetrics     AgentEventType = "prefix_cache_metrics"
	AgentEventTypeUsage                  AgentEventType = "usage"
	AgentEventTypeBudgetWarning          AgentEventType = "budget_warning"
	AgentEventTypeTurnCancelled          AgentEventType = "turn_cancelled"
	AgentEventTypeForcedSummaryStarted   AgentEventType = "forced_summary_started"
	AgentEventTypeForcedSummaryDone      AgentEventType = "forced_summary_done"
	AgentEventTypeForcedSummaryFailed    AgentEventType = "forced_summary_failed"
	AgentEventTypeHookStarted            AgentEventType = "hook_started"
	AgentEventTypeHookBlocked            AgentEventType = "hook_blocked"
	AgentEventTypeHookWarned             AgentEventType = "hook_warned"
	AgentEventTypeHookFailed             AgentEventType = "hook_failed"
	AgentEventTypeHookCompleted          AgentEventType = "hook_completed"
	AgentEventTypeParallelReasonStarted  AgentEventType = "parallel_reason_started"
	AgentEventTypeParallelReasonDone     AgentEventType = "parallel_reason_completed"
	AgentEventTypeSubagentStarted        AgentEventType = "subagent_started"
	AgentEventTypeTaskProgress           AgentEventType = "task_progress"
	AgentEventTypeSubagentDone           AgentEventType = "subagent_completed"
	AgentEventTypeDone                   AgentEventType = "done"
	AgentEventTypeError                  AgentEventType = "error"
)

type AgentOption

type AgentOption func(*Agent)

func WithApprovalFunc

func WithApprovalFunc(fn policy.ApprovalFunc) AgentOption

func WithAutoCompact

func WithAutoCompact(enabled bool, threshold float64, contextWindow int) AgentOption

func WithBudgetWarningUSD

func WithBudgetWarningUSD(capUSD float64) AgentOption

func WithDisabledSkills added in v0.1.11

func WithDisabledSkills(names []string) AgentOption

func WithDynamicSystemBlocks added in v0.1.30

func WithDynamicSystemBlocks(blocks ...func() string) AgentOption

func WithDynamicSystemBlocksForTurn added in v0.1.43

func WithDynamicSystemBlocksForTurn(blocks ...func(RunOptions) string) AgentOption

func WithExtraSkills added in v0.1.15

func WithExtraSkills(extra []*skills.Skill) AgentOption

func WithExtraSystemBlocks added in v0.1.5

func WithExtraSystemBlocks(blocks ...string) AgentOption

func WithHookExecutors added in v0.1.34

func WithHookExecutors(promptExecutor, agentExecutor HookExecutor) AgentOption

func WithHookHandlers added in v0.1.15

func WithHookHandlers(handlers ...HookHandler) AgentOption

func WithHookRunner added in v0.1.15

func WithHookRunner(runner *HookRunner) AgentOption

func WithHooks

func WithHooks(hooks []ResolvedHook, workspaceRoot string) AgentOption

func WithMaxParallelSubagents added in v0.1.22

func WithMaxParallelSubagents(maxParallel int) AgentOption

func WithMaxToolCalls added in v0.1.30

func WithMaxToolCalls(maxCalls int) AgentOption

func WithMaxToolIters added in v0.1.5

func WithMaxToolIters(maxIters int) AgentOption

func WithMaxTurns added in v0.1.34

func WithMaxTurns(maxTurns int) AgentOption

func WithProjectMemory

func WithProjectMemory(enabled bool, maxChars int, fileOrder []string, workspaceRoot string) AgentOption

func WithRecoveryPolicy

func WithRecoveryPolicy(r RecoveryPolicy) AgentOption

func WithSessionMode

func WithSessionMode(mode session.Mode) AgentOption

func WithSessionsDir

func WithSessionsDir(sessionsDir string) AgentOption

func WithToolPolicy

func WithToolPolicy(policy policy.ToolPolicy) AgentOption

func WithToolRefresh added in v0.1.23

func WithToolRefresh(fn func(context.Context) error) AgentOption

func WithUsageLogPath

func WithUsageLogPath(path string) AgentOption

func WithUserInputFunc

func WithUserInputFunc(fn UserInputFunc) AgentOption

func WithWorktreeContext added in v0.1.20

func WithWorktreeContext(worktreeRoot, originalWorkspace string) AgentOption

type BudgetWarningInfo

type BudgetWarningInfo struct {
	CapUSD      float64
	SpentUSD    float64
	Percent     int
	TurnCostUSD float64
}

type CompactInfo

type CompactInfo struct {
	Compacted      bool
	Auto           bool
	MessagesBefore int
	MessagesAfter  int
	BeforeEstimate int
	AfterEstimate  int
}

type FailureClass

type FailureClass string
const (
	FailureClassTimeout          FailureClass = "timeout"
	FailureClassExecFailed       FailureClass = "exec_failed"
	FailureClassParseFailed      FailureClass = "parse_failed"
	FailureClassEmptyOutput      FailureClass = "empty_output"
	FailureClassPolicyDenied     FailureClass = "policy_denied"
	FailureClassApprovalDenied   FailureClass = "approval_denied"
	FailureClassPlanRequired     FailureClass = "plan_required"
	FailureClassPermissionDenied FailureClass = "permission_denied"
	FailureClassMCPToolError     FailureClass = "mcp_tool_error"
	FailureClassToolUnavailable  FailureClass = "tool_unavailable"
	FailureClassUnknown          FailureClass = "unknown"
)

type HookConfig

type HookConfig struct {
	Type           string            `json:"type,omitempty" toml:"type,omitempty"`
	Match          string            `json:"match,omitempty" toml:"match,omitempty"`
	If             string            `json:"if,omitempty" toml:"if,omitempty"`
	Command        string            `json:"command" toml:"command,omitempty"`
	Prompt         string            `json:"prompt,omitempty" toml:"prompt,omitempty"`
	URL            string            `json:"url,omitempty" toml:"url,omitempty"`
	Model          string            `json:"model,omitempty" toml:"model,omitempty"`
	Description    string            `json:"description,omitempty" toml:"description,omitempty"`
	TimeoutSec     int               `json:"timeout,omitempty" toml:"timeout,omitempty"`
	CWD            string            `json:"cwd,omitempty" toml:"cwd,omitempty"`
	Shell          string            `json:"shell,omitempty" toml:"shell,omitempty"`
	Once           bool              `json:"once,omitempty" toml:"once,omitempty"`
	Async          bool              `json:"async,omitempty" toml:"async,omitempty"`
	AsyncRewake    bool              `json:"asyncRewake,omitempty" toml:"asyncRewake,omitempty"`
	Headers        map[string]string `json:"headers,omitempty" toml:"headers,omitempty"`
	AllowedEnvVars []string          `json:"allowedEnvVars,omitempty" toml:"allowedEnvVars,omitempty"`
}

type HookDecision

type HookDecision string
const (
	HookDecisionPass    HookDecision = "pass"
	HookDecisionBlock   HookDecision = "block"
	HookDecisionHalt    HookDecision = "halt"
	HookDecisionWarn    HookDecision = "warn"
	HookDecisionTimeout HookDecision = "timeout"
	HookDecisionError   HookDecision = "error"
)

type HookEvent

type HookEvent string
const (
	HookEventPreToolUse        HookEvent = "PreToolUse"
	HookEventPermissionRequest HookEvent = "PermissionRequest"
	HookEventPostToolUse       HookEvent = "PostToolUse"
	HookEventPreCompact        HookEvent = "PreCompact"
	HookEventPostCompact       HookEvent = "PostCompact"
	HookEventSessionStart      HookEvent = "SessionStart"
	HookEventUserPromptSubmit  HookEvent = "UserPromptSubmit"
	HookEventSubagentStart     HookEvent = "SubagentStart"
	HookEventSubagentStop      HookEvent = "SubagentStop"
	HookEventStop              HookEvent = "Stop"
)

type HookEventInfo

type HookEventInfo struct {
	ID         string
	Name       string
	Event      HookEvent
	Source     string
	Command    string
	Decision   HookDecision
	ExitCode   int
	Message    string
	DurationMS int64
	Truncated  bool
}

type HookExecutor added in v0.1.34

type HookExecutor func(ctx context.Context, cfg HookConfig, payload HookPayload) HookResult

type HookHandler added in v0.1.15

type HookHandler struct {
	Event       HookEvent
	Match       string
	Name        string
	Source      string
	Description string
	TimeoutSec  int
	Run         func(context.Context, HookPayload) HookResult
}

type HookLifecycleEventInfo added in v0.1.32

type HookLifecycleEventInfo struct {
	Event       HookEvent
	Description string
}

func HookEvents added in v0.1.32

func HookEvents() []HookLifecycleEventInfo

type HookListEntry added in v0.1.32

type HookListEntry struct {
	Key            string            `json:"key"`
	Event          HookEvent         `json:"event"`
	Type           string            `json:"type"`
	Name           string            `json:"name,omitempty"`
	Source         string            `json:"source,omitempty"`
	Match          string            `json:"match,omitempty"`
	If             string            `json:"if,omitempty"`
	Command        string            `json:"command,omitempty"`
	Prompt         string            `json:"prompt,omitempty"`
	URL            string            `json:"url,omitempty"`
	Model          string            `json:"model,omitempty"`
	Description    string            `json:"description,omitempty"`
	TimeoutSec     int               `json:"timeout_sec,omitempty"`
	CWD            string            `json:"cwd,omitempty"`
	Shell          string            `json:"shell,omitempty"`
	Once           bool              `json:"once,omitempty"`
	Async          bool              `json:"async,omitempty"`
	AsyncRewake    bool              `json:"asyncRewake,omitempty"`
	Headers        map[string]string `json:"-"`
	AllowedEnvVars []string          `json:"allowedEnvVars,omitempty"`
	Hash           string            `json:"hash,omitempty"`
	Enabled        bool              `json:"enabled"`
	Managed        bool              `json:"managed"`
	DefaultTrusted bool              `json:"-"`
	Active         bool              `json:"active"`
	Trust          HookTrustStatus   `json:"trust"`
}

type HookOutcome

type HookOutcome struct {
	Hook       ResolvedHook
	ID         string
	Name       string
	Source     string
	Command    string
	Decision   HookDecision
	ExitCode   int
	Stdout     string
	Stderr     string
	Message    string
	DurationMS int64
	Truncated  bool

	AdditionalContext string
	UpdatedInput      string
	Metadata          map[string]any
}

type HookPayload

type HookPayload struct {
	Event             HookEvent      `json:"event"`
	CWD               string         `json:"cwd"`
	SessionID         string         `json:"session_id,omitempty"`
	ToolName          string         `json:"tool_name,omitempty"`
	ToolArgs          any            `json:"tool_args,omitempty"`
	ToolResult        string         `json:"tool_result,omitempty"`
	ToolOutcome       string         `json:"tool_outcome,omitempty"`
	ToolErrorCode     string         `json:"tool_error_code,omitempty"`
	Prompt            string         `json:"prompt,omitempty"`
	LastAssistantText string         `json:"last_assistant_text,omitempty"`
	Turn              int            `json:"turn,omitempty"`
	ToolCall          *core.ToolCall `json:"tool_call,omitempty"`
	ApprovalReason    string         `json:"approval_reason,omitempty"`
	ApprovalCode      string         `json:"approval_code,omitempty"`
	CompactSummary    string         `json:"compact_summary,omitempty"`
	MessagesBefore    int            `json:"messages_before,omitempty"`
	MessagesAfter     int            `json:"messages_after,omitempty"`
	SubagentRole      string         `json:"subagent_role,omitempty"`
	SubagentModel     string         `json:"subagent_model,omitempty"`
	SubagentSummary   string         `json:"subagent_summary,omitempty"`
}

func NewPermissionRequestPayload added in v0.1.32

func NewPermissionRequestPayload(sessionID, cwd string, call core.ToolCall, reason, code string) HookPayload

func NewPostCompactPayload added in v0.1.32

func NewPostCompactPayload(sessionID, cwd, summary string, messagesBefore, messagesAfter int) HookPayload

func NewPostToolUsePayload

func NewPostToolUsePayload(sessionID string, call core.ToolCall, toolArgs any, res core.ToolResult) HookPayload

func NewPreCompactPayload added in v0.1.32

func NewPreCompactPayload(sessionID, cwd string, messagesBefore int) HookPayload

func NewPreToolUsePayload

func NewPreToolUsePayload(sessionID string, call core.ToolCall, toolArgs any) HookPayload

func NewSessionStartPayload added in v0.1.32

func NewSessionStartPayload(sessionID, cwd string) HookPayload

func NewStopPayload

func NewStopPayload(sessionID, cwd, lastAssistantText string, turn int) HookPayload

func NewSubagentHookPayload added in v0.1.32

func NewSubagentHookPayload(event HookEvent, sessionID, cwd, role, model, summary string) HookPayload

func NewUserPromptSubmitPayload

func NewUserPromptSubmitPayload(sessionID, cwd, prompt string) HookPayload

type HookReport

type HookReport struct {
	Event             HookEvent
	Outcomes          []HookOutcome
	Blocked           bool
	Halted            bool
	AdditionalContext string
	UpdatedInput      string
	Metadata          map[string]any
}

type HookResult added in v0.1.15

type HookResult struct {
	Decision HookDecision
	Message  string
	Stdout   string
	Stderr   string

	AdditionalContext string
	UpdatedInput      string
	Metadata          map[string]any
}

type HookRunObserver added in v0.1.32

type HookRunObserver func(HookRunStage, HookEventInfo)

type HookRunStage added in v0.1.32

type HookRunStage string
const (
	HookRunStarted   HookRunStage = "started"
	HookRunCompleted HookRunStage = "completed"
	HookRunBlocked   HookRunStage = "blocked"
	HookRunWarned    HookRunStage = "warned"
	HookRunFailed    HookRunStage = "failed"
)

type HookRunner

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

func NewHookRunner

func NewHookRunner(hooks []ResolvedHook, workspace string) *HookRunner

func NewHookRunnerWithState added in v0.1.32

func NewHookRunnerWithState(hooks []ResolvedHook, workspace string, states HookStates) *HookRunner

func (*HookRunner) AddHandlers added in v0.1.15

func (r *HookRunner) AddHandlers(handlers ...HookHandler)

func (*HookRunner) Empty

func (r *HookRunner) Empty() bool

func (*HookRunner) ListHooks added in v0.1.32

func (r *HookRunner) ListHooks() []HookListEntry

func (*HookRunner) RunHook added in v0.1.24

func (r *HookRunner) RunHook(ctx context.Context, payload HookPayload) HookReport

func (*HookRunner) RunHookWithObserver added in v0.1.32

func (r *HookRunner) RunHookWithObserver(ctx context.Context, payload HookPayload, observer HookRunObserver) HookReport

func (*HookRunner) SetExecutors added in v0.1.34

func (r *HookRunner) SetExecutors(promptExecutor, agentExecutor HookExecutor)

type HookSettings

type HookSettings struct {
	Hooks map[HookEvent][]HookConfig `json:"hooks"`
}

type HookSpawnInput

type HookSpawnInput struct {
	Command string
	Shell   string
	CWD     string
	Stdin   string
	Timeout time.Duration
}

type HookSpawnResult

type HookSpawnResult struct {
	ExitCode  int
	Stdout    string
	Stderr    string
	TimedOut  bool
	SpawnErr  error
	Truncated bool
}

type HookSpawner

type HookSpawner func(ctx context.Context, in HookSpawnInput) HookSpawnResult

type HookState added in v0.1.32

type HookState struct {
	TrustedHash string `json:"trusted_hash,omitempty" toml:"trusted_hash,omitempty"`
	Enabled     *bool  `json:"enabled,omitempty" toml:"enabled,omitempty"`
}

type HookStates added in v0.1.32

type HookStates map[string]HookState

func SetHookEnabledStates added in v0.1.32

func SetHookEnabledStates(entries []HookListEntry, states HookStates, keys []string, enabled bool) HookStates

func TrustHookStates added in v0.1.32

func TrustHookStates(entries []HookListEntry, states HookStates, keys []string) HookStates

type HookTrustStatus added in v0.1.32

type HookTrustStatus string
const (
	HookTrustManaged   HookTrustStatus = "Managed"
	HookTrustUntrusted HookTrustStatus = "Untrusted"
	HookTrustTrusted   HookTrustStatus = "Trusted"
	HookTrustModified  HookTrustStatus = "Modified"
)

type PlanUpdateInfo added in v0.1.15

type PlanUpdateInfo struct {
	Explanation string           `json:"explanation,omitempty"`
	Plan        []PlanUpdateStep `json:"plan"`
}

type PlanUpdateStep added in v0.1.15

type PlanUpdateStep struct {
	Step   string `json:"step"`
	Status string `json:"status"`
}

type PrefixCacheMetricsInfo

type PrefixCacheMetricsInfo struct {
	Model             string
	PrefixFingerprint string
	CacheShape        *telemetry.CacheShape
	PromptTokens      int
	CachedTokens      int
	CacheHitRatio     float64
}

type PrefixDriftInfo

type PrefixDriftInfo struct {
	Expected string
	Actual   string
}

type RecoveryAction

type RecoveryAction string
const (
	RecoveryActionRetrySame        RecoveryAction = "retry_same"
	RecoveryActionRetryWithBackoff RecoveryAction = "retry_with_backoff"
	RecoveryActionFallbackReadOnly RecoveryAction = "fallback_readonly"
	RecoveryActionRequestReplan    RecoveryAction = "request_replan"
	RecoveryActionHardBlock        RecoveryAction = "hard_block"
	RecoveryActionPassThrough      RecoveryAction = "pass_through"
)

type RecoveryPolicy

type RecoveryPolicy struct {
	Enabled bool
	Rules   map[FailureClass]RecoveryRule
}

func DefaultRecoveryPolicy

func DefaultRecoveryPolicy() RecoveryPolicy

type RecoveryRule

type RecoveryRule struct {
	Action      RecoveryAction
	MaxAttempts int
	BackoffMS   int
}

type ResolvedHook

type ResolvedHook struct {
	HookConfig
	Event          HookEvent
	Source         string
	Managed        bool
	DefaultTrusted bool
}

func LoadHooks

func LoadHooks(workspaceRoot, dataDir string) ([]ResolvedHook, []string, error)

func LoadProjectHooks

func LoadProjectHooks(workspaceRoot string) ([]ResolvedHook, error)

func ResolveHooks added in v0.1.9

func ResolveHooks(st HookSettings, source string) []ResolvedHook

type RunOptions added in v0.1.17

type RunOptions struct {
	HiddenInput        bool
	ReadOnly           bool
	GoalContinuation   bool
	ShellAllowPrefixes []string
	ViewMode           string
	AssistantPrefix    string
	PrefixCompletion   bool
	WorkflowAuthoring  bool
	// SuppressTools forces the turn to be sent without any tools. Prefix
	// completion requests also require no current tool schemas.
	SuppressTools bool
}

type SideQuestionEvent added in v0.1.17

type SideQuestionEvent struct {
	Type    SideQuestionEventType
	Content string
	Err     error
}

type SideQuestionEventType added in v0.1.17

type SideQuestionEventType string
const (
	SideQuestionEventDelta SideQuestionEventType = "delta"
	SideQuestionEventDone  SideQuestionEventType = "done"
	SideQuestionEventError SideQuestionEventType = "error"
)

type TaskActivityInfo added in v0.1.5

type TaskActivityInfo struct {
	ToolCallID       string
	ToolName         string
	Role             string
	Model            string
	Count            int
	Summary          string
	Status           string
	DurationMS       int64
	Metadata         map[string]any
	ProgressMessages []core.SubagentStep
}

type ToolApprovalGranted added in v0.1.15

type ToolApprovalGranted struct {
	SessionID  string
	ToolCallID string
	ToolName   string
	Key        string
	Keys       []string
}

type ToolApprovalRequired

type ToolApprovalRequired struct {
	ToolCallID string
	ToolName   string
	Reason     string
	Code       string
	Key        string
	Keys       []string
	Summary    string
	Scope      string
	Metadata   map[string]any
}

type ToolArgsProgress

type ToolArgsProgress struct {
	ToolCallIndex int
	ToolName      string
	ArgsChars     int
	ReadyCount    int
}

type ToolArgsRepair

type ToolArgsRepair struct {
	ToolCallIndex int
	ToolName      string
}

type ToolCallBlocked

type ToolCallBlocked struct {
	ToolCallID string
	ToolName   string
	ReasonCode string
}

type ToolCallScavenged

type ToolCallScavenged struct {
	Count int
}

type ToolPolicyDecision

type ToolPolicyDecision struct {
	ToolCallID    string
	ToolName      string
	Allow         bool
	NeedsApproval bool
	Reason        string
	Code          string
	Phase         string
	MatchedRule   string
}

type ToolRecoveryInfo

type ToolRecoveryInfo struct {
	ToolCallID     string
	ToolName       string
	FailureClass   string
	Action         string
	Attempt        int
	MaxAttempts    int
	Reason         string
	Executed       bool
	ReplanInjected bool
}

type UsageInfo added in v0.1.30

type UsageInfo struct {
	Model string
	Usage llm.Usage
}

type UserInputFunc

type UserInputFunc func(req UserInputRequest) (core.UserInputResponse, bool)

type UserInputRequest

type UserInputRequest struct {
	SessionID string
	ToolCall  core.ToolCall
	Questions []core.UserInputQuestion
}

Jump to

Keyboard shortcuts

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