VoiceRun command-line interface
Project description
voicerun-cli
A comprehensive command-line interface for interacting with the VoiceRun API. This CLI tool provides easy access to manage agents, functions, environments, and authentication.
Table of Contents
- Prerequisites
- Installation
- Install from PyPI
- Install from Source
- Development Setup
- Quick Start
- Authentication
- Agent Management
- Agent Functions
- Agent Environments
- Features
- Configuration
- API Endpoints
- Requirements
- Dependencies
- Support
- CLI Output Conventions
- Developer Notes
- Phone Number Management
Prerequisites
- Python 3.12+
- uv
If you do not have a uv virtual environment, you can create one with:
uv venv --python 3.12
Note: We recommend using uv to install the package due to the incredible speed of the package manager. The package can still be installed via pip directly, but it will be slower.
Make sure you run below when you are on mac os
pip install pyaudio
Installation
Install from PyPI
The easiest way to install voicerun-cli is from PyPI:
pip install primcli
Install from Source
To install from source (for development or latest features):
uv pip install .
Development Setup
Environment
To switch target platform environment, update:
vr_cli/tools/config.py : API_BASE_URL + FRONTEND_URL
Git Hooks
This project includes git hooks to ensure code quality. To set up the git hooks:
python setup_hooks.py
This will create a pre-commit hook that automatically runs black on Python files before each commit.
Quick Start
-
Sign in to your account:
vr signin -
List your agents:
vr list
Authentication
Sign In
vr signin
This command offers two authentication methods:
- Direct authentication: Enter email and password directly in the terminal
- Web authentication: Opens a browser to login through the VoiceRun website (recommended for enhanced security via Stytch)
When using web authentication, the CLI will open a login URL in your browser and poll for completion. Upon successful login, your session is securely stored locally.
Sign Out
vr signout
Clears your authentication session and removes stored credentials.
Agent Management
List Agents
vr list [--all]
--all: Show detailed information including creation dates and IDs
Agent Information
vr info <agent_name_or_id>
Create Agent
vr create
Interactive command that prompts for:
- Agent name (required)
- Description (required)
- Default voice (by name or ID, required)
Update Agent
vr update <agent_name_or_id>
Interactive command to modify agent properties.
Delete Agent
vr delete <agent_name_or_id>
Deletes an agent after confirmation.
Agent Functions
List Functions
vr func list <agent_name_or_id>
Function Information
vr func info <agent_name_or_id> <function_name_or_id>
Create Function
vr func create <agent_name_or_id> --dir <directory_path>
Creates a new function from a directory. Supports multiple programming languages:
- Python (.py)
- JavaScript (.js)
- e.g. to create a new function with a display name:
vr func create <agent_name_or_id> --dir <directory_path> --display-name "v2"
Update Function
vr func update <agent_name_or_id> <function_name_or_id> [--dir <directory_path>]
--dir: Path to the updated code directory- Without
--dir: Creates a temporary file for editing - e.g. from URL: https://app.primvoices.com/agents/<agent_name_or_id>/function?f=<function_name_or_id>
Delete Function
vr func delete <agent_name_or_id> <function_name_or_id>
Deploy Function
vr func deploy <agent_name_or_id> <function_name_or_id>
Debug Functions
NEW: Debug functions interactively using the command-line debugger, with support for phone and advanced audio features:
vr func debug <agent_name_or_id> <function_name_or_id> [--env <environment_name_or_id>] [--phone]
--phone: Start debugging via phone call (uses environment or user phone number)
Debugger Features
The CLI debugger provides the same functionality as the web UI debugger, plus:
- Real-time WebSocket communication with the agent
- Send text messages to the agent
- View agent responses including text-to-speech events
- Monitor debug events and logs
- Track conversation turns and performance
- Start/stop microphone recording (
listen/stopcommands) - Connect/disconnect phone number (
phonecommand) - Advanced audio system: Echo cancellation, interruption detection, and dynamic echo alignment for seamless voice interaction
Debugger Commands
Once in the debugger, you can use these commands:
send <text>- Send a text message to the agentlisten- Start microphone recording (voice input)stop- Stop microphone recordingphone- Connect or disconnect a phone number for call-based debuggingstatus- Show connection status and debug summarymessages- Show all debug messagesclear- Clear debug messageshelp- Show available commandsquit- Exit debugger
Prerequisites
Before using the debugger, make sure:
-
VoiceRun Agent Server is running on
localhost:7860# In the primvoices-agents directory python src/main.py
-
WebSocket dependency is installed:
pip install websockets
-
Agent and function exist and are properly configured
Example Debug Session
$ vr func debug my-agent my-function
Starting debugger for agent: my-agent, function: my-function
Debug Configuration:
Agent: My Agent (agent-123)
Function: My Function (func-456)
Environment: Development (env-789)
Language: python
Starting interactive debugger...
Connecting to WebSocket server at ws://localhost:7860/ws
โ Connected to ws://localhost:7860/ws
VoiceRun CLI Debugger
Type 'help' for available commands, 'quit' to exit
debug> send Hello, how are you?
โ Sent: Hello, how are you?
๐ค Agent (nova): Hello! I'm doing well, thank you for asking. How can I help you today?
debug> status
Debug Summary:
Total messages: 3
Current turn: 1
Connection: Connected
Listening: No
Recent Messages:
text (input)
text_to_speech (output)
turn_end (system)
debug> quit
Disconnected
Agent Environments
List Environments
vr env list <agent_name_or_id>
Environment Information
vr env info <agent_name_or_id> <environment_name_or_id>
Create Environment
vr env create <agent_name_or_id>
Interactive command that prompts for:
- Environment name (required)
- Phone number (optional)
- Recording settings
- Redaction settings
- STT language (English or Multi-lingual)
- STT keywords (optional)
- Function deployment (optional)
- Environment variables (names required, values optional)
If you choose to add a phone number, the CLI will guide you through associating a number with the environment. This enables phone-based debugging and agent interaction.
Update Environment
vr env update <agent_name_or_id> <environment_name_or_id>
Interactive command to modify environment properties and variables.
Delete Environment
vr env delete <agent_name_or_id> <environment_name_or_id>
Deploy to Environment
vr env deploy <agent_name_or_id> <environment_name_or_id>
Debug Functions
NEW: Debug functions interactively using the command-line debugger:
vr env debug <agent_name_or_id> <environment_name_or_id>
Debugger Features
The CLI debugger provides the same functionality as the web UI debugger:
- WebSocket Communication: Real-time bidirectional communication with VoiceRun agents
- Audio Processing: Capture microphone input and play agent responses
- Text Messaging: Send text messages to agents
- Debug Monitoring: Real-time display of debug messages and conversation turns
- Audio Statistics: Monitor audio levels and speech detection
- Session Management: Automatic session ID generation and management
- Configuration: Environment-based configuration with custom parameters
- Phone Integration: Connect to a phone number for call-based debugging and agent interaction
Debugger Commands
Once in the debugger, you can use these commands:
help- Show help informationstatus- Show connection statusconfig- Show running agent, environment, and functionmessages- Show recent debug messagesdebug <ID>- Show detailed debugging info for a specific messageclear- Clear message historyquit,exit,q, orx- Exit debuggersend <text>- Send a text message to an agent (also runs when typing any text that's not a command)listen- Start microphone recordingstop- Stop microphone recordingphone- Connect or disconnect a phone number
Example Debug Session
$ vr env debug my-agent my-environment
Debugging function 'my-agent' in environment 'my-environment'
VoiceRun Debugger
Type 'help' for available commands, or 'quit' to exit
โ ผ Connected!
start (turn 0)
Agent: Hello from your agent
turn_end (turn 0)
debugger> Hello!
Sent: Hello!
You: Hello!
Agent: Agent heard hello!
turn_end (turn 1)
debugger> config
Agent: my-agent
Agent ID: agent-123
Environment: my-environment
Environment ID: environment-456
Function: my-function
Function ID: function-789
debugger> quit
Goodbye!
Features
Rich Terminal Output
- Color-coded tables and information displays
- Formatted dates and timestamps
- Clear status indicators (Yes/No, On/Off)
Secure Authentication
- Session cookie management
- Secure credential storage
- Direct or web-based authentication using Stytch
File Management
- Automatic language detection from file extensions
- Temporary file creation for code editing
- Support for multiple programming languages
Interactive Prompts
- Confirmation dialogs for destructive operations
- Default value suggestions
- Clear error messages and help text
- All prompts require non-empty input by default unless otherwise specified.
- To allow empty input, the
validationparameter can be set toNonein the prompt utility. - All prompts and confirmations use single quotes around referenced names/IDs and enforce clear, imperative language.
Advanced Audio System
- Real-time microphone capture and playback with PyAudio and pygame
- Echo cancellation: Removes agent output from mic input to prevent feedback
- Interruption detection: Detects when a human interrupts agent speech and stops playback for immediate response
- Dynamic echo alignment: Automatically calibrates echo delay for robust interruption detection
- Hysteresis: Prevents false stops during brief pauses in conversation
- All audio features are available in the debugger and during phone-based sessions
Phone Number Management
User Phone Number
Manage your user phone number for call-based agent interaction:
vr phone
- View your current phone number
- Add a new phone number if none is set
Environment Phone Number
When creating or updating an environment, you can associate a phone number for inbound/outbound calls. This enables phone-based debugging and agent interaction.
- Add a phone number during
vr env createorvr env update - Use the
phonecommand in the debugger to connect/disconnect calls
Configuration
The CLI automatically manages configuration in your home directory:
- Authentication cookies:
~/.voicerun_cookie - Session management and API endpoints
API Endpoints
- API Base URL:
https://api.primvoices.com - Frontend URL:
https://app.primvoices.com
Requirements
- Python 3.7 or higher
- Internet connection for API access
Dependencies
typer: Command-line interface frameworkrequests: HTTP client for API communicationrich: Rich terminal output formatting
CLI Output Conventions
The VoiceRun CLI uses consistent output conventions for all commands to ensure clarity and a professional user experience. These conventions are enforced throughout the codebase:
-
Success messages:
- Printed in bold green using Rich.
- Use
print_success()utility. - Example:
[bold green]Agent created successfully![/bold green]
-
Warning messages:
- Printed in bold yellow with a
Warning:prefix using Rich. - Use
print_warning()utility. - Example:
[bold yellow]Warning: No Set-Cookie header received[/bold yellow]
- Printed in bold yellow with a
-
Error messages:
- Printed in bold red with an
Error:prefix using Rich. - Use
print_error()utility. - Example:
[bold red]Error: Unauthorized. Please sign in with vr signin.[/bold red]
- Printed in bold red with an
-
IDs:
- Always styled as blue in output:
[blue]{id}[/blue] - Applies to all user-facing output, including tables and error messages.
- Always styled as blue in output:
-
File paths and URLs:
- Always styled as cyan in output:
[cyan]{path_or_url}[/cyan] - Applies to all user-facing output, including error/warning messages and informational output.
- Always styled as cyan in output:
-
Tables and formatted output:
- The CLI uses the Rich library for all tables and styled output.
- Table headers use the color defined in
TITLE_COLORinutils/config.py.
-
Prompts and Confirmations:
- All interactive prompts use the
promptandconfirmutilities fromvr_cli/utils/utils.py. - Prompts require non-empty input by default. To allow empty input, pass
validation=None. - Prompts and confirmations use single quotes for referenced names/IDs and clear, imperative language.
- All interactive prompts use the
Note:
- All output and prompt utilities are defined in
vr_cli/utils/utils.py. - Please follow these conventions for any new commands or output added to the CLI.
Developer Notes
Adding New Commands
- Use Typer's
@app.commanddecorator for new commands. - Use the
promptandconfirmutilities for all user input. By default, prompts require non-empty input. For optional input, setvalidation=None. - Always use single quotes around referenced names/IDs in prompts and confirmations.
- Use the output utilities (
print_success,print_error,print_warning,print_info) for all user-facing output. - Style IDs as blue and file paths as cyan using Rich markup.
- Table headers should use the color defined in
TITLE_COLORinutils/config.py.
Testing Agents
NEW: Test your agents interactively using text input:
vr env run <agent_name_or_id> <environment_name_or_id>
This command starts an interactive session where you can:
- Send text messages to your agent
- See real-time responses from your agent function
- View conversation history
- Use built-in commands like
help,status,clear,history
Requirements for Real Agent Testing
To test with real agent responses (not simulated), you need:
- API Key: Set the
PRIMVOICES_API_KEYenvironment variable - PrimVoices Agents: The
primvoices-agentsproject must be available in the same directory - Deployed Function: A function must be deployed to the environment you're testing
Example Session
$ vr env run my-agent development
Starting interactive session for agent 'my-agent' in environment 'development'
Type your messages and press Enter. Type 'quit' or 'exit' to end the session.
Type 'help' for available commands.
Agent function loaded successfully!
You can now interact with your agent using text messages.
You: Hello, how are you?
Agent: Hello! I'm doing well, thank you for asking. How can I help you today?
You: What's the weather like?
Agent: I don't have access to real-time weather information, but I can help you with other questions or tasks. What would you like to know?
You: help
โโ Help โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Available commands: โ
โ - help: Show this help message โ
โ - quit/exit: End the session โ
โ - clear: Clear the conversation history โ
โ - history: Show conversation history โ
โ - status: Show current session status โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
You: quit
Ending session...
Session ended. Total messages: 4
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
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
File details
Details for the file voicerun_cli-0.2.9.tar.gz.
File metadata
- Download URL: voicerun_cli-0.2.9.tar.gz
- Upload date:
- Size: 49.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5181b887acd7e971fe9c5b7e1e4d442ba161b9e7b8c27dee21d7755cc7d9f08
|
|
| MD5 |
7e85986ce687c013fb75fa91c441d7ae
|
|
| BLAKE2b-256 |
f2790e715027470bc5a86fae93305af22d91d4fda8a0041ef1365eaf3bcdbd1b
|
File details
Details for the file voicerun_cli-0.2.9-py3-none-any.whl.
File metadata
- Download URL: voicerun_cli-0.2.9-py3-none-any.whl
- Upload date:
- Size: 46.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7aa1ac83e885b3fc69c7ca4002a23e20b62c45684fdcac345d3c624c4f09558
|
|
| MD5 |
4f2241e668d8d6fb800abf0d2997f176
|
|
| BLAKE2b-256 |
3d0fd54acc79d4a32cf6845d87420f9c4b419229b1b65f5d501f87a29ce8aa5e
|