shell

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExecuteTools

func GetExecuteTools(opts ...Option) []tool.BaseTool

GetExecuteTools 获取命令执行工具

func GetTools

func GetTools(opts ...Option) []tool.BaseTool

GetTools 获取全部 Shell 工具

Types

type ExecuteParams

type ExecuteParams struct {
	Command    string `json:"command" jsonschema:"description=要执行的shell命令,required"`
	WorkingDir string `json:"workingDir,omitempty" jsonschema:"description=命令执行的工作目录"`
	Timeout    int    `json:"timeout,omitempty" jsonschema:"description=超时时间(秒),默认为60秒"`
}

ExecuteParams 表示命令执行的参数

type Option added in v0.3.0

type Option func(*ShellTool)

Option configures shell tool execution policy.

func WithAllowedCommands added in v0.3.0

func WithAllowedCommands(commands ...string) Option

WithAllowedCommands restricts execution to simple commands whose executable name is in the allowlist. Shell operators are rejected when this is set.

func WithDefaultTimeout added in v0.3.0

func WithDefaultTimeout(timeout time.Duration) Option

WithDefaultTimeout sets the timeout used when params.Timeout is omitted.

func WithDeniedCommands added in v0.3.0

func WithDeniedCommands(commands ...string) Option

WithDeniedCommands adds executable names that should never be run.

func WithMaxOutputBytes added in v0.3.0

func WithMaxOutputBytes(n int) Option

WithMaxOutputBytes caps captured stdout/stderr to avoid unbounded memory use.

func WithMaxTimeout added in v0.3.0

func WithMaxTimeout(timeout time.Duration) Option

WithMaxTimeout caps caller-provided command timeouts.

func WithUnrestrictedWorkingDir added in v0.3.0

func WithUnrestrictedWorkingDir() Option

WithUnrestrictedWorkingDir disables WorkingDir root validation.

func WithWorkingDirRoot added in v0.3.0

func WithWorkingDirRoot(root string) Option

WithWorkingDirRoot restricts WorkingDir to root or one of its descendants.

type ShellTool

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

type ToolResult

type ToolResult struct {
	Output  string `json:"output"`  // 命令输出的结果
	IsError bool   `json:"isError"` // 是否发生错误
}

ToolResult 表示命令执行的可读结果

Jump to

Keyboard shortcuts

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