Skip to content

feat(cli): trinity deploy . — file-based agent deployment with tracking, limits, and MCP provisioning #259

Closed

Description

@vybe

Summary

Implement the simplest possible onboarding flow for deploying an agent to a hosted Trinity instance:

pip install trinity-cli
trinity init
trinity deploy .

No GitHub knowledge required. No manual MCP configuration. Three commands from zero to deployed agent.

Requirements

1. trinity deploy . CLI command

File: src/cli/trinity_cli/commands/deploy.py (new)

  • Tar + base64 encode local directory (respecting .gitignore, excluding .git/, node_modules/, .env)
  • POST to /api/agents/deploy-local (endpoint already exists)
  • On first deploy: create agent, write .trinity-remote.yaml tracking file
  • On subsequent deploys: detect .trinity-remote.yaml, redeploy to same instance/agent (idempotent update)
  • Add .trinity-remote.yaml to .gitignore automatically if git repo detected
  • Support --name flag to override agent name (default: directory name)
  • Support --repo user/repo flag to use an existing public GitHub repo instead of file-based deploy

Tracking file format (.trinity-remote.yaml):

# Auto-generated by trinity deploy — do not edit
instance: https://trinity.example.com
agent: my-agent
profile: production
deployed_at: 2026-04-03T15:45:00Z

2. Agent limit enforcement (3 per user default)

Files: src/backend/services/agent_service/crud.py, src/backend/services/agent_service/deploy.py

  • Add per-user agent count check in create_agent_internal() (after duplicate name check, ~line 89)
  • Add same check in deploy_local_agent_logic() (before calling create_agent_fn())
  • Use existing get_agents_by_owner() for count
  • Default limit: 3 agents per user
  • Make configurable via settings (e.g., MAX_AGENTS_PER_USER in settings table)
  • Return HTTP 429 with clear message: "Agent quota exceeded. Maximum 3 agents per user. Delete an agent to create a new one."
  • No database schema changes needed — agent_ownership table already tracks this

3. MCP key auto-provisioning in trinity init

File: src/cli/trinity_cli/commands/auth.py

After successful login in trinity init / trinity login:

  • Call POST /api/mcp/keys/ensure-default (endpoint already exists)
  • Store MCP API key in the profile within ~/.trinity/config.json
  • Optionally write/merge Trinity MCP server config into local .mcp.json so Claude Code can connect immediately

Result: After trinity init, the user's local Claude Code automatically has MCP access to Trinity. Zero manual configuration.

4. Abilities plugin uses CLI credentials

Repo: abilityai/abilities (trinity-onboard plugin)

  • trinity-onboard:onboard should check ~/.trinity/config.json for active profile before prompting for credentials
  • Credential resolution: TRINITY_API_KEY env var → ~/.trinity/config.json active profile → prompt user
  • Deploy step should call trinity deploy . (the CLI command) instead of reimplementing tar+upload via MCP
  • Plugin reads/writes .trinity-remote.yaml as the shared tracking file

Architecture

User's local machine                    Hosted Trinity instance
┌─────────────────────┐                ┌──────────────────────┐
│ ~/my-agent/         │                │                      │
│   CLAUDE.md         │  trinity       │  POST /api/agents/   │
│   .claude/          │  deploy .      │  deploy-local        │
│   template.yaml     │ ──────────────>│                      │
│   .trinity-remote.yaml (tracking)    │  Agent container     │
│                     │                │  created & running   │
│ ~/.trinity/         │                │                      │
│   config.json       │  trinity init  │  POST /api/access/   │
│     (JWT + MCP key) │ <────────────> │  request + verify    │
└─────────────────────┘                └──────────────────────┘

Existing infrastructure (no changes needed)

Component Status
POST /api/agents/deploy-local ✅ Exists
POST /api/mcp/keys/ensure-default ✅ Exists
POST /api/access/request (auto-whitelist) ✅ Exists
get_agents_by_owner() DB method ✅ Exists
~/.trinity/config.json profile system ✅ Exists
trinity-cli on PyPI ✅ Published

Acceptance criteria

  • pip install trinity-cli && trinity init && trinity deploy . works end-to-end on a hosted instance
  • Second trinity deploy . updates the same agent (idempotent via .trinity-remote.yaml)
  • User cannot create more than 3 agents (clear error message with count)
  • After trinity init, MCP key is stored in profile and .mcp.json is configured
  • Abilities plugin detects CLI credentials and skips auth prompts
  • No GitHub account or knowledge required for the default flow

Implementation order

  1. Agent limit enforcement (backend, small)
  2. MCP key provisioning in trinity init (CLI, small)
  3. trinity deploy . command (CLI, medium)
  4. .trinity-remote.yaml tracking file (CLI, small)
  5. Abilities plugin credential sharing (abilities repo, small)

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-p0type-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions