Documentation
¶
Index ¶
- func GetExecuteTools(opts ...Option) []tool.BaseTool
- func GetTools(opts ...Option) []tool.BaseTool
- type ExecuteParams
- type Option
- func WithAllowedCommands(commands ...string) Option
- func WithDefaultTimeout(timeout time.Duration) Option
- func WithDeniedCommands(commands ...string) Option
- func WithMaxOutputBytes(n int) Option
- func WithMaxTimeout(timeout time.Duration) Option
- func WithUnrestrictedWorkingDir() Option
- func WithWorkingDirRoot(root string) Option
- type ShellTool
- type ToolResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExecuteTools ¶
GetExecuteTools 获取命令执行工具
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
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
WithDefaultTimeout sets the timeout used when params.Timeout is omitted.
func WithDeniedCommands ¶ added in v0.3.0
WithDeniedCommands adds executable names that should never be run.
func WithMaxOutputBytes ¶ added in v0.3.0
WithMaxOutputBytes caps captured stdout/stderr to avoid unbounded memory use.
func WithMaxTimeout ¶ added in v0.3.0
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
WithWorkingDirRoot restricts WorkingDir to root or one of its descendants.
type ToolResult ¶
type ToolResult struct {
Output string `json:"output"` // 命令输出的结果
IsError bool `json:"isError"` // 是否发生错误
}
ToolResult 表示命令执行的可读结果