Documentation
¶
Index ¶
- Constants
- Variables
- func BuildToolDefs(d *Dispatcher) []provider.ToolDefinition
- func NewDispatcherFactory(backupDir, sessionsDir string, permCfg *config.PermissionsConfig, ...) subagent.DispatcherFactory
- func SetVersion(v string)
- type Agent
- type AskUserQuestion
- type Bash
- type CodeMap
- type Dispatcher
- func (d *Dispatcher) ApprovePermission(requestID int64, allowed bool, remember bool)
- func (d *Dispatcher) Execute(ctx context.Context, call types.ToolCall) (types.ToolResult, error)
- func (d *Dispatcher) GetTool(name string) (types.Tool, bool)
- func (d *Dispatcher) List() []string
- func (d *Dispatcher) QuestionRequestCh() chan QuestionRequest
- func (d *Dispatcher) QuestionResponseCh() chan QuestionResponse
- func (d *Dispatcher) Register(tool types.Tool) error
- func (d *Dispatcher) RequestCh() chan PermissionRequest
- func (d *Dispatcher) RespondQuestion(requestID int64, answer string)
- func (d *Dispatcher) SelectAgent(agent string) error
- func (d *Dispatcher) SetPermission(toolName string, allowed bool)
- func (d *Dispatcher) SetSessionID(id string)
- func (d *Dispatcher) Stop()
- func (d *Dispatcher) UpdatePermissions(cfg *config.PermissionsConfig)
- type Edit
- type FileDelete
- type FileList
- type FileMove
- type FileRead
- type FileWrite
- type Glob
- type Grep
- type PermissionContext
- type PermissionRequest
- type PermissionResponse
- type QuestionRequest
- type QuestionResponse
- type TodoWrite
- func (t *TodoWrite) Description() string
- func (t *TodoWrite) Execute(ctx context.Context, input types.ToolInput) (types.ToolResult, error)
- func (t *TodoWrite) Name() string
- func (t *TodoWrite) ParameterSchema() string
- func (t *TodoWrite) RiskLevel() types.RiskLevel
- func (t *TodoWrite) SetSessionID(id string)
- type WebFetch
- type WebSearch
Constants ¶
const ( BashKillGracePeriod = time.Duration(types.DefaultBashKillGraceSecs) * time.Second BashWaitTimeout = 30 * time.Second MaxBackupsPerFile = types.DefaultMaxBackupsPerFile DirPermission = types.DirPermission FilePermission = types.FilePermission MaxGlobResults = types.DefaultMaxGlobResults MaxGrepPatternLength = 1024 DefaultMaxGrepResults = types.DefaultMaxGrepResults MaxRedirects = types.DefaultWebfetchMaxRedirects DefaultTimeoutSecs = 30 MaxTimeoutSecs = 120 DNSCacheTTL = 5 * time.Minute MinLinesForFuzzy = 3 LevenshteinThreshold = 0.7 PermissionChannelBuffer = 8 QuestionChannelBuffer = 4 DefaultAgentName = "default" // Rate limiting: token bucket for tool execution. // Max 20 tools per second burst, sustained 10 tools/second. ToolRateLimitBurst = 20 ToolRateLimitPerSec = 10 DefaultSearchBaseURL = "https://search.sagibo.net" MaxSearchQueryLength = 500 DefaultMaxSearchResults = 5 MaxSearchResults = 10 )
Variables ¶
var Version atomic.Value
Version is the application version used in User-Agent headers. Set via SetVersion() from cmd/m31a/main.go.
Functions ¶
func BuildToolDefs ¶
func BuildToolDefs(d *Dispatcher) []provider.ToolDefinition
BuildToolDefs creates provider.ToolDefinition slices from a Dispatcher's registered tools. This is shared between the workflow engine and the autonomous agent loop to avoid duplicating tool schema logic.
func NewDispatcherFactory ¶
func NewDispatcherFactory(backupDir, sessionsDir string, permCfg *config.PermissionsConfig, manager *subagent.Manager) subagent.DispatcherFactory
NewDispatcherFactory returns a DispatcherFactory that creates a fresh tools.Dispatcher for each subagent workspace. The factory registers the Agent tool (with isChild=true) on every dispatcher so a subagent can spawn its own child, but forced-foreground to block runaway fan-out.
backupDir and sessionsDir are shared across all dispatchers; permCfg is reused verbatim so permission rules apply uniformly.
func SetVersion ¶
func SetVersion(v string)
SetVersion sets the application version for User-Agent headers.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is a tool that spawns a parallel subagent to perform an independent task. The parent conversation receives the subagent's ID immediately and can continue issuing other tool calls while the subagent runs.
Background mode (default) returns the agent ID and delivers the final summary to the parent via SubagentEvent messages consumed by the TUI. Foreground mode (run_in_background=false) blocks until the subagent finishes and returns its summary as this tool's output.
func (*Agent) Description ¶
func (*Agent) ParameterSchema ¶
ParameterSchema returns the JSON schema exposed to the LLM.
type AskUserQuestion ¶
type AskUserQuestion struct {
// contains filtered or unexported fields
}
func NewAskUserQuestion ¶
func NewAskUserQuestion(requestCh chan QuestionRequest, responseCh chan QuestionResponse, pending *sync.Map) *AskUserQuestion
func (*AskUserQuestion) Description ¶
func (t *AskUserQuestion) Description() string
func (*AskUserQuestion) Execute ¶
func (t *AskUserQuestion) Execute(ctx context.Context, input types.ToolInput) (types.ToolResult, error)
func (*AskUserQuestion) Name ¶
func (t *AskUserQuestion) Name() string
func (*AskUserQuestion) ParameterSchema ¶
func (t *AskUserQuestion) ParameterSchema() string
ParameterSchema returns the JSON Schema for AskUserQuestion tool parameters.
func (*AskUserQuestion) RiskLevel ¶
func (t *AskUserQuestion) RiskLevel() types.RiskLevel
type Bash ¶
type Bash struct {
// contains filtered or unexported fields
}
func (*Bash) Description ¶
func (*Bash) ParameterSchema ¶
ParameterSchema returns the JSON Schema for Bash tool parameters.
type CodeMap ¶
type CodeMap struct {
// contains filtered or unexported fields
}
CodeMap is a tool that queries the codebase intelligence layer for import graph, symbol definitions, and relevant file discovery.
func NewCodeMap ¶
func (*CodeMap) Description ¶
func (*CodeMap) ParameterSchema ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func DefaultDispatcher ¶
func DefaultDispatcher(workDir, backupDir, sessionsDir string, cfg *config.PermissionsConfig) (*Dispatcher, error)
func NewDispatcher ¶
func NewDispatcher(cfg *config.PermissionsConfig) *Dispatcher
NewDispatcher creates a new Dispatcher with a background rate-limiter goroutine. The caller MUST call Stop() when the Dispatcher is no longer needed to prevent goroutine leaks (e.g., during session restart or app shutdown).
func (*Dispatcher) ApprovePermission ¶
func (d *Dispatcher) ApprovePermission(requestID int64, allowed bool, remember bool)
func (*Dispatcher) Execute ¶
func (d *Dispatcher) Execute(ctx context.Context, call types.ToolCall) (types.ToolResult, error)
func (*Dispatcher) List ¶
func (d *Dispatcher) List() []string
func (*Dispatcher) QuestionRequestCh ¶
func (d *Dispatcher) QuestionRequestCh() chan QuestionRequest
func (*Dispatcher) QuestionResponseCh ¶
func (d *Dispatcher) QuestionResponseCh() chan QuestionResponse
func (*Dispatcher) RequestCh ¶
func (d *Dispatcher) RequestCh() chan PermissionRequest
func (*Dispatcher) RespondQuestion ¶
func (d *Dispatcher) RespondQuestion(requestID int64, answer string)
RespondQuestion routes a question response to the per-request channel for the given request ID. Falls back to the shared channel if no per-request channel exists. This prevents cross-caller response routing (H-2).
func (*Dispatcher) SelectAgent ¶
func (d *Dispatcher) SelectAgent(agent string) error
func (*Dispatcher) SetPermission ¶
func (d *Dispatcher) SetPermission(toolName string, allowed bool)
func (*Dispatcher) SetSessionID ¶
func (d *Dispatcher) SetSessionID(id string)
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
Stop shuts down the rate limiter goroutine and ticker. Should be called when the Dispatcher is no longer needed (e.g., during app shutdown). C-12: Uses sync.Once to prevent TOCTOU race on concurrent calls.
func (*Dispatcher) UpdatePermissions ¶
func (d *Dispatcher) UpdatePermissions(cfg *config.PermissionsConfig)
UpdatePermissions hot-reloads the permission configuration.
type Edit ¶
type Edit struct {
// contains filtered or unexported fields
}
func (*Edit) Description ¶
func (*Edit) ParameterSchema ¶
ParameterSchema returns the JSON Schema for Edit tool parameters.
type FileDelete ¶
type FileDelete struct {
// contains filtered or unexported fields
}
func NewFileDelete ¶
func NewFileDelete(workDir, backupDir string) *FileDelete
func (*FileDelete) Description ¶
func (t *FileDelete) Description() string
func (*FileDelete) Execute ¶
func (t *FileDelete) Execute(ctx context.Context, input types.ToolInput) (types.ToolResult, error)
func (*FileDelete) Name ¶
func (t *FileDelete) Name() string
func (*FileDelete) ParameterSchema ¶
func (t *FileDelete) ParameterSchema() string
func (*FileDelete) RiskLevel ¶
func (t *FileDelete) RiskLevel() types.RiskLevel
type FileList ¶
type FileList struct {
// contains filtered or unexported fields
}
func NewFileList ¶
func (*FileList) Description ¶
func (*FileList) ParameterSchema ¶
type FileMove ¶
type FileMove struct {
// contains filtered or unexported fields
}
func NewFileMove ¶
func (*FileMove) Description ¶
func (*FileMove) ParameterSchema ¶
type FileRead ¶
type FileRead struct {
// contains filtered or unexported fields
}
func NewFileRead ¶
func (*FileRead) Description ¶
func (*FileRead) ParameterSchema ¶
ParameterSchema returns the JSON Schema for FileRead tool parameters.
type FileWrite ¶
type FileWrite struct {
// contains filtered or unexported fields
}
func NewFileWrite ¶
func (*FileWrite) Description ¶
func (*FileWrite) ParameterSchema ¶
ParameterSchema returns the JSON Schema for FileWrite tool parameters.
type Glob ¶
type Glob struct {
// contains filtered or unexported fields
}
func (*Glob) Description ¶
func (*Glob) ParameterSchema ¶
ParameterSchema returns the JSON Schema for Glob tool parameters.
type Grep ¶
type Grep struct {
// contains filtered or unexported fields
}
func (*Grep) Description ¶
func (*Grep) ParameterSchema ¶
ParameterSchema returns the JSON Schema for Grep tool parameters.
type PermissionContext ¶
type PermissionContext struct {
RuleTool string // Tool name from the matched rule
RulePattern string // Pattern from the matched rule
RuleAction string // The action that triggered (allow/deny/ask)
Source string // Source of the decision: "rule", "agent_default", or "risk_level"
}
PermissionContext carries additional info about a matched rule for display in the permission modal.
type PermissionRequest ¶
type PermissionRequest struct {
ID int64 `json:"id"`
ToolName string `json:"tool_name"`
Command string `json:"command"`
RiskLevel types.RiskLevel `json:"risk_level"`
TimeoutSecs int `json:"timeout_secs"`
// Rule context (populated when a permission rule matched)
RuleTool string `json:"rule_tool,omitempty"`
RulePattern string `json:"rule_pattern,omitempty"`
RuleAction string `json:"rule_action,omitempty"`
}
type PermissionResponse ¶
type QuestionRequest ¶
type QuestionRequest struct {
ID int64
Question string
Header string
Options []string
AllowCustom bool
TimeoutSecs int
}
QuestionRequest represents a question sent from the tool to the TUI.
type QuestionResponse ¶
type QuestionResponse struct {
Answer string
}
QuestionResponse represents the user's answer from the TUI.
type TodoWrite ¶
type TodoWrite struct {
// contains filtered or unexported fields
}
func NewTodoWrite ¶
func (*TodoWrite) Description ¶
func (*TodoWrite) ParameterSchema ¶
ParameterSchema returns the JSON Schema for TodoWrite tool parameters.
func (*TodoWrite) SetSessionID ¶
type WebFetch ¶
type WebFetch struct {
// contains filtered or unexported fields
}
func NewWebFetch ¶
func (*WebFetch) Description ¶
func (*WebFetch) ParameterSchema ¶
ParameterSchema returns the JSON Schema for WebFetch tool parameters.
type WebSearch ¶
type WebSearch struct {
// contains filtered or unexported fields
}
func NewWebSearch ¶
func (*WebSearch) Close ¶ added in v1.0.2
func (t *WebSearch) Close()
Close releases idle connections held by the HTTP client's transport. Call this during shutdown to prevent connection leaks.