Monthly credit metering and workflow export/import
Dshamir adds per-user monthly credit enforcement on both chat streaming routes and portable workflow files - two product features that signal the fork is targeting metered multi-tenant operation.
Credit enforcement is a new credits.ts module. Before each LLM call, checkCredits(userId) reads messageCreditsUsed and creditsResetDate from the user profile. If the reset date has passed, it resets the counter and advances the date by 30 days. If the user is at or above MONTHLY_CREDIT_LIMIT (env var, defaults to 999999 if unset), the route returns 429 with a message. After a successful stream completes, incrementCredits(userId) bumps the counter via updateMany. Both chat routes (/chat and /projects/:id/chat) got the check wired in.
Workflow export and import are two new endpoints. GET /workflows/:id/export serializes a workflow record to JSON and sends it as a .mikeworkflow.json download. POST /workflows/import reads the uploaded file and creates a new workflow for the current user. A one-line follow-up commit fixed the audit action type from "import" (not a valid enum value) to "create".
These are product-tier decisions, not infrastructure primitives. The credit module assumes UserProfile.messageCreditsUsed exists in the schema - so it only applies if you adopt the Prisma migration. The logic itself is straightforward and easy to adapt to a different storage model if needed.
Spotted something wrong? Or know the PR text has fresher detail than the writeup above?