Registry / web-framework / cua-computer

cua-computer

JSON →
library0.5.19pypypi✓ verified 24d ago

Cua-computer is a Python framework for building rich Computer-Use Interface (CUI) applications, providing programmatic control over terminal interactions, state management, and event processing. It leverages concepts like `Computer`, `Context`, `Task`, and `State` to enable complex, interactive command-line programs. Currently at version 0.5.17, it maintains an active development cadence, with a focus on Python 3.12+ environments.

pip install cua-computer
INSTALL
IMPORT
SIG · CUA-COMPUTER
C
cua-computer
web-frameworkpythonv0.5.19
Install
7.3s avg
Import
1070ms
Disk
70MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 9.8s
py 3.11
✓ —
✓ 7.5s
py 3.12
✓ —
✓ 5.9s
py 3.13
✓ —
✓ 6.1s
py 3.9
✕ build_error
✕ build_error
70MB installed
● package 70MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Computer
from computer import Computer
from cua_computer import Computer

This quickstart demonstrates how to define application `State`, create asynchronous `Task`s for logic and user interaction, and run them using the `Computer` main loop. It includes an example of spawning a sub-task and handling basic keyboard input.

import asyncio from cua_computer import Computer, Context, State, Task, TaskContext from typing import Dict, Any # Define a simple application state class MyState(State): count: int = 0 message: str = "Hello Cua!" # Define a task that increments the count class IncrementTask(Task): async def run(self, context: TaskContext[MyState]): await context.write("Incrementing count...") context.state.count += 1 await context.sleep(1) # Simulate some work await context.write(f"Count is now: {context.state.count}") context.exit() # Task completes # Define a task that displays the current state and offers an action class DisplayTask(Task): async def run(self, context: TaskContext[MyState]): await context.write(f"Current State: {context.state.message} (Count: {context.state.count})") await context.write("Press 'i' to increment, 'q' to quit.") while True: key = await context.read_key() if key == 'i': await context.spawn(IncrementTask()) elif key == 'q': context.exit() break else: await context.write("Unknown command. Press 'i' or 'q'.") async def main(): initial_state = MyState() computer = Computer(initial_state) # Run the main display task await computer.run(DisplayTask()) await computer.exit() # Ensure cleanup after tasks are done if __name__ == "__main__": try: asyncio.run(main()) except KeyboardInterrupt: print("\nExiting Cua application.")
cua --version
Debug
Known issues
breakingAs a pre-1.0 library (currently 0.5.17), `cua-computer`'s API is subject to change without strict adherence to semantic versioning. Users should expect potential breaking changes in minor or even patch releases.
fix
Review release notes carefully for each update and test your application thoroughly after upgrading. Pin to specific patch versions if stability is critical.
affects: <1.0.0
gotchaCUI applications require careful management of the underlying asynchronous event loop. Improper handling of blocking operations or task concurrency can lead to frozen UIs or unexpected behavior.
fix
Always use `await` with `context.sleep()` for delays, `context.read_key()` for input, and `context.spawn()` for long-running or parallel tasks to ensure non-blocking execution within the Cua event loop.
affects: All
gotchaCUI applications can exhibit varying behavior across different terminal emulators (e.g., `xterm`, `gnome-terminal`, `iTerm2`, `tmux`) or operating systems, particularly concerning input handling, color support, and rendering of specific characters or escape codes.
fix
Test your Cua application on target terminal environments. Leverage `rich`'s robust capabilities through `cua-computer` but be aware of its limitations in less capable terminals.
affects: All
gotchaThe `State` object is central to Cua applications. For complex applications, ensuring data consistency and managing state transitions across multiple concurrent `Task`s can become challenging without clear patterns.
fix
Design your `State` object carefully, make state changes explicit within `Task`s, and consider using immutability where appropriate or a dedicated state management pattern for large applications.
affects: All
gotcha`cua-computer`'s `Task`s are designed to be asynchronous. Attempting to run long-duration CPU-bound or blocking I/O operations directly within a `Task` without offloading to a thread pool or separate process will block the entire CUI, freezing the user interface.
fix
For blocking operations, use `asyncio.to_thread()` or `ProcessPoolExecutor` to run them in separate threads/processes, allowing the Cua event loop to remain responsive. Integrate their results back into the `State` asynchronously.
affects: All
Upgrade
Version history
0.5.19latest on PyPI · released Jun 18, 2026
Audit
Dependencies
richrequiredUsed internally for rich terminal rendering and styling capabilities.
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
cua-computer — pip install cua-computer · libregistry