@burdenoff/microfe-botmanor 2026.1120.22 → 2026.1120.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botlit/BotmanorRootInner.js +46 -45
- package/dist/botlit/BotmanorRootInner.js.map +1 -1
- package/dist/botlit/components/PlanUsageCard.d.ts +2 -0
- package/dist/botlit/components/PlanUsageCard.js +79 -0
- package/dist/botlit/components/PlanUsageCard.js.map +1 -0
- package/dist/botlit/components/QuotaExhaustedDialog.d.ts +14 -3
- package/dist/botlit/components/QuotaExhaustedDialog.js +33 -13
- package/dist/botlit/components/QuotaExhaustedDialog.js.map +1 -1
- package/dist/botlit/hooks/usePlanUsage.d.ts +19 -0
- package/dist/botlit/hooks/usePlanUsage.js +45 -0
- package/dist/botlit/hooks/usePlanUsage.js.map +1 -0
- package/dist/botlit/pages/BotDetailPage.js +4 -4
- package/dist/botlit/pages/DashboardPage.js +151 -149
- package/dist/botlit/pages/DashboardPage.js.map +1 -1
- package/dist/botlit/providers/QuotaGuard.d.ts +2 -0
- package/dist/botlit/providers/QuotaGuard.js +51 -0
- package/dist/botlit/providers/QuotaGuard.js.map +1 -0
- package/dist/botlit/providers/quotaGuardContext.d.ts +11 -0
- package/dist/botlit/providers/quotaGuardContext.js +9 -0
- package/dist/botlit/providers/quotaGuardContext.js.map +1 -0
- package/dist/botlit/utils/quotaErrors.d.ts +48 -0
- package/dist/botlit/utils/quotaErrors.js +118 -0
- package/dist/botlit/utils/quotaErrors.js.map +1 -0
- package/dist/botlit/utils/watchPlanLimits.d.ts +12 -0
- package/dist/botlit/utils/watchPlanLimits.js +27 -0
- package/dist/botlit/utils/watchPlanLimits.js.map +1 -0
- package/dist/generated/wspace-operations.d.ts +52 -0
- package/dist/generated/wspace-operations.js +60 -40
- package/dist/generated/wspace-operations.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardPage.js","names":["_Fragment","Fragment$1","NAME_TOKEN","QUICK_ACTION_CLASS","LoadingRows","label","i","QuickAction","link","Link","icon","permission","BotmanorPermissionGate","DashboardPage","t","useTr","location","useLocation","useBotlit","botsAccess","useBotmanorPermissionDecision","BOTMANOR_PERMISSIONS","agentsAccess","executionsAccess","canReadBots","canReadAgents","permissionsLoading","bots","botsLoading","botsError","botsHasMore","refetchBots","useBots","agents","agentsLoading","agentsError","agentsHasMore","refetchAgents","useAgents","botCounts","useBotAppCounts","agentCounts","useAgentCounts","recentBots","useMemo","byRecentActivity","activeAgents","agent","recentActiveAgents","noAccess","isReturning","countLabel","hasMore","formatNumber","count","botsTotal","activeAgentsTotal","agentsTotal","stats","AppWindow","Bot","executionsLabel","n","firstName","getGreetingName","currentUser","greeting","Fragment","part","index","parts","GradientText","PageLayout","Button","navigateTo","Plus","PagePurpose","Zap","Lock","Card","stat","CardContent","DashboardUsagePanel","CardHeader","CardTitle","ArrowRight","ErrorState","getPath","bot","StatusBadge","GlassCard","BookOpen","KeyRound","MessagesSquare","Headset"],"sources":["../../../src/botlit/pages/DashboardPage.tsx"],"sourcesContent":["/**\n * Dashboard Page\n * @module botlit/pages\n */\n\nimport { Fragment, useMemo, type FC, type ReactNode } from 'react';\nimport { Link, useLocation } from 'react-router';\nimport {\n AppWindow,\n Bot,\n BookOpen,\n Zap,\n ArrowRight,\n Plus,\n Headset,\n KeyRound,\n Lock,\n MessagesSquare,\n} from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { GradientText, GlassCard, PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardHeader, CardTitle, CardContent } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { StatusBadge } from '../components/Badge';\nimport { ErrorState } from '../components/ErrorState';\nimport { DashboardUsagePanel } from '../components/DashboardUsagePanel';\nimport { useBotAppCounts, useBots } from '../hooks/useBots';\nimport { useAgentCounts, useAgents } from '../hooks/useAgents';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatNumber, MISSING_VALUE } from '../utils/formatters';\nimport { byRecentActivity, getGreetingName } from '../utils/greeting';\nimport {\n BOTMANOR_PERMISSIONS,\n BotmanorPermissionGate,\n useBotmanorPermissionDecision,\n type BotmanorPermission,\n} from '../permissions';\n\n/** Placeholder swapped for the user's name so the translated sentence keeps its word order. */\nconst NAME_TOKEN = '\\u0001';\n\nconst QUICK_ACTION_CLASS =\n 'flex flex-col items-center gap-2 p-4 rounded-card border border-border-seam bg-bg-surface hover:border-border-strong hover:shadow-elevation-2 transition-[box-shadow,border-color]';\n\nconst LoadingRows: FC<{ label: string }> = ({ label }) => (\n <div className=\"space-y-3\" role=\"status\" aria-busy=\"true\" aria-label={label}>\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-16 bg-bg-sunken rounded-lg motion-safe:animate-vc-shimmer\" />\n ))}\n </div>\n);\n\ninterface QuickActionProps {\n permission?: BotmanorPermission;\n to: string | { pathname: string; search: string };\n icon: ReactNode;\n label: string;\n}\n\nconst QuickAction: FC<QuickActionProps> = ({ permission, to, icon, label }) => {\n const link = (\n <li>\n <Link to={to} className={QUICK_ACTION_CLASS}>\n {icon}\n <span className=\"text-sm font-medium\">{label}</span>\n </Link>\n </li>\n );\n return permission ? (\n <BotmanorPermissionGate permission={permission}>{link}</BotmanorPermissionGate>\n ) : (\n link\n );\n};\n\nexport const DashboardPage: FC = () => {\n const t = useTr();\n const location = useLocation();\n const { currentUser, navigateTo, getPath } = useBotlit();\n\n const botsAccess = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.APP_READ);\n const agentsAccess = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.AGENT_READ);\n const executionsAccess = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.EXECUTION_READ);\n const canReadBots = botsAccess === 'allowed';\n const canReadAgents = agentsAccess === 'allowed';\n const permissionsLoading = botsAccess === 'loading' || agentsAccess === 'loading';\n\n const {\n data: bots,\n loading: botsLoading,\n error: botsError,\n hasMore: botsHasMore,\n refetch: refetchBots,\n } = useBots();\n const {\n data: agents,\n loading: agentsLoading,\n error: agentsError,\n hasMore: agentsHasMore,\n refetch: refetchAgents,\n } = useAgents();\n\n // Exact totals come from the count queries (BOFF-12426). The paged lists\n // above only feed the \"Recent\" panels; if a count query fails the stat falls\n // back to the list length, shown with \"+\" when the list may be truncated.\n const botCounts = useBotAppCounts(canReadBots);\n const agentCounts = useAgentCounts(canReadAgents);\n\n const recentBots = useMemo(() => [...bots].sort(byRecentActivity).slice(0, 4), [bots]);\n const activeAgents = useMemo(() => agents.filter((agent) => agent.status === 'ACTIVE'), [agents]);\n const recentActiveAgents = useMemo(\n () => [...activeAgents].sort(byRecentActivity).slice(0, 4),\n [activeAgents]\n );\n\n const noAccess = !permissionsLoading && !canReadBots && !canReadAgents;\n // \"Welcome back\" is only true once the user is known to have bots or agents;\n // while loading, after an error, or for a first-time user the greeting stays neutral.\n const isReturning = (canReadBots && bots.length > 0) || (canReadAgents && agents.length > 0);\n\n /** A list that stopped at a full page is shown as \"100+\", never as an exact count. */\n const countLabel = (count: number, hasMore: boolean) =>\n hasMore ? `${formatNumber(count)}+` : formatNumber(count);\n\n // \"Total Bots\" is every bot that is not archived; \"Active Agents\" is the\n // agents whose status is ACTIVE. Both are exact when the count query answers.\n const botsTotal = botCounts.data ? botCounts.data.total - botCounts.data.archived : undefined;\n const activeAgentsTotal = agentCounts.data ? agentCounts.data.active : undefined;\n const agentsTotal = agentCounts.data\n ? agentCounts.data.total - agentCounts.data.archived\n : undefined;\n\n const stats: Array<{\n key: string;\n label: string;\n value: string;\n loading: boolean;\n icon: ReactNode;\n hero: boolean;\n }> = [];\n if (canReadBots) {\n stats.push({\n key: 'bots',\n label: t('botlit.dashboard.stats.totalBots', 'Total Bots'),\n value:\n botsTotal !== undefined\n ? formatNumber(botsTotal)\n : botsError\n ? MISSING_VALUE\n : countLabel(bots.length, botsHasMore),\n loading: botsTotal === undefined && (botCounts.loading || botsLoading),\n icon: <AppWindow className=\"h-5 w-5\" aria-hidden=\"true\" />,\n hero: true,\n });\n }\n if (canReadAgents) {\n stats.push({\n key: 'agents',\n label: t('botlit.dashboard.stats.activeAgents', 'Active Agents'),\n value:\n activeAgentsTotal !== undefined\n ? formatNumber(activeAgentsTotal)\n : agentsError\n ? MISSING_VALUE\n : countLabel(activeAgents.length, agentsHasMore),\n loading: activeAgentsTotal === undefined && (agentCounts.loading || agentsLoading),\n icon: <Bot className=\"h-5 w-5\" aria-hidden=\"true\" />,\n hero: !canReadBots,\n });\n }\n\n const executionsLabel = (count: number | null | undefined) => {\n const n = count ?? 0;\n return n === 1\n ? t('botlit.common.executionsOne', '{{count}} execution', { count: formatNumber(n) })\n : t('botlit.common.executionsOther', '{{count}} executions', { count: formatNumber(n) });\n };\n\n const firstName = getGreetingName(currentUser);\n const greetingTemplate = firstName\n ? isReturning\n ? t('botlit.dashboard.titleNamed', 'Welcome back, {{name}}', { name: NAME_TOKEN })\n : t('botlit.dashboard.welcomeNamed', 'Welcome, {{name}}', { name: NAME_TOKEN })\n : isReturning\n ? t('botlit.dashboard.title', 'Welcome back')\n : t('botlit.dashboard.welcome', 'Welcome');\n const greeting = greetingTemplate.split(NAME_TOKEN).map((part, index, parts) => (\n <Fragment key={index}>\n {part}\n {index < parts.length - 1 ? <GradientText>{firstName}</GradientText> : null}\n </Fragment>\n ));\n\n return (\n <PageLayout\n hero\n title={greeting}\n description={t(\n 'botlit.dashboard.description',\n \"Here's an overview of your AI agents and bots\"\n )}\n actions={\n <div className=\"flex gap-2\">\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_CREATE}>\n <Button leftIcon={<Bot size={16} />} onClick={() => navigateTo('agents/new')}>\n {t('botlit.dashboard.actions.createAgent', 'Create Agent')}\n </Button>\n </BotmanorPermissionGate>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_CREATE}>\n <Button\n variant=\"outline\"\n leftIcon={<Plus size={16} />}\n onClick={() => navigateTo('bots/new')}\n >\n {t('botlit.dashboard.actions.createBot', 'Create Bot')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<Zap size={18} aria-hidden=\"true\" />}>\n {t(\n 'botlit.dashboard.purpose',\n 'This is your home base — a quick pulse on every bot and agent in your workspace. Glance at the headline numbers, jump back into recent work, and use the quick actions below to start something new. If you are just getting started, create your first agent and connect it to a bot.'\n )}\n </PagePurpose>\n\n {noAccess ? (\n <div\n role=\"status\"\n className=\"flex flex-col items-center justify-center gap-3 rounded-lg border border-border-subtle bg-bg-surface px-4 py-12 text-center\"\n >\n <Lock size={28} className=\"text-text-secondary\" aria-hidden=\"true\" />\n <div>\n <h2 className=\"text-lg font-medium text-text-primary\">\n {t('botlit.dashboard.noAccess.title', 'You do not have access to this dashboard')}\n </h2>\n <p className=\"mt-2 max-w-md text-sm text-text-secondary\">\n {t(\n 'botlit.dashboard.noAccess.description',\n 'Your role in this workspace cannot view bots or agents. Ask a workspace admin for read access.'\n )}\n </p>\n </div>\n </div>\n ) : (\n <>\n {/* Stats Grid */}\n <ul\n className=\"grid grid-cols-1 md:grid-cols-2 gap-4\"\n aria-label={t('botlit.dashboard.stats.title', 'Workspace totals')}\n >\n {permissionsLoading ? (\n <li>\n <LoadingRows label={t('botlit.common.loading', 'Loading')} />\n </li>\n ) : (\n stats.map((stat) => (\n <li key={stat.key}>\n <Card treatment={stat.hero ? 'glass' : 'metric'} glow={stat.hero}>\n <CardContent className=\"pt-6\">\n <div className=\"flex items-center gap-4\">\n <div className=\"p-3 rounded-lg bg-[var(--color-accent-soft)] text-text-primary [&>svg]:text-text-primary\">\n {stat.icon}\n </div>\n {/* Label first in the DOM so screen readers announce \"Total Bots, 12\". */}\n <div className=\"flex flex-col-reverse\">\n <p className=\"text-sm text-text-secondary\">{stat.label}</p>\n {stat.loading ? (\n <div\n role=\"status\"\n aria-busy=\"true\"\n aria-label={t('botlit.common.loading', 'Loading')}\n className=\"h-8 w-12 rounded bg-bg-sunken motion-safe:animate-vc-shimmer\"\n />\n ) : (\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">\n {stat.value}\n </p>\n )}\n </div>\n </div>\n </CardContent>\n </Card>\n </li>\n ))\n )}\n </ul>\n\n {/* Runs, success rate, cost, top agents and health (BOFF-15360) */}\n {executionsAccess === 'allowed' ? <DashboardUsagePanel /> : null}\n\n {/* Main Content Grid */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n {canReadBots ? (\n <Card treatment=\"insight\">\n <CardHeader className=\"flex flex-row items-center justify-between\">\n <CardTitle as=\"h2\">\n {t('botlit.dashboard.recentBots.title', 'Recent Bots')}\n </CardTitle>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n rightIcon={<ArrowRight size={16} />}\n onClick={() => navigateTo('bots')}\n >\n {t('botlit.common.viewAll', 'View All')}\n </Button>\n </CardHeader>\n <CardContent>\n {botsLoading ? (\n <LoadingRows label={t('botlit.common.loading', 'Loading')} />\n ) : botsError ? (\n <ErrorState\n resource={t('botlit.dashboard.resource.bots', 'bots')}\n error={botsError}\n onRetry={() => void refetchBots()}\n />\n ) : recentBots.length > 0 ? (\n <ul className=\"space-y-3\">\n {recentBots.map((bot) => (\n <li key={bot.id}>\n <Link\n to={getPath(`bots/${bot.id}`)}\n className=\"flex items-center justify-between p-3 rounded-lg border border-border-seam hover:border-border-strong hover:bg-accent transition-colors\"\n >\n <div className=\"flex items-center gap-3\">\n <span className=\"text-2xl\" aria-hidden=\"true\">\n {bot.icon || '🤖'}\n </span>\n <div>\n <p className=\"font-medium text-text-primary\">{bot.name}</p>\n <p className=\"text-xs text-text-secondary\">\n {executionsLabel(bot.executionCount)}\n </p>\n </div>\n </div>\n <StatusBadge status={bot.status} />\n </Link>\n </li>\n ))}\n </ul>\n ) : (\n <div className=\"text-center py-8 text-text-secondary\">\n <AppWindow className=\"h-8 w-8 mx-auto mb-2 opacity-50\" aria-hidden=\"true\" />\n <p>{t('botlit.dashboard.recentBots.emptyTitle', 'No bots yet')}</p>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_CREATE}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"mt-3\"\n onClick={() => navigateTo('bots/new')}\n >\n {t('botlit.dashboard.recentBots.emptyAction', 'Create your first bot')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n )}\n </CardContent>\n </Card>\n ) : null}\n\n {canReadAgents ? (\n <Card treatment=\"insight\">\n <CardHeader className=\"flex flex-row items-center justify-between\">\n <CardTitle as=\"h2\">\n {t('botlit.dashboard.activeAgents.title', 'Active Agents')}\n </CardTitle>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n rightIcon={<ArrowRight size={16} />}\n onClick={() => navigateTo('agents')}\n >\n {t('botlit.common.viewAll', 'View All')}\n </Button>\n </CardHeader>\n <CardContent>\n {agentsLoading ? (\n <LoadingRows label={t('botlit.common.loading', 'Loading')} />\n ) : agentsError ? (\n <ErrorState\n resource={t('botlit.dashboard.resource.agents', 'agents')}\n error={agentsError}\n onRetry={() => void refetchAgents()}\n />\n ) : recentActiveAgents.length > 0 ? (\n <ul className=\"space-y-3\">\n {recentActiveAgents.map((agent) => (\n <li key={agent.id}>\n <Link\n to={getPath(`agents/${agent.id}`)}\n className=\"flex items-center justify-between p-3 rounded-lg border border-border-seam hover:border-border-strong hover:bg-accent transition-colors\"\n >\n <div className=\"flex items-center gap-3\">\n <span className=\"relative text-2xl\">\n <span aria-hidden=\"true\">🤖</span>\n <span\n aria-hidden=\"true\"\n className=\"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-status-success-text motion-safe:animate-vc-glow-pulse\"\n />\n </span>\n <div>\n <p className=\"font-medium text-text-primary\">{agent.name}</p>\n <p className=\"text-xs text-text-secondary\">\n <span className=\"sr-only\">\n {t('botlit.status.active', 'Active')}.{' '}\n </span>\n {executionsLabel(agent.executionCount)}\n </p>\n </div>\n </div>\n </Link>\n </li>\n ))}\n </ul>\n ) : (\n <div className=\"text-center py-8 text-text-secondary\">\n <Bot className=\"h-8 w-8 mx-auto mb-2 opacity-50\" aria-hidden=\"true\" />\n {agents.length === 0 ? (\n <>\n <p>{t('botlit.dashboard.activeAgents.emptyTitle', 'No agents yet')}</p>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_CREATE}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"mt-3\"\n onClick={() => navigateTo('agents/new')}\n >\n {t(\n 'botlit.dashboard.activeAgents.emptyAction',\n 'Create your first agent'\n )}\n </Button>\n </BotmanorPermissionGate>\n </>\n ) : (\n <>\n <p>\n {activeAgentsTotal !== undefined && activeAgentsTotal > 0\n ? t(\n 'botlit.dashboard.activeAgents.activeElsewhere',\n '{{count}} active agents',\n { count: formatNumber(activeAgentsTotal) }\n )\n : t(\n 'botlit.dashboard.activeAgents.noneActive',\n '{{count}} agents, none active',\n {\n count:\n agentsTotal !== undefined\n ? formatNumber(agentsTotal)\n : countLabel(agents.length, agentsHasMore),\n }\n )}\n </p>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"mt-3\"\n onClick={() => navigateTo('agents')}\n >\n {t('botlit.dashboard.activeAgents.viewAgents', 'Review agents')}\n </Button>\n </>\n )}\n </div>\n )}\n </CardContent>\n </Card>\n ) : null}\n </div>\n\n {/* Quick Actions, in setup order: knowledge → model → agent → bot */}\n <GlassCard treatment=\"plain\" className=\"border-border-seam p-6\">\n <h2 className=\"text-lg font-semibold tracking-tight text-text-primary\">\n {t('botlit.dashboard.quickActions.title', 'Quick Actions')}\n </h2>\n <ul className=\"mt-4 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4\">\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.KNOWLEDGE_CREATE}\n to={getPath('knowledge/new')}\n icon={<BookOpen className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.quickActions.addKnowledge', 'Add Knowledge')}\n />\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.LLM_CREATE}\n to={getPath('settings')}\n icon={<KeyRound className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.quickActions.connectModel', 'Connect LLM Provider')}\n />\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.AGENT_CREATE}\n to={getPath('agents/new')}\n icon={<Bot className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.actions.createAgent', 'Create Agent')}\n />\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.APP_CREATE}\n to={getPath('bots/new')}\n icon={<AppWindow className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.actions.createBot', 'Create Bot')}\n />\n {/* Conversations is its own app mounted at /conversations, outside this basePath.\n A router link avoids the full reload and keeps the org/workspace/tenant params. */}\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.CHANNEL_MESSAGE_READ}\n to={{ pathname: '/conversations', search: location.search }}\n icon={\n <MessagesSquare className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />\n }\n label={t('botlit.dashboard.quickActions.conversations', 'Conversations')}\n />\n <QuickAction\n to={getPath('handoffs')}\n icon={<Headset className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.quickActions.handoffs', 'Human Handoffs')}\n />\n </ul>\n </GlassCard>\n </>\n )}\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwCA,IAAME,IAAa,KAEbC,IACJ,sLAEIC,KAAsC,EAAE,eAC5C,kBAAC,OAAD;CAAK,WAAU;CAAY,MAAK;CAAS,aAAU;CAAO,cAAYC;CACnE,UAAA;EAAC;EAAG;EAAG;CAAC,CAAC,CAAC,KAAK,MACd,kBAAC,OAAD,EAAa,WAAU,8DAA+D,GAA5EC,CAA4E,CACvF;AACE,CAAA,GAUDC,KAAqC,EAAE,eAAY,O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QAAQ,CAAA;QAC3E,OAAOhF,EAAE,0CAA0C,gBAAgB;OACpE,CAAA;MACC;KACK,CAAA,CAAA;;GACX,EAAA,CAAA,CAED;;CACK,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"DashboardPage.js","names":["_Fragment","Fragment$1","NAME_TOKEN","QUICK_ACTION_CLASS","LoadingRows","label","i","QuickAction","link","Link","icon","permission","BotmanorPermissionGate","DashboardPage","t","useTr","location","useLocation","useBotlit","botsAccess","useBotmanorPermissionDecision","BOTMANOR_PERMISSIONS","agentsAccess","executionsAccess","canReadBots","canReadAgents","permissionsLoading","bots","botsLoading","botsError","botsHasMore","refetchBots","useBots","agents","agentsLoading","agentsError","agentsHasMore","refetchAgents","useAgents","botCounts","useBotAppCounts","agentCounts","useAgentCounts","recentBots","useMemo","byRecentActivity","activeAgents","agent","recentActiveAgents","noAccess","isReturning","countLabel","hasMore","formatNumber","count","botsTotal","activeAgentsTotal","agentsTotal","stats","AppWindow","Bot","executionsLabel","n","firstName","getGreetingName","currentUser","greeting","Fragment","part","index","parts","GradientText","PageLayout","Button","navigateTo","Plus","PagePurpose","Zap","Lock","Card","stat","CardContent","DashboardUsagePanel","PlanUsageCard","CardHeader","CardTitle","ArrowRight","ErrorState","getPath","bot","StatusBadge","GlassCard","BookOpen","KeyRound","MessagesSquare","Headset"],"sources":["../../../src/botlit/pages/DashboardPage.tsx"],"sourcesContent":["/**\n * Dashboard Page\n * @module botlit/pages\n */\n\nimport { Fragment, useMemo, type FC, type ReactNode } from 'react';\nimport { Link, useLocation } from 'react-router';\nimport {\n AppWindow,\n Bot,\n BookOpen,\n Zap,\n ArrowRight,\n Plus,\n Headset,\n KeyRound,\n Lock,\n MessagesSquare,\n} from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { GradientText, GlassCard, PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardHeader, CardTitle, CardContent } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { StatusBadge } from '../components/Badge';\nimport { ErrorState } from '../components/ErrorState';\nimport { DashboardUsagePanel } from '../components/DashboardUsagePanel';\nimport { PlanUsageCard } from '../components/PlanUsageCard';\nimport { useBotAppCounts, useBots } from '../hooks/useBots';\nimport { useAgentCounts, useAgents } from '../hooks/useAgents';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatNumber, MISSING_VALUE } from '../utils/formatters';\nimport { byRecentActivity, getGreetingName } from '../utils/greeting';\nimport {\n BOTMANOR_PERMISSIONS,\n BotmanorPermissionGate,\n useBotmanorPermissionDecision,\n type BotmanorPermission,\n} from '../permissions';\n\n/** Placeholder swapped for the user's name so the translated sentence keeps its word order. */\nconst NAME_TOKEN = '\\u0001';\n\nconst QUICK_ACTION_CLASS =\n 'flex flex-col items-center gap-2 p-4 rounded-card border border-border-seam bg-bg-surface hover:border-border-strong hover:shadow-elevation-2 transition-[box-shadow,border-color]';\n\nconst LoadingRows: FC<{ label: string }> = ({ label }) => (\n <div className=\"space-y-3\" role=\"status\" aria-busy=\"true\" aria-label={label}>\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-16 bg-bg-sunken rounded-lg motion-safe:animate-vc-shimmer\" />\n ))}\n </div>\n);\n\ninterface QuickActionProps {\n permission?: BotmanorPermission;\n to: string | { pathname: string; search: string };\n icon: ReactNode;\n label: string;\n}\n\nconst QuickAction: FC<QuickActionProps> = ({ permission, to, icon, label }) => {\n const link = (\n <li>\n <Link to={to} className={QUICK_ACTION_CLASS}>\n {icon}\n <span className=\"text-sm font-medium\">{label}</span>\n </Link>\n </li>\n );\n return permission ? (\n <BotmanorPermissionGate permission={permission}>{link}</BotmanorPermissionGate>\n ) : (\n link\n );\n};\n\nexport const DashboardPage: FC = () => {\n const t = useTr();\n const location = useLocation();\n const { currentUser, navigateTo, getPath } = useBotlit();\n\n const botsAccess = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.APP_READ);\n const agentsAccess = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.AGENT_READ);\n const executionsAccess = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.EXECUTION_READ);\n const canReadBots = botsAccess === 'allowed';\n const canReadAgents = agentsAccess === 'allowed';\n const permissionsLoading = botsAccess === 'loading' || agentsAccess === 'loading';\n\n const {\n data: bots,\n loading: botsLoading,\n error: botsError,\n hasMore: botsHasMore,\n refetch: refetchBots,\n } = useBots();\n const {\n data: agents,\n loading: agentsLoading,\n error: agentsError,\n hasMore: agentsHasMore,\n refetch: refetchAgents,\n } = useAgents();\n\n // Exact totals come from the count queries (BOFF-12426). The paged lists\n // above only feed the \"Recent\" panels; if a count query fails the stat falls\n // back to the list length, shown with \"+\" when the list may be truncated.\n const botCounts = useBotAppCounts(canReadBots);\n const agentCounts = useAgentCounts(canReadAgents);\n\n const recentBots = useMemo(() => [...bots].sort(byRecentActivity).slice(0, 4), [bots]);\n const activeAgents = useMemo(() => agents.filter((agent) => agent.status === 'ACTIVE'), [agents]);\n const recentActiveAgents = useMemo(\n () => [...activeAgents].sort(byRecentActivity).slice(0, 4),\n [activeAgents]\n );\n\n const noAccess = !permissionsLoading && !canReadBots && !canReadAgents;\n // \"Welcome back\" is only true once the user is known to have bots or agents;\n // while loading, after an error, or for a first-time user the greeting stays neutral.\n const isReturning = (canReadBots && bots.length > 0) || (canReadAgents && agents.length > 0);\n\n /** A list that stopped at a full page is shown as \"100+\", never as an exact count. */\n const countLabel = (count: number, hasMore: boolean) =>\n hasMore ? `${formatNumber(count)}+` : formatNumber(count);\n\n // \"Total Bots\" is every bot that is not archived; \"Active Agents\" is the\n // agents whose status is ACTIVE. Both are exact when the count query answers.\n const botsTotal = botCounts.data ? botCounts.data.total - botCounts.data.archived : undefined;\n const activeAgentsTotal = agentCounts.data ? agentCounts.data.active : undefined;\n const agentsTotal = agentCounts.data\n ? agentCounts.data.total - agentCounts.data.archived\n : undefined;\n\n const stats: Array<{\n key: string;\n label: string;\n value: string;\n loading: boolean;\n icon: ReactNode;\n hero: boolean;\n }> = [];\n if (canReadBots) {\n stats.push({\n key: 'bots',\n label: t('botlit.dashboard.stats.totalBots', 'Total Bots'),\n value:\n botsTotal !== undefined\n ? formatNumber(botsTotal)\n : botsError\n ? MISSING_VALUE\n : countLabel(bots.length, botsHasMore),\n loading: botsTotal === undefined && (botCounts.loading || botsLoading),\n icon: <AppWindow className=\"h-5 w-5\" aria-hidden=\"true\" />,\n hero: true,\n });\n }\n if (canReadAgents) {\n stats.push({\n key: 'agents',\n label: t('botlit.dashboard.stats.activeAgents', 'Active Agents'),\n value:\n activeAgentsTotal !== undefined\n ? formatNumber(activeAgentsTotal)\n : agentsError\n ? MISSING_VALUE\n : countLabel(activeAgents.length, agentsHasMore),\n loading: activeAgentsTotal === undefined && (agentCounts.loading || agentsLoading),\n icon: <Bot className=\"h-5 w-5\" aria-hidden=\"true\" />,\n hero: !canReadBots,\n });\n }\n\n const executionsLabel = (count: number | null | undefined) => {\n const n = count ?? 0;\n return n === 1\n ? t('botlit.common.executionsOne', '{{count}} execution', { count: formatNumber(n) })\n : t('botlit.common.executionsOther', '{{count}} executions', { count: formatNumber(n) });\n };\n\n const firstName = getGreetingName(currentUser);\n const greetingTemplate = firstName\n ? isReturning\n ? t('botlit.dashboard.titleNamed', 'Welcome back, {{name}}', { name: NAME_TOKEN })\n : t('botlit.dashboard.welcomeNamed', 'Welcome, {{name}}', { name: NAME_TOKEN })\n : isReturning\n ? t('botlit.dashboard.title', 'Welcome back')\n : t('botlit.dashboard.welcome', 'Welcome');\n const greeting = greetingTemplate.split(NAME_TOKEN).map((part, index, parts) => (\n <Fragment key={index}>\n {part}\n {index < parts.length - 1 ? <GradientText>{firstName}</GradientText> : null}\n </Fragment>\n ));\n\n return (\n <PageLayout\n hero\n title={greeting}\n description={t(\n 'botlit.dashboard.description',\n \"Here's an overview of your AI agents and bots\"\n )}\n actions={\n <div className=\"flex gap-2\">\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_CREATE}>\n <Button leftIcon={<Bot size={16} />} onClick={() => navigateTo('agents/new')}>\n {t('botlit.dashboard.actions.createAgent', 'Create Agent')}\n </Button>\n </BotmanorPermissionGate>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_CREATE}>\n <Button\n variant=\"outline\"\n leftIcon={<Plus size={16} />}\n onClick={() => navigateTo('bots/new')}\n >\n {t('botlit.dashboard.actions.createBot', 'Create Bot')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<Zap size={18} aria-hidden=\"true\" />}>\n {t(\n 'botlit.dashboard.purpose',\n 'This is your home base — a quick pulse on every bot and agent in your workspace. Glance at the headline numbers, jump back into recent work, and use the quick actions below to start something new. If you are just getting started, create your first agent and connect it to a bot.'\n )}\n </PagePurpose>\n\n {noAccess ? (\n <div\n role=\"status\"\n className=\"flex flex-col items-center justify-center gap-3 rounded-lg border border-border-subtle bg-bg-surface px-4 py-12 text-center\"\n >\n <Lock size={28} className=\"text-text-secondary\" aria-hidden=\"true\" />\n <div>\n <h2 className=\"text-lg font-medium text-text-primary\">\n {t('botlit.dashboard.noAccess.title', 'You do not have access to this dashboard')}\n </h2>\n <p className=\"mt-2 max-w-md text-sm text-text-secondary\">\n {t(\n 'botlit.dashboard.noAccess.description',\n 'Your role in this workspace cannot view bots or agents. Ask a workspace admin for read access.'\n )}\n </p>\n </div>\n </div>\n ) : (\n <>\n {/* Stats Grid */}\n <ul\n className=\"grid grid-cols-1 md:grid-cols-2 gap-4\"\n aria-label={t('botlit.dashboard.stats.title', 'Workspace totals')}\n >\n {permissionsLoading ? (\n <li>\n <LoadingRows label={t('botlit.common.loading', 'Loading')} />\n </li>\n ) : (\n stats.map((stat) => (\n <li key={stat.key}>\n <Card treatment={stat.hero ? 'glass' : 'metric'} glow={stat.hero}>\n <CardContent className=\"pt-6\">\n <div className=\"flex items-center gap-4\">\n <div className=\"p-3 rounded-lg bg-[var(--color-accent-soft)] text-text-primary [&>svg]:text-text-primary\">\n {stat.icon}\n </div>\n {/* Label first in the DOM so screen readers announce \"Total Bots, 12\". */}\n <div className=\"flex flex-col-reverse\">\n <p className=\"text-sm text-text-secondary\">{stat.label}</p>\n {stat.loading ? (\n <div\n role=\"status\"\n aria-busy=\"true\"\n aria-label={t('botlit.common.loading', 'Loading')}\n className=\"h-8 w-12 rounded bg-bg-sunken motion-safe:animate-vc-shimmer\"\n />\n ) : (\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">\n {stat.value}\n </p>\n )}\n </div>\n </div>\n </CardContent>\n </Card>\n </li>\n ))\n )}\n </ul>\n\n {/* Runs, success rate, cost, top agents and health (BOFF-15360) */}\n {executionsAccess === 'allowed' ? <DashboardUsagePanel /> : null}\n\n {/* Plan allowances: bots, runs, messages, knowledge bases (BOFF-15484) */}\n <PlanUsageCard />\n\n {/* Main Content Grid */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n {canReadBots ? (\n <Card treatment=\"insight\">\n <CardHeader className=\"flex flex-row items-center justify-between\">\n <CardTitle as=\"h2\">\n {t('botlit.dashboard.recentBots.title', 'Recent Bots')}\n </CardTitle>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n rightIcon={<ArrowRight size={16} />}\n onClick={() => navigateTo('bots')}\n >\n {t('botlit.common.viewAll', 'View All')}\n </Button>\n </CardHeader>\n <CardContent>\n {botsLoading ? (\n <LoadingRows label={t('botlit.common.loading', 'Loading')} />\n ) : botsError ? (\n <ErrorState\n resource={t('botlit.dashboard.resource.bots', 'bots')}\n error={botsError}\n onRetry={() => void refetchBots()}\n />\n ) : recentBots.length > 0 ? (\n <ul className=\"space-y-3\">\n {recentBots.map((bot) => (\n <li key={bot.id}>\n <Link\n to={getPath(`bots/${bot.id}`)}\n className=\"flex items-center justify-between p-3 rounded-lg border border-border-seam hover:border-border-strong hover:bg-accent transition-colors\"\n >\n <div className=\"flex items-center gap-3\">\n <span className=\"text-2xl\" aria-hidden=\"true\">\n {bot.icon || '🤖'}\n </span>\n <div>\n <p className=\"font-medium text-text-primary\">{bot.name}</p>\n <p className=\"text-xs text-text-secondary\">\n {executionsLabel(bot.executionCount)}\n </p>\n </div>\n </div>\n <StatusBadge status={bot.status} />\n </Link>\n </li>\n ))}\n </ul>\n ) : (\n <div className=\"text-center py-8 text-text-secondary\">\n <AppWindow className=\"h-8 w-8 mx-auto mb-2 opacity-50\" aria-hidden=\"true\" />\n <p>{t('botlit.dashboard.recentBots.emptyTitle', 'No bots yet')}</p>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_CREATE}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"mt-3\"\n onClick={() => navigateTo('bots/new')}\n >\n {t('botlit.dashboard.recentBots.emptyAction', 'Create your first bot')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n )}\n </CardContent>\n </Card>\n ) : null}\n\n {canReadAgents ? (\n <Card treatment=\"insight\">\n <CardHeader className=\"flex flex-row items-center justify-between\">\n <CardTitle as=\"h2\">\n {t('botlit.dashboard.activeAgents.title', 'Active Agents')}\n </CardTitle>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n rightIcon={<ArrowRight size={16} />}\n onClick={() => navigateTo('agents')}\n >\n {t('botlit.common.viewAll', 'View All')}\n </Button>\n </CardHeader>\n <CardContent>\n {agentsLoading ? (\n <LoadingRows label={t('botlit.common.loading', 'Loading')} />\n ) : agentsError ? (\n <ErrorState\n resource={t('botlit.dashboard.resource.agents', 'agents')}\n error={agentsError}\n onRetry={() => void refetchAgents()}\n />\n ) : recentActiveAgents.length > 0 ? (\n <ul className=\"space-y-3\">\n {recentActiveAgents.map((agent) => (\n <li key={agent.id}>\n <Link\n to={getPath(`agents/${agent.id}`)}\n className=\"flex items-center justify-between p-3 rounded-lg border border-border-seam hover:border-border-strong hover:bg-accent transition-colors\"\n >\n <div className=\"flex items-center gap-3\">\n <span className=\"relative text-2xl\">\n <span aria-hidden=\"true\">🤖</span>\n <span\n aria-hidden=\"true\"\n className=\"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-status-success-text motion-safe:animate-vc-glow-pulse\"\n />\n </span>\n <div>\n <p className=\"font-medium text-text-primary\">{agent.name}</p>\n <p className=\"text-xs text-text-secondary\">\n <span className=\"sr-only\">\n {t('botlit.status.active', 'Active')}.{' '}\n </span>\n {executionsLabel(agent.executionCount)}\n </p>\n </div>\n </div>\n </Link>\n </li>\n ))}\n </ul>\n ) : (\n <div className=\"text-center py-8 text-text-secondary\">\n <Bot className=\"h-8 w-8 mx-auto mb-2 opacity-50\" aria-hidden=\"true\" />\n {agents.length === 0 ? (\n <>\n <p>{t('botlit.dashboard.activeAgents.emptyTitle', 'No agents yet')}</p>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_CREATE}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"mt-3\"\n onClick={() => navigateTo('agents/new')}\n >\n {t(\n 'botlit.dashboard.activeAgents.emptyAction',\n 'Create your first agent'\n )}\n </Button>\n </BotmanorPermissionGate>\n </>\n ) : (\n <>\n <p>\n {activeAgentsTotal !== undefined && activeAgentsTotal > 0\n ? t(\n 'botlit.dashboard.activeAgents.activeElsewhere',\n '{{count}} active agents',\n { count: formatNumber(activeAgentsTotal) }\n )\n : t(\n 'botlit.dashboard.activeAgents.noneActive',\n '{{count}} agents, none active',\n {\n count:\n agentsTotal !== undefined\n ? formatNumber(agentsTotal)\n : countLabel(agents.length, agentsHasMore),\n }\n )}\n </p>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"mt-3\"\n onClick={() => navigateTo('agents')}\n >\n {t('botlit.dashboard.activeAgents.viewAgents', 'Review agents')}\n </Button>\n </>\n )}\n </div>\n )}\n </CardContent>\n </Card>\n ) : null}\n </div>\n\n {/* Quick Actions, in setup order: knowledge → model → agent → bot */}\n <GlassCard treatment=\"plain\" className=\"border-border-seam p-6\">\n <h2 className=\"text-lg font-semibold tracking-tight text-text-primary\">\n {t('botlit.dashboard.quickActions.title', 'Quick Actions')}\n </h2>\n <ul className=\"mt-4 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4\">\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.KNOWLEDGE_CREATE}\n to={getPath('knowledge/new')}\n icon={<BookOpen className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.quickActions.addKnowledge', 'Add Knowledge')}\n />\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.LLM_CREATE}\n to={getPath('settings')}\n icon={<KeyRound className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.quickActions.connectModel', 'Connect LLM Provider')}\n />\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.AGENT_CREATE}\n to={getPath('agents/new')}\n icon={<Bot className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.actions.createAgent', 'Create Agent')}\n />\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.APP_CREATE}\n to={getPath('bots/new')}\n icon={<AppWindow className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.actions.createBot', 'Create Bot')}\n />\n {/* Conversations is its own app mounted at /conversations, outside this basePath.\n A router link avoids the full reload and keeps the org/workspace/tenant params. */}\n <QuickAction\n permission={BOTMANOR_PERMISSIONS.CHANNEL_MESSAGE_READ}\n to={{ pathname: '/conversations', search: location.search }}\n icon={\n <MessagesSquare className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />\n }\n label={t('botlit.dashboard.quickActions.conversations', 'Conversations')}\n />\n <QuickAction\n to={getPath('handoffs')}\n icon={<Headset className=\"h-8 w-8 text-text-secondary\" aria-hidden=\"true\" />}\n label={t('botlit.dashboard.quickActions.handoffs', 'Human Handoffs')}\n />\n </ul>\n </GlassCard>\n </>\n )}\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;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AY;OAC5D,CAAA;OAGD,kBAACP,GAAD;QACE,YAAYc,EAAqB;QACjC,IAAI;SAAE,UAAU;SAAkB,QAAQL,EAAS;QAAO;QAC1D,MACE,kBAAC8E,IAAD;SAAgB,WAAU;SAA8B,eAAY;QAAQ,CAAA;QAE9E,OAAOhF,EAAE,+CAA+C,eAAe;OACxE,CAAA;OACD,kBAACP,GAAD;QACE,IAAIiF,EAAQ,UAAU;QACtB,MAAM,kBAACO,IAAD;SAAS,WAAU;SAA8B,eAAY;QAAQ,CAAA;QAC3E,OAAOjF,EAAE,0CAA0C,gBAAgB;OACpE,CAAA;MACC;KACK,CAAA,CAAA;;GACX,EAAA,CAAA,CAED;;CACK,CAAA;AAEhB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
+
import { PlanLimitDialog as t } from "../components/QuotaExhaustedDialog.js";
|
|
3
|
+
import { planLimitCopy as n } from "../utils/quotaErrors.js";
|
|
4
|
+
import { watchPlanLimits as r } from "../utils/watchPlanLimits.js";
|
|
5
|
+
import { useBotlit as i } from "./BotlitProvider.js";
|
|
6
|
+
import { QuotaGuardContext as a } from "./quotaGuardContext.js";
|
|
7
|
+
import { useCallback as o, useMemo as s, useState as c } from "react";
|
|
8
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
|
+
import { GatewayProvider as d, useSafeGateway as f } from "@burdenoff/fe-libs/shared/graphql";
|
|
10
|
+
// src/botlit/providers/QuotaGuard.tsx
|
|
11
|
+
var p = ({ children: p }) => {
|
|
12
|
+
let m = e(), { navigate: h } = i(), g = f(), [_, v] = c(null), y = o((e, t) => {
|
|
13
|
+
let n = {
|
|
14
|
+
copy: e,
|
|
15
|
+
onClose: t
|
|
16
|
+
};
|
|
17
|
+
return v(n), () => v((e) => e === n ? null : e);
|
|
18
|
+
}, []), b = o((e) => {
|
|
19
|
+
let t = { copy: n(m, e) };
|
|
20
|
+
v((e) => e ?? t);
|
|
21
|
+
}, [m]), x = s(() => {
|
|
22
|
+
if (!g) return null;
|
|
23
|
+
let e = r(g.workspaceClient, b);
|
|
24
|
+
return {
|
|
25
|
+
...g,
|
|
26
|
+
workspaceClient: e,
|
|
27
|
+
getClient: (t) => t === "workspace" ? e : g.getClient(t)
|
|
28
|
+
};
|
|
29
|
+
}, [g, b]), S = s(() => ({ present: y }), [y]), C = () => {
|
|
30
|
+
let e = _?.onClose;
|
|
31
|
+
v(null), e?.();
|
|
32
|
+
}, w = /* @__PURE__ */ u(a.Provider, {
|
|
33
|
+
value: S,
|
|
34
|
+
children: [p, /* @__PURE__ */ l(t, {
|
|
35
|
+
open: _ !== null,
|
|
36
|
+
title: _?.copy.title ?? "",
|
|
37
|
+
description: _?.copy.description ?? "",
|
|
38
|
+
onClose: C,
|
|
39
|
+
onViewBilling: () => {
|
|
40
|
+
C(), h ? h("/billing") : window.location.assign("/billing");
|
|
41
|
+
}
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
return x ? /* @__PURE__ */ l(d, {
|
|
45
|
+
value: x,
|
|
46
|
+
children: w
|
|
47
|
+
}) : w;
|
|
48
|
+
};
|
|
49
|
+
export { p as QuotaGuard };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=QuotaGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuotaGuard.js","names":["QuotaGuard","t","useTr","useBotlit","gateway","useSafeGateway","dialog","setDialog","useState","present","useCallback","entry","current","onLimit","next","planLimitCopy","error","value","useMemo","workspaceClient","watchPlanLimits","which","guard","close","onClose","tree","QuotaGuardContext","children","PlanLimitDialog","navigate","GatewayProvider"],"sources":["../../../src/botlit/providers/QuotaGuard.tsx"],"sourcesContent":["/**\n * Plan-limit routing for every metered mutation (BOFF-15484)\n * @module botlit/providers\n *\n * Only Create Bot used to explain a plan limit; a knowledge base, a chat\n * message or a run that hit one failed with a raw or generic error, because\n * the shell's error toast deliberately skips quota codes and leaves them to\n * the product. This provider re-provides the shell's gateway clients with the\n * workspace client's `mutate` watched: any mutation that comes back with a\n * plan-limit error opens one translated dialog that names the allowance and\n * links to billing. The error still reaches the caller unchanged, so pages\n * keep their own handling; a page that shows `QuotaExhaustedDialog` itself\n * feeds its copy into this same dialog instead of opening a second one.\n */\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\nimport {\n GatewayProvider,\n useSafeGateway,\n type GatewayContextValue,\n} from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useTr } from '../../shared/hooks/useTr';\nimport { PlanLimitDialog } from '../components/QuotaExhaustedDialog';\nimport { planLimitCopy, type PlanLimitCopy, type PlanLimitError } from '../utils/quotaErrors';\nimport { watchPlanLimits } from '../utils/watchPlanLimits';\nimport { useBotlit } from './BotlitProvider';\nimport { QuotaGuardContext, type QuotaGuardValue } from './quotaGuardContext';\n\n/** One request to show the dialog; compared by identity, so no id is needed. */\ninterface OpenDialog {\n copy: PlanLimitCopy;\n onClose?: () => void;\n}\n\nexport const QuotaGuard: FC<PropsWithChildren> = ({ children }) => {\n const t = useTr();\n const { navigate } = useBotlit();\n const gateway = useSafeGateway();\n const [dialog, setDialog] = useState<OpenDialog | null>(null);\n\n const present = useCallback<QuotaGuardValue['present']>((copy, onClose) => {\n const entry: OpenDialog = { copy, onClose };\n setDialog(entry);\n return () => setDialog((current) => (current === entry ? null : current));\n }, []);\n\n const onLimit = useCallback(\n (error: PlanLimitError) => {\n // A page that already explained this limit keeps its own wording.\n const next: OpenDialog = { copy: planLimitCopy(t, error) };\n setDialog((current) => current ?? next);\n },\n [t]\n );\n\n const value = useMemo<GatewayContextValue | null>(() => {\n if (!gateway) return null;\n const workspaceClient = watchPlanLimits(gateway.workspaceClient, onLimit);\n return {\n ...gateway,\n workspaceClient,\n getClient: (which) => (which === 'workspace' ? workspaceClient : gateway.getClient(which)),\n };\n }, [gateway, onLimit]);\n\n const guard = useMemo<QuotaGuardValue>(() => ({ present }), [present]);\n\n const close = () => {\n const onClose = dialog?.onClose;\n setDialog(null);\n onClose?.();\n };\n\n const viewBilling = () => {\n close();\n if (navigate) navigate('/billing');\n else window.location.assign('/billing');\n };\n\n const tree = (\n <QuotaGuardContext.Provider value={guard}>\n {children}\n <PlanLimitDialog\n open={dialog !== null}\n title={dialog?.copy.title ?? ''}\n description={dialog?.copy.description ?? ''}\n onClose={close}\n onViewBilling={viewBilling}\n />\n </QuotaGuardContext.Provider>\n );\n\n return value ? <GatewayProvider value={value}>{tree}</GatewayProvider> : tree;\n};\n"],"mappings":";;;;;;;;;;AAoCA,IAAaA,KAAqC,EAAE,kBAAe;CACjE,IAAMC,IAAIC,EAAM,GACV,EAAE,gBAAaC,EAAU,GACzBC,IAAUC,EAAe,GACzB,CAACC,GAAQC,KAAaC,EAA4B,IAAI,GAEtDC,IAAUC,GAAyC,GAAM,MAAY;EACzE,IAAMC,IAAoB;GAAE;GAAM;EAAQ;EAE1C,OADAJ,EAAUI,CAAK,SACFJ,GAAW,MAAaK,MAAYD,IAAQ,OAAOC,CAAQ;CAC1E,GAAG,CAAC,CAAC,GAECC,IAAUH,GACb,MAA0B;EAEzB,IAAMI,IAAmB,EAAE,MAAMC,EAAcd,GAAGe,CAAK,EAAE;EACzD,GAAW,MAAYJ,KAAWE,CAAI;CACxC,GACA,CAACb,CAAC,CACJ,GAEMgB,IAAQC,QAA0C;EACtD,IAAI,CAACd,GAAS,OAAO;EACrB,IAAMe,IAAkBC,EAAgBhB,EAAQ,iBAAiBS,CAAO;EACxE,OAAO;GACL,GAAGT;GACH;GACA,YAAY,MAAWiB,MAAU,cAAcF,IAAkBf,EAAQ,UAAUiB,CAAK;EAC1F;CACF,GAAG,CAACjB,GAASS,CAAO,CAAC,GAEfS,IAAQJ,SAAgC,EAAE,WAAQ,IAAI,CAACT,CAAO,CAAC,GAE/Dc,UAAc;EAClB,IAAMC,IAAUlB,GAAQ;EAExB,AADAC,EAAU,IAAI,GACdiB,IAAU;CACZ,GAQMC,IACJ,kBAACC,EAAkB,UAAnB;EAA4B,OAAOJ;EAAnC,UAAA,CACGK,GACD,kBAACC,GAAD;GACE,MAAMtB,MAAW;GACjB,OAAOA,GAAQ,KAAK,SAAS;GAC7B,aAAaA,GAAQ,KAAK,eAAe;GACzC,SAASiB;GACT,qBAdoB;IAExB,AADAA,EAAM,GACFM,IAAUA,EAAS,UAAU,IAC5B,OAAO,SAAS,OAAO,UAAU;GACxC;EAWK,CAAA,CACyB;;CAG9B,OAAOZ,IAAQ,kBAACa,GAAD;EAAwB;EAAQ,UAAAL;CAAsB,CAAA,IAAIA;AAC3E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PlanLimitCopy } from '../utils/quotaErrors';
|
|
2
|
+
export interface QuotaGuardValue {
|
|
3
|
+
/**
|
|
4
|
+
* Shows the shared plan-limit dialog with this copy. `onClose` runs once
|
|
5
|
+
* when the dialog closes. Returns a function that withdraws the request.
|
|
6
|
+
*/
|
|
7
|
+
present: (copy: PlanLimitCopy, onClose?: () => void) => () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const QuotaGuardContext: import('react').Context<QuotaGuardValue | null>;
|
|
10
|
+
/** The shared plan-limit dialog, or null outside BotManor's root. */
|
|
11
|
+
export declare function useQuotaGuard(): QuotaGuardValue | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext as e, useContext as t } from "react";
|
|
2
|
+
// src/botlit/providers/quotaGuardContext.ts
|
|
3
|
+
var n = e(null);
|
|
4
|
+
function r() {
|
|
5
|
+
return t(n);
|
|
6
|
+
}
|
|
7
|
+
export { n as QuotaGuardContext, r as useQuotaGuard };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=quotaGuardContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotaGuardContext.js","names":["QuotaGuardContext","createContext","useQuotaGuard","useContext"],"sources":["../../../src/botlit/providers/quotaGuardContext.ts"],"sourcesContent":["/**\n * Plan-limit dialog context (BOFF-15484)\n * @module botlit/providers\n *\n * Kept apart from `QuotaGuard.tsx` so components can reach the shared dialog\n * without importing the gateway plumbing.\n */\n\nimport { createContext, useContext } from 'react';\n\nimport type { PlanLimitCopy } from '../utils/quotaErrors';\n\nexport interface QuotaGuardValue {\n /**\n * Shows the shared plan-limit dialog with this copy. `onClose` runs once\n * when the dialog closes. Returns a function that withdraws the request.\n */\n present: (copy: PlanLimitCopy, onClose?: () => void) => () => void;\n}\n\nexport const QuotaGuardContext = createContext<QuotaGuardValue | null>(null);\n\n/** The shared plan-limit dialog, or null outside BotManor's root. */\nexport function useQuotaGuard(): QuotaGuardValue | null {\n return useContext(QuotaGuardContext);\n}\n"],"mappings":";;AAoBA,IAAaA,IAAoBC,EAAsC,IAAI;AAG3E,SAAgBC,IAAwC;CACtD,OAAOC,EAAWH,CAAiB;AACrC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan-limit errors from the workspace gateway (BOFF-15484)
|
|
3
|
+
* @module botlit/utils
|
|
4
|
+
*
|
|
5
|
+
* When an `@usage`-metered mutation runs out of allowance the gateway answers
|
|
6
|
+
* HTTP 429 with one GraphQL error:
|
|
7
|
+
*
|
|
8
|
+
* { message: "Quota exhausted for botmanor.bots.count",
|
|
9
|
+
* extensions: { code: "QUOTA_EXHAUSTED", field: "createBotApp", limitLeft: 0 } }
|
|
10
|
+
*
|
|
11
|
+
* or, when the workspace's plan does not include the quota at all,
|
|
12
|
+
* `code: "QUOTA_NOT_PROVISIONED"` with "No active subscription covers …".
|
|
13
|
+
* Apollo v4 surfaces that body in more than one shape (CombinedGraphQLErrors
|
|
14
|
+
* `.errors`, the batched fetch layer's `networkError.errors`, a ServerError's
|
|
15
|
+
* parsed `result.errors`), and the workspace hooks wrap failures in an Error
|
|
16
|
+
* whose `cause` is the original. `findPlanLimitError` looks in all of them.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PLAN_LIMIT_CODES: readonly ["QUOTA_EXHAUSTED", "QUOTA_NOT_PROVISIONED", "RESOURCE_CAP_EXCEEDED"];
|
|
19
|
+
export type PlanLimitCode = (typeof PLAN_LIMIT_CODES)[number];
|
|
20
|
+
export interface PlanLimitError {
|
|
21
|
+
code: PlanLimitCode;
|
|
22
|
+
/** Quota identifier, e.g. `botmanor.bots.count`, when the gateway named it. */
|
|
23
|
+
quotaName?: string;
|
|
24
|
+
/** The metered GraphQL field, e.g. `createBotApp`. */
|
|
25
|
+
field?: string;
|
|
26
|
+
limitLeft?: number;
|
|
27
|
+
}
|
|
28
|
+
/** BotManor's metered quotas, keyed by the `@usage` quota name. */
|
|
29
|
+
export type BotmanorQuotaKey = 'bots' | 'knowledgeBases' | 'messages' | 'runs' | 'mcpServers' | 'aiCredits';
|
|
30
|
+
/**
|
|
31
|
+
* The plan-limit error behind a failed operation, or null when the failure is
|
|
32
|
+
* something else. Follows `cause` chains and every Apollo error shape.
|
|
33
|
+
*/
|
|
34
|
+
export declare function findPlanLimitError(error: unknown): PlanLimitError | null;
|
|
35
|
+
/** Which BotManor allowance a plan-limit error is about, when it can be told. */
|
|
36
|
+
export declare function quotaKeyOf(error: PlanLimitError): BotmanorQuotaKey | undefined;
|
|
37
|
+
/** Maps a quota name from the usage API onto BotManor's allowance keys. */
|
|
38
|
+
export declare function quotaKeyOfName(quotaName: string): BotmanorQuotaKey | undefined;
|
|
39
|
+
type Translate = (key: string, fallback: string, params?: Record<string, string | number>) => string;
|
|
40
|
+
/** Display name of an allowance, e.g. "Bots". */
|
|
41
|
+
export declare function quotaLabel(t: Translate, key: BotmanorQuotaKey): string;
|
|
42
|
+
export interface PlanLimitCopy {
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
}
|
|
46
|
+
/** Dialog copy for a plan-limit error, specific to the allowance when known. */
|
|
47
|
+
export declare function planLimitCopy(t: Translate, error: PlanLimitError): PlanLimitCopy;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// src/botlit/utils/quotaErrors.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"QUOTA_EXHAUSTED",
|
|
4
|
+
"QUOTA_NOT_PROVISIONED",
|
|
5
|
+
"RESOURCE_CAP_EXCEEDED"
|
|
6
|
+
], t = {
|
|
7
|
+
"botmanor.bots.count": "bots",
|
|
8
|
+
"botmanor.knowledge_bases.count": "knowledgeBases",
|
|
9
|
+
"botmanor.messages.count": "messages",
|
|
10
|
+
"botmanor.runs.count": "runs",
|
|
11
|
+
"botmanor.mcp_servers.count": "mcpServers",
|
|
12
|
+
"botmanor.ai.credits": "aiCredits"
|
|
13
|
+
}, n = {
|
|
14
|
+
createBotApp: "bots",
|
|
15
|
+
createAppFromTemplate: "bots",
|
|
16
|
+
createBotFromDraft: "bots",
|
|
17
|
+
createKnowledgeBase: "knowledgeBases",
|
|
18
|
+
chatWithAgent: "messages",
|
|
19
|
+
startAssistantTurn: "messages",
|
|
20
|
+
sendChannelMessage: "messages",
|
|
21
|
+
runExecution: "runs",
|
|
22
|
+
rerunExecution: "runs",
|
|
23
|
+
createExecution: "runs",
|
|
24
|
+
triggerBoundWorkflow: "runs",
|
|
25
|
+
triggerBotmanorBoundWorkflow: "runs",
|
|
26
|
+
createMCPConnection: "mcpServers",
|
|
27
|
+
draftBotFromDescription: "aiCredits",
|
|
28
|
+
suggestAgentImprovements: "aiCredits"
|
|
29
|
+
}, r = /\b(botmanor\.[a-z_]+\.[a-z_]+)\b/;
|
|
30
|
+
function i(e) {
|
|
31
|
+
return typeof e == "object" && !!e;
|
|
32
|
+
}
|
|
33
|
+
function a(t) {
|
|
34
|
+
if (!Array.isArray(t)) return null;
|
|
35
|
+
for (let n of t) {
|
|
36
|
+
if (!i(n)) continue;
|
|
37
|
+
let { extensions: t, message: a } = n, o = t?.code;
|
|
38
|
+
if (typeof o != "string" || !e.includes(o)) continue;
|
|
39
|
+
let s = typeof t?.quotaName == "string" ? t.quotaName : typeof a == "string" ? r.exec(a)?.[1] : void 0;
|
|
40
|
+
return {
|
|
41
|
+
code: o,
|
|
42
|
+
...s ? { quotaName: s } : {},
|
|
43
|
+
...typeof t?.field == "string" ? { field: t.field } : {},
|
|
44
|
+
...typeof t?.limitLeft == "number" ? { limitLeft: t.limitLeft } : {}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
function o(t) {
|
|
50
|
+
let n = /* @__PURE__ */ new Set(), r = t;
|
|
51
|
+
for (; i(r) && !n.has(r);) {
|
|
52
|
+
n.add(r);
|
|
53
|
+
let e = i(r.networkError) ? r.networkError : void 0, t = i(r.result) ? r.result : void 0, o = e && i(e.result) ? e.result : void 0, s = a(r.graphQLErrors) ?? a(r.errors) ?? a(t?.errors) ?? a(e?.errors) ?? a(o?.errors);
|
|
54
|
+
if (s) return s;
|
|
55
|
+
r = r.cause;
|
|
56
|
+
}
|
|
57
|
+
if (t instanceof Error) {
|
|
58
|
+
let n = e.find((e) => t.message.includes(e));
|
|
59
|
+
if (n) return { code: n };
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function s(e) {
|
|
64
|
+
if (e.quotaName && t[e.quotaName]) return t[e.quotaName];
|
|
65
|
+
if (e.field && n[e.field]) return n[e.field];
|
|
66
|
+
}
|
|
67
|
+
function c(e) {
|
|
68
|
+
return t[e];
|
|
69
|
+
}
|
|
70
|
+
function l(e, t) {
|
|
71
|
+
switch (t) {
|
|
72
|
+
case "bots": return e("botlit.usage.quota.bots", "Bots");
|
|
73
|
+
case "knowledgeBases": return e("botlit.usage.quota.knowledgeBases", "Knowledge bases");
|
|
74
|
+
case "messages": return e("botlit.usage.quota.messages", "Messages");
|
|
75
|
+
case "runs": return e("botlit.usage.quota.runs", "Bot runs");
|
|
76
|
+
case "mcpServers": return e("botlit.usage.quota.mcpServers", "MCP servers");
|
|
77
|
+
case "aiCredits": return e("botlit.usage.quota.aiCredits", "AI credits");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function u(e, t) {
|
|
81
|
+
if (t.code === "QUOTA_NOT_PROVISIONED") return {
|
|
82
|
+
title: e("botlit.usage.notIncluded.title", "Not included in your plan"),
|
|
83
|
+
description: e("botlit.usage.notIncluded.description", "Your current plan does not include this BotManor feature. Upgrade your plan to use it.")
|
|
84
|
+
};
|
|
85
|
+
switch (s(t)) {
|
|
86
|
+
case "bots": return {
|
|
87
|
+
title: e("botlit.usage.botQuota.title", "Bot Limit Reached"),
|
|
88
|
+
description: e("botlit.usage.botQuota.description", "You have reached the number of bots allowed on your current plan.")
|
|
89
|
+
};
|
|
90
|
+
case "runs": return {
|
|
91
|
+
title: e("botlit.usage.runQuota.title", "Bot Run Limit Reached"),
|
|
92
|
+
description: e("botlit.usage.runQuota.description", "You have reached your bot run limit for this month.")
|
|
93
|
+
};
|
|
94
|
+
case "knowledgeBases": return {
|
|
95
|
+
title: e("botlit.usage.knowledgeBaseQuota.title", "Knowledge Base Limit Reached"),
|
|
96
|
+
description: e("botlit.usage.knowledgeBaseQuota.description", "You have reached the number of knowledge bases allowed on your current plan.")
|
|
97
|
+
};
|
|
98
|
+
case "messages": return {
|
|
99
|
+
title: e("botlit.usage.messageQuota.title", "Message Limit Reached"),
|
|
100
|
+
description: e("botlit.usage.messageQuota.description", "You have used all the bot messages included in your plan for this period.")
|
|
101
|
+
};
|
|
102
|
+
case "mcpServers": return {
|
|
103
|
+
title: e("botlit.usage.mcpQuota.title", "MCP Server Limit Reached"),
|
|
104
|
+
description: e("botlit.usage.mcpQuota.description", "You have reached the number of MCP server connections allowed on your current plan.")
|
|
105
|
+
};
|
|
106
|
+
case "aiCredits": return {
|
|
107
|
+
title: e("botlit.usage.aiCreditQuota.title", "AI Credits Used Up"),
|
|
108
|
+
description: e("botlit.usage.aiCreditQuota.description", "You have used all the AI credits included in your plan for this period.")
|
|
109
|
+
};
|
|
110
|
+
default: return {
|
|
111
|
+
title: e("botlit.usage.limit.title", "Plan Limit Reached"),
|
|
112
|
+
description: e("botlit.usage.limit.description", "You have reached a usage limit on your current plan. Upgrade your plan to continue.")
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export { e as PLAN_LIMIT_CODES, o as findPlanLimitError, u as planLimitCopy, s as quotaKeyOf, c as quotaKeyOfName, l as quotaLabel };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=quotaErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotaErrors.js","names":["PLAN_LIMIT_CODES","QUOTA_KEYS","FIELD_KEYS","QUOTA_IN_MESSAGE","isObject","value","fromList","list","entry","code","extensions","named","message","findPlanLimitError","seen","current","error","network","result","networkResult","found","candidate","quotaKeyOf","quotaKeyOfName","quotaName","quotaLabel","key","t","planLimitCopy"],"sources":["../../../src/botlit/utils/quotaErrors.ts"],"sourcesContent":["/**\n * Plan-limit errors from the workspace gateway (BOFF-15484)\n * @module botlit/utils\n *\n * When an `@usage`-metered mutation runs out of allowance the gateway answers\n * HTTP 429 with one GraphQL error:\n *\n * { message: \"Quota exhausted for botmanor.bots.count\",\n * extensions: { code: \"QUOTA_EXHAUSTED\", field: \"createBotApp\", limitLeft: 0 } }\n *\n * or, when the workspace's plan does not include the quota at all,\n * `code: \"QUOTA_NOT_PROVISIONED\"` with \"No active subscription covers …\".\n * Apollo v4 surfaces that body in more than one shape (CombinedGraphQLErrors\n * `.errors`, the batched fetch layer's `networkError.errors`, a ServerError's\n * parsed `result.errors`), and the workspace hooks wrap failures in an Error\n * whose `cause` is the original. `findPlanLimitError` looks in all of them.\n */\n\nexport const PLAN_LIMIT_CODES = [\n 'QUOTA_EXHAUSTED',\n 'QUOTA_NOT_PROVISIONED',\n 'RESOURCE_CAP_EXCEEDED',\n] as const;\n\nexport type PlanLimitCode = (typeof PLAN_LIMIT_CODES)[number];\n\nexport interface PlanLimitError {\n code: PlanLimitCode;\n /** Quota identifier, e.g. `botmanor.bots.count`, when the gateway named it. */\n quotaName?: string;\n /** The metered GraphQL field, e.g. `createBotApp`. */\n field?: string;\n limitLeft?: number;\n}\n\n/** BotManor's metered quotas, keyed by the `@usage` quota name. */\nexport type BotmanorQuotaKey =\n 'bots' | 'knowledgeBases' | 'messages' | 'runs' | 'mcpServers' | 'aiCredits';\n\nconst QUOTA_KEYS: Record<string, BotmanorQuotaKey> = {\n 'botmanor.bots.count': 'bots',\n 'botmanor.knowledge_bases.count': 'knowledgeBases',\n 'botmanor.messages.count': 'messages',\n 'botmanor.runs.count': 'runs',\n 'botmanor.mcp_servers.count': 'mcpServers',\n 'botmanor.ai.credits': 'aiCredits',\n};\n\n/** Metered mutations, for errors that name the field but not the quota. */\nconst FIELD_KEYS: Record<string, BotmanorQuotaKey> = {\n createBotApp: 'bots',\n createAppFromTemplate: 'bots',\n createBotFromDraft: 'bots',\n createKnowledgeBase: 'knowledgeBases',\n chatWithAgent: 'messages',\n startAssistantTurn: 'messages',\n sendChannelMessage: 'messages',\n runExecution: 'runs',\n rerunExecution: 'runs',\n createExecution: 'runs',\n triggerBoundWorkflow: 'runs',\n triggerBotmanorBoundWorkflow: 'runs',\n createMCPConnection: 'mcpServers',\n draftBotFromDescription: 'aiCredits',\n suggestAgentImprovements: 'aiCredits',\n};\n\nconst QUOTA_IN_MESSAGE = /\\b(botmanor\\.[a-z_]+\\.[a-z_]+)\\b/;\n\ninterface GraphqlErrorLike {\n message?: unknown;\n extensions?: { code?: unknown; field?: unknown; limitLeft?: unknown; quotaName?: unknown };\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object';\n}\n\nfunction fromList(list: unknown): PlanLimitError | null {\n if (!Array.isArray(list)) return null;\n for (const entry of list as unknown[]) {\n if (!isObject(entry)) continue;\n const { extensions, message } = entry as GraphqlErrorLike;\n const code = extensions?.code;\n if (typeof code !== 'string' || !(PLAN_LIMIT_CODES as readonly string[]).includes(code)) {\n continue;\n }\n const named =\n typeof extensions?.quotaName === 'string'\n ? extensions.quotaName\n : typeof message === 'string'\n ? QUOTA_IN_MESSAGE.exec(message)?.[1]\n : undefined;\n return {\n code: code as PlanLimitCode,\n ...(named ? { quotaName: named } : {}),\n ...(typeof extensions?.field === 'string' ? { field: extensions.field } : {}),\n ...(typeof extensions?.limitLeft === 'number' ? { limitLeft: extensions.limitLeft } : {}),\n };\n }\n return null;\n}\n\n/**\n * The plan-limit error behind a failed operation, or null when the failure is\n * something else. Follows `cause` chains and every Apollo error shape.\n */\nexport function findPlanLimitError(error: unknown): PlanLimitError | null {\n const seen = new Set<unknown>();\n let current: unknown = error;\n while (isObject(current) && !seen.has(current)) {\n seen.add(current);\n const network = isObject(current.networkError) ? current.networkError : undefined;\n const result = isObject(current.result) ? current.result : undefined;\n const networkResult = network && isObject(network.result) ? network.result : undefined;\n const found =\n fromList(current.graphQLErrors) ??\n fromList(current.errors) ??\n fromList(result?.errors) ??\n fromList(network?.errors) ??\n fromList(networkResult?.errors);\n if (found) return found;\n current = current.cause;\n }\n if (error instanceof Error) {\n const code = PLAN_LIMIT_CODES.find((candidate) => error.message.includes(candidate));\n if (code) return { code };\n }\n return null;\n}\n\n/** Which BotManor allowance a plan-limit error is about, when it can be told. */\nexport function quotaKeyOf(error: PlanLimitError): BotmanorQuotaKey | undefined {\n if (error.quotaName && QUOTA_KEYS[error.quotaName]) return QUOTA_KEYS[error.quotaName];\n if (error.field && FIELD_KEYS[error.field]) return FIELD_KEYS[error.field];\n return undefined;\n}\n\n/** Maps a quota name from the usage API onto BotManor's allowance keys. */\nexport function quotaKeyOfName(quotaName: string): BotmanorQuotaKey | undefined {\n return QUOTA_KEYS[quotaName];\n}\n\ntype Translate = (\n key: string,\n fallback: string,\n params?: Record<string, string | number>\n) => string;\n\n/** Display name of an allowance, e.g. \"Bots\". */\nexport function quotaLabel(t: Translate, key: BotmanorQuotaKey): string {\n switch (key) {\n case 'bots':\n return t('botlit.usage.quota.bots', 'Bots');\n case 'knowledgeBases':\n return t('botlit.usage.quota.knowledgeBases', 'Knowledge bases');\n case 'messages':\n return t('botlit.usage.quota.messages', 'Messages');\n case 'runs':\n return t('botlit.usage.quota.runs', 'Bot runs');\n case 'mcpServers':\n return t('botlit.usage.quota.mcpServers', 'MCP servers');\n case 'aiCredits':\n return t('botlit.usage.quota.aiCredits', 'AI credits');\n }\n}\n\nexport interface PlanLimitCopy {\n title: string;\n description: string;\n}\n\n/** Dialog copy for a plan-limit error, specific to the allowance when known. */\nexport function planLimitCopy(t: Translate, error: PlanLimitError): PlanLimitCopy {\n if (error.code === 'QUOTA_NOT_PROVISIONED') {\n return {\n title: t('botlit.usage.notIncluded.title', 'Not included in your plan'),\n description: t(\n 'botlit.usage.notIncluded.description',\n 'Your current plan does not include this BotManor feature. Upgrade your plan to use it.'\n ),\n };\n }\n switch (quotaKeyOf(error)) {\n case 'bots':\n return {\n title: t('botlit.usage.botQuota.title', 'Bot Limit Reached'),\n description: t(\n 'botlit.usage.botQuota.description',\n 'You have reached the number of bots allowed on your current plan.'\n ),\n };\n case 'runs':\n return {\n title: t('botlit.usage.runQuota.title', 'Bot Run Limit Reached'),\n description: t(\n 'botlit.usage.runQuota.description',\n 'You have reached your bot run limit for this month.'\n ),\n };\n case 'knowledgeBases':\n return {\n title: t('botlit.usage.knowledgeBaseQuota.title', 'Knowledge Base Limit Reached'),\n description: t(\n 'botlit.usage.knowledgeBaseQuota.description',\n 'You have reached the number of knowledge bases allowed on your current plan.'\n ),\n };\n case 'messages':\n return {\n title: t('botlit.usage.messageQuota.title', 'Message Limit Reached'),\n description: t(\n 'botlit.usage.messageQuota.description',\n 'You have used all the bot messages included in your plan for this period.'\n ),\n };\n case 'mcpServers':\n return {\n title: t('botlit.usage.mcpQuota.title', 'MCP Server Limit Reached'),\n description: t(\n 'botlit.usage.mcpQuota.description',\n 'You have reached the number of MCP server connections allowed on your current plan.'\n ),\n };\n case 'aiCredits':\n return {\n title: t('botlit.usage.aiCreditQuota.title', 'AI Credits Used Up'),\n description: t(\n 'botlit.usage.aiCreditQuota.description',\n 'You have used all the AI credits included in your plan for this period.'\n ),\n };\n default:\n return {\n title: t('botlit.usage.limit.title', 'Plan Limit Reached'),\n description: t(\n 'botlit.usage.limit.description',\n 'You have reached a usage limit on your current plan. Upgrade your plan to continue.'\n ),\n };\n }\n}\n"],"mappings":";AAkBA,IAAaA,IAAmB;CAC9B;CACA;CACA;AACF,GAiBMC,IAA+C;CACnD,uBAAuB;CACvB,kCAAkC;CAClC,2BAA2B;CAC3B,uBAAuB;CACvB,8BAA8B;CAC9B,uBAAuB;AACzB,GAGMC,IAA+C;CACnD,cAAc;CACd,uBAAuB;CACvB,oBAAoB;CACpB,qBAAqB;CACrB,eAAe;CACf,oBAAoB;CACpB,oBAAoB;CACpB,cAAc;CACd,gBAAgB;CAChB,iBAAiB;CACjB,sBAAsB;CACtB,8BAA8B;CAC9B,qBAAqB;CACrB,yBAAyB;CACzB,0BAA0B;AAC5B,GAEMC,IAAmB;AAOzB,SAASC,EAAS,GAAkD;CAClE,OAAyB,OAAOC,KAAU,cAAnCA;AACT;AAEA,SAASC,EAAS,GAAsC;CACtD,IAAI,CAAC,MAAM,QAAQC,CAAI,GAAG,OAAO;CACjC,KAAK,IAAMC,KAASD,GAAmB;EACrC,IAAI,CAACH,EAASI,CAAK,GAAG;EACtB,IAAM,EAAE,eAAY,eAAYA,GAC1BC,IAAOC,GAAY;EACzB,IAAI,OAAOD,KAAS,YAAY,CAAET,EAAuC,SAASS,CAAI,GACpF;EAEF,IAAME,IACJ,OAAOD,GAAY,aAAc,WAC7BA,EAAW,YACX,OAAOE,KAAY,WACjBT,EAAiB,KAAKS,CAAO,CAAC,GAAG,KACjC,KAAA;EACR,OAAO;GACC;GACN,GAAID,IAAQ,EAAE,WAAWA,EAAM,IAAI,CAAC;GACpC,GAAI,OAAOD,GAAY,SAAU,WAAW,EAAE,OAAOA,EAAW,MAAM,IAAI,CAAC;GAC3E,GAAI,OAAOA,GAAY,aAAc,WAAW,EAAE,WAAWA,EAAW,UAAU,IAAI,CAAC;E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AAiC,aAAa;EACzD,KAAK,aACH,OAAOA,EAAE,gCAAgC,YAAY;CACzD;AACF;AAQA,SAAgBC,EAAc,GAAc,GAAsC;CAChF,IAAIZ,EAAM,SAAS,yBACjB,OAAO;EACL,OAAOW,EAAE,kCAAkC,2BAA2B;EACtE,aAAaA,EACX,wCACA,wFACF;CACF;CAEF,QAAQL,EAAWN,CAAK,GAAxB;EACE,KAAK,QACH,OAAO;GACL,OAAOW,EAAE,+BAA+B,mBAAmB;GAC3D,aAAaA,EACX,qCACA,mEACF;EACF;EACF,KAAK,QACH,OAAO;GACL,OAAOA,EAAE,+BAA+B,uBAAuB;GAC/D,aAAaA,EACX,qCACA,qDACF;EACF;EACF,KAAK,kBACH,OAAO;GACL,OAAOA,EAAE,yCAAyC,8BAA8B;GAChF,aAAaA,EACX,+CACA,8EACF;EACF;EACF,KAAK,YACH,OAAO;GACL,OAAOA,EAAE,mCAAmC,uBAAuB;GACnE,aAAaA,EACX,yCACA,2EACF;EACF;EACF,KAAK,cACH,OAAO;GACL,OAAOA,EAAE,+BAA+B,0BAA0B;GAClE,aAAaA,EACX,qCACA,qFACF;EACF;EACF,KAAK,aACH,OAAO;GACL,OAAOA,EAAE,oCAAoC,oBAAoB;GACjE,aAAaA,EACX,0CACA,yEACF;EACF;EACF,SACE,OAAO;GACL,OAAOA,EAAE,4BAA4B,oBAAoB;GACzD,aAAaA,EACX,kCACA,qFACF;EACF;CACJ;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PlanLimitError } from './quotaErrors';
|
|
2
|
+
interface MutatingClient {
|
|
3
|
+
mutate: (options: never) => Promise<unknown>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a GraphQL client so `onLimit` hears about every mutation that fails
|
|
7
|
+
* on a plan limit, whether Apollo rejects or resolves with `result.error`.
|
|
8
|
+
* Everything else passes through to the client untouched (methods stay bound
|
|
9
|
+
* to it, so Apollo's private state keeps working).
|
|
10
|
+
*/
|
|
11
|
+
export declare function watchPlanLimits<T extends MutatingClient>(client: T, onLimit: (error: PlanLimitError) => void): T;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { findPlanLimitError as e } from "./quotaErrors.js";
|
|
2
|
+
// src/botlit/utils/watchPlanLimits.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = (t) => {
|
|
5
|
+
let r = e(t);
|
|
6
|
+
r && n(r);
|
|
7
|
+
}, i = async (e) => {
|
|
8
|
+
try {
|
|
9
|
+
let n = await t.mutate(e);
|
|
10
|
+
if (typeof n == "object" && n) {
|
|
11
|
+
let e = n.error;
|
|
12
|
+
e == null ? "errors" in n && r(n) : r(e);
|
|
13
|
+
}
|
|
14
|
+
return n;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
throw r(e), e;
|
|
17
|
+
}
|
|
18
|
+
}, a = /* @__PURE__ */ new Map();
|
|
19
|
+
return new Proxy(t, { get(e, t) {
|
|
20
|
+
if (t === "mutate") return i;
|
|
21
|
+
let n = Reflect.get(e, t, e);
|
|
22
|
+
return typeof n == "function" ? (a.has(t) || a.set(t, n.bind(e)), a.get(t)) : n;
|
|
23
|
+
} });
|
|
24
|
+
}
|
|
25
|
+
export { t as watchPlanLimits };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=watchPlanLimits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchPlanLimits.js","names":["watchPlanLimits","report","limit","findPlanLimitError","failure","onLimit","mutate","result","client","options","bound","property","value","target"],"sources":["../../../src/botlit/utils/watchPlanLimits.ts"],"sourcesContent":["/**\n * Plan-limit watching for a GraphQL client (BOFF-15484)\n * @module botlit/utils\n *\n * Used by `providers/QuotaGuard.tsx`; kept out of the component file so Fast\n * Refresh can preserve the provider's state.\n */\n\nimport { findPlanLimitError, type PlanLimitError } from './quotaErrors';\n\ninterface MutatingClient {\n // `never` so any client's mutate (whatever its options type) fits; the\n // wrapper only forwards the options it was given, untouched.\n mutate: (options: never) => Promise<unknown>;\n}\n\n/**\n * Wraps a GraphQL client so `onLimit` hears about every mutation that fails\n * on a plan limit, whether Apollo rejects or resolves with `result.error`.\n * Everything else passes through to the client untouched (methods stay bound\n * to it, so Apollo's private state keeps working).\n */\nexport function watchPlanLimits<T extends MutatingClient>(\n client: T,\n onLimit: (error: PlanLimitError) => void\n): T {\n const report = (failure: unknown) => {\n const limit = findPlanLimitError(failure);\n if (limit) onLimit(limit);\n };\n const mutate = async (options: never): Promise<unknown> => {\n try {\n const result = await client.mutate(options);\n if (result !== null && typeof result === 'object') {\n // Apollo v4 resolves with `error`; an `errorPolicy: 'all'` caller gets `errors`.\n const failure = (result as { error?: unknown }).error;\n if (failure != null) report(failure);\n else if ('errors' in result) report(result);\n }\n return result;\n } catch (failure) {\n report(failure);\n throw failure;\n }\n };\n const bound = new Map<PropertyKey, unknown>();\n return new Proxy(client, {\n get(target, property) {\n if (property === 'mutate') return mutate;\n const value: unknown = Reflect.get(target, property, target);\n if (typeof value !== 'function') return value;\n // Stable identity per method, bound to the real client.\n if (!bound.has(property)) {\n bound.set(property, (value as (...args: unknown[]) => unknown).bind(target));\n }\n return bound.get(property);\n },\n });\n}\n"],"mappings":";;AAsBA,SAAgBA,EACd,GACA,GACG;CACH,IAAMC,KAAU,MAAqB;EACnC,IAAMC,IAAQC,EAAmBC,CAAO;EACxC,AAAIF,KAAOG,EAAQH,CAAK;CAC1B,GACMI,IAAS,OAAO,MAAqC;EACzD,IAAI;GACF,IAAMC,IAAS,MAAMC,EAAO,OAAOC,CAAO;GAC1C,IAAuB,OAAOF,KAAW,YAArCA,GAA+C;IAEjD,IAAMH,IAAWG,EAA+B;IAChD,AAAIH,KAAW,OACN,YAAYG,KAAQN,EAAOM,CAAM,IADrBN,EAAOG,CAAO;GAErC;GACA,OAAOG;EACT,SAASH,GAAS;GAEhB,MADAH,EAAOG,CAAO,GACRA;EACR;CACF,GACMM,oBAAQ,IAAI,IAA0B;CAC5C,OAAO,IAAI,MAAMF,GAAQ,EACvB,IAAI,GAAQ,GAAU;EACpB,IAAIG,MAAa,UAAU,OAAOL;EAClC,IAAMM,IAAiB,QAAQ,IAAIC,GAAQF,GAAUE,CAAM;EAM3D,OALI,OAAOD,KAAU,cAEhBF,EAAM,IAAIC,CAAQ,KACrBD,EAAM,IAAIC,GAAWC,EAA0C,KAAKC,CAAM,CAAC,GAEtEH,EAAM,IAAIC,CAAQ,KALeC;CAM1C,EACF,CAAC;AACH"}
|
|
@@ -2717,6 +2717,28 @@ export type RefreshMcpResourcesMutation = {
|
|
|
2717
2717
|
uri: string;
|
|
2718
2718
|
}>;
|
|
2719
2719
|
};
|
|
2720
|
+
export type BotmanorPlanUsageQueryVariables = Exact<{
|
|
2721
|
+
workspaceId: string | number;
|
|
2722
|
+
}>;
|
|
2723
|
+
export type BotmanorPlanUsageQuery = {
|
|
2724
|
+
workspaceQuotaOverview: Array<{
|
|
2725
|
+
effectiveUsed: number;
|
|
2726
|
+
remaining: number | null;
|
|
2727
|
+
usagePercentage: number;
|
|
2728
|
+
assignment: {
|
|
2729
|
+
id: string;
|
|
2730
|
+
quotaName: string;
|
|
2731
|
+
productId: string;
|
|
2732
|
+
limit: number | null;
|
|
2733
|
+
used: number;
|
|
2734
|
+
noLimit: boolean;
|
|
2735
|
+
resetPeriod: string;
|
|
2736
|
+
lastResetAt: string | null;
|
|
2737
|
+
isActive: boolean;
|
|
2738
|
+
subscriptionId: string | null;
|
|
2739
|
+
};
|
|
2740
|
+
}>;
|
|
2741
|
+
};
|
|
2720
2742
|
export type GetPolicyQueryVariables = Exact<{
|
|
2721
2743
|
id: string | number;
|
|
2722
2744
|
}>;
|
|
@@ -6248,6 +6270,36 @@ export declare function useRefreshMcpResourcesMutation(baseOptions?: ApolloReact
|
|
|
6248
6270
|
export type RefreshMcpResourcesMutationHookResult = ReturnType<typeof useRefreshMcpResourcesMutation>;
|
|
6249
6271
|
export type RefreshMcpResourcesMutationResult = Apollo.MutationResult<Types.RefreshMcpResourcesMutation>;
|
|
6250
6272
|
export type RefreshMcpResourcesMutationOptions = Apollo.BaseMutationOptions<Types.RefreshMcpResourcesMutation, Types.RefreshMcpResourcesMutationVariables>;
|
|
6273
|
+
export declare const BotmanorPlanUsageDocument: Apollo.DocumentNode;
|
|
6274
|
+
/**
|
|
6275
|
+
* __useBotmanorPlanUsageQuery__
|
|
6276
|
+
*
|
|
6277
|
+
* To run a query within a React component, call `useBotmanorPlanUsageQuery` and pass it any options that fit your needs.
|
|
6278
|
+
* When your component renders, `useBotmanorPlanUsageQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
|
6279
|
+
* you can use to render your UI.
|
|
6280
|
+
*
|
|
6281
|
+
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
|
6282
|
+
*
|
|
6283
|
+
* @example
|
|
6284
|
+
* const { data, loading, error } = useBotmanorPlanUsageQuery({
|
|
6285
|
+
* variables: {
|
|
6286
|
+
* workspaceId: // value for 'workspaceId'
|
|
6287
|
+
* },
|
|
6288
|
+
* });
|
|
6289
|
+
*/
|
|
6290
|
+
export declare function useBotmanorPlanUsageQuery(baseOptions: ApolloReactHooks.QueryHookOptions<Types.BotmanorPlanUsageQuery, Types.BotmanorPlanUsageQueryVariables> & ({
|
|
6291
|
+
variables: Types.BotmanorPlanUsageQueryVariables;
|
|
6292
|
+
skip?: boolean;
|
|
6293
|
+
} | {
|
|
6294
|
+
skip: boolean;
|
|
6295
|
+
})): ApolloReactHooks.useQuery.Result<Types.BotmanorPlanUsageQuery, Types.BotmanorPlanUsageQueryVariables, "empty" | "complete" | "streaming", Types.BotmanorPlanUsageQueryVariables, undefined>;
|
|
6296
|
+
export declare function useBotmanorPlanUsageLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<Types.BotmanorPlanUsageQuery, Types.BotmanorPlanUsageQueryVariables>): ApolloReactHooks.useLazyQuery.ResultTuple<Types.BotmanorPlanUsageQuery, Types.BotmanorPlanUsageQueryVariables, "empty" | "complete" | "streaming", undefined>;
|
|
6297
|
+
export declare function useBotmanorPlanUsageSuspenseQuery(baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<Types.BotmanorPlanUsageQuery, Types.BotmanorPlanUsageQueryVariables>): ApolloReactHooks.UseSuspenseQueryResult<Types.BotmanorPlanUsageQuery, Types.BotmanorPlanUsageQueryVariables>;
|
|
6298
|
+
export declare function useBotmanorPlanUsageSuspenseQuery(baseOptions?: ApolloReactHooks.SkipToken | ApolloReactHooks.SuspenseQueryHookOptions<Types.BotmanorPlanUsageQuery, Types.BotmanorPlanUsageQueryVariables>): ApolloReactHooks.UseSuspenseQueryResult<Types.BotmanorPlanUsageQuery | undefined, Types.BotmanorPlanUsageQueryVariables>;
|
|
6299
|
+
export type BotmanorPlanUsageQueryHookResult = ReturnType<typeof useBotmanorPlanUsageQuery>;
|
|
6300
|
+
export type BotmanorPlanUsageLazyQueryHookResult = ReturnType<typeof useBotmanorPlanUsageLazyQuery>;
|
|
6301
|
+
export type BotmanorPlanUsageSuspenseQueryHookResult = ReturnType<typeof useBotmanorPlanUsageSuspenseQuery>;
|
|
6302
|
+
export type BotmanorPlanUsageQueryResult = Apollo.QueryResult<Types.BotmanorPlanUsageQuery, Types.BotmanorPlanUsageQueryVariables>;
|
|
6251
6303
|
export declare const GetPolicyDocument: Apollo.DocumentNode;
|
|
6252
6304
|
/**
|
|
6253
6305
|
* __useGetPolicyQuery__
|