feat: reminders and scheduled tasks (schedule tool, app store and delivery)
The brain gets a schedule tool (add, list, delete the asker's own reminders, timers and tasks) offered only with a schedule backend. The voice worker asks the app through schedule_action and runs fired tasks as reply via task with read-only tools, no MCP and a fresh short-term memory. The app keeps the schedules in config/schedules.json, fires them every 5 s, speaks them when the person is in Jarvis's voice channel and otherwise posts in the chat channel they asked in (or schedule.chatChannel for voice). A feature switch and a 예약 screen list and delete everyone's schedules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1051,10 +1051,12 @@ def _recent_messages(cfg, dialogue_memory) -> list:
|
||||
return dialogue_memory.get_recent_messages()
|
||||
|
||||
|
||||
def _offered_builtins(cfg, chat_available: bool) -> dict:
|
||||
"""The built-in tools this turn can offer: the enabled ones (``enabled_builtin_tools``), and
|
||||
chatChannels only with a chat backend (chat_channels.spec.md)."""
|
||||
return {k: v for k, v in enabled_builtin_tools(cfg).items() if k != "chatChannels" or chat_available}
|
||||
def _offered_builtins(cfg, chat_available: bool, schedule_available: bool = False) -> dict:
|
||||
"""The built-in tools this turn can offer: the enabled ones (``enabled_builtin_tools``),
|
||||
chatChannels only with a chat backend (chat_channels.spec.md) and schedule only with a
|
||||
schedule backend (schedule.spec.md)."""
|
||||
return {k: v for k, v in enabled_builtin_tools(cfg).items()
|
||||
if (k != "chatChannels" or chat_available) and (k != "schedule" or schedule_available)}
|
||||
|
||||
|
||||
def _route_tools(cfg, redacted: str, builtin_tools: dict, mcp_tools: dict, recent_messages: list):
|
||||
@@ -1077,12 +1079,14 @@ def _route_tools(cfg, redacted: str, builtin_tools: dict, mcp_tools: dict, recen
|
||||
)
|
||||
|
||||
|
||||
def prepare_intent(cfg, text: str, dialogue_memory, chat_available: bool) -> Optional[list]:
|
||||
def prepare_intent(cfg, text: str, dialogue_memory, chat_available: bool,
|
||||
schedule_available: bool = False) -> Optional[list]:
|
||||
"""Run the intent judge (the tool router) for ``text`` ahead of its reply (v2: on a partial
|
||||
transcript while the user still speaks), with the inputs ``run_reply_engine(intent_judge=True)``
|
||||
would give it, so its pick can be passed back as ``prepared_tools``. None when the router gave
|
||||
up (its fall-open to the whole catalogue is not a pick). ``chat_available``: the reply will
|
||||
have a chat backend (the chatChannels tool is in the catalogue)."""
|
||||
have a chat backend (the chatChannels tool is in the catalogue); ``schedule_available``: a
|
||||
schedule backend (the schedule tool is)."""
|
||||
mcp_tools: dict = {}
|
||||
if getattr(cfg, "mcps", {}):
|
||||
try:
|
||||
@@ -1090,7 +1094,7 @@ def prepare_intent(cfg, text: str, dialogue_memory, chat_available: bool) -> Opt
|
||||
mcp_tools = get_cached_mcp_tools()
|
||||
except Exception:
|
||||
mcp_tools = {}
|
||||
builtin = _offered_builtins(cfg, chat_available)
|
||||
builtin = _offered_builtins(cfg, chat_available, schedule_available)
|
||||
try:
|
||||
routed = _route_tools(cfg, redact(text), builtin, mcp_tools, _recent_messages(cfg, dialogue_memory))
|
||||
except Exception as exc: # pragma: no cover — defensive
|
||||
@@ -1230,9 +1234,9 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
# needed. Both cases are preserved for the engine to distinguish.
|
||||
# chatChannels exists only when the v2 brain gave this turn a chat backend
|
||||
# (chat_channels.spec.md); otherwise it is not in the catalogue at all.
|
||||
from .turn_state import get_chat as _get_chat
|
||||
from .turn_state import get_chat as _get_chat, get_schedule as _get_schedule
|
||||
_chat_backend = _get_chat()
|
||||
_builtin_tools = _offered_builtins(cfg, _chat_backend is not None)
|
||||
_builtin_tools = _offered_builtins(cfg, _chat_backend is not None, _get_schedule() is not None)
|
||||
_all_builtin_names = list(_builtin_tools.keys())
|
||||
_all_mcp_names = list(mcp_tools.keys())
|
||||
_full_catalog_names = _all_builtin_names + _all_mcp_names
|
||||
|
||||
Reference in New Issue
Block a user