tools

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BashToolName = "bash"

	DefaultTimeout  = 1 * 60 * 1000  // 1 minutes in milliseconds
	MaxTimeout      = 10 * 60 * 1000 // 10 minutes in milliseconds
	MaxOutputLength = 30000
)
View Source
const (
	Context7ResolveToolName = "c7_resolve_library_id"
	Context7DocsToolName    = "c7_get_library_docs"
)
View Source
const (
	LSToolName = "ls"
	MaxLSFiles = 1000
)
View Source
const (
	ToolResponseTypeText  toolResponseType = "text"
	ToolResponseTypeImage toolResponseType = "image"

	SessionIDContextKey     sessionIDContextKey     = "session_id"
	MessageIDContextKey     messageIDContextKey     = "message_id"
	ACPClientConnContextKey acpClientConnContextKey = "acp_client_connection"
)
View Source
const (
	ViewToolName     = "view"
	MaxReadSize      = 250 * 1024
	DefaultReadLimit = 2000
	MaxLineLength    = 2000
)
View Source
const (
	BraveSearchToolName = "brave_search"
)
View Source
const (
	DiagnosticsToolName = "diagnostics"
)
View Source
const (
	EditToolName = "edit"
)
View Source
const (
	FetchToolName = "fetch"
)
View Source
const (
	GlobToolName = "glob"
)
View Source
const (
	GoogleSearchToolName = "google_search"
)
View Source
const (
	GrepToolName = "grep"
)
View Source
const (
	PatchToolName = "patch"
)
View Source
const (
	PerplexitySearchToolName = "perplexity_search"
)
View Source
const (
	SourcegraphToolName = "sourcegraph"
)
View Source
const (
	WriteToolName = "write"
)

Variables

This section is empty.

Functions

func GetContextValues

func GetContextValues(ctx context.Context) (string, string)

func ResetAllCaches added in v0.14.0

func ResetAllCaches()

ResetAllCaches clears all session-scoped caches (file locks and regex cache). Call this at the end of each session to prevent memory leaks.

func ResetRegexCache added in v0.14.0

func ResetRegexCache()

ResetRegexCache clears all cached regular expressions. Should be called at session end to prevent memory leaks.

Types

type BaseTool

type BaseTool interface {
	Info() ToolInfo
	Run(ctx context.Context, params ToolCall) (ToolResponse, error)
}

func NewBashTool

func NewBashTool(permission permission.Service) BaseTool

func NewBraveSearchTool added in v0.20.0

func NewBraveSearchTool(permissions permission.Service) BaseTool

func NewCodeFindSymbolTool added in v0.7.0

func NewCodeFindSymbolTool(indexer *code.CodeIndexer) BaseTool

func NewCodeGetProjectStatsTool added in v0.7.0

func NewCodeGetProjectStatsTool(indexer *code.CodeIndexer) BaseTool

func NewCodeGetSymbolsOverviewTool added in v0.7.0

func NewCodeGetSymbolsOverviewTool(indexer *code.CodeIndexer) BaseTool

func NewCodeHybridSearchTool added in v0.7.0

func NewCodeHybridSearchTool(indexer *code.CodeIndexer) BaseTool

func NewCodeIndexProjectTool added in v0.7.0

func NewCodeIndexProjectTool(indexer *code.CodeIndexer) BaseTool

func NewCodeIndexStatusTool added in v0.7.0

func NewCodeIndexStatusTool(indexer *code.CodeIndexer) BaseTool

func NewCodeListProjectsTool added in v0.7.0

func NewCodeListProjectsTool(indexer *code.CodeIndexer) BaseTool

func NewCodeReindexFileTool added in v0.7.0

func NewCodeReindexFileTool(indexer *code.CodeIndexer) BaseTool

func NewCodeSearchPatternTool added in v0.7.0

func NewCodeSearchPatternTool(indexer *code.CodeIndexer) BaseTool

func NewContext7Tools added in v0.20.0

func NewContext7Tools() []BaseTool

NewContext7Tools returns both Context7 tools.

