@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,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composer's microphone: record a clip, then transcribe it with a Kaana
|
|
3
|
+
* transcription model through Alia (`POST /v1/audio/transcriptions`, ADR 0017
|
|
4
|
+
* §7). Free on every plan, five minutes per clip at most.
|
|
5
|
+
*
|
|
6
|
+
* idle → requesting-permission → recording → transcribing → idle (text)
|
|
7
|
+
* ↘ error { code }
|
|
8
|
+
*
|
|
9
|
+
* - `recording` is entered only once the recorder reports it started; the
|
|
10
|
+
* level meter is the real recorder's.
|
|
11
|
+
* - The text arrives after the person stops — `onText` — and never partially:
|
|
12
|
+
* a failed transcription inserts nothing and keeps the clip for ONE `retry()`.
|
|
13
|
+
* - At five minutes the recording stops by itself and is transcribed; the
|
|
14
|
+
* remaining time is exposed for the last 30 seconds.
|
|
15
|
+
*
|
|
16
|
+
* Nothing is recognized on the device.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
20
|
+
import { create } from 'zustand';
|
|
21
|
+
import { useOxy } from '@oxy.so/services/ui/client';
|
|
22
|
+
import {
|
|
23
|
+
dictationFailureCode,
|
|
24
|
+
MAX_DICTATION_MS,
|
|
25
|
+
requestTranscription,
|
|
26
|
+
type DictationClip,
|
|
27
|
+
} from '../lib/dictation';
|
|
28
|
+
import { DictationRecorderError, useDictationRecorder } from '../lib/dictation-recorder';
|
|
29
|
+
import { defaultSpeechLanguage } from '../lib/speech-language';
|
|
30
|
+
import { VOICE_ERROR_MESSAGES, type VoiceErrorCode } from '../lib/speech-messages';
|
|
31
|
+
import { GEMIES_API_URL } from '../lib/origins';
|
|
32
|
+
import { bindAudioSession } from '../lib/audio-session-binding';
|
|
33
|
+
|
|
34
|
+
/** The remaining time is shown from here on. */
|
|
35
|
+
const COUNTDOWN_FROM_MS = 30_000;
|
|
36
|
+
const CLOCK_MS = 250;
|
|
37
|
+
|
|
38
|
+
export type DictationState =
|
|
39
|
+
| 'idle'
|
|
40
|
+
| 'requesting-permission'
|
|
41
|
+
| 'recording'
|
|
42
|
+
| 'transcribing'
|
|
43
|
+
| 'error';
|
|
44
|
+
|
|
45
|
+
export interface UseDictationOptions {
|
|
46
|
+
apiUrl?: string;
|
|
47
|
+
/** Bearer; defaults to the surrounding Oxy session's. */
|
|
48
|
+
accessToken?: string;
|
|
49
|
+
/** Language spoken (BCP-47); defaults to the platform's. The Alia app passes its own. */
|
|
50
|
+
lang?: string;
|
|
51
|
+
/** The transcribed text, once — after a stop, the five-minute stop, or a retry. */
|
|
52
|
+
onText?: (text: string) => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface DictationStoreState {
|
|
56
|
+
isRecording: boolean;
|
|
57
|
+
metering: number;
|
|
58
|
+
setRecording: (isRecording: boolean) => void;
|
|
59
|
+
setMetering: (metering: number) => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Whether the composer is recording, and its level: what the ambient field and
|
|
64
|
+
* the app's turn actions read without holding the hook.
|
|
65
|
+
*/
|
|
66
|
+
export const useDictationStore = create<DictationStoreState>((set) => ({
|
|
67
|
+
isRecording: false,
|
|
68
|
+
metering: 0,
|
|
69
|
+
setRecording: (isRecording) => set({ isRecording }),
|
|
70
|
+
setMetering: (metering) => set({ metering }),
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
export function useDictation(options: UseDictationOptions = {}) {
|
|
74
|
+
const { oxyServices } = useOxy();
|
|
75
|
+
const recorder = useDictationRecorder();
|
|
76
|
+
const [state, setStateValue] = useState<DictationState>('idle');
|
|
77
|
+
const [errorCode, setErrorCode] = useState<VoiceErrorCode | null>(null);
|
|
78
|
+
const [elapsedMs, setElapsedMs] = useState(0);
|
|
79
|
+
const [canRetry, setCanRetry] = useState(false);
|
|
80
|
+
|
|
81
|
+
const stateRef = useRef<DictationState>('idle');
|
|
82
|
+
const mountedRef = useRef(true);
|
|
83
|
+
const startedAtRef = useRef(0);
|
|
84
|
+
const clockRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
85
|
+
const capRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
86
|
+
const failedClipRef = useRef<DictationClip | null>(null);
|
|
87
|
+
const abortRef = useRef<AbortController | null>(null);
|
|
88
|
+
const lastMeteringRef = useRef(0);
|
|
89
|
+
const optionsRef = useRef(options);
|
|
90
|
+
optionsRef.current = options;
|
|
91
|
+
|
|
92
|
+
const setState = useCallback((next: DictationState) => {
|
|
93
|
+
stateRef.current = next;
|
|
94
|
+
if (mountedRef.current) setStateValue(next);
|
|
95
|
+
}, []);
|
|
96
|
+
|
|
97
|
+
const report = useCallback(
|
|
98
|
+
(code: VoiceErrorCode | null) => {
|
|
99
|
+
if (mountedRef.current) setErrorCode(code);
|
|
100
|
+
if (code !== null) setState('error');
|
|
101
|
+
},
|
|
102
|
+
[setState],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const store = useDictationStore.getState();
|
|
107
|
+
store.setRecording(state === 'recording');
|
|
108
|
+
if (state !== 'recording') {
|
|
109
|
+
lastMeteringRef.current = 0;
|
|
110
|
+
store.setMetering(0);
|
|
111
|
+
}
|
|
112
|
+
}, [state]);
|
|
113
|
+
|
|
114
|
+
const clearClock = useCallback((): void => {
|
|
115
|
+
if (clockRef.current !== null) clearInterval(clockRef.current);
|
|
116
|
+
if (capRef.current !== null) clearTimeout(capRef.current);
|
|
117
|
+
clockRef.current = null;
|
|
118
|
+
capRef.current = null;
|
|
119
|
+
}, []);
|
|
120
|
+
|
|
121
|
+
const transcribe = useCallback(
|
|
122
|
+
async (clip: DictationClip): Promise<string | null> => {
|
|
123
|
+
const apiUrl = optionsRef.current.apiUrl || GEMIES_API_URL;
|
|
124
|
+
const token = optionsRef.current.accessToken;
|
|
125
|
+
setState('transcribing');
|
|
126
|
+
const controller = new AbortController();
|
|
127
|
+
abortRef.current = controller;
|
|
128
|
+
const linked = token ? null : bindAudioSession(oxyServices, apiUrl, () => controller.abort());
|
|
129
|
+
try {
|
|
130
|
+
const result = await requestTranscription({
|
|
131
|
+
apiUrl,
|
|
132
|
+
...(linked ? { transport: linked } : { token: token ?? '' }),
|
|
133
|
+
clip,
|
|
134
|
+
language: optionsRef.current.lang ?? defaultSpeechLanguage(),
|
|
135
|
+
signal: controller.signal,
|
|
136
|
+
});
|
|
137
|
+
if (controller.signal.aborted) return null;
|
|
138
|
+
failedClipRef.current = null;
|
|
139
|
+
if (mountedRef.current) setCanRetry(false);
|
|
140
|
+
setState('idle');
|
|
141
|
+
const text = result.text.trim();
|
|
142
|
+
if (text === '') return null;
|
|
143
|
+
optionsRef.current.onText?.(text);
|
|
144
|
+
return text;
|
|
145
|
+
} catch (caught: unknown) {
|
|
146
|
+
if (controller.signal.aborted) return null;
|
|
147
|
+
const code = dictationFailureCode(caught);
|
|
148
|
+
// Kept for one retry, unless retrying cannot change the answer.
|
|
149
|
+
const keep = code !== 'too-long' && code !== 'not-authenticated';
|
|
150
|
+
failedClipRef.current = keep ? clip : null;
|
|
151
|
+
if (mountedRef.current) setCanRetry(keep);
|
|
152
|
+
report(code);
|
|
153
|
+
return null;
|
|
154
|
+
} finally {
|
|
155
|
+
linked?.dispose();
|
|
156
|
+
if (abortRef.current === controller) abortRef.current = null;
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
[oxyServices, report, setState],
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const stop = useCallback(async (): Promise<string | null> => {
|
|
163
|
+
if (stateRef.current !== 'recording') return null;
|
|
164
|
+
clearClock();
|
|
165
|
+
setState('transcribing');
|
|
166
|
+
let clip: DictationClip | null;
|
|
167
|
+
try {
|
|
168
|
+
clip = await recorder.stop();
|
|
169
|
+
} catch {
|
|
170
|
+
report('mic-unavailable');
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
if (clip === null) {
|
|
174
|
+
setState('idle');
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
if (clip.durationMs > MAX_DICTATION_MS + 1_000) {
|
|
178
|
+
report('too-long');
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
return transcribe(clip);
|
|
182
|
+
}, [clearClock, recorder, report, setState, transcribe]);
|
|
183
|
+
|
|
184
|
+
const stopRef = useRef(stop);
|
|
185
|
+
stopRef.current = stop;
|
|
186
|
+
|
|
187
|
+
const start = useCallback(async (): Promise<void> => {
|
|
188
|
+
if (stateRef.current !== 'idle' && stateRef.current !== 'error') return;
|
|
189
|
+
if (mountedRef.current) {
|
|
190
|
+
setErrorCode(null);
|
|
191
|
+
setCanRetry(false);
|
|
192
|
+
setElapsedMs(0);
|
|
193
|
+
}
|
|
194
|
+
failedClipRef.current = null;
|
|
195
|
+
setState('requesting-permission');
|
|
196
|
+
try {
|
|
197
|
+
await recorder.start((level) => {
|
|
198
|
+
if (stateRef.current !== 'recording') return;
|
|
199
|
+
// Quiet should not thrash the store's subscribers.
|
|
200
|
+
if (Math.abs(level - lastMeteringRef.current) < 0.02) return;
|
|
201
|
+
lastMeteringRef.current = level;
|
|
202
|
+
useDictationStore.getState().setMetering(level);
|
|
203
|
+
});
|
|
204
|
+
} catch (caught: unknown) {
|
|
205
|
+
if ((stateRef.current as DictationState) !== 'requesting-permission') return;
|
|
206
|
+
report(caught instanceof DictationRecorderError ? caught.code : 'mic-unavailable');
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if ((stateRef.current as DictationState) !== 'requesting-permission') {
|
|
210
|
+
// Cancelled while the permission was asked.
|
|
211
|
+
recorder.cancel();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
startedAtRef.current = Date.now();
|
|
215
|
+
setState('recording');
|
|
216
|
+
clockRef.current = setInterval(() => {
|
|
217
|
+
if (mountedRef.current) setElapsedMs(Date.now() - startedAtRef.current);
|
|
218
|
+
}, CLOCK_MS);
|
|
219
|
+
capRef.current = setTimeout(() => {
|
|
220
|
+
void stopRef.current();
|
|
221
|
+
}, MAX_DICTATION_MS);
|
|
222
|
+
}, [recorder, report, setState]);
|
|
223
|
+
|
|
224
|
+
const retry = useCallback(async (): Promise<string | null> => {
|
|
225
|
+
const clip = failedClipRef.current;
|
|
226
|
+
if (clip === null || stateRef.current === 'recording' || stateRef.current === 'transcribing')
|
|
227
|
+
return null;
|
|
228
|
+
// One retry: whatever it answers, the clip is not kept for another.
|
|
229
|
+
failedClipRef.current = null;
|
|
230
|
+
if (mountedRef.current) {
|
|
231
|
+
setCanRetry(false);
|
|
232
|
+
setErrorCode(null);
|
|
233
|
+
}
|
|
234
|
+
const text = await transcribe(clip);
|
|
235
|
+
failedClipRef.current = null;
|
|
236
|
+
if (mountedRef.current) setCanRetry(false);
|
|
237
|
+
return text;
|
|
238
|
+
}, [transcribe]);
|
|
239
|
+
|
|
240
|
+
const cancel = useCallback(() => {
|
|
241
|
+
clearClock();
|
|
242
|
+
abortRef.current?.abort();
|
|
243
|
+
abortRef.current = null;
|
|
244
|
+
if (stateRef.current === 'recording' || stateRef.current === 'requesting-permission')
|
|
245
|
+
recorder.cancel();
|
|
246
|
+
failedClipRef.current = null;
|
|
247
|
+
if (mountedRef.current) {
|
|
248
|
+
setErrorCode(null);
|
|
249
|
+
setCanRetry(false);
|
|
250
|
+
}
|
|
251
|
+
setState('idle');
|
|
252
|
+
}, [clearClock, recorder, setState]);
|
|
253
|
+
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
mountedRef.current = true;
|
|
256
|
+
return () => {
|
|
257
|
+
mountedRef.current = false;
|
|
258
|
+
clearClock();
|
|
259
|
+
abortRef.current?.abort();
|
|
260
|
+
const wasRecording =
|
|
261
|
+
stateRef.current === 'recording' || stateRef.current === 'requesting-permission';
|
|
262
|
+
stateRef.current = 'idle';
|
|
263
|
+
if (wasRecording) recorder.cancel();
|
|
264
|
+
// The store outlives this hook: a composer unmounted mid-dictation (the
|
|
265
|
+
// call bar replacing it) must not leave the field reading "recording".
|
|
266
|
+
useDictationStore.getState().setRecording(false);
|
|
267
|
+
useDictationStore.getState().setMetering(0);
|
|
268
|
+
};
|
|
269
|
+
}, [clearClock, recorder]);
|
|
270
|
+
|
|
271
|
+
const remaining = MAX_DICTATION_MS - elapsedMs;
|
|
272
|
+
return {
|
|
273
|
+
state,
|
|
274
|
+
/** What went wrong, in English. */
|
|
275
|
+
error: errorCode === null ? null : VOICE_ERROR_MESSAGES[errorCode],
|
|
276
|
+
/** The same, as a code an app can translate. */
|
|
277
|
+
errorCode,
|
|
278
|
+
/** Since the recording started. */
|
|
279
|
+
elapsedMs,
|
|
280
|
+
/** Left before the five-minute stop, in the last 30 seconds; else `null`. */
|
|
281
|
+
remainingMs:
|
|
282
|
+
state === 'recording' && remaining <= COUNTDOWN_FROM_MS ? Math.max(0, remaining) : null,
|
|
283
|
+
/** A failed transcription kept its clip for one more try. */
|
|
284
|
+
canRetry,
|
|
285
|
+
start,
|
|
286
|
+
stop,
|
|
287
|
+
retry,
|
|
288
|
+
cancel,
|
|
289
|
+
isRecording: state === 'recording',
|
|
290
|
+
isTranscribing: state === 'transcribing',
|
|
291
|
+
};
|
|
292
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DocumentPickerResult, pickDocuments } from '../lib/document-picker';
|
|
2
|
+
|
|
3
|
+
export type { DocumentPickerResult };
|
|
4
|
+
|
|
5
|
+
type UseDocumentPickerResult = {
|
|
6
|
+
pickDocument: () => Promise<DocumentPickerResult[] | undefined>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function useDocumentPicker(): UseDocumentPickerResult {
|
|
10
|
+
return { pickDocument: pickDocuments };
|
|
11
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useLabels } from '../lib/labels';
|
|
2
|
+
import type { FailedTurn } from '../runtime/model';
|
|
3
|
+
import { toast } from '@oxy.so/bloom/toast';
|
|
4
|
+
import { useEffect, useRef } from 'react';
|
|
5
|
+
|
|
6
|
+
/** One toast for the failed turn, replaced by the next failure and dismissed with the turn. */
|
|
7
|
+
export const FAILED_TURN_TOAST_ID = 'failed-turn';
|
|
8
|
+
/** Long enough to read the line and press Retry; a toast that is gone before that is no error. */
|
|
9
|
+
const FAILED_TURN_TOAST_MS = 10_000;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A failed turn is told with a toast, with Retry as its action.
|
|
13
|
+
*
|
|
14
|
+
* The person's message is still in the thread, and the toast says why it has no answer in the
|
|
15
|
+
* app's own words, in the reader's language (the server's stand-in text, "all models are busy…",
|
|
16
|
+
* is never shown as Alia's own). Real output before the failure reads "interrupted", not "couldn't
|
|
17
|
+
* answer". The server's words, if any, go under the line. It leaves with the turn: when the failure
|
|
18
|
+
* is cleared (a retry, a new message, another chat), so does the toast.
|
|
19
|
+
*/
|
|
20
|
+
export function useFailedTurnToast(
|
|
21
|
+
failedTurn: FailedTurn | null | undefined,
|
|
22
|
+
onRetry?: () => void,
|
|
23
|
+
) {
|
|
24
|
+
const { t } = useLabels();
|
|
25
|
+
// The latest retry, without making a new toast of every render.
|
|
26
|
+
const retry = useRef(onRetry);
|
|
27
|
+
retry.current = onRetry;
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!failedTurn) return;
|
|
31
|
+
const line = failedTurn.partial ? t('chat.turnInterrupted') : t('chat.turnFailed');
|
|
32
|
+
const canRetry = failedTurn.retryable && retry.current !== undefined;
|
|
33
|
+
toast.error(canRetry ? `${line} ${t('chat.turnFailedRetryHint')}` : line, {
|
|
34
|
+
id: FAILED_TURN_TOAST_ID,
|
|
35
|
+
description: failedTurn.detail || undefined,
|
|
36
|
+
duration: FAILED_TURN_TOAST_MS,
|
|
37
|
+
...(canRetry ? { action: { label: t('chat.retry'), onClick: () => retry.current?.() } } : {}),
|
|
38
|
+
});
|
|
39
|
+
return () => {
|
|
40
|
+
toast.dismiss(FAILED_TURN_TOAST_ID);
|
|
41
|
+
};
|
|
42
|
+
}, [failedTurn, t]);
|
|
43
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
runOnJS,
|
|
4
|
+
type SharedValue,
|
|
5
|
+
useAnimatedReaction,
|
|
6
|
+
useSharedValue,
|
|
7
|
+
} from 'react-native-reanimated';
|
|
8
|
+
|
|
9
|
+
/** Bloom's sheet reports `1` once fully presented; a hair under it absorbs float rounding. */
|
|
10
|
+
const PRESENTED = 0.999;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Calls `focus` once each time a sheet finishes presenting.
|
|
14
|
+
*
|
|
15
|
+
* `progress` is the `animatedProgress` of Bloom's `BottomSheet`: `0` closed, `1` fully
|
|
16
|
+
* presented, every value between while it animates or is dragged. The sheet is armed while it
|
|
17
|
+
* is closed and fires on reaching `1`, so dragging it part-way and letting go does not take the
|
|
18
|
+
* focus again; only a new `present()` does. Reduced motion settles immediately, which is the
|
|
19
|
+
* same crossing. Omitted, nothing happens — the surface is not a sheet.
|
|
20
|
+
*/
|
|
21
|
+
export function useFocusWhenPresented(
|
|
22
|
+
progress: SharedValue<number> | undefined,
|
|
23
|
+
focus: () => void,
|
|
24
|
+
): void {
|
|
25
|
+
const latest = useRef(focus);
|
|
26
|
+
latest.current = focus;
|
|
27
|
+
const run = useCallback(() => latest.current(), []);
|
|
28
|
+
const armed = useSharedValue(true);
|
|
29
|
+
useAnimatedReaction(
|
|
30
|
+
() => progress?.value ?? 0,
|
|
31
|
+
(value) => {
|
|
32
|
+
if (value <= 0) {
|
|
33
|
+
armed.value = true;
|
|
34
|
+
} else if (value >= PRESENTED && armed.value) {
|
|
35
|
+
armed.value = false;
|
|
36
|
+
runOnJS(run)();
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
[progress, run],
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useOxy } from '@oxy.so/services/ui/client';
|
|
3
|
+
import type { GemieAvatarState } from '../components/GemieAvatar';
|
|
4
|
+
import { selectGemieActivity, useGemieActivityStore } from '../lib/activity-store';
|
|
5
|
+
import { acquireActivitySocket } from '../lib/activity-socket';
|
|
6
|
+
import { GEMIES_API_URL } from '../lib/origins';
|
|
7
|
+
|
|
8
|
+
export interface UseGemieActivityOptions {
|
|
9
|
+
/** The API the activity socket connects to. Defaults to the runtime's `apiUrl`. */
|
|
10
|
+
apiUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* What Alia is doing right now, for any surface that wants to show it — an "Ask Alia" button's
|
|
15
|
+
* avatar, a status dot. It is the busiest of:
|
|
16
|
+
*
|
|
17
|
+
* - a turn running in this app (`useConversationThread`, so every chat drives every button), and
|
|
18
|
+
* - her runs for the signed-in person elsewhere, reported by the server over one shared socket
|
|
19
|
+
* (background work, another device), connected only while someone is signed in AND using this.
|
|
20
|
+
*/
|
|
21
|
+
export function useGemieActivity(options: UseGemieActivityOptions = {}): GemieAvatarState {
|
|
22
|
+
const { apiUrl = GEMIES_API_URL } = options;
|
|
23
|
+
const { oxyServices, isAuthenticated } = useOxy();
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!isAuthenticated) return;
|
|
27
|
+
return acquireActivitySocket(apiUrl, () => oxyServices.session.accessToken);
|
|
28
|
+
}, [apiUrl, isAuthenticated, oxyServices]);
|
|
29
|
+
|
|
30
|
+
return useGemieActivityStore(selectGemieActivity);
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as ImagePicker from 'expo-image-picker';
|
|
2
|
+
|
|
3
|
+
export type ImagePickerAsset = {
|
|
4
|
+
uri: string;
|
|
5
|
+
name: string;
|
|
6
|
+
size: number;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type ImagePickerResult = {
|
|
11
|
+
pickImage: () => Promise<ImagePickerAsset[] | undefined>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function useImagePicker(): ImagePickerResult {
|
|
15
|
+
const pickImage = async (): Promise<ImagePickerAsset[] | undefined> => {
|
|
16
|
+
try {
|
|
17
|
+
const result = await ImagePicker.launchImageLibraryAsync({
|
|
18
|
+
allowsMultipleSelection: true,
|
|
19
|
+
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
|
20
|
+
aspect: [4, 3],
|
|
21
|
+
quality: 1,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (!result.canceled && result.assets.length > 0) {
|
|
25
|
+
return result.assets.map((asset) => ({
|
|
26
|
+
uri: asset.uri,
|
|
27
|
+
name: asset.fileName || `image-${Date.now()}.jpg`,
|
|
28
|
+
size: asset.fileSize || 0,
|
|
29
|
+
mimeType: asset.mimeType || 'image/jpeg',
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.warn('Failed to pick image:', error);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return { pickImage };
|
|
38
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { toast } from '@oxy.so/bloom/toast';
|
|
2
|
+
import { useOxy } from '@oxy.so/services/ui/client';
|
|
3
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useReducer, useRef } from 'react';
|
|
5
|
+
import { useLabels } from '../lib/labels';
|
|
6
|
+
import { useGemieApi } from '../runtime/api';
|
|
7
|
+
import { useGemieRuntime } from '../runtime/config';
|
|
8
|
+
import { GEMIES_API_ROUTES } from '../runtime/model';
|
|
9
|
+
import {
|
|
10
|
+
MessageReactionController,
|
|
11
|
+
readMessageReactionUpdate,
|
|
12
|
+
readMessageReactionAcknowledgement,
|
|
13
|
+
type MessageReactionSnapshot,
|
|
14
|
+
} from '../runtime/message-reactions';
|
|
15
|
+
import { updateReactionCaches } from '../runtime/reaction-cache';
|
|
16
|
+
|
|
17
|
+
const NONE: readonly string[] = [];
|
|
18
|
+
|
|
19
|
+
/** Save a reaction's desired state; only pending intent overrides the latest server revision. */
|
|
20
|
+
export function useMessageReactions({
|
|
21
|
+
conversationIds = [],
|
|
22
|
+
onChange,
|
|
23
|
+
enabled = true,
|
|
24
|
+
}: {
|
|
25
|
+
conversationIds?: readonly string[];
|
|
26
|
+
onChange?: (update: MessageReactionSnapshot) => void;
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
} = {}) {
|
|
29
|
+
const { t } = useLabels();
|
|
30
|
+
const api = useGemieApi();
|
|
31
|
+
const { host } = useGemieRuntime();
|
|
32
|
+
const { user } = useOxy();
|
|
33
|
+
const queryClient = useQueryClient();
|
|
34
|
+
const [version, changed] = useReducer((value: number) => value + 1, 0);
|
|
35
|
+
const callbacks = useRef({ onChange, t });
|
|
36
|
+
callbacks.current = { onChange, t };
|
|
37
|
+
const accountId = user?.id;
|
|
38
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: account identity scopes pending reactions
|
|
39
|
+
const controller = useMemo(
|
|
40
|
+
() =>
|
|
41
|
+
new MessageReactionController({
|
|
42
|
+
send: async ({ conversationId, messageId, emoji, active, mutationId }) => {
|
|
43
|
+
const { data } = await api.post<Record<string, unknown>>(
|
|
44
|
+
GEMIES_API_ROUTES.conversations.react(conversationId, messageId),
|
|
45
|
+
{ emoji, active, mutationId },
|
|
46
|
+
);
|
|
47
|
+
const update = readMessageReactionAcknowledgement(
|
|
48
|
+
data,
|
|
49
|
+
conversationId,
|
|
50
|
+
messageId,
|
|
51
|
+
mutationId,
|
|
52
|
+
);
|
|
53
|
+
if (!update) throw new Error('Invalid reaction acknowledgement');
|
|
54
|
+
return update;
|
|
55
|
+
},
|
|
56
|
+
changed,
|
|
57
|
+
confirmed: (update) => {
|
|
58
|
+
updateReactionCaches(queryClient, update);
|
|
59
|
+
callbacks.current.onChange?.(update);
|
|
60
|
+
},
|
|
61
|
+
failed: () => toast.error(callbacks.current.t('chat.reactionFailed')),
|
|
62
|
+
}),
|
|
63
|
+
[api, queryClient, accountId],
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
controller.activate();
|
|
68
|
+
return () => controller.dispose();
|
|
69
|
+
}, [controller]);
|
|
70
|
+
|
|
71
|
+
const subscriptions = JSON.stringify([...new Set(conversationIds)].sort());
|
|
72
|
+
const subscribe = host.subscribeConversationReactions;
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!enabled || !subscribe) return;
|
|
75
|
+
const ids: string[] = JSON.parse(subscriptions);
|
|
76
|
+
const unsubscribers = ids.map((conversationId) =>
|
|
77
|
+
subscribe(conversationId, (value) => {
|
|
78
|
+
const update = readMessageReactionUpdate(value);
|
|
79
|
+
if (update?.conversationId === conversationId) controller.receive(update);
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
return () => {
|
|
83
|
+
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
84
|
+
};
|
|
85
|
+
}, [controller, enabled, subscribe, subscriptions]);
|
|
86
|
+
|
|
87
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: each update refreshes memoized rows
|
|
88
|
+
const reactionsOf = useCallback(
|
|
89
|
+
(
|
|
90
|
+
messageId: string,
|
|
91
|
+
stored: readonly string[] = NONE,
|
|
92
|
+
conversationId?: string,
|
|
93
|
+
revision = 0,
|
|
94
|
+
): readonly string[] =>
|
|
95
|
+
conversationId === undefined
|
|
96
|
+
? stored
|
|
97
|
+
: controller.reactionsOf(conversationId, messageId, stored, revision),
|
|
98
|
+
[controller, version],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const toggle = useCallback(
|
|
102
|
+
(
|
|
103
|
+
messageId: string,
|
|
104
|
+
emoji: string,
|
|
105
|
+
stored: readonly string[] | undefined,
|
|
106
|
+
conversationId: string | undefined,
|
|
107
|
+
revision = 0,
|
|
108
|
+
) => {
|
|
109
|
+
if (!enabled) return;
|
|
110
|
+
if (conversationId === undefined) {
|
|
111
|
+
toast.error(callbacks.current.t('chat.reactionFailed'));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
controller.toggle(conversationId, messageId, emoji, stored ?? NONE, revision);
|
|
115
|
+
},
|
|
116
|
+
[controller, enabled],
|
|
117
|
+
);
|
|
118
|
+
return { reactionsOf, toggle };
|
|
119
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { toast } from '@oxy.so/bloom/toast';
|
|
2
|
+
import { useCallback, useRef } from 'react';
|
|
3
|
+
import { useLabels } from '../lib/labels';
|
|
4
|
+
import { useGemieApi } from '../runtime/api';
|
|
5
|
+
import { GEMIES_API_ROUTES } from '../runtime/model';
|
|
6
|
+
|
|
7
|
+
export type Vote = 'up' | 'down';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Like or dislike a reply; pressing the same vote again retracts it.
|
|
11
|
+
*
|
|
12
|
+
* `conversationId` is the conversation that holds the MESSAGE, which is not always the one on
|
|
13
|
+
* screen — a thread shows several, and an old message's vote sent to the stretch being streamed
|
|
14
|
+
* into would fail quietly. It is `undefined` for a message no conversation holds yet
|
|
15
|
+
* (`Message.unsaved`): a turn that failed or was stopped. There is nothing to record the vote on,
|
|
16
|
+
* and the button cannot be hidden on its own, so the press says so rather than thanking the person
|
|
17
|
+
* for nothing.
|
|
18
|
+
*/
|
|
19
|
+
export function useMessageVote() {
|
|
20
|
+
const { t } = useLabels();
|
|
21
|
+
const api = useGemieApi();
|
|
22
|
+
/** This screen's votes, read to decide whether a press casts or retracts one. */
|
|
23
|
+
const votes = useRef<Record<string, Vote>>({});
|
|
24
|
+
const inFlight = useRef<Set<string>>(new Set());
|
|
25
|
+
|
|
26
|
+
return useCallback(
|
|
27
|
+
(messageId: string, vote: Vote, conversationId: string | undefined) => {
|
|
28
|
+
if (conversationId === undefined) {
|
|
29
|
+
toast.error(t('chat.feedbackFailed'));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (inFlight.current.has(messageId)) return;
|
|
33
|
+
const next = votes.current[messageId] === vote ? null : vote;
|
|
34
|
+
if (next) votes.current[messageId] = next;
|
|
35
|
+
else delete votes.current[messageId];
|
|
36
|
+
inFlight.current.add(messageId);
|
|
37
|
+
api
|
|
38
|
+
.patch(GEMIES_API_ROUTES.conversations.vote(conversationId, messageId), { vote: next })
|
|
39
|
+
.then(() => toast.success(t('chat.thanksFeedback')))
|
|
40
|
+
.catch(() => {
|
|
41
|
+
// Back to what the server holds, so the next press casts it again.
|
|
42
|
+
if (next) delete votes.current[messageId];
|
|
43
|
+
else votes.current[messageId] = vote;
|
|
44
|
+
toast.error(t('chat.feedbackFailed'));
|
|
45
|
+
})
|
|
46
|
+
.finally(() => inFlight.current.delete(messageId));
|
|
47
|
+
},
|
|
48
|
+
[api, t],
|
|
49
|
+
);
|
|
50
|
+
}
|