Skip to content
refs
History
34 lines · 1.6 KBRaw
1import type { AgentTask, InstanceSize, Step } from "../config/pipeline.ts";
2import type { Outcome } from "../runs/run.ts";
3
4/**
5 * Everything a job runner needs to run one job. It holds no secret, because the Workflow stores it: the runner asks
6 * RunHub for the job's secrets and fetches its own short-lived clone token.
7 */
8export interface JobSpec {
9 readonly runId: string;
10 readonly job: string;
11 readonly repo: string;
12 readonly sha: string;
13 readonly ref: string;
14 readonly image: string;
15 readonly size: InstanceSize;
16 readonly steps: readonly Step[];
17 readonly timeoutMinutes: number;
18 /** Set for a job that runs a hosted agent on the server instead of steps in a container. */
19 readonly agent: AgentTask | null;
20}
21
22export type JobResult =
23 | { readonly outcome: Outcome; readonly exitCode: number | null; readonly failedStep: number | null; readonly reason: string | null }
24 | { readonly outcome: "cancelled"; readonly exitCode: null; readonly failedStep: null; readonly reason: string };
25
26export function failedJob(reason: string): JobResult {
27 return { outcome: "failed", exitCode: null, failedStep: null, reason };
28}
29
30/** How an agent job started: a session to wait for, or an end with the reason. */
31export type AgentStart = { readonly kind: "started"; readonly session: string } | { readonly kind: "ended"; readonly result: JobResult };
32
33/** Where a started agent job stands. `done` carries the job result once the agent's run ended. */
34export type AgentProgress = { readonly done: false } | { readonly done: true; readonly result: JobResult; readonly log: string };