@d-id/client-sdk 2.0.10 → 3.0.0-staging.412

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.
Files changed (49) hide show
  1. package/README.md +54 -265
  2. package/dist/{index-K6rHpqny.js → index-BLrKDuV_.js} +3002 -2825
  3. package/dist/index.js +23 -31
  4. package/dist/index.umd.cjs +5 -5
  5. package/dist/{livekit-manager-25aUaO_G.js → livekit-manager-Cfb9x2ei.js} +53 -50
  6. package/dist/src/api/agents.d.ts +1 -1
  7. package/dist/src/api/apiClient.d.ts +1 -1
  8. package/dist/src/api/knowledge.d.ts +1 -1
  9. package/dist/src/api/streams/streamApi.d.ts +1 -1
  10. package/dist/src/api/streams/streamsApiV2.d.ts +1 -1
  11. package/dist/src/errors/base-error.d.ts +170 -1
  12. package/dist/src/errors/chat/chat-creation-failed.d.ts +24 -0
  13. package/dist/src/errors/chat/chat-mode-downgraded.d.ts +29 -0
  14. package/dist/src/errors/http-error.d.ts +67 -5
  15. package/dist/src/errors/index.d.ts +1 -0
  16. package/dist/src/errors/network-error.d.ts +62 -8
  17. package/dist/src/errors/request-meta.d.ts +12 -0
  18. package/dist/src/errors/stream-error.d.ts +32 -0
  19. package/dist/src/errors/validation-error.d.ts +62 -1
  20. package/dist/src/errors/ws-error.d.ts +29 -0
  21. package/dist/src/index.d.ts +18 -4
  22. package/dist/src/public-api.test.d.ts +1 -0
  23. package/dist/src/services/agent-manager/index.d.ts +46 -6
  24. package/dist/src/services/chat/intial-messages.test.d.ts +1 -0
  25. package/dist/src/services/streaming-manager/common.d.ts +8 -3
  26. package/dist/src/types/auth.d.ts +78 -6
  27. package/dist/src/types/entities/agents/agent.d.ts +152 -6
  28. package/dist/src/types/entities/agents/chat.d.ts +384 -12
  29. package/dist/src/types/entities/agents/manager.d.ts +795 -215
  30. package/dist/src/types/entities/avatar.d.ts +21 -0
  31. package/dist/src/types/entities/index.d.ts +1 -1
  32. package/dist/src/types/entities/knowledge/document.d.ts +7 -8
  33. package/dist/src/types/entities/knowledge/knowledge.d.ts +20 -0
  34. package/dist/src/types/entities/knowledge/record.d.ts +8 -0
  35. package/dist/src/types/entities/knowledge/retrival.d.ts +4 -0
  36. package/dist/src/types/stream/api/clip.d.ts +8 -9
  37. package/dist/src/types/stream/api/talk.d.ts +8 -9
  38. package/dist/src/types/stream/rtc.d.ts +54 -4
  39. package/dist/src/types/stream/stream.d.ts +553 -34
  40. package/dist/src/types/stream/streams-v2.d.ts +12 -0
  41. package/dist/src/types/stream-script.d.ts +92 -19
  42. package/dist/src/types/voice/stt.d.ts +12 -0
  43. package/dist/src/types/voice/tts.d.ts +149 -64
  44. package/dist/src/utils/analytics.d.ts +2 -2
  45. package/dist/src/utils/content-parser.d.ts +31 -0
  46. package/dist/src/utils/tool-calls.d.ts +21 -2
  47. package/dist/src/version.d.ts +6 -0
  48. package/package.json +7 -3
  49. package/dist/src/types/entities/video.d.ts +0 -6
@@ -1,6 +1,14 @@
1
+ /**
2
+ * Transport used to establish a session created via the v2 sessions API.
3
+ * @internal Wire type of the streaming transport; not part of the public SDK surface.
4
+ */
1
5
  export declare enum TransportProvider {
2
6
  Livekit = "livekit"
3
7
  }
