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:
javis-bot
2026-11-14 17:10:53 +09:00
parent e4b6327cf9
commit a5bd25b86f
32 changed files with 901 additions and 91 deletions

View File

@@ -0,0 +1,87 @@
"""personalNotes: the asker's standing instructions for how Jarvis answers them (v2).
Contract: personal_notes.spec.md."""
from __future__ import annotations
import re
from typing import Any, Dict, Optional
from ..base import Tool, ToolContext
from ..types import ToolExecutionResult
from ...debug import debug_log
_ACTIONS = ("add", "list", "delete")
MAX_TEXT_CHARS = 300
def _fail(text: str) -> ToolExecutionResult:
return ToolExecutionResult(success=False, reply_text=f"Error: {text}", error_message=text)
def _ok(text: str) -> ToolExecutionResult:
return ToolExecutionResult(success=True, reply_text=text)
class PersonalNotesTool(Tool):
@property
def name(self) -> str:
return "personalNotes"
@property
def description(self) -> str:
return (
"The person's standing instructions for how you answer them from now on, such as how to "
"address them or which units to use. Call it with action='add' only when they ask for "
"something to apply from now on (not for a one-off request), with text as one short "
"instruction in their language; list or delete them when asked. The saved instructions "
"are shown to you on every answer to this person."
)
@property
def inputSchema(self) -> Dict[str, Any]:
return {
"type": "object",
"properties": {
"action": {"type": "string", "enum": list(_ACTIONS)},
"text": {"type": "string", "description": "add: the instruction, one short sentence"},
"id": {"type": "string", "description": "delete: the id from list"},
},
"required": ["action"],
}
def run(self, args: Optional[Dict[str, Any]], context: ToolContext) -> ToolExecutionResult:
from ...reply.turn_state import get_notes
backend = get_notes()
if backend is None:
return _fail("standing instructions are not available here")
args = args if isinstance(args, dict) else {}
action = next((w for w in re.findall(r"[a-z]+", str(args.get("action") or "").lower()) if w in _ACTIONS), "")
if not action:
return _fail(f"action must be one of {', '.join(_ACTIONS)}")
debug_log(f"personalNotes {action}", "tools")
if action == "list":
result = backend.act("list") or {}
if not result.get("ok"):
return _fail(str(result.get("error") or "the list could not be read"))
items = result.get("items") or []
return _ok("Standing instructions of this person:\n" + "\n".join(
f"- id {i.get('id')}: {i.get('text')}" for i in items) if items
else "No standing instructions are saved for this person.")
if action == "delete":
nid = str(args.get("id") or "").strip()
if not nid:
return _fail("delete needs id (call action='list' first)")
result = backend.act("delete", note=nid) or {}
if not result.get("ok"):
return _fail(str(result.get("error") or "not deleted"))
return _ok(f"Deleted: {result.get('item', {}).get('text', '')}".strip())
text = " ".join(str(args.get("text") or "").split())
if not text:
return _fail("add needs text")
if len(text) > MAX_TEXT_CHARS:
return _fail(f"text must be at most {MAX_TEXT_CHARS} characters")
result = backend.act("add", text=text) or {}
if not result.get("ok"):
return _fail(str(result.get("error") or "not saved"))
return _ok(f"Saved as id {result.get('item', {}).get('id')}: {text}. It applies to every answer to this person.")

View File

@@ -0,0 +1,40 @@
# personalNotes tool spec (v2)
Each person's standing instructions for how Jarvis answers them ("앞으로 나한테는 반말로 해",
"날씨는 섭씨로만"). Product rules: `docs/v2/proactive.md` (제안 4). The app keeps the notes and
sends the asker's with every reply (`app/src/admin.spec.md`, "Personal notes"); this tool only asks
it to add, list or delete them.
## Principles
- **Only in v2, only the asker's own.** The tool exists for a turn only when the v2 voice worker's
brain put a notes backend in the turn state (`turn_state.set_notes`). Without one (v1, evals
without a backend, scheduled tasks) it is not offered and refuses. The backend acts for the
person asking only.
- **Saved only when asked to apply from now on.** The description tells the model to add a note
only for something the person wants from now on, never for a one-off request.
- **Notes shape answers, never permissions.** The reply engine puts the asker's notes
(`run_reply_engine(person_notes=...)`) in the system prompt inside a `<person_notes>` fence,
labelled as the person's own preferences for how they are answered, to follow unless they conflict
with the rules above, and never permitting an action or a tool. Fence tags inside a note are
removed so it cannot close the block. Only the asker's notes are sent, so one person's notes never
reach another person's answer. Eval: `evals/test_personal_notes.py`.
- **Raw data.** The tool returns plain text for the reply model; no LLM call inside.
## Schema
| action | needs | does |
|---|---|---|
| `add` | `text` | saves it (whitespace collapsed, 1-300 characters) |
| `list` | | the asker's notes: `- id <id>: <text>` |
| `delete` | `id` | deletes one of the asker's notes |
`action` is read as its first known word. A refused request never reaches the app.
## Backend
`turn_state.get_notes()` returns an object with `act(action, **fields) -> dict` (add: `text`;
delete: `note`, the note's id): `{"ok": true, "item": {"id", "text"}}` for add and delete,
`{"ok": true, "items": [...]}` for list, `{"ok": false, "error": "..."}` on failure. The voice worker
implements it (`voice_worker/app_bridge.py`): each action goes to the app as `note_action` with the
asker (voice_worker.spec.md, "Personal notes").

View File

@@ -44,6 +44,6 @@ Reminders, timers and scheduled tasks of the person asking. Product rules: `docs
`text`, `at`, `repeat`; delete: `schedule`, the schedule's id): `{"ok": true,
"item": {...}}` for add and delete, `{"ok": true, "items": [...]}` for list, `{"ok": false, "error":
"..."}` on failure. Items carry `id`, `kind`, `text`, `next` (Unix time) and `repeat`. The voice
worker implements it (`voice_worker/schedule_bridge.py`): each action goes to the app as
worker implements it (`voice_worker/app_bridge.py`): each action goes to the app as
`schedule_action` with the asker and where they asked (voice_worker.spec.md, "Schedules").
Failures come back as `Error: ...` text with `success=False`.

View File

@@ -18,6 +18,7 @@ from .builtin.nutrition.fetch_meals import FetchMealsTool
from .builtin.nutrition.delete_meal import DeleteMealTool
from .builtin.chat_channels import ChatChannelsTool
from .builtin.schedule import ScheduleTool
from .builtin.personal_notes import PersonalNotesTool
from .builtin.bot_browser import BotBrowserTool, CDP_ENV
from .builtin.refresh_mcp_tools import RefreshMCPToolsTool
from .builtin.weather import WeatherTool
@@ -50,6 +51,7 @@ BUILTIN_TOOLS = {
"setBroadcast": SetBroadcastTool(),
"chatChannels": ChatChannelsTool(),
"schedule": ScheduleTool(),
"personalNotes": PersonalNotesTool(),
"botBrowser": BotBrowserTool(),
}