@d-id/client-sdk 2.0.10-staging.411 → 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.
- package/README.md +53 -264
- package/dist/{index-BgmEitAw.js → index-BLrKDuV_.js} +3002 -2825
- package/dist/index.js +23 -31
- package/dist/index.umd.cjs +5 -5
- package/dist/{livekit-manager-CgErNpNN.js → livekit-manager-Cfb9x2ei.js} +53 -50
- package/dist/src/api/agents.d.ts +1 -1
- package/dist/src/api/apiClient.d.ts +1 -1
- package/dist/src/api/knowledge.d.ts +1 -1
- package/dist/src/api/streams/streamApi.d.ts +1 -1
- package/dist/src/api/streams/streamsApiV2.d.ts +1 -1
- package/dist/src/errors/base-error.d.ts +170 -1
- package/dist/src/errors/chat/chat-creation-failed.d.ts +24 -0
- package/dist/src/errors/chat/chat-mode-downgraded.d.ts +29 -0
- package/dist/src/errors/http-error.d.ts +67 -5
- package/dist/src/errors/index.d.ts +1 -0
- package/dist/src/errors/network-error.d.ts +62 -8
- package/dist/src/errors/request-meta.d.ts +12 -0
- package/dist/src/errors/stream-error.d.ts +32 -0
- package/dist/src/errors/validation-error.d.ts +62 -1
- package/dist/src/errors/ws-error.d.ts +29 -0
- package/dist/src/index.d.ts +18 -4
- package/dist/src/public-api.test.d.ts +1 -0
- package/dist/src/services/agent-manager/index.d.ts +46 -6
- package/dist/src/services/chat/intial-messages.test.d.ts +1 -0
- package/dist/src/services/streaming-manager/common.d.ts +8 -3
- package/dist/src/types/auth.d.ts +78 -6
- package/dist/src/types/entities/agents/agent.d.ts +152 -6
- package/dist/src/types/entities/agents/chat.d.ts +384 -12
- package/dist/src/types/entities/agents/manager.d.ts +795 -215
- package/dist/src/types/entities/avatar.d.ts +21 -0
- package/dist/src/types/entities/index.d.ts +1 -1
- package/dist/src/types/entities/knowledge/document.d.ts +7 -8
- package/dist/src/types/entities/knowledge/knowledge.d.ts +20 -0
- package/dist/src/types/entities/knowledge/record.d.ts +8 -0
- package/dist/src/types/entities/knowledge/retrival.d.ts +4 -0
- package/dist/src/types/stream/api/clip.d.ts +8 -9
- package/dist/src/types/stream/api/talk.d.ts +8 -9
- package/dist/src/types/stream/rtc.d.ts +54 -4
- package/dist/src/types/stream/stream.d.ts +553 -34
- package/dist/src/types/stream/streams-v2.d.ts +12 -0
- package/dist/src/types/stream-script.d.ts +92 -19
- package/dist/src/types/voice/stt.d.ts +12 -0
- package/dist/src/types/voice/tts.d.ts +149 -64
- package/dist/src/utils/analytics.d.ts +2 -2
- package/dist/src/utils/content-parser.d.ts +31 -0
- package/dist/src/utils/tool-calls.d.ts +21 -2
- package/dist/src/version.d.ts +6 -0
- package/package.json +7 -3
- package/dist/src/types/entities/video.d.ts +0 -6
|
@@ -1,52 +1,198 @@
|
|
|
1
|
+
import { AvatarType } from '../avatar';
|
|
1
2
|
import { Chat, ChatPayload, ChatResponse } from './chat';
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The end-of-call feedback form configured on an agent.
|
|
6
|
+
*
|
|
7
|
+
* It describes what to ask the user when the conversation ends; the SDK does not render anything
|
|
8
|
+
* itself. Read it from {@link Agent.end_of_call_feedback}, show your own form when
|
|
9
|
+
* {@link EndOfCallFeedbackConfig.enabled | enabled} is set, and send the result with
|
|
10
|
+
* {@link AgentManager.submitFeedback | submitFeedback()}.
|
|
11
|
+
*
|
|
12
|
+
* @category Agent Manager
|
|
13
|
+
*/
|
|
3
14
|
export interface EndOfCallFeedbackConfig {
|
|
15
|
+
/** Whether the agent is configured to ask for feedback when a call ends. */
|
|
4
16
|
enabled: boolean;
|
|
17
|
+
/** The line to show the user as the call ends, before the rating is asked for. */
|
|
5
18
|
closing_message?: string;
|
|
19
|
+
/** Whether a free-text follow-up question should be asked after the rating. */
|
|
6
20
|
follow_up_enabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The follow-up question to ask, chosen by the score the user gave.
|
|
23
|
+
*
|
|
24
|
+
* Whichever one you show is what {@link AgentManager.submitFeedback | submitFeedback()} records
|
|
25
|
+
* as {@link SubmitFeedbackResponse.question_shown | question_shown}.
|
|
26
|
+
*/
|
|
7
27
|
follow_up_messages?: {
|
|
28
|
+
/** Question for a score at the low end of the scale. */
|
|
8
29
|
low?: string;
|
|
30
|
+
/** Question for a score of 4. */
|
|
9
31
|
four?: string;
|
|
32
|
+
/** Question for a score of 5. */
|
|
10
33
|
five?: string;
|
|
11
34
|
};
|
|
12
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The avatar an agent speaks through: its rendering tier and the language of its voice.
|
|
38
|
+
*
|
|
39
|
+
* The value of {@link Agent.avatar}. Its `type` is the single most important field on an agent: it
|
|
40
|
+
* decides which transport the session uses and therefore which SDK features work.
|
|
41
|
+
*
|
|
42
|
+
* @category Agent Manager
|
|
43
|
+
*/
|
|
44
|
+
export interface AgentAvatar {
|
|
45
|
+
/**
|
|
46
|
+
* The kind of avatar: {@link AvatarType.Talk | talk} for Talks (V2), {@link AvatarType.Clip | clip}
|
|
47
|
+
* for Clips (V3), {@link AvatarType.Expressive | expressive} for Expressive (V4).
|
|
48
|
+
*
|
|
49
|
+
* Talks (V2) and Clips (V3) agents stream over WebRTC and receive their events on the
|
|
50
|
+
* notifications web socket; Expressive (V4) agents connect to a real-time session instead, which
|
|
51
|
+
* is what makes the microphone, camera, client tool and data-channel methods of
|
|
52
|
+
* {@link AgentManager} available.
|
|
53
|
+
*/
|
|
54
|
+
type: AvatarType;
|
|
55
|
+
/** The voice the agent speaks with. */
|
|
56
|
+
voice?: {
|
|
57
|
+
/**
|
|
58
|
+
* Language of the configured voice. The SDK reports it in analytics; it does not change how
|
|
59
|
+
* the session behaves.
|
|
60
|
+
*/
|
|
61
|
+
language?: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* An agent's profile, as the Agents API returns it.
|
|
66
|
+
*
|
|
67
|
+
* The SDK fetches it once while {@link createAgentManager} runs and exposes it as
|
|
68
|
+
* {@link AgentManager.agent}, so everything here is available before
|
|
69
|
+
* {@link AgentManager.connect | connect()} — which is what makes it useful for rendering the agent
|
|
70
|
+
* before the video exists. The fields are the agent's configuration, whether it was set in D-ID Studio
|
|
71
|
+
* or through the Agents API; most of them are for the application to use, and each one below says
|
|
72
|
+
* where the SDK itself reads it.
|
|
73
|
+
*
|
|
74
|
+
* @see [Get an agent](https://docs.d-id.com/reference/agent-get)
|
|
75
|
+
* @category Agent Manager
|
|
76
|
+
*/
|
|
13
77
|
export interface Agent {
|
|
78
|
+
/** Id of the agent: the same value passed to {@link createAgentManager}. */
|
|
14
79
|
id: string;
|
|
80
|
+
/** Id of the D-ID account that owns the agent. Set by the Agents API. */
|
|
15
81
|
owner_id?: string;
|
|
82
|
+
/** The agent's display name. */
|
|
16
83
|
name?: string;
|
|
84
|
+
/** `'public'` when the agent is configured for public access; omitted otherwise. */
|
|
17
85
|
access?: 'public';
|
|
86
|
+
/** URL of the agent's still image. Use it as the poster of your video element before
|
|
87
|
+
* {@link AgentManager.connect | connect()} has a stream to show. */
|
|
18
88
|
thumbnail?: string;
|
|
89
|
+
/**
|
|
90
|
+
* The greeting lines configured for the agent.
|
|
91
|
+
*
|
|
92
|
+
* The SDK never speaks them by itself: pass one to {@link AgentManager.speak | speak()} once
|
|
93
|
+
* the agent is connected if you want the agent to open the conversation. Check what your own
|
|
94
|
+
* agent does first — an Expressive (V4) session's server side may greet on its own, in which
|
|
95
|
+
* case speaking a greeting as well says it twice.
|
|
96
|
+
*/
|
|
19
97
|
greetings?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Suggested opening questions to offer the user.
|
|
100
|
+
*
|
|
101
|
+
* The SDK surfaces the same array as {@link AgentManager.starterMessages | starterMessages}.
|
|
102
|
+
*/
|
|
20
103
|
starter_message?: string[];
|
|
104
|
+
/**
|
|
105
|
+
* URL of the agent's looping idle video.
|
|
106
|
+
*
|
|
107
|
+
* Show it while the agent is not speaking: put it on your video element's `src` when
|
|
108
|
+
* {@link AgentManagerCallbacks.onVideoStateChange | onVideoStateChange} reports `STOP`.
|
|
109
|
+
*/
|
|
21
110
|
idle_video?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The knowledge base attached to the agent, when it has one.
|
|
113
|
+
*
|
|
114
|
+
* Its presence is what tells you the agent can cite sources; the citations themselves arrive on
|
|
115
|
+
* each answer as {@link Message.matches | matches}.
|
|
116
|
+
*/
|
|
22
117
|
knowledge?: {
|
|
118
|
+
/**
|
|
119
|
+
* Id of the knowledge base.
|
|
120
|
+
*
|
|
121
|
+
* The SDK sends it with every rating made by {@link AgentManager.rate | rate()}, and it is
|
|
122
|
+
* the {@link RetrievalMetadata.knowledge_id | knowledge_id} of the citations on an answer.
|
|
123
|
+
*/
|
|
23
124
|
id: string;
|
|
125
|
+
/** The embedding model the knowledge base was indexed with. The SDK does not act on it. */
|
|
24
126
|
embedder?: {
|
|
127
|
+
/** Whether that embedding model covers only a limited set of languages, so knowledge
|
|
128
|
+
* written in another language may not be retrieved well. */
|
|
25
129
|
is_limited_language?: boolean;
|
|
26
130
|
};
|
|
27
131
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
132
|
+
/**
|
|
133
|
+
* The avatar the agent is built on.
|
|
134
|
+
*
|
|
135
|
+
* Its `type` is the single most important field on an agent: it decides which transport the
|
|
136
|
+
* session uses and therefore which SDK features work. See {@link AgentAvatar}.
|
|
137
|
+
*/
|
|
138
|
+
avatar: AgentAvatar;
|
|
139
|
+
/**
|
|
140
|
+
* Whether vision is enabled for the agent.
|
|
141
|
+
*
|
|
142
|
+
* Exposed so an application can decide whether to offer the camera; the SDK does not read it,
|
|
143
|
+
* and publishing a camera stream is an Expressive (V4) feature — see
|
|
144
|
+
* {@link AgentManager.publishCameraStream | publishCameraStream()}.
|
|
145
|
+
*/
|
|
34
146
|
vision?: {
|
|
147
|
+
/** `true` when the agent is configured to use the user's camera. */
|
|
35
148
|
enabled: boolean;
|
|
36
149
|
};
|
|
150
|
+
/**
|
|
151
|
+
* The end-of-call feedback form configured for the agent.
|
|
152
|
+
*
|
|
153
|
+
* The SDK does not read it: render your own form from it and submit the result with
|
|
154
|
+
* {@link AgentManager.submitFeedback | submitFeedback()}. See
|
|
155
|
+
* {@link EndOfCallFeedbackConfig}.
|
|
156
|
+
*/
|
|
37
157
|
end_of_call_feedback?: EndOfCallFeedbackConfig;
|
|
158
|
+
/** Whether the agent has triggers configured. The SDK does not act on them. */
|
|
38
159
|
triggers_available?: boolean;
|
|
160
|
+
/** Settings that change how D-ID's own surfaces present the agent. */
|
|
39
161
|
advanced_settings?: {
|
|
162
|
+
/**
|
|
163
|
+
* Whether the SDK logs its streaming lifecycle to the browser console.
|
|
164
|
+
*
|
|
165
|
+
* When it is enabled the SDK turns debug logging on for every visitor, whatever
|
|
166
|
+
* {@link AgentManagerOptions.debug | debug} was passed to {@link createAgentManager}.
|
|
167
|
+
*/
|
|
40
168
|
ui_debug_mode?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Account the agent's rendering VM is billed to.
|
|
171
|
+
*
|
|
172
|
+
* @internal D-ID internal; not part of the public SDK contract.
|
|
173
|
+
*/
|
|
41
174
|
vm_account_id?: string;
|
|
175
|
+
/** Whether the embedding UI should show closed captions. The SDK does not act on it. */
|
|
42
176
|
closed_captions_enabled?: boolean;
|
|
43
177
|
};
|
|
178
|
+
/**
|
|
179
|
+
* Feature-flag targeting context for the account this agent belongs to.
|
|
180
|
+
*
|
|
181
|
+
* @internal D-ID internal; not part of the public SDK contract.
|
|
182
|
+
*/
|
|
44
183
|
ld_context?: {
|
|
184
|
+
/** Key identifying the context. */
|
|
45
185
|
key: string;
|
|
186
|
+
/** Hashed form of the key. */
|
|
46
187
|
hash_key: string;
|
|
188
|
+
/** The plan group the account falls into. */
|
|
47
189
|
plan_group: string;
|
|
48
190
|
};
|
|
49
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Internal HTTP client surface used by the agent manager to talk to the Agents API.
|
|
194
|
+
* @internal Implementation type; not part of the public SDK surface.
|
|
195
|
+
*/
|
|
50
196
|
export interface AgentsAPI {
|
|
51
197
|
getRuntimeById(id: string, options?: RequestInit): Promise<Agent>;
|
|
52
198
|
newChat(agentId: string, payload: {
|