Expand description
HTTP handlers for jobs (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.1) and the persistent cron scheduler under them.
Routes (all auth-gated via X-AuthKey), under /agentmux/jobs, and the
same under /agentmux/cron, kept as aliases for one release:
POST /agentmux/jobs — create a job: a job definition
(jobVersion 1), or the cron shape
the Schedule tool sends
DELETE /agentmux/jobs/:id — delete a job
GET /agentmux/jobs — list all jobs, each with its last run
PATCH /agentmux/jobs/:id — pause / resume, or edit its definition
GET /agentmux/jobs/:id/runs — a job’s runs, newest first
POST /agentmux/jobs/:id/run — run it now (a manual run)
POST /agentmux/jobs/runs/:run_id/report — a run’s own verdict
The run routes are the run ledger’s (§3.2, §3.3 MuxAPI). Who may do what
is §7: Who.
Structs§
- Cron
Create Request - Cron
JobView - Cron
Report Request - Cron
Runs Query - Cron
Summary - Swarm-pane row shape for one cron job (SPEC_SWARM_LONG_RUNNING_PROCESS_
ROWS_2026_07_20 Phase 2) —
CronJobViewplus thecreated_byagent’s resolvedblock_id, so the frontend can group it under that agent’s row the same wayShellSummarydoes for the Shell bucket.
Enums§
- Who 🔒
- Who is asking, for the rules of §7. The operator is the app’s own
client, which carries no agent token (
Caller::Unattributed).
Constants§
- CONTAINER_
HOST_ 🔒JOB - What a container agent is told for a job whose runs start things on the host (§7): the only jobs it can’t have, as it can’t start or run anything there. It says why and what to do instead.
- FIXED_
FIELDS 🔒 - A job’s fields an edit can’t change: srv sets them.
- REPORT_
LABEL_ 🔒MAX - REPORT_
LINKS_ 🔒MAX - The most links one report keeps, and the longest url and label.
- REPORT_
URL_ 🔒MAX - RUNS_
MAX 🔒 - The most runs one history call returns.
- SPAWN_
FROM_ 🔒THE_ APP - What a spawn job asks of anyone who isn’t the app’s own controls: it starts agents that spend until someone stops them.
Functions§
- bad_
request 🔒 - create_
job 🔒 - Create a job from a definition or the cron shape.
origin.from_host: the operator’s decision, from the host route (handle_host_jobs) or the app’s own proven window (jobs.save): the only way to create a job that starts workers, to raise a cap, or to confirm a job on a provider that reports no cost. A definition that names a template is made from it (jobs::from_template). - forbidden 🔒
- handle_
cron_ 🔒create - handle_
cron_ 🔒delete - handle_
cron_ 🔒list - handle_
cron_ 🔒patch PATCH:{"action": "pause" | "resume"}, or an edit: definition fields (§5.1) laid over the job’s definition, which is then read as a create’s is. The 15-minute minimum applies only when the edit sets the trigger or the action, so a job kept as it was isn’t refused for a rule newer than it.- handle_
cron_ 🔒report - handle_
cron_ 🔒run_ now - handle_
cron_ 🔒runs - handle_
host_ 🔒jobs POST /api/v1/host/jobs: what the operator decides in the Jobs tab that starts agents, relayed by the host with its own token.actioniscreate(definition: a job definition, aspawnjob included),update(id,fields: an edit, which may raise the job’s caps) orrun_now(id).confirm_no_cost: trueconfirms a job whose agent’s provider reports no cost (§5.3).- inject_
here_ 🔒following_ runs - Deliver on this instance (
jekt_files::inject_here). A delivery another instance forwarded here whoserequest_idis a run another channel fired is followed here, before the answer goes back (#1988). - job_
for_ 🔒change - The store and the job, or the response refusing the change: no store, no
such job, or a caller
may_change_jobrefuses. - jobs_
store 🔒 - Where jobs are (
db_jobs): the shared store, beside thedb_cron_jobsit replaced, or the work store of atask devbuild, which keeps its own (crate::registry::work_store). Every job read and write goes through here, so the store can move in one place. - jobs_
store_ 🔒or_ 503 jobs_store, or the answer when there is none.- ledger_
or_ 🔒503 - ledger_
store 🔒 - Where the run ledger is (
db_job_runs): the identity store, or the work store of atask devbuild, which keeps its own (crate::registry::work_store). - legacy_
definition 🔒 - The definition the cron shape describes: a
crontrigger intzand amessageaction to the target. - may_
act_ 🔒on - Whether
callermay act onjob(Run now): the operator (the app’s own client, which carries no agent token) or the agent that created or owns it (jobs spec §7). By UID when the job recorded one, else by the creator’s name against the caller’s agent slug. - may_
change_ 🔒job - Whether
callermay pause, resume or deletejob. An agent (a request carrying its token) may change only a job it created or owns, or one aimed at it; everyone else, the UI included, may change any job. Unattributed requests can’t be refused: at the same-user boundary one that omits its token looks like the UI (caller.rs). This stops an agent changing another agent’s job by mistake, not a determined one. A job with no recorded creator UID (created before identity M4c-1, or unattributed) is open to any caller. Editing the definition is narrower:may_edit_job. - may_
define 🔒 - Whether
whomay define a job likedef(§7): the operator any job; an agent, container or not, amessageortaskjob it owns; a native agent a Drone job too, which a container agent can’t have as its runs start on the host. Aspawnjob needs the operator’s approval once (the spawn consent rule, made at creation since its runs are unattended), which has no flow yet, so an agent can’t create one.current_owneris the job’s owner on an edit. - may_
edit_ 🔒job - Whether
callermay editjob’s definition: the operator, or the agent that created or owns it (§7). The agent a job messages may pause it, not rewrite it. A job with no creator (the operator’s, or one from before creators were recorded) is the operator’s to edit. - next_
fire 🔒 - The job’s next fire (its trigger’s next slot, in its time zone) as an
ISO-8601 UTC string;
Nonewhen disabled, when its trigger has no next slot, or when it doesn’t read. - patch_
job 🔒 handle_cron_patch’s work.origin.from_host: the operator’s edit, from the host route or the app’s own proven window, which may raise caps, confirm a job on a provider that reports no cost, and change a spawn job.- publish_
cron_ 🔒changed - report_
links 🔒 - The links a report keeps: https URLs, given as strings or as
{label, url}, within the length bounds, at most five. Anything else is dropped: the ledger shows them to other agents and the UI. - run_
job_ 🔒now - Run
jobnow and say how it went. - runnable_
yet 🔒 - What this build can’t run yet, though the definition is valid. Refused
rather than stored and silently ignored:
max_turnsis a flag at the CLI’s launch, which a message to a running agent can’t set. - set_
enabled 🔒 - Pause or resume job
id. - starts_
on_ 🔒the_ host - Whether a job of this
action_kindis one a container agent can’t run now or have scheduled: a spawn or Drone job starts things on the host. - target_
of 🔒 - A message’s
toas the job’s target(name, uid): a UID names that agent; anything else is kept as a name, never resolved here (identity spec §5.4: the job then fires by name, counted). - to_
summary 🔒 - to_view 🔒
- who 🔒
- work_
store 🔒 - Where tasks are filed (the work queue and its cards): the identity store, or
the work store of a
task devbuild, which keeps its own. - writer_
of 🔒 - Who stands behind a definition this request writes, as the request proves it: the app’s own window, an agent by its
token, or no one (a caller nothing identified, which the rest of this file treats as the operator but cannot prove is).
A scheduled fire of the job is proven only as far as this goes (
CronJob::fire_proof).
Type Aliases§
- Answer 🔒