shell

package
v0.0.0-...-3309b9d Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 22 Imported by: 0

README

// Package shell provides an eino shell tool backed by the Dagger engine. // It gives LLM agents a secure, sandboxed shell inside an OCI base image // (golang, node, python, etc.) with shared caching across agents. // // The tool implements both tool.InvokableTool and tool.StreamableTool. // // Usage: // // cfg := &shell.Config{ // Workdir: "/path/to/project", // } // shellTool, err := shell.NewShellTool(ctx, cfg) // // // With safety middleware: // tools, mw, err := shell.NewAllToolsWithSafety(ctx, cfg, nil) // agent, _ := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{ // Name: "shell-agent", // Model: myModel, // Tools: tools, // Handlers: []adk.ChatModelAgentMiddleware{mw}, // }) // // Requirements: // - A reachable Dagger engine (local or remote). // - The engine URL can be set via DAGGER_HOST env var or EngineURL config. // // Security: // - Command blocklist prevents destructive commands (rm, kill, etc.). // - Egress network policy restricts outbound traffic. // - Safety middleware gates all executions behind dry-run/confirmed flow. package shell

Documentation

Overview

Package shell provides an eino shell tool backed by the Dagger engine. It gives LLM agents a secure, sandboxed shell inside an OCI base image (golang, node, python, etc.) with shared caching across agents.

The tool implements both tool.InvokableTool and tool.StreamableTool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, cfg *Config) checkup.Results

func NewAllToolsWithSafety

func NewAllToolsWithSafety(ctx context.Context, cfg *Config, safetyCfg *safetymw.Config) ([]tool.InvokableTool, *safetymw.Middleware, error)

func NewShellToolsForProfiles

func NewShellToolsForProfiles(ctx context.Context, cfg *Config) (map[string]*ShellTool, error)

func WriteToolNames

func WriteToolNames() []string

Types

type Config

type Config struct {
	BaseImage      string                         `validate:"omitempty" jsonschema:"description=Default OCI base image when no profile matches"`
	Profiles       map[string]profile.Profile     `validate:"omitempty" jsonschema:"description=Profile overrides keyed by profile name"`
	Workdir        string                         `validate:"required" jsonschema:"description=Project workdir to mount into containers"`
	NetworkPolicy  *egress.Policy                 `validate:"omitempty" jsonschema:"description=Egress network policy for container outbound access"`
	CacheKey       string                         `validate:"omitempty" jsonschema:"description=Cache volume key prefix for shared installs"`
	RegistryAuth   map[string]dagger.RegistryAuth `validate:"omitempty" jsonschema:"description=Registry auth credentials keyed by hostname"`
	Blocklist      []string                       `validate:"omitempty" jsonschema:"description=Custom command blocklist patterns (extend defaults)"`
	DefaultTimeout time.Duration                  `validate:"omitempty" jsonschema:"description=Default timeout for command execution"`
}

type ShellParams

type ShellParams struct {
	Command           []string `json:"command" validate:"required,min=1" jsonschema:"(required) The command to execute as an array of strings"`
	Profile           string   `json:"profile,omitempty" validate:"omitempty" jsonschema:"(optional) Profile name to override default container image"`
	DryRun            bool     `json:"dryRun,omitempty" jsonschema:"(optional) If true, preview the command without executing"`
	Confirmed         bool     `json:"confirmed,omitempty" jsonschema:"(optional) Must be true to actually execute"`
	FilterPattern     string   `json:"filterPattern,omitempty" validate:"omitempty" jsonschema:"(optional) A Go RE2 regex applied on each output line"`
	Timeout           string   `json:"timeout,omitempty" validate:"omitempty" jsonschema:"(optional) Timeout duration string (e.g. '30s', '5m')"`
	AllowLocalNetwork *bool    `json:"allowLocalNetwork,omitempty" jsonschema:"(optional) Override to allow local network access for this call"`
}

type ShellTool

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

func NewShellTool

func NewShellTool(ctx context.Context, cfg *Config) (*ShellTool, error)

func (*ShellTool) Info

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

func (*ShellTool) InvokableRun

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

func (*ShellTool) Invoke

func (t *ShellTool) Invoke(ctx context.Context, params *ShellParams) (string, error)

func (*ShellTool) InvokeAsStream

func (t *ShellTool) InvokeAsStream(ctx context.Context, params *ShellParams) (*schema.StreamReader[string], error)

func (*ShellTool) StreamableRun

func (t *ShellTool) StreamableRun(ctx context.Context, args string, opts ...tool.Option) (*schema.StreamReader[string], error)

Jump to

Keyboard shortcuts

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