Server-side execution engine for the matrx scheduling spine (sch_* tables): scanner, claim, runner, cron parser, HTTP API.
Actively maintained. Last release 7 days ago. A safe choice.
pip install matrx-schedulermatrx-scheduler
Server-side execution engine for the matrx scheduling spine (sch_* tables in
Supabase). Provides:
- a scanner loop that claims due tasks atomically,
- a runner that drives the host's agent_runner / tool_runner,
- an authoritative cron parser + next-due computation,
- and (since 0.3) an HTTP API surface (FastAPI) for task / trigger / run CRUD, manual fires, scanner status, and cron preview.
Any host application (aidream is the reference) wires it up via configure()
and either runs the scanner directly, mounts the HTTP routes, or both.
What it does (under the hood)
- Polls
sch_taskfor rows wherenext_due_at <= now()and the host surface is insurfaces[](or'any'). - Atomically claims a candidate by inserting a
sch_runwithclaim_tokenandclaim_expires_at(the lease). - Drives the matrx-ai agent runner (host-injected) against the claimed task,
or the host's tool_runner for
kind='tool'. - Writes back results (
status,result_summary,output_ref, etc.). - Recomputes the next fire time on recurring triggers; the DB cascade
updates
sch_task.next_due_atautomatically.
Capability-within, injection-without
matrx-scheduler doesn't import from a host app. It exposes a configure()
function the host calls at startup, passing in:
supabase_client— service-role client used by the SCANNER to read sch_task across users and update lease state.surface— the string this host identifies as insch_task.surfaces[](e.g.'server'for aidream,'desktop'for matrx-local).agent_runner— callable that runs an agent (kind='agent' tasks).tool_runner— optional callable for kind='tool' tasks. Hosts that don't claim tool tasks (e.g. aidream itself) leave this unset.user_supabase_factory— optional callable(user_jwt) -> AsyncClientused by the HTTP routes to build per-request user-scoped clients. If not provided, the package falls back to an env-based factory keyed onSUPABASE_MATRIX_URL+SUPABASE_MATRIX_PUBLISHABLE_KEY.get_app_context, , , — see the docstring.