Cua CLI API Reference
Python API reference for the Cua command-line interface
CUA CLI - Unified command-line interface for Computer-Use Agents.
main
Main entry point for CUA CLI.
print_error
def print_error(message: str) -> NonePrint an error message to stderr.
create_parser
def create_parser() -> argparse.ArgumentParserCreate the main argument parser with all subcommands.
main
def main() -> intMain entry point for the CLI.
auth
Authentication module for CUA CLI.
CredentialStore
SQLite-based credential store with WAL mode for concurrent access.
Constructor
CredentialStore(self, db_path: Path | None = None)Attributes
| Name | Type | Description |
|---|---|---|
db_path | Any |
Methods
CredentialStore.get
def get(self, key: str) -> Optional[str]Get a value from the store.
Parameters:
| Name | Type | Description |
|---|---|---|
key | Any | The key to look up |
Returns: The value, or None if not found
CredentialStore.set
def set(self, key: str, value: str) -> NoneSet a value in the store.
Parameters:
| Name | Type | Description |
|---|---|---|
key | Any | The key to set |
value | Any | The value to store |
CredentialStore.delete
def delete(self, key: str) -> boolDelete a value from the store.
Parameters:
| Name | Type | Description |
|---|---|---|
key | Any | The key to delete |
Returns: True if the key was deleted, False if it didn't exist
CredentialStore.clear
def clear(self) -> NoneClear all stored credentials.
clear_credentials
def clear_credentials() -> NoneClear all stored credentials.
get_api_key
def get_api_key() -> Optional[str]Get the stored API key.
First checks CUA_API_KEY environment variable, then falls back to stored credentials.
Returns: The API key, or None if not found
save_api_key
def save_api_key(api_key: str) -> NoneSave an API key to the credential store.
Parameters:
| Name | Type | Description |
|---|---|---|
api_key | Any | The API key to save |
utils
Utility modules for CUA CLI.
run_async
def run_async(coro: Coroutine[Any, Any, T]) -> TRun an async coroutine synchronously.
This is the standard pattern for CLI commands that need to call async code.
Parameters:
| Name | Type | Description |
|---|---|---|
coro | Any | The coroutine to run |
Returns: The result of the coroutine
print_error
def print_error(message: str) -> NonePrint an error message to stderr.
print_info
def print_info(message: str) -> NonePrint an info message.
print_json
def print_json(data: Any) -> NonePrint data as formatted JSON.
print_success
def print_success(message: str) -> NonePrint a success message.
print_table
def print_table(data: list[dict[str, Any]], columns: list[tuple[str, str]] | None = None, title: str | None = None) -> NonePrint data as a formatted table.
Parameters:
| Name | Type | Description |
|---|---|---|
data | Any | List of dictionaries to display |
columns | Any | List of (key, header) tuples. If None, uses all keys from first item. |
title | Any | Optional table title |
print_warning
def print_warning(message: str) -> NonePrint a warning message.
Was this page helpful?