tools

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 59 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tools implements the agent's callable tool surface and the toolset groupings that decide which tools a given platform exposes.

Index

Constants

View Source
const MCPPrefix = "mcp__"

MCPPrefix namespaces tools imported from MCP servers.

Variables

View Source
var ErrShellConfigChanged = errors.New("terminal configuration changed; retry when current command finishes")

ErrShellConfigChanged reports that a persistent shell is still executing a command under the previous terminal configuration. The caller should retry once that command finishes, which lets session() retire the stale shell.

View Source
var Toolsets = map[string][]string{

	"none":    {},
	"minimal": {"read_file", "list_files", "grep", "todo"},
	"coding": {
		"read_file", "read_document", "write_file", "edit_file", "list_files", "glob", "grep",
		"terminal", "process", "todo", "board", "project_info", "set_soul", "skill", "delegate_task", "task", "list_roles", "diagnostics", "http_request", "ask_user", "schedule",
	},
	"research": {
		"read_file", "read_document", "web_search", "web_fetch", "http_request", "browser", "grep", "todo", "memory",
		"session_search", "rag_search", "skill", "view_image", "report_finding", "add_intel", "methodology_status",
		"delegate_task", "task", "list_roles",
	},
	"browser": {"browser", "web_search", "web_fetch", "http_request", "read_file", "write_file", "todo", "report_finding", "add_intel", "methodology_status"},
	"security": {
		"read_file", "write_file", "list_files", "glob", "grep", "terminal", "process",
		"web_search", "web_fetch", "http_request", "browser", "todo", "skill",
		"report_finding", "triage_finding", "add_intel", "methodology_status",
		"delegate_task", "task", "list_roles", "diagnostics", "ask_user", "vps_run", "vps_upload", "vps_download",
		"osint_dns", "osint_dorks", "osint_whois", "osint_ip", "osint_username", "osint_github", "osint_email", "osint_email_full", "list_proxies", "osint_breach", "osint_shodan", "osint_reputation", "osint_crypto", "osint_domain", "osint_phone", "osint_scrape", "osint_paste", "osint_footprint", "osint_pivot", "osint_google", "osint_dorks_live", "check_dependencies", "re_info", "re_strings", "re_analyze", "re_decompile", "solve_captcha", "intercept",
		"attack_script", "awshook", "azurehook", "kubehook", "winhook", "machook", "cipipe", "ebpf",
		"hackbrowser",
	},
	"osint": {
		"osint_dns", "osint_dorks", "osint_whois", "osint_ip", "osint_username", "osint_github", "osint_email", "osint_email_full", "list_proxies", "osint_breach", "osint_shodan", "osint_reputation", "osint_crypto", "osint_domain", "osint_phone", "osint_scrape", "osint_paste", "osint_footprint", "osint_pivot", "osint_google", "osint_dorks_live", "check_dependencies", "re_info", "re_strings", "re_analyze", "re_decompile", "solve_captcha", "intercept",
		"web_search", "web_fetch", "http_request", "read_file", "todo", "add_intel", "report_finding",
	},
	"reverse": {
		"re_info", "re_strings", "re_analyze", "re_decompile", "check_dependencies",
		"read_file", "list_files", "glob", "grep", "terminal", "process", "todo", "report_finding",
	},
	"vibecoder": {
		"web_fetch", "http_request", "browser", "web_search", "terminal", "process",
		"read_file", "write_file", "list_files", "glob", "grep", "check_dependencies",
		"todo", "report_finding", "add_intel", "methodology_status", "skill", "rag_search",
	},
	"intercept": {
		"intercept", "browser", "http_request", "web_fetch", "solve_captcha",
		"read_file", "write_file", "todo", "report_finding", "add_intel",
	},
	"content-creator": {
		"content_creator", "image_generate", "view_image", "read_file", "read_document", "write_file", "edit_file", "list_files", "glob", "grep",
		"terminal", "process", "web_search", "web_fetch", "http_request", "browser", "social_browser", "social_account",
		"todo", "memory", "skill", "delegate_task", "task", "list_roles", "schedule", "rag_search", "speak", "transcribe",
	},
	"social": {
		"read_file", "write_file", "edit_file", "list_files", "glob", "grep",
		"terminal", "process", "web_search", "web_fetch", "http_request", "browser",
		"todo", "memory", "skill", "delegate_task", "task", "list_roles",
		"email_read", "temp_mail", "social_browser", "social_account", "ask_user", "schedule", "rag_search", "rag_index",
	},
	"default": {
		"read_file", "read_document", "write_file", "edit_file", "list_files", "glob", "grep",
		"terminal", "process", "web_search", "web_fetch", "http_request", "browser", "todo", "board", "project_info", "set_soul", "memory", "list_proxies", "vps_run", "vps_upload", "vps_download",
		"session_search", "rag_search", "rag_index", "skill", "delegate_task", "task", "list_roles", "image_generate", "view_image", "speak", "transcribe", "computer", "diagnostics", "ask_user", "schedule",
		"osint_dns", "osint_dorks", "osint_whois", "osint_ip", "osint_username", "osint_github", "osint_email", "osint_email_full", "osint_breach", "osint_shodan", "osint_reputation", "osint_crypto", "osint_domain", "osint_phone", "osint_scrape", "osint_paste", "osint_footprint", "osint_pivot", "osint_google", "osint_dorks_live", "check_dependencies", "re_info", "re_strings", "re_analyze", "re_decompile", "solve_captcha", "intercept",
		"email_read", "temp_mail", "social_browser", "social_account",
	},
	"all": nil,
}

