2026-02-25 07:20:56 -05:00
|
|
|
import subprocess
|
2026-02-21 16:53:16 +00:00
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
import typer
|
|
|
|
|
|
|
|
|
|
from timmy.agent import create_timmy
|
2026-03-05 19:45:38 -05:00
|
|
|
from timmy.prompts import STATUS_PROMPT
|
2026-02-19 19:05:01 +00:00
|
|
|
|
|
|
|
|
app = typer.Typer(help="Timmy — sovereign AI agent")
|
|
|
|
|
|
2026-02-21 16:53:16 +00:00
|
|
|
# Shared option definitions (reused across commands for consistency).
|
|
|
|
|
_BACKEND_OPTION = typer.Option(
|
|
|
|
|
None,
|
|
|
|
|
"--backend",
|
|
|
|
|
"-b",
|
|
|
|
|
help="Inference backend: 'ollama' (default) | 'airllm' | 'auto'",
|
|
|
|
|
)
|
|
|
|
|
_MODEL_SIZE_OPTION = typer.Option(
|
|
|
|
|
None,
|
|
|
|
|
"--model-size",
|
|
|
|
|
"-s",
|
|
|
|
|
help="AirLLM model size when --backend airllm: '8b' | '70b' | '405b'",
|
|
|
|
|
)
|
|
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
|
2026-03-11 08:47:57 -04:00
|
|
|
@app.command()
|
|
|
|
|
def tick():
|
|
|
|
|
"""Run one autonomous thinking cycle (used by systemd timer)."""
|
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
|
|
from timmy.thinking import thinking_engine
|
|
|
|
|
|
|
|
|
|
thought = asyncio.run(thinking_engine.think_once())
|
|
|
|
|
if thought:
|
|
|
|
|
typer.echo(f"[{thought.seed_type}] {thought.content}")
|
|
|
|
|
else:
|
|
|
|
|
typer.echo("No thought produced (thinking disabled or Ollama down).")
|
|
|
|
|
|
|
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
@app.command()
|
2026-02-21 16:53:16 +00:00
|
|
|
def think(
|
|
|
|
|
topic: str = typer.Argument(..., help="Topic to reason about"),
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
backend: str | None = _BACKEND_OPTION,
|
|
|
|
|
model_size: str | None = _MODEL_SIZE_OPTION,
|
2026-02-21 16:53:16 +00:00
|
|
|
):
|
2026-02-19 19:05:01 +00:00
|
|
|
"""Ask Timmy to think carefully about a topic."""
|
2026-02-21 16:53:16 +00:00
|
|
|
timmy = create_timmy(backend=backend, model_size=model_size)
|
2026-02-19 19:05:01 +00:00
|
|
|
timmy.print_response(f"Think carefully about: {topic}", stream=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
2026-02-21 16:53:16 +00:00
|
|
|
def chat(
|
|
|
|
|
message: str = typer.Argument(..., help="Message to send"),
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
backend: str | None = _BACKEND_OPTION,
|
|
|
|
|
model_size: str | None = _MODEL_SIZE_OPTION,
|
2026-02-21 16:53:16 +00:00
|
|
|
):
|
2026-02-19 19:05:01 +00:00
|
|
|
"""Send a message to Timmy."""
|
2026-02-21 16:53:16 +00:00
|
|
|
timmy = create_timmy(backend=backend, model_size=model_size)
|
2026-02-19 19:05:01 +00:00
|
|
|
timmy.print_response(message, stream=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
2026-02-21 16:53:16 +00:00
|
|
|
def status(
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
backend: str | None = _BACKEND_OPTION,
|
|
|
|
|
model_size: str | None = _MODEL_SIZE_OPTION,
|
2026-02-21 16:53:16 +00:00
|
|
|
):
|
2026-02-19 19:05:01 +00:00
|
|
|
"""Print Timmy's operational status."""
|
2026-02-21 16:53:16 +00:00
|
|
|
timmy = create_timmy(backend=backend, model_size=model_size)
|
2026-03-05 19:45:38 -05:00
|
|
|
timmy.print_response(STATUS_PROMPT, stream=False)
|
2026-02-19 19:05:01 +00:00
|
|
|
|
|
|
|
|
|
2026-02-28 09:35:44 -05:00
|
|
|
@app.command()
|
|
|
|
|
def interview(
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
backend: str | None = _BACKEND_OPTION,
|
|
|
|
|
model_size: str | None = _MODEL_SIZE_OPTION,
|
2026-02-28 09:35:44 -05:00
|
|
|
):
|
|
|
|
|
"""Initialize Timmy and run a structured interview.
|
|
|
|
|
|
|
|
|
|
Asks Timmy a series of questions about his identity, capabilities,
|
|
|
|
|
values, and operation to verify he is working correctly.
|
|
|
|
|
"""
|
|
|
|
|
from timmy.interview import InterviewEntry, format_transcript, run_interview
|
|
|
|
|
from timmy.session import chat
|
|
|
|
|
|
|
|
|
|
typer.echo("Initializing Timmy for interview...\n")
|
|
|
|
|
|
|
|
|
|
# Force agent creation by calling chat once with a warm-up prompt
|
|
|
|
|
try:
|
|
|
|
|
chat("Hello, Timmy. We're about to start your interview.", session_id="interview")
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
typer.echo(f"Warning: Initialization issue — {exc}", err=True)
|
|
|
|
|
|
|
|
|
|
def _on_answer(entry: InterviewEntry) -> None:
|
|
|
|
|
typer.echo(f"[{entry.category}]")
|
|
|
|
|
typer.echo(f" Q: {entry.question}")
|
|
|
|
|
typer.echo(f" A: {entry.answer}")
|
|
|
|
|
typer.echo()
|
|
|
|
|
|
|
|
|
|
typer.echo("Starting interview...\n")
|
|
|
|
|
transcript = run_interview(
|
|
|
|
|
chat_fn=lambda msg: chat(msg, session_id="interview"),
|
|
|
|
|
on_answer=_on_answer,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Print full transcript at the end
|
|
|
|
|
typer.echo("\n" + format_transcript(transcript))
|
|
|
|
|
|
|
|
|
|
|
2026-02-25 07:20:56 -05:00
|
|
|
@app.command()
|
|
|
|
|
def up(
|
|
|
|
|
dev: bool = typer.Option(False, "--dev", help="Enable hot-reload for development"),
|
|
|
|
|
build: bool = typer.Option(True, "--build/--no-build", help="Rebuild images before starting"),
|
|
|
|
|
):
|
|
|
|
|
"""Start Timmy Time in Docker (dashboard + agents)."""
|
|
|
|
|
cmd = ["docker", "compose"]
|
|
|
|
|
if dev:
|
|
|
|
|
cmd += ["-f", "docker-compose.yml", "-f", "docker-compose.dev.yml"]
|
|
|
|
|
cmd += ["up", "-d"]
|
|
|
|
|
if build:
|
|
|
|
|
cmd.append("--build")
|
|
|
|
|
|
|
|
|
|
mode = "dev mode (hot-reload active)" if dev else "production mode"
|
|
|
|
|
typer.echo(f"Starting Timmy Time in {mode}...")
|
|
|
|
|
result = subprocess.run(cmd)
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
|
typer.echo(f"\n Timmy Time running at http://localhost:8000 ({mode})\n")
|
|
|
|
|
else:
|
|
|
|
|
typer.echo("Failed to start. Is Docker running?", err=True)
|
|
|
|
|
raise typer.Exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
|
|
|
|
def down():
|
|
|
|
|
"""Stop all Timmy Time Docker containers."""
|
|
|
|
|
subprocess.run(["docker", "compose", "down"], check=True)
|
|
|
|
|
|
|
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
def main():
|
|
|
|
|
app()
|