Repository navigation
feat(routines): bots ask for routines with schedule_routine - #72
Merged
Merged
Conversation
Asked to check something every day, bots called CronCreate. That job lives only in the bot's process: it dies on a restart, expires in 7 days and never shows in the Routines tab. Bots now run with --disallowedTools for CronCreate, CronDelete, CronList, ScheduleWakeup and RemoteTrigger, and their rules send the owner to the Routines tab instead.
A bot asked to do something at set times now calls schedule_routine: a name, what to do each time and when, for itself or, by handle, for another bot of its crew. The daemon checks it like routines.create before the owner sees it; the owner gets a card in the bot's chat with the same fields as the routine editor, may change them and creates or declines it. Changes are checked again before the request closes, so a bad schedule is worded on the card and it stays open. A bot that bypasses permissions creates it at once. Without a zone, the computer's zone is used, as in the app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Built on top of #70 (its commit is the first one here); merge #70 first with a merge commit and this diff shrinks to one commit.
Problem
Bots could not create Botloft routines (spec 20.10 left it for later), so when the owner asked for something at a set time they reached for Claude Code's own scheduler, which #70 turns off. This gives them the real thing.
Change
schedule_routineMCP tool (any bot, not only the chief):name,prompt,schedule(same JSON as spec 20.2), optionalbot(handle of another crew bot) andtimezone(defaults to the computer's zone, read withjiff, as the app does).routines.createbefore the owner sees anything; impossible requests (too often, unknown zone, unknown handle, extra fields) go back to the bot as errors.approvals.answerbefore the request closes, so a bad schedule is shown on the card in the owner's language and the card stays open.bypass_permissionscreates it at once, likesuggest_bot.schedule_routine, the only way to schedule.Tests
crates/botloftd/tests/routine_requests.rs: approve, change before approving (a too-frequent change is refused and the request stays open), decline, a routine for another bot plus an unknown handle, impossible requests never reaching the owner, and bypass with the default zone.app/src/features/routines/routineRequest.test.tsx: create as asked, change the schedule, a routine for another bot, decline with a note.cargo fmt,clippy -D warnings,cargo test --workspaceandpnpm checkpass.Tested with real Claude Code (2.1.284, Haiku, dev daemon in a separate home)
ToolSearch, calledcrew_roster, thenschedule_routinewithbot: "email", weekdays at 08:00. The zone came out as the system'sAmerica/Sao_Paulo. After approval,routines.listshowed the routine on Email with its next run at 08:00 local.Manual check in the app