@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.
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Termination Condition Handlers for AutoGen-style Group Chat
3
+ *
4
+ * Implements various termination conditions for multi-agent conversations
5
+ * including keyword-based, round-based, timeout, and custom evaluators.
6
+ */
7
+ import type { Message, ChatParticipant, ChatContext, TerminationCondition, TerminationConditionType, TerminationResult, TerminationEvaluator, ConsensusConfigType } from './types';
8
+ /**
9
+ * Handler interface for termination conditions
10
+ */
11
+ export interface TerminationHandler {
12
+ /**
13
+ * Evaluate whether the termination condition is met
14
+ * @param messages - Conversation messages
15
+ * @param participants - Chat participants
16
+ * @param context - Current chat context
17
+ * @returns Termination result
18
+ */
19
+ evaluate(messages: Message[], participants: ChatParticipant[], context: ChatContext): Promise<TerminationResult>;
20
+ }
21
+ /**
22
+ * Factory function to create termination handlers
23
+ * @param condition - Termination condition configuration
24
+ * @returns Appropriate termination handler
25
+ */
26
+ export declare function createTerminationHandler(condition: TerminationCondition): TerminationHandler;
27
+ /**
28
+ * Handler for maximum rounds termination
29
+ */
30
+ export declare class MaxRoundsHandler implements TerminationHandler {
31
+ private maxRounds;
32
+ /**
33
+ * Create a max rounds handler
34
+ * @param maxRounds - Maximum number of rounds allowed
35
+ */
36
+ constructor(maxRounds: number);
37
+ /**
38
+ * Evaluate if max rounds has been reached
39
+ * @param messages - Conversation messages
40
+ * @param participants - Chat participants
41
+ * @param context - Current chat context
42
+ * @returns Termination result
43
+ */
44
+ evaluate(_messages: Message[], _participants: ChatParticipant[], context: ChatContext): Promise<TerminationResult>;
45
+ }
46
+ /**
47
+ * Handler for maximum messages termination
48
+ */
49
+ export declare class MaxMessagesHandler implements TerminationHandler {
50
+ private maxMessages;
51
+ /**
52
+ * Create a max messages handler
53
+ * @param maxMessages - Maximum number of messages allowed
54
+ */
55
+ constructor(maxMessages: number);
56
+ /**
57
+ * Evaluate if max messages has been reached
58
+ * @param messages - Conversation messages
59
+ * @param participants - Chat participants
60
+ * @param context - Current chat context
61
+ * @returns Termination result
62
+ */
63
+ evaluate(messages: Message[], _participants: ChatParticipant[], _context: ChatContext): Promise<TerminationResult>;
64
+ }
65
+ /**
66
+ * Handler for keyword-based termination
67
+ */
68
+ export declare class KeywordHandler implements TerminationHandler {
69
+ private keywords;
70
+ private caseSensitive;
71
+ private requireAll;
72
+ /**
73
+ * Create a keyword handler
74
+ * @param keywords - Keywords to detect
75
+ * @param caseSensitive - Whether matching is case-sensitive
76
+ * @param requireAll - Whether all keywords must be present
77
+ */
78
+ constructor(keywords: string | string[], caseSensitive?: boolean, requireAll?: boolean);
79
+ /**
80
+ * Evaluate if termination keywords are found
81
+ * @param messages - Conversation messages
82
+ * @param participants - Chat participants
83
+ * @param context - Current chat context
84
+ * @returns Termination result
85
+ */
86
+ evaluate(messages: Message[], _participants: ChatParticipant[], _context: ChatContext): Promise<TerminationResult>;
87
+ }
88
+ /**
89
+ * Handler for timeout-based termination
90
+ */
91
+ export declare class TimeoutHandler implements TerminationHandler {
92
+ private timeoutMs;
93
+ /**
94
+ * Create a timeout handler
95
+ * @param timeoutMs - Timeout duration in milliseconds
96
+ */
97
+ constructor(timeoutMs: number);
98
+ /**
99
+ * Evaluate if timeout has been reached
100
+ * @param messages - Conversation messages
101
+ * @param participants - Chat participants
102
+ * @param context - Current chat context
103
+ * @returns Termination result
104
+ */
105
+ evaluate(_messages: Message[], _participants: ChatParticipant[], context: ChatContext): Promise<TerminationResult>;
106
+ }
107
+ /**
108
+ * Handler for function-based termination
109
+ */
110
+ export declare class FunctionHandler implements TerminationHandler {
111
+ private evaluator;
112
+ /**
113
+ * Create a function handler
114
+ * @param evaluator - Custom evaluation function
115
+ */
116
+ constructor(evaluator: TerminationEvaluator);
117
+ /**
118
+ * Evaluate using the custom function
119
+ * @param messages - Conversation messages
120
+ * @param participants - Chat participants
121
+ * @param context - Current chat context
122
+ * @returns Termination result
123
+ */
124
+ evaluate(messages: Message[], participants: ChatParticipant[], context: ChatContext): Promise<TerminationResult>;
125
+ }
126
+ /**
127
+ * ConsensusConfig is re-exported for backwards compatibility
128
+ * @deprecated Use ConsensusConfigType from ./types instead
129
+ */
130
+ export type ConsensusConfig = ConsensusConfigType;
131
+ /**
132
+ * Handler for consensus-based termination
133
+ */
134
+ export declare class ConsensusHandler implements TerminationHandler {
135
+ private config;
136
+ /**
137
+ * Create a consensus handler
138
+ * @param config - Consensus configuration
139
+ */
140
+ constructor(config: ConsensusConfigType);
141
+ /**
142
+ * Evaluate if consensus has been reached
143
+ * @param messages - Conversation messages
144
+ * @param participants - Chat participants
145
+ * @param context - Current chat context
146
+ * @returns Termination result
147
+ */
148
+ evaluate(messages: Message[], _participants: ChatParticipant[], _context: ChatContext): Promise<TerminationResult>;
149
+ }
150
+ /**
151
+ * Handler for custom termination conditions
152
+ */
153
+ export declare class CustomHandler implements TerminationHandler {
154
+ private condition;
155
+ /**
156
+ * Create a custom handler
157
+ * @param condition - Custom termination condition
158
+ */
159
+ constructor(condition: TerminationCondition);
160
+ /**
161
+ * Evaluate the custom condition
162
+ * @param messages - Conversation messages
163
+ * @param participants - Chat participants
164
+ * @param context - Current chat context
165
+ * @returns Termination result
166
+ */
167
+ evaluate(messages: Message[], participants: ChatParticipant[], context: ChatContext): Promise<TerminationResult>;
168
+ }
169
+ /**
170
+ * Manager for multiple termination conditions
171
+ */
172
+ export declare class TerminationManager {
173
+ private handlers;
174
+ private conditions;
175
+ /**
176
+ * Create a termination manager
177
+ * @param conditions - Initial termination conditions
178
+ */
179
+ constructor(conditions?: TerminationCondition[]);
180
+ /**
181
+ * Add a termination condition
182
+ * @param condition - Condition to add
183
+ */
184
+ addCondition(condition: TerminationCondition): void;
185
+ /**
186
+ * Remove a termination condition by type
187
+ * @param type - Condition type to remove
188
+ */
189
+ removeCondition(type: TerminationConditionType): void;
190
+ /**
191
+ * Clear all termination conditions
192
+ */
193
+ clearConditions(): void;
194
+ /**
195
+ * Evaluate all termination conditions
196
+ * @param messages - Conversation messages
197
+ * @param participants - Chat participants
198
+ * @param context - Current chat context
199
+ * @returns Combined termination result
200
+ */
201
+ evaluate(messages: Message[], participants: ChatParticipant[], context: ChatContext): Promise<TerminationResult>;
202
+ /**
203
+ * Get all configured conditions
204
+ * @returns Array of termination conditions
205
+ */
206
+ getConditions(): TerminationCondition[];
207
+ /**
208
+ * Check if a specific condition type is configured
209
+ * @param type - Condition type to check
210
+ * @returns Whether the condition type exists
211
+ */
212
+ hasCondition(type: TerminationConditionType): boolean;
213
+ }
214
+ /**
215
+ * Common termination condition presets
216
+ */
217
+ export declare const TerminationPresets: {
218
+ /**
219
+ * Create a preset for task completion detection
220
+ */
221
+ taskCompletion(): TerminationCondition;
222
+ /**
223
+ * Create a preset for approval workflows
224
+ */
225
+ approval(): TerminationCondition;
226
+ /**
227
+ * Create a preset for quick discussions
228
+ * @param rounds - Maximum rounds
229
+ */
230
+ quickDiscussion(rounds?: number): TerminationCondition[];
231
+ /**
232
+ * Create a preset for long-running tasks
233
+ * @param timeoutMinutes - Timeout in minutes
234
+ */
235
+ longRunning(timeoutMinutes?: number): TerminationCondition[];
236
+ };
237
+ //# sourceMappingURL=termination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"termination.d.ts","sourceRoot":"","sources":["../src/termination.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,wBAAwB,EAExB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,QAAQ,CACN,QAAQ,EAAE,OAAO,EAAE,EACnB,YAAY,EAAE,eAAe,EAAE,EAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/B;AAgCD;;;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