packages/config/ai-capabilities.ts
1/** Single registry shared by Studio switches and server enforcement. */
2export const AI_TOOL_DEFINITIONS = [
3 { name: 'unleashAmerica', title: 'Miami event knowledge' },
4 { name: 'unleashWorld', title: 'Paris event knowledge' },
5 { name: 'unleashAmericaAgenda', title: 'Miami agenda search' },
6 { name: 'unleashWorldAgenda', title: 'Paris agenda search' },
7 { name: 'generalKnowledge', title: 'General knowledge and FAQs' },
8 {
9 name: 'eventFacts',
10 title:
11 'Verified event policies, volunteering and exhibitor support (read only)',
12 },
13 { name: 'unleashSales', title: 'Sales knowledge (read only)' },
14 { name: 'unleashSalesSpex', title: 'Sponsor/exhibitor knowledge (read only)' },
15 { name: 'mediaCatalogue', title: 'Media catalogue' },
16 { name: 'siteMap', title: 'Site page search' },
17 { name: 'recentArticles', title: 'Recent articles' },
18 { name: 'upcomingWebinars', title: 'Upcoming webinars' },
19 { name: 'agendaLookup', title: 'Session and speaker lookup' },
20 { name: 'badgesLookup', title: 'Badge and live price lookup' },
21 { name: 'pageDirectory', title: 'Event pages and hotel booking links' },
22 { name: 'buildAgenda', title: 'Build a personal agenda in chat' },
23 { name: 'submitLead', title: 'Submit ticket / sponsor / exhibitor enquiries' },
24 { name: 'sendAgendaByEmail', title: 'Send an agenda by email' },
25] as const
26export type AiToolName = (typeof AI_TOOL_DEFINITIONS)[number]['name']
27export type AiCapabilities = {
28 productionEnabled: boolean
29 allowEmailSubmissions: boolean
30 tools: Partial<Record<AiToolName, boolean>>
31}
32export function aiToolEnabled(
33 config: AiCapabilities,
34 name: AiToolName,
35): boolean {
36 if (
37 (name === 'submitLead' || name === 'sendAgendaByEmail') &&
38 !config.allowEmailSubmissions
39 )
40 return false
41 if (name === 'sendAgendaByEmail' && config.tools.buildAgenda === false)
42 return false
43 return config.tools[name] !== false
44}
45export function aiProductionVisible(
46 config: AiCapabilities,
47 environment?: string,
48 emergencyOverride?: string,
49) {
50 return (
51 environment !== 'production' ||
52 (emergencyOverride !== 'false' && config.productionEnabled)
53 )
54}
55
56/** Demo permission applies only to the pre-prod Preview deployment, never production. */
57export function aiSubmissionsAllowed(
58 settings: {
59 allowEmailSubmissions?: boolean | null
60 stagingEmailSubmissions?: boolean | null
61 },
62 environment?: string,
63 branch?: string,
64) {
65 if (environment === 'preview' && branch === 'pre-prod')
66 return settings.stagingEmailSubmissions === true
67 return settings.allowEmailSubmissions === true
68}
69