agent-swarm-kit 1.0.69 → 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 +1016 -131
- package/build/index.mjs +1007 -132
- package/package.json +1 -1
- package/types.d.ts +921 -686
package/types.d.ts
CHANGED
|
@@ -53,989 +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> {
|
|
416
320
|
/**
|
|
417
|
-
*
|
|
418
|
-
|
|
419
|
-
|
|
321
|
+
* The agents can share the state
|
|
322
|
+
*/
|
|
323
|
+
shared?: boolean;
|
|
324
|
+
/**
|
|
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>;
|
|
541
|
+
}
|
|
542
|
+
/** Type alias for swarm name */
|
|
543
|
+
type SwarmName = string;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Parameters required to create a session.
|
|
547
|
+
* @interface
|
|
548
|
+
*/
|
|
549
|
+
interface ISessionParams extends ISessionSchema, ISwarmSessionCallbacks {
|
|
550
|
+
clientId: string;
|
|
551
|
+
logger: ILogger;
|
|
552
|
+
bus: IBus;
|
|
553
|
+
swarm: ISwarm;
|
|
554
|
+
swarmName: SwarmName;
|
|
598
555
|
}
|
|
599
556
|
/**
|
|
600
|
-
*
|
|
557
|
+
* Schema for session data.
|
|
558
|
+
* @interface
|
|
601
559
|
*/
|
|
602
|
-
|
|
560
|
+
interface ISessionSchema {
|
|
561
|
+
}
|
|
603
562
|
/**
|
|
604
|
-
*
|
|
563
|
+
* Function type for sending messages.
|
|
564
|
+
* @typedef {function} SendMessageFn
|
|
565
|
+
* @param {IOutgoingMessage} outgoing - The outgoing message.
|
|
566
|
+
* @returns {Promise<void> | void}
|
|
605
567
|
*/
|
|
606
|
-
|
|
607
|
-
|
|
568
|
+
type SendMessageFn$1 = (outgoing: IOutgoingMessage) => Promise<void> | void;
|
|
608
569
|
/**
|
|
609
|
-
*
|
|
570
|
+
* Function type for receiving messages.
|
|
571
|
+
* @typedef {function} ReceiveMessageFn
|
|
572
|
+
* @param {IIncomingMessage} incoming - The incoming message.
|
|
573
|
+
* @returns {Promise<void> | void}
|
|
610
574
|
*/
|
|
611
|
-
|
|
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;
|
|
742
746
|
/**
|
|
743
|
-
*
|
|
744
|
-
* @
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
*
|
|
747
|
+
* Optional tool calls associated with the message.
|
|
748
|
+
* @type {Array<{ function: { name: string; arguments: { [key: string]: any; }; }; }>}
|
|
749
|
+
*/
|
|
750
|
+
tool_calls?: IToolCall[];
|
|
751
|
+
/**
|
|
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
|
|
828
|
+
interface IHistoryAdapter {
|
|
830
829
|
/**
|
|
831
|
-
*
|
|
832
|
-
* @param items - The updated items.
|
|
830
|
+
* Iterate over the history messages.
|
|
833
831
|
* @param clientId - The client ID.
|
|
834
|
-
* @param
|
|
832
|
+
* @param agentName - The agent name.
|
|
833
|
+
* @returns An async iterable iterator of model messages.
|
|
835
834
|
*/
|
|
836
|
-
|
|
835
|
+
iterate(clientId: string, agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
837
836
|
/**
|
|
838
|
-
*
|
|
839
|
-
* @param
|
|
840
|
-
* @param index - The sorted array of storage data.
|
|
837
|
+
* Push a new message to the history.
|
|
838
|
+
* @param value - The model message to push.
|
|
841
839
|
* @param clientId - The client ID.
|
|
842
|
-
* @param
|
|
840
|
+
* @param agentName - The agent name.
|
|
841
|
+
* @returns A promise that resolves when the message is pushed.
|
|
843
842
|
*/
|
|
844
|
-
|
|
843
|
+
push: (value: IModelMessage, clientId: string, agentName: AgentName) => Promise<void>;
|
|
844
|
+
/**
|
|
845
|
+
* Dispose of the history for a given client and agent.
|
|
846
|
+
* @param clientId - The client ID.
|
|
847
|
+
* @param agentName - The agent name or null.
|
|
848
|
+
* @returns A promise that resolves when the history is disposed.
|
|
849
|
+
*/
|
|
850
|
+
dispose: (clientId: string, agentName: AgentName | null) => Promise<void>;
|
|
845
851
|
}
|
|
846
852
|
/**
|
|
847
|
-
* Interface
|
|
848
|
-
* @template T - Type of the storage data.
|
|
853
|
+
* Interface for History Control
|
|
849
854
|
*/
|
|
850
|
-
interface
|
|
855
|
+
interface IHistoryControl {
|
|
851
856
|
/**
|
|
852
|
-
*
|
|
857
|
+
* Use a custom history adapter.
|
|
858
|
+
* @param Ctor - The constructor for the history instance.
|
|
853
859
|
*/
|
|
854
|
-
|
|
860
|
+
useHistoryAdapter(Ctor: THistoryInstanceCtor): void;
|
|
855
861
|
/**
|
|
856
|
-
*
|
|
862
|
+
* Use history lifecycle callbacks.
|
|
863
|
+
* @param Callbacks - The callbacks dictionary.
|
|
857
864
|
*/
|
|
858
|
-
|
|
865
|
+
useHistoryCallbacks: (Callbacks: Partial<IHistoryInstanceCallbacks>) => void;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Interface for History Instance
|
|
869
|
+
*/
|
|
870
|
+
interface IHistoryInstance {
|
|
859
871
|
/**
|
|
860
|
-
*
|
|
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.
|
|
861
875
|
*/
|
|
862
|
-
|
|
876
|
+
iterate(agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
863
877
|
/**
|
|
864
|
-
*
|
|
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.
|
|
865
882
|
*/
|
|
866
|
-
|
|
883
|
+
waitForInit(agentName: AgentName, init: boolean): Promise<void>;
|
|
867
884
|
/**
|
|
868
|
-
*
|
|
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.
|
|
869
889
|
*/
|
|
870
|
-
|
|
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>;
|
|
871
897
|
}
|
|
872
898
|
/**
|
|
873
|
-
*
|
|
874
|
-
* @template T - Type of the storage data.
|
|
899
|
+
* Type for History Instance Constructor
|
|
875
900
|
*/
|
|
876
|
-
|
|
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;
|
|
877
909
|
/**
|
|
878
|
-
*
|
|
879
|
-
* @param
|
|
880
|
-
* @param total - The total number of items to take.
|
|
881
|
-
* @param score - Optional score parameter.
|
|
882
|
-
* @returns A promise that resolves to an array of storage data.
|
|
910
|
+
* Wait for the history to initialize.
|
|
911
|
+
* @param agentName - The agent name.
|
|
883
912
|
*/
|
|
884
|
-
|
|
913
|
+
waitForInit: ((agentName: AgentName) => Promise<void>) & functools_kit.ISingleshotClearable;
|
|
885
914
|
/**
|
|
886
|
-
*
|
|
887
|
-
* @param
|
|
888
|
-
* @
|
|
915
|
+
* Create a HistoryInstance.
|
|
916
|
+
* @param clientId - The client ID.
|
|
917
|
+
* @param callbacks - The callbacks for the history instance.
|
|
889
918
|
*/
|
|
890
|
-
|
|
919
|
+
constructor(clientId: string, callbacks: Partial<IHistoryInstanceCallbacks>);
|
|
891
920
|
/**
|
|
892
|
-
*
|
|
893
|
-
* @param
|
|
894
|
-
* @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.
|
|
895
924
|
*/
|
|
896
|
-
|
|
925
|
+
iterate(agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
897
926
|
/**
|
|
898
|
-
*
|
|
899
|
-
* @param
|
|
900
|
-
* @
|
|
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.
|
|
901
931
|
*/
|
|
902
|
-
|
|
932
|
+
push: (value: IModelMessage, agentName: AgentName) => Promise<void>;
|
|
903
933
|
/**
|
|
904
|
-
*
|
|
905
|
-
* @param
|
|
906
|
-
* @returns A promise that resolves
|
|
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.
|
|
962
|
+
*/
|
|
963
|
+
iterate(clientId: string, agentName: AgentName): AsyncIterableIterator<IModelMessage>;
|
|
964
|
+
/**
|
|
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.
|
|
907
970
|
*/
|
|
908
|
-
|
|
971
|
+
push: (value: IModelMessage, clientId: string, agentName: AgentName) => Promise<void>;
|
|
909
972
|
/**
|
|
910
|
-
*
|
|
911
|
-
* @
|
|
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.
|
|
912
977
|
*/
|
|
913
|
-
|
|
978
|
+
dispose: (clientId: string, agentName: AgentName | null) => Promise<void>;
|
|
914
979
|
}
|
|
915
980
|
/**
|
|
916
|
-
*
|
|
981
|
+
* Exported History Adapter instance
|
|
917
982
|
*/
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
type IStateData = any;
|
|
983
|
+
declare const HistoryAdapter: HistoryUtils;
|
|
921
984
|
/**
|
|
922
|
-
*
|
|
923
|
-
* @template T - The type of the state data.
|
|
924
|
-
* @param {T} state - The current state.
|
|
925
|
-
* @param {string} clientId - The client ID.
|
|
926
|
-
* @param {StateName} stateName - The name of the state.
|
|
927
|
-
* @returns {Promise<T>} - The updated state.
|
|
985
|
+
* Exported History Control instance
|
|
928
986
|
*/
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
}
|
|
987
|
+
declare const History: IHistoryControl;
|
|
988
|
+
|
|
932
989
|
/**
|
|
933
|
-
*
|
|
934
|
-
* @template T - The type of the state data.
|
|
990
|
+
* Interface representing the history of model messages.
|
|
935
991
|
*/
|
|
936
|
-
interface
|
|
992
|
+
interface IHistory {
|
|
937
993
|
/**
|
|
938
|
-
*
|
|
939
|
-
* @param {
|
|
940
|
-
* @
|
|
994
|
+
* Pushes a message to the history.
|
|
995
|
+
* @param {IModelMessage} message - The message to push.
|
|
996
|
+
* @returns {Promise<void>}
|
|
941
997
|
*/
|
|
942
|
-
|
|
998
|
+
push(message: IModelMessage): Promise<void>;
|
|
943
999
|
/**
|
|
944
|
-
*
|
|
945
|
-
* @param {string}
|
|
946
|
-
* @
|
|
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[]>}
|
|
947
1003
|
*/
|
|
948
|
-
|
|
1004
|
+
toArrayForAgent(prompt: string, system?: string[]): Promise<IModelMessage[]>;
|
|
949
1005
|
/**
|
|
950
|
-
*
|
|
951
|
-
* @
|
|
952
|
-
* @param {string} clientId - The client ID.
|
|
953
|
-
* @param {StateName} stateName - The name of the state.
|
|
1006
|
+
* Converts the history to an array of raw messages.
|
|
1007
|
+
* @returns {Promise<IModelMessage[]>}
|
|
954
1008
|
*/
|
|
955
|
-
|
|
1009
|
+
toArrayForRaw(): Promise<IModelMessage[]>;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Interface representing the parameters required to create a history instance.
|
|
1013
|
+
*/
|
|
1014
|
+
interface IHistoryParams extends IHistorySchema {
|
|
956
1015
|
/**
|
|
957
|
-
*
|
|
958
|
-
* @
|
|
959
|
-
* @param {string} clientId - The client ID.
|
|
960
|
-
* @param {StateName} stateName - The name of the state.
|
|
1016
|
+
* The name of the agent.
|
|
1017
|
+
* @type {AgentName}
|
|
961
1018
|
*/
|
|
962
|
-
|
|
1019
|
+
agentName: AgentName;
|
|
963
1020
|
/**
|
|
964
|
-
*
|
|
965
|
-
* @
|
|
966
|
-
* @param {string} clientId - The client ID.
|
|
967
|
-
* @param {StateName} stateName - The name of the state.
|
|
1021
|
+
* The client ID.
|
|
1022
|
+
* @type {string}
|
|
968
1023
|
*/
|
|
969
|
-
|
|
1024
|
+
clientId: string;
|
|
1025
|
+
/**
|
|
1026
|
+
* The logger instance.
|
|
1027
|
+
* @type {ILogger}
|
|
1028
|
+
*/
|
|
1029
|
+
logger: ILogger;
|
|
1030
|
+
/** The bus instance. */
|
|
1031
|
+
bus: IBus;
|
|
970
1032
|
}
|
|
971
1033
|
/**
|
|
972
|
-
*
|
|
973
|
-
* @template T - The type of the state data.
|
|
1034
|
+
* Interface representing the schema of the history.
|
|
974
1035
|
*/
|
|
975
|
-
interface
|
|
1036
|
+
interface IHistorySchema {
|
|
976
1037
|
/**
|
|
977
|
-
* The
|
|
1038
|
+
* The adapter for array of model messages.
|
|
1039
|
+
* @type {IHistoryAdapter}
|
|
978
1040
|
*/
|
|
979
|
-
|
|
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 {
|
|
980
1053
|
/**
|
|
981
|
-
*
|
|
982
|
-
* @param {string} clientId - The client ID.
|
|
983
|
-
* @param {StateName} stateName - The name of the state.
|
|
984
|
-
* @returns {T | Promise<T>} - The current state.
|
|
1054
|
+
* Client ID.
|
|
985
1055
|
*/
|
|
986
|
-
|
|
1056
|
+
clientId: string;
|
|
987
1057
|
/**
|
|
988
|
-
*
|
|
989
|
-
* @param {T} state - The new state.
|
|
990
|
-
* @param {string} clientId - The client ID.
|
|
991
|
-
* @param {StateName} stateName - The name of the state.
|
|
992
|
-
* @returns {Promise<void> | void} - A promise that resolves when the state is set.
|
|
1058
|
+
* Name of the agent.
|
|
993
1059
|
*/
|
|
994
|
-
|
|
1060
|
+
agentName: AgentName;
|
|
995
1061
|
/**
|
|
996
|
-
*
|
|
1062
|
+
* The source of the last message: tool or user
|
|
997
1063
|
*/
|
|
998
|
-
|
|
1064
|
+
mode: ExecutionMode;
|
|
999
1065
|
/**
|
|
1000
|
-
*
|
|
1066
|
+
* Array of model messages.
|
|
1001
1067
|
*/
|
|
1002
|
-
|
|
1068
|
+
messages: IModelMessage[];
|
|
1069
|
+
/**
|
|
1070
|
+
* Optional array of tools.
|
|
1071
|
+
*/
|
|
1072
|
+
tools?: ITool[];
|
|
1003
1073
|
}
|
|
1004
1074
|
/**
|
|
1005
|
-
*
|
|
1006
|
-
* @template T - The type of the state data.
|
|
1075
|
+
* Completion lifecycle callbacks
|
|
1007
1076
|
*/
|
|
1008
|
-
interface
|
|
1009
|
-
/**
|
|
1010
|
-
* The client ID.
|
|
1011
|
-
*/
|
|
1012
|
-
clientId: string;
|
|
1077
|
+
interface ICompletionCallbacks {
|
|
1013
1078
|
/**
|
|
1014
|
-
*
|
|
1079
|
+
* Callback fired after complete.
|
|
1080
|
+
* @param args - Arguments passed to complete
|
|
1081
|
+
* @param output - Output of the model
|
|
1015
1082
|
*/
|
|
1016
|
-
|
|
1083
|
+
onComplete?: (args: ICompletionArgs, output: IModelMessage) => void;
|
|
1017
1084
|
}
|
|
1018
1085
|
/**
|
|
1019
|
-
*
|
|
1020
|
-
* @template T - The type of the state data.
|
|
1086
|
+
* Schema for a completion.
|
|
1021
1087
|
*/
|
|
1022
|
-
interface
|
|
1088
|
+
interface ICompletionSchema {
|
|
1023
1089
|
/**
|
|
1024
|
-
*
|
|
1025
|
-
* @returns {Promise<T>} - The current state.
|
|
1090
|
+
* Name of the completion.
|
|
1026
1091
|
*/
|
|
1027
|
-
|
|
1092
|
+
completionName: CompletionName;
|
|
1028
1093
|
/**
|
|
1029
|
-
*
|
|
1030
|
-
* @param
|
|
1031
|
-
* @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.
|
|
1032
1097
|
*/
|
|
1033
|
-
|
|
1098
|
+
getCompletion(args: ICompletionArgs): Promise<IModelMessage>;
|
|
1099
|
+
/**
|
|
1100
|
+
* Completion lifecycle callbacks
|
|
1101
|
+
*/
|
|
1102
|
+
callbacks?: Partial<ICompletionCallbacks>;
|
|
1034
1103
|
}
|
|
1035
1104
|
/**
|
|
1036
|
-
*
|
|
1105
|
+
* Type representing the name of a completion.
|
|
1037
1106
|
*/
|
|
1038
|
-
type
|
|
1107
|
+
type CompletionName = string;
|
|
1039
1108
|
|
|
1040
1109
|
/**
|
|
1041
1110
|
* Interface representing lifecycle callbacks of a tool
|
|
@@ -1128,6 +1197,8 @@ interface IAgentParams extends Omit<IAgentSchema, keyof {
|
|
|
1128
1197
|
clientId: string;
|
|
1129
1198
|
/** The logger instance. */
|
|
1130
1199
|
logger: ILogger;
|
|
1200
|
+
/** The bus instance. */
|
|
1201
|
+
bus: IBus;
|
|
1131
1202
|
/** The history instance. */
|
|
1132
1203
|
history: IHistory;
|
|
1133
1204
|
/** The completion instance. */
|
|
@@ -1429,6 +1500,7 @@ declare class ClientAgent implements IAgent {
|
|
|
1429
1500
|
*/
|
|
1430
1501
|
declare class AgentConnectionService implements IAgent {
|
|
1431
1502
|
private readonly loggerService;
|
|
1503
|
+
private readonly busService;
|
|
1432
1504
|
private readonly contextService;
|
|
1433
1505
|
private readonly sessionValidationService;
|
|
1434
1506
|
private readonly historyConnectionService;
|
|
@@ -1536,6 +1608,7 @@ declare class ClientHistory implements IHistory {
|
|
|
1536
1608
|
*/
|
|
1537
1609
|
declare class HistoryConnectionService implements IHistory {
|
|
1538
1610
|
private readonly loggerService;
|
|
1611
|
+
private readonly busService;
|
|
1539
1612
|
private readonly contextService;
|
|
1540
1613
|
private readonly sessionValidationService;
|
|
1541
1614
|
/**
|
|
@@ -1616,16 +1689,21 @@ declare class ClientSwarm implements ISwarm {
|
|
|
1616
1689
|
readonly params: ISwarmParams;
|
|
1617
1690
|
private _agentChangedSubject;
|
|
1618
1691
|
private _activeAgent;
|
|
1692
|
+
private _cancelOutputSubject;
|
|
1619
1693
|
get _agentList(): [string, IAgent][];
|
|
1620
1694
|
/**
|
|
1621
1695
|
* Creates an instance of ClientSwarm.
|
|
1622
1696
|
* @param {ISwarmParams} params - The parameters for the swarm.
|
|
1623
1697
|
*/
|
|
1624
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>;
|
|
1625
1704
|
/**
|
|
1626
1705
|
* Waits for output from the active agent.
|
|
1627
1706
|
* @returns {Promise<string>} - The output from the active agent.
|
|
1628
|
-
* @throws {Error} - If the timeout is reached.
|
|
1629
1707
|
*/
|
|
1630
1708
|
waitForOutput: () => Promise<string>;
|
|
1631
1709
|
/**
|
|
@@ -1658,6 +1736,7 @@ declare class ClientSwarm implements ISwarm {
|
|
|
1658
1736
|
*/
|
|
1659
1737
|
declare class SwarmConnectionService implements ISwarm {
|
|
1660
1738
|
private readonly loggerService;
|
|
1739
|
+
private readonly busService;
|
|
1661
1740
|
private readonly contextService;
|
|
1662
1741
|
private readonly agentConnectionService;
|
|
1663
1742
|
private readonly swarmSchemaService;
|
|
@@ -1668,6 +1747,11 @@ declare class SwarmConnectionService implements ISwarm {
|
|
|
1668
1747
|
* @returns {ClientSwarm} The client swarm instance.
|
|
1669
1748
|
*/
|
|
1670
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>;
|
|
1671
1755
|
/**
|
|
1672
1756
|
* Waits for the output from the swarm.
|
|
1673
1757
|
* @returns {Promise<any>} The output from the swarm.
|
|
@@ -1810,6 +1894,7 @@ declare class ClientSession implements ISession {
|
|
|
1810
1894
|
*/
|
|
1811
1895
|
declare class SessionConnectionService implements ISession {
|
|
1812
1896
|
private readonly loggerService;
|
|
1897
|
+
private readonly busService;
|
|
1813
1898
|
private readonly contextService;
|
|
1814
1899
|
private readonly swarmConnectionService;
|
|
1815
1900
|
private readonly swarmSchemaService;
|
|
@@ -2094,6 +2179,13 @@ type TSwarmConnectionService = {
|
|
|
2094
2179
|
declare class SwarmPublicService implements TSwarmConnectionService {
|
|
2095
2180
|
private readonly loggerService;
|
|
2096
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>;
|
|
2097
2189
|
/**
|
|
2098
2190
|
* Waits for output from the swarm.
|
|
2099
2191
|
* @param {string} clientId - The client ID.
|
|
@@ -2482,6 +2574,11 @@ declare class ClientStorage<T extends IStorageData = IStorageData> implements IS
|
|
|
2482
2574
|
* @returns {Promise<T[]>} - The list of items.
|
|
2483
2575
|
*/
|
|
2484
2576
|
list: (filter?: (item: T) => boolean) => Promise<T[]>;
|
|
2577
|
+
/**
|
|
2578
|
+
* Disposes of the state.
|
|
2579
|
+
* @returns {Promise<void>}
|
|
2580
|
+
*/
|
|
2581
|
+
dispose: () => Promise<void>;
|
|
2485
2582
|
}
|
|
2486
2583
|
|
|
2487
2584
|
/**
|
|
@@ -2490,6 +2587,7 @@ declare class ClientStorage<T extends IStorageData = IStorageData> implements IS
|
|
|
2490
2587
|
*/
|
|
2491
2588
|
declare class StorageConnectionService implements IStorage {
|
|
2492
2589
|
private readonly loggerService;
|
|
2590
|
+
private readonly busService;
|
|
2493
2591
|
private readonly contextService;
|
|
2494
2592
|
private readonly storageSchemaService;
|
|
2495
2593
|
private readonly sessionValidationService;
|
|
@@ -2701,9 +2799,17 @@ declare class ClientState<State extends IStateData = IStateData> implements ISta
|
|
|
2701
2799
|
*/
|
|
2702
2800
|
declare class StateConnectionService<T extends IStateData = IStateData> implements IState<T> {
|
|
2703
2801
|
private readonly loggerService;
|
|
2802
|
+
private readonly busService;
|
|
2704
2803
|
private readonly contextService;
|
|
2705
2804
|
private readonly stateSchemaService;
|
|
2706
2805
|
private readonly sessionValidationService;
|
|
2806
|
+
/**
|
|
2807
|
+
* Memoized function to get a shared state reference.
|
|
2808
|
+
* @param {string} clientId - The client ID.
|
|
2809
|
+
* @param {StateName} stateName - The state name.
|
|
2810
|
+
* @returns {ClientState} The client state.
|
|
2811
|
+
*/
|
|
2812
|
+
getSharedStateRef: ((clientId: string, stateName: StateName) => ClientState<any>) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientState<any>>;
|
|
2707
2813
|
/**
|
|
2708
2814
|
* Memoized function to get a state reference.
|
|
2709
2815
|
* @param {string} clientId - The client ID.
|
|
@@ -2733,6 +2839,7 @@ interface IStateConnectionService extends StateConnectionService {
|
|
|
2733
2839
|
}
|
|
2734
2840
|
type InternalKeys = keyof {
|
|
2735
2841
|
getStateRef: never;
|
|
2842
|
+
getSharedStateRef: never;
|
|
2736
2843
|
};
|
|
2737
2844
|
type TStateConnectionService = {
|
|
2738
2845
|
[key in Exclude<keyof IStateConnectionService, InternalKeys>]: unknown;
|
|
@@ -2784,6 +2891,41 @@ declare class StateSchemaService {
|
|
|
2784
2891
|
get: (key: StateName) => IStateSchema;
|
|
2785
2892
|
}
|
|
2786
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
|
+
|
|
2787
2929
|
declare const swarm: {
|
|
2788
2930
|
agentValidationService: AgentValidationService;
|
|
2789
2931
|
toolValidationService: ToolValidationService;
|
|
@@ -2811,6 +2953,7 @@ declare const swarm: {
|
|
|
2811
2953
|
sessionConnectionService: SessionConnectionService;
|
|
2812
2954
|
storageConnectionService: StorageConnectionService;
|
|
2813
2955
|
stateConnectionService: StateConnectionService<any>;
|
|
2956
|
+
busService: BusService;
|
|
2814
2957
|
loggerService: LoggerService;
|
|
2815
2958
|
contextService: {
|
|
2816
2959
|
readonly context: IContext;
|
|
@@ -3145,6 +3288,16 @@ declare const emitForce: (content: string, clientId: string) => Promise<void>;
|
|
|
3145
3288
|
*/
|
|
3146
3289
|
declare const executeForce: (content: string, clientId: string) => Promise<string>;
|
|
3147
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
|
+
|
|
3148
3301
|
/**
|
|
3149
3302
|
* Retrieves the last message sent by the user from the client's message history.
|
|
3150
3303
|
*
|
|
@@ -3226,6 +3379,88 @@ declare const makeAutoDispose: (clientId: string, swarmName: SwarmName, { timeou
|
|
|
3226
3379
|
destroy(): void;
|
|
3227
3380
|
};
|
|
3228
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
|
+
|
|
3229
3464
|
declare const GLOBAL_CONFIG: {
|
|
3230
3465
|
CC_TOOL_CALL_EXCEPTION_PROMPT: string;
|
|
3231
3466
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: string[];
|
|
@@ -3387,4 +3622,4 @@ declare class StateUtils implements TState {
|
|
|
3387
3622
|
*/
|
|
3388
3623
|
declare const State: StateUtils;
|
|
3389
3624
|
|
|
3390
|
-
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 };
|