feat: personal notes, each person's standing instructions for how Jarvis answers them
A personalNotes tool (add, list, delete the asker's own notes) offered only with a notes backend. The app keeps the notes in config/notes.json and sends the asker's with every voice, chat and task reply; the reply engine puts them in a <person_notes> fence as that person's preferences, which never permit an action or a tool. The worker's schedule bridge becomes a shared app bridge for schedule_action and note_action. A 사람별 지침 screen edits and deletes any note; features.notes turns the tool and the notes off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,12 +18,14 @@ from jarvis.memory.history import HistoryContext, Scope
|
||||
|
||||
class Brain(Protocol):
|
||||
def reply(self, user: str, text: str, history: HistoryContext, chat=None, schedule=None,
|
||||
task: bool = False) -> Optional[str]:
|
||||
task: bool = False, notes: Optional[list] = None, notes_backend=None) -> Optional[str]:
|
||||
"""Blocking; called on a worker thread, one call per person at a time (a voice and a chat
|
||||
reply for different people may overlap). ``chat``: the chat backend for
|
||||
the chatChannels tool (voice_worker/chat_bridge.py), or None without registered channels.
|
||||
``schedule``: the schedule backend for the schedule tool (voice_worker/schedule_bridge.py).
|
||||
``task``: a scheduled task runs, with the read-only tools only (``TASK_TOOLS``)."""
|
||||
``schedule``: the schedule backend for the schedule tool (voice_worker/app_bridge.py).
|
||||
``task``: a scheduled task runs, with the read-only tools only (``TASK_TOOLS``).
|
||||
``notes``: the asker's standing instructions, put in the prompt; ``notes_backend``: the
|
||||
backend for the personalNotes tool (personal_notes.spec.md)."""
|
||||
|
||||
def addressed(self, user: str, text: str, names: list[str]) -> Optional[bool]:
|
||||
"""Blocking: was ``text`` said to the assistant (called ``names``)? None when it could not tell.
|
||||
@@ -267,7 +269,8 @@ class JarvisBrain:
|
||||
self._prepared[user] = p
|
||||
t0 = time.perf_counter()
|
||||
try:
|
||||
p.tools = Muted.run(prepare_intent, self.cfg, text, mem, chat, schedule_available=True)
|
||||
p.tools = Muted.run(prepare_intent, self.cfg, text, mem, chat, schedule_available=True,
|
||||
notes_available=True)
|
||||
finally:
|
||||
p.done.set()
|
||||
debug_log(f"brain prepare user={user} picked={p.tools is not None} "
|
||||
@@ -290,7 +293,7 @@ class JarvisBrain:
|
||||
return dataclasses.replace(self.cfg, disabled_tools=tuple(dict.fromkeys(off)), mcps={})
|
||||
|
||||
def reply(self, user: str, text: str, history: HistoryContext, chat=None, schedule=None,
|
||||
task: bool = False) -> Optional[str]:
|
||||
task: bool = False, notes: Optional[list] = None, notes_backend=None) -> Optional[str]:
|
||||
from jarvis.memory.conversation import DialogueMemory
|
||||
from jarvis.reply import turn_state
|
||||
from jarvis.reply.engine import run_reply_engine
|
||||
@@ -309,11 +312,13 @@ class JarvisBrain:
|
||||
turn_state.set_user(user)
|
||||
turn_state.set_chat(None if task else chat)
|
||||
turn_state.set_schedule(None if task else schedule)
|
||||
turn_state.set_notes(None if task else notes_backend)
|
||||
try:
|
||||
return run_reply_engine(self.db, cfg, None, text, memory,
|
||||
language=self.language, history=history, legacy_memory=False,
|
||||
default_language=self.reply_language, compact_prompt=True,
|
||||
intent_judge=True, prepared_tools=prepared)
|
||||
intent_judge=True, prepared_tools=prepared,
|
||||
person_notes=notes or None)
|
||||
finally:
|
||||
turn_state.reset()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user