@d-id/client-sdk 3.0.0-staging.413 → 3.0.0-staging.415
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 +2 -0
- package/dist/index-D0K-5SID.js +2037 -0
- package/dist/index.d.ts +3270 -0
- package/dist/index.js +20 -20
- package/dist/index.umd.cjs +13 -13
- package/dist/{index-BOeL7MEm.js → livekit-client.esm-QkbCKsng.js} +6234 -8256
- package/dist/livekit-manager-CU_yynQK.js +557 -0
- package/package.json +33 -9
- package/dist/livekit-manager-D-B3qdMq.js +0 -506
- package/dist/src/api/agents.d.ts +0 -18
- package/dist/src/api/apiClient.d.ts +0 -11
- package/dist/src/api/apiClient.test.d.ts +0 -1
- package/dist/src/api/knowledge.d.ts +0 -15
- package/dist/src/api/streams/index.d.ts +0 -1
- package/dist/src/api/streams/streamApi.d.ts +0 -3
- package/dist/src/api/streams/streamsApiV2.d.ts +0 -5
- package/dist/src/auth/get-auth-header.d.ts +0 -5
- package/dist/src/auth/get-auth-header.test.d.ts +0 -1
- package/dist/src/config/consts.d.ts +0 -3
- package/dist/src/config/environment.d.ts +0 -5
- package/dist/src/errors/base-error.d.ts +0 -182
- package/dist/src/errors/chat/chat-creation-failed.d.ts +0 -30
- package/dist/src/errors/chat/chat-mode-downgraded.d.ts +0 -35
- package/dist/src/errors/errors.test.d.ts +0 -1
- package/dist/src/errors/http-error.d.ts +0 -74
- package/dist/src/errors/index.d.ts +0 -9
- package/dist/src/errors/network-error.d.ts +0 -72
- package/dist/src/errors/request-meta.d.ts +0 -12
- package/dist/src/errors/stream-error.d.ts +0 -37
- package/dist/src/errors/validation-error.d.ts +0 -67
- package/dist/src/errors/ws-error.d.ts +0 -34
- package/dist/src/index.d.ts +0 -20
- package/dist/src/public-api.test.d.ts +0 -1
- package/dist/src/services/agent-manager/connect-to-manager.d.ts +0 -19
- package/dist/src/services/agent-manager/connect-to-manager.test.d.ts +0 -1
- package/dist/src/services/agent-manager/index.d.ts +0 -64
- package/dist/src/services/agent-manager/index.test.d.ts +0 -1
- package/dist/src/services/analytics/mixpanel.d.ts +0 -22
- package/dist/src/services/analytics/mixpanel.test.d.ts +0 -1
- package/dist/src/services/analytics/timestamp-tracker.d.ts +0 -15
- package/dist/src/services/chat/index.d.ts +0 -10
- package/dist/src/services/chat/index.test.d.ts +0 -1
- package/dist/src/services/chat/intial-messages.d.ts +0 -3
- package/dist/src/services/chat/intial-messages.test.d.ts +0 -1
- package/dist/src/services/socket-manager/index.d.ts +0 -12
- package/dist/src/services/socket-manager/message-queue.d.ts +0 -12
- package/dist/src/services/socket-manager/message-queue.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/advanced.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/business-flows.test.d.ts +0 -5
- package/dist/src/services/streaming-manager/common.d.ts +0 -101
- package/dist/src/services/streaming-manager/data-channel-handlers.d.ts +0 -3
- package/dist/src/services/streaming-manager/disconnect.test.d.ts +0 -5
- package/dist/src/services/streaming-manager/edge-cases.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/factory.d.ts +0 -13
- package/dist/src/services/streaming-manager/factory.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/index.d.ts +0 -5
- package/dist/src/services/streaming-manager/livekit-manager.d.ts +0 -10
- package/dist/src/services/streaming-manager/livekit-manager.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/stats/av-sync.d.ts +0 -3
- package/dist/src/services/streaming-manager/stats/av-sync.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/stats/poll.d.ts +0 -16
- package/dist/src/services/streaming-manager/stats/report.d.ts +0 -19
- package/dist/src/services/streaming-manager/stats/report.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/webrtc-core.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/webrtc-manager.d.ts +0 -12
- package/dist/src/services/streaming-manager/webrtc-utils.test.d.ts +0 -5
- package/dist/src/test-utils/factories/agent-manager.factory.d.ts +0 -3
- package/dist/src/test-utils/factories/agent.factory.d.ts +0 -4
- package/dist/src/test-utils/factories/agents-api.factory.d.ts +0 -1
- package/dist/src/test-utils/factories/analytics.factory.d.ts +0 -1
- package/dist/src/test-utils/factories/chat.factory.d.ts +0 -1
- package/dist/src/test-utils/factories/index.d.ts +0 -8
- package/dist/src/test-utils/factories/socket-manager.factory.d.ts +0 -1
- package/dist/src/test-utils/factories/stream-api.factory.d.ts +0 -1
- package/dist/src/test-utils/factories/streaming-manager.factory.d.ts +0 -4
- package/dist/src/types/auth.d.ts +0 -95
- package/dist/src/types/entities/agents/agent.d.ts +0 -202
- package/dist/src/types/entities/agents/chat.d.ts +0 -476
- package/dist/src/types/entities/agents/index.d.ts +0 -3
- package/dist/src/types/entities/agents/manager.d.ts +0 -896
- package/dist/src/types/entities/avatar.d.ts +0 -21
- package/dist/src/types/entities/index.d.ts +0 -3
- package/dist/src/types/entities/knowledge/document.d.ts +0 -31
- package/dist/src/types/entities/knowledge/index.d.ts +0 -4
- package/dist/src/types/entities/knowledge/knowledge.d.ts +0 -56
- package/dist/src/types/entities/knowledge/record.d.ts +0 -24
- package/dist/src/types/entities/knowledge/retrival.d.ts +0 -9
- package/dist/src/types/face-rect.d.ts +0 -6
- package/dist/src/types/index.d.ts +0 -6
- package/dist/src/types/stream/api/clip.d.ts +0 -122
- package/dist/src/types/stream/api/index.d.ts +0 -2
- package/dist/src/types/stream/api/talk.d.ts +0 -77
- package/dist/src/types/stream/data-channel.d.ts +0 -16
- package/dist/src/types/stream/index.d.ts +0 -4
- package/dist/src/types/stream/rtc.d.ts +0 -114
- package/dist/src/types/stream/stream.d.ts +0 -785
- package/dist/src/types/stream/streams-v2.d.ts +0 -28
- package/dist/src/types/stream-script.d.ts +0 -138
- package/dist/src/types/voice/stt.d.ts +0 -16
- package/dist/src/types/voice/tts.d.ts +0 -238
- package/dist/src/utils/agent.d.ts +0 -8
- package/dist/src/utils/analytics.d.ts +0 -31
- package/dist/src/utils/analytics.test.d.ts +0 -1
- package/dist/src/utils/chat.d.ts +0 -4
- package/dist/src/utils/content-parser.d.ts +0 -35
- package/dist/src/utils/content-parser.test.d.ts +0 -1
- package/dist/src/utils/defer.d.ts +0 -7
- package/dist/src/utils/error-analytics.d.ts +0 -4
- package/dist/src/utils/error-analytics.test.d.ts +0 -1
- package/dist/src/utils/index.d.ts +0 -3
- package/dist/src/utils/retry-operation.d.ts +0 -38
- package/dist/src/utils/stream-end.d.ts +0 -5
- package/dist/src/utils/stream-end.test.d.ts +0 -1
- package/dist/src/utils/tool-calls.d.ts +0 -27
- package/dist/src/utils/tool-calls.test.d.ts +0 -1
- package/dist/src/utils/user-context.d.ts +0 -15
- package/dist/src/utils/user-context.test.d.ts +0 -1
- package/dist/src/version.d.ts +0 -7
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
*/
|
|
5
|
-
export declare enum TransportProvider {
|
|
6
|
-
Livekit = "livekit"
|
|
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
|
-
*/
|
|
12
|
-
export interface CreateSessionV2Options {
|
|
13
|
-
transport: {
|
|
14
|
-
provider: TransportProvider.Livekit;
|
|
15
|
-
};
|
|
16
|
-
chat_persist?: boolean;
|
|
17
|
-
verbose?: boolean;
|
|
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
|
-
*/
|
|
23
|
-
export interface CreateSessionV2Response {
|
|
24
|
-
id: string;
|
|
25
|
-
session_url: string;
|
|
26
|
-
session_token: string;
|
|
27
|
-
interrupt_enabled: boolean;
|
|
28
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { Message } from './entities';
|
|
2
|
-
import { StreamTextToSpeechProviders } from './voice/tts';
|
|
3
|
-
|
|
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 {
|
|
32
|
-
/**
|
|
33
|
-
* Which kind of script this is. Always `text` for this variant; an
|
|
34
|
-
* {@link AudioStreamScript} carries `audio` instead.
|
|
35
|
-
*/
|
|
36
|
-
type: 'text';
|
|
37
|
-
/**
|
|
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.
|
|
45
|
-
*/
|
|
46
|
-
provider?: StreamTextToSpeechProviders;
|
|
47
|
-
/**
|
|
48
|
-
* The text to be synthesised into speech.
|
|
49
|
-
*
|
|
50
|
-
* Each provider has its own limit on the text length.
|
|
51
|
-
* @example "This is an example text"
|
|
52
|
-
* @maxLength 40000
|
|
53
|
-
* @minLength 3
|
|
54
|
-
*/
|
|
55
|
-
input: string;
|
|
56
|
-
/**
|
|
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.
|
|
61
|
-
* @default false
|
|
62
|
-
*/
|
|
63
|
-
ssml?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Queue this speak behind the current speech instead of interrupting it. Expressive (V4)
|
|
66
|
-
* agents only.
|
|
67
|
-
* @default false
|
|
68
|
-
*/
|
|
69
|
-
should_queue_speaks?: boolean;
|
|
70
|
-
/**
|
|
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.
|
|
73
|
-
* @example "friendly"
|
|
74
|
-
*/
|
|
75
|
-
sentiment?: string;
|
|
76
|
-
}
|
|
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 {
|
|
94
|
-
/**
|
|
95
|
-
* Which kind of script this is. Always `audio` for this variant; a
|
|
96
|
-
* {@link TextStreamScript} carries `text` instead.
|
|
97
|
-
*/
|
|
98
|
-
type: 'audio';
|
|
99
|
-
/**
|
|
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"
|
|
105
|
-
*/
|
|
106
|
-
audio_url: string;
|
|
107
|
-
}
|
|
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 {
|
|
113
|
-
type: 'llm';
|
|
114
|
-
provider: StreamTextToSpeechProviders;
|
|
115
|
-
ssml?: boolean;
|
|
116
|
-
llm: {
|
|
117
|
-
messages: Message[];
|
|
118
|
-
provider: 'openai';
|
|
119
|
-
};
|
|
120
|
-
input?: string;
|
|
121
|
-
stream_audio?: boolean;
|
|
122
|
-
}
|
|
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,16 +0,0 @@
|
|
|
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
|
-
*/
|
|
11
|
-
export interface STTTokenResponse {
|
|
12
|
-
/** The authorization token to present to the speech service. */
|
|
13
|
-
token: string;
|
|
14
|
-
/** The speech service region the token is valid in. */
|
|
15
|
-
region: string;
|
|
16
|
-
}
|
|
@@ -1,238 +0,0 @@
|
|
|
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
|
-
*/
|
|
11
|
-
export declare enum Providers {
|
|
12
|
-
/** Amazon's text-to-speech service; see {@link AmazonTtsProvider}. */
|
|
13
|
-
Amazon = "amazon",
|
|
14
|
-
/** Azure OpenAI text-to-speech; see {@link AzureOpenAiTtsProvider}. */
|
|
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}. */
|
|
18
|
-
Microsoft = "microsoft",
|
|
19
|
-
/** ElevenLabs text-to-speech; see {@link ElevenlabsTtsProvider}. */
|
|
20
|
-
Elevenlabs = "elevenlabs"
|
|
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
|
-
*/
|
|
30
|
-
export declare enum VoiceAccess {
|
|
31
|
-
/** As exposed by the voices API: available to every account. */
|
|
32
|
-
Public = "public",
|
|
33
|
-
/** As exposed by the voices API: available to accounts whose plan includes premium voices. */
|
|
34
|
-
Premium = "premium",
|
|
35
|
-
/** As exposed by the voices API: available only to the account the voice belongs to. */
|
|
36
|
-
Private = "private"
|
|
37
|
-
}
|
|
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`. */
|
|
53
|
-
id: string;
|
|
54
|
-
/** Human-readable name of the voice. */
|
|
55
|
-
name: string;
|
|
56
|
-
/** The gender the voice is labelled with. */
|
|
57
|
-
gender: string;
|
|
58
|
-
/** The locale the voice speaks, such as `en-US`. */
|
|
59
|
-
locale: string;
|
|
60
|
-
/** Which accounts may use the voice. See {@link VoiceAccess}. */
|
|
61
|
-
access: VoiceAccess;
|
|
62
|
-
/** The provider that serves the voice. See {@link Providers}. */
|
|
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. */
|
|
66
|
-
styles: string[];
|
|
67
|
-
/** The language of the voice, as a name rather than a locale code. */
|
|
68
|
-
language: string;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
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
|
|
77
|
-
*/
|
|
78
|
-
export interface ElevenlabsTtsProvider {
|
|
79
|
-
/** Selects ElevenLabs. Always {@link Providers.Elevenlabs} (`'elevenlabs'`). */
|
|
80
|
-
type: Providers.Elevenlabs;
|
|
81
|
-
/**
|
|
82
|
-
* Id of the voice to speak with, from D-ID's list of ElevenLabs voices.
|
|
83
|
-
*
|
|
84
|
-
* @example "21m00Tcm4TlvDq8ikWAM"
|
|
85
|
-
* @see [ElevenLabs voices](https://docs.d-id.com/docs/tts-elevenlabs)
|
|
86
|
-
*/
|
|
87
|
-
voice_id: string;
|
|
88
|
-
/**
|
|
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)
|
|
93
|
-
*/
|
|
94
|
-
voice_config?: VoiceConfigElevenlabs;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
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
|
|
106
|
-
*/
|
|
107
|
-
export interface MicrosoftTtsProvider {
|
|
108
|
-
/** Selects Microsoft Azure. Always {@link Providers.Microsoft} (`'microsoft'`). */
|
|
109
|
-
type: Providers.Microsoft;
|
|
110
|
-
/**
|
|
111
|
-
* Id of the voice to speak with, from D-ID's list of Microsoft Azure voices.
|
|
112
|
-
*
|
|
113
|
-
* @example "en-US-JennyNeural"
|
|
114
|
-
* @see [Microsoft Azure voices](https://docs.d-id.com/docs/tts-microsoft)
|
|
115
|
-
*/
|
|
116
|
-
voice_id: string;
|
|
117
|
-
/**
|
|
118
|
-
* How the voice should deliver the text: style, rate and pitch. See
|
|
119
|
-
* {@link VoiceConfigMicrosoft}.
|
|
120
|
-
*/
|
|
121
|
-
voice_config?: VoiceConfigMicrosoft;
|
|
122
|
-
/**
|
|
123
|
-
* @internal Not accepted by the Agents API, whose provider schema allows only `type`,
|
|
124
|
-
* `voice_id`, `voice_config` and `language`.
|
|
125
|
-
*/
|
|
126
|
-
voice_name?: string;
|
|
127
|
-
/**
|
|
128
|
-
* @internal Not accepted by the Agents API, whose provider schema allows only `type`,
|
|
129
|
-
* `voice_id`, `voice_config` and `language`.
|
|
130
|
-
*/
|
|
131
|
-
voice_language?: string;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
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
|
|
141
|
-
*/
|
|
142
|
-
export interface AzureOpenAiTtsProvider extends Omit<MicrosoftTtsProvider, 'type'> {
|
|
143
|
-
/** Selects Azure OpenAI. Always {@link Providers.AzureOpenAi} (`'azure-openai'`). */
|
|
144
|
-
type: Providers.AzureOpenAi;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
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
|
|
153
|
-
*/
|
|
154
|
-
export interface AmazonTtsProvider {
|
|
155
|
-
/** Selects Amazon. Always {@link Providers.Amazon} (`'amazon'`). */
|
|
156
|
-
type: Providers.Amazon;
|
|
157
|
-
/**
|
|
158
|
-
* Id of the voice to speak with, from D-ID's list of Amazon voices.
|
|
159
|
-
*
|
|
160
|
-
* @example "Joanna"
|
|
161
|
-
* @see [Amazon voices](https://docs.d-id.com/docs/tts-amazon)
|
|
162
|
-
*/
|
|
163
|
-
voice_id: string;
|
|
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
|
-
*/
|
|
173
|
-
export interface VoiceConfigMicrosoft {
|
|
174
|
-
/**
|
|
175
|
-
* The style of the voice.
|
|
176
|
-
* Available styles change between voices.
|
|
177
|
-
*/
|
|
178
|
-
style?: string;
|
|
179
|
-
/**
|
|
180
|
-
* The speed of the voice.
|
|
181
|
-
* The value is relative to 1, 0.5 being half speed, 2 being twice as fast, etc.
|
|
182
|
-
* Another option is a constant value from x-slow/slow/medium/fast/x-fast.
|
|
183
|
-
* @example "0.5"
|
|
184
|
-
*/
|
|
185
|
-
rate?: string;
|
|
186
|
-
/**
|
|
187
|
-
* The pitch of the voice.
|
|
188
|
-
* Value could be an absolute value in Hz (including units), a relative value in Hz or st(semitones)
|
|
189
|
-
* or a constant value from x-low/low/medium/high/x-high.
|
|
190
|
-
* @example "+2st"
|
|
191
|
-
*/
|
|
192
|
-
pitch?: string;
|
|
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
|
-
*/
|
|
202
|
-
export interface VoiceConfigElevenlabs {
|
|
203
|
-
/**
|
|
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
|
|
209
|
-
*/
|
|
210
|
-
stability?: number;
|
|
211
|
-
/**
|
|
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
|
|
216
|
-
*/
|
|
217
|
-
similarity_boost?: number;
|
|
218
|
-
}
|
|
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;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Agent } from '../types';
|
|
2
|
-
|
|
3
|
-
type AgentType = 'clip_v2' | Agent['avatar']['type'];
|
|
4
|
-
export type PresenterType = 'v4' | 'v3-pro' | 'v2';
|
|
5
|
-
export declare const getAgentType: (presenter: Agent["avatar"]) => AgentType;
|
|
6
|
-
export declare const getPresenterType: (presenter: Agent["avatar"]) => PresenterType;
|
|
7
|
-
export declare const isStreamsV2Agent: (type: AgentType) => boolean;
|
|
8
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Agent } from '../types/index';
|
|
2
|
-
|
|
3
|
-
export declare function getAnalyticsInfo(agent: Agent): {
|
|
4
|
-
$os: string;
|
|
5
|
-
isMobile: string;
|
|
6
|
-
browser: string;
|
|
7
|
-
origin: string;
|
|
8
|
-
agentType: import('../types/index').AvatarType | "clip_v2";
|
|
9
|
-
agentVoice: {
|
|
10
|
-
language: string | undefined;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare function getAgentInfo(agent: Agent): {
|
|
14
|
-
agentType: import('../types/index').AvatarType | "clip_v2";
|
|
15
|
-
presenterType: import('./agent').PresenterType;
|
|
16
|
-
owner_id: string;
|
|
17
|
-
starterQuestionsCount: number | undefined;
|
|
18
|
-
agentId: string;
|
|
19
|
-
agentName: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
export declare const getErrorMessage: (error: unknown) => string;
|
|
22
|
-
export declare const sumFunc: (numbers: number[]) => number;
|
|
23
|
-
export declare const average: (numbers: number[]) => number;
|
|
24
|
-
export declare const min: (numbers: number[]) => number;
|
|
25
|
-
export declare const max: (numbers: number[]) => number;
|
|
26
|
-
export declare const round: (value: number, decimals?: number) => number;
|
|
27
|
-
export declare const percentile: (numbers: number[], p: number) => number;
|
|
28
|
-
export declare const median: (numbers: number[]) => number;
|
|
29
|
-
/** Run fn, returning fallback instead of throwing — so a telemetry failure can never break the caller. */
|
|
30
|
-
export declare const safe: <T>(fn: () => T, fallback: T) => T;
|
|
31
|
-
export declare function getStreamAnalyticsProps(data: any, agent: Agent, additionalProps: Record<string, any>): any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/utils/chat.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { MessagePart } from '../types/entities/agents/chat';
|
|
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 (``), the video thumbnail form (`[](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:  — 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
|
-
*/
|
|
34
|
-
export declare function parseMessageParts(content: string): MessagePart[];
|
|
35
|
-
export declare function parseMessagePartsMemo(content: string): MessagePart[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defers function execution until browser is idle to avoid blocking critical path.
|
|
3
|
-
* Uses requestIdleCallback when available, falls back to setTimeout.
|
|
4
|
-
*
|
|
5
|
-
* @param fn - Function to execute when browser is idle
|
|
6
|
-
*/
|
|
7
|
-
export declare function defer(fn: () => void): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
interface RetryOptions {
|
|
2
|
-
limit?: number;
|
|
3
|
-
delayMs?: number;
|
|
4
|
-
timeout?: number;
|
|
5
|
-
timeoutErrorMessage?: string;
|
|
6
|
-
shouldRetryFn?: (error: any) => boolean;
|
|
7
|
-
onRetry?: (error: any) => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Utility function to retry a promise operation with configurable retry logic
|
|
11
|
-
*
|
|
12
|
-
* @param operation - A function that returns a Promise to be retried
|
|
13
|
-
* @param userOptions - Configuration options for retry behavior
|
|
14
|
-
* @param userOptions.limit - Maximum number of retry attempts (default: 3)
|
|
15
|
-
* @param userOptions.delayMs - Delay between retries in milliseconds (default: 0, no delay)
|
|
16
|
-
* @param userOptions.timeout - Timeout for each attempt in milliseconds (default: 30000, set 0 to disable)
|
|
17
|
-
* @param userOptions.timeoutErrorMessage - Custom timeout error message
|
|
18
|
-
* @param userOptions.shouldRetryFn - Function to determine if retry should occur based on error, that will force throw even if limit is not reached when returns "false"
|
|
19
|
-
*
|
|
20
|
-
* @returns Promise that resolves with the operation result or rejects with the last error
|
|
21
|
-
*
|
|
22
|
-
* @throws {Error} Last error encountered after all retries are exhausted
|
|
23
|
-
* @throws {Error} Timeout error if operation exceeds specified timeout
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* // With custom options
|
|
27
|
-
* const result = await retryOperation(
|
|
28
|
-
* async () => await fetch(url),
|
|
29
|
-
* {
|
|
30
|
-
* limit: 5,
|
|
31
|
-
* delayMs: 1000,
|
|
32
|
-
* timeout: 5000,
|
|
33
|
-
* shouldRetryFn: (error) => error.status === 429
|
|
34
|
-
* }
|
|
35
|
-
* );
|
|
36
|
-
*/
|
|
37
|
-
export declare function retryOperation<T>(operation: () => Promise<T>, userOptions?: RetryOptions): Promise<T>;
|
|
38
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { RunningToolCall } from '../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Whether the agent is waiting on a tool call before it can continue.
|
|
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
|
|
26
|
-
*/
|
|
27
|
-
export declare function isAwaitingTool(calls: readonly RunningToolCall[]): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Best-effort user context (location + device) resolved entirely on the client
|
|
3
|
-
* and attached to the LiveKit participant as attributes on connect. The agent
|
|
4
|
-
* backend reads these to enrich the LLM context (see `get_user_context`).
|
|
5
|
-
*
|
|
6
|
-
* `location` is the IANA timezone (e.g. `America/New_York`) — a coarse but
|
|
7
|
-
* network-free location proxy. `device` is a short human-readable descriptor.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Non-empty `{ timezone, device }` attributes to attach to the participant.
|
|
11
|
-
* Keys with no resolvable value are omitted. The backend infers the user's
|
|
12
|
-
* country from the timezone (a timezone identifies a country reliably, but its
|
|
13
|
-
* reference city is not the user's actual city).
|
|
14
|
-
*/
|
|
15
|
-
export declare function getUserContextAttributes(): Record<string, string>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|