Skip to main content

remote-cli

Shared SSH & Terminal CLI tool for AI Agent and Human Co-piloting.

remote-cli allows a human user to start an interactive SSH session (handling passwords, 2FA, bastion hosts, and SSH keys themselves) and share that session with an AI Agent via a unique session-id.


Key Features

  • 🤝 Real-Time Human & Agent Co-piloting:
    • The human sees everything the Agent does in their original terminal window in real-time.
    • The human can continue typing and operating in the same session at any time.
  • Zero External Binary Dependencies:
    • Pure Python + POSIX PTY (pty.openpty, termios, tty).
    • No need to install tmux or screen on local or remote servers.
  • 🤖 First-Class AI Agent Support:
    • exec: Structured execution of shell commands with stdout capture and return codes.
    • snapshot: In-memory 2D virtual terminal rendering (pyte) for clean screen capture (even for ncurses / curses / colored prompts).
    • send: Keystrokes and control signals (Ctrl+C, Ctrl+D, confirmation answers y/n).
    • logs: Fast access to recent scrollback history.
  • 🔌 Seamless Background Daemon:
    • Communicates via Unix Domain Sockets (~/.remote-cli/remote-cli.sock).
    • Transparently auto-starts in the background on demand.
    • Safely detach (Ctrl+]) and re-attach (remote-cli attach <session-id>) anytime.

Installation & Setup

Using uv:

# Clone the repository
git clone https://github.com/your-username/remote-cli.git
cd remote-cli

# Install dependencies and create venv
uv sync

# Run directly via uv
uv run remote-cli --help

Quickstart & Workflow

1. Human Starts SSH Session

The user initiates the SSH connection to the remote machine. Once connected and authenticated, a Session ID is displayed:

uv run remote-cli ssh user@server.example.com

Output:

╭────────────────────── remote-cli SSH Session ──────────────────────╮
│ Session Created: s_7f8a9b2c                                        │
│ Agent Command: remote-cli exec s_7f8a9b2c "<command>"               │
│ Press Ctrl+] to detach from session at any time.                  │
╰────────────────────────────────────────────────────────────────────╯
user@server.example.com's password: ***
user@server:~$ _

Tip: You can also create local shell sessions for testing:

uv run remote-cli session create --name my-session -- /bin/bash

2. Share session-id with AI Agent

Simply tell your AI Agent:

"I have logged into the server. The session ID is s_7f8a9b2c. Please check the disk space and restart Nginx."

The Agent can now execute commands on the remote server via remote-cli:

# Agent runs a command and captures return code and stdout
uv run remote-cli exec s_7f8a9b2c "df -h"

# Agent runs a command with JSON output
uv run remote-cli exec s_7f8a9b2c "systemctl status nginx" --json

# Agent inspects the current 2D screen state
uv run remote-cli snapshot s_7f8a9b2c

# Agent sends an interactive response (e.g. confirming a prompt)
uv run remote-cli send s_7f8a9b2c "y"

# Agent sends Ctrl+C to interrupt a long-running process
uv run remote-cli send s_7f8a9b2c --ctrl-c

3. Human Observation & Intervention

While the Agent is executing commands, the human user sees all command text and outputs scrolling in real time in their terminal window. If needed, the human can type commands directly into that same terminal window.


CLI Command Reference

Command Description
remote-cli ssh [SSH_ARGS...] Start SSH session, print Session ID, and attach immediately
remote-cli session create [-d] [-- <CMD...>] Create a new session (default: /bin/bash)
remote-cli session list (or ls) List all active and recent sessions
remote-cli session attach <ID> (or attach) Attach terminal in raw mode to existing session
remote-cli session close <ID> Close and terminate a session
remote-cli exec <ID> "<COMMAND>" Execute command in session, capture output & exit code
remote-cli send <ID> [TEXT] Send raw keystrokes or control keys (--ctrl-c, --ctrl-d)
remote-cli snapshot <ID> Capture 2D terminal screen state (ANSI-rendered)
remote-cli logs <ID> [-n LINES] View recent output scrollback logs
remote-cli daemon start / stop / status Manage background daemon lifecycle

Architecture

┌─────────────────────────┐          ┌───────────────────────────┐
│   Human User Terminal   │          │     AI Agent / Script     │
│       (Raw Mode)        │          │ (remote-cli exec/snapshot)│
└────────────┬────────────┘          └─────────────┬─────────────┘
             │                                     │
             │   Attach (Stdin/Stdout stream)      │ JSON Request/Response
             ▼                                     ▼
   ┌─────────────────────────────────────────────────────────────┐
   │             remote-cli Daemon Process                       │
   │       (Unix Domain Socket: ~/.remote-cli/remote-cli.sock)   │
   │                                                             │
   │  ┌────────────────────────────────────────────────────────┐ │
   │  │ Session (e.g. s_7f8a9b2c)                              │ │
   │  │  - Master/Slave PTY (`pty.openpty`)                    │ │
   │  │  - Pyte Virtual Terminal Screen (`pyte.HistoryScreen`) │ │
   │  │  - Scrollback Ring Buffer                              │ │
   │  │  - Exec Sentinel Detection Engine                      │ │
   │  │  - Process: `ssh user@remote-server` (or local shell)  │ │
   │  └────────────────────────────────────────────────────────┘ │
   └─────────────────────────────────────────────────────────────┘

Running Tests

uv run pytest -v

Release files for remote-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for remote-cli 0.1.0
File Size Uploaded
remote_cli-0.1.0.tar.gz 35.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for remote-cli 0.1.0
File Interpreter ABI Platform
remote_cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 54.7 kB

Release files / remote_cli-0.1.0.tar.gz

Download URL remote_cli-0.1.0.tar.gz
Size 35.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dcc5afd200e76aca9740dfeb84b0e745586d299587ebea7d782339d4da79ee98
BLAKE2b-256 checksum
How to use checksums
4c4381e76eb6f5d0e9bf657dcead2248e21a8c74ca67589c374eb575f8754830
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / remote_cli-0.1.0-py3-none-any.whl

Download URL remote_cli-0.1.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e141299c5feaba7e26c59881352f2ce485df16353fc935a573f2f8869d72bfd8
BLAKE2b-256 checksum
How to use checksums
96bad3850512139f1ebc2f46c090487a9c82bb399037c9f54464b5eeeb6e729f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page