@shogo-ai/voice 1.4.1
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/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/chunk-D2EVSUZX.js +27 -0
- package/dist/chunk-Q3TJAJ54.js +165 -0
- package/dist/chunk-QHDIEE7O.js +453 -0
- package/dist/chunk-S3S2RNO6.js +671 -0
- package/dist/chunk-ZGYHDC5G.js +423 -0
- package/dist/index.cjs +1316 -0
- package/dist/index.d.cts +432 -0
- package/dist/index.d.ts +432 -0
- package/dist/index.js +735 -0
- package/dist/native/index.cjs +1667 -0
- package/dist/native/index.d.cts +285 -0
- package/dist/native/index.d.ts +285 -0
- package/dist/native/index.js +949 -0
- package/dist/organicParticlesShaders-DIva0vBO.d.cts +693 -0
- package/dist/organicParticlesShaders-DIva0vBO.d.ts +693 -0
- package/dist/react/index.cjs +1670 -0
- package/dist/react/index.d.cts +423 -0
- package/dist/react/index.d.ts +423 -0
- package/dist/react/index.js +952 -0
- package/dist/route/agent.cjs +981 -0
- package/dist/route/agent.d.cts +20 -0
- package/dist/route/agent.d.ts +20 -0
- package/dist/route/agent.js +17 -0
- package/dist/route/audio-tags.cjs +975 -0
- package/dist/route/audio-tags.d.cts +16 -0
- package/dist/route/audio-tags.d.ts +16 -0
- package/dist/route/audio-tags.js +13 -0
- package/dist/route/index.cjs +987 -0
- package/dist/route/index.d.cts +115 -0
- package/dist/route/index.d.ts +115 -0
- package/dist/route/index.js +12 -0
- package/dist/route/signed-url.cjs +975 -0
- package/dist/route/signed-url.d.cts +12 -0
- package/dist/route/signed-url.d.ts +12 -0
- package/dist/route/signed-url.js +13 -0
- package/dist/route/tts-preview.cjs +975 -0
- package/dist/route/tts-preview.d.cts +17 -0
- package/dist/route/tts-preview.d.ts +17 -0
- package/dist/route/tts-preview.js +13 -0
- package/dist/server.cjs +999 -0
- package/dist/server.d.cts +88 -0
- package/dist/server.d.ts +88 -0
- package/dist/server.js +11 -0
- package/dist/types-BKJtOUbE.d.cts +352 -0
- package/dist/types-BKJtOUbE.d.ts +352 -0
- package/package.json +148 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { B as BaseVoiceConversationOptions, a as BaseVoiceConversationResult, b as BaseChatConversationOptions, c as BaseChatConversationResult, O as OrganicSphereConfig, d as OrganicParticlesConfig } from '../organicParticlesShaders-DIva0vBO.cjs';
|
|
3
|
+
export { e as BandReactivity, C as ChatClientToolFn, f as ChatConversationStatus, g as ChatToolDescriptor, D as DEFAULT_ORGANIC_PARTICLES_CONFIG, h as DEFAULT_ORGANIC_SPHERE_CONFIG, i as ORGANIC_PARTICLES_FRAGMENT_SHADER, j as ORGANIC_PARTICLES_VERTEX_SHADER, k as ORGANIC_SPHERE_FRAGMENT_SHADER, l as ORGANIC_SPHERE_VERTEX_SHADER, P as PERLIN_4D, r as resolveOrganicParticlesConfig, m as resolveOrganicSphereConfig } from '../organicParticlesShaders-DIva0vBO.cjs';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
6
|
+
import 'ai';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `ShogoVoiceProvider` (native) — root provider that every
|
|
10
|
+
* `useShogoVoice` / `useVoiceConversation` caller from
|
|
11
|
+
* `@shogo-ai/sdk/voice/native` needs to live under.
|
|
12
|
+
*
|
|
13
|
+
* Mirrors the web provider in [packages/sdk/src/voice/react/ShogoVoiceProvider.tsx]
|
|
14
|
+
* but wraps `@elevenlabs/react-native`'s `ConversationProvider` instead
|
|
15
|
+
* of `@elevenlabs/react`'s. Importantly, just importing
|
|
16
|
+
* `@elevenlabs/react-native` runs its module side-effects:
|
|
17
|
+
*
|
|
18
|
+
* - `registerGlobals()` from `@livekit/react-native` polyfills the
|
|
19
|
+
* WebRTC globals the underlying ElevenLabs client expects.
|
|
20
|
+
* - `setSetupStrategy(reactNativeSessionSetup)` swaps the voice
|
|
21
|
+
* session bootstrapper to start a native iOS/Android AudioSession
|
|
22
|
+
* before opening the LiveKit connection.
|
|
23
|
+
*
|
|
24
|
+
* That's why this provider is the single recommended import path on
|
|
25
|
+
* native — pulling in `@elevenlabs/react-native` somewhere near the
|
|
26
|
+
* root of the app is what makes the native voice path work at all.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
interface ShogoVoiceProviderProps {
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Optional default agent id forwarded to `ConversationProvider`.
|
|
33
|
+
* Omit if your app passes `signedUrl` per-session via
|
|
34
|
+
* `useVoiceConversation` (the recommended Shogo flow).
|
|
35
|
+
*/
|
|
36
|
+
agentId?: string;
|
|
37
|
+
}
|
|
38
|
+
declare function ShogoVoiceProvider(props: ShogoVoiceProviderProps): React.ReactElement;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `useVoiceConversation` (native) — drop-in React Native hook wrapping
|
|
42
|
+
* `@elevenlabs/react-native`'s `useConversation` with the same battery-
|
|
43
|
+
* included behaviour as the web hook (signed-URL fetch, `add_memory`
|
|
44
|
+
* tool, contextual memory injection, transcript persistence).
|
|
45
|
+
*
|
|
46
|
+
* Differences from the web implementation:
|
|
47
|
+
*
|
|
48
|
+
* - Imports from `@elevenlabs/react-native` rather than
|
|
49
|
+
* `@elevenlabs/react`. The RN package re-exports the same
|
|
50
|
+
* `useConversation` API and additionally configures WebRTC +
|
|
51
|
+
* native AudioSession internally, so the wrapper logic is
|
|
52
|
+
* identical.
|
|
53
|
+
* - There is no `navigator.mediaDevices.getUserMedia` pre-call —
|
|
54
|
+
* LiveKit handles mic permission negotiation when the session
|
|
55
|
+
* opens. Consumers can pass an optional `requestPermissions`
|
|
56
|
+
* callback (typically wired to `expo-av` or
|
|
57
|
+
* `react-native-permissions`) which is awaited before the
|
|
58
|
+
* signed-URL fetch.
|
|
59
|
+
* - The browser's `pagehide` + `navigator.sendBeacon` flush is
|
|
60
|
+
* replaced with an `AppState.addEventListener('change', ...)`
|
|
61
|
+
* handler that fires a regular `fetch` POST when the app moves
|
|
62
|
+
* to the background. There's no native equivalent to `sendBeacon`,
|
|
63
|
+
* but the OS keeps the JS context alive long enough during a
|
|
64
|
+
* background transition for the request to leave the device.
|
|
65
|
+
*
|
|
66
|
+
* Requires the host app to install `@elevenlabs/react-native`,
|
|
67
|
+
* `@livekit/react-native`, and `@livekit/react-native-webrtc`. All
|
|
68
|
+
* three are optional peer dependencies of `@shogo-ai/sdk`.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
interface UseVoiceConversationOptions extends BaseVoiceConversationOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Optional pre-flight microphone permission hook. Called once
|
|
74
|
+
* before each `start()` (and the `start()` triggered inside
|
|
75
|
+
* `restart()`). Throw to abort the session — the rejection
|
|
76
|
+
* propagates out through `start()` so the consumer can present a
|
|
77
|
+
* permissions UI.
|
|
78
|
+
*
|
|
79
|
+
* Typical wiring with `expo-av`:
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* import * as Audio from 'expo-av'
|
|
83
|
+
* useVoiceConversation({
|
|
84
|
+
* characterName: 'Shogo',
|
|
85
|
+
* requestPermissions: async () => {
|
|
86
|
+
* const { status } = await Audio.requestPermissionsAsync()
|
|
87
|
+
* if (status !== 'granted') {
|
|
88
|
+
* throw new Error('Microphone permission denied')
|
|
89
|
+
* }
|
|
90
|
+
* },
|
|
91
|
+
* })
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* If omitted, the SDK relies on LiveKit's internal permission flow
|
|
95
|
+
* (which presents the OS prompt the first time the audio track
|
|
96
|
+
* starts). Wiring this explicitly gives consumers a deterministic
|
|
97
|
+
* place to surface a custom denial UI.
|
|
98
|
+
*/
|
|
99
|
+
requestPermissions?: () => Promise<void> | void;
|
|
100
|
+
}
|
|
101
|
+
type UseVoiceConversationResult = BaseVoiceConversationResult;
|
|
102
|
+
/**
|
|
103
|
+
* Native hook that owns the voice session lifecycle end-to-end. See
|
|
104
|
+
* the module docblock for the wire format of the various server
|
|
105
|
+
* endpoints.
|
|
106
|
+
*/
|
|
107
|
+
declare function useVoiceConversation(options: UseVoiceConversationOptions): UseVoiceConversationResult;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* `useShogoVoice` (native) — zero-config voice hook for Expo / React
|
|
111
|
+
* Native pod apps.
|
|
112
|
+
*
|
|
113
|
+
* Mirrors the web counterpart in
|
|
114
|
+
* [packages/sdk/src/voice/react/useShogoVoice.ts] — same options, same
|
|
115
|
+
* result shape — so a pod that already drives the web sphere can swap
|
|
116
|
+
* its import path from `@shogo-ai/sdk/voice/react` to
|
|
117
|
+
* `@shogo-ai/sdk/voice/native` and keep the rest of its code unchanged.
|
|
118
|
+
*
|
|
119
|
+
* Defaults applied here:
|
|
120
|
+
*
|
|
121
|
+
* - `characterName: 'Shogo'`
|
|
122
|
+
* - `signedUrlPath: '/api/voice/signed-url'`
|
|
123
|
+
* - `fetchCredentials: 'include'` — RN apps are always cross-origin
|
|
124
|
+
* to the Shogo API, so `same-origin` (the web default) makes no
|
|
125
|
+
* sense; `include` carries any cookies the consumer's auth flow
|
|
126
|
+
* stored in the native cookie jar.
|
|
127
|
+
*
|
|
128
|
+
* Provider requirement
|
|
129
|
+
* --------------------
|
|
130
|
+
* Mount `<ShogoVoiceProvider>` near the root of your app (it wraps
|
|
131
|
+
* `@elevenlabs/react-native`'s `ConversationProvider`). Without it
|
|
132
|
+
* the underlying `useRegisterCallbacks` throws:
|
|
133
|
+
*
|
|
134
|
+
* useRegisterCallbacks must be used within a ConversationProvider
|
|
135
|
+
*
|
|
136
|
+
* Just importing `@elevenlabs/react-native` (which `ShogoVoiceProvider`
|
|
137
|
+
* does for you) is also what wires up the WebRTC polyfills and the
|
|
138
|
+
* native AudioSession setup strategy, so don't lazy-import the
|
|
139
|
+
* provider — keep it in the tree from app start.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```tsx
|
|
143
|
+
* import {
|
|
144
|
+
* ShogoVoiceProvider,
|
|
145
|
+
* useShogoVoice,
|
|
146
|
+
* } from '@shogo-ai/sdk/voice/native'
|
|
147
|
+
*
|
|
148
|
+
* function VoiceButton() {
|
|
149
|
+
* const { start, end, status } = useShogoVoice()
|
|
150
|
+
* const active = status === 'connected' || status === 'connecting'
|
|
151
|
+
* return (
|
|
152
|
+
* <Pressable onPress={active ? end : start}>
|
|
153
|
+
* <Text>{active ? 'End call' : 'Talk to Shogo'}</Text>
|
|
154
|
+
* </Pressable>
|
|
155
|
+
* )
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
* export default function App() {
|
|
159
|
+
* return (
|
|
160
|
+
* <ShogoVoiceProvider>
|
|
161
|
+
* <VoiceButton />
|
|
162
|
+
* </ShogoVoiceProvider>
|
|
163
|
+
* )
|
|
164
|
+
* }
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* Named secondary agents
|
|
168
|
+
* ----------------------
|
|
169
|
+
* Same as on web: declare extra agents in `shogo.config.json#agents`,
|
|
170
|
+
* run `bunx shogo deploy`, then pass `agentName` to drive a specific
|
|
171
|
+
* persona. `useShogoVoice({ agentName })` and `useShogoChat({
|
|
172
|
+
* agentName })` resolve to the same `ProjectAgent` row.
|
|
173
|
+
*
|
|
174
|
+
* Per-user dynamic variables
|
|
175
|
+
* --------------------------
|
|
176
|
+
* Pass `dynamicVariables: { user_display_name, relationship_stage }`
|
|
177
|
+
* (or any keys the agent prompt references) to surface per-user
|
|
178
|
+
* fields from your local `Companion` row to ElevenLabs at session
|
|
179
|
+
* start. The SDK's built-ins (`character_name`, `user_context`,
|
|
180
|
+
* `conversation_id`) always win on collision.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
type UseShogoVoiceOptions = Partial<UseVoiceConversationOptions>;
|
|
184
|
+
declare function useShogoVoice(opts?: UseShogoVoiceOptions): UseVoiceConversationResult;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* `useChatConversation` (native) — text-only sibling of
|
|
188
|
+
* {@link useVoiceConversation}.
|
|
189
|
+
*
|
|
190
|
+
* Mirrors the web counterpart in
|
|
191
|
+
* [packages/sdk/src/voice/react/useChatConversation.ts] — same options,
|
|
192
|
+
* same result shape — so a pod that already drives the web chat panel
|
|
193
|
+
* can swap its import path from `@shogo-ai/sdk/voice/react` to
|
|
194
|
+
* `@shogo-ai/sdk/voice/native` and keep the rest of its code unchanged.
|
|
195
|
+
*
|
|
196
|
+
* Differences from the web implementation:
|
|
197
|
+
*
|
|
198
|
+
* - Default `fetchCredentials` flips from `'same-origin'` (web) to
|
|
199
|
+
* `'omit'` when `shogoApiKey` is set, or `'include'` otherwise.
|
|
200
|
+
* RN apps are always cross-origin to the backend, so `same-origin`
|
|
201
|
+
* makes no sense; `include` carries any cookies the consumer's
|
|
202
|
+
* auth flow stored in the native cookie jar.
|
|
203
|
+
* - No DOM hooks. `@ai-sdk/react` is platform-agnostic; the import
|
|
204
|
+
* surface used here (`useChat`, `DefaultChatTransport`) runs the
|
|
205
|
+
* same way on RN/Hermes/JSC.
|
|
206
|
+
*
|
|
207
|
+
* Requires the host app to install `@ai-sdk/react` and `ai`. Both are
|
|
208
|
+
* optional peer deps of `@shogo-ai/sdk`.
|
|
209
|
+
*
|
|
210
|
+
* @experimental V1 surface — shape may evolve before promotion.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
type UseChatConversationOptions = BaseChatConversationOptions;
|
|
214
|
+
type UseChatConversationResult = BaseChatConversationResult;
|
|
215
|
+
declare function useChatConversation(options?: UseChatConversationOptions): UseChatConversationResult;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* `useShogoChat` (native) — zero-config text-chat hook for Expo / React
|
|
219
|
+
* Native pod apps.
|
|
220
|
+
*
|
|
221
|
+
* Mirrors the web counterpart in
|
|
222
|
+
* [packages/sdk/src/voice/react/useShogoChat.ts] — same options, same
|
|
223
|
+
* result shape — so a pod that already drives the web chat panel can
|
|
224
|
+
* swap its import path from `@shogo-ai/sdk/voice/react` to
|
|
225
|
+
* `@shogo-ai/sdk/voice/native` and keep the rest of its code unchanged.
|
|
226
|
+
*
|
|
227
|
+
* Defaults applied here:
|
|
228
|
+
*
|
|
229
|
+
* - `api: '/api/chat/turn'`
|
|
230
|
+
* - `fetchCredentials: 'include'` — RN apps are always cross-origin
|
|
231
|
+
* to the Shogo API, so `same-origin` (the web default) makes no
|
|
232
|
+
* sense; `include` carries any cookies the consumer's auth flow
|
|
233
|
+
* stored in the native cookie jar.
|
|
234
|
+
*
|
|
235
|
+
* For external SDK consumers using a Shogo API key, drive
|
|
236
|
+
* `useChatConversation({ shogoApiKey, projectId, ... })` directly —
|
|
237
|
+
* the bearer path defaults to `'omit'` automatically.
|
|
238
|
+
*
|
|
239
|
+
* @experimental V1 surface — shape may evolve before promotion.
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
type UseShogoChatOptions = Partial<UseChatConversationOptions>;
|
|
243
|
+
declare function useShogoChat(opts?: UseShogoChatOptions): UseChatConversationResult;
|
|
244
|
+
|
|
245
|
+
interface OrganicSphereProps {
|
|
246
|
+
/**
|
|
247
|
+
* Returns the current agent-output frequency buffer (length = fftSize,
|
|
248
|
+
* values 0–255). Typically `useVoiceConversation().getOutputByteFrequencyData`.
|
|
249
|
+
*/
|
|
250
|
+
getFrequencyData?: () => Uint8Array | null;
|
|
251
|
+
/**
|
|
252
|
+
* Whether audio is live. When `false` the sphere settles into its
|
|
253
|
+
* idle pose (no pulsing). Purely cosmetic — the component keeps the
|
|
254
|
+
* render loop running either way.
|
|
255
|
+
*
|
|
256
|
+
* @default true
|
|
257
|
+
*/
|
|
258
|
+
active?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Full configuration object (partial). Any unspecified keys fall back
|
|
261
|
+
* to `DEFAULT_ORGANIC_SPHERE_CONFIG`.
|
|
262
|
+
*/
|
|
263
|
+
config?: Partial<OrganicSphereConfig>;
|
|
264
|
+
/** Inline style for the wrapping `<GLView>`. Size the parent — the GLView fills it. */
|
|
265
|
+
style?: StyleProp<ViewStyle>;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Audio-reactive organic sphere for React Native (Expo). See the
|
|
269
|
+
* module docblock for usage.
|
|
270
|
+
*/
|
|
271
|
+
declare function OrganicSphere({ getFrequencyData, active, config: configProp, style, }: OrganicSphereProps): react_jsx_runtime.JSX.Element;
|
|
272
|
+
|
|
273
|
+
interface OrganicParticlesProps {
|
|
274
|
+
getFrequencyData?: () => Uint8Array | null;
|
|
275
|
+
active?: boolean;
|
|
276
|
+
config?: Partial<OrganicParticlesConfig>;
|
|
277
|
+
style?: StyleProp<ViewStyle>;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Audio-reactive particle cloud for React Native (Expo). See the
|
|
281
|
+
* module docblock for usage.
|
|
282
|
+
*/
|
|
283
|
+
declare function OrganicParticles({ getFrequencyData, active, config: configProp, style, }: OrganicParticlesProps): react_jsx_runtime.JSX.Element;
|
|
284
|
+
|
|
285
|
+
export { BaseChatConversationOptions, BaseChatConversationResult, OrganicParticles, OrganicParticlesConfig, type OrganicParticlesProps, OrganicSphere, OrganicSphereConfig, type OrganicSphereProps, ShogoVoiceProvider, type ShogoVoiceProviderProps, type UseChatConversationOptions, type UseChatConversationResult, type UseShogoChatOptions, type UseShogoVoiceOptions, type UseVoiceConversationOptions, type UseVoiceConversationResult, useChatConversation, useShogoChat, useShogoVoice, useVoiceConversation };
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { B as BaseVoiceConversationOptions, a as BaseVoiceConversationResult, b as BaseChatConversationOptions, c as BaseChatConversationResult, O as OrganicSphereConfig, d as OrganicParticlesConfig } from '../organicParticlesShaders-DIva0vBO.js';
|
|
3
|
+
export { e as BandReactivity, C as ChatClientToolFn, f as ChatConversationStatus, g as ChatToolDescriptor, D as DEFAULT_ORGANIC_PARTICLES_CONFIG, h as DEFAULT_ORGANIC_SPHERE_CONFIG, i as ORGANIC_PARTICLES_FRAGMENT_SHADER, j as ORGANIC_PARTICLES_VERTEX_SHADER, k as ORGANIC_SPHERE_FRAGMENT_SHADER, l as ORGANIC_SPHERE_VERTEX_SHADER, P as PERLIN_4D, r as resolveOrganicParticlesConfig, m as resolveOrganicSphereConfig } from '../organicParticlesShaders-DIva0vBO.js';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
6
|
+
import 'ai';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `ShogoVoiceProvider` (native) — root provider that every
|
|
10
|
+
* `useShogoVoice` / `useVoiceConversation` caller from
|
|
11
|
+
* `@shogo-ai/sdk/voice/native` needs to live under.
|
|
12
|
+
*
|
|
13
|
+
* Mirrors the web provider in [packages/sdk/src/voice/react/ShogoVoiceProvider.tsx]
|
|
14
|
+
* but wraps `@elevenlabs/react-native`'s `ConversationProvider` instead
|
|
15
|
+
* of `@elevenlabs/react`'s. Importantly, just importing
|
|
16
|
+
* `@elevenlabs/react-native` runs its module side-effects:
|
|
17
|
+
*
|
|
18
|
+
* - `registerGlobals()` from `@livekit/react-native` polyfills the
|
|
19
|
+
* WebRTC globals the underlying ElevenLabs client expects.
|
|
20
|
+
* - `setSetupStrategy(reactNativeSessionSetup)` swaps the voice
|
|
21
|
+
* session bootstrapper to start a native iOS/Android AudioSession
|
|
22
|
+
* before opening the LiveKit connection.
|
|
23
|
+
*
|
|
24
|
+
* That's why this provider is the single recommended import path on
|
|
25
|
+
* native — pulling in `@elevenlabs/react-native` somewhere near the
|
|
26
|
+
* root of the app is what makes the native voice path work at all.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
interface ShogoVoiceProviderProps {
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Optional default agent id forwarded to `ConversationProvider`.
|
|
33
|
+
* Omit if your app passes `signedUrl` per-session via
|
|
34
|
+
* `useVoiceConversation` (the recommended Shogo flow).
|
|
35
|
+
*/
|
|
36
|
+
agentId?: string;
|
|
37
|
+
}
|
|
38
|
+
declare function ShogoVoiceProvider(props: ShogoVoiceProviderProps): React.ReactElement;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `useVoiceConversation` (native) — drop-in React Native hook wrapping
|
|
42
|
+
* `@elevenlabs/react-native`'s `useConversation` with the same battery-
|
|
43
|
+
* included behaviour as the web hook (signed-URL fetch, `add_memory`
|
|
44
|
+
* tool, contextual memory injection, transcript persistence).
|
|
45
|
+
*
|
|
46
|
+
* Differences from the web implementation:
|
|
47
|
+
*
|
|
48
|
+
* - Imports from `@elevenlabs/react-native` rather than
|
|
49
|
+
* `@elevenlabs/react`. The RN package re-exports the same
|
|
50
|
+
* `useConversation` API and additionally configures WebRTC +
|
|
51
|
+
* native AudioSession internally, so the wrapper logic is
|
|
52
|
+
* identical.
|
|
53
|
+
* - There is no `navigator.mediaDevices.getUserMedia` pre-call —
|
|
54
|
+
* LiveKit handles mic permission negotiation when the session
|
|
55
|
+
* opens. Consumers can pass an optional `requestPermissions`
|
|
56
|
+
* callback (typically wired to `expo-av` or
|
|
57
|
+
* `react-native-permissions`) which is awaited before the
|
|
58
|
+
* signed-URL fetch.
|
|
59
|
+
* - The browser's `pagehide` + `navigator.sendBeacon` flush is
|
|
60
|
+
* replaced with an `AppState.addEventListener('change', ...)`
|
|
61
|
+
* handler that fires a regular `fetch` POST when the app moves
|
|
62
|
+
* to the background. There's no native equivalent to `sendBeacon`,
|
|
63
|
+
* but the OS keeps the JS context alive long enough during a
|
|
64
|
+
* background transition for the request to leave the device.
|
|
65
|
+
*
|
|
66
|
+
* Requires the host app to install `@elevenlabs/react-native`,
|
|
67
|
+
* `@livekit/react-native`, and `@livekit/react-native-webrtc`. All
|
|
68
|
+
* three are optional peer dependencies of `@shogo-ai/sdk`.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
interface UseVoiceConversationOptions extends BaseVoiceConversationOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Optional pre-flight microphone permission hook. Called once
|
|
74
|
+
* before each `start()` (and the `start()` triggered inside
|
|
75
|
+
* `restart()`). Throw to abort the session — the rejection
|
|
76
|
+
* propagates out through `start()` so the consumer can present a
|
|
77
|
+
* permissions UI.
|
|
78
|
+
*
|
|
79
|
+
* Typical wiring with `expo-av`:
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* import * as Audio from 'expo-av'
|
|
83
|
+
* useVoiceConversation({
|
|
84
|
+
* characterName: 'Shogo',
|
|
85
|
+
* requestPermissions: async () => {
|
|
86
|
+
* const { status } = await Audio.requestPermissionsAsync()
|
|
87
|
+
* if (status !== 'granted') {
|
|
88
|
+
* throw new Error('Microphone permission denied')
|
|
89
|
+
* }
|
|
90
|
+
* },
|
|
91
|
+
* })
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* If omitted, the SDK relies on LiveKit's internal permission flow
|
|
95
|
+
* (which presents the OS prompt the first time the audio track
|
|
96
|
+
* starts). Wiring this explicitly gives consumers a deterministic
|
|
97
|
+
* place to surface a custom denial UI.
|
|
98
|
+
*/
|
|
99
|
+
requestPermissions?: () => Promise<void> | void;
|
|
100
|
+
}
|
|
101
|
+
type UseVoiceConversationResult = BaseVoiceConversationResult;
|
|
102
|
+
/**
|
|
103
|
+
* Native hook that owns the voice session lifecycle end-to-end. See
|
|
104
|
+
* the module docblock for the wire format of the various server
|
|
105
|
+
* endpoints.
|
|
106
|
+
*/
|
|
107
|
+
declare function useVoiceConversation(options: UseVoiceConversationOptions): UseVoiceConversationResult;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* `useShogoVoice` (native) — zero-config voice hook for Expo / React
|
|
111
|
+
* Native pod apps.
|
|
112
|
+
*
|
|
113
|
+
* Mirrors the web counterpart in
|
|
114
|
+
* [packages/sdk/src/voice/react/useShogoVoice.ts] — same options, same
|
|
115
|
+
* result shape — so a pod that already drives the web sphere can swap
|
|
116
|
+
* its import path from `@shogo-ai/sdk/voice/react` to
|
|
117
|
+
* `@shogo-ai/sdk/voice/native` and keep the rest of its code unchanged.
|
|
118
|
+
*
|
|
119
|
+
* Defaults applied here:
|
|
120
|
+
*
|
|
121
|
+
* - `characterName: 'Shogo'`
|
|
122
|
+
* - `signedUrlPath: '/api/voice/signed-url'`
|
|
123
|
+
* - `fetchCredentials: 'include'` — RN apps are always cross-origin
|
|
124
|
+
* to the Shogo API, so `same-origin` (the web default) makes no
|
|
125
|
+
* sense; `include` carries any cookies the consumer's auth flow
|
|
126
|
+
* stored in the native cookie jar.
|
|
127
|
+
*
|
|
128
|
+
* Provider requirement
|
|
129
|
+
* --------------------
|
|
130
|
+
* Mount `<ShogoVoiceProvider>` near the root of your app (it wraps
|
|
131
|
+
* `@elevenlabs/react-native`'s `ConversationProvider`). Without it
|
|
132
|
+
* the underlying `useRegisterCallbacks` throws:
|
|
133
|
+
*
|
|
134
|
+
* useRegisterCallbacks must be used within a ConversationProvider
|
|
135
|
+
*
|
|
136
|
+
* Just importing `@elevenlabs/react-native` (which `ShogoVoiceProvider`
|
|
137
|
+
* does for you) is also what wires up the WebRTC polyfills and the
|
|
138
|
+
* native AudioSession setup strategy, so don't lazy-import the
|
|
139
|
+
* provider — keep it in the tree from app start.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```tsx
|
|
143
|
+
* import {
|
|
144
|
+
* ShogoVoiceProvider,
|
|
145
|
+
* useShogoVoice,
|
|
146
|
+
* } from '@shogo-ai/sdk/voice/native'
|
|
147
|
+
*
|
|
148
|
+
* function VoiceButton() {
|
|
149
|
+
* const { start, end, status } = useShogoVoice()
|
|
150
|
+
* const active = status === 'connected' || status === 'connecting'
|
|
151
|
+
* return (
|
|
152
|
+
* <Pressable onPress={active ? end : start}>
|
|
153
|
+
* <Text>{active ? 'End call' : 'Talk to Shogo'}</Text>
|
|
154
|
+
* </Pressable>
|
|
155
|
+
* )
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
* export default function App() {
|
|
159
|
+
* return (
|
|
160
|
+
* <ShogoVoiceProvider>
|
|
161
|
+
* <VoiceButton />
|
|
162
|
+
* </ShogoVoiceProvider>
|
|
163
|
+
* )
|
|
164
|
+
* }
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* Named secondary agents
|
|
168
|
+
* ----------------------
|
|
169
|
+
* Same as on web: declare extra agents in `shogo.config.json#agents`,
|
|
170
|
+
* run `bunx shogo deploy`, then pass `agentName` to drive a specific
|
|
171
|
+
* persona. `useShogoVoice({ agentName })` and `useShogoChat({
|
|
172
|
+
* agentName })` resolve to the same `ProjectAgent` row.
|
|
173
|
+
*
|
|
174
|
+
* Per-user dynamic variables
|
|
175
|
+
* --------------------------
|
|
176
|
+
* Pass `dynamicVariables: { user_display_name, relationship_stage }`
|
|
177
|
+
* (or any keys the agent prompt references) to surface per-user
|
|
178
|
+
* fields from your local `Companion` row to ElevenLabs at session
|
|
179
|
+
* start. The SDK's built-ins (`character_name`, `user_context`,
|
|
180
|
+
* `conversation_id`) always win on collision.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
type UseShogoVoiceOptions = Partial<UseVoiceConversationOptions>;
|
|
184
|
+
declare function useShogoVoice(opts?: UseShogoVoiceOptions): UseVoiceConversationResult;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* `useChatConversation` (native) — text-only sibling of
|
|
188
|
+
* {@link useVoiceConversation}.
|
|
189
|
+
*
|
|
190
|
+
* Mirrors the web counterpart in
|
|
191
|
+
* [packages/sdk/src/voice/react/useChatConversation.ts] — same options,
|
|
192
|
+
* same result shape — so a pod that already drives the web chat panel
|
|
193
|
+
* can swap its import path from `@shogo-ai/sdk/voice/react` to
|
|
194
|
+
* `@shogo-ai/sdk/voice/native` and keep the rest of its code unchanged.
|
|
195
|
+
*
|
|
196
|
+
* Differences from the web implementation:
|
|
197
|
+
*
|
|
198
|
+
* - Default `fetchCredentials` flips from `'same-origin'` (web) to
|
|
199
|
+
* `'omit'` when `shogoApiKey` is set, or `'include'` otherwise.
|
|
200
|
+
* RN apps are always cross-origin to the backend, so `same-origin`
|
|
201
|
+
* makes no sense; `include` carries any cookies the consumer's
|
|
202
|
+
* auth flow stored in the native cookie jar.
|
|
203
|
+
* - No DOM hooks. `@ai-sdk/react` is platform-agnostic; the import
|
|
204
|
+
* surface used here (`useChat`, `DefaultChatTransport`) runs the
|
|
205
|
+
* same way on RN/Hermes/JSC.
|
|
206
|
+
*
|
|
207
|
+
* Requires the host app to install `@ai-sdk/react` and `ai`. Both are
|
|
208
|
+
* optional peer deps of `@shogo-ai/sdk`.
|
|
209
|
+
*
|
|
210
|
+
* @experimental V1 surface — shape may evolve before promotion.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
type UseChatConversationOptions = BaseChatConversationOptions;
|
|
214
|
+
type UseChatConversationResult = BaseChatConversationResult;
|
|
215
|
+
declare function useChatConversation(options?: UseChatConversationOptions): UseChatConversationResult;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* `useShogoChat` (native) — zero-config text-chat hook for Expo / React
|
|
219
|
+
* Native pod apps.
|
|
220
|
+
*
|
|
221
|
+
* Mirrors the web counterpart in
|
|
222
|
+
* [packages/sdk/src/voice/react/useShogoChat.ts] — same options, same
|
|
223
|
+
* result shape — so a pod that already drives the web chat panel can
|
|
224
|
+
* swap its import path from `@shogo-ai/sdk/voice/react` to
|
|
225
|
+
* `@shogo-ai/sdk/voice/native` and keep the rest of its code unchanged.
|
|
226
|
+
*
|
|
227
|
+
* Defaults applied here:
|
|
228
|
+
*
|
|
229
|
+
* - `api: '/api/chat/turn'`
|
|
230
|
+
* - `fetchCredentials: 'include'` — RN apps are always cross-origin
|
|
231
|
+
* to the Shogo API, so `same-origin` (the web default) makes no
|
|
232
|
+
* sense; `include` carries any cookies the consumer's auth flow
|
|
233
|
+
* stored in the native cookie jar.
|
|
234
|
+
*
|
|
235
|
+
* For external SDK consumers using a Shogo API key, drive
|
|
236
|
+
* `useChatConversation({ shogoApiKey, projectId, ... })` directly —
|
|
237
|
+
* the bearer path defaults to `'omit'` automatically.
|
|
238
|
+
*
|
|
239
|
+
* @experimental V1 surface — shape may evolve before promotion.
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
type UseShogoChatOptions = Partial<UseChatConversationOptions>;
|
|
243
|
+
declare function useShogoChat(opts?: UseShogoChatOptions): UseChatConversationResult;
|
|
244
|
+
|
|
245
|
+
interface OrganicSphereProps {
|
|
246
|
+
/**
|
|
247
|
+
* Returns the current agent-output frequency buffer (length = fftSize,
|
|
248
|
+
* values 0–255). Typically `useVoiceConversation().getOutputByteFrequencyData`.
|
|
249
|
+
*/
|
|
250
|
+
getFrequencyData?: () => Uint8Array | null;
|
|
251
|
+
/**
|
|
252
|
+
* Whether audio is live. When `false` the sphere settles into its
|
|
253
|
+
* idle pose (no pulsing). Purely cosmetic — the component keeps the
|
|
254
|
+
* render loop running either way.
|
|
255
|
+
*
|
|
256
|
+
* @default true
|
|
257
|
+
*/
|
|
258
|
+
active?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Full configuration object (partial). Any unspecified keys fall back
|
|
261
|
+
* to `DEFAULT_ORGANIC_SPHERE_CONFIG`.
|
|
262
|
+
*/
|
|
263
|
+
config?: Partial<OrganicSphereConfig>;
|
|
264
|
+
/** Inline style for the wrapping `<GLView>`. Size the parent — the GLView fills it. */
|
|
265
|
+
style?: StyleProp<ViewStyle>;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Audio-reactive organic sphere for React Native (Expo). See the
|
|
269
|
+
* module docblock for usage.
|
|
270
|
+
*/
|
|
271
|
+
declare function OrganicSphere({ getFrequencyData, active, config: configProp, style, }: OrganicSphereProps): react_jsx_runtime.JSX.Element;
|
|
272
|
+
|
|
273
|
+
interface OrganicParticlesProps {
|
|
274
|
+
getFrequencyData?: () => Uint8Array | null;
|
|
275
|
+
active?: boolean;
|
|
276
|
+
config?: Partial<OrganicParticlesConfig>;
|
|
277
|
+
style?: StyleProp<ViewStyle>;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Audio-reactive particle cloud for React Native (Expo). See the
|
|
281
|
+
* module docblock for usage.
|
|
282
|
+
*/
|
|
283
|
+
declare function OrganicParticles({ getFrequencyData, active, config: configProp, style, }: OrganicParticlesProps): react_jsx_runtime.JSX.Element;
|
|
284
|
+
|
|
285
|
+
export { BaseChatConversationOptions, BaseChatConversationResult, OrganicParticles, OrganicParticlesConfig, type OrganicParticlesProps, OrganicSphere, OrganicSphereConfig, type OrganicSphereProps, ShogoVoiceProvider, type ShogoVoiceProviderProps, type UseChatConversationOptions, type UseChatConversationResult, type UseShogoChatOptions, type UseShogoVoiceOptions, type UseVoiceConversationOptions, type UseVoiceConversationResult, useChatConversation, useShogoChat, useShogoVoice, useVoiceConversation };
|