@gemies/sdk 0.0.0-stage → 1.1.0

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 (246) hide show
  1. package/CHANGELOG.md +1678 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +15 -0
  4. package/README.md +516 -2
  5. package/package.json +105 -4
  6. package/src/accounts.ts +29 -0
  7. package/src/animations.ts +5 -0
  8. package/src/ask-eager.ts +8 -0
  9. package/src/ask-text.ts +11 -0
  10. package/src/ask.ts +12 -0
  11. package/src/avatar.ts +13 -0
  12. package/src/character.ts +1 -0
  13. package/src/components/AmbientField.tsx +580 -0
  14. package/src/components/ComposerDropZone.tsx +235 -0
  15. package/src/components/ComposerSuggestions.tsx +45 -0
  16. package/src/components/GemieAccounts.tsx +433 -0
  17. package/src/components/GemieAskCore.tsx +184 -0
  18. package/src/components/GemieAskProvider.tsx +18 -0
  19. package/src/components/GemieAskProviderLazy.tsx +27 -0
  20. package/src/components/GemieAskProviderText.tsx +25 -0
  21. package/src/components/GemieAskSheet.tsx +51 -0
  22. package/src/components/GemieAskSheetWithVoice.tsx +10 -0
  23. package/src/components/GemieAvatar.tsx +57 -0
  24. package/src/components/GemieAvatarIcon.tsx +35 -0
  25. package/src/components/GemieChatContent.tsx +900 -0
  26. package/src/components/GemieChatHeader.tsx +123 -0
  27. package/src/components/GemieChatScreen.tsx +170 -0
  28. package/src/components/GemieChatSheet.tsx +368 -0
  29. package/src/components/GemieChatWithVoice.tsx +13 -0
  30. package/src/components/GemieComposer.tsx +388 -0
  31. package/src/components/GemieGroupWelcome.tsx +37 -0
  32. package/src/components/GemieParticipants.tsx +133 -0
  33. package/src/components/GemieParticipantsHeader.tsx +27 -0
  34. package/src/components/GemieRecentConversations.tsx +65 -0
  35. package/src/components/GemieSharedConversation.tsx +87 -0
  36. package/src/components/GemieWelcomeMessage.tsx +58 -0
  37. package/src/components/IdentityMark.tsx +225 -0
  38. package/src/components/Image.tsx +12 -0
  39. package/src/components/InertWhen.tsx +48 -0
  40. package/src/components/PlanPreviewCard.tsx +53 -0
  41. package/src/components/QuestionCard.tsx +64 -0
  42. package/src/components/ReplyMarkdown.tsx +373 -0
  43. package/src/components/RichBlocks.tsx +195 -0
  44. package/src/components/VoiceModeIcon.tsx +18 -0
  45. package/src/components/canvas/CanvasComponent.tsx +65 -0
  46. package/src/components/canvas/ChartRenderer.tsx +73 -0
  47. package/src/components/canvas/CodeRenderer.tsx +20 -0
  48. package/src/components/canvas/DashboardRenderer.tsx +70 -0
  49. package/src/components/canvas/DeckRenderer.tsx +43 -0
  50. package/src/components/canvas/FormRenderer.tsx +101 -0
  51. package/src/components/canvas/MarkdownRenderer.tsx +14 -0
  52. package/src/components/canvas/TableRenderer.tsx +47 -0
  53. package/src/components/icons/RiEmojiPicker.tsx +39 -0
  54. package/src/components/icons/RiMoreDots.tsx +32 -0
  55. package/src/components/icons/RiReplyLine.tsx +25 -0
  56. package/src/components/thought/FilesAndSources.tsx +120 -0
  57. package/src/components/thought/ThoughtPanel.tsx +426 -0
  58. package/src/components/thought/ToolStep.tsx +134 -0
  59. package/src/components/thread/AgentExchangeView.tsx +112 -0
  60. package/src/components/thread/AgentResultCard.tsx +125 -0
  61. package/src/components/thread/AgentTaskCard.tsx +127 -0
  62. package/src/components/thread/ChatBubble.tsx +256 -0
  63. package/src/components/thread/GemieThread.tsx +455 -0
  64. package/src/components/thread/MessageBlockBoundary.tsx +78 -0
  65. package/src/components/thread/NewConversationOffer.tsx +54 -0
  66. package/src/components/thread/ThreadRow.tsx +598 -0
  67. package/src/components/thread/ThreadSearch.tsx +130 -0
  68. package/src/components/thread/ThreadSkeleton.tsx +30 -0
  69. package/src/components/thread/ToolResultCard.tsx +254 -0
  70. package/src/components/thread/TurnMenu.tsx +54 -0
  71. package/src/components/thread/TurnStatusLine.tsx +34 -0
  72. package/src/components/voice/GemieVoiceCall.tsx +21 -0
  73. package/src/components/voice/GemieVoiceCall.web.tsx +17 -0
  74. package/src/components/voice/VoiceCallContext.ts +13 -0
  75. package/src/components/voice/VoiceControls.tsx +106 -0
  76. package/src/components/voice/VoiceSession.tsx +120 -0
  77. package/src/components/voice/withVoiceCall.tsx +25 -0
  78. package/src/csp.ts +50 -0
  79. package/src/dictation.ts +40 -0
  80. package/src/hooks/useAmbientWave.ts +184 -0
  81. package/src/hooks/useAtBottom.ts +51 -0
  82. package/src/hooks/useAttachMenu.ts +93 -0
  83. package/src/hooks/useAttachmentIntake.ts +401 -0
  84. package/src/hooks/useAudioLevelMonitor.ts +46 -0
  85. package/src/hooks/useAudioLevels.ts +51 -0
  86. package/src/hooks/useChatComposer.ts +309 -0
  87. package/src/hooks/useChatVoice.ts +129 -0
  88. package/src/hooks/useComposerSuggestions.ts +84 -0
  89. package/src/hooks/useDictation.ts +292 -0
  90. package/src/hooks/useDocumentPicker.ts +11 -0
  91. package/src/hooks/useFailedTurnToast.ts +43 -0
  92. package/src/hooks/useFocusWhenPresented.ts +41 -0
  93. package/src/hooks/useGemieActivity.ts +31 -0
  94. package/src/hooks/useImagePicker.ts +38 -0
  95. package/src/hooks/useMessageReactions.ts +119 -0
  96. package/src/hooks/useMessageVote.ts +50 -0
  97. package/src/hooks/useOpenThought.ts +79 -0
  98. package/src/hooks/usePendingQuestions.ts +19 -0
  99. package/src/hooks/useReadAloud.ts +92 -0
  100. package/src/hooks/useShareHandler.ts +24 -0
  101. package/src/hooks/useSoundEffects.ts +137 -0
  102. package/src/hooks/useTTS.ts +303 -0
  103. package/src/hooks/useThoughtScope.ts +59 -0
  104. package/src/hooks/useThreadRows.ts +157 -0
  105. package/src/hooks/useThreadView.ts +67 -0
  106. package/src/hooks/useTimelineWindow.ts +256 -0
  107. package/src/hooks/useVoiceLauncher.ts +180 -0
  108. package/src/hooks/useVoiceRoom.ts +212 -0
  109. package/src/index.ts +141 -0
  110. package/src/lib/activity-socket.ts +102 -0
  111. package/src/lib/activity-store.ts +53 -0
  112. package/src/lib/add-menu.ts +7 -0
  113. package/src/lib/agent-character.ts +28 -0
  114. package/src/lib/alia-character.ts +14 -0
  115. package/src/lib/alia-gemie.ts +6 -0
  116. package/src/lib/attachment-intake.ts +154 -0
  117. package/src/lib/attachment-tiles.ts +74 -0
  118. package/src/lib/audio-level.ts +130 -0
  119. package/src/lib/audio-request-auth.ts +4 -0
  120. package/src/lib/audio-session-binding.ts +27 -0
  121. package/src/lib/bubbles.tsx +16 -0
  122. package/src/lib/call-thread.ts +33 -0
  123. package/src/lib/canvas-result.ts +21 -0
  124. package/src/lib/catalogue-tool.ts +22 -0
  125. package/src/lib/citations.ts +192 -0
  126. package/src/lib/clipboard.ts +23 -0
  127. package/src/lib/content-utils.ts +46 -0
  128. package/src/lib/copy-en.ts +333 -0
  129. package/src/lib/copy-es.ts +330 -0
  130. package/src/lib/copy.ts +38 -0
  131. package/src/lib/deferred/document-picker.ts +2 -0
  132. package/src/lib/deferred/document-picker.web.ts +12 -0
  133. package/src/lib/deferred/expo-audio.ts +2 -0
  134. package/src/lib/deferred/expo-audio.web.ts +12 -0
  135. package/src/lib/deferred/image-data-url.ts +5 -0
  136. package/src/lib/deferred/image-data-url.web.ts +12 -0
  137. package/src/lib/dictation-protocol.ts +142 -0
  138. package/src/lib/dictation-recorder-types.ts +37 -0
  139. package/src/lib/dictation-recorder.native.ts +90 -0
  140. package/src/lib/dictation-recorder.ts +131 -0
  141. package/src/lib/dictation-stream.ts +238 -0
  142. package/src/lib/dictation.ts +216 -0
  143. package/src/lib/document-picker.ts +31 -0
  144. package/src/lib/domain.ts +12 -0
  145. package/src/lib/flights.ts +33 -0
  146. package/src/lib/focus-return.ts +66 -0
  147. package/src/lib/greeting.ts +15 -0
  148. package/src/lib/image-data-url.ts +35 -0
  149. package/src/lib/keyboard.native.tsx +25 -0
  150. package/src/lib/keyboard.tsx +55 -0
  151. package/src/lib/labels-es.ts +113 -0
  152. package/src/lib/labels.tsx +207 -0
  153. package/src/lib/origins.ts +28 -0
  154. package/src/lib/participants.ts +97 -0
  155. package/src/lib/pcm.ts +57 -0
  156. package/src/lib/power-level-options.ts +66 -0
  157. package/src/lib/questions.ts +92 -0
  158. package/src/lib/speech-language.ts +20 -0
  159. package/src/lib/speech-messages.ts +54 -0
  160. package/src/lib/speech-synthesis.ts +156 -0
  161. package/src/lib/suggestions.ts +53 -0
  162. package/src/lib/task-labels.ts +35 -0
  163. package/src/lib/text-input.ts +10 -0
  164. package/src/lib/tool-call-status.ts +28 -0
  165. package/src/lib/tool-icons.ts +36 -0
  166. package/src/lib/tool-registry.ts +71 -0
  167. package/src/lib/tool-renderers.tsx +32 -0
  168. package/src/lib/turn-state.ts +15 -0
  169. package/src/lib/utils.ts +35 -0
  170. package/src/lib/voice-audio-engine-types.ts +59 -0
  171. package/src/lib/voice-audio-engine.native.ts +232 -0
  172. package/src/lib/voice-audio-engine.ts +206 -0
  173. package/src/lib/voice-call-request.ts +49 -0
  174. package/src/lib/voice-call.ts +627 -0
  175. package/src/lib/voice-controls-labels.ts +31 -0
  176. package/src/lib/voice-levels.ts +64 -0
  177. package/src/lib/voice-protocol.ts +328 -0
  178. package/src/lib/voice-worklets.ts +19 -0
  179. package/src/lib/work-log.ts +370 -0
  180. package/src/metro/chart-importers.json +18 -0
  181. package/src/metro/granular-charts.js +3 -0
  182. package/src/metro/index.cjs +227 -0
  183. package/src/metro/index.d.cts +5 -0
  184. package/src/runtime/agents.ts +151 -0
  185. package/src/runtime/api.ts +144 -0
  186. package/src/runtime/app-assertion.ts +51 -0
  187. package/src/runtime/attachment-utils.ts +97 -0
  188. package/src/runtime/chat-turn-control.ts +74 -0
  189. package/src/runtime/composer-draft-store.ts +270 -0
  190. package/src/runtime/config.tsx +222 -0
  191. package/src/runtime/conversation-dates.ts +31 -0
  192. package/src/runtime/conversation-store.ts +49 -0
  193. package/src/runtime/conversations.ts +633 -0
  194. package/src/runtime/error-utils.ts +144 -0
  195. package/src/runtime/gemie-accounts.ts +182 -0
  196. package/src/runtime/host-tools.ts +290 -0
  197. package/src/runtime/index.ts +137 -0
  198. package/src/runtime/message-history.ts +124 -0
  199. package/src/runtime/message-reactions.ts +214 -0
  200. package/src/runtime/model.ts +39 -0
  201. package/src/runtime/oxy-files.ts +37 -0
  202. package/src/runtime/power-levels.ts +66 -0
  203. package/src/runtime/query-keys.ts +60 -0
  204. package/src/runtime/random-uuid.ts +25 -0
  205. package/src/runtime/reaction-cache.ts +45 -0
  206. package/src/runtime/room-events.ts +333 -0
  207. package/src/runtime/routes.ts +85 -0
  208. package/src/runtime/sharing.ts +217 -0
  209. package/src/runtime/sse-frame-reader.ts +88 -0
  210. package/src/runtime/stream-events.ts +154 -0
  211. package/src/runtime/stream-outcome.ts +21 -0
  212. package/src/runtime/thought-store.ts +103 -0
  213. package/src/runtime/thread/agent-activity.ts +261 -0
  214. package/src/runtime/thread/agent-exchange.ts +94 -0
  215. package/src/runtime/thread/automation-labels.ts +79 -0
  216. package/src/runtime/thread/conversation-export.ts +135 -0
  217. package/src/runtime/thread/message-days.ts +120 -0
  218. package/src/runtime/thread/message-processor.ts +93 -0
  219. package/src/runtime/thread/speaker-changes.ts +66 -0
  220. package/src/runtime/thread/task-utils.ts +11 -0
  221. package/src/runtime/thread/thought-utils.ts +750 -0
  222. package/src/runtime/thread/thread-history.ts +139 -0
  223. package/src/runtime/thread/timeline.ts +202 -0
  224. package/src/runtime/thread/title-tags.ts +8 -0
  225. package/src/runtime/thread/tool-cards.ts +387 -0
  226. package/src/runtime/turn-failure.ts +108 -0
  227. package/src/runtime/turn-preparation.ts +21 -0
  228. package/src/runtime/types.ts +172 -0
  229. package/src/runtime/usage-limit-error.ts +44 -0
  230. package/src/runtime/use-agent-activity.ts +80 -0
  231. package/src/runtime/use-conversation-stream.ts +1669 -0
  232. package/src/runtime/use-conversation-thread.ts +590 -0
  233. package/src/runtime/use-gemie-thread.ts +54 -0
  234. package/src/runtime/use-room-events.ts +75 -0
  235. package/src/runtime/use-start-conversation.ts +107 -0
  236. package/src/runtime/use-thread-history.ts +73 -0
  237. package/src/runtime/use-thread-search.ts +100 -0
  238. package/src/runtime/use-turn-edit.ts +99 -0
  239. package/src/text.ts +19 -0
  240. package/src/theme.ts +16 -0
  241. package/src/tools.ts +27 -0
  242. package/src/types.ts +161 -0
  243. package/src/voice-messages.ts +2 -0
  244. package/src/voice.ts +67 -0
  245. package/tsconfig.json +17 -0
  246. package/worklets/voice-processors.js +152 -0
