@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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A conversation somebody shared (`GET /v1/shared/:token`, `docs/agent-embedding.md` §6), read
|
|
3
|
+
* by anybody with the link, signed in or not. It is the SDK's own thread (`GemieThread`), read-only:
|
|
4
|
+
* words, pictures, who wrote them and the canvas artifacts Alia drew (a report, deck or dashboard,
|
|
5
|
+
* drawn inline because there is no canvas panel here). The server sends no other tool's output,
|
|
6
|
+
* which can hold the person's own data, and there is nothing to vote on, play, edit or regenerate.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { AgentAvatarProvider } from '@oxy.so/bloom/agent-avatar';
|
|
10
|
+
import type { AiChatThreadHandle } from '@oxy.so/bloom/ai-chat';
|
|
11
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
12
|
+
import { useMemo, useRef } from 'react';
|
|
13
|
+
import { View } from 'react-native';
|
|
14
|
+
import { type GemieChatLabels, GemieChatLabelsProvider, useLabels } from '../lib/labels';
|
|
15
|
+
import { GemieRuntimeProvider } from '../runtime/config';
|
|
16
|
+
import {
|
|
17
|
+
SharedConversationGoneError,
|
|
18
|
+
sharedMessages,
|
|
19
|
+
useSharedConversation,
|
|
20
|
+
} from '../runtime/sharing';
|
|
21
|
+
import { GemieThread } from './thread/GemieThread';
|
|
22
|
+
import { ThreadSkeleton } from './thread/ThreadSkeleton';
|
|
23
|
+
|
|
24
|
+
export interface GemieSharedConversationProps {
|
|
25
|
+
/** The share link's token. */
|
|
26
|
+
token: string;
|
|
27
|
+
/** The Gemies API origin; omitted, production. */
|
|
28
|
+
apiUrl?: string;
|
|
29
|
+
/** Overrides for the chat's own copy; omitted, English. */
|
|
30
|
+
labels?: Partial<GemieChatLabels>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function SharedThread({ token }: { token: string }) {
|
|
34
|
+
const { t } = useLabels();
|
|
35
|
+
const { data, error, isLoading } = useSharedConversation(token);
|
|
36
|
+
const threadRef = useRef<AiChatThreadHandle | null>(null);
|
|
37
|
+
const messages = useMemo(() => (data ? sharedMessages(data) : []), [data]);
|
|
38
|
+
const agentId = data?.agent?.id;
|
|
39
|
+
const memberIds = useMemo(() => new Set(agentId ? [agentId] : []), [agentId]);
|
|
40
|
+
|
|
41
|
+
if (isLoading) {
|
|
42
|
+
return (
|
|
43
|
+
<View className="w-full max-w-4xl flex-1 self-center px-4">
|
|
44
|
+
<ThreadSkeleton />
|
|
45
|
+
</View>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (error || !data) {
|
|
49
|
+
return (
|
|
50
|
+
<View className="flex-1 items-center justify-center px-6">
|
|
51
|
+
<Text className="text-center text-base text-muted-foreground">
|
|
52
|
+
{error instanceof SharedConversationGoneError
|
|
53
|
+
? t('chat.sharedGone')
|
|
54
|
+
: t('chat.sharedFailed')}
|
|
55
|
+
</Text>
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return (
|
|
60
|
+
<View className="flex-1">
|
|
61
|
+
{data.title ? (
|
|
62
|
+
<Text className="px-4 pt-4 text-lg font-semibold text-foreground" numberOfLines={2}>
|
|
63
|
+
{data.title}
|
|
64
|
+
</Text>
|
|
65
|
+
) : null}
|
|
66
|
+
<GemieThread
|
|
67
|
+
messages={messages}
|
|
68
|
+
memberIds={memberIds}
|
|
69
|
+
isLoading={false}
|
|
70
|
+
threadRef={threadRef}
|
|
71
|
+
readOnly
|
|
72
|
+
/>
|
|
73
|
+
</View>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function GemieSharedConversation({ token, apiUrl, labels }: GemieSharedConversationProps) {
|
|
78
|
+
return (
|
|
79
|
+
<AgentAvatarProvider>
|
|
80
|
+
<GemieChatLabelsProvider labels={labels}>
|
|
81
|
+
<GemieRuntimeProvider apiUrl={apiUrl}>
|
|
82
|
+
<SharedThread token={token} />
|
|
83
|
+
</GemieRuntimeProvider>
|
|
84
|
+
</GemieChatLabelsProvider>
|
|
85
|
+
</AgentAvatarProvider>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AgentAvatar } from '@oxy.so/bloom/agent-avatar';
|
|
2
|
+
import { AvatarAnchor } from '@oxy.so/bloom/avatar-flight';
|
|
3
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { ANCHORS, useGemieFlights } from '../lib/flights';
|
|
6
|
+
import { greetingLines } from '../lib/greeting';
|
|
7
|
+
import { ALIA_LEAD, type GemieLead } from '../lib/participants';
|
|
8
|
+
import { GemieAvatar } from './GemieAvatar';
|
|
9
|
+
|
|
10
|
+
export interface GemieWelcomeMessageProps {
|
|
11
|
+
/** The greeting, e.g. "Hi Nate, what's on your mind?". */
|
|
12
|
+
greeting: string;
|
|
13
|
+
subtitle?: string;
|
|
14
|
+
markSize?: number;
|
|
15
|
+
/** Who greets: the agent the chat was opened on. Default Alia. */
|
|
16
|
+
lead?: GemieLead;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The empty chat's greeting: the lead's avatar above it, both centred, the address on top ("Hi Nate,")
|
|
21
|
+
* and the rest under it (`greetingLines`). The Alia app and the SDK chat
|
|
22
|
+
* draw exactly this. The greeting has a max width (`max-w-md`, 28rem) so it sets in two lines at
|
|
23
|
+
* any width, as a headline under a mark rather than one long line across a wide column. The
|
|
24
|
+
* suggestions are not part of it; they sit over the composer (`ComposerSuggestions`).
|
|
25
|
+
*/
|
|
26
|
+
export function GemieWelcomeMessage({
|
|
27
|
+
greeting,
|
|
28
|
+
subtitle,
|
|
29
|
+
markSize = 88,
|
|
30
|
+
lead = ALIA_LEAD,
|
|
31
|
+
}: GemieWelcomeMessageProps) {
|
|
32
|
+
const flights = useGemieFlights();
|
|
33
|
+
const avatar = lead.isAlia ? (
|
|
34
|
+
<GemieAvatar size={markSize} interactive />
|
|
35
|
+
) : (
|
|
36
|
+
<AgentAvatar character={lead.character} size={markSize} label={lead.name} interactive />
|
|
37
|
+
);
|
|
38
|
+
return (
|
|
39
|
+
<View className="items-center gap-2">
|
|
40
|
+
<View className="items-center justify-center gap-4">
|
|
41
|
+
{/* It flies up into the header's profile when the conversation begins. */}
|
|
42
|
+
{flights ? (
|
|
43
|
+
<AvatarAnchor flights={flights} anchor={ANCHORS.welcome}>
|
|
44
|
+
{avatar}
|
|
45
|
+
</AvatarAnchor>
|
|
46
|
+
) : (
|
|
47
|
+
avatar
|
|
48
|
+
)}
|
|
49
|
+
<Text selectable={false} className="max-w-md shrink text-center text-4xl text-text-primary">
|
|
50
|
+
{greetingLines(greeting).join('\n')}
|
|
51
|
+
</Text>
|
|
52
|
+
</View>
|
|
53
|
+
{subtitle ? (
|
|
54
|
+
<Text className="text-center text-lg text-text-secondary">{subtitle}</Text>
|
|
55
|
+
) : null}
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { useHaptics } from '@oxy.so/bloom/hooks';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Pressable, View } from 'react-native';
|
|
4
|
+
import type { GemieAvatarState } from './GemieAvatar';
|
|
5
|
+
import Svg, { Path } from 'react-native-svg';
|
|
6
|
+
import Animated, {
|
|
7
|
+
useSharedValue,
|
|
8
|
+
useAnimatedReaction,
|
|
9
|
+
useAnimatedStyle,
|
|
10
|
+
withTiming,
|
|
11
|
+
withRepeat,
|
|
12
|
+
withSequence,
|
|
13
|
+
cancelAnimation,
|
|
14
|
+
Easing,
|
|
15
|
+
} from 'react-native-reanimated';
|
|
16
|
+
|
|
17
|
+
/** What the mark is doing: the same states as the avatar's. */
|
|
18
|
+
export type IdentityMarkState = GemieAvatarState;
|
|
19
|
+
|
|
20
|
+
export interface IdentityMarkProps {
|
|
21
|
+
/** Width & height in px. Default 24. */
|
|
22
|
+
size?: number;
|
|
23
|
+
/** Animation state — spins while thinking/working, opacity-pulses while writing, still when idle. Default 'idle'. */
|
|
24
|
+
state?: IdentityMarkState;
|
|
25
|
+
/** Layout classes for the outer box (color comes from `color`, not classes). */
|
|
26
|
+
className?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Who the mark stands for, as a colour. An agent passes its own colour and
|
|
29
|
+
* gets the same artwork at the same size, which is the whole of the
|
|
30
|
+
* difference between Alia's mark and an agent's.
|
|
31
|
+
*
|
|
32
|
+
* The default is the Alia brand purple, and that is what an agent-less
|
|
33
|
+
* surface gets when it passes nothing. But do not read the default as a rule:
|
|
34
|
+
* three of Alia's own surfaces — the sidebar logo, the chat's mark and the
|
|
35
|
+
* welcome message — deliberately pass `colors.primary`, so Alia's face
|
|
36
|
+
* follows the account's accent there and stays brand purple elsewhere
|
|
37
|
+
* (`welcome-intro.tsx`). That split predates this component and is not
|
|
38
|
+
* settled; it is written down here so the next reader picks a side knowingly
|
|
39
|
+
* rather than copying whichever neighbour they happened to open.
|
|
40
|
+
*/
|
|
41
|
+
color?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Called after the press flourish, for a mark that is a control — the sidebar
|
|
44
|
+
* logo, which goes home.
|
|
45
|
+
*/
|
|
46
|
+
onPress?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Take the tap for the flourish alone: spin, haptic, nothing else.
|
|
49
|
+
*
|
|
50
|
+
* For a mark that IS Alia standing on its own — the welcome greeting, a chat
|
|
51
|
+
* header — where the spin has always been the whole of what a tap does. There
|
|
52
|
+
* is no callback to give it, and `onPress={() => {}}` would be a lie about
|
|
53
|
+
* that, so this is how such a mark asks to be pressable.
|
|
54
|
+
*
|
|
55
|
+
* Sibling of `spinOnMount`, and off by default like it. Off is what lets the
|
|
56
|
+
* mark sit inside a row that is itself pressable — a sidebar agent entry, a
|
|
57
|
+
* card — without swallowing the tap meant for the row, which is the whole
|
|
58
|
+
* reason the press target is opt-in.
|
|
59
|
+
*/
|
|
60
|
+
spinOnPress?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Accessible name. A mark standing in for whoever is speaking is not
|
|
63
|
+
* decoration, so it says who; Alia's own, drawn beside her name, is.
|
|
64
|
+
*/
|
|
65
|
+
accessibilityLabel?: string;
|
|
66
|
+
/** Play the one-shot spin when the mark mounts (e.g. the sidebar rail collapsing in). */
|
|
67
|
+
spinOnMount?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Alia brand purple — the mark keeps its identity color across themes. */
|
|
71
|
+
const BRAND_FILL = '#d269e6';
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Square viewBox centered on the glyph (exact curve bounds sampled from the
|
|
75
|
+
* path: x 140.6–1359.6, y 74.4–1425.0), so the mark renders margin-free at any
|
|
76
|
+
* size without distortion.
|
|
77
|
+
*/
|
|
78
|
+
const VIEWBOX = '74.8 74.4 1350.6 1350.6';
|
|
79
|
+
|
|
80
|
+
const GLYPH_PATH =
|
|
81
|
+
'M 728 76.199219 C 659.800781 84 596.601562 133.199219 558.800781 207.199219 C 539.800781 244.601562 527.199219 292.398438 524.601562 336.398438 L 523.398438 357.800781 L 506.199219 349 C 457.398438 324.199219 413.601562 313.398438 361 313.199219 C 314.601562 313 281.800781 320 247.199219 337.199219 C 194.398438 363.601562 161 404.601562 145.800781 461.199219 C 140.199219 482.199219 139.601562 527.398438 144.601562 550.199219 C 156.199219 601.800781 182 649.199219 220.601562 689.398438 C 239.800781 709.199219 271 734.601562 287.800781 744 C 292.199219 746.601562 296 749.199219 296 749.800781 C 296 750.398438 292.398438 753 288 755.601562 C 270.800781 765.398438 240 790.601562 221 810.398438 C 137.199219 897.398438 116.601562 1013 170.199219 1095.199219 C 200.199219 1141.199219 247.601562 1171.199219 309 1183.199219 C 333.601562 1188 383.800781 1188 410.800781 1183.199219 C 444 1177.199219 474.398438 1167 505.800781 1151.199219 L 524 1142 L 524 1153.601562 C 524 1180.398438 530.800781 1218.601562 541.199219 1250 C 582.800781 1376 690 1446.800781 796.800781 1419 C 846.398438 1406 893.800781 1369.800781 926 1320 C 953.601562 1277.199219 972.199219 1218.398438 975.398438 1163.601562 L 976.601562 1142.398438 L 994.398438 1151.398438 C 1044.800781 1176.601562 1087.800781 1187 1142 1186.800781 C 1192.601562 1186.601562 1229.601562 1177.199219 1269 1154.199219 C 1289.601562 1142.199219 1319.800781 1112.398438 1331.800781 1092.398438 C 1351.398438 1059.800781 1358.398438 1033.800781 1358.601562 994 C 1358.800781 953.199219 1353.199219 929.398438 1334 888.601562 C 1310.800781 839.601562 1265.398438 789 1217.601562 759.398438 C 1210.199219 754.800781 1204 750.601562 1204 750 C 1204 749.398438 1210.199219 745.199219 1217.601562 740.601562 C 1251.398438 719.601562 1291 681.199219 1313 648 C 1348.601562 594.601562 1364.601562 537 1358.199219 484.800781 C 1347.398438 397.800781 1285.398438 335.398438 1191 316.800781 C 1164.398438 311.398438 1114.199219 311.800781 1085 317.601562 C 1054.601562 323.601562 1029.398438 332 1000.601562 346 L 976 357.800781 L 976 346.398438 C 976 290 952.800781 217.800781 919.800781 171 C 881 116.398438 829 83.601562 769.199219 76 C 751.398438 73.800781 749.398438 73.800781 728 76.199219 Z';
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The mark that stands for whoever is speaking — the six-lobed flower glyph as
|
|
85
|
+
* an SVG (unselectable by nature), painted in one colour.
|
|
86
|
+
*
|
|
87
|
+
* Alia and every agent draw THIS, and nothing else: the colour is the only
|
|
88
|
+
* difference between them, and where a face would otherwise go it is the size
|
|
89
|
+
* that adapts, not a background. There is no disc, no crop and no image to fall
|
|
90
|
+
* back from — an agent's Oxy account carries no avatar at all, so this is the
|
|
91
|
+
* whole of an agent's likeness in the app.
|
|
92
|
+
*
|
|
93
|
+
* Effect-free reanimated: spin while thinking/using tools, opacity-pulse while
|
|
94
|
+
* streaming text, still when idle.
|
|
95
|
+
*/
|
|
96
|
+
export function IdentityMark({
|
|
97
|
+
size = 24,
|
|
98
|
+
state = 'idle',
|
|
99
|
+
className,
|
|
100
|
+
color,
|
|
101
|
+
onPress,
|
|
102
|
+
spinOnPress = false,
|
|
103
|
+
accessibilityLabel,
|
|
104
|
+
spinOnMount = false,
|
|
105
|
+
}: IdentityMarkProps) {
|
|
106
|
+
// Imperative animations via reanimated's reactive primitive (NOT a React effect):
|
|
107
|
+
// on this reanimated-web setup, animations returned from mappers/styles never
|
|
108
|
+
// tick, but `sharedValue.value = withRepeat(...)` does.
|
|
109
|
+
const rotation = useSharedValue(0);
|
|
110
|
+
useAnimatedReaction(
|
|
111
|
+
() => state === 'thinking' || state === 'working',
|
|
112
|
+
(spinning, previous) => {
|
|
113
|
+
if (spinning === previous) return;
|
|
114
|
+
if (spinning) {
|
|
115
|
+
rotation.value = 0;
|
|
116
|
+
rotation.value = withRepeat(withTiming(360, { duration: 1000, easing: Easing.linear }), -1);
|
|
117
|
+
} else {
|
|
118
|
+
cancelAnimation(rotation);
|
|
119
|
+
rotation.value = withTiming(0, { duration: 200 });
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
[state],
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const opacity = useSharedValue(1);
|
|
126
|
+
useAnimatedReaction(
|
|
127
|
+
() => state === 'writing',
|
|
128
|
+
(pulsing, previous) => {
|
|
129
|
+
if (pulsing === previous) return;
|
|
130
|
+
if (pulsing) {
|
|
131
|
+
opacity.value = withRepeat(
|
|
132
|
+
withSequence(
|
|
133
|
+
withTiming(0.5, { duration: 1000, easing: Easing.bezier(0.4, 0, 0.6, 1) }),
|
|
134
|
+
withTiming(1, { duration: 1000, easing: Easing.bezier(0.4, 0, 0.6, 1) }),
|
|
135
|
+
),
|
|
136
|
+
-1,
|
|
137
|
+
);
|
|
138
|
+
} else {
|
|
139
|
+
cancelAnimation(opacity);
|
|
140
|
+
opacity.value = withTiming(1, { duration: 200 });
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[state],
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// One-shot press/mount flourish. Skipped while the state-driven spin runs so
|
|
147
|
+
// the two never fight over the shared rotation value.
|
|
148
|
+
const [spinCount, setSpinCount] = useState(spinOnMount ? 1 : 0);
|
|
149
|
+
const haptic = useHaptics();
|
|
150
|
+
useAnimatedReaction(
|
|
151
|
+
() => spinCount,
|
|
152
|
+
(current, previous) => {
|
|
153
|
+
if (current === previous || current === 0) return;
|
|
154
|
+
rotation.value = 0;
|
|
155
|
+
rotation.value = withTiming(360, {
|
|
156
|
+
duration: 500,
|
|
157
|
+
easing: Easing.bezier(0.34, 1.3, 0.64, 1),
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
[spinCount],
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
164
|
+
opacity: opacity.value,
|
|
165
|
+
transform: [{ rotate: `${rotation.value}deg` }],
|
|
166
|
+
}));
|
|
167
|
+
|
|
168
|
+
const handlePress = () => {
|
|
169
|
+
if (state !== 'thinking' && state !== 'working') {
|
|
170
|
+
setSpinCount((count) => count + 1);
|
|
171
|
+
}
|
|
172
|
+
haptic();
|
|
173
|
+
onPress?.();
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const box = {
|
|
177
|
+
width: size,
|
|
178
|
+
height: size,
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
justifyContent: 'center',
|
|
181
|
+
} as const;
|
|
182
|
+
const glyph = (
|
|
183
|
+
<Animated.View style={animatedStyle}>
|
|
184
|
+
<Svg width={size} height={size} viewBox={VIEWBOX}>
|
|
185
|
+
<Path d={GLYPH_PATH} fill={color ?? BRAND_FILL} />
|
|
186
|
+
</Svg>
|
|
187
|
+
</Animated.View>
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
// A `Pressable` captures the touch whether or not the caller wanted one, so
|
|
191
|
+
// the inert mark is a plain view — a mark drawn as somebody's face inside a
|
|
192
|
+
// row that is itself pressable must not stop that row from opening. Asking for
|
|
193
|
+
// the touch is therefore explicit, and either prop asks: a callback to run, or
|
|
194
|
+
// the flourish for its own sake.
|
|
195
|
+
if (onPress === undefined && !spinOnPress) {
|
|
196
|
+
return (
|
|
197
|
+
<View
|
|
198
|
+
accessibilityRole="image"
|
|
199
|
+
accessibilityLabel={accessibilityLabel}
|
|
200
|
+
className={className}
|
|
201
|
+
style={box}
|
|
202
|
+
>
|
|
203
|
+
{glyph}
|
|
204
|
+
</View>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<Pressable
|
|
210
|
+
onPress={handlePress}
|
|
211
|
+
// Pressable, but a button only when the press DOES something beyond the
|
|
212
|
+
// flourish. A screen reader announcing the welcome greeting's mark as a
|
|
213
|
+
// button would promise an action it does not have.
|
|
214
|
+
accessibilityRole={onPress === undefined ? 'image' : 'button'}
|
|
215
|
+
accessibilityLabel={accessibilityLabel}
|
|
216
|
+
// Nor a Tab stop: on web a Pressable is focusable by default, so the
|
|
217
|
+
// flourish was an unlabelled stop in the keyboard order that did nothing.
|
|
218
|
+
focusable={onPress !== undefined}
|
|
219
|
+
className={className}
|
|
220
|
+
style={box}
|
|
221
|
+
>
|
|
222
|
+
{glyph}
|
|
223
|
+
</Pressable>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Image as ExpoImage, type ImageProps } from 'expo-image';
|
|
2
|
+
import type { ComponentType } from 'react';
|
|
3
|
+
import { styled } from 'react-native-css';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `expo-image` with `className`. On web the class reaches the DOM either way; on native
|
|
7
|
+
* react-native-css maps classes to styles only for react-native's own primitives, so anything
|
|
8
|
+
* else drops them silently unless it is wrapped once, here, at module scope.
|
|
9
|
+
*/
|
|
10
|
+
export const Image: ComponentType<ImageProps & { className?: string }> = styled(ExpoImage, {
|
|
11
|
+
className: 'style',
|
|
12
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface InertWhenProps {
|
|
5
|
+
/** The content is out of reach while true: not focusable, not read by a screen reader. */
|
|
6
|
+
inert: boolean;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Takes what it wraps out of reach while something is drawn over it, and keeps it mounted.
|
|
12
|
+
*
|
|
13
|
+
* It is Bloom's `OverlayInertBoundary` (same props per platform) driven by this in-tree overlay
|
|
14
|
+
* instead of by Bloom's global modal registry: that registry is app-wide, so registering the
|
|
15
|
+
* view there would make the host's sidebar and header inert too, where only the chat under the
|
|
16
|
+
* view must be. Web gets `inert` + `aria-hidden` and no box (`display: contents`, so layout is
|
|
17
|
+
* what it was); Android `no-hide-descendants`; iOS `accessibilityElementsHidden`.
|
|
18
|
+
*/
|
|
19
|
+
export function InertWhen({ inert, children }: InertWhenProps) {
|
|
20
|
+
if (Platform.OS === 'web') {
|
|
21
|
+
return (
|
|
22
|
+
<View
|
|
23
|
+
testID="inert-when"
|
|
24
|
+
style={styles.web}
|
|
25
|
+
aria-hidden={inert ? true : undefined}
|
|
26
|
+
{...(inert ? { inert: true } : null)}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return (
|
|
33
|
+
<View
|
|
34
|
+
testID="inert-when"
|
|
35
|
+
collapsable={false}
|
|
36
|
+
style={styles.native}
|
|
37
|
+
importantForAccessibility={inert ? 'no-hide-descendants' : 'auto'}
|
|
38
|
+
accessibilityElementsHidden={inert}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const styles = StyleSheet.create({
|
|
46
|
+
native: { flex: 1 },
|
|
47
|
+
web: { display: 'contents' },
|
|
48
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Card, CardBody, CardHeader, CardTitle } from '@oxy.so/bloom/card';
|
|
2
|
+
import { RiListCheck3 } from '@oxy.so/bloom/icons/RiListCheck3';
|
|
3
|
+
import { Item } from '@oxy.so/bloom/item';
|
|
4
|
+
import { useTheme } from '@oxy.so/bloom/theme';
|
|
5
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
6
|
+
import { View } from 'react-native';
|
|
7
|
+
import Animated from 'react-native-reanimated';
|
|
8
|
+
import { planPreviewEnter } from '../animations';
|
|
9
|
+
import { useLabels } from '../lib/labels';
|
|
10
|
+
import type { PlanStep } from '../types';
|
|
11
|
+
|
|
12
|
+
interface PlanPreviewCardProps {
|
|
13
|
+
steps: PlanStep[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The plan the agent shows before it works. It is only shown: the agent does not wait on it, and
|
|
18
|
+
* nobody is asked to approve it.
|
|
19
|
+
*/
|
|
20
|
+
export function PlanPreviewCard({ steps }: PlanPreviewCardProps) {
|
|
21
|
+
const labels = useLabels();
|
|
22
|
+
const { colors } = useTheme();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Animated.View entering={planPreviewEnter} className="my-2">
|
|
26
|
+
<Card appearance="outline">
|
|
27
|
+
<CardHeader>
|
|
28
|
+
<View className="flex-row items-center gap-2">
|
|
29
|
+
<RiListCheck3 width={16} height={16} fill={colors.icon} />
|
|
30
|
+
<CardTitle>{labels.planTitle}</CardTitle>
|
|
31
|
+
</View>
|
|
32
|
+
</CardHeader>
|
|
33
|
+
<CardBody>
|
|
34
|
+
{steps.map((step, index) => (
|
|
35
|
+
<Item
|
|
36
|
+
// A plan has no ids and its steps never reorder: the position is the identity.
|
|
37
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: see above
|
|
38
|
+
key={index}
|
|
39
|
+
density="compact"
|
|
40
|
+
leading={
|
|
41
|
+
<Text className="w-5 text-center text-xs font-bold text-text-secondary">
|
|
42
|
+
{index + 1}
|
|
43
|
+
</Text>
|
|
44
|
+
}
|
|
45
|
+
title={step.action}
|
|
46
|
+
subtitle={step.description || undefined}
|
|
47
|
+
/>
|
|
48
|
+
))}
|
|
49
|
+
</CardBody>
|
|
50
|
+
</Card>
|
|
51
|
+
</Animated.View>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Questionnaire, type QuestionnaireAnswers } from '@oxy.so/bloom/questionnaire';
|
|
2
|
+
import { Muted } from '@oxy.so/bloom/typography';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { type AskedQuestion, formatAnswers } from '../lib/questions';
|
|
5
|
+
|
|
6
|
+
interface QuestionCardProps {
|
|
7
|
+
questions: AskedQuestion[];
|
|
8
|
+
/** Sends the answers as the person's next message. */
|
|
9
|
+
onSubmit: (message: string) => void;
|
|
10
|
+
/** Shows the corner dismiss; typing a reply in the composer answers just as well. */
|
|
11
|
+
onDismiss?: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Ids are positions: the questions are the model's, and carry none. */
|
|
15
|
+
const idOf = (index: number) => `q${index}`;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The questions Alia asked, as Bloom's `Questionnaire`. Give it to the composer's `question`
|
|
19
|
+
* slot while the person can still answer: it docks above the composer, where they are about
|
|
20
|
+
* to type, rather than sitting in the thread.
|
|
21
|
+
*/
|
|
22
|
+
export function QuestionCard({ questions, onSubmit, onDismiss }: QuestionCardProps) {
|
|
23
|
+
const complete = (answers: QuestionnaireAnswers) =>
|
|
24
|
+
onSubmit(
|
|
25
|
+
formatAnswers(
|
|
26
|
+
questions,
|
|
27
|
+
questions.map((_, i) => ({
|
|
28
|
+
picked: (answers[idOf(i)]?.values ?? []).map(Number),
|
|
29
|
+
other: answers[idOf(i)]?.other,
|
|
30
|
+
})),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Questionnaire
|
|
36
|
+
questions={questions.map((q, i) => ({
|
|
37
|
+
id: idOf(i),
|
|
38
|
+
question: q.question,
|
|
39
|
+
select: q.multiSelect ? 'multiple' : 'single',
|
|
40
|
+
other: true,
|
|
41
|
+
options: q.options.map((option, index) => ({
|
|
42
|
+
value: String(index),
|
|
43
|
+
label: option.label,
|
|
44
|
+
description: option.description,
|
|
45
|
+
})),
|
|
46
|
+
}))}
|
|
47
|
+
onComplete={complete}
|
|
48
|
+
onDismiss={onDismiss}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The questions Alia asked, as plain lines: the thread's record of them once they are answered. */
|
|
54
|
+
export function AskedQuestions({ questions }: { questions: AskedQuestion[] }) {
|
|
55
|
+
return (
|
|
56
|
+
<View className="my-2 gap-1">
|
|
57
|
+
{questions.map((q, i) => (
|
|
58
|
+
// The model's questions never reorder: the position is the identity.
|
|
59
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: see above
|
|
60
|
+
<Muted key={i}>{q.question}</Muted>
|
|
61
|
+
))}
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
64
|
+
}
|