agent-swarm-kit 1.0.55 → 1.0.57

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
@@ -1230,9 +1230,18 @@ var ClientHistory = /** @class */ (function () {
1230
1230
  return agentName === _this.params.agentName;
1231
1231
  });
1232
1232
  commonMessages = commonMessagesRaw
1233
+ .map(function (_a) {
1234
+ var content = _a.content, tool_calls = _a.tool_calls, other = __rest(_a, ["content", "tool_calls"]);
1235
+ return (__assign(__assign({}, other), { tool_calls: tool_calls, content: (tool_calls === null || tool_calls === void 0 ? void 0 : tool_calls.length) ? "" : content }));
1236
+ })
1233
1237
  .filter(this._filterCondition)
1234
1238
  .slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);
1235
- assistantToolOutputCallSet = new Set(commonMessages.map(function (_a) {
1239
+ assistantToolOutputCallSet = new Set(commonMessages
1240
+ .filter(function (_a) {
1241
+ var tool_call_id = _a.tool_call_id;
1242
+ return !!tool_call_id;
1243
+ })
1244
+ .map(function (_a) {
1236
1245
  var tool_call_id = _a.tool_call_id;
1237
1246
  return tool_call_id;
1238
1247
  }));
@@ -1250,8 +1259,8 @@ var ClientHistory = /** @class */ (function () {
1250
1259
  });
1251
1260
  assistantToolCallSet = new Set(assistantRawMessages
1252
1261
  .filter(function (_a) {
1253
- var role = _a.role;
1254
- return role === "tool";
1262
+ var tool_calls = _a.tool_calls;
1263
+ return !!tool_calls;
1255
1264
  })
1256
1265
  .flatMap(function (_a) {
1257
1266
  var tool_calls = _a.tool_calls;
@@ -1261,8 +1270,8 @@ var ClientHistory = /** @class */ (function () {
1261
1270
  });
1262
1271
  }));
1263
1272
  assistantMessages = assistantRawMessages.filter(function (_a) {
1264
- var role = _a.role, tool_call_id = _a.tool_call_id;
1265
- if (role === "tool") {
1273
+ var tool_call_id = _a.tool_call_id;
1274
+ if (tool_call_id) {
1266
1275
  return assistantToolCallSet.has(tool_call_id);
1267
1276
  }
1268
1277
  return true;
@@ -3699,11 +3708,24 @@ var StorageSchemaService = /** @class */ (function () {
3699
3708
  return StorageSchemaService;
3700
3709
  }());
3701
3710
 
3711
+ /**
3712
+ * ClientStorage class to manage storage operations.
3713
+ * @template T - The type of storage data.
3714
+ */
3702
3715
  var ClientStorage = /** @class */ (function () {
3716
+ /**
3717
+ * Creates an instance of ClientStorage.
3718
+ * @param {IStorageParams<T>} params - The storage parameters.
3719
+ */
3703
3720
  function ClientStorage(params) {
3704
3721
  var _this = this;
3705
3722
  this.params = params;
3706
3723
  this._itemMap = new Map();
3724
+ /**
3725
+ * Creates an embedding for the given item.
3726
+ * @param {T} item - The item to create an embedding for.
3727
+ * @returns {Promise<readonly [any, any]>} - The embeddings and index.
3728
+ */
3707
3729
  this._createEmbedding = functoolsKit.memoize(function (_a) {
3708
3730
  var _b = __read(_a, 1), id = _b[0].id;
3709
3731
  return id;
@@ -3728,6 +3750,10 @@ var ClientStorage = /** @class */ (function () {
3728
3750
  }
3729
3751
  });
3730
3752
  }); });
3753
+ /**
3754
+ * Waits for the initialization of the storage.
3755
+ * @returns {Promise<void>}
3756
+ */
3731
3757
  this.waitForInit = functoolsKit.singleshot(function () { return __awaiter(_this, void 0, void 0, function () {
3732
3758
  var data;
3733
3759
  return __generator(this, function (_a) {
@@ -3751,6 +3777,13 @@ var ClientStorage = /** @class */ (function () {
3751
3777
  }
3752
3778
  });
3753
3779
  }); });
3780
+ /**
3781
+ * Takes a specified number of items based on the search criteria.
3782
+ * @param {string} search - The search string.
3783
+ * @param {number} total - The total number of items to take.
3784
+ * @param {number} [score=GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY] - The similarity score.
3785
+ * @returns {Promise<T[]>} - The list of items.
3786
+ */
3754
3787
  this.take = function (search_1, total_1) {
3755
3788
  var args_1 = [];
3756
3789
  for (var _i = 2; _i < arguments.length; _i++) {
@@ -3809,6 +3842,11 @@ var ClientStorage = /** @class */ (function () {
3809
3842
  });
3810
3843
  });
3811
3844
  };
3845
+ /**
3846
+ * Upserts an item into the storage.
3847
+ * @param {T} item - The item to upsert.
3848
+ * @returns {Promise<void>}
3849
+ */
3812
3850
  this.upsert = function (item) { return __awaiter(_this, void 0, void 0, function () {
3813
3851
  var _a, _b;
3814
3852
  return __generator(this, function (_c) {
@@ -3829,6 +3867,11 @@ var ClientStorage = /** @class */ (function () {
3829
3867
  }
3830
3868
  });
3831
3869
  }); };
3870
+ /**
3871
+ * Removes an item from the storage.
3872
+ * @param {IStorageData["id"]} itemId - The ID of the item to remove.
3873
+ * @returns {Promise<void>}
3874
+ */
3832
3875
  this.remove = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
3833
3876
  var _a, _b;
3834
3877
  return __generator(this, function (_c) {
@@ -3843,6 +3886,10 @@ var ClientStorage = /** @class */ (function () {
3843
3886
  return [2 /*return*/];
3844
3887
  });
3845
3888
  }); };
3889
+ /**
3890
+ * Clears all items from the storage.
3891
+ * @returns {Promise<void>}
3892
+ */
3846
3893
  this.clear = function () { return __awaiter(_this, void 0, void 0, function () {
3847
3894
  return __generator(this, function (_a) {
3848
3895
  this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " clear"));
@@ -3851,6 +3898,11 @@ var ClientStorage = /** @class */ (function () {
3851
3898
  return [2 /*return*/];
3852
3899
  });
3853
3900
  }); };
3901
+ /**
3902
+ * Gets an item by its ID.
3903
+ * @param {IStorageData["id"]} itemId - The ID of the item to get.
3904
+ * @returns {Promise<T | null>} - The item or null if not found.
3905
+ */
3854
3906
  this.get = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
3855
3907
  var _a;
3856
3908
  return __generator(this, function (_b) {
@@ -3860,6 +3912,11 @@ var ClientStorage = /** @class */ (function () {
3860
3912
  return [2 /*return*/, (_a = this._itemMap.get(itemId)) !== null && _a !== void 0 ? _a : null];
3861
3913
  });
3862
3914
  }); };
3915
+ /**
3916
+ * Lists all items in the storage, optionally filtered by a predicate.
3917
+ * @param {(item: T) => boolean} [filter] - The filter predicate.
3918
+ * @returns {Promise<T[]>} - The list of items.
3919
+ */
3863
3920
  this.list = function (filter) { return __awaiter(_this, void 0, void 0, function () {
3864
3921
  var result, _a, _b, item;
3865
3922
  var e_1, _c;
package/build/index.mjs CHANGED
@@ -1228,9 +1228,18 @@ var ClientHistory = /** @class */ (function () {
1228
1228
  return agentName === _this.params.agentName;
1229
1229
  });
1230
1230
  commonMessages = commonMessagesRaw
1231
+ .map(function (_a) {
1232
+ var content = _a.content, tool_calls = _a.tool_calls, other = __rest(_a, ["content", "tool_calls"]);
1233
+ return (__assign(__assign({}, other), { tool_calls: tool_calls, content: (tool_calls === null || tool_calls === void 0 ? void 0 : tool_calls.length) ? "" : content }));
1234
+ })
1231
1235
  .filter(this._filterCondition)
1232
1236
  .slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);
1233
- assistantToolOutputCallSet = new Set(commonMessages.map(function (_a) {
1237
+ assistantToolOutputCallSet = new Set(commonMessages
1238
+ .filter(function (_a) {
1239
+ var tool_call_id = _a.tool_call_id;
1240
+ return !!tool_call_id;
1241
+ })
1242
+ .map(function (_a) {
1234
1243
  var tool_call_id = _a.tool_call_id;
1235
1244
  return tool_call_id;
1236
1245
  }));
@@ -1248,8 +1257,8 @@ var ClientHistory = /** @class */ (function () {
1248
1257
  });
1249
1258
  assistantToolCallSet = new Set(assistantRawMessages
1250
1259
  .filter(function (_a) {
1251
- var role = _a.role;
1252
- return role === "tool";
1260
+ var tool_calls = _a.tool_calls;
1261
+ return !!tool_calls;
1253
1262
  })
1254
1263
  .flatMap(function (_a) {
1255
1264
  var tool_calls = _a.tool_calls;
@@ -1259,8 +1268,8 @@ var ClientHistory = /** @class */ (function () {
1259
1268
  });
1260
1269
  }));
1261
1270
  assistantMessages = assistantRawMessages.filter(function (_a) {
1262
- var role = _a.role, tool_call_id = _a.tool_call_id;
1263
- if (role === "tool") {
1271
+ var tool_call_id = _a.tool_call_id;
1272
+ if (tool_call_id) {
1264
1273
  return assistantToolCallSet.has(tool_call_id);
1265
1274
  }
1266
1275
  return true;
@@ -3697,11 +3706,24 @@ var StorageSchemaService = /** @class */ (function () {
3697
3706
  return StorageSchemaService;
3698
3707
  }());
3699
3708
 
3709
+ /**
3710
+ * ClientStorage class to manage storage operations.
3711
+ * @template T - The type of storage data.
3712
+ */
3700
3713
  var ClientStorage = /** @class */ (function () {
3714
+ /**
3715
+ * Creates an instance of ClientStorage.
3716
+ * @param {IStorageParams<T>} params - The storage parameters.
3717
+ */
3701
3718
  function ClientStorage(params) {
3702
3719
  var _this = this;
3703
3720
  this.params = params;
3704
3721
  this._itemMap = new Map();
3722
+ /**
3723
+ * Creates an embedding for the given item.
3724
+ * @param {T} item - The item to create an embedding for.
3725
+ * @returns {Promise<readonly [any, any]>} - The embeddings and index.
3726
+ */
3705
3727
  this._createEmbedding = memoize(function (_a) {
3706
3728
  var _b = __read(_a, 1), id = _b[0].id;
3707
3729
  return id;
@@ -3726,6 +3748,10 @@ var ClientStorage = /** @class */ (function () {
3726
3748
  }
3727
3749
  });
3728
3750
  }); });
3751
+ /**
3752
+ * Waits for the initialization of the storage.
3753
+ * @returns {Promise<void>}
3754
+ */
3729
3755
  this.waitForInit = singleshot(function () { return __awaiter(_this, void 0, void 0, function () {
3730
3756
  var data;
3731
3757
  return __generator(this, function (_a) {
@@ -3749,6 +3775,13 @@ var ClientStorage = /** @class */ (function () {
3749
3775
  }
3750
3776
  });
3751
3777
  }); });
3778
+ /**
3779
+ * Takes a specified number of items based on the search criteria.
3780
+ * @param {string} search - The search string.
3781
+ * @param {number} total - The total number of items to take.
3782
+ * @param {number} [score=GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY] - The similarity score.
3783
+ * @returns {Promise<T[]>} - The list of items.
3784
+ */
3752
3785
  this.take = function (search_1, total_1) {
3753
3786
  var args_1 = [];
3754
3787
  for (var _i = 2; _i < arguments.length; _i++) {
@@ -3807,6 +3840,11 @@ var ClientStorage = /** @class */ (function () {
3807
3840
  });
3808
3841
  });
3809
3842
  };
3843
+ /**
3844
+ * Upserts an item into the storage.
3845
+ * @param {T} item - The item to upsert.
3846
+ * @returns {Promise<void>}
3847
+ */
3810
3848
  this.upsert = function (item) { return __awaiter(_this, void 0, void 0, function () {
3811
3849
  var _a, _b;
3812
3850
  return __generator(this, function (_c) {
@@ -3827,6 +3865,11 @@ var ClientStorage = /** @class */ (function () {
3827
3865
  }
3828
3866
  });
3829
3867
  }); };
3868
+ /**
3869
+ * Removes an item from the storage.
3870
+ * @param {IStorageData["id"]} itemId - The ID of the item to remove.
3871
+ * @returns {Promise<void>}
3872
+ */
3830
3873
  this.remove = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
3831
3874
  var _a, _b;
3832
3875
  return __generator(this, function (_c) {
@@ -3841,6 +3884,10 @@ var ClientStorage = /** @class */ (function () {
3841
3884
  return [2 /*return*/];
3842
3885
  });
3843
3886
  }); };
3887
+ /**
3888
+ * Clears all items from the storage.
3889
+ * @returns {Promise<void>}
3890
+ */
3844
3891
  this.clear = function () { return __awaiter(_this, void 0, void 0, function () {
3845
3892
  return __generator(this, function (_a) {
3846
3893
  this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " clear"));
@@ -3849,6 +3896,11 @@ var ClientStorage = /** @class */ (function () {
3849
3896
  return [2 /*return*/];
3850
3897
  });
3851
3898
  }); };
3899
+ /**
3900
+ * Gets an item by its ID.
3901
+ * @param {IStorageData["id"]} itemId - The ID of the item to get.
3902
+ * @returns {Promise<T | null>} - The item or null if not found.
3903
+ */
3852
3904
  this.get = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
3853
3905
  var _a;
3854
3906
  return __generator(this, function (_b) {
@@ -3858,6 +3910,11 @@ var ClientStorage = /** @class */ (function () {
3858
3910
  return [2 /*return*/, (_a = this._itemMap.get(itemId)) !== null && _a !== void 0 ? _a : null];
3859
3911
  });
3860
3912
  }); };
3913
+ /**
3914
+ * Lists all items in the storage, optionally filtered by a predicate.
3915
+ * @param {(item: T) => boolean} [filter] - The filter predicate.
3916
+ * @returns {Promise<T[]>} - The list of items.
3917
+ */
3861
3918
  this.list = function (filter) { return __awaiter(_this, void 0, void 0, function () {
3862
3919
  var result, _a, _b, item;
3863
3920
  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.57",
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