tool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const BinaryIndicator = "[binary file — not displaying]"

BinaryIndicator is the message returned instead of binary content.

Variables

This section is empty.

Functions

func AutoCommit

func AutoCommit(path, toolName, description string) error

AutoCommit stages the file at path and creates a commit with a conventional hawk message. toolName and description are used to build the commit message.

func BackupFile

func BackupFile(path string) (string, error)

BackupFile creates a backup of a file before modification. Returns the backup path, or empty string if backup wasn't needed.

func DecodeFileContent

func DecodeFileContent(data []byte) (string, error)

DecodeFileContent reads file bytes and returns clean UTF-8 string. Strips BOM, detects binary (null bytes in first 8KB), handles common encodings.

func DetectCredentials

func DetectCredentials(content string) string

DetectCredentials returns a non-empty description of the first credential pattern found in content, or "" if none match.

func FormatAuditSummary

func FormatAuditSummary() string

FormatAuditSummary produces a human-readable summary of today's modifications.

func IsBinaryContent

func IsBinaryContent(data []byte) bool

IsBinaryContent returns true when data contains at least one null byte in the first binaryProbeSize bytes, indicating likely binary content.

func IsBinaryData

func IsBinaryData(data []byte) bool

IsBinaryData checks for null bytes in the first 8KB.

func IsDestructiveCommand

func IsDestructiveCommand(command string) bool

IsDestructiveCommand returns true when the command contains a pattern that is considered destructive. This is a superset intended for pre-execution gating — it catches broader patterns than bash.go's dangerousSubstrings (e.g. "rm -rf ." is already caught; this also catches bare "rm -rf").

func IsGitRepo

func IsGitRepo() bool

IsGitRepo returns true when the current working directory is inside a git repository.

func IsPlanMode

func IsPlanMode() bool

IsPlanMode returns whether plan mode is active.

func IsPowerShellAvailable

func IsPowerShellAvailable() bool

IsPowerShellAvailable returns whether a PowerShell runtime is available.

func IsSafeGitCommit

func IsSafeGitCommit(command string) bool

IsSafeGitCommit checks if a git commit command is safe. Git commits with simple quoted messages are considered safe.

func IsSensitivePath

func IsSensitivePath(path string) string

IsSensitivePath returns a non-empty reason when path points to a file that should be blocked for security. The path is cleaned and, when possible, resolved through symlinks before checking.

func IsSuspicious

func IsSuspicious(command string) bool

IsSuspicious returns true if the command needs a permission prompt. This is fail-closed: anything we can't confidently classify as safe gets flagged.

func LastAutoCommitHash

func LastAutoCommitHash() string

LastAutoCommitHash returns the hash of the most recent hawk auto-commit, or "" if none has been made in this process.

func ListBackups

func ListBackups(path string) []string

ListBackups returns all backups for a file.

func RecordFileDelete

func RecordFileDelete(toolName, path string)

RecordFileDelete logs a file deletion.

func RecordFileEdit

func RecordFileEdit(toolName, path string, linesChanged int)

RecordFileEdit logs a file edit operation.

func RecordFileWrite

func RecordFileWrite(toolName, path string, bytes int)

RecordFileWrite logs a file write/create operation.

func ResolvePath

func ResolvePath(path string) (string, error)

ResolvePath returns the absolute, symlink-resolved path. If resolution fails it falls back to filepath.Abs.

func RestoreFromBackup

func RestoreFromBackup(path string) error

RestoreFromBackup restores the most recent backup of a file.

func RevertLastAutoCommit

func RevertLastAutoCommit() error

RevertLastAutoCommit reverts the most recent auto-commit, but only if the current HEAD message starts with "hawk:".

func SegmentCommand

func SegmentCommand(cmd string) []string

SegmentCommand splits a command string on &&, ||, ;, and | (respecting quotes) into individual segments for independent analysis.

func StripBOM

func StripBOM(data []byte) []byte

StripBOM removes Byte Order Mark from file content if present.

func ToolTimeout

func ToolTimeout(toolName string) time.Duration

ToolTimeout returns the default timeout for a given tool name. Callers may still override with an explicit per-invocation value.

func TruncateOutput

func TruncateOutput(s string) string

TruncateOutput trims output to maxOutputBytes and appends an indicator.

func UndoLatest

func UndoLatest() (string, error)

UndoLatest finds the most recent backup across all files and restores it. Returns the restored file path for display, or an error if no backups exist.

func ValidateToolInput

func ValidateToolInput(toolName string, input json.RawMessage) error

ValidateToolInput checks that required parameters are present and have correct types. It inspects the tool's Parameters() schema for "required" fields and verifies they exist in the provided input JSON.

func WithContainerExecutor

func WithContainerExecutor(ctx context.Context, ce ContainerExecutor) context.Context

WithContainerExecutor injects a container executor into the context. When present, BashTool routes all commands through it instead of local shell.

func WithToolContext

func WithToolContext(ctx context.Context, tc *ToolContext) context.Context

WithToolContext attaches a ToolContext to a context.

Types

type AgentTool

type AgentTool struct{}

