@serenity-star/sdk 1.0.3 → 2.1.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 +390 -85
- package/dist/index.d.ts +390 -85
- 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 +134 -75
package/dist/index.d.mts
CHANGED
|
@@ -76,9 +76,9 @@ type SerenityClientOptions = {
|
|
|
76
76
|
baseUrl?: string;
|
|
77
77
|
};
|
|
78
78
|
/**
|
|
79
|
-
* Base options for
|
|
80
|
-
|
|
81
|
-
type
|
|
79
|
+
* Base options for setting up an agent.
|
|
80
|
+
*/
|
|
81
|
+
type AgentSetupOptions = {
|
|
82
82
|
/**
|
|
83
83
|
* Optional identifier for the user initiating the execution.
|
|
84
84
|
*/
|
|
@@ -92,20 +92,20 @@ type AgentExecutionOptions = {
|
|
|
92
92
|
*/
|
|
93
93
|
channel?: string;
|
|
94
94
|
/**
|
|
95
|
-
* Optional
|
|
95
|
+
* Optional key-value pairs of input parameters specific to the agent.
|
|
96
96
|
*/
|
|
97
|
-
|
|
97
|
+
inputParameters?: {
|
|
98
|
+
[key: string]: any;
|
|
99
|
+
};
|
|
98
100
|
};
|
|
99
101
|
/**
|
|
100
|
-
*
|
|
102
|
+
* Base options for executing any type of agent.
|
|
101
103
|
*/
|
|
102
|
-
type
|
|
104
|
+
type AgentExecutionOptions = AgentSetupOptions & {
|
|
103
105
|
/**
|
|
104
|
-
* Optional
|
|
106
|
+
* Optional array of volatile knowledge IDs to include in the execution context.
|
|
105
107
|
*/
|
|
106
|
-
|
|
107
|
-
[key: string]: any;
|
|
108
|
-
};
|
|
108
|
+
volatileKnowledgeIds?: string[];
|
|
109
109
|
};
|
|
110
110
|
/**
|
|
111
111
|
* Maps agent types to their specific execution options for conversational agents.
|
|
@@ -114,8 +114,8 @@ type AgentExecutionOptionsWithParameters = AgentExecutionOptions & {
|
|
|
114
114
|
* Both assistant and copilot agents support input parameters in addition to base execution options.
|
|
115
115
|
*/
|
|
116
116
|
type ConversationalAgentExecutionOptionsMap = {
|
|
117
|
-
"assistant":
|
|
118
|
-
"copilot":
|
|
117
|
+
"assistant": AgentSetupOptions;
|
|
118
|
+
"copilot": AgentSetupOptions;
|
|
119
119
|
};
|
|
120
120
|
/**
|
|
121
121
|
* Maps agent types to their specific execution options for system agents.
|
|
@@ -125,9 +125,8 @@ type ConversationalAgentExecutionOptionsMap = {
|
|
|
125
125
|
* - Proxy agents have specific proxy execution options
|
|
126
126
|
*/
|
|
127
127
|
type SystemAgentExecutionOptionsMap = {
|
|
128
|
-
"activity":
|
|
129
|
-
"
|
|
130
|
-
"chat-completion": AgentExecutionOptionsWithParameters & {
|
|
128
|
+
"activity": AgentExecutionOptions;
|
|
129
|
+
"chat-completion": AgentExecutionOptions & {
|
|
131
130
|
/** The single message content for the chat completion */
|
|
132
131
|
message: string;
|
|
133
132
|
/** Optional array of message objects representing the conversation history */
|
|
@@ -142,13 +141,15 @@ type AgentResult = {
|
|
|
142
141
|
content: string;
|
|
143
142
|
instance_id: string;
|
|
144
143
|
json_content?: any;
|
|
145
|
-
meta_analysis?: MetaAnalysisRes;
|
|
146
|
-
completion_usage?: CompletionUsageRes;
|
|
144
|
+
meta_analysis?: MetaAnalysisRes$1;
|
|
145
|
+
completion_usage?: CompletionUsageRes$1;
|
|
147
146
|
time_to_first_token?: number;
|
|
148
|
-
executor_task_logs?: ExecutorTaskLogsRes;
|
|
147
|
+
executor_task_logs?: ExecutorTaskLogsRes$1;
|
|
149
148
|
action_results?: {
|
|
150
|
-
[key: string]: PluginExecutionResult;
|
|
149
|
+
[key: string]: PluginExecutionResult$1;
|
|
151
150
|
};
|
|
151
|
+
agent_message_id?: string;
|
|
152
|
+
user_message_id?: string;
|
|
152
153
|
};
|
|
153
154
|
/**
|
|
154
155
|
* Represents the events that can occur during a realtime session.
|
|
@@ -210,7 +211,7 @@ type ExecuteBodyParams = Array<{
|
|
|
210
211
|
Key: string;
|
|
211
212
|
Value: any;
|
|
212
213
|
}>;
|
|
213
|
-
type MetaAnalysisRes = {
|
|
214
|
+
type MetaAnalysisRes$1 = {
|
|
214
215
|
[key: string]: any;
|
|
215
216
|
} & {
|
|
216
217
|
policy_compliance?: {
|
|
@@ -258,23 +259,370 @@ type MetaAnalysisRes = {
|
|
|
258
259
|
topic_area?: string;
|
|
259
260
|
};
|
|
260
261
|
};
|
|
261
|
-
type CompletionUsageRes = {
|
|
262
|
+
type CompletionUsageRes$1 = {
|
|
262
263
|
completion_tokens: number;
|
|
263
264
|
prompt_tokens: number;
|
|
264
265
|
total_tokens: number;
|
|
265
266
|
};
|
|
266
|
-
type ExecutorTaskLogsRes = {
|
|
267
|
+
type ExecutorTaskLogsRes$1 = {
|
|
267
268
|
description: string;
|
|
268
269
|
duration: number;
|
|
269
270
|
}[];
|
|
270
|
-
type SpeechGenerationResult = {
|
|
271
|
+
type SpeechGenerationResult$1 = {
|
|
271
272
|
content: string;
|
|
272
273
|
finish_reason?: string;
|
|
273
274
|
usage?: {
|
|
274
275
|
[key: string]: any;
|
|
275
276
|
};
|
|
276
277
|
};
|
|
278
|
+
type PluginExecutionResult$1 = SpeechGenerationResult$1;
|
|
279
|
+
type BaseErrorBody = {
|
|
280
|
+
message: string;
|
|
281
|
+
statusCode: number;
|
|
282
|
+
};
|
|
283
|
+
type ValidationErrorBody = BaseErrorBody & {
|
|
284
|
+
errors: {
|
|
285
|
+
[key: string]: string;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
type RateLimitErrorBody = BaseErrorBody & {
|
|
289
|
+
retryAfter: number;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
type MessageAdditionalInfo = {
|
|
293
|
+
inputParameters?: {
|
|
294
|
+
[key: string]: any;
|
|
295
|
+
};
|
|
296
|
+
volatileKnowledgeIds?: string[];
|
|
297
|
+
};
|
|
298
|
+
type ConversationInfoResult = {
|
|
299
|
+
agent: {
|
|
300
|
+
isRealtime: boolean;
|
|
301
|
+
version: number;
|
|
302
|
+
visionEnabled: boolean;
|
|
303
|
+
imageId: string;
|
|
304
|
+
};
|
|
305
|
+
conversation: {
|
|
306
|
+
initialMessage: string;
|
|
307
|
+
starters: string[];
|
|
308
|
+
};
|
|
309
|
+
channel?: ChatWidgetRes;
|
|
310
|
+
};
|
|
311
|
+
type ChatWidgetRes = {
|
|
312
|
+
expanded: boolean;
|
|
313
|
+
opened: boolean;
|
|
314
|
+
showExpandButton: boolean;
|
|
315
|
+
allowUpload: boolean;
|
|
316
|
+
allowAudioRecording: boolean;
|
|
317
|
+
storeConversation: boolean;
|
|
318
|
+
stream: boolean;
|
|
319
|
+
extractPageContent: boolean;
|
|
320
|
+
showSystemLogo: boolean;
|
|
321
|
+
userIdentifier: string;
|
|
322
|
+
logoURL: string;
|
|
323
|
+
mode: string;
|
|
324
|
+
engagementMessage: EngagementMessageRes;
|
|
325
|
+
locale: LocaleRes;
|
|
326
|
+
theme: ThemeRes;
|
|
327
|
+
enableFeedbackRecollection: boolean;
|
|
328
|
+
};
|
|
329
|
+
type EngagementMessageRes = {
|
|
330
|
+
enabled: boolean;
|
|
331
|
+
message: string;
|
|
332
|
+
showAfter: number;
|
|
333
|
+
};
|
|
334
|
+
type LocaleRes = {
|
|
335
|
+
uploadFileErrorMessage: string;
|
|
336
|
+
uploadFilesErrorMessage: string;
|
|
337
|
+
chatErrorMessage: string;
|
|
338
|
+
chatInitConversationErrorMessage: string;
|
|
339
|
+
headerTitle: string;
|
|
340
|
+
finalizedMessage: string;
|
|
341
|
+
limitExceededMessage: string;
|
|
342
|
+
waitUntilMessage: string;
|
|
343
|
+
remainingMessage: string;
|
|
344
|
+
inputPlaceholder: string;
|
|
345
|
+
internalLinkMessage: string;
|
|
346
|
+
newChatBtnMessage: string;
|
|
347
|
+
exceededMaxNumberOfFilesMessage: string;
|
|
348
|
+
exceededMaxFileStatusChecksMessage: string;
|
|
349
|
+
closedConversationMessage: string;
|
|
350
|
+
};
|
|
351
|
+
type ThemeRes = {
|
|
352
|
+
header: HeaderThemeRes;
|
|
353
|
+
fabButton: FabButtonThemeRes;
|
|
354
|
+
sendButton: SendButtonThemeRes;
|
|
355
|
+
engagementMessage: EngagementMessageThemeRes;
|
|
356
|
+
conversationStarters: ConversationStartersThemeRes;
|
|
357
|
+
scrollToBottomIndicator: ScrollToBottomIndicatorThemeRes;
|
|
358
|
+
uploadFileBtn: UploadFileBtnThemeRes;
|
|
359
|
+
messageBubble: MessageBubbleThemeRes;
|
|
360
|
+
};
|
|
361
|
+
type HeaderThemeRes = {
|
|
362
|
+
bgColor: string;
|
|
363
|
+
textColor: string;
|
|
364
|
+
resetChatBtn: ResetChatBtnThemeRes;
|
|
365
|
+
minimizeBtn: MinimizeBtnThemeRes;
|
|
366
|
+
};
|
|
367
|
+
type FabButtonThemeRes = {
|
|
368
|
+
bgColor: string;
|
|
369
|
+
iconStrokeColor: string;
|
|
370
|
+
buttonSize: number;
|
|
371
|
+
iconSize: number;
|
|
372
|
+
};
|
|
373
|
+
type SendButtonThemeRes = {
|
|
374
|
+
bgColor: string;
|
|
375
|
+
iconStrokeColor: string;
|
|
376
|
+
};
|
|
377
|
+
type EngagementMessageThemeRes = {
|
|
378
|
+
bgColor: string;
|
|
379
|
+
textColor: string;
|
|
380
|
+
};
|
|
381
|
+
type ConversationStartersThemeRes = {
|
|
382
|
+
bgColor: string;
|
|
383
|
+
textColor: string;
|
|
384
|
+
containerBgColor: string;
|
|
385
|
+
initialMessageBgColor: string;
|
|
386
|
+
initialMessageTextColor: string;
|
|
387
|
+
};
|
|
388
|
+
type ScrollToBottomIndicatorThemeRes = {
|
|
389
|
+
bgColor: string;
|
|
390
|
+
iconStrokeColor: string;
|
|
391
|
+
};
|
|
392
|
+
type UploadFileBtnThemeRes = {
|
|
393
|
+
iconStrokeColor: string;
|
|
394
|
+
};
|
|
395
|
+
type MessageBubbleThemeRes = {
|
|
396
|
+
user: UserThemeRes;
|
|
397
|
+
assistant: AssistantThemeRes;
|
|
398
|
+
};
|
|
399
|
+
type ResetChatBtnThemeRes = {
|
|
400
|
+
bgColor: string;
|
|
401
|
+
hoverBgColor: string;
|
|
402
|
+
textColor: string;
|
|
403
|
+
};
|
|
404
|
+
type MinimizeBtnThemeRes = {
|
|
405
|
+
iconStrokeColor: string;
|
|
406
|
+
};
|
|
407
|
+
type UserThemeRes = {
|
|
408
|
+
bgColor: string;
|
|
409
|
+
textColor: string;
|
|
410
|
+
};
|
|
411
|
+
type AssistantThemeRes = {
|
|
412
|
+
bgColor: string;
|
|
413
|
+
textColor: string;
|
|
414
|
+
};
|
|
415
|
+
type ConversationRes = {
|
|
416
|
+
startDate: string;
|
|
417
|
+
endDate: string;
|
|
418
|
+
id: string;
|
|
419
|
+
messages: Message[];
|
|
420
|
+
name: string;
|
|
421
|
+
userIdentifier?: string;
|
|
422
|
+
useVision?: boolean;
|
|
423
|
+
conversationStarters?: string[];
|
|
424
|
+
open?: boolean;
|
|
425
|
+
};
|
|
426
|
+
type Message = ({
|
|
427
|
+
sender: "user";
|
|
428
|
+
} | {
|
|
429
|
+
sender: "bot";
|
|
430
|
+
conversationStarters?: string[];
|
|
431
|
+
}) & {
|
|
432
|
+
id: string;
|
|
433
|
+
created_at: Date;
|
|
434
|
+
type: "text" | "image" | "error" | "info";
|
|
435
|
+
value: string;
|
|
436
|
+
attachments?: VolatileKnowledgeUploadRes[] | AttachedVolatileKnowledge[];
|
|
437
|
+
meta_analysis?: MetaAnalysisRes;
|
|
438
|
+
completion_usage?: CompletionUsageRes;
|
|
439
|
+
time_to_first_token?: number;
|
|
440
|
+
executor_task_logs?: ExecutorTaskLogsRes;
|
|
441
|
+
attached_volatile_knowledges?: AttachedVolatileKnowledge[];
|
|
442
|
+
action_results?: {
|
|
443
|
+
[key: string]: PluginExecutionResult;
|
|
444
|
+
};
|
|
445
|
+
};
|
|
277
446
|
type PluginExecutionResult = SpeechGenerationResult;
|
|
447
|
+
type SpeechGenerationResult = {
|
|
448
|
+
content: string;
|
|
449
|
+
finish_reason?: string;
|
|
450
|
+
usage?: object;
|
|
451
|
+
};
|
|
452
|
+
type VolatileKnowledgeUploadRes = {
|
|
453
|
+
id: string;
|
|
454
|
+
expirationDate: string;
|
|
455
|
+
status: string;
|
|
456
|
+
fileName: string;
|
|
457
|
+
fileSize: number;
|
|
458
|
+
};
|
|
459
|
+
type AttachedVolatileKnowledge = {
|
|
460
|
+
id: string;
|
|
461
|
+
expirationDate: string;
|
|
462
|
+
fileId: string;
|
|
463
|
+
fileName: string;
|
|
464
|
+
fileSize: number;
|
|
465
|
+
downloadUrl: string;
|
|
466
|
+
};
|
|
467
|
+
type CompletionUsageRes = {
|
|
468
|
+
completion_tokens: number;
|
|
469
|
+
prompt_tokens: number;
|
|
470
|
+
total_tokens: number;
|
|
471
|
+
};
|
|
472
|
+
type ExecutorTaskLogsRes = {
|
|
473
|
+
description: string;
|
|
474
|
+
duration: number;
|
|
475
|
+
}[];
|
|
476
|
+
type MetaAnalysisRes = {
|
|
477
|
+
[key: string]: any;
|
|
478
|
+
} & {
|
|
479
|
+
policy_compliance?: {
|
|
480
|
+
compliance_score?: number;
|
|
481
|
+
explanation?: string;
|
|
482
|
+
policy_violations?: {
|
|
483
|
+
source_id?: string;
|
|
484
|
+
source_document_name: string;
|
|
485
|
+
chunk_id?: string;
|
|
486
|
+
section_number?: string;
|
|
487
|
+
section?: string;
|
|
488
|
+
policy?: string;
|
|
489
|
+
policy_name: string;
|
|
490
|
+
policy_id?: string;
|
|
491
|
+
}[];
|
|
492
|
+
};
|
|
493
|
+
pii_release_risk?: {
|
|
494
|
+
risk_score?: number;
|
|
495
|
+
explanation?: string;
|
|
496
|
+
};
|
|
497
|
+
ethics?: {
|
|
498
|
+
score?: number;
|
|
499
|
+
explanation?: string;
|
|
500
|
+
avoid_topics?: {
|
|
501
|
+
topic: string;
|
|
502
|
+
reason: string;
|
|
503
|
+
}[];
|
|
504
|
+
};
|
|
505
|
+
deception_estimation?: {
|
|
506
|
+
deception_score?: number;
|
|
507
|
+
explanation?: string;
|
|
508
|
+
};
|
|
509
|
+
cybersecurity_threat?: {
|
|
510
|
+
threat_assessment?: number;
|
|
511
|
+
explanation?: string;
|
|
512
|
+
};
|
|
513
|
+
social_content_risk?: {
|
|
514
|
+
risk_score?: number;
|
|
515
|
+
explanation?: string;
|
|
516
|
+
};
|
|
517
|
+
conversation_analysis?: {
|
|
518
|
+
emotion_value_estimate?: number;
|
|
519
|
+
predicted_next_goal?: string;
|
|
520
|
+
attended_to_features?: string[];
|
|
521
|
+
topic_area?: string;
|
|
522
|
+
};
|
|
523
|
+
guardrails_compliance?: {
|
|
524
|
+
explanation?: string;
|
|
525
|
+
investment_score?: number;
|
|
526
|
+
legal_score?: number;
|
|
527
|
+
medical_score?: number;
|
|
528
|
+
tax_score?: number;
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
type SubmitFeedbackOptions = {
|
|
532
|
+
/**
|
|
533
|
+
* The ID of the agent message to provide feedback for
|
|
534
|
+
*/
|
|
535
|
+
agentMessageId: string;
|
|
536
|
+
/**
|
|
537
|
+
* The feedback value - true for positive, false for negative
|
|
538
|
+
*/
|
|
539
|
+
feedback: boolean;
|
|
540
|
+
};
|
|
541
|
+
type SubmitFeedbackResult = {
|
|
542
|
+
/**
|
|
543
|
+
* Indicates if the feedback was successfully submitted
|
|
544
|
+
*/
|
|
545
|
+
success: boolean;
|
|
546
|
+
};
|
|
547
|
+
type RemoveFeedbackOptions = {
|
|
548
|
+
/**
|
|
549
|
+
* The ID of the agent message to remove feedback from
|
|
550
|
+
*/
|
|
551
|
+
agentMessageId: string;
|
|
552
|
+
};
|
|
553
|
+
type RemoveFeedbackResult = {
|
|
554
|
+
/**
|
|
555
|
+
* Indicates if the feedback was successfully removed
|
|
556
|
+
*/
|
|
557
|
+
success: boolean;
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
declare class Conversation extends EventEmitter<SSEStreamEvents> {
|
|
561
|
+
#private;
|
|
562
|
+
private agentCode;
|
|
563
|
+
private apiKey;
|
|
564
|
+
private baseUrl;
|
|
565
|
+
private userIdentifier?;
|
|
566
|
+
private agentVersion?;
|
|
567
|
+
private channel?;
|
|
568
|
+
private inputParameters?;
|
|
569
|
+
conversationId?: string;
|
|
570
|
+
info: ConversationInfoResult | null;
|
|
571
|
+
private constructor();
|
|
572
|
+
private static create;
|
|
573
|
+
private static createWithoutInfo;
|
|
574
|
+
streamMessage(message: string, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
575
|
+
sendMessage(message: string, options?: MessageAdditionalInfo): Promise<AgentResult>;
|
|
576
|
+
getConversationById(id: string, options?: {
|
|
577
|
+
showExecutorTaskLogs: boolean;
|
|
578
|
+
}): Promise<ConversationRes>;
|
|
579
|
+
getInfo(): Promise<ConversationInfoResult>;
|
|
580
|
+
/**
|
|
581
|
+
* Submit feedback for an agent message in the conversation.
|
|
582
|
+
*
|
|
583
|
+
* @param options - The feedback options including the agent message ID and feedback value
|
|
584
|
+
* @returns A promise that resolves to the feedback submission result
|
|
585
|
+
* @throws Error if the conversation ID is not set or if the request fails
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* ```typescript
|
|
589
|
+
* const conversation = await client.agents.assistants.createConversation("agent-code");
|
|
590
|
+
* const response = await conversation.sendMessage("Hello!");
|
|
591
|
+
*
|
|
592
|
+
* // Submit positive feedback
|
|
593
|
+
* await conversation.submitFeedback({
|
|
594
|
+
* agentMessageId: response.agent_message_id!,
|
|
595
|
+
* feedback: true
|
|
596
|
+
* });
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
submitFeedback(options: SubmitFeedbackOptions): Promise<SubmitFeedbackResult>;
|
|
600
|
+
/**
|
|
601
|
+
* Remove feedback for an agent message in the conversation.
|
|
602
|
+
*
|
|
603
|
+
* @param options - The feedback options including the agent message ID
|
|
604
|
+
* @returns A promise that resolves to the feedback removal result
|
|
605
|
+
* @throws Error if the conversation ID is not set or if the request fails
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```typescript
|
|
609
|
+
* const conversation = await client.agents.assistants.createConversation("agent-code");
|
|
610
|
+
* const response = await conversation.sendMessage("Hello!");
|
|
611
|
+
*
|
|
612
|
+
* // Submit feedback first
|
|
613
|
+
* await conversation.submitFeedback({
|
|
614
|
+
* agentMessageId: response.agent_message_id!,
|
|
615
|
+
* feedback: true
|
|
616
|
+
* });
|
|
617
|
+
*
|
|
618
|
+
* // Remove feedback
|
|
619
|
+
* await conversation.removeFeedback({
|
|
620
|
+
* agentMessageId: response.agent_message_id!
|
|
621
|
+
* });
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
removeFeedback(options: RemoveFeedbackOptions): Promise<RemoveFeedbackResult>;
|
|
625
|
+
}
|
|
278
626
|
|
|
279
627
|
/**
|
|
280
628
|
* Events that can be emitted by a realtime session.
|
|
@@ -351,7 +699,7 @@ declare class RealtimeSession extends EventEmitter<RealtimeSessionEvents> {
|
|
|
351
699
|
private localStream?;
|
|
352
700
|
private dataChannel?;
|
|
353
701
|
private socket?;
|
|
354
|
-
constructor(agentCode: string, apiKey: string, baseUrl: string, options?:
|
|
702
|
+
constructor(agentCode: string, apiKey: string, baseUrl: string, options?: AgentSetupOptions);
|
|
355
703
|
/**
|
|
356
704
|
* Starts the real-time session.
|
|
357
705
|
*/
|
|
@@ -370,29 +718,6 @@ declare class RealtimeSession extends EventEmitter<RealtimeSessionEvents> {
|
|
|
370
718
|
unmuteMicrophone(): void;
|
|
371
719
|
}
|
|
372
720
|
|
|
373
|
-
type MessageOptions = {
|
|
374
|
-
inputParameters?: {
|
|
375
|
-
[key: string]: any;
|
|
376
|
-
};
|
|
377
|
-
volatileKnowledgeIds?: string[];
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
declare class Conversation extends EventEmitter<SSEStreamEvents> {
|
|
381
|
-
#private;
|
|
382
|
-
private agentCode;
|
|
383
|
-
private apiKey;
|
|
384
|
-
private baseUrl;
|
|
385
|
-
private inputParameters?;
|
|
386
|
-
private userIdentifier?;
|
|
387
|
-
private agentVersion?;
|
|
388
|
-
private channel?;
|
|
389
|
-
conversationId?: string;
|
|
390
|
-
private constructor();
|
|
391
|
-
private static create;
|
|
392
|
-
streamMessage(message: string, options?: MessageOptions): Promise<AgentResult>;
|
|
393
|
-
sendMessage(message: string, options?: MessageOptions): Promise<AgentResult>;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
721
|
declare abstract class SystemAgent<T extends keyof SystemAgentExecutionOptionsMap> extends EventEmitter<SSEStreamEvents> {
|
|
397
722
|
protected readonly agentCode: string;
|
|
398
723
|
protected readonly apiKey: string;
|
|
@@ -431,16 +756,6 @@ declare class ChatCompletion extends SystemAgent<"chat-completion"> {
|
|
|
431
756
|
private appendInputParametersIfNeeded;
|
|
432
757
|
}
|
|
433
758
|
|
|
434
|
-
declare class Plan extends SystemAgent<"plan"> {
|
|
435
|
-
private constructor();
|
|
436
|
-
static create(agentCode: string, apiKey: string, baseUrl: string, options?: SystemAgentExecutionOptionsMap["plan"]): Plan;
|
|
437
|
-
static createAndExecute(agentCode: string, apiKey: string, baseUrl: string, options?: SystemAgentExecutionOptionsMap["plan"]): Promise<AgentResult>;
|
|
438
|
-
protected createExecuteBody(stream: boolean): ExecuteBodyParams | {
|
|
439
|
-
[key: string]: any;
|
|
440
|
-
};
|
|
441
|
-
private appendInputParametersIfNeeded;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
759
|
declare class Proxy extends SystemAgent<"proxy"> {
|
|
445
760
|
private constructor();
|
|
446
761
|
static create(agentCode: string, apiKey: string, baseUrl: string, options?: SystemAgentExecutionOptionsMap["proxy"]): Proxy;
|
|
@@ -477,7 +792,7 @@ type ConversationalAgentScope<T extends keyof ConversationalAgentExecutionOption
|
|
|
477
792
|
* @param options - Additional options for the conversation
|
|
478
793
|
* @returns A Promise that resolves to a Conversation instance
|
|
479
794
|
*/
|
|
480
|
-
createConversation: (agentCode: string, options?:
|
|
795
|
+
createConversation: (agentCode: string, options?: AgentSetupOptions) => Promise<Conversation>;
|
|
481
796
|
/**
|
|
482
797
|
* Create a real-time session with an agent.
|
|
483
798
|
* This allows for voice interactions and real-time responses.
|
|
@@ -501,6 +816,10 @@ type ConversationalAgentScope<T extends keyof ConversationalAgentExecutionOption
|
|
|
501
816
|
* @returns A RealtimeSession instance
|
|
502
817
|
*/
|
|
503
818
|
createRealtimeSession: (agentCode: string, options?: ConversationalAgentExecutionOptionsMap[T]) => RealtimeSession;
|
|
819
|
+
getInfoByCode: (agentCode: string, options?: AgentSetupOptions) => Promise<ConversationInfoResult> | null;
|
|
820
|
+
getConversationById: (agentCode: string, conversationId: string, options?: {
|
|
821
|
+
showExecutorTaskLogs: boolean;
|
|
822
|
+
}) => Promise<ConversationRes>;
|
|
504
823
|
};
|
|
505
824
|
type SystemAgentScope<T extends keyof SystemAgentExecutionOptionsMap, TCreateReturn> = {
|
|
506
825
|
/**
|
|
@@ -555,7 +874,7 @@ declare class SerenityClient {
|
|
|
555
874
|
private baseUrl;
|
|
556
875
|
/**
|
|
557
876
|
* Interact with the different agents available in Serenity Star.
|
|
558
|
-
* You can choose between assistants, copilots, activities, chat completions
|
|
877
|
+
* You can choose between assistants, copilots, activities, chat completions and proxies.
|
|
559
878
|
*/
|
|
560
879
|
readonly agents: {
|
|
561
880
|
/**
|
|
@@ -726,32 +1045,18 @@ declare class SerenityClient {
|
|
|
726
1045
|
* ```
|
|
727
1046
|
*/
|
|
728
1047
|
proxies: SystemAgentScope<"proxy", Proxy>;
|
|
729
|
-
/**
|
|
730
|
-
* Interact with Plan agents available in Serenity Star.
|
|
731
|
-
* This allows you to execute plans.
|
|
732
|
-
* It supports streaming.
|
|
733
|
-
* Plan agents are capable of building an execution plan based on the user input and execute it.
|
|
734
|
-
*
|
|
735
|
-
* ## Regular plan execution:
|
|
736
|
-
* ```typescript
|
|
737
|
-
* const response = await client.agents.plans.execute("event-planner");
|
|
738
|
-
* console.log(response.content);
|
|
739
|
-
* ```
|
|
740
|
-
*
|
|
741
|
-
* ## Stream plan with SSE:
|
|
742
|
-
* ```typescript
|
|
743
|
-
* const plan = client.agents.plans
|
|
744
|
-
* .create("event-planner")
|
|
745
|
-
* .on("start", () => console.log("Started"))
|
|
746
|
-
* .on("content", (chunk) => console.log(chunk))
|
|
747
|
-
* .on("error", (error) => console.error(error));
|
|
748
|
-
*
|
|
749
|
-
* await plan.stream();
|
|
750
|
-
* ```
|
|
751
|
-
*/
|
|
752
|
-
plans: SystemAgentScope<"plan", Plan>;
|
|
753
1048
|
};
|
|
754
1049
|
constructor(options: SerenityClientOptions);
|
|
755
1050
|
}
|
|
756
1051
|
|
|
757
|
-
|
|
1052
|
+
declare class ExternalErrorHelper {
|
|
1053
|
+
static determineErrorType(error: unknown): {
|
|
1054
|
+
type: "RateLimitError" | "ValidationError" | "BaseError" | "UnknownError";
|
|
1055
|
+
error: RateLimitErrorBody | ValidationErrorBody | BaseErrorBody | unknown;
|
|
1056
|
+
};
|
|
1057
|
+
private static isRateLimitErrorBody;
|
|
1058
|
+
private static isValidationErrorBody;
|
|
1059
|
+
private static isBaseErrorBody;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
export { type AgentResult, type BaseErrorBody, type ChatWidgetRes, Conversation, type ConversationInfoResult, type ConversationRes, ExternalErrorHelper as ErrorHelper, type Message, type RateLimitErrorBody, RealtimeSession, type RemoveFeedbackOptions, type RemoveFeedbackResult, SerenityClient, type SubmitFeedbackOptions, type SubmitFeedbackResult, type ValidationErrorBody };
|