Merge branch 'main' into kimi/issue-222
All checks were successful
Tests / lint (pull_request) Successful in 4s
Tests / test (pull_request) Successful in 1m4s

This commit is contained in:
2026-03-19 03:19:25 -04:00
2 changed files with 23 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ def _build_world_state(presence: dict) -> dict:
"energy": presence.get("energy", 0.5),
"confidence": presence.get("confidence", 0.7),
},
"familiar": presence.get("familiar"),
"activeThreads": presence.get("active_threads", []),
"recentEvents": presence.get("recent_events", []),
"concerns": presence.get("concerns", []),
@@ -232,6 +233,14 @@ async def _bark_and_broadcast(visitor_text: str) -> None:
"""Generate a bark response and broadcast it to all Workshop clients."""
await _broadcast(json.dumps({"type": "timmy_thinking"}))
# Notify Pip that a visitor spoke
try:
from timmy.familiar import pip_familiar
pip_familiar.on_event("visitor_spoke")
except Exception:
pass # Pip is optional
_refresh_ground(visitor_text)
reply = await _generate_bark(visitor_text)

View File

@@ -73,6 +73,19 @@ def _current_energy() -> float:
return max(_ENERGY_MIN, min(1.0, decayed))
def _pip_snapshot(mood: str, confidence: float) -> dict:
"""Tick Pip and return his current snapshot dict.
Feeds Timmy's mood and confidence into Pip's behavioral AI so the
familiar reacts to Timmy's cognitive state.
"""
from timmy.familiar import pip_familiar
pip_familiar.on_mood_change(mood, confidence=confidence)
pip_familiar.tick()
return pip_familiar.snapshot().to_dict()
def get_state_dict() -> dict:
"""Build presence state dict from current cognitive state.
@@ -135,6 +148,7 @@ def get_state_dict() -> dict:
"local_time": local_now.strftime("%-I:%M %p"),
"day_of_week": local_now.strftime("%A"),
},
"familiar": _pip_snapshot(mood, confidence),
"meta": {
"schema_version": 1,
"updated_at": now.strftime("%Y-%m-%dT%H:%M:%SZ"),