- WS /ws/session: modes, summon, anomaly fragments, streaming direct contact,
passive wire-ghost ambient loop, per-user rate limits, event transcript
- entities: anomaly-signature fingerprinting, LLM minting + procedural
fallback, Codex matching with contact counts and sightings
- tts: 8 local Piper voices (EN/ES), per-entity voice profiles, numpy
effects chain (pitch/rate/bitcrush/echo/static)
- llm: streaming client, submit_stream in bounded queue, SpiritService
with offline fallbacks for every channel
- routes: public /api/codex, /api/codex/{id}, /api/stats; /audio static mount
- models: Entity, EntitySighting, Event, ContactSession(entity_id, language)
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import uuid
|
|
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, String, Text
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db import Base
|
|
|
|
EVENT_KINDS = {"anomaly", "utterance", "question", "reply", "system"}
|
|
|
|
|
|
class Event(Base):
|
|
"""One line in a contact session's transcript: an anomaly, an utterance,
|
|
a user question, or a spirit reply."""
|
|
|
|
__tablename__ = "events"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
|
|
session_id: Mapped[uuid.UUID] = mapped_column(
|
|
ForeignKey("contact_sessions.id"), index=True
|
|
)
|
|
kind: Mapped[str] = mapped_column(String(32))
|
|
text: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
payload: Mapped[dict | None] = mapped_column(JSONB, nullable=True)
|
|
audio_path: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), index=True
|
|
)
|