feat(story-3.5): add cloud-mode LLM model selection with token quota enforcement

Implement system-managed model catalog, subscription tier enforcement,
atomic token quota tracking, and frontend cloud/self-hosted conditional
rendering. Apply all 20 BMAD code review patches including security
fixes (cross-user API key hijack), race condition mitigation (atomic SQL
UPDATE), and SSE mid-stream quota error handling.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
This commit is contained in:
Vonic 2026-04-14 17:01:21 +07:00
parent e7382b26de
commit c1776b3ec8
19 changed files with 1003 additions and 34 deletions

View file

@ -166,6 +166,27 @@ export const globalNewLLMConfig = z.object({
export const getGlobalNewLLMConfigsResponse = z.array(globalNewLLMConfig);
// =============================================================================
// System Model Catalog (cloud mode — backend-managed LLMs)
// =============================================================================
/**
* SystemModelItem a backend-managed LLM exposed via GET /api/v1/models/system
* id is negative (e.g. -1, -2, ), distinct from user configs (positive) and Auto mode (0)
*/
export const systemModelItem = z.object({
id: z.number(),
name: z.string(),
description: z.string().nullable().optional(),
provider: z.string(),
model_name: z.string(),
tier_required: z.string().default("free"),
});
export const getSystemModelsResponse = z.array(systemModelItem);
export type SystemModelItem = z.infer<typeof systemModelItem>;
// =============================================================================
// Image Generation Config (separate table from NewLLMConfig)
// =============================================================================