tools

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 19 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

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidArgs = errors.New("invalid tool arguments")

Functions

func InvalidArgs

func InvalidArgs(toolID string, err error) error

func IsProcessProbeCommand

func IsProcessProbeCommand(command string) bool

Types

type ApprovalRequest

type ApprovalRequest struct {
	ID          string `json:"id"`
	ToolCallID  string `json:"tool_call_id,omitempty"`
	ToolID      string `json:"tool_id"`
	Action      string `json:"action"`
	Path        string `json:"path,omitempty"`
	Description string `json:"description,omitempty"`
	Params      any    `json:"params,omitempty"`
}

type BackgroundJob

type BackgroundJob struct {
	ID          string    `json:"shell_id"`
	Command     string    `json:"command"`
	WorkingDir  string    `json:"working_dir"`
	Description string    `json:"description,omitempty"`
	StartedAt   time.Time `json:"started_at"`
}

type BashParams

type BashParams struct {
	Description         string `json:"description,omitempty"`
	Command             string `json:"command"`
	WorkingDir          string `json:"working_dir,omitempty"`
	RunInBackground     bool   `json:"run_in_background,omitempty"`
	AutoBackgroundAfter int    `json:"auto_background_after,omitempty"`
}

type BashPermissionsParams

type BashPermissionsParams struct {
	Description         string `json:"description"`
	Command             string `json:"command"`
	WorkingDir          string `json:"working_dir"`
	RunInBackground     bool   `json:"run_in_background"`
	AutoBackgroundAfter int    `json:"auto_background_after"`
}

type BashResponseMetadata

type BashResponseMetadata struct {
	StartTime        int64  `json:"start_time"`
	EndTime          int64  `json:"end_time"`
	Output           string `json:"output"`
	ExitCode         int    `json:"exit_code,omitempty"`
	Description      string `json:"description,omitempty"`
	WorkingDirectory string `json:"working_directory"`
	Background       bool   `json:"background,omitempty"`
	ShellID          string `json:"shell_id,omitempty"`
}

type Call

type Call struct {
	SessionID  string          `json:"session_id,omitempty"`
	RunID      string          `json:"run_id,omitempty"`
	WorkingDir string          `json:"working_dir,omitempty"`
	Approved   bool            `json:"approved,omitempty"`
	Args       json.RawMessage `json:"args,omitempty"`
}

type EditOperation

type EditOperation struct {
	OldString  string `json:"old_string"`
	NewString  string `json:"new_string"`
	ReplaceAll bool   `json:"replace_all,omitempty"`
}

type EditParams

type EditParams struct {
	FilePath   string `json:"file_path"`
	OldString  string `json:"old_string"`
	NewString  string `json:"new_string"`
	ReplaceAll bool   `json:"replace_all,omitempty"`
}

type EditPermissionsParams

type EditPermissionsParams struct {
	FilePath            string `json:"file_path"`
	OldContent          string `json:"old_content,omitempty"`
	NewContent          string `json:"new_content,omitempty"`
	OldContentTruncated bool   `json:"old_content_truncated,omitempty"`
	NewContentTruncated bool   `json:"new_content_truncated,omitempty"`
	OldContentBytes     int    `json:"old_content_bytes,omitempty"`
	NewContentBytes     int    `json:"new_content_bytes,omitempty"`
}

type EditResponseMetadata

type EditResponseMetadata struct {
	Diff       string `json:"diff"`
	Additions  int    `json:"additions"`
	Removals   int    `json:"removals"`
	OldContent string `json:"old_content,omitempty"`
	NewContent string `json:"new_content,omitempty"`
}

type Executor

type Executor interface {
	Spec() Spec
	Execute(ctx context.Context, call Call) (Result, error)
}

func NewBashExecutor

func NewBashExecutor() Executor

func NewEditExecutor

func NewEditExecutor() Executor

func NewGlobExecutor

func NewGlobExecutor() Executor

func NewGrepExecutor

func NewGrepExecutor() Executor

