Documentation
¶
Index ¶
- Constants
- Variables
- func ResolveWebSearchProviderName(opts WebSearchToolOptions, query string) (string, error)
- func ToolAgentID(ctx context.Context) string
- func ToolChannel(ctx context.Context) string
- func ToolChatID(ctx context.Context) string
- func ToolMessageID(ctx context.Context) string
- func ToolReplyToMessageID(ctx context.Context) string
- func ToolSessionKey(ctx context.Context) string
- func ToolSessionScope(ctx context.Context) *session.SessionScope
- func ToolToSchema(tool Tool) map[string]any
- func WebSearchProviderReady(opts WebSearchToolOptions, name string) bool
- func WithHiddenTools(ctx context.Context, hidden func(name string, tool Tool) bool) context.Context
- func WithToolContext(ctx context.Context, channel, chatID string) context.Context
- func WithToolInboundContext(ctx context.Context, channel, chatID, messageID, replyToMessageID string) context.Context
- func WithToolMessageContext(ctx context.Context, messageID, replyToMessageID string) context.Context
- func WithToolSessionContext(ctx context.Context, agentID, sessionKey string, scope *session.SessionScope) context.Context
- type APIKeyIterator
- type APIKeyPool
- type AppendFileTool
- type AsyncCallback
- type AsyncExecutor
- type BM25SearchTool
- type BaiduSearchProvider
- type BraveSearchProvider
- type CronTool
- func (t *CronTool) Description() string
- func (t *CronTool) Execute(ctx context.Context, args map[string]any) *ToolResult
- func (t *CronTool) ExecuteJob(ctx context.Context, job *cron.CronJob) string
- func (t *CronTool) Name() string
- func (t *CronTool) Parameters() map[string]any
- func (t *CronTool) RunJob(ctx context.Context, job *cron.CronJob) (string, error)
- func (t *CronTool) SetApprovalGate(gate approval.Gate)
- type DelegateTool
- func (t *DelegateTool) Description() string
- func (t *DelegateTool) Execute(ctx context.Context, args map[string]any) *ToolResult
- func (t *DelegateTool) Name() string
- func (t *DelegateTool) Parameters() map[string]any
- func (t *DelegateTool) SetAllowlistChecker(check func(targetAgentID string) bool)
- func (t *DelegateTool) SetSelfAgentID(id string)
- func (t *DelegateTool) SetSpawner(spawner SubTurnSpawner)
- type DuckDuckGoSearchProvider
- type EditFileTool
- type ExecRequest
- type ExecResponse
- type ExecTool
- func (t *ExecTool) CallTimeout(ctx context.Context, args map[string]any) time.Duration
- func (t *ExecTool) Description() string
- func (t *ExecTool) Execute(ctx context.Context, args map[string]any) *ToolResult
- func (t *ExecTool) Name() string
- func (t *ExecTool) Parameters() map[string]any
- func (t *ExecTool) SetAllowPatterns(patterns []string) error
- func (t *ExecTool) SetRestrictToWorkspace(restrict bool)
- func (t *ExecTool) SetTimeout(timeout time.Duration)
- type FindSkillsTool
- type FunctionCall
- type GLMSearchProvider
- type GeminiSearchProvider
- type HiddenToolDoc
- type HiddenToolSnapshot
- type I2CTool
- type InstallSkillTool
- type JobExecutor
- type LLMProvider
- type LLMResponse
- type ListDirTool
- type LoadImageTool
- type MCPManager
- type MCPTool
- type Message
- type MessageTool
- type PerplexitySearchProvider
- type ProcessSession
- func (s *ProcessSession) GetExitCode() int
- func (s *ProcessSession) GetPtyKeyMode() PtyKeyMode
- func (s *ProcessSession) GetStatus() string
- func (s *ProcessSession) IsDone() bool
- func (s *ProcessSession) Kill() error
- func (s *ProcessSession) Read() string
- func (s *ProcessSession) SetExitCode(code int)
- func (s *ProcessSession) SetPtyKeyMode(mode PtyKeyMode)
- func (s *ProcessSession) SetStatus(status string)
- func (s *ProcessSession) ToSessionInfo() SessionInfo
- func (s *ProcessSession) Write(data string) error
- type PromptMetadata
- type PromptMetadataProvider
- type PtyKeyMode
- type ReactionCallback
- type ReactionTool
- type ReadFileLinesTool
- type ReadFileTool
- type RegexSearchTool
- type SPITool
- type SearXNGSearchProvider
- type SearchProvider
- type SearchResultItem
- type SelfTimed
- type SendCallbackWithContext
- type SendFileTool
- type SendTTSTool
- type SerialTool
- type SessionInfo
- type SessionManager
- type SogouSearchProvider
- type SpawnStatusTool
- type SpawnTool
- func (t *SpawnTool) Description() string
- func (t *SpawnTool) Execute(ctx context.Context, args map[string]any) *ToolResult
- func (t *SpawnTool) ExecuteAsync(ctx context.Context, args map[string]any, cb AsyncCallback) *ToolResult
- func (t *SpawnTool) Name() string
- func (t *SpawnTool) Parameters() map[string]any
- func (t *SpawnTool) SetAllowlistChecker(check func(targetAgentID string) bool)
- func (t *SpawnTool) SetSpawner(spawner SubTurnSpawner)
- type SubTurnConfig
- type SubTurnSpawner
- type SubagentManager
- type SubagentTask
- type SubagentTool
- type TavilySearchProvider
- type Tool
- type ToolCall
- type ToolDefinition
- type ToolEntry
- type ToolFunctionDefinition
- type ToolRegistry
- func (r *ToolRegistry) Clone() *ToolRegistry
- func (r *ToolRegistry) Count() int
- func (r *ToolRegistry) Execute(ctx context.Context, name string, args map[string]any) *ToolResult
- func (r *ToolRegistry) ExecuteWithContext(ctx context.Context, name string, args map[string]any, channel, chatID string, ...) *ToolResult
- func (r *ToolRegistry) Get(name string) (Tool, bool)
- func (r *ToolRegistry) GetAll() []Tool
- func (r *ToolRegistry) GetDefinitions() []map[string]any
- func (r *ToolRegistry) GetSummaries() []string
- func (r *ToolRegistry) HasRegistered(name string) bool
- func (r *ToolRegistry) List() []string
- func (r *ToolRegistry) PromoteTools(names []string, ttl int)
- func (r *ToolRegistry) PromoteToolsForSession(sessionKey string, names []string, ttl int)
- func (r *ToolRegistry) Register(tool Tool)
- func (r *ToolRegistry) RegisterExtension(tool Tool)
- func (r *ToolRegistry) RegisterHidden(tool Tool)
- func (r *ToolRegistry) SearchBM25(query string, maxSearchResults int) []ToolSearchResult
- func (r *ToolRegistry) SearchRegex(pattern string, maxSearchResults int) ([]ToolSearchResult, error)
- func (r *ToolRegistry) SetAllowlist(names []string)
- func (r *ToolRegistry) SetMediaStore(store media.MediaStore)
- func (r *ToolRegistry) SetSensitiveDataFilter(filter func(string) string)
- func (r *ToolRegistry) SnapshotHiddenTools() HiddenToolSnapshot
- func (r *ToolRegistry) TickTTL()
- func (r *ToolRegistry) TickTTLForSession(sessionKey string)
- func (r *ToolRegistry) ToProviderDefs() []providers.ToolDefinition
- func (r *ToolRegistry) ToProviderDefsForSession(sessionKey string) []providers.ToolDefinition
- func (r *ToolRegistry) Unregister(name string) bool
- func (r *ToolRegistry) Version() uint64
- type ToolResult
- func AsyncResult(forLLM string) *ToolResult
- func DiffResult(path string, before, after []byte) *ToolResult
- func ErrorResult(message string) *ToolResult
- func MediaResult(forLLM string, mediaRefs []string) *ToolResult
- func NewToolResult(forLLM string) *ToolResult
- func SilentResult(forLLM string) *ToolResult
- func UserResult(content string) *ToolResult
- type ToolSearchResult
- type UsageInfo
- type WebFetchTool
- func NewWebFetchTool(maxChars int, format string, fetchLimitBytes int64) (*WebFetchTool, error)
- func NewWebFetchToolWithConfig(maxChars int, proxy string, format string, fetchLimitBytes int64, ...) (*WebFetchTool, error)
- func NewWebFetchToolWithProxy(maxChars int, proxy string, format string, fetchLimitBytes int64, ...) (*WebFetchTool, error)
- type WebSearchTool
- type WebSearchToolOptions
- type WriteFileTool
Constants ¶
const ( MaxRegexPatternLength = 200 RegexSearchToolName = "tool_search_tool_regex" BM25SearchToolName = "tool_search_tool_bm25" )
const ( ToolPromptLayerCapability = toolshared.ToolPromptLayerCapability ToolPromptSlotTooling = toolshared.ToolPromptSlotTooling ToolPromptSlotMCP = toolshared.ToolPromptSlotMCP ToolPromptSourceRegistry = toolshared.ToolPromptSourceRegistry ToolPromptSourceDiscovery = toolshared.ToolPromptSourceDiscovery )
const MaxReadFileSize = fstools.MaxReadFileSize
Variables ¶
Functions ¶
func ResolveWebSearchProviderName ¶
func ResolveWebSearchProviderName(opts WebSearchToolOptions, query string) (string, error)
func ToolAgentID ¶
func ToolChannel ¶
func ToolChatID ¶
func ToolMessageID ¶
func ToolReplyToMessageID ¶
func ToolSessionKey ¶
func ToolSessionScope ¶
func ToolSessionScope(ctx context.Context) *session.SessionScope
func ToolToSchema ¶
func WebSearchProviderReady ¶
func WebSearchProviderReady(opts WebSearchToolOptions, name string) bool
func WithHiddenTools ¶
WithHiddenTools returns ctx for a call of a turn that is not offered the tools hidden reports (the approval policy's hide): tool discovery leaves them out. hidden runs under the registry's lock and must not use it.
func WithToolContext ¶
func WithToolInboundContext ¶
func WithToolMessageContext ¶
func WithToolSessionContext ¶
Types ¶
type APIKeyIterator ¶
type APIKeyIterator = integrationtools.APIKeyIterator
type APIKeyPool ¶
type APIKeyPool = integrationtools.APIKeyPool
func NewAPIKeyPool ¶
func NewAPIKeyPool(keys []string) *APIKeyPool
type AppendFileTool ¶
type AppendFileTool = fstools.AppendFileTool
func NewAppendFileTool ¶
func NewAppendFileTool( workspace string, restrict bool, allowPaths ...[]*regexp.Regexp, ) *AppendFileTool
type AsyncCallback ¶
type AsyncCallback = toolshared.AsyncCallback
type AsyncExecutor ¶
type AsyncExecutor = toolshared.AsyncExecutor
type BM25SearchTool ¶
type BM25SearchTool struct {
// contains filtered or unexported fields
}
func NewBM25SearchTool ¶
func NewBM25SearchTool(r *ToolRegistry, ttl int, maxSearchResults int) *BM25SearchTool
func (*BM25SearchTool) Description ¶
func (t *BM25SearchTool) Description() string
func (*BM25SearchTool) Execute ¶
func (t *BM25SearchTool) Execute(ctx context.Context, args map[string]any) *ToolResult
func (*BM25SearchTool) Name ¶
func (t *BM25SearchTool) Name() string
func (*BM25SearchTool) Parameters ¶
func (t *BM25SearchTool) Parameters() map[string]any
func (*BM25SearchTool) PromptMetadata ¶
func (t *BM25SearchTool) PromptMetadata() PromptMetadata
type BaiduSearchProvider ¶
type BaiduSearchProvider = integrationtools.BaiduSearchProvider
type BraveSearchProvider ¶
type BraveSearchProvider = integrationtools.BraveSearchProvider
type CronTool ¶
type CronTool struct {
// contains filtered or unexported fields
}
CronTool provides scheduling capabilities for the agent
func NewCronTool ¶
func NewCronTool( cronService *cron.CronService, executor JobExecutor, msgBus *bus.MessageBus, workspace string, restrict bool, execTimeout time.Duration, config *config.Config, ) (*CronTool, error)
NewCronTool creates a new CronTool execTimeout: 0 means no timeout, >0 sets the timeout duration
func (*CronTool) Description ¶
Description returns the tool description
func (*CronTool) ExecuteJob ¶
ExecuteJob executes a cron job through the agent. It returns "ok", or the error of a turn that failed; RunJob also reports a failed run as an error.
func (*CronTool) Parameters ¶
Parameters returns the tool parameters schema
func (*CronTool) RunJob ¶
RunJob executes a cron job like ExecuteJob, and returns an error when the run failed: the turn failed, the command failed, was refused or could not run, or the job's context ended first (its timeout). It is a cron.JobHandlerContext, so the job's last status records the failure.
func (*CronTool) SetApprovalGate ¶
SetApprovalGate sets the gate that decides each run of a scheduled command, asking when the approval policy says to. Without a gate the policy alone decides, and a command it says to ask about does not run.
type DelegateTool ¶
type DelegateTool struct {
// contains filtered or unexported fields
}
DelegateTool delegates a task to a specific named agent and waits for the result. Unlike spawn (async, fire-and-forget) or subagent (sync but generic), delegate targets a named agent and runs the task using that agent's own workspace, model, and tools.
func NewDelegateTool ¶
func NewDelegateTool() *DelegateTool
func (*DelegateTool) Description ¶
func (t *DelegateTool) Description() string
func (*DelegateTool) Execute ¶
func (t *DelegateTool) Execute(ctx context.Context, args map[string]any) *ToolResult
func (*DelegateTool) Name ¶
func (t *DelegateTool) Name() string
func (*DelegateTool) Parameters ¶
func (t *DelegateTool) Parameters() map[string]any
func (*DelegateTool) SetAllowlistChecker ¶
func (t *DelegateTool) SetAllowlistChecker(check func(targetAgentID string) bool)
func (*DelegateTool) SetSelfAgentID ¶
func (t *DelegateTool) SetSelfAgentID(id string)
func (*DelegateTool) SetSpawner ¶
func (t *DelegateTool) SetSpawner(spawner SubTurnSpawner)
type DuckDuckGoSearchProvider ¶
type DuckDuckGoSearchProvider = integrationtools.DuckDuckGoSearchProvider
type EditFileTool ¶
type EditFileTool = fstools.EditFileTool
func NewEditFileTool ¶
func NewEditFileTool( workspace string, restrict bool, allowPaths ...[]*regexp.Regexp, ) *EditFileTool
type ExecRequest ¶
type ExecRequest = toolshared.ExecRequest
type ExecResponse ¶
type ExecResponse = toolshared.ExecResponse
type ExecTool ¶
type ExecTool struct {
// contains filtered or unexported fields
}
func NewExecTool ¶
func NewExecToolWithConfig ¶
func (*ExecTool) CallTimeout ¶
CallTimeout returns the timeout of a foreground run, which ends it; it can be longer than the agent's default limit on a tool call. A run without a timeout and the other actions have none of their own: 0.
func (*ExecTool) Description ¶
func (*ExecTool) Parameters ¶
func (*ExecTool) SetAllowPatterns ¶
func (*ExecTool) SetRestrictToWorkspace ¶
func (*ExecTool) SetTimeout ¶
SetTimeout sets the timeout of foreground runs. 0 means none, also in turns from chat apps, which otherwise get defaultExecTimeout.
type FindSkillsTool ¶
type FindSkillsTool = integrationtools.FindSkillsTool
func NewFindSkillsTool ¶
func NewFindSkillsTool(registryMgr *skills.RegistryManager, cache *skills.SearchCache) *FindSkillsTool
type FunctionCall ¶
type FunctionCall = toolshared.FunctionCall
type GLMSearchProvider ¶
type GLMSearchProvider = integrationtools.GLMSearchProvider
type GeminiSearchProvider ¶
type GeminiSearchProvider = integrationtools.GeminiSearchProvider
type HiddenToolDoc ¶
HiddenToolDoc is a lightweight representation of a hidden tool for search indexing.
type HiddenToolSnapshot ¶
type HiddenToolSnapshot struct {
Docs []HiddenToolDoc
Version uint64
}
HiddenToolSnapshot holds a consistent snapshot of hidden tools and the registry version at which it was taken. Used by BM25SearchTool cache.
type InstallSkillTool ¶
type InstallSkillTool = integrationtools.InstallSkillTool
func NewInstallSkillTool ¶
func NewInstallSkillTool(registryMgr *skills.RegistryManager, workspace string) *InstallSkillTool
type JobExecutor ¶
type JobExecutor interface {
ProcessDirectWithChannel(ctx context.Context, content, sessionKey, channel, chatID string) (string, error)
// PublishResponseIfNeeded sends response to the outbound bus only when the
// agent did not already deliver content through the message tool in this round.
PublishResponseIfNeeded(ctx context.Context, channel, chatID, sessionKey, response string)
}
JobExecutor is the interface for executing cron jobs through the agent
type LLMProvider ¶
type LLMProvider = toolshared.LLMProvider
type LLMResponse ¶
type LLMResponse = toolshared.LLMResponse
type ListDirTool ¶
type ListDirTool = fstools.ListDirTool
func NewListDirTool ¶
func NewListDirTool( workspace string, restrict bool, allowPaths ...[]*regexp.Regexp, ) *ListDirTool
type LoadImageTool ¶
type LoadImageTool = fstools.LoadImageTool
func NewLoadImageTool ¶
func NewLoadImageTool( workspace string, restrict bool, maxFileSize int, store media.MediaStore, allowPaths ...[]*regexp.Regexp, ) *LoadImageTool
type MCPManager ¶
type MCPManager = integrationtools.MCPManager
type MCPTool ¶
type MCPTool = integrationtools.MCPTool
func NewMCPTool ¶
func NewMCPTool(manager MCPManager, serverName string, tool *mcp.Tool) *MCPTool
type Message ¶
type Message = toolshared.Message
type MessageTool ¶
type MessageTool = integrationtools.MessageTool
func NewMessageTool ¶
func NewMessageTool() *MessageTool
type PerplexitySearchProvider ¶
type PerplexitySearchProvider = integrationtools.PerplexitySearchProvider
type ProcessSession ¶
type ProcessSession struct {
ID string
PID int
Command string
PTY bool
Background bool
StartTime int64
ExitCode int
Status string
// contains filtered or unexported fields
}
func (*ProcessSession) GetExitCode ¶
func (s *ProcessSession) GetExitCode() int
func (*ProcessSession) GetPtyKeyMode ¶
func (s *ProcessSession) GetPtyKeyMode() PtyKeyMode
func (*ProcessSession) GetStatus ¶
func (s *ProcessSession) GetStatus() string
func (*ProcessSession) IsDone ¶
func (s *ProcessSession) IsDone() bool
func (*ProcessSession) Kill ¶
func (s *ProcessSession) Kill() error
func (*ProcessSession) Read ¶
func (s *ProcessSession) Read() string
func (*ProcessSession) SetExitCode ¶
func (s *ProcessSession) SetExitCode(code int)
func (*ProcessSession) SetPtyKeyMode ¶
func (s *ProcessSession) SetPtyKeyMode(mode PtyKeyMode)
func (*ProcessSession) SetStatus ¶
func (s *ProcessSession) SetStatus(status string)
func (*ProcessSession) ToSessionInfo ¶
func (s *ProcessSession) ToSessionInfo() SessionInfo
func (*ProcessSession) Write ¶
func (s *ProcessSession) Write(data string) error
type PromptMetadata ¶
type PromptMetadata = toolshared.PromptMetadata
type PromptMetadataProvider ¶
type PromptMetadataProvider = toolshared.PromptMetadataProvider
type PtyKeyMode ¶
type PtyKeyMode uint8
PtyKeyMode represents arrow key encoding mode for PTY sessions. Programs send smkx/rmkx sequences to switch between CSI and SS3 modes.
const ( PtyKeyModeCSI PtyKeyMode = iota // triggered by rmkx (\x1b[?1l) PtyKeyModeSS3 // triggered by smkx (\x1b[?1h) )
const PtyKeyModeNotFound PtyKeyMode = 255
type ReactionCallback ¶
type ReactionCallback = integrationtools.ReactionCallback
type ReactionTool ¶
type ReactionTool = integrationtools.ReactionTool
func NewReactionTool ¶
func NewReactionTool() *ReactionTool
type ReadFileLinesTool ¶
type ReadFileLinesTool = fstools.ReadFileLinesTool
func NewReadFileLinesTool ¶
type ReadFileTool ¶
type ReadFileTool = fstools.ReadFileTool
func NewReadFileBytesTool ¶
func NewReadFileTool ¶
type RegexSearchTool ¶
type RegexSearchTool struct {
// contains filtered or unexported fields
}
func NewRegexSearchTool ¶
func NewRegexSearchTool(r *ToolRegistry, ttl int, maxSearchResults int) *RegexSearchTool
func (*RegexSearchTool) Description ¶
func (t *RegexSearchTool) Description() string
func (*RegexSearchTool) Execute ¶
func (t *RegexSearchTool) Execute(ctx context.Context, args map[string]any) *ToolResult
func (*RegexSearchTool) Name ¶
func (t *RegexSearchTool) Name() string
func (*RegexSearchTool) Parameters ¶
func (t *RegexSearchTool) Parameters() map[string]any
func (*RegexSearchTool) PromptMetadata ¶
func (t *RegexSearchTool) PromptMetadata() PromptMetadata
type SearXNGSearchProvider ¶
type SearXNGSearchProvider = integrationtools.SearXNGSearchProvider
type SearchProvider ¶
type SearchProvider = integrationtools.SearchProvider
type SearchResultItem ¶
type SearchResultItem = integrationtools.SearchResultItem
type SelfTimed ¶
type SelfTimed = toolshared.SelfTimed
type SendCallbackWithContext ¶
type SendCallbackWithContext = integrationtools.SendCallbackWithContext
type SendFileTool ¶
type SendFileTool = fstools.SendFileTool
func NewSendFileTool ¶
func NewSendFileTool( workspace string, restrict bool, maxFileSize int, store media.MediaStore, allowPaths ...[]*regexp.Regexp, ) *SendFileTool
type SendTTSTool ¶
type SendTTSTool = integrationtools.SendTTSTool
func NewSendTTSTool ¶
func NewSendTTSTool(provider tts.TTSProvider, store media.MediaStore) *SendTTSTool
type SerialTool ¶
type SerialTool = hardwaretools.SerialTool
func NewSerialTool ¶
func NewSerialTool() *SerialTool
type SessionInfo ¶
type SessionInfo = toolshared.SessionInfo
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager() *SessionManager
func (*SessionManager) Add ¶
func (sm *SessionManager) Add(session *ProcessSession)
func (*SessionManager) Get ¶
func (sm *SessionManager) Get(sessionID string) (*ProcessSession, error)
func (*SessionManager) List ¶
func (sm *SessionManager) List() []SessionInfo
func (*SessionManager) Remove ¶
func (sm *SessionManager) Remove(sessionID string)
func (*SessionManager) Stop ¶
func (sm *SessionManager) Stop()
Stop shuts down the background cleanup goroutine. Safe to call multiple times from concurrent goroutines. After Stop returns, the SessionManager is still usable — only the cleanup goroutine is terminated.
type SogouSearchProvider ¶
type SogouSearchProvider = integrationtools.SogouSearchProvider
type SpawnStatusTool ¶
type SpawnStatusTool struct {
// contains filtered or unexported fields
}
SpawnStatusTool reports the status of subagents that were spawned via the spawn tool. It can query a specific task by ID, or list every known task with a summary count broken-down by status.
func NewSpawnStatusTool ¶
func NewSpawnStatusTool(manager *SubagentManager) *SpawnStatusTool
NewSpawnStatusTool creates a SpawnStatusTool backed by the given manager.
func (*SpawnStatusTool) Description ¶
func (t *SpawnStatusTool) Description() string
func (*SpawnStatusTool) Execute ¶
func (t *SpawnStatusTool) Execute(ctx context.Context, args map[string]any) *ToolResult
func (*SpawnStatusTool) Name ¶
func (t *SpawnStatusTool) Name() string
func (*SpawnStatusTool) Parameters ¶
func (t *SpawnStatusTool) Parameters() map[string]any
type SpawnTool ¶
type SpawnTool struct {
// contains filtered or unexported fields
}
func NewSpawnTool ¶
func NewSpawnTool(manager *SubagentManager) *SpawnTool
func (*SpawnTool) Description ¶
func (*SpawnTool) ExecuteAsync ¶
func (t *SpawnTool) ExecuteAsync( ctx context.Context, args map[string]any, cb AsyncCallback, ) *ToolResult
ExecuteAsync implements AsyncExecutor. The callback is passed through to the subagent manager as a call parameter — never stored on the SpawnTool instance.
func (*SpawnTool) Parameters ¶
func (*SpawnTool) SetAllowlistChecker ¶
func (*SpawnTool) SetSpawner ¶
func (t *SpawnTool) SetSpawner(spawner SubTurnSpawner)
SetSpawner sets the SubTurnSpawner for direct sub-turn execution.
type SubTurnConfig ¶
type SubTurnConfig struct {
SystemPrompt string
Async bool // true for async (spawn), false for sync (subagent)
Critical bool // continue running after parent finishes gracefully
Timeout time.Duration // 0 = use default (5 minutes)
ActualSystemPrompt string
InitialMessages []providers.Message
TargetAgentID string // If set, run as this agent (its workspace, model, tools)
}
SubTurnConfig holds configuration for spawning a sub-turn. A sub-turn runs on its agent's model: the spawning agent's — or, with TargetAgentID, the target agent's — with that agent's tools and model settings.
type SubTurnSpawner ¶
type SubTurnSpawner interface {
SpawnSubTurn(ctx context.Context, cfg SubTurnConfig) (*ToolResult, error)
}
SubTurnSpawner is an interface for spawning sub-turns. This avoids circular dependency between tools and agent packages.
type SubagentManager ¶
type SubagentManager struct {
// contains filtered or unexported fields
}
SubagentManager holds the task registry reported by spawn_status, shared by the spawn and subagent tools.
func NewSubagentManager ¶
func NewSubagentManager() *SubagentManager
func (*SubagentManager) GetTaskCopy ¶
func (sm *SubagentManager) GetTaskCopy(taskID string) (SubagentTask, bool)
GetTaskCopy returns a copy of the task with the given ID, taken under the read lock, so the caller receives a consistent snapshot with no data race.
func (*SubagentManager) ListTaskCopies ¶
func (sm *SubagentManager) ListTaskCopies() []SubagentTask
ListTaskCopies returns value copies of all tasks, taken under the read lock, so callers receive consistent snapshots with no data race.
type SubagentTask ¶
type SubagentTool ¶
type SubagentTool struct {
// contains filtered or unexported fields
}
SubagentTool executes a subagent task synchronously and returns the result. It directly calls SubTurnSpawner with Async=false for synchronous execution. The child runs as an agent, with that agent's own model settings.
func NewSubagentTool ¶
func NewSubagentTool(manager *SubagentManager) *SubagentTool
func (*SubagentTool) Description ¶
func (t *SubagentTool) Description() string
func (*SubagentTool) Execute ¶
func (t *SubagentTool) Execute(ctx context.Context, args map[string]any) *ToolResult
func (*SubagentTool) Name ¶
func (t *SubagentTool) Name() string
func (*SubagentTool) Parameters ¶
func (t *SubagentTool) Parameters() map[string]any
func (*SubagentTool) SetSpawner ¶
func (t *SubagentTool) SetSpawner(spawner SubTurnSpawner)
SetSpawner sets the SubTurnSpawner for direct sub-turn execution.
type TavilySearchProvider ¶
type TavilySearchProvider = integrationtools.TavilySearchProvider
type Tool ¶
type Tool = toolshared.Tool
type ToolCall ¶
type ToolCall = toolshared.ToolCall
type ToolDefinition ¶
type ToolDefinition = toolshared.ToolDefinition
type ToolFunctionDefinition ¶
type ToolFunctionDefinition = toolshared.ToolFunctionDefinition
type ToolRegistry ¶
type ToolRegistry struct {
// contains filtered or unexported fields
}
func NewToolRegistry ¶
func NewToolRegistry() *ToolRegistry
func (*ToolRegistry) Clone ¶
func (r *ToolRegistry) Clone() *ToolRegistry
Clone creates an independent copy of the registry containing the same tool entries (shallow copy of each ToolEntry). This is used to give subagents a snapshot of the parent agent's tools without sharing the same registry — tools registered on the parent after cloning (e.g. spawn, spawn_status) will NOT be visible to the clone, preventing recursive subagent spawning. The version counter is reset to 0 in the clone as it's a new independent registry.
func (*ToolRegistry) Count ¶
func (r *ToolRegistry) Count() int
Count returns the number of registered tools.
func (*ToolRegistry) Execute ¶
func (r *ToolRegistry) Execute(ctx context.Context, name string, args map[string]any) *ToolResult
func (*ToolRegistry) ExecuteWithContext ¶
func (r *ToolRegistry) ExecuteWithContext( ctx context.Context, name string, args map[string]any, channel, chatID string, asyncCallback AsyncCallback, ) *ToolResult
ExecuteWithContext executes a tool with channel/chatID context and optional async callback. If the tool implements AsyncExecutor and a non-nil callback is provided, ExecuteAsync is called instead of Execute — the callback is a parameter, never stored as mutable state on the tool.
func (*ToolRegistry) Get ¶
func (r *ToolRegistry) Get(name string) (Tool, bool)
Get returns a callable tool: a core tool, or a hidden tool that is unlocked for every session or for any one session.
func (*ToolRegistry) GetAll ¶
func (r *ToolRegistry) GetAll() []Tool
GetAll returns all registered tools (both core and non-core with TTL > 0). Used by SubTurn to inherit parent's tool set.
func (*ToolRegistry) GetDefinitions ¶
func (r *ToolRegistry) GetDefinitions() []map[string]any
func (*ToolRegistry) GetSummaries ¶
func (r *ToolRegistry) GetSummaries() []string
GetSummaries returns human-readable summaries of all registered tools. Returns a slice of "name - description" strings.
func (*ToolRegistry) HasRegistered ¶
func (r *ToolRegistry) HasRegistered(name string) bool
HasRegistered reports whether a tool name is present in the registry, including hidden tools whose TTL is currently zero.
func (*ToolRegistry) List ¶
func (r *ToolRegistry) List() []string
List returns a list of all registered tool names.
func (*ToolRegistry) PromoteTools ¶
func (r *ToolRegistry) PromoteTools(names []string, ttl int)
PromoteTools atomically sets the TTL for multiple non-core tools, for every session of the agent. Discovery tools unlock per session instead (see PromoteToolsForSession). Setting all TTLs under one lock prevents a concurrent TickTTL from decrementing between promotions.
func (*ToolRegistry) PromoteToolsForSession ¶
func (r *ToolRegistry) PromoteToolsForSession(sessionKey string, names []string, ttl int)
PromoteToolsForSession unlocks hidden tools for one session only, for ttl rounds of that session. An empty session key promotes for every session.
func (*ToolRegistry) Register ¶
func (r *ToolRegistry) Register(tool Tool)
Register adds a visible tool. A name that is already registered keeps its first tool -- a later tool must not silently take the place of another -- except for a tool added through RegisterExtension, which a built-in tool replaces.
func (*ToolRegistry) RegisterExtension ¶
func (r *ToolRegistry) RegisterExtension(tool Tool)
RegisterExtension adds a visible tool contributed from outside Compa, such as a module's. It never replaces a registered tool, and a built-in tool registered later under the same name replaces it.
func (*ToolRegistry) RegisterHidden ¶
func (r *ToolRegistry) RegisterHidden(tool Tool)
RegisterHidden saves hidden tools (visible only via TTL). A name that is already registered keeps its first tool.
func (*ToolRegistry) SearchBM25 ¶
func (r *ToolRegistry) SearchBM25(query string, maxSearchResults int) []ToolSearchResult
SearchBM25 ranks hidden tools against query using BM25 via utils.BM25Engine. This non-cached variant rebuilds the engine on every call. Used by tests and any code that doesn't hold a BM25SearchTool instance.
func (*ToolRegistry) SearchRegex ¶
func (r *ToolRegistry) SearchRegex(pattern string, maxSearchResults int) ([]ToolSearchResult, error)
func (*ToolRegistry) SetAllowlist ¶
func (r *ToolRegistry) SetAllowlist(names []string)
SetAllowlist restricts registrations to the provided runtime tool names. A nil slice means "allow all". An empty-but-non-nil slice means "allow none".
func (*ToolRegistry) SetMediaStore ¶
func (r *ToolRegistry) SetMediaStore(store media.MediaStore)
SetMediaStore injects a MediaStore into all registered tools that can consume it, and remembers it for future registrations.
func (*ToolRegistry) SetSensitiveDataFilter ¶
func (r *ToolRegistry) SetSensitiveDataFilter(filter func(string) string)
SetSensitiveDataFilter sets the function that removes secrets from the tool arguments and failure results the registry logs.
func (*ToolRegistry) SnapshotHiddenTools ¶
func (r *ToolRegistry) SnapshotHiddenTools() HiddenToolSnapshot
SnapshotHiddenTools returns all non-core tools and the current registry version under a single read-lock, guaranteeing consistency between the two values.
func (*ToolRegistry) TickTTL ¶
func (r *ToolRegistry) TickTTL()
TickTTL decreases TTL only for non-core tools: the TTLs set for every session and those of each session.
func (*ToolRegistry) TickTTLForSession ¶
func (r *ToolRegistry) TickTTLForSession(sessionKey string)
TickTTLForSession ends one round of a session: the tools that session unlocked, and those unlocked for every session, count down by one.
func (*ToolRegistry) ToProviderDefs ¶
func (r *ToolRegistry) ToProviderDefs() []providers.ToolDefinition
ToProviderDefs converts tool definitions to provider-compatible format. This is the format expected by LLM provider APIs. Hidden tools unlocked by any session are included; ToProviderDefsForSession limits them to one.
func (*ToolRegistry) ToProviderDefsForSession ¶
func (r *ToolRegistry) ToProviderDefsForSession(sessionKey string) []providers.ToolDefinition
ToProviderDefsForSession returns the provider definitions offered to one session: core tools, hidden tools unlocked for every session, and those the session itself unlocked. An empty key includes every session's unlocks.
func (*ToolRegistry) Unregister ¶
func (r *ToolRegistry) Unregister(name string) bool
Unregister removes a tool, reporting whether it was registered.
func (*ToolRegistry) Version ¶
func (r *ToolRegistry) Version() uint64
Version returns the current registry version (atomically).
type ToolResult ¶
type ToolResult = toolshared.ToolResult
func AsyncResult ¶
func AsyncResult(forLLM string) *ToolResult
func DiffResult ¶
func DiffResult(path string, before, after []byte) *ToolResult
func ErrorResult ¶
func ErrorResult(message string) *ToolResult
func MediaResult ¶
func MediaResult(forLLM string, mediaRefs []string) *ToolResult
func NewToolResult ¶
func NewToolResult(forLLM string) *ToolResult
func SilentResult ¶
func SilentResult(forLLM string) *ToolResult
func UserResult ¶
func UserResult(content string) *ToolResult
type ToolSearchResult ¶
ToolSearchResult represents the result returned to the LLM. Parameters are omitted from the JSON response to save context tokens; the LLM will see full schemas via ToProviderDefs after promotion.
type UsageInfo ¶
type UsageInfo = toolshared.UsageInfo
type WebFetchTool ¶
type WebFetchTool = integrationtools.WebFetchTool
func NewWebFetchTool ¶
func NewWebFetchTool(maxChars int, format string, fetchLimitBytes int64) (*WebFetchTool, error)
type WebSearchTool ¶
type WebSearchTool = integrationtools.WebSearchTool
func NewWebSearchTool ¶
func NewWebSearchTool(opts WebSearchToolOptions) (*WebSearchTool, error)
type WebSearchToolOptions ¶
type WebSearchToolOptions = integrationtools.WebSearchToolOptions
func WebSearchToolOptionsFromConfig ¶
func WebSearchToolOptionsFromConfig(cfg *config.Config) WebSearchToolOptions
type WriteFileTool ¶
type WriteFileTool = fstools.WriteFileTool
func NewWriteFileTool ¶
func NewWriteFileTool( workspace string, restrict bool, allowPaths ...[]*regexp.Regexp, ) *WriteFileTool