ulysses/routes
pewdiepie-archdaemon a19b6d2d4d Cookbook scheduler: calendar events drive model serve windows (experimental, feature-flagged)
Add a calendar-driven scheduler so a user can pick a model in Cookbook, click "Schedule…" instead of "Launch", choose time windows + days of the week + (optional) end date, and have Odysseus auto-launch the serve when the window starts and hard-kill it when the window ends. The calendar IS the source of truth — events on a designated calendar are interpreted as serve schedules, so editing the event in the calendar UI immediately changes the schedule.

Whole feature is gated by setting `cookbook_scheduler_enabled` (default False). Disabling the setting silences the reconciler and the API refuses requests; setting + three new files = entire surface, easy to revert.

New files:
  - src/cookbook_scheduler.py — background reconciler: ticks every 60s, reads next ±90s of calendar events on the designated calendar, launches/kills serves to match. Honors "refuse if GPUs busy" (skips with reason, no retry). Adopts pre-existing manual serves matching the event's model so window-end cleanup still applies. Tags scheduler-owned tasks with `_scheduledBy: <event_uid>` so it never kills serves it doesn't own.
  - routes/cookbook_schedule_routes.py — POST /api/cookbook/schedule/from-cookbook builds RRULE+ICS events from the modal's input (model, slots[], days[], until). GET /upcoming returns the next 24h with per-event status (scheduled / running / adopted / skipped / failed / ended) for the UI. POST /reconcile-now manually kicks the reconciler.
  - static/js/cookbookSchedule.js — Schedule button click handler + modal. Daily/hourly time slot picker, multi-slot ("+ add another time slot"), weekday chips with Weekdays/Weekend/Every-day quicksets, optional Until date. Calls /from-cookbook on save. Whole module is a single IIFE; deleting the file plus its <script> tag removes the UI surface.

Existing files touched (minimal):
  - app.py: register the new router + add the reconcile loop as a startup task (~10 lines, all in one block). Reconcile loop checks the feature flag on every tick, so leaving it running with the flag off costs ~one settings lookup per minute.
  - static/index.html: one new <script> tag for cookbookSchedule.js.
  - static/js/cookbookServe.js: add a "Schedule…" button next to the existing Launch button. Hidden by default; cookbookSchedule.js reveals it after confirming the feature flag is on.
  - static/style.css: ~80 lines for the modal styles (mobile-aware via @media).

User choices baked in:
  - Calendar events are the source of truth.
  - Refuse to launch if GPUs busy (skip + log reason in scheduler.events[uid].reason).
  - Hard kill at event end.
  - No retry on a skipped event within the window.
  - Multi-slot per day supported (one calendar event per slot, shared RRULE).
  - Pre-existing manual serves get adopted at window start so they're killed at end.

Known follow-ups (not in this commit):
  - Settings UI to pick the schedule calendar + toggle the feature flag.
  - Calendar event color/badge for status (running/skipped/failed).
  - "Lazy launch on first request" — currently launches at event start. Replacing _launch_serve with a proxy that defers vllm until the first chat request is a contained future change.