func NewJobKillExecutor

func NewJobKillExecutor() Executor

func NewJobOutputExecutor

func NewJobOutputExecutor() Executor

func NewLSExecutor

func NewLSExecutor() Executor

func NewMultiEditExecutor

func NewMultiEditExecutor() Executor

func NewReadExecutor

func NewReadExecutor() Executor

func NewWriteExecutor

func NewWriteExecutor() Executor

type FailedEdit

type FailedEdit struct {
	Index int           `json:"index"`
	Error string        `json:"error"`
	Edit  EditOperation `json:"edit"`
}

type FileVersion

type FileVersion struct {
	Path       string `json:"path"`
	OldContent string `json:"old_content,omitempty"`
	NewContent string `json:"new_content,omitempty"`
	Diff       string `json:"diff,omitempty"`
	Additions  int    `json:"additions,omitempty"`
	Removals   int    `json:"removals,omitempty"`
}

type FilesystemPathPolicy

type FilesystemPathPolicy struct {
	Input              string
	WorkingDir         string
	WorkingDirProvided bool
	Path               string
	RealPath           string
	RealWorkingDir     string
	BoundaryKnown      bool
	WithinWorkingDir   bool
	EscapesWorkingDir  bool
	SymlinkEvalApplied bool
}

func ResolveFilesystemPath

func ResolveFilesystemPath(workingDir string, value string) (FilesystemPathPolicy, error)

type GlobParams

type GlobParams struct {
	Pattern string `json:"pattern"`
	Path    string `json:"path,omitempty"`
}

type GlobResponseMetadata

type GlobResponseMetadata struct {
	NumberOfFiles int  `json:"number_of_files"`
	Truncated     bool `json:"truncated"`
}

type GrepParams

type GrepParams struct {
	Pattern     string `json:"pattern"`
	Path        string `json:"path,omitempty"`
	Include     string `json:"include,omitempty"`
	LiteralText bool   `json:"literal_text,omitempty"`
}

type GrepResponseMetadata

type GrepResponseMetadata struct {
	NumberOfMatches int  `json:"number_of_matches"`
	Truncated       bool `json:"truncated"`
}

type InvalidArgsError

type InvalidArgsError struct {
	ToolID string
	Err    error
}

func (*InvalidArgsError) Error

func (e *InvalidArgsError) Error() string

func (*InvalidArgsError) Is

func (e *InvalidArgsError) Is(target error) bool

func (*InvalidArgsError) Unwrap

func (e *InvalidArgsError) Unwrap() error

type JobKillParams

type JobKillParams struct {
	ShellID string `json:"shell_id"`
}

type JobKillResponseMetadata

type JobKillResponseMetadata struct {
	ShellID     string `json:"shell_id"`
	Command     string `json:"command"`
	Description string `json:"description"`
}

type JobOutputParams

type JobOutputParams struct {
	ShellID string `json:"shell_id"`
	Wait    bool   `json:"wait,omitempty"`
}

type JobOutputResponseMetadata

type JobOutputResponseMetadata struct {
	ShellID          string `json:"shell_id"`
	Command          string `json:"command"`
	Description      string `json:"description"`
	Done             bool   `json:"done"`
	WorkingDirectory string `json:"working_directory"`
}

type LSParams

type LSParams struct {
	Path   string   `json:"path,omitempty"`
	Ignore []string `json:"ignore,omitempty"`
	Depth  int      `json:"depth,omitempty"`
}

type LSResponseMetadata

type LSResponseMetadata struct {
	NumberOfFiles int  `json:"number_of_files"`
	Truncated     bool `json:"truncated"`
}

type MultiEditParams

type MultiEditParams struct {
	FilePath string          `json:"file_path"`
	Edits    []EditOperation `json:"edits"`
}

type MultiEditPermissionsParams

