Skip to content

Direct container operations via CLI + API #232

Closed as not planned
Closed as not planned

Description

@vybe

Summary

Add direct operational commands to the Trinity CLI and backend API that interact with agent containers without invoking the target agent's LLM. Enables file inspection, command execution, process management, and log access at the container level.

Motivation

  • Currently, any interaction with an agent container goes through the chat/execution queue, which invokes the agent's LLM — expensive and slow for operational tasks
  • Common ops tasks (check files, read logs, inspect processes, sync git) don't need LLM reasoning
  • Platform operators need direct container access without docker exec knowledge
  • Enables automated health checks, file syncs, and maintenance scripts

New Backend API Endpoints

POST   /api/agents/{name}/exec           # Execute command in container
GET    /api/agents/{name}/files           # List files in directory
GET    /api/agents/{name}/files/{path}    # Read file contents
PUT    /api/agents/{name}/files/{path}    # Write file contents
DELETE /api/agents/{name}/files/{path}    # Delete file
GET    /api/agents/{name}/processes       # List running processes
POST   /api/agents/{name}/git/pull        # Git pull in workspace
GET    /api/agents/{name}/git/status      # Git status of workspace

CLI Commands

# Execute arbitrary command in agent container
trinity exec <agent> -- <command>
trinity exec oracle-1 -- cat /home/user/.env
trinity exec oracle-1 -- pip list
trinity exec oracle-1 -- git -C /home/user/agent status

# File operations
trinity files <agent> ls [path]
trinity files <agent> cat <path>
trinity files <agent> write <path> --content "..."
trinity files <agent> rm <path>

# Process inspection
trinity ps <agent>

# Git operations on agent workspace
trinity git <agent> status
trinity git <agent> pull
trinity git <agent> log --oneline -5

# Enhanced logs (direct container logs, not via Vector)
trinity logs <agent> --tail 100 --follow
trinity logs <agent> --since 1h

Security Considerations

  • All operations scoped to agent owner (validated via MCP API key / JWT)
  • Audit logged (command, user, agent, timestamp) via structured logging
  • exec commands run as the agent's container user (not root)
  • File operations restricted to /home/user/ workspace by default
  • Optional allowlist/blocklist for exec commands (future)
  • No credential values exposed in logs

Implementation

  • Backend: New router src/backend/routers/container_ops.py
  • Docker access: Uses existing read-only Docker socket + docker exec via Docker SDK
  • CLI: Extends the trinity CLI from Trinity CLI tool mirroring MCP server #231
  • Timeout: All exec commands have configurable timeout (default 30s)
  • Streaming: trinity exec and trinity logs --follow support streaming output

Acceptance Criteria

  • trinity exec runs commands in agent containers and returns stdout/stderr
  • trinity files provides read/write/list/delete for agent workspace files
  • trinity ps lists processes inside agent container
  • trinity git proxies git commands to agent workspace
  • All operations audit logged with user identity
  • Operations scoped to agent owner (non-admin cannot exec into others' agents)
  • 30s default timeout on exec, configurable via --timeout
  • Works from CLI and directly via API
  • No LLM invocation on the target agent

Depends On

Activity

  1. added
    enhancement
    priority-p1
    on Mar 30, 2026
  2. added
    complexity-medium
    theme-devex
    on Jun 3, 2026
  3. added
    type-feature
    on Jun 3, 2026
  4. vybe commented on Jun 5, 2026

    @vybe
    ContributorAuthor

    Closed during backlog prioritization (2026-06-05): aged P1 "Later"-horizon feature off the current Reliability/Security critical path. Not planned for now — reopen if it becomes relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumenhancementpriority-p1theme-devextype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions