@shogo-ai/voice 1.10.0 → 2.4.2
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/README.md +89 -0
- package/dist/{chunk-S3S2RNO6.js → chunk-BI6SL35K.js} +1 -184
- package/dist/chunk-IOFWML5L.js +1078 -0
- package/dist/chunk-KMSL5PWK.js +540 -0
- package/dist/chunk-ME3SIZZU.js +581 -0
- package/dist/{chunk-T3T4EBWY.js → chunk-RALZRMFL.js} +6 -2
- package/dist/chunk-TQOBJMEK.js +17 -0
- package/dist/chunk-U5UC7ZVS.js +988 -0
- package/dist/chunk-UW7VQ3S6.js +148 -0
- package/dist/chunk-ZAW6F3YT.js +172 -0
- package/dist/index.cjs +748 -25
- package/dist/index.d.cts +396 -3
- package/dist/index.d.ts +396 -3
- package/dist/index.js +63 -3
- package/dist/live/client.cjs +173 -0
- package/dist/live/client.d.cts +132 -0
- package/dist/live/client.d.ts +132 -0
- package/dist/live/client.js +9 -0
- package/dist/native/index.d.cts +5 -2
- package/dist/native/index.d.ts +5 -2
- package/dist/native/index.js +15 -11
- package/dist/{organicParticlesShaders-DIva0vBO.d.ts → organicParticlesShaders-seZq7jYX.d.cts} +1 -421
- package/dist/{organicParticlesShaders-DIva0vBO.d.cts → organicParticlesShaders-seZq7jYX.d.ts} +1 -421
- package/dist/particlesConfig-0YbdPOdY.d.cts +223 -0
- package/dist/particlesConfig-0YbdPOdY.d.ts +223 -0
- package/dist/react/conversation.cjs +789 -0
- package/dist/react/conversation.d.cts +134 -0
- package/dist/react/conversation.d.ts +134 -0
- package/dist/react/conversation.js +13 -0
- package/dist/react/index.cjs +374 -36
- package/dist/react/index.d.cts +10 -141
- package/dist/react/index.d.ts +10 -141
- package/dist/react/index.js +23 -770
- package/dist/react/visuals.cjs +1048 -0
- package/dist/react/visuals.d.cts +70 -0
- package/dist/react/visuals.d.ts +70 -0
- package/dist/react/visuals.js +10 -0
- package/dist/route/agent.cjs +1047 -85
- package/dist/route/agent.js +3 -3
- package/dist/route/audio-tags.cjs +1047 -85
- package/dist/route/audio-tags.js +3 -3
- package/dist/route/index.cjs +1051 -85
- package/dist/route/index.d.cts +19 -3
- package/dist/route/index.d.ts +19 -3
- package/dist/route/index.js +3 -3
- package/dist/route/music.cjs +1047 -85
- package/dist/route/music.js +3 -3
- package/dist/route/op.cjs +2127 -0
- package/dist/route/op.d.cts +43 -0
- package/dist/route/op.d.ts +43 -0
- package/dist/route/op.js +27 -0
- package/dist/route/signed-url.cjs +1047 -85
- package/dist/route/signed-url.js +3 -3
- package/dist/route/tts-preview.cjs +1047 -85
- package/dist/route/tts-preview.d.cts +6 -4
- package/dist/route/tts-preview.d.ts +6 -4
- package/dist/route/tts-preview.js +3 -3
- package/dist/server.cjs +1047 -85
- package/dist/server.d.cts +40 -8
- package/dist/server.d.ts +40 -8
- package/dist/server.js +2 -2
- package/dist/types-Bfhu-aQH.d.cts +199 -0
- package/dist/types-Bfhu-aQH.d.ts +199 -0
- package/dist/{types-W9y6eMj3.d.ts → types-CadjTXNH.d.cts} +193 -12
- package/dist/{types-W9y6eMj3.d.cts → types-CadjTXNH.d.ts} +193 -12
- package/package.json +21 -1
- package/dist/chunk-B4JC3DK2.js +0 -529
- package/dist/chunk-O362EJQR.js +0 -524
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { B as BaseVoiceConversationOptions, a as BaseVoiceConversationResult } from '../types-Bfhu-aQH.cjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Platform-agnostic memory plumbing for the voice hooks:
|
|
6
|
+
*
|
|
7
|
+
* - `createMemoryAddTool` builds the canonical `add_memory` client
|
|
8
|
+
* tool that POSTs to `memoryAddPath`. Mounted on the convai
|
|
9
|
+
* session's `clientTools` map so the agent can persist user-stated
|
|
10
|
+
* facts via a tool call.
|
|
11
|
+
* - `createMemoryContextInjector` returns an `inject(userText)`
|
|
12
|
+
* function that fetches `limit` relevant memory chunks from
|
|
13
|
+
* `memoryRetrievePath` and forwards them to the active session as
|
|
14
|
+
* a contextual update — but only if the chunks differ from the
|
|
15
|
+
* last batch we sent (so we don't re-inject the same context every
|
|
16
|
+
* turn).
|
|
17
|
+
*
|
|
18
|
+
* Both factories take only the bits they need (a `PostJson`, a couple
|
|
19
|
+
* of refs) so the same code runs on web and native without DOM hooks.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
type ClientToolFn = (params: Record<string, unknown>) => Promise<string> | string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* `useVoiceConversation` (web) — drop-in React hook wrapping
|
|
26
|
+
* `@elevenlabs/react`'s `useConversation` with batteries included:
|
|
27
|
+
*
|
|
28
|
+
* 1. Fetches a signed URL from the consumer's server (default: `/api/voice/signed-url`).
|
|
29
|
+
* 2. Registers the canonical `add_memory` client tool (POST-es to `/api/memory/add`).
|
|
30
|
+
* 3. Auto-injects relevant memory as a contextual update on each user message
|
|
31
|
+
* (POST `/api/memory/retrieve`).
|
|
32
|
+
* 4. Accumulates a plain-text transcript and calls `onTranscript` on disconnect,
|
|
33
|
+
* plus a `pagehide` `navigator.sendBeacon` fallback so nothing is lost on
|
|
34
|
+
* tab close.
|
|
35
|
+
*
|
|
36
|
+
* Consumers can mix in additional `clientTools` and override every path.
|
|
37
|
+
*
|
|
38
|
+
* Requires the caller's app to have `@elevenlabs/react` installed (optional
|
|
39
|
+
* peer dependency). For React Native, import from
|
|
40
|
+
* `@shogo-ai/sdk/voice/native` instead.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
type UseVoiceConversationOptions = BaseVoiceConversationOptions;
|
|
44
|
+
type UseVoiceConversationResult = BaseVoiceConversationResult;
|
|
45
|
+
/**
|
|
46
|
+
* Hook that owns the voice session lifecycle end-to-end. See module docblock
|
|
47
|
+
* for the wire format of the various server endpoints.
|
|
48
|
+
*/
|
|
49
|
+
declare function useVoiceConversation(options: UseVoiceConversationOptions): UseVoiceConversationResult;
|
|
50
|
+
|
|
51
|
+
interface LiveVoiceSessionResponse {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
sdp: string;
|
|
54
|
+
}
|
|
55
|
+
interface LiveTranscriptTurn {
|
|
56
|
+
role: 'user' | 'assistant';
|
|
57
|
+
text: string;
|
|
58
|
+
}
|
|
59
|
+
interface LiveDelegationRequest {
|
|
60
|
+
delegationId: string;
|
|
61
|
+
/** Recent conversation, oldest first, including the turn that triggered the delegation. */
|
|
62
|
+
transcript: LiveTranscriptTurn[];
|
|
63
|
+
}
|
|
64
|
+
interface UseLiveVoiceConversationOptions {
|
|
65
|
+
/** Mint a GPT-Live WebRTC answer from the browser's SDP offer. */
|
|
66
|
+
mintSession: (sdp: string) => Promise<LiveVoiceSessionResponse>;
|
|
67
|
+
/** Function tools for sessions that use Responses delegation. */
|
|
68
|
+
clientTools?: Record<string, ClientToolFn>;
|
|
69
|
+
/**
|
|
70
|
+
* Answer a client delegation. GPT-Live's delegation event carries no task
|
|
71
|
+
* text, so the handler gets the recent transcript instead. A returned
|
|
72
|
+
* string is sent back as spoken commentary for that delegation.
|
|
73
|
+
*/
|
|
74
|
+
onDelegation?: (request: LiveDelegationRequest) => Promise<string | null | void>;
|
|
75
|
+
onError?: (error: unknown) => void;
|
|
76
|
+
onMessage?: (message: {
|
|
77
|
+
source: string;
|
|
78
|
+
message: string;
|
|
79
|
+
}) => void;
|
|
80
|
+
}
|
|
81
|
+
type UseLiveVoiceConversationResult = BaseVoiceConversationResult & {
|
|
82
|
+
/** Recent transcript across sessions started by this hook, oldest first. */
|
|
83
|
+
getTranscript: () => LiveTranscriptTurn[];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* GPT-Live WebRTC conversation hook. The API route is injected so this
|
|
87
|
+
* package remains transport-focused and can be used by SDK consumers too.
|
|
88
|
+
*/
|
|
89
|
+
declare function useLiveVoiceConversation(options: UseLiveVoiceConversationOptions): UseLiveVoiceConversationResult;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* `ShogoVoiceProvider` — root provider that every `useShogoVoice` /
|
|
93
|
+
* `useVoiceConversation` caller needs to live under.
|
|
94
|
+
*
|
|
95
|
+
* Why this exists
|
|
96
|
+
* ---------------
|
|
97
|
+
* `@elevenlabs/react` ≥ 1.1 split `useConversation` into a
|
|
98
|
+
* provider-backed API: every caller of the hook (and therefore every
|
|
99
|
+
* caller of our `useVoiceConversation` / `useShogoVoice` wrapper) must
|
|
100
|
+
* have a `<ConversationProvider>` somewhere above it in the tree.
|
|
101
|
+
* Without it the underlying `useRegisterCallbacks` throws:
|
|
102
|
+
*
|
|
103
|
+
* useRegisterCallbacks must be used within a ConversationProvider
|
|
104
|
+
*
|
|
105
|
+
* Re-exporting the provider here keeps consumer code free of a direct
|
|
106
|
+
* `@elevenlabs/react` import — pods only ever import from
|
|
107
|
+
* `@shogo-ai/sdk/voice/react`, which means we can swap providers (or
|
|
108
|
+
* upgrade across breaking versions) without touching every app.
|
|
109
|
+
*
|
|
110
|
+
* Usage
|
|
111
|
+
* -----
|
|
112
|
+
* Wrap the SDK's voice-aware tree once, near the root of your app:
|
|
113
|
+
*
|
|
114
|
+
* ```tsx
|
|
115
|
+
* import { ShogoVoiceProvider } from '@shogo-ai/sdk/voice/react'
|
|
116
|
+
*
|
|
117
|
+
* export default function Root({ children }: { children: React.ReactNode }) {
|
|
118
|
+
* return <ShogoVoiceProvider>{children}</ShogoVoiceProvider>
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* One provider is enough for an entire app — sibling components that
|
|
123
|
+
* use the voice hook share the same underlying convai session context.
|
|
124
|
+
* Mounting multiple providers is supported but isolates their
|
|
125
|
+
* sessions, so do that intentionally (e.g. two completely separate
|
|
126
|
+
* voice surfaces in one shell).
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
interface ShogoVoiceProviderProps {
|
|
130
|
+
children: React.ReactNode;
|
|
131
|
+
}
|
|
132
|
+
declare function ShogoVoiceProvider(props: ShogoVoiceProviderProps): React.ReactElement;
|
|
133
|
+
|
|
134
|
+
export { type LiveDelegationRequest, type LiveTranscriptTurn, type LiveVoiceSessionResponse, ShogoVoiceProvider, type ShogoVoiceProviderProps, type UseLiveVoiceConversationOptions, type UseLiveVoiceConversationResult, type UseVoiceConversationOptions, type UseVoiceConversationResult, useLiveVoiceConversation, useVoiceConversation };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { B as BaseVoiceConversationOptions, a as BaseVoiceConversationResult } from '../types-Bfhu-aQH.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Platform-agnostic memory plumbing for the voice hooks:
|
|
6
|
+
*
|
|
7
|
+
* - `createMemoryAddTool` builds the canonical `add_memory` client
|
|
8
|
+
* tool that POSTs to `memoryAddPath`. Mounted on the convai
|
|
9
|
+
* session's `clientTools` map so the agent can persist user-stated
|
|
10
|
+
* facts via a tool call.
|
|
11
|
+
* - `createMemoryContextInjector` returns an `inject(userText)`
|
|
12
|
+
* function that fetches `limit` relevant memory chunks from
|
|
13
|
+
* `memoryRetrievePath` and forwards them to the active session as
|
|
14
|
+
* a contextual update — but only if the chunks differ from the
|
|
15
|
+
* last batch we sent (so we don't re-inject the same context every
|
|
16
|
+
* turn).
|
|
17
|
+
*
|
|
18
|
+
* Both factories take only the bits they need (a `PostJson`, a couple
|
|
19
|
+
* of refs) so the same code runs on web and native without DOM hooks.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
type ClientToolFn = (params: Record<string, unknown>) => Promise<string> | string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* `useVoiceConversation` (web) — drop-in React hook wrapping
|
|
26
|
+
* `@elevenlabs/react`'s `useConversation` with batteries included:
|
|
27
|
+
*
|
|
28
|
+
* 1. Fetches a signed URL from the consumer's server (default: `/api/voice/signed-url`).
|
|
29
|
+
* 2. Registers the canonical `add_memory` client tool (POST-es to `/api/memory/add`).
|
|
30
|
+
* 3. Auto-injects relevant memory as a contextual update on each user message
|
|
31
|
+
* (POST `/api/memory/retrieve`).
|
|
32
|
+
* 4. Accumulates a plain-text transcript and calls `onTranscript` on disconnect,
|
|
33
|
+
* plus a `pagehide` `navigator.sendBeacon` fallback so nothing is lost on
|
|
34
|
+
* tab close.
|
|
35
|
+
*
|
|
36
|
+
* Consumers can mix in additional `clientTools` and override every path.
|
|
37
|
+
*
|
|
38
|
+
* Requires the caller's app to have `@elevenlabs/react` installed (optional
|
|
39
|
+
* peer dependency). For React Native, import from
|
|
40
|
+
* `@shogo-ai/sdk/voice/native` instead.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
type UseVoiceConversationOptions = BaseVoiceConversationOptions;
|
|
44
|
+
type UseVoiceConversationResult = BaseVoiceConversationResult;
|
|
45
|
+
/**
|
|
46
|
+
* Hook that owns the voice session lifecycle end-to-end. See module docblock
|
|
47
|
+
* for the wire format of the various server endpoints.
|
|
48
|
+
*/
|
|
49
|
+
declare function useVoiceConversation(options: UseVoiceConversationOptions): UseVoiceConversationResult;
|
|
50
|
+
|
|
51
|
+
interface LiveVoiceSessionResponse {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
sdp: string;
|
|
54
|
+
}
|
|
55
|
+
interface LiveTranscriptTurn {
|
|
56
|
+
role: 'user' | 'assistant';
|
|
57
|
+
text: string;
|
|
58
|
+
}
|
|
59
|
+
interface LiveDelegationRequest {
|
|
60
|
+
delegationId: string;
|
|
61
|
+
/** Recent conversation, oldest first, including the turn that triggered the delegation. */
|
|
62
|
+
transcript: LiveTranscriptTurn[];
|
|
63
|
+
}
|
|
64
|
+
interface UseLiveVoiceConversationOptions {
|
|
65
|
+
/** Mint a GPT-Live WebRTC answer from the browser's SDP offer. */
|
|
66
|
+
mintSession: (sdp: string) => Promise<LiveVoiceSessionResponse>;
|
|
67
|
+
/** Function tools for sessions that use Responses delegation. */
|
|
68
|
+
clientTools?: Record<string, ClientToolFn>;
|
|
69
|
+
/**
|
|
70
|
+
* Answer a client delegation. GPT-Live's delegation event carries no task
|
|
71
|
+
* text, so the handler gets the recent transcript instead. A returned
|
|
72
|
+
* string is sent back as spoken commentary for that delegation.
|
|
73
|
+
*/
|
|
74
|
+
onDelegation?: (request: LiveDelegationRequest) => Promise<string | null | void>;
|
|
75
|
+
onError?: (error: unknown) => void;
|
|
76
|
+
onMessage?: (message: {
|
|
77
|
+
source: string;
|
|
78
|
+
message: string;
|
|
79
|
+
}) => void;
|
|
80
|
+
}
|
|
81
|
+
type UseLiveVoiceConversationResult = BaseVoiceConversationResult & {
|
|
82
|
+
/** Recent transcript across sessions started by this hook, oldest first. */
|
|
83
|
+
getTranscript: () => LiveTranscriptTurn[];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* GPT-Live WebRTC conversation hook. The API route is injected so this
|
|
87
|
+
* package remains transport-focused and can be used by SDK consumers too.
|
|
88
|
+
*/
|
|
89
|
+
declare function useLiveVoiceConversation(options: UseLiveVoiceConversationOptions): UseLiveVoiceConversationResult;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* `ShogoVoiceProvider` — root provider that every `useShogoVoice` /
|
|
93
|
+
* `useVoiceConversation` caller needs to live under.
|
|
94
|
+
*
|
|
95
|
+
* Why this exists
|
|
96
|
+
* ---------------
|
|
97
|
+
* `@elevenlabs/react` ≥ 1.1 split `useConversation` into a
|
|
98
|
+
* provider-backed API: every caller of the hook (and therefore every
|
|
99
|
+
* caller of our `useVoiceConversation` / `useShogoVoice` wrapper) must
|
|
100
|
+
* have a `<ConversationProvider>` somewhere above it in the tree.
|
|
101
|
+
* Without it the underlying `useRegisterCallbacks` throws:
|
|
102
|
+
*
|
|
103
|
+
* useRegisterCallbacks must be used within a ConversationProvider
|
|
104
|
+
*
|
|
105
|
+
* Re-exporting the provider here keeps consumer code free of a direct
|
|
106
|
+
* `@elevenlabs/react` import — pods only ever import from
|
|
107
|
+
* `@shogo-ai/sdk/voice/react`, which means we can swap providers (or
|
|
108
|
+
* upgrade across breaking versions) without touching every app.
|
|
109
|
+
*
|
|
110
|
+
* Usage
|
|
111
|
+
* -----
|
|
112
|
+
* Wrap the SDK's voice-aware tree once, near the root of your app:
|
|
113
|
+
*
|
|
114
|
+
* ```tsx
|
|
115
|
+
* import { ShogoVoiceProvider } from '@shogo-ai/sdk/voice/react'
|
|
116
|
+
*
|
|
117
|
+
* export default function Root({ children }: { children: React.ReactNode }) {
|
|
118
|
+
* return <ShogoVoiceProvider>{children}</ShogoVoiceProvider>
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* One provider is enough for an entire app — sibling components that
|
|
123
|
+
* use the voice hook share the same underlying convai session context.
|
|
124
|
+
* Mounting multiple providers is supported but isolates their
|
|
125
|
+
* sessions, so do that intentionally (e.g. two completely separate
|
|
126
|
+
* voice surfaces in one shell).
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
interface ShogoVoiceProviderProps {
|
|
130
|
+
children: React.ReactNode;
|
|
131
|
+
}
|
|
132
|
+
declare function ShogoVoiceProvider(props: ShogoVoiceProviderProps): React.ReactElement;
|
|
133
|
+
|
|
134
|
+
export { type LiveDelegationRequest, type LiveTranscriptTurn, type LiveVoiceSessionResponse, ShogoVoiceProvider, type ShogoVoiceProviderProps, type UseLiveVoiceConversationOptions, type UseLiveVoiceConversationResult, type UseVoiceConversationOptions, type UseVoiceConversationResult, useLiveVoiceConversation, useVoiceConversation };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ShogoVoiceProvider,
|
|
3
|
+
useLiveVoiceConversation,
|
|
4
|
+
useVoiceConversation
|
|
5
|
+
} from "../chunk-ME3SIZZU.js";
|
|
6
|
+
import "../chunk-ZAW6F3YT.js";
|
|
7
|
+
import "../chunk-Q3TJAJ54.js";
|
|
8
|
+
export {
|
|
9
|
+
ShogoVoiceProvider,
|
|
10
|
+
useLiveVoiceConversation,
|
|
11
|
+
useVoiceConversation
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=conversation.js.map
|