Documentation
¶
Index ¶
- Constants
- Variables
- func FormatPlanUpdateForDisplay(update PlanUpdateInfo) string
- type Agent
- func (a *Agent) CompactSession(ctx context.Context, sessionID string) (CompactInfo, error)
- func (a *Agent) Run(ctx context.Context, sessionID, input string) (core.Message, error)
- func (a *Agent) RunSideQuestion(ctx context.Context, sessionID, question string) (<-chan SideQuestionEvent, error)
- func (a *Agent) RunStream(ctx context.Context, sessionID, input string) (<-chan AgentEvent, error)
- func (a *Agent) RunStreamWithInjectedInput(ctx context.Context, sessionID, visibleInput, hiddenInput string) (<-chan AgentEvent, error)
- func (a *Agent) RunStreamWithInjectedInputOptions(ctx context.Context, sessionID, visibleInput, hiddenInput string, ...) (<-chan AgentEvent, error)
- func (a *Agent) RunStreamWithOptions(ctx context.Context, sessionID, input string, hiddenInput bool) (<-chan AgentEvent, error)
- func (a *Agent) RunStreamWithTurnOptions(ctx context.Context, sessionID, input string, opts RunOptions) (<-chan AgentEvent, error)
- type AgentEvent
- type AgentEventType
- type AgentOption
- func WithApprovalFunc(fn policy.ApprovalFunc) AgentOption
- func WithAutoCompact(enabled bool, threshold float64, contextWindow int) AgentOption
- func WithBudgetWarningUSD(capUSD float64) AgentOption
- func WithDisabledSkills(names []string) AgentOption
- func WithExtraSkills(extra []*skills.Skill) AgentOption
- func WithExtraSystemBlocks(blocks ...string) AgentOption
- func WithHookHandlers(handlers ...HookHandler) AgentOption
- func WithHookRunner(runner *HookRunner) AgentOption
- func WithHooks(hooks []ResolvedHook, workspaceRoot string) AgentOption
- func WithMaxToolIters(maxIters int) AgentOption
- func WithProjectMemory(enabled bool, maxChars int, fileOrder []string, workspaceRoot string) AgentOption
- func WithRecoveryPolicy(r RecoveryPolicy) AgentOption
- func WithSessionMode(mode session.Mode) AgentOption
- func WithSessionsDir(sessionsDir string) AgentOption
- func WithToolPolicy(policy policy.ToolPolicy) AgentOption
- func WithUsageLogPath(path string) AgentOption
- func WithUserInputFunc(fn UserInputFunc) AgentOption
- type BudgetWarningInfo
- type CompactInfo
- type FailureClass
- type HookConfig
- type HookDecision
- type HookEvent
- type HookEventInfo
- type HookHandler
- type HookOutcome
- type HookPayload
- func NewPostToolUsePayload(sessionID string, call core.ToolCall, toolArgs any, toolResult string) HookPayload
- func NewPreToolUsePayload(sessionID string, call core.ToolCall, toolArgs any) HookPayload
- func NewStopPayload(sessionID, cwd, lastAssistantText string, turn int) HookPayload
- func NewUserPromptSubmitPayload(sessionID, cwd, prompt string) HookPayload
- type HookReport
- type HookResult
- type HookRunner
- type HookSettings
- type HookSpawnInput
- type HookSpawnResult
- type HookSpawner
- type PlanUpdateInfo
- type PlanUpdateStep
- type PrefixCacheMetricsInfo
- type PrefixDriftInfo
- type RecoveryAction
- type RecoveryPolicy
- type RecoveryRule
- type ResolvedHook
- type RunOptions
- type SideQuestionEvent
- type SideQuestionEventType
- type TaskActivityInfo
- type ToolApprovalGranted
- type ToolApprovalRequired
- type ToolArgsProgress
- type ToolArgsRepair
- type ToolCallBlocked
- type ToolCallScavenged
- type ToolPolicyDecision
- type ToolRecoveryInfo
- type UserInputFunc
- type UserInputRequest
Constants ¶
View Source
const (
DefaultHookOutputCapBytes = 256 * 1024
)
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
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func NewAgentWithRegistry ¶
func NewAgentWithRegistry(provider llm.Provider, store store.MessageStore, tools *core.ToolRegistry, opts ...AgentOption) *Agent
func (*Agent) CompactSession ¶
func (*Agent) RunSideQuestion ¶ added in v0.1.17
func (*Agent) RunStreamWithInjectedInput ¶ added in v0.1.4
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 (*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
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" 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" 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 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 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 WithMaxToolIters ¶ added in v0.1.5
func WithMaxToolIters(maxIters 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 WithUsageLogPath ¶
func WithUsageLogPath(path string) AgentOption
func WithUserInputFunc ¶
func WithUserInputFunc(fn UserInputFunc) AgentOption
type BudgetWarningInfo ¶
type CompactInfo ¶
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" FailureClassUnknown FailureClass = "unknown" )
type HookConfig ¶
type HookConfig struct {
Match string `json:"match,omitempty" toml:"match,omitempty"`
Command string `json:"command" toml:"command,omitempty"`
Description string `json:"description,omitempty" toml:"description,omitempty"`
TimeoutMS int `json:"timeout,omitempty" toml:"timeout,omitempty"`
CWD string `json:"cwd,omitempty" toml:"cwd,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 HookEventInfo ¶
type HookHandler ¶ added in v0.1.15
type HookHandler struct {
Event HookEvent
Match string
Name string
Source string
Description string
TimeoutMS int
Run func(context.Context, HookPayload) HookResult
}
type HookOutcome ¶
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"`
Prompt string `json:"prompt,omitempty"`
LastAssistantText string `json:"last_assistant_text,omitempty"`
Turn int `json:"turn,omitempty"`
ToolCall *core.ToolCall `json:"tool_call,omitempty"`
}
func NewPostToolUsePayload ¶
func NewPreToolUsePayload ¶
func NewPreToolUsePayload(sessionID string, call core.ToolCall, toolArgs any) HookPayload
func NewStopPayload ¶
func NewStopPayload(sessionID, cwd, lastAssistantText string, turn int) HookPayload
func NewUserPromptSubmitPayload ¶
func NewUserPromptSubmitPayload(sessionID, cwd, prompt string) HookPayload
type HookReport ¶
type HookResult ¶ added in v0.1.15
type HookRunner ¶
type HookRunner struct {
// contains filtered or unexported fields
}
func NewHookRunner ¶
func NewHookRunner(hooks []ResolvedHook, workspace string) *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) Run ¶
func (r *HookRunner) Run(ctx context.Context, payload HookPayload) HookReport
type HookSettings ¶
type HookSettings struct {
Hooks map[HookEvent][]HookConfig `json:"hooks"`
}
type HookSpawnInput ¶
type HookSpawnResult ¶
type HookSpawner ¶
type HookSpawner func(ctx context.Context, in HookSpawnInput) HookSpawnResult
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 PrefixCacheMetricsInfo ¶
type PrefixDriftInfo ¶
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
}
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 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 ToolApprovalGranted ¶ added in v0.1.15
type ToolApprovalRequired ¶
type ToolArgsProgress ¶
type ToolArgsRepair ¶
type ToolCallBlocked ¶
type ToolCallScavenged ¶
type ToolCallScavenged struct {
Count int
}
type ToolPolicyDecision ¶
type ToolRecoveryInfo ¶
type UserInputFunc ¶
type UserInputFunc func(req UserInputRequest) (core.UserInputResponse, bool)
type UserInputRequest ¶
type UserInputRequest struct {
SessionID string
ToolCall core.ToolCall
Questions []core.UserInputQuestion
}
Source Files
¶
- agent.go
- approvals.go
- compact.go
- force_summary.go
- hook_events.go
- hooks.go
- interrupt_marker.go
- plan_mode.go
- plan_update.go
- recovery.go
- recovery_dispatch.go
- side_question.go
- stream.go
- system_prompt.go
- task_activity.go
- todo_tools.go
- tool_input_telemetry.go
- tool_preview.go
- tool_repair.go
- turn_loop.go
- usage_budget.go
- user_input.go
Click to show internal directories.
Click to hide internal directories.