@d-id/client-sdk 3.0.0-staging.414 → 3.0.0-staging.416

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 (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/dist/index-DCAt0P7O.js +2062 -0
  4. package/dist/index.d.ts +3525 -0
  5. package/dist/index.js +1 -1
  6. package/dist/index.umd.cjs +13 -13
  7. package/dist/{index-DBWnR72S.js → livekit-client.esm-QkbCKsng.js} +6234 -8269
  8. package/dist/livekit-manager-Cj0YXe2U.js +557 -0
  9. package/package.json +33 -9
  10. package/dist/livekit-manager-BM3JMzT5.js +0 -531
  11. package/dist/src/api/agents.d.ts +0 -18
  12. package/dist/src/api/apiClient.d.ts +0 -11
  13. package/dist/src/api/apiClient.test.d.ts +0 -1
  14. package/dist/src/api/knowledge.d.ts +0 -15
  15. package/dist/src/api/streams/index.d.ts +0 -1
  16. package/dist/src/api/streams/streamApi.d.ts +0 -3
  17. package/dist/src/api/streams/streamApi.test.d.ts +0 -1
  18. package/dist/src/api/streams/streamsApiV2.d.ts +0 -5
  19. package/dist/src/auth/get-auth-header.d.ts +0 -5
  20. package/dist/src/auth/get-auth-header.test.d.ts +0 -1
  21. package/dist/src/config/consts.d.ts +0 -3
  22. package/dist/src/config/environment.d.ts +0 -5
  23. package/dist/src/errors/base-error.d.ts +0 -182
  24. package/dist/src/errors/chat/chat-creation-failed.d.ts +0 -30
  25. package/dist/src/errors/chat/chat-mode-downgraded.d.ts +0 -35
  26. package/dist/src/errors/errors.test.d.ts +0 -1
  27. package/dist/src/errors/http-error.d.ts +0 -74
  28. package/dist/src/errors/index.d.ts +0 -9
  29. package/dist/src/errors/network-error.d.ts +0 -72
  30. package/dist/src/errors/request-meta.d.ts +0 -12
  31. package/dist/src/errors/stream-error.d.ts +0 -37
  32. package/dist/src/errors/validation-error.d.ts +0 -67
  33. package/dist/src/errors/ws-error.d.ts +0 -34
  34. package/dist/src/index.d.ts +0 -20
  35. package/dist/src/public-api.test.d.ts +0 -1
  36. package/dist/src/services/agent-manager/connect-to-manager.d.ts +0 -19
  37. package/dist/src/services/agent-manager/connect-to-manager.test.d.ts +0 -1
  38. package/dist/src/services/agent-manager/index.d.ts +0 -64
  39. package/dist/src/services/agent-manager/index.test.d.ts +0 -1
  40. package/dist/src/services/analytics/mixpanel.d.ts +0 -22
  41. package/dist/src/services/analytics/mixpanel.test.d.ts +0 -1
  42. package/dist/src/services/analytics/timestamp-tracker.d.ts +0 -15
  43. package/dist/src/services/chat/index.d.ts +0 -10
  44. package/dist/src/services/chat/index.test.d.ts +0 -1
  45. package/dist/src/services/chat/intial-messages.d.ts +0 -3
  46. package/dist/src/services/chat/intial-messages.test.d.ts +0 -1
  47. package/dist/src/services/socket-manager/index.d.ts +0 -12
  48. package/dist/src/services/socket-manager/message-queue.d.ts +0 -12
  49. package/dist/src/services/socket-manager/message-queue.test.d.ts +0 -1
  50. package/dist/src/services/streaming-manager/advanced.test.d.ts +0 -1
  51. package/dist/src/services/streaming-manager/business-flows.test.d.ts +0 -5
  52. package/dist/src/services/streaming-manager/common.d.ts +0 -101
  53. package/dist/src/services/streaming-manager/data-channel-handlers.d.ts +0 -3
  54. package/dist/src/services/streaming-manager/disconnect.test.d.ts +0 -5
  55. package/dist/src/services/streaming-manager/edge-cases.test.d.ts +0 -1
  56. package/dist/src/services/streaming-manager/factory.d.ts +0 -13
  57. package/dist/src/services/streaming-manager/factory.test.d.ts +0 -1
  58. package/dist/src/services/streaming-manager/index.d.ts +0 -5
  59. package/dist/src/services/streaming-manager/livekit-manager.d.ts +0 -10
  60. package/dist/src/services/streaming-manager/livekit-manager.test.d.ts +0 -1
  61. package/dist/src/services/streaming-manager/stats/av-sync.d.ts +0 -3
  62. package/dist/src/services/streaming-manager/stats/av-sync.test.d.ts +0 -1
  63. package/dist/src/services/streaming-manager/stats/poll.d.ts +0 -16
  64. package/dist/src/services/streaming-manager/stats/report.d.ts +0 -19
  65. package/dist/src/services/streaming-manager/stats/report.test.d.ts +0 -1
  66. package/dist/src/services/streaming-manager/webrtc-core.test.d.ts +0 -1
  67. package/dist/src/services/streaming-manager/webrtc-manager.d.ts +0 -12
  68. package/dist/src/services/streaming-manager/webrtc-utils.test.d.ts +0 -5
  69. package/dist/src/test-utils/factories/agent-manager.factory.d.ts +0 -3
  70. package/dist/src/test-utils/factories/agent.factory.d.ts +0 -4
  71. package/dist/src/test-utils/factories/agents-api.factory.d.ts +0 -1
  72. package/dist/src/test-utils/factories/analytics.factory.d.ts +0 -1
  73. package/dist/src/test-utils/factories/chat.factory.d.ts +0 -1
  74. package/dist/src/test-utils/factories/index.d.ts +0 -8
  75. package/dist/src/test-utils/factories/socket-manager.factory.d.ts +0 -1
  76. package/dist/src/test-utils/factories/stream-api.factory.d.ts +0 -1
  77. package/dist/src/test-utils/factories/streaming-manager.factory.d.ts +0 -4
  78. package/dist/src/types/auth.d.ts +0 -95
  79. package/dist/src/types/entities/agents/agent.d.ts +0 -202
  80. package/dist/src/types/entities/agents/chat.d.ts +0 -476
  81. package/dist/src/types/entities/agents/index.d.ts +0 -3
  82. package/dist/src/types/entities/agents/manager.d.ts +0 -897
  83. package/dist/src/types/entities/avatar.d.ts +0 -21
  84. package/dist/src/types/entities/index.d.ts +0 -3
  85. package/dist/src/types/entities/knowledge/document.d.ts +0 -31
  86. package/dist/src/types/entities/knowledge/index.d.ts +0 -4
  87. package/dist/src/types/entities/knowledge/knowledge.d.ts +0 -56
  88. package/dist/src/types/entities/knowledge/record.d.ts +0 -24
  89. package/dist/src/types/entities/knowledge/retrival.d.ts +0 -9
  90. package/dist/src/types/face-rect.d.ts +0 -6
  91. package/dist/src/types/index.d.ts +0 -6
  92. package/dist/src/types/stream/api/clip.d.ts +0 -122
  93. package/dist/src/types/stream/api/index.d.ts +0 -2
  94. package/dist/src/types/stream/api/talk.d.ts +0 -77
  95. package/dist/src/types/stream/data-channel.d.ts +0 -16
  96. package/dist/src/types/stream/index.d.ts +0 -4
  97. package/dist/src/types/stream/rtc.d.ts +0 -125
  98. package/dist/src/types/stream/stream.d.ts +0 -856
  99. package/dist/src/types/stream/streams-v2.d.ts +0 -28
  100. package/dist/src/types/stream-script.d.ts +0 -138
  101. package/dist/src/types/voice/stt.d.ts +0 -16
  102. package/dist/src/types/voice/tts.d.ts +0 -238
  103. package/dist/src/utils/agent.d.ts +0 -8
  104. package/dist/src/utils/analytics.d.ts +0 -31
  105. package/dist/src/utils/analytics.test.d.ts +0 -1
  106. package/dist/src/utils/chat.d.ts +0 -4
  107. package/dist/src/utils/content-parser.d.ts +0 -35
  108. package/dist/src/utils/content-parser.test.d.ts +0 -1
  109. package/dist/src/utils/defer.d.ts +0 -7
  110. package/dist/src/utils/error-analytics.d.ts +0 -4
  111. package/dist/src/utils/error-analytics.test.d.ts +0 -1
  112. package/dist/src/utils/index.d.ts +0 -3
  113. package/dist/src/utils/retry-operation.d.ts +0 -38
  114. package/dist/src/utils/stream-end.d.ts +0 -5
  115. package/dist/src/utils/stream-end.test.d.ts +0 -1
  116. package/dist/src/utils/tool-calls.d.ts +0 -27
  117. package/dist/src/utils/tool-calls.test.d.ts +0 -1
  118. package/dist/src/utils/user-context.d.ts +0 -15
  119. package/dist/src/utils/user-context.test.d.ts +0 -1
  120. package/dist/src/version.d.ts +0 -7
@@ -1,182 +0,0 @@
1
- /**
2
- * The JSON-safe payload {@link BaseError.toJson | toJson()} produces, for logs and error reports.
3
- *
4
- * Only the fields the SDK deliberately exposes are present, so the payload can be forwarded to a
5
- * logging service as it is. Subclasses add their own keys: {@link HttpError} adds `httpStatus` and,
6
- * when the failing call is known, `endpoint` and `method`; {@link NetworkError} adds `endpoint`,
7
- * `method`, `durationMs`, `online` and `visibility`.
8
- *
9
- * @example An HttpError from a request that was refused
10
- * ```json
11
- * {
12
- * "kind": "InsufficientCreditsError",
13
- * "message": "Account has insufficient credits",
14
- * "httpStatus": 402,
15
- * "endpoint": "/agt_x/chat/cht_y",
16
- * "method": "POST"
17
- * }
18
- * ```
19
- * @category Errors
20
- */
21
- export interface ErrorJson {
22
- /**
23
- * Stable machine-readable code for the failure — the error's {@link BaseError.kind | kind}.
24
- */
25
- kind: string;
26
- /**
27
- * Human-readable description of the failure — the error's `message`.
28
- */
29
- message: string;
30
- /**
31
- * Message of the error that caused this one, truncated to 256 characters.
32
- *
33
- * Present only when {@link BaseError.originalError | originalError} is an `Error` and its
34
- * message differs from {@link ErrorJson.message | message}. A cause that is not an `Error` is
35
- * never serialized, so an arbitrary object carrying credentials cannot end up in the payload.
36
- */
37
- cause?: string;
38
- /**
39
- * Additional fields contributed by a subclass, such as `httpStatus` on {@link HttpError}.
40
- */
41
- [key: string]: any;
42
- }
43
- /**
44
- * Base class of every error the SDK itself raises.
45
- *
46
- * Catching `BaseError` catches everything the SDK classified; branch on
47
- * {@link BaseError.kind | kind}, which is stable, rather than on the message, which is not.
48
- * Errors reach the application two ways, and each subclass says which applies: some are thrown to
49
- * the caller of the method, so they reject the promise it returned; others are handed to
50
- * {@link AgentManagerCallbacks.onError | onError} because no call of yours was in flight when they
51
- * happened. {@link HttpError} and {@link NetworkError} do both — the request that failed rejects,
52
- * and the callback is notified as well.
53
- *
54
- * Not everything that reaches the application is one of these. The streaming transport is the main
55
- * exception: a failure LiveKit raises inside a media call on an Expressive (V4) agent — no
56
- * microphone publication to replace, a room that is not connected — rejects with a plain `Error`,
57
- * and so do a few low-level guards inside {@link AgentManager.connect | connect()}, such as a
58
- * `livekit-client` package that is not installed, a transport the SDK does not recognise, or a
59
- * stream the server created without a session id. An unknown
60
- * {@link AgentManagerOptions.auth | auth} type is a plain `Error` too. So keep the
61
- * `else throw error` branch in a handler built on {@link isDIDError}.
62
- *
63
- * Subclasses: {@link HttpError}, {@link NetworkError}, {@link WsError}, {@link StreamError},
64
- * {@link ValidationError}, {@link ChatCreationFailed} and {@link ChatModeDowngraded}. When the
65
- * caught value is typed `unknown`, {@link isDIDError} narrows it to this class.
66
- *
67
- * @category Errors
68
- */
69
- export declare class BaseError extends Error {
70
- /**
71
- * Stable machine-readable code for this failure, and the value to branch on.
72
- *
73
- * Every subclass redeclares it as the literal it always carries, so a `switch` on `kind`
74
- * narrows the caught error to that class: `'NetworkError'` on {@link NetworkError},
75
- * `'WSError'` on {@link WsError}, `'StreamError'` on {@link StreamError},
76
- * `'ValidationError'` on {@link ValidationError}, `'ChatCreationFailed'` on
77
- * {@link ChatCreationFailed} and `'ChatModeDowngraded'` on {@link ChatModeDowngraded}.
78
- * {@link HttpError} is the one that stays a plain `string`, because it reuses the server's
79
- * own classification when the response carries one and is `'HttpError'` otherwise. On a
80
- * `BaseError` built directly it is whatever the caller passed, and `'Error'` when nothing
81
- * was.
82
- */
83
- readonly kind: string;
84
- /**
85
- * The error or value that caused this one, when the SDK was wrapping something else.
86
- *
87
- * For a {@link NetworkError} this is the browser's own `fetch` rejection. It is not
88
- * serialized as-is: {@link BaseError.toJson | toJson()} takes only an `Error` cause's
89
- * message.
90
- */
91
- readonly originalError?: unknown | undefined;
92
- /**
93
- * Creates an SDK error. The SDK builds these itself; applications normally only catch them.
94
- *
95
- * @param message - Human-readable description of the failure, used as the `Error` message.
96
- * @param kind - Stable machine-readable code for the failure.
97
- * @param originalError - The underlying error or value this one wraps, when there is one.
98
- */
99
- constructor(message: string,
100
- /**
101
- * Stable machine-readable code for this failure, and the value to branch on.
102
- *
103
- * Every subclass redeclares it as the literal it always carries, so a `switch` on `kind`
104
- * narrows the caught error to that class: `'NetworkError'` on {@link NetworkError},
105
- * `'WSError'` on {@link WsError}, `'StreamError'` on {@link StreamError},
106
- * `'ValidationError'` on {@link ValidationError}, `'ChatCreationFailed'` on
107
- * {@link ChatCreationFailed} and `'ChatModeDowngraded'` on {@link ChatModeDowngraded}.
108
- * {@link HttpError} is the one that stays a plain `string`, because it reuses the server's
109
- * own classification when the response carries one and is `'HttpError'` otherwise. On a
110
- * `BaseError` built directly it is whatever the caller passed, and `'Error'` when nothing
111
- * was.
112
- */
113
- kind?: string,
114
- /**
115
- * The error or value that caused this one, when the SDK was wrapping something else.
116
- *
117
- * For a {@link NetworkError} this is the browser's own `fetch` rejection. It is not
118
- * serialized as-is: {@link BaseError.toJson | toJson()} takes only an `Error` cause's
119
- * message.
120
- */
121
- originalError?: unknown | undefined);
122
- /**
123
- * Serializes the error into the JSON-safe {@link ErrorJson} payload for logging or reporting.
124
- *
125
- * The payload always carries {@link BaseError.kind | kind} and the message. The cause's message
126
- * is added only when {@link BaseError.originalError | originalError} is an `Error` and says
127
- * something the message does not, truncated to 256 characters; any other cause is dropped.
128
- * Subclasses extend the payload with the fields listed on their own pages.
129
- *
130
- * @returns The error as plain, JSON-serializable data.
131
- * @example An HttpError from a request that was refused
132
- * ```json
133
- * {
134
- * "kind": "InsufficientCreditsError",
135
- * "message": "Account has insufficient credits",
136
- * "httpStatus": 402,
137
- * "endpoint": "/agt_x/chat/cht_y",
138
- * "method": "POST"
139
- * }
140
- * ```
141
- * @example A NetworkError from a request that never left the browser
142
- * ```json
143
- * {
144
- * "kind": "NetworkError",
145
- * "message": "Network request failed",
146
- * "cause": "Failed to fetch",
147
- * "endpoint": "/agt_x/chat/cht_y",
148
- * "method": "POST",
149
- * "durationMs": 12,
150
- * "online": false,
151
- * "visibility": "visible"
152
- * }
153
- * ```
154
- */
155
- toJson(): ErrorJson;
156
- }
157
- /**
158
- * Type guard that reports whether a caught value is an error raised by the SDK.
159
- *
160
- * It accepts any `Error` carrying a string `kind`, which every {@link BaseError} has, so it also
161
- * recognizes SDK errors that crossed a bundle boundary, where `instanceof BaseError` can fail
162
- * because two copies of the class are loaded. Narrowing with it gives typed access to
163
- * {@link BaseError.kind | kind}, {@link BaseError.originalError | originalError} and
164
- * {@link BaseError.toJson | toJson()}.
165
- *
166
- * @param error - The caught value to test.
167
- * @returns `true` when `error` is a {@link BaseError}.
168
- * @example
169
- * ```ts
170
- * try {
171
- * await agentManager.chat('What is the distance to the moon?');
172
- * } catch (error) {
173
- * if (isDIDError(error)) {
174
- * console.error(error.kind, error.toJson());
175
- * } else {
176
- * throw error;
177
- * }
178
- * }
179
- * ```
180
- * @category Errors
181
- */
182
- export declare function isDIDError(error: unknown): error is BaseError;
@@ -1,30 +0,0 @@
1
- import { ChatMode } from '../../types';
2
- import { BaseError } from '../base-error';
3
-
4
- /**
5
- * A chat could not be created for the session.
6
- *
7
- * {@link AgentManager.chat | chat()} creates a chat on the first message when the session does not
8
- * have one yet; this error is thrown when that call comes back without one, so it rejects the
9
- * promise `chat()` returned and the user's message is not sent. It is not delivered to
10
- * {@link AgentManagerCallbacks.onError | onError} — catch it around `chat()`. A failing request
11
- * surfaces as {@link HttpError} or {@link NetworkError} instead; this error is the case where the
12
- * request succeeded but produced no chat.
13
- *
14
- * The message names the {@link ChatMode} in effect and whether a persistent chat was asked for, for
15
- * example `Failed to create persistent chat, mode: Functional`.
16
- * {@link BaseError.kind | kind} is `'ChatCreationFailed'`.
17
- *
18
- * @category Errors
19
- */
20
- export declare class ChatCreationFailed extends BaseError {
21
- /**
22
- * Always `'ChatCreationFailed'`. Branch on it to tell this failure from the other SDK errors.
23
- */
24
- readonly kind: 'ChatCreationFailed';
25
- /**
26
- * Builds the error from the attempt that failed.
27
- * @internal The SDK builds this itself; applications catch the error rather than construct it.
28
- */
29
- constructor(mode: ChatMode, persistent: boolean);
30
- }
@@ -1,35 +0,0 @@
1
- import { ChatMode } from '../../types';
2
- import { BaseError } from '../base-error';
3
-
4
- /**
5
- * The server put the session into a different chat mode from the one that was requested, and the
6
- * new mode cannot stream video.
7
- *
8
- * Raised while {@link AgentManager.connect | connect()} runs, when the chat the server created came
9
- * back in a mode other than the requested {@link AgentManagerOptions.mode | mode} and that mode is
10
- * not {@link ChatMode.Functional | Functional} — {@link ChatMode.TextOnly | TextOnly} or
11
- * {@link ChatMode.Maintenance | Maintenance}, for instance. The comparison only runs when `mode` was
12
- * set in the options, so a session that never asked for a mode never sees this error. The SDK
13
- * disconnects the stream it had just opened and `connect()` resolves anyway, so no video will play
14
- * and {@link AgentManagerCallbacks.onSrcObjectReady | onSrcObjectReady} will not fire again: the
15
- * session continues as a text chat.
16
- *
17
- * It is delivered to {@link AgentManagerCallbacks.onError | onError} and never thrown, so
18
- * `connect()` does not reject on it.
19
- * {@link AgentManagerCallbacks.onModeChange | onModeChange} fires with the new mode just before it.
20
- * Treat it as a signal to switch the interface to text, not as a connection failure.
21
- * {@link BaseError.kind | kind} is `'ChatModeDowngraded'`.
22
- *
23
- * @category Errors
24
- */
25
- export declare class ChatModeDowngraded extends BaseError {
26
- /**
27
- * Always `'ChatModeDowngraded'`. Branch on it to tell this failure from the other SDK errors.
28
- */
29
- readonly kind: 'ChatModeDowngraded';
30
- /**
31
- * Builds the error from the mode the session ended up in.
32
- * @internal The SDK builds this itself; applications catch the error rather than construct it.
33
- */
34
- constructor(mode: ChatMode);
35
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,74 +0,0 @@
1
- import { BaseError, ErrorJson } from './base-error';
2
- import { RequestMeta } from './request-meta';
3
-
4
- /**
5
- * A request to the Agents API came back with a non-2xx status.
6
- *
7
- * Raised for every REST call the SDK makes on the application's behalf: fetching the agent in
8
- * {@link createAgentManager}, creating the stream and the chat during
9
- * {@link AgentManager.connect | connect()}, sending a message with
10
- * {@link AgentManager.chat | chat()}, and the rating and feedback calls. The same error is both
11
- * handed to {@link AgentManagerCallbacks.onError | onError} and thrown, so it also rejects the
12
- * promise of whichever method made the request — catch it around that call, or handle it centrally
13
- * in the callback. For the message-send request behind {@link AgentManager.chat | chat()} the
14
- * callback may not fire; the error is still thrown. Typical cases are `401` or `403` for a client
15
- * key that is not authorized for the agent or the calling domain, and `404` for an unknown agent
16
- * id; an account that is out of credits comes back with {@link BaseError.kind | kind}
17
- * `'InsufficientCreditsError'`. A `429` is retried twice, one second apart (three attempts in
18
- * total), before it surfaces.
19
- *
20
- * {@link BaseError.kind | kind} is the server's own classification when the response body is D-ID's
21
- * `{ kind, description }` envelope — the `'InsufficientCreditsError'` above is one — and
22
- * `'HttpError'` otherwise, so a message-independent branch on a specific API failure is possible.
23
- *
24
- * The message is the envelope's `description` when the body is that JSON, and the raw body
25
- * otherwise — truncated to 256 characters either way, because a gateway can answer a 5xx with a
26
- * whole HTML page.
27
- *
28
- * @category Errors
29
- */
30
- export declare class HttpError extends BaseError {
31
- /**
32
- * The server's own classification of the failure, and `'HttpError'` when the response body was
33
- * not D-ID's `{ kind, description }` envelope.
34
- *
35
- * The only {@link BaseError.kind | kind} in the SDK that is not a fixed literal, so it stays
36
- * typed `string`: an account out of credits comes back as `'InsufficientCreditsError'`, for
37
- * instance. Use {@link HttpError.status | status} for the transport-level branch and this for
38
- * the API-level one.
39
- */
40
- readonly kind: string;
41
- /**
42
- * HTTP status code of the response, such as `401`, `404` or `500`.
43
- */
44
- readonly status: number;
45
- /**
46
- * Path of the request that failed, relative to the API client's base path — for example
47
- * `/agt_x/chat/cht_y` for a message sent to a chat.
48
- *
49
- * Absent when the error was constructed without call context. {@link NetworkError.endpoint}
50
- * is the same value on a transport failure.
51
- */
52
- readonly endpoint?: string;
53
- /**
54
- * HTTP method of the request that failed, such as `GET` or `POST`.
55
- *
56
- * Absent when the error was constructed without call context.
57
- */
58
- readonly method?: string;
59
- /**
60
- * Builds the error from the failing response.
61
- * @internal The SDK builds this itself; applications catch the error rather than construct it.
62
- */
63
- constructor(status: number, body: string, meta?: RequestMeta);
64
- /**
65
- * Serializes the error, adding the failing call to what
66
- * {@link BaseError.toJson | BaseError.toJson()} already returns.
67
- *
68
- * Adds `httpStatus` from {@link HttpError.status | status}, and `endpoint` and `method` when the
69
- * call context is known. The raw `status` property is serialized as `httpStatus`.
70
- *
71
- * @returns The error as plain, JSON-serializable data.
72
- */
73
- toJson(): ErrorJson;
74
- }
@@ -1,9 +0,0 @@
1
- export * from './base-error';
2
- export * from './chat/chat-creation-failed';
3
- export * from './chat/chat-mode-downgraded';
4
- export * from './http-error';
5
- export * from './network-error';
6
- export * from './request-meta';
7
- export * from './stream-error';
8
- export * from './validation-error';
9
- export * from './ws-error';
@@ -1,72 +0,0 @@
1
- import { BaseError, ErrorJson } from './base-error';
2
- import { RequestMeta } from './request-meta';
3
-
4
- /**
5
- * A request to the Agents API never reached the server, so no response came back.
6
- *
7
- * This is the transport failure counterpart of {@link HttpError}, where the server did answer: the
8
- * browser's `fetch` rejected outright because the device is offline, DNS or TLS failed, the
9
- * connection was refused or the request was blocked, for instance by CORS or an extension. Like
10
- * {@link HttpError} it is both handed to {@link AgentManagerCallbacks.onError | onError} and
11
- * thrown, so it also rejects the promise of the method that made the request; for the message-send
12
- * request behind {@link AgentManager.chat | chat()} the callback may not fire, but the error is
13
- * still thrown. A request the SDK cancelled itself is not reported this way — the browser's own
14
- * `AbortError` is rethrown unchanged.
15
- *
16
- * The message is always `'Network request failed'`; the browser's own wording, such as
17
- * `'Failed to fetch'`, is kept in {@link BaseError.originalError | originalError} and appears as
18
- * `cause` in {@link NetworkError.toJson | toJson()}. The remaining properties record what was
19
- * happening at the time, which is usually what distinguishes a dropped connection from a tab that
20
- * was backgrounded.
21
- *
22
- * @category Errors
23
- */
24
- export declare class NetworkError extends BaseError {
25
- /**
26
- * Always `'NetworkError'`. Branch on it to tell this failure from the other SDK errors.
27
- */
28
- readonly kind: 'NetworkError';
29
- /**
30
- * Path of the request that failed, relative to the API client's base path — for example
31
- * `/agt_x/chat/cht_y`.
32
- */
33
- readonly endpoint?: string;
34
- /**
35
- * HTTP method of the request that failed, such as `GET` or `POST`.
36
- */
37
- readonly method?: string;
38
- /**
39
- * How long the request ran before it failed, in milliseconds.
40
- *
41
- * A value close to zero usually means the request never left the browser; a large one points
42
- * at a connection that was established and then lost.
43
- */
44
- readonly durationMs?: number;
45
- /**
46
- * The browser's `navigator.onLine` at the moment of the failure — `false` when the device
47
- * reported itself offline.
48
- */
49
- readonly online?: boolean;
50
- /**
51
- * The page's `document.visibilityState` at the moment of the failure.
52
- *
53
- * `'hidden'` means the tab was in the background, where browsers throttle or suspend network
54
- * activity.
55
- */
56
- readonly visibility?: DocumentVisibilityState;
57
- /**
58
- * Wraps a rejected `fetch` together with what was known about the call.
59
- * @internal The SDK builds this itself; applications catch the error rather than construct it.
60
- */
61
- constructor(originalError?: unknown, meta?: RequestMeta);
62
- /**
63
- * Serializes the error, adding the captured context to what
64
- * {@link BaseError.toJson | BaseError.toJson()} already returns.
65
- *
66
- * Each of `endpoint`, `method`, `durationMs`, `online` and `visibility` is included only when it
67
- * was captured.
68
- *
69
- * @returns The error as plain, JSON-serializable data.
70
- */
71
- toJson(): ErrorJson;
72
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Request context recorded on an error: what was requested, how long it took and what the tab
3
- * could see of the network at the time. Shared by `HttpError` and `NetworkError`.
4
- * @internal Implementation type; not part of the public SDK surface.
5
- */
6
- export interface RequestMeta {
7
- endpoint?: string;
8
- method?: string;
9
- durationMs?: number;
10
- online?: boolean;
11
- visibility?: DocumentVisibilityState;
12
- }
@@ -1,37 +0,0 @@
1
- import { BaseError } from './base-error';
2
-
3
- /**
4
- * Something went wrong inside the live audio and video stream.
5
- *
6
- * Unlike {@link HttpError} and {@link NetworkError}, which come from REST calls, this one comes
7
- * from the transport carrying the agent's video, so it is only ever delivered to
8
- * {@link AgentManagerCallbacks.onError | onError} — no call of yours is necessarily in flight when
9
- * it happens, and nothing throws it. The SDK raises it when:
10
- *
11
- * - no media track is subscribed within the timeout after the LiveKit room used by Expressive (V4)
12
- * agents connects, after which the SDK disconnects the stream;
13
- * - the LiveKit room reports a media-device or encryption failure;
14
- * - a message cannot be put on the data channel — the WebRTC channel used by Talks (V2) and Clips
15
- * (V3) is not open, or the LiveKit room is not connected or rejects the send;
16
- * - the server reports that the stream itself failed, with the message
17
- * `Stream failed with event <event>`.
18
- *
19
- * Most of these leave the session unusable, so the useful response is to tell the user and call
20
- * {@link AgentManager.reconnect | reconnect()}. {@link BaseError.kind | kind} is `'StreamError'`.
21
- * The message describes the failure, and is the plain `'Stream Error'` when the transport gave no
22
- * detail; the underlying error, where there was one, is kept as
23
- * {@link BaseError.originalError | originalError}.
24
- *
25
- * @category Errors
26
- */
27
- export declare class StreamError extends BaseError {
28
- /**
29
- * Always `'StreamError'`. Branch on it to tell this failure from the other SDK errors.
30
- */
31
- readonly kind: 'StreamError';
32
- /**
33
- * Wraps a streaming failure.
34
- * @internal The SDK builds this itself; applications catch the error rather than construct it.
35
- */
36
- constructor(message: string, originalError?: unknown);
37
- }
@@ -1,67 +0,0 @@
1
- import { BaseError } from './base-error';
2
-
3
- /**
4
- * A method was called with arguments, or in a state, that the SDK will not send to the Agents
5
- * API.
6
- *
7
- * This is one of the two SDK errors that only ever reach the caller and are never delivered to
8
- * {@link AgentManagerCallbacks.onError | onError} (the other is {@link ChatCreationFailed}): it is
9
- * the direct answer to the call you just made, and every method that raises it rejects the promise
10
- * it returned, so `await` the call inside a `try`/`catch` or attach a `.catch()`. The SDK raises it
11
- * from
12
- * {@link AgentManager.chat | chat()} when the message is empty or 2000 characters or longer, when
13
- * the session's {@link ChatMode} has chat disabled or is in maintenance, and when the chat or the
14
- * stream has not been initialized yet; from {@link AgentManager.speak | speak()} when it is called
15
- * before {@link AgentManager.connect | connect()}; and from
16
- * {@link AgentManager.rate | rate()}, {@link AgentManager.deleteRate | deleteRate()} and
17
- * {@link AgentManager.submitFeedback | submitFeedback()} when no chat has started, plus, for
18
- * `rate()` alone, when no message with the given id is in the transcript. It is also raised from
19
- * {@link createAgentManager} and {@link AgentManager.changeMode | changeMode()} when an Expressive
20
- * (V4) agent is asked for {@link ChatMode.Off} or {@link ChatMode.DirectPlayback}, which only Talks
21
- * (V2) and Clips (V3) agents support. The five Expressive-only media methods —
22
- * {@link AgentManager.publishMicrophoneStream | publishMicrophoneStream()},
23
- * {@link AgentManager.replaceMicrophoneTrack | replaceMicrophoneTrack()},
24
- * {@link AgentManager.publishCameraStream | publishCameraStream()},
25
- * {@link AgentManager.setSttLanguage | setSttLanguage()} and
26
- * {@link AgentManager.sendDataChannelMessage | sendDataChannelMessage()} — raise it the other way
27
- * round: when the session is a Talks (V2) or Clips (V3) one, or
28
- * {@link AgentManager.connect | connect()} has not run yet.
29
- *
30
- * Nothing was sent to the Agents API when this is raised, so the session stays usable: fix the
31
- * argument or wait for {@link ConnectionState.Connected | 'connected'} and call again.
32
- * {@link BaseError.kind | kind} is `'ValidationError'`.
33
- *
34
- * @category Errors
35
- */
36
- export declare class ValidationError extends BaseError {
37
- /**
38
- * Name of the field the failure is about.
39
- *
40
- * The SDK does not populate it — every validation it raises passes the message alone — so it
41
- * is only set on a `ValidationError` an application constructed itself. It is also left out
42
- * of {@link BaseError.toJson | toJson()}, so a serialized validation error carries only its
43
- * kind and message.
44
- */
45
- readonly key?: string | undefined;
46
- /**
47
- * Always `'ValidationError'`. Branch on it to tell this failure from the other SDK errors.
48
- */
49
- readonly kind: 'ValidationError';
50
- /**
51
- * Builds a validation failure. The SDK does this itself before it performs a request.
52
- *
53
- * @param message - What was wrong with the call, such as `'Message cannot be empty'`.
54
- * @param key - Name of the field the failure is about. The SDK's own validations leave it
55
- * unset.
56
- */
57
- constructor(message: string,
58
- /**
59
- * Name of the field the failure is about.
60
- *
61
- * The SDK does not populate it — every validation it raises passes the message alone — so it
62
- * is only set on a `ValidationError` an application constructed itself. It is also left out
63
- * of {@link BaseError.toJson | toJson()}, so a serialized validation error carries only its
64
- * kind and message.
65
- */
66
- key?: string | undefined);
67
- }
@@ -1,34 +0,0 @@
1
- import { BaseError } from './base-error';
2
-
3
- /**
4
- * The web socket the SDK uses for chat notifications failed to connect.
5
- *
6
- * Talks (V2) and Clips (V3) sessions open a web socket alongside the video stream; the agent's
7
- * answer arrives over it as `partial` and `answer` events, which is what drives
8
- * {@link AgentManagerCallbacks.onNewMessage | onNewMessage}. This error is raised when that socket
9
- * emits an `error` event, once per failed attempt while
10
- * {@link AgentManager.connect | connect()} is retrying. It is only delivered to
11
- * {@link AgentManagerCallbacks.onError | onError} and never thrown, so there is nothing to catch
12
- * around `connect()` for it; if every attempt fails, `connect()` rejects with the browser's own
13
- * socket event instead.
14
- *
15
- * The socket is not opened at all for Expressive (V4) agents, which receive the same events over
16
- * the LiveKit data channel, nor in {@link ChatMode.DirectPlayback | DirectPlayback} mode, so the
17
- * error cannot occur in either case.
18
- *
19
- * {@link BaseError.kind | kind} is `'WSError'`, and the message is
20
- * `'Websocket failed to connect'`.
21
- *
22
- * @category Errors
23
- */
24
- export declare class WsError extends BaseError {
25
- /**
26
- * Always `'WSError'` — note the capitalization, which does not match the class name.
27
- */
28
- readonly kind: 'WSError';
29
- /**
30
- * Wraps a web socket failure, built from the socket's `error` event.
31
- * @internal The SDK builds this itself; applications catch the error rather than construct it.
32
- */
33
- constructor(message: string);
34
- }
@@ -1,20 +0,0 @@
1
- export { createAgentManager } from './services/agent-manager';
2
- export type { Auth, BasicAuth, BearerToken, ClientKeyAuth } from './types/auth';
3
- export type { Agent, AgentAvatar, EndOfCallFeedbackConfig } from './types/entities/agents/agent';
4
- export type { AgentManager, AgentManagerCallbacks, AgentManagerOptions, StreamOptions, } from './types/entities/agents/manager';
5
- export { AvatarType } from './types/entities/avatar';
6
- export type { SttTokenResponse } from './types/voice/stt';
7
- export { AgentActivityState, ConnectionState, ConnectivityState, DataChannelTopic, StreamEndReason, StreamingState, ToolCallEvent, } from './types/stream/stream';
8
- export type { ClientToolHandler, RunningToolCall, StreamCreatedInfo, ToolCallDonePayload, ToolCallErrorPayload, ToolCallStartedPayload, ToolEventCallback, ToolExecutionMode, } from './types/stream/stream';
9
- export type { SpeakResponse } from './types/stream/rtc';
10
- export { StreamType } from './types/stream/stream';
11
- export type { CompatibilityMode } from './types/stream/stream';
12
- export type { AudioStreamScript, SpeakScript, TextStreamScript } from './types/stream-script';
13
- export { ChatMode } from './types/entities/agents/chat';
14
- export type { ChatResponse, InterruptOptions, Message, MessagePart, MessageSentiment, Rating, RetrievalMetadata, SubmitFeedbackResponse, } from './types/entities/agents/chat';
15
- export { parseMessageParts } from './utils/content-parser';
16
- export { isAwaitingTool } from './utils/tool-calls';
17
- export { Providers, VoiceAccess } from './types/voice/tts';
18
- export type { AmazonTtsProvider, AzureOpenAiTtsProvider, ElevenlabsTtsProvider, MicrosoftTtsProvider, TtsProvider, Voice, VoiceConfigElevenlabs, VoiceConfigMicrosoft, } from './types/voice/tts';
19
- export { BaseError, ChatCreationFailed, ChatModeDowngraded, HttpError, NetworkError, StreamError, ValidationError, WsError, isDIDError, } from './errors';
20
- export type { ErrorJson } from './errors';
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { StreamingManager } from '../streaming-manager';
2
- import { Agent, AgentManagerOptions, AgentsAPI, AudioDetectionMetrics, Chat, ChatProgressCallback, CreateSessionV2Options, CreateStreamOptions, StreamingManagerOptions } from '../../types';
3
- import { Analytics } from '../analytics/mixpanel';
4
-
5
- type ConnectToManagerOptions = AgentManagerOptions & {
6
- callbacks: AgentManagerOptions['callbacks'] & {
7
- onVideoIdChange?: (videoId: string | null) => void;
8
- /** Internal callback for livekit-manager data channel events */
9
- onMessage?: ChatProgressCallback;
10
- onFirstAudioDetected?: (metrics: AudioDetectionMetrics) => void;
11
- };
12
- chatId?: string;
13
- rpcMethods?: StreamingManagerOptions['rpcMethods'];
14
- };
15
- export declare function initializeStreamAndChat(agent: Agent, options: ConnectToManagerOptions, agentsApi: AgentsAPI, analytics: Analytics, chat?: Chat): Promise<{
16
- chat?: Chat;
17
- streamingManager?: StreamingManager<CreateStreamOptions | CreateSessionV2Options>;
18
- }>;
19
- export {};