@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
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Speaker Selection Strategies for AutoGen-style Group Chat
|
|
3
|
+
*
|
|
4
|
+
* Implements various strategies for selecting the next speaker in a
|
|
5
|
+
* multi-agent conversation, including round-robin, LLM-selected, and priority-based.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChatParticipant, Message, ChatContext, SpeakerSelectionConfig, SpeakerSelectionResult, SpeakerSelectionStrategy, SpeakerSelectionMethod } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Factory function to create speaker selection strategies
|
|
10
|
+
* @param method - The speaker selection method to use
|
|
11
|
+
* @returns The appropriate speaker selection strategy
|
|
12
|
+
*/
|
|
13
|
+
export declare function createSpeakerSelector(method: SpeakerSelectionMethod): SpeakerSelectionStrategy;
|
|
14
|
+
/**
|
|
15
|
+
* Round-robin speaker selection - cycles through participants in order
|
|
16
|
+
*/
|
|
17
|
+
export declare class RoundRobinSelector implements SpeakerSelectionStrategy {
|
|
18
|
+
private currentIndex;
|
|
19
|
+
/**
|
|
20
|
+
* Select the next speaker using round-robin ordering
|
|
21
|
+
* @param participants - Available participants
|
|
22
|
+
* @param messages - Message history
|
|
23
|
+
* @param context - Current chat context
|
|
24
|
+
* @param _config - Optional configuration (unused)
|
|
25
|
+
* @returns Speaker selection result
|
|
26
|
+
*/
|
|
27
|
+
selectSpeaker(participants: ChatParticipant[], messages: Message[], _context: ChatContext, _config?: SpeakerSelectionConfig): Promise<SpeakerSelectionResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Reset the round-robin index
|
|
30
|
+
*/
|
|
31
|
+
reset(): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Random speaker selection - randomly selects from available participants
|
|
35
|
+
*/
|
|
36
|
+
export declare class RandomSelector implements SpeakerSelectionStrategy {
|
|
37
|
+
/**
|
|
38
|
+
* Select the next speaker randomly
|
|
39
|
+
* @param participants - Available participants
|
|
40
|
+
* @param messages - Message history
|
|
41
|
+
* @param context - Current chat context
|
|
42
|
+
* @param config - Optional configuration
|
|
43
|
+
* @returns Speaker selection result
|
|
44
|
+
*/
|
|
45
|
+
selectSpeaker(participants: ChatParticipant[], messages: Message[], context: ChatContext, config?: SpeakerSelectionConfig): Promise<SpeakerSelectionResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Perform weighted random selection
|
|
48
|
+
* @param participants - Participants to select from
|
|
49
|
+
* @param weights - Weight for each participant
|
|
50
|
+
* @returns Selected participant
|
|
51
|
+
*/
|
|
52
|
+
private weightedSelection;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* LLM-based speaker selection - uses an LLM to determine the best next speaker
|
|
56
|
+
*/
|
|
57
|
+
export declare class LLMSelector implements SpeakerSelectionStrategy {
|
|
58
|
+
/**
|
|
59
|
+
* Select the next speaker using LLM reasoning
|
|
60
|
+
* @param participants - Available participants
|
|
61
|
+
* @param messages - Message history
|
|
62
|
+
* @param context - Current chat context
|
|
63
|
+
* @param config - Configuration including LLM settings
|
|
64
|
+
* @returns Speaker selection result
|
|
65
|
+
*/
|
|
66
|
+
selectSpeaker(participants: ChatParticipant[], messages: Message[], context: ChatContext, config?: SpeakerSelectionConfig): Promise<SpeakerSelectionResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Build the prompt for LLM speaker selection
|
|
69
|
+
* @param participants - Available participants
|
|
70
|
+
* @param messages - Message history
|
|
71
|
+
* @param context - Chat context
|
|
72
|
+
* @param config - Selection configuration
|
|
73
|
+
* @returns Formatted prompt string
|
|
74
|
+
*/
|
|
75
|
+
private buildSelectionPrompt;
|
|
76
|
+
/**
|
|
77
|
+
* Simulate LLM selection (placeholder for actual LLM call)
|
|
78
|
+
* @param prompt - Selection prompt
|
|
79
|
+
* @param participants - Available participants
|
|
80
|
+
* @param messages - Message history
|
|
81
|
+
* @returns Selected participant name
|
|
82
|
+
*/
|
|
83
|
+
private simulateLLMSelection;
|
|
84
|
+
/**
|
|
85
|
+
* Find the participant most relevant to the given content
|
|
86
|
+
* @param content - Message content to analyze
|
|
87
|
+
* @param participants - Available participants
|
|
88
|
+
* @returns Most relevant participant or null
|
|
89
|
+
*/
|
|
90
|
+
private findMostRelevantParticipant;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Priority-based speaker selection - selects based on configured priority order
|
|
94
|
+
*/
|
|
95
|
+
export declare class PrioritySelector implements SpeakerSelectionStrategy {
|
|
96
|
+
/**
|
|
97
|
+
* Select the next speaker based on priority order
|
|
98
|
+
* @param participants - Available participants
|
|
99
|
+
* @param messages - Message history
|
|
100
|
+
* @param context - Current chat context
|
|
101
|
+
* @param config - Configuration with priority order
|
|
102
|
+
* @returns Speaker selection result
|
|
103
|
+
*/
|
|
104
|
+
selectSpeaker(participants: ChatParticipant[], messages: Message[], context: ChatContext, config?: SpeakerSelectionConfig): Promise<SpeakerSelectionResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Apply transition rules to determine next speaker
|
|
107
|
+
* @param fromSpeaker - Current speaker name
|
|
108
|
+
* @param rules - Transition rules
|
|
109
|
+
* @param participants - Available participants
|
|
110
|
+
* @returns Next speaker or null
|
|
111
|
+
*/
|
|
112
|
+
private applyTransitionRules;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Manual speaker selection - expects explicit selection from context
|
|
116
|
+
*/
|
|
117
|
+
export declare class ManualSelector implements SpeakerSelectionStrategy {
|
|
118
|
+
/**
|
|
119
|
+
* Select the next speaker from manual specification
|
|
120
|
+
* @param participants - Available participants
|
|
121
|
+
* @param messages - Message history
|
|
122
|
+
* @param context - Current chat context with manual selection
|
|
123
|
+
* @returns Speaker selection result
|
|
124
|
+
*/
|
|
125
|
+
selectSpeaker(participants: ChatParticipant[], _messages: Message[], context: ChatContext): Promise<SpeakerSelectionResult>;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Auto speaker selection - intelligently chooses selection strategy based on context
|
|
129
|
+
*/
|
|
130
|
+
export declare class AutoSelector implements SpeakerSelectionStrategy {
|
|
131
|
+
private roundRobin;
|
|
132
|
+
private llm;
|
|
133
|
+
private priority;
|
|
134
|
+
/**
|
|
135
|
+
* Automatically select the best strategy and next speaker
|
|
136
|
+
* @param participants - Available participants
|
|
137
|
+
* @param messages - Message history
|
|
138
|
+
* @param context - Current chat context
|
|
139
|
+
* @param config - Selection configuration
|
|
140
|
+
* @returns Speaker selection result
|
|
141
|
+
*/
|
|
142
|
+
selectSpeaker(participants: ChatParticipant[], messages: Message[], context: ChatContext, config?: SpeakerSelectionConfig): Promise<SpeakerSelectionResult>;
|
|
143
|
+
/**
|
|
144
|
+
* Determine the best selection strategy for current context
|
|
145
|
+
* @param participants - Active participants
|
|
146
|
+
* @param messages - Message history
|
|
147
|
+
* @param context - Chat context
|
|
148
|
+
* @param config - Selection configuration
|
|
149
|
+
* @returns Strategy name to use
|
|
150
|
+
*/
|
|
151
|
+
private determineStrategy;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Speaker selection manager that wraps all strategies
|
|
155
|
+
*/
|
|
156
|
+
export declare class SpeakerSelectionManager {
|
|
157
|
+
private strategies;
|
|
158
|
+
private currentStrategy;
|
|
159
|
+
private method;
|
|
160
|
+
/**
|
|
161
|
+
* Create a new speaker selection manager
|
|
162
|
+
* @param method - Initial selection method
|
|
163
|
+
*/
|
|
164
|
+
constructor(method?: SpeakerSelectionMethod);
|
|
165
|
+
/**
|
|
166
|
+
* Initialize all available strategies
|
|
167
|
+
*/
|
|
168
|
+
private initializeStrategies;
|
|
169
|
+
/**
|
|
170
|
+
* Select the next speaker using the current strategy
|
|
171
|
+
* @param participants - Available participants
|
|
172
|
+
* @param messages - Message history
|
|
173
|
+
* @param context - Chat context
|
|
174
|
+
* @param config - Selection configuration
|
|
175
|
+
* @returns Speaker selection result
|
|
176
|
+
*/
|
|
177
|
+
selectSpeaker(participants: ChatParticipant[], messages: Message[], context: ChatContext, config?: SpeakerSelectionConfig): Promise<SpeakerSelectionResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Change the selection method
|
|
180
|
+
* @param method - New selection method
|
|
181
|
+
*/
|
|
182
|
+
setMethod(method: SpeakerSelectionMethod): void;
|
|
183
|
+
/**
|
|
184
|
+
* Get the current selection method
|
|
185
|
+
* @returns Current method
|
|
186
|
+
*/
|
|
187
|
+
getMethod(): SpeakerSelectionMethod;
|
|
188
|
+
/**
|
|
189
|
+
* Get a specific strategy instance
|
|
190
|
+
* @param method - Selection method
|
|
191
|
+
* @returns Strategy instance
|
|
192
|
+
*/
|
|
193
|
+
getStrategy(method: SpeakerSelectionMethod): SpeakerSelectionStrategy;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=speaker-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speaker-selection.d.ts","sourceRoot":"","sources":["../src/speaker-selection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,sBAAsB,GAC7B,wBAAwB,CAiB1B;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,wBAAwB;IACjE,OAAO,CAAC,YAAY,CAAK;IAEzB;;;;;;;OAOG;IACG,aAAa,CACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,WAAW,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,sBAAsB,CAAC;IAmClC;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,wBAAwB;IAC7D;;;;;;;OAOG;IACG,aAAa,CACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,WAAW,EACpB,MAAM,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,sBAAsB,CAAC;IA2ClC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAsB1B;AAED;;GAEG;AACH,qBAAa,WAAY,YAAW,wBAAwB;IAC1D;;;;;;;OAOG;IACG,aAAa,CACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,WAAW,EACpB,MAAM,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,sBAAsB,CAAC;IAoDlC;;;;;;;OAOG;IACH,OA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