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:
shumeiko.it
2026-10-15 19:31:50 +02:00
parent 369d8269c1
commit fe2eb0f648
117 changed files with 342 additions and 6424 deletions

View File

@@ -69,8 +69,7 @@ import {
} from '@waggle/agent';
import { PluginRuntimeManager, getStarterSkillsDir, validatePluginManifest } from '@waggle/sdk';
import { MarketplaceDB, MarketplaceSync, seedMcpServers, seedNewSources } from '@waggle/marketplace';
import { parseTier, type RiskLevel } from '@waggle/shared';
import { readTierFromDataDir } from '../middleware/assert-tier.js';
import type { RiskLevel } from '@waggle/shared';
import { runConnectorFetch } from './connector-harvest.js';
import { writeAutoSyncSummaryFrame } from './harvest-autosync-frame.js';
import { runLoopTick } from './loop-executor.js';
@@ -163,7 +162,6 @@ import { waggleSignalRoutes } from './routes/waggle-signals.js';
import { providerRoutes } from './routes/providers.js';
import { profileRoutes } from './routes/profile.js';
import { telemetryRoutes } from './routes/telemetry.js';
import { stripeRoutes } from '../stripe/index.js';
import { agentGroupRoutes } from './routes/agent-groups.js';
import { localJobRoutes } from './routes/jobs.js';
import { agentEntityRoutes } from './routes/agents.js';
@@ -196,8 +194,7 @@ import {
type ProactiveMessage,
} from './proactive-handlers.js';
import { generateMonthlyAssessment, saveAssessmentToMind } from './monthly-assessment.js';
import { WorkspaceSessionManager } from './workspace-sessions.js';
import { maxWorkspaceSessionsForTier } from './tier-session-cap.js';
import { MAX_WORKSPACE_SESSIONS, WorkspaceSessionManager } from './workspace-sessions.js';
import { EventEmitter } from 'node:events';
import { LocalJobStore } from './job-store.js';
import { AgentRunRegistry } from './agent-run-registry.js';
@@ -213,8 +210,6 @@ export interface LocalConfig {
instanceId?: string;
/** Governed CLI execution — allowlist of program names the agent may run. */
cli?: { allowlist?: string[] };
/** Active subscription tier, when known (drives session/feature caps). */
tier?: string;
/** True only when startService owns the LiteLLM child lifecycle. */
manageLiteLLM?: boolean;
/** Stable child-process port, retained even while requests use a fallback proxy. */
@@ -495,9 +490,6 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
&& rawDesktopBootstrapToken.length <= 200
? rawDesktopBootstrapToken
: null;
const resolvedTier = parseTier(String(fullConfig.tier ?? '')) ?? readTierFromDataDir(fullConfig.dataDir);
fullConfig.tier = resolvedTier;
const server = Fastify({ logger: false });
const localJobStore = new LocalJobStore();
server.decorate('localJobStore', localJobStore);
@@ -1289,9 +1281,8 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
// ── Workspace Session Manager ────────────────────────────────────
// Manages concurrent workspace sessions with independent minds, orchestrators,
// and tools. Cap is tied to the active tier at startup and when the tier changes.
const sessionManager = new WorkspaceSessionManager(3);
sessionManager.setMaxSessions(maxWorkspaceSessionsForTier(resolvedTier));
// and tools.
const sessionManager = new WorkspaceSessionManager(MAX_WORKSPACE_SESSIONS);
server.decorate('sessionManager', sessionManager);
/**
@@ -2893,7 +2884,6 @@ Return ONLY the improved system prompt text. No commentary, no markdown fences,
await server.register(telemetryRoutes);
await server.register(agentGroupRoutes);
await server.register(localJobRoutes);
await server.register(stripeRoutes);
await server.register(harvestRoutes);
await server.register(wikiRoutes);
await server.register(identityRoutes);