shell

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ShellTool

type ShellTool struct {
	*tools.BaseTool
	// contains filtered or unexported fields
}

ShellTool Shell 命令执行工具

提供安全的 shell 命令执行能力,支持命令白名单

func CommonShellTools

func CommonShellTools() []*ShellTool

CommonShellTools 创建常用的 Shell 工具集合

func NewShellTool

func NewShellTool(allowedCommands []string, timeout time.Duration) *ShellTool

NewShellTool 创建 Shell 工具

Parameters:

  • allowedCommands: 允许执行的命令列表(白名单)
  • timeout: 默认超时时间

func (*ShellTool) ExecutePipeline

func (s *ShellTool) ExecutePipeline(ctx context.Context, commands []string) (*interfaces.ToolOutput, error)

ExecutePipeline 执行管道命令的便捷方法

func (*ShellTool) ExecuteScript

func (s *ShellTool) ExecuteScript(ctx context.Context, scriptPath string, args []string) (*interfaces.ToolOutput, error)

ExecuteScript 执行脚本的便捷方法

func (*ShellTool) GetAllowedCommands

func (s *ShellTool) GetAllowedCommands() []string

GetAllowedCommands 获取允许的命令列表

func (*ShellTool) IsCommandAllowed

func (s *ShellTool) IsCommandAllowed(command string) bool

IsCommandAllowed 检查命令是否在白名单中

type ShellToolBuilder

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

ShellToolBuilder Shell 工具构建器

func NewShellToolBuilder

func NewShellToolBuilder() *ShellToolBuilder

NewShellToolBuilder 创建 Shell 工具构建器

func (*ShellToolBuilder) Build

func (b *ShellToolBuilder) Build() *ShellTool

Build 构建工具

func (*ShellToolBuilder) WithAllowedCommands

func (b *ShellToolBuilder) WithAllowedCommands(commands ...string) *ShellToolBuilder

WithAllowedCommands 设置允许的命令

func (*ShellToolBuilder) WithTimeout

func (b *ShellToolBuilder) WithTimeout(timeout time.Duration) *ShellToolBuilder

WithTimeout 设置超时

Jump to

Keyboard shortcuts

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