Toolsets are named groupings mirroring the platform toolset config.

Functions

func CloseBrowsers

func CloseBrowsers()

CloseBrowsers shuts every browser down, for process exit.

func CommandOf added in v0.4.0

func CommandOf(t Tool, args json.RawMessage) (string, bool)

CommandOf returns the command a call would run at a shell. It reports false both for a tool that runs no commands and for one that does but whose arguments could not be read; RunsShellCommands tells those two apart, and a caller that inspects commands must not read either as "nothing to run".

func ExpandToolset

func ExpandToolset(name string) []string

ExpandToolset returns the tool names in a named toolset.

func InterceptActivate

func InterceptActivate(ctx context.Context, id string, extra map[string]any) (intercept.Session, error)

InterceptActivate resolves the shared proxy+CA and activates an interceptor by id, auto-starting the proxy if it is down. It is the one path the tool and the HTTP handlers share for "hook a client to the proxy".

func InterceptProxy

func InterceptProxy() (*intercept.Proxy, error)

InterceptProxy returns the shared proxy, creating it (with a persisted CA) on first use. Exported so the HTTP server can surface the same instance.

func InterceptRegistry

func InterceptRegistry() *intercept.Registry

InterceptRegistry returns the shared interceptor registry, seeded once with every available interceptor (browsers, terminal, and the dependency-gated ones). Exported so the HTTP server surfaces the same set.

func NeedsApproval

func NeedsApproval(t Tool) bool

NeedsApproval reports whether a tool mutates state.

func ReturnsUntrustedOutput added in v0.4.0

func ReturnsUntrustedOutput(t Tool) bool

ReturnsUntrustedOutput reports whether a tool's result carries content from outside this machine.

func RunsShellCommands added in v0.4.0

func RunsShellCommands(t Tool) bool

RunsShellCommands reports whether a tool hands commands to a shell.

func ToolsetNames

func ToolsetNames() []string

ToolsetNames lists the available toolsets, sorted.

func ToolsetsFor

func ToolsetsFor(name string) []string

ToolsetsFor reports which named toolsets include a tool.

func UploadsDir

func UploadsDir() string

UploadsDir is the temporary root for attached files. It lives under the antares home (not the workspace), so uploads never pollute the user's project and can be cleaned per session or by age.

Types

type Approval

type Approval interface {
	RequiresApproval() bool
}

Approval reports whether a tool mutates state and should be gated.

type AskFunc

type AskFunc func(ctx context.Context, questions []AskQuestion) (string, error)

AskFunc pauses the turn, asks the questions, and returns the answer text. It unblocks with an error if the run is cancelled.

type AskQuestion

type AskQuestion struct {
	Question    string   `json:"question"`
	Header      string   `json:"header,omitempty"`
	Options     []string `json:"options,omitempty"`
	MultiSelect bool     `json:"multiSelect,omitempty"`
}

AskQuestion is one question the ask_user tool puts to the person.

type BackgroundTasks

type BackgroundTasks interface {
	Start(req SubAgentRequest) string
	Status(id string) (TaskInfo, bool)
	List(parent string) []TaskInfo
	Stop(id string) bool
	// Send continues a finished task with a follow-up, running another turn on
	// its session and returning the new reply.
	Send(id, message string) (string, error)
}

BackgroundTasks runs sub-agents asynchronously: Start returns a handle immediately and the work continues in the background, to be polled later. It is how one turn dispatches several long workstreams without blocking on each.

type Deps

type Deps struct {
	Config *config.Config
	Store  store.Store
	RAG    RAGProvider
	Sub    SubAgent
	Skills SkillLibrary
	// Tasks runs sub-agents in the background. It may be nil.
	Tasks BackgroundTasks
	// Shell owns persistent terminal sessions keyed by session id.
	Shell *ShellManager
	// Checkpoint saves a copy of a file about to be changed. It may be nil,
	// in which case nothing is kept and an edit cannot be undone.
	Checkpoint func(sessionID, path, tool string)
	// RecordResult notes the sha256 of what a tool just wrote to a file, so a
	// later rollback can tell session-produced content from an outside edit. Nil
	// when checkpoints are off.
	RecordResult func(sessionID, path, resultHash string)
	// Roles lists the specialist roles available for delegation. It may be nil.
	Roles func() []RoleInfo
	// Vision describes an image using a vision model. It may be nil.
	Vision func(ctx context.Context, data []byte, mime, question string) (string, error)
	// Speak synthesises speech from text, returning the audio and its extension.
	// It may be nil.
	Speak func(ctx context.Context, text, voice string) (audio []byte, ext string, err error)
	// Transcribe turns speech audio into text. It may be nil.
	Transcribe func(ctx context.Context, filename string, audio []byte) (string, error)
	// Board is the Kanban board store. It may be nil.
	Board *board.Board
	// Findings is the security engagement ledger. It may be nil.
	Findings FindingStore
	// Intel is the engagement's fact ledger and methodology. It may be nil.
	Intel IntelStore
	// SocialBrowser is the persistent stealth Chromium for social media. Nil
	// when the social feature is not configured.
	SocialBrowser SocialBrowserManager
}

Deps bundles the services tools may reach for.

type FindingStore

type FindingStore interface {
	Add(sessionID string, f findings.Finding) (findings.Finding, error)
	Triage(sessionID, id string, status findings.Status, duplicateOf string) (findings.Finding, bool, error)
	List(sessionID string) ([]findings.Finding, error)
}

FindingStore is the subset of the findings store the tools need.

type GoogleAccount

type GoogleAccount struct {
	AuthUser int    `json:"authuser"`
	Email    string `json:"email"`
	Name     string `json:"name"`
}

GoogleAccount is a logged-in Google account resolved from a session cookie. AuthUser is the /u/<N>/ index that selects it in a multi-account session.

func VerifyGoogleCookie

func VerifyGoogleCookie(ctx context.Context, raw string) (accounts []GoogleAccount, err error)

VerifyGoogleCookie checks whether a stored Google cookie is a live session and returns the account(s) it belongs to. It accepts the same input the osint_google tool does (Cookie-Editor JSON or a raw header). The accounts.google.com/ListAccounts endpoint answers to the cookie alone, so it doubles as a "is this cookie still valid?" probe.

type Input

type Input struct {
	Args      json.RawMessage
	CallID    string
	SessionID string
	UserID    string
	Platform  string
	Workspace string
	// WriteRoots, when non-empty, marks this a project session: file writes are
	// confined to these directories (the project folder plus the antares
	// workspace), while reads are allowed anywhere on the machine so the agent
	// can read and copy from outside. Empty = an ordinary session, where reads
	// and writes are both confined to Workspace.
	WriteRoots []string
	// Emit reports progress; it is never nil.
	Emit func(Progress)
	// AskUser blocks the current turn to put questions to the person and returns
	// their answer as text. Nil where no one can answer (some gateways/cron), in
	// which case a blocking tool must fall back to yielding via its result.
	AskUser AskFunc
	// Deps exposes shared services (store, memory, rag, llm factory, sub-agent).
	Deps *Deps
}

Input carries everything a tool needs to run one invocation.

func (Input) Bind

func (in Input) Bind(v any) error

Bind decodes the tool arguments into v.

type IntelStore

type IntelStore interface {
	Add(sessionID string, in engagement.Intel) (engagement.Intel, bool, error)
	State(sessionID string, hasScope, hasReport bool) ([]engagement.PhaseState, error)
	List(sessionID string) ([]engagement.Intel, error)
}

