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:
@@ -149,6 +149,21 @@ pub struct ScheduleAction {
|
||||
pub schedule: Option<String>,
|
||||
}
|
||||
|
||||
/// The brain's personalNotes tool asks the app for the person asking (voice_worker.spec.md,
|
||||
/// "Personal notes").
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||
pub struct NoteAction {
|
||||
pub id: String,
|
||||
/// `add`, `list` or `delete`.
|
||||
pub action: String,
|
||||
pub user: String,
|
||||
#[serde(default)]
|
||||
pub text: Option<String>,
|
||||
/// delete: the note's id.
|
||||
#[serde(default)]
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum WorkerEvent {
|
||||
Ready(HelloOk),
|
||||
@@ -160,6 +175,7 @@ pub enum WorkerEvent {
|
||||
TtsDone(TtsDone),
|
||||
ChatAction(ChatAction),
|
||||
ScheduleAction(ScheduleAction),
|
||||
NoteAction(NoteAction),
|
||||
/// The brain's answer to `reply` (empty and `failed` when it gave none).
|
||||
ReplyText { id: String, text: String, failed: bool },
|
||||
/// Was the utterance said to Jarvis? (a failed judgement is a no)
|
||||
@@ -350,15 +366,24 @@ impl WorkerClient {
|
||||
|
||||
/// The outcome of a `schedule_action`: `{item}` or `{items}`, or why it failed.
|
||||
pub fn schedule_action_result(&self, id: &str, result: Result<Value, String>) {
|
||||
self.app_action_result("schedule_action_result", id, result);
|
||||
}
|
||||
|
||||
/// The outcome of a `note_action`: `{item}` or `{items}`, or why it failed.
|
||||
pub fn note_action_result(&self, id: &str, result: Result<Value, String>) {
|
||||
self.app_action_result("note_action_result", id, result);
|
||||
}
|
||||
|
||||
fn app_action_result(&self, kind: &str, id: &str, result: Result<Value, String>) {
|
||||
let msg = match result {
|
||||
Ok(Value::Object(mut m)) => {
|
||||
m.insert("type".into(), json!("schedule_action_result"));
|
||||
m.insert("type".into(), json!(kind));
|
||||
m.insert("id".into(), json!(id));
|
||||
m.insert("ok".into(), json!(true));
|
||||
Value::Object(m)
|
||||
}
|
||||
Ok(_) => json!({"type": "schedule_action_result", "id": id, "ok": true}),
|
||||
Err(e) => json!({"type": "schedule_action_result", "id": id, "ok": false, "error": e}),
|
||||
Ok(_) => json!({"type": kind, "id": id, "ok": true}),
|
||||
Err(e) => json!({"type": kind, "id": id, "ok": false, "error": e}),
|
||||
};
|
||||
self.send_json(msg);
|
||||
}
|
||||
@@ -375,12 +400,14 @@ impl WorkerClient {
|
||||
/// no answer, or the worker refuses it.
|
||||
/// `via`: `voice`, `chat` or `task` (a scheduled task: read-only tools, never spoken).
|
||||
pub fn reply(&self, id: &str, user: u64, text: &str, via: &str, speak: bool) -> bool {
|
||||
self.reply_in(id, user, text, via, speak, None)
|
||||
self.reply_in(id, user, text, via, speak, None, &[])
|
||||
}
|
||||
|
||||
/// `reply`, naming the chat channel a chat message was written in (the brain's schedule tool
|
||||
/// delivers there).
|
||||
pub fn reply_in(&self, id: &str, user: u64, text: &str, via: &str, speak: bool, channel: Option<u64>) -> bool {
|
||||
/// delivers there) and carrying the asker's standing instructions (`notes`, at most 20).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn reply_in(&self, id: &str, user: u64, text: &str, via: &str, speak: bool, channel: Option<u64>,
|
||||
notes: &[String]) -> bool {
|
||||
if speak {
|
||||
self.inner.state.lock().unwrap().open_tts.insert(id.to_owned());
|
||||
}
|
||||
@@ -389,6 +416,9 @@ impl WorkerClient {
|
||||
if let Some(c) = channel {
|
||||
msg["channel"] = json!(c.to_string());
|
||||
}
|
||||
if !notes.is_empty() {
|
||||
msg["notes"] = json!(notes);
|
||||
}
|
||||
let sent = self.send_json(msg);
|
||||
if !sent && speak {
|
||||
self.end_failed(id);
|
||||
@@ -634,6 +664,7 @@ fn on_text(inner: &Inner, t: &str) {
|
||||
"final" => serde_json::from_value(v).ok().map(WorkerEvent::Final),
|
||||
"chat_action" => serde_json::from_value(v).ok().map(WorkerEvent::ChatAction),
|
||||
"schedule_action" => serde_json::from_value(v).ok().map(WorkerEvent::ScheduleAction),
|
||||
"note_action" => serde_json::from_value(v).ok().map(WorkerEvent::NoteAction),
|
||||
"llm_idle" => {
|
||||
if let Some(id) = v["id"].as_u64() {
|
||||
inner.llm_idle.send_if_modified(|got| if id > *got { *got = id; true } else { false });
|
||||
|
||||
Reference in New Issue
Block a user