Skip to main content

Python SDK for the agents-ui terminal workspace application

Project description

agents-ui Python SDK

License: AGPL v3 Python 3.10+

Python SDK for the agents-ui terminal workspace application. Provides complete programmatic access to all 68 API methods — sessions, projects, files, SSH, recordings, events, and more.

This is the official Python client for agents-ui, a terminal workspace for AI coding agents.

Installation

pip install agents-ui-sdk

From source:

git clone https://github.com/FusionbaseHQ/agents-ui-python-sdk.git
cd agents-ui-python-sdk
pip install -e ".[dev]"

Quick Start

Async

import asyncio
from agents_ui import AgentsUIClient

async def main():
    async with AgentsUIClient() as client:
        # List projects
        projects = await client.projects.list()
        print(f"Projects: {[p.title for p in projects]}")

        # Create a session and run a command
        session = await client.sessions.create(projects[0].id, name="sdk-demo")
        await client.sessions.write(session.id, "echo hello world\r")

        # Subscribe to output events
        async with client.subscribe(["sessions.output"], session_id=session.id) as stream:
            async for event in stream:
                print(event.data.get("output", ""))
                break

asyncio.run(main())

Sync

from agents_ui import SyncAgentsUIClient

with SyncAgentsUIClient() as client:
    info = client.app.info()
    print(f"Connected to {info.name} v{info.version}")

    projects = client.projects.list()
    for project in projects:
        print(f"  - {project.title} ({project.id})")

Architecture

The SDK communicates with the agents-ui desktop application over a Unix domain socket using JSON-RPC 2.0. Connection parameters are automatically discovered from ~/.agents-ui/api.json.

Your Python code
      |
      v
 AgentsUIClient  (this SDK)
      |
      v  JSON-RPC 2.0 over Unix socket
      |
 agents-ui desktop app  (Tauri/Rust)
      |
      v  PTY / SSH / filesystem
      |
 Terminal sessions, files, SSH hosts

Key Features

  • Async-first with a full synchronous wrapper — use whichever fits your project
  • Auto-discovery — connection parameters are read from ~/.agents-ui/api.json automatically
  • Complete coverage — all 68 API methods across 14 namespaces
  • Typed models — frozen dataclasses for every domain object with full IDE autocompletion
  • Event streaming — subscribe to real-time terminal output, session exits, and more
  • Zero dependencies — stdlib only (asyncio, json, socket)

Namespaces

The client organizes methods into namespaces matching the API categories:

Namespace Methods Description
client.sessions 16 Terminal session lifecycle and I/O
client.persistent_sessions 3 Background persistent sessions
client.projects 8 Workspace project management
client.prompts 7 Reusable command prompts
client.environments 5 Environment configurations
client.assets 7 Project asset templates
client.recordings 6 Session recording playback
client.ssh 4 SSH connection management
client.files 7 Local file operations
client.ssh_files 8 Remote SSH file operations
client.split_views 4 Terminal split panes
client.ui 5 UI control and state
client.app 4 App info and event subscriptions
client.api 2 API introspection

Connection Override

# Use explicit connection parameters instead of auto-discovery
client = AgentsUIClient(
    socket_path="/path/to/api.sock",
    token="your-auth-token",
)

Error Handling

All API errors map to typed exceptions:

from agents_ui import AgentsUIClient, NotFoundError, RateLimitError

async with AgentsUIClient() as client:
    try:
        session = await client.sessions.get("nonexistent")
    except NotFoundError:
        print("Session not found")
    except RateLimitError:
        print("Too many requests")

Event Subscriptions

async with client.subscribe(["sessions.output", "sessions.exit"]) as stream:
    async for event in stream:
        if event.event == "sessions.output":
            print(f"[{event.session_id}] {event.data['output']}")
        elif event.event == "sessions.exit":
            print(f"Session {event.session_id} exited")
            break

Utilities

Raw PTY output includes ANSI escape sequences. Use strip_ansi() for clean text:

from agents_ui import strip_ansi

clean = strip_ansi(raw_terminal_output)

Examples

The examples/ directory contains runnable scripts covering every major feature:

Example Description
01_quickstart.py Connect, list projects and sessions (async)
02_quickstart_sync.py Same as above using the synchronous client
03_run_command.py Create a session, run a command, capture output
04_file_operations.py List, read, write, rename, and delete files
05_event_stream.py Subscribe to real-time session output events
06_project_management.py Create, update, list, and delete projects
07_ssh_hosts.py List SSH hosts and connection history
08_prompts_and_environments.py Manage reusable prompts and environment configs
09_recordings.py List and load session recordings
10_api_introspection.py Discover all available API methods at runtime
11_ui_and_theme.py Control UI state, themes, and panel visibility
12_error_handling.py Typed exceptions and error handling patterns

Run any example (requires a running agents-ui instance):

python examples/01_quickstart.py

Development

git clone https://github.com/FusionbaseHQ/agents-ui-python-sdk.git
cd agents-ui-python-sdk
pip install -e ".[dev]"

# Run tests (no running app needed — uses a mock server)
pytest

# Type checking
mypy src/agents_ui/

Requirements

  • Python 3.10+
  • A running agents-ui desktop application
  • Zero runtime dependencies (stdlib only)

Related Projects

  • agents-ui — The terminal workspace application (Tauri/Rust + React)
  • agents-ui.com — Project homepage and downloads

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

See the LICENSE file for the full license text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agents_ui_sdk-0.1.1.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agents_ui_sdk-0.1.1-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file agents_ui_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: agents_ui_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for agents_ui_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 17ccbe63701bded03132a97572afae16ad2745ff8a9246c08fee40a44985812b
MD5 d8456a340c332b4acb5d436c1a620dcf
BLAKE2b-256 71959e3fec587f80f7d51643455db93d5fea9b7a1426c7de6533d4d741f93a7b

See more details on using hashes here.

File details

Details for the file agents_ui_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agents_ui_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 43.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for agents_ui_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8715d26ab6fd59f3440f145e51aba7a21cf172623f7d68c3e5db0d80a463c1cf
MD5 764cee82cc5a6afbe8ec5a9755c49c86
BLAKE2b-256 bce83b62077fb446fa623817588a9191f6c2c603267a2e74beb25f1937dd8fc4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page