refactor: remove the billing tier model (P0.1)
The community edition has no monetization (ADR-0001). Remove the tier model (packages/shared/src/tiers.ts), the requireTier middleware and every tier gate, GET/PATCH /api/tier and the trial start, and the Stripe integration, which depends on the tier model. Personal features a tier used to limit are open to everyone: unlimited workspaces and connectors, every embedding provider including LiteLLM, per-workspace costs, Approvals. The workspace session cap is one constant (100). Team and enterprise surfaces are hidden instead of unlocked (team dock zone, Settings Team/Enterprise/Plan tabs, workspace Team tab); cloud sync reports unavailable, as it did for free users. The sidecar ignores the tier keys in config.json but does not delete them: both editions may still share ~/.waggle. Web billing UI is deleted: plan cards, upgrade and trial modals, payment success route, the KVARK sales block, tier 403 handling.
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
* The read side (`GET /api/embedding/status`) and reprobe
|
||||
* (`POST /api/embedding/reprobe`) live inline in local/index.ts, where they have
|
||||
* closure access to the boot-time embedding config. This plugin owns
|
||||
* `POST /api/embedding/provider`: validate → tier-gate → persist the choice.
|
||||
* `POST /api/embedding/provider`: validate → persist the choice. Every provider is
|
||||
* selectable (ADR-0001).
|
||||
*
|
||||
* Hot-swap note: the live embedder is created once at boot and threaded BY
|
||||
* REFERENCE into the Orchestrator, mind search, and the vector-backfill path.
|
||||
@@ -19,8 +20,7 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import type { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
||||
import { z } from 'zod';
|
||||
import { WaggleConfig, getMinimumTierForProvider, type EmbeddingProviderType } from '@waggle/core';
|
||||
import { TIER_CAPABILITIES, parseTier, getEffectiveTier, type Tier } from '@waggle/shared';
|
||||
import { WaggleConfig } from '@waggle/core';
|
||||
import { validateBody } from '../../validate-body.js';
|
||||
|
||||
/**
|
||||
@@ -35,19 +35,6 @@ const setProviderSchema = z.object({
|
||||
provider: z.enum(SELECTABLE_PROVIDERS),
|
||||
});
|
||||
|
||||
/** Effective tier from config.json (mirrors settings.ts readTierConfig + trial resolution). */
|
||||
function readEffectiveTier(dataDir: string): Tier {
|
||||
try {
|
||||
const configPath = path.join(dataDir, 'config.json');
|
||||
if (fs.existsSync(configPath)) {
|
||||
const raw = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
||||
const parsed = parseTier(String(raw.tier ?? '')) ?? 'FREE';
|
||||
return getEffectiveTier(parsed, raw.trialStartedAt ?? null);
|
||||
}
|
||||
} catch { /* fall through to FREE */ }
|
||||
return 'FREE';
|
||||
}
|
||||
|
||||
/** True when EMBEDDING_PROVIDER env var is set — it wins over the persisted choice. */
|
||||
function envOverrideProvider(): string | null {
|
||||
const v = process.env.EMBEDDING_PROVIDER?.trim();
|
||||
@@ -103,22 +90,6 @@ export const embeddingRoutes: FastifyPluginAsync = async (server) => {
|
||||
});
|
||||
}
|
||||
|
||||
// Tier gate — 'auto' is always allowed; an explicit provider must be in
|
||||
// the tier's allowed set (TIER_CAPABILITIES.embeddingProviders).
|
||||
if (provider !== 'auto') {
|
||||
const tier = readEffectiveTier(server.localConfig.dataDir);
|
||||
const allowed = TIER_CAPABILITIES[tier].embeddingProviders as readonly string[];
|
||||
if (!allowed.includes(provider)) {
|
||||
const requiredTier = getMinimumTierForProvider(provider as EmbeddingProviderType);
|
||||
return reply.status(403).send({
|
||||
error: 'TIER_REQUIRED',
|
||||
message: `The "${provider}" embedding provider requires the ${requiredTier} tier or higher (current: ${tier}).`,
|
||||
requiredTier,
|
||||
currentTier: tier,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Persist (setEmbeddingProvider does not save on its own).
|
||||
const config = new WaggleConfig(server.localConfig.dataDir);
|
||||
config.setEmbeddingProvider(provider);
|
||||
|
||||
Reference in New Issue
Block a user