tools

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_CMD_TIMEOUT = 5

Variables

View Source
var ExemptAutoApprovalTools = []string{"cmd_bg", "smart_cmd"}

Functions

func GetBuiltinTools

func GetBuiltinTools(ctx context.Context, category string, params map[string]interface{}) ([]tool.BaseTool, error)

Types

type BackgroundTask

type BackgroundTask struct {
	ID         string
	Command    string
	WorkingDir string
	StartTime  time.Time
	EndTime    *time.Time
	Status     TaskStatus
	Output     strings.Builder
	Stderr     strings.Builder
	ExitCode   *int
	Process    *exec.Cmd
	CancelFunc context.CancelFunc
	// contains filtered or unexported fields
}

func (*BackgroundTask) GetDuration

func (t *BackgroundTask) GetDuration() string

func (*BackgroundTask) GetOutputString

func (t *BackgroundTask) GetOutputString() string

type BackgroundTaskManager

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

func NewBackgroundTaskManager

func NewBackgroundTaskManager() *BackgroundTaskManager

func (*BackgroundTaskManager) GetTask

func (tm *BackgroundTaskManager) GetTask(id string) (*BackgroundTask, bool)

func (*BackgroundTaskManager) GetTaskOutput

func (tm *BackgroundTaskManager) GetTaskOutput(id string, follow bool) (<-chan string, error)

func (*BackgroundTaskManager) KillTask

func (tm *BackgroundTaskManager) KillTask(id string) error

func (*BackgroundTaskManager) ListTasks

func (tm *BackgroundTaskManager) ListTasks() []*BackgroundTask

func (*BackgroundTaskManager) RemoveTask

func (tm *BackgroundTaskManager) RemoveTask(id string) error

func (*BackgroundTaskManager) StartTask

func (tm *BackgroundTaskManager) StartTask(command, workdir string) (*BackgroundTask, error)

type GetToolsFunc

type GetToolsFunc func(params map[string]interface{}) ([]tool.BaseTool, error)

type RunBackgroundCommandArgs

type RunBackgroundCommandArgs struct {
	Action string `json:"action"`
	TaskID string `json:"task_id,omitempty"`
}

type RunBackgroundCommandTool

type RunBackgroundCommandTool struct {
	TaskManager *BackgroundTaskManager
}

func (*RunBackgroundCommandTool) Info

func (*RunBackgroundCommandTool) InvokableRun

func (t *RunBackgroundCommandTool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error)

type RunTerminalCommandArgs

type RunTerminalCommandArgs struct {
	Command    string `json:"command"`
	WorkingDir string `json:"working_dir,omitempty"`
	Background bool   `json:"background,omitempty"`
}

type RunTerminalCommandTool

type RunTerminalCommandTool struct {
	WorkingDir      string        `json:"workDir"`
	Timeout         time.Duration `json:"timeout"`
	AllowedCommands []string
	TaskManager     *BackgroundTaskManager
}

func (*RunTerminalCommandTool) Info

func (*RunTerminalCommandTool) InvokableRun

func (t *RunTerminalCommandTool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error)

InvokableRun executes the tool and returns the command output.

type SmartCmdTool

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

SmartCmdTool wraps cmd tool with intelligent permission control

func NewSmartCmdTool

func NewSmartCmdTool(baseTool *RunTerminalCommandTool) *SmartCmdTool

func (*SmartCmdTool) Info

func (t *SmartCmdTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*SmartCmdTool) InvokableRun

func (t *SmartCmdTool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error)

type TaskStatus

type TaskStatus string
const (
	TaskStatusRunning TaskStatus = "running"
	TaskStatusSuccess TaskStatus = "success"
	TaskStatusFailed  TaskStatus = "failed"
	TaskStatusKilled  TaskStatus = "killed"
)

Jump to

Keyboard shortcuts

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