Files
Timmy-time-dashboard/src/timmy_serve/cli.py
Alexander Whitestone 91af33d71c
Some checks failed
Tests / lint (pull_request) Failing after 12s
Tests / test (pull_request) Has been skipped
refactor: extract hardcoded sats limit in grok L402 proxy
Replace hardcoded sats values with config.settings references:
- grok.py: use settings.grok_sats_hard_cap instead of literal 100
- cli.py: default --price to settings.grok_sats_hard_cap from config

Fixes #937

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 21:40:11 -04:00

57 lines
1.6 KiB
Python

"""Serve-mode CLI — run Timmy as an API service.
Usage:
timmy-serve start [--port 8402]
timmy-serve status
"""
import typer
app = typer.Typer(help="Timmy Serve — sovereign AI agent API")
@app.command()
def start(
port: int = typer.Option(8402, "--port", "-p", help="Port for the serve API"),
host: str = typer.Option("0.0.0.0", "--host", "-h", help="Host to bind to"),
price: int = typer.Option(None, "--price", help="Price per request in sats (default: from config)"),
dry_run: bool = typer.Option(False, "--dry-run", help="Print config and exit (for testing)"),
):
"""Start Timmy in serve mode."""
from config import settings
if price is None:
price = settings.grok_sats_hard_cap
typer.echo(f"Starting Timmy Serve on {host}:{port}")
typer.echo(f"L402 payment proxy active — {price} sats per request")
typer.echo("Press Ctrl-C to stop")
typer.echo("\nEndpoints:")
typer.echo(" POST /serve/chat — Chat with Timmy")
typer.echo(" GET /serve/invoice — Request an invoice")
typer.echo(" GET /serve/status — Service status")
typer.echo(" GET /health — Health check")
if dry_run:
typer.echo("\n(Dry run mode - not starting server)")
return
import uvicorn
from timmy_serve.app import create_timmy_serve_app
serve_app = create_timmy_serve_app()
uvicorn.run(serve_app, host=host, port=port)
@app.command()
def status():
"""Show serve-mode status."""
typer.echo("Timmy Serve — Status")
typer.echo(" Service: active")
def main():
app()