IntelStore is the subset of the engagement store the tools need.

type Progress

type Progress struct {
	Tool    string `json:"tool"`
	Message string `json:"message"`
	Chunk   string `json:"chunk,omitempty"`
	Percent int    `json:"percent,omitempty"`
}

Progress is an incremental update emitted while a tool runs.

type RAGDoc

type RAGDoc struct {
	ID      string         `json:"id"`
	Path    string         `json:"path"`
	Content string         `json:"content"`
	Meta    map[string]any `json:"meta,omitempty"`
}

RAGDoc is one document submitted for indexing.

type RAGProvider

type RAGProvider interface {
	Name() string
	Search(ctx context.Context, collection, query string, topK int) ([]RAGResult, error)
	Index(ctx context.Context, collection string, docs []RAGDoc) (int, error)
	Collections(ctx context.Context) ([]string, error)
	Delete(ctx context.Context, collection string) error
}

RAGProvider is the native retrieval backend (vectors in the Antares DB).

type RAGResult

type RAGResult struct {
	Content string  `json:"content"`
	Path    string  `json:"path,omitempty"`
	DocID   string  `json:"doc_id,omitempty"`
	Score   float64 `json:"score"`
}

RAGResult is one retrieved passage.

type Registry

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

Registry holds the process-wide tool set.

func Default

func Default() *Registry

Default returns the process-wide registry.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) All

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

All returns every registered tool, sorted by name.

func (*Registry) Get

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

Get looks up a tool by name.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns all registered tool names, sorted.

func (*Registry) Register

func (r *Registry) Register(t Tool)

Register adds or replaces a tool.

func (*Registry) Replace added in v0.4.0

func (r *Registry) Replace(oldNames []string, replacements []Tool)

Replace removes oldNames and registers replacements while holding one lock, so concurrent tool resolution never observes a partially refreshed MCP set.

func (*Registry) Resolve

func (r *Registry) Resolve(toolset string, enabled, disabled []string) []Tool

Resolve expands a toolset name plus explicit enable/disable lists into the concrete tools handed to the model.

func (*Registry) Unregister added in v0.4.0

func (r *Registry) Unregister(name string)

Unregister removes a tool by name. It is a no-op when the name is absent.

type Result

type Result struct {
	// Content is what the model sees.
	Content string `json:"content"`
	// Display is an optional richer rendering for the dashboard.
	Display string         `json:"display,omitempty"`
	IsError bool           `json:"is_error,omitempty"`
	Meta    map[string]any `json:"meta,omitempty"`
}

Result is the outcome of a tool invocation.

func Errorf

func Errorf(format string, args ...any) Result

Errorf builds a failed Result the model can read and recover from.

func Text

func Text(s string) Result

Text builds a successful text Result.

type RoleInfo

type RoleInfo struct {
	Name     string
	Summary  string
	Category string
	Danger   bool
	// Subrole is true for a specialist reached only through its master role.
	Subrole bool
	// Parent names the master role a subrole belongs to.
	Parent string
}

RoleInfo is the subset of a role the tools need.

type ShellCommander added in v0.4.0

type ShellCommander interface {
	// ShellCommand returns the command these arguments would run. It reports
	// false when the arguments cannot be read, which is unknown rather than
	// harmless and must not be treated as "no command".
	ShellCommand(args json.RawMessage) (string, bool)
}

ShellCommander is implemented by a tool that hands a command to a shell, whichever machine that shell runs on. Anything inspecting commands has to find its subjects by this capability rather than by name: a command sent to a remote host destroys as thoroughly as the same command run locally.

type ShellManager

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

ShellManager owns one long-lived shell per session so `cd`, exported variables, and activated virtualenvs survive between tool calls.

func NewShellManager

func NewShellManager(cfg config.Terminal) *ShellManager

NewShellManager builds a manager for the given terminal config.

func (*ShellManager) Active

func (m *ShellManager) Active() int

Active reports how many shells are currently running.

func (*ShellManager) CancelRunning added in v0.3.0

func (m *ShellManager) CancelRunning(sessionID string) int

CancelRunning stops every managed process owned by a session. It is used by the agent interrupt path so the dashboard Stop button reaches backend process groups instead of only cancelling the current model/tool context.

