Documentation
¶
Overview ¶
Package coding provides agent tools for terminal control, file I/O, web search, and code execution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveToolNames ¶
func ActiveToolNames() []string
ActiveToolNames returns the default active coding tool names.
func RegisterAll ¶
RegisterAll registers chat assistant tools on the registry.
Types ¶
type ReadFileTool ¶
type ReadFileTool struct {
Workspace Workspace
Env env.ExecutionEnv
}
ReadFileTool reads file contents from the workspace.
func (ReadFileTool) Description ¶
func (ReadFileTool) Description() string
Description explains the tool to the model.
func (ReadFileTool) Execute ¶
func (t ReadFileTool) Execute(ctx context.Context, id string, args map[string]any, _ tool.UpdateHandler) (msg.ToolResultMessage, error)
Execute reads the requested file.
func (ReadFileTool) Parameters ¶
func (ReadFileTool) Parameters() map[string]any
Parameters returns the JSON schema for tool arguments.
type RunCodeTool ¶
type RunCodeTool struct {
Workspace Workspace
Env env.ExecutionEnv
}
RunCodeTool executes source code by writing a temporary file and invoking an interpreter.
func (RunCodeTool) Description ¶
func (RunCodeTool) Description() string
Description explains the tool to the model.
func (RunCodeTool) Execute ¶
func (t RunCodeTool) Execute(ctx context.Context, id string, args map[string]any, onUpdate tool.UpdateHandler) (msg.ToolResultMessage, error)
Execute runs the provided code snippet.
func (RunCodeTool) Parameters ¶
func (RunCodeTool) Parameters() map[string]any
Parameters returns the JSON schema for tool arguments.
type RunTerminalTool ¶
type RunTerminalTool struct {
Workspace Workspace
Env env.ExecutionEnv
}
RunTerminalTool executes shell commands inside the workspace.
func (RunTerminalTool) Description ¶
func (RunTerminalTool) Description() string
Description explains the tool to the model.
func (RunTerminalTool) Execute ¶
func (t RunTerminalTool) Execute(ctx context.Context, id string, args map[string]any, onUpdate tool.UpdateHandler) (msg.ToolResultMessage, error)
Execute runs the requested command.
func (RunTerminalTool) Name ¶
func (RunTerminalTool) Name() string
Name returns the tool identifier.
func (RunTerminalTool) Parameters ¶
func (RunTerminalTool) Parameters() map[string]any
Parameters returns the JSON schema for tool arguments.
type WebSearchTool ¶
type WebSearchTool struct {
HTTPClient *http.Client
MaxOutput int
// BaseURL overrides the DuckDuckGo endpoint for tests.
BaseURL string
}
WebSearchTool searches the web using DuckDuckGo Instant Answer API.
func (WebSearchTool) Description ¶
func (WebSearchTool) Description() string
Description explains the tool to the model.
func (WebSearchTool) Execute ¶
func (t WebSearchTool) Execute(ctx context.Context, id string, args map[string]any, onUpdate tool.UpdateHandler) (msg.ToolResultMessage, error)
Execute performs the web search.
func (WebSearchTool) Parameters ¶
func (WebSearchTool) Parameters() map[string]any
Parameters returns the JSON schema for tool arguments.
type Workspace ¶
type Workspace struct {
// Root is the absolute workspace path.
Root string
// Timeout limits shell and code execution duration.
Timeout time.Duration
// MaxOutput truncates tool stdout/stderr beyond this byte count.
MaxOutput int
}
Workspace bounds file and shell operations to a single root directory.
func (Workspace) ResolvePath ¶
ResolvePath maps a relative or absolute path into the workspace root.
func (Workspace) TruncateOutput ¶
TruncateOutput limits output size for model context safety.
type WriteFileTool ¶
type WriteFileTool struct {
Workspace Workspace
Env env.ExecutionEnv
}
WriteFileTool writes or overwrites a file in the workspace.
func (WriteFileTool) Description ¶
func (WriteFileTool) Description() string
Description explains the tool to the model.
func (WriteFileTool) Execute ¶
func (t WriteFileTool) Execute(ctx context.Context, id string, args map[string]any, _ tool.UpdateHandler) (msg.ToolResultMessage, error)
Execute writes the requested file.
func (WriteFileTool) Parameters ¶
func (WriteFileTool) Parameters() map[string]any
Parameters returns the JSON schema for tool arguments.