func (AgentTool) Aliases

func (AgentTool) Aliases() []string

func (AgentTool) Description

func (AgentTool) Description() string

func (AgentTool) Execute

func (AgentTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (AgentTool) Name

func (AgentTool) Name() string

func (AgentTool) Parameters

func (AgentTool) Parameters() map[string]interface{}

func (AgentTool) RiskLevel

func (AgentTool) RiskLevel() string

type AgenticFetchTool

type AgenticFetchTool struct{}

AgenticFetchTool spawns a sub-agent to fetch, process, and summarize web content.

func (AgenticFetchTool) Aliases

func (AgenticFetchTool) Aliases() []string

func (AgenticFetchTool) Description

func (AgenticFetchTool) Description() string

func (AgenticFetchTool) Execute

func (AgenticFetchTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (AgenticFetchTool) Name

func (AgenticFetchTool) Name() string

func (AgenticFetchTool) Parameters

func (AgenticFetchTool) Parameters() map[string]interface{}

func (AgenticFetchTool) RiskLevel

func (AgenticFetchTool) RiskLevel() string

type AliasedTool

type AliasedTool interface {
	Aliases() []string
}

AliasedTool can be implemented by tools that need backward-compatible wire names.

type AskUserQuestionTool

type AskUserQuestionTool struct{}

func (AskUserQuestionTool) Aliases

func (AskUserQuestionTool) Aliases() []string

func (AskUserQuestionTool) Description

func (AskUserQuestionTool) Description() string

func (AskUserQuestionTool) Execute

func (AskUserQuestionTool) Name

func (AskUserQuestionTool) Name() string

func (AskUserQuestionTool) Parameters

func (AskUserQuestionTool) Parameters() map[string]interface{}

type AuditEntry

type AuditEntry struct {
	Timestamp    time.Time `json:"timestamp"`
	Tool         string    `json:"tool"`
	Action       string    `json:"action"` // "create", "edit", "write", "delete"
	Path         string    `json:"path"`
	BackupRef    string    `json:"backup_ref,omitempty"`
	LinesChanged int       `json:"lines_changed,omitempty"`
	BytesWritten int       `json:"bytes_written,omitempty"`
}

AuditEntry records a file modification event.

func TodayEntries

func TodayEntries() ([]AuditEntry, error)

TodayEntries reads today's audit entries.

type AuditLog

type AuditLog struct {
	// contains filtered or unexported fields
}

AuditLog tracks all file modifications for accountability.

func GetAuditLog

func GetAuditLog() *AuditLog

GetAuditLog returns the global audit log instance.

func (*AuditLog) Close

func (a *AuditLog) Close()

Close closes the audit log.

func (*AuditLog) Record

func (a *AuditLog) Record(entry AuditEntry)

Record logs a file modification event.

type BashTool

type BashTool struct{}

func (BashTool) Aliases

func (BashTool) Aliases() []string

func (BashTool) Description

func (BashTool) Description() string

func (BashTool) Execute

func (BashTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (BashTool) Name

func (BashTool) Name() string

func (BashTool) Parameters

func (BashTool) Parameters() map[string]interface{}

func (BashTool) RiskLevel

func (BashTool) RiskLevel() string

type BriefTool

type BriefTool struct{}

BriefTool (SendUserMessage) sends a message the user will read. Text outside this tool is visible in the detail view; the answer lives here.

func (BriefTool) Aliases

func (BriefTool) Aliases() []string

func (BriefTool) Description

func (BriefTool) Description() string

func (BriefTool) Execute

func (BriefTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (BriefTool) Name

func (BriefTool) Name() string

func (BriefTool) Parameters

func (BriefTool) Parameters() map[string]interface{}

type CodeSearchResult

type CodeSearchResult struct {
	Path      string
	StartLine int
	EndLine   int
	Content   string
	Symbol    string
	Language  string
	Score     float64
}

CodeSearchResult is returned by CodeSearchFn.

type CodeSearchTool

type CodeSearchTool struct{}

CodeSearchTool searches the codebase semantically.

func (CodeSearchTool) Aliases

func (CodeSearchTool) Aliases() []string

func (CodeSearchTool) Description

func (CodeSearchTool) Description() string

func (CodeSearchTool) Execute

func (CodeSearchTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (CodeSearchTool) Name

func (CodeSearchTool) Name() string

func (CodeSearchTool) Parameters

func (CodeSearchTool) Parameters() map[string]interface{}

func (CodeSearchTool) RiskLevel

func (CodeSearchTool) RiskLevel() string

type ConfigTool

type ConfigTool struct{}

ConfigTool reads/writes hawk settings.

func (ConfigTool) Aliases

func (ConfigTool) Aliases() []string

func (ConfigTool) Description

func (ConfigTool) Description() string

func (ConfigTool) Execute

func (ConfigTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (ConfigTool) Name

func (ConfigTool) Name() string

func (ConfigTool) Parameters

func (ConfigTool) Parameters() map[string]interface{}

type ContainerExecutor

type ContainerExecutor interface {
	Exec(ctx context.Context, command string, timeout time.Duration) (string, error)
	Running() bool
}

ContainerExecutor allows BashTool to route commands through a container instead of local execution. When set via context, all commands run inside the container (Docker-first mode, like herm).

func ContainerExecutorFromContext

func ContainerExecutorFromContext(ctx context.Context) ContainerExecutor

ContainerExecutorFromContext extracts the container executor, if any.

type CoreMemoryAppendTool

type CoreMemoryAppendTool struct{}

CoreMemoryAppendTool appends content to a memory block identified by label.

func (CoreMemoryAppendTool) Description

func (CoreMemoryAppendTool) Description() string

func (CoreMemoryAppendTool) Execute

func (CoreMemoryAppendTool) Name

func (CoreMemoryAppendTool) Parameters

func (CoreMemoryAppendTool) Parameters() map[string]interface{}

type CoreMemoryReplaceTool

type CoreMemoryReplaceTool struct{}

CoreMemoryReplaceTool finds and replaces content within a memory block.

func (CoreMemoryReplaceTool) Description

func (CoreMemoryReplaceTool) Description() string

func (CoreMemoryReplaceTool) Execute

func (CoreMemoryReplaceTool) Name

func (CoreMemoryReplaceTool) Parameters

func (CoreMemoryReplaceTool) Parameters() map[string]interface{}

type CoreMemoryRethinkTool

type CoreMemoryRethinkTool struct{}

CoreMemoryRethinkTool completely rewrites a memory block.

func (CoreMemoryRethinkTool) Description

func (CoreMemoryRethinkTool) Description() string

func (CoreMemoryRethinkTool) Execute

func (CoreMemoryRethinkTool) Name

func (CoreMemoryRethinkTool) Parameters

func (CoreMemoryRethinkTool) Parameters() map[string]interface{}

type CronCreateTool

type CronCreateTool struct{}

CronCreateTool schedules a prompt to run on a cron schedule.

func (CronCreateTool) Aliases

func (CronCreateTool) Aliases() []string

func (CronCreateTool) Description

func (CronCreateTool) Description() string

func (CronCreateTool) Execute

func (CronCreateTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (CronCreateTool) Name

func (CronCreateTool) Name() string

func (CronCreateTool) Parameters

func (CronCreateTool) Parameters() map[string]interface{}

type CronDeleteTool

type CronDeleteTool struct{}

CronDeleteTool removes a scheduled job.

func (CronDeleteTool) Aliases

func (CronDeleteTool) Aliases() []string

func (CronDeleteTool) Description

func (CronDeleteTool) Description() string

func (CronDeleteTool) Execute

func (CronDeleteTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (CronDeleteTool) Name

func (CronDeleteTool) Name() string

func (CronDeleteTool) Parameters

func (CronDeleteTool) Parameters() map[string]interface{}

type CronJob

type CronJob struct {
	ID        string    `json:"id"`
	Schedule  string    `json:"schedule"`
	Prompt    string    `json:"prompt"`
	Recurring bool      `json:"recurring"`
	Durable   bool      `json:"durable"`
	CreatedAt time.Time `json:"createdAt"`
	LastRun   time.Time `json:"lastRun,omitempty"`
	NextRun   time.Time `json:"nextRun"`
	Runs      int       `json:"runs"`
	// contains filtered or unexported fields
}

CronJob represents a scheduled recurring or one-shot task.

type CronListTool

type CronListTool struct{}

CronListTool lists all scheduled jobs.

func (CronListTool) Aliases

func (CronListTool) Aliases() []string

func (CronListTool) Description

func (CronListTool) Description() string

func (CronListTool) Execute

func (CronListTool) Name

func (CronListTool) Name() string

func (CronListTool) Parameters

func (CronListTool) Parameters() map[string]interface{}

type CronScheduler

type CronScheduler struct {
	// contains filtered or unexported fields
}

CronScheduler manages scheduled tasks.

func GetCronScheduler

func GetCronScheduler() *CronScheduler

func (*CronScheduler) Create

func (s *CronScheduler) Create(schedule, prompt string, recurring, durable bool) (*CronJob, error)

func (*CronScheduler) Delete

func (s *CronScheduler) Delete(id string) bool

func (*CronScheduler) Get

func (s *CronScheduler) Get(id string) (*CronJob, bool)

func (*CronScheduler) List

func (s *CronScheduler) List() []*CronJob

type DebuggerTool

type DebuggerTool struct{}

DebuggerTool provides debugging capabilities via language-specific debuggers (Delve for Go, pdb for Python, node --inspect for Node).

func (DebuggerTool) Aliases

func (DebuggerTool) Aliases() []string

func (DebuggerTool) Description

func (DebuggerTool) Description() string

func (DebuggerTool) Execute

func (DebuggerTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (DebuggerTool) Name

func (DebuggerTool) Name() string

func (DebuggerTool) Parameters

func (DebuggerTool) Parameters() map[string]interface{}

type DevEnvTool

type DevEnvTool struct{}

DevEnvTool allows the agent to read, write, and build Docker environments dynamically. When the agent needs a tool that isn't installed, it can modify the Dockerfile and rebuild the container on-the-fly (inspired by herm).

func (DevEnvTool) Aliases

func (DevEnvTool) Aliases() []string

func (DevEnvTool) Description

func (DevEnvTool) Description() string

func (DevEnvTool) Execute

func (DevEnvTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (DevEnvTool) Name

func (DevEnvTool) Name() string

func (DevEnvTool) Parameters

func (DevEnvTool) Parameters() map[string]interface{}

func (DevEnvTool) RiskLevel

func (DevEnvTool) RiskLevel() string

type DiagnosticsTool

type DiagnosticsTool struct{}

DiagnosticsTool runs lint/type/compile diagnostics for a file or project.

func (DiagnosticsTool) Aliases

func (DiagnosticsTool) Aliases() []string

func (DiagnosticsTool) Description

func (DiagnosticsTool) Description() string

func (DiagnosticsTool) Execute

func (DiagnosticsTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (DiagnosticsTool) Name

func (DiagnosticsTool) Name() string

func (DiagnosticsTool) Parameters

func (DiagnosticsTool) Parameters() map[string]interface{}

type DownloadTool

type DownloadTool struct{}

DownloadTool downloads a file from a URL to a local path.

func (DownloadTool) Aliases

func (DownloadTool) Aliases() []string

func (DownloadTool) Description

func (DownloadTool) Description() string

func (DownloadTool) Execute

func (DownloadTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (DownloadTool) Name

func (DownloadTool) Name() string

func (DownloadTool) Parameters

func (DownloadTool) Parameters() map[string]interface{}

func (DownloadTool) RiskLevel

func (DownloadTool) RiskLevel() string

type EnterPlanModeTool

type EnterPlanModeTool struct{}

func (EnterPlanModeTool) Aliases

func (EnterPlanModeTool) Aliases() []string

func (EnterPlanModeTool) Description

func (EnterPlanModeTool) Description() string

func (EnterPlanModeTool) Execute

func (EnterPlanModeTool) Name

func (EnterPlanModeTool) Name() string

func (EnterPlanModeTool) Parameters

func (EnterPlanModeTool) Parameters() map[string]interface{}

type EnterWorktreeTool

type EnterWorktreeTool struct{}

EnterWorktreeTool switches to a git worktree.

func (EnterWorktreeTool) Aliases

func (EnterWorktreeTool) Aliases() []string

func (EnterWorktreeTool) Description

func (EnterWorktreeTool) Description() string

func (EnterWorktreeTool) Execute

func (EnterWorktreeTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (EnterWorktreeTool) Name

func (EnterWorktreeTool) Name() string

func (EnterWorktreeTool) Parameters

func (EnterWorktreeTool) Parameters() map[string]interface{}

type ExitPlanModeTool

type ExitPlanModeTool struct{}

func (ExitPlanModeTool) Aliases

func (ExitPlanModeTool) Aliases() []string

func (ExitPlanModeTool) Description

func (ExitPlanModeTool) Description() string

func (ExitPlanModeTool) Execute

func (ExitPlanModeTool) Name

func (ExitPlanModeTool) Name() string

func (ExitPlanModeTool) Parameters

func (ExitPlanModeTool) Parameters() map[string]interface{}

type ExitWorktreeTool

type ExitWorktreeTool struct{}

ExitWorktreeTool returns to the main repository from a worktree.

func (ExitWorktreeTool) Aliases

func (ExitWorktreeTool) Aliases() []string

func (ExitWorktreeTool) Description

func (ExitWorktreeTool) Description() string

func (ExitWorktreeTool) Execute

func (ExitWorktreeTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (ExitWorktreeTool) Name

func (ExitWorktreeTool) Name() string

func (ExitWorktreeTool) Parameters

func (ExitWorktreeTool) Parameters() map[string]interface{}

type FileEditTool

type FileEditTool struct{}

func (FileEditTool) Aliases

func (FileEditTool) Aliases() []string

func (FileEditTool) Description

func (FileEditTool) Description() string

func (FileEditTool) Execute

func (FileEditTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (FileEditTool) Name

func (FileEditTool) Name() string

func (FileEditTool) Parameters

func (FileEditTool) Parameters() map[string]interface{}

func (FileEditTool) RiskLevel

func (FileEditTool) RiskLevel() string

type FileReadTool

type FileReadTool struct{}

func (FileReadTool) Aliases

func (FileReadTool) Aliases() []string

func (FileReadTool) Description

func (FileReadTool) Description() string

func (FileReadTool) Execute

func (FileReadTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (FileReadTool) Name

func (FileReadTool) Name() string

func (FileReadTool) Parameters

func (FileReadTool) Parameters() map[string]interface{}

func (FileReadTool) RiskLevel

func (FileReadTool) RiskLevel() string

type FileWriteTool

type FileWriteTool struct{}

func (FileWriteTool) Aliases

func (FileWriteTool) Aliases() []string

func (FileWriteTool) Description

func (FileWriteTool) Description() string

func (FileWriteTool) Execute

func (FileWriteTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (FileWriteTool) Name

func (FileWriteTool) Name() string

func (FileWriteTool) Parameters

func (FileWriteTool) Parameters() map[string]interface{}

func (FileWriteTool) RiskLevel

func (FileWriteTool) RiskLevel() string

type GitConfig

type GitConfig map[string]map[string]string

GitConfig represents a parsed .git/config file. Keys are stored as "section.key" or "section.subsection.key".

func ParseGitConfig

func ParseGitConfig(path string) (GitConfig, error)

ParseGitConfig reads and parses a git config file without spawning git. It handles: [section], [section "subsection"], key = value, and comments.

type GitState

type GitState struct {
	Branch   string
	Commit   string
	IsDirty  bool
	Worktree bool
}

GitState holds parsed git repository state read directly from the filesystem without spawning a git subprocess.

func ReadGitState

func ReadGitState(dir string) (*GitState, error)

ReadGitState reads .git/HEAD and refs to determine the current branch and commit hash without spawning a git subprocess.

type GlobTool

type GlobTool struct{}

func (GlobTool) Aliases

func (GlobTool) Aliases() []string

func (GlobTool) Description

func (GlobTool) Description() string

func (GlobTool) Execute

func (GlobTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (GlobTool) Name

func (GlobTool) Name() string

func (GlobTool) Parameters

func (GlobTool) Parameters() map[string]interface{}

func (GlobTool) RiskLevel

func (GlobTool) RiskLevel() string

type GrepTool

type GrepTool struct{}

func (GrepTool) Aliases

func (GrepTool) Aliases() []string

func (GrepTool) Description

func (GrepTool) Description() string

func (GrepTool) Execute

func (GrepTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (GrepTool) Name

func (GrepTool) Name() string

func (GrepTool) Parameters

func (GrepTool) Parameters() map[string]interface{}

func (GrepTool) RiskLevel

func (GrepTool) RiskLevel() string

type LSPTool

type LSPTool struct{}

func (LSPTool) Aliases

func (LSPTool) Aliases() []string

func (LSPTool) Description

func (LSPTool) Description() string

func (LSPTool) Execute

func (LSPTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (LSPTool) Name

func (LSPTool) Name() string

func (LSPTool) Parameters

func (LSPTool) Parameters() map[string]interface{}

type LSTool

type LSTool struct{}

func (LSTool) Aliases

func (LSTool) Aliases() []string

func (LSTool) Description

func (LSTool) Description() string

func (LSTool) Execute

func (LSTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (LSTool) Name

func (LSTool) Name() string

func (LSTool) Parameters

func (LSTool) Parameters() map[string]interface{}

func (LSTool) RiskLevel

func (LSTool) RiskLevel() string

type ListMcpResourcesTool

type ListMcpResourcesTool struct{}

func (ListMcpResourcesTool) Aliases

func (ListMcpResourcesTool) Aliases() []string

func (ListMcpResourcesTool) Description

func (ListMcpResourcesTool) Description() string

func (ListMcpResourcesTool) Execute

func (ListMcpResourcesTool) Name

func (ListMcpResourcesTool) Parameters

func (ListMcpResourcesTool) Parameters() map[string]interface{}

type MCPAuthManager

type MCPAuthManager struct {
	// contains filtered or unexported fields
}

MCPAuthManager handles OAuth flows for MCP servers.

func GetMCPAuthManager

func GetMCPAuthManager() *MCPAuthManager

func (*MCPAuthManager) GetState

func (m *MCPAuthManager) GetState(serverName string) (*MCPAuthState, bool)

func (*MCPAuthManager) SetAuthenticated

func (m *MCPAuthManager) SetAuthenticated(serverName string)

func (*MCPAuthManager) StartAuth

func (m *MCPAuthManager) StartAuth(serverName, serverURL string) (*MCPAuthState, error)

type MCPAuthState

type MCPAuthState struct {
	ServerName string `json:"serverName"`
	AuthURL    string `json:"authUrl,omitempty"`
	Status     string `json:"status"` // "pending", "authenticated", "error"
	Error      string `json:"error,omitempty"`
}

MCPAuthState tracks OAuth state for an MCP server.

type MCPTool

type MCPTool struct {
	// contains filtered or unexported fields
}

MCPTool wraps an MCP server tool as a hawk tool.

func NewMCPTool

func NewMCPTool(server *mcp.Server, t mcp.Tool) *MCPTool

func (*MCPTool) Aliases

func (m *MCPTool) Aliases() []string

func (*MCPTool) Description

func (m *MCPTool) Description() string

func (*MCPTool) Execute

func (m *MCPTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (*MCPTool) Name

func (m *MCPTool) Name() string

func (*MCPTool) Parameters

func (m *MCPTool) Parameters() map[string]interface{}

type McpAuthTool

type McpAuthTool struct{}

McpAuthTool initiates OAuth authentication for an MCP server.

func (McpAuthTool) Aliases

func (McpAuthTool) Aliases() []string

func (McpAuthTool) Description

func (McpAuthTool) Description() string

func (McpAuthTool) Execute

func (McpAuthTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (McpAuthTool) Name

func (McpAuthTool) Name() string

func (McpAuthTool) Parameters

func (McpAuthTool) Parameters() map[string]interface{}

type MultiAgentTool

type MultiAgentTool struct{}

MultiAgentTool spawns multiple sub-agents in parallel.

func (MultiAgentTool) Aliases

func (MultiAgentTool) Aliases() []string

func (MultiAgentTool) Description

func (MultiAgentTool) Description() string

func (MultiAgentTool) Execute

func (MultiAgentTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (MultiAgentTool) Name

func (MultiAgentTool) Name() string

func (MultiAgentTool) Parameters

func (MultiAgentTool) Parameters() map[string]interface{}

type MultiEditTool

type MultiEditTool struct{}

MultiEditTool applies multiple edits to a single file in one call.

func (MultiEditTool) Aliases

func (MultiEditTool) Aliases() []string

func (MultiEditTool) Description

func (MultiEditTool) Description() string

func (MultiEditTool) Execute

func (MultiEditTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (MultiEditTool) Name

func (MultiEditTool) Name() string

func (MultiEditTool) Parameters

func (MultiEditTool) Parameters() map[string]interface{}

func (MultiEditTool) RiskLevel

func (MultiEditTool) RiskLevel() string

type NotebookEditTool

type NotebookEditTool struct{}

NotebookEditTool edits Jupyter notebook cells.

func (NotebookEditTool) Aliases

func (NotebookEditTool) Aliases() []string

func (NotebookEditTool) Description

func (NotebookEditTool) Description() string

func (NotebookEditTool) Execute

func (NotebookEditTool) Name

func (NotebookEditTool) Name() string

func (NotebookEditTool) Parameters

func (NotebookEditTool) Parameters() map[string]interface{}

type PathProtector

type PathProtector interface {
	IsProtected(path string) bool
}

PathProtector checks whether a file path is protected (read-only). engine.ProtectedPaths implements this interface.

type PowerShellTool

type PowerShellTool struct{}

PowerShellTool executes PowerShell commands (Windows/cross-platform pwsh).

func (PowerShellTool) Aliases

func (PowerShellTool) Aliases() []string

func (PowerShellTool) Description

func (PowerShellTool) Description() string

func (PowerShellTool) Execute

func (PowerShellTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (PowerShellTool) Name

func (PowerShellTool) Name() string

func (PowerShellTool) Parameters

func (PowerShellTool) Parameters() map[string]interface{}

func (PowerShellTool) RiskLevel

func (PowerShellTool) RiskLevel() string

type ReadMcpResourceTool

type ReadMcpResourceTool struct{}

func (ReadMcpResourceTool) Aliases

func (ReadMcpResourceTool) Aliases() []string

func (ReadMcpResourceTool) Description

func (ReadMcpResourceTool) Description() string

func (ReadMcpResourceTool) Execute

func (ReadMcpResourceTool) Name

func (ReadMcpResourceTool) Name() string

func (ReadMcpResourceTool) Parameters

func (ReadMcpResourceTool) Parameters() map[string]interface{}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds all registered tools.

func NewRegistry

func NewRegistry(tools ...Tool) *Registry

NewRegistry creates a registry with the given tools.

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, name string, input json.RawMessage) (string, error)

Execute runs a tool by name with the given JSON input.

func (*Registry) EyrieTools

func (r *Registry) EyrieTools() []client.EyrieTool

EyrieTools converts all tools to eyrie tool definitions for the API.

func (*Registry) Filter

func (r *Registry) Filter(allow []string) *Registry

Filter returns a new Registry containing only tools whose names are in the allowlist.

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

Get returns a tool by name.

func (*Registry) PrimaryTools

func (r *Registry) PrimaryTools() []Tool

PrimaryTools returns the model-visible tools registered in this registry.

type RiskLevelProvider

type RiskLevelProvider interface {
	RiskLevel() string // "low", "medium", "high"
}

RiskLevelProvider can be implemented by tools to declare their risk level. Tools that don't implement it default to "medium".

type SkillTool

type SkillTool struct{}

func (SkillTool) Aliases

func (SkillTool) Aliases() []string

func (SkillTool) Description

func (SkillTool) Description() string

func (SkillTool) Execute

func (SkillTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (SkillTool) Name

func (SkillTool) Name() string

func (SkillTool) Parameters

func (SkillTool) Parameters() map[string]interface{}

type SleepTool

type SleepTool struct{}

SleepTool pauses execution for a specified duration.

func (SleepTool) Aliases

func (SleepTool) Aliases() []string

func (SleepTool) Description

func (SleepTool) Description() string

func (SleepTool) Execute

func (SleepTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (SleepTool) Name

func (SleepTool) Name() string

func (SleepTool) Parameters

func (SleepTool) Parameters() map[string]interface{}

type Task

type Task struct {
	ID           string           `json:"id"`
	ParentID     string           `json:"parentId,omitempty"`
	Subject      string           `json:"subject"`
	Description  string           `json:"description"`
	ActiveForm   string           `json:"activeForm,omitempty"`
	Status       TaskStatus       `json:"status"`
	Owner        string           `json:"owner,omitempty"`
	Dependencies []TaskDependency `json:"dependencies"`
	Metadata     map[string]any   `json:"metadata,omitempty"`
	CreatedAt    time.Time        `json:"createdAt"`
	UpdatedAt    time.Time        `json:"updatedAt"`
}

Task represents a structured task in the task list.

type TaskCreateTool

type TaskCreateTool struct{}

TaskCreateTool creates a new task in the task list.

func (TaskCreateTool) Aliases

func (TaskCreateTool) Aliases() []string

func (TaskCreateTool) Description

func (TaskCreateTool) Description() string

func (TaskCreateTool) Execute

func (TaskCreateTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (TaskCreateTool) Name

func (TaskCreateTool) Name() string

func (TaskCreateTool) Parameters

func (TaskCreateTool) Parameters() map[string]interface{}

type TaskDependency

type TaskDependency struct {
	TargetID string `json:"targetId"`
	Type     string `json:"type"` // "blocks", "related", "parent-child"
}

TaskDependency represents a typed dependency between tasks.

type TaskGetTool

type TaskGetTool struct{}

TaskGetTool retrieves a task by ID.

func (TaskGetTool) Aliases

func (TaskGetTool) Aliases() []string

func (TaskGetTool) Description

func (TaskGetTool) Description() string

func (TaskGetTool) Execute

func (TaskGetTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (TaskGetTool) Name

func (TaskGetTool) Name() string

func (TaskGetTool) Parameters

func (TaskGetTool) Parameters() map[string]interface{}

type TaskListTool

type TaskListTool struct{}

TaskListTool lists all tasks.

func (TaskListTool) Aliases

func (TaskListTool) Aliases() []string

func (TaskListTool) Description

func (TaskListTool) Description() string

func (TaskListTool) Execute

func (TaskListTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (TaskListTool) Name

func (TaskListTool) Name() string

func (TaskListTool) Parameters

func (TaskListTool) Parameters() map[string]interface{}

type TaskOutputTool

type TaskOutputTool struct{}

func (TaskOutputTool) Aliases

func (TaskOutputTool) Aliases() []string

func (TaskOutputTool) Description

func (TaskOutputTool) Description() string

func (TaskOutputTool) Execute

func (TaskOutputTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (TaskOutputTool) Name

func (TaskOutputTool) Name() string

func (TaskOutputTool) Parameters

func (TaskOutputTool) Parameters() map[string]interface{}

type TaskStatus

type TaskStatus string

TaskStatus represents the state of a task.

const (
	TaskStatusPending    TaskStatus = "pending"
	TaskStatusInProgress TaskStatus = "in_progress"
	TaskStatusCompleted  TaskStatus = "completed"
)

type TaskStopTool

type TaskStopTool struct{}

func (TaskStopTool) Aliases

func (TaskStopTool) Aliases() []string

func (TaskStopTool) Description

func (TaskStopTool) Description() string

func (TaskStopTool) Execute

func (TaskStopTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (TaskStopTool) Name

func (TaskStopTool) Name() string

func (TaskStopTool) Parameters

func (TaskStopTool) Parameters() map[string]interface{}

type TaskStore

type TaskStore struct {
	// contains filtered or unexported fields
}

TaskStore is a thread-safe in-memory store for tasks.

func GetTaskStore

func GetTaskStore() *TaskStore

GetTaskStore returns the global task store.

func (*TaskStore) CompactCompleted

func (s *TaskStore) CompactCompleted() string

CompactCompleted removes completed tasks and returns a summary.

func (*TaskStore) Create

func (s *TaskStore) Create(subject, description, activeForm string, metadata map[string]any) *Task

func (*TaskStore) CreateWithParent

func (s *TaskStore) CreateWithParent(subject, description, activeForm string, metadata map[string]any, parentID string) *Task

func (*TaskStore) Delete

func (s *TaskStore) Delete(id string) bool

func (*TaskStore) Get

func (s *TaskStore) Get(id string) (*Task, bool)

func (*TaskStore) GetReadyWork

func (s *TaskStore) GetReadyWork() []*Task

GetReadyWork returns pending tasks with no open blocking dependencies.

func (*TaskStore) List

func (s *TaskStore) List() []*Task

func (*TaskStore) Reset

func (s *TaskStore) Reset()

func (*TaskStore) Update

func (s *TaskStore) Update(id string, fn func(*Task)) bool

type TaskUpdateTool

type TaskUpdateTool struct{}

TaskUpdateTool updates task fields.

func (TaskUpdateTool) Aliases

func (TaskUpdateTool) Aliases() []string

func (TaskUpdateTool) Description

func (TaskUpdateTool) Description() string

func (TaskUpdateTool) Execute

func (TaskUpdateTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (TaskUpdateTool) Name

func (TaskUpdateTool) Name() string

func (TaskUpdateTool) Parameters

func (TaskUpdateTool) Parameters() map[string]interface{}

type TodoWriteTool

type TodoWriteTool struct{}

func (TodoWriteTool) Aliases

func (TodoWriteTool) Aliases() []string

func (TodoWriteTool) Description

func (TodoWriteTool) Description() string

func (TodoWriteTool) Execute

func (TodoWriteTool) Execute(_ context.Context, input json.RawMessage) (string, error)

func (TodoWriteTool) Name

func (TodoWriteTool) Name() string

func (TodoWriteTool) Parameters

func (TodoWriteTool) Parameters() map[string]interface{}

type Tool

type Tool interface {
	Name() string
	Description() string
	Parameters() map[string]interface{}
	Execute(ctx context.Context, input json.RawMessage) (string, error)
}

Tool is the interface every hawk tool implements.

func LoadMCPTools

func LoadMCPTools(ctx context.Context, name, command string, args ...string) ([]Tool, error)

LoadMCPTools connects to an MCP server and returns hawk tools for all its tools.

type ToolContext

type ToolContext struct {
	AgentSpawnFn       func(ctx context.Context, prompt string) (string, error)
	AskUserFn          func(question string) (string, error)
	CodeSearchFn       func(ctx context.Context, query string, limit int) ([]CodeSearchResult, error)
	RefreshCodeIndexFn func(ctx context.Context) error
	AvailableTools     []Tool
	AllowedDirectories []string
	SandboxMode        sandbox.Mode
	AutoCommit         bool
	Protected          PathProtector
	YaadBridge         *memory.YaadBridge
}

ToolContext carries session-level functions for tools that need them.

func GetToolContext

func GetToolContext(ctx context.Context) *ToolContext

GetToolContext retrieves the ToolContext from a context.

type ToolSearchTool

type ToolSearchTool struct{}

func (ToolSearchTool) Aliases

func (ToolSearchTool) Aliases() []string

func (ToolSearchTool) Description

func (ToolSearchTool) Description() string

func (ToolSearchTool) Execute

func (ToolSearchTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (ToolSearchTool) Name

func (ToolSearchTool) Name() string

func (ToolSearchTool) Parameters

func (ToolSearchTool) Parameters() map[string]interface{}

func (ToolSearchTool) RiskLevel

func (ToolSearchTool) RiskLevel() string

type VerifyPlanExecutionTool

type VerifyPlanExecutionTool struct{}

VerifyPlanExecutionTool checks whether a plan's steps have been executed correctly.

func (VerifyPlanExecutionTool) Aliases

func (VerifyPlanExecutionTool) Aliases() []string

func (VerifyPlanExecutionTool) Description

func (VerifyPlanExecutionTool) Description() string

func (VerifyPlanExecutionTool) Execute

func (VerifyPlanExecutionTool) Name

func (VerifyPlanExecutionTool) Parameters

func (VerifyPlanExecutionTool) Parameters() map[string]interface{}

type WebFetchTool

type WebFetchTool struct{}

func (WebFetchTool) Aliases

func (WebFetchTool) Aliases() []string

func (WebFetchTool) Description

func (WebFetchTool) Description() string

func (WebFetchTool) Execute

func (WebFetchTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (WebFetchTool) Name

func (WebFetchTool) Name() string

func (WebFetchTool) Parameters

func (WebFetchTool) Parameters() map[string]interface{}

type WebSearchTool

type WebSearchTool struct{}

func (WebSearchTool) Aliases

func (WebSearchTool) Aliases() []string

func (WebSearchTool) Description

func (WebSearchTool) Description() string

func (WebSearchTool) Execute

func (WebSearchTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (WebSearchTool) Name

func (WebSearchTool) Name() string

func (WebSearchTool) Parameters

func (WebSearchTool) Parameters() map[string]interface{}

func (WebSearchTool) RiskLevel

func (WebSearchTool) RiskLevel() string

type WorkflowDef

type WorkflowDef struct {
	Name        string         `yaml:"name" json:"name"`
	Description string         `yaml:"description" json:"description"`
	Steps       []WorkflowStep `yaml:"steps" json:"steps"`
}

WorkflowDef defines a scripted workflow loaded from .hawk/workflows/.

func ListWorkflows

func ListWorkflows() []WorkflowDef

ListWorkflows discovers available workflows.

type WorkflowStep

type WorkflowStep struct {
	Name    string `yaml:"name" json:"name"`
	Prompt  string `yaml:"prompt" json:"prompt"`
	Tool    string `yaml:"tool" json:"tool"`
	Input   string `yaml:"input" json:"input"`
	OnError string `yaml:"on_error" json:"on_error"`
}

WorkflowStep is a single step in a workflow.

type WorkflowTool

type WorkflowTool struct{}

WorkflowTool executes scripted workflows from .hawk/workflows/.

func (WorkflowTool) Aliases

func (WorkflowTool) Aliases() []string

func (WorkflowTool) Description

func (WorkflowTool) Description() string

func (WorkflowTool) Execute

func (WorkflowTool) Execute(ctx context.Context, input json.RawMessage) (string, error)

func (WorkflowTool) Name

func (WorkflowTool) Name() string

func (WorkflowTool) Parameters

func (WorkflowTool) Parameters() map[string]interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL