import type { AgentTask, InstanceSize, Step } from "../config/pipeline.ts"; import type { Outcome } from "../runs/run.ts"; /** * Everything a job runner needs to run one job. It holds no secret, because the Workflow stores it: the runner asks * RunHub for the job's secrets and fetches its own short-lived clone token. */ export interface JobSpec { readonly runId: string; readonly job: string; readonly repo: string; readonly sha: string; readonly ref: string; readonly image: string; readonly size: InstanceSize; readonly steps: readonly Step[]; readonly timeoutMinutes: number; /** Set for a job that runs a hosted agent on the server instead of steps in a container. */ readonly agent: AgentTask | null; } export type JobResult = | { readonly outcome: Outcome; readonly exitCode: number | null; readonly failedStep: number | null; readonly reason: string | null } | { readonly outcome: "cancelled"; readonly exitCode: null; readonly failedStep: null; readonly reason: string }; export function failedJob(reason: string): JobResult { return { outcome: "failed", exitCode: null, failedStep: null, reason }; } /** How an agent job started: a session to wait for, or an end with the reason. */ export type AgentStart = { readonly kind: "started"; readonly session: string } | { readonly kind: "ended"; readonly result: JobResult }; /** Where a started agent job stands. `done` carries the job result once the agent's run ended. */ export type AgentProgress = { readonly done: false } | { readonly done: true; readonly result: JobResult; readonly log: string };