agent-swarm-kit 1.0.59 → 1.0.61
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 +59 -59
- package/build/index.mjs +59 -59
- package/package.json +1 -1
- package/types.d.ts +39 -7
package/build/index.cjs
CHANGED
|
@@ -3869,11 +3869,12 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3869
3869
|
args_1[_i - 2] = arguments[_i];
|
|
3870
3870
|
}
|
|
3871
3871
|
return __awaiter(_this, __spreadArray([search_1, total_1], __read(args_1), false), void 0, function (search, total, score) {
|
|
3872
|
-
var indexed, searchEmbeddings
|
|
3872
|
+
var indexed, searchEmbeddings;
|
|
3873
3873
|
var _this = this;
|
|
3874
|
+
var _a, _b;
|
|
3874
3875
|
if (score === void 0) { score = GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY; }
|
|
3875
|
-
return __generator(this, function (
|
|
3876
|
-
switch (
|
|
3876
|
+
return __generator(this, function (_c) {
|
|
3877
|
+
switch (_c.label) {
|
|
3877
3878
|
case 0:
|
|
3878
3879
|
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " take"), {
|
|
3879
3880
|
search: search,
|
|
@@ -3882,7 +3883,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3882
3883
|
indexed = new functoolsKit.SortedArray();
|
|
3883
3884
|
return [4 /*yield*/, this.params.createEmbedding(search)];
|
|
3884
3885
|
case 1:
|
|
3885
|
-
searchEmbeddings =
|
|
3886
|
+
searchEmbeddings = _c.sent();
|
|
3886
3887
|
if (this.params.onCreate) {
|
|
3887
3888
|
this.params.onCreate(search, searchEmbeddings, this.params.clientId, this.params.embedding);
|
|
3888
3889
|
}
|
|
@@ -3899,7 +3900,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3899
3900
|
if (this.params.onCompare) {
|
|
3900
3901
|
this.params.onCompare(search, index, score, this.params.clientId, this.params.embedding);
|
|
3901
3902
|
}
|
|
3902
|
-
indexed.push(
|
|
3903
|
+
indexed.push(item, score);
|
|
3903
3904
|
return [2 /*return*/];
|
|
3904
3905
|
}
|
|
3905
3906
|
});
|
|
@@ -3908,15 +3909,14 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3908
3909
|
maxExec: GLOBAL_CONFIG.CC_STORAGE_SEARCH_POOL,
|
|
3909
3910
|
})))];
|
|
3910
3911
|
case 2:
|
|
3911
|
-
|
|
3912
|
+
_c.sent();
|
|
3912
3913
|
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " take indexed"), {
|
|
3913
3914
|
indexed: indexed.getEntries(),
|
|
3914
3915
|
});
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
})];
|
|
3916
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onSearch) {
|
|
3917
|
+
(_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onSearch(search, indexed, this.params.clientId, this.params.storageName);
|
|
3918
|
+
}
|
|
3919
|
+
return [2 /*return*/, indexed.take(total, score)];
|
|
3920
3920
|
}
|
|
3921
3921
|
});
|
|
3922
3922
|
});
|
|
@@ -5922,22 +5922,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5922
5922
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
5923
5923
|
* @template T
|
|
5924
5924
|
*/
|
|
5925
|
-
this.take = function (
|
|
5925
|
+
this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
5926
5926
|
return __generator(this, function (_a) {
|
|
5927
5927
|
switch (_a.label) {
|
|
5928
5928
|
case 0:
|
|
5929
5929
|
swarm.loggerService.log("StorageStatic take", {
|
|
5930
|
-
search: search,
|
|
5931
|
-
total: total,
|
|
5932
|
-
clientId: clientId,
|
|
5933
|
-
storageName: storageName,
|
|
5934
|
-
score: score,
|
|
5930
|
+
search: payload.search,
|
|
5931
|
+
total: payload.total,
|
|
5932
|
+
clientId: payload.clientId,
|
|
5933
|
+
storageName: payload.storageName,
|
|
5934
|
+
score: payload.score,
|
|
5935
5935
|
});
|
|
5936
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
5937
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
5938
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (take)"));
|
|
5936
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
5937
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5938
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
5939
5939
|
}
|
|
5940
|
-
return [4 /*yield*/, swarm.storagePublicService.take(search, total, clientId, storageName, score)];
|
|
5940
|
+
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, payload.clientId, payload.storageName, payload.score)];
|
|
5941
5941
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
5942
5942
|
}
|
|
5943
5943
|
});
|
|
@@ -5951,20 +5951,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5951
5951
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
5952
5952
|
* @template T
|
|
5953
5953
|
*/
|
|
5954
|
-
this.upsert = function (
|
|
5954
|
+
this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
5955
5955
|
return __generator(this, function (_a) {
|
|
5956
5956
|
switch (_a.label) {
|
|
5957
5957
|
case 0:
|
|
5958
5958
|
swarm.loggerService.log("StorageStatic upsert", {
|
|
5959
|
-
item: item,
|
|
5960
|
-
clientId: clientId,
|
|
5961
|
-
storageName: storageName,
|
|
5959
|
+
item: payload.item,
|
|
5960
|
+
clientId: payload.clientId,
|
|
5961
|
+
storageName: payload.storageName,
|
|
5962
5962
|
});
|
|
5963
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
5964
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
5965
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (upsert)"));
|
|
5963
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
5964
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5965
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
5966
5966
|
}
|
|
5967
|
-
return [4 /*yield*/, swarm.storagePublicService.upsert(item, clientId, storageName)];
|
|
5967
|
+
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, payload.clientId, payload.storageName)];
|
|
5968
5968
|
case 1: return [2 /*return*/, _a.sent()];
|
|
5969
5969
|
}
|
|
5970
5970
|
});
|
|
@@ -5977,20 +5977,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5977
5977
|
* @param {StorageName} storageName - The storage name.
|
|
5978
5978
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
5979
5979
|
*/
|
|
5980
|
-
this.remove = function (
|
|
5980
|
+
this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
5981
5981
|
return __generator(this, function (_a) {
|
|
5982
5982
|
switch (_a.label) {
|
|
5983
5983
|
case 0:
|
|
5984
5984
|
swarm.loggerService.log("StorageStatic remove", {
|
|
5985
|
-
itemId: itemId,
|
|
5986
|
-
clientId: clientId,
|
|
5987
|
-
storageName: storageName,
|
|
5985
|
+
itemId: payload.itemId,
|
|
5986
|
+
clientId: payload.clientId,
|
|
5987
|
+
storageName: payload.storageName,
|
|
5988
5988
|
});
|
|
5989
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
5990
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
5991
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (remove)"));
|
|
5989
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
5990
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5991
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
5992
5992
|
}
|
|
5993
|
-
return [4 /*yield*/, swarm.storagePublicService.remove(itemId, clientId, storageName)];
|
|
5993
|
+
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, payload.clientId, payload.storageName)];
|
|
5994
5994
|
case 1: return [2 /*return*/, _a.sent()];
|
|
5995
5995
|
}
|
|
5996
5996
|
});
|
|
@@ -6004,20 +6004,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6004
6004
|
* @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
|
|
6005
6005
|
* @template T
|
|
6006
6006
|
*/
|
|
6007
|
-
this.get = function (
|
|
6007
|
+
this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
6008
6008
|
return __generator(this, function (_a) {
|
|
6009
6009
|
switch (_a.label) {
|
|
6010
6010
|
case 0:
|
|
6011
6011
|
swarm.loggerService.log("StorageStatic get", {
|
|
6012
|
-
itemId: itemId,
|
|
6013
|
-
clientId: clientId,
|
|
6014
|
-
storageName: storageName,
|
|
6012
|
+
itemId: payload.itemId,
|
|
6013
|
+
clientId: payload.clientId,
|
|
6014
|
+
storageName: payload.storageName,
|
|
6015
6015
|
});
|
|
6016
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
6017
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
6018
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (get)"));
|
|
6016
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
6017
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6018
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
6019
6019
|
}
|
|
6020
|
-
return [4 /*yield*/, swarm.storagePublicService.get(itemId, clientId, storageName)];
|
|
6020
|
+
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, payload.clientId, payload.storageName)];
|
|
6021
6021
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
6022
6022
|
}
|
|
6023
6023
|
});
|
|
@@ -6031,19 +6031,19 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6031
6031
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
6032
6032
|
* @template T
|
|
6033
6033
|
*/
|
|
6034
|
-
this.list = function (
|
|
6034
|
+
this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
6035
6035
|
return __generator(this, function (_a) {
|
|
6036
6036
|
switch (_a.label) {
|
|
6037
6037
|
case 0:
|
|
6038
6038
|
swarm.loggerService.log("StorageStatic list", {
|
|
6039
|
-
clientId: clientId,
|
|
6040
|
-
storageName: storageName,
|
|
6039
|
+
clientId: payload.clientId,
|
|
6040
|
+
storageName: payload.storageName,
|
|
6041
6041
|
});
|
|
6042
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
6043
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
6044
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (list)"));
|
|
6042
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
6043
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6044
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
6045
6045
|
}
|
|
6046
|
-
return [4 /*yield*/, swarm.storagePublicService.list(clientId, storageName, filter)];
|
|
6046
|
+
return [4 /*yield*/, swarm.storagePublicService.list(payload.clientId, payload.storageName, payload.filter)];
|
|
6047
6047
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
6048
6048
|
}
|
|
6049
6049
|
});
|
|
@@ -6055,19 +6055,19 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6055
6055
|
* @param {StorageName} storageName - The storage name.
|
|
6056
6056
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
6057
6057
|
*/
|
|
6058
|
-
this.clear = function (
|
|
6058
|
+
this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
6059
6059
|
return __generator(this, function (_a) {
|
|
6060
6060
|
switch (_a.label) {
|
|
6061
6061
|
case 0:
|
|
6062
6062
|
swarm.loggerService.log("StorageStatic clear", {
|
|
6063
|
-
clientId: clientId,
|
|
6064
|
-
storageName: storageName,
|
|
6063
|
+
clientId: payload.clientId,
|
|
6064
|
+
storageName: payload.storageName,
|
|
6065
6065
|
});
|
|
6066
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
6067
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
6068
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (clear)"));
|
|
6066
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
6067
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6068
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
6069
6069
|
}
|
|
6070
|
-
return [4 /*yield*/, swarm.storagePublicService.clear(clientId, storageName)];
|
|
6070
|
+
return [4 /*yield*/, swarm.storagePublicService.clear(payload.clientId, payload.storageName)];
|
|
6071
6071
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6072
6072
|
}
|
|
6073
6073
|
});
|
package/build/index.mjs
CHANGED
|
@@ -3867,11 +3867,12 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3867
3867
|
args_1[_i - 2] = arguments[_i];
|
|
3868
3868
|
}
|
|
3869
3869
|
return __awaiter(_this, __spreadArray([search_1, total_1], __read(args_1), false), void 0, function (search, total, score) {
|
|
3870
|
-
var indexed, searchEmbeddings
|
|
3870
|
+
var indexed, searchEmbeddings;
|
|
3871
3871
|
var _this = this;
|
|
3872
|
+
var _a, _b;
|
|
3872
3873
|
if (score === void 0) { score = GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY; }
|
|
3873
|
-
return __generator(this, function (
|
|
3874
|
-
switch (
|
|
3874
|
+
return __generator(this, function (_c) {
|
|
3875
|
+
switch (_c.label) {
|
|
3875
3876
|
case 0:
|
|
3876
3877
|
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " take"), {
|
|
3877
3878
|
search: search,
|
|
@@ -3880,7 +3881,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3880
3881
|
indexed = new SortedArray();
|
|
3881
3882
|
return [4 /*yield*/, this.params.createEmbedding(search)];
|
|
3882
3883
|
case 1:
|
|
3883
|
-
searchEmbeddings =
|
|
3884
|
+
searchEmbeddings = _c.sent();
|
|
3884
3885
|
if (this.params.onCreate) {
|
|
3885
3886
|
this.params.onCreate(search, searchEmbeddings, this.params.clientId, this.params.embedding);
|
|
3886
3887
|
}
|
|
@@ -3897,7 +3898,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3897
3898
|
if (this.params.onCompare) {
|
|
3898
3899
|
this.params.onCompare(search, index, score, this.params.clientId, this.params.embedding);
|
|
3899
3900
|
}
|
|
3900
|
-
indexed.push(
|
|
3901
|
+
indexed.push(item, score);
|
|
3901
3902
|
return [2 /*return*/];
|
|
3902
3903
|
}
|
|
3903
3904
|
});
|
|
@@ -3906,15 +3907,14 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3906
3907
|
maxExec: GLOBAL_CONFIG.CC_STORAGE_SEARCH_POOL,
|
|
3907
3908
|
})))];
|
|
3908
3909
|
case 2:
|
|
3909
|
-
|
|
3910
|
+
_c.sent();
|
|
3910
3911
|
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " take indexed"), {
|
|
3911
3912
|
indexed: indexed.getEntries(),
|
|
3912
3913
|
});
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
})];
|
|
3914
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onSearch) {
|
|
3915
|
+
(_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onSearch(search, indexed, this.params.clientId, this.params.storageName);
|
|
3916
|
+
}
|
|
3917
|
+
return [2 /*return*/, indexed.take(total, score)];
|
|
3918
3918
|
}
|
|
3919
3919
|
});
|
|
3920
3920
|
});
|
|
@@ -5920,22 +5920,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5920
5920
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
5921
5921
|
* @template T
|
|
5922
5922
|
*/
|
|
5923
|
-
this.take = function (
|
|
5923
|
+
this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
5924
5924
|
return __generator(this, function (_a) {
|
|
5925
5925
|
switch (_a.label) {
|
|
5926
5926
|
case 0:
|
|
5927
5927
|
swarm.loggerService.log("StorageStatic take", {
|
|
5928
|
-
search: search,
|
|
5929
|
-
total: total,
|
|
5930
|
-
clientId: clientId,
|
|
5931
|
-
storageName: storageName,
|
|
5932
|
-
score: score,
|
|
5928
|
+
search: payload.search,
|
|
5929
|
+
total: payload.total,
|
|
5930
|
+
clientId: payload.clientId,
|
|
5931
|
+
storageName: payload.storageName,
|
|
5932
|
+
score: payload.score,
|
|
5933
5933
|
});
|
|
5934
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
5935
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
5936
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (take)"));
|
|
5934
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
5935
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5936
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
5937
5937
|
}
|
|
5938
|
-
return [4 /*yield*/, swarm.storagePublicService.take(search, total, clientId, storageName, score)];
|
|
5938
|
+
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, payload.clientId, payload.storageName, payload.score)];
|
|
5939
5939
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
5940
5940
|
}
|
|
5941
5941
|
});
|
|
@@ -5949,20 +5949,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5949
5949
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
5950
5950
|
* @template T
|
|
5951
5951
|
*/
|
|
5952
|
-
this.upsert = function (
|
|
5952
|
+
this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
5953
5953
|
return __generator(this, function (_a) {
|
|
5954
5954
|
switch (_a.label) {
|
|
5955
5955
|
case 0:
|
|
5956
5956
|
swarm.loggerService.log("StorageStatic upsert", {
|
|
5957
|
-
item: item,
|
|
5958
|
-
clientId: clientId,
|
|
5959
|
-
storageName: storageName,
|
|
5957
|
+
item: payload.item,
|
|
5958
|
+
clientId: payload.clientId,
|
|
5959
|
+
storageName: payload.storageName,
|
|
5960
5960
|
});
|
|
5961
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
5962
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
5963
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (upsert)"));
|
|
5961
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
5962
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5963
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
5964
5964
|
}
|
|
5965
|
-
return [4 /*yield*/, swarm.storagePublicService.upsert(item, clientId, storageName)];
|
|
5965
|
+
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, payload.clientId, payload.storageName)];
|
|
5966
5966
|
case 1: return [2 /*return*/, _a.sent()];
|
|
5967
5967
|
}
|
|
5968
5968
|
});
|
|
@@ -5975,20 +5975,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5975
5975
|
* @param {StorageName} storageName - The storage name.
|
|
5976
5976
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
5977
5977
|
*/
|
|
5978
|
-
this.remove = function (
|
|
5978
|
+
this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
5979
5979
|
return __generator(this, function (_a) {
|
|
5980
5980
|
switch (_a.label) {
|
|
5981
5981
|
case 0:
|
|
5982
5982
|
swarm.loggerService.log("StorageStatic remove", {
|
|
5983
|
-
itemId: itemId,
|
|
5984
|
-
clientId: clientId,
|
|
5985
|
-
storageName: storageName,
|
|
5983
|
+
itemId: payload.itemId,
|
|
5984
|
+
clientId: payload.clientId,
|
|
5985
|
+
storageName: payload.storageName,
|
|
5986
5986
|
});
|
|
5987
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
5988
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
5989
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (remove)"));
|
|
5987
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
5988
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5989
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
5990
5990
|
}
|
|
5991
|
-
return [4 /*yield*/, swarm.storagePublicService.remove(itemId, clientId, storageName)];
|
|
5991
|
+
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, payload.clientId, payload.storageName)];
|
|
5992
5992
|
case 1: return [2 /*return*/, _a.sent()];
|
|
5993
5993
|
}
|
|
5994
5994
|
});
|
|
@@ -6002,20 +6002,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6002
6002
|
* @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
|
|
6003
6003
|
* @template T
|
|
6004
6004
|
*/
|
|
6005
|
-
this.get = function (
|
|
6005
|
+
this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
6006
6006
|
return __generator(this, function (_a) {
|
|
6007
6007
|
switch (_a.label) {
|
|
6008
6008
|
case 0:
|
|
6009
6009
|
swarm.loggerService.log("StorageStatic get", {
|
|
6010
|
-
itemId: itemId,
|
|
6011
|
-
clientId: clientId,
|
|
6012
|
-
storageName: storageName,
|
|
6010
|
+
itemId: payload.itemId,
|
|
6011
|
+
clientId: payload.clientId,
|
|
6012
|
+
storageName: payload.storageName,
|
|
6013
6013
|
});
|
|
6014
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
6015
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
6016
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (get)"));
|
|
6014
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
6015
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6016
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
6017
6017
|
}
|
|
6018
|
-
return [4 /*yield*/, swarm.storagePublicService.get(itemId, clientId, storageName)];
|
|
6018
|
+
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, payload.clientId, payload.storageName)];
|
|
6019
6019
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
6020
6020
|
}
|
|
6021
6021
|
});
|
|
@@ -6029,19 +6029,19 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6029
6029
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
6030
6030
|
* @template T
|
|
6031
6031
|
*/
|
|
6032
|
-
this.list = function (
|
|
6032
|
+
this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
6033
6033
|
return __generator(this, function (_a) {
|
|
6034
6034
|
switch (_a.label) {
|
|
6035
6035
|
case 0:
|
|
6036
6036
|
swarm.loggerService.log("StorageStatic list", {
|
|
6037
|
-
clientId: clientId,
|
|
6038
|
-
storageName: storageName,
|
|
6037
|
+
clientId: payload.clientId,
|
|
6038
|
+
storageName: payload.storageName,
|
|
6039
6039
|
});
|
|
6040
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
6041
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
6042
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (list)"));
|
|
6040
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
6041
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6042
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
6043
6043
|
}
|
|
6044
|
-
return [4 /*yield*/, swarm.storagePublicService.list(clientId, storageName, filter)];
|
|
6044
|
+
return [4 /*yield*/, swarm.storagePublicService.list(payload.clientId, payload.storageName, payload.filter)];
|
|
6045
6045
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
6046
6046
|
}
|
|
6047
6047
|
});
|
|
@@ -6053,19 +6053,19 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6053
6053
|
* @param {StorageName} storageName - The storage name.
|
|
6054
6054
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
6055
6055
|
*/
|
|
6056
|
-
this.clear = function (
|
|
6056
|
+
this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
6057
6057
|
return __generator(this, function (_a) {
|
|
6058
6058
|
switch (_a.label) {
|
|
6059
6059
|
case 0:
|
|
6060
6060
|
swarm.loggerService.log("StorageStatic clear", {
|
|
6061
|
-
clientId: clientId,
|
|
6062
|
-
storageName: storageName,
|
|
6061
|
+
clientId: payload.clientId,
|
|
6062
|
+
storageName: payload.storageName,
|
|
6063
6063
|
});
|
|
6064
|
-
swarm.storageValidationService.validate(storageName, "StorageStatic");
|
|
6065
|
-
if (!swarm.agentValidationService.hasStorage(agentName, storageName)) {
|
|
6066
|
-
throw new Error("agent-swarm StorageUtils ".concat(storageName, " not registered in ").concat(agentName, " (clear)"));
|
|
6064
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageStatic");
|
|
6065
|
+
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6066
|
+
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
6067
6067
|
}
|
|
6068
|
-
return [4 /*yield*/, swarm.storagePublicService.clear(clientId, storageName)];
|
|
6068
|
+
return [4 /*yield*/, swarm.storagePublicService.clear(payload.clientId, payload.storageName)];
|
|
6069
6069
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6070
6070
|
}
|
|
6071
6071
|
});
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as di_scoped from 'di-scoped';
|
|
2
2
|
import * as functools_kit from 'functools-kit';
|
|
3
|
-
import { IPubsubArray, Subject } from 'functools-kit';
|
|
3
|
+
import { IPubsubArray, SortedArray, Subject } from 'functools-kit';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Interface representing an incoming message.
|
|
@@ -517,6 +517,7 @@ interface IStorageSchema<T extends IStorageData = IStorageData> {
|
|
|
517
517
|
}
|
|
518
518
|
interface IStorageCallbacks<T extends IStorageData = IStorageData> {
|
|
519
519
|
onUpdate: (items: T[], clientId: string, storageName: StorageName) => void;
|
|
520
|
+
onSearch: (search: string, index: SortedArray<T>, clientId: string, storageName: StorageName) => void;
|
|
520
521
|
}
|
|
521
522
|
interface IStorageParams<T extends IStorageData = IStorageData> extends IStorageSchema<T>, Partial<IEmbeddingCallbacks> {
|
|
522
523
|
clientId: string;
|
|
@@ -2570,7 +2571,14 @@ declare class StorageUtils implements TStorage {
|
|
|
2570
2571
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
2571
2572
|
* @template T
|
|
2572
2573
|
*/
|
|
2573
|
-
take: <T extends IStorageData = IStorageData>(
|
|
2574
|
+
take: <T extends IStorageData = IStorageData>(payload: {
|
|
2575
|
+
search: string;
|
|
2576
|
+
total: number;
|
|
2577
|
+
clientId: string;
|
|
2578
|
+
agentName: AgentName;
|
|
2579
|
+
storageName: StorageName;
|
|
2580
|
+
score?: number;
|
|
2581
|
+
}) => Promise<T[]>;
|
|
2574
2582
|
/**
|
|
2575
2583
|
* Upserts an item in the storage.
|
|
2576
2584
|
* @param {T} item - The item to upsert.
|
|
@@ -2580,7 +2588,12 @@ declare class StorageUtils implements TStorage {
|
|
|
2580
2588
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
2581
2589
|
* @template T
|
|
2582
2590
|
*/
|
|
2583
|
-
upsert: <T extends IStorageData = IStorageData>(
|
|
2591
|
+
upsert: <T extends IStorageData = IStorageData>(payload: {
|
|
2592
|
+
item: T;
|
|
2593
|
+
clientId: string;
|
|
2594
|
+
agentName: AgentName;
|
|
2595
|
+
storageName: StorageName;
|
|
2596
|
+
}) => Promise<void>;
|
|
2584
2597
|
/**
|
|
2585
2598
|
* Removes an item from the storage.
|
|
2586
2599
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
@@ -2589,7 +2602,12 @@ declare class StorageUtils implements TStorage {
|
|
|
2589
2602
|
* @param {StorageName} storageName - The storage name.
|
|
2590
2603
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
2591
2604
|
*/
|
|
2592
|
-
remove: (
|
|
2605
|
+
remove: (payload: {
|
|
2606
|
+
itemId: IStorageData["id"];
|
|
2607
|
+
clientId: string;
|
|
2608
|
+
agentName: AgentName;
|
|
2609
|
+
storageName: StorageName;
|
|
2610
|
+
}) => Promise<void>;
|
|
2593
2611
|
/**
|
|
2594
2612
|
* Gets an item from the storage.
|
|
2595
2613
|
* @param {IStorageData["id"]} itemId - The ID of the item to get.
|
|
@@ -2599,7 +2617,12 @@ declare class StorageUtils implements TStorage {
|
|
|
2599
2617
|
* @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
|
|
2600
2618
|
* @template T
|
|
2601
2619
|
*/
|
|
2602
|
-
get: <T extends IStorageData = IStorageData>(
|
|
2620
|
+
get: <T extends IStorageData = IStorageData>(payload: {
|
|
2621
|
+
itemId: IStorageData["id"];
|
|
2622
|
+
clientId: string;
|
|
2623
|
+
agentName: AgentName;
|
|
2624
|
+
storageName: StorageName;
|
|
2625
|
+
}) => Promise<T | null>;
|
|
2603
2626
|
/**
|
|
2604
2627
|
* Lists items from the storage.
|
|
2605
2628
|
* @param {string} clientId - The client ID.
|
|
@@ -2609,7 +2632,12 @@ declare class StorageUtils implements TStorage {
|
|
|
2609
2632
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
2610
2633
|
* @template T
|
|
2611
2634
|
*/
|
|
2612
|
-
list: <T extends IStorageData = IStorageData>(
|
|
2635
|
+
list: <T extends IStorageData = IStorageData>(payload: {
|
|
2636
|
+
clientId: string;
|
|
2637
|
+
agentName: AgentName;
|
|
2638
|
+
storageName: StorageName;
|
|
2639
|
+
filter?: (item: T) => boolean;
|
|
2640
|
+
}) => Promise<T[]>;
|
|
2613
2641
|
/**
|
|
2614
2642
|
* Clears the storage.
|
|
2615
2643
|
* @param {string} clientId - The client ID.
|
|
@@ -2617,7 +2645,11 @@ declare class StorageUtils implements TStorage {
|
|
|
2617
2645
|
* @param {StorageName} storageName - The storage name.
|
|
2618
2646
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
2619
2647
|
*/
|
|
2620
|
-
clear: (
|
|
2648
|
+
clear: (payload: {
|
|
2649
|
+
clientId: string;
|
|
2650
|
+
agentName: AgentName;
|
|
2651
|
+
storageName: StorageName;
|
|
2652
|
+
}) => Promise<void>;
|
|
2621
2653
|
}
|
|
2622
2654
|
declare const Storage: StorageUtils;
|
|
2623
2655
|
|