fix: wire Pip familiar into Workshop state pipeline (#412)
Co-authored-by: Kimi Agent <kimi@timmy.local> Co-committed-by: Kimi Agent <kimi@timmy.local>
This commit was merged in pull request #412.
This commit is contained in:
@@ -75,6 +75,7 @@ def _build_world_state(presence: dict) -> dict:
|
|||||||
"energy": presence.get("energy", 0.5),
|
"energy": presence.get("energy", 0.5),
|
||||||
"confidence": presence.get("confidence", 0.7),
|
"confidence": presence.get("confidence", 0.7),
|
||||||
},
|
},
|
||||||
|
"familiar": presence.get("familiar"),
|
||||||
"activeThreads": presence.get("active_threads", []),
|
"activeThreads": presence.get("active_threads", []),
|
||||||
"recentEvents": presence.get("recent_events", []),
|
"recentEvents": presence.get("recent_events", []),
|
||||||
"concerns": presence.get("concerns", []),
|
"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."""
|
"""Generate a bark response and broadcast it to all Workshop clients."""
|
||||||
await _broadcast(json.dumps({"type": "timmy_thinking"}))
|
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)
|
_refresh_ground(visitor_text)
|
||||||
reply = await _generate_bark(visitor_text)
|
reply = await _generate_bark(visitor_text)
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,19 @@ def _current_energy() -> float:
|
|||||||
return max(_ENERGY_MIN, min(1.0, decayed))
|
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:
|
def get_state_dict() -> dict:
|
||||||
"""Build presence state dict from current cognitive state.
|
"""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"),
|
"local_time": local_now.strftime("%-I:%M %p"),
|
||||||
"day_of_week": local_now.strftime("%A"),
|
"day_of_week": local_now.strftime("%A"),
|
||||||
},
|
},
|
||||||
|
"familiar": _pip_snapshot(mood, confidence),
|
||||||
"meta": {
|
"meta": {
|
||||||
"schema_version": 1,
|
"schema_version": 1,
|
||||||
"updated_at": now.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
"updated_at": now.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||||
|
|||||||
Reference in New Issue
Block a user