tools

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 20 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 ApprovalMode added in v0.1.2

type ApprovalMode string
const (
	ApprovalNever     ApprovalMode = "never"
	ApprovalOnRequest ApprovalMode = "on_request"
)

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 Category added in v0.1.1

type Category string
const (
	CategoryFilesystem Category = "filesystem"
	CategoryShell      Category = "shell"
	CategoryAutomation Category = "automation"
	CategoryStorage    Category = "storage"
)

type Definition added in v0.1.2

type Definition struct {
	Spec        Spec
	NewExecutor func() Executor
}

func CoreDefinitions added in v0.1.2

func CoreDefinitions() []Definition

func CoreDefinitionsFor added in v0.1.2

func CoreDefinitionsFor(policy Policy) []Definition

func (Definition) Executor added in v0.1.2

func (d Definition) Executor() Executor

type DuplicateToolError added in v0.1.1

type DuplicateToolError struct {
	ID string
}

func (DuplicateToolError) Error added in v0.1.1

func (e DuplicateToolError) Error() string

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 {
	FilesystemPathMetadata
	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 {
	FilesystemPathMetadata
	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 Effect added in v0.1.2

type Effect string
const (
	EffectReadOnly Effect = "readonly"
	EffectMutation Effect = "mutation"
)

type Executor

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

func CoreCodingExecutors added in v0.1.1

func CoreCodingExecutors() []Executor

func CoreReadOnlyExecutors added in v0.1.1

func CoreReadOnlyExecutors() []Executor

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 FilesystemPathMetadata added in v0.1.2

type FilesystemPathMetadata struct {
	RequestedPath      string `json:"requested_path,omitempty"`
	ResolvedPath       string `json:"resolved_path,omitempty"`
	WorkingDir         string `json:"working_dir,omitempty"`
	RealPath           string `json:"real_path,omitempty"`
	RealWorkingDir     string `json:"real_working_dir,omitempty"`
	BoundaryKnown      bool   `json:"boundary_known,omitempty"`
	WithinWorkingDir   bool   `json:"within_working_dir,omitempty"`
	SymlinkEvalApplied bool   `json:"symlink_eval_applied,omitempty"`
}

type FilesystemPathPolicy

type FilesystemPathPolicy struct {
	Input              string
	WorkingDir         string
	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 {
	FilesystemPathMetadata
	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 {
	FilesystemPathMetadata
	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 InvalidToolSpecError added in v0.1.1

type InvalidToolSpecError struct {
	Reason string
}

func (InvalidToolSpecError) Error added in v0.1.1

func (e InvalidToolSpecError) Error() string

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 {
	FilesystemPathMetadata
	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 {
	FilesystemPathMetadata
	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 {
	FilesystemPathMetadata
	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 OutputKind added in v0.1.1

type OutputKind string
const (
	OutputText          OutputKind = "text"
	OutputFileContent   OutputKind = "file_content"
	OutputFileTree      OutputKind = "file_tree"
	OutputSearchResults OutputKind = "search_results"
	OutputDiff          OutputKind = "diff"
	OutputJob           OutputKind = "job"
	OutputStorageEntry  OutputKind = "storage_entry"
	OutputStorageList   OutputKind = "storage_list"
)

type Policy added in v0.1.1

type Policy struct {
	Profiles   []Profile
	Categories []Category
	IncludeIDs []string
	ExcludeIDs []string
}

func (Policy) Allows added in v0.1.1

func (p Policy) Allows(spec Spec) bool

type PolicyRegistry added in v0.1.1

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

func (*PolicyRegistry) Execute added in v0.1.1

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

func (*PolicyRegistry) List added in v0.1.1

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

func (*PolicyRegistry) Spec added in v0.1.2

func (r *PolicyRegistry) Spec(toolID string) (Spec, bool)

type Profile added in v0.1.1

type Profile string
const (
	ProfileReadOnly   Profile = "readonly"
	ProfileCoding     Profile = "coding"
	ProfileAutomation Profile = "automation"
	ProfileStorage    Profile = "storage"
)

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 {
	FilesystemPathMetadata
	FilePath string `json:"file_path"`
	Content  string `json:"content"`
}

type Registry

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

func NewCoreCodingRegistry added in v0.1.1

func NewCoreCodingRegistry(extra ...Executor) *Registry

func NewCoreReadOnlyRegistry added in v0.1.1

func NewCoreReadOnlyRegistry(extra ...Executor) *Registry

func NewRegistry

func NewRegistry(executors ...Executor) *Registry

func (*Registry) Err added in v0.1.1

func (r *Registry) Err() error

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) ListFor added in v0.1.1

func (r *Registry) ListFor(policy Policy) []Spec

func (*Registry) Register

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

func (*Registry) Spec added in v0.1.1

func (r *Registry) Spec(toolID string) (Spec, bool)

func (*Registry) View added in v0.1.1

func (r *Registry) View(policy Policy) *PolicyRegistry

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"`
	Effect           Effect          `json:"effect,omitempty"`
	ApprovalMode     ApprovalMode    `json:"approval_mode,omitempty"`
	PermissionParams string          `json:"permission_params,omitempty"`
	Namespace        string          `json:"namespace,omitempty"`
	Category         Category        `json:"category,omitempty"`
	Profiles         []Profile       `json:"profiles,omitempty"`
	OutputKind       OutputKind      `json:"output_kind,omitempty"`
	InputJSONSchema  json.RawMessage `json:"input_json_schema,omitempty"`
}

func CoreSpec added in v0.1.2

func CoreSpec(toolID string) (Spec, bool)

func (Spec) IsFilesystemMutation added in v0.1.2

func (s Spec) IsFilesystemMutation() bool

func (Spec) Mutates added in v0.1.2

func (s Spec) Mutates() bool

func (Spec) RequiresApproval added in v0.1.2

func (s Spec) RequiresApproval() bool

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 {
	FilesystemPathMetadata
	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 {
	FilesystemPathMetadata
	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