Documentation
¶
Index ¶
- Constants
- func ConvertHTMLToMarkdown(htmlContent string) (string, error)
- func FetchURLAndConvert(ctx context.Context, client *http.Client, url string) (string, error)
- func FormatJSON(content string) (string, error)
- func GetMessageFromContext(ctx context.Context) string
- func GetModelNameFromContext(ctx context.Context) string
- func GetSessionFromContext(ctx context.Context) string
- func GetSupportsImagesFromContext(ctx context.Context) bool
- func NewBashTool(permissions permission.Service, workingDir string, ...) fantasy.AgentTool
- func NewDiagnosticsTool(lspClients *csync.Map[string, *lsp.Client]) fantasy.AgentTool
- func NewDownloadTool(permissions permission.Service, workingDir string, client *http.Client) fantasy.AgentTool
- func NewEditTool(lspClients *csync.Map[string, *lsp.Client], permissions permission.Service, ...) fantasy.AgentTool
- func NewFetchTool(permissions permission.Service, workingDir string, client *http.Client) fantasy.AgentTool
- func NewGlobTool(workingDir string) fantasy.AgentTool
- func NewGrepTool(workingDir string) fantasy.AgentTool
- func NewJobKillTool() fantasy.AgentTool
- func NewJobOutputTool() fantasy.AgentTool
- func NewLsTool(permissions permission.Service, workingDir string, lsConfig config.ToolLs) fantasy.AgentTool
- func NewMultiEditTool(lspClients *csync.Map[string, *lsp.Client], permissions permission.Service, ...) fantasy.AgentTool
- func NewReferencesTool(lspClients *csync.Map[string, *lsp.Client]) fantasy.AgentTool
- func NewSourcegraphTool(client *http.Client) fantasy.AgentTool
- func NewTodosTool(sessions session.Service) fantasy.AgentTool
- func NewViewTool(lspClients *csync.Map[string, *lsp.Client], permissions permission.Service, ...) fantasy.AgentTool
- func NewWebFetchTool(workingDir string, client *http.Client) fantasy.AgentTool
- func NewWebSearchTool(client *http.Client) fantasy.AgentTool
- func NewWriteTool(lspClients *csync.Map[string, *lsp.Client], permissions permission.Service, ...) fantasy.AgentTool
- type AgenticFetchParams
- type AgenticFetchPermissionsParams
- type BashParams
- type BashPermissionsParams
- type BashResponseMetadata
- type DiagnosticsParams
- type DownloadParams
- type DownloadPermissionsParams
- type EditParams
- type EditPermissionsParams
- type EditResponseMetadata
- type FailedEdit
- type FetchParams
- type FetchPermissionsParams
- type GlobParams
- type GlobResponseMetadata
- type GrepParams
- type GrepResponseMetadata
- type JobKillParams
- type JobKillResponseMetadata
- type JobOutputParams
- type JobOutputResponseMetadata
- type LSParams
- type LSPermissionsParams
- type LSResponseMetadata
- type LineScanner
- type MultiEditOperation
- type MultiEditParams
- type MultiEditPermissionsParams
- type MultiEditResponseMetadata
- type ReferencesParams
- type SearchResult
- type SourcegraphParams
- type SourcegraphResponseMetadata
- type TodoItem
- type TodosParams
- type TodosResponseMetadata
- type Tool
- func (m *Tool) Info() fantasy.ToolInfo
- func (m *Tool) MCP() string
- func (m *Tool) MCPToolName() string
- func (m *Tool) Name() string
- func (m *Tool) ProviderOptions() fantasy.ProviderOptions
- func (m *Tool) Run(ctx context.Context, params fantasy.ToolCall) (fantasy.ToolResponse, error)
- func (m *Tool) SetProviderOptions(opts fantasy.ProviderOptions)
- type TreeNode
- type ViewParams
- type ViewPermissionsParams
- type ViewResponseMetadata
- type WebFetchParams
- type WebSearchParams
- type WriteParams
- type WritePermissionsParams
- type WriteResponseMetadata
Constants ¶
const ( AutoBackgroundThreshold = 1 * time.Minute // Commands taking longer automatically become background jobs MaxOutputLength = 30000 BashNoOutput = "no output" )
const ( // SessionIDContextKey is the key for the session ID in the context. SessionIDContextKey sessionIDContextKey = "session_id" // MessageIDContextKey is the key for the message ID in the context. MessageIDContextKey messageIDContextKey = "message_id" // SupportsImagesContextKey is the key for the model's image support capability. SupportsImagesContextKey supportsImagesKey = "supports_images" // ModelNameContextKey is the key for the model name in the context. ModelNameContextKey modelNameKey = "model_name" )
const ( MaxReadSize = 5 * 1024 * 1024 // 5MB DefaultReadLimit = 2000 MaxLineLength = 2000 )
const AgenticFetchToolName = constants.AgenticFetchToolName
AgenticFetchToolName is the name of the agentic fetch tool. Deprecated: Use constants.AgenticFetchToolName instead.
const BashToolName = constants.BashToolName
BashToolName is the name of the bash tool. Deprecated: Use constants.BashToolName instead.
const BrowserUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
BrowserUserAgent is a realistic browser User-Agent for better compatibility.
const DiagnosticsToolName = constants.DiagnosticsToolName
DiagnosticsToolName is the name of the diagnostics tool. Deprecated: Use constants.DiagnosticsToolName instead.
const DownloadToolName = constants.DownloadToolName
DownloadToolName is the name of the download tool. Deprecated: Use constants.DownloadToolName instead.
const EditToolName = constants.EditToolName
EditToolName is the name of the edit tool. Deprecated: Use constants.EditToolName instead.
const FetchToolName = constants.FetchToolName
FetchToolName is the name of the fetch tool. Deprecated: Use constants.FetchToolName instead.
const GrepToolName = constants.GrepToolName
GrepToolName is the name of the grep tool. Deprecated: Use constants.GrepToolName instead.
const LSToolName = constants.LSToolName
LSToolName is the name of the ls tool. Deprecated: Use constants.LSToolName instead.
const LargeContentThreshold = 50000 // 50KB
LargeContentThreshold is the size threshold for saving content to a file.
const MultiEditToolName = constants.MultiEditToolName
MultiEditToolName is the name of the multiedit tool. Deprecated: Use constants.MultiEditToolName instead.
const SourcegraphToolName = constants.SourcegraphToolName
SourcegraphToolName is the name of the sourcegraph tool. Deprecated: Use constants.SourcegraphToolName instead.
const TodosToolName = constants.TodosToolName
TodosToolName is the name of the todos tool. Deprecated: Use constants.TodosToolName instead.
const ViewToolName = constants.ViewToolName
ViewToolName is the name of the view tool. Deprecated: Use constants.ViewToolName instead.
const WebFetchToolName = constants.WebFetchToolName
WebFetchToolName is the name of the web_fetch tool. Deprecated: Use constants.WebFetchToolName instead.
const WebSearchToolName = constants.WebSearchToolName
WebSearchToolName is the name of the web_search tool for sub-agents. Deprecated: Use constants.WebSearchToolName instead.
const WriteToolName = constants.WriteToolName
WriteToolName is the name of the write tool. Deprecated: Use constants.WriteToolName instead.
Variables ¶
This section is empty.
Functions ¶
func ConvertHTMLToMarkdown ¶
ConvertHTMLToMarkdown converts HTML content to markdown format.
func FetchURLAndConvert ¶
FetchURLAndConvert fetches a URL and converts HTML content to markdown.
func FormatJSON ¶
FormatJSON formats JSON content with proper indentation.
func GetMessageFromContext ¶
GetMessageFromContext retrieves the message ID from the context.
func GetModelNameFromContext ¶
GetModelNameFromContext retrieves the model name from the context.
func GetSessionFromContext ¶
GetSessionFromContext retrieves the session ID from the context.
func GetSupportsImagesFromContext ¶
GetSupportsImagesFromContext retrieves whether the model supports images from the context.
func NewBashTool ¶
func NewBashTool(permissions permission.Service, workingDir string, attribution *config.Attribution, modelName string) fantasy.AgentTool
func NewDiagnosticsTool ¶
func NewDownloadTool ¶
func NewEditTool ¶
func NewFetchTool ¶
func NewGlobTool ¶
func NewGrepTool ¶
func NewJobKillTool ¶
func NewJobOutputTool ¶
func NewMultiEditTool ¶
func NewReferencesTool ¶
func NewViewTool ¶
func NewWebFetchTool ¶
NewWebFetchTool creates a simple web fetch tool for sub-agents (no permissions needed).
func NewWebSearchTool ¶
NewWebSearchTool creates a web search tool for sub-agents (no permissions needed).
Types ¶
type AgenticFetchParams ¶
type AgenticFetchParams struct {
URL string `json:"url,omitempty" description:"The URL to fetch content from (optional - if not provided, the agent will search the web)"`
Prompt string `json:"prompt" description:"The prompt describing what information to find or extract"`
}
AgenticFetchParams defines the parameters for the agentic fetch tool.
type AgenticFetchPermissionsParams ¶
type AgenticFetchPermissionsParams struct {
URL string `json:"url,omitempty"`
Prompt string `json:"prompt"`
}
AgenticFetchPermissionsParams defines the permission parameters for the agentic fetch tool.
type BashParams ¶
type BashParams struct {
Description string `json:"description" description:"A brief description of what the command does, try to keep it under 30 characters or so"`
Command string `json:"command" description:"The command to execute"`
WorkingDir string `json:"working_dir,omitempty" description:"The working directory to execute the command in (defaults to current directory)"`
RunInBackground bool `` /* 150-byte string literal not displayed */
}
type BashPermissionsParams ¶
type BashResponseMetadata ¶
type BashResponseMetadata struct {
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
Output string `json:"output"`
Description string `json:"description"`
WorkingDirectory string `json:"working_directory"`
Background bool `json:"background,omitempty"`
ShellID string `json:"shell_id,omitempty"`
}
type DiagnosticsParams ¶
type DiagnosticsParams struct {
FilePath string `json:"file_path,omitempty" description:"The path to the file to get diagnostics for (leave w empty for project diagnostics)"`
}
type DownloadParams ¶
type EditParams ¶
type EditParams struct {
FilePath string `json:"file_path" description:"The absolute path to the file to modify"`
OldString string `json:"old_string" description:"The text to replace"`
NewString string `json:"new_string" description:"The text to replace it with"`
ReplaceAll bool `json:"replace_all,omitempty" description:"Replace all occurrences of old_string (default false)"`
}
type EditPermissionsParams ¶
type EditResponseMetadata ¶
type FailedEdit ¶
type FailedEdit struct {
Index int `json:"index"`
Error string `json:"error"`
Edit MultiEditOperation `json:"edit"`
}
type FetchParams ¶
type FetchParams struct {
URL string `json:"url" description:"The URL to fetch content from"`
Format string `json:"format" description:"The format to return the content in (text, markdown, or html)"`
Timeout int `json:"timeout,omitempty" description:"Optional timeout in seconds (max 120)"`
}
FetchParams defines the parameters for the simple fetch tool.
type FetchPermissionsParams ¶
type FetchPermissionsParams struct {
URL string `json:"url"`
Format string `json:"format"`
Timeout int `json:"timeout,omitempty"`
}
FetchPermissionsParams defines the permission parameters for the simple fetch tool.
type GlobParams ¶
type GlobResponseMetadata ¶
type GrepParams ¶
type GrepParams struct {
Pattern string `json:"pattern" description:"The regex pattern to search for in file contents"`
Path string `json:"path,omitempty" description:"The directory to search in. Defaults to the current working directory."`
Include string `json:"include,omitempty" description:"File pattern to include in the search (e.g. \"*.js\", \"*.{ts,tsx}\")"`
LiteralText bool `` /* 153-byte string literal not displayed */
}
type GrepResponseMetadata ¶
type JobKillParams ¶
type JobKillParams struct {
ShellID string `json:"shell_id" description:"The ID of the background shell to terminate"`
}
type JobKillResponseMetadata ¶
type JobOutputParams ¶
type JobOutputParams struct {
ShellID string `json:"shell_id" description:"The ID of the background shell to retrieve output from"`
}
type LSParams ¶
type LSParams struct {
Path string `json:"path,omitempty" description:"The path to the directory to list (defaults to current working directory)"`
Ignore []string `json:"ignore,omitempty" description:"List of glob patterns to ignore"`
Depth int `json:"depth,omitempty" description:"The maximum depth to traverse"`
}
type LSPermissionsParams ¶
type LSResponseMetadata ¶
type LSResponseMetadata struct {
NumberOfFiles int `json:"number_of_files"`
Truncated bool `json:"truncated"`
}
func ListDirectoryTree ¶
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 MultiEditOperation ¶
type MultiEditOperation struct {
OldString string `json:"old_string" description:"The text to replace"`
NewString string `json:"new_string" description:"The text to replace it with"`
ReplaceAll bool `json:"replace_all,omitempty" description:"Replace all occurrences of old_string (default false)."`
}
type MultiEditParams ¶
type MultiEditParams struct {
FilePath string `json:"file_path" description:"The absolute path to the file to modify"`
Edits []MultiEditOperation `json:"edits" description:"Array of edit operations to perform sequentially on the file"`
}
type MultiEditResponseMetadata ¶
type MultiEditResponseMetadata struct {
Additions int `json:"additions"`
Removals int `json:"removals"`
OldContent string `json:"old_content,omitempty"`
NewContent string `json:"new_content,omitempty"`
EditsApplied int `json:"edits_applied"`
EditsFailed []FailedEdit `json:"edits_failed,omitempty"`
}
type ReferencesParams ¶
type SearchResult ¶
SearchResult represents a single search result from DuckDuckGo.
type SourcegraphParams ¶
type SourcegraphParams struct {
Query string `json:"query" description:"The Sourcegraph search query"`
Count int `json:"count,omitempty" description:"Optional number of results to return (default: 10, max: 20)"`
ContextWindow int `json:"context_window,omitempty" description:"The context around the match to return (default: 10 lines)"`
Timeout int `json:"timeout,omitempty" description:"Optional timeout in seconds (max 120)"`
}
type TodoItem ¶
type TodoItem struct {
Content string `json:"content" description:"What needs to be done (imperative form)"`
Status string `json:"status" description:"Task status: pending, in_progress, or completed"`
ActiveForm string `json:"active_form" description:"Present continuous form (e.g., 'Running tests')"`
}
type TodosParams ¶
type TodosParams struct {
Todos []TodoItem `json:"todos" description:"The updated todo list"`
}
type TodosResponseMetadata ¶
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool is a tool from a MCP.
func GetMCPTools ¶
func GetMCPTools(permissions permission.Service, wd string) []*Tool
GetMCPTools gets all the currently available MCP tools.
func (*Tool) MCPToolName ¶
func (*Tool) ProviderOptions ¶
func (m *Tool) ProviderOptions() fantasy.ProviderOptions
func (*Tool) SetProviderOptions ¶
func (m *Tool) SetProviderOptions(opts fantasy.ProviderOptions)
type ViewParams ¶
type ViewPermissionsParams ¶
type ViewResponseMetadata ¶
type WebFetchParams ¶
type WebFetchParams struct {
URL string `json:"url" description:"The URL to fetch content from"`
}
WebFetchParams defines the parameters for the web_fetch tool.
type WebSearchParams ¶
type WebSearchParams struct {
Query string `json:"query" description:"The search query to find information on the web"`
MaxResults int `json:"max_results,omitempty" description:"Maximum number of results to return (default: 10, max: 20)"`
}
WebSearchParams defines the parameters for the web_search tool.