Skip to content

[EXAMPLE] Simple Script Executor Agent #2

@djdarcy

Description

@djdarcy

Objective

Create a basic agent that can execute shell scripts and command-line tasks.

Features

  • Execute bash/shell commands
  • Handle stdin/stdout/stderr
  • Set working directory
  • Environment variable management
  • Timeout handling

Example Tasks It Can Handle

{
  "type": "shell_command",
  "content": "Run backup script",
  "properties": {
    "command": "./backup.sh",
    "working_dir": "/home/user/scripts",
    "timeout": 300,
    "env": {
      "BACKUP_DIR": "/mnt/backup"
    }
  }
}

Safety Considerations

  • Command whitelisting
  • Sandbox execution
  • Resource limits
  • Output size limits
  • No arbitrary code execution

Implementation Steps

  1. Create ScriptExecutorAgent class
  2. Implement command parsing
  3. Add process management
  4. Handle output capture
  5. Add safety checks
  6. Write comprehensive tests

Success Criteria

  • Can execute allowed commands safely
  • Properly captures output
  • Handles errors gracefully
  • Respects timeouts
  • Clear capability reporting

Related to: Core Agent Base Class

Metadata

Metadata

Assignees

No one assigned

    Labels

    exampleExample agent implementationssecuritySecurity and sandboxing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions