src/env.ts
102 lines and 0 functions in DrDustinEdwards/capsid, at commit daa875b on 2026-10-24. This file on GitHub.
Functions
None: it only declares types or values.
Imports
It imports no other module of this repo. Imported by src/access-login.ts, src/access-sync.ts, src/approval-executor.ts, src/auto-merge-policy.ts, src/auto-merge-tick.ts, src/backup.ts, src/bench.ts, src/bing-webmaster.ts, src/complete-ci.ts, src/controls-perform.ts, src/controls-plan.ts, src/controls-token.ts, src/controls.ts, src/dcr.ts, src/deploy-outcomes.ts, src/digest.ts, src/doc-index.ts, src/fail-exemption.ts, src/gate-policy.ts, src/github/actions.ts, src/github/client.ts, src/github/contents.ts, src/github/dispatch.ts, src/github/pr-files.ts, src/github/prune.ts, src/github/refs.ts, src/github/releases.ts, src/github/search.ts, src/health.ts, src/inbox.ts, src/index.ts, src/job-breaker.ts, src/job-fact-check.ts, src/job-outcomes.ts, src/job-overlaps.ts, src/jobs-begin.ts, src/jobs-claim.ts, src/jobs-edit.ts, src/jobs-holder.ts, src/jobs-mirror.ts, src/jobs-park.ts, src/jobs-seat.ts, src/jobs-transition.ts, src/live-checks.ts, src/maintenance-branches.ts, src/maintenance-deploys.ts, src/maintenance-prs.ts, src/maintenance-releases.ts, src/maintenance.ts, src/manual-steps.ts, src/mcp-handler.ts, src/merge-resume.ts, src/merge-safety.ts, src/merge-units.ts, src/model-drift.ts, src/model-routing-pr.ts, src/namespace-delete-token.ts, src/namespace-delete.ts, src/operator-key.ts, src/ops-cloudflare-config.ts, src/ops-cloudflare.ts, src/ops-feed.ts, src/ops-hooks.ts, src/ops-packages.ts, src/ops-snapshot.ts, src/outcome-prs.ts, src/overnight-plan.ts, src/overnight.ts, src/policy-sign.ts, src/portal-actions.ts, src/portal-app.ts, src/portal-auth.ts, src/portal-claims.ts, src/portal-convergence.ts, src/portal-library.ts, src/portal-maintenance.ts, src/portal-overnight.ts, src/portal-packages.ts, src/portal-stale.ts, src/portal-trends.ts, src/pr-approvals.ts, src/public-code.ts, src/public-data.ts, src/public-stats.ts, src/push.ts, src/review.ts, src/routes.ts, src/routine-fire.ts, src/search-console.ts, src/secret-presence.ts, src/server.ts, src/shadow.ts, src/shared-code.ts, src/signed-docs.ts, src/signed-requests.ts, src/site-check.ts, src/site-convergence.ts, src/site-key.ts, src/site-operator.ts, src/site-repair.ts, src/site-reports.ts, src/site-watch.ts, src/skills-refresh.ts, src/stale-canon.ts, src/stale-jobs.ts, src/status.ts, src/supersede.ts, src/task-runs.ts, src/tick.ts, src/tools/docs.ts, src/trends.ts, src/unmapped-repos.ts, src/watcher-findings.ts, src/watcher-gather.ts, src/watcher.ts, src/whats-next.ts, src/workers-builds.ts.
Source
import type { OAuthHelpers } from "@cloudflare/workers-oauth-provider";
// The bindings and vars wrangler.jsonc.example declares (DB, APP_KV, OAUTH_KV, MEDIA,
// AI_SEARCH, GITHUB_APP_CLIENT_ID) come from worker-configuration.d.ts, which
// `npm run types` generates with `wrangler types` and test/env-types.test.ts holds to
// the example in both directions. What is written here is what the config cannot say:
// secrets, the OAuth provider the library injects, the optional assets binding, and the
// build stamps. GITHUB_APP_CLIENT_ID is generated as the literal pinned id; it is widened to string
// here so tests and the deploy check can hold other values.
export interface Env extends Omit<GeneratedEnv, "GITHUB_APP_CLIENT_ID"> {
OAUTH_PROVIDER: OAuthHelpers;
OPERATOR_KEY_HASH: string;
COOKIE_ENCRYPTION_KEY: string;
// The MCP and Portal logins' upstream: Cloudflare Access for SaaS (OIDC),
// src/access-login.ts. Unset, the sign-in is closed; ADMIN_EMAIL unset admits nobody,
// co-owners included.
ACCESS_TEAM_DOMAIN?: string;
ACCESS_SAAS_CLIENT_ID?: string;
ACCESS_SAAS_CLIENT_SECRET?: string;
ADMIN_EMAIL?: string;
// Co-owners: comma-separated emails admitted exactly like ADMIN_EMAIL (src/auth.ts
// isAdminEmail), each recorded under its own verified email, `access:<email>`. A
// co-owner cannot change ADMIN_EMAIL or this list: both are set only in Cloudflare.
// Optional; unset or empty means no co-owners. Ignored while ADMIN_EMAIL is unset.
CO_OWNER_EMAILS?: string;
// The Watch Floor's Cloudflare read (src/ops-cloudflare.ts): a read-only API token
// with Account Analytics Read and Workers Scripts Read, and the account it reads.
// Unset, the deploy and error columns show no data and say why.
CF_OPS_TOKEN?: string;
CF_ACCOUNT_ID?: string;
// Capsid Admin's capsid_admin_set_site_key (src/site-key.ts): a token with Workers Scripts Edit, to
// set a site's key as a secret on its Worker and on Carrel. Apart from CF_OPS_TOKEN
// because it writes. Unset, capsid_admin_set_site_key mints nothing and says why.
CF_SECRETS_TOKEN?: string;
// The Access sync's write token (src/access-sync.ts): Access: Groups Write, Access: Users
// Read and Zero Trust: Seats Write on this account only. Capsid is its only holder
// (Dustin, 2026-10-09). Unset, POST /ops/access-sync answers 503 and calls nothing.
CF_ACCESS_SYNC_TOKEN?: string;
// Google Search Console's read (src/search-console.ts): a service account's whole JSON
// key, the account added as a Full user on each site's property. Unset,
// capsid_inspect_repo action search reads nothing and says why.
GSC_SERVICE_ACCOUNT_KEY?: string;
// Bing Webmaster Tools' read (src/bing-webmaster.ts): the API key from Bing Webmaster
// Tools' Settings, API access. Bing gives it no narrower scope, so the module calls only
// Get methods. Unset, capsid_inspect_repo action bing reads nothing and says why.
BING_WEBMASTER_API_KEY?: string;
// The dashboard app's built files (dashboard/dist), served under /portal/ only
// after the Portal's gate. Absent where no assets are configured.
ASSETS?: Fetcher;
// GitHub App. No pinned installation id: resolved per owner and repo.
GITHUB_APP_CLIENT_ID: string;
GITHUB_APP_PRIVATE_KEY: string;
// Stamped by scripts/deploy.mjs at deploy time, not committed.
BUILD_SHA?: string;
BUILD_DIRTY?: string;
BUILT_AT?: string;
// Root secret the job and policy signing key (src/signed-docs.ts) and the backup
// credential key (src/signed-requests.ts) are derived from. Named for the improve
// loop that first used it; renaming a Worker secret is a step only the seat can take.
IMPROVE_SCORE_SECRET?: string;
// The capsid-bench repo's signing key (src/bench.ts), the same value as its BENCH_KEY secret.
BENCH_SECRET?: string;
// The backup credential mint (src/signed-requests.ts): the temp-access-credentials
// token and the parent it derives from. Omitted from RepoEnv.
R2_TEMP_CRED_TOKEN?: string;
R2_ACCOUNT_ID?: string;
R2_BACKUP_PARENT_ACCESS_KEY_ID?: string;
// The watcher's red and green mail about a site's health (src/site-watch.ts): a
// send_email binding, the address it sends to and the one it sends from, all optional and set by the seat
// in wrangler.jsonc (docs/portal.md, "Site repairs"). Unset, nothing is mailed, the
// finding still opens in Incidents, and each pass says the mail was not sent.
// Each site's operator token is a secret named by that site's configuration
// (<NAME>_OPERATOR_TOKEN, src/site-operator.ts), read by name and never declared here.
// The per-connector DCR callbacks (src/dcr.ts): Gemini's and ChatGPT's exact
// redirect URIs, comma separated, set by the seat in wrangler.jsonc. Unset, only the
// fixed Grok and ChatGPT callbacks can register.
DCR_REDIRECT_URIS?: string;
EMAIL?: SendEmail;
// The daily digest (src/digest.ts) sends only when this var is "on", which the seat sets
// once Dustin has turned Email Routing on for the domain and verified ALERT_EMAIL.
EMAIL_ROUTING?: string;
// Phone alerts (src/push.ts, src/web-push.ts): the VAPID key that signs each Web Push,
// a P-256 private key as a JWK, put by scripts/vapid-keys.mjs. Unset, no alert is sent
// and the Portal's Settings says why.
VAPID_PRIVATE_KEY?: string;
ALERT_EMAIL?: string;
ALERT_FROM?: string;
}
// What the GitHub modules (src/github/) are handed: everything except the credentials
// that mint backup read access, the Cloudflare read token (it can read Worker code), the
// Access sync's write token and the key that signs phone alerts.
export type RepoEnv = Omit<Env, "R2_TEMP_CRED_TOKEN" | "R2_BACKUP_PARENT_ACCESS_KEY_ID" | "CF_OPS_TOKEN" | "CF_ACCESS_SYNC_TOKEN" | "VAPID_PRIVATE_KEY">;
// A grant's props: the email Access verified at sign-in. Grants issued before the move
// to Access carry { id, login, name } from GitHub instead, fail the per-request email
// check, and the client signs in again once.
export interface Props extends Record<string, unknown> {
email: string;
// When Access verified that email, in milliseconds since the epoch, set at /callback.
// The admin server's step-up reads it (src/scope.ts STEP_UP): a risky admin action
// needs a sign-in this recent. A grant made before it was recorded carries none and
// reads as stale.
signed_in_at?: number;
}