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:
@@ -98,6 +98,8 @@ pub struct FeatureSettings {
|
||||
/// The bot browser's window on a virtual monitor to share in Discord (admin.spec.md, "Virtual
|
||||
/// monitor"); off by default.
|
||||
pub browser_share: bool,
|
||||
/// Reminders and scheduled tasks (admin.spec.md, "Schedules").
|
||||
pub schedule: bool,
|
||||
}
|
||||
|
||||
/// Game detection (admin.spec.md, "Game detection"): on by default; the person's own games and
|
||||
@@ -174,6 +176,9 @@ pub struct Settings {
|
||||
pub mcp_servers: Vec<McpServerSettings>,
|
||||
pub collect: CollectSettings,
|
||||
pub game: GameSettings,
|
||||
/// The registered chat channel a schedule asked by voice is posted in when its person is not in
|
||||
/// Jarvis's voice channel (admin.spec.md, "Schedules"); None: not delivered then.
|
||||
pub schedule_channel: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -217,10 +222,11 @@ impl Default for Settings {
|
||||
response: PolicySettings::default(),
|
||||
memory: Map::new(),
|
||||
llm: LlmSettings { url: None, port: 8080, context: 32768 },
|
||||
features: FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false },
|
||||
features: FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false, schedule: true },
|
||||
mcp_servers: vec![],
|
||||
collect: CollectSettings { keep_days: 30, targets: vec![] },
|
||||
game: GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0, reserve_gb: 8.0, revert_seconds: 30, pause_in_game: false },
|
||||
schedule_channel: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,6 +502,10 @@ pub fn parse_settings(raw: &Value) -> Result<Settings, SettingsError> {
|
||||
sync_discord: get_bool(Some(m), "syncDiscord", &path, true)?,
|
||||
});
|
||||
}
|
||||
let schedule_channel = opt_snowflake(section(raw, "schedule")?, "chatChannel", "schedule", None, "a Discord channel ID")?;
|
||||
if schedule_channel.is_some_and(|c| !chat_channels.iter().any(|x| x.id == c && x.send)) {
|
||||
return err("schedule.chatChannel must be a registered chat channel with sending on");
|
||||
}
|
||||
|
||||
Ok(Settings {
|
||||
discord: DiscordSettings {
|
||||
@@ -541,11 +551,13 @@ pub fn parse_settings(raw: &Value) -> Result<Settings, SettingsError> {
|
||||
collect: get_bool(f, "collect", "features", d.features.collect)?,
|
||||
browser: get_bool(f, "browser", "features", d.features.browser)?,
|
||||
browser_share: get_bool(f, "browserShare", "features", d.features.browser_share)?,
|
||||
schedule: get_bool(f, "schedule", "features", d.features.schedule)?,
|
||||
}
|
||||
},
|
||||
mcp_servers: parse_mcp_servers(raw)?,
|
||||
collect: parse_collect(raw, &d.collect)?,
|
||||
game: parse_game(raw, &d.game)?,
|
||||
schedule_channel,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -881,18 +893,26 @@ mod tests {
|
||||
#[test]
|
||||
fn features_and_mcp_servers_are_read_and_checked() {
|
||||
let s = parse_settings(&json!({}));
|
||||
assert_eq!(s.unwrap().features, FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false });
|
||||
assert_eq!(s.unwrap().features, FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false, schedule: true });
|
||||
let s = parse_settings(&json!({
|
||||
"features": {"weather": false, "meals": false, "browserShare": true},
|
||||
"features": {"weather": false, "meals": false, "browserShare": true, "schedule": false},
|
||||
"mcpServers": [{"name": "brave", "command": "npx", "args": ["-y", "brave"], "env": ["BRAVE_API_KEY", " "]},
|
||||
{"name": "time-2", "command": "uvx", "enabled": false}]
|
||||
})).unwrap();
|
||||
assert_eq!(s.features, FeatureSettings { weather: false, web_search: true, meals: false, collect: true, browser: true, browser_share: true });
|
||||
assert_eq!(s.features, FeatureSettings { weather: false, web_search: true, meals: false, collect: true, browser: true, browser_share: true, schedule: false });
|
||||
assert_eq!(s.mcp_servers, vec![
|
||||
McpServerSettings { name: "brave".into(), command: "npx".into(), args: vec!["-y".into(), "brave".into()],
|
||||
env: vec!["BRAVE_API_KEY".into()], enabled: true },
|
||||
McpServerSettings { name: "time-2".into(), command: "uvx".into(), args: vec![], env: vec![], enabled: false },
|
||||
]);
|
||||
// A schedule channel must be a registered one that Jarvis may send in.
|
||||
let ch = json!([{"id": "123456789012345678", "send": true}, {"id": "123456789012345679", "send": false}]);
|
||||
let s = parse_settings(&json!({"chatChannels": ch, "schedule": {"chatChannel": "123456789012345678"}})).unwrap();
|
||||
assert_eq!(s.schedule_channel, Some(123456789012345678));
|
||||
for c in ["123456789012345679", "123456789012345670"] {
|
||||
let e = parse_settings(&json!({"chatChannels": ch, "schedule": {"chatChannel": c}})).unwrap_err();
|
||||
assert!(e.0.contains("schedule.chatChannel"), "{e}");
|
||||
}
|
||||
let cases = [
|
||||
(json!({"features": {"weather": "no"}}), "features.weather"),
|
||||
(json!({"mcpServers": {}}), "mcpServers"),
|
||||
|
||||
Reference in New Issue
Block a user