func (*ShellManager) Close

func (m *ShellManager) Close(id string)

Close terminates a session's shell.

func (*ShellManager) CloseAll

func (m *ShellManager) CloseAll()

CloseAll terminates every live shell.

func (*ShellManager) EnableHTTPShim

func (m *ShellManager) EnableHTTPShim(dir, preset, proxy string)

EnableHTTPShim makes new shells route curl/wget through the fingerprinted client. dir is the directory holding the shim scripts.

func (*ShellManager) ReapIdle

func (m *ShellManager) ReapIdle(lifetime time.Duration)

ReapIdle closes shells idle for longer than lifetime.

func (*ShellManager) Reconfigure added in v0.4.0

func (m *ShellManager) Reconfigure(cfg config.Terminal)

Reconfigure swaps in a new terminal configuration snapshot. Existing foreground commands keep running to completion; the next session() call for a shell whose generation predates the swap retires that shell (if idle) or reports ErrShellConfigChanged (if a command is still running). Unchanged configs are a no-op so a routine reload does not disturb live sessions.

type SkillInfo

type SkillInfo struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Tags        []string `json:"tags"`
	Triggers    []string `json:"triggers"`
	Enabled     bool     `json:"enabled"`
	// Security-library metadata, empty for everyday skills.
	CWEIDs     []string `json:"cwe_ids,omitempty"`
	TechStack  []string `json:"tech_stack,omitempty"`
	OWASPID    string   `json:"owasp_id,omitempty"`
	ChainsWith []string `json:"chains_with,omitempty"`
}

SkillInfo describes one stored skill.

type SkillLibrary

type SkillLibrary interface {
	List() []SkillInfo
	Search(query string, limit int) []SkillInfo
	// SearchFiltered ranks matches and narrows by security metadata; empty
	// filter fields are ignored.
	SearchFiltered(query, cwe, tech, category string, limit int) []SkillInfo
	// Chains resolves a skill's follow-on techniques (chains_with).
	Chains(name string) []SkillInfo
	Read(name string) (SkillInfo, string, bool)
	Write(name, description, body string, tags []string) error
	MarkUsed(name string)
}

SkillLibrary is the subset of the skills manager that tools need.

type SocialBrowserManager added in v0.4.0

type SocialBrowserManager interface {
	Status() (string, string)
	Start(ctx context.Context) error
	Stop()
}

SocialBrowserManager is the minimal interface the social_browser tool needs from the socialbrowser.Manager.

type SubAgent

type SubAgent func(ctx context.Context, req SubAgentRequest) (string, error)

SubAgent runs a nested agent turn for delegate_task.

type SubAgentRequest

type SubAgentRequest struct {
	Prompt      string
	SystemExtra string
	Toolset     string
	Model       string
	// Role names a specialist to run this workstream as. It sets the prompt,
	// toolset, and model unless those are given explicitly.
	Role string
	// Isolate runs the sub-agent in its own git worktree, so parallel
	// sub-agents editing the same repository do not conflict.
	Isolate bool
	// Workspace overrides the sub-agent's working directory.
	Workspace  string
	MaxTurns   int
	ParentID   string
	OnProgress func(Progress)
}

SubAgentRequest describes a delegated workstream.

type TaskInfo

type TaskInfo struct {
	ID        string    `json:"id"`
	Role      string    `json:"role"`
	Task      string    `json:"task"`
	Status    string    `json:"status"` // running|done|error|stopped
	Output    string    `json:"output"`
	Error     string    `json:"error"`
	StartedAt time.Time `json:"started_at"`
	EndedAt   time.Time `json:"ended_at"`
}

TaskInfo is a snapshot of a background task.

type TodoItem

type TodoItem struct {
	Content string `json:"content"`
	Status  string `json:"status"` // pending|in_progress|completed
}

TodoItem is one entry in the session task list.

type Tool

type Tool interface {
	Name() string
	Description() string
	Schema() map[string]any
	Execute(ctx context.Context, in Input) Result
}

Tool is one callable capability.

type UntrustedOutputer added in v0.4.0

type UntrustedOutputer interface {
	UntrustedOutput() bool
}

UntrustedOutputer is implemented by a tool whose result carries content from outside this machine — a page, a search snippet, an API response — which whoever wrote it may have seeded with instructions aimed at the model.

Jump to

Keyboard shortcuts

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