Skip to content
refs
68 lines · 2.3 KBRaw
1export const BUILT_IN_IMAGES = ["base", "node", "python", "go", "rust", "android"] as const;
2export type BuiltInImage = (typeof BUILT_IN_IMAGES)[number];
3
4export const INSTANCE_SIZES = ["lite", "standard-1", "standard-2", "standard-3", "standard-4"] as const;
5export type InstanceSize = (typeof INSTANCE_SIZES)[number];
6
7export const DEFAULT_SIZE: InstanceSize = "standard-2";
8export const DEFAULT_TIMEOUT_MINUTES = 60;
9export const AGENT_TIMEOUT_MINUTES = 20;
10export const MAX_TIMEOUT_MINUTES = 360;
11
12/** A built-in image, optionally pinned to a dated release (`rust@2026-12`). Images deploy with the Worker, so a repo cannot bring its own. */
13export type ImageRef = { readonly kind: "built-in"; readonly name: BuiltInImage; readonly version: string | null };
14
15export interface Step {
16 readonly name: string;
17 readonly run: string;
18}
19
20export interface CacheSpec {
21 readonly key: string;
22 readonly paths: readonly string[];
23}
24
25/** A job that runs a hosted agent on the run's pull request instead of shell steps in a container. */
26export interface AgentTask {
27 readonly handle: string;
28 /** What the job asks the agent, added to the agent's own instructions. Empty asks for the instructions alone. */
29 readonly prompt: string;
30}
31
32export interface Job {
33 readonly name: string;
34 readonly agent: AgentTask | null;
35 readonly image: ImageRef;
36 readonly size: InstanceSize;
37 readonly needs: readonly string[];
38 readonly steps: readonly Step[];
39 readonly environment: string | null;
40 readonly timeoutMinutes: number;
41 readonly cache: CacheSpec | null;
42 readonly artifacts: readonly string[];
43 /** The secrets the job's steps get as environment variables. A job gets no secret it does not name. */
44 readonly secrets: readonly string[];
45}
46
47/** Branch patterns a trigger accepts. An empty list accepts every branch. */
48export interface BranchFilter {
49 readonly branches: readonly string[];
50}
51
52export interface Triggers {
53 readonly push: BranchFilter | null;
54 readonly pullRequest: BranchFilter | null;
55 readonly manual: boolean;
56}
57
58export interface Pipeline {
59 readonly triggers: Triggers;
60 readonly jobs: ReadonlyMap<string, Job>;
61}
62
63export interface ConfigProblem {
64 readonly path: string;
65 readonly message: string;
66}
67
68export type ParseResult = { readonly kind: "valid"; readonly pipeline: Pipeline } | { readonly kind: "invalid"; readonly problems: readonly ConfigProblem[] };