@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.
- package/CHANGELOG.md +1678 -0
- package/LICENSE +202 -0
- package/NOTICE +15 -0
- package/README.md +516 -2
- package/package.json +105 -4
- package/src/accounts.ts +29 -0
- package/src/animations.ts +5 -0
- package/src/ask-eager.ts +8 -0
- package/src/ask-text.ts +11 -0
- package/src/ask.ts +12 -0
- package/src/avatar.ts +13 -0
- package/src/character.ts +1 -0
- package/src/components/AmbientField.tsx +580 -0
- package/src/components/ComposerDropZone.tsx +235 -0
- package/src/components/ComposerSuggestions.tsx +45 -0
- package/src/components/GemieAccounts.tsx +433 -0
- package/src/components/GemieAskCore.tsx +184 -0
- package/src/components/GemieAskProvider.tsx +18 -0
- package/src/components/GemieAskProviderLazy.tsx +27 -0
- package/src/components/GemieAskProviderText.tsx +25 -0
- package/src/components/GemieAskSheet.tsx +51 -0
- package/src/components/GemieAskSheetWithVoice.tsx +10 -0
- package/src/components/GemieAvatar.tsx +57 -0
- package/src/components/GemieAvatarIcon.tsx +35 -0
- package/src/components/GemieChatContent.tsx +900 -0
- package/src/components/GemieChatHeader.tsx +123 -0
- package/src/components/GemieChatScreen.tsx +170 -0
- package/src/components/GemieChatSheet.tsx +368 -0
- package/src/components/GemieChatWithVoice.tsx +13 -0
- package/src/components/GemieComposer.tsx +388 -0
- package/src/components/GemieGroupWelcome.tsx +37 -0
- package/src/components/GemieParticipants.tsx +133 -0
- package/src/components/GemieParticipantsHeader.tsx +27 -0
- package/src/components/GemieRecentConversations.tsx +65 -0
- package/src/components/GemieSharedConversation.tsx +87 -0
- package/src/components/GemieWelcomeMessage.tsx +58 -0
- package/src/components/IdentityMark.tsx +225 -0
- package/src/components/Image.tsx +12 -0
- package/src/components/InertWhen.tsx +48 -0
- package/src/components/PlanPreviewCard.tsx +53 -0
- package/src/components/QuestionCard.tsx +64 -0
- package/src/components/ReplyMarkdown.tsx +373 -0
- package/src/components/RichBlocks.tsx +195 -0
- package/src/components/VoiceModeIcon.tsx +18 -0
- package/src/components/canvas/CanvasComponent.tsx +65 -0
- package/src/components/canvas/ChartRenderer.tsx +73 -0
- package/src/components/canvas/CodeRenderer.tsx +20 -0
- package/src/components/canvas/DashboardRenderer.tsx +70 -0
- package/src/components/canvas/DeckRenderer.tsx +43 -0
- package/src/components/canvas/FormRenderer.tsx +101 -0
- package/src/components/canvas/MarkdownRenderer.tsx +14 -0
- package/src/components/canvas/TableRenderer.tsx +47 -0
- package/src/components/icons/RiEmojiPicker.tsx +39 -0
- package/src/components/icons/RiMoreDots.tsx +32 -0
- package/src/components/icons/RiReplyLine.tsx +25 -0
- package/src/components/thought/FilesAndSources.tsx +120 -0
- package/src/components/thought/ThoughtPanel.tsx +426 -0
- package/src/components/thought/ToolStep.tsx +134 -0
- package/src/components/thread/AgentExchangeView.tsx +112 -0
- package/src/components/thread/AgentResultCard.tsx +125 -0
- package/src/components/thread/AgentTaskCard.tsx +127 -0
- package/src/components/thread/ChatBubble.tsx +256 -0
- package/src/components/thread/GemieThread.tsx +455 -0
- package/src/components/thread/MessageBlockBoundary.tsx +78 -0
- package/src/components/thread/NewConversationOffer.tsx +54 -0
- package/src/components/thread/ThreadRow.tsx +598 -0
- package/src/components/thread/ThreadSearch.tsx +130 -0
- package/src/components/thread/ThreadSkeleton.tsx +30 -0
- package/src/components/thread/ToolResultCard.tsx +254 -0
- package/src/components/thread/TurnMenu.tsx +54 -0
- package/src/components/thread/TurnStatusLine.tsx +34 -0
- package/src/components/voice/GemieVoiceCall.tsx +21 -0
- package/src/components/voice/GemieVoiceCall.web.tsx +17 -0
- package/src/components/voice/VoiceCallContext.ts +13 -0
- package/src/components/voice/VoiceControls.tsx +106 -0
- package/src/components/voice/VoiceSession.tsx +120 -0
- package/src/components/voice/withVoiceCall.tsx +25 -0
- package/src/csp.ts +50 -0
- package/src/dictation.ts +40 -0
- package/src/hooks/useAmbientWave.ts +184 -0
- package/src/hooks/useAtBottom.ts +51 -0
- package/src/hooks/useAttachMenu.ts +93 -0
- package/src/hooks/useAttachmentIntake.ts +401 -0
- package/src/hooks/useAudioLevelMonitor.ts +46 -0
- package/src/hooks/useAudioLevels.ts +51 -0
- package/src/hooks/useChatComposer.ts +309 -0
- package/src/hooks/useChatVoice.ts +129 -0
- package/src/hooks/useComposerSuggestions.ts +84 -0
- package/src/hooks/useDictation.ts +292 -0
- package/src/hooks/useDocumentPicker.ts +11 -0
- package/src/hooks/useFailedTurnToast.ts +43 -0
- package/src/hooks/useFocusWhenPresented.ts +41 -0
- package/src/hooks/useGemieActivity.ts +31 -0
- package/src/hooks/useImagePicker.ts +38 -0
- package/src/hooks/useMessageReactions.ts +119 -0
- package/src/hooks/useMessageVote.ts +50 -0
- package/src/hooks/useOpenThought.ts +79 -0
- package/src/hooks/usePendingQuestions.ts +19 -0
- package/src/hooks/useReadAloud.ts +92 -0
- package/src/hooks/useShareHandler.ts +24 -0
- package/src/hooks/useSoundEffects.ts +137 -0
- package/src/hooks/useTTS.ts +303 -0
- package/src/hooks/useThoughtScope.ts +59 -0
- package/src/hooks/useThreadRows.ts +157 -0
- package/src/hooks/useThreadView.ts +67 -0
- package/src/hooks/useTimelineWindow.ts +256 -0
- package/src/hooks/useVoiceLauncher.ts +180 -0
- package/src/hooks/useVoiceRoom.ts +212 -0
- package/src/index.ts +141 -0
- package/src/lib/activity-socket.ts +102 -0
- package/src/lib/activity-store.ts +53 -0
- package/src/lib/add-menu.ts +7 -0
- package/src/lib/agent-character.ts +28 -0
- package/src/lib/alia-character.ts +14 -0
- package/src/lib/alia-gemie.ts +6 -0
- package/src/lib/attachment-intake.ts +154 -0
- package/src/lib/attachment-tiles.ts +74 -0
- package/src/lib/audio-level.ts +130 -0
- package/src/lib/audio-request-auth.ts +4 -0
- package/src/lib/audio-session-binding.ts +27 -0
- package/src/lib/bubbles.tsx +16 -0
- package/src/lib/call-thread.ts +33 -0
- package/src/lib/canvas-result.ts +21 -0
- package/src/lib/catalogue-tool.ts +22 -0
- package/src/lib/citations.ts +192 -0
- package/src/lib/clipboard.ts +23 -0
- package/src/lib/content-utils.ts +46 -0
- package/src/lib/copy-en.ts +333 -0
- package/src/lib/copy-es.ts +330 -0
- package/src/lib/copy.ts +38 -0
- package/src/lib/deferred/document-picker.ts +2 -0
- package/src/lib/deferred/document-picker.web.ts +12 -0
- package/src/lib/deferred/expo-audio.ts +2 -0
- package/src/lib/deferred/expo-audio.web.ts +12 -0
- package/src/lib/deferred/image-data-url.ts +5 -0
- package/src/lib/deferred/image-data-url.web.ts +12 -0
- package/src/lib/dictation-protocol.ts +142 -0
- package/src/lib/dictation-recorder-types.ts +37 -0
- package/src/lib/dictation-recorder.native.ts +90 -0
- package/src/lib/dictation-recorder.ts +131 -0
- package/src/lib/dictation-stream.ts +238 -0
- package/src/lib/dictation.ts +216 -0
- package/src/lib/document-picker.ts +31 -0
- package/src/lib/domain.ts +12 -0
- package/src/lib/flights.ts +33 -0
- package/src/lib/focus-return.ts +66 -0
- package/src/lib/greeting.ts +15 -0
- package/src/lib/image-data-url.ts +35 -0
- package/src/lib/keyboard.native.tsx +25 -0
- package/src/lib/keyboard.tsx +55 -0
- package/src/lib/labels-es.ts +113 -0
- package/src/lib/labels.tsx +207 -0
- package/src/lib/origins.ts +28 -0
- package/src/lib/participants.ts +97 -0
- package/src/lib/pcm.ts +57 -0
- package/src/lib/power-level-options.ts +66 -0
- package/src/lib/questions.ts +92 -0
- package/src/lib/speech-language.ts +20 -0
- package/src/lib/speech-messages.ts +54 -0
- package/src/lib/speech-synthesis.ts +156 -0
- package/src/lib/suggestions.ts +53 -0
- package/src/lib/task-labels.ts +35 -0
- package/src/lib/text-input.ts +10 -0
- package/src/lib/tool-call-status.ts +28 -0
- package/src/lib/tool-icons.ts +36 -0
- package/src/lib/tool-registry.ts +71 -0
- package/src/lib/tool-renderers.tsx +32 -0
- package/src/lib/turn-state.ts +15 -0
- package/src/lib/utils.ts +35 -0
- package/src/lib/voice-audio-engine-types.ts +59 -0
- package/src/lib/voice-audio-engine.native.ts +232 -0
- package/src/lib/voice-audio-engine.ts +206 -0
- package/src/lib/voice-call-request.ts +49 -0
- package/src/lib/voice-call.ts +627 -0
- package/src/lib/voice-controls-labels.ts +31 -0
- package/src/lib/voice-levels.ts +64 -0
- package/src/lib/voice-protocol.ts +328 -0
- package/src/lib/voice-worklets.ts +19 -0
- package/src/lib/work-log.ts +370 -0
- package/src/metro/chart-importers.json +18 -0
- package/src/metro/granular-charts.js +3 -0
- package/src/metro/index.cjs +227 -0
- package/src/metro/index.d.cts +5 -0
- package/src/runtime/agents.ts +151 -0
- package/src/runtime/api.ts +144 -0
- package/src/runtime/app-assertion.ts +51 -0
- package/src/runtime/attachment-utils.ts +97 -0
- package/src/runtime/chat-turn-control.ts +74 -0
- package/src/runtime/composer-draft-store.ts +270 -0
- package/src/runtime/config.tsx +222 -0
- package/src/runtime/conversation-dates.ts +31 -0
- package/src/runtime/conversation-store.ts +49 -0
- package/src/runtime/conversations.ts +633 -0
- package/src/runtime/error-utils.ts +144 -0
- package/src/runtime/gemie-accounts.ts +182 -0
- package/src/runtime/host-tools.ts +290 -0
- package/src/runtime/index.ts +137 -0
- package/src/runtime/message-history.ts +124 -0
- package/src/runtime/message-reactions.ts +214 -0
- package/src/runtime/model.ts +39 -0
- package/src/runtime/oxy-files.ts +37 -0
- package/src/runtime/power-levels.ts +66 -0
- package/src/runtime/query-keys.ts +60 -0
- package/src/runtime/random-uuid.ts +25 -0
- package/src/runtime/reaction-cache.ts +45 -0
- package/src/runtime/room-events.ts +333 -0
- package/src/runtime/routes.ts +85 -0
- package/src/runtime/sharing.ts +217 -0
- package/src/runtime/sse-frame-reader.ts +88 -0
- package/src/runtime/stream-events.ts +154 -0
- package/src/runtime/stream-outcome.ts +21 -0
- package/src/runtime/thought-store.ts +103 -0
- package/src/runtime/thread/agent-activity.ts +261 -0
- package/src/runtime/thread/agent-exchange.ts +94 -0
- package/src/runtime/thread/automation-labels.ts +79 -0
- package/src/runtime/thread/conversation-export.ts +135 -0
- package/src/runtime/thread/message-days.ts +120 -0
- package/src/runtime/thread/message-processor.ts +93 -0
- package/src/runtime/thread/speaker-changes.ts +66 -0
- package/src/runtime/thread/task-utils.ts +11 -0
- package/src/runtime/thread/thought-utils.ts +750 -0
- package/src/runtime/thread/thread-history.ts +139 -0
- package/src/runtime/thread/timeline.ts +202 -0
- package/src/runtime/thread/title-tags.ts +8 -0
- package/src/runtime/thread/tool-cards.ts +387 -0
- package/src/runtime/turn-failure.ts +108 -0
- package/src/runtime/turn-preparation.ts +21 -0
- package/src/runtime/types.ts +172 -0
- package/src/runtime/usage-limit-error.ts +44 -0
- package/src/runtime/use-agent-activity.ts +80 -0
- package/src/runtime/use-conversation-stream.ts +1669 -0
- package/src/runtime/use-conversation-thread.ts +590 -0
- package/src/runtime/use-gemie-thread.ts +54 -0
- package/src/runtime/use-room-events.ts +75 -0
- package/src/runtime/use-start-conversation.ts +107 -0
- package/src/runtime/use-thread-history.ts +73 -0
- package/src/runtime/use-thread-search.ts +100 -0
- package/src/runtime/use-turn-edit.ts +99 -0
- package/src/text.ts +19 -0
- package/src/theme.ts +16 -0
- package/src/tools.ts +27 -0
- package/src/types.ts +161 -0
- package/src/voice-messages.ts +2 -0
- package/src/voice.ts +67 -0
- package/tsconfig.json +17 -0
- package/worklets/voice-processors.js +152 -0
package/README.md
CHANGED
|
@@ -1,3 +1,517 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gemies/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Gemies SDK for React Native and Expo apps built on Oxy, which talk to a gemie (Alia unless the
|
|
4
|
+
app opens another): the conversation (the chat sheet,
|
|
5
|
+
the screen, the thread, the thought panel and the composer), the streaming hook, speech in and
|
|
6
|
+
out, and the primitives they are made of. It renders inside the one `OxyProvider` your app already mounts and sends
|
|
7
|
+
the signed-in user's Oxy session with every request; it never holds a token of
|
|
8
|
+
its own.
|
|
9
|
+
|
|
10
|
+
The package ships **raw TypeScript source** — `main`, `types` and every
|
|
11
|
+
`exports` entry point at `src/`. Your bundler compiles it with the rest of your
|
|
12
|
+
app, which is why the section on endpoints below matters more than it would for
|
|
13
|
+
a prebuilt library.
|
|
14
|
+
|
|
15
|
+
It replaced `@alia.onl/sdk` (last version 25.0.1) with no bridge package: the components and
|
|
16
|
+
hooks are named `Gemie*` (`GemieChatContent`, `GemieChatSheet`, `GemieAvatar`, `useAskGemie`…),
|
|
17
|
+
the default API is `https://api.gemies.ai` and the shared web origin is `https://gemies.ai`. The
|
|
18
|
+
mapping is in [`CHANGELOG.md`](./CHANGELOG.md) under 1.0.0.
|
|
19
|
+
|
|
20
|
+
## Optional granular chart imports for Metro
|
|
21
|
+
|
|
22
|
+
The standard SDK entries and Bloom peer range are unchanged. Apps that install a Bloom
|
|
23
|
+
version exposing `chart-cards/bar-list` and `chart-cards/line` can opt into a narrower
|
|
24
|
+
chart graph by wrapping their **finished** Metro configuration:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const { withGemieGranularCharts } = require('@gemies/sdk/metro');
|
|
28
|
+
|
|
29
|
+
module.exports = withGemieGranularCharts(existingMetroConfig);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This Node-only entry wraps the previous resolver and redirects two verified chart imports
|
|
33
|
+
in this SDK copy. It delegates extra resolution probes to that resolver, so resolver
|
|
34
|
+
implementations with side effects will observe those calls. It checks that the original
|
|
35
|
+
barrel and both granular imports resolve to
|
|
36
|
+
the same physical Bloom copy for the original importer and the adapter. Both subpaths
|
|
37
|
+
must be explicit `exports` keys resolving under the active Metro conditions to files
|
|
38
|
+
inside that copy; arrays, patterns and redirects to other files are not supported.
|
|
39
|
+
The SDK importer hashes are rechecked on affected resolutions, including in watch mode.
|
|
40
|
+
Detection uses the registered paths and their real paths; new aliases introduced later
|
|
41
|
+
may be treated as unregistered, so restart Metro after changing SDK links.
|
|
42
|
+
Missing exports,
|
|
43
|
+
an altered SDK importer or incompatible metadata fail with an explicit build error; the
|
|
44
|
+
normal SDK does not require those exports when this option is not used. File hashes detect
|
|
45
|
+
changes requiring review; they do not authenticate packages.
|
|
46
|
+
|
|
47
|
+
Apply the wrapper once, after other Metro wrappers. Reapplying it directly throws;
|
|
48
|
+
register all copies together instead. Opaque wrappers or cloned configurations can
|
|
49
|
+
hide the marker; do not apply this helper again after composing them.
|
|
50
|
+
Multiple installed SDK copies are not discovered automatically. To opt in other copies,
|
|
51
|
+
pass `{ additionalSdkRoots: ['/absolute/path/to/sdk'] }`; each must ship matching opt-in
|
|
52
|
+
metadata. Unregistered copies retain their original imports and may still include the chart
|
|
53
|
+
barrel. This does not deduplicate React, Bloom or SDK providers, nor prove a bundle-size
|
|
54
|
+
reduction. Review importers, update the version and hashes in `chart-importers.json`, and
|
|
55
|
+
run the Metro tests when updating the SDK package or those files.
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
bun add @gemies/sdk
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`react`, `react-native`, `@oxy.so/core`, `@oxy.so/services`, `@tanstack/react-query`
|
|
64
|
+
(the conversation runtime's cache; `OxyProvider` mounts the client), `react-native-css`
|
|
65
|
+
(the thread's images take `className`) and the Expo modules listed under `peerDependencies` in
|
|
66
|
+
`package.json` — among them `expo-clipboard` and `expo-web-browser`, which the thread's copy
|
|
67
|
+
button and its sources use — are yours to install. Metro
|
|
68
|
+
must resolve package `exports` (`resolver.unstable_enablePackageExports = true`,
|
|
69
|
+
the default in Expo SDK 53+), because every icon import is a subpath.
|
|
70
|
+
|
|
71
|
+
The chat is built from Bloom (`@oxy.so/bloom`, a peer dependency): mount Bloom's
|
|
72
|
+
`BloomProvider` above it, with the one `KeyboardProvider` your app already has.
|
|
73
|
+
The main and conversation sheets use Bloom's default content sizing: they grow and
|
|
74
|
+
shrink with the chat up to the shared viewport limit. Bloom coordinates the Screen
|
|
75
|
+
content, safe areas and keyboard clearance. Hosts should not add window-height calculations or a second
|
|
76
|
+
scroll container to make an embedded chat visible.
|
|
77
|
+
|
|
78
|
+
Alia's avatar is Bloom's character (`AgentAvatar`), drawn as SVG on web and native (Bloom
|
|
79
|
+
17.22 and later). There is nothing to host, fetch or configure: the chat components mount Bloom's
|
|
80
|
+
`AgentAvatarProvider` themselves, so the app mounts no avatar provider and passes no URL. The
|
|
81
|
+
`ALIA_CHARACTER_RUNTIME_URL` export, the `characterRuntimeUrl` prop and the optional
|
|
82
|
+
`@oxy.so/bloom-avatar-native` companion were removed in 23.0.0.
|
|
83
|
+
|
|
84
|
+
A web app with a Content-Security-Policy composes the SDK's into its own instead of listing
|
|
85
|
+
Alia's origins by hand: `@gemies/sdk/csp` exports `GEMIES_SDK_CSP` and `withGemiesSdkCsp(extensions)`
|
|
86
|
+
in the shape of `@oxy.so/core`'s `OxyCspExtensions` (a leaf entry, safe on a server):
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { withGemiesSdkCsp } from '@gemies/sdk/csp';
|
|
90
|
+
app.use(createOxySecurityHeaders({ csp: withGemiesSdkCsp(APP_CSP_EXTENSIONS) }));
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
It declares the API and its WebSocket (`connect-src`), the avatar runtime and the voice call's
|
|
94
|
+
worklets on `https://gemies.ai` (`script-src`, with `'wasm-unsafe-eval'` for the runtime's
|
|
95
|
+
WebAssembly), attachments and read-aloud clips (`img-src`, `media-src`). No `blob:` script:
|
|
96
|
+
the worklets are a content-addressed file on `gemies.ai`, not a blob URL.
|
|
97
|
+
|
|
98
|
+
The empty chat greets the signed-in person by name ("Hi Nate, what's on your mind?"); pass
|
|
99
|
+
`welcomeGreeting` to say something else, or `labels.greeting` / `labels.greetingNamed` to translate it.
|
|
100
|
+
|
|
101
|
+
Failures (a voice call that cannot start, a dictation error) are shown with Bloom's `toast`,
|
|
102
|
+
so the app needs a `ToastOutlet` (`OxyProvider` mounts one), or pass `onError` to handle them.
|
|
103
|
+
|
|
104
|
+
`GemieAskProvider` follows the language Oxy Services resolves for the active account, including
|
|
105
|
+
language changes while its sheet is open. The SDK ships English and Spanish (regional Spanish tags
|
|
106
|
+
such as `es-ES` and `es-MX` use Spanish); other languages fall back to English. `GemieChatSheet` and
|
|
107
|
+
`GemieChatScreen` select their built-in copy from `labels.locale`. Pass `labels` to override any copy
|
|
108
|
+
(`GemieChatLabels`), or `labels.t` for another catalogue. Nested overrides preserve the surrounding
|
|
109
|
+
chat's translations. Bloom's own strings follow `BloomProvider`'s `locale`.
|
|
110
|
+
|
|
111
|
+
Entry points:
|
|
112
|
+
|
|
113
|
+
- `@gemies/sdk` — the conversation screen (`GemieChatScreen`, `GemieChatSheet`,
|
|
114
|
+
`GemieChatContent`, the thread `GemieThread`, the work panel `ThoughtPanel`) with its voice call included: the button that opens it, the
|
|
115
|
+
bar with its honest state, the notices (failure, moved to another device, time
|
|
116
|
+
limit) and the transcript in the same thread. Also dictation, read-aloud,
|
|
117
|
+
the conversation runtime, primitives. The call loads on the first call.
|
|
118
|
+
- `@gemies/sdk/runtime` — the conversation data layer alone (hooks, cache, stores,
|
|
119
|
+
`GemieRuntimeProvider`), for a sidebar or a test that must not load the chat UI.
|
|
120
|
+
- `@gemies/sdk/model` — the conversation as pure data (the records, the timeline, the thought
|
|
121
|
+
panel's steps and sources, tool cards, the markdown export): no React, no Oxy client.
|
|
122
|
+
- `@gemies/sdk/csp` — the CSP the SDK needs from a host page (above).
|
|
123
|
+
- `@gemies/sdk/voice` — the call's parts (`VoiceSession`, `useVoiceRoom`,
|
|
124
|
+
the audio engine) for a host that builds its own screen.
|
|
125
|
+
|
|
126
|
+
Voice is on by default; `voice={false}` makes a chat text-only, and
|
|
127
|
+
`voice={{ canStartVoice, onVoiceBlocked, onCallEnded, onNotice, sounds }}` brings
|
|
128
|
+
what only the host knows (the plan and credits gate, what to refresh when a call
|
|
129
|
+
ends, where notices go, the cues it plays). Whether the screen holding the call is the one on
|
|
130
|
+
show is `isFocused` of the chat. The conversation a call lives in is the chat's own. Its words are `labels.voiceControls`,
|
|
131
|
+
`voiceError`, `voiceEnded`, `voiceEndingSoon` and `voiceBlocked`. A host with its
|
|
132
|
+
own screen uses `useVoiceLauncher` and `GemieVoiceCall`, the same pieces.
|
|
133
|
+
|
|
134
|
+
## Speech
|
|
135
|
+
|
|
136
|
+
Nothing is recognized on the device. Speech is recognized by Kaana, through
|
|
137
|
+
Alia (Alia ADR 0017):
|
|
138
|
+
|
|
139
|
+
- **Dictation** (`useDictation`, the composer's mic) records a clip — the
|
|
140
|
+
browser's `MediaRecorder`, or the `expo-audio` recorder on iOS and Android —
|
|
141
|
+
and, when the person stops, sends it to `POST /v1/audio/transcriptions`.
|
|
142
|
+
The text arrives once, never partially. Five minutes per clip. Free on every
|
|
143
|
+
Alia plan.
|
|
144
|
+
- **A voice call** (`useVoiceRoom`, `VoiceSession`) is a realtime
|
|
145
|
+
speech-to-speech session: a WebSocket to Alia's `GET /v1/voice/session`
|
|
146
|
+
carrying PCM16 24 kHz audio both ways. Turn detection and barge-in are the
|
|
147
|
+
model's; tools run in Alia; the transcript is stored in the conversation.
|
|
148
|
+
Voice calls need a paid Alia plan and use credits per minute.
|
|
149
|
+
|
|
150
|
+
Audio reaches Alia, Kaana and the model's provider; Alia logs no audio and no
|
|
151
|
+
transcript content.
|
|
152
|
+
|
|
153
|
+
On iOS and Android a call needs
|
|
154
|
+
[`react-native-audio-api`](https://github.com/software-mansion/react-native-audio-api)
|
|
155
|
+
(a peer of the SDK: the conversation screen includes the call)
|
|
156
|
+
and its config plugin, then a new native build:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
["react-native-audio-api", {
|
|
160
|
+
"iosMicrophonePermission": "Allow $(PRODUCT_NAME) to hear what you dictate and say in voice calls.",
|
|
161
|
+
"iosBackgroundMode": false,
|
|
162
|
+
"androidForegroundService": false,
|
|
163
|
+
"androidPermissions": ["android.permission.RECORD_AUDIO"]
|
|
164
|
+
}]
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Dictation needs only `expo-audio` (already a peer). Pass `lang` to both hooks
|
|
168
|
+
(`speechLanguage` to `GemieComposer`) to follow your app's language.
|
|
169
|
+
|
|
170
|
+
## Use
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
import { GemieChatScreen } from '@gemies/sdk';
|
|
174
|
+
|
|
175
|
+
export function Assistant() {
|
|
176
|
+
return <GemieChatScreen />;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`GemieChatScreen` is a full-screen route: it pads itself by the top and bottom
|
|
181
|
+
safe-area insets, so render it where no tab bar or other bottom chrome is drawn.
|
|
182
|
+
On iOS and Android its composer rises with the keyboard through
|
|
183
|
+
`react-native-keyboard-controller`, which needs the app wrapped in its
|
|
184
|
+
`KeyboardProvider` (re-exported here).
|
|
185
|
+
|
|
186
|
+
The sheet, the screen and the Alia app are three frames around ONE conversation runtime
|
|
187
|
+
(see [The conversation runtime](#the-conversation-runtime)): they list, open, create, send,
|
|
188
|
+
stop, retry, edit and clear conversations through the same hooks, and a conversation started in
|
|
189
|
+
one is the same conversation in the others.
|
|
190
|
+
|
|
191
|
+
### Which entry to import
|
|
192
|
+
|
|
193
|
+
| You want | Import from | Bundles the voice call |
|
|
194
|
+
|---|---|---|
|
|
195
|
+
| The chat with the call (`GemieChatSheet`, `GemieChatScreen`, `GemieChatContent`) | `@gemies/sdk` | yes |
|
|
196
|
+
| The same chat, text only | `@gemies/sdk/text` | no |
|
|
197
|
+
| One "Ask" sheet at the app's root, loaded with the first `ask` | `@gemies/sdk/ask` | yes, in the sheet's chunk |
|
|
198
|
+
| The root's eager Ask provider and hook | `@gemies/sdk/ask/eager` | yes, loaded eagerly |
|
|
199
|
+
| The same, text only | `@gemies/sdk/ask/text` | no |
|
|
200
|
+
| Data only: conversations, the stream, the model | `@gemies/sdk/runtime`, `@gemies/sdk/model` | no |
|
|
201
|
+
| Her face on a button | `@gemies/sdk/avatar` | no |
|
|
202
|
+
| Character parser and runtime URL | `@gemies/sdk/character` | no |
|
|
203
|
+
| Voice error messages without the call | `@gemies/sdk/voice/messages` | no |
|
|
204
|
+
|
|
205
|
+
`voice={false}` hides the call, but the code still ships: the root entry and `@gemies/sdk/ask`
|
|
206
|
+
bundle the call (its socket, protocol and audio engine) because their chat can open one. A
|
|
207
|
+
text-only app imports from `@gemies/sdk/text` or `@gemies/sdk/ask/text`. Their chat never
|
|
208
|
+
reaches those modules and never offers a call, whatever `voice` says. Read-aloud and dictation
|
|
209
|
+
are still there, because they belong to the thread and the composer. Types can still come from
|
|
210
|
+
`@gemies/sdk`, since type imports are erased. A value imported from the root brings the call
|
|
211
|
+
along with it. In CrowdSource's reviewer, `@gemies/sdk/text` made its lazy sheet chunk 98 KB
|
|
212
|
+
smaller (raw; 39 KB gzip).
|
|
213
|
+
|
|
214
|
+
## Any agent, from any app
|
|
215
|
+
|
|
216
|
+
Every agent — Alia included — is the same agent (ADR 0020), and any Oxy app opens any agent the
|
|
217
|
+
person can reach. The wire contract is [`docs/agent-embedding.md`](../../docs/agent-embedding.md).
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
import { GemieAskProvider, useAskGemie } from '@gemies/sdk/ask';
|
|
221
|
+
|
|
222
|
+
<GemieAskProvider
|
|
223
|
+
agents={{ alia: {}, sindi: { id: SINDI_AGENT_ID } }} // no id = Alia
|
|
224
|
+
clientContext={`Homiio — viewing listing ${listing.id}`} // the screen, built per turn
|
|
225
|
+
hostTools={{
|
|
226
|
+
app: 'homiio',
|
|
227
|
+
definitions: [{ name: 'apply_search', description: '…', inputSchema: { type: 'object' } }],
|
|
228
|
+
execute: async (action) => applySearch(action.input), // → { outcome: 'applied' | … }
|
|
229
|
+
}}
|
|
230
|
+
toolRenderers={{ 'homiio:searchListings': (r) => <ListingCards data={r.output} /> }}
|
|
231
|
+
onFeatureLocked={(key) => showHomiioPlus(key)}
|
|
232
|
+
onShare={({ token }) => shareSheet(`https://homiio.com/shared/${token}`)}
|
|
233
|
+
>
|
|
234
|
+
{children}
|
|
235
|
+
</GemieAskProvider>;
|
|
236
|
+
|
|
237
|
+
const { ask, resume, dismiss } = useAskGemie();
|
|
238
|
+
ask('sindi', { text: 'Is this flat a good price?' }); // signed out: Oxy's sign-in instead
|
|
239
|
+
resume('sindi', conversationId); // a stored conversation, where the person left it
|
|
240
|
+
dismiss(); // e.g. after a host tool changed the page under the sheet
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Mount it from `@gemies/sdk/ask`: that entry is the provider and its hook alone, and the sheet
|
|
244
|
+
loads with the first `ask` (fetched in the background once the person is signed in), so the chat
|
|
245
|
+
stays out of the app's entry bundle. The root entry exports the same two, with the whole chat
|
|
246
|
+
(its provider imports the sheet statically).
|
|
247
|
+
For hosts that need that exact eager behavior without the root barrel, import the provider and
|
|
248
|
+
hook from `@gemies/sdk/ask/eager`. The character entry exports `readAgentCharacter`,
|
|
249
|
+
and `DEFAULT_AGENT_CHARACTER` without the chat.
|
|
250
|
+
|
|
251
|
+
**On web, load the chat through ONE async boundary.** Expo's Metro serializer hoists every module
|
|
252
|
+
two async chunks share into `__common.js`, which loads at first paint. The SDK draws no async chunk
|
|
253
|
+
boundary of its own on web (the call, sounds and pickers import statically there), except the one
|
|
254
|
+
of `@gemies/sdk/ask`. So either mount the provider from `@gemies/sdk/ask`, or lazy-import your
|
|
255
|
+
own module that imports the root entry (or `@gemies/sdk/text`). Don't do both, or the chat they
|
|
256
|
+
share lands in `__common.js`. The text-only entries draw no extra boundary either.
|
|
257
|
+
|
|
258
|
+
The sheet offers the person's latest conversations with its lead under the greeting
|
|
259
|
+
(`recentConversations={false}` turns it off). The code that configures the sheet sits above it, so
|
|
260
|
+
`GemieAskProvider` forwards a ref to the same `GemieAsk` for it.
|
|
261
|
+
|
|
262
|
+
- **The lead.** `agent={{ id }}` (on `GemieChatSheet`, `GemieChatScreen` and `GemieChatContent`) makes
|
|
263
|
+
that agent the conversation's lead: its greeting, name, character and starters
|
|
264
|
+
(`GET /v1/agents/:id/profile`) and the header's first avatar. Omitted, Alia.
|
|
265
|
+
- **The participants.** `GemieChatState.participants` is `{ lead, joined }`; draw it with
|
|
266
|
+
`GemieParticipants` (or `GemieParticipantsHeader` inside Bloom's AI chat shell) wherever the
|
|
267
|
+
chrome puts the conversation's title. When the lead consults an agent (`alia.agent_start`), the
|
|
268
|
+
agent's reply is drawn under its own identity and its avatar flies from there into the header —
|
|
269
|
+
Bloom's multi-agent join — which gains the agent when it lands.
|
|
270
|
+
- **Host tools** are UI effects the app's own client performs. An `alia.host_action` is executed
|
|
271
|
+
once, by `execute`, and its outcome is sent with the next request; an outcome whose request did
|
|
272
|
+
not get through goes with the one after. They are never authority over data.
|
|
273
|
+
- **Tool renderers** are keyed `<app>:<tool>`, parsed only from `oxy_<app>__<tool>` /
|
|
274
|
+
`self_<app>__<tool>`, and drawn before the generic tool card — for consulted agents too.
|
|
275
|
+
- **Feature gates.** The attach menu offers photos and files as the lead offers them
|
|
276
|
+
(`GET /v1/agents/:id/features`); a locked row, and a turn refused with
|
|
277
|
+
`feature_entitlement_required`, call `onFeatureLocked(key)`. Documents are uploaded to the
|
|
278
|
+
person's Oxy Files (`oxyServices.assets.upload`) and sent as a `file` part.
|
|
279
|
+
- **Sharing.** `onShare` receives `{ conversationId, token, expiresAt }` once the SDK has minted
|
|
280
|
+
the link; `useShareConversation()` mints and revokes, and `<GemieSharedConversation token>` reads
|
|
281
|
+
one, signed in or not. `useConversations({ agentId })` lists the person's conversations with one
|
|
282
|
+
agent.
|
|
283
|
+
|
|
284
|
+
## An "Ask Alia" button with her avatar
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
import { GemieAvatarIcon, useGemieActivity } from '@gemies/sdk';
|
|
288
|
+
|
|
289
|
+
<Button icon={GemieAvatarIcon} onPress={openGemie}>Ask Alia</Button>;
|
|
290
|
+
const state = useGemieActivity(); // 'idle' | 'thinking' | 'working' | 'writing'
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
`GemieAvatarIcon` is a Bloom icon component (`BloomIconComponent`): pass it as `icon` /
|
|
294
|
+
`leadingIcon`. Bloom draws her as SVG under its own `AgentAvatarProvider`, so a header that shows
|
|
295
|
+
her fetches nothing. While she thinks or works she plays her working turn; reduced motion keeps
|
|
296
|
+
her still.
|
|
297
|
+
|
|
298
|
+
`useGemieActivity()` is the busiest of two sources, so a button reacts even with the sheet closed:
|
|
299
|
+
|
|
300
|
+
- a turn running in this app: every `useConversationThread` publishes its lifecycle to a shared store;
|
|
301
|
+
- her runs for the signed-in person elsewhere (background work, another device): the API's
|
|
302
|
+
`alia:activity` event on the person's `user:<id>` room, over ONE Socket.IO connection per
|
|
303
|
+
API origin, opened with the Oxy session's token only while someone is signed in and a
|
|
304
|
+
consumer is mounted, closed with the last one. A run that goes quiet for 90 s is treated as over.
|
|
305
|
+
|
|
306
|
+
`socket.io-client` is a regular dependency, not a peer: the SDK owns this connection and an
|
|
307
|
+
app should not have to install a transport to use a button.
|
|
308
|
+
|
|
309
|
+
## The thread
|
|
310
|
+
|
|
311
|
+
The sheet, the screen and the Alia app draw ONE thread, `GemieThread` (inside `GemieChatContent`),
|
|
312
|
+
and nothing else draws turns: Bloom's AI Chat turns with their reveal, the feedback row and the
|
|
313
|
+
long-press menu; the reply's Markdown with its rich blocks, its code card and its references;
|
|
314
|
+
the work log (`WebSearch`, `TaskList`) and the "Worked for…" line; tool cards; the questions Alia
|
|
315
|
+
asked; the plan an agent shows; the failed turn's toast with its Retry; day lines; the window over a long
|
|
316
|
+
history with the scroll that goes with it; and the card of an agent's run. What a frame adds is
|
|
317
|
+
around it, never in it (`tests/components/thread/one-thread.test.tsx` mounts it both ways and
|
|
318
|
+
holds the rows equal, and fails if anything else imports Bloom's thread).
|
|
319
|
+
|
|
320
|
+
An agent's permanent thread is `threadHandle`: the conversations behind the open one are paged in
|
|
321
|
+
above it, the thread can be searched (`state.openSearch`), and a hit opens the stretch around it.
|
|
322
|
+
Those routes (`/agents/thread/:handle/…`) answer Alia's own origins only, as `/conversations` did
|
|
323
|
+
before `/v1`: an embedding Oxy app has no agents of its own and passes no handle.
|
|
324
|
+
|
|
325
|
+
### The work panel, and where it goes
|
|
326
|
+
|
|
327
|
+
A turn that used tools has a "Worked for…" line; pressing it selects the turn (`useThoughtStore`)
|
|
328
|
+
and asks the host to show it (`runtime.showThought`). `ThoughtPanel` — steps, sources, activity —
|
|
329
|
+
draws the selection wherever the host puts it: the Alia app's right panel, the sheet's own sheet
|
|
330
|
+
over the conversation. A host without `showThought` has no panel, and the line is plain text. A
|
|
331
|
+
running turn's first tool opens the panel by itself (`showThought('automatic')`) unless the host
|
|
332
|
+
declines because something else is open. A file the turn generated opens where the host keeps its
|
|
333
|
+
files (`ThoughtPanel`'s `outputActions`).
|
|
334
|
+
|
|
335
|
+
### Cards: why weather, market and FairCoin are the SDK's
|
|
336
|
+
|
|
337
|
+
The weather, market quote and FairCoin price cards are the thread's. Their tools
|
|
338
|
+
(`getWeather`, `getMarketQuote`, `getFairCoin`) are in the pipeline every Alia surface calls, and
|
|
339
|
+
the card's numbers travel in the message itself (the whole of every range is in the snapshot, so a
|
|
340
|
+
thread reopened next month shows the figures it was answered with). So any surface that draws
|
|
341
|
+
Alia's reply draws them. The scheduled-task card is the same card with one difference: it points at
|
|
342
|
+
a screen of the host's, so it is a link only where `runtime.openAutomation` says where it goes.
|
|
343
|
+
|
|
344
|
+
## The composer
|
|
345
|
+
|
|
346
|
+
The sheet, the screen and the Alia app share one composer, `GemieComposer`: Bloom's
|
|
347
|
+
`ComposerPill` with files by paste and drop (read with real progress, retried, refused with a
|
|
348
|
+
sentence), dictation, suggestions over the field and Alia's questions docked above it.
|
|
349
|
+
`GemieChatSheet` and `GemieChatScreen` render it with photos, voice and suggestions, and
|
|
350
|
+
`GemieChatSheet` focuses it once the sheet has presented. The conversation also owns the draft
|
|
351
|
+
(per conversation and account), sending, rewriting a question already sent, the questions Alia
|
|
352
|
+
asked and the power-level selector: give `GemieChatContent` an `onModelChange` and the composer
|
|
353
|
+
offers the seven levels (`auto` … `ultra`) with `deviceModels` of the person's own after them;
|
|
354
|
+
give it an `addMenu` (rows and what pressing one does) and that menu replaces the photos one. To build your own surface, mount it and
|
|
355
|
+
pass what the surface has:
|
|
356
|
+
|
|
357
|
+
```tsx
|
|
358
|
+
import { GemieComposer } from '@gemies/sdk';
|
|
359
|
+
|
|
360
|
+
<GemieComposer
|
|
361
|
+
value={draft}
|
|
362
|
+
onValueChange={setDraft}
|
|
363
|
+
onSubmit={send}
|
|
364
|
+
busy={isStreaming}
|
|
365
|
+
onStop={stop}
|
|
366
|
+
modes={powerLevels} // the mode selector; omit to hide it
|
|
367
|
+
mode={level}
|
|
368
|
+
onModeChange={setLevel}
|
|
369
|
+
addMenu={groups} // the add menu's rows, and what pressing one does
|
|
370
|
+
onAddMenuSelect={onAdd}
|
|
371
|
+
attachments={files} // omit `onAddAttachment` and the composer takes no paste or drop
|
|
372
|
+
onAddAttachment={addFile}
|
|
373
|
+
onRemoveAttachment={removeFile}
|
|
374
|
+
attachmentKinds={['image']} // what your send carries; others are refused with a sentence
|
|
375
|
+
labels={{ composerSend: 'Enviar' }} // anything omitted is English
|
|
376
|
+
/>;
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## The conversation runtime
|
|
380
|
+
|
|
381
|
+
Everything that is a conversation lives in `src/runtime`, in layers that depend only downward:
|
|
382
|
+
|
|
383
|
+
| Layer | What | Public names |
|
|
384
|
+
| --- | --- | --- |
|
|
385
|
+
| Transport | Alia's REST API over the signed-in person's Oxy client (token, refresh and the single 401 replay are Oxy's); the turn's SSE stream | `useGemieApi`, `GemieApiError` |
|
|
386
|
+
| Model and state | the records, React Query keys and the cached lists; zustand stores for the composer drafts and the hand-off of a first message | `Message`, `Conversation`, `gemieQueryKeys`, `useComposerDraftStore`, `useConversationStore` |
|
|
387
|
+
| Hooks | `useConversations` (the list, paginated), `useConversation` (one, with its history), `useCreateConversation`, `useRenameConversation`, `useDeleteConversation`, `useClearConversation`, and `useConversationThread`: the live thread of one conversation — messages, `sendMessage`, `createNewConversation`, `editMessage`, `regenerateMessage`, `retryFailedTurn`, `stopGeneration`, `clearConversation`, `startOver`, `ensureConversation` | `use…` |
|
|
388
|
+
| UI | `GemieChatContent` (the conversation screen), `GemieChatScreen`, `GemieChatSheet`, `GemieThread`, `ThoughtPanel` | components |
|
|
389
|
+
|
|
390
|
+
Between the hooks and the components are the hooks of what a person does with a conversation —
|
|
391
|
+
`useChatComposer` (the draft, send, edit, suggestions), `useChatVoice` (the call and its
|
|
392
|
+
transcript in the thread), `useThreadView` (the present or a moment of an agent's thread),
|
|
393
|
+
`useOpenThought`, `useReadAloud`, `useMessageVote` — each used by exactly one layer above it.
|
|
394
|
+
|
|
395
|
+
An agent's thread and runs (`useThreadHistory`, `useThreadSearch`, `useThreadWindow`,
|
|
396
|
+
`useAgentActivity`) read the agent routes through the same API and cache.
|
|
397
|
+
|
|
398
|
+
A turn goes to `POST {apiUrl}/v1/chat/completions`; conversations to `{apiUrl}/v1/conversations`.
|
|
399
|
+
`apiUrl` defaults to `EXPO_PUBLIC_GEMIES_API_URL`, then `https://api.gemies.ai`. A failure to
|
|
400
|
+
answer is a typed error that keeps the person's turn in the thread with a retry (`FailedTurn`),
|
|
401
|
+
never a filler message; running out of credits or hitting a rate limit is a `UsageLimitError`.
|
|
402
|
+
|
|
403
|
+
### Configure it once: `GemieRuntimeProvider`
|
|
404
|
+
|
|
405
|
+
Providers nest and merge, so the sheet works with no provider at all and the Alia app mounts
|
|
406
|
+
one above its routes. Everything is optional.
|
|
407
|
+
|
|
408
|
+
```tsx
|
|
409
|
+
import { GemieRuntimeProvider, type GemieRuntimeHost } from '@gemies/sdk';
|
|
410
|
+
|
|
411
|
+
const host: GemieRuntimeHost = {
|
|
412
|
+
// navigation: the runtime created or chose a conversation / the open one is gone
|
|
413
|
+
openConversation: (id) => router.push(`/c/${id}`),
|
|
414
|
+
closeConversation: () => router.replace('/'),
|
|
415
|
+
// what only the host can show: credits, an artifact panel, a haptic tick
|
|
416
|
+
onUsage: (frame) => updateCredits(frame.credits_remaining),
|
|
417
|
+
onArtifact: (artifact) => rightPanel.show(artifact),
|
|
418
|
+
turnRequest: () => ({ webSearch: composerMenu.webSearch, deepResearch: composerMenu.deepResearch }),
|
|
419
|
+
// where the work of a turn is read; return false to decline an automatic opening
|
|
420
|
+
showThought: (opening) => (opening === 'automatic' && panel.isOpen ? false : panel.show('thought')),
|
|
421
|
+
openAutomation: (id) => router.push(`/automations/${id}`), // a scheduled-task card is a link
|
|
422
|
+
faviconUrl: (url) => favicons.of(url), // the work log's source icons
|
|
423
|
+
// the edges of a turn this runtime sends
|
|
424
|
+
onTurnStart: () => executor.beginTurn(),
|
|
425
|
+
onTurnEnd: () => executor.runHeldBack(), // finished, stopped or failed: once per turn
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
<GemieRuntimeProvider
|
|
429
|
+
apiUrl="https://api.gemies.ai"
|
|
430
|
+
offline={accountScopedStore} // optional: where a 401-ed session keeps its conversations
|
|
431
|
+
streamFetch={expoFetch} // optional: a fetch that can stream a body on native
|
|
432
|
+
speech={{ voice: 'female', tone: 'brief', language: 'es-ES' }} // read-aloud, dictation, calls
|
|
433
|
+
host={host} // memoise it
|
|
434
|
+
>
|
|
435
|
+
{children}
|
|
436
|
+
</GemieRuntimeProvider>;
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
`onTurnStart` is called just before each turn the runtime sends — from the composer, a retry,
|
|
440
|
+
an edit or a regenerate — so a host can take what the turn will be judged against at that send.
|
|
441
|
+
`onTurnEnd` is called exactly once for each turn the runtime sends, when it stops streaming —
|
|
442
|
+
the answer was written, the person pressed Stop, or the turn failed — and only while the
|
|
443
|
+
conversation that sent it is still mounted. A host that holds back what would take the chat off
|
|
444
|
+
the screen (a host tool that navigates away) runs it there; a surface that left mid-turn is never
|
|
445
|
+
called back, so what it held back goes with it.
|
|
446
|
+
|
|
447
|
+
The sheet and the Alia app differ ONLY in what they put there:
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
// The sheet: nothing to configure; the chat keeps its own conversation.
|
|
451
|
+
<GemieChatSheet ref={sheet} />
|
|
452
|
+
|
|
453
|
+
// The Alia app: its route owns the conversation, its sidebar reads the same list.
|
|
454
|
+
<GemieChatContent
|
|
455
|
+
surface // the container draws the page's card
|
|
456
|
+
conversationId={id}
|
|
457
|
+
threadHandle={handle} // an agent's thread: history above, search
|
|
458
|
+
model={powerLevel}
|
|
459
|
+
onModelChange={setPowerLevel} // the composer offers the levels
|
|
460
|
+
addMenu={{ groups, onSelect }} // the host's rows
|
|
461
|
+
chrome={(chat) => ({ header, title, project, actions: <Actions chat={chat} /> })}
|
|
462
|
+
renderUsageLimit={({ error, dismiss }) => <UsageLimitDialog error={error} onDismiss={dismiss} />}
|
|
463
|
+
/>
|
|
464
|
+
function Sidebar() {
|
|
465
|
+
const { data } = useConversations(); // the very query the thread keeps up to date
|
|
466
|
+
…
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Voice lives in the conversation
|
|
471
|
+
|
|
472
|
+
A call always has a home. With a conversation open the call lives in it; on a new-chat screen
|
|
473
|
+
the conversation is created when the call starts (after the plan/credits gate) and the call
|
|
474
|
+
opens on the screen that shows it. That is one code path for the sheet, `GemieChatScreen` and the
|
|
475
|
+
Alia app (`useVoiceLauncher`'s `resolveConversation` and `useVoiceCallRequests`):
|
|
476
|
+
|
|
477
|
+
- the sheet has no routes, so the chat itself switches to the new conversation and the call opens
|
|
478
|
+
in place;
|
|
479
|
+
- the Alia app's new-chat route is replaced by the conversation's (`host.openConversation`), and
|
|
480
|
+
the call opens on that screen, which takes the pending request.
|
|
481
|
+
|
|
482
|
+
**Who decides which conversation is open:** the host, when it navigates (it passes
|
|
483
|
+
`runtime.openConversation`, or an outer `GemieRuntimeProvider` has one); otherwise the chat.
|
|
484
|
+
|
|
485
|
+
## Which API the SDK calls
|
|
486
|
+
|
|
487
|
+
The SDK is Alia's product client and speaks **only to `/v1`**, the Gemies product API: a bearer of
|
|
488
|
+
the signed-in person's Oxy session, no cookies, and public CORS — so it works in the browser of
|
|
489
|
+
every Oxy app, on that app's own origin, with nothing to configure and no backend in between.
|
|
490
|
+
|
|
491
|
+
- A turn: `POST {apiUrl}/v1/chat/completions` — the same handler `/alia/chat` mounts, with every
|
|
492
|
+
`alia.*` stream event, `conversationId` and the stored history.
|
|
493
|
+
- Conversations: `{apiUrl}/v1/conversations` (list, open, create, save, rename, delete, clear,
|
|
494
|
+
vote). A person's session only: an application key or a bot secret is refused, because a
|
|
495
|
+
conversation is somebody's private history.
|
|
496
|
+
- Dictation, read-aloud and the voice call: `/v1/audio/*` and `/v1/voice/session`.
|
|
497
|
+
|
|
498
|
+
`apiUrl` defaults to `EXPO_PUBLIC_GEMIES_API_URL`, then `https://api.gemies.ai`. `routes.ts` holds
|
|
499
|
+
the paths, and `tests/runtime/v1-only.test.ts` fails if the transport builds a URL outside `/v1`.
|
|
500
|
+
The one exception is the agent routes (`AGENT_ROUTES`: an agent's thread and its runs), which only
|
|
501
|
+
Alia's own clients use.
|
|
502
|
+
|
|
503
|
+
`model` is a power level (`auto`, `instant`, `medium`, `high`, `xhigh`, `pro`, `ultra`) or an
|
|
504
|
+
exact `publisher/model`; it is sent as given, and omitted the server's default answers. The SDK
|
|
505
|
+
ships no model identifier of its own.
|
|
506
|
+
|
|
507
|
+
## Scripts
|
|
508
|
+
|
|
509
|
+
```sh
|
|
510
|
+
bun run typecheck # tsc --noEmit
|
|
511
|
+
bun run test # vitest
|
|
512
|
+
bun run check:entries # entry isolation; on web, no async chunk boundary but the ask entry's; no retired modules
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
## Licence
|
|
516
|
+
|
|
517
|
+
Apache-2.0. See `LICENSE` and `NOTICE`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,107 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gemies/sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "The Gemies SDK: the conversation runtime, chat UI, voice calls and dictation for Oxy apps that talk to a gemie",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"react-native": "src/index.ts",
|
|
7
|
+
"source": "src/index.ts",
|
|
8
|
+
"types": "src/index.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.ts",
|
|
11
|
+
"./accounts": "./src/accounts.ts",
|
|
12
|
+
"./ask": "./src/ask.ts",
|
|
13
|
+
"./ask/eager": "./src/ask-eager.ts",
|
|
14
|
+
"./ask/text": "./src/ask-text.ts",
|
|
15
|
+
"./avatar": "./src/avatar.ts",
|
|
16
|
+
"./character": "./src/character.ts",
|
|
17
|
+
"./content": "./src/lib/content-utils.ts",
|
|
18
|
+
"./csp": "./src/csp.ts",
|
|
19
|
+
"./dictation": "./src/dictation.ts",
|
|
20
|
+
"./model": "./src/runtime/model.ts",
|
|
21
|
+
"./metro": {
|
|
22
|
+
"types": "./src/metro/index.d.cts",
|
|
23
|
+
"default": "./src/metro/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./runtime": "./src/runtime/index.ts",
|
|
26
|
+
"./text": "./src/text.ts",
|
|
27
|
+
"./tools": "./src/tools.ts",
|
|
28
|
+
"./voice": "./src/voice.ts",
|
|
29
|
+
"./voice/messages": "./src/voice-messages.ts",
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"src",
|
|
34
|
+
"worklets",
|
|
35
|
+
"NOTICE",
|
|
36
|
+
"tsconfig.json",
|
|
37
|
+
"CHANGELOG.md"
|
|
38
|
+
],
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/OxyHQ/Gemies.git",
|
|
43
|
+
"directory": "packages/sdk"
|
|
44
|
+
},
|
|
45
|
+
"private": false,
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:metro": "node --test scripts/metro/opt-in.node.cjs",
|
|
53
|
+
"check:entries": "node scripts/check-entry-isolation.mjs",
|
|
54
|
+
"check:entry-types": "node scripts/check-entry-types.mjs"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"clsx": "^2.1.1",
|
|
58
|
+
"socket.io-client": "^4.8.3",
|
|
59
|
+
"tailwind-merge": "^3.7.0",
|
|
60
|
+
"zustand": "^5.0.15"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"react": "^19.2.3",
|
|
64
|
+
"react-native": "^0.86.0 || ^0.88.0",
|
|
65
|
+
"@expo/vector-icons": "^15.1.1",
|
|
66
|
+
"@oxy.so/bloom": ">=17.41.0",
|
|
67
|
+
"@oxy.so/core": ">=7.1.0 <8",
|
|
68
|
+
"@oxy.so/services": ">=14.19.1 <15",
|
|
69
|
+
"@tanstack/react-query": "^5.101",
|
|
70
|
+
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
71
|
+
"expo-blur": "^57.0.0 || ^58.0.0",
|
|
72
|
+
"react-native-reanimated": "^4.5.0",
|
|
73
|
+
"react-native-gesture-handler": "^2.32.0 || ^3.3.0",
|
|
74
|
+
"react-native-safe-area-context": "^5.8.0",
|
|
75
|
+
"react-native-keyboard-controller": "^1.21.9",
|
|
76
|
+
"react-native-svg": "^15.15.5",
|
|
77
|
+
"expo-audio": "^57.0.0 || ^58.0.0",
|
|
78
|
+
"expo-image": "^57.0.0 || ^58.0.0",
|
|
79
|
+
"expo-image-picker": "^57.0.2 || ^58.0.0",
|
|
80
|
+
"expo-document-picker": "^57.0.0 || ^58.0.0",
|
|
81
|
+
"expo-haptics": "^57.0.0 || ^58.0.0",
|
|
82
|
+
"nativewind": "^5.0.0-preview.3",
|
|
83
|
+
"expo-clipboard": "^57.0.0 || ^58.0.0",
|
|
84
|
+
"expo-file-system": "^57.0.0 || ^58.0.0",
|
|
85
|
+
"expo-web-browser": "^57.0.0 || ^58.0.0",
|
|
86
|
+
"react-native-css": "^3.0.7",
|
|
87
|
+
"react-native-audio-api": "^0.13.6",
|
|
88
|
+
"react-native-qrcode-svg": "^6.3.21"
|
|
89
|
+
},
|
|
90
|
+
"peerDependenciesMeta": {
|
|
91
|
+
"nativewind": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"expo-clipboard": {
|
|
95
|
+
"optional": true
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"devDependencies": {
|
|
99
|
+
"@types/react-test-renderer": "^19.1.0",
|
|
100
|
+
"metro-resolver": "0.87.1",
|
|
101
|
+
"react-native-audio-api": "0.13.6",
|
|
102
|
+
"react-native-qrcode-svg": "^6.3.21",
|
|
103
|
+
"react-test-renderer": "19.3.0",
|
|
104
|
+
"typescript": "^5.9.3",
|
|
105
|
+
"vitest": "^4.1.10"
|
|
106
|
+
}
|
|
107
|
+
}
|
package/src/accounts.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="nativewind/types" />
|
|
2
|
+
/**
|
|
3
|
+
* The connected-accounts leaf entry (ADR 0035): the WhatsApp and Telegram accounts a person links
|
|
4
|
+
* to a gemie, and the panel that manages them. Its own entry so an app that does not draw it never
|
|
5
|
+
* reaches its QR encoder.
|
|
6
|
+
*/
|
|
7
|
+
export { GemieAccounts } from './components/GemieAccounts';
|
|
8
|
+
export { ALIA_GEMIE_ID } from './lib/alia-gemie';
|
|
9
|
+
export type { GemieAccountsProps } from './components/GemieAccounts';
|
|
10
|
+
export {
|
|
11
|
+
GEMIE_ACCOUNT_GROUP_REPLIES,
|
|
12
|
+
GEMIE_ACCOUNT_PLATFORMS,
|
|
13
|
+
GEMIE_ACCOUNT_REPLIES,
|
|
14
|
+
GEMIE_ACCOUNT_STATUSES,
|
|
15
|
+
useGemieAccountChats,
|
|
16
|
+
useGemieAccountMutations,
|
|
17
|
+
useGemieAccountQr,
|
|
18
|
+
useGemieAccounts,
|
|
19
|
+
} from './runtime/gemie-accounts';
|
|
20
|
+
export type {
|
|
21
|
+
GemieAccount,
|
|
22
|
+
GemieAccountChat,
|
|
23
|
+
GemieAccountGroupReplies,
|
|
24
|
+
GemieAccountLink,
|
|
25
|
+
GemieAccountPlatform,
|
|
26
|
+
GemieAccountReplies,
|
|
27
|
+
GemieAccountsAnswer,
|
|
28
|
+
GemieAccountStatus,
|
|
29
|
+
} from './runtime/gemie-accounts';
|