@mobileai/react-native 0.9.16 → 0.9.18

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.
Files changed (214) hide show
  1. package/README.md +2 -2
  2. package/package.json +5 -8
  3. package/lib/module/__cli_tmp__.js.map +0 -1
  4. package/lib/module/components/AIAgent.js.map +0 -1
  5. package/lib/module/components/AIZone.js.map +0 -1
  6. package/lib/module/components/AgentChatBar.js.map +0 -1
  7. package/lib/module/components/AgentErrorBoundary.js.map +0 -1
  8. package/lib/module/components/AgentOverlay.js.map +0 -1
  9. package/lib/module/components/DiscoveryTooltip.js.map +0 -1
  10. package/lib/module/components/HighlightOverlay.js.map +0 -1
  11. package/lib/module/components/Icons.js.map +0 -1
  12. package/lib/module/components/ProactiveHint.js.map +0 -1
  13. package/lib/module/components/cards/InfoCard.js.map +0 -1
  14. package/lib/module/components/cards/ReviewSummary.js.map +0 -1
  15. package/lib/module/config/endpoints.js.map +0 -1
  16. package/lib/module/core/ActionRegistry.js.map +0 -1
  17. package/lib/module/core/AgentRuntime.js.map +0 -1
  18. package/lib/module/core/FiberTreeWalker.js.map +0 -1
  19. package/lib/module/core/IdleDetector.js.map +0 -1
  20. package/lib/module/core/MCPBridge.js.map +0 -1
  21. package/lib/module/core/ScreenDehydrator.js.map +0 -1
  22. package/lib/module/core/ZoneRegistry.js.map +0 -1
  23. package/lib/module/core/systemPrompt.js.map +0 -1
  24. package/lib/module/core/types.js.map +0 -1
  25. package/lib/module/hooks/useAction.js.map +0 -1
  26. package/lib/module/index.js.map +0 -1
  27. package/lib/module/plugin/withAppIntents.js.map +0 -1
  28. package/lib/module/providers/GeminiProvider.js.map +0 -1
  29. package/lib/module/providers/OpenAIProvider.js.map +0 -1
  30. package/lib/module/providers/ProviderFactory.js.map +0 -1
  31. package/lib/module/services/AudioInputService.js.map +0 -1
  32. package/lib/module/services/AudioOutputService.js.map +0 -1
  33. package/lib/module/services/KnowledgeBaseService.js.map +0 -1
  34. package/lib/module/services/VoiceService.js.map +0 -1
  35. package/lib/module/services/flags/FlagService.js.map +0 -1
  36. package/lib/module/services/telemetry/MobileAI.js.map +0 -1
  37. package/lib/module/services/telemetry/PiiScrubber.js.map +0 -1
  38. package/lib/module/services/telemetry/TelemetryService.js.map +0 -1
  39. package/lib/module/services/telemetry/TouchAutoCapture.js.map +0 -1
  40. package/lib/module/services/telemetry/device.js.map +0 -1
  41. package/lib/module/services/telemetry/deviceMetadata.js.map +0 -1
  42. package/lib/module/services/telemetry/index.js.map +0 -1
  43. package/lib/module/services/telemetry/types.js.map +0 -1
  44. package/lib/module/support/CSATSurvey.js.map +0 -1
  45. package/lib/module/support/EscalationEventSource.js.map +0 -1
  46. package/lib/module/support/EscalationSocket.js.map +0 -1
  47. package/lib/module/support/SupportChatModal.js.map +0 -1
  48. package/lib/module/support/SupportGreeting.js.map +0 -1
  49. package/lib/module/support/TicketStore.js.map +0 -1
  50. package/lib/module/support/escalateTool.js.map +0 -1
  51. package/lib/module/support/index.js.map +0 -1
  52. package/lib/module/support/supportPrompt.js.map +0 -1
  53. package/lib/module/support/types.js.map +0 -1
  54. package/lib/module/tools/datePickerTool.js.map +0 -1
  55. package/lib/module/tools/guideTool.js.map +0 -1
  56. package/lib/module/tools/index.js.map +0 -1
  57. package/lib/module/tools/keyboardTool.js.map +0 -1
  58. package/lib/module/tools/longPressTool.js.map +0 -1
  59. package/lib/module/tools/pickerTool.js.map +0 -1
  60. package/lib/module/tools/restoreTool.js.map +0 -1
  61. package/lib/module/tools/scrollTool.js.map +0 -1
  62. package/lib/module/tools/simplifyTool.js.map +0 -1
  63. package/lib/module/tools/sliderTool.js.map +0 -1
  64. package/lib/module/tools/tapTool.js.map +0 -1
  65. package/lib/module/tools/typeTool.js.map +0 -1
  66. package/lib/module/tools/types.js.map +0 -1
  67. package/lib/module/types/jsx.d.js.map +0 -1
  68. package/lib/module/utils/audioUtils.js.map +0 -1
  69. package/lib/module/utils/logger.js.map +0 -1
  70. package/lib/typescript/babel.config.d.ts.map +0 -1
  71. package/lib/typescript/bin/generate-map.d.cts.map +0 -1
  72. package/lib/typescript/eslint.config.d.mts.map +0 -1
  73. package/lib/typescript/generate-map.d.ts.map +0 -1
  74. package/lib/typescript/src/__cli_tmp__.d.ts.map +0 -1
  75. package/lib/typescript/src/components/AIAgent.d.ts.map +0 -1
  76. package/lib/typescript/src/components/AIZone.d.ts.map +0 -1
  77. package/lib/typescript/src/components/AgentChatBar.d.ts.map +0 -1
  78. package/lib/typescript/src/components/AgentErrorBoundary.d.ts.map +0 -1
  79. package/lib/typescript/src/components/AgentOverlay.d.ts.map +0 -1
  80. package/lib/typescript/src/components/DiscoveryTooltip.d.ts.map +0 -1
  81. package/lib/typescript/src/components/HighlightOverlay.d.ts.map +0 -1
  82. package/lib/typescript/src/components/Icons.d.ts.map +0 -1
  83. package/lib/typescript/src/components/ProactiveHint.d.ts.map +0 -1
  84. package/lib/typescript/src/components/cards/InfoCard.d.ts.map +0 -1
  85. package/lib/typescript/src/components/cards/ReviewSummary.d.ts.map +0 -1
  86. package/lib/typescript/src/config/endpoints.d.ts.map +0 -1
  87. package/lib/typescript/src/core/ActionRegistry.d.ts.map +0 -1
  88. package/lib/typescript/src/core/AgentRuntime.d.ts.map +0 -1
  89. package/lib/typescript/src/core/FiberTreeWalker.d.ts.map +0 -1
  90. package/lib/typescript/src/core/IdleDetector.d.ts.map +0 -1
  91. package/lib/typescript/src/core/MCPBridge.d.ts.map +0 -1
  92. package/lib/typescript/src/core/ScreenDehydrator.d.ts.map +0 -1
  93. package/lib/typescript/src/core/ZoneRegistry.d.ts.map +0 -1
  94. package/lib/typescript/src/core/systemPrompt.d.ts.map +0 -1
  95. package/lib/typescript/src/core/types.d.ts.map +0 -1
  96. package/lib/typescript/src/hooks/useAction.d.ts.map +0 -1
  97. package/lib/typescript/src/index.d.ts.map +0 -1
  98. package/lib/typescript/src/plugin/withAppIntents.d.ts.map +0 -1
  99. package/lib/typescript/src/providers/GeminiProvider.d.ts.map +0 -1
  100. package/lib/typescript/src/providers/OpenAIProvider.d.ts.map +0 -1
  101. package/lib/typescript/src/providers/ProviderFactory.d.ts.map +0 -1
  102. package/lib/typescript/src/services/AudioInputService.d.ts.map +0 -1
  103. package/lib/typescript/src/services/AudioOutputService.d.ts.map +0 -1
  104. package/lib/typescript/src/services/KnowledgeBaseService.d.ts.map +0 -1
  105. package/lib/typescript/src/services/VoiceService.d.ts.map +0 -1
  106. package/lib/typescript/src/services/flags/FlagService.d.ts.map +0 -1
  107. package/lib/typescript/src/services/telemetry/MobileAI.d.ts.map +0 -1
  108. package/lib/typescript/src/services/telemetry/PiiScrubber.d.ts.map +0 -1
  109. package/lib/typescript/src/services/telemetry/TelemetryService.d.ts.map +0 -1
  110. package/lib/typescript/src/services/telemetry/TouchAutoCapture.d.ts.map +0 -1
  111. package/lib/typescript/src/services/telemetry/device.d.ts.map +0 -1
  112. package/lib/typescript/src/services/telemetry/deviceMetadata.d.ts.map +0 -1
  113. package/lib/typescript/src/services/telemetry/index.d.ts.map +0 -1
  114. package/lib/typescript/src/services/telemetry/types.d.ts.map +0 -1
  115. package/lib/typescript/src/support/CSATSurvey.d.ts.map +0 -1
  116. package/lib/typescript/src/support/EscalationEventSource.d.ts.map +0 -1
  117. package/lib/typescript/src/support/EscalationSocket.d.ts.map +0 -1
  118. package/lib/typescript/src/support/SupportChatModal.d.ts.map +0 -1
  119. package/lib/typescript/src/support/SupportGreeting.d.ts.map +0 -1
  120. package/lib/typescript/src/support/TicketStore.d.ts.map +0 -1
  121. package/lib/typescript/src/support/escalateTool.d.ts.map +0 -1
  122. package/lib/typescript/src/support/index.d.ts.map +0 -1
  123. package/lib/typescript/src/support/supportPrompt.d.ts.map +0 -1
  124. package/lib/typescript/src/support/types.d.ts.map +0 -1
  125. package/lib/typescript/src/tools/datePickerTool.d.ts.map +0 -1
  126. package/lib/typescript/src/tools/guideTool.d.ts.map +0 -1
  127. package/lib/typescript/src/tools/index.d.ts.map +0 -1
  128. package/lib/typescript/src/tools/keyboardTool.d.ts.map +0 -1
  129. package/lib/typescript/src/tools/longPressTool.d.ts.map +0 -1
  130. package/lib/typescript/src/tools/pickerTool.d.ts.map +0 -1
  131. package/lib/typescript/src/tools/restoreTool.d.ts.map +0 -1
  132. package/lib/typescript/src/tools/scrollTool.d.ts.map +0 -1
  133. package/lib/typescript/src/tools/simplifyTool.d.ts.map +0 -1
  134. package/lib/typescript/src/tools/sliderTool.d.ts.map +0 -1
  135. package/lib/typescript/src/tools/tapTool.d.ts.map +0 -1
  136. package/lib/typescript/src/tools/typeTool.d.ts.map +0 -1
  137. package/lib/typescript/src/tools/types.d.ts.map +0 -1
  138. package/lib/typescript/src/utils/audioUtils.d.ts.map +0 -1
  139. package/lib/typescript/src/utils/logger.d.ts.map +0 -1
  140. package/src/__cli_tmp__.tsx +0 -9
  141. package/src/cli/analyzers/chain-analyzer.ts +0 -183
  142. package/src/cli/extractors/ai-extractor.ts +0 -6
  143. package/src/cli/extractors/ast-extractor.ts +0 -551
  144. package/src/cli/generate-intents.ts +0 -140
  145. package/src/cli/generate-map.ts +0 -121
  146. package/src/cli/generate-swift.ts +0 -116
  147. package/src/cli/scanners/expo-scanner.ts +0 -203
  148. package/src/cli/scanners/rn-scanner.ts +0 -445
  149. package/src/components/AIAgent.tsx +0 -1716
  150. package/src/components/AIZone.tsx +0 -147
  151. package/src/components/AgentChatBar.tsx +0 -1143
  152. package/src/components/AgentErrorBoundary.tsx +0 -78
  153. package/src/components/AgentOverlay.tsx +0 -73
  154. package/src/components/DiscoveryTooltip.tsx +0 -148
  155. package/src/components/HighlightOverlay.tsx +0 -136
  156. package/src/components/Icons.tsx +0 -253
  157. package/src/components/ProactiveHint.tsx +0 -145
  158. package/src/components/cards/InfoCard.tsx +0 -58
  159. package/src/components/cards/ReviewSummary.tsx +0 -76
  160. package/src/config/endpoints.ts +0 -22
  161. package/src/core/ActionRegistry.ts +0 -105
  162. package/src/core/AgentRuntime.ts +0 -1471
  163. package/src/core/FiberTreeWalker.ts +0 -930
  164. package/src/core/IdleDetector.ts +0 -72
  165. package/src/core/MCPBridge.ts +0 -163
  166. package/src/core/ScreenDehydrator.ts +0 -53
  167. package/src/core/ZoneRegistry.ts +0 -44
  168. package/src/core/systemPrompt.ts +0 -431
  169. package/src/core/types.ts +0 -521
  170. package/src/hooks/useAction.ts +0 -182
  171. package/src/index.ts +0 -83
  172. package/src/plugin/withAppIntents.ts +0 -98
  173. package/src/providers/GeminiProvider.ts +0 -357
  174. package/src/providers/OpenAIProvider.ts +0 -379
  175. package/src/providers/ProviderFactory.ts +0 -36
  176. package/src/services/AudioInputService.ts +0 -226
  177. package/src/services/AudioOutputService.ts +0 -236
  178. package/src/services/KnowledgeBaseService.ts +0 -156
  179. package/src/services/VoiceService.ts +0 -451
  180. package/src/services/flags/FlagService.ts +0 -137
  181. package/src/services/telemetry/MobileAI.ts +0 -66
  182. package/src/services/telemetry/PiiScrubber.ts +0 -17
  183. package/src/services/telemetry/TelemetryService.ts +0 -323
  184. package/src/services/telemetry/TouchAutoCapture.ts +0 -165
  185. package/src/services/telemetry/device.ts +0 -93
  186. package/src/services/telemetry/deviceMetadata.ts +0 -13
  187. package/src/services/telemetry/index.ts +0 -13
  188. package/src/services/telemetry/types.ts +0 -75
  189. package/src/support/CSATSurvey.tsx +0 -304
  190. package/src/support/EscalationEventSource.ts +0 -190
  191. package/src/support/EscalationSocket.ts +0 -152
  192. package/src/support/SupportChatModal.tsx +0 -563
  193. package/src/support/SupportGreeting.tsx +0 -161
  194. package/src/support/TicketStore.ts +0 -100
  195. package/src/support/escalateTool.ts +0 -174
  196. package/src/support/index.ts +0 -29
  197. package/src/support/supportPrompt.ts +0 -55
  198. package/src/support/types.ts +0 -155
  199. package/src/tools/datePickerTool.ts +0 -60
  200. package/src/tools/guideTool.ts +0 -76
  201. package/src/tools/index.ts +0 -20
  202. package/src/tools/keyboardTool.ts +0 -30
  203. package/src/tools/longPressTool.ts +0 -61
  204. package/src/tools/pickerTool.ts +0 -115
  205. package/src/tools/restoreTool.ts +0 -33
  206. package/src/tools/scrollTool.ts +0 -156
  207. package/src/tools/simplifyTool.ts +0 -33
  208. package/src/tools/sliderTool.ts +0 -65
  209. package/src/tools/tapTool.ts +0 -93
  210. package/src/tools/typeTool.ts +0 -113
  211. package/src/tools/types.ts +0 -58
  212. package/src/types/jsx.d.ts +0 -20
  213. package/src/utils/audioUtils.ts +0 -54
  214. package/src/utils/logger.ts +0 -38