8
+ /**
9
+ * Wire request body for creating a session via the v2 sessions API.
10
+ * @internal Wire type of the streaming transport; not part of the public SDK surface.
11
+ */
4
12
  export interface CreateSessionV2Options {
5
13
  transport: {
6
14
  provider: TransportProvider.Livekit;
@@ -8,6 +16,10 @@ export interface CreateSessionV2Options {
8
16
  chat_persist?: boolean;
9
17
  verbose?: boolean;
10
18
  }
19
+ /**
20
+ * Wire response of the v2 sessions API's session-creation request.
21
+ * @internal Wire type of the streaming transport; not part of the public SDK surface.
22
+ */
11
23
  export interface CreateSessionV2Response {
12
24
  id: string;
13
25
  session_url: string;
@@ -1,22 +1,53 @@
1
1
  import { Message } from './entities';
2
2
  import { StreamTextToSpeechProviders } from './voice/tts';
3
3
 
4
- export type StreamScriptType = 'text' | 'audio';
5
- export interface BaseStreamScript {
6
- type: StreamScriptType;
7
- }
8
- export interface Stream_Text_Script extends BaseStreamScript {
4
+ /**
5
+ * A script that makes the agent say text you supply, synthesised by a text-to-speech provider.
6
+ *
7
+ * The usual payload for {@link AgentManager.speak | speak()}. The agent's LLM is not involved, so
8
+ * the agent says exactly what {@link TextStreamScript.input | input} contains — which is what makes
9
+ * it the right script for greetings and other canned lines. Passing a plain string to
10
+ * {@link AgentManager.speak | speak()} is shorthand for this script with `ssml` set to `false`.
11
+ *
12
+ * @example Text
13
+ * ```ts
14
+ * const speak = await agentManager.speak({
15
+ * type: 'text',
16
+ * input: "Hi! I'm Alice!",
17
+ * });
18
+ * ```
19
+ * @example Text with sentiment
20
+ * `sentiment` is for Expressive (V4) agents only. If the requested sentiment is not supported by
21
+ * the agent, the default sentiment is used.
22
+ * ```ts
23
+ * const speak = await agentManager.speak({
24
+ * type: 'text',
25
+ * input: "Hi! I'm Alice!",
26
+ * sentiment: 'friendly',
27
+ * });
28
+ * ```
29
+ * @category Speak & Scripts
30
+ */
31
+ export interface TextStreamScript {
9
32
  /**
10
- * The type of the script.
33
+ * Which kind of script this is. Always `text` for this variant; an
34
+ * {@link AudioStreamScript} carries `audio` instead.
11
35
  */
12
36
  type: 'text';
13
37
  /**
14
- * text-to-speech provider from list of supported providers. default is microsoft tts
38
+ * The text-to-speech provider and voice that synthesise
39
+ * {@link TextStreamScript.input | input}, from the list of supported providers.
40
+ *
41
+ * One of the objects in {@link StreamTextToSpeechProviders}: a `type` naming the provider, the
42
+ * `voice_id` to speak with, and optional provider-specific `voice_config`. Leave it out and the
43
+ * SDK sends the script without a provider, so the voice is chosen server-side; the Agents API
44
+ * documents Microsoft TTS as its default when no provider is given.
15
45
  */
16
46
  provider?: StreamTextToSpeechProviders;
17
47
  /**
18
- * The input text that will be synthesized to an audio file.
19
- * Note that each provider has its own limitations on the text length.
48
+ * The text to be synthesised into speech.
49
+ *
50
+ * Each provider has its own limit on the text length.
20
51
  * @example "This is an example text"
21
52
  * @maxLength 40000
22
53
  * @minLength 3
@@ -24,33 +55,61 @@ export interface Stream_Text_Script extends BaseStreamScript {
24
55
  input: string;
25
56
  /**
26
57
  * Is the text provided in ssml form.
58
+ *
59
+ * Set it to `true` when {@link TextStreamScript.input | input} is SSML markup rather than plain
60
+ * text, so the provider reads the tags instead of speaking them.
27
61
  * @default false
28
62
  */
29
63
  ssml?: boolean;
30
64
  /**
31
- * Queue this speak behind the current speech instead of interrupting it (expressive avatars only).
65
+ * Queue this speak behind the current speech instead of interrupting it. Expressive (V4)
66
+ * agents only.
32
67
  * @default false
33
68
  */
34
69
  should_queue_speaks?: boolean;
35
70
  /**
36
- * Sentiment name to speak with (expressive avatars only).
37
- * If the sentiment is not supported by the agent, the default sentiment is used.
71
+ * Sentiment name to speak with. Expressive (V4) agents only; if the agent does not support the
72
+ * requested sentiment, its default sentiment is used.
38
73
  * @example "friendly"
39
74
  */
40
75
  sentiment?: string;
41
76
  }
42
- export interface Stream_Audio_Script extends BaseStreamScript {
77
+ /**
78
+ * A script that makes the agent lip-sync an audio file you host, with no text-to-speech involved.
79
+ *
80
+ * The other payload {@link AgentManager.speak | speak()} accepts. Use it when the audio already
81
+ * exists — a recording, or speech you synthesised yourself — instead of having a provider generate
82
+ * it from text.
83
+ *
84
+ * @example Audio file
85
+ * ```ts
86
+ * const speak = await agentManager.speak({
87
+ * type: 'audio',
88
+ * audio_url: 'https://www.yourwebsite.com/audio.mp3',
89
+ * });
90
+ * ```
91
+ * @category Speak & Scripts
92
+ */
93
+ export interface AudioStreamScript {
43
94
  /**
44
- * The type of the script.
95
+ * Which kind of script this is. Always `audio` for this variant; a
96
+ * {@link TextStreamScript} carries `text` instead.
45
97
  */
46
98
  type: 'audio';
47
99
  /**
48
- * The URL of the audio file which will be used by the actor.
49
- * File size is limit to 15MB.
100
+ * URL of the audio file the agent lip-syncs to.
101
+ *
102
+ * The URL has to be publicly reachable, since the file is fetched server-side rather than
103
+ * uploaded from the browser. The file may be at most 15 MB.
104
+ * @example "https://www.yourwebsite.com/audio.mp3"
50
105
  */
51
106
  audio_url: string;
52
107
  }
53
- export interface Stream_LLM_Script {
108
+ /**
109
+ * Script variant that has the agent's LLM generate the response to speak, rather than supplying text or audio directly.
110
+ * @internal Implementation type; not part of the public SDK surface.
111
+ */
112
+ export interface LlmStreamScript {
54
113
  type: 'llm';
55
114
  provider: StreamTextToSpeechProviders;
56
115
  ssml?: boolean;
@@ -61,5 +120,19 @@ export interface Stream_LLM_Script {
61
120
  input?: string;
62
121
  stream_audio?: boolean;
63
122
  }
64
- export type StreamScript = Stream_Text_Script | Stream_Audio_Script | Stream_LLM_Script;
65
- export type SupportedStreamScript = Stream_Text_Script | Stream_Audio_Script;
123
+ /**
124
+ * Union of every script variant accepted internally, including the LLM-generated variant not exposed to consumers.
125
+ * @internal Implementation type; not part of the public SDK surface.
126
+ */
127
+ export type StreamScript = TextStreamScript | AudioStreamScript | LlmStreamScript;
128
+ /**
129
+ * The script payload {@link AgentManager.speak | speak()} accepts: text or audio.
130
+ *
131
+ * Discriminated by its `type` field, so `'text'` narrows the object to {@link TextStreamScript}
132
+ * and `'audio'` to {@link AudioStreamScript}.
133
+ * {@link AgentManager.speak | speak()} additionally takes a plain string, as shorthand for a
134
+ * {@link TextStreamScript} with that string as its `input`.
135
+ *
136
+ * @category Speak & Scripts
137
+ */
138
+ export type SupportedStreamScript = TextStreamScript | AudioStreamScript;
@@ -1,4 +1,16 @@
1
+ /**
2
+ * A short-lived credential for the D-ID speech-to-text service.
3
+ *
4
+ * What {@link AgentManager.getSTTToken | getSTTToken()} resolves with, fetched fresh from the
5
+ * Agents API each time. It lets an application drive its own speech recognition against the
6
+ * service the agent uses without putting D-ID credentials in the browser. The token expires, so request one per recognition session
7
+ * rather than holding on to it.
8
+ *
9
+ * @category Agent Manager
10
+ */
1
11
  export interface STTTokenResponse {
12
+ /** The authorization token to present to the speech service. */
2
13
  token: string;
14
+ /** The speech service region the token is valid in. */
3
15
  region: string;
4
16
  }
@@ -1,100 +1,175 @@
1
+ /**
2
+ * The text-to-speech engines a voice can be served by.
3
+ *
4
+ * The value of the `type` field that discriminates the provider objects — {@link Providers.Microsoft}
5
+ * selects a {@link MicrosoftTtsProvider}, {@link Providers.Elevenlabs} an
6
+ * {@link ElevenlabsTtsProvider}, and so on — and of {@link Voice.provider} when you look a voice up
7
+ * in D-ID's catalogue. Which providers an account may use depends on its plan.
8
+ *
9
+ * @category Voice
10
+ */
1
11
  export declare enum Providers {
12
+ /** Amazon's text-to-speech service; see {@link AmazonTtsProvider}. */
2
13
  Amazon = "amazon",
14
+ /** Azure OpenAI text-to-speech; see {@link AzureOpenAiTtsProvider}. */
3
15
  AzureOpenAi = "azure-openai",
16
+ /** Microsoft Azure text-to-speech, which the Agents API documents as its default when a
17
+ * script names no provider; see {@link MicrosoftTtsProvider}. */
4
18
  Microsoft = "microsoft",
5
- Afflorithmics = "afflorithmics",
19
+ /** ElevenLabs text-to-speech; see {@link ElevenlabsTtsProvider}. */
6
20
  Elevenlabs = "elevenlabs"
7
21
  }
22
+ /**
23
+ * Who may use a voice.
24
+ *
25
+ * The value of {@link Voice.access}, so an application listing voices can show or hide the ones the
26
+ * account cannot select.
27
+ *
28
+ * @category Voice
29
+ */
8
30
  export declare enum VoiceAccess {
31
+ /** As exposed by the voices API: available to every account. */
9
32
  Public = "public",
33
+ /** As exposed by the voices API: available to accounts whose plan includes premium voices. */
10
34
  Premium = "premium",
35
+ /** As exposed by the voices API: available only to the account the voice belongs to. */
11
36
  Private = "private"
12
37
  }
13
- export interface IVoice {
38
+ /**
39
+ * One voice in D-ID's catalogue of text-to-speech voices.
40
+ *
41
+ * The SDK does not fetch voices itself; the type is exported so an application that lists them —
42
+ * to build a voice picker, say — can type the result and then feed {@link Voice.id | id} and
43
+ * {@link Voice.provider | provider} into the provider object it passes as
44
+ * {@link TextStreamScript.provider}. {@link Voice.provider | provider} is the wide
45
+ * {@link Providers} enum, while each provider variant requires its own literal `type` — so switch
46
+ * on it to build the matching variant, for example {@link Providers.Elevenlabs} to an
47
+ * {@link ElevenlabsTtsProvider}.
48
+ *
49
+ * @category Voice
50
+ */
51
+ export interface Voice {
52
+ /** Identifier of the voice: the value to pass as a provider object's `voice_id`. */
14
53
  id: string;
54
+ /** Human-readable name of the voice. */
15
55
  name: string;
56
+ /** The gender the voice is labelled with. */
16
57
  gender: string;
58
+ /** The locale the voice speaks, such as `en-US`. */
17
59
  locale: string;
60
+ /** Which accounts may use the voice. See {@link VoiceAccess}. */
18
61
  access: VoiceAccess;
62
+ /** The provider that serves the voice. See {@link Providers}. */
19
63
  provider: Providers;
64
+ /** The speaking styles this particular voice offers, for example as a
65
+ * {@link VoiceConfigMicrosoft.style | style}. Styles differ from voice to voice. */
20
66
  styles: string[];
67
+ /** The language of the voice, as a name rather than a locale code. */
21
68
  language: string;
22
69
  }
23
70
  /**
24
- * Elevenlabs provider details, contains the provider type and requested voice id, available for premium users.
71
+ * ElevenLabs provider details: the provider type and the requested voice id. Available to premium users.
72
+ *
73
+ * Pass it as {@link TextStreamScript.provider} to have ElevenLabs synthesise the text, optionally
74
+ * with {@link VoiceConfigElevenlabs} to control how closely the voice is reproduced.
75
+ *
76
+ * @category Voice
25
77
  */
26
- export interface Elevenlabs_tts_provider {
78
+ export interface ElevenlabsTtsProvider {
79
+ /** Selects ElevenLabs. Always {@link Providers.Elevenlabs} (`'elevenlabs'`). */
27
80
  type: Providers.Elevenlabs;
28
81
  /**
29
- * The voice_id from the list of available voices. https://api.elevenlabs.io/v1/voices.
82
+ * Id of the voice to speak with, from D-ID's list of ElevenLabs voices.
83
+ *
30
84
  * @example "21m00Tcm4TlvDq8ikWAM"
31
- * @default 21m00Tcm4TlvDq8ikWAM
85
+ * @see [ElevenLabs voices](https://docs.d-id.com/docs/tts-elevenlabs)
32
86
  */
33
87
  voice_id: string;
34
88
  /**
35
- * Voice customization options. Read more here: https://docs.elevenlabs.io/speech-synthesis/voice-settings
89
+ * How closely the voice should follow the original it was cloned from. See
90
+ * {@link VoiceConfigElevenlabs}.
91
+ *
92
+ * @see [ElevenLabs voice settings](https://elevenlabs.io/docs/best-practices/prompting/controls)
36
93
  */
37
94
  voice_config?: VoiceConfigElevenlabs;
38
95
  }
39
96
  /**
40
- * Afflorithmics provider details, contains the provider type and requested voice id, available for enterprise users.
41
- */
42
- export interface Afflorithmics_tts_provider {
43
- type: Providers.Afflorithmics;
44
- /**
45
- * The voice_id from the list of available voices.
46
- * @example "abc123DEF456"
47
- * @default abc123DEF456
48
- */
49
- voice_id: string;
50
- /**
51
- * Voice customization options. Read more here: https://docs.audiostack.ai/reference/postspeech
52
- */
53
- voice_config?: VoiceConfigAfflorithmics;
54
- }
55
- /**
56
- * AzureMicrosoft provider details, contains the provider type and requested voice id and style
97
+ * Microsoft Azure provider details: the provider type, the requested voice id and an optional
98
+ * `voice_config` for style, rate and pitch.
99
+ *
100
+ * Pass it as {@link TextStreamScript.provider} to pick a Microsoft Azure voice explicitly,
101
+ * optionally with {@link VoiceConfigMicrosoft} to set style, rate and pitch. The Agents API
102
+ * documents Microsoft TTS as its default when a script names no provider, so this is also the
103
+ * provider a script without one ends up using.
104
+ *
105
+ * @category Voice
57
106
  */
58
- export interface Microsoft_tts_provider {
107
+ export interface MicrosoftTtsProvider {
108
+ /** Selects Microsoft Azure. Always {@link Providers.Microsoft} (`'microsoft'`). */
59
109
  type: Providers.Microsoft;
60
110
  /**
61
- * The voice_id from the list of available voices.
62
- * For full list of voice_ids: https://docs.d-id.com/reference/microsoft-azure
111
+ * Id of the voice to speak with, from D-ID's list of Microsoft Azure voices.
112
+ *
63
113
  * @example "en-US-JennyNeural"
64
- * @default en-US-JennyNeural
114
+ * @see [Microsoft Azure voices](https://docs.d-id.com/docs/tts-microsoft)
65
115
  */
66
116
  voice_id: string;
67
117
  /**
68
- * Voice customization options
118
+ * How the voice should deliver the text: style, rate and pitch. See
119
+ * {@link VoiceConfigMicrosoft}.
69
120
  */
70
121
  voice_config?: VoiceConfigMicrosoft;
71
122
  /**
72
- * Voice name
123
+ * @internal Not accepted by the Agents API, whose provider schema allows only `type`,
124
+ * `voice_id`, `voice_config` and `language`.
73
125
  */
74
126
  voice_name?: string;
75
127
  /**
76
- * Voice language
128
+ * @internal Not accepted by the Agents API, whose provider schema allows only `type`,
129
+ * `voice_id`, `voice_config` and `language`.
77
130
  */
78
131
  voice_language?: string;
79
132
  }
80
133
  /**
81
- * AzureOpenAi provider details, contains the provider type and requested voice id and style
134
+ * Azure OpenAI provider details: the provider type, the requested voice id and an optional
135
+ * `voice_config` for style, rate and pitch.
136
+ *
137
+ * The same shape as {@link MicrosoftTtsProvider} — a `voice_id` and an optional
138
+ * {@link VoiceConfigMicrosoft} as `voice_config` — with the `type` naming Azure OpenAI instead.
139
+ *
140
+ * @category Voice
82
141
  */
83
- export interface AzureOpenAi_tts_provider extends Omit<Microsoft_tts_provider, 'type'> {
142
+ export interface AzureOpenAiTtsProvider extends Omit<MicrosoftTtsProvider, 'type'> {
143
+ /** Selects Azure OpenAI. Always {@link Providers.AzureOpenAi} (`'azure-openai'`). */
84
144
  type: Providers.AzureOpenAi;
85
145
  }
86
146
  /**
87
- * Amazon provider details, contains the provider type and requested voice id
147
+ * Amazon provider details: the provider type and the requested voice id.
148
+ *
149
+ * Pass it as {@link TextStreamScript.provider} to have Amazon synthesise the text. It is the one
150
+ * provider with no `voice_config`: the voice is selected by `voice_id` alone.
151
+ *
152
+ * @category Voice
88
153
  */
89
- export interface Amazon_tts_provider {
154
+ export interface AmazonTtsProvider {
155
+ /** Selects Amazon. Always {@link Providers.Amazon} (`'amazon'`). */
90
156
  type: Providers.Amazon;
91
157
  /**
92
- * The voice_id from the list of available voices.
93
- * For full list of voice_ids: https://docs.d-id.com/reference/text-to-speech-providers
158
+ * Id of the voice to speak with, from D-ID's list of Amazon voices.
159
+ *
94
160
  * @example "Joanna"
161
+ * @see [Amazon voices](https://docs.d-id.com/docs/tts-amazon)
95
162
  */
96
163
  voice_id: string;
97
164
  }
165
+ /**
166
+ * How a Microsoft Azure or Azure OpenAI voice should deliver the text.
167
+ *
168
+ * The `voice_config` of {@link MicrosoftTtsProvider} and {@link AzureOpenAiTtsProvider}. Every
169
+ * field is optional; when one is omitted the Agents API applies its own default.
170
+ *
171
+ * @category Voice
172
+ */
98
173
  export interface VoiceConfigMicrosoft {
99
174
  /**
100
175
  * The style of the voice.
@@ -116,38 +191,48 @@ export interface VoiceConfigMicrosoft {
116
191
  */
117
192
  pitch?: string;
118
193
  }
194
+ /**
195
+ * How closely an ElevenLabs voice should follow the original it was built from.
196
+ *
197
+ * The `voice_config` of {@link ElevenlabsTtsProvider}, mirroring ElevenLabs' own voice settings.
198
+ * Both fields are optional; when one is omitted the Agents API applies its own default.
199
+ *
200
+ * @category Voice
201
+ */
119
202
  export interface VoiceConfigElevenlabs {
120
203
  /**
121
- * How stable the voice is and the randomness of each new generation.
122
- * @example "0"
204
+ * How stable the voice is, and how much each generation varies.
205
+ *
206
+ * A number from 0 to 1: lower is more expressive and more variable between generations, higher
207
+ * is flatter and more repeatable.
208
+ * @example 0.5
123
209
  */
124
210
  stability?: number;
125
211
  /**
126
- * The similarity slider dictates how closely the AI should adhere to the original voice when attempting to replicate it.
127
- * @example "0"
212
+ * How closely the synthesised speech should adhere to the original voice it was cloned from.
213
+ *
214
+ * A number from 0 to 1: higher follows the original more strictly.
215
+ * @example 0.5
128
216
  */
129
217
  similarity_boost?: number;
130
218
  }
131
- export interface VoiceConfigAfflorithmics {
132
- /**
133
- * The speed of the voice.
134
- * The value is relative to 1, 0.5 being half speed, 2 being twice as fast, etc.
135
- * Another option is a constant value from x-slow/slow/medium/fast/x-fast.
136
- * @example "1.2"
137
- * @min 0.5
138
- * @max 1.5
139
- * @default 1
140
- */
141
- rate?: string;
142
- /**
143
- * Amount of microseconds for silence padding. Half of the amount is inserted as silence at the beginning and at the end of each Speech file.
144
- */
145
- silencePadding?: number;
146
- /**
147
- * Flag to apply lexicographical text corrections
148
- */
149
- voiceIntelligence?: boolean;
150
- }
151
- export type TextToSpeechProviders = Microsoft_tts_provider | AzureOpenAi_tts_provider | Afflorithmics_tts_provider | Elevenlabs_tts_provider;
152
- export type ExtendedTextToSpeechProviders = TextToSpeechProviders | Amazon_tts_provider;
153
- export type StreamTextToSpeechProviders = Microsoft_tts_provider | AzureOpenAi_tts_provider | Afflorithmics_tts_provider | Elevenlabs_tts_provider | Amazon_tts_provider;
219
+ /**
220
+ * The provider object a speak script accepts: any of the four text-to-speech providers.
221
+ *
222
+ * This is the type of {@link TextStreamScript.provider}. Pick the variant for the provider you
223
+ * want, give it the `voice_id` to speak with and, except for {@link AmazonTtsProvider}, an optional
224
+ * `voice_config`; `type` discriminates the union.
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * import { Providers } from '@d-id/client-sdk';
229
+ *
230
+ * const speak = await agentManager.speak({
231
+ * type: 'text',
232
+ * input: "Hi! I'm Alice!",
233
+ * provider: { type: Providers.Microsoft, voice_id: 'en-US-JennyNeural' },
234
+ * });
235
+ * ```
236
+ * @category Voice
237
+ */
238
+ export type StreamTextToSpeechProviders = MicrosoftTtsProvider | AzureOpenAiTtsProvider | ElevenlabsTtsProvider | AmazonTtsProvider;
@@ -5,13 +5,13 @@ export declare function getAnalyticsInfo(agent: Agent): {
5
5
  isMobile: string;
6
6
  browser: string;
7
7
  origin: string;
8
- agentType: "talk" | "clip" | "expressive" | "clip_v2";
8
+ agentType: import('../types/index').AvatarType | "clip_v2";
9
9
  agentVoice: {
10
10
  language: string | undefined;
11
11
  };
12
12
  };
13
13
  export declare function getAgentInfo(agent: Agent): {
14
- agentType: "talk" | "clip" | "expressive" | "clip_v2";
14
+ agentType: import('../types/index').AvatarType | "clip_v2";
15
15
  presenterType: import('./agent').PresenterType;
16
16
  owner_id: string;
17
17
  starterQuestionsCount: number | undefined;
@@ -1,4 +1,35 @@
1
1
  import { MessagePart } from '../types/entities/agents/chat';
2
2
 
3
+ /**
4
+ * Splits a message's text into the typed {@link MessagePart | parts} a UI can render.
5
+ *
6
+ * The SDK already runs it over every message it builds and keeps the result on
7
+ * {@link Message.parts}, so this is for content that comes from somewhere else — a transcript you
8
+ * render outside the SDK, or text you assembled before handing it to a renderer.
9
+ * {@link AgentManagerOptions.initialMessages | initialMessages} no longer need it: pass `parts: []`
10
+ * and the SDK runs this for you. It recognises markdown
11
+ * images (`![alt](url)`), the video thumbnail form (`[![alt](thumb)](video)`), markdown links
12
+ * (`[label](url)`) and HTML anchors (`<a href="url">label</a>`); an image whose URL looks like a
13
+ * video becomes a `video` part instead, and a GIF is tagged with a `mimeType`, both under the rules
14
+ * {@link MessagePart} sets out. Everything the parser does not recognise is preserved verbatim as a
15
+ * `text` part, in its original order, and nothing is dropped or reordered; each recognised part
16
+ * replaces the markup it was written as, so the parts are not a concatenation of the input.
17
+ *
18
+ * @param content - The message text to split, as it appears in {@link Message.content}.
19
+ * @returns The parts in the order they appear in `content`: a single `text` part when there is no
20
+ * markup to find, and an empty array for an empty string.
21
+ * @example
22
+ * ```ts
23
+ * import { parseMessageParts } from '@d-id/client-sdk';
24
+ *
25
+ * parseMessageParts('Here it is: ![a cat](https://example.com/cat.png) — enjoy!');
26
+ * // [
27
+ * // { type: 'text', text: 'Here it is: ' },
28
+ * // { type: 'image', src: 'https://example.com/cat.png', alt: 'a cat' },
29
+ * // { type: 'text', text: ' — enjoy!' },
30
+ * // ]
31
+ * ```
32
+ * @category Chat
33
+ */
3
34
  export declare function parseMessageParts(content: string): MessagePart[];
4
35
  export declare function parseMessagePartsMemo(content: string): MessagePart[];
@@ -2,7 +2,26 @@ import { RunningToolCall } from '../types';
2
2
 
3
3
  /**
4
4
  * Whether the agent is waiting on a tool call before it can continue.
5
- * True while any running call is 'blocking'. False when nothing is running,
6
- * or when everything running is 'async' and the agent is still available.
5
+ *
6
+ * True while any of the running calls is `blocking`; false when nothing is running, or when
7
+ * everything running is `async` and the agent can keep talking. Pass it the array
8
+ * {@link AgentManagerCallbacks.onRunningToolCallsChange | onRunningToolCallsChange} hands you, to
9
+ * decide whether to show the user that the agent is busy.
10
+ *
11
+ * @param calls - The tool calls running right now, as reported by
12
+ * {@link AgentManagerCallbacks.onRunningToolCallsChange | onRunningToolCallsChange}. See
13
+ * {@link RunningToolCall}.
14
+ * @returns `true` while the agent is suspended on a blocking tool call.
15
+ * @example
16
+ * ```ts
17
+ * import { isAwaitingTool } from '@d-id/client-sdk';
18
+ *
19
+ * const callbacks = {
20
+ * onRunningToolCallsChange(calls) {
21
+ * setSpinnerVisible(isAwaitingTool(calls));
22
+ * },
23
+ * };
24
+ * ```
25
+ * @category Callbacks & Events
7
26
  */
8
27
  export declare function isAwaitingTool(calls: readonly RunningToolCall[]): boolean;
@@ -1 +1,7 @@
1
+ /**
2
+ * Published version of the SDK this bundle was built from, `'dev'` when it runs from source.
3
+ * Attached to every analytics event.
4
+ *
5
+ * @internal
6
+ */
1
7
  export declare const SDK_VERSION: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d-id/client-sdk",
3
3
  "private": false,
4
- "version": "2.0.10",
4
+ "version": "3.0.0-staging.412",
5
5
  "type": "module",
6
6
  "description": "d-id client sdk",
7
7
  "repository": {
@@ -29,7 +29,9 @@
29
29
  "deploy:prod": "node ./infra/deploy.js --version beta",
30
30
  "preview": "vite preview",
31
31
  "test-build": "node .infra/build.js -m development",
32
- "build:docs": "typedoc",
32
+ "docs:build": "typedoc",
33
+ "docs:check": "typedoc --out .docs-check-site",
34
+ "docs:serve": "yarn docs:build && vite preview --outDir docs-site --port 4173 --strictPort --open",
33
35
  "test": "jest",
34
36
  "test:watch": "jest --watch",
35
37
  "test:ci": "jest --watchAll=false --passWithNoTests --verbose=false",
@@ -59,7 +61,9 @@
59
61
  "string-width": "^4.2.3",
60
62
  "strip-ansi": "^6.0.1",
61
63
  "ts-jest": "^29.4.1",
62
- "typedoc": "^0.25.7",
64
+ "typedoc": "^0.28.20",
65
+ "typedoc-plugin-coverage": "^4.0.3",
66
+ "typedoc-plugin-mdn-links": "^5.1.1",
63
67
  "typescript": "^5.3.3",
64
68
  "vite": "^6.4.2",
65
69
  "vite-plugin-dts": "^3.7.3"
@@ -1,6 +0,0 @@
1
- export declare enum VideoType {
2
- Clip = "clip",
3
- Talk = "talk",
4
- Expressive = "expressive"
5
- }
6
- export declare const mapVideoType: (type: string) => VideoType;