agent-swarm-kit 1.0.55 → 1.0.56

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 CHANGED
@@ -1232,7 +1232,12 @@ var ClientHistory = /** @class */ (function () {
1232
1232
  commonMessages = commonMessagesRaw
1233
1233
  .filter(this._filterCondition)
1234
1234
  .slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);
1235
- assistantToolOutputCallSet = new Set(commonMessages.map(function (_a) {
1235
+ assistantToolOutputCallSet = new Set(commonMessages
1236
+ .filter(function (_a) {
1237
+ var tool_call_id = _a.tool_call_id;
1238
+ return !!tool_call_id;
1239
+ })
1240
+ .map(function (_a) {
1236
1241
  var tool_call_id = _a.tool_call_id;
1237
1242
  return tool_call_id;
1238
1243
  }));
@@ -1250,8 +1255,8 @@ var ClientHistory = /** @class */ (function () {
1250
1255
  });
1251
1256
  assistantToolCallSet = new Set(assistantRawMessages
1252
1257
  .filter(function (_a) {
1253
- var role = _a.role;
1254
- return role === "tool";
1258
+ var tool_calls = _a.tool_calls;
1259
+ return !!tool_calls;
1255
1260
  })
1256
1261
  .flatMap(function (_a) {
1257
1262
  var tool_calls = _a.tool_calls;
@@ -1261,8 +1266,8 @@ var ClientHistory = /** @class */ (function () {
1261
1266
  });
1262
1267
  }));
1263
1268
  assistantMessages = assistantRawMessages.filter(function (_a) {
1264
- var role = _a.role, tool_call_id = _a.tool_call_id;
1265
- if (role === "tool") {
1269
+ var tool_call_id = _a.tool_call_id;
1270
+ if (tool_call_id) {
1266
1271
  return assistantToolCallSet.has(tool_call_id);
1267
1272
  }
1268
1273
  return true;
@@ -3699,11 +3704,24 @@ var StorageSchemaService = /** @class */ (function () {
3699
3704
  return StorageSchemaService;
3700
3705
  }());
3701
3706
 
3707
+ /**
3708
+ * ClientStorage class to manage storage operations.
3709
+ * @template T - The type of storage data.
3710
+ */
3702
3711
  var ClientStorage = /** @class */ (function () {
3712
+ /**
3713
+ * Creates an instance of ClientStorage.
3714
+ * @param {IStorageParams<T>} params - The storage parameters.
3715
+ */
3703
3716
  function ClientStorage(params) {
3704
3717
  var _this = this;
3705
3718
  this.params = params;
3706
3719
  this._itemMap = new Map();
3720
+ /**
3721
+ * Creates an embedding for the given item.
3722
+ * @param {T} item - The item to create an embedding for.
3723
+ * @returns {Promise<readonly [any, any]>} - The embeddings and index.
3724
+ */
3707
3725
  this._createEmbedding = functoolsKit.memoize(function (_a) {
3708
3726
  var _b = __read(_a, 1), id = _b[0].id;
3709
3727
  return id;
@@ -3728,6 +3746,10 @@ var ClientStorage = /** @class */ (function () {
3728
3746
  }
3729
3747
  });
3730
3748
  }); });
3749
+ /**
3750
+ * Waits for the initialization of the storage.
3751
+ * @returns {Promise<void>}
3752
+ */
3731
3753
  this.waitForInit = functoolsKit.singleshot(function () { return __awaiter(_this, void 0, void 0, function () {
3732
3754
  var data;
3733
3755
  return __generator(this, function (_a) {
@@ -3751,6 +3773,13 @@ var ClientStorage = /** @class */ (function () {
3751
3773
  }
3752
3774
  });
3753
3775
  }); });
3776
+ /**
3777
+ * Takes a specified number of items based on the search criteria.
3778
+ * @param {string} search - The search string.
3779
+ * @param {number} total - The total number of items to take.
3780
+ * @param {number} [score=GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY] - The similarity score.
3781
+ * @returns {Promise<T[]>} - The list of items.
3782
+ */
3754
3783
  this.take = function (search_1, total_1) {
3755
3784
  var args_1 = [];
3756
3785
  for (var _i = 2; _i < arguments.length; _i++) {
@@ -3809,6 +3838,11 @@ var ClientStorage = /** @class */ (function () {
3809
3838
  });
3810
3839
  });
3811
3840
  };
3841
+ /**
3842
+ * Upserts an item into the storage.
3843
+ * @param {T} item - The item to upsert.
3844
+ * @returns {Promise<void>}
3845
+ */
3812
3846
  this.upsert = function (item) { return __awaiter(_this, void 0, void 0, function () {
3813
3847
  var _a, _b;
3814
3848
  return __generator(this, function (_c) {
@@ -3829,6 +3863,11 @@ var ClientStorage = /** @class */ (function () {
3829
3863
  }
3830
3864
  });
3831
3865
  }); };
3866
+ /**
3867
+ * Removes an item from the storage.
3868
+ * @param {IStorageData["id"]} itemId - The ID of the item to remove.
3869
+ * @returns {Promise<void>}
3870
+ */
3832
3871
  this.remove = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
3833
3872
  var _a, _b;
3834
3873
  return __generator(this, function (_c) {
@@ -3843,6 +3882,10 @@ var ClientStorage = /** @class */ (function () {
3843
3882
  return [2 /*return*/];
3844
3883
  });
3845
3884
  }); };
3885
+ /**
3886
+ * Clears all items from the storage.
3887
+ * @returns {Promise<void>}
3888
+ */
3846
3889
  this.clear = function () { return __awaiter(_this, void 0, void 0, function () {
3847
3890
  return __generator(this, function (_a) {
3848
3891
  this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " clear"));
@@ -3851,6 +3894,11 @@ var ClientStorage = /** @class */ (function () {
3851
3894
  return [2 /*return*/];
3852
3895
  });
3853
3896
  }); };
3897
+ /**
3898
+ * Gets an item by its ID.
3899
+ * @param {IStorageData["id"]} itemId - The ID of the item to get.
3900
+ * @returns {Promise<T | null>} - The item or null if not found.
3901
+ */
3854
3902
  this.get = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
3855
3903
  var _a;
3856
3904
  return __generator(this, function (_b) {
@@ -3860,6 +3908,11 @@ var ClientStorage = /** @class */ (function () {
3860
3908
  return [2 /*return*/, (_a = this._itemMap.get(itemId)) !== null && _a !== void 0 ? _a : null];
3861
3909
  });
3862
3910
  }); };
3911
+ /**
3912
+ * Lists all items in the storage, optionally filtered by a predicate.
3913
+ * @param {(item: T) => boolean} [filter] - The filter predicate.
3914
+ * @returns {Promise<T[]>} - The list of items.
3915
+ */
3863
3916
  this.list = function (filter) { return __awaiter(_this, void 0, void 0, function () {
3864
3917
  var result, _a, _b, item;
3865
3918
  var e_1, _c;
package/build/index.mjs CHANGED
@@ -1230,7 +1230,12 @@ var ClientHistory = /** @class */ (function () {
1230
1230
  commonMessages = commonMessagesRaw
1231
1231
  .filter(this._filterCondition)
1232
1232
  .slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);
1233
- assistantToolOutputCallSet = new Set(commonMessages.map(function (_a) {
1233
+ assistantToolOutputCallSet = new Set(commonMessages
1234
+ .filter(function (_a) {
1235
+ var tool_call_id = _a.tool_call_id;
1236
+ return !!tool_call_id;
1237
+ })
1238
+ .map(function (_a) {
1234
1239
  var tool_call_id = _a.tool_call_id;
1235
1240
  return tool_call_id;
1236
1241
  }));
@@ -1248,8 +1253,8 @@ var ClientHistory = /** @class */ (function () {
1248
1253
  });
1249
1254
  assistantToolCallSet = new Set(assistantRawMessages
1250
1255
  .filter(function (_a) {
1251
- var role = _a.role;
1252
- return role === "tool";
1256
+ var tool_calls = _a.tool_calls;
1257
+ return !!tool_calls;
1253
1258
  })
1254
1259
  .flatMap(function (_a) {
1255
1260
  var tool_calls = _a.tool_calls;
@@ -1259,8 +1264,8 @@ var ClientHistory = /** @class */ (function () {
1259
1264
  });
1260
1265
  }));
1261
1266
  assistantMessages = assistantRawMessages.filter(function (_a) {
1262
- var role = _a.role, tool_call_id = _a.tool_call_id;
1263
- if (role === "tool") {
1267
+ var tool_call_id = _a.tool_call_id;
1268
+ if (tool_call_id) {
1264
1269
  return assistantToolCallSet.has(tool_call_id);
1265
1270
  }
1266
1271
  return true;
@@ -3697,11 +3702,24 @@ var StorageSchemaService = /** @class */ (function () {
3697
3702
  return StorageSchemaService;
3698
3703
  }());
3699
3704
 
3705
+ /**
3706
+ * ClientStorage class to manage storage operations.
3707
+ * @template T - The type of storage data.
3708
+ */
3700
3709
  var ClientStorage = /** @class */ (function () {
3710
+ /**
3711
+ * Creates an instance of ClientStorage.
3712
+ * @param {IStorageParams<T>} params - The storage parameters.
3713
+ */
3701
3714
  function ClientStorage(params) {
3702
3715
  var _this = this;
3703
3716
  this.params = params;
3704
3717
  this._itemMap = new Map();
3718
+ /**
3719
+ * Creates an embedding for the given item.
3720
+ * @param {T} item - The item to create an embedding for.
3721
+ * @returns {Promise<readonly [any, any]>} - The embeddings and index.
3722
+ */
3705
3723
  this._createEmbedding = memoize(function (_a) {
3706
3724
  var _b = __read(_a, 1), id = _b[0].id;
3707
3725
  return id;
@@ -3726,6 +3744,10 @@ var ClientStorage = /** @class */ (function () {
3726
3744
  }
3727
3745
  });
3728
3746
  }); });
3747
+ /**
3748
+ * Waits for the initialization of the storage.
3749
+ * @returns {Promise<void>}
3750
+ */
3729
3751
  this.waitForInit = singleshot(function () { return __awaiter(_this, void 0, void 0, function () {
3730
3752
  var data;
3731
3753
  return __generator(this, function (_a) {
@@ -3749,6 +3771,13 @@ var ClientStorage = /** @class */ (function () {
3749
3771
  }
3750
3772
  });
3751
3773
  }); });
3774
+ /**
3775
+ * Takes a specified number of items based on the search criteria.
3776
+ * @param {string} search - The search string.
3777
+ * @param {number} total - The total number of items to take.
3778
+ * @param {number} [score=GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY] - The similarity score.
3779
+ * @returns {Promise<T[]>} - The list of items.
3780
+ */
3752
3781
  this.take = function (search_1, total_1) {
3753
3782
  var args_1 = [];
3754
3783
  for (var _i = 2; _i < arguments.length; _i++) {
@@ -3807,6 +3836,11 @@ var ClientStorage = /** @class */ (function () {
3807
3836
  });
3808
3837
  });
3809
3838
  };
3839
+ /**
3840
+ * Upserts an item into the storage.
3841
+ * @param {T} item - The item to upsert.
3842
+ * @returns {Promise<void>}
3843
+ */
3810
3844
  this.upsert = function (item) { return __awaiter(_this, void 0, void 0, function () {
3811
3845
  var _a, _b;
3812
3846
  return __generator(this, function (_c) {
@@ -3827,6 +3861,11 @@ var ClientStorage = /** @class */ (function () {
3827
3861
  }
3828
3862
  });
3829
3863
  }); };
3864
+ /**
3865
+ * Removes an item from the storage.
3866
+ * @param {IStorageData["id"]} itemId - The ID of the item to remove.
3867
+ * @returns {Promise<void>}
3868
+ */
3830
3869
  this.remove = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
3831
3870
  var _a, _b;
3832
3871
  return __generator(this, function (_c) {
@@ -3841,6 +3880,10 @@ var ClientStorage = /** @class */ (function () {
3841
3880
  return [2 /*return*/];
3842
3881
  });
3843
3882
  }); };
3883
+ /**
3884
+ * Clears all items from the storage.
3885
+ * @returns {Promise<void>}
3886
+ */
3844
3887
  this.clear = function () { return __awaiter(_this, void 0, void 0, function () {
3845
3888
  return __generator(this, function (_a) {
3846
3889
  this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " clear"));
@@ -3849,6 +3892,11 @@ var ClientStorage = /** @class */ (function () {
3849
3892
  return [2 /*return*/];
3850
3893
  });
3851
3894
  }); };
3895
+ /**
3896
+ * Gets an item by its ID.
3897
+ * @param {IStorageData["id"]} itemId - The ID of the item to get.
3898
+ * @returns {Promise<T | null>} - The item or null if not found.
3899
+ */
3852
3900
  this.get = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
3853
3901
  var _a;
3854
3902
  return __generator(this, function (_b) {
@@ -3858,6 +3906,11 @@ var ClientStorage = /** @class */ (function () {
3858
3906
  return [2 /*return*/, (_a = this._itemMap.get(itemId)) !== null && _a !== void 0 ? _a : null];
3859
3907
  });
3860
3908
  }); };
3909
+ /**
3910
+ * Lists all items in the storage, optionally filtered by a predicate.
3911
+ * @param {(item: T) => boolean} [filter] - The filter predicate.
3912
+ * @returns {Promise<T[]>} - The list of items.
3913
+ */
3861
3914
  this.list = function (filter) { return __awaiter(_this, void 0, void 0, function () {
3862
3915
  var result, _a, _b, item;
3863
3916
  var e_1, _c;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -1855,17 +1855,65 @@ declare class StorageSchemaService {
1855
1855
  get: (key: StorageName) => IStorageSchema;
1856
1856
  }
1857
1857
 
1858
+ /**
1859
+ * ClientStorage class to manage storage operations.
1860
+ * @template T - The type of storage data.
1861
+ */
1858
1862
  declare class ClientStorage<T extends IStorageData = IStorageData> implements IStorage<T> {
1859
1863
  readonly params: IStorageParams<T>;
1860
1864
  private _itemMap;
1865
+ /**
1866
+ * Creates an instance of ClientStorage.
1867
+ * @param {IStorageParams<T>} params - The storage parameters.
1868
+ */
1861
1869
  constructor(params: IStorageParams<T>);
1870
+ /**
1871
+ * Creates an embedding for the given item.
1872
+ * @param {T} item - The item to create an embedding for.
1873
+ * @returns {Promise<readonly [any, any]>} - The embeddings and index.
1874
+ */
1862
1875
  _createEmbedding: ((item: T) => Promise<readonly [Embeddings, string]>) & functools_kit.IClearableMemoize<string | number> & functools_kit.IControlMemoize<string | number, Promise<readonly [Embeddings, string]>>;
1876
+ /**
1877
+ * Waits for the initialization of the storage.
1878
+ * @returns {Promise<void>}
1879
+ */
1863
1880
  waitForInit: (() => Promise<void>) & functools_kit.ISingleshotClearable;
1881
+ /**
1882
+ * Takes a specified number of items based on the search criteria.
1883
+ * @param {string} search - The search string.
1884
+ * @param {number} total - The total number of items to take.
1885
+ * @param {number} [score=GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY] - The similarity score.
1886
+ * @returns {Promise<T[]>} - The list of items.
1887
+ */
1864
1888
  take: (search: string, total: number, score?: number) => Promise<T[]>;
1889
+ /**
1890
+ * Upserts an item into the storage.
1891
+ * @param {T} item - The item to upsert.
1892
+ * @returns {Promise<void>}
1893
+ */
1865
1894
  upsert: (item: T) => Promise<void>;
1895
+ /**
1896
+ * Removes an item from the storage.
1897
+ * @param {IStorageData["id"]} itemId - The ID of the item to remove.
1898
+ * @returns {Promise<void>}
1899
+ */
1866
1900
  remove: (itemId: IStorageData["id"]) => Promise<void>;
1901
+ /**
1902
+ * Clears all items from the storage.
1903
+ * @returns {Promise<void>}
1904
+ */
1867
1905
  clear: () => Promise<void>;
1906
+ /**
1907
+ * Gets an item by its ID.
1908
+ * @param {IStorageData["id"]} itemId - The ID of the item to get.
1909
+ * @returns {Promise<T | null>} - The item or null if not found.
1910
+ */
1868
1911
  get: (itemId: IStorageData["id"]) => Promise<T | null>;
1912
+ /**
1913
+ * Lists all items in the storage, optionally filtered by a predicate.
1914
+ * @param {(item: T) => boolean} [filter] - The filter predicate.
1915
+ * @returns {Promise<T[]>} - The list of items.
1916
+ */
1869
1917
  list: (filter?: (item: T) => boolean) => Promise<T[]>;
1870
1918
  }
1871
1919