Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

90 lines · 4.4 KBRaw History
1import type { DiffineryEvent } from "@diffinery/shared";
2import type { RepoDO } from "./repo/RepoDO.js";
3import type { SchedulerDO } from "./scheduler.js";
4import type { ImportContainer } from "./imports/container.js";
5import type { RunnerContainer, SandboxContainer } from "./runner/containers.js";
6import type { MailJob } from "./mail/types.js";
7import type { ProjectDO } from "./agentic/ProjectDO.js";
8
9export interface Env {
10 DB: D1Database;
11 BUCKET: R2Bucket;
12 EVENTS: Queue<DiffineryEvent>;
13 REPO: DurableObjectNamespace<RepoDO>;
14 /** Fires workflow schedules (src/scheduler.ts). */
15 SCHEDULER: DurableObjectNamespace<SchedulerDO>;
16 /** Minutes between scheduler ticks, 1 to 60 (default 5, GitHub's shortest schedule interval). */
17 SCHEDULE_TICK_MINUTES?: string;
18 RUNNER: DurableObjectNamespace<RunnerContainer>;
19 SANDBOX: DurableObjectNamespace<SandboxContainer>;
20 /** One per repository: its agent tasks (agentic/ProjectDO.ts). */
21 PROJECT: DurableObjectNamespace<ProjectDO>;
22 /**
23 * Local development and end-to-end tests only: sandboxes run in one `agent.mjs --sandbox-pool`
24 * process at this URL instead of Cloudflare Containers (which don't run under `wrangler dev`).
25 */
26 SANDBOX_POOL_URL?: string;
27 SANDBOX_POOL_SECRET?: string;
28 /** `off` switches web terminals (agentic/terminals.ts) off for the whole instance; on by default. */
29 TERMINALS?: string;
30 /** Local development and end-to-end tests only: where the model proxy forwards instead of the providers' APIs. */
31 MODEL_UPSTREAM_ANTHROPIC?: string;
32 MODEL_UPSTREAM_OPENAI?: string;
33 MODEL_UPSTREAM_OPENROUTER?: string;
34 RUN_WORKFLOW: Workflow<{ repoId: string; runId: string }>;
35 /** Cloudflare Email Sending. Missing when sending isn't set up; emails are then logged as skipped. */
36 EMAIL?: SendEmail;
37 /** Request rate limits (lib/rate-limit.ts); none in local development. */
38 RL_AUTH?: RateLimit;
39 RL_ANON?: RateLimit;
40 RL_ACCOUNT?: RateLimit;
41 RL_CREATE?: RateLimit;
42 /** Email jobs, sent by the queue consumer in mail/send.ts. */
43 MAIL?: Queue<MailJob>;
44 IMPORT_WORKFLOW: Workflow<{ importId: string }>;
45 /** GitHub imports copy Git data in this container (absent under `wrangler dev`). */
46 IMPORTER?: DurableObjectNamespace<ImportContainer>;
47 /** "external": an import agent started outside the Worker claims the Git transfer (local development and tests). */
48 IMPORT_GIT_AGENT?: string;
49 /** Default per-account quotas (lib/quotas.ts); -1 is unlimited. Site administrators override them per account. */
50 QUOTA_HOSTED_MINUTES?: string;
51 QUOTA_HOSTED_JOBS?: string;
52 QUOTA_SANDBOXES?: string;
53 QUOTA_REPOSITORIES?: string;
54 /** Largest source repository an import will take, in KB (GitHub `size`); default 10 GB. */
55 IMPORT_MAX_REPO_KB?: string;
56 /** Optional GitHub OAuth app, for linking an account through the web flow instead of a gist. */
57 GITHUB_OAUTH_CLIENT_ID?: string;
58 GITHUB_OAUTH_CLIENT_SECRET?: string;
59
60 /** Canonical origin, e.g. https://diffinery.com */
61 PUBLIC_URL: string;
62 /** Sender address for every email, e.g. notifications@diffinery.com. */
63 MAIL_FROM?: string;
64 /** Comma-separated emails or logins that become site admins on first sign-in. */
65 BOOTSTRAP_ADMINS: string;
66 /** e.g. codician.cloudflareaccess.com — empty disables Access verification. */
67 ACCESS_TEAM_DOMAIN: string;
68 /** Access application audience tag. */
69 ACCESS_AUD: string;
70 /** Artifact storage per repository in bytes (live artifacts plus uploads in progress); default 10 GiB. */
71 ARTIFACT_QUOTA_BYTES?: string;
72 /** Local development only: act as this email when Access is not configured. */
73 DEV_AUTH?: string;
74 /**
75 * "open": anyone can create an account at /signup by confirming an emailed code (auth/signup.ts).
76 * Anything else, or unset, keeps the instance invite-only.
77 */
78 SIGNUP?: string;
79 /** Cloudflare Turnstile widget on the sign-up page; open sign-up needs it and TURNSTILE_SECRET outside local development. */
80 TURNSTILE_SITE_KEY?: string;
81
82 /** Secret: base64 32 bytes; root key for envelope encryption of secrets. */
83 MASTER_KEY?: string;
84 /** Secret: ES256 private JWK (JSON) used to sign OIDC tokens for jobs. */
85 OIDC_PRIVATE_KEY?: string;
86 /** Secret: Cloudflare Turnstile secret key, to check the sign-up page's widget (siteverify). */
87 TURNSTILE_SECRET?: string;
88 /** Optional GitHub Enterprise host (e.g. github.example.com) the importer may download release assets from. */
89 IMPORT_GHE_HOST?: string;
90}