@@ -1,145 +0,0 @@
1
- import React, { useEffect, useRef } from 'react';
2
- import { View, Animated, StyleSheet, Text, Pressable } from 'react-native';
3
-
4
- interface ProactiveHintProps {
5
- stage: 'hidden' | 'pulse' | 'badge';
6
- badgeText?: string;
7
- onDismiss: () => void;
8
- children: React.ReactNode;
9
- }
10
-
11
- export function ProactiveHint({ stage, badgeText = "Need help?", onDismiss, children }: ProactiveHintProps) {
12
- const pulseAnim = useRef(new Animated.Value(1)).current;
13
- const opacityAnim = useRef(new Animated.Value(0)).current;
14
- const badgeScale = useRef(new Animated.Value(0)).current;
15
-
16
- useEffect(() => {
17
- // Pulse animation logic
18
- if (stage === 'pulse') {
19
- Animated.loop(
20
- Animated.sequence([
21
- Animated.parallel([
22
- Animated.timing(pulseAnim, {
23
- toValue: 1.3,
24
- duration: 1500,
25
- useNativeDriver: true,
26
- }),
27
- Animated.timing(opacityAnim, {
28
- toValue: 0,
29
- duration: 1500,
30
- useNativeDriver: true,
31
- }),
32
- ]),
33
- Animated.timing(pulseAnim, {
34
- toValue: 1,
35
- duration: 0,
36
- useNativeDriver: true,
37
- }),
38
- Animated.timing(opacityAnim, {
39
- toValue: 0.8,
40
- duration: 0,
41
- useNativeDriver: true,
42
- }),
43
- ])
44
- ).start();
45
- } else {
46
- pulseAnim.stopAnimation();
47
- opacityAnim.stopAnimation();
48
- pulseAnim.setValue(1);
49
- opacityAnim.setValue(0);
50
- }
51
-
52
- // Badge animation logic
53
- if (stage === 'badge') {
54
- Animated.spring(badgeScale, {
55
- toValue: 1,
56
- friction: 5,
57
- tension: 100,
58
- useNativeDriver: true,
59
- }).start();
60
- } else {
61
- badgeScale.setValue(0);
62
- }
63
- }, [stage, pulseAnim, opacityAnim, badgeScale]);
64
-
65
- return (
66
- <View style={styles.container}>
67
- {/* Badge State */}
68
- {stage === 'badge' && (
69
- <Animated.View style={[styles.badgeContainer, { transform: [{ scale: badgeScale }] }]}>
70
- <Text style={styles.badgeText}>{badgeText}</Text>
71
- <Pressable hitSlop={10} style={styles.closeButton} onPress={onDismiss}>
72
- <Text style={styles.closeText}>×</Text>
73
- </Pressable>
74
- </Animated.View>
75
- )}
76
-
77
- {/* Pulse effect under children */}
78
- {stage === 'pulse' && (
79
- <Animated.View
80
- style={[
81
- styles.pulseRing,
82
- {
83
- transform: [{ scale: pulseAnim }],
84
- opacity: opacityAnim,
85
- },
86
- ]}
87
- />
88
- )}
89
-
90
- {/* The main FAB or children */}
91
- {children}
92
- </View>
93
- );
94
- }
95
-
96
- const styles = StyleSheet.create({
97
- container: {
98
- alignItems: 'center',
99
- justifyContent: 'center',
100
- },
101
- pulseRing: {
102
- position: 'absolute',
103
- width: 60,
104
- height: 60,
105
- borderRadius: 30,
106
- backgroundColor: '#7B68EE',
107
- },
108
- badgeContainer: {
109
- position: 'absolute',
110
- bottom: 70, // Float above the FAB
111
- right: 0,
112
- flexDirection: 'row',
113
- alignItems: 'center',
114
- backgroundColor: '#ffffff',
115
- paddingHorizontal: 12,
116
- paddingVertical: 8,
117
- borderRadius: 20,
118
- shadowColor: '#000',
119
- shadowOffset: { width: 0, height: 2 },
120
- shadowOpacity: 0.15,
121
- shadowRadius: 4,
122
- elevation: 4,
123
- minWidth: 120,
124
- },
125
- badgeText: {
126
- color: '#333333',
127
- fontSize: 14,
128
- fontWeight: '500',
129
- marginRight: 8,
130
- },
131
- closeButton: {
132
- justifyContent: 'center',
133
- alignItems: 'center',
134
- width: 20,
135
- height: 20,
136
- borderRadius: 10,
137
- backgroundColor: '#f0f0f0',
138
- },
139
- closeText: {
140
- fontSize: 14,
141
- color: '#666',
142
- fontWeight: 'bold',
143
- marginTop: -2,
144
- },
145
- });
@@ -1,58 +0,0 @@
1
- import { View, Text, StyleSheet } from 'react-native';
2
-
3
- interface InfoCardProps {
4
- title?: string;
5
- body?: string;
6
- icon?: string;
7
- }
8
-
9
- /**
10
- * Built-in card template for AI injection.
11
- *
12
- * IMPORTANT: displayName must be set explicitly here.
13
- * In production/minified builds, the function name is mangled (e.g. `a`, `b`),
14
- * so `injectCardTool` cannot identify templates by inferred name alone.
15
- * Always look up templates by `T.displayName`, never by `T.name`.
16
- */
17
- export function InfoCard({ title = 'Info', body = '', icon = 'ℹ️' }: InfoCardProps) {
18
- return (
19
- <View style={styles.container}>
20
- <Text style={styles.icon}>{icon}</Text>
21
- <View style={styles.content}>
22
- <Text style={styles.title}>{title}</Text>
23
- {body ? <Text style={styles.body}>{body}</Text> : null}
24
- </View>
25
- </View>
26
- );
27
- }
28
-
29
- // Must be explicit — minification mangles function.name in production builds.
30
- InfoCard.displayName = 'InfoCard';
31
-
32
- const styles = StyleSheet.create({
33
- container: {
34
- flexDirection: 'row',
35
- alignItems: 'flex-start',
36
- backgroundColor: '#f0f7ff',
37
- borderRadius: 10,
38
- padding: 12,
39
- gap: 10,
40
- },
41
- icon: {
42
- fontSize: 22,
43
- },
44
- content: {
45
- flex: 1,
46
- },
47
- title: {
48
- fontWeight: '600',
49
- fontSize: 14,
50
- color: '#1a1a2e',
51
- marginBottom: 2,
52
- },
53
- body: {
54
- fontSize: 13,
55
- color: '#444',
56
- lineHeight: 18,
57
- },
58
- });
@@ -1,76 +0,0 @@
1
- import { View, Text, StyleSheet } from 'react-native';
2
-
3
- interface ReviewSummaryProps {
4
- rating?: number; // 0-5
5
- reviewCount?: number;
6
- headline?: string;
7
- sentiment?: 'positive' | 'neutral' | 'negative';
8
- }
9
-
10
- /**
11
- * Built-in card template that shows a product/service review summary.
12
- * Injected by the AI agent to surface social proof at decision points.
13
- *
14
- * IMPORTANT: displayName is set explicitly to survive minification.
15
- * The injectCardTool resolves templates by `T.displayName`, not `T.name`.
16
- */
17
- export function ReviewSummary({
18
- rating = 0,
19
- reviewCount = 0,
20
- headline = 'Customer Reviews',
21
- sentiment = 'neutral',
22
- }: ReviewSummaryProps) {
23
- const stars = Math.round(Math.min(5, Math.max(0, rating)));
24
- const filled = '★'.repeat(stars);
25
- const empty = '☆'.repeat(5 - stars);
26
-
27
- const sentimentColor: Record<ReviewSummaryProps['sentiment'] & string, string> = {
28
- positive: '#16a34a',
29
- neutral: '#6b7280',
30
- negative: '#dc2626',
31
- };
32
-
33
- return (
34
- <View style={styles.container}>
35
- <Text style={styles.headline}>{headline}</Text>
36
- <View style={styles.row}>
37
- <Text style={[styles.stars, { color: sentimentColor[sentiment] }]}>
38
- {filled}{empty}
39
- </Text>
40
- <Text style={styles.meta}>
41
- {rating.toFixed(1)} · {reviewCount.toLocaleString()} reviews
42
- </Text>
43
- </View>
44
- </View>
45
- );
46
- }
47
-
48
- // Explicit — function.name is mangled in minified production builds.
49
- ReviewSummary.displayName = 'ReviewSummary';
50
-
51
- const styles = StyleSheet.create({
52
- container: {
53
- backgroundColor: '#fffbeb',
54
- borderRadius: 10,
55
- padding: 12,
56
- },
57
- headline: {
58
- fontWeight: '600',
59
- fontSize: 13,
60
- color: '#1a1a2e',
61
- marginBottom: 6,
62
- },
63
- row: {
64
- flexDirection: 'row',
65
- alignItems: 'center',
66
- gap: 8,
67
- },
68
- stars: {
69
- fontSize: 18,
70
- letterSpacing: 1,
71
- },
72
- meta: {
73
- fontSize: 12,
74
- color: '#6b7280',
75
- },
76
- });
@@ -1,22 +0,0 @@
1
- /**
2
- * SDK Endpoint Configuration
3
- *
4
- * All MobileAI backend URLs live here.
5
- * Change these to point to a self-hosted or staging server.
6
- *
7
- * Enterprise customers: use the `analyticsProxyUrl` prop on <AIAgent>
8
- * to route telemetry through your own backend without touching this file.
9
- */
10
-
11
- const MOBILEAI_BASE = 'http://localhost:3001';
12
-
13
- export const ENDPOINTS = {
14
- /** Telemetry event ingest — receives batched SDK events */
15
- telemetryIngest: `${MOBILEAI_BASE}/api/v1/events`,
16
-
17
- /** Feature flag sync — fetches remote flags for this analyticsKey */
18
- featureFlags: `${MOBILEAI_BASE}/api/v1/flags`,
19
-
20
- /** Live agent escalation (support handoff) */
21
- escalation: `${MOBILEAI_BASE}`,
22
- } as const;
@@ -1,105 +0,0 @@
1
- import type { ActionDefinition, ActionParameterDef } from './types';
2
-
3
- export interface MCPToolDeclaration {
4
- name: string;
5
- description: string;
6
- inputSchema: {
7
- type: string;
8
- properties: Record<string, any>;
9
- required: string[];
10
- };
11
- }
12
-
13
- /**
14
- * A central registry for all actions registered via `useAction`.
15
- * This acts as the single source of truth for:
16
- * 1. The in-app AI Agent (AgentRuntime)
17
- * 2. The MCP Server (external agents)
18
- * 3. iOS App Intents (Siri)
19
- * 4. Android AppFunctions (Gemini)
20
- */
21
- export class ActionRegistry {
22
- private actions = new Map<string, ActionDefinition>();
23
- private listeners = new Set<() => void>();
24
-
25
- /** Register a new action definition */
26
- register(action: ActionDefinition): void {
27
- this.actions.set(action.name, action);
28
- this.notify();
29
- }
30
-
31
- /** Unregister an action by name */
32
- unregister(name: string): void {
33
- this.actions.delete(name);
34
- this.notify();
35
- }
36
-
37
- /** Get a specific action by name */
38
- get(name: string): ActionDefinition | undefined {
39
- return this.actions.get(name);
40
- }
41
-
42
- /** Get all registered actions */
43
- getAll(): ActionDefinition[] {
44
- return Array.from(this.actions.values());
45
- }
46
-
47
- /** Clear all registered actions (useful for testing) */
48
- clear(): void {
49
- this.actions.clear();
50
- this.notify();
51
- }
52
-
53
- /**
54
- * Subscribe to changes (e.g. when a new screen mounts and registers actions).
55
- * Useful for the MCP server to re-announce tools.
56
- */
57
- onChange(listener: () => void): () => void {
58
- this.listeners.add(listener);
59
- return () => {
60
- this.listeners.delete(listener);
61
- };
62
- }
63
-
64
- /** Serialize all actions as strictly-typed MCP tool declarations */
65
- toMCPTools(): MCPToolDeclaration[] {
66
- return this.getAll().map((a) => ({
67
- name: a.name,
68
- description: a.description,
69
- inputSchema: this.buildInputSchema(a.parameters),
70
- }));
71
- }
72
-
73
- private buildInputSchema(params: Record<string, string | ActionParameterDef>) {
74
- const properties: Record<string, any> = {};
75
- const required: string[] = [];
76
-
77
- for (const [key, val] of Object.entries(params)) {
78
- if (typeof val === 'string') {
79
- // Backward compatibility: passing a string means it's a required string param.
80
- properties[key] = { type: 'string', description: val };
81
- required.push(key);
82
- } else {
83
- // New strict parameter definition
84
- properties[key] = { type: val.type, description: val.description };
85
- if (val.enum) {
86
- properties[key].enum = val.enum;
87
- }
88
- if (val.required !== false) {
89
- required.push(key);
90
- }
91
- }
92
- }
93
-
94
- return { type: 'object', properties, required };
95
- }
96
-
97
- private notify() {
98
- this.listeners.forEach((l) => l());
99
- }
100
- }
101
-
102
- // Export a singleton instance.
103
- // This allows background channels (like App Intents bridging) to access actions
104
- // even if the React tree hasn't accessed the AIAgent context yet.
105
- export const actionRegistry = new ActionRegistry();