Documentation
¶
Index ¶
- type BackgroundProcess
- type CommandGuard
- type Config
- type Result
- type Tool
- func (t *Tool) Cleanup()
- func (t *Tool) GetBackgroundStatus(id string) (*BackgroundProcess, error)
- func (t *Tool) ListBackground() []*BackgroundProcess
- func (t *Tool) Run(ctx context.Context, command string, timeout time.Duration) (*Result, error)
- func (t *Tool) RunWithPTY(ctx context.Context, command string, timeout time.Duration) (*Result, error)
- func (t *Tool) StartBackground(command string) (string, error)
- func (t *Tool) StopBackground(id string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackgroundProcess ¶
type BackgroundProcess struct {
ID string
Command string
Cmd *exec.Cmd
Output *syncBuffer
StartTime time.Time
Done bool
ExitCode int
Error string
}
BackgroundProcess represents a running background command
type CommandGuard ¶ added in v0.6.0
type CommandGuard struct {
// contains filtered or unexported fields
}
CommandGuard checks shell commands for access to protected paths and dangerous process management operations.
func NewCommandGuard ¶ added in v0.6.0
func NewCommandGuard(protectedPaths []string) *CommandGuard
NewCommandGuard creates a CommandGuard that blocks commands targeting the given protected paths. Paths are resolved to absolute form at construction time.
func (*CommandGuard) CheckCommand ¶ added in v0.6.0
func (g *CommandGuard) CheckCommand(command string) (blocked bool, reason string)
CheckCommand returns true and a reason string if the command should be blocked. It checks for:
- Commands that access protected paths (sqlite3, cat, python, etc.)
- Process management commands (kill, pkill, killall)
type Config ¶
type Config struct {
DefaultTimeout time.Duration
AllowBackground bool
WorkDir string
EnvFilter []string // environment variables to exclude
EnvWhitelist []string // if set, ONLY these vars are allowed
Refs *security.RefStore // secret reference token resolver
}
Config holds exec tool configuration
type Result ¶
type Result struct {
ExitCode int `json:"exitCode"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
TimedOut bool `json:"timedOut,omitempty"`
}
Result represents command execution result
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool provides shell command execution
func (*Tool) GetBackgroundStatus ¶
func (t *Tool) GetBackgroundStatus(id string) (*BackgroundProcess, error)
GetBackgroundStatus returns the status of a background process
func (*Tool) ListBackground ¶
func (t *Tool) ListBackground() []*BackgroundProcess
ListBackground returns all background processes
func (*Tool) RunWithPTY ¶
func (t *Tool) RunWithPTY(ctx context.Context, command string, timeout time.Duration) (*Result, error)
RunWithPTY executes a command with PTY support
func (*Tool) StartBackground ¶
StartBackground starts a command in the background
func (*Tool) StopBackground ¶
StopBackground stops a background process