func NewDiagnosticsTool

func NewDiagnosticsTool(lspClients map[string]*lsp.Client) BaseTool

func NewEditTool

func NewEditTool(lspClients map[string]*lsp.Client, permissions permission.Service, files history.Service) BaseTool

func NewFetchTool

func NewFetchTool(permissions permission.Service) BaseTool

func NewGlobTool

func NewGlobTool() BaseTool

func NewGoogleSearchTool added in v0.20.0

func NewGoogleSearchTool(permissions permission.Service) BaseTool

func NewGrepTool

func NewGrepTool() BaseTool

func NewKBAddDocumentTool added in v0.7.0

func NewKBAddDocumentTool(store *kb.KBStore) BaseTool

NewKBAddDocumentTool creates a new KBAddDocumentTool.

func NewKBDeleteDocumentTool added in v0.7.0

func NewKBDeleteDocumentTool(store *kb.KBStore) BaseTool

NewKBDeleteDocumentTool creates a new KBDeleteDocumentTool.

func NewKBGetDocumentTool added in v0.7.0

func NewKBGetDocumentTool(store *kb.KBStore) BaseTool

NewKBGetDocumentTool creates a new KBGetDocumentTool.

func NewKBSearchDocumentsTool added in v0.7.0

func NewKBSearchDocumentsTool(store *kb.KBStore) BaseTool

NewKBSearchDocumentsTool creates a new KBSearchDocumentsTool.

func NewLsTool

func NewLsTool() BaseTool

func NewMesnadaCancelTaskTool

func NewMesnadaCancelTaskTool(orch *orchestrator.Orchestrator) BaseTool

func NewMesnadaGetOutputTool

func NewMesnadaGetOutputTool(orch *orchestrator.Orchestrator) BaseTool

func NewMesnadaGetTaskTool

func NewMesnadaGetTaskTool(orch *orchestrator.Orchestrator) BaseTool

func NewMesnadaListTasksTool

func NewMesnadaListTasksTool(orch *orchestrator.Orchestrator) BaseTool

func NewMesnadaSpawnTool

func NewMesnadaSpawnTool(orch *orchestrator.Orchestrator) BaseTool

func NewMesnadaWaitTaskTool

func NewMesnadaWaitTaskTool(orch *orchestrator.Orchestrator) BaseTool

func NewPatchTool

func NewPatchTool(lspClients map[string]*lsp.Client, permissions permission.Service, files history.Service) BaseTool

func NewPerplexitySearchTool added in v0.20.0

func NewPerplexitySearchTool(permissions permission.Service) BaseTool

func NewSaveEventTool added in v0.7.0

func NewSaveEventTool(store *events.EventStore) BaseTool

NewSaveEventTool creates a new SaveEventTool.

func NewSearchEventsTool added in v0.7.0

func NewSearchEventsTool(store *events.EventStore) BaseTool

NewSearchEventsTool creates a new SearchEventsTool.

func NewSourcegraphTool

func NewSourcegraphTool() BaseTool

func NewViewTool

func NewViewTool(lspClients map[string]*lsp.Client) BaseTool

func NewWriteTool

func NewWriteTool(lspClients map[string]*lsp.Client, permissions permission.Service, files history.Service) BaseTool

type BashParams

type BashParams struct {
	Command string `json:"command"`
	Timeout int    `json:"timeout"`
}

type BashPermissionsParams

type BashPermissionsParams struct {
	Command string `json:"command"`
	Timeout int    `json:"timeout"`
}

type BashResponseMetadata

type BashResponseMetadata struct {
	StartTime int64 `json:"start_time"`
	EndTime   int64 `json:"end_time"`
}

type CodeFindSymbolTool added in v0.7.0

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

CodeFindSymbolTool finds symbols by name pattern.

func (*CodeFindSymbolTool) Info added in v0.7.0

func (t *CodeFindSymbolTool) Info() ToolInfo

func (*CodeFindSymbolTool) Run added in v0.7.0

