agent-swarm-kit 1.0.49 → 1.0.51

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.
Files changed (4) hide show
  1. package/build/index.cjs +1247 -131
  2. package/build/index.mjs +1246 -133
  3. package/package.json +2 -2
  4. package/types.d.ts +387 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -74,7 +74,7 @@
74
74
  "dependencies": {
75
75
  "di-kit": "^1.0.12",
76
76
  "di-scoped": "^1.0.11",
77
- "functools-kit": "^1.0.73",
77
+ "functools-kit": "^1.0.74",
78
78
  "lodash-es": "4.17.21",
79
79
  "xml2js": "0.6.2"
80
80
  }
package/types.d.ts CHANGED
@@ -491,6 +491,50 @@ interface ICompletionSchema {
491
491
  */
492
492
  type CompletionName = string;
493
493
 
494
+ type Embeddings = number[];
495
+ interface IEmbeddingCallbacks {
496
+ onCreate(text: string, embeddings: Embeddings, clientId: string, embeddingName: EmbeddingName): void;
497
+ onCompare(text1: string, text2: string, similarity: number, clientId: string, embeddingName: EmbeddingName): void;
498
+ }
499
+ interface IEmbeddingSchema {
500
+ embeddingName: EmbeddingName;
501
+ createEmbedding(text: string): Promise<Embeddings>;
502
+ calculateSimilarity(a: Embeddings, b: Embeddings): Promise<number>;
503
+ callbacks?: Partial<IEmbeddingCallbacks>;
504
+ }
505
+ type EmbeddingName = string;
506
+
507
+ type StorageId = string | number;
508
+ interface IStorageData {
509
+ id: StorageId;
510
+ }
511
+ interface IStorageSchema<T extends IStorageData = IStorageData> {
512
+ getData?: (clientId: string, storageName: StorageName) => Promise<T[]> | T[];
513
+ createIndex(item: T): Promise<string>;
514
+ embedding: EmbeddingName;
515
+ storageName: StorageName;
516
+ callbacks?: Partial<IStorageCallbacks<T>>;
517
+ }
518
+ interface IStorageCallbacks<T extends IStorageData = IStorageData> {
519
+ onUpdate: (items: T[], clientId: string, storageName: StorageName) => void;
520
+ }
521
+ interface IStorageParams<T extends IStorageData = IStorageData> extends IStorageSchema<T>, Partial<IEmbeddingCallbacks> {
522
+ clientId: string;
523
+ calculateSimilarity: IEmbeddingSchema["calculateSimilarity"];
524
+ createEmbedding: IEmbeddingSchema["createEmbedding"];
525
+ storageName: StorageName;
526
+ logger: ILogger;
527
+ }
528
+ interface IStorage<T extends IStorageData = IStorageData> {
529
+ take(search: string, total: number): Promise<T[]>;
530
+ upsert(item: T): Promise<void>;
531
+ remove(itemId: IStorageData["id"]): Promise<void>;
532
+ get(itemId: IStorageData["id"]): Promise<T | null>;
533
+ list(filter?: (item: T) => boolean): Promise<T[]>;
534
+ clear(): Promise<void>;
535
+ }
536
+ type StorageName = string;
537
+
494
538
  /**
495
539
  * Interface representing lifecycle callbacks of a tool
496
540
  * @template T - The type of the parameters for the tool.
@@ -522,6 +566,14 @@ interface IAgentToolCallbacks<T = Record<string, unknown>> {
522
566
  * @returns A promise that resolves to a boolean indicating whether the parameters are valid.
523
567
  */
524
568
  onValidate?: (clientId: string, agentName: AgentName, params: T) => Promise<boolean>;
569
+ /**
570
+ * Callback triggered when the tool fails to execute
571
+ * @param clientId - The ID of the client.
572
+ * @param agentName - The name of the agent.
573
+ * @param params - The parameters for the tool.
574
+ * @returns A promise that resolves to a boolean indicating whether the parameters are valid.
575
+ */
576
+ onCallError?: (toolId: string, clientId: string, agentName: AgentName, params: T, error: Error) => Promise<void>;
525
577
  }
