From f4208780fdc033d2fb7ac292e64aff44a5ef9c9f Mon Sep 17 00:00:00 2001 From: Antigravity Date: Fri, 29 May 2026 12:10:31 +0000 Subject: [PATCH] fix: quota slide_generate pour tier BASIC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajoute slide_generate et excalidraw_generate dans TIER_LIMITS (BASIC: 3, PRO: 20, BUSINESS: 100, ENTERPRISE: unlimited) - run-for-note: utilise le bon feature key selon le type d'agent - slides.tool: incrémente slide_generate (pas reformulate) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- memento-note/app/api/agents/run-for-note/route.ts | 5 +++-- memento-note/lib/ai/tools/slides.tool.ts | 4 ++-- memento-note/lib/entitlements.ts | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/memento-note/app/api/agents/run-for-note/route.ts b/memento-note/app/api/agents/run-for-note/route.ts index 6789cb7..5da7d5e 100644 --- a/memento-note/app/api/agents/run-for-note/route.ts +++ b/memento-note/app/api/agents/run-for-note/route.ts @@ -44,9 +44,10 @@ export async function POST(req: NextRequest) { return NextResponse.json({ error: 'Paramètres invalides' }, { status: 400 }) } - // Quota check — slides/excalidraw generation counts as 'reformulate' credit + // Quota check — feature key depends on generation type + const featureKey = type === 'slide-generator' ? 'slide_generate' : 'excalidraw_generate' try { - await checkEntitlementOrThrow(userId, 'reformulate') + await checkEntitlementOrThrow(userId, featureKey) } catch (e) { if (e instanceof QuotaExceededError) { return NextResponse.json({ error: e.message }, { status: 402 }) diff --git a/memento-note/lib/ai/tools/slides.tool.ts b/memento-note/lib/ai/tools/slides.tool.ts index fb19442..845eca9 100644 --- a/memento-note/lib/ai/tools/slides.tool.ts +++ b/memento-note/lib/ai/tools/slides.tool.ts @@ -81,8 +81,8 @@ RULES: console.log('[Slides Tool] Canvas created:', canvas.id, '| Slides:', slides.length, '| Size:', Math.round(html.length / 1024), 'KB') - // Decrement reformulate quota (agent-based generation consumes credits) - incrementUsageAsync(ctx.userId, 'reformulate') + // Decrement slide_generate quota after successful canvas creation + incrementUsageAsync(ctx.userId, 'slide_generate') if (ctx.actionId) { await prisma.agentAction.update({ diff --git a/memento-note/lib/entitlements.ts b/memento-note/lib/entitlements.ts index 7e59863..7bc896b 100644 --- a/memento-note/lib/entitlements.ts +++ b/memento-note/lib/entitlements.ts @@ -79,6 +79,8 @@ const TIER_LIMITS: Record brainstorm_expand: 10, brainstorm_enrich: 20, suggest_charts: 5, + slide_generate: 3, + excalidraw_generate: 3, }, PRO: { semantic_search: 100, @@ -90,6 +92,8 @@ const TIER_LIMITS: Record brainstorm_expand: 100, brainstorm_enrich: 200, suggest_charts: 50, + slide_generate: 20, + excalidraw_generate: 20, }, BUSINESS: { semantic_search: 1000, @@ -101,6 +105,8 @@ const TIER_LIMITS: Record brainstorm_expand: 500, brainstorm_enrich: 1000, suggest_charts: 200, + slide_generate: 100, + excalidraw_generate: 100, }, ENTERPRISE: { semantic_search: 'unlimited', @@ -112,6 +118,8 @@ const TIER_LIMITS: Record brainstorm_expand: 'unlimited', brainstorm_enrich: 'unlimited', suggest_charts: 'unlimited', + slide_generate: 'unlimited', + excalidraw_generate: 'unlimited', }, };