feat(scheduled): retire core Send later doors for the plugin's commands (CLI + MCP) #36

Closed
gabrielvidal wants to merge 0 commits from scheduled-doors into main
pull from: scheduled-doors
Owner

Merge after #37 (branch based on cron-jobs-plugin).

Summary

Send later became the scheduled-conversations plugin on 2026-11-26, but core kept its doors: /api/scheduled*, the CLI's ai-agent later / scheduled / unschedule, and the MCP's schedule_conversation / cancel_scheduled / browse kind=scheduled. Gabriel decided (form cron-scheduled-in-the-cli-and-mcp_x4nk83) to remove them and route everything through the plugin's own commands, each with "mcp": true. Connections bound to a worker can't schedule anymore: only Full does (the owner's own CLI, or an unbound connection). The core keeps the week's budget reader (op: upcoming) and the stopped-run card's Resume at…. The plugin PR is the companion: gabrielvidal/ai-agent-plugins scheduled-doors.

Key changes

  • backend/plugins/schedule_bridge.py: the router and its /api/scheduled* routes are gone. What remains is the provider lookup, run_op and upcoming (budget). main.py no longer mounts it.
  • backend/schemas/scheduled.py deleted, and frontend/openapi.json + src/generated regenerated (only deletions).
  • authz:
    • the runs.schedule permission is removed (it had no route left; stored roles drop unknown ids through catalog.clean);
    • the routes are out of authz/routes.py;
    • matrix.golden.txt is regenerated;
    • worker.read / worker.run lose it;
    • mock/rolesCatalog.json is regenerated.
  • workers/bound.py: the docstring no longer says bound connections schedule. A bound connection has no plugins.use, so it gets no plugin actions and no plugin tools.
  • cli/ai_agent.py: later / scheduled / unschedule are gone. They are not aliased: each one now only prints the plugin command that replaces it and exits 2, the way ai-agent services does. The scheduling section (parse_when) is gone too.
  • cli/mcp_tools.py:
    • schedule_conversation, cancel_scheduled and browse kind scheduled are removed;
    • the schedule group is removed (GROUPS, mcpserver/store.py defaults, the AI apps page label), and stored settings drop it through the existing intersection;
    • WORKER_TOOLS / WORKER_KINDS are trimmed.
  • cli/mcp_server.py: the instructions now name the plugin tools.
  • New generic command arg, "conversation": true:
    • It is validated in plugins/commands.py.
    • cli/plugin_commands.resolve_conversations turns any spelling (a session id, a ≥6-char prefix, a conversation id or a viewer link) into a session id before calling the action. This is the old CLI's resolve().
    • The CLI maps . to $CLAUDE_SESSION_ID; the MCP refuses ..
    • This is how add --to . keeps parity with ai-agent later … --to ..
  • Docs are updated: CLAUDE.md, docs/plugins.md (conversation arg, the provider and commands notes), docs/mcp.md, docs/permissions.md, docs/fresh-context.md. scripts/fresh-context-calibration.py now reads the plugin's store, plus the .migrated copy.
  • Tests:
    • test_worker_bound checks that a bound connection (run or read) gets a 403 on the plugin's actions and its commands catalogue;
    • test_plugin_schedule checks that the door is gone;
    • test_mcp checks that the old tools are gone and that a bound connection has no plugin_* tools and no browse scheduled;
    • test_plugin_commands covers the conversation arg;
    • the cli tests cover ., a viewer link, a missing session, the MCP prefix resolution and the . refusal.

Key decisions

  • conversation: true as a generic arg type rather than a header or plugin-specific code. Core still names no plugin. The plugin can't see the caller's session, but the CLI can. An older hub ignores the key, and the plugin then refuses . with a clear message.
  • Remove the runs.schedule permission: a route permission with no routes fails test_every_route_permission_is_in_the_catalog. The plugin's actions are ownerOnly anyway.
  • Remove the schedule MCP group: it would be an empty switch. Plugin tools go in read / run.
  • Pointer messages for the old commands (exit 2, nothing runs). This is not an alias; it follows the ai-agent services precedent, so a stale habit in an agent prompt gets a clear way forward.

Changelog

  • Changed: Send later from a shell or an AI app is now ai-agent plugin scheduled-conversations add|ls|show|cancel|start and the MCP tools plugin_scheduled-conversations_*.
  • Removed: ai-agent later / scheduled / unschedule, the MCP schedule_conversation / cancel_scheduled / browse scheduled, and the Schedule tool group in Settings → AI apps.
  • Removed: a connection bound to a worker can no longer schedule conversations.

Test notes

  • Backend, every module under bwrap (one process each): 168/169 pass. test_typed_plugins::test_records_carry_kind fails identically on main.
  • cli/ with pytest: 117 passed. Vitest: 1104/1105 (FreshContext CacheExpiredNotice, already failing on main). tsc clean, npm run build OK.
  • Live local hub on :8132 with the plugin 1.1.0 installed from the plugins worktree:
    • ai-agent plugin scheduled-conversations add "…" --in 2h, --model qwen (→ pi), --to ., --to <prefix>, ls, cancel, show (404 after cancel);
    • the MCP listing shows the five plugin_scheduled-conversations_* tools and none of the old three;
    • . over MCP is refused;
    • a worker-headed call to the plugin action gets a 403;
    • /api/scheduled POST gets a 405, and GET falls through to the SPA shell;
    • op: upcoming still answers for the budget;
    • Settings → AI apps renders (screenshot).
  • Deploy order: install / upgrade the scheduled-conversations plugin to 1.1.0 when this deploys. It adds the models.read capability, so it needs re-approval, and every command becomes MCP. Merge the homelab PR at the same time: its cron agents (goal-keeper, tag-tuner, backup-audit) call the new command.
  • Not deployed from the EVOX2: deploy from the Homelab after review.
  • Rebased onto cron-jobs-plugin (2026-11-28): the conflicts in CLAUDE.md, backend/main.py, cli/ai_agent.py, cli/mcp_server.py, cli/mcp_tools.py, cli/test_mcp_tools.py, docs/mcp.md and AiApps.tsx were resolved so that both the cron MCP tools / browse cron (#37) and the scheduled ones (this PR) are gone. The MCP groups are now read · run · agents. frontend/openapi.json, src/generated, matrix.golden.txt and mock/rolesCatalog.json were regenerated from the rebased tree (only #37's docstrings moved; the golden matrix is unchanged).
  • After the rebase: backend 2141 passed, 1 failed (test_typed_plugins::test_records_carry_kind, which also fails on main); cli/ 117 passed; tsc clean.

When hub-mcp-plugin is rebased onto this (don't merge as is)

ai-agent hub-mcp-plugin:

  • cli/ai_agent.py: drop cmd_later / cmd_scheduled / cmd_unschedule + their parsers (this branch replaced them with SCHEDULED_MOVED pointers), and parse_when / the # ── scheduling section (_DUR_RE/_DUR_S now sit above _since).
  • cli/test_ai_agent.py: the later / scheduled tests.
  • backend/main.py: the plugins.schedule_bridge.router mount; backend/test_worker_bound.py's test_scheduled_turns_are_passed_on_as_that_worker / test_without_the_plugin_nothing_is_scheduled.
  • CLAUDE.md's "/api/scheduled* stays as a thin door…" paragraph.
  • That branch gives a worker's CLI a Full mode. Only Full may schedule (it must hold plugins.use); Read / Run must not.

ai-agent-plugins hub-mcp (plugins/hub-mcp/):

  • handlers/hubmcp_tools.py:
    • drop the schedule_conversation / cancel_scheduled tools;
    • drop "scheduled" from BROWSE_KINDS / WORKER_KINDS and the _rows branch;
    • drop "schedule" from GROUPS;
    • drop both from the worker tool set.
  • README.md: the schedule table row.
  • Tests: test_hub_mcp_plugin.py (groups ["read","run","schedule","agents"], tools["schedule"]), test_hub_mcp_tools.py (the schedule group / schedule_conversation tests), test_hub_mcp_endpoint.py (schedule_conversation / cancel_scheduled assertions).
  • Its plugin tools path must also call resolve_conversations (conversation args) if it re-implements call_tool.

🤖 Generated with Claude Code

Screenshots

127_2026-11-28_174003.png

**Merge after #37 (branch based on cron-jobs-plugin).** ## Summary Send later became the `scheduled-conversations` plugin on 2026-11-26, but core kept its doors: `/api/scheduled*`, the CLI's `ai-agent later` / `scheduled` / `unschedule`, and the MCP's `schedule_conversation` / `cancel_scheduled` / `browse kind=scheduled`. Gabriel decided (form `cron-scheduled-in-the-cli-and-mcp_x4nk83`) to remove them and route everything through the plugin's own commands, each with `"mcp": true`. Connections bound to a worker can't schedule anymore: only Full does (the owner's own CLI, or an unbound connection). The core keeps the week's budget reader (`op: upcoming`) and the stopped-run card's *Resume at…*. The plugin PR is the companion: gabrielvidal/ai-agent-plugins `scheduled-doors`. ## Key changes - `backend/plugins/schedule_bridge.py`: the router and its `/api/scheduled*` routes are gone. What remains is the provider lookup, `run_op` and `upcoming` (budget). `main.py` no longer mounts it. - `backend/schemas/scheduled.py` deleted, and `frontend/openapi.json` + `src/generated` regenerated (only deletions). - authz: - the `runs.schedule` permission is removed (it had no route left; stored roles drop unknown ids through `catalog.clean`); - the routes are out of `authz/routes.py`; - `matrix.golden.txt` is regenerated; - `worker.read` / `worker.run` lose it; - `mock/rolesCatalog.json` is regenerated. - `workers/bound.py`: the docstring no longer says bound connections schedule. A bound connection has no `plugins.use`, so it gets no plugin actions and no plugin tools. - `cli/ai_agent.py`: `later` / `scheduled` / `unschedule` are gone. They are not aliased: each one now only prints the plugin command that replaces it and exits 2, the way `ai-agent services` does. The scheduling section (`parse_when`) is gone too. - `cli/mcp_tools.py`: - `schedule_conversation`, `cancel_scheduled` and `browse` kind `scheduled` are removed; - the `schedule` group is removed (`GROUPS`, `mcpserver/store.py` defaults, the AI apps page label), and stored settings drop it through the existing intersection; - `WORKER_TOOLS` / `WORKER_KINDS` are trimmed. - `cli/mcp_server.py`: the instructions now name the plugin tools. - **New generic command arg, `"conversation": true`**: - It is validated in `plugins/commands.py`. - `cli/plugin_commands.resolve_conversations` turns any spelling (a session id, a ≥6-char prefix, a conversation id or a viewer link) into a session id before calling the action. This is the old CLI's `resolve()`. - The CLI maps `.` to `$CLAUDE_SESSION_ID`; the MCP refuses `.`. - This is how `add --to .` keeps parity with `ai-agent later … --to .`. - Docs are updated: CLAUDE.md, docs/plugins.md (`conversation` arg, the provider and commands notes), docs/mcp.md, docs/permissions.md, docs/fresh-context.md. `scripts/fresh-context-calibration.py` now reads the plugin's store, plus the `.migrated` copy. - Tests: - `test_worker_bound` checks that a bound connection (run or read) gets a 403 on the plugin's actions and its commands catalogue; - `test_plugin_schedule` checks that the door is gone; - `test_mcp` checks that the old tools are gone and that a bound connection has no `plugin_*` tools and no `browse scheduled`; - `test_plugin_commands` covers the `conversation` arg; - the cli tests cover `.`, a viewer link, a missing session, the MCP prefix resolution and the `.` refusal. ## Key decisions - **`conversation: true` as a generic arg type** rather than a header or plugin-specific code. Core still names no plugin. The plugin can't see the caller's session, but the CLI can. An older hub ignores the key, and the plugin then refuses `.` with a clear message. - **Remove the `runs.schedule` permission**: a route permission with no routes fails `test_every_route_permission_is_in_the_catalog`. The plugin's actions are `ownerOnly` anyway. - **Remove the `schedule` MCP group**: it would be an empty switch. Plugin tools go in `read` / `run`. - **Pointer messages for the old commands** (exit 2, nothing runs). This is not an alias; it follows the `ai-agent services` precedent, so a stale habit in an agent prompt gets a clear way forward. ## Changelog - Changed: Send later from a shell or an AI app is now `ai-agent plugin scheduled-conversations add|ls|show|cancel|start` and the MCP tools `plugin_scheduled-conversations_*`. - Removed: `ai-agent later` / `scheduled` / `unschedule`, the MCP `schedule_conversation` / `cancel_scheduled` / `browse scheduled`, and the *Schedule* tool group in Settings → AI apps. - Removed: a connection bound to a worker can no longer schedule conversations. ## Test notes - Backend, every module under bwrap (one process each): 168/169 pass. `test_typed_plugins::test_records_carry_kind` fails identically on main. - `cli/` with pytest: 117 passed. Vitest: 1104/1105 (`FreshContext` CacheExpiredNotice, already failing on main). `tsc` clean, `npm run build` OK. - Live local hub on :8132 with the plugin 1.1.0 installed from the plugins worktree: - `ai-agent plugin scheduled-conversations add "…" --in 2h`, `--model qwen` (→ pi), `--to .`, `--to <prefix>`, `ls`, `cancel`, `show` (404 after cancel); - the MCP listing shows the five `plugin_scheduled-conversations_*` tools and none of the old three; - `.` over MCP is refused; - a worker-headed call to the plugin action gets a 403; - `/api/scheduled` POST gets a 405, and GET falls through to the SPA shell; - `op: upcoming` still answers for the budget; - Settings → AI apps renders (screenshot). - **Deploy order:** install / upgrade the `scheduled-conversations` plugin to 1.1.0 when this deploys. It adds the `models.read` capability, so it needs re-approval, and every command becomes MCP. Merge the homelab PR at the same time: its cron agents (goal-keeper, tag-tuner, backup-audit) call the new command. - **Not deployed from the EVOX2**: deploy from the Homelab after review. - **Rebased onto `cron-jobs-plugin`** (2026-11-28): the conflicts in CLAUDE.md, `backend/main.py`, `cli/ai_agent.py`, `cli/mcp_server.py`, `cli/mcp_tools.py`, `cli/test_mcp_tools.py`, docs/mcp.md and AiApps.tsx were resolved so that both the cron MCP tools / `browse cron` (#37) and the scheduled ones (this PR) are gone. The MCP groups are now read · run · agents. `frontend/openapi.json`, `src/generated`, `matrix.golden.txt` and `mock/rolesCatalog.json` were regenerated from the rebased tree (only #37's docstrings moved; the golden matrix is unchanged). - After the rebase: backend 2141 passed, 1 failed (`test_typed_plugins::test_records_carry_kind`, which also fails on main); `cli/` 117 passed; `tsc` clean. ### When `hub-mcp-plugin` is rebased onto this (don't merge as is) `ai-agent` `hub-mcp-plugin`: - `cli/ai_agent.py`: drop `cmd_later` / `cmd_scheduled` / `cmd_unschedule` + their parsers (this branch replaced them with `SCHEDULED_MOVED` pointers), and `parse_when` / the `# ── scheduling` section (`_DUR_RE`/`_DUR_S` now sit above `_since`). - `cli/test_ai_agent.py`: the `later` / `scheduled` tests. - `backend/main.py`: the `plugins.schedule_bridge.router` mount; `backend/test_worker_bound.py`'s `test_scheduled_turns_are_passed_on_as_that_worker` / `test_without_the_plugin_nothing_is_scheduled`. - CLAUDE.md's "`/api/scheduled*` stays as a thin door…" paragraph. - That branch gives a worker's CLI a Full mode. Only Full may schedule (it must hold `plugins.use`); Read / Run must not. `ai-agent-plugins` `hub-mcp` (`plugins/hub-mcp/`): - `handlers/hubmcp_tools.py`: - drop the `schedule_conversation` / `cancel_scheduled` tools; - drop `"scheduled"` from `BROWSE_KINDS` / `WORKER_KINDS` and the `_rows` branch; - drop `"schedule"` from `GROUPS`; - drop both from the worker tool set. - `README.md`: the `schedule` table row. - Tests: `test_hub_mcp_plugin.py` (groups `["read","run","schedule","agents"]`, `tools["schedule"]`), `test_hub_mcp_tools.py` (the schedule group / `schedule_conversation` tests), `test_hub_mcp_endpoint.py` (`schedule_conversation` / `cancel_scheduled` assertions). - Its plugin tools path must also call `resolve_conversations` (`conversation` args) if it re-implements `call_tool`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Screenshots ![127_2026-11-28_174003.png](https://git.gabvdl.xyz/attachments/eff923fc-d047-495f-be19-368a782c848c)
gabrielvidal self-assigned this 2026-11-28 17:41:07 +01:00
gabrielvidal added 2 commits 2026-11-28 18:05:50 +01:00
Owner jobs and guests' own scheduled jobs are the cron-jobs live plugin's
(forms move-ai-agent-cron-jobs-into-a-plugin_u0wa6b,
cron-scheduled-in-the-cli-and-mcp_x4nk83). Gone: backend/cron/,
schemas/cron.py, /api/cron*, /api/me/cron*, the cron scheduler thread,
Settings → Cron and the guests' Tâches planifiées pages, `ai-agent cron`
(now a pointer), MCP run_cron_job / set_cron_job / browse cron, the
scheduled-jobs core skill, guestDefaults.cronLimits.

The core keeps thin contracts:
- runs.guest bridge (runs/guestjob.py): a guest's job run as that guest,
  confined by the core from their record; the plugin only names it.
- runs.start's cron stamp → meta.cron.
- delivery of a guest job's result (push, mail, mailHtml) off the stamp.
- « Discuter »: POST /api/cron-runs/discuss.
- runs.cron provider readers (plugins/cron_bridge.py): budget,
  auto-archive, agents catalog, the agents page's Schedule.
- core/cronexpr.py, agents/runconfig.py; context.write create for a new
  agent definition; ui.pages[].unless; setRoute keeps a Settings page
  under /settings/p/.
- carryover.cron_jobs: /data/cron-jobs.json → the plugin's jobs.json,
  cronLimits → limits.json, guests' qwen jobs → sonnet (PR #23's
  decision, superseded).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gabrielvidal force-pushed scheduled-doors from 210bdef985 to 2768941145 2026-11-28 18:05:50 +01:00 Compare
Author
Owner
Merged into `main` as 98ecb63b by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/01a22324-ffa9-78f0-999d-dff18a148ad0.
gabrielvidal closed this pull request 2026-11-28 18:26:04 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gabrielvidal/ai-agent#36