type CodeGetProjectStatsTool added in v0.7.0

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

CodeGetProjectStatsTool returns statistics for an indexed project.

func (*CodeGetProjectStatsTool) Info added in v0.7.0

func (*CodeGetProjectStatsTool) Run added in v0.7.0

type CodeGetSymbolsOverviewTool added in v0.7.0

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

CodeGetSymbolsOverviewTool returns a high-level overview of symbols in a file.

func (*CodeGetSymbolsOverviewTool) Info added in v0.7.0

func (*CodeGetSymbolsOverviewTool) Run added in v0.7.0

type CodeHybridSearchTool added in v0.7.0

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

CodeHybridSearchTool performs hybrid semantic + FTS search over code symbols.

func (*CodeHybridSearchTool) Info added in v0.7.0

func (t *CodeHybridSearchTool) Info() ToolInfo

func (*CodeHybridSearchTool) Run added in v0.7.0

type CodeIndexProjectTool added in v0.7.0

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

CodeIndexProjectTool starts indexing a code project.

func (*CodeIndexProjectTool) Info added in v0.7.0

func (t *CodeIndexProjectTool) Info() ToolInfo

func (*CodeIndexProjectTool) Run added in v0.7.0

type CodeIndexStatusTool added in v0.7.0

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

CodeIndexStatusTool returns the status of an indexing job.

func (*CodeIndexStatusTool) Info added in v0.7.0

func (t *CodeIndexStatusTool) Info() ToolInfo

func (*CodeIndexStatusTool) Run added in v0.7.0

type CodeListProjectsTool added in v0.7.0

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

CodeListProjectsTool lists all indexed projects.

func (*CodeListProjectsTool) Info added in v0.7.0

func (t *CodeListProjectsTool) Info() ToolInfo

func (*CodeListProjectsTool) Run added in v0.7.0

type CodeReindexFileTool added in v0.7.0

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

CodeReindexFileTool re-indexes a single file.

func (*CodeReindexFileTool) Info added in v0.7.0

func (t *CodeReindexFileTool) Info() ToolInfo

func (*CodeReindexFileTool) Run added in v0.7.0

type CodeSearchPatternTool added in v0.7.0

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

CodeSearchPatternTool searches for text patterns in code symbols.

func (*CodeSearchPatternTool) Info added in v0.7.0

func (t *CodeSearchPatternTool) Info() ToolInfo

func (*CodeSearchPatternTool) Run added in v0.7.0

type DiagnosticsParams

type DiagnosticsParams struct {
	FilePath string `json:"file_path"`
}

type EditParams

type EditParams struct {
	FilePath  string `json:"file_path"`
	OldString string `json:"old_string"`
	NewString string `json:"new_string"`
}

type EditPermissionsParams

type EditPermissionsParams struct {
	FilePath string `json:"file_path"`
	Diff     string `json:"diff"`
}

type EditResponseMetadata

type EditResponseMetadata struct {
	Diff      string `json:"diff"`
	Additions int    `json:"additions"`
	Removals  int    `json:"removals"`
}

type EditStrategy added in v0.14.0

type EditStrategy interface {
	Apply(content, oldStr, newStr string) (result string, matched bool)
	Name() string
}

EditStrategy tries to find oldStr in content and replace it with newStr. Returns (result, true) on success, ("", false) if not matched. IMPORTANT: normalization is applied only for MATCHING, not for the replacement. The actual replacement must use the original content at the found position.

type FetchParams

type FetchParams struct {
	URL     string `json:"url"`
	Format  string `json:"format"`
	Timeout int    `json:"timeout,omitempty"`
}

type FetchPermissionsParams

type FetchPermissionsParams struct {
	URL     string `json:"url"`
	Format  string `json:"format"`
	Timeout int    `json:"timeout,omitempty"`
}

type GlobParams

type GlobParams struct {
	Pattern string `json:"pattern"`
	Path    string `json:"path"`
}

type GlobResponseMetadata

type GlobResponseMetadata struct {
	NumberOfFiles int  `json:"number_of_files"`
	Truncated     bool `json:"truncated"`
}

