Documentation
¶
Index ¶
- func ExpandPath(p string) string
- func IsSkipDir(name string) bool
- func ResolvePath(workDir, userPath string) string
- type BackgroundShell
- type BashTool
- func (t *BashTool) BackgroundShells() []BackgroundShell
- func (t *BashTool) Description() string
- func (t *BashTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
- func (t *BashTool) Label() string
- func (t *BashTool) Name() string
- func (t *BashTool) Schema() map[string]any
- func (t *BashTool) SetBgOutputFactory(fn func(shellID string) (io.WriteCloser, string, error))
- func (t *BashTool) SetNotifyFn(fn func(agentcore.AgentMessage))
- func (t *BashTool) StopAllBackgroundShells() int
- func (t *BashTool) StopBackgroundShell(id string) bool
- type EditTool
- func (t *EditTool) Description() string
- func (t *EditTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
- func (t *EditTool) Label() string
- func (t *EditTool) Name() string
- func (t *EditTool) Preview(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
- func (t *EditTool) Schema() map[string]any
- type GlobTool
- type GrepTool
- type LsTool
- type ReadTool
- func (t *ReadTool) Description() string
- func (t *ReadTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
- func (t *ReadTool) ExecuteContent(ctx context.Context, args json.RawMessage) ([]agentcore.ContentBlock, error)
- func (t *ReadTool) Label() string
- func (t *ReadTool) Name() string
- func (t *ReadTool) Schema() map[string]any
- type ToolSearchTool
- func (t *ToolSearchTool) Activate(names ...string)
- func (t *ToolSearchTool) DeferredNames() []string
- func (t *ToolSearchTool) Description() string
- func (t *ToolSearchTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
- func (t *ToolSearchTool) ExecuteContent(_ context.Context, args json.RawMessage) ([]agentcore.ContentBlock, error)
- func (t *ToolSearchTool) IsDeferred(name string) bool
- func (t *ToolSearchTool) Name() string
- func (t *ToolSearchTool) Schema() map[string]any
- func (t *ToolSearchTool) WasDeferred(name string) bool
- type TruncationResult
- type WriteTool
- func (t *WriteTool) Description() string
- func (t *WriteTool) Execute(_ context.Context, args json.RawMessage) (json.RawMessage, error)
- func (t *WriteTool) Label() string
- func (t *WriteTool) Name() string
- func (t *WriteTool) Preview(_ context.Context, args json.RawMessage) (json.RawMessage, error)
- func (t *WriteTool) Schema() map[string]any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandPath ¶ added in v1.5.1
ExpandPath normalizes a user-provided path:
- Replaces Unicode special spaces with ASCII space
- Expands ~ to the user's home directory
func IsSkipDir ¶ added in v1.5.1
IsSkipDir reports whether a directory name should be excluded from traversal.
func ResolvePath ¶ added in v1.5.1
ResolvePath resolves a user-provided path against a working directory. If userPath is empty, returns workDir. If absolute, returns as-is. Otherwise joins with workDir.
Types ¶
type BackgroundShell ¶ added in v1.5.3
type BackgroundShell struct {
ID string
Command string
Description string
Status string // "running" | "completed" | "failed"
StartedAt time.Time
EndedAt time.Time
OutputFile string // path to output file on disk
ExitCode int
PID int
// contains filtered or unexported fields
}
BackgroundShell tracks a background shell command's lifecycle. Output is written to a file on disk (OutputFile) instead of memory.
type BashTool ¶
type BashTool struct {
WorkDir string
Timeout time.Duration // default: 2 minutes
// contains filtered or unexported fields
}
BashTool executes shell commands. Streams stdout+stderr via ReportToolProgress for real-time display. Final result applies tail truncation (2000 lines / 50KB). Supports run_in_background mode for long-running commands.
func (*BashTool) BackgroundShells ¶ added in v1.5.3
func (t *BashTool) BackgroundShells() []BackgroundShell
BackgroundShells returns a snapshot of all background shells.
func (*BashTool) Description ¶
func (*BashTool) Execute ¶
func (t *BashTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
func (*BashTool) SetBgOutputFactory ¶ added in v1.5.3
SetBgOutputFactory sets the factory that creates output writers for background shells. The factory receives the shell ID and returns a writer, file path, and error. If not set, background output is discarded.
func (*BashTool) SetNotifyFn ¶ added in v1.5.3
func (t *BashTool) SetNotifyFn(fn func(agentcore.AgentMessage))
SetNotifyFn sets the callback invoked when a background shell completes. Typically bound to Agent.FollowUp so the main agent receives the result.
func (*BashTool) StopAllBackgroundShells ¶ added in v1.5.3
StopAllBackgroundShells cancels all running background shells.
func (*BashTool) StopBackgroundShell ¶ added in v1.5.3
StopBackgroundShell cancels a running background shell by ID.
type EditTool ¶
type EditTool struct {
WorkDir string
}
EditTool performs exact string replacement in a file. Supports line ending normalization, fuzzy matching, and returns unified diff.
func (*EditTool) Description ¶
func (*EditTool) Execute ¶
func (t *EditTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
func (*EditTool) Preview ¶ added in v1.5.1
func (t *EditTool) Preview(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
Preview computes the diff without writing the file.
type GlobTool ¶ added in v1.5.5
type GlobTool struct {
WorkDir string
}
GlobTool matches files by glob pattern and returns relative paths sorted by modification time (newest first). Uses rg --files if available, falls back to filepath.WalkDir.
func (*GlobTool) Description ¶ added in v1.5.5
func (*GlobTool) Execute ¶ added in v1.5.5
func (t *GlobTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
type GrepTool ¶
type GrepTool struct {
WorkDir string
}
GrepTool searches file contents by pattern. Uses ripgrep (rg) if available, falls back to regexp + bufio.Scanner.
func (*GrepTool) Description ¶
func (*GrepTool) Execute ¶
func (t *GrepTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
type LsTool ¶
type LsTool struct {
WorkDir string
}
LsTool lists directory contents with optional depth control.
func (*LsTool) Description ¶
func (*LsTool) Execute ¶
func (t *LsTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
type ReadTool ¶
type ReadTool struct {
WorkDir string
}
ReadTool reads file contents with optional offset and limit. Supports directory listings and image files. Text output is streamed and truncated by line count / byte size. Binary files are rejected.
func (*ReadTool) Description ¶
func (*ReadTool) Execute ¶
func (t *ReadTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
Execute returns a text-only result (for backward compatibility / middleware).
func (*ReadTool) ExecuteContent ¶ added in v1.5.1
func (t *ReadTool) ExecuteContent(ctx context.Context, args json.RawMessage) ([]agentcore.ContentBlock, error)
ExecuteContent returns rich content blocks (text or image). Implements agentcore.ContentTool.
type ToolSearchTool ¶ added in v1.5.2
type ToolSearchTool struct {
// contains filtered or unexported fields
}
ToolSearchTool provides LLM-driven discovery of deferred tools. It implements agentcore.Tool, agentcore.ContentTool, and agentcore.DeferFilter.
When called, it returns tool_reference content blocks that instruct the API server to load the referenced deferred tool schemas into the LLM context.
func NewToolSearchTool ¶ added in v1.5.2
func NewToolSearchTool(deferred ...agentcore.Tool) *ToolSearchTool
NewToolSearchTool creates a ToolSearchTool that defers the given tools. Deferred tools are sent to the API with defer_loading: true and only loaded into LLM context when discovered via tool_reference blocks.
func (*ToolSearchTool) Activate ¶ added in v1.5.2
func (t *ToolSearchTool) Activate(names ...string)
Activate marks the given tool names as activated so their schemas are sent to the API with defer_loading: true instead of being excluded. Used to restore activation state when resuming a session.
func (*ToolSearchTool) DeferredNames ¶ added in v1.5.2
func (t *ToolSearchTool) DeferredNames() []string
DeferredNames returns the names of all deferred (not yet activated) tools.
func (*ToolSearchTool) Description ¶ added in v1.5.2
func (t *ToolSearchTool) Description() string
func (*ToolSearchTool) Execute ¶ added in v1.5.2
func (t *ToolSearchTool) Execute(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
Execute implements agentcore.Tool. Delegates to ExecuteContent and returns a text summary. In practice, the agent loop uses ExecuteContent (ContentTool) and this method serves as a fallback.
func (*ToolSearchTool) ExecuteContent ¶ added in v1.5.2
func (t *ToolSearchTool) ExecuteContent(_ context.Context, args json.RawMessage) ([]agentcore.ContentBlock, error)
ExecuteContent implements agentcore.ContentTool. Returns tool_reference content blocks for matched tools.
func (*ToolSearchTool) IsDeferred ¶ added in v1.5.2
func (t *ToolSearchTool) IsDeferred(name string) bool
IsDeferred implements agentcore.DeferFilter. Returns true for deferred tools not yet activated (should be excluded from API).
func (*ToolSearchTool) Name ¶ added in v1.5.2
func (t *ToolSearchTool) Name() string
func (*ToolSearchTool) Schema ¶ added in v1.5.2
func (t *ToolSearchTool) Schema() map[string]any
func (*ToolSearchTool) WasDeferred ¶ added in v1.5.2
func (t *ToolSearchTool) WasDeferred(name string) bool
WasDeferred implements agentcore.DeferFilter. Returns true if the tool was originally in the deferred set (regardless of activation state). Activated deferred tools are sent with defer_loading: true.
type TruncationResult ¶ added in v1.5.1
type TruncationResult struct {
Content string
Truncated bool
TruncatedBy string // "lines", "bytes", or ""
TotalLines int
TotalBytes int
OutputLines int
OutputBytes int
FirstLineExceedsLimit bool // truncateHead: first line alone exceeds byte limit
LastLinePartial bool // truncateTail: final line was byte-sliced
}
TruncationResult holds detailed metadata about a truncation operation.
type WriteTool ¶
type WriteTool struct {
WorkDir string
}
WriteTool writes content to a file, creating directories as needed.
func (*WriteTool) Description ¶
func (*WriteTool) Execute ¶
func (t *WriteTool) Execute(_ context.Context, args json.RawMessage) (json.RawMessage, error)
func (*WriteTool) Preview ¶ added in v1.5.5
func (t *WriteTool) Preview(_ context.Context, args json.RawMessage) (json.RawMessage, error)