@gemies/sdk 0.0.0-stage → 1.0.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 +1662 -0
- package/LICENSE +202 -0
- package/NOTICE +15 -0
- package/README.md +516 -2
- package/package.json +102 -4
- 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/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 +140 -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/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 +291 -0
- package/src/lib/copy-es.ts +287 -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/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 +49 -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 +81 -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
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ButtonGroup, ButtonGroupItem } from '@oxy.so/bloom/button-group';
|
|
2
|
+
import {
|
|
3
|
+
DropdownMenu,
|
|
4
|
+
DropdownMenuContent,
|
|
5
|
+
DropdownMenuItem,
|
|
6
|
+
DropdownMenuTrigger,
|
|
7
|
+
} from '@oxy.so/bloom/dropdown-menu';
|
|
8
|
+
import { RiArrowLeftLine } from '@oxy.so/bloom/icons/RiArrowLeftLine';
|
|
9
|
+
import { RiDeleteBin6Line } from '@oxy.so/bloom/icons/RiDeleteBin6Line';
|
|
10
|
+
import { RiMoreFill } from '@oxy.so/bloom/icons/RiMoreFill';
|
|
11
|
+
import { RiShare2Line } from '@oxy.so/bloom/icons/RiShare2Line';
|
|
12
|
+
import { PageHeader } from '@oxy.so/bloom/page-header';
|
|
13
|
+
import { memo, type ReactNode } from 'react';
|
|
14
|
+
import { useLabels } from '../lib/labels';
|
|
15
|
+
import type { GemieChatParticipants } from '../lib/participants';
|
|
16
|
+
import { GemieParticipants } from './GemieParticipants';
|
|
17
|
+
|
|
18
|
+
export interface GemieChatHeaderProps {
|
|
19
|
+
/** The chat has messages: there is something to share and to clear. */
|
|
20
|
+
hasMessages: boolean;
|
|
21
|
+
/** Who is in the conversation (`GemieChatState.participants`): the bar's title. */
|
|
22
|
+
participants: GemieChatParticipants;
|
|
23
|
+
/** Clears the conversation, from the menu. */
|
|
24
|
+
onClear: () => void;
|
|
25
|
+
/** Draws the back button at the start of the bar; omit where there is nowhere to go back to. */
|
|
26
|
+
onBack?: () => void;
|
|
27
|
+
/** Draws the share button, once there is a conversation; omit where the host cannot share. */
|
|
28
|
+
onShare?: () => void;
|
|
29
|
+
/** More rows for the menu (`DropdownMenuItem`s), before Clear. */
|
|
30
|
+
menu?: ReactNode;
|
|
31
|
+
/** The host's own start content instead of the back button, e.g. a navigation drawer's menu. */
|
|
32
|
+
leading?: ReactNode;
|
|
33
|
+
/** The host's own actions, before share and the menu. */
|
|
34
|
+
trailing?: ReactNode;
|
|
35
|
+
/** Pressing the participants. Omitted, every avatar in it waves. */
|
|
36
|
+
onProfilePress?: () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The chat's top bar: Bloom's `PageHeader`, set up as the shell sets it up for the
|
|
41
|
+
* agents' screens (inline, no scrim, no safe area). The participants are its title only once
|
|
42
|
+
* there is a conversation: the empty chat already shows the lead's avatar beside its greeting,
|
|
43
|
+
* so the bar carries just its buttons until then.
|
|
44
|
+
*/
|
|
45
|
+
export const GemieChatHeader = memo(function GemieChatHeader({
|
|
46
|
+
hasMessages,
|
|
47
|
+
participants,
|
|
48
|
+
onClear,
|
|
49
|
+
onBack,
|
|
50
|
+
onShare,
|
|
51
|
+
menu,
|
|
52
|
+
leading,
|
|
53
|
+
trailing,
|
|
54
|
+
onProfilePress,
|
|
55
|
+
}: GemieChatHeaderProps) {
|
|
56
|
+
const labels = useLabels();
|
|
57
|
+
// Share and the menu act on a conversation. With none there is nothing for them to do, and a
|
|
58
|
+
// bar of dimmed buttons over the empty chat is chrome with no job: no bar at all, unless the
|
|
59
|
+
// host brought content of its own (a back button to somewhere, a drawer's menu).
|
|
60
|
+
if (!hasMessages && !onBack && leading === undefined && trailing === undefined) return null;
|
|
61
|
+
return (
|
|
62
|
+
<PageHeader
|
|
63
|
+
leading={
|
|
64
|
+
leading ??
|
|
65
|
+
(onBack ? (
|
|
66
|
+
<ButtonGroup accessibilityLabel={labels.chatActions}>
|
|
67
|
+
<ButtonGroupItem
|
|
68
|
+
iconOnly
|
|
69
|
+
leadingIcon={RiArrowLeftLine}
|
|
70
|
+
accessibilityLabel={labels.back}
|
|
71
|
+
onPress={onBack}
|
|
72
|
+
/>
|
|
73
|
+
</ButtonGroup>
|
|
74
|
+
) : undefined)
|
|
75
|
+
}
|
|
76
|
+
title={
|
|
77
|
+
hasMessages ? (
|
|
78
|
+
<GemieParticipants participants={participants} onPress={onProfilePress} />
|
|
79
|
+
) : undefined
|
|
80
|
+
}
|
|
81
|
+
titleAlign="center"
|
|
82
|
+
actions={
|
|
83
|
+
<>
|
|
84
|
+
{trailing}
|
|
85
|
+
{hasMessages ? (
|
|
86
|
+
<ButtonGroup accessibilityLabel={labels.chatActions}>
|
|
87
|
+
{onShare ? (
|
|
88
|
+
<ButtonGroupItem
|
|
89
|
+
iconOnly
|
|
90
|
+
leadingIcon={RiShare2Line}
|
|
91
|
+
accessibilityLabel={labels.share}
|
|
92
|
+
onPress={onShare}
|
|
93
|
+
/>
|
|
94
|
+
) : null}
|
|
95
|
+
<DropdownMenu>
|
|
96
|
+
<DropdownMenuTrigger asChild label={labels.more}>
|
|
97
|
+
<ButtonGroupItem
|
|
98
|
+
iconOnly
|
|
99
|
+
leadingIcon={RiMoreFill}
|
|
100
|
+
accessibilityLabel={labels.more}
|
|
101
|
+
/>
|
|
102
|
+
</DropdownMenuTrigger>
|
|
103
|
+
<DropdownMenuContent align="end">
|
|
104
|
+
{menu}
|
|
105
|
+
<DropdownMenuItem
|
|
106
|
+
tone="danger"
|
|
107
|
+
leading={<RiDeleteBin6Line width={16} height={16} />}
|
|
108
|
+
onPress={onClear}
|
|
109
|
+
>
|
|
110
|
+
{labels.clear}
|
|
111
|
+
</DropdownMenuItem>
|
|
112
|
+
</DropdownMenuContent>
|
|
113
|
+
</DropdownMenu>
|
|
114
|
+
</ButtonGroup>
|
|
115
|
+
) : null}
|
|
116
|
+
</>
|
|
117
|
+
}
|
|
118
|
+
scrim="none"
|
|
119
|
+
sticky={false}
|
|
120
|
+
safeArea={false}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
});
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full-screen Alia chat component for use as a route/screen in Oxy ecosystem apps.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* ```tsx
|
|
6
|
+
* import { GemieChatScreen } from '@gemies/sdk';
|
|
7
|
+
*
|
|
8
|
+
* <GemieChatScreen
|
|
9
|
+
* clientContext="Notes app — user is viewing note #42"
|
|
10
|
+
* suggestions={[{ label: 'Summarize', prompt: 'Summarize this note' }]}
|
|
11
|
+
* headerLeft={<BackButton />}
|
|
12
|
+
* />
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Voice is part of the screen: the button, the call bar, the notices and the transcript in the
|
|
16
|
+
* thread. `voice={false}` makes it text-only; `voice={{ canStartVoice, onCallEnded, … }}` brings
|
|
17
|
+
* the host's own callbacks. The call loads on the first one.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { AgentAvatarProvider } from '@oxy.so/bloom/agent-avatar';
|
|
21
|
+
import type React from 'react';
|
|
22
|
+
import { useCallback } from 'react';
|
|
23
|
+
import { View } from 'react-native';
|
|
24
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
25
|
+
import { KeyboardAvoidingView } from '../lib/keyboard';
|
|
26
|
+
import {
|
|
27
|
+
type GemieChatAgentRef,
|
|
28
|
+
GemieChatContent,
|
|
29
|
+
type GemieChatContentProps,
|
|
30
|
+
} from './GemieChatContent';
|
|
31
|
+
import { GemieChatHeader } from './GemieChatHeader';
|
|
32
|
+
import type { GemieSuggestion } from '../types';
|
|
33
|
+
import type { GemieChatLabels } from '../lib/labels';
|
|
34
|
+
import type { GemieToolRenderers } from '../lib/tool-renderers';
|
|
35
|
+
import { useShareHandler } from '../hooks/useShareHandler';
|
|
36
|
+
import type { GemieHostTools } from '../runtime/host-tools';
|
|
37
|
+
import type { GemieConversationShare } from '../runtime/sharing';
|
|
38
|
+
|
|
39
|
+
export interface GemieChatScreenProps {
|
|
40
|
+
/** The agent the screen is with, any agent the person can reach; omitted, Alia. */
|
|
41
|
+
agent?: GemieChatAgentRef;
|
|
42
|
+
/** App context injected into system prompt */
|
|
43
|
+
clientContext?: string;
|
|
44
|
+
/** The Oxy app this chat is embedded in, by its slug (see `GemieChatContentProps.app`). */
|
|
45
|
+
app?: string;
|
|
46
|
+
/** The UI effects this app performs for the lead (see `GemieChatContentProps.hostTools`). */
|
|
47
|
+
hostTools?: GemieHostTools;
|
|
48
|
+
/** The app's own drawing of catalogue tools' results, keyed `<app>:<tool>`. */
|
|
49
|
+
toolRenderers?: GemieToolRenderers;
|
|
50
|
+
/** The lead's feature gate refused something: show the app's upsell for `key`. */
|
|
51
|
+
onFeatureLocked?: (key: string) => void;
|
|
52
|
+
/** The power level (`auto`, `instant`, `medium`, `high`, `xhigh`, `pro`, `ultra`) or an exact `publisher/model` every turn is sent with; omitted, the server picks. */
|
|
53
|
+
model?: string;
|
|
54
|
+
/** API URL override */
|
|
55
|
+
apiUrl?: string;
|
|
56
|
+
/** Draws the header's back button; omit where there is nowhere to go back to. */
|
|
57
|
+
onBack?: () => void;
|
|
58
|
+
/** Optional header left content instead of the back button (e.g. a drawer's menu button) */
|
|
59
|
+
headerLeft?: React.ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* Draws the header's share button once there is a conversation; omitted, no share button.
|
|
62
|
+
* Pressed, the conversation's read-only link is minted and handed here for the app to show.
|
|
63
|
+
*/
|
|
64
|
+
onShare?: (share: GemieConversationShare) => void;
|
|
65
|
+
/** More rows for the header's menu (`DropdownMenuItem`s from `@oxy.so/bloom/dropdown-menu`). */
|
|
66
|
+
headerMenu?: React.ReactNode;
|
|
67
|
+
/** Optional header right action (e.g., settings button) */
|
|
68
|
+
headerRight?: React.ReactNode;
|
|
69
|
+
/** Welcome screen greeting */
|
|
70
|
+
welcomeGreeting?: string;
|
|
71
|
+
/** Welcome screen subtitle */
|
|
72
|
+
welcomeSubtitle?: string;
|
|
73
|
+
/** Welcome screen suggestions */
|
|
74
|
+
welcomeSuggestions?: GemieSuggestion[];
|
|
75
|
+
/** What the host found for the typed text, shown over the composer (see `onSuggestionQuery`). */
|
|
76
|
+
suggestionMatches?: GemieSuggestion[];
|
|
77
|
+
/** The typed text, once typing has settled, for the host to search suggestions with. */
|
|
78
|
+
onSuggestionQuery?: (query: string) => void;
|
|
79
|
+
/** Dark-mode flag — forwarded to the ambient wave overlay. */
|
|
80
|
+
isDarkMode?: boolean;
|
|
81
|
+
/** The chat's voice call: on by default, `false` for text only, an object for the host's callbacks. */
|
|
82
|
+
voice?: GemieChatContentProps['voice'];
|
|
83
|
+
/** Overrides for the chat's own copy (header, composer, plan, research…); omitted, English. */
|
|
84
|
+
labels?: Partial<GemieChatLabels>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function GemieChatScreen({
|
|
88
|
+
agent,
|
|
89
|
+
app,
|
|
90
|
+
clientContext,
|
|
91
|
+
hostTools,
|
|
92
|
+
toolRenderers,
|
|
93
|
+
onFeatureLocked,
|
|
94
|
+
model,
|
|
95
|
+
apiUrl,
|
|
96
|
+
onBack,
|
|
97
|
+
headerLeft,
|
|
98
|
+
onShare,
|
|
99
|
+
headerMenu,
|
|
100
|
+
headerRight,
|
|
101
|
+
welcomeGreeting,
|
|
102
|
+
welcomeSubtitle,
|
|
103
|
+
welcomeSuggestions,
|
|
104
|
+
suggestionMatches,
|
|
105
|
+
onSuggestionQuery,
|
|
106
|
+
isDarkMode,
|
|
107
|
+
voice,
|
|
108
|
+
labels,
|
|
109
|
+
}: GemieChatScreenProps) {
|
|
110
|
+
const insets = useSafeAreaInsets();
|
|
111
|
+
// The screen owns the whole window, so it keeps its composer out of both
|
|
112
|
+
// system bars: the top inset clears the status bar, the bottom one the
|
|
113
|
+
// gesture bar or home indicator an edge-to-edge app draws over.
|
|
114
|
+
//
|
|
115
|
+
// The keyboard is handled INSIDE the bottom inset. The avoiding view measures
|
|
116
|
+
// its own frame in the window (`automaticOffset`), and that frame already
|
|
117
|
+
// ends `insets.bottom` above the window's edge, so the padding it adds is the
|
|
118
|
+
// keyboard's height minus the inset: the composer sits on the keyboard, not
|
|
119
|
+
// one inset above it. (Its parent-relative layout would read as zero overlap
|
|
120
|
+
// this deep in a host's tree, which is why the offset is measured.)
|
|
121
|
+
const share = useShareHandler(onShare);
|
|
122
|
+
const chrome = useCallback<NonNullable<GemieChatContentProps['chrome']>>(
|
|
123
|
+
({ hasMessages, startOver, participants, conversationId }) => ({
|
|
124
|
+
header: (
|
|
125
|
+
<GemieChatHeader
|
|
126
|
+
hasMessages={hasMessages}
|
|
127
|
+
participants={participants}
|
|
128
|
+
onClear={startOver}
|
|
129
|
+
onBack={onBack}
|
|
130
|
+
onShare={share && conversationId !== undefined ? () => share(conversationId) : undefined}
|
|
131
|
+
menu={headerMenu}
|
|
132
|
+
leading={headerLeft}
|
|
133
|
+
trailing={headerRight}
|
|
134
|
+
/>
|
|
135
|
+
),
|
|
136
|
+
}),
|
|
137
|
+
[onBack, share, headerMenu, headerLeft, headerRight],
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<AgentAvatarProvider>
|
|
142
|
+
<View
|
|
143
|
+
className="flex-1 bg-background-full"
|
|
144
|
+
style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}
|
|
145
|
+
>
|
|
146
|
+
<KeyboardAvoidingView behavior="padding" automaticOffset style={{ flex: 1 }}>
|
|
147
|
+
<GemieChatContent
|
|
148
|
+
agent={agent}
|
|
149
|
+
app={app}
|
|
150
|
+
clientContext={clientContext}
|
|
151
|
+
hostTools={hostTools}
|
|
152
|
+
toolRenderers={toolRenderers}
|
|
153
|
+
onFeatureLocked={onFeatureLocked}
|
|
154
|
+
model={model}
|
|
155
|
+
apiUrl={apiUrl}
|
|
156
|
+
welcomeGreeting={welcomeGreeting}
|
|
157
|
+
welcomeSubtitle={welcomeSubtitle}
|
|
158
|
+
welcomeSuggestions={welcomeSuggestions}
|
|
159
|
+
suggestionMatches={suggestionMatches}
|
|
160
|
+
onSuggestionQuery={onSuggestionQuery}
|
|
161
|
+
isDarkMode={isDarkMode}
|
|
162
|
+
voice={voice}
|
|
163
|
+
labels={labels}
|
|
164
|
+
chrome={chrome}
|
|
165
|
+
/>
|
|
166
|
+
</KeyboardAvoidingView>
|
|
167
|
+
</View>
|
|
168
|
+
</AgentAvatarProvider>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { AvatarFlightLayer, useAvatarFlights } from '@oxy.so/bloom/avatar-flight';
|
|
2
|
+
import { AgentAvatarProvider } from '@oxy.so/bloom/agent-avatar';
|
|
3
|
+
import { BottomSheet, type BottomSheetRef } from '@oxy.so/bloom/bottom-sheet';
|
|
4
|
+
import {
|
|
5
|
+
forwardRef,
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import { useTheme } from '@oxy.so/bloom/theme';
|
|
14
|
+
import { useWindowDimensions, View } from 'react-native';
|
|
15
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
16
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
17
|
+
import { BREAKPOINTS } from '@oxy.so/bloom/styles';
|
|
18
|
+
import { GemieChatLabelsProvider, type GemieChatLabels } from '../lib/labels';
|
|
19
|
+
import type { GemieToolRenderers } from '../lib/tool-renderers';
|
|
20
|
+
import { useShareHandler } from '../hooks/useShareHandler';
|
|
21
|
+
import type { GemieRuntimeHost } from '../runtime/config';
|
|
22
|
+
import type { GemieHostTools } from '../runtime/host-tools';
|
|
23
|
+
import type { GemieConversationShare } from '../runtime/sharing';
|
|
24
|
+
import { useThoughtStore } from '../runtime/thought-store';
|
|
25
|
+
import type { GemieTurn } from '../hooks/useChatComposer';
|
|
26
|
+
import {
|
|
27
|
+
type GemieChatAgentRef,
|
|
28
|
+
GemieChatContent,
|
|
29
|
+
type GemieChatContentProps,
|
|
30
|
+
} from './GemieChatContent';
|
|
31
|
+
import { GemieChatHeader } from './GemieChatHeader';
|
|
32
|
+
import { GemieRecentConversations } from './GemieRecentConversations';
|
|
33
|
+
import { ThoughtPanel } from './thought/ThoughtPanel';
|
|
34
|
+
import type { GemieSuggestion } from '../types';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* TODO(bloom): drop this once Bloom's sheet is rounder by default. Its detached
|
|
38
|
+
* sheet hardcodes `radius: 24` (`BottomSheetBase.tsx`, not a design token) and
|
|
39
|
+
* the web fork draws a plain `border-radius`, so 24 reads squarer than the
|
|
40
|
+
* native `smooth` curve it is meant to match. Remove `SHEET_RADIUS` and the
|
|
41
|
+
* `borderRadius` in `style` below when that lands.
|
|
42
|
+
*/
|
|
43
|
+
const SHEET_RADIUS = 40;
|
|
44
|
+
|
|
45
|
+
/** How much of the screen's height the sheet of a turn's work takes. */
|
|
46
|
+
const THOUGHT_SHEET_HEIGHT = 0.7;
|
|
47
|
+
|
|
48
|
+
/** The sheet floats (detached) from tablet width up; on a phone it is flush with the screen edges. */
|
|
49
|
+
const DETACHED_FROM = BREAKPOINTS.md;
|
|
50
|
+
|
|
51
|
+
export interface GemieChatSheetProps {
|
|
52
|
+
/** The agent the sheet opens on, any agent the person can reach; omitted, Alia. */
|
|
53
|
+
agent?: GemieChatAgentRef;
|
|
54
|
+
/** App context injected into system prompt */
|
|
55
|
+
clientContext?: string;
|
|
56
|
+
/** The Oxy app this chat is embedded in, by its slug (see `GemieChatContentProps.app`). */
|
|
57
|
+
app?: string;
|
|
58
|
+
/** The UI effects this app performs for the lead (see `GemieChatContentProps.hostTools`). */
|
|
59
|
+
hostTools?: GemieHostTools;
|
|
60
|
+
/** The app's own drawing of catalogue tools' results, keyed `<app>:<tool>`. */
|
|
61
|
+
toolRenderers?: GemieToolRenderers;
|
|
62
|
+
/** The lead's feature gate refused something: show the app's upsell for `key`. */
|
|
63
|
+
onFeatureLocked?: (key: string) => void;
|
|
64
|
+
/** The power level (`auto`, `instant`, `medium`, `high`, `xhigh`, `pro`, `ultra`) or an exact `publisher/model` every turn is sent with; omitted, the server picks. */
|
|
65
|
+
model?: string;
|
|
66
|
+
/** API URL override */
|
|
67
|
+
apiUrl?: string;
|
|
68
|
+
/** Welcome screen greeting */
|
|
69
|
+
welcomeGreeting?: string;
|
|
70
|
+
/** Welcome screen subtitle */
|
|
71
|
+
welcomeSubtitle?: string;
|
|
72
|
+
/** Welcome screen suggestions */
|
|
73
|
+
welcomeSuggestions?: GemieSuggestion[];
|
|
74
|
+
/** What the host found for the typed text, shown over the composer (see `onSuggestionQuery`). */
|
|
75
|
+
suggestionMatches?: GemieSuggestion[];
|
|
76
|
+
/** The typed text, once typing has settled, for the host to search suggestions with. */
|
|
77
|
+
onSuggestionQuery?: (query: string) => void;
|
|
78
|
+
/** Dark-mode flag — forwarded to the ambient wave overlay (defaults to the sheet's own color scheme). */
|
|
79
|
+
isDarkMode?: boolean;
|
|
80
|
+
/** The chat's voice call: on by default, `false` for text only, an object for the host's callbacks. */
|
|
81
|
+
voice?: GemieChatContentProps['voice'];
|
|
82
|
+
/** Overrides for the chat's own copy (header, composer, plan, research…); omitted, English. */
|
|
83
|
+
labels?: Partial<GemieChatLabels>;
|
|
84
|
+
/**
|
|
85
|
+
* Draws the header's share button once there is a conversation; omitted, no share button.
|
|
86
|
+
* Pressed, the conversation's read-only link is minted and handed here for the app to show.
|
|
87
|
+
*/
|
|
88
|
+
onShare?: (share: GemieConversationShare) => void;
|
|
89
|
+
/** More rows for the header's menu (`DropdownMenuItem`s from `@oxy.so/bloom/dropdown-menu`). */
|
|
90
|
+
headerMenu?: React.ReactNode;
|
|
91
|
+
/** The person's latest conversations with the lead, under the greeting. Default `true`. */
|
|
92
|
+
recentConversations?: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface GemieChatSheetRef {
|
|
96
|
+
/**
|
|
97
|
+
* Opens the sheet. Given a `turn`, the conversation opens over it with that message already
|
|
98
|
+
* sent (an "ask Alia about this" button: a profile, a post, a file); without one, the sheet
|
|
99
|
+
* opens on its welcome, with the composer focused.
|
|
100
|
+
*/
|
|
101
|
+
present: (turn?: GemieTurn) => void;
|
|
102
|
+
/** Opens the sheet on a stored conversation with its lead, where the person left it. */
|
|
103
|
+
resume: (conversationId: string) => void;
|
|
104
|
+
/** Closes the sheet and what is stacked on it, stopping a turn still being written. */
|
|
105
|
+
dismiss: () => void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const GemieChatSheet = forwardRef<GemieChatSheetRef, GemieChatSheetProps>(
|
|
109
|
+
function GemieChatSheet(props, ref) {
|
|
110
|
+
return (
|
|
111
|
+
<GemieChatLabelsProvider labels={props.labels}>
|
|
112
|
+
<GemieChatSheetBody {...props} ref={ref} />
|
|
113
|
+
</GemieChatLabelsProvider>
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const GemieChatSheetBody = forwardRef<GemieChatSheetRef, GemieChatSheetProps>(
|
|
119
|
+
(
|
|
120
|
+
{
|
|
121
|
+
agent,
|
|
122
|
+
app,
|
|
123
|
+
clientContext,
|
|
124
|
+
hostTools,
|
|
125
|
+
toolRenderers,
|
|
126
|
+
onFeatureLocked,
|
|
127
|
+
model,
|
|
128
|
+
apiUrl,
|
|
129
|
+
welcomeGreeting,
|
|
130
|
+
welcomeSubtitle,
|
|
131
|
+
welcomeSuggestions,
|
|
132
|
+
suggestionMatches,
|
|
133
|
+
onSuggestionQuery,
|
|
134
|
+
isDarkMode,
|
|
135
|
+
voice,
|
|
136
|
+
labels,
|
|
137
|
+
onShare,
|
|
138
|
+
headerMenu,
|
|
139
|
+
recentConversations = true,
|
|
140
|
+
},
|
|
141
|
+
ref,
|
|
142
|
+
) => {
|
|
143
|
+
// Bloom's resolved mode, not the system's scheme.
|
|
144
|
+
const { isDark } = useTheme();
|
|
145
|
+
// How far each sheet is presented (0 closed, 1 up): its chat takes the composer's focus at 1.
|
|
146
|
+
const mainProgress = useSharedValue(0);
|
|
147
|
+
const conversationProgress = useSharedValue(0);
|
|
148
|
+
const mainRef = useRef<BottomSheetRef>(null);
|
|
149
|
+
const conversationRef = useRef<BottomSheetRef>(null);
|
|
150
|
+
// Closing detaches this sheet's reader; only its explicit Stop cancels the generation.
|
|
151
|
+
const mainDetachRef = useRef<(() => void) | null>(null);
|
|
152
|
+
const conversationDetachRef = useRef<(() => void) | null>(null);
|
|
153
|
+
|
|
154
|
+
// The conversation sheet, stacked over the main one while a chat is open: begun by a first
|
|
155
|
+
// turn, or a stored one picked up again. The key makes every opening a fresh chat.
|
|
156
|
+
const [conversation, setConversation] = useState<{
|
|
157
|
+
key: number;
|
|
158
|
+
turn?: GemieTurn;
|
|
159
|
+
conversationId?: string;
|
|
160
|
+
} | null>(null);
|
|
161
|
+
|
|
162
|
+
const registerMainDetach = useCallback((stop: (() => void) | null) => {
|
|
163
|
+
mainDetachRef.current = stop;
|
|
164
|
+
}, []);
|
|
165
|
+
const registerConversationDetach = useCallback((stop: (() => void) | null) => {
|
|
166
|
+
conversationDetachRef.current = stop;
|
|
167
|
+
}, []);
|
|
168
|
+
|
|
169
|
+
const startConversation = useCallback((turn: GemieTurn) => {
|
|
170
|
+
setConversation((current) => ({ key: (current?.key ?? 0) + 1, turn }));
|
|
171
|
+
}, []);
|
|
172
|
+
const resumeConversation = useCallback((conversationId: string) => {
|
|
173
|
+
setConversation((current) => ({ key: (current?.key ?? 0) + 1, conversationId }));
|
|
174
|
+
}, []);
|
|
175
|
+
// The chat inside follows its conversation (a first turn creates it, "start over" leaves it).
|
|
176
|
+
const followConversation = useCallback((conversationId: string | undefined) => {
|
|
177
|
+
setConversation((current) => (current ? { ...current, conversationId } : current));
|
|
178
|
+
}, []);
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
if (conversation) conversationRef.current?.present();
|
|
181
|
+
}, [conversation]);
|
|
182
|
+
|
|
183
|
+
// Back, and the menu's Clear: close the conversation, back to the main screen underneath.
|
|
184
|
+
const closeConversation = useCallback(() => {
|
|
185
|
+
conversationDetachRef.current?.();
|
|
186
|
+
conversationRef.current?.dismiss();
|
|
187
|
+
}, []);
|
|
188
|
+
const onConversationDismissAttempt = useCallback(() => {
|
|
189
|
+
conversationDetachRef.current?.();
|
|
190
|
+
return true;
|
|
191
|
+
}, []);
|
|
192
|
+
|
|
193
|
+
// What a turn did — its steps, its sources, its reasoning — opens in a sheet over the
|
|
194
|
+
// conversation when the reader asks for it. A turn that begins using tools does not open one by
|
|
195
|
+
// itself: on a phone that would cover the answer being written.
|
|
196
|
+
const thoughtRef = useRef<BottomSheetRef>(null);
|
|
197
|
+
const closeThought = useCallback(() => {
|
|
198
|
+
useThoughtStore.getState().close();
|
|
199
|
+
thoughtRef.current?.dismiss();
|
|
200
|
+
}, []);
|
|
201
|
+
const runtime = useMemo<GemieRuntimeHost>(
|
|
202
|
+
() => ({
|
|
203
|
+
showThought: (opening) => {
|
|
204
|
+
if (opening === 'automatic') return false;
|
|
205
|
+
thoughtRef.current?.present();
|
|
206
|
+
return true;
|
|
207
|
+
},
|
|
208
|
+
}),
|
|
209
|
+
[],
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
const handleDismiss = useCallback(() => {
|
|
213
|
+
conversationDetachRef.current?.();
|
|
214
|
+
mainDetachRef.current?.();
|
|
215
|
+
conversationRef.current?.dismiss();
|
|
216
|
+
mainRef.current?.dismiss();
|
|
217
|
+
closeThought();
|
|
218
|
+
}, [closeThought]);
|
|
219
|
+
|
|
220
|
+
useImperativeHandle(
|
|
221
|
+
ref,
|
|
222
|
+
() => ({
|
|
223
|
+
present: (turn) => {
|
|
224
|
+
mainRef.current?.present();
|
|
225
|
+
if (turn) startConversation(turn);
|
|
226
|
+
},
|
|
227
|
+
resume: (conversationId) => {
|
|
228
|
+
mainRef.current?.present();
|
|
229
|
+
resumeConversation(conversationId);
|
|
230
|
+
},
|
|
231
|
+
dismiss: handleDismiss,
|
|
232
|
+
}),
|
|
233
|
+
[handleDismiss, startConversation, resumeConversation],
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
// Closing the main sheet (a drag, backdrop press, Back or Escape) closes what is stacked on it.
|
|
237
|
+
const onMainDismissAttempt = useCallback(() => {
|
|
238
|
+
mainDetachRef.current?.();
|
|
239
|
+
conversationDetachRef.current?.();
|
|
240
|
+
conversationRef.current?.dismiss();
|
|
241
|
+
closeThought();
|
|
242
|
+
return true;
|
|
243
|
+
}, [closeThought]);
|
|
244
|
+
|
|
245
|
+
const { width, height } = useWindowDimensions();
|
|
246
|
+
const detached = width >= DETACHED_FROM;
|
|
247
|
+
// Flush with the screen edge the sheet runs behind the home indicator: the composer clears it.
|
|
248
|
+
const { bottom } = useSafeAreaInsets();
|
|
249
|
+
const sheetStyle = detached
|
|
250
|
+
? { maxWidth: 600, alignSelf: 'center' as const, borderRadius: SHEET_RADIUS }
|
|
251
|
+
: undefined;
|
|
252
|
+
|
|
253
|
+
// The avatars fly between the two sheets: one controller, one layer.
|
|
254
|
+
const flights = useAvatarFlights();
|
|
255
|
+
// The conversation's bar: back to the main screen, the participants, share and the menu.
|
|
256
|
+
const share = useShareHandler(onShare);
|
|
257
|
+
const conversationChrome = useCallback<NonNullable<GemieChatContentProps['chrome']>>(
|
|
258
|
+
({ participants, conversationId }) => ({
|
|
259
|
+
header: (
|
|
260
|
+
<View className="pt-8">
|
|
261
|
+
<GemieChatHeader
|
|
262
|
+
participants={participants}
|
|
263
|
+
hasMessages
|
|
264
|
+
onClear={closeConversation}
|
|
265
|
+
onBack={closeConversation}
|
|
266
|
+
onShare={
|
|
267
|
+
share && conversationId !== undefined ? () => share(conversationId) : undefined
|
|
268
|
+
}
|
|
269
|
+
menu={headerMenu}
|
|
270
|
+
/>
|
|
271
|
+
</View>
|
|
272
|
+
),
|
|
273
|
+
}),
|
|
274
|
+
[closeConversation, share, headerMenu],
|
|
275
|
+
);
|
|
276
|
+
const shared = {
|
|
277
|
+
flights,
|
|
278
|
+
layout: 'sheet' as const,
|
|
279
|
+
agent,
|
|
280
|
+
app,
|
|
281
|
+
clientContext,
|
|
282
|
+
hostTools,
|
|
283
|
+
toolRenderers,
|
|
284
|
+
onFeatureLocked,
|
|
285
|
+
model,
|
|
286
|
+
apiUrl,
|
|
287
|
+
isDarkMode: isDarkMode ?? isDark,
|
|
288
|
+
voice,
|
|
289
|
+
runtime,
|
|
290
|
+
bottomInset: detached ? 0 : bottom,
|
|
291
|
+
labels,
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
// The provider wraps the sheets AND the flight layer: both draw avatars, and Bloom's avatars
|
|
295
|
+
// share one capability map only under the same provider.
|
|
296
|
+
return (
|
|
297
|
+
<AgentAvatarProvider>
|
|
298
|
+
<BottomSheet
|
|
299
|
+
ref={mainRef}
|
|
300
|
+
detached={detached}
|
|
301
|
+
scrollable={false}
|
|
302
|
+
manualActivation
|
|
303
|
+
animatedProgress={mainProgress}
|
|
304
|
+
onDismissAttempt={onMainDismissAttempt}
|
|
305
|
+
onDismiss={() => setConversation(null)}
|
|
306
|
+
style={sheetStyle}
|
|
307
|
+
>
|
|
308
|
+
{/* The main screen: the greeting, the suggestions and the composer. A first turn opens
|
|
309
|
+
the conversation in its own sheet over this one, so this chat stays empty. */}
|
|
310
|
+
<GemieChatContent
|
|
311
|
+
{...shared}
|
|
312
|
+
welcomeGreeting={welcomeGreeting}
|
|
313
|
+
welcomeSubtitle={welcomeSubtitle}
|
|
314
|
+
welcomeSuggestions={welcomeSuggestions}
|
|
315
|
+
suggestionMatches={suggestionMatches}
|
|
316
|
+
onSuggestionQuery={onSuggestionQuery}
|
|
317
|
+
welcomeAccessory={
|
|
318
|
+
recentConversations ? (
|
|
319
|
+
<GemieRecentConversations agentId={agent?.id} onOpen={resumeConversation} />
|
|
320
|
+
) : undefined
|
|
321
|
+
}
|
|
322
|
+
presentedProgress={mainProgress}
|
|
323
|
+
onDetachReady={registerMainDetach}
|
|
324
|
+
onStart={startConversation}
|
|
325
|
+
/>
|
|
326
|
+
</BottomSheet>
|
|
327
|
+
|
|
328
|
+
{conversation ? (
|
|
329
|
+
<BottomSheet
|
|
330
|
+
key={conversation.key}
|
|
331
|
+
ref={conversationRef}
|
|
332
|
+
detached={detached}
|
|
333
|
+
scrollable={false}
|
|
334
|
+
manualActivation
|
|
335
|
+
animatedProgress={conversationProgress}
|
|
336
|
+
onDismissAttempt={onConversationDismissAttempt}
|
|
337
|
+
onDismiss={() => setConversation(null)}
|
|
338
|
+
style={sheetStyle}
|
|
339
|
+
>
|
|
340
|
+
<GemieChatContent
|
|
341
|
+
{...shared}
|
|
342
|
+
initialTurn={conversation.turn}
|
|
343
|
+
conversationId={conversation.conversationId}
|
|
344
|
+
onConversationChange={followConversation}
|
|
345
|
+
presentedProgress={conversationProgress}
|
|
346
|
+
onDetachReady={registerConversationDetach}
|
|
347
|
+
chrome={conversationChrome}
|
|
348
|
+
/>
|
|
349
|
+
</BottomSheet>
|
|
350
|
+
) : null}
|
|
351
|
+
<BottomSheet
|
|
352
|
+
ref={thoughtRef}
|
|
353
|
+
detached={detached}
|
|
354
|
+
scrollable={false}
|
|
355
|
+
onDismiss={() => useThoughtStore.getState().close()}
|
|
356
|
+
style={sheetStyle}
|
|
357
|
+
>
|
|
358
|
+
<View style={{ height: height * THOUGHT_SHEET_HEIGHT }}>
|
|
359
|
+
<ThoughtPanel onClose={closeThought} />
|
|
360
|
+
</View>
|
|
361
|
+
</BottomSheet>
|
|
362
|
+
<AvatarFlightLayer flights={flights} />
|
|
363
|
+
</AgentAvatarProvider>
|
|
364
|
+
);
|
|
365
|
+
},
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
GemieChatSheet.displayName = 'GemieChatSheet';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chat components of the root entry: each draws the voice call (`withVoiceCall`). The same
|
|
3
|
+
* components without it — and without bundling it — are `@gemies/sdk/text`.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { GemieChatContent as TextChatContent } from './GemieChatContent';
|
|
7
|
+
import { GemieChatScreen as TextChatScreen } from './GemieChatScreen';
|
|
8
|
+
import { GemieChatSheet as TextChatSheet } from './GemieChatSheet';
|
|
9
|
+
import { withVoiceCall } from './voice/withVoiceCall';
|
|
10
|
+
|
|
11
|
+
export const GemieChatContent = withVoiceCall(TextChatContent, 'GemieChatContent');
|
|
12
|
+
export const GemieChatSheet = withVoiceCall(TextChatSheet, 'GemieChatSheet');
|
|
13
|
+
export const GemieChatScreen = withVoiceCall(TextChatScreen, 'GemieChatScreen');
|