Files
simstudioai--sim/apps/sim/lib/billing/constants.ts
T
wehub-resource-sync d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

77 lines
2.4 KiB
TypeScript

/**
* Billing and cost constants shared between client and server code
*/
/**
* Fallback free credits (in dollars) when env var is not set
*/
export const DEFAULT_FREE_CREDITS = 5
/**
* Default per-user minimum limits (in dollars) for paid plans when env vars are absent.
* These are intentionally kept at legacy pricing ($20 Pro, $40 Team) for backward
* compatibility with existing subscribers on the old plan names ('pro', 'team').
* New tiered plans (pro_6000, team_25000, etc.) derive their limits from CREDIT_TIERS.
*/
export const DEFAULT_PRO_TIER_COST_LIMIT = 20
export const DEFAULT_TEAM_TIER_COST_LIMIT = 40
export const DEFAULT_ENTERPRISE_TIER_COST_LIMIT = 200
/**
* Base charge applied to every workflow execution
* This charge is applied regardless of whether the workflow uses AI models
*/
export const BASE_EXECUTION_CHARGE = 0.005
/**
* Fixed cost for search tool invocation (in dollars)
*/
export const SEARCH_TOOL_COST = 0.01
/**
* Default threshold (in dollars) for incremental overage billing
* When unbilled overage reaches this amount, an invoice item is created
*/
export const DEFAULT_OVERAGE_THRESHOLD = 100
/**
* Maximum time to wait on billing coordination row locks before retrying later.
*/
export const BILLING_LOCK_TIMEOUT_MS = 5_000
/**
* Available credit tiers. Each tier maps a credit amount to the underlying dollar cost.
* 1 credit = $0.005, so credits = dollars * 200.
*/
export const CREDIT_TIERS = [
{ credits: 6000, dollars: 25, name: 'Pro' },
{ credits: 25000, dollars: 100, name: 'Max' },
] as const
export type CreditTier = (typeof CREDIT_TIERS)[number]
/**
* Credits granted per dollar of plan spend. A credit is $0.005, so a dollar
* buys 200 — the conversion behind both free-tier and daily-refresh credits.
*/
export const CREDITS_PER_DOLLAR = 200
/**
* Daily refresh rate: 1% of plan cost per day.
* E.g. $25 plan => $0.25/day => 50 credits/day included usage.
*/
export const DAILY_REFRESH_RATE = 0.01
/**
* Annual subscribers pay 15% less than the equivalent monthly plan
* but receive the same included credits. The Stripe annual price is
* `monthlyDollars * 12 * (1 - ANNUAL_DISCOUNT_RATE)`.
*/
export const ANNUAL_DISCOUNT_RATE = 0.15
/**
* Dollar value used as the usage limit when on-demand billing is enabled.
* Effectively unlimited — any limit >= this threshold is treated as uncapped.
*/
export const ON_DEMAND_UNLIMITED = 999999