Files
watch_sceen_ai/wsai/factory.py
EJClaw 6b0755e1ff feat: live status dashboard for the voice loop
Add a stdlib-only observability site so you can open a browser and watch,
step by step: whether it is listening, what it heard, what the brain thought
and answered, how long each stage took, and whether anything errored.

- wsai/monitor.py: thread-safe telemetry hub (per-turn timed steps, status
  header, error log) with a pub/sub for live push.
- wsai/dashboard.py: stdlib http.server serving a self-contained page plus an
  SSE (/events) live stream; /api/state snapshot fallback.
- Pipeline emits step-by-step turn telemetry (화면 맥락 → 두뇌 → 응답) and
  listening/running status; optional monitor, so existing paths are untouched.
- `python -m wsai --dashboard` starts the site (0.0.0.0:8787, WSAI_DASHBOARD_PORT)
  and loops the mock voice demo so there is always live activity to watch.
- Tests cover turn recording, per-step timing, error marking, and live push.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-08-16 20:24:13 +09:00

89 lines
2.2 KiB
Python

"""Build a Pipeline from Settings. This is the single place that knows which
concrete class each config name maps to, so adding a backend = one line here."""
from __future__ import annotations
from .config import Settings
from .monitor import Monitor
from .pipeline import Pipeline
def build(settings: Settings, monitor: Monitor | None = None) -> Pipeline:
pipe = Pipeline(
source=_source(settings),
vision=_vision(settings),
brain=_brain(settings),
stt=_stt(settings),
tts=_tts(settings),
text_channel=_text(settings),
monitor=monitor,
)
if monitor is not None:
monitor.set_components(
{
"source": settings.source or "none",
"vision": settings.vision or "none",
"stt": settings.stt or "none",
"brain": settings.brain,
"tts": settings.tts or "none",
"text": settings.text or "none",
}
)
return pipe
def _source(s: Settings):
if s.source in (None, "none"):
return None
if s.source == "mss":
from .backends.capture_mss import MSSFrameSource
return MSSFrameSource(interval=s.capture_interval)
from .backends.mock import MockFrameSource
return MockFrameSource(interval=s.capture_interval)
def _vision(s: Settings):
if s.vision in (None, "none"):
return None
if s.vision == "claude":
from .backends.claude import ClaudeVision
return ClaudeVision(model=s.anthropic_model)
from .backends.mock import MockVision
return MockVision()
def _brain(s: Settings):
if s.brain == "claude":
from .backends.claude import ClaudeBrain
return ClaudeBrain(model=s.anthropic_model)
from .backends.mock import MockBrain
return MockBrain()
def _stt(s: Settings):
if s.stt in (None, "none"):
return None
from .backends.mock import MockSTT
return MockSTT()
def _tts(s: Settings):
if s.tts in (None, "none"):
return None
from .backends.mock import MockTTS
return MockTTS()
def _text(s: Settings):
if s.text in (None, "none"):
return None
raise NotImplementedError("discord text channel backend not implemented yet")