Installation
The Narrator CLI is automatically installed when you install the Narrator package:narrator
command will be available (run with uv run narrator
if using uv).
Commands
Database Commands
narrator init
Initialize database tables for thread and message storage:threads
- Stores conversation threadsmessages
- Stores messages within threads
narrator status
Check database connection and display basic statistics:- Database connection status
- Number of recent threads
- Basic health check information
Docker Commands
narrator docker-setup
One-command setup that starts PostgreSQL and initializes tables:- Starts a PostgreSQL container with the correct configuration
- Waits for the database to be ready
- Initializes the required tables
- Provides the connection string to use
narrator docker-start
Start a PostgreSQL container for Narrator:narrator docker-stop
Stop the PostgreSQL container:Quick Start with Docker
The fastest way to get started with PostgreSQL for Narrator:Configuration
Environment Variables
The Narrator CLI respects these environment variables:Database Connection
Variable | Description | Default |
---|---|---|
NARRATOR_DATABASE_URL | Database connection string | None (uses in-memory) |
Docker Configuration
These variables affect thedocker-*
commands:
Variable | Description | Default |
---|---|---|
NARRATOR_DB_NAME | Database name | narrator |
NARRATOR_DB_USER | Database username | narrator |
NARRATOR_DB_PASSWORD | Database password | narrator_dev |
NARRATOR_DB_PORT | Port to expose PostgreSQL | 5432 |
Connection Pool Settings
For PostgreSQL connections:Variable | Description | Default |
---|---|---|
NARRATOR_DB_POOL_SIZE | Connection pool size | 5 |
NARRATOR_DB_MAX_OVERFLOW | Max overflow connections | 10 |
NARRATOR_DB_POOL_TIMEOUT | Connection timeout (seconds) | 30 |
NARRATOR_DB_POOL_RECYCLE | Connection recycle time (seconds) | 300 |
NARRATOR_DB_ECHO | Enable SQL logging | false |
Database URLs
Narrator supports different database backends:Examples
Local Development Setup
Custom Docker Configuration
Production Setup
CI/CD Pipeline
Integration with Tyler
When using Tyler agents with persistent storage:Troubleshooting
Connection Errors
“Failed to connect to database”: Check your database URL and ensure the database server is running:Permission Errors
“Permission denied”: Ensure your database user has CREATE TABLE permissions:Migration Issues
“Table already exists”: The init command is idempotent and will skip existing tables. This is not an error.Environment Variable Issues
“No database URL provided”: Set the environment variable:Best Practices
- Always initialize before use: Run
narrator init
before using ThreadStore with a database - Use environment variables: Avoid hardcoding database URLs in your code
- Use connection pooling: For production, configure pool settings appropriately
- Regular backups: Set up automated backups for production databases
- Monitor connections: Keep an eye on connection pool usage in production
Advanced Usage
Custom Database Configuration
Create a.env
file for your project: