Skip to content

An open-source, faster Devin alternative

TypeScript

Free-tier paywall: upgrade to Pro ($200), no top-ups

Mohamed Habib via Computer8bb936b5e623
diff --git a/cli/README.md b/cli/README.md
index dd22b5c5..55ecba07 100644
--- a/cli/README.md
+++ b/cli/README.md
@@ -152,10 +152,11 @@ remaining balance after each run (a `credits` block under `--json`, with
```bash
opencomputer billing
-opencomputer upgrade pro # prints the checkout link for Pro ($20/mo, $200 credits)
+opencomputer upgrade # prints the checkout link for Pro ($200/mo)
```
When credits are exhausted every command fails with HTTP `402` and a structured
`insufficient_credits` error whose `hint` and `details.upgradeUrl` point at
-checkout. Agents driving the CLI should stop, relay that link to the user, and
-resume once billing is sorted rather than retrying.
+checkout for Pro ($200/mo). Pro also lets the user connect their own Claude or
+ChatGPT subscription. Agents driving the CLI should stop, relay that link to
+the user, and resume once billing is sorted rather than retrying.
diff --git a/cli/src/api.ts b/cli/src/api.ts
index 2b1bf99d..4d2d3b2d 100644
--- a/cli/src/api.ts
+++ b/cli/src/api.ts
@@ -471,7 +471,7 @@ export interface CreditsStatus {
isHalted: boolean;
billingUrl: string;
upgradeUrl: string;
- plans: Array<{ id: "pro" | "max"; priceUsd: number; creditsUsd: number }>;
+ plans: Array<{ id: "pro" | "max"; name?: string; priceUsd: number; creditsUsd: number }>;
}
function errorMessage(body: unknown, status: number): string {
diff --git a/cli/src/billing.test.ts b/cli/src/billing.test.ts
index 8642f5ac..13116907 100644
--- a/cli/src/billing.test.ts
+++ b/cli/src/billing.test.ts
@@ -16,24 +16,34 @@ const base: CreditsStatus = {
isLow: false,
isHalted: false,
billingUrl: "https://app.opencomputer.dev/billing",
- upgradeUrl: "https://app.opencomputer.dev/billing?plan=pro",
- plans: [
- { id: "pro", priceUsd: 20, creditsUsd: 200 },
- { id: "max", priceUsd: 200, creditsUsd: 2000 },
- ],
+ upgradeUrl: "https://app.opencomputer.dev/billing?plan=max",
+ plans: [{ id: "max", name: "Pro", priceUsd: 200, creditsUsd: 2000 }],
};
test("run footer nudges free orgs, warns when low, and is silent for healthy paid plans", () => {
assert.match(creditsFooter(base), /\$3\.40 free credits left/);
- assert.match(creditsFooter(base), /plan=pro/);
+ assert.match(creditsFooter(base), /plan=max/);
+ assert.match(creditsFooter(base), /Pro \(\$200\/mo\)/);
assert.match(
creditsFooter({ ...base, creditsRemainingCents: 90, isLow: true }),
/running low/,
);
assert.match(
creditsFooter({ ...base, creditsRemainingCents: 0, isHalted: true }),
- /exhausted/,
+ /You've used your free credits\. Upgrade to Pro \(\$200\/mo\)/,
);
+ for (const status of [
+ base,
+ { ...base, isLow: true },
+ { ...base, isHalted: true },
+ { ...base, usagePlan: "pro" as const, isHalted: true },
+ ]) {
+ assert.doesNotMatch(creditsFooter(status), /\$20\/mo|top.?up|plan=pro/i);
+ }
+ // $200 Pro orgs are never offered an upgrade or a top-up.
+ const maxHalted = creditsFooter({ ...base, usagePlan: "max", isHalted: true });
+ assert.match(maxHalted, /renew/);
+ assert.doesNotMatch(maxHalted, /upgrade|top.?up/i);
assert.equal(
creditsFooter({ ...base, usagePlan: "pro", creditsRemainingCents: 15_000 }),
"",
@@ -55,11 +65,23 @@ test("json credits block carries a machine-readable warning", () => {
assert.equal(creditsSummary(null), undefined);
});
-test("billing table lists plans and marks the current one", () => {
- const text = formatBilling({ ...base, usagePlan: "pro" });
- assert.match(text, /Pro \(\$20\/mo\)/);
- assert.match(text, /pro\s+\$20\/mo.*\(current\)/);
- assert.match(text, /max\s+\$200\/mo — \$2,000/);
+test("billing table lists only Pro ($200) unless the org is on legacy Pro", () => {
+ const free = formatBilling(base);
+ assert.match(free, /Plan\s+Free/);
+ assert.match(free, /Pro\s+\$200\/mo — \$2,000/);
+ assert.doesNotMatch(free, /\$20\/mo|top.?up|Max \(/i);
+
+ const legacy = formatBilling({
+ ...base,
+ usagePlan: "pro",
+ plans: [
+ { id: "pro", name: "Pro (legacy)", priceUsd: 20, creditsUsd: 200 },
+ { id: "max", name: "Pro", priceUsd: 200, creditsUsd: 2000 },
+ ],
+ });
+ assert.match(legacy, /Plan\s+Pro \(legacy, \$20\/mo\)/);
+ assert.match(legacy, /Pro \(legacy\)\s+\$20\/mo.*\(current\)/);
+ assert.match(legacy, /Upgrade:\s+\S+plan=max/);
});
test("upgrade url falls back to the API origin when no credit status is available", () => {
@@ -67,5 +89,5 @@ test("upgrade url falls back to the API origin when no credit status is availabl
upgradeUrlFor(null, "https://app.opencomputer.dev/", "max"),
"https://app.opencomputer.dev/billing?plan=max",
);
- assert.equal(upgradeUrlFor(base, "https://x", "pro"), base.upgradeUrl);
+ assert.equal(upgradeUrlFor(base, "https://x"), base.upgradeUrl);
});
diff --git a/cli/src/billing.ts b/cli/src/billing.ts
index f47321fa..d97e9a59 100644
--- a/cli/src/billing.ts
+++ b/cli/src/billing.ts
@@ -4,10 +4,20 @@ export function formatUsd(cents: number): string {
return `$${(cents / 100).toFixed(2)}`;
}
+// The plan on sale is Pro ($200/mo); its billing id stays `max`. The old $20
+// plan (id `pro`) is shown as "Pro (legacy)" only to orgs already on it.
+export const UPGRADE_PLAN = "max" as const;
+export const UPGRADE_PLAN_LABEL = "Pro ($200/mo)";
+
const PLAN_LABEL: Record<CreditsStatus["usagePlan"], string> = {
- base: "Usage (prepaid)",
- pro: "Pro ($20/mo)",
- max: "Max ($200/mo)",
+ base: "Free",
+ pro: "Pro (legacy, $20/mo)",
+ max: UPGRADE_PLAN_LABEL,
+};
+
+const PLAN_NAME: Record<"pro" | "max", string> = {
+ pro: "Pro (legacy)",
+ max: "Pro",
};
/** Human-readable summary for `opencomputer billing`. */
@@ -21,12 +31,13 @@ export function formatBilling(status: CreditsStatus): string {
"Plans:",
...status.plans.map(
(p) =>
- ` ${p.id.padEnd(5)} $${p.priceUsd}/mo — $${p.creditsUsd.toLocaleString("en-US")} in credits every month` +
+ ` ${(p.name ?? PLAN_NAME[p.id]).padEnd(12)} $${p.priceUsd}/mo — $${p.creditsUsd.toLocaleString("en-US")} in credits every month` +
(p.id === status.usagePlan ? " (current)" : ""),
),
"",
- `Upgrade: ${status.upgradeUrl}`,
- `Top up: ${status.billingUrl}`,
+ ...(status.usagePlan === UPGRADE_PLAN
+ ? [`Billing: ${status.billingUrl}`]
+ : [`Upgrade: ${status.upgradeUrl}`]),
];
return `${lines.join("\n")}\n`;
}
@@ -38,16 +49,22 @@ export function formatBilling(status: CreditsStatus): string {
export function creditsFooter(status: CreditsStatus | null): string {
if (!status) return "";
const left = formatUsd(status.creditsRemainingCents);
+ const onPro = status.usagePlan === UPGRADE_PLAN;
if (status.isHalted) {
- return `\nCredits exhausted — upgrade to keep running: ${status.upgradeUrl}\n`;
- }
- if (status.isLow) {
+ if (onPro) {
+ return `\nThis month's Pro credits are used up; they renew next billing period: ${status.billingUrl}\n`;
+ }
return (
- `\n${left} credits left (running low). Pro is $20/mo for $200 in credits: ${status.upgradeUrl}\n`
+ `\n${status.usagePlan === "base" ? "You've used your free credits." : "You've used this month's credits."} ` +
+ `Upgrade to ${UPGRADE_PLAN_LABEL} to keep going, or to use your own Claude or ChatGPT subscription: ${status.upgradeUrl}\n`
);
}
+ if (status.isLow) {
+ if (onPro) return `\n${left} credits left this month (running low).\n`;
+ return `\n${left} credits left (running low). Upgrade to ${UPGRADE_PLAN_LABEL}: ${status.upgradeUrl}\n`;
+ }
if (status.usagePlan === "base") {
- return `\n${left} free credits left · upgrade to Pro ($20/mo, $200 credits): ${status.upgradeUrl}\n`;
+ return `\n${left} free credits left · upgrade to ${UPGRADE_PLAN_LABEL}: ${status.upgradeUrl}\n`;
}
return "";
}
@@ -91,7 +108,7 @@ export async function fetchCredits(
export function upgradeUrlFor(
status: CreditsStatus | null,
apiUrl: string,
- plan: "pro" | "max",
+ plan: typeof UPGRADE_PLAN = UPGRADE_PLAN,
): string {
const base = status?.billingUrl ?? `${apiUrl.replace(/\/$/, "")}/billing`;
return `${base}?plan=${plan}`;
diff --git a/cli/src/commands.ts b/cli/src/commands.ts
index 534b0f7c..cf170647 100644
--- a/cli/src/commands.ts
+++ b/cli/src/commands.ts
@@ -19,6 +19,7 @@ import {
fetchCredits,
formatBilling,
upgradeUrlFor,
+ UPGRADE_PLAN,
} from "./billing.js";
import { codexLogin } from "./codex-oauth.js";
import { resolveConfig } from "./config.js";
@@ -1269,20 +1270,25 @@ export async function runCommand(
}
if (command === "upgrade") {
- const plan = args.shift() ?? "pro";
- if (plan !== "pro" && plan !== "max") {
- throw new Error("Usage: opencomputer upgrade [pro|max]");
+ // `pro` and `max` are both accepted for older scripts; both open the one
+ // plan on sale, Pro ($200/mo), whose billing id is `max`.
+ const requested = args.shift() ?? "pro";
+ if (requested !== "pro" && requested !== "max") {
+ throw new Error("Usage: opencomputer upgrade [pro]");
}
if (args.length) throw new Error(`Unexpected argument: ${args[0]}`);
+ const plan = UPGRADE_PLAN;
const status = await fetchCredits(client);
const url = upgradeUrlFor(status, config.apiUrl, plan);
if (globals.json) {
printJSON({ plan, url, credits: creditsSummary(status) });
+ } else if (status?.usagePlan === plan) {
+ process.stdout.write(`This organization is already on Pro. Manage billing at ${status.billingUrl}\n`);
} else {
const offer = status?.plans.find((p) => p.id === plan);
process.stdout.write(
- `Open this link to upgrade to ${plan === "pro" ? "Pro" : "Max"}` +
- (offer ? ` ($${offer.priceUsd}/mo, $${offer.creditsUsd.toLocaleString("en-US")} in credits every month)` : "") +
+ "Open this link to upgrade to Pro" +
+ (offer ? ` ($${offer.priceUsd}/mo, $${offer.creditsUsd.toLocaleString("en-US")} in credits every month)` : " ($200/mo)") +
`:\n\n ${url}\n\nCheckout completes in the browser; the CLI resumes working as soon as the plan is active.\n`,
);
}
diff --git a/cli/src/errors.test.ts b/cli/src/errors.test.ts
index f30675e4..5a609b7d 100644
--- a/cli/src/errors.test.ts
+++ b/cli/src/errors.test.ts
@@ -40,19 +40,28 @@ test("out-of-credits responses tell the agent to stop and surface the upgrade li
"Out of prepaid credits.",
402,
"insufficient_credits",
- "https://app.opencomputer.dev/billing?plan=pro",
+ "https://app.opencomputer.dev/billing?plan=max",
),
);
assert.equal(halted.code, "insufficient_credits");
assert.match(halted.hint, /do not retry/);
- assert.match(halted.hint, /https:\/\/app\.opencomputer\.dev\/billing\?plan=pro/);
+ assert.match(halted.hint, /https:\/\/app\.opencomputer\.dev\/billing\?plan=max/);
assert.deepEqual(halted.details, {
status: 402,
apiCode: "insufficient_credits",
- upgradeUrl: "https://app.opencomputer.dev/billing?plan=pro",
+ upgradeUrl: "https://app.opencomputer.dev/billing?plan=max",
});
const bare = structuredError(new APIError("Payment required.", 402));
assert.equal(bare.code, "insufficient_credits");
- assert.match(bare.hint, /opencomputer upgrade pro/);
+ assert.match(bare.hint, /opencomputer upgrade/);
+ assert.match(bare.hint, /Pro \(\$200\/mo\)/);
+ assert.doesNotMatch(bare.hint + halted.hint, /\$20\/mo|top.?up/i);
+
+ // A $200 Pro org is pointed at billing (credits renew), not at an upgrade.
+ const pro = structuredError(
+ new APIError("Out of credits.", 402, "insufficient_credits", "https://app.opencomputer.dev/billing"),
+ );
+ assert.match(pro.hint, /renew/);
+ assert.doesNotMatch(pro.hint, /upgrade/i);
});
diff --git a/cli/src/errors.ts b/cli/src/errors.ts
index 768ea69c..c8b7caee 100644
--- a/cli/src/errors.ts
+++ b/cli/src/errors.ts
@@ -31,13 +31,17 @@ export function structuredError(error: unknown): StructuredCLIError {
if (error instanceof APIError) {
if (error.code === "insufficient_credits" || error.status === 402) {
const url = error.actionUrl;
+ // A $200 Pro org that has used its monthly credits gets the plain billing
+ // page (no `?plan=`): there is nothing to upgrade to, so don't say so.
+ const renewOnly = url !== undefined && !url.includes("?plan=");
return {
code: "insufficient_credits",
message,
- hint:
- "Out of prepaid credits \u2014 do not retry. Tell the user to upgrade to Pro ($20/mo, $200 credits)" +
- (url ? ` at ${url}` : " with `opencomputer upgrade pro`") +
- ", then run the command again.",
+ hint: renewOnly
+ ? `Out of this month's credits \u2014 do not retry. They renew next billing period; the user can review billing at ${url}.`
+ : "Out of credits \u2014 do not retry. Tell the user to upgrade to Pro ($200/mo)" +
+ (url ? ` at ${url}` : " with `opencomputer upgrade`") +
+ " to keep going, or to use their own Claude or ChatGPT subscription, then run the command again.",
details: {
status: error.status,
apiCode: error.code ?? "insufficient_credits",
diff --git a/cli/src/index.ts b/cli/src/index.ts
index 20e441d5..a0754e61 100644
--- a/cli/src/index.ts
+++ b/cli/src/index.ts
@@ -48,7 +48,7 @@ Usage:
opencomputer logout [--local]
opencomputer whoami
opencomputer billing
- opencomputer upgrade [pro|max]
+ opencomputer upgrade [pro]
opencomputer agents
opencomputer init <directory|.>
opencomputer template validate [directory] [--repository-url <url>] [--app-url <url>]
diff --git a/cloudflare-workers/api-edge/src/billing_onramp.test.ts b/cloudflare-workers/api-edge/src/billing_onramp.test.ts
index f82b137c..9fac98e6 100644
--- a/cloudflare-workers/api-edge/src/billing_onramp.test.ts
+++ b/cloudflare-workers/api-edge/src/billing_onramp.test.ts
@@ -2,9 +2,12 @@ import { describe, expect, it } from "vitest";
import {
activeUsagePlan,
billingLinks,
+ FREE_CREDITS_PAYWALL,
insufficientCreditsLegacyResponse,
insufficientCreditsResponse,
lowCreditThresholdCents,
+ USAGE_PLAN_OFFERS,
+ usagePlanOffers,
} from "./billing_onramp";
import type { AutumnCustomer } from "./autumn_webhook";
@@ -29,7 +32,7 @@ describe("billing_onramp", () => {
});
it("builds deep links off the request origin", () => {
- expect(billingLinks(req, "max")).toEqual({
+ expect(billingLinks(req)).toEqual({
billingUrl: "https://app.opencomputer.dev/billing",
upgradeUrl: "https://app.opencomputer.dev/billing?plan=max",
});
@@ -41,8 +44,50 @@ describe("billing_onramp", () => {
const body = (await res.json()) as { error: Record<string, string> };
expect(body.error.code).toBe("insufficient_credits");
expect(body.error.message).toMatch(/do not retry/);
- expect(body.error.upgradeUrl).toBe("https://app.opencomputer.dev/billing?plan=pro");
- expect(body.error.actionUrl).toBe("https://app.opencomputer.dev/billing");
+ expect(body.error.message).toContain("You've used your free credits.");
+ expect(body.error.message).toContain(
+ "upgrade to Pro ($200/mo) at https://app.opencomputer.dev/billing?plan=max",
+ );
+ expect(body.error.upgradeUrl).toBe("https://app.opencomputer.dev/billing?plan=max");
+ expect(body.error.actionUrl).toBe("https://app.opencomputer.dev/billing?plan=max");
+ });
+
+ it("never offers top-ups or the retired $20 plan in any 402", async () => {
+ for (const plan of [undefined, "base", "pro", "max"] as const) {
+ const body = (await insufficientCreditsResponse(req, plan).json()) as {
+ error: Record<string, string>;
+ };
+ expect(body.error.message).not.toMatch(/top.?up|\$20\b|plan=pro/i);
+ expect(body.error.upgradeUrl).not.toContain("plan=pro");
+ }
+ });
+
+ it("points a legacy $20 Pro org at the $200 Pro, and does not upsell a $200 Pro org", async () => {
+ const legacy = (await insufficientCreditsResponse(req, "pro").json()) as {
+ error: Record<string, string>;
+ };
+ expect(legacy.error.message).toContain("upgrade to Pro ($200/mo) at https://app.opencomputer.dev/billing?plan=max");
+ const max = (await insufficientCreditsResponse(req, "max").json()) as {
+ error: Record<string, string>;
+ };
+ expect(max.error.message).not.toMatch(/upgrade/i);
+ expect(max.error.actionUrl).toBe("https://app.opencomputer.dev/billing");
+ });
+
+ it("offers only the $200 Pro, listing legacy Pro to its own subscribers", () => {
+ expect(USAGE_PLAN_OFFERS).toEqual([{ id: "max", name: "Pro", priceUsd: 200, creditsUsd: 2_000 }]);
+ expect(usagePlanOffers("base").map((p) => p.id)).toEqual(["max"]);
+ expect(usagePlanOffers("max").map((p) => p.id)).toEqual(["max"]);
+ expect(usagePlanOffers("pro").map((p) => [p.id, p.name])).toEqual([
+ ["pro", "Pro (legacy)"],
+ ["max", "Pro"],
+ ]);
+ });
+
+ it("paywall copy names Pro and BYO subscriptions but not the grant amount", () => {
+ expect(FREE_CREDITS_PAYWALL).toBe(
+ "You've used your free credits. Upgrade to Pro ($200/mo) to keep going, or to use your own Claude or ChatGPT subscription.",
+ );
});
it("legacy sandbox 402 keeps `error` a string and adds structured fields", async () => {
@@ -50,7 +95,7 @@ describe("billing_onramp", () => {
const body = (await res.json()) as Record<string, unknown>;
expect(typeof body.error).toBe("string");
expect(body.code).toBe("insufficient_credits");
- expect(body.upgradeUrl).toBe("https://app.opencomputer.dev/billing?plan=pro");
+ expect(body.upgradeUrl).toBe("https://app.opencomputer.dev/billing?plan=max");
expect(body.creditsRemainingCents).toBe(0);
});
});
diff --git a/cloudflare-workers/api-edge/src/billing_onramp.ts b/cloudflare-workers/api-edge/src/billing_onramp.ts
index ec85f48d..d0278931 100644
--- a/cloudflare-workers/api-edge/src/billing_onramp.ts
+++ b/cloudflare-workers/api-edge/src/billing_onramp.ts
@@ -31,31 +31,71 @@ export interface BillingLinks {
upgradeUrl: string;
}
-export function billingLinks(request: Request, plan: "pro" | "max" = "pro"): BillingLinks {
+// The one plan new customers can buy. Its Autumn id stays `max` (no Stripe
+// migration); it is displayed as "Pro". The old $20/mo plan (Autumn id `pro`)
+// is retired for new customers and shown as "Pro (legacy)" to its existing
+// subscribers only, so nothing here ever links to it. Top-ups are no longer
+// sold either.
+export const UPGRADE_PLAN = "max" as const;
+export const UPGRADE_PLAN_PRICE_USD = 200;
+export const PLAN_DISPLAY_NAMES: Record<UsagePlan, string> = {
+ base: "Free",
+ pro: "Pro (legacy)",
+ max: "Pro",
+};
+
+// The free-tier paywall copy, shared by every surface. It does not state the
+// grant amount: that is still $5 today and changes in a later step.
+export const FREE_CREDITS_PAYWALL =
+ `You've used your free credits. Upgrade to Pro ($${UPGRADE_PLAN_PRICE_USD}/mo) to keep going, ` +
+ "or to use your own Claude or ChatGPT subscription.";
+
+export function billingLinks(request: Request): BillingLinks {
const origin = new URL(request.url).origin;
return {
billingUrl: `${origin}/billing`,
- upgradeUrl: `${origin}/billing?plan=${plan}`,
+ upgradeUrl: `${origin}/billing?plan=${UPGRADE_PLAN}`,
};
}
+// Agent-facing out-of-credits message. Free (and unknown/legacy) orgs get the
+// paywall; a legacy $20 Pro org is pointed at the same Pro upgrade; a $200 Pro
+// org keeps its current halt (a later step moves it to GLM) but is never
+// offered a top-up.
+export function insufficientCreditsMessage(links: BillingLinks, plan?: UsagePlan | null): string {
+ if (plan === "max") {
+ return (
+ "You've used this month's Pro credits. They renew at the start of the next billing period; " +
+ `the user can review billing at ${links.billingUrl}. Do not retry until credits renew.`
+ );
+ }
+ if (plan === "pro") {
+ return (
+ `You've used this month's credits. Ask the user to upgrade to Pro ($${UPGRADE_PLAN_PRICE_USD}/mo) at ${links.upgradeUrl} ` +
+ "to keep going, or to use their own Claude or ChatGPT subscription; do not retry until they have."
+ );
+ }
+ return (
+ `You've used your free credits. Ask the user to upgrade to Pro ($${UPGRADE_PLAN_PRICE_USD}/mo) at ${links.upgradeUrl} ` +
+ "to keep going, or to use their own Claude or ChatGPT subscription; do not retry until they have."
+ );
+}
+
// The 402 body every credit gate returns. `error` is an object (code/message)
// for the managed-agents API; sandbox routes historically used a string
// `error`, so callers there spread `legacyStringError()` instead.
-export function insufficientCreditsError(request: Request) {
+export function insufficientCreditsError(request: Request, plan?: UsagePlan | null) {
const links = billingLinks(request);
return {
code: "insufficient_credits" as const,
- message:
- `Out of prepaid credits. Ask the user to upgrade to Pro ($20/mo, $200 credits) at ${links.upgradeUrl} ` +
- `or top up at ${links.billingUrl}; do not retry until they have.`,
- actionUrl: links.billingUrl,
+ message: insufficientCreditsMessage(links, plan),
+ actionUrl: plan === "max" ? links.billingUrl : links.upgradeUrl,
...links,
};
}
-export function insufficientCreditsResponse(request: Request): Response {
- return Response.json({ error: insufficientCreditsError(request) }, { status: 402 });
+export function insufficientCreditsResponse(request: Request, plan?: UsagePlan | null): Response {
+ return Response.json({ error: insufficientCreditsError(request, plan) }, { status: 402 });
}
// Sandbox-route flavour: keeps `error` a string (the `oc` Go CLI prints it
@@ -63,8 +103,9 @@ export function insufficientCreditsResponse(request: Request): Response {
export function insufficientCreditsLegacyResponse(
request: Request,
extra: Record<string, unknown> = {},
+ plan?: UsagePlan | null,
): Response {
- const e = insufficientCreditsError(request);
+ const e = insufficientCreditsError(request, plan);
return Response.json(
{
error: e.message,
@@ -86,16 +127,23 @@ export interface CreditsStatus {
isHalted: boolean;
billingUrl: string;
upgradeUrl: string;
- plans: Array<{ id: "pro" | "max"; priceUsd: number; creditsUsd: number }>;
+ // Plans shown to this org. `name` is the display name (`max` is "Pro").
+ // The retired $20 plan is listed only for orgs already on it.
+ plans: Array<{ id: "pro" | "max"; name: string; priceUsd: number; creditsUsd: number }>;
}
-export const USAGE_PLAN_OFFERS: CreditsStatus["plans"] = [
- { id: "pro", priceUsd: 20, creditsUsd: 200 },
- { id: "max", priceUsd: 200, creditsUsd: 2_000 },
-];
+const PRO_OFFER = { id: "max", name: PLAN_DISPLAY_NAMES.max, priceUsd: UPGRADE_PLAN_PRICE_USD, creditsUsd: 2_000 } as const;
+const LEGACY_PRO_OFFER = { id: "pro", name: PLAN_DISPLAY_NAMES.pro, priceUsd: 20, creditsUsd: 200 } as const;
+
+// Kept for callers that list offers without an org: only the plan on sale.
+export const USAGE_PLAN_OFFERS: CreditsStatus["plans"] = [PRO_OFFER];
+
+export function usagePlanOffers(current: UsagePlan): CreditsStatus["plans"] {
+ return current === "pro" ? [LEGACY_PRO_OFFER, PRO_OFFER] : [PRO_OFFER];
+}
// GET /api/billing/credits — API-key authenticated credit status for the CLI.
-// Re-syncs Autumn → D1 like the dashboard endpoint so a fresh top-up clears a
+// Re-syncs Autumn → D1 like the dashboard endpoint so a fresh upgrade clears a
// halt on the next CLI call too. Legacy (Stripe) orgs have no Autumn customer
// and get a 404 — clients treat that as "no credit meter".
export async function handleCreditsStatus(
@@ -117,7 +165,7 @@ export async function handleCreditsStatus(
const usagePlan = activeUsagePlan(r.customer);
const creditsRemainingCents = Math.max(0, Math.round(r.creditsRemaining * 100));
const threshold = lowCreditThresholdCents(usagePlan);
- const links = billingLinks(req, usagePlan === "pro" ? "max" : "pro");
+ const links = billingLinks(req);
const status: CreditsStatus = {
usagePlan,
creditsRemainingCents,
@@ -125,7 +173,7 @@ export async function handleCreditsStatus(
isLow: !r.halted && creditsRemainingCents <= threshold,
isHalted: r.halted,
...links,
- plans: USAGE_PLAN_OFFERS,
+ plans: usagePlanOffers(usagePlan),
};
return Response.json(status);
}
diff --git a/cloudflare-workers/api-edge/src/index.ts b/cloudflare-workers/api-edge/src/index.ts
index bd7a6aa7..eba7f4cd 100644
--- a/cloudflare-workers/api-edge/src/index.ts
+++ b/cloudflare-workers/api-edge/src/index.ts
@@ -77,7 +77,7 @@ import {
enforceManagedAgentCreditGate,
insufficientManagedAgentCredits,
} from "./managed_agent_credit_gate";
-import { handleCreditsStatus, insufficientCreditsLegacyResponse } from "./billing_onramp";
+import { handleCreditsStatus, insufficientCreditsLegacyResponse, type UsagePlan } from "./billing_onramp";
export { ManagedAgentBillingService } from "./managed_agent_billing_service";
import { runRetentionSweep } from "./retention";
import * as secretStores from "./secret_stores";
@@ -1383,6 +1383,24 @@ async function refreshOrgPolicy(env: Env, orgID: string): Promise<OrgPolicy | nu
return policy;
}
+// The usage plan behind an out-of-credits 402, so its message fits the org:
+// free gets the paywall, legacy $20 Pro the upgrade to Pro, $200 Pro no upsell.
+// Only read on the (rare) halted path; any failure falls back to the paywall.
+function usagePlanOf(value: string | null | undefined): UsagePlan {
+ return value === "pro" || value === "max" ? value : "base";
+}
+
+async function haltedUsagePlan(env: Env, orgID: string): Promise<UsagePlan> {
+ try {
+ const row = await env.OPENCOMPUTER_DB.prepare("SELECT usage_plan FROM orgs WHERE id = ?1")
+ .bind(orgID)
+ .first<{ usage_plan: string | null }>();
+ return usagePlanOf(row?.usage_plan);
+ } catch {
+ return "base";
+ }
+}
+
// enforceCreatePolicy applies every org-level gate for creating or forking a
// sandbox, reading authoritative state from D1 (and the CreditAccount DO for
// free orgs). Returns an error Response to short-circuit, or null when allowed.
@@ -1413,7 +1431,7 @@ async function enforceCreatePolicy(
// pay per GB-second); only the per-org max_disk_mb cap applies.
if (org.billing_provider === "autumn") {
if (org.is_halted === 1 && (await selfHealHalt(env, orgID))) {
- return insufficientCreditsLegacyResponse(req);
+ return insufficientCreditsLegacyResponse(req, {}, await haltedUsagePlan(env, orgID));
}
} else if (plan === "free") {
// Legacy free-tier gate. is_halted is the D1 fast path; otherwise ask the
@@ -3369,10 +3387,10 @@ async function proxyToCellSDK(req: Request, env: Env, ctx: ExecutionContext, cal
// silently fell through, letting halted orgs wake. Mirror the create
// flow's halt check here so wake gets the same treatment.
const haltRow = await env.OPENCOMPUTER_DB.prepare(
- "SELECT is_halted, billing_provider FROM orgs WHERE id = ?1",
+ "SELECT is_halted, billing_provider, usage_plan FROM orgs WHERE id = ?1",
)
.bind(caller.orgID)
- .first<{ is_halted: number; billing_provider: string }>();
+ .first<{ is_halted: number; billing_provider: string; usage_plan: string | null }>();
if (haltRow?.is_halted === 1) {
// Autumn orgs self-heal: re-check the authoritative balance before
// blocking a wake, so a just-topped-up user resumes without waiting for
@@ -3380,7 +3398,7 @@ async function proxyToCellSDK(req: Request, env: Env, ctx: ExecutionContext, cal
const stillHalted =
haltRow.billing_provider === "autumn" ? await selfHealHalt(env, caller.orgID) : true;
if (stillHalted) {
- return insufficientCreditsLegacyResponse(req);
+ return insufficientCreditsLegacyResponse(req, {}, usagePlanOf(haltRow.usage_plan));
}
}
}
diff --git a/cloudflare-workers/api-edge/src/managed_agent_credit_gate.test.ts b/cloudflare-workers/api-edge/src/managed_agent_credit_gate.test.ts
index 7dd87a3a..8875fdc4 100644
--- a/cloudflare-workers/api-edge/src/managed_agent_credit_gate.test.ts
+++ b/cloudflare-workers/api-edge/src/managed_agent_credit_gate.test.ts
@@ -243,12 +243,14 @@ describe("managed-agent credit admission", () => {
const body = (await response.json()) as { error: Record<string, unknown> };
expect(body.error).toMatchObject({
code: "insufficient_credits",
- actionUrl: "https://mo-oc-dev.com/billing",
+ actionUrl: "https://mo-oc-dev.com/billing?plan=max",
billingUrl: "https://mo-oc-dev.com/billing",
- upgradeUrl: "https://mo-oc-dev.com/billing?plan=pro",
+ upgradeUrl: "https://mo-oc-dev.com/billing?plan=max",
});
- expect(body.error.message).toContain("https://mo-oc-dev.com/billing?plan=pro");
+ expect(body.error.message).toContain("https://mo-oc-dev.com/billing?plan=max");
+ expect(body.error.message).toContain("upgrade to Pro ($200/mo)");
expect(body.error.message).toContain("do not retry");
+ expect(body.error.message).not.toMatch(/top.?up|\$20\b/i);
});
it("allows active organizations and fails open when D1 is unavailable", async () => {
diff --git a/cloudflare-workers/api-edge/src/managed_agents.ts b/cloudflare-workers/api-edge/src/managed_agents.ts
index 7ad88a7b..9fc6009e 100644
--- a/cloudflare-workers/api-edge/src/managed_agents.ts
+++ b/cloudflare-workers/api-edge/src/managed_agents.ts
@@ -1,4 +1,5 @@
import { getAutumnCustomer } from "./autumn_webhook";
+import { FREE_CREDITS_PAYWALL } from "./billing_onramp";
import {
COMPUTER_ERROR_MESSAGES,
computerFallbackMessage,
@@ -67,7 +68,7 @@ function byokPlanRequired(): Response {
{
error: {
code: "model_access_plan_required",
- message: "Upgrade to Pro to connect or enable a BYOK account.",
+ message: "Upgrade to Pro ($200/mo) to connect or enable a BYOK account.",
},
},
{ status: 403 },
@@ -359,7 +360,7 @@ async function publicErrorResponse(
} else if (upstream.status === 402) {
message =
backendCode === "insufficient_credits"
- ? "Insufficient prepaid credits. Top up or enable automatic top-up."
+ ? FREE_CREDITS_PAYWALL
: "The agent request requires additional prepaid credits.";
} else if (upstream.status >= 500) {
message = "The agent service is temporarily unavailable.";
diff --git a/skills/opencomputer/SKILL.md b/skills/opencomputer/SKILL.md
index 7cde66b4..10441a4d 100644
--- a/skills/opencomputer/SKILL.md
+++ b/skills/opencomputer/SKILL.md
@@ -56,11 +56,13 @@ message mentioning "credits exhausted" / "out of prepaid credits", the
organization has no prepaid credits left and **every further command will fail
the same way**. Do **not** retry or work around it. Instead:
-1. Stop and tell the user their OpenComputer credits are exhausted.
+1. Stop and tell the user they've used their OpenComputer credits.
2. Relay the upgrade link from the error verbatim (it looks like
- `https://app.opencomputer.dev/billing?plan=pro`). Pro is $20/month for $200 in
- credits; one-off top-ups are on the same page.
-3. Resume once they confirm they've upgraded or topped up.
+ `https://app.opencomputer.dev/billing?plan=max`). Pro is $200/month and also
+ lets them use their own Claude or ChatGPT subscription. If the error links
+ to plain `/billing` instead, the org is already on Pro and its monthly
+ credits renew next billing period.
+3. Resume once they confirm they've upgraded.
A response that carries `warning: "low_credits"` (or a "credits left (running
low)" line) still succeeded — finish the task, then mention the balance and
diff --git a/web/src/components/app-shell.tsx b/web/src/components/app-shell.tsx
index d08a7687..071f7d39 100644
--- a/web/src/components/app-shell.tsx
+++ b/web/src/components/app-shell.tsx
@@ -55,7 +55,9 @@ import { managedAgentsExperimentEnabled } from '@/managed-agents/feature'
import { useCreditState } from '@/hooks/useCreditState'
import {
BASE_GRANT_CENTS,
- PLAN_OFFERS,
+ FREE_CREDITS_USED,
+ UPGRADE_PLAN,
+ UPGRADE_PLAN_LABEL,
billingOnrampV2Enabled,
formatUsd,
trackUpsellClicked,
@@ -475,7 +477,7 @@ function SidebarCreditMeter({ onNavigate }: { onNavigate?: () => void }) {
if (visible)
trackUpsellShown({
surface: 'sidebar_meter',
- plan: 'pro',
+ plan: UPGRADE_PLAN,
usagePlan,
creditsRemainingCents,
})
@@ -508,11 +510,11 @@ function SidebarCreditMeter({ onNavigate }: { onNavigate?: () => void }) {
/>
</div>
<Link
- to={upgradeHref('pro')}
+ to={upgradeHref()}
onClick={() => {
trackUpsellClicked({
surface: 'sidebar_meter',
- plan: 'pro',
+ plan: UPGRADE_PLAN,
usagePlan,
creditsRemainingCents,
})
@@ -520,8 +522,7 @@ function SidebarCreditMeter({ onNavigate }: { onNavigate?: () => void }) {
}}
className="text-foreground mt-2 block text-xs font-medium underline-offset-2 hover:underline"
>
- Upgrade to Pro · ${PLAN_OFFERS.pro.priceUsd}/mo → get $
- {PLAN_OFFERS.pro.creditsUsd} in monthly credits
+ Upgrade to {UPGRADE_PLAN_LABEL} →
</Link>
</div>
)
@@ -529,9 +530,10 @@ function SidebarCreditMeter({ onNavigate }: { onNavigate?: () => void }) {
// Org-wide credit notice. Prepaid (autumn) orgs that exhaust credits get halted
// (sandboxes hibernate); show a banner everywhere except Billing so users know
-// why things paused and where to resolve it. Below the low-credit threshold the
+// why things paused and where to resolve it. A free org sees the paywall: one
+// message, one link to the Pro checkout. Below the low-credit threshold the
// banner is an amber nudge instead. Legacy orgs 404 on /billing/autumn → no
-// data → no banner.
+// data → no banner. Top-ups are no longer sold, so nothing here offers one.
function HaltBanner() {
const location = useLocation()
const {
@@ -545,7 +547,7 @@ function HaltBanner() {
const onBilling = location.pathname.startsWith('/billing')
const state = isHalted ? 'halted' : isLow ? 'low' : null
useEffect(() => {
- if (state && !onBilling)
+ if (state && !onBilling && upgradePlan)
trackUpsellShown({
surface: state === 'halted' ? 'halt_banner' : 'low_credit_banner',
plan: upgradePlan,
@@ -555,30 +557,39 @@ function HaltBanner() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state, onBilling])
if (!state || onBilling) return null
- const offer = PLAN_OFFERS[upgradePlan]
- const planName = upgradePlan === 'pro' ? 'Pro' : 'Max'
- const click = () =>
+ const click = () => {
+ if (!upgradePlan) return
trackUpsellClicked({
surface: state === 'halted' ? 'halt_banner' : 'low_credit_banner',
plan: upgradePlan,
usagePlan,
creditsRemainingCents,
})
+ }
+ const upgradeLink = (label: string) => (
+ <Link
+ to={upgradeHref()}
+ onClick={click}
+ className="font-semibold underline underline-offset-2"
+ >
+ {label}
+ </Link>
+ )
if (state === 'low') {
return (
<div className="flex items-center justify-center gap-2 border-b border-amber-500/40 bg-amber-500/10 px-4 py-2.5 text-center text-sm font-medium text-amber-700 sm:px-8 dark:text-amber-400">
<CircleAlert className="size-4 shrink-0" />
<span>
- {formatUsd(creditsRemainingCents ?? 0)} of credits left — sessions
- pause at $0.{' '}
- <Link
- to={upgradeHref(upgradePlan)}
- onClick={click}
- className="font-semibold underline underline-offset-2"
- >
- Upgrade to {planName}
- </Link>{' '}
- for ${offer.creditsUsd}/mo of credits at ${offer.priceUsd}/mo.
+ {formatUsd(creditsRemainingCents ?? 0)}{' '}
+ {usagePlan === 'base'
+ ? 'of free credits left — sessions pause at $0.'
+ : "of this month's credits left."}
+ {upgradePlan ? (
+ <>
+ {' '}
+ {upgradeLink(`Upgrade to ${UPGRADE_PLAN_LABEL}`)} to keep going.
+ </>
+ ) : null}
</span>
</div>
)
@@ -589,15 +600,15 @@ function HaltBanner() {
<CircleAlert className="size-4 shrink-0" />
<span>
You&apos;ve used this month&apos;s credits — agents keep running on an
- open-weight model (GLM).{' '}
- <Link
- to="/billing"
- onClick={click}
- className="font-semibold underline underline-offset-2"
- >
- Top up
- </Link>{' '}
- to switch back to your selected models.
+ open-weight model (GLM)
+ {upgradePlan ? (
+ <>
+ . {upgradeLink(`Upgrade to ${UPGRADE_PLAN_LABEL}`)} to switch back
+ to your selected models.
+ </>
+ ) : (
+ ' until your plan renews.'
+ )}
</span>
</div>
)
@@ -606,34 +617,8 @@ function HaltBanner() {
<div className="border-destructive/40 bg-status-error-bg text-destructive flex items-center justify-center gap-2 border-b px-4 py-2.5 text-center text-sm font-medium sm:px-8">
<CircleAlert className="size-4 shrink-0" />
<span>
- Your agent sessions are paused — you&apos;re out of prepaid credits.{' '}
- {billingOnrampV2Enabled ? (
- <>
- <Link
- to={upgradeHref(upgradePlan)}
- onClick={click}
- className="font-semibold underline underline-offset-2"
- >
- Upgrade to {planName} (${offer.priceUsd}/mo, ${offer.creditsUsd}{' '}
- credits)
- </Link>{' '}
- or{' '}
- <Link to="/billing" className="underline underline-offset-2">
- top up
- </Link>{' '}
- to resume.
- </>
- ) : (
- <>
- <Link
- to="/billing"
- className="font-semibold underline underline-offset-2"
- >
- Top up &amp; turn on auto-recharge
- </Link>{' '}
- to resume.
- </>
- )}
+ {FREE_CREDITS_USED} {upgradeLink(`Upgrade to ${UPGRADE_PLAN_LABEL}`)} to
+ keep going, or to use your own Claude or ChatGPT subscription.
</span>
</div>
)
diff --git a/web/src/components/post-session-upsell.tsx b/web/src/components/post-session-upsell.tsx
index c7340bf9..5b9f6861 100644
--- a/web/src/components/post-session-upsell.tsx
+++ b/web/src/components/post-session-upsell.tsx
@@ -6,7 +6,8 @@ import { Button } from '@/components/ui/button'
import { useCreditState } from '@/hooks/useCreditState'
import {
BASE_GRANT_CENTS,
- PLAN_OFFERS,
+ UPGRADE_PLAN,
+ UPGRADE_PLAN_LABEL,
billingOnrampV2Enabled,
formatUsd,
trackFirstSessionCompleted,
@@ -75,7 +76,7 @@ export function PostSessionUpsell({
})
trackUpsellShown({
surface: 'post_session_card',
- plan: 'pro',
+ plan: UPGRADE_PLAN,
usagePlan,
creditsRemainingCents,
})
@@ -83,7 +84,6 @@ export function PostSessionUpsell({
}, [show, sessionId])
if (!show || spentCents === null) return null
- const pro = PLAN_OFFERS.pro
return (
<Panel
className={`flex flex-wrap items-center justify-between gap-4 p-4 ${className ?? ''}`}
@@ -97,25 +97,24 @@ export function PostSessionUpsell({
{formatUsd(creditsRemainingCents ?? 0)} left.
</p>
<p className="text-muted-foreground mt-0.5">
- Pro is ${pro.priceUsd}/mo for ${pro.creditsUsd} in credits —{' '}
- {Math.round(pro.creditsUsd / pro.priceUsd)}× the value every month,
- and your agents never pause.
+ Upgrade to {UPGRADE_PLAN_LABEL} to keep going when they run out, or
+ to use your own Claude or ChatGPT subscription.
</p>
</div>
</div>
<Button asChild size="sm">
<Link
- to={upgradeHref('pro')}
+ to={upgradeHref()}
onClick={() =>
trackUpsellClicked({
surface: 'post_session_card',
- plan: 'pro',
+ plan: UPGRADE_PLAN,
usagePlan,
creditsRemainingCents,
})
}
>
- Upgrade to Pro — ${pro.priceUsd}/mo
+ Upgrade to {UPGRADE_PLAN_LABEL}
</Link>
</Button>
</Panel>
diff --git a/web/src/components/session-conversation.test.tsx b/web/src/components/session-conversation.test.tsx
index 0751ea35..ac6da674 100644
--- a/web/src/components/session-conversation.test.tsx
+++ b/web/src/components/session-conversation.test.tsx
@@ -1,7 +1,8 @@
import { renderToStaticMarkup } from 'react-dom/server'
+import { MemoryRouter } from 'react-router-dom'
import { describe, expect, it } from 'vitest'
import type { SessionEvent } from '@/api/client'
-import { HttpRequestCard } from './session-conversation'
+import { HttpRequestCard, MessageBubble } from './session-conversation'
describe('HttpRequestCard', () => {
it('renders the attributed payload as structured, escaped JSON', () => {
@@ -30,3 +31,17 @@ describe('HttpRequestCard', () => {
expect(markup).toContain('&quot;count&quot;: 2')
})
})
+
+describe('MessageBubble', () => {
+ it('offers the Pro upgrade, not a top-up, when the agent is out of credits', () => {
+ const markup = renderToStaticMarkup(
+ <MemoryRouter>
+ <MessageBubble label="Agent" text="Out of credits" outOfCredits />
+ </MemoryRouter>,
+ )
+
+ expect(markup).toContain('href="/billing?plan=max"')
+ expect(markup).toContain('Upgrade to Pro ($200/mo)')
+ expect(markup).not.toMatch(/top.?up/i)
+ })
+})
diff --git a/web/src/components/session-conversation.tsx b/web/src/components/session-conversation.tsx
index 0dbb41d8..45df343f 100644
--- a/web/src/components/session-conversation.tsx
+++ b/web/src/components/session-conversation.tsx
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom'
import { Hourglass } from 'lucide-react'
import type { SessionEvent } from '@/api/client'
import { Button } from '@/components/ui/button'
+import { UPGRADE_PLAN_LABEL, upgradeHref } from '@/lib/billing-onramp'
import {
bodyText,
httpRequestPayloadText,
@@ -74,7 +75,7 @@ export function MessageBubble({
<p className="text-foreground/90 text-sm whitespace-pre-wrap">{text}</p>
{outOfCredits ? (
<Button asChild size="sm" className="mt-2">
- <Link to="/billing">Top up</Link>
+ <Link to={upgradeHref()}>Upgrade to {UPGRADE_PLAN_LABEL}</Link>
</Button>
) : null}
</div>
diff --git a/web/src/hooks/useCreditState.ts b/web/src/hooks/useCreditState.ts
index 7fc7f752..6301b30f 100644
--- a/web/src/hooks/useCreditState.ts
+++ b/web/src/hooks/useCreditState.ts
@@ -5,7 +5,7 @@ import {
billingOnrampV2Enabled,
lowCreditThresholdCents,
upgradePlanFor,
- type PaidPlanId,
+ type UpgradePlanId,
type UsagePlanId,
} from '@/lib/billing-onramp'
@@ -21,7 +21,9 @@ export interface CreditState {
// Below the low-credit threshold but not yet halted; only for prepaid orgs
// with the on-ramp experiment enabled.
isLow: boolean
- upgradePlan: PaidPlanId
+ // The plan to prompt for (always the $200 Pro, Autumn id `max`); null when
+ // the org is already on it. Legacy $20 Pro is never offered.
+ upgradePlan: UpgradePlanId | null
}
// Shares the same 30s poll as useHalted/HaltBanner via the 'autumn-billing' key.
diff --git a/web/src/lib/billing-onramp.test.ts b/web/src/lib/billing-onramp.test.ts
new file mode 100644
index 00000000..ccd3aef2
--- /dev/null
+++ b/web/src/lib/billing-onramp.test.ts
@@ -0,0 +1,52 @@
+import { describe, expect, it } from 'vitest'
+import {
+ FREE_CREDITS_PAYWALL,
+ PLAN_NAMES,
+ UPGRADE_PLAN,
+ UPGRADE_PLAN_LABEL,
+ deepLinkedPlanFor,
+ selectablePaidPlans,
+ upgradeHref,
+ upgradePlanFor,
+} from '@/lib/billing-onramp'
+
+describe('billing on-ramp plans', () => {
+ it('sells only the $200 plan (Autumn id max), named Pro', () => {
+ expect(UPGRADE_PLAN).toBe('max')
+ expect(PLAN_NAMES).toEqual({
+ base: 'Free',
+ pro: 'Pro (legacy)',
+ max: 'Pro',
+ })
+ expect(UPGRADE_PLAN_LABEL).toBe('Pro ($200/mo)')
+ expect(upgradeHref()).toBe('/billing?plan=max')
+ })
+
+ it('prompts Free and legacy Pro orgs to the $200 Pro, and nobody to legacy Pro', () => {
+ expect(upgradePlanFor('base')).toBe('max')
+ expect(upgradePlanFor('pro')).toBe('max')
+ expect(upgradePlanFor('max')).toBeNull()
+ })
+
+ it('lists legacy Pro only to its own subscribers', () => {
+ expect(selectablePaidPlans('base')).toEqual(['max'])
+ expect(selectablePaidPlans('max')).toEqual(['max'])
+ expect(selectablePaidPlans('pro')).toEqual(['pro', 'max'])
+ })
+
+ it('opens the $200 Pro checkout for ?plan= deep links, old plan=pro links included', () => {
+ expect(deepLinkedPlanFor('max', 'base')).toBe('max')
+ expect(deepLinkedPlanFor('pro', 'base')).toBe('max')
+ expect(deepLinkedPlanFor('pro', 'pro')).toBe('max')
+ expect(deepLinkedPlanFor('max', 'max')).toBeNull()
+ expect(deepLinkedPlanFor(null, 'base')).toBeNull()
+ expect(deepLinkedPlanFor('top_up', 'base')).toBeNull()
+ })
+
+ it('uses one paywall message without the grant amount or a top-up', () => {
+ expect(FREE_CREDITS_PAYWALL).toBe(
+ "You've used your free credits. Upgrade to Pro ($200/mo) to keep going, or to use your own Claude or ChatGPT subscription.",
+ )
+ expect(FREE_CREDITS_PAYWALL).not.toMatch(/top.?up|\$5\b|\$10\b/i)
+ })
+})
diff --git a/web/src/lib/billing-onramp.ts b/web/src/lib/billing-onramp.ts
index 9940b7b0..0983b63c 100644
--- a/web/src/lib/billing-onramp.ts
+++ b/web/src/lib/billing-onramp.ts
@@ -1,7 +1,8 @@
import posthog from 'posthog-js'
+import { USAGE_PLAN_NAMES } from '@/lib/plan-label'
// Payment on-ramp experiment (low-credit banner, sidebar meter, post-session
-// upsell, Pro-first halt copy). Set the build-time value to "0" to fall back to
+// upsell, Pro paywall copy). Set the build-time value to "0" to fall back to
// the halt-only behaviour.
export const billingOnrampV2Enabled =
import.meta.env.VITE_BILLING_ONRAMP_V2 !== '0'
@@ -9,6 +10,13 @@ export const billingOnrampV2Enabled =
export type UsagePlanId = 'base' | 'pro' | 'max'
export type PaidPlanId = Exclude<UsagePlanId, 'base'>
+// The one plan new customers can buy. Its Autumn id stays `max`; it is shown
+// as "Pro". The old $20/mo plan (Autumn id `pro`) is retired: it shows as
+// "Pro (legacy)" to its existing subscribers and is never offered to anyone
+// else. Top-ups are no longer sold.
+export const UPGRADE_PLAN = 'max' as const satisfies PaidPlanId
+export type UpgradePlanId = typeof UPGRADE_PLAN
+
export const PLAN_OFFERS: Record<
PaidPlanId,
{ priceUsd: number; creditsUsd: number }
@@ -17,6 +25,18 @@ export const PLAN_OFFERS: Record<
max: { priceUsd: 200, creditsUsd: 2000 },
}
+export const PLAN_NAMES: Record<UsagePlanId, string> = USAGE_PLAN_NAMES
+
+export const UPGRADE_OFFER = PLAN_OFFERS[UPGRADE_PLAN]
+
+// "Pro ($200/mo)": how every upgrade prompt names the plan to buy.
+export const UPGRADE_PLAN_LABEL = `${PLAN_NAMES[UPGRADE_PLAN]} ($${UPGRADE_OFFER.priceUsd}/mo)`
+
+// The free-tier paywall, the same on every surface. It does not state the
+// grant amount: that is still $5 today and changes in a later step.
+export const FREE_CREDITS_USED = "You've used your free credits."
+export const FREE_CREDITS_PAYWALL = `${FREE_CREDITS_USED} Upgrade to ${UPGRADE_PLAN_LABEL} to keep going, or to use your own Claude or ChatGPT subscription.`
+
// Monthly grant per plan; the base grant is the signup allowance.
export const BASE_GRANT_CENTS = 500
const PLAN_GRANT_CENTS: Record<UsagePlanId, number> = {
@@ -30,14 +50,33 @@ export function lowCreditThresholdCents(plan: UsagePlanId): number {
return Math.round(PLAN_GRANT_CENTS[plan] * LOW_CREDIT_FRACTION)
}
-export function upgradePlanFor(plan: UsagePlanId): PaidPlanId {
- return plan === 'pro' ? 'max' : 'pro'
+// The plan an org is prompted to upgrade to: always the $200 Pro, from Free
+// and from legacy Pro alike. null when the org is already on it.
+export function upgradePlanFor(plan: UsagePlanId): UpgradePlanId | null {
+ return plan === UPGRADE_PLAN ? null : UPGRADE_PLAN
}
-export function upgradeHref(plan: PaidPlanId): string {
+export function upgradeHref(plan: PaidPlanId = UPGRADE_PLAN): string {
return `/billing?plan=${plan}`
}
+// Paid plans an org may pick on the Billing page: the $200 Pro for everyone,
+// plus legacy Pro only for an org already subscribed to it.
+export function selectablePaidPlans(current: UsagePlanId): PaidPlanId[] {
+ return current === 'pro' ? ['pro', UPGRADE_PLAN] : [UPGRADE_PLAN]
+}
+
+// `?plan=` deep link → the plan whose checkout to open. Older links (and
+// agent transcripts) still carry `plan=pro`; for anyone not on legacy Pro they
+// mean "upgrade", so they open the $200 Pro. Never opens legacy Pro checkout.
+export function deepLinkedPlanFor(
+ requested: string | null,
+ current: UsagePlanId,
+): UpgradePlanId | null {
+ if (requested !== 'pro' && requested !== 'max') return null
+ return current === UPGRADE_PLAN ? null : UPGRADE_PLAN
+}
+
export function formatUsd(cents: number): string {
return `$${(cents / 100).toFixed(2)}`
}
@@ -88,7 +127,6 @@ export function attributedSurface(): UpsellSurface | undefined {
export function trackCheckoutStarted(props: {
plan?: PaidPlanId
- topupUsd?: number
usagePlan?: UsagePlanId
}): void {
posthog.capture('checkout_started', {
@@ -99,7 +137,6 @@ export function trackCheckoutStarted(props: {
export function trackPlanActivated(props: {
plan?: PaidPlanId
- topupUsd?: number
usagePlan?: UsagePlanId
}): void {
posthog.capture('plan_activated', { ...props, surface: attributedSurface() })
diff --git a/web/src/lib/plan-label.test.ts b/web/src/lib/plan-label.test.ts
index fa30ff8e..06637c6b 100644
--- a/web/src/lib/plan-label.test.ts
+++ b/web/src/lib/plan-label.test.ts
@@ -1,5 +1,9 @@
import { describe, expect, it } from 'vitest'
-import { organizationPlanLabel, planLabel } from '@/lib/plan-label'
+import {
+ organizationPlanLabel,
+ planLabel,
+ usagePlanLabel,
+} from '@/lib/plan-label'
describe('planLabel', () => {
it.each([
@@ -16,6 +20,17 @@ describe('planLabel', () => {
})
})
+describe('usagePlanLabel', () => {
+ it.each([
+ ['base', 'Free'],
+ ['pro', 'Pro (legacy)'],
+ ['max', 'Pro'],
+ ['enterprise_custom', 'Enterprise Custom'],
+ ])('names usage plan %s as %s', (plan, label) => {
+ expect(usagePlanLabel(plan)).toBe(label)
+ })
+})
+
describe('organizationPlanLabel', () => {
const org = { plan: 'free' }
@@ -31,7 +46,17 @@ describe('organizationPlanLabel', () => {
usagePlan: 'max',
},
),
- ).toBe('Max')
+ ).toBe('Pro')
+ })
+
+ it('labels the retired $20 plan as legacy and the free plan as Free', () => {
+ const autumnBilling = { plan: 'free', billingProvider: 'autumn' }
+ expect(
+ organizationPlanLabel(org, autumnBilling, { usagePlan: 'pro' }),
+ ).toBe('Pro (legacy)')
+ expect(
+ organizationPlanLabel(org, autumnBilling, { usagePlan: 'base' }),
+ ).toBe('Free')
})
it('uses the standard billing plan for legacy billing', () => {
diff --git a/web/src/lib/plan-label.ts b/web/src/lib/plan-label.ts
index 13d4a1e9..aa202da8 100644
--- a/web/src/lib/plan-label.ts
+++ b/web/src/lib/plan-label.ts
@@ -1,3 +1,17 @@
+// Display names of the Autumn usage plans. `max` ($200/mo) is sold as "Pro";
+// the retired $20/mo plan (id `pro`) is "Pro (legacy)" for its subscribers.
+export const USAGE_PLAN_NAMES: Record<'base' | 'pro' | 'max', string> = {
+ base: 'Free',
+ pro: 'Pro (legacy)',
+ max: 'Pro',
+}
+
+export function usagePlanLabel(plan: string): string {
+ return plan === 'base' || plan === 'pro' || plan === 'max'
+ ? USAGE_PLAN_NAMES[plan]
+ : planLabel(plan)
+}
+
export function planLabel(plan: string): string {
return plan
.split('_')
@@ -24,7 +38,7 @@ export function organizationPlanLabel(
autumn: AutumnPlanSource | undefined,
): string {
if (billing?.billingProvider === 'autumn') {
- return planLabel(autumn?.usagePlan ?? 'base')
+ return usagePlanLabel(autumn?.usagePlan ?? 'base')
}
return planLabel(billing?.plan ?? org?.plan ?? 'free')
diff --git a/web/src/lib/session-turns.ts b/web/src/lib/session-turns.ts
index b5b469f7..4f51a5a8 100644
--- a/web/src/lib/session-turns.ts
+++ b/web/src/lib/session-turns.ts
@@ -76,7 +76,7 @@ export function httpRequestPayloadText(ev: SessionEvent): string | null {
}
// The runtime's failPreExec emits an agent.message tagged with an
-// insufficient_credits code so the UI can offer a "top up" affordance.
+// insufficient_credits code so the UI can offer the upgrade-to-Pro paywall.
export function isOutOfCredits(ev: SessionEvent): boolean {
return (
ev.type === 'agent.message' &&
diff --git a/web/src/managed-agents/BYOK.tsx b/web/src/managed-agents/BYOK.tsx
index 7b7f214b..aaebc7b9 100644
--- a/web/src/managed-agents/BYOK.tsx
+++ b/web/src/managed-agents/BYOK.tsx
@@ -21,7 +21,8 @@ import {
type ProjectEnvironmentMode,
} from './project-context'
import {
- PLAN_OFFERS,
+ UPGRADE_PLAN,
+ UPGRADE_PLAN_LABEL,
trackUpsellClicked,
trackUpsellShown,
upgradeHref,
@@ -82,7 +83,7 @@ export function ManagedProjectBYOK({
const planEligible = hasBYOKPlanAccess(usagePlan)
const showGate = !billing.isLoading && !billing.isError && !planEligible
useEffect(() => {
- if (showGate) trackUpsellShown({ surface: 'byok_gate', plan: 'pro' })
+ if (showGate) trackUpsellShown({ surface: 'byok_gate', plan: UPGRADE_PLAN })
}, [showGate])
const billingLoading =
billing.isLoading ||
@@ -193,16 +194,19 @@ export function ManagedProjectBYOK({
<EmptyState
icon={LockKeyhole}
title="BYOK is available on Pro"
- description={`Bring your own provider keys and route this project's models through them. Pro is $${PLAN_OFFERS.pro.priceUsd}/mo and includes $${PLAN_OFFERS.pro.creditsUsd} in credits every month.`}
+ description={`Bring your own provider keys and route this project's models through them. Available on ${UPGRADE_PLAN_LABEL}, which also lets you use your own Claude or ChatGPT subscription.`}
action={
<Button asChild>
<Link
- to={upgradeHref('pro')}
+ to={upgradeHref()}
onClick={() =>
- trackUpsellClicked({ surface: 'byok_gate', plan: 'pro' })
+ trackUpsellClicked({
+ surface: 'byok_gate',
+ plan: UPGRADE_PLAN,
+ })
}
>
- Upgrade to Pro — ${PLAN_OFFERS.pro.priceUsd}/mo
+ Upgrade to {UPGRADE_PLAN_LABEL}
</Link>
</Button>
}
diff --git a/web/src/managed-agents/Detail.tsx b/web/src/managed-agents/Detail.tsx
index 93bc04bd..c0398962 100644
--- a/web/src/managed-agents/Detail.tsx
+++ b/web/src/managed-agents/Detail.tsx
@@ -76,8 +76,9 @@ import { useLiveSessionEvents } from './use-live-session-events'
import { PostSessionUpsell } from '@/components/post-session-upsell'
import { useCreditState } from '@/hooks/useCreditState'
import {
- PLAN_OFFERS,
- billingOnrampV2Enabled,
+ FREE_CREDITS_USED,
+ UPGRADE_PLAN,
+ UPGRADE_PLAN_LABEL,
trackUpsellClicked,
upgradeHref,
} from '@/lib/billing-onramp'
@@ -517,32 +518,22 @@ function PlaygroundChat({
) : null}
{halted ? (
<p className="text-destructive mb-2 text-xs">
- Out of credits — this agent can&apos;t run until you{' '}
+ {FREE_CREDITS_USED}{' '}
<Link
- to={upgradeHref(credits.upgradePlan)}
+ to={upgradeHref()}
className="font-medium underline"
onClick={() =>
trackUpsellClicked({
surface: 'session_composer',
- plan: credits.upgradePlan,
+ plan: UPGRADE_PLAN,
usagePlan: credits.usagePlan,
creditsRemainingCents: credits.creditsRemainingCents,
})
}
>
- upgrade to {credits.upgradePlan === 'max' ? 'Max' : 'Pro'} — $
- {PLAN_OFFERS[credits.upgradePlan].priceUsd}/mo
- </Link>
- {billingOnrampV2Enabled ? (
- <>
- {' '}
- or{' '}
- <Link to="/billing" className="underline">
- top up
- </Link>
- </>
- ) : null}
- .
+ Upgrade to {UPGRADE_PLAN_LABEL}
+ </Link>{' '}
+ to keep going, or to use your own Claude or ChatGPT subscription.
</p>
) : error ? (
<p className="text-destructive mb-2 text-xs">{error.message}</p>
diff --git a/web/src/pages/Billing.tsx b/web/src/pages/Billing.tsx
index 9b576ed6..f535999e 100644
--- a/web/src/pages/Billing.tsx
+++ b/web/src/pages/Billing.tsx
@@ -9,7 +9,6 @@ import {
autumnBillingPortal,
autumnSubscribeConcurrency,
autumnSubscribeUsagePlan,
- autumnTopup,
billingPortal,
billingSetup,
getAutumnBilling,
@@ -35,10 +34,19 @@ import { ConfirmDialog } from '@/components/confirm-dialog'
import { ResourceTable, type Column } from '@/components/resource-table'
import { cn } from '@/lib/utils'
import {
+ FREE_CREDITS_PAYWALL,
+ PLAN_NAMES,
+ PLAN_OFFERS,
+ UPGRADE_PLAN,
+ UPGRADE_PLAN_LABEL,
billingOnrampV2Enabled,
+ deepLinkedPlanFor,
+ selectablePaidPlans,
trackCheckoutStarted,
trackPlanActivated,
trackUpsellShown,
+ type PaidPlanId,
+ type UsagePlanId,
} from '@/lib/billing-onramp'
type Tab = 'usage' | 'invoices'
@@ -249,38 +257,52 @@ function PlanTab() {
/* ── Prepaid (Autumn) ─────────────────────────────────────────────────────── */
-const TOPUP_AMOUNTS = billingOnrampV2Enabled ? [10, 25, 100] : [5, 25, 100]
-const DEFAULT_TOPUP = billingOnrampV2Enabled ? 10 : 25
-
const CONCURRENCY_TIERS = [
{ id: 'concurrency_pro', label: 'Pro', limit: 100, price: 150 },
{ id: 'concurrency_pro_plus', label: 'Pro+', limit: 600, price: 500 },
{ id: 'concurrency_pro_plus_plus', label: 'Pro++', limit: 1000, price: 1000 },
]
-const USAGE_PLANS = [
+// Plans on the Billing page. `max` is the one plan on sale, shown as "Pro".
+// The retired $20 plan (id `pro`, "Pro (legacy)") is listed only to orgs
+// already subscribed to it; see selectablePaidPlans.
+const USAGE_PLANS: Array<{
+ id: UsagePlanId
+ label: string
+ price: number
+ credits: number | null
+ description: string
+}> = [
{
id: 'base',
- label: 'Usage',
+ label: PLAN_NAMES.base,
price: 0,
credits: null,
- description: 'No subscription. Add prepaid credits whenever you need them.',
+ description: 'Free credits to get started. Upgrade when they run out.',
},
{
id: 'pro',
- label: 'Pro',
- price: 20,
- credits: 200,
- description: '$200 in shared credits added every month.',
+ label: PLAN_NAMES.pro,
+ price: PLAN_OFFERS.pro.priceUsd,
+ credits: PLAN_OFFERS.pro.creditsUsd,
+ description: `$${PLAN_OFFERS.pro.creditsUsd} in shared credits added every month. No longer offered to new customers.`,
},
{
id: 'max',
- label: 'Max',
- price: 200,
- credits: 2000,
- description: '$2,000 in shared credits added every month.',
+ label: PLAN_NAMES.max,
+ price: PLAN_OFFERS.max.priceUsd,
+ credits: PLAN_OFFERS.max.creditsUsd,
+ description: `$${PLAN_OFFERS.max.creditsUsd.toLocaleString()} in shared credits added every month. Use your own Claude or ChatGPT subscription.`,
},
-] as const
+]
+
+// The plans shown to an org: Free, Pro, and legacy Pro only for its subscribers.
+function visibleUsagePlans(current: UsagePlanId) {
+ const paid = selectablePaidPlans(current)
+ return USAGE_PLANS.filter(
+ (plan) => plan.id === 'base' || paid.includes(plan.id),
+ )
+}
function formatCreditAmount(cents: number) {
return `$${(cents / 100).toFixed(2)}`
@@ -300,32 +322,24 @@ function PrepaidPlan() {
const redirectedPlan = searchParams.get('usage-plan')
const pendingUsagePlan =
redirectedPlan === 'pro' || redirectedPlan === 'max' ? redirectedPlan : null
- // `?plan=pro|max` (upsell deep link) opens the upgrade confirmation directly.
- const requestedPlan = searchParams.get('plan')
- const deepLinkedPlan =
- billingOnrampV2Enabled &&
- (requestedPlan === 'pro' || requestedPlan === 'max')
- ? requestedPlan
- : null
const activationToastShown = useRef(false)
const { data: autumn, isLoading } = useQuery({
queryKey: ['autumn-billing'],
queryFn: getAutumnBilling,
refetchInterval: pendingUsagePlan != null ? 1_500 : 30_000,
})
- const [amount, setAmount] = useState(DEFAULT_TOPUP)
- const [confirmTopup, setConfirmTopup] = useState(false)
+ // `?plan=` (upsell deep link) opens the Pro ($200) upgrade confirmation
+ // directly. Old `?plan=pro` links open it too; legacy Pro is never offered.
+ const deepLinkedPlan =
+ billingOnrampV2Enabled && autumn
+ ? deepLinkedPlanFor(searchParams.get('plan'), autumn.usagePlan)
+ : null
const [confirmPlanId, setConfirmPlanId] = useState<string | null>(null)
- const [confirmUsagePlanId, setConfirmUsagePlanId] = useState<
- 'pro' | 'max' | null
- >(null)
+ const [confirmUsagePlanId, setConfirmUsagePlanId] =
+ useState<PaidPlanId | null>(null)
// While `?plan=` is in the URL it drives the dialog; closing it clears the
// param so the same link can reopen it later.
- const openUsagePlanId =
- confirmUsagePlanId ??
- (deepLinkedPlan && autumn && autumn.usagePlan !== deepLinkedPlan
- ? deepLinkedPlan
- : null)
+ const openUsagePlanId = confirmUsagePlanId ?? deepLinkedPlan
const clearDeepLink = () => {
if (!searchParams.has('plan')) return
const next = new URLSearchParams(searchParams)
@@ -356,7 +370,7 @@ function PrepaidPlan() {
return
if (!activationToastShown.current) {
- const label = pendingUsagePlan === 'pro' ? 'Pro' : 'Max'
+ const label = PLAN_NAMES[pendingUsagePlan]
toast.success(`${label} plan activated`, {
description: 'Your monthly credits are ready to use.',
})
@@ -374,17 +388,6 @@ function PrepaidPlan() {
if (data.url) window.location.href = data.url
else void queryClient.invalidateQueries({ queryKey: ['autumn-billing'] })
}
- const topupMutation = useMutation({
- mutationFn: () => autumnTopup(amount),
- onSuccess: (d) => {
- setConfirmTopup(false)
- trackCheckoutStarted({ topupUsd: amount, usagePlan: autumn?.usagePlan })
- if (!d.url)
- trackPlanActivated({ topupUsd: amount, usagePlan: autumn?.usagePlan })
- onPurchase(d)
- },
- onError: (e) => notifyError("Couldn't complete the top-up.", e),
- })
const concurrencyPlanMutation = useMutation({
mutationFn: (plan: string) => autumnSubscribeConcurrency(plan),
onSuccess: (d) => {
@@ -399,7 +402,7 @@ function PrepaidPlan() {
closeUsagePlanDialog()
trackCheckoutStarted({ plan, usagePlan: autumn?.usagePlan })
if (!d.url) {
- const label = plan === 'pro' ? 'Pro' : 'Max'
+ const label = PLAN_NAMES[plan]
toast.success(`${label} plan updated`, {
description: 'Your billing status and credits are refreshing.',
})
@@ -447,7 +450,7 @@ function PrepaidPlan() {
<CircleCheck className="text-status-running mt-0.5 size-5 shrink-0" />
<div>
<h2 className="text-sm font-semibold">
- Activating {pendingUsagePlan === 'pro' ? 'Pro' : 'Max'}…
+ Activating {PLAN_NAMES[pendingUsagePlan]}…
</h2>
<p className="text-muted-foreground mt-1 text-sm">
Payment completed. We are waiting for the plan and monthly
@@ -487,7 +490,7 @@ function PrepaidPlan() {
<p className="font-medium">
{autumn?.usagePlan === 'base'
? 'Signup credits'
- : `${autumn?.usagePlan === 'max' ? 'Max' : 'Pro'} plan credits`}
+ : `${PLAN_NAMES[autumn?.usagePlan ?? 'max']} plan credits`}
</p>
<p className="text-muted-foreground mt-0.5 text-xs">
{creditBreakdown.planResetsAt
@@ -535,63 +538,28 @@ function PrepaidPlan() {
<CircleAlert className="size-4 shrink-0" />
{autumn?.usagePlan === 'pro' || autumn?.usagePlan === 'max'
? 'Credits exhausted — agents are running on an open-weight model (GLM)'
- : 'Credits exhausted — your agent sessions are paused'}
+ : FREE_CREDITS_PAYWALL}
</p>
- {billingOnrampV2Enabled && autumn?.usagePlan !== 'max' ? (
+ {autumn?.usagePlan !== UPGRADE_PLAN ? (
<Button
size="sm"
- onClick={() =>
- setConfirmUsagePlanId(
- autumn?.usagePlan === 'pro' ? 'max' : 'pro',
- )
- }
+ onClick={() => setConfirmUsagePlanId(UPGRADE_PLAN)}
>
- {autumn?.usagePlan === 'pro'
- ? 'Upgrade to Max — $200/mo'
- : 'Upgrade to Pro — $20/mo for $200 credits'}
+ Upgrade to {UPGRADE_PLAN_LABEL}
</Button>
) : null}
</div>
) : null}
-
- <div className="mt-5">
- <p className="text-muted-foreground mb-2.5 text-sm">
- Add credits (billed at the same per-second rates)
- </p>
- <div className="mb-3 flex flex-wrap items-center gap-2">
- {TOPUP_AMOUNTS.map((a) => (
- <Button
- key={a}
- variant={amount === a ? 'default' : 'outline'}
- size="sm"
- className="font-mono"
- onClick={() => setAmount(a)}
- >
- ${a}
- </Button>
- ))}
- <Input
- type="number"
- min={1}
- value={amount}
- onChange={(e) =>
- setAmount(
- Math.max(1, Math.floor(Number(e.target.value) || 0)),
- )
- }
- className="w-24 font-mono"
- />
- </div>
- <Button disabled={amount < 1} onClick={() => setConfirmTopup(true)}>
- Top up ${amount}
- </Button>
- </div>
</Panel>
- <AutoTopupCard
- current={autumn?.autoTopup ?? null}
- hasToppedUp={autumn?.hasToppedUp ?? false}
- />
+ {/* Top-ups are no longer sold. An org that already turned on
+ automatic top-up keeps the card so it can change or turn it off. */}
+ {autumn?.autoTopup?.enabled ? (
+ <AutoTopupCard
+ current={autumn.autoTopup}
+ hasToppedUp={autumn.hasToppedUp}
+ />
+ ) : null}
{hasCard ? (
<Panel className="p-6">
@@ -649,15 +617,6 @@ function PrepaidPlan() {
)}
</div>
- <ConfirmDialog
- open={confirmTopup}
- onOpenChange={(o) => !o && setConfirmTopup(false)}
- title="Confirm top-up"
- description={`Add $${amount} in prepaid credits. If a payment method is on file you'll be charged $${amount} now; otherwise you'll continue to checkout to add one.`}
- confirmLabel={`Top up $${amount}`}
- pending={topupMutation.isPending}
- onConfirm={() => topupMutation.mutate()}
- />
<ConfirmDialog
open={!!tier}
onOpenChange={(o) => !o && setConfirmPlanId(null)}
@@ -702,8 +661,8 @@ function UsagePlanCard({
onManage,
managing,
}: {
- currentPlan: 'base' | 'pro' | 'max'
- onSelectPlan: (plan: 'pro' | 'max') => void
+ currentPlan: UsagePlanId
+ onSelectPlan: (plan: PaidPlanId) => void
onManage: () => void
managing: boolean
}) {
@@ -713,11 +672,16 @@ function UsagePlanCard({
<h2 className="text-sm font-semibold">Plan</h2>
<p className="text-muted-foreground mt-1 text-sm">
Monthly credits are shared by serverless-agent sessions and sandboxes.
- Top-ups stack with every plan.
</p>
</div>
- <div className="grid gap-3 md:grid-cols-3">
- {USAGE_PLANS.map((plan) => {
+ <div
+ className={cn(
+ 'grid gap-3',
+ currentPlan === 'pro' ? 'md:grid-cols-3' : 'md:grid-cols-2',
+ )}
+ >
+ {visibleUsagePlans(currentPlan).map((plan) => {
+ const planId = plan.id
const current = plan.id === currentPlan
return (
<div key={plan.id} className="rounded-md border p-4">
@@ -751,7 +715,7 @@ function UsagePlanCard({
Manage subscription
</Button>
)
- ) : plan.id === 'base' ? (
+ ) : planId === 'base' ? (
<Button
className="mt-4 w-full"
variant="outline"
@@ -764,9 +728,9 @@ function UsagePlanCard({
<Button
className="mt-4 w-full"
variant="outline"
- onClick={() => onSelectPlan(plan.id)}
+ onClick={() => onSelectPlan(planId)}
>
- {currentPlan === 'base' ? 'Upgrade' : 'Switch plan'}
+ {plan.id === UPGRADE_PLAN ? 'Upgrade' : 'Switch plan'}
</Button>
)}
</div>
diff --git a/web/src/pages/SessionDetail.tsx b/web/src/pages/SessionDetail.tsx
index ab60e4b3..7e0973a3 100644
--- a/web/src/pages/SessionDetail.tsx
+++ b/web/src/pages/SessionDetail.tsx
@@ -14,6 +14,11 @@ import {
import { GuidedTour, type GuideStep } from '@/components/guided-tour'
import { notifyError } from '@/lib/errors'
import { useHalted } from '@/hooks/useHalted'
+import {
+ FREE_CREDITS_USED,
+ UPGRADE_PLAN_LABEL,
+ upgradeHref,
+} from '@/lib/billing-onramp'
import {
getSession,
getSessionSources,
@@ -626,14 +631,15 @@ for await (const event of session.events()) {
<div className="text-destructive mb-2 flex items-center gap-1.5 text-xs">
<CircleAlert className="size-3.5 shrink-0" />
<span>
- Out of credits —{' '}
+ {FREE_CREDITS_USED}{' '}
<Link
- to="/billing"
+ to={upgradeHref()}
className="font-medium underline underline-offset-2"
>
- top up to resume
- </Link>
- .
+ Upgrade to {UPGRADE_PLAN_LABEL}
+ </Link>{' '}
+ to keep going, or to use your own Claude or ChatGPT
+ subscription.
</span>
</div>
)}
@@ -660,7 +666,7 @@ for await (const event of session.events()) {
}}
placeholder={
halted
- ? 'Out of credits — top up to resume'
+ ? `${FREE_CREDITS_USED} Upgrade to ${UPGRADE_PLAN_LABEL} to resume.`
: canSteer
? 'Send a message to steer the session…'
: 'Session archived'
diff --git a/web/src/pages/Sessions.tsx b/web/src/pages/Sessions.tsx
index 0f40a206..876f34db 100644
--- a/web/src/pages/Sessions.tsx
+++ b/web/src/pages/Sessions.tsx
@@ -4,6 +4,7 @@ import { Link, useNavigate } from 'react-router-dom'
import { MessagesSquare, Plus } from 'lucide-react'
import { notifyError } from '@/lib/errors'
import { useHalted } from '@/hooks/useHalted'
+import { FREE_CREDITS_USED, UPGRADE_PLAN_LABEL } from '@/lib/billing-onramp'
import { getSessions, getAgents, createSession, ApiError } from '@/api/client'
import type { Session } from '@/api/client'
import { PageHeader } from '@/components/page-header'
@@ -35,6 +36,7 @@ import {
usageDisclosure,
} from '@/lib/usage'
+const HALTED_TITLE = `${FREE_CREDITS_USED} Upgrade to ${UPGRADE_PLAN_LABEL} to resume.`
export default function Sessions() {
const navigate = useNavigate()
const queryClient = useQueryClient()
@@ -205,7 +207,7 @@ export default function Sessions() {
<Button
onClick={openStart}
disabled={halted}
- title={halted ? 'Out of credits — top up to resume' : undefined}
+ title={halted ? HALTED_TITLE : undefined}
>
<Plus className="size-4" />
Start session
@@ -229,9 +231,7 @@ export default function Sessions() {
size="sm"
onClick={openStart}
disabled={halted}
- title={
- halted ? 'Out of credits — top up to resume' : undefined
- }
+ title={halted ? HALTED_TITLE : undefined}
>
<Plus className="size-4" />
Start session