@serenity-star/sdk 2.2.1 → 2.4.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.
- package/dist/index.d.mts +215 -10
- package/dist/index.d.ts +215 -10
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +238 -5
package/dist/index.d.mts
CHANGED
|
@@ -291,12 +291,66 @@ type BaseErrorBody = {
|
|
|
291
291
|
};
|
|
292
292
|
type ValidationErrorBody = BaseErrorBody & {
|
|
293
293
|
errors: {
|
|
294
|
-
[key: string]: string;
|
|
294
|
+
[key: string]: string | string[];
|
|
295
295
|
};
|
|
296
296
|
};
|
|
297
297
|
type RateLimitErrorBody = BaseErrorBody & {
|
|
298
298
|
retryAfter: number;
|
|
299
299
|
};
|
|
300
|
+
type FileError = {
|
|
301
|
+
file?: File;
|
|
302
|
+
error: Error;
|
|
303
|
+
};
|
|
304
|
+
type VolatileKnowledgeUploadRes = {
|
|
305
|
+
success: true;
|
|
306
|
+
id: string;
|
|
307
|
+
expirationDate: string;
|
|
308
|
+
status: string;
|
|
309
|
+
fileName: string;
|
|
310
|
+
fileSize: number;
|
|
311
|
+
} | {
|
|
312
|
+
success: false;
|
|
313
|
+
error: FileError;
|
|
314
|
+
};
|
|
315
|
+
type VolatileKnowledgeUploadOptions = {
|
|
316
|
+
processEmbeddings?: boolean;
|
|
317
|
+
noExpiration?: boolean;
|
|
318
|
+
expirationDays?: number;
|
|
319
|
+
useVision?: boolean;
|
|
320
|
+
locale?: {
|
|
321
|
+
uploadFileErrorMessage?: string;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
type TranscribeAudioOptions = {
|
|
325
|
+
modelId?: string;
|
|
326
|
+
prompt?: string;
|
|
327
|
+
userIdentifier?: string;
|
|
328
|
+
};
|
|
329
|
+
type TranscribeAudioResult = {
|
|
330
|
+
transcript: string;
|
|
331
|
+
metadata?: TranscriptionMetadata;
|
|
332
|
+
tokenUsage?: TranscriptionTokenUsage;
|
|
333
|
+
cost?: TranscriptionCost;
|
|
334
|
+
};
|
|
335
|
+
type TranscriptionMetadata = {
|
|
336
|
+
language?: string;
|
|
337
|
+
duration?: number;
|
|
338
|
+
};
|
|
339
|
+
type TranscriptionTokenUsage = {
|
|
340
|
+
completionTokens: number;
|
|
341
|
+
promptTokens: number;
|
|
342
|
+
totalTokens: number;
|
|
343
|
+
};
|
|
344
|
+
type TranscriptionCost = {
|
|
345
|
+
completion: number;
|
|
346
|
+
prompt: number;
|
|
347
|
+
total: number;
|
|
348
|
+
currency: string;
|
|
349
|
+
};
|
|
350
|
+
type FileUploadRes = {
|
|
351
|
+
id: string;
|
|
352
|
+
downloadUrl: string;
|
|
353
|
+
};
|
|
300
354
|
|
|
301
355
|
type MessageAdditionalInfo = {
|
|
302
356
|
inputParameters?: {
|
|
@@ -309,6 +363,7 @@ type ConversationInfoResult = {
|
|
|
309
363
|
isRealtime: boolean;
|
|
310
364
|
version: number;
|
|
311
365
|
visionEnabled: boolean;
|
|
366
|
+
audioInputEnabled: boolean;
|
|
312
367
|
imageId: string;
|
|
313
368
|
};
|
|
314
369
|
conversation: {
|
|
@@ -458,13 +513,6 @@ type SpeechGenerationResult = {
|
|
|
458
513
|
finish_reason?: string;
|
|
459
514
|
usage?: object;
|
|
460
515
|
};
|
|
461
|
-
type VolatileKnowledgeUploadRes = {
|
|
462
|
-
id: string;
|
|
463
|
-
expirationDate: string;
|
|
464
|
-
status: string;
|
|
465
|
-
fileName: string;
|
|
466
|
-
fileSize: number;
|
|
467
|
-
};
|
|
468
516
|
type AttachedVolatileKnowledge = {
|
|
469
517
|
id: string;
|
|
470
518
|
expirationDate: string;
|
|
@@ -582,6 +630,78 @@ type ConnectorStatusResult = {
|
|
|
582
630
|
isConnected: boolean;
|
|
583
631
|
};
|
|
584
632
|
|
|
633
|
+
/**
|
|
634
|
+
* Manages volatile knowledge files for agent instances.
|
|
635
|
+
* Provides methods to upload, remove, and clear files.
|
|
636
|
+
*/
|
|
637
|
+
declare class VolatileKnowledgeManager {
|
|
638
|
+
private readonly baseUrl;
|
|
639
|
+
private readonly apiKey;
|
|
640
|
+
private ids;
|
|
641
|
+
constructor(baseUrl: string, apiKey: string);
|
|
642
|
+
/**
|
|
643
|
+
* Upload a file to be used as volatile knowledge in the next agent execution.
|
|
644
|
+
* The file will be automatically included in subsequent messages/executions until cleared.
|
|
645
|
+
*
|
|
646
|
+
* @param file - The file to upload
|
|
647
|
+
* @param options - Optional configuration for file processing
|
|
648
|
+
* @returns Upload result with file details or errors
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* ```typescript
|
|
652
|
+
* const uploadResult = await conversation.volatileKnowledge.upload(file);
|
|
653
|
+
*
|
|
654
|
+
* if (uploadResult.success) {
|
|
655
|
+
* console.log('File uploaded:', uploadResult.id);
|
|
656
|
+
* } else {
|
|
657
|
+
* console.error('Upload failed:', uploadResult.error);
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
upload(file: File, options?: VolatileKnowledgeUploadOptions): Promise<VolatileKnowledgeUploadRes>;
|
|
662
|
+
/**
|
|
663
|
+
* Remove a specific volatile knowledge file by its ID.
|
|
664
|
+
*
|
|
665
|
+
* @param fileId - The ID of the file to remove
|
|
666
|
+
* @returns True if the file was removed, false otherwise
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```typescript
|
|
670
|
+
* const uploadResult = await conversation.volatileKnowledge.upload(file);
|
|
671
|
+
*
|
|
672
|
+
* if (uploadResult.success) {
|
|
673
|
+
* // Remove the file from the queue
|
|
674
|
+
* conversation.volatileKnowledge.removeById(uploadResult.id);
|
|
675
|
+
* }
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
removeById(fileId: string): boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Clear all volatile knowledge files from the queue.
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* ```typescript
|
|
684
|
+
* await conversation.volatileKnowledge.upload(file1);
|
|
685
|
+
* await conversation.volatileKnowledge.upload(file2);
|
|
686
|
+
*
|
|
687
|
+
* // Clear all files from the queue
|
|
688
|
+
* conversation.volatileKnowledge.clear();
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
clear(): void;
|
|
692
|
+
/**
|
|
693
|
+
* Get all volatile knowledge file IDs currently in the queue.
|
|
694
|
+
* @internal
|
|
695
|
+
*/
|
|
696
|
+
getIds(): string[];
|
|
697
|
+
/**
|
|
698
|
+
* Fetch details of a volatile knowledge file by its ID.
|
|
699
|
+
* @param fileId - The ID of the file to fetch
|
|
700
|
+
* @returns The file details or an error
|
|
701
|
+
*/
|
|
702
|
+
getById(fileId: string): Promise<VolatileKnowledgeUploadRes>;
|
|
703
|
+
}
|
|
704
|
+
|
|
585
705
|
declare class Conversation extends EventEmitter<SSEStreamEvents> {
|
|
586
706
|
#private;
|
|
587
707
|
private agentCode;
|
|
@@ -593,11 +713,27 @@ declare class Conversation extends EventEmitter<SSEStreamEvents> {
|
|
|
593
713
|
private inputParameters?;
|
|
594
714
|
conversationId?: string;
|
|
595
715
|
info: ConversationInfoResult | null;
|
|
716
|
+
/**
|
|
717
|
+
* Volatile knowledge manager for uploading and managing temporary files.
|
|
718
|
+
* Files uploaded through this manager will be included in the next message/execution.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```typescript
|
|
722
|
+
* const uploadResult = await conversation.volatileKnowledge.upload(file);
|
|
723
|
+
* if (uploadResult.success) {
|
|
724
|
+
* console.log('File uploaded:', uploadResult.id);
|
|
725
|
+
* }
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
readonly volatileKnowledge: VolatileKnowledgeManager;
|
|
729
|
+
private readonly fileManager;
|
|
596
730
|
private constructor();
|
|
597
731
|
private static create;
|
|
598
732
|
private static createWithoutInfo;
|
|
599
733
|
streamMessage(message: string, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
600
734
|
sendMessage(message: string, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
735
|
+
sendAudioMessage(audio: Blob, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
736
|
+
streamAudioMessage(audio: Blob, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
601
737
|
getConversationById(id: string, options?: {
|
|
602
738
|
showExecutorTaskLogs: boolean;
|
|
603
739
|
}): Promise<ConversationRes>;
|
|
@@ -765,14 +901,33 @@ declare class RealtimeSession extends EventEmitter<RealtimeSessionEvents> {
|
|
|
765
901
|
}
|
|
766
902
|
|
|
767
903
|
declare abstract class SystemAgent<T extends keyof SystemAgentExecutionOptionsMap> extends EventEmitter<SSEStreamEvents> {
|
|
904
|
+
#private;
|
|
768
905
|
protected readonly agentCode: string;
|
|
769
906
|
protected readonly apiKey: string;
|
|
770
907
|
protected readonly baseUrl: string;
|
|
771
908
|
protected readonly options?: SystemAgentExecutionOptionsMap[T] | undefined;
|
|
909
|
+
/**
|
|
910
|
+
* Volatile knowledge manager for uploading and managing temporary files.
|
|
911
|
+
* Files uploaded through this manager will be included in the next execution.
|
|
912
|
+
*
|
|
913
|
+
* @example
|
|
914
|
+
* ```typescript
|
|
915
|
+
* const uploadResult = await activity.volatileKnowledge.upload(file);
|
|
916
|
+
* if (uploadResult.success) {
|
|
917
|
+
* console.log('File uploaded:', uploadResult.id);
|
|
918
|
+
* }
|
|
919
|
+
* ```
|
|
920
|
+
*/
|
|
921
|
+
readonly volatileKnowledge: VolatileKnowledgeManager;
|
|
922
|
+
private readonly fileManager;
|
|
772
923
|
protected constructor(agentCode: string, apiKey: string, baseUrl: string, options?: SystemAgentExecutionOptionsMap[T] | undefined);
|
|
773
924
|
stream(): Promise<AgentResult>;
|
|
925
|
+
streamWithAudio(audio: Blob): Promise<AgentResult>;
|
|
774
926
|
protected execute(): Promise<AgentResult>;
|
|
775
|
-
|
|
927
|
+
executeWithAudio(audio: Blob): Promise<AgentResult>;
|
|
928
|
+
protected createExecuteBody(stream: boolean, audio?: {
|
|
929
|
+
fileId: string;
|
|
930
|
+
}): ExecuteBodyParams | {
|
|
776
931
|
[key: string]: any;
|
|
777
932
|
};
|
|
778
933
|
protected appendUserIdentifierIfNeeded(body: ExecuteBodyParams): void;
|
|
@@ -915,6 +1070,31 @@ type SystemAgentScope<T extends keyof SystemAgentExecutionOptionsMap, TCreateRet
|
|
|
915
1070
|
create: (agentCode: string, options?: SystemAgentExecutionOptionsMap[T]) => TCreateReturn;
|
|
916
1071
|
};
|
|
917
1072
|
|
|
1073
|
+
type AudioServiceScope = {
|
|
1074
|
+
/**
|
|
1075
|
+
* Transcribe an audio file using the Serenity API.
|
|
1076
|
+
*
|
|
1077
|
+
* @param file - The audio file to transcribe
|
|
1078
|
+
* @param options - Optional configuration for transcription
|
|
1079
|
+
* @returns Transcription result with transcript, metadata, token usage, and cost information
|
|
1080
|
+
*
|
|
1081
|
+
* @example
|
|
1082
|
+
* ```typescript
|
|
1083
|
+
* const result = await client.services.audio.transcribe(audioFile, {
|
|
1084
|
+
* modelId: '[YOUR_MODEL_ID]',
|
|
1085
|
+
* prompt: 'This is a conversation about AI',
|
|
1086
|
+
* userIdentifier: 'user123'
|
|
1087
|
+
* });
|
|
1088
|
+
*
|
|
1089
|
+
* console.log('Transcript:', result.transcript);
|
|
1090
|
+
* console.log('Duration:', result.metadata?.duration);
|
|
1091
|
+
* console.log('Total tokens:', result.tokenUsage?.totalTokens);
|
|
1092
|
+
* console.log('Cost:', result.cost?.total, result.cost?.currency);
|
|
1093
|
+
* ```
|
|
1094
|
+
*/
|
|
1095
|
+
transcribe: (file: File, options?: TranscribeAudioOptions) => Promise<TranscribeAudioResult>;
|
|
1096
|
+
};
|
|
1097
|
+
|
|
918
1098
|
declare class SerenityClient {
|
|
919
1099
|
private apiKey;
|
|
920
1100
|
private baseUrl;
|
|
@@ -1092,6 +1272,31 @@ declare class SerenityClient {
|
|
|
1092
1272
|
*/
|
|
1093
1273
|
proxies: SystemAgentScope<"proxy", Proxy>;
|
|
1094
1274
|
};
|
|
1275
|
+
/**
|
|
1276
|
+
* Access various services provided by Serenity Star.
|
|
1277
|
+
* Services include audio transcription and other utility features.
|
|
1278
|
+
*/
|
|
1279
|
+
readonly services: {
|
|
1280
|
+
/**
|
|
1281
|
+
* Audio-related services including transcription.
|
|
1282
|
+
*
|
|
1283
|
+
* ## Transcribe an audio file:
|
|
1284
|
+
* ```typescript
|
|
1285
|
+
* const file = new File([audioBlob], "audio.mp3", { type: "audio/mpeg" });
|
|
1286
|
+
* const result = await client.services.audio.transcribe(file, {
|
|
1287
|
+
* modelId: '[YOUR_MODEL_ID]',
|
|
1288
|
+
* prompt: 'This is a conversation about AI',
|
|
1289
|
+
* userIdentifier: 'user123'
|
|
1290
|
+
* });
|
|
1291
|
+
*
|
|
1292
|
+
* console.log('Transcript:', result.transcript);
|
|
1293
|
+
* console.log('Duration:', result.metadata?.duration);
|
|
1294
|
+
* console.log('Total tokens:', result.tokenUsage?.totalTokens);
|
|
1295
|
+
* console.log('Cost:', result.cost?.total, result.cost?.currency);
|
|
1296
|
+
* ```
|
|
1297
|
+
*/
|
|
1298
|
+
audio: AudioServiceScope;
|
|
1299
|
+
};
|
|
1095
1300
|
constructor(options: SerenityClientOptions);
|
|
1096
1301
|
}
|
|
1097
1302
|
|
|
@@ -1105,4 +1310,4 @@ declare class ExternalErrorHelper {
|
|
|
1105
1310
|
private static isBaseErrorBody;
|
|
1106
1311
|
}
|
|
1107
1312
|
|
|
1108
|
-
export { type AgentResult, type BaseErrorBody, type ChatWidgetRes, type ConnectorStatusResult, Conversation, type ConversationInfoResult, type ConversationRes, ExternalErrorHelper as ErrorHelper, type GetConnectorStatusOptions, type Message, type PendingAction, type RateLimitErrorBody, RealtimeSession, type RemoveFeedbackOptions, type RemoveFeedbackResult, SerenityClient, type SubmitFeedbackOptions, type SubmitFeedbackResult, type ValidationErrorBody };
|
|
1313
|
+
export { type AgentResult, type BaseErrorBody, type ChatWidgetRes, type ConnectorStatusResult, Conversation, type ConversationInfoResult, type ConversationRes, ExternalErrorHelper as ErrorHelper, type FileError, type FileUploadRes, type GetConnectorStatusOptions, type Message, type PendingAction, type RateLimitErrorBody, RealtimeSession, type RemoveFeedbackOptions, type RemoveFeedbackResult, SerenityClient, type SubmitFeedbackOptions, type SubmitFeedbackResult, type TranscribeAudioOptions, type TranscribeAudioResult, type ValidationErrorBody, VolatileKnowledgeManager, type VolatileKnowledgeUploadOptions, type VolatileKnowledgeUploadRes };
|
package/dist/index.d.ts
CHANGED
|
@@ -291,12 +291,66 @@ type BaseErrorBody = {
|
|
|
291
291
|
};
|
|
292
292
|
type ValidationErrorBody = BaseErrorBody & {
|
|
293
293
|
errors: {
|
|
294
|
-
[key: string]: string;
|
|
294
|
+
[key: string]: string | string[];
|
|
295
295
|
};
|
|
296
296
|
};
|
|
297
297
|
type RateLimitErrorBody = BaseErrorBody & {
|
|
298
298
|
retryAfter: number;
|
|
299
299
|
};
|
|
300
|
+
type FileError = {
|
|
301
|
+
file?: File;
|
|
302
|
+
error: Error;
|
|
303
|
+
};
|
|
304
|
+
type VolatileKnowledgeUploadRes = {
|
|
305
|
+
success: true;
|
|
306
|
+
id: string;
|
|
307
|
+
expirationDate: string;
|
|
308
|
+
status: string;
|
|
309
|
+
fileName: string;
|
|
310
|
+
fileSize: number;
|
|
311
|
+
} | {
|
|
312
|
+
success: false;
|
|
313
|
+
error: FileError;
|
|
314
|
+
};
|
|
315
|
+
type VolatileKnowledgeUploadOptions = {
|
|
316
|
+
processEmbeddings?: boolean;
|
|
317
|
+
noExpiration?: boolean;
|
|
318
|
+
expirationDays?: number;
|
|
319
|
+
useVision?: boolean;
|
|
320
|
+
locale?: {
|
|
321
|
+
uploadFileErrorMessage?: string;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
type TranscribeAudioOptions = {
|
|
325
|
+
modelId?: string;
|
|
326
|
+
prompt?: string;
|
|
327
|
+
userIdentifier?: string;
|
|
328
|
+
};
|
|
329
|
+
type TranscribeAudioResult = {
|
|
330
|
+
transcript: string;
|
|
331
|
+
metadata?: TranscriptionMetadata;
|
|
332
|
+
tokenUsage?: TranscriptionTokenUsage;
|
|
333
|
+
cost?: TranscriptionCost;
|
|
334
|
+
};
|
|
335
|
+
type TranscriptionMetadata = {
|
|
336
|
+
language?: string;
|
|
337
|
+
duration?: number;
|
|
338
|
+
};
|
|
339
|
+
type TranscriptionTokenUsage = {
|
|
340
|
+
completionTokens: number;
|
|
341
|
+
promptTokens: number;
|
|
342
|
+
totalTokens: number;
|
|
343
|
+
};
|
|
344
|
+
type TranscriptionCost = {
|
|
345
|
+
completion: number;
|
|
346
|
+
prompt: number;
|
|
347
|
+
total: number;
|
|
348
|
+
currency: string;
|
|
349
|
+
};
|
|
350
|
+
type FileUploadRes = {
|
|
351
|
+
id: string;
|
|
352
|
+
downloadUrl: string;
|
|
353
|
+
};
|
|
300
354
|
|
|
301
355
|
type MessageAdditionalInfo = {
|
|
302
356
|
inputParameters?: {
|
|
@@ -309,6 +363,7 @@ type ConversationInfoResult = {
|
|
|
309
363
|
isRealtime: boolean;
|
|
310
364
|
version: number;
|
|
311
365
|
visionEnabled: boolean;
|
|
366
|
+
audioInputEnabled: boolean;
|
|
312
367
|
imageId: string;
|
|
313
368
|
};
|
|
314
369
|
conversation: {
|
|
@@ -458,13 +513,6 @@ type SpeechGenerationResult = {
|
|
|
458
513
|
finish_reason?: string;
|
|
459
514
|
usage?: object;
|
|
460
515
|
};
|
|
461
|
-
type VolatileKnowledgeUploadRes = {
|
|
462
|
-
id: string;
|
|
463
|
-
expirationDate: string;
|
|
464
|
-
status: string;
|
|
465
|
-
fileName: string;
|
|
466
|
-
fileSize: number;
|
|
467
|
-
};
|
|
468
516
|
type AttachedVolatileKnowledge = {
|
|
469
517
|
id: string;
|
|
470
518
|
expirationDate: string;
|
|
@@ -582,6 +630,78 @@ type ConnectorStatusResult = {
|
|
|
582
630
|
isConnected: boolean;
|
|
583
631
|
};
|
|
584
632
|
|
|
633
|
+
/**
|
|
634
|
+
* Manages volatile knowledge files for agent instances.
|
|
635
|
+
* Provides methods to upload, remove, and clear files.
|
|
636
|
+
*/
|
|
637
|
+
declare class VolatileKnowledgeManager {
|
|
638
|
+
private readonly baseUrl;
|
|
639
|
+
private readonly apiKey;
|
|
640
|
+
private ids;
|
|
641
|
+
constructor(baseUrl: string, apiKey: string);
|
|
642
|
+
/**
|
|
643
|
+
* Upload a file to be used as volatile knowledge in the next agent execution.
|
|
644
|
+
* The file will be automatically included in subsequent messages/executions until cleared.
|
|
645
|
+
*
|
|
646
|
+
* @param file - The file to upload
|
|
647
|
+
* @param options - Optional configuration for file processing
|
|
648
|
+
* @returns Upload result with file details or errors
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* ```typescript
|
|
652
|
+
* const uploadResult = await conversation.volatileKnowledge.upload(file);
|
|
653
|
+
*
|
|
654
|
+
* if (uploadResult.success) {
|
|
655
|
+
* console.log('File uploaded:', uploadResult.id);
|
|
656
|
+
* } else {
|
|
657
|
+
* console.error('Upload failed:', uploadResult.error);
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
upload(file: File, options?: VolatileKnowledgeUploadOptions): Promise<VolatileKnowledgeUploadRes>;
|
|
662
|
+
/**
|
|
663
|
+
* Remove a specific volatile knowledge file by its ID.
|
|
664
|
+
*
|
|
665
|
+
* @param fileId - The ID of the file to remove
|
|
666
|
+
* @returns True if the file was removed, false otherwise
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```typescript
|
|
670
|
+
* const uploadResult = await conversation.volatileKnowledge.upload(file);
|
|
671
|
+
*
|
|
672
|
+
* if (uploadResult.success) {
|
|
673
|
+
* // Remove the file from the queue
|
|
674
|
+
* conversation.volatileKnowledge.removeById(uploadResult.id);
|
|
675
|
+
* }
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
removeById(fileId: string): boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Clear all volatile knowledge files from the queue.
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* ```typescript
|
|
684
|
+
* await conversation.volatileKnowledge.upload(file1);
|
|
685
|
+
* await conversation.volatileKnowledge.upload(file2);
|
|
686
|
+
*
|
|
687
|
+
* // Clear all files from the queue
|
|
688
|
+
* conversation.volatileKnowledge.clear();
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
clear(): void;
|
|
692
|
+
/**
|
|
693
|
+
* Get all volatile knowledge file IDs currently in the queue.
|
|
694
|
+
* @internal
|
|
695
|
+
*/
|
|
696
|
+
getIds(): string[];
|
|
697
|
+
/**
|
|
698
|
+
* Fetch details of a volatile knowledge file by its ID.
|
|
699
|
+
* @param fileId - The ID of the file to fetch
|
|
700
|
+
* @returns The file details or an error
|
|
701
|
+
*/
|
|
702
|
+
getById(fileId: string): Promise<VolatileKnowledgeUploadRes>;
|
|
703
|
+
}
|
|
704
|
+
|
|
585
705
|
declare class Conversation extends EventEmitter<SSEStreamEvents> {
|
|
586
706
|
#private;
|
|
587
707
|
private agentCode;
|
|
@@ -593,11 +713,27 @@ declare class Conversation extends EventEmitter<SSEStreamEvents> {
|
|
|
593
713
|
private inputParameters?;
|
|
594
714
|
conversationId?: string;
|
|
595
715
|
info: ConversationInfoResult | null;
|
|
716
|
+
/**
|
|
717
|
+
* Volatile knowledge manager for uploading and managing temporary files.
|
|
718
|
+
* Files uploaded through this manager will be included in the next message/execution.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```typescript
|
|
722
|
+
* const uploadResult = await conversation.volatileKnowledge.upload(file);
|
|
723
|
+
* if (uploadResult.success) {
|
|
724
|
+
* console.log('File uploaded:', uploadResult.id);
|
|
725
|
+
* }
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
readonly volatileKnowledge: VolatileKnowledgeManager;
|
|
729
|
+
private readonly fileManager;
|
|
596
730
|
private constructor();
|
|
597
731
|
private static create;
|
|
598
732
|
private static createWithoutInfo;
|
|
599
733
|
streamMessage(message: string, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
600
734
|
sendMessage(message: string, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
735
|
+
sendAudioMessage(audio: Blob, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
736
|
+
streamAudioMessage(audio: Blob, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
601
737
|
getConversationById(id: string, options?: {
|
|
602
738
|
showExecutorTaskLogs: boolean;
|
|
603
739
|
}): Promise<ConversationRes>;
|
|
@@ -765,14 +901,33 @@ declare class RealtimeSession extends EventEmitter<RealtimeSessionEvents> {
|
|
|
765
901
|
}
|
|
766
902
|
|
|
767
903
|
declare abstract class SystemAgent<T extends keyof SystemAgentExecutionOptionsMap> extends EventEmitter<SSEStreamEvents> {
|
|
904
|
+
#private;
|
|
768
905
|
protected readonly agentCode: string;
|
|
769
906
|
protected readonly apiKey: string;
|
|
770
907
|
protected readonly baseUrl: string;
|
|
771
908
|
protected readonly options?: SystemAgentExecutionOptionsMap[T] | undefined;
|
|
909
|
+
/**
|
|
910
|
+
* Volatile knowledge manager for uploading and managing temporary files.
|
|
911
|
+
* Files uploaded through this manager will be included in the next execution.
|
|
912
|
+
*
|
|
913
|
+
* @example
|
|
914
|
+
* ```typescript
|
|
915
|
+
* const uploadResult = await activity.volatileKnowledge.upload(file);
|
|
916
|
+
* if (uploadResult.success) {
|
|
917
|
+
* console.log('File uploaded:', uploadResult.id);
|
|
918
|
+
* }
|
|
919
|
+
* ```
|
|
920
|
+
*/
|
|
921
|
+
readonly volatileKnowledge: VolatileKnowledgeManager;
|
|
922
|
+
private readonly fileManager;
|
|
772
923
|
protected constructor(agentCode: string, apiKey: string, baseUrl: string, options?: SystemAgentExecutionOptionsMap[T] | undefined);
|
|
773
924
|
stream(): Promise<AgentResult>;
|
|
925
|
+
streamWithAudio(audio: Blob): Promise<AgentResult>;
|
|
774
926
|
protected execute(): Promise<AgentResult>;
|
|
775
|
-
|
|
927
|
+
executeWithAudio(audio: Blob): Promise<AgentResult>;
|
|
928
|
+
protected createExecuteBody(stream: boolean, audio?: {
|
|
929
|
+
fileId: string;
|
|
930
|
+
}): ExecuteBodyParams | {
|
|
776
931
|
[key: string]: any;
|
|
777
932
|
};
|
|
778
933
|
protected appendUserIdentifierIfNeeded(body: ExecuteBodyParams): void;
|
|
@@ -915,6 +1070,31 @@ type SystemAgentScope<T extends keyof SystemAgentExecutionOptionsMap, TCreateRet
|
|
|
915
1070
|
create: (agentCode: string, options?: SystemAgentExecutionOptionsMap[T]) => TCreateReturn;
|
|
916
1071
|
};
|
|
917
1072
|
|
|
1073
|
+
type AudioServiceScope = {
|
|
1074
|
+
/**
|
|
1075
|
+
* Transcribe an audio file using the Serenity API.
|
|
1076
|
+
*
|
|
1077
|
+
* @param file - The audio file to transcribe
|
|
1078
|
+
* @param options - Optional configuration for transcription
|
|
1079
|
+
* @returns Transcription result with transcript, metadata, token usage, and cost information
|
|
1080
|
+
*
|
|
1081
|
+
* @example
|
|
1082
|
+
* ```typescript
|
|
1083
|
+
* const result = await client.services.audio.transcribe(audioFile, {
|
|
1084
|
+
* modelId: '[YOUR_MODEL_ID]',
|
|
1085
|
+
* prompt: 'This is a conversation about AI',
|
|
1086
|
+
* userIdentifier: 'user123'
|
|
1087
|
+
* });
|
|
1088
|
+
*
|
|
1089
|
+
* console.log('Transcript:', result.transcript);
|
|
1090
|
+
* console.log('Duration:', result.metadata?.duration);
|
|
1091
|
+
* console.log('Total tokens:', result.tokenUsage?.totalTokens);
|
|
1092
|
+
* console.log('Cost:', result.cost?.total, result.cost?.currency);
|
|
1093
|
+
* ```
|
|
1094
|
+
*/
|
|
1095
|
+
transcribe: (file: File, options?: TranscribeAudioOptions) => Promise<TranscribeAudioResult>;
|
|
1096
|
+
};
|
|
1097
|
+
|
|
918
1098
|
declare class SerenityClient {
|
|
919
1099
|
private apiKey;
|
|
920
1100
|
private baseUrl;
|
|
@@ -1092,6 +1272,31 @@ declare class SerenityClient {
|
|
|
1092
1272
|
*/
|
|
1093
1273
|
proxies: SystemAgentScope<"proxy", Proxy>;
|
|
1094
1274
|
};
|
|
1275
|
+
/**
|
|
1276
|
+
* Access various services provided by Serenity Star.
|
|
1277
|
+
* Services include audio transcription and other utility features.
|
|
1278
|
+
*/
|
|
1279
|
+
readonly services: {
|
|
1280
|
+
/**
|
|
1281
|
+
* Audio-related services including transcription.
|
|
1282
|
+
*
|
|
1283
|
+
* ## Transcribe an audio file:
|
|
1284
|
+
* ```typescript
|
|
1285
|
+
* const file = new File([audioBlob], "audio.mp3", { type: "audio/mpeg" });
|
|
1286
|
+
* const result = await client.services.audio.transcribe(file, {
|
|
1287
|
+
* modelId: '[YOUR_MODEL_ID]',
|
|
1288
|
+
* prompt: 'This is a conversation about AI',
|
|
1289
|
+
* userIdentifier: 'user123'
|
|
1290
|
+
* });
|
|
1291
|
+
*
|
|
1292
|
+
* console.log('Transcript:', result.transcript);
|
|
1293
|
+
* console.log('Duration:', result.metadata?.duration);
|
|
1294
|
+
* console.log('Total tokens:', result.tokenUsage?.totalTokens);
|
|
1295
|
+
* console.log('Cost:', result.cost?.total, result.cost?.currency);
|
|
1296
|
+
* ```
|
|
1297
|
+
*/
|
|
1298
|
+
audio: AudioServiceScope;
|
|
1299
|
+
};
|
|
1095
1300
|
constructor(options: SerenityClientOptions);
|
|
1096
1301
|
}
|
|
1097
1302
|
|
|
@@ -1105,4 +1310,4 @@ declare class ExternalErrorHelper {
|
|
|
1105
1310
|
private static isBaseErrorBody;
|
|
1106
1311
|
}
|
|
1107
1312
|
|
|
1108
|
-
export { type AgentResult, type BaseErrorBody, type ChatWidgetRes, type ConnectorStatusResult, Conversation, type ConversationInfoResult, type ConversationRes, ExternalErrorHelper as ErrorHelper, type GetConnectorStatusOptions, type Message, type PendingAction, type RateLimitErrorBody, RealtimeSession, type RemoveFeedbackOptions, type RemoveFeedbackResult, SerenityClient, type SubmitFeedbackOptions, type SubmitFeedbackResult, type ValidationErrorBody };
|
|
1313
|
+
export { type AgentResult, type BaseErrorBody, type ChatWidgetRes, type ConnectorStatusResult, Conversation, type ConversationInfoResult, type ConversationRes, ExternalErrorHelper as ErrorHelper, type FileError, type FileUploadRes, type GetConnectorStatusOptions, type Message, type PendingAction, type RateLimitErrorBody, RealtimeSession, type RemoveFeedbackOptions, type RemoveFeedbackResult, SerenityClient, type SubmitFeedbackOptions, type SubmitFeedbackResult, type TranscribeAudioOptions, type TranscribeAudioResult, type ValidationErrorBody, VolatileKnowledgeManager, type VolatileKnowledgeUploadOptions, type VolatileKnowledgeUploadRes };
|