perso-interactive-sdk-web 1.5.1 → 1.6.0

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.
@@ -122,11 +122,292 @@ declare enum SessionCapabilityName {
122
122
  STF_ONPREMISE = "STF_ONPREMISE",
123
123
  STF_WEBRTC = "STF_WEBRTC"
124
124
  }
125
+ declare enum SessionEvent {
126
+ SESSION_START = "SESSION_START",
127
+ SESSION_DURING = "SESSION_DURING",
128
+ SESSION_LOG = "SESSION_LOG",
129
+ SESSION_END = "SESSION_END",
130
+ SESSION_ERROR = "SESSION_ERROR",
131
+ SESSION_TTS = "SESSION_TTS",
132
+ SESSION_STT = "SESSION_STT",
133
+ SESSION_LLM = "SESSION_LLM"
134
+ }
125
135
  interface TextNormalizationDownload {
126
136
  config_id: string;
127
137
  config_name: string;
128
138
  file_url: string;
129
139
  }
140
+ declare class PersoUtil {
141
+ /**
142
+ * @param apiServer Perso Interactive API Server
143
+ * @param apiKey Perso Interactive API Key
144
+ * @returns JSON
145
+ * [
146
+ * {
147
+ * "name": string
148
+ * }
149
+ * ]
150
+ */
151
+ static getLLMs(apiServer: string, apiKey: string): Promise<any>;
152
+ /**
153
+ * @param apiServer Perso Interactive API Server
154
+ * @param apiKey Perso Interactive API Key
155
+ * @returns JSON
156
+ * [
157
+ * {
158
+ * "name": string,
159
+ * "model": string,
160
+ * "style": string
161
+ * }
162
+ * ]
163
+ */
164
+ static getModelStyles(apiServer: string, apiKey: string): Promise<any>;
165
+ /**
166
+ * @param apiServer Perso Interactive API Server
167
+ * @param apiKey Perso Interactive API Key
168
+ * @returns JSON
169
+ * [
170
+ * {
171
+ * "backgroundimage_id": string,
172
+ * "title": string,
173
+ * "image": string
174
+ * "created_at": string // ex) "2024-05-02T09:05:55.395Z"
175
+ * }
176
+ * ]
177
+ */
178
+ static getBackgroundImages(apiServer: string, apiKey: string): Promise<any>;
179
+ /**
180
+ * @param apiServer Perso Interactive API Server
181
+ * @param apiKey Perso Interactive API Key
182
+ * @returns JSON
183
+ * [
184
+ * {
185
+ * "name": string,
186
+ * "service": string,
187
+ * "speaker": string
188
+ * }
189
+ * ]
190
+ */
191
+ static getTTSs(apiServer: string, apiKey: string): Promise<any>;
192
+ /**
193
+ * @param apiServer Perso Interactive API Server
194
+ * @param apiKey Perso Interactive API Key
195
+ * @returns JSON
196
+ * [
197
+ * {
198
+ * "name": string,
199
+ * "service": string
200
+ * }
201
+ * ]
202
+ */
203
+ static getSTTs(apiServer: string, apiKey: string): Promise<any>;
204
+ /**
205
+ * Sends text to the TTS API and returns Base64-encoded audio.
206
+ * @param apiServer Perso Interactive API Server
207
+ * @param params Session ID and text to synthesize.
208
+ * @returns JSON with Base64 audio string.
209
+ * {
210
+ * "audio": string
211
+ * }
212
+ */
213
+ static makeTTS(apiServer: string, { sessionId, text, locale, output_format }: {
214
+ sessionId: string;
215
+ text: string;
216
+ locale?: string;
217
+ output_format?: string;
218
+ }): Promise<{
219
+ audio: string;
220
+ }>;
221
+ /**
222
+ * @param apiServer Perso Interactive API Server
223
+ * @param apiKey Perso Interactive API Key
224
+ * @returns JSON
225
+ * [
226
+ * {
227
+ * "name": string,
228
+ * "description": string,
229
+ * "prompt_id": string,
230
+ * "system_prompt": string,
231
+ * "require_document": boolean,
232
+ * "intro_message": string
233
+ * }
234
+ * ]
235
+ */
236
+ static getPrompts(apiServer: string, apiKey: string): Promise<any>;
237
+ /**
238
+ * @param apiServer Perso Interactive API Server
239
+ * @param apiKey Perso Interactive API Key
240
+ * @returns JSON
241
+ * [
242
+ * {
243
+ * "document_id": string,
244
+ * "title": string,
245
+ * "description": string,
246
+ * "search_count": number,
247
+ * "processed": boolean,
248
+ * "created_at": string, // ex) "2024-05-02T09:05:55.395Z",
249
+ * "updated_at": string // ex) "2024-05-02T09:05:55.395Z"
250
+ * }
251
+ * ]
252
+ */
253
+ static getDocuments(apiServer: string, apiKey: string): Promise<any>;
254
+ /**
255
+ * @param apiServer Perso Interactive API Server
256
+ * @param apiKey Perso Interactive API Key
257
+ * @returns JSON
258
+ * [
259
+ * {
260
+ * "mcpserver_id": string,
261
+ * "name": string,
262
+ * "url": string,
263
+ * "description": string
264
+ * }
265
+ * ]
266
+ */
267
+ /**
268
+ * @param apiServer Perso Interactive API Server
269
+ * @param apiKey Perso Interactive API Key
270
+ * @returns JSON
271
+ * [
272
+ * {
273
+ * "textnormalizationconfig_id": string,
274
+ * "name": string,
275
+ * "created_at": string
276
+ * }
277
+ * ]
278
+ */
279
+ static getTextNormalizations(apiServer: string, apiKey: string): Promise<any>;
280
+ /**
281
+ * Downloads the ruleset data file for a Text Normalization Config.
282
+ * Returns a pre-signed Blob Storage URL for the CSV file.
283
+ * The client can download the file directly from this URL and leverage Azure Blob Storage ETag for caching.
284
+ * @param apiServer Perso Interactive API Server
285
+ * @param apiKey Perso Interactive API Key
286
+ * @param configId Text Normalization Config ID
287
+ * @returns JSON
288
+ * {
289
+ * "config_id": string,
290
+ * "config_name": string,
291
+ * "file_url": string
292
+ * }
293
+ */
294
+ static downloadTextNormalization(apiServer: string, apiKey: string, configId: string): Promise<TextNormalizationDownload>;
295
+ /**
296
+ * Retrieves the list of session templates.
297
+ * @param apiServer Perso Interactive API Server
298
+ * @param apiKey Perso Interactive API Key
299
+ * @returns Array of SessionTemplate objects
300
+ */
301
+ static getSessionTemplates(apiServer: string, apiKey: string): Promise<SessionTemplate[]>;
302
+ /**
303
+ * Retrieves a single session template by ID.
304
+ * @param apiServer Perso Interactive API Server
305
+ * @param apiKey Perso Interactive API Key
306
+ * @param sessionTemplateId Session Template ID
307
+ * @returns SessionTemplate object
308
+ */
309
+ static getSessionTemplate(apiServer: string, apiKey: string, sessionTemplateId: string): Promise<SessionTemplate>;
310
+ static getMcpServers(apiServer: string, apiKey: string): Promise<any>;
311
+ /**
312
+ * @param apiServer Perso Interactive API Server
313
+ * @param apiKey Perso Interactive API Key
314
+ * @returns JSON
315
+ * {
316
+ * "session_id": string,
317
+ * "client_sdp": string,
318
+ * "server_sdp": string,
319
+ * "prompt": {
320
+ * "name": string,
321
+ * "description": string,
322
+ * "prompt_id": string,
323
+ * "system_prompt": string,
324
+ * "require_document": boolean,
325
+ * "intro_message": string
326
+ * },
327
+ * "document": string,
328
+ * "llm_type": {
329
+ * "name": string
330
+ * },
331
+ * "model_style": {
332
+ * "name": string,
333
+ * "model": string,
334
+ * "model_file": string,
335
+ * "style": string,
336
+ * "file": string
337
+ * },
338
+ * "tts_type": {
339
+ * "name": string,
340
+ * "service": string,
341
+ * "model": string,
342
+ * "voice": string,
343
+ * "style": string,
344
+ * "voice_extra_data": string
345
+ * },
346
+ * "ice_servers": Array<RTCIceServer>,
347
+ * "status": string, // "CREATED", "EXCHANGED", "IN_PROGRESS", "TERMINATED"
348
+ * "termination_reason": string, // "GRACEFUL_TERMINATION", "SESSION_EXPIRED_BEFORE_CONNECTION", "SESSION_LOST_AFTER_CONNECTION", "SESSION_MISC_ERROR", "MAX_ACTIVE_SESSION_QUOTA_EXCEEDED", "MAX_MIN_PER_SESSION_QUOTA_EXCEEDED", "TOTAL_MIN_PER_MONTH_QUOTA_EXCEEDED"
349
+ * "duration_sec": number,
350
+ * "created_at": string, // ex) "2024-05-02T09:05:55.395Z"
351
+ * "padding_left": number,
352
+ * "padding_top": number,
353
+ * "padding_height": number,
354
+ * "background_image": {
355
+ * "backgroundimage_id": string,
356
+ * "title": string,
357
+ * "image": string,
358
+ * "created_at": string // ex) "2024-05-02T09:05:55.395Z"
359
+ * },
360
+ * "extra_data": string,
361
+ * "capability": Array<{
362
+ * "name": string, // "LLM" | "TTS" | "STT" | "STF_ONPREMISE" | "STF_WEBRTC"
363
+ * "description": string
364
+ * }>
365
+ * }
366
+ */
367
+ static getSessionInfo(apiServer: string, sessionId: string): Promise<any>;
368
+ static sessionEvent(apiServer: string, sessionId: string, sessionEvent: SessionEvent, detail?: string): Promise<void>;
369
+ /**
370
+ * Sends audio data to the STT API endpoint for speech-to-text conversion.
371
+ * @param apiServer Perso Interactive API Server
372
+ * @param sessionId Session ID for the current session
373
+ * @param audioFile Audio file (WAV format)
374
+ * @param language Optional language code (e.g., 'ko', 'en')
375
+ * @returns STTResponse with only the transcribed text.
376
+ *
377
+ * The server returns additional fields (e.g., `locale`, `normalized_text`)
378
+ * which are intentionally not exposed by the SDK.
379
+ */
380
+ static makeSTT(apiServer: string, sessionId: string, audioFile: File, language?: string): Promise<STTResponse>;
381
+ /**
382
+ * Initiates an LLM streaming request and returns the response body reader.
383
+ * @param apiServer Perso Interactive API Server
384
+ * @param sessionId Session ID for the current session
385
+ * @param body Request body containing messages and tools
386
+ * @param signal Optional AbortSignal to cancel the request
387
+ * @returns ReadableStreamDefaultReader for SSE streaming response
388
+ * @throws ApiError when response is not ok
389
+ */
390
+ static makeLLM(apiServer: string, sessionId: string, body: {
391
+ messages: Array<object>;
392
+ tools: Array<object>;
393
+ }, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>;
394
+ /**
395
+ * Fetches ICE server configuration for WebRTC peer connection setup.
396
+ * @param apiServer Perso Interactive API Server
397
+ * @param sessionId Session ID
398
+ * @returns Array of RTCIceServer configurations.
399
+ */
400
+ static getIceServers(apiServer: string, sessionId: string): Promise<Array<RTCIceServer>>;
401
+ /**
402
+ * Exchanges the client SDP offer with the server and returns the server SDP answer.
403
+ * @param apiServer Perso Interactive API Server
404
+ * @param sessionId Session ID
405
+ * @param offer Client SDP offer from RTCPeerConnection.createOffer().
406
+ * @returns Server SDP answer to set as remote description.
407
+ */
408
+ static exchangeSDP(apiServer: string, sessionId: string, offer: RTCSessionDescriptionInit): Promise<RTCSessionDescriptionInit>;
409
+ static parseJson(response: Response): Promise<any>;
410
+ }
130
411
 
131
412
  interface Chat {
132
413
  text: string;
@@ -607,6 +888,8 @@ declare class Session {
607
888
  private stopHeartbeat;
608
889
  }
609
890
 
891
+ declare const DEFAULT_API_SERVER = "https://platform.perso.ai";
892
+
610
893
  /**
611
894
  * Callbacks that LlmProcessor uses to notify the host of side effects.
612
895
  */
@@ -710,114 +993,233 @@ declare class WavRecorder {
710
993
  */
711
994
  declare function createWavRecorder(options?: WavRecorderOptions): WavRecorder;
712
995
 
996
+ type ApiKeyOptions = {
997
+ apiKey: string;
998
+ apiServer?: string;
999
+ };
713
1000
  /**
714
1001
  * Retrieves the list of available LLM providers from the API.
1002
+ *
1003
+ * @param options.apiKey API key used for authentication.
1004
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1005
+ */
1006
+ declare function getLLMs(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getLLMs>;
1007
+ /**
715
1008
  * @param apiServer Perso API server URL.
716
1009
  * @param apiKey API key used for authentication.
717
- * @returns Promise resolving with LLM metadata.
718
1010
  */
719
- declare function getLLMs(apiServer: string, apiKey: string): Promise<any>;
1011
+ declare function getLLMs(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getLLMs>;
720
1012
  /**
721
1013
  * Retrieves available TTS providers.
1014
+ *
1015
+ * @param options.apiKey API key used for authentication.
1016
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1017
+ */
1018
+ declare function getTTSs(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getTTSs>;
1019
+ /**
722
1020
  * @param apiServer Perso API server URL.
723
1021
  * @param apiKey API key used for authentication.
724
1022
  */
725
- declare function getTTSs(apiServer: string, apiKey: string): Promise<any>;
1023
+ declare function getTTSs(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getTTSs>;
726
1024
  /**
727
1025
  * Retrieves available STT providers.
1026
+ *
1027
+ * @param options.apiKey API key used for authentication.
1028
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1029
+ */
1030
+ declare function getSTTs(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getSTTs>;
1031
+ /**
728
1032
  * @param apiServer Perso API server URL.
729
1033
  * @param apiKey API key used for authentication.
730
1034
  */
731
- declare function getSTTs(apiServer: string, apiKey: string): Promise<any>;
1035
+ declare function getSTTs(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getSTTs>;
732
1036
  /**
733
1037
  * Fetches avatar model styles.
1038
+ *
1039
+ * @param options.apiKey API key used for authentication.
1040
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1041
+ */
1042
+ declare function getModelStyles(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getModelStyles>;
1043
+ /**
734
1044
  * @param apiServer Perso API server URL.
735
1045
  * @param apiKey API key used for authentication.
736
1046
  */
737
- declare function getModelStyles(apiServer: string, apiKey: string): Promise<any>;
1047
+ declare function getModelStyles(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getModelStyles>;
738
1048
  /**
739
1049
  * Fetches preset background images.
1050
+ *
1051
+ * @param options.apiKey API key used for authentication.
1052
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1053
+ */
1054
+ declare function getBackgroundImages(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getBackgroundImages>;
1055
+ /**
740
1056
  * @param apiServer Perso API server URL.
741
1057
  * @param apiKey API key used for authentication.
742
1058
  */
743
- declare function getBackgroundImages(apiServer: string, apiKey: string): Promise<any>;
1059
+ declare function getBackgroundImages(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getBackgroundImages>;
744
1060
  /**
745
1061
  * Returns predefined prompt templates.
1062
+ *
1063
+ * @param options.apiKey API key used for authentication.
1064
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1065
+ */
1066
+ declare function getPrompts(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getPrompts>;
1067
+ /**
746
1068
  * @param apiServer Perso API server URL.
747
1069
  * @param apiKey API key used for authentication.
748
1070
  */
749
- declare function getPrompts(apiServer: string, apiKey: string): Promise<any>;
1071
+ declare function getPrompts(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getPrompts>;
750
1072
  /**
751
1073
  * Returns supporting document metadata usable by the session.
1074
+ *
1075
+ * @param options.apiKey API key used for authentication.
1076
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1077
+ */
1078
+ declare function getDocuments(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getDocuments>;
1079
+ /**
752
1080
  * @param apiServer Perso API server URL.
753
1081
  * @param apiKey API key used for authentication.
754
1082
  */
755
- declare function getDocuments(apiServer: string, apiKey: string): Promise<any>;
1083
+ declare function getDocuments(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getDocuments>;
756
1084
  /**
757
1085
  * Lists MCP server identifiers configured for the tenant.
1086
+ *
1087
+ * @param options.apiKey API key used for authentication.
1088
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1089
+ */
1090
+ declare function getMcpServers(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getMcpServers>;
1091
+ /**
758
1092
  * @param apiServer Perso API server URL.
759
1093
  * @param apiKey API key used for authentication.
760
1094
  */
761
- declare function getMcpServers(apiServer: string, apiKey: string): Promise<any>;
1095
+ declare function getMcpServers(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getMcpServers>;
762
1096
  /**
763
1097
  * Retrieves available text normalization options.
1098
+ *
1099
+ * @param options.apiKey API key used for authentication.
1100
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1101
+ */
1102
+ declare function getTextNormalizations(options: ApiKeyOptions): ReturnType<typeof PersoUtil.getTextNormalizations>;
1103
+ /**
764
1104
  * @param apiServer Perso API server URL.
765
1105
  * @param apiKey API key used for authentication.
766
1106
  */
767
- declare function getTextNormalizations(apiServer: string, apiKey: string): Promise<any>;
1107
+ declare function getTextNormalizations(apiServer: string, apiKey: string): ReturnType<typeof PersoUtil.getTextNormalizations>;
1108
+ type GetTextNormalizationOptions = {
1109
+ apiKey: string;
1110
+ configId: string;
1111
+ apiServer?: string;
1112
+ };
768
1113
  /**
769
1114
  * Downloads the ruleset data file for a Text Normalization Config.
770
1115
  * Returns a pre-signed Blob Storage URL for the CSV file.
1116
+ *
1117
+ * @param options.apiKey API key used for authentication.
1118
+ * @param options.configId Identifier of the Text Normalization Config to download.
1119
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1120
+ */
1121
+ declare function getTextNormalization(options: GetTextNormalizationOptions): Promise<TextNormalizationDownload>;
1122
+ /**
771
1123
  * @param apiServer Perso API server URL.
772
1124
  * @param apiKey API key used for authentication.
773
- * @param configId Text Normalization Config ID.
1125
+ * @param configId Identifier of the Text Normalization Config to download.
774
1126
  */
775
1127
  declare function getTextNormalization(apiServer: string, apiKey: string, configId: string): Promise<TextNormalizationDownload>;
776
1128
  /**
777
1129
  * Retrieves the list of session templates.
1130
+ *
1131
+ * @param options.apiKey API key used for authentication.
1132
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1133
+ */
1134
+ declare function getSessionTemplates(options: ApiKeyOptions): Promise<SessionTemplate[]>;
1135
+ /**
778
1136
  * @param apiServer Perso API server URL.
779
1137
  * @param apiKey API key used for authentication.
780
1138
  */
781
1139
  declare function getSessionTemplates(apiServer: string, apiKey: string): Promise<SessionTemplate[]>;
1140
+ type GetSessionTemplateOptions = {
1141
+ apiKey: string;
1142
+ sessionTemplateId: string;
1143
+ apiServer?: string;
1144
+ };
1145
+ type AllSettings = {
1146
+ llms: Awaited<ReturnType<typeof PersoUtil.getLLMs>>;
1147
+ ttsTypes: Awaited<ReturnType<typeof PersoUtil.getTTSs>>;
1148
+ sttTypes: Awaited<ReturnType<typeof PersoUtil.getSTTs>>;
1149
+ modelStyles: Awaited<ReturnType<typeof PersoUtil.getModelStyles>>;
1150
+ backgroundImages: Awaited<ReturnType<typeof PersoUtil.getBackgroundImages>>;
1151
+ prompts: Awaited<ReturnType<typeof PersoUtil.getPrompts>>;
1152
+ documents: Awaited<ReturnType<typeof PersoUtil.getDocuments>>;
1153
+ mcpServers: Awaited<ReturnType<typeof PersoUtil.getMcpServers>>;
1154
+ textNormalizations: Awaited<ReturnType<typeof PersoUtil.getTextNormalizations>> | [];
1155
+ };
782
1156
  /**
783
1157
  * Convenience helper that fetches every dropdown-friendly resource needed to
784
1158
  * build a Perso session configuration screen in one call chain.
785
- * @param apiServer Perso API server URL.
786
- * @param apiKey API key used for authentication.
787
- * @returns Object containing arrays for LLMs, TTS/STT types, model styles, etc.
788
- */
789
- declare function getAllSettings(apiServer: string, apiKey: string): Promise<{
790
- llms: any;
791
- ttsTypes: any;
792
- sttTypes: any;
793
- modelStyles: any;
794
- backgroundImages: any;
795
- prompts: any;
796
- documents: any;
797
- mcpServers: any;
798
- textNormalizations: any;
799
- }>;
1159
+ *
1160
+ * @param options.apiKey API key used for authentication.
1161
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1162
+ */
1163
+ declare function getAllSettings(options: ApiKeyOptions): Promise<AllSettings>;
800
1164
  /**
801
- * Sends text to the TTS API and returns Base64-encoded audio.
802
1165
  * @param apiServer Perso API server URL.
803
- * @param params Session ID and text to synthesize.
804
- * @returns Object with Base64 audio string.
1166
+ * @param apiKey API key used for authentication.
805
1167
  */
806
- declare function makeTTS(apiServer: string, params: {
1168
+ declare function getAllSettings(apiServer: string, apiKey: string): Promise<AllSettings>;
1169
+ type MakeTTSParams = {
807
1170
  sessionId: string;
808
1171
  text: string;
809
1172
  locale?: string;
810
1173
  output_format?: string;
811
- }): Promise<{
1174
+ };
1175
+ type MakeTTSOptions = MakeTTSParams & {
1176
+ apiServer?: string;
1177
+ };
1178
+ /**
1179
+ * Sends text to the TTS API and returns Base64-encoded audio.
1180
+ *
1181
+ * @param options.sessionId Identifier of the active session.
1182
+ * @param options.text Text to synthesize.
1183
+ * @param options.locale Optional locale override for the TTS voice.
1184
+ * @param options.output_format Optional output audio format.
1185
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1186
+ */
1187
+ declare function makeTTS(options: MakeTTSOptions): Promise<{
812
1188
  audio: string;
813
1189
  }>;
1190
+ /**
1191
+ * @param apiServer Perso API server URL.
1192
+ * @param params TTS request parameters (`sessionId`, `text`, optional `locale`, `output_format`).
1193
+ */
1194
+ declare function makeTTS(apiServer: string, params: MakeTTSParams): Promise<{
1195
+ audio: string;
1196
+ }>;
1197
+ type GetSessionInfoOptions = {
1198
+ sessionId: string;
1199
+ apiServer?: string;
1200
+ };
814
1201
  /**
815
1202
  * Retrieves metadata for an existing session.
1203
+ *
1204
+ * @param options.sessionId Identifier of the session to look up.
1205
+ * @param options.apiServer Perso API server URL. Defaults to `https://platform.perso.ai`.
1206
+ */
1207
+ declare function getSessionInfo(options: GetSessionInfoOptions): ReturnType<typeof PersoUtil.getSessionInfo>;
1208
+ /**
816
1209
  * @param apiServer Perso API server URL.
817
- * @param sessionId Session id to inspect.
1210
+ * @param sessionId Identifier of the session to look up.
818
1211
  */
819
- declare function getSessionInfo(apiServer: string, sessionId: string): Promise<any>;
1212
+ declare function getSessionInfo(apiServer: string, sessionId: string): ReturnType<typeof PersoUtil.getSessionInfo>;
820
1213
 
1214
+ type CreateSessionObjectOptions = {
1215
+ sessionId: string;
1216
+ width: number;
1217
+ height: number;
1218
+ clientTools: Array<ChatTool>;
1219
+ apiServer?: string;
1220
+ };
1221
+ /** @overload Object-form. Uses DEFAULT_API_SERVER when apiServer is omitted. */
1222
+ declare function createSession(options: CreateSessionObjectOptions): Promise<Session>;
821
1223
  /**
822
1224
  * Creates a Session with REST-based STT/TTS (current mode).
823
1225
  */
@@ -847,33 +1249,20 @@ type CreateSessionIdBody = {
847
1249
  stt_text_normalization_config?: string;
848
1250
  stt_text_normalization_locale?: string | null;
849
1251
  };
850
- /**
851
- * Requests a new session creation ID by POSTing the desired runtime options to
852
- * the Perso backend (`/api/v1/session/`).
853
- *
854
- * WARNING: This function requires an API key. When using this function in
855
- * client-side code, the API key will be exposed to the browser. For production
856
- * use, prefer creating session IDs server-side using `perso-interactive-sdk-web/server`.
857
- *
858
- * @overload Creates a session from a SessionTemplate ID. Internally calls
859
- * `getSessionTemplate` to resolve the template and maps it to the request body.
860
- * @param apiServer Perso API server URL.
861
- * @param apiKey API key used for authentication.
862
- * @param sessionTemplateId SessionTemplate ID to resolve configuration from.
863
- * @returns Session ID returned by the server.
864
- * @throws {Error} If the template's `model_style.platform_type` is not `"webrtc"`.
865
- * @throws {SessionCreationError} When the API returns an error during session creation.
866
- * @throws {DoesNotExistError} When the server response `code` is `'does_not_exist'` (subclass of `SessionCreationError`).
867
- * @throws {NotInOrganizationError} When the server response `code` is `'not_in_organization'` (subclass of `SessionCreationError`).
868
- */
1252
+ type CreateSessionIdObjectOptions = {
1253
+ apiKey: string;
1254
+ params: CreateSessionIdBody;
1255
+ apiServer?: string;
1256
+ } | {
1257
+ apiKey: string;
1258
+ sessionTemplateId: string;
1259
+ apiServer?: string;
1260
+ };
1261
+ /** @overload Object-form. Uses DEFAULT_API_SERVER when apiServer is omitted. */
1262
+ declare function createSessionId(options: CreateSessionIdObjectOptions): Promise<string>;
1263
+ /** @overload Positional form SessionTemplate ID. */
869
1264
  declare function createSessionId(apiServer: string, apiKey: string, sessionTemplateId: string): Promise<string>;
870
- /**
871
- * @overload Creates a session from explicit runtime options.
872
- * @param apiServer Perso API server URL.
873
- * @param apiKey API key used for authentication.
874
- * @param params Runtime options for the session.
875
- * @returns Session ID returned by the server.
876
- */
1265
+ /** @overload Positional form — explicit params. */
877
1266
  declare function createSessionId(apiServer: string, apiKey: string, params: CreateSessionIdBody): Promise<string>;
878
1267
 
879
1268
  declare class ApiError extends Error {
@@ -943,5 +1332,5 @@ declare function getWavSampleRate(arrayBuffer: ArrayBuffer): number;
943
1332
 
944
1333
  declare const TTS_TARGET_SAMPLE_RATE = 16000;
945
1334
 
946
- export { ApiError, ChatState, ChatTool, DoesNotExistError, LLMError, LLMStreamingResponseError, LlmProcessor, NotInOrganizationError, STTError, Session, SessionCreationError, TTSDecodeError, TTSError, TTS_TARGET_SAMPLE_RATE, WavRecorder, createSession, createSessionId, createWavRecorder, getAllSettings, getBackgroundImages, getDocuments, getLLMs, getMcpServers, getModelStyles, getPrompts, getSTTs, getSessionInfo, getSessionTemplates, getTTSs, getTextNormalization, getTextNormalizations, getWavSampleRate, makeTTS };
947
- export type { AIHumanModelFile, BackgroundImage, Chat, Document, LLMStreamChunk, LLMType, LlmProcessorCallbacks, LlmProcessorConfig, MCPServer, ModelStyle, ModelStyleConfig, ProcessLLMOptions, Prompt, STTResponse, STTType, SessionCapability, SessionTemplate, TTSType, TextNormalizationConfig, TextNormalizationDownload, WavRecorderOptions };
1335
+ export { ApiError, ChatState, ChatTool, DEFAULT_API_SERVER, DoesNotExistError, LLMError, LLMStreamingResponseError, LlmProcessor, NotInOrganizationError, STTError, Session, SessionCreationError, TTSDecodeError, TTSError, TTS_TARGET_SAMPLE_RATE, WavRecorder, createSession, createSessionId, createWavRecorder, getAllSettings, getBackgroundImages, getDocuments, getLLMs, getMcpServers, getModelStyles, getPrompts, getSTTs, getSessionInfo, getSessionTemplates, getTTSs, getTextNormalization, getTextNormalizations, getWavSampleRate, makeTTS };
1336
+ export type { AIHumanModelFile, ApiKeyOptions, BackgroundImage, Chat, CreateSessionObjectOptions, Document, GetSessionInfoOptions, GetSessionTemplateOptions, GetTextNormalizationOptions, LLMStreamChunk, LLMType, LlmProcessorCallbacks, LlmProcessorConfig, MCPServer, MakeTTSOptions, ModelStyle, ModelStyleConfig, ProcessLLMOptions, Prompt, STTResponse, STTType, SessionCapability, SessionTemplate, TTSType, TextNormalizationConfig, TextNormalizationDownload, WavRecorderOptions };