@wundr.io/autogen-orchestrator 1.0.12 → 1.0.15

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.
@@ -0,0 +1,321 @@
1
+ /**
2
+ * GroupChatManager - Core orchestration for AutoGen-style multi-agent conversations
3
+ *
4
+ * Implements conversational patterns for coordinating multiple AI agents in a
5
+ * group chat setting with configurable speaker selection and termination conditions.
6
+ */
7
+ import { EventEmitter } from 'eventemitter3';
8
+ import type { NestedChatResult } from './nested-chat';
9
+ import type { Message, ChatParticipant, ChatContext, ChatResult, ChatStatus, ChatMetrics, ChatError, GroupChatConfig, TerminationCondition, NestedChatConfig, CreateMessageOptions, AddParticipantOptions, StartChatOptions, ParticipantStatus } from './types';
10
+ /**
11
+ * Events emitted by the GroupChatManager
12
+ */
13
+ export interface GroupChatEvents {
14
+ 'chat:started': (data: {
15
+ chatId: string;
16
+ config: GroupChatConfig;
17
+ }) => void;
18
+ 'chat:ended': (data: {
19
+ chatId: string;
20
+ result: ChatResult;
21
+ }) => void;
22
+ 'chat:error': (data: {
23
+ chatId: string;
24
+ error: ChatError;
25
+ }) => void;
26
+ 'message:sent': (data: {
27
+ chatId: string;
28
+ message: Message;
29
+ }) => void;
30
+ 'message:received': (data: {
31
+ chatId: string;
32
+ message: Message;
33
+ }) => void;
34
+ 'speaker:selected': (data: {
35
+ chatId: string;
36
+ speaker: string;
37
+ reason?: string;
38
+ }) => void;
39
+ 'round:started': (data: {
40
+ chatId: string;
41
+ round: number;
42
+ }) => void;
43
+ 'round:ended': (data: {
44
+ chatId: string;
45
+ round: number;
46
+ }) => void;
47
+ 'termination:triggered': (data: {
48
+ chatId: string;
49
+ reason: string;
50
+ }) => void;
51
+ 'nested:started': (data: {
52
+ chatId: string;
53
+ nestedChatId: string;
54
+ }) => void;
55
+ 'nested:ended': (data: {
56
+ chatId: string;
57
+ nestedChatId: string;
58
+ result: NestedChatResult;
59
+ }) => void;
60
+ }
61
+ /**
62
+ * Response generator function type
63
+ * Used to generate responses for participants
64
+ */
65
+ export type ResponseGenerator = (participant: ChatParticipant, messages: Message[], context: ChatContext) => Promise<string>;
66
+ /**
67
+ * GroupChatManager - Orchestrates multi-agent conversations
68
+ */
69
+ export declare class GroupChatManager extends EventEmitter<GroupChatEvents> {
70
+ private config;
71
+ private participants;
72
+ private messages;
73
+ private context;
74
+ private status;
75
+ private startTime?;
76
+ private endTime?;
77
+ private chatId;
78
+ private speakerManager;
79
+ private terminationManager;
80
+ private nestedChatManager;
81
+ private responseGenerator?;
82
+ private metrics;
83
+ private nestedResults;
84
+ /**
85
+ * Create a new GroupChatManager
86
+ * @param config - Group chat configuration
87
+ */
88
+ constructor(config: GroupChatConfig);
89
+ /**
90
+ * Setup event forwarding from nested chat manager
91
+ */
92
+ private setupNestedChatEvents;
93
+ /**
94
+ * Set the response generator function
95
+ * @param generator - Function to generate participant responses
96
+ */
97
+ setResponseGenerator(generator: ResponseGenerator): void;
98
+ /**
99
+ * Start the group chat
100
+ * @param options - Optional start options
101
+ * @returns Chat result when completed
102
+ */
103
+ start(options?: StartChatOptions): Promise<ChatResult>;
104
+ /**
105
+ * Run the main conversation loop
106
+ * @param options - Start options
107
+ * @returns Chat result
108
+ */
109
+ private runConversationLoop;
110
+ /**
111
+ * Generate a response for a participant
112
+ * @param participant - Participant to generate response for
113
+ * @returns Generated response content
114
+ */
115
+ private generateResponse;
116
+ /**
117
+ * Update metrics after a response
118
+ * @param participantName - Name of the participant
119
+ * @param latencyMs - Response latency
120
+ * @param tokenEstimate - Estimated token count
121
+ */
122
+ private updateMetrics;
123
+ /**
124
+ * Check if a message triggers a nested chat
125
+ * @param message - Message to check
126
+ */
127
+ private checkNestedChatTriggers;
128
+ /**
129
+ * Run a nested chat session
130
+ * @param config - Nested chat configuration
131
+ * @param triggerMessageId - ID of the triggering message
132
+ */
133
+ private runNestedChat;
134
+ /**
135
+ * Add a message to the chat
136
+ * @param options - Message options
137
+ * @returns Created message
138
+ */
139
+ addMessage(options: CreateMessageOptions): Promise<Message>;
140
+ /**
141
+ * Add a participant to the chat
142
+ * @param options - Participant options
143
+ * @returns Created participant
144
+ */
145
+ addParticipant(options: AddParticipantOptions): ChatParticipant;
146
+ /**
147
+ * Remove a participant from the chat
148
+ * @param name - Participant name
149
+ */
150
+ removeParticipant(name: string): void;
151
+ /**
152
+ * Update a participant's status
153
+ * @param name - Participant name
154
+ * @param status - New status
155
+ */
156
+ updateParticipantStatus(name: string, status: ParticipantStatus): void;
157
+ /**
158
+ * Add a termination condition
159
+ * @param condition - Condition to add
160
+ */
161
+ addTerminationCondition(condition: TerminationCondition): void;
162
+ /**
163
+ * Add a nested chat configuration
164
+ * @param config - Nested chat config
165
+ */
166
+ addNestedChatConfig(config: NestedChatConfig): void;
167
+ /**
168
+ * Pause the chat
169
+ */
170
+ pause(): void;
171
+ /**
172
+ * Resume the chat
173
+ */
174
+ resume(): void;
175
+ /**
176
+ * Stop the chat
177
+ * @param reason - Reason for stopping
178
+ * @returns Chat result
179
+ */
180
+ stop(reason?: string): Promise<ChatResult>;
181
+ /**
182
+ * End the chat and produce a result
183
+ * @param status - Final status
184
+ * @param reason - Termination reason
185
+ * @returns Chat result
186
+ */
187
+ private endChat;
188
+ /**
189
+ * Handle an error during chat execution
190
+ * @param error - Error that occurred
191
+ * @returns Chat result with error
192
+ */
193
+ private handleError;
194
+ /**
195
+ * Generate a summary of the conversation
196
+ * @returns Summary string
197
+ */
198
+ private generateSummary;
199
+ /**
200
+ * Emit a chat event
201
+ * @param type - Event type
202
+ * @param data - Event data typed based on event type
203
+ */
204
+ private emitEvent;
205
+ /**
206
+ * Get the current chat status
207
+ * @returns Current status
208
+ */
209
+ getStatus(): ChatStatus;
210
+ /**
211
+ * Get the chat ID
212
+ * @returns Chat ID
213
+ */
214
+ getChatId(): string;
215
+ /**
216
+ * Get all messages
217
+ * @returns Message array
218
+ */
219
+ getMessages(): Message[];
220
+ /**
221
+ * Get all participants
222
+ * @returns Participant array
223
+ */
224
+ getParticipants(): ChatParticipant[];
225
+ /**
226
+ * Get the current context
227
+ * @returns Chat context
228
+ */
229
+ getContext(): ChatContext;
230
+ /**
231
+ * Get current metrics
232
+ * @returns Chat metrics
233
+ */
234
+ getMetrics(): ChatMetrics;
235
+ /**
236
+ * Update context state
237
+ * @param key - State key
238
+ * @param value - State value (typed for common use cases)
239
+ */
240
+ updateState<T extends string | number | boolean | object | null>(key: string, value: T): void;
241
+ /**
242
+ * Get context state value
243
+ * @param key - State key
244
+ * @returns State value
245
+ */
246
+ getState<T>(key: string): T | undefined;
247
+ }
248
+ /**
249
+ * Builder for creating GroupChatManager instances
250
+ */
251
+ export declare class GroupChatBuilder {
252
+ private config;
253
+ /**
254
+ * Set the chat name
255
+ * @param name - Chat name
256
+ */
257
+ withName(name: string): this;
258
+ /**
259
+ * Set the chat description
260
+ * @param description - Chat description
261
+ */
262
+ withDescription(description: string): this;
263
+ /**
264
+ * Add a participant
265
+ * @param participant - Participant to add
266
+ */
267
+ withParticipant(participant: ChatParticipant): this;
268
+ /**
269
+ * Set the speaker selection method
270
+ * @param method - Selection method
271
+ */
272
+ withSpeakerSelection(method: GroupChatConfig['speakerSelectionMethod']): this;
273
+ /**
274
+ * Set maximum rounds
275
+ * @param maxRounds - Maximum rounds
276
+ */
277
+ withMaxRounds(maxRounds: number): this;
278
+ /**
279
+ * Set maximum messages
280
+ * @param maxMessages - Maximum messages
281
+ */
282
+ withMaxMessages(maxMessages: number): this;
283
+ /**
284
+ * Add a termination condition
285
+ * @param condition - Termination condition
286
+ */
287
+ withTerminationCondition(condition: TerminationCondition): this;
288
+ /**
289
+ * Enable nested chats
290
+ */
291
+ withNestedChats(): this;
292
+ /**
293
+ * Add a nested chat configuration
294
+ * @param config - Nested chat config
295
+ */
296
+ withNestedChatConfig(config: NestedChatConfig): this;
297
+ /**
298
+ * Set the admin name
299
+ * @param name - Admin name
300
+ */
301
+ withAdmin(name: string): this;
302
+ /**
303
+ * Set timeout
304
+ * @param timeoutMs - Timeout in milliseconds
305
+ */
306
+ withTimeout(timeoutMs: number): this;
307
+ /**
308
+ * Build the GroupChatManager
309
+ * @returns Configured GroupChatManager
310
+ */
311
+ build(): GroupChatManager;
312
+ }
313
+ /**
314
+ * Create a simple participant configuration
315
+ * @param name - Participant name
316
+ * @param systemPrompt - System prompt
317
+ * @param capabilities - Participant capabilities
318
+ * @returns Participant configuration
319
+ */
320
+ export declare function createParticipant(name: string, systemPrompt: string, capabilities?: string[]): ChatParticipant;
321
+ //# sourceMappingURL=group-chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-chat.d.ts","sourceRoot":"","sources":["../src/group-chat.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAQ7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,EAIT,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,eAAe,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5E,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,KAAK,IAAI,CAAC;IACrE,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,cAAc,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;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