type GrepParams

type GrepParams struct {
	Pattern     string `json:"pattern"`
	Path        string `json:"path"`
	Include     string `json:"include"`
	LiteralText bool   `json:"literal_text"`
	// Extended parameters
	OutputMode string `json:"output_mode"` // "content" | "files_with_matches" | "count" (default: "files_with_matches")
	Context    int    `json:"context"`     // lines of context before AND after (-C)
	Before     int    `json:"before"`      // lines before match (-B), overrides Context
	After      int    `json:"after"`       // lines after match (-A), overrides Context
	Type       string `json:"type"`        // file type filter: "go", "js", "py", "ts", "rust", etc.
	Multiline  bool   `json:"multiline"`   // enable multiline matching
	HeadLimit  int    `json:"head_limit"`  // cap total results (0 = use default 100)
	Offset     int    `json:"offset"`      // skip first N results for pagination
}

type GrepResponseMetadata

type GrepResponseMetadata struct {
	NumberOfMatches int  `json:"number_of_matches"`
	Truncated       bool `json:"truncated"`
}

type KBAddDocumentTool added in v0.7.0

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

KBAddDocumentTool adds a document to the knowledge base.

func (*KBAddDocumentTool) Info added in v0.7.0

func (t *KBAddDocumentTool) Info() ToolInfo

func (*KBAddDocumentTool) Run added in v0.7.0

type KBDeleteDocumentTool added in v0.7.0

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

KBDeleteDocumentTool removes a document from the knowledge base.

func (*KBDeleteDocumentTool) Info added in v0.7.0

func (t *KBDeleteDocumentTool) Info() ToolInfo

func (*KBDeleteDocumentTool) Run added in v0.7.0

type KBGetDocumentTool added in v0.7.0

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

KBGetDocumentTool retrieves a document from the knowledge base by path.

func (*KBGetDocumentTool) Info added in v0.7.0

func (t *KBGetDocumentTool) Info() ToolInfo

func (*KBGetDocumentTool) Run added in v0.7.0

type KBSearchDocumentsTool added in v0.7.0

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

KBSearchDocumentsTool searches documents in the knowledge base.

func (*KBSearchDocumentsTool) Info added in v0.7.0

func (t *KBSearchDocumentsTool) Info() ToolInfo

func (*KBSearchDocumentsTool) Run added in v0.7.0

type LSParams

type LSParams struct {
	Path   string   `json:"path"`
	Ignore []string `json:"ignore"`
}

type LSResponseMetadata

type LSResponseMetadata struct {
	NumberOfFiles int  `json:"number_of_files"`
	Truncated     bool `json:"truncated"`
}

type LineScanner

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

func NewLineScanner

func NewLineScanner(r io.Reader) *LineScanner

func (*LineScanner) Err

func (s *LineScanner) Err() error

func (*LineScanner) Scan

func (s *LineScanner) Scan() bool

func (*LineScanner) Text

func (s *LineScanner) Text() string

type MesnadaCancelTaskTool

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

MesnadaCancelTaskTool cancels a running or pending Mesnada task.

func (*MesnadaCancelTaskTool) Info

func (t *MesnadaCancelTaskTool) Info() ToolInfo

func (*MesnadaCancelTaskTool) Run

type MesnadaGetOutputTool

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

MesnadaGetOutputTool returns task output for a Mesnada task.

func (*MesnadaGetOutputTool) Info

func (t *MesnadaGetOutputTool) Info() ToolInfo

func (*MesnadaGetOutputTool) Run

type MesnadaGetTaskTool

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

MesnadaGetTaskTool returns full task information for a Mesnada task.

func (*MesnadaGetTaskTool) Info

func (t *MesnadaGetTaskTool) Info() ToolInfo

func (*MesnadaGetTaskTool) Run

type MesnadaListTasksTool

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

MesnadaListTasksTool lists Mesnada tasks using optional filters.

func (*MesnadaListTasksTool) Info

