155 lines · 7.1 KB
/**
 * Pricing: the single source of truth for every price on the platform. Pure data, shared by server and UI.
 *
 * Every price is Cloudflare's published cost for the resource times MARKUP. Meters (src/lib/meters.ts),
 * plans (src/lib/plans.ts), prepaid packs, the Stripe setup script and the billing page all derive from here,
 * so changing a cost or the markup updates everything at once.
 */

/** Target price over cost for metered usage and prepaid packs (1.75x, about 43% gross margin). */
export const MARKUP = 1.75;

/** Pro subscription, per month. Its included allowances are sized so even a maxed-out month keeps a margin. */
export const PRO_PRICE_CENTS = 1500;

/** Custom domain add-on, per domain per month (Cloudflare for SaaS bills us per hostname past the first 100). */
export const CUSTOM_DOMAIN_PRICE_CENTS = 500;

/** Most custom domains one account may attach across its Sites. */
export const CUSTOM_DOMAIN_LIMIT = 25;

const SECONDS_PER_HOUR = 3600;
const MICRO_CENTS_PER_DOLLAR = 1e8;

/** Cloudflare list prices (USD), from developers.cloudflare.com pricing pages, Oct 2026. */
export const CLOUDFLARE_COSTS = {
  containerVcpuSecond: 0.00002,
  containerGibSecond: 0.0000025,
  containerDiskGbSecond: 0.00000007,
  r2GbMonth: 0.015,
  workersMillionRequests: 0.3,
  workersMillionCpuMs: 0.02,
  /** Blended AI token cost: the default merge-fix model (glm-5.3-flash, $0.15/M in, $0.50/M out) at 70% input. */
  aiMillionTokens: 0.255,
  /** One platform AI call's fixed overhead, mostly the Clef decision (~2.5k input tokens at $0.24/M). */
  aiCall: 0.0006,
} as const;

export type ContainerSpec = { id: string; vcpu: number; memoryGib: number; diskGb: number };

/** Container instance types used by cloud runners and editors (see wrangler.jsonc). */