@wundr.io/autogen-orchestrator 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1088 -0
- package/dist/group-chat.d.ts +327 -0
- package/dist/group-chat.d.ts.map +1 -0
- package/dist/group-chat.js +724 -0
- package/dist/group-chat.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/nested-chat.d.ts +296 -0
- package/dist/nested-chat.d.ts.map +1 -0
- package/dist/nested-chat.js +600 -0
- package/dist/nested-chat.js.map +1 -0
- package/dist/speaker-selection.d.ts +195 -0
- package/dist/speaker-selection.d.ts.map +1 -0
- package/dist/speaker-selection.js +569 -0
- package/dist/speaker-selection.js.map +1 -0
- package/dist/termination.d.ts +237 -0
- package/dist/termination.d.ts.map +1 -0
- package/dist/termination.js +566 -0
- package/dist/termination.js.map +1 -0
- package/dist/types.d.ts +1248 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +201 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -0
- package/src/group-chat.ts +980 -0
- package/src/index.ts +145 -0
- package/src/nested-chat.ts +795 -0
- package/src/speaker-selection.ts +794 -0
- package/src/termination.ts +704 -0
- package/src/types.ts +876 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,1248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for AutoGen-style multi-agent orchestration
|
|
3
|
+
*
|
|
4
|
+
* Implements conversational patterns for agent coordination including
|
|
5
|
+
* group chat, speaker selection, and termination handling.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Role of the message sender in the conversation
|
|
10
|
+
*/
|
|
11
|
+
export type MessageRole = 'system' | 'user' | 'assistant' | 'function';
|
|
12
|
+
/**
|
|
13
|
+
* Status of a message in the conversation flow
|
|
14
|
+
*/
|
|
15
|
+
export type MessageStatus = 'pending' | 'delivered' | 'processed' | 'failed';
|
|
16
|
+
/**
|
|
17
|
+
* Content type within a message
|
|
18
|
+
*/
|
|
19
|
+
export type ContentType = 'text' | 'code' | 'image' | 'function_call' | 'function_result';
|
|
20
|
+
/**
|
|
21
|
+
* Represents a single message in the conversation
|
|
22
|
+
*/
|
|
23
|
+
export interface Message {
|
|
24
|
+
/** Unique identifier for the message */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Role of the message sender */
|
|
27
|
+
role: MessageRole;
|
|
28
|
+
/** Content of the message */
|
|
29
|
+
content: string;
|
|
30
|
+
/** Name of the sender (participant name) */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Timestamp when message was created */
|
|
33
|
+
timestamp: Date;
|
|
34
|
+
/** Optional metadata attached to the message */
|
|
35
|
+
metadata?: MessageMetadata;
|
|
36
|
+
/** Content type */
|
|
37
|
+
contentType?: ContentType;
|
|
38
|
+
/** Function call details if applicable */
|
|
39
|
+
functionCall?: FunctionCall;
|
|
40
|
+
/** Status of the message */
|
|
41
|
+
status?: MessageStatus;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Metadata attached to a message
|
|
45
|
+
*/
|
|
46
|
+
export interface MessageMetadata {
|
|
47
|
+
/** Token count for the message */
|
|
48
|
+
tokenCount?: number;
|
|
49
|
+
/** Processing latency in milliseconds */
|
|
50
|
+
latencyMs?: number;
|
|
51
|
+
/** Model used to generate the message */
|
|
52
|
+
model?: string;
|
|
53
|
+
/** Associated task ID */
|
|
54
|
+
taskId?: string;
|
|
55
|
+
/** Parent message ID for threading */
|
|
56
|
+
parentId?: string;
|
|
57
|
+
/** Custom properties */
|
|
58
|
+
properties?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Function call embedded in a message
|
|
62
|
+
*/
|
|
63
|
+
export interface FunctionCall {
|
|
64
|
+
/** Name of the function to call */
|
|
65
|
+
name: string;
|
|
66
|
+
/** Arguments for the function */
|
|
67
|
+
arguments: Record<string, unknown>;
|
|
68
|
+
/** Result of the function call */
|
|
69
|
+
result?: unknown;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Type of chat participant
|
|
73
|
+
*/
|
|
74
|
+
export type ParticipantType = 'human' | 'assistant' | 'agent' | 'tool';
|
|
75
|
+
/**
|
|
76
|
+
* Status of a chat participant
|
|
77
|
+
*/
|
|
78
|
+
export type ParticipantStatus = 'active' | 'idle' | 'busy' | 'offline' | 'error';
|
|
79
|
+
/**
|
|
80
|
+
* Represents a participant in the group chat
|
|
81
|
+
*/
|
|
82
|
+
export interface ChatParticipant {
|
|
83
|
+
/** Unique identifier for the participant */
|
|
84
|
+
id: string;
|
|
85
|
+
/** Display name of the participant */
|
|
86
|
+
name: string;
|
|
87
|
+
/** Type of participant */
|
|
88
|
+
type: ParticipantType;
|
|
89
|
+
/** System prompt defining participant's behavior */
|
|
90
|
+
systemPrompt: string;
|
|
91
|
+
/** Current status of the participant */
|
|
92
|
+
status: ParticipantStatus;
|
|
93
|
+
/** Capabilities of this participant */
|
|
94
|
+
capabilities: string[];
|
|
95
|
+
/** Model configuration for AI participants */
|
|
96
|
+
modelConfig?: ModelConfig;
|
|
97
|
+
/** Function definitions available to this participant */
|
|
98
|
+
functions?: FunctionDefinition[];
|
|
99
|
+
/** Maximum number of consecutive replies allowed */
|
|
100
|
+
maxConsecutiveReplies?: number;
|
|
101
|
+
/** Description of the participant's role */
|
|
102
|
+
description?: string;
|
|
103
|
+
/** Metadata for the participant */
|
|
104
|
+
metadata?: ParticipantMetadata;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Model configuration for AI participants
|
|
108
|
+
*/
|
|
109
|
+
export interface ModelConfig {
|
|
110
|
+
/** Model identifier */
|
|
111
|
+
model: string;
|
|
112
|
+
/** Temperature for generation */
|
|
113
|
+
temperature?: number;
|
|
114
|
+
/** Maximum tokens to generate */
|
|
115
|
+
maxTokens?: number;
|
|
116
|
+
/** Top-p sampling parameter */
|
|
117
|
+
topP?: number;
|
|
118
|
+
/** Frequency penalty */
|
|
119
|
+
frequencyPenalty?: number;
|
|
120
|
+
/** Presence penalty */
|
|
121
|
+
presencePenalty?: number;
|
|
122
|
+
/** Stop sequences */
|
|
123
|
+
stopSequences?: string[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Function definition for participants
|
|
127
|
+
*/
|
|
128
|
+
export interface FunctionDefinition {
|
|
129
|
+
/** Function name */
|
|
130
|
+
name: string;
|
|
131
|
+
/** Function description */
|
|
132
|
+
description: string;
|
|
133
|
+
/** Parameter schema */
|
|
134
|
+
parameters: Record<string, unknown>;
|
|
135
|
+
/** Whether function is required */
|
|
136
|
+
required?: boolean;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Metadata for participants
|
|
140
|
+
*/
|
|
141
|
+
export interface ParticipantMetadata {
|
|
142
|
+
/** Creation timestamp */
|
|
143
|
+
createdAt: Date;
|
|
144
|
+
/** Last activity timestamp */
|
|
145
|
+
lastActiveAt?: Date;
|
|
146
|
+
/** Total messages sent */
|
|
147
|
+
messageCount?: number;
|
|
148
|
+
/** Success rate */
|
|
149
|
+
successRate?: number;
|
|
150
|
+
/** Custom properties */
|
|
151
|
+
properties?: Record<string, unknown>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Speaker selection method for group chat
|
|
155
|
+
*/
|
|
156
|
+
export type SpeakerSelectionMethod = 'round_robin' | 'random' | 'llm_selected' | 'priority' | 'manual' | 'auto';
|
|
157
|
+
/**
|
|
158
|
+
* Configuration for the group chat
|
|
159
|
+
*/
|
|
160
|
+
export interface GroupChatConfig {
|
|
161
|
+
/** Unique identifier for the chat */
|
|
162
|
+
id?: string;
|
|
163
|
+
/** Name of the group chat */
|
|
164
|
+
name: string;
|
|
165
|
+
/** Description of the chat's purpose */
|
|
166
|
+
description?: string;
|
|
167
|
+
/** Participants in the chat */
|
|
168
|
+
participants: ChatParticipant[];
|
|
169
|
+
/** Speaker selection method */
|
|
170
|
+
speakerSelectionMethod: SpeakerSelectionMethod;
|
|
171
|
+
/** Configuration for speaker selection */
|
|
172
|
+
speakerSelectionConfig?: SpeakerSelectionConfig;
|
|
173
|
+
/** Maximum number of conversation rounds */
|
|
174
|
+
maxRounds?: number;
|
|
175
|
+
/** Maximum total messages allowed */
|
|
176
|
+
maxMessages?: number;
|
|
177
|
+
/** Termination conditions */
|
|
178
|
+
terminationConditions?: TerminationCondition[];
|
|
179
|
+
/** Whether to allow nested chats */
|
|
180
|
+
allowNestedChats?: boolean;
|
|
181
|
+
/** Nested chat configurations */
|
|
182
|
+
nestedChatConfigs?: NestedChatConfig[];
|
|
183
|
+
/** Admin participant name */
|
|
184
|
+
adminName?: string;
|
|
185
|
+
/** Enable message history */
|
|
186
|
+
enableHistory?: boolean;
|
|
187
|
+
/** Maximum history length to maintain */
|
|
188
|
+
maxHistoryLength?: number;
|
|
189
|
+
/** Timeout for the entire chat in milliseconds */
|
|
190
|
+
timeoutMs?: number;
|
|
191
|
+
/** Custom metadata */
|
|
192
|
+
metadata?: Record<string, unknown>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Configuration for speaker selection
|
|
196
|
+
*/
|
|
197
|
+
export interface SpeakerSelectionConfig {
|
|
198
|
+
/** Model for LLM-based selection */
|
|
199
|
+
selectorModel?: string;
|
|
200
|
+
/** Prompt template for LLM selection */
|
|
201
|
+
selectorPrompt?: string;
|
|
202
|
+
/** Priority order for priority-based selection */
|
|
203
|
+
priorityOrder?: string[];
|
|
204
|
+
/** Weights for weighted selection */
|
|
205
|
+
weights?: Record<string, number>;
|
|
206
|
+
/** Maximum retries for selection */
|
|
207
|
+
maxRetries?: number;
|
|
208
|
+
/** Transition rules between speakers */
|
|
209
|
+
transitionRules?: TransitionRule[];
|
|
210
|
+
/** Allowed speaker transitions */
|
|
211
|
+
allowedTransitions?: Record<string, string[]>;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Rule for speaker transitions
|
|
215
|
+
*/
|
|
216
|
+
export interface TransitionRule {
|
|
217
|
+
/** From participant name */
|
|
218
|
+
from: string;
|
|
219
|
+
/** To participant names */
|
|
220
|
+
to: string[];
|
|
221
|
+
/** Condition for the transition */
|
|
222
|
+
condition?: string;
|
|
223
|
+
/** Weight for this transition */
|
|
224
|
+
weight?: number;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Type of termination condition
|
|
228
|
+
*/
|
|
229
|
+
export type TerminationConditionType = 'max_rounds' | 'max_messages' | 'keyword' | 'timeout' | 'function' | 'consensus' | 'custom';
|
|
230
|
+
/**
|
|
231
|
+
* Configuration for consensus-based termination
|
|
232
|
+
*/
|
|
233
|
+
export interface ConsensusConfigType {
|
|
234
|
+
/** Minimum agreement threshold (0-1) */
|
|
235
|
+
threshold: number;
|
|
236
|
+
/** Keywords indicating agreement */
|
|
237
|
+
agreementKeywords: string[];
|
|
238
|
+
/** Keywords indicating disagreement */
|
|
239
|
+
disagreementKeywords: string[];
|
|
240
|
+
/** Minimum participants required for consensus */
|
|
241
|
+
minParticipants?: number;
|
|
242
|
+
/** Number of recent messages to consider */
|
|
243
|
+
windowSize?: number;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Union type for termination condition values based on type
|
|
247
|
+
* - max_rounds: number
|
|
248
|
+
* - max_messages: number
|
|
249
|
+
* - keyword: string | string[]
|
|
250
|
+
* - timeout: number (milliseconds)
|
|
251
|
+
* - function: TerminationEvaluator
|
|
252
|
+
* - consensus: ConsensusConfigType
|
|
253
|
+
* - custom: TerminationEvaluator | unknown
|
|
254
|
+
*/
|
|
255
|
+
export type TerminationConditionValue = number | string | string[] | ConsensusConfigType | TerminationEvaluator;
|
|
256
|
+
/**
|
|
257
|
+
* Configuration for termination conditions
|
|
258
|
+
*/
|
|
259
|
+
export interface TerminationCondition {
|
|
260
|
+
/** Type of termination condition */
|
|
261
|
+
type: TerminationConditionType;
|
|
262
|
+
/** Value for the condition - type depends on condition type */
|
|
263
|
+
value: TerminationConditionValue;
|
|
264
|
+
/** Description of the condition */
|
|
265
|
+
description?: string;
|
|
266
|
+
/** Custom function for evaluation (for 'function' type) */
|
|
267
|
+
evaluator?: TerminationEvaluator;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Function type for custom termination evaluation
|
|
271
|
+
*/
|
|
272
|
+
export type TerminationEvaluator = (messages: Message[], participants: ChatParticipant[], context: ChatContext) => Promise<TerminationResult>;
|
|
273
|
+
/**
|
|
274
|
+
* Result of termination evaluation
|
|
275
|
+
*/
|
|
276
|
+
export interface TerminationResult {
|
|
277
|
+
/** Whether to terminate */
|
|
278
|
+
shouldTerminate: boolean;
|
|
279
|
+
/** Reason for termination */
|
|
280
|
+
reason?: string;
|
|
281
|
+
/** Final summary */
|
|
282
|
+
summary?: string;
|
|
283
|
+
/** Additional data */
|
|
284
|
+
data?: Record<string, unknown>;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Configuration for nested chat sessions
|
|
288
|
+
*/
|
|
289
|
+
export interface NestedChatConfig {
|
|
290
|
+
/** Unique identifier for nested chat config */
|
|
291
|
+
id: string;
|
|
292
|
+
/** Name of the nested chat */
|
|
293
|
+
name: string;
|
|
294
|
+
/** Trigger condition for starting nested chat */
|
|
295
|
+
trigger: NestedChatTrigger;
|
|
296
|
+
/** Participants in the nested chat */
|
|
297
|
+
participants: string[];
|
|
298
|
+
/** Maximum rounds for nested chat */
|
|
299
|
+
maxRounds?: number;
|
|
300
|
+
/** Summary method after nested chat completes */
|
|
301
|
+
summaryMethod?: SummaryMethod;
|
|
302
|
+
/** Custom prompt for the nested chat */
|
|
303
|
+
prompt?: string;
|
|
304
|
+
/** Whether to share context with parent chat */
|
|
305
|
+
shareContext?: boolean;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Condition function type for nested chat triggers
|
|
309
|
+
*/
|
|
310
|
+
export type NestedChatConditionFn = (message: Message, context: ChatContext) => boolean;
|
|
311
|
+
/**
|
|
312
|
+
* Union type for nested chat trigger values based on trigger type
|
|
313
|
+
* - keyword: string | string[] (keywords to match)
|
|
314
|
+
* - participant: string | string[] (participant names)
|
|
315
|
+
* - condition: string | NestedChatConditionFn (condition expression or function)
|
|
316
|
+
* - manual: string (state key to check)
|
|
317
|
+
*/
|
|
318
|
+
export type NestedChatTriggerValue = string | string[] | NestedChatConditionFn;
|
|
319
|
+
/**
|
|
320
|
+
* Trigger for starting a nested chat
|
|
321
|
+
*/
|
|
322
|
+
export interface NestedChatTrigger {
|
|
323
|
+
/** Type of trigger */
|
|
324
|
+
type: 'keyword' | 'participant' | 'condition' | 'manual';
|
|
325
|
+
/** Value for the trigger - type depends on trigger type */
|
|
326
|
+
value: NestedChatTriggerValue;
|
|
327
|
+
/** Description of the trigger */
|
|
328
|
+
description?: string;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Method for summarizing nested chat results
|
|
332
|
+
*/
|
|
333
|
+
export type SummaryMethod = 'last' | 'llm' | 'reflection' | 'custom';
|
|
334
|
+
/**
|
|
335
|
+
* Status of the chat session
|
|
336
|
+
*/
|
|
337
|
+
export type ChatStatus = 'initializing' | 'active' | 'paused' | 'completed' | 'terminated' | 'error';
|
|
338
|
+
/**
|
|
339
|
+
* Result of a group chat session
|
|
340
|
+
*/
|
|
341
|
+
export interface ChatResult {
|
|
342
|
+
/** Chat session ID */
|
|
343
|
+
chatId: string;
|
|
344
|
+
/** Final status of the chat */
|
|
345
|
+
status: ChatStatus;
|
|
346
|
+
/** All messages in the conversation */
|
|
347
|
+
messages: Message[];
|
|
348
|
+
/** Summary of the conversation */
|
|
349
|
+
summary?: string;
|
|
350
|
+
/** Termination reason */
|
|
351
|
+
terminationReason?: string;
|
|
352
|
+
/** Total rounds completed */
|
|
353
|
+
totalRounds: number;
|
|
354
|
+
/** Total messages exchanged */
|
|
355
|
+
totalMessages: number;
|
|
356
|
+
/** Participants involved */
|
|
357
|
+
participants: string[];
|
|
358
|
+
/** Duration in milliseconds */
|
|
359
|
+
durationMs: number;
|
|
360
|
+
/** Metrics for the chat session */
|
|
361
|
+
metrics?: ChatMetrics;
|
|
362
|
+
/** Nested chat results if any */
|
|
363
|
+
nestedResults?: NestedChatResult[];
|
|
364
|
+
/** Error information if failed */
|
|
365
|
+
error?: ChatError;
|
|
366
|
+
/** Timestamp when chat started */
|
|
367
|
+
startedAt: Date;
|
|
368
|
+
/** Timestamp when chat ended */
|
|
369
|
+
endedAt: Date;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Metrics for a chat session
|
|
373
|
+
*/
|
|
374
|
+
export interface ChatMetrics {
|
|
375
|
+
/** Total tokens used */
|
|
376
|
+
totalTokens: number;
|
|
377
|
+
/** Average response time in milliseconds */
|
|
378
|
+
avgResponseTimeMs: number;
|
|
379
|
+
/** Messages per participant */
|
|
380
|
+
messagesPerParticipant: Record<string, number>;
|
|
381
|
+
/** Token usage per participant */
|
|
382
|
+
tokensPerParticipant: Record<string, number>;
|
|
383
|
+
/** Successful responses count */
|
|
384
|
+
successfulResponses: number;
|
|
385
|
+
/** Failed responses count */
|
|
386
|
+
failedResponses: number;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Result from a nested chat session
|
|
390
|
+
*/
|
|
391
|
+
export interface NestedChatResult {
|
|
392
|
+
/** Nested chat ID */
|
|
393
|
+
nestedChatId: string;
|
|
394
|
+
/** Config ID that triggered this nested chat */
|
|
395
|
+
configId: string;
|
|
396
|
+
/** Result of the nested chat */
|
|
397
|
+
result: ChatResult;
|
|
398
|
+
/** Summary from the nested chat */
|
|
399
|
+
summary?: string;
|
|
400
|
+
/** Parent message ID that triggered the nested chat */
|
|
401
|
+
parentMessageId: string;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Error information for chat failures
|
|
405
|
+
*/
|
|
406
|
+
export interface ChatError {
|
|
407
|
+
/** Error code */
|
|
408
|
+
code: string;
|
|
409
|
+
/** Error message */
|
|
410
|
+
message: string;
|
|
411
|
+
/** Stack trace if available */
|
|
412
|
+
stack?: string;
|
|
413
|
+
/** Context of the error */
|
|
414
|
+
context?: Record<string, unknown>;
|
|
415
|
+
/** Whether the error is recoverable */
|
|
416
|
+
recoverable: boolean;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Context available during chat execution
|
|
420
|
+
*/
|
|
421
|
+
export interface ChatContext {
|
|
422
|
+
/** Current chat ID */
|
|
423
|
+
chatId: string;
|
|
424
|
+
/** Current round number */
|
|
425
|
+
currentRound: number;
|
|
426
|
+
/** Total messages so far */
|
|
427
|
+
messageCount: number;
|
|
428
|
+
/** Active participants */
|
|
429
|
+
activeParticipants: string[];
|
|
430
|
+
/** Current speaker */
|
|
431
|
+
currentSpeaker?: string;
|
|
432
|
+
/** Previous speaker */
|
|
433
|
+
previousSpeaker?: string;
|
|
434
|
+
/** Start time */
|
|
435
|
+
startTime: Date;
|
|
436
|
+
/** Shared state */
|
|
437
|
+
state: Record<string, unknown>;
|
|
438
|
+
/** Parent context if nested */
|
|
439
|
+
parentContext?: ChatContext;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Result of speaker selection
|
|
443
|
+
*/
|
|
444
|
+
export interface SpeakerSelectionResult {
|
|
445
|
+
/** Selected speaker name */
|
|
446
|
+
speaker: string;
|
|
447
|
+
/** Reason for selection */
|
|
448
|
+
reason?: string;
|
|
449
|
+
/** Confidence score (0-1) */
|
|
450
|
+
confidence?: number;
|
|
451
|
+
/** Alternative speakers considered */
|
|
452
|
+
alternatives?: string[];
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Interface for speaker selection strategies
|
|
456
|
+
*/
|
|
457
|
+
export interface SpeakerSelectionStrategy {
|
|
458
|
+
/** Select the next speaker */
|
|
459
|
+
selectSpeaker(participants: ChatParticipant[], messages: Message[], context: ChatContext, config?: SpeakerSelectionConfig): Promise<SpeakerSelectionResult>;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Types of events emitted during chat
|
|
463
|
+
*/
|
|
464
|
+
export type ChatEventType = 'chat_started' | 'chat_ended' | 'message_sent' | 'message_received' | 'speaker_selected' | 'round_started' | 'round_ended' | 'nested_chat_started' | 'nested_chat_ended' | 'termination_triggered' | 'error';
|
|
465
|
+
/**
|
|
466
|
+
* Data payloads for different chat event types
|
|
467
|
+
*/
|
|
468
|
+
export interface ChatEventDataMap {
|
|
469
|
+
chat_started: {
|
|
470
|
+
config: GroupChatConfig;
|
|
471
|
+
};
|
|
472
|
+
chat_ended: {
|
|
473
|
+
result: ChatResult;
|
|
474
|
+
};
|
|
475
|
+
message_sent: {
|
|
476
|
+
message: Message;
|
|
477
|
+
};
|
|
478
|
+
message_received: {
|
|
479
|
+
message: Message;
|
|
480
|
+
};
|
|
481
|
+
speaker_selected: {
|
|
482
|
+
speaker: string;
|
|
483
|
+
reason?: string;
|
|
484
|
+
};
|
|
485
|
+
round_started: {
|
|
486
|
+
round: number;
|
|
487
|
+
};
|
|
488
|
+
round_ended: {
|
|
489
|
+
round: number;
|
|
490
|
+
};
|
|
491
|
+
nested_chat_started: {
|
|
492
|
+
nestedChatId: string;
|
|
493
|
+
configId: string;
|
|
494
|
+
};
|
|
495
|
+
nested_chat_ended: {
|
|
496
|
+
nestedChatId: string;
|
|
497
|
+
result: NestedChatResult;
|
|
498
|
+
};
|
|
499
|
+
termination_triggered: {
|
|
500
|
+
reason: string;
|
|
501
|
+
};
|
|
502
|
+
error: {
|
|
503
|
+
error: ChatError;
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Event emitted during chat execution
|
|
508
|
+
*/
|
|
509
|
+
export interface ChatEvent<T extends ChatEventType = ChatEventType> {
|
|
510
|
+
/** Event type */
|
|
511
|
+
type: T;
|
|
512
|
+
/** Event timestamp */
|
|
513
|
+
timestamp: Date;
|
|
514
|
+
/** Chat ID */
|
|
515
|
+
chatId: string;
|
|
516
|
+
/** Event data - typed based on event type */
|
|
517
|
+
data: T extends keyof ChatEventDataMap ? ChatEventDataMap[T] : Record<string, unknown>;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Zod schema for Message validation
|
|
521
|
+
*/
|
|
522
|
+
export declare const MessageSchema: z.ZodObject<{
|
|
523
|
+
id: z.ZodString;
|
|
524
|
+
role: z.ZodEnum<["system", "user", "assistant", "function"]>;
|
|
525
|
+
content: z.ZodString;
|
|
526
|
+
name: z.ZodString;
|
|
527
|
+
timestamp: z.ZodDate;
|
|
528
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
529
|
+
tokenCount: z.ZodOptional<z.ZodNumber>;
|
|
530
|
+
latencyMs: z.ZodOptional<z.ZodNumber>;
|
|
531
|
+
model: z.ZodOptional<z.ZodString>;
|
|
532
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
533
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
534
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
535
|
+
}, "strip", z.ZodTypeAny, {
|
|
536
|
+
tokenCount?: number | undefined;
|
|
537
|
+
latencyMs?: number | undefined;
|
|
538
|
+
model?: string | undefined;
|
|
539
|
+
taskId?: string | undefined;
|
|
540
|
+
parentId?: string | undefined;
|
|
541
|
+
properties?: Record<string, unknown> | undefined;
|
|
542
|
+
}, {
|
|
543
|
+
tokenCount?: number | undefined;
|
|
544
|
+
latencyMs?: number | undefined;
|
|
545
|
+
model?: string | undefined;
|
|
546
|
+
taskId?: string | undefined;
|
|
547
|
+
parentId?: string | undefined;
|
|
548
|
+
properties?: Record<string, unknown> | undefined;
|
|
549
|
+
}>>;
|
|
550
|
+
contentType: z.ZodOptional<z.ZodEnum<["text", "code", "image", "function_call", "function_result"]>>;
|
|
551
|
+
functionCall: z.ZodOptional<z.ZodObject<{
|
|
552
|
+
name: z.ZodString;
|
|
553
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
554
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
555
|
+
}, "strip", z.ZodTypeAny, {
|
|
556
|
+
name: string;
|
|
557
|
+
arguments: Record<string, unknown>;
|
|
558
|
+
result?: unknown;
|
|
559
|
+
}, {
|
|
560
|
+
name: string;
|
|
561
|
+
arguments: Record<string, unknown>;
|
|
562
|
+
result?: unknown;
|
|
563
|
+
}>>;
|
|
564
|
+
status: z.ZodOptional<z.ZodEnum<["pending", "delivered", "processed", "failed"]>>;
|
|
565
|
+
}, "strip", z.ZodTypeAny, {
|
|
566
|
+
id: string;
|
|
567
|
+
role: "function" | "system" | "user" | "assistant";
|
|
568
|
+
content: string;
|
|
569
|
+
name: string;
|
|
570
|
+
timestamp: Date;
|
|
571
|
+
status?: "pending" | "delivered" | "processed" | "failed" | undefined;
|
|
572
|
+
metadata?: {
|
|
573
|
+
tokenCount?: number | undefined;
|
|
574
|
+
latencyMs?: number | undefined;
|
|
575
|
+
model?: string | undefined;
|
|
576
|
+
taskId?: string | undefined;
|
|
577
|
+
parentId?: string | undefined;
|
|
578
|
+
properties?: Record<string, unknown> | undefined;
|
|
579
|
+
} | undefined;
|
|
580
|
+
contentType?: "text" | "code" | "image" | "function_call" | "function_result" | undefined;
|
|
581
|
+
functionCall?: {
|
|
582
|
+
name: string;
|
|
583
|
+
arguments: Record<string, unknown>;
|
|
584
|
+
result?: unknown;
|
|
585
|
+
} | undefined;
|
|
586
|
+
}, {
|
|
587
|
+
id: string;
|
|
588
|
+
role: "function" | "system" | "user" | "assistant";
|
|
589
|
+
content: string;
|
|
590
|
+
name: string;
|
|
591
|
+
timestamp: Date;
|
|
592
|
+
status?: "pending" | "delivered" | "processed" | "failed" | undefined;
|
|
593
|
+
metadata?: {
|
|
594
|
+
tokenCount?: number | undefined;
|
|
595
|
+
latencyMs?: number | undefined;
|
|
596
|
+
model?: string | undefined;
|
|
597
|
+
taskId?: string | undefined;
|
|
598
|
+
parentId?: string | undefined;
|
|
599
|
+
properties?: Record<string, unknown> | undefined;
|
|
600
|
+
} | undefined;
|
|
601
|
+
contentType?: "text" | "code" | "image" | "function_call" | "function_result" | undefined;
|
|
602
|
+
functionCall?: {
|
|
603
|
+
name: string;
|
|
604
|
+
arguments: Record<string, unknown>;
|
|
605
|
+
result?: unknown;
|
|
606
|
+
} | undefined;
|
|
607
|
+
}>;
|
|
608
|
+
/**
|
|
609
|
+
* Zod schema for ChatParticipant validation
|
|
610
|
+
*/
|
|
611
|
+
export declare const ChatParticipantSchema: z.ZodObject<{
|
|
612
|
+
id: z.ZodString;
|
|
613
|
+
name: z.ZodString;
|
|
614
|
+
type: z.ZodEnum<["human", "assistant", "agent", "tool"]>;
|
|
615
|
+
systemPrompt: z.ZodString;
|
|
616
|
+
status: z.ZodEnum<["active", "idle", "busy", "offline", "error"]>;
|
|
617
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
618
|
+
modelConfig: z.ZodOptional<z.ZodObject<{
|
|
619
|
+
model: z.ZodString;
|
|
620
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
621
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
622
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
623
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
624
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
625
|
+
stopSequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
626
|
+
}, "strip", z.ZodTypeAny, {
|
|
627
|
+
model: string;
|
|
628
|
+
temperature?: number | undefined;
|
|
629
|
+
maxTokens?: number | undefined;
|
|
630
|
+
topP?: number | undefined;
|
|
631
|
+
frequencyPenalty?: number | undefined;
|
|
632
|
+
presencePenalty?: number | undefined;
|
|
633
|
+
stopSequences?: string[] | undefined;
|
|
634
|
+
}, {
|
|
635
|
+
model: string;
|
|
636
|
+
temperature?: number | undefined;
|
|
637
|
+
maxTokens?: number | undefined;
|
|
638
|
+
topP?: number | undefined;
|
|
639
|
+
frequencyPenalty?: number | undefined;
|
|
640
|
+
presencePenalty?: number | undefined;
|
|
641
|
+
stopSequences?: string[] | undefined;
|
|
642
|
+
}>>;
|
|
643
|
+
functions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
644
|
+
name: z.ZodString;
|
|
645
|
+
description: z.ZodString;
|
|
646
|
+
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
647
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
648
|
+
}, "strip", z.ZodTypeAny, {
|
|
649
|
+
name: string;
|
|
650
|
+
description: string;
|
|
651
|
+
parameters: Record<string, unknown>;
|
|
652
|
+
required?: boolean | undefined;
|
|
653
|
+
}, {
|
|
654
|
+
name: string;
|
|
655
|
+
description: string;
|
|
656
|
+
parameters: Record<string, unknown>;
|
|
657
|
+
required?: boolean | undefined;
|
|
658
|
+
}>, "many">>;
|
|
659
|
+
maxConsecutiveReplies: z.ZodOptional<z.ZodNumber>;
|
|
660
|
+
description: z.ZodOptional<z.ZodString>;
|
|
661
|
+
}, "strip", z.ZodTypeAny, {
|
|
662
|
+
id: string;
|
|
663
|
+
status: "active" | "idle" | "busy" | "offline" | "error";
|
|
664
|
+
type: "assistant" | "human" | "agent" | "tool";
|
|
665
|
+
name: string;
|
|
666
|
+
systemPrompt: string;
|
|
667
|
+
capabilities: string[];
|
|
668
|
+
modelConfig?: {
|
|
669
|
+
model: string;
|
|
670
|
+
temperature?: number | undefined;
|
|
671
|
+
maxTokens?: number | undefined;
|
|
672
|
+
topP?: number | undefined;
|
|
673
|
+
frequencyPenalty?: number | undefined;
|
|
674
|
+
presencePenalty?: number | undefined;
|
|
675
|
+
stopSequences?: string[] | undefined;
|
|
676
|
+
} | undefined;
|
|
677
|
+
description?: string | undefined;
|
|
678
|
+
functions?: {
|
|
679
|
+
name: string;
|
|
680
|
+
description: string;
|
|
681
|
+
parameters: Record<string, unknown>;
|
|
682
|
+
required?: boolean | undefined;
|
|
683
|
+
}[] | undefined;
|
|
684
|
+
maxConsecutiveReplies?: number | undefined;
|
|
685
|
+
}, {
|
|
686
|
+
id: string;
|
|
687
|
+
status: "active" | "idle" | "busy" | "offline" | "error";
|
|
688
|
+
type: "assistant" | "human" | "agent" | "tool";
|
|
689
|
+
name: string;
|
|
690
|
+
systemPrompt: string;
|
|
691
|
+
capabilities: string[];
|
|
692
|
+
modelConfig?: {
|
|
693
|
+
model: string;
|
|
694
|
+
temperature?: number | undefined;
|
|
695
|
+
maxTokens?: number | undefined;
|
|
696
|
+
topP?: number | undefined;
|
|
697
|
+
frequencyPenalty?: number | undefined;
|
|
698
|
+
presencePenalty?: number | undefined;
|
|
699
|
+
stopSequences?: string[] | undefined;
|
|
700
|
+
} | undefined;
|
|
701
|
+
description?: string | undefined;
|
|
702
|
+
functions?: {
|
|
703
|
+
name: string;
|
|
704
|
+
description: string;
|
|
705
|
+
parameters: Record<string, unknown>;
|
|
706
|
+
required?: boolean | undefined;
|
|
707
|
+
}[] | undefined;
|
|
708
|
+
maxConsecutiveReplies?: number | undefined;
|
|
709
|
+
}>;
|
|
710
|
+
/**
|
|
711
|
+
* Zod schema for GroupChatConfig validation
|
|
712
|
+
*/
|
|
713
|
+
export declare const GroupChatConfigSchema: z.ZodObject<{
|
|
714
|
+
id: z.ZodOptional<z.ZodString>;
|
|
715
|
+
name: z.ZodString;
|
|
716
|
+
description: z.ZodOptional<z.ZodString>;
|
|
717
|
+
participants: z.ZodArray<z.ZodObject<{
|
|
718
|
+
id: z.ZodString;
|
|
719
|
+
name: z.ZodString;
|
|
720
|
+
type: z.ZodEnum<["human", "assistant", "agent", "tool"]>;
|
|
721
|
+
systemPrompt: z.ZodString;
|
|
722
|
+
status: z.ZodEnum<["active", "idle", "busy", "offline", "error"]>;
|
|
723
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
724
|
+
modelConfig: z.ZodOptional<z.ZodObject<{
|
|
725
|
+
model: z.ZodString;
|
|
726
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
727
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
728
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
729
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
730
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
731
|
+
stopSequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
732
|
+
}, "strip", z.ZodTypeAny, {
|
|
733
|
+
model: string;
|
|
734
|
+
temperature?: number | undefined;
|
|
735
|
+
maxTokens?: number | undefined;
|
|
736
|
+
topP?: number | undefined;
|
|
737
|
+
frequencyPenalty?: number | undefined;
|
|
738
|
+
presencePenalty?: number | undefined;
|
|
739
|
+
stopSequences?: string[] | undefined;
|
|
740
|
+
}, {
|
|
741
|
+
model: string;
|
|
742
|
+
temperature?: number | undefined;
|
|
743
|
+
maxTokens?: number | undefined;
|
|
744
|
+
topP?: number | undefined;
|
|
745
|
+
frequencyPenalty?: number | undefined;
|
|
746
|
+
presencePenalty?: number | undefined;
|
|
747
|
+
stopSequences?: string[] | undefined;
|
|
748
|
+
}>>;
|
|
749
|
+
functions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
750
|
+
name: z.ZodString;
|
|
751
|
+
description: z.ZodString;
|
|
752
|
+
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
753
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
754
|
+
}, "strip", z.ZodTypeAny, {
|
|
755
|
+
name: string;
|
|
756
|
+
description: string;
|
|
757
|
+
parameters: Record<string, unknown>;
|
|
758
|
+
required?: boolean | undefined;
|
|
759
|
+
}, {
|
|
760
|
+
name: string;
|
|
761
|
+
description: string;
|
|
762
|
+
parameters: Record<string, unknown>;
|
|
763
|
+
required?: boolean | undefined;
|
|
764
|
+
}>, "many">>;
|
|
765
|
+
maxConsecutiveReplies: z.ZodOptional<z.ZodNumber>;
|
|
766
|
+
description: z.ZodOptional<z.ZodString>;
|
|
767
|
+
}, "strip", z.ZodTypeAny, {
|
|
768
|
+
id: string;
|
|
769
|
+
status: "active" | "idle" | "busy" | "offline" | "error";
|
|
770
|
+
type: "assistant" | "human" | "agent" | "tool";
|
|
771
|
+
name: string;
|
|
772
|
+
systemPrompt: string;
|
|
773
|
+
capabilities: string[];
|
|
774
|
+
modelConfig?: {
|
|
775
|
+
model: string;
|
|
776
|
+
temperature?: number | undefined;
|
|
777
|
+
maxTokens?: number | undefined;
|
|
778
|
+
topP?: number | undefined;
|
|
779
|
+
frequencyPenalty?: number | undefined;
|
|
780
|
+
presencePenalty?: number | undefined;
|
|
781
|
+
stopSequences?: string[] | undefined;
|
|
782
|
+
} | undefined;
|
|
783
|
+
description?: string | undefined;
|
|
784
|
+
functions?: {
|
|
785
|
+
name: string;
|
|
786
|
+
description: string;
|
|
787
|
+
parameters: Record<string, unknown>;
|
|
788
|
+
required?: boolean | undefined;
|
|
789
|
+
}[] | undefined;
|
|
790
|
+
maxConsecutiveReplies?: number | undefined;
|
|
791
|
+
}, {
|
|
792
|
+
id: string;
|
|
793
|
+
status: "active" | "idle" | "busy" | "offline" | "error";
|
|
794
|
+
type: "assistant" | "human" | "agent" | "tool";
|
|
795
|
+
name: string;
|
|
796
|
+
systemPrompt: string;
|
|
797
|
+
capabilities: string[];
|
|
798
|
+
modelConfig?: {
|
|
799
|
+
model: string;
|
|
800
|
+
temperature?: number | undefined;
|
|
801
|
+
maxTokens?: number | undefined;
|
|
802
|
+
topP?: number | undefined;
|
|
803
|
+
frequencyPenalty?: number | undefined;
|
|
804
|
+
presencePenalty?: number | undefined;
|
|
805
|
+
stopSequences?: string[] | undefined;
|
|
806
|
+
} | undefined;
|
|
807
|
+
description?: string | undefined;
|
|
808
|
+
functions?: {
|
|
809
|
+
name: string;
|
|
810
|
+
description: string;
|
|
811
|
+
parameters: Record<string, unknown>;
|
|
812
|
+
required?: boolean | undefined;
|
|
813
|
+
}[] | undefined;
|
|
814
|
+
maxConsecutiveReplies?: number | undefined;
|
|
815
|
+
}>, "many">;
|
|
816
|
+
speakerSelectionMethod: z.ZodEnum<["round_robin", "random", "llm_selected", "priority", "manual", "auto"]>;
|
|
817
|
+
speakerSelectionConfig: z.ZodOptional<z.ZodObject<{
|
|
818
|
+
selectorModel: z.ZodOptional<z.ZodString>;
|
|
819
|
+
selectorPrompt: z.ZodOptional<z.ZodString>;
|
|
820
|
+
priorityOrder: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
821
|
+
weights: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
822
|
+
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
823
|
+
transitionRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
824
|
+
from: z.ZodString;
|
|
825
|
+
to: z.ZodArray<z.ZodString, "many">;
|
|
826
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
827
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
828
|
+
}, "strip", z.ZodTypeAny, {
|
|
829
|
+
from: string;
|
|
830
|
+
to: string[];
|
|
831
|
+
condition?: string | undefined;
|
|
832
|
+
weight?: number | undefined;
|
|
833
|
+
}, {
|
|
834
|
+
from: string;
|
|
835
|
+
to: string[];
|
|
836
|
+
condition?: string | undefined;
|
|
837
|
+
weight?: number | undefined;
|
|
838
|
+
}>, "many">>;
|
|
839
|
+
allowedTransitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
840
|
+
}, "strip", z.ZodTypeAny, {
|
|
841
|
+
selectorModel?: string | undefined;
|
|
842
|
+
selectorPrompt?: string | undefined;
|
|
843
|
+
priorityOrder?: string[] | undefined;
|
|
844
|
+
weights?: Record<string, number> | undefined;
|
|
845
|
+
maxRetries?: number | undefined;
|
|
846
|
+
transitionRules?: {
|
|
847
|
+
from: string;
|
|
848
|
+
to: string[];
|
|
849
|
+
condition?: string | undefined;
|
|
850
|
+
weight?: number | undefined;
|
|
851
|
+
}[] | undefined;
|
|
852
|
+
allowedTransitions?: Record<string, string[]> | undefined;
|
|
853
|
+
}, {
|
|
854
|
+
selectorModel?: string | undefined;
|
|
855
|
+
selectorPrompt?: string | undefined;
|
|
856
|
+
priorityOrder?: string[] | undefined;
|
|
857
|
+
weights?: Record<string, number> | undefined;
|
|
858
|
+
maxRetries?: number | undefined;
|
|
859
|
+
transitionRules?: {
|
|
860
|
+
from: string;
|
|
861
|
+
to: string[];
|
|
862
|
+
condition?: string | undefined;
|
|
863
|
+
weight?: number | undefined;
|
|
864
|
+
}[] | undefined;
|
|
865
|
+
allowedTransitions?: Record<string, string[]> | undefined;
|
|
866
|
+
}>>;
|
|
867
|
+
maxRounds: z.ZodOptional<z.ZodNumber>;
|
|
868
|
+
maxMessages: z.ZodOptional<z.ZodNumber>;
|
|
869
|
+
terminationConditions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
870
|
+
type: z.ZodEnum<["max_rounds", "max_messages", "keyword", "timeout", "function", "consensus", "custom"]>;
|
|
871
|
+
value: z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodObject<{
|
|
872
|
+
threshold: z.ZodNumber;
|
|
873
|
+
agreementKeywords: z.ZodArray<z.ZodString, "many">;
|
|
874
|
+
disagreementKeywords: z.ZodArray<z.ZodString, "many">;
|
|
875
|
+
minParticipants: z.ZodOptional<z.ZodNumber>;
|
|
876
|
+
windowSize: z.ZodOptional<z.ZodNumber>;
|
|
877
|
+
}, "strip", z.ZodTypeAny, {
|
|
878
|
+
threshold: number;
|
|
879
|
+
agreementKeywords: string[];
|
|
880
|
+
disagreementKeywords: string[];
|
|
881
|
+
minParticipants?: number | undefined;
|
|
882
|
+
windowSize?: number | undefined;
|
|
883
|
+
}, {
|
|
884
|
+
threshold: number;
|
|
885
|
+
agreementKeywords: string[];
|
|
886
|
+
disagreementKeywords: string[];
|
|
887
|
+
minParticipants?: number | undefined;
|
|
888
|
+
windowSize?: number | undefined;
|
|
889
|
+
}>, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>;
|
|
890
|
+
description: z.ZodOptional<z.ZodString>;
|
|
891
|
+
}, "strip", z.ZodTypeAny, {
|
|
892
|
+
value: string | number | string[] | {
|
|
893
|
+
threshold: number;
|
|
894
|
+
agreementKeywords: string[];
|
|
895
|
+
disagreementKeywords: string[];
|
|
896
|
+
minParticipants?: number | undefined;
|
|
897
|
+
windowSize?: number | undefined;
|
|
898
|
+
} | ((...args: unknown[]) => unknown);
|
|
899
|
+
type: "function" | "max_rounds" | "max_messages" | "keyword" | "timeout" | "consensus" | "custom";
|
|
900
|
+
description?: string | undefined;
|
|
901
|
+
}, {
|
|
902
|
+
value: string | number | string[] | {
|
|
903
|
+
threshold: number;
|
|
904
|
+
agreementKeywords: string[];
|
|
905
|
+
disagreementKeywords: string[];
|
|
906
|
+
minParticipants?: number | undefined;
|
|
907
|
+
windowSize?: number | undefined;
|
|
908
|
+
} | ((...args: unknown[]) => unknown);
|
|
909
|
+
type: "function" | "max_rounds" | "max_messages" | "keyword" | "timeout" | "consensus" | "custom";
|
|
910
|
+
description?: string | undefined;
|
|
911
|
+
}>, "many">>;
|
|
912
|
+
allowNestedChats: z.ZodOptional<z.ZodBoolean>;
|
|
913
|
+
nestedChatConfigs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
914
|
+
id: z.ZodString;
|
|
915
|
+
name: z.ZodString;
|
|
916
|
+
trigger: z.ZodObject<{
|
|
917
|
+
type: z.ZodEnum<["keyword", "participant", "condition", "manual"]>;
|
|
918
|
+
value: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>;
|
|
919
|
+
description: z.ZodOptional<z.ZodString>;
|
|
920
|
+
}, "strip", z.ZodTypeAny, {
|
|
921
|
+
value: string | string[] | ((...args: unknown[]) => unknown);
|
|
922
|
+
type: "manual" | "keyword" | "participant" | "condition";
|
|
923
|
+
description?: string | undefined;
|
|
924
|
+
}, {
|
|
925
|
+
value: string | string[] | ((...args: unknown[]) => unknown);
|
|
926
|
+
type: "manual" | "keyword" | "participant" | "condition";
|
|
927
|
+
description?: string | undefined;
|
|
928
|
+
}>;
|
|
929
|
+
participants: z.ZodArray<z.ZodString, "many">;
|
|
930
|
+
maxRounds: z.ZodOptional<z.ZodNumber>;
|
|
931
|
+
summaryMethod: z.ZodOptional<z.ZodEnum<["last", "llm", "reflection", "custom"]>>;
|
|
932
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
933
|
+
shareContext: z.ZodOptional<z.ZodBoolean>;
|
|
934
|
+
}, "strip", z.ZodTypeAny, {
|
|
935
|
+
id: string;
|
|
936
|
+
name: string;
|
|
937
|
+
participants: string[];
|
|
938
|
+
trigger: {
|
|
939
|
+
value: string | string[] | ((...args: unknown[]) => unknown);
|
|
940
|
+
type: "manual" | "keyword" | "participant" | "condition";
|
|
941
|
+
description?: string | undefined;
|
|
942
|
+
};
|
|
943
|
+
maxRounds?: number | undefined;
|
|
944
|
+
summaryMethod?: "custom" | "last" | "llm" | "reflection" | undefined;
|
|
945
|
+
prompt?: string | undefined;
|
|
946
|
+
shareContext?: boolean | undefined;
|
|
947
|
+
}, {
|
|
948
|
+
id: string;
|
|
949
|
+
name: string;
|
|
950
|
+
participants: string[];
|
|
951
|
+
trigger: {
|
|
952
|
+
value: string | string[] | ((...args: unknown[]) => unknown);
|
|
953
|
+
type: "manual" | "keyword" | "participant" | "condition";
|
|
954
|
+
description?: string | undefined;
|
|
955
|
+
};
|
|
956
|
+
maxRounds?: number | undefined;
|
|
957
|
+
summaryMethod?: "custom" | "last" | "llm" | "reflection" | undefined;
|
|
958
|
+
prompt?: string | undefined;
|
|
959
|
+
shareContext?: boolean | undefined;
|
|
960
|
+
}>, "many">>;
|
|
961
|
+
adminName: z.ZodOptional<z.ZodString>;
|
|
962
|
+
enableHistory: z.ZodOptional<z.ZodBoolean>;
|
|
963
|
+
maxHistoryLength: z.ZodOptional<z.ZodNumber>;
|
|
964
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
965
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
966
|
+
}, "strip", z.ZodTypeAny, {
|
|
967
|
+
name: string;
|
|
968
|
+
participants: {
|
|
969
|
+
id: string;
|
|
970
|
+
status: "active" | "idle" | "busy" | "offline" | "error";
|
|
971
|
+
type: "assistant" | "human" | "agent" | "tool";
|
|
972
|
+
name: string;
|
|
973
|
+
systemPrompt: string;
|
|
974
|
+
capabilities: string[];
|
|
975
|
+
modelConfig?: {
|
|
976
|
+
model: string;
|
|
977
|
+
temperature?: number | undefined;
|
|
978
|
+
maxTokens?: number | undefined;
|
|
979
|
+
topP?: number | undefined;
|
|
980
|
+
frequencyPenalty?: number | undefined;
|
|
981
|
+
presencePenalty?: number | undefined;
|
|
982
|
+
stopSequences?: string[] | undefined;
|
|
983
|
+
} | undefined;
|
|
984
|
+
description?: string | undefined;
|
|
985
|
+
functions?: {
|
|
986
|
+
name: string;
|
|
987
|
+
description: string;
|
|
988
|
+
parameters: Record<string, unknown>;
|
|
989
|
+
required?: boolean | undefined;
|
|
990
|
+
}[] | undefined;
|
|
991
|
+
maxConsecutiveReplies?: number | undefined;
|
|
992
|
+
}[];
|
|
993
|
+
speakerSelectionMethod: "round_robin" | "random" | "llm_selected" | "priority" | "manual" | "auto";
|
|
994
|
+
id?: string | undefined;
|
|
995
|
+
metadata?: Record<string, unknown> | undefined;
|
|
996
|
+
description?: string | undefined;
|
|
997
|
+
speakerSelectionConfig?: {
|
|
998
|
+
selectorModel?: string | undefined;
|
|
999
|
+
selectorPrompt?: string | undefined;
|
|
1000
|
+
priorityOrder?: string[] | undefined;
|
|
1001
|
+
weights?: Record<string, number> | undefined;
|
|
1002
|
+
maxRetries?: number | undefined;
|
|
1003
|
+
transitionRules?: {
|
|
1004
|
+
from: string;
|
|
1005
|
+
to: string[];
|
|
1006
|
+
condition?: string | undefined;
|
|
1007
|
+
weight?: number | undefined;
|
|
1008
|
+
}[] | undefined;
|
|
1009
|
+
allowedTransitions?: Record<string, string[]> | undefined;
|
|
1010
|
+
} | undefined;
|
|
1011
|
+
maxRounds?: number | undefined;
|
|
1012
|
+
maxMessages?: number | undefined;
|
|
1013
|
+
terminationConditions?: {
|
|
1014
|
+
value: string | number | string[] | {
|
|
1015
|
+
threshold: number;
|
|
1016
|
+
agreementKeywords: string[];
|
|
1017
|
+
disagreementKeywords: string[];
|
|
1018
|
+
minParticipants?: number | undefined;
|
|
1019
|
+
windowSize?: number | undefined;
|
|
1020
|
+
} | ((...args: unknown[]) => unknown);
|
|
1021
|
+
type: "function" | "max_rounds" | "max_messages" | "keyword" | "timeout" | "consensus" | "custom";
|
|
1022
|
+
description?: string | undefined;
|
|
1023
|
+
}[] | undefined;
|
|
1024
|
+
allowNestedChats?: boolean | undefined;
|
|
1025
|
+
nestedChatConfigs?: {
|
|
1026
|
+
id: string;
|
|
1027
|
+
name: string;
|
|
1028
|
+
participants: string[];
|
|
1029
|
+
trigger: {
|
|
1030
|
+
value: string | string[] | ((...args: unknown[]) => unknown);
|
|
1031
|
+
type: "manual" | "keyword" | "participant" | "condition";
|
|
1032
|
+
description?: string | undefined;
|
|
1033
|
+
};
|
|
1034
|
+
maxRounds?: number | undefined;
|
|
1035
|
+
summaryMethod?: "custom" | "last" | "llm" | "reflection" | undefined;
|
|
1036
|
+
prompt?: string | undefined;
|
|
1037
|
+
shareContext?: boolean | undefined;
|
|
1038
|
+
}[] | undefined;
|
|
1039
|
+
adminName?: string | undefined;
|
|
1040
|
+
enableHistory?: boolean | undefined;
|
|
1041
|
+
maxHistoryLength?: number | undefined;
|
|
1042
|
+
timeoutMs?: number | undefined;
|
|
1043
|
+
}, {
|
|
1044
|
+
name: string;
|
|
1045
|
+
participants: {
|
|
1046
|
+
id: string;
|
|
1047
|
+
status: "active" | "idle" | "busy" | "offline" | "error";
|
|
1048
|
+
type: "assistant" | "human" | "agent" | "tool";
|
|
1049
|
+
name: string;
|
|
1050
|
+
systemPrompt: string;
|
|
1051
|
+
capabilities: string[];
|
|
1052
|
+
modelConfig?: {
|
|
1053
|
+
model: string;
|
|
1054
|
+
temperature?: number | undefined;
|
|
1055
|
+
maxTokens?: number | undefined;
|
|
1056
|
+
topP?: number | undefined;
|
|
1057
|
+
frequencyPenalty?: number | undefined;
|
|
1058
|
+
presencePenalty?: number | undefined;
|
|
1059
|
+
stopSequences?: string[] | undefined;
|
|
1060
|
+
} | undefined;
|
|
1061
|
+
description?: string | undefined;
|
|
1062
|
+
functions?: {
|
|
1063
|
+
name: string;
|
|
1064
|
+
description: string;
|
|
1065
|
+
parameters: Record<string, unknown>;
|
|
1066
|
+
required?: boolean | undefined;
|
|
1067
|
+
}[] | undefined;
|
|
1068
|
+
maxConsecutiveReplies?: number | undefined;
|
|
1069
|
+
}[];
|
|
1070
|
+
speakerSelectionMethod: "round_robin" | "random" | "llm_selected" | "priority" | "manual" | "auto";
|
|
1071
|
+
id?: string | undefined;
|
|
1072
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1073
|
+
description?: string | undefined;
|
|
1074
|
+
speakerSelectionConfig?: {
|
|
1075
|
+
selectorModel?: string | undefined;
|
|
1076
|
+
selectorPrompt?: string | undefined;
|
|
1077
|
+
priorityOrder?: string[] | undefined;
|
|
1078
|
+
weights?: Record<string, number> | undefined;
|
|
1079
|
+
maxRetries?: number | undefined;
|
|
1080
|
+
transitionRules?: {
|
|
1081
|
+
from: string;
|
|
1082
|
+
to: string[];
|
|
1083
|
+
condition?: string | undefined;
|
|
1084
|
+
weight?: number | undefined;
|
|
1085
|
+
}[] | undefined;
|
|
1086
|
+
allowedTransitions?: Record<string, string[]> | undefined;
|
|
1087
|
+
} | undefined;
|
|
1088
|
+
maxRounds?: number | undefined;
|
|
1089
|
+
maxMessages?: number | undefined;
|
|
1090
|
+
terminationConditions?: {
|
|
1091
|
+
value: string | number | string[] | {
|
|
1092
|
+
threshold: number;
|
|
1093
|
+
agreementKeywords: string[];
|
|
1094
|
+
disagreementKeywords: string[];
|
|
1095
|
+
minParticipants?: number | undefined;
|
|
1096
|
+
windowSize?: number | undefined;
|
|
1097
|
+
} | ((...args: unknown[]) => unknown);
|
|
1098
|
+
type: "function" | "max_rounds" | "max_messages" | "keyword" | "timeout" | "consensus" | "custom";
|
|
1099
|
+
description?: string | undefined;
|
|
1100
|
+
}[] | undefined;
|
|
1101
|
+
allowNestedChats?: boolean | undefined;
|
|
1102
|
+
nestedChatConfigs?: {
|
|
1103
|
+
id: string;
|
|
1104
|
+
name: string;
|
|
1105
|
+
participants: string[];
|
|
1106
|
+
trigger: {
|
|
1107
|
+
value: string | string[] | ((...args: unknown[]) => unknown);
|
|
1108
|
+
type: "manual" | "keyword" | "participant" | "condition";
|
|
1109
|
+
description?: string | undefined;
|
|
1110
|
+
};
|
|
1111
|
+
maxRounds?: number | undefined;
|
|
1112
|
+
summaryMethod?: "custom" | "last" | "llm" | "reflection" | undefined;
|
|
1113
|
+
prompt?: string | undefined;
|
|
1114
|
+
shareContext?: boolean | undefined;
|
|
1115
|
+
}[] | undefined;
|
|
1116
|
+
adminName?: string | undefined;
|
|
1117
|
+
enableHistory?: boolean | undefined;
|
|
1118
|
+
maxHistoryLength?: number | undefined;
|
|
1119
|
+
timeoutMs?: number | undefined;
|
|
1120
|
+
}>;
|
|
1121
|
+
/**
|
|
1122
|
+
* Zod schema for ConsensusConfig validation
|
|
1123
|
+
*/
|
|
1124
|
+
export declare const ConsensusConfigSchema: z.ZodObject<{
|
|
1125
|
+
threshold: z.ZodNumber;
|
|
1126
|
+
agreementKeywords: z.ZodArray<z.ZodString, "many">;
|
|
1127
|
+
disagreementKeywords: z.ZodArray<z.ZodString, "many">;
|
|
1128
|
+
minParticipants: z.ZodOptional<z.ZodNumber>;
|
|
1129
|
+
windowSize: z.ZodOptional<z.ZodNumber>;
|
|
1130
|
+
}, "strip", z.ZodTypeAny, {
|
|
1131
|
+
threshold: number;
|
|
1132
|
+
agreementKeywords: string[];
|
|
1133
|
+
disagreementKeywords: string[];
|
|
1134
|
+
minParticipants?: number | undefined;
|
|
1135
|
+
windowSize?: number | undefined;
|
|
1136
|
+
}, {
|
|
1137
|
+
threshold: number;
|
|
1138
|
+
agreementKeywords: string[];
|
|
1139
|
+
disagreementKeywords: string[];
|
|
1140
|
+
minParticipants?: number | undefined;
|
|
1141
|
+
windowSize?: number | undefined;
|
|
1142
|
+
}>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Zod schema for TerminationConditionValue validation
|
|
1145
|
+
*/
|
|
1146
|
+
export declare const TerminationConditionValueSchema: z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodObject<{
|
|
1147
|
+
threshold: z.ZodNumber;
|
|
1148
|
+
agreementKeywords: z.ZodArray<z.ZodString, "many">;
|
|
1149
|
+
disagreementKeywords: z.ZodArray<z.ZodString, "many">;
|
|
1150
|
+
minParticipants: z.ZodOptional<z.ZodNumber>;
|
|
1151
|
+
windowSize: z.ZodOptional<z.ZodNumber>;
|
|
1152
|
+
}, "strip", z.ZodTypeAny, {
|
|
1153
|
+
threshold: number;
|
|
1154
|
+
agreementKeywords: string[];
|
|
1155
|
+
disagreementKeywords: string[];
|
|
1156
|
+
minParticipants?: number | undefined;
|
|
1157
|
+
windowSize?: number | undefined;
|
|
1158
|
+
}, {
|
|
1159
|
+
threshold: number;
|
|
1160
|
+
agreementKeywords: string[];
|
|
1161
|
+
disagreementKeywords: string[];
|
|
1162
|
+
minParticipants?: number | undefined;
|
|
1163
|
+
windowSize?: number | undefined;
|
|
1164
|
+
}>, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>;
|
|
1165
|
+
/**
|
|
1166
|
+
* Zod schema for TerminationCondition validation
|
|
1167
|
+
*/
|
|
1168
|
+
export declare const TerminationConditionSchema: z.ZodObject<{
|
|
1169
|
+
type: z.ZodEnum<["max_rounds", "max_messages", "keyword", "timeout", "function", "consensus", "custom"]>;
|
|
1170
|
+
value: z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodObject<{
|
|
1171
|
+
threshold: z.ZodNumber;
|
|
1172
|
+
agreementKeywords: z.ZodArray<z.ZodString, "many">;
|
|
1173
|
+
disagreementKeywords: z.ZodArray<z.ZodString, "many">;
|
|
1174
|
+
minParticipants: z.ZodOptional<z.ZodNumber>;
|
|
1175
|
+
windowSize: z.ZodOptional<z.ZodNumber>;
|
|
1176
|
+
}, "strip", z.ZodTypeAny, {
|
|
1177
|
+
threshold: number;
|
|
1178
|
+
agreementKeywords: string[];
|
|
1179
|
+
disagreementKeywords: string[];
|
|
1180
|
+
minParticipants?: number | undefined;
|
|
1181
|
+
windowSize?: number | undefined;
|
|
1182
|
+
}, {
|
|
1183
|
+
threshold: number;
|
|
1184
|
+
agreementKeywords: string[];
|
|
1185
|
+
disagreementKeywords: string[];
|
|
1186
|
+
minParticipants?: number | undefined;
|
|
1187
|
+
windowSize?: number | undefined;
|
|
1188
|
+
}>, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>;
|
|
1189
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1190
|
+
}, "strip", z.ZodTypeAny, {
|
|
1191
|
+
value: string | number | string[] | ((...args: unknown[]) => unknown) | {
|
|
1192
|
+
threshold: number;
|
|
1193
|
+
agreementKeywords: string[];
|
|
1194
|
+
disagreementKeywords: string[];
|
|
1195
|
+
minParticipants?: number | undefined;
|
|
1196
|
+
windowSize?: number | undefined;
|
|
1197
|
+
};
|
|
1198
|
+
type: "function" | "max_rounds" | "max_messages" | "keyword" | "timeout" | "consensus" | "custom";
|
|
1199
|
+
description?: string | undefined;
|
|
1200
|
+
}, {
|
|
1201
|
+
value: string | number | string[] | ((...args: unknown[]) => unknown) | {
|
|
1202
|
+
threshold: number;
|
|
1203
|
+
agreementKeywords: string[];
|
|
1204
|
+
disagreementKeywords: string[];
|
|
1205
|
+
minParticipants?: number | undefined;
|
|
1206
|
+
windowSize?: number | undefined;
|
|
1207
|
+
};
|
|
1208
|
+
type: "function" | "max_rounds" | "max_messages" | "keyword" | "timeout" | "consensus" | "custom";
|
|
1209
|
+
description?: string | undefined;
|
|
1210
|
+
}>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Options for creating a new message
|
|
1213
|
+
*/
|
|
1214
|
+
export interface CreateMessageOptions {
|
|
1215
|
+
role: MessageRole;
|
|
1216
|
+
content: string;
|
|
1217
|
+
name: string;
|
|
1218
|
+
contentType?: ContentType;
|
|
1219
|
+
functionCall?: FunctionCall;
|
|
1220
|
+
metadata?: Partial<MessageMetadata>;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Options for adding a participant
|
|
1224
|
+
*/
|
|
1225
|
+
export interface AddParticipantOptions {
|
|
1226
|
+
name: string;
|
|
1227
|
+
type: ParticipantType;
|
|
1228
|
+
systemPrompt: string;
|
|
1229
|
+
capabilities?: string[];
|
|
1230
|
+
modelConfig?: ModelConfig;
|
|
1231
|
+
functions?: FunctionDefinition[];
|
|
1232
|
+
maxConsecutiveReplies?: number;
|
|
1233
|
+
description?: string;
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Options for starting a chat
|
|
1237
|
+
*/
|
|
1238
|
+
export interface StartChatOptions {
|
|
1239
|
+
/** Initial message to start the chat */
|
|
1240
|
+
initialMessage?: string;
|
|
1241
|
+
/** Initial sender name */
|
|
1242
|
+
initialSender?: string;
|
|
1243
|
+
/** Initial context state */
|
|
1244
|
+
initialState?: Record<string, unknown>;
|
|
1245
|
+
/** Skip first speaker selection */
|
|
1246
|
+
skipInitialSelection?: boolean;
|
|
1247
|
+
}
|
|
1248
|
+
//# sourceMappingURL=types.d.ts.map
|