Phase 3 — WS frame + REST fallbacka

This commit is contained in:
Roberto Musso
2026-04-18 22:18:53 +02:00
parent 0b5ef48463
commit d5fea95561
20 changed files with 613 additions and 15 deletions

View File

@@ -3,6 +3,7 @@
from __future__ import annotations
import re
from datetime import datetime, timezone
from typing import Any
from langchain_core.tools import tool
@@ -92,9 +93,33 @@ async def delete_timeline(timeline_id: str) -> str:
return f"Timeline {timeline_id} deleted."
@tool
async def list_timelines_today() -> str:
"""List all timeline events (milestones) whose date falls on today (UTC)."""
now = datetime.now(tz=timezone.utc)
start_ms = int(datetime(now.year, now.month, now.day, tzinfo=timezone.utc).timestamp() * 1000)
end_ms = start_ms + 86_400_000 - 1
result = await execute_on_client(
action="select",
table="timelines",
filters={"dateFrom": start_ms, "dateTo": end_ms},
)
rows = result.get("rows", [])
if not rows:
return "No timeline events today."
lines = [f"- {r['title']} (date: {r['date']}, id: {r['id']})" for r in rows]
return f"Timeline events today ({len(rows)}):\n" + "\n".join(lines)
TIMELINE_TOOLS: list[Any] = [
list_timelines,
list_timelines_today,
create_timeline,
update_timeline,
delete_timeline,
]
TIMELINE_READ_TOOLS: list[Any] = [
list_timelines,
list_timelines_today,
]