func (t *MesnadaListTasksTool) Info() ToolInfo

func (*MesnadaListTasksTool) Run

type MesnadaSpawnTool

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

MesnadaSpawnTool creates and runs a Mesnada task directly through the orchestrator.

func (*MesnadaSpawnTool) Info

func (t *MesnadaSpawnTool) Info() ToolInfo

func (*MesnadaSpawnTool) Run

func (t *MesnadaSpawnTool) Run(ctx context.Context, params ToolCall) (ToolResponse, error)

type MesnadaWaitTaskTool

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

MesnadaWaitTaskTool waits for a Mesnada task to reach a terminal state.

func (*MesnadaWaitTaskTool) Info

func (t *MesnadaWaitTaskTool) Info() ToolInfo

func (*MesnadaWaitTaskTool) Run

type PatchParams

type PatchParams struct {
	PatchText string `json:"patch_text"`
}

type PatchResponseMetadata

type PatchResponseMetadata struct {
	FilesChanged []string `json:"files_changed"`
	Additions    int      `json:"additions"`
	Removals     int      `json:"removals"`
}

type SaveEventTool added in v0.7.0

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

SaveEventTool stores a temporal event with semantic search.

func (*SaveEventTool) Info added in v0.7.0

func (t *SaveEventTool) Info() ToolInfo

func (*SaveEventTool) Run added in v0.7.0

func (t *SaveEventTool) Run(ctx context.Context, params ToolCall) (ToolResponse, error)

type SearchEventsTool added in v0.7.0

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

SearchEventsTool searches events with hybrid text and time filters.

func (*SearchEventsTool) Info added in v0.7.0

func (t *SearchEventsTool) Info() ToolInfo

func (*SearchEventsTool) Run added in v0.7.0

func (t *SearchEventsTool) Run(ctx context.Context, params ToolCall) (ToolResponse, error)

type SourcegraphParams

type SourcegraphParams struct {
	Query         string `json:"query"`
	Count         int    `json:"count,omitempty"`
	ContextWindow int    `json:"context_window,omitempty"`
	Timeout       int    `json:"timeout,omitempty"`
}

type SourcegraphResponseMetadata

type SourcegraphResponseMetadata struct {
	NumberOfMatches int  `json:"number_of_matches"`
	Truncated       bool `json:"truncated"`
}

type ToolCall

type ToolCall struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Input string `json:"input"`
}

type ToolInfo

type ToolInfo struct {
	Name        string
	Description string
	Parameters  map[string]any
	Required    []string
}

type ToolResponse

type ToolResponse struct {
	Type     toolResponseType `json:"type"`
	Content  string           `json:"content"`
	Metadata string           `json:"metadata,omitempty"`
	IsError  bool             `json:"is_error"`
}

func NewTextErrorResponse

func NewTextErrorResponse(content string) ToolResponse

func NewTextResponse

func NewTextResponse(content string) ToolResponse

func WithResponseMetadata

func WithResponseMetadata(response ToolResponse, metadata any) ToolResponse

type TreeNode

type TreeNode struct {
	Name     string      `json:"name"`
	Path     string      `json:"path"`
	Type     string      `json:"type"` // "file" or "directory"
	Children []*TreeNode `json:"children,omitempty"`
}

type ViewParams

type ViewParams struct {
	FilePath string `json:"file_path"`
	Offset   int    `json:"offset"`
	Limit    int    `json:"limit"`
}

type ViewResponseMetadata

type ViewResponseMetadata struct {
	FilePath string `json:"file_path"`
	Content  string `json:"content"`
}

type WriteParams

type WriteParams struct {
	FilePath string `json:"file_path"`
	Content  string `json:"content"`
}

type WritePermissionsParams

type WritePermissionsParams struct {
	FilePath string `json:"file_path"`
	Diff     string `json:"diff"`
}

type WriteResponseMetadata

type WriteResponseMetadata struct {
	Diff      string `json:"diff"`
	Additions int    `json:"additions"`
	Removals  int    `json:"removals"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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