526
578
  /**
527
579
  * Interface representing a tool used by an agent.
@@ -676,6 +728,8 @@ interface IAgentSchema {
676
728
  system?: string[];
677
729
  /** The names of the tools used by the agent. */
678
730
  tools?: ToolName[];
731
+ /** The names of the storages used by the agent. */
732
+ storages?: StorageName[];
679
733
  /**
680
734
  * Validates the output.
681
735
  * @param output - The output to validate.
@@ -742,6 +796,7 @@ interface IContext {
742
796
  clientId: string;
743
797
  agentName: AgentName;
744
798
  swarmName: SwarmName;
799
+ storageName: StorageName;
745
800
  }
746
801
  /**
747
802
  * Service providing context information.
@@ -783,6 +838,7 @@ declare class LoggerService implements ILogger {
783
838
  */
784
839
  declare class ClientAgent implements IAgent {
785
840
  readonly params: IAgentParams;
841
+ readonly _toolErrorSubject: Subject<void>;
786
842
  readonly _toolCommitSubject: Subject<void>;
787
843
  readonly _outputSubject: Subject<string>;
788
844
  /**
@@ -1154,16 +1210,16 @@ declare class CompletionSchemaService {
1154
1210
  private registry;
1155
1211
  /**
1156
1212
  * Registers a new completion schema.
1157
- * @param {string} key - The key for the schema.
1213
+ * @param {CompletionName} key - The key for the schema.
1158
1214
  * @param {ICompletionSchema} value - The schema to register.
1159
1215
  */
1160
- register: (key: string, value: ICompletionSchema) => void;
1216
+ register: (key: CompletionName, value: ICompletionSchema) => void;
1161
1217
  /**
1162
1218
  * Retrieves a completion schema by key.
1163
- * @param {string} key - The key of the schema to retrieve.
1219
+ * @param {CompletionName} key - The key of the schema to retrieve.
1164
1220
  * @returns {ICompletionSchema} The retrieved schema.
1165
1221
  */
1166
- get: (key: string) => ICompletionSchema;
1222
+ get: (key: CompletionName) => ICompletionSchema;
1167
1223
  }
1168
1224
 
1169
1225
  /**
@@ -1295,11 +1351,11 @@ declare class SessionConnectionService implements ISession {
1295
1351
 
1296
1352
  interface IAgentConnectionService extends AgentConnectionService {
1297
1353
  }
1298
- type InternalKeys$3 = keyof {
1354
+ type InternalKeys$4 = keyof {
1299
1355
  getAgent: never;
1300
1356
  };
1301
1357
  type TAgentConnectionService = {
1302
- [key in Exclude<keyof IAgentConnectionService, InternalKeys$3>]: unknown;
1358
+ [key in Exclude<keyof IAgentConnectionService, InternalKeys$4>]: unknown;
1303
1359
  };
1304
1360
  /**
1305
1361
  * Service for managing public agent operations.
@@ -1372,12 +1428,12 @@ declare class AgentPublicService implements TAgentConnectionService {
1372
1428
 
1373
1429
  interface IHistoryConnectionService extends HistoryConnectionService {
1374
1430
  }
1375
- type InternalKeys$2 = keyof {
1431
+ type InternalKeys$3 = keyof {
1376
1432
  getHistory: never;
1377
1433
  getItems: never;
1378
1434
  };
1379
1435
  type THistoryConnectionService = {
1380
- [key in Exclude<keyof IHistoryConnectionService, InternalKeys$2>]: unknown;
1436
+ [key in Exclude<keyof IHistoryConnectionService, InternalKeys$3>]: unknown;
1381
1437
  };
1382
1438
  /**
1383
1439
  * Service for handling public history operations.
@@ -1419,11 +1475,11 @@ declare class HistoryPublicService implements THistoryConnectionService {
1419
1475
 
1420
1476
  interface ISessionConnectionService extends SessionConnectionService {
1421
1477
  }
1422
- type InternalKeys$1 = keyof {
1478
+ type InternalKeys$2 = keyof {
1423
1479
  getSession: never;
1424
1480
  };
1425
1481
  type TSessionConnectionService = {
1426
- [key in Exclude<keyof ISessionConnectionService, InternalKeys$1>]: unknown;
1482
+ [key in Exclude<keyof ISessionConnectionService, InternalKeys$2>]: unknown;
1427
1483
  };
1428
1484
  /**
1429
1485
  * Service for managing public session interactions.
@@ -1498,11 +1554,11 @@ declare class SessionPublicService implements TSessionConnectionService {
1498
1554
 
1499
1555
  interface ISwarmConnectionService extends SwarmConnectionService {
1500
1556
  }
1501
- type InternalKeys = keyof {
1557
+ type InternalKeys$1 = keyof {
1502
1558
  getSwarm: never;
1503
1559
  };
1504
1560
  type TSwarmConnectionService = {
1505
- [key in Exclude<keyof ISwarmConnectionService, InternalKeys>]: unknown;
1561
+ [key in Exclude<keyof ISwarmConnectionService, InternalKeys$1>]: unknown;
1506
1562
  };
1507
1563
  /**
1508
1564
  * Service for managing public swarm interactions.
@@ -1564,7 +1620,15 @@ declare class AgentValidationService {
1564
1620
  private readonly loggerService;
1565
1621
  private readonly toolValidationService;
1566
1622
  private readonly completionValidationService;
1623
+ private readonly storageValidationService;
1567
1624
  private _agentMap;
1625
+ /**
1626
+ * Retrieves the storages used by the agent
1627
+ * @param {agentName} agentName - The name of the swarm.
1628
+ * @returns {string[]} The list of storage names.
1629
+ * @throws Will throw an error if the swarm is not found.
1630
+ */
1631
+ getStorageList: (agentName: string) => string[];
1568
1632
  /**
1569
1633
  * Adds a new agent to the validation service.
1570
1634
  * @param {AgentName} agentName - The name of the agent.
@@ -1572,6 +1636,10 @@ declare class AgentValidationService {
1572
1636
  * @throws {Error} If the agent already exists.
1573
1637
  */
