agent-swarm-kit 1.0.214 β 1.0.216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -1
- package/build/index.cjs +47 -0
- package/build/index.mjs +47 -0
- package/package.json +2 -1
- package/types.d.ts +27 -0
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Unleash the power of collaborative AI with `agent-swarm-kit`! This library empow
|
|
|
22
22
|
|
|
23
23
|
## π Getting Started
|
|
24
24
|
|
|
25
|
-
**Want a real-world demo?** Check out our **[
|
|
25
|
+
**Want a real-world demo?** Check out our **[Binance Candle Chat](https://github.com/tripolskypetr/agent-swarm-kit/blob/master/demo/binance-candle-chat/src/lib/swarm.ts)**βa practical example of a sales agent in action!
|
|
26
26
|
|
|
27
27
|
### Installation
|
|
28
28
|
|
|
@@ -290,6 +290,35 @@ Storage.take<PhoneModel>({
|
|
|
290
290
|
}).then((phones) => console.log(phones));
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## π§© Demo Projects
|
|
296
|
+
|
|
297
|
+
Hereβs a rundown of the demo projects showcasing `agent-swarm-kit` in action:
|
|
298
|
+
|
|
299
|
+
- [**binance-candle-chat**](./demo/binance-candle-chat/): A cryptocurrency trading swarm with a triage agent routing to specialized trader agents (BTC, ETH, BNB, XRP, SOL) that calculate buy/sell orders and predict trends using OpenAI completion.
|
|
300
|
+
|
|
301
|
+
- [**it-consulting-swarm**](./demo/it-consulting-swarm/): A multi-agent system with a triage agent routing queries to specialized agents for tech trends, cybersecurity, environment, health, and finance, all powered by OpenAI completion.
|
|
302
|
+
|
|
303
|
+
- [**langchain-stream**](./demo/langchain-stream/): A pharma sales demo with a triage agent using Cohere completion and LangChain for real-time token streaming, alongside Ollama and LMStudio, to assist with consultations and cart operations.
|
|
304
|
+
|
|
305
|
+
- [**redis-persist-chat**](./demo/redis-persist-chat/): A chat system with a triage agent using Saiga Yandex GPT, persisting chat history and states (like Tic-tac-toe) in Redis, with policies to restrict sensitive topics.
|
|
306
|
+
|
|
307
|
+
- [**nginx-balancer-chat**](./demo/nginx-balancer-chat/): A test environment demonstrating load balancing across 5 chat instances via Nginx, with a single agent reporting the server port using OpenAI completion.
|
|
308
|
+
|
|
309
|
+
- [**cohere-token-rotate**](./demo/cohere-token-rotate/): A pharma sales system with a triage agent using Cohere completion and a token rotation mechanism (10 trial tokens in parallel) for optimized API performance.
|
|
310
|
+
|
|
311
|
+
- [**whisper-voice-chat**](./demo/whisper-voice-chat/): A voice-based chat system using Whisper for real-time transcription and a single test agent powered by Nemotron Mini (via Ollama) to handle user interactions.
|
|
312
|
+
|
|
313
|
+
- [**telegram-ollama-chat**](./demo/telegram-ollama-chat/): A Telegram-based pharma sales chatbot with a triage agent routing requests to a sales agent, both using Ollama for natural conversations and managing product data from a shared storage.
|
|
314
|
+
|
|
315
|
+
- [**repl-phone-seller**](./demo/repl-phone-seller/): A REPL terminal app featuring a sales agent that helps users add phones to a cart, leveraging Ollama completions and tools for searching phones by keywords or diagonal size.
|
|
316
|
+
|
|
317
|
+
- [**client-server-chat**](./demo/client-server-chat/): A WebSocket-based pharma sales demo with a single test agent using Saiga Yandex GPT to provide consultations and manage a cart.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
|
|
293
322
|
## β Orchestration Principles
|
|
294
323
|
|
|
295
324
|
1. Several chatgpt sessions (agents) [execute tool calls](https://ollama.com/blog/tool-support). Each agent can use different model, for example, [mistral 7b](https://ollama.com/library/mistral) for small talk, [nemotron](https://ollama.com/library/nemotron) for business conversation
|
package/build/index.cjs
CHANGED
|
@@ -17384,6 +17384,8 @@ const METHOD_NAME_REMOVE$1 = "StorageUtils.remove";
|
|
|
17384
17384
|
const METHOD_NAME_GET$1 = "StorageUtils.get";
|
|
17385
17385
|
/** @private Constant for logging the list method in StorageUtils */
|
|
17386
17386
|
const METHOD_NAME_LIST$1 = "StorageUtils.list";
|
|
17387
|
+
/** @private Constant for logging the createNumericIndex method in SharedStorageUtils */
|
|
17388
|
+
const METHOD_NAME_CREATE_NUMERIC_INDEX$1 = "StorageUtils.createNumericIndex";
|
|
17387
17389
|
/** @private Constant for logging the clear method in StorageUtils */
|
|
17388
17390
|
const METHOD_NAME_CLEAR$1 = "StorageUtils.clear";
|
|
17389
17391
|
/**
|
|
@@ -17529,6 +17531,31 @@ class StorageUtils {
|
|
|
17529
17531
|
}
|
|
17530
17532
|
return await swarm$1.storagePublicService.list(METHOD_NAME_LIST$1, payload.clientId, payload.storageName, payload.filter);
|
|
17531
17533
|
});
|
|
17534
|
+
/**
|
|
17535
|
+
* Creates a numeric index for the storage of a given client and agent.
|
|
17536
|
+
* Validates the storage name and agent-storage registration before calculating the index.
|
|
17537
|
+
* Executes within a context for logging.
|
|
17538
|
+
* The numeric index is determined based on the current number of items in the storage.
|
|
17539
|
+
* @param {Object} payload - The payload containing client, agent, and storage details.
|
|
17540
|
+
* @param {string} payload.clientId - The ID of the client whose storage is being indexed.
|
|
17541
|
+
* @param {AgentName} payload.agentName - The name of the agent associated with the storage.
|
|
17542
|
+
* @param {StorageName} payload.storageName - The name of the storage to index.
|
|
17543
|
+
* @returns {Promise<number>} A promise resolving to the next numeric index for the storage.
|
|
17544
|
+
* @throws {Error} If storage validation fails, the storage is not registered in the agent, or the storage service encounters an error.
|
|
17545
|
+
*/
|
|
17546
|
+
this.createNumericIndex = beginContext(async (payload) => {
|
|
17547
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17548
|
+
swarm$1.loggerService.log(METHOD_NAME_CREATE_NUMERIC_INDEX$1, {
|
|
17549
|
+
clientId: payload.clientId,
|
|
17550
|
+
storageName: payload.storageName,
|
|
17551
|
+
});
|
|
17552
|
+
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_CREATE_NUMERIC_INDEX$1);
|
|
17553
|
+
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
17554
|
+
throw new Error(`agent-swarm StorageUtils ${payload.storageName} not registered in ${payload.agentName} (createNumericIndex)`);
|
|
17555
|
+
}
|
|
17556
|
+
const { length } = await swarm$1.storagePublicService.list(METHOD_NAME_CREATE_NUMERIC_INDEX$1, payload.clientId, payload.storageName);
|
|
17557
|
+
return length + 1;
|
|
17558
|
+
});
|
|
17532
17559
|
/**
|
|
17533
17560
|
* Clears all items from the storage for a given client and agent.
|
|
17534
17561
|
* Validates the storage name and agent-storage registration before clearing via the storage service.
|
|
@@ -17570,6 +17597,8 @@ const METHOD_NAME_REMOVE = "SharedStorageUtils.remove";
|
|
|
17570
17597
|
const METHOD_NAME_GET = "SharedStorageUtils.get";
|
|
17571
17598
|
/** @private Constant for logging the list method in SharedStorageUtils */
|
|
17572
17599
|
const METHOD_NAME_LIST = "SharedStorageUtils.list";
|
|
17600
|
+
/** @private Constant for logging the createNumericIndex method in SharedStorageUtils */
|
|
17601
|
+
const METHOD_NAME_CREATE_NUMERIC_INDEX = "SharedStorageUtils.createNumericIndex";
|
|
17573
17602
|
/** @private Constant for logging the clear method in SharedStorageUtils */
|
|
17574
17603
|
const METHOD_NAME_CLEAR = "SharedStorageUtils.clear";
|
|
17575
17604
|
/**
|
|
@@ -17672,6 +17701,24 @@ class SharedStorageUtils {
|
|
|
17672
17701
|
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_LIST);
|
|
17673
17702
|
return await swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, storageName, filter);
|
|
17674
17703
|
});
|
|
17704
|
+
/**
|
|
17705
|
+
* Creates a new numeric index for the specified storage.
|
|
17706
|
+
* Executes within a context for logging and validation, ensuring the storage name is valid.
|
|
17707
|
+
* The numeric index is determined based on the current number of items in the storage.
|
|
17708
|
+
*
|
|
17709
|
+
* @param {StorageName} storageName - The name of the storage for which to create the numeric index.
|
|
17710
|
+
* @returns {Promise<number>} A promise resolving to the newly created numeric index.
|
|
17711
|
+
* @throws {Error} If storage validation fails or the shared storage service encounters an error.
|
|
17712
|
+
*/
|
|
17713
|
+
this.createNumericIndex = beginContext(async (storageName) => {
|
|
17714
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17715
|
+
swarm$1.loggerService.log(METHOD_NAME_CREATE_NUMERIC_INDEX, {
|
|
17716
|
+
storageName,
|
|
17717
|
+
});
|
|
17718
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_CREATE_NUMERIC_INDEX);
|
|
17719
|
+
const { length } = await swarm$1.sharedStoragePublicService.list(METHOD_NAME_CREATE_NUMERIC_INDEX, storageName);
|
|
17720
|
+
return length + 1;
|
|
17721
|
+
});
|
|
17675
17722
|
/**
|
|
17676
17723
|
* Clears all items from the storage.
|
|
17677
17724
|
* Executes within a context for logging and validation, ensuring the storage name is valid.
|
package/build/index.mjs
CHANGED
|
@@ -17382,6 +17382,8 @@ const METHOD_NAME_REMOVE$1 = "StorageUtils.remove";
|
|
|
17382
17382
|
const METHOD_NAME_GET$1 = "StorageUtils.get";
|
|
17383
17383
|
/** @private Constant for logging the list method in StorageUtils */
|
|
17384
17384
|
const METHOD_NAME_LIST$1 = "StorageUtils.list";
|
|
17385
|
+
/** @private Constant for logging the createNumericIndex method in SharedStorageUtils */
|
|
17386
|
+
const METHOD_NAME_CREATE_NUMERIC_INDEX$1 = "StorageUtils.createNumericIndex";
|
|
17385
17387
|
/** @private Constant for logging the clear method in StorageUtils */
|
|
17386
17388
|
const METHOD_NAME_CLEAR$1 = "StorageUtils.clear";
|
|
17387
17389
|
/**
|
|
@@ -17527,6 +17529,31 @@ class StorageUtils {
|
|
|
17527
17529
|
}
|
|
17528
17530
|
return await swarm$1.storagePublicService.list(METHOD_NAME_LIST$1, payload.clientId, payload.storageName, payload.filter);
|
|
17529
17531
|
});
|
|
17532
|
+
/**
|
|
17533
|
+
* Creates a numeric index for the storage of a given client and agent.
|
|
17534
|
+
* Validates the storage name and agent-storage registration before calculating the index.
|
|
17535
|
+
* Executes within a context for logging.
|
|
17536
|
+
* The numeric index is determined based on the current number of items in the storage.
|
|
17537
|
+
* @param {Object} payload - The payload containing client, agent, and storage details.
|
|
17538
|
+
* @param {string} payload.clientId - The ID of the client whose storage is being indexed.
|
|
17539
|
+
* @param {AgentName} payload.agentName - The name of the agent associated with the storage.
|
|
17540
|
+
* @param {StorageName} payload.storageName - The name of the storage to index.
|
|
17541
|
+
* @returns {Promise<number>} A promise resolving to the next numeric index for the storage.
|
|
17542
|
+
* @throws {Error} If storage validation fails, the storage is not registered in the agent, or the storage service encounters an error.
|
|
17543
|
+
*/
|
|
17544
|
+
this.createNumericIndex = beginContext(async (payload) => {
|
|
17545
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17546
|
+
swarm$1.loggerService.log(METHOD_NAME_CREATE_NUMERIC_INDEX$1, {
|
|
17547
|
+
clientId: payload.clientId,
|
|
17548
|
+
storageName: payload.storageName,
|
|
17549
|
+
});
|
|
17550
|
+
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_CREATE_NUMERIC_INDEX$1);
|
|
17551
|
+
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
17552
|
+
throw new Error(`agent-swarm StorageUtils ${payload.storageName} not registered in ${payload.agentName} (createNumericIndex)`);
|
|
17553
|
+
}
|
|
17554
|
+
const { length } = await swarm$1.storagePublicService.list(METHOD_NAME_CREATE_NUMERIC_INDEX$1, payload.clientId, payload.storageName);
|
|
17555
|
+
return length + 1;
|
|
17556
|
+
});
|
|
17530
17557
|
/**
|
|
17531
17558
|
* Clears all items from the storage for a given client and agent.
|
|
17532
17559
|
* Validates the storage name and agent-storage registration before clearing via the storage service.
|
|
@@ -17568,6 +17595,8 @@ const METHOD_NAME_REMOVE = "SharedStorageUtils.remove";
|
|
|
17568
17595
|
const METHOD_NAME_GET = "SharedStorageUtils.get";
|
|
17569
17596
|
/** @private Constant for logging the list method in SharedStorageUtils */
|
|
17570
17597
|
const METHOD_NAME_LIST = "SharedStorageUtils.list";
|
|
17598
|
+
/** @private Constant for logging the createNumericIndex method in SharedStorageUtils */
|
|
17599
|
+
const METHOD_NAME_CREATE_NUMERIC_INDEX = "SharedStorageUtils.createNumericIndex";
|
|
17571
17600
|
/** @private Constant for logging the clear method in SharedStorageUtils */
|
|
17572
17601
|
const METHOD_NAME_CLEAR = "SharedStorageUtils.clear";
|
|
17573
17602
|
/**
|
|
@@ -17670,6 +17699,24 @@ class SharedStorageUtils {
|
|
|
17670
17699
|
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_LIST);
|
|
17671
17700
|
return await swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, storageName, filter);
|
|
17672
17701
|
});
|
|
17702
|
+
/**
|
|
17703
|
+
* Creates a new numeric index for the specified storage.
|
|
17704
|
+
* Executes within a context for logging and validation, ensuring the storage name is valid.
|
|
17705
|
+
* The numeric index is determined based on the current number of items in the storage.
|
|
17706
|
+
*
|
|
17707
|
+
* @param {StorageName} storageName - The name of the storage for which to create the numeric index.
|
|
17708
|
+
* @returns {Promise<number>} A promise resolving to the newly created numeric index.
|
|
17709
|
+
* @throws {Error} If storage validation fails or the shared storage service encounters an error.
|
|
17710
|
+
*/
|
|
17711
|
+
this.createNumericIndex = beginContext(async (storageName) => {
|
|
17712
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17713
|
+
swarm$1.loggerService.log(METHOD_NAME_CREATE_NUMERIC_INDEX, {
|
|
17714
|
+
storageName,
|
|
17715
|
+
});
|
|
17716
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_CREATE_NUMERIC_INDEX);
|
|
17717
|
+
const { length } = await swarm$1.sharedStoragePublicService.list(METHOD_NAME_CREATE_NUMERIC_INDEX, storageName);
|
|
17718
|
+
return length + 1;
|
|
17719
|
+
});
|
|
17673
17720
|
/**
|
|
17674
17721
|
* Clears all items from the storage.
|
|
17675
17722
|
* Executes within a context for logging and validation, ensuring the storage name is valid.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-swarm-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.216",
|
|
4
4
|
"description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Petr Tripolsky",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"docs:www": "rimraf docs/wwwroot && typedoc && node ./packages/typedoc-yandex-metrica/index.mjs",
|
|
47
47
|
"docs:demo:win": ".\\scripts\\win\\build_demo_docs.bat",
|
|
48
48
|
"docs:demo": "sh ./scripts/linux/build_demo_docs.sh",
|
|
49
|
+
"docs:demo:concat": "node ./packages/concat-demo-docs/index.mjs",
|
|
49
50
|
"repl": "dotenv -e .env -- npm run build && node -e \"import('./scripts/repl.mjs')\" --interactive"
|
|
50
51
|
},
|
|
51
52
|
"main": "build/index.cjs",
|
package/types.d.ts
CHANGED
|
@@ -11054,6 +11054,23 @@ declare class StorageUtils implements TStorage {
|
|
|
11054
11054
|
storageName: StorageName;
|
|
11055
11055
|
filter?: (item: T) => boolean;
|
|
11056
11056
|
}) => Promise<T[]>;
|
|
11057
|
+
/**
|
|
11058
|
+
* Creates a numeric index for the storage of a given client and agent.
|
|
11059
|
+
* Validates the storage name and agent-storage registration before calculating the index.
|
|
11060
|
+
* Executes within a context for logging.
|
|
11061
|
+
* The numeric index is determined based on the current number of items in the storage.
|
|
11062
|
+
* @param {Object} payload - The payload containing client, agent, and storage details.
|
|
11063
|
+
* @param {string} payload.clientId - The ID of the client whose storage is being indexed.
|
|
11064
|
+
* @param {AgentName} payload.agentName - The name of the agent associated with the storage.
|
|
11065
|
+
* @param {StorageName} payload.storageName - The name of the storage to index.
|
|
11066
|
+
* @returns {Promise<number>} A promise resolving to the next numeric index for the storage.
|
|
11067
|
+
* @throws {Error} If storage validation fails, the storage is not registered in the agent, or the storage service encounters an error.
|
|
11068
|
+
*/
|
|
11069
|
+
createNumericIndex: (payload: {
|
|
11070
|
+
clientId: string;
|
|
11071
|
+
agentName: AgentName;
|
|
11072
|
+
storageName: StorageName;
|
|
11073
|
+
}) => Promise<number>;
|
|
11057
11074
|
/**
|
|
11058
11075
|
* Clears all items from the storage for a given client and agent.
|
|
11059
11076
|
* Validates the storage name and agent-storage registration before clearing via the storage service.
|
|
@@ -11147,6 +11164,16 @@ declare class SharedStorageUtils implements TSharedStorage {
|
|
|
11147
11164
|
* @throws {Error} If storage validation fails or the shared storage service encounters an error.
|
|
11148
11165
|
*/
|
|
11149
11166
|
list: <T extends IStorageData = IStorageData>(storageName: StorageName, filter?: (item: T) => boolean) => Promise<T[]>;
|
|
11167
|
+
/**
|
|
11168
|
+
* Creates a new numeric index for the specified storage.
|
|
11169
|
+
* Executes within a context for logging and validation, ensuring the storage name is valid.
|
|
11170
|
+
* The numeric index is determined based on the current number of items in the storage.
|
|
11171
|
+
*
|
|
11172
|
+
* @param {StorageName} storageName - The name of the storage for which to create the numeric index.
|
|
11173
|
+
* @returns {Promise<number>} A promise resolving to the newly created numeric index.
|
|
11174
|
+
* @throws {Error} If storage validation fails or the shared storage service encounters an error.
|
|
11175
|
+
*/
|
|
11176
|
+
createNumericIndex: (storageName: string) => Promise<number>;
|
|
11150
11177
|
/**
|
|
11151
11178
|
* Clears all items from the storage.
|
|
11152
11179
|
* Executes within a context for logging and validation, ensuring the storage name is valid.
|