@@ -0,0 +1,31 @@
1
+ import * as DocumentPicker from 'expo-document-picker';
2
+
3
+ export type DocumentPickerResult = {
4
+ uri: string;
5
+ name: string;
6
+ size: number;
7
+ mimeType: string;
8
+ };
9
+
10
+ /** The platform's document picker, several at once; nothing when the person cancels or it fails. */
11
+ export async function pickDocuments(): Promise<DocumentPickerResult[] | undefined> {
12
+ try {
13
+ const result = await DocumentPicker.getDocumentAsync({
14
+ type: '*/*',
15
+ multiple: true,
16
+ copyToCacheDirectory: true,
17
+ });
18
+
19
+ if (result.canceled === false && result.assets && result.assets.length > 0) {
20
+ return result.assets.map((asset) => ({
21
+ uri: asset.uri,
22
+ name: asset.name,
23
+ size: asset.size || 0,
24
+ mimeType: asset.mimeType || 'application/octet-stream',
25
+ }));
26
+ }
27
+ } catch (error) {
28
+ console.warn('Failed to pick document:', error);
29
+ }
30
+ return undefined;
31
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The host of a URL, or the string itself when it is not one. Citations drop a leading `www.`
3
+ * (the number in `[3]` names a site); a source row in the work log keeps the host as served.
4
+ */
5
+ export function domainOf(url: string, { stripWww = false }: { stripWww?: boolean } = {}): string {
6
+ try {
7
+ const host = new URL(url).hostname;
8
+ return stripWww ? host.replace(/^www\./, '') : host;
9
+ } catch {
10
+ return url;
11
+ }
12
+ }
@@ -0,0 +1,33 @@
1
+ import { createContext, useContext } from 'react';
2
+ import type { AvatarFlights, AvatarFlightSpec } from '@oxy.so/bloom/avatar-flight';
3
+
4
+ import type { GemieParticipant } from './participants';
5
+
6
+ /**
7
+ * Where the conversation's avatars are: the lead's, large in the greeting; everybody's, small in
8
+ * the header's participants; and a consulted agent's, beside the reply it is writing.
9
+ */
10
+ export const ANCHORS = {
11
+ welcome: 'lead:welcome',
12
+ profile: 'participants',
13
+ reply: (agentId: string) => `reply:${agentId}`,
14
+ } as const;
15
+
16
+ /** The greeting's avatar flies up into the header's participants as the conversation begins. */
17
+ export function leadToProfile(lead: GemieParticipant): AvatarFlightSpec {
18
+ return {
19
+ key: 'lead',
20
+ character: lead.character,
21
+ from: ANCHORS.welcome,
22
+ to: ANCHORS.profile,
23
+ duration: 800,
24
+ };
25
+ }
26
+
27
+ const FlightsContext = createContext<AvatarFlights | null>(null);
28
+
29
+ /** The chat's avatar flights, for the greeting, the thread and the header that share them. */
30
+ export const GemieFlightsProvider = FlightsContext.Provider;
31
+
32
+ /** `null` outside a chat: the greeting, the replies and the header then draw their avatars without flying. */
33
+ export const useGemieFlights = () => useContext(FlightsContext);
@@ -0,0 +1,66 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ /**
4
+ * Where keyboard focus goes back to when the execution panel closes.
5
+ *
6
+ * The panel is opened from a row in the conversation — a tool step, the
7
+ * sources row, the reasoning trigger — and on the web the desktop rail is not
8
+ * a dialog: nothing moves focus into it and nothing would move it back. So a
9
+ * screen-reader or keyboard user who opened it and pressed Escape was left
10
+ * with focus wherever the browser had put it, which after a click on a
11
+ * `Pressable` is `body` in Safari. The opener is remembered here at open time
12
+ * and focused again at close.
13
+ *
14
+ * One slot, module-level: there is one panel, and the store's own selection
15
+ * already says which message it is about. A DOM element in the store would
16
+ * also be a DOM element in a persisted store's state tree, which it must not
17
+ * be.
18
+ */
19
+ type Focusable = { focus: () => void };
20
+
21
+ let opener: Focusable | null = null;
22
+
23
+ function isFocusable(value: unknown): value is Focusable {
24
+ return (
25
+ typeof value === 'object' &&
26
+ value !== null &&
27
+ typeof (value as { focus?: unknown }).focus === 'function'
28
+ );
29
+ }
30
+
31
+ /**
32
+ * Remember what opened the panel. A caller with a ref to its own control
33
+ * passes it; one without (a memoised row whose ref would be one more prop)
34
+ * lets this read the element that is focused right now, which on the web is
35
+ * the button that was just activated by keyboard, and the button or `body`
36
+ * after a pointer press depending on the browser. Nothing is remembered on
37
+ * native, where focus does not work this way.
38
+ */
39
+ export function rememberOpener(candidate?: unknown): void {
40
+ if (isFocusable(candidate)) {
41
+ opener = candidate;
42
+ return;
43
+ }
44
+ if (
45
+ Platform.OS === 'web' &&
46
+ typeof document !== 'undefined' &&
47
+ isFocusable(document.activeElement)
48
+ ) {
49
+ opener = document.activeElement;
50
+ return;
51
+ }
52
+ opener = null;
53
+ }
54
+
55
+ /** Focus the remembered opener, once, and forget it. */
56
+ export function restoreOpenerFocus(): void {
57
+ const target = opener;
58
+ opener = null;
59
+ if (target === null) return;
60
+ try {
61
+ target.focus();
62
+ } catch {
63
+ // An element that has since left the document cannot take focus; there
64
+ // is nowhere better to send it.
65
+ }
66
+ }
@@ -0,0 +1,15 @@
1
+ /** Commas of the languages the apps greet in: Latin, fullwidth, ideographic and Arabic. */
2
+ const COMMA = /[,,、،]/;
3
+
4
+ /**
5
+ * A greeting in two lines: the address ("Hi Nate,") over the rest ("what's on your mind?"). It
6
+ * breaks after the first comma, which keeps the greeting one string a translator writes once; a
7
+ * greeting without one (or with nothing after it) stays a single line.
8
+ */
9
+ export function greetingLines(greeting: string): [string] | [string, string] {
10
+ const at = greeting.search(COMMA);
11
+ if (at < 0) return [greeting];
12
+ const first = greeting.slice(0, at + 1);
13
+ const rest = greeting.slice(at + 1).trim();
14
+ return rest === '' ? [greeting] : [first, rest];
15
+ }
@@ -0,0 +1,35 @@
1
+ import { File } from 'expo-file-system';
2
+ import { Platform } from 'react-native';
3
+
4
+ /**
5
+ * Reads a picked image into a `data:` URL, the one form the chat API accepts as an `image_url`
6
+ * part without the server having to reach the device. The picker's URI means nothing off the
7
+ * device: on web it is a `blob:` URL (a handle into this tab's memory), on native a `file://`
8
+ * path, and sent as it is either arrives as a string the model cannot open.
9
+ *
10
+ * Web reads the blob back; native reads the file with `expo-file-system`, as the Alia app does.
11
+ */
12
+ export async function imageUriToDataUrl(uri: string, mimeType?: string): Promise<string> {
13
+ if (uri.startsWith('data:')) return uri;
14
+ if (Platform.OS !== 'web') {
15
+ // The `File` API: the legacy `readAsStringAsync` from the package root throws at runtime.
16
+ const base64 = await new File(uri).base64();
17
+ return `data:${mimeType || 'image/jpeg'};base64,${base64}`;
18
+ }
19
+ const blob = await (await fetch(uri)).blob();
20
+ return await new Promise<string>((resolve, reject) => {
21
+ const reader = new FileReader();
22
+ reader.onerror = () => reject(reader.error ?? new Error('Could not read the image'));
23
+ reader.onload = () => {
24
+ const result = String(reader.result);
25
+ // `readAsDataURL` stamps the blob's own type; it is only octet-stream when the blob has
26
+ // none, and then the picker's type is the better guess.
27
+ resolve(
28
+ mimeType && result.startsWith('data:application/octet-stream')
29
+ ? result.replace('data:application/octet-stream', `data:${mimeType}`)
30
+ : result,
31
+ );
32
+ };
33
+ reader.readAsDataURL(blob);
34
+ });
35
+ }
@@ -0,0 +1,25 @@
1
+ // Native: re-export react-native-keyboard-controller components
2
+ import Animated, { useAnimatedStyle } from 'react-native-reanimated';
3
+ import { useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller';
4
+
5
+ export {
6
+ KeyboardAwareScrollView,
7
+ KeyboardAvoidingView,
8
+ KeyboardProvider,
9
+ } from 'react-native-keyboard-controller';
10
+
11
+ /**
12
+ * The room under a bottom-anchored control for the gesture bar, while the gesture bar is what lies
13
+ * under it.
14
+ *
15
+ * With the keyboard up, a keyboard-avoiding host already ends at the keyboard's top edge, and the
16
+ * keyboard covers the gesture bar. Keeping this room then counts the bar twice: the chat's composer
17
+ * floated a bar's height above the keyboard, with the transcript showing through the gap (Pixel 8a).
18
+ * It follows the keyboard's own animation, so the control settles onto the keyboard as it rises
19
+ * instead of jumping after.
20
+ */
21
+ export function KeyboardSafeAreaFloor({ inset }: { inset: number }) {
22
+ const { progress } = useReanimatedKeyboardAnimation();
23
+ const style = useAnimatedStyle(() => ({ height: inset * (1 - progress.value) }), [inset]);
24
+ return <Animated.View style={style} />;
25
+ }
@@ -0,0 +1,55 @@
1
+ // Web: re-export React Native built-in components as keyboard-controller substitutes
2
+ import React from 'react';
3
+ import {
4
+ ScrollView,
5
+ type ScrollViewProps,
6
+ KeyboardAvoidingView as RNKeyboardAvoidingView,
7
+ type KeyboardAvoidingViewProps as RNKeyboardAvoidingViewProps,
8
+ View,
9
+ } from 'react-native';
10
+
11
+ // Accept native-only props so shared components don't cause TS errors
12
+ type KeyboardAwareScrollViewProps = ScrollViewProps & {
13
+ bottomOffset?: number;
14
+ disableScrollOnKeyboardHide?: boolean;
15
+ enabled?: boolean;
16
+ extraKeyboardSpace?: number;
17
+ };
18
+
19
+ // `ComponentRef`, not `ScrollView` itself: React Native 0.88 types `ScrollView` as a function
20
+ // component, so the class is no longer its instance type.
21
+ const KeyboardAwareScrollView = React.forwardRef<
22
+ React.ComponentRef<typeof ScrollView>,
23
+ KeyboardAwareScrollViewProps
24
+ >(({ bottomOffset, disableScrollOnKeyboardHide, enabled, extraKeyboardSpace, ...props }, ref) => (
25
+ <ScrollView ref={ref} {...props} />
26
+ ));
27
+ KeyboardAwareScrollView.displayName = 'KeyboardAwareScrollView';
28
+
29
+ // `automaticOffset` is keyboard-controller's: measure the view's position in
30
+ // the window instead of trusting its parent-relative layout. The browser moves
31
+ // its own viewport for the keyboard, so on web it has nothing to do.
32
+ type KeyboardAvoidingViewProps = RNKeyboardAvoidingViewProps & {
33
+ automaticOffset?: boolean;
34
+ };
35
+
36
+ const KeyboardAvoidingView = React.forwardRef<
37
+ React.ComponentRef<typeof RNKeyboardAvoidingView>,
38
+ KeyboardAvoidingViewProps
39
+ >(({ automaticOffset, ...props }, ref) => <RNKeyboardAvoidingView ref={ref} {...props} />);
40
+ KeyboardAvoidingView.displayName = 'KeyboardAvoidingView';
41
+
42
+ export { KeyboardAwareScrollView, KeyboardAvoidingView };
43
+
44
+ // No-op provider on web — keyboard-controller is native-only
45
+ export function KeyboardProvider({ children }: { children: React.ReactNode }) {
46
+ return <>{children}</>;
47
+ }
48
+
49
+ /**
50
+ * The room under a bottom-anchored control for the system's bottom bar. The web's keyboard resizes
51
+ * the page rather than covering it, so that room never has to give way to it (see the native file).
52
+ */
53
+ export function KeyboardSafeAreaFloor({ inset }: { inset: number }) {
54
+ return <View style={{ height: inset }} />;
55
+ }
@@ -0,0 +1,113 @@
1
+ import type { GemieChatLabels, VoiceBlockReason } from './labels';
2
+ import { spanishCopy } from './copy';
3
+ import type { VoiceCloseReason } from './voice-protocol';
4
+ import type { VoiceErrorCode } from './speech-messages';
5
+
6
+ const VOICE_ERRORS: Record<VoiceErrorCode, string> = {
7
+ 'not-authenticated': 'Inicia sesión para usar la voz',
8
+ 'credential-not-supported': 'La voz solo está disponible con tu sesión de Alia',
9
+ 'plan-required': 'El modo voz necesita un plan de pago',
10
+ 'credits-exhausted': 'Te has quedado sin créditos para esta llamada',
11
+ 'agent-unavailable': 'Este Gemie no está disponible para una llamada',
12
+ 'invalid-request': 'No se pudo iniciar la llamada',
13
+ 'resume-unavailable': 'No se pudo retomar la llamada: empieza una nueva',
14
+ 'realtime-unavailable': 'La voz no está disponible ahora mismo: inténtalo más tarde',
15
+ 'realtime-limited': 'La voz ha llegado a su límite por ahora: inténtalo más tarde',
16
+ 'realtime-rejected': 'No se pudo iniciar la llamada con esta configuración',
17
+ 'realtime-failed': 'La llamada ha fallado: inténtalo de nuevo',
18
+ 'mic-denied': 'Se necesita permiso para usar el micrófono',
19
+ 'mic-unavailable': 'No se pudo usar el micrófono: revisa tus dispositivos de entrada',
20
+ 'connection-lost': 'Se perdió la conexión',
21
+ 'voice-unavailable': 'La voz no está disponible en este dispositivo o navegador',
22
+ 'too-long': 'El dictado era demasiado largo: cinco minutos como máximo',
23
+ 'transcription-unavailable': 'El dictado no está disponible ahora mismo',
24
+ 'transcription-limited': 'El dictado ha llegado a su límite por ahora: inténtalo más tarde',
25
+ 'transcription-rejected': 'No se pudo transcribir esa grabación',
26
+ 'transcription-failed': 'Falló el dictado: inténtalo de nuevo',
27
+ };
28
+ const VOICE_ENDED: Partial<Record<VoiceCloseReason, string>> = {
29
+ 'call-moved-elsewhere': 'La llamada sigue en tu otro dispositivo',
30
+ 'max-duration': 'La llamada llegó a su límite de 30 minutos',
31
+ 'idle-timeout': 'La llamada terminó tras dos minutos de silencio',
32
+ 'credits-exhausted': 'La llamada terminó: te quedaste sin créditos',
33
+ 'server-shutdown': 'La llamada terminó mientras Alia se actualizaba: empieza una nueva',
34
+ };
35
+ const VOICE_BLOCKED: Record<VoiceBlockReason, string> = {
36
+ 'sign-in': 'Inicia sesión para usar la voz',
37
+ 'plan-required': 'El modo voz necesita un plan de pago',
38
+ 'credits-exhausted': 'Te has quedado sin créditos',
39
+ };
40
+
41
+ /** Built-in Spanish, shared by every app that embeds the chat. */
42
+ export const SPANISH_LABELS: GemieChatLabels = {
43
+ clear: 'Borrar',
44
+ back: 'Volver',
45
+ share: 'Compartir',
46
+ more: 'Más',
47
+ chatActions: 'Acciones de la conversación',
48
+ addMenuGroup: 'Adjuntar',
49
+ addPhotos: 'Fotos',
50
+ addDocuments: 'Archivos',
51
+ startVoice: 'Iniciar llamada',
52
+ voiceEndingSoon: 'Queda un minuto de llamada',
53
+ composerMessage: 'Mensaje',
54
+ composerAddMenu: 'Añadir al chat',
55
+ composerModes: 'Potencia',
56
+ composerVoice: 'Dictar',
57
+ composerSend: 'Enviar mensaje',
58
+ composerStop: 'Detener la generación',
59
+ composerRemove: 'Quitar',
60
+ composerRetry: 'Reintentar',
61
+ composerUntitled: 'sin título',
62
+ dropHint: 'Suelta los archivos aquí para adjuntarlos',
63
+ dropUnavailable: 'Ahora mismo no se pueden adjuntar archivos',
64
+ greeting: 'Hola, ¿qué tienes en mente?',
65
+ copy: 'Copiar',
66
+ helpful: 'Respuesta útil',
67
+ unhelpful: 'Respuesta poco útil',
68
+ copied: 'Copiado',
69
+ edit: 'Editar',
70
+ save: 'Guardar',
71
+ cancel: 'Cancelar',
72
+ readAloud: 'Leer en voz alta',
73
+ stopReading: 'Dejar de leer',
74
+ planTitle: 'Este es mi plan',
75
+ reasoning: 'Razonamiento',
76
+ locale: 'es',
77
+ newChat: 'Nueva conversación',
78
+ recentConversations: 'Recientes',
79
+ sendFailed:
80
+ 'No se pudo enviar el mensaje. Lo tienes de vuelta en el cuadro de texto, inténtalo otra vez.',
81
+ signInRequired: 'Inicia sesión para seguir conversando',
82
+ conversationSaveFailed: 'No se pudo guardar la conversación',
83
+ conversationDeleteFailed: 'No se pudo eliminar la conversación',
84
+ conversationCreateFailed: 'No se pudo crear la conversación',
85
+ conversationClearFailed: 'No se pudo borrar la conversación',
86
+ placeholder: (name) => `Pregúntale lo que quieras a ${name}`,
87
+ greetingNamed: (name) => `Hola ${name}, ¿qué tienes en mente?`,
88
+ fileReadFailed: (name) => `No se pudo leer ${name}: selecciona para reintentar`,
89
+ fileTooLarge: (name, limit) => `${name} supera ${limit} y no se ha adjuntado`,
90
+ fileEmpty: (name) => `${name} está vacío: no se pueden adjuntar carpetas`,
91
+ fileUnsupported: (name) => `No se puede enviar ${name} aquí: solo se admiten fotos`,
92
+ dictationRemaining: (seconds) => `Quedan ${seconds} s de dictado`,
93
+ thoughtFor: (seconds) => `Pensó durante ${seconds} segundos`,
94
+ attachmentNotSent: (name) => `No se envió ${name}: solo se pueden enviar fotos`,
95
+ attachmentUnreadable: (name) => `No se pudo leer ${name} y no se envió`,
96
+ voiceError: (code) => VOICE_ERRORS[code],
97
+ voiceEnded: (reason) => VOICE_ENDED[reason] ?? null,
98
+ voiceBlocked: (reason) => VOICE_BLOCKED[reason],
99
+ voiceControls: {
100
+ connecting: 'Conectando…',
101
+ reconnecting: 'Reconectando…',
102
+ connected: 'Conectado',
103
+ listening: 'Escuchando…',
104
+ muted: 'Silenciado',
105
+ thinking: 'Pensando…',
106
+ usingTool: 'Trabajando en ello…',
107
+ speaking: 'Hablando…',
108
+ mute: 'Silenciar',
109
+ unmute: 'Activar micrófono',
110
+ end: 'Colgar',
111
+ },
112
+ t: spanishCopy,
113
+ };
@@ -0,0 +1,207 @@
1
+ import { createContext, type ReactNode, useContext, useMemo } from 'react';
2
+ import { SPANISH_LABELS } from './labels-es';
3
+ import { VOICE_ERROR_MESSAGES, type VoiceErrorCode } from './speech-messages';
4
+ import { englishCopy, type Translate } from './copy';
5
+ import { VOICE_CONTROLS_LABELS, type VoiceControlsLabels } from './voice-controls-labels';
6
+ import type { VoiceCloseReason } from './voice-protocol';
7
+
8
+ /** Why a call could not be opened; the host's `canStartVoice` answers with one. */
9
+ export type VoiceBlockReason = 'sign-in' | 'plan-required' | 'credits-exhausted';
10
+
11
+ /** Every string the chat UI draws itself. Bloom's own copy follows `BloomProvider locale`. */
12
+ export interface GemieChatLabels {
13
+ // Header
14
+ clear: string;
15
+ back: string;
16
+ share: string;
17
+ more: string;
18
+ chatActions: string;
19
+ // Composer
20
+ /** The empty composer's prompt, naming the conversation's lead ("Ask Sindi..."). */
21
+ placeholder: (leadName: string) => string;
22
+ addMenuGroup: string;
23
+ addPhotos: string;
24
+ /** The add menu's row for documents, where the lead takes them. */
25
+ addDocuments: string;
26
+ startVoice: string;
27
+ /** The call bar's words (status, mute, end). */
28
+ voiceControls: VoiceControlsLabels;
29
+ /** Why a call ended without failing; `null` for a hang-up (the person knows). */
30
+ voiceEnded: (reason: VoiceCloseReason) => string | null;
31
+ /** Said once, and shown in the bar, when the call is about to reach its time limit. */
32
+ voiceEndingSoon: string;
33
+ /** Why a call was not opened, told instead of a button that silently does nothing. */
34
+ voiceBlocked: (reason: VoiceBlockReason) => string;
35
+ /** The field's accessible name. */
36
+ composerMessage: string;
37
+ /** The add button's accessible name. */
38
+ composerAddMenu: string;
39
+ /** The mode selector's accessible name (the host's power levels). */
40
+ composerModes: string;
41
+ /** The dictation button's accessible name. */
42
+ composerVoice: string;
43
+ composerSend: string;
44
+ composerStop: string;
45
+ /** A tile's remove button. */
46
+ composerRemove: string;
47
+ /** Bloom names a retry button "<this> <file name>". */
48
+ composerRetry: string;
49
+ /** What a tile without a file name is called. */
50
+ composerUntitled: string;
51
+ fileReadFailed: (name: string) => string;
52
+ fileTooLarge: (name: string, limit: string) => string;
53
+ fileEmpty: (name: string) => string;
54
+ /** A file of a kind the chat cannot send (a document, where only photos go). */
55
+ fileUnsupported: (name: string) => string;
56
+ /** Over the composer while a file is dragged onto it. */
57
+ dropHint: string;
58
+ dropUnavailable: string;
59
+ /** Why dictation failed, in the host's language. */
60
+ voiceError: (code: VoiceErrorCode) => string;
61
+ /** Over the composer in the last 30 s of a dictation's five minutes. */
62
+ dictationRemaining: (seconds: number) => string;
63
+ // Welcome
64
+ /** The empty chat's greeting for a signed-out visitor. */
65
+ greeting: string;
66
+ /** The empty chat's greeting for a named person. */
67
+ greetingNamed: (name: string) => string;
68
+ // Messages
69
+ copy: string;
70
+ helpful: string;
71
+ unhelpful: string;
72
+ copied: string;
73
+ edit: string;
74
+ save: string;
75
+ cancel: string;
76
+ readAloud: string;
77
+ stopReading: string;
78
+ // Plan
79
+ planTitle: string;
80
+ // Reasoning
81
+ reasoning: string;
82
+ thoughtFor: (seconds: number) => string;
83
+ // The words that are not one fixed field
84
+ /** The words that are not one fixed field (the thread, its cards, the work log), keyed as the Alia app keys them (see `copy.ts`). */
85
+ t: Translate;
86
+ /** The language `t` speaks, as a BCP 47 tag: dates, days and prices in the thread are formatted in it. */
87
+ locale: string;
88
+ // Conversations (the runtime's own words: toasts and the errors it raises)
89
+ /** A conversation's title until it has one. */
90
+ newChat: string;
91
+ /** Over the sheet's recent conversations with its lead. */
92
+ recentConversations: string;
93
+ /** A turn could not be sent and the composer got its text back. */
94
+ sendFailed: string;
95
+ /** The session ended mid-request. */
96
+ signInRequired: string;
97
+ conversationSaveFailed: string;
98
+ conversationDeleteFailed: string;
99
+ conversationCreateFailed: string;
100
+ conversationClearFailed: string;
101
+ /** An attachment of a kind the chat API does not carry was left out of the turn. */
102
+ attachmentNotSent: (name: string) => string;
103
+ /** A photo whose bytes could not be read was left out of the turn. */
104
+ attachmentUnreadable: (name: string) => string;
105
+ // Research
106
+ }
107
+
108
+ const ENDED_ENGLISH: Partial<Record<VoiceCloseReason, string>> = {
109
+ 'call-moved-elsewhere': 'The call continues on your other device',
110
+ 'max-duration': 'The call reached its time limit',
111
+ 'idle-timeout': 'The call ended after two minutes of silence',
112
+ 'credits-exhausted': 'The call ended: you ran out of credits',
113
+ 'server-shutdown': 'The call ended while Alia was updating — start a new one',
114
+ };
115
+
116
+ const BLOCKED_ENGLISH: Record<VoiceBlockReason, string> = {
117
+ 'sign-in': 'Sign in to use voice',
118
+ 'plan-required': 'Voice mode needs a paid plan',
119
+ 'credits-exhausted': "You've run out of credits",
120
+ };
121
+
122
+ export const DEFAULT_LABELS: GemieChatLabels = {
123
+ clear: 'Clear',
124
+ back: 'Back',
125
+ share: 'Share',
126
+ more: 'More',
127
+ chatActions: 'Chat actions',
128
+ placeholder: (leadName) => `Ask ${leadName}...`,
129
+ addMenuGroup: 'Add',
130
+ addPhotos: 'Photos',
131
+ addDocuments: 'Files',
132
+ startVoice: 'Start voice',
133
+ voiceControls: VOICE_CONTROLS_LABELS,
134
+ voiceEnded: (reason) => ENDED_ENGLISH[reason] ?? null,
135
+ voiceEndingSoon: 'One minute left in this call',
136
+ voiceBlocked: (reason) => BLOCKED_ENGLISH[reason],
137
+ composerMessage: 'Message',
138
+ composerAddMenu: 'Add to chat',
139
+ composerModes: 'Power level',
140
+ composerVoice: 'Dictate',
141
+ composerSend: 'Send message',
142
+ composerStop: 'Stop generating',
143
+ composerRemove: 'Remove',
144
+ composerRetry: 'Retry',
145
+ composerUntitled: 'untitled',
146
+ fileReadFailed: (name) => `${name} could not be read — select to try again`,
147
+ fileTooLarge: (name, limit) => `${name} is larger than ${limit} and was not attached`,
148
+ fileEmpty: (name) => `${name} is empty — folders can't be attached`,
149
+ fileUnsupported: (name) => `${name} can't be sent here — only photos can`,
150
+ dropHint: 'Drop files here to attach them',
151
+ dropUnavailable: "Files can't be attached right now",
152
+ voiceError: (code) => VOICE_ERROR_MESSAGES[code],
153
+ dictationRemaining: (seconds) => `${seconds}s of dictation left`,
154
+ greeting: "Hi, what's on your mind?",
155
+ greetingNamed: (name) => `Hi ${name}, what's on your mind?`,
156
+ copy: 'Copy',
157
+ helpful: 'Helpful response',
158
+ unhelpful: 'Unhelpful response',
159
+ copied: 'Copied',
160
+ edit: 'Edit',
161
+ save: 'Save',
162
+ cancel: 'Cancel',
163
+ readAloud: 'Read aloud',
164
+ stopReading: 'Stop reading',
165
+ planTitle: "Here's my plan",
166
+ reasoning: 'Reasoning',
167
+ thoughtFor: (seconds) => `Thought for ${seconds} seconds`,
168
+ t: englishCopy,
169
+ locale: 'en',
170
+ newChat: 'New chat',
171
+ recentConversations: 'Recent',
172
+ sendFailed: "Your message couldn't be sent",
173
+ signInRequired: 'Sign in to keep chatting',
174
+ conversationSaveFailed: 'Failed to save conversation',
175
+ conversationDeleteFailed: 'Failed to delete conversation',
176
+ conversationCreateFailed: 'Failed to create conversation',
177
+ conversationClearFailed: "The conversation couldn't be cleared",
178
+ attachmentNotSent: (name) => `${name} wasn't sent — only photos can be sent`,
179
+ attachmentUnreadable: (name) => `${name} couldn't be read and wasn't sent`,
180
+ };
181
+
182
+ const LabelsContext = createContext<GemieChatLabels | null>(null);
183
+
184
+ /** The chat's labels: the defaults, with whatever the host overrides. */
185
+ export function GemieChatLabelsProvider({
186
+ labels,
187
+ children,
188
+ }: {
189
+ labels?: Partial<GemieChatLabels>;
190
+ children: ReactNode;
191
+ }) {
192
+ // Over whatever labels are already in reach, so a part that takes its own `labels` (the
193
+ // composer) refines the chat's copy instead of resetting it to English.
194
+ const inherited = useContext(LabelsContext);
195
+ const value = useMemo(() => {
196
+ const locale = labels?.locale ?? inherited?.locale ?? 'en';
197
+ const language = locale.toLowerCase().split('-')[0];
198
+ const defaults = language === 'es' ? SPANISH_LABELS : DEFAULT_LABELS;
199
+ const parent = inherited?.locale.toLowerCase().split('-')[0] === language ? inherited : null;
200
+ return { ...defaults, ...parent, ...labels };
201
+ }, [inherited, labels]);
202
+ return <LabelsContext.Provider value={value}>{children}</LabelsContext.Provider>;
203
+ }
204
+
205
+ export function useLabels(): GemieChatLabels {
206
+ return useContext(LabelsContext) ?? DEFAULT_LABELS;
207
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The two origins the SDK talks to, defined once. Every URL it builds starts from one of them,
3
+ * and `@gemies/sdk/csp` (`src/csp.ts`) derives the host's CSP from these same values, so an
4
+ * origin the SDK uses is an origin it declares.
5
+ */
6
+
7
+ // Declared here, not taken from the host's globals: Expo apps get `process` from Expo's types, a
8
+ // Vite app has none unless it installs Node's, and every entry that reaches this file must
9
+ // type-check alone (`check:entry-types`). Type-only; Metro still inlines the static access below.
10
+ declare const process: { readonly env: { readonly EXPO_PUBLIC_GEMIES_API_URL?: string } };
11
+
12
+ /** The Gemies API: `EXPO_PUBLIC_GEMIES_API_URL`, then production. Chat, dictation, speech, voice. */
13
+ export const GEMIES_API_URL = process.env.EXPO_PUBLIC_GEMIES_API_URL ?? 'https://api.gemies.ai';
14
+
15
+ /**
16
+ * The Gemies web app, which serves the files the SDK shares with every host: the voice call's
17
+ * worklets (`/sdk/voice-worklets/`), with CORS open (`packages/app/worker/index.js`).
18
+ */
19
+ export const GEMIES_WEB_ORIGIN = 'https://gemies.ai';
20
+
21
+ /**
22
+ * The one public page of a shared conversation, on the Gemies web app, for every agent and every app
23
+ * that embeds one (`docs/agent-embedding.md` §6). An app shares this URL rather than a page of its
24
+ * own, so a link reads the same wherever it was minted.
25
+ */
26
+ export function gemiesSharedConversationUrl(token: string): string {
27
+ return `${GEMIES_WEB_ORIGIN}/shared/${encodeURIComponent(token)}`;
28
+ }