2026-06-05 02:35:23 +09:00
..
__init__.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
admin_wipe_routes.py Admin: wipe gallery albums with images 2026-06-02 20:35:57 +09:00
api_token_routes.py Codex Agent integration: HTTP surface + plugin bundle + Settings UI 2026-06-03 22:49:09 +09:00
assistant_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
auth_routes.py fix(auth): revoke API tokens when deleting users 2026-06-04 04:44:34 +01:00
backup_routes.py fix: backup import drops a user's memory when its text matches another user's (#1743) 2026-06-03 13:29:14 +09:00
calendar_routes.py chore: remove unused imports in calendar_routes (#2221) 2026-06-04 12:13:18 +01:00
chat_helpers.py fix: auto-naming for 24h time format (#1374) 2026-06-03 14:14:34 +09:00
chat_routes.py fix: rewriting a message is lost on reload due to a non-existent DB column (#1729) 2026-06-03 13:31:19 +09:00
cleanup_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
codex_routes.py cookbook agent debug loop: persistent log files, auto-adopt orphan tmux, Codex/Claude skill parity 2026-06-04 23:27:18 +09:00
compare_routes.py fix(compare): stop blind mode leaking model identities via session names (#1318) 2026-06-04 04:39:01 +01:00
contacts_routes.py fix(contacts): parse Apple/iCloud item-grouped vCard EMAIL/TEL properties (#1438) 2026-06-03 14:24:04 +09:00
cookbook_helpers.py cookbook agent debug loop: persistent log files, auto-adopt orphan tmux, Codex/Claude skill parity 2026-06-04 23:27:18 +09:00
cookbook_routes.py cookbook agent debug loop: persistent log files, auto-adopt orphan tmux, Codex/Claude skill parity 2026-06-04 23:27:18 +09:00
cookbook_schedule_routes.py Cookbook scheduler: calendar events drive model serve windows (experimental, feature-flagged) 2026-06-05 02:35:23 +09:00
diagnostics_routes.py Fix email-thread HTML injection, attachment path traversal, and missing authz (#475) 2026-06-01 22:20:17 +09:00
document_helpers.py fix: _resolve_user_upload_path crashes on a non-dict resolve_upload result (#1715) 2026-06-03 13:34:33 +09:00
document_routes.py fix: document library language facet undercounts text documents (#1758) 2026-06-03 13:28:38 +09:00
editor_draft_routes.py Ignore invalid editor draft payloads (#1533) 2026-06-03 14:07:03 +09:00
email_helpers.py fix(email): guard _decode_header against unknown MIME charset (#1354) 2026-06-03 14:24:20 +09:00
email_pollers.py fix: guard remaining uid.decode() calls in auto-classify spam path (#1860) 2026-06-04 04:06:10 +01:00
email_routes.py fix(uploads): bound direct upload reads 2026-06-04 00:32:50 +01:00
embedding_routes.py Ignore non-object embedding endpoint config (#1260) 2026-06-03 14:12:41 +09:00
emoji_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
font_routes.py Keep compact font family names together (#1263) 2026-06-03 14:24:30 +09:00
gallery_helpers.py fix: gallery records raw instead of display dimensions for EXIF-rotated photos (#1667) 2026-06-03 14:23:04 +09:00
gallery_routes.py fix(uploads): bound direct upload reads 2026-06-04 00:32:50 +01:00
history_routes.py fix: history DB fallback returned hidden (compaction) messages to the client (#1726) 2026-06-03 13:30:11 +09:00
hwfit_routes.py Merge remote-tracking branch 'origin/main' into visual-pr-playground 2026-06-03 16:49:10 +09:00
mcp_routes.py Fix email-thread HTML injection, attachment path traversal, and missing authz (#475) 2026-06-01 22:20:17 +09:00
memory_routes.py fix(uploads): bound direct upload reads 2026-06-04 00:32:50 +01:00
model_routes.py fix: log warnings on silently swallowed agent and endpoint failures (#2367) 2026-06-04 12:29:31 +01:00
note_routes.py fix: fire-reminder endpoint crashes with NameError on _gcu (#1250) 2026-06-03 01:02:25 +09:00
personal_routes.py fix: personal-docs path confinement used abspath, allowing symlink escape (#1728) 2026-06-03 13:29:57 +09:00
prefs_routes.py Persist user prefs atomically (#1840) 2026-06-04 03:55:22 +01:00
preset_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
research_routes.py fix(research): owner-scope endpoint resolution 2026-06-03 23:19:28 +01:00
search_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
session_routes.py fix(compare): stop blind mode leaking model identities via session names (#1318) 2026-06-04 04:39:01 +01:00
shell_routes.py Add a 'Rebuild llama.cpp' Cookbook action to force a fresh GPU build (#1787) 2026-06-03 13:28:19 +09:00
signature_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
skills_routes.py fix: skill test-task / precision helpers crash on a non-dict skill (#1638) 2026-06-03 08:59:24 +09:00
stt_routes.py fix(uploads): bound direct upload reads 2026-06-04 00:32:50 +01:00
task_routes.py feat: Claude Agent integration + cookbook reconnect + UI polish 2026-06-04 08:27:26 +09:00
tts_routes.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
upload_routes.py fix: use safe .get for id lookup in uploads.json to prevent KeyError (#1465) 2026-06-03 14:12:00 +09:00
vault_routes.py Keep Bitwarden unlock password off argv (#1311) 2026-06-03 02:13:51 +09:00
webhook_routes.py Reapply "Merge branch 'main' of github.com:pewdiepie-archdaemon/odysseus" 2026-06-03 22:47:00 +09:00