jobs.define
Always bad_request: jobs are declared with ctx.jobs.define in an init file or an eval, then workspaces.reload_init (PRT-352).
Params: DefineJobParams
Section titled “Params: DefineJobParams”/** * `jobs.define` params: always `bad_request`, jobs are declared with `ctx.jobs.define` in an init file or an eval * (PRT-352, D-34). */export type DefineJobParams = { job: unknown; name: string; /** Overwrite an existing job of that name. */ replace?: boolean | null; workspaceId: string;};Result: JobView
Section titled “Result: JobView”/** A declared job with its state (PRT-200). */export type JobView = { job: JobDefinition; /** The newest finished run that was not skipped. */ lastRun?: RunInfo | null; name: string; /** The next time of a schedule or a waiting service's restart (Unix ms). */ nextAt?: number | null; /** The running run. */ run?: RunInfo | null; status: JobViewStatus;};Types they use
Section titled “Types they use”/** * A job an init file or eval declares (`ctx.jobs.define`, DMN-990) with its defaults filled in (PRT-200); a job of * code (`run`) has neither `command` nor `prompt`. */export type JobDefinition = { /** `sh -c` command; at most one of `command` and `prompt`. */ command?: string | null; /** Folder of a command run, relative to the workspace folder. */ cwd?: string | null; description?: string | null; enabled: boolean; missed: MissedPolicy; prompt?: JobPrompt | null; restart: RestartPolicy; /** The cron expression of a `schedule` job. */ schedule?: string | null; trigger: JobTrigger;};
/** One run of a job (DMN-330); its id is a job id (`job/<id>`, `jobs.kill`). */export type RunInfo = { /** The command a command run ran (its output is `job/<id>`); `null` for a prompt run. */ command?: string | null; endedAt?: number | null; exitCode?: number | null; id: string; /** The declared job; `null` for a transient run. */ job?: string | null; /** Why it was skipped or could not start. */ reason?: string | null; signal?: number | null; startedAt: number; /** Who asked; `null` for the scheduler and the supervisor. */ startedBy?: CreatedBy | null; status: JobRunStatus; /** A prompt run's thread. */ threadId?: string | null; trigger: RunTrigger; workspaceId: string;};
/** Where a declared job stands (PRT-200). */export type JobViewStatus = | "disabled" | "idle" | "running" /** A service between restarts (`nextAt`). */ | "waiting" /** A service killed through the protocol, or one that ended under `on-failure` without failing. */ | "stopped";
/** What a schedule does with times the daemon missed (DMN-325). */export type MissedPolicy = | "skip" /** One catch-up run, however many times were missed. */ | "run";
/** The prompt a prompt job sends (DMN-992). */export type JobPrompt = { approvalMode?: string | null; /** The thread a run creates is disposable, as `threads.create`'s `ephemeral` (DMN-1403); not with `reuse`. */ ephemeral?: boolean | null; model?: string | null; text: string; thinkingLevel?: string | null; thread: PromptThread; /** The tool list of the thread a run creates, as `threads.create`'s `tools` (DMN-1320); absent: every tool. */ tools?: string[] | null;};
/** When a service starts again after its run ended (DMN-326). */export type RestartPolicy = "always" | "on-failure";
/** When a declared job runs (DMN-990). */export type JobTrigger = /** Only when asked. */ | "manual" /** At the times of its cron `schedule` (DMN-323). */ | "schedule" /** Kept running (DMN-326). */ | "service";
/** * The principal behind a created entity: the user, the agent of a thread, or an MCP client outside omfp, * named by the provenance's `client`. */export type CreatedBy = | { kind: "user"; } | { kind: "thread"; threadId: string; } | { kind: "mcp"; } /** A run of the declared job `job` of the entity's workspace (PRT-209). */ | { job: string; kind: "job"; };
/** How a run ended, or that it still runs (DMN-330). */export type JobRunStatus = | "running" | "succeeded" | "failed" | "killed" /** Not started: the job still ran, or its reused thread was busy (`reason`). */ | "skipped" /** Still running when the daemon stopped. */ | "interrupted";
/** What started a run (DMN-330). */export type RunTrigger = | "manual" | "schedule" | "service" /** A catch-up run for missed times (DMN-325). */ | "missed" /** A transient run of `jobs.start`. */ | "start";
/** Which thread a prompt run sends to (DMN-992). */export type PromptThread = /** A new thread per run. */ | "new" /** The job's own thread, made on first use. */ | "reuse";