1574
1638
  addAgent: (agentName: AgentName, agentSchema: IAgentSchema) => void;
1639
+ /**
1640
+ * Check if agent got registered storage
1641
+ */
1642
+ hasStorage: ((agentName: AgentName, storageName: StorageName) => boolean) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, boolean>;
1575
1643
  /**
1576
1644
  * Validates an agent by its name and source.
1577
1645
  * @param {AgentName} agentName - The name of the agent.
@@ -1747,24 +1815,247 @@ declare class CompletionValidationService {
1747
1815
  validate: (completionName: CompletionName, source: string) => void;
1748
1816
  }
1749
1817
 
1818
+ /**
1819
+ * Service for managing embedding schemas.
1820
+ */
1821
+ declare class EmbeddingSchemaService {
1822
+ private readonly loggerService;
1823
+ private registry;
1824
+ /**
1825
+ * Registers a embedding with the given key and value.
1826
+ * @param {EmbeddingName} key - The name of the embedding.
1827
+ * @param {IAgentTool} value - The embedding to register.
1828
+ */
1829
+ register: (key: EmbeddingName, value: IEmbeddingSchema) => void;
1830
+ /**
1831
+ * Retrieves a embedding by its key.
1832
+ * @param {EmbeddingName} key - The name of the embedding.
1833
+ * @returns {IAgentTool} The embedding associated with the given key.
1834
+ */
1835
+ get: (key: EmbeddingName) => IEmbeddingSchema;
1836
+ }
1837
+
1838
+ /**
1839
+ * Service for managing storage schemas.
1840
+ */
1841
+ declare class StorageSchemaService {
1842
+ readonly loggerService: LoggerService;
1843
+ private registry;
1844
+ /**
1845
+ * Registers a new storage schema.
1846
+ * @param {StorageName} key - The key for the schema.
1847
+ * @param {IStorageSchema} value - The schema to register.
1848
+ */
1849
+ register: (key: StorageName, value: IStorageSchema) => void;
1850
+ /**
1851
+ * Retrieves a storage schema by key.
1852
+ * @param {StorageName} key - The key of the schema to retrieve.
1853
+ * @returns {IStorageSchema} The retrieved schema.
1854
+ */
1855
+ get: (key: StorageName) => IStorageSchema;
1856
+ }
1857
+
1858
+ declare class ClientStorage<T extends IStorageData = IStorageData> implements IStorage<T> {
1859
+ readonly params: IStorageParams<T>;
1860
+ private _itemMap;
1861
+ constructor(params: IStorageParams<T>);
1862
+ _createEmbedding: ((item: T) => Promise<readonly [Embeddings, string]>) & functools_kit.IClearableMemoize<string | number> & functools_kit.IControlMemoize<string | number, Promise<readonly [Embeddings, string]>>;
1863
+ waitForInit: (() => Promise<void>) & functools_kit.ISingleshotClearable;
1864
+ take: (search: string, total: number) => Promise<T[]>;
1865
+ upsert: (item: T) => Promise<void>;
1866
+ remove: (itemId: IStorageData["id"]) => Promise<void>;
1867
+ clear: () => Promise<void>;
1868
+ get: (itemId: IStorageData["id"]) => Promise<T | null>;
1869
+ list: (filter?: (item: T) => boolean) => Promise<T[]>;
1870
+ }
1871
+
1872
+ /**
1873
+ * Service for managing storage connections.
1874
+ * @implements {IStorage}
1875
+ */
1876
+ declare class StorageConnectionService implements IStorage {
1877
+ private readonly loggerService;
1878
+ private readonly contextService;
1879
+ private readonly storageSchemaService;
1880
+ private readonly embeddingSchemaService;
1881
+ /**
1882
+ * Retrieves a storage instance based on client ID and storage name.
1883
+ * @param {string} clientId - The client ID.
1884
+ * @param {string} storageName - The storage name.
1885
+ * @returns {ClientStorage} The client storage instance.
1886
+ */
1887
+ getStorage: ((clientId: string, storageName: StorageName) => ClientStorage<IStorageData>) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientStorage<IStorageData>>;
1888
+ /**
1889
+ * Retrieves a list of storage data based on a search query and total number of items.
1890
+ * @param {string} search - The search query.
1891
+ * @param {number} total - The total number of items to retrieve.
1892
+ * @returns {Promise<IStorageData[]>} The list of storage data.
1893
+ */
1894
+ take: (search: string, total: number) => Promise<IStorageData[]>;
1895
+ /**
1896
+ * Upserts an item in the storage.
1897
+ * @param {IStorageData} item - The item to upsert.
1898
+ * @returns {Promise<void>}
1899
+ */
1900
+ upsert: (item: IStorageData) => Promise<void>;
1901
+ /**
1902
+ * Removes an item from the storage.
1903
+ * @param {IStorageData["id"]} itemId - The ID of the item to remove.
1904
+ * @returns {Promise<void>}
1905
+ */
1906
+ remove: (itemId: IStorageData["id"]) => Promise<void>;
1907
+ /**
1908
+ * Retrieves an item from the storage by its ID.
1909
+ * @param {IStorageData["id"]} itemId - The ID of the item to retrieve.
1910
+ * @returns {Promise<IStorageData>} The retrieved item.
1911
+ */
1912
+ get: (itemId: IStorageData["id"]) => Promise<IStorageData | null>;
1913
+ /**
1914
+ * Retrieves a list of items from the storage, optionally filtered by a predicate function.
1915
+ * @param {function(IStorageData): boolean} [filter] - The optional filter function.
1916
+ * @returns {Promise<IStorageData[]>} The list of items.
1917
+ */
1918
+ list: (filter?: (item: IStorageData) => boolean) => Promise<IStorageData[]>;
1919
+ /**
1920
+ * Clears all items from the storage.
1921
+ * @returns {Promise<void>}
1922
+ */
1923
+ clear: () => Promise<void>;
1924
+ /**
1925
+ * Disposes of the storage connection.
1926
+ * @returns {Promise<void>}
1927
+ */
1928
+ dispose: () => Promise<void>;
1929
+ }
1930
+
1931
+ interface IStorageConnectionService extends StorageConnectionService {
1932
+ }
1933
+ type InternalKeys = keyof {
1934
+ getStorage: never;
1935
+ };
1936
+ type TStorageConnectionService = {
1937
+ [key in Exclude<keyof IStorageConnectionService, InternalKeys>]: unknown;
1938
+ };
1939
+ /**
1940
+ * Service for managing public storage interactions.
1941
+ */
1942
+ declare class StoragePublicService implements TStorageConnectionService {
1943
+ private readonly loggerService;
1944
+ private readonly storageConnectionService;
1945
+ /**
1946
+ * Retrieves a list of storage data based on a search query and total number of items.
1947
+ * @param {string} search - The search query.
1948
+ * @param {number} total - The total number of items to retrieve.
1949
+ * @returns {Promise<IStorageData[]>} The list of storage data.
1950
+ */
1951
+ take: (search: string, total: number, clientId: string, storageName: StorageName) => Promise<IStorageData[]>;
1952
+ /**
1953
+ * Upserts an item in the storage.
1954
+ * @param {IStorageData} item - The item to upsert.
1955
+ * @returns {Promise<void>}
1956
+ */
1957
+ upsert: (item: IStorageData, clientId: string, storageName: StorageName) => Promise<void>;
1958
+ /**
1959
+ * Removes an item from the storage.
1960
+ * @param {IStorageData["id"]} itemId - The ID of the item to remove.
1961
+ * @returns {Promise<void>}
1962
+ */
1963
+ remove: (itemId: IStorageData["id"], clientId: string, storageName: StorageName) => Promise<void>;
1964
+ /**
1965
+ * Retrieves an item from the storage by its ID.
1966
+ * @param {IStorageData["id"]} itemId - The ID of the item to retrieve.
1967
+ * @returns {Promise<IStorageData>} The retrieved item.
1968
+ */
1969
+ get: (itemId: IStorageData["id"], clientId: string, storageName: StorageName) => Promise<IStorageData | null>;
1970
+ /**
1971
+ * Retrieves a list of items from the storage, optionally filtered by a predicate function.
1972
+ * @param {function(IStorageData): boolean} [filter] - The optional filter function.
1973
+ * @returns {Promise<IStorageData[]>} The list of items.
1974
+ */
1975
+ list: (clientId: string, storageName: StorageName, filter?: (item: IStorageData) => boolean) => Promise<IStorageData[]>;
1976
+ /**
1977
+ * Clears all items from the storage.
1978
+ * @returns {Promise<void>}
1979
+ */
1980
+ clear: (clientId: string, storageName: StorageName) => Promise<void>;
1981
+ /**
1982
+ * Disposes of the storage.
1983
+ * @param {string} clientId - The client ID.
1984
+ * @param {StorageName} storageName - The storage name.
1985
+ * @returns {Promise<void>}
1986
+ */
1987
+ dispose: (clientId: string, storageName: StorageName) => Promise<void>;
1988
+ }
1989
+
1990
+ /**
1991
+ * Service for validating storages within the storage swarm.
1992
+ */
1993
+ declare class StorageValidationService {
1994
+ private readonly loggerService;
1995
+ private readonly embeddingValidationService;
1996
+ private _storageMap;
1997
+ /**
1998
+ * Adds a new storage to the validation service.
1999
+ * @param {StorageName} storageName - The name of the storage.
2000
+ * @param {IStorageSchema} storageSchema - The schema of the storage.
2001
+ * @throws {Error} If the storage already exists.
2002
+ */
2003
+ addStorage: (storageName: StorageName, storageSchema: IStorageSchema) => void;
2004
+ /**
2005
+ * Validates an storage by its name and source.
2006
+ * @param {StorageName} storageName - The name of the storage.
2007
+ * @param {string} source - The source of the validation request.
2008
+ * @throws {Error} If the storage is not found.
2009
+ */
2010
+ validate: (storageName: StorageName, source: string) => void;
2011
+ }
2012
+
2013
+ /**
2014
+ * Service for validating embeddings within the agent-swarm.
2015
+ */
2016
+ declare class EmbeddingValidationService {
2017
+ private readonly loggerService;
2018
+ private _embeddingMap;
2019
+ /**
2020
+ * Adds a new embedding to the validation service.
2021
+ * @param {EmbeddingName} embeddingName - The name of the embedding to add.
2022
+ * @param {IAgentEmbedding} embeddingSchema - The schema of the embedding to add.
2023
+ * @throws Will throw an error if the embedding already exists.
2024
+ */
2025
+ addEmbedding: (embeddingName: EmbeddingName, embeddingSchema: IEmbeddingSchema) => void;
2026
+ /**
2027
+ * Validates if a embedding exists in the validation service.
2028
+ * @param {EmbeddingName} embeddingName - The name of the embedding to validate.
2029
+ * @param {string} source - The source of the validation request.
2030
+ * @throws Will throw an error if the embedding is not found.
2031
+ */
2032
+ validate: (embeddingName: EmbeddingName, source: string) => void;
2033
+ }
2034
+
1750
2035
  declare const swarm: {
1751
2036
  agentValidationService: AgentValidationService;
1752
2037
  toolValidationService: ToolValidationService;
1753
2038
  sessionValidationService: SessionValidationService;
1754
2039
  swarmValidationService: SwarmValidationService;
1755
2040
  completionValidationService: CompletionValidationService;
2041
+ storageValidationService: StorageValidationService;
2042
+ embeddingValidationService: EmbeddingValidationService;
1756
2043
  agentPublicService: AgentPublicService;
1757
2044
  historyPublicService: HistoryPublicService;
1758
2045
  sessionPublicService: SessionPublicService;
1759
2046
  swarmPublicService: SwarmPublicService;
2047
+ storagePublicService: StoragePublicService;
1760
2048
  agentSchemaService: AgentSchemaService;
1761
2049
  toolSchemaService: ToolSchemaService;
1762
2050
  swarmSchemaService: SwarmSchemaService;
1763
2051
  completionSchemaService: CompletionSchemaService;
2052
+ embeddingSchemaService: EmbeddingSchemaService;
2053
+ storageSchemaService: StorageSchemaService;
1764
2054
  agentConnectionService: AgentConnectionService;
1765
2055
  historyConnectionService: HistoryConnectionService;
1766
2056
  swarmConnectionService: SwarmConnectionService;
1767
2057
  sessionConnectionService: SessionConnectionService;
2058
+ storageConnectionService: StorageConnectionService;
1768
2059
  loggerService: LoggerService;
1769
2060
  contextService: {
1770
2061
  readonly context: IContext;
@@ -1805,6 +2096,22 @@ declare const addSwarm: (swarmSchema: ISwarmSchema) => string;
1805
2096
  */
1806
2097
  declare const addTool: (toolSchema: IAgentTool) => string;
1807
2098
 
2099
+ /**
2100
+ * Adds a new embedding to the embedding registry. The swarm takes only those embeddings which was registered
2101
+ *
2102
+ * @param {IEmbeddingSchema} embeddingSchema - The schema of the embedding to be added.
2103
+ * @returns {string} The name of the added embedding.
2104
+ */
2105
+ declare const addEmbedding: (embeddingSchema: IEmbeddingSchema) => string;
2106
+
2107
+ /**
2108
+ * Adds a new storage to the storage registry. The swarm takes only those storages which was registered
2109
+ *
2110
+ * @param {IStorageSchema} storageSchema - The schema of the storage to be added.
2111
+ * @returns {string} The name of the added storage.
2112
+ */
2113
+ declare const addStorage: <T extends IStorageData = IStorageData>(storageSchema: IStorageSchema<T>) => string;
2114
+
1808
2115
  type SendMessageFn = (outgoing: string) => Promise<void>;
1809
2116
  /**
1810
2117
  * A connection factory for a client to a swarm and returns a function to send messages.
@@ -2171,7 +2478,74 @@ declare const GLOBAL_CONFIG: {
2171
2478
  CC_AGENT_SEPARATE_HISTORY: boolean;
2172
2479
  CC_AGENT_DISALLOWED_TAGS: string[];
2173
2480
  CC_AGENT_DISALLOWED_SYMBOLS: string[];
2481
+ CC_STORAGE_SEARCH_SIMILARITY: number;
2482
+ CC_STORAGE_SEARCH_POOL: number;
2174
2483
  };
2175
2484
  declare const setConfig: (config: Partial<typeof GLOBAL_CONFIG>) => void;
2176
2485
 
2177
- export { ContextService, type IAgentSchema, type IAgentTool, type ICompletionArgs, type ICompletionSchema, type IIncomingMessage, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type ISwarmSchema, type ITool, type IToolCall, type ReceiveMessageFn, type SendMessageFn$1 as SendMessageFn, addAgent, addCompletion, 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 };
2486
+ type TStorage = {
2487
+ [key in keyof IStorage]: unknown;
2488
+ };
2489
+ declare class StorageUtils implements TStorage {
2490
+ /**
2491
+ * Takes items from the storage.
2492
+ * @param {string} search - The search query.
2493
+ * @param {number} total - The total number of items to take.
2494
+ * @param {string} clientId - The client ID.
2495
+ * @param {AgentName} agentName - The agent name.
2496
+ * @param {StorageName} storageName - The storage name.
2497
+ * @returns {Promise<T[]>} - A promise that resolves to an array of items.
2498
+ * @template T
2499
+ */
2500
+ take: <T extends IStorageData = IStorageData>(search: string, total: number, clientId: string, agentName: AgentName, storageName: StorageName) => Promise<T[]>;
2501
+ /**
2502
+ * Upserts an item in the storage.
2503
+ * @param {T} item - The item to upsert.
2504
+ * @param {string} clientId - The client ID.
2505
+ * @param {AgentName} agentName - The agent name.
2506
+ * @param {StorageName} storageName - The storage name.
2507
+ * @returns {Promise<void>} - A promise that resolves when the operation is complete.
2508
+ * @template T
2509
+ */
2510
+ upsert: <T extends IStorageData = IStorageData>(item: T, clientId: string, agentName: AgentName, storageName: StorageName) => Promise<void>;
2511
+ /**
2512
+ * Removes an item from the storage.
2513
+ * @param {IStorageData["id"]} itemId - The ID of the item to remove.
2514
+ * @param {string} clientId - The client ID.
2515
+ * @param {AgentName} agentName - The agent name.
2516
+ * @param {StorageName} storageName - The storage name.
2517
+ * @returns {Promise<void>} - A promise that resolves when the operation is complete.
2518
+ */
2519
+ remove: (itemId: IStorageData["id"], clientId: string, agentName: AgentName, storageName: StorageName) => Promise<void>;
2520
+ /**
2521
+ * Gets an item from the storage.
2522
+ * @param {IStorageData["id"]} itemId - The ID of the item to get.
2523
+ * @param {string} clientId - The client ID.
2524
+ * @param {AgentName} agentName - The agent name.
2525
+ * @param {StorageName} storageName - The storage name.
2526
+ * @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
2527
+ * @template T
2528
+ */
2529
+ get: <T extends IStorageData = IStorageData>(itemId: IStorageData["id"], clientId: string, agentName: AgentName, storageName: StorageName) => Promise<T | null>;
2530
+ /**
2531
+ * Lists items from the storage.
2532
+ * @param {string} clientId - The client ID.
2533
+ * @param {AgentName} agentName - The agent name.
2534
+ * @param {StorageName} storageName - The storage name.
2535
+ * @param {(item: T) => boolean} [filter] - Optional filter function.
2536
+ * @returns {Promise<T[]>} - A promise that resolves to an array of items.
2537
+ * @template T
2538
+ */
2539
+ list: <T extends IStorageData = IStorageData>(clientId: string, agentName: AgentName, storageName: StorageName, filter?: (item: T) => boolean) => Promise<T[]>;
2540
+ /**
2541
+ * Clears the storage.
2542
+ * @param {string} clientId - The client ID.
2543
+ * @param {AgentName} agentName - The agent name.
2544
+ * @param {StorageName} storageName - The storage name.
2545
+ * @returns {Promise<void>} - A promise that resolves when the operation is complete.
2546
+ */
2547
+ clear: (clientId: string, agentName: AgentName, storageName: StorageName) => Promise<void>;
2548
+ }
2549
+ declare const Storage: StorageUtils;
2550
+
2551
+ export { ContextService, type IAgentSchema, type IAgentTool, type ICompletionArgs, type ICompletionSchema, type IEmbeddingSchema, type IIncomingMessage, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, type ReceiveMessageFn, type SendMessageFn$1 as SendMessageFn, Storage, addAgent, addCompletion, addEmbedding, 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 };