Add Hearthkeeper preview endpoint

This commit is contained in:
2026-05-12 20:30:00 -05:00
parent 5c920fa309
commit 02fe426c94
2 changed files with 64 additions and 0 deletions

View File

@@ -398,6 +398,38 @@ class AgentOrchestrator:
"third_tick_after_interval": third_tick,
}
async def preview_hearthkeeper_prompt(self, session_id: str) -> dict:
"""Generate a Hearthkeeper prompt preview without sending or recording it."""
session_info = self.active_sessions.get(session_id)
if not session_info:
return {"generated": False, "reason": "session_not_found"}
recent_discussion_messages = []
async for db_session in get_session():
repo = Repository(db_session)
recent_discussion_messages = await repo.get_recent_human_messages(
session_id=session_id,
limit=5,
)
recent_discussion = [
message.content for message in recent_discussion_messages[:5]
]
agent_response = await self.hearthkeeper.generate_prompt(
theme=session_info.get("theme"),
dashboard=session_info.get("dashboard"),
recent_discussion=recent_discussion,
)
return {
"generated": True,
"session_id": session_id,
"agent_response": agent_response,
"theme": session_info.get("theme"),
"dashboard": session_info.get("dashboard"),
"recent_discussion": recent_discussion,
}
async def _count_response_actions(self, session_id: str, mode: str) -> int:
"""Count response actions for a mode in a session."""
async for db_session in get_session():