Documentation
¶
Index ¶
- Variables
- func BuildAll(deps *Deps, reg *CommandRegistry)
- func BuildGroup(group string, deps *Deps, reg *CommandRegistry)
- func ParseArgs[T any](arguments string) (T, error)
- func RegisterFactory(f Factory)
- func SchemaOf(proto any) map[string]any
- func SplitCommandLine(input string) ([]string, error)
- type AgentTool
- type BashArgs
- type BashTool
- func (t *BashTool) Close()
- func (t *BashTool) Definition() ToolDefinition
- func (t *BashTool) Description() string
- func (t *BashTool) Execute(ctx context.Context, arguments string) (ToolResult, error)
- func (t *BashTool) Manager() *tmux.Manager
- func (t *BashTool) Name() string
- func (t *BashTool) SetCommandNames(fn func() []string)
- func (t *BashTool) SetInbox(ib inbox.Inbox)
- func (t *BashTool) SetScannerProxy(proxy string)
- func (t *BashTool) WithScannerProxy(proxy string) *BashTool
- type Command
- type CommandRegistry
- func (r *CommandRegistry) All() []Command
- func (r *CommandRegistry) CloneTools() *CommandRegistry
- func (r *CommandRegistry) Execute(ctx context.Context, cmdLine string) (string, error)
- func (r *CommandRegistry) ExecuteArgs(ctx context.Context, tokens []string) (string, error)
- func (r *CommandRegistry) ExecuteArgsStreaming(ctx context.Context, tokens []string, stream io.Writer) (out string, err error)
- func (r *CommandRegistry) ExecuteTool(ctx context.Context, name, arguments string) (result ToolResult, err error)
- func (r *CommandRegistry) Get(name string) (Command, bool)
- func (r *CommandRegistry) GetTool(name string) (AgentTool, bool)
- func (r *CommandRegistry) GroupNames(group string) []string
- func (r *CommandRegistry) Has(name string) bool
- func (r *CommandRegistry) Names() []string
- func (r *CommandRegistry) Register(cmd Command, group string)
- func (r *CommandRegistry) RegisterTool(t AgentTool)
- func (r *CommandRegistry) SetOutput(w io.Writer)
- func (r *CommandRegistry) SetWorkDir(dir string)
- func (r *CommandRegistry) ToolDefinitions() []ToolDefinition
- func (r *CommandRegistry) Tools() []AgentTool
- func (r *CommandRegistry) UsageDocs() string
- type ContentBlock
- type Deps
- type EditPatch
- type Factory
- type FunctionDefinition
- type GlobArgs
- type GlobTool
- type OutputWriter
- type ReadArgs
- type ReadTool
- type TmuxCommand
- type ToolDefinition
- type ToolResult
- type VirtualFileReader
- type VirtualGlobber
- type WorkDirAware
- type WriteArgs
- type WriteTool
Constants ¶
This section is empty.
Variables ¶
View Source
var Output = &OutputWriter{w: io.Discard}
Output is the global output writer for commands. Commands write to it via fmt.Fprint(commands.Output, ...). The registry configures its destination before each execution.
Functions ¶
func BuildAll ¶
func BuildAll(deps *Deps, reg *CommandRegistry)
func BuildGroup ¶
func BuildGroup(group string, deps *Deps, reg *CommandRegistry)
func RegisterFactory ¶
func RegisterFactory(f Factory)
func SchemaOf ¶
SchemaOf generates a JSON Schema (as map[string]any) from a Go struct. Struct fields use standard tags:
json:"name" → property name; omitempty marks the field as optional jsonschema:"..." → description, enum, etc. per invopop/jsonschema
Fields without omitempty are automatically added to the "required" list.
func SplitCommandLine ¶
Types ¶
type AgentTool ¶
type AgentTool interface {
Name() string
Description() string
Definition() ToolDefinition
Execute(ctx context.Context, arguments string) (ToolResult, error)
}
type BashArgs ¶
type BashArgs struct {
Command string `` /* 176-byte string literal not displayed */
}
type BashTool ¶
type BashTool struct {
// contains filtered or unexported fields
}
func NewBashTool ¶
func (*BashTool) Definition ¶
func (t *BashTool) Definition() ToolDefinition
func (*BashTool) Description ¶
func (*BashTool) SetCommandNames ¶
func (*BashTool) SetScannerProxy ¶
func (*BashTool) WithScannerProxy ¶
type CommandRegistry ¶
type CommandRegistry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *CommandRegistry
func (*CommandRegistry) All ¶
func (r *CommandRegistry) All() []Command
func (*CommandRegistry) CloneTools ¶
func (r *CommandRegistry) CloneTools() *CommandRegistry
func (*CommandRegistry) ExecuteArgs ¶
func (*CommandRegistry) ExecuteArgsStreaming ¶
func (*CommandRegistry) ExecuteTool ¶
func (r *CommandRegistry) ExecuteTool(ctx context.Context, name, arguments string) (result ToolResult, err error)
func (*CommandRegistry) GroupNames ¶
func (r *CommandRegistry) GroupNames(group string) []string
func (*CommandRegistry) Has ¶
func (r *CommandRegistry) Has(name string) bool
func (*CommandRegistry) Names ¶
func (r *CommandRegistry) Names() []string
func (*CommandRegistry) Register ¶
func (r *CommandRegistry) Register(cmd Command, group string)
func (*CommandRegistry) RegisterTool ¶
func (r *CommandRegistry) RegisterTool(t AgentTool)
func (*CommandRegistry) SetOutput ¶
func (r *CommandRegistry) SetOutput(w io.Writer)
func (*CommandRegistry) SetWorkDir ¶
func (r *CommandRegistry) SetWorkDir(dir string)
func (*CommandRegistry) ToolDefinitions ¶
func (r *CommandRegistry) ToolDefinitions() []ToolDefinition
func (*CommandRegistry) Tools ¶
func (r *CommandRegistry) Tools() []AgentTool
func (*CommandRegistry) UsageDocs ¶
func (r *CommandRegistry) UsageDocs() string
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
MimeType string `json:"mime_type,omitempty"`
Base64Data string `json:"base64_data,omitempty"`
}
func ImageBlock ¶
func ImageBlock(mimeType, base64Data string) ContentBlock
func TextBlock ¶
func TextBlock(text string) ContentBlock
type Deps ¶
type EditPatch ¶
type EditPatch struct {
OldText string `` /* 141-byte string literal not displayed */
NewText string `json:"new_text" jsonschema:"description=Replacement text for this edit."`
ReplaceAll bool `json:"replace_all,omitempty" jsonschema:"description=Replace all occurrences of old_text instead of requiring uniqueness."`
}
type Factory ¶
type Factory struct {
Group string
Build func(deps *Deps, reg *CommandRegistry)
}
type FunctionDefinition ¶
type FunctionDefinition = provider.FunctionDefinition
type GlobTool ¶
type GlobTool struct {
// contains filtered or unexported fields
}
func NewGlobTool ¶
func NewGlobTool(workDir string, globbers ...VirtualGlobber) *GlobTool
func (*GlobTool) Definition ¶
func (t *GlobTool) Definition() ToolDefinition
func (*GlobTool) Description ¶
type OutputWriter ¶
type OutputWriter struct {
// contains filtered or unexported fields
}
func (*OutputWriter) Captured ¶
func (o *OutputWriter) Captured() string
func (*OutputWriter) Reset ¶
func (o *OutputWriter) Reset(w io.Writer)
type ReadArgs ¶
type ReadArgs struct {
Path string `json:"path" jsonschema:"description=File path to read (absolute or relative to working directory)"`
Offset int `json:"offset,omitempty" jsonschema:"description=1-indexed line number to start reading from (default: 1)"`
Limit int `json:"limit,omitempty" jsonschema:"description=Maximum number of lines to read (default: 2000)"`
}
type ReadTool ¶
type ReadTool struct {
// contains filtered or unexported fields
}
func NewReadTool ¶
func NewReadTool(workDir string, readers ...VirtualFileReader) *ReadTool
func (*ReadTool) Definition ¶
func (t *ReadTool) Definition() ToolDefinition
func (*ReadTool) Description ¶
type TmuxCommand ¶
type TmuxCommand struct {
// contains filtered or unexported fields
}
func NewTmuxCommand ¶
func NewTmuxCommand(mgr *tmux.Manager) *TmuxCommand
func (*TmuxCommand) Execute ¶
func (t *TmuxCommand) Execute(ctx context.Context, args []string) error
func (*TmuxCommand) Name ¶
func (t *TmuxCommand) Name() string
func (*TmuxCommand) Usage ¶
func (t *TmuxCommand) Usage() string
type ToolDefinition ¶
type ToolDefinition = provider.ToolDefinition
func ToolDef ¶
func ToolDef(name, description string, argsProto any) ToolDefinition
ToolDef builds a complete ToolDefinition from a name, description, and an args struct prototype.
type ToolResult ¶
type ToolResult struct {
Content []ContentBlock
IsError bool
Terminate bool
}
func ErrorResult ¶
func ErrorResult(msg string) ToolResult
func TerminateResult ¶
func TerminateResult(s string) ToolResult
func TextResult ¶
func TextResult(s string) ToolResult
func (ToolResult) HasImages ¶
func (r ToolResult) HasImages() bool
func (ToolResult) Text ¶
func (r ToolResult) Text() string
Text returns all text content blocks concatenated, for backward compatibility with code that expects a plain string.
type VirtualFileReader ¶
type VirtualGlobber ¶
type WorkDirAware ¶
type WorkDirAware interface {
SetWorkDir(dir string)
}
type WriteArgs ¶
type WriteArgs struct {
Path string `json:"path" jsonschema:"description=File path to write or edit (absolute or relative to working directory)"`
Content string `json:"content,omitempty" jsonschema:"description=Full file content for write mode. Ignored when edits is provided."`
Edits []EditPatch `` /* 166-byte string literal not displayed */
}
type WriteTool ¶
type WriteTool struct {
// contains filtered or unexported fields
}
func NewWriteTool ¶
func (*WriteTool) Definition ¶
func (t *WriteTool) Definition() ToolDefinition
func (*WriteTool) Description ¶
Click to show internal directories.
Click to hide internal directories.