tools

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 30 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 (
	BatchToolName        = "batch"
	BatchToolDescription = `` /* 1029-byte string literal not displayed */

)
View Source
const (
	LSToolName = "ls"
	MaxLSFiles = 1000
)
View Source
const (
	ToolResponseTypeText  toolResponseType = "text"
	ToolResponseTypeImage toolResponseType = "image"

	SessionIDContextKey sessionIDContextKey = "session_id"
	MessageIDContextKey messageIDContextKey = "message_id"
)
View Source
const (
	ViewToolName     = "view"
	MaxReadSize      = 250 * 1024
	DefaultReadLimit = 2000
	MaxLineLength    = 2000
)
View Source
const (
	CodeActionToolName = "codeAction"
)
View Source
const (
	DefinitionToolName = "definition"
)
View Source
const (
	DiagnosticsToolName = "diagnostics"
)
View Source
const (
	DocSymbolsToolName = "docSymbols"
)
View Source
const (
	EditToolName = "edit"
)
View Source
const (
	FetchToolName = "fetch"
)
View Source
const (
	GlobToolName = "glob"
)
View Source
const (
	GrepToolName = "grep"
)
View Source
const (
	PatchToolName = "patch"
)
View Source
const (
	ReferencesToolName = "references"
)
View Source
const (
	WorkspaceSymbolsToolName = "workspaceSymbols"
)
View Source
const (
	WriteToolName = "write"
)

Variables

This section is empty.

Functions

func GetContextValues

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

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 NewBatchTool added in v0.0.49

func NewBatchTool(tools map[string]BaseTool) BaseTool

func NewCodeActionTool

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

func NewDefinitionTool

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

func NewDiagnosticsTool

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

func NewDocSymbolsTool

func NewDocSymbolsTool(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 NewGrepTool

func NewGrepTool() BaseTool

func NewLsTool

func NewLsTool() BaseTool

func NewPatchTool

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

func NewReferencesTool

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

func NewViewTool

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

func NewWorkspaceSymbolsTool

func NewWorkspaceSymbolsTool(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 BatchParams added in v0.0.49

type BatchParams struct {
	Calls []BatchToolCall `json:"calls"`
}

type BatchResult added in v0.0.49

type BatchResult struct {
	Results []BatchToolResult `json:"results"`
}

type BatchToolCall added in v0.0.49

type BatchToolCall struct {
	Name  string          `json:"name"`
	Input json.RawMessage `json:"input"`
}

type BatchToolResult added in v0.0.49

type BatchToolResult struct {
	ToolName  string          `json:"tool_name"`
	ToolInput json.RawMessage `json:"tool_input"`
	Result    json.RawMessage `json:"result"`
	Error     string          `json:"error,omitempty"`
	// Added for better formatting and separation between results
	Separator string `json:"separator,omitempty"`
}

type CodeActionParams

type CodeActionParams struct {
	FilePath  string `json:"file_path"`
	Line      int    `json:"line"`
	Column    int    `json:"column"`
	EndLine   int    `json:"end_line,omitempty"`
	EndColumn int    `json:"end_column,omitempty"`
	ActionID  int    `json:"action_id,omitempty"`
	LspName   string `json:"lsp_name,omitempty"`
}

type DefinitionParams

type DefinitionParams struct {
	FilePath string `json:"file_path"`
	Line     int    `json:"line"`
	Column   int    `json:"column"`
}

type DiagnosticsParams

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

type DocSymbolsParams

type DocSymbolsParams 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 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"`
}

type GrepResponseMetadata

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

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 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 ReferencesParams

type ReferencesParams struct {
	FilePath           string `json:"file_path"`
	Line               int    `json:"line"`
	Column             int    `json:"column"`
	IncludeDeclaration bool   `json:"include_declaration"`
}

type SymbolInfo

type SymbolInfo struct {
	Name     string
	Kind     string
	Location string
	Children []SymbolInfo
}

SymbolInfo represents a symbol in a document

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 WorkspaceSymbolsParams

type WorkspaceSymbolsParams struct {
	Query string `json:"query"`
}

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