Python SDK for CMDOP agent interaction
Project description
cmdop
Python SDK for CMDOP — remote terminal and file management for your machines.
Installation
pip install cmdop
Quick Start
from cmdop import CMDOPClient
with CMDOPClient.remote(api_key="cmdop_live_xxx") as client:
# Terminal
session = client.terminal.create()
client.terminal.send_input(session.session_id, "ls -la\n")
# Files
files = client.files.list("/home")
content = client.files.read("/etc/hostname")
Features
| Feature | Description |
|---|---|
| Remote Mode | Connect via cloud relay (grpc.cmdop.com) |
| Local Mode | Direct IPC with local agent (Unix socket) |
| Sync & Async | Both CMDOPClient and AsyncCMDOPClient |
| Terminal | Create sessions, send input, resize, signals |
| Files | List, read, write, copy, move, delete |
| Type Safe | Full Pydantic v2 models |
Connection Modes
# Remote — via cloud relay
client = CMDOPClient.remote(api_key="cmdop_live_xxx")
# Local — direct to agent
client = CMDOPClient.local()
Async Usage
import asyncio
from cmdop import AsyncCMDOPClient
async def main():
async with AsyncCMDOPClient.remote(api_key="cmdop_live_xxx") as client:
session = await client.terminal.create()
await client.terminal.send_input(session.session_id, "whoami\n")
files = await client.files.list("/tmp")
asyncio.run(main())
API Reference
Terminal Service
| Method | Description |
|---|---|
create(shell, cols, rows) |
Create terminal session |
send_input(session_id, data) |
Send input to terminal |
resize(session_id, cols, rows) |
Resize terminal |
send_signal(session_id, signal) |
Send signal (SIGINT, etc.) |
get_history(session_id, lines) |
Get output history |
close(session_id) |
Close session |
Files Service
| Method | Description |
|---|---|
list(path, limit, offset) |
List directory contents |
read(path) |
Read file contents |
write(path, content) |
Write file |
delete(path, recursive) |
Delete file or directory |
copy(src, dst) |
Copy file |
move(src, dst) |
Move/rename file |
mkdir(path, parents) |
Create directory |
info(path) |
Get file metadata |
Error Handling
from cmdop import CMDOPClient
from cmdop.exceptions import (
AgentOfflineError,
AuthenticationError,
SessionNotFoundError,
FileNotFoundError,
)
try:
client = CMDOPClient.remote(api_key="cmdop_live_xxx")
client.terminal.create()
except AuthenticationError:
print("Invalid API key")
except AgentOfflineError:
print("Agent not connected")
Configuration
from cmdop import CMDOPClient
from cmdop.models import ConnectionConfig, KeepaliveConfig
config = ConnectionConfig(
connect_timeout_seconds=10.0,
request_timeout_seconds=30.0,
keepalive=KeepaliveConfig(time_ms=10_000, timeout_ms=5_000),
)
client = CMDOPClient.remote(api_key="cmdop_live_xxx", config=config)
Requirements
- Python 3.10+
- grpcio, protobuf
- pydantic v2
- httpx
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cmdop-0.1.0.tar.gz
(118.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
cmdop-0.1.0-py3-none-any.whl
(212.5 kB
view details)
File details
Details for the file cmdop-0.1.0.tar.gz.
File metadata
- Download URL: cmdop-0.1.0.tar.gz
- Upload date:
- Size: 118.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7502489aaa159ae1b613297f0365e2965ff10a1a95eff1e3cd0850d4fb9f7911
|
|
| MD5 |
5f0b1ffa800e04a0ef5064aa7ac7c16f
|
|
| BLAKE2b-256 |
900bdba37bba4f6a8e083d927e9fffceb403d6048ed40b7c55d189e2a15f443f
|
File details
Details for the file cmdop-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cmdop-0.1.0-py3-none-any.whl
- Upload date:
- Size: 212.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0745c1d8cb3c642072daa6d0cac57013532b78b2ad183ee45253ab1ce4ad8bff
|
|
| MD5 |
065058eae5e1acf19644157bb26c01c7
|
|
| BLAKE2b-256 |
4954fac8802c23b3045d94d29019ef9f82bb98a8aa9ea4c53e2427c8c0a8c131
|