agent-swarm-kit 1.0.70 → 1.0.71
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/build/index.cjs +915 -113
- package/build/index.mjs +906 -114
- package/package.json +1 -1
- package/types.d.ts +903 -697
package/types.d.ts
CHANGED
|
@@ -53,1005 +53,1058 @@ interface ILogger {
|
|
|
53
53
|
debug(...args: any[]): void;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Type representing an array of numbers as embeddings.
|
|
58
|
+
*/
|
|
59
|
+
type Embeddings = number[];
|
|
60
|
+
/**
|
|
61
|
+
* Interface for embedding callbacks.
|
|
62
|
+
*/
|
|
63
|
+
interface IEmbeddingCallbacks {
|
|
57
64
|
/**
|
|
58
|
-
* Callback
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
65
|
+
* Callback for when an embedding is created.
|
|
66
|
+
* @param text - The text used to create the embedding.
|
|
67
|
+
* @param embeddings - The generated embeddings.
|
|
68
|
+
* @param clientId - The client ID associated with the embedding.
|
|
69
|
+
* @param embeddingName - The name of the embedding.
|
|
61
70
|
*/
|
|
62
|
-
|
|
71
|
+
onCreate(text: string, embeddings: Embeddings, clientId: string, embeddingName: EmbeddingName): void;
|
|
63
72
|
/**
|
|
64
|
-
* Callback
|
|
65
|
-
* @param
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
73
|
+
* Callback for when embeddings are compared.
|
|
74
|
+
* @param text1 - The first text used in the comparison.
|
|
75
|
+
* @param text2 - The second text used in the comparison.
|
|
76
|
+
* @param similarity - The similarity score between the embeddings.
|
|
77
|
+
* @param clientId - The client ID associated with the comparison.
|
|
78
|
+
* @param embeddingName - The name of the embedding.
|
|
69
79
|
*/
|
|
70
|
-
|
|
80
|
+
onCompare(text1: string, text2: string, similarity: number, clientId: string, embeddingName: EmbeddingName): void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Interface representing the schema for embeddings.
|
|
84
|
+
*/
|
|
85
|
+
interface IEmbeddingSchema {
|
|
71
86
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @param clientId - The ID of the client.
|
|
74
|
-
* @param swarmName - The name of the swarm.
|
|
75
|
-
* @param message - The message to emit.
|
|
87
|
+
* The name of the embedding.
|
|
76
88
|
*/
|
|
77
|
-
|
|
89
|
+
embeddingName: EmbeddingName;
|
|
78
90
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @param
|
|
81
|
-
* @
|
|
91
|
+
* Creates an embedding from the given text.
|
|
92
|
+
* @param text - The text to create the embedding from.
|
|
93
|
+
* @returns A promise that resolves to the generated embeddings.
|
|
82
94
|
*/
|
|
83
|
-
|
|
95
|
+
createEmbedding(text: string): Promise<Embeddings>;
|
|
84
96
|
/**
|
|
85
|
-
*
|
|
86
|
-
* @param
|
|
87
|
-
* @param
|
|
97
|
+
* Calculates the similarity between two embeddings.
|
|
98
|
+
* @param a - The first embedding.
|
|
99
|
+
* @param b - The second embedding.
|
|
100
|
+
* @returns A promise that resolves to the similarity score.
|
|
88
101
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
interface ISwarmCallbacks extends ISwarmSessionCallbacks {
|
|
95
|
-
/** Emit the callback on agent change */
|
|
96
|
-
onAgentChanged: (clientId: string, agentName: AgentName, swarmName: SwarmName) => Promise<void>;
|
|
102
|
+
calculateSimilarity(a: Embeddings, b: Embeddings): Promise<number>;
|
|
103
|
+
/**
|
|
104
|
+
* Optional callbacks for embedding events.
|
|
105
|
+
*/
|
|
106
|
+
callbacks?: Partial<IEmbeddingCallbacks>;
|
|
97
107
|
}
|
|
98
108
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @interface
|
|
101
|
-
* @extends {Omit<ISwarmSchema, 'agentList'>}
|
|
109
|
+
* Type representing the name of an embedding.
|
|
102
110
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}>, ISwarmCallbacks {
|
|
107
|
-
/** Client identifier */
|
|
108
|
-
clientId: string;
|
|
109
|
-
/** Logger instance */
|
|
110
|
-
logger: ILogger;
|
|
111
|
-
/** Map of agent names to agent instances */
|
|
112
|
-
agentMap: Record<AgentName, IAgent>;
|
|
113
|
-
}
|
|
111
|
+
type EmbeddingName = string;
|
|
112
|
+
|
|
113
|
+
type StorageId = string | number;
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
116
|
-
* @interface
|
|
115
|
+
* Interface representing the data stored in the storage.
|
|
117
116
|
*/
|
|
118
|
-
interface
|
|
119
|
-
|
|
120
|
-
defaultAgent: AgentName;
|
|
121
|
-
/** Name of the swarm */
|
|
122
|
-
swarmName: string;
|
|
123
|
-
/** List of agent names */
|
|
124
|
-
agentList: string[];
|
|
125
|
-
/** Lifecycle callbacks*/
|
|
126
|
-
callbacks?: Partial<ISwarmCallbacks>;
|
|
117
|
+
interface IStorageData {
|
|
118
|
+
id: StorageId;
|
|
127
119
|
}
|
|
128
120
|
/**
|
|
129
|
-
* Interface
|
|
130
|
-
* @
|
|
121
|
+
* Interface representing the schema of the storage.
|
|
122
|
+
* @template T - Type of the storage data.
|
|
131
123
|
*/
|
|
132
|
-
interface
|
|
124
|
+
interface IStorageSchema<T extends IStorageData = IStorageData> {
|
|
133
125
|
/**
|
|
134
|
-
*
|
|
135
|
-
* @returns {Promise<string>} The output from the swarm.
|
|
126
|
+
* All agents will share the same ClientStorage instance
|
|
136
127
|
*/
|
|
137
|
-
|
|
128
|
+
shared?: boolean;
|
|
138
129
|
/**
|
|
139
|
-
*
|
|
140
|
-
* @
|
|
130
|
+
* Function to get data from the storage.
|
|
131
|
+
* @param clientId - The client ID.
|
|
132
|
+
* @param storageName - The name of the storage.
|
|
133
|
+
* @returns A promise that resolves to an array of storage data or an array of storage data.
|
|
141
134
|
*/
|
|
142
|
-
|
|
135
|
+
getData?: (clientId: string, storageName: StorageName) => Promise<T[]> | T[];
|
|
143
136
|
/**
|
|
144
|
-
*
|
|
145
|
-
* @
|
|
137
|
+
* Function to create an index for an item.
|
|
138
|
+
* @param item - The item to index.
|
|
139
|
+
* @returns A promise that resolves to a string or a string.
|
|
146
140
|
*/
|
|
147
|
-
|
|
141
|
+
createIndex(item: T): Promise<string> | string;
|
|
148
142
|
/**
|
|
149
|
-
*
|
|
150
|
-
* @param {AgentName} agentName - The name of the agent.
|
|
151
|
-
* @param {IAgent} agent - The agent instance.
|
|
152
|
-
* @returns {Promise<void>}
|
|
143
|
+
* The name of the embedding.
|
|
153
144
|
*/
|
|
154
|
-
|
|
145
|
+
embedding: EmbeddingName;
|
|
155
146
|
/**
|
|
156
|
-
*
|
|
157
|
-
* @param {AgentName} agentName - The name of the agent.
|
|
158
|
-
* @returns {Promise<void>}
|
|
147
|
+
* The name of the storage.
|
|
159
148
|
*/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Parameters required to create a session.
|
|
167
|
-
* @interface
|
|
168
|
-
*/
|
|
169
|
-
interface ISessionParams extends ISessionSchema, ISwarmSessionCallbacks {
|
|
170
|
-
clientId: string;
|
|
171
|
-
logger: ILogger;
|
|
172
|
-
swarm: ISwarm;
|
|
173
|
-
swarmName: SwarmName;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Schema for session data.
|
|
177
|
-
* @interface
|
|
178
|
-
*/
|
|
179
|
-
interface ISessionSchema {
|
|
149
|
+
storageName: StorageName;
|
|
150
|
+
/**
|
|
151
|
+
* Optional callbacks for storage events.
|
|
152
|
+
*/
|
|
153
|
+
callbacks?: Partial<IStorageCallbacks<T>>;
|
|
180
154
|
}
|
|
181
155
|
/**
|
|
182
|
-
*
|
|
183
|
-
* @
|
|
184
|
-
* @param {IOutgoingMessage} outgoing - The outgoing message.
|
|
185
|
-
* @returns {Promise<void> | void}
|
|
186
|
-
*/
|
|
187
|
-
type SendMessageFn$1 = (outgoing: IOutgoingMessage) => Promise<void> | void;
|
|
188
|
-
/**
|
|
189
|
-
* Function type for receiving messages.
|
|
190
|
-
* @typedef {function} ReceiveMessageFn
|
|
191
|
-
* @param {IIncomingMessage} incoming - The incoming message.
|
|
192
|
-
* @returns {Promise<void> | void}
|
|
193
|
-
*/
|
|
194
|
-
type ReceiveMessageFn = (incoming: IIncomingMessage) => Promise<void> | void;
|
|
195
|
-
/**
|
|
196
|
-
* Interface for a session.
|
|
197
|
-
* @interface
|
|
156
|
+
* Interface representing the callbacks for storage events.
|
|
157
|
+
* @template T - Type of the storage data.
|
|
198
158
|
*/
|
|
199
|
-
interface
|
|
200
|
-
/**
|
|
201
|
-
* Emit a message.
|
|
202
|
-
* @param {string} message - The message to emit.
|
|
203
|
-
* @returns {Promise<void>}
|
|
204
|
-
*/
|
|
205
|
-
emit(message: string): Promise<void>;
|
|
206
|
-
/**
|
|
207
|
-
* Execute a command.
|
|
208
|
-
* @param {string} content - The content to execute.
|
|
209
|
-
* @param {string} mode - The source of execution: tool or user
|
|
210
|
-
* @returns {Promise<string>}
|
|
211
|
-
*/
|
|
212
|
-
execute(content: string, mode: ExecutionMode): Promise<string>;
|
|
213
|
-
/**
|
|
214
|
-
* Connect to a message sender.
|
|
215
|
-
* @param {SendMessageFn} connector - The function to send messages.
|
|
216
|
-
* @returns {ReceiveMessageFn}
|
|
217
|
-
*/
|
|
218
|
-
connect(connector: SendMessageFn$1): ReceiveMessageFn;
|
|
159
|
+
interface IStorageCallbacks<T extends IStorageData = IStorageData> {
|
|
219
160
|
/**
|
|
220
|
-
*
|
|
221
|
-
* @param
|
|
222
|
-
* @param
|
|
223
|
-
* @
|
|
161
|
+
* Callback function for update events.
|
|
162
|
+
* @param items - The updated items.
|
|
163
|
+
* @param clientId - The client ID.
|
|
164
|
+
* @param storageName - The name of the storage.
|
|
224
165
|
*/
|
|
225
|
-
|
|
166
|
+
onUpdate: (items: T[], clientId: string, storageName: StorageName) => void;
|
|
226
167
|
/**
|
|
227
|
-
*
|
|
228
|
-
* @param
|
|
229
|
-
* @
|
|
168
|
+
* Callback function for search events.
|
|
169
|
+
* @param search - The search query.
|
|
170
|
+
* @param index - The sorted array of storage data.
|
|
171
|
+
* @param clientId - The client ID.
|
|
172
|
+
* @param storageName - The name of the storage.
|
|
230
173
|
*/
|
|
231
|
-
|
|
174
|
+
onSearch: (search: string, index: SortedArray<T>, clientId: string, storageName: StorageName) => void;
|
|
232
175
|
/**
|
|
233
|
-
*
|
|
234
|
-
* @
|
|
176
|
+
* Callback function for init
|
|
177
|
+
* @param clientId - The client ID.
|
|
178
|
+
* @param storageName - The name of the storage.
|
|
235
179
|
*/
|
|
236
|
-
|
|
180
|
+
onInit: (clientId: string, storageName: StorageName) => void;
|
|
237
181
|
/**
|
|
238
|
-
*
|
|
239
|
-
* @param
|
|
240
|
-
* @
|
|
182
|
+
* Callback function for dispose
|
|
183
|
+
* @param clientId - The client ID.
|
|
184
|
+
* @param storageName - The name of the storage.
|
|
241
185
|
*/
|
|
242
|
-
|
|
186
|
+
onDispose: (clientId: string, storageName: StorageName) => void;
|
|
243
187
|
}
|
|
244
188
|
/**
|
|
245
|
-
*
|
|
246
|
-
* @
|
|
247
|
-
*/
|
|
248
|
-
type SessionId = string;
|
|
249
|
-
/**
|
|
250
|
-
* Type for session mode.
|
|
251
|
-
* @typedef {"session" | "makeConnection" | "complete"} SessionMode
|
|
252
|
-
*/
|
|
253
|
-
type SessionMode = "session" | "makeConnection" | "complete";
|
|
254
|
-
/**
|
|
255
|
-
* Tools can emit user messages to trigger user friendly responses.
|
|
256
|
-
* Should be ignored for `getUserHistory`
|
|
257
|
-
* @typedef {"tool" | "user"} ExecutionMode
|
|
258
|
-
*/
|
|
259
|
-
type ExecutionMode = "tool" | "user";
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Represents a tool call with a function name and arguments.
|
|
189
|
+
* Interface representing the parameters for storage.
|
|
190
|
+
* @template T - Type of the storage data.
|
|
263
191
|
*/
|
|
264
|
-
interface
|
|
192
|
+
interface IStorageParams<T extends IStorageData = IStorageData> extends IStorageSchema<T>, Partial<IEmbeddingCallbacks> {
|
|
265
193
|
/**
|
|
266
|
-
* The ID
|
|
194
|
+
* The client ID.
|
|
267
195
|
*/
|
|
268
|
-
|
|
196
|
+
clientId: string;
|
|
269
197
|
/**
|
|
270
|
-
*
|
|
198
|
+
* Function to calculate similarity.
|
|
271
199
|
*/
|
|
272
|
-
|
|
200
|
+
calculateSimilarity: IEmbeddingSchema["calculateSimilarity"];
|
|
273
201
|
/**
|
|
274
|
-
*
|
|
202
|
+
* Function to create an embedding.
|
|
275
203
|
*/
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* The name of the function to be called.
|
|
279
|
-
*/
|
|
280
|
-
name: string;
|
|
281
|
-
/**
|
|
282
|
-
* The arguments to be passed to the function.
|
|
283
|
-
*/
|
|
284
|
-
arguments: {
|
|
285
|
-
[key: string]: any;
|
|
286
|
-
};
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Represents a tool with a type and function details.
|
|
291
|
-
*/
|
|
292
|
-
interface ITool {
|
|
204
|
+
createEmbedding: IEmbeddingSchema["createEmbedding"];
|
|
293
205
|
/**
|
|
294
|
-
* The
|
|
206
|
+
* The name of the storage.
|
|
295
207
|
*/
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
* The description of the function.
|
|
304
|
-
*/
|
|
305
|
-
description: string;
|
|
306
|
-
/**
|
|
307
|
-
* The parameters required by the function.
|
|
308
|
-
*/
|
|
309
|
-
parameters: {
|
|
310
|
-
/**
|
|
311
|
-
* The type of the parameters.
|
|
312
|
-
*/
|
|
313
|
-
type: string;
|
|
314
|
-
/**
|
|
315
|
-
* The list of required parameters.
|
|
316
|
-
*/
|
|
317
|
-
required: string[];
|
|
318
|
-
/**
|
|
319
|
-
* The properties of the parameters.
|
|
320
|
-
*/
|
|
321
|
-
properties: {
|
|
322
|
-
[key: string]: {
|
|
323
|
-
/**
|
|
324
|
-
* The type of the property.
|
|
325
|
-
*/
|
|
326
|
-
type: string;
|
|
327
|
-
/**
|
|
328
|
-
* The description of the property.
|
|
329
|
-
*/
|
|
330
|
-
description: string;
|
|
331
|
-
/**
|
|
332
|
-
* The possible values for the property.
|
|
333
|
-
*/
|
|
334
|
-
enum?: string[];
|
|
335
|
-
};
|
|
336
|
-
};
|
|
337
|
-
};
|
|
338
|
-
};
|
|
208
|
+
storageName: StorageName;
|
|
209
|
+
/**
|
|
210
|
+
* Logger instance.
|
|
211
|
+
*/
|
|
212
|
+
logger: ILogger;
|
|
213
|
+
/** The bus instance. */
|
|
214
|
+
bus: IBus;
|
|
339
215
|
}
|
|
340
|
-
|
|
341
216
|
/**
|
|
342
|
-
* Interface representing
|
|
217
|
+
* Interface representing the storage.
|
|
218
|
+
* @template T - Type of the storage data.
|
|
343
219
|
*/
|
|
344
|
-
interface
|
|
220
|
+
interface IStorage<T extends IStorageData = IStorageData> {
|
|
345
221
|
/**
|
|
346
|
-
*
|
|
347
|
-
* @
|
|
222
|
+
* Function to take items from the storage.
|
|
223
|
+
* @param search - The search query.
|
|
224
|
+
* @param total - The total number of items to take.
|
|
225
|
+
* @param score - Optional score parameter.
|
|
226
|
+
* @returns A promise that resolves to an array of storage data.
|
|
348
227
|
*/
|
|
349
|
-
|
|
228
|
+
take(search: string, total: number, score?: number): Promise<T[]>;
|
|
350
229
|
/**
|
|
351
|
-
*
|
|
352
|
-
* @
|
|
230
|
+
* Function to upsert an item in the storage.
|
|
231
|
+
* @param item - The item to upsert.
|
|
232
|
+
* @returns A promise that resolves when the operation is complete.
|
|
353
233
|
*/
|
|
354
|
-
|
|
234
|
+
upsert(item: T): Promise<void>;
|
|
355
235
|
/**
|
|
356
|
-
*
|
|
357
|
-
* @
|
|
236
|
+
* Function to remove an item from the storage.
|
|
237
|
+
* @param itemId - The ID of the item to remove.
|
|
238
|
+
* @returns A promise that resolves when the operation is complete.
|
|
358
239
|
*/
|
|
359
|
-
|
|
240
|
+
remove(itemId: IStorageData["id"]): Promise<void>;
|
|
360
241
|
/**
|
|
361
|
-
*
|
|
362
|
-
* @
|
|
242
|
+
* Function to get an item from the storage.
|
|
243
|
+
* @param itemId - The ID of the item to get.
|
|
244
|
+
* @returns A promise that resolves to the item or null if not found.
|
|
363
245
|
*/
|
|
364
|
-
|
|
246
|
+
get(itemId: IStorageData["id"]): Promise<T | null>;
|
|
365
247
|
/**
|
|
366
|
-
*
|
|
367
|
-
* @
|
|
248
|
+
* Function to list items from the storage.
|
|
249
|
+
* @param filter - Optional filter function.
|
|
250
|
+
* @returns A promise that resolves to an array of storage data.
|
|
368
251
|
*/
|
|
369
|
-
|
|
252
|
+
list(filter?: (item: T) => boolean): Promise<T[]>;
|
|
370
253
|
/**
|
|
371
|
-
*
|
|
254
|
+
* Function to clear the storage.
|
|
255
|
+
* @returns A promise that resolves when the operation is complete.
|
|
372
256
|
*/
|
|
373
|
-
|
|
257
|
+
clear(): Promise<void>;
|
|
374
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Type representing the name of the storage.
|
|
261
|
+
*/
|
|
262
|
+
type StorageName = string;
|
|
375
263
|
|
|
264
|
+
type IStateData = any;
|
|
376
265
|
/**
|
|
377
|
-
*
|
|
266
|
+
* Middleware function for state management.
|
|
267
|
+
* @template T - The type of the state data.
|
|
268
|
+
* @param {T} state - The current state.
|
|
269
|
+
* @param {string} clientId - The client ID.
|
|
270
|
+
* @param {StateName} stateName - The name of the state.
|
|
271
|
+
* @returns {Promise<T>} - The updated state.
|
|
378
272
|
*/
|
|
379
|
-
interface
|
|
273
|
+
interface IStateMiddleware<T extends IStateData = IStateData> {
|
|
274
|
+
(state: T, clientId: string, stateName: StateName): Promise<T>;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Callbacks for state lifecycle events.
|
|
278
|
+
* @template T - The type of the state data.
|
|
279
|
+
*/
|
|
280
|
+
interface IStateCallbacks<T extends IStateData = IStateData> {
|
|
380
281
|
/**
|
|
381
|
-
*
|
|
382
|
-
* @param
|
|
383
|
-
* @param
|
|
384
|
-
* @param agentName - The agent name.
|
|
385
|
-
* @returns A promise that resolves to a boolean indicating whether the message passes the filter.
|
|
282
|
+
* Called when the state is initialized.
|
|
283
|
+
* @param {string} clientId - The client ID.
|
|
284
|
+
* @param {StateName} stateName - The name of the state.
|
|
386
285
|
*/
|
|
387
|
-
|
|
286
|
+
onInit: (clientId: string, stateName: StateName) => void;
|
|
388
287
|
/**
|
|
389
|
-
*
|
|
390
|
-
* @param clientId - The client ID.
|
|
391
|
-
* @param
|
|
392
|
-
* @returns A promise that resolves to an array of model messages.
|
|
288
|
+
* Called when the state is disposed.
|
|
289
|
+
* @param {string} clientId - The client ID.
|
|
290
|
+
* @param {StateName} stateName - The name of the state.
|
|
393
291
|
*/
|
|
394
|
-
|
|
292
|
+
onDispose: (clientId: string, stateName: StateName) => void;
|
|
395
293
|
/**
|
|
396
|
-
*
|
|
397
|
-
* @param
|
|
398
|
-
* @param clientId - The client ID.
|
|
399
|
-
* @param
|
|
294
|
+
* Called when the state is loaded.
|
|
295
|
+
* @param {T} state - The current state.
|
|
296
|
+
* @param {string} clientId - The client ID.
|
|
297
|
+
* @param {StateName} stateName - The name of the state.
|
|
400
298
|
*/
|
|
401
|
-
|
|
299
|
+
onLoad: (state: T, clientId: string, stateName: StateName) => void;
|
|
402
300
|
/**
|
|
403
|
-
*
|
|
404
|
-
* @param
|
|
405
|
-
* @param clientId - The client ID.
|
|
406
|
-
* @param
|
|
301
|
+
* Called when the state is read.
|
|
302
|
+
* @param {T} state - The current state.
|
|
303
|
+
* @param {string} clientId - The client ID.
|
|
304
|
+
* @param {StateName} stateName - The name of the state.
|
|
407
305
|
*/
|
|
408
|
-
|
|
306
|
+
onRead: (state: T, clientId: string, stateName: StateName) => void;
|
|
409
307
|
/**
|
|
410
|
-
*
|
|
411
|
-
* @param
|
|
412
|
-
* @param clientId - The client ID.
|
|
413
|
-
* @param
|
|
308
|
+
* Called when the state is written.
|
|
309
|
+
* @param {T} state - The current state.
|
|
310
|
+
* @param {string} clientId - The client ID.
|
|
311
|
+
* @param {StateName} stateName - The name of the state.
|
|
414
312
|
*/
|
|
415
|
-
|
|
313
|
+
onWrite: (state: T, clientId: string, stateName: StateName) => void;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Schema for state management.
|
|
317
|
+
* @template T - The type of the state data.
|
|
318
|
+
*/
|
|
319
|
+
interface IStateSchema<T extends IStateData = IStateData> {
|
|
320
|
+
/**
|
|
321
|
+
* The agents can share the state
|
|
322
|
+
*/
|
|
323
|
+
shared?: boolean;
|
|
416
324
|
/**
|
|
417
|
-
*
|
|
418
|
-
* @param clientId - The client ID.
|
|
419
|
-
* @param agentName - The agent name.
|
|
325
|
+
* The name of the state.
|
|
420
326
|
*/
|
|
421
|
-
|
|
327
|
+
stateName: StateName;
|
|
422
328
|
/**
|
|
423
|
-
*
|
|
424
|
-
* @param clientId - The client ID.
|
|
425
|
-
* @param
|
|
329
|
+
* Gets the state.
|
|
330
|
+
* @param {string} clientId - The client ID.
|
|
331
|
+
* @param {StateName} stateName - The name of the state.
|
|
332
|
+
* @returns {T | Promise<T>} - The current state.
|
|
426
333
|
*/
|
|
427
|
-
|
|
334
|
+
getState: (clientId: string, stateName: StateName) => T | Promise<T>;
|
|
428
335
|
/**
|
|
429
|
-
*
|
|
430
|
-
* @param
|
|
336
|
+
* Sets the state.
|
|
337
|
+
* @param {T} state - The new state.
|
|
338
|
+
* @param {string} clientId - The client ID.
|
|
339
|
+
* @param {StateName} stateName - The name of the state.
|
|
340
|
+
* @returns {Promise<void> | void} - A promise that resolves when the state is set.
|
|
431
341
|
*/
|
|
432
|
-
|
|
342
|
+
setState?: (state: T, clientId: string, stateName: StateName) => Promise<void> | void;
|
|
433
343
|
/**
|
|
434
|
-
*
|
|
435
|
-
* @param clientId - The client ID.
|
|
344
|
+
* Middleware functions for state management.
|
|
436
345
|
*/
|
|
437
|
-
|
|
346
|
+
middlewares?: IStateMiddleware<T>[];
|
|
438
347
|
/**
|
|
439
|
-
*
|
|
440
|
-
* @param clientId - The client ID.
|
|
348
|
+
* Callbacks for state lifecycle events.
|
|
441
349
|
*/
|
|
442
|
-
|
|
350
|
+
callbacks?: Partial<IStateCallbacks<T>>;
|
|
443
351
|
}
|
|
444
352
|
/**
|
|
445
|
-
*
|
|
353
|
+
* Parameters for state management.
|
|
354
|
+
* @template T - The type of the state data.
|
|
446
355
|
*/
|
|
447
|
-
interface
|
|
448
|
-
/**
|
|
449
|
-
* Iterate over the history messages.
|
|
450
|
-
* @param clientId - The client ID.
|
|
451
|
-
* @param agentName - The agent name.
|
|
452
|
-
* @returns An async iterable iterator of model messages.
|
|
453
|
-
*/
|
|
454
|
-
iterate(clientId: string, agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
356
|
+
interface IStateParams<T extends IStateData = IStateData> extends IStateSchema<T> {
|
|
455
357
|
/**
|
|
456
|
-
*
|
|
457
|
-
* @param value - The model message to push.
|
|
458
|
-
* @param clientId - The client ID.
|
|
459
|
-
* @param agentName - The agent name.
|
|
460
|
-
* @returns A promise that resolves when the message is pushed.
|
|
358
|
+
* The client ID.
|
|
461
359
|
*/
|
|
462
|
-
|
|
360
|
+
clientId: string;
|
|
463
361
|
/**
|
|
464
|
-
*
|
|
465
|
-
* @param clientId - The client ID.
|
|
466
|
-
* @param agentName - The agent name or null.
|
|
467
|
-
* @returns A promise that resolves when the history is disposed.
|
|
362
|
+
* The logger instance.
|
|
468
363
|
*/
|
|
469
|
-
|
|
364
|
+
logger: ILogger;
|
|
365
|
+
/** The bus instance. */
|
|
366
|
+
bus: IBus;
|
|
470
367
|
}
|
|
471
368
|
/**
|
|
472
|
-
*
|
|
369
|
+
* State management interface.
|
|
370
|
+
* @template T - The type of the state data.
|
|
473
371
|
*/
|
|
474
|
-
interface
|
|
372
|
+
interface IState<T extends IStateData = IStateData> {
|
|
475
373
|
/**
|
|
476
|
-
*
|
|
477
|
-
* @
|
|
374
|
+
* Gets the state.
|
|
375
|
+
* @returns {Promise<T>} - The current state.
|
|
478
376
|
*/
|
|
479
|
-
|
|
377
|
+
getState: () => Promise<T>;
|
|
480
378
|
/**
|
|
481
|
-
*
|
|
482
|
-
* @param
|
|
379
|
+
* Sets the state.
|
|
380
|
+
* @param {(prevState: T) => Promise<T>} dispatchFn - The function to dispatch the new state.
|
|
381
|
+
* @returns {Promise<T>} - The updated state.
|
|
483
382
|
*/
|
|
484
|
-
|
|
383
|
+
setState: (dispatchFn: (prevState: T) => Promise<T>) => Promise<T>;
|
|
485
384
|
}
|
|
486
385
|
/**
|
|
487
|
-
*
|
|
386
|
+
* The name of the state.
|
|
488
387
|
*/
|
|
489
|
-
|
|
388
|
+
type StateName = string;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Interface representing the base context for an event.
|
|
392
|
+
*/
|
|
393
|
+
interface IBaseEventContext {
|
|
490
394
|
/**
|
|
491
|
-
*
|
|
492
|
-
* @param agentName - The agent name.
|
|
493
|
-
* @returns An async iterable iterator of model messages.
|
|
395
|
+
* The name of the agent.
|
|
494
396
|
*/
|
|
495
|
-
|
|
397
|
+
agentName: AgentName;
|
|
496
398
|
/**
|
|
497
|
-
*
|
|
498
|
-
* @param agentName - The agent name.
|
|
499
|
-
* @param init - Whether the history is initializing.
|
|
500
|
-
* @returns A promise that resolves when the history is initialized.
|
|
399
|
+
* The name of the swarm.
|
|
501
400
|
*/
|
|
502
|
-
|
|
401
|
+
swarmName: SwarmName;
|
|
503
402
|
/**
|
|
504
|
-
*
|
|
505
|
-
* @param value - The model message to push.
|
|
506
|
-
* @param agentName - The agent name.
|
|
507
|
-
* @returns A promise that resolves when the message is pushed.
|
|
403
|
+
* The name of the storage.
|
|
508
404
|
*/
|
|
509
|
-
|
|
405
|
+
storageName: StorageName;
|
|
510
406
|
/**
|
|
511
|
-
*
|
|
512
|
-
* @param agentName - The agent name or null.
|
|
513
|
-
* @returns A promise that resolves when the history is disposed.
|
|
407
|
+
* The name of the state.
|
|
514
408
|
*/
|
|
515
|
-
|
|
409
|
+
stateName: StateName;
|
|
516
410
|
}
|
|
517
411
|
/**
|
|
518
|
-
* Type
|
|
412
|
+
* Type representing the possible sources of an event.
|
|
519
413
|
*/
|
|
520
|
-
type
|
|
414
|
+
type EventSource = string;
|
|
521
415
|
/**
|
|
522
|
-
*
|
|
416
|
+
* Interface representing the base structure of an event.
|
|
523
417
|
*/
|
|
524
|
-
|
|
525
|
-
readonly clientId: string;
|
|
526
|
-
readonly callbacks: Partial<IHistoryInstanceCallbacks>;
|
|
527
|
-
private _array;
|
|
418
|
+
interface IBaseEvent {
|
|
528
419
|
/**
|
|
529
|
-
*
|
|
530
|
-
* @param agentName - The agent name.
|
|
420
|
+
* The source of the event.
|
|
531
421
|
*/
|
|
532
|
-
|
|
422
|
+
source: EventSource;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
interface IBus {
|
|
426
|
+
emit<T extends IBaseEvent>(clientId: string, event: T): Promise<void>;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
interface ISwarmSessionCallbacks {
|
|
533
430
|
/**
|
|
534
|
-
*
|
|
535
|
-
* @param clientId - The client
|
|
536
|
-
* @param
|
|
431
|
+
* Callback triggered when a client connects.
|
|
432
|
+
* @param clientId - The ID of the client.
|
|
433
|
+
* @param swarmName - The name of the swarm.
|
|
537
434
|
*/
|
|
538
|
-
|
|
435
|
+
onConnect?: (clientId: string, swarmName: SwarmName) => void;
|
|
539
436
|
/**
|
|
540
|
-
*
|
|
541
|
-
* @param
|
|
542
|
-
* @
|
|
437
|
+
* Callback triggered when a command is executed.
|
|
438
|
+
* @param clientId - The ID of the client.
|
|
439
|
+
* @param swarmName - The name of the swarm.
|
|
440
|
+
* @param content - The content to execute.
|
|
441
|
+
* @param mode - The source of execution: tool or user.
|
|
543
442
|
*/
|
|
544
|
-
|
|
443
|
+
onExecute?: (clientId: string, swarmName: SwarmName, content: string, mode: ExecutionMode) => void;
|
|
545
444
|
/**
|
|
546
|
-
*
|
|
547
|
-
* @param
|
|
548
|
-
* @param
|
|
549
|
-
* @
|
|
445
|
+
* Callback triggered when a message is emitted.
|
|
446
|
+
* @param clientId - The ID of the client.
|
|
447
|
+
* @param swarmName - The name of the swarm.
|
|
448
|
+
* @param message - The message to emit.
|
|
550
449
|
*/
|
|
551
|
-
|
|
450
|
+
onEmit?: (clientId: string, swarmName: SwarmName, message: string) => void;
|
|
552
451
|
/**
|
|
553
|
-
*
|
|
554
|
-
* @param
|
|
555
|
-
* @
|
|
452
|
+
* Callback triggered when a session being connected
|
|
453
|
+
* @param clientId - The ID of the client.
|
|
454
|
+
* @param swarmName - The name of the swarm.
|
|
556
455
|
*/
|
|
557
|
-
|
|
456
|
+
onInit?: (clientId: string, swarmName: SwarmName) => void;
|
|
457
|
+
/**
|
|
458
|
+
* Callback triggered when a session being disponnected
|
|
459
|
+
* @param clientId - The ID of the client.
|
|
460
|
+
* @param swarmName - The name of the swarm.
|
|
461
|
+
*/
|
|
462
|
+
onDispose?: (clientId: string, swarmName: SwarmName) => void;
|
|
558
463
|
}
|
|
559
464
|
/**
|
|
560
|
-
*
|
|
465
|
+
* Lifecycle callbacks of initialized swarm
|
|
561
466
|
*/
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
467
|
+
interface ISwarmCallbacks extends ISwarmSessionCallbacks {
|
|
468
|
+
/** Emit the callback on agent change */
|
|
469
|
+
onAgentChanged: (clientId: string, agentName: AgentName, swarmName: SwarmName) => Promise<void>;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Parameters for initializing a swarm.
|
|
473
|
+
* @interface
|
|
474
|
+
* @extends {Omit<ISwarmSchema, 'agentList'>}
|
|
475
|
+
*/
|
|
476
|
+
interface ISwarmParams extends Omit<ISwarmSchema, keyof {
|
|
477
|
+
agentList: never;
|
|
478
|
+
onAgentChanged: never;
|
|
479
|
+
}>, ISwarmCallbacks {
|
|
480
|
+
/** Client identifier */
|
|
481
|
+
clientId: string;
|
|
482
|
+
/** Logger instance */
|
|
483
|
+
logger: ILogger;
|
|
484
|
+
/** The bus instance. */
|
|
485
|
+
bus: IBus;
|
|
486
|
+
/** Map of agent names to agent instances */
|
|
487
|
+
agentMap: Record<AgentName, IAgent>;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Schema for defining a swarm.
|
|
491
|
+
* @interface
|
|
492
|
+
*/
|
|
493
|
+
interface ISwarmSchema {
|
|
494
|
+
/** Default agent name */
|
|
495
|
+
defaultAgent: AgentName;
|
|
496
|
+
/** Name of the swarm */
|
|
497
|
+
swarmName: string;
|
|
498
|
+
/** List of agent names */
|
|
499
|
+
agentList: string[];
|
|
500
|
+
/** Lifecycle callbacks*/
|
|
501
|
+
callbacks?: Partial<ISwarmCallbacks>;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Interface for a swarm.
|
|
505
|
+
* @interface
|
|
506
|
+
*/
|
|
507
|
+
interface ISwarm {
|
|
566
508
|
/**
|
|
567
|
-
*
|
|
568
|
-
* @
|
|
509
|
+
* Will return empty string in waitForOutput
|
|
510
|
+
* @returns {Promise<void>}
|
|
569
511
|
*/
|
|
570
|
-
|
|
512
|
+
cancelOutput(): Promise<void>;
|
|
571
513
|
/**
|
|
572
|
-
*
|
|
573
|
-
* @
|
|
514
|
+
* Waits for the output from the swarm.
|
|
515
|
+
* @returns {Promise<string>} The output from the swarm.
|
|
574
516
|
*/
|
|
575
|
-
|
|
517
|
+
waitForOutput(): Promise<string>;
|
|
576
518
|
/**
|
|
577
|
-
*
|
|
578
|
-
* @
|
|
579
|
-
* @param agentName - The agent name.
|
|
580
|
-
* @returns An async iterable iterator of model messages.
|
|
519
|
+
* Gets the name of the agent.
|
|
520
|
+
* @returns {Promise<AgentName>} The name of the agent.
|
|
581
521
|
*/
|
|
582
|
-
|
|
522
|
+
getAgentName(): Promise<AgentName>;
|
|
583
523
|
/**
|
|
584
|
-
*
|
|
585
|
-
* @
|
|
586
|
-
* @param clientId - The client ID.
|
|
587
|
-
* @param agentName - The agent name.
|
|
588
|
-
* @returns A promise that resolves when the message is pushed.
|
|
524
|
+
* Gets the agent instance.
|
|
525
|
+
* @returns {Promise<IAgent>} The agent instance.
|
|
589
526
|
*/
|
|
590
|
-
|
|
527
|
+
getAgent(): Promise<IAgent>;
|
|
591
528
|
/**
|
|
592
|
-
*
|
|
593
|
-
* @param
|
|
594
|
-
* @param
|
|
595
|
-
* @returns
|
|
529
|
+
* Sets the reference to an agent.
|
|
530
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
531
|
+
* @param {IAgent} agent - The agent instance.
|
|
532
|
+
* @returns {Promise<void>}
|
|
596
533
|
*/
|
|
597
|
-
|
|
534
|
+
setAgentRef(agentName: AgentName, agent: IAgent): Promise<void>;
|
|
535
|
+
/**
|
|
536
|
+
* Sets the name of the agent.
|
|
537
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
538
|
+
* @returns {Promise<void>}
|
|
539
|
+
*/
|
|
540
|
+
setAgentName(agentName: AgentName): Promise<void>;
|
|
598
541
|
}
|
|
542
|
+
/** Type alias for swarm name */
|
|
543
|
+
type SwarmName = string;
|
|
544
|
+
|
|
599
545
|
/**
|
|
600
|
-
*
|
|
546
|
+
* Parameters required to create a session.
|
|
547
|
+
* @interface
|
|
601
548
|
*/
|
|
602
|
-
|
|
549
|
+
interface ISessionParams extends ISessionSchema, ISwarmSessionCallbacks {
|
|
550
|
+
clientId: string;
|
|
551
|
+
logger: ILogger;
|
|
552
|
+
bus: IBus;
|
|
553
|
+
swarm: ISwarm;
|
|
554
|
+
swarmName: SwarmName;
|
|
555
|
+
}
|
|
603
556
|
/**
|
|
604
|
-
*
|
|
557
|
+
* Schema for session data.
|
|
558
|
+
* @interface
|
|
605
559
|
*/
|
|
606
|
-
|
|
607
|
-
|
|
560
|
+
interface ISessionSchema {
|
|
561
|
+
}
|
|
608
562
|
/**
|
|
609
|
-
*
|
|
563
|
+
* Function type for sending messages.
|
|
564
|
+
* @typedef {function} SendMessageFn
|
|
565
|
+
* @param {IOutgoingMessage} outgoing - The outgoing message.
|
|
566
|
+
* @returns {Promise<void> | void}
|
|
610
567
|
*/
|
|
611
|
-
|
|
568
|
+
type SendMessageFn$1 = (outgoing: IOutgoingMessage) => Promise<void> | void;
|
|
569
|
+
/**
|
|
570
|
+
* Function type for receiving messages.
|
|
571
|
+
* @typedef {function} ReceiveMessageFn
|
|
572
|
+
* @param {IIncomingMessage} incoming - The incoming message.
|
|
573
|
+
* @returns {Promise<void> | void}
|
|
574
|
+
*/
|
|
575
|
+
type ReceiveMessageFn = (incoming: IIncomingMessage) => Promise<void> | void;
|
|
576
|
+
/**
|
|
577
|
+
* Interface for a session.
|
|
578
|
+
* @interface
|
|
579
|
+
*/
|
|
580
|
+
interface ISession {
|
|
612
581
|
/**
|
|
613
|
-
*
|
|
614
|
-
* @param {
|
|
582
|
+
* Emit a message.
|
|
583
|
+
* @param {string} message - The message to emit.
|
|
615
584
|
* @returns {Promise<void>}
|
|
616
585
|
*/
|
|
617
|
-
|
|
586
|
+
emit(message: string): Promise<void>;
|
|
618
587
|
/**
|
|
619
|
-
*
|
|
620
|
-
* @param {string}
|
|
621
|
-
* @
|
|
588
|
+
* Execute a command.
|
|
589
|
+
* @param {string} content - The content to execute.
|
|
590
|
+
* @param {string} mode - The source of execution: tool or user
|
|
591
|
+
* @returns {Promise<string>}
|
|
622
592
|
*/
|
|
623
|
-
|
|
593
|
+
execute(content: string, mode: ExecutionMode): Promise<string>;
|
|
624
594
|
/**
|
|
625
|
-
*
|
|
626
|
-
* @
|
|
595
|
+
* Connect to a message sender.
|
|
596
|
+
* @param {SendMessageFn} connector - The function to send messages.
|
|
597
|
+
* @returns {ReceiveMessageFn}
|
|
627
598
|
*/
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Interface representing the parameters required to create a history instance.
|
|
632
|
-
*/
|
|
633
|
-
interface IHistoryParams extends IHistorySchema {
|
|
599
|
+
connect(connector: SendMessageFn$1): ReceiveMessageFn;
|
|
634
600
|
/**
|
|
635
|
-
*
|
|
636
|
-
* @
|
|
601
|
+
* Commit tool output.
|
|
602
|
+
* @param {string} toolId - The `tool_call_id` for openai history
|
|
603
|
+
* @param {string} content - The content to commit.
|
|
604
|
+
* @returns {Promise<void>}
|
|
637
605
|
*/
|
|
638
|
-
|
|
606
|
+
commitToolOutput(toolId: string, content: string): Promise<void>;
|
|
639
607
|
/**
|
|
640
|
-
*
|
|
641
|
-
* @
|
|
608
|
+
* Commit user message without answer
|
|
609
|
+
* @param {string} message - The message to commit.
|
|
610
|
+
* @returns {Promise<void>}
|
|
642
611
|
*/
|
|
643
|
-
|
|
612
|
+
commitUserMessage: (message: string) => Promise<void>;
|
|
644
613
|
/**
|
|
645
|
-
*
|
|
646
|
-
* @
|
|
614
|
+
* Commit flush of agent history
|
|
615
|
+
* @returns {Promise<void>}
|
|
647
616
|
*/
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* Interface representing the schema of the history.
|
|
652
|
-
*/
|
|
653
|
-
interface IHistorySchema {
|
|
617
|
+
commitFlush: () => Promise<void>;
|
|
654
618
|
/**
|
|
655
|
-
*
|
|
656
|
-
* @
|
|
619
|
+
* Commit a system message.
|
|
620
|
+
* @param {string} message - The message to commit.
|
|
621
|
+
* @returns {Promise<void>}
|
|
657
622
|
*/
|
|
658
|
-
|
|
623
|
+
commitSystemMessage(message: string): Promise<void>;
|
|
659
624
|
}
|
|
660
|
-
|
|
661
625
|
/**
|
|
662
|
-
*
|
|
626
|
+
* Type for session ID.
|
|
627
|
+
* @typedef {string} SessionId
|
|
663
628
|
*/
|
|
664
|
-
|
|
665
|
-
}
|
|
629
|
+
type SessionId = string;
|
|
666
630
|
/**
|
|
667
|
-
*
|
|
631
|
+
* Type for session mode.
|
|
632
|
+
* @typedef {"session" | "makeConnection" | "complete"} SessionMode
|
|
668
633
|
*/
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
634
|
+
type SessionMode = "session" | "makeConnection" | "complete";
|
|
635
|
+
/**
|
|
636
|
+
* Tools can emit user messages to trigger user friendly responses.
|
|
637
|
+
* Should be ignored for `getUserHistory`
|
|
638
|
+
* @typedef {"tool" | "user"} ExecutionMode
|
|
639
|
+
*/
|
|
640
|
+
type ExecutionMode = "tool" | "user";
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Represents a tool call with a function name and arguments.
|
|
644
|
+
*/
|
|
645
|
+
interface IToolCall {
|
|
678
646
|
/**
|
|
679
|
-
* The
|
|
647
|
+
* The ID of the tool call.
|
|
680
648
|
*/
|
|
681
|
-
|
|
649
|
+
id: string;
|
|
682
650
|
/**
|
|
683
|
-
*
|
|
651
|
+
* The type of the tool. Currently, only `function` is supported.
|
|
684
652
|
*/
|
|
685
|
-
|
|
653
|
+
type: 'function';
|
|
686
654
|
/**
|
|
687
|
-
*
|
|
655
|
+
* The function that the model called.
|
|
688
656
|
*/
|
|
689
|
-
|
|
657
|
+
function: {
|
|
658
|
+
/**
|
|
659
|
+
* The name of the function to be called.
|
|
660
|
+
*/
|
|
661
|
+
name: string;
|
|
662
|
+
/**
|
|
663
|
+
* The arguments to be passed to the function.
|
|
664
|
+
*/
|
|
665
|
+
arguments: {
|
|
666
|
+
[key: string]: any;
|
|
667
|
+
};
|
|
668
|
+
};
|
|
690
669
|
}
|
|
691
670
|
/**
|
|
692
|
-
*
|
|
671
|
+
* Represents a tool with a type and function details.
|
|
693
672
|
*/
|
|
694
|
-
interface
|
|
673
|
+
interface ITool {
|
|
695
674
|
/**
|
|
696
|
-
*
|
|
697
|
-
* @param args - Arguments passed to complete
|
|
698
|
-
* @param output - Output of the model
|
|
675
|
+
* The type of the tool.
|
|
699
676
|
*/
|
|
700
|
-
|
|
677
|
+
type: string;
|
|
678
|
+
function: {
|
|
679
|
+
/**
|
|
680
|
+
* The name of the function.
|
|
681
|
+
*/
|
|
682
|
+
name: string;
|
|
683
|
+
/**
|
|
684
|
+
* The description of the function.
|
|
685
|
+
*/
|
|
686
|
+
description: string;
|
|
687
|
+
/**
|
|
688
|
+
* The parameters required by the function.
|
|
689
|
+
*/
|
|
690
|
+
parameters: {
|
|
691
|
+
/**
|
|
692
|
+
* The type of the parameters.
|
|
693
|
+
*/
|
|
694
|
+
type: string;
|
|
695
|
+
/**
|
|
696
|
+
* The list of required parameters.
|
|
697
|
+
*/
|
|
698
|
+
required: string[];
|
|
699
|
+
/**
|
|
700
|
+
* The properties of the parameters.
|
|
701
|
+
*/
|
|
702
|
+
properties: {
|
|
703
|
+
[key: string]: {
|
|
704
|
+
/**
|
|
705
|
+
* The type of the property.
|
|
706
|
+
*/
|
|
707
|
+
type: string;
|
|
708
|
+
/**
|
|
709
|
+
* The description of the property.
|
|
710
|
+
*/
|
|
711
|
+
description: string;
|
|
712
|
+
/**
|
|
713
|
+
* The possible values for the property.
|
|
714
|
+
*/
|
|
715
|
+
enum?: string[];
|
|
716
|
+
};
|
|
717
|
+
};
|
|
718
|
+
};
|
|
719
|
+
};
|
|
701
720
|
}
|
|
721
|
+
|
|
702
722
|
/**
|
|
703
|
-
*
|
|
723
|
+
* Interface representing a model message.
|
|
704
724
|
*/
|
|
705
|
-
interface
|
|
725
|
+
interface IModelMessage {
|
|
706
726
|
/**
|
|
707
|
-
*
|
|
727
|
+
* The role of the message sender.
|
|
728
|
+
* @type {'assistant' | 'system' | 'tool' | 'user' | 'resque' | 'flush'}
|
|
708
729
|
*/
|
|
709
|
-
|
|
730
|
+
role: "assistant" | "system" | "tool" | "user" | "resque" | "flush";
|
|
710
731
|
/**
|
|
711
|
-
*
|
|
712
|
-
* @
|
|
713
|
-
* @returns A promise that resolves to a model message.
|
|
732
|
+
* The name of the agent sending the message.
|
|
733
|
+
* @type {string}
|
|
714
734
|
*/
|
|
715
|
-
|
|
735
|
+
agentName: string;
|
|
716
736
|
/**
|
|
717
|
-
*
|
|
737
|
+
* The content of the message.
|
|
738
|
+
* @type {string}
|
|
718
739
|
*/
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
/**
|
|
722
|
-
* Type representing the name of a completion.
|
|
723
|
-
*/
|
|
724
|
-
type CompletionName = string;
|
|
725
|
-
|
|
726
|
-
/**
|
|
727
|
-
* Type representing an array of numbers as embeddings.
|
|
728
|
-
*/
|
|
729
|
-
type Embeddings = number[];
|
|
730
|
-
/**
|
|
731
|
-
* Interface for embedding callbacks.
|
|
732
|
-
*/
|
|
733
|
-
interface IEmbeddingCallbacks {
|
|
740
|
+
content: string;
|
|
734
741
|
/**
|
|
735
|
-
*
|
|
736
|
-
* @
|
|
737
|
-
* @param embeddings - The generated embeddings.
|
|
738
|
-
* @param clientId - The client ID associated with the embedding.
|
|
739
|
-
* @param embeddingName - The name of the embedding.
|
|
742
|
+
* The source of message: tool or user
|
|
743
|
+
* @type {ExecutionMode}
|
|
740
744
|
*/
|
|
741
|
-
|
|
745
|
+
mode: ExecutionMode;
|
|
746
|
+
/**
|
|
747
|
+
* Optional tool calls associated with the message.
|
|
748
|
+
* @type {Array<{ function: { name: string; arguments: { [key: string]: any; }; }; }>}
|
|
749
|
+
*/
|
|
750
|
+
tool_calls?: IToolCall[];
|
|
742
751
|
/**
|
|
743
|
-
*
|
|
744
|
-
* @param text1 - The first text used in the comparison.
|
|
745
|
-
* @param text2 - The second text used in the comparison.
|
|
746
|
-
* @param similarity - The similarity score between the embeddings.
|
|
747
|
-
* @param clientId - The client ID associated with the comparison.
|
|
748
|
-
* @param embeddingName - The name of the embedding.
|
|
752
|
+
* Tool call that this message is responding to.
|
|
749
753
|
*/
|
|
750
|
-
|
|
754
|
+
tool_call_id?: string;
|
|
751
755
|
}
|
|
756
|
+
|
|
752
757
|
/**
|
|
753
|
-
* Interface
|
|
758
|
+
* Interface for History Adapter Callbacks
|
|
754
759
|
*/
|
|
755
|
-
interface
|
|
760
|
+
interface IHistoryInstanceCallbacks {
|
|
756
761
|
/**
|
|
757
|
-
*
|
|
762
|
+
* Filter condition for history messages.
|
|
763
|
+
* @param message - The model message.
|
|
764
|
+
* @param clientId - The client ID.
|
|
765
|
+
* @param agentName - The agent name.
|
|
766
|
+
* @returns A promise that resolves to a boolean indicating whether the message passes the filter.
|
|
758
767
|
*/
|
|
759
|
-
|
|
768
|
+
filterCondition?: (message: IModelMessage, clientId: string, agentName: AgentName) => Promise<boolean> | boolean;
|
|
760
769
|
/**
|
|
761
|
-
*
|
|
762
|
-
* @param
|
|
763
|
-
* @
|
|
770
|
+
* Get data for the history.
|
|
771
|
+
* @param clientId - The client ID.
|
|
772
|
+
* @param agentName - The agent name.
|
|
773
|
+
* @returns A promise that resolves to an array of model messages.
|
|
764
774
|
*/
|
|
765
|
-
|
|
775
|
+
getData: (clientId: string, agentName: AgentName) => Promise<IModelMessage[]> | IModelMessage[];
|
|
766
776
|
/**
|
|
767
|
-
*
|
|
768
|
-
* @param
|
|
769
|
-
* @param
|
|
770
|
-
* @
|
|
777
|
+
* Callback for when the history changes.
|
|
778
|
+
* @param data - The array of model messages.
|
|
779
|
+
* @param clientId - The client ID.
|
|
780
|
+
* @param agentName - The agent name.
|
|
771
781
|
*/
|
|
772
|
-
|
|
782
|
+
onChange: (data: IModelMessage[], clientId: string, agentName: AgentName) => void;
|
|
773
783
|
/**
|
|
774
|
-
*
|
|
784
|
+
* Callback for when the history get the new message
|
|
785
|
+
* @param data - The array of model messages.
|
|
786
|
+
* @param clientId - The client ID.
|
|
787
|
+
* @param agentName - The agent name.
|
|
775
788
|
*/
|
|
776
|
-
|
|
777
|
-
}
|
|
778
|
-
/**
|
|
779
|
-
* Type representing the name of an embedding.
|
|
780
|
-
*/
|
|
781
|
-
type EmbeddingName = string;
|
|
782
|
-
|
|
783
|
-
type StorageId = string | number;
|
|
784
|
-
/**
|
|
785
|
-
* Interface representing the data stored in the storage.
|
|
786
|
-
*/
|
|
787
|
-
interface IStorageData {
|
|
788
|
-
id: StorageId;
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* Interface representing the schema of the storage.
|
|
792
|
-
* @template T - Type of the storage data.
|
|
793
|
-
*/
|
|
794
|
-
interface IStorageSchema<T extends IStorageData = IStorageData> {
|
|
789
|
+
onPush: (data: IModelMessage, clientId: string, agentName: AgentName) => void;
|
|
795
790
|
/**
|
|
796
|
-
*
|
|
791
|
+
* Callback for when the history is read. Will be called for each message
|
|
792
|
+
* @param message - The model message.
|
|
793
|
+
* @param clientId - The client ID.
|
|
794
|
+
* @param agentName - The agent name.
|
|
797
795
|
*/
|
|
798
|
-
|
|
796
|
+
onRead: (message: IModelMessage, clientId: string, agentName: AgentName) => void;
|
|
799
797
|
/**
|
|
800
|
-
*
|
|
798
|
+
* Callback for when the read is begin
|
|
801
799
|
* @param clientId - The client ID.
|
|
802
|
-
* @param
|
|
803
|
-
* @returns A promise that resolves to an array of storage data or an array of storage data.
|
|
800
|
+
* @param agentName - The agent name.
|
|
804
801
|
*/
|
|
805
|
-
|
|
802
|
+
onReadBegin: (clientId: string, agentName: AgentName) => void;
|
|
806
803
|
/**
|
|
807
|
-
*
|
|
808
|
-
* @param
|
|
809
|
-
* @
|
|
804
|
+
* Callback for when the read is end
|
|
805
|
+
* @param clientId - The client ID.
|
|
806
|
+
* @param agentName - The agent name.
|
|
810
807
|
*/
|
|
811
|
-
|
|
808
|
+
onReadEnd: (clientId: string, agentName: AgentName) => void;
|
|
812
809
|
/**
|
|
813
|
-
*
|
|
810
|
+
* Callback for when the history is disposed.
|
|
811
|
+
* @param clientId - The client ID.
|
|
814
812
|
*/
|
|
815
|
-
|
|
813
|
+
onDispose: (clientId: string) => void;
|
|
816
814
|
/**
|
|
817
|
-
*
|
|
815
|
+
* Callback for when the history is initialized.
|
|
816
|
+
* @param clientId - The client ID.
|
|
818
817
|
*/
|
|
819
|
-
|
|
818
|
+
onInit: (clientId: string) => void;
|
|
820
819
|
/**
|
|
821
|
-
*
|
|
820
|
+
* Callback to obtain history ref
|
|
821
|
+
* @param clientId - The client ID.
|
|
822
822
|
*/
|
|
823
|
-
|
|
823
|
+
onRef: (history: HistoryInstance) => void;
|
|
824
824
|
}
|
|
825
825
|
/**
|
|
826
|
-
* Interface
|
|
827
|
-
* @template T - Type of the storage data.
|
|
826
|
+
* Interface for History Adapter
|
|
828
827
|
*/
|
|
829
|
-
interface
|
|
830
|
-
/**
|
|
831
|
-
* Callback function for update events.
|
|
832
|
-
* @param items - The updated items.
|
|
833
|
-
* @param clientId - The client ID.
|
|
834
|
-
* @param storageName - The name of the storage.
|
|
835
|
-
*/
|
|
836
|
-
onUpdate: (items: T[], clientId: string, storageName: StorageName) => void;
|
|
828
|
+
interface IHistoryAdapter {
|
|
837
829
|
/**
|
|
838
|
-
*
|
|
839
|
-
* @param search - The search query.
|
|
840
|
-
* @param index - The sorted array of storage data.
|
|
830
|
+
* Iterate over the history messages.
|
|
841
831
|
* @param clientId - The client ID.
|
|
842
|
-
* @param
|
|
832
|
+
* @param agentName - The agent name.
|
|
833
|
+
* @returns An async iterable iterator of model messages.
|
|
843
834
|
*/
|
|
844
|
-
|
|
835
|
+
iterate(clientId: string, agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
845
836
|
/**
|
|
846
|
-
*
|
|
837
|
+
* Push a new message to the history.
|
|
838
|
+
* @param value - The model message to push.
|
|
847
839
|
* @param clientId - The client ID.
|
|
848
|
-
* @param
|
|
840
|
+
* @param agentName - The agent name.
|
|
841
|
+
* @returns A promise that resolves when the message is pushed.
|
|
849
842
|
*/
|
|
850
|
-
|
|
843
|
+
push: (value: IModelMessage, clientId: string, agentName: AgentName) => Promise<void>;
|
|
851
844
|
/**
|
|
852
|
-
*
|
|
845
|
+
* Dispose of the history for a given client and agent.
|
|
853
846
|
* @param clientId - The client ID.
|
|
854
|
-
* @param
|
|
847
|
+
* @param agentName - The agent name or null.
|
|
848
|
+
* @returns A promise that resolves when the history is disposed.
|
|
855
849
|
*/
|
|
856
|
-
|
|
850
|
+
dispose: (clientId: string, agentName: AgentName | null) => Promise<void>;
|
|
857
851
|
}
|
|
858
852
|
/**
|
|
859
|
-
* Interface
|
|
860
|
-
* @template T - Type of the storage data.
|
|
853
|
+
* Interface for History Control
|
|
861
854
|
*/
|
|
862
|
-
interface
|
|
855
|
+
interface IHistoryControl {
|
|
863
856
|
/**
|
|
864
|
-
*
|
|
857
|
+
* Use a custom history adapter.
|
|
858
|
+
* @param Ctor - The constructor for the history instance.
|
|
865
859
|
*/
|
|
866
|
-
|
|
860
|
+
useHistoryAdapter(Ctor: THistoryInstanceCtor): void;
|
|
867
861
|
/**
|
|
868
|
-
*
|
|
862
|
+
* Use history lifecycle callbacks.
|
|
863
|
+
* @param Callbacks - The callbacks dictionary.
|
|
869
864
|
*/
|
|
870
|
-
|
|
865
|
+
useHistoryCallbacks: (Callbacks: Partial<IHistoryInstanceCallbacks>) => void;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Interface for History Instance
|
|
869
|
+
*/
|
|
870
|
+
interface IHistoryInstance {
|
|
871
871
|
/**
|
|
872
|
-
*
|
|
872
|
+
* Iterate over the history messages for a given agent.
|
|
873
|
+
* @param agentName - The agent name.
|
|
874
|
+
* @returns An async iterable iterator of model messages.
|
|
873
875
|
*/
|
|
874
|
-
|
|
876
|
+
iterate(agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
875
877
|
/**
|
|
876
|
-
*
|
|
878
|
+
* Wait for the history to initialize.
|
|
879
|
+
* @param agentName - The agent name.
|
|
880
|
+
* @param init - Whether the history is initializing.
|
|
881
|
+
* @returns A promise that resolves when the history is initialized.
|
|
877
882
|
*/
|
|
878
|
-
|
|
883
|
+
waitForInit(agentName: AgentName, init: boolean): Promise<void>;
|
|
879
884
|
/**
|
|
880
|
-
*
|
|
885
|
+
* Push a new message to the history for a given agent.
|
|
886
|
+
* @param value - The model message to push.
|
|
887
|
+
* @param agentName - The agent name.
|
|
888
|
+
* @returns A promise that resolves when the message is pushed.
|
|
881
889
|
*/
|
|
882
|
-
|
|
890
|
+
push(value: IModelMessage, agentName: AgentName): Promise<void>;
|
|
891
|
+
/**
|
|
892
|
+
* Dispose of the history for a given agent.
|
|
893
|
+
* @param agentName - The agent name or null.
|
|
894
|
+
* @returns A promise that resolves when the history is disposed.
|
|
895
|
+
*/
|
|
896
|
+
dispose(agentName: AgentName | null): Promise<void>;
|
|
883
897
|
}
|
|
884
898
|
/**
|
|
885
|
-
*
|
|
886
|
-
* @template T - Type of the storage data.
|
|
899
|
+
* Type for History Instance Constructor
|
|
887
900
|
*/
|
|
888
|
-
|
|
901
|
+
type THistoryInstanceCtor = new (clientId: string, ...args: unknown[]) => IHistoryInstance;
|
|
902
|
+
/**
|
|
903
|
+
* Class representing a History Instance
|
|
904
|
+
*/
|
|
905
|
+
declare class HistoryInstance implements IHistoryInstance {
|
|
906
|
+
readonly clientId: string;
|
|
907
|
+
readonly callbacks: Partial<IHistoryInstanceCallbacks>;
|
|
908
|
+
private _array;
|
|
889
909
|
/**
|
|
890
|
-
*
|
|
891
|
-
* @param
|
|
892
|
-
* @param total - The total number of items to take.
|
|
893
|
-
* @param score - Optional score parameter.
|
|
894
|
-
* @returns A promise that resolves to an array of storage data.
|
|
910
|
+
* Wait for the history to initialize.
|
|
911
|
+
* @param agentName - The agent name.
|
|
895
912
|
*/
|
|
896
|
-
|
|
913
|
+
waitForInit: ((agentName: AgentName) => Promise<void>) & functools_kit.ISingleshotClearable;
|
|
897
914
|
/**
|
|
898
|
-
*
|
|
899
|
-
* @param
|
|
900
|
-
* @
|
|
915
|
+
* Create a HistoryInstance.
|
|
916
|
+
* @param clientId - The client ID.
|
|
917
|
+
* @param callbacks - The callbacks for the history instance.
|
|
901
918
|
*/
|
|
902
|
-
|
|
919
|
+
constructor(clientId: string, callbacks: Partial<IHistoryInstanceCallbacks>);
|
|
903
920
|
/**
|
|
904
|
-
*
|
|
905
|
-
* @param
|
|
906
|
-
* @returns
|
|
921
|
+
* Iterate over the history messages for a given agent.
|
|
922
|
+
* @param agentName - The agent name.
|
|
923
|
+
* @returns An async iterable iterator of model messages.
|
|
907
924
|
*/
|
|
908
|
-
|
|
925
|
+
iterate(agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
909
926
|
/**
|
|
910
|
-
*
|
|
911
|
-
* @param
|
|
912
|
-
* @
|
|
927
|
+
* Push a new message to the history for a given agent.
|
|
928
|
+
* @param value - The model message to push.
|
|
929
|
+
* @param agentName - The agent name.
|
|
930
|
+
* @returns A promise that resolves when the message is pushed.
|
|
931
|
+
*/
|
|
932
|
+
push: (value: IModelMessage, agentName: AgentName) => Promise<void>;
|
|
933
|
+
/**
|
|
934
|
+
* Dispose of the history for a given agent.
|
|
935
|
+
* @param agentName - The agent name or null.
|
|
936
|
+
* @returns A promise that resolves when the history is disposed.
|
|
937
|
+
*/
|
|
938
|
+
dispose: (agentName: AgentName | null) => Promise<void>;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Class representing History Utilities
|
|
942
|
+
*/
|
|
943
|
+
declare class HistoryUtils implements IHistoryAdapter, IHistoryControl {
|
|
944
|
+
private HistoryFactory;
|
|
945
|
+
private HistoryCallbacks;
|
|
946
|
+
private getHistory;
|
|
947
|
+
/**
|
|
948
|
+
* Use a custom history adapter.
|
|
949
|
+
* @param Ctor - The constructor for the history instance.
|
|
950
|
+
*/
|
|
951
|
+
useHistoryAdapter: (Ctor: THistoryInstanceCtor) => void;
|
|
952
|
+
/**
|
|
953
|
+
* Use history lifecycle callbacks.
|
|
954
|
+
* @param Callbacks - The callbacks dictionary.
|
|
955
|
+
*/
|
|
956
|
+
useHistoryCallbacks: (Callbacks: Partial<IHistoryInstanceCallbacks>) => void;
|
|
957
|
+
/**
|
|
958
|
+
* Iterate over the history messages.
|
|
959
|
+
* @param clientId - The client ID.
|
|
960
|
+
* @param agentName - The agent name.
|
|
961
|
+
* @returns An async iterable iterator of model messages.
|
|
913
962
|
*/
|
|
914
|
-
|
|
963
|
+
iterate(clientId: string, agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
915
964
|
/**
|
|
916
|
-
*
|
|
917
|
-
* @param
|
|
918
|
-
* @
|
|
965
|
+
* Push a new message to the history.
|
|
966
|
+
* @param value - The model message to push.
|
|
967
|
+
* @param clientId - The client ID.
|
|
968
|
+
* @param agentName - The agent name.
|
|
969
|
+
* @returns A promise that resolves when the message is pushed.
|
|
919
970
|
*/
|
|
920
|
-
|
|
971
|
+
push: (value: IModelMessage, clientId: string, agentName: AgentName) => Promise<void>;
|
|
921
972
|
/**
|
|
922
|
-
*
|
|
923
|
-
* @
|
|
973
|
+
* Dispose of the history for a given client and agent.
|
|
974
|
+
* @param clientId - The client ID.
|
|
975
|
+
* @param agentName - The agent name or null.
|
|
976
|
+
* @returns A promise that resolves when the history is disposed.
|
|
924
977
|
*/
|
|
925
|
-
|
|
978
|
+
dispose: (clientId: string, agentName: AgentName | null) => Promise<void>;
|
|
926
979
|
}
|
|
927
980
|
/**
|
|
928
|
-
*
|
|
981
|
+
* Exported History Adapter instance
|
|
929
982
|
*/
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
type IStateData = any;
|
|
983
|
+
declare const HistoryAdapter: HistoryUtils;
|
|
933
984
|
/**
|
|
934
|
-
*
|
|
935
|
-
* @template T - The type of the state data.
|
|
936
|
-
* @param {T} state - The current state.
|
|
937
|
-
* @param {string} clientId - The client ID.
|
|
938
|
-
* @param {StateName} stateName - The name of the state.
|
|
939
|
-
* @returns {Promise<T>} - The updated state.
|
|
985
|
+
* Exported History Control instance
|
|
940
986
|
*/
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}
|
|
987
|
+
declare const History: IHistoryControl;
|
|
988
|
+
|
|
944
989
|
/**
|
|
945
|
-
*
|
|
946
|
-
* @template T - The type of the state data.
|
|
990
|
+
* Interface representing the history of model messages.
|
|
947
991
|
*/
|
|
948
|
-
interface
|
|
992
|
+
interface IHistory {
|
|
949
993
|
/**
|
|
950
|
-
*
|
|
951
|
-
* @param {
|
|
952
|
-
* @
|
|
994
|
+
* Pushes a message to the history.
|
|
995
|
+
* @param {IModelMessage} message - The message to push.
|
|
996
|
+
* @returns {Promise<void>}
|
|
953
997
|
*/
|
|
954
|
-
|
|
998
|
+
push(message: IModelMessage): Promise<void>;
|
|
955
999
|
/**
|
|
956
|
-
*
|
|
957
|
-
* @param {string}
|
|
958
|
-
* @
|
|
1000
|
+
* Converts the history to an array of messages for a specific agent.
|
|
1001
|
+
* @param {string} prompt - The prompt to filter messages for the agent.
|
|
1002
|
+
* @returns {Promise<IModelMessage[]>}
|
|
959
1003
|
*/
|
|
960
|
-
|
|
1004
|
+
toArrayForAgent(prompt: string, system?: string[]): Promise<IModelMessage[]>;
|
|
961
1005
|
/**
|
|
962
|
-
*
|
|
963
|
-
* @
|
|
964
|
-
* @param {string} clientId - The client ID.
|
|
965
|
-
* @param {StateName} stateName - The name of the state.
|
|
1006
|
+
* Converts the history to an array of raw messages.
|
|
1007
|
+
* @returns {Promise<IModelMessage[]>}
|
|
966
1008
|
*/
|
|
967
|
-
|
|
1009
|
+
toArrayForRaw(): Promise<IModelMessage[]>;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Interface representing the parameters required to create a history instance.
|
|
1013
|
+
*/
|
|
1014
|
+
interface IHistoryParams extends IHistorySchema {
|
|
968
1015
|
/**
|
|
969
|
-
*
|
|
970
|
-
* @
|
|
971
|
-
* @param {string} clientId - The client ID.
|
|
972
|
-
* @param {StateName} stateName - The name of the state.
|
|
1016
|
+
* The name of the agent.
|
|
1017
|
+
* @type {AgentName}
|
|
973
1018
|
*/
|
|
974
|
-
|
|
1019
|
+
agentName: AgentName;
|
|
975
1020
|
/**
|
|
976
|
-
*
|
|
977
|
-
* @
|
|
978
|
-
* @param {string} clientId - The client ID.
|
|
979
|
-
* @param {StateName} stateName - The name of the state.
|
|
1021
|
+
* The client ID.
|
|
1022
|
+
* @type {string}
|
|
980
1023
|
*/
|
|
981
|
-
|
|
1024
|
+
clientId: string;
|
|
1025
|
+
/**
|
|
1026
|
+
* The logger instance.
|
|
1027
|
+
* @type {ILogger}
|
|
1028
|
+
*/
|
|
1029
|
+
logger: ILogger;
|
|
1030
|
+
/** The bus instance. */
|
|
1031
|
+
bus: IBus;
|
|
982
1032
|
}
|
|
983
1033
|
/**
|
|
984
|
-
*
|
|
985
|
-
* @template T - The type of the state data.
|
|
1034
|
+
* Interface representing the schema of the history.
|
|
986
1035
|
*/
|
|
987
|
-
interface
|
|
1036
|
+
interface IHistorySchema {
|
|
988
1037
|
/**
|
|
989
|
-
* The
|
|
1038
|
+
* The adapter for array of model messages.
|
|
1039
|
+
* @type {IHistoryAdapter}
|
|
990
1040
|
*/
|
|
991
|
-
|
|
1041
|
+
items: IHistoryAdapter;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Interface representing a completion.
|
|
1046
|
+
*/
|
|
1047
|
+
interface ICompletion extends ICompletionSchema {
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Arguments required to get a completion.
|
|
1051
|
+
*/
|
|
1052
|
+
interface ICompletionArgs {
|
|
992
1053
|
/**
|
|
993
|
-
*
|
|
1054
|
+
* Client ID.
|
|
994
1055
|
*/
|
|
995
|
-
|
|
1056
|
+
clientId: string;
|
|
996
1057
|
/**
|
|
997
|
-
*
|
|
998
|
-
* @param {string} clientId - The client ID.
|
|
999
|
-
* @param {StateName} stateName - The name of the state.
|
|
1000
|
-
* @returns {T | Promise<T>} - The current state.
|
|
1058
|
+
* Name of the agent.
|
|
1001
1059
|
*/
|
|
1002
|
-
|
|
1060
|
+
agentName: AgentName;
|
|
1003
1061
|
/**
|
|
1004
|
-
*
|
|
1005
|
-
* @param {T} state - The new state.
|
|
1006
|
-
* @param {string} clientId - The client ID.
|
|
1007
|
-
* @param {StateName} stateName - The name of the state.
|
|
1008
|
-
* @returns {Promise<void> | void} - A promise that resolves when the state is set.
|
|
1062
|
+
* The source of the last message: tool or user
|
|
1009
1063
|
*/
|
|
1010
|
-
|
|
1064
|
+
mode: ExecutionMode;
|
|
1011
1065
|
/**
|
|
1012
|
-
*
|
|
1066
|
+
* Array of model messages.
|
|
1013
1067
|
*/
|
|
1014
|
-
|
|
1068
|
+
messages: IModelMessage[];
|
|
1015
1069
|
/**
|
|
1016
|
-
*
|
|
1070
|
+
* Optional array of tools.
|
|
1017
1071
|
*/
|
|
1018
|
-
|
|
1072
|
+
tools?: ITool[];
|
|
1019
1073
|
}
|
|
1020
1074
|
/**
|
|
1021
|
-
*
|
|
1022
|
-
* @template T - The type of the state data.
|
|
1075
|
+
* Completion lifecycle callbacks
|
|
1023
1076
|
*/
|
|
1024
|
-
interface
|
|
1025
|
-
/**
|
|
1026
|
-
* The client ID.
|
|
1027
|
-
*/
|
|
1028
|
-
clientId: string;
|
|
1077
|
+
interface ICompletionCallbacks {
|
|
1029
1078
|
/**
|
|
1030
|
-
*
|
|
1079
|
+
* Callback fired after complete.
|
|
1080
|
+
* @param args - Arguments passed to complete
|
|
1081
|
+
* @param output - Output of the model
|
|
1031
1082
|
*/
|
|
1032
|
-
|
|
1083
|
+
onComplete?: (args: ICompletionArgs, output: IModelMessage) => void;
|
|
1033
1084
|
}
|
|
1034
1085
|
/**
|
|
1035
|
-
*
|
|
1036
|
-
* @template T - The type of the state data.
|
|
1086
|
+
* Schema for a completion.
|
|
1037
1087
|
*/
|
|
1038
|
-
interface
|
|
1088
|
+
interface ICompletionSchema {
|
|
1039
1089
|
/**
|
|
1040
|
-
*
|
|
1041
|
-
* @returns {Promise<T>} - The current state.
|
|
1090
|
+
* Name of the completion.
|
|
1042
1091
|
*/
|
|
1043
|
-
|
|
1092
|
+
completionName: CompletionName;
|
|
1044
1093
|
/**
|
|
1045
|
-
*
|
|
1046
|
-
* @param
|
|
1047
|
-
* @returns
|
|
1094
|
+
* Method to get a completion.
|
|
1095
|
+
* @param args - Arguments required to get a completion.
|
|
1096
|
+
* @returns A promise that resolves to a model message.
|
|
1048
1097
|
*/
|
|
1049
|
-
|
|
1098
|
+
getCompletion(args: ICompletionArgs): Promise<IModelMessage>;
|
|
1099
|
+
/**
|
|
1100
|
+
* Completion lifecycle callbacks
|
|
1101
|
+
*/
|
|
1102
|
+
callbacks?: Partial<ICompletionCallbacks>;
|
|
1050
1103
|
}
|
|
1051
1104
|
/**
|
|
1052
|
-
*
|
|
1105
|
+
* Type representing the name of a completion.
|
|
1053
1106
|
*/
|
|
1054
|
-
type
|
|
1107
|
+
type CompletionName = string;
|
|
1055
1108
|
|
|
1056
1109
|
/**
|
|
1057
1110
|
* Interface representing lifecycle callbacks of a tool
|
|
@@ -1144,6 +1197,8 @@ interface IAgentParams extends Omit<IAgentSchema, keyof {
|
|
|
1144
1197
|
clientId: string;
|
|
1145
1198
|
/** The logger instance. */
|
|
1146
1199
|
logger: ILogger;
|
|
1200
|
+
/** The bus instance. */
|
|
1201
|
+
bus: IBus;
|
|
1147
1202
|
/** The history instance. */
|
|
1148
1203
|
history: IHistory;
|
|
1149
1204
|
/** The completion instance. */
|
|
@@ -1445,6 +1500,7 @@ declare class ClientAgent implements IAgent {
|
|
|
1445
1500
|
*/
|
|
1446
1501
|
declare class AgentConnectionService implements IAgent {
|
|
1447
1502
|
private readonly loggerService;
|
|
1503
|
+
private readonly busService;
|
|
1448
1504
|
private readonly contextService;
|
|
1449
1505
|
private readonly sessionValidationService;
|
|
1450
1506
|
private readonly historyConnectionService;
|
|
@@ -1552,6 +1608,7 @@ declare class ClientHistory implements IHistory {
|
|
|
1552
1608
|
*/
|
|
1553
1609
|
declare class HistoryConnectionService implements IHistory {
|
|
1554
1610
|
private readonly loggerService;
|
|
1611
|
+
private readonly busService;
|
|
1555
1612
|
private readonly contextService;
|
|
1556
1613
|
private readonly sessionValidationService;
|
|
1557
1614
|
/**
|
|
@@ -1632,16 +1689,21 @@ declare class ClientSwarm implements ISwarm {
|
|
|
1632
1689
|
readonly params: ISwarmParams;
|
|
1633
1690
|
private _agentChangedSubject;
|
|
1634
1691
|
private _activeAgent;
|
|
1692
|
+
private _cancelOutputSubject;
|
|
1635
1693
|
get _agentList(): [string, IAgent][];
|
|
1636
1694
|
/**
|
|
1637
1695
|
* Creates an instance of ClientSwarm.
|
|
1638
1696
|
* @param {ISwarmParams} params - The parameters for the swarm.
|
|
1639
1697
|
*/
|
|
1640
1698
|
constructor(params: ISwarmParams);
|
|
1699
|
+
/**
|
|
1700
|
+
* Cancel the await of output by emit of empty string
|
|
1701
|
+
* @returns {Promise<string>} - The output from the active agent.
|
|
1702
|
+
*/
|
|
1703
|
+
cancelOutput: () => Promise<void>;
|
|
1641
1704
|
/**
|
|
1642
1705
|
* Waits for output from the active agent.
|
|
1643
1706
|
* @returns {Promise<string>} - The output from the active agent.
|
|
1644
|
-
* @throws {Error} - If the timeout is reached.
|
|
1645
1707
|
*/
|
|
1646
1708
|
waitForOutput: () => Promise<string>;
|
|
1647
1709
|
/**
|
|
@@ -1674,6 +1736,7 @@ declare class ClientSwarm implements ISwarm {
|
|
|
1674
1736
|
*/
|
|
1675
1737
|
declare class SwarmConnectionService implements ISwarm {
|
|
1676
1738
|
private readonly loggerService;
|
|
1739
|
+
private readonly busService;
|
|
1677
1740
|
private readonly contextService;
|
|
1678
1741
|
private readonly agentConnectionService;
|
|
1679
1742
|
private readonly swarmSchemaService;
|
|
@@ -1684,6 +1747,11 @@ declare class SwarmConnectionService implements ISwarm {
|
|
|
1684
1747
|
* @returns {ClientSwarm} The client swarm instance.
|
|
1685
1748
|
*/
|
|
1686
1749
|
getSwarm: ((clientId: string, swarmName: string) => ClientSwarm) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientSwarm>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Cancel the await of output by emit of empty string
|
|
1752
|
+
* @returns {Promise<void>}
|
|
1753
|
+
*/
|
|
1754
|
+
cancelOutput: () => Promise<void>;
|
|
1687
1755
|
/**
|
|
1688
1756
|
* Waits for the output from the swarm.
|
|
1689
1757
|
* @returns {Promise<any>} The output from the swarm.
|
|
@@ -1826,6 +1894,7 @@ declare class ClientSession implements ISession {
|
|
|
1826
1894
|
*/
|
|
1827
1895
|
declare class SessionConnectionService implements ISession {
|
|
1828
1896
|
private readonly loggerService;
|
|
1897
|
+
private readonly busService;
|
|
1829
1898
|
private readonly contextService;
|
|
1830
1899
|
private readonly swarmConnectionService;
|
|
1831
1900
|
private readonly swarmSchemaService;
|
|
@@ -2110,6 +2179,13 @@ type TSwarmConnectionService = {
|
|
|
2110
2179
|
declare class SwarmPublicService implements TSwarmConnectionService {
|
|
2111
2180
|
private readonly loggerService;
|
|
2112
2181
|
private readonly swarmConnectionService;
|
|
2182
|
+
/**
|
|
2183
|
+
* Cancel the await of output by emit of empty string
|
|
2184
|
+
* @param {string} clientId - The client ID.
|
|
2185
|
+
* @param {SwarmName} swarmName - The swarm name.
|
|
2186
|
+
* @returns {Promise<void>}
|
|
2187
|
+
*/
|
|
2188
|
+
cancelOutput: (clientId: string, swarmName: SwarmName) => Promise<void>;
|
|
2113
2189
|
/**
|
|
2114
2190
|
* Waits for output from the swarm.
|
|
2115
2191
|
* @param {string} clientId - The client ID.
|
|
@@ -2511,6 +2587,7 @@ declare class ClientStorage<T extends IStorageData = IStorageData> implements IS
|
|
|
2511
2587
|
*/
|
|
2512
2588
|
declare class StorageConnectionService implements IStorage {
|
|
2513
2589
|
private readonly loggerService;
|
|
2590
|
+
private readonly busService;
|
|
2514
2591
|
private readonly contextService;
|
|
2515
2592
|
private readonly storageSchemaService;
|
|
2516
2593
|
private readonly sessionValidationService;
|
|
@@ -2722,6 +2799,7 @@ declare class ClientState<State extends IStateData = IStateData> implements ISta
|
|
|
2722
2799
|
*/
|
|
2723
2800
|
declare class StateConnectionService<T extends IStateData = IStateData> implements IState<T> {
|
|
2724
2801
|
private readonly loggerService;
|
|
2802
|
+
private readonly busService;
|
|
2725
2803
|
private readonly contextService;
|
|
2726
2804
|
private readonly stateSchemaService;
|
|
2727
2805
|
private readonly sessionValidationService;
|
|
@@ -2813,6 +2891,41 @@ declare class StateSchemaService {
|
|
|
2813
2891
|
get: (key: StateName) => IStateSchema;
|
|
2814
2892
|
}
|
|
2815
2893
|
|
|
2894
|
+
declare class BusService implements IBus {
|
|
2895
|
+
private readonly loggerService;
|
|
2896
|
+
private _eventSourceSet;
|
|
2897
|
+
private getEventSubject;
|
|
2898
|
+
/**
|
|
2899
|
+
* Subscribes to events for a specific client and source.
|
|
2900
|
+
* @param {string} clientId - The client ID.
|
|
2901
|
+
* @param {EventSource} source - The event source.
|
|
2902
|
+
* @param {(event: T) => void} fn - The callback function to handle the event.
|
|
2903
|
+
* @returns {Subscription} The subscription object.
|
|
2904
|
+
*/
|
|
2905
|
+
subscribe: <T extends IBaseEvent>(clientId: string, source: EventSource, fn: (event: T) => void) => () => void;
|
|
2906
|
+
/**
|
|
2907
|
+
* Subscribes to a single event for a specific client and source.
|
|
2908
|
+
* @param {string} clientId - The client ID.
|
|
2909
|
+
* @param {EventSource} source - The event source.
|
|
2910
|
+
* @param {(event: T) => boolean} filterFn - The filter function to determine if the event should be handled.
|
|
2911
|
+
* @param {(event: T) => void} fn - The callback function to handle the event.
|
|
2912
|
+
* @returns {Subscription} The subscription object.
|
|
2913
|
+
*/
|
|
2914
|
+
once: <T extends IBaseEvent>(clientId: string, source: EventSource, filterFn: (event: T) => boolean, fn: (event: T) => void) => () => void;
|
|
2915
|
+
/**
|
|
2916
|
+
* Emits an event for a specific client.
|
|
2917
|
+
* @param {string} clientId - The client ID.
|
|
2918
|
+
* @param {T} event - The event to emit.
|
|
2919
|
+
* @returns {Promise<void>} A promise that resolves when the event has been emitted.
|
|
2920
|
+
*/
|
|
2921
|
+
emit: <T extends IBaseEvent>(clientId: string, event: T) => Promise<void>;
|
|
2922
|
+
/**
|
|
2923
|
+
* Disposes of all event subscriptions for a specific client.
|
|
2924
|
+
* @param {string} clientId - The client ID.
|
|
2925
|
+
*/
|
|
2926
|
+
dispose: (clientId: string) => void;
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2816
2929
|
declare const swarm: {
|
|
2817
2930
|
agentValidationService: AgentValidationService;
|
|
2818
2931
|
toolValidationService: ToolValidationService;
|
|
@@ -2840,6 +2953,7 @@ declare const swarm: {
|
|
|
2840
2953
|
sessionConnectionService: SessionConnectionService;
|
|
2841
2954
|
storageConnectionService: StorageConnectionService;
|
|
2842
2955
|
stateConnectionService: StateConnectionService<any>;
|
|
2956
|
+
busService: BusService;
|
|
2843
2957
|
loggerService: LoggerService;
|
|
2844
2958
|
contextService: {
|
|
2845
2959
|
readonly context: IContext;
|
|
@@ -3174,6 +3288,16 @@ declare const emitForce: (content: string, clientId: string) => Promise<void>;
|
|
|
3174
3288
|
*/
|
|
3175
3289
|
declare const executeForce: (content: string, clientId: string) => Promise<string>;
|
|
3176
3290
|
|
|
3291
|
+
/**
|
|
3292
|
+
* Listens for an event on the swarm bus service and executes a callback function when the event is received.
|
|
3293
|
+
*
|
|
3294
|
+
* @template T - The type of the data payload.
|
|
3295
|
+
* @param {string} clientId - The ID of the client to listen for events from.
|
|
3296
|
+
* @param {(data: T) => void} fn - The callback function to execute when the event is received. The data payload is passed as an argument to this function.
|
|
3297
|
+
* @returns {void} - Returns nothing.
|
|
3298
|
+
*/
|
|
3299
|
+
declare const listenEvent: <T extends unknown = any>(clientId: string, topicName: string, fn: (data: T) => void) => () => void;
|
|
3300
|
+
|
|
3177
3301
|
/**
|
|
3178
3302
|
* Retrieves the last message sent by the user from the client's message history.
|
|
3179
3303
|
*
|
|
@@ -3255,6 +3379,88 @@ declare const makeAutoDispose: (clientId: string, swarmName: SwarmName, { timeou
|
|
|
3255
3379
|
destroy(): void;
|
|
3256
3380
|
};
|
|
3257
3381
|
|
|
3382
|
+
/**
|
|
3383
|
+
* Emits an event to the swarm bus service.
|
|
3384
|
+
*
|
|
3385
|
+
* @template T - The type of the payload.
|
|
3386
|
+
* @param {string} clientId - The ID of the client emitting the event.
|
|
3387
|
+
* @param {T} payload - The payload of the event.
|
|
3388
|
+
* @returns {boolean} - Returns true if the event was successfully emitted.
|
|
3389
|
+
*/
|
|
3390
|
+
declare const event: <T extends unknown = any>(clientId: string, topicName: string, payload: T) => Promise<void>;
|
|
3391
|
+
|
|
3392
|
+
/**
|
|
3393
|
+
* Cancel the await of output by emit of empty string
|
|
3394
|
+
*
|
|
3395
|
+
* @param {string} clientId - The ID of the client.
|
|
3396
|
+
* @param {string} agentName - The name of the agent.
|
|
3397
|
+
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
3398
|
+
*/
|
|
3399
|
+
declare const cancelOutput: (clientId: string, agentName: string) => Promise<void>;
|
|
3400
|
+
|
|
3401
|
+
/**
|
|
3402
|
+
* Cancel the await of output by emit of empty string without checking active agent
|
|
3403
|
+
*
|
|
3404
|
+
* @param {string} clientId - The ID of the client.
|
|
3405
|
+
* @param {string} agentName - The name of the agent.
|
|
3406
|
+
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
3407
|
+
*/
|
|
3408
|
+
declare const cancelOutputForce: (clientId: string) => Promise<void>;
|
|
3409
|
+
|
|
3410
|
+
/**
|
|
3411
|
+
* Hook to subscribe to agent events for a specific client.
|
|
3412
|
+
*
|
|
3413
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
3414
|
+
* @param {function} fn - The callback function to handle the event.
|
|
3415
|
+
* @returns {function} - A function to unsubscribe from the event.
|
|
3416
|
+
*/
|
|
3417
|
+
declare const listenAgentEvent: (clientId: string, fn: (event: IBaseEvent) => void) => () => void;
|
|
3418
|
+
|
|
3419
|
+
/**
|
|
3420
|
+
* Hook to subscribe to history events for a specific client.
|
|
3421
|
+
*
|
|
3422
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
3423
|
+
* @param {(event: IBaseEvent) => void} fn - The callback function to handle the event.
|
|
3424
|
+
* @returns {Function} - The unsubscribe function.
|
|
3425
|
+
*/
|
|
3426
|
+
declare const listenHistoryEvent: (clientId: string, fn: (event: IBaseEvent) => void) => () => void;
|
|
3427
|
+
|
|
3428
|
+
/**
|
|
3429
|
+
* Hook to subscribe to session events for a specific client.
|
|
3430
|
+
*
|
|
3431
|
+
* @param {string} clientId - The ID of the client to subscribe to session events for.
|
|
3432
|
+
* @param {function} fn - The callback function to handle the session events.
|
|
3433
|
+
* @returns {function} - The unsubscribe function to stop listening to session events.
|
|
3434
|
+
*/
|
|
3435
|
+
declare const listenSessionEvent: (clientId: string, fn: (event: IBaseEvent) => void) => () => void;
|
|
3436
|
+
|
|
3437
|
+
/**
|
|
3438
|
+
* Hook to subscribe to state events for a specific client.
|
|
3439
|
+
*
|
|
3440
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
3441
|
+
* @param {function} fn - The callback function to handle the event.
|
|
3442
|
+
* @returns {function} - The unsubscribe function to stop listening to the events.
|
|
3443
|
+
*/
|
|
3444
|
+
declare const listenStateEvent: (clientId: string, fn: (event: IBaseEvent) => void) => () => void;
|
|
3445
|
+
|
|
3446
|
+
/**
|
|
3447
|
+
* Hook to subscribe to storage events for a specific client.
|
|
3448
|
+
*
|
|
3449
|
+
* @param {string} clientId - The ID of the client to subscribe to storage events for.
|
|
3450
|
+
* @param {function} fn - The callback function to handle the storage event.
|
|
3451
|
+
* @returns {function} - A function to unsubscribe from the storage events.
|
|
3452
|
+
*/
|
|
3453
|
+
declare const listenStorageEvent: (clientId: string, fn: (event: IBaseEvent) => void) => () => void;
|
|
3454
|
+
|
|
3455
|
+
/**
|
|
3456
|
+
* Hook to subscribe to swarm events for a specific client.
|
|
3457
|
+
*
|
|
3458
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
3459
|
+
* @param {(event: IBaseEvent) => void} fn - The callback function to handle the event.
|
|
3460
|
+
* @returns {Function} - A function to unsubscribe from the event.
|
|
3461
|
+
*/
|
|
3462
|
+
declare const listenSwarmEvent: (clientId: string, fn: (event: IBaseEvent) => void) => () => void;
|
|
3463
|
+
|
|
3258
3464
|
declare const GLOBAL_CONFIG: {
|
|
3259
3465
|
CC_TOOL_CALL_EXCEPTION_PROMPT: string;
|
|
3260
3466
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: string[];
|
|
@@ -3416,4 +3622,4 @@ declare class StateUtils implements TState {
|
|
|
3416
3622
|
*/
|
|
3417
3623
|
declare const State: StateUtils;
|
|
3418
3624
|
|
|
3419
|
-
export { ContextService, History, HistoryAdapter, HistoryInstance, type IAgentSchema, type IAgentTool, type ICompletionArgs, type ICompletionSchema, type IEmbeddingSchema, type IHistoryAdapter, type IHistoryInstance, type IHistoryInstanceCallbacks, type IIncomingMessage, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type IStateSchema, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, type ReceiveMessageFn, type SendMessageFn$1 as SendMessageFn, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, makeAutoDispose, makeConnection, session, setConfig, swarm };
|
|
3625
|
+
export { ContextService, type EventSource, History, HistoryAdapter, HistoryInstance, type IAgentSchema, type IAgentTool, type IBaseEvent, type IBaseEventContext, type ICompletionArgs, type ICompletionSchema, type IEmbeddingSchema, type IHistoryAdapter, type IHistoryInstance, type IHistoryInstanceCallbacks, type IIncomingMessage, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type IStateSchema, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, type ReceiveMessageFn, type SendMessageFn$1 as SendMessageFn, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenEvent, listenHistoryEvent, listenSessionEvent, listenStateEvent, listenStorageEvent, listenSwarmEvent, makeAutoDispose, makeConnection, session, setConfig, swarm };
|