type MultiEditPermissionsParams struct {
	FilePath            string `json:"file_path"`
	OldContent          string `json:"old_content,omitempty"`
	NewContent          string `json:"new_content,omitempty"`
	OldContentTruncated bool   `json:"old_content_truncated,omitempty"`
	NewContentTruncated bool   `json:"new_content_truncated,omitempty"`
	OldContentBytes     int    `json:"old_content_bytes,omitempty"`
	NewContentBytes     int    `json:"new_content_bytes,omitempty"`
}

type MultiEditResponseMetadata

type MultiEditResponseMetadata struct {
	Diff         string       `json:"diff"`
	Additions    int          `json:"additions"`
	Removals     int          `json:"removals"`
	OldContent   string       `json:"old_content,omitempty"`
	NewContent   string       `json:"new_content,omitempty"`
	EditsApplied int          `json:"edits_applied"`
	EditsFailed  []FailedEdit `json:"edits_failed,omitempty"`
}

type NodeType

type NodeType string
const (
	NodeTypeFile      NodeType = "file"
	NodeTypeDirectory NodeType = "directory"
)

type ReadParams

type ReadParams struct {
	FilePath string `json:"file_path"`
	Offset   int    `json:"offset,omitempty"`
	Limit    int    `json:"limit,omitempty"`
}

type ReadResponseMetadata

type ReadResponseMetadata struct {
	FilePath string `json:"file_path"`
	Content  string `json:"content"`
}

type Registry

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

func NewRegistry

func NewRegistry(executors ...Executor) *Registry

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, toolID string, call Call) (Result, error)

func (*Registry) List

func (r *Registry) List() []Spec

func (*Registry) Register

func (r *Registry) Register(executors ...Executor)

type Result

type Result struct {
	Content     string           `json:"content"`
	Metadata    any              `json:"metadata,omitempty"`
	MIMEType    string           `json:"mime_type,omitempty"`
	Status      ResultStatus     `json:"status,omitempty"`
	IsError     bool             `json:"is_error,omitempty"`
	Approval    *ApprovalRequest `json:"approval,omitempty"`
	FileVersion *FileVersion     `json:"file_version,omitempty"`
	Background  *BackgroundJob   `json:"background,omitempty"`
}

type ResultStatus

type ResultStatus string
const (
	ResultStatusSuccess ResultStatus = "success"
	ResultStatusError   ResultStatus = "error"
	ResultStatusNeutral ResultStatus = "neutral"
)

type RiskLevel

type RiskLevel string
const (
	RiskSafe     RiskLevel = "safe"
	RiskApproval RiskLevel = "approval"
)

type Spec

type Spec struct {
	ID              string          `json:"id"`
	Name            string          `json:"name"`
	Description     string          `json:"description,omitempty"`
	Risk            RiskLevel       `json:"risk"`
	InputJSONSchema json.RawMessage `json:"input_json_schema,omitempty"`
}

type TreeNode

type TreeNode struct {
	Name     string      `json:"name"`
	Path     string      `json:"path"`
	Type     NodeType    `json:"type"`
	Children []*TreeNode `json:"children,omitempty"`
}

type WriteParams

type WriteParams struct {
	FilePath string `json:"file_path"`
	Content  string `json:"content"`
}

type WritePermissionsParams

type WritePermissionsParams struct {
	FilePath            string `json:"file_path"`
	OldContent          string `json:"old_content,omitempty"`
	NewContent          string `json:"new_content,omitempty"`
	OldContentTruncated bool   `json:"old_content_truncated,omitempty"`
	NewContentTruncated bool   `json:"new_content_truncated,omitempty"`
	OldContentBytes     int    `json:"old_content_bytes,omitempty"`
	NewContentBytes     int    `json:"new_content_bytes,omitempty"`
}

type WriteResponseMetadata

type WriteResponseMetadata struct {
	Diff       string `json:"diff"`
	Additions  int    `json:"additions"`
	Removals   int    `json:"removals"`
	OldContent string `json:"old_content,omitempty"`
	NewContent string `json:"new_content,omitempty"`
}

Jump